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
@@ -1,10 +1,10 @@
1
- import { type BlockId } from '../../placement/model.js';
2
- import type { IndexAnchored } from './anchored.js';
1
+ import type { BlockId } from '../../placement/model.js';
3
2
  import type { IndexClaims } from './claims.js';
4
3
  import type { IndexPlacement } from './placement.js';
5
4
  import type { IndexState } from './state.js';
5
+ import type { IndexStreams } from './streams.js';
6
6
  /** The block records of one doc's index. */
7
- export declare const indexRecords: (ix: IndexState & IndexClaims & IndexAnchored & IndexPlacement) => {
7
+ export declare const indexRecords: (ix: IndexState & IndexClaims & IndexStreams & IndexPlacement) => {
8
8
  kept: (item: unknown) => boolean;
9
9
  updateBlockRec: (id: BlockId) => void;
10
10
  ensureRec: (id: BlockId) => void;
@@ -6,14 +6,12 @@
6
6
  import { readData } from '../../data.js';
7
7
  import { Y } from '../../engine.js';
8
8
  import { baseIdOf, incarnationNode, incarnationsOf, isIncarnationId } from '../../incarnations.js';
9
- import { candidatesOf } from '../../placement/model.js';
10
9
  import { engineOps } from '../../structs.js';
11
- import { CLAIMS, CONTENT, NONCE, hasDeleteMark, hasWithdrawMark, isNodeLike } from '../../schema.js';
12
- import { readClaims } from '../model.js';
13
- import { dropFrom, sameShape, typeAttr } from './shared.js';
10
+ import { CONTENT, NONCE, hasDeleteMark, hasWithdrawMark, isNodeLike } from '../../schema.js';
11
+ import { sameShape, typeAttr } from './shared.js';
14
12
  /** The block records of one doc's index. */
15
13
  export const indexRecords = (ix) => {
16
- const { registry, blocks, shells, attachOf, foreignOf, retargets, reclaim, byArgParent, placementSeeds, stateSeeds, incarnations, noteClaims, effectiveClaims, noteKind, argParent, noteCands } = ix;
14
+ const { registry, blocks, shells, reclaim, rawOrder, placementSeeds, stateSeeds, incarnations, noteClaims, claimsOf, noteKind, homeFor, reslot } = ix;
17
15
  // ── records ──────────────────────────────────────────────────────
18
16
  /** Fork patch YP14's predicate: the registry values the engine keeps. */
19
17
  const kept = engineOps(Y).isKeptReplaced;
@@ -25,10 +23,7 @@ export const indexRecords = (ix) => {
25
23
  return incarnationNode(registry, id, kept) ?? undefined;
26
24
  };
27
25
  const buildRec = (id, node) => {
28
- const list = node.getAttr(CLAIMS);
29
- const claimsNode = isNodeLike(list) ? list : undefined;
30
26
  const content = node.getAttr(CONTENT);
31
- const own = readClaims(claimsNode);
32
27
  const derived = isIncarnationId(id);
33
28
  // A losing incarnation lives and dies with its key's block: hidden by its
34
29
  // own delete mark or while that block is deleted (a withdrawn one included).
@@ -39,10 +34,8 @@ export const indexRecords = (ix) => {
39
34
  ? []
40
35
  : incarnationsOf(registry, id, kept).map((x, i) => ({
41
36
  m: x.id,
42
- stamp: { c: -1, k: -1 - i },
43
- seqIndex: -1
37
+ stamp: { c: -1, k: -1 - i }
44
38
  }));
45
- const listClaims = implicit.length === 0 ? own : [...implicit, ...own];
46
39
  return {
47
40
  id,
48
41
  node,
@@ -51,44 +44,44 @@ export const indexRecords = (ix) => {
51
44
  n: node.getAttr(NONCE),
52
45
  deleted: hasDeleteMark(node) || keyDeleted,
53
46
  content: isNodeLike(content) ? content : undefined,
54
- claimsNode,
55
- listClaims,
56
- // Until the next retarget pass its own claims stay with it (`merge.claim.anchor`).
57
- claims: effectiveClaims(id, listClaims),
58
- cands: candidatesOf(node)
47
+ implicit,
48
+ // Read from its stream once the record is in (`claimsOf`), again after the fold's texts.
49
+ claims: [],
50
+ home: homeFor(id)
59
51
  };
60
52
  };
61
53
  /**
62
54
  * Rebuild (or create, or drop) block `id`'s record, and note what the
63
55
  * maintained facts must re-decide: its owner and the tops of the
64
56
  * blocks it claims, its placement — and, when its entry came or
65
- * went, the placements of the blocks whose candidate names it.
57
+ * went, the placements of the blocks whose display edge it holds.
66
58
  */
67
59
  const updateBlockRec = (id) => {
68
60
  const old = blocks.get(id);
69
61
  const node = nodeAt(id);
70
- // Its list may change: its claims stay its own until the retarget pass.
71
- for (const t of attachOf.get(id) ?? []) {
72
- if (t === id)
73
- continue;
74
- dropFrom(foreignOf, t, id);
75
- reclaim.add(t);
76
- }
77
- attachOf.delete(id);
78
- retargets.add(id);
79
62
  if (!isNodeLike(node))
80
63
  blocks.delete(id);
81
- else
82
- blocks.set(id, buildRec(id, node));
64
+ else {
65
+ const rec = buildRec(id, node);
66
+ blocks.set(id, rec);
67
+ rec.claims = claimsOf(id);
68
+ reclaim.add(id);
69
+ }
83
70
  const rec = blocks.get(id);
71
+ // Another node now stands for `id` (or none): its sequence's slots change owner.
72
+ if (old?.node !== rec?.node) {
73
+ if (old !== undefined)
74
+ reslot(old.node);
75
+ if (rec !== undefined)
76
+ reslot(rec.node);
77
+ }
84
78
  noteShell(id);
85
79
  noteClaims(id, old?.claims ?? [], rec?.claims ?? []);
86
- noteCands(id, argParent(old));
87
80
  placementSeeds.add(id);
88
81
  if ((old === undefined) !== (rec === undefined)) {
89
82
  stateSeeds.add(id);
90
- for (const c of byArgParent.get(id) ?? [])
91
- placementSeeds.add(c);
83
+ for (const c of rawOrder.get(id) ?? [])
84
+ placementSeeds.add(c.id);
92
85
  }
93
86
  if (old?.type !== rec?.type) {
94
87
  noteKind(id);
@@ -9,13 +9,21 @@ import type { SelfChecks } from './state.js';
9
9
  export declare const ENTRY_FACET = "";
10
10
  /** The facet name of a write to a block's `content` attr itself (a streamless block's own text). */
11
11
  export declare const CONTENT_ATTR = "#content";
12
+ /**
13
+ * The facet name of a write to a block's sequence (fork patch YP22): its
14
+ * children's home slots, its data arrays' item slots and its move records.
15
+ */
16
+ export declare const SEQ_FACET = "#seq";
17
+ /** The facet the fold adds when a sequence write changed the block's data (its arrays' items). */
18
+ export declare const DATA_SEQ_FACET = "#data";
12
19
  /**
13
20
  * Facets of a block node that can change derived state: `content` (a
14
21
  * sequence edit of the block's own text), `structure` (claims, delete marks,
15
- * the nonce, the `content` attr, unknown attrs), `at` (placement candidates —
16
- * placements and order only) and `meta` (type/data — metadata only).
22
+ * the nonce, the `content` attr, unknown attrs), `seq` (its sequence: slots
23
+ * and records — placements and order, or its arrays' items) and `meta`
24
+ * (type/data — metadata only).
17
25
  */
18
- export type Facet = 'content' | 'structure' | 'at' | 'meta' | 'ignore';
26
+ export type Facet = 'content' | 'structure' | 'seq' | 'meta' | 'ignore';
19
27
  export declare const facetOf: (attr: string) => Facet;
20
28
  /** A record's `data` as the projection publishes it: a total JSON clone, `undefined` when absent. */
21
29
  export declare const dataOf: (rec: BlockRec) => Record<string, unknown> | undefined;
@@ -4,7 +4,7 @@
4
4
  * and the self-check switch.
5
5
  */
6
6
  import { cloneJsonSafe } from '../../../utils/json.js';
7
- import { AT, CONTENT, DATA, DATA_LEAF_PREFIX, ID, LAST_CHANGED_ATTR, TYPE } from '../../schema.js';
7
+ import { CONTENT, DATA, DATA_LEAF_PREFIX, ID, LAST_CHANGED_ATTR, TYPE } from '../../schema.js';
8
8
  /**
9
9
  * The facet name of a block's registry entry itself (inserted or removed) —
10
10
  * every other facet is named by the block attr it entered through.
@@ -12,11 +12,20 @@ import { AT, CONTENT, DATA, DATA_LEAF_PREFIX, ID, LAST_CHANGED_ATTR, TYPE } from
12
12
  export const ENTRY_FACET = '';
13
13
  /** The facet name of a write to a block's `content` attr itself (a streamless block's own text). */
14
14
  export const CONTENT_ATTR = '#content';
15
+ /**
16
+ * The facet name of a write to a block's sequence (fork patch YP22): its
17
+ * children's home slots, its data arrays' item slots and its move records.
18
+ */
19
+ export const SEQ_FACET = '#seq';
20
+ /** The facet the fold adds when a sequence write changed the block's data (its arrays' items). */
21
+ export const DATA_SEQ_FACET = '#data';
15
22
  export const facetOf = (attr) => {
16
23
  if (attr === CONTENT)
17
24
  return 'content';
18
- if (attr === AT)
19
- return 'at';
25
+ if (attr === SEQ_FACET)
26
+ return 'seq';
27
+ if (attr === DATA_SEQ_FACET)
28
+ return 'ignore';
20
29
  if (attr === ID || attr === TYPE || attr === DATA || attr.startsWith(DATA_LEAF_PREFIX))
21
30
  return 'meta';
22
31
  // The `l` lastChangedBy stamp is attribution bookkeeping only.
@@ -6,7 +6,7 @@
6
6
  * What one part alone keeps stays in that part.
7
7
  */
8
8
  import type { EngineDoc, EngineTransaction } from '../../engine-api.js';
9
- import { type BlockId, type BlockRec, type ChildSlot, type ResolvedPlacement } from '../../placement/model.js';
9
+ import { type BlockId, type BlockRec, type ChildSlot, type Edge, type ResolvedPlacement, type SlotRef } from '../../placement/model.js';
10
10
  import type { IdSetLike } from '../../structs.js';
11
11
  import type { LiveRow, RowItem } from '../rows.js';
12
12
  import type { ContentRun, DisplayRoles, Folded } from '../runs.js';
@@ -47,7 +47,7 @@ export type Slot = {
47
47
  export type Placed = {
48
48
  head: BlockId | null;
49
49
  keys: string[];
50
- blocks: BlockId[];
50
+ blocks: (BlockId | null)[];
51
51
  };
52
52
  /** The tree the change report last published. */
53
53
  export type Published = {
@@ -68,6 +68,10 @@ export type Tx = {
68
68
  insertSet?: IdSetLike;
69
69
  deleteSet?: IdSetLike;
70
70
  changed?: EngineTransaction['changed'];
71
+ /** The visibility changes hold records made, in order (fork patch YP20). */
72
+ holds?: number[];
73
+ /** The units whose mover changed, in order (fork patch YP22). */
74
+ moves?: number[];
71
75
  };
72
76
  /** The index's self-checks (`indexChecks`), run after each fold and each report. */
73
77
  export type SelfChecks = {
@@ -102,16 +106,7 @@ export declare const indexState: (doc: EngineDoc) => {
102
106
  placed: Map<string, Placed>;
103
107
  /** Each row's text → its home (rows are keyed by home). */
104
108
  homeOfText: WeakMap<object, string>;
105
- /** Each holder's list claims' effective claimers, by list index (absent: all its own). */
106
- attachOf: Map<string, string[]>;
107
- /** An effective claimer → the holders whose claims moved to it. */
108
- foreignOf: Map<string, Set<string>>;
109
- /** A row's home → the holders with an anchored claim in its text. */
110
- anchoredIn: Map<string, Set<string>>;
111
- /** Holders whose targets the next pass re-decides, and blocks whose claims it re-reads. */
112
- retargets: Set<string>;
113
- /** Holders with an anchored claim and no stream yet: any re-placed row may resolve them. */
114
- unresolved: Set<string>;
109
+ /** Blocks whose claims (implicit, then their stream's claim items) the next pass re-reads. */
115
110
  reclaim: Set<string>;
116
111
  /** The role table the display reads; `null` → none. */
117
112
  roles: DisplayRoles | null;
@@ -121,10 +116,18 @@ export declare const indexState: (doc: EngineDoc) => {
121
116
  dissolved: Set<string>;
122
117
  /** Resolved placements. */
123
118
  placementsMap: Map<string, ResolvedPlacement>;
124
- /** The texts whose pieces' order is re-decided at the next pass (`order.split.text`). */
125
- regroup: Set<string>;
126
- /** A block's argmax candidate parent → the blocks naming it (its entry decides theirs). */
127
- byArgParent: Map<string, Set<string>>;
119
+ /** Counts the folds that changed a sequence (a slot or record written or removed): a slot map read before one is stale. */
120
+ seqEpoch: number;
121
+ /** Every block slot by the id it names (`{ b }`, fork patch YP22), kept from the folds; a block's home is `homeFor`. */
122
+ slotsByBlock: Map<string, SlotRef[]>;
123
+ /** Each sequence owner's blocks (every block whose display edge it holds), sorted by key. */
124
+ rawOrder: Map<string | null, ChildSlot[]>;
125
+ /** Each block's display edge as accepted, or its strongest when none is (`null`: no slot). */
126
+ edges: Map<string, Edge | null>;
127
+ /** The blocks shown below their strongest edge: a cycle dropped a later move, they are back where they stood. */
128
+ fallen: Set<string>;
129
+ /** The blocks at the root's tail: every edge closes a cycle, or no slot. */
130
+ rejected: Set<string>;
128
131
  /** The children index without the layout rules (what they read), and with them. */
129
132
  kids0: Map<string | null, ChildSlot[]>;
130
133
  slots0: Map<string, Slot>;
@@ -146,7 +149,7 @@ export declare const indexState: (doc: EngineDoc) => {
146
149
  allListsDirty: boolean;
147
150
  /** The next pass rebuilds everything (first build, roles, an irregular state). */
148
151
  placementFull: boolean;
149
- /** Blocks whose candidates or record changed, whose display state changed. */
152
+ /** Blocks whose slot, record or mover changed; blocks whose display state changed. */
150
153
  placementSeeds: Set<string>;
151
154
  stateSeeds: Set<string>;
152
155
  /**
@@ -182,6 +185,7 @@ export declare const indexState: (doc: EngineDoc) => {
182
185
  folds: number;
183
186
  pairs: number;
184
187
  structs: number;
188
+ placed: number;
185
189
  };
186
190
  /** Frames tracking the folds (the write funnel's `track()`), and the report's candidates. */
187
191
  frames: Set<Folded>;
@@ -32,17 +32,7 @@ export const indexState = (doc) => {
32
32
  placed: new Map(),
33
33
  /** Each row's text → its home (rows are keyed by home). */
34
34
  homeOfText: new WeakMap(),
35
- // ── anchored merge claims (`anchored.ts`)
36
- /** Each holder's list claims' effective claimers, by list index (absent: all its own). */
37
- attachOf: new Map(),
38
- /** An effective claimer → the holders whose claims moved to it. */
39
- foreignOf: new Map(),
40
- /** A row's home → the holders with an anchored claim in its text. */
41
- anchoredIn: new Map(),
42
- /** Holders whose targets the next pass re-decides, and blocks whose claims it re-reads. */
43
- retargets: new Set(),
44
- /** Holders with an anchored claim and no stream yet: any re-placed row may resolve them. */
45
- unresolved: new Set(),
35
+ /** Blocks whose claims (implicit, then their stream's claim items) the next pass re-reads. */
46
36
  reclaim: new Set(),
47
37
  // ── roles
48
38
  /** The role table the display reads; `null` → none. */
@@ -54,10 +44,18 @@ export const indexState = (doc) => {
54
44
  dissolved: new Set(),
55
45
  /** Resolved placements. */
56
46
  placementsMap: new Map(),
57
- /** The texts whose pieces' order is re-decided at the next pass (`order.split.text`). */
58
- regroup: new Set(),
59
- /** A block's argmax candidate parent → the blocks naming it (its entry decides theirs). */
60
- byArgParent: new Map(),
47
+ /** Counts the folds that changed a sequence (a slot or record written or removed): a slot map read before one is stale. */
48
+ seqEpoch: 0,
49
+ /** Every block slot by the id it names (`{ b }`, fork patch YP22), kept from the folds; a block's home is `homeFor`. */
50
+ slotsByBlock: new Map(),
51
+ /** Each sequence owner's blocks (every block whose display edge it holds), sorted by key. */
52
+ rawOrder: new Map(),
53
+ /** Each block's display edge as accepted, or its strongest when none is (`null`: no slot). */
54
+ edges: new Map(),
55
+ /** The blocks shown below their strongest edge: a cycle dropped a later move, they are back where they stood. */
56
+ fallen: new Set(),
57
+ /** The blocks at the root's tail: every edge closes a cycle, or no slot. */
58
+ rejected: new Set(),
61
59
  /** The children index without the layout rules (what they read), and with them. */
62
60
  kids0,
63
61
  slots0,
@@ -79,7 +77,7 @@ export const indexState = (doc) => {
79
77
  allListsDirty: true,
80
78
  /** The next pass rebuilds everything (first build, roles, an irregular state). */
81
79
  placementFull: true,
82
- /** Blocks whose candidates or record changed, whose display state changed. */
80
+ /** Blocks whose slot, record or mover changed; blocks whose display state changed. */
83
81
  placementSeeds: new Set(),
84
82
  stateSeeds: new Set(),
85
83
  /**
@@ -106,7 +104,7 @@ export const indexState = (doc) => {
106
104
  /** The index version (`RunView.version`). */
107
105
  version: 0,
108
106
  /** The fold counters `debug` exposes read-only. */
109
- foldStats: { folds: 0, pairs: 0, structs: 0 },
107
+ foldStats: { folds: 0, pairs: 0, structs: 0, placed: 0 },
110
108
  // ── the fold (`fold.ts`) and the report (`report.ts`)
111
109
  /** Frames tracking the folds (the write funnel's `track()`), and the report's candidates. */
112
110
  frames: new Set(),
@@ -1,13 +1,15 @@
1
1
  /**
2
2
  * The stream table: one maintained row per backing text, the
3
- * delimiting boundary of each block, and each block's segment.
3
+ * delimiting boundary of each block, each block's segment, and each
4
+ * block's claims (the claim items of its segment).
4
5
  */
5
6
  import type { BlockId } from '../../placement/model.js';
6
- import { type Stream } from '../model.js';
7
+ import { type Claim, type Stream } from '../model.js';
7
8
  import { type LiveRow } from '../rows.js';
8
- import type { IndexState } from './state.js';
9
- /** The stream table of one doc's index, over its state. */
10
- export declare const indexStreams: (ix: IndexState) => {
9
+ import type { IndexClaims } from './claims.js';
10
+ import type { FoldCtx, IndexState } from './state.js';
11
+ /** The stream table of one doc's index, over its state and claim graph. */
12
+ export declare const indexStreams: (ix: IndexState & IndexClaims) => {
11
13
  streamOf: (b: BlockId) => Stream | undefined;
12
14
  streamsIn: (home: BlockId) => Stream[];
13
15
  streamAt: (home: BlockId, i: number) => Stream | undefined;
@@ -16,5 +18,8 @@ export declare const indexStreams: (ix: IndexState) => {
16
18
  refreshDelims: (named: Iterable<BlockId>, homes: Set<BlockId>) => void;
17
19
  placeHome: (home: BlockId, invalidated: Set<BlockId>) => void;
18
20
  rebuildTable: (invalidated: Set<BlockId>) => void;
21
+ sameClaims: (x: readonly Claim[], y: readonly Claim[]) => boolean;
22
+ claimsOf: (b: BlockId) => Claim[];
23
+ applyReclaims: (ctx: FoldCtx | null) => void;
19
24
  };
20
25
  export type IndexStreams = ReturnType<typeof indexStreams>;
@@ -1,8 +1,9 @@
1
- import { byId, scanText } from '../model.js';
2
- import { headOf, placeRow, rowOf, segmentAt, segmentOfCut, streamOfSegment } from '../rows.js';
3
- /** The stream table of one doc's index, over its state. */
1
+ import { byId, cmpStamp, scanText } from '../model.js';
2
+ import { removedKeys } from '../streams.js';
3
+ import { headOf, placeRow, rowOf, segmentAt, segmentClaims, segmentOfCut, streamOfSegment } from '../rows.js';
4
+ /** The stream table of one doc's index, over its state and claim graph. */
4
5
  export const indexStreams = (ix) => {
5
- const { blocks, listConsumers, rows, streamIx, placed, homeOfText, anchoredIn, retargets, unresolved, regroup } = ix;
6
+ const { registry, blocks, listConsumers, rows, streamIx, placed, homeOfText, reclaim, noteClaims, invalidateBlock } = ix;
6
7
  // ── the stream table ────────────────────────────────────
7
8
  // One maintained row per backing text (keyed by its home block): its
8
9
  // live boundaries and the units between them (`text/rows.ts`), the
@@ -54,7 +55,7 @@ export const indexStreams = (ix) => {
54
55
  if (old?.key === row?.key)
55
56
  return;
56
57
  for (const b of old?.bounds ?? []) {
57
- if (row?.keyIndex.has(b.key))
58
+ if (b.m !== undefined || row?.keyIndex.has(b.key))
58
59
  continue;
59
60
  const by = boundsBy.get(b.s);
60
61
  // A text can change homes (a key's node becomes a losing incarnation,
@@ -66,7 +67,7 @@ export const indexStreams = (ix) => {
66
67
  named.add(b.s);
67
68
  }
68
69
  for (const b of row?.bounds ?? []) {
69
- if (old?.keyIndex.has(b.key))
70
+ if (b.m !== undefined || old?.keyIndex.has(b.key))
70
71
  continue;
71
72
  let by = boundsBy.get(b.s);
72
73
  if (by === undefined)
@@ -80,18 +81,27 @@ export const indexStreams = (ix) => {
80
81
  const text = blocks.get(home)?.content;
81
82
  return text === undefined ? undefined : rowOf(scanText(home, text));
82
83
  };
84
+ /** A removed block's key (`room.purge.what`): its boundary delimits nobody's stretch. */
85
+ const removed = removedKeys(registry);
86
+ /** A cut's stretch is nobody's when it names no block (a removed one). */
87
+ const nobody = (s) => !blocks.has(s);
83
88
  /** Re-decide the delimiting boundary of each block in `named`; the rows a change cuts join `homes`. */
84
89
  const refreshDelims = (named, homes) => {
85
90
  for (const s of named) {
86
- const n = blocks.get(s)?.n;
91
+ const rec = blocks.get(s);
92
+ const gone = rec === undefined && removed(s);
87
93
  let best;
88
- if (blocks.has(s))
94
+ if (rec !== undefined || gone)
89
95
  for (const [key, b] of boundsBy.get(s) ?? [])
90
- if (b.n === n && (best === undefined || byId(key, best) < 0))
96
+ if ((gone || b.n === rec.n) && (best === undefined || byId(key, best) < 0))
91
97
  best = key;
92
98
  const old = ix.delim.get(s);
93
- if (old === best)
99
+ if (old === best) {
100
+ // The cut stays, and the block it opens may have come or gone (removed).
101
+ if (best !== undefined)
102
+ homes.add(boundsBy.get(s).get(best).home);
94
103
  continue;
104
+ }
95
105
  if (best === undefined)
96
106
  ix.delim.delete(s);
97
107
  else
@@ -116,33 +126,34 @@ export const indexStreams = (ix) => {
116
126
  const before = placed.get(home) ?? { head: null, keys: [], blocks: [] };
117
127
  const now = { head: null, keys: [], blocks: [] };
118
128
  if (row !== undefined) {
119
- placeRow(row, ix.delim);
129
+ placeRow(row, ix.delim, nobody);
120
130
  now.head = row.head;
121
- for (const j of row.cuts) {
131
+ row.cuts.forEach((j, k) => {
122
132
  now.keys.push(row.bounds[j].key);
123
- now.blocks.push(row.bounds[j].s);
124
- }
133
+ now.blocks.push(row.heads[k]);
134
+ });
125
135
  }
126
136
  if (row === undefined)
127
137
  placed.delete(home);
128
138
  else
129
139
  placed.set(home, now);
130
- // Its cuts may move the claims anchored in its text (`merge.claim.anchor`).
131
- for (const h of anchoredIn.get(home) ?? [])
132
- retargets.add(h);
133
- for (const h of unresolved)
134
- retargets.add(h);
135
- // A change of the text's segments re-decides its pieces' order.
136
- if (before.head !== now.head ||
137
- before.blocks.length !== now.blocks.length ||
138
- before.blocks.some((b, i) => now.blocks[i] !== b))
139
- regroup.add(home);
140
+ // Its segments' claim items may have changed, or gone to other blocks.
141
+ for (const x of [before, now]) {
142
+ if (x.head !== null)
143
+ reclaim.add(x.head);
144
+ for (const b of x.blocks)
145
+ if (b !== null)
146
+ reclaim.add(b);
147
+ }
140
148
  const [a, b] = [before.keys, now.keys];
149
+ // A cut is the same when its boundary and the block it opens are (a
150
+ // removed block's cut opens nobody's stretch).
151
+ const same = (i, j) => a[i] === b[j] && before.blocks[i] === now.blocks[j];
141
152
  let p = 0;
142
- while (p < a.length && p < b.length && a[p] === b[p])
153
+ while (p < a.length && p < b.length && same(p, p))
143
154
  p++;
144
155
  let q = 0;
145
- while (q < a.length - p && q < b.length - p && a[a.length - 1 - q] === b[b.length - 1 - q])
156
+ while (q < a.length - p && q < b.length - p && same(a.length - 1 - q, b.length - 1 - q))
146
157
  q++;
147
158
  // Segment k ends at cut k: it changed iff k lies in [p, n - q] (segment 0 also with its block).
148
159
  const from = before.head === now.head ? p : 0;
@@ -173,6 +184,8 @@ export const indexStreams = (ix) => {
173
184
  boundsBy.clear();
174
185
  for (const [home, row] of rows)
175
186
  for (const b of row.bounds) {
187
+ if (b.m !== undefined)
188
+ continue;
176
189
  let by = boundsBy.get(b.s);
177
190
  if (by === undefined)
178
191
  boundsBy.set(b.s, (by = new Map()));
@@ -184,6 +197,41 @@ export const indexStreams = (ix) => {
184
197
  for (const home of homes)
185
198
  placeHome(home, invalidated);
186
199
  };
200
+ // ── claims ──────────────────────────────────────────────
201
+ // A block's claims are its implicit ones (`id.same.concurrent`), then
202
+ // the claim items of its segment, in text order (fork patch YP21:
203
+ // YATA placed each one, so a split its writer did not see leaves it in
204
+ // the piece that ends its holder's region, `merge.claim.anchor`). They
205
+ // change with the record (its implicit claims) and with its row's bounds
206
+ // or cuts: re-read after each fold's texts for the blocks queued.
207
+ const sameClaims = (x, y) => x.length === y.length &&
208
+ x.every((c, i) => c.m === y[i].m && cmpStamp(c.stamp, y[i].stamp) === 0);
209
+ /** `b`'s claims now: its implicit ones, then its segment's claim items. */
210
+ const claimsOf = (b) => {
211
+ const at = streamIx.get(b);
212
+ const row = at && rows.get(at.home);
213
+ const k = row === undefined ? -1 : segmentOfCut(row, at.cut);
214
+ const items = k < 0 ? [] : segmentClaims(row, k);
215
+ const implicit = blocks.get(b)?.implicit ?? [];
216
+ return implicit.length === 0 ? items : [...implicit, ...items];
217
+ };
218
+ /** Re-read the claims of the blocks queued; a change is a structural change of the block. */
219
+ const applyReclaims = (ctx) => {
220
+ for (const b of reclaim) {
221
+ const rec = blocks.get(b);
222
+ if (rec === undefined)
223
+ continue;
224
+ const before = rec.claims;
225
+ const after = claimsOf(b);
226
+ if (sameClaims(before, after))
227
+ continue;
228
+ rec.claims = after;
229
+ noteClaims(b, before, after);
230
+ if (ctx !== null)
231
+ invalidateBlock(b, ctx, before);
232
+ }
233
+ reclaim.clear();
234
+ };
187
235
  return {
188
236
  streamOf,
189
237
  streamsIn,
@@ -192,6 +240,9 @@ export const indexStreams = (ix) => {
192
240
  scanRow,
193
241
  refreshDelims,
194
242
  placeHome,
195
- rebuildTable
243
+ rebuildTable,
244
+ sameClaims,
245
+ claimsOf,
246
+ applyReclaims
196
247
  };
197
248
  };
@@ -1,8 +1,15 @@
1
1
  /**
2
- * The guards of a backing text's items: a boundary item's payload, and a
3
- * node's first item for sequence walks.
2
+ * The guards of a backing text's items: a boundary item's payload, a merge
3
+ * claim item's, and a node's first item for sequence walks.
4
4
  */
5
5
  import type { EngineNode } from '../engine-api.js';
6
- import type { Boundary, SeqItem } from './model.js';
6
+ import type { Boundary, MergeClaim, SeqItem } from './model.js';
7
7
  export declare const isBoundary: (v: unknown) => v is Boundary;
8
+ /**
9
+ * A merge claim item `{m}` (fork patch YP21: the engine sorts it after the
10
+ * content and boundaries of its origin, and keeps it on collection).
11
+ */
12
+ export declare const isClaimItem: (v: unknown) => v is MergeClaim;
13
+ /** A unit a row tracks and no read displays: a boundary or a claim item. */
14
+ export declare const isRowMark: (v: unknown) => boolean;
8
15
  export declare const nodeStart: (node: EngineNode) => SeqItem | null;
@@ -1,3 +1,10 @@
1
1
  import { firstItem } from '../structs.js';
2
2
  export const isBoundary = (v) => v != null && typeof v === 'object' && typeof v.s === 'string' && 'n' in v;
3
+ /**
4
+ * A merge claim item `{m}` (fork patch YP21: the engine sorts it after the
5
+ * content and boundaries of its origin, and keeps it on collection).
6
+ */
7
+ export const isClaimItem = (v) => v != null && typeof v === 'object' && typeof v.m === 'string';
8
+ /** A unit a row tracks and no read displays: a boundary or a claim item. */
9
+ export const isRowMark = (v) => isBoundary(v) || isClaimItem(v);
3
10
  export const nodeStart = (node) => firstItem(node);