@blocknote/core 0.56.0 → 0.57.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/NOTICE.txt +101 -0
- package/dist/BlockNoteExtension-U58cXw1g.js +64 -0
- package/dist/ThreadStore-CSEwCO0O.js +8 -0
- package/dist/{UserStore-OZJP3K8T.js → UserStore-BFv6NXA-.js} +3 -7
- package/dist/ar-DPJDxCQI.js +3 -0
- package/dist/blocknote.js +8 -6
- package/dist/blocks-BUX9dXi9.js +2063 -0
- package/dist/blocks.js +3 -2
- package/dist/comments.js +8 -9
- package/dist/de-CakHBokE.js +3 -0
- package/dist/emoji-data.js +102 -0
- package/dist/en-BGdzE27X.js +3 -0
- package/dist/{en-Ch-vvt5e.js → en-Ne9rlj9Y.js} +9 -6
- package/dist/es-VeBX6MEG.js +3 -0
- package/dist/{extensions-BbM81hHa.js → extensions-CEgexSyF.js} +846 -824
- package/dist/extensions.js +4 -4
- package/dist/fa-Dt7EYtKf.js +3 -0
- package/dist/fr-DUhhjxrJ.js +3 -0
- package/dist/getDefaultSlashMenuItems-DfDOr807.js +1939 -0
- package/dist/he-BShJg1dK.js +3 -0
- package/dist/hr-BXtyqmwg.js +3 -0
- package/dist/is-2Fb-0w_j.js +3 -0
- package/dist/it-CiZtVb3Y.js +3 -0
- package/dist/ja-CsxD3kEL.js +3 -0
- package/dist/ko-It6g03Cy.js +3 -0
- package/dist/locales.js +692 -54
- package/dist/markGroups-BszXCkX8.js +18 -0
- package/dist/nb-CLao87La.js +3 -0
- package/dist/nl-JQSo8dht.js +3 -0
- package/dist/pl-DEMBgHEP.js +3 -0
- package/dist/pt-CBCdYAax.js +3 -0
- package/dist/ru-BQk_9Q-L.js +3 -0
- package/dist/sk-kgB2DtDL.js +3 -0
- package/dist/{src-BmLsLZfE.js → src-DksfoQmN.js} +1173 -1090
- package/dist/style.css +1 -1
- package/dist/tr-DkcSXX8f.js +3 -0
- package/dist/uk-Bib-e6bV.js +3 -0
- package/dist/uz-B2jaKhJb.js +3 -0
- package/dist/vi-V_GFRxE8.js +3 -0
- package/dist/y.js +356 -361
- package/dist/yjs.js +134 -135
- package/dist/zh-hant-2ZrAkFnC.js +3 -0
- package/dist/zh-jglyCmjs.js +3 -0
- package/package.json +45 -21
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.d.ts +5 -0
- package/types/src/api/blockManipulation/tables/tables.d.ts +9 -4
- package/types/src/api/clipboard/fromClipboard/normalizeOfficeHTML.d.ts +5 -0
- package/types/src/api/exporters/markdown/wrapWithDelimiter.d.ts +6 -0
- package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +4 -0
- package/types/src/blocks/defaultBlocks.d.ts +10 -0
- package/types/src/editor/BlockNoteEditor.d.ts +2 -1
- package/types/src/editor/managers/ExtensionManager/index.d.ts +4 -4
- package/types/src/editor/managers/StyleManager.d.ts +2 -1
- package/types/src/emoji-data/frimousse/ar.d.ts +2 -0
- package/types/src/emoji-data/frimousse/common.d.ts +3 -0
- package/types/src/emoji-data/frimousse/de.d.ts +2 -0
- package/types/src/emoji-data/frimousse/en.d.ts +2 -0
- package/types/src/emoji-data/frimousse/es.d.ts +2 -0
- package/types/src/emoji-data/frimousse/fa.d.ts +2 -0
- package/types/src/emoji-data/frimousse/fr.d.ts +2 -0
- package/types/src/emoji-data/frimousse/he.d.ts +2 -0
- package/types/src/emoji-data/frimousse/hr.d.ts +2 -0
- package/types/src/emoji-data/frimousse/is.d.ts +2 -0
- package/types/src/emoji-data/frimousse/it.d.ts +2 -0
- package/types/src/emoji-data/frimousse/ja.d.ts +2 -0
- package/types/src/emoji-data/frimousse/ko.d.ts +2 -0
- package/types/src/emoji-data/frimousse/loadFrimousseData.d.ts +2 -0
- package/types/src/emoji-data/frimousse/nb.d.ts +2 -0
- package/types/src/emoji-data/frimousse/nl.d.ts +2 -0
- package/types/src/emoji-data/frimousse/pl.d.ts +2 -0
- package/types/src/emoji-data/frimousse/pt.d.ts +2 -0
- package/types/src/emoji-data/frimousse/ru.d.ts +2 -0
- package/types/src/emoji-data/frimousse/sk.d.ts +2 -0
- package/types/src/emoji-data/frimousse/tr.d.ts +2 -0
- package/types/src/emoji-data/frimousse/types.d.ts +21 -0
- package/types/src/emoji-data/frimousse/uk.d.ts +2 -0
- package/types/src/emoji-data/frimousse/uz.d.ts +2 -0
- package/types/src/emoji-data/frimousse/vi.d.ts +2 -0
- package/types/src/emoji-data/frimousse/zh-hant.d.ts +2 -0
- package/types/src/emoji-data/frimousse/zh.d.ts +2 -0
- package/types/src/emoji-data/index.d.ts +3 -0
- package/types/src/emoji-data/searchEmojis.d.ts +5 -0
- package/types/src/extensions/Loading/Loading.d.ts +11 -0
- package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +13 -4
- package/types/src/extensions/SideMenu/SideMenu.d.ts +2 -1
- package/types/src/extensions/Versioning/Versioning.d.ts +2 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +1 -0
- package/types/src/extensions/Versioning/types.d.ts +12 -6
- package/types/src/extensions/Versioning/versioningState.d.ts +6 -0
- package/types/src/extensions/index.d.ts +1 -2
- package/types/src/i18n/dictionary.d.ts +4 -1
- package/types/src/i18n/locales/en.d.ts +6 -0
- package/types/src/i18n/locales/fa.d.ts +6 -0
- package/types/src/i18n/locales/index.d.ts +1 -0
- package/types/src/i18n/locales/sk.d.ts +6 -0
- package/types/src/i18n/locales/tr.d.ts +378 -0
- package/types/src/index.d.ts +0 -1
- package/types/src/schema/inlineContent/createSpec.d.ts +2 -1
- package/types/src/schema/inlineContent/internal.d.ts +1 -1
- package/types/src/schema/inlineContent/types.d.ts +2 -4
- package/types/src/schema/styles/createSpec.d.ts +2 -1
- package/types/src/schema/styles/internal.d.ts +4 -1
- package/types/src/schema/styles/types.d.ts +2 -0
- package/types/src/y/extensions/YSync.d.ts +1 -1
- package/types/src/y/extensions/index.d.ts +1 -1
- package/types/src/y/versioning/yhub.d.ts +2 -0
- package/types/src/yjs/extensions/Versioning.d.ts +1 -0
- package/types/src/yjs/extensions/YUndo.d.ts +3 -2
- package/types/src/yjs/extensions/index.d.ts +1 -1
- package/dist/BlockNoteExtension-DjEkXkR5.cjs +0 -2
- package/dist/BlockNoteExtension-DjEkXkR5.cjs.map +0 -1
- package/dist/BlockNoteExtension-TsTGtIeX.js +0 -87
- package/dist/BlockNoteExtension-TsTGtIeX.js.map +0 -1
- package/dist/ThreadStore-Bx-gSEh1.cjs +0 -2
- package/dist/ThreadStore-Bx-gSEh1.cjs.map +0 -1
- package/dist/ThreadStore-et9wB5Xt.js +0 -11
- package/dist/ThreadStore-et9wB5Xt.js.map +0 -1
- package/dist/UserStore-CTVzVGh-.cjs +0 -2
- package/dist/UserStore-CTVzVGh-.cjs.map +0 -1
- package/dist/UserStore-OZJP3K8T.js.map +0 -1
- package/dist/blocknote.cjs +0 -1
- package/dist/blocks-COVwe5Cf.cjs +0 -12
- package/dist/blocks-COVwe5Cf.cjs.map +0 -1
- package/dist/blocks-COYcDVg7.js +0 -3943
- package/dist/blocks-COYcDVg7.js.map +0 -1
- package/dist/blocks.cjs +0 -1
- package/dist/comments.cjs +0 -2
- package/dist/comments.cjs.map +0 -1
- package/dist/comments.js.map +0 -1
- package/dist/en-Ch-vvt5e.js.map +0 -1
- package/dist/en-N5lu0-j8.cjs +0 -2
- package/dist/en-N5lu0-j8.cjs.map +0 -1
- package/dist/extensions-BbM81hHa.js.map +0 -1
- package/dist/extensions-D_WkAfSt.cjs +0 -58
- package/dist/extensions-D_WkAfSt.cjs.map +0 -1
- package/dist/extensions.cjs +0 -1
- package/dist/locales.cjs +0 -2
- package/dist/locales.cjs.map +0 -1
- package/dist/locales.js.map +0 -1
- package/dist/src-4OQT3z5S.cjs +0 -23
- package/dist/src-4OQT3z5S.cjs.map +0 -1
- package/dist/src-BmLsLZfE.js.map +0 -1
- package/dist/webpack-stats.json +0 -1
- package/dist/y.cjs +0 -2
- package/dist/y.cjs.map +0 -1
- package/dist/y.js.map +0 -1
- package/dist/yjs.cjs +0 -2
- package/dist/yjs.cjs.map +0 -1
- package/dist/yjs.js.map +0 -1
- package/src/api/README.md +0 -8
- package/src/api/__snapshots__/blocks-deleted-nested-deep.json +0 -26
- package/src/api/__snapshots__/blocks-deleted-nested.json +0 -68
- package/src/api/__snapshots__/blocks-deleted.json +0 -26
- package/src/api/__snapshots__/blocks-indented-changed.json +0 -129
- package/src/api/__snapshots__/blocks-inserted-nested.json +0 -62
- package/src/api/__snapshots__/blocks-inserted.json +0 -20
- package/src/api/__snapshots__/blocks-moved-deeper-into-nesting.json +0 -164
- package/src/api/__snapshots__/blocks-moved-down-twice-in-same-parent.json +0 -44
- package/src/api/__snapshots__/blocks-moved-insert-changes-sibling-order.json +0 -26
- package/src/api/__snapshots__/blocks-moved-multiple-in-same-transaction.json +0 -188
- package/src/api/__snapshots__/blocks-moved-nested-sibling-reorder.json +0 -180
- package/src/api/__snapshots__/blocks-moved-to-different-parent.json +0 -78
- package/src/api/__snapshots__/blocks-moved-to-root-level.json +0 -78
- package/src/api/__snapshots__/blocks-moved-up-down-in-same-parent.json +0 -44
- package/src/api/__snapshots__/blocks-moved-up-down-in-same-transaction.json +0 -44
- package/src/api/__snapshots__/blocks-outdented-changed.json +0 -129
- package/src/api/__snapshots__/blocks-updated-content-inserted.json +0 -42
- package/src/api/__snapshots__/blocks-updated-multiple-insert.json +0 -50
- package/src/api/__snapshots__/blocks-updated-multiple.json +0 -82
- package/src/api/__snapshots__/blocks-updated-nested-deep.json +0 -42
- package/src/api/__snapshots__/blocks-updated-nested-multiple.json +0 -118
- package/src/api/__snapshots__/blocks-updated-nested.json +0 -78
- package/src/api/__snapshots__/blocks-updated-single.json +0 -42
- package/src/api/__snapshots__/blocks-updated.json +0 -42
- package/src/api/blockManipulation/__snapshots__/transactions.test.ts.snap +0 -34
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -4570
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +0 -176
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +0 -95
- package/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.ts +0 -217
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -2761
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +0 -251
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +0 -187
- package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +0 -13625
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +0 -391
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +0 -350
- package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -952
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +0 -917
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +0 -248
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -5710
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +0 -306
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +0 -143
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -3507
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +0 -364
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +0 -90
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -15085
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +0 -1210
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +0 -706
- package/src/api/blockManipulation/getBlock/getBlock.ts +0 -104
- package/src/api/blockManipulation/insertContentAt.ts +0 -83
- package/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.ts +0 -173
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.ts +0 -293
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.ts +0 -145
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.ts +0 -783
- package/src/api/blockManipulation/layoutBlocks/plainBlocks.test.ts +0 -180
- package/src/api/blockManipulation/layoutBlocks/titledBlocks.test.ts +0 -365
- package/src/api/blockManipulation/selections/selection.ts +0 -234
- package/src/api/blockManipulation/selections/textCursorPosition.ts +0 -63
- package/src/api/blockManipulation/setupTestEnv.ts +0 -223
- package/src/api/blockManipulation/tables/tables.test.ts +0 -2127
- package/src/api/blockManipulation/tables/tables.ts +0 -887
- package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +0 -8
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +0 -55
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +0 -209
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +0 -38
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +0 -157
- package/src/api/clipboard/toClipboard/copyExtension.ts +0 -299
- package/src/api/combineTransactionSteps.ts +0 -22
- package/src/api/exporters/html/externalHTMLExporter.ts +0 -76
- package/src/api/exporters/html/internalHTMLSerializer.ts +0 -182
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +0 -510
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +0 -283
- package/src/api/exporters/markdown/htmlToMarkdown.ts +0 -895
- package/src/api/exporters/markdown/markdownExporter.ts +0 -41
- package/src/api/getBlockInfoFromPos.test.ts +0 -681
- package/src/api/getBlockInfoFromPos.ts +0 -693
- package/src/api/getBlocksChangedByTransaction.test.ts +0 -783
- package/src/api/getBlocksChangedByTransaction.ts +0 -458
- package/src/api/getChangedRangeWithAttrs.ts +0 -54
- package/src/api/getChangedRanges.test.ts +0 -391
- package/src/api/getChangedRanges.ts +0 -368
- package/src/api/nodeConversions/blockToNode.test.ts +0 -113
- package/src/api/nodeConversions/blockToNode.ts +0 -427
- package/src/api/nodeConversions/fragmentToBlocks.ts +0 -48
- package/src/api/nodeConversions/nodeToBlock.ts +0 -717
- package/src/api/nodeUtil.ts +0 -46
- package/src/api/parsers/html/parseHTML.ts +0 -80
- package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +0 -144
- package/src/api/parsers/html/util/nestedLists.test.ts +0 -165
- package/src/api/parsers/html/util/nestedLists.ts +0 -123
- package/src/api/parsers/html/util/normalizeWhitespace.ts +0 -87
- package/src/api/parsers/markdown/autolink.ts +0 -23
- package/src/api/parsers/markdown/detectMarkdown.test.ts +0 -211
- package/src/api/parsers/markdown/detectMarkdown.ts +0 -61
- package/src/api/parsers/markdown/markdownToHtml.ts +0 -1444
- package/src/api/parsers/markdown/parseMarkdown.ts +0 -24
- package/src/api/pmUtil.ts +0 -79
- package/src/api/positionMapping.test.ts +0 -209
- package/src/api/positionMapping.ts +0 -42
- package/src/blocks/Audio/block.ts +0 -171
- package/src/blocks/Audio/parseAudioElement.ts +0 -5
- package/src/blocks/BlockNoteSchema.ts +0 -59
- package/src/blocks/Code/CodeBlockOptions.ts +0 -83
- package/src/blocks/Code/block.test.ts +0 -265
- package/src/blocks/Code/block.ts +0 -56
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +0 -125
- package/src/blocks/Code/helpers/parse/parsePreCode.ts +0 -45
- package/src/blocks/Code/helpers/render/createCodeBlock.ts +0 -98
- package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +0 -14
- package/src/blocks/Divider/block.ts +0 -49
- package/src/blocks/File/block.ts +0 -95
- package/src/blocks/File/helpers/parse/parseEmbedElement.ts +0 -5
- package/src/blocks/File/helpers/parse/parseFigureElement.ts +0 -16
- package/src/blocks/File/helpers/render/createAddFileButton.ts +0 -69
- package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +0 -88
- package/src/blocks/File/helpers/render/createFileNameWithIcon.ts +0 -37
- package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +0 -271
- package/src/blocks/File/helpers/toExternalHTML/createFigureWithCaption.ts +0 -13
- package/src/blocks/File/helpers/toExternalHTML/createLinkWithCaption.ts +0 -15
- package/src/blocks/Heading/block.ts +0 -227
- package/src/blocks/Image/block.ts +0 -193
- package/src/blocks/Image/parseImageElement.ts +0 -7
- package/src/blocks/ListItem/BulletListItem/block.ts +0 -129
- package/src/blocks/ListItem/CheckListItem/block.test.ts +0 -61
- package/src/blocks/ListItem/CheckListItem/block.ts +0 -184
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +0 -352
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +0 -239
- package/src/blocks/ListItem/NumberedListItem/block.ts +0 -143
- package/src/blocks/ListItem/ToggleListItem/block.ts +0 -139
- package/src/blocks/ListItem/getListItemContent.ts +0 -115
- package/src/blocks/PageBreak/block.ts +0 -72
- package/src/blocks/PageBreak/getPageBreakSlashMenuItems.ts +0 -47
- package/src/blocks/Paragraph/block.ts +0 -80
- package/src/blocks/Quote/block.ts +0 -99
- package/src/blocks/README.md +0 -3
- package/src/blocks/Table/TableExtension.test.ts +0 -231
- package/src/blocks/Table/TableExtension.ts +0 -115
- package/src/blocks/Table/block.ts +0 -492
- package/src/blocks/ToggleWrapper/createToggleFrame.ts +0 -126
- package/src/blocks/ToggleWrapper/toggleBlocks.browser.test.ts +0 -1056
- package/src/blocks/Video/block.ts +0 -142
- package/src/blocks/Video/parseVideoElement.ts +0 -7
- package/src/blocks/defaultBlockHelpers.ts +0 -113
- package/src/blocks/defaultBlockTypeGuards.ts +0 -167
- package/src/blocks/defaultBlockTypeItems.test.ts +0 -70
- package/src/blocks/defaultBlockTypeItems.ts +0 -99
- package/src/blocks/defaultBlocks.test.ts +0 -67
- package/src/blocks/defaultBlocks.ts +0 -214
- package/src/blocks/defaultProps.ts +0 -165
- package/src/blocks/getDetailsContent.ts +0 -77
- package/src/blocks/index.ts +0 -30
- package/src/comments/CommentEditorSubmitExtension.test.ts +0 -141
- package/src/comments/CommentEditorSubmitExtension.ts +0 -56
- package/src/comments/extension.ts +0 -396
- package/src/comments/index.ts +0 -8
- package/src/comments/mark.ts +0 -64
- package/src/comments/threadstore/DefaultThreadStoreAuth.ts +0 -106
- package/src/comments/threadstore/ThreadStore.ts +0 -130
- package/src/comments/threadstore/ThreadStoreAuth.ts +0 -13
- package/src/comments/threadstore/TipTapThreadStore.ts +0 -292
- package/src/comments/threadstore/tiptap/types.ts +0 -131
- package/src/comments/types.ts +0 -121
- package/src/editor/Block.css +0 -1498
- package/src/editor/BlockNoteEditor.node.test.ts +0 -35
- package/src/editor/BlockNoteEditor.test.ts +0 -278
- package/src/editor/BlockNoteEditor.ts +0 -1559
- package/src/editor/BlockNoteExtension.test.ts +0 -103
- package/src/editor/BlockNoteExtension.ts +0 -246
- package/src/editor/README.md +0 -3
- package/src/editor/blockColors.browser.test.ts +0 -127
- package/src/editor/cursorPositionTypes.ts +0 -17
- package/src/editor/defaultColors.ts +0 -77
- package/src/editor/editor.css +0 -257
- package/src/editor/managers/BlockManager.ts +0 -256
- package/src/editor/managers/EventManager.browser.test.ts +0 -334
- package/src/editor/managers/EventManager.ts +0 -260
- package/src/editor/managers/ExportManager.ts +0 -137
- package/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.ts +0 -45
- package/src/editor/managers/ExtensionManager/ExtensionManager.node.test.ts +0 -209
- package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +0 -336
- package/src/editor/managers/ExtensionManager/extensions.ts +0 -200
- package/src/editor/managers/ExtensionManager/index.ts +0 -764
- package/src/editor/managers/ExtensionManager/symbol.ts +0 -5
- package/src/editor/managers/SelectionManager.ts +0 -120
- package/src/editor/managers/StateManager.ts +0 -261
- package/src/editor/managers/StyleManager.browser.test.ts +0 -122
- package/src/editor/managers/StyleManager.test.ts +0 -98
- package/src/editor/managers/StyleManager.ts +0 -278
- package/src/editor/managers/index.ts +0 -8
- package/src/editor/performance.test.ts +0 -192
- package/src/editor/selectionTypes.ts +0 -14
- package/src/editor/transformPasted.test.ts +0 -295
- package/src/editor/transformPasted.ts +0 -294
- package/src/exporter/ExportImage.ts +0 -50
- package/src/exporter/Exporter.test.ts +0 -255
- package/src/exporter/Exporter.ts +0 -185
- package/src/exporter/index.ts +0 -3
- package/src/exporter/mapping.ts +0 -110
- package/src/extensions/BlockChange/BlockChange.ts +0 -67
- package/src/extensions/DropCursor/DropCursor.ts +0 -376
- package/src/extensions/DropCursor/dropIntoChildren.ts +0 -80
- package/src/extensions/DropCursor/utils.ts +0 -195
- package/src/extensions/FilePanel/FilePanel.ts +0 -41
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +0 -157
- package/src/extensions/History/History.ts +0 -11
- package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +0 -109
- package/src/extensions/LinkToolbar/LinkToolbar.ts +0 -76
- package/src/extensions/LinkToolbar/protocols.ts +0 -13
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.ts +0 -190
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +0 -112
- package/src/extensions/Placeholder/Placeholder.test.ts +0 -23
- package/src/extensions/Placeholder/Placeholder.ts +0 -150
- package/src/extensions/PositionMapping/PositionMapping.ts +0 -68
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +0 -156
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +0 -201
- package/src/extensions/README.md +0 -3
- package/src/extensions/ReadOnly/ReadOnly.test.ts +0 -181
- package/src/extensions/ReadOnly/ReadOnly.ts +0 -73
- package/src/extensions/ShowSelection/ShowSelection.ts +0 -61
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +0 -89
- package/src/extensions/SideMenu/SideMenu.ts +0 -470
- package/src/extensions/SideMenu/blockDropHandling.ts +0 -372
- package/src/extensions/SideMenu/blockGeometry.browser.test.ts +0 -148
- package/src/extensions/SideMenu/blockGeometry.test.ts +0 -46
- package/src/extensions/SideMenu/blockGeometry.ts +0 -53
- package/src/extensions/SideMenu/dragging.ts +0 -200
- package/src/extensions/SideMenu/sideMenuHover.test.ts +0 -36
- package/src/extensions/SideMenu/sideMenuHover.ts +0 -270
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +0 -193
- package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +0 -142
- package/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.ts +0 -4
- package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +0 -11
- package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +0 -309
- package/src/extensions/SuggestionMenu/SuggestionMenu.ts +0 -436
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +0 -76
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +0 -299
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +0 -130
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +0 -89
- package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +0 -135
- package/src/extensions/SyntaxHighlighting/shiki.ts +0 -116
- package/src/extensions/TableHandles/TableHandles.browser.test.ts +0 -307
- package/src/extensions/TableHandles/TableHandles.ts +0 -1263
- package/src/extensions/TrailingNode/TrailingNode.ts +0 -233
- package/src/extensions/Versioning/Versioning.browser.test.ts +0 -151
- package/src/extensions/Versioning/Versioning.node.test.ts +0 -177
- package/src/extensions/Versioning/Versioning.ts +0 -161
- package/src/extensions/Versioning/__test__/result.ts +0 -12
- package/src/extensions/Versioning/comparison.test.ts +0 -40
- package/src/extensions/Versioning/createVersioning.test.ts +0 -867
- package/src/extensions/Versioning/createVersioning.ts +0 -499
- package/src/extensions/Versioning/formatVersionDate.ts +0 -24
- package/src/extensions/Versioning/inMemoryVersioning.test.ts +0 -572
- package/src/extensions/Versioning/inMemoryVersioning.ts +0 -268
- package/src/extensions/Versioning/index.ts +0 -6
- package/src/extensions/Versioning/scrollScheduling.test.ts +0 -51
- package/src/extensions/Versioning/scrollToFirstChange.test.ts +0 -320
- package/src/extensions/Versioning/scrollToFirstChange.ts +0 -139
- package/src/extensions/Versioning/types.ts +0 -219
- package/src/extensions/Versioning/versioningState.ts +0 -154
- package/src/extensions/blockDOM.browser.test.ts +0 -102
- package/src/extensions/blockDOM.test.ts +0 -178
- package/src/extensions/blockDOM.ts +0 -135
- package/src/extensions/index.ts +0 -27
- package/src/extensions/tiptap-extensions/BackgroundColor/BackgroundColorExtension.ts +0 -17
- package/src/extensions/tiptap-extensions/HardBreak/HardBreak.ts +0 -35
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +0 -1870
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +0 -1116
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.ts +0 -152
- package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +0 -174
- package/src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts +0 -82
- package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +0 -412
- package/src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts +0 -53
- package/src/extensions/tiptap-extensions/Link/helpers/tlds.ts +0 -7
- package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +0 -13
- package/src/extensions/tiptap-extensions/Link/index.ts +0 -2
- package/src/extensions/tiptap-extensions/Link/link.test.ts +0 -945
- package/src/extensions/tiptap-extensions/Link/link.ts +0 -238
- package/src/extensions/tiptap-extensions/TextAlignment/TextAlignmentExtension.ts +0 -33
- package/src/extensions/tiptap-extensions/TextColor/TextColorExtension.ts +0 -17
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +0 -173
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +0 -339
- package/src/extensions/tiptap-extensions/index.ts +0 -7
- package/src/extensions-shared/UiElementPosition.ts +0 -4
- package/src/fonts/inter.browser.test.ts +0 -57
- package/src/i18n/dictionary.ts +0 -17
- package/src/i18n/index.ts +0 -2
- package/src/i18n/locales/ar.ts +0 -443
- package/src/i18n/locales/de.ts +0 -477
- package/src/i18n/locales/en.ts +0 -458
- package/src/i18n/locales/es.ts +0 -456
- package/src/i18n/locales/fa.ts +0 -427
- package/src/i18n/locales/fr.ts +0 -504
- package/src/i18n/locales/he.ts +0 -458
- package/src/i18n/locales/hr.ts +0 -472
- package/src/i18n/locales/index.ts +0 -23
- package/src/i18n/locales/is.ts +0 -472
- package/src/i18n/locales/it.ts +0 -480
- package/src/i18n/locales/ja.ts +0 -498
- package/src/i18n/locales/ko.ts +0 -471
- package/src/i18n/locales/nl.ts +0 -459
- package/src/i18n/locales/no.ts +0 -476
- package/src/i18n/locales/pl.ts +0 -449
- package/src/i18n/locales/pt.ts +0 -451
- package/src/i18n/locales/ru.ts +0 -502
- package/src/i18n/locales/sk.ts +0 -456
- package/src/i18n/locales/uk.ts +0 -482
- package/src/i18n/locales/uz.ts +0 -492
- package/src/i18n/locales/vi.ts +0 -457
- package/src/i18n/locales/zh-tw.ts +0 -499
- package/src/i18n/locales/zh.ts +0 -499
- package/src/index.ts +0 -66
- package/src/locales.ts +0 -1
- package/src/pm-nodes/BlockContainer.test.ts +0 -101
- package/src/pm-nodes/BlockContainer.ts +0 -200
- package/src/pm-nodes/BlockGroup.ts +0 -58
- package/src/pm-nodes/Doc.ts +0 -11
- package/src/pm-nodes/README.md +0 -143
- package/src/pm-nodes/index.ts +0 -3
- package/src/pm-nodes/suggestionMarks.ts +0 -43
- package/src/schema/README.md +0 -3
- package/src/schema/blocks/children.test.ts +0 -288
- package/src/schema/blocks/children.ts +0 -136
- package/src/schema/blocks/createSpec.browser.test.ts +0 -176
- package/src/schema/blocks/createSpec.test.ts +0 -354
- package/src/schema/blocks/createSpec.ts +0 -732
- package/src/schema/blocks/extendBlockSpec.test.ts +0 -188
- package/src/schema/blocks/frame.test.ts +0 -112
- package/src/schema/blocks/frame.ts +0 -337
- package/src/schema/blocks/internal.test.ts +0 -86
- package/src/schema/blocks/internal.ts +0 -288
- package/src/schema/blocks/keyboard.ts +0 -154
- package/src/schema/blocks/layoutBlockAttributes.ts +0 -29
- package/src/schema/blocks/meta.test.ts +0 -53
- package/src/schema/blocks/meta.ts +0 -35
- package/src/schema/blocks/renderFrame.test.ts +0 -691
- package/src/schema/blocks/types.ts +0 -966
- package/src/schema/blocks/validateChildren.ts +0 -156
- package/src/schema/contentTypePropagation.test.ts +0 -182
- package/src/schema/dataAttributes.test.ts +0 -72
- package/src/schema/dataAttributes.ts +0 -69
- package/src/schema/index.ts +0 -15
- package/src/schema/inlineContent/createSpec.test.ts +0 -161
- package/src/schema/inlineContent/createSpec.ts +0 -409
- package/src/schema/inlineContent/internal.ts +0 -131
- package/src/schema/inlineContent/types.ts +0 -204
- package/src/schema/markGroups.ts +0 -82
- package/src/schema/nodeViewMutations.test.ts +0 -146
- package/src/schema/nodeViewMutations.ts +0 -49
- package/src/schema/propTypes.ts +0 -61
- package/src/schema/schema.test.ts +0 -110
- package/src/schema/schema.ts +0 -243
- package/src/schema/styles/createSpec.ts +0 -140
- package/src/schema/styles/internal.ts +0 -155
- package/src/schema/styles/types.ts +0 -57
- package/src/style.css +0 -2
- package/src/user/UserStore.ts +0 -199
- package/src/user/createUserStore.test.ts +0 -126
- package/src/user/index.ts +0 -2
- package/src/user/userColors.test.ts +0 -108
- package/src/user/userColors.ts +0 -101
- package/src/util/EventEmitter.ts +0 -59
- package/src/util/README.md +0 -3
- package/src/util/Store.test.ts +0 -132
- package/src/util/Store.ts +0 -135
- package/src/util/browser.ts +0 -54
- package/src/util/combineByGroup.ts +0 -25
- package/src/util/expandToWords.ts +0 -38
- package/src/util/string.ts +0 -36
- package/src/util/table.ts +0 -110
- package/src/util/topo-sort.test.ts +0 -125
- package/src/util/topo-sort.ts +0 -206
- package/src/util/typescript.ts +0 -17
- package/src/vite-env.d.ts +0 -7
- package/src/y/README.md +0 -5
- package/src/y/comments/RESTYjsThreadStore.ts +0 -138
- package/src/y/comments/YjsThreadStore.test.ts +0 -295
- package/src/y/comments/YjsThreadStore.ts +0 -358
- package/src/y/comments/YjsThreadStoreBase.ts +0 -50
- package/src/y/comments/index.ts +0 -3
- package/src/y/comments/yjsHelpers.ts +0 -125
- package/src/y/extensions/AttributionExtension.test.ts +0 -364
- package/src/y/extensions/AttributionExtension.ts +0 -401
- package/src/y/extensions/DiffVersioningExtension.test.ts +0 -242
- package/src/y/extensions/DiffVersioningExtension.ts +0 -200
- package/src/y/extensions/EmptyDocBinding.test.ts +0 -282
- package/src/y/extensions/ForkYDoc.node.test.ts +0 -77
- package/src/y/extensions/ForkYDoc.test.ts +0 -344
- package/src/y/extensions/ForkYDoc.ts +0 -117
- package/src/y/extensions/History.test.ts +0 -125
- package/src/y/extensions/RelativePositionMapping.test.ts +0 -453
- package/src/y/extensions/RelativePositionMapping.ts +0 -45
- package/src/y/extensions/Suggestions.ts +0 -174
- package/src/y/extensions/Versioning.node.test.ts +0 -126
- package/src/y/extensions/Versioning.test.ts +0 -117
- package/src/y/extensions/Versioning.ts +0 -74
- package/src/y/extensions/YAttributionMarks.ts +0 -422
- package/src/y/extensions/YCursorPlugin.ts +0 -192
- package/src/y/extensions/YSync.node.test.ts +0 -75
- package/src/y/extensions/YSync.ts +0 -197
- package/src/y/extensions/YSyncRemount.test.ts +0 -99
- package/src/y/extensions/blockMatchNodes.ts +0 -173
- package/src/y/extensions/index.ts +0 -140
- package/src/y/extensions/legacyYjsDocBinding.test.ts +0 -652
- package/src/y/extensions/nestingChanges.test.ts +0 -326
- package/src/y/extensions/persistentBlockGroups.test.ts +0 -1709
- package/src/y/extensions/persistentBlockGroups.ts +0 -953
- package/src/y/extensions/snapshotCodec.test.ts +0 -105
- package/src/y/extensions/snapshotCodec.ts +0 -39
- package/src/y/extensions/snapshotPreview.test.ts +0 -201
- package/src/y/extensions/snapshotPreview.ts +0 -292
- package/src/y/extensions/tableReshape.test.ts +0 -121
- package/src/y/extensions/v1BindingSnapshotDiff.test.ts +0 -121
- package/src/y/extensions/versionDiffAttribution.test.ts +0 -944
- package/src/y/extensions/versionDiffPerformance.test.ts +0 -101
- package/src/y/index.ts +0 -5
- package/src/y/utils.test.ts +0 -1309
- package/src/y/utils.ts +0 -366
- package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all-after.json +0 -50
- package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all.json +0 -20
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +0 -32
- package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +0 -1
- package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
- package/src/y/versioning/__test__/fixtures/patch-response.json +0 -4
- package/src/y/versioning/__test__/yhub.test.ts +0 -966
- package/src/y/versioning/index.ts +0 -6
- package/src/y/versioning/yhub.ts +0 -350
- package/src/y/versioning/yhubClient.ts +0 -345
- package/src/yjs/README.md +0 -5
- package/src/yjs/comments/RESTYjsThreadStore.test.ts +0 -95
- package/src/yjs/comments/RESTYjsThreadStore.ts +0 -172
- package/src/yjs/comments/YjsThreadStore.test.ts +0 -295
- package/src/yjs/comments/YjsThreadStore.ts +0 -345
- package/src/yjs/comments/YjsThreadStoreBase.ts +0 -50
- package/src/yjs/comments/index.ts +0 -3
- package/src/yjs/comments/yjsHelpers.ts +0 -127
- package/src/yjs/extensions/FixUpSchema.test.ts +0 -421
- package/src/yjs/extensions/FixUpSchema.ts +0 -99
- package/src/yjs/extensions/ForkYDoc.browser.test.ts +0 -84
- package/src/yjs/extensions/ForkYDoc.node.test.ts +0 -231
- package/src/yjs/extensions/ForkYDoc.test.ts +0 -320
- package/src/yjs/extensions/ForkYDoc.ts +0 -177
- package/src/yjs/extensions/RelativePositionMapping.test.ts +0 -418
- package/src/yjs/extensions/RelativePositionMapping.ts +0 -77
- package/src/yjs/extensions/Versioning.test.ts +0 -376
- package/src/yjs/extensions/Versioning.ts +0 -126
- package/src/yjs/extensions/YCursorPlugin.ts +0 -201
- package/src/yjs/extensions/YSync.ts +0 -16
- package/src/yjs/extensions/YUndo.ts +0 -12
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor-forked.json +0 -19
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor.json +0 -19
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap-forked.html +0 -1
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap.html +0 -1
- package/src/yjs/extensions/index.ts +0 -89
- package/src/yjs/extensions/schemaMigration/SchemaMigration.ts +0 -59
- package/src/yjs/extensions/schemaMigration/migrationRules/index.ts +0 -4
- package/src/yjs/extensions/schemaMigration/migrationRules/migrationRule.ts +0 -4
- package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.ts +0 -130
- package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.ts +0 -91
- package/src/yjs/index.ts +0 -7
- package/src/yjs/utils.test.ts +0 -1013
- package/src/yjs/utils.ts +0 -186
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +0 -1
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.d.ts +0 -1
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/layoutBlocks/plainBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/layoutBlocks/titledBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/tables/tables.test.d.ts +0 -1
- package/types/src/api/getBlockInfoFromPos.test.d.ts +0 -1
- package/types/src/api/getBlocksChangedByTransaction.test.d.ts +0 -1
- package/types/src/api/getChangedRanges.test.d.ts +0 -1
- package/types/src/api/nodeConversions/blockToNode.test.d.ts +0 -1
- package/types/src/api/parsers/html/util/nestedLists.test.d.ts +0 -1
- package/types/src/api/parsers/markdown/detectMarkdown.test.d.ts +0 -1
- package/types/src/api/positionMapping.test.d.ts +0 -1
- package/types/src/blocks/Code/block.test.d.ts +0 -1
- package/types/src/blocks/ListItem/CheckListItem/block.test.d.ts +0 -1
- package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +0 -1
- package/types/src/blocks/Table/TableExtension.test.d.ts +0 -1
- package/types/src/blocks/ToggleWrapper/toggleBlocks.browser.test.d.ts +0 -1
- package/types/src/blocks/defaultBlockTypeItems.test.d.ts +0 -1
- package/types/src/blocks/defaultBlocks.test.d.ts +0 -1
- package/types/src/comments/CommentEditorSubmitExtension.test.d.ts +0 -1
- package/types/src/editor/BlockNoteEditor.node.test.d.ts +0 -1
- package/types/src/editor/BlockNoteEditor.test.d.ts +0 -1
- package/types/src/editor/BlockNoteExtension.test.d.ts +0 -1
- package/types/src/editor/blockColors.browser.test.d.ts +0 -1
- package/types/src/editor/managers/EventManager.browser.test.d.ts +0 -1
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.d.ts +0 -1
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.node.test.d.ts +0 -1
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.test.d.ts +0 -1
- package/types/src/editor/managers/StyleManager.browser.test.d.ts +0 -1
- package/types/src/editor/managers/StyleManager.test.d.ts +0 -1
- package/types/src/editor/performance.test.d.ts +0 -1
- package/types/src/editor/transformPasted.test.d.ts +0 -1
- package/types/src/exporter/Exporter.test.d.ts +0 -1
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.d.ts +0 -1
- package/types/src/extensions/Placeholder/Placeholder.test.d.ts +0 -1
- package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +0 -1
- package/types/src/extensions/ReadOnly/ReadOnly.test.d.ts +0 -1
- package/types/src/extensions/SideMenu/blockGeometry.browser.test.d.ts +0 -1
- package/types/src/extensions/SideMenu/blockGeometry.test.d.ts +0 -1
- package/types/src/extensions/SideMenu/sideMenuHover.test.d.ts +0 -1
- package/types/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.d.ts +0 -4
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.test.d.ts +0 -1
- package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +0 -4
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +0 -1
- package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +0 -1
- package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +0 -1
- package/types/src/extensions/Versioning/Versioning.browser.test.d.ts +0 -1
- package/types/src/extensions/Versioning/Versioning.node.test.d.ts +0 -1
- package/types/src/extensions/Versioning/__test__/result.d.ts +0 -3
- package/types/src/extensions/Versioning/comparison.test.d.ts +0 -1
- package/types/src/extensions/Versioning/createVersioning.test.d.ts +0 -1
- package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +0 -1
- package/types/src/extensions/Versioning/scrollScheduling.test.d.ts +0 -1
- package/types/src/extensions/Versioning/scrollToFirstChange.test.d.ts +0 -1
- package/types/src/extensions/blockDOM.browser.test.d.ts +0 -1
- package/types/src/extensions/blockDOM.test.d.ts +0 -1
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +0 -4
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.d.ts +0 -1
- package/types/src/extensions/tiptap-extensions/Link/link.test.d.ts +0 -1
- package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +0 -4
- package/types/src/fonts/inter.browser.test.d.ts +0 -2
- package/types/src/pm-nodes/BlockContainer.test.d.ts +0 -1
- package/types/src/schema/blocks/children.test.d.ts +0 -1
- package/types/src/schema/blocks/createSpec.browser.test.d.ts +0 -1
- package/types/src/schema/blocks/createSpec.test.d.ts +0 -1
- package/types/src/schema/blocks/extendBlockSpec.test.d.ts +0 -1
- package/types/src/schema/blocks/frame.test.d.ts +0 -1
- package/types/src/schema/blocks/internal.test.d.ts +0 -1
- package/types/src/schema/blocks/meta.test.d.ts +0 -1
- package/types/src/schema/blocks/renderFrame.test.d.ts +0 -1
- package/types/src/schema/contentTypePropagation.test.d.ts +0 -1
- package/types/src/schema/dataAttributes.test.d.ts +0 -1
- package/types/src/schema/inlineContent/createSpec.test.d.ts +0 -1
- package/types/src/schema/nodeViewMutations.test.d.ts +0 -1
- package/types/src/schema/schema.test.d.ts +0 -1
- package/types/src/user/createUserStore.test.d.ts +0 -1
- package/types/src/user/userColors.test.d.ts +0 -1
- package/types/src/util/Store.test.d.ts +0 -1
- package/types/src/util/topo-sort.test.d.ts +0 -1
- package/types/src/y/comments/YjsThreadStore.test.d.ts +0 -1
- package/types/src/y/extensions/AttributionExtension.test.d.ts +0 -1
- package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +0 -1
- package/types/src/y/extensions/EmptyDocBinding.test.d.ts +0 -1
- package/types/src/y/extensions/ForkYDoc.node.test.d.ts +0 -1
- package/types/src/y/extensions/ForkYDoc.test.d.ts +0 -1
- package/types/src/y/extensions/History.test.d.ts +0 -1
- package/types/src/y/extensions/RelativePositionMapping.test.d.ts +0 -1
- package/types/src/y/extensions/Versioning.node.test.d.ts +0 -1
- package/types/src/y/extensions/Versioning.test.d.ts +0 -1
- package/types/src/y/extensions/YSync.node.test.d.ts +0 -1
- package/types/src/y/extensions/YSyncRemount.test.d.ts +0 -1
- package/types/src/y/extensions/legacyYjsDocBinding.test.d.ts +0 -1
- package/types/src/y/extensions/nestingChanges.test.d.ts +0 -1
- package/types/src/y/extensions/persistentBlockGroups.test.d.ts +0 -1
- package/types/src/y/extensions/snapshotCodec.test.d.ts +0 -1
- package/types/src/y/extensions/snapshotPreview.test.d.ts +0 -1
- package/types/src/y/extensions/tableReshape.test.d.ts +0 -1
- package/types/src/y/extensions/v1BindingSnapshotDiff.test.d.ts +0 -1
- package/types/src/y/extensions/versionDiffAttribution.test.d.ts +0 -1
- package/types/src/y/extensions/versionDiffPerformance.test.d.ts +0 -1
- package/types/src/y/utils.test.d.ts +0 -1
- package/types/src/y/versioning/__test__/yhub.test.d.ts +0 -1
- package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +0 -1
- package/types/src/yjs/comments/YjsThreadStore.test.d.ts +0 -1
- package/types/src/yjs/extensions/FixUpSchema.test.d.ts +0 -1
- package/types/src/yjs/extensions/ForkYDoc.browser.test.d.ts +0 -1
- package/types/src/yjs/extensions/ForkYDoc.node.test.d.ts +0 -1
- package/types/src/yjs/extensions/ForkYDoc.test.d.ts +0 -1
- package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +0 -1
- package/types/src/yjs/extensions/Versioning.test.d.ts +0 -1
- package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +0 -1
- package/types/src/yjs/utils.test.d.ts +0 -1
|
@@ -1,966 +0,0 @@
|
|
|
1
|
-
// @vitest-environment node
|
|
2
|
-
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
|
|
3
|
-
import { decodeAny, encodeAny } from "lib0/buffer";
|
|
4
|
-
import * as Y from "@y/y";
|
|
5
|
-
import {
|
|
6
|
-
configureYProsemirror,
|
|
7
|
-
docToDelta,
|
|
8
|
-
ySyncPluginKey,
|
|
9
|
-
} from "@y/prosemirror";
|
|
10
|
-
import {
|
|
11
|
-
createYHubVersionStorage,
|
|
12
|
-
YVersioningExtension,
|
|
13
|
-
type YHubVersionStorageOptions,
|
|
14
|
-
} from "../yhub.js";
|
|
15
|
-
import { YHubClient } from "../yhubClient.js";
|
|
16
|
-
import { createVersioning } from "../../../extensions/Versioning/createVersioning.js";
|
|
17
|
-
import { resultValue } from "../../../extensions/Versioning/__test__/result.js";
|
|
18
|
-
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
19
|
-
import type { VersioningController } from "../../../extensions/Versioning/Versioning.js";
|
|
20
|
-
import { withCollaboration } from "../../extensions/index.js";
|
|
21
|
-
import {
|
|
22
|
-
_blocksToProsemirrorNode,
|
|
23
|
-
docDiffToDelta,
|
|
24
|
-
yNodeToTransaction,
|
|
25
|
-
} from "../../utils.js";
|
|
26
|
-
|
|
27
|
-
const options = { baseUrl: "https://yhub.test/api", org: "org", docId: "doc" };
|
|
28
|
-
const signal = new AbortController().signal;
|
|
29
|
-
const first = { from: 1000, to: 1000, by: ["alice"] };
|
|
30
|
-
const latest = { from: 2000, to: 2000, by: ["bob"] };
|
|
31
|
-
const version = {
|
|
32
|
-
type: "version:v1" as const,
|
|
33
|
-
t: 1000,
|
|
34
|
-
name: "Milestone",
|
|
35
|
-
custom: { restoredFrom: 42, ticket: "BN-1" },
|
|
36
|
-
updatedAt: 3000,
|
|
37
|
-
};
|
|
38
|
-
const cleanup: Array<() => void> = [];
|
|
39
|
-
let fetchSpy = vi.spyOn(globalThis, "fetch");
|
|
40
|
-
beforeEach(() => {
|
|
41
|
-
fetchSpy = vi.spyOn(globalThis, "fetch");
|
|
42
|
-
});
|
|
43
|
-
afterEach(() => {
|
|
44
|
-
for (const dispose of cleanup.splice(0)) {
|
|
45
|
-
dispose();
|
|
46
|
-
}
|
|
47
|
-
vi.restoreAllMocks();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
function response(body: unknown, status = 200) {
|
|
51
|
-
return new Response(status === 204 ? null : new Uint8Array(encodeAny(body)), {
|
|
52
|
-
status,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function storage(activityParams?: YHubVersionStorageOptions["activityParams"]) {
|
|
57
|
-
const doc = new Y.Doc();
|
|
58
|
-
const fragment = doc.get("default");
|
|
59
|
-
cleanup.push(() => doc.destroy());
|
|
60
|
-
return {
|
|
61
|
-
api: createYHubVersionStorage({
|
|
62
|
-
...options,
|
|
63
|
-
activityParams,
|
|
64
|
-
fragment,
|
|
65
|
-
beforeRestoreName: "Before restore",
|
|
66
|
-
}),
|
|
67
|
-
doc,
|
|
68
|
-
fragment,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function request(index: number) {
|
|
73
|
-
const [url, init] = fetchSpy.mock.calls[index];
|
|
74
|
-
return {
|
|
75
|
-
url: new URL(url instanceof Request ? url.url : url),
|
|
76
|
-
method: init?.method ?? "GET",
|
|
77
|
-
body: init?.body instanceof Uint8Array ? decodeAny(init.body) : undefined,
|
|
78
|
-
signal: init?.signal,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Types `a`, `b`, `c` as separate edits at 1000, 1100 and 1200 (by the given
|
|
84
|
-
* authors), serves them through a mocked YHub with the given activity, and
|
|
85
|
-
* returns each character of the shown comparison with the authors that the
|
|
86
|
-
* diff credits it to (none = not changed).
|
|
87
|
-
*/
|
|
88
|
-
async function compareCharacters({
|
|
89
|
-
authors,
|
|
90
|
-
activity,
|
|
91
|
-
target,
|
|
92
|
-
compareTo,
|
|
93
|
-
showCurrentVersion = false,
|
|
94
|
-
}: {
|
|
95
|
-
authors: [string, string, string];
|
|
96
|
-
activity: { first: unknown; history: unknown[] };
|
|
97
|
-
target: { type: "current" } | { type: "snapshot"; id: string };
|
|
98
|
-
compareTo: (history: { id: string }[]) => string;
|
|
99
|
-
showCurrentVersion?: boolean;
|
|
100
|
-
}) {
|
|
101
|
-
const { api, doc, fragment } = storage();
|
|
102
|
-
const editor = BlockNoteEditor.create(
|
|
103
|
-
withCollaboration({
|
|
104
|
-
extensions: [
|
|
105
|
-
YVersioningExtension({ storage: { ...api, showCurrentVersion } }),
|
|
106
|
-
],
|
|
107
|
-
collaboration: { fragment, user: { name: "Alice", color: "red" } },
|
|
108
|
-
}),
|
|
109
|
-
);
|
|
110
|
-
const mode = editor.getExtension<VersioningController>("versioning")!;
|
|
111
|
-
cleanup.unshift(() => {
|
|
112
|
-
mode.dispose();
|
|
113
|
-
editor._tiptapEditor.destroy();
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const edits: {
|
|
117
|
-
at: number;
|
|
118
|
-
content: Uint8Array;
|
|
119
|
-
attributions: Y.ContentMap;
|
|
120
|
-
}[] = [];
|
|
121
|
-
doc.on("beforeObserverCalls", (transaction) => {
|
|
122
|
-
const at = 1000 + edits.length * 100;
|
|
123
|
-
edits.push({
|
|
124
|
-
at,
|
|
125
|
-
content: Y.encodeStateAsUpdate(doc),
|
|
126
|
-
attributions: Y.createContentMapFromContentIds(
|
|
127
|
-
{ inserts: transaction.insertSet, deletes: transaction.deleteSet },
|
|
128
|
-
[
|
|
129
|
-
Y.createContentAttribute("insert", authors[edits.length]),
|
|
130
|
-
Y.createContentAttribute("insertAt", at),
|
|
131
|
-
],
|
|
132
|
-
[],
|
|
133
|
-
),
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
function paragraph(text: string) {
|
|
137
|
-
return _blocksToProsemirrorNode(editor, [
|
|
138
|
-
{ id: "paragraph", type: "paragraph", content: text },
|
|
139
|
-
]);
|
|
140
|
-
}
|
|
141
|
-
const empty = Y.encodeStateAsUpdate(doc);
|
|
142
|
-
for (const text of ["a", "ab", "abc"]) {
|
|
143
|
-
fragment.applyDelta(
|
|
144
|
-
text === "a"
|
|
145
|
-
? docToDelta(paragraph(text))
|
|
146
|
-
: docDiffToDelta(paragraph(text.slice(0, -1)), paragraph(text)),
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
fetchSpy.mockImplementation(async (input) => {
|
|
151
|
-
const url = new URL(input instanceof Request ? input.url : input);
|
|
152
|
-
if (url.pathname.includes("/activity/")) {
|
|
153
|
-
return response({
|
|
154
|
-
activity:
|
|
155
|
-
url.searchParams.get("order") === "asc"
|
|
156
|
-
? [activity.first]
|
|
157
|
-
: activity.history,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
const from = Number(url.searchParams.get("from") ?? 0);
|
|
161
|
-
const to = Number(url.searchParams.get("to") ?? Infinity);
|
|
162
|
-
if (url.searchParams.has("attributions")) {
|
|
163
|
-
const attributions = Y.createContentMap();
|
|
164
|
-
for (const edit of edits.filter(
|
|
165
|
-
(edit) => from <= edit.at && edit.at <= to,
|
|
166
|
-
)) {
|
|
167
|
-
Y.insertIntoIdMap(attributions.inserts, edit.attributions.inserts);
|
|
168
|
-
}
|
|
169
|
-
return response({ attributions: Y.encodeContentMap(attributions) });
|
|
170
|
-
}
|
|
171
|
-
// YHub includes edits at `to`, not just edits before it.
|
|
172
|
-
return response({
|
|
173
|
-
ydoc: edits.findLast((edit) => edit.at <= to)?.content ?? empty,
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
editor.replaceBlocks(editor.document, [
|
|
178
|
-
{ id: "paragraph", type: "paragraph", content: "abc" },
|
|
179
|
-
]);
|
|
180
|
-
editor.prosemirrorView.updateState(
|
|
181
|
-
editor.prosemirrorState.reconfigure({
|
|
182
|
-
plugins: editor._tiptapEditor.extensionManager.plugins,
|
|
183
|
-
}),
|
|
184
|
-
);
|
|
185
|
-
editor.exec(configureYProsemirror({ ytype: fragment }));
|
|
186
|
-
mode.open();
|
|
187
|
-
expect(await mode.list()).toEqual({ status: "done" });
|
|
188
|
-
const state = mode.store.state;
|
|
189
|
-
if (state.mode !== "versions" || state.history.status !== "success") {
|
|
190
|
-
throw new Error("Expected loaded version history");
|
|
191
|
-
}
|
|
192
|
-
expect(
|
|
193
|
-
await mode.select(target, { compareTo: compareTo(state.history.data) }),
|
|
194
|
-
).toEqual({ status: "done" });
|
|
195
|
-
|
|
196
|
-
// Headless editors have no plugin view to hydrate the configured preview.
|
|
197
|
-
const binding = ySyncPluginKey.getState(editor.prosemirrorState)!;
|
|
198
|
-
editor.prosemirrorView.dispatch(
|
|
199
|
-
yNodeToTransaction(editor.prosemirrorState.tr, binding.ytype!, {
|
|
200
|
-
renderer: binding.renderer,
|
|
201
|
-
}),
|
|
202
|
-
);
|
|
203
|
-
const characters: { character: string; authors: string[] }[] = [];
|
|
204
|
-
editor.prosemirrorState.doc.descendants((node) => {
|
|
205
|
-
if (node.isText) {
|
|
206
|
-
const insertion = node.marks.find(
|
|
207
|
-
(mark) => mark.type.name === "y-attributed-insert",
|
|
208
|
-
);
|
|
209
|
-
for (const character of node.text!) {
|
|
210
|
-
characters.push({
|
|
211
|
-
character,
|
|
212
|
-
authors: insertion?.attrs.userIds ?? [],
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
return characters;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
it.each([false, true])(
|
|
221
|
-
"attributes every character of abc when comparing since beginning (Current: %s)",
|
|
222
|
-
async (showCurrentVersion) => {
|
|
223
|
-
const characters = await compareCharacters({
|
|
224
|
-
authors: ["alice", "alice", "alice"],
|
|
225
|
-
activity: { first, history: [{ ...first, to: 1200 }] },
|
|
226
|
-
target: showCurrentVersion
|
|
227
|
-
? { type: "current" }
|
|
228
|
-
: { type: "snapshot", id: "1000-1200" },
|
|
229
|
-
compareTo: (history) => history.at(-1)!.id,
|
|
230
|
-
showCurrentVersion,
|
|
231
|
-
});
|
|
232
|
-
expect(characters).toEqual(
|
|
233
|
-
["a", "b", "c"].map((character) => ({ character, authors: ["alice"] })),
|
|
234
|
-
);
|
|
235
|
-
},
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
it("shows only the selected version's edits when comparing to the previous version", async () => {
|
|
239
|
-
// Beginning (a), then "1000-1100" by alice (a, b), then "1200-1200" by bob (c).
|
|
240
|
-
const characters = await compareCharacters({
|
|
241
|
-
authors: ["alice", "alice", "bob"],
|
|
242
|
-
activity: {
|
|
243
|
-
first,
|
|
244
|
-
history: [
|
|
245
|
-
{ from: 1200, to: 1200, by: ["bob"] },
|
|
246
|
-
{ from: 1000, to: 1100, by: ["alice"] },
|
|
247
|
-
],
|
|
248
|
-
},
|
|
249
|
-
target: { type: "snapshot", id: "1200-1200" },
|
|
250
|
-
compareTo: () => "1000-1100",
|
|
251
|
-
});
|
|
252
|
-
expect(characters).toEqual([
|
|
253
|
-
{ character: "a", authors: [] },
|
|
254
|
-
{ character: "b", authors: [] },
|
|
255
|
-
{ character: "c", authors: ["bob"] },
|
|
256
|
-
]);
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
it("shows only the selected version's edits when the previous version is the first edit alone", async () => {
|
|
260
|
-
// "1000-1000" is both the first edit and a version of its own; the start of
|
|
261
|
-
// the document is a separate, empty row before it.
|
|
262
|
-
const characters = await compareCharacters({
|
|
263
|
-
authors: ["alice", "bob", "bob"],
|
|
264
|
-
activity: {
|
|
265
|
-
first,
|
|
266
|
-
history: [
|
|
267
|
-
{ from: 1100, to: 1200, by: ["bob"] },
|
|
268
|
-
{ from: 1000, to: 1000, by: ["alice"] },
|
|
269
|
-
],
|
|
270
|
-
},
|
|
271
|
-
target: { type: "snapshot", id: "1100-1200" },
|
|
272
|
-
compareTo: () => "1000-1000",
|
|
273
|
-
});
|
|
274
|
-
expect(characters).toEqual([
|
|
275
|
-
{ character: "a", authors: [] },
|
|
276
|
-
{ character: "b", authors: ["bob"] },
|
|
277
|
-
{ character: "c", authors: ["bob"] },
|
|
278
|
-
]);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it("uses the latest server checkpoint as Current without a separate capture row", () => {
|
|
282
|
-
expect(storage().api.showCurrentVersion).toBe(false);
|
|
283
|
-
expect(fetchSpy).not.toHaveBeenCalled();
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it("pins the start of the document, before the first edit, independently of sidebar filters and grouping", async () => {
|
|
287
|
-
const { api, doc } = storage({ from: 1500, by: "bob", group: true });
|
|
288
|
-
doc.get("default").push(["initial content"]);
|
|
289
|
-
fetchSpy
|
|
290
|
-
.mockResolvedValueOnce(response({ activity: [latest] }))
|
|
291
|
-
.mockResolvedValueOnce(response({ activity: [{ ...first, version }] }))
|
|
292
|
-
.mockResolvedValueOnce(response({ ydoc: Y.encodeStateAsUpdate(doc) }));
|
|
293
|
-
const { snapshots: versions } = resultValue(await api.list(signal));
|
|
294
|
-
expect(versions).toHaveLength(2);
|
|
295
|
-
const start = versions[1];
|
|
296
|
-
// The moment before the first edit: an empty document, without the first
|
|
297
|
-
// edit's name.
|
|
298
|
-
expect(start).toMatchObject({ id: "999-999", createdAt: 999, by: ["alice"] });
|
|
299
|
-
expect(start.name).toBeUndefined();
|
|
300
|
-
const content = resultValue(await api.getContent(start.id, signal));
|
|
301
|
-
const decoded = new Y.Doc();
|
|
302
|
-
try {
|
|
303
|
-
Y.applyUpdateV2(decoded, content);
|
|
304
|
-
expect(Object.fromEntries(request(1).url.searchParams)).toEqual({
|
|
305
|
-
from: "0",
|
|
306
|
-
order: "asc",
|
|
307
|
-
limit: "1",
|
|
308
|
-
group: "false",
|
|
309
|
-
versions: "true",
|
|
310
|
-
customAttributions: "true",
|
|
311
|
-
});
|
|
312
|
-
expect(request(2).url.searchParams.get("to")).toBe("999");
|
|
313
|
-
} finally {
|
|
314
|
-
decoded.destroy();
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it("lists no snapshots when there are no recorded edits", async () => {
|
|
319
|
-
fetchSpy.mockImplementation(async () => response({ activity: [] }));
|
|
320
|
-
expect(await storage().api.list(signal)).toEqual({
|
|
321
|
-
ok: true,
|
|
322
|
-
value: { snapshots: [], nextCursor: undefined },
|
|
323
|
-
});
|
|
324
|
-
expect(fetchSpy).toHaveBeenCalledTimes(2);
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
it("reloads an unnamed YHub checkpoint as Current on each opening without creating a version", async () => {
|
|
328
|
-
const { api, doc } = storage();
|
|
329
|
-
const show = vi.fn();
|
|
330
|
-
const mode = createVersioning({
|
|
331
|
-
storage: api,
|
|
332
|
-
adapter: {
|
|
333
|
-
supportsComparison: false,
|
|
334
|
-
open() {
|
|
335
|
-
return {
|
|
336
|
-
current: { content: new Uint8Array(), capturedAt: 3000 },
|
|
337
|
-
show,
|
|
338
|
-
close() {},
|
|
339
|
-
};
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
setReadOnly() {},
|
|
343
|
-
});
|
|
344
|
-
for (let opening = 0; opening < 2; opening++) {
|
|
345
|
-
fetchSpy
|
|
346
|
-
.mockResolvedValueOnce(response({ activity: [latest, first] }))
|
|
347
|
-
.mockResolvedValueOnce(response({ activity: [first] }))
|
|
348
|
-
.mockResolvedValueOnce(response({ ydoc: Y.encodeStateAsUpdate(doc) }));
|
|
349
|
-
mode.open();
|
|
350
|
-
expect(await mode.list()).toEqual({ status: "done" });
|
|
351
|
-
expect(mode.store.state).toMatchObject({
|
|
352
|
-
showCurrentVersion: false,
|
|
353
|
-
displayed: { type: "snapshot", id: "2000-2000" },
|
|
354
|
-
history: {
|
|
355
|
-
data: [
|
|
356
|
-
{ id: "2000-2000", name: undefined },
|
|
357
|
-
{ id: "1000-1000" },
|
|
358
|
-
{ id: "999-999" },
|
|
359
|
-
],
|
|
360
|
-
},
|
|
361
|
-
});
|
|
362
|
-
expect(show.mock.lastCall?.[0].target).toEqual({
|
|
363
|
-
type: "snapshot",
|
|
364
|
-
id: "2000-2000",
|
|
365
|
-
});
|
|
366
|
-
mode.close();
|
|
367
|
-
}
|
|
368
|
-
expect(fetchSpy).toHaveBeenCalledTimes(6);
|
|
369
|
-
for (let index = 0; index < 6; index++) {
|
|
370
|
-
expect(request(index).method).toBe("GET");
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
it("lists server checkpoints with their attached versions and empty versions", async () => {
|
|
375
|
-
fetchSpy
|
|
376
|
-
.mockResolvedValueOnce(
|
|
377
|
-
response({
|
|
378
|
-
activity: [
|
|
379
|
-
latest,
|
|
380
|
-
{
|
|
381
|
-
...first,
|
|
382
|
-
by: ["alice", "bob"],
|
|
383
|
-
version,
|
|
384
|
-
customAttributions: [{ k: "source", v: "import" }],
|
|
385
|
-
},
|
|
386
|
-
{
|
|
387
|
-
from: 500,
|
|
388
|
-
to: 500,
|
|
389
|
-
by: [],
|
|
390
|
-
version: { ...version, t: 500, name: "Empty" },
|
|
391
|
-
isEmpty: true,
|
|
392
|
-
},
|
|
393
|
-
],
|
|
394
|
-
}),
|
|
395
|
-
)
|
|
396
|
-
.mockResolvedValueOnce(response({ activity: [] }));
|
|
397
|
-
expect(resultValue(await storage().api.list(signal)).snapshots).toMatchObject(
|
|
398
|
-
[
|
|
399
|
-
{ id: "2000-2000", by: ["bob"] },
|
|
400
|
-
{
|
|
401
|
-
id: "1000-1000",
|
|
402
|
-
by: ["alice", "bob"],
|
|
403
|
-
name: "Milestone",
|
|
404
|
-
metadata: version.custom,
|
|
405
|
-
restoredFrom: { id: "42-42", createdAt: 42 },
|
|
406
|
-
customAttributions: { source: "import" },
|
|
407
|
-
},
|
|
408
|
-
{ id: "500-500", by: [], name: "Empty" },
|
|
409
|
-
],
|
|
410
|
-
);
|
|
411
|
-
expect(fetchSpy).toHaveBeenCalledTimes(2);
|
|
412
|
-
expect(request(0).url.searchParams.get("versions")).toBe("true");
|
|
413
|
-
expect(request(0).signal).toBeInstanceOf(AbortSignal);
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
it.each([false, 0, "", ["app"], {}, null].map((custom) => ({ custom })))(
|
|
417
|
-
"preserves each activity entry and its custom metadata $custom",
|
|
418
|
-
async ({ custom }) => {
|
|
419
|
-
fetchSpy
|
|
420
|
-
.mockResolvedValueOnce(
|
|
421
|
-
response({
|
|
422
|
-
activity: [
|
|
423
|
-
{ ...first, by: "bob", version: { ...version, custom } },
|
|
424
|
-
{
|
|
425
|
-
...first,
|
|
426
|
-
by: "alice",
|
|
427
|
-
customAttributions: [{ k: "source", v: "edit" }],
|
|
428
|
-
},
|
|
429
|
-
],
|
|
430
|
-
}),
|
|
431
|
-
)
|
|
432
|
-
.mockResolvedValueOnce(response({ activity: [first] }));
|
|
433
|
-
const { snapshots: rows } = resultValue(
|
|
434
|
-
await storage({ groupByUser: true }).api.list(signal),
|
|
435
|
-
);
|
|
436
|
-
expect(rows).toHaveLength(3);
|
|
437
|
-
expect(rows[2].id).toBe("999-999");
|
|
438
|
-
expect(rows[0].by).toEqual(["bob"]);
|
|
439
|
-
expect(rows[0].metadata).toEqual(custom);
|
|
440
|
-
expect(rows[1].by).toEqual(["alice"]);
|
|
441
|
-
expect(rows[1].metadata).toBeUndefined();
|
|
442
|
-
expect(rows[1].customAttributions).toEqual({ source: "edit" });
|
|
443
|
-
expect(request(0).url.searchParams.get("groupByUser")).toBe("true");
|
|
444
|
-
},
|
|
445
|
-
);
|
|
446
|
-
|
|
447
|
-
it("preserves caller activity filters without merging returned entries", async () => {
|
|
448
|
-
fetchSpy
|
|
449
|
-
.mockResolvedValueOnce(
|
|
450
|
-
response({
|
|
451
|
-
activity: [
|
|
452
|
-
{ ...first, customAttributions: [{ k: "source", v: "import" }] },
|
|
453
|
-
{
|
|
454
|
-
...first,
|
|
455
|
-
by: ["bob"],
|
|
456
|
-
version,
|
|
457
|
-
customAttributions: [{ k: "tag", v: "release" }],
|
|
458
|
-
},
|
|
459
|
-
],
|
|
460
|
-
}),
|
|
461
|
-
)
|
|
462
|
-
.mockResolvedValueOnce(response({ activity: [first] }));
|
|
463
|
-
const activityParams = {
|
|
464
|
-
groupExclude: "alice,bob",
|
|
465
|
-
order: "desc",
|
|
466
|
-
limit: 10,
|
|
467
|
-
from: 500,
|
|
468
|
-
by: "alice,bob",
|
|
469
|
-
customAttributions: true,
|
|
470
|
-
};
|
|
471
|
-
expect(
|
|
472
|
-
resultValue(await storage(activityParams).api.list(signal)).snapshots,
|
|
473
|
-
).toMatchObject([
|
|
474
|
-
{
|
|
475
|
-
id: "1000-1000",
|
|
476
|
-
by: ["alice"],
|
|
477
|
-
customAttributions: { source: "import" },
|
|
478
|
-
},
|
|
479
|
-
{
|
|
480
|
-
id: "1000-1000",
|
|
481
|
-
by: ["bob"],
|
|
482
|
-
name: "Milestone",
|
|
483
|
-
metadata: version.custom,
|
|
484
|
-
restoredFrom: { id: "42-42", createdAt: 42 },
|
|
485
|
-
customAttributions: { tag: "release" },
|
|
486
|
-
},
|
|
487
|
-
{ id: "999-999", by: ["alice"] },
|
|
488
|
-
]);
|
|
489
|
-
for (const [key, value] of Object.entries(activityParams)) {
|
|
490
|
-
expect(request(0).url.searchParams.get(key)).toBe(
|
|
491
|
-
String(key === "limit" ? Number(value) + 1 : value),
|
|
492
|
-
);
|
|
493
|
-
}
|
|
494
|
-
expect(activityParams).toEqual({
|
|
495
|
-
groupExclude: "alice,bob",
|
|
496
|
-
order: "desc",
|
|
497
|
-
limit: 10,
|
|
498
|
-
from: 500,
|
|
499
|
-
by: "alice,bob",
|
|
500
|
-
customAttributions: true,
|
|
501
|
-
});
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
it("pages through bounded activity windows with stable timestamp identifiers", async () => {
|
|
505
|
-
const activity = [
|
|
506
|
-
{ from: 90, to: 100, by: ["alice"] },
|
|
507
|
-
{ from: 70, to: 80, by: ["bob"], version: { ...version, t: 80 } },
|
|
508
|
-
{ from: 50, to: 60, by: ["alice"] },
|
|
509
|
-
];
|
|
510
|
-
fetchSpy.mockImplementation(async (url) => {
|
|
511
|
-
const params = new URL(url instanceof Request ? url.url : url).searchParams;
|
|
512
|
-
if (params.get("order") === "asc") {
|
|
513
|
-
return response({ activity: [activity.at(-1)] });
|
|
514
|
-
}
|
|
515
|
-
const to = Number(params.get("to") ?? Infinity);
|
|
516
|
-
return response({
|
|
517
|
-
activity: activity
|
|
518
|
-
.filter((entry) => entry.to <= to)
|
|
519
|
-
.slice(0, Number(params.get("limit"))),
|
|
520
|
-
});
|
|
521
|
-
});
|
|
522
|
-
const { api } = storage({ limit: 1 });
|
|
523
|
-
const snapshots = [];
|
|
524
|
-
const cursors = new Set<string>();
|
|
525
|
-
let cursor: string | undefined;
|
|
526
|
-
do {
|
|
527
|
-
const page = resultValue(await api.list(signal, cursor));
|
|
528
|
-
snapshots.push(...page.snapshots);
|
|
529
|
-
cursor = page.nextCursor;
|
|
530
|
-
if (cursor !== undefined) {
|
|
531
|
-
expect(cursors.has(cursor)).toBe(false);
|
|
532
|
-
cursors.add(cursor);
|
|
533
|
-
}
|
|
534
|
-
} while (cursor !== undefined);
|
|
535
|
-
expect(
|
|
536
|
-
snapshots.map(({ id, createdAt, name }) => ({ id, createdAt, name })),
|
|
537
|
-
).toEqual([
|
|
538
|
-
{ id: "90-100", createdAt: 100, name: undefined },
|
|
539
|
-
// The first page also pins the start, the moment before the first edit.
|
|
540
|
-
{ id: "49-49", createdAt: 49, name: undefined },
|
|
541
|
-
{ id: "70-80", createdAt: 80, name: "Milestone" },
|
|
542
|
-
{ id: "50-60", createdAt: 60, name: undefined },
|
|
543
|
-
]);
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
it("keeps grouping fixed while traversing a cursor and uses changed options on refresh", async () => {
|
|
547
|
-
const activityParams = { limit: 1, groupMaxGap: 10, groupByUser: false };
|
|
548
|
-
fetchSpy.mockImplementation(async (url) => {
|
|
549
|
-
const params = new URL(url instanceof Request ? url.url : url).searchParams;
|
|
550
|
-
if (params.get("order") === "asc") {
|
|
551
|
-
return response({ activity: [first] });
|
|
552
|
-
}
|
|
553
|
-
return response({ activity: params.has("to") ? [first] : [latest, first] });
|
|
554
|
-
});
|
|
555
|
-
const { api } = storage(activityParams);
|
|
556
|
-
const page = resultValue(await api.list(signal));
|
|
557
|
-
activityParams.groupMaxGap = 20;
|
|
558
|
-
activityParams.groupByUser = true;
|
|
559
|
-
expect(
|
|
560
|
-
resultValue(await api.list(signal, page.nextCursor)).snapshots[0].id,
|
|
561
|
-
).toBe("1000-1000");
|
|
562
|
-
await api.list(signal);
|
|
563
|
-
expect(request(2).url.searchParams.get("groupMaxGap")).toBe("10");
|
|
564
|
-
expect(request(2).url.searchParams.get("groupByUser")).toBe("false");
|
|
565
|
-
expect(request(3).url.searchParams.get("groupMaxGap")).toBe("20");
|
|
566
|
-
expect(request(3).url.searchParams.get("groupByUser")).toBe("true");
|
|
567
|
-
});
|
|
568
|
-
|
|
569
|
-
it.each([{ activity: [] }, { activity: [latest] }])(
|
|
570
|
-
"reports exhaustion without an unnecessary empty-page request for %j",
|
|
571
|
-
async ({ activity }) => {
|
|
572
|
-
fetchSpy
|
|
573
|
-
.mockResolvedValueOnce(response({ activity }))
|
|
574
|
-
.mockResolvedValueOnce(response({ activity }));
|
|
575
|
-
const page = resultValue(await storage({ limit: 1 }).api.list(signal));
|
|
576
|
-
expect(page.nextCursor).toBeUndefined();
|
|
577
|
-
// With an edit, the start of the document is pinned after it.
|
|
578
|
-
expect(page.snapshots.map((snapshot) => snapshot.id)).toEqual(
|
|
579
|
-
activity.length ? ["2000-2000", "1999-1999"] : [],
|
|
580
|
-
);
|
|
581
|
-
},
|
|
582
|
-
);
|
|
583
|
-
|
|
584
|
-
it.each([0, -1, 1.5, NaN, Infinity, Number.MAX_SAFE_INTEGER + 1])(
|
|
585
|
-
"rejects invalid activity page size %s",
|
|
586
|
-
async (limit) => {
|
|
587
|
-
await expect(storage({ limit }).api.list(signal)).rejects.toThrow(
|
|
588
|
-
"positive integer",
|
|
589
|
-
);
|
|
590
|
-
},
|
|
591
|
-
);
|
|
592
|
-
|
|
593
|
-
it("names the latest checkpoint only when its content matches frozen current", async () => {
|
|
594
|
-
const { api, doc } = storage();
|
|
595
|
-
doc.get("default").push(["shown"]);
|
|
596
|
-
fetchSpy
|
|
597
|
-
.mockResolvedValueOnce(response({ activity: [latest] }))
|
|
598
|
-
.mockResolvedValueOnce(response({ ydoc: Y.encodeStateAsUpdate(doc) }))
|
|
599
|
-
.mockResolvedValueOnce(response({ versions: [] }))
|
|
600
|
-
.mockResolvedValueOnce(
|
|
601
|
-
response({ ...version, t: latest.to, name: "Current milestone" }),
|
|
602
|
-
);
|
|
603
|
-
expect(
|
|
604
|
-
await api.create!(Y.encodeStateAsUpdateV2(doc), "Current milestone"),
|
|
605
|
-
).toMatchObject({
|
|
606
|
-
ok: true,
|
|
607
|
-
value: { id: "2000-2000", createdAt: 2000, name: "Current milestone" },
|
|
608
|
-
});
|
|
609
|
-
expect(request(0).url.searchParams.get("limit")).toBe("1");
|
|
610
|
-
expect(request(3).method).toBe("POST");
|
|
611
|
-
expect(request(3).body).toEqual({
|
|
612
|
-
type: "version:v1",
|
|
613
|
-
t: 2000,
|
|
614
|
-
name: "Current milestone",
|
|
615
|
-
});
|
|
616
|
-
});
|
|
617
|
-
|
|
618
|
-
it("renames an already named latest checkpoint while preserving metadata", async () => {
|
|
619
|
-
const { api, doc } = storage();
|
|
620
|
-
doc.get("default").push(["shown"]);
|
|
621
|
-
const current = { ...version, t: latest.to };
|
|
622
|
-
fetchSpy
|
|
623
|
-
.mockResolvedValueOnce(response({ activity: [latest] }))
|
|
624
|
-
.mockResolvedValueOnce(response({ ydoc: Y.encodeStateAsUpdate(doc) }))
|
|
625
|
-
.mockResolvedValueOnce(response({ versions: [current] }))
|
|
626
|
-
.mockResolvedValueOnce(response({ ...current, name: "Renamed current" }));
|
|
627
|
-
expect(
|
|
628
|
-
await api.create!(Y.encodeStateAsUpdateV2(doc), "Renamed current"),
|
|
629
|
-
).toMatchObject({
|
|
630
|
-
ok: true,
|
|
631
|
-
value: {
|
|
632
|
-
id: "2000-2000",
|
|
633
|
-
name: "Renamed current",
|
|
634
|
-
metadata: version.custom,
|
|
635
|
-
},
|
|
636
|
-
});
|
|
637
|
-
expect(request(3).method).toBe("PATCH");
|
|
638
|
-
expect(request(3).body.custom).toEqual(version.custom);
|
|
639
|
-
});
|
|
640
|
-
|
|
641
|
-
it("does not name a checkpoint when no edits have been recorded", async () => {
|
|
642
|
-
fetchSpy.mockResolvedValueOnce(response({ activity: [] }));
|
|
643
|
-
expect(
|
|
644
|
-
await storage().api.create?.(new Uint8Array(), "Current milestone"),
|
|
645
|
-
).toEqual({ ok: false, error: { type: "conflict" } });
|
|
646
|
-
expect(fetchSpy).toHaveBeenCalledOnce();
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
it("names a recorded checkpoint through POST", async () => {
|
|
650
|
-
fetchSpy.mockResolvedValueOnce(response({ versions: [] }));
|
|
651
|
-
fetchSpy.mockResolvedValueOnce(response({ ...version, name: "Saved" }));
|
|
652
|
-
await storage().api.rename!("900-1000", "Saved");
|
|
653
|
-
expect(request(1)).toMatchObject({
|
|
654
|
-
method: "POST",
|
|
655
|
-
body: { type: "version:v1", t: 1000, name: "Saved" },
|
|
656
|
-
});
|
|
657
|
-
});
|
|
658
|
-
|
|
659
|
-
it("renames through conditional PATCH without losing custom data", async () => {
|
|
660
|
-
fetchSpy.mockResolvedValueOnce(response({ versions: [version] }));
|
|
661
|
-
fetchSpy.mockResolvedValueOnce(response({ ...version, name: "New" }));
|
|
662
|
-
await storage().api.rename!("900-1000", "New");
|
|
663
|
-
expect(request(1)).toMatchObject({
|
|
664
|
-
method: "PATCH",
|
|
665
|
-
body: {
|
|
666
|
-
updatedAt: 3000,
|
|
667
|
-
name: "New",
|
|
668
|
-
custom: version.custom,
|
|
669
|
-
},
|
|
670
|
-
});
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
it("removes a name without removing app metadata", async () => {
|
|
674
|
-
fetchSpy.mockResolvedValueOnce(response({ versions: [version] }));
|
|
675
|
-
fetchSpy.mockResolvedValueOnce(response({ ...version, name: "" }));
|
|
676
|
-
await storage().api.remove!("900-1000");
|
|
677
|
-
expect(request(1).body).toMatchObject({ name: "", custom: version.custom });
|
|
678
|
-
});
|
|
679
|
-
|
|
680
|
-
it("conditionally deletes a version without custom metadata", async () => {
|
|
681
|
-
fetchSpy.mockResolvedValueOnce(
|
|
682
|
-
response({ versions: [{ ...version, custom: null }] }),
|
|
683
|
-
);
|
|
684
|
-
fetchSpy.mockResolvedValueOnce(response(null, 204));
|
|
685
|
-
await storage().api.remove!("900-1000");
|
|
686
|
-
expect(request(1).method).toBe("DELETE");
|
|
687
|
-
expect(request(1).url.searchParams.get("updatedAt")).toBe("3000");
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
it("leaves unnamed automatic activity alone", async () => {
|
|
691
|
-
fetchSpy.mockResolvedValueOnce(response({ versions: [] }));
|
|
692
|
-
await storage().api.remove!("900-1000");
|
|
693
|
-
expect(fetchSpy).toHaveBeenCalledOnce();
|
|
694
|
-
});
|
|
695
|
-
|
|
696
|
-
it("propagates concurrent version conflicts", async () => {
|
|
697
|
-
fetchSpy.mockResolvedValueOnce(response({ versions: [version] }));
|
|
698
|
-
fetchSpy.mockResolvedValueOnce(response({ error: "conflict" }, 409));
|
|
699
|
-
expect(await storage().api.rename!("900-1000", "New")).toEqual({
|
|
700
|
-
ok: false,
|
|
701
|
-
error: { type: "conflict" },
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
|
|
705
|
-
it("loads V2 content at the end of its window", async () => {
|
|
706
|
-
const { api, doc } = storage();
|
|
707
|
-
doc.get("default").push(["hello"]);
|
|
708
|
-
fetchSpy.mockResolvedValueOnce(
|
|
709
|
-
response({ ydoc: Y.encodeStateAsUpdate(doc) }),
|
|
710
|
-
);
|
|
711
|
-
const content = resultValue(await api.getContent("900-1000", signal));
|
|
712
|
-
const restored = new Y.Doc();
|
|
713
|
-
try {
|
|
714
|
-
Y.applyUpdateV2(restored, content);
|
|
715
|
-
expect(restored.get("default").toArray()).toEqual(["hello"]);
|
|
716
|
-
} finally {
|
|
717
|
-
restored.destroy();
|
|
718
|
-
}
|
|
719
|
-
expect(request(0).url.searchParams.get("to")).toBe("1000");
|
|
720
|
-
expect(request(0).signal).toBeInstanceOf(AbortSignal);
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
it.each([
|
|
724
|
-
{ type: "current", capturedAt: 500 },
|
|
725
|
-
{ type: "current", capturedAt: 2500 },
|
|
726
|
-
{ type: "snapshot", capturedAt: 2500 },
|
|
727
|
-
] as const)(
|
|
728
|
-
"uses the server attribution cutoff for $type with client capture time $capturedAt",
|
|
729
|
-
async ({ type, capturedAt }) => {
|
|
730
|
-
fetchSpy.mockResolvedValueOnce(
|
|
731
|
-
response({ attributions: Y.encodeContentMap(Y.createContentMap()) }),
|
|
732
|
-
);
|
|
733
|
-
await storage().api.getAttributions!(
|
|
734
|
-
type === "current" ? { type } : { type, id: "1900-2000" },
|
|
735
|
-
"900-1000",
|
|
736
|
-
capturedAt,
|
|
737
|
-
signal,
|
|
738
|
-
);
|
|
739
|
-
// The baseline already holds its edits up to 1000.
|
|
740
|
-
expect(request(0).url.searchParams.get("from")).toBe("1001");
|
|
741
|
-
expect(request(0).url.searchParams.get("to")).toBe(
|
|
742
|
-
type === "current" ? null : "2000",
|
|
743
|
-
);
|
|
744
|
-
expect(request(0).signal).toBeInstanceOf(AbortSignal);
|
|
745
|
-
},
|
|
746
|
-
);
|
|
747
|
-
|
|
748
|
-
it.each([false, true])(
|
|
749
|
-
"preserves the live head before restore, existing named checkpoint: %s",
|
|
750
|
-
async (named) => {
|
|
751
|
-
const { api, doc, fragment } = storage();
|
|
752
|
-
fragment.push(["hello"]);
|
|
753
|
-
fetchSpy.mockImplementation(async (input, init) => {
|
|
754
|
-
const path = new URL(input instanceof Request ? input.url : input)
|
|
755
|
-
.pathname;
|
|
756
|
-
if (path.includes("/activity/")) {
|
|
757
|
-
return response({ activity: [latest] });
|
|
758
|
-
}
|
|
759
|
-
if (path.includes("/ydoc/")) {
|
|
760
|
-
return response({ doc: Y.encodeStateAsUpdate(doc) });
|
|
761
|
-
}
|
|
762
|
-
if (path.includes("/version/") && init?.method !== "POST") {
|
|
763
|
-
return response({ versions: named ? [{ ...version, t: 2000 }] : [] });
|
|
764
|
-
}
|
|
765
|
-
if (path.includes("/version/")) {
|
|
766
|
-
return response({ ...version, t: 2000 });
|
|
767
|
-
}
|
|
768
|
-
return response({ success: true });
|
|
769
|
-
});
|
|
770
|
-
await api.restore!("900-1000");
|
|
771
|
-
const calls = fetchSpy.mock.calls.map((_, index) => request(index));
|
|
772
|
-
const pins = calls.filter(
|
|
773
|
-
(call) =>
|
|
774
|
-
call.method === "POST" && call.url.pathname.includes("/version/"),
|
|
775
|
-
);
|
|
776
|
-
expect(pins).toHaveLength(named ? 0 : 1);
|
|
777
|
-
if (!named) {
|
|
778
|
-
expect(pins[0].body).toMatchObject({ t: 2000, name: "Before restore" });
|
|
779
|
-
}
|
|
780
|
-
const rollback = calls.find((call) =>
|
|
781
|
-
call.url.pathname.includes("/rollback/"),
|
|
782
|
-
);
|
|
783
|
-
expect(rollback?.body.from).toBe(1001);
|
|
784
|
-
expect(Y.decodeContentIds(rollback?.body.contentIds).inserts).toBeDefined();
|
|
785
|
-
},
|
|
786
|
-
);
|
|
787
|
-
|
|
788
|
-
it.each(["alice", "bob"])(
|
|
789
|
-
"authenticates every restore request as %s without using the rollback author filter",
|
|
790
|
-
async (userid) => {
|
|
791
|
-
const doc = new Y.Doc();
|
|
792
|
-
cleanup.push(() => doc.destroy());
|
|
793
|
-
const fragment = doc.get("default");
|
|
794
|
-
fragment.push(["hello"]);
|
|
795
|
-
const api = createYHubVersionStorage({
|
|
796
|
-
...options,
|
|
797
|
-
queryParams: { userid },
|
|
798
|
-
fragment,
|
|
799
|
-
beforeRestoreName: "Before restore",
|
|
800
|
-
});
|
|
801
|
-
fetchSpy.mockImplementation(async (input, init) => {
|
|
802
|
-
const path = new URL(input instanceof Request ? input.url : input)
|
|
803
|
-
.pathname;
|
|
804
|
-
if (path.includes("/activity/")) {
|
|
805
|
-
return response({ activity: [latest] });
|
|
806
|
-
}
|
|
807
|
-
if (path.includes("/ydoc/")) {
|
|
808
|
-
return response({ doc: Y.encodeStateAsUpdate(doc) });
|
|
809
|
-
}
|
|
810
|
-
if (path.includes("/version/")) {
|
|
811
|
-
return init?.method === "POST"
|
|
812
|
-
? response({ ...version, t: latest.to })
|
|
813
|
-
: response({ versions: [] });
|
|
814
|
-
}
|
|
815
|
-
return response({ success: true });
|
|
816
|
-
});
|
|
817
|
-
expect(await api.restore("900-1000")).toEqual({
|
|
818
|
-
ok: true,
|
|
819
|
-
value: undefined,
|
|
820
|
-
});
|
|
821
|
-
const calls = fetchSpy.mock.calls.map((_, index) => request(index));
|
|
822
|
-
expect(calls).toHaveLength(6);
|
|
823
|
-
for (const call of calls) {
|
|
824
|
-
expect(call.url.searchParams.get("userid")).toBe(userid);
|
|
825
|
-
}
|
|
826
|
-
const rollback = calls.find((call) =>
|
|
827
|
-
call.url.pathname.includes("/rollback/"),
|
|
828
|
-
);
|
|
829
|
-
expect(Object.keys(rollback?.body).sort()).toEqual(["contentIds", "from"]);
|
|
830
|
-
expect(calls[0].url.searchParams.get("limit")).toBe("1");
|
|
831
|
-
expect(calls[1].url.searchParams.get("gc")).toBe("false");
|
|
832
|
-
},
|
|
833
|
-
);
|
|
834
|
-
|
|
835
|
-
it.each([false, 0, "", [], {}, null].map((custom) => ({ custom })))(
|
|
836
|
-
"the transport can still save app metadata $custom directly",
|
|
837
|
-
async ({ custom }) => {
|
|
838
|
-
fetchSpy.mockResolvedValueOnce(response({ ...version, custom }));
|
|
839
|
-
await new YHubClient(options).createVersion(1000, "Milestone", custom);
|
|
840
|
-
expect(request(0).body.custom).toEqual(custom);
|
|
841
|
-
},
|
|
842
|
-
);
|
|
843
|
-
|
|
844
|
-
it("refuses to name newer server content that was not shown in frozen current", async () => {
|
|
845
|
-
const { api, doc, fragment } = storage();
|
|
846
|
-
fragment.push(["shown"]);
|
|
847
|
-
const frozen = Y.encodeStateAsUpdateV2(doc);
|
|
848
|
-
fragment.push(["unseen"]);
|
|
849
|
-
fetchSpy
|
|
850
|
-
.mockResolvedValueOnce(response({ activity: [latest] }))
|
|
851
|
-
.mockResolvedValueOnce(response({ ydoc: Y.encodeStateAsUpdate(doc) }));
|
|
852
|
-
expect(await api.create!(frozen, "Milestone")).toEqual({
|
|
853
|
-
ok: false,
|
|
854
|
-
error: { type: "conflict" },
|
|
855
|
-
});
|
|
856
|
-
expect(fetchSpy).toHaveBeenCalledTimes(2);
|
|
857
|
-
expect(fetchSpy.mock.calls.every(([, init]) => !init?.method)).toBe(true);
|
|
858
|
-
});
|
|
859
|
-
|
|
860
|
-
it("waits for the post-rollback document and applies it to the original live document", async () => {
|
|
861
|
-
const { api, doc, fragment } = storage();
|
|
862
|
-
fragment.push(["before"]);
|
|
863
|
-
const server = new Y.Doc();
|
|
864
|
-
Y.applyUpdate(server, Y.encodeStateAsUpdate(doc));
|
|
865
|
-
server.get("default").delete(0, 1);
|
|
866
|
-
server.get("default").push(["restored"]);
|
|
867
|
-
let finish!: (response: Response) => void;
|
|
868
|
-
const postRollback = new Promise<Response>((resolve) => {
|
|
869
|
-
finish = resolve;
|
|
870
|
-
});
|
|
871
|
-
fetchSpy
|
|
872
|
-
.mockResolvedValueOnce(response({ activity: [latest] }))
|
|
873
|
-
.mockResolvedValueOnce(response({ doc: Y.encodeStateAsUpdate(doc) }))
|
|
874
|
-
.mockResolvedValueOnce(response({ versions: [{ ...version, t: 2000 }] }))
|
|
875
|
-
.mockResolvedValueOnce(response({ success: true }))
|
|
876
|
-
.mockReturnValueOnce(postRollback);
|
|
877
|
-
let completed = false;
|
|
878
|
-
const restore = api.restore!("900-1000").then((result) => {
|
|
879
|
-
completed = true;
|
|
880
|
-
return result;
|
|
881
|
-
});
|
|
882
|
-
await vi.waitFor(() => expect(fetchSpy).toHaveBeenCalledTimes(5));
|
|
883
|
-
expect(completed).toBe(false);
|
|
884
|
-
expect(fragment.toArray()).toEqual(["before"]);
|
|
885
|
-
finish(response({ doc: Y.encodeStateAsUpdate(server) }));
|
|
886
|
-
expect(await restore).toEqual({ ok: true, value: undefined });
|
|
887
|
-
expect(fragment.toArray()).toEqual(["restored"]);
|
|
888
|
-
server.destroy();
|
|
889
|
-
});
|
|
890
|
-
|
|
891
|
-
it.each([
|
|
892
|
-
{ status: 403, error: { type: "forbidden" } },
|
|
893
|
-
{ status: 404, error: { type: "not-found" } },
|
|
894
|
-
{ status: 409, error: { type: "conflict" } },
|
|
895
|
-
{ status: 500, error: { type: "server", status: 500 } },
|
|
896
|
-
])(
|
|
897
|
-
"returns a typed expected error for HTTP $status without exposing its body",
|
|
898
|
-
async ({ status, error }) => {
|
|
899
|
-
fetchSpy.mockResolvedValueOnce(
|
|
900
|
-
response({ error: "private server details" }, status),
|
|
901
|
-
);
|
|
902
|
-
expect(await new YHubClient(options).getActivity()).toEqual({
|
|
903
|
-
ok: false,
|
|
904
|
-
error,
|
|
905
|
-
});
|
|
906
|
-
},
|
|
907
|
-
);
|
|
908
|
-
|
|
909
|
-
it("classifies transport failures but lets unexpected bugs throw", async () => {
|
|
910
|
-
const client = new YHubClient(options);
|
|
911
|
-
fetchSpy.mockRejectedValueOnce(new TypeError("fetch failed"));
|
|
912
|
-
expect(await client.getActivity()).toEqual({
|
|
913
|
-
ok: false,
|
|
914
|
-
error: { type: "network" },
|
|
915
|
-
});
|
|
916
|
-
const bug = new Error("programmer error");
|
|
917
|
-
fetchSpy.mockRejectedValueOnce(bug);
|
|
918
|
-
await expect(client.getActivity()).rejects.toBe(bug);
|
|
919
|
-
fetchSpy.mockResolvedValueOnce(response(null));
|
|
920
|
-
await expect(client.getActivity()).rejects.toThrow();
|
|
921
|
-
});
|
|
922
|
-
|
|
923
|
-
it.each(["read", "mutation"] as const)(
|
|
924
|
-
"bounds a hung $type request and reports whether its outcome is known",
|
|
925
|
-
async (type) => {
|
|
926
|
-
fetchSpy.mockImplementationOnce(
|
|
927
|
-
(_input, init) =>
|
|
928
|
-
new Promise((_, reject) => {
|
|
929
|
-
init?.signal?.addEventListener(
|
|
930
|
-
"abort",
|
|
931
|
-
() => reject(init.signal?.reason),
|
|
932
|
-
{ once: true },
|
|
933
|
-
);
|
|
934
|
-
}),
|
|
935
|
-
);
|
|
936
|
-
const client = new YHubClient({ ...options, timeoutMs: 10 });
|
|
937
|
-
const result = await (type === "read"
|
|
938
|
-
? client.getActivity()
|
|
939
|
-
: client.createVersion(1000, "Named"));
|
|
940
|
-
expect(result).toEqual({
|
|
941
|
-
ok: false,
|
|
942
|
-
error: {
|
|
943
|
-
type: "timeout",
|
|
944
|
-
outcome: type === "read" ? "unchanged" : "unknown",
|
|
945
|
-
},
|
|
946
|
-
});
|
|
947
|
-
expect(fetchSpy).toHaveBeenCalledOnce();
|
|
948
|
-
},
|
|
949
|
-
);
|
|
950
|
-
|
|
951
|
-
it("preserves caller cancellation rather than showing it as a network failure", async () => {
|
|
952
|
-
const abort = new AbortController();
|
|
953
|
-
fetchSpy.mockImplementationOnce(
|
|
954
|
-
(_input, init) =>
|
|
955
|
-
new Promise((_, reject) => {
|
|
956
|
-
init?.signal?.addEventListener(
|
|
957
|
-
"abort",
|
|
958
|
-
() => reject(init.signal?.reason),
|
|
959
|
-
{ once: true },
|
|
960
|
-
);
|
|
961
|
-
}),
|
|
962
|
-
);
|
|
963
|
-
const pending = new YHubClient(options).getActivity(undefined, abort.signal);
|
|
964
|
-
abort.abort();
|
|
965
|
-
await expect(pending).rejects.toBe(abort.signal.reason);
|
|
966
|
-
});
|