edytor 4.0.0 → 6.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 +2 -2
- package/dist/block/block.svelte.js +6 -21
- package/dist/block/inlineBlock.svelte.js +4 -6
- package/dist/clipboard/moveText.js +6 -8
- package/dist/cloudflare/DocumentRoom.d.ts +10 -3
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/room/access.d.ts +8 -3
- package/dist/cloudflare/room/access.js +44 -20
- package/dist/cloudflare/room/admission.js +28 -5
- package/dist/cloudflare/room/comments.js +28 -1
- package/dist/cloudflare/room/context.d.ts +106 -109
- package/dist/cloudflare/room/context.js +10 -3
- package/dist/cloudflare/room/forged.d.ts +14 -0
- package/dist/cloudflare/room/forged.js +30 -2
- package/dist/cloudflare/room/frames.d.ts +4 -0
- package/dist/cloudflare/room/frames.js +5 -1
- package/dist/cloudflare/room/purge.js +2 -1
- package/dist/cloudflare/room/replicas.d.ts +4 -2
- package/dist/cloudflare/room/replicas.js +8 -3
- package/dist/cloudflare/room/suggest.d.ts +7 -0
- package/dist/cloudflare/room/suggest.js +143 -0
- package/dist/cloudflare/routeDocumentSocket.d.ts +10 -1
- package/dist/cloudflare/routeDocumentSocket.js +5 -3
- package/dist/components/Content.svelte +9 -1
- package/dist/crdt/anchors.js +3 -2
- package/dist/crdt/attribution/attribution.d.ts +3 -0
- package/dist/crdt/attribution/attribution.js +3 -3
- package/dist/crdt/doc/funnel.d.ts +1 -1
- package/dist/crdt/doc/funnel.js +5 -2
- package/dist/crdt/doc/gate.d.ts +1 -1
- package/dist/crdt/doc/history.d.ts +6 -0
- package/dist/crdt/doc/history.js +79 -59
- package/dist/crdt/doc/ops.d.ts +81 -0
- package/dist/crdt/doc/ops.js +1898 -0
- package/dist/crdt/doc/reads.d.ts +2 -2
- package/dist/crdt/doc/reads.js +18 -28
- package/dist/crdt/doc/suggest.d.ts +167 -0
- package/dist/crdt/doc/suggest.js +579 -0
- package/dist/crdt/document.d.ts +10 -1
- package/dist/crdt/document.js +19 -11
- package/dist/crdt/edytor-doc.d.ts +294 -272
- package/dist/crdt/edytor-doc.js +123 -108
- package/dist/crdt/engine-api.d.ts +8 -2
- package/dist/crdt/engine.d.ts +2 -1
- package/dist/crdt/engine.js +3 -1
- package/dist/crdt/flow.d.ts +5 -47
- package/dist/crdt/flow.js +3 -269
- package/dist/crdt/index.d.ts +102 -108
- package/dist/crdt/index.js +3 -0
- package/dist/crdt/operations.d.ts +13 -4
- package/dist/crdt/parts.d.ts +43 -0
- package/dist/crdt/parts.js +44 -0
- package/dist/crdt/placement/display.d.ts +1 -1
- package/dist/crdt/placement/display.js +3 -3
- package/dist/crdt/placement/keys.d.ts +5 -0
- package/dist/crdt/placement/keys.js +5 -0
- package/dist/crdt/placement/resolve.d.ts +1 -1
- package/dist/crdt/placement/resolve.js +2 -1
- package/dist/crdt/protocol.d.ts +1 -1
- package/dist/crdt/protocol.js +1 -1
- package/dist/crdt/protocols/auth.d.ts +11 -1
- package/dist/crdt/protocols/auth.js +17 -1
- package/dist/crdt/protocols/awareness.js +46 -81
- package/dist/crdt/protocols/comments.d.ts +16 -1
- package/dist/crdt/protocols/comments.js +9 -1
- package/dist/crdt/providers/index.d.ts +12 -22
- package/dist/crdt/providers/index.js +3 -1
- package/dist/crdt/providers/indexeddb.d.ts +6 -10
- package/dist/crdt/providers/indexeddb.js +10 -16
- package/dist/crdt/providers/room.d.ts +11 -0
- package/dist/crdt/providers/room.js +26 -12
- package/dist/crdt/providers/websocket.d.ts +8 -12
- package/dist/crdt/providers/websocket.js +17 -19
- package/dist/crdt/purge.d.ts +7 -1
- package/dist/crdt/purge.js +32 -2
- package/dist/crdt/rangeDelete.d.ts +2 -47
- package/dist/crdt/rangeDelete.js +1 -169
- package/dist/crdt/restore.d.ts +2 -1
- package/dist/crdt/restore.js +9 -0
- package/dist/crdt/schema.d.ts +9 -1
- package/dist/crdt/schema.js +13 -3
- package/dist/crdt/structs.d.ts +2 -0
- package/dist/crdt/structs.js +2 -0
- package/dist/crdt/text/index/build.d.ts +125 -0
- package/dist/crdt/text/index/build.js +2895 -0
- package/dist/crdt/text/index/shared.d.ts +2 -6
- package/dist/crdt/text/index/shared.js +19 -19
- package/dist/crdt/text/model.d.ts +10 -0
- package/dist/crdt/text/model.js +10 -4
- package/dist/crdt/text/runs.d.ts +43 -42
- package/dist/crdt/text/runs.js +2 -165
- package/dist/crdt/vendor/yjs/UPSTREAM.md +83 -0
- package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
- package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +6 -3
- package/dist/crdt/vendor/yjs/dts/ynode.d.ts +13 -2
- package/dist/crdt/vendor/yjs/src/index.js +1 -1
- package/dist/crdt/vendor/yjs/src/structs/Item.js +44 -5
- package/dist/crdt/vendor/yjs/src/ynode.js +29 -7
- package/dist/edytor.svelte.d.ts +1 -1
- package/dist/edytor.svelte.js +100 -75
- package/dist/events/beforeInputCommands.d.ts +2 -2
- package/dist/events/domTextOffset.d.ts +2 -0
- package/dist/events/domTextOffset.js +8 -0
- package/dist/events/nativeInteractiveControl.d.ts +11 -1
- package/dist/events/nativeInteractiveControl.js +41 -1
- package/dist/events/onBeforeInput.js +3 -3
- package/dist/events/onFocus.js +9 -11
- package/dist/export/forms.d.ts +75 -75
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/labels.d.ts +8 -0
- package/dist/labels.js +6 -1
- package/dist/plugins/comments/CommentsController.svelte.d.ts +5 -1
- package/dist/plugins/comments/CommentsController.svelte.js +14 -4
- package/dist/plugins/find/search.js +2 -2
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/richtext/RichTextPlugin.svelte +63 -61
- package/dist/plugins/richtext/richTextOperations.js +26 -32
- package/dist/plugins/suggestions/SuggestionBars.svelte +40 -23
- package/dist/plugins/suggestions/SuggestionBars.svelte.d.ts +3 -1
- package/dist/plugins/suggestions/SuggestionRuns.svelte +77 -0
- package/dist/plugins/suggestions/SuggestionRuns.svelte.d.ts +9 -0
- package/dist/plugins/suggestions/shared.svelte.d.ts +58 -0
- package/dist/plugins/suggestions/shared.svelte.js +421 -0
- package/dist/plugins/suggestions/suggestionsPlugin.d.ts +15 -4
- package/dist/selection/domSelection.d.ts +2 -0
- package/dist/selection/domSelection.js +6 -2
- package/dist/selection/pointer.svelte.js +75 -48
- package/dist/selection/replaceSelection.js +2 -6
- package/dist/selection/selection.svelte.d.ts +3 -3
- package/dist/selection/selection.svelte.js +39 -32
- package/dist/selection/selection.utils.d.ts +14 -0
- package/dist/selection/selection.utils.js +33 -11
- package/dist/session/commands.js +21 -11
- package/dist/session/composition.svelte.d.ts +5 -3
- package/dist/session/composition.svelte.js +21 -17
- package/dist/session/handles.d.ts +4 -17
- package/dist/session/handles.js +14 -44
- package/dist/session/navigation.js +6 -9
- package/dist/session/selection.d.ts +11 -5
- package/dist/session/selection.js +14 -48
- package/dist/session/suggestions.svelte.d.ts +38 -9
- package/dist/session/suggestions.svelte.js +37 -18
- package/dist/session/virtual.d.ts +1 -1
- package/dist/surface/attributes.d.ts +5 -0
- package/dist/surface/attributes.js +2 -2
- package/dist/surface/cells.d.ts +2 -26
- package/dist/surface/cells.js +2 -33
- package/dist/surface/observer.svelte.d.ts +6 -1
- package/dist/surface/observer.svelte.js +143 -111
- package/dist/surface/pin.svelte.d.ts +9 -9
- package/dist/surface/pin.svelte.js +15 -22
- package/dist/surface/projector.svelte.js +10 -16
- package/dist/text/text.svelte.js +14 -19
- package/dist/themes/notion.css +29 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +7 -0
- package/package.json +3 -1
- package/dist/crdt/doc/capability.d.ts +0 -56
- package/dist/crdt/doc/capability.js +0 -211
- 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 -199
- 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 -225
- 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 -24
- package/dist/crdt/text/index/layout.js +0 -271
- package/dist/crdt/text/index/placement.d.ts +0 -47
- package/dist/crdt/text/index/placement.js +0 -741
- 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
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { cellKey, LAST_CELL, unlistedCellKey } from '../../placement/keys.js';
|
|
2
|
-
import { listedColumns, unlistedRank } from '../../tables.js';
|
|
3
|
-
/** The layout rules of one doc's index, over its state. */
|
|
4
|
-
export const indexLayout = (ix) => {
|
|
5
|
-
const { blocks, kindsOf } = ix;
|
|
6
|
-
/** `ask` of `b`'s stored kind; `undefined` without roles or a record. */
|
|
7
|
-
const role = (b, ask) => {
|
|
8
|
-
const type = blocks.get(b)?.type;
|
|
9
|
-
return ix.roles === null || type === undefined ? undefined : ask(ix.roles, type);
|
|
10
|
-
};
|
|
11
|
-
/** The line kind of `b` when it is an island declared `lines`. */
|
|
12
|
-
const lineKind = (b) => role(b, (r, type) => r.line(type));
|
|
13
|
-
/** The item kind of `b` when it is a layout. */
|
|
14
|
-
const itemKind = (b) => role(b, (r, type) => r.layout(type));
|
|
15
|
-
/** The item kinds the roles declare. */
|
|
16
|
-
const declaredItems = () => {
|
|
17
|
-
const items = new Set();
|
|
18
|
-
for (const type of ix.roles?.layoutKinds() ?? [])
|
|
19
|
-
items.add(ix.roles.layout(type));
|
|
20
|
-
return items;
|
|
21
|
-
};
|
|
22
|
-
/** The row kind of `b` when it is a table (`table.*`). */
|
|
23
|
-
const rowKind = (b) => role(b, (r, type) => r.table(type));
|
|
24
|
-
/** `table`'s row kind and that row kind's cell kind, as `[row, cell]`. */
|
|
25
|
-
const rowOfTable = (table) => {
|
|
26
|
-
const row = ix.roles?.table(table);
|
|
27
|
-
return row === undefined ? undefined : [row, ix.roles.defaultChild(row)];
|
|
28
|
-
};
|
|
29
|
-
/** The row kinds (with their cell kinds) the roles declare. */
|
|
30
|
-
const declaredRows = () => new Map([...(ix.roles?.tableKinds() ?? [])]
|
|
31
|
-
.flatMap((type) => rowOfTable(type) ?? [])
|
|
32
|
-
.map(([row, cell]) => [row, cell]));
|
|
33
|
-
/** The cell kind of `b` when it is a row of a table kind. */
|
|
34
|
-
const cellKind = (b) => ix.rowKinds.get(blocks.get(b)?.type ?? '');
|
|
35
|
-
/**
|
|
36
|
-
* The column ids of table `table` in their order, each with its
|
|
37
|
-
* position (`data.columns[i].id`), or `null` when it is no table or
|
|
38
|
-
* holds no `columns` array: its cells then show in their own order.
|
|
39
|
-
* Read from the record's data, memoized per data object.
|
|
40
|
-
*/
|
|
41
|
-
const columnsMemo = new WeakMap();
|
|
42
|
-
const columnsOf = (table) => {
|
|
43
|
-
if (rowKind(table) === undefined)
|
|
44
|
-
return null;
|
|
45
|
-
const data = blocks.get(table)?.data;
|
|
46
|
-
if (data === null || typeof data !== 'object')
|
|
47
|
-
return null;
|
|
48
|
-
let index = columnsMemo.get(data);
|
|
49
|
-
if (index === undefined) {
|
|
50
|
-
const ids = listedColumns(data);
|
|
51
|
-
columnsMemo.set(data, (index = ids && new Map(ids.map((id, i) => [id, i]))));
|
|
52
|
-
}
|
|
53
|
-
return index;
|
|
54
|
-
};
|
|
55
|
-
/** The column a cell names (`data.column`), if any. */
|
|
56
|
-
const columnOf = (cell) => {
|
|
57
|
-
const c = blocks.get(cell)?.data?.column;
|
|
58
|
-
return typeof c === 'string' ? c : undefined;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* What of `b`'s data the table rules read, as one key: a table's column
|
|
62
|
-
* ids, a cell's column (`''` for any other block). A change of it
|
|
63
|
-
* re-places the table's cells.
|
|
64
|
-
*/
|
|
65
|
-
const tableFacts = (b, data) => {
|
|
66
|
-
const k = kindsOf.get(b);
|
|
67
|
-
if (data === null || typeof data !== 'object')
|
|
68
|
-
return '';
|
|
69
|
-
if (k?.table)
|
|
70
|
-
return JSON.stringify(listedColumns(data));
|
|
71
|
-
if (k?.cell) {
|
|
72
|
-
const c = data.column;
|
|
73
|
-
return typeof c === 'string' ? c : '';
|
|
74
|
-
}
|
|
75
|
-
return '';
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* The rank cell `id` displays at in row `row` (`table.columns`): its
|
|
79
|
-
* column's position in the table holding the row, so every row shows its
|
|
80
|
-
* cells in the table's column order whatever their placements (a key of
|
|
81
|
-
* the position, ties by block id); a withdrawn cell of a
|
|
82
|
-
* column the table no longer lists after them, its column's place among
|
|
83
|
-
* those fixed by its id (`unlistedRank`); any other cell of no listed
|
|
84
|
-
* column last (it does not display, `table.cell`).
|
|
85
|
-
* `undefined`: no table with columns holds the row — its placement rank.
|
|
86
|
-
*/
|
|
87
|
-
const cellRank = (row, id) => {
|
|
88
|
-
const cell = cellKind(row);
|
|
89
|
-
if (cell === undefined || blocks.get(id)?.type !== cell)
|
|
90
|
-
return undefined;
|
|
91
|
-
const table = ix.placementsMap.get(row)?.parent;
|
|
92
|
-
const index = typeof table === 'string' ? columnsOf(table) : null;
|
|
93
|
-
if (index === null)
|
|
94
|
-
return undefined;
|
|
95
|
-
const column = columnOf(id);
|
|
96
|
-
const at = column === undefined ? undefined : index.get(column);
|
|
97
|
-
if (at === undefined && column !== undefined && ix.shells.has(id))
|
|
98
|
-
return unlistedCellKey(unlistedRank(column));
|
|
99
|
-
return at === undefined ? LAST_CELL : cellKey(at);
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* The table rules (`table.*`), in the same pass: a cell displays only in
|
|
103
|
-
* a row of a table, and, when the table lists its columns, only for a
|
|
104
|
-
* listed column — or, withdrawn by an undo while it holds another
|
|
105
|
-
* writer's text (`hist.undo.withdraw`), for the column the undo took out
|
|
106
|
-
* of the list — and as the first of the row's cells for it
|
|
107
|
-
* (`table.cell`); a row displays only in a table and while it shows a
|
|
108
|
-
* cell (`table.row`); a table displays while it shows a row
|
|
109
|
-
* (`table.empty`). What does not display hands up nothing a table rule
|
|
110
|
-
* shows: a cell's text goes with it.
|
|
111
|
-
*/
|
|
112
|
-
const tableVisit = (kids, out, id, ctx, shown) => {
|
|
113
|
-
const k = kindsOf.get(id);
|
|
114
|
-
const childIds = (kids.get(id) ?? []).map((c) => c.id);
|
|
115
|
-
const pass = (sub) => {
|
|
116
|
-
out.add(id);
|
|
117
|
-
shown.push(...sub.filter((x) => !isTableish(x.id)));
|
|
118
|
-
};
|
|
119
|
-
if (k.table) {
|
|
120
|
-
const sub = dissolveVisit(kids, out, childIds, false, { table: id });
|
|
121
|
-
if (sub.some((x) => kindsOf.get(x.id)?.row))
|
|
122
|
-
shown.push({ id, kids: sub.map((x) => x.id) });
|
|
123
|
-
else
|
|
124
|
-
pass(sub);
|
|
125
|
-
}
|
|
126
|
-
else if (k.row) {
|
|
127
|
-
const table = ctx !== null && 'table' in ctx ? ctx.table : null;
|
|
128
|
-
const sub = dissolveVisit(kids, out, childIds, false, table === null ? null : { row: id, columns: columnsOf(table), seen: new Set() });
|
|
129
|
-
if (table !== null && sub.some((x) => kindsOf.get(x.id)?.cell))
|
|
130
|
-
shown.push({ id, kids: sub.map((x) => x.id) });
|
|
131
|
-
else
|
|
132
|
-
pass(sub);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
const sub = dissolveVisit(kids, out, childIds, false, null);
|
|
136
|
-
const row = ctx !== null && 'row' in ctx ? ctx : null;
|
|
137
|
-
let shows = row !== null;
|
|
138
|
-
if (row !== null && row.columns !== null) {
|
|
139
|
-
const column = columnOf(id);
|
|
140
|
-
shows =
|
|
141
|
-
column !== undefined &&
|
|
142
|
-
(row.columns.has(column) || ix.shells.has(id)) &&
|
|
143
|
-
!row.seen.has(column);
|
|
144
|
-
if (shows)
|
|
145
|
-
row.seen.add(column);
|
|
146
|
-
}
|
|
147
|
-
if (shows)
|
|
148
|
-
shown.push({ id, kids: sub.map((x) => x.id) });
|
|
149
|
-
else
|
|
150
|
-
pass(sub);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
/** `b`'s kind is a table, a table's row or a row's cell. */
|
|
154
|
-
const isTableish = (b) => {
|
|
155
|
-
const k = kindsOf.get(b);
|
|
156
|
-
return k !== undefined && (k.table || k.row || k.cell);
|
|
157
|
-
};
|
|
158
|
-
const dissolveVisit = (kids, out, ids, layout, ctx = null) => {
|
|
159
|
-
const isItem = (b) => ix.itemKinds.has(blocks.get(b)?.type ?? '');
|
|
160
|
-
const shown = [];
|
|
161
|
-
for (const id of ids) {
|
|
162
|
-
if (isTableish(id)) {
|
|
163
|
-
tableVisit(kids, out, id, ctx, shown);
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
const own = itemKind(id) !== undefined;
|
|
167
|
-
const sub = dissolveVisit(kids, out, (kids.get(id) ?? []).map((k) => k.id), own);
|
|
168
|
-
if (own) {
|
|
169
|
-
if (sub.length > 1)
|
|
170
|
-
shown.push({ id, kids: [] });
|
|
171
|
-
else {
|
|
172
|
-
out.add(id);
|
|
173
|
-
for (const k of sub) {
|
|
174
|
-
out.add(k.id);
|
|
175
|
-
shown.push(...k.kids.map((kid) => ({ id: kid, kids: [] })));
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
else if (isItem(id) && (!layout || sub.length === 0)) {
|
|
180
|
-
out.add(id);
|
|
181
|
-
shown.push(...sub);
|
|
182
|
-
}
|
|
183
|
-
else
|
|
184
|
-
shown.push({ id, kids: sub.map((k) => k.id) });
|
|
185
|
-
}
|
|
186
|
-
return shown;
|
|
187
|
-
};
|
|
188
|
-
const dissolve = (kids) => {
|
|
189
|
-
const out = new Set();
|
|
190
|
-
dissolveVisit(kids, out, (kids.get(null) ?? []).map((k) => k.id), false);
|
|
191
|
-
return out;
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* Re-run the layout rules on the layouts `changed` (blocks whose slot
|
|
195
|
-
* in `kids0` changed, with their parents) and `kinds` reach: from each
|
|
196
|
-
* one up through layouts and items, the topmost such ancestor's
|
|
197
|
-
* subtree. Returns the blocks whose dissolved state flipped.
|
|
198
|
-
*/
|
|
199
|
-
const redissolve = (changed, kinds) => {
|
|
200
|
-
const flips = new Set();
|
|
201
|
-
const isLayoutish = (b) => {
|
|
202
|
-
const k = kindsOf.get(b);
|
|
203
|
-
return k !== undefined && (k.layout || k.item || k.table || k.row || k.cell);
|
|
204
|
-
};
|
|
205
|
-
const roots = new Set();
|
|
206
|
-
const climb = (b) => {
|
|
207
|
-
let top;
|
|
208
|
-
for (let x = b; typeof x === 'string' && isLayoutish(x); x = ix.slots0.get(x)?.parent)
|
|
209
|
-
top = x;
|
|
210
|
-
if (top !== undefined)
|
|
211
|
-
roots.add(top);
|
|
212
|
-
};
|
|
213
|
-
for (const [id, [from, to]] of changed) {
|
|
214
|
-
climb(id);
|
|
215
|
-
climb(from);
|
|
216
|
-
climb(to);
|
|
217
|
-
}
|
|
218
|
-
for (const id of kinds) {
|
|
219
|
-
// Its kind decides its own rule, its parent's count and its children's (`layout`).
|
|
220
|
-
climb(id);
|
|
221
|
-
climb(ix.slots0.get(id)?.parent);
|
|
222
|
-
for (const k of ix.kids0.get(id) ?? [])
|
|
223
|
-
climb(k.id);
|
|
224
|
-
// Only a layout, an item or a table's block dissolves: one that left those kinds shows again.
|
|
225
|
-
if (!isLayoutish(id) && ix.dissolved.delete(id))
|
|
226
|
-
flips.add(id);
|
|
227
|
-
}
|
|
228
|
-
for (const root of roots) {
|
|
229
|
-
if (!ix.slots0.has(root))
|
|
230
|
-
continue;
|
|
231
|
-
const parent = ix.slots0.get(root).parent;
|
|
232
|
-
const nodes = [];
|
|
233
|
-
const stack = [root];
|
|
234
|
-
for (let x = stack.pop(); x !== undefined; x = stack.pop()) {
|
|
235
|
-
nodes.push(x);
|
|
236
|
-
for (const k of ix.kids0.get(x) ?? [])
|
|
237
|
-
stack.push(k.id);
|
|
238
|
-
}
|
|
239
|
-
const out = new Set();
|
|
240
|
-
dissolveVisit(ix.kids0, out, [root], parent !== null && itemKind(parent) !== undefined);
|
|
241
|
-
for (const x of nodes) {
|
|
242
|
-
if (out.has(x) === ix.dissolved.has(x))
|
|
243
|
-
continue;
|
|
244
|
-
if (out.has(x))
|
|
245
|
-
ix.dissolved.add(x);
|
|
246
|
-
else
|
|
247
|
-
ix.dissolved.delete(x);
|
|
248
|
-
flips.add(x);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
// A block that left the index (hidden, removed) dissolves no more.
|
|
252
|
-
for (const id of changed.keys())
|
|
253
|
-
if (!ix.slots0.has(id) && ix.dissolved.delete(id))
|
|
254
|
-
flips.add(id);
|
|
255
|
-
return flips;
|
|
256
|
-
};
|
|
257
|
-
return {
|
|
258
|
-
role,
|
|
259
|
-
lineKind,
|
|
260
|
-
itemKind,
|
|
261
|
-
rowKind,
|
|
262
|
-
rowOfTable,
|
|
263
|
-
declaredRows,
|
|
264
|
-
cellKind,
|
|
265
|
-
cellRank,
|
|
266
|
-
tableFacts,
|
|
267
|
-
declaredItems,
|
|
268
|
-
dissolve,
|
|
269
|
-
redissolve
|
|
270
|
-
};
|
|
271
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Placements and the children index (maintained), the display
|
|
3
|
-
* ownership the display reads (`ownShim`), and THE shown-kind rule
|
|
4
|
-
* (`typeOf`).
|
|
5
|
-
*
|
|
6
|
-
* A structural change re-decides only what it can change: the display
|
|
7
|
-
* edge of the blocks whose slot, record or mover changed (fork patch
|
|
8
|
-
* YP22), and the display slot of every block whose slot walk
|
|
9
|
-
* (`displaySlotOf`) reads one that changed — its stored subtree, through
|
|
10
|
-
* the blocks it displays — patched into the parents' child lists. A
|
|
11
|
-
* block's candidate edges are its live move records, strongest first, then
|
|
12
|
-
* its home slot; it shows at the first that closes no cycle through the
|
|
13
|
-
* accepted edges (`settle`): the later move wins, and the block whose edge
|
|
14
|
-
* is the oldest of a cycle falls back to its next candidate, back where it
|
|
15
|
-
* stood (its previous record, else home; the root's tail only when every
|
|
16
|
-
* candidate closes a cycle), so a cycle resolves locally: no global pass.
|
|
17
|
-
* The first build places every block the same way (their unique acyclic
|
|
18
|
-
* acceptance, whatever the order; the tests' greedy rebuild,
|
|
19
|
-
* `src/tests/oracles/placements.ts`, is what the self-checks compare). A
|
|
20
|
-
* placed block's order key is found from its sequence neighbours
|
|
21
|
-
* (`placement/keys.ts`), never by walking the parent's sequence; a rebuild
|
|
22
|
-
* keys every list once, in its sequence's order. The layout rules re-run
|
|
23
|
-
* only on the layouts a change reaches.
|
|
24
|
-
*/
|
|
25
|
-
import { type BlockId, type DisplayOwnership, type DocOrder } from '../../placement/model.js';
|
|
26
|
-
import { homeOf, type SlotRef } from '../../placement/resolve.js';
|
|
27
|
-
import { type Unit } from '../../placement/slots.js';
|
|
28
|
-
import type { EngineNode } from '../../engine-api.js';
|
|
29
|
-
import type { IndexClaims } from './claims.js';
|
|
30
|
-
import type { IndexLayout } from './layout.js';
|
|
31
|
-
import type { IndexState } from './state.js';
|
|
32
|
-
import type { IndexStreams } from './streams.js';
|
|
33
|
-
/** Placement maintenance of one doc's index, over its state, claims, streams and layout rules. */
|
|
34
|
-
export declare const indexPlacement: (ix: IndexState & IndexClaims & IndexStreams & IndexLayout) => {
|
|
35
|
-
ownShim: DisplayOwnership;
|
|
36
|
-
own0: DisplayOwnership;
|
|
37
|
-
noteKind: (id: BlockId) => void;
|
|
38
|
-
homeFor: (id: BlockId) => ReturnType<typeof homeOf>;
|
|
39
|
-
putSlot: (b: BlockId, u: Unit, ref: SlotRef | null) => void;
|
|
40
|
-
edgeParent: (id: BlockId) => BlockId | null | undefined;
|
|
41
|
-
noteFollowing: (id: BlockId) => void;
|
|
42
|
-
ensurePlacements: () => void;
|
|
43
|
-
reslot: (node: EngineNode) => void;
|
|
44
|
-
typeOf: (id: BlockId) => string;
|
|
45
|
-
order: () => DocOrder;
|
|
46
|
-
};
|
|
47
|
-
export type IndexPlacement = ReturnType<typeof indexPlacement>;
|