@loro-dev/roost 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -11
- package/dist/lody-history.d.ts +65 -0
- package/dist/lody-history.js +425 -55
- package/dist/sync/history.d.ts +16 -51
- package/dist/sync/history.js +96 -172
- package/dist/sync/index.d.ts +1 -1
- package/dist/sync/mod.d.ts +1 -1
- package/dist/sync/transport.d.ts +1 -4
- package/dist/sync/transport.js +15 -25
- package/node/client.d.mts +8 -2
- package/node/client.mjs +23 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -12,13 +12,14 @@ The `Inbox` module adds atomic raw receipt/cursor storage, without authenticatin
|
|
|
12
12
|
or applying those bytes.
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
|
-
npm install @loro-dev/roost@0.3.
|
|
15
|
+
npm install @loro-dev/roost@0.3.2
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
The TypeScript SDK uses Streams client 0.16.0 for framed RR backward pages.
|
|
19
|
+
`StreamsTransport.readBackward` returns frames in stream order with opaque
|
|
20
|
+
start cursors and continuation flags. `HistoryReader` reassembles complete
|
|
21
|
+
messages within the requested byte budget and resumes existing prefix scans at
|
|
22
|
+
their persisted cursors. Registry availability follows the npm release.
|
|
22
23
|
|
|
23
24
|
For source development and browser tests:
|
|
24
25
|
|
|
@@ -285,10 +286,11 @@ intake commits, and initialize `Link.catchUpAt` from the original window tail,
|
|
|
285
286
|
never a later `head()` result. The Node window API is unchanged.
|
|
286
287
|
|
|
287
288
|
`pnpm pack:consumer -- /absolute/output/directory` builds the npm tarball and
|
|
288
|
-
checks its public entries.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
the root, `./sync`, and
|
|
289
|
+
checks its public entries. The package pins `@loro-dev/streams-client` to an
|
|
290
|
+
exact registry version in `package.json`. `pnpm check:consumer` installs the
|
|
291
|
+
tarball in a fresh project with a fresh npm cache, verifies the installed
|
|
292
|
+
Streams version against that pin, and checks the root, `./sync`, and
|
|
293
|
+
`./lody-history` exports.
|
|
292
294
|
|
|
293
295
|
IndexedDB container version is now 2. Opening a valid version-1 database upgrades
|
|
294
296
|
only its version, retaining all records; incompatible layouts abort the upgrade.
|
|
@@ -360,7 +362,9 @@ Already published incomplete Turns expose their applied prefix. Unsealed content
|
|
|
360
362
|
remains provisional; the projected `sealed` flag is not a verification level.
|
|
361
363
|
|
|
362
364
|
Node active-branch pages privately reuse sealed bodies after matching authoritative
|
|
363
|
-
headers, including sequence, seal and parent edges.
|
|
365
|
+
headers, including sequence, seal and parent edges. Initial Native page hydration
|
|
366
|
+
also reuses the same Turn's already-read header for immutable parents, avoiding a
|
|
367
|
+
second full Create export. The per-history cache keeps at
|
|
364
368
|
most 64 bodies and 8 MiB of source JSON UTF-16 bytes (an input budget, not exact
|
|
365
369
|
heap usage). Oversized and unsealed bodies are not retained. Returned bodies are
|
|
366
370
|
independent copies. Page membership, cursors, availability and event fences are
|
|
@@ -477,7 +481,7 @@ both browser and Node adapters: it atomically creates and seals a non-message
|
|
|
477
481
|
reconstruct the rollback, including an empty restored view, from that native
|
|
478
482
|
record. `branch_state` is readable as an internal history identity but is excluded
|
|
479
483
|
from `HistoryWriteIdentity`, `AcceptHistory` and batch commands; generic authoring
|
|
480
|
-
rejects it at runtime as well. Use
|
|
484
|
+
rejects it at runtime as well. Use the dedicated branch APIs for this reserved identity. It
|
|
481
485
|
does not edit sealed Turns or change the Rust state machine/wire.
|
|
482
486
|
|
|
483
487
|
Active-branch pages return `startPosition`, `totalCount`, `hasMoreOlder`, and an
|
|
@@ -548,3 +552,24 @@ Recorded example: 2026-09-17 results and measurement limits.
|
|
|
548
552
|
Host payload crypto may return a Promise (`AsyncPayloadCrypto`), including
|
|
549
553
|
WebCrypto. Encryption and decryption are awaited outside storage transactions;
|
|
550
554
|
failed transforms never fall back to plaintext. See RSE1.
|
|
555
|
+
|
|
556
|
+
### Selected membership and sparse branch changes (0.3.1)
|
|
557
|
+
|
|
558
|
+
`readActiveBranchMembers(viewId, options)` returns logical positions, member references and ancestry
|
|
559
|
+
cursors. `lookupMember(identity)` returns header information;
|
|
560
|
+
`readActiveBranchMessages(viewId, businessIds)` hydrates selected active bodies.
|
|
561
|
+
|
|
562
|
+
`NodeLodyHistory.replaceActiveBranchMembers` accepts an ordered list of logical segment references
|
|
563
|
+
and optional new messages. Each logical row has one primary. Existing physical Turns are reused;
|
|
564
|
+
a fresh `primary:<id>` physical segment can represent a reinserted business ID's logical `primary`.
|
|
565
|
+
A signed `branch_state` with v2 metadata holds the membership root, which subsequent appends reference.
|
|
566
|
+
New messages are sealed by default; `sealed: false` creates an unsealed replacement.
|
|
567
|
+
|
|
568
|
+
The manifest uses bounded private array appends. Its Create binds the intent digest, retries compare
|
|
569
|
+
the stored prefix, and the completed root is sealed. A small activation claim commits branch state
|
|
570
|
+
and operation/application receipts in one exclusive Native transaction. Operation-ID retries return
|
|
571
|
+
the original receipt. Incomplete membership is reported until referenced records arrive.
|
|
572
|
+
|
|
573
|
+
The SDK reads existing v1 branches in place and v2 membership views. V1 SDKs read v1 views. This API
|
|
574
|
+
requires matching `field-reads-v1` and `exclusive-batch-v1` Native capabilities; consumers update their
|
|
575
|
+
version pins after the paired SDK/Native release.
|
package/dist/lody-history.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export type HistoryBatchOptions = {
|
|
|
58
58
|
export type HistoryProjectedMessage = {
|
|
59
59
|
businessId: string;
|
|
60
60
|
segmentId: string;
|
|
61
|
+
physicalSegmentId?: string;
|
|
61
62
|
turnId: Uint8Array;
|
|
62
63
|
content: JsonValue;
|
|
63
64
|
nextSeq: bigint;
|
|
@@ -93,6 +94,7 @@ export type BranchViewState = {
|
|
|
93
94
|
head: HistoryIdentity | null;
|
|
94
95
|
operationId: string | null;
|
|
95
96
|
logicalCount?: bigint;
|
|
97
|
+
membershipBase?: HistoryIdentity;
|
|
96
98
|
conflict?: boolean;
|
|
97
99
|
};
|
|
98
100
|
export type BranchMutationResult = {
|
|
@@ -136,6 +138,10 @@ export type ActiveBranchPageRead = {
|
|
|
136
138
|
cursor: ActiveBranchPageCursor | null;
|
|
137
139
|
complete: boolean;
|
|
138
140
|
};
|
|
141
|
+
/** Read active member references and headers. */
|
|
142
|
+
export type ActiveBranchMembersRead = Omit<ActiveBranchPageRead, 'messages'> & {
|
|
143
|
+
members: ActiveBranchSegmentRef[];
|
|
144
|
+
};
|
|
139
145
|
export type ActiveBranchPageCursor = {
|
|
140
146
|
viewId: string;
|
|
141
147
|
turnId: Uint8Array;
|
|
@@ -154,6 +160,29 @@ export type ActiveBranchPageAdvance = Omit<ActiveBranchPageRead, 'messages'> & {
|
|
|
154
160
|
message: HistoryProjectedMessage;
|
|
155
161
|
through: bigint;
|
|
156
162
|
};
|
|
163
|
+
export type ActiveBranchMemberIdentity = {
|
|
164
|
+
identity: HistoryIdentity;
|
|
165
|
+
segmentId: string;
|
|
166
|
+
};
|
|
167
|
+
export type ReplaceActiveBranchMembersInput = {
|
|
168
|
+
viewId: string;
|
|
169
|
+
expectedRevision: bigint;
|
|
170
|
+
expectedHead: HistoryIdentity | null;
|
|
171
|
+
operationId: string;
|
|
172
|
+
members: ActiveBranchMemberIdentity[];
|
|
173
|
+
messages?: {
|
|
174
|
+
identity: HistoryWriteIdentity;
|
|
175
|
+
content: JsonValue;
|
|
176
|
+
parents?: ParentRef[];
|
|
177
|
+
attachments?: AcceptHistory['attachments'];
|
|
178
|
+
sealed?: boolean;
|
|
179
|
+
}[];
|
|
180
|
+
supersedes?: HistoryIdentity[];
|
|
181
|
+
receipts?: Extract<HistoryBatchCommand, {
|
|
182
|
+
type: 'accept';
|
|
183
|
+
}>[];
|
|
184
|
+
expectedEventCursor: bigint;
|
|
185
|
+
};
|
|
157
186
|
export type RestoreActiveBranchInput = {
|
|
158
187
|
viewId: string;
|
|
159
188
|
expectedRevision: bigint;
|
|
@@ -316,6 +345,7 @@ export type NodeHistoryIndexPut = NodeIndexKey & {
|
|
|
316
345
|
emitEvent?: boolean;
|
|
317
346
|
};
|
|
318
347
|
export type NodeHistoryBatchOptions = {
|
|
348
|
+
requireLocalInterval?: boolean;
|
|
319
349
|
indexPuts?: NodeHistoryIndexPut[];
|
|
320
350
|
expectedEventCursor?: bigint;
|
|
321
351
|
expectedIndexes?: NodeIndexEntry[];
|
|
@@ -355,6 +385,21 @@ export interface LodyNodeHost {
|
|
|
355
385
|
key?: Uint8Array;
|
|
356
386
|
};
|
|
357
387
|
}[]>;
|
|
388
|
+
readonly fieldReads?: boolean;
|
|
389
|
+
readonly exclusiveBatches?: boolean;
|
|
390
|
+
readCreateFields?(id: Uint8Array, selectors: {
|
|
391
|
+
path: NodeHistoryPath;
|
|
392
|
+
}[], omitDigestKeys: string[]): Promise<{
|
|
393
|
+
fields: ({
|
|
394
|
+
state: 'missing';
|
|
395
|
+
} | {
|
|
396
|
+
state: 'ready';
|
|
397
|
+
contentJson: string;
|
|
398
|
+
})[];
|
|
399
|
+
owner: Uint8Array;
|
|
400
|
+
digest: Uint8Array;
|
|
401
|
+
filteredDigest: Uint8Array;
|
|
402
|
+
}>;
|
|
358
403
|
exportUpdates(id: Uint8Array, from: bigint, limit: bigint): Promise<Uint8Array>;
|
|
359
404
|
createOnce(key: Uint8Array, parents: ParentRef[], contentJson: string, options?: {
|
|
360
405
|
expectedEventCursor?: bigint;
|
|
@@ -495,6 +540,20 @@ export declare class NodeLodyHistory {
|
|
|
495
540
|
latest?: boolean;
|
|
496
541
|
limit?: number;
|
|
497
542
|
}): Promise<ActiveBranchPageRead>;
|
|
543
|
+
readActiveBranchMembers(viewId: string, input?: {
|
|
544
|
+
before?: ActiveBranchPageCursor;
|
|
545
|
+
from?: number;
|
|
546
|
+
latest?: boolean;
|
|
547
|
+
limit?: number;
|
|
548
|
+
}): Promise<ActiveBranchMembersRead>;
|
|
549
|
+
/** Resolve an identity to its Turn header. */
|
|
550
|
+
lookupMember(identity: HistoryIdentity): Promise<{
|
|
551
|
+
turnId: Uint8Array;
|
|
552
|
+
nextSeq: bigint;
|
|
553
|
+
sealed: boolean;
|
|
554
|
+
} | undefined>;
|
|
555
|
+
replaceActiveBranchMembers(input: ReplaceActiveBranchMembersInput): Promise<RestoreActiveBranchResult>;
|
|
556
|
+
readActiveBranchMessages(viewId: string, businessIds: readonly string[]): Promise<HistoryProjectedMessage[]>;
|
|
498
557
|
advanceActiveBranchDirectory(page: ActiveBranchPageRead, result: BranchMutationResult, limit?: number): ActiveBranchPageAdvance | undefined;
|
|
499
558
|
respondPermission(input: {
|
|
500
559
|
requestId: string;
|
|
@@ -536,6 +595,12 @@ export declare class NodeLodyHistory {
|
|
|
536
595
|
}>;
|
|
537
596
|
}
|
|
538
597
|
type HistoryHost = LodyHistory | NodeLodyHistory;
|
|
598
|
+
type ActiveBranchSegmentRef = {
|
|
599
|
+
businessId: string;
|
|
600
|
+
segmentId: string;
|
|
601
|
+
turnId: Uint8Array;
|
|
602
|
+
physicalSegmentId?: string;
|
|
603
|
+
};
|
|
539
604
|
export type HistoryMessageViewUpdate = {
|
|
540
605
|
/** Treat rows and their nested content as read-only. Unchanged rows retain identity. */
|
|
541
606
|
messages: readonly HistoryProjectedMessage[];
|