Repository navigation
Conversation
A page can carry properties: a tree keyed by path, where each node holds a value, a set of items, both, or only what is under it. This adds the bottom layer of #84, all in @pbnotes/pages: five events, the fold over them, and the reads. Nothing writes these events yet and nothing shows them; the builders and commands are #133. properties.ts holds the events (page.property.set, .unset, .item.added, .item.removed and .removed, each at v: 1), the fold and the reads. The fold parses a payload into edits to single paths, or skips the event whole if it is malformed, then applies the edits. removed is several of the edits the single events make, applied in one go: it clears a seen value only if it is still the one seen, and the items it lists, so what another device wrote that the remover never saw survives. The fold trims path segments and puts every string in NFC; scalars are strings, finite numbers, booleans and null, and keep their type. No timestamps are kept. Pages gains properties beside blocks and titles, and pagesFold runs the block fold, then the property fold. block.created built its result from blocks and titles alone, which would have dropped properties; it now spreads the state. HANDLES is the block table plus the property table; the block half is BLOCK_HANDLES inside the package. getPages lists a day that has properties and no blocks. A property event spells its page's title the way block.created does. Closes #132. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Closes #132. Part of #84.
What changed
Page properties (
packages/pages/properties.ts, new): the bottom layer of #84. Nothing writes these events yet and nothing shows them; the builders and commands are #133.NAMESPACEatv: 1:page.property.set,.unset,.item.added,.item.removedand.removed. Payload types with doc comments on what each field means.parseturns a payload into edits to single paths, or skips the event whole if it is malformed (ledger: ignore what the format doesn't name, instead of refusing or reporting it #104).applymakes the edits. An entry left with nothing is deleted, then a page left with no entries.removedis several of the edits the single events make, applied in one go. It clears a seen value only if it is still the one seen, and the items it lists. What another device wrote that the remover never saw survives, in either fold order.null, and keep their type.-0is0.{ type, v, payload }like the block fold, and keeps noat.get,getValue,getItems,list,children, and thepath/showPathhelpers. Sorted by path segment, by codepoint. Every result is a snapshot.The pages fold (
pages.ts,blocks.ts):Pagesgainspropertiesbesideblocksandtitles.pagesFoldruns the block fold, then the property fold. Each hands back the state it was given for an event that is not its own.HANDLESis the block table plus the property table. The block half isBLOCK_HANDLESinside the package; the publicHANDLESkeeps its name.getPageslists a journal day that has properties and no blocks.block.createddoes;spellis exported within the package for that.README.md: a "Page properties" section with the five events, the rules, and the reads.For the reviewer
block.createdbuilt its result fromblocksandtitlesalone, which would have droppedproperties. It now spreads the state.NaNwould be skipped live but written to disk asnull, a value, and show after a reopen. The fold can't tell; Page properties: builders and commands #133's commands refuse non-finite numbers for that reason.get,listandchildrenare top-level package exports, as Page properties #84 names them. Happy to rename to something property-specific next togetPageif preferred.Tests
properties.test.ts(20 tests, new), folding throughpagesFold:unsetleaves items alone anditem.removedleaves the value alonelistandchildrendon't show themv;__proto__as a title, a segment or an item is an ordinary key1,"1",trueandnullare four items; trimmed segments;""is a valueremoved: what it lists is cleared, what it doesn't list survives in either fold order,nulland an absentvaluelistandchildrenon nested paths, the root, a scope that holds something itself,["foo"]beside["foobar"], codepoint orderblocks.test.tsbuildsPageswithpropertiesand checksBLOCK_HANDLES.npm test --workspaces(233 pass),npm run lint -w appandnpx tsc --noEmit -p appare clean.🤖 Generated with Claude Code