edytor 2.0.0 → 4.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 +19 -4
- package/dist/block/block.svelte.js +2 -4
- package/dist/clipboard/htmlFlow.d.ts +20 -7
- package/dist/clipboard/htmlFlow.js +23 -15
- package/dist/clipboard/serializeClipboardFragment.d.ts +37 -4
- package/dist/clipboard/serializeClipboardFragment.js +6 -4
- package/dist/clipboard/textBlocks.d.ts +8 -0
- package/dist/clipboard/textBlocks.js +6 -2
- package/dist/cloudflare/DocumentRoom.d.ts +13 -9
- package/dist/cloudflare/DocumentRoom.js +10 -6
- package/dist/cloudflare/room/admission.js +3 -3
- package/dist/cloudflare/room/context.d.ts +28 -27
- package/dist/cloudflare/room/context.js +2 -2
- package/dist/cloudflare/room/purge.d.ts +6 -3
- package/dist/cloudflare/room/purge.js +44 -19
- package/dist/cloudflare/room/updates.d.ts +3 -4
- package/dist/cloudflare/room/updates.js +6 -8
- package/dist/cloudflare/routeDocumentSocket.d.ts +17 -0
- package/dist/cloudflare/routeDocumentSocket.js +53 -0
- package/dist/collaboration/comments/client.d.ts +1 -1
- package/dist/collaboration/comments/client.js +1 -1
- package/dist/collaboration/remoteSelection.js +3 -3
- package/dist/components/Edytor.svelte +2 -10
- package/dist/components/Edytor.svelte.d.ts +1 -3
- package/dist/crdt/admission.d.ts +5 -10
- package/dist/crdt/admission.js +5 -11
- package/dist/crdt/attribution/attribution.d.ts +31 -12
- package/dist/crdt/attribution/attribution.js +56 -18
- package/dist/crdt/attribution/block.d.ts +3 -3
- package/dist/crdt/attribution/block.js +7 -8
- package/dist/crdt/attribution/index.d.ts +1 -1
- package/dist/crdt/attribution/index.js +1 -1
- package/dist/crdt/data.d.ts +62 -31
- package/dist/crdt/data.js +211 -103
- package/dist/crdt/doc/delete.d.ts +1 -1
- package/dist/crdt/doc/delete.js +13 -30
- package/dist/crdt/doc/funnel.d.ts +7 -6
- package/dist/crdt/doc/funnel.js +39 -33
- package/dist/crdt/doc/gate.d.ts +3 -20
- package/dist/crdt/doc/gate.js +2 -41
- package/dist/crdt/doc/history.d.ts +25 -9
- package/dist/crdt/doc/history.js +152 -42
- package/dist/crdt/doc/layout.js +11 -22
- package/dist/crdt/doc/meta.js +12 -17
- package/dist/crdt/doc/moves.d.ts +1 -1
- package/dist/crdt/doc/moves.js +52 -32
- package/dist/crdt/doc/reads.js +2 -2
- package/dist/crdt/doc/seed.js +2 -2
- package/dist/crdt/doc/split-merge.js +12 -15
- package/dist/crdt/doc/steps.d.ts +25 -13
- package/dist/crdt/doc/steps.js +52 -122
- package/dist/crdt/doc/types.d.ts +21 -9
- package/dist/crdt/document.d.ts +21 -19
- package/dist/crdt/document.js +26 -23
- package/dist/crdt/edytor-doc.d.ts +66 -68
- package/dist/crdt/edytor-doc.js +21 -20
- package/dist/crdt/engine-api.d.ts +33 -1
- package/dist/crdt/engine.d.ts +0 -1
- package/dist/crdt/engine.js +1 -4
- package/dist/crdt/flow.d.ts +1 -1
- package/dist/crdt/flow.js +25 -27
- package/dist/crdt/index.d.ts +29 -28
- package/dist/crdt/index.js +3 -3
- package/dist/crdt/placement/display.d.ts +5 -30
- package/dist/crdt/placement/display.js +39 -144
- package/dist/crdt/placement/keys.d.ts +58 -0
- package/dist/crdt/placement/keys.js +90 -0
- package/dist/crdt/placement/model.d.ts +119 -118
- package/dist/crdt/placement/model.js +242 -142
- package/dist/crdt/placement/resolve.d.ts +123 -35
- package/dist/crdt/placement/resolve.js +187 -153
- package/dist/crdt/placement/slots.d.ts +134 -0
- package/dist/crdt/placement/slots.js +152 -0
- package/dist/crdt/protocol.d.ts +2 -2
- package/dist/crdt/protocol.js +2 -2
- package/dist/crdt/providers/index.d.ts +1 -1
- package/dist/crdt/providers/room.d.ts +26 -11
- package/dist/crdt/providers/room.js +77 -27
- package/dist/crdt/providers/websocket.d.ts +1 -1
- package/dist/crdt/providers/websocket.js +33 -32
- package/dist/crdt/purge.d.ts +17 -8
- package/dist/crdt/purge.js +236 -126
- package/dist/crdt/restore.d.ts +2 -2
- package/dist/crdt/restore.js +18 -34
- package/dist/crdt/schema.d.ts +22 -21
- package/dist/crdt/schema.js +29 -23
- package/dist/crdt/semantics.js +3 -1
- package/dist/crdt/storage.d.ts +1 -1
- package/dist/crdt/storage.js +1 -1
- package/dist/crdt/structs.d.ts +15 -15
- package/dist/crdt/structs.js +8 -22
- package/dist/crdt/text/index/cache.js +4 -0
- package/dist/crdt/text/index/claims.js +12 -0
- package/dist/crdt/text/index/fold.d.ts +2 -3
- package/dist/crdt/text/index/fold.js +194 -44
- package/dist/crdt/text/index/layout.js +5 -8
- package/dist/crdt/text/index/placement.d.ts +26 -18
- package/dist/crdt/text/index/placement.js +404 -138
- package/dist/crdt/text/index/records.d.ts +3 -3
- package/dist/crdt/text/index/records.js +24 -31
- package/dist/crdt/text/index/shared.d.ts +11 -3
- package/dist/crdt/text/index/shared.js +12 -3
- package/dist/crdt/text/index/state.d.ts +21 -17
- package/dist/crdt/text/index/state.js +15 -17
- package/dist/crdt/text/index/streams.d.ts +10 -5
- package/dist/crdt/text/index/streams.js +78 -27
- package/dist/crdt/text/items.d.ts +10 -3
- package/dist/crdt/text/items.js +7 -0
- package/dist/crdt/text/model.d.ts +77 -62
- package/dist/crdt/text/model.js +84 -169
- package/dist/crdt/text/ranges.d.ts +1 -1
- package/dist/crdt/text/ranges.js +3 -3
- package/dist/crdt/text/rows.d.ts +13 -7
- package/dist/crdt/text/rows.js +24 -7
- package/dist/crdt/text/runs.d.ts +17 -12
- package/dist/crdt/text/runs.js +24 -7
- package/dist/crdt/text/streams.d.ts +26 -13
- package/dist/crdt/text/streams.js +41 -14
- package/dist/crdt/vendor/yjs/UPSTREAM.md +568 -21
- package/dist/crdt/vendor/yjs/dts/global.d.ts +2 -0
- package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
- package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +7 -0
- package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +194 -10
- package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +6 -3
- package/dist/crdt/vendor/yjs/dts/utils/StructStore.d.ts +5 -18
- package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +15 -1
- package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +14 -6
- package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +33 -6
- package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +1 -65
- package/dist/crdt/vendor/yjs/dts/utils/marks.d.ts +6 -1
- package/dist/crdt/vendor/yjs/dts/ynode.d.ts +43 -7
- package/dist/crdt/vendor/yjs/global.d.ts +2 -0
- package/dist/crdt/vendor/yjs/src/index.js +1 -1
- package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +10 -0
- package/dist/crdt/vendor/yjs/src/structs/Item.js +610 -51
- package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +18 -9
- package/dist/crdt/vendor/yjs/src/utils/Doc.js +5 -3
- package/dist/crdt/vendor/yjs/src/utils/StructStore.js +5 -0
- package/dist/crdt/vendor/yjs/src/utils/Transaction.js +36 -13
- package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +88 -18
- package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +119 -32
- package/dist/crdt/vendor/yjs/src/utils/encoding.js +13 -1
- package/dist/crdt/vendor/yjs/src/utils/ids.js +7 -7
- package/dist/crdt/vendor/yjs/src/utils/marks.js +193 -8
- package/dist/crdt/vendor/yjs/src/utils/redo.js +1 -1
- package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +1 -1
- package/dist/crdt/vendor/yjs/src/utils/updates.js +3 -3
- package/dist/crdt/vendor/yjs/src/ynode.js +177 -12
- package/dist/dnd/autoScroll.d.ts +15 -7
- package/dist/dnd/autoScroll.js +10 -15
- package/dist/dnd/dropIndicator.js +2 -5
- package/dist/dnd/external.d.ts +6 -0
- package/dist/dnd/external.js +17 -0
- package/dist/dnd/geometry.d.ts +2 -0
- package/dist/dnd/geometry.js +3 -4
- package/dist/dnd/placement.d.ts +1 -1
- package/dist/dnd/pragmatic.d.ts +3 -1
- package/dist/dnd/pragmatic.js +12 -2
- package/dist/dnd/vendor/pragmatic/UPSTREAM.md +51 -18
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.d.ts +0 -2
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.js +4 -22
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter-types.d.ts +26 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.d.ts +30 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.js +203 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-items.js +13 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-types.js +9 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/is-an-available-type.js +19 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/make-honey-pot-fix.js +4 -16
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types.d.ts +1 -8
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-drop-target.js +5 -6
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-monitor.js +2 -3
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.d.ts +1 -1
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.js +6 -24
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.d.ts +2 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js +5 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.d.ts +3 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js +12 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/native-types.d.ts +12 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window-in-safari.js +10 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window.js +55 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.js +8 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/internal-types.d.ts +0 -4
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/get-scroll-by.js +16 -72
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/try-scroll.js +1 -9
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/configuration.js +4 -29
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-scroll-change.js +2 -3
- package/dist/edytor.svelte.d.ts +2 -5
- package/dist/edytor.svelte.js +21 -32
- package/dist/events/beforeInputCommands.js +2 -2
- package/dist/events/onBeforeInput.js +1 -1
- package/dist/events/onDrop.d.ts +0 -6
- package/dist/events/onDrop.js +10 -23
- package/dist/events/onInput.d.ts +0 -12
- package/dist/events/onInput.js +1 -67
- package/dist/events/onPageHide.d.ts +3 -0
- package/dist/events/onPageHide.js +16 -0
- package/dist/export/forms.d.ts +627 -0
- package/dist/export/forms.js +749 -0
- package/dist/export/index.d.ts +170 -0
- package/dist/export/index.js +161 -0
- package/dist/export/markdown.d.ts +41 -0
- package/dist/export/markdown.js +585 -0
- package/dist/export/markdownWriter.d.ts +9 -0
- package/dist/export/markdownWriter.js +133 -0
- package/dist/export/mdx.d.ts +15 -0
- package/dist/export/mdx.js +33 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/kinds.js +1 -1
- package/dist/plugins/anchored.svelte.d.ts +21 -25
- package/dist/plugins/anchored.svelte.js +23 -39
- package/dist/plugins/blockHandles/BlockHandleController.svelte.js +24 -32
- package/dist/plugins/blockHandles/dragPreview.d.ts +26 -7
- package/dist/plugins/blockHandles/dragPreview.js +33 -0
- package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +5 -0
- package/dist/plugins/blockMenu/BlockMenuController.svelte.js +7 -2
- package/dist/plugins/blockMenu/blockMenuPlugin.js +5 -50
- package/dist/plugins/chrome.d.ts +27 -5
- package/dist/plugins/chrome.js +24 -9
- package/dist/plugins/code/CodePlugin.svelte +12 -9
- package/dist/plugins/code/header.svelte.js +7 -11
- package/dist/plugins/code/languageMenu.svelte.d.ts +5 -2
- package/dist/plugins/code/languageMenu.svelte.js +13 -20
- package/dist/plugins/columns/ColumnsPlugin.svelte +7 -20
- package/dist/plugins/columns/resize.svelte.d.ts +2 -3
- package/dist/plugins/columns/resize.svelte.js +2 -5
- package/dist/plugins/comments/CommentsController.svelte.d.ts +6 -0
- package/dist/plugins/comments/CommentsController.svelte.js +20 -0
- package/dist/plugins/equation/EquationPlugin.svelte +12 -22
- package/dist/plugins/equation/equation.svelte.d.ts +7 -15
- package/dist/plugins/equation/equation.svelte.js +13 -50
- package/dist/plugins/equation/tex.d.ts +17 -0
- package/dist/plugins/equation/tex.js +42 -0
- package/dist/plugins/fileDrop.d.ts +38 -23
- package/dist/plugins/fileDrop.js +82 -76
- package/dist/plugins/find/FindController.svelte.d.ts +5 -0
- package/dist/plugins/find/FindController.svelte.js +14 -14
- package/dist/plugins/find/findPlugin.js +1 -15
- package/dist/plugins/image/ImageChrome.svelte +8 -2
- package/dist/plugins/image/ImagePlugin.svelte +15 -52
- package/dist/plugins/image/controls.svelte.js +16 -2
- package/dist/plugins/image/toolbar.svelte.d.ts +5 -4
- package/dist/plugins/image/toolbar.svelte.js +21 -31
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/list.svelte.d.ts +9 -0
- package/dist/plugins/list.svelte.js +18 -0
- package/dist/plugins/marquee/marqueePlugin.js +0 -4
- package/dist/plugins/media/AudioPlugin.svelte +1 -1
- package/dist/plugins/media/BookmarkPlugin.svelte +6 -97
- package/dist/plugins/media/EmbedPlugin.svelte +5 -90
- package/dist/plugins/media/EmptySlot.svelte +36 -20
- package/dist/plugins/media/EmptySlot.svelte.d.ts +6 -15
- package/dist/plugins/media/FilePlugin.svelte +1 -19
- package/dist/plugins/media/MediaEmpty.svelte +2 -55
- package/dist/plugins/media/MediaEmpty.svelte.d.ts +18 -14
- package/dist/plugins/media/SourceBlock.svelte +142 -52
- package/dist/plugins/media/SourceBlock.svelte.d.ts +10 -4
- package/dist/plugins/media/VideoPlugin.svelte +1 -1
- package/dist/plugins/media/empty.svelte.js +2 -7
- package/dist/plugins/media/media.d.ts +2 -63
- package/dist/plugins/media/media.js +1 -194
- package/dist/plugins/media/sources.d.ts +60 -0
- package/dist/plugins/media/sources.js +165 -0
- package/dist/plugins/media/urlPaste.svelte.d.ts +2 -1
- package/dist/plugins/media/urlPaste.svelte.js +12 -21
- package/dist/plugins/mention/MentionPlugin.svelte +8 -35
- package/dist/plugins/page/PagePlugin.svelte +2 -9
- package/dist/plugins/page/page.js +1 -1
- package/dist/plugins/pageLink/PageLinkPlugin.svelte +6 -13
- package/dist/plugins/richtext/RichTextPlugin.svelte +85 -197
- package/dist/plugins/richtext/body.js +1 -1
- package/dist/plugins/richtext/calloutIcons.svelte.d.ts +2 -2
- package/dist/plugins/richtext/calloutIcons.svelte.js +5 -7
- package/dist/plugins/richtext/richTextOperations.d.ts +1 -19
- package/dist/plugins/richtext/richTextOperations.js +3 -49
- package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +2 -0
- package/dist/plugins/slashMenu/SlashMenuController.svelte.js +7 -0
- package/dist/plugins/slashMenu/slashMenuPlugin.js +5 -14
- package/dist/plugins/table/TableChrome.svelte +2 -3
- package/dist/plugins/table/TablePlugin.svelte +20 -54
- package/dist/plugins/table/chrome.svelte.d.ts +5 -2
- package/dist/plugins/table/chrome.svelte.js +30 -54
- package/dist/plugins/table/table.js +3 -3
- package/dist/plugins/toc/TocPlugin.svelte +2 -4
- package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +7 -0
- package/dist/plugins/toolbar/ToolbarController.svelte.js +20 -13
- package/dist/plugins/toolbar/toolbarPlugin.js +19 -53
- package/dist/plugins/triggers/TriggerController.svelte.d.ts +7 -2
- package/dist/plugins/triggers/TriggerController.svelte.js +11 -4
- package/dist/plugins/triggers/place.js +1 -2
- package/dist/plugins/triggers/triggers.d.ts +6 -1
- package/dist/plugins/triggers/triggers.js +12 -13
- package/dist/plugins/uploads.svelte.d.ts +5 -2
- package/dist/plugins/uploads.svelte.js +25 -15
- package/dist/plugins.d.ts +26 -0
- package/dist/plugins.js +0 -24
- package/dist/selection/replaceSelection.js +2 -2
- package/dist/selection/selection.svelte.d.ts +4 -10
- package/dist/selection/selection.svelte.js +7 -11
- package/dist/session/bindings.js +1 -1
- package/dist/session/commands.d.ts +7 -11
- package/dist/session/commands.js +13 -19
- package/dist/session/inputRules.js +1 -1
- package/dist/session/navigation.js +1 -1
- package/dist/session/suggestions.svelte.d.ts +0 -11
- package/dist/session/suggestions.svelte.js +15 -3
- package/dist/session/uploads.d.ts +8 -8
- package/dist/surface/lines.js +1 -3
- package/dist/surface/observer.svelte.d.ts +17 -1
- package/dist/surface/observer.svelte.js +74 -19
- package/dist/surface/overlay.d.ts +0 -14
- package/dist/surface/overlay.js +0 -25
- package/dist/surface/projector.svelte.d.ts +15 -3
- package/dist/surface/projector.svelte.js +60 -9
- package/dist/text/text.svelte.js +3 -13
- package/dist/utils/sanitize.d.ts +38 -0
- package/dist/utils/sanitize.js +82 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +5 -0
- package/package.json +19 -2
- package/dist/crdt/placement/rank.d.ts +0 -87
- package/dist/crdt/placement/rank.js +0 -332
- package/dist/crdt/placement/source.d.ts +0 -43
- package/dist/crdt/placement/source.js +0 -66
- package/dist/crdt/text/delete-index.d.ts +0 -129
- package/dist/crdt/text/delete-index.js +0 -365
- package/dist/crdt/text/deletes.d.ts +0 -76
- package/dist/crdt/text/deletes.js +0 -362
- package/dist/crdt/text/index/anchored.d.ts +0 -17
- package/dist/crdt/text/index/anchored.js +0 -197
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/max-z-index.js +0 -3
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/supports-popover.js +0 -16
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-axis-allowed.js +0 -3
- package/dist/plugins/code/LanguageMenu.svelte +0 -25
- package/dist/plugins/code/LanguageMenu.svelte.d.ts +0 -9
- package/dist/plugins/equation/EquationEditor.svelte +0 -27
- package/dist/plugins/equation/EquationEditor.svelte.d.ts +0 -9
- package/dist/plugins/image/ImageToolbarHost.svelte +0 -37
- package/dist/plugins/image/ImageToolbarHost.svelte.d.ts +0 -9
- package/dist/plugins/richtext/CalloutIconPicker.svelte +0 -26
- package/dist/plugins/richtext/CalloutIconPicker.svelte.d.ts +0 -9
|
@@ -6,15 +6,16 @@
|
|
|
6
6
|
import { readData } from '../../data.js';
|
|
7
7
|
import { Y } from '../../engine.js';
|
|
8
8
|
import { LIVE_WRITERS, baseIdOf, incarnationId } from '../../incarnations.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { ownerOfNode, slotOwner } from '../../placement/resolve.js';
|
|
10
|
+
import { isBlockSlot, isDataSlot, isRecord, unitOf } from '../../placement/slots.js';
|
|
11
|
+
import { CONTENT, CONTENT_NODE, NONCE, hasDeleteMark, isNodeLike } from '../../schema.js';
|
|
12
|
+
import { changedUnder, clientsOf, engineOps, itemOf, queuedTransactions, sequenceLength, structAt, walkIdSet } from '../../structs.js';
|
|
13
|
+
import { DEAD, isRowMark } from '../model.js';
|
|
13
14
|
import { gapOfItem, headOf, rowLength, segmentOfGap, shiftGap } from '../rows.js';
|
|
14
|
-
import { CONTENT_ATTR, EMPTY_RUNS, ENTRY_FACET, facetOf, checksOf, indexChecks, sameShape, typeAttr } from './shared.js';
|
|
15
|
+
import { CONTENT_ATTR, DATA_SEQ_FACET, EMPTY_RUNS, ENTRY_FACET, SEQ_FACET, facetOf, checksOf, indexChecks, sameShape, typeAttr } from './shared.js';
|
|
15
16
|
/** The fold of one doc's index, over every part it folds into. */
|
|
16
17
|
export const indexFold = (ix) => {
|
|
17
|
-
const { doc, registry, dataRoot, blocks, shells, textConsumers, ownerSeeds, rows,
|
|
18
|
+
const { doc, registry, dataRoot, blocks, shells, textConsumers, ownerSeeds, rows, reclaim, placementSeeds, stateSeeds, incarnations, cache, dirty, foldStats, frames, candidates, ownerOf, invalidateBlock, streamOf, streamsIn, setRow, scanRow, refreshDelims, placeHome, applyReclaims, noteKind, homeFor, putSlot, edgeParent, kept, updateBlockRec, ensureRec, syncIncarnations, computeRuns, tableFacts } = ix;
|
|
18
19
|
const ops = engineOps(Y);
|
|
19
20
|
const NO_EDITS = Object.freeze({
|
|
20
21
|
edits: [],
|
|
@@ -26,12 +27,86 @@ export const indexFold = (ix) => {
|
|
|
26
27
|
if (arr === undefined)
|
|
27
28
|
return false;
|
|
28
29
|
for (let k = from - s.id.clock; k < to - s.id.clock; k++)
|
|
29
|
-
if (
|
|
30
|
+
if (isRowMark(arr[k]))
|
|
30
31
|
return true;
|
|
31
32
|
return false;
|
|
32
33
|
};
|
|
33
|
-
/** The
|
|
34
|
-
const
|
|
34
|
+
/** The struct holding id `client:clock` (unsplit), `null` when the store holds none. */
|
|
35
|
+
const structOf = (client, clock) => structAt(Y, clientsOf(doc).get(client) ?? [], clock);
|
|
36
|
+
/**
|
|
37
|
+
* The edits the id sets `ins`/`del`, the hold log `log` and the move log
|
|
38
|
+
* `moves` (what the fold has not folded yet) hold: per text, its edits
|
|
39
|
+
* (a log entry is a unit a hold record hid or showed, fork patch YP20:
|
|
40
|
+
* `client, clock, ±len`, in order); per sequence, what changed in it
|
|
41
|
+
* (`seq`): the slots written and removed, the records written and
|
|
42
|
+
* removed and the units whose mover changed name the blocks to re-place.
|
|
43
|
+
* Reading the sequences writes the slot map (the slots written and
|
|
44
|
+
* removed, `putSlot`) and lists the ids whose home to read again
|
|
45
|
+
* (`rehome`).
|
|
46
|
+
*/
|
|
47
|
+
const makeEditIndex = (ins, del, log = [], moves = []) => {
|
|
48
|
+
let seqs;
|
|
49
|
+
const rehome = new Set();
|
|
50
|
+
const seqOf = (node) => {
|
|
51
|
+
let e = seqs.get(node);
|
|
52
|
+
if (e === undefined)
|
|
53
|
+
seqs.set(node, (e = { blocks: new Set(), data: false }));
|
|
54
|
+
return e;
|
|
55
|
+
};
|
|
56
|
+
/** Note unit `c:k` (`value`) of the sequence of `node`: a block slot names its block, a data slot its data. */
|
|
57
|
+
const noteUnit = (e, owner, value, c, k, inserted) => {
|
|
58
|
+
if (isBlockSlot(value)) {
|
|
59
|
+
e.blocks.add(slotOwner(registry, kept, value.b, c));
|
|
60
|
+
if (inserted === null || (inserted && owner === undefined))
|
|
61
|
+
return;
|
|
62
|
+
putSlot(value.b, { c, k }, inserted ? { parent: owner, c, k } : null);
|
|
63
|
+
rehome.add(value.b);
|
|
64
|
+
}
|
|
65
|
+
else if (isDataSlot(value))
|
|
66
|
+
e.data = true;
|
|
67
|
+
};
|
|
68
|
+
const visitSeq = (s, from, to, inserted) => {
|
|
69
|
+
const parent = s.parent;
|
|
70
|
+
if (s.parentSub !== null || !isNodeLike(parent) || parent.name === CONTENT_NODE)
|
|
71
|
+
return;
|
|
72
|
+
const e = seqOf(parent);
|
|
73
|
+
const owner = ownerOfNode(registry, kept, parent);
|
|
74
|
+
const it = s;
|
|
75
|
+
if (it.content === undefined)
|
|
76
|
+
return;
|
|
77
|
+
if (isRecord(it)) {
|
|
78
|
+
const ids = it.content.ids;
|
|
79
|
+
for (let i = 0; i < ids.length; i += 3)
|
|
80
|
+
for (let j = 0; j < ids[i + 2]; j++) {
|
|
81
|
+
const u = unitOf(doc, { c: ids[i], k: ids[i + 1] + j });
|
|
82
|
+
if (u !== null)
|
|
83
|
+
noteUnit(e, owner, u.value, ids[i], ids[i + 1] + j, null);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else if (it.content.arr !== undefined)
|
|
87
|
+
for (let k = from; k < to; k++)
|
|
88
|
+
noteUnit(e, owner, it.content.arr[k - s.id.clock], s.id.client, k, inserted);
|
|
89
|
+
};
|
|
90
|
+
const buildSeqs = () => {
|
|
91
|
+
if (seqs !== undefined)
|
|
92
|
+
return seqs;
|
|
93
|
+
seqs = new Map();
|
|
94
|
+
if (ins === undefined || del === undefined)
|
|
95
|
+
return seqs;
|
|
96
|
+
walkIdSet(Y, doc, ins, (s, from, to) => visitSeq(s, from, to, true));
|
|
97
|
+
walkIdSet(Y, doc, del, (s, from, to) => visitSeq(s, from, to, false));
|
|
98
|
+
for (let i = 0; i < moves.length; i += 3) {
|
|
99
|
+
const s = structOf(moves[i], moves[i + 1]);
|
|
100
|
+
if (s === null)
|
|
101
|
+
continue;
|
|
102
|
+
visitSeq(s, moves[i + 1], moves[i + 1] + moves[i + 2], null);
|
|
103
|
+
// Where the unit shows now: that sequence changed too.
|
|
104
|
+
const mover = s.mover;
|
|
105
|
+
if (mover)
|
|
106
|
+
seqOf(mover.parent);
|
|
107
|
+
}
|
|
108
|
+
return seqs;
|
|
109
|
+
};
|
|
35
110
|
let built;
|
|
36
111
|
const build = () => {
|
|
37
112
|
if (built !== undefined)
|
|
@@ -39,7 +114,7 @@ export const indexFold = (ix) => {
|
|
|
39
114
|
if (ins === undefined || del === undefined)
|
|
40
115
|
return (built = null);
|
|
41
116
|
const out = new Map();
|
|
42
|
-
const
|
|
117
|
+
const edit = (s, from, to, deleted) => {
|
|
43
118
|
const parent = s.parent;
|
|
44
119
|
if (s.parentSub !== null || !isNodeLike(parent))
|
|
45
120
|
return;
|
|
@@ -49,20 +124,44 @@ export const indexFold = (ix) => {
|
|
|
49
124
|
// A format marker moves no unit; its effect reaches past the edit.
|
|
50
125
|
if (s.countable !== true)
|
|
51
126
|
return void (e.opaque = true);
|
|
52
|
-
// Written and removed within the fold: nothing moved.
|
|
53
|
-
if (deleted ? ins.has(s.id.client, from) : s.deleted)
|
|
54
|
-
return;
|
|
55
127
|
if (holdsBoundary(s, from, to))
|
|
56
128
|
return void (e.scan = true);
|
|
57
129
|
e.edits.push({ item: s, len: to - from, del: deleted });
|
|
130
|
+
};
|
|
131
|
+
const visit = (idSet, deleted) => walkIdSet(Y, doc, idSet, (s, from, to) => {
|
|
132
|
+
// Written and removed (or held) within the fold: nothing moved.
|
|
133
|
+
if (!(deleted ? ins.has(s.id.client, from) : s.deleted))
|
|
134
|
+
edit(s, from, to, deleted);
|
|
58
135
|
});
|
|
59
|
-
|
|
136
|
+
// In order, after the inserts and before the deletes (each gap then
|
|
137
|
+
// holds what an edit takes); a unit written within the fold shows or
|
|
138
|
+
// not as its insert says.
|
|
139
|
+
const held = () => {
|
|
140
|
+
for (let i = 0; i < log.length; i += 3) {
|
|
141
|
+
const s = structOf(log[i], log[i + 1]);
|
|
142
|
+
if (s === null)
|
|
143
|
+
return false;
|
|
144
|
+
const n = log[i + 2];
|
|
145
|
+
if (!ins.has(log[i], log[i + 1]))
|
|
146
|
+
edit(s, log[i + 1], log[i + 1] + Math.abs(n), n < 0);
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
};
|
|
150
|
+
built = visit(ins, false) && held() && visit(del, true) ? out : null;
|
|
60
151
|
return built;
|
|
61
152
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
153
|
+
return {
|
|
154
|
+
/** `node`'s edits (`null`: unknown — rescan, every consumer recomputes). */
|
|
155
|
+
text: (node) => {
|
|
156
|
+
const map = build();
|
|
157
|
+
return map === null ? null : (map.get(node) ?? NO_EDITS);
|
|
158
|
+
},
|
|
159
|
+
/** What changed in `node`'s sequence (`undefined`: nothing). */
|
|
160
|
+
seq: (node) => buildSeqs().get(node),
|
|
161
|
+
/** The sequences the fold changed. */
|
|
162
|
+
seqNodes: () => buildSeqs().keys(),
|
|
163
|
+
/** The ids whose home to read again (their slots changed). */
|
|
164
|
+
rehome
|
|
66
165
|
};
|
|
67
166
|
};
|
|
68
167
|
const runs = (b) => {
|
|
@@ -73,7 +172,8 @@ export const indexFold = (ix) => {
|
|
|
73
172
|
return cache.get(b)?.runs ?? EMPTY_RUNS;
|
|
74
173
|
};
|
|
75
174
|
// ── the fold ─────────────────────────────────────────────────────
|
|
76
|
-
|
|
175
|
+
/** The owner of the sequence `id`'s slot shows in (its display edge's parent), as the engine stands. */
|
|
176
|
+
const parentOf = (id) => edgeParent(id);
|
|
77
177
|
/** Note edits of `id`'s own text (`null`: unknown — rescan, every reader re-reads). */
|
|
78
178
|
const noteText = (ctx, id, e) => {
|
|
79
179
|
let t = ctx.texts.get(id);
|
|
@@ -92,11 +192,12 @@ export const indexFold = (ix) => {
|
|
|
92
192
|
t.edits.push(x);
|
|
93
193
|
};
|
|
94
194
|
/** Fold one block's changed facets (`edits`: its own text's, one per changed content node). */
|
|
95
|
-
const foldBlock = (id, facets, edits, ctx) => {
|
|
195
|
+
const foldBlock = (id, facets, edits, ctx, editsOf) => {
|
|
96
196
|
const kinds = new Set();
|
|
97
197
|
for (const f of facets)
|
|
98
198
|
kinds.add(f === ENTRY_FACET ? 'entry' : facetOf(f));
|
|
99
|
-
|
|
199
|
+
// The display parents a shell may flip by (`settle`): read while there are shells.
|
|
200
|
+
const parentBefore = shells.size > 0 ? parentOf(id) : undefined;
|
|
100
201
|
if (typeof parentBefore === 'string')
|
|
101
202
|
ctx.parents.add(parentBefore);
|
|
102
203
|
if (kinds.has('entry') || kinds.has('structure')) {
|
|
@@ -123,12 +224,9 @@ export const indexFold = (ix) => {
|
|
|
123
224
|
else {
|
|
124
225
|
ensureRec(id);
|
|
125
226
|
const rec = blocks.get(id);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
noteCands(id, before);
|
|
130
|
-
placementSeeds.add(id);
|
|
131
|
-
}
|
|
227
|
+
// A data slot in the block's sequence: its arrays' items changed (the seq pass seeded the blocks).
|
|
228
|
+
if (kinds.has('seq') && rec && editsOf.seq(rec.node)?.data)
|
|
229
|
+
kinds.add('meta');
|
|
132
230
|
if (kinds.has('meta') && rec) {
|
|
133
231
|
const was = rec.type;
|
|
134
232
|
const facts = tableFacts(id, rec.data);
|
|
@@ -147,7 +245,7 @@ export const indexFold = (ix) => {
|
|
|
147
245
|
stateSeeds.add(id);
|
|
148
246
|
}
|
|
149
247
|
}
|
|
150
|
-
const parentAfter = parentOf(id);
|
|
248
|
+
const parentAfter = shells.size > 0 ? parentOf(id) : undefined;
|
|
151
249
|
if (typeof parentAfter === 'string')
|
|
152
250
|
ctx.parents.add(parentAfter);
|
|
153
251
|
if (kinds.has('content'))
|
|
@@ -195,7 +293,7 @@ export const indexFold = (ix) => {
|
|
|
195
293
|
const next = scanRow(home);
|
|
196
294
|
const same = next !== undefined && row !== undefined && next.key === row.key;
|
|
197
295
|
if (same)
|
|
198
|
-
[next.cuts, next.head] = [row.cuts, row.head];
|
|
296
|
+
[next.cuts, next.heads, next.head] = [row.cuts, row.heads, row.head];
|
|
199
297
|
setRow(home, next, ctx.named);
|
|
200
298
|
if (!same)
|
|
201
299
|
homes.add(home);
|
|
@@ -269,8 +367,10 @@ export const indexFold = (ix) => {
|
|
|
269
367
|
if (holdsUnit(id))
|
|
270
368
|
hold(id);
|
|
271
369
|
for (const [id, rec] of blocks) {
|
|
272
|
-
|
|
273
|
-
|
|
370
|
+
if (shells.has(id) || rec.deleted)
|
|
371
|
+
continue;
|
|
372
|
+
const p = parentOf(id);
|
|
373
|
+
if (typeof p === 'string' && shells.has(p))
|
|
274
374
|
hold(p);
|
|
275
375
|
}
|
|
276
376
|
for (let id = up.pop(); id !== undefined; id = up.pop()) {
|
|
@@ -327,8 +427,9 @@ export const indexFold = (ix) => {
|
|
|
327
427
|
return null;
|
|
328
428
|
id = incarnationId(id, item);
|
|
329
429
|
}
|
|
430
|
+
// The block's own sequence (its slots and records: `SEQ_FACET`), or one of its attrs.
|
|
330
431
|
if (below === null)
|
|
331
|
-
return [id, sub === CONTENT ? CONTENT_ATTR :
|
|
432
|
+
return [id, sub === CONTENT ? CONTENT_ATTR : sub === null ? SEQ_FACET : sub, false];
|
|
332
433
|
const facet = below._item?.parentSub ?? CONTENT;
|
|
333
434
|
return [id, facet, sub === null && below === type && facet === CONTENT];
|
|
334
435
|
}
|
|
@@ -361,7 +462,7 @@ export const indexFold = (ix) => {
|
|
|
361
462
|
let list = edits.get(id);
|
|
362
463
|
if (list === undefined)
|
|
363
464
|
edits.set(id, (list = []));
|
|
364
|
-
list.push(seq ? editsOf(type) : null);
|
|
465
|
+
list.push(seq ? editsOf.text(type) : null);
|
|
365
466
|
}
|
|
366
467
|
}
|
|
367
468
|
const ctx = {
|
|
@@ -371,15 +472,42 @@ export const indexFold = (ix) => {
|
|
|
371
472
|
table: false,
|
|
372
473
|
parents: new Set()
|
|
373
474
|
};
|
|
475
|
+
// The sequences (the root's, the blocks'): their slots index the blocks' homes, their changes seed the placements.
|
|
476
|
+
for (const node of editsOf.seqNodes()) {
|
|
477
|
+
const ch = editsOf.seq(node);
|
|
478
|
+
ix.seqEpoch++;
|
|
479
|
+
for (const b of ch.blocks)
|
|
480
|
+
placementSeeds.add(b);
|
|
481
|
+
if (ch.blocks.size > 0 || ch.data)
|
|
482
|
+
derived = true;
|
|
483
|
+
const owner = ownerOfNode(registry, kept, node);
|
|
484
|
+
if (typeof owner === 'string') {
|
|
485
|
+
let facets = touched.get(owner);
|
|
486
|
+
if (facets === undefined)
|
|
487
|
+
touched.set(owner, (facets = new Set()));
|
|
488
|
+
facets.add(SEQ_FACET);
|
|
489
|
+
if (ch.data)
|
|
490
|
+
facets.add(DATA_SEQ_FACET);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
// A slot's block, and its losing incarnations, re-read their home (which slot is whose).
|
|
494
|
+
for (const b of editsOf.rehome)
|
|
495
|
+
for (const id of [b, ...(incarnations.get(b) ?? [])]) {
|
|
496
|
+
const rec = blocks.get(id);
|
|
497
|
+
if (rec === undefined)
|
|
498
|
+
continue;
|
|
499
|
+
const home = homeFor(id);
|
|
500
|
+
if (home?.c !== rec.home?.c || home?.k !== rec.home?.k)
|
|
501
|
+
placementSeeds.add(id);
|
|
502
|
+
rec.home = home;
|
|
503
|
+
}
|
|
374
504
|
for (const [id, facets] of touched) {
|
|
375
|
-
foldBlock(id, facets, edits.get(id) ?? [], ctx);
|
|
505
|
+
foldBlock(id, facets, edits.get(id) ?? [], ctx, editsOf);
|
|
376
506
|
derived ||= [...facets].some((f) => f === ENTRY_FACET || facetOf(f) !== 'ignore');
|
|
377
507
|
}
|
|
378
508
|
foldTexts(ctx);
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
if (retargets.size > 0 || reclaim.size > 0)
|
|
382
|
-
applyRetargets(ctx);
|
|
509
|
+
if (reclaim.size > 0)
|
|
510
|
+
applyReclaims(ctx);
|
|
383
511
|
if (shells.size > 0)
|
|
384
512
|
settle(ctx.table ? shells : [...touched.keys(), ...ctx.parents, ...editedStreams(ctx)], ctx);
|
|
385
513
|
for (const b of ctx.invalidated)
|
|
@@ -406,7 +534,7 @@ export const indexFold = (ix) => {
|
|
|
406
534
|
}
|
|
407
535
|
return touched;
|
|
408
536
|
};
|
|
409
|
-
/** Each transaction's folded part: copies of its id sets, and
|
|
537
|
+
/** Each transaction's folded part: copies of its id sets, the hold and move logs' folded lengths, and the watermark. */
|
|
410
538
|
const cursors = new WeakMap();
|
|
411
539
|
/** The transactions whose commit fold ran. */
|
|
412
540
|
const committed = new WeakSet();
|
|
@@ -418,6 +546,11 @@ export const indexFold = (ix) => {
|
|
|
418
546
|
});
|
|
419
547
|
return n;
|
|
420
548
|
};
|
|
549
|
+
/** How much a transaction wrote so far: its id sets' lengths and its hold and move logs'. */
|
|
550
|
+
const watermark = (tr) => lengthOf(tr.insertSet) +
|
|
551
|
+
lengthOf(tr.deleteSet) +
|
|
552
|
+
(tr.holds?.length ?? 0) +
|
|
553
|
+
(tr.moves?.length ?? 0);
|
|
421
554
|
/**
|
|
422
555
|
* Fold the pending part of `tr` — the structs its insert/delete sets
|
|
423
556
|
* gained since the last fold — before a read inside it (read-your-
|
|
@@ -429,14 +562,18 @@ export const indexFold = (ix) => {
|
|
|
429
562
|
return false;
|
|
430
563
|
let cursor = cursors.get(tr);
|
|
431
564
|
if (cursor === undefined)
|
|
432
|
-
cursors.set(tr, (cursor = { ins: ops.idSet(), del: ops.idSet(), mark: 0 }));
|
|
433
|
-
const mark =
|
|
565
|
+
cursors.set(tr, (cursor = { ins: ops.idSet(), del: ops.idSet(), holds: 0, moves: 0, mark: 0 }));
|
|
566
|
+
const mark = watermark(tr);
|
|
434
567
|
if (mark === cursor.mark)
|
|
435
568
|
return false;
|
|
436
569
|
const ins = ops.diff(tr.insertSet, cursor.ins);
|
|
437
570
|
const del = ops.diff(tr.deleteSet, cursor.del);
|
|
571
|
+
const log = (tr.holds ?? []).slice(cursor.holds);
|
|
572
|
+
const moves = (tr.moves ?? []).slice(cursor.moves);
|
|
438
573
|
ops.insertInto(cursor.ins, ins);
|
|
439
574
|
ops.insertInto(cursor.del, del);
|
|
575
|
+
cursor.holds += log.length;
|
|
576
|
+
cursor.moves += moves.length;
|
|
440
577
|
cursor.mark = mark;
|
|
441
578
|
for (const f of frames)
|
|
442
579
|
f.wrote = true;
|
|
@@ -452,7 +589,18 @@ export const indexFold = (ix) => {
|
|
|
452
589
|
};
|
|
453
590
|
walkIdSet(Y, doc, ins, note);
|
|
454
591
|
walkIdSet(Y, doc, del, note);
|
|
455
|
-
|
|
592
|
+
for (const l of [log, moves])
|
|
593
|
+
for (let i = 0; i < l.length; i += 3) {
|
|
594
|
+
const s = structOf(l[i], l[i + 1]);
|
|
595
|
+
if (s === null)
|
|
596
|
+
continue;
|
|
597
|
+
note(s);
|
|
598
|
+
// A unit a record moved: where it shows now changed too (a held unit has no mover).
|
|
599
|
+
const mover = s.mover;
|
|
600
|
+
if (mover)
|
|
601
|
+
note(mover);
|
|
602
|
+
}
|
|
603
|
+
fold(changed, makeEditIndex(ins, del, log, moves));
|
|
456
604
|
return true;
|
|
457
605
|
};
|
|
458
606
|
const openTx = () => doc._transaction;
|
|
@@ -473,7 +621,7 @@ export const indexFold = (ix) => {
|
|
|
473
621
|
const unfolded = () => queuedTransactions(doc).some((tr) => !committed.has(tr) &&
|
|
474
622
|
tr.insertSet !== undefined &&
|
|
475
623
|
tr.deleteSet !== undefined &&
|
|
476
|
-
|
|
624
|
+
watermark(tr) !== (cursors.get(tr)?.mark ?? 0));
|
|
477
625
|
/**
|
|
478
626
|
* The commit of a transaction that changed the registry or a node under
|
|
479
627
|
* it: fold `transaction.changed` once (the report publishes from `update`).
|
|
@@ -489,9 +637,11 @@ export const indexFold = (ix) => {
|
|
|
489
637
|
ins = ops.diff(ins, cursor.ins);
|
|
490
638
|
del = ops.diff(del, cursor.del);
|
|
491
639
|
}
|
|
640
|
+
const log = (tr.holds ?? []).slice(cursor?.holds ?? 0);
|
|
641
|
+
const moves = (tr.moves ?? []).slice(cursor?.moves ?? 0);
|
|
492
642
|
cursors.delete(tr);
|
|
493
643
|
committed.add(tr);
|
|
494
|
-
fold(tr.changed ?? new Map(), makeEditIndex(ins, del));
|
|
644
|
+
fold(tr.changed ?? new Map(), makeEditIndex(ins, del, log, moves));
|
|
495
645
|
};
|
|
496
646
|
return {
|
|
497
647
|
runs,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cellKey, LAST_CELL, unlistedCellKey } from '../../placement/keys.js';
|
|
2
2
|
import { listedColumns, unlistedRank } from '../../tables.js';
|
|
3
3
|
/** The layout rules of one doc's index, over its state. */
|
|
4
4
|
export const indexLayout = (ix) => {
|
|
@@ -77,8 +77,8 @@ export const indexLayout = (ix) => {
|
|
|
77
77
|
/**
|
|
78
78
|
* The rank cell `id` displays at in row `row` (`table.columns`): its
|
|
79
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
|
|
81
|
-
*
|
|
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
82
|
* column the table no longer lists after them, its column's place among
|
|
83
83
|
* those fixed by its id (`unlistedRank`); any other cell of no listed
|
|
84
84
|
* column last (it does not display, `table.cell`).
|
|
@@ -95,11 +95,8 @@ export const indexLayout = (ix) => {
|
|
|
95
95
|
const column = columnOf(id);
|
|
96
96
|
const at = column === undefined ? undefined : index.get(column);
|
|
97
97
|
if (at === undefined && column !== undefined && ix.shells.has(id))
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
-
{ v: unlistedRank(column), t: 0 }
|
|
101
|
-
]);
|
|
102
|
-
return encodeRank([{ v: at ?? RANK_VMAX, t: 0 }]);
|
|
98
|
+
return unlistedCellKey(unlistedRank(column));
|
|
99
|
+
return at === undefined ? LAST_CELL : cellKey(at);
|
|
103
100
|
};
|
|
104
101
|
/**
|
|
105
102
|
* The table rules (`table.*`), in the same pass: a cell displays only in
|
|
@@ -3,36 +3,44 @@
|
|
|
3
3
|
* ownership the display reads (`ownShim`), and THE shown-kind rule
|
|
4
4
|
* (`typeOf`).
|
|
5
5
|
*
|
|
6
|
-
* A structural change re-decides only what it can change: the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* (`
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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.
|
|
16
24
|
*/
|
|
17
|
-
import { type BlockId, type
|
|
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';
|
|
18
29
|
import type { IndexClaims } from './claims.js';
|
|
19
30
|
import type { IndexLayout } from './layout.js';
|
|
20
31
|
import type { IndexState } from './state.js';
|
|
21
32
|
import type { IndexStreams } from './streams.js';
|
|
22
33
|
/** Placement maintenance of one doc's index, over its state, claims, streams and layout rules. */
|
|
23
34
|
export declare const indexPlacement: (ix: IndexState & IndexClaims & IndexStreams & IndexLayout) => {
|
|
24
|
-
ranker: {
|
|
25
|
-
rank: (id: BlockId, parent: BlockId | null, rank: string) => string;
|
|
26
|
-
regroup: (home: BlockId) => Set<BlockId>;
|
|
27
|
-
forget: (home?: BlockId) => void;
|
|
28
|
-
};
|
|
29
35
|
ownShim: DisplayOwnership;
|
|
30
36
|
own0: DisplayOwnership;
|
|
31
37
|
noteKind: (id: BlockId) => void;
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
homeFor: (id: BlockId) => ReturnType<typeof homeOf>;
|
|
39
|
+
putSlot: (b: BlockId, u: Unit, ref: SlotRef | null) => void;
|
|
40
|
+
edgeParent: (id: BlockId) => BlockId | null | undefined;
|
|
34
41
|
noteFollowing: (id: BlockId) => void;
|
|
35
42
|
ensurePlacements: () => void;
|
|
43
|
+
reslot: (node: EngineNode) => void;
|
|
36
44
|
typeOf: (id: BlockId) => string;
|
|
37
45
|
order: () => DocOrder;
|
|
38
46
|
};
|