edytor 4.0.0 → 5.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 (147) hide show
  1. package/README.md +2 -2
  2. package/dist/block/block.svelte.js +6 -21
  3. package/dist/block/inlineBlock.svelte.js +4 -6
  4. package/dist/clipboard/moveText.js +6 -8
  5. package/dist/cloudflare/DocumentRoom.d.ts +10 -3
  6. package/dist/cloudflare/index.d.ts +1 -1
  7. package/dist/cloudflare/room/access.d.ts +8 -3
  8. package/dist/cloudflare/room/access.js +44 -20
  9. package/dist/cloudflare/room/admission.js +28 -5
  10. package/dist/cloudflare/room/comments.js +28 -1
  11. package/dist/cloudflare/room/context.d.ts +115 -106
  12. package/dist/cloudflare/room/context.js +10 -3
  13. package/dist/cloudflare/room/forged.d.ts +14 -0
  14. package/dist/cloudflare/room/forged.js +30 -2
  15. package/dist/cloudflare/room/frames.d.ts +4 -0
  16. package/dist/cloudflare/room/frames.js +5 -1
  17. package/dist/cloudflare/room/purge.js +2 -1
  18. package/dist/cloudflare/room/replicas.d.ts +4 -2
  19. package/dist/cloudflare/room/replicas.js +8 -3
  20. package/dist/cloudflare/room/suggest.d.ts +7 -0
  21. package/dist/cloudflare/room/suggest.js +143 -0
  22. package/dist/cloudflare/routeDocumentSocket.d.ts +10 -1
  23. package/dist/cloudflare/routeDocumentSocket.js +5 -3
  24. package/dist/components/Content.svelte +9 -1
  25. package/dist/crdt/anchors.js +3 -2
  26. package/dist/crdt/attribution/attribution.d.ts +3 -0
  27. package/dist/crdt/attribution/attribution.js +3 -3
  28. package/dist/crdt/doc/capability.js +9 -13
  29. package/dist/crdt/doc/funnel.d.ts +1 -1
  30. package/dist/crdt/doc/funnel.js +5 -2
  31. package/dist/crdt/doc/gate.d.ts +1 -1
  32. package/dist/crdt/doc/history.d.ts +6 -0
  33. package/dist/crdt/doc/history.js +77 -56
  34. package/dist/crdt/doc/layout.js +5 -5
  35. package/dist/crdt/doc/meta.js +6 -7
  36. package/dist/crdt/doc/reads.d.ts +2 -2
  37. package/dist/crdt/doc/reads.js +18 -28
  38. package/dist/crdt/doc/steps.js +4 -4
  39. package/dist/crdt/doc/suggest.d.ts +167 -0
  40. package/dist/crdt/doc/suggest.js +579 -0
  41. package/dist/crdt/document.d.ts +10 -1
  42. package/dist/crdt/document.js +19 -11
  43. package/dist/crdt/edytor-doc.d.ts +355 -333
  44. package/dist/crdt/edytor-doc.js +125 -82
  45. package/dist/crdt/engine-api.d.ts +8 -2
  46. package/dist/crdt/engine.d.ts +2 -1
  47. package/dist/crdt/engine.js +3 -1
  48. package/dist/crdt/flow.d.ts +1 -1
  49. package/dist/crdt/flow.js +4 -10
  50. package/dist/crdt/index.d.ts +111 -105
  51. package/dist/crdt/index.js +3 -0
  52. package/dist/crdt/operations.d.ts +12 -3
  53. package/dist/crdt/parts.d.ts +43 -0
  54. package/dist/crdt/parts.js +44 -0
  55. package/dist/crdt/placement/display.d.ts +1 -1
  56. package/dist/crdt/placement/display.js +3 -3
  57. package/dist/crdt/placement/keys.d.ts +5 -0
  58. package/dist/crdt/placement/keys.js +5 -0
  59. package/dist/crdt/placement/resolve.js +2 -1
  60. package/dist/crdt/protocol.d.ts +1 -1
  61. package/dist/crdt/protocol.js +1 -1
  62. package/dist/crdt/protocols/auth.d.ts +11 -1
  63. package/dist/crdt/protocols/auth.js +17 -1
  64. package/dist/crdt/protocols/comments.d.ts +16 -1
  65. package/dist/crdt/protocols/comments.js +9 -1
  66. package/dist/crdt/providers/index.d.ts +6 -4
  67. package/dist/crdt/providers/index.js +3 -1
  68. package/dist/crdt/providers/websocket.d.ts +6 -4
  69. package/dist/crdt/providers/websocket.js +9 -4
  70. package/dist/crdt/purge.d.ts +7 -1
  71. package/dist/crdt/purge.js +32 -2
  72. package/dist/crdt/restore.d.ts +2 -1
  73. package/dist/crdt/restore.js +9 -0
  74. package/dist/crdt/schema.d.ts +9 -1
  75. package/dist/crdt/schema.js +13 -3
  76. package/dist/crdt/structs.d.ts +2 -0
  77. package/dist/crdt/structs.js +2 -0
  78. package/dist/crdt/text/index/claims.js +1 -23
  79. package/dist/crdt/text/index/layout.d.ts +2 -4
  80. package/dist/crdt/text/index/layout.js +9 -22
  81. package/dist/crdt/text/index/placement.js +21 -24
  82. package/dist/crdt/text/index/shared.js +17 -14
  83. package/dist/crdt/text/model.d.ts +10 -0
  84. package/dist/crdt/text/model.js +8 -1
  85. package/dist/crdt/text/runs.d.ts +34 -30
  86. package/dist/crdt/vendor/yjs/UPSTREAM.md +83 -0
  87. package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
  88. package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +6 -3
  89. package/dist/crdt/vendor/yjs/dts/ynode.d.ts +13 -2
  90. package/dist/crdt/vendor/yjs/src/index.js +1 -1
  91. package/dist/crdt/vendor/yjs/src/structs/Item.js +44 -5
  92. package/dist/crdt/vendor/yjs/src/ynode.js +29 -7
  93. package/dist/edytor.svelte.d.ts +1 -1
  94. package/dist/edytor.svelte.js +100 -75
  95. package/dist/events/beforeInputCommands.d.ts +2 -2
  96. package/dist/events/nativeInteractiveControl.d.ts +11 -1
  97. package/dist/events/nativeInteractiveControl.js +41 -1
  98. package/dist/events/onBeforeInput.js +3 -3
  99. package/dist/events/onFocus.js +9 -11
  100. package/dist/export/forms.d.ts +25 -25
  101. package/dist/index.d.ts +4 -2
  102. package/dist/index.js +1 -1
  103. package/dist/labels.d.ts +8 -0
  104. package/dist/labels.js +6 -1
  105. package/dist/plugins/comments/CommentsController.svelte.d.ts +5 -1
  106. package/dist/plugins/comments/CommentsController.svelte.js +14 -4
  107. package/dist/plugins/find/search.js +2 -2
  108. package/dist/plugins/index.d.ts +1 -0
  109. package/dist/plugins/index.js +1 -0
  110. package/dist/plugins/suggestions/SuggestionBars.svelte +40 -23
  111. package/dist/plugins/suggestions/SuggestionBars.svelte.d.ts +3 -1
  112. package/dist/plugins/suggestions/SuggestionRuns.svelte +77 -0
  113. package/dist/plugins/suggestions/SuggestionRuns.svelte.d.ts +9 -0
  114. package/dist/plugins/suggestions/shared.svelte.d.ts +58 -0
  115. package/dist/plugins/suggestions/shared.svelte.js +421 -0
  116. package/dist/plugins/suggestions/suggestionsPlugin.d.ts +15 -4
  117. package/dist/selection/domSelection.d.ts +2 -0
  118. package/dist/selection/domSelection.js +6 -2
  119. package/dist/selection/pointer.svelte.js +75 -48
  120. package/dist/selection/replaceSelection.js +2 -6
  121. package/dist/selection/selection.svelte.d.ts +3 -3
  122. package/dist/selection/selection.svelte.js +39 -32
  123. package/dist/selection/selection.utils.d.ts +14 -0
  124. package/dist/selection/selection.utils.js +28 -3
  125. package/dist/session/commands.js +21 -11
  126. package/dist/session/composition.svelte.d.ts +5 -3
  127. package/dist/session/composition.svelte.js +21 -17
  128. package/dist/session/handles.d.ts +4 -17
  129. package/dist/session/handles.js +11 -37
  130. package/dist/session/navigation.js +6 -9
  131. package/dist/session/selection.d.ts +11 -5
  132. package/dist/session/selection.js +14 -48
  133. package/dist/session/suggestions.svelte.d.ts +38 -9
  134. package/dist/session/suggestions.svelte.js +37 -18
  135. package/dist/session/virtual.d.ts +1 -1
  136. package/dist/surface/attributes.d.ts +5 -0
  137. package/dist/surface/attributes.js +2 -2
  138. package/dist/surface/cells.d.ts +2 -26
  139. package/dist/surface/cells.js +2 -33
  140. package/dist/surface/observer.svelte.d.ts +6 -1
  141. package/dist/surface/observer.svelte.js +128 -81
  142. package/dist/surface/pin.svelte.d.ts +9 -9
  143. package/dist/surface/pin.svelte.js +15 -22
  144. package/dist/surface/projector.svelte.js +8 -14
  145. package/dist/text/text.svelte.js +14 -19
  146. package/dist/themes/notion.css +29 -0
  147. package/package.json +3 -1
@@ -46,6 +46,7 @@
46
46
  */
47
47
  export { EdytorDocument, createDocument, loadDocument, attachDocument, SemanticConflictError, DocumentNotReadyError, DocumentDestroyedError, DEFAULT_READINESS_BOUND, type DocumentActor, type DocumentOptions, type DocumentReadiness, type DocumentSemanticsConfig, type CreateDocumentOptions, type LoadDocumentOptions } from './document.js';
48
48
  export { defaultSemantics, richTextSemantics, codeSemantics, imageSemantics, mediaKinds, mediaSemantics, layoutSemantics, pageKinds, pageSemantics, tocKinds, tocSemantics, tableKinds, tableSemantics, equationKinds, equationSemantics, richTextKinds, codeKinds, imageKinds, layoutKinds, richTextMarks, commentMarks, facadeConfigOf, semanticsOf, mergeSemantics, semanticsDigest, semanticsMismatch, type KindSemantics, type KindRecord, type MergedSemantics } from './semantics.js';
49
+ export { adoptSharedSuggestions, type SuggestedChange } from './doc/suggest.js';
49
50
  export { tableBlock, type TableBlockOptions } from './tables.js';
50
51
  export { markName, type MarkEdge } from './text/marks.js';
51
52
  export type { JSONDoc, JSONBlock, JSONText, JSONInlineBlock, SerializableContent } from '../utils/json.js';
@@ -75,7 +76,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
75
76
  Awareness: typeof _Awareness;
76
77
  doc: {
77
78
  SCHEMA: {
78
- readonly version: 10;
79
+ readonly version: 11;
79
80
  readonly name: "edytor-doc";
80
81
  readonly roots: {
81
82
  readonly registry: "blocks";
@@ -86,7 +87,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
86
87
  readonly schema: "schema";
87
88
  };
88
89
  };
89
- SCHEMA_VERSION: 10;
90
+ SCHEMA_VERSION: 11;
90
91
  SCHEMA_NAME: "edytor-doc";
91
92
  META_KEY: "meta";
92
93
  init: (doc: import("./engine-api.js").EngineDoc, opts?: {
@@ -102,48 +103,36 @@ export declare const bindCrdt: (Y: EngineApi) => {
102
103
  assertSchema: (doc: import("./engine-api.js").EngineDoc, docName?: string) => void;
103
104
  SchemaMismatchError: typeof import("./edytor-doc.js").SchemaMismatchError;
104
105
  create: (doc: import("./engine-api.js").EngineDoc, config?: import("./edytor-doc.js").EdytorDocConfig) => {
105
- prepare: {
106
- insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => import("./edytor-doc.js").Prepared;
107
- deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
108
- replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
109
- insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[]) => import("./edytor-doc.js").Prepared;
110
- moveBlocks: (ids: readonly import("./index.js").BlockId[], dest: import("./index.js").Destination) => import("./edytor-doc.js").Prepared;
111
- nestBlock: (id: import("./index.js").BlockId, parent: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
112
- unNestBlock: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
113
- unNestBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
114
- liftOut: (id: import("./index.js").BlockId, kind: string, { keep, after }?: {
115
- keep?: boolean;
116
- after?: readonly import("./index.js").BlockSpec[];
117
- }) => import("./edytor-doc.js").Prepared;
118
- placeBeside: (ids: readonly import("./index.js").BlockId[], target: import("./index.js").BlockId, side: "left" | "right", kind?: string) => import("./edytor-doc.js").Prepared;
119
- wrapInLayout: (ids: readonly import("./index.js").BlockId[], kind?: string, columns?: number) => import("./edytor-doc.js").Prepared;
120
- splitBlock: (id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail?: import("./placement/model.js").SplitTail) => import("./edytor-doc.js").Prepared;
121
- mergeBlocks: (fromId: import("./index.js").BlockId, intoId: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
122
- mergeBackward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
123
- mergeForward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
124
- deleteBlock: (id: import("./index.js").BlockId, opts?: {
125
- keepChildren?: boolean;
126
- }) => import("./edytor-doc.js").Prepared;
127
- setBlock: (id: import("./index.js").BlockId, value: {
128
- type?: string;
129
- data?: Record<string, unknown>;
130
- content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
131
- children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
132
- }) => import("./edytor-doc.js").Prepared;
133
- setBlockType: (id: import("./index.js").BlockId, type: string) => import("./edytor-doc.js").Prepared;
134
- patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").Prepared;
135
- duplicateBlock: (id: import("./index.js").BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => import("./edytor-doc.js").Prepared;
136
- insertText: (id: import("./index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
137
- deleteText: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
138
- formatRange: (id: import("./index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
139
- clearMarks: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
140
- insertInline: (id: import("./index.js").BlockId, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").Prepared;
141
- removeInline: (id: import("./index.js").BlockId, inlineId: string) => import("./edytor-doc.js").Prepared;
142
- deleteBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
143
- };
144
- apply: (p: import("./edytor-doc.js").Prepared) => import("./edytor-doc.js").OpResult;
145
- compose: (...parts: import("./edytor-doc.js").Prepared[]) => import("./edytor-doc.js").Prepared;
146
- transact: <R>(fn: () => R, origin?: unknown) => R;
106
+ init: (opts?: Parameters<(doc: import("./engine-api.js").EngineDoc, opts?: {
107
+ content?: import("./index.js").BlockSpec[];
108
+ defaultType?: string;
109
+ }) => void>[1]) => void;
110
+ seed: (value: import("./index.js").JSONBlock[], data?: import("./doc/types.js").JsonObj) => void;
111
+ isInitialized: () => boolean;
112
+ schemaVersion: () => number | undefined;
113
+ checkSchema: () => import("./edytor-doc.js").SchemaProblem | null;
114
+ assertSchema: () => void;
115
+ dispose: () => void;
116
+ createUndoManager: (options?: import("./doc/history.js").HistoryOptions) => import("./doc/history.js").UndoManager;
117
+ part: import("./doc/suggest.js").SuggestContext;
118
+ childSlots: (parent: import("./index.js").BlockId | null) => import("./placement/model.js").ChildSlot[];
119
+ slotOf: (id: string) => {
120
+ parent: import("./index.js").BlockId | null;
121
+ rank: string;
122
+ } | null;
123
+ crdtId: (id: string) => string | null;
124
+ resolveBlock: (id: string) => import("./engine-api.js").EngineNode | null;
125
+ followUndo: (anchor: import("./edytor-doc.js").DocAnchor) => import("./edytor-doc.js").DocAnchor;
126
+ rolesChanged: (place?: boolean) => void;
127
+ defaultChild: (id: string | null) => string;
128
+ contentJSON: (id: string) => ({
129
+ text: string;
130
+ marks?: Record<string, unknown>;
131
+ } | {
132
+ id?: string;
133
+ type: string;
134
+ data?: unknown;
135
+ })[];
147
136
  model: {
148
137
  REGISTRY_KEY: string;
149
138
  registryOf: (doc: import("./engine-api.js").EngineDoc) => import("./engine-api.js").EngineNode;
@@ -213,64 +202,94 @@ export declare const bindCrdt: (Y: EngineApi) => {
213
202
  };
214
203
  };
215
204
  runsView: import("./text/runs.js").RunView;
205
+ api: object;
206
+ } & {
207
+ prepare: {
208
+ insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => import("./edytor-doc.js").Prepared;
209
+ deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
210
+ replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
211
+ nestBlock: (id: import("./index.js").BlockId, parent: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
212
+ deleteBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
213
+ insertText: (id: import("./index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
214
+ deleteText: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
215
+ formatRange: (id: import("./index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
216
+ clearMarks: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
217
+ insertInline: (id: import("./index.js").BlockId, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").Prepared;
218
+ removeInline: (id: import("./index.js").BlockId, inlineId: string) => import("./edytor-doc.js").Prepared;
219
+ setBlockType: (id: import("./index.js").BlockId, type: string) => import("./edytor-doc.js").Prepared;
220
+ patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").Prepared;
221
+ setBlock: (id: import("./index.js").BlockId, value: {
222
+ type?: string;
223
+ data?: Record<string, unknown>;
224
+ content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
225
+ children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
226
+ }) => import("./edytor-doc.js").Prepared;
227
+ deleteBlock: (id: import("./index.js").BlockId, opts?: {
228
+ keepChildren?: boolean;
229
+ }) => import("./edytor-doc.js").Prepared;
230
+ splitBlock: (id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail?: import("./placement/model.js").SplitTail) => import("./edytor-doc.js").Prepared;
231
+ mergeBlocks: (fromId: import("./index.js").BlockId, intoId: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
232
+ mergeBackward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
233
+ mergeForward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
234
+ placeBeside: (ids: readonly import("./index.js").BlockId[], target: import("./index.js").BlockId, side: "left" | "right", kind?: string) => import("./edytor-doc.js").Prepared;
235
+ wrapInLayout: (ids: readonly import("./index.js").BlockId[], kind?: string, columns?: number) => import("./edytor-doc.js").Prepared;
236
+ insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[]) => import("./edytor-doc.js").Prepared;
237
+ moveBlocks: (ids: readonly import("./index.js").BlockId[], dest: import("./index.js").Destination) => import("./edytor-doc.js").Prepared;
238
+ unNestBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
239
+ unNestBlock: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
240
+ liftOut: (id: import("./index.js").BlockId, kind: string, { keep, after }?: {
241
+ keep?: boolean;
242
+ after?: readonly import("./index.js").BlockSpec[];
243
+ }) => import("./edytor-doc.js").Prepared;
244
+ duplicateBlock: (id: import("./index.js").BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => import("./edytor-doc.js").Prepared;
245
+ };
246
+ apply: (p: import("./edytor-doc.js").Prepared, quiet?: boolean) => import("./edytor-doc.js").OpResult;
247
+ compose: (...parts: import("./edytor-doc.js").Prepared[]) => import("./edytor-doc.js").Prepared;
248
+ transact: <R>(fn: () => R, origin?: unknown) => R;
216
249
  version: number;
217
250
  insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => import("./edytor-doc.js").OpResult;
218
251
  deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
219
252
  replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
220
- insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[]) => import("./edytor-doc.js").OpResult;
221
- moveBlocks: (ids: readonly string[], dest: import("./index.js").Destination) => import("./edytor-doc.js").OpResult;
222
253
  nestBlock: (id: string, parent: string) => import("./edytor-doc.js").OpResult;
223
- unNestBlock: (id: string) => import("./edytor-doc.js").OpResult;
224
- unNestBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
225
- liftOut: (id: string, kind: string, args_2?: {
226
- keep?: boolean;
227
- after?: readonly import("./index.js").BlockSpec[];
228
- } | undefined) => import("./edytor-doc.js").OpResult;
229
- placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => import("./edytor-doc.js").OpResult;
230
- wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("./edytor-doc.js").OpResult;
231
- splitBlock: (id: string, offset: number, newId: string, tail?: import("./placement/model.js").SplitTail | undefined) => import("./edytor-doc.js").OpResult;
232
- mergeBlocks: (fromId: string, intoId: string) => import("./edytor-doc.js").OpResult;
233
- mergeBackward: (id: string) => import("./edytor-doc.js").OpResult;
234
- mergeForward: (id: string) => import("./edytor-doc.js").OpResult;
235
- deleteBlock: (id: string, opts?: {
236
- keepChildren?: boolean;
237
- } | undefined) => import("./edytor-doc.js").OpResult;
254
+ deleteBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
255
+ insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => import("./edytor-doc.js").OpResult;
256
+ deleteText: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
257
+ formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").OpResult;
258
+ clearMarks: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
259
+ insertInline: (id: string, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").OpResult;
260
+ removeInline: (id: string, inlineId: string) => import("./edytor-doc.js").OpResult;
261
+ setBlockType: (id: string, type: string) => import("./edytor-doc.js").OpResult;
262
+ patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").OpResult;
238
263
  setBlock: (id: string, value: {
239
264
  type?: string;
240
265
  data?: Record<string, unknown>;
241
266
  content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
242
267
  children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
243
268
  }) => import("./edytor-doc.js").OpResult;
244
- setBlockType: (id: string, type: string) => import("./edytor-doc.js").OpResult;
245
- patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").OpResult;
269
+ deleteBlock: (id: string, opts?: {
270
+ keepChildren?: boolean;
271
+ } | undefined) => import("./edytor-doc.js").OpResult;
272
+ splitBlock: (id: string, offset: number, newId: string, tail?: import("./placement/model.js").SplitTail | undefined) => import("./edytor-doc.js").OpResult;
273
+ mergeBlocks: (fromId: string, intoId: string) => import("./edytor-doc.js").OpResult;
274
+ mergeBackward: (id: string) => import("./edytor-doc.js").OpResult;
275
+ mergeForward: (id: string) => import("./edytor-doc.js").OpResult;
276
+ placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => import("./edytor-doc.js").OpResult;
277
+ wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("./edytor-doc.js").OpResult;
278
+ insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").JSONBlock | import("./index.js").BlockSpec)[]) => import("./edytor-doc.js").OpResult;
279
+ moveBlocks: (ids: readonly string[], dest: import("./index.js").Destination) => import("./edytor-doc.js").OpResult;
280
+ unNestBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
281
+ unNestBlock: (id: string) => import("./edytor-doc.js").OpResult;
282
+ liftOut: (id: string, kind: string, args_2?: {
283
+ keep?: boolean;
284
+ after?: readonly import("./index.js").BlockSpec[];
285
+ } | undefined) => import("./edytor-doc.js").OpResult;
246
286
  duplicateBlock: (id: string, freshId?: ((oldId: string, kind: "block" | "inline") => string) | undefined) => import("./edytor-doc.js").OpResult;
247
- insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => import("./edytor-doc.js").OpResult;
248
- deleteText: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
249
- formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").OpResult;
250
- clearMarks: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
251
- insertInline: (id: string, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").OpResult;
252
- removeInline: (id: string, inlineId: string) => import("./edytor-doc.js").OpResult;
253
- deleteBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
254
- init: (opts?: Parameters<(doc: import("./engine-api.js").EngineDoc, opts?: {
255
- content?: import("./index.js").BlockSpec[];
256
- defaultType?: string;
257
- }) => void>[1]) => void;
258
- seed: (value: import("./index.js").JSONBlock[], data?: import("./doc/types.js").JsonObj) => void;
259
- isInitialized: () => boolean;
260
- schemaVersion: () => number | undefined;
261
- checkSchema: () => import("./edytor-doc.js").SchemaProblem | null;
262
- assertSchema: () => void;
263
- dispose: () => void;
264
- createUndoManager: (options?: import("./doc/history.js").HistoryOptions) => import("./doc/history.js").UndoManager;
265
287
  project: () => import("./index.js").ProjectedDoc;
266
- toJSON: () => import("./index.js").JSONDoc;
288
+ toJSON: (options?: {
289
+ suggestions?: boolean;
290
+ } | undefined) => import("./index.js").JSONDoc;
267
291
  blockJSON: (id: string) => import("./index.js").JSONBlock;
268
292
  childrenIds: (id: string | null) => string[];
269
- childSlots: (parent: import("./index.js").BlockId | null) => import("./placement/model.js").ChildSlot[];
270
- slotOf: (id: string) => {
271
- parent: import("./index.js").BlockId | null;
272
- rank: string;
273
- } | null;
274
293
  positionOf: (id: string) => import("./index.js").Destination | null;
275
294
  pathOf: (id: string) => number[] | null;
276
295
  parentOf: (id: string) => string | null;
@@ -288,8 +307,6 @@ export declare const bindCrdt: (Y: EngineApi) => {
288
307
  ids: (path: readonly string[]) => string[];
289
308
  } | null;
290
309
  blockAttribution: (id: string) => import("./index.js").BlockAttribution | undefined;
291
- crdtId: (id: string) => string | null;
292
- resolveBlock: (id: string) => import("./engine-api.js").EngineNode | null;
293
310
  displayLength: (id: string) => number;
294
311
  contentItems: (id: string) => import("./index.js").ContentItem[];
295
312
  hasBlock: (id: string) => boolean;
@@ -303,8 +320,6 @@ export declare const bindCrdt: (Y: EngineApi) => {
303
320
  blockId: import("./index.js").BlockId;
304
321
  offset: number;
305
322
  } | null;
306
- followUndo: (anchor: import("./edytor-doc.js").DocAnchor) => import("./edytor-doc.js").DocAnchor;
307
- rolesChanged: () => void;
308
323
  isVoid: (id: string) => boolean;
309
324
  isIsland: (id: string) => boolean;
310
325
  isLines: (id: string) => boolean;
@@ -336,20 +351,11 @@ export declare const bindCrdt: (Y: EngineApi) => {
336
351
  parent: string | null;
337
352
  levels: string[];
338
353
  };
339
- defaultChild: (id: string | null) => string;
340
354
  runs: (id: string) => readonly import("./index.js").ContentRun[];
341
- contentJSON: (id: string) => ({
342
- text: string;
343
- marks?: Record<string, unknown>;
344
- } | {
345
- id?: string;
346
- type: string;
347
- data?: unknown;
348
- })[];
349
355
  onChange: (cb: (change: import("./edytor-doc.js").DocChange) => void) => (() => void);
350
356
  };
351
357
  newDoc: (opts?: ConstructorParameters<EngineApi["Doc"]>[0]) => YDoc;
352
- purge: (doc: import("./engine-api.js").EngineDoc, facade: {
358
+ purge: (doc: import("./engine-api.js").EngineDoc, facade: Partial<import("./doc/suggest.js").SuggestFacade> & {
353
359
  model: import("./placement/model.js").PlacementModel;
354
360
  text: import("./text/model.js").TextEngine;
355
361
  }, horizon: import("./purge.js").Horizon | null) => import("./purge.js").PurgeReport;
@@ -577,11 +583,11 @@ export declare const bindCrdt: (Y: EngineApi) => {
577
583
  destroy(): void;
578
584
  disconnect(): void;
579
585
  connect(): void;
580
- emit<N extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: N, args: Parameters<import("./protocol.js").WebsocketProviderEvents[N]>): void;
586
+ emit<N extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: N, args: Parameters<import("./protocol.js").WebsocketProviderEvents[N]>): void;
581
587
  _observers: Map<string, Set<any>>;
582
- on<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]): import("./protocol.js").WebsocketProviderEvents[NAME];
583
- once<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
- 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;
588
+ on<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): import("./protocol.js").WebsocketProviderEvents[NAME];
589
+ once<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
590
+ off<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
585
591
  };
586
592
  };
587
593
  watchComments: (server: string | null, roomName: string, listener: (message: import("./protocol.js").CommentMessage) => void) => (() => void);
@@ -61,6 +61,9 @@ export { EdytorDocument, createDocument, loadDocument, attachDocument, SemanticC
61
61
  // `blocks`), `mergeSemantics` merges configs field by field, and the digest
62
62
  // is the dev-time check a room logs mismatches with. Frozen.
63
63
  export { defaultSemantics, richTextSemantics, codeSemantics, imageSemantics, mediaKinds, mediaSemantics, layoutSemantics, pageKinds, pageSemantics, tocKinds, tocSemantics, tableKinds, tableSemantics, equationKinds, equationSemantics, richTextKinds, codeKinds, imageKinds, layoutKinds, richTextMarks, commentMarks, facadeConfigOf, semanticsOf, mergeSemantics, semanticsDigest, semanticsMismatch } from './semantics.js';
64
+ // A document read without a view leaves its pending shared suggestions out
65
+ // of `toJSON()` once they are built over it (`sugg.json.base`).
66
+ export { adoptSharedSuggestions } from './doc/suggest.js';
64
67
  // A new table as document JSON (`table.*`).
65
68
  export { tableBlock } from './tables.js';
66
69
  // Paired marks — a mark's edge as document semantics, the record a key names.
@@ -7,8 +7,10 @@
7
7
  * a view (`edytor.insertBlocks(…)`) they are dispatched. The facade a
8
8
  * document binds has more (the index, the engine hooks): those stay
9
9
  * internal. `DOCUMENT_OPERATIONS` lists the names, `DOCUMENT_WRITES` the
10
- * writes, checked against the interfaces here and against the facade in
11
- * `document.ts`. Worker-safe: types and two lists.
10
+ * writes, checked against the interfaces here; the document and the view
11
+ * read the names from the facade itself (its `api` and `prepare`, checked
12
+ * against `DocumentOperations` in `document.ts`). Worker-safe: types and
13
+ * two lists.
12
14
  */
13
15
  import type { BlockAttribution } from './attribution/block.js';
14
16
  import type { AnchorAffinity, DataTarget, DocAnchor, DocChange, JsonObj, OpResult, OrderPolicy, Prepared } from './doc/types.js';
@@ -63,7 +65,14 @@ export interface DocumentWrites {
63
65
  }
64
66
  /** The document's reads (transaction-aware where the reference says so). */
65
67
  export interface DocumentReads {
66
- toJSON(): JSONDoc;
68
+ /**
69
+ * The document as JSON, without its pending suggestions (their inserted
70
+ * text and blocks left out, their proposals not applied); with
71
+ * `suggestions: true`, as shown, pending suggestions included.
72
+ */
73
+ toJSON(options?: {
74
+ suggestions?: boolean;
75
+ }): JSONDoc;
67
76
  docData(): JsonObj;
68
77
  dataItemIds(target: DataTarget, path: readonly string[]): string[];
69
78
  project(): ProjectedDoc;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * A block's content as its parts: the text segments between inline atoms
3
+ * and the atoms, alternating, starting and ending with a segment (an empty
4
+ * content is one empty `start` segment), each at its display offsets (an
5
+ * atom counts 1). One pure function of the index's runs, memoized per runs
6
+ * array: the cells render it, the handles and the projection read it.
7
+ */
8
+ import type { ContentRun } from './text/runs.js';
9
+ export declare const START = "start";
10
+ type TextRun = Extract<ContentRun, {
11
+ kind: 'text';
12
+ }>;
13
+ /** The text between two inline atoms (or a content edge), keyed causally. */
14
+ export type Segment = {
15
+ readonly kind: 'text';
16
+ /** The id of the atom before this segment, or {@link START}. */
17
+ readonly key: string;
18
+ readonly text: string;
19
+ readonly runs: readonly TextRun[];
20
+ /** Its position among the block's segments. */
21
+ readonly segOrd: number;
22
+ readonly start: number;
23
+ readonly end: number;
24
+ };
25
+ export type AtomPart = {
26
+ readonly kind: 'inline';
27
+ readonly key: string;
28
+ readonly id: string;
29
+ readonly type: string;
30
+ readonly data: Readonly<Record<string, unknown>> | undefined;
31
+ readonly start: number;
32
+ readonly end: number;
33
+ };
34
+ export type Part = Segment | AtomPart;
35
+ export declare const partsOf: (runs: readonly ContentRun[]) => readonly Part[];
36
+ /** The text segment showing `offset`: the first ending at or after it (a seam belongs to the left text), else the last. */
37
+ export declare const segmentAt: <P extends {
38
+ kind: string;
39
+ end: number;
40
+ }>(parts: readonly P[], offset: number) => Extract<P, {
41
+ kind: "text";
42
+ }>;
43
+ export {};
@@ -0,0 +1,44 @@
1
+ export const START = 'start';
2
+ const memo = new WeakMap();
3
+ export const partsOf = (runs) => {
4
+ const hit = memo.get(runs);
5
+ if (hit)
6
+ return hit;
7
+ const parts = [];
8
+ let [key, segment, start, at, segOrd] = [START, [], 0, 0, 0];
9
+ const close = () => parts.push(Object.freeze({
10
+ kind: 'text',
11
+ key,
12
+ text: segment.map((run) => run.text).join(''),
13
+ runs: Object.freeze(segment),
14
+ segOrd: segOrd++,
15
+ start,
16
+ end: at
17
+ }));
18
+ for (const run of runs) {
19
+ if (run.kind === 'text') {
20
+ segment.push(run);
21
+ at += run.text.length;
22
+ continue;
23
+ }
24
+ close();
25
+ parts.push(Object.freeze({
26
+ kind: 'inline',
27
+ key: run.id,
28
+ id: run.id,
29
+ type: run.type,
30
+ data: run.data,
31
+ start: at,
32
+ end: ++at
33
+ }));
34
+ [key, segment, start] = [run.id, [], at];
35
+ }
36
+ close();
37
+ memo.set(runs, Object.freeze(parts));
38
+ return parts;
39
+ };
40
+ /** The text segment showing `offset`: the first ending at or after it (a seam belongs to the left text), else the last. */
41
+ export const segmentAt = (parts, offset) => {
42
+ const texts = parts.filter((part) => part.kind === 'text');
43
+ return texts.find((part) => offset <= part.end) ?? texts.at(-1);
44
+ };
@@ -68,7 +68,7 @@ export declare const displayParentOf: (own: DisplayOwnership, pl: ResolvedPlacem
68
68
  * promoted one ({@link displaySlotOf}).
69
69
  */
70
70
  export declare const childrenIndex: (placements: Map<BlockId, ResolvedPlacement>, own: DisplayOwnership) => Map<BlockId | null, ChildSlot[]>;
71
- /** The order of a children list: by rank, ties by id. */
71
+ /** The order of a children list: by rank, ties by id ({@link compareIds}). */
72
72
  export declare const bySlot: (a: {
73
73
  id: BlockId;
74
74
  rank: string;
@@ -7,7 +7,7 @@
7
7
  * (`order.split.text`: a split-born slot's key, fork patch YP22).
8
8
  */
9
9
  import { DEAD } from '../text/model.js';
10
- import { claimedRank, promotedRank } from './keys.js';
10
+ import { claimedRank, compareIds, promotedRank } from './keys.js';
11
11
  /**
12
12
  * THE liveness answer: `id` carries no live delete mark, owns
13
13
  * itself (`own.hidden` covers both: a delete-marked or unknown block owns
@@ -210,8 +210,8 @@ export const childrenIndex = (placements, own) => {
210
210
  bucket.sort(bySlot);
211
211
  return index;
212
212
  };
213
- /** The order of a children list: by rank, ties by id. */
214
- export const bySlot = (a, b) => (a.rank === b.rank ? a.id.localeCompare(b.id) : a.rank < b.rank ? -1 : 1);
213
+ /** The order of a children list: by rank, ties by id ({@link compareIds}). */
214
+ export const bySlot = (a, b) => (a.rank === b.rank ? compareIds(a.id, b.id) : a.rank < b.rank ? -1 : 1);
215
215
  export const documentOrder = (kids) => {
216
216
  const ids = [];
217
217
  const at = new Map();
@@ -22,6 +22,11 @@
22
22
  * above every key character;
23
23
  * - a table's cells show in column order ({@link cellKey}).
24
24
  */
25
+ /**
26
+ * The one order of two ids on a tie (a children list, the seam, the root's
27
+ * tail): their code units, the order every replica computes the same.
28
+ */
29
+ export declare const compareIds: (a: string, b: string) => number;
25
30
  /** Sorts below every key character: the separator of a promoted child's key. */
26
31
  export declare const PROMOTED = "!";
27
32
  /**
@@ -22,6 +22,11 @@
22
22
  * above every key character;
23
23
  * - a table's cells show in column order ({@link cellKey}).
24
24
  */
25
+ /**
26
+ * The one order of two ids on a tie (a children list, the seam, the root's
27
+ * tail): their code units, the order every replica computes the same.
28
+ */
29
+ export const compareIds = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
25
30
  /**
26
31
  * Order-preserving alphabet: charCode order equals numeric order (64
27
32
  * characters, all safe inside a JSON string).
@@ -3,6 +3,7 @@ import { baseIdOf, incarnationId, incarnationsOf, LIVE_WRITERS } from '../incarn
3
3
  import { attrItems, firstItem, itemOf } from '../structs.js';
4
4
  import { cmpStamp, isBlockSlot, isRecord, itemAt, sameUnit, stampOf, unitsOf } from './slots.js';
5
5
  import { DEAD } from '../text/model.js';
6
+ import { compareIds } from './keys.js';
6
7
  /** The stamp of a home slot's edge: below every record's. */
7
8
  const HOME = 0;
8
9
  /** The stamp of a block with no slot: below every edge (it shows at the root's tail). */
@@ -130,7 +131,7 @@ export const cycleThrough = (accepted, ownerOf, block, parent) => {
130
131
  return null;
131
132
  };
132
133
  /** The order of the blocks at the root's tail (rejected or slotless): by their edge's stamp, then id. */
133
- export const byTail = (a, b) => cmpStamp(a.stamp, b.stamp) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
134
+ export const byTail = (a, b) => cmpStamp(a.stamp, b.stamp) || compareIds(a.id, b.id);
134
135
  /**
135
136
  * The home slot of block `id` among the slots naming its registry id
136
137
  * (`slots`: every `{ b }` slot by `b`): the one its writer wrote
@@ -29,7 +29,7 @@ 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
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
- export { messagePermissionDenied, messageReadOnly, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
32
+ export { messageAccess, messagePermissionDenied, messageReadOnly, writeAccess, 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';
@@ -32,7 +32,7 @@ export { GENERATION, generationWord, frame, PROTOCOL_VERSION, GENERATION_RECORD,
32
32
  // ── Message types, acknowledgements and chunks ─────────────────────────
33
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
- export { messagePermissionDenied, messageReadOnly, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
35
+ export { messageAccess, messagePermissionDenied, messageReadOnly, writeAccess, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
36
36
  export { commentsSubscribe, commentsSnapshot, commentsChange, writeCommentsSubscribe, writeCommentsSnapshot, writeCommentsChange, readCommentsMessage } from './protocols/comments.js';
37
37
  export { applyAwarenessUpdate, encodeAwarenessUpdate, readAwarenessEntries, writeAwarenessEntries } from './protocols/awareness.js';
38
38
  // Minimal wire codec for frame bodies (lib0 — the codec the frames are
@@ -14,10 +14,20 @@ import * as decoding from 'lib0-v14/decoding';
14
14
  export declare const messagePermissionDenied = 0;
15
15
  /** The denial of a read-only socket's write: that socket still syncs (not a terminal refusal). */
16
16
  export declare const READ_ONLY_DENIAL = "read-only";
17
+ /** The denial of what a suggest-only socket wrote that is no suggestion's: it still syncs. */
18
+ export declare const SUGGEST_ONLY_DENIAL = "suggest-only";
17
19
  export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
18
20
  /** The socket may read but not write: sent when it joins, before any write is refused. */
19
21
  export declare const messageReadOnly = 1;
20
22
  export declare const writeReadOnly: (encoder: encoding.Encoder) => void;
23
+ /**
24
+ * The socket's access (the string that follows: `write`, `suggest` or
25
+ * `comment`), sent when it joins, before anything else it reads; a
26
+ * `comment` one's after its read-only notice (a `read` one has only the
27
+ * notice).
28
+ */
29
+ export declare const messageAccess = 2;
30
+ export declare const writeAccess: (encoder: encoding.Encoder, access: string) => void;
21
31
  export type PermissionDeniedHandler = (ydoc: unknown, reason: string) => void;
22
32
  /**
23
33
  * Decode one auth payload. Returns the auth message subtype so the caller
@@ -25,4 +35,4 @@ export type PermissionDeniedHandler = (ydoc: unknown, reason: string) => void;
25
35
  * do not speak is protocol skew, and this stack's contract is that skew is
26
36
  * reported, not silently dropped (same rule as unknown sync subtypes).
27
37
  */
28
- export declare const readAuthMessage: (decoder: decoding.Decoder, y: unknown, permissionDeniedHandler: PermissionDeniedHandler, readOnlyHandler?: (ydoc: unknown) => void) => number;
38
+ export declare const readAuthMessage: (decoder: decoding.Decoder, y: unknown, permissionDeniedHandler: PermissionDeniedHandler, readOnlyHandler?: (ydoc: unknown) => void, accessHandler?: (access: string) => void) => number;
@@ -14,6 +14,8 @@ import * as decoding from 'lib0-v14/decoding';
14
14
  export const messagePermissionDenied = 0;
15
15
  /** The denial of a read-only socket's write: that socket still syncs (not a terminal refusal). */
16
16
  export const READ_ONLY_DENIAL = 'read-only';
17
+ /** The denial of what a suggest-only socket wrote that is no suggestion's: it still syncs. */
18
+ export const SUGGEST_ONLY_DENIAL = 'suggest-only';
17
19
  export const writePermissionDenied = (encoder, reason) => {
18
20
  encoding.writeVarUint(encoder, messagePermissionDenied);
19
21
  encoding.writeVarString(encoder, reason);
@@ -23,13 +25,24 @@ export const messageReadOnly = 1;
23
25
  export const writeReadOnly = (encoder) => {
24
26
  encoding.writeVarUint(encoder, messageReadOnly);
25
27
  };
28
+ /**
29
+ * The socket's access (the string that follows: `write`, `suggest` or
30
+ * `comment`), sent when it joins, before anything else it reads; a
31
+ * `comment` one's after its read-only notice (a `read` one has only the
32
+ * notice).
33
+ */
34
+ export const messageAccess = 2;
35
+ export const writeAccess = (encoder, access) => {
36
+ encoding.writeVarUint(encoder, messageAccess);
37
+ encoding.writeVarString(encoder, access);
38
+ };
26
39
  /**
27
40
  * Decode one auth payload. Returns the auth message subtype so the caller
28
41
  * can surface unknown subtypes — a valid envelope carrying an auth type we
29
42
  * do not speak is protocol skew, and this stack's contract is that skew is
30
43
  * reported, not silently dropped (same rule as unknown sync subtypes).
31
44
  */
32
- export const readAuthMessage = (decoder, y, permissionDeniedHandler, readOnlyHandler) => {
45
+ export const readAuthMessage = (decoder, y, permissionDeniedHandler, readOnlyHandler, accessHandler) => {
33
46
  const authMessageType = decoding.readVarUint(decoder);
34
47
  switch (authMessageType) {
35
48
  case messagePermissionDenied:
@@ -38,6 +51,9 @@ export const readAuthMessage = (decoder, y, permissionDeniedHandler, readOnlyHan
38
51
  case messageReadOnly:
39
52
  // Unclaimed, it is returned like any subtype the caller does not speak.
40
53
  readOnlyHandler?.(y);
54
+ break;
55
+ case messageAccess:
56
+ accessHandler?.(decoding.readVarString(decoder));
41
57
  }
42
58
  return authMessageType;
43
59
  };