edytor 1.0.0-rc.3 → 1.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 +65 -25
- package/dist/block/block.svelte.d.ts +10 -85
- package/dist/block/block.svelte.js +27 -137
- package/dist/block/colors.d.ts +0 -9
- package/dist/block/colors.js +1 -18
- package/dist/block/contentRange.d.ts +5 -1
- package/dist/block/contentRange.js +15 -16
- package/dist/block/inlineBlock.svelte.d.ts +8 -10
- package/dist/block/inlineBlock.svelte.js +14 -22
- package/dist/clipboard/createClipboardFragment.js +22 -64
- package/dist/clipboard/fragmentData.js +17 -42
- package/dist/clipboard/htmlFlow.js +7 -7
- package/dist/clipboard/insertClipboardFragment.js +5 -4
- package/dist/clipboard/moveText.js +16 -8
- package/dist/clipboard/serializeClipboardFragment.d.ts +2 -0
- package/dist/clipboard/serializeClipboardFragment.js +32 -28
- package/dist/cloudflare/DocumentRoom.d.ts +4 -17
- package/dist/cloudflare/DocumentRoom.js +3 -5
- package/dist/cloudflare/move.d.ts +1 -18
- package/dist/cloudflare/move.js +2 -48
- package/dist/cloudflare/room/admission.d.ts +1 -60
- package/dist/cloudflare/room/admission.js +25 -29
- package/dist/cloudflare/room/comments.d.ts +1 -3
- package/dist/cloudflare/room/comments.js +6 -6
- package/dist/cloudflare/room/context.d.ts +19 -82
- package/dist/cloudflare/room/context.js +8 -8
- package/dist/cloudflare/room/forged.d.ts +1 -1
- package/dist/cloudflare/room/forged.js +2 -12
- package/dist/cloudflare/room/frames.d.ts +1 -1
- package/dist/cloudflare/room/frames.js +1 -1
- package/dist/cloudflare/room/history.d.ts +1 -25
- package/dist/cloudflare/room/history.js +39 -54
- package/dist/cloudflare/room/moves.d.ts +1 -13
- package/dist/cloudflare/room/moves.js +33 -57
- package/dist/cloudflare/room/presence.d.ts +1 -11
- package/dist/cloudflare/room/presence.js +4 -4
- package/dist/cloudflare/room/purge.d.ts +1 -2
- package/dist/cloudflare/room/purge.js +2 -2
- package/dist/cloudflare/room/replicas.d.ts +1 -7
- package/dist/cloudflare/room/replicas.js +2 -2
- package/dist/cloudflare/room/storage.d.ts +3 -32
- package/dist/cloudflare/room/storage.js +33 -108
- package/dist/cloudflare/room/updates.d.ts +4 -4
- package/dist/cloudflare/room/updates.js +17 -24
- package/dist/cloudflare/room/validation.d.ts +1 -5
- package/dist/cloudflare/room/validation.js +16 -37
- package/dist/collaboration/RemoteSelections.svelte +13 -17
- package/dist/collaboration/comments/client.d.ts +2 -2
- package/dist/collaboration/comments/client.js +1 -1
- package/dist/collaboration/history/index.d.ts +5 -5
- package/dist/collaboration/history/index.js +5 -5
- package/dist/collaboration/history/panel.svelte.d.ts +91 -0
- package/dist/collaboration/history/panel.svelte.js +223 -0
- package/dist/collaboration/providers.d.ts +12 -3
- package/dist/collaboration/providers.js +5 -4
- package/dist/components/Block.svelte +39 -55
- package/dist/components/Block.svelte.d.ts +7 -5
- package/dist/components/Content.svelte +1 -5
- package/dist/components/Edytor.svelte +53 -96
- package/dist/components/Edytor.svelte.d.ts +8 -12
- package/dist/components/Ranges.svelte +96 -0
- package/dist/components/Ranges.svelte.d.ts +19 -0
- package/dist/components/Suggestion.svelte +3 -2
- package/dist/components/Text.svelte +2 -5
- package/dist/components/Text.svelte.d.ts +1 -1
- package/dist/crdt/admission.d.ts +2 -9
- package/dist/crdt/admission.js +3 -9
- package/dist/crdt/attribution/attribution.d.ts +11 -72
- package/dist/crdt/attribution/attribution.js +5 -52
- package/dist/crdt/attribution/block.d.ts +0 -78
- package/dist/crdt/attribution/block.js +1 -144
- package/dist/crdt/data.d.ts +8 -13
- package/dist/crdt/data.js +30 -70
- package/dist/crdt/doc/anchors.js +4 -4
- package/dist/crdt/doc/content.d.ts +5 -1
- package/dist/crdt/doc/content.js +3 -1
- package/dist/crdt/doc/delete.d.ts +1 -0
- package/dist/crdt/doc/funnel.d.ts +0 -23
- package/dist/crdt/doc/funnel.js +34 -85
- package/dist/crdt/doc/gate.d.ts +8 -9
- package/dist/crdt/doc/gate.js +7 -17
- package/dist/crdt/doc/history.d.ts +87 -14
- package/dist/crdt/doc/history.js +334 -149
- package/dist/crdt/doc/layout.d.ts +0 -1
- package/dist/crdt/doc/layout.js +2 -3
- package/dist/crdt/doc/meta.d.ts +4 -4
- package/dist/crdt/doc/meta.js +10 -21
- package/dist/crdt/doc/moves.d.ts +4 -4
- package/dist/crdt/doc/moves.js +5 -5
- package/dist/crdt/doc/plan.d.ts +2 -0
- package/dist/crdt/doc/plan.js +2 -0
- package/dist/crdt/doc/reads.d.ts +1 -5
- package/dist/crdt/doc/reads.js +38 -49
- package/dist/crdt/doc/seed.d.ts +15 -6
- package/dist/crdt/doc/seed.js +27 -26
- package/dist/crdt/doc/split-merge.d.ts +1 -3
- package/dist/crdt/doc/split-merge.js +4 -5
- package/dist/crdt/doc/steps.d.ts +3 -7
- package/dist/crdt/doc/steps.js +20 -9
- package/dist/crdt/doc/types.d.ts +0 -10
- package/dist/crdt/document.d.ts +24 -115
- package/dist/crdt/document.js +207 -305
- package/dist/crdt/edytor-doc.d.ts +671 -90
- package/dist/crdt/edytor-doc.js +73 -149
- package/dist/crdt/engine-api.d.ts +15 -47
- package/dist/crdt/engine.d.ts +7 -17
- package/dist/crdt/engine.js +9 -19
- package/dist/crdt/flow.d.ts +9 -37
- package/dist/crdt/flow.js +260 -238
- package/dist/crdt/index.d.ts +26 -85
- package/dist/crdt/index.js +21 -47
- package/dist/crdt/operations.d.ts +24 -33
- package/dist/crdt/operations.js +7 -17
- package/dist/crdt/placement/display.d.ts +0 -2
- package/dist/crdt/placement/display.js +0 -15
- package/dist/crdt/placement/model.d.ts +160 -12
- package/dist/crdt/placement/model.js +413 -414
- package/dist/crdt/placement/rank.d.ts +1 -5
- package/dist/crdt/placement/rank.js +28 -38
- package/dist/crdt/protocol.d.ts +4 -5
- package/dist/crdt/protocol.js +3 -4
- package/dist/crdt/protocols/awareness.d.ts +3 -7
- package/dist/crdt/protocols/awareness.js +17 -33
- package/dist/crdt/protocols/envelope.d.ts +9 -29
- package/dist/crdt/protocols/envelope.js +8 -25
- package/dist/crdt/protocols/sync.d.ts +15 -30
- package/dist/crdt/protocols/sync.js +27 -89
- package/dist/crdt/providers/bound.d.ts +3 -1
- package/dist/crdt/providers/bound.js +3 -1
- package/dist/crdt/providers/container.d.ts +11 -17
- package/dist/crdt/providers/container.js +39 -27
- package/dist/crdt/providers/index.d.ts +34 -6
- package/dist/crdt/providers/index.js +106 -111
- package/dist/crdt/providers/indexeddb.d.ts +2 -12
- package/dist/crdt/providers/indexeddb.js +29 -90
- package/dist/crdt/providers/room.d.ts +58 -2
- package/dist/crdt/providers/room.js +38 -21
- package/dist/crdt/providers/websocket.d.ts +1 -1
- package/dist/crdt/providers/websocket.js +3 -4
- package/dist/crdt/purge.d.ts +2 -2
- package/dist/crdt/purge.js +69 -6
- package/dist/crdt/rangeDelete.d.ts +4 -42
- package/dist/crdt/rangeDelete.js +7 -6
- package/dist/crdt/restore.d.ts +21 -1
- package/dist/crdt/restore.js +54 -59
- package/dist/crdt/schema.d.ts +2 -2
- package/dist/crdt/schema.js +4 -5
- package/dist/crdt/semantics.d.ts +10 -15
- package/dist/crdt/semantics.js +22 -21
- package/dist/crdt/storage.d.ts +7 -13
- package/dist/crdt/storage.js +10 -24
- package/dist/crdt/structs.d.ts +42 -47
- package/dist/crdt/structs.js +76 -67
- package/dist/crdt/tables.d.ts +9 -0
- package/dist/crdt/tables.js +20 -0
- package/dist/crdt/text/delete-index.d.ts +0 -13
- package/dist/crdt/text/delete-index.js +7 -14
- package/dist/crdt/text/deletes.d.ts +9 -22
- package/dist/crdt/text/deletes.js +11 -74
- package/dist/crdt/text/index/cache.js +3 -3
- package/dist/crdt/text/index/fold.d.ts +1 -2
- package/dist/crdt/text/index/fold.js +15 -10
- package/dist/crdt/text/index/layout.d.ts +0 -10
- package/dist/crdt/text/index/layout.js +6 -20
- package/dist/crdt/text/index/records.js +2 -1
- package/dist/crdt/text/index/report.js +5 -6
- package/dist/crdt/text/index/shared.d.ts +11 -4
- package/dist/crdt/text/index/shared.js +8 -7
- package/dist/crdt/text/index/state.d.ts +3 -33
- package/dist/crdt/text/index/state.js +2 -4
- package/dist/crdt/text/model.d.ts +82 -2
- package/dist/crdt/text/model.js +344 -354
- package/dist/crdt/text/rows.d.ts +0 -2
- package/dist/crdt/text/rows.js +0 -11
- package/dist/crdt/text/runs.d.ts +6 -3
- package/dist/crdt/text/runs.js +132 -137
- package/dist/crdt/text/streams.d.ts +1 -1
- package/dist/crdt/text/streams.js +1 -1
- package/dist/crdt/vendor/yjs/API-NOTES.md +25 -8
- package/dist/crdt/vendor/yjs/UPSTREAM.md +288 -8
- package/dist/crdt/vendor/yjs/dts/global.d.ts +5 -26
- package/dist/crdt/vendor/yjs/dts/index.d.ts +10 -15
- package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +2 -2
- package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +14 -219
- package/dist/crdt/vendor/yjs/dts/structs/Skip.d.ts +2 -2
- package/dist/crdt/vendor/yjs/dts/utils/BlockSet.d.ts +2 -2
- package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +12 -123
- package/dist/crdt/vendor/yjs/dts/utils/ID.d.ts +1 -1
- package/dist/crdt/vendor/yjs/dts/utils/RangeCursor.d.ts +37 -58
- package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +3 -78
- package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +2 -81
- package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +2 -74
- package/dist/crdt/vendor/yjs/dts/utils/encoding-helpers.d.ts +4 -4
- package/dist/crdt/vendor/yjs/dts/utils/encoding.d.ts +6 -18
- package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +12 -237
- package/dist/crdt/vendor/yjs/dts/utils/positions.d.ts +5 -0
- package/dist/crdt/vendor/yjs/dts/utils/redo.d.ts +3 -0
- package/dist/crdt/vendor/yjs/dts/utils/transaction-helpers.d.ts +1 -3
- package/dist/crdt/vendor/yjs/dts/utils/updates.d.ts +6 -23
- package/dist/crdt/vendor/yjs/dts/ynode.d.ts +73 -498
- package/dist/crdt/vendor/yjs/global.d.ts +5 -26
- package/dist/crdt/vendor/yjs/src/index.js +11 -25
- package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +1 -1
- package/dist/crdt/vendor/yjs/src/structs/GC.js +1 -1
- package/dist/crdt/vendor/yjs/src/structs/Item.js +10 -372
- package/dist/crdt/vendor/yjs/src/structs/Skip.js +1 -1
- package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +2 -2
- package/dist/crdt/vendor/yjs/src/utils/Doc.js +14 -170
- package/dist/crdt/vendor/yjs/src/utils/ID.js +1 -1
- package/dist/crdt/vendor/yjs/src/utils/RangeCursor.js +61 -128
- package/dist/crdt/vendor/yjs/src/utils/StructStore.js +0 -22
- package/dist/crdt/vendor/yjs/src/utils/Transaction.js +17 -282
- package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +3 -130
- package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +2 -132
- package/dist/crdt/vendor/yjs/src/utils/encoding-helpers.js +4 -4
- package/dist/crdt/vendor/yjs/src/utils/encoding.js +49 -146
- package/dist/crdt/vendor/yjs/src/utils/ids.js +23 -900
- package/dist/crdt/vendor/yjs/src/utils/positions.js +115 -0
- package/dist/crdt/vendor/yjs/src/utils/redo.js +143 -0
- package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +10 -127
- package/dist/crdt/vendor/yjs/src/utils/updates.js +7 -50
- package/dist/crdt/vendor/yjs/src/ynode.js +261 -2226
- package/dist/dnd/autoScroll.js +1 -2
- package/dist/dnd/pragmatic.d.ts +4 -22
- package/dist/dnd/pragmatic.js +7 -26
- package/dist/dnd/track.d.ts +14 -0
- package/dist/dnd/track.js +55 -0
- package/dist/dnd/vendor/pragmatic/UPSTREAM.md +103 -0
- package/dist/dnd/vendor/pragmatic/bind-event-listener/LICENSE +21 -0
- package/dist/dnd/vendor/pragmatic/bind-event-listener/bind-all.js +46 -0
- package/dist/dnd/vendor/pragmatic/bind-event-listener/bind.js +7 -0
- package/dist/dnd/vendor/pragmatic/bind-event-listener/index.js +2 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/LICENSE.md +11 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter-native-data-key.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.d.ts +57 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.js +306 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/entry-point/element/adapter.d.ts +8 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/entry-point/element/adapter.js +10 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/entry-point/element/set-custom-native-drag-preview.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/entry-point/element/set-custom-native-drag-preview.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/entry-point/types.d.ts +1 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/get-element-from-point-without-honey-pot.js +12 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/honey-pot-data-attribute.js +3 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/is-honey-pot-element.js +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/make-honey-pot-fix.js +333 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types.d.ts +350 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/ledger/dispatch-consumer-event.js +128 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/ledger/lifecycle-manager.js +340 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/ledger/usage-ledger.js +32 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-adapter.js +59 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-drop-target.js +288 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-monitor.js +85 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/combine.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.d.ts +36 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.js +153 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/types.d.ts +16 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/once.js +13 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/add-attribute.js +7 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/android.js +10 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/count-events-for-safari.js +104 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-from-another-window.js +16 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-leaving-window-in-safari.js +12 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-leaving-window.js +55 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/detect-broken-drag.js +48 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/get-input.js +14 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/is-firefox.js +13 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/is-safari.js +19 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/max-z-index.js +3 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/media-types/text-media-type.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/media-types/url-media-type.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/popover-reset-styles.js +40 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/supports-popover.js +16 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/LICENSE.md +11 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/element.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/element.js +8 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/internal-types.d.ts +50 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/data-attributes.js +9 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/get-scroll-by.js +117 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/make-api.js +90 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/try-scroll.js +183 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/axis.js +22 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/can-scroll-on-edge.js +17 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/configuration.js +49 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/edges.js +9 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/engagement-history.js +43 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-over-element-hitbox.js +50 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-percentage-in-range.js +19 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-scroll-change.js +106 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-axis-allowed.js +3 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-within.js +11 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/scheduler.js +104 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/side.js +6 -0
- package/dist/dnd/vendor/pragmatic/raf-schd/LICENSE +21 -0
- package/dist/dnd/vendor/pragmatic/raf-schd/raf-schd.esm.js +34 -0
- package/dist/edytor.svelte.d.ts +34 -64
- package/dist/edytor.svelte.js +116 -180
- package/dist/events/beforeInputCommands.d.ts +6 -11
- package/dist/events/beforeInputCommands.js +185 -181
- package/dist/events/beforeInputDeleteCommands.d.ts +20 -1
- package/dist/events/beforeInputDeleteCommands.js +153 -204
- package/dist/events/domTextOffset.d.ts +9 -9
- package/dist/events/domTextOffset.js +20 -48
- package/dist/events/events.utils.d.ts +0 -2
- package/dist/events/events.utils.js +0 -4
- package/dist/events/nativeInteractiveControl.d.ts +13 -13
- package/dist/events/nativeInteractiveControl.js +28 -56
- package/dist/events/onBeforeInput.d.ts +6 -1
- package/dist/events/onBeforeInput.js +207 -331
- package/dist/events/onCopy.js +1 -5
- package/dist/events/onDrop.d.ts +1 -1
- package/dist/events/onDrop.js +27 -69
- package/dist/events/onFocus.d.ts +9 -4
- package/dist/events/onFocus.js +45 -67
- package/dist/events/onInput.d.ts +8 -4
- package/dist/events/onInput.js +34 -147
- package/dist/events/onKeyDown.js +55 -122
- package/dist/events/onPaste.d.ts +13 -1
- package/dist/events/onPaste.js +46 -76
- package/dist/index.d.ts +10 -14
- package/dist/index.js +3 -3
- package/dist/kinds.d.ts +4 -6
- package/dist/kinds.js +28 -27
- package/dist/labels.d.ts +81 -320
- package/dist/labels.js +180 -408
- package/dist/plugins/Chrome.svelte +29 -0
- package/dist/plugins/Chrome.svelte.d.ts +32 -0
- package/dist/plugins/Control.svelte +23 -0
- package/dist/plugins/Control.svelte.d.ts +30 -0
- package/dist/plugins/anchored.svelte.d.ts +47 -0
- package/dist/plugins/anchored.svelte.js +73 -0
- package/dist/plugins/arrowMove/arrowMove.d.ts +2 -1
- package/dist/plugins/arrowMove/arrowMove.js +9 -5
- package/dist/plugins/bands.svelte.d.ts +57 -0
- package/dist/plugins/bands.svelte.js +95 -0
- package/dist/plugins/blockHandles/BlockHandle.svelte +14 -154
- package/dist/plugins/blockHandles/BlockHandle.svelte.d.ts +2 -2
- package/dist/plugins/blockHandles/BlockHandleController.svelte.d.ts +39 -94
- package/dist/plugins/blockHandles/BlockHandleController.svelte.js +190 -247
- package/dist/plugins/blockHandles/BlockHandles.svelte +27 -17
- package/dist/plugins/blockHandles/BlockHandles.svelte.d.ts +2 -2
- package/dist/plugins/blockHandles/blockHandlesPlugin.d.ts +25 -39
- package/dist/plugins/blockHandles/blockHandlesPlugin.js +129 -185
- package/dist/plugins/blockHandles/dragPreview.d.ts +8 -6
- package/dist/plugins/blockHandles/dragPreview.js +18 -16
- package/dist/plugins/blockHandles/dropIndicator.js +52 -60
- package/dist/plugins/blockHandles/geometry.d.ts +2 -1
- package/dist/plugins/blockHandles/geometry.js +6 -6
- package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +28 -38
- package/dist/plugins/blockMenu/BlockMenuController.svelte.js +116 -183
- package/dist/plugins/blockMenu/blockMenuPlugin.d.ts +1 -3
- package/dist/plugins/blockMenu/blockMenuPlugin.js +12 -29
- package/dist/plugins/brand.d.ts +8 -0
- package/dist/plugins/brand.js +8 -0
- package/dist/plugins/chrome.d.ts +45 -38
- package/dist/plugins/chrome.js +59 -36
- package/dist/plugins/code/CodeHeader.svelte +3 -35
- package/dist/plugins/code/CodePlugin.svelte +50 -53
- package/dist/plugins/code/CodePlugin.svelte.d.ts +0 -2
- package/dist/plugins/code/LanguageMenu.svelte +16 -125
- package/dist/plugins/code/LanguageMenu.svelte.d.ts +2 -1
- package/dist/plugins/code/code.css +5 -117
- package/dist/plugins/code/header.svelte.d.ts +2 -11
- package/dist/plugins/code/header.svelte.js +11 -38
- package/dist/plugins/code/languageMenu.svelte.d.ts +12 -32
- package/dist/plugins/code/languageMenu.svelte.js +30 -160
- package/dist/plugins/code/languages.d.ts +9 -19
- package/dist/plugins/code/languages.js +39 -126
- package/dist/plugins/columns/ColumnResize.svelte +13 -25
- package/dist/plugins/columns/ColumnResize.svelte.d.ts +1 -1
- package/dist/plugins/columns/ColumnsPlugin.svelte +46 -78
- package/dist/plugins/columns/ColumnsPlugin.svelte.d.ts +0 -12
- package/dist/plugins/columns/columns.css +7 -26
- package/dist/plugins/columns/resize.svelte.d.ts +14 -51
- package/dist/plugins/columns/resize.svelte.js +70 -164
- package/dist/plugins/comments/CommentsController.svelte.d.ts +1 -4
- package/dist/plugins/comments/CommentsController.svelte.js +14 -25
- package/dist/plugins/comments/CommentsSidebar.svelte +82 -431
- package/dist/plugins/comments/CommentsSidebar.svelte.d.ts +4 -2
- package/dist/plugins/comments/commentsPlugin.d.ts +25 -9
- package/dist/plugins/comments/commentsPlugin.js +12 -10
- package/dist/plugins/equation/EquationEditor.svelte +16 -130
- package/dist/plugins/equation/EquationEditor.svelte.d.ts +1 -2
- package/dist/plugins/equation/EquationPlugin.svelte +109 -165
- package/dist/plugins/equation/EquationPlugin.svelte.d.ts +2 -2
- package/dist/plugins/equation/EquationView.svelte +20 -11
- package/dist/plugins/equation/equation.svelte.d.ts +37 -24
- package/dist/plugins/equation/equation.svelte.js +20 -94
- package/dist/plugins/equation/katex.js +6 -9
- package/dist/plugins/find/FindController.svelte.d.ts +8 -13
- package/dist/plugins/find/FindController.svelte.js +34 -55
- package/dist/plugins/find/findPlugin.d.ts +4 -8
- package/dist/plugins/find/findPlugin.js +29 -9
- package/dist/plugins/image/ImageChrome.svelte +6 -167
- package/dist/plugins/image/ImageChrome.svelte.d.ts +0 -2
- package/dist/plugins/image/ImagePlugin.svelte +45 -134
- package/dist/plugins/image/ImagePlugin.svelte.d.ts +1 -42
- package/dist/plugins/image/ImageToolbarHost.svelte +37 -0
- package/dist/plugins/image/ImageToolbarHost.svelte.d.ts +9 -0
- package/dist/plugins/image/controls.svelte.d.ts +6 -36
- package/dist/plugins/image/controls.svelte.js +43 -212
- package/dist/plugins/image/image.d.ts +0 -5
- package/dist/plugins/image/image.js +0 -3
- package/dist/plugins/image/toolbar.svelte.d.ts +69 -0
- package/dist/plugins/image/toolbar.svelte.js +145 -0
- package/dist/plugins/index.d.ts +31 -26
- package/dist/plugins/index.js +29 -22
- package/dist/plugins/list.svelte.d.ts +128 -0
- package/dist/plugins/list.svelte.js +217 -0
- package/dist/plugins/markdownShortcuts.d.ts +1 -1
- package/dist/plugins/markdownShortcuts.js +6 -5
- package/dist/plugins/marquee/MarqueeBox.svelte +3 -20
- package/dist/plugins/marquee/MarqueeBox.svelte.d.ts +1 -1
- package/dist/plugins/marquee/MarqueeController.svelte.d.ts +0 -2
- package/dist/plugins/marquee/MarqueeController.svelte.js +20 -23
- package/dist/plugins/marquee/marquee.js +4 -21
- package/dist/plugins/marquee/marqueePlugin.d.ts +4 -3
- package/dist/plugins/marquee/marqueePlugin.js +16 -15
- package/dist/plugins/media/AudioPlugin.svelte +3 -90
- package/dist/plugins/media/AudioPlugin.svelte.d.ts +1 -4
- package/dist/plugins/media/BookmarkPlugin.svelte +113 -120
- package/dist/plugins/media/BookmarkPlugin.svelte.d.ts +10 -15
- package/dist/plugins/media/EmbedPlugin.svelte +82 -86
- package/dist/plugins/media/EmbedPlugin.svelte.d.ts +11 -17
- package/dist/plugins/media/EmptySlot.svelte +44 -0
- package/dist/plugins/media/EmptySlot.svelte.d.ts +25 -0
- package/dist/plugins/media/FilePlugin.svelte +35 -113
- package/dist/plugins/media/FilePlugin.svelte.d.ts +12 -4
- package/dist/plugins/media/MediaEmpty.svelte +51 -90
- package/dist/plugins/media/MediaEmpty.svelte.d.ts +26 -10
- package/dist/plugins/media/SourceBlock.svelte +164 -0
- package/dist/plugins/media/SourceBlock.svelte.d.ts +33 -0
- package/dist/plugins/media/VideoPlugin.svelte +4 -99
- package/dist/plugins/media/VideoPlugin.svelte.d.ts +2 -5
- package/dist/plugins/media/empty.svelte.d.ts +36 -44
- package/dist/plugins/media/empty.svelte.js +41 -45
- package/dist/plugins/media/media.d.ts +90 -44
- package/dist/plugins/media/media.js +77 -99
- package/dist/plugins/media/urlPaste.svelte.d.ts +6 -37
- package/dist/plugins/media/urlPaste.svelte.js +32 -102
- package/dist/plugins/mention/MentionPlugin.svelte +42 -123
- package/dist/plugins/mention/MentionPlugin.svelte.d.ts +6 -25
- package/dist/plugins/page/PageLink.svelte +54 -38
- package/dist/plugins/page/PagePlugin.svelte +20 -18
- package/dist/plugins/page/PagePlugin.svelte.d.ts +2 -4
- package/dist/plugins/page/page.d.ts +35 -9
- package/dist/plugins/page/page.js +3 -4
- package/dist/plugins/pageLink/PageLinkPlugin.svelte +47 -107
- package/dist/plugins/pageLink/PageLinkPlugin.svelte.d.ts +6 -25
- package/dist/plugins/planned.d.ts +10 -0
- package/dist/plugins/planned.js +12 -0
- package/dist/plugins/richtext/CalloutIcon.svelte +13 -26
- package/dist/plugins/richtext/CalloutIconPicker.svelte +26 -0
- package/dist/plugins/richtext/CalloutIconPicker.svelte.d.ts +9 -0
- package/dist/plugins/richtext/EmptyBody.svelte +13 -20
- package/dist/plugins/richtext/RichTextControl.svelte +39 -0
- package/dist/plugins/richtext/RichTextControl.svelte.d.ts +8 -0
- package/dist/plugins/richtext/RichTextPlugin.svelte +161 -177
- package/dist/plugins/richtext/RichTextPlugin.svelte.d.ts +33 -34
- package/dist/plugins/richtext/TodoCheckbox.svelte +10 -21
- package/dist/plugins/richtext/TodoCheckbox.svelte.d.ts +0 -2
- package/dist/plugins/richtext/body.js +2 -2
- package/dist/plugins/richtext/calloutIcons.svelte.d.ts +50 -55
- package/dist/plugins/richtext/calloutIcons.svelte.js +86 -174
- package/dist/plugins/richtext/callouts.d.ts +15 -0
- package/dist/plugins/richtext/callouts.js +23 -0
- package/dist/plugins/richtext/controls.svelte.d.ts +110 -0
- package/dist/plugins/richtext/controls.svelte.js +126 -0
- package/dist/plugins/richtext/richTextOperations.js +37 -28
- package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +2 -14
- package/dist/plugins/slashMenu/SlashMenuController.svelte.js +34 -71
- package/dist/plugins/slashMenu/slashMenuPlugin.d.ts +9 -26
- package/dist/plugins/slashMenu/slashMenuPlugin.js +27 -68
- package/dist/plugins/suggestions/SuggestionBars.svelte +27 -84
- package/dist/plugins/suggestions/SuggestionBars.svelte.d.ts +9 -3
- package/dist/plugins/suggestions/suggestionsPlugin.d.ts +10 -18
- package/dist/plugins/suggestions/suggestionsPlugin.js +9 -24
- package/dist/plugins/table/TableChrome.svelte +40 -124
- package/dist/plugins/table/TablePlugin.svelte +106 -168
- package/dist/plugins/table/TablePlugin.svelte.d.ts +0 -4
- package/dist/plugins/table/chrome.svelte.d.ts +38 -141
- package/dist/plugins/table/chrome.svelte.js +339 -589
- package/dist/plugins/table/ops.d.ts +47 -0
- package/dist/plugins/table/ops.js +233 -0
- package/dist/plugins/table/table.css +16 -152
- package/dist/plugins/table/table.d.ts +15 -14
- package/dist/plugins/table/table.js +22 -16
- package/dist/plugins/toc/TableOfContents.svelte +32 -38
- package/dist/plugins/toc/TableOfContents.svelte.d.ts +1 -5
- package/dist/plugins/toc/TocPlugin.svelte +22 -22
- package/dist/plugins/toc/TocPlugin.svelte.d.ts +4 -6
- package/dist/plugins/toc/toc.d.ts +41 -10
- package/dist/plugins/toc/toc.js +2 -3
- package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +4 -68
- package/dist/plugins/toolbar/ToolbarController.svelte.js +63 -89
- package/dist/plugins/toolbar/toolbarPlugin.d.ts +8 -18
- package/dist/plugins/toolbar/toolbarPlugin.js +28 -43
- package/dist/plugins/triggers/TriggerController.svelte.d.ts +4 -68
- package/dist/plugins/triggers/TriggerController.svelte.js +48 -129
- package/dist/plugins/triggers/place.d.ts +0 -9
- package/dist/plugins/triggers/place.js +1 -17
- package/dist/plugins/triggers/triggers.d.ts +31 -9
- package/dist/plugins/triggers/triggers.js +82 -62
- package/dist/plugins/uploads.svelte.d.ts +38 -20
- package/dist/plugins/uploads.svelte.js +39 -32
- package/dist/plugins.d.ts +154 -59
- package/dist/selection/domSelection.d.ts +13 -4
- package/dist/selection/domSelection.js +110 -183
- package/dist/selection/pointer.svelte.d.ts +8 -10
- package/dist/selection/pointer.svelte.js +32 -73
- package/dist/selection/replaceSelection.d.ts +21 -22
- package/dist/selection/replaceSelection.js +60 -69
- package/dist/selection/selection.svelte.d.ts +5 -73
- package/dist/selection/selection.svelte.js +224 -542
- package/dist/selection/selection.utils.d.ts +34 -11
- package/dist/selection/selection.utils.js +128 -247
- package/dist/selection/visibility.d.ts +3 -8
- package/dist/selection/visibility.js +7 -5
- package/dist/session/announcer.svelte.d.ts +2 -1
- package/dist/session/announcer.svelte.js +7 -3
- package/dist/session/attempt.d.ts +33 -39
- package/dist/session/attempt.js +61 -55
- package/dist/session/bindings.js +108 -139
- package/dist/session/commands.d.ts +47 -22
- package/dist/session/commands.js +206 -208
- package/dist/session/composition.svelte.d.ts +2 -4
- package/dist/session/composition.svelte.js +55 -65
- package/dist/session/editing/text.d.ts +6 -0
- package/dist/session/editing/text.js +17 -3
- package/dist/session/handles.d.ts +10 -1
- package/dist/session/handles.js +28 -0
- package/dist/session/history.d.ts +0 -4
- package/dist/session/history.js +15 -21
- package/dist/session/inputRules.js +75 -84
- package/dist/session/keymap.d.ts +1 -6
- package/dist/session/keymap.js +17 -20
- package/dist/session/moves.d.ts +10 -10
- package/dist/session/moves.js +31 -59
- package/dist/session/navigation.d.ts +3 -2
- package/dist/session/navigation.js +127 -168
- package/dist/session/ports.d.ts +2 -7
- package/dist/session/selection.d.ts +4 -3
- package/dist/session/selection.js +5 -0
- package/dist/session/suggestions.svelte.d.ts +1 -1
- package/dist/session/suggestions.svelte.js +42 -47
- package/dist/session/virtual.d.ts +3 -3
- package/dist/session/virtual.js +18 -40
- package/dist/surface/attributes.d.ts +1 -0
- package/dist/surface/attributes.js +3 -26
- package/dist/surface/cells.d.ts +5 -0
- package/dist/surface/cells.js +5 -0
- package/dist/surface/lines.d.ts +2 -2
- package/dist/surface/lines.js +1 -1
- package/dist/surface/observer.svelte.d.ts +3 -20
- package/dist/surface/observer.svelte.js +52 -72
- package/dist/surface/overlay.d.ts +41 -3
- package/dist/surface/overlay.js +92 -37
- package/dist/surface/pin.svelte.d.ts +5 -0
- package/dist/surface/pin.svelte.js +5 -0
- package/dist/surface/projector.svelte.d.ts +4 -6
- package/dist/surface/projector.svelte.js +42 -69
- package/dist/text/text.svelte.d.ts +14 -40
- package/dist/text/text.svelte.js +35 -51
- package/dist/text/wordBoundary.d.ts +19 -0
- package/dist/text/wordBoundary.js +29 -44
- package/dist/themes/notion.css +263 -106
- package/dist/utils/json.d.ts +3 -1
- package/dist/utils/json.js +52 -51
- package/dist/utils/listen.d.ts +8 -0
- package/dist/utils/listen.js +19 -0
- package/package.json +4 -5
- package/dist/block/block.utils.d.ts +0 -340
- package/dist/block/block.utils.js +0 -356
- package/dist/collaboration/history/HistoryPanel.svelte +0 -554
- package/dist/collaboration/history/HistoryPanel.svelte.d.ts +0 -7
- package/dist/collaboration/history/panel.d.ts +0 -61
- package/dist/collaboration/history/panel.js +0 -3
- package/dist/components/SuggestionRanges.svelte +0 -58
- package/dist/components/SuggestionRanges.svelte.d.ts +0 -7
- package/dist/crdt/doc/table.d.ts +0 -21
- package/dist/crdt/doc/table.js +0 -288
- package/dist/crdt/migration/generation.d.ts +0 -58
- package/dist/crdt/migration/generation.js +0 -70
- package/dist/crdt/migration/legacy-schema.d.ts +0 -61
- package/dist/crdt/migration/legacy-schema.js +0 -151
- package/dist/crdt/migration/migrate.d.ts +0 -56
- package/dist/crdt/migration/migrate.js +0 -227
- package/dist/crdt/nodes.d.ts +0 -121
- package/dist/crdt/nodes.js +0 -56
- package/dist/crdt/text/index/checks.d.ts +0 -15
- package/dist/crdt/text/index/checks.js +0 -156
- package/dist/crdt/vendor/yjs/dts/utils/EventHandler.d.ts +0 -17
- package/dist/crdt/vendor/yjs/dts/utils/RelativePosition.d.ts +0 -80
- package/dist/crdt/vendor/yjs/dts/utils/UndoManager.d.ts +0 -205
- package/dist/crdt/vendor/yjs/dts/utils/YEvent.d.ts +0 -93
- package/dist/crdt/vendor/yjs/dts/utils/meta.d.ts +0 -25
- package/dist/crdt/vendor/yjs/dts/utils/renderer-helpers.d.ts +0 -98
- package/dist/crdt/vendor/yjs/dts/utils/schemas.d.ts +0 -2
- package/dist/crdt/vendor/yjs/src/utils/EventHandler.js +0 -75
- package/dist/crdt/vendor/yjs/src/utils/RelativePosition.js +0 -301
- package/dist/crdt/vendor/yjs/src/utils/UndoManager.js +0 -554
- package/dist/crdt/vendor/yjs/src/utils/YEvent.js +0 -158
- package/dist/crdt/vendor/yjs/src/utils/meta.js +0 -74
- package/dist/crdt/vendor/yjs/src/utils/renderer-helpers.js +0 -186
- package/dist/crdt/vendor/yjs/src/utils/schemas.js +0 -3
- package/dist/edytor.utils.d.ts +0 -50
- package/dist/edytor.utils.js +0 -67
- package/dist/plugins/blockMenu/BlockMenu.svelte +0 -335
- package/dist/plugins/blockMenu/BlockMenu.svelte.d.ts +0 -9
- package/dist/plugins/find/FindBar.svelte +0 -170
- package/dist/plugins/find/FindBar.svelte.d.ts +0 -9
- package/dist/plugins/find/FindHighlights.svelte +0 -75
- package/dist/plugins/find/FindHighlights.svelte.d.ts +0 -9
- package/dist/plugins/icons.d.ts +0 -2
- package/dist/plugins/icons.js +0 -63
- package/dist/plugins/image/ImageEmpty.svelte +0 -93
- package/dist/plugins/image/ImageEmpty.svelte.d.ts +0 -15
- package/dist/plugins/image/empty.svelte.d.ts +0 -56
- package/dist/plugins/image/empty.svelte.js +0 -83
- package/dist/plugins/keepInView.d.ts +0 -4
- package/dist/plugins/keepInView.js +0 -6
- package/dist/plugins/media/UrlPasteMenu.svelte +0 -92
- package/dist/plugins/media/UrlPasteMenu.svelte.d.ts +0 -9
- package/dist/plugins/richtext/CalloutIconMenu.svelte +0 -98
- package/dist/plugins/richtext/CalloutIconMenu.svelte.d.ts +0 -9
- package/dist/plugins/richtext/labels.d.ts +0 -9
- package/dist/plugins/richtext/labels.js +0 -7
- package/dist/plugins/slashMenu/SlashMenu.svelte +0 -276
- package/dist/plugins/slashMenu/SlashMenu.svelte.d.ts +0 -11
- package/dist/plugins/table/dragPreview.d.ts +0 -29
- package/dist/plugins/table/dragPreview.js +0 -103
- package/dist/plugins/toolbar/LinkCard.svelte +0 -122
- package/dist/plugins/toolbar/LinkCard.svelte.d.ts +0 -9
- package/dist/plugins/toolbar/Toolbar.svelte +0 -349
- package/dist/plugins/toolbar/Toolbar.svelte.d.ts +0 -9
- package/dist/plugins/triggers/TriggerMenu.svelte +0 -135
- package/dist/plugins/triggers/TriggerMenu.svelte.d.ts +0 -7
- package/dist/session/props.d.ts +0 -28
- package/dist/session/props.js +0 -162
- package/dist/text/deltas.d.ts +0 -22
- package/dist/text/deltas.js +0 -46
- package/dist/text/text.utils.d.ts +0 -45
- package/dist/text/text.utils.js +0 -199
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* and undoing that restore. The stores themselves are `../history.ts`.
|
|
6
6
|
*/
|
|
7
7
|
import { Y } from '../../crdt/engine.js';
|
|
8
|
-
import * as E from '../../crdt/protocol.js';
|
|
9
8
|
import { gunzip, packed } from '../../crdt/storage.js';
|
|
10
9
|
import { asEngineDoc, collectable, collectNow, collects, engineOps, stepsOf } from '../../crdt/structs.js';
|
|
11
10
|
import { PURGE_ORIGIN, RESTORE_ORIGIN, noTimers } from './shared.js';
|
|
@@ -21,9 +20,9 @@ export class RoomHistory {
|
|
|
21
20
|
/** Who the room writes for while a restore or its undo runs (the slot's editor). */
|
|
22
21
|
writer = null;
|
|
23
22
|
/** The last restore's step (`room.history.undo`), read from the `restore` table at load. */
|
|
24
|
-
restoreStep = null;
|
|
23
|
+
#restoreStep = null;
|
|
25
24
|
/** The history recording restores (`RESTORE_ORIGIN`), on the live facade. */
|
|
26
|
-
restoreManager = null;
|
|
25
|
+
#restoreManager = null;
|
|
27
26
|
/** The version writes in flight (`historyWritten()`). */
|
|
28
27
|
writing = Promise.resolve();
|
|
29
28
|
_config;
|
|
@@ -94,24 +93,24 @@ export class RoomHistory {
|
|
|
94
93
|
const room = this.room;
|
|
95
94
|
if ((room.scheduler.due('history') ?? Infinity) > room.clock())
|
|
96
95
|
return;
|
|
97
|
-
const captured = this
|
|
96
|
+
const captured = this.#captureSlot();
|
|
98
97
|
if (captured === null)
|
|
99
98
|
return;
|
|
100
|
-
const job = this
|
|
99
|
+
const job = this.#putSlot(captured);
|
|
101
100
|
this.writing = Promise.all([this.writing, job]);
|
|
102
101
|
room.ctx.waitUntil?.(job);
|
|
103
102
|
}
|
|
104
103
|
/** Close the open slot: capture it now, write it (the alarm, a start past its end). */
|
|
105
104
|
async closeSlot() {
|
|
106
|
-
const captured = this
|
|
105
|
+
const captured = this.#captureSlot();
|
|
107
106
|
if (captured !== null)
|
|
108
|
-
await this
|
|
107
|
+
await this.#putSlot(captured);
|
|
109
108
|
}
|
|
110
109
|
/**
|
|
111
110
|
* The open slot's version, read now (synchronous: nothing writes
|
|
112
111
|
* between the read and the slot's close), and the slot closed.
|
|
113
112
|
*/
|
|
114
|
-
captureSlot() {
|
|
113
|
+
#captureSlot() {
|
|
115
114
|
const room = this.room;
|
|
116
115
|
const { scheduler } = room;
|
|
117
116
|
const end = scheduler.due('history');
|
|
@@ -125,7 +124,7 @@ export class RoomHistory {
|
|
|
125
124
|
if (room.live === null) {
|
|
126
125
|
// No document to read (its rows unreadable, or refused): that slot is skipped.
|
|
127
126
|
scheduler.unschedule('history');
|
|
128
|
-
this
|
|
127
|
+
this.#skipVersion({
|
|
129
128
|
key: historyKey(this.room.roomId, slotAt(end - 1, config.timeZone)),
|
|
130
129
|
error: 'room unavailable'
|
|
131
130
|
});
|
|
@@ -144,20 +143,20 @@ export class RoomHistory {
|
|
|
144
143
|
this.slotEditors.clear();
|
|
145
144
|
scheduler.unschedule('history');
|
|
146
145
|
if (key === null) {
|
|
147
|
-
this
|
|
146
|
+
this.#skipVersion({ room: this.room.roomId, reason: 'key longer than 512 bytes' });
|
|
148
147
|
return null;
|
|
149
148
|
}
|
|
150
149
|
return { key, raw, blocks, editors, at: room.clock() };
|
|
151
150
|
});
|
|
152
151
|
}
|
|
153
152
|
/** Write a captured version (`room.history.value`); a failure is noted `history` and the slot skipped. */
|
|
154
|
-
async putSlot(version) {
|
|
153
|
+
async #putSlot(version) {
|
|
155
154
|
const room = this.room;
|
|
156
155
|
const config = this.config;
|
|
157
156
|
try {
|
|
158
157
|
const bytes = await packed(version.raw);
|
|
159
158
|
if (bytes.length > config.maxValueBytes) {
|
|
160
|
-
return this
|
|
159
|
+
return this.#skipVersion({
|
|
161
160
|
key: version.key,
|
|
162
161
|
bytes: bytes.length,
|
|
163
162
|
limit: config.maxValueBytes
|
|
@@ -184,15 +183,15 @@ export class RoomHistory {
|
|
|
184
183
|
});
|
|
185
184
|
}
|
|
186
185
|
catch (error) {
|
|
187
|
-
this
|
|
186
|
+
this.#skipVersion({ key: version.key, error: String(error) });
|
|
188
187
|
}
|
|
189
188
|
}
|
|
190
|
-
skipVersion(detail) {
|
|
189
|
+
#skipVersion(detail) {
|
|
191
190
|
this.room.counters.history.skipped++;
|
|
192
191
|
this.room.note({ reason: 'history', detail });
|
|
193
192
|
}
|
|
194
193
|
/** The history settings, or a throw: the room keeps no history. */
|
|
195
|
-
requireHistory() {
|
|
194
|
+
#requireHistory() {
|
|
196
195
|
const config = this.config;
|
|
197
196
|
if (config === null)
|
|
198
197
|
throw new Error('this room keeps no history (the `history` option)');
|
|
@@ -205,10 +204,10 @@ export class RoomHistory {
|
|
|
205
204
|
// ── Versions ─────────────────────────────────────────────────────────
|
|
206
205
|
/** The room's versions, newest first (`AttachedDocument.listHistory`). */
|
|
207
206
|
async list() {
|
|
208
|
-
const config = this
|
|
207
|
+
const config = this.#requireHistory();
|
|
209
208
|
const now = this.room.clock();
|
|
210
209
|
const out = [];
|
|
211
|
-
for await (const { key, expiresAt, metadata } of this
|
|
210
|
+
for await (const { key, expiresAt, metadata } of this.#storedVersions(config.store)) {
|
|
212
211
|
// Past its expiry it is gone, whether or not the store deleted it yet.
|
|
213
212
|
if (expiresAt !== null && expiresAt <= now)
|
|
214
213
|
continue;
|
|
@@ -219,7 +218,7 @@ export class RoomHistory {
|
|
|
219
218
|
return out.sort((a, b) => (a.key < b.key ? 1 : a.key > b.key ? -1 : 0));
|
|
220
219
|
}
|
|
221
220
|
/** Every version key the store holds under this room's prefix, page by page. */
|
|
222
|
-
async
|
|
221
|
+
async *#storedVersions(store) {
|
|
223
222
|
const prefix = historyPrefix(this.room.roomId);
|
|
224
223
|
let cursor;
|
|
225
224
|
do {
|
|
@@ -244,7 +243,7 @@ export class RoomHistory {
|
|
|
244
243
|
let next = Infinity;
|
|
245
244
|
try {
|
|
246
245
|
const expired = [];
|
|
247
|
-
for await (const { key, expiresAt } of this
|
|
246
|
+
for await (const { key, expiresAt } of this.#storedVersions(config.store)) {
|
|
248
247
|
if (expiresAt === null || parseHistoryKey(this.room.roomId, key) === null)
|
|
249
248
|
continue;
|
|
250
249
|
if (expiresAt <= now)
|
|
@@ -267,7 +266,7 @@ export class RoomHistory {
|
|
|
267
266
|
/** Version `key` as JSON (`AttachedDocument.readHistory`). */
|
|
268
267
|
async read(key) {
|
|
269
268
|
const room = this.room;
|
|
270
|
-
const config = this
|
|
269
|
+
const config = this.#requireHistory();
|
|
271
270
|
if (parseHistoryKey(this.room.roomId, key) === null)
|
|
272
271
|
return null;
|
|
273
272
|
const found = await config.store.get(key);
|
|
@@ -275,17 +274,7 @@ export class RoomHistory {
|
|
|
275
274
|
return null;
|
|
276
275
|
const bytes = await gunzip(found.value);
|
|
277
276
|
return noTimers(() => {
|
|
278
|
-
|
|
279
|
-
try {
|
|
280
|
-
doc = admit([{ v2: bytes }], `room ${room.ctx.id} version ${key}`, () => null);
|
|
281
|
-
}
|
|
282
|
-
catch (error) {
|
|
283
|
-
// A version written by generation 4 reads through its JSON (`room.generation.convert`).
|
|
284
|
-
const problem = error.problem;
|
|
285
|
-
if (problem?.kind !== 'unsupported' || problem.version !== E.PREVIOUS_SCHEMA)
|
|
286
|
-
throw error;
|
|
287
|
-
return crdt.generations.previousJSON([{ v2: bytes }], (d) => room.facadeOf(d));
|
|
288
|
-
}
|
|
277
|
+
const doc = admit(bytes, `room ${room.ctx.id} version ${key}`, () => null);
|
|
289
278
|
const facade = room.facadeOf(doc);
|
|
290
279
|
try {
|
|
291
280
|
return facade.toJSON();
|
|
@@ -299,7 +288,7 @@ export class RoomHistory {
|
|
|
299
288
|
// ── Restores (`room.history.restore`, `room.history.undo`) ───────────
|
|
300
289
|
/** The last restore's deleted content, kept for its undo (`prepareRoomDoc`). */
|
|
301
290
|
get restoreKeep() {
|
|
302
|
-
return this
|
|
291
|
+
return this.#restoreStep?.deletes ?? null;
|
|
303
292
|
}
|
|
304
293
|
/** Restore version `key` as a forward edit (`AttachedDocument.restoreHistory`). */
|
|
305
294
|
async restore(key, options = {}) {
|
|
@@ -315,9 +304,9 @@ export class RoomHistory {
|
|
|
315
304
|
room.storage.heal();
|
|
316
305
|
const doc = room.requireDoc();
|
|
317
306
|
this.closeSlotIfPast();
|
|
318
|
-
const history = this
|
|
307
|
+
const history = this.#restoreHistoryOf();
|
|
319
308
|
// One level: the previous restore's step goes.
|
|
320
|
-
this
|
|
309
|
+
this.#dropRestore();
|
|
321
310
|
this.writer = options.user ?? null;
|
|
322
311
|
let report;
|
|
323
312
|
room.transacting = true;
|
|
@@ -346,7 +335,7 @@ export class RoomHistory {
|
|
|
346
335
|
deletes: step.deletes
|
|
347
336
|
};
|
|
348
337
|
room.sql.exec(`INSERT OR REPLACE INTO ${room.tables.restore} (id, key, user, at, inserts, deletes) VALUES (0, ?, ?, ?, ?, ?)`, kept.key, kept.user, kept.at, deletesUpdate(kept.inserts), deletesUpdate(kept.deletes));
|
|
349
|
-
this
|
|
338
|
+
this.#restoreStep = kept;
|
|
350
339
|
room.log({ edytor: 'restore', key, user: kept.user, undo: false });
|
|
351
340
|
room.storage.compactIfDue();
|
|
352
341
|
return { status: 'applied', key, ...report };
|
|
@@ -362,10 +351,10 @@ export class RoomHistory {
|
|
|
362
351
|
}
|
|
363
352
|
room.storage.heal();
|
|
364
353
|
room.requireDoc();
|
|
365
|
-
const step = this
|
|
354
|
+
const step = this.#restoreStep;
|
|
366
355
|
if (step === null)
|
|
367
356
|
return { status: 'noop' };
|
|
368
|
-
const history = this
|
|
357
|
+
const history = this.#restoreHistoryOf();
|
|
369
358
|
// A woken room rebuilds the step from its table.
|
|
370
359
|
if (history.undoStack.length === 0) {
|
|
371
360
|
stepsOf(history.undoStack).push({
|
|
@@ -390,15 +379,15 @@ export class RoomHistory {
|
|
|
390
379
|
room.storage.heal();
|
|
391
380
|
throw error;
|
|
392
381
|
}
|
|
393
|
-
this
|
|
382
|
+
this.#dropRestore();
|
|
394
383
|
room.log({ edytor: 'restore', key: step.key, user: options.user ?? null, undo: true });
|
|
395
384
|
room.storage.compactIfDue();
|
|
396
385
|
return { status: undone ? 'applied' : 'noop' };
|
|
397
386
|
});
|
|
398
387
|
}
|
|
399
388
|
/** The history recording restores, on the live facade (`RESTORE_ORIGIN` only, one step each). */
|
|
400
|
-
restoreHistoryOf() {
|
|
401
|
-
return (this
|
|
389
|
+
#restoreHistoryOf() {
|
|
390
|
+
return (this.#restoreManager ??= this.room.facade.createUndoManager({
|
|
402
391
|
captureTimeout: 0,
|
|
403
392
|
trackedOrigins: new Set([RESTORE_ORIGIN])
|
|
404
393
|
}));
|
|
@@ -408,7 +397,7 @@ export class RoomHistory {
|
|
|
408
397
|
const row = this.room.sql
|
|
409
398
|
.exec(`SELECT key, user, at, inserts, deletes FROM ${this.room.tables.restore} WHERE id = 0`)
|
|
410
399
|
.toArray()[0];
|
|
411
|
-
this
|
|
400
|
+
this.#restoreStep =
|
|
412
401
|
row === undefined
|
|
413
402
|
? null
|
|
414
403
|
: {
|
|
@@ -419,38 +408,34 @@ export class RoomHistory {
|
|
|
419
408
|
deletes: Y.decodeUpdate(new Uint8Array(row.deletes)).ds
|
|
420
409
|
};
|
|
421
410
|
}
|
|
422
|
-
/** Forget the last restore's step (its table was emptied: a conversion). */
|
|
423
|
-
clearRestore() {
|
|
424
|
-
this.restoreStep = null;
|
|
425
|
-
}
|
|
426
411
|
/** Forget the restore's step and the open slot's editors (a reset dropped their tables). */
|
|
427
412
|
forget() {
|
|
428
|
-
this
|
|
413
|
+
this.#restoreStep = null;
|
|
429
414
|
this.slotEditors.clear();
|
|
430
415
|
}
|
|
431
416
|
/** The live document was replaced: the restore history recorded the old one. */
|
|
432
417
|
detach() {
|
|
433
|
-
this
|
|
418
|
+
this.#restoreManager = null;
|
|
434
419
|
}
|
|
435
420
|
/** A restore past the purge horizon `at` can no longer be undone. */
|
|
436
421
|
expireRestore(at) {
|
|
437
|
-
if (this
|
|
438
|
-
this
|
|
422
|
+
if (this.#restoreStep !== null && this.#restoreStep.at <= at)
|
|
423
|
+
this.#dropRestore();
|
|
439
424
|
}
|
|
440
425
|
/**
|
|
441
426
|
* Forget the last restore's step: its table row goes, then what it kept
|
|
442
427
|
* is released and collected (the next compaction stores it collected).
|
|
443
428
|
*/
|
|
444
|
-
dropRestore() {
|
|
429
|
+
#dropRestore() {
|
|
445
430
|
const room = this.room;
|
|
446
|
-
const step = this
|
|
431
|
+
const step = this.#restoreStep;
|
|
447
432
|
if (step === null)
|
|
448
433
|
return;
|
|
449
|
-
this
|
|
434
|
+
this.#restoreStep = null;
|
|
450
435
|
room.sql.exec(`DELETE FROM ${room.tables.restore}`);
|
|
451
|
-
const history = this
|
|
436
|
+
const history = this.#restoreManager;
|
|
452
437
|
if (history !== null)
|
|
453
|
-
|
|
438
|
+
history.clear();
|
|
454
439
|
const doc = room.live;
|
|
455
440
|
if (doc === null)
|
|
456
441
|
return;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { type CommitResult, type ExportedBlocks, type ImportReceipt, type ImportRequest, type LateEditBatch } from '../move.js';
|
|
2
2
|
import { type RoomContext } from './context.js';
|
|
3
3
|
export declare class RoomMoves {
|
|
4
|
+
#private;
|
|
4
5
|
private readonly room;
|
|
5
6
|
/** The blocks moved out and watched for late edits, by id → their move (`null`: not read yet). */
|
|
6
7
|
private watched;
|
|
7
8
|
constructor(room: RoomContext);
|
|
8
9
|
/** Forget the watched blocks (a reset dropped the moves table). */
|
|
9
10
|
forget(): void;
|
|
10
|
-
private ensureMoves;
|
|
11
|
-
/** One move's row. */
|
|
12
|
-
private moveRow;
|
|
13
11
|
/** Days a moved-out block is watched for late edits: the purge horizon, else {@link DEFAULT_MOVE_GRACE_DAYS}. */
|
|
14
12
|
private get graceMs();
|
|
15
13
|
/** Export blocks `ids` for a move (`AttachedDocument.exportBlocks`). */
|
|
@@ -35,12 +33,6 @@ export declare class RoomMoves {
|
|
|
35
33
|
applied: number;
|
|
36
34
|
skipped: string[];
|
|
37
35
|
};
|
|
38
|
-
/** One block's late edit, merged into what it holds (inside a room transaction). */
|
|
39
|
-
private mergeLateEdit;
|
|
40
|
-
/** The registry entries carrying a `del.<marker>` mark written between clocks `c0` and `c1`. */
|
|
41
|
-
private markedBetween;
|
|
42
|
-
/** The moved-out blocks watched for late edits (`room.move.late`), by id → their move. */
|
|
43
|
-
private watchedBlocks;
|
|
44
36
|
/** A transaction that changed a watched block marks its move dirty (inside the `update` emit: no doc write). */
|
|
45
37
|
noteLateEdits(tr: {
|
|
46
38
|
changed?: Map<unknown, Set<string | null>>;
|
|
@@ -53,8 +45,4 @@ export declare class RoomMoves {
|
|
|
53
45
|
* grace period. A forward that fails runs again a minute later.
|
|
54
46
|
*/
|
|
55
47
|
forwardMoves(): Promise<void>;
|
|
56
|
-
/** The document's blocks as they show without the deletes of `moves`' commits: a copy, read once. */
|
|
57
|
-
private withoutMoveDeletes;
|
|
58
|
-
/** One dirty move's changes since its last batch, as a new batch of late edits (or a report). */
|
|
59
|
-
private collectLateEdits;
|
|
60
48
|
}
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
import { Y } from '../../crdt/engine.js';
|
|
8
8
|
import { DEL_PREFIX, REGISTRY_KEY } from '../../crdt/schema.js';
|
|
9
9
|
import { asEngineDoc, attrItems } from '../../crdt/structs.js';
|
|
10
|
-
import { toBlockSpec } from '../../utils/json.js';
|
|
10
|
+
import { jsonContentToItems, toBlockSpec } from '../../utils/json.js';
|
|
11
|
+
import { rewriteContent, unitsOf } from '../../crdt/restore.js';
|
|
11
12
|
import { noTimers } from './shared.js';
|
|
12
|
-
import { DEFAULT_MOVE_GRACE_DAYS,
|
|
13
|
+
import { DEFAULT_MOVE_GRACE_DAYS, flattenMoved, mergeData, subtreesOf, threeWay } from '../move.js';
|
|
13
14
|
import { DAY, crdt } from './context.js';
|
|
14
15
|
/** A forward of late edits that failed runs again this much later (`room.move.late`). */
|
|
15
16
|
const FORWARD_RETRY = 60_000;
|
|
@@ -24,7 +25,7 @@ export class RoomMoves {
|
|
|
24
25
|
forget() {
|
|
25
26
|
this.watched = null;
|
|
26
27
|
}
|
|
27
|
-
ensureMoves() {
|
|
28
|
+
#ensureMoves() {
|
|
28
29
|
const { sql, tables } = this.room;
|
|
29
30
|
sql.exec(`CREATE TABLE IF NOT EXISTS ${tables.moves} (
|
|
30
31
|
id TEXT PRIMARY KEY,
|
|
@@ -45,8 +46,8 @@ export class RoomMoves {
|
|
|
45
46
|
sql.exec(`CREATE TABLE IF NOT EXISTS ${tables.late} (move TEXT NOT NULL, seq INTEGER NOT NULL, edits TEXT NOT NULL, PRIMARY KEY (move, seq))`);
|
|
46
47
|
}
|
|
47
48
|
/** One move's row. */
|
|
48
|
-
moveRow(id, role) {
|
|
49
|
-
this
|
|
49
|
+
#moveRow(id, role) {
|
|
50
|
+
this.#ensureMoves();
|
|
50
51
|
return this.room.sql
|
|
51
52
|
.exec(`SELECT * FROM ${this.room.tables.moves} WHERE id = ? AND role = ?`, id, role)
|
|
52
53
|
.toArray()[0];
|
|
@@ -65,7 +66,7 @@ export class RoomMoves {
|
|
|
65
66
|
if (blocks.length === 0)
|
|
66
67
|
throw new Error('exportBlocks: none of these blocks shows');
|
|
67
68
|
const moveId = crypto.randomUUID();
|
|
68
|
-
this
|
|
69
|
+
this.#ensureMoves();
|
|
69
70
|
room.sql.exec(`INSERT INTO ${room.tables.moves} (id, role, state, roots, sent, at) VALUES (?, 'out', 'exported', ?, ?, ?)`, moveId, JSON.stringify(blocks.map((b) => b.id)), JSON.stringify(blocks), room.clock());
|
|
70
71
|
return { moveId, blocks };
|
|
71
72
|
});
|
|
@@ -74,7 +75,7 @@ export class RoomMoves {
|
|
|
74
75
|
importBlocks(request) {
|
|
75
76
|
const room = this.room;
|
|
76
77
|
return noTimers(() => {
|
|
77
|
-
const known = this
|
|
78
|
+
const known = this.#moveRow(request.moveId, 'in');
|
|
78
79
|
if (known !== undefined)
|
|
79
80
|
return { moveId: request.moveId, status: 'applied', ids: JSON.parse(known.map) };
|
|
80
81
|
const facade = room.facade;
|
|
@@ -118,7 +119,7 @@ export class RoomMoves {
|
|
|
118
119
|
commitMove(moveId, receipt) {
|
|
119
120
|
const room = this.room;
|
|
120
121
|
return noTimers(() => {
|
|
121
|
-
const row = this
|
|
122
|
+
const row = this.#moveRow(moveId, 'out');
|
|
122
123
|
if (row === undefined)
|
|
123
124
|
return { moveId, status: 'refused', reason: 'unknown move' };
|
|
124
125
|
if (row.state === 'moved' || row.state === 'done')
|
|
@@ -135,7 +136,7 @@ export class RoomMoves {
|
|
|
135
136
|
f.apply(f.prepare.deleteBlock(id, { keepChildren: false }));
|
|
136
137
|
});
|
|
137
138
|
const c1 = doc.store.getClock(marker);
|
|
138
|
-
const watched = this
|
|
139
|
+
const watched = this.#markedBetween(room.requireDoc(), marker, c0, c1);
|
|
139
140
|
room.sql.exec(`UPDATE ${room.tables.moves} SET state = 'moved', peer = ?, map = ?, marker = ?, c0 = ?, c1 = ?, watched = ?, at = ?, dirty = 1 WHERE id = ? AND role = 'out'`, receipt.to, JSON.stringify(receipt.ids), marker, c0, c1, JSON.stringify(watched), room.clock(), moveId);
|
|
140
141
|
this.watched = null;
|
|
141
142
|
room.scheduler.schedule('forward', room.clock(), 'earlier');
|
|
@@ -145,8 +146,8 @@ export class RoomMoves {
|
|
|
145
146
|
}
|
|
146
147
|
/** Drop an export that was not committed (`AttachedDocument.abortMove`). */
|
|
147
148
|
abortMove(moveId) {
|
|
148
|
-
this
|
|
149
|
-
const row = this
|
|
149
|
+
this.#ensureMoves();
|
|
150
|
+
const row = this.#moveRow(moveId, 'out');
|
|
150
151
|
if (row?.state !== 'exported')
|
|
151
152
|
return { moveId, status: 'noop' };
|
|
152
153
|
this.room.sql.exec(`UPDATE ${this.room.tables.moves} SET state = 'aborted', sent = '[]' WHERE id = ? AND role = 'out'`, moveId);
|
|
@@ -155,7 +156,7 @@ export class RoomMoves {
|
|
|
155
156
|
/** The late edits waiting to reach their destination, oldest first. */
|
|
156
157
|
lateEdits() {
|
|
157
158
|
const { sql, tables } = this.room;
|
|
158
|
-
this
|
|
159
|
+
this.#ensureMoves();
|
|
159
160
|
return sql
|
|
160
161
|
.exec(`SELECT l.move AS move, l.seq AS seq, l.edits AS edits, m.peer AS peer FROM ${tables.late} l JOIN ${tables.moves} m ON m.id = l.move AND m.role = 'out' ORDER BY l.move, l.seq`)
|
|
161
162
|
.toArray()
|
|
@@ -169,13 +170,13 @@ export class RoomMoves {
|
|
|
169
170
|
}
|
|
170
171
|
/** The destination applied a move's late edits through `seq`: they are dropped here. */
|
|
171
172
|
ackLateEdits(moveId, seq) {
|
|
172
|
-
this
|
|
173
|
+
this.#ensureMoves();
|
|
173
174
|
this.room.sql.exec(`DELETE FROM ${this.room.tables.late} WHERE move = ? AND seq <= ?`, moveId, seq);
|
|
174
175
|
}
|
|
175
176
|
/** Apply a batch of late edits (`AttachedDocument.applyLateEdits`). */
|
|
176
177
|
applyLateEdits(batch) {
|
|
177
178
|
return noTimers(() => {
|
|
178
|
-
const row = this
|
|
179
|
+
const row = this.#moveRow(batch.moveId, 'in');
|
|
179
180
|
if (row === undefined)
|
|
180
181
|
return { applied: 0, skipped: batch.edits.map((e) => e.block) };
|
|
181
182
|
if (row.seq >= batch.seq)
|
|
@@ -187,7 +188,7 @@ export class RoomMoves {
|
|
|
187
188
|
skipped.push(edit.block);
|
|
188
189
|
continue;
|
|
189
190
|
}
|
|
190
|
-
this
|
|
191
|
+
this.#mergeLateEdit(f, edit);
|
|
191
192
|
}
|
|
192
193
|
});
|
|
193
194
|
this.room.sql.exec(`UPDATE ${this.room.tables.moves} SET seq = ? WHERE id = ? AND role = 'in'`, batch.seq, batch.moveId);
|
|
@@ -195,45 +196,20 @@ export class RoomMoves {
|
|
|
195
196
|
});
|
|
196
197
|
}
|
|
197
198
|
/** One block's late edit, merged into what it holds (inside a room transaction). */
|
|
198
|
-
mergeLateEdit(f, edit) {
|
|
199
|
+
#mergeLateEdit(f, edit) {
|
|
199
200
|
const id = edit.block;
|
|
200
|
-
const dst = unitsOf(f.contentItems(id)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
type: item.type,
|
|
205
|
-
...(item.data === undefined ? {} : { data: item.data })
|
|
206
|
-
}));
|
|
207
|
-
const merged = threeWay(unitsOf(edit.base.content), unitsOf(edit.src.content), dst);
|
|
208
|
-
const { p, e, mid } = hunk(dst, merged);
|
|
209
|
-
const width = (u) => (u.text === undefined ? 1 : u.text.length);
|
|
210
|
-
let at = dst.slice(0, p).reduce((n, u) => n + width(u), 0);
|
|
211
|
-
const gone = dst.slice(p, e).reduce((n, u) => n + width(u), 0);
|
|
212
|
-
if (gone > 0)
|
|
213
|
-
f.apply(f.prepare.deleteText(id, at, gone));
|
|
214
|
-
for (const item of contentOf(mid)) {
|
|
215
|
-
if ('text' in item && typeof item.text === 'string') {
|
|
216
|
-
f.apply(f.prepare.insertText(id, at, item.text, item.marks));
|
|
217
|
-
at += item.text.length;
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
const atom = item;
|
|
221
|
-
f.apply(f.prepare.insertInline(id, at, {
|
|
222
|
-
id: atom.id ?? crypto.randomUUID(),
|
|
223
|
-
type: atom.type,
|
|
224
|
-
...(atom.data === undefined ? {} : { data: atom.data })
|
|
225
|
-
}));
|
|
226
|
-
at += 1;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
201
|
+
const dst = unitsOf(f.contentItems(id));
|
|
202
|
+
// An atom the late edit names no id of keys as the empty id.
|
|
203
|
+
const units = (content) => unitsOf(jsonContentToItems(content ?? [], false, () => ''));
|
|
204
|
+
rewriteContent(f, id, dst, threeWay(units(edit.base.content), units(edit.src.content), dst));
|
|
229
205
|
const now = subtreesOf(f.toJSON().children, new Set([id]))[0];
|
|
230
206
|
const data = (now?.data ?? {});
|
|
231
207
|
const next = mergeData(edit.base.data, edit.src.data, data);
|
|
232
208
|
if (JSON.stringify(next) !== JSON.stringify(data))
|
|
233
|
-
f.apply(f.prepare.
|
|
209
|
+
f.apply(f.prepare.patchData(id, [{ path: [], value: next }]));
|
|
234
210
|
}
|
|
235
211
|
/** The registry entries carrying a `del.<marker>` mark written between clocks `c0` and `c1`. */
|
|
236
|
-
markedBetween(doc, marker, c0, c1) {
|
|
212
|
+
#markedBetween(doc, marker, c0, c1) {
|
|
237
213
|
const out = [];
|
|
238
214
|
const key = `${DEL_PREFIX}${marker}`;
|
|
239
215
|
asEngineDoc(doc)
|
|
@@ -249,10 +225,10 @@ export class RoomMoves {
|
|
|
249
225
|
return out;
|
|
250
226
|
}
|
|
251
227
|
/** The moved-out blocks watched for late edits (`room.move.late`), by id → their move. */
|
|
252
|
-
watchedBlocks() {
|
|
228
|
+
#watchedBlocks() {
|
|
253
229
|
if (this.watched !== null)
|
|
254
230
|
return this.watched;
|
|
255
|
-
this
|
|
231
|
+
this.#ensureMoves();
|
|
256
232
|
const out = new Map();
|
|
257
233
|
for (const row of this.room.sql
|
|
258
234
|
.exec(`SELECT id, watched FROM ${this.room.tables.moves} WHERE role = 'out' AND state = 'moved'`)
|
|
@@ -275,7 +251,7 @@ export class RoomMoves {
|
|
|
275
251
|
let key = null;
|
|
276
252
|
if (type === registry) {
|
|
277
253
|
for (const sub of subs) {
|
|
278
|
-
watched ??= this
|
|
254
|
+
watched ??= this.#watchedBlocks();
|
|
279
255
|
const move = sub === null ? undefined : watched.get(sub);
|
|
280
256
|
if (move !== undefined)
|
|
281
257
|
dirty.add(move);
|
|
@@ -294,7 +270,7 @@ export class RoomMoves {
|
|
|
294
270
|
}
|
|
295
271
|
if (key === null)
|
|
296
272
|
continue;
|
|
297
|
-
watched ??= this
|
|
273
|
+
watched ??= this.#watchedBlocks();
|
|
298
274
|
if (watched.size === 0)
|
|
299
275
|
return;
|
|
300
276
|
const move = watched.get(key);
|
|
@@ -318,7 +294,7 @@ export class RoomMoves {
|
|
|
318
294
|
const room = this.room;
|
|
319
295
|
const { scheduler, sql, tables } = room;
|
|
320
296
|
scheduler.unschedule('forward');
|
|
321
|
-
this
|
|
297
|
+
this.#ensureMoves();
|
|
322
298
|
const now = room.clock();
|
|
323
299
|
// Past the grace period: no longer watched.
|
|
324
300
|
sql.exec(`UPDATE ${tables.moves} SET state = 'done', sent = '[]', watched = '[]' WHERE role = 'out' AND state = 'moved' AND at <= ?`, now - this.graceMs);
|
|
@@ -327,9 +303,9 @@ export class RoomMoves {
|
|
|
327
303
|
.exec(`SELECT id, roots, sent, map, watched, marker, c0, c1, seq FROM ${tables.moves} WHERE role = 'out' AND state = 'moved' AND dirty = 1`)
|
|
328
304
|
.toArray();
|
|
329
305
|
if (dirty.length > 0 && room.live !== null) {
|
|
330
|
-
const children = noTimers(() => this
|
|
306
|
+
const children = noTimers(() => this.#withoutMoveDeletes(dirty));
|
|
331
307
|
for (const row of dirty)
|
|
332
|
-
this
|
|
308
|
+
this.#collectLateEdits(row, children);
|
|
333
309
|
}
|
|
334
310
|
const rooms = room.options.rooms?.();
|
|
335
311
|
let retry = false;
|
|
@@ -356,9 +332,9 @@ export class RoomMoves {
|
|
|
356
332
|
scheduler.schedule('forward', next + this.graceMs, 'earlier');
|
|
357
333
|
}
|
|
358
334
|
/** The document's blocks as they show without the deletes of `moves`' commits: a copy, read once. */
|
|
359
|
-
withoutMoveDeletes(moves) {
|
|
335
|
+
#withoutMoveDeletes(moves) {
|
|
360
336
|
const copy = crdt.createDoc();
|
|
361
|
-
Y.
|
|
337
|
+
Y.applyUpdate(copy, Y.encodeStateAsUpdate(this.room.requireDoc()));
|
|
362
338
|
const facade = this.room.facadeOf(copy);
|
|
363
339
|
try {
|
|
364
340
|
const registry = asEngineDoc(copy).get(REGISTRY_KEY);
|
|
@@ -385,7 +361,7 @@ export class RoomMoves {
|
|
|
385
361
|
}
|
|
386
362
|
}
|
|
387
363
|
/** One dirty move's changes since its last batch, as a new batch of late edits (or a report). */
|
|
388
|
-
collectLateEdits(row, children) {
|
|
364
|
+
#collectLateEdits(row, children) {
|
|
389
365
|
const room = this.room;
|
|
390
366
|
const roots = new Set(JSON.parse(row.roots));
|
|
391
367
|
const now = subtreesOf(children, roots);
|
|
@@ -3,9 +3,8 @@ import type { YDoc } from '../../crdt/index.js';
|
|
|
3
3
|
import type { Attachment } from '../DocumentRoom.js';
|
|
4
4
|
import { type RoomContext } from './context.js';
|
|
5
5
|
export declare class RoomPresence {
|
|
6
|
+
#private;
|
|
6
7
|
private readonly room;
|
|
7
|
-
/** Each socket's presence allowance, a bucket of its own. */
|
|
8
|
-
private readonly allowances;
|
|
9
8
|
/** Sockets in a burst past their presence rate, logged once (`overRate`). */
|
|
10
9
|
private readonly bursts;
|
|
11
10
|
/**
|
|
@@ -64,15 +63,6 @@ export declare class RoomPresence {
|
|
|
64
63
|
* presence every 15 s).
|
|
65
64
|
*/
|
|
66
65
|
private drain;
|
|
67
|
-
/**
|
|
68
|
-
* The dev-time roles check: a client's presence advertises the
|
|
69
|
-
* digest of its document's roles (`semantics`, development builds); one
|
|
70
|
-
* naming kinds, marks or a default type the room reads otherwise is
|
|
71
|
-
* logged (`semantics`), once per digest the client advertises. Never a
|
|
72
|
-
* refusal: a client without a plugin, or with roles the room lacks, is
|
|
73
|
-
* the host's to fix, in `semantics`.
|
|
74
|
-
*/
|
|
75
|
-
private compareSemantics;
|
|
76
66
|
/**
|
|
77
67
|
* A presence message past the socket's rate (`room.presence.quota`):
|
|
78
68
|
* never closed. A burst is one log entry, its first message's (the
|
|
@@ -35,7 +35,7 @@ const verifiedPresence = (entry, user) => {
|
|
|
35
35
|
export class RoomPresence {
|
|
36
36
|
room;
|
|
37
37
|
/** Each socket's presence allowance, a bucket of its own. */
|
|
38
|
-
allowances = new WeakMap();
|
|
38
|
+
#allowances = new WeakMap();
|
|
39
39
|
/** Sockets in a burst past their presence rate, logged once (`overRate`). */
|
|
40
40
|
bursts = new WeakSet();
|
|
41
41
|
/**
|
|
@@ -68,7 +68,7 @@ export class RoomPresence {
|
|
|
68
68
|
* on a bucket of the socket's own. `false`: over it.
|
|
69
69
|
*/
|
|
70
70
|
allow(ws) {
|
|
71
|
-
if (!allowance(this
|
|
71
|
+
if (!allowance(this.#allowances, ws, this.room.limits.maxPresencePerSecond))
|
|
72
72
|
return false;
|
|
73
73
|
this.bursts.delete(ws);
|
|
74
74
|
return true;
|
|
@@ -113,7 +113,7 @@ export class RoomPresence {
|
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
this
|
|
116
|
+
this.#compareSemantics(attachment.user, known, entry);
|
|
117
117
|
if (entry.state === null)
|
|
118
118
|
this.entries.delete(replica);
|
|
119
119
|
else
|
|
@@ -219,7 +219,7 @@ export class RoomPresence {
|
|
|
219
219
|
* refusal: a client without a plugin, or with roles the room lacks, is
|
|
220
220
|
* the host's to fix, in `semantics`.
|
|
221
221
|
*/
|
|
222
|
-
compareSemantics(user, known, entry) {
|
|
222
|
+
#compareSemantics(user, known, entry) {
|
|
223
223
|
const advertised = entry.state?.semantics;
|
|
224
224
|
if (advertised === undefined)
|
|
225
225
|
return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PurgeReport } from '../../crdt/purge.js';
|
|
2
2
|
import { type RoomContext } from './context.js';
|
|
3
3
|
export declare class RoomPurge {
|
|
4
|
+
#private;
|
|
4
5
|
private readonly room;
|
|
5
6
|
constructor(room: RoomContext);
|
|
6
7
|
/** Days after which deleted content is purged (`null`: never), `room.purge.timing`. */
|
|
@@ -11,6 +12,4 @@ export declare class RoomPurge {
|
|
|
11
12
|
tick(): (PurgeReport & {
|
|
12
13
|
horizon: number;
|
|
13
14
|
}) | null;
|
|
14
|
-
/** Purge what was deleted before `horizon`, as the room's own transaction, then compact. */
|
|
15
|
-
private purgeTo;
|
|
16
15
|
}
|
|
@@ -59,7 +59,7 @@ export class RoomPurge {
|
|
|
59
59
|
.toArray()[0];
|
|
60
60
|
let result = null;
|
|
61
61
|
if (horizon !== undefined && horizon.at > purged) {
|
|
62
|
-
result = this
|
|
62
|
+
result = this.#purgeTo({ at: horizon.at, sv: new Uint8Array(horizon.sv) });
|
|
63
63
|
}
|
|
64
64
|
// The next epoch to pass the horizon, or the next change, arms it again.
|
|
65
65
|
const next = sql
|
|
@@ -73,7 +73,7 @@ export class RoomPurge {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
/** Purge what was deleted before `horizon`, as the room's own transaction, then compact. */
|
|
76
|
-
purgeTo(horizon) {
|
|
76
|
+
#purgeTo(horizon) {
|
|
77
77
|
const room = this.room;
|
|
78
78
|
const doc = room.requireDoc();
|
|
79
79
|
// A restore past the horizon can no longer be undone (`room.history.undo`).
|
|
@@ -5,6 +5,7 @@ import type { RoomContext } from './context.js';
|
|
|
5
5
|
export declare class StorageFault extends Error {
|
|
6
6
|
}
|
|
7
7
|
export declare class ReplicaRegistry {
|
|
8
|
+
#private;
|
|
8
9
|
private readonly room;
|
|
9
10
|
constructor(room: RoomContext);
|
|
10
11
|
/** A registry read or write, its SQLite fault tagged (the socket closes 1011, never 1008). */
|
|
@@ -35,13 +36,6 @@ export declare class ReplicaRegistry {
|
|
|
35
36
|
* Ownership never moves to a relayer.
|
|
36
37
|
*/
|
|
37
38
|
attribute({ user, replica }: Attachment, writers: Set<number>, sv: Map<number, number>, orphans: Set<number>): Set<number>;
|
|
38
|
-
/**
|
|
39
|
-
* A claimed orphan (an id relayed by another user, whose binding the
|
|
40
|
-
* relay could not carry): the room binds it to its claimer, when the
|
|
41
|
-
* room holds content of it. A failed write is healed here, the claim
|
|
42
|
-
* kept (the binding then stays as it was).
|
|
43
|
-
*/
|
|
44
|
-
private bindOrphan;
|
|
45
39
|
/**
|
|
46
40
|
* Bind the sender's replicas whose `c/<n>` a frame set to another actor
|
|
47
41
|
* to its verified user (`room.attribution.trust`): one room write after the frame's, which
|