edytor 2.0.0 → 3.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 (222) 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/room/admission.js +3 -3
  10. package/dist/cloudflare/room/context.d.ts +1 -1
  11. package/dist/cloudflare/routeDocumentSocket.d.ts +17 -0
  12. package/dist/cloudflare/routeDocumentSocket.js +53 -0
  13. package/dist/collaboration/comments/client.d.ts +1 -1
  14. package/dist/collaboration/comments/client.js +1 -1
  15. package/dist/collaboration/remoteSelection.js +3 -3
  16. package/dist/components/Edytor.svelte +2 -10
  17. package/dist/components/Edytor.svelte.d.ts +1 -3
  18. package/dist/crdt/admission.d.ts +5 -10
  19. package/dist/crdt/admission.js +5 -11
  20. package/dist/crdt/doc/funnel.d.ts +7 -6
  21. package/dist/crdt/doc/funnel.js +10 -9
  22. package/dist/crdt/doc/gate.d.ts +0 -17
  23. package/dist/crdt/doc/gate.js +2 -41
  24. package/dist/crdt/doc/history.js +2 -2
  25. package/dist/crdt/document.d.ts +5 -14
  26. package/dist/crdt/document.js +5 -19
  27. package/dist/crdt/edytor-doc.d.ts +4 -4
  28. package/dist/crdt/edytor-doc.js +3 -7
  29. package/dist/crdt/index.d.ts +3 -3
  30. package/dist/crdt/index.js +2 -2
  31. package/dist/crdt/protocol.d.ts +2 -2
  32. package/dist/crdt/protocol.js +2 -2
  33. package/dist/crdt/providers/index.d.ts +1 -1
  34. package/dist/crdt/providers/room.d.ts +10 -9
  35. package/dist/crdt/providers/room.js +13 -10
  36. package/dist/crdt/providers/websocket.d.ts +1 -1
  37. package/dist/crdt/providers/websocket.js +28 -29
  38. package/dist/crdt/semantics.js +3 -1
  39. package/dist/dnd/autoScroll.d.ts +15 -7
  40. package/dist/dnd/autoScroll.js +10 -15
  41. package/dist/dnd/dropIndicator.js +2 -5
  42. package/dist/dnd/external.d.ts +6 -0
  43. package/dist/dnd/external.js +17 -0
  44. package/dist/dnd/geometry.d.ts +2 -0
  45. package/dist/dnd/geometry.js +3 -4
  46. package/dist/dnd/placement.d.ts +1 -1
  47. package/dist/dnd/pragmatic.d.ts +3 -1
  48. package/dist/dnd/pragmatic.js +12 -2
  49. package/dist/dnd/vendor/pragmatic/UPSTREAM.md +51 -18
  50. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.d.ts +4 -0
  51. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js +6 -0
  52. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.d.ts +0 -2
  53. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.js +4 -22
  54. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter-types.d.ts +26 -0
  55. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.d.ts +30 -0
  56. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.js +203 -0
  57. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-items.js +13 -0
  58. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-types.js +9 -0
  59. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/is-an-available-type.js +19 -0
  60. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.d.ts +4 -0
  61. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.js +6 -0
  62. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/make-honey-pot-fix.js +4 -16
  63. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types.d.ts +1 -8
  64. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-drop-target.js +5 -6
  65. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-monitor.js +2 -3
  66. 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
  67. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.js +6 -24
  68. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.d.ts +2 -0
  69. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js +5 -0
  70. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.d.ts +3 -0
  71. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js +12 -0
  72. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/native-types.d.ts +12 -0
  73. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window-in-safari.js +10 -0
  74. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window.js +55 -0
  75. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.d.ts +4 -0
  76. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.js +8 -0
  77. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/internal-types.d.ts +0 -4
  78. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/get-scroll-by.js +16 -72
  79. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/try-scroll.js +1 -9
  80. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/configuration.js +4 -29
  81. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-scroll-change.js +2 -3
  82. package/dist/edytor.svelte.d.ts +2 -5
  83. package/dist/edytor.svelte.js +17 -31
  84. package/dist/events/onBeforeInput.js +1 -1
  85. package/dist/events/onDrop.d.ts +0 -6
  86. package/dist/events/onDrop.js +10 -23
  87. package/dist/events/onInput.d.ts +0 -12
  88. package/dist/events/onInput.js +1 -67
  89. package/dist/export/forms.d.ts +627 -0
  90. package/dist/export/forms.js +749 -0
  91. package/dist/export/index.d.ts +170 -0
  92. package/dist/export/index.js +161 -0
  93. package/dist/export/markdown.d.ts +41 -0
  94. package/dist/export/markdown.js +585 -0
  95. package/dist/export/markdownWriter.d.ts +9 -0
  96. package/dist/export/markdownWriter.js +133 -0
  97. package/dist/export/mdx.d.ts +15 -0
  98. package/dist/export/mdx.js +33 -0
  99. package/dist/index.d.ts +3 -3
  100. package/dist/index.js +1 -1
  101. package/dist/kinds.js +1 -1
  102. package/dist/plugins/anchored.svelte.d.ts +21 -25
  103. package/dist/plugins/anchored.svelte.js +23 -39
  104. package/dist/plugins/blockHandles/BlockHandleController.svelte.js +24 -32
  105. package/dist/plugins/blockHandles/dragPreview.d.ts +26 -7
  106. package/dist/plugins/blockHandles/dragPreview.js +33 -0
  107. package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +5 -0
  108. package/dist/plugins/blockMenu/BlockMenuController.svelte.js +7 -2
  109. package/dist/plugins/blockMenu/blockMenuPlugin.js +5 -50
  110. package/dist/plugins/chrome.d.ts +27 -5
  111. package/dist/plugins/chrome.js +24 -9
  112. package/dist/plugins/code/CodePlugin.svelte +12 -9
  113. package/dist/plugins/code/header.svelte.js +7 -11
  114. package/dist/plugins/code/languageMenu.svelte.d.ts +5 -2
  115. package/dist/plugins/code/languageMenu.svelte.js +13 -20
  116. package/dist/plugins/columns/ColumnsPlugin.svelte +7 -20
  117. package/dist/plugins/columns/resize.svelte.d.ts +2 -3
  118. package/dist/plugins/columns/resize.svelte.js +2 -5
  119. package/dist/plugins/comments/CommentsController.svelte.d.ts +6 -0
  120. package/dist/plugins/comments/CommentsController.svelte.js +20 -0
  121. package/dist/plugins/equation/EquationPlugin.svelte +12 -22
  122. package/dist/plugins/equation/equation.svelte.d.ts +7 -15
  123. package/dist/plugins/equation/equation.svelte.js +13 -50
  124. package/dist/plugins/equation/tex.d.ts +17 -0
  125. package/dist/plugins/equation/tex.js +42 -0
  126. package/dist/plugins/fileDrop.d.ts +38 -23
  127. package/dist/plugins/fileDrop.js +82 -76
  128. package/dist/plugins/find/FindController.svelte.d.ts +5 -0
  129. package/dist/plugins/find/FindController.svelte.js +14 -14
  130. package/dist/plugins/find/findPlugin.js +1 -15
  131. package/dist/plugins/image/ImageChrome.svelte +8 -2
  132. package/dist/plugins/image/ImagePlugin.svelte +15 -52
  133. package/dist/plugins/image/controls.svelte.js +16 -2
  134. package/dist/plugins/image/toolbar.svelte.d.ts +5 -4
  135. package/dist/plugins/image/toolbar.svelte.js +21 -31
  136. package/dist/plugins/index.d.ts +1 -1
  137. package/dist/plugins/list.svelte.d.ts +9 -0
  138. package/dist/plugins/list.svelte.js +18 -0
  139. package/dist/plugins/marquee/marqueePlugin.js +0 -4
  140. package/dist/plugins/media/AudioPlugin.svelte +1 -1
  141. package/dist/plugins/media/BookmarkPlugin.svelte +6 -97
  142. package/dist/plugins/media/EmbedPlugin.svelte +5 -90
  143. package/dist/plugins/media/EmptySlot.svelte +36 -20
  144. package/dist/plugins/media/EmptySlot.svelte.d.ts +6 -15
  145. package/dist/plugins/media/FilePlugin.svelte +1 -19
  146. package/dist/plugins/media/MediaEmpty.svelte +2 -55
  147. package/dist/plugins/media/MediaEmpty.svelte.d.ts +18 -14
  148. package/dist/plugins/media/SourceBlock.svelte +142 -52
  149. package/dist/plugins/media/SourceBlock.svelte.d.ts +10 -4
  150. package/dist/plugins/media/VideoPlugin.svelte +1 -1
  151. package/dist/plugins/media/empty.svelte.js +2 -7
  152. package/dist/plugins/media/media.d.ts +2 -63
  153. package/dist/plugins/media/media.js +1 -194
  154. package/dist/plugins/media/sources.d.ts +60 -0
  155. package/dist/plugins/media/sources.js +165 -0
  156. package/dist/plugins/media/urlPaste.svelte.d.ts +2 -1
  157. package/dist/plugins/media/urlPaste.svelte.js +12 -21
  158. package/dist/plugins/mention/MentionPlugin.svelte +8 -35
  159. package/dist/plugins/page/PagePlugin.svelte +2 -9
  160. package/dist/plugins/page/page.js +1 -1
  161. package/dist/plugins/pageLink/PageLinkPlugin.svelte +6 -13
  162. package/dist/plugins/richtext/RichTextPlugin.svelte +85 -197
  163. package/dist/plugins/richtext/body.js +1 -1
  164. package/dist/plugins/richtext/calloutIcons.svelte.d.ts +2 -2
  165. package/dist/plugins/richtext/calloutIcons.svelte.js +5 -7
  166. package/dist/plugins/richtext/richTextOperations.d.ts +1 -19
  167. package/dist/plugins/richtext/richTextOperations.js +3 -49
  168. package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +2 -0
  169. package/dist/plugins/slashMenu/SlashMenuController.svelte.js +7 -0
  170. package/dist/plugins/slashMenu/slashMenuPlugin.js +5 -14
  171. package/dist/plugins/table/TableChrome.svelte +2 -3
  172. package/dist/plugins/table/TablePlugin.svelte +20 -54
  173. package/dist/plugins/table/chrome.svelte.d.ts +5 -2
  174. package/dist/plugins/table/chrome.svelte.js +30 -54
  175. package/dist/plugins/table/table.js +3 -3
  176. package/dist/plugins/toc/TocPlugin.svelte +2 -4
  177. package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +7 -0
  178. package/dist/plugins/toolbar/ToolbarController.svelte.js +20 -13
  179. package/dist/plugins/toolbar/toolbarPlugin.js +19 -53
  180. package/dist/plugins/triggers/TriggerController.svelte.d.ts +7 -2
  181. package/dist/plugins/triggers/TriggerController.svelte.js +11 -4
  182. package/dist/plugins/triggers/place.js +1 -2
  183. package/dist/plugins/triggers/triggers.d.ts +6 -1
  184. package/dist/plugins/triggers/triggers.js +12 -13
  185. package/dist/plugins/uploads.svelte.d.ts +5 -2
  186. package/dist/plugins/uploads.svelte.js +25 -15
  187. package/dist/plugins.d.ts +26 -0
  188. package/dist/plugins.js +0 -24
  189. package/dist/selection/replaceSelection.js +2 -2
  190. package/dist/selection/selection.svelte.d.ts +4 -10
  191. package/dist/selection/selection.svelte.js +7 -11
  192. package/dist/session/bindings.js +1 -1
  193. package/dist/session/commands.d.ts +7 -11
  194. package/dist/session/commands.js +13 -19
  195. package/dist/session/inputRules.js +1 -1
  196. package/dist/session/navigation.js +1 -1
  197. package/dist/session/suggestions.svelte.d.ts +0 -11
  198. package/dist/session/suggestions.svelte.js +15 -3
  199. package/dist/session/uploads.d.ts +8 -8
  200. package/dist/surface/lines.js +1 -3
  201. package/dist/surface/observer.svelte.d.ts +17 -1
  202. package/dist/surface/observer.svelte.js +72 -17
  203. package/dist/surface/overlay.d.ts +0 -14
  204. package/dist/surface/overlay.js +0 -25
  205. package/dist/surface/projector.svelte.js +1 -1
  206. package/dist/text/text.svelte.js +3 -13
  207. package/dist/utils/sanitize.d.ts +38 -0
  208. package/dist/utils/sanitize.js +82 -0
  209. package/dist/utils.d.ts +2 -0
  210. package/dist/utils.js +5 -0
  211. package/package.json +18 -1
  212. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/max-z-index.js +0 -3
  213. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/supports-popover.js +0 -16
  214. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-axis-allowed.js +0 -3
  215. package/dist/plugins/code/LanguageMenu.svelte +0 -25
  216. package/dist/plugins/code/LanguageMenu.svelte.d.ts +0 -9
  217. package/dist/plugins/equation/EquationEditor.svelte +0 -27
  218. package/dist/plugins/equation/EquationEditor.svelte.d.ts +0 -9
  219. package/dist/plugins/image/ImageToolbarHost.svelte +0 -37
  220. package/dist/plugins/image/ImageToolbarHost.svelte.d.ts +0 -9
  221. package/dist/plugins/richtext/CalloutIconPicker.svelte +0 -26
  222. package/dist/plugins/richtext/CalloutIconPicker.svelte.d.ts +0 -9
@@ -4,14 +4,12 @@
4
4
  * Every way content enters an {@link EdytorDocument} crosses the same
5
5
  * gate here, in the same order, with the same refusal semantics:
6
6
  *
7
- * 1. **`assertUsableDoc`** — is this a v14 engine doc at all
8
- * ({@link UnsupportedDocError} `'foreign'`)?
9
- * 2. **`assertSchema`** — does the committed schema manifest allow
7
+ * 1. **`assertSchema`** — does the committed schema manifest allow
10
8
  * this build to own the doc ({@link SchemaMismatchError}:
11
9
  * `'unversioned'` content with no version stamp, `'unsupported'`
12
10
  * version this build cannot speak, `'foreign'` manifest naming
13
11
  * another schema)?
14
- * 3. **Verdict** — `'fresh'` (registry empty — seeding is legal) or
12
+ * 2. **Verdict** — `'fresh'` (registry empty — seeding is legal) or
15
13
  * `'initialized'` (supported schema content present — assert and
16
14
  * adopt, never seed).
17
15
  *
@@ -59,10 +57,10 @@
59
57
  * readiness transition, and a pending document never writes or
60
58
  * broadcasts a bootstrap block.
61
59
  */
62
- import { assertSchema, assertUsableDoc, checkSchema, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError, UnsupportedDocError } from './edytor-doc.js';
60
+ import { assertSchema, checkSchema, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError } from './edytor-doc.js';
63
61
  import type { SchemaProblem } from './edytor-doc.js';
64
62
  import type { EngineApi, EngineDoc, YDoc } from './engine-api.js';
65
- export { assertSchema, assertUsableDoc, checkSchema, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError, UnsupportedDocError };
63
+ export { assertSchema, checkSchema, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError };
66
64
  export type { SchemaProblem };
67
65
  /**
68
66
  * What an admitted doc carries — the `sync()` readiness decision:
@@ -83,7 +81,7 @@ export type AdmissionResult = {
83
81
  verdict: AdmissionVerdict;
84
82
  } | {
85
83
  admitted: false;
86
- error: UnsupportedDocError | SchemaMismatchError;
84
+ error: SchemaMismatchError;
87
85
  };
88
86
  /**
89
87
  * Raised when a candidate update cannot even be decoded or integrated —
@@ -102,9 +100,6 @@ export declare class UndecodableUpdateError extends Error {
102
100
  * The document-level admission gate — runs the ordered checks and throws
103
101
  * the typed refusal:
104
102
  *
105
- * - {@link UnsupportedDocError} `'foreign'` — not a v14 engine doc
106
- * (foreign roots/engines may still attach *content* later; this is
107
- * about doc shape);
108
103
  * - {@link SchemaMismatchError} `'unversioned' | 'unsupported' |
109
104
  * 'foreign'` — a schema claim this build cannot own.
110
105
  *
@@ -4,14 +4,12 @@
4
4
  * Every way content enters an {@link EdytorDocument} crosses the same
5
5
  * gate here, in the same order, with the same refusal semantics:
6
6
  *
7
- * 1. **`assertUsableDoc`** — is this a v14 engine doc at all
8
- * ({@link UnsupportedDocError} `'foreign'`)?
9
- * 2. **`assertSchema`** — does the committed schema manifest allow
7
+ * 1. **`assertSchema`** — does the committed schema manifest allow
10
8
  * this build to own the doc ({@link SchemaMismatchError}:
11
9
  * `'unversioned'` content with no version stamp, `'unsupported'`
12
10
  * version this build cannot speak, `'foreign'` manifest naming
13
11
  * another schema)?
14
- * 3. **Verdict** — `'fresh'` (registry empty — seeding is legal) or
12
+ * 2. **Verdict** — `'fresh'` (registry empty — seeding is legal) or
15
13
  * `'initialized'` (supported schema content present — assert and
16
14
  * adopt, never seed).
17
15
  *
@@ -59,11 +57,11 @@
59
57
  * readiness transition, and a pending document never writes or
60
58
  * broadcasts a bootstrap block.
61
59
  */
62
- import { assertSchema, assertUsableDoc, checkSchema, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError, UnsupportedDocError } from './edytor-doc.js';
60
+ import { assertSchema, checkSchema, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError } from './edytor-doc.js';
63
61
  import { asEngineDoc } from './structs.js';
64
62
  import { keepingReplaced } from './incarnations.js';
65
63
  // ── shared gate vocabulary (one doorway for document + transport layers) ──
66
- export { assertSchema, assertUsableDoc, checkSchema, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError, UnsupportedDocError };
64
+ export { assertSchema, checkSchema, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError };
67
65
  /**
68
66
  * Raised when a candidate update cannot even be decoded or integrated —
69
67
  * refused before the schema question is ever asked. Distinct from the
@@ -86,9 +84,6 @@ export class UndecodableUpdateError extends Error {
86
84
  * The document-level admission gate — runs the ordered checks and throws
87
85
  * the typed refusal:
88
86
  *
89
- * - {@link UnsupportedDocError} `'foreign'` — not a v14 engine doc
90
- * (foreign roots/engines may still attach *content* later; this is
91
- * about doc shape);
92
87
  * - {@link SchemaMismatchError} `'unversioned' | 'unsupported' |
93
88
  * 'foreign'` — a schema claim this build cannot own.
94
89
  *
@@ -98,7 +93,6 @@ export class UndecodableUpdateError extends Error {
98
93
  * readiness decision.
99
94
  */
100
95
  export const assertAdmission = (doc, docName = 'document') => {
101
- assertUsableDoc(doc);
102
96
  assertSchema(doc, docName);
103
97
  return isInitialized(doc) ? 'initialized' : 'fresh';
104
98
  };
@@ -112,7 +106,7 @@ export const inspectAdmission = (doc, docName = 'document') => {
112
106
  return { admitted: true, verdict: assertAdmission(doc, docName) };
113
107
  }
114
108
  catch (error) {
115
- if (error instanceof UnsupportedDocError || error instanceof SchemaMismatchError) {
109
+ if (error instanceof SchemaMismatchError) {
116
110
  return { admitted: false, error };
117
111
  }
118
112
  throw error;
@@ -2,13 +2,14 @@ import type { BlockAttributionApi } from '../attribution/block.js';
2
2
  import type { EdytorDocConfig, OpResult, Prepared } from './types.js';
3
3
  import type { DocBase, DocReads } from './reads.js';
4
4
  /**
5
- * Raised when a mutating facade op runs after `dispose()` — disposal is
6
- * terminal for writes (reads stay dead-safe: a stale handle may still be
7
- * inspected while its document outlives the facade). The facade-level
8
- * counterpart of `DocumentDestroyedError` — kept in this module because a
9
- * bare `bindEdytorDoc` facade has no document layer above it.
5
+ * Raised when an operation runs against a torn-down document: every attach
6
+ * reference released, or its facade disposed (terminal for writes; reads
7
+ * stay dead-safe: a stale handle may still be inspected). Distinct from
8
+ * `DocumentNotReadyError`: destroyed is terminal, pending may still resolve.
9
+ * Kept in this module because a bare `bindEdytorDoc` facade has no document
10
+ * layer above it.
10
11
  */
11
- export declare class EdytorDocDisposedError extends Error {
12
+ export declare class DocumentDestroyedError extends Error {
12
13
  constructor(service?: string);
13
14
  }
14
15
  /** What the write funnel writes with: the reads, the attribution writer and the facade's configuration. */
@@ -11,16 +11,17 @@ import { writeLeaves } from '../data.js';
11
11
  import { NOOP } from './plan.js';
12
12
  import { claimInto, deleteRange, formatRangeIn, insertIntoText } from '../text/model.js';
13
13
  /**
14
- * Raised when a mutating facade op runs after `dispose()` — disposal is
15
- * terminal for writes (reads stay dead-safe: a stale handle may still be
16
- * inspected while its document outlives the facade). The facade-level
17
- * counterpart of `DocumentDestroyedError` — kept in this module because a
18
- * bare `bindEdytorDoc` facade has no document layer above it.
14
+ * Raised when an operation runs against a torn-down document: every attach
15
+ * reference released, or its facade disposed (terminal for writes; reads
16
+ * stay dead-safe: a stale handle may still be inspected). Distinct from
17
+ * `DocumentNotReadyError`: destroyed is terminal, pending may still resolve.
18
+ * Kept in this module because a bare `bindEdytorDoc` facade has no document
19
+ * layer above it.
19
20
  */
20
- export class EdytorDocDisposedError extends Error {
21
+ export class DocumentDestroyedError extends Error {
21
22
  constructor(service) {
22
- super(`EdytorDoc${service ? `.${service}` : ''}: facade is disposed.`);
23
- this.name = 'EdytorDocDisposedError';
23
+ super(`${service ?? 'document'}: the document is destroyed`);
24
+ this.name = 'DocumentDestroyedError';
24
25
  }
25
26
  }
26
27
  /** The write funnel of one facade. */
@@ -37,7 +38,7 @@ export const writeFunnel = (c) => {
37
38
  /** Mutation boundary — every facade write funnels through `write`. */
38
39
  const write = (fn) => {
39
40
  if (disposed) {
40
- throw new EdytorDocDisposedError();
41
+ throw new DocumentDestroyedError();
41
42
  }
42
43
  config.assertWritable?.();
43
44
  return fn();
@@ -86,20 +86,3 @@ export declare class SchemaMismatchError extends Error {
86
86
  * mutating a synced document.
87
87
  */
88
88
  export declare const assertSchema: (doc: EngineDoc, docName?: string) => void;
89
- /**
90
- * Error raised by {@link assertUsableDoc} — the doc cannot host a v14 facade:
91
- * a foreign engine object (a v13 `yjs` Doc — a different CRDT implementation
92
- * entirely).
93
- */
94
- export declare class UnsupportedDocError extends Error {
95
- readonly kind: 'foreign';
96
- constructor(kind: 'foreign');
97
- }
98
- /**
99
- * Document-boundary guard run by {@link EdytorDocBinding.create} before the
100
- * runs view attaches. The facade only speaks the v14 unified-node surface —
101
- * without this gate a foreign doc dies obscurely inside `buildView`
102
- * (`registry.forEachAttr is not a function`); it fails fast with an
103
- * actionable error instead.
104
- */
105
- export declare const assertUsableDoc: (doc: EngineDoc) => void;
@@ -1,4 +1,4 @@
1
- import { isNodeLike, SCHEMA } from '../schema.js';
1
+ import { SCHEMA } from '../schema.js';
2
2
  export const SCHEMA_VERSION = SCHEMA.version;
3
3
  export const SCHEMA_NAME = SCHEMA.name;
4
4
  export const META_KEY = SCHEMA.roots.meta;
@@ -51,13 +51,7 @@ export class SchemaMismatchError extends Error {
51
51
  docName;
52
52
  problem;
53
53
  constructor(docName, problem) {
54
- super(problem.kind === 'unversioned'
55
- ? `Document "${docName}" carries replicated registry state but no meta.v schema version — refusing to treat it as initialized.`
56
- : problem.kind === 'unsupported'
57
- ? `Document "${docName}" claims unsupported schema version ${problem.version} (this build speaks ${SCHEMA_VERSION}).`
58
- : problem.schema === undefined
59
- ? `Document "${docName}" carries meta.v=${problem.version} but no meta.schema manifest name — refusing it as an "${SCHEMA_NAME}" document.`
60
- : `Document "${docName}" claims foreign schema "${String(problem.schema)}" (this build speaks "${SCHEMA_NAME}").`);
54
+ super(`${docName}: ${problem.kind} schema version ${problem.version} "${String(problem.schema)}" (this build speaks ${SCHEMA_VERSION} "${SCHEMA_NAME}")`);
61
55
  this.docName = docName;
62
56
  this.problem = problem;
63
57
  this.name = 'SchemaMismatchError';
@@ -73,36 +67,3 @@ export const assertSchema = (doc, docName = 'doc') => {
73
67
  if (problem !== null)
74
68
  throw new SchemaMismatchError(docName, problem);
75
69
  };
76
- /**
77
- * Error raised by {@link assertUsableDoc} — the doc cannot host a v14 facade:
78
- * a foreign engine object (a v13 `yjs` Doc — a different CRDT implementation
79
- * entirely).
80
- */
81
- export class UnsupportedDocError extends Error {
82
- kind;
83
- constructor(kind) {
84
- super('Document is not a v14 engine doc — the `blocks` registry is not a ' +
85
- 'unified Y.Node. Use `crdt.createDoc()` (or `new Y.Doc()` from `edytor/crdt`).');
86
- this.kind = kind;
87
- this.name = 'UnsupportedDocError';
88
- }
89
- }
90
- /**
91
- * Document-boundary guard run by {@link EdytorDocBinding.create} before the
92
- * runs view attaches. The facade only speaks the v14 unified-node surface —
93
- * without this gate a foreign doc dies obscurely inside `buildView`
94
- * (`registry.forEachAttr is not a function`); it fails fast with an
95
- * actionable error instead.
96
- */
97
- export const assertUsableDoc = (doc) => {
98
- let registry;
99
- try {
100
- registry = typeof doc?.get === 'function' ? doc.get(SCHEMA.roots.registry) : undefined;
101
- }
102
- catch {
103
- registry = undefined;
104
- }
105
- if (!isNodeLike(registry) || typeof registry.forEachAttr !== 'function') {
106
- throw new UnsupportedDocError('foreign');
107
- }
108
- };
@@ -15,7 +15,7 @@ import { readHorizon } from '../purge.js';
15
15
  import { BLOCK_NODE, DATA_LEAF_PREFIX, DOC_DATA_ROOT, HORIZON_ROOT, INLINE_NODE, LAST_CHANGED_ATTR, TYPE } from '../schema.js';
16
16
  import { changedUnder, collectable, collectNow, collects, dropSearchMarkers, engineOps, walkIdSet } from '../structs.js';
17
17
  import { isInitialized } from './gate.js';
18
- import { EdytorDocDisposedError } from './funnel.js';
18
+ import { DocumentDestroyedError } from './funnel.js';
19
19
  import { registryOf, withdrawOnUndo } from '../placement/model.js';
20
20
  /** The undo steps a document's history keeps by default: older ones are released. */
21
21
  export const DEFAULT_HISTORY_LIMIT = 200;
@@ -367,7 +367,7 @@ export const docHistory = (c) => {
367
367
  */
368
368
  const createUndoManager = (options = {}) => {
369
369
  if (disposed()) {
370
- throw new EdytorDocDisposedError('createUndoManager');
370
+ throw new DocumentDestroyedError('createUndoManager');
371
371
  }
372
372
  write(() => {
373
373
  if (!isInitialized(doc))
@@ -64,7 +64,7 @@
64
64
  * - `createDocument` — the fresh doc is trivially admitted;
65
65
  * - `loadDocument` — the payload is decoded+integrated onto a SCRATCH
66
66
  * doc first (`admitUpdate`) and the gate runs on the merged result; a
67
- * refusal ({@link UndecodableUpdateError}, {@link UnsupportedDocError},
67
+ * refusal ({@link UndecodableUpdateError},
68
68
  * {@link SchemaMismatchError}) leaves nothing composed and never
69
69
  * touches the caller's bytes;
70
70
  * - `attachDocument` — the borrowed doc is gated BEFORE any composition
@@ -144,7 +144,7 @@ import type { MarkEdge } from './text/marks.js';
144
144
  import type { EngineApi, EngineDoc, YDoc, YUndoManager } from './engine-api.js';
145
145
  import { type DocumentOperations } from './operations.js';
146
146
  import { type AttributionBinding, type DocumentAttribution } from './attribution/index.js';
147
- import { type BlockRole, type DocFacade, type EdytorDocConfig } from './edytor-doc.js';
147
+ import { DocumentDestroyedError, type BlockRole, type DocFacade, type EdytorDocConfig } from './edytor-doc.js';
148
148
  import { Awareness } from './protocols/awareness.js';
149
149
  import type { EdytorSync, EdytorSyncCleanup } from './providers/index.js';
150
150
  import { SyncRefusedError } from './providers/room.js';
@@ -243,19 +243,11 @@ export type CreateDocumentOptions = DocumentOptions & {
243
243
  value?: JSONDoc;
244
244
  };
245
245
  export type LoadDocumentOptions = DocumentOptions;
246
+ export { DocumentDestroyedError };
246
247
  /** Raised when a readiness-gated service is used on a pending document. */
247
248
  export declare class DocumentNotReadyError extends Error {
248
249
  constructor(service: string);
249
250
  }
250
- /**
251
- * Raised when an operation runs against a torn-down document — every
252
- * attach reference has been released and the facade/history/awareness
253
- * teardown already ran. Distinct from {@link DocumentNotReadyError}:
254
- * destroyed is terminal, pending may still resolve.
255
- */
256
- export declare class DocumentDestroyedError extends Error {
257
- constructor(service?: string);
258
- }
259
251
  /**
260
252
  * How the document's content state was decided — the distinction the
261
253
  * readiness contract requires:
@@ -641,9 +633,8 @@ export declare const bindDocument: (Y: EngineApi) => {
641
633
  * borrowed doc. Content state stays `pending` — the caller (view or
642
634
  * provider path) drives `sync()`.
643
635
  *
644
- * Admission runs BEFORE any composition touches the doc: a
645
- * foreign engine object refuses with {@link UnsupportedDocError}, an
646
- * unversioned/unsupported/foreign schema claim with
636
+ * Admission runs BEFORE any composition touches the doc: an
637
+ * unversioned/unsupported/foreign schema claim refuses with
647
638
  * {@link SchemaMismatchError} — the borrowed doc is left
648
639
  * byte-identical (the gate reads are write-free) and can be
649
640
  * attached once its state heals (e.g. a remote update supplies the
@@ -5,7 +5,7 @@ import { DOCUMENT_OPERATIONS } from './operations.js';
5
5
  import { propsProxy } from './props.js';
6
6
  import { bindAttribution } from './attribution/index.js';
7
7
  import { profileOf } from './attribution/attribution.js';
8
- import { docFacade, DEFAULT_HISTORY_LIMIT, isInitialized } from './edytor-doc.js';
8
+ import { docFacade, DocumentDestroyedError, DEFAULT_HISTORY_LIMIT, isInitialized } from './edytor-doc.js';
9
9
  import { assertAdmission, assertSchema, bindAdmission, checkSchema } from './admission.js';
10
10
  import { Awareness } from './protocols/awareness.js';
11
11
  import { callEach } from './protocols/observable.js';
@@ -18,27 +18,14 @@ const alive = (document, op) => {
18
18
  if (document.destroyed)
19
19
  throw new DocumentDestroyedError(op);
20
20
  };
21
+ export { DocumentDestroyedError };
21
22
  /** Raised when a readiness-gated service is used on a pending document. */
22
23
  export class DocumentNotReadyError extends Error {
23
24
  constructor(service) {
24
- super(`EdytorDocument.${service}: document is not ready — it is still pending ` +
25
- `(created without a value, provider hydration may be in flight). ` +
26
- `Wait for the sync callback / call document.sync() first.`);
25
+ super(`${service}: the document is not ready (call document.sync() first)`);
27
26
  this.name = 'DocumentNotReadyError';
28
27
  }
29
28
  }
30
- /**
31
- * Raised when an operation runs against a torn-down document — every
32
- * attach reference has been released and the facade/history/awareness
33
- * teardown already ran. Distinct from {@link DocumentNotReadyError}:
34
- * destroyed is terminal, pending may still resolve.
35
- */
36
- export class DocumentDestroyedError extends Error {
37
- constructor(service) {
38
- super(`EdytorDocument${service ? `.${service}` : ''}: document is destroyed.`);
39
- this.name = 'DocumentDestroyedError';
40
- }
41
- }
42
29
  /**
43
30
  * How long (ms) an empty document waits for a provider that has not
44
31
  * settled before it decides without it (settle-or-bound) — the bound a
@@ -926,9 +913,8 @@ export const bindDocument = (Y) => {
926
913
  * borrowed doc. Content state stays `pending` — the caller (view or
927
914
  * provider path) drives `sync()`.
928
915
  *
929
- * Admission runs BEFORE any composition touches the doc: a
930
- * foreign engine object refuses with {@link UnsupportedDocError}, an
931
- * unversioned/unsupported/foreign schema claim with
916
+ * Admission runs BEFORE any composition touches the doc: an
917
+ * unversioned/unsupported/foreign schema claim refuses with
932
918
  * {@link SchemaMismatchError} — the borrowed doc is left
933
919
  * byte-identical (the gate reads are write-free) and can be
934
920
  * attached once its state heals (e.g. a remote update supplies the
@@ -5,7 +5,7 @@ import { bindText } from './text/model.js';
5
5
  import { type RunView } from './text/runs.js';
6
6
  import { type BlockAttribution } from './attribution/block.js';
7
7
  import type { JSONBlock, JSONDoc } from '../utils/json.js';
8
- import { assertSchema, assertUsableDoc, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion } from './doc/gate.js';
8
+ import { assertSchema, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion } from './doc/gate.js';
9
9
  import type { EngineNode } from './engine-api.js';
10
10
  import type { ContentItem, InlineSpec, ModelView, SplitTail } from './placement/model.js';
11
11
  import type { Anchor } from './text/model.js';
@@ -14,10 +14,10 @@ import type { DocPosition } from './rangeDelete.js';
14
14
  import type { DataPatch } from './data.js';
15
15
  import type { AnchorAffinity, BlockRole, DataTarget, DocAnchor, DocChange, EdytorDocConfig, JsonObj, OpResult, OrderPolicy, Plan, PlanEffect, PlanStep, Prepared, TextRange } from './doc/types.js';
16
16
  export { SCHEMA };
17
- export { assertSchema, assertUsableDoc, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion };
18
- export { UnsupportedDocError, type SchemaProblem } from './doc/gate.js';
17
+ export { assertSchema, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion };
18
+ export type { SchemaProblem } from './doc/gate.js';
19
19
  export { SEED_ORIGIN } from './doc/seed.js';
20
- export { EdytorDocDisposedError } from './doc/funnel.js';
20
+ export { DocumentDestroyedError } from './doc/funnel.js';
21
21
  export { DEFAULT_HISTORY_LIMIT } from './doc/history.js';
22
22
  export type { AnchorAffinity, BlockRole, DataTarget, DocAnchor, DocChange, EdytorDocConfig, OpResult, OrderPolicy, Plan, PlanEffect, PlanStep, Prepared, TextRange };
23
23
  export type EdytorDoc = ReturnType<EdytorDocBinding['create']>;
@@ -58,7 +58,7 @@ import { bindRuns, indexOf } from './text/runs.js';
58
58
  import { bindBlockAttribution, blockAttributionOf } from './attribution/block.js';
59
59
  import { rangeDeleteOps } from './rangeDelete.js';
60
60
  import { flowOps } from './flow.js';
61
- import { assertSchema, assertUsableDoc, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion } from './doc/gate.js';
61
+ import { assertSchema, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion } from './doc/gate.js';
62
62
  import { bindSeed, restore } from './doc/seed.js';
63
63
  import { applied, ref } from './doc/plan.js';
64
64
  import { docReads } from './doc/reads.js';
@@ -76,10 +76,9 @@ import { metaOps } from './doc/meta.js';
76
76
  import { contentOps } from './doc/content.js';
77
77
  // ── schema manifest and gate (`doc/gate.ts`) ────────────────────────────
78
78
  export { SCHEMA };
79
- export { assertSchema, assertUsableDoc, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion };
80
- export { UnsupportedDocError } from './doc/gate.js';
79
+ export { assertSchema, checkSchema, isInitialized, META_KEY, registryEmpty, SCHEMA_NAME, SCHEMA_VERSION, SchemaMismatchError, schemaVersion };
81
80
  export { SEED_ORIGIN } from './doc/seed.js';
82
- export { EdytorDocDisposedError } from './doc/funnel.js';
81
+ export { DocumentDestroyedError } from './doc/funnel.js';
83
82
  export { DEFAULT_HISTORY_LIMIT } from './doc/history.js';
84
83
  /**
85
84
  * The per-doc facade factory over the engine `Y` (the editor's documents
@@ -94,9 +93,6 @@ export const docFacade = (Y, layers) => {
94
93
  const { init, seed } = bindSeed(Y, BA);
95
94
  return (doc, config = {}) => {
96
95
  keepingReplaced(doc);
97
- // Document-boundary check — foreign (v13-engine) and legacy-schema docs
98
- // fail fast here rather than inside the runs view (see assertUsableDoc).
99
- assertUsableDoc(doc);
100
96
  setMarkEdges(doc, config.markEdge ?? (() => undefined));
101
97
  const roleOf = config.roleOf ?? (() => undefined);
102
98
  const defaultType = config.defaultType ?? 'paragraph';
@@ -62,7 +62,7 @@ export type { YDoc, YUndoManager, YTransaction } from './engine-api.js';
62
62
  export { type EdytorSync, type EdytorSyncPayload, type EdytorSyncCleanup, type IndexeddbSyncOptions, type WebsocketSync, type WebsocketSyncOptions, type ProviderStack, type PrefetchOptions, type PrefetchResult, type LastUpdatedOptions } from './providers/index.js';
63
63
  export { SyncRefusedError } from './providers/room.js';
64
64
  export { Awareness, type AwarenessDoc, type AwarenessStates, type AwarenessUpdate, type MetaClientState } from './protocols/awareness.js';
65
- export { SchemaMismatchError, UndecodableUpdateError, UnsupportedDocError } from './admission.js';
65
+ export { SchemaMismatchError, UndecodableUpdateError } from './admission.js';
66
66
  export { type DocumentAttribution, type AttributionActor, type ActorProfile, type AttributionController } from './attribution/index.js';
67
67
  export { type ActorId, type BlockAttribution } from './attribution/index.js';
68
68
  import type { EngineApi, YDoc } from './engine-api.js';
@@ -583,7 +583,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
583
583
  off<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
584
584
  };
585
585
  };
586
- watchComments: (server: string, roomName: string, listener: (message: import("./protocol.js").CommentMessage) => void) => (() => void);
586
+ watchComments: (server: string | null, roomName: string, listener: (message: import("./protocol.js").CommentMessage) => void) => (() => void);
587
587
  storeState: (idbPersistence: {
588
588
  db: IDBDatabase | null;
589
589
  name: string;
@@ -632,4 +632,4 @@ export declare const bindCrdt: (Y: EngineApi) => {
632
632
  };
633
633
  export type Crdt = ReturnType<typeof bindCrdt>;
634
634
  export type { EngineApi, EngineDoc, EngineNode, EngineTransaction, EngineItemRef, YNode, YItem } from './engine-api.js';
635
- export { EdytorDocDisposedError, DEFAULT_HISTORY_LIMIT } from './edytor-doc.js';
635
+ export { DEFAULT_HISTORY_LIMIT } from './edytor-doc.js';
@@ -101,7 +101,7 @@ export { Awareness } from './protocols/awareness.js';
101
101
  // every content-entry path crosses). The gates themselves
102
102
  // (`assertAdmission`, `inspectAdmission`, …) are diagnostics vocabulary:
103
103
  // `edytor/protocol`.
104
- export { SchemaMismatchError, UndecodableUpdateError, UnsupportedDocError } from './admission.js';
104
+ export { SchemaMismatchError, UndecodableUpdateError } from './admission.js';
105
105
  // ── 5 · Attribution (read surface) ─────────────────────────────────────
106
106
  //
107
107
  // `document.attribution` hands back a `DocumentAttribution` — compact
@@ -145,4 +145,4 @@ export const bindCrdt = (Y) => {
145
145
  // The facade's disposal error and the history's default depth belong
146
146
  // to the document; the frame contract, message types and codecs are
147
147
  // `edytor/protocol`.
148
- export { EdytorDocDisposedError, DEFAULT_HISTORY_LIMIT } from './edytor-doc.js';
148
+ export { DEFAULT_HISTORY_LIMIT } from './edytor-doc.js';
@@ -27,14 +27,14 @@
27
27
  export { bindCrdt, type Crdt, type EngineApi, type EngineDoc, type EngineNode, type EngineTransaction, type EngineItemRef, type YNode, type YItem, type YDoc, type YUndoManager, type YTransaction } from './index.js';
28
28
  export { SCHEMA_VERSION, META_KEY } from './edytor-doc.js';
29
29
  export { GENERATION, generationWord, frame, PROTOCOL_VERSION, GENERATION_RECORD, GenerationMismatchError, readProtocolVersion, type GenerationRecord } from './protocols/envelope.js';
30
- export { messageSync, messageAwareness, messageAuth, messageQueryAwareness, messageSaved, messageChunk, messageComments, MAX_FRAME_BYTES, chunkFrame, createChunkReader, ChunkLimitError, type ChunkReader, CLOSE } from './providers/room.js';
30
+ export { messageSync, messageAwareness, messageAuth, messageQueryAwareness, messageSaved, messageChunk, messageComments, MAX_FRAME_BYTES, chunkFrame, createChunkReader, ChunkError, type ChunkReader, CLOSE } from './providers/room.js';
31
31
  export { messageYjsSyncStep1, messageYjsSyncStep2, messageYjsUpdate, type SyncProtocol } from './protocols/sync.js';
32
32
  export { messagePermissionDenied, messageReadOnly, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
33
33
  export { commentsSubscribe, commentsSnapshot, commentsChange, writeCommentsSubscribe, writeCommentsSnapshot, writeCommentsChange, readCommentsMessage, type CommentChange, type CommentMessage, type CommentSnapshot, type CommentThread, type ThreadComment } from './protocols/comments.js';
34
34
  export { applyAwarenessUpdate, encodeAwarenessUpdate, readAwarenessEntries, writeAwarenessEntries, type AwarenessEntry } from './protocols/awareness.js';
35
35
  export { createDecoder, readVarUint, readVarUint8Array, type Decoder } from 'lib0-v14/decoding';
36
36
  export { writeVarUint8Array, type Encoder } from 'lib0-v14/encoding';
37
- export { assertAdmission, assertSchema, assertUsableDoc, checkSchema, inspectAdmission, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError, UndecodableUpdateError, UnsupportedDocError, type AdmissionResult, type AdmissionVerdict, type SchemaProblem } from './admission.js';
37
+ export { assertAdmission, assertSchema, checkSchema, inspectAdmission, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError, UndecodableUpdateError, type AdmissionResult, type AdmissionVerdict, type SchemaProblem } from './admission.js';
38
38
  import type { ProviderStack } from './providers/index.js';
39
39
  export declare const IndexeddbPersistence: ProviderStack['IndexeddbPersistence'];
40
40
  export declare const WebsocketProvider: ProviderStack['WebsocketProvider'];
@@ -30,7 +30,7 @@ export { bindCrdt } from './index.js';
30
30
  export { SCHEMA_VERSION, META_KEY } from './edytor-doc.js';
31
31
  export { GENERATION, generationWord, frame, PROTOCOL_VERSION, GENERATION_RECORD, GenerationMismatchError, readProtocolVersion } from './protocols/envelope.js';
32
32
  // ── Message types, acknowledgements and chunks ─────────────────────────
33
- export { messageSync, messageAwareness, messageAuth, messageQueryAwareness, messageSaved, messageChunk, messageComments, MAX_FRAME_BYTES, chunkFrame, createChunkReader, ChunkLimitError, CLOSE } from './providers/room.js';
33
+ export { messageSync, messageAwareness, messageAuth, messageQueryAwareness, messageSaved, messageChunk, messageComments, MAX_FRAME_BYTES, chunkFrame, createChunkReader, ChunkError, CLOSE } from './providers/room.js';
34
34
  export { messageYjsSyncStep1, messageYjsSyncStep2, messageYjsUpdate } from './protocols/sync.js';
35
35
  export { messagePermissionDenied, messageReadOnly, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
36
36
  export { commentsSubscribe, commentsSnapshot, commentsChange, writeCommentsSubscribe, writeCommentsSnapshot, writeCommentsChange, readCommentsMessage } from './protocols/comments.js';
@@ -46,7 +46,7 @@ export { writeVarUint8Array } from 'lib0-v14/encoding';
46
46
  // the matrix and the refusal-preserves-data contract). The errors they
47
47
  // throw are also exported from `edytor` and `edytor/crdt/edytor`, where a
48
48
  // `loadDocument` caller catches them.
49
- export { assertAdmission, assertSchema, assertUsableDoc, checkSchema, inspectAdmission, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError, UndecodableUpdateError, UnsupportedDocError } from './admission.js';
49
+ export { assertAdmission, assertSchema, checkSchema, inspectAdmission, isInitialized, registryEmpty, schemaVersion, SchemaMismatchError, UndecodableUpdateError } from './admission.js';
50
50
  // ── Raw providers ──────────────────────────────────────────────────────
51
51
  //
52
52
  // The classes `createIndexeddbSync`/`createWebsocketSync` construct, bound
@@ -280,7 +280,7 @@ export declare const bindProviders: (Y: EngineApi) => {
280
280
  off<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: WebsocketProviderEvents[NAME]): void;
281
281
  };
282
282
  };
283
- watchComments: (server: string, roomName: string, listener: (message: import("../protocol.js").CommentMessage) => void) => (() => void);
283
+ watchComments: (server: string | null, roomName: string, listener: (message: import("../protocol.js").CommentMessage) => void) => (() => void);
284
284
  storeState: (idbPersistence: {
285
285
  db: IDBDatabase | null;
286
286
  name: string;
@@ -69,14 +69,15 @@ export declare const MAX_FRAME_BYTES: number;
69
69
  * receiver applies the reassembled frame only once `end` arrives.
70
70
  */
71
71
  export declare const chunkFrame: (whole: Uint8Array, maxFrameBytes?: number) => Uint8Array[];
72
- /** A chunk sequence announces a frame larger than its reader takes ({@link createChunkReader}). */
73
- export declare class ChunkLimitError extends Error {
74
- readonly total: number;
75
- readonly limit: number;
76
- constructor(total: number, limit: number);
77
- }
78
- /** A chunk part or end with no sequence started (one lost, or never sent). */
79
- export declare class ChunkSequenceError extends Error {
72
+ /**
73
+ * A chunk sequence its reader refuses ({@link createChunkReader}): one
74
+ * announcing a frame larger than the reader takes (`total` over `limit`),
75
+ * or a part or end with no sequence started (one lost, or never sent).
76
+ */
77
+ export declare class ChunkError extends Error {
78
+ readonly total?: number | undefined;
79
+ readonly limit?: number | undefined;
80
+ constructor(total?: number | undefined, limit?: number | undefined);
80
81
  }
81
82
  /** A chunk reader ({@link createChunkReader}): feed it chunk bodies; `buffered` is what it holds. */
82
83
  export type ChunkReader = {
@@ -89,7 +90,7 @@ export type ChunkReader = {
89
90
  * each chunk frame's body (after the message type); it returns the whole
90
91
  * frame on `end`, `null` before. An out-of-order or oversized sequence
91
92
  * throws and resets; a sequence announcing more than `maxBytes` throws
92
- * {@link ChunkLimitError} at its start, before anything is buffered. A
93
+ * {@link ChunkError} at its start, before anything is buffered. A
93
94
  * sequence is assembled into ONE buffer of its announced size, allocated
94
95
  * at its start (`buffered`), never into parts copied at its end.
95
96
  * `admit(total)` is asked at each start, before that allocation: it may
@@ -92,26 +92,29 @@ export const chunkFrame = (whole, maxFrameBytes = MAX_FRAME_BYTES) => {
92
92
  frames.push(frame(messageChunk, (e) => encoding.writeVarUint(e, chunkEnd)));
93
93
  return frames;
94
94
  };
95
- /** A chunk sequence announces a frame larger than its reader takes ({@link createChunkReader}). */
96
- export class ChunkLimitError extends Error {
95
+ /**
96
+ * A chunk sequence its reader refuses ({@link createChunkReader}): one
97
+ * announcing a frame larger than the reader takes (`total` over `limit`),
98
+ * or a part or end with no sequence started (one lost, or never sent).
99
+ */
100
+ export class ChunkError extends Error {
97
101
  total;
98
102
  limit;
99
103
  constructor(total, limit) {
100
- super(`chunked frame of ${total} bytes exceeds ${limit}`);
104
+ super(limit === undefined
105
+ ? 'chunk without a start'
106
+ : `chunked frame of ${total} bytes exceeds ${limit}`);
101
107
  this.total = total;
102
108
  this.limit = limit;
103
- this.name = 'ChunkLimitError';
109
+ this.name = 'ChunkError';
104
110
  }
105
111
  }
106
- /** A chunk part or end with no sequence started (one lost, or never sent). */
107
- export class ChunkSequenceError extends Error {
108
- }
109
112
  /**
110
113
  * The receiving half of {@link chunkFrame}, one per connection: feed it
111
114
  * each chunk frame's body (after the message type); it returns the whole
112
115
  * frame on `end`, `null` before. An out-of-order or oversized sequence
113
116
  * throws and resets; a sequence announcing more than `maxBytes` throws
114
- * {@link ChunkLimitError} at its start, before anything is buffered. A
117
+ * {@link ChunkError} at its start, before anything is buffered. A
115
118
  * sequence is assembled into ONE buffer of its announced size, allocated
116
119
  * at its start (`buffered`), never into parts copied at its end.
117
120
  * `admit(total)` is asked at each start, before that allocation: it may
@@ -136,14 +139,14 @@ export const createChunkReader = (maxBytes = Infinity, admit = () => true) => {
136
139
  reset();
137
140
  const announced = decoding.readVarUint(decoder);
138
141
  if (announced > maxBytes)
139
- throw new ChunkLimitError(announced, maxBytes);
142
+ throw new ChunkError(announced, maxBytes);
140
143
  whole = admit(announced) ? new Uint8Array(announced) : null;
141
144
  total = announced;
142
145
  open = true;
143
146
  return null;
144
147
  }
145
148
  if (!open)
146
- throw new ChunkSequenceError(`chunk ${kind} without a start`);
149
+ throw new ChunkError();
147
150
  if (kind === chunkPart) {
148
151
  const bytes = decoding.readVarUint8Array(decoder);
149
152
  if (received + bytes.length > total)
@@ -228,5 +228,5 @@ export declare const bindWebsocketProvider: (Y: EngineApi) => {
228
228
  off<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: WebsocketProviderEvents[NAME]): void;
229
229
  };
230
230
  };
231
- watchComments: (server: string, roomName: string, listener: (message: CommentMessage) => void) => (() => void);
231
+ watchComments: (server: string | null, roomName: string, listener: (message: CommentMessage) => void) => (() => void);
232
232
  };