From 6385c1dd7ef9ea5bcf8ce6fe2010da9934cf594e Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Fri, 30 Oct 2026 21:37:16 -0400 Subject: [PATCH] Add the app shell (D17) and the Loro decision (D16) The app shell is a layout tree of splits and tab stacks. VS Code's parts are slot tags on stacks, so any panel can go anywhere. Panels are views over files, processes, and conversations: explorer, editor, preview, terminal, and agent. Every change is a command applied by a pure reducer, and named shell commands back the keybindings. The DOM renderer never reparents panel bodies, so a moved preview iframe keeps its document. A Vite playground persists the layout. Also brings D16 and its CRDT bakeoff probes from nmoo/app/crdt-realtime, which the shell branch was cut from. --- docs/VISION.md | 88 +- packages/app/.gitignore | 3 + packages/app/package.json | 24 + packages/app/playground/index.html | 16 + packages/app/playground/main.ts | 47 + packages/app/playwright.config.ts | 15 + packages/app/src/shell/commands.ts | 78 + packages/app/src/shell/dom/render.ts | 299 +++ packages/app/src/shell/dom/shell.css | 84 + packages/app/src/shell/dom/views.ts | 172 ++ packages/app/src/shell/index.ts | 4 + packages/app/src/shell/kinds.ts | 46 + packages/app/src/shell/layout.ts | 338 ++++ packages/app/src/shell/workbench.ts | 127 ++ packages/app/tests/shell.spec.ts | 99 + packages/app/tests/shell.test.ts | 193 ++ packages/app/tsconfig.json | 15 + pnpm-lock.yaml | 15 + probes/crdt/.gitignore | 7 + probes/crdt/correctness/RESULTS.md | 191 ++ .../crdt/correctness/adapters/automerge.mjs | 128 ++ probes/crdt/correctness/adapters/loro.mjs | 140 ++ probes/crdt/correctness/adapters/yjs13.mjs | 134 ++ probes/crdt/correctness/adapters/yjs14.mjs | 135 ++ probes/crdt/correctness/case1.mjs | 196 ++ probes/crdt/correctness/case2.mjs | 229 +++ probes/crdt/correctness/case5.mjs | 167 ++ probes/crdt/correctness/out/case1.txt | 72 + probes/crdt/correctness/out/case2.txt | 153 ++ probes/crdt/correctness/out/case5.txt | 35 + probes/crdt/correctness/out/downloads.txt | 12 + probes/crdt/correctness/out/npmview.txt | 56 + probes/crdt/correctness/package-lock.json | 1065 +++++++++++ probes/crdt/correctness/package.json | 26 + probes/crdt/perf/RESULTS.md | 241 +++ probes/crdt/perf/bench.mjs | 107 ++ .../perf/entries/automerge-slim.entry.mjs | 10 + .../perf/entries/automerge-worker.entry.mjs | 5 + probes/crdt/perf/entries/automerge.entry.mjs | 7 + probes/crdt/perf/entries/guest-automerge.mjs | 12 + probes/crdt/perf/entries/guest-loro.mjs | 12 + probes/crdt/perf/entries/guest-yjs.mjs | 11 + probes/crdt/perf/entries/guest-yy.mjs | 11 + .../crdt/perf/entries/loro-bundler.entry.mjs | 2 + .../crdt/perf/entries/loro-worker.entry.mjs | 5 + probes/crdt/perf/entries/loro.entry.mjs | 7 + probes/crdt/perf/entries/yjs-worker.entry.mjs | 5 + probes/crdt/perf/entries/yjs.entry.mjs | 6 + probes/crdt/perf/entries/yy-worker.entry.mjs | 5 + probes/crdt/perf/entries/yy.entry.mjs | 6 + probes/crdt/perf/gen-snapshots.mjs | 13 + probes/crdt/perf/libs/automerge.mjs | 28 + probes/crdt/perf/libs/loro.mjs | 32 + probes/crdt/perf/libs/yjs.mjs | 27 + probes/crdt/perf/libs/yy.mjs | 27 + probes/crdt/perf/package-lock.json | 1665 +++++++++++++++++ probes/crdt/perf/package.json | 17 + probes/crdt/perf/playwright.config.mjs | 16 + probes/crdt/perf/quicktest-am.mjs | 8 + probes/crdt/perf/quicktest.mjs | 13 + probes/crdt/perf/results/automerge-10k.err | 0 probes/crdt/perf/results/automerge-10k.json | 43 + probes/crdt/perf/results/automerge-full.err | 0 probes/crdt/perf/results/automerge-full.json | 43 + .../crdt/perf/results/browser-automerge.json | 57 + probes/crdt/perf/results/browser-loro.json | 57 + probes/crdt/perf/results/browser-yjs.json | 57 + probes/crdt/perf/results/browser-yy.json | 57 + probes/crdt/perf/results/bundle-sizes.csv | 6 + probes/crdt/perf/results/loro-10k.err | 0 probes/crdt/perf/results/loro-10k.json | 43 + probes/crdt/perf/results/loro-full.err | 0 probes/crdt/perf/results/loro-full.json | 43 + probes/crdt/perf/results/wasm-sizes.csv | 9 + probes/crdt/perf/results/yjs-10k.err | 0 probes/crdt/perf/results/yjs-10k.json | 43 + probes/crdt/perf/results/yjs-full.err | 0 probes/crdt/perf/results/yjs-full.json | 43 + probes/crdt/perf/results/yy-10k.err | 0 probes/crdt/perf/results/yy-10k.json | 43 + probes/crdt/perf/results/yy-full.err | 0 probes/crdt/perf/results/yy-full.json | 43 + probes/crdt/perf/size-bundles.sh | 27 + probes/crdt/perf/size-wasm.sh | 20 + probes/crdt/perf/trace.mjs | 19 + probes/crdt/perf/web/index.html | 14 + probes/crdt/perf/web/server.mjs | 28 + .../crdt/perf/web/snapshots/automerge-10k.bin | Bin 0 -> 6939 bytes probes/crdt/perf/web/snapshots/loro-10k.bin | Bin 0 -> 14101 bytes probes/crdt/perf/web/snapshots/yjs-10k.bin | Bin 0 -> 15905 bytes probes/crdt/perf/web/snapshots/yy-10k.bin | Bin 0 -> 19079 bytes probes/crdt/perf/web/worker.mjs | 43 + probes/crdt/perf/worker-bench.spec.mjs | 16 + probes/crdt/perf/workerd/gen-dynamic.mjs | 57 + probes/crdt/perf/workerd/src/dynamic.js | 33 + probes/crdt/perf/workerd/src/index.js | 78 + probes/crdt/perf/workerd/wrangler.jsonc | 9 + 97 files changed, 7634 insertions(+), 4 deletions(-) create mode 100644 packages/app/.gitignore create mode 100644 packages/app/package.json create mode 100644 packages/app/playground/index.html create mode 100644 packages/app/playground/main.ts create mode 100644 packages/app/playwright.config.ts create mode 100644 packages/app/src/shell/commands.ts create mode 100644 packages/app/src/shell/dom/render.ts create mode 100644 packages/app/src/shell/dom/shell.css create mode 100644 packages/app/src/shell/dom/views.ts create mode 100644 packages/app/src/shell/index.ts create mode 100644 packages/app/src/shell/kinds.ts create mode 100644 packages/app/src/shell/layout.ts create mode 100644 packages/app/src/shell/workbench.ts create mode 100644 packages/app/tests/shell.spec.ts create mode 100644 packages/app/tests/shell.test.ts create mode 100644 packages/app/tsconfig.json create mode 100644 probes/crdt/.gitignore create mode 100644 probes/crdt/correctness/RESULTS.md create mode 100644 probes/crdt/correctness/adapters/automerge.mjs create mode 100644 probes/crdt/correctness/adapters/loro.mjs create mode 100644 probes/crdt/correctness/adapters/yjs13.mjs create mode 100644 probes/crdt/correctness/adapters/yjs14.mjs create mode 100644 probes/crdt/correctness/case1.mjs create mode 100644 probes/crdt/correctness/case2.mjs create mode 100644 probes/crdt/correctness/case5.mjs create mode 100644 probes/crdt/correctness/out/case1.txt create mode 100644 probes/crdt/correctness/out/case2.txt create mode 100644 probes/crdt/correctness/out/case5.txt create mode 100644 probes/crdt/correctness/out/downloads.txt create mode 100644 probes/crdt/correctness/out/npmview.txt create mode 100644 probes/crdt/correctness/package-lock.json create mode 100644 probes/crdt/correctness/package.json create mode 100644 probes/crdt/perf/RESULTS.md create mode 100644 probes/crdt/perf/bench.mjs create mode 100644 probes/crdt/perf/entries/automerge-slim.entry.mjs create mode 100644 probes/crdt/perf/entries/automerge-worker.entry.mjs create mode 100644 probes/crdt/perf/entries/automerge.entry.mjs create mode 100644 probes/crdt/perf/entries/guest-automerge.mjs create mode 100644 probes/crdt/perf/entries/guest-loro.mjs create mode 100644 probes/crdt/perf/entries/guest-yjs.mjs create mode 100644 probes/crdt/perf/entries/guest-yy.mjs create mode 100644 probes/crdt/perf/entries/loro-bundler.entry.mjs create mode 100644 probes/crdt/perf/entries/loro-worker.entry.mjs create mode 100644 probes/crdt/perf/entries/loro.entry.mjs create mode 100644 probes/crdt/perf/entries/yjs-worker.entry.mjs create mode 100644 probes/crdt/perf/entries/yjs.entry.mjs create mode 100644 probes/crdt/perf/entries/yy-worker.entry.mjs create mode 100644 probes/crdt/perf/entries/yy.entry.mjs create mode 100644 probes/crdt/perf/gen-snapshots.mjs create mode 100644 probes/crdt/perf/libs/automerge.mjs create mode 100644 probes/crdt/perf/libs/loro.mjs create mode 100644 probes/crdt/perf/libs/yjs.mjs create mode 100644 probes/crdt/perf/libs/yy.mjs create mode 100644 probes/crdt/perf/package-lock.json create mode 100644 probes/crdt/perf/package.json create mode 100644 probes/crdt/perf/playwright.config.mjs create mode 100644 probes/crdt/perf/quicktest-am.mjs create mode 100644 probes/crdt/perf/quicktest.mjs create mode 100644 probes/crdt/perf/results/automerge-10k.err create mode 100644 probes/crdt/perf/results/automerge-10k.json create mode 100644 probes/crdt/perf/results/automerge-full.err create mode 100644 probes/crdt/perf/results/automerge-full.json create mode 100644 probes/crdt/perf/results/browser-automerge.json create mode 100644 probes/crdt/perf/results/browser-loro.json create mode 100644 probes/crdt/perf/results/browser-yjs.json create mode 100644 probes/crdt/perf/results/browser-yy.json create mode 100644 probes/crdt/perf/results/bundle-sizes.csv create mode 100644 probes/crdt/perf/results/loro-10k.err create mode 100644 probes/crdt/perf/results/loro-10k.json create mode 100644 probes/crdt/perf/results/loro-full.err create mode 100644 probes/crdt/perf/results/loro-full.json create mode 100644 probes/crdt/perf/results/wasm-sizes.csv create mode 100644 probes/crdt/perf/results/yjs-10k.err create mode 100644 probes/crdt/perf/results/yjs-10k.json create mode 100644 probes/crdt/perf/results/yjs-full.err create mode 100644 probes/crdt/perf/results/yjs-full.json create mode 100644 probes/crdt/perf/results/yy-10k.err create mode 100644 probes/crdt/perf/results/yy-10k.json create mode 100644 probes/crdt/perf/results/yy-full.err create mode 100644 probes/crdt/perf/results/yy-full.json create mode 100755 probes/crdt/perf/size-bundles.sh create mode 100755 probes/crdt/perf/size-wasm.sh create mode 100644 probes/crdt/perf/trace.mjs create mode 100644 probes/crdt/perf/web/index.html create mode 100644 probes/crdt/perf/web/server.mjs create mode 100644 probes/crdt/perf/web/snapshots/automerge-10k.bin create mode 100644 probes/crdt/perf/web/snapshots/loro-10k.bin create mode 100644 probes/crdt/perf/web/snapshots/yjs-10k.bin create mode 100644 probes/crdt/perf/web/snapshots/yy-10k.bin create mode 100644 probes/crdt/perf/web/worker.mjs create mode 100644 probes/crdt/perf/worker-bench.spec.mjs create mode 100644 probes/crdt/perf/workerd/gen-dynamic.mjs create mode 100644 probes/crdt/perf/workerd/src/dynamic.js create mode 100644 probes/crdt/perf/workerd/src/index.js create mode 100644 probes/crdt/perf/workerd/wrangler.jsonc diff --git a/docs/VISION.md b/docs/VISION.md index 83c8a35..2de5b35 100644 --- a/docs/VISION.md +++ b/docs/VISION.md @@ -313,24 +313,104 @@ Build order, each step useful alone: Hosting Spaces comes before hosting PDSes. A PDS host takes on identity custody (signing keys, account recovery, email), uptime, takedown and abuse duties, and federation limits on new hosts. A Space host gets most of the benefit without them. One rule holds for every step: runners, hooks, and deploys must work for users whose PDS nibling does not host. Hosting is a convenience, never a requirement. +### D16. Live files sync through Loro: a doc per file and a tree per space + +Source files (D5) sync live through [Loro](https://loro.dev) (`loro-crdt`). Each file is its own Loro doc, keyed by the file's stable identity. Each space's namespace is one more Loro doc whose `LoroTree` maps names to those identities. A sandbox loads only the docs it mounts (D4), and each space syncs on its own. One doc per tree would break both, because part of a doc cannot be synced. + +A bakeoff on 2026-10-30 compared Loro 1.17.1, Yjs 13.6.33, Yjs 14.0.0-rc.7 (`@y/y`) and Automerge 3.5.0. It ran on an Apple M1 with the 259,778-edit `automerge-paper` trace from josephg/editing-traces, and every library reproduced the trace's final text. Medians of 5 runs: + +| | Loro | Yjs 13 | Yjs 14 RC | Automerge | +|---|---|---|---|---| +| Apply the full trace | 573 ms | 2.35 s | 15.8 s | 29.2 s | +| Load the full-trace snapshot | 0.8 ms | 22 ms | 41 ms | 862 ms | +| Snapshot size (full / shallow) | 251 / 65 KB | 311 KB | 377 KB | 129 KB | +| Cold start in a Web Worker (Chromium) | 19 ms | 7 ms | 9 ms | 290 ms | +| Transfer size, brotli (JS + wasm) | 852 KB | 20 KB | 26 KB | 802 KB | +| Concurrent move cycle stays a tree | yes | no | no | no | +| Plain Worker in workerd | yes | yes | yes | yes | +| Dynamic Worker, `globalOutbound: null` | yes | yes | yes | no | +| CodeMirror 6 binding round-trips | yes | yes | no | yes | + +Loro wins on the two things nibling cannot work around. Its tree has a real move operation and keeps the namespace acyclic when two people move folders into each other. Yjs and Automerge have no move, so a parent-pointer map ends in a cycle cut off from root, and nibling would have to write and maintain the repair. Loro is also the fastest to apply and to open. Its cost is about 840 KB of brotli wasm and 12 ms more worker start-up than Yjs. Under D4 the wasm is a pinned, content-addressed mount, so a user downloads it once. + +Rejected: + +- Automerge: about 50 times slower than Loro on the full trace, a 290 ms cold start, and its wasm fails to start in a Dynamic Worker with `internal error; reference = …`. The cause was not investigated. +- Yjs 14 RC: 7 times slower than Yjs 13 on the full trace, and `y-codemirror.next` throws `Not same Y.Doc` against it. Its API is a new generic `YType` with deltas, not `Y.Text` or `Y.Map`. +- Yjs 13 is the fallback if bundle size ever matters more than tree moves. + +Consequences: + +- A write is applied against the version its writer read. A whole-file write such as `fs.writeFile` from an agent is diffed into edits. If the diff is taken against the current text, it deletes edits that arrived after the writer read the file. The bakeoff showed this in all four libraries. So the kernel records, per process and file, the Loro frontiers the process last read. A write forks the doc at those frontiers (`forkAt`), applies `LoroText.update(newText)`, and merges the result. Concurrent typing then survives. A write from a process that never read the file replaces the current text. This is part of the D5 journal format. +- Names are not unique in the CRDT. Two people who rename different files to the same name in one directory get two tree nodes with that name. The filesystem layer shows both under deterministic distinct names. +- A record's body stays the plain lexicon value, so any atproto app can read it. Loro state is stored beside the record, not in it. Where it is stored is an open question. +- Opening a file loads a shallow snapshot (65 KB for the full trace, against 251 KB with history), and history loads on demand. +- The browser uses `loro-crdt/web` with its wasm as a separate file. A plain Worker uses `loro-crdt/bundler`, which wrangler bundles as a wasm-module import. A Dynamic Worker receives the wasm as a `WebAssembly.Module` in the loader's module map. workerd cannot compile wasm from bytes at run time, so these are the only paths that work there. +- Editors bind through `loro-codemirror`. Its default text lookup uses the key `"codemirror"`, and the editor must mount empty and let the plugin sync the initial text. Otherwise it desyncs silently, then crashes. nibling's editor wrapper enforces both. A ProseMirror binding (`loro-prosemirror`) for Docs has not been tested yet. +- The relay does not need to understand Loro. It forwards updates by doc identity, so the relay transport question is unaffected. + +The probe code and full results are in `probes/crdt/` (`correctness/RESULTS.md` and `perf/RESULTS.md`). + +### D17. The app shell is a layout tree of panels, and every change is a command + +The app shell is the OS shell on the top-level origin (D10). It arranges panels the way VS Code does: an explorer on the left, editors in the middle, a terminal below them, and an agent conversation on the right. Each panel is a view over a file, a process, or a conversation (D11). The shell owns where panels are. It does not own what they show. + +The layout is one tree. A split holds children along an axis with fractional sizes, and a stack holds tabbed panels with one active. A panel is `{ id, kind, input }`, and its input names what it views: + +| Kind | Input | Identity | Home slot | Renders on | +|---|---|---|---|---| +| `explorer` | `root` | the root | `primary` | chrome | +| `editor` | `path` | the path | `main` | a sandbox (the app that edits the file) | +| `preview` | `path` | the path | `main` | a sandbox (guest HTTP) | +| `terminal` | `cwd`, `session` | the session | `panel` | chrome (it draws bytes, never guest DOM) | +| `agent` | `conversation` | the conversation | `secondary` | chrome (it draws a transcript file) | + +Opening a panel whose identity is already open activates the existing one, so `open a.md` twice gives one tab. Apps add kinds by augmenting the `PanelInputs` type. + +VS Code's parts (side bars, editor area, panel) are tags on stacks, not separate regions. A stack can carry a slot: `main`, `primary`, `secondary`, or `panel`. A kind opens into its home slot. Toggling a slot hides its stack and keeps its size. Closing a slot's last panel removes the stack, and the next open recreates it on that slot's edge, with the panel spanning the whole editor area. Because every part is the same kind of node, any panel can go anywhere, and one move algorithm covers tabs, splits, and parts. VS Code has two layout systems, and it had to add "terminal in the editor area" as a separate feature. + +Considered and rejected: fixed parts with an editor grid inside, as VS Code builds them. Toggling is simpler in that model, but it splits the layout into two systems. + +Every change is a `Command` (`open`, `close`, `activate`, `move`, `resize`, `toggle`, `focus`) applied by a pure reducer, so the shell has a headless core (D12). Named shell commands such as `layout.toggle.panel` and `panel.split.right` wrap commands for keybindings, a palette, and a `nib shell` CLI. The playground's terminal has an `open` command to show that a shell drives the same commands as the GUI. + +The layout belongs to one viewer and is not shared. Two collaborators in one space each arrange their own panels, so the layout is plain JSON, not a CRDT. What collaborators share is the files the panels view (D16). Who has which file open is presence and goes through the relay. Stored layouts are parsed at the boundary. A layout that fails a check is discarded for the default, and panels that no stack shows are dropped. + +The DOM renderer rebuilds the tree of splits, tab bars, and gutters only when the structure changes. Focus and the active tab are repainted in place, so a pointerdown that focuses a stack keeps the element under the pointer. Panel bodies are never reparented. Each body is created once and positioned in one layer over its stack's content area, because moving an iframe in the DOM reloads it. `Element.moveBefore()` preserves iframe state in Chromium 133 and Firefox 144, but not in Safari. A Playwright test moves a preview between stacks and checks that its document survives. + +Code: `packages/app/src/shell/` (`layout.ts` is the model and reducer, `workbench.ts` the store and the storage parser, `commands.ts` the named commands, `dom/` the renderer, stock views, and structural CSS). Run `pnpm --filter @nibling/app dev` for the playground. + +Still stubbed: + +- The stock views read an in-memory `Files` interface. The kernel filesystem and Loro docs (D16) replace it. The editor is a textarea until the CodeMirror and Loro binding lands. +- The terminal is a line shell with `ls`, `cat`, `open`, and `preview`. bashkit from `examples/slopbox` replaces it. +- The agent panel appends messages to `.agents/.json` and calls no model (D8). +- Sandbox-origin panels render in-page. The preview uses an opaque-origin `srcdoc` iframe as a stand-in for a sandbox origin (D3). +- Clicks inside an iframe do not move focus to its stack, because iframes swallow pointer events. Window `blur` with `document.activeElement` can detect them. +- There is no command palette UI, no arrow-key navigation between tabs, and no panel maximize yet. + ## Where the code stands | Area | State | Gap | |---|---|---| | ESM | Native module loading over the Service Worker virtual origin | Default process runtime is Node (D2) | | Kernel | Single filesystem owner behind a typed syscall table | Objects have no stable identity (D5); no permissions (D3) | -| Persistence | In-memory store | Sync format before OPFS (D5) | +| Persistence | In-memory store | Sync format before OPFS (D5), built on Loro (D16) | | Resolver | One scheme check for `node:` | Add `nib:` | | Previews | Guest HTTP through the Service Worker and kernel port table | Per-sandbox origins (D3), `nib:browser` (D7) | | Shell | bashkit in `examples/slopbox` | Same permission checks as code mode (D7) | -| Packages | `app`, `sdk`, `api`, `docs`, `www`, `design-system` are empty | Everything above tier 1 | +| App shell | Layout tree, commands, and DOM renderer in `packages/app/src/shell` (D17) | Views bound to the kernel and Loro; sandbox-origin panels | +| Packages | `sdk`, `api`, `docs`, `www`, `design-system` are empty | Everything above tier 1 | ## Open questions - Sandbox origins: which registrable domain hosts them? (CSP on Service Worker responses does apply to workers; see D3.) - Spaces: what is the encryption model, and how does a record move between a public repo and a Space? - Links whose record a collaborator deleted: dangling, tombstoned, or pruned? -- Which CRDT, and is it per file or per tree? +- Where is a record's Loro state stored: a blob the record references, the space host, or both? (D16 chose the CRDT.) +- How should the filesystem name two nodes that end up with the same name in one directory (D16)? +- Does `loro-prosemirror` work for Docs? +- Where does a viewer's shell layout live: a private record per space, one per device, or both (D17)? +- How does an app declare its panel kinds: in its sandbox manifest, beside the lexicons it opens (D11, D17)? - Relay transport: a WebSocket per space, or WebRTC with signaling? - Runner protocol and discovery: a DID service entry, a workspace record field, or both? - Runner isolation: Deno processes, V8 isolates (workerd), or both? How are a runner's isolates limited for CPU and memory? @@ -355,5 +435,5 @@ Hosting Spaces comes before hosting PDSes. A PDS host takes on identity custody 3. Done 2026-10-30 (see D3): the sandbox-origin probe passed in all three engines. Real Safari 27.0 also passed on its default feature flags. Follow-ups are Service Worker restarts. The `server.ts` header options are done. 4. Done 2026-10-30: `exec(entry, { runtime: "web" | "node" })`, default `node` (commits 73c2a4b, de60485). Follow-up done the same day: the kernel read the runtime worker's own channel as well as its private port, so guest `postMessage` could forge runtime messages; it now reads only the port. A guest `close()` in a `web` process now exits it with code 0 after the current task, as `close()` ends a worker. Node globals for npm packages inside a `web` process, and flipping the default, come later. 5. Add the `nib:` scheme with a scoped `nib:fs` and `nib:context`, and generate their types. -6. Design the store and namespace format (D5), then build OPFS on it. +6. Design the store and namespace format (D5) on Loro (D16), including writes applied against the version their writer read, then build OPFS on it. 7. Build Drive on that format. diff --git a/packages/app/.gitignore b/packages/app/.gitignore new file mode 100644 index 0000000..21fe9b8 --- /dev/null +++ b/packages/app/.gitignore @@ -0,0 +1,3 @@ +/node_modules +/test-results/ +/playwright-report/ diff --git a/packages/app/package.json b/packages/app/package.json new file mode 100644 index 0000000..cd3cd4b --- /dev/null +++ b/packages/app/package.json @@ -0,0 +1,24 @@ +{ + "name": "@nibling/app", + "private": true, + "type": "module", + "version": "0.0.1", + "exports": { + "./shell": "./src/shell/index.ts", + "./shell/dom": "./src/shell/dom/render.ts" + }, + "scripts": { + "dev": "vite playground", + "test": "node --test 'tests/**/*.test.ts' && playwright test", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "@playwright/test": "^1.50.0", + "@types/node": "^24.0.0", + "typescript": "^5.7.0", + "vite": "^7.3.7" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/packages/app/playground/index.html b/packages/app/playground/index.html new file mode 100644 index 0000000..c38ff67 --- /dev/null +++ b/packages/app/playground/index.html @@ -0,0 +1,16 @@ + + + + + + nibling shell + + + +
+ + + diff --git a/packages/app/playground/main.ts b/packages/app/playground/main.ts new file mode 100644 index 0000000..ed48aca --- /dev/null +++ b/packages/app/playground/main.ts @@ -0,0 +1,47 @@ +import "../src/shell/dom/shell.css"; +import { mainStack, parseLayout, Workbench } from "../src/shell/index.ts"; +import { bindKeys, renderWorkbench } from "../src/shell/dom/render.ts"; +import { memoryFiles, stockViews } from "../src/shell/dom/views.ts"; + +const STORAGE_KEY = "nib.shell.layout"; + +const files = memoryFiles({ + "index.html": "\n

Hello from nibling

\n

Edit index.html and this preview updates.

\n", + "README.md": "# Playground\n\nDrag tabs to split, drag gutters to resize, Mod+B / Mod+J / Mod+Alt+B to toggle parts.\n", + "style.css": "h1 { color: rebeccapurple; }\n", +}); + +function stored() { + try { + return parseLayout(JSON.parse(localStorage.getItem(STORAGE_KEY) ?? "null")); + } catch { + return undefined; + } +} + +const layout = new URLSearchParams(location.search).has("reset") ? undefined : stored(); +const workbench = new Workbench(layout ? { layout } : {}); + +if (!layout) { + workbench.open({ kind: "explorer", input: { root: "/" } }); + workbench.open({ kind: "editor", input: { path: "index.html" } }); + workbench.open({ kind: "editor", input: { path: "README.md" } }); + workbench.open( + { kind: "preview", input: { path: "index.html" } }, + { beside: mainStack(workbench.layout.root).id, edge: "right" }, + ); + workbench.open({ kind: "terminal", input: { cwd: "/", session: "default" } }); + workbench.open({ kind: "agent", input: { conversation: "default" } }); +} + +workbench.subscribe((next) => { + try { + localStorage.setItem(STORAGE_KEY, JSON.stringify(next)); + } catch { + // Storage is a convenience here; the shell works without it. + } +}); + +renderWorkbench(document.getElementById("shell")!, workbench, stockViews(files)); +bindKeys(window, workbench); +Object.assign(globalThis, { workbench }); diff --git a/packages/app/playwright.config.ts b/packages/app/playwright.config.ts new file mode 100644 index 0000000..32ea2bc --- /dev/null +++ b/packages/app/playwright.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from "@playwright/test"; + +const port = 8941; + +export default defineConfig({ + testDir: "tests", + testMatch: "**/*.spec.ts", + use: { baseURL: `http://localhost:${port}` }, + webServer: { + command: `vite playground --port ${port} --strictPort`, + port, + // Reusing a server on this port could test another checkout's playground. + reuseExistingServer: false, + }, +}); diff --git a/packages/app/src/shell/commands.ts b/packages/app/src/shell/commands.ts new file mode 100644 index 0000000..3b1a3fa --- /dev/null +++ b/packages/app/src/shell/commands.ts @@ -0,0 +1,78 @@ +import { findNode, type Stack } from "./layout.ts"; +import type { Workbench } from "./workbench.ts"; + +/** + * A named shell action (D12). The same table backs keybindings, a command palette, and the + * `nib shell ` command an agent would call. Keys use `Mod` for Cmd on macOS and Ctrl elsewhere. + */ +export interface ShellCommand { + readonly id: string; + readonly title: string; + readonly keys?: string; + readonly run: (workbench: Workbench) => void; +} + +/** The stack that has focus, which commands without an explicit target act on. */ +export function focusedStack(workbench: Workbench): Stack { + const node = findNode(workbench.layout.root, workbench.layout.focus); + if (node?.type !== "stack") throw new Error("focus does not point at a stack"); + return node; +} + +function activePanel(workbench: Workbench) { + return focusedStack(workbench).active; +} + +export const commands: readonly ShellCommand[] = [ + { id: "view.explorer", title: "Show Explorer", keys: "Mod+Shift+E", run: (wb) => void wb.open({ kind: "explorer", input: { root: "/" } }) }, + { + id: "view.terminal.new", + title: "New Terminal", + keys: "Ctrl+Shift+`", + run: (wb) => void wb.open({ kind: "terminal", input: { cwd: "/", session: wb.env.id() } }), + }, + { + id: "view.agent.new", + title: "New Agent Conversation", + keys: "Mod+Shift+I", + run: (wb) => void wb.open({ kind: "agent", input: { conversation: wb.env.id() } }), + }, + { id: "layout.toggle.primary", title: "Toggle Primary Side Bar", keys: "Mod+B", run: (wb) => wb.dispatch({ type: "toggle", slot: "primary" }) }, + { id: "layout.toggle.secondary", title: "Toggle Secondary Side Bar", keys: "Mod+Alt+B", run: (wb) => wb.dispatch({ type: "toggle", slot: "secondary" }) }, + { id: "layout.toggle.panel", title: "Toggle Panel", keys: "Mod+J", run: (wb) => wb.dispatch({ type: "toggle", slot: "panel" }) }, + { + id: "panel.close", + title: "Close Panel", + // Browsers reserve Mod+W, so the web shell cannot claim it. + keys: "Alt+W", + run: (wb) => { + const panel = activePanel(wb); + if (panel) wb.dispatch({ type: "close", panel }); + }, + }, + { + id: "panel.split.right", + title: "Move Panel to a New Group on the Right", + keys: "Mod+\\", + run: (wb) => { + const stack = focusedStack(wb); + if (stack.active && stack.panels.length > 1) { + wb.dispatch({ type: "move", panel: stack.active, to: { beside: stack.id, edge: "right" } }); + } + }, + }, + { + id: "panel.split.down", + title: "Move Panel to a New Group Below", + run: (wb) => { + const stack = focusedStack(wb); + if (stack.active && stack.panels.length > 1) { + wb.dispatch({ type: "move", panel: stack.active, to: { beside: stack.id, edge: "bottom" } }); + } + }, + }, +]; + +export function command(id: string): ShellCommand | undefined { + return commands.find((c) => c.id === id); +} diff --git a/packages/app/src/shell/dom/render.ts b/packages/app/src/shell/dom/render.ts new file mode 100644 index 0000000..bfdb4fa --- /dev/null +++ b/packages/app/src/shell/dom/render.ts @@ -0,0 +1,299 @@ +import { commands as defaultCommands, type ShellCommand } from "../commands.ts"; +import { titleOf } from "../kinds.ts"; +import { isVisible, stacks, type Edge, type Layout, type LayoutNode, type NodeId, type Panel, type PanelId, type PanelKind, type Placement, type Split, type Stack } from "../layout.ts"; +import type { Unsubscribe, Workbench } from "../workbench.ts"; + +export interface PanelView { + readonly element: HTMLElement; + readonly dispose?: () => void; +} + +export type Views = { + readonly [K in PanelKind]: (panel: Extract, workbench: Workbench) => PanelView; +}; + +const DRAG_TYPE = "application/x-nib-panel"; + +/** + * Renders a workbench into `host`. The layout (splits, tab bars, gutters) is rebuilt when its + * structure changes. Panel bodies are created once per panel and live in one layer positioned over their + * stack, so moving a panel never reparents it: reparenting reloads an iframe, and Safari has no + * `moveBefore()` to avoid that. + */ +export function renderWorkbench(host: HTMLElement, workbench: Workbench, views: Views): Unsubscribe { + host.classList.add("nib-workbench"); + const tree = host.appendChild(div("nib-tree")); + const layer = host.appendChild(div("nib-bodies")); + const drop = host.appendChild(div("nib-drop")); + drop.hidden = true; + const bodies = new Map(); + const contents = new Map(); + + const stackEls = new Map }>(); + let structure = ""; + + const render = (layout: Layout) => { + // Focus and the active tab are state, not structure. Repainting them in place keeps the element + // under the pointer alive, so a pointerdown that focuses a stack still gets its click or drag. + const next = JSON.stringify([layout.root, layout.hidden], (key, value) => (key === "active" ? undefined : value)); + if (next !== structure) { + structure = next; + contents.clear(); + stackEls.clear(); + tree.replaceChildren(renderNode(layout, layout.root)); + } + for (const [id, body] of bodies) { + if (id in layout.panels) continue; + body.view.dispose?.(); + body.frame.remove(); + bodies.delete(id); + } + for (const panel of Object.values(layout.panels)) { + if (bodies.has(panel.id)) continue; + const view = (views[panel.kind] as (p: Panel, wb: Workbench) => PanelView)(panel, workbench); + const frame = layer.appendChild(div("nib-body")); + frame.dataset.panel = panel.id; + frame.append(view.element); + frame.addEventListener("pointerdown", () => { + const stack = stacks(workbench.layout.root).find((s) => s.panels.includes(panel.id)); + if (stack && stack.id !== workbench.layout.focus) workbench.dispatch({ type: "focus", stack: stack.id }); + }); + bodies.set(panel.id, { view, frame }); + } + paint(layout); + position(layout); + }; + + const paint = (layout: Layout) => { + for (const stack of stacks(layout.root)) { + const els = stackEls.get(stack.id); + if (!els) continue; + els.el.toggleAttribute("data-focused", layout.focus === stack.id); + for (const [id, tab] of els.tabs) tab.setAttribute("aria-selected", String(stack.active === id)); + } + }; + + const position = (layout: Layout) => { + const origin = host.getBoundingClientRect(); + for (const stack of stacks(layout.root)) { + const content = contents.get(stack.id); + for (const id of stack.panels) { + const frame = bodies.get(id)?.frame; + if (!frame) continue; + frame.hidden = !content || stack.active !== id; + if (frame.hidden || !content) continue; + const rect = content.getBoundingClientRect(); + Object.assign(frame.style, { + left: `${rect.left - origin.left}px`, + top: `${rect.top - origin.top}px`, + width: `${rect.width}px`, + height: `${rect.height}px`, + }); + } + } + }; + + const renderNode = (layout: Layout, node: LayoutNode): HTMLElement => + node.type === "split" ? renderSplit(layout, node) : renderStack(layout, node); + + const renderSplit = (layout: Layout, split: Split): HTMLElement => { + const el = div("nib-split"); + el.dataset.axis = split.axis; + const shown = split.children.map((child, i) => ({ child, i })).filter(({ child }) => isVisible(layout, child)); + shown.forEach(({ child, i }, n) => { + if (n > 0) el.append(gutter(split, el, shown[n - 1]!.i, i)); + const cell = el.appendChild(div("nib-cell")); + cell.dataset.index = String(i); + cell.style.flexGrow = String(split.sizes[i]); + cell.append(renderNode(layout, child)); + }); + return el; + }; + + const renderStack = (layout: Layout, stack: Stack): HTMLElement => { + const el = div("nib-stack"); + el.dataset.stack = stack.id; + if (stack.slot) el.dataset.slot = stack.slot; + const tabEls = new Map(); + stackEls.set(stack.id, { el, tabs: tabEls }); + el.addEventListener("pointerdown", () => { + if (workbench.layout.focus !== stack.id) workbench.dispatch({ type: "focus", stack: stack.id }); + }); + + const tabs = el.appendChild(div("nib-tabs")); + tabs.setAttribute("role", "tablist"); + for (const id of stack.panels) { + const panel = layout.panels[id]!; + const tab = tabs.appendChild(document.createElement("div")); + tab.className = "nib-tab"; + tab.setAttribute("role", "tab"); + tab.dataset.panel = id; + tabEls.set(id, tab); + tab.draggable = true; + const label = tab.appendChild(document.createElement("button")); + label.textContent = titleOf(panel); + label.addEventListener("click", () => workbench.dispatch({ type: "activate", panel: id })); + const close = tab.appendChild(document.createElement("button")); + close.textContent = "×"; + close.setAttribute("aria-label", `Close ${titleOf(panel)}`); + close.addEventListener("click", () => workbench.dispatch({ type: "close", panel: id })); + tab.addEventListener("dragstart", (event) => { + event.dataTransfer?.setData(DRAG_TYPE, id); + // Bodies cover the content areas that take drops, so they stop taking pointer events while dragging. + host.classList.add("nib-dragging"); + }); + tab.addEventListener("dragend", () => { + host.classList.remove("nib-dragging"); + drop.hidden = true; + }); + } + droppable(tabs, (event) => ({ stack: stack.id, index: tabIndex(tabs, event.clientX) })); + + const content = el.appendChild(div("nib-content")); + contents.set(stack.id, content); + droppable(content, (event) => { + const edge = edgeAt(content.getBoundingClientRect(), event.clientX, event.clientY); + return edge ? { beside: stack.id, edge } : { stack: stack.id }; + }); + return el; + }; + + /** Makes an element a drop target for dragged tabs, showing where the panel would land. */ + const droppable = (el: HTMLElement, placement: (event: DragEvent) => Placement) => { + el.addEventListener("dragover", (event) => { + if (!event.dataTransfer?.types.includes(DRAG_TYPE)) return; + event.preventDefault(); + showDrop(el, placement(event)); + }); + el.addEventListener("dragleave", () => (drop.hidden = true)); + el.addEventListener("drop", (event) => { + const panel = event.dataTransfer?.getData(DRAG_TYPE) as PanelId | undefined; + drop.hidden = true; + host.classList.remove("nib-dragging"); + if (!panel) return; + event.preventDefault(); + workbench.dispatch({ type: "move", panel, to: placement(event) }); + }); + }; + + const showDrop = (el: HTMLElement, placement: Placement) => { + const origin = host.getBoundingClientRect(); + const rect = el.getBoundingClientRect(); + let { left, top, width, height } = { left: rect.left - origin.left, top: rect.top - origin.top, width: rect.width, height: rect.height }; + if ("edge" in placement) { + if (placement.edge === "right") left += width / 2; + if (placement.edge === "bottom") top += height / 2; + if (placement.edge === "left" || placement.edge === "right") width /= 2; + else height /= 2; + } + Object.assign(drop.style, { left: `${left}px`, top: `${top}px`, width: `${width}px`, height: `${height}px` }); + drop.hidden = false; + }; + + /** + * A gutter between two visible children. Dragging it changes their flex weights directly and + * dispatches one `resize` on release, since re-rendering mid-drag would destroy the gutter. + */ + const gutter = (split: Split, el: HTMLElement, before: number, after: number): HTMLElement => { + const handle = div("nib-gutter"); + handle.setAttribute("role", "separator"); + handle.setAttribute("aria-orientation", split.axis === "row" ? "vertical" : "horizontal"); + handle.addEventListener("pointerdown", (start) => { + start.preventDefault(); + handle.setPointerCapture(start.pointerId); + const cells = [...el.children].filter((c): c is HTMLElement => c.classList.contains("nib-cell")); + const a = cells.find((c) => c.dataset.index === String(before))!; + const b = cells.find((c) => c.dataset.index === String(after))!; + const horizontal = split.axis === "row"; + const length = (c: HTMLElement) => (horizontal ? c.getBoundingClientRect().width : c.getBoundingClientRect().height); + const [lengthA, lengthB] = [length(a), length(b)]; + const weight = split.sizes[before]! + split.sizes[after]!; + const sizes = [...split.sizes]; + host.classList.add("nib-resizing"); + const onMove = (event: PointerEvent) => { + const delta = (horizontal ? event.clientX - start.clientX : event.clientY - start.clientY); + const share = Math.min(Math.max((lengthA + delta) / (lengthA + lengthB), 0.05), 0.95); + sizes[before] = weight * share; + sizes[after] = weight * (1 - share); + a.style.flexGrow = String(sizes[before]); + b.style.flexGrow = String(sizes[after]); + position(workbench.layout); + }; + const onUp = () => { + handle.removeEventListener("pointermove", onMove); + host.classList.remove("nib-resizing"); + workbench.dispatch({ type: "resize", split: split.id, sizes }); + }; + handle.addEventListener("pointermove", onMove); + handle.addEventListener("pointerup", onUp, { once: true }); + }); + return handle; + }; + + const observer = new ResizeObserver(() => position(workbench.layout)); + observer.observe(host); + render(workbench.layout); + const unsubscribe = workbench.subscribe(render); + return () => { + unsubscribe(); + observer.disconnect(); + for (const body of bodies.values()) body.view.dispose?.(); + host.replaceChildren(); + host.classList.remove("nib-workbench"); + }; +} + +/** Runs shell commands from their keybindings. */ +export function bindKeys(target: Window, workbench: Workbench, commands: readonly ShellCommand[] = defaultCommands): Unsubscribe { + const mac = /Mac|iPhone|iPad/.test(navigator.platform); + const onKey = (event: KeyboardEvent) => { + const match = commands.find((c) => c.keys && matches(c.keys, event, mac)); + if (!match) return; + event.preventDefault(); + match.run(workbench); + }; + target.addEventListener("keydown", onKey); + return () => target.removeEventListener("keydown", onKey); +} + +/** Matches `Mod+Shift+E` against a key event by physical key, so Alt and Shift don't change the letter. */ +export function matches(keys: string, event: Pick, mac: boolean): boolean { + const parts = keys.split("+"); + const key = parts.pop()!; + const mods = new Set(parts.map((m) => (m === "Mod" ? (mac ? "Meta" : "Ctrl") : m))); + if (mods.has("Meta") !== event.metaKey || mods.has("Ctrl") !== event.ctrlKey) return false; + if (mods.has("Alt") !== event.altKey || mods.has("Shift") !== event.shiftKey) return false; + return event.code === codeOf(key); +} + +function codeOf(key: string): string { + if (/^[A-Z]$/i.test(key)) return `Key${key.toUpperCase()}`; + if (/^\d$/.test(key)) return `Digit${key}`; + return { "\\": "Backslash", "`": "Backquote", "/": "Slash", ",": "Comma", ".": "Period" }[key] ?? key; +} + +function tabIndex(tabs: HTMLElement, x: number): number { + const all = [...tabs.children] as HTMLElement[]; + const at = all.findIndex((tab) => { + const rect = tab.getBoundingClientRect(); + return x < rect.left + rect.width / 2; + }); + return at === -1 ? all.length : at; +} + +/** The edge a drop at (x, y) splits toward, or none for the middle of the area. */ +function edgeAt(rect: DOMRect, x: number, y: number): Edge | undefined { + const fx = (x - rect.left) / rect.width; + const fy = (y - rect.top) / rect.height; + const nearest = Math.min(fx, 1 - fx, fy, 1 - fy); + if (nearest > 0.25) return undefined; + if (nearest === fx) return "left"; + if (nearest === 1 - fx) return "right"; + return nearest === fy ? "top" : "bottom"; +} + +function div(className: string): HTMLElement { + const el = document.createElement("div"); + el.className = className; + return el; +} diff --git a/packages/app/src/shell/dom/shell.css b/packages/app/src/shell/dom/shell.css new file mode 100644 index 0000000..457eb1c --- /dev/null +++ b/packages/app/src/shell/dom/shell.css @@ -0,0 +1,84 @@ +/* Structural styles for the shell. Only what layout, positioning, and state need. */ +:root { + color-scheme: light dark; + --nib-bg: light-dark(#fff, #1e1e1e); + --nib-fg: light-dark(#1f1f1f, #d4d4d4); + --nib-chrome: light-dark(#f3f3f3, #252526); + --nib-line: light-dark(#d4d4d4, #3c3c3c); + --nib-accent: light-dark(#005fb8, #3794ff); +} + +.nib-workbench { + position: relative; + overflow: hidden; + background: var(--nib-bg); + color: var(--nib-fg); + font: 13px/1.4 system-ui, sans-serif; +} + +.nib-tree, +.nib-tree > *, +.nib-split, +.nib-cell, +.nib-stack { + display: flex; + min-width: 0; + min-height: 0; +} + +.nib-tree { position: absolute; inset: 0; } +.nib-tree > *, .nib-split, .nib-stack { flex: 1; } +.nib-split[data-axis="row"] { flex-direction: row; } +.nib-split[data-axis="column"] { flex-direction: column; } +.nib-cell { flex-basis: 0; } +.nib-stack { flex-direction: column; } + +.nib-gutter { flex: 0 0 4px; background: var(--nib-line); touch-action: none; } +.nib-split[data-axis="row"] > .nib-gutter { cursor: col-resize; } +.nib-split[data-axis="column"] > .nib-gutter { cursor: row-resize; } + +.nib-tabs { + display: flex; + flex: 0 0 auto; + overflow-x: auto; + min-height: 30px; + background: var(--nib-chrome); + border-bottom: 1px solid var(--nib-line); +} +.nib-tab { display: flex; align-items: center; border-right: 1px solid var(--nib-line); } +.nib-tab[aria-selected="true"] { background: var(--nib-bg); } +.nib-stack[data-focused] .nib-tab[aria-selected="true"] { box-shadow: inset 0 1px var(--nib-accent); } +.nib-tab button { border: 0; background: none; color: inherit; font: inherit; padding: 4px 8px; } +.nib-tab button + button { padding-inline: 4px 8px; } +.nib-content { flex: 1; } + +/* Bodies sit over their stack's content area and are never reparented (see render.ts). */ +.nib-bodies { position: absolute; inset: 0; pointer-events: none; } +.nib-body { position: absolute; display: flex; pointer-events: auto; } +.nib-body[hidden] { display: none; } +.nib-body > * { flex: 1; min-width: 0; min-height: 0; } +.nib-dragging .nib-body, +.nib-resizing .nib-body { pointer-events: none; } +.nib-resizing { user-select: none; } + +.nib-drop { + position: absolute; + pointer-events: none; + background: color-mix(in srgb, var(--nib-accent) 20%, transparent); + outline: 1px solid var(--nib-accent); +} +.nib-drop[hidden] { display: none; } + +/* Stock views. */ +.nib-explorer { list-style: none; margin: 0; padding: 4px 0; overflow: auto; } +.nib-explorer li { display: flex; } +.nib-explorer button { border: 0; background: none; color: inherit; font: inherit; text-align: start; padding: 2px 12px; } +.nib-explorer button:first-child { flex: 1; } +.nib-editor { border: 0; resize: none; padding: 8px; background: var(--nib-bg); color: inherit; font: 13px/1.5 ui-monospace, monospace; } +.nib-preview { border: 0; background: #fff; } +.nib-terminal, .nib-agent { display: flex; flex-direction: column; overflow: hidden; } +.nib-terminal pre { flex: 1; margin: 0; padding: 8px; overflow: auto; font: 12px/1.4 ui-monospace, monospace; } +.nib-terminal input { font: 12px ui-monospace, monospace; width: 100%; box-sizing: border-box; } +.nib-agent ol { flex: 1; margin: 0; padding: 8px 8px 8px 24px; overflow: auto; } +.nib-agent form { display: flex; gap: 4px; padding: 4px; } +.nib-agent textarea { flex: 1; resize: none; font: inherit; } diff --git a/packages/app/src/shell/dom/views.ts b/packages/app/src/shell/dom/views.ts new file mode 100644 index 0000000..9b829fc --- /dev/null +++ b/packages/app/src/shell/dom/views.ts @@ -0,0 +1,172 @@ +import type { Unsubscribe, Workbench } from "../workbench.ts"; +import type { PanelView, Views } from "./render.ts"; + +/** + * The file access the stock views need. It stands in for the kernel's filesystem and the Loro docs + * behind it (D16); views keep no state of their own beyond what is on screen (D11). + */ +export interface Files { + list(): string[]; + read(path: string): string | undefined; + write(path: string, text: string): void; + /** Calls `listener` with the path of every write. */ + watch(listener: (path: string) => void): Unsubscribe; +} + +export function memoryFiles(initial: Record): Files { + const files = new Map(Object.entries(initial)); + const listeners = new Set<(path: string) => void>(); + return { + list: () => [...files.keys()].sort(), + read: (path) => files.get(path), + write(path, text) { + files.set(path, text); + for (const listener of listeners) listener(path); + }, + watch(listener) { + listeners.add(listener); + return () => listeners.delete(listener); + }, + }; +} + +/** Stock views for every panel kind, each a minimal view over `files`. */ +export function stockViews(files: Files): Views { + return { + explorer: (_panel, wb) => explorer(files, wb), + editor: (panel) => editor(files, panel.input.path), + preview: (panel) => preview(files, panel.input.path), + terminal: (panel, wb) => terminal(files, wb, panel.input.cwd), + agent: (panel) => agent(files, panel.input.conversation), + }; +} + +function explorer(files: Files, wb: Workbench): PanelView { + const element = el("ul", "nib-explorer"); + const draw = () => { + element.replaceChildren( + ...files.list().filter((path) => !path.startsWith(".")).map((path) => { + const item = el("li"); + const open = item.appendChild(el("button")); + open.textContent = path; + open.addEventListener("click", () => wb.open({ kind: "editor", input: { path } })); + if (path.endsWith(".html")) { + const run = item.appendChild(el("button")); + run.textContent = "▶"; + run.setAttribute("aria-label", `Preview ${path}`); + run.addEventListener("click", () => wb.open({ kind: "preview", input: { path } })); + } + return item; + }), + ); + }; + draw(); + return { element, dispose: files.watch(draw) }; +} + +function editor(files: Files, path: string): PanelView { + const element = el("textarea", "nib-editor") as HTMLTextAreaElement; + element.spellcheck = false; + element.setAttribute("aria-label", path); + element.value = files.read(path) ?? ""; + element.addEventListener("input", () => files.write(path, element.value)); + const dispose = files.watch((changed) => { + if (changed === path && element.value !== files.read(path)) element.value = files.read(path) ?? ""; + }); + return { element, dispose }; +} + +/** + * Renders an HTML file in an opaque-origin iframe. The real preview is guest HTTP on the sandbox's + * own origin (D3); `sandbox` without `allow-same-origin` is the in-page stand-in. + */ +function preview(files: Files, path: string): PanelView { + const element = el("iframe", "nib-preview") as HTMLIFrameElement; + element.title = `Preview of ${path}`; + element.sandbox.add("allow-scripts"); + element.srcdoc = files.read(path) ?? ""; + const dispose = files.watch((changed) => { + if (changed === path) element.srcdoc = files.read(path) ?? ""; + }); + return { element, dispose }; +} + +/** + * A line shell over `files` and the workbench. bashkit replaces it; `open` and `preview` show that + * a shell drives the same commands the GUI does (D12). + */ +function terminal(files: Files, wb: Workbench, cwd: string): PanelView { + const element = el("div", "nib-terminal"); + const output = element.appendChild(el("pre")); + const form = element.appendChild(el("form")); + const input = form.appendChild(el("input")) as HTMLInputElement; + input.setAttribute("aria-label", "Terminal input"); + const print = (text: string) => { + output.textContent += `${text}\n`; + output.scrollTop = output.scrollHeight; + }; + const run = (line: string) => { + const [name, ...args] = line.trim().split(/\s+/); + const path = args[0] ?? ""; + switch (name) { + case "": + return; + case "ls": + return print(files.list().join("\n")); + case "cat": + return print(files.read(path) ?? `cat: ${path}: No such file`); + case "open": + case "preview": + if (files.read(path) === undefined) return print(`${name}: ${path}: No such file`); + return void wb.open({ kind: name === "open" ? "editor" : "preview", input: { path } }); + default: + return print(`${name}: command not found (try ls, cat, open, preview)`); + } + }; + form.addEventListener("submit", (event) => { + event.preventDefault(); + print(`${cwd} $ ${input.value}`); + run(input.value); + input.value = ""; + }); + return { element }; +} + +/** + * A conversation is a transcript file, so an agent, the shell, and other viewers all see the same + * messages. No model is called here: the agent loop is userland (D8). + */ +function agent(files: Files, conversation: string): PanelView { + const path = `.agents/${conversation}.json`; + const element = el("div", "nib-agent"); + const log = element.appendChild(el("ol")); + const form = element.appendChild(el("form")); + const input = form.appendChild(el("textarea")) as HTMLTextAreaElement; + input.setAttribute("aria-label", "Message"); + form.appendChild(el("button")).textContent = "Send"; + const messages = (): { role: string; text: string }[] => JSON.parse(files.read(path) ?? "[]"); + const draw = () => { + log.replaceChildren( + ...messages().map((message) => { + const item = el("li"); + item.dataset.role = message.role; + item.textContent = message.text; + return item; + }), + ); + }; + form.addEventListener("submit", (event) => { + event.preventDefault(); + if (!input.value.trim()) return; + files.write(path, JSON.stringify([...messages(), { role: "user", text: input.value }])); + input.value = ""; + }); + draw(); + return { element, dispose: files.watch((changed) => changed === path && draw()) }; +} + +function el(tag: K, className?: string): HTMLElementTagNameMap[K] { + const element = document.createElement(tag); + if (className) element.className = className; + return element; +} diff --git a/packages/app/src/shell/index.ts b/packages/app/src/shell/index.ts new file mode 100644 index 0000000..2e63ed2 --- /dev/null +++ b/packages/app/src/shell/index.ts @@ -0,0 +1,4 @@ +export * from "./layout.ts"; +export * from "./kinds.ts"; +export * from "./workbench.ts"; +export * from "./commands.ts"; diff --git a/packages/app/src/shell/kinds.ts b/packages/app/src/shell/kinds.ts new file mode 100644 index 0000000..29d43af --- /dev/null +++ b/packages/app/src/shell/kinds.ts @@ -0,0 +1,46 @@ +import type { OpenRequest, PanelInputs, PanelKind, Slot } from "./layout.ts"; + +/** + * Where a panel's UI renders. `chrome` panels draw on the shell's top-level origin from data the + * shell parses (file trees, terminal bytes, transcripts). `sandbox` panels render guest UI, so they + * must be a sandbox origin's iframe (D3, D10). The playground renders both in-page for now. + */ +export type PanelOrigin = "chrome" | "sandbox"; + +export interface KindSpec { + readonly title: (input: PanelInputs[K]) => string; + /** Identity of the view: opening a panel whose key is already open activates that panel. */ + readonly key: (input: PanelInputs[K]) => string; + readonly slot: Slot; + readonly origin: PanelOrigin; + /** The input's string fields, checked when a stored layout is parsed. */ + readonly fields: readonly (keyof PanelInputs[K] & string)[]; +} + +export type Kinds = { readonly [K in PanelKind]: KindSpec }; + +const basename = (path: string) => path.slice(path.lastIndexOf("/") + 1) || path; + +export const kinds: Kinds = { + explorer: { title: () => "Explorer", key: (input) => input.root, slot: "primary", origin: "chrome", fields: ["root"] }, + editor: { title: (input) => basename(input.path), key: (input) => input.path, slot: "main", origin: "sandbox", fields: ["path"] }, + preview: { title: (input) => `Preview ${basename(input.path)}`, key: (input) => input.path, slot: "main", origin: "sandbox", fields: ["path"] }, + terminal: { title: () => "Terminal", key: (input) => input.session, slot: "panel", origin: "chrome", fields: ["cwd", "session"] }, + agent: { title: () => "Agent", key: (input) => input.conversation, slot: "secondary", origin: "chrome", fields: ["conversation"] }, +}; + +export function isKind(value: unknown): value is PanelKind { + return typeof value === "string" && Object.hasOwn(kinds, value); +} + +export function spec(kind: K): KindSpec { + return kinds[kind]; +} + +export function keyOf(request: OpenRequest): string { + return (spec(request.kind).key as (input: OpenRequest["input"]) => string)(request.input); +} + +export function titleOf(request: OpenRequest): string { + return (spec(request.kind).title as (input: OpenRequest["input"]) => string)(request.input); +} diff --git a/packages/app/src/shell/layout.ts b/packages/app/src/shell/layout.ts new file mode 100644 index 0000000..3190550 --- /dev/null +++ b/packages/app/src/shell/layout.ts @@ -0,0 +1,338 @@ +declare const brand: unique symbol; +type Brand = T & { readonly [brand]: B }; + +export type PanelId = Brand; +export type NodeId = Brand; + +/** + * Panel inputs by kind. Each kind's input says what the panel is a view of (D11). + * Apps add their own kinds by augmenting this interface. + */ +export interface PanelInputs { + explorer: { readonly root: string }; + editor: { readonly path: string }; + preview: { readonly path: string }; + terminal: { readonly cwd: string; readonly session: string }; + agent: { readonly conversation: string }; +} + +export type PanelKind = keyof PanelInputs; + +export type Panel = { + [K in PanelKind]: { readonly id: PanelId; readonly kind: K; readonly input: PanelInputs[K] }; +}[PanelKind]; + +/** + * A slot names a stack's role, as VS Code's parts do. Opening a kind goes to its slot's stack, + * and toggling a slot hides that stack without losing its size. `main` always exists. + */ +export type Slot = "main" | "primary" | "secondary" | "panel"; +export type Axis = "row" | "column"; +export type Edge = "left" | "right" | "top" | "bottom"; + +export interface Stack { + readonly type: "stack"; + readonly id: NodeId; + readonly slot?: Slot; + readonly panels: readonly PanelId[]; + readonly active: PanelId | null; +} + +export interface Split { + readonly type: "split"; + readonly id: NodeId; + readonly axis: Axis; + readonly children: readonly LayoutNode[]; + /** Fractions of the split's length, one per child, summing to 1. */ + readonly sizes: readonly number[]; +} + +export type LayoutNode = Stack | Split; + +/** One person's arrangement of panels. It is per viewer, not shared, so it is plain data, not a CRDT. */ +export interface Layout { + readonly version: 1; + readonly root: LayoutNode; + readonly panels: Readonly>; + readonly focus: NodeId; + readonly hidden: readonly Slot[]; +} + +export type Placement = + | { readonly slot: Slot } + | { readonly stack: NodeId; readonly index?: number } + | { readonly beside: NodeId; readonly edge: Edge }; + +export type OpenRequest = { [K in PanelKind]: { readonly kind: K; readonly input: PanelInputs[K] } }[PanelKind]; + +export type Command = + | ({ readonly type: "open"; readonly at?: Placement } & OpenRequest) + | { readonly type: "close"; readonly panel: PanelId } + | { readonly type: "activate"; readonly panel: PanelId } + | { readonly type: "move"; readonly panel: PanelId; readonly to: Placement } + | { readonly type: "resize"; readonly split: NodeId; readonly sizes: readonly number[] } + | { readonly type: "toggle"; readonly slot: Exclude; readonly visible?: boolean } + | { readonly type: "focus"; readonly stack: NodeId }; + +/** What the reducer needs from outside: fresh ids, and each kind's identity and home slot. */ +export interface Env { + readonly id: () => string; + /** Two panels of one kind with the same key are the same view; opening it again activates it. */ + readonly key: (request: OpenRequest) => string; + readonly slot: (kind: PanelKind) => Slot; +} + +/** Default share of the parent a slot gets when the shell recreates its stack. */ +const SLOT_SHARE: Record, number> = { primary: 0.2, secondary: 0.25, panel: 0.3 }; +const SLOT_EDGE: Record, Edge> = { primary: "left", secondary: "right", panel: "bottom" }; + +export function emptyLayout(env: Env): Layout { + const main: Stack = { type: "stack", id: env.id() as NodeId, slot: "main", panels: [], active: null }; + return { version: 1, root: main, panels: {}, focus: main.id, hidden: [] }; +} + +export function apply(layout: Layout, command: Command, env: Env): Layout { + switch (command.type) { + case "open": + return open(layout, command, command.at ?? { slot: env.slot(command.kind) }, env); + case "close": + return command.panel in layout.panels ? normalize(removePanel(layout, command.panel)) : layout; + case "activate": { + const stack = stackOf(layout.root, command.panel); + if (!stack) return layout; + return reveal(withStack(layout, { ...stack, active: command.panel }), stack.id); + } + case "move": + return move(layout, command.panel, command.to, env); + case "resize": { + const split = findNode(layout.root, command.split); + if (split?.type !== "split" || split.children.length !== command.sizes.length) return layout; + return { ...layout, root: replaceNode(layout.root, split.id, { ...split, sizes: fractions(command.sizes) }) }; + } + case "toggle": { + const visible = command.visible ?? layout.hidden.includes(command.slot); + const hidden = layout.hidden.filter((slot) => slot !== command.slot); + if (visible) return { ...layout, hidden }; + const next = { ...layout, hidden: [...hidden, command.slot] }; + const focused = findNode(layout.root, layout.focus); + return focused?.type === "stack" && focused.slot === command.slot ? { ...next, focus: mainStack(next.root).id } : next; + } + case "focus": + return findNode(layout.root, command.stack)?.type === "stack" ? reveal(layout, command.stack) : layout; + } +} + +/** Every stack in document order, for renderers and tests. */ +export function stacks(node: LayoutNode): Stack[] { + return node.type === "stack" ? [node] : node.children.flatMap(stacks); +} + +export function stackOf(node: LayoutNode, panel: PanelId): Stack | undefined { + return stacks(node).find((stack) => stack.panels.includes(panel)); +} + +export function findNode(node: LayoutNode, id: NodeId): LayoutNode | undefined { + if (node.id === id) return node; + if (node.type === "stack") return undefined; + for (const child of node.children) { + const found = findNode(child, id); + if (found) return found; + } + return undefined; +} + +export function mainStack(node: LayoutNode): Stack { + const main = stacks(node).find((stack) => stack.slot === "main"); + if (!main) throw new Error("layout has no main stack"); + return main; +} + +/** Whether a node renders: a stack in a hidden slot does not, and neither does a split whose children all don't. */ +export function isVisible(layout: Layout, node: LayoutNode): boolean { + if (node.type === "stack") return !node.slot || !layout.hidden.includes(node.slot); + return node.children.some((child) => isVisible(layout, child)); +} + +function open(layout: Layout, request: Command & { type: "open" }, at: Placement, env: Env): Layout { + const key = env.key(request); + const existing = Object.values(layout.panels).find((panel) => panel.kind === request.kind && env.key(panel) === key); + if (existing) return apply(layout, { type: "activate", panel: existing.id }, env); + const panel = { id: env.id() as PanelId, kind: request.kind, input: request.input } as Panel; + return normalize(place({ ...layout, panels: { ...layout.panels, [panel.id]: panel } }, panel.id, at, env)); +} + +function move(layout: Layout, panel: PanelId, to: Placement, env: Env): Layout { + const from = stackOf(layout.root, panel); + if (!from) return layout; + // Detach first so a reorder within one stack sees the right indices. An emptied source stack + // stays in the tree until `normalize`, so placing beside it still finds it. + const detached = withStack(layout, withoutPanel(from, panel)); + return normalize(place(detached, panel, to, env)); +} + +/** Puts an already-registered panel at a placement, creating a stack when the placement asks for one. */ +function place(layout: Layout, panel: PanelId, at: Placement, env: Env): Layout { + if ("slot" in at) { + const stack = stacks(layout.root).find((s) => s.slot === at.slot); + if (stack) return place(layout, panel, { stack: stack.id }, env); + // The slot's stack was closed. Recreate it where VS Code keeps that part. + const slot = at.slot as Exclude; + if (slot !== "panel") return insertStack(layout, panel, layout.root.id, SLOT_EDGE[slot], SLOT_SHARE[slot], env, slot); + const area = editorArea(layout.root, env); + return insertStack({ ...layout, root: area.root }, panel, area.id, SLOT_EDGE[slot], SLOT_SHARE[slot], env, slot); + } + if ("beside" in at) return insertStack(layout, panel, at.beside, at.edge, 0.5, env); + const stack = findNode(layout.root, at.stack); + if (stack?.type !== "stack") return place(layout, panel, { slot: "main" }, env); + const panels = [...stack.panels]; + panels.splice(Math.min(at.index ?? panels.length, panels.length), 0, panel); + return reveal(withStack(layout, { ...stack, panels, active: panel }), stack.id); +} + +function insertStack( + layout: Layout, + panel: PanelId, + anchor: NodeId, + edge: Edge, + share: number, + env: Env, + slot?: Slot, +): Layout { + const target = findNode(layout.root, anchor) ?? layout.root; + const stack: Stack = { type: "stack", id: env.id() as NodeId, panels: [panel], active: panel, ...(slot && { slot }) }; + const axis: Axis = edge === "left" || edge === "right" ? "row" : "column"; + const before = edge === "left" || edge === "top"; + const parent = parentOf(layout.root, target.id); + let root: LayoutNode; + if (parent && parent.axis === axis) { + const at = parent.children.indexOf(target); + const children = [...parent.children]; + const sizes = [...parent.sizes]; + const taken = sizes[at]! * share; + sizes[at] = sizes[at]! - taken; + children.splice(before ? at : at + 1, 0, stack); + sizes.splice(before ? at : at + 1, 0, taken); + root = replaceNode(layout.root, parent.id, { ...parent, children, sizes }); + } else { + const split: Split = { + type: "split", + id: env.id() as NodeId, + axis, + children: before ? [stack, target] : [target, stack], + sizes: before ? [share, 1 - share] : [1 - share, share], + }; + root = replaceNode(layout.root, target.id, split); + } + return reveal({ ...layout, root }, stack.id); +} + +/** + * Finds VS Code's editor area: the main stack plus the siblings around it that hold no other + * slotted stack. When the area is a run of siblings rather than one node, it is grouped into its + * own split so the panel slot can span it. + */ +function editorArea(node: LayoutNode, env: Env): { root: LayoutNode; id: NodeId } { + const clean = (n: LayoutNode) => stacks(n).every((stack) => !stack.slot || stack.slot === "main"); + if (node.type === "stack" || clean(node)) return { root: node, id: node.id }; + const at = node.children.findIndex((child) => stacks(child).some((stack) => stack.slot === "main")); + const holder = node.children[at]!; + if (!clean(holder)) { + const inner = editorArea(holder, env); + return { root: replaceNode(node, holder.id, inner.root), id: inner.id }; + } + let [lo, hi] = [at, at]; + while (lo > 0 && clean(node.children[lo - 1]!)) lo--; + while (hi < node.children.length - 1 && clean(node.children[hi + 1]!)) hi++; + if (lo === hi) return { root: node, id: holder.id }; + const group: Split = { + type: "split", + id: env.id() as NodeId, + axis: node.axis, + children: node.children.slice(lo, hi + 1), + sizes: fractions(node.sizes.slice(lo, hi + 1)), + }; + const weight = node.sizes.slice(lo, hi + 1).reduce((sum, size) => sum + size, 0); + const children = [...node.children.slice(0, lo), group, ...node.children.slice(hi + 1)]; + const sizes = [...node.sizes.slice(0, lo), weight, ...node.sizes.slice(hi + 1)]; + return { root: { ...node, children, sizes }, id: group.id }; +} + +function removePanel(layout: Layout, panel: PanelId): Layout { + const stack = stackOf(layout.root, panel); + const { [panel]: _, ...panels } = layout.panels; + if (!stack) return { ...layout, panels }; + return { ...withStack(layout, withoutPanel(stack, panel)), panels }; +} + +function withoutPanel(stack: Stack, panel: PanelId): Stack { + const at = stack.panels.indexOf(panel); + const panels = stack.panels.filter((id) => id !== panel); + const active = stack.active === panel ? (panels[Math.min(at, panels.length - 1)] ?? null) : stack.active; + return { ...stack, panels, active }; +} + +function withStack(layout: Layout, stack: Stack): Layout { + return { ...layout, root: replaceNode(layout.root, stack.id, stack) }; +} + +/** Focuses a stack and unhides its slot, since a focused stack must be on screen. */ +function reveal(layout: Layout, stack: NodeId): Layout { + const node = findNode(layout.root, stack); + const slot = node?.type === "stack" ? node.slot : undefined; + return { ...layout, focus: stack, hidden: layout.hidden.filter((s) => s !== slot) }; +} + +/** + * Restores the invariants every command relies on: no empty stacks except `main`, no split with + * fewer than two children, no split nested in one of the same axis, sizes that sum to 1, and a + * focus that points at a live stack. + */ +export function normalize(layout: Layout): Layout { + const root = prune(layout.root) ?? { type: "stack", id: layout.focus, slot: "main", panels: [], active: null }; + const live = new Set(stacks(root).map((stack) => stack.id)); + return { ...layout, root, focus: live.has(layout.focus) ? layout.focus : mainStack(root).id }; +} + +function prune(node: LayoutNode): LayoutNode | undefined { + if (node.type === "stack") return node.panels.length > 0 || node.slot === "main" ? node : undefined; + const children: LayoutNode[] = []; + const sizes: number[] = []; + node.children.forEach((child, i) => { + const kept = prune(child); + if (!kept) return; + if (kept.type === "split" && kept.axis === node.axis) { + kept.children.forEach((grandchild, j) => { + children.push(grandchild); + sizes.push(node.sizes[i]! * kept.sizes[j]!); + }); + } else { + children.push(kept); + sizes.push(node.sizes[i]!); + } + }); + if (children.length === 0) return undefined; + if (children.length === 1) return children[0]; + return { ...node, children, sizes: fractions(sizes) }; +} + +function parentOf(node: LayoutNode, id: NodeId): Split | undefined { + if (node.type === "stack") return undefined; + if (node.children.some((child) => child.id === id)) return node; + for (const child of node.children) { + const found = parentOf(child, id); + if (found) return found; + } + return undefined; +} + +function replaceNode(node: LayoutNode, id: NodeId, next: LayoutNode): LayoutNode { + if (node.id === id) return next; + if (node.type === "stack") return node; + return { ...node, children: node.children.map((child) => replaceNode(child, id, next)) }; +} + +function fractions(sizes: readonly number[]): number[] { + const clamped = sizes.map((size) => (Number.isFinite(size) && size > 0 ? size : 0)); + const total = clamped.reduce((sum, size) => sum + size, 0); + return total > 0 ? clamped.map((size) => size / total) : sizes.map(() => 1 / sizes.length); +} diff --git a/packages/app/src/shell/workbench.ts b/packages/app/src/shell/workbench.ts new file mode 100644 index 0000000..5903307 --- /dev/null +++ b/packages/app/src/shell/workbench.ts @@ -0,0 +1,127 @@ +import { isKind, keyOf, spec } from "./kinds.ts"; +import { + apply, + emptyLayout, + normalize, + type Command, + type Env, + type Layout, + type LayoutNode, + type NodeId, + type OpenRequest, + type Panel, + type PanelId, + type PanelKind, + type Placement, + type Slot, +} from "./layout.ts"; + +const SLOTS: readonly Slot[] = ["main", "primary", "secondary", "panel"]; + +export type Unsubscribe = () => void; + +export interface WorkbenchOptions { + readonly layout?: Layout; + /** Id source. Tests pass a counter; the default is `crypto.randomUUID`. */ + readonly id?: () => string; +} + +/** + * The shell's headless core (D12). It owns one viewer's layout, applies commands to it, and tells + * subscribers when it changed. A renderer, a keybinding, a palette, and an agent all drive it with + * the same `Command`s. + */ +export class Workbench { + readonly env: Env; + #layout: Layout; + #listeners = new Set<(layout: Layout) => void>(); + + constructor({ layout, id = () => crypto.randomUUID() }: WorkbenchOptions = {}) { + this.env = { id, key: keyOf, slot: (kind) => spec(kind).slot }; + this.#layout = layout ?? emptyLayout(this.env); + } + + get layout(): Layout { + return this.#layout; + } + + dispatch(command: Command): void { + const next = apply(this.#layout, command, this.env); + if (next === this.#layout) return; + this.#layout = next; + for (const listener of this.#listeners) listener(next); + } + + /** Opens a view, or activates it if it is already open, and returns its panel id. */ + open(request: OpenRequest, at?: Placement): PanelId { + this.dispatch({ type: "open", ...request, ...(at && { at }) } as Command); + const key = keyOf(request); + const panel = Object.values(this.#layout.panels).find((p) => p.kind === request.kind && keyOf(p) === key); + if (!panel) throw new Error(`open did not create a ${request.kind} panel`); + return panel.id; + } + + /** The panels of one kind, for views that want to find their siblings (an explorer's open editors). */ + panels(kind: K): Extract[] { + return Object.values(this.#layout.panels).filter((p): p is Extract => p.kind === kind); + } + + subscribe(listener: (layout: Layout) => void): Unsubscribe { + this.#listeners.add(listener); + return () => this.#listeners.delete(listener); + } +} + +/** + * Parses a stored layout. Storage is a boundary: anything that fails a check returns `undefined`, + * and the caller starts from a default layout instead. + */ +export function parseLayout(value: unknown): Layout | undefined { + if (!isRecord(value) || value.version !== 1 || !isRecord(value.panels) || !Array.isArray(value.hidden)) return; + const panels: Record = {}; + for (const [id, panel] of Object.entries(value.panels)) { + if (!isRecord(panel) || panel.id !== id || !isKind(panel.kind) || !isRecord(panel.input)) return; + if (!spec(panel.kind).fields.every((field) => typeof (panel.input as Record)[field] === "string")) return; + panels[id] = panel as unknown as Panel; + } + const seen = new Set(); + const root = parseNode(value.root, panels, seen); + if (!root || typeof value.focus !== "string") return; + const hidden = value.hidden.filter((slot): slot is Exclude => slot !== "main" && SLOTS.includes(slot)); + // Panels no stack shows are dropped rather than rejected. A layout needs exactly one main stack. + const shown = Object.fromEntries(Object.entries(panels).filter(([id]) => seen.has(id))) as Record; + const layout: Layout = { version: 1, root, panels: shown, focus: value.focus as NodeId, hidden }; + return countMains(root) === 1 ? normalize(layout) : undefined; +} + +function parseNode(value: unknown, panels: Record, seen: Set): LayoutNode | undefined { + if (!isRecord(value) || typeof value.id !== "string") return; + if (value.type === "stack") { + if (!Array.isArray(value.panels)) return; + // Ids are branded here, at the boundary, after the checks that make them real. + const ids = value.panels.filter((id): id is PanelId => typeof id === "string" && id in panels && !seen.has(id)); + ids.forEach((id) => seen.add(id)); + const slot = SLOTS.find((s) => s === value.slot); + const active = ids.find((id) => id === value.active) ?? ids[0] ?? null; + return { type: "stack", id: value.id as NodeId, panels: ids, active, ...(slot && { slot }) }; + } + if (value.type === "split") { + if (value.axis !== "row" && value.axis !== "column") return; + if (!Array.isArray(value.children) || !Array.isArray(value.sizes)) return; + if (value.children.length !== value.sizes.length) return; + const children = value.children.map((child) => parseNode(child, panels, seen)); + if (children.some((child) => !child)) return; + const sizes = value.sizes.map((size) => (typeof size === "number" ? size : 0)); + return { type: "split", id: value.id as NodeId, axis: value.axis, children: children as LayoutNode[], sizes }; + } + return; +} + +function countMains(node: LayoutNode): number { + if (node.type === "stack") return node.slot === "main" ? 1 : 0; + return node.children.reduce((sum, child) => sum + countMains(child), 0); +} + +function isRecord(value: unknown): value is Record { + return typeof value === "object" && value !== null && !Array.isArray(value); +} diff --git a/packages/app/tests/shell.spec.ts b/packages/app/tests/shell.spec.ts new file mode 100644 index 0000000..34f136f --- /dev/null +++ b/packages/app/tests/shell.spec.ts @@ -0,0 +1,99 @@ +import { expect, test, type Page } from "@playwright/test"; + +const stack = (page: Page, slot: string) => page.locator(`.nib-stack[data-slot="${slot}"]`); +const tab = (page: Page, title: string) => page.locator(".nib-tab", { has: page.getByRole("button", { name: title, exact: true }) }); + +test.beforeEach(async ({ page }) => { + await page.goto("/?reset"); + await page.evaluate(() => localStorage.clear()); +}); + +test("the default layout has every slot, and each stack shows only its active panel", async ({ page }) => { + for (const slot of ["primary", "main", "panel", "secondary"]) await expect(stack(page, slot)).toBeVisible(); + await expect(page.locator(".nib-body:not([hidden])")).toHaveCount(5); + await expect(page.getByRole("textbox", { name: "README.md" })).toBeVisible(); + await expect(page.getByRole("textbox", { name: "index.html" })).toBeHidden(); +}); + +test("a body sits exactly over its stack's content area", async ({ page }) => { + const content = await stack(page, "panel").locator(".nib-content").boundingBox(); + const body = await page.locator(".nib-body:not([hidden])", { has: page.locator(".nib-terminal") }).boundingBox(); + expect(body).toEqual(content); +}); + +test("the explorer opens editors and previews, and editing updates the preview", async ({ page }) => { + await page.locator(".nib-explorer").getByRole("button", { name: "style.css" }).click(); + await expect(tab(page, "style.css")).toHaveAttribute("aria-selected", "true"); + await tab(page, "index.html").getByRole("button", { name: "index.html", exact: true }).click(); + const editor = page.getByRole("textbox", { name: "index.html" }); + await editor.fill("

Changed

"); + await expect(page.frameLocator(".nib-preview").getByRole("heading")).toHaveText("Changed"); +}); + +test("keybindings toggle parts without losing their panels", async ({ page }) => { + await page.locator("body").click({ position: { x: 1, y: 1 } }); + await page.keyboard.press("ControlOrMeta+b"); + await expect(stack(page, "primary")).toHaveCount(0); + await expect(page.locator(".nib-explorer")).toBeHidden(); + await page.keyboard.press("ControlOrMeta+j"); + await expect(stack(page, "panel")).toHaveCount(0); + await page.keyboard.press("ControlOrMeta+b"); + await expect(page.locator(".nib-explorer")).toBeVisible(); +}); + +test("dragging a tab to a content edge splits the stack", async ({ page }) => { + const before = await page.locator(".nib-stack").count(); + const target = stack(page, "main").locator(".nib-content"); + const box = (await target.boundingBox())!; + // The content area sits under its panel body until a drag starts, so skip the actionability check. + await tab(page, "README.md").dragTo(target, { force: true, targetPosition: { x: box.width / 2, y: box.height - 5 } }); + await expect(page.locator(".nib-stack")).toHaveCount(before + 1); + await expect(stack(page, "main").locator(".nib-tab")).toHaveCount(1); + await expect(page.getByRole("textbox", { name: "README.md" })).toBeVisible(); +}); + +test("moving the preview keeps its iframe document instead of reloading it", async ({ page }) => { + // The preview is opaque-origin, so the marker is set from inside the frame. + const frame = (await (await page.locator(".nib-preview").elementHandle())!.contentFrame())!; + await frame.evaluate(() => Object.assign(globalThis, { marker: 42 })); + const main = await stack(page, "main").getAttribute("data-stack"); + await page.evaluate((main) => { + const wb = (globalThis as any).workbench; + const [preview] = wb.panels("preview"); + wb.dispatch({ type: "move", panel: preview.id, to: { stack: main } }); + }, main); + await expect(tab(page, "Preview index.html")).toBeVisible(); + await expect(page.frameLocator(".nib-preview").getByRole("heading")).toBeVisible(); + expect(await frame.evaluate(() => (globalThis as { marker?: number }).marker)).toBe(42); +}); + +test("dragging a gutter resizes, and the layout survives a reload", async ({ page }) => { + const primary = stack(page, "primary"); + const width = (await primary.boundingBox())!.width; + const gutter = page.locator(".nib-tree > .nib-split > .nib-gutter").first(); + const box = (await gutter.boundingBox())!; + await page.mouse.move(box.x + 2, box.y + box.height / 2); + await page.mouse.down(); + await page.mouse.move(box.x + 102, box.y + box.height / 2, { steps: 5 }); + await page.mouse.up(); + const resized = (await primary.boundingBox())!.width; + expect(resized).toBeGreaterThan(width + 80); + await page.goto("/"); + expect((await stack(page, "primary").boundingBox())!.width).toBeCloseTo(resized, 0); +}); + +test("the terminal drives the workbench with the same commands as the GUI", async ({ page }) => { + const input = page.getByRole("textbox", { name: "Terminal input" }); + await input.fill("open style.css"); + await input.press("Enter"); + await expect(tab(page, "style.css")).toHaveAttribute("aria-selected", "true"); + await input.fill("nope"); + await input.press("Enter"); + await expect(page.locator(".nib-terminal pre")).toContainText("nope: command not found"); +}); + +test("agent messages are written to the conversation's transcript file", async ({ page }) => { + await page.getByRole("textbox", { name: "Message" }).fill("hello"); + await page.getByRole("button", { name: "Send" }).click(); + await expect(page.locator(".nib-agent li")).toHaveText(["hello"]); +}); diff --git a/packages/app/tests/shell.test.ts b/packages/app/tests/shell.test.ts new file mode 100644 index 0000000..e6f87fc --- /dev/null +++ b/packages/app/tests/shell.test.ts @@ -0,0 +1,193 @@ +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { command, mainStack, parseLayout, stacks, stackOf, Workbench, type Layout, type LayoutNode } from "../src/shell/index.ts"; + +function workbench(layout?: Layout) { + let n = 0; + return new Workbench({ id: () => `id${++n}`, ...(layout && { layout }) }); +} + +/** A compact picture of the tree: `row(primary[explorer] main[a.md])`. */ +function shape(wb: Workbench, node: LayoutNode = wb.layout.root): string { + if (node.type === "split") return `${node.axis}(${node.children.map((child) => shape(wb, child)).join(" ")})`; + const titles = node.panels.map((id) => { + const panel = wb.layout.panels[id]!; + return panel.kind === "editor" || panel.kind === "preview" ? panel.input.path : panel.kind; + }); + return `${node.slot ?? "stack"}[${titles.join(",")}]`; +} + +function vscode() { + const wb = workbench(); + wb.open({ kind: "explorer", input: { root: "/" } }); + wb.open({ kind: "editor", input: { path: "a.md" } }); + wb.open({ kind: "terminal", input: { cwd: "/", session: "t1" } }); + wb.open({ kind: "agent", input: { conversation: "c1" } }); + return wb; +} + +test("kinds open into their slots, which are created where VS Code keeps them", () => { + const wb = vscode(); + assert.equal(shape(wb), "row(primary[explorer] column(main[a.md] panel[terminal]) secondary[agent])"); +}); + +test("the panel slot spans the whole editor area, not just the main stack", () => { + const wb = workbench(); + wb.open({ kind: "explorer", input: { root: "/" } }); + wb.open({ kind: "editor", input: { path: "a.md" } }); + wb.open({ kind: "preview", input: { path: "a.md" } }, { beside: mainStack(wb.layout.root).id, edge: "right" }); + wb.open({ kind: "terminal", input: { cwd: "/", session: "t1" } }); + assert.equal(shape(wb), "row(primary[explorer] column(row(main[a.md] stack[a.md]) panel[terminal]))"); +}); + +test("opening a view that is already open activates it instead of duplicating it", () => { + const wb = vscode(); + const a = wb.open({ kind: "editor", input: { path: "a.md" } }); + wb.open({ kind: "editor", input: { path: "b.md" } }); + assert.equal(wb.open({ kind: "editor", input: { path: "a.md" } }), a); + assert.equal(mainStack(wb.layout.root).active, a); + assert.equal(wb.panels("editor").length, 2); +}); + +test("closing the last panel of a side stack removes it, and the main stack always survives", () => { + const wb = vscode(); + const terminal = wb.panels("terminal")[0]!.id; + const editor = wb.panels("editor")[0]!.id; + wb.dispatch({ type: "close", panel: terminal }); + wb.dispatch({ type: "close", panel: editor }); + assert.equal(shape(wb), "row(primary[explorer] main[] secondary[agent])"); + assert.equal(Object.keys(wb.layout.panels).length, 2); +}); + +test("closing the active tab activates its neighbour", () => { + const wb = workbench(); + wb.open({ kind: "editor", input: { path: "a.md" } }); + const b = wb.open({ kind: "editor", input: { path: "b.md" } }); + const c = wb.open({ kind: "editor", input: { path: "c.md" } }); + wb.dispatch({ type: "activate", panel: b }); + wb.dispatch({ type: "close", panel: b }); + assert.equal(mainStack(wb.layout.root).active, c); +}); + +test("a closed slot's stack is recreated on its edge with its default share", () => { + const wb = vscode(); + wb.dispatch({ type: "close", panel: wb.panels("explorer")[0]!.id }); + wb.open({ kind: "explorer", input: { root: "/" } }); + assert.equal(shape(wb), "row(primary[explorer] column(main[a.md] panel[terminal]) secondary[agent])"); + const root = wb.layout.root; + assert.equal(root.type, "split"); + assert.ok(root.type === "split" && Math.abs(root.sizes[0]! - 0.2) < 1e-9); +}); + +test("moving a panel beside its stack splits it, and a same-axis split takes a sibling instead of nesting", () => { + const wb = workbench(); + wb.open({ kind: "editor", input: { path: "a.md" } }); + const b = wb.open({ kind: "editor", input: { path: "b.md" } }); + const c = wb.open({ kind: "editor", input: { path: "c.md" } }); + const main = mainStack(wb.layout.root).id; + wb.dispatch({ type: "move", panel: b, to: { beside: main, edge: "right" } }); + wb.dispatch({ type: "move", panel: c, to: { beside: main, edge: "right" } }); + assert.equal(shape(wb), "row(main[a.md] stack[c.md] stack[b.md])"); + const root = wb.layout.root; + assert.ok(root.type === "split"); + assert.deepEqual(root.sizes, [0.25, 0.25, 0.5]); +}); + +test("moving the only panel of a stack beside that stack leaves one stack, not an empty one", () => { + const wb = workbench(); + wb.open({ kind: "editor", input: { path: "a.md" } }); + const b = wb.open({ kind: "editor", input: { path: "b.md" } }); + wb.dispatch({ type: "move", panel: b, to: { beside: mainStack(wb.layout.root).id, edge: "bottom" } }); + const lone = stackOf(wb.layout.root, b)!.id; + wb.dispatch({ type: "move", panel: b, to: { beside: lone, edge: "right" } }); + assert.equal(shape(wb), "column(main[a.md] stack[b.md])"); +}); + +test("moving a panel into another stack joins it, and an emptied split collapses", () => { + const wb = workbench(); + wb.open({ kind: "editor", input: { path: "a.md" } }); + const b = wb.open({ kind: "editor", input: { path: "b.md" } }); + const main = mainStack(wb.layout.root).id; + wb.dispatch({ type: "move", panel: b, to: { beside: main, edge: "right" } }); + wb.dispatch({ type: "move", panel: b, to: { stack: main, index: 0 } }); + assert.equal(shape(wb), "main[b.md,a.md]"); +}); + +test("moving within one stack reorders its tabs", () => { + const wb = workbench(); + const a = wb.open({ kind: "editor", input: { path: "a.md" } }); + wb.open({ kind: "editor", input: { path: "b.md" } }); + wb.open({ kind: "editor", input: { path: "c.md" } }); + wb.dispatch({ type: "move", panel: a, to: { stack: mainStack(wb.layout.root).id, index: 2 } }); + assert.equal(shape(wb), "main[b.md,c.md,a.md]"); +}); + +test("nested splits of one axis flatten when the split between them collapses", () => { + const wb = workbench(); + wb.open({ kind: "editor", input: { path: "a.md" } }); + const b = wb.open({ kind: "editor", input: { path: "b.md" } }); + const c = wb.open({ kind: "editor", input: { path: "c.md" } }); + const main = mainStack(wb.layout.root).id; + wb.dispatch({ type: "move", panel: b, to: { beside: main, edge: "right" } }); + wb.dispatch({ type: "move", panel: c, to: { beside: stackOf(wb.layout.root, b)!.id, edge: "bottom" } }); + assert.equal(shape(wb), "row(main[a.md] column(stack[b.md] stack[c.md]))"); + wb.dispatch({ type: "close", panel: b }); + assert.equal(shape(wb), "row(main[a.md] stack[c.md])"); +}); + +test("toggling a slot hides its stack, moves focus off it, and opening into it reveals it", () => { + const wb = vscode(); + wb.dispatch({ type: "focus", stack: stackOf(wb.layout.root, wb.panels("explorer")[0]!.id)!.id }); + command("layout.toggle.primary")!.run(wb); + assert.deepEqual(wb.layout.hidden, ["primary"]); + assert.equal(wb.layout.focus, mainStack(wb.layout.root).id); + assert.match(shape(wb), /primary\[explorer\]/, "a hidden stack keeps its place and size"); + wb.open({ kind: "explorer", input: { root: "/" } }); + assert.deepEqual(wb.layout.hidden, []); +}); + +test("resize normalizes sizes and ignores a size list of the wrong length", () => { + const wb = vscode(); + const root = wb.layout.root; + assert.ok(root.type === "split"); + wb.dispatch({ type: "resize", split: root.id, sizes: [1, 2, 1] }); + assert.deepEqual((wb.layout.root as typeof root).sizes, [0.25, 0.5, 0.25]); + const before = wb.layout; + wb.dispatch({ type: "resize", split: root.id, sizes: [1, 1] }); + assert.equal(wb.layout, before); +}); + +test("subscribers hear about changes, not no-ops", () => { + const wb = vscode(); + let calls = 0; + wb.subscribe(() => calls++); + wb.dispatch({ type: "close", panel: "missing" as never }); + wb.dispatch({ type: "toggle", slot: "panel" }); + assert.equal(calls, 1); +}); + +test("split commands move the active panel into a new group", () => { + const wb = workbench(); + wb.open({ kind: "editor", input: { path: "a.md" } }); + wb.open({ kind: "editor", input: { path: "b.md" } }); + command("panel.split.right")!.run(wb); + assert.equal(shape(wb), "row(main[a.md] stack[b.md])"); + assert.equal(wb.layout.focus, stacks(wb.layout.root)[1]!.id); +}); + +test("a stored layout round-trips through JSON", () => { + const wb = vscode(); + const parsed = parseLayout(JSON.parse(JSON.stringify(wb.layout))); + assert.deepEqual(parsed, wb.layout); +}); + +test("parsing rejects a layout without exactly one main stack, and drops unknown or unshown panels", () => { + const layout = JSON.parse(JSON.stringify(vscode().layout)); + assert.equal(parseLayout({ ...layout, root: { type: "stack", id: "x", panels: [], active: null } }), undefined); + assert.equal(parseLayout({ ...layout, version: 2 }), undefined); + const orphan = { id: "orphan", kind: "editor", input: { path: "z.md" } }; + const parsed = parseLayout({ ...layout, panels: { ...layout.panels, orphan } }); + assert.ok(parsed && !("orphan" in parsed.panels)); + const badInput = { ...layout.panels, orphan: { ...orphan, input: { path: 1 } } }; + assert.equal(parseLayout({ ...layout, panels: badInput }), undefined); +}); diff --git a/packages/app/tsconfig.json b/packages/app/tsconfig.json new file mode 100644 index 0000000..56c21f6 --- /dev/null +++ b/packages/app/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "strict": true, + "noUncheckedIndexedAccess": true, + "noEmit": true, + "skipLibCheck": true, + "allowImportingTsExtensions": true, + "types": ["node"] + }, + "include": ["src", "tests", "playground"] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d4169fe..3fc4ccf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,6 +30,21 @@ importers: specifier: ^0.25.0 version: 0.25.12 + packages/app: + devDependencies: + '@playwright/test': + specifier: ^1.50.0 + version: 1.64.1 + '@types/node': + specifier: ^24.0.0 + version: 24.19.2 + typescript: + specifier: ^5.7.0 + version: 5.9.3 + vite: + specifier: ^7.3.7 + version: 7.3.7(@types/node@24.19.2) + packages/kernel: devDependencies: '@playwright/test': diff --git a/probes/crdt/.gitignore b/probes/crdt/.gitignore new file mode 100644 index 0000000..995f754 --- /dev/null +++ b/probes/crdt/.gitignore @@ -0,0 +1,7 @@ +node_modules/ +dist/ +test-results/ +.wrangler/ +traces/ +perf/workerd/generated/ +*.log diff --git a/probes/crdt/correctness/RESULTS.md b/probes/crdt/correctness/RESULTS.md new file mode 100644 index 0000000..4827e32 --- /dev/null +++ b/probes/crdt/correctness/RESULTS.md @@ -0,0 +1,191 @@ +# CRDT bakeoff — merge correctness & editor bindings + +Scope: `loro-crdt@1.17.1`, `yjs@13.6.33`, `@y/y@14.0.0-rc.7` (Yjs v14 RC), `@automerge/automerge@3.5.0`. +Everything below was actually executed with `node` (bounded with `bound `); raw stdout for +each run is in `out/case1.txt`, `out/case2.txt`, `out/case5.txt`, `out/npmview.txt`, `out/downloads.txt`. +No library behavior here is guessed from docs — every claim is backed by a run in this directory. + +Adapters: `adapters/loro.mjs`, `adapters/yjs13.mjs`, `adapters/yjs14.mjs`, `adapters/automerge.mjs`. +Case scripts: `case1.mjs` (text), `case2.mjs` (tree), `case5.mjs` (editor bindings). + +Yjs whole-file diffing uses **fast-diff** (same library y-quill uses), as instructed. + +## Case 1 — whole-file writes vs live typing + +Base doc: 200 deterministic lines (`line NNN: lorem ipsum ...`). Peer A = human (char-by-char +`insert`), peer B = agent (whole-file write). + +### 1a — disjoint edits (A types HELLO in line 100; B rewrites lines 10/150/190) + +| library | B's whole-file write cost | converged | HELLO present | all 3 B-edits present | line count == 200 | +|---|---|---|---|---|---| +| loro | `LoroText.update`: 154 bytes / `updateByLine`: 420 bytes | yes | yes | yes | yes | +| yjs13 (fast-diff) | 3 ops / 95 bytes | yes | yes | yes | yes | +| yjs14 (fast-diff + delta builder) | 3 ops / 116 bytes | yes | yes | yes | yes | +| automerge (`updateText`) | 4 ops / 193 bytes | yes | yes | yes | yes | + +All four converge to the identical final text (verified byte-for-byte via `getText(a) === getText(b)` +after bidirectional exchange), no duplicated/lost lines. `LoroText.update` (whole-string diff) is +cheaper than `updateByLine` (line-oriented diff) for this edit pattern — both produce a minimal diff, +not delete-all/insert-all, satisfying the "report ops size, should be minimal" requirement. + +### 1b — overlapping (B's rewrite also touches line 100, the line A is typing in) + +All four libraries converge, and **all four produce the exact same merged line 100**, verbatim: + +``` +REWRITTEN: line 100: lorem ipsum doloHELLOr sit amet consectetur 100 +``` + +(B's `"REWRITTEN: " + originalLine100` and A's 5-character `HELLO` insertion mid-word both survive +and interleave identically across loro / yjs13 / yjs14 / automerge.) Costs: loro 172 bytes; yjs13 +4 ops/122 bytes; yjs14 4 ops/149 bytes; automerge 6 ops/229 bytes (automerge's text-splice op count +is consistently ~1.5–2x the Yjs fast-diff op count across both 1a and 1b, likely because +`updateText`'s internal diff is coarser-grained than fast-diff's). + +### 1c — stale base (the important one) + +B "reads" the file at V0 (before A's HELLO). A's HELLO reaches B's replica. B then writes a new +full file computed **from V0** (doesn't know about HELLO). + +**Naive ingestion (diff current-state → newText) DELETES A's HELLO, confirmed in all 4 libraries:** + +| library | naive result (line 100) | HELLO survives naive? | +|---|---|---| +| loro | `line 100: lorem ipsum dolor sit amet consectetur 100` | **no** | +| yjs13 | same | **no** | +| yjs14 | same | **no** | +| automerge | same | **no** | + +**3-way variant (diff against the version read, not current state) — HELLO survives in all 4:** + +| library | 3-way mechanism used | 3-way result (line 100) | HELLO survives? | +|---|---|---|---| +| loro | `doc.forkAt(frontiers)` → `update()` on fork → export update from fork's base → `import()` into main doc | `line 100: lorem ipsum doloHELLOr sit amet consectetur 100` | **yes** | +| yjs13 | `Y.snapshot()` (requires `gc:false`) → `Y.createDocFromSnapshot()` → fast-diff + edit the restored fork → `Y.encodeStateAsUpdate()` from fork's base → `Y.applyUpdate()` into live doc | same | **yes** | +| yjs14 | identical recipe to yjs13, using `@y/y`'s `Y.snapshot`/`createDocFromSnapshot` (present, unchanged API) | `hell!O world`-style ordering (see surprise below) but **same character set** survives | **yes** | +| automerge | `A.changeAt(doc, oldHeads, callback)` — the callback is handed the document **as of oldHeads** for editing, and the returned `newDoc` is already the fully-merged live doc (no separate `merge()` call; in fact `A.merge()` throws `"Attempting to change an out of date document"` if you try it on a `changeAt` result, since `changeAt` reuses the same actor id) | `line 100: lorem ipsum doloHELLOr sit amet consectetur 100` | **yes** | + +All four libraries have a clean, documented way to do the 3-way merge — none needed a "best +workaround" fallback. Automerge's `changeAt` is the cleanest API: you literally write your diff +logic as if editing the old version, and get the fully-reconciled doc back for free. + +**API surprise (yjs14 vs the other three):** the character-level merge *order* differs. For the +toy repro `"hello world"` → A inserts `!` at index 5 (making `"hello! world"`); B's rewrite (from +V0) capitalizes the `o` at index 4 (`"hellO world"`). yjs13 and automerge produce `"hellO! world"`; +yjs14, with the same fast-diff-derived delete+insert ops, produces `"hell!O world"` — both inserted +single characters anchor at the same left-neighbor item (the second `l`), and v14's generic `YType` +resolves that concurrent-insert tie differently from v13's `YText` in this specific diff encoding. +Both results are valid CRDT merges (same character set, different relative order of two single-char +concurrent edits) — worth flagging if an app depends on exact ordering of adjacent concurrent edits. + +## Case 2 — namespace tree with stable identities + +Loro: native `LoroTree` with per-node `.data` map holding `name`, and native `.move()`. The others +(yjs13, yjs14, automerge) have no move op, so they're modeled the standard way: a map +`id -> {parent, name}`. + +API notes / surprises: +- Loro: `tree.createNode(parentId)` takes a **node id string**, but `node.move(targetNode)` takes a + **node object** (not an id) — calling `.move()` with an id string panics the wasm module with an + unrecoverable `RuntimeError: unreachable` (not a catchable JS exception). `node.move()` with no + argument moves the node to root. +- `@y/y` v14 has no `Y.Map` class; the generic `YType`'s XML-element-style attribute slots + (`setAttr`/`getAttr`/`deleteAttr`/`attrEntries`) double as map semantics and were used for the + parent-pointer model, same shape as yjs13/automerge. +- Comparing two peers' maps via `JSON.stringify` gives false "diverged" readings purely from + JS object key insertion order differing between replicas (same entries, different order) — the + case script normalizes by sorting keys before comparing (`sameTree()` in `case2.mjs`). + +| test | loro | yjs13 | yjs14 | automerge | +|---|---|---|---|---| +| 2a concurrent move of same node to 2 parents | 1 winner, no dup, both peers agree | same | same | same | +| 2b move cycle (acyclic + reachable after merge?) | **yes — Loro's native move rejects the cycle automatically**, tree stays acyclic | **no — genuine cycle**, `a` and `b` both detached from root | same cycle as yjs13 | same cycle as yjs13 | +| 2c rename+move vs delete: does `d/x` survive? | yes, parent=root, name="x-renamed"; `d` itself gone | same | same | same | +| 2d name collision (two renames to "same") | both nodes survive, distinct ids, same name | same | same | same | +| 2e concurrent create under same dir | both present, converged | both present, converged (no native order) | same | same | + +**2b is the standout divergence.** Loro's native tree move has built-in cycle prevention: after +merging A's `move(a → under b)` and B's concurrent `move(b → under a)`, Loro's tree stays acyclic +and every node is reachable from root (one of the two moves is effectively not applied in a way +that would create a cycle). For the three parent-pointer models (yjs13, yjs14, automerge — no +native move op), the merge produces exactly the expected failure mode: a genuine 2-cycle +(`a.parent = b`, `b.parent = a`), both nodes unreachable from root. Raw data after merge (identical +across yjs13/yjs14/automerge): + +```json +{"root":{"parent":null,"name":"root"}, + "a":{"parent":"b","name":"a"}, + "b":{"parent":"a","name":"b"}, + "d":{"parent":"root","name":"d"}, + "d-x":{"parent":"d","name":"x"}, + "p":{"parent":"root","name":"p"}, + "q":{"parent":"root","name":"q"}} +``` +`reachable from root: [d, d-x, p, q, root]` — `unreachable/cyclic: [a, b]`. **Confirms the task's +prediction exactly**: any filesystem layer built on a parent-pointer model needs an app-level +cycle check/fixup on every move (walk up from the moved node and refuse/detach if it would hit +itself); Loro's tree gives you this for free. + +2c (rename+move vs. delete) result is identical across all four: `d/x` survives, detached to root +under the name `x-renamed`; the deleted `d` itself is gone. No library "undeletes" `d` or orphans +`x` silently — the content/identity separation held. + +Content-doc separation demo: renaming a node on A while B concurrently edits that node's separate +content-CRDT converges cleanly in all four libraries — the rename never touches the content doc. + +## Case 5 — editor bindings + +### Package facts (via `npm view` + npmjs downloads API, `out/npmview.txt` / `out/downloads.txt`) + +| binding | latest | last published | weekly downloads | peers on | +|---|---|---|---|---| +| `loro-codemirror` | 0.3.3 | 2025-10-07 | 6,674 | `loro-crdt ^1.8.2`, `@codemirror/{state,view} ^6` | +| `y-codemirror.next` | 0.3.6 | 2026-08-18 | 345,043 | `yjs ^13.5.6`, `@codemirror/{state,view} ^6` | +| `@automerge/automerge-codemirror` | 0.2.0 | 2026-04-13 | 460 | (none declared) | +| `loro-prosemirror` | 0.4.4 | 2026-08-22 | 25,179 | `loro-crdt ^1.10.2` | +| `y-prosemirror` | 1.3.7 | 2025-07-03 | 3,294,558 | `prosemirror-{model,state,view}`, `y-protocols ^1.0.1`, `yjs ^13.5.38` | +| `@automerge/prosemirror` | 0.2.0 | 2026-04-13 | 7,811 | (none declared) | + +`y-codemirror.next` / `y-prosemirror` declare a peer on `yjs ^13.x`, not `@y/y` — see the explicit +compatibility test below. + +### jsdom + CodeMirror 6 mount test (actually run, `case5.mjs` / `out/case5.txt`) + +jsdom hosted CodeMirror 6 fine once given `MutationObserver`, `requestAnimationFrame`/ +`cancelAnimationFrame` (not present on jsdom's `window` by default) and a non-frozen `navigator`. +For each binding: mount an `EditorView`, dispatch a local insert transaction, confirm it lands in +the CRDT; then apply a remote CRDT update, confirm it lands in the editor. + +| binding | mounted | local edit → CRDT | remote CRDT → editor | notes | +|---|---|---|---|---| +| `loro-codemirror` | yes | yes | yes | **must** use `doc.getText("codemirror")` — that's `defaultGetTextFromDoc`'s hardcoded key; using any other key (tried `"content"`) silently desyncs the plugin from the editor and later crashes CodeMirror's `ChangeSet.of` with `"Invalid change range ... doc of length 0"`. Also: pre-populating both the CRDT text *and* the initial `EditorState.doc` before mounting crashes the plugin ("Index out of bound... Position: loro_internal/handler.rs:2229") — mount with an empty editor doc and let the plugin own the initial sync. | +| `y-codemirror.next` | yes | yes | yes | works once mounted with an empty initial doc (plugin drives the initial sync itself); no key constraint (any `Y.Text` name works). | +| `@automerge/automerge-codemirror` | yes | yes | yes | needs a `DocHandle`-shaped object (`isReady/doc/change/on/off`) — stubbed a minimal one in ~10 lines; no `automerge-repo` dependency required for this to work. | +| `y-codemirror.next` on `@y/y@14.0.0-rc.7` | mounts (`EditorView` constructs) | **not tested further** | **not tested further** | fails with `yjs#509 Not same Y.Doc` as soon as the plugin tries to bind the `@y/y` text type — it does an `instanceof`/identity check against the v13 `Y.Doc`/`Y.Text` classes that a `@y/y` `Doc`/`YType` instance does not satisfy. Confirmed by direct error, not inferred from the peer-dep range. | + +ProseMirror bindings were **not** mounted — the ~30 minute timebox for the hands-on jsdom exercise +was spent getting the three CodeMirror bindings working (each had a real, non-obvious integration +bug: wrong text key, wrong mount order, missing DocHandle shape). Package facts for the ProseMirror +bindings (table above) were still gathered and verified via `npm view`/downloads API, per the task. + +## What wasn't tested / limitations + +- ProseMirror editor mounting (CodeMirror consumed the Case 5 timebox; see above). +- `@y/y` v14's tree/map modeling (`setAttr`/`getAttr`/`attrEntries`) was exercised only in Case 2's + parent-pointer tests, not independently stress-tested beyond what the case script covers. +- No perf/size measurements — explicitly out of scope for this half of the bakeoff (the other agent + owns size/perf). +- Case 1's "B whole-file write ops" counts are `fast-diff`-derived op counts (yjs13/yjs14) or the + underlying library's own op/patch count (loro's exported-update byte length; automerge's + `A.diff()` patch count) — these aren't all the same unit, so cross-library op-count comparisons + in the tables above are indicative, not apples-to-apples; bytes are the more comparable number + for "was this a minimal diff." + +## Files + +- `adapters/loro.mjs`, `adapters/yjs13.mjs`, `adapters/yjs14.mjs`, `adapters/automerge.mjs` +- `case1.mjs`, `case2.mjs`, `case5.mjs` +- `out/case1.txt`, `out/case2.txt`, `out/case5.txt`, `out/npmview.txt`, `out/downloads.txt`, + `out/npm-install.txt`, `out/npm-install2.txt` +- `package.json` / `package-lock.json` (npm, standalone, outside the pnpm workspace globs) diff --git a/probes/crdt/correctness/adapters/automerge.mjs b/probes/crdt/correctness/adapters/automerge.mjs new file mode 100644 index 0000000..a8a45cf --- /dev/null +++ b/probes/crdt/correctness/adapters/automerge.mjs @@ -0,0 +1,128 @@ +// Automerge adapter — @automerge/automerge@3.5.0 +import * as A from '@automerge/automerge'; + +export const name = 'automerge'; +export const TREE_KEY = 'tree'; + +export function createDoc() { + let doc = A.init(); + return { doc }; +} + +// ---- text ---- +export function initText(box, text) { + box.doc = A.change(box.doc, d => { + d.text = ''; + A.updateText(d, ['text'], text); + }); +} + +export function getText(box) { + return box.doc.text; +} + +export function insertChar(box, index, ch) { + box.doc = A.change(box.doc, d => { + A.splice(d, ['text'], index, 0, ch); + }); +} + +export function getVersion(box) { + return A.getHeads(box.doc); +} + +// naive: diff against current content, apply directly (updateText diffs internally against doc's +// current text at the given path, and only emits the minimal ops). +export function wholeFileNaiveUpdate(box, newText) { + const before = box.save ? null : null; + const v0 = A.getHeads(box.doc); + box.doc = A.change(box.doc, d => { + A.updateText(d, ['text'], newText); + }); + const patch = A.diff(box.doc, v0, A.getHeads(box.doc)); + return { ops: patch.length, bytes: A.saveSince(box.doc, v0).length }; +} + +// 3-way: `version` = heads B read at (V0). changeAt presents the callback with the document +// AS OF `version` for editing, but splices the resulting change into the live doc's history as +// a change causally concurrent with anything that happened after `version`. The returned newDoc +// is the full, already-merged document — no separate merge() call needed (and plain A.merge() +// does not work here since changeAt reuses the same actor id). +export function wholeFileVersionedUpdate(box, version, newText) { + const r = A.changeAt(box.doc, version, d => { + A.updateText(d, ['text'], newText); + }); + const patch = A.diff(r.newDoc, version, r.newHeads); + box.doc = r.newDoc; + return { ops: patch.length, bytes: null, baseTextWasFork: true }; +} + +export function exportFull(box) { + return A.save(box.doc); +} + +export function importBytes(box, bytes) { + // merge in a doc loaded from bytes (used to bring in a peer's changes) + const incoming = A.load(bytes); + box.doc = A.merge(box.doc, incoming); +} + +export function cloneForPeer(box) { + return { doc: A.clone(box.doc) }; +} + +// ---- tree: parent-pointer model (plain map id -> {parent, name}); Automerge has no move op ---- +function treeMap(box) { + if (!box.doc.tree) { + box.doc = A.change(box.doc, d => { d.tree = {}; }); + } + return box.doc.tree; +} + +export function treeCreateRoot(box, name, id) { + treeMap(box); + box.doc = A.change(box.doc, d => { + d.tree[id] = { parent: null, name }; + }); + return id; +} + +export function treeCreateChild(box, parentId, name, id) { + treeMap(box); + box.doc = A.change(box.doc, d => { + d.tree[id] = { parent: parentId, name }; + }); + return id; +} + +export function treeMove(box, nodeId, newParentId) { + box.doc = A.change(box.doc, d => { + d.tree[nodeId].parent = newParentId; + }); +} + +export function treeMoveToRoot(box, nodeId) { + box.doc = A.change(box.doc, d => { + d.tree[nodeId].parent = null; + }); +} + +export function treeRename(box, nodeId, newName) { + box.doc = A.change(box.doc, d => { + d.tree[nodeId].name = newName; + }); +} + +export function treeDelete(box, nodeId) { + box.doc = A.change(box.doc, d => { + delete d.tree[nodeId]; + }); +} + +export function treeRaw(box) { + const out = {}; + for (const [k, v] of Object.entries(box.doc.tree || {})) { + out[k] = { parent: v.parent, name: v.name }; + } + return out; +} diff --git a/probes/crdt/correctness/adapters/loro.mjs b/probes/crdt/correctness/adapters/loro.mjs new file mode 100644 index 0000000..5d4df67 --- /dev/null +++ b/probes/crdt/correctness/adapters/loro.mjs @@ -0,0 +1,140 @@ +// Loro adapter — loro-crdt@1.17.1 +import { LoroDoc } from 'loro-crdt'; + +export const name = 'loro'; +export const TEXT_KEY = 'content'; +export const TREE_KEY = 'tree'; + +export function createDoc(peerId) { + const doc = new LoroDoc(); + if (peerId != null) doc.setPeerId(BigInt(peerId)); + return { doc }; +} + +// ---- text ---- +export function initText(box, text) { + box.doc.getText(TEXT_KEY).insert(0, text); + box.doc.commit(); +} + +export function getText(box) { + return box.doc.getText(TEXT_KEY).toString(); +} + +export function insertChar(box, index, ch) { + box.doc.getText(TEXT_KEY).insert(index, ch); + box.doc.commit(); +} + +export function getVersion(box) { + return box.doc.frontiers(); +} + +export function forkAt(box, version) { + const forked = box.doc.forkAt(version); + return { doc: forked }; +} + +// naive whole-file update applied directly against current live state +export function wholeFileNaiveUpdate(box, newText) { + const before = box.doc.export({ mode: 'update', from: box.doc.oplogVersion() }); // empty baseline marker, unused + const v0 = box.doc.oplogVersion(); + box.doc.getText(TEXT_KEY).update(newText); + box.doc.commit(); + const patch = box.doc.export({ mode: 'update', from: v0 }); + return { bytes: patch.length }; +} + +export function wholeFileUpdateByLine(box, newText) { + const v0 = box.doc.oplogVersion(); + box.doc.getText(TEXT_KEY).updateByLine(newText); + box.doc.commit(); + const patch = box.doc.export({ mode: 'update', from: v0 }); + return { bytes: patch.length }; +} + +// 3-way: B read at `version` (frontiers), computed newText from that snapshot. +// Apply the edit on a fork at `version`, then transplant the resulting ops into box's doc. +export function wholeFileVersionedUpdate(box, version, newText) { + const fork = box.doc.forkAt(version); + const forkV0 = fork.oplogVersion(); + fork.getText(TEXT_KEY).update(newText); + fork.commit(); + const patch = fork.export({ mode: 'update', from: forkV0 }); + box.doc.import(patch); + box.doc.commit(); + return { bytes: patch.length }; +} + +export function exportFull(box) { + return box.doc.export({ mode: 'snapshot' }); +} + +export function importBytes(box, bytes) { + box.doc.import(bytes); +} + +export function cloneForPeer(box, peerId) { + const bytes = box.doc.export({ mode: 'snapshot' }); + const doc = new LoroDoc(); + if (peerId != null) doc.setPeerId(BigInt(peerId)); + doc.import(bytes); + return { doc }; +} + +// ---- tree ---- +export function treeCreateRoot(box, name) { + const node = box.doc.getTree(TREE_KEY).createNode(); + node.data.set('name', name); + box.doc.commit(); + return node.id; +} + +export function treeCreateChild(box, parentId, name) { + const tree = box.doc.getTree(TREE_KEY); + const node = tree.createNode(parentId); + node.data.set('name', name); + box.doc.commit(); + return node.id; +} + +export function treeMove(box, nodeId, newParentId) { + const tree = box.doc.getTree(TREE_KEY); + const node = tree.getNodeByID(nodeId); + const parent = tree.getNodeByID(newParentId); + node.move(parent); + box.doc.commit(); +} + +export function treeMoveToRoot(box, nodeId) { + const tree = box.doc.getTree(TREE_KEY); + const node = tree.getNodeByID(nodeId); + node.move(); + box.doc.commit(); +} + +export function treeRename(box, nodeId, newName) { + const tree = box.doc.getTree(TREE_KEY); + const node = tree.getNodeByID(nodeId); + node.data.set('name', newName); + box.doc.commit(); +} + +export function treeDelete(box, nodeId) { + const tree = box.doc.getTree(TREE_KEY); + tree.delete(tree.getNodeByID(nodeId).id); + box.doc.commit(); +} + +// Returns { ok: tree-shaped JSON if acyclic reachable from root, raw: full node list } +export function treeDump(box) { + const tree = box.doc.getTree(TREE_KEY); + return tree.toJSON(); +} + +export function treeNodeIds(box) { + return tree_ids(box); +} +function tree_ids(box) { + return box.doc.getTree(TREE_KEY).nodes().map(n => n.id); +} diff --git a/probes/crdt/correctness/adapters/yjs13.mjs b/probes/crdt/correctness/adapters/yjs13.mjs new file mode 100644 index 0000000..7dee5c7 --- /dev/null +++ b/probes/crdt/correctness/adapters/yjs13.mjs @@ -0,0 +1,134 @@ +// Yjs v13 adapter — yjs@13.6.33. Whole-file diffing via fast-diff (same lib y-quill uses). +import * as Y from 'yjs'; +import fastDiff from 'fast-diff'; + +export const name = 'yjs13'; +export const TEXT_KEY = 'content'; +export const TREE_KEY = 'tree'; // Y.Map id -> {parent, name} + +export function createDoc() { + // gc:false is required so Y.snapshot()/createDocFromSnapshot() can see history (needed for case 1c) + const doc = new Y.Doc({ gc: false }); + return { doc }; +} + +// ---- text ---- +export function initText(box, text) { + box.doc.getText(TEXT_KEY).insert(0, text); +} + +export function getText(box) { + return box.doc.getText(TEXT_KEY).toString(); +} + +export function insertChar(box, index, ch) { + box.doc.getText(TEXT_KEY).insert(index, ch); +} + +export function getVersion(box) { + return Y.snapshot(box.doc); +} + +// Apply a fast-diff based patch (oldText -> newText) onto a Y.Text, at current positions. +function applyDiffToYText(ytext, oldText, newText) { + const diffs = fastDiff(oldText, newText); + let ops = 0; + let idx = 0; + for (const [op, chunk] of diffs) { + if (op === fastDiff.EQUAL) { + idx += chunk.length; + } else if (op === fastDiff.DELETE) { + ytext.delete(idx, chunk.length); + ops++; + } else if (op === fastDiff.INSERT) { + ytext.insert(idx, chunk); + idx += chunk.length; + ops++; + } + } + return ops; +} + +// naive: diff CURRENT state -> newText, apply directly to live doc +export function wholeFileNaiveUpdate(box, newText) { + const before = box.doc.getText(TEXT_KEY).toString(); + const v0 = Y.encodeStateVector(box.doc); + const ops = applyDiffToYText(box.doc.getText(TEXT_KEY), before, newText); + const patch = Y.encodeStateAsUpdate(box.doc, v0); + return { ops, bytes: patch.length }; +} + +// 3-way: `version` is a Y.Snapshot taken earlier (what B "read"). Build a throwaway doc +// restoring that snapshot's content, edit IT to newText, then transplant the resulting +// update into the live doc. Yjs merges by item-id/relative-position so this interleaves +// correctly with edits the live doc received after the snapshot was taken. +export function wholeFileVersionedUpdate(box, version, newText) { + const forkDoc = Y.createDocFromSnapshot(box.doc, version, new Y.Doc({ gc: false })); + const forkText = forkDoc.getText(TEXT_KEY); + const baseText = forkText.toString(); + const v0 = Y.encodeStateVector(forkDoc); + const ops = applyDiffToYText(forkText, baseText, newText); + const patch = Y.encodeStateAsUpdate(forkDoc, v0); + Y.applyUpdate(box.doc, patch); + return { ops, bytes: patch.length, baseText }; +} + +export function exportFull(box) { + return Y.encodeStateAsUpdate(box.doc); +} + +export function importBytes(box, bytes) { + Y.applyUpdate(box.doc, bytes); +} + +export function cloneForPeer(box) { + const bytes = Y.encodeStateAsUpdate(box.doc); + const doc = new Y.Doc({ gc: false }); + Y.applyUpdate(doc, bytes); + return { doc }; +} + +// ---- tree: parent-pointer model in a Y.Map ---- +function treeMap(box) { + return box.doc.getMap(TREE_KEY); +} + +export function treeCreateRoot(box, name, id) { + const m = new Y.Map(); + m.set('parent', null); + m.set('name', name); + treeMap(box).set(id, m); + return id; +} + +export function treeCreateChild(box, parentId, name, id) { + const m = new Y.Map(); + m.set('parent', parentId); + m.set('name', name); + treeMap(box).set(id, m); + return id; +} + +export function treeMove(box, nodeId, newParentId) { + treeMap(box).get(nodeId).set('parent', newParentId); +} + +export function treeMoveToRoot(box, nodeId) { + treeMap(box).get(nodeId).set('parent', null); +} + +export function treeRename(box, nodeId, newName) { + treeMap(box).get(nodeId).set('name', newName); +} + +export function treeDelete(box, nodeId) { + treeMap(box).delete(nodeId); +} + +export function treeRaw(box) { + const out = {}; + treeMap(box).forEach((v, k) => { + out[k] = { parent: v.get('parent'), name: v.get('name') }; + }); + return out; +} diff --git a/probes/crdt/correctness/adapters/yjs14.mjs b/probes/crdt/correctness/adapters/yjs14.mjs new file mode 100644 index 0000000..0a1dafa --- /dev/null +++ b/probes/crdt/correctness/adapters/yjs14.mjs @@ -0,0 +1,135 @@ +// Yjs v14 RC adapter — @y/y@14.0.0-rc.7 +// API SURPRISE: v14 drops the familiar Y.Text/Y.Map/Y.Array classes. doc.get(name) returns a +// generic YType; mutation happens through a delta builder (lib0/delta: create().retain(n).insert(x) +// .delete(n).done()) applied via ytype.applyDelta(delta). Text content is read with .toString(). +import * as Y from '@y/y'; +import * as delta from 'lib0/delta'; +import fastDiff from 'fast-diff'; + +export const name = 'yjs14'; +export const TEXT_KEY = 'content'; +export const TREE_KEY = 'tree'; + +export function createDoc() { + const doc = new Y.Doc({ gc: false }); + return { doc }; +} + +export function initText(box, text) { + box.doc.get(TEXT_KEY).applyDelta(delta.create().insert(text).done()); +} + +export function getText(box) { + return box.doc.get(TEXT_KEY).toString(); +} + +export function insertChar(box, index, ch) { + box.doc.get(TEXT_KEY).applyDelta(delta.create().retain(index).insert(ch).done()); +} + +export function getVersion(box) { + return Y.snapshot(box.doc); +} + +function applyDiffToYType(ytype, oldText, newText) { + const diffs = fastDiff(oldText, newText); + let ops = 0; + const builder = delta.create(); + let pendingRetain = 0; + for (const [op, chunk] of diffs) { + if (op === fastDiff.EQUAL) { + pendingRetain += chunk.length; + } else if (op === fastDiff.DELETE) { + if (pendingRetain) { builder.retain(pendingRetain); pendingRetain = 0; } + builder.delete(chunk.length); + ops++; + } else if (op === fastDiff.INSERT) { + if (pendingRetain) { builder.retain(pendingRetain); pendingRetain = 0; } + builder.insert(chunk); + ops++; + } + } + ytype.applyDelta(builder.done()); + return ops; +} + +export function wholeFileNaiveUpdate(box, newText) { + const before = box.doc.get(TEXT_KEY).toString(); + const v0 = Y.encodeStateVector(box.doc); + const ops = applyDiffToYType(box.doc.get(TEXT_KEY), before, newText); + const patch = Y.encodeStateAsUpdate(box.doc, v0); + return { ops, bytes: patch.length }; +} + +export function wholeFileVersionedUpdate(box, version, newText) { + const forkDoc = Y.createDocFromSnapshot(box.doc, version, new Y.Doc({ gc: false })); + const forkType = forkDoc.get(TEXT_KEY); + const baseText = forkType.toString(); + const v0 = Y.encodeStateVector(forkDoc); + const ops = applyDiffToYType(forkType, baseText, newText); + const patch = Y.encodeStateAsUpdate(forkDoc, v0); + Y.applyUpdate(box.doc, patch); + return { ops, bytes: patch.length, baseText }; +} + +export function exportFull(box) { + return Y.encodeStateAsUpdate(box.doc); +} + +export function importBytes(box, bytes) { + Y.applyUpdate(box.doc, bytes); +} + +export function cloneForPeer(box) { + const bytes = Y.encodeStateAsUpdate(box.doc); + const doc = new Y.Doc({ gc: false }); + Y.applyUpdate(doc, bytes); + return { doc }; +} + +// ---- tree: parent-pointer model. v14 has no separate Y.Map class; a generic YType's "attrs" +// (its XmlElement-style attribute slots: setAttr/getAttr/deleteAttr/attrEntries) double as +// map semantics, so we key each tree node's {parent, name} record off an attr named by its id. +function treeMapGet(box) { + return box.doc.get(TREE_KEY); +} + +export function treeCreateRoot(box, name, id) { + treeMapGet(box).setAttr(id, { parent: null, name }); + return id; +} + +export function treeCreateChild(box, parentId, name, id) { + treeMapGet(box).setAttr(id, { parent: parentId, name }); + return id; +} + +export function treeMove(box, nodeId, newParentId) { + const m = treeMapGet(box); + const entry = m.getAttr(nodeId); + m.setAttr(nodeId, { parent: newParentId, name: entry.name }); +} + +export function treeMoveToRoot(box, nodeId) { + const m = treeMapGet(box); + const entry = m.getAttr(nodeId); + m.setAttr(nodeId, { parent: null, name: entry.name }); +} + +export function treeRename(box, nodeId, newName) { + const m = treeMapGet(box); + const entry = m.getAttr(nodeId); + m.setAttr(nodeId, { parent: entry.parent, name: newName }); +} + +export function treeDelete(box, nodeId) { + treeMapGet(box).deleteAttr(nodeId); +} + +export function treeRaw(box) { + const out = {}; + for (const [k, v] of treeMapGet(box).attrEntries()) { + out[k] = v; + } + return out; +} diff --git a/probes/crdt/correctness/case1.mjs b/probes/crdt/correctness/case1.mjs new file mode 100644 index 0000000..df3b059 --- /dev/null +++ b/probes/crdt/correctness/case1.mjs @@ -0,0 +1,196 @@ +// Case 1 — whole-file writes vs live typing (text), run against every adapter. +import * as loro from './adapters/loro.mjs'; +import * as yjs13 from './adapters/yjs13.mjs'; +import * as yjs14 from './adapters/yjs14.mjs'; +import * as automerge from './adapters/automerge.mjs'; + +const LIBS = [loro, yjs13, yjs14, automerge]; + +function genLines(n) { + const lines = []; + for (let i = 1; i <= n; i++) { + lines.push(`line ${String(i).padStart(3, '0')}: lorem ipsum dolor sit amet consectetur ${i}`); + } + return lines; +} + +function setLine(lines, idx1based, newLine) { + const copy = lines.slice(); + copy[idx1based - 1] = newLine; + return copy; +} + +function joinText(lines) { + return lines.join('\n') + '\n'; +} + +function report(title) { + console.log('\n' + '='.repeat(80)); + console.log(title); + console.log('='.repeat(80)); +} + +const baseLines = genLines(200); +const baseText = joinText(baseLines); + +// -------------------- 1a: disjoint -------------------- +report('CASE 1a — disjoint: A types HELLO char-by-char in line 100; B rewrites lines 10/150/190'); + +for (const lib of LIBS) { + console.log(`\n--- ${lib.name} ---`); + const a = lib.createDoc(1); + lib.initText(a, baseText); + const b = lib.cloneForPeer(a, 2); + + // A types HELLO char by char in the middle of line 100 (0-indexed line 99) + const line100 = baseLines[99]; + const mid = Math.floor(line100.length / 2); + // absolute char offset of that position in baseText + const prefixLines = baseLines.slice(0, 99).join('\n') + '\n'; + const insertAt = prefixLines.length + mid; + let cursor = insertAt; + for (const ch of 'HELLO') { + lib.insertChar(a, cursor, ch); + cursor += 1; + } + + // B computes a new full file with lines 10, 150, 190 changed, from the version it already has + // (no concurrency yet at this point — this is the "normal" whole-file write path). + const newLines10 = setLine(setLine(setLine(baseLines, 10, baseLines[9] + ' [B-EDIT-10]'), 150, baseLines[149] + ' [B-EDIT-150]'), 190, baseLines[189] + ' [B-EDIT-190]'); + const newFullText = joinText(newLines10); + let result; + if (lib === loro) { + result = lib.wholeFileNaiveUpdate(b, newFullText); + // compare LoroText.update vs updateByLine cost on an identical throwaway peer + const bLine = lib.cloneForPeer(a, 3); + const resultByLine = lib.wholeFileUpdateByLine(bLine, newFullText); + console.log(' B whole-file write LoroText.update bytes:', result.bytes, '| updateByLine bytes:', resultByLine.bytes); + } else { + result = lib.wholeFileNaiveUpdate(b, newFullText); + console.log(' B whole-file write ops:', result.ops, 'bytes:', result.bytes); + } + + // exchange updates both directions + const updA = lib.exportFull(a); + const updB = lib.exportFull(b); + lib.importBytes(a, updB); + lib.importBytes(b, updA); + + const finalA = lib.getText(a); + const finalB = lib.getText(b); + const converged = finalA === finalB; + const hasHello = finalA.includes('HELLO'); + const has10 = finalA.includes('[B-EDIT-10]'); + const has150 = finalA.includes('[B-EDIT-150]'); + const has190 = finalA.includes('[B-EDIT-190]'); + const lineCountOk = finalA.split('\n').filter(Boolean).length === 200; + + console.log(' converged:', converged, '| HELLO present:', hasHello, '| edit10:', has10, '| edit150:', has150, '| edit190:', has190, '| lineCount200:', lineCountOk); + if (!converged || !hasHello || !has10 || !has150 || !has190 || !lineCountOk) { + console.log(' FAILURE DETAIL — finalA line100:', finalA.split('\n')[99]); + } +} + +// -------------------- 1b: overlapping -------------------- +report('CASE 1b — overlapping: B\'s rewrite also changes line 100 (the line A is typing in)'); + +for (const lib of LIBS) { + console.log(`\n--- ${lib.name} ---`); + const a = lib.createDoc(1); + lib.initText(a, baseText); + const b = lib.cloneForPeer(a, 2); + + const line100 = baseLines[99]; + const mid = Math.floor(line100.length / 2); + const prefixLines = baseLines.slice(0, 99).join('\n') + '\n'; + const insertAt = prefixLines.length + mid; + let cursor = insertAt; + for (const ch of 'HELLO') { + lib.insertChar(a, cursor, ch); + cursor += 1; + } + + // B's rewrite ALSO changes line 100 (in addition to 10/150/190) — concurrently, from B's + // pre-HELLO view of the file. + let newLines = setLine(baseLines, 10, baseLines[9] + ' [B-EDIT-10]'); + newLines = setLine(newLines, 100, 'REWRITTEN: ' + baseLines[99]); + newLines = setLine(newLines, 150, baseLines[149] + ' [B-EDIT-150]'); + newLines = setLine(newLines, 190, baseLines[189] + ' [B-EDIT-190]'); + const newFullText = joinText(newLines); + const result = lib.wholeFileNaiveUpdate(b, newFullText); + console.log(' B whole-file write ops/bytes:', result.ops ?? '(n/a)', result.bytes); + + const updA = lib.exportFull(a); + const updB = lib.exportFull(b); + lib.importBytes(a, updB); + lib.importBytes(b, updA); + + const finalA = lib.getText(a); + const finalB = lib.getText(b); + const converged = finalA === finalB; + const mergedLine100 = finalA.split('\n')[99]; + console.log(' converged:', converged); + console.log(' MERGED LINE 100 (verbatim):', JSON.stringify(mergedLine100)); +} + +// -------------------- 1c: stale base -------------------- +report('CASE 1c — stale base: B reads at V0, A types HELLO, naive ingestion deletes it; 3-way variant preserves it'); + +for (const lib of LIBS) { + console.log(`\n--- ${lib.name} ---`); + + // --- naive path --- + { + const a = lib.createDoc(1); + lib.initText(a, baseText); + const b = lib.cloneForPeer(a, 2); + const v0 = lib.getVersion(b); // B "reads" the file here + + const line100 = baseLines[99]; + const mid = Math.floor(line100.length / 2); + const prefixLines = baseLines.slice(0, 99).join('\n') + '\n'; + const insertAt = prefixLines.length + mid; + let cursor = insertAt; + for (const ch of 'HELLO') { + lib.insertChar(a, cursor, ch); + cursor += 1; + } + // A's HELLO reaches B + lib.importBytes(b, lib.exportFull(a)); + console.log(' B after receiving A\'s HELLO:', lib.getText(b).split('\n')[99]); + + // B now writes its new full file, computed from V0 (lacks HELLO) — naive diff against + // CURRENT state (which already has HELLO) + const newLines10 = setLine(baseLines, 10, baseLines[9] + ' [B-EDIT-10]'); + const newFullText = joinText(newLines10); + lib.wholeFileNaiveUpdate(b, newFullText); + const line100Naive = lib.getText(b).split('\n')[99]; + console.log(' NAIVE result line 100:', JSON.stringify(line100Naive), '| HELLO survives naive:', line100Naive.includes('HELLO')); + } + + // --- 3-way path --- + { + const a = lib.createDoc(1); + lib.initText(a, baseText); + const b = lib.cloneForPeer(a, 2); + const v0 = lib.getVersion(b); // B "reads" the file here (frontiers/heads/snapshot) + + const line100 = baseLines[99]; + const mid = Math.floor(line100.length / 2); + const prefixLines = baseLines.slice(0, 99).join('\n') + '\n'; + const insertAt = prefixLines.length + mid; + let cursor = insertAt; + for (const ch of 'HELLO') { + lib.insertChar(a, cursor, ch); + cursor += 1; + } + lib.importBytes(b, lib.exportFull(a)); // A's HELLO reaches B + + const newLines10 = setLine(baseLines, 10, baseLines[9] + ' [B-EDIT-10]'); + const newFullText = joinText(newLines10); // computed from V0 (baseLines), no HELLO + const r = lib.wholeFileVersionedUpdate(b, v0, newFullText); + const line100ThreeWay = lib.getText(b).split('\n')[99]; + console.log(' 3-WAY result line 100:', JSON.stringify(line100ThreeWay), '| HELLO survives 3-way:', line100ThreeWay.includes('HELLO'), '| patch info:', JSON.stringify({ ops: r.ops, bytes: r.bytes })); + console.log(' 3-way result line 10:', lib.getText(b).split('\n')[9]); + } +} diff --git a/probes/crdt/correctness/case2.mjs b/probes/crdt/correctness/case2.mjs new file mode 100644 index 0000000..f7b289c --- /dev/null +++ b/probes/crdt/correctness/case2.mjs @@ -0,0 +1,229 @@ +// Case 2 — namespace tree with stable identities, run against every adapter. +import * as loro from './adapters/loro.mjs'; +import * as yjs13 from './adapters/yjs13.mjs'; +import * as yjs14 from './adapters/yjs14.mjs'; +import * as automerge from './adapters/automerge.mjs'; + +const LIBS = [loro, yjs13, yjs14, automerge]; + +function report(title) { + console.log('\n' + '='.repeat(80)); + console.log(title); + console.log('='.repeat(80)); +} + +// Loro uses native tree ids (returned by createNode); the parent-pointer libs let us pick ids. +// We allocate our own deterministic ids for the parent-pointer libs, and use whatever Loro hands +// back (tracking them in a name->id map) so all libraries can be driven by the same case script. +function buildBaseTree(lib) { + const doc = lib.createDoc(1); + const ids = {}; + ids.root = lib.treeCreateRoot(doc, 'root', 'root'); + ids.a = lib.treeCreateChild(doc, ids.root, 'a', 'a'); + ids.b = lib.treeCreateChild(doc, ids.root, 'b', 'b'); + ids.d = lib.treeCreateChild(doc, ids.root, 'd', 'd'); + ids.x = lib.treeCreateChild(doc, ids.d, 'x', 'd-x'); + ids.p = lib.treeCreateChild(doc, ids.root, 'p', 'p'); + ids.q = lib.treeCreateChild(doc, ids.root, 'q', 'q'); + return { doc, ids }; +} + +function dumpRaw(lib, doc) { + return lib.treeRaw ? lib.treeRaw(doc) : lib.treeDump(doc); +} + +// Normalize raw parent-pointer / Loro-tree data into {id: {parent, name}} for uniform printing, +// and independently check reachability-from-root + acyclicity. +function normalize(lib, doc) { + if (lib === loro) { + const nodes = {}; + const walk = (list, parent) => { + for (const n of list) { + nodes[n.id] = { parent, name: n.meta?.name }; + if (n.children?.length) walk(n.children, n.id); + } + }; + walk(lib.treeDump(doc), null); + return nodes; + } + return lib.treeRaw(doc); +} + +// Order-independent equality: Y.Map/Automerge map iteration order is not part of CRDT semantics, +// only the (id -> {parent,name}) *set* is. Compare sorted entries, not raw JSON.stringify. +function sameTree(flatA, flatB) { + const keysA = Object.keys(flatA).sort(); + const keysB = Object.keys(flatB).sort(); + if (JSON.stringify(keysA) !== JSON.stringify(keysB)) return false; + return keysA.every(k => JSON.stringify(flatA[k]) === JSON.stringify(flatB[k])); +} + +function checkReachability(flat, rootId) { + const ids = Object.keys(flat); + const reachable = new Set(); + for (const id of ids) { + // walk up parent chain with cycle protection + let cur = id; + const seen = new Set(); + let hitRoot = false; + let cyclic = false; + while (cur != null) { + if (seen.has(cur)) { cyclic = true; break; } + seen.add(cur); + if (cur === rootId) { hitRoot = true; break; } + const entry = flat[cur]; + if (!entry) break; // parent not in this doc's node set (e.g. deleted) -> treat as orphan + cur = entry.parent; + } + if (hitRoot && !cyclic) reachable.add(id); + } + return { reachable: [...reachable], unreachableOrCyclic: ids.filter(id => !reachable.has(id)) }; +} + +for (const lib of LIBS) { + report(`CASE 2 — ${lib.name}`); + + // ---- 2a: concurrent move of the same node to two different parents ---- + { + console.log('\n-- 2a concurrent move of same node to two different parents --'); + const { doc: docA, ids } = buildBaseTree(lib); + const docB = lib.cloneForPeer(docA, 2); + + lib.treeMove(docA, ids.x, ids.a); // A moves d/x into a + lib.treeMove(docB, ids.x, ids.b); // B moves d/x into b (concurrently) + + const upA = lib.exportFull(docA); + const upB = lib.exportFull(docB); + lib.importBytes(docA, upB); + lib.importBytes(docB, upA); + + const flatA = normalize(lib, docA); + const flatB = normalize(lib, docB); + console.log(' A sees x.parent =', flatA[ids.x]?.parent, '| B sees x.parent =', flatB[ids.x]?.parent); + console.log(' converged (A==B JSON):', sameTree(flatA, flatB)); + const xCountA = Object.values(flatA).filter(n => n.name === 'x').length; + console.log(' exactly one x node, one parent, no duplicate:', xCountA === 1); + } + + // ---- 2b: move cycle ---- + { + console.log('\n-- 2b move cycle: A moves a into b, B moves b into a --'); + const { doc: docA, ids } = buildBaseTree(lib); + const docB = lib.cloneForPeer(docA, 2); + + lib.treeMove(docA, ids.a, ids.b); // A: a -> under b + lib.treeMove(docB, ids.b, ids.a); // B: b -> under a (concurrently) + + const upA = lib.exportFull(docA); + const upB = lib.exportFull(docB); + lib.importBytes(docA, upB); + lib.importBytes(docB, upA); + + const flatA = normalize(lib, docA); + const flatB = normalize(lib, docB); + console.log(' raw data (A):', JSON.stringify(flatA)); + console.log(' raw data (B):', JSON.stringify(flatB)); + const { reachable, unreachableOrCyclic } = checkReachability(flatA, ids.root); + console.log(' reachable from root:', reachable.sort()); + console.log(' unreachable / cyclic (detached):', unreachableOrCyclic.sort()); + console.log(' acyclic & fully reachable:', unreachableOrCyclic.length === 0); + } + + // ---- 2c: rename vs delete ---- + { + console.log('\n-- 2c rename vs delete: A deletes dir d (with children); B moves d/x out to root and renames --'); + const { doc: docA, ids } = buildBaseTree(lib); + const docB = lib.cloneForPeer(docA, 2); + + lib.treeDelete(docA, ids.d); // A deletes d (and, for tree-native libs, its subtree) + lib.treeMoveToRoot(docB, ids.x); // B concurrently moves d/x to root + lib.treeRename(docB, ids.x, 'x-renamed'); + + const upA = lib.exportFull(docA); + const upB = lib.exportFull(docB); + lib.importBytes(docA, upB); + lib.importBytes(docB, upA); + + const flatA = normalize(lib, docA); + const flatB = normalize(lib, docB); + console.log(' A final:', JSON.stringify(flatA)); + console.log(' B final:', JSON.stringify(flatB)); + const xSurvives = (ids.x in flatA) || !!flatA[ids.x]; + console.log(' d-x present after merge:', ids.x in flatA, '| its parent:', flatA[ids.x]?.parent, '| its name:', flatA[ids.x]?.name); + console.log(' d itself present after merge:', ids.d in flatA); + } + + // ---- 2d: name collision ---- + { + console.log('\n-- 2d name collision: A renames p -> same, B renames q -> same --'); + const { doc: docA, ids } = buildBaseTree(lib); + const docB = lib.cloneForPeer(docA, 2); + + lib.treeRename(docA, ids.p, 'same'); + lib.treeRename(docB, ids.q, 'same'); + + const upA = lib.exportFull(docA); + const upB = lib.exportFull(docB); + lib.importBytes(docA, upB); + lib.importBytes(docB, upA); + + const flatA = normalize(lib, docA); + console.log(' p:', JSON.stringify(flatA[ids.p]), '| q:', JSON.stringify(flatA[ids.q])); + console.log(' both nodes still exist with distinct ids, same name:', flatA[ids.p]?.name === 'same' && flatA[ids.q]?.name === 'same' && ids.p !== ids.q); + } + + // ---- 2e: concurrent create of children in same dir ---- + { + console.log('\n-- 2e concurrent create of children in same dir from both peers --'); + const { doc: docA, ids } = buildBaseTree(lib); + const docB = lib.cloneForPeer(docA, 2); + + const newA = lib.treeCreateChild(docA, ids.root, 'new-from-A', 'new-A'); + const newB = lib.treeCreateChild(docB, ids.root, 'new-from-B', 'new-B'); + + const upA = lib.exportFull(docA); + const upB = lib.exportFull(docB); + lib.importBytes(docA, upB); + lib.importBytes(docB, upA); + + const flatA = normalize(lib, docA); + const flatB = normalize(lib, docB); + console.log(' both present in A:', (newA in flatA) && (newB in flatA)); + console.log(' both present in B:', (newA in flatB) && (newB in flatB)); + console.log(' converged (A==B JSON):', sameTree(flatA, flatB)); + // deterministic order: for Loro use native sibling order (toJSON order); for parent-pointer + // libs there's no inherent order, so report what's available. + if (lib === loro) { + const siblingsOrder = lib.treeDump(docA)[0].children.map(n => n.meta.name); + console.log(' Loro native sibling order under root:', siblingsOrder); + } else { + console.log(' (parent-pointer model has no native sibling order; app layer must sort, e.g. by id/insertion time)'); + } + } + + // ---- content/identity separation demo ---- + { + console.log('\n-- content doc separation: rename a file on A while B edits its "content" doc --'); + const { doc: docA, ids } = buildBaseTree(lib); + const docB = lib.cloneForPeer(docA, 2); + // model the file's content as a wholly separate CRDT doc keyed by node id (ids.x) + const contentA = lib.createDoc(1); + lib.initText(contentA, 'original content\n'); + const contentB = lib.cloneForPeer(contentA, 2); + + lib.treeRename(docA, ids.x, 'x-renamed-on-A'); // A renames the node (tree doc only) + lib.insertChar(contentB, 'original content\n'.length - 1, ' appended-by-B'); // B edits content doc only + + // sync tree docs + lib.importBytes(docA, lib.exportFull(docB)); + lib.importBytes(docB, lib.exportFull(docA)); + // sync content docs + lib.importBytes(contentA, lib.exportFull(contentB)); + lib.importBytes(contentB, lib.exportFull(contentA)); + + const flatA = normalize(lib, docA); + console.log(' node name after rename+merge:', flatA[ids.x]?.name); + console.log(' content after B\'s edit+merge:', JSON.stringify(lib.getText(contentA))); + console.log(' both survived independently:', flatA[ids.x]?.name === 'x-renamed-on-A' && lib.getText(contentA).includes('appended-by-B')); + } +} diff --git a/probes/crdt/correctness/case5.mjs b/probes/crdt/correctness/case5.mjs new file mode 100644 index 0000000..72bb40f --- /dev/null +++ b/probes/crdt/correctness/case5.mjs @@ -0,0 +1,167 @@ +// Case 5 — editor bindings. jsdom + CodeMirror 6, timeboxed (~30min) per library. +import { JSDOM } from 'jsdom'; + +const dom = new JSDOM(''); +global.window = dom.window; +global.document = dom.window.document; +Object.defineProperty(global, 'navigator', { value: dom.window.navigator, configurable: true }); +for (const k of ['MutationObserver', 'getComputedStyle', 'DocumentFragment', 'Node', 'Element', 'HTMLElement', 'Text', 'Range', 'Window']) { + if (dom.window[k] && !global[k]) global[k] = dom.window[k]; +} +global.requestAnimationFrame = (cb) => setTimeout(cb, 0); +global.cancelAnimationFrame = (id) => clearTimeout(id); +dom.window.requestAnimationFrame = global.requestAnimationFrame; +dom.window.cancelAnimationFrame = global.cancelAnimationFrame; + +const { EditorView } = await import('@codemirror/view'); +const { EditorState } = await import('@codemirror/state'); + +function mount(extensions, docText) { + const state = EditorState.create({ doc: docText, extensions }); + const parent = document.createElement('div'); + document.body.appendChild(parent); + const view = new EditorView({ state, parent }); + return view; +} + +const results = {}; + +// ---------------- loro-codemirror ---------------- +try { + const { LoroDoc } = await import('loro-crdt'); + const { LoroSyncPlugin } = await import('loro-codemirror'); + + const doc = new LoroDoc(); + doc.setPeerId(1n); + // mount with an EMPTY editor state and let the plugin own the initial sync — pre-populating + // both the CRDT and the editor's initial doc caused an "Index out of bound" crash (the plugin's + // own notion of doc length diverged from the editor's), so the correct integration order is: + // create the plugin against an empty shared doc, then make all further changes through it. + const view = mount([LoroSyncPlugin(doc)], ''); + // loro-codemirror's defaultGetTextFromDoc reads doc.getText("codemirror") specifically — an + // API surprise worth recording; using an arbitrary key (e.g. "content") silently desyncs the + // plugin from the editor (editor text stays empty / later dispatch crashes "doc of length 0"). + doc.getText('codemirror').insert(0, 'hello'); + doc.commit(); + await new Promise(r => setTimeout(r, 10)); + console.log('[loro-codemirror] mounted + CRDT seeded, editor text =', view.state.doc.toString()); + + // local editor transaction -> should land in the CRDT + view.dispatch({ changes: { from: 5, insert: ' world' } }); + console.log('[loro-codemirror] after local dispatch, CRDT text =', doc.getText('codemirror').toString()); + const localOk = doc.getText('codemirror').toString() === 'hello world'; + + // remote CRDT update -> should land in the editor + const peer2 = new LoroDoc(); + peer2.setPeerId(2n); + peer2.import(doc.export({ mode: 'snapshot' })); + const v0 = peer2.oplogVersion(); + peer2.getText('codemirror').insert(0, '>>> '); + peer2.commit(); + const patch = peer2.export({ mode: 'update', from: v0 }); + doc.import(patch); + doc.commit(); + console.log('[loro-codemirror] after remote import, CRDT text =', doc.getText('codemirror').toString()); + // give the plugin's subscription a tick to flush into the view + await new Promise(r => setTimeout(r, 10)); + console.log('[loro-codemirror] after remote import, editor text =', view.state.doc.toString()); + const remoteOk = view.state.doc.toString() === doc.getText('codemirror').toString(); + + results['loro-codemirror'] = { mounted: true, localEditToCrdt: localOk, remoteCrdtToEditor: remoteOk }; +} catch (e) { + console.log('[loro-codemirror] ERROR:', e.stack || e.message); + results['loro-codemirror'] = { error: String(e.message || e) }; +} + +// ---------------- y-codemirror.next ---------------- +try { + const Y = await import('yjs'); + const { yCollab, ySyncFacet } = await import('y-codemirror.next'); + + const ydoc = new Y.Doc(); + const ytext = ydoc.getText('content'); + + const view = mount([yCollab(ytext)], ''); + ytext.insert(0, 'hello'); + await new Promise(r => setTimeout(r, 10)); + console.log('[y-codemirror.next] mounted + CRDT seeded, editor text =', view.state.doc.toString()); + + view.dispatch({ changes: { from: 5, insert: ' world' } }); + console.log('[y-codemirror.next] after local dispatch, CRDT text =', ytext.toString()); + const localOk = ytext.toString() === 'hello world'; + + const ydoc2 = new Y.Doc(); + Y.applyUpdate(ydoc2, Y.encodeStateAsUpdate(ydoc)); + ydoc2.getText('content').insert(0, '>>> '); + Y.applyUpdate(ydoc, Y.encodeStateAsUpdate(ydoc2, Y.encodeStateVector(ydoc))); + console.log('[y-codemirror.next] after remote update, CRDT text =', ytext.toString()); + await new Promise(r => setTimeout(r, 10)); + console.log('[y-codemirror.next] after remote update, editor text =', view.state.doc.toString()); + const remoteOk = view.state.doc.toString() === ytext.toString(); + + results['y-codemirror.next'] = { mounted: true, localEditToCrdt: localOk, remoteCrdtToEditor: remoteOk }; +} catch (e) { + console.log('[y-codemirror.next] ERROR:', e.stack || e.message); + results['y-codemirror.next'] = { error: String(e.message || e) }; +} + +// ---------------- y-codemirror.next against @y/y v14 (peer compatibility check) ---------------- +try { + const Y14 = await import('@y/y'); + const { yCollab } = await import('y-codemirror.next'); + const ydoc = new Y14.Doc(); + // y-codemirror.next's ySync plugin calls ytext.observe/toString/insert/delete — v14's generic + // YType exposes .toString()/.insert()/.delete() too (list-style API kept for back-compat on + // text-like types), so try the same path. + const ytext = ydoc.get('content'); + ytext.applyDelta((await import('lib0/delta')).create().insert('hello').done()); + const view = mount([yCollab(ytext)], ''); + console.log('[y-codemirror.next on @y/y v14] mounted, editor text =', view.state.doc.toString()); + results['y-codemirror.next+@y/y14'] = { mounted: true }; +} catch (e) { + console.log('[y-codemirror.next on @y/y v14] ERROR:', e.message); + results['y-codemirror.next+@y/y14'] = { error: String(e.message || e), note: 'peer dep declares yjs ^13.5.6; v14 breaks the shared-type API y-codemirror.next relies on (Y.Text class / observe signature), confirmed incompatible by direct test, not by reading docs' }; +} + +// ---------------- @automerge/automerge-codemirror ---------------- +try { + const A = await import('@automerge/automerge'); + const { automergeSyncPlugin } = await import('@automerge/automerge-codemirror'); + + let doc = A.init(); + doc = A.change(doc, d => { d.text = ''; A.updateText(d, ['text'], 'hello'); }); + + const listeners = new Set(); + const handle = { + isReady: () => true, + doc: () => doc, + change: (cb) => { doc = A.change(doc, cb); listeners.forEach(l => l()); }, + on: (ev, cb) => { if (ev === 'change') listeners.add(cb); }, + off: (ev, cb) => { if (ev === 'change') listeners.delete(cb); }, + }; + + const view = mount([automergeSyncPlugin({ handle, path: ['text'] })], doc.text); + console.log('[automerge-codemirror] mounted, editor text =', view.state.doc.toString()); + + view.dispatch({ changes: { from: 5, insert: ' world' } }); + console.log('[automerge-codemirror] after local dispatch, CRDT text =', handle.doc().text); + const localOk = handle.doc().text === 'hello world'; + + // remote update: merge a concurrent change into handle's doc, then notify listeners + const fork = A.clone(handle.doc()); + const changedFork = A.change(fork, d => { A.updateText(d, ['text'], '>>> ' + d.text); }); + doc = A.merge(doc, changedFork); + listeners.forEach(l => l()); + console.log('[automerge-codemirror] after remote merge, CRDT text =', handle.doc().text); + await new Promise(r => setTimeout(r, 10)); + console.log('[automerge-codemirror] after remote merge, editor text =', view.state.doc.toString()); + const remoteOk = view.state.doc.toString() === handle.doc().text; + + results['automerge-codemirror'] = { mounted: true, localEditToCrdt: localOk, remoteCrdtToEditor: remoteOk }; +} catch (e) { + console.log('[automerge-codemirror] ERROR:', e.stack || e.message); + results['automerge-codemirror'] = { error: String(e.message || e) }; +} + +console.log('\nSUMMARY:', JSON.stringify(results, null, 2)); +process.exit(0); diff --git a/probes/crdt/correctness/out/case1.txt b/probes/crdt/correctness/out/case1.txt new file mode 100644 index 0000000..abb6488 --- /dev/null +++ b/probes/crdt/correctness/out/case1.txt @@ -0,0 +1,72 @@ + +================================================================================ +CASE 1a — disjoint: A types HELLO char-by-char in line 100; B rewrites lines 10/150/190 +================================================================================ + +--- loro --- + B whole-file write LoroText.update bytes: 154 | updateByLine bytes: 420 + converged: true | HELLO present: true | edit10: true | edit150: true | edit190: true | lineCount200: true + +--- yjs13 --- + B whole-file write ops: 3 bytes: 95 + converged: true | HELLO present: true | edit10: true | edit150: true | edit190: true | lineCount200: true + +--- yjs14 --- + B whole-file write ops: 3 bytes: 116 + converged: true | HELLO present: true | edit10: true | edit150: true | edit190: true | lineCount200: true + +--- automerge --- + B whole-file write ops: 4 bytes: 193 + converged: true | HELLO present: true | edit10: true | edit150: true | edit190: true | lineCount200: true + +================================================================================ +CASE 1b — overlapping: B's rewrite also changes line 100 (the line A is typing in) +================================================================================ + +--- loro --- + B whole-file write ops/bytes: (n/a) 172 + converged: true + MERGED LINE 100 (verbatim): "REWRITTEN: line 100: lorem ipsum doloHELLOr sit amet consectetur 100" + +--- yjs13 --- + B whole-file write ops/bytes: 4 122 + converged: true + MERGED LINE 100 (verbatim): "REWRITTEN: line 100: lorem ipsum doloHELLOr sit amet consectetur 100" + +--- yjs14 --- + B whole-file write ops/bytes: 4 149 + converged: true + MERGED LINE 100 (verbatim): "REWRITTEN: line 100: lorem ipsum doloHELLOr sit amet consectetur 100" + +--- automerge --- + B whole-file write ops/bytes: 6 229 + converged: true + MERGED LINE 100 (verbatim): "REWRITTEN: line 100: lorem ipsum doloHELLOr sit amet consectetur 100" + +================================================================================ +CASE 1c — stale base: B reads at V0, A types HELLO, naive ingestion deletes it; 3-way variant preserves it +================================================================================ + +--- loro --- + B after receiving A's HELLO: line 100: lorem ipsum doloHELLOr sit amet consectetur 100 + NAIVE result line 100: "line 100: lorem ipsum dolor sit amet consectetur 100" | HELLO survives naive: false + 3-WAY result line 100: "line 100: lorem ipsum doloHELLOr sit amet consectetur 100" | HELLO survives 3-way: true | patch info: {"bytes":113} + 3-way result line 10: line 010: lorem ipsum dolor sit amet consectetur 10 [B-EDIT-10] + +--- yjs13 --- + B after receiving A's HELLO: line 100: lorem ipsum doloHELLOr sit amet consectetur 100 + NAIVE result line 100: "line 100: lorem ipsum dolor sit amet consectetur 100" | HELLO survives naive: false + 3-WAY result line 100: "line 100: lorem ipsum doloHELLOr sit amet consectetur 100" | HELLO survives 3-way: true | patch info: {"ops":1,"bytes":37} + 3-way result line 10: line 010: lorem ipsum dolor sit amet consectetur 10 [B-EDIT-10] + +--- yjs14 --- + B after receiving A's HELLO: line 100: lorem ipsum doloHELLOr sit amet consectetur 100 + NAIVE result line 100: "line 100: lorem ipsum dolor sit amet consectetur 100" | HELLO survives naive: false + 3-WAY result line 100: "line 100: lorem ipsum doloHELLOr sit amet consectetur 100" | HELLO survives 3-way: true | patch info: {"ops":1,"bytes":46} + 3-way result line 10: line 010: lorem ipsum dolor sit amet consectetur 10 [B-EDIT-10] + +--- automerge --- + B after receiving A's HELLO: line 100: lorem ipsum doloHELLOr sit amet consectetur 100 + NAIVE result line 100: "line 100: lorem ipsum dolor sit amet consectetur 100" | HELLO survives naive: false + 3-WAY result line 100: "line 100: lorem ipsum doloHELLOr sit amet consectetur 100" | HELLO survives 3-way: true | patch info: {"ops":1,"bytes":null} + 3-way result line 10: line 010: lorem ipsum dolor sit amet consectetur 10 [B-EDIT-10] diff --git a/probes/crdt/correctness/out/case2.txt b/probes/crdt/correctness/out/case2.txt new file mode 100644 index 0000000..78c3ab4 --- /dev/null +++ b/probes/crdt/correctness/out/case2.txt @@ -0,0 +1,153 @@ + +================================================================================ +CASE 2 — loro +================================================================================ + +-- 2a concurrent move of same node to two different parents -- + A sees x.parent = 4@1 | B sees x.parent = 4@1 + converged (A==B JSON): true + exactly one x node, one parent, no duplicate: true + +-- 2b move cycle: A moves a into b, B moves b into a -- + raw data (A): {"0@1":{"parent":null,"name":"root"},"4@1":{"parent":"0@1","name":"b"},"2@1":{"parent":"4@1","name":"a"},"6@1":{"parent":"0@1","name":"d"},"8@1":{"parent":"6@1","name":"x"},"10@1":{"parent":"0@1","name":"p"},"12@1":{"parent":"0@1","name":"q"}} + raw data (B): {"0@1":{"parent":null,"name":"root"},"4@1":{"parent":"0@1","name":"b"},"2@1":{"parent":"4@1","name":"a"},"6@1":{"parent":"0@1","name":"d"},"8@1":{"parent":"6@1","name":"x"},"10@1":{"parent":"0@1","name":"p"},"12@1":{"parent":"0@1","name":"q"}} + reachable from root: [ + '0@1', '10@1', + '12@1', '2@1', + '4@1', '6@1', + '8@1' +] + unreachable / cyclic (detached): [] + acyclic & fully reachable: true + +-- 2c rename vs delete: A deletes dir d (with children); B moves d/x out to root and renames -- + A final: {"0@1":{"parent":null,"name":"root"},"2@1":{"parent":"0@1","name":"a"},"4@1":{"parent":"0@1","name":"b"},"10@1":{"parent":"0@1","name":"p"},"12@1":{"parent":"0@1","name":"q"},"8@1":{"parent":null,"name":"x-renamed"}} + B final: {"0@1":{"parent":null,"name":"root"},"2@1":{"parent":"0@1","name":"a"},"4@1":{"parent":"0@1","name":"b"},"10@1":{"parent":"0@1","name":"p"},"12@1":{"parent":"0@1","name":"q"},"8@1":{"parent":null,"name":"x-renamed"}} + d-x present after merge: true | its parent: null | its name: x-renamed + d itself present after merge: false + +-- 2d name collision: A renames p -> same, B renames q -> same -- + p: {"parent":"0@1","name":"same"} | q: {"parent":"0@1","name":"same"} + both nodes still exist with distinct ids, same name: true + +-- 2e concurrent create of children in same dir from both peers -- + both present in A: true + both present in B: true + converged (A==B JSON): true + Loro native sibling order under root: [ 'a', 'b', 'd', 'p', 'q', 'new-from-A', 'new-from-B' ] + +-- content doc separation: rename a file on A while B edits its "content" doc -- + node name after rename+merge: x-renamed-on-A + content after B's edit+merge: "original content appended-by-B\n" + both survived independently: true + +================================================================================ +CASE 2 — yjs13 +================================================================================ + +-- 2a concurrent move of same node to two different parents -- + A sees x.parent = b | B sees x.parent = b + converged (A==B JSON): true + exactly one x node, one parent, no duplicate: true + +-- 2b move cycle: A moves a into b, B moves b into a -- + raw data (A): {"root":{"parent":null,"name":"root"},"a":{"parent":"b","name":"a"},"b":{"parent":"a","name":"b"},"d":{"parent":"root","name":"d"},"d-x":{"parent":"d","name":"x"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + raw data (B): {"root":{"parent":null,"name":"root"},"a":{"parent":"b","name":"a"},"b":{"parent":"a","name":"b"},"d":{"parent":"root","name":"d"},"d-x":{"parent":"d","name":"x"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + reachable from root: [ 'd', 'd-x', 'p', 'q', 'root' ] + unreachable / cyclic (detached): [ 'a', 'b' ] + acyclic & fully reachable: false + +-- 2c rename vs delete: A deletes dir d (with children); B moves d/x out to root and renames -- + A final: {"root":{"parent":null,"name":"root"},"a":{"parent":"root","name":"a"},"b":{"parent":"root","name":"b"},"d-x":{"parent":null,"name":"x-renamed"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + B final: {"root":{"parent":null,"name":"root"},"a":{"parent":"root","name":"a"},"b":{"parent":"root","name":"b"},"d-x":{"parent":null,"name":"x-renamed"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + d-x present after merge: true | its parent: null | its name: x-renamed + d itself present after merge: false + +-- 2d name collision: A renames p -> same, B renames q -> same -- + p: {"parent":"root","name":"same"} | q: {"parent":"root","name":"same"} + both nodes still exist with distinct ids, same name: true + +-- 2e concurrent create of children in same dir from both peers -- + both present in A: true + both present in B: true + converged (A==B JSON): true + (parent-pointer model has no native sibling order; app layer must sort, e.g. by id/insertion time) + +-- content doc separation: rename a file on A while B edits its "content" doc -- + node name after rename+merge: x-renamed-on-A + content after B's edit+merge: "original content appended-by-B\n" + both survived independently: true + +================================================================================ +CASE 2 — yjs14 +================================================================================ + +-- 2a concurrent move of same node to two different parents -- + A sees x.parent = a | B sees x.parent = a + converged (A==B JSON): true + exactly one x node, one parent, no duplicate: true + +-- 2b move cycle: A moves a into b, B moves b into a -- + raw data (A): {"root":{"parent":null,"name":"root"},"a":{"parent":"b","name":"a"},"b":{"parent":"a","name":"b"},"d":{"parent":"root","name":"d"},"d-x":{"parent":"d","name":"x"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + raw data (B): {"root":{"parent":null,"name":"root"},"a":{"parent":"b","name":"a"},"b":{"parent":"a","name":"b"},"d":{"parent":"root","name":"d"},"d-x":{"parent":"d","name":"x"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + reachable from root: [ 'd', 'd-x', 'p', 'q', 'root' ] + unreachable / cyclic (detached): [ 'a', 'b' ] + acyclic & fully reachable: false + +-- 2c rename vs delete: A deletes dir d (with children); B moves d/x out to root and renames -- + A final: {"root":{"parent":null,"name":"root"},"a":{"parent":"root","name":"a"},"b":{"parent":"root","name":"b"},"d-x":{"parent":null,"name":"x-renamed"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + B final: {"root":{"parent":null,"name":"root"},"a":{"parent":"root","name":"a"},"b":{"parent":"root","name":"b"},"d-x":{"parent":null,"name":"x-renamed"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + d-x present after merge: true | its parent: null | its name: x-renamed + d itself present after merge: false + +-- 2d name collision: A renames p -> same, B renames q -> same -- + p: {"parent":"root","name":"same"} | q: {"parent":"root","name":"same"} + both nodes still exist with distinct ids, same name: true + +-- 2e concurrent create of children in same dir from both peers -- + both present in A: true + both present in B: true + converged (A==B JSON): true + (parent-pointer model has no native sibling order; app layer must sort, e.g. by id/insertion time) + +-- content doc separation: rename a file on A while B edits its "content" doc -- + node name after rename+merge: x-renamed-on-A + content after B's edit+merge: "original content appended-by-B\n" + both survived independently: true + +================================================================================ +CASE 2 — automerge +================================================================================ + +-- 2a concurrent move of same node to two different parents -- + A sees x.parent = b | B sees x.parent = b + converged (A==B JSON): true + exactly one x node, one parent, no duplicate: true + +-- 2b move cycle: A moves a into b, B moves b into a -- + raw data (A): {"root":{"parent":null,"name":"root"},"a":{"parent":"b","name":"a"},"b":{"parent":"a","name":"b"},"d":{"parent":"root","name":"d"},"d-x":{"parent":"d","name":"x"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + raw data (B): {"root":{"parent":null,"name":"root"},"a":{"parent":"b","name":"a"},"b":{"parent":"a","name":"b"},"d":{"parent":"root","name":"d"},"d-x":{"parent":"d","name":"x"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + reachable from root: [ 'd', 'd-x', 'p', 'q', 'root' ] + unreachable / cyclic (detached): [ 'a', 'b' ] + acyclic & fully reachable: false + +-- 2c rename vs delete: A deletes dir d (with children); B moves d/x out to root and renames -- + A final: {"root":{"parent":null,"name":"root"},"a":{"parent":"root","name":"a"},"b":{"parent":"root","name":"b"},"d-x":{"parent":null,"name":"x-renamed"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + B final: {"root":{"parent":null,"name":"root"},"a":{"parent":"root","name":"a"},"b":{"parent":"root","name":"b"},"d-x":{"parent":null,"name":"x-renamed"},"p":{"parent":"root","name":"p"},"q":{"parent":"root","name":"q"}} + d-x present after merge: true | its parent: null | its name: x-renamed + d itself present after merge: false + +-- 2d name collision: A renames p -> same, B renames q -> same -- + p: {"parent":"root","name":"same"} | q: {"parent":"root","name":"same"} + both nodes still exist with distinct ids, same name: true + +-- 2e concurrent create of children in same dir from both peers -- + both present in A: true + both present in B: true + converged (A==B JSON): true + (parent-pointer model has no native sibling order; app layer must sort, e.g. by id/insertion time) + +-- content doc separation: rename a file on A while B edits its "content" doc -- + node name after rename+merge: x-renamed-on-A + content after B's edit+merge: "original content appended-by-B\n" + both survived independently: true diff --git a/probes/crdt/correctness/out/case5.txt b/probes/crdt/correctness/out/case5.txt new file mode 100644 index 0000000..c43c63a --- /dev/null +++ b/probes/crdt/correctness/out/case5.txt @@ -0,0 +1,35 @@ +[loro-codemirror] mounted + CRDT seeded, editor text = hello +[loro-codemirror] after local dispatch, CRDT text = hello world +[loro-codemirror] after remote import, CRDT text = >>> hello world +[loro-codemirror] after remote import, editor text = >>> hello world +[y-codemirror.next] mounted + CRDT seeded, editor text = hello +[y-codemirror.next] after local dispatch, CRDT text = hello world +[y-codemirror.next] after remote update, CRDT text = >>> hello world +[y-codemirror.next] after remote update, editor text = >>> hello world +[yjs#509] Not same Y.Doc +[y-codemirror.next on @y/y v14] mounted, editor text = +[automerge-codemirror] mounted, editor text = hello +[automerge-codemirror] after local dispatch, CRDT text = hello world +[automerge-codemirror] after remote merge, CRDT text = >>> hello world +[automerge-codemirror] after remote merge, editor text = >>> hello world + +SUMMARY: { + "loro-codemirror": { + "mounted": true, + "localEditToCrdt": true, + "remoteCrdtToEditor": true + }, + "y-codemirror.next": { + "mounted": true, + "localEditToCrdt": true, + "remoteCrdtToEditor": true + }, + "y-codemirror.next+@y/y14": { + "mounted": true + }, + "automerge-codemirror": { + "mounted": true, + "localEditToCrdt": true, + "remoteCrdtToEditor": true + } +} diff --git a/probes/crdt/correctness/out/downloads.txt b/probes/crdt/correctness/out/downloads.txt new file mode 100644 index 0000000..c8b3dbf --- /dev/null +++ b/probes/crdt/correctness/out/downloads.txt @@ -0,0 +1,12 @@ +=== loro-codemirror === +{"downloads":6674,"start":"2026-10-23","end":"2026-10-29","package":"loro-codemirror"} +=== y-codemirror.next === +{"downloads":345043,"start":"2026-10-23","end":"2026-10-29","package":"y-codemirror.next"} +=== @automerge%2Fautomerge-codemirror === +{"downloads":460,"start":"2026-10-23","end":"2026-10-29","package":"@automerge/automerge-codemirror"} +=== loro-prosemirror === +{"downloads":25179,"start":"2026-10-23","end":"2026-10-29","package":"loro-prosemirror"} +=== y-prosemirror === +{"downloads":3294558,"start":"2026-10-23","end":"2026-10-29","package":"y-prosemirror"} +=== @automerge%2Fprosemirror === +{"downloads":7811,"start":"2026-10-23","end":"2026-10-29","package":"@automerge/prosemirror"} diff --git a/probes/crdt/correctness/out/npmview.txt b/probes/crdt/correctness/out/npmview.txt new file mode 100644 index 0000000..b0509ab --- /dev/null +++ b/probes/crdt/correctness/out/npmview.txt @@ -0,0 +1,56 @@ +=== loro-codemirror === +{ + "version": "0.3.3", + "time.modified": "2025-10-07T08:25:06.746Z", + "peerDependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.7.0", + "loro-crdt": "^1.8.2" + } +} + +=== y-codemirror.next === +{ + "version": "0.3.6", + "time.modified": "2026-08-18T14:52:15.248Z", + "peerDependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "yjs": "^13.5.6" + } +} + +=== @automerge/automerge-codemirror === +{ + "version": "0.2.0", + "time.modified": "2026-04-13T19:45:06.102Z" +} + +=== loro-prosemirror === +{ + "version": "0.4.4", + "time.modified": "2026-08-22T11:58:15.040Z", + "peerDependencies": { + "loro-crdt": "^1.10.2" + } +} + +=== y-prosemirror === +{ + "version": "1.3.7", + "time.modified": "2025-07-03T13:43:51.147Z", + "peerDependencies": { + "prosemirror-model": "^1.7.1", + "prosemirror-state": "^1.2.3", + "prosemirror-view": "^1.9.10", + "y-protocols": "^1.0.1", + "yjs": "^13.5.38" + } +} + +=== @automerge/prosemirror === +{ + "version": "0.2.0", + "time.modified": "2026-04-13T19:45:15.140Z" +} + diff --git a/probes/crdt/correctness/package-lock.json b/probes/crdt/correctness/package-lock.json new file mode 100644 index 0000000..48c4ebe --- /dev/null +++ b/probes/crdt/correctness/package-lock.json @@ -0,0 +1,1065 @@ +{ + "name": "crdt-correctness-probe", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "crdt-correctness-probe", + "version": "0.0.0", + "dependencies": { + "@automerge/automerge": "3.5.0", + "@automerge/automerge-codemirror": "^0.2.0", + "@automerge/prosemirror": "^0.2.0", + "@codemirror/state": "^6.7.6", + "@codemirror/view": "^6.43.15", + "@y/y": "14.0.0-rc.7", + "fast-diff": "^1.3.0", + "jsdom": "^30.1.3", + "loro-codemirror": "^0.3.3", + "loro-crdt": "1.17.1", + "loro-prosemirror": "^0.4.4", + "prosemirror-model": "^1.25.12", + "prosemirror-state": "^1.4.4", + "prosemirror-view": "^1.42.8", + "y-codemirror.next": "^0.3.6", + "y-prosemirror": "^1.3.7", + "y-protocols": "^1.0.7", + "yjs": "13.6.33" + } + }, + "node_modules/@asamuzakjp/css-color": { + "version": "7.1.9", + "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-7.1.9.tgz", + "integrity": "sha512-vZ6JQVq8Ivgz6b/IBlAf90wZviXdluY13cQOPO+nJHbmXwGrPl2GcpqUY7a55/8ZVdfONXpCFMpRijOBCHNlcQ==", + "license": "MIT", + "dependencies": { + "@csstools/css-calc": "^3.4.3", + "@csstools/css-color-parser": "^4.2.6", + "@csstools/css-parser-algorithms": "^4.0.2", + "@csstools/css-tokenizer": "^4.0.2", + "lru-cache": "^11.5.3" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + } + }, + "node_modules/@asamuzakjp/dom-selector": { + "version": "10.0.5", + "resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-10.0.5.tgz", + "integrity": "sha512-EgmJ7oEaGQECTn3H3wmnQpEy4hKY66VvM7VQndwPIQob3p877BgbyOUE3EX0LgXQCciF2H8KMdR+RznqjMNOLw==", + "license": "MIT", + "dependencies": { + "bidi-js": "^1.1.0", + "css-tree": "^3.2.1", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.5.3" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + } + }, + "node_modules/@automerge/automerge": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@automerge/automerge/-/automerge-3.5.0.tgz", + "integrity": "sha512-ejbqJWfXWM2QbTcUK/5ugYiQiyOP7LYVAp/RuSvthCc07oek0FClMxEuouuhjrLjVPDSI34RP1ftGc45PF7WRA==", + "license": "MIT" + }, + "node_modules/@automerge/automerge-codemirror": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@automerge/automerge-codemirror/-/automerge-codemirror-0.2.0.tgz", + "integrity": "sha512-GBNh4ESZHFNHZKLznf/2G2KdmBD+unEdk64+l621LsjIsJs6HBmQmO8RCY1v7vIq31kFyoVHNcBMGQOnLgy4GA==", + "license": "MIT", + "dependencies": { + "@automerge/automerge": "^3.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "codemirror": "^6.0.0" + } + }, + "node_modules/@automerge/prosemirror": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@automerge/prosemirror/-/prosemirror-0.2.0.tgz", + "integrity": "sha512-Mixxftvfs12tKi7DsStobrQxFayoLJXhEjbrnmNnaQbMzwHrUzuwac+OUvw6ujbtXaulWX+JE8hAuHFAGRDsvQ==", + "license": "MIT", + "dependencies": { + "@automerge/automerge": "^3.1", + "ordered-map": "^0.1.0", + "prosemirror-changeset": "^2.2.1", + "prosemirror-history": "^1.4.1", + "prosemirror-model": "^1.25.2", + "prosemirror-schema-basic": "^1.2.2", + "prosemirror-schema-list": "^1.3.0", + "prosemirror-state": "^1.4.3", + "prosemirror-transform": "^1.7.3", + "prosemirror-view": "^1.40.1" + } + }, + "node_modules/@bramus/specificity": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.3.tgz", + "integrity": "sha512-0GEz8qJWokkUVYQYRukmkSHIFNoBH8QTreeHrAFbvz1XFYc3Y+puhMs8PQ5x8GNugiC2l5jvDBXKLbBIByeSBw==", + "license": "MIT", + "dependencies": { + "css-tree": "^3.2.1" + }, + "bin": { + "specificity": "bin/cli.js" + } + }, + "node_modules/@codemirror/autocomplete": { + "version": "6.20.4", + "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.4.tgz", + "integrity": "sha512-yF8RhOf2SXlg00+qtupzLhrglcas61boqaONiNcbPIebHCpJocpqTBA6dyrtUrQO47hqyTdeob/3XnYilT7TaQ==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0" + } + }, + "node_modules/@codemirror/commands": { + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.11.1.tgz", + "integrity": "sha512-O/4hG3SC1YwcmQ0d2UVNDs+AsaNWd1iHVxbTeEBuqH+6bExAiPK3iS/BvpY6rZGURALv4ZD3sIgcCmRvw3ehBg==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.7.0", + "@codemirror/view": "^6.27.0", + "@lezer/common": "^1.1.0" + } + }, + "node_modules/@codemirror/language": { + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.13.1.tgz", + "integrity": "sha512-zfvU2r3TyylQLMj/te+5CnQ0rSqZi8B1oTCBbQkagcLW4Xc6imab6qN+pEJhsuNOLaJqiRyBXp9UhWA1DhVvDw==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/streamparser": "^6.0.0", + "@codemirror/view": "^6.23.0", + "@lezer/common": "^1.5.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0", + "style-mod": "^4.0.0" + } + }, + "node_modules/@codemirror/lint": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.7.tgz", + "integrity": "sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.42.0", + "crelt": "^1.0.5" + } + }, + "node_modules/@codemirror/search": { + "version": "6.7.2", + "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.7.2.tgz", + "integrity": "sha512-gUYkYhT2+n/+VGZ+8EzE5WFkYZUZYm1VOKDudIsNqh42uRVQJ0a6Yss9sdKT3MeOYfuL1N6AZA57oza0Oyr0LA==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.37.0", + "crelt": "^1.0.5" + } + }, + "node_modules/@codemirror/state": { + "version": "6.7.6", + "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.7.6.tgz", + "integrity": "sha512-kAz+AncRtKuIknedxT1bq4XwXv4UowhbkHU1myPrtVb/jZtImWuV5BXzv5vK6i3kYACsdiZiQKFQQ5Mq7elW8w==", + "license": "MIT", + "dependencies": { + "@marijn/find-cluster-break": "^1.0.0" + } + }, + "node_modules/@codemirror/streamparser": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@codemirror/streamparser/-/streamparser-6.0.0.tgz", + "integrity": "sha512-JTFPF6xrfjt0mnfGPgzcLiMwYmvIyNaoizp8BYzv8FE8KrT6GBGDZ190rtt+O7Wke3gG/MFHyiY9YGNeimof4w==", + "license": "MIT" + }, + "node_modules/@codemirror/view": { + "version": "6.43.15", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.15.tgz", + "integrity": "sha512-HHsfpqFeHyXLs983pSRe38Xajs0vFWZQ2BuX0m7Ki8w3jZ5iD8cuR3lBz2/5/X53Dhf32SBHKh6rtSTB6tKeGw==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.7.0", + "crelt": "^1.0.6", + "style-mod": "^4.1.0", + "w3c-keyname": "^2.2.4" + } + }, + "node_modules/@csstools/color-helpers": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.1.2.tgz", + "integrity": "sha512-grhRy3OKmniaAEKXMjua5z/EODX0MSqBGjunw8+j/3HQjOnahs2AGhvEOIYVUWcU6ScApbhLhVrQTX8XqrMrow==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/@csstools/css-calc": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.4.3.tgz", + "integrity": "sha512-iex20d8CHVkyvg6B7UKV7uHnI2Bqo9g+EFfT9E0y+GvTvhZ/DwONJ+9aKb1dlqm0ZiGsL5RXjp0fCoJYnkeDjA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.2", + "@csstools/css-tokenizer": "^4.0.2" + } + }, + "node_modules/@csstools/css-color-parser": { + "version": "4.2.7", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.7.tgz", + "integrity": "sha512-zgm9yjQz5iJB4VL8RyVwd71TWB8Q89FSxt/NzXoWqPSkEBOVtn9L6vAPtSc9hpKfB0Awo/AL2VKFHjYetBLFHQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/color-helpers": "^6.1.2", + "@csstools/css-calc": "^3.4.3" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.2", + "@csstools/css-tokenizer": "^4.0.2" + } + }, + "node_modules/@csstools/css-parser-algorithms": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.2.tgz", + "integrity": "sha512-40cSKyMvK+tq4qz6Awrlye2WGuOKt3FwPgtGg6KTfbHOWNw+Rk1rzbAtZnZ6IBhsY491HLRnDXwoyBAijmmILA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-tokenizer": "^4.0.2" + } + }, + "node_modules/@csstools/css-syntax-patches-for-csstree": { + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.16.tgz", + "integrity": "sha512-LsDbJPP/B8cPasUJyTA5S99F7C4G93ngW8hUluXz8CFeOaaRnBPtBiIlvgcPYU0HmHNz8CXg+1vwFrIB4F6Dgw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "peerDependencies": { + "css-tree": "^3.2.1" + }, + "peerDependenciesMeta": { + "css-tree": { + "optional": true + } + } + }, + "node_modules/@csstools/css-tokenizer": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.2.tgz", + "integrity": "sha512-OoKoR0f76dCY666JlcbhmVTs2drYj1GUXZTYTcbUgJjh9Nv41aFfZ21bPQTERm5+L5cBDo466NltB2lplS5GBw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/@exodus/bytes": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.16.0.tgz", + "integrity": "sha512-IcpW84uEn3N7ETtNZMlxKhfl6Pec8rUNGOTBtWbK1FKhJxIFAptZyVrvVRVBimAJxJCgc3PxepxkdWWG4DVzfA==", + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@noble/hashes": "^1.8.0 || ^2.0.0" + }, + "peerDependenciesMeta": { + "@noble/hashes": { + "optional": true + } + } + }, + "node_modules/@lezer/common": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.5.tgz", + "integrity": "sha512-Pw7PVCndruF1pb3ebCxpSVpkMHSDjwRCLcTRw+RizUKco5QbWylwq2g4lnG/RYN7yTTQDXE9F77MwtkAyphrjg==", + "license": "MIT" + }, + "node_modules/@lezer/highlight": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.5.tgz", + "integrity": "sha512-O1GMVKgtf5YspFaRzpmqkVgMtIk2HG9uMAbH6wdAIdNh3TVzCsch/+cRi+6l2//UGDKe6NB9BW3cvuR5ezMQ0w==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.3.0" + } + }, + "node_modules/@lezer/lr": { + "version": "1.4.12", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.12.tgz", + "integrity": "sha512-On9HU4oMMiHPMkQDgoTnGahjgG5n/MkN38CgG77sMraKLL+3JBbeQNi1FcCXV9QRqwF9/BUXP3caHyJC1fBOTQ==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.0.0" + } + }, + "node_modules/@marijn/find-cluster-break": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.4.tgz", + "integrity": "sha512-Wy0V7+SGUjnF9/TkiM1hKVDPj7jKXduPNboMVtHTA8dySMURWqfg/JZ9E2Sq8JgSJmkl7k7Qe9FLeMSrSraWmQ==", + "license": "MIT" + }, + "node_modules/@y/y": { + "version": "14.0.0-rc.7", + "resolved": "https://registry.npmjs.org/@y/y/-/y-14.0.0-rc.7.tgz", + "integrity": "sha512-J2nZO3+fMnGpRgqVFnOUX+AgqbuRSmUROl+fuJSPJFfk0gR5/Tb6WRqJAzpYSMf37HM5NGpUMqgSXA8wN3VpyA==", + "license": "MIT", + "dependencies": { + "lib0": "^1.0.0-rc.7" + }, + "engines": { + "node": ">=22.0.0", + "npm": ">=8.0.0" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/bidi-js": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.1.0.tgz", + "integrity": "sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==", + "license": "MIT", + "dependencies": { + "require-from-string": "^2.0.2" + } + }, + "node_modules/codemirror": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.2.tgz", + "integrity": "sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/commands": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/lint": "^6.0.0", + "@codemirror/search": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0" + } + }, + "node_modules/crelt": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz", + "integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==", + "license": "MIT" + }, + "node_modules/css-tree": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz", + "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==", + "license": "MIT", + "dependencies": { + "mdn-data": "2.27.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "node_modules/data-urls": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-8.0.0.tgz", + "integrity": "sha512-JQUCCK+/CAGbGGx618PlFZMXH81Jtj7t73CHv9dd/zVWvxgGT2zLFRjnKb+Ng46GIwcy+f7f88qd4duqllK+WQ==", + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^17.1.2" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "license": "MIT" + }, + "node_modules/entities": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz", + "integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "license": "Apache-2.0" + }, + "node_modules/html-encoding-sniffer": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-7.0.0.tgz", + "integrity": "sha512-UikN5yr7xsCDAq87Or5or0PAlD3HJJOKVzM05az588WnpDJ4Ux7a2A53Qi6gofGg2/EtvF/H4hCi/TXfCW4Y6w==", + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.15.1" + }, + "engines": { + "node": "^22.13.0 || >=24.0.0" + } + }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "license": "MIT" + }, + "node_modules/isomorphic.js": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.2.5.tgz", + "integrity": "sha512-PIeMbHqMt4DnUP3MA/Flc0HElYjMXArsw1qwJZcm9sqR8mq3l8NYizFMty0pWwE/tzIGH3EKK5+jes5mAr85yw==", + "license": "MIT", + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/jsdom": { + "version": "30.1.3", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-30.1.3.tgz", + "integrity": "sha512-hQMUPvRgN7KxsfIytDQji7bimuJeRQa6Qo5+iuiZQk5CafeRxLIA10/cG5YCBFNpD9RO3oqIiN4CO1Y44kxqXg==", + "license": "MIT", + "dependencies": { + "@asamuzakjp/css-color": "^7.1.3", + "@asamuzakjp/dom-selector": "^10.0.3", + "@bramus/specificity": "^2.4.2", + "@csstools/css-syntax-patches-for-csstree": "^1.1.15", + "@exodus/bytes": "^1.16.0", + "css-tree": "^3.2.1", + "data-urls": "^8.0.0", + "decimal.js": "^10.6.0", + "html-encoding-sniffer": "^7.0.0", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.5.3", + "parse5": "^8.0.1", + "saxes": "^6.0.0", + "tough-cookie": "^6.0.2", + "undici": "^8.12.1", + "w3c-xmlserializer": "^6.0.0", + "webidl-conversions": "^8.0.1", + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^17.2.0", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + }, + "peerDependencies": { + "canvas": "^3.2.3" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/lib0": { + "version": "1.0.0-rc.36", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-1.0.0-rc.36.tgz", + "integrity": "sha512-7t/I+PCQqakal22rhXq5giOUtDP/RfecQtdeKvzCtnAvPkxSLAE+/Zvzi/kJDopg+hBAYKo46qmxmlkhX0tYlQ==", + "license": "MIT", + "bin": { + "0ecdsa-generate-keypair": "src/bin/0ecdsa-generate-keypair.js", + "0gentesthtml": "src/bin/gentesthtml.js", + "0serve": "src/bin/0serve.js" + }, + "engines": { + "node": ">=22" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/loro-codemirror": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/loro-codemirror/-/loro-codemirror-0.3.3.tgz", + "integrity": "sha512-C6qAUmDjMTyoXVeDxKWixvr/TSTo/jXFrvgGW+wn6RAHeIzNFovBDLQNi/Sary4Ahx8DaYADTCm9eCaRAjvWtw==", + "license": "MIT", + "peerDependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.7.0", + "loro-crdt": "^1.8.2" + } + }, + "node_modules/loro-crdt": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/loro-crdt/-/loro-crdt-1.17.1.tgz", + "integrity": "sha512-83hWRYG6eMMpPezm+yXWlOqCuUsC0BYY1MVCPW9x2zlikgkHhL7GC7Q6JFH+Hjvauyn287Q1MiwTuRW0lUOUag==", + "license": "MIT" + }, + "node_modules/loro-prosemirror": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/loro-prosemirror/-/loro-prosemirror-0.4.4.tgz", + "integrity": "sha512-9Ttd3yHcb6Y+qxsqiS+fNMy9c9bNeimlLd7FShbVwRUBer8iosI9txWZlegzKnNjUUqIRyV15ybM6w3c2zS+Jg==", + "license": "MIT", + "dependencies": { + "lib0": "^0.2.42", + "prosemirror-model": "^1.18.1", + "prosemirror-state": "^1.4.1", + "prosemirror-view": "^1.28.0" + }, + "peerDependencies": { + "loro-crdt": "^1.10.2" + } + }, + "node_modules/loro-prosemirror/node_modules/lib0": { + "version": "0.2.119", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.119.tgz", + "integrity": "sha512-vh+TiejVy8Xm+hCdnRfn9BthGNvNUZdEXltNjVZL3TzRIKP3s1lnQh8pWd/Q0wCgY0FPAGVVjFF4ZiHUV3LFgA==", + "license": "MIT", + "dependencies": { + "isomorphic.js": "^0.2.4" + }, + "bin": { + "0ecdsa-generate-keypair": "bin/0ecdsa-generate-keypair.js", + "0gentesthtml": "bin/gentesthtml.js", + "0serve": "bin/0serve.js" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/mdn-data": { + "version": "2.27.1", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz", + "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==", + "license": "CC0-1.0" + }, + "node_modules/ordered-map": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/ordered-map/-/ordered-map-0.1.0.tgz", + "integrity": "sha512-ttpssyEqKXIeTapKeFTFG+oUCnrC+Fmyy1DPjys0vPJtccBE3baKDFTbJPDuKd9/XHbnKKe+KPQKTzBLri6Mtw==", + "license": "MIT" + }, + "node_modules/orderedmap": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz", + "integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==", + "license": "MIT" + }, + "node_modules/parse5": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz", + "integrity": "sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==", + "license": "MIT", + "dependencies": { + "entities": "^8.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/prosemirror-changeset": { + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.4.5.tgz", + "integrity": "sha512-hv3Qhsn5GyoferiBqL8euGvj3Y8Z+2Ef75NnPLChr5DTWArpPAjK6F96Yc0iM7SBYNDPQbQaA+xEtAR8NuWo9A==", + "license": "MIT", + "dependencies": { + "prosemirror-transform": "^1.0.0" + } + }, + "node_modules/prosemirror-history": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.5.1.tgz", + "integrity": "sha512-onlwnqKvgtFg6srZOmDOAhlAy1FIHQpOExORybX0S+DvJepE5tPALrB9iGet/2sqqqrelSnB10OoiOJqAvu2DA==", + "license": "MIT", + "dependencies": { + "prosemirror-state": "^1.2.2", + "prosemirror-transform": "^1.0.0", + "prosemirror-view": "^1.31.0", + "rope-sequence": "^1.3.0" + } + }, + "node_modules/prosemirror-model": { + "version": "1.25.12", + "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.12.tgz", + "integrity": "sha512-Ue2gTmXMa7EhpLNhC7J+h4+ykD8ha12K6rrZFFKKJHBForfIStw5gJ6Zrf1mqqAa9NmpmEB4wp9bKmA4eUVjWg==", + "license": "MIT", + "dependencies": { + "orderedmap": "^2.0.0" + } + }, + "node_modules/prosemirror-schema-basic": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/prosemirror-schema-basic/-/prosemirror-schema-basic-1.2.5.tgz", + "integrity": "sha512-McBWhfgOfThyu3Nltbs8SOUbM4t/h0pxteibaaHd1QR4S+F1t0u7M1ETaCE6/cveFoF+2fowTIBNkJOyeZQjNg==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.25.0" + } + }, + "node_modules/prosemirror-schema-list": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.6.0.tgz", + "integrity": "sha512-G1srDtan+VqWn+qpmWFj/6j0YsZ5zMU+ZIlGVIW41a5JF2jAI3jzfMRWmSABmEH2Qoq1PmAG/o2mucMMdLOsLg==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.0.0", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.7.3" + } + }, + "node_modules/prosemirror-state": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.4.tgz", + "integrity": "sha512-6jiYHH2CIGbCfnxdHbXZ12gySFY/fz/ulZE333G6bPqIZ4F+TXo9ifiR86nAHpWnfoNjOb3o5ESi7J8Uz1jXHw==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.0.0", + "prosemirror-transform": "^1.0.0", + "prosemirror-view": "^1.27.0" + } + }, + "node_modules/prosemirror-transform": { + "version": "1.12.4", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.12.4.tgz", + "integrity": "sha512-2/WuPum3pn+O/Vi2vzpi8210ICUe2kIPXdLYjQ09Pv5DtT5bcKWMJhAKPBwvpPjpp5iOYUVwVEr0gOM1BY1Mgw==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.21.0" + } + }, + "node_modules/prosemirror-view": { + "version": "1.42.8", + "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.42.8.tgz", + "integrity": "sha512-ftDZjCs9AjAekXmCfJRn2U3IdlRCl0Yc4tZT1/jJWCsz4DiSifEBXtWmpJpw/4f1Rg328uAUQ+u2lCJ0+AVZkw==", + "license": "MIT", + "dependencies": { + "prosemirror-model": "^1.25.12", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.1.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rope-sequence": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz", + "integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==", + "license": "MIT" + }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/style-mod": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.4.tgz", + "integrity": "sha512-XXWIQt633/EpAFx8aZDOTjBzrCaGmhvEQlQo6MVPfa2OzO2cWo+4hV9h+6UkHYlXGfy+ODXKUdP7Pthmcu5ATw==", + "license": "MIT" + }, + "node_modules/tldts": { + "version": "7.4.19", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.19.tgz", + "integrity": "sha512-48dH6aSpQnpbzDUc4vIQZ1VjB8tkK+e8c1yx05/SZK+rkssgjEOlxDd/yU8/a4vGYQ9vRgJr9dwMq9TJ0b3X2Q==", + "license": "MIT", + "dependencies": { + "tldts-core": "^7.4.19" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "7.4.20", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.20.tgz", + "integrity": "sha512-C630TWXZCZmLq0F2bW4QqwnaaxCQ/svpAqvJwnC4JvgEM5ohhBnGsEzTLSOXcN+xjz+kEaHS5uoWIw2klnqd0A==", + "license": "MIT" + }, + "node_modules/tough-cookie": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz", + "integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==", + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^7.0.5" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-7.0.0.tgz", + "integrity": "sha512-BcDSDW+SIGWVOns1Zm6Yg91q9AEj7eaID0QDY9oIqJD1A8dscNwMcl9Sms2DeuWCNov1X0/oXanHGYQBSLwZsg==", + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, + "node_modules/undici": { + "version": "8.12.3", + "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz", + "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==", + "license": "MIT", + "engines": { + "node": ">=22.19.0" + } + }, + "node_modules/w3c-keyname": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", + "license": "MIT" + }, + "node_modules/w3c-xmlserializer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz", + "integrity": "sha512-4Nsy8K5Tr6SPDH9jhKJOHf7ChDrc1zufZTVSF7x72hwuEXBqxqk9G6cK+K2NRUtB3iELRJqjXb4JPDMBjMTl2Q==", + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + } + }, + "node_modules/webidl-conversions": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz", + "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-mimetype": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz", + "integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==", + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-url": { + "version": "17.3.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.3.0.tgz", + "integrity": "sha512-KwOAJrpf+GTgBvcBQJcP38sMF0DsQKdwtG+TxM2pW44P6E5k0hDbWrDmyuJDIF0Uef0aQq0ZoJs+5oI+k8ddhg==", + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.16.0", + "tr46": "^7.0.0", + "webidl-conversions": "^8.0.1" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "license": "MIT" + }, + "node_modules/y-codemirror.next": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/y-codemirror.next/-/y-codemirror.next-0.3.6.tgz", + "integrity": "sha512-GnmVXhTe+UtoFbbaSdwhq6gdAQZdIY9az0Xj6HR2J4PO6Yw4w3xaaSssU+6T72WhXAI0wf9FbuY2s0Ms+WrexA==", + "license": "MIT", + "dependencies": { + "lib0": "^0.2.42" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + }, + "peerDependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "yjs": "^13.5.6" + } + }, + "node_modules/y-codemirror.next/node_modules/lib0": { + "version": "0.2.119", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.119.tgz", + "integrity": "sha512-vh+TiejVy8Xm+hCdnRfn9BthGNvNUZdEXltNjVZL3TzRIKP3s1lnQh8pWd/Q0wCgY0FPAGVVjFF4ZiHUV3LFgA==", + "license": "MIT", + "dependencies": { + "isomorphic.js": "^0.2.4" + }, + "bin": { + "0ecdsa-generate-keypair": "bin/0ecdsa-generate-keypair.js", + "0gentesthtml": "bin/gentesthtml.js", + "0serve": "bin/0serve.js" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/y-prosemirror": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/y-prosemirror/-/y-prosemirror-1.3.7.tgz", + "integrity": "sha512-NpM99WSdD4Fx4if5xOMDpPtU3oAmTSjlzh5U4353ABbRHl1HtAFUx6HlebLZfyFxXN9jzKMDkVbcRjqOZVkYQg==", + "license": "MIT", + "dependencies": { + "lib0": "^0.2.109" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=8.0.0" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + }, + "peerDependencies": { + "prosemirror-model": "^1.7.1", + "prosemirror-state": "^1.2.3", + "prosemirror-view": "^1.9.10", + "y-protocols": "^1.0.1", + "yjs": "^13.5.38" + } + }, + "node_modules/y-prosemirror/node_modules/lib0": { + "version": "0.2.119", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.119.tgz", + "integrity": "sha512-vh+TiejVy8Xm+hCdnRfn9BthGNvNUZdEXltNjVZL3TzRIKP3s1lnQh8pWd/Q0wCgY0FPAGVVjFF4ZiHUV3LFgA==", + "license": "MIT", + "dependencies": { + "isomorphic.js": "^0.2.4" + }, + "bin": { + "0ecdsa-generate-keypair": "bin/0ecdsa-generate-keypair.js", + "0gentesthtml": "bin/gentesthtml.js", + "0serve": "bin/0serve.js" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/y-protocols": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-1.0.7.tgz", + "integrity": "sha512-YSVsLoXxO67J6eE/nV4AtFtT3QEotZf5sK5BHxFBXso7VDUT3Tx07IfA6hsu5Q5OmBdMkQVmFZ9QOA7fikWvnw==", + "license": "MIT", + "dependencies": { + "lib0": "^0.2.85" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=8.0.0" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + }, + "peerDependencies": { + "yjs": "^13.0.0" + } + }, + "node_modules/y-protocols/node_modules/lib0": { + "version": "0.2.119", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.119.tgz", + "integrity": "sha512-vh+TiejVy8Xm+hCdnRfn9BthGNvNUZdEXltNjVZL3TzRIKP3s1lnQh8pWd/Q0wCgY0FPAGVVjFF4ZiHUV3LFgA==", + "license": "MIT", + "dependencies": { + "isomorphic.js": "^0.2.4" + }, + "bin": { + "0ecdsa-generate-keypair": "bin/0ecdsa-generate-keypair.js", + "0gentesthtml": "bin/gentesthtml.js", + "0serve": "bin/0serve.js" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/yjs": { + "version": "13.6.33", + "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.6.33.tgz", + "integrity": "sha512-q/UYvr1gOk4XII+Cu1CW2dINjYqJJFifTzogEaIARznrvX7uOlHsdTEXcnOBMuIsrCGEEKdNxi74kyMLZlKVfw==", + "license": "MIT", + "dependencies": { + "lib0": "^0.2.99" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=8.0.0" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/yjs/node_modules/lib0": { + "version": "0.2.119", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.119.tgz", + "integrity": "sha512-vh+TiejVy8Xm+hCdnRfn9BthGNvNUZdEXltNjVZL3TzRIKP3s1lnQh8pWd/Q0wCgY0FPAGVVjFF4ZiHUV3LFgA==", + "license": "MIT", + "dependencies": { + "isomorphic.js": "^0.2.4" + }, + "bin": { + "0ecdsa-generate-keypair": "bin/0ecdsa-generate-keypair.js", + "0gentesthtml": "bin/gentesthtml.js", + "0serve": "bin/0serve.js" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + } + } +} diff --git a/probes/crdt/correctness/package.json b/probes/crdt/correctness/package.json new file mode 100644 index 0000000..ffab2f9 --- /dev/null +++ b/probes/crdt/correctness/package.json @@ -0,0 +1,26 @@ +{ + "name": "crdt-correctness-probe", + "version": "0.0.0", + "private": true, + "type": "module", + "dependencies": { + "@automerge/automerge": "3.5.0", + "@automerge/automerge-codemirror": "^0.2.0", + "@automerge/prosemirror": "^0.2.0", + "@codemirror/state": "^6.7.6", + "@codemirror/view": "^6.43.15", + "@y/y": "14.0.0-rc.7", + "fast-diff": "^1.3.0", + "jsdom": "^30.1.3", + "loro-codemirror": "^0.3.3", + "loro-crdt": "1.17.1", + "loro-prosemirror": "^0.4.4", + "prosemirror-model": "^1.25.12", + "prosemirror-state": "^1.4.4", + "prosemirror-view": "^1.42.8", + "y-codemirror.next": "^0.3.6", + "y-prosemirror": "^1.3.7", + "y-protocols": "^1.0.7", + "yjs": "13.6.33" + } +} diff --git a/probes/crdt/perf/RESULTS.md b/probes/crdt/perf/RESULTS.md new file mode 100644 index 0000000..3caaa09 --- /dev/null +++ b/probes/crdt/perf/RESULTS.md @@ -0,0 +1,241 @@ +# CRDT bakeoff — size, performance, runtime portability + +Probe directory: `/Users/nmoo/Developer/nibling-dev/nibling/.worktrees/app/crdt-realtime/probes/crdt/perf/` +(standalone npm project, outside the pnpm workspace; `"type": "module"`) + +Scope note: merge correctness is a different agent's job. This covers size (3a), +editing-trace performance in Node + headless Chromium worker (3b), and workerd +plain/Dynamic-Worker portability (4). + +## Machine / versions + +- CPU: `Apple M1` (via `sysctl -n machdep.cpu.brand_string`) +- Node: `v24.16.0` +- `esbuild`: bundled via npx (whatever `npm install esbuild` resolved, installed in this probe's `node_modules`) +- `wrangler`: `4.156.0` +- Playwright: `1.64.1`, Chromium (cached build, `chromium-1248` / Chrome for Testing 156.0.8078.4) +- Libraries (pinned exact): `loro-crdt@1.17.1`, `yjs@13.6.33`, `@y/y@14.0.0-rc.7`, `@automerge/automerge@3.5.0` + +## Trace used + +Real trace: `josephg/editing-traces`, `sequential_traces/automerge-paper.json.gz` (downloaded +successfully). Decompressed: 259,778 single-position edits (insert/delete), end text length +104,852 chars. Format: `{ startContent, endContent, txns: [{ patches: [[pos, delCount, insText]] }] }`, +flattened to one op list. Two sizes run: first 10,000 ops, and the full 259,778-op trace. + +Correctness: for the **full** trace, final text from loro, yjs, and `@y/y` was compared +byte-for-byte against the trace's `endContent` (104,852 chars) — all three matched exactly +(`matchesExpectedEndContent: true`). Automerge's apply loop also produced the same final text +length (104,852) under the same reconstruction, confirmed by cross-comparison across libraries +(all 4 libraries' final text was identical). No mismatches found. For the 10k subset there is no +provided expected text in the trace file, so correctness there was checked by cross-library +agreement only (all 4 produced identical 6,980-char text). + +--- + +## 3a — Size + +### npm unpacked size (via `npm pack --dry-run --json`, run inside each package dir) + +| Library | Unpacked size | File count | +|---|---|---| +| loro-crdt@1.17.1 | 21,903,342 B (20.9 MiB) | 41 | +| yjs@13.6.33 | 2,308,376 B (2.2 MiB) | 135 | +| @automerge/automerge@3.5.0 | 47,522,133 B (45.3 MiB) | 57 | +| @y/y@14.0.0-rc.7 | 631,413 B (0.6 MiB) | 134 | + +(`loro-crdt` and `@automerge/automerge` ship 4–5 copies of the same ~3.6 MB wasm binary, one per +entrypoint: `web`, `bundler`/`browser`, `nodejs`, plus `workerd` for automerge — that's most of +the unpacked-size gap vs. the pure-JS libraries.) + +### wasm binary raw / gzip -9 / brotli -q 11 + +| Library (entrypoint) | raw | gzip -9 | brotli -q 11 | +|---|---|---|---| +| loro-crdt (web) | 3,595,346 | 1,194,452 | 841,433 | +| loro-crdt (bundler) | 3,596,988 | 1,194,546 | 841,462 | +| loro-crdt (browser) | 3,596,988 | 1,194,547 | 841,251 | +| loro-crdt (nodejs) | 3,597,806 | 1,194,576 | 840,839 | +| automerge (web/bundler/workerd/nodejs — identical bytes) | 3,644,225 | 1,136,571 | 792,564 | + +@y/y and yjs ship no wasm (pure JS). + +### esbuild bundle of a minimal entry (create doc → insert text → export update), `--bundle --minify --format=esm --platform=browser` + +| Library | JS raw | JS gzip | JS brotli | wasm raw | wasm gzip | wasm brotli | **total raw** | **total gzip** | **total brotli** | +|---|---|---|---|---|---|---|---|---|---| +| yjs | 75,339 | 22,687 | 20,435 | — | — | — | 75,339 | 22,687 | 20,435 | +| @y/y | 96,636 | 29,160 | 26,124 | — | — | — | 96,636 | 29,160 | 26,124 | +| loro-crdt (`loro-crdt/web`, separate wasm file) | 85,073 | 12,120 | 10,541 | 3,595,346 | 1,194,452 | 841,433 | 3,680,419 | 1,206,572 | 851,974 | +| automerge (default `.`, resolves to base64-inlined wasm — see note) | 4,900,333 | 1,643,895 | 1,115,472 | 0 (inlined) | — | — | 4,900,333 | 1,643,895 | 1,115,472 | +| automerge (`/slim` + separate wasm, `--loader:.wasm=file`) | 42,819 | 11,013 | 9,609 | 3,644,225 | 1,136,572 | 792,564 | 3,687,044 | 1,147,585 | 802,173 | + +**How each ships wasm, and what actually worked with plain esbuild:** + +- **yjs / @y/y** — pure JS, no wasm. Bundle with plain esbuild, no special handling. Browser and workerd: same file works for both. +- **loro-crdt** — `loro-crdt/web` entrypoint exports a default async `init()` function plus named exports; `init()` internally does `new URL('loro_wasm_bg.wasm', import.meta.url)` then `fetch` + `instantiateStreaming`. **esbuild does not auto-copy that wasm file** — it leaves the `new URL(...)` call as literal runtime code (verified: the string `"loro_wasm_bg.wasm"` and `import.meta.url` both survive minification untouched, and no asset is emitted even with `--loader:.wasm=file`, since it isn't a static `import` specifier). You must manually place `loro_wasm_bg.wasm` next to your bundle output (confirmed working end-to-end in the Playwright worker test below once copied). Also: forgetting to call the exported `init()` before use fails silently at bundle time (esbuild has no way to know) and only breaks at runtime. + - `loro-crdt/bundler` entrypoint instead does a static `import * as rawWasm from "./loro_wasm_bg.wasm"` — this is the one that works directly in Cloudflare Workers/workerd (native ESM wasm-module import, see §4), but **plain esbuild cannot bundle it at all** without a custom wasm loader plugin (`No loader is configured for ".wasm" files`). + - Browser choice: `loro-crdt/web` + manual wasm asset placement. workerd choice: `loro-crdt/bundler` (native wasm-module import — works as-is, see §4a). +- **automerge** — the default export condition map resolves `"browser"` → `fullfat_bundler.js`, which does a static `import * as wasm from "./automerge_wasm_bg.wasm"`. **Plain esbuild with `--platform=browser` fails outright**: `No loader is configured for ".wasm" files: .../automerge_wasm_bg.wasm`. Two working paths found: + 1. `--platform=neutral` (skips the `browser` condition, falls through to the default `import` condition → `fullfat_base64.js`, which base64-inlines the wasm and decodes+`initSync`s it synchronously at module-evaluation time). Works with zero extra esbuild flags, at the cost of one ~4.7 MB JS file (base64 inflates the 3.6 MB wasm to ~4.86 MB before gzip). + 2. Explicit `@automerge/automerge/slim` + the public `./automerge.wasm` export subpath, fetched and passed to the (also public, re-exported) `Automerge.initializeWasm(bytes)` — this needs `--loader:.wasm=file` and gives the smaller, separately-cacheable 42.8 KB JS + 3.6 MB wasm split used in the table above. **Caveat for workerd**: `initializeWasm` calls `WebAssembly.instantiate()` on raw bytes internally — which workerd forbids at runtime (see §4a) — so this path is browser-only, not portable to a Cloudflare Worker. + - Browser choice for smallest/most cacheable transfer: `/slim` + separate wasm + `initializeWasm`. workerd choice: default import, which Node/Workers' `"workerd"` export condition resolves to `fullfat_workerd.js` (`import wasm from ".../automerge_wasm_bg.wasm"`, `api.initSync({ module: wasm })` — safe, module-based, see §4a). + +--- + +## 3b — Editing-trace performance + +All numbers are Node, `node --expose-gc bench.mjs `, 5 repetitions per cell, **median** reported (all 5 raw values are kept in `results/*.json`). "Apply" = one `insert`/`delete` call per trace op into a fresh doc (for automerge, one `Automerge.change()` per op — the realistic per-keystroke-commit path, which is also automerge's worst case for this harness). + +### 10,000 edits + +| Library | Apply (median ms) | Heap Δ (median) | Snapshot size | Cold load (median ms) | Read text (median ms) | Shallow snapshot | Shallow load | +|---|---|---|---|---|---|---|---| +| loro-crdt | 19.6 | 444,216 B | 14,103 B | 0.66 | 0.19 | 5,417 B | 0.84 ms | +| yjs | 64.7 | 16,900,848 B | 15,905 B | 3.38 | 0.04 | n/a | n/a | +| @y/y | 94.8 | 36,603,336 B | 19,079 B | 3.87 | 0.45 | n/a | n/a | +| automerge | 2,084.0 | 49,603,360 B | 6,929 B | 60.1 | 0.004 | n/a | n/a (`saveIncremental` not meaningfully testable here — see note) | + +### Full trace (259,778 edits) + +| Library | Apply (median ms) | Heap Δ (median) | Snapshot size | Cold load (median ms) | Read text (median ms) | Shallow snapshot | Shallow load | +|---|---|---|---|---|---|---|---| +| loro-crdt | 572.7 | 10,443,016 B | 251,391 B | 0.81 | 1.04 | 64,958 B | 1.63 ms | +| yjs | 2,351.3 | 14,164,504 B | 311,038 B | 22.0 | 0.43 | n/a | n/a | +| @y/y | 15,826.4 | 53,976,208 B | 376,756 B | 41.4 | 4.12 | n/a | n/a | +| automerge | 29,150.0 | 33,528,616 B | 129,285 B | 862.4 | 0.003 | n/a | n/a | + +Full `applyMsAll` arrays (showing variance) are in `results/-full.json`; notably `@y/y`'s apply +time was *not* linear from the 10k run — 10k→full is a 26x op-count increase but a ~167x time +increase (95 ms → 15.8 s median, with one rep at 23.6 s). loro and yjs scale roughly linearly +(~29x and ~36x respectively for a 26x op increase). This smells like an O(n) or worse per-insert +cost in `@y/y`'s v14 rewrite (plausibly the generic `YType`/delta machinery lacking yjs's classic +search-marker cache) rather than a fluke — worth a closer look before adopting `@y/y` for +long-lived documents, but out of scope to root-cause further here. + +Automerge's `saveIncremental`: tested in isolation (not in the main harness) and found to return +0 bytes immediately after `Automerge.save()`, because it diffs against automerge's own +last-save-point rather than performing a running incremental log — it isn't a meaningful "cost of +replaying N edits" number with this harness's one-shot bulk-apply shape, so it's reported as +not applicable rather than guessed at. + +Peak heap: the "heap Δ" numbers are `process.memoryUsage().heapUsed` before/after each apply, +with `--expose-gc` + explicit `global.gc()` immediately before the "before" sample — this is a +delta, not a true tracked peak (Node doesn't expose a cheap peak-heap sampler without a +profiler attached), so treat it as a reasonable proxy, not an exact figure. + +### Chromium, inside a dedicated Web Worker (Playwright, headless Chromium 156.0.8078.4) + +5 reps per library, median. "Cold start" = time from the very first line of the worker script to +the first `doc` object being created (includes dynamic `import()` of the bundle and, where +applicable, wasm fetch+instantiate). "Snapshot load/read" = loading the 10k-edit snapshot +(generated in Node, see sizes above) fetched over `http://localhost:8933` and reading the text back. + +| Library | Cold start (median ms) | — of which module import | — of which explicit wasm init | Snapshot load (median ms) | Read text (median ms) | +|---|---|---|---|---|---| +| loro-crdt | 19.1 | 3.3 | 14.5 | 8.7 | 1.1 | +| yjs | 7.4 | 7.2 | 0 (no wasm) | 4.0 | 0.1 | +| @y/y | 8.8 | 8.6 | 0 (no wasm) | 4.5 | 0.9 | +| automerge | 289.7 | 285.0 | 0 (self-inits during module eval) | 71.1 | 0.0 | + +Automerge's bundle here is the 4.7 MB base64-inlined one (`--platform=neutral` path from §3a) — +its "module import" time is dominated by parsing/decoding that ~4.7 MB string and running +`initSync` synchronously during module evaluation, which is reflected directly in the 285 ms +figure. This is the realistic cost of the simplest-to-bundle automerge entrypoint; the smaller +`/slim` + separate-wasm path would move bytes out of "module import" and into an explicit fetch, +but wasn't re-run through the worker harness given it also isn't workerd-portable (see above). + +Raw per-rep JSON: `results/browser-{loro,yjs,yy,automerge}.json`. + +--- + +## 4 — workerd isolates + +Worker Loader pattern copied from the prior probe at +`/private/tmp/claude-501/.../scratchpad/probes/worker-loader/` (`wrangler.jsonc` with +`worker_loaders: [{ binding: "LOADER" }]`, `env.LOADER.get(id, async () => ({ mainModule, modules, globalOutbound: null, ... }))`). Run via `wrangler dev` (wrangler 4.156.0), local workerd. Probe files: `/Users/nmoo/Developer/nibling-dev/nibling/.worktrees/app/crdt-realtime/probes/crdt/perf/workerd/`. + +### 4a — plain Worker (fetch handler, two docs, edit both, exchange updates, encode snapshot, return merged text) + +All four libraries work **as plain Workers**, but only after picking the right entrypoint: + +| Library | Entrypoint used | Result | +|---|---|---| +| yjs | default (`yjs`) | Works unmodified. `{"aText":"world hello ","bText":"world hello "}` | +| @y/y | default (`@y/y`) | Works unmodified. `{"aText":"hello world ","bText":"hello world "}` | +| loro-crdt | `loro-crdt/bundler` (**not** the default `.` export, and **not** `/web`) | Works. Wrangler's esbuild-based bundler natively handles the static `import * as rawWasm from "./loro_wasm_bg.wasm"` as a Workers wasm-module import — no extra config needed. `{"aText":"world hello ","bText":"world hello "}` | +| @automerge/automerge | default (`.`) — package.json's `"workerd"` export condition is honored by wrangler/esbuild automatically and resolves to `fullfat_workerd.js` (`import wasm from ".../automerge_wasm_bg.wasm"; api.initSync({ module: wasm })`) | Works unmodified. `{"aText":"hello ","bText":"hello "}` | + +Automerge merge-result note (not a bug in this harness, flagging for the correctness agent): +both docs start from an independent `d.text = ''` assignment before their respective inserts; +automerge resolves the two concurrent "set text to empty" ops as a single-register conflict, and +in this run `bText` ended up equal to `aText` ("hello ") rather than containing "world " — i.e. +one side's insert was effectively dropped relative to a naive "both texts merged" expectation. +Reported as observed; not investigated further since merge semantics are out of this probe's scope. + +Confirms the task's framing: `WebAssembly.compile`/`instantiate` on a raw buffer is never called +on any of these four *default-for-workerd* entrypoints — they all rely on the wasm-as-ES-module +import, which workerd's own module linker instantiates outside the sandboxed JS the way a normal +module import is resolved, consistent with "wasm must be imported as a module." + +### 4b — Dynamic Worker via Worker Loader, `globalOutbound: null` + +Guest code was bundled standalone with esbuild (`--platform=neutral`/`browser` + `--external:*.wasm` as needed) and embedded into the host's module map as JSON-encoded strings (`{"main.js": ""}`); wasm assets were imported natively by the **host** worker (`import x from ".../foo.wasm"`, giving a compiled `WebAssembly.Module`) and passed into the guest's module map under the exact import specifier the guest bundle used. + +| Library | Module map form tried | Result | +|---|---|---| +| yjs | `{ "main.js": "" }` (no wasm) | **Works.** `{"ok":true,"aText":"hello world ","bText":"hello world "}` | +| @y/y | `{ "main.js": "" }` (no wasm) | **Works.** `{"ok":true,"aText":"world hello ","bText":"world hello "}` | +| loro-crdt | `{ "main.js": "...", "loro_wasm_bg.wasm": { wasm: Module } }` (wrapped) | **Works.** `{"ok":true,"aText":"hello world ","bText":"hello world "}` | +| loro-crdt | `{ "main.js": "...", "loro_wasm_bg.wasm": Module }` (bare, no `{wasm:...}` wrapper) | **Also works**, identical result. So the loader accepts a `WebAssembly.Module` value for a `.wasm`-suffixed key in **either** bare or `{wasm: Module}` form. | +| automerge | `{ "main.js": "...", "../wasm_bindgen_output/workerd/automerge_wasm_bg.wasm": { wasm: Module } }` (wrapped, using the `fullfat_workerd.js`-derived guest bundle + the exact original import specifier it kept after `--external:*.wasm`) | **Fails**, both wrapped and bare form: `Error: Failed to start Worker:\nUncaught Error: internal error; reference = vi5ethpirjpnc7s6v5npjfl6` (reference id differs per attempt, message is otherwise identical and reproducible across repeated requests and across using the `bundler`-folder vs `workerd`-folder copy of the wasm binary for the host-side import — same bytes, same opaque result). | +| automerge | same, bare form | **Fails** the same way: `Error: Failed to start Worker:\nUncaught Error: internal error; reference = i6sg3dlamn2kkeor4primfqc` | + +Debugging trail for automerge, in order (kept because each step changed the error, which is useful signal): +1. Guest bundled via `--platform=browser` picked automerge's `fullfat_bundler.js` (the "webpack-style" `import * as wasm from "./x.wasm"` + direct `__wbg_set_wasm(wasm)`, which assumes the import already yields instantiated exports) → `TypeError: wasm3.__wbindgen_start is not a function`. Root cause: Cloudflare's native wasm-module ESM import gives a raw `WebAssembly.Module`, not pre-instantiated exports — this entrypoint is only valid for bundlers (webpack/Vite) that do their own wasm-import magic, not for workerd's module linker. +2. Rebuilt the guest with `--conditions=workerd` to force `fullfat_workerd.js` (the `initSync({ module: wasm })` form that worked fine in 4a) → new error, `Invalid module specifier "../wasm_bindgen_output/workerd/automerge_wasm_bg.wasm"`, because `--external:*.wasm` preserves the *original* deep relative import path from automerge's source tree rather than rewriting it relative to the flattened bundle, and my module-map key didn't match it yet. +3. Fixed the module-map key to match that exact specifier string → the opaque `internal error; reference = ...` above, which did not change with further input changes (host-side wasm file source, wrapped vs. bare). This looks like a genuine limitation (or at least an undiagnosed bug) of `wrangler dev`'s local Worker Loader implementation specifically for automerge's ~3.6 MB wasm module, since the same-sized loro wasm module loads fine through the identical code path. Not root-caused further — flagging as "automerge-via-Dynamic-Worker did not work in this environment, exact error above" rather than guessing at a fix. + +**Bottom line for 4b**: pure-JS libraries (yjs, @y/y) load into a Dynamic Worker with zero friction. Of the two wasm-backed libraries, loro-crdt's wasm module loads successfully through the Worker Loader's module map (both `{wasm: Module}` and bare `Module` forms accepted) — automerge's did not, with a reproducible opaque internal error whose root cause wasn't identified within this probe's scope. + +--- + +## What was not tested / limitations + +- **@y/y (Yjs v14 RC) API mismatch**: it does not export `Y.Text`/`Y.Array`/`Y.Map` convenience + classes like Yjs v13. Instead `doc.get(key)` returns a generic `YType` with a delta-based API + (`insert(index, content)`, `delete(index, len)`, `toString()`, `applyDelta(...)`). This was + adaptable with reasonable effort (confirmed via its own source, `src/utils/Doc.js` / + `src/ytype.js`, since the README is an unmodified copy of the v13 Yjs README and does not + document the new API) — used throughout this probe as `libs/yy.mjs`. No feature of the + benchmark required something the RC couldn't do. +- **@y/y's apply-time non-linearity** (10k→full scaling ~167x vs ~26x the op count) was observed + and reported, not root-caused. +- **Automerge `saveIncremental`** sizing wasn't meaningfully measurable with this harness's + bulk-apply shape (see note above) — reported as not applicable rather than a fabricated number. +- **Automerge in a Dynamic Worker** failed with an opaque internal error (see §4b) — not fixed or + root-caused further; flagged as a concrete, reproducible finding rather than papered over. +- **Loro's "shallow snapshot"** was only measured for loro (the other three libraries have no + equivalent concept) — marked `n/a` rather than guessed. +- Did **not** re-run the Chromium worker test against the *full*-trace snapshot (259,778 edits) — + the task only asked for the 10k-edit snapshot in the browser; the full-trace numbers are + Node-only (§3b first table). +- Peak heap is a heapUsed delta around `global.gc()`, not a true OS-level peak-RSS sample; called + out above rather than presented as an exact peak. +- Did not attempt to deploy to real (non-local) Cloudflare infrastructure — all workerd results + are from local `wrangler dev` (workerd), per the task's existing Worker Loader probe pattern. + +## File list + +- `package.json`, `trace.mjs`, `bench.mjs`, `gen-snapshots.mjs`, `quicktest*.mjs` — Node harness +- `libs/{loro,yjs,yy,automerge}.mjs` — per-library adapters used by `bench.mjs` +- `entries/*.entry.mjs`, `entries/guest-*.mjs` — esbuild entry points for size tests and workerd guests +- `dist/*.bundle.js`, `dist/worker-*.js`, `dist/guest-*.js`, `dist/*.wasm` — built bundles +- `size-wasm.sh`, `size-bundles.sh` — size measurement scripts, output in `results/wasm-sizes.csv`, `results/bundle-sizes.csv` +- `traces/automerge-paper.json(.gz)` — the real editing trace +- `results/*.json`, `results/*.err` — raw Node bench output (5 reps each, all kept) +- `web/server.mjs`, `web/index.html`, `web/worker.mjs`, `web/snapshots/*.bin` — static server + Web Worker harness for Chromium tests +- `worker-bench.spec.mjs`, `playwright.config.mjs` — Playwright spec/config +- `results/browser-{loro,yjs,yy,automerge}.json` — raw Chromium worker results (5 reps each) +- `workerd/wrangler.jsonc`, `workerd/src/index.js`, `workerd/gen-dynamic.mjs`, `workerd/src/dynamic.js`, `workerd/generated/*.json` — workerd 4a/4b probe +- `RESULTS.md` — this file diff --git a/probes/crdt/perf/bench.mjs b/probes/crdt/perf/bench.mjs new file mode 100644 index 0000000..316071f --- /dev/null +++ b/probes/crdt/perf/bench.mjs @@ -0,0 +1,107 @@ +// Usage: node --expose-gc bench.mjs +// : loro | yjs | yy | automerge +// : 10k | full +import { loadTrace, sliceOps } from './trace.mjs' + +const libArg = process.argv[2] +const sizeArg = process.argv[3] + +const libModules = { + loro: './libs/loro.mjs', + yjs: './libs/yjs.mjs', + yy: './libs/yy.mjs', + automerge: './libs/automerge.mjs', +} + +const lib = await import(libModules[libArg]) + +const trace = loadTrace('./traces/automerge-paper.json') +const ops = sizeArg === '10k' ? sliceOps(trace, 10000) : trace.ops + +const REPS = 5 +const applyTimes = [] +const heapDeltas = [] +let lastDoc = null +let lastText = null + +function gc() { + if (global.gc) global.gc() +} + +for (let i = 0; i < REPS; i++) { + gc() + const before = process.memoryUsage().heapUsed + const t0 = performance.now() + const doc = lib.applyOps(ops) + const t1 = performance.now() + const after = process.memoryUsage().heapUsed + applyTimes.push(t1 - t0) + heapDeltas.push(after - before) + lastDoc = doc + lastText = lib.getText(doc) +} + +function median(arr) { + const s = [...arr].sort((a, b) => a - b) + const mid = Math.floor(s.length / 2) + return s.length % 2 ? s[mid] : (s[mid - 1] + s[mid]) / 2 +} + +// snapshot size + cold load timing (5 reps using the final doc's snapshot bytes) +const snapBytes = lib.snapshot(lastDoc) +const loadTimes = [] +const readTimes = [] +for (let i = 0; i < REPS; i++) { + gc() + const t0 = performance.now() + const doc2 = lib.loadFromSnapshot(snapBytes) + const t1 = performance.now() + const text2 = lib.getText(doc2) + const t2 = performance.now() + loadTimes.push(t1 - t0) + readTimes.push(t2 - t1) + if (i === 0 && text2 !== lastText) { + console.error('MISMATCH after reload! lengths', text2.length, lastText.length) + } +} + +let shallowBytes = null +let shallowLoadMs = null +if (libArg === 'loro') { + shallowBytes = lib.shallowSnapshot(lastDoc) + const t0 = performance.now() + lib.loadFromSnapshot(shallowBytes) + shallowLoadMs = performance.now() - t0 +} + +let incrementalBytes = null +if (libArg === 'automerge') { + // saveIncremental after a fresh load+no new changes is 0; the meaningful + // number is: load from full save, then saveIncremental immediately (full redundant log) is not useful. + // Report size of Automerge.getBackend? skip; note limitation instead. +} + +const expectedEnd = sizeArg === 'full' ? trace.endContent : null +const matchesExpected = expectedEnd !== null ? (lastText === expectedEnd) : null + +const result = { + lib: lib.name, + libArg, + size: sizeArg, + opCount: ops.length, + finalTextLength: lastText.length, + matchesExpectedEndContent: matchesExpected, + applyMsMedian: median(applyTimes), + applyMsAll: applyTimes, + heapDeltaBytesMedian: median(heapDeltas), + heapDeltaBytesAll: heapDeltas, + snapshotBytes: snapBytes.length, + loadMsMedian: median(loadTimes), + loadMsAll: loadTimes, + readMsMedian: median(readTimes), + readMsAll: readTimes, + shallowSnapshotBytes: shallowBytes ? shallowBytes.length : null, + shallowLoadMs: shallowLoadMs, +} + +console.log(JSON.stringify(result, null, 2)) diff --git a/probes/crdt/perf/entries/automerge-slim.entry.mjs b/probes/crdt/perf/entries/automerge-slim.entry.mjs new file mode 100644 index 0000000..31895df --- /dev/null +++ b/probes/crdt/perf/entries/automerge-slim.entry.mjs @@ -0,0 +1,10 @@ +import * as Automerge from '@automerge/automerge/slim' +import wasmUrl from '@automerge/automerge/automerge.wasm' +export async function run() { + const bytes = await (await fetch(wasmUrl)).arrayBuffer() + Automerge.initializeWasm(new Uint8Array(bytes)) + let doc = Automerge.init() + doc = Automerge.change(doc, d => { d.text = '' }) + doc = Automerge.change(doc, d => { Automerge.splice(d, ['text'], 0, 0, 'hello world') }) + return Automerge.save(doc) +} diff --git a/probes/crdt/perf/entries/automerge-worker.entry.mjs b/probes/crdt/perf/entries/automerge-worker.entry.mjs new file mode 100644 index 0000000..960ec8b --- /dev/null +++ b/probes/crdt/perf/entries/automerge-worker.entry.mjs @@ -0,0 +1,5 @@ +import * as Automerge from '@automerge/automerge' +export async function init() {} +export function createDoc() { return Automerge.init() } +export function loadFromSnapshot(bytes) { return Automerge.load(bytes) } +export function getText(doc) { return doc.text } diff --git a/probes/crdt/perf/entries/automerge.entry.mjs b/probes/crdt/perf/entries/automerge.entry.mjs new file mode 100644 index 0000000..f6dda5d --- /dev/null +++ b/probes/crdt/perf/entries/automerge.entry.mjs @@ -0,0 +1,7 @@ +import * as Automerge from '@automerge/automerge' +export function run() { + let doc = Automerge.init() + doc = Automerge.change(doc, d => { d.text = '' }) + doc = Automerge.change(doc, d => { Automerge.splice(d, ['text'], 0, 0, 'hello world') }) + return Automerge.save(doc) +} diff --git a/probes/crdt/perf/entries/guest-automerge.mjs b/probes/crdt/perf/entries/guest-automerge.mjs new file mode 100644 index 0000000..ea03a61 --- /dev/null +++ b/probes/crdt/perf/entries/guest-automerge.mjs @@ -0,0 +1,12 @@ +import * as Automerge from '@automerge/automerge' +export default { + async fetch() { + let a = Automerge.init(), b = Automerge.init() + a = Automerge.change(a, d => { d.text = '' }) + a = Automerge.change(a, d => { Automerge.splice(d, ['text'], 0, 0, 'hello ') }) + b = Automerge.change(b, d => { d.text = '' }) + b = Automerge.change(b, d => { Automerge.splice(d, ['text'], 0, 0, 'world ') }) + const merged = Automerge.merge(a, b) + return Response.json({ ok: true, aText: merged.text, bText: merged.text }) + } +} diff --git a/probes/crdt/perf/entries/guest-loro.mjs b/probes/crdt/perf/entries/guest-loro.mjs new file mode 100644 index 0000000..ee8ba2a --- /dev/null +++ b/probes/crdt/perf/entries/guest-loro.mjs @@ -0,0 +1,12 @@ +import { LoroDoc } from 'loro-crdt/bundler' +export default { + async fetch() { + const a = new LoroDoc(), b = new LoroDoc() + a.getText('text').insert(0, 'hello ') + b.getText('text').insert(0, 'world ') + a.commit(); b.commit() + const updA = a.export({ mode: 'snapshot' }), updB = b.export({ mode: 'snapshot' }) + a.import(updB); b.import(updA) + return Response.json({ ok: true, aText: a.getText('text').toString(), bText: b.getText('text').toString() }) + } +} diff --git a/probes/crdt/perf/entries/guest-yjs.mjs b/probes/crdt/perf/entries/guest-yjs.mjs new file mode 100644 index 0000000..34f955e --- /dev/null +++ b/probes/crdt/perf/entries/guest-yjs.mjs @@ -0,0 +1,11 @@ +import * as Y from 'yjs' +export default { + async fetch() { + const a = new Y.Doc(), b = new Y.Doc() + a.getText('text').insert(0, 'hello ') + b.getText('text').insert(0, 'world ') + const updA = Y.encodeStateAsUpdate(a), updB = Y.encodeStateAsUpdate(b) + Y.applyUpdate(a, updB); Y.applyUpdate(b, updA) + return Response.json({ ok: true, aText: a.getText('text').toString(), bText: b.getText('text').toString() }) + } +} diff --git a/probes/crdt/perf/entries/guest-yy.mjs b/probes/crdt/perf/entries/guest-yy.mjs new file mode 100644 index 0000000..3452b6b --- /dev/null +++ b/probes/crdt/perf/entries/guest-yy.mjs @@ -0,0 +1,11 @@ +import { Doc, encodeStateAsUpdate, applyUpdate } from '@y/y' +export default { + async fetch() { + const a = new Doc(), b = new Doc() + a.get('text').insert(0, 'hello ') + b.get('text').insert(0, 'world ') + const updA = encodeStateAsUpdate(a), updB = encodeStateAsUpdate(b) + applyUpdate(a, updB); applyUpdate(b, updA) + return Response.json({ ok: true, aText: a.get('text').toString(), bText: b.get('text').toString() }) + } +} diff --git a/probes/crdt/perf/entries/loro-bundler.entry.mjs b/probes/crdt/perf/entries/loro-bundler.entry.mjs new file mode 100644 index 0000000..ac240e6 --- /dev/null +++ b/probes/crdt/perf/entries/loro-bundler.entry.mjs @@ -0,0 +1,2 @@ +import { LoroDoc } from 'loro-crdt/bundler' +export function makeLoroDoc() { return new LoroDoc() } diff --git a/probes/crdt/perf/entries/loro-worker.entry.mjs b/probes/crdt/perf/entries/loro-worker.entry.mjs new file mode 100644 index 0000000..29cabea --- /dev/null +++ b/probes/crdt/perf/entries/loro-worker.entry.mjs @@ -0,0 +1,5 @@ +import initWasm, { LoroDoc } from 'loro-crdt/web' +export async function init() { await initWasm() } +export function createDoc() { return new LoroDoc() } +export function loadFromSnapshot(bytes) { const d = new LoroDoc(); d.import(bytes); return d } +export function getText(doc) { return doc.getText('text').toString() } diff --git a/probes/crdt/perf/entries/loro.entry.mjs b/probes/crdt/perf/entries/loro.entry.mjs new file mode 100644 index 0000000..8d83e12 --- /dev/null +++ b/probes/crdt/perf/entries/loro.entry.mjs @@ -0,0 +1,7 @@ +import init, { LoroDoc } from 'loro-crdt/web' +export async function run() { + await init() + const doc = new LoroDoc() + doc.getText('text').insert(0, 'hello world') + return doc.export({ mode: 'snapshot' }) +} diff --git a/probes/crdt/perf/entries/yjs-worker.entry.mjs b/probes/crdt/perf/entries/yjs-worker.entry.mjs new file mode 100644 index 0000000..16d6115 --- /dev/null +++ b/probes/crdt/perf/entries/yjs-worker.entry.mjs @@ -0,0 +1,5 @@ +import * as Y from 'yjs' +export async function init() {} +export function createDoc() { return new Y.Doc() } +export function loadFromSnapshot(bytes) { const d = new Y.Doc(); Y.applyUpdate(d, bytes); return d } +export function getText(doc) { return doc.getText('text').toString() } diff --git a/probes/crdt/perf/entries/yjs.entry.mjs b/probes/crdt/perf/entries/yjs.entry.mjs new file mode 100644 index 0000000..476f796 --- /dev/null +++ b/probes/crdt/perf/entries/yjs.entry.mjs @@ -0,0 +1,6 @@ +import * as Y from 'yjs' +export function run() { + const doc = new Y.Doc() + doc.getText('text').insert(0, 'hello world') + return Y.encodeStateAsUpdate(doc) +} diff --git a/probes/crdt/perf/entries/yy-worker.entry.mjs b/probes/crdt/perf/entries/yy-worker.entry.mjs new file mode 100644 index 0000000..2b957e9 --- /dev/null +++ b/probes/crdt/perf/entries/yy-worker.entry.mjs @@ -0,0 +1,5 @@ +import { Doc, applyUpdate } from '@y/y' +export async function init() {} +export function createDoc() { return new Doc() } +export function loadFromSnapshot(bytes) { const d = new Doc(); applyUpdate(d, bytes); return d } +export function getText(doc) { return doc.get('text').toString() } diff --git a/probes/crdt/perf/entries/yy.entry.mjs b/probes/crdt/perf/entries/yy.entry.mjs new file mode 100644 index 0000000..3eb8e3d --- /dev/null +++ b/probes/crdt/perf/entries/yy.entry.mjs @@ -0,0 +1,6 @@ +import { Doc, encodeStateAsUpdate } from '@y/y' +export function run() { + const doc = new Doc() + doc.get('text').insert(0, 'hello world') + return encodeStateAsUpdate(doc) +} diff --git a/probes/crdt/perf/gen-snapshots.mjs b/probes/crdt/perf/gen-snapshots.mjs new file mode 100644 index 0000000..158282e --- /dev/null +++ b/probes/crdt/perf/gen-snapshots.mjs @@ -0,0 +1,13 @@ +import { loadTrace, sliceOps } from './trace.mjs' +import fs from 'node:fs' + +const trace = loadTrace('./traces/automerge-paper.json') +const ops10k = sliceOps(trace, 10000) + +for (const [arg, mod] of [['loro','./libs/loro.mjs'],['yjs','./libs/yjs.mjs'],['yy','./libs/yy.mjs'],['automerge','./libs/automerge.mjs']]) { + const lib = await import(mod) + const doc = lib.applyOps(ops10k) + const snap = lib.snapshot(doc) + fs.writeFileSync(`./web/snapshots/${arg}-10k.bin`, snap) + console.log(arg, 'snapshot bytes', snap.length, 'text len', lib.getText(doc).length) +} diff --git a/probes/crdt/perf/libs/automerge.mjs b/probes/crdt/perf/libs/automerge.mjs new file mode 100644 index 0000000..929e591 --- /dev/null +++ b/probes/crdt/perf/libs/automerge.mjs @@ -0,0 +1,28 @@ +import * as Automerge from '@automerge/automerge' + +export const name = '@automerge/automerge' + +export function applyOps(ops) { + let doc = Automerge.init() + doc = Automerge.change(doc, d => { d.text = '' }) + // One change() per edit mirrors how a real local editor would commit each + // keystroke; this is the realistic (and worst-case overhead) path for Automerge. + for (const op of ops) { + doc = Automerge.change(doc, d => { + Automerge.splice(d, ['text'], op.pos, op.del, op.ins) + }) + } + return doc +} + +export function getText(doc) { + return doc.text +} + +export function snapshot(doc) { + return Automerge.save(doc) +} + +export function loadFromSnapshot(bytes) { + return Automerge.load(bytes) +} diff --git a/probes/crdt/perf/libs/loro.mjs b/probes/crdt/perf/libs/loro.mjs new file mode 100644 index 0000000..52a0941 --- /dev/null +++ b/probes/crdt/perf/libs/loro.mjs @@ -0,0 +1,32 @@ +import { LoroDoc } from 'loro-crdt' + +export const name = 'loro-crdt' + +export function applyOps(ops) { + const doc = new LoroDoc() + const text = doc.getText('text') + for (const op of ops) { + if (op.del > 0) text.delete(op.pos, op.del) + if (op.ins) text.insert(op.pos, op.ins) + } + doc.commit() + return doc +} + +export function getText(doc) { + return doc.getText('text').toString() +} + +export function snapshot(doc) { + return doc.export({ mode: 'snapshot' }) +} + +export function shallowSnapshot(doc) { + return doc.export({ mode: 'shallow-snapshot', frontiers: doc.frontiers() }) +} + +export function loadFromSnapshot(bytes) { + const doc = new LoroDoc() + doc.import(bytes) + return doc +} diff --git a/probes/crdt/perf/libs/yjs.mjs b/probes/crdt/perf/libs/yjs.mjs new file mode 100644 index 0000000..995c323 --- /dev/null +++ b/probes/crdt/perf/libs/yjs.mjs @@ -0,0 +1,27 @@ +import * as Y from 'yjs' + +export const name = 'yjs' + +export function applyOps(ops) { + const doc = new Y.Doc() + const text = doc.getText('text') + for (const op of ops) { + if (op.del > 0) text.delete(op.pos, op.del) + if (op.ins) text.insert(op.pos, op.ins) + } + return doc +} + +export function getText(doc) { + return doc.getText('text').toString() +} + +export function snapshot(doc) { + return Y.encodeStateAsUpdate(doc) +} + +export function loadFromSnapshot(bytes) { + const doc = new Y.Doc() + Y.applyUpdate(doc, bytes) + return doc +} diff --git a/probes/crdt/perf/libs/yy.mjs b/probes/crdt/perf/libs/yy.mjs new file mode 100644 index 0000000..1d1246b --- /dev/null +++ b/probes/crdt/perf/libs/yy.mjs @@ -0,0 +1,27 @@ +import { Doc, encodeStateAsUpdate, applyUpdate } from '@y/y' + +export const name = '@y/y' + +export function applyOps(ops) { + const doc = new Doc() + const text = doc.get('text') + for (const op of ops) { + if (op.del > 0) text.delete(op.pos, op.del) + if (op.ins) text.insert(op.pos, op.ins) + } + return doc +} + +export function getText(doc) { + return doc.get('text').toString() +} + +export function snapshot(doc) { + return encodeStateAsUpdate(doc) +} + +export function loadFromSnapshot(bytes) { + const doc = new Doc() + applyUpdate(doc, bytes) + return doc +} diff --git a/probes/crdt/perf/package-lock.json b/probes/crdt/perf/package-lock.json new file mode 100644 index 0000000..f0cc850 --- /dev/null +++ b/probes/crdt/perf/package-lock.json @@ -0,0 +1,1665 @@ +{ + "name": "crdt-perf-probe", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "crdt-perf-probe", + "version": "0.0.0", + "dependencies": { + "@automerge/automerge": "^3.5.0", + "@y/y": "^14.0.0-rc.7", + "esbuild": "^0.28.2", + "loro-crdt": "^1.17.1", + "yjs": "^13.6.33" + }, + "devDependencies": { + "@playwright/test": "^1.64.1", + "wrangler": "^4.156.0" + } + }, + "node_modules/@automerge/automerge": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@automerge/automerge/-/automerge-3.5.0.tgz", + "integrity": "sha512-ejbqJWfXWM2QbTcUK/5ugYiQiyOP7LYVAp/RuSvthCc07oek0FClMxEuouuhjrLjVPDSI34RP1ftGc45PF7WRA==", + "license": "MIT" + }, + "node_modules/@cloudflare/kv-asset-handler": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.5.0.tgz", + "integrity": "sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg==", + "dev": true, + "license": "MIT OR Apache-2.0", + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@cloudflare/unenv-preset": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/@cloudflare/unenv-preset/-/unenv-preset-2.16.2.tgz", + "integrity": "sha512-JBP1+Z7ZSNG/d4mRP+y8VC5dka3tZVMLEZRvS+rzQ4DGV1EoxRFQckcJTTkXbHSQiTj0DtNI01Zwb/V2fX0mvQ==", + "dev": true, + "license": "MIT OR Apache-2.0", + "peerDependencies": { + "unenv": "2.0.0-rc.24", + "workerd": ">1.20260305.0 <2.0.0-0" + }, + "peerDependenciesMeta": { + "workerd": { + "optional": true + } + } + }, + "node_modules/@cloudflare/workerd-darwin-64": { + "version": "1.20261023.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20261023.1.tgz", + "integrity": "sha512-lsEx0i7nR0PNG/erUFFHmQmiidEhLfDE5uQmAL9421/y4/ycuxDDOSaxu3VGGYFFPK5sduyUeMmjIlX4CwOBFg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20261023.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20261023.1.tgz", + "integrity": "sha512-5e79fHgabdDD8EgmjOhJ1S+xMsf6DbC7fL7IgTBizMnzOp0P2isDn7pYmUxI9AJZE9FVQ4RUilH/I36YNg+GQQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-64": { + "version": "1.20261023.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20261023.1.tgz", + "integrity": "sha512-VHQ6jKFSihjR2+x1buby8XTdBLLJztVnYiB7OLOTYO8aDXB+c1Rd2410PdgFuFYc4AgFEk6PCJLyCLL5L1KBnw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20261023.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20261023.1.tgz", + "integrity": "sha512-ilpRHzfDN8YFRM5CLRKuFw40x/LJBS89yVdhdQmxehlVDuBqjKpJB++zPFbTgKRRFaNupgnXc8RHktXAIhgCmQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20261023.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20261023.1.tgz", + "integrity": "sha512-279WLVjNsMycAwr0EZNiNEf0l2SY6NUtsN80NwZzbTHzakmiN+WSx4w38muxPm+PAU0oSPPAPXKVD+H6Hya8xw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.5.tgz", + "integrity": "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.5.tgz", + "integrity": "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-freebsd-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.5.tgz", + "integrity": "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.4.tgz", + "integrity": "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.4.tgz", + "integrity": "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.4.tgz", + "integrity": "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.4.tgz", + "integrity": "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.4.tgz", + "integrity": "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.4.tgz", + "integrity": "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.4.tgz", + "integrity": "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.4.tgz", + "integrity": "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.4.tgz", + "integrity": "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.4.tgz", + "integrity": "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.5.tgz", + "integrity": "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.5.tgz", + "integrity": "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.5.tgz", + "integrity": "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.5.tgz", + "integrity": "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.5.tgz", + "integrity": "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.5.tgz", + "integrity": "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.5.tgz", + "integrity": "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.5.tgz", + "integrity": "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz", + "integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==", + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.11.3" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-webcontainers-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz", + "integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.5.tgz", + "integrity": "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.5.tgz", + "integrity": "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.5.tgz", + "integrity": "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@playwright/test": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz", + "integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.64.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@poppinss/colors": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz", + "integrity": "sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^4.1.5" + } + }, + "node_modules/@poppinss/dumper": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@poppinss/dumper/-/dumper-0.6.5.tgz", + "integrity": "sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@sindresorhus/is": "^7.0.2", + "supports-color": "^10.0.0" + } + }, + "node_modules/@poppinss/exception": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@poppinss/exception/-/exception-1.2.3.tgz", + "integrity": "sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@sindresorhus/is": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz", + "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, + "node_modules/@speed-highlight/core": { + "version": "1.2.24", + "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.24.tgz", + "integrity": "sha512-qeW2e1l78afw8VhRPfPQ1Gjj+KU5XFQ/OFV5ti6eTa9bruO7mJyZtA4vw0ofqmA3tKCkROE9xLk3VZoeRc98nw==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/@y/y": { + "version": "14.0.0-rc.7", + "resolved": "https://registry.npmjs.org/@y/y/-/y-14.0.0-rc.7.tgz", + "integrity": "sha512-J2nZO3+fMnGpRgqVFnOUX+AgqbuRSmUROl+fuJSPJFfk0gR5/Tb6WRqJAzpYSMf37HM5NGpUMqgSXA8wN3VpyA==", + "license": "MIT", + "dependencies": { + "lib0": "^1.0.0-rc.7" + }, + "engines": { + "node": ">=22.0.0", + "npm": ">=8.0.0" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/@y/y/node_modules/lib0": { + "version": "1.0.0-rc.36", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-1.0.0-rc.36.tgz", + "integrity": "sha512-7t/I+PCQqakal22rhXq5giOUtDP/RfecQtdeKvzCtnAvPkxSLAE+/Zvzi/kJDopg+hBAYKo46qmxmlkhX0tYlQ==", + "license": "MIT", + "bin": { + "0ecdsa-generate-keypair": "src/bin/0ecdsa-generate-keypair.js", + "0gentesthtml": "src/bin/gentesthtml.js", + "0serve": "src/bin/0serve.js" + }, + "engines": { + "node": ">=22" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/blake3-wasm": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz", + "integrity": "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==", + "dev": true, + "license": "MIT" + }, + "node_modules/cookie": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", + "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/error-stack-parser-es": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/error-stack-parser-es/-/error-stack-parser-es-1.0.5.tgz", + "integrity": "sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/isomorphic.js": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.2.5.tgz", + "integrity": "sha512-PIeMbHqMt4DnUP3MA/Flc0HElYjMXArsw1qwJZcm9sqR8mq3l8NYizFMty0pWwE/tzIGH3EKK5+jes5mAr85yw==", + "license": "MIT", + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/lib0": { + "version": "0.2.119", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.119.tgz", + "integrity": "sha512-vh+TiejVy8Xm+hCdnRfn9BthGNvNUZdEXltNjVZL3TzRIKP3s1lnQh8pWd/Q0wCgY0FPAGVVjFF4ZiHUV3LFgA==", + "license": "MIT", + "dependencies": { + "isomorphic.js": "^0.2.4" + }, + "bin": { + "0ecdsa-generate-keypair": "bin/0ecdsa-generate-keypair.js", + "0gentesthtml": "bin/gentesthtml.js", + "0serve": "bin/0serve.js" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/loro-crdt": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/loro-crdt/-/loro-crdt-1.17.1.tgz", + "integrity": "sha512-83hWRYG6eMMpPezm+yXWlOqCuUsC0BYY1MVCPW9x2zlikgkHhL7GC7Q6JFH+Hjvauyn287Q1MiwTuRW0lUOUag==", + "license": "MIT" + }, + "node_modules/miniflare": { + "version": "5.20261023.3-beta", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-5.20261023.3-beta.tgz", + "integrity": "sha512-thdXzlktu5GE1o/BlmMAPeJ0Cu6Tu5LpMbRlyfRrpVvMRrhd6p52TMqcITCZZLVzt1UO92VGBkLDhLOpryUAyQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "0.8.1", + "sharp": "0.35.5", + "undici": "7.30.1", + "workerd": "1.20261023.1", + "ws": "8.21.0", + "youch": "4.1.0-beta.10" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/path-to-regexp": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/playwright": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz", + "integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.64.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright-core": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz", + "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sharp": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.5.tgz", + "integrity": "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.1.0", + "detect-libc": "^2.1.2", + "semver": "^7.8.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.35.5", + "@img/sharp-darwin-x64": "0.35.5", + "@img/sharp-freebsd-wasm32": "0.35.5", + "@img/sharp-libvips-darwin-arm64": "1.3.4", + "@img/sharp-libvips-darwin-x64": "1.3.4", + "@img/sharp-libvips-linux-arm": "1.3.4", + "@img/sharp-libvips-linux-arm64": "1.3.4", + "@img/sharp-libvips-linux-ppc64": "1.3.4", + "@img/sharp-libvips-linux-riscv64": "1.3.4", + "@img/sharp-libvips-linux-s390x": "1.3.4", + "@img/sharp-libvips-linux-x64": "1.3.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4", + "@img/sharp-libvips-linuxmusl-x64": "1.3.4", + "@img/sharp-linux-arm": "0.35.5", + "@img/sharp-linux-arm64": "0.35.5", + "@img/sharp-linux-ppc64": "0.35.5", + "@img/sharp-linux-riscv64": "0.35.5", + "@img/sharp-linux-s390x": "0.35.5", + "@img/sharp-linux-x64": "0.35.5", + "@img/sharp-linuxmusl-arm64": "0.35.5", + "@img/sharp-linuxmusl-x64": "0.35.5", + "@img/sharp-webcontainers-wasm32": "0.35.5", + "@img/sharp-win32-arm64": "0.35.5", + "@img/sharp-win32-ia32": "0.35.5", + "@img/sharp-win32-x64": "0.35.5" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/supports-color": { + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.2.2.tgz", + "integrity": "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/undici": { + "version": "7.30.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.30.1.tgz", + "integrity": "sha512-03KrMbjIFDWQR5RNPrSw3bd1r12JpyFQl9/yxjUbJtqkjmllqC5lFjZh6ujeuJCKr8EOQvRW872Oy/az+nLYxg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, + "node_modules/unenv": { + "version": "2.0.0-rc.24", + "resolved": "https://registry.npmjs.org/unenv/-/unenv-2.0.0-rc.24.tgz", + "integrity": "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "pathe": "^2.0.3" + } + }, + "node_modules/workerd": { + "version": "1.20261023.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20261023.1.tgz", + "integrity": "sha512-NeofJFyaYNpqKpFRJW3ApuonaerPd6/JWlfTtLDYf2A6ygqrDEFnYgEXmc0hhOxqnJsSM+kXJN6VebPojzRrsg==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "bin": { + "workerd": "bin/workerd" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "@cloudflare/workerd-darwin-64": "1.20261023.1", + "@cloudflare/workerd-darwin-arm64": "1.20261023.1", + "@cloudflare/workerd-linux-64": "1.20261023.1", + "@cloudflare/workerd-linux-arm64": "1.20261023.1", + "@cloudflare/workerd-windows-64": "1.20261023.1" + } + }, + "node_modules/wrangler": { + "version": "4.156.0", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-4.156.0.tgz", + "integrity": "sha512-kVLAShuLiNgE3jcrmXcymDf/iPKDPrSxACe5ueugW/33HeNB9E9CkKYchudCeBwgmsnl4k+1zt4NO7vqb/fRuQ==", + "dev": true, + "license": "MIT OR Apache-2.0", + "dependencies": { + "@cloudflare/kv-asset-handler": "0.5.0", + "@cloudflare/unenv-preset": "2.16.2", + "blake3-wasm": "2.1.5", + "esbuild": "0.28.2", + "miniflare": "5.20261023.3-beta", + "path-to-regexp": "6.3.0", + "unenv": "2.0.0-rc.24", + "workerd": "1.20261023.1" + }, + "bin": { + "cf-wrangler": "bin/cf-wrangler.js", + "wrangler": "bin/wrangler.js", + "wrangler2": "bin/wrangler.js" + }, + "engines": { + "node": ">=22.0.0" + }, + "optionalDependencies": { + "fsevents": "2.3.3" + }, + "peerDependencies": { + "@cloudflare/workers-types": "^5.20261023.1" + }, + "peerDependenciesMeta": { + "@cloudflare/workers-types": { + "optional": true + } + } + }, + "node_modules/ws": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", + "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/yjs": { + "version": "13.6.33", + "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.6.33.tgz", + "integrity": "sha512-q/UYvr1gOk4XII+Cu1CW2dINjYqJJFifTzogEaIARznrvX7uOlHsdTEXcnOBMuIsrCGEEKdNxi74kyMLZlKVfw==", + "license": "MIT", + "dependencies": { + "lib0": "^0.2.99" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=8.0.0" + }, + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/dmonad" + } + }, + "node_modules/youch": { + "version": "4.1.0-beta.10", + "resolved": "https://registry.npmjs.org/youch/-/youch-4.1.0-beta.10.tgz", + "integrity": "sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@poppinss/dumper": "^0.6.4", + "@speed-highlight/core": "^1.2.7", + "cookie": "^1.0.2", + "youch-core": "^0.3.3" + } + }, + "node_modules/youch-core": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/youch-core/-/youch-core-0.3.3.tgz", + "integrity": "sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/exception": "^1.2.2", + "error-stack-parser-es": "^1.0.5" + } + } + } +} diff --git a/probes/crdt/perf/package.json b/probes/crdt/perf/package.json new file mode 100644 index 0000000..561a280 --- /dev/null +++ b/probes/crdt/perf/package.json @@ -0,0 +1,17 @@ +{ + "name": "crdt-perf-probe", + "private": true, + "type": "module", + "version": "0.0.0", + "dependencies": { + "@automerge/automerge": "^3.5.0", + "@y/y": "^14.0.0-rc.7", + "esbuild": "^0.28.2", + "loro-crdt": "^1.17.1", + "yjs": "^13.6.33" + }, + "devDependencies": { + "@playwright/test": "^1.64.1", + "wrangler": "^4.156.0" + } +} diff --git a/probes/crdt/perf/playwright.config.mjs b/probes/crdt/perf/playwright.config.mjs new file mode 100644 index 0000000..963d3e4 --- /dev/null +++ b/probes/crdt/perf/playwright.config.mjs @@ -0,0 +1,16 @@ +import { defineConfig } from '@playwright/test' + +export default defineConfig({ + testDir: '.', + timeout: 20000, + globalTimeout: 220000, + use: { + baseURL: 'http://localhost:8933', + headless: true, + }, + webServer: { + command: 'node web/server.mjs', + port: 8933, + reuseExistingServer: false, + }, +}) diff --git a/probes/crdt/perf/quicktest-am.mjs b/probes/crdt/perf/quicktest-am.mjs new file mode 100644 index 0000000..1e7105d --- /dev/null +++ b/probes/crdt/perf/quicktest-am.mjs @@ -0,0 +1,8 @@ +import { loadTrace, sliceOps } from './trace.mjs' +const trace = loadTrace('./traces/automerge-paper.json') +const ops10k = sliceOps(trace, 10000) +const lib = await import('./libs/automerge.mjs') +const t0 = performance.now() +const doc = lib.applyOps(ops10k) +const t1 = performance.now() +console.log(lib.name, '10k apply ms:', (t1-t0).toFixed(1), 'len', lib.getText(doc).length) diff --git a/probes/crdt/perf/quicktest.mjs b/probes/crdt/perf/quicktest.mjs new file mode 100644 index 0000000..1229f22 --- /dev/null +++ b/probes/crdt/perf/quicktest.mjs @@ -0,0 +1,13 @@ +import { loadTrace, sliceOps } from './trace.mjs' +const trace = loadTrace('./traces/automerge-paper.json') +const ops10k = sliceOps(trace, 10000) +console.log('total ops', trace.ops.length, 'endContent len', trace.endContent.length) + +for (const modName of ['./libs/loro.mjs', './libs/yjs.mjs', './libs/yy.mjs']) { + const lib = await import(modName) + const t0 = performance.now() + const doc = lib.applyOps(ops10k) + const t1 = performance.now() + const text = lib.getText(doc) + console.log(lib.name, '10k apply ms:', (t1-t0).toFixed(1), 'len', text.length) +} diff --git a/probes/crdt/perf/results/automerge-10k.err b/probes/crdt/perf/results/automerge-10k.err new file mode 100644 index 0000000..e69de29 diff --git a/probes/crdt/perf/results/automerge-10k.json b/probes/crdt/perf/results/automerge-10k.json new file mode 100644 index 0000000..bf043ff --- /dev/null +++ b/probes/crdt/perf/results/automerge-10k.json @@ -0,0 +1,43 @@ +{ + "lib": "@automerge/automerge", + "libArg": "automerge", + "size": "10k", + "opCount": 10000, + "finalTextLength": 6980, + "matchesExpectedEndContent": null, + "applyMsMedian": 2083.974, + "applyMsAll": [ + 2902.519792, + 2098.724458, + 2083.974, + 1520.861917000001, + 1536.862708999999 + ], + "heapDeltaBytesMedian": 49603360, + "heapDeltaBytesAll": [ + 42302896, + 49554056, + 49634392, + 49696632, + 49603360 + ], + "snapshotBytes": 6929, + "loadMsMedian": 60.069792000000234, + "loadMsAll": [ + 106.50424999999996, + 60.069792000000234, + 70.23095799999828, + 53.40520900000047, + 49.6802919999991 + ], + "readMsMedian": 0.004291000001103384, + "readMsAll": [ + 0.003957999999329331, + 0.004708000000391621, + 0.004417000000103144, + 0.003749999999854481, + 0.004291000001103384 + ], + "shallowSnapshotBytes": null, + "shallowLoadMs": null +} diff --git a/probes/crdt/perf/results/automerge-full.err b/probes/crdt/perf/results/automerge-full.err new file mode 100644 index 0000000..e69de29 diff --git a/probes/crdt/perf/results/automerge-full.json b/probes/crdt/perf/results/automerge-full.json new file mode 100644 index 0000000..4eabbfe --- /dev/null +++ b/probes/crdt/perf/results/automerge-full.json @@ -0,0 +1,43 @@ +{ + "lib": "@automerge/automerge", + "libArg": "automerge", + "size": "full", + "opCount": 259778, + "finalTextLength": 104852, + "matchesExpectedEndContent": true, + "applyMsMedian": 29150.042457999996, + "applyMsAll": [ + 28072.250458000002, + 40654.231166, + 22514.093042000008, + 29150.042457999996, + 30889.661041999992 + ], + "heapDeltaBytesMedian": 33528616, + "heapDeltaBytesAll": [ + 55737160, + 33528616, + 32847504, + 33523384, + 33666184 + ], + "snapshotBytes": 129285, + "loadMsMedian": 862.3845839999849, + "loadMsAll": [ + 1551.885707999987, + 837.8622920000053, + 862.3845839999849, + 848.0520839999954, + 941.0997919999936 + ], + "readMsMedian": 0.003124999988358468, + "readMsAll": [ + 0.010250000021187589, + 0.002582999994046986, + 0.0036660000041592866, + 0.0027079999854322523, + 0.003124999988358468 + ], + "shallowSnapshotBytes": null, + "shallowLoadMs": null +} diff --git a/probes/crdt/perf/results/browser-automerge.json b/probes/crdt/perf/results/browser-automerge.json new file mode 100644 index 0000000..496d898 --- /dev/null +++ b/probes/crdt/perf/results/browser-automerge.json @@ -0,0 +1,57 @@ +[ + { + "ok": true, + "lib": "automerge", + "textLength": 6980, + "coldStartMs": 333.2999999523163, + "moduleLoadMs": 327.89999997615814, + "initMs": 0, + "firstDocMs": 5.399999976158142, + "snapshotLoadMs": 71.29999995231628, + "snapshotReadMs": 0 + }, + { + "ok": true, + "lib": "automerge", + "textLength": 6980, + "coldStartMs": 289.6999999284744, + "moduleLoadMs": 285, + "initMs": 0, + "firstDocMs": 4.699999928474426, + "snapshotLoadMs": 70.70000004768372, + "snapshotReadMs": 0 + }, + { + "ok": true, + "lib": "automerge", + "textLength": 6980, + "coldStartMs": 290.1999999284744, + "moduleLoadMs": 285.39999997615814, + "initMs": 0, + "firstDocMs": 4.799999952316284, + "snapshotLoadMs": 71.5, + "snapshotReadMs": 0 + }, + { + "ok": true, + "lib": "automerge", + "textLength": 6980, + "coldStartMs": 288.5, + "moduleLoadMs": 284.10000002384186, + "initMs": 0, + "firstDocMs": 4.399999976158142, + "snapshotLoadMs": 70.60000002384186, + "snapshotReadMs": 0.09999990463256836 + }, + { + "ok": true, + "lib": "automerge", + "textLength": 6980, + "coldStartMs": 287.89999997615814, + "moduleLoadMs": 283.2000000476837, + "initMs": 0.10000002384185791, + "firstDocMs": 4.599999904632568, + "snapshotLoadMs": 71.09999990463257, + "snapshotReadMs": 0 + } +] \ No newline at end of file diff --git a/probes/crdt/perf/results/browser-loro.json b/probes/crdt/perf/results/browser-loro.json new file mode 100644 index 0000000..567fa94 --- /dev/null +++ b/probes/crdt/perf/results/browser-loro.json @@ -0,0 +1,57 @@ +[ + { + "ok": true, + "lib": "loro", + "textLength": 6980, + "coldStartMs": 35.89999997615814, + "moduleLoadMs": 8.600000023841858, + "initMs": 25.299999952316284, + "firstDocMs": 2, + "snapshotLoadMs": 9.400000095367432, + "snapshotReadMs": 1.1999999284744263 + }, + { + "ok": true, + "lib": "loro", + "textLength": 6980, + "coldStartMs": 18.399999976158142, + "moduleLoadMs": 3.1999999284744263, + "initMs": 14, + "firstDocMs": 1.2000000476837158, + "snapshotLoadMs": 8.600000023841858, + "snapshotReadMs": 1.1999999284744263 + }, + { + "ok": true, + "lib": "loro", + "textLength": 6980, + "coldStartMs": 18.600000023841858, + "moduleLoadMs": 3.299999952316284, + "initMs": 13.900000095367432, + "firstDocMs": 1.399999976158142, + "snapshotLoadMs": 8.799999952316284, + "snapshotReadMs": 1 + }, + { + "ok": true, + "lib": "loro", + "textLength": 6980, + "coldStartMs": 19.200000047683716, + "moduleLoadMs": 3.3000000715255737, + "initMs": 14.5, + "firstDocMs": 1.399999976158142, + "snapshotLoadMs": 8.700000047683716, + "snapshotReadMs": 1 + }, + { + "ok": true, + "lib": "loro", + "textLength": 6980, + "coldStartMs": 19.100000023841858, + "moduleLoadMs": 3.200000047683716, + "initMs": 14.5, + "firstDocMs": 1.399999976158142, + "snapshotLoadMs": 8.600000023841858, + "snapshotReadMs": 1.100000023841858 + } +] \ No newline at end of file diff --git a/probes/crdt/perf/results/browser-yjs.json b/probes/crdt/perf/results/browser-yjs.json new file mode 100644 index 0000000..fb5b668 --- /dev/null +++ b/probes/crdt/perf/results/browser-yjs.json @@ -0,0 +1,57 @@ +[ + { + "ok": true, + "lib": "yjs", + "textLength": 6980, + "coldStartMs": 30, + "moduleLoadMs": 29.399999976158142, + "initMs": 0, + "firstDocMs": 0.6000000238418579, + "snapshotLoadMs": 6.799999952316284, + "snapshotReadMs": 0.30000007152557373 + }, + { + "ok": true, + "lib": "yjs", + "textLength": 6980, + "coldStartMs": 7.399999976158142, + "moduleLoadMs": 7.200000047683716, + "initMs": 0, + "firstDocMs": 0.19999992847442627, + "snapshotLoadMs": 4.299999952316284, + "snapshotReadMs": 0 + }, + { + "ok": true, + "lib": "yjs", + "textLength": 6980, + "coldStartMs": 7.399999976158142, + "moduleLoadMs": 7.299999952316284, + "initMs": 0, + "firstDocMs": 0.10000002384185791, + "snapshotLoadMs": 4, + "snapshotReadMs": 0.10000002384185791 + }, + { + "ok": true, + "lib": "yjs", + "textLength": 6980, + "coldStartMs": 7.100000023841858, + "moduleLoadMs": 6.899999976158142, + "initMs": 0, + "firstDocMs": 0.20000004768371582, + "snapshotLoadMs": 3.9000000953674316, + "snapshotReadMs": 0.19999992847442627 + }, + { + "ok": true, + "lib": "yjs", + "textLength": 6980, + "coldStartMs": 7.199999928474426, + "moduleLoadMs": 7, + "initMs": 0.09999990463256836, + "firstDocMs": 0.10000002384185791, + "snapshotLoadMs": 4, + "snapshotReadMs": 0.09999990463256836 + } +] \ No newline at end of file diff --git a/probes/crdt/perf/results/browser-yy.json b/probes/crdt/perf/results/browser-yy.json new file mode 100644 index 0000000..bb01042 --- /dev/null +++ b/probes/crdt/perf/results/browser-yy.json @@ -0,0 +1,57 @@ +[ + { + "ok": true, + "lib": "yy", + "textLength": 6980, + "coldStartMs": 15.199999928474426, + "moduleLoadMs": 14.699999928474426, + "initMs": 0, + "firstDocMs": 0.5, + "snapshotLoadMs": 5, + "snapshotReadMs": 1 + }, + { + "ok": true, + "lib": "yy", + "textLength": 6980, + "coldStartMs": 8.800000071525574, + "moduleLoadMs": 8.600000023841858, + "initMs": 0.10000002384185791, + "firstDocMs": 0.10000002384185791, + "snapshotLoadMs": 4.5, + "snapshotReadMs": 0.8999999761581421 + }, + { + "ok": true, + "lib": "yy", + "textLength": 6980, + "coldStartMs": 9, + "moduleLoadMs": 8.799999952316284, + "initMs": 0, + "firstDocMs": 0.20000004768371582, + "snapshotLoadMs": 4.5, + "snapshotReadMs": 1 + }, + { + "ok": true, + "lib": "yy", + "textLength": 6980, + "coldStartMs": 8.699999928474426, + "moduleLoadMs": 8.599999904632568, + "initMs": 0, + "firstDocMs": 0.10000002384185791, + "snapshotLoadMs": 4.5, + "snapshotReadMs": 0.8999999761581421 + }, + { + "ok": true, + "lib": "yy", + "textLength": 6980, + "coldStartMs": 8.800000071525574, + "moduleLoadMs": 8.5, + "initMs": 0.10000002384185791, + "firstDocMs": 0.20000004768371582, + "snapshotLoadMs": 4.400000095367432, + "snapshotReadMs": 0.8999999761581421 + } +] \ No newline at end of file diff --git a/probes/crdt/perf/results/bundle-sizes.csv b/probes/crdt/perf/results/bundle-sizes.csv new file mode 100644 index 0000000..dd9442d --- /dev/null +++ b/probes/crdt/perf/results/bundle-sizes.csv @@ -0,0 +1,6 @@ +name,js_raw,js_gzip,js_brotli,wasm_raw,wasm_gzip,wasm_brotli,total_raw,total_gzip,total_brotli +yjs,75339,22687,20435,0,0,0,75339,22687,20435 +@y/y,96636,29160,26124,0,0,0,96636,29160,26124 +loro-crdt(web,separate-wasm),85073,12120,10541,3595346,1194452,841433,3680419,1206572,851974 +automerge(default-base64-neutral),4900333,1643895,1115472,0,0,0,4900333,1643895,1115472 +automerge(slim+separate-wasm),42819,11013,9609,3644225,1136572,792564,3687044,1147585,802173 diff --git a/probes/crdt/perf/results/loro-10k.err b/probes/crdt/perf/results/loro-10k.err new file mode 100644 index 0000000..e69de29 diff --git a/probes/crdt/perf/results/loro-10k.json b/probes/crdt/perf/results/loro-10k.json new file mode 100644 index 0000000..06b379d --- /dev/null +++ b/probes/crdt/perf/results/loro-10k.json @@ -0,0 +1,43 @@ +{ + "lib": "loro-crdt", + "libArg": "loro", + "size": "10k", + "opCount": 10000, + "finalTextLength": 6980, + "matchesExpectedEndContent": null, + "applyMsMedian": 19.56320800000003, + "applyMsAll": [ + 47.08104099999997, + 19.7115, + 18.46350000000001, + 18.320375000000013, + 19.56320800000003 + ], + "heapDeltaBytesMedian": 444216, + "heapDeltaBytesAll": [ + 836840, + 436160, + 444216, + 432304, + 447912 + ], + "snapshotBytes": 14103, + "loadMsMedian": 0.6614999999999895, + "loadMsAll": [ + 7.3480840000000285, + 0.6551249999999982, + 0.6142090000000167, + 0.6614999999999895, + 0.8776250000000232 + ], + "readMsMedian": 0.19233300000001918, + "readMsAll": [ + 0.6392079999999964, + 0.16287499999998545, + 0.19233300000001918, + 0.14337500000004866, + 0.21283299999998917 + ], + "shallowSnapshotBytes": 5417, + "shallowLoadMs": 0.8362079999999992 +} diff --git a/probes/crdt/perf/results/loro-full.err b/probes/crdt/perf/results/loro-full.err new file mode 100644 index 0000000..e69de29 diff --git a/probes/crdt/perf/results/loro-full.json b/probes/crdt/perf/results/loro-full.json new file mode 100644 index 0000000..7e9156e --- /dev/null +++ b/probes/crdt/perf/results/loro-full.json @@ -0,0 +1,43 @@ +{ + "lib": "loro-crdt", + "libArg": "loro", + "size": "full", + "opCount": 259778, + "finalTextLength": 104852, + "matchesExpectedEndContent": true, + "applyMsMedian": 572.670375, + "applyMsAll": [ + 572.670375, + 473.5160830000001, + 600.4616249999999, + 614.265042, + 471.255584 + ], + "heapDeltaBytesMedian": 10443016, + "heapDeltaBytesAll": [ + 10841832, + 10442936, + 10420264, + 10443016, + 10445304 + ], + "snapshotBytes": 251391, + "loadMsMedian": 0.8082089999998061, + "loadMsAll": [ + 6.112458000000061, + 0.8082089999998061, + 0.6961670000000595, + 0.6989589999998316, + 1.0230830000000424 + ], + "readMsMedian": 1.0392500000002656, + "readMsAll": [ + 2.0513339999997697, + 1.0392500000002656, + 0.9756250000000364, + 0.9692079999999805, + 1.212416999999732 + ], + "shallowSnapshotBytes": 64958, + "shallowLoadMs": 1.6304170000003069 +} diff --git a/probes/crdt/perf/results/wasm-sizes.csv b/probes/crdt/perf/results/wasm-sizes.csv new file mode 100644 index 0000000..d3ae15b --- /dev/null +++ b/probes/crdt/perf/results/wasm-sizes.csv @@ -0,0 +1,9 @@ +name,path,raw,gzip9,brotli11 +loro-crdt(web),node_modules/loro-crdt/web/loro_wasm_bg.wasm,3595346,1194452,841433 +loro-crdt(bundler),node_modules/loro-crdt/bundler/loro_wasm_bg.wasm,3596988,1194546,841462 +loro-crdt(browser),node_modules/loro-crdt/browser/loro_wasm_bg.wasm,3596988,1194547,841251 +loro-crdt(nodejs),node_modules/loro-crdt/nodejs/loro_wasm_bg.wasm,3597806,1194576,840839 +automerge(web),node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/web/automerge_wasm_bg.wasm,3644225,1136571,792564 +automerge(bundler),node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/bundler/automerge_wasm_bg.wasm,3644225,1136571,792564 +automerge(workerd),node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/workerd/automerge_wasm_bg.wasm,3644225,1136571,792564 +automerge(nodejs),node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/nodejs/automerge_wasm_bg.wasm,3644225,1136571,792564 diff --git a/probes/crdt/perf/results/yjs-10k.err b/probes/crdt/perf/results/yjs-10k.err new file mode 100644 index 0000000..e69de29 diff --git a/probes/crdt/perf/results/yjs-10k.json b/probes/crdt/perf/results/yjs-10k.json new file mode 100644 index 0000000..0741664 --- /dev/null +++ b/probes/crdt/perf/results/yjs-10k.json @@ -0,0 +1,43 @@ +{ + "lib": "yjs", + "libArg": "yjs", + "size": "10k", + "opCount": 10000, + "finalTextLength": 6980, + "matchesExpectedEndContent": null, + "applyMsMedian": 64.65575000000001, + "applyMsAll": [ + 84.22287499999999, + 69.68729200000001, + 64.65575000000001, + 53.10895900000003, + 53.92141700000002 + ], + "heapDeltaBytesMedian": 16900848, + "heapDeltaBytesAll": [ + 18793728, + 16684632, + 17925000, + 16870496, + 16900848 + ], + "snapshotBytes": 15905, + "loadMsMedian": 3.38412500000004, + "loadMsAll": [ + 4.487666999999988, + 3.905375000000049, + 3.38412500000004, + 3.032332999999994, + 3.1219999999999573 + ], + "readMsMedian": 0.036958000000026914, + "readMsAll": [ + 0.04008299999998144, + 0.03499999999996817, + 0.04841699999997218, + 0.03462500000000546, + 0.036958000000026914 + ], + "shallowSnapshotBytes": null, + "shallowLoadMs": null +} diff --git a/probes/crdt/perf/results/yjs-full.err b/probes/crdt/perf/results/yjs-full.err new file mode 100644 index 0000000..e69de29 diff --git a/probes/crdt/perf/results/yjs-full.json b/probes/crdt/perf/results/yjs-full.json new file mode 100644 index 0000000..c8c0918 --- /dev/null +++ b/probes/crdt/perf/results/yjs-full.json @@ -0,0 +1,43 @@ +{ + "lib": "yjs", + "libArg": "yjs", + "size": "full", + "opCount": 259778, + "finalTextLength": 104852, + "matchesExpectedEndContent": true, + "applyMsMedian": 2351.272083, + "applyMsAll": [ + 2272.6229590000003, + 2745.255291, + 2587.754667, + 2351.272083, + 1551.2606669999986 + ], + "heapDeltaBytesMedian": 14164504, + "heapDeltaBytesAll": [ + 16871080, + 13253872, + 14164504, + 69834536, + 12561120 + ], + "snapshotBytes": 311038, + "loadMsMedian": 22.023333000001003, + "loadMsAll": [ + 25.109875000000102, + 20.04791699999987, + 20.580250000000888, + 22.75433399999929, + 22.023333000001003 + ], + "readMsMedian": 0.42637500000091677, + "readMsAll": [ + 0.8319589999991877, + 0.44695799999863084, + 0.3645829999986745, + 0.42637500000091677, + 0.3289580000000569 + ], + "shallowSnapshotBytes": null, + "shallowLoadMs": null +} diff --git a/probes/crdt/perf/results/yy-10k.err b/probes/crdt/perf/results/yy-10k.err new file mode 100644 index 0000000..e69de29 diff --git a/probes/crdt/perf/results/yy-10k.json b/probes/crdt/perf/results/yy-10k.json new file mode 100644 index 0000000..c6f5f49 --- /dev/null +++ b/probes/crdt/perf/results/yy-10k.json @@ -0,0 +1,43 @@ +{ + "lib": "@y/y", + "libArg": "yy", + "size": "10k", + "opCount": 10000, + "finalTextLength": 6980, + "matchesExpectedEndContent": null, + "applyMsMedian": 94.84945900000002, + "applyMsAll": [ + 109.77100000000002, + 94.84945900000002, + 95.39137500000004, + 87.18008299999997, + 79.709833 + ], + "heapDeltaBytesMedian": 36603336, + "heapDeltaBytesAll": [ + 38512248, + 36666064, + 36584872, + 36603336, + 35374456 + ], + "snapshotBytes": 19079, + "loadMsMedian": 3.8726250000000846, + "loadMsAll": [ + 4.5591249999999945, + 4.519999999999982, + 3.8726250000000846, + 3.768165999999951, + 3.5937079999999924 + ], + "readMsMedian": 0.4518749999999727, + "readMsAll": [ + 0.4518749999999727, + 0.4852090000000544, + 0.4540839999999662, + 0.4396669999999858, + 0.4484579999999596 + ], + "shallowSnapshotBytes": null, + "shallowLoadMs": null +} diff --git a/probes/crdt/perf/results/yy-full.err b/probes/crdt/perf/results/yy-full.err new file mode 100644 index 0000000..e69de29 diff --git a/probes/crdt/perf/results/yy-full.json b/probes/crdt/perf/results/yy-full.json new file mode 100644 index 0000000..1901d8a --- /dev/null +++ b/probes/crdt/perf/results/yy-full.json @@ -0,0 +1,43 @@ +{ + "lib": "@y/y", + "libArg": "yy", + "size": "full", + "opCount": 259778, + "finalTextLength": 104852, + "matchesExpectedEndContent": true, + "applyMsMedian": 15826.435417, + "applyMsAll": [ + 15401.990584000001, + 14656.676375, + 18276.085083, + 23614.291875000003, + 15826.435417 + ], + "heapDeltaBytesMedian": 53976208, + "heapDeltaBytesAll": [ + 12118456, + 113040840, + 53976208, + 54085400, + 53869776 + ], + "snapshotBytes": 376756, + "loadMsMedian": 41.35541699999885, + "loadMsAll": [ + 43.34274999999616, + 40.614041000008, + 36.46004199999152, + 43.72650000000431, + 41.35541699999885 + ], + "readMsMedian": 4.116083000000799, + "readMsAll": [ + 9.056500000006054, + 2.0724169999884907, + 4.116083000000799, + 9.199041999992914, + 2.273458000010578 + ], + "shallowSnapshotBytes": null, + "shallowLoadMs": null +} diff --git a/probes/crdt/perf/size-bundles.sh b/probes/crdt/perf/size-bundles.sh new file mode 100755 index 0000000..694efe9 --- /dev/null +++ b/probes/crdt/perf/size-bundles.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e +cd "$(dirname "$0")" +sizeof() { + local path="$1" + if [ ! -f "$path" ]; then echo "0,0,0"; return; fi + raw=$(/usr/bin/stat -f%z "$path") + gz=$(/usr/bin/gzip -9 -c "$path" | /usr/bin/wc -c | tr -d ' ') + br=$(/opt/homebrew/bin/brotli -q 11 -c "$path" | /usr/bin/wc -c | tr -d ' ') + echo "$raw,$gz,$br" +} +echo "name,js_raw,js_gzip,js_brotli,wasm_raw,wasm_gzip,wasm_brotli,total_raw,total_gzip,total_brotli" +emit() { + name="$1"; js="$2"; wasm="$3" + jr=$(sizeof "$js"); IFS=, read jraw jgz jbr <<< "$jr" + if [ -n "$wasm" ]; then + wr=$(sizeof "$wasm"); IFS=, read wraw wgz wbr <<< "$wr" + else + wraw=0; wgz=0; wbr=0 + fi + echo "$name,$jraw,$jgz,$jbr,$wraw,$wgz,$wbr,$((jraw+wraw)),$((jgz+wgz)),$((jbr+wbr))" +} +emit "yjs" "dist/yjs.bundle.js" "" +emit "@y/y" "dist/yy.bundle.js" "" +emit "loro-crdt(web,separate-wasm)" "dist/loro.bundle.js" "dist/loro_wasm_bg.wasm" +emit "automerge(default-base64-neutral)" "dist/automerge.bundle.js" "" +emit "automerge(slim+separate-wasm)" "dist/automerge-slim.bundle.js" "dist/automerge-X4OLCNJ7.wasm" diff --git a/probes/crdt/perf/size-wasm.sh b/probes/crdt/perf/size-wasm.sh new file mode 100755 index 0000000..90d9e38 --- /dev/null +++ b/probes/crdt/perf/size-wasm.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e +cd "$(dirname "$0")" +report() { + name="$1"; path="$2" + if [ ! -f "$path" ]; then echo "$name,$path,MISSING,,"; return; fi + raw=$(/usr/bin/stat -f%z "$path") + gz=$(/usr/bin/gzip -9 -c "$path" | /usr/bin/wc -c | tr -d ' ') + br=$(/opt/homebrew/bin/brotli -q 11 -c "$path" | /usr/bin/wc -c | tr -d ' ') + echo "$name,$path,$raw,$gz,$br" +} +echo "name,path,raw,gzip9,brotli11" +report "loro-crdt(web)" "node_modules/loro-crdt/web/loro_wasm_bg.wasm" +report "loro-crdt(bundler)" "node_modules/loro-crdt/bundler/loro_wasm_bg.wasm" +report "loro-crdt(browser)" "node_modules/loro-crdt/browser/loro_wasm_bg.wasm" +report "loro-crdt(nodejs)" "node_modules/loro-crdt/nodejs/loro_wasm_bg.wasm" +report "automerge(web)" "node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/web/automerge_wasm_bg.wasm" +report "automerge(bundler)" "node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/bundler/automerge_wasm_bg.wasm" +report "automerge(workerd)" "node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/workerd/automerge_wasm_bg.wasm" +report "automerge(nodejs)" "node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/nodejs/automerge_wasm_bg.wasm" diff --git a/probes/crdt/perf/trace.mjs b/probes/crdt/perf/trace.mjs new file mode 100644 index 0000000..b13f674 --- /dev/null +++ b/probes/crdt/perf/trace.mjs @@ -0,0 +1,19 @@ +import fs from 'node:fs' + +// Loads the josephg/editing-traces sequential trace format: +// { startContent, endContent, txns: [{ patches: [[pos, delCount, insText], ...] }, ...] } +export function loadTrace(path) { + const raw = JSON.parse(fs.readFileSync(path, 'utf8')) + const ops = [] + for (const txn of raw.txns) { + for (const p of txn.patches) { + const [pos, del, ins] = p + ops.push({ pos, del, ins: ins || '' }) + } + } + return { startContent: raw.startContent || '', endContent: raw.endContent || '', ops } +} + +export function sliceOps(trace, n) { + return trace.ops.slice(0, n) +} diff --git a/probes/crdt/perf/web/index.html b/probes/crdt/perf/web/index.html new file mode 100644 index 0000000..687a5ea --- /dev/null +++ b/probes/crdt/perf/web/index.html @@ -0,0 +1,14 @@ + + + + + + diff --git a/probes/crdt/perf/web/server.mjs b/probes/crdt/perf/web/server.mjs new file mode 100644 index 0000000..d653c14 --- /dev/null +++ b/probes/crdt/perf/web/server.mjs @@ -0,0 +1,28 @@ +import http from 'node:http' +import fs from 'node:fs' +import path from 'node:path' + +const root = path.resolve(import.meta.dirname, '..') +const port = process.env.PORT || 8933 + +const mime = { + '.js': 'application/javascript', + '.mjs': 'application/javascript', + '.wasm': 'application/wasm', + '.html': 'text/html', + '.json': 'application/json', +} + +http.createServer((req, res) => { + const url = new URL(req.url, 'http://x') + let p = decodeURIComponent(url.pathname) + if (p === '/') p = '/web/index.html' + const file = path.join(root, p) + if (!file.startsWith(root)) { res.writeHead(403); res.end(); return } + fs.readFile(file, (err, data) => { + if (err) { res.writeHead(404); res.end('not found: ' + p); return } + const ext = path.extname(file) + res.writeHead(200, { 'Content-Type': mime[ext] || 'application/octet-stream' }) + res.end(data) + }) +}).listen(port, () => console.log('listening on', port)) diff --git a/probes/crdt/perf/web/snapshots/automerge-10k.bin b/probes/crdt/perf/web/snapshots/automerge-10k.bin new file mode 100644 index 0000000000000000000000000000000000000000..49d34b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SeHN9&75m^NH8-`MR2_f=aO)?j}soLKGJKS$t?RWX?o=A#JcXxSra5m z7EOH1UtIjqDs;>Gn8Rst%lnOA)}5`o!7Z0vD`6n_CW=S7HS0;ngfA1mS@Bm+e|L9E z!@N+<9h1I3@Ks}dznSZok-zMZEvn4?mp*T(-(Fx4+pTF{SaefPzRsKBE!Vo8S3exj z+Oc3!!Sz_)RN(`GYZs(2z2W?O#!EKQxcr8-hwhmacUg;x{0l^MT^*r#XA<-EvMUD+Wf%T9{jxy% znS4rfTdv`g?w;3g(^JJN4PuS%2P5 ztBN}RqsPK~Lv&?u;qSwNHxegGeth`+zb(_PbzF%%FWd~udq2sr+)mf9EA{p%*Bh%e Z;~u%O>bWi}(^&DHgFoS9?@9X!egOL+VT=F( literal 0 HcmV?d00001 diff --git a/probes/crdt/perf/web/snapshots/loro-10k.bin b/probes/crdt/perf/web/snapshots/loro-10k.bin new file mode 100644 index 0000000000000000000000000000000000000000..e702dd88243977f92b0190f8bcc08a2268eb4387 GIT binary patch literal 14101 zcmc}EFUn^?0>R8IcNv&ZD={$m_y_qjFm@kZedxuGH=8Qw&0%Cz`)4B z#>m3R#K6GHQj%Ix!tjKZk%jphGs6-lUj_#=295^CLyQb+j7$syuNc`Ym@S-~`MCWU zf>=9P8JZZGO$u^8F*59DGVo_%W8{@ClHShpj!l4-g@Ij-p~{Yh3lX9&x2Dlx>kFhof(Y-Ri`z`@19!l=NYvxt$ohmqld5I^rhMsd~yj0{Y@OqUpw zuP`=>FdPuP#JG|13gc#Bh6jR|7=11>-es3`5>sGkKtge`~NhuuzqnSqhriJilY zT}p>RN=+wCpK%H+GbcB%C_6W!C!;f~u&6w{Bs(iNGovjtXR7K+X6`h`Ys>-4s~DMz z7L^YW=7%V%nZwz8J06M zs;ppUW?^6!S2@eb!pg|W#>&ab%E`*f!U`ey)kx7Y> zoll;TpM{BEmWzpzm4%gyjWL#km4}sugOx{wnTe5;SDlHSiIt6=n}v;0l~IYAi(7z& zmxY;)iBX=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(#YZ-rWeCJ5=yTs1UcADMfAKP&@!*eWb zXIUE9|FV6vduz9dwUhM+3tK1443;H~3mKO&&SVt2%JhNxIrA>Yt&B3SnAbDMFe-bw zUSc}Sbj|9lRTpDdr95 zSck1)w2kmdlM$Et#rT==ALDh#CPwp&h@pky55_r69gLqCgKVxd?qc##5mvb9|JBhc5tJ-GF}-AT;M5gR(+r84 z%c#g_WXZ%XC#w-wD^-wLr)_J@#UR8kY**98*ve$h#LUOd=wz*9=w{34VpS|6tD)V& z7$E$JaUnCS5u-jACkrzJQ^GsO^Gr+}e1aCXEOO#p-1C_GnO8ARXH;hp;bvrIW3~}q z$H=Pln^AyUL|lNIF)p5qlSxdHg@Ip;otJ@!m4las0kk3tFjEapCK>4_#%4x_FO2&c z_4(uk>`RIn3T80oawO{IO7XHWvoWy87^^a}Fi1*Ca>b=Hv9U9-F|qNoF)U{CaA)FR zXOt0TVP_CgGBq+}WZ+_F1W7V5nVE8MGRU!WGqQFt=F2gv@-m9FFlt7|Tw`3$#Hyqg zFQKFs&mh9j#LD32%D~3K%fKYVrp&;?#$IQ&nvq42g@<2DR9HelQbCuGmqAF4QIuDZ zkDD#0n2CW=M9q+eX93ejCL8-rjB6QL733LMM4mC$D@1atiSueRbG%{t%jCeP4;o2i eVAydZ=K&*h$dQeqi3L=~Hzu||vEdhiC;$Mn)SY(# literal 0 HcmV?d00001 diff --git a/probes/crdt/perf/web/snapshots/yjs-10k.bin b/probes/crdt/perf/web/snapshots/yjs-10k.bin new file mode 100644 index 0000000000000000000000000000000000000000..3b4abe9f1563386abee3dddcaefe94f9630789b7 GIT binary patch literal 15905 zcmZOZ$#VNa&tiTC7Dkqm)QS@8n3VkF(%jU%lH{Dk;^OE;lY+#8)FPdd^8DodoYLGp z9YceHlGy6RqLR$yoYY#bn9}0Zg2d$P#Prlgut`>oEnwPOAiA_9%_6osGq0euBsDL& z79#FFl@VD}b#7uwMnOq#MXiFWLP=(BYOz95er{r(jzVT$a!zSVW?s4iNC~o@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A>{IQT?%Ok;cVGqpT)Kfw literal 0 HcmV?d00001 diff --git a/probes/crdt/perf/web/worker.mjs b/probes/crdt/perf/web/worker.mjs new file mode 100644 index 0000000..5433aa0 --- /dev/null +++ b/probes/crdt/perf/web/worker.mjs @@ -0,0 +1,43 @@ +// Generic CRDT bench worker. Query params: lib=loro|yjs|yy|automerge +const tWorkerStart = performance.now() +const params = new URL(self.location.href).searchParams +const lib = params.get('lib') + +const modulePaths = { + loro: '/dist/worker-loro.js', + yjs: '/dist/worker-yjs.js', + yy: '/dist/worker-yy.js', + automerge: '/dist/worker-automerge.js', +} + +async function main() { + const mod = await import(modulePaths[lib]) + const tModuleLoaded = performance.now() + await mod.init() + const tInitDone = performance.now() + const doc = mod.createDoc() + const tFirstDocCreated = performance.now() + + // fetch the 10k-edit snapshot and measure load+read + const snapRes = await fetch(`/web/snapshots/${lib}-10k.bin`) + const snapBytes = new Uint8Array(await snapRes.arrayBuffer()) + const tSnapFetched = performance.now() + const doc2 = mod.loadFromSnapshot(snapBytes) + const tSnapLoaded = performance.now() + const text = mod.getText(doc2) + const tTextRead = performance.now() + + postMessage({ + ok: true, + lib, + textLength: text.length, + coldStartMs: tFirstDocCreated - tWorkerStart, + moduleLoadMs: tModuleLoaded - tWorkerStart, + initMs: tInitDone - tModuleLoaded, + firstDocMs: tFirstDocCreated - tInitDone, + snapshotLoadMs: tSnapLoaded - tSnapFetched, + snapshotReadMs: tTextRead - tSnapLoaded, + }) +} + +main().catch(err => postMessage({ ok: false, lib, error: String(err), stack: err && err.stack })) diff --git a/probes/crdt/perf/worker-bench.spec.mjs b/probes/crdt/perf/worker-bench.spec.mjs new file mode 100644 index 0000000..a46c74f --- /dev/null +++ b/probes/crdt/perf/worker-bench.spec.mjs @@ -0,0 +1,16 @@ +import { test } from '@playwright/test' +import fs from 'node:fs' + +const LIB = process.env.BENCH_LIB +const REPS = 5 + +test(`worker bench: ${LIB}`, async ({ page, baseURL }) => { + await page.goto(baseURL + '/web/index.html') + const runs = [] + for (let i = 0; i < REPS; i++) { + const result = await page.evaluate((lib) => window.runWorkerBench(lib), LIB) + runs.push(result) + } + fs.writeFileSync(`./results/browser-${LIB}.json`, JSON.stringify(runs, null, 2)) + console.log('BENCH_RESULT', LIB, JSON.stringify(runs)) +}) diff --git a/probes/crdt/perf/workerd/gen-dynamic.mjs b/probes/crdt/perf/workerd/gen-dynamic.mjs new file mode 100644 index 0000000..7964df8 --- /dev/null +++ b/probes/crdt/perf/workerd/gen-dynamic.mjs @@ -0,0 +1,57 @@ +import fs from 'node:fs' +import path from 'node:path' + +const perf = path.resolve(import.meta.dirname, '..') +const read = (p) => fs.readFileSync(path.join(perf, p), 'utf8') + +const sources = { + yjs: read('dist/guest-yjs.js'), + yy: read('dist/guest-yy.js'), + loro: read('dist/guest-loro.js'), + automerge: read('dist/guest-automerge.js'), +} + +// Write each guest bundle out as its own JSON-encoded string module so the +// generated host file never has to deal with nested template-literal escaping. +fs.mkdirSync('./generated', { recursive: true }) +for (const [name, src] of Object.entries(sources)) { + fs.writeFileSync(`./generated/guest-${name}.json`, JSON.stringify(src)) +} + +const lines = [] +lines.push("// AUTO-GENERATED by gen-dynamic.mjs — do not edit directly") +lines.push("import loroWasmModule from '../../node_modules/loro-crdt/bundler/loro_wasm_bg.wasm'") +lines.push("import automergeWasmModule from '../../node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/workerd/automerge_wasm_bg.wasm'") +lines.push("import GUEST_YJS from '../generated/guest-yjs.json'") +lines.push("import GUEST_YY from '../generated/guest-yy.json'") +lines.push("import GUEST_LORO from '../generated/guest-loro.json'") +lines.push("import GUEST_AUTOMERGE from '../generated/guest-automerge.json'") +lines.push("") +lines.push("function buildModules(mainSrc, wasmKey, wasmModule, wasmForm) {") +lines.push(" const modules = { 'main.js': mainSrc }") +lines.push(" if (wasmKey) {") +lines.push(" modules[wasmKey] = wasmForm === 'bare' ? wasmModule : { wasm: wasmModule }") +lines.push(" }") +lines.push(" return modules") +lines.push("}") +lines.push("") +lines.push("export async function runDynamic(env, kase, wasmForm) {") +lines.push(" let modules") +lines.push(" if (kase === 'yjs') modules = buildModules(GUEST_YJS, null, null, wasmForm)") +lines.push(" else if (kase === 'yy') modules = buildModules(GUEST_YY, null, null, wasmForm)") +lines.push(" else if (kase === 'loro') modules = buildModules(GUEST_LORO, 'loro_wasm_bg.wasm', loroWasmModule, wasmForm)") +lines.push(" else if (kase === 'automerge') modules = buildModules(GUEST_AUTOMERGE, '../wasm_bindgen_output/workerd/automerge_wasm_bg.wasm', automergeWasmModule, wasmForm)") +lines.push(" else throw new Error('unknown case ' + kase)") +lines.push("") +lines.push(" const worker = env.LOADER.get('dyn-' + kase + '-' + wasmForm, async () => ({") +lines.push(" compatibilityDate: '2026-10-29',") +lines.push(" mainModule: 'main.js',") +lines.push(" modules,") +lines.push(" env: {},") +lines.push(" globalOutbound: null,") +lines.push(" }))") +lines.push(" return await worker.getEntrypoint().fetch(new Request('https://guest/'))") +lines.push("}") + +fs.writeFileSync('./src/dynamic.js', lines.join('\n') + '\n') +console.log('wrote src/dynamic.js and generated/*.json') diff --git a/probes/crdt/perf/workerd/src/dynamic.js b/probes/crdt/perf/workerd/src/dynamic.js new file mode 100644 index 0000000..5012049 --- /dev/null +++ b/probes/crdt/perf/workerd/src/dynamic.js @@ -0,0 +1,33 @@ +// AUTO-GENERATED by gen-dynamic.mjs — do not edit directly +import loroWasmModule from '../../node_modules/loro-crdt/bundler/loro_wasm_bg.wasm' +import automergeWasmModule from '../../node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/workerd/automerge_wasm_bg.wasm' +import GUEST_YJS from '../generated/guest-yjs.json' +import GUEST_YY from '../generated/guest-yy.json' +import GUEST_LORO from '../generated/guest-loro.json' +import GUEST_AUTOMERGE from '../generated/guest-automerge.json' + +function buildModules(mainSrc, wasmKey, wasmModule, wasmForm) { + const modules = { 'main.js': mainSrc } + if (wasmKey) { + modules[wasmKey] = wasmForm === 'bare' ? wasmModule : { wasm: wasmModule } + } + return modules +} + +export async function runDynamic(env, kase, wasmForm) { + let modules + if (kase === 'yjs') modules = buildModules(GUEST_YJS, null, null, wasmForm) + else if (kase === 'yy') modules = buildModules(GUEST_YY, null, null, wasmForm) + else if (kase === 'loro') modules = buildModules(GUEST_LORO, 'loro_wasm_bg.wasm', loroWasmModule, wasmForm) + else if (kase === 'automerge') modules = buildModules(GUEST_AUTOMERGE, '../wasm_bindgen_output/workerd/automerge_wasm_bg.wasm', automergeWasmModule, wasmForm) + else throw new Error('unknown case ' + kase) + + const worker = env.LOADER.get('dyn-' + kase + '-' + wasmForm, async () => ({ + compatibilityDate: '2026-10-29', + mainModule: 'main.js', + modules, + env: {}, + globalOutbound: null, + })) + return await worker.getEntrypoint().fetch(new Request('https://guest/')) +} diff --git a/probes/crdt/perf/workerd/src/index.js b/probes/crdt/perf/workerd/src/index.js new file mode 100644 index 0000000..3f1d2b0 --- /dev/null +++ b/probes/crdt/perf/workerd/src/index.js @@ -0,0 +1,78 @@ +import { runDynamic } from './dynamic.js' +import * as Y from 'yjs' +import { Doc as YYDoc, encodeStateAsUpdate as yyEncode, applyUpdate as yyApply } from '@y/y' +import { LoroDoc } from 'loro-crdt/bundler' +import * as Automerge from '@automerge/automerge' + +function twoDocTest({ makeDoc, getText, insert, encode, applyUpdate }) { + const a = makeDoc() + const b = makeDoc() + insert(a, 0, 'hello ') + insert(b, 0, 'world ') + const updA = encode(a) + const updB = encode(b) + applyUpdate(a, updB) + applyUpdate(b, updA) + return { aText: getText(a), bText: getText(b), snapshotBytes: encode(a).length } +} + +const CASES = { + yjs() { + return twoDocTest({ + makeDoc: () => new Y.Doc(), + getText: (d) => d.getText('text').toString(), + insert: (d, i, s) => d.getText('text').insert(i, s), + encode: (d) => Y.encodeStateAsUpdate(d), + applyUpdate: (d, u) => Y.applyUpdate(d, u), + }) + }, + yy() { + return twoDocTest({ + makeDoc: () => new YYDoc(), + getText: (d) => d.get('text').toString(), + insert: (d, i, s) => d.get('text').insert(i, s), + encode: (d) => yyEncode(d), + applyUpdate: (d, u) => yyApply(d, u), + }) + }, + loro() { + return twoDocTest({ + makeDoc: () => new LoroDoc(), + getText: (d) => d.getText('text').toString(), + insert: (d, i, s) => d.getText('text').insert(i, s), + encode: (d) => { d.commit(); return d.export({ mode: 'snapshot' }) }, + applyUpdate: (d, u) => d.import(u), + }) + }, + automerge() { + let a = Automerge.init() + let b = Automerge.init() + a = Automerge.change(a, (d) => { d.text = '' }) + a = Automerge.change(a, (d) => { Automerge.splice(d, ['text'], 0, 0, 'hello ') }) + b = Automerge.change(b, (d) => { d.text = '' }) + b = Automerge.change(b, (d) => { Automerge.splice(d, ['text'], 0, 0, 'world ') }) + const merged = Automerge.merge(a, b) + const snap = Automerge.save(merged) + return { aText: merged.text, bText: merged.text, snapshotBytes: snap.length } + }, +} + +export default { + async fetch(req, env) { + const url = new URL(req.url) + const kase = url.searchParams.get('case') || 'yjs' + const mode = url.searchParams.get('mode') || 'plain' // plain | dynamic + const wasmForm = url.searchParams.get('wasmForm') || 'wrapped' // wrapped | bare + try { + if (mode === 'dynamic') { + return await runDynamic(env, kase, wasmForm) + } + const fn = CASES[kase] + if (!fn) return new Response('unknown case: ' + kase, { status: 400 }) + const result = fn() + return Response.json({ ok: true, case: kase, result }) + } catch (err) { + return Response.json({ ok: false, case: kase, mode, wasmForm, error: String(err), stack: err && err.stack }, { status: 500 }) + } + }, +} diff --git a/probes/crdt/perf/workerd/wrangler.jsonc b/probes/crdt/perf/workerd/wrangler.jsonc new file mode 100644 index 0000000..2f24226 --- /dev/null +++ b/probes/crdt/perf/workerd/wrangler.jsonc @@ -0,0 +1,9 @@ +{ + "$schema": "node_modules/wrangler/config-schema.json", + "name": "crdt-workerd-probe", + "main": "src/index.js", + "compatibility_date": "2026-10-29", + "worker_loaders": [ + { "binding": "LOADER" } + ] +} -- knotmirror 0.0.1