Repository navigation
Improve hash, diff packages and refactor iterators - #1050
Merged
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
There are several correctness/robustness issues in newly added shared utilities (diff bisect bounds, DOM selection helper, iterator polyfill typing, and Emitter API constraints) that should be fixed before merging.
Pull request overview
This PR modularizes core functionality by extracting diffing and JSON hashing into dedicated workspace packages (@jsonjoy.com/diff, @jsonjoy.com/json-hash), then updates downstream packages to consume the new modules and shared utilities, alongside a few reliability improvements in demos/tests and session handling.
Changes:
- Introduces new workspace packages for diffing and JSON hashing, with extensive test coverage for diff/hash behavior.
- Updates imports across
json-joy,peritext, and collaborative packages to use@jsonjoy.com/diff,@jsonjoy.com/json-hash,@jsonjoy.com/util, andthingies/lib/sync. - Improves operational robustness in demo/test setups (isolated LevelDB dirs) and avoids unhandled rejection in
EditSessiontimer catch-up.
File summaries
| File | Description |
|---|---|
| yarn.lock | Adds new workspace deps |
| tsconfig.solution.json | Adds new TS project refs |
| packages/util/src/iterator/polyfill.ts | Adds Iterator runtime polyfill |
| packages/util/src/iterator/index.ts | Adds undefined-terminated iterator |
| packages/util/src/events/TypedEventTarget.ts | Adds typed EventTarget wrapper |
| packages/util/src/events/Emitter.ts | Adds lightweight event emitter |
| packages/rpc-server/src/demos/json-crdt-server/services/blocks/store/level/LevelStore.ts | Fixes key-range scan bounds |
| packages/rpc-server/src/demos/json-crdt-server/tests/setup.ts | Uses isolated temp LevelDB dir |
| packages/peritext/tsconfig.json | Adds project references |
| packages/peritext/tsconfig.build.json | Adds build references |
| packages/peritext/src/web/state/index.ts | Switches Value to thingies |
| packages/peritext/src/web/react/hooks.ts | Switches SyncStore type import |
| packages/peritext/src/web/dom/controllers/InputController.ts | Repoints TypedEventTarget import |
| packages/peritext/src/plugins/minimal/RenderPeritext.tsx | Switches Value to thingies |
| packages/peritext/src/plugins/minimal/context.ts | Switches Value type import |
| packages/peritext/src/plugins/debug/state/index.tsx | Switches Value to thingies |
| packages/peritext/src/plugins/debug/RenderPeritext.tsx | Switches Value to thingies |
| packages/peritext/src/plugins/debug/context.ts | Switches Value type import |
| packages/peritext/src/editor/state/menus/CaretMenu.tsx | Updates commented import path |
| packages/peritext/src/editor/inline/components/FmtManagePane/state.ts | Switches string diff module |
| packages/peritext/src/editor/components/CollaborativeInput.tsx | Uses scoped collaborative-input pkg |
| packages/peritext/package.json | Adds new deps (diff/util/thingies) |
| packages/json-joy/tsconfig.json | Adds new project references |
| packages/json-joy/tsconfig.build.json | Adds new build references |
| packages/json-joy/src/util/events/sync-store.ts | Removes re-export shim |
| packages/json-joy/src/util/diff/str-utils.ts | Removes old diff utility impl |
| packages/json-joy/src/json-patch-diff/JsonPatchDiff.ts | Repoints diff/hash imports |
| packages/json-joy/src/json-ml/walk.ts | Repoints iterator import |
| packages/json-joy/src/json-hash/index.ts | Adjusts exported surface |
| packages/json-joy/src/json-hash/hash.ts | Delegates to new json-hash pkg |
| packages/json-joy/src/json-crdt/nodes/rga/AbstractRga.ts | Repoints iterator import |
| packages/json-joy/src/json-crdt/nodes/const/ConNode.ts | Repoints print helper import |
| packages/json-joy/src/json-crdt/model/Model.ts | Repoints print helper import |
| packages/json-joy/src/json-crdt/model/api/nodes.ts | Switches SyncStore type import |
| packages/json-joy/src/json-crdt/model/api/NodeEvents.ts | Switches SyncStore type import |
| packages/json-joy/src/json-crdt/json-patch/JsonPatchStore.ts | Switches SyncStore type import |
| packages/json-joy/src/json-crdt/hash.ts | Uses @jsonjoy.com/json-hash |
| packages/json-joy/src/json-crdt/delta/Delta.ts | Repoints print helper import |
| packages/json-joy/src/json-crdt-patch/structHash.ts | Uses @jsonjoy.com/json-hash + clock |
| packages/json-joy/src/json-crdt-patch/schema.ts | Repoints print helper import |
| packages/json-joy/src/json-crdt-patch/print.ts | Repoints clock import |
| packages/json-joy/src/json-crdt-patch/tests/structHash.spec.ts | Repoints clock import in tests |
| packages/json-joy/src/json-crdt-extensions/peritext/util/dom.ts | Adds selection save/restore helper |
| packages/json-joy/src/json-crdt-extensions/peritext/util/ChunkSlice.ts | Uses @jsonjoy.com/json-hash |
| packages/json-joy/src/json-crdt-extensions/peritext/slice/Slices.ts | Uses new iterator/hash imports |
| packages/json-joy/src/json-crdt-extensions/peritext/slice/Slice.ts | Uses @jsonjoy.com/json-hash |
| packages/json-joy/src/json-crdt-extensions/peritext/rga/Range.ts | Uses @jsonjoy.com/json-hash |
| packages/json-joy/src/json-crdt-extensions/peritext/Peritext.ts | Uses @jsonjoy.com/json-hash |
| packages/json-joy/src/json-crdt-extensions/peritext/overlay/Overlay.ts | Uses new iterator/hash imports |
| packages/json-joy/src/json-crdt-extensions/peritext/overlay/tests/Overlay.markers.spec.ts | Repoints iterator import in tests |
| packages/json-joy/src/json-crdt-extensions/peritext/events/PeritextEventTarget.ts | Repoints TypedEventTarget import |
| packages/json-joy/src/json-crdt-extensions/peritext/events/clipboard/PeritextClipboardImpl.ts | Repoints saveSelection import |
| packages/json-joy/src/json-crdt-extensions/peritext/editor/types.ts | Repoints iterator types import |
| packages/json-joy/src/json-crdt-extensions/peritext/editor/Editor.ts | Uses thingies + iterator import |
| packages/json-joy/src/json-crdt-extensions/peritext/block/Inline.ts | Uses @jsonjoy.com/json-hash |
| packages/json-joy/src/json-crdt-extensions/peritext/block/Block.ts | Uses new iterator/hash imports |
| packages/json-joy/src/json-crdt-extensions/peritext/block/tests/Inline.key.spec.ts | Uses @jsonjoy.com/json-hash |
| packages/json-joy/src/json-crdt-extensions/peritext/annals/WebUndo.ts | Repoints saveSelection import |
| packages/json-joy/src/json-crdt-diff/structHashSchema.ts | Uses new structHash/hash paths |
| packages/json-joy/src/json-crdt-diff/structHashCrdt.ts | Uses new structHash/hash paths |
| packages/json-joy/src/json-crdt-diff/JsonCrdtDiff.ts | Uses new diff + structHash modules |
| packages/json-joy/src/json-crdt-diff/tests/structHashCrdt.spec.ts | Adds structHashCrdt tests |
| packages/json-joy/src/json-crdt-diff/tests/structHash-fuzzing.spec.ts | Adds fuzz coverage for hashes |
| packages/json-joy/src/json-crdt-diff/tests/structHash-automated.spec.ts | Adds fixture-driven hash tests |
| packages/json-joy/src/json-crdt-diff/tests/assertStructHash.ts | Repoints structHash import |
| packages/json-joy/package.json | Adds new workspace deps |
| packages/json-hash/tsconfig.json | Adds new package TS config |
| packages/json-hash/tsconfig.build.json | Adds new package build config |
| packages/json-hash/src/index.ts | Adds package entrypoint |
| packages/json-hash/src/hash.ts | Adds structural hash implementation |
| packages/json-hash/src/tests/hash.spec.ts | Adds hash unit tests |
| packages/json-hash/SECURITY.md | Adds security policy doc |
| packages/json-hash/README.md | Updates package name/imports |
| packages/json-hash/package.json | Adds new publishable package |
| packages/json-hash/LICENSE | Adds license file |
| packages/json-crdt-server/package.json | Makes package publishable + bin |
| packages/json-crdt-server/bin/json-crdt-server.js | Adds CLI entrypoint |
| packages/json-crdt-repo/src/session/EditSession.ts | Catches timer race errors |
| packages/json-crdt-repo/src/session/tests/EditSession.delrace.spec.ts | Adds regression test for race |
| packages/diff/tsconfig.json | Adds new package TS config |
| packages/diff/tsconfig.build.json | Adds new package build config |
| packages/diff/src/str.ts | Adds string diff implementation |
| packages/diff/src/line.ts | Adds line diff built on str |
| packages/diff/src/index.ts | Adds package entrypoint exports |
| packages/diff/src/bin.ts | Adds binary diff helpers |
| packages/diff/src/tests/util.ts | Adds shared diff test helpers |
| packages/diff/src/tests/str.spec.ts | Adds extensive str diff tests |
| packages/diff/src/tests/str-fuzz.spec.ts | Adds fuzz testing for str diff |
| packages/diff/src/tests/line.ts | Adds shared line test helper |
| packages/diff/src/tests/line.spec.ts | Adds line diff test suite |
| packages/diff/src/tests/line-fuzzer.spec.ts | Adds fuzzing for line diff |
| packages/diff/src/tests/bin.spec.ts | Adds binary diff test suite |
| packages/diff/src/tests/bin-fuzz.spec.ts | Adds fuzzing for binary diff |
| packages/diff/SECURITY.md | Adds security policy doc |
| packages/diff/README.md | Adds package README + usage |
| packages/diff/package.json | Adds new publishable package |
| packages/diff/LICENSE | Adds license file |
| packages/collaborative-str/tsconfig.json | Adds diff project reference |
| packages/collaborative-str/tsconfig.build.json | Adds diff build reference |
| packages/collaborative-str/src/StrBinding.ts | Uses new diff implementation |
| packages/collaborative-str/package.json | Adds @jsonjoy.com/diff dep |
| packages/collaborative-slate/tsconfig.json | Adds diff project reference |
| packages/collaborative-slate/tsconfig.build.json | Adds diff build reference |
| packages/collaborative-slate/src/sync/applyPatch.ts | Uses new diff implementation |
| packages/collaborative-slate/package.json | Adds @jsonjoy.com/diff dep |
| packages/collaborative-react/src/hooks.ts | Switches SyncStore type import |
| packages/collaborative-react/package.json | Adds thingies dependency |
| packages/collaborative-input/docs/text.md | Updates install/import docs |
| packages/click-json/src/ClickableJsonCrdt/nodes/JsonCrdtStrNode/StrEdit.tsx | Uses scoped collaborative-input pkg |
Review details
- Files reviewed: 87/109 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.