edytor 5.0.0 → 7.0.0
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 +3 -3
- package/dist/cloudflare/DocumentRoom.d.ts +77 -2
- package/dist/cloudflare/DocumentRoom.js +37 -1
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.js +1 -1
- package/dist/cloudflare/room/access.d.ts +6 -1
- package/dist/cloudflare/room/access.js +30 -4
- package/dist/cloudflare/room/admission.d.ts +11 -0
- package/dist/cloudflare/room/admission.js +43 -10
- package/dist/cloudflare/room/context.d.ts +73 -76
- package/dist/cloudflare/room/context.js +17 -6
- package/dist/cloudflare/room/forged.d.ts +1 -1
- package/dist/cloudflare/room/forged.js +11 -9
- package/dist/cloudflare/room/frames.d.ts +2 -0
- package/dist/cloudflare/room/frames.js +2 -0
- package/dist/cloudflare/room/presence.js +1 -4
- package/dist/cloudflare/room/reseed.d.ts +93 -0
- package/dist/cloudflare/room/reseed.js +500 -0
- package/dist/cloudflare/room/scheduler.d.ts +1 -1
- package/dist/cloudflare/room/scheduler.js +9 -1
- package/dist/cloudflare/room/shared.d.ts +10 -0
- package/dist/cloudflare/room/shared.js +10 -0
- package/dist/cloudflare/room/storage.d.ts +7 -0
- package/dist/cloudflare/room/storage.js +33 -1
- package/dist/components/Edytor.svelte +18 -3
- package/dist/components/Edytor.svelte.d.ts +10 -1
- package/dist/components/EdytorRoot.svelte +17 -0
- package/dist/components/EdytorRoot.svelte.d.ts +4 -0
- package/dist/components/Suggestion.svelte +1 -1
- package/dist/crdt/attribution/block.d.ts +3 -0
- package/dist/crdt/attribution/block.js +3 -2
- package/dist/crdt/doc/history.js +2 -3
- package/dist/crdt/doc/ops.d.ts +81 -0
- package/dist/crdt/doc/ops.js +1898 -0
- package/dist/crdt/doc/suggest.d.ts +6 -2
- package/dist/crdt/doc/suggest.js +6 -5
- package/dist/crdt/edytor-doc.d.ts +157 -157
- package/dist/crdt/edytor-doc.js +15 -43
- package/dist/crdt/engine-room.d.ts +4 -0
- package/dist/crdt/engine-room.js +6 -0
- package/dist/crdt/flow.d.ts +4 -46
- package/dist/crdt/flow.js +2 -262
- package/dist/crdt/index.d.ts +64 -75
- package/dist/crdt/operations.d.ts +1 -1
- package/dist/crdt/placement/resolve.d.ts +1 -1
- package/dist/crdt/protocol.d.ts +2 -2
- package/dist/crdt/protocol.js +2 -2
- package/dist/crdt/protocols/auth.d.ts +8 -1
- package/dist/crdt/protocols/auth.js +14 -1
- package/dist/crdt/protocols/awareness.js +46 -81
- package/dist/crdt/providers/index.d.ts +11 -22
- package/dist/crdt/providers/index.js +22 -3
- package/dist/crdt/providers/indexeddb.d.ts +6 -10
- package/dist/crdt/providers/indexeddb.js +10 -16
- package/dist/crdt/providers/room.d.ts +26 -0
- package/dist/crdt/providers/room.js +41 -12
- package/dist/crdt/providers/websocket.d.ts +10 -14
- package/dist/crdt/providers/websocket.js +43 -23
- package/dist/crdt/rangeDelete.d.ts +2 -47
- package/dist/crdt/rangeDelete.js +1 -169
- package/dist/crdt/reseed.d.ts +127 -0
- package/dist/crdt/reseed.js +533 -0
- package/dist/crdt/restore.d.ts +13 -1
- package/dist/crdt/restore.js +8 -3
- package/dist/crdt/schema.d.ts +6 -0
- package/dist/crdt/schema.js +6 -0
- package/dist/crdt/structs.d.ts +8 -11
- package/dist/crdt/structs.js +25 -44
- package/dist/crdt/text/index/build.d.ts +119 -0
- package/dist/crdt/text/index/build.js +2801 -0
- package/dist/crdt/text/index/shared.d.ts +2 -6
- package/dist/crdt/text/index/shared.js +2 -5
- package/dist/crdt/text/model.js +2 -3
- package/dist/crdt/text/runs.d.ts +9 -12
- package/dist/crdt/text/runs.js +2 -165
- package/dist/crdt/vendor/yjs/UPSTREAM.md +101 -5
- package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
- package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +10 -10
- package/dist/crdt/vendor/yjs/dts/utils/encoding.d.ts +1 -0
- package/dist/crdt/vendor/yjs/src/index.js +1 -1
- package/dist/crdt/vendor/yjs/src/structs/Item.js +24 -13
- package/dist/crdt/vendor/yjs/src/utils/Transaction.js +12 -10
- package/dist/crdt/vendor/yjs/src/utils/encoding.js +42 -1
- package/dist/events/domTextOffset.d.ts +2 -0
- package/dist/events/domTextOffset.js +8 -0
- package/dist/export/forms.d.ts +50 -50
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/richtext/RichTextPlugin.svelte +63 -61
- package/dist/plugins/richtext/richTextOperations.js +26 -32
- package/dist/selection/selection.svelte.d.ts +1 -1
- package/dist/selection/selection.svelte.js +87 -106
- package/dist/selection/selection.utils.js +5 -8
- package/dist/session/commands.js +49 -51
- package/dist/session/handles.js +3 -7
- package/dist/surface/attributes.d.ts +3 -3
- package/dist/surface/attributes.js +2 -2
- package/dist/surface/observer.svelte.d.ts +7 -7
- package/dist/surface/observer.svelte.js +225 -336
- package/dist/surface/projector.svelte.js +2 -2
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +7 -0
- package/package.json +1 -1
- package/dist/crdt/doc/capability.d.ts +0 -56
- package/dist/crdt/doc/capability.js +0 -207
- package/dist/crdt/doc/content.d.ts +0 -16
- package/dist/crdt/doc/content.js +0 -77
- package/dist/crdt/doc/delete.d.ts +0 -15
- package/dist/crdt/doc/delete.js +0 -84
- package/dist/crdt/doc/layout.d.ts +0 -9
- package/dist/crdt/doc/layout.js +0 -178
- package/dist/crdt/doc/meta.d.ts +0 -19
- package/dist/crdt/doc/meta.js +0 -198
- package/dist/crdt/doc/moves.d.ts +0 -21
- package/dist/crdt/doc/moves.js +0 -274
- package/dist/crdt/doc/split-merge.d.ts +0 -10
- package/dist/crdt/doc/split-merge.js +0 -179
- package/dist/crdt/doc/steps.d.ts +0 -65
- package/dist/crdt/doc/steps.js +0 -311
- package/dist/crdt/text/index/cache.d.ts +0 -16
- package/dist/crdt/text/index/cache.js +0 -175
- package/dist/crdt/text/index/claims.d.ts +0 -18
- package/dist/crdt/text/index/claims.js +0 -203
- package/dist/crdt/text/index/fold.d.ts +0 -21
- package/dist/crdt/text/index/fold.js +0 -656
- package/dist/crdt/text/index/layout.d.ts +0 -22
- package/dist/crdt/text/index/layout.js +0 -258
- package/dist/crdt/text/index/placement.d.ts +0 -47
- package/dist/crdt/text/index/placement.js +0 -738
- package/dist/crdt/text/index/records.d.ts +0 -13
- package/dist/crdt/text/index/records.js +0 -139
- package/dist/crdt/text/index/report.d.ts +0 -18
- package/dist/crdt/text/index/report.js +0 -337
- package/dist/crdt/text/index/state.d.ts +0 -197
- package/dist/crdt/text/index/state.js +0 -116
- package/dist/crdt/text/index/streams.d.ts +0 -25
- package/dist/crdt/text/index/streams.js +0 -248
package/dist/crdt/restore.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export type Unit = {
|
|
|
35
35
|
};
|
|
36
36
|
/** `items` one unit each (a character with its marks, or an atom), keyed for comparison. */
|
|
37
37
|
export declare const unitsOf: (items: readonly ContentItem[]) => Unit[];
|
|
38
|
+
/** Units back to runs: consecutive characters with the same marks joined. */
|
|
39
|
+
export declare const runsOf: (units: readonly Unit[]) => ContentItem[];
|
|
38
40
|
/** The one changed stretch from `x` to `y`: `x[p, e)` became `mid`. */
|
|
39
41
|
export declare const hunk: (x: readonly Unit[], y: readonly Unit[]) => {
|
|
40
42
|
p: number;
|
|
@@ -76,9 +78,19 @@ export type RestoreFacade<Plan> = Partial<SuggestFacade> & {
|
|
|
76
78
|
patchData(target: null, ops: DataPatch[]): Plan;
|
|
77
79
|
};
|
|
78
80
|
};
|
|
81
|
+
/** How a restore writes content, and whether it rejects the pending suggestions. */
|
|
82
|
+
export type RestoreOptions<Plan> = {
|
|
83
|
+
/**
|
|
84
|
+
* The content rewrite of a block that differs (default `rewriteContent`).
|
|
85
|
+
* Another one edits through the display, so the block keeps its claims.
|
|
86
|
+
*/
|
|
87
|
+
rewrite?: (facade: RestoreFacade<Plan>, id: BlockId, have: readonly Unit[], want: readonly Unit[]) => boolean;
|
|
88
|
+
/** `keep`: the pending suggestions stay (a re-seed's rebase writes as one more writer). */
|
|
89
|
+
suggestions?: 'reject' | 'keep';
|
|
90
|
+
};
|
|
79
91
|
/**
|
|
80
92
|
* Make the visible document `doc` (through `facade`, the facade over it)
|
|
81
93
|
* equal `json`. Runs inside the caller's transaction; the writer is
|
|
82
94
|
* `doc.clientID`. See the module comment for what it writes.
|
|
83
95
|
*/
|
|
84
|
-
export declare const restoreDocument: <Plan>(doc: EngineDoc, facade: RestoreFacade<Plan>, json: JSONDoc) => RestoreReport;
|
|
96
|
+
export declare const restoreDocument: <Plan>(doc: EngineDoc, facade: RestoreFacade<Plan>, json: JSONDoc, { rewrite, suggestions }?: RestoreOptions<Plan>) => RestoreReport;
|
package/dist/crdt/restore.js
CHANGED
|
@@ -24,7 +24,7 @@ export const unitsOf = (items) => {
|
|
|
24
24
|
return out;
|
|
25
25
|
};
|
|
26
26
|
/** Units back to runs: consecutive characters with the same marks joined. */
|
|
27
|
-
const runsOf = (units) => {
|
|
27
|
+
export const runsOf = (units) => {
|
|
28
28
|
const out = [];
|
|
29
29
|
let tag = null;
|
|
30
30
|
for (const { key, item } of units) {
|
|
@@ -98,7 +98,7 @@ const walk = (specs, parent, into) => {
|
|
|
98
98
|
* equal `json`. Runs inside the caller's transaction; the writer is
|
|
99
99
|
* `doc.clientID`. See the module comment for what it writes.
|
|
100
100
|
*/
|
|
101
|
-
export const restoreDocument = (doc, facade, json) => {
|
|
101
|
+
export const restoreDocument = (doc, facade, json, { rewrite, suggestions = 'reject' } = {}) => {
|
|
102
102
|
const report = { revived: 0, moved: 0, rewritten: 0, created: 0, deleted: 0 };
|
|
103
103
|
const specs = json.children.map((block) => toBlockSpec(block));
|
|
104
104
|
const all = walk(specs, null, new Map());
|
|
@@ -170,6 +170,11 @@ export const restoreDocument = (doc, facade, json) => {
|
|
|
170
170
|
if (have.length === want.length && have.every((u, i) => u.key === want[i].key))
|
|
171
171
|
continue;
|
|
172
172
|
const claims = modelView(doc).blocks.get(id)?.claims ?? [];
|
|
173
|
+
if (rewrite) {
|
|
174
|
+
rewrite(facade, id, have, want);
|
|
175
|
+
report.rewritten++;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
173
178
|
if (claims.some((c) => c.stamp.c >= 0)) {
|
|
174
179
|
deleteClaims(doc, claims);
|
|
175
180
|
have = unitsOf(facade.contentItems(id));
|
|
@@ -202,7 +207,7 @@ export const restoreDocument = (doc, facade, json) => {
|
|
|
202
207
|
// their proposals — is rejected, in the restore's step (its undo brings
|
|
203
208
|
// them back).
|
|
204
209
|
// (Built over the facade, its shared suggestions: `doc/suggest.ts`.)
|
|
205
|
-
const suggest = facade.part && suggestionsOf(facade);
|
|
210
|
+
const suggest = suggestions === 'reject' && facade.part && suggestionsOf(facade);
|
|
206
211
|
if (suggest)
|
|
207
212
|
suggest.run(suggest.decide(suggest.changes(), false));
|
|
208
213
|
return report;
|
package/dist/crdt/schema.d.ts
CHANGED
|
@@ -98,6 +98,12 @@ export declare const hasWithdrawMark: (node: {
|
|
|
98
98
|
/** The per-block `lastChangedBy` LWW attr (`SCHEMA.blockAttrs.lastChanged`). */
|
|
99
99
|
export declare const LAST_CHANGED_ATTR = "l";
|
|
100
100
|
export declare const CONTENT = "content";
|
|
101
|
+
/**
|
|
102
|
+
* The epoch a re-seed wrote (`room.reseed.protocol`): the root `epoch`, its
|
|
103
|
+
* attr `n` (none before the first re-seed). Apart from `meta`, whose keys
|
|
104
|
+
* are the schema stamp's alone.
|
|
105
|
+
*/
|
|
106
|
+
export declare const EPOCH_ROOT = "epoch";
|
|
101
107
|
/** The schema generation stamped on the `meta` root (`v`) and its manifest name (`schema`). */
|
|
102
108
|
export declare const SCHEMA: {
|
|
103
109
|
readonly version: 11;
|
package/dist/crdt/schema.js
CHANGED
|
@@ -87,6 +87,12 @@ export const hasWithdrawMark = (node) => [...node.attrKeys()].some((key) => key.
|
|
|
87
87
|
/** The per-block `lastChangedBy` LWW attr (`SCHEMA.blockAttrs.lastChanged`). */
|
|
88
88
|
export const LAST_CHANGED_ATTR = 'l';
|
|
89
89
|
export const CONTENT = 'content';
|
|
90
|
+
/**
|
|
91
|
+
* The epoch a re-seed wrote (`room.reseed.protocol`): the root `epoch`, its
|
|
92
|
+
* attr `n` (none before the first re-seed). Apart from `meta`, whose keys
|
|
93
|
+
* are the schema stamp's alone.
|
|
94
|
+
*/
|
|
95
|
+
export const EPOCH_ROOT = 'epoch';
|
|
90
96
|
/** The schema generation stamped on the `meta` root (`v`) and its manifest name (`schema`). */
|
|
91
97
|
export const SCHEMA = {
|
|
92
98
|
// 7: a text delete is a hold record (fork patch YP20) on the wire and in
|
package/dist/crdt/structs.d.ts
CHANGED
|
@@ -64,17 +64,14 @@ export declare const clientsOf: (doc: EngineDoc) => Map<number, StoreStruct[]>;
|
|
|
64
64
|
*/
|
|
65
65
|
export declare const structAt: (Y: EngineApi, structs: readonly StoreStruct[], clock: number) => StoreStruct | null;
|
|
66
66
|
/**
|
|
67
|
-
* Walk every struct
|
|
68
|
-
* from, to)` gets the struct and the clock range `[from,
|
|
69
|
-
* covers (a struct can reach past
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* partial walk. `clientsOf` throws first when the store itself is absent.
|
|
76
|
-
*/
|
|
77
|
-
export declare const walkIdSet: (Y: EngineApi, doc: EngineDoc, idSet: IdSetLike, fn: (struct: StoreStruct, from: number, to: number) => boolean | void) => boolean;
|
|
67
|
+
* Walk every struct the range `client:clock`, `len` units, covers, in clock
|
|
68
|
+
* order: `fn(struct, from, to)` gets the struct and the clock range `[from,
|
|
69
|
+
* to)` of it the range covers (a struct can reach past it). The walk never
|
|
70
|
+
* splits a struct; a client or a clock the store lacks walks nothing.
|
|
71
|
+
*/
|
|
72
|
+
export declare const walkRange: (Y: EngineApi, doc: EngineDoc, client: number, clock: number, len: number, fn: (struct: StoreStruct, from: number, to: number) => void) => void;
|
|
73
|
+
/** Walk every struct an IdSet covers, in (client, clock) order (`walkRange` over each range). */
|
|
74
|
+
export declare const walkIdSet: (Y: EngineApi, doc: EngineDoc, idSet: IdSetLike, fn: (struct: StoreStruct, from: number, to: number) => void) => void;
|
|
78
75
|
/**
|
|
79
76
|
* The id the local `redone` chain leads `id` to: the copy an undo or redo
|
|
80
77
|
* on THIS replica re-created of a deleted item (redo copies chain), or `id`
|
package/dist/crdt/structs.js
CHANGED
|
@@ -50,51 +50,32 @@ export const structAt = (Y, structs, clock) => {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
|
-
* Walk every struct
|
|
54
|
-
* from, to)` gets the struct and the clock range `[from,
|
|
55
|
-
* covers (a struct can reach past
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
for (const r of ranges.getIds()) {
|
|
76
|
-
const end = r.clock + r.len;
|
|
77
|
-
let i;
|
|
78
|
-
try {
|
|
79
|
-
i = Y.findIndexSS(structs, r.clock);
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
complete = false;
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
for (; i < structs.length; i++) {
|
|
86
|
-
const s = structs[i];
|
|
87
|
-
if (s.id.clock >= end)
|
|
88
|
-
break;
|
|
89
|
-
if (fn(s, Math.max(r.clock, s.id.clock), Math.min(end, s.id.clock + s.length)) === false) {
|
|
90
|
-
stopped = true;
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
return complete;
|
|
53
|
+
* Walk every struct the range `client:clock`, `len` units, covers, in clock
|
|
54
|
+
* order: `fn(struct, from, to)` gets the struct and the clock range `[from,
|
|
55
|
+
* to)` of it the range covers (a struct can reach past it). The walk never
|
|
56
|
+
* splits a struct; a client or a clock the store lacks walks nothing.
|
|
57
|
+
*/
|
|
58
|
+
export const walkRange = (Y, doc, client, clock, len, fn) => {
|
|
59
|
+
const structs = clientsOf(doc).get(client) ?? [];
|
|
60
|
+
const end = clock + len;
|
|
61
|
+
let i = structs.length;
|
|
62
|
+
try {
|
|
63
|
+
if (clock < end)
|
|
64
|
+
i = Y.findIndexSS(structs, clock);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// past the client's clock: nothing to walk
|
|
68
|
+
}
|
|
69
|
+
for (; i < structs.length && structs[i].id.clock < end; i++) {
|
|
70
|
+
const s = structs[i];
|
|
71
|
+
fn(s, Math.max(clock, s.id.clock), Math.min(end, s.id.clock + s.length));
|
|
72
|
+
}
|
|
97
73
|
};
|
|
74
|
+
/** Walk every struct an IdSet covers, in (client, clock) order (`walkRange` over each range). */
|
|
75
|
+
export const walkIdSet = (Y, doc, idSet, fn) => idSet.clients.forEach((ranges, client) => {
|
|
76
|
+
for (const r of ranges.getIds())
|
|
77
|
+
walkRange(Y, doc, client, r.clock, r.len, fn);
|
|
78
|
+
});
|
|
98
79
|
/**
|
|
99
80
|
* The id the local `redone` chain leads `id` to: the copy an undo or redo
|
|
100
81
|
* on THIS replica re-created of a deleted item (redo copies chain), or `id`
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-document index (`indexOf`) as ONE closure: its state, then its
|
|
3
|
+
* parts — the claim graph, the stream table and each block's claims, the
|
|
4
|
+
* layout and table rules, placements and the children index (with THE
|
|
5
|
+
* shown-kind rule, `typeOf`), block records, the run cache, the fold and the
|
|
6
|
+
* change report — each reading the state and the parts before it as closure
|
|
7
|
+
* variables, then the view (`RunView`) over them. `../runs.ts` declares the
|
|
8
|
+
* index's types and contracts. The self-checks (`indexChecks`) read the
|
|
9
|
+
* maintained facts through {@link IndexFacts} and rebuild their own.
|
|
10
|
+
*/
|
|
11
|
+
import type { EngineDoc, EngineNode, EngineTransaction } from '../../engine-api.js';
|
|
12
|
+
import { type BlockId, type BlockRec, type ChildSlot, type DisplayOwnership, type ResolvedPlacement } from '../../placement/model.js';
|
|
13
|
+
import { type LiveRow, type RowItem } from '../rows.js';
|
|
14
|
+
import type { ContentRun, RunView } from '../runs.js';
|
|
15
|
+
import { type Cached } from './shared.js';
|
|
16
|
+
import { type Claim, type Owner, type Stream } from '../model.js';
|
|
17
|
+
import { type Edge, type SlotRef } from '../../placement/resolve.js';
|
|
18
|
+
export type TextEdit = {
|
|
19
|
+
item: RowItem;
|
|
20
|
+
n: number;
|
|
21
|
+
};
|
|
22
|
+
export type TextEdits = {
|
|
23
|
+
edits: TextEdit[];
|
|
24
|
+
scan: boolean;
|
|
25
|
+
opaque: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** One fold's effects: invalidated blocks, rescanned texts, rebuilt facets. */
|
|
28
|
+
export type FoldCtx = {
|
|
29
|
+
invalidated: Set<BlockId>;
|
|
30
|
+
/** Per home block: its text's edits, whether it rescans, whether every reader re-reads. */
|
|
31
|
+
texts: Map<BlockId, {
|
|
32
|
+
edits: TextEdit[];
|
|
33
|
+
scan: boolean;
|
|
34
|
+
opaque: boolean;
|
|
35
|
+
seen: Set<TextEdits>;
|
|
36
|
+
}>;
|
|
37
|
+
/** The blocks whose entry or nonce changed: their delimiters are re-decided. */
|
|
38
|
+
named: Set<BlockId>;
|
|
39
|
+
table: boolean;
|
|
40
|
+
/** The winning parents, before and after, of the blocks the fold touched. */
|
|
41
|
+
parents: Set<BlockId>;
|
|
42
|
+
};
|
|
43
|
+
/** A slot in a children index: its display parent, rank and the island it displays out of. */
|
|
44
|
+
export type Slot = {
|
|
45
|
+
parent: BlockId | null;
|
|
46
|
+
rank: string;
|
|
47
|
+
reset?: BlockId;
|
|
48
|
+
};
|
|
49
|
+
/** Each row's segments at its last placement: segment 0's block, then each cut's key and block. */
|
|
50
|
+
export type Placed = {
|
|
51
|
+
head: BlockId | null;
|
|
52
|
+
keys: string[];
|
|
53
|
+
blocks: (BlockId | null)[];
|
|
54
|
+
};
|
|
55
|
+
/** The tree the change report last published. */
|
|
56
|
+
export type Published = {
|
|
57
|
+
nodes: Map<BlockId, {
|
|
58
|
+
parent: BlockId | null;
|
|
59
|
+
index: number;
|
|
60
|
+
type: string;
|
|
61
|
+
data: unknown;
|
|
62
|
+
runs: readonly ContentRun[];
|
|
63
|
+
key?: string;
|
|
64
|
+
}>;
|
|
65
|
+
order: Map<BlockId | null, readonly BlockId[]>;
|
|
66
|
+
/** The children index version it was taken at. */
|
|
67
|
+
kids: number;
|
|
68
|
+
};
|
|
69
|
+
/** A transaction as the fold reads it. */
|
|
70
|
+
export type Tx = {
|
|
71
|
+
changed?: EngineTransaction['changed'];
|
|
72
|
+
/** What the transaction did to items, in order: per item `kind, client, clock, len` (fork patch YP33). */
|
|
73
|
+
log?: number[];
|
|
74
|
+
};
|
|
75
|
+
/** The index's self-checks (`indexChecks`), run after each fold and each report. */
|
|
76
|
+
export type SelfChecks = {
|
|
77
|
+
check: () => void;
|
|
78
|
+
checkPublished: (pub: Published) => void;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* What the self-checks read of one index: the facts it maintains
|
|
82
|
+
* incrementally (compared with their rebuild from the replicated state) and
|
|
83
|
+
* the reads they compare through.
|
|
84
|
+
*/
|
|
85
|
+
export type IndexFacts = {
|
|
86
|
+
doc: EngineDoc;
|
|
87
|
+
registry: EngineNode;
|
|
88
|
+
blocks: ReadonlyMap<BlockId, BlockRec>;
|
|
89
|
+
displaysMap: ReadonlyMap<BlockId, ReadonlySet<BlockId>>;
|
|
90
|
+
rows: ReadonlyMap<BlockId, LiveRow>;
|
|
91
|
+
streamIx: ReadonlyMap<BlockId, unknown>;
|
|
92
|
+
delim: ReadonlyMap<BlockId, string>;
|
|
93
|
+
placementsMap: ReadonlyMap<BlockId, ResolvedPlacement>;
|
|
94
|
+
slotsByBlock: ReadonlyMap<BlockId, SlotRef[]>;
|
|
95
|
+
edges: ReadonlyMap<BlockId, Edge | null>;
|
|
96
|
+
rejected: ReadonlySet<BlockId>;
|
|
97
|
+
kids0: Map<BlockId | null, ChildSlot[]>;
|
|
98
|
+
kidsMap: Map<BlockId | null, ChildSlot[]>;
|
|
99
|
+
slots: ReadonlyMap<BlockId, Slot>;
|
|
100
|
+
dissolved: ReadonlySet<BlockId>;
|
|
101
|
+
following: ReadonlySet<BlockId>;
|
|
102
|
+
cache: ReadonlyMap<BlockId, Cached>;
|
|
103
|
+
dirty: ReadonlySet<BlockId>;
|
|
104
|
+
ownShim: DisplayOwnership;
|
|
105
|
+
own0: DisplayOwnership;
|
|
106
|
+
ownerOf: (b: BlockId) => Owner;
|
|
107
|
+
streamOf: (b: BlockId) => Stream | undefined;
|
|
108
|
+
sameClaims: (x: readonly Claim[], y: readonly Claim[]) => boolean;
|
|
109
|
+
dissolve: (kids: Map<BlockId | null, ChildSlot[]>) => Set<BlockId>;
|
|
110
|
+
noteFollowing: (id: BlockId) => void;
|
|
111
|
+
ensurePlacements: () => void;
|
|
112
|
+
computeFresh: (b: BlockId) => {
|
|
113
|
+
fresh: readonly ContentRun[];
|
|
114
|
+
};
|
|
115
|
+
unfolded: () => boolean;
|
|
116
|
+
reachable: (prev?: Published['nodes']) => Published;
|
|
117
|
+
};
|
|
118
|
+
/** The doc's index — built on first use, torn down when the doc is destroyed. */
|
|
119
|
+
export declare const indexOf: (doc: EngineDoc) => RunView;
|