@clubmed/usg-chat-ui 1.0.1 → 1.2.4
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.
- package/chunks/_commonjsHelpers.js +9 -0
- package/chunks/_commonjsHelpers.js.map +1 -0
- package/chunks/browser.js +579 -0
- package/chunks/browser.js.map +1 -0
- package/chunks/client.js +27323 -0
- package/chunks/client.js.map +1 -0
- package/chunks/index.js +59 -32
- package/chunks/index.js.map +1 -1
- package/chunks/index2.js +32 -59
- package/chunks/index2.js.map +1 -1
- package/chunks/index3.js +22 -740
- package/chunks/index3.js.map +1 -1
- package/chunks/index4.js +740 -22
- package/chunks/index4.js.map +1 -1
- package/chunks/index5.js +1 -1
- package/chunks/index6.js +144 -150
- package/chunks/index6.js.map +1 -1
- package/chunks/index7.js +14 -13
- package/chunks/index7.js.map +1 -1
- package/chunks/magic-string.es.js +664 -0
- package/chunks/magic-string.es.js.map +1 -0
- package/chunks/react.esm.js +10007 -0
- package/chunks/react.esm.js.map +1 -0
- package/chunks/{collaboration.js → useCollaboration.js} +536 -523
- package/chunks/useCollaboration.js.map +1 -0
- package/chunks/vi.2VT5v0um.js +10573 -0
- package/chunks/vi.2VT5v0um.js.map +1 -0
- package/contexts/ChatContext.d.ts +2 -1
- package/contexts/ChatContext.js +32 -30
- package/contexts/ChatContext.js.map +1 -1
- package/core/interfaces/ChatConfig.d.ts +4 -0
- package/core/interfaces/StoryVersion.d.ts +7 -2
- package/index.d.ts +1 -0
- package/molecules/AiElements/Message.js +1 -1
- package/molecules/AiElements/Response.js +15 -13
- package/molecules/AiElements/Response.js.map +1 -1
- package/molecules/AiElements/Sources.d.ts +2 -2
- package/molecules/AiElements/Sources.js.map +1 -1
- package/molecules/Buttons/Button.d.ts +1 -1
- package/molecules/Buttons/Button.js +2 -2
- package/molecules/{AiElements → CodeBlock}/CodeBlock.d.ts +5 -2
- package/molecules/CodeBlock/CodeBlock.js +128 -0
- package/molecules/CodeBlock/CodeBlock.js.map +1 -0
- package/molecules/CodeBlock/CodeBlock.test.d.ts +1 -0
- package/molecules/CodeBlock/CodeBlock.test.js +3158 -0
- package/molecules/CodeBlock/CodeBlock.test.js.map +1 -0
- package/molecules/CodeBlock/highlightCode.d.ts +2 -0
- package/molecules/CodeBlock/highlightCode.js +5850 -0
- package/molecules/CodeBlock/highlightCode.js.map +1 -0
- package/molecules/CodeBlock/highlightCode.test.d.ts +1 -0
- package/molecules/CodeBlock/highlightCode.test.js +47 -0
- package/molecules/CodeBlock/highlightCode.test.js.map +1 -0
- package/molecules/Collapsibles/Collapsible.js +1 -1
- package/molecules/Forms/InputGroups/InputGroup.js +1 -1
- package/molecules/Labels/Label.js +2 -2
- package/molecules/Notifications/{Sonner.js → Toaster.js} +2 -2
- package/molecules/Notifications/Toaster.js.map +1 -0
- package/molecules/Notifications/{use-toast.js → useToast.js} +1 -1
- package/molecules/Notifications/useToast.js.map +1 -0
- package/{organisms → molecules}/RichText/DynamicEditor.js.map +1 -1
- package/molecules/RichText/EditorWithAI.js +55854 -0
- package/molecules/RichText/EditorWithAI.js.map +1 -0
- package/molecules/RichText/useCollaboration.d.ts +9 -0
- package/molecules/RichText/useCollaboration.js +8 -0
- package/molecules/RichText/useCollaboration.js.map +1 -0
- package/molecules/RichText/useCollaboration.test.d.ts +1 -0
- package/molecules/RichText/useCollaboration.test.js +70 -0
- package/molecules/RichText/useCollaboration.test.js.map +1 -0
- package/molecules/Tabs/Tabs.js +1 -1
- package/organisms/canvas/ApiDocsCanvas.js +15 -15
- package/organisms/canvas/ApiDocsCanvas.js.map +1 -1
- package/organisms/canvas/ReleaseNoteCanvas.js +2 -2
- package/organisms/canvas/ReleaseNoteCanvas.js.map +1 -1
- package/organisms/canvas/StoryCanvas.js +2 -2
- package/organisms/canvas/StoryCanvas.js.map +1 -1
- package/organisms/chat/MessageActions.js +1 -1
- package/organisms/chat/MessageActions.js.map +1 -1
- package/organisms/chat/hooks/useChat.js +1 -1
- package/organisms/chat/hooks/useChat.js.map +1 -1
- package/organisms/chat/hooks/useChatKeyboardsShortcuts.js +16 -33
- package/organisms/chat/hooks/useChatKeyboardsShortcuts.js.map +1 -1
- package/organisms/chat/hooks/useConversations.js +1 -1
- package/organisms/chat/hooks/useConversations.js.map +1 -1
- package/organisms/settings/SettingsModal.js +1 -1
- package/package.json +3 -4
- package/.npm/_logs/2026-01-19T16_54_30_380Z-debug-0.log +0 -19
- package/.npm/_logs/2026-01-19T16_54_30_467Z-debug-0.log +0 -19
- package/.npm/_logs/2026-01-19T16_54_30_553Z-debug-0.log +0 -14
- package/chunks/collaboration.js.map +0 -1
- package/core/collaboration.d.ts +0 -6
- package/core/collaboration.js +0 -5
- package/core/collaboration.js.map +0 -1
- package/molecules/AiElements/CodeBlock.js +0 -6525
- package/molecules/AiElements/CodeBlock.js.map +0 -1
- package/molecules/Notifications/Sonner.js.map +0 -1
- package/molecules/Notifications/use-toast.js.map +0 -1
- package/molecules/index.d.ts +0 -28
- package/molecules/index.js +0 -88
- package/molecules/index.js.map +0 -1
- package/organisms/RichText/EditorWithAI.js +0 -83167
- package/organisms/RichText/EditorWithAI.js.map +0 -1
- /package/molecules/Notifications/{Sonner.d.ts → Toaster.d.ts} +0 -0
- /package/molecules/Notifications/{use-toast.d.ts → useToast.d.ts} +0 -0
- /package/{organisms → molecules}/RichText/DynamicEditor.d.ts +0 -0
- /package/{organisms → molecules}/RichText/DynamicEditor.js +0 -0
- /package/{organisms → molecules}/RichText/EditorWithAI.d.ts +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
var ur = Object.defineProperty;
|
|
2
2
|
var dr = (e, t, n) => t in e ? ur(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var le = (e, t, n) => dr(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { useChatConfig as fr } from "../contexts/ChatContext.js";
|
|
5
|
+
import { useMemo as gr } from "react";
|
|
4
6
|
const x = () => /* @__PURE__ */ new Map(), an = (e) => {
|
|
5
7
|
const t = x();
|
|
6
8
|
return e.forEach((n, s) => {
|
|
@@ -9,17 +11,17 @@ const x = () => /* @__PURE__ */ new Map(), an = (e) => {
|
|
|
9
11
|
}, q = (e, t, n) => {
|
|
10
12
|
let s = e.get(t);
|
|
11
13
|
return s === void 0 && e.set(t, s = n()), s;
|
|
12
|
-
},
|
|
14
|
+
}, pr = (e, t) => {
|
|
13
15
|
const n = [];
|
|
14
16
|
for (const [s, i] of e)
|
|
15
17
|
n.push(t(i, s));
|
|
16
18
|
return n;
|
|
17
|
-
},
|
|
19
|
+
}, wr = (e, t) => {
|
|
18
20
|
for (const [n, s] of e)
|
|
19
21
|
if (t(s, n))
|
|
20
22
|
return !0;
|
|
21
23
|
return !1;
|
|
22
|
-
}, ht = () => /* @__PURE__ */ new Set(),
|
|
24
|
+
}, ht = () => /* @__PURE__ */ new Set(), ze = (e) => e[e.length - 1], yr = (e, t) => {
|
|
23
25
|
for (let n = 0; n < t.length; n++)
|
|
24
26
|
e.push(t[n]);
|
|
25
27
|
}, X = Array.from, Tn = (e, t) => {
|
|
@@ -32,7 +34,7 @@ const x = () => /* @__PURE__ */ new Map(), an = (e) => {
|
|
|
32
34
|
if (t(e[n], n, e))
|
|
33
35
|
return !0;
|
|
34
36
|
return !1;
|
|
35
|
-
},
|
|
37
|
+
}, mr = (e, t) => {
|
|
36
38
|
const n = new Array(e);
|
|
37
39
|
for (let s = 0; s < e; s++)
|
|
38
40
|
n[s] = t(s, n);
|
|
@@ -100,7 +102,7 @@ class Vs {
|
|
|
100
102
|
this._observers = x();
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
|
-
class
|
|
105
|
+
class kr {
|
|
104
106
|
constructor() {
|
|
105
107
|
this._observers = x();
|
|
106
108
|
}
|
|
@@ -145,7 +147,7 @@ class yr {
|
|
|
145
147
|
this._observers = x();
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
|
-
const F = Math.floor, ge = Math.abs, Bs = (e, t) => e < t ? e : t, ft = (e, t) => e > t ? e : t, Fs = (e) => e !== 0 ? e < 0 : 1 / e < 0, es = 1, ns = 2,
|
|
150
|
+
const F = Math.floor, ge = Math.abs, Bs = (e, t) => e < t ? e : t, ft = (e, t) => e > t ? e : t, Fs = (e) => e !== 0 ? e < 0 : 1 / e < 0, es = 1, ns = 2, Xe = 4, qe = 8, Yt = 32, z = 64, R = 128, Bh = 1 << 29, Me = 31, un = 63, ot = 127, Sr = 2147483647, Se = Number.MAX_SAFE_INTEGER, ss = Number.MIN_SAFE_INTEGER, br = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && F(e) === e), js = String.fromCharCode, _r = (e) => e.toLowerCase(), Er = /^\s*/g, Cr = (e) => e.replace(Er, ""), Dr = /([A-Z])/g, is = (e, t) => Cr(e.replace(Dr, (n) => `${t}${_r(n)}`)), Ar = (e) => {
|
|
149
151
|
const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
|
|
150
152
|
for (let i = 0; i < n; i++)
|
|
151
153
|
s[i] = /** @type {number} */
|
|
@@ -154,32 +156,32 @@ const F = Math.floor, ge = Math.abs, Bs = (e, t) => e < t ? e : t, ft = (e, t) =
|
|
|
154
156
|
}, Gt = (
|
|
155
157
|
/** @type {TextEncoder} */
|
|
156
158
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
157
|
-
),
|
|
159
|
+
), Tr = (e) => Gt.encode(e), vr = Gt ? Tr : Ar;
|
|
158
160
|
let Ht = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
159
161
|
Ht && Ht.decode(new Uint8Array()).length === 1 && (Ht = null);
|
|
160
|
-
const
|
|
162
|
+
const Ir = (e, t) => mr(t, () => e).join("");
|
|
161
163
|
let ee = class {
|
|
162
164
|
constructor() {
|
|
163
165
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
164
166
|
}
|
|
165
167
|
};
|
|
166
|
-
const xt = () => new ee(),
|
|
168
|
+
const xt = () => new ee(), Ur = (e) => {
|
|
167
169
|
const t = xt();
|
|
168
170
|
return e(t), B(t);
|
|
169
|
-
},
|
|
171
|
+
}, Or = (e) => {
|
|
170
172
|
let t = e.cpos;
|
|
171
173
|
for (let n = 0; n < e.bufs.length; n++)
|
|
172
174
|
t += e.bufs[n].length;
|
|
173
175
|
return t;
|
|
174
176
|
}, B = (e) => {
|
|
175
|
-
const t = new Uint8Array(
|
|
177
|
+
const t = new Uint8Array(Or(e));
|
|
176
178
|
let n = 0;
|
|
177
179
|
for (let s = 0; s < e.bufs.length; s++) {
|
|
178
180
|
const i = e.bufs[s];
|
|
179
181
|
t.set(i, n), n += i.length;
|
|
180
182
|
}
|
|
181
183
|
return t.set(new Uint8Array(e.cbuf.buffer, 0, e.cpos), n), t;
|
|
182
|
-
},
|
|
184
|
+
}, Lr = (e, t) => {
|
|
183
185
|
const n = e.cbuf.length;
|
|
184
186
|
n - e.cpos < t && (e.bufs.push(new Uint8Array(e.cbuf.buffer, 0, e.cpos)), e.cbuf = new Uint8Array(ft(n, t) * 2), e.cpos = 0);
|
|
185
187
|
}, A = (e, t) => {
|
|
@@ -193,15 +195,15 @@ const xt = () => new ee(), vr = (e) => {
|
|
|
193
195
|
const n = Fs(t);
|
|
194
196
|
for (n && (t = -t), A(e, (t > un ? R : 0) | (n ? z : 0) | un & t), t = F(t / 64); t > 0; )
|
|
195
197
|
A(e, (t > ot ? R : 0) | ot & t), t = F(t / 128);
|
|
196
|
-
}, fn = new Uint8Array(3e4),
|
|
197
|
-
if (t.length <
|
|
198
|
+
}, fn = new Uint8Array(3e4), Nr = fn.length / 3, xr = (e, t) => {
|
|
199
|
+
if (t.length < Nr) {
|
|
198
200
|
const n = Gt.encodeInto(t, fn).written || 0;
|
|
199
201
|
w(e, n);
|
|
200
202
|
for (let s = 0; s < n; s++)
|
|
201
203
|
A(e, fn[s]);
|
|
202
204
|
} else
|
|
203
|
-
I(e,
|
|
204
|
-
},
|
|
205
|
+
I(e, vr(t));
|
|
206
|
+
}, Rr = (e, t) => {
|
|
205
207
|
const n = unescape(encodeURIComponent(t)), s = n.length;
|
|
206
208
|
w(e, s);
|
|
207
209
|
for (let i = 0; i < s; i++)
|
|
@@ -211,28 +213,28 @@ const xt = () => new ee(), vr = (e) => {
|
|
|
211
213
|
n.codePointAt(i)
|
|
212
214
|
);
|
|
213
215
|
}, ct = Gt && /** @type {any} */
|
|
214
|
-
Gt.encodeInto ?
|
|
216
|
+
Gt.encodeInto ? xr : Rr, $e = (e, t) => {
|
|
215
217
|
const n = e.cbuf.length, s = e.cpos, i = Bs(n - s, t.length), r = t.length - i;
|
|
216
218
|
e.cbuf.set(t.subarray(0, i), s), e.cpos += i, r > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(ft(n * 2, r)), e.cbuf.set(t.subarray(i)), e.cpos = r);
|
|
217
219
|
}, I = (e, t) => {
|
|
218
|
-
w(e, t.byteLength),
|
|
220
|
+
w(e, t.byteLength), $e(e, t);
|
|
219
221
|
}, Un = (e, t) => {
|
|
220
|
-
|
|
222
|
+
Lr(e, t);
|
|
221
223
|
const n = new DataView(e.cbuf.buffer, e.cpos, t);
|
|
222
224
|
return e.cpos += t, n;
|
|
223
|
-
},
|
|
225
|
+
}, Mr = (e, t) => Un(e, 4).setFloat32(0, t, !1), $r = (e, t) => Un(e, 8).setFloat64(0, t, !1), Vr = (e, t) => (
|
|
224
226
|
/** @type {any} */
|
|
225
227
|
Un(e, 8).setBigInt64(0, t, !1)
|
|
226
|
-
), rs = new DataView(new ArrayBuffer(4)),
|
|
228
|
+
), rs = new DataView(new ArrayBuffer(4)), Br = (e) => (rs.setFloat32(0, e), rs.getFloat32(0) === e), Dt = (e, t) => {
|
|
227
229
|
switch (typeof t) {
|
|
228
230
|
case "string":
|
|
229
231
|
A(e, 119), ct(e, t);
|
|
230
232
|
break;
|
|
231
233
|
case "number":
|
|
232
|
-
|
|
234
|
+
br(t) && ge(t) <= Sr ? (A(e, 125), In(e, t)) : Br(t) ? (A(e, 124), Mr(e, t)) : (A(e, 123), $r(e, t));
|
|
233
235
|
break;
|
|
234
236
|
case "bigint":
|
|
235
|
-
A(e, 122),
|
|
237
|
+
A(e, 122), Vr(e, t);
|
|
236
238
|
break;
|
|
237
239
|
case "object":
|
|
238
240
|
if (t === null)
|
|
@@ -302,7 +304,7 @@ const ls = (e) => {
|
|
|
302
304
|
In(e.encoder, t), e.count > 1 && w(e.encoder, e.count - 2);
|
|
303
305
|
}
|
|
304
306
|
};
|
|
305
|
-
class
|
|
307
|
+
class Qe {
|
|
306
308
|
constructor() {
|
|
307
309
|
this.encoder = new ee(), this.s = 0, this.count = 0, this.diff = 0;
|
|
308
310
|
}
|
|
@@ -321,7 +323,7 @@ class qe {
|
|
|
321
323
|
return ls(this), B(this.encoder);
|
|
322
324
|
}
|
|
323
325
|
}
|
|
324
|
-
class
|
|
326
|
+
class Fr {
|
|
325
327
|
constructor() {
|
|
326
328
|
this.sarr = [], this.s = "", this.lensE = new pe();
|
|
327
329
|
}
|
|
@@ -333,7 +335,7 @@ class Vr {
|
|
|
333
335
|
}
|
|
334
336
|
toUint8Array() {
|
|
335
337
|
const t = new ee();
|
|
336
|
-
return this.sarr.push(this.s), this.s = "", ct(t, this.sarr.join("")),
|
|
338
|
+
return this.sarr.push(this.s), this.s = "", ct(t, this.sarr.join("")), $e(t, this.lensE.toUint8Array()), B(t);
|
|
337
339
|
}
|
|
338
340
|
}
|
|
339
341
|
const Y = (e) => new Error(e), K = () => {
|
|
@@ -341,7 +343,7 @@ const Y = (e) => new Error(e), K = () => {
|
|
|
341
343
|
}, M = () => {
|
|
342
344
|
throw Y("Unexpected case");
|
|
343
345
|
}, Ks = Y("Unexpected end of array"), Hs = Y("Integer out of Range");
|
|
344
|
-
let
|
|
346
|
+
let Ve = class {
|
|
345
347
|
/**
|
|
346
348
|
* @param {Uint8Array<Buf>} uint8Array Binary data to decode
|
|
347
349
|
*/
|
|
@@ -349,17 +351,17 @@ let $e = class {
|
|
|
349
351
|
this.arr = t, this.pos = 0;
|
|
350
352
|
}
|
|
351
353
|
};
|
|
352
|
-
const gt = (e) => new
|
|
354
|
+
const gt = (e) => new Ve(e), jr = (e) => e.pos !== e.arr.length, Kr = (e, t) => {
|
|
353
355
|
const n = new Uint8Array(e.arr.buffer, e.pos + e.arr.byteOffset, t);
|
|
354
356
|
return e.pos += t, n;
|
|
355
|
-
}, L = (e) =>
|
|
357
|
+
}, L = (e) => Kr(e, y(e)), At = (e) => e.arr[e.pos++], y = (e) => {
|
|
356
358
|
let t = 0, n = 1;
|
|
357
359
|
const s = e.arr.length;
|
|
358
360
|
for (; e.pos < s; ) {
|
|
359
361
|
const i = e.arr[e.pos++];
|
|
360
362
|
if (t = t + (i & ot) * n, n *= 128, i < R)
|
|
361
363
|
return t;
|
|
362
|
-
if (t >
|
|
364
|
+
if (t > Se)
|
|
363
365
|
throw Hs;
|
|
364
366
|
}
|
|
365
367
|
throw Ks;
|
|
@@ -372,11 +374,11 @@ const gt = (e) => new $e(e), Br = (e) => e.pos !== e.arr.length, Fr = (e, t) =>
|
|
|
372
374
|
for (; e.pos < r; ) {
|
|
373
375
|
if (t = e.arr[e.pos++], n = n + (t & ot) * s, s *= 128, t < R)
|
|
374
376
|
return i * n;
|
|
375
|
-
if (n >
|
|
377
|
+
if (n > Se)
|
|
376
378
|
throw Hs;
|
|
377
379
|
}
|
|
378
380
|
throw Ks;
|
|
379
|
-
},
|
|
381
|
+
}, Hr = (e) => {
|
|
380
382
|
let t = y(e);
|
|
381
383
|
if (t === 0)
|
|
382
384
|
return "";
|
|
@@ -396,16 +398,16 @@ const gt = (e) => new $e(e), Br = (e) => e.pos !== e.arr.length, Fr = (e, t) =>
|
|
|
396
398
|
}
|
|
397
399
|
return decodeURIComponent(escape(n));
|
|
398
400
|
}
|
|
399
|
-
},
|
|
401
|
+
}, Yr = (e) => (
|
|
400
402
|
/** @type any */
|
|
401
403
|
Ht.decode(L(e))
|
|
402
|
-
), lt = Ht ?
|
|
404
|
+
), lt = Ht ? Yr : Hr, Ln = (e, t) => {
|
|
403
405
|
const n = new DataView(e.arr.buffer, e.arr.byteOffset + e.pos, t);
|
|
404
406
|
return e.pos += t, n;
|
|
405
|
-
},
|
|
407
|
+
}, Gr = (e) => Ln(e, 4).getFloat32(0, !1), Pr = (e) => Ln(e, 8).getFloat64(0, !1), Jr = (e) => (
|
|
406
408
|
/** @type {any} */
|
|
407
409
|
Ln(e, 8).getBigInt64(0, !1)
|
|
408
|
-
),
|
|
410
|
+
), Wr = [
|
|
409
411
|
(e) => {
|
|
410
412
|
},
|
|
411
413
|
// CASE 127: undefined
|
|
@@ -413,11 +415,11 @@ const gt = (e) => new $e(e), Br = (e) => e.pos !== e.arr.length, Fr = (e, t) =>
|
|
|
413
415
|
// CASE 126: null
|
|
414
416
|
On,
|
|
415
417
|
// CASE 125: integer
|
|
416
|
-
|
|
418
|
+
Gr,
|
|
417
419
|
// CASE 124: float32
|
|
418
|
-
|
|
420
|
+
Pr,
|
|
419
421
|
// CASE 123: float64
|
|
420
|
-
|
|
422
|
+
Jr,
|
|
421
423
|
// CASE 122: bigint
|
|
422
424
|
(e) => !1,
|
|
423
425
|
// CASE 121: boolean (false)
|
|
@@ -441,8 +443,8 @@ const gt = (e) => new $e(e), Br = (e) => e.pos !== e.arr.length, Fr = (e, t) =>
|
|
|
441
443
|
},
|
|
442
444
|
L
|
|
443
445
|
// CASE 116: Uint8Array
|
|
444
|
-
], Pt = (e) =>
|
|
445
|
-
class hs extends
|
|
446
|
+
], Pt = (e) => Wr[127 - At(e)](e);
|
|
447
|
+
class hs extends Ve {
|
|
446
448
|
/**
|
|
447
449
|
* @param {Uint8Array} uint8Array
|
|
448
450
|
* @param {function(Decoder):T} reader
|
|
@@ -451,11 +453,11 @@ class hs extends $e {
|
|
|
451
453
|
super(t), this.reader = n, this.s = null, this.count = 0;
|
|
452
454
|
}
|
|
453
455
|
read() {
|
|
454
|
-
return this.count === 0 && (this.s = this.reader(this),
|
|
456
|
+
return this.count === 0 && (this.s = this.reader(this), jr(this) ? this.count = y(this) + 1 : this.count = -1), this.count--, /** @type {T} */
|
|
455
457
|
this.s;
|
|
456
458
|
}
|
|
457
459
|
}
|
|
458
|
-
class we extends
|
|
460
|
+
class we extends Ve {
|
|
459
461
|
/**
|
|
460
462
|
* @param {Uint8Array} uint8Array
|
|
461
463
|
*/
|
|
@@ -472,7 +474,7 @@ class we extends $e {
|
|
|
472
474
|
this.s;
|
|
473
475
|
}
|
|
474
476
|
}
|
|
475
|
-
class
|
|
477
|
+
class Ze extends Ve {
|
|
476
478
|
/**
|
|
477
479
|
* @param {Uint8Array} uint8Array
|
|
478
480
|
*/
|
|
@@ -490,7 +492,7 @@ class Qe extends $e {
|
|
|
490
492
|
return this.s += this.diff, this.count--, this.s;
|
|
491
493
|
}
|
|
492
494
|
}
|
|
493
|
-
class
|
|
495
|
+
class zr {
|
|
494
496
|
/**
|
|
495
497
|
* @param {Uint8Array} uint8Array
|
|
496
498
|
*/
|
|
@@ -505,7 +507,7 @@ class Jr {
|
|
|
505
507
|
return this.spos = t, n;
|
|
506
508
|
}
|
|
507
509
|
}
|
|
508
|
-
const
|
|
510
|
+
const Xr = crypto.getRandomValues.bind(crypto), qr = Math.random, Ys = () => Xr(new Uint32Array(1))[0], Kh = (e) => e[F(qr() * e.length)], Qr = "10000000-1000-4000-8000" + -1e11, Zr = () => Qr.replace(
|
|
509
511
|
/[018]/g,
|
|
510
512
|
/** @param {number} c */
|
|
511
513
|
(e) => (e ^ Ys() & 15 >> e / 4).toString(16)
|
|
@@ -515,7 +517,7 @@ const Wr = crypto.getRandomValues.bind(crypto), zr = Math.random, Ys = () => Wr(
|
|
|
515
517
|
);
|
|
516
518
|
Promise.all.bind(Promise);
|
|
517
519
|
const us = (e) => e === void 0 ? null : e;
|
|
518
|
-
class
|
|
520
|
+
class to {
|
|
519
521
|
constructor() {
|
|
520
522
|
this.map = /* @__PURE__ */ new Map();
|
|
521
523
|
}
|
|
@@ -533,18 +535,18 @@ class Qr {
|
|
|
533
535
|
return this.map.get(t);
|
|
534
536
|
}
|
|
535
537
|
}
|
|
536
|
-
let Gs = new
|
|
538
|
+
let Gs = new to(), eo = !0;
|
|
537
539
|
try {
|
|
538
|
-
typeof localStorage < "u" && localStorage && (Gs = localStorage,
|
|
540
|
+
typeof localStorage < "u" && localStorage && (Gs = localStorage, eo = !1);
|
|
539
541
|
} catch {
|
|
540
542
|
}
|
|
541
|
-
const
|
|
543
|
+
const no = Gs, Wt = Symbol("Equality"), Ps = (e, t) => {
|
|
542
544
|
var n;
|
|
543
545
|
return e === t || !!((n = e == null ? void 0 : e[Wt]) != null && n.call(e, t)) || !1;
|
|
544
|
-
},
|
|
546
|
+
}, so = (e) => typeof e == "object", io = Object.assign, ro = Object.keys, oo = (e, t) => {
|
|
545
547
|
for (const n in e)
|
|
546
548
|
t(e[n], n);
|
|
547
|
-
},
|
|
549
|
+
}, be = (e) => ro(e).length, co = (e) => {
|
|
548
550
|
for (const t in e)
|
|
549
551
|
return !1;
|
|
550
552
|
return !0;
|
|
@@ -553,12 +555,12 @@ const to = Gs, Wt = Symbol("Equality"), Ps = (e, t) => {
|
|
|
553
555
|
if (!t(e[n], n))
|
|
554
556
|
return !1;
|
|
555
557
|
return !0;
|
|
556
|
-
}, Nn = (e, t) => Object.prototype.hasOwnProperty.call(e, t),
|
|
558
|
+
}, Nn = (e, t) => Object.prototype.hasOwnProperty.call(e, t), lo = (e, t) => e === t || be(e) === be(t) && ne(e, (n, s) => (n !== void 0 || Nn(t, s)) && Ps(t[s], n)), ho = Object.freeze, Js = (e) => {
|
|
557
559
|
for (const t in e) {
|
|
558
560
|
const n = e[t];
|
|
559
561
|
(typeof n == "object" || typeof n == "function") && Js(e[t]);
|
|
560
562
|
}
|
|
561
|
-
return
|
|
563
|
+
return ho(e);
|
|
562
564
|
}, xn = (e, t, n = 0) => {
|
|
563
565
|
try {
|
|
564
566
|
for (; n < e.length; n++)
|
|
@@ -566,7 +568,7 @@ const to = Gs, Wt = Symbol("Equality"), Ps = (e, t) => {
|
|
|
566
568
|
} finally {
|
|
567
569
|
n < e.length && xn(e, t, n + 1);
|
|
568
570
|
}
|
|
569
|
-
},
|
|
571
|
+
}, ao = (e) => e, kt = (e, t) => {
|
|
570
572
|
if (e === t)
|
|
571
573
|
return !0;
|
|
572
574
|
if (e == null || t == null || e.constructor !== t.constructor && (e.constructor || Object) !== (t.constructor || Object))
|
|
@@ -602,7 +604,7 @@ const to = Gs, Wt = Symbol("Equality"), Ps = (e, t) => {
|
|
|
602
604
|
}
|
|
603
605
|
case void 0:
|
|
604
606
|
case Object:
|
|
605
|
-
if (
|
|
607
|
+
if (be(e) !== be(t))
|
|
606
608
|
return !1;
|
|
607
609
|
for (const n in e)
|
|
608
610
|
if (!Nn(e, n) || !kt(e[n], t[n]))
|
|
@@ -619,9 +621,9 @@ const to = Gs, Wt = Symbol("Equality"), Ps = (e, t) => {
|
|
|
619
621
|
return !1;
|
|
620
622
|
}
|
|
621
623
|
return !0;
|
|
622
|
-
},
|
|
624
|
+
}, uo = (e, t) => t.includes(e), Tt = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process < "u" ? process : 0) === "[object process]", fo = typeof window < "u" && typeof document < "u" && !Tt;
|
|
623
625
|
let H;
|
|
624
|
-
const
|
|
626
|
+
const go = () => {
|
|
625
627
|
if (H === void 0)
|
|
626
628
|
if (Tt) {
|
|
627
629
|
H = x();
|
|
@@ -639,17 +641,17 @@ const uo = () => {
|
|
|
639
641
|
}
|
|
640
642
|
})) : H = x();
|
|
641
643
|
return H;
|
|
642
|
-
}, gn = (e) =>
|
|
643
|
-
!Ws("no-color") && (!Tt || process.stdout.isTTY) && (!Tt || gn("--color") ||
|
|
644
|
+
}, gn = (e) => go().has(e), _e = (e) => us(Tt ? process.env[e.toUpperCase().replaceAll("-", "_")] : no.getItem(e)), Ws = (e) => gn("--" + e) || _e(e) !== null, po = Ws("production"), wo = Tt && uo(process.env.FORCE_COLOR, ["true", "1", "2"]), yo = wo || !gn("--no-colors") && // @todo deprecate --no-colors
|
|
645
|
+
!Ws("no-color") && (!Tt || process.stdout.isTTY) && (!Tt || gn("--color") || _e("COLORTERM") !== null || (_e("TERM") || "").includes("color")), mo = (e) => new Uint8Array(e), ko = (e) => {
|
|
644
646
|
let t = "";
|
|
645
647
|
for (let n = 0; n < e.byteLength; n++)
|
|
646
648
|
t += js(e[n]);
|
|
647
649
|
return btoa(t);
|
|
648
|
-
},
|
|
649
|
-
const t =
|
|
650
|
+
}, So = (e) => Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("base64"), Hh = fo ? ko : So, bo = (e) => {
|
|
651
|
+
const t = mo(e.byteLength);
|
|
650
652
|
return t.set(e), t;
|
|
651
|
-
},
|
|
652
|
-
class
|
|
653
|
+
}, Yh = (e) => Ur((t) => Dt(t, e));
|
|
654
|
+
class _o {
|
|
653
655
|
/**
|
|
654
656
|
* @param {L} left
|
|
655
657
|
* @param {R} right
|
|
@@ -658,14 +660,14 @@ class So {
|
|
|
658
660
|
this.left = t, this.right = n;
|
|
659
661
|
}
|
|
660
662
|
}
|
|
661
|
-
const W = (e, t) => new
|
|
663
|
+
const W = (e, t) => new _o(e, t), ds = (e) => e.next() >= 0.5, tn = (e, t, n) => F(e.next() * (n + 1 - t) + t), zs = (e, t, n) => F(e.next() * (n + 1 - t) + t), Rn = (e, t, n) => zs(e, t, n), Eo = (e) => js(Rn(e, 97, 122)), Co = (e, t = 0, n = 20) => {
|
|
662
664
|
const s = Rn(e, t, n);
|
|
663
665
|
let i = "";
|
|
664
666
|
for (let r = 0; r < s; r++)
|
|
665
|
-
i +=
|
|
667
|
+
i += Eo(e);
|
|
666
668
|
return i;
|
|
667
|
-
},
|
|
668
|
-
class
|
|
669
|
+
}, en = (e, t) => t[Rn(e, 0, t.length - 1)], Do = Symbol("0schema");
|
|
670
|
+
class Ao {
|
|
669
671
|
constructor() {
|
|
670
672
|
this._rerrs = [];
|
|
671
673
|
}
|
|
@@ -682,7 +684,7 @@ class Co {
|
|
|
682
684
|
const t = [];
|
|
683
685
|
for (let n = this._rerrs.length - 1; n > 0; n--) {
|
|
684
686
|
const s = this._rerrs[n];
|
|
685
|
-
t.push(
|
|
687
|
+
t.push(Ir(" ", (this._rerrs.length - n) * 2) + `${s.path != null ? `[${s.path}] ` : ""}${s.has} doesn't match ${s.expected}. ${s.message}`);
|
|
686
688
|
}
|
|
687
689
|
return t.join(`
|
|
688
690
|
`);
|
|
@@ -691,7 +693,7 @@ class Co {
|
|
|
691
693
|
const pn = (e, t) => e === t ? !0 : e == null || t == null || e.constructor !== t.constructor ? !1 : e[Wt] ? Ps(e, t) : Ct(e) ? Tn(
|
|
692
694
|
e,
|
|
693
695
|
(n) => vn(t, (s) => pn(n, s))
|
|
694
|
-
) :
|
|
696
|
+
) : so(e) ? ne(
|
|
695
697
|
e,
|
|
696
698
|
(n, s) => pn(n, t[s])
|
|
697
699
|
) : !1;
|
|
@@ -719,7 +721,7 @@ class O {
|
|
|
719
721
|
equals(t) {
|
|
720
722
|
return this.constructor === t.constructor && kt(this.shape, t.shape);
|
|
721
723
|
}
|
|
722
|
-
[
|
|
724
|
+
[Do]() {
|
|
723
725
|
return !0;
|
|
724
726
|
}
|
|
725
727
|
/**
|
|
@@ -758,7 +760,7 @@ class O {
|
|
|
758
760
|
* @type {Schema<T?>}
|
|
759
761
|
*/
|
|
760
762
|
get nullable() {
|
|
761
|
-
return Rt(this,
|
|
763
|
+
return Rt(this, He);
|
|
762
764
|
}
|
|
763
765
|
/**
|
|
764
766
|
* @type {$Optional<Schema<T>>}
|
|
@@ -854,7 +856,7 @@ class $n extends O {
|
|
|
854
856
|
}
|
|
855
857
|
const v = (e) => new $n(e);
|
|
856
858
|
C($n);
|
|
857
|
-
class
|
|
859
|
+
class Be extends O {
|
|
858
860
|
/**
|
|
859
861
|
* @param {Array<T>} literals
|
|
860
862
|
*/
|
|
@@ -872,13 +874,13 @@ class Ve extends O {
|
|
|
872
874
|
return !s && (n == null || n.extend(null, this.shape.join(" | "), t.toString())), s;
|
|
873
875
|
}
|
|
874
876
|
}
|
|
875
|
-
const
|
|
877
|
+
const Fe = (...e) => new Be(e), Xs = C(Be), To = (
|
|
876
878
|
/** @type {any} */
|
|
877
879
|
RegExp.escape || /** @type {(str:string) => string} */
|
|
878
880
|
((e) => e.replace(/[().|&,$^[\]]/g, (t) => "\\" + t))
|
|
879
881
|
), qs = (e) => {
|
|
880
882
|
if (vt.check(e))
|
|
881
|
-
return [
|
|
883
|
+
return [To(e)];
|
|
882
884
|
if (Xs.check(e))
|
|
883
885
|
return (
|
|
884
886
|
/** @type {Array<string|number>} */
|
|
@@ -888,11 +890,11 @@ const Be = (...e) => new Ve(e), Xs = C(Ve), Do = (
|
|
|
888
890
|
return ["[+-]?\\d+.?\\d*"];
|
|
889
891
|
if (li.check(e))
|
|
890
892
|
return [".*"];
|
|
891
|
-
if (
|
|
893
|
+
if (Ce.check(e))
|
|
892
894
|
return e.shape.map(qs).flat(1);
|
|
893
895
|
M();
|
|
894
896
|
};
|
|
895
|
-
class
|
|
897
|
+
class vo extends O {
|
|
896
898
|
/**
|
|
897
899
|
* @param {T} shape
|
|
898
900
|
*/
|
|
@@ -909,8 +911,8 @@ class Ao extends O {
|
|
|
909
911
|
return !s && (n == null || n.extend(null, this._r.toString(), t.toString(), "String doesn't match string template.")), s;
|
|
910
912
|
}
|
|
911
913
|
}
|
|
912
|
-
C(
|
|
913
|
-
const
|
|
914
|
+
C(vo);
|
|
915
|
+
const Io = Symbol("optional");
|
|
914
916
|
class Qs extends O {
|
|
915
917
|
/**
|
|
916
918
|
* @param {S} shape
|
|
@@ -927,12 +929,12 @@ class Qs extends O {
|
|
|
927
929
|
const s = t === void 0 || this.shape.check(t);
|
|
928
930
|
return !s && (n == null || n.extend(null, "undefined (optional)", "()")), s;
|
|
929
931
|
}
|
|
930
|
-
get [
|
|
932
|
+
get [Io]() {
|
|
931
933
|
return !0;
|
|
932
934
|
}
|
|
933
935
|
}
|
|
934
|
-
const
|
|
935
|
-
class
|
|
936
|
+
const Uo = C(Qs);
|
|
937
|
+
class Oo extends O {
|
|
936
938
|
/**
|
|
937
939
|
* @param {any} _o
|
|
938
940
|
* @param {ValidationError} [err]
|
|
@@ -942,8 +944,8 @@ class Io extends O {
|
|
|
942
944
|
return n == null || n.extend(null, "never", typeof t), !1;
|
|
943
945
|
}
|
|
944
946
|
}
|
|
945
|
-
C(
|
|
946
|
-
const
|
|
947
|
+
C(Oo);
|
|
948
|
+
const Re = class Re extends O {
|
|
947
949
|
/**
|
|
948
950
|
* @param {S} shape
|
|
949
951
|
* @param {boolean} partial
|
|
@@ -955,7 +957,7 @@ const xe = class xe extends O {
|
|
|
955
957
|
* @type {Schema<Partial<$ObjectToType<S>>>}
|
|
956
958
|
*/
|
|
957
959
|
get partial() {
|
|
958
|
-
return new
|
|
960
|
+
return new Re(this.shape, !0);
|
|
959
961
|
}
|
|
960
962
|
/**
|
|
961
963
|
* @param {any} o
|
|
@@ -969,12 +971,12 @@ const xe = class xe extends O {
|
|
|
969
971
|
});
|
|
970
972
|
}
|
|
971
973
|
};
|
|
972
|
-
le(
|
|
973
|
-
let
|
|
974
|
-
const
|
|
974
|
+
le(Re, "_dilutes", !0);
|
|
975
|
+
let Ee = Re;
|
|
976
|
+
const Lo = (e) => (
|
|
975
977
|
/** @type {any} */
|
|
976
|
-
new
|
|
977
|
-
),
|
|
978
|
+
new Ee(e)
|
|
979
|
+
), No = C(Ee), xo = v((e) => e != null && (e.constructor === Object || e.constructor == null));
|
|
978
980
|
class Zs extends O {
|
|
979
981
|
/**
|
|
980
982
|
* @param {Keys} keys
|
|
@@ -998,7 +1000,7 @@ class Zs extends O {
|
|
|
998
1000
|
});
|
|
999
1001
|
}
|
|
1000
1002
|
}
|
|
1001
|
-
const ti = (e, t) => new Zs(e, t),
|
|
1003
|
+
const ti = (e, t) => new Zs(e, t), Ro = C(Zs);
|
|
1002
1004
|
class ei extends O {
|
|
1003
1005
|
/**
|
|
1004
1006
|
* @param {S} shape
|
|
@@ -1021,14 +1023,14 @@ class ei extends O {
|
|
|
1021
1023
|
});
|
|
1022
1024
|
}
|
|
1023
1025
|
}
|
|
1024
|
-
const
|
|
1026
|
+
const Mo = (...e) => new ei(e);
|
|
1025
1027
|
C(ei);
|
|
1026
1028
|
class ni extends O {
|
|
1027
1029
|
/**
|
|
1028
1030
|
* @param {Array<S>} v
|
|
1029
1031
|
*/
|
|
1030
1032
|
constructor(t) {
|
|
1031
|
-
super(), this.shape = t.length === 1 ? t[0] : new
|
|
1033
|
+
super(), this.shape = t.length === 1 ? t[0] : new je(t);
|
|
1032
1034
|
}
|
|
1033
1035
|
/**
|
|
1034
1036
|
* @param {any} o
|
|
@@ -1040,7 +1042,7 @@ class ni extends O {
|
|
|
1040
1042
|
return !s && (n == null || n.extend(null, "Array", "")), s;
|
|
1041
1043
|
}
|
|
1042
1044
|
}
|
|
1043
|
-
const si = (...e) => new ni(e),
|
|
1045
|
+
const si = (...e) => new ni(e), $o = C(ni), Vo = v((e) => Ct(e));
|
|
1044
1046
|
class ii extends O {
|
|
1045
1047
|
/**
|
|
1046
1048
|
* @param {new (...args:any) => T} constructor
|
|
@@ -1059,15 +1061,15 @@ class ii extends O {
|
|
|
1059
1061
|
return !s && (n == null || n.extend(null, this.shape.name, t == null ? void 0 : t.constructor.name)), s;
|
|
1060
1062
|
}
|
|
1061
1063
|
}
|
|
1062
|
-
const
|
|
1064
|
+
const Bo = (e, t = null) => new ii(e, t);
|
|
1063
1065
|
C(ii);
|
|
1064
|
-
const
|
|
1065
|
-
class
|
|
1066
|
+
const Fo = Bo(O);
|
|
1067
|
+
class jo extends O {
|
|
1066
1068
|
/**
|
|
1067
1069
|
* @param {Args} args
|
|
1068
1070
|
*/
|
|
1069
1071
|
constructor(t) {
|
|
1070
|
-
super(), this.len = t.length - 1, this.args =
|
|
1072
|
+
super(), this.len = t.length - 1, this.args = Mo(...t.slice(-1)), this.res = t[this.len];
|
|
1071
1073
|
}
|
|
1072
1074
|
/**
|
|
1073
1075
|
* @param {any} f
|
|
@@ -1079,8 +1081,8 @@ class Bo extends O {
|
|
|
1079
1081
|
return !s && (n == null || n.extend(null, "function", typeof t)), s;
|
|
1080
1082
|
}
|
|
1081
1083
|
}
|
|
1082
|
-
const
|
|
1083
|
-
class
|
|
1084
|
+
const Ko = C(jo), Ho = v((e) => typeof e == "function");
|
|
1085
|
+
class Yo extends O {
|
|
1084
1086
|
/**
|
|
1085
1087
|
* @param {T} v
|
|
1086
1088
|
*/
|
|
@@ -1097,8 +1099,8 @@ class Ko extends O {
|
|
|
1097
1099
|
return !s && (n == null || n.extend(null, "Intersectinon", typeof t)), s;
|
|
1098
1100
|
}
|
|
1099
1101
|
}
|
|
1100
|
-
C(
|
|
1101
|
-
class
|
|
1102
|
+
C(Yo, (e) => e.shape.length > 0);
|
|
1103
|
+
class je extends O {
|
|
1102
1104
|
/**
|
|
1103
1105
|
* @param {Array<Schema<S>>} v
|
|
1104
1106
|
*/
|
|
@@ -1115,14 +1117,14 @@ class Fe extends O {
|
|
|
1115
1117
|
return n == null || n.extend(null, "Union", typeof t), s;
|
|
1116
1118
|
}
|
|
1117
1119
|
}
|
|
1118
|
-
le(
|
|
1119
|
-
const Rt = (...e) => e.findIndex((t) =>
|
|
1120
|
+
le(je, "_dilutes", !0);
|
|
1121
|
+
const Rt = (...e) => e.findIndex((t) => Ce.check(t)) >= 0 ? Rt(...e.map((t) => zt(t)).map((t) => Ce.check(t) ? t.shape : [t]).flat(1)) : e.length === 1 ? e[0] : new je(e), Ce = (
|
|
1120
1122
|
/** @type {Schema<$Union<any>>} */
|
|
1121
|
-
C(
|
|
1122
|
-
), ri = () => !0,
|
|
1123
|
+
C(je)
|
|
1124
|
+
), ri = () => !0, De = v(ri), Go = (
|
|
1123
1125
|
/** @type {Schema<Schema<any>>} */
|
|
1124
1126
|
C($n, (e) => e.shape === ri)
|
|
1125
|
-
), Vn = v((e) => typeof e == "bigint"),
|
|
1127
|
+
), Vn = v((e) => typeof e == "bigint"), Po = (
|
|
1126
1128
|
/** @type {Schema<Schema<BigInt>>} */
|
|
1127
1129
|
v((e) => e === Vn)
|
|
1128
1130
|
), oi = v((e) => typeof e == "symbol");
|
|
@@ -1133,55 +1135,55 @@ const St = v((e) => typeof e == "number"), ci = (
|
|
|
1133
1135
|
), vt = v((e) => typeof e == "string"), li = (
|
|
1134
1136
|
/** @type {Schema<Schema<string>>} */
|
|
1135
1137
|
v((e) => e === vt)
|
|
1136
|
-
),
|
|
1138
|
+
), Ke = v((e) => typeof e == "boolean"), Jo = (
|
|
1137
1139
|
/** @type {Schema<Schema<Boolean>>} */
|
|
1138
|
-
v((e) => e ===
|
|
1139
|
-
), hi =
|
|
1140
|
-
C(
|
|
1141
|
-
|
|
1142
|
-
const
|
|
1140
|
+
v((e) => e === Ke)
|
|
1141
|
+
), hi = Fe(void 0);
|
|
1142
|
+
C(Be, (e) => e.shape.length === 1 && e.shape[0] === void 0);
|
|
1143
|
+
Fe(void 0);
|
|
1144
|
+
const He = Fe(null), Wo = (
|
|
1143
1145
|
/** @type {Schema<Schema<null>>} */
|
|
1144
|
-
C(
|
|
1146
|
+
C(Be, (e) => e.shape.length === 1 && e.shape[0] === null)
|
|
1145
1147
|
);
|
|
1146
1148
|
C(Uint8Array);
|
|
1147
1149
|
C(Mn, (e) => e.shape === Uint8Array);
|
|
1148
|
-
const
|
|
1150
|
+
const zo = Rt(St, vt, He, hi, Vn, Ke, oi);
|
|
1149
1151
|
(() => {
|
|
1150
1152
|
const e = (
|
|
1151
1153
|
/** @type {$Array<$any>} */
|
|
1152
|
-
si(
|
|
1154
|
+
si(De)
|
|
1153
1155
|
), t = (
|
|
1154
1156
|
/** @type {$Record<$string,$any>} */
|
|
1155
|
-
ti(vt,
|
|
1156
|
-
), n = Rt(St, vt,
|
|
1157
|
+
ti(vt, De)
|
|
1158
|
+
), n = Rt(St, vt, He, Ke, e, t);
|
|
1157
1159
|
return e.shape = n, t.shape.values = n, n;
|
|
1158
1160
|
})();
|
|
1159
1161
|
const zt = (e) => {
|
|
1160
|
-
if (
|
|
1162
|
+
if (Fo.check(e))
|
|
1161
1163
|
return (
|
|
1162
1164
|
/** @type {any} */
|
|
1163
1165
|
e
|
|
1164
1166
|
);
|
|
1165
|
-
if (
|
|
1167
|
+
if (xo.check(e)) {
|
|
1166
1168
|
const t = {};
|
|
1167
1169
|
for (const n in e)
|
|
1168
1170
|
t[n] = zt(e[n]);
|
|
1169
1171
|
return (
|
|
1170
1172
|
/** @type {any} */
|
|
1171
|
-
|
|
1173
|
+
Lo(t)
|
|
1172
1174
|
);
|
|
1173
1175
|
} else {
|
|
1174
|
-
if (
|
|
1176
|
+
if (Vo.check(e))
|
|
1175
1177
|
return (
|
|
1176
1178
|
/** @type {any} */
|
|
1177
1179
|
Rt(...e.map(zt))
|
|
1178
1180
|
);
|
|
1179
|
-
if (
|
|
1181
|
+
if (zo.check(e))
|
|
1180
1182
|
return (
|
|
1181
1183
|
/** @type {any} */
|
|
1182
|
-
|
|
1184
|
+
Fe(e)
|
|
1183
1185
|
);
|
|
1184
|
-
if (
|
|
1186
|
+
if (Ho.check(e))
|
|
1185
1187
|
return (
|
|
1186
1188
|
/** @type {any} */
|
|
1187
1189
|
C(
|
|
@@ -1191,14 +1193,14 @@ const zt = (e) => {
|
|
|
1191
1193
|
);
|
|
1192
1194
|
}
|
|
1193
1195
|
M();
|
|
1194
|
-
}, fs =
|
|
1196
|
+
}, fs = po ? () => {
|
|
1195
1197
|
} : (e, t) => {
|
|
1196
|
-
const n = new
|
|
1198
|
+
const n = new Ao();
|
|
1197
1199
|
if (!t.check(e, n))
|
|
1198
1200
|
throw Y(`Expected value to be of type ${t.constructor.name}.
|
|
1199
1201
|
${n.toString()}`);
|
|
1200
1202
|
};
|
|
1201
|
-
class
|
|
1203
|
+
class Xo {
|
|
1202
1204
|
/**
|
|
1203
1205
|
* @param {Schema<State>} [$state]
|
|
1204
1206
|
*/
|
|
@@ -1220,7 +1222,7 @@ class Wo {
|
|
|
1220
1222
|
* @param {(o:any,s:State)=>R} h
|
|
1221
1223
|
*/
|
|
1222
1224
|
else(t) {
|
|
1223
|
-
return this.if(
|
|
1225
|
+
return this.if(De, t);
|
|
1224
1226
|
}
|
|
1225
1227
|
/**
|
|
1226
1228
|
* @return {State extends undefined
|
|
@@ -1241,19 +1243,19 @@ class Wo {
|
|
|
1241
1243
|
);
|
|
1242
1244
|
}
|
|
1243
1245
|
}
|
|
1244
|
-
const
|
|
1246
|
+
const qo = (e) => new Xo(
|
|
1245
1247
|
/** @type {any} */
|
|
1246
1248
|
e
|
|
1247
1249
|
), ai = (
|
|
1248
1250
|
/** @type {any} */
|
|
1249
|
-
|
|
1251
|
+
qo(
|
|
1250
1252
|
/** @type {Schema<prng.PRNG>} */
|
|
1251
|
-
|
|
1252
|
-
).if(ci, (e, t) =>
|
|
1253
|
+
De
|
|
1254
|
+
).if(ci, (e, t) => tn(t, ss, Se)).if(li, (e, t) => Co(t)).if(Jo, (e, t) => ds(t)).if(Po, (e, t) => BigInt(tn(t, ss, Se))).if(Ce, (e, t) => yt(t, en(t, e.shape))).if(No, (e, t) => {
|
|
1253
1255
|
const n = {};
|
|
1254
1256
|
for (const s in e.shape) {
|
|
1255
1257
|
let i = e.shape[s];
|
|
1256
|
-
if (
|
|
1258
|
+
if (Uo.check(i)) {
|
|
1257
1259
|
if (ds(t))
|
|
1258
1260
|
continue;
|
|
1259
1261
|
i = i.shape;
|
|
@@ -1261,25 +1263,25 @@ const zo = (e) => new Wo(
|
|
|
1261
1263
|
n[s] = ai(i, t);
|
|
1262
1264
|
}
|
|
1263
1265
|
return n;
|
|
1264
|
-
}).if(
|
|
1266
|
+
}).if($o, (e, t) => {
|
|
1265
1267
|
const n = [], s = zs(t, 0, 42);
|
|
1266
1268
|
for (let i = 0; i < s; i++)
|
|
1267
1269
|
n.push(yt(t, e.shape));
|
|
1268
1270
|
return n;
|
|
1269
|
-
}).if(Xs, (e, t) =>
|
|
1271
|
+
}).if(Xs, (e, t) => en(t, e.shape)).if(Wo, (e, t) => null).if(Ko, (e, t) => {
|
|
1270
1272
|
const n = yt(t, e.res);
|
|
1271
1273
|
return () => n;
|
|
1272
|
-
}).if(
|
|
1274
|
+
}).if(Go, (e, t) => yt(t, en(t, [
|
|
1273
1275
|
St,
|
|
1274
1276
|
vt,
|
|
1275
|
-
|
|
1277
|
+
He,
|
|
1276
1278
|
hi,
|
|
1277
1279
|
Vn,
|
|
1278
|
-
|
|
1280
|
+
Ke,
|
|
1279
1281
|
si(St),
|
|
1280
1282
|
ti(Rt("a", "b", "c"), St)
|
|
1281
|
-
]))).if(
|
|
1282
|
-
const n = {}, s =
|
|
1283
|
+
]))).if(Ro, (e, t) => {
|
|
1284
|
+
const n = {}, s = tn(t, 0, 3);
|
|
1283
1285
|
for (let i = 0; i < s; i++) {
|
|
1284
1286
|
const r = yt(t, e.shape.keys), o = yt(t, e.shape.values);
|
|
1285
1287
|
n[r] = o;
|
|
@@ -1289,17 +1291,17 @@ const zo = (e) => new Wo(
|
|
|
1289
1291
|
), yt = (e, t) => (
|
|
1290
1292
|
/** @type {any} */
|
|
1291
1293
|
ai(zt(t), e)
|
|
1292
|
-
),
|
|
1294
|
+
), Ye = (
|
|
1293
1295
|
/** @type {Document} */
|
|
1294
1296
|
typeof document < "u" ? document : {}
|
|
1295
1297
|
);
|
|
1296
|
-
v((e) => e.nodeType ===
|
|
1298
|
+
v((e) => e.nodeType === nc);
|
|
1297
1299
|
typeof DOMParser < "u" && new DOMParser();
|
|
1298
|
-
v((e) => e.nodeType === qo);
|
|
1299
|
-
v((e) => e.nodeType === Qo);
|
|
1300
|
-
const Xo = (e) => fr(e, (t, n) => `${n}:${t};`).join(""), qo = He.ELEMENT_NODE, Qo = He.TEXT_NODE, Zo = He.DOCUMENT_NODE, tc = He.DOCUMENT_FRAGMENT_NODE;
|
|
1301
1300
|
v((e) => e.nodeType === Zo);
|
|
1302
|
-
|
|
1301
|
+
v((e) => e.nodeType === tc);
|
|
1302
|
+
const Qo = (e) => pr(e, (t, n) => `${n}:${t};`).join(""), Zo = Ye.ELEMENT_NODE, tc = Ye.TEXT_NODE, ec = Ye.DOCUMENT_NODE, nc = Ye.DOCUMENT_FRAGMENT_NODE;
|
|
1303
|
+
v((e) => e.nodeType === ec);
|
|
1304
|
+
const Q = Symbol, ui = Q(), di = Q(), sc = Q(), ic = Q(), rc = Q(), fi = Q(), oc = Q(), Bn = Q(), cc = Q(), lc = (e) => {
|
|
1303
1305
|
var i;
|
|
1304
1306
|
e.length === 1 && ((i = e[0]) == null ? void 0 : i.constructor) === Function && (e = /** @type {Array<string|Symbol|Object|number>} */
|
|
1305
1307
|
/** @type {[function]} */
|
|
@@ -1320,18 +1322,18 @@ const Q = Symbol, ui = Q(), di = Q(), ec = Q(), nc = Q(), sc = Q(), fi = Q(), ic
|
|
|
1320
1322
|
r instanceof Symbol || n.push(r);
|
|
1321
1323
|
}
|
|
1322
1324
|
return n;
|
|
1323
|
-
},
|
|
1325
|
+
}, hc = {
|
|
1324
1326
|
[ui]: W("font-weight", "bold"),
|
|
1325
1327
|
[di]: W("font-weight", "normal"),
|
|
1326
|
-
[
|
|
1327
|
-
[
|
|
1328
|
-
[
|
|
1328
|
+
[sc]: W("color", "blue"),
|
|
1329
|
+
[rc]: W("color", "green"),
|
|
1330
|
+
[ic]: W("color", "grey"),
|
|
1329
1331
|
[fi]: W("color", "red"),
|
|
1330
|
-
[
|
|
1332
|
+
[oc]: W("color", "purple"),
|
|
1331
1333
|
[Bn]: W("color", "orange"),
|
|
1332
1334
|
// not well supported in chrome when debugging node with inspector - TODO: deprecate
|
|
1333
|
-
[
|
|
1334
|
-
},
|
|
1335
|
+
[cc]: W("color", "black")
|
|
1336
|
+
}, ac = (e) => {
|
|
1335
1337
|
var o;
|
|
1336
1338
|
e.length === 1 && ((o = e[0]) == null ? void 0 : o.constructor) === Function && (e = /** @type {Array<string|Symbol|Object|number>} */
|
|
1337
1339
|
/** @type {[function]} */
|
|
@@ -1339,14 +1341,14 @@ const Q = Symbol, ui = Q(), di = Q(), ec = Q(), nc = Q(), sc = Q(), fi = Q(), ic
|
|
|
1339
1341
|
const t = [], n = [], s = x();
|
|
1340
1342
|
let i = [], r = 0;
|
|
1341
1343
|
for (; r < e.length; r++) {
|
|
1342
|
-
const c = e[r], l =
|
|
1344
|
+
const c = e[r], l = hc[c];
|
|
1343
1345
|
if (l !== void 0)
|
|
1344
1346
|
s.set(l.left, l.right);
|
|
1345
1347
|
else {
|
|
1346
1348
|
if (c === void 0)
|
|
1347
1349
|
break;
|
|
1348
1350
|
if (c.constructor === String || c.constructor === Number) {
|
|
1349
|
-
const h =
|
|
1351
|
+
const h = Qo(s);
|
|
1350
1352
|
r > 0 || h.length > 0 ? (t.push("%c" + c), n.push(h)) : t.push(c);
|
|
1351
1353
|
} else
|
|
1352
1354
|
break;
|
|
@@ -1357,7 +1359,7 @@ const Q = Symbol, ui = Q(), di = Q(), ec = Q(), nc = Q(), sc = Q(), fi = Q(), ic
|
|
|
1357
1359
|
c instanceof Symbol || i.push(c);
|
|
1358
1360
|
}
|
|
1359
1361
|
return i;
|
|
1360
|
-
}, gi =
|
|
1362
|
+
}, gi = yo ? ac : lc, uc = (...e) => {
|
|
1361
1363
|
console.log(...gi(e)), wi.forEach((t) => t.print(e));
|
|
1362
1364
|
}, pi = (...e) => {
|
|
1363
1365
|
console.warn(...gi(e)), e.unshift(Bn), wi.forEach((t) => t.print(e));
|
|
@@ -1370,13 +1372,13 @@ const Q = Symbol, ui = Q(), di = Q(), ec = Q(), nc = Q(), sc = Q(), fi = Q(), ic
|
|
|
1370
1372
|
},
|
|
1371
1373
|
// @ts-ignore
|
|
1372
1374
|
next: e
|
|
1373
|
-
}),
|
|
1375
|
+
}), dc = (e, t) => yi(() => {
|
|
1374
1376
|
let n;
|
|
1375
1377
|
do
|
|
1376
1378
|
n = e.next();
|
|
1377
1379
|
while (!n.done && !t(n.value));
|
|
1378
1380
|
return n;
|
|
1379
|
-
}),
|
|
1381
|
+
}), nn = (e, t) => yi(() => {
|
|
1380
1382
|
const { done: n, value: s } = e.next();
|
|
1381
1383
|
return { done: n, value: n ? void 0 : t(s) };
|
|
1382
1384
|
});
|
|
@@ -1404,7 +1406,7 @@ const It = (e, t, n) => t.clients.forEach((s, i) => {
|
|
|
1404
1406
|
for (let l = 0, h = s[l]; l < s.length && h.clock < c; h = s[++l])
|
|
1405
1407
|
xi(e, r, h.clock, h.len, n);
|
|
1406
1408
|
}
|
|
1407
|
-
}),
|
|
1409
|
+
}), fc = (e, t) => {
|
|
1408
1410
|
let n = 0, s = e.length - 1;
|
|
1409
1411
|
for (; n <= s; ) {
|
|
1410
1412
|
const i = F((n + s) / 2), r = e[i], o = r.clock;
|
|
@@ -1418,7 +1420,7 @@ const It = (e, t, n) => t.clients.forEach((s, i) => {
|
|
|
1418
1420
|
return null;
|
|
1419
1421
|
}, se = (e, t) => {
|
|
1420
1422
|
const n = e.clients.get(t.client);
|
|
1421
|
-
return n !== void 0 &&
|
|
1423
|
+
return n !== void 0 && fc(n, t.clock) !== null;
|
|
1422
1424
|
}, jn = (e) => {
|
|
1423
1425
|
e.clients.forEach((t) => {
|
|
1424
1426
|
t.sort((i, r) => i.clock - r.clock);
|
|
@@ -1436,7 +1438,7 @@ const It = (e, t, n) => t.clients.forEach((s, i) => {
|
|
|
1436
1438
|
if (!t.clients.has(i)) {
|
|
1437
1439
|
const r = s.slice();
|
|
1438
1440
|
for (let o = n + 1; o < e.length; o++)
|
|
1439
|
-
|
|
1441
|
+
yr(r, e[o].clients.get(i) || []);
|
|
1440
1442
|
t.clients.set(i, r);
|
|
1441
1443
|
}
|
|
1442
1444
|
});
|
|
@@ -1446,8 +1448,8 @@ const It = (e, t, n) => t.clients.forEach((s, i) => {
|
|
|
1446
1448
|
/** @type {Array<DeleteItem>} */
|
|
1447
1449
|
[]
|
|
1448
1450
|
)).push(new Fn(n, s));
|
|
1449
|
-
},
|
|
1450
|
-
const t =
|
|
1451
|
+
}, gc = () => new Mt(), mi = (e) => {
|
|
1452
|
+
const t = gc();
|
|
1451
1453
|
return e.clients.forEach((n, s) => {
|
|
1452
1454
|
const i = [];
|
|
1453
1455
|
for (let r = 0; r < n.length; r++) {
|
|
@@ -1498,8 +1500,8 @@ const It = (e, t, n) => t.clients.forEach((s, i) => {
|
|
|
1498
1500
|
if (u < h) {
|
|
1499
1501
|
h < d && Xt(s, o, h, d - h);
|
|
1500
1502
|
let f = G(l, u), g = l[f];
|
|
1501
|
-
for (!g.deleted && g.id.clock < u && (l.splice(f + 1, 0,
|
|
1502
|
-
g.deleted || (d < g.id.clock + g.length && l.splice(f, 0,
|
|
1503
|
+
for (!g.deleted && g.id.clock < u && (l.splice(f + 1, 0, Ne(t, g, u - g.id.clock)), f++); f < l.length && (g = l[f++], g.id.clock < d); )
|
|
1504
|
+
g.deleted || (d < g.id.clock + g.length && l.splice(f, 0, Ne(t, g, d - g.id.clock)), g.delete(t));
|
|
1503
1505
|
} else
|
|
1504
1506
|
Xt(s, o, u, d - u);
|
|
1505
1507
|
}
|
|
@@ -1514,7 +1516,7 @@ class pt extends Vs {
|
|
|
1514
1516
|
/**
|
|
1515
1517
|
* @param {DocOpts} opts configuration
|
|
1516
1518
|
*/
|
|
1517
|
-
constructor({ guid: t =
|
|
1519
|
+
constructor({ guid: t = Zr(), collectionid: n = null, gc: s = !0, gcFilter: i = () => !0, meta: r = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
|
|
1518
1520
|
super(), this.gc = s, this.gcFilter = i, this.clientID = ki(), this.guid = t, this.collectionid = n, this.share = /* @__PURE__ */ new Map(), this.store = new Li(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = c, this.autoLoad = o, this.meta = r, this.isLoaded = !1, this.isSynced = !1, this.isDestroyed = !1, this.whenLoaded = as((h) => {
|
|
1519
1521
|
this.on("load", () => {
|
|
1520
1522
|
this.isLoaded = !0, h(this);
|
|
@@ -1807,7 +1809,7 @@ class bi extends Si {
|
|
|
1807
1809
|
* @return {Uint8Array}
|
|
1808
1810
|
*/
|
|
1809
1811
|
readBuf() {
|
|
1810
|
-
return
|
|
1812
|
+
return bo(L(this.restDecoder));
|
|
1811
1813
|
}
|
|
1812
1814
|
/**
|
|
1813
1815
|
* Legacy implementation uses JSON parse. We use any-decoding in v2.
|
|
@@ -1824,7 +1826,7 @@ class bi extends Si {
|
|
|
1824
1826
|
return lt(this.restDecoder);
|
|
1825
1827
|
}
|
|
1826
1828
|
}
|
|
1827
|
-
class
|
|
1829
|
+
class pc {
|
|
1828
1830
|
/**
|
|
1829
1831
|
* @param {decoding.Decoder} decoder
|
|
1830
1832
|
*/
|
|
@@ -1848,12 +1850,12 @@ class fc {
|
|
|
1848
1850
|
return this.dsCurrVal += t, t;
|
|
1849
1851
|
}
|
|
1850
1852
|
}
|
|
1851
|
-
class Ut extends
|
|
1853
|
+
class Ut extends pc {
|
|
1852
1854
|
/**
|
|
1853
1855
|
* @param {decoding.Decoder} decoder
|
|
1854
1856
|
*/
|
|
1855
1857
|
constructor(t) {
|
|
1856
|
-
super(t), this.keys = [], y(t), this.keyClockDecoder = new
|
|
1858
|
+
super(t), this.keys = [], y(t), this.keyClockDecoder = new Ze(L(t)), this.clientDecoder = new we(L(t)), this.leftClockDecoder = new Ze(L(t)), this.rightClockDecoder = new Ze(L(t)), this.infoDecoder = new hs(L(t), At), this.stringDecoder = new zr(L(t)), this.parentInfoDecoder = new hs(L(t), At), this.typeRefDecoder = new we(L(t)), this.lenDecoder = new we(L(t));
|
|
1857
1859
|
}
|
|
1858
1860
|
/**
|
|
1859
1861
|
* @return {ID}
|
|
@@ -2069,11 +2071,11 @@ class Ei {
|
|
|
2069
2071
|
}
|
|
2070
2072
|
class at extends Ei {
|
|
2071
2073
|
constructor() {
|
|
2072
|
-
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new
|
|
2074
|
+
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new Qe(), this.clientEncoder = new pe(), this.leftClockEncoder = new Qe(), this.rightClockEncoder = new Qe(), this.infoEncoder = new os(dn), this.stringEncoder = new Fr(), this.parentInfoEncoder = new os(dn), this.typeRefEncoder = new pe(), this.lenEncoder = new pe();
|
|
2073
2075
|
}
|
|
2074
2076
|
toUint8Array() {
|
|
2075
2077
|
const t = xt();
|
|
2076
|
-
return w(t, 0), I(t, this.keyClockEncoder.toUint8Array()), I(t, this.clientEncoder.toUint8Array()), I(t, this.leftClockEncoder.toUint8Array()), I(t, this.rightClockEncoder.toUint8Array()), I(t, B(this.infoEncoder)), I(t, this.stringEncoder.toUint8Array()), I(t, B(this.parentInfoEncoder)), I(t, this.typeRefEncoder.toUint8Array()), I(t, this.lenEncoder.toUint8Array()),
|
|
2078
|
+
return w(t, 0), I(t, this.keyClockEncoder.toUint8Array()), I(t, this.clientEncoder.toUint8Array()), I(t, this.leftClockEncoder.toUint8Array()), I(t, this.rightClockEncoder.toUint8Array()), I(t, B(this.infoEncoder)), I(t, this.stringEncoder.toUint8Array()), I(t, B(this.parentInfoEncoder)), I(t, this.typeRefEncoder.toUint8Array()), I(t, this.lenEncoder.toUint8Array()), $e(t, B(this.restEncoder)), B(t);
|
|
2077
2079
|
}
|
|
2078
2080
|
/**
|
|
2079
2081
|
* @param {ID} id
|
|
@@ -2160,7 +2162,7 @@ class at extends Ei {
|
|
|
2160
2162
|
n === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(t)) : this.keyClockEncoder.write(n);
|
|
2161
2163
|
}
|
|
2162
2164
|
}
|
|
2163
|
-
const
|
|
2165
|
+
const wc = (e, t, n, s) => {
|
|
2164
2166
|
s = ft(s, t[0].id.clock);
|
|
2165
2167
|
const i = G(t, s);
|
|
2166
2168
|
w(e.restEncoder, t.length - i), e.writeClient(n), w(e.restEncoder, s);
|
|
@@ -2175,7 +2177,7 @@ const gc = (e, t, n, s) => {
|
|
|
2175
2177
|
}), re(t).forEach((i, r) => {
|
|
2176
2178
|
n.has(r) || s.set(r, 0);
|
|
2177
2179
|
}), w(e.restEncoder, s.size), X(s.entries()).sort((i, r) => r[0] - i[0]).forEach(([i, r]) => {
|
|
2178
|
-
|
|
2180
|
+
wc(
|
|
2179
2181
|
e,
|
|
2180
2182
|
/** @type {Array<GC|Item>} */
|
|
2181
2183
|
t.clients.get(i),
|
|
@@ -2183,7 +2185,7 @@ const gc = (e, t, n, s) => {
|
|
|
2183
2185
|
r
|
|
2184
2186
|
);
|
|
2185
2187
|
});
|
|
2186
|
-
},
|
|
2188
|
+
}, yc = (e, t) => {
|
|
2187
2189
|
const n = x(), s = y(e.restDecoder);
|
|
2188
2190
|
for (let i = 0; i < s; i++) {
|
|
2189
2191
|
const r = y(e.restDecoder), o = new Array(r), c = e.readClient();
|
|
@@ -2191,7 +2193,7 @@ const gc = (e, t, n, s) => {
|
|
|
2191
2193
|
n.set(c, { i: 0, refs: o });
|
|
2192
2194
|
for (let h = 0; h < r; h++) {
|
|
2193
2195
|
const a = e.readInfo();
|
|
2194
|
-
switch (
|
|
2196
|
+
switch (Me & a) {
|
|
2195
2197
|
case 0: {
|
|
2196
2198
|
const u = e.readLen();
|
|
2197
2199
|
o[h] = new $(m(c, l), u), l += u;
|
|
@@ -2226,7 +2228,7 @@ const gc = (e, t, n, s) => {
|
|
|
2226
2228
|
}
|
|
2227
2229
|
}
|
|
2228
2230
|
return n;
|
|
2229
|
-
},
|
|
2231
|
+
}, mc = (e, t, n) => {
|
|
2230
2232
|
const s = [];
|
|
2231
2233
|
let i = X(n.keys()).sort((f, g) => f - g);
|
|
2232
2234
|
if (i.length === 0)
|
|
@@ -2311,10 +2313,10 @@ const gc = (e, t, n, s) => {
|
|
|
2311
2313
|
return Hn(f, c, /* @__PURE__ */ new Map()), w(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
|
|
2312
2314
|
}
|
|
2313
2315
|
return null;
|
|
2314
|
-
},
|
|
2316
|
+
}, kc = (e, t) => Hn(e, t.doc.store, t.beforeState), Sc = (e, t, n, s = new Ut(e)) => S(t, (i) => {
|
|
2315
2317
|
i.local = !1;
|
|
2316
2318
|
let r = !1;
|
|
2317
|
-
const o = i.doc, c = o.store, l =
|
|
2319
|
+
const o = i.doc, c = o.store, l = yc(s, o), h = mc(i, c, l), a = c.pendingStructs;
|
|
2318
2320
|
if (a) {
|
|
2319
2321
|
for (const [d, f] of a.missing)
|
|
2320
2322
|
if (f < E(c, d)) {
|
|
@@ -2326,7 +2328,7 @@ const gc = (e, t, n, s) => {
|
|
|
2326
2328
|
const g = a.missing.get(d);
|
|
2327
2329
|
(g == null || g > f) && a.missing.set(d, f);
|
|
2328
2330
|
}
|
|
2329
|
-
a.update =
|
|
2331
|
+
a.update = Te([a.update, h.update]);
|
|
2330
2332
|
}
|
|
2331
2333
|
} else
|
|
2332
2334
|
c.pendingStructs = h;
|
|
@@ -2335,7 +2337,7 @@ const gc = (e, t, n, s) => {
|
|
|
2335
2337
|
const d = new Ut(gt(c.pendingDs));
|
|
2336
2338
|
y(d.restDecoder);
|
|
2337
2339
|
const f = gs(d, i, c);
|
|
2338
|
-
u && f ? c.pendingDs =
|
|
2340
|
+
u && f ? c.pendingDs = Te([u, f]) : c.pendingDs = u || f;
|
|
2339
2341
|
} else
|
|
2340
2342
|
c.pendingDs = u;
|
|
2341
2343
|
if (r) {
|
|
@@ -2347,36 +2349,36 @@ const gc = (e, t, n, s) => {
|
|
|
2347
2349
|
}
|
|
2348
2350
|
}, n, !1), Ci = (e, t, n, s = Ut) => {
|
|
2349
2351
|
const i = gt(t);
|
|
2350
|
-
|
|
2351
|
-
}, Di = (e, t, n) => Ci(e, t, n, bi),
|
|
2352
|
+
Sc(i, e, n, new s(i));
|
|
2353
|
+
}, Di = (e, t, n) => Ci(e, t, n, bi), bc = (e, t, n = /* @__PURE__ */ new Map()) => {
|
|
2352
2354
|
Hn(e, t.store, n), $t(e, mi(t.store));
|
|
2353
|
-
},
|
|
2355
|
+
}, _c = (e, t = new Uint8Array([0]), n = new at()) => {
|
|
2354
2356
|
const s = Ti(t);
|
|
2355
|
-
|
|
2357
|
+
bc(n, e, s);
|
|
2356
2358
|
const i = [n.toUint8Array()];
|
|
2357
|
-
if (e.store.pendingDs && i.push(e.store.pendingDs), e.store.pendingStructs && i.push(
|
|
2359
|
+
if (e.store.pendingDs && i.push(e.store.pendingDs), e.store.pendingStructs && i.push(Kc(e.store.pendingStructs.update, t)), i.length > 1) {
|
|
2358
2360
|
if (n.constructor === ie)
|
|
2359
|
-
return
|
|
2361
|
+
return Fc(i.map((r, o) => o === 0 ? r : Yc(r)));
|
|
2360
2362
|
if (n.constructor === at)
|
|
2361
|
-
return
|
|
2363
|
+
return Te(i);
|
|
2362
2364
|
}
|
|
2363
2365
|
return i[0];
|
|
2364
|
-
}, Ai = (e, t) =>
|
|
2366
|
+
}, Ai = (e, t) => _c(e, t, new ie()), Ec = (e) => {
|
|
2365
2367
|
const t = /* @__PURE__ */ new Map(), n = y(e.restDecoder);
|
|
2366
2368
|
for (let s = 0; s < n; s++) {
|
|
2367
2369
|
const i = y(e.restDecoder), r = y(e.restDecoder);
|
|
2368
2370
|
t.set(i, r);
|
|
2369
2371
|
}
|
|
2370
2372
|
return t;
|
|
2371
|
-
}, Ti = (e) =>
|
|
2373
|
+
}, Ti = (e) => Ec(new Si(gt(e))), vi = (e, t) => (w(e.restEncoder, t.size), X(t.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
|
|
2372
2374
|
w(e.restEncoder, n), w(e.restEncoder, s);
|
|
2373
|
-
}), e),
|
|
2374
|
-
class
|
|
2375
|
+
}), e), Cc = (e, t) => vi(e, re(t.store)), Dc = (e, t = new Ei()) => (e instanceof Map ? vi(t, e) : Cc(t, e), t.toUint8Array()), Ac = (e) => Dc(e, new _i());
|
|
2376
|
+
class Tc {
|
|
2375
2377
|
constructor() {
|
|
2376
2378
|
this.l = [];
|
|
2377
2379
|
}
|
|
2378
2380
|
}
|
|
2379
|
-
const ps = () => new
|
|
2381
|
+
const ps = () => new Tc(), ws = (e, t) => e.l.push(t), ys = (e, t) => {
|
|
2380
2382
|
const n = e.l, s = n.length;
|
|
2381
2383
|
e.l = n.filter((i) => t !== i), s === e.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
|
|
2382
2384
|
}, Ii = (e, t, n) => xn(e.l, [t, n]);
|
|
@@ -2394,7 +2396,7 @@ const mt = (e, t) => e === t || e !== null && t !== null && e.client === t.clien
|
|
|
2394
2396
|
if (n === e)
|
|
2395
2397
|
return t;
|
|
2396
2398
|
throw M();
|
|
2397
|
-
},
|
|
2399
|
+
}, Ae = (e, t) => {
|
|
2398
2400
|
for (; t !== null; ) {
|
|
2399
2401
|
if (t.parent === e)
|
|
2400
2402
|
return !0;
|
|
@@ -2414,8 +2416,8 @@ class Oi {
|
|
|
2414
2416
|
this.type = t, this.tname = n, this.item = s, this.assoc = i;
|
|
2415
2417
|
}
|
|
2416
2418
|
}
|
|
2417
|
-
const
|
|
2418
|
-
class
|
|
2419
|
+
const Gh = (e) => new Oi(e.type == null ? null : m(e.type.client, e.type.clock), e.tname ?? null, e.item == null ? null : m(e.item.client, e.item.clock), e.assoc == null ? 0 : e.assoc);
|
|
2420
|
+
class vc {
|
|
2419
2421
|
/**
|
|
2420
2422
|
* @param {AbstractType<any>} type
|
|
2421
2423
|
* @param {number} index
|
|
@@ -2425,10 +2427,10 @@ class Ac {
|
|
|
2425
2427
|
this.type = t, this.index = n, this.assoc = s;
|
|
2426
2428
|
}
|
|
2427
2429
|
}
|
|
2428
|
-
const
|
|
2430
|
+
const Ic = (e, t, n = 0) => new vc(e, t, n), he = (e, t, n) => {
|
|
2429
2431
|
let s = null, i = null;
|
|
2430
2432
|
return e._item === null ? i = Ui(e) : s = m(e._item.id.client, e._item.id.clock), new Oi(s, i, t, n);
|
|
2431
|
-
},
|
|
2433
|
+
}, Ph = (e, t, n = 0) => {
|
|
2432
2434
|
let s = e._start;
|
|
2433
2435
|
if (n < 0) {
|
|
2434
2436
|
if (t === 0)
|
|
@@ -2446,19 +2448,19 @@ const Tc = (e, t, n = 0) => new Ac(e, t, n), he = (e, t, n) => {
|
|
|
2446
2448
|
s = s.right;
|
|
2447
2449
|
}
|
|
2448
2450
|
return he(e, null, n);
|
|
2449
|
-
},
|
|
2451
|
+
}, Uc = (e, t) => {
|
|
2450
2452
|
const n = _t(e, t), s = t.clock - n.id.clock;
|
|
2451
2453
|
return {
|
|
2452
2454
|
item: n,
|
|
2453
2455
|
diff: s
|
|
2454
2456
|
};
|
|
2455
|
-
},
|
|
2457
|
+
}, Jh = (e, t, n = !0) => {
|
|
2456
2458
|
const s = t.store, i = e.item, r = e.type, o = e.tname, c = e.assoc;
|
|
2457
2459
|
let l = null, h = 0;
|
|
2458
2460
|
if (i !== null) {
|
|
2459
2461
|
if (E(s, i.client) <= i.clock)
|
|
2460
2462
|
return null;
|
|
2461
|
-
const a = n ? Sn(s, i) :
|
|
2463
|
+
const a = n ? Sn(s, i) : Uc(s, i), u = a.item;
|
|
2462
2464
|
if (!(u instanceof b))
|
|
2463
2465
|
return null;
|
|
2464
2466
|
if (l = /** @type {AbstractType<any>} */
|
|
@@ -2483,9 +2485,9 @@ const Tc = (e, t, n = 0) => new Ac(e, t, n), he = (e, t, n) => {
|
|
|
2483
2485
|
throw M();
|
|
2484
2486
|
c >= 0 ? h = l._length : h = 0;
|
|
2485
2487
|
}
|
|
2486
|
-
return
|
|
2487
|
-
},
|
|
2488
|
-
class
|
|
2488
|
+
return Ic(l, h, e.assoc);
|
|
2489
|
+
}, Wh = (e, t) => e === t || e !== null && t !== null && e.tname === t.tname && mt(e.item, t.item) && mt(e.type, t.type) && e.assoc === t.assoc;
|
|
2490
|
+
class Oc {
|
|
2489
2491
|
/**
|
|
2490
2492
|
* @param {DeleteSet} ds
|
|
2491
2493
|
* @param {Map<number,number>} sv state map
|
|
@@ -2494,7 +2496,7 @@ class Ic {
|
|
|
2494
2496
|
this.ds = t, this.sv = n;
|
|
2495
2497
|
}
|
|
2496
2498
|
}
|
|
2497
|
-
const
|
|
2499
|
+
const Lc = (e, t) => new Oc(e, t), zh = (e) => Lc(mi(e.store), re(e.store)), it = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !se(t.ds, e.id), yn = (e, t) => {
|
|
2498
2500
|
const n = q(e.meta, yn, ht), s = e.doc.store;
|
|
2499
2501
|
n.has(t) || (t.sv.forEach((i, r) => {
|
|
2500
2502
|
i < E(s, r) && N(e, m(r, i));
|
|
@@ -2543,15 +2545,15 @@ const re = (e) => {
|
|
|
2543
2545
|
o = F((n + s) / 2);
|
|
2544
2546
|
}
|
|
2545
2547
|
throw M();
|
|
2546
|
-
},
|
|
2548
|
+
}, Nc = (e, t) => {
|
|
2547
2549
|
const n = e.clients.get(t.client);
|
|
2548
2550
|
return n[G(n, t.clock)];
|
|
2549
2551
|
}, _t = (
|
|
2550
2552
|
/** @type {function(StructStore,ID):Item} */
|
|
2551
|
-
|
|
2553
|
+
Nc
|
|
2552
2554
|
), mn = (e, t, n) => {
|
|
2553
2555
|
const s = G(t, n), i = t[s];
|
|
2554
|
-
return i.id.clock < n && i instanceof b ? (t.splice(s + 1, 0,
|
|
2556
|
+
return i.id.clock < n && i instanceof b ? (t.splice(s + 1, 0, Ne(e, i, n - i.id.clock)), s + 1) : s;
|
|
2555
2557
|
}, N = (e, t) => {
|
|
2556
2558
|
const n = (
|
|
2557
2559
|
/** @type {Array<Item>} */
|
|
@@ -2560,8 +2562,8 @@ const re = (e) => {
|
|
|
2560
2562
|
return n[mn(e, n, t.clock)];
|
|
2561
2563
|
}, ms = (e, t, n) => {
|
|
2562
2564
|
const s = t.clients.get(n.client), i = G(s, n.clock), r = s[i];
|
|
2563
|
-
return n.clock !== r.id.clock + r.length - 1 && r.constructor !== $ && s.splice(i + 1, 0,
|
|
2564
|
-
},
|
|
2565
|
+
return n.clock !== r.id.clock + r.length - 1 && r.constructor !== $ && s.splice(i + 1, 0, Ne(e, r, n.clock - r.id.clock + 1)), r;
|
|
2566
|
+
}, xc = (e, t, n) => {
|
|
2565
2567
|
const s = (
|
|
2566
2568
|
/** @type {Array<GC|Item>} */
|
|
2567
2569
|
e.clients.get(t.id.client)
|
|
@@ -2576,7 +2578,7 @@ const re = (e) => {
|
|
|
2576
2578
|
c = t[o++], r < c.id.clock + c.length && mn(e, t, r), i(c);
|
|
2577
2579
|
while (o < t.length && t[o].id.clock < r);
|
|
2578
2580
|
};
|
|
2579
|
-
class
|
|
2581
|
+
class Rc {
|
|
2580
2582
|
/**
|
|
2581
2583
|
* @param {Doc} doc
|
|
2582
2584
|
* @param {any} origin
|
|
@@ -2586,7 +2588,7 @@ class Nc {
|
|
|
2586
2588
|
this.doc = t, this.deleteSet = new Mt(), this.beforeState = re(t.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = n, this.meta = /* @__PURE__ */ new Map(), this.local = s, this.subdocsAdded = /* @__PURE__ */ new Set(), this.subdocsRemoved = /* @__PURE__ */ new Set(), this.subdocsLoaded = /* @__PURE__ */ new Set(), this._needFormattingCleanup = !1;
|
|
2587
2589
|
}
|
|
2588
2590
|
}
|
|
2589
|
-
const ks = (e, t) => t.deleteSet.clients.size === 0 && !
|
|
2591
|
+
const ks = (e, t) => t.deleteSet.clients.size === 0 && !wr(t.afterState, (n, s) => t.beforeState.get(s) !== n) ? !1 : (jn(t.deleteSet), kc(e, t), $t(e, t.deleteSet), !0), Ss = (e, t, n) => {
|
|
2590
2592
|
const s = t._item;
|
|
2591
2593
|
(s === null || s.id.clock < (e.beforeState.get(s.id.client) || 0) && !s.deleted) && q(e.changed, t, ht).add(n);
|
|
2592
2594
|
}, ye = (e, t) => {
|
|
@@ -2605,7 +2607,7 @@ const ks = (e, t) => t.deleteSet.clients.size === 0 && !gr(t.afterState, (n, s)
|
|
|
2605
2607
|
}
|
|
2606
2608
|
const r = t - i;
|
|
2607
2609
|
return r && e.splice(t + 1 - r, r), r;
|
|
2608
|
-
},
|
|
2610
|
+
}, Mc = (e, t, n) => {
|
|
2609
2611
|
for (const [s, i] of e.clients.entries()) {
|
|
2610
2612
|
const r = (
|
|
2611
2613
|
/** @type {Array<GC|Item>} */
|
|
@@ -2621,7 +2623,7 @@ const ks = (e, t) => t.deleteSet.clients.size === 0 && !gr(t.afterState, (n, s)
|
|
|
2621
2623
|
}
|
|
2622
2624
|
}
|
|
2623
2625
|
}
|
|
2624
|
-
},
|
|
2626
|
+
}, $c = (e, t) => {
|
|
2625
2627
|
e.clients.forEach((n, s) => {
|
|
2626
2628
|
const i = (
|
|
2627
2629
|
/** @type {Array<GC|Item>} */
|
|
@@ -2653,11 +2655,11 @@ const ks = (e, t) => t.deleteSet.clients.size === 0 && !gr(t.afterState, (n, s)
|
|
|
2653
2655
|
Ii(h._dEH, l, n);
|
|
2654
2656
|
}));
|
|
2655
2657
|
}), c.push(() => s.emit("afterTransaction", [n, s])), c.push(() => {
|
|
2656
|
-
n._needFormattingCleanup &&
|
|
2658
|
+
n._needFormattingCleanup && il(n);
|
|
2657
2659
|
});
|
|
2658
2660
|
}), xn(c, []);
|
|
2659
2661
|
} finally {
|
|
2660
|
-
s.gc &&
|
|
2662
|
+
s.gc && Mc(r, i, s.gcFilter), $c(r, i), n.afterState.forEach((a, u) => {
|
|
2661
2663
|
const d = n.beforeState.get(u) || 0;
|
|
2662
2664
|
if (d !== a) {
|
|
2663
2665
|
const f = (
|
|
@@ -2675,7 +2677,7 @@ const ks = (e, t) => t.deleteSet.clients.size === 0 && !gr(t.afterState, (n, s)
|
|
|
2675
2677
|
), g = G(f, d);
|
|
2676
2678
|
g + 1 < f.length && ye(f, g + 1) > 1 || g > 0 && ye(f, g);
|
|
2677
2679
|
}
|
|
2678
|
-
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (
|
|
2680
|
+
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (uc(Bn, ui, "[yjs] ", di, fi, "Changed the client-id because another client seems to be using it."), s.clientID = ki()), s.emit("afterTransactionCleanup", [n, s]), s._observers.has("update")) {
|
|
2679
2681
|
const a = new ie();
|
|
2680
2682
|
ks(a, n) && s.emit("update", [a.toUint8Array(), n.origin, s, n]);
|
|
2681
2683
|
}
|
|
@@ -2692,7 +2694,7 @@ const ks = (e, t) => t.deleteSet.clients.size === 0 && !gr(t.afterState, (n, s)
|
|
|
2692
2694
|
}, S = (e, t, n = null, s = !0) => {
|
|
2693
2695
|
const i = e._transactionCleanups;
|
|
2694
2696
|
let r = !1, o = null;
|
|
2695
|
-
e._transaction === null && (r = !0, e._transaction = new
|
|
2697
|
+
e._transaction === null && (r = !0, e._transaction = new Rc(e, n, s), i.push(e._transaction), i.length === 1 && e.emit("beforeAllTransactions", [e]), e.emit("beforeTransaction", [e._transaction, e]));
|
|
2696
2698
|
try {
|
|
2697
2699
|
o = t(e._transaction);
|
|
2698
2700
|
} finally {
|
|
@@ -2703,7 +2705,7 @@ const ks = (e, t) => t.deleteSet.clients.size === 0 && !gr(t.afterState, (n, s)
|
|
|
2703
2705
|
}
|
|
2704
2706
|
return o;
|
|
2705
2707
|
};
|
|
2706
|
-
class
|
|
2708
|
+
class Vc {
|
|
2707
2709
|
/**
|
|
2708
2710
|
* @param {DeleteSet} deletions
|
|
2709
2711
|
* @param {DeleteSet} insertions
|
|
@@ -2714,7 +2716,7 @@ class Mc {
|
|
|
2714
2716
|
}
|
|
2715
2717
|
const bs = (e, t, n) => {
|
|
2716
2718
|
It(e, n.deletions, (s) => {
|
|
2717
|
-
s instanceof b && t.scope.some((i) => i === e.doc ||
|
|
2719
|
+
s instanceof b && t.scope.some((i) => i === e.doc || Ae(
|
|
2718
2720
|
/** @type {AbstractType<any>} */
|
|
2719
2721
|
i,
|
|
2720
2722
|
s
|
|
@@ -2736,7 +2738,7 @@ const bs = (e, t, n) => {
|
|
|
2736
2738
|
let { item: g, diff: p } = Sn(l, f.id);
|
|
2737
2739
|
p > 0 && (g = N(c, m(g.id.client, g.id.clock + p))), f = g;
|
|
2738
2740
|
}
|
|
2739
|
-
!f.deleted && r.some((g) => g === c.doc ||
|
|
2741
|
+
!f.deleted && r.some((g) => g === c.doc || Ae(
|
|
2740
2742
|
/** @type {AbstractType<any>} */
|
|
2741
2743
|
g,
|
|
2742
2744
|
/** @type {Item} */
|
|
@@ -2744,7 +2746,7 @@ const bs = (e, t, n) => {
|
|
|
2744
2746
|
)) && u.push(f);
|
|
2745
2747
|
}
|
|
2746
2748
|
}), It(c, h.deletions, (f) => {
|
|
2747
|
-
f instanceof b && r.some((g) => g === c.doc ||
|
|
2749
|
+
f instanceof b && r.some((g) => g === c.doc || Ae(
|
|
2748
2750
|
/** @type {AbstractType<any>} */
|
|
2749
2751
|
g,
|
|
2750
2752
|
f
|
|
@@ -2770,7 +2772,7 @@ const bs = (e, t, n) => {
|
|
|
2770
2772
|
}
|
|
2771
2773
|
return o;
|
|
2772
2774
|
};
|
|
2773
|
-
class
|
|
2775
|
+
class Xh extends Vs {
|
|
2774
2776
|
/**
|
|
2775
2777
|
* @param {Doc|AbstractType<any>|Array<AbstractType<any>>} typeScope Limits the scope of the UndoManager. If this is set to a ydoc instance, all changes on that ydoc will be undone. If set to a specific type, only changes on that type or its children will be undone. Also accepts an array of types.
|
|
2776
2778
|
* @param {UndoManagerOptions} options
|
|
@@ -2805,13 +2807,13 @@ class Jh extends Vs {
|
|
|
2805
2807
|
const k = u[u.length - 1];
|
|
2806
2808
|
k.deletions = wn([k.deletions, l.deleteSet]), k.insertions = wn([k.insertions, d]);
|
|
2807
2809
|
} else
|
|
2808
|
-
u.push(new
|
|
2810
|
+
u.push(new Vc(l.deleteSet, d)), g = !0;
|
|
2809
2811
|
!h && !a && (this.lastChange = f), It(
|
|
2810
2812
|
l,
|
|
2811
2813
|
l.deleteSet,
|
|
2812
2814
|
/** @param {Item|GC} item */
|
|
2813
2815
|
(k) => {
|
|
2814
|
-
k instanceof b && this.scope.some((_) => _ === l.doc ||
|
|
2816
|
+
k instanceof b && this.scope.some((_) => _ === l.doc || Ae(
|
|
2815
2817
|
/** @type {AbstractType<any>} */
|
|
2816
2818
|
_,
|
|
2817
2819
|
k
|
|
@@ -2925,7 +2927,7 @@ class Jh extends Vs {
|
|
|
2925
2927
|
this.trackedOrigins.delete(this), this.doc.off("afterTransaction", this.afterTransactionHandler), super.destroy();
|
|
2926
2928
|
}
|
|
2927
2929
|
}
|
|
2928
|
-
function*
|
|
2930
|
+
function* Bc(e) {
|
|
2929
2931
|
const t = y(e.restDecoder);
|
|
2930
2932
|
for (let n = 0; n < t; n++) {
|
|
2931
2933
|
const s = y(e.restDecoder), i = e.readClient();
|
|
@@ -2935,7 +2937,7 @@ function* $c(e) {
|
|
|
2935
2937
|
if (c === 10) {
|
|
2936
2938
|
const l = y(e.restDecoder);
|
|
2937
2939
|
yield new V(m(i, r), l), r += l;
|
|
2938
|
-
} else if (
|
|
2940
|
+
} else if (Me & c) {
|
|
2939
2941
|
const l = (c & (z | R)) === 0, h = new b(
|
|
2940
2942
|
m(i, r),
|
|
2941
2943
|
null,
|
|
@@ -2968,7 +2970,7 @@ class Yn {
|
|
|
2968
2970
|
* @param {boolean} filterSkips
|
|
2969
2971
|
*/
|
|
2970
2972
|
constructor(t, n) {
|
|
2971
|
-
this.gen =
|
|
2973
|
+
this.gen = Bc(t), this.curr = null, this.done = !1, this.filterSkips = n, this.next();
|
|
2972
2974
|
}
|
|
2973
2975
|
/**
|
|
2974
2976
|
* @return {Item | GC | Skip |null}
|
|
@@ -2988,7 +2990,7 @@ class Gn {
|
|
|
2988
2990
|
this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = t, this.clientStructs = [];
|
|
2989
2991
|
}
|
|
2990
2992
|
}
|
|
2991
|
-
const
|
|
2993
|
+
const Fc = (e) => Te(e, bi, ie), jc = (e, t) => {
|
|
2992
2994
|
if (e.constructor === $) {
|
|
2993
2995
|
const { client: n, clock: s } = e.id;
|
|
2994
2996
|
return new $(m(n, s + t), e.length - t);
|
|
@@ -3011,7 +3013,7 @@ const Vc = (e) => Ae(e, bi, ie), Bc = (e, t) => {
|
|
|
3011
3013
|
n.content.splice(t)
|
|
3012
3014
|
);
|
|
3013
3015
|
}
|
|
3014
|
-
},
|
|
3016
|
+
}, Te = (e, t = Ut, n = at) => {
|
|
3015
3017
|
if (e.length === 1)
|
|
3016
3018
|
return e[0];
|
|
3017
3019
|
const s = e.map((a) => new t(gt(a)));
|
|
@@ -3054,7 +3056,7 @@ const Vc = (e) => Ae(e, bi, ie), Bc = (e, t) => {
|
|
|
3054
3056
|
}
|
|
3055
3057
|
else {
|
|
3056
3058
|
const g = r.struct.id.clock + r.struct.length - d.id.clock;
|
|
3057
|
-
g > 0 && (r.struct.constructor === V ? r.struct.length -= g : d =
|
|
3059
|
+
g > 0 && (r.struct.constructor === V ? r.struct.length -= g : d = jc(d, g)), r.struct.mergeWith(
|
|
3058
3060
|
/** @type {any} */
|
|
3059
3061
|
d
|
|
3060
3062
|
) || (et(c, r.struct, r.offset), r = { struct: d, offset: 0 }, a.next());
|
|
@@ -3070,7 +3072,7 @@ const Vc = (e) => Ae(e, bi, ie), Bc = (e, t) => {
|
|
|
3070
3072
|
r !== null && (et(c, r.struct, r.offset), r = null), Pn(c);
|
|
3071
3073
|
const l = s.map((a) => Kn(a)), h = wn(l);
|
|
3072
3074
|
return $t(o, h), o.toUint8Array();
|
|
3073
|
-
},
|
|
3075
|
+
}, Kc = (e, t, n = Ut, s = at) => {
|
|
3074
3076
|
const i = Ti(t), r = new s(), o = new Gn(r), c = new n(gt(e)), l = new Yn(c, !1);
|
|
3075
3077
|
for (; l.curr; ) {
|
|
3076
3078
|
const a = l.curr, u = a.id.client, d = i.get(u) || 0;
|
|
@@ -3098,17 +3100,17 @@ const Vc = (e) => Ae(e, bi, ie), Bc = (e, t) => {
|
|
|
3098
3100
|
w(t, e.clientStructs.length);
|
|
3099
3101
|
for (let n = 0; n < e.clientStructs.length; n++) {
|
|
3100
3102
|
const s = e.clientStructs[n];
|
|
3101
|
-
w(t, s.written),
|
|
3103
|
+
w(t, s.written), $e(t, s.restEncoder);
|
|
3102
3104
|
}
|
|
3103
|
-
},
|
|
3105
|
+
}, Hc = (e, t, n, s) => {
|
|
3104
3106
|
const i = new n(gt(e)), r = new Yn(i, !1), o = new s(), c = new Gn(o);
|
|
3105
3107
|
for (let h = r.curr; h !== null; h = r.next())
|
|
3106
3108
|
et(c, t(h), 0);
|
|
3107
3109
|
Pn(c);
|
|
3108
3110
|
const l = Kn(i);
|
|
3109
3111
|
return $t(o, l), o.toUint8Array();
|
|
3110
|
-
},
|
|
3111
|
-
class
|
|
3112
|
+
}, Yc = (e) => Hc(e, ao, Ut, ie), Es = "You must not compute changes after the event-handler fired.";
|
|
3113
|
+
class Ge {
|
|
3112
3114
|
/**
|
|
3113
3115
|
* @param {T} target The changed type.
|
|
3114
3116
|
* @param {Transaction} transaction
|
|
@@ -3130,7 +3132,7 @@ class Ye {
|
|
|
3130
3132
|
* type === event.target // => true
|
|
3131
3133
|
*/
|
|
3132
3134
|
get path() {
|
|
3133
|
-
return this._path || (this._path =
|
|
3135
|
+
return this._path || (this._path = Gc(this.currentTarget, this.target));
|
|
3134
3136
|
}
|
|
3135
3137
|
/**
|
|
3136
3138
|
* Check if a struct is deleted by this event.
|
|
@@ -3165,13 +3167,13 @@ class Ye {
|
|
|
3165
3167
|
l = l.left;
|
|
3166
3168
|
if (this.deletes(r))
|
|
3167
3169
|
if (l !== null && this.deletes(l))
|
|
3168
|
-
o = "delete", c =
|
|
3170
|
+
o = "delete", c = ze(l.content.getContent());
|
|
3169
3171
|
else
|
|
3170
3172
|
return;
|
|
3171
3173
|
else
|
|
3172
|
-
l !== null && this.deletes(l) ? (o = "update", c =
|
|
3174
|
+
l !== null && this.deletes(l) ? (o = "update", c = ze(l.content.getContent())) : (o = "add", c = void 0);
|
|
3173
3175
|
} else if (this.deletes(r))
|
|
3174
|
-
o = "delete", c =
|
|
3176
|
+
o = "delete", c = ze(
|
|
3175
3177
|
/** @type {Item} */
|
|
3176
3178
|
r.content.getContent()
|
|
3177
3179
|
);
|
|
@@ -3242,7 +3244,7 @@ class Ye {
|
|
|
3242
3244
|
);
|
|
3243
3245
|
}
|
|
3244
3246
|
}
|
|
3245
|
-
const
|
|
3247
|
+
const Gc = (e, t) => {
|
|
3246
3248
|
const n = [];
|
|
3247
3249
|
for (; t._item !== null && t !== e; ) {
|
|
3248
3250
|
if (t._item.parentSub !== null)
|
|
@@ -3264,7 +3266,7 @@ const Hc = (e, t) => {
|
|
|
3264
3266
|
pi("Invalid access: Add Yjs type to a document before reading data.");
|
|
3265
3267
|
}, $i = 80;
|
|
3266
3268
|
let Jn = 0;
|
|
3267
|
-
class
|
|
3269
|
+
class Pc {
|
|
3268
3270
|
/**
|
|
3269
3271
|
* @param {Item} p
|
|
3270
3272
|
* @param {number} index
|
|
@@ -3273,24 +3275,24 @@ class Yc {
|
|
|
3273
3275
|
t.marker = !0, this.p = t, this.index = n, this.timestamp = Jn++;
|
|
3274
3276
|
}
|
|
3275
3277
|
}
|
|
3276
|
-
const
|
|
3278
|
+
const Jc = (e) => {
|
|
3277
3279
|
e.timestamp = Jn++;
|
|
3278
3280
|
}, Vi = (e, t, n) => {
|
|
3279
3281
|
e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp = Jn++;
|
|
3280
|
-
},
|
|
3282
|
+
}, Wc = (e, t, n) => {
|
|
3281
3283
|
if (e.length >= $i) {
|
|
3282
3284
|
const s = e.reduce((i, r) => i.timestamp < r.timestamp ? i : r);
|
|
3283
3285
|
return Vi(s, t, n), s;
|
|
3284
3286
|
} else {
|
|
3285
|
-
const s = new
|
|
3287
|
+
const s = new Pc(t, n);
|
|
3286
3288
|
return e.push(s), s;
|
|
3287
3289
|
}
|
|
3288
|
-
},
|
|
3290
|
+
}, Pe = (e, t) => {
|
|
3289
3291
|
if (e._start === null || t === 0 || e._searchMarker === null)
|
|
3290
3292
|
return null;
|
|
3291
3293
|
const n = e._searchMarker.length === 0 ? null : e._searchMarker.reduce((r, o) => ge(t - r.index) < ge(t - o.index) ? r : o);
|
|
3292
3294
|
let s = e._start, i = 0;
|
|
3293
|
-
for (n !== null && (s = n.p, i = n.index,
|
|
3295
|
+
for (n !== null && (s = n.p, i = n.index, Jc(n)); s.right !== null && i < t; ) {
|
|
3294
3296
|
if (!s.deleted && s.countable) {
|
|
3295
3297
|
if (t < i + s.length)
|
|
3296
3298
|
break;
|
|
@@ -3303,7 +3305,7 @@ const Gc = (e) => {
|
|
|
3303
3305
|
for (; s.left !== null && s.left.id.client === s.id.client && s.left.id.clock + s.left.length === s.id.clock; )
|
|
3304
3306
|
s = s.left, !s.deleted && s.countable && (i -= s.length);
|
|
3305
3307
|
return n !== null && ge(n.index - i) < /** @type {YText|YArray<any>} */
|
|
3306
|
-
s.parent.length / $i ? (Vi(n, s, i), n) :
|
|
3308
|
+
s.parent.length / $i ? (Vi(n, s, i), n) : Wc(e._searchMarker, s, i);
|
|
3307
3309
|
}, qt = (e, t, n) => {
|
|
3308
3310
|
for (let s = e.length - 1; s >= 0; s--) {
|
|
3309
3311
|
const i = e[s];
|
|
@@ -3319,7 +3321,7 @@ const Gc = (e) => {
|
|
|
3319
3321
|
}
|
|
3320
3322
|
(t < i.index || n > 0 && t === i.index) && (i.index = ft(t, i.index + n));
|
|
3321
3323
|
}
|
|
3322
|
-
},
|
|
3324
|
+
}, Je = (e, t, n) => {
|
|
3323
3325
|
const s = e, i = t.changedParentTypes;
|
|
3324
3326
|
for (; q(i, e, () => []).push(n), e._item !== null; )
|
|
3325
3327
|
e = /** @type {AbstractType<any>} */
|
|
@@ -3463,7 +3465,7 @@ const Bi = (e, t, n) => {
|
|
|
3463
3465
|
n = n.right;
|
|
3464
3466
|
}
|
|
3465
3467
|
return t;
|
|
3466
|
-
},
|
|
3468
|
+
}, qh = (e, t) => {
|
|
3467
3469
|
const n = [];
|
|
3468
3470
|
let s = e._start;
|
|
3469
3471
|
for (; s !== null; ) {
|
|
@@ -3490,7 +3492,7 @@ const Bi = (e, t, n) => {
|
|
|
3490
3492
|
return Qt(e, (s, i) => {
|
|
3491
3493
|
n.push(t(s, i, e));
|
|
3492
3494
|
}), n;
|
|
3493
|
-
},
|
|
3495
|
+
}, zc = (e) => {
|
|
3494
3496
|
let t = e._start, n = null, s = 0;
|
|
3495
3497
|
return {
|
|
3496
3498
|
[Symbol.iterator]() {
|
|
@@ -3516,7 +3518,7 @@ const Bi = (e, t, n) => {
|
|
|
3516
3518
|
};
|
|
3517
3519
|
}, Ki = (e, t) => {
|
|
3518
3520
|
e.doc ?? U();
|
|
3519
|
-
const n =
|
|
3521
|
+
const n = Pe(e, t);
|
|
3520
3522
|
let s = e._start;
|
|
3521
3523
|
for (n !== null && (s = n.p, t -= n.index); s !== null; s = s.right)
|
|
3522
3524
|
if (!s.deleted && s.countable) {
|
|
@@ -3524,7 +3526,7 @@ const Bi = (e, t, n) => {
|
|
|
3524
3526
|
return s.content.getContent()[t];
|
|
3525
3527
|
t -= s.length;
|
|
3526
3528
|
}
|
|
3527
|
-
},
|
|
3529
|
+
}, ve = (e, t, n, s) => {
|
|
3528
3530
|
let i = n;
|
|
3529
3531
|
const r = e.doc, o = r.clientID, c = r.store, l = n === null ? t._start : n.right;
|
|
3530
3532
|
let h = [];
|
|
@@ -3570,8 +3572,8 @@ const Bi = (e, t, n) => {
|
|
|
3570
3572
|
if (n > t._length)
|
|
3571
3573
|
throw Hi();
|
|
3572
3574
|
if (n === 0)
|
|
3573
|
-
return t._searchMarker && qt(t._searchMarker, n, s.length),
|
|
3574
|
-
const i = n, r =
|
|
3575
|
+
return t._searchMarker && qt(t._searchMarker, n, s.length), ve(e, t, null, s);
|
|
3576
|
+
const i = n, r = Pe(t, n);
|
|
3575
3577
|
let o = t._start;
|
|
3576
3578
|
for (r !== null && (o = r.p, n -= r.index, n === 0 && (o = o.prev, n += o && o.countable && !o.deleted ? o.length : 0)); o !== null; o = o.right)
|
|
3577
3579
|
if (!o.deleted && o.countable) {
|
|
@@ -3581,17 +3583,17 @@ const Bi = (e, t, n) => {
|
|
|
3581
3583
|
}
|
|
3582
3584
|
n -= o.length;
|
|
3583
3585
|
}
|
|
3584
|
-
return t._searchMarker && qt(t._searchMarker, i, s.length),
|
|
3585
|
-
},
|
|
3586
|
+
return t._searchMarker && qt(t._searchMarker, i, s.length), ve(e, t, o, s);
|
|
3587
|
+
}, Xc = (e, t, n) => {
|
|
3586
3588
|
let i = (t._searchMarker || []).reduce((r, o) => o.index > r.index ? o : r, { index: 0, p: t._start }).p;
|
|
3587
3589
|
if (i)
|
|
3588
3590
|
for (; i.right; )
|
|
3589
3591
|
i = i.right;
|
|
3590
|
-
return
|
|
3592
|
+
return ve(e, t, i, n);
|
|
3591
3593
|
}, Gi = (e, t, n, s) => {
|
|
3592
3594
|
if (s === 0)
|
|
3593
3595
|
return;
|
|
3594
|
-
const i = n, r = s, o =
|
|
3596
|
+
const i = n, r = s, o = Pe(t, n);
|
|
3595
3597
|
let c = t._start;
|
|
3596
3598
|
for (o !== null && (c = o.p, n -= o.index); c !== null && n > 0; c = c.right)
|
|
3597
3599
|
!c.deleted && c.countable && (n < c.length && N(e, m(c.id.client, c.id.clock + n)), n -= c.length);
|
|
@@ -3605,7 +3607,7 @@ const Bi = (e, t, n) => {
|
|
|
3605
3607
|
-r + s
|
|
3606
3608
|
/* in case we remove the above exception */
|
|
3607
3609
|
);
|
|
3608
|
-
},
|
|
3610
|
+
}, Ie = (e, t, n) => {
|
|
3609
3611
|
const s = t._map.get(n);
|
|
3610
3612
|
s !== void 0 && s.delete(e);
|
|
3611
3613
|
}, Wn = (e, t, n, s) => {
|
|
@@ -3656,7 +3658,7 @@ const Bi = (e, t, n) => {
|
|
|
3656
3658
|
e.doc ?? U();
|
|
3657
3659
|
const n = e._map.get(t);
|
|
3658
3660
|
return n !== void 0 && !n.deleted;
|
|
3659
|
-
},
|
|
3661
|
+
}, qc = (e, t) => {
|
|
3660
3662
|
const n = {};
|
|
3661
3663
|
return e._map.forEach((s, i) => {
|
|
3662
3664
|
let r = s;
|
|
@@ -3664,12 +3666,12 @@ const Bi = (e, t, n) => {
|
|
|
3664
3666
|
r = r.left;
|
|
3665
3667
|
r !== null && it(r, t) && (n[i] = r.content.getContent()[r.length - 1]);
|
|
3666
3668
|
}), n;
|
|
3667
|
-
}, ae = (e) => (e.doc ?? U(),
|
|
3669
|
+
}, ae = (e) => (e.doc ?? U(), dc(
|
|
3668
3670
|
e._map.entries(),
|
|
3669
3671
|
/** @param {any} entry */
|
|
3670
3672
|
(t) => !t[1].deleted
|
|
3671
3673
|
));
|
|
3672
|
-
class
|
|
3674
|
+
class Qc extends Ge {
|
|
3673
3675
|
}
|
|
3674
3676
|
class Et extends T {
|
|
3675
3677
|
constructor() {
|
|
@@ -3734,7 +3736,7 @@ class Et extends T {
|
|
|
3734
3736
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
3735
3737
|
*/
|
|
3736
3738
|
_callObserver(t, n) {
|
|
3737
|
-
super._callObserver(t, n),
|
|
3739
|
+
super._callObserver(t, n), Je(this, t, new Qc(this, t));
|
|
3738
3740
|
}
|
|
3739
3741
|
/**
|
|
3740
3742
|
* Inserts new content at an index.
|
|
@@ -3772,7 +3774,7 @@ class Et extends T {
|
|
|
3772
3774
|
*/
|
|
3773
3775
|
push(t) {
|
|
3774
3776
|
this.doc !== null ? S(this.doc, (n) => {
|
|
3775
|
-
|
|
3777
|
+
Xc(
|
|
3776
3778
|
n,
|
|
3777
3779
|
this,
|
|
3778
3780
|
/** @type {any} */
|
|
@@ -3863,17 +3865,17 @@ class Et extends T {
|
|
|
3863
3865
|
* @return {IterableIterator<T>}
|
|
3864
3866
|
*/
|
|
3865
3867
|
[Symbol.iterator]() {
|
|
3866
|
-
return
|
|
3868
|
+
return zc(this);
|
|
3867
3869
|
}
|
|
3868
3870
|
/**
|
|
3869
3871
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3870
3872
|
*/
|
|
3871
3873
|
_write(t) {
|
|
3872
|
-
t.writeTypeRef(
|
|
3874
|
+
t.writeTypeRef(El);
|
|
3873
3875
|
}
|
|
3874
3876
|
}
|
|
3875
|
-
const
|
|
3876
|
-
class
|
|
3877
|
+
const Zc = (e) => new Et();
|
|
3878
|
+
class tl extends Ge {
|
|
3877
3879
|
/**
|
|
3878
3880
|
* @param {YMap<T>} ymap The YArray that changed.
|
|
3879
3881
|
* @param {Transaction} transaction
|
|
@@ -3935,7 +3937,7 @@ class Ot extends T {
|
|
|
3935
3937
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
3936
3938
|
*/
|
|
3937
3939
|
_callObserver(t, n) {
|
|
3938
|
-
|
|
3940
|
+
Je(this, t, new tl(this, t, n));
|
|
3939
3941
|
}
|
|
3940
3942
|
/**
|
|
3941
3943
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -3966,7 +3968,7 @@ class Ot extends T {
|
|
|
3966
3968
|
* @return {IterableIterator<string>}
|
|
3967
3969
|
*/
|
|
3968
3970
|
keys() {
|
|
3969
|
-
return
|
|
3971
|
+
return nn(
|
|
3970
3972
|
ae(this),
|
|
3971
3973
|
/** @param {any} v */
|
|
3972
3974
|
(t) => t[0]
|
|
@@ -3978,7 +3980,7 @@ class Ot extends T {
|
|
|
3978
3980
|
* @return {IterableIterator<MapType>}
|
|
3979
3981
|
*/
|
|
3980
3982
|
values() {
|
|
3981
|
-
return
|
|
3983
|
+
return nn(
|
|
3982
3984
|
ae(this),
|
|
3983
3985
|
/** @param {any} v */
|
|
3984
3986
|
(t) => t[1].content.getContent()[t[1].length - 1]
|
|
@@ -3990,7 +3992,7 @@ class Ot extends T {
|
|
|
3990
3992
|
* @return {IterableIterator<[string, MapType]>}
|
|
3991
3993
|
*/
|
|
3992
3994
|
entries() {
|
|
3993
|
-
return
|
|
3995
|
+
return nn(
|
|
3994
3996
|
ae(this),
|
|
3995
3997
|
/** @param {any} v */
|
|
3996
3998
|
(t) => (
|
|
@@ -4024,7 +4026,7 @@ class Ot extends T {
|
|
|
4024
4026
|
*/
|
|
4025
4027
|
delete(t) {
|
|
4026
4028
|
this.doc !== null ? S(this.doc, (n) => {
|
|
4027
|
-
|
|
4029
|
+
Ie(n, this, t);
|
|
4028
4030
|
}) : this._prelimContent.delete(t);
|
|
4029
4031
|
}
|
|
4030
4032
|
/**
|
|
@@ -4073,7 +4075,7 @@ class Ot extends T {
|
|
|
4073
4075
|
clear() {
|
|
4074
4076
|
this.doc !== null ? S(this.doc, (t) => {
|
|
4075
4077
|
this.forEach(function(n, s, i) {
|
|
4076
|
-
|
|
4078
|
+
Ie(t, i, s);
|
|
4077
4079
|
});
|
|
4078
4080
|
}) : this._prelimContent.clear();
|
|
4079
4081
|
}
|
|
@@ -4081,10 +4083,10 @@ class Ot extends T {
|
|
|
4081
4083
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4082
4084
|
*/
|
|
4083
4085
|
_write(t) {
|
|
4084
|
-
t.writeTypeRef(
|
|
4086
|
+
t.writeTypeRef(Cl);
|
|
4085
4087
|
}
|
|
4086
4088
|
}
|
|
4087
|
-
const
|
|
4089
|
+
const el = (e) => new Ot(), nt = (e, t) => e === t || typeof e == "object" && typeof t == "object" && e && t && lo(e, t);
|
|
4088
4090
|
class kn {
|
|
4089
4091
|
/**
|
|
4090
4092
|
* @param {Item|null} left
|
|
@@ -4132,7 +4134,7 @@ const Cs = (e, t, n) => {
|
|
|
4132
4134
|
}
|
|
4133
4135
|
return t;
|
|
4134
4136
|
}, ue = (e, t, n, s) => {
|
|
4135
|
-
const i = /* @__PURE__ */ new Map(), r = s ?
|
|
4137
|
+
const i = /* @__PURE__ */ new Map(), r = s ? Pe(t, n) : null;
|
|
4136
4138
|
if (r) {
|
|
4137
4139
|
const o = new kn(r.p.left, r.p, r.index, i);
|
|
4138
4140
|
return Cs(e, o, n - r.index);
|
|
@@ -4184,7 +4186,7 @@ const Cs = (e, t, n) => {
|
|
|
4184
4186
|
}
|
|
4185
4187
|
}
|
|
4186
4188
|
return o;
|
|
4187
|
-
},
|
|
4189
|
+
}, sn = (e, t, n, s, i) => {
|
|
4188
4190
|
n.currentAttributes.forEach((d, f) => {
|
|
4189
4191
|
i[f] === void 0 && (i[f] = null);
|
|
4190
4192
|
});
|
|
@@ -4271,7 +4273,7 @@ const Cs = (e, t, n) => {
|
|
|
4271
4273
|
t.right;
|
|
4272
4274
|
}
|
|
4273
4275
|
return c;
|
|
4274
|
-
},
|
|
4276
|
+
}, nl = (e, t) => {
|
|
4275
4277
|
for (; t && t.right && (t.right.deleted || !t.right.countable); )
|
|
4276
4278
|
t = t.right;
|
|
4277
4279
|
const n = /* @__PURE__ */ new Set();
|
|
@@ -4285,7 +4287,7 @@ const Cs = (e, t, n) => {
|
|
|
4285
4287
|
}
|
|
4286
4288
|
t = t.left;
|
|
4287
4289
|
}
|
|
4288
|
-
},
|
|
4290
|
+
}, sl = (e) => {
|
|
4289
4291
|
let t = 0;
|
|
4290
4292
|
return S(
|
|
4291
4293
|
/** @type {Doc} */
|
|
@@ -4314,7 +4316,7 @@ const Cs = (e, t, n) => {
|
|
|
4314
4316
|
}
|
|
4315
4317
|
}
|
|
4316
4318
|
), t;
|
|
4317
|
-
},
|
|
4319
|
+
}, il = (e) => {
|
|
4318
4320
|
const t = /* @__PURE__ */ new Set(), n = e.doc;
|
|
4319
4321
|
for (const [s, i] of e.afterState.entries()) {
|
|
4320
4322
|
const r = e.beforeState.get(s) || 0;
|
|
@@ -4345,10 +4347,10 @@ const Cs = (e, t, n) => {
|
|
|
4345
4347
|
/** @type {YText} */
|
|
4346
4348
|
i.parent
|
|
4347
4349
|
);
|
|
4348
|
-
i.content.constructor === D ? t.add(r) :
|
|
4350
|
+
i.content.constructor === D ? t.add(r) : nl(s, i);
|
|
4349
4351
|
});
|
|
4350
4352
|
for (const i of t)
|
|
4351
|
-
|
|
4353
|
+
sl(i);
|
|
4352
4354
|
});
|
|
4353
4355
|
}, As = (e, t, n) => {
|
|
4354
4356
|
const s = n, i = an(t.currentAttributes), r = t.right;
|
|
@@ -4371,7 +4373,7 @@ const Cs = (e, t, n) => {
|
|
|
4371
4373
|
);
|
|
4372
4374
|
return o._searchMarker && qt(o._searchMarker, t.index, -s + n), t;
|
|
4373
4375
|
};
|
|
4374
|
-
class
|
|
4376
|
+
class rl extends Ge {
|
|
4375
4377
|
/**
|
|
4376
4378
|
* @param {YText} ytext
|
|
4377
4379
|
* @param {Transaction} transaction
|
|
@@ -4432,7 +4434,7 @@ class sl extends Ye {
|
|
|
4432
4434
|
}))), h = "";
|
|
4433
4435
|
break;
|
|
4434
4436
|
case "retain":
|
|
4435
|
-
a > 0 && (f = { retain: a },
|
|
4437
|
+
a > 0 && (f = { retain: a }, co(l) || (f.attributes = io({}, l))), a = 0;
|
|
4436
4438
|
break;
|
|
4437
4439
|
}
|
|
4438
4440
|
f && n.push(f), c = null;
|
|
@@ -4542,8 +4544,8 @@ class Lt extends T {
|
|
|
4542
4544
|
*/
|
|
4543
4545
|
_callObserver(t, n) {
|
|
4544
4546
|
super._callObserver(t, n);
|
|
4545
|
-
const s = new
|
|
4546
|
-
|
|
4547
|
+
const s = new rl(this, t, n);
|
|
4548
|
+
Je(this, t, s), !t.local && this._hasFormatting && (t._needFormattingCleanup = !0);
|
|
4547
4549
|
}
|
|
4548
4550
|
/**
|
|
4549
4551
|
* Returns the unformatted string representation of this YText type.
|
|
@@ -4585,7 +4587,7 @@ class Lt extends T {
|
|
|
4585
4587
|
if (o.insert !== void 0) {
|
|
4586
4588
|
const c = !n && typeof o.insert == "string" && r === t.length - 1 && i.right === null && o.insert.slice(-1) === `
|
|
4587
4589
|
` ? o.insert.slice(0, -1) : o.insert;
|
|
4588
|
-
(typeof c != "string" || c.length > 0) &&
|
|
4590
|
+
(typeof c != "string" || c.length > 0) && sn(s, this, i, c, o.attributes || {});
|
|
4589
4591
|
} else o.retain !== void 0 ? Ds(s, this, i, o.retain, o.attributes || {}) : o.delete !== void 0 && As(s, i, o.delete);
|
|
4590
4592
|
}
|
|
4591
4593
|
}) : this._pending.push(() => this.applyDelta(t));
|
|
@@ -4680,7 +4682,7 @@ class Lt extends T {
|
|
|
4680
4682
|
const o = ue(r, this, t, !s);
|
|
4681
4683
|
s || (s = {}, o.currentAttributes.forEach((c, l) => {
|
|
4682
4684
|
s[l] = c;
|
|
4683
|
-
})),
|
|
4685
|
+
})), sn(r, this, o, n, s);
|
|
4684
4686
|
}) : this._pending.push(() => this.insert(t, n, s));
|
|
4685
4687
|
}
|
|
4686
4688
|
/**
|
|
@@ -4697,7 +4699,7 @@ class Lt extends T {
|
|
|
4697
4699
|
const i = this.doc;
|
|
4698
4700
|
i !== null ? S(i, (r) => {
|
|
4699
4701
|
const o = ue(r, this, t, !s);
|
|
4700
|
-
|
|
4702
|
+
sn(r, this, o, n, s || {});
|
|
4701
4703
|
}) : this._pending.push(() => this.insertEmbed(t, n, s || {}));
|
|
4702
4704
|
}
|
|
4703
4705
|
/**
|
|
@@ -4746,7 +4748,7 @@ class Lt extends T {
|
|
|
4746
4748
|
*/
|
|
4747
4749
|
removeAttribute(t) {
|
|
4748
4750
|
this.doc !== null ? S(this.doc, (n) => {
|
|
4749
|
-
|
|
4751
|
+
Ie(n, this, t);
|
|
4750
4752
|
}) : this._pending.push(() => this.removeAttribute(t));
|
|
4751
4753
|
}
|
|
4752
4754
|
/**
|
|
@@ -4797,11 +4799,11 @@ class Lt extends T {
|
|
|
4797
4799
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4798
4800
|
*/
|
|
4799
4801
|
_write(t) {
|
|
4800
|
-
t.writeTypeRef(
|
|
4802
|
+
t.writeTypeRef(Dl);
|
|
4801
4803
|
}
|
|
4802
4804
|
}
|
|
4803
|
-
const
|
|
4804
|
-
class
|
|
4805
|
+
const ol = (e) => new Lt();
|
|
4806
|
+
class rn {
|
|
4805
4807
|
/**
|
|
4806
4808
|
* @param {YXmlFragment | YXmlElement} root
|
|
4807
4809
|
* @param {function(AbstractType<any>):boolean} [f]
|
|
@@ -4910,7 +4912,7 @@ class ut extends T {
|
|
|
4910
4912
|
* @public
|
|
4911
4913
|
*/
|
|
4912
4914
|
createTreeWalker(t) {
|
|
4913
|
-
return new
|
|
4915
|
+
return new rn(this, t);
|
|
4914
4916
|
}
|
|
4915
4917
|
/**
|
|
4916
4918
|
* Returns the first YXmlElement that matches the query.
|
|
@@ -4929,7 +4931,7 @@ class ut extends T {
|
|
|
4929
4931
|
*/
|
|
4930
4932
|
querySelector(t) {
|
|
4931
4933
|
t = t.toUpperCase();
|
|
4932
|
-
const s = new
|
|
4934
|
+
const s = new rn(this, (i) => i.nodeName && i.nodeName.toUpperCase() === t).next();
|
|
4933
4935
|
return s.done ? null : s.value;
|
|
4934
4936
|
}
|
|
4935
4937
|
/**
|
|
@@ -4944,7 +4946,7 @@ class ut extends T {
|
|
|
4944
4946
|
* @public
|
|
4945
4947
|
*/
|
|
4946
4948
|
querySelectorAll(t) {
|
|
4947
|
-
return t = t.toUpperCase(), X(new
|
|
4949
|
+
return t = t.toUpperCase(), X(new rn(this, (n) => n.nodeName && n.nodeName.toUpperCase() === t));
|
|
4948
4950
|
}
|
|
4949
4951
|
/**
|
|
4950
4952
|
* Creates YXmlEvent and calls observers.
|
|
@@ -4953,7 +4955,7 @@ class ut extends T {
|
|
|
4953
4955
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
4954
4956
|
*/
|
|
4955
4957
|
_callObserver(t, n) {
|
|
4956
|
-
|
|
4958
|
+
Je(this, t, new hl(this, n, t));
|
|
4957
4959
|
}
|
|
4958
4960
|
/**
|
|
4959
4961
|
* Get the string representation of all the children of this YXmlFragment.
|
|
@@ -5019,7 +5021,7 @@ class ut extends T {
|
|
|
5019
5021
|
if (this.doc !== null)
|
|
5020
5022
|
S(this.doc, (s) => {
|
|
5021
5023
|
const i = t && t instanceof T ? t._item : t;
|
|
5022
|
-
|
|
5024
|
+
ve(s, this, i, n);
|
|
5023
5025
|
});
|
|
5024
5026
|
else {
|
|
5025
5027
|
const s = (
|
|
@@ -5103,10 +5105,10 @@ class ut extends T {
|
|
|
5103
5105
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
5104
5106
|
*/
|
|
5105
5107
|
_write(t) {
|
|
5106
|
-
t.writeTypeRef(
|
|
5108
|
+
t.writeTypeRef(Tl);
|
|
5107
5109
|
}
|
|
5108
5110
|
}
|
|
5109
|
-
const
|
|
5111
|
+
const cl = (e) => new ut();
|
|
5110
5112
|
class Nt extends ut {
|
|
5111
5113
|
constructor(t = "UNDEFINED") {
|
|
5112
5114
|
super(), this.nodeName = t, this._prelimAttrs = /* @__PURE__ */ new Map();
|
|
@@ -5166,7 +5168,7 @@ class Nt extends ut {
|
|
|
5166
5168
|
*/
|
|
5167
5169
|
clone() {
|
|
5168
5170
|
const t = new Nt(this.nodeName), n = this.getAttributes();
|
|
5169
|
-
return
|
|
5171
|
+
return oo(n, (s, i) => {
|
|
5170
5172
|
t.setAttribute(
|
|
5171
5173
|
i,
|
|
5172
5174
|
/** @type {any} */
|
|
@@ -5205,7 +5207,7 @@ class Nt extends ut {
|
|
|
5205
5207
|
*/
|
|
5206
5208
|
removeAttribute(t) {
|
|
5207
5209
|
this.doc !== null ? S(this.doc, (n) => {
|
|
5208
|
-
|
|
5210
|
+
Ie(n, this, t);
|
|
5209
5211
|
}) : this._prelimAttrs.delete(t);
|
|
5210
5212
|
}
|
|
5211
5213
|
/**
|
|
@@ -5265,7 +5267,7 @@ class Nt extends ut {
|
|
|
5265
5267
|
getAttributes(t) {
|
|
5266
5268
|
return (
|
|
5267
5269
|
/** @type {any} */
|
|
5268
|
-
t ?
|
|
5270
|
+
t ? qc(this, t) : Pi(this)
|
|
5269
5271
|
);
|
|
5270
5272
|
}
|
|
5271
5273
|
/**
|
|
@@ -5302,11 +5304,11 @@ class Nt extends ut {
|
|
|
5302
5304
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
5303
5305
|
*/
|
|
5304
5306
|
_write(t) {
|
|
5305
|
-
t.writeTypeRef(
|
|
5307
|
+
t.writeTypeRef(Al), t.writeKey(this.nodeName);
|
|
5306
5308
|
}
|
|
5307
5309
|
}
|
|
5308
|
-
const
|
|
5309
|
-
class
|
|
5310
|
+
const ll = (e) => new Nt(e.readKey());
|
|
5311
|
+
class hl extends Ge {
|
|
5310
5312
|
/**
|
|
5311
5313
|
* @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
|
|
5312
5314
|
* @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
|
|
@@ -5320,7 +5322,7 @@ class cl extends Ye {
|
|
|
5320
5322
|
});
|
|
5321
5323
|
}
|
|
5322
5324
|
}
|
|
5323
|
-
class
|
|
5325
|
+
class Ue extends Ot {
|
|
5324
5326
|
/**
|
|
5325
5327
|
* @param {string} hookName nodeName of the Dom Node.
|
|
5326
5328
|
*/
|
|
@@ -5331,7 +5333,7 @@ class Ie extends Ot {
|
|
|
5331
5333
|
* Creates an Item with the same effect as this Item (without position effect)
|
|
5332
5334
|
*/
|
|
5333
5335
|
_copy() {
|
|
5334
|
-
return new
|
|
5336
|
+
return new Ue(this.hookName);
|
|
5335
5337
|
}
|
|
5336
5338
|
/**
|
|
5337
5339
|
* Makes a copy of this data type that can be included somewhere else.
|
|
@@ -5341,7 +5343,7 @@ class Ie extends Ot {
|
|
|
5341
5343
|
* @return {YXmlHook}
|
|
5342
5344
|
*/
|
|
5343
5345
|
clone() {
|
|
5344
|
-
const t = new
|
|
5346
|
+
const t = new Ue(this.hookName);
|
|
5345
5347
|
return this.forEach((n, s) => {
|
|
5346
5348
|
t.set(s, n);
|
|
5347
5349
|
}), t;
|
|
@@ -5375,11 +5377,11 @@ class Ie extends Ot {
|
|
|
5375
5377
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
5376
5378
|
*/
|
|
5377
5379
|
_write(t) {
|
|
5378
|
-
t.writeTypeRef(
|
|
5380
|
+
t.writeTypeRef(vl), t.writeKey(this.hookName);
|
|
5379
5381
|
}
|
|
5380
5382
|
}
|
|
5381
|
-
const
|
|
5382
|
-
class
|
|
5383
|
+
const al = (e) => new Ue(e.readKey());
|
|
5384
|
+
class Oe extends Lt {
|
|
5383
5385
|
/**
|
|
5384
5386
|
* @type {YXmlElement|YXmlText|null}
|
|
5385
5387
|
*/
|
|
@@ -5403,7 +5405,7 @@ class Ue extends Lt {
|
|
|
5403
5405
|
) : null;
|
|
5404
5406
|
}
|
|
5405
5407
|
_copy() {
|
|
5406
|
-
return new
|
|
5408
|
+
return new Oe();
|
|
5407
5409
|
}
|
|
5408
5410
|
/**
|
|
5409
5411
|
* Makes a copy of this data type that can be included somewhere else.
|
|
@@ -5413,7 +5415,7 @@ class Ue extends Lt {
|
|
|
5413
5415
|
* @return {YXmlText}
|
|
5414
5416
|
*/
|
|
5415
5417
|
clone() {
|
|
5416
|
-
const t = new
|
|
5418
|
+
const t = new Oe();
|
|
5417
5419
|
return t.applyDelta(this.toDelta()), t;
|
|
5418
5420
|
}
|
|
5419
5421
|
/**
|
|
@@ -5471,10 +5473,10 @@ class Ue extends Lt {
|
|
|
5471
5473
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
5472
5474
|
*/
|
|
5473
5475
|
_write(t) {
|
|
5474
|
-
t.writeTypeRef(
|
|
5476
|
+
t.writeTypeRef(Il);
|
|
5475
5477
|
}
|
|
5476
5478
|
}
|
|
5477
|
-
const
|
|
5479
|
+
const ul = (e) => new Oe();
|
|
5478
5480
|
class Xn {
|
|
5479
5481
|
/**
|
|
5480
5482
|
* @param {ID} id
|
|
@@ -5515,7 +5517,7 @@ class Xn {
|
|
|
5515
5517
|
throw K();
|
|
5516
5518
|
}
|
|
5517
5519
|
}
|
|
5518
|
-
const
|
|
5520
|
+
const dl = 0;
|
|
5519
5521
|
class $ extends Xn {
|
|
5520
5522
|
get deleted() {
|
|
5521
5523
|
return !0;
|
|
@@ -5541,7 +5543,7 @@ class $ extends Xn {
|
|
|
5541
5543
|
* @param {number} offset
|
|
5542
5544
|
*/
|
|
5543
5545
|
write(t, n) {
|
|
5544
|
-
t.writeInfo(
|
|
5546
|
+
t.writeInfo(dl), t.writeLen(this.length - n);
|
|
5545
5547
|
}
|
|
5546
5548
|
/**
|
|
5547
5549
|
* @param {Transaction} transaction
|
|
@@ -5627,7 +5629,7 @@ class oe {
|
|
|
5627
5629
|
return 3;
|
|
5628
5630
|
}
|
|
5629
5631
|
}
|
|
5630
|
-
const
|
|
5632
|
+
const fl = (e) => new oe(e.readBuf());
|
|
5631
5633
|
class Zt {
|
|
5632
5634
|
/**
|
|
5633
5635
|
* @param {number} len
|
|
@@ -5705,7 +5707,7 @@ class Zt {
|
|
|
5705
5707
|
return 1;
|
|
5706
5708
|
}
|
|
5707
5709
|
}
|
|
5708
|
-
const
|
|
5710
|
+
const gl = (e) => new Zt(e.readLen()), Qi = (e, t) => new pt({ guid: e, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
|
|
5709
5711
|
class ce {
|
|
5710
5712
|
/**
|
|
5711
5713
|
* @param {Doc} doc
|
|
@@ -5785,7 +5787,7 @@ class ce {
|
|
|
5785
5787
|
return 9;
|
|
5786
5788
|
}
|
|
5787
5789
|
}
|
|
5788
|
-
const
|
|
5790
|
+
const pl = (e) => new ce(Qi(e.readString(), e.readAny()));
|
|
5789
5791
|
class wt {
|
|
5790
5792
|
/**
|
|
5791
5793
|
* @param {Object} embed
|
|
@@ -5861,7 +5863,7 @@ class wt {
|
|
|
5861
5863
|
return 5;
|
|
5862
5864
|
}
|
|
5863
5865
|
}
|
|
5864
|
-
const
|
|
5866
|
+
const wl = (e) => new wt(e.readJSON());
|
|
5865
5867
|
class D {
|
|
5866
5868
|
/**
|
|
5867
5869
|
* @param {string} key
|
|
@@ -5943,8 +5945,8 @@ class D {
|
|
|
5943
5945
|
return 6;
|
|
5944
5946
|
}
|
|
5945
5947
|
}
|
|
5946
|
-
const
|
|
5947
|
-
class
|
|
5948
|
+
const yl = (e) => new D(e.readKey(), e.readJSON());
|
|
5949
|
+
class Le {
|
|
5948
5950
|
/**
|
|
5949
5951
|
* @param {Array<any>} arr
|
|
5950
5952
|
*/
|
|
@@ -5973,14 +5975,14 @@ class Oe {
|
|
|
5973
5975
|
* @return {ContentJSON}
|
|
5974
5976
|
*/
|
|
5975
5977
|
copy() {
|
|
5976
|
-
return new
|
|
5978
|
+
return new Le(this.arr);
|
|
5977
5979
|
}
|
|
5978
5980
|
/**
|
|
5979
5981
|
* @param {number} offset
|
|
5980
5982
|
* @return {ContentJSON}
|
|
5981
5983
|
*/
|
|
5982
5984
|
splice(t) {
|
|
5983
|
-
const n = new
|
|
5985
|
+
const n = new Le(this.arr.slice(t));
|
|
5984
5986
|
return this.arr = this.arr.slice(0, t), n;
|
|
5985
5987
|
}
|
|
5986
5988
|
/**
|
|
@@ -6025,20 +6027,20 @@ class Oe {
|
|
|
6025
6027
|
return 2;
|
|
6026
6028
|
}
|
|
6027
6029
|
}
|
|
6028
|
-
const
|
|
6030
|
+
const ml = (e) => {
|
|
6029
6031
|
const t = e.readLen(), n = [];
|
|
6030
6032
|
for (let s = 0; s < t; s++) {
|
|
6031
6033
|
const i = e.readString();
|
|
6032
6034
|
i === "undefined" ? n.push(void 0) : n.push(JSON.parse(i));
|
|
6033
6035
|
}
|
|
6034
|
-
return new
|
|
6035
|
-
},
|
|
6036
|
+
return new Le(n);
|
|
6037
|
+
}, kl = _e("node_env") === "development";
|
|
6036
6038
|
class dt {
|
|
6037
6039
|
/**
|
|
6038
6040
|
* @param {Array<any>} arr
|
|
6039
6041
|
*/
|
|
6040
6042
|
constructor(t) {
|
|
6041
|
-
this.arr = t,
|
|
6043
|
+
this.arr = t, kl && Js(t);
|
|
6042
6044
|
}
|
|
6043
6045
|
/**
|
|
6044
6046
|
* @return {number}
|
|
@@ -6114,7 +6116,7 @@ class dt {
|
|
|
6114
6116
|
return 8;
|
|
6115
6117
|
}
|
|
6116
6118
|
}
|
|
6117
|
-
const
|
|
6119
|
+
const Sl = (e) => {
|
|
6118
6120
|
const t = e.readLen(), n = [];
|
|
6119
6121
|
for (let s = 0; s < t; s++)
|
|
6120
6122
|
n.push(e.readAny());
|
|
@@ -6198,15 +6200,15 @@ class P {
|
|
|
6198
6200
|
return 4;
|
|
6199
6201
|
}
|
|
6200
6202
|
}
|
|
6201
|
-
const
|
|
6202
|
-
qc,
|
|
6203
|
+
const bl = (e) => new P(e.readString()), _l = [
|
|
6203
6204
|
Zc,
|
|
6204
|
-
|
|
6205
|
+
el,
|
|
6205
6206
|
ol,
|
|
6206
|
-
rl,
|
|
6207
6207
|
ll,
|
|
6208
|
-
|
|
6209
|
-
|
|
6208
|
+
cl,
|
|
6209
|
+
al,
|
|
6210
|
+
ul
|
|
6211
|
+
], El = 0, Cl = 1, Dl = 2, Al = 3, Tl = 4, vl = 5, Il = 6;
|
|
6210
6212
|
class J {
|
|
6211
6213
|
/**
|
|
6212
6214
|
* @param {AbstractType<any>} type
|
|
@@ -6299,7 +6301,7 @@ class J {
|
|
|
6299
6301
|
return 7;
|
|
6300
6302
|
}
|
|
6301
6303
|
}
|
|
6302
|
-
const
|
|
6304
|
+
const Ul = (e) => new J(_l[e.readTypeRef()](e)), Sn = (e, t) => {
|
|
6303
6305
|
let n = t, s = 0, i;
|
|
6304
6306
|
do
|
|
6305
6307
|
s > 0 && (n = m(n.client, n.clock + s)), i = _t(e, n), s = n.clock - i.id.clock, n = i.redone;
|
|
@@ -6312,7 +6314,7 @@ const vl = (e) => new J(Sl[e.readTypeRef()](e)), Sn = (e, t) => {
|
|
|
6312
6314
|
for (; e !== null && e.keep !== t; )
|
|
6313
6315
|
e.keep = t, e = /** @type {AbstractType<any>} */
|
|
6314
6316
|
e.parent._item;
|
|
6315
|
-
},
|
|
6317
|
+
}, Ne = (e, t, n) => {
|
|
6316
6318
|
const { client: s, clock: i } = t.id, r = new b(
|
|
6317
6319
|
m(s, i + n),
|
|
6318
6320
|
t,
|
|
@@ -6413,10 +6415,10 @@ class b extends Xn {
|
|
|
6413
6415
|
* @type {boolean}
|
|
6414
6416
|
*/
|
|
6415
6417
|
set marker(t) {
|
|
6416
|
-
(this.info &
|
|
6418
|
+
(this.info & qe) > 0 !== t && (this.info ^= qe);
|
|
6417
6419
|
}
|
|
6418
6420
|
get marker() {
|
|
6419
|
-
return (this.info &
|
|
6421
|
+
return (this.info & qe) > 0;
|
|
6420
6422
|
}
|
|
6421
6423
|
/**
|
|
6422
6424
|
* If true, do not garbage collect this Item.
|
|
@@ -6435,13 +6437,13 @@ class b extends Xn {
|
|
|
6435
6437
|
* @type {Boolean}
|
|
6436
6438
|
*/
|
|
6437
6439
|
get deleted() {
|
|
6438
|
-
return (this.info &
|
|
6440
|
+
return (this.info & Xe) > 0;
|
|
6439
6441
|
}
|
|
6440
6442
|
set deleted(t) {
|
|
6441
|
-
this.deleted !== t && (this.info ^=
|
|
6443
|
+
this.deleted !== t && (this.info ^= Xe);
|
|
6442
6444
|
}
|
|
6443
6445
|
markDeleted() {
|
|
6444
|
-
this.info |=
|
|
6446
|
+
this.info |= Xe;
|
|
6445
6447
|
}
|
|
6446
6448
|
/**
|
|
6447
6449
|
* Return the creator clientID of the missing op or define missing items and return null.
|
|
@@ -6588,7 +6590,7 @@ class b extends Xn {
|
|
|
6588
6590
|
gc(t, n) {
|
|
6589
6591
|
if (!this.deleted)
|
|
6590
6592
|
throw M();
|
|
6591
|
-
this.content.gc(t), n ?
|
|
6593
|
+
this.content.gc(t), n ? xc(t, this, new $(this.id, this.length)) : this.content = new Zt(this.length);
|
|
6592
6594
|
}
|
|
6593
6595
|
/**
|
|
6594
6596
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -6600,7 +6602,7 @@ class b extends Xn {
|
|
|
6600
6602
|
* @param {number} offset
|
|
6601
6603
|
*/
|
|
6602
6604
|
write(t, n) {
|
|
6603
|
-
const s = n > 0 ? m(this.id.client, this.id.clock + n - 1) : this.origin, i = this.rightOrigin, r = this.parentSub, o = this.content.getRef() &
|
|
6605
|
+
const s = n > 0 ? m(this.id.client, this.id.clock + n - 1) : this.origin, i = this.rightOrigin, r = this.parentSub, o = this.content.getRef() & Me | (s === null ? 0 : R) | // origin is defined
|
|
6604
6606
|
(i === null ? 0 : z) | // right origin is defined
|
|
6605
6607
|
(r === null ? 0 : Yt);
|
|
6606
6608
|
if (t.writeInfo(o), s !== null && t.writeLeftID(s), i !== null && t.writeRightID(i), s === null && i === null) {
|
|
@@ -6621,34 +6623,34 @@ class b extends Xn {
|
|
|
6621
6623
|
this.content.write(t, n);
|
|
6622
6624
|
}
|
|
6623
6625
|
}
|
|
6624
|
-
const tr = (e, t) =>
|
|
6626
|
+
const tr = (e, t) => Ol[t & Me](e), Ol = [
|
|
6625
6627
|
() => {
|
|
6626
6628
|
M();
|
|
6627
6629
|
},
|
|
6628
6630
|
// GC is not ItemContent
|
|
6629
|
-
|
|
6631
|
+
gl,
|
|
6630
6632
|
// 1
|
|
6631
|
-
|
|
6633
|
+
ml,
|
|
6632
6634
|
// 2
|
|
6633
|
-
|
|
6635
|
+
fl,
|
|
6634
6636
|
// 3
|
|
6635
|
-
|
|
6637
|
+
bl,
|
|
6636
6638
|
// 4
|
|
6637
|
-
|
|
6639
|
+
wl,
|
|
6638
6640
|
// 5
|
|
6639
|
-
|
|
6641
|
+
yl,
|
|
6640
6642
|
// 6
|
|
6641
|
-
|
|
6643
|
+
Ul,
|
|
6642
6644
|
// 7
|
|
6643
|
-
|
|
6645
|
+
Sl,
|
|
6644
6646
|
// 8
|
|
6645
|
-
|
|
6647
|
+
pl,
|
|
6646
6648
|
// 9
|
|
6647
6649
|
() => {
|
|
6648
6650
|
M();
|
|
6649
6651
|
}
|
|
6650
6652
|
// 10 - Skip is not ItemContent
|
|
6651
|
-
],
|
|
6653
|
+
], Ll = 10;
|
|
6652
6654
|
class V extends Xn {
|
|
6653
6655
|
get deleted() {
|
|
6654
6656
|
return !0;
|
|
@@ -6674,7 +6676,7 @@ class V extends Xn {
|
|
|
6674
6676
|
* @param {number} offset
|
|
6675
6677
|
*/
|
|
6676
6678
|
write(t, n) {
|
|
6677
|
-
t.writeInfo(
|
|
6679
|
+
t.writeInfo(Ll), w(t.restEncoder, this.length - n);
|
|
6678
6680
|
}
|
|
6679
6681
|
/**
|
|
6680
6682
|
* @param {Transaction} transaction
|
|
@@ -6691,20 +6693,8 @@ const er = (
|
|
|
6691
6693
|
), nr = "__ $YJS$ __";
|
|
6692
6694
|
er[nr] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
|
|
6693
6695
|
er[nr] = !0;
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
return window.btoa(e);
|
|
6697
|
-
if (typeof Buffer < "u")
|
|
6698
|
-
return Buffer.from(e).toString("base64");
|
|
6699
|
-
throw new Error("Unable to encode to Base64");
|
|
6700
|
-
}
|
|
6701
|
-
function Ll(e) {
|
|
6702
|
-
const t = JSON.stringify(e);
|
|
6703
|
-
let n = Ol(t);
|
|
6704
|
-
return n = n.replace("+", "-").replace("/", "_").replace(/=+$/, ""), n;
|
|
6705
|
-
}
|
|
6706
|
-
const rn = 3e4;
|
|
6707
|
-
class Nl extends yr {
|
|
6696
|
+
const on = 3e4;
|
|
6697
|
+
class Nl extends kr {
|
|
6708
6698
|
/**
|
|
6709
6699
|
* @param {Y.Doc} doc
|
|
6710
6700
|
*/
|
|
@@ -6712,13 +6702,13 @@ class Nl extends yr {
|
|
|
6712
6702
|
super(), this.doc = t, this.clientID = t.clientID, this.states = /* @__PURE__ */ new Map(), this.meta = /* @__PURE__ */ new Map(), this._checkInterval = /** @type {any} */
|
|
6713
6703
|
setInterval(() => {
|
|
6714
6704
|
const n = Jt();
|
|
6715
|
-
this.getLocalState() !== null &&
|
|
6705
|
+
this.getLocalState() !== null && on / 2 <= n - /** @type {{lastUpdated:number}} */
|
|
6716
6706
|
this.meta.get(this.clientID).lastUpdated && this.setLocalState(this.getLocalState());
|
|
6717
6707
|
const s = [];
|
|
6718
6708
|
this.meta.forEach((i, r) => {
|
|
6719
|
-
r !== this.clientID &&
|
|
6709
|
+
r !== this.clientID && on <= n - i.lastUpdated && this.states.has(r) && s.push(r);
|
|
6720
6710
|
}), s.length > 0 && bn(this, s, "timeout");
|
|
6721
|
-
}, F(
|
|
6711
|
+
}, F(on / 10)), t.on("destroy", () => {
|
|
6722
6712
|
this.destroy();
|
|
6723
6713
|
}), this.setLocalState({});
|
|
6724
6714
|
}
|
|
@@ -6780,7 +6770,7 @@ const bn = (e, t, n) => {
|
|
|
6780
6770
|
}
|
|
6781
6771
|
}
|
|
6782
6772
|
s.length > 0 && (e.emit("change", [{ added: [], updated: [], removed: s }, n]), e.emit("update", [{ added: [], updated: [], removed: s }, n]));
|
|
6783
|
-
},
|
|
6773
|
+
}, cn = (e, t, n = e.states) => {
|
|
6784
6774
|
const s = t.length, i = xt();
|
|
6785
6775
|
w(i, s);
|
|
6786
6776
|
for (let r = 0; r < s; r++) {
|
|
@@ -6811,13 +6801,26 @@ const bn = (e, t, n) => {
|
|
|
6811
6801
|
updated: o,
|
|
6812
6802
|
removed: l
|
|
6813
6803
|
}, n]);
|
|
6814
|
-
}
|
|
6804
|
+
};
|
|
6805
|
+
function Rl(e) {
|
|
6806
|
+
if (typeof window < "u" && window.btoa)
|
|
6807
|
+
return window.btoa(e);
|
|
6808
|
+
if (typeof Buffer < "u")
|
|
6809
|
+
return Buffer.from(e).toString("base64");
|
|
6810
|
+
throw new Error("Unable to encode to Base64");
|
|
6811
|
+
}
|
|
6812
|
+
function Ml(e) {
|
|
6813
|
+
const t = JSON.stringify(e);
|
|
6814
|
+
let n = Rl(t);
|
|
6815
|
+
return n = n.replace("+", "-").replace("/", "_").replace(/=+$/, ""), n;
|
|
6816
|
+
}
|
|
6817
|
+
const sr = 0, Qn = 1, ir = 2, $l = (e, t) => {
|
|
6815
6818
|
w(e, sr);
|
|
6816
|
-
const n =
|
|
6819
|
+
const n = Ac(t);
|
|
6817
6820
|
I(e, n);
|
|
6818
|
-
},
|
|
6821
|
+
}, Vl = (e, t, n) => {
|
|
6819
6822
|
w(e, Qn), I(e, Ai(t, n));
|
|
6820
|
-
},
|
|
6823
|
+
}, Bl = (e, t, n) => Vl(t, n, L(e)), rr = (e, t, n, s) => {
|
|
6821
6824
|
try {
|
|
6822
6825
|
Di(t, L(e), n);
|
|
6823
6826
|
} catch (i) {
|
|
@@ -6826,26 +6829,26 @@ const bn = (e, t, n) => {
|
|
|
6826
6829
|
i
|
|
6827
6830
|
), console.error("Caught error while handling a Yjs update", i);
|
|
6828
6831
|
}
|
|
6829
|
-
},
|
|
6832
|
+
}, Fl = (e, t) => {
|
|
6830
6833
|
w(e, ir), I(e, t);
|
|
6831
|
-
},
|
|
6834
|
+
}, jl = rr, Kl = (e, t, n, s, i) => {
|
|
6832
6835
|
const r = y(e);
|
|
6833
6836
|
switch (r) {
|
|
6834
6837
|
case sr:
|
|
6835
|
-
|
|
6838
|
+
Bl(e, t, n);
|
|
6836
6839
|
break;
|
|
6837
6840
|
case Qn:
|
|
6838
6841
|
rr(e, n, s, i);
|
|
6839
6842
|
break;
|
|
6840
6843
|
case ir:
|
|
6841
|
-
|
|
6844
|
+
jl(e, n, s, i);
|
|
6842
6845
|
break;
|
|
6843
6846
|
default:
|
|
6844
6847
|
throw new Error("Unknown message type");
|
|
6845
6848
|
}
|
|
6846
6849
|
return r;
|
|
6847
6850
|
};
|
|
6848
|
-
var or = 128, me = 127,
|
|
6851
|
+
var or = 128, me = 127, Hl = Math.floor, Yl = (e, t) => e < t ? e : t, Gl = (e, t) => e > t ? e : t, Pl = Number.MAX_SAFE_INTEGER, Jl = (e) => {
|
|
6849
6852
|
const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
|
|
6850
6853
|
for (let i = 0; i < n; i++)
|
|
6851
6854
|
s[i] = /** @type {number} */
|
|
@@ -6854,13 +6857,13 @@ var or = 128, me = 127, jl = Math.floor, Kl = (e, t) => e < t ? e : t, Hl = (e,
|
|
|
6854
6857
|
}, te = (
|
|
6855
6858
|
/** @type {TextEncoder} */
|
|
6856
6859
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
6857
|
-
),
|
|
6858
|
-
|
|
6859
|
-
var cr = (e) => new Error(e),
|
|
6860
|
+
), Wl = (e) => te.encode(e), zl = te ? Wl : Jl, ln = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
6861
|
+
ln && ln.decode(new Uint8Array()).length === 1 && (ln = null);
|
|
6862
|
+
var cr = (e) => new Error(e), Xl = class {
|
|
6860
6863
|
constructor() {
|
|
6861
6864
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
6862
6865
|
}
|
|
6863
|
-
}, Z = () => new
|
|
6866
|
+
}, Z = () => new Xl(), lr = (e) => {
|
|
6864
6867
|
let t = e.cpos;
|
|
6865
6868
|
for (let n = 0; n < e.bufs.length; n++)
|
|
6866
6869
|
t += e.bufs[n].length;
|
|
@@ -6873,26 +6876,26 @@ var cr = (e) => new Error(e), Wl = class {
|
|
|
6873
6876
|
t.set(i, n), n += i.length;
|
|
6874
6877
|
}
|
|
6875
6878
|
return t.set(new Uint8Array(e.cbuf.buffer, 0, e.cpos), n), t;
|
|
6876
|
-
},
|
|
6879
|
+
}, xe = (e, t) => {
|
|
6877
6880
|
const n = e.cbuf.length;
|
|
6878
6881
|
e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
|
|
6879
6882
|
}, j = (e, t) => {
|
|
6880
6883
|
for (; t > me; )
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
}, _n = new Uint8Array(3e4),
|
|
6884
|
-
if (t.length <
|
|
6884
|
+
xe(e, or | me & t), t = Hl(t / 128);
|
|
6885
|
+
xe(e, me & t);
|
|
6886
|
+
}, _n = new Uint8Array(3e4), ql = _n.length / 3, Ql = (e, t) => {
|
|
6887
|
+
if (t.length < ql) {
|
|
6885
6888
|
const n = te.encodeInto(t, _n).written || 0;
|
|
6886
6889
|
j(e, n);
|
|
6887
6890
|
for (let s = 0; s < n; s++)
|
|
6888
|
-
|
|
6891
|
+
xe(e, _n[s]);
|
|
6889
6892
|
} else
|
|
6890
|
-
Ft(e,
|
|
6891
|
-
},
|
|
6893
|
+
Ft(e, zl(t));
|
|
6894
|
+
}, Zl = (e, t) => {
|
|
6892
6895
|
const n = unescape(encodeURIComponent(t)), s = n.length;
|
|
6893
6896
|
j(e, s);
|
|
6894
6897
|
for (let i = 0; i < s; i++)
|
|
6895
|
-
|
|
6898
|
+
xe(
|
|
6896
6899
|
e,
|
|
6897
6900
|
/** @type {number} */
|
|
6898
6901
|
n.codePointAt(i)
|
|
@@ -6900,32 +6903,32 @@ var cr = (e) => new Error(e), Wl = class {
|
|
|
6900
6903
|
};
|
|
6901
6904
|
te && /** @type {any} */
|
|
6902
6905
|
te.encodeInto;
|
|
6903
|
-
var
|
|
6904
|
-
const n = e.cbuf.length, s = e.cpos, i =
|
|
6905
|
-
e.cbuf.set(t.subarray(0, i), s), e.cpos += i, r > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(
|
|
6906
|
+
var th = (e, t) => {
|
|
6907
|
+
const n = e.cbuf.length, s = e.cpos, i = Yl(n - s, t.length), r = t.length - i;
|
|
6908
|
+
e.cbuf.set(t.subarray(0, i), s), e.cpos += i, r > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(Gl(n * 2, r)), e.cbuf.set(t.subarray(i)), e.cpos = r);
|
|
6906
6909
|
}, Ft = (e, t) => {
|
|
6907
|
-
j(e, t.byteLength),
|
|
6908
|
-
},
|
|
6910
|
+
j(e, t.byteLength), th(e, t);
|
|
6911
|
+
}, eh = cr("Unexpected end of array"), nh = cr("Integer out of Range"), sh = class {
|
|
6909
6912
|
/**
|
|
6910
6913
|
* @param {Uint8Array} uint8Array Binary data to decode
|
|
6911
6914
|
*/
|
|
6912
6915
|
constructor(e) {
|
|
6913
6916
|
this.arr = e, this.pos = 0;
|
|
6914
6917
|
}
|
|
6915
|
-
}, vs = (e) => new
|
|
6918
|
+
}, vs = (e) => new sh(e), ih = (e, t) => {
|
|
6916
6919
|
const n = new Uint8Array(e.arr.buffer, e.pos + e.arr.byteOffset, t);
|
|
6917
6920
|
return e.pos += t, n;
|
|
6918
|
-
}, Is = (e) =>
|
|
6921
|
+
}, Is = (e) => ih(e, En(e)), En = (e) => {
|
|
6919
6922
|
let t = 0, n = 1;
|
|
6920
6923
|
const s = e.arr.length;
|
|
6921
6924
|
for (; e.pos < s; ) {
|
|
6922
6925
|
const i = e.arr[e.pos++];
|
|
6923
6926
|
if (t = t + (i & me) * n, n *= 128, i < or)
|
|
6924
6927
|
return t;
|
|
6925
|
-
if (t >
|
|
6926
|
-
throw
|
|
6928
|
+
if (t > Pl)
|
|
6929
|
+
throw nh;
|
|
6927
6930
|
}
|
|
6928
|
-
throw
|
|
6931
|
+
throw eh;
|
|
6929
6932
|
}, Us = class {
|
|
6930
6933
|
constructor(e) {
|
|
6931
6934
|
this.promise = new Promise((t, n) => {
|
|
@@ -6946,68 +6949,68 @@ var Ql = (e, t) => {
|
|
|
6946
6949
|
wake() {
|
|
6947
6950
|
this.resolve && this.resolve();
|
|
6948
6951
|
}
|
|
6949
|
-
},
|
|
6950
|
-
function
|
|
6951
|
-
return e === rt ?
|
|
6952
|
+
}, rh = "status", oh = "sync", ch = "connection-close", lh = "connection-error", hh = "synced", ah = "connected", hr = "disconnected", uh = "connecting";
|
|
6953
|
+
function dh(e) {
|
|
6954
|
+
return e === rt ? ah : [Kt, Dn].includes(e) ? uh : hr;
|
|
6952
6955
|
}
|
|
6953
|
-
var
|
|
6956
|
+
var fh = class {
|
|
6954
6957
|
constructor(e) {
|
|
6955
6958
|
this.provider = e, this.lastStatus = hr, this.lastSyncStatus = !1, this.provider.on(jt, this.updateStatus.bind(this));
|
|
6956
6959
|
}
|
|
6957
6960
|
updateStatus(e) {
|
|
6958
|
-
const t =
|
|
6959
|
-
this.lastSyncStatus !== n && (this.lastSyncStatus = n, this.provider.emit(
|
|
6961
|
+
const t = dh(e), n = e === rt;
|
|
6962
|
+
this.lastSyncStatus !== n && (this.lastSyncStatus = n, this.provider.emit(oh, n), this.provider.emit(hh, n)), this.lastStatus !== t && (this.lastStatus = t, this.provider.emit(rh, { status: t }));
|
|
6960
6963
|
}
|
|
6961
|
-
},
|
|
6964
|
+
}, We = {
|
|
6962
6965
|
name: "AES-GCM",
|
|
6963
6966
|
length: 256
|
|
6964
6967
|
}, ar = ["encrypt", "decrypt"], Cn = 12;
|
|
6965
|
-
function
|
|
6968
|
+
function gh(e) {
|
|
6966
6969
|
return btoa(String.fromCharCode(...new Uint8Array(e)));
|
|
6967
6970
|
}
|
|
6968
|
-
function
|
|
6971
|
+
function ph(e) {
|
|
6969
6972
|
const t = atob(e);
|
|
6970
6973
|
return Uint8Array.from(t, (s) => s.charCodeAt(0)).buffer;
|
|
6971
6974
|
}
|
|
6972
|
-
async function
|
|
6973
|
-
const t =
|
|
6974
|
-
return await crypto.subtle.importKey("raw", t,
|
|
6975
|
+
async function wh(e) {
|
|
6976
|
+
const t = ph(e);
|
|
6977
|
+
return await crypto.subtle.importKey("raw", t, We, !0, ar);
|
|
6975
6978
|
}
|
|
6976
|
-
async function
|
|
6979
|
+
async function yh(e) {
|
|
6977
6980
|
const t = await crypto.subtle.exportKey("raw", e);
|
|
6978
|
-
return
|
|
6981
|
+
return gh(t);
|
|
6979
6982
|
}
|
|
6980
|
-
function
|
|
6981
|
-
return crypto.subtle.generateKey(
|
|
6983
|
+
function mh() {
|
|
6984
|
+
return crypto.subtle.generateKey(We, !0, ar);
|
|
6982
6985
|
}
|
|
6983
6986
|
async function Os(e, t) {
|
|
6984
|
-
const n = crypto.getRandomValues(new Uint8Array(Cn)), s = await crypto.subtle.encrypt({ name:
|
|
6987
|
+
const n = crypto.getRandomValues(new Uint8Array(Cn)), s = await crypto.subtle.encrypt({ name: We.name, iv: n }, t, e), i = new Uint8Array(n.length + s.byteLength);
|
|
6985
6988
|
return i.set(n), i.set(new Uint8Array(s), n.length), i;
|
|
6986
6989
|
}
|
|
6987
|
-
async function
|
|
6988
|
-
const n = e.slice(0, Cn), s = e.slice(Cn), i = await crypto.subtle.decrypt({ name:
|
|
6990
|
+
async function kh(e, t) {
|
|
6991
|
+
const n = e.slice(0, Cn), s = e.slice(Cn), i = await crypto.subtle.decrypt({ name: We.name, iv: n }, t, s);
|
|
6989
6992
|
return new Uint8Array(i);
|
|
6990
6993
|
}
|
|
6991
6994
|
var Ls = "YSWEET_OFFLINE_KEY";
|
|
6992
|
-
function
|
|
6995
|
+
function Sh(e) {
|
|
6993
6996
|
var s;
|
|
6994
6997
|
const n = `; ${document.cookie}`.split(`; ${e}=`);
|
|
6995
6998
|
return n.length === 2 && ((s = n.pop()) == null ? void 0 : s.split(";").shift()) || null;
|
|
6996
6999
|
}
|
|
6997
|
-
function
|
|
7000
|
+
function bh(e, t) {
|
|
6998
7001
|
document.cookie = `${e}=${t};path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;secure`;
|
|
6999
7002
|
}
|
|
7000
|
-
async function
|
|
7001
|
-
const e =
|
|
7003
|
+
async function _h() {
|
|
7004
|
+
const e = Sh(Ls);
|
|
7002
7005
|
if (e)
|
|
7003
|
-
return await
|
|
7006
|
+
return await wh(e);
|
|
7004
7007
|
{
|
|
7005
|
-
const t = await
|
|
7006
|
-
return
|
|
7008
|
+
const t = await mh(), n = await yh(t);
|
|
7009
|
+
return bh(Ls, n), t;
|
|
7007
7010
|
}
|
|
7008
7011
|
}
|
|
7009
|
-
var
|
|
7010
|
-
function
|
|
7012
|
+
var Eh = "y-sweet-", st = "updates", Ch = 50;
|
|
7013
|
+
function Dh(e) {
|
|
7011
7014
|
return new Promise((t, n) => {
|
|
7012
7015
|
const s = indexedDB.open(e, 4);
|
|
7013
7016
|
s.onupgradeneeded = () => {
|
|
@@ -7015,11 +7018,11 @@ function Eh(e) {
|
|
|
7015
7018
|
}, s.onsuccess = () => t(s.result), s.onerror = n;
|
|
7016
7019
|
});
|
|
7017
7020
|
}
|
|
7018
|
-
async function
|
|
7019
|
-
const n = await Eh
|
|
7020
|
-
return new
|
|
7021
|
+
async function Ah(e, t) {
|
|
7022
|
+
const n = await Dh(Eh + t), s = await _h();
|
|
7023
|
+
return new Th(e, t, n, s);
|
|
7021
7024
|
}
|
|
7022
|
-
var
|
|
7025
|
+
var Th = class {
|
|
7023
7026
|
constructor(e, t, n, s) {
|
|
7024
7027
|
this.doc = e, this.db = n, this.encryptionKey = s, this.lastUpdateKey = -1, this.handleUpdate = this.handleUpdate.bind(this), e.on("update", this.handleUpdate), this.broadcastChannel = new BroadcastChannel(`y-sweet-${t}`), this.broadcastChannel.onmessage = (i) => {
|
|
7025
7028
|
i.data > this.lastUpdateKey && this.loadFromDb();
|
|
@@ -7044,7 +7047,7 @@ var Dh = class {
|
|
|
7044
7047
|
for (; ; ) {
|
|
7045
7048
|
await this.loadFromDb();
|
|
7046
7049
|
let n = this.updateKey(), s = await this.insertValue(n, e);
|
|
7047
|
-
if (s !== null && !(s >
|
|
7050
|
+
if (s !== null && !(s > Ch && (n = this.updateKey(), !await this.saveWholeState(n))))
|
|
7048
7051
|
break;
|
|
7049
7052
|
}
|
|
7050
7053
|
this.broadcastChannel.postMessage(this.lastUpdateKey);
|
|
@@ -7059,7 +7062,7 @@ var Dh = class {
|
|
|
7059
7062
|
});
|
|
7060
7063
|
return await Promise.all(
|
|
7061
7064
|
i.map(async (r) => {
|
|
7062
|
-
let o = await
|
|
7065
|
+
let o = await kh(r.value, this.encryptionKey);
|
|
7063
7066
|
return {
|
|
7064
7067
|
key: r.key,
|
|
7065
7068
|
value: o
|
|
@@ -7105,14 +7108,14 @@ var Dh = class {
|
|
|
7105
7108
|
r.onsuccess = () => c(r.result), r.onerror = l;
|
|
7106
7109
|
});
|
|
7107
7110
|
}
|
|
7108
|
-
}, de = 0, Ns = 3,
|
|
7111
|
+
}, de = 0, Ns = 3, hn = 1, xs = 102, vh = 3, Ih = 500, Uh = 3e3, Rs = 1.1, Ms = 10, Oh = 2e3, Lh = 3e3, $s = "local-changes", jt = "connection-status", fe = "offline", Kt = "connecting", Bt = "error", Dn = "handshaking", rt = "connected";
|
|
7109
7112
|
function An(e, t) {
|
|
7110
7113
|
if (e.docId !== t)
|
|
7111
7114
|
throw new Error(
|
|
7112
7115
|
`ClientToken docId does not match YSweetProvider docId: ${e.docId} !== ${t}`
|
|
7113
7116
|
);
|
|
7114
7117
|
}
|
|
7115
|
-
async function
|
|
7118
|
+
async function Nh(e, t) {
|
|
7116
7119
|
if (typeof e == "function") {
|
|
7117
7120
|
const r = await e();
|
|
7118
7121
|
return An(r, t), r;
|
|
@@ -7127,13 +7130,13 @@ async function Oh(e, t) {
|
|
|
7127
7130
|
const i = await s.json();
|
|
7128
7131
|
return An(i, t), i;
|
|
7129
7132
|
}
|
|
7130
|
-
var
|
|
7133
|
+
var xh = class {
|
|
7131
7134
|
constructor(e, t, n, s = {}) {
|
|
7132
|
-
this.authEndpoint = e, this.docId = t, this.doc = n, this.clientToken = null, this.status = fe, this.websocket = null, this.listeners = /* @__PURE__ */ new Map(), this.localVersion = 0, this.ackedVersion = -1, this.isConnecting = !1, this.heartbeatHandle = null, this.connectionTimeoutHandle = null, this.reconnectSleeper = null, this.showDebuggerLink = !0, this.indexedDBProvider = null, this.retries = 0, this.receivedAtLeastOneSyncResponse = !1, s.initialClientToken && (this.clientToken = s.initialClientToken, An(this.clientToken, this.docId)), this.showDebuggerLink = s.showDebuggerLink !== !1, new
|
|
7135
|
+
this.authEndpoint = e, this.docId = t, this.doc = n, this.clientToken = null, this.status = fe, this.websocket = null, this.listeners = /* @__PURE__ */ new Map(), this.localVersion = 0, this.ackedVersion = -1, this.isConnecting = !1, this.heartbeatHandle = null, this.connectionTimeoutHandle = null, this.reconnectSleeper = null, this.showDebuggerLink = !0, this.indexedDBProvider = null, this.retries = 0, this.receivedAtLeastOneSyncResponse = !1, s.initialClientToken && (this.clientToken = s.initialClientToken, An(this.clientToken, this.docId)), this.showDebuggerLink = s.showDebuggerLink !== !1, new fh(this), this.awareness = s.awareness ?? new Nl(n), this.awareness.on("update", this.handleAwarenessUpdate.bind(this)), this.WebSocketPolyfill = s.WebSocketPolyfill || WebSocket, this.handleBeforeUnload = this.handleBeforeUnload.bind(this), this.online = this.online.bind(this), this.offline = this.offline.bind(this), typeof window < "u" && (window.addEventListener("offline", this.offline), window.addEventListener("online", this.online), s.warnOnClose && window.addEventListener("beforeunload", this.handleBeforeUnload)), s.offlineSupport === !0 && typeof indexedDB < "u" && (async () => this.indexedDBProvider = await Ah(n, t))(), n.on("update", this.update.bind(this)), s.connect !== !1 && this.connect();
|
|
7133
7136
|
}
|
|
7134
7137
|
/** @deprecated */
|
|
7135
7138
|
get debugUrl() {
|
|
7136
|
-
return this.clientToken ? `https://debugger.y-sweet.dev/?payload=${
|
|
7139
|
+
return this.clientToken ? `https://debugger.y-sweet.dev/?payload=${Ml(this.clientToken)}` : null;
|
|
7137
7140
|
}
|
|
7138
7141
|
offline() {
|
|
7139
7142
|
this.checkSync();
|
|
@@ -7147,7 +7150,7 @@ var Lh = class {
|
|
|
7147
7150
|
resetHeartbeat() {
|
|
7148
7151
|
this.clearHeartbeat(), this.heartbeatHandle = setTimeout(() => {
|
|
7149
7152
|
this.checkSync(), this.heartbeatHandle = null;
|
|
7150
|
-
},
|
|
7153
|
+
}, Oh);
|
|
7151
7154
|
}
|
|
7152
7155
|
clearConnectionTimeout() {
|
|
7153
7156
|
this.connectionTimeoutHandle && (clearTimeout(this.connectionTimeoutHandle), this.connectionTimeoutHandle = null);
|
|
@@ -7155,7 +7158,7 @@ var Lh = class {
|
|
|
7155
7158
|
setConnectionTimeout() {
|
|
7156
7159
|
this.connectionTimeoutHandle || this.receivedAtLeastOneSyncResponse && (this.connectionTimeoutHandle = setTimeout(() => {
|
|
7157
7160
|
this.websocket && (this.websocket.close(), this.setStatus(Bt), this.connect()), this.connectionTimeoutHandle = null;
|
|
7158
|
-
},
|
|
7161
|
+
}, Lh));
|
|
7159
7162
|
}
|
|
7160
7163
|
send(e) {
|
|
7161
7164
|
var t;
|
|
@@ -7181,7 +7184,7 @@ var Lh = class {
|
|
|
7181
7184
|
"Client with read-only authorization attempted to write to the Yjs document. These changes may appear locally, but they will not be applied to the shared document."
|
|
7182
7185
|
);
|
|
7183
7186
|
const s = Z();
|
|
7184
|
-
j(s, de),
|
|
7187
|
+
j(s, de), Fl(s, e), this.send(tt(s)), this.incrementLocalVersion(), this.checkSync();
|
|
7185
7188
|
}
|
|
7186
7189
|
checkSync() {
|
|
7187
7190
|
const e = Z();
|
|
@@ -7190,7 +7193,7 @@ var Lh = class {
|
|
|
7190
7193
|
j(t, this.localVersion), Ft(e, tt(t)), this.send(tt(e)), this.setConnectionTimeout();
|
|
7191
7194
|
}
|
|
7192
7195
|
async ensureClientToken() {
|
|
7193
|
-
return this.clientToken === null && (this.clientToken = await
|
|
7196
|
+
return this.clientToken === null && (this.clientToken = await Nh(this.authEndpoint, this.docId)), this.clientToken;
|
|
7194
7197
|
}
|
|
7195
7198
|
/**
|
|
7196
7199
|
* Attempts to connect to the websocket.
|
|
@@ -7222,16 +7225,16 @@ var Lh = class {
|
|
|
7222
7225
|
t = await this.ensureClientToken();
|
|
7223
7226
|
} catch (n) {
|
|
7224
7227
|
console.warn("Failed to get client token", n), this.setStatus(Bt);
|
|
7225
|
-
let s =
|
|
7228
|
+
let s = Uh * Math.min(Ms, Math.pow(Rs, this.retries));
|
|
7226
7229
|
this.retries += 1, this.reconnectSleeper = new Us(s), await this.reconnectSleeper.sleep();
|
|
7227
7230
|
continue;
|
|
7228
7231
|
}
|
|
7229
|
-
for (let n = 0; n <
|
|
7232
|
+
for (let n = 0; n < vh; n++) {
|
|
7230
7233
|
if (await this.attemptToConnect(t)) {
|
|
7231
7234
|
this.retries = 0;
|
|
7232
7235
|
break t;
|
|
7233
7236
|
}
|
|
7234
|
-
let s =
|
|
7237
|
+
let s = Ih * Math.min(Ms, Math.pow(Rs, this.retries));
|
|
7235
7238
|
this.retries += 1, this.reconnectSleeper = new Us(s), await this.reconnectSleeper.sleep();
|
|
7236
7239
|
}
|
|
7237
7240
|
this.clientToken = null;
|
|
@@ -7256,17 +7259,17 @@ var Lh = class {
|
|
|
7256
7259
|
}
|
|
7257
7260
|
syncStep1() {
|
|
7258
7261
|
const e = Z();
|
|
7259
|
-
j(e, de),
|
|
7262
|
+
j(e, de), $l(e, this.doc), this.send(tt(e));
|
|
7260
7263
|
}
|
|
7261
7264
|
receiveSyncMessage(e) {
|
|
7262
7265
|
const t = Z();
|
|
7263
|
-
j(t, de),
|
|
7266
|
+
j(t, de), Kl(e, t, this.doc, this) === Qn && this.setStatus(rt), lr(t) > 1 && this.send(tt(t));
|
|
7264
7267
|
}
|
|
7265
7268
|
queryAwareness() {
|
|
7266
7269
|
const e = Z();
|
|
7267
7270
|
j(e, Ns), Ft(
|
|
7268
7271
|
e,
|
|
7269
|
-
|
|
7272
|
+
cn(
|
|
7270
7273
|
this.awareness,
|
|
7271
7274
|
Array.from(this.awareness.getStates().keys())
|
|
7272
7275
|
)
|
|
@@ -7275,9 +7278,9 @@ var Lh = class {
|
|
|
7275
7278
|
broadcastAwareness() {
|
|
7276
7279
|
if (this.awareness.getLocalState() !== null) {
|
|
7277
7280
|
const e = Z();
|
|
7278
|
-
j(e,
|
|
7281
|
+
j(e, hn), Ft(
|
|
7279
7282
|
e,
|
|
7280
|
-
|
|
7283
|
+
cn(this.awareness, [this.doc.clientID])
|
|
7281
7284
|
), this.send(tt(e));
|
|
7282
7285
|
}
|
|
7283
7286
|
}
|
|
@@ -7299,7 +7302,7 @@ var Lh = class {
|
|
|
7299
7302
|
case de:
|
|
7300
7303
|
this.receiveSyncMessage(n);
|
|
7301
7304
|
break;
|
|
7302
|
-
case
|
|
7305
|
+
case hn:
|
|
7303
7306
|
this.updateAwareness(n);
|
|
7304
7307
|
break;
|
|
7305
7308
|
case Ns:
|
|
@@ -7312,7 +7315,7 @@ var Lh = class {
|
|
|
7312
7315
|
}
|
|
7313
7316
|
}
|
|
7314
7317
|
websocketClose(e) {
|
|
7315
|
-
this.emit(
|
|
7318
|
+
this.emit(ch, e), this.setStatus(Bt), this.clearHeartbeat(), this.clearConnectionTimeout(), this.connect(), bn(
|
|
7316
7319
|
this.awareness,
|
|
7317
7320
|
Array.from(this.awareness.getStates().keys()).filter(
|
|
7318
7321
|
(t) => t !== this.doc.clientID
|
|
@@ -7321,7 +7324,7 @@ var Lh = class {
|
|
|
7321
7324
|
);
|
|
7322
7325
|
}
|
|
7323
7326
|
websocketError(e) {
|
|
7324
|
-
this.emit(
|
|
7327
|
+
this.emit(lh, e), this.setStatus(Bt), this.clearHeartbeat(), this.clearConnectionTimeout(), this.connect();
|
|
7325
7328
|
}
|
|
7326
7329
|
emit(e, t = null) {
|
|
7327
7330
|
const n = this.listeners.get(e) || /* @__PURE__ */ new Set();
|
|
@@ -7330,9 +7333,9 @@ var Lh = class {
|
|
|
7330
7333
|
}
|
|
7331
7334
|
handleAwarenessUpdate({ added: e, updated: t, removed: n }, s) {
|
|
7332
7335
|
const i = e.concat(t).concat(n), r = Z();
|
|
7333
|
-
j(r,
|
|
7336
|
+
j(r, hn), Ft(
|
|
7334
7337
|
r,
|
|
7335
|
-
|
|
7338
|
+
cn(this.awareness, i)
|
|
7336
7339
|
), this.send(tt(r));
|
|
7337
7340
|
}
|
|
7338
7341
|
destroy() {
|
|
@@ -7401,72 +7404,82 @@ var Lh = class {
|
|
|
7401
7404
|
return this.status === rt;
|
|
7402
7405
|
}
|
|
7403
7406
|
};
|
|
7404
|
-
function
|
|
7405
|
-
return new
|
|
7407
|
+
function Rh(e, t, n, s = {}) {
|
|
7408
|
+
return new xh(n, t, e, s);
|
|
7406
7409
|
}
|
|
7407
|
-
const
|
|
7408
|
-
function
|
|
7409
|
-
|
|
7410
|
+
const ke = /* @__PURE__ */ new Map();
|
|
7411
|
+
function Qh() {
|
|
7412
|
+
ke.clear();
|
|
7410
7413
|
}
|
|
7411
|
-
function
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7414
|
+
function Zh({ documentId: e, collaborationEnabled: t }) {
|
|
7415
|
+
const { collaborationUrl: n = "https://demos.y-sweet.cloud/api/auth" } = fr();
|
|
7416
|
+
function s(o) {
|
|
7417
|
+
if (ke.has(o))
|
|
7418
|
+
return ke.get(o);
|
|
7419
|
+
const c = new pt(), l = Rh(c, o, n);
|
|
7420
|
+
l.on("status", (a) => {
|
|
7421
|
+
console.log(`[${o}] Y-Sweet status:`, a.status);
|
|
7422
|
+
}), l.on("sync", (a) => {
|
|
7423
|
+
console.log(`[${o}] Synced:`, a);
|
|
7424
|
+
});
|
|
7425
|
+
const h = { doc: c, provider: l };
|
|
7426
|
+
return ke.set(o, h), h;
|
|
7427
|
+
}
|
|
7428
|
+
const { doc: i, provider: r } = gr(() => !t || !e ? (console.log("🚫 Collaboration disabled or no documentId"), { doc: null, provider: null }) : s(e), [t, e, s]);
|
|
7429
|
+
return {
|
|
7430
|
+
doc: i,
|
|
7431
|
+
provider: r
|
|
7432
|
+
};
|
|
7422
7433
|
}
|
|
7423
7434
|
export {
|
|
7424
|
-
|
|
7435
|
+
gc as A,
|
|
7425
7436
|
R as B,
|
|
7426
7437
|
P as C,
|
|
7427
7438
|
pt as D,
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7439
|
+
Ph as E,
|
|
7440
|
+
Ui as F,
|
|
7441
|
+
Jh as G,
|
|
7442
|
+
Ae as H,
|
|
7432
7443
|
b as I,
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7444
|
+
m as J,
|
|
7445
|
+
x as K,
|
|
7446
|
+
Wh as L,
|
|
7447
|
+
Gh as M,
|
|
7448
|
+
J as N,
|
|
7449
|
+
ut as O,
|
|
7450
|
+
Di as P,
|
|
7451
|
+
Ai as Q,
|
|
7441
7452
|
Oi as R,
|
|
7442
|
-
|
|
7443
|
-
|
|
7453
|
+
Oc as S,
|
|
7454
|
+
Ac as T,
|
|
7455
|
+
Xh as U,
|
|
7444
7456
|
Nt as Y,
|
|
7445
|
-
|
|
7457
|
+
Qh as _,
|
|
7458
|
+
Bh as a,
|
|
7446
7459
|
ft as b,
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7460
|
+
Rh as c,
|
|
7461
|
+
Ye as d,
|
|
7462
|
+
Yh as e,
|
|
7463
|
+
M as f,
|
|
7464
|
+
Ci as g,
|
|
7465
|
+
G as h,
|
|
7466
|
+
fo as i,
|
|
7467
|
+
It as j,
|
|
7468
|
+
qh as k,
|
|
7469
|
+
Lc as l,
|
|
7457
7470
|
Bs as m,
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
+
se as n,
|
|
7472
|
+
K as o,
|
|
7473
|
+
Oe as p,
|
|
7474
|
+
Lt as q,
|
|
7475
|
+
ne as r,
|
|
7476
|
+
zh as s,
|
|
7477
|
+
Hh as t,
|
|
7478
|
+
Zh as u,
|
|
7479
|
+
ro as v,
|
|
7480
|
+
ht as w,
|
|
7481
|
+
Kh as x,
|
|
7482
|
+
D as y,
|
|
7483
|
+
q as z
|
|
7471
7484
|
};
|
|
7472
|
-
//# sourceMappingURL=
|
|
7485
|
+
//# sourceMappingURL=useCollaboration.js.map
|