From baa30ca590255f7da6aefd8c9bcd318a4fcebf9f Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Thu, 1 Oct 2026 08:18:01 -0400 Subject: [PATCH] =?UTF-8?q?M0.12:=20web=20persistence=20=E2=80=94=20librar?= =?UTF-8?q?y,=20edits=20and=20imported=20originals=20survive=20a=20reload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The catalog Store on the web is an in-memory mirror (apps/lightcraft-web/src/files.rs) loaded from browser storage at start-up and flushed in the background in modification order (so a snapshot always lands before the log reset that follows it). Storage is OPFS when writable from the main thread (createWritable), else IndexedDB (?store=idb forces it); ?reset clears it. Imported originals are stored as originals/ and referenced as web//; the main thread keeps a bounded memory cache and loads misses (and the active photo) asynchronously. view.json and ui.json are saved every second when changed. Engine: Session::open_library_in(LibraryStores) opens a library from any Store (presets, view and prefs go through it too); Session::save_view; Copy imports into a non-disk library add. JS automation API: lightcraft.command(id, paramsJson) (+ web.stats). Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 2 + apps/lightcraft-web/Cargo.toml | 28 +++ apps/lightcraft-web/index.html | 12 +- apps/lightcraft-web/src/backend.rs | 324 ++++++++++++++++++++++++++++ apps/lightcraft-web/src/bench.rs | 2 +- apps/lightcraft-web/src/files.rs | 255 ++++++++++++++++++++++ apps/lightcraft-web/src/lib.rs | 20 +- apps/lightcraft-web/src/store.rs | 194 ++++++++++++----- apps/lightcraft-web/src/web.rs | 327 ++++++++++++++++++++++++++--- crates/engine/src/import.rs | 5 +- crates/engine/src/library.rs | 91 ++++++-- 11 files changed, 1147 insertions(+), 113 deletions(-) create mode 100644 apps/lightcraft-web/src/backend.rs create mode 100644 apps/lightcraft-web/src/files.rs diff --git a/Cargo.lock b/Cargo.lock index 8ff6fc3ef..20ae00caf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2229,9 +2229,11 @@ dependencies = [ "js-sys", "lightcraft-codecs", "lightcraft-engine", + "lightcraft-preview", "lightcraft-raster", "lightcraft-ui-egui", "log", + "serde", "serde_json", "wasm-bindgen", "wasm-bindgen-futures", diff --git a/apps/lightcraft-web/Cargo.toml b/apps/lightcraft-web/Cargo.toml index b9c7bdf23..1f9f14c13 100644 --- a/apps/lightcraft-web/Cargo.toml +++ b/apps/lightcraft-web/Cargo.toml @@ -17,6 +17,8 @@ lightcraft-engine = { workspace = true } lightcraft-ui-egui = { workspace = true } lightcraft-codecs = { workspace = true } lightcraft-raster = { workspace = true } +lightcraft-preview = { workspace = true } +serde = { workspace = true } serde_json = { workspace = true } log = { workspace = true } @@ -29,16 +31,42 @@ js-sys = { workspace = true } web-sys = { workspace = true, features = [ "Blob", "BlobPropertyBag", + "DedicatedWorkerGlobalScope", "Document", + "DomStringList", "Element", + "EventTarget", "File", "FileList", + "FileSystemCreateWritableOptions", + "FileSystemDirectoryHandle", + "FileSystemFileHandle", + "FileSystemGetDirectoryOptions", + "FileSystemGetFileOptions", + "FileSystemRemoveOptions", + "FileSystemWritableFileStream", "HtmlAnchorElement", "HtmlCanvasElement", "HtmlElement", "HtmlInputElement", + "IdbDatabase", + "IdbFactory", + "IdbKeyRange", + "IdbObjectStore", + "IdbOpenDbRequest", + "IdbRequest", + "IdbTransaction", + "IdbTransactionMode", + "IdbVersionChangeEvent", "Location", + "MessageEvent", + "Navigator", "Performance", + "StorageManager", "Url", "Window", + "Worker", + "WorkerOptions", + "WorkerType", + "WritableStream", ] } diff --git a/apps/lightcraft-web/index.html b/apps/lightcraft-web/index.html index ac1ed167a..bc0ad2037 100644 --- a/apps/lightcraft-web/index.html +++ b/apps/lightcraft-web/index.html @@ -22,8 +22,16 @@
Loading LightCraft…