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
|
@@ -28,7 +28,7 @@ export declare const crdt: {
|
|
|
28
28
|
Awareness: typeof import("../../index.js").Awareness;
|
|
29
29
|
doc: {
|
|
30
30
|
SCHEMA: {
|
|
31
|
-
readonly version:
|
|
31
|
+
readonly version: 10;
|
|
32
32
|
readonly name: "edytor-doc";
|
|
33
33
|
readonly roots: {
|
|
34
34
|
readonly registry: "blocks";
|
|
@@ -39,7 +39,7 @@ export declare const crdt: {
|
|
|
39
39
|
readonly schema: "schema";
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
-
SCHEMA_VERSION:
|
|
42
|
+
SCHEMA_VERSION: 10;
|
|
43
43
|
SCHEMA_NAME: "edytor-doc";
|
|
44
44
|
META_KEY: "meta";
|
|
45
45
|
init: (doc: E.EngineDoc, opts?: {
|
|
@@ -103,29 +103,30 @@ export declare const crdt: {
|
|
|
103
103
|
blockNodeOf: (doc: E.EngineDoc, id: import("../../index.js").BlockId) => E.EngineNode | null;
|
|
104
104
|
liveNodeOf: (doc: E.EngineDoc, id: import("../../index.js").BlockId) => E.EngineNode | null;
|
|
105
105
|
isLive: (doc: E.EngineDoc, id: import("../../index.js").BlockId) => boolean;
|
|
106
|
-
candidatesOf: (node: E.EngineNode) => import("../../crdt/placement/model.js").PlacementCand[];
|
|
107
106
|
view: (doc: E.EngineDoc) => import("../../crdt/placement/model.js").ModelView;
|
|
108
|
-
resolvePlacements: (blocks: Map<import("../../index.js").BlockId, import("../../crdt/placement/model.js").BlockRec>, ownerOf?: (b: import("../../index.js").BlockId) => import("../../crdt/text/model.js").Owner) => Map<import("../../index.js").BlockId, import("../../crdt/placement/model.js").ResolvedPlacement>;
|
|
109
107
|
childrenIndex: (placements: Map<import("../../index.js").BlockId, import("../../crdt/placement/model.js").ResolvedPlacement>, own: import("../../crdt/placement/model.js").DisplayOwnership) => Map<import("../../index.js").BlockId | null, import("../../crdt/placement/model.js").ChildSlot[]>;
|
|
110
108
|
positionInView: (v: import("../../crdt/placement/model.js").ModelView, id: import("../../index.js").BlockId) => import("../../index.js").Destination | null;
|
|
111
109
|
buildInline: (atom: import("../../index.js").InlineSpec) => E.EngineNode;
|
|
112
110
|
isSelfOrDescendant: (placements: Map<import("../../index.js").BlockId, import("../../crdt/placement/model.js").ResolvedPlacement>, own: import("../../crdt/text/model.js").Ownership, id: import("../../index.js").BlockId, maybeAncestor: import("../../index.js").BlockId) => boolean;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
writePlacement: (doc: E.EngineDoc, node: E.EngineNode, p: import("../../index.js").BlockId | null, r: string) => void;
|
|
111
|
+
placeBlocks: (doc: E.EngineDoc, v: import("../../crdt/placement/model.js").ModelView, parent: import("../../index.js").BlockId | null, left: import("../../index.js").BlockId | null, right: import("../../index.js").BlockId | null, slots: readonly import("../../crdt/placement/slots.js").BlockSlot[] | null, moved?: readonly number[] | null, side?: number, part?: number, at?: import("../../crdt/placement/slots.js").Unit | null) => void;
|
|
112
|
+
moveBlocksTo: (doc: E.EngineDoc, v: import("../../crdt/placement/model.js").ModelView, ids: readonly import("../../index.js").BlockId[], parent: import("../../index.js").BlockId | null, index: number, side?: number, part?: number, at?: import("../../index.js").BlockId | null) => void;
|
|
113
|
+
insertSpecsAt: (doc: E.EngineDoc, v: import("../../crdt/placement/model.js").ModelView, parent: import("../../index.js").BlockId | null, index: number, specs: readonly import("../../index.js").BlockSpec[], split?: import("../../crdt/placement/slots.js").Unit | null) => void;
|
|
117
114
|
withdrawOnUndo: (doc: E.EngineDoc) => (item: E.EngineItemRef, stackItem: {
|
|
118
115
|
inserts: {
|
|
119
116
|
has(client: number, clock: number): boolean;
|
|
120
117
|
};
|
|
121
118
|
}) => boolean;
|
|
122
|
-
materializeSpec: (doc: E.EngineDoc, sp: import("../../index.js").BlockSpec, parent: import("../../index.js").BlockId | null, rank: string) => void;
|
|
123
119
|
collides: (doc: E.EngineDoc, specs: readonly import("../../index.js").BlockSpec[]) => boolean;
|
|
124
|
-
writeSplit: (doc: E.EngineDoc, id: import("../../index.js").BlockId, offset: number, newId: import("../../index.js").BlockId, tail: import("../../index.js").SplitTail,
|
|
120
|
+
writeSplit: (doc: E.EngineDoc, id: import("../../index.js").BlockId, offset: number, newId: import("../../index.js").BlockId, tail: import("../../index.js").SplitTail, parent: import("../../index.js").BlockId | null, index: number) => import("../../crdt/placement/slots.js").Unit;
|
|
125
121
|
ownText: (doc: E.EngineDoc, id: import("../../index.js").BlockId) => {
|
|
126
122
|
from: unknown;
|
|
127
123
|
to: number;
|
|
128
124
|
};
|
|
125
|
+
recordsOf: (doc: E.EngineDoc, node: E.EngineNode, v?: import("../../crdt/placement/model.js").ModelView) => {
|
|
126
|
+
item: import("../../crdt/placement/slots.js").SeqItem;
|
|
127
|
+
stamp: import("../../crdt/placement/slots.js").Stamp;
|
|
128
|
+
wins: boolean;
|
|
129
|
+
}[];
|
|
129
130
|
insertBlocks: (doc: E.EngineDoc, dest: import("../../index.js").Destination, specs: import("../../index.js").BlockSpec[]) => boolean;
|
|
130
131
|
insertBlock: (doc: E.EngineDoc, dest: import("../../index.js").Destination, spec: import("../../index.js").BlockSpec) => boolean;
|
|
131
132
|
restoreBlocks: (doc: E.EngineDoc, specs: import("../../index.js").BlockSpec[]) => void;
|
|
@@ -157,8 +158,8 @@ export declare const crdt: {
|
|
|
157
158
|
at: number;
|
|
158
159
|
node: E.EngineNode;
|
|
159
160
|
} | null;
|
|
160
|
-
splitAt: (blocks: ReadonlyMap<import("../../crdt/text/model.js").BlockId, import("../../crdt/text/model.js").TextBlockRec>, own: import("../../crdt/text/model.js").Ownership, b: import("../../crdt/text/model.js").BlockId, offset: number, newId: import("../../crdt/text/model.js").BlockId, n: number) =>
|
|
161
|
-
claimInto: (
|
|
161
|
+
splitAt: (doc: E.EngineDoc, blocks: ReadonlyMap<import("../../crdt/text/model.js").BlockId, import("../../crdt/text/model.js").TextBlockRec>, own: import("../../crdt/text/model.js").Ownership, b: import("../../crdt/text/model.js").BlockId, offset: number, newId: import("../../crdt/text/model.js").BlockId, n: number) => void;
|
|
162
|
+
claimInto: (own: Pick<import("../../crdt/text/model.js").Ownership, "streamOf">, from: import("../../crdt/text/model.js").BlockId, into: import("../../crdt/text/model.js").BlockId) => void;
|
|
162
163
|
ownText: (doc: E.EngineDoc, rec: import("../../crdt/text/model.js").TextBlockRec) => {
|
|
163
164
|
from: unknown;
|
|
164
165
|
to: number;
|
|
@@ -178,7 +179,7 @@ export declare const crdt: {
|
|
|
178
179
|
keep?: boolean;
|
|
179
180
|
after?: readonly import("../../index.js").BlockSpec[];
|
|
180
181
|
} | undefined) => import("../../index.js").OpResult;
|
|
181
|
-
placeBeside: (ids: readonly string[], target: string, side: "
|
|
182
|
+
placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => import("../../index.js").OpResult;
|
|
182
183
|
wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("../../index.js").OpResult;
|
|
183
184
|
splitBlock: (id: string, offset: number, newId: string, tail?: import("../../index.js").SplitTail | undefined) => import("../../index.js").OpResult;
|
|
184
185
|
mergeBlocks: (fromId: string, intoId: string) => import("../../index.js").OpResult;
|
|
@@ -301,11 +302,10 @@ export declare const crdt: {
|
|
|
301
302
|
onChange: (cb: (change: import("../../index.js").DocChange) => void) => (() => void);
|
|
302
303
|
};
|
|
303
304
|
newDoc: (opts?: ConstructorParameters<E.EngineApi["Doc"]>[0]) => YDoc;
|
|
304
|
-
keepCopies: (doc: E.EngineDoc) => void;
|
|
305
305
|
purge: (doc: E.EngineDoc, facade: {
|
|
306
306
|
model: import("../../crdt/placement/model.js").PlacementModel;
|
|
307
307
|
text: import("../../crdt/text/model.js").TextEngine;
|
|
308
|
-
}, horizon: import("../../crdt/purge.js").Horizon) => import("../index.js").PurgeReport;
|
|
308
|
+
}, horizon: import("../../crdt/purge.js").Horizon | null) => import("../index.js").PurgeReport;
|
|
309
309
|
horizonOf: (doc: E.EngineDoc) => import("../../crdt/purge.js").Horizon | null;
|
|
310
310
|
restoreTo: <Plan>(doc: E.EngineDoc, facade: import("../../crdt/restore.js").RestoreFacade<Plan>, json: JSONDoc) => import("../../crdt/restore.js").RestoreReport;
|
|
311
311
|
model: {
|
|
@@ -314,29 +314,30 @@ export declare const crdt: {
|
|
|
314
314
|
blockNodeOf: (doc: E.EngineDoc, id: import("../../index.js").BlockId) => E.EngineNode | null;
|
|
315
315
|
liveNodeOf: (doc: E.EngineDoc, id: import("../../index.js").BlockId) => E.EngineNode | null;
|
|
316
316
|
isLive: (doc: E.EngineDoc, id: import("../../index.js").BlockId) => boolean;
|
|
317
|
-
candidatesOf: (node: E.EngineNode) => import("../../crdt/placement/model.js").PlacementCand[];
|
|
318
317
|
view: (doc: E.EngineDoc) => import("../../crdt/placement/model.js").ModelView;
|
|
319
|
-
resolvePlacements: (blocks: Map<import("../../index.js").BlockId, import("../../crdt/placement/model.js").BlockRec>, ownerOf?: (b: import("../../index.js").BlockId) => import("../../crdt/text/model.js").Owner) => Map<import("../../index.js").BlockId, import("../../crdt/placement/model.js").ResolvedPlacement>;
|
|
320
318
|
childrenIndex: (placements: Map<import("../../index.js").BlockId, import("../../crdt/placement/model.js").ResolvedPlacement>, own: import("../../crdt/placement/model.js").DisplayOwnership) => Map<import("../../index.js").BlockId | null, import("../../crdt/placement/model.js").ChildSlot[]>;
|
|
321
319
|
positionInView: (v: import("../../crdt/placement/model.js").ModelView, id: import("../../index.js").BlockId) => import("../../index.js").Destination | null;
|
|
322
320
|
buildInline: (atom: import("../../index.js").InlineSpec) => E.EngineNode;
|
|
323
321
|
isSelfOrDescendant: (placements: Map<import("../../index.js").BlockId, import("../../crdt/placement/model.js").ResolvedPlacement>, own: import("../../crdt/text/model.js").Ownership, id: import("../../index.js").BlockId, maybeAncestor: import("../../index.js").BlockId) => boolean;
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
writePlacement: (doc: E.EngineDoc, node: E.EngineNode, p: import("../../index.js").BlockId | null, r: string) => void;
|
|
322
|
+
placeBlocks: (doc: E.EngineDoc, v: import("../../crdt/placement/model.js").ModelView, parent: import("../../index.js").BlockId | null, left: import("../../index.js").BlockId | null, right: import("../../index.js").BlockId | null, slots: readonly import("../../crdt/placement/slots.js").BlockSlot[] | null, moved?: readonly number[] | null, side?: number, part?: number, at?: import("../../crdt/placement/slots.js").Unit | null) => void;
|
|
323
|
+
moveBlocksTo: (doc: E.EngineDoc, v: import("../../crdt/placement/model.js").ModelView, ids: readonly import("../../index.js").BlockId[], parent: import("../../index.js").BlockId | null, index: number, side?: number, part?: number, at?: import("../../index.js").BlockId | null) => void;
|
|
324
|
+
insertSpecsAt: (doc: E.EngineDoc, v: import("../../crdt/placement/model.js").ModelView, parent: import("../../index.js").BlockId | null, index: number, specs: readonly import("../../index.js").BlockSpec[], split?: import("../../crdt/placement/slots.js").Unit | null) => void;
|
|
328
325
|
withdrawOnUndo: (doc: E.EngineDoc) => (item: E.EngineItemRef, stackItem: {
|
|
329
326
|
inserts: {
|
|
330
327
|
has(client: number, clock: number): boolean;
|
|
331
328
|
};
|
|
332
329
|
}) => boolean;
|
|
333
|
-
materializeSpec: (doc: E.EngineDoc, sp: import("../../index.js").BlockSpec, parent: import("../../index.js").BlockId | null, rank: string) => void;
|
|
334
330
|
collides: (doc: E.EngineDoc, specs: readonly import("../../index.js").BlockSpec[]) => boolean;
|
|
335
|
-
writeSplit: (doc: E.EngineDoc, id: import("../../index.js").BlockId, offset: number, newId: import("../../index.js").BlockId, tail: import("../../index.js").SplitTail,
|
|
331
|
+
writeSplit: (doc: E.EngineDoc, id: import("../../index.js").BlockId, offset: number, newId: import("../../index.js").BlockId, tail: import("../../index.js").SplitTail, parent: import("../../index.js").BlockId | null, index: number) => import("../../crdt/placement/slots.js").Unit;
|
|
336
332
|
ownText: (doc: E.EngineDoc, id: import("../../index.js").BlockId) => {
|
|
337
333
|
from: unknown;
|
|
338
334
|
to: number;
|
|
339
335
|
};
|
|
336
|
+
recordsOf: (doc: E.EngineDoc, node: E.EngineNode, v?: import("../../crdt/placement/model.js").ModelView) => {
|
|
337
|
+
item: import("../../crdt/placement/slots.js").SeqItem;
|
|
338
|
+
stamp: import("../../crdt/placement/slots.js").Stamp;
|
|
339
|
+
wins: boolean;
|
|
340
|
+
}[];
|
|
340
341
|
insertBlocks: (doc: E.EngineDoc, dest: import("../../index.js").Destination, specs: import("../../index.js").BlockSpec[]) => boolean;
|
|
341
342
|
insertBlock: (doc: E.EngineDoc, dest: import("../../index.js").Destination, spec: import("../../index.js").BlockSpec) => boolean;
|
|
342
343
|
restoreBlocks: (doc: E.EngineDoc, specs: import("../../index.js").BlockSpec[]) => void;
|
|
@@ -368,8 +369,8 @@ export declare const crdt: {
|
|
|
368
369
|
at: number;
|
|
369
370
|
node: E.EngineNode;
|
|
370
371
|
} | null;
|
|
371
|
-
splitAt: (blocks: ReadonlyMap<import("../../crdt/text/model.js").BlockId, import("../../crdt/text/model.js").TextBlockRec>, own: import("../../crdt/text/model.js").Ownership, b: import("../../crdt/text/model.js").BlockId, offset: number, newId: import("../../crdt/text/model.js").BlockId, n: number) =>
|
|
372
|
-
claimInto: (
|
|
372
|
+
splitAt: (doc: E.EngineDoc, blocks: ReadonlyMap<import("../../crdt/text/model.js").BlockId, import("../../crdt/text/model.js").TextBlockRec>, own: import("../../crdt/text/model.js").Ownership, b: import("../../crdt/text/model.js").BlockId, offset: number, newId: import("../../crdt/text/model.js").BlockId, n: number) => void;
|
|
373
|
+
claimInto: (own: Pick<import("../../crdt/text/model.js").Ownership, "streamOf">, from: import("../../crdt/text/model.js").BlockId, into: import("../../crdt/text/model.js").BlockId) => void;
|
|
373
374
|
ownText: (doc: E.EngineDoc, rec: import("../../crdt/text/model.js").TextBlockRec) => {
|
|
374
375
|
from: unknown;
|
|
375
376
|
to: number;
|
|
@@ -536,7 +537,7 @@ export declare const crdt: {
|
|
|
536
537
|
off<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: E.WebsocketProviderEvents[NAME]): void;
|
|
537
538
|
};
|
|
538
539
|
};
|
|
539
|
-
watchComments: (server: string, roomName: string, listener: (message: E.CommentMessage) => void) => (() => void);
|
|
540
|
+
watchComments: (server: string | null, roomName: string, listener: (message: E.CommentMessage) => void) => (() => void);
|
|
540
541
|
storeState: (idbPersistence: {
|
|
541
542
|
db: IDBDatabase | null;
|
|
542
543
|
name: string;
|
|
@@ -691,9 +692,9 @@ export declare class RoomContext {
|
|
|
691
692
|
emptied: number;
|
|
692
693
|
marks: number;
|
|
693
694
|
records: number;
|
|
694
|
-
candidates: number;
|
|
695
695
|
claims: number;
|
|
696
696
|
merged: number;
|
|
697
|
+
released: number;
|
|
697
698
|
};
|
|
698
699
|
since: number;
|
|
699
700
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PurgeReport } from '../../crdt/purge.js';
|
|
2
2
|
import { type RoomContext } from './context.js';
|
|
3
3
|
export declare class RoomPurge {
|
|
4
4
|
#private;
|
|
@@ -8,8 +8,11 @@ export declare class RoomPurge {
|
|
|
8
8
|
get days(): number | null;
|
|
9
9
|
/** A change was stored at `at`: the purge tick runs a day later at the latest. */
|
|
10
10
|
noteChange(at: number): void;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* The purge task (`AttachedDocument.purge`): its report, `horizon` the
|
|
13
|
+
* epoch it purged to (`null`: only ended sessions' deletes).
|
|
14
|
+
*/
|
|
12
15
|
tick(): (PurgeReport & {
|
|
13
|
-
horizon: number;
|
|
16
|
+
horizon: number | null;
|
|
14
17
|
}) | null;
|
|
15
18
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The purge (`room.purge.*`): the daily tick records an epoch (the state
|
|
3
3
|
* vector) when the document changed, and purges what was deleted before
|
|
4
|
-
* the horizon — the newest epoch at least `purgeAfterDays` old —
|
|
5
|
-
*
|
|
4
|
+
* the horizon — the newest epoch at least `purgeAfterDays` old — and what
|
|
5
|
+
* the sessions whose history ended deleted (`hist.release.end`), as the
|
|
6
|
+
* room's own transaction (`crdt/purge.ts`), then compacts. With no epoch
|
|
7
|
+
* due, a tick still purges the ended sessions' deletes.
|
|
6
8
|
*/
|
|
7
9
|
import { Y } from '../../crdt/engine.js';
|
|
10
|
+
import { releasesOf } from '../../crdt/purge.js';
|
|
8
11
|
import { asEngineDoc } from '../../crdt/structs.js';
|
|
9
12
|
import { PURGE_ORIGIN, noTimers } from './shared.js';
|
|
10
13
|
import { DEFAULT_RETENTION_DAYS } from '../history.js';
|
|
@@ -27,7 +30,10 @@ export class RoomPurge {
|
|
|
27
30
|
if (this.days !== null)
|
|
28
31
|
this.room.scheduler.schedule('purge', at + DAY, 'earlier');
|
|
29
32
|
}
|
|
30
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* The purge task (`AttachedDocument.purge`): its report, `horizon` the
|
|
35
|
+
* epoch it purged to (`null`: only ended sessions' deletes).
|
|
36
|
+
*/
|
|
31
37
|
tick() {
|
|
32
38
|
const room = this.room;
|
|
33
39
|
const { scheduler, sql, tables } = room;
|
|
@@ -61,6 +67,10 @@ export class RoomPurge {
|
|
|
61
67
|
if (horizon !== undefined && horizon.at > purged) {
|
|
62
68
|
result = this.#purgeTo({ at: horizon.at, sv: new Uint8Array(horizon.sv) });
|
|
63
69
|
}
|
|
70
|
+
else if (releasesOf(asEngineDoc(doc)).size > 0) {
|
|
71
|
+
// No epoch is due: the ended sessions' deletes go all the same.
|
|
72
|
+
result = this.#purgeTo(null);
|
|
73
|
+
}
|
|
64
74
|
// The next epoch to pass the horizon, or the next change, arms it again.
|
|
65
75
|
const next = sql
|
|
66
76
|
.exec(`SELECT at FROM ${tables.epochs} WHERE at > ? ORDER BY at LIMIT 1`, Math.max(purged, horizon?.at ?? -1))
|
|
@@ -72,18 +82,27 @@ export class RoomPurge {
|
|
|
72
82
|
return result;
|
|
73
83
|
});
|
|
74
84
|
}
|
|
75
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Purge what was deleted before `horizon` and what ended sessions deleted
|
|
87
|
+
* (`null`: only those), as the room's own transaction, then compact. A
|
|
88
|
+
* purge of ended sessions' deletes that finds none left compacts nothing
|
|
89
|
+
* and reports `null`.
|
|
90
|
+
*/
|
|
76
91
|
#purgeTo(horizon) {
|
|
77
92
|
const room = this.room;
|
|
78
93
|
const doc = room.requireDoc();
|
|
79
94
|
// A restore past the horizon can no longer be undone (`room.history.undo`).
|
|
80
|
-
|
|
95
|
+
if (horizon !== null)
|
|
96
|
+
room.history.expireRestore(horizon.at);
|
|
81
97
|
room.history.closeSlotIfPast();
|
|
82
98
|
let report;
|
|
99
|
+
let wrote = true;
|
|
83
100
|
room.transacting = true;
|
|
84
101
|
try {
|
|
85
102
|
room.facade.transact(() => {
|
|
86
103
|
report = crdt.doc.purge(asEngineDoc(doc), room.facade, horizon);
|
|
104
|
+
const tr = asEngineDoc(doc)._transaction;
|
|
105
|
+
wrote = !tr.insertSet.isEmpty() || !tr.deleteSet.isEmpty();
|
|
87
106
|
}, PURGE_ORIGIN);
|
|
88
107
|
}
|
|
89
108
|
finally {
|
|
@@ -94,30 +113,36 @@ export class RoomPurge {
|
|
|
94
113
|
room.storage.heal();
|
|
95
114
|
throw error;
|
|
96
115
|
}
|
|
97
|
-
|
|
98
|
-
room.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
counters.runs++;
|
|
104
|
-
counters.horizon = horizon.at;
|
|
105
|
-
for (const key of [
|
|
116
|
+
if (horizon !== null)
|
|
117
|
+
room.ctx.storage.transactionSync(() => {
|
|
118
|
+
room.sql.exec(`INSERT OR REPLACE INTO ${room.tables.meta} (key, value) VALUES ('purged', ?)`, horizon.at);
|
|
119
|
+
room.sql.exec(`DELETE FROM ${room.tables.epochs} WHERE at < ?`, horizon.at);
|
|
120
|
+
});
|
|
121
|
+
const keys = [
|
|
106
122
|
'removed',
|
|
107
123
|
'emptied',
|
|
108
124
|
'marks',
|
|
109
125
|
'records',
|
|
110
|
-
'candidates',
|
|
111
126
|
'claims',
|
|
112
|
-
'merged'
|
|
113
|
-
|
|
127
|
+
'merged',
|
|
128
|
+
'released'
|
|
129
|
+
];
|
|
130
|
+
// Nothing an ended session deleted was left: no compaction, no run.
|
|
131
|
+
if (horizon === null && !wrote)
|
|
132
|
+
return null;
|
|
133
|
+
room.storage.compact();
|
|
134
|
+
const counters = room.counters.purge;
|
|
135
|
+
counters.runs++;
|
|
136
|
+
if (horizon !== null)
|
|
137
|
+
counters.horizon = horizon.at;
|
|
138
|
+
for (const key of keys)
|
|
114
139
|
counters[key] += report[key];
|
|
115
140
|
room.log({
|
|
116
141
|
edytor: 'purge',
|
|
117
|
-
horizon: horizon
|
|
142
|
+
horizon: horizon?.at ?? null,
|
|
118
143
|
bytes: room.counters.compaction.lastBytes,
|
|
119
144
|
...report
|
|
120
145
|
});
|
|
121
|
-
return { ...report, horizon: horizon
|
|
146
|
+
return { ...report, horizon: horizon?.at ?? null };
|
|
122
147
|
}
|
|
123
148
|
}
|
|
@@ -77,10 +77,9 @@ export declare const heldDeletes: (doc: YDoc, ds: Decoded["ds"]) => Decoded["ds"
|
|
|
77
77
|
export declare const withoutPending: <T>(doc: YDoc, read: () => T) => T;
|
|
78
78
|
/**
|
|
79
79
|
* The live document as one update: its healed state — the engine
|
|
80
|
-
* merged what each keystroke wrote and collected deleted content
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* holds exactly what the stored records hold, collected.
|
|
80
|
+
* merged what each keystroke wrote and collected deleted content —,
|
|
81
|
+
* without what waits (`withoutPending`). Memory never runs ahead of
|
|
82
|
+
* storage, so it holds exactly what the stored records hold, collected.
|
|
84
83
|
*/
|
|
85
84
|
export declare const liveState: (doc: YDoc) => Uint8Array;
|
|
86
85
|
/** A fresh room document (`prepareRoomDoc`'s collection rules). */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import * as encoding from 'lib0-v14/encoding';
|
|
7
7
|
import { Y } from '../../crdt/engine.js';
|
|
8
|
-
import {
|
|
8
|
+
import { keepFromCollection, structAt as storeStructAt } from '../../crdt/structs.js';
|
|
9
9
|
import { ROOM_ORIGIN } from './shared.js';
|
|
10
10
|
import { crdt } from './context.js';
|
|
11
11
|
export const stateVector = (doc) => Y.decodeStateVector(Y.encodeStateVector(doc));
|
|
@@ -295,19 +295,17 @@ export const withoutPending = (doc, read) => {
|
|
|
295
295
|
};
|
|
296
296
|
/**
|
|
297
297
|
* The live document as one update: its healed state — the engine
|
|
298
|
-
* merged what each keystroke wrote and collected deleted content
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
* holds exactly what the stored records hold, collected.
|
|
298
|
+
* merged what each keystroke wrote and collected deleted content —,
|
|
299
|
+
* without what waits (`withoutPending`). Memory never runs ahead of
|
|
300
|
+
* storage, so it holds exactly what the stored records hold, collected.
|
|
302
301
|
*/
|
|
303
302
|
export const liveState = (doc) => withoutPending(doc, () => Y.encodeStateAsUpdate(doc));
|
|
304
303
|
/**
|
|
305
304
|
* A room document's collection rules, before any update applies: it keeps
|
|
306
|
-
*
|
|
307
|
-
*
|
|
305
|
+
* the content the last restore deleted while its undo stands (`keep`,
|
|
306
|
+
* `room.history.undo`).
|
|
308
307
|
*/
|
|
309
308
|
const prepareRoomDoc = (doc, keep) => {
|
|
310
|
-
crdt.doc.keepCopies(asEngineDoc(doc));
|
|
311
309
|
keepFromCollection(doc, (it) => !(keep()?.intersects(it.id.client, it.id.clock, it.length) ?? false));
|
|
312
310
|
};
|
|
313
311
|
/** A fresh room document (`prepareRoomDoc`'s collection rules). */
|
|
@@ -50,6 +50,23 @@ export type RouteDocumentOptions = {
|
|
|
50
50
|
* your page from another site's. Omitted: every origin passes.
|
|
51
51
|
*/
|
|
52
52
|
allowedOrigins?: readonly string[] | ((origin: string) => boolean);
|
|
53
|
+
/**
|
|
54
|
+
* Answer a page on another origin (the app on `app.example.com`, the
|
|
55
|
+
* room on `rooms.example.com`): `OPTIONS` preflights are answered `204`
|
|
56
|
+
* (`GET, POST`, the headers the page asked for), and every HTTP answer
|
|
57
|
+
* (comments, history, the probes) carries `Access-Control-Allow-Origin`.
|
|
58
|
+
* The origins are `allowedOrigins`: with a list or a predicate, the
|
|
59
|
+
* request's `Origin` is echoed (`Vary: Origin`) and `credentials: true`
|
|
60
|
+
* lets the page send its cookies (`fetch(…, { credentials: 'include' })`);
|
|
61
|
+
* without one, every origin gets `*` and no credentials. A preflight from
|
|
62
|
+
* an origin `allowedOrigins` refuses is answered `403`. `maxAge`: how long
|
|
63
|
+
* a browser keeps a preflight, in seconds (default 600). A WebSocket dial
|
|
64
|
+
* needs none of it. Omitted: no CORS headers, and `OPTIONS` answers `405`.
|
|
65
|
+
*/
|
|
66
|
+
cors?: boolean | {
|
|
67
|
+
credentials?: boolean;
|
|
68
|
+
maxAge?: number;
|
|
69
|
+
};
|
|
53
70
|
};
|
|
54
71
|
/** The replica a client asked for in `?replica=<doc.clientID>` (or `param`), or `null`. */
|
|
55
72
|
export declare const requestedReplica: (request: Request, param?: string) => number | null;
|
|
@@ -28,6 +28,50 @@ import { CLOSE, validRoomId } from '../crdt/providers/room.js';
|
|
|
28
28
|
import { COMMENTS_HEADER, HISTORY_HEADER, HISTORY_KEY_HEADER, IDENTITY_HEADERS, PROBE_HEADER, closedSocket } from './room/shared.js';
|
|
29
29
|
import { parseReplica } from './room/access.js';
|
|
30
30
|
import { MAX_COMMENT_REQUEST_BYTES } from './room/comments.js';
|
|
31
|
+
/** The CORS headers `options.cors` gives an answer to `request` (none: `null`). */
|
|
32
|
+
const corsHeaders = (request, options) => {
|
|
33
|
+
const cors = options?.cors;
|
|
34
|
+
const origin = request.headers.get('Origin');
|
|
35
|
+
if (!cors || origin === null || !originAllowed(request, options))
|
|
36
|
+
return null;
|
|
37
|
+
const headers = new Headers();
|
|
38
|
+
if (options?.allowedOrigins === undefined) {
|
|
39
|
+
headers.set('Access-Control-Allow-Origin', '*');
|
|
40
|
+
return headers;
|
|
41
|
+
}
|
|
42
|
+
headers.set('Access-Control-Allow-Origin', origin);
|
|
43
|
+
headers.set('Vary', 'Origin');
|
|
44
|
+
if (typeof cors === 'object' && cors.credentials === true)
|
|
45
|
+
headers.set('Access-Control-Allow-Credentials', 'true');
|
|
46
|
+
return headers;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* One HTTP route with `options.cors`: a preflight answered here, every other
|
|
50
|
+
* answer given its CORS headers (a `101` upgrade passes as it is).
|
|
51
|
+
*/
|
|
52
|
+
const withCors = async (request, options, route) => {
|
|
53
|
+
const cors = options?.cors;
|
|
54
|
+
if (cors && request.method === 'OPTIONS' && request.headers.has('Origin')) {
|
|
55
|
+
const headers = corsHeaders(request, options);
|
|
56
|
+
if (headers === null)
|
|
57
|
+
return new Response('origin not allowed', { status: 403 });
|
|
58
|
+
headers.set('Access-Control-Allow-Methods', 'GET, POST');
|
|
59
|
+
headers.set('Access-Control-Allow-Headers', request.headers.get('Access-Control-Request-Headers') ?? 'Content-Type');
|
|
60
|
+
headers.set('Access-Control-Max-Age', String((typeof cors === 'object' ? cors.maxAge : undefined) ?? 600));
|
|
61
|
+
return new Response(null, { status: 204, headers });
|
|
62
|
+
}
|
|
63
|
+
const response = await route();
|
|
64
|
+
const headers = corsHeaders(request, options);
|
|
65
|
+
if (headers === null || response.status === 101)
|
|
66
|
+
return response;
|
|
67
|
+
const merged = new Headers(response.headers);
|
|
68
|
+
headers.forEach((value, name) => merged.set(name, value));
|
|
69
|
+
return new Response(response.body, {
|
|
70
|
+
status: response.status,
|
|
71
|
+
statusText: response.statusText,
|
|
72
|
+
headers: merged
|
|
73
|
+
});
|
|
74
|
+
};
|
|
31
75
|
/** Is `request`'s `Origin` one `options` allows (no `Origin`, or no list: yes)? */
|
|
32
76
|
const originAllowed = (request, options) => {
|
|
33
77
|
const allowed = options?.allowedOrigins;
|
|
@@ -109,6 +153,9 @@ const identityHeaders = (identity) => {
|
|
|
109
153
|
* `404` (the room keeps no history), `405` (another method).
|
|
110
154
|
*/
|
|
111
155
|
export async function routeDocumentHistory(request, rooms, documentId, authorize, options) {
|
|
156
|
+
return withCors(request, options, () => routeHistory(request, rooms, documentId, authorize, options));
|
|
157
|
+
}
|
|
158
|
+
async function routeHistory(request, rooms, documentId, authorize, options) {
|
|
112
159
|
const query = new URL(request.url).searchParams;
|
|
113
160
|
const op = request.method === 'GET'
|
|
114
161
|
? query.has('key')
|
|
@@ -191,6 +238,9 @@ const bodyWithin = async (request, max) => {
|
|
|
191
238
|
* comment bytes full), `429` (the user past the room's comment rate).
|
|
192
239
|
*/
|
|
193
240
|
export async function routeDocumentComments(request, rooms, documentId, authorize, options) {
|
|
241
|
+
return withCors(request, options, () => routeComments(request, rooms, documentId, authorize, options));
|
|
242
|
+
}
|
|
243
|
+
async function routeComments(request, rooms, documentId, authorize, options) {
|
|
194
244
|
const op = request.method === 'GET' ? 'list' : request.method === 'POST' ? 'post' : null;
|
|
195
245
|
if (op === null)
|
|
196
246
|
return new Response('method not allowed', { status: 405 });
|
|
@@ -215,6 +265,9 @@ export async function routeDocumentComments(request, rooms, documentId, authoriz
|
|
|
215
265
|
.fetch(new Request(request.url, { method: op === 'post' ? 'POST' : 'GET', headers, body }));
|
|
216
266
|
}
|
|
217
267
|
export async function routeDocumentSocket(request, rooms, documentId, authorize, options) {
|
|
268
|
+
return withCors(request, options, () => routeSocket(request, rooms, documentId, authorize, options));
|
|
269
|
+
}
|
|
270
|
+
async function routeSocket(request, rooms, documentId, authorize, options) {
|
|
218
271
|
// The probes: a plain GET, authorized like a dial, answered with JSON or
|
|
219
272
|
// an HTTP status — `lastUpdated` and `snapshot` (the document).
|
|
220
273
|
const query = new URL(request.url).searchParams;
|
|
@@ -48,7 +48,7 @@ export type CommentsClientOptions = {
|
|
|
48
48
|
/**
|
|
49
49
|
* The websocket sync's server URL (the `server` of `<Edytor>` or
|
|
50
50
|
* `createWebsocketSync`), whose socket hears the room's changes. Default:
|
|
51
|
-
*
|
|
51
|
+
* every websocket sync of the same room on the page, whatever its URL.
|
|
52
52
|
*/
|
|
53
53
|
socket?: string;
|
|
54
54
|
/** Query parameters sent with each request (a token): an object, or a function read at every request. */
|
|
@@ -34,7 +34,7 @@ export const createCommentsClient = (options) => {
|
|
|
34
34
|
assertRoomId(options.room);
|
|
35
35
|
const server = options.server.replace(/\/+$/, '');
|
|
36
36
|
const base = `${server.replace(/^ws/, 'http')}/${encodeURIComponent(options.room)}`;
|
|
37
|
-
const socket =
|
|
37
|
+
const socket = options.socket?.replace(/\/+$/, '') ?? null;
|
|
38
38
|
const request = async (method, body) => {
|
|
39
39
|
const url = new URL(base);
|
|
40
40
|
const params = typeof options.params === 'function' ? options.params() : options.params;
|
|
@@ -42,8 +42,8 @@ const getCaretRect = (point, origin, editor) => {
|
|
|
42
42
|
const range = (point.node.ownerDocument ?? editor.ownerDocument).createRange();
|
|
43
43
|
range.setStart(point.node, point.offset);
|
|
44
44
|
range.collapse(true);
|
|
45
|
-
const rect =
|
|
46
|
-
if (rect
|
|
45
|
+
const rect = range.getBoundingClientRect();
|
|
46
|
+
if (rect.width || rect.height) {
|
|
47
47
|
return toRemoteRect(rect, origin);
|
|
48
48
|
}
|
|
49
49
|
return getFallbackRect(point, origin, editor);
|
|
@@ -71,7 +71,7 @@ const getSelectionRects = (start, end, origin, editor) => {
|
|
|
71
71
|
(end.text.node && renderSkipped(end.text.node))) {
|
|
72
72
|
return [getFallbackRect(start, origin, editor)];
|
|
73
73
|
}
|
|
74
|
-
const clientRects =
|
|
74
|
+
const clientRects = Array.from(range.getClientRects());
|
|
75
75
|
const seen = new Set();
|
|
76
76
|
const rects = clientRects
|
|
77
77
|
.filter((rect) => rect.width || rect.height)
|
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
import { Edytor as EdytorClass, useEdytor } from '../edytor.svelte.js';
|
|
6
6
|
import {
|
|
7
7
|
SyncRefusedError,
|
|
8
|
-
type Awareness,
|
|
9
8
|
type DocChange,
|
|
10
9
|
type DocumentActor,
|
|
11
|
-
type EdytorDocument
|
|
12
|
-
type YDoc
|
|
10
|
+
type EdytorDocument
|
|
13
11
|
} from '../crdt/index.js';
|
|
14
12
|
import { CLOSE, validRoomId } from '../crdt/providers/room.js';
|
|
15
13
|
import type { EdytorSync, WebsocketSyncOptions } from '../collaboration/index.js';
|
|
@@ -75,8 +73,6 @@
|
|
|
75
73
|
edytor?: EdytorClass;
|
|
76
74
|
/** The assembled document this view renders (see `crdt/document.ts`). */
|
|
77
75
|
document?: EdytorDocument;
|
|
78
|
-
doc?: YDoc;
|
|
79
|
-
awareness?: Awareness;
|
|
80
76
|
/** The local author (id, name, color) of the document this view owns: attribution and presence. */
|
|
81
77
|
actor?: DocumentActor;
|
|
82
78
|
/**
|
|
@@ -187,7 +183,6 @@
|
|
|
187
183
|
edytor = $bindable(),
|
|
188
184
|
// Aliased so the DOM `document` global keeps working in this scope.
|
|
189
185
|
document: edytorDocument,
|
|
190
|
-
doc,
|
|
191
186
|
readonly = false,
|
|
192
187
|
allowNesting = false,
|
|
193
188
|
value = defaultValue,
|
|
@@ -200,7 +195,6 @@
|
|
|
200
195
|
onSyncRefused,
|
|
201
196
|
requireHydration,
|
|
202
197
|
snapshot,
|
|
203
|
-
awareness,
|
|
204
198
|
actor,
|
|
205
199
|
presence,
|
|
206
200
|
onChange,
|
|
@@ -221,8 +215,6 @@
|
|
|
221
215
|
allowNesting,
|
|
222
216
|
plugins: defaultPlugins ? withDefaults(userPlugins) : userPlugins,
|
|
223
217
|
document: edytorDocument,
|
|
224
|
-
doc,
|
|
225
|
-
awareness,
|
|
226
218
|
actor,
|
|
227
219
|
requireHydration,
|
|
228
220
|
hotkeys,
|
|
@@ -294,7 +286,7 @@
|
|
|
294
286
|
}
|
|
295
287
|
});
|
|
296
288
|
|
|
297
|
-
// The component owns the Edytor — release its
|
|
289
|
+
// The component owns the Edytor — release its facade/
|
|
298
290
|
// undo-manager listeners so a shared doc doesn't retain dead mounts.
|
|
299
291
|
// `onDestroy` also runs after a server render: a view-owned document
|
|
300
292
|
// (and its awareness timer) must not outlive the request.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Edytor as EdytorClass, useEdytor } from '../edytor.svelte.js';
|
|
2
|
-
import { SyncRefusedError, type
|
|
2
|
+
import { SyncRefusedError, type DocChange, type DocumentActor, type EdytorDocument } from '../crdt/index.js';
|
|
3
3
|
import type { EdytorSync, WebsocketSyncOptions } from '../collaboration/index.js';
|
|
4
4
|
import { type PresenceOptions } from '../collaboration/awarenessSelection.js';
|
|
5
5
|
export { EdytorClass as EdytorContext, useEdytor };
|
|
@@ -21,8 +21,6 @@ export type EdytorProps = {
|
|
|
21
21
|
edytor?: EdytorClass;
|
|
22
22
|
/** The assembled document this view renders (see `crdt/document.ts`). */
|
|
23
23
|
document?: EdytorDocument;
|
|
24
|
-
doc?: YDoc;
|
|
25
|
-
awareness?: Awareness;
|
|
26
24
|
/** The local author (id, name, color) of the document this view owns: attribution and presence. */
|
|
27
25
|
actor?: DocumentActor;
|
|
28
26
|
/**
|