markloom 0.4.0 → 0.5.1

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 (51) hide show
  1. package/README.md +29 -16
  2. package/ai.md +160 -0
  3. package/collab.md +70 -0
  4. package/dist/ai/index.cjs +4 -3
  5. package/dist/ai/index.d.cts +4 -2
  6. package/dist/ai/index.d.ts +4 -2
  7. package/dist/ai/index.js +3 -2
  8. package/dist/chunk-4JSJAHTB.js +255 -0
  9. package/dist/{chunk-VVFIQLVR.cjs → chunk-4TMHVNL6.cjs} +71 -79
  10. package/dist/chunk-ALZ3A5CS.cjs +255 -0
  11. package/dist/{chunk-QXJHFQLJ.js → chunk-FCH7LZFI.js} +23 -15
  12. package/dist/chunk-GQ2HHRGI.cjs +16 -0
  13. package/dist/chunk-JS527FDV.cjs +294 -0
  14. package/dist/chunk-LA5SBCGQ.js +16 -0
  15. package/dist/{chunk-ITVAR2UM.js → chunk-LEYAQNJA.js} +5 -3
  16. package/dist/{chunk-J3QWW6CN.js → chunk-MFYF2A6U.js} +5 -13
  17. package/dist/chunk-RLTHVQNQ.js +294 -0
  18. package/dist/{chunk-VSTOMEU2.cjs → chunk-VXM7Q6P5.cjs} +813 -478
  19. package/dist/{chunk-LNSKDJMF.cjs → chunk-YIFOGP2D.cjs} +46 -38
  20. package/dist/{chunk-HA6XHJUD.cjs → chunk-YXQDCW4Y.cjs} +22 -20
  21. package/dist/{chunk-VMUJM52A.js → chunk-ZMTLSFLO.js} +350 -15
  22. package/dist/client-6KiH4kGK.d.ts +144 -0
  23. package/dist/client-ZRZj2nkq.d.cts +144 -0
  24. package/dist/collab/index.cjs +25 -0
  25. package/dist/collab/index.d.cts +11 -0
  26. package/dist/collab/index.d.ts +11 -0
  27. package/dist/collab/index.js +25 -0
  28. package/dist/comments-DlExS6f-.d.cts +43 -0
  29. package/dist/comments-PhnR7Gkn.d.ts +43 -0
  30. package/dist/{controller-B_wG2Wh-.d.ts → controller-BNuuUM3E.d.ts} +26 -2
  31. package/dist/{controller-Cd1Dprrk.d.cts → controller-DQITsFhy.d.cts} +26 -2
  32. package/dist/index.cjs +21 -243
  33. package/dist/index.d.cts +5 -7
  34. package/dist/index.d.ts +5 -7
  35. package/dist/index.js +22 -244
  36. package/dist/react/index.cjs +8 -5
  37. package/dist/react/index.d.cts +4 -2
  38. package/dist/react/index.d.ts +4 -2
  39. package/dist/react/index.js +7 -4
  40. package/dist/rebase-batch-8rL_aXEE.d.ts +38 -0
  41. package/dist/rebase-batch-bYnBJpRO.d.cts +38 -0
  42. package/dist/step-BrvHIK7O.d.cts +65 -0
  43. package/dist/step-BrvHIK7O.d.ts +65 -0
  44. package/dist/view/index.cjs +11 -8
  45. package/dist/view/index.d.cts +5 -3
  46. package/dist/view/index.d.ts +5 -3
  47. package/dist/view/index.js +7 -4
  48. package/dist/view/theme.css +72 -0
  49. package/package.json +10 -3
  50. package/dist/comments-USjT1wYN.d.cts +0 -105
  51. package/dist/comments-USjT1wYN.d.ts +0 -105
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
4
 
@@ -9,7 +9,7 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkHA6XHJUDcjs = require('./chunk-HA6XHJUD.cjs');
12
+ var _chunkYXQDCW4Ycjs = require('./chunk-YXQDCW4Y.cjs');
13
13
 
14
14
 
15
15
 
@@ -69,259 +69,33 @@ var _chunkHA6XHJUDcjs = require('./chunk-HA6XHJUD.cjs');
69
69
 
70
70
 
71
71
 
72
+
73
+ var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
72
74
 
73
75
 
74
76
 
75
77
 
76
- var _chunkVVFIQLVRcjs = require('./chunk-VVFIQLVR.cjs');
77
78
 
78
- // src/tree/map.ts
79
- function mapPosition(step, pos) {
80
- const p = pos.path;
81
- switch (step.kind) {
82
- case "insertText":
83
- return mapText(step.path, step.offset, step.text.length, p, pos);
84
- case "deleteText":
85
- return mapText(step.path, step.offset, -step.length, p, pos);
86
- case "spliceChildren":
87
- return mapSplice(step.path, step.at, step.remove, step.insert.length, p, pos);
88
- case "replaceNode":
89
- return underPrefix(step.path, p) ? withPath(step.path.concat(0), pos) : pos;
90
- }
91
- }
92
- function mapSelection(step, sel) {
93
- return { anchor: mapPosition(step, sel.anchor), head: mapPosition(step, sel.head) };
94
- }
95
- function mapText(stepPath, at, delta, p, pos) {
96
- if (p.length !== stepPath.length + 1 || !isPrefix(stepPath, p))
97
- return pos;
98
- const off = p[p.length - 1];
99
- if (off < at)
100
- return pos;
101
- if (off === at) {
102
- if (delta > 0 && (_nullishCoalesce(pos.assoc, () => ( 1))) === 1)
103
- return withLast(p, off + delta, pos);
104
- return pos;
105
- }
106
- if (delta < 0 && off < at - delta)
107
- return withLast(p, at, pos);
108
- return withLast(p, off + delta, pos);
109
- }
110
- function mapSplice(parentPath, at, remove, insertCount, p, pos) {
111
- const d = parentPath.length;
112
- if (!isPrefix(parentPath, p) || p.length <= d)
113
- return pos;
114
- const idx = p[d];
115
- const delta = insertCount - remove;
116
- if (idx < at)
117
- return pos;
118
- if (idx < at + remove)
119
- return withPath(parentPath.concat(at), pos);
120
- if (idx === at) {
121
- if (insertCount > 0 && (_nullishCoalesce(pos.assoc, () => ( 1))) === 1)
122
- return withSeg(p, d, idx + insertCount, pos);
123
- return pos;
124
- }
125
- return withSeg(p, d, idx + delta, pos);
126
- }
127
- function withPath(path, src) {
128
- return src.assoc === void 0 ? { path } : { path, assoc: src.assoc };
129
- }
130
- function withLast(path, last, src) {
131
- return withPath(path.slice(0, -1).concat(last), src);
132
- }
133
- function withSeg(path, d, seg, src) {
134
- const next = path.slice();
135
- next[d] = seg;
136
- return withPath(next, src);
137
- }
138
- function isPrefix(a, b) {
139
- if (a.length > b.length)
140
- return false;
141
- for (let i = 0; i < a.length; i++) {
142
- if (a[i] !== b[i])
143
- return false;
144
- }
145
- return true;
146
- }
147
- function underPrefix(a, b) {
148
- return b.length > a.length && isPrefix(a, b);
149
- }
150
- function normalizePosition(doc, pos) {
151
- let cur = doc;
152
- for (let i = 0; i < pos.path.length - 1; i++) {
153
- if (!_chunkVVFIQLVRcjs.isElement.call(void 0, cur))
154
- break;
155
- const next = cur.children[pos.path[i]];
156
- if (!next)
157
- return pos;
158
- cur = next;
159
- }
160
- if (_chunkVVFIQLVRcjs.isText.call(void 0, cur))
161
- return pos;
162
- const at = _nullishCoalesce(pos.path[pos.path.length - 1], () => ( 0));
163
- const prefix = pos.path.slice(0, -1);
164
- return withPath(descendToText(cur, at, prefix), pos);
165
- }
166
- function descendToText(parent, at, prefix) {
167
- const kids = parent.children;
168
- if (kids.length === 0)
169
- return prefix.concat(0);
170
- const leftIdx = at > 0 ? at - 1 : 0;
171
- const toEnd = at > 0;
172
- let path = prefix.concat(leftIdx);
173
- let node = kids[Math.min(leftIdx, kids.length - 1)];
174
- while (_chunkVVFIQLVRcjs.isElement.call(void 0, node)) {
175
- const cs = node.children;
176
- if (cs.length === 0)
177
- return path.concat(0);
178
- const idx = toEnd ? cs.length - 1 : 0;
179
- path = path.concat(idx);
180
- node = cs[idx];
181
- }
182
- return path.concat(toEnd ? node.text.length : 0);
183
- }
184
79
 
185
- // src/tree/rebase.ts
186
- function makeBias(thisSite, overSite) {
187
- return thisSite > overSite ? 1 : -1;
188
- }
189
- function rebase(over, step, bias) {
190
- switch (step.kind) {
191
- case "insertText":
192
- case "deleteText": {
193
- if ((over.kind === "insertText" || over.kind === "deleteText") && samePath(over.path, step.path))
194
- return textVsText(over, step, bias);
195
- const want = step.path.length + 1;
196
- const mlo = movePoint(over, step.path.concat(step.offset), bias);
197
- if (mlo.length < want)
198
- return null;
199
- if (step.kind === "insertText")
200
- return { ...step, path: mlo.slice(0, -1), offset: mlo[mlo.length - 1] };
201
- const mhi = movePoint(over, step.path.concat(step.offset + step.length), bias);
202
- if (mhi.length < want)
203
- return null;
204
- const a = mlo[mlo.length - 1];
205
- const b = mhi[mhi.length - 1];
206
- return { ...step, path: mlo.slice(0, -1), offset: a, length: Math.max(0, b - a) };
207
- }
208
- case "spliceChildren": {
209
- if (over.kind === "spliceChildren" && samePath(over.path, step.path))
210
- return spliceVsSplice(over, step, bias);
211
- const want = step.path.length + 1;
212
- const moved = movePoint(over, step.path.concat(step.at), bias);
213
- if (moved.length < want)
214
- return null;
215
- return { ...step, path: moved.slice(0, -1), at: moved[moved.length - 1] };
216
- }
217
- case "replaceNode": {
218
- if (removesTarget(over, step.path, bias))
219
- return null;
220
- return { ...step, path: movePoint(over, step.path, 1) };
221
- }
222
- }
223
- }
224
- function removesTarget(over, targetPath, bias) {
225
- if (over.kind === "spliceChildren") {
226
- const d = over.path.length;
227
- if (targetPath.length <= d || !isPrefix2(over.path, targetPath))
228
- return false;
229
- const idx = targetPath[d];
230
- return idx >= over.at && idx < over.at + over.remove;
231
- }
232
- if (over.kind === "replaceNode") {
233
- if (isPrefix2(over.path, targetPath)) {
234
- const sameNode = targetPath.length === over.path.length;
235
- return sameNode ? bias === 1 : true;
236
- }
237
- return false;
238
- }
239
- return false;
240
- }
241
- function textVsText(over, step, bias) {
242
- if (over.kind === "insertText") {
243
- const o = over.offset;
244
- const ins = over.text.length;
245
- if (step.kind === "insertText") {
246
- const x = step.offset;
247
- const off = x < o ? x : x > o ? x + ins : bias === 1 ? x + ins : x;
248
- return { ...step, offset: off };
249
- }
250
- const s2 = step.offset;
251
- const e2 = step.offset + step.length;
252
- if (o <= s2)
253
- return { ...step, offset: s2 + ins, length: step.length };
254
- if (o >= e2)
255
- return { ...step, offset: s2, length: step.length };
256
- return { ...step, offset: s2, length: step.length + ins };
257
- }
258
- const d = over.offset;
259
- const oLen = over.length;
260
- if (step.kind === "insertText") {
261
- const x = step.offset;
262
- if (x > d && x < d + oLen)
263
- return null;
264
- return { ...step, offset: x <= d ? x : x - oLen };
265
- }
266
- const s0 = step.offset;
267
- const e0 = step.offset + step.length;
268
- const s = s0 <= d ? s0 : s0 >= d + oLen ? s0 - oLen : d;
269
- const e = e0 <= d ? e0 : e0 >= d + oLen ? e0 - oLen : d;
270
- const len = Math.max(0, e - s);
271
- if (len === 0)
272
- return null;
273
- return { ...step, offset: s, length: len };
274
- }
275
- function spliceVsSplice(over, step, bias) {
276
- const oa = over.at;
277
- const oe = over.at + over.remove;
278
- const oN = over.insert.length;
279
- const delta = oN - over.remove;
280
- const sa = step.at;
281
- const se = step.at + step.remove;
282
- const out = [];
283
- const leftRem = Math.max(0, Math.min(se, oa) - sa);
284
- const rightRem = Math.max(0, se - Math.max(sa, oe));
285
- if (rightRem > 0)
286
- out.push({ kind: "spliceChildren", path: step.path, at: Math.max(sa, oe) + delta, remove: rightRem, insert: [] });
287
- if (leftRem > 0)
288
- out.push({ kind: "spliceChildren", path: step.path, at: sa, remove: leftRem, insert: [] });
289
- if (step.insert.length > 0) {
290
- const insAt = sa === oa ? bias === 1 ? oa + oN : oa : sa < oa ? sa : sa >= oe ? sa + delta : oa + oN;
291
- out.push({ kind: "spliceChildren", path: step.path, at: insAt, remove: 0, insert: step.insert });
292
- }
293
- if (out.length === 0)
294
- return null;
295
- if (out.length === 1)
296
- return out[0];
297
- out.sort((x, y) => y.at - x.at || x.insert.length - y.insert.length);
298
- return out;
299
- }
300
- function samePath(a, b) {
301
- return a.length === b.length && a.every((x, i) => x === b[i]);
302
- }
303
- function isPrefix2(a, b) {
304
- if (a.length > b.length)
305
- return false;
306
- for (let i = 0; i < a.length; i++) {
307
- if (a[i] !== b[i])
308
- return false;
309
- }
310
- return true;
311
- }
312
- function movePoint(over, path, bias) {
313
- const pos = { path, assoc: bias };
314
- return mapPosition(over, pos).path;
315
- }
80
+
81
+
82
+
83
+
84
+ var _chunkJS527FDVcjs = require('./chunk-JS527FDV.cjs');
85
+
86
+
87
+
88
+
89
+ var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
316
90
 
317
91
  // src/tree/stats.ts
318
92
  function rawText(node) {
319
- if (_chunkVVFIQLVRcjs.isText.call(void 0, node))
93
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
320
94
  return node.text;
321
95
  return node.children.map(rawText).join("");
322
96
  }
323
97
  function spacedText(node) {
324
- if (_chunkVVFIQLVRcjs.isText.call(void 0, node))
98
+ if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
325
99
  return node.text;
326
100
  return node.children.map(spacedText).join("\n");
327
101
  }
@@ -421,4 +195,8 @@ function docStats(doc) {
421
195
 
422
196
 
423
197
 
424
- exports.amend = _chunkHA6XHJUDcjs.amend; exports.appendText = _chunkVVFIQLVRcjs.appendText; exports.apply = _chunkVVFIQLVRcjs.apply; exports.applyAll = _chunkVVFIQLVRcjs.applyAll; exports.arrowCell = _chunkVVFIQLVRcjs.arrowCell; exports.basicSchema = _chunkVVFIQLVRcjs.basicSchema; exports.buildGrid = _chunkVVFIQLVRcjs.buildGrid; exports.buildIdIndex = _chunkVVFIQLVRcjs.buildIdIndex; exports.calloutToHtml = _chunkVVFIQLVRcjs.calloutToHtml; exports.caretCell = _chunkVVFIQLVRcjs.caretCell; exports.cellCaret = _chunkVVFIQLVRcjs.cellCaret; exports.cellText = _chunkVVFIQLVRcjs.cellText; exports.checkSchema = _chunkVVFIQLVRcjs.checkSchema; exports.checkTable = _chunkVVFIQLVRcjs.checkTable; exports.clearCells = _chunkVVFIQLVRcjs.clearCells; exports.colspanOf = _chunkVVFIQLVRcjs.colspanOf; exports.commentIdsInDoc = _chunkHA6XHJUDcjs.commentIdsInDoc; exports.commit = _chunkHA6XHJUDcjs.commit; exports.deleteCol = _chunkVVFIQLVRcjs.deleteCol; exports.deleteRow = _chunkVVFIQLVRcjs.deleteRow; exports.deleteTableBlock = _chunkVVFIQLVRcjs.deleteTableBlock; exports.diffById = _chunkVVFIQLVRcjs.diffById; exports.docStats = docStats; exports.docToMd = _chunkVVFIQLVRcjs.docToMd; exports.embedHtml = _chunkVVFIQLVRcjs.embedHtml; exports.firstLeafPath = _chunkVVFIQLVRcjs.firstLeafPath; exports.firstViolation = _chunkHA6XHJUDcjs.firstViolation; exports.hasSpan = _chunkVVFIQLVRcjs.hasSpan; exports.htmlToBlocks = _chunkVVFIQLVRcjs.htmlToBlocks; exports.init = _chunkHA6XHJUDcjs.init; exports.insertAfter = _chunkVVFIQLVRcjs.insertAfter; exports.insertCol = _chunkVVFIQLVRcjs.insertCol; exports.insertRow = _chunkVVFIQLVRcjs.insertRow; exports.invariants = _chunkHA6XHJUDcjs.invariants; exports.invert = _chunkVVFIQLVRcjs.invert; exports.invertAll = _chunkVVFIQLVRcjs.invertAll; exports.isElement = _chunkVVFIQLVRcjs.isElement; exports.isInlineAtom = _chunkVVFIQLVRcjs.isInlineAtom; exports.isRichHtmlBlocks = _chunkVVFIQLVRcjs.isRichHtmlBlocks; exports.isText = _chunkVVFIQLVRcjs.isText; exports.lastLeafEnd = _chunkVVFIQLVRcjs.lastLeafEnd; exports.makeBias = makeBias; exports.makeTable = _chunkVVFIQLVRcjs.makeTable; exports.mapPosition = mapPosition; exports.mapSelection = mapSelection; exports.mdToDoc = _chunkVVFIQLVRcjs.mdToDoc; exports.mergeCells = _chunkVVFIQLVRcjs.mergeCells; exports.moveBlock = _chunkVVFIQLVRcjs.moveBlock; exports.moveCol = _chunkVVFIQLVRcjs.moveCol; exports.moveRow = _chunkVVFIQLVRcjs.moveRow; exports.nextCell = _chunkVVFIQLVRcjs.nextCell; exports.nodeAt = _chunkVVFIQLVRcjs.nodeAt; exports.normalizePosition = normalizePosition; exports.normalizeToLeaf = _chunkVVFIQLVRcjs.normalizeToLeaf; exports.outline = _chunkHA6XHJUDcjs.outline; exports.pathOfId = _chunkVVFIQLVRcjs.pathOfId; exports.rebase = rebase; exports.redo = _chunkHA6XHJUDcjs.redo; exports.replaceAt = _chunkVVFIQLVRcjs.replaceAt; exports.resolve = _chunkVVFIQLVRcjs.resolve; exports.rewriteNode = _chunkVVFIQLVRcjs.rewriteNode; exports.rowspanOf = _chunkVVFIQLVRcjs.rowspanOf; exports.setAlign = _chunkVVFIQLVRcjs.setAlign; exports.setCellStyle = _chunkVVFIQLVRcjs.setCellStyle; exports.setColWidths = _chunkVVFIQLVRcjs.setColWidths; exports.setFreeze = _chunkVVFIQLVRcjs.setFreeze; exports.spliceAt = _chunkVVFIQLVRcjs.spliceAt; exports.splitCell = _chunkVVFIQLVRcjs.splitCell; exports.stripCommentMarks = _chunkHA6XHJUDcjs.stripCommentMarks; exports.tableAt = _chunkVVFIQLVRcjs.tableAt; exports.tableColWidths = _chunkVVFIQLVRcjs.tableColWidths; exports.tableHasExtras = _chunkVVFIQLVRcjs.tableHasExtras; exports.tableSchema = _chunkVVFIQLVRcjs.tableSchema; exports.tableShape = _chunkVVFIQLVRcjs.tableShape; exports.tableToHtml = _chunkVVFIQLVRcjs.tableToHtml; exports.undo = _chunkHA6XHJUDcjs.undo; exports.validate = _chunkVVFIQLVRcjs.validate; exports.validateAll = _chunkVVFIQLVRcjs.validateAll;
198
+
199
+
200
+
201
+
202
+ exports.amend = _chunkYXQDCW4Ycjs.amend; exports.appendText = _chunk4TMHVNL6cjs.appendText; exports.apply = _chunk4TMHVNL6cjs.apply; exports.applyAll = _chunk4TMHVNL6cjs.applyAll; exports.arrowCell = _chunk4TMHVNL6cjs.arrowCell; exports.basicSchema = _chunk4TMHVNL6cjs.basicSchema; exports.buildGrid = _chunk4TMHVNL6cjs.buildGrid; exports.buildIdIndex = _chunk4TMHVNL6cjs.buildIdIndex; exports.calloutToHtml = _chunk4TMHVNL6cjs.calloutToHtml; exports.caretCell = _chunk4TMHVNL6cjs.caretCell; exports.cellCaret = _chunk4TMHVNL6cjs.cellCaret; exports.cellText = _chunk4TMHVNL6cjs.cellText; exports.checkSchema = _chunk4TMHVNL6cjs.checkSchema; exports.checkTable = _chunk4TMHVNL6cjs.checkTable; exports.clearCells = _chunk4TMHVNL6cjs.clearCells; exports.colspanOf = _chunk4TMHVNL6cjs.colspanOf; exports.commentIdsInDoc = _chunkYXQDCW4Ycjs.commentIdsInDoc; exports.commit = _chunkYXQDCW4Ycjs.commit; exports.deleteCol = _chunk4TMHVNL6cjs.deleteCol; exports.deleteRow = _chunk4TMHVNL6cjs.deleteRow; exports.deleteTableBlock = _chunk4TMHVNL6cjs.deleteTableBlock; exports.diffById = _chunk4TMHVNL6cjs.diffById; exports.docStats = docStats; exports.docToMd = _chunk4TMHVNL6cjs.docToMd; exports.embedHtml = _chunk4TMHVNL6cjs.embedHtml; exports.firstLeafPath = _chunk4TMHVNL6cjs.firstLeafPath; exports.firstViolation = _chunkYXQDCW4Ycjs.firstViolation; exports.hasSpan = _chunk4TMHVNL6cjs.hasSpan; exports.htmlToBlocks = _chunk4TMHVNL6cjs.htmlToBlocks; exports.init = _chunkYXQDCW4Ycjs.init; exports.insertAfter = _chunk4TMHVNL6cjs.insertAfter; exports.insertCol = _chunk4TMHVNL6cjs.insertCol; exports.insertRow = _chunk4TMHVNL6cjs.insertRow; exports.invariants = _chunkYXQDCW4Ycjs.invariants; exports.invert = _chunk4TMHVNL6cjs.invert; exports.invertAll = _chunk4TMHVNL6cjs.invertAll; exports.isElement = _chunkGQ2HHRGIcjs.isElement; exports.isInlineAtom = _chunkGQ2HHRGIcjs.isInlineAtom; exports.isRichHtmlBlocks = _chunk4TMHVNL6cjs.isRichHtmlBlocks; exports.isText = _chunkGQ2HHRGIcjs.isText; exports.lastLeafEnd = _chunk4TMHVNL6cjs.lastLeafEnd; exports.makeBias = _chunkJS527FDVcjs.makeBias; exports.makeTable = _chunk4TMHVNL6cjs.makeTable; exports.mapPosition = _chunkJS527FDVcjs.mapPosition; exports.mapSelection = _chunkJS527FDVcjs.mapSelection; exports.mdToDoc = _chunk4TMHVNL6cjs.mdToDoc; exports.mergeCells = _chunk4TMHVNL6cjs.mergeCells; exports.moveBlock = _chunk4TMHVNL6cjs.moveBlock; exports.moveCol = _chunk4TMHVNL6cjs.moveCol; exports.moveRow = _chunk4TMHVNL6cjs.moveRow; exports.nextCell = _chunk4TMHVNL6cjs.nextCell; exports.nodeAt = _chunk4TMHVNL6cjs.nodeAt; exports.normalizePosition = _chunkJS527FDVcjs.normalizePosition; exports.normalizeToLeaf = _chunk4TMHVNL6cjs.normalizeToLeaf; exports.outline = _chunkYXQDCW4Ycjs.outline; exports.pathOfId = _chunk4TMHVNL6cjs.pathOfId; exports.rebase = _chunkJS527FDVcjs.rebase; exports.rebaseBatchOver = _chunkJS527FDVcjs.rebaseBatchOver; exports.rebaseOne = _chunkJS527FDVcjs.rebaseOne; exports.rebaseStepsThrough = _chunkJS527FDVcjs.rebaseStepsThrough; exports.redo = _chunkYXQDCW4Ycjs.redo; exports.replaceAt = _chunk4TMHVNL6cjs.replaceAt; exports.resolve = _chunk4TMHVNL6cjs.resolve; exports.rewriteNode = _chunk4TMHVNL6cjs.rewriteNode; exports.rowspanOf = _chunk4TMHVNL6cjs.rowspanOf; exports.setAlign = _chunk4TMHVNL6cjs.setAlign; exports.setCellStyle = _chunk4TMHVNL6cjs.setCellStyle; exports.setColWidths = _chunk4TMHVNL6cjs.setColWidths; exports.setFreeze = _chunk4TMHVNL6cjs.setFreeze; exports.spliceAt = _chunk4TMHVNL6cjs.spliceAt; exports.splitCell = _chunk4TMHVNL6cjs.splitCell; exports.stripCommentMarks = _chunkYXQDCW4Ycjs.stripCommentMarks; exports.tableAt = _chunk4TMHVNL6cjs.tableAt; exports.tableColWidths = _chunk4TMHVNL6cjs.tableColWidths; exports.tableHasExtras = _chunk4TMHVNL6cjs.tableHasExtras; exports.tableSchema = _chunk4TMHVNL6cjs.tableSchema; exports.tableShape = _chunk4TMHVNL6cjs.tableShape; exports.tableToHtml = _chunk4TMHVNL6cjs.tableToHtml; exports.transformRemoteAgainstPending = _chunkJS527FDVcjs.transformRemoteAgainstPending; exports.undo = _chunkYXQDCW4Ycjs.undo; exports.validate = _chunk4TMHVNL6cjs.validate; exports.validateAll = _chunk4TMHVNL6cjs.validateAll;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
- import { E as ElementNode, P as Path, S as Step, N as Node, a as Position } from './comments-USjT1wYN.cjs';
2
- export { C as CommentAuthor, b as CommentMessage, c as CommentRenderState, d as CommentThread, e as Commit, D as DeleteText, f as Doc, H as History, I as InsertText, M as Mark, R as ReplaceNode, g as Selection, h as SpliceChildren, T as TextNode, i as amend, j as apply, k as applyAll, l as commentIdsInDoc, m as commit, n as init, o as invert, p as invertAll, q as isElement, r as isInlineAtom, s as isText, t as moveBlock, u as redo, v as stripCommentMarks, w as undo } from './comments-USjT1wYN.cjs';
1
+ import { E as ElementNode, P as Path, S as Step, N as Node, a as Position } from './step-BrvHIK7O.cjs';
2
+ export { D as DeleteText, b as Doc, I as InsertText, M as Mark, R as ReplaceNode, c as Selection, d as SpliceChildren, T as TextNode, e as apply, f as applyAll, i as invert, g as invertAll, h as isElement, j as isInlineAtom, k as isText, m as moveBlock } from './step-BrvHIK7O.cjs';
3
+ export { C as CommentAuthor, a as CommentMessage, b as CommentRenderState, c as CommentThread, d as Commit, H as History, e as amend, f as commentIdsInDoc, g as commit, i as init, r as redo, s as stripCommentMarks, u as undo } from './comments-DlExS6f-.cjs';
4
+ export { B as Bias, m as makeBias, c as rebase, r as rebaseBatchOver, a as rebaseOne, b as rebaseStepsThrough, t as transformRemoteAgainstPending } from './rebase-batch-bYnBJpRO.cjs';
3
5
 
4
6
  interface TableShape {
5
7
  rows: number;
@@ -162,10 +164,6 @@ declare function mapSelection(step: Step, sel: {
162
164
  };
163
165
  declare function normalizePosition(doc: ElementNode, pos: Position): Position;
164
166
 
165
- type Bias = -1 | 1;
166
- declare function makeBias(thisSite: number, overSite: number): Bias;
167
- declare function rebase(over: Step, step: Step, bias: Bias): Step | Step[] | null;
168
-
169
167
  interface DocStats {
170
168
  chars: number;
171
169
  words: number;
@@ -181,4 +179,4 @@ interface TocEntry {
181
179
  }
182
180
  declare function outline(doc: ElementNode): TocEntry[];
183
181
 
184
- export { type Bias, type DocStats, ElementNode, type Grid, type IdIndex, Node, type NodeChange, type NodeSpec, Path, Position, type Resolved, type Schema, Step, type TableShape, type TocEntry, type Violation, appendText, arrowCell, basicSchema, buildGrid, buildIdIndex, calloutToHtml, caretCell, cellCaret, cellText, checkSchema, checkTable, clearCells, colspanOf, deleteCol, deleteRow, deleteTableBlock, diffById, docStats, docToMd, embedHtml, firstLeafPath, firstViolation, hasSpan, htmlToBlocks, insertAfter, insertCol, insertRow, invariants, isRichHtmlBlocks, lastLeafEnd, makeBias, makeTable, mapPosition, mapSelection, mdToDoc, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, rebase, replaceAt, resolve, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, spliceAt, splitCell, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };
182
+ export { type DocStats, ElementNode, type Grid, type IdIndex, Node, type NodeChange, type NodeSpec, Path, Position, type Resolved, type Schema, Step, type TableShape, type TocEntry, type Violation, appendText, arrowCell, basicSchema, buildGrid, buildIdIndex, calloutToHtml, caretCell, cellCaret, cellText, checkSchema, checkTable, clearCells, colspanOf, deleteCol, deleteRow, deleteTableBlock, diffById, docStats, docToMd, embedHtml, firstLeafPath, firstViolation, hasSpan, htmlToBlocks, insertAfter, insertCol, insertRow, invariants, isRichHtmlBlocks, lastLeafEnd, makeTable, mapPosition, mapSelection, mdToDoc, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, replaceAt, resolve, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, spliceAt, splitCell, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { E as ElementNode, P as Path, S as Step, N as Node, a as Position } from './comments-USjT1wYN.js';
2
- export { C as CommentAuthor, b as CommentMessage, c as CommentRenderState, d as CommentThread, e as Commit, D as DeleteText, f as Doc, H as History, I as InsertText, M as Mark, R as ReplaceNode, g as Selection, h as SpliceChildren, T as TextNode, i as amend, j as apply, k as applyAll, l as commentIdsInDoc, m as commit, n as init, o as invert, p as invertAll, q as isElement, r as isInlineAtom, s as isText, t as moveBlock, u as redo, v as stripCommentMarks, w as undo } from './comments-USjT1wYN.js';
1
+ import { E as ElementNode, P as Path, S as Step, N as Node, a as Position } from './step-BrvHIK7O.js';
2
+ export { D as DeleteText, b as Doc, I as InsertText, M as Mark, R as ReplaceNode, c as Selection, d as SpliceChildren, T as TextNode, e as apply, f as applyAll, i as invert, g as invertAll, h as isElement, j as isInlineAtom, k as isText, m as moveBlock } from './step-BrvHIK7O.js';
3
+ export { C as CommentAuthor, a as CommentMessage, b as CommentRenderState, c as CommentThread, d as Commit, H as History, e as amend, f as commentIdsInDoc, g as commit, i as init, r as redo, s as stripCommentMarks, u as undo } from './comments-PhnR7Gkn.js';
4
+ export { B as Bias, m as makeBias, c as rebase, r as rebaseBatchOver, a as rebaseOne, b as rebaseStepsThrough, t as transformRemoteAgainstPending } from './rebase-batch-8rL_aXEE.js';
3
5
 
4
6
  interface TableShape {
5
7
  rows: number;
@@ -162,10 +164,6 @@ declare function mapSelection(step: Step, sel: {
162
164
  };
163
165
  declare function normalizePosition(doc: ElementNode, pos: Position): Position;
164
166
 
165
- type Bias = -1 | 1;
166
- declare function makeBias(thisSite: number, overSite: number): Bias;
167
- declare function rebase(over: Step, step: Step, bias: Bias): Step | Step[] | null;
168
-
169
167
  interface DocStats {
170
168
  chars: number;
171
169
  words: number;
@@ -181,4 +179,4 @@ interface TocEntry {
181
179
  }
182
180
  declare function outline(doc: ElementNode): TocEntry[];
183
181
 
184
- export { type Bias, type DocStats, ElementNode, type Grid, type IdIndex, Node, type NodeChange, type NodeSpec, Path, Position, type Resolved, type Schema, Step, type TableShape, type TocEntry, type Violation, appendText, arrowCell, basicSchema, buildGrid, buildIdIndex, calloutToHtml, caretCell, cellCaret, cellText, checkSchema, checkTable, clearCells, colspanOf, deleteCol, deleteRow, deleteTableBlock, diffById, docStats, docToMd, embedHtml, firstLeafPath, firstViolation, hasSpan, htmlToBlocks, insertAfter, insertCol, insertRow, invariants, isRichHtmlBlocks, lastLeafEnd, makeBias, makeTable, mapPosition, mapSelection, mdToDoc, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, rebase, replaceAt, resolve, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, spliceAt, splitCell, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };
182
+ export { type DocStats, ElementNode, type Grid, type IdIndex, Node, type NodeChange, type NodeSpec, Path, Position, type Resolved, type Schema, Step, type TableShape, type TocEntry, type Violation, appendText, arrowCell, basicSchema, buildGrid, buildIdIndex, calloutToHtml, caretCell, cellCaret, cellText, checkSchema, checkTable, clearCells, colspanOf, deleteCol, deleteRow, deleteTableBlock, diffById, docStats, docToMd, embedHtml, firstLeafPath, firstViolation, hasSpan, htmlToBlocks, insertAfter, insertCol, insertRow, invariants, isRichHtmlBlocks, lastLeafEnd, makeTable, mapPosition, mapSelection, mdToDoc, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, replaceAt, resolve, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, spliceAt, splitCell, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  redo,
10
10
  stripCommentMarks,
11
11
  undo
12
- } from "./chunk-ITVAR2UM.js";
12
+ } from "./chunk-LEYAQNJA.js";
13
13
  import {
14
14
  appendText,
15
15
  apply,
@@ -40,10 +40,7 @@ import {
40
40
  insertRow,
41
41
  invert,
42
42
  invertAll,
43
- isElement,
44
- isInlineAtom,
45
43
  isRichHtmlBlocks,
46
- isText,
47
44
  lastLeafEnd,
48
45
  makeTable,
49
46
  mdToDoc,
@@ -73,246 +70,23 @@ import {
73
70
  tableToHtml,
74
71
  validate,
75
72
  validateAll
76
- } from "./chunk-J3QWW6CN.js";
77
-
78
- // src/tree/map.ts
79
- function mapPosition(step, pos) {
80
- const p = pos.path;
81
- switch (step.kind) {
82
- case "insertText":
83
- return mapText(step.path, step.offset, step.text.length, p, pos);
84
- case "deleteText":
85
- return mapText(step.path, step.offset, -step.length, p, pos);
86
- case "spliceChildren":
87
- return mapSplice(step.path, step.at, step.remove, step.insert.length, p, pos);
88
- case "replaceNode":
89
- return underPrefix(step.path, p) ? withPath(step.path.concat(0), pos) : pos;
90
- }
91
- }
92
- function mapSelection(step, sel) {
93
- return { anchor: mapPosition(step, sel.anchor), head: mapPosition(step, sel.head) };
94
- }
95
- function mapText(stepPath, at, delta, p, pos) {
96
- if (p.length !== stepPath.length + 1 || !isPrefix(stepPath, p))
97
- return pos;
98
- const off = p[p.length - 1];
99
- if (off < at)
100
- return pos;
101
- if (off === at) {
102
- if (delta > 0 && (pos.assoc ?? 1) === 1)
103
- return withLast(p, off + delta, pos);
104
- return pos;
105
- }
106
- if (delta < 0 && off < at - delta)
107
- return withLast(p, at, pos);
108
- return withLast(p, off + delta, pos);
109
- }
110
- function mapSplice(parentPath, at, remove, insertCount, p, pos) {
111
- const d = parentPath.length;
112
- if (!isPrefix(parentPath, p) || p.length <= d)
113
- return pos;
114
- const idx = p[d];
115
- const delta = insertCount - remove;
116
- if (idx < at)
117
- return pos;
118
- if (idx < at + remove)
119
- return withPath(parentPath.concat(at), pos);
120
- if (idx === at) {
121
- if (insertCount > 0 && (pos.assoc ?? 1) === 1)
122
- return withSeg(p, d, idx + insertCount, pos);
123
- return pos;
124
- }
125
- return withSeg(p, d, idx + delta, pos);
126
- }
127
- function withPath(path, src) {
128
- return src.assoc === void 0 ? { path } : { path, assoc: src.assoc };
129
- }
130
- function withLast(path, last, src) {
131
- return withPath(path.slice(0, -1).concat(last), src);
132
- }
133
- function withSeg(path, d, seg, src) {
134
- const next = path.slice();
135
- next[d] = seg;
136
- return withPath(next, src);
137
- }
138
- function isPrefix(a, b) {
139
- if (a.length > b.length)
140
- return false;
141
- for (let i = 0; i < a.length; i++) {
142
- if (a[i] !== b[i])
143
- return false;
144
- }
145
- return true;
146
- }
147
- function underPrefix(a, b) {
148
- return b.length > a.length && isPrefix(a, b);
149
- }
150
- function normalizePosition(doc, pos) {
151
- let cur = doc;
152
- for (let i = 0; i < pos.path.length - 1; i++) {
153
- if (!isElement(cur))
154
- break;
155
- const next = cur.children[pos.path[i]];
156
- if (!next)
157
- return pos;
158
- cur = next;
159
- }
160
- if (isText(cur))
161
- return pos;
162
- const at = pos.path[pos.path.length - 1] ?? 0;
163
- const prefix = pos.path.slice(0, -1);
164
- return withPath(descendToText(cur, at, prefix), pos);
165
- }
166
- function descendToText(parent, at, prefix) {
167
- const kids = parent.children;
168
- if (kids.length === 0)
169
- return prefix.concat(0);
170
- const leftIdx = at > 0 ? at - 1 : 0;
171
- const toEnd = at > 0;
172
- let path = prefix.concat(leftIdx);
173
- let node = kids[Math.min(leftIdx, kids.length - 1)];
174
- while (isElement(node)) {
175
- const cs = node.children;
176
- if (cs.length === 0)
177
- return path.concat(0);
178
- const idx = toEnd ? cs.length - 1 : 0;
179
- path = path.concat(idx);
180
- node = cs[idx];
181
- }
182
- return path.concat(toEnd ? node.text.length : 0);
183
- }
184
-
185
- // src/tree/rebase.ts
186
- function makeBias(thisSite, overSite) {
187
- return thisSite > overSite ? 1 : -1;
188
- }
189
- function rebase(over, step, bias) {
190
- switch (step.kind) {
191
- case "insertText":
192
- case "deleteText": {
193
- if ((over.kind === "insertText" || over.kind === "deleteText") && samePath(over.path, step.path))
194
- return textVsText(over, step, bias);
195
- const want = step.path.length + 1;
196
- const mlo = movePoint(over, step.path.concat(step.offset), bias);
197
- if (mlo.length < want)
198
- return null;
199
- if (step.kind === "insertText")
200
- return { ...step, path: mlo.slice(0, -1), offset: mlo[mlo.length - 1] };
201
- const mhi = movePoint(over, step.path.concat(step.offset + step.length), bias);
202
- if (mhi.length < want)
203
- return null;
204
- const a = mlo[mlo.length - 1];
205
- const b = mhi[mhi.length - 1];
206
- return { ...step, path: mlo.slice(0, -1), offset: a, length: Math.max(0, b - a) };
207
- }
208
- case "spliceChildren": {
209
- if (over.kind === "spliceChildren" && samePath(over.path, step.path))
210
- return spliceVsSplice(over, step, bias);
211
- const want = step.path.length + 1;
212
- const moved = movePoint(over, step.path.concat(step.at), bias);
213
- if (moved.length < want)
214
- return null;
215
- return { ...step, path: moved.slice(0, -1), at: moved[moved.length - 1] };
216
- }
217
- case "replaceNode": {
218
- if (removesTarget(over, step.path, bias))
219
- return null;
220
- return { ...step, path: movePoint(over, step.path, 1) };
221
- }
222
- }
223
- }
224
- function removesTarget(over, targetPath, bias) {
225
- if (over.kind === "spliceChildren") {
226
- const d = over.path.length;
227
- if (targetPath.length <= d || !isPrefix2(over.path, targetPath))
228
- return false;
229
- const idx = targetPath[d];
230
- return idx >= over.at && idx < over.at + over.remove;
231
- }
232
- if (over.kind === "replaceNode") {
233
- if (isPrefix2(over.path, targetPath)) {
234
- const sameNode = targetPath.length === over.path.length;
235
- return sameNode ? bias === 1 : true;
236
- }
237
- return false;
238
- }
239
- return false;
240
- }
241
- function textVsText(over, step, bias) {
242
- if (over.kind === "insertText") {
243
- const o = over.offset;
244
- const ins = over.text.length;
245
- if (step.kind === "insertText") {
246
- const x = step.offset;
247
- const off = x < o ? x : x > o ? x + ins : bias === 1 ? x + ins : x;
248
- return { ...step, offset: off };
249
- }
250
- const s2 = step.offset;
251
- const e2 = step.offset + step.length;
252
- if (o <= s2)
253
- return { ...step, offset: s2 + ins, length: step.length };
254
- if (o >= e2)
255
- return { ...step, offset: s2, length: step.length };
256
- return { ...step, offset: s2, length: step.length + ins };
257
- }
258
- const d = over.offset;
259
- const oLen = over.length;
260
- if (step.kind === "insertText") {
261
- const x = step.offset;
262
- if (x > d && x < d + oLen)
263
- return null;
264
- return { ...step, offset: x <= d ? x : x - oLen };
265
- }
266
- const s0 = step.offset;
267
- const e0 = step.offset + step.length;
268
- const s = s0 <= d ? s0 : s0 >= d + oLen ? s0 - oLen : d;
269
- const e = e0 <= d ? e0 : e0 >= d + oLen ? e0 - oLen : d;
270
- const len = Math.max(0, e - s);
271
- if (len === 0)
272
- return null;
273
- return { ...step, offset: s, length: len };
274
- }
275
- function spliceVsSplice(over, step, bias) {
276
- const oa = over.at;
277
- const oe = over.at + over.remove;
278
- const oN = over.insert.length;
279
- const delta = oN - over.remove;
280
- const sa = step.at;
281
- const se = step.at + step.remove;
282
- const out = [];
283
- const leftRem = Math.max(0, Math.min(se, oa) - sa);
284
- const rightRem = Math.max(0, se - Math.max(sa, oe));
285
- if (rightRem > 0)
286
- out.push({ kind: "spliceChildren", path: step.path, at: Math.max(sa, oe) + delta, remove: rightRem, insert: [] });
287
- if (leftRem > 0)
288
- out.push({ kind: "spliceChildren", path: step.path, at: sa, remove: leftRem, insert: [] });
289
- if (step.insert.length > 0) {
290
- const insAt = sa === oa ? bias === 1 ? oa + oN : oa : sa < oa ? sa : sa >= oe ? sa + delta : oa + oN;
291
- out.push({ kind: "spliceChildren", path: step.path, at: insAt, remove: 0, insert: step.insert });
292
- }
293
- if (out.length === 0)
294
- return null;
295
- if (out.length === 1)
296
- return out[0];
297
- out.sort((x, y) => y.at - x.at || x.insert.length - y.insert.length);
298
- return out;
299
- }
300
- function samePath(a, b) {
301
- return a.length === b.length && a.every((x, i) => x === b[i]);
302
- }
303
- function isPrefix2(a, b) {
304
- if (a.length > b.length)
305
- return false;
306
- for (let i = 0; i < a.length; i++) {
307
- if (a[i] !== b[i])
308
- return false;
309
- }
310
- return true;
311
- }
312
- function movePoint(over, path, bias) {
313
- const pos = { path, assoc: bias };
314
- return mapPosition(over, pos).path;
315
- }
73
+ } from "./chunk-MFYF2A6U.js";
74
+ import {
75
+ makeBias,
76
+ mapPosition,
77
+ mapSelection,
78
+ normalizePosition,
79
+ rebase,
80
+ rebaseBatchOver,
81
+ rebaseOne,
82
+ rebaseStepsThrough,
83
+ transformRemoteAgainstPending
84
+ } from "./chunk-RLTHVQNQ.js";
85
+ import {
86
+ isElement,
87
+ isInlineAtom,
88
+ isText
89
+ } from "./chunk-LA5SBCGQ.js";
316
90
 
317
91
  // src/tree/stats.ts
318
92
  function rawText(node) {
@@ -400,6 +174,9 @@ export {
400
174
  outline,
401
175
  pathOfId,
402
176
  rebase,
177
+ rebaseBatchOver,
178
+ rebaseOne,
179
+ rebaseStepsThrough,
403
180
  redo,
404
181
  replaceAt,
405
182
  resolve,
@@ -418,6 +195,7 @@ export {
418
195
  tableSchema,
419
196
  tableShape,
420
197
  tableToHtml,
198
+ transformRemoteAgainstPending,
421
199
  undo,
422
200
  validate,
423
201
  validateAll