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.
Files changed (346) hide show
  1. package/README.md +19 -4
  2. package/dist/block/block.svelte.js +2 -4
  3. package/dist/clipboard/htmlFlow.d.ts +20 -7
  4. package/dist/clipboard/htmlFlow.js +23 -15
  5. package/dist/clipboard/serializeClipboardFragment.d.ts +37 -4
  6. package/dist/clipboard/serializeClipboardFragment.js +6 -4
  7. package/dist/clipboard/textBlocks.d.ts +8 -0
  8. package/dist/clipboard/textBlocks.js +6 -2
  9. package/dist/cloudflare/DocumentRoom.d.ts +13 -9
  10. package/dist/cloudflare/DocumentRoom.js +10 -6
  11. package/dist/cloudflare/room/admission.js +3 -3
  12. package/dist/cloudflare/room/context.d.ts +28 -27
  13. package/dist/cloudflare/room/context.js +2 -2
  14. package/dist/cloudflare/room/purge.d.ts +6 -3
  15. package/dist/cloudflare/room/purge.js +44 -19
  16. package/dist/cloudflare/room/updates.d.ts +3 -4
  17. package/dist/cloudflare/room/updates.js +6 -8
  18. package/dist/cloudflare/routeDocumentSocket.d.ts +17 -0
  19. package/dist/cloudflare/routeDocumentSocket.js +53 -0
  20. package/dist/collaboration/comments/client.d.ts +1 -1
  21. package/dist/collaboration/comments/client.js +1 -1
  22. package/dist/collaboration/remoteSelection.js +3 -3
  23. package/dist/components/Edytor.svelte +2 -10
  24. package/dist/components/Edytor.svelte.d.ts +1 -3
  25. package/dist/crdt/admission.d.ts +5 -10
  26. package/dist/crdt/admission.js +5 -11
  27. package/dist/crdt/attribution/attribution.d.ts +31 -12
  28. package/dist/crdt/attribution/attribution.js +56 -18
  29. package/dist/crdt/attribution/block.d.ts +3 -3
  30. package/dist/crdt/attribution/block.js +7 -8
  31. package/dist/crdt/attribution/index.d.ts +1 -1
  32. package/dist/crdt/attribution/index.js +1 -1
  33. package/dist/crdt/data.d.ts +62 -31
  34. package/dist/crdt/data.js +211 -103
  35. package/dist/crdt/doc/delete.d.ts +1 -1
  36. package/dist/crdt/doc/delete.js +13 -30
  37. package/dist/crdt/doc/funnel.d.ts +7 -6
  38. package/dist/crdt/doc/funnel.js +39 -33
  39. package/dist/crdt/doc/gate.d.ts +3 -20
  40. package/dist/crdt/doc/gate.js +2 -41
  41. package/dist/crdt/doc/history.d.ts +25 -9
  42. package/dist/crdt/doc/history.js +152 -42
  43. package/dist/crdt/doc/layout.js +11 -22
  44. package/dist/crdt/doc/meta.js +12 -17
  45. package/dist/crdt/doc/moves.d.ts +1 -1
  46. package/dist/crdt/doc/moves.js +52 -32
  47. package/dist/crdt/doc/reads.js +2 -2
  48. package/dist/crdt/doc/seed.js +2 -2
  49. package/dist/crdt/doc/split-merge.js +12 -15
  50. package/dist/crdt/doc/steps.d.ts +25 -13
  51. package/dist/crdt/doc/steps.js +52 -122
  52. package/dist/crdt/doc/types.d.ts +21 -9
  53. package/dist/crdt/document.d.ts +21 -19
  54. package/dist/crdt/document.js +26 -23
  55. package/dist/crdt/edytor-doc.d.ts +66 -68
  56. package/dist/crdt/edytor-doc.js +21 -20
  57. package/dist/crdt/engine-api.d.ts +33 -1
  58. package/dist/crdt/engine.d.ts +0 -1
  59. package/dist/crdt/engine.js +1 -4
  60. package/dist/crdt/flow.d.ts +1 -1
  61. package/dist/crdt/flow.js +25 -27
  62. package/dist/crdt/index.d.ts +29 -28
  63. package/dist/crdt/index.js +3 -3
  64. package/dist/crdt/placement/display.d.ts +5 -30
  65. package/dist/crdt/placement/display.js +39 -144
  66. package/dist/crdt/placement/keys.d.ts +58 -0
  67. package/dist/crdt/placement/keys.js +90 -0
  68. package/dist/crdt/placement/model.d.ts +119 -118
  69. package/dist/crdt/placement/model.js +242 -142
  70. package/dist/crdt/placement/resolve.d.ts +123 -35
  71. package/dist/crdt/placement/resolve.js +187 -153
  72. package/dist/crdt/placement/slots.d.ts +134 -0
  73. package/dist/crdt/placement/slots.js +152 -0
  74. package/dist/crdt/protocol.d.ts +2 -2
  75. package/dist/crdt/protocol.js +2 -2
  76. package/dist/crdt/providers/index.d.ts +1 -1
  77. package/dist/crdt/providers/room.d.ts +26 -11
  78. package/dist/crdt/providers/room.js +77 -27
  79. package/dist/crdt/providers/websocket.d.ts +1 -1
  80. package/dist/crdt/providers/websocket.js +33 -32
  81. package/dist/crdt/purge.d.ts +17 -8
  82. package/dist/crdt/purge.js +236 -126
  83. package/dist/crdt/restore.d.ts +2 -2
  84. package/dist/crdt/restore.js +18 -34
  85. package/dist/crdt/schema.d.ts +22 -21
  86. package/dist/crdt/schema.js +29 -23
  87. package/dist/crdt/semantics.js +3 -1
  88. package/dist/crdt/storage.d.ts +1 -1
  89. package/dist/crdt/storage.js +1 -1
  90. package/dist/crdt/structs.d.ts +15 -15
  91. package/dist/crdt/structs.js +8 -22
  92. package/dist/crdt/text/index/cache.js +4 -0
  93. package/dist/crdt/text/index/claims.js +12 -0
  94. package/dist/crdt/text/index/fold.d.ts +2 -3
  95. package/dist/crdt/text/index/fold.js +194 -44
  96. package/dist/crdt/text/index/layout.js +5 -8
  97. package/dist/crdt/text/index/placement.d.ts +26 -18
  98. package/dist/crdt/text/index/placement.js +404 -138
  99. package/dist/crdt/text/index/records.d.ts +3 -3
  100. package/dist/crdt/text/index/records.js +24 -31
  101. package/dist/crdt/text/index/shared.d.ts +11 -3
  102. package/dist/crdt/text/index/shared.js +12 -3
  103. package/dist/crdt/text/index/state.d.ts +21 -17
  104. package/dist/crdt/text/index/state.js +15 -17
  105. package/dist/crdt/text/index/streams.d.ts +10 -5
  106. package/dist/crdt/text/index/streams.js +78 -27
  107. package/dist/crdt/text/items.d.ts +10 -3
  108. package/dist/crdt/text/items.js +7 -0
  109. package/dist/crdt/text/model.d.ts +77 -62
  110. package/dist/crdt/text/model.js +84 -169
  111. package/dist/crdt/text/ranges.d.ts +1 -1
  112. package/dist/crdt/text/ranges.js +3 -3
  113. package/dist/crdt/text/rows.d.ts +13 -7
  114. package/dist/crdt/text/rows.js +24 -7
  115. package/dist/crdt/text/runs.d.ts +17 -12
  116. package/dist/crdt/text/runs.js +24 -7
  117. package/dist/crdt/text/streams.d.ts +26 -13
  118. package/dist/crdt/text/streams.js +41 -14
  119. package/dist/crdt/vendor/yjs/UPSTREAM.md +568 -21
  120. package/dist/crdt/vendor/yjs/dts/global.d.ts +2 -0
  121. package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
  122. package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +7 -0
  123. package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +194 -10
  124. package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +6 -3
  125. package/dist/crdt/vendor/yjs/dts/utils/StructStore.d.ts +5 -18
  126. package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +15 -1
  127. package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +14 -6
  128. package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +33 -6
  129. package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +1 -65
  130. package/dist/crdt/vendor/yjs/dts/utils/marks.d.ts +6 -1
  131. package/dist/crdt/vendor/yjs/dts/ynode.d.ts +43 -7
  132. package/dist/crdt/vendor/yjs/global.d.ts +2 -0
  133. package/dist/crdt/vendor/yjs/src/index.js +1 -1
  134. package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +10 -0
  135. package/dist/crdt/vendor/yjs/src/structs/Item.js +610 -51
  136. package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +18 -9
  137. package/dist/crdt/vendor/yjs/src/utils/Doc.js +5 -3
  138. package/dist/crdt/vendor/yjs/src/utils/StructStore.js +5 -0
  139. package/dist/crdt/vendor/yjs/src/utils/Transaction.js +36 -13
  140. package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +88 -18
  141. package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +119 -32
  142. package/dist/crdt/vendor/yjs/src/utils/encoding.js +13 -1
  143. package/dist/crdt/vendor/yjs/src/utils/ids.js +7 -7
  144. package/dist/crdt/vendor/yjs/src/utils/marks.js +193 -8
  145. package/dist/crdt/vendor/yjs/src/utils/redo.js +1 -1
  146. package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +1 -1
  147. package/dist/crdt/vendor/yjs/src/utils/updates.js +3 -3
  148. package/dist/crdt/vendor/yjs/src/ynode.js +177 -12
  149. package/dist/dnd/autoScroll.d.ts +15 -7
  150. package/dist/dnd/autoScroll.js +10 -15
  151. package/dist/dnd/dropIndicator.js +2 -5
  152. package/dist/dnd/external.d.ts +6 -0
  153. package/dist/dnd/external.js +17 -0
  154. package/dist/dnd/geometry.d.ts +2 -0
  155. package/dist/dnd/geometry.js +3 -4
  156. package/dist/dnd/placement.d.ts +1 -1
  157. package/dist/dnd/pragmatic.d.ts +3 -1
  158. package/dist/dnd/pragmatic.js +12 -2
  159. package/dist/dnd/vendor/pragmatic/UPSTREAM.md +51 -18
  160. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.d.ts +4 -0
  161. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js +6 -0
  162. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.d.ts +0 -2
  163. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.js +4 -22
  164. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter-types.d.ts +26 -0
  165. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.d.ts +30 -0
  166. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.js +203 -0
  167. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-items.js +13 -0
  168. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-types.js +9 -0
  169. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/is-an-available-type.js +19 -0
  170. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.d.ts +4 -0
  171. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.js +6 -0
  172. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/make-honey-pot-fix.js +4 -16
  173. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types.d.ts +1 -8
  174. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-drop-target.js +5 -6
  175. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-monitor.js +2 -3
  176. 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
  177. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.js +6 -24
  178. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.d.ts +2 -0
  179. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js +5 -0
  180. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.d.ts +3 -0
  181. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js +12 -0
  182. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/native-types.d.ts +12 -0
  183. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window-in-safari.js +10 -0
  184. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window.js +55 -0
  185. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.d.ts +4 -0
  186. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.js +8 -0
  187. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/internal-types.d.ts +0 -4
  188. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/get-scroll-by.js +16 -72
  189. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/try-scroll.js +1 -9
  190. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/configuration.js +4 -29
  191. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-scroll-change.js +2 -3
  192. package/dist/edytor.svelte.d.ts +2 -5
  193. package/dist/edytor.svelte.js +21 -32
  194. package/dist/events/beforeInputCommands.js +2 -2
  195. package/dist/events/onBeforeInput.js +1 -1
  196. package/dist/events/onDrop.d.ts +0 -6
  197. package/dist/events/onDrop.js +10 -23
  198. package/dist/events/onInput.d.ts +0 -12
  199. package/dist/events/onInput.js +1 -67
  200. package/dist/events/onPageHide.d.ts +3 -0
  201. package/dist/events/onPageHide.js +16 -0
  202. package/dist/export/forms.d.ts +627 -0
  203. package/dist/export/forms.js +749 -0
  204. package/dist/export/index.d.ts +170 -0
  205. package/dist/export/index.js +161 -0
  206. package/dist/export/markdown.d.ts +41 -0
  207. package/dist/export/markdown.js +585 -0
  208. package/dist/export/markdownWriter.d.ts +9 -0
  209. package/dist/export/markdownWriter.js +133 -0
  210. package/dist/export/mdx.d.ts +15 -0
  211. package/dist/export/mdx.js +33 -0
  212. package/dist/index.d.ts +3 -3
  213. package/dist/index.js +1 -1
  214. package/dist/kinds.js +1 -1
  215. package/dist/plugins/anchored.svelte.d.ts +21 -25
  216. package/dist/plugins/anchored.svelte.js +23 -39
  217. package/dist/plugins/blockHandles/BlockHandleController.svelte.js +24 -32
  218. package/dist/plugins/blockHandles/dragPreview.d.ts +26 -7
  219. package/dist/plugins/blockHandles/dragPreview.js +33 -0
  220. package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +5 -0
  221. package/dist/plugins/blockMenu/BlockMenuController.svelte.js +7 -2
  222. package/dist/plugins/blockMenu/blockMenuPlugin.js +5 -50
  223. package/dist/plugins/chrome.d.ts +27 -5
  224. package/dist/plugins/chrome.js +24 -9
  225. package/dist/plugins/code/CodePlugin.svelte +12 -9
  226. package/dist/plugins/code/header.svelte.js +7 -11
  227. package/dist/plugins/code/languageMenu.svelte.d.ts +5 -2
  228. package/dist/plugins/code/languageMenu.svelte.js +13 -20
  229. package/dist/plugins/columns/ColumnsPlugin.svelte +7 -20
  230. package/dist/plugins/columns/resize.svelte.d.ts +2 -3
  231. package/dist/plugins/columns/resize.svelte.js +2 -5
  232. package/dist/plugins/comments/CommentsController.svelte.d.ts +6 -0
  233. package/dist/plugins/comments/CommentsController.svelte.js +20 -0
  234. package/dist/plugins/equation/EquationPlugin.svelte +12 -22
  235. package/dist/plugins/equation/equation.svelte.d.ts +7 -15
  236. package/dist/plugins/equation/equation.svelte.js +13 -50
  237. package/dist/plugins/equation/tex.d.ts +17 -0
  238. package/dist/plugins/equation/tex.js +42 -0
  239. package/dist/plugins/fileDrop.d.ts +38 -23
  240. package/dist/plugins/fileDrop.js +82 -76
  241. package/dist/plugins/find/FindController.svelte.d.ts +5 -0
  242. package/dist/plugins/find/FindController.svelte.js +14 -14
  243. package/dist/plugins/find/findPlugin.js +1 -15
  244. package/dist/plugins/image/ImageChrome.svelte +8 -2
  245. package/dist/plugins/image/ImagePlugin.svelte +15 -52
  246. package/dist/plugins/image/controls.svelte.js +16 -2
  247. package/dist/plugins/image/toolbar.svelte.d.ts +5 -4
  248. package/dist/plugins/image/toolbar.svelte.js +21 -31
  249. package/dist/plugins/index.d.ts +1 -1
  250. package/dist/plugins/list.svelte.d.ts +9 -0
  251. package/dist/plugins/list.svelte.js +18 -0
  252. package/dist/plugins/marquee/marqueePlugin.js +0 -4
  253. package/dist/plugins/media/AudioPlugin.svelte +1 -1
  254. package/dist/plugins/media/BookmarkPlugin.svelte +6 -97
  255. package/dist/plugins/media/EmbedPlugin.svelte +5 -90
  256. package/dist/plugins/media/EmptySlot.svelte +36 -20
  257. package/dist/plugins/media/EmptySlot.svelte.d.ts +6 -15
  258. package/dist/plugins/media/FilePlugin.svelte +1 -19
  259. package/dist/plugins/media/MediaEmpty.svelte +2 -55
  260. package/dist/plugins/media/MediaEmpty.svelte.d.ts +18 -14
  261. package/dist/plugins/media/SourceBlock.svelte +142 -52
  262. package/dist/plugins/media/SourceBlock.svelte.d.ts +10 -4
  263. package/dist/plugins/media/VideoPlugin.svelte +1 -1
  264. package/dist/plugins/media/empty.svelte.js +2 -7
  265. package/dist/plugins/media/media.d.ts +2 -63
  266. package/dist/plugins/media/media.js +1 -194
  267. package/dist/plugins/media/sources.d.ts +60 -0
  268. package/dist/plugins/media/sources.js +165 -0
  269. package/dist/plugins/media/urlPaste.svelte.d.ts +2 -1
  270. package/dist/plugins/media/urlPaste.svelte.js +12 -21
  271. package/dist/plugins/mention/MentionPlugin.svelte +8 -35
  272. package/dist/plugins/page/PagePlugin.svelte +2 -9
  273. package/dist/plugins/page/page.js +1 -1
  274. package/dist/plugins/pageLink/PageLinkPlugin.svelte +6 -13
  275. package/dist/plugins/richtext/RichTextPlugin.svelte +85 -197
  276. package/dist/plugins/richtext/body.js +1 -1
  277. package/dist/plugins/richtext/calloutIcons.svelte.d.ts +2 -2
  278. package/dist/plugins/richtext/calloutIcons.svelte.js +5 -7
  279. package/dist/plugins/richtext/richTextOperations.d.ts +1 -19
  280. package/dist/plugins/richtext/richTextOperations.js +3 -49
  281. package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +2 -0
  282. package/dist/plugins/slashMenu/SlashMenuController.svelte.js +7 -0
  283. package/dist/plugins/slashMenu/slashMenuPlugin.js +5 -14
  284. package/dist/plugins/table/TableChrome.svelte +2 -3
  285. package/dist/plugins/table/TablePlugin.svelte +20 -54
  286. package/dist/plugins/table/chrome.svelte.d.ts +5 -2
  287. package/dist/plugins/table/chrome.svelte.js +30 -54
  288. package/dist/plugins/table/table.js +3 -3
  289. package/dist/plugins/toc/TocPlugin.svelte +2 -4
  290. package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +7 -0
  291. package/dist/plugins/toolbar/ToolbarController.svelte.js +20 -13
  292. package/dist/plugins/toolbar/toolbarPlugin.js +19 -53
  293. package/dist/plugins/triggers/TriggerController.svelte.d.ts +7 -2
  294. package/dist/plugins/triggers/TriggerController.svelte.js +11 -4
  295. package/dist/plugins/triggers/place.js +1 -2
  296. package/dist/plugins/triggers/triggers.d.ts +6 -1
  297. package/dist/plugins/triggers/triggers.js +12 -13
  298. package/dist/plugins/uploads.svelte.d.ts +5 -2
  299. package/dist/plugins/uploads.svelte.js +25 -15
  300. package/dist/plugins.d.ts +26 -0
  301. package/dist/plugins.js +0 -24
  302. package/dist/selection/replaceSelection.js +2 -2
  303. package/dist/selection/selection.svelte.d.ts +4 -10
  304. package/dist/selection/selection.svelte.js +7 -11
  305. package/dist/session/bindings.js +1 -1
  306. package/dist/session/commands.d.ts +7 -11
  307. package/dist/session/commands.js +13 -19
  308. package/dist/session/inputRules.js +1 -1
  309. package/dist/session/navigation.js +1 -1
  310. package/dist/session/suggestions.svelte.d.ts +0 -11
  311. package/dist/session/suggestions.svelte.js +15 -3
  312. package/dist/session/uploads.d.ts +8 -8
  313. package/dist/surface/lines.js +1 -3
  314. package/dist/surface/observer.svelte.d.ts +17 -1
  315. package/dist/surface/observer.svelte.js +74 -19
  316. package/dist/surface/overlay.d.ts +0 -14
  317. package/dist/surface/overlay.js +0 -25
  318. package/dist/surface/projector.svelte.d.ts +15 -3
  319. package/dist/surface/projector.svelte.js +60 -9
  320. package/dist/text/text.svelte.js +3 -13
  321. package/dist/utils/sanitize.d.ts +38 -0
  322. package/dist/utils/sanitize.js +82 -0
  323. package/dist/utils.d.ts +2 -0
  324. package/dist/utils.js +5 -0
  325. package/package.json +19 -2
  326. package/dist/crdt/placement/rank.d.ts +0 -87
  327. package/dist/crdt/placement/rank.js +0 -332
  328. package/dist/crdt/placement/source.d.ts +0 -43
  329. package/dist/crdt/placement/source.js +0 -66
  330. package/dist/crdt/text/delete-index.d.ts +0 -129
  331. package/dist/crdt/text/delete-index.js +0 -365
  332. package/dist/crdt/text/deletes.d.ts +0 -76
  333. package/dist/crdt/text/deletes.js +0 -362
  334. package/dist/crdt/text/index/anchored.d.ts +0 -17
  335. package/dist/crdt/text/index/anchored.js +0 -197
  336. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/max-z-index.js +0 -3
  337. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/supports-popover.js +0 -16
  338. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-axis-allowed.js +0 -3
  339. package/dist/plugins/code/LanguageMenu.svelte +0 -25
  340. package/dist/plugins/code/LanguageMenu.svelte.d.ts +0 -9
  341. package/dist/plugins/equation/EquationEditor.svelte +0 -27
  342. package/dist/plugins/equation/EquationEditor.svelte.d.ts +0 -9
  343. package/dist/plugins/image/ImageToolbarHost.svelte +0 -37
  344. package/dist/plugins/image/ImageToolbarHost.svelte.d.ts +0 -9
  345. package/dist/plugins/richtext/CalloutIconPicker.svelte +0 -26
  346. package/dist/plugins/richtext/CalloutIconPicker.svelte.d.ts +0 -9
@@ -37,7 +37,7 @@ export const readBlockSet = (decoder) => {
37
37
  clientRefs.clients.set(client, new BlockRange(refs))
38
38
  for (let i = 0; i < numberOfBlocks; i++) {
39
39
  const info = decoder.readInfo()
40
- switch (binary.BITS5 & info) {
40
+ switch (binary.BITS4 & info) { // YP27: content refs fit four bits
41
41
  case 0: { // GC
42
42
  const len = decoder.readLen()
43
43
  refs[i] = new GC(createID(client, clock), len)
@@ -68,9 +68,9 @@ export const readBlockSet = (decoder) => {
68
68
  (info & binary.BIT8) === binary.BIT8 ? decoder.readLeftID() : null, // origin
69
69
  null, // right
70
70
  (info & binary.BIT7) === binary.BIT7 ? decoder.readRightID() : null, // right origin
71
- cantCopyParentInfo ? (decoder.readParentInfo() ? decoder.readString() : decoder.readLeftID()) : null, // parent
72
- cantCopyParentInfo && (info & binary.BIT6) === binary.BIT6 ? decoder.readString() : null, // parentSub
73
- readItemContent(decoder, info) // item content
71
+ cantCopyParentInfo ? ((info & binary.BIT5) === binary.BIT5 ? decoder.readKey() : decoder.readLeftID()) : null, // parent (YP27: bit 5 a root's name, YP24: a key)
72
+ cantCopyParentInfo && (info & binary.BIT6) === binary.BIT6 ? decoder.readKey() : null, // parentSub (YP24: a key)
73
+ readItemContent(decoder, info, createID(client, clock)) // item content (YP25: with its id)
74
74
  )
75
75
  refs[i] = block
76
76
  clock += block.length
@@ -147,19 +147,28 @@ export class BlockSet {
147
147
  for (const client of clientids) {
148
148
  const range = exclude.clients.get(client)
149
149
  const structs = this.clients.get(client)?.refs
150
- if (range == null || structs == null) return
151
- const firstStruct = structs[0]
152
- const lastStruct = structs[structs.length - 1]
150
+ if (range == null || structs == null) continue // YP23: the other clients are excluded too
153
151
  const idranges = range.getIds()
154
152
  for (let i = 0; i < idranges.length; i++) {
155
153
  const range = idranges[i]
156
- let startIndex = 0
154
+ // YP23: read the bounds per range, and the last struct again after
155
+ // the start's split — `findIndexCleanStart` splits a struct in place
156
+ // (the struct shrinks, a new one holds the rest), so bounds read
157
+ // before a split are stale: the next range was skipped (an arriving
158
+ // GC spanning a skip, known ids and the state's end integrated whole
159
+ // over the known middle, and its delete-set entry outran the store),
160
+ // or the end's split was skipped and the range's skip replaced the
161
+ // struct's tail too.
162
+ const firstStruct = structs[0]
163
+ let lastStruct = structs[structs.length - 1]
157
164
  if (range.clock >= lastStruct.id.clock + lastStruct.length) continue
165
+ if (range.clock + range.len <= firstStruct.id.clock) continue
166
+ let startIndex = 0
158
167
  if (range.clock > firstStruct.id.clock) {
159
168
  startIndex = findIndexCleanStart(null, structs, range.clock)
160
169
  }
170
+ lastStruct = structs[structs.length - 1]
161
171
  let endIndex = structs.length // must be set here, after structs is modified
162
- if (range.clock + range.len <= firstStruct.id.clock) continue
163
172
  if (range.clock + range.len < lastStruct.id.clock + lastStruct.length) {
164
173
  endIndex = findIndexCleanStart(null, structs, range.clock + range.len)
165
174
  }
@@ -21,6 +21,7 @@ import { YNode } from '../ynode.js'
21
21
  * @property {function(Uint8Array<ArrayBuffer>, any, Doc, Transaction):void} DocEvents.update
22
22
  * @property {function(Doc):void} DocEvents.beforeAllTransactions
23
23
  * @property {function(Transaction, Doc):void} DocEvents.beforeTransaction
24
+ * @property {function(Transaction, Doc):void} DocEvents.beforeCommit
24
25
  * @property {function(Transaction, Doc):void} DocEvents.commit
25
26
  * @property {function(Transaction, Doc):void} DocEvents.afterTransaction
26
27
  * @property {function(Doc, Array<Transaction>):void} DocEvents.afterAllTransactions
@@ -56,11 +57,12 @@ export class Doc extends ObservableV2 {
56
57
  this.keepReplaced = null
57
58
  this.clientID = generateNewClientId()
58
59
  /**
59
- * YP13: the greatest Lamport timestamp of a paired mark this document
60
- * integrated (see `utils/marks.js`).
60
+ * YP13, YP22: the greatest Lamport timestamp of a paired mark or a move
61
+ * record this document integrated (see `utils/marks.js`,
62
+ * `structs/Item.js` `ContentMove`); the next one it writes takes `_clock + 1`.
61
63
  * @type {number}
62
64
  */
63
- this._markClock = 0
65
+ this._clock = 0
64
66
  /**
65
67
  * @type {Map<string, YNode>}
66
68
  */
@@ -18,6 +18,11 @@ export class StructStore {
18
18
  * @type {null | Uint8Array<ArrayBuffer>}
19
19
  */
20
20
  this.pendingDs = null
21
+ /**
22
+ * YP20: holds whose items have not arrived, `client → [clock, len, delta, …]`.
23
+ * @type {Map<number, Array<number>>|null}
24
+ */
25
+ this.pendingHolds = null
21
26
  this.skips = createIdSet()
22
27
  }
23
28
 
@@ -15,7 +15,8 @@ export const generateNewClientId = random.uint53
15
15
  * minimize the number of messages sent.
16
16
  *
17
17
  * YP19: a commit is told through the document's events (`commit`, then
18
- * `afterTransaction`); nodes have no observers.
18
+ * `afterTransaction`); nodes have no observers. YP30: `beforeCommit` runs
19
+ * before them, inside the transaction.
19
20
  *
20
21
  * @public
21
22
  */
@@ -39,6 +40,19 @@ export class Transaction {
39
40
  * Describes the set of inserted items by ids
40
41
  */
41
42
  this.insertSet = createIdSet()
43
+ /**
44
+ * YP20: the visibility changes hold records made, in order: per item,
45
+ * `client, clock, len` (`len > 0`: shown, `< 0`: hidden; an item removed
46
+ * while held is logged shown, as the delete set counts it hidden).
47
+ * @type {Array<number>}
48
+ */
49
+ this.holds = []
50
+ /**
51
+ * YP22: the units whose mover changed (a move record integrated or
52
+ * deleted, a moved unit removed), in order: per item `client, clock, len`.
53
+ * @type {Array<number>}
54
+ */
55
+ this.moves = []
42
56
  /**
43
57
  * All types that were directly modified (property added or child
44
58
  * inserted/deleted). New types are not included in this Set.
@@ -174,18 +188,27 @@ export const transact = (doc, f, origin = null, local = true) => {
174
188
  result = f(doc._transaction)
175
189
  } finally {
176
190
  if (initialCall) {
177
- const finishCleanup = doc._transaction === transactionCleanups[0]
178
- doc._transaction = null
179
- if (finishCleanup) {
180
- // The first transaction ended, now process observer calls.
181
- // Observer call may create new transactions for which we need to call the observers and do cleanup.
182
- // We don't want to nest these calls, so we execute these calls one after
183
- // another.
184
- // Also we need to ensure that all cleanups are called, even if the
185
- // observes throw errors.
186
- // This file is full of hacky try {} finally {} blocks to ensure that an
187
- // event can throw errors and also that the cleanup is called.
188
- cleanupTransactions(transactionCleanups, 0)
191
+ try {
192
+ // YP30 begin: the outermost function returned (or threw), the
193
+ // transaction still open: a `beforeCommit` listener's writes join it.
194
+ if (doc._observers.has('beforeCommit')) {
195
+ doc.emit('beforeCommit', [doc._transaction, doc])
196
+ }
197
+ // YP30 end
198
+ } finally {
199
+ const finishCleanup = doc._transaction === transactionCleanups[0]
200
+ doc._transaction = null
201
+ if (finishCleanup) {
202
+ // The first transaction ended, now process observer calls.
203
+ // Observer call may create new transactions for which we need to call the observers and do cleanup.
204
+ // We don't want to nest these calls, so we execute these calls one after
205
+ // another.
206
+ // Also we need to ensure that all cleanups are called, even if the
207
+ // observes throw errors.
208
+ // This file is full of hacky try {} finally {} blocks to ensure that an
209
+ // event can throw errors and also that the cleanup is called.
210
+ cleanupTransactions(transactionCleanups, 0)
211
+ }
189
212
  }
190
213
  }
191
214
  }
@@ -1,6 +1,50 @@
1
1
  import * as decoding from 'lib0-v14/decoding'
2
+ import * as error from 'lib0-v14/error' // YP24
2
3
 
3
4
  import { ID } from './ID.js'
5
+ import { UPDATE_ENCODING } from './UpdateEncoder.js' // YP24
6
+
7
+ // YP24 begin (edytor fork: one string table per update — see UPSTREAM.md YP24)
8
+ /**
9
+ * Read a content value written by `writeValue` (lib0's `readAny` layout, its
10
+ * strings and object keys from the update's string table).
11
+ *
12
+ * @param {UpdateDecoder} decoder
13
+ * @return {any}
14
+ */
15
+ const readValue = decoder => {
16
+ const rest = decoder.restDecoder
17
+ switch (rest.arr[rest.pos]) {
18
+ case 115: // YP28: a large integer
19
+ rest.pos++
20
+ return decoding.readVarUint(rest)
21
+ case 114: // YP28: a large integer, through the client table, and a clock
22
+ rest.pos++
23
+ return [decoder.readClient(), decoding.readVarUint(rest)]
24
+ case 119:
25
+ rest.pos++
26
+ return decoder.readKey()
27
+ case 118: {
28
+ rest.pos++
29
+ /** @type {Object<string,any>} */
30
+ const obj = {}
31
+ for (let n = decoding.readVarUint(rest); n > 0; n--) {
32
+ const key = decoder.readKey()
33
+ obj[key] = readValue(decoder)
34
+ }
35
+ return obj
36
+ }
37
+ case 117: {
38
+ rest.pos++
39
+ const arr = []
40
+ for (let n = decoding.readVarUint(rest); n > 0; n--) arr.push(readValue(decoder))
41
+ return arr
42
+ }
43
+ default:
44
+ return decoding.readAny(rest)
45
+ }
46
+ }
47
+ // YP24 end
4
48
 
5
49
  export class IdSetDecoder {
6
50
  /**
@@ -18,6 +62,15 @@ export class IdSetDecoder {
18
62
  this.dsCurrVal = 0
19
63
  }
20
64
 
65
+ /**
66
+ * YP26: the client of a delete set's ranges.
67
+ *
68
+ * @return {number}
69
+ */
70
+ readDsClient () {
71
+ return decoding.readVarUint(this.restDecoder)
72
+ }
73
+
21
74
  /**
22
75
  * @return {number}
23
76
  */
@@ -49,38 +102,60 @@ export class UpdateDecoder extends IdSetDecoder {
49
102
  * @type {Array<string>}
50
103
  */
51
104
  this.keys = []
52
- decoding.readVarUint(decoder) // read feature flag - currently unused
53
- this.keyClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder))
105
+ // YP24: the feature flag names the encoding; another one (upstream's `0`) is refused
106
+ if (decoding.readVarUint(decoder) !== UPDATE_ENCODING) throw error.create('an update of another encoding')
107
+ this.keyClockDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder)) // YP24
54
108
  this.clientDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder))
55
109
  this.leftClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder))
56
110
  this.rightClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder))
57
111
  this.infoDecoder = new decoding.RleDecoder(decoding.readVarUint8Array(decoder), decoding.readUint8)
58
112
  this.stringDecoder = new decoding.StringDecoder(decoding.readVarUint8Array(decoder))
59
- this.parentInfoDecoder = new decoding.RleDecoder(decoding.readVarUint8Array(decoder), decoding.readUint8)
60
113
  this.typeRefDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder))
61
114
  this.lenDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder))
115
+ // YP26 begin: the update's client table, read as its indices are
116
+ /**
117
+ * @type {Array<number>}
118
+ */
119
+ this.clients = []
120
+ // YP26 end
62
121
  }
63
122
 
64
123
  /**
65
124
  * @return {ID}
66
125
  */
67
126
  readLeftID () {
68
- return new ID(this.clientDecoder.read(), this.leftClockDecoder.read())
127
+ return new ID(this.readClient(), this.leftClockDecoder.read())
69
128
  }
70
129
 
71
130
  /**
72
131
  * @return {ID}
73
132
  */
74
133
  readRightID () {
75
- return new ID(this.clientDecoder.read(), this.rightClockDecoder.read())
134
+ return new ID(this.readClient(), this.rightClockDecoder.read())
76
135
  }
77
136
 
78
137
  /**
79
138
  * Read the next client id.
80
139
  * Use this in favor of readID whenever possible to reduce the number of objects created.
140
+ * YP26: an index in the update's client table (a new one's id follows it).
141
+ *
142
+ * @return {number}
81
143
  */
82
144
  readClient () {
83
- return this.clientDecoder.read()
145
+ const index = this.clientDecoder.read()
146
+ const clients = this.clients
147
+ if (index === clients.length) clients.push(this.clientDecoder.read())
148
+ else if (index > clients.length) throw error.create('an unknown client')
149
+ return clients[index]
150
+ }
151
+
152
+ /**
153
+ * YP26: a delete set's client, from the client table.
154
+ *
155
+ * @return {number}
156
+ */
157
+ readDsClient () {
158
+ return this.readClient()
84
159
  }
85
160
 
86
161
  /**
@@ -97,13 +172,6 @@ export class UpdateDecoder extends IdSetDecoder {
97
172
  return this.stringDecoder.read()
98
173
  }
99
174
 
100
- /**
101
- * @return {boolean}
102
- */
103
- readParentInfo () {
104
- return this.parentInfoDecoder.read() === 1
105
- }
106
-
107
175
  /**
108
176
  * @return {number} An unsigned 8-bit integer
109
177
  */
@@ -124,7 +192,7 @@ export class UpdateDecoder extends IdSetDecoder {
124
192
  * @return {any}
125
193
  */
126
194
  readAny () {
127
- return decoding.readAny(this.restDecoder)
195
+ return readValue(this) // YP24
128
196
  }
129
197
 
130
198
  /**
@@ -138,20 +206,22 @@ export class UpdateDecoder extends IdSetDecoder {
138
206
  * @return {any}
139
207
  */
140
208
  readJSON () {
141
- return decoding.readAny(this.restDecoder)
209
+ return readValue(this) // YP24
142
210
  }
143
211
 
144
212
  /**
145
213
  * @return {string}
146
214
  */
147
215
  readKey () {
216
+ // YP24: `0` a new string, else the index of a known one plus one
148
217
  const keyClock = this.keyClockDecoder.read()
149
- if (keyClock < this.keys.length) {
150
- return this.keys[keyClock]
151
- } else {
218
+ if (keyClock === 0) {
152
219
  const key = this.stringDecoder.read()
153
220
  this.keys.push(key)
154
221
  return key
155
222
  }
223
+ if (keyClock > this.keys.length) throw error.create('an unknown key')
224
+ return this.keys[keyClock - 1]
156
225
  }
226
+
157
227
  }
@@ -1,6 +1,63 @@
1
1
  import * as error from 'lib0-v14/error'
2
2
  import * as encoding from 'lib0-v14/encoding'
3
3
 
4
+ // YP24 begin (edytor fork: one string table per update — see UPSTREAM.md YP24)
5
+ /**
6
+ * The update encoding this fork writes and reads, in upstream's reserved
7
+ * feature-flag varuint (upstream writes `0`): `1`, a string table per update.
8
+ */
9
+ export const UPDATE_ENCODING = 1
10
+
11
+ /**
12
+ * YP28: whether `x` is an integer past 31 bits a varint holds exactly.
13
+ *
14
+ * @param {any} x
15
+ * @return {boolean}
16
+ */
17
+ const large = x => Number.isInteger(x) && x > 0x7fffffff && x <= Number.MAX_SAFE_INTEGER
18
+
19
+ /**
20
+ * Write a content value in lib0's `writeAny` layout, its strings and object
21
+ * keys through the update's string table (`writeKey`).
22
+ *
23
+ * @param {UpdateEncoder} encoder
24
+ * @param {any} data
25
+ */
26
+ const writeValue = (encoder, data) => {
27
+ const rest = encoder.restEncoder
28
+ if (typeof data === 'string') {
29
+ encoding.write(rest, 119)
30
+ encoder.writeKey(data)
31
+ } else if (large(data)) {
32
+ // YP28: an integer past lib0's 31 bits (a float64 there) as a varint
33
+ encoding.write(rest, 115)
34
+ encoding.writeVarUint(rest, data)
35
+ } else if (data !== null && typeof data === 'object' && !(data instanceof Uint8Array)) {
36
+ if (Array.isArray(data) && data.length === 2 && large(data[0]) && Number.isInteger(data[1]) && data[1] >= 0) {
37
+ // YP28: a pair of a large integer and a clock (an item id, a block
38
+ // slot's split key) names its first through the client table
39
+ encoding.write(rest, 114)
40
+ encoder.clientIndex(data[0])
41
+ encoding.writeVarUint(rest, data[1])
42
+ } else if (Array.isArray(data)) {
43
+ encoding.write(rest, 117)
44
+ encoding.writeVarUint(rest, data.length)
45
+ for (let i = 0; i < data.length; i++) writeValue(encoder, data[i])
46
+ } else {
47
+ const keys = Object.keys(data)
48
+ encoding.write(rest, 118)
49
+ encoding.writeVarUint(rest, keys.length)
50
+ for (let i = 0; i < keys.length; i++) {
51
+ encoder.writeKey(keys[i])
52
+ writeValue(encoder, data[keys[i]])
53
+ }
54
+ }
55
+ } else {
56
+ encoding.writeAny(rest, data)
57
+ }
58
+ }
59
+ // YP24 end
60
+
4
61
  export class IdSetEncoder {
5
62
  constructor () {
6
63
  this.restEncoder = encoding.createEncoder() // encodes all the rest / non-optimized
@@ -15,6 +72,15 @@ export class IdSetEncoder {
15
72
  this.dsCurrVal = 0
16
73
  }
17
74
 
75
+ /**
76
+ * YP26: the client of a delete set's ranges.
77
+ *
78
+ * @param {number} client
79
+ */
80
+ writeDsClient (client) {
81
+ encoding.writeVarUint(this.restEncoder, client)
82
+ }
83
+
18
84
  /**
19
85
  * @param {number} clock
20
86
  */
@@ -50,27 +116,52 @@ export class UpdateEncoder extends IdSetEncoder {
50
116
  * @type {number}
51
117
  */
52
118
  this.keyClock = 0
53
- this.keyClockEncoder = new encoding.IntDiffOptRleEncoder()
119
+ this.keyClockEncoder = new encoding.UintOptRleEncoder() // YP24: 0 a new string, else its index + 1
54
120
  this.clientEncoder = new encoding.UintOptRleEncoder()
55
121
  this.leftClockEncoder = new encoding.IntDiffOptRleEncoder()
56
122
  this.rightClockEncoder = new encoding.IntDiffOptRleEncoder()
57
123
  this.infoEncoder = new encoding.RleEncoder(encoding.writeUint8)
58
124
  this.stringEncoder = new encoding.StringEncoder()
59
- this.parentInfoEncoder = new encoding.RleEncoder(encoding.writeUint8)
60
125
  this.typeRefEncoder = new encoding.UintOptRleEncoder()
61
126
  this.lenEncoder = new encoding.UintOptRleEncoder()
127
+ // YP26 begin: one client table per update
128
+ /**
129
+ * Each client's index, in first-use order.
130
+ *
131
+ * @type {Map<number,number>}
132
+ */
133
+ this.clientTable = new Map()
134
+ // YP26 end
135
+ }
136
+
137
+ /**
138
+ * YP26: write `client` to the client column as its index in the update's
139
+ * client table, in first-use order: a new client's index (the table's
140
+ * size) is followed by its id, once.
141
+ *
142
+ * @param {number} client
143
+ */
144
+ clientIndex (client) {
145
+ const index = this.clientTable.get(client)
146
+ if (index === undefined) {
147
+ const next = this.clientTable.size
148
+ this.clientTable.set(client, next)
149
+ this.clientEncoder.write(next)
150
+ this.clientEncoder.write(client)
151
+ } else {
152
+ this.clientEncoder.write(index)
153
+ }
62
154
  }
63
155
 
64
156
  toUint8Array () {
65
157
  const encoder = encoding.createEncoder()
66
- encoding.writeVarUint(encoder, 0) // this is a feature flag that we might use in the future
158
+ encoding.writeVarUint(encoder, UPDATE_ENCODING) // YP24: the feature flag names the encoding
67
159
  encoding.writeVarUint8Array(encoder, this.keyClockEncoder.toUint8Array())
68
160
  encoding.writeVarUint8Array(encoder, this.clientEncoder.toUint8Array())
69
161
  encoding.writeVarUint8Array(encoder, this.leftClockEncoder.toUint8Array())
70
162
  encoding.writeVarUint8Array(encoder, this.rightClockEncoder.toUint8Array())
71
163
  encoding.writeVarUint8Array(encoder, encoding.toUint8Array(this.infoEncoder))
72
164
  encoding.writeVarUint8Array(encoder, this.stringEncoder.toUint8Array())
73
- encoding.writeVarUint8Array(encoder, encoding.toUint8Array(this.parentInfoEncoder))
74
165
  encoding.writeVarUint8Array(encoder, this.typeRefEncoder.toUint8Array())
75
166
  encoding.writeVarUint8Array(encoder, this.lenEncoder.toUint8Array())
76
167
  // @note The rest encoder is appended! (note the missing var)
@@ -82,7 +173,7 @@ export class UpdateEncoder extends IdSetEncoder {
82
173
  * @param {ID} id
83
174
  */
84
175
  writeLeftID (id) {
85
- this.clientEncoder.write(id.client)
176
+ this.clientIndex(id.client) // YP26
86
177
  this.leftClockEncoder.write(id.clock)
87
178
  }
88
179
 
@@ -90,7 +181,7 @@ export class UpdateEncoder extends IdSetEncoder {
90
181
  * @param {ID} id
91
182
  */
92
183
  writeRightID (id) {
93
- this.clientEncoder.write(id.client)
184
+ this.clientIndex(id.client) // YP26
94
185
  this.rightClockEncoder.write(id.clock)
95
186
  }
96
187
 
@@ -98,7 +189,16 @@ export class UpdateEncoder extends IdSetEncoder {
98
189
  * @param {number} client
99
190
  */
100
191
  writeClient (client) {
101
- this.clientEncoder.write(client)
192
+ this.clientIndex(client) // YP26
193
+ }
194
+
195
+ /**
196
+ * YP26: a delete set's client goes through the client table too.
197
+ *
198
+ * @param {number} client
199
+ */
200
+ writeDsClient (client) {
201
+ this.writeClient(client)
102
202
  }
103
203
 
104
204
  /**
@@ -115,13 +215,6 @@ export class UpdateEncoder extends IdSetEncoder {
115
215
  this.stringEncoder.write(s)
116
216
  }
117
217
 
118
- /**
119
- * @param {boolean} isYKey
120
- */
121
- writeParentInfo (isYKey) {
122
- this.parentInfoEncoder.write(isYKey ? 1 : 0)
123
- }
124
-
125
218
  /**
126
219
  * @param {number} info An unsigned 8-bit integer
127
220
  */
@@ -142,7 +235,7 @@ export class UpdateEncoder extends IdSetEncoder {
142
235
  * @param {any} any
143
236
  */
144
237
  writeAny (any) {
145
- encoding.writeAny(this.restEncoder, any)
238
+ writeValue(this, any) // YP24
146
239
  }
147
240
 
148
241
  /**
@@ -156,7 +249,7 @@ export class UpdateEncoder extends IdSetEncoder {
156
249
  * @param {any} embed
157
250
  */
158
251
  writeJSON (embed) {
159
- encoding.writeAny(this.restEncoder, embed)
252
+ writeValue(this, embed) // YP24
160
253
  }
161
254
 
162
255
  /**
@@ -165,29 +258,23 @@ export class UpdateEncoder extends IdSetEncoder {
165
258
  *
166
259
  * We cache these keys in a Map and refer to them via a unique number.
167
260
  *
261
+ * YP24: the cache is on (upstream left it off for decoders older than its
262
+ * own), and every map key, root name and string of a content value goes
263
+ * through it: an update writes each distinct string once. The key column
264
+ * says `0` for a new string (the next in the string column) and the index
265
+ * of a known one plus one, so a key repeated block after block is the same
266
+ * small number every time.
267
+ *
168
268
  * @param {string} key
169
269
  */
170
270
  writeKey (key) {
171
271
  const clock = this.keyMap.get(key)
172
272
  if (clock === undefined) {
173
- /**
174
- * @todo uncomment to introduce this feature finally
175
- *
176
- * Background. The ContentFormat object was always encoded using writeKey, but the decoder used to use readString.
177
- * Furthermore, I forgot to set the keyclock. So everything was working fine.
178
- *
179
- * However, this feature here is basically useless as it is not being used (it actually only consumes extra memory).
180
- *
181
- * I don't know yet how to reintroduce this feature..
182
- *
183
- * Older clients won't be able to read updates when we reintroduce this feature. So this should probably be done using a flag.
184
- *
185
- */
186
- // this.keyMap.set(key, this.keyClock)
187
- this.keyClockEncoder.write(this.keyClock++)
273
+ this.keyMap.set(key, this.keyClock++)
274
+ this.keyClockEncoder.write(0)
188
275
  this.stringEncoder.write(key)
189
276
  } else {
190
- this.keyClockEncoder.write(clock)
277
+ this.keyClockEncoder.write(clock + 1)
191
278
  }
192
279
  }
193
280
  }
@@ -29,7 +29,7 @@ import { UpdateEncoder } from './UpdateEncoder.js'
29
29
  import { LazyStructReader, LazyStructWriter, writeStructToLazyStructWriter, finishLazyStructWriting } from './updates.js'
30
30
  import { readBlockSet, writeBlockSet } from './BlockSet.js'
31
31
  import { Skip } from '../structs/Skip.js'
32
- import { Item } from '../structs/Item.js'
32
+ import { Item, applyPending, ContentMove } from '../structs/Item.js' // YP20, YP22: applyPending, ContentMove
33
33
  import { GC } from '../structs/GC.js'
34
34
  import { Doc } from './Doc.js'
35
35
  import { transact } from './Transaction.js'
@@ -287,6 +287,7 @@ export const readUpdate = (decoder, ydoc, transactionOrigin, structDecoder = new
287
287
  // start = performance.now()
288
288
  // console.log('time to merge: ', performance.now() - start) // @todo remove
289
289
  // start = performance.now()
290
+ const arrived = Array.from(ss.clients.keys()) // YP20, YP22: a hold or a move of this update may wait for another of its clients
290
291
  const restStructs = integrateStructs(transaction, store, ss)
291
292
  const pending = store.pendingStructs
292
293
  if (pending) {
@@ -312,6 +313,7 @@ export const readUpdate = (decoder, ydoc, transactionOrigin, structDecoder = new
312
313
  }
313
314
  // console.log('time to integrate: ', performance.now() - start) // @todo remove
314
315
  // start = performance.now()
316
+ if (store.pendingHolds !== null) applyPending(transaction, arrived) // YP20: the holds that waited for what just arrived
315
317
  const dsRest = readAndApplyDeleteSet(structDecoder, transaction, store)
316
318
  if (store.pendingDs) {
317
319
  // @todo we could make a lower-bound state-vector check as we do above
@@ -529,6 +531,16 @@ const getMissing = (struct, transaction, store) => {
529
531
  if (parent && parent.constructor === ID && (parent.clock >= store.getClock(parent.client) || store.skips.hasId(parent))) {
530
532
  return parent.client
531
533
  }
534
+ if (struct.content.constructor === ContentMove) { // YP22: a move record waits for the units it names and stands at
535
+ // (a skip stands for none of them: its sort reads the units' order, `sourceOrder`)
536
+ const { ids, at } = /** @type {ContentMove} */ (struct.content)
537
+ if (at !== null) {
538
+ for (const id of at) if (id.clock >= store.getClock(id.client) || store.skips.hasId(id)) return id.client
539
+ }
540
+ for (let i = 0; i < ids.length; i += 3) {
541
+ if (ids[i + 1] + ids[i + 2] > store.getClock(ids[i]) || store.skips.intersects(ids[i], ids[i + 1], ids[i + 2])) return ids[i]
542
+ }
543
+ }
532
544
  // We have all missing ids, now find the items
533
545
  if (origin) {
534
546
  struct.left = getItemCleanEnd(transaction, store, origin)