@1agh/maude 0.21.0 → 0.22.2
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/cli/commands/doctor.mjs +87 -76
- package/cli/commands/hub.mjs +17 -3
- package/package.json +9 -9
- package/plugins/design/dev-server/bin/check-runtime-bundles.sh +125 -0
- package/plugins/design/dev-server/bin/runtime-health.sh +47 -6
- package/plugins/design/dev-server/build.ts +19 -5
- package/plugins/design/dev-server/dist/client.bundle.js +3 -3
- package/plugins/design/dev-server/dist/runtime/.min-sizes.json +16 -0
- package/plugins/design/dev-server/dist/runtime/lib0_decoding.js +620 -0
- package/plugins/design/dev-server/dist/runtime/lib0_encoding.js +604 -0
- package/plugins/design/dev-server/dist/runtime/motion.js +4787 -8
- package/plugins/design/dev-server/dist/runtime/motion_react.js +9654 -7
- package/plugins/design/dev-server/dist/runtime/pixi-js.js +5865 -5469
- package/plugins/design/dev-server/dist/runtime/react-dom.js +4 -22
- package/plugins/design/dev-server/dist/runtime/react-dom_client.js +5 -23
- package/plugins/design/dev-server/dist/runtime/react.js +4 -22
- package/plugins/design/dev-server/dist/runtime/react_jsx-dev-runtime.js +4 -22
- package/plugins/design/dev-server/dist/runtime/react_jsx-runtime.js +4 -22
- package/plugins/design/dev-server/dist/runtime/y-protocols_awareness.js +37 -248
- package/plugins/design/dev-server/dist/runtime/y-protocols_sync.js +13 -170
- package/plugins/design/dev-server/dist/runtime/yjs.js +300 -720
- package/plugins/design/dev-server/runtime-bundle.ts +11 -0
- package/plugins/design/templates/_shell.html +3 -1
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __returnValue = (v) => v;
|
|
3
|
-
function __exportSetter(name, newValue) {
|
|
4
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
5
|
-
}
|
|
6
2
|
var __export = (target, all) => {
|
|
7
3
|
for (var name in all)
|
|
8
4
|
__defProp(target, name, {
|
|
9
5
|
get: all[name],
|
|
10
6
|
enumerable: true,
|
|
11
7
|
configurable: true,
|
|
12
|
-
set:
|
|
8
|
+
set: (newValue) => all[name] = () => newValue
|
|
13
9
|
});
|
|
14
10
|
};
|
|
15
11
|
|
|
@@ -227,7 +223,10 @@ var floor = Math.floor;
|
|
|
227
223
|
var abs = Math.abs;
|
|
228
224
|
var min = (a, b) => a < b ? a : b;
|
|
229
225
|
var max = (a, b) => a > b ? a : b;
|
|
230
|
-
|
|
226
|
+
|
|
227
|
+
// ../../../node_modules/.pnpm/yjs@13.6.30/node_modules/yjs/dist/yjs.mjs
|
|
228
|
+
import * as encoding from "lib0/encoding";
|
|
229
|
+
import * as decoding from "lib0/decoding";
|
|
231
230
|
|
|
232
231
|
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/binary.js
|
|
233
232
|
var BIT1 = 1;
|
|
@@ -253,7 +252,6 @@ var BIT30 = 1 << 29;
|
|
|
253
252
|
var BIT31 = 1 << 30;
|
|
254
253
|
var BIT32 = 1 << 31;
|
|
255
254
|
var BITS5 = 31;
|
|
256
|
-
var BITS6 = 63;
|
|
257
255
|
var BITS7 = 127;
|
|
258
256
|
var BITS17 = BIT18 - 1;
|
|
259
257
|
var BITS18 = BIT19 - 1;
|
|
@@ -269,13 +267,22 @@ var BITS27 = BIT28 - 1;
|
|
|
269
267
|
var BITS28 = BIT29 - 1;
|
|
270
268
|
var BITS29 = BIT30 - 1;
|
|
271
269
|
var BITS30 = BIT31 - 1;
|
|
272
|
-
var BITS31 = 2147483647;
|
|
273
270
|
|
|
274
|
-
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/
|
|
275
|
-
var
|
|
276
|
-
var
|
|
277
|
-
|
|
278
|
-
|
|
271
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/webcrypto.js
|
|
272
|
+
var subtle = crypto.subtle;
|
|
273
|
+
var getRandomValues = crypto.getRandomValues.bind(crypto);
|
|
274
|
+
|
|
275
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/random.js
|
|
276
|
+
var uint32 = () => getRandomValues(new Uint32Array(1))[0];
|
|
277
|
+
var uuidv4Template = [1e7] + -1000 + -4000 + -8000 + -100000000000;
|
|
278
|
+
var uuidv4 = () => uuidv4Template.replace(/[018]/g, (c) => (c ^ uint32() & 15 >> c / 4).toString(16));
|
|
279
|
+
|
|
280
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/time.js
|
|
281
|
+
var getUnixTime = Date.now;
|
|
282
|
+
|
|
283
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/promise.js
|
|
284
|
+
var create3 = (f) => new Promise(f);
|
|
285
|
+
var all = Promise.all.bind(Promise);
|
|
279
286
|
|
|
280
287
|
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/string.js
|
|
281
288
|
var fromCharCode = String.fromCharCode;
|
|
@@ -304,510 +311,6 @@ if (utf8TextDecoder && utf8TextDecoder.decode(new Uint8Array).length === 1) {
|
|
|
304
311
|
}
|
|
305
312
|
var repeat = (source, n) => unfold(n, () => source).join("");
|
|
306
313
|
|
|
307
|
-
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/encoding.js
|
|
308
|
-
class Encoder {
|
|
309
|
-
constructor() {
|
|
310
|
-
this.cpos = 0;
|
|
311
|
-
this.cbuf = new Uint8Array(100);
|
|
312
|
-
this.bufs = [];
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
var createEncoder = () => new Encoder;
|
|
316
|
-
var length = (encoder) => {
|
|
317
|
-
let len = encoder.cpos;
|
|
318
|
-
for (let i = 0;i < encoder.bufs.length; i++) {
|
|
319
|
-
len += encoder.bufs[i].length;
|
|
320
|
-
}
|
|
321
|
-
return len;
|
|
322
|
-
};
|
|
323
|
-
var toUint8Array = (encoder) => {
|
|
324
|
-
const uint8arr = new Uint8Array(length(encoder));
|
|
325
|
-
let curPos = 0;
|
|
326
|
-
for (let i = 0;i < encoder.bufs.length; i++) {
|
|
327
|
-
const d = encoder.bufs[i];
|
|
328
|
-
uint8arr.set(d, curPos);
|
|
329
|
-
curPos += d.length;
|
|
330
|
-
}
|
|
331
|
-
uint8arr.set(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos), curPos);
|
|
332
|
-
return uint8arr;
|
|
333
|
-
};
|
|
334
|
-
var verifyLen = (encoder, len) => {
|
|
335
|
-
const bufferLen = encoder.cbuf.length;
|
|
336
|
-
if (bufferLen - encoder.cpos < len) {
|
|
337
|
-
encoder.bufs.push(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos));
|
|
338
|
-
encoder.cbuf = new Uint8Array(max(bufferLen, len) * 2);
|
|
339
|
-
encoder.cpos = 0;
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
var write = (encoder, num) => {
|
|
343
|
-
const bufferLen = encoder.cbuf.length;
|
|
344
|
-
if (encoder.cpos === bufferLen) {
|
|
345
|
-
encoder.bufs.push(encoder.cbuf);
|
|
346
|
-
encoder.cbuf = new Uint8Array(bufferLen * 2);
|
|
347
|
-
encoder.cpos = 0;
|
|
348
|
-
}
|
|
349
|
-
encoder.cbuf[encoder.cpos++] = num;
|
|
350
|
-
};
|
|
351
|
-
var writeUint8 = write;
|
|
352
|
-
var writeVarUint = (encoder, num) => {
|
|
353
|
-
while (num > BITS7) {
|
|
354
|
-
write(encoder, BIT8 | BITS7 & num);
|
|
355
|
-
num = floor(num / 128);
|
|
356
|
-
}
|
|
357
|
-
write(encoder, BITS7 & num);
|
|
358
|
-
};
|
|
359
|
-
var writeVarInt = (encoder, num) => {
|
|
360
|
-
const isNegative = isNegativeZero(num);
|
|
361
|
-
if (isNegative) {
|
|
362
|
-
num = -num;
|
|
363
|
-
}
|
|
364
|
-
write(encoder, (num > BITS6 ? BIT8 : 0) | (isNegative ? BIT7 : 0) | BITS6 & num);
|
|
365
|
-
num = floor(num / 64);
|
|
366
|
-
while (num > 0) {
|
|
367
|
-
write(encoder, (num > BITS7 ? BIT8 : 0) | BITS7 & num);
|
|
368
|
-
num = floor(num / 128);
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
var _strBuffer = new Uint8Array(30000);
|
|
372
|
-
var _maxStrBSize = _strBuffer.length / 3;
|
|
373
|
-
var _writeVarStringNative = (encoder, str) => {
|
|
374
|
-
if (str.length < _maxStrBSize) {
|
|
375
|
-
const written = utf8TextEncoder.encodeInto(str, _strBuffer).written || 0;
|
|
376
|
-
writeVarUint(encoder, written);
|
|
377
|
-
for (let i = 0;i < written; i++) {
|
|
378
|
-
write(encoder, _strBuffer[i]);
|
|
379
|
-
}
|
|
380
|
-
} else {
|
|
381
|
-
writeVarUint8Array(encoder, encodeUtf8(str));
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
var _writeVarStringPolyfill = (encoder, str) => {
|
|
385
|
-
const encodedString = unescape(encodeURIComponent(str));
|
|
386
|
-
const len = encodedString.length;
|
|
387
|
-
writeVarUint(encoder, len);
|
|
388
|
-
for (let i = 0;i < len; i++) {
|
|
389
|
-
write(encoder, encodedString.codePointAt(i));
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
var writeVarString = utf8TextEncoder && utf8TextEncoder.encodeInto ? _writeVarStringNative : _writeVarStringPolyfill;
|
|
393
|
-
var writeBinaryEncoder = (encoder, append) => writeUint8Array(encoder, toUint8Array(append));
|
|
394
|
-
var writeUint8Array = (encoder, uint8Array) => {
|
|
395
|
-
const bufferLen = encoder.cbuf.length;
|
|
396
|
-
const cpos = encoder.cpos;
|
|
397
|
-
const leftCopyLen = min(bufferLen - cpos, uint8Array.length);
|
|
398
|
-
const rightCopyLen = uint8Array.length - leftCopyLen;
|
|
399
|
-
encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
|
|
400
|
-
encoder.cpos += leftCopyLen;
|
|
401
|
-
if (rightCopyLen > 0) {
|
|
402
|
-
encoder.bufs.push(encoder.cbuf);
|
|
403
|
-
encoder.cbuf = new Uint8Array(max(bufferLen * 2, rightCopyLen));
|
|
404
|
-
encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
|
|
405
|
-
encoder.cpos = rightCopyLen;
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
var writeVarUint8Array = (encoder, uint8Array) => {
|
|
409
|
-
writeVarUint(encoder, uint8Array.byteLength);
|
|
410
|
-
writeUint8Array(encoder, uint8Array);
|
|
411
|
-
};
|
|
412
|
-
var writeOnDataView = (encoder, len) => {
|
|
413
|
-
verifyLen(encoder, len);
|
|
414
|
-
const dview = new DataView(encoder.cbuf.buffer, encoder.cpos, len);
|
|
415
|
-
encoder.cpos += len;
|
|
416
|
-
return dview;
|
|
417
|
-
};
|
|
418
|
-
var writeFloat32 = (encoder, num) => writeOnDataView(encoder, 4).setFloat32(0, num, false);
|
|
419
|
-
var writeFloat64 = (encoder, num) => writeOnDataView(encoder, 8).setFloat64(0, num, false);
|
|
420
|
-
var writeBigInt64 = (encoder, num) => writeOnDataView(encoder, 8).setBigInt64(0, num, false);
|
|
421
|
-
var floatTestBed = new DataView(new ArrayBuffer(4));
|
|
422
|
-
var isFloat32 = (num) => {
|
|
423
|
-
floatTestBed.setFloat32(0, num);
|
|
424
|
-
return floatTestBed.getFloat32(0) === num;
|
|
425
|
-
};
|
|
426
|
-
var writeAny = (encoder, data) => {
|
|
427
|
-
switch (typeof data) {
|
|
428
|
-
case "string":
|
|
429
|
-
write(encoder, 119);
|
|
430
|
-
writeVarString(encoder, data);
|
|
431
|
-
break;
|
|
432
|
-
case "number":
|
|
433
|
-
if (isInteger(data) && abs(data) <= BITS31) {
|
|
434
|
-
write(encoder, 125);
|
|
435
|
-
writeVarInt(encoder, data);
|
|
436
|
-
} else if (isFloat32(data)) {
|
|
437
|
-
write(encoder, 124);
|
|
438
|
-
writeFloat32(encoder, data);
|
|
439
|
-
} else {
|
|
440
|
-
write(encoder, 123);
|
|
441
|
-
writeFloat64(encoder, data);
|
|
442
|
-
}
|
|
443
|
-
break;
|
|
444
|
-
case "bigint":
|
|
445
|
-
write(encoder, 122);
|
|
446
|
-
writeBigInt64(encoder, data);
|
|
447
|
-
break;
|
|
448
|
-
case "object":
|
|
449
|
-
if (data === null) {
|
|
450
|
-
write(encoder, 126);
|
|
451
|
-
} else if (isArray(data)) {
|
|
452
|
-
write(encoder, 117);
|
|
453
|
-
writeVarUint(encoder, data.length);
|
|
454
|
-
for (let i = 0;i < data.length; i++) {
|
|
455
|
-
writeAny(encoder, data[i]);
|
|
456
|
-
}
|
|
457
|
-
} else if (data instanceof Uint8Array) {
|
|
458
|
-
write(encoder, 116);
|
|
459
|
-
writeVarUint8Array(encoder, data);
|
|
460
|
-
} else {
|
|
461
|
-
write(encoder, 118);
|
|
462
|
-
const keys = Object.keys(data);
|
|
463
|
-
writeVarUint(encoder, keys.length);
|
|
464
|
-
for (let i = 0;i < keys.length; i++) {
|
|
465
|
-
const key = keys[i];
|
|
466
|
-
writeVarString(encoder, key);
|
|
467
|
-
writeAny(encoder, data[key]);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
break;
|
|
471
|
-
case "boolean":
|
|
472
|
-
write(encoder, data ? 120 : 121);
|
|
473
|
-
break;
|
|
474
|
-
default:
|
|
475
|
-
write(encoder, 127);
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
class RleEncoder extends Encoder {
|
|
480
|
-
constructor(writer) {
|
|
481
|
-
super();
|
|
482
|
-
this.w = writer;
|
|
483
|
-
this.s = null;
|
|
484
|
-
this.count = 0;
|
|
485
|
-
}
|
|
486
|
-
write(v) {
|
|
487
|
-
if (this.s === v) {
|
|
488
|
-
this.count++;
|
|
489
|
-
} else {
|
|
490
|
-
if (this.count > 0) {
|
|
491
|
-
writeVarUint(this, this.count - 1);
|
|
492
|
-
}
|
|
493
|
-
this.count = 1;
|
|
494
|
-
this.w(this, v);
|
|
495
|
-
this.s = v;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
var flushUintOptRleEncoder = (encoder) => {
|
|
500
|
-
if (encoder.count > 0) {
|
|
501
|
-
writeVarInt(encoder.encoder, encoder.count === 1 ? encoder.s : -encoder.s);
|
|
502
|
-
if (encoder.count > 1) {
|
|
503
|
-
writeVarUint(encoder.encoder, encoder.count - 2);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
class UintOptRleEncoder {
|
|
509
|
-
constructor() {
|
|
510
|
-
this.encoder = new Encoder;
|
|
511
|
-
this.s = 0;
|
|
512
|
-
this.count = 0;
|
|
513
|
-
}
|
|
514
|
-
write(v) {
|
|
515
|
-
if (this.s === v) {
|
|
516
|
-
this.count++;
|
|
517
|
-
} else {
|
|
518
|
-
flushUintOptRleEncoder(this);
|
|
519
|
-
this.count = 1;
|
|
520
|
-
this.s = v;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
toUint8Array() {
|
|
524
|
-
flushUintOptRleEncoder(this);
|
|
525
|
-
return toUint8Array(this.encoder);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
var flushIntDiffOptRleEncoder = (encoder) => {
|
|
529
|
-
if (encoder.count > 0) {
|
|
530
|
-
const encodedDiff = encoder.diff * 2 + (encoder.count === 1 ? 0 : 1);
|
|
531
|
-
writeVarInt(encoder.encoder, encodedDiff);
|
|
532
|
-
if (encoder.count > 1) {
|
|
533
|
-
writeVarUint(encoder.encoder, encoder.count - 2);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
class IntDiffOptRleEncoder {
|
|
539
|
-
constructor() {
|
|
540
|
-
this.encoder = new Encoder;
|
|
541
|
-
this.s = 0;
|
|
542
|
-
this.count = 0;
|
|
543
|
-
this.diff = 0;
|
|
544
|
-
}
|
|
545
|
-
write(v) {
|
|
546
|
-
if (this.diff === v - this.s) {
|
|
547
|
-
this.s = v;
|
|
548
|
-
this.count++;
|
|
549
|
-
} else {
|
|
550
|
-
flushIntDiffOptRleEncoder(this);
|
|
551
|
-
this.count = 1;
|
|
552
|
-
this.diff = v - this.s;
|
|
553
|
-
this.s = v;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
toUint8Array() {
|
|
557
|
-
flushIntDiffOptRleEncoder(this);
|
|
558
|
-
return toUint8Array(this.encoder);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
class StringEncoder {
|
|
563
|
-
constructor() {
|
|
564
|
-
this.sarr = [];
|
|
565
|
-
this.s = "";
|
|
566
|
-
this.lensE = new UintOptRleEncoder;
|
|
567
|
-
}
|
|
568
|
-
write(string) {
|
|
569
|
-
this.s += string;
|
|
570
|
-
if (this.s.length > 19) {
|
|
571
|
-
this.sarr.push(this.s);
|
|
572
|
-
this.s = "";
|
|
573
|
-
}
|
|
574
|
-
this.lensE.write(string.length);
|
|
575
|
-
}
|
|
576
|
-
toUint8Array() {
|
|
577
|
-
const encoder = new Encoder;
|
|
578
|
-
this.sarr.push(this.s);
|
|
579
|
-
this.s = "";
|
|
580
|
-
writeVarString(encoder, this.sarr.join(""));
|
|
581
|
-
writeUint8Array(encoder, this.lensE.toUint8Array());
|
|
582
|
-
return toUint8Array(encoder);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/error.js
|
|
587
|
-
var create3 = (s) => new Error(s);
|
|
588
|
-
var methodUnimplemented = () => {
|
|
589
|
-
throw create3("Method unimplemented");
|
|
590
|
-
};
|
|
591
|
-
var unexpectedCase = () => {
|
|
592
|
-
throw create3("Unexpected case");
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/decoding.js
|
|
596
|
-
var errorUnexpectedEndOfArray = create3("Unexpected end of array");
|
|
597
|
-
var errorIntegerOutOfRange = create3("Integer out of Range");
|
|
598
|
-
|
|
599
|
-
class Decoder {
|
|
600
|
-
constructor(uint8Array) {
|
|
601
|
-
this.arr = uint8Array;
|
|
602
|
-
this.pos = 0;
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
var createDecoder = (uint8Array) => new Decoder(uint8Array);
|
|
606
|
-
var hasContent = (decoder) => decoder.pos !== decoder.arr.length;
|
|
607
|
-
var readUint8Array = (decoder, len) => {
|
|
608
|
-
const view = new Uint8Array(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len);
|
|
609
|
-
decoder.pos += len;
|
|
610
|
-
return view;
|
|
611
|
-
};
|
|
612
|
-
var readVarUint8Array = (decoder) => readUint8Array(decoder, readVarUint(decoder));
|
|
613
|
-
var readUint8 = (decoder) => decoder.arr[decoder.pos++];
|
|
614
|
-
var readVarUint = (decoder) => {
|
|
615
|
-
let num = 0;
|
|
616
|
-
let mult = 1;
|
|
617
|
-
const len = decoder.arr.length;
|
|
618
|
-
while (decoder.pos < len) {
|
|
619
|
-
const r = decoder.arr[decoder.pos++];
|
|
620
|
-
num = num + (r & BITS7) * mult;
|
|
621
|
-
mult *= 128;
|
|
622
|
-
if (r < BIT8) {
|
|
623
|
-
return num;
|
|
624
|
-
}
|
|
625
|
-
if (num > MAX_SAFE_INTEGER) {
|
|
626
|
-
throw errorIntegerOutOfRange;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
throw errorUnexpectedEndOfArray;
|
|
630
|
-
};
|
|
631
|
-
var readVarInt = (decoder) => {
|
|
632
|
-
let r = decoder.arr[decoder.pos++];
|
|
633
|
-
let num = r & BITS6;
|
|
634
|
-
let mult = 64;
|
|
635
|
-
const sign = (r & BIT7) > 0 ? -1 : 1;
|
|
636
|
-
if ((r & BIT8) === 0) {
|
|
637
|
-
return sign * num;
|
|
638
|
-
}
|
|
639
|
-
const len = decoder.arr.length;
|
|
640
|
-
while (decoder.pos < len) {
|
|
641
|
-
r = decoder.arr[decoder.pos++];
|
|
642
|
-
num = num + (r & BITS7) * mult;
|
|
643
|
-
mult *= 128;
|
|
644
|
-
if (r < BIT8) {
|
|
645
|
-
return sign * num;
|
|
646
|
-
}
|
|
647
|
-
if (num > MAX_SAFE_INTEGER) {
|
|
648
|
-
throw errorIntegerOutOfRange;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
throw errorUnexpectedEndOfArray;
|
|
652
|
-
};
|
|
653
|
-
var _readVarStringPolyfill = (decoder) => {
|
|
654
|
-
let remainingLen = readVarUint(decoder);
|
|
655
|
-
if (remainingLen === 0) {
|
|
656
|
-
return "";
|
|
657
|
-
} else {
|
|
658
|
-
let encodedString = String.fromCodePoint(readUint8(decoder));
|
|
659
|
-
if (--remainingLen < 100) {
|
|
660
|
-
while (remainingLen--) {
|
|
661
|
-
encodedString += String.fromCodePoint(readUint8(decoder));
|
|
662
|
-
}
|
|
663
|
-
} else {
|
|
664
|
-
while (remainingLen > 0) {
|
|
665
|
-
const nextLen = remainingLen < 1e4 ? remainingLen : 1e4;
|
|
666
|
-
const bytes = decoder.arr.subarray(decoder.pos, decoder.pos + nextLen);
|
|
667
|
-
decoder.pos += nextLen;
|
|
668
|
-
encodedString += String.fromCodePoint.apply(null, bytes);
|
|
669
|
-
remainingLen -= nextLen;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
return decodeURIComponent(escape(encodedString));
|
|
673
|
-
}
|
|
674
|
-
};
|
|
675
|
-
var _readVarStringNative = (decoder) => utf8TextDecoder.decode(readVarUint8Array(decoder));
|
|
676
|
-
var readVarString = utf8TextDecoder ? _readVarStringNative : _readVarStringPolyfill;
|
|
677
|
-
var readFromDataView = (decoder, len) => {
|
|
678
|
-
const dv = new DataView(decoder.arr.buffer, decoder.arr.byteOffset + decoder.pos, len);
|
|
679
|
-
decoder.pos += len;
|
|
680
|
-
return dv;
|
|
681
|
-
};
|
|
682
|
-
var readFloat32 = (decoder) => readFromDataView(decoder, 4).getFloat32(0, false);
|
|
683
|
-
var readFloat64 = (decoder) => readFromDataView(decoder, 8).getFloat64(0, false);
|
|
684
|
-
var readBigInt64 = (decoder) => readFromDataView(decoder, 8).getBigInt64(0, false);
|
|
685
|
-
var readAnyLookupTable = [
|
|
686
|
-
(decoder) => {
|
|
687
|
-
return;
|
|
688
|
-
},
|
|
689
|
-
(decoder) => null,
|
|
690
|
-
readVarInt,
|
|
691
|
-
readFloat32,
|
|
692
|
-
readFloat64,
|
|
693
|
-
readBigInt64,
|
|
694
|
-
(decoder) => false,
|
|
695
|
-
(decoder) => true,
|
|
696
|
-
readVarString,
|
|
697
|
-
(decoder) => {
|
|
698
|
-
const len = readVarUint(decoder);
|
|
699
|
-
const obj = {};
|
|
700
|
-
for (let i = 0;i < len; i++) {
|
|
701
|
-
const key = readVarString(decoder);
|
|
702
|
-
obj[key] = readAny(decoder);
|
|
703
|
-
}
|
|
704
|
-
return obj;
|
|
705
|
-
},
|
|
706
|
-
(decoder) => {
|
|
707
|
-
const len = readVarUint(decoder);
|
|
708
|
-
const arr = [];
|
|
709
|
-
for (let i = 0;i < len; i++) {
|
|
710
|
-
arr.push(readAny(decoder));
|
|
711
|
-
}
|
|
712
|
-
return arr;
|
|
713
|
-
},
|
|
714
|
-
readVarUint8Array
|
|
715
|
-
];
|
|
716
|
-
var readAny = (decoder) => readAnyLookupTable[127 - readUint8(decoder)](decoder);
|
|
717
|
-
|
|
718
|
-
class RleDecoder extends Decoder {
|
|
719
|
-
constructor(uint8Array, reader) {
|
|
720
|
-
super(uint8Array);
|
|
721
|
-
this.reader = reader;
|
|
722
|
-
this.s = null;
|
|
723
|
-
this.count = 0;
|
|
724
|
-
}
|
|
725
|
-
read() {
|
|
726
|
-
if (this.count === 0) {
|
|
727
|
-
this.s = this.reader(this);
|
|
728
|
-
if (hasContent(this)) {
|
|
729
|
-
this.count = readVarUint(this) + 1;
|
|
730
|
-
} else {
|
|
731
|
-
this.count = -1;
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
this.count--;
|
|
735
|
-
return this.s;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
class UintOptRleDecoder extends Decoder {
|
|
739
|
-
constructor(uint8Array) {
|
|
740
|
-
super(uint8Array);
|
|
741
|
-
this.s = 0;
|
|
742
|
-
this.count = 0;
|
|
743
|
-
}
|
|
744
|
-
read() {
|
|
745
|
-
if (this.count === 0) {
|
|
746
|
-
this.s = readVarInt(this);
|
|
747
|
-
const isNegative = isNegativeZero(this.s);
|
|
748
|
-
this.count = 1;
|
|
749
|
-
if (isNegative) {
|
|
750
|
-
this.s = -this.s;
|
|
751
|
-
this.count = readVarUint(this) + 2;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
this.count--;
|
|
755
|
-
return this.s;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
class IntDiffOptRleDecoder extends Decoder {
|
|
759
|
-
constructor(uint8Array) {
|
|
760
|
-
super(uint8Array);
|
|
761
|
-
this.s = 0;
|
|
762
|
-
this.count = 0;
|
|
763
|
-
this.diff = 0;
|
|
764
|
-
}
|
|
765
|
-
read() {
|
|
766
|
-
if (this.count === 0) {
|
|
767
|
-
const diff = readVarInt(this);
|
|
768
|
-
const hasCount = diff & 1;
|
|
769
|
-
this.diff = floor(diff / 2);
|
|
770
|
-
this.count = 1;
|
|
771
|
-
if (hasCount) {
|
|
772
|
-
this.count = readVarUint(this) + 2;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
this.s += this.diff;
|
|
776
|
-
this.count--;
|
|
777
|
-
return this.s;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
class StringDecoder {
|
|
782
|
-
constructor(uint8Array) {
|
|
783
|
-
this.decoder = new UintOptRleDecoder(uint8Array);
|
|
784
|
-
this.str = readVarString(this.decoder);
|
|
785
|
-
this.spos = 0;
|
|
786
|
-
}
|
|
787
|
-
read() {
|
|
788
|
-
const end = this.spos + this.decoder.read();
|
|
789
|
-
const res = this.str.slice(this.spos, end);
|
|
790
|
-
this.spos = end;
|
|
791
|
-
return res;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/webcrypto.js
|
|
796
|
-
var subtle = crypto.subtle;
|
|
797
|
-
var getRandomValues = crypto.getRandomValues.bind(crypto);
|
|
798
|
-
|
|
799
|
-
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/random.js
|
|
800
|
-
var uint32 = () => getRandomValues(new Uint32Array(1))[0];
|
|
801
|
-
var uuidv4Template = [1e7] + -1000 + -4000 + -8000 + -100000000000;
|
|
802
|
-
var uuidv4 = () => uuidv4Template.replace(/[018]/g, (c) => (c ^ uint32() & 15 >> c / 4).toString(16));
|
|
803
|
-
|
|
804
|
-
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/time.js
|
|
805
|
-
var getUnixTime = Date.now;
|
|
806
|
-
|
|
807
|
-
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/promise.js
|
|
808
|
-
var create4 = (f) => new Promise(f);
|
|
809
|
-
var all = Promise.all.bind(Promise);
|
|
810
|
-
|
|
811
314
|
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/conditions.js
|
|
812
315
|
var undefinedToNull = (v) => v === undefined ? null : v;
|
|
813
316
|
|
|
@@ -1014,6 +517,83 @@ var production = hasConf("production");
|
|
|
1014
517
|
var forceColor = isNode && isOneOf(process.env.FORCE_COLOR, ["true", "1", "2"]);
|
|
1015
518
|
var supportsColor = forceColor || !hasParam("--no-colors") && !hasConf("no-color") && (!isNode || process.stdout.isTTY) && (!isNode || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
|
|
1016
519
|
|
|
520
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/number.js
|
|
521
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
|
|
522
|
+
var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER;
|
|
523
|
+
var LOWEST_INT32 = 1 << 31;
|
|
524
|
+
|
|
525
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/encoding.js
|
|
526
|
+
var write = (encoder, num) => {
|
|
527
|
+
const bufferLen = encoder.cbuf.length;
|
|
528
|
+
if (encoder.cpos === bufferLen) {
|
|
529
|
+
encoder.bufs.push(encoder.cbuf);
|
|
530
|
+
encoder.cbuf = new Uint8Array(bufferLen * 2);
|
|
531
|
+
encoder.cpos = 0;
|
|
532
|
+
}
|
|
533
|
+
encoder.cbuf[encoder.cpos++] = num;
|
|
534
|
+
};
|
|
535
|
+
var writeVarUint = (encoder, num) => {
|
|
536
|
+
while (num > BITS7) {
|
|
537
|
+
write(encoder, BIT8 | BITS7 & num);
|
|
538
|
+
num = floor(num / 128);
|
|
539
|
+
}
|
|
540
|
+
write(encoder, BITS7 & num);
|
|
541
|
+
};
|
|
542
|
+
var _strBuffer = new Uint8Array(30000);
|
|
543
|
+
var _maxStrBSize = _strBuffer.length / 3;
|
|
544
|
+
var _writeVarStringNative = (encoder, str) => {
|
|
545
|
+
if (str.length < _maxStrBSize) {
|
|
546
|
+
const written = utf8TextEncoder.encodeInto(str, _strBuffer).written || 0;
|
|
547
|
+
writeVarUint(encoder, written);
|
|
548
|
+
for (let i = 0;i < written; i++) {
|
|
549
|
+
write(encoder, _strBuffer[i]);
|
|
550
|
+
}
|
|
551
|
+
} else {
|
|
552
|
+
writeVarUint8Array(encoder, encodeUtf8(str));
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
var _writeVarStringPolyfill = (encoder, str) => {
|
|
556
|
+
const encodedString = unescape(encodeURIComponent(str));
|
|
557
|
+
const len = encodedString.length;
|
|
558
|
+
writeVarUint(encoder, len);
|
|
559
|
+
for (let i = 0;i < len; i++) {
|
|
560
|
+
write(encoder, encodedString.codePointAt(i));
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
var writeVarString = utf8TextEncoder && utf8TextEncoder.encodeInto ? _writeVarStringNative : _writeVarStringPolyfill;
|
|
564
|
+
var writeUint8Array = (encoder, uint8Array) => {
|
|
565
|
+
const bufferLen = encoder.cbuf.length;
|
|
566
|
+
const cpos = encoder.cpos;
|
|
567
|
+
const leftCopyLen = min(bufferLen - cpos, uint8Array.length);
|
|
568
|
+
const rightCopyLen = uint8Array.length - leftCopyLen;
|
|
569
|
+
encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
|
|
570
|
+
encoder.cpos += leftCopyLen;
|
|
571
|
+
if (rightCopyLen > 0) {
|
|
572
|
+
encoder.bufs.push(encoder.cbuf);
|
|
573
|
+
encoder.cbuf = new Uint8Array(max(bufferLen * 2, rightCopyLen));
|
|
574
|
+
encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
|
|
575
|
+
encoder.cpos = rightCopyLen;
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
var writeVarUint8Array = (encoder, uint8Array) => {
|
|
579
|
+
writeVarUint(encoder, uint8Array.byteLength);
|
|
580
|
+
writeUint8Array(encoder, uint8Array);
|
|
581
|
+
};
|
|
582
|
+
var floatTestBed = new DataView(new ArrayBuffer(4));
|
|
583
|
+
|
|
584
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/error.js
|
|
585
|
+
var create4 = (s) => new Error(s);
|
|
586
|
+
var methodUnimplemented = () => {
|
|
587
|
+
throw create4("Method unimplemented");
|
|
588
|
+
};
|
|
589
|
+
var unexpectedCase = () => {
|
|
590
|
+
throw create4("Unexpected case");
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/decoding.js
|
|
594
|
+
var errorUnexpectedEndOfArray = create4("Unexpected end of array");
|
|
595
|
+
var errorIntegerOutOfRange = create4("Integer out of Range");
|
|
596
|
+
|
|
1017
597
|
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/buffer.js
|
|
1018
598
|
var createUint8ArrayFromLen = (len) => new Uint8Array(len);
|
|
1019
599
|
var copyUint8Array = (uint8Array) => {
|
|
@@ -1408,7 +988,7 @@ var $ = (o) => {
|
|
|
1408
988
|
var assert = production ? () => {} : (o, schema) => {
|
|
1409
989
|
const err = new ValidationError;
|
|
1410
990
|
if (!schema.check(o, err)) {
|
|
1411
|
-
throw
|
|
991
|
+
throw create4(`Expected value to be of type ${schema.constructor.name}.
|
|
1412
992
|
${err.toString()}`);
|
|
1413
993
|
}
|
|
1414
994
|
};
|
|
@@ -1433,7 +1013,7 @@ class PatternMatcher {
|
|
|
1433
1013
|
return p.h(o, s);
|
|
1434
1014
|
}
|
|
1435
1015
|
}
|
|
1436
|
-
throw
|
|
1016
|
+
throw create4("Unhandled pattern");
|
|
1437
1017
|
};
|
|
1438
1018
|
}
|
|
1439
1019
|
}
|
|
@@ -1733,8 +1313,8 @@ var mergeDeleteSets = (dss) => {
|
|
|
1733
1313
|
sortAndMergeDeleteSet(merged);
|
|
1734
1314
|
return merged;
|
|
1735
1315
|
};
|
|
1736
|
-
var addToDeleteSet = (ds, client, clock,
|
|
1737
|
-
setIfUndefined(ds.clients, client, () => []).push(new DeleteItem(clock,
|
|
1316
|
+
var addToDeleteSet = (ds, client, clock, length) => {
|
|
1317
|
+
setIfUndefined(ds.clients, client, () => []).push(new DeleteItem(clock, length));
|
|
1738
1318
|
};
|
|
1739
1319
|
var createDeleteSet = () => new DeleteSet;
|
|
1740
1320
|
var createDeleteSetFromStructStore = (ss) => {
|
|
@@ -1761,12 +1341,12 @@ var createDeleteSetFromStructStore = (ss) => {
|
|
|
1761
1341
|
return ds;
|
|
1762
1342
|
};
|
|
1763
1343
|
var writeDeleteSet = (encoder, ds) => {
|
|
1764
|
-
writeVarUint(encoder.restEncoder, ds.clients.size);
|
|
1344
|
+
encoding.writeVarUint(encoder.restEncoder, ds.clients.size);
|
|
1765
1345
|
from2(ds.clients.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, dsitems]) => {
|
|
1766
1346
|
encoder.resetDsCurVal();
|
|
1767
|
-
writeVarUint(encoder.restEncoder, client);
|
|
1347
|
+
encoding.writeVarUint(encoder.restEncoder, client);
|
|
1768
1348
|
const len = dsitems.length;
|
|
1769
|
-
writeVarUint(encoder.restEncoder, len);
|
|
1349
|
+
encoding.writeVarUint(encoder.restEncoder, len);
|
|
1770
1350
|
for (let i = 0;i < len; i++) {
|
|
1771
1351
|
const item = dsitems[i];
|
|
1772
1352
|
encoder.writeDsClock(item.clock);
|
|
@@ -1776,11 +1356,11 @@ var writeDeleteSet = (encoder, ds) => {
|
|
|
1776
1356
|
};
|
|
1777
1357
|
var readDeleteSet = (decoder) => {
|
|
1778
1358
|
const ds = new DeleteSet;
|
|
1779
|
-
const numClients = readVarUint(decoder.restDecoder);
|
|
1359
|
+
const numClients = decoding.readVarUint(decoder.restDecoder);
|
|
1780
1360
|
for (let i = 0;i < numClients; i++) {
|
|
1781
1361
|
decoder.resetDsCurVal();
|
|
1782
|
-
const client = readVarUint(decoder.restDecoder);
|
|
1783
|
-
const numberOfDeletes = readVarUint(decoder.restDecoder);
|
|
1362
|
+
const client = decoding.readVarUint(decoder.restDecoder);
|
|
1363
|
+
const numberOfDeletes = decoding.readVarUint(decoder.restDecoder);
|
|
1784
1364
|
if (numberOfDeletes > 0) {
|
|
1785
1365
|
const dsField = setIfUndefined(ds.clients, client, () => []);
|
|
1786
1366
|
for (let i2 = 0;i2 < numberOfDeletes; i2++) {
|
|
@@ -1792,11 +1372,11 @@ var readDeleteSet = (decoder) => {
|
|
|
1792
1372
|
};
|
|
1793
1373
|
var readAndApplyDeleteSet = (decoder, transaction, store) => {
|
|
1794
1374
|
const unappliedDS = new DeleteSet;
|
|
1795
|
-
const numClients = readVarUint(decoder.restDecoder);
|
|
1375
|
+
const numClients = decoding.readVarUint(decoder.restDecoder);
|
|
1796
1376
|
for (let i = 0;i < numClients; i++) {
|
|
1797
1377
|
decoder.resetDsCurVal();
|
|
1798
|
-
const client = readVarUint(decoder.restDecoder);
|
|
1799
|
-
const numberOfDeletes = readVarUint(decoder.restDecoder);
|
|
1378
|
+
const client = decoding.readVarUint(decoder.restDecoder);
|
|
1379
|
+
const numberOfDeletes = decoding.readVarUint(decoder.restDecoder);
|
|
1800
1380
|
const structs = store.clients.get(client) || [];
|
|
1801
1381
|
const state = getState(store, client);
|
|
1802
1382
|
for (let i2 = 0;i2 < numberOfDeletes; i2++) {
|
|
@@ -1832,7 +1412,7 @@ var readAndApplyDeleteSet = (decoder, transaction, store) => {
|
|
|
1832
1412
|
}
|
|
1833
1413
|
if (unappliedDS.clients.size > 0) {
|
|
1834
1414
|
const ds = new UpdateEncoderV2;
|
|
1835
|
-
writeVarUint(ds.restEncoder, 0);
|
|
1415
|
+
encoding.writeVarUint(ds.restEncoder, 0);
|
|
1836
1416
|
writeDeleteSet(ds, unappliedDS);
|
|
1837
1417
|
return ds.toUint8Array();
|
|
1838
1418
|
}
|
|
@@ -1877,13 +1457,13 @@ class Doc extends ObservableV2 {
|
|
|
1877
1457
|
this.isLoaded = false;
|
|
1878
1458
|
this.isSynced = false;
|
|
1879
1459
|
this.isDestroyed = false;
|
|
1880
|
-
this.whenLoaded =
|
|
1460
|
+
this.whenLoaded = create3((resolve) => {
|
|
1881
1461
|
this.on("load", () => {
|
|
1882
1462
|
this.isLoaded = true;
|
|
1883
1463
|
resolve(this);
|
|
1884
1464
|
});
|
|
1885
1465
|
});
|
|
1886
|
-
const provideSyncedPromise = () =>
|
|
1466
|
+
const provideSyncedPromise = () => create3((resolve) => {
|
|
1887
1467
|
const eventHandler = (isSynced) => {
|
|
1888
1468
|
if (isSynced === undefined || isSynced === true) {
|
|
1889
1469
|
this.off("sync", eventHandler);
|
|
@@ -2002,49 +1582,49 @@ class DSDecoderV1 {
|
|
|
2002
1582
|
}
|
|
2003
1583
|
resetDsCurVal() {}
|
|
2004
1584
|
readDsClock() {
|
|
2005
|
-
return readVarUint(this.restDecoder);
|
|
1585
|
+
return decoding.readVarUint(this.restDecoder);
|
|
2006
1586
|
}
|
|
2007
1587
|
readDsLen() {
|
|
2008
|
-
return readVarUint(this.restDecoder);
|
|
1588
|
+
return decoding.readVarUint(this.restDecoder);
|
|
2009
1589
|
}
|
|
2010
1590
|
}
|
|
2011
1591
|
|
|
2012
1592
|
class UpdateDecoderV1 extends DSDecoderV1 {
|
|
2013
1593
|
readLeftID() {
|
|
2014
|
-
return createID(readVarUint(this.restDecoder), readVarUint(this.restDecoder));
|
|
1594
|
+
return createID(decoding.readVarUint(this.restDecoder), decoding.readVarUint(this.restDecoder));
|
|
2015
1595
|
}
|
|
2016
1596
|
readRightID() {
|
|
2017
|
-
return createID(readVarUint(this.restDecoder), readVarUint(this.restDecoder));
|
|
1597
|
+
return createID(decoding.readVarUint(this.restDecoder), decoding.readVarUint(this.restDecoder));
|
|
2018
1598
|
}
|
|
2019
1599
|
readClient() {
|
|
2020
|
-
return readVarUint(this.restDecoder);
|
|
1600
|
+
return decoding.readVarUint(this.restDecoder);
|
|
2021
1601
|
}
|
|
2022
1602
|
readInfo() {
|
|
2023
|
-
return readUint8(this.restDecoder);
|
|
1603
|
+
return decoding.readUint8(this.restDecoder);
|
|
2024
1604
|
}
|
|
2025
1605
|
readString() {
|
|
2026
|
-
return readVarString(this.restDecoder);
|
|
1606
|
+
return decoding.readVarString(this.restDecoder);
|
|
2027
1607
|
}
|
|
2028
1608
|
readParentInfo() {
|
|
2029
|
-
return readVarUint(this.restDecoder) === 1;
|
|
1609
|
+
return decoding.readVarUint(this.restDecoder) === 1;
|
|
2030
1610
|
}
|
|
2031
1611
|
readTypeRef() {
|
|
2032
|
-
return readVarUint(this.restDecoder);
|
|
1612
|
+
return decoding.readVarUint(this.restDecoder);
|
|
2033
1613
|
}
|
|
2034
1614
|
readLen() {
|
|
2035
|
-
return readVarUint(this.restDecoder);
|
|
1615
|
+
return decoding.readVarUint(this.restDecoder);
|
|
2036
1616
|
}
|
|
2037
1617
|
readAny() {
|
|
2038
|
-
return readAny(this.restDecoder);
|
|
1618
|
+
return decoding.readAny(this.restDecoder);
|
|
2039
1619
|
}
|
|
2040
1620
|
readBuf() {
|
|
2041
|
-
return copyUint8Array(readVarUint8Array(this.restDecoder));
|
|
1621
|
+
return copyUint8Array(decoding.readVarUint8Array(this.restDecoder));
|
|
2042
1622
|
}
|
|
2043
1623
|
readJSON() {
|
|
2044
|
-
return JSON.parse(readVarString(this.restDecoder));
|
|
1624
|
+
return JSON.parse(decoding.readVarString(this.restDecoder));
|
|
2045
1625
|
}
|
|
2046
1626
|
readKey() {
|
|
2047
|
-
return readVarString(this.restDecoder);
|
|
1627
|
+
return decoding.readVarString(this.restDecoder);
|
|
2048
1628
|
}
|
|
2049
1629
|
}
|
|
2050
1630
|
|
|
@@ -2057,11 +1637,11 @@ class DSDecoderV2 {
|
|
|
2057
1637
|
this.dsCurrVal = 0;
|
|
2058
1638
|
}
|
|
2059
1639
|
readDsClock() {
|
|
2060
|
-
this.dsCurrVal += readVarUint(this.restDecoder);
|
|
1640
|
+
this.dsCurrVal += decoding.readVarUint(this.restDecoder);
|
|
2061
1641
|
return this.dsCurrVal;
|
|
2062
1642
|
}
|
|
2063
1643
|
readDsLen() {
|
|
2064
|
-
const diff = readVarUint(this.restDecoder) + 1;
|
|
1644
|
+
const diff = decoding.readVarUint(this.restDecoder) + 1;
|
|
2065
1645
|
this.dsCurrVal += diff;
|
|
2066
1646
|
return diff;
|
|
2067
1647
|
}
|
|
@@ -2071,16 +1651,16 @@ class UpdateDecoderV2 extends DSDecoderV2 {
|
|
|
2071
1651
|
constructor(decoder) {
|
|
2072
1652
|
super(decoder);
|
|
2073
1653
|
this.keys = [];
|
|
2074
|
-
readVarUint(decoder);
|
|
2075
|
-
this.keyClockDecoder = new IntDiffOptRleDecoder(readVarUint8Array(decoder));
|
|
2076
|
-
this.clientDecoder = new UintOptRleDecoder(readVarUint8Array(decoder));
|
|
2077
|
-
this.leftClockDecoder = new IntDiffOptRleDecoder(readVarUint8Array(decoder));
|
|
2078
|
-
this.rightClockDecoder = new IntDiffOptRleDecoder(readVarUint8Array(decoder));
|
|
2079
|
-
this.infoDecoder = new RleDecoder(readVarUint8Array(decoder), readUint8);
|
|
2080
|
-
this.stringDecoder = new StringDecoder(readVarUint8Array(decoder));
|
|
2081
|
-
this.parentInfoDecoder = new RleDecoder(readVarUint8Array(decoder), readUint8);
|
|
2082
|
-
this.typeRefDecoder = new UintOptRleDecoder(readVarUint8Array(decoder));
|
|
2083
|
-
this.lenDecoder = new UintOptRleDecoder(readVarUint8Array(decoder));
|
|
1654
|
+
decoding.readVarUint(decoder);
|
|
1655
|
+
this.keyClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
1656
|
+
this.clientDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
1657
|
+
this.leftClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
1658
|
+
this.rightClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
1659
|
+
this.infoDecoder = new decoding.RleDecoder(decoding.readVarUint8Array(decoder), decoding.readUint8);
|
|
1660
|
+
this.stringDecoder = new decoding.StringDecoder(decoding.readVarUint8Array(decoder));
|
|
1661
|
+
this.parentInfoDecoder = new decoding.RleDecoder(decoding.readVarUint8Array(decoder), decoding.readUint8);
|
|
1662
|
+
this.typeRefDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
1663
|
+
this.lenDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
2084
1664
|
}
|
|
2085
1665
|
readLeftID() {
|
|
2086
1666
|
return new ID(this.clientDecoder.read(), this.leftClockDecoder.read());
|
|
@@ -2107,13 +1687,13 @@ class UpdateDecoderV2 extends DSDecoderV2 {
|
|
|
2107
1687
|
return this.lenDecoder.read();
|
|
2108
1688
|
}
|
|
2109
1689
|
readAny() {
|
|
2110
|
-
return readAny(this.restDecoder);
|
|
1690
|
+
return decoding.readAny(this.restDecoder);
|
|
2111
1691
|
}
|
|
2112
1692
|
readBuf() {
|
|
2113
|
-
return readVarUint8Array(this.restDecoder);
|
|
1693
|
+
return decoding.readVarUint8Array(this.restDecoder);
|
|
2114
1694
|
}
|
|
2115
1695
|
readJSON() {
|
|
2116
|
-
return readAny(this.restDecoder);
|
|
1696
|
+
return decoding.readAny(this.restDecoder);
|
|
2117
1697
|
}
|
|
2118
1698
|
readKey() {
|
|
2119
1699
|
const keyClock = this.keyClockDecoder.read();
|
|
@@ -2129,68 +1709,68 @@ class UpdateDecoderV2 extends DSDecoderV2 {
|
|
|
2129
1709
|
|
|
2130
1710
|
class DSEncoderV1 {
|
|
2131
1711
|
constructor() {
|
|
2132
|
-
this.restEncoder = createEncoder();
|
|
1712
|
+
this.restEncoder = encoding.createEncoder();
|
|
2133
1713
|
}
|
|
2134
1714
|
toUint8Array() {
|
|
2135
|
-
return toUint8Array(this.restEncoder);
|
|
1715
|
+
return encoding.toUint8Array(this.restEncoder);
|
|
2136
1716
|
}
|
|
2137
1717
|
resetDsCurVal() {}
|
|
2138
1718
|
writeDsClock(clock) {
|
|
2139
|
-
writeVarUint(this.restEncoder, clock);
|
|
1719
|
+
encoding.writeVarUint(this.restEncoder, clock);
|
|
2140
1720
|
}
|
|
2141
1721
|
writeDsLen(len) {
|
|
2142
|
-
writeVarUint(this.restEncoder, len);
|
|
1722
|
+
encoding.writeVarUint(this.restEncoder, len);
|
|
2143
1723
|
}
|
|
2144
1724
|
}
|
|
2145
1725
|
|
|
2146
1726
|
class UpdateEncoderV1 extends DSEncoderV1 {
|
|
2147
1727
|
writeLeftID(id2) {
|
|
2148
|
-
writeVarUint(this.restEncoder, id2.client);
|
|
2149
|
-
writeVarUint(this.restEncoder, id2.clock);
|
|
1728
|
+
encoding.writeVarUint(this.restEncoder, id2.client);
|
|
1729
|
+
encoding.writeVarUint(this.restEncoder, id2.clock);
|
|
2150
1730
|
}
|
|
2151
1731
|
writeRightID(id2) {
|
|
2152
|
-
writeVarUint(this.restEncoder, id2.client);
|
|
2153
|
-
writeVarUint(this.restEncoder, id2.clock);
|
|
1732
|
+
encoding.writeVarUint(this.restEncoder, id2.client);
|
|
1733
|
+
encoding.writeVarUint(this.restEncoder, id2.clock);
|
|
2154
1734
|
}
|
|
2155
1735
|
writeClient(client) {
|
|
2156
|
-
writeVarUint(this.restEncoder, client);
|
|
1736
|
+
encoding.writeVarUint(this.restEncoder, client);
|
|
2157
1737
|
}
|
|
2158
1738
|
writeInfo(info) {
|
|
2159
|
-
writeUint8(this.restEncoder, info);
|
|
1739
|
+
encoding.writeUint8(this.restEncoder, info);
|
|
2160
1740
|
}
|
|
2161
1741
|
writeString(s) {
|
|
2162
|
-
writeVarString(this.restEncoder, s);
|
|
1742
|
+
encoding.writeVarString(this.restEncoder, s);
|
|
2163
1743
|
}
|
|
2164
1744
|
writeParentInfo(isYKey) {
|
|
2165
|
-
writeVarUint(this.restEncoder, isYKey ? 1 : 0);
|
|
1745
|
+
encoding.writeVarUint(this.restEncoder, isYKey ? 1 : 0);
|
|
2166
1746
|
}
|
|
2167
1747
|
writeTypeRef(info) {
|
|
2168
|
-
writeVarUint(this.restEncoder, info);
|
|
1748
|
+
encoding.writeVarUint(this.restEncoder, info);
|
|
2169
1749
|
}
|
|
2170
1750
|
writeLen(len) {
|
|
2171
|
-
writeVarUint(this.restEncoder, len);
|
|
1751
|
+
encoding.writeVarUint(this.restEncoder, len);
|
|
2172
1752
|
}
|
|
2173
1753
|
writeAny(any2) {
|
|
2174
|
-
writeAny(this.restEncoder, any2);
|
|
1754
|
+
encoding.writeAny(this.restEncoder, any2);
|
|
2175
1755
|
}
|
|
2176
1756
|
writeBuf(buf) {
|
|
2177
|
-
writeVarUint8Array(this.restEncoder, buf);
|
|
1757
|
+
encoding.writeVarUint8Array(this.restEncoder, buf);
|
|
2178
1758
|
}
|
|
2179
1759
|
writeJSON(embed) {
|
|
2180
|
-
writeVarString(this.restEncoder, JSON.stringify(embed));
|
|
1760
|
+
encoding.writeVarString(this.restEncoder, JSON.stringify(embed));
|
|
2181
1761
|
}
|
|
2182
1762
|
writeKey(key) {
|
|
2183
|
-
writeVarString(this.restEncoder, key);
|
|
1763
|
+
encoding.writeVarString(this.restEncoder, key);
|
|
2184
1764
|
}
|
|
2185
1765
|
}
|
|
2186
1766
|
|
|
2187
1767
|
class DSEncoderV2 {
|
|
2188
1768
|
constructor() {
|
|
2189
|
-
this.restEncoder = createEncoder();
|
|
1769
|
+
this.restEncoder = encoding.createEncoder();
|
|
2190
1770
|
this.dsCurrVal = 0;
|
|
2191
1771
|
}
|
|
2192
1772
|
toUint8Array() {
|
|
2193
|
-
return toUint8Array(this.restEncoder);
|
|
1773
|
+
return encoding.toUint8Array(this.restEncoder);
|
|
2194
1774
|
}
|
|
2195
1775
|
resetDsCurVal() {
|
|
2196
1776
|
this.dsCurrVal = 0;
|
|
@@ -2198,13 +1778,13 @@ class DSEncoderV2 {
|
|
|
2198
1778
|
writeDsClock(clock) {
|
|
2199
1779
|
const diff = clock - this.dsCurrVal;
|
|
2200
1780
|
this.dsCurrVal = clock;
|
|
2201
|
-
writeVarUint(this.restEncoder, diff);
|
|
1781
|
+
encoding.writeVarUint(this.restEncoder, diff);
|
|
2202
1782
|
}
|
|
2203
1783
|
writeDsLen(len) {
|
|
2204
1784
|
if (len === 0) {
|
|
2205
1785
|
unexpectedCase();
|
|
2206
1786
|
}
|
|
2207
|
-
writeVarUint(this.restEncoder, len - 1);
|
|
1787
|
+
encoding.writeVarUint(this.restEncoder, len - 1);
|
|
2208
1788
|
this.dsCurrVal += len;
|
|
2209
1789
|
}
|
|
2210
1790
|
}
|
|
@@ -2214,30 +1794,30 @@ class UpdateEncoderV2 extends DSEncoderV2 {
|
|
|
2214
1794
|
super();
|
|
2215
1795
|
this.keyMap = new Map;
|
|
2216
1796
|
this.keyClock = 0;
|
|
2217
|
-
this.keyClockEncoder = new IntDiffOptRleEncoder;
|
|
2218
|
-
this.clientEncoder = new UintOptRleEncoder;
|
|
2219
|
-
this.leftClockEncoder = new IntDiffOptRleEncoder;
|
|
2220
|
-
this.rightClockEncoder = new IntDiffOptRleEncoder;
|
|
2221
|
-
this.infoEncoder = new RleEncoder(writeUint8);
|
|
2222
|
-
this.stringEncoder = new StringEncoder;
|
|
2223
|
-
this.parentInfoEncoder = new RleEncoder(writeUint8);
|
|
2224
|
-
this.typeRefEncoder = new UintOptRleEncoder;
|
|
2225
|
-
this.lenEncoder = new UintOptRleEncoder;
|
|
1797
|
+
this.keyClockEncoder = new encoding.IntDiffOptRleEncoder;
|
|
1798
|
+
this.clientEncoder = new encoding.UintOptRleEncoder;
|
|
1799
|
+
this.leftClockEncoder = new encoding.IntDiffOptRleEncoder;
|
|
1800
|
+
this.rightClockEncoder = new encoding.IntDiffOptRleEncoder;
|
|
1801
|
+
this.infoEncoder = new encoding.RleEncoder(encoding.writeUint8);
|
|
1802
|
+
this.stringEncoder = new encoding.StringEncoder;
|
|
1803
|
+
this.parentInfoEncoder = new encoding.RleEncoder(encoding.writeUint8);
|
|
1804
|
+
this.typeRefEncoder = new encoding.UintOptRleEncoder;
|
|
1805
|
+
this.lenEncoder = new encoding.UintOptRleEncoder;
|
|
2226
1806
|
}
|
|
2227
1807
|
toUint8Array() {
|
|
2228
|
-
const encoder = createEncoder();
|
|
2229
|
-
writeVarUint(encoder, 0);
|
|
2230
|
-
writeVarUint8Array(encoder, this.keyClockEncoder.toUint8Array());
|
|
2231
|
-
writeVarUint8Array(encoder, this.clientEncoder.toUint8Array());
|
|
2232
|
-
writeVarUint8Array(encoder, this.leftClockEncoder.toUint8Array());
|
|
2233
|
-
writeVarUint8Array(encoder, this.rightClockEncoder.toUint8Array());
|
|
2234
|
-
writeVarUint8Array(encoder, toUint8Array(this.infoEncoder));
|
|
2235
|
-
writeVarUint8Array(encoder, this.stringEncoder.toUint8Array());
|
|
2236
|
-
writeVarUint8Array(encoder, toUint8Array(this.parentInfoEncoder));
|
|
2237
|
-
writeVarUint8Array(encoder, this.typeRefEncoder.toUint8Array());
|
|
2238
|
-
writeVarUint8Array(encoder, this.lenEncoder.toUint8Array());
|
|
2239
|
-
writeUint8Array(encoder, toUint8Array(this.restEncoder));
|
|
2240
|
-
return toUint8Array(encoder);
|
|
1808
|
+
const encoder = encoding.createEncoder();
|
|
1809
|
+
encoding.writeVarUint(encoder, 0);
|
|
1810
|
+
encoding.writeVarUint8Array(encoder, this.keyClockEncoder.toUint8Array());
|
|
1811
|
+
encoding.writeVarUint8Array(encoder, this.clientEncoder.toUint8Array());
|
|
1812
|
+
encoding.writeVarUint8Array(encoder, this.leftClockEncoder.toUint8Array());
|
|
1813
|
+
encoding.writeVarUint8Array(encoder, this.rightClockEncoder.toUint8Array());
|
|
1814
|
+
encoding.writeVarUint8Array(encoder, encoding.toUint8Array(this.infoEncoder));
|
|
1815
|
+
encoding.writeVarUint8Array(encoder, this.stringEncoder.toUint8Array());
|
|
1816
|
+
encoding.writeVarUint8Array(encoder, encoding.toUint8Array(this.parentInfoEncoder));
|
|
1817
|
+
encoding.writeVarUint8Array(encoder, this.typeRefEncoder.toUint8Array());
|
|
1818
|
+
encoding.writeVarUint8Array(encoder, this.lenEncoder.toUint8Array());
|
|
1819
|
+
encoding.writeUint8Array(encoder, encoding.toUint8Array(this.restEncoder));
|
|
1820
|
+
return encoding.toUint8Array(encoder);
|
|
2241
1821
|
}
|
|
2242
1822
|
writeLeftID(id2) {
|
|
2243
1823
|
this.clientEncoder.write(id2.client);
|
|
@@ -2266,13 +1846,13 @@ class UpdateEncoderV2 extends DSEncoderV2 {
|
|
|
2266
1846
|
this.lenEncoder.write(len);
|
|
2267
1847
|
}
|
|
2268
1848
|
writeAny(any2) {
|
|
2269
|
-
writeAny(this.restEncoder, any2);
|
|
1849
|
+
encoding.writeAny(this.restEncoder, any2);
|
|
2270
1850
|
}
|
|
2271
1851
|
writeBuf(buf) {
|
|
2272
|
-
writeVarUint8Array(this.restEncoder, buf);
|
|
1852
|
+
encoding.writeVarUint8Array(this.restEncoder, buf);
|
|
2273
1853
|
}
|
|
2274
1854
|
writeJSON(embed) {
|
|
2275
|
-
writeAny(this.restEncoder, embed);
|
|
1855
|
+
encoding.writeAny(this.restEncoder, embed);
|
|
2276
1856
|
}
|
|
2277
1857
|
writeKey(key) {
|
|
2278
1858
|
const clock = this.keyMap.get(key);
|
|
@@ -2287,9 +1867,9 @@ class UpdateEncoderV2 extends DSEncoderV2 {
|
|
|
2287
1867
|
var writeStructs = (encoder, structs, client, clock) => {
|
|
2288
1868
|
clock = max(clock, structs[0].id.clock);
|
|
2289
1869
|
const startNewStructs = findIndexSS(structs, clock);
|
|
2290
|
-
writeVarUint(encoder.restEncoder, structs.length - startNewStructs);
|
|
1870
|
+
encoding.writeVarUint(encoder.restEncoder, structs.length - startNewStructs);
|
|
2291
1871
|
encoder.writeClient(client);
|
|
2292
|
-
writeVarUint(encoder.restEncoder, clock);
|
|
1872
|
+
encoding.writeVarUint(encoder.restEncoder, clock);
|
|
2293
1873
|
const firstStruct = structs[startNewStructs];
|
|
2294
1874
|
firstStruct.write(encoder, clock - firstStruct.id.clock);
|
|
2295
1875
|
for (let i = startNewStructs + 1;i < structs.length; i++) {
|
|
@@ -2308,19 +1888,19 @@ var writeClientsStructs = (encoder, store, _sm) => {
|
|
|
2308
1888
|
sm.set(client, 0);
|
|
2309
1889
|
}
|
|
2310
1890
|
});
|
|
2311
|
-
writeVarUint(encoder.restEncoder, sm.size);
|
|
1891
|
+
encoding.writeVarUint(encoder.restEncoder, sm.size);
|
|
2312
1892
|
from2(sm.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, clock]) => {
|
|
2313
1893
|
writeStructs(encoder, store.clients.get(client), client, clock);
|
|
2314
1894
|
});
|
|
2315
1895
|
};
|
|
2316
1896
|
var readClientsStructRefs = (decoder, doc2) => {
|
|
2317
1897
|
const clientRefs = create();
|
|
2318
|
-
const numOfStateUpdates = readVarUint(decoder.restDecoder);
|
|
1898
|
+
const numOfStateUpdates = decoding.readVarUint(decoder.restDecoder);
|
|
2319
1899
|
for (let i = 0;i < numOfStateUpdates; i++) {
|
|
2320
|
-
const numberOfStructs = readVarUint(decoder.restDecoder);
|
|
1900
|
+
const numberOfStructs = decoding.readVarUint(decoder.restDecoder);
|
|
2321
1901
|
const refs = new Array(numberOfStructs);
|
|
2322
1902
|
const client = decoder.readClient();
|
|
2323
|
-
let clock = readVarUint(decoder.restDecoder);
|
|
1903
|
+
let clock = decoding.readVarUint(decoder.restDecoder);
|
|
2324
1904
|
clientRefs.set(client, { i: 0, refs });
|
|
2325
1905
|
for (let i2 = 0;i2 < numberOfStructs; i2++) {
|
|
2326
1906
|
const info = decoder.readInfo();
|
|
@@ -2332,7 +1912,7 @@ var readClientsStructRefs = (decoder, doc2) => {
|
|
|
2332
1912
|
break;
|
|
2333
1913
|
}
|
|
2334
1914
|
case 10: {
|
|
2335
|
-
const len = readVarUint(decoder.restDecoder);
|
|
1915
|
+
const len = decoding.readVarUint(decoder.restDecoder);
|
|
2336
1916
|
refs[i2] = new Skip(createID(client, clock), len);
|
|
2337
1917
|
clock += len;
|
|
2338
1918
|
break;
|
|
@@ -2442,7 +2022,7 @@ var integrateStructs = (transaction, store, clientsStructRefs) => {
|
|
|
2442
2022
|
if (restStructs.clients.size > 0) {
|
|
2443
2023
|
const encoder = new UpdateEncoderV2;
|
|
2444
2024
|
writeClientsStructs(encoder, restStructs, new Map);
|
|
2445
|
-
writeVarUint(encoder.restEncoder, 0);
|
|
2025
|
+
encoding.writeVarUint(encoder.restEncoder, 0);
|
|
2446
2026
|
return { missing: missingSV, update: encoder.toUint8Array() };
|
|
2447
2027
|
}
|
|
2448
2028
|
return null;
|
|
@@ -2477,8 +2057,8 @@ var readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = new Update
|
|
|
2477
2057
|
}
|
|
2478
2058
|
const dsRest = readAndApplyDeleteSet(structDecoder, transaction, store);
|
|
2479
2059
|
if (store.pendingDs) {
|
|
2480
|
-
const pendingDSUpdate = new UpdateDecoderV2(createDecoder(store.pendingDs));
|
|
2481
|
-
readVarUint(pendingDSUpdate.restDecoder);
|
|
2060
|
+
const pendingDSUpdate = new UpdateDecoderV2(decoding.createDecoder(store.pendingDs));
|
|
2061
|
+
decoding.readVarUint(pendingDSUpdate.restDecoder);
|
|
2482
2062
|
const dsRest2 = readAndApplyDeleteSet(pendingDSUpdate, transaction, store);
|
|
2483
2063
|
if (dsRest && dsRest2) {
|
|
2484
2064
|
store.pendingDs = mergeUpdatesV2([dsRest, dsRest2]);
|
|
@@ -2496,7 +2076,7 @@ var readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = new Update
|
|
|
2496
2076
|
}, transactionOrigin, false);
|
|
2497
2077
|
var readUpdate = (decoder, ydoc, transactionOrigin) => readUpdateV2(decoder, ydoc, transactionOrigin, new UpdateDecoderV1(decoder));
|
|
2498
2078
|
var applyUpdateV2 = (ydoc, update, transactionOrigin, YDecoder = UpdateDecoderV2) => {
|
|
2499
|
-
const decoder = createDecoder(update);
|
|
2079
|
+
const decoder = decoding.createDecoder(update);
|
|
2500
2080
|
readUpdateV2(decoder, ydoc, transactionOrigin, new YDecoder(decoder));
|
|
2501
2081
|
};
|
|
2502
2082
|
var applyUpdate = (ydoc, update, transactionOrigin) => applyUpdateV2(ydoc, update, transactionOrigin, UpdateDecoderV1);
|
|
@@ -2526,20 +2106,20 @@ var encodeStateAsUpdateV2 = (doc2, encodedTargetStateVector = new Uint8Array([0]
|
|
|
2526
2106
|
var encodeStateAsUpdate = (doc2, encodedTargetStateVector) => encodeStateAsUpdateV2(doc2, encodedTargetStateVector, new UpdateEncoderV1);
|
|
2527
2107
|
var readStateVector = (decoder) => {
|
|
2528
2108
|
const ss = new Map;
|
|
2529
|
-
const ssLength = readVarUint(decoder.restDecoder);
|
|
2109
|
+
const ssLength = decoding.readVarUint(decoder.restDecoder);
|
|
2530
2110
|
for (let i = 0;i < ssLength; i++) {
|
|
2531
|
-
const client = readVarUint(decoder.restDecoder);
|
|
2532
|
-
const clock = readVarUint(decoder.restDecoder);
|
|
2111
|
+
const client = decoding.readVarUint(decoder.restDecoder);
|
|
2112
|
+
const clock = decoding.readVarUint(decoder.restDecoder);
|
|
2533
2113
|
ss.set(client, clock);
|
|
2534
2114
|
}
|
|
2535
2115
|
return ss;
|
|
2536
2116
|
};
|
|
2537
|
-
var decodeStateVector = (decodedState) => readStateVector(new DSDecoderV1(createDecoder(decodedState)));
|
|
2117
|
+
var decodeStateVector = (decodedState) => readStateVector(new DSDecoderV1(decoding.createDecoder(decodedState)));
|
|
2538
2118
|
var writeStateVector = (encoder, sv) => {
|
|
2539
|
-
writeVarUint(encoder.restEncoder, sv.size);
|
|
2119
|
+
encoding.writeVarUint(encoder.restEncoder, sv.size);
|
|
2540
2120
|
from2(sv.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, clock]) => {
|
|
2541
|
-
writeVarUint(encoder.restEncoder, client);
|
|
2542
|
-
writeVarUint(encoder.restEncoder, clock);
|
|
2121
|
+
encoding.writeVarUint(encoder.restEncoder, client);
|
|
2122
|
+
encoding.writeVarUint(encoder.restEncoder, clock);
|
|
2543
2123
|
});
|
|
2544
2124
|
return encoder;
|
|
2545
2125
|
};
|
|
@@ -2580,10 +2160,10 @@ class ID {
|
|
|
2580
2160
|
var compareIDs = (a, b) => a === b || a !== null && b !== null && a.client === b.client && a.clock === b.clock;
|
|
2581
2161
|
var createID = (client, clock) => new ID(client, clock);
|
|
2582
2162
|
var writeID = (encoder, id2) => {
|
|
2583
|
-
writeVarUint(encoder, id2.client);
|
|
2584
|
-
writeVarUint(encoder, id2.clock);
|
|
2163
|
+
encoding.writeVarUint(encoder, id2.client);
|
|
2164
|
+
encoding.writeVarUint(encoder, id2.clock);
|
|
2585
2165
|
};
|
|
2586
|
-
var readID = (decoder) => createID(readVarUint(decoder), readVarUint(decoder));
|
|
2166
|
+
var readID = (decoder) => createID(decoding.readVarUint(decoder), decoding.readVarUint(decoder));
|
|
2587
2167
|
var findRootTypeKey = (type) => {
|
|
2588
2168
|
for (const [key, value] of type.doc.share.entries()) {
|
|
2589
2169
|
if (value === type) {
|
|
@@ -2627,12 +2207,12 @@ class PermanentUserData {
|
|
|
2627
2207
|
event.changes.added.forEach((item) => {
|
|
2628
2208
|
item.content.getContent().forEach((encodedDs) => {
|
|
2629
2209
|
if (encodedDs instanceof Uint8Array) {
|
|
2630
|
-
this.dss.set(userDescription, mergeDeleteSets([this.dss.get(userDescription) || createDeleteSet(), readDeleteSet(new DSDecoderV1(createDecoder(encodedDs)))]));
|
|
2210
|
+
this.dss.set(userDescription, mergeDeleteSets([this.dss.get(userDescription) || createDeleteSet(), readDeleteSet(new DSDecoderV1(decoding.createDecoder(encodedDs)))]));
|
|
2631
2211
|
}
|
|
2632
2212
|
});
|
|
2633
2213
|
});
|
|
2634
2214
|
});
|
|
2635
|
-
this.dss.set(userDescription, mergeDeleteSets(ds.map((encodedDs) => readDeleteSet(new DSDecoderV1(createDecoder(encodedDs))))));
|
|
2215
|
+
this.dss.set(userDescription, mergeDeleteSets(ds.map((encodedDs) => readDeleteSet(new DSDecoderV1(decoding.createDecoder(encodedDs))))));
|
|
2636
2216
|
ids.observe((event) => event.changes.added.forEach((item) => item.content.getContent().forEach(addClientId)));
|
|
2637
2217
|
ids.forEach(addClientId);
|
|
2638
2218
|
};
|
|
@@ -2764,44 +2344,44 @@ var createRelativePositionFromTypeIndex = (type, index, assoc = 0) => {
|
|
|
2764
2344
|
var writeRelativePosition = (encoder, rpos) => {
|
|
2765
2345
|
const { type, tname, item, assoc } = rpos;
|
|
2766
2346
|
if (item !== null) {
|
|
2767
|
-
writeVarUint(encoder, 0);
|
|
2347
|
+
encoding.writeVarUint(encoder, 0);
|
|
2768
2348
|
writeID(encoder, item);
|
|
2769
2349
|
} else if (tname !== null) {
|
|
2770
|
-
writeUint8(encoder, 1);
|
|
2771
|
-
writeVarString(encoder, tname);
|
|
2350
|
+
encoding.writeUint8(encoder, 1);
|
|
2351
|
+
encoding.writeVarString(encoder, tname);
|
|
2772
2352
|
} else if (type !== null) {
|
|
2773
|
-
writeUint8(encoder, 2);
|
|
2353
|
+
encoding.writeUint8(encoder, 2);
|
|
2774
2354
|
writeID(encoder, type);
|
|
2775
2355
|
} else {
|
|
2776
2356
|
throw unexpectedCase();
|
|
2777
2357
|
}
|
|
2778
|
-
writeVarInt(encoder, assoc);
|
|
2358
|
+
encoding.writeVarInt(encoder, assoc);
|
|
2779
2359
|
return encoder;
|
|
2780
2360
|
};
|
|
2781
2361
|
var encodeRelativePosition = (rpos) => {
|
|
2782
|
-
const encoder = createEncoder();
|
|
2362
|
+
const encoder = encoding.createEncoder();
|
|
2783
2363
|
writeRelativePosition(encoder, rpos);
|
|
2784
|
-
return toUint8Array(encoder);
|
|
2364
|
+
return encoding.toUint8Array(encoder);
|
|
2785
2365
|
};
|
|
2786
2366
|
var readRelativePosition = (decoder) => {
|
|
2787
2367
|
let type = null;
|
|
2788
2368
|
let tname = null;
|
|
2789
2369
|
let itemID = null;
|
|
2790
|
-
switch (readVarUint(decoder)) {
|
|
2370
|
+
switch (decoding.readVarUint(decoder)) {
|
|
2791
2371
|
case 0:
|
|
2792
2372
|
itemID = readID(decoder);
|
|
2793
2373
|
break;
|
|
2794
2374
|
case 1:
|
|
2795
|
-
tname = readVarString(decoder);
|
|
2375
|
+
tname = decoding.readVarString(decoder);
|
|
2796
2376
|
break;
|
|
2797
2377
|
case 2: {
|
|
2798
2378
|
type = readID(decoder);
|
|
2799
2379
|
}
|
|
2800
2380
|
}
|
|
2801
|
-
const assoc = hasContent(decoder) ? readVarInt(decoder) : 0;
|
|
2381
|
+
const assoc = decoding.hasContent(decoder) ? decoding.readVarInt(decoder) : 0;
|
|
2802
2382
|
return new RelativePosition(type, tname, itemID, assoc);
|
|
2803
2383
|
};
|
|
2804
|
-
var decodeRelativePosition = (uint8Array) => readRelativePosition(createDecoder(uint8Array));
|
|
2384
|
+
var decodeRelativePosition = (uint8Array) => readRelativePosition(decoding.createDecoder(uint8Array));
|
|
2805
2385
|
var getItemWithOffset = (store, id2) => {
|
|
2806
2386
|
const item = getItem(store, id2);
|
|
2807
2387
|
const diff = id2.clock - item.id.clock;
|
|
@@ -2904,10 +2484,10 @@ var encodeSnapshotV2 = (snapshot, encoder = new DSEncoderV2) => {
|
|
|
2904
2484
|
return encoder.toUint8Array();
|
|
2905
2485
|
};
|
|
2906
2486
|
var encodeSnapshot = (snapshot) => encodeSnapshotV2(snapshot, new DSEncoderV1);
|
|
2907
|
-
var decodeSnapshotV2 = (buf, decoder = new DSDecoderV2(createDecoder(buf))) => {
|
|
2487
|
+
var decodeSnapshotV2 = (buf, decoder = new DSDecoderV2(decoding.createDecoder(buf))) => {
|
|
2908
2488
|
return new Snapshot(readDeleteSet(decoder), readStateVector(decoder));
|
|
2909
2489
|
};
|
|
2910
|
-
var decodeSnapshot = (buf) => decodeSnapshotV2(buf, new DSDecoderV1(createDecoder(buf)));
|
|
2490
|
+
var decodeSnapshot = (buf) => decodeSnapshotV2(buf, new DSDecoderV1(decoding.createDecoder(buf)));
|
|
2911
2491
|
var createSnapshot = (ds, sm) => new Snapshot(ds, sm);
|
|
2912
2492
|
var emptySnapshot = createSnapshot(createDeleteSet(), new Map);
|
|
2913
2493
|
var snapshot = (doc2) => createSnapshot(createDeleteSetFromStructStore(doc2.store), getStateVector(doc2.store));
|
|
@@ -2938,7 +2518,7 @@ var createDocFromSnapshot = (originDoc, snapshot2, newDoc = new Doc) => {
|
|
|
2938
2518
|
size2++;
|
|
2939
2519
|
}
|
|
2940
2520
|
});
|
|
2941
|
-
writeVarUint(encoder.restEncoder, size2);
|
|
2521
|
+
encoding.writeVarUint(encoder.restEncoder, size2);
|
|
2942
2522
|
for (const [client, clock] of sv) {
|
|
2943
2523
|
if (clock === 0) {
|
|
2944
2524
|
continue;
|
|
@@ -2948,9 +2528,9 @@ var createDocFromSnapshot = (originDoc, snapshot2, newDoc = new Doc) => {
|
|
|
2948
2528
|
}
|
|
2949
2529
|
const structs = originDoc.store.clients.get(client) || [];
|
|
2950
2530
|
const lastStructIndex = findIndexSS(structs, clock - 1);
|
|
2951
|
-
writeVarUint(encoder.restEncoder, lastStructIndex + 1);
|
|
2531
|
+
encoding.writeVarUint(encoder.restEncoder, lastStructIndex + 1);
|
|
2952
2532
|
encoder.writeClient(client);
|
|
2953
|
-
writeVarUint(encoder.restEncoder, 0);
|
|
2533
|
+
encoding.writeVarUint(encoder.restEncoder, 0);
|
|
2954
2534
|
for (let i = 0;i <= lastStructIndex; i++) {
|
|
2955
2535
|
structs[i].write(encoder, 0);
|
|
2956
2536
|
}
|
|
@@ -2961,7 +2541,7 @@ var createDocFromSnapshot = (originDoc, snapshot2, newDoc = new Doc) => {
|
|
|
2961
2541
|
return newDoc;
|
|
2962
2542
|
};
|
|
2963
2543
|
var snapshotContainsUpdateV2 = (snapshot2, update, YDecoder = UpdateDecoderV2) => {
|
|
2964
|
-
const updateDecoder = new YDecoder(createDecoder(update));
|
|
2544
|
+
const updateDecoder = new YDecoder(decoding.createDecoder(update));
|
|
2965
2545
|
const lazyDecoder = new LazyStructReader(updateDecoder, false);
|
|
2966
2546
|
for (let curr = lazyDecoder.curr;curr !== null; curr = lazyDecoder.next()) {
|
|
2967
2547
|
if ((snapshot2.sv.get(curr.id.client) || 0) < curr.id.clock + curr.length) {
|
|
@@ -3519,15 +3099,15 @@ class UndoManager extends ObservableV2 {
|
|
|
3519
3099
|
}
|
|
3520
3100
|
}
|
|
3521
3101
|
function* lazyStructReaderGenerator(decoder) {
|
|
3522
|
-
const numOfStateUpdates = readVarUint(decoder.restDecoder);
|
|
3102
|
+
const numOfStateUpdates = decoding.readVarUint(decoder.restDecoder);
|
|
3523
3103
|
for (let i = 0;i < numOfStateUpdates; i++) {
|
|
3524
|
-
const numberOfStructs = readVarUint(decoder.restDecoder);
|
|
3104
|
+
const numberOfStructs = decoding.readVarUint(decoder.restDecoder);
|
|
3525
3105
|
const client = decoder.readClient();
|
|
3526
|
-
let clock = readVarUint(decoder.restDecoder);
|
|
3106
|
+
let clock = decoding.readVarUint(decoder.restDecoder);
|
|
3527
3107
|
for (let i2 = 0;i2 < numberOfStructs; i2++) {
|
|
3528
3108
|
const info = decoder.readInfo();
|
|
3529
3109
|
if (info === 10) {
|
|
3530
|
-
const len = readVarUint(decoder.restDecoder);
|
|
3110
|
+
const len = decoding.readVarUint(decoder.restDecoder);
|
|
3531
3111
|
yield new Skip(createID(client, clock), len);
|
|
3532
3112
|
clock += len;
|
|
3533
3113
|
} else if ((BITS5 & info) !== 0) {
|
|
@@ -3562,7 +3142,7 @@ class LazyStructReader {
|
|
|
3562
3142
|
var logUpdate = (update) => logUpdateV2(update, UpdateDecoderV1);
|
|
3563
3143
|
var logUpdateV2 = (update, YDecoder = UpdateDecoderV2) => {
|
|
3564
3144
|
const structs = [];
|
|
3565
|
-
const updateDecoder = new YDecoder(createDecoder(update));
|
|
3145
|
+
const updateDecoder = new YDecoder(decoding.createDecoder(update));
|
|
3566
3146
|
const lazyDecoder = new LazyStructReader(updateDecoder, false);
|
|
3567
3147
|
for (let curr = lazyDecoder.curr;curr !== null; curr = lazyDecoder.next()) {
|
|
3568
3148
|
structs.push(curr);
|
|
@@ -3574,7 +3154,7 @@ var logUpdateV2 = (update, YDecoder = UpdateDecoderV2) => {
|
|
|
3574
3154
|
var decodeUpdate = (update) => decodeUpdateV2(update, UpdateDecoderV1);
|
|
3575
3155
|
var decodeUpdateV2 = (update, YDecoder = UpdateDecoderV2) => {
|
|
3576
3156
|
const structs = [];
|
|
3577
|
-
const updateDecoder = new YDecoder(createDecoder(update));
|
|
3157
|
+
const updateDecoder = new YDecoder(decoding.createDecoder(update));
|
|
3578
3158
|
const lazyDecoder = new LazyStructReader(updateDecoder, false);
|
|
3579
3159
|
for (let curr = lazyDecoder.curr;curr !== null; curr = lazyDecoder.next()) {
|
|
3580
3160
|
structs.push(curr);
|
|
@@ -3597,7 +3177,7 @@ class LazyStructWriter {
|
|
|
3597
3177
|
var mergeUpdates = (updates) => mergeUpdatesV2(updates, UpdateDecoderV1, UpdateEncoderV1);
|
|
3598
3178
|
var encodeStateVectorFromUpdateV2 = (update, YEncoder = DSEncoderV2, YDecoder = UpdateDecoderV2) => {
|
|
3599
3179
|
const encoder = new YEncoder;
|
|
3600
|
-
const updateDecoder = new LazyStructReader(new YDecoder(createDecoder(update)), false);
|
|
3180
|
+
const updateDecoder = new LazyStructReader(new YDecoder(decoding.createDecoder(update)), false);
|
|
3601
3181
|
let curr = updateDecoder.curr;
|
|
3602
3182
|
if (curr !== null) {
|
|
3603
3183
|
let size2 = 0;
|
|
@@ -3608,8 +3188,8 @@ var encodeStateVectorFromUpdateV2 = (update, YEncoder = DSEncoderV2, YDecoder =
|
|
|
3608
3188
|
if (currClient !== curr.id.client) {
|
|
3609
3189
|
if (currClock !== 0) {
|
|
3610
3190
|
size2++;
|
|
3611
|
-
writeVarUint(encoder.restEncoder, currClient);
|
|
3612
|
-
writeVarUint(encoder.restEncoder, currClock);
|
|
3191
|
+
encoding.writeVarUint(encoder.restEncoder, currClient);
|
|
3192
|
+
encoding.writeVarUint(encoder.restEncoder, currClock);
|
|
3613
3193
|
}
|
|
3614
3194
|
currClient = curr.id.client;
|
|
3615
3195
|
currClock = 0;
|
|
@@ -3624,16 +3204,16 @@ var encodeStateVectorFromUpdateV2 = (update, YEncoder = DSEncoderV2, YDecoder =
|
|
|
3624
3204
|
}
|
|
3625
3205
|
if (currClock !== 0) {
|
|
3626
3206
|
size2++;
|
|
3627
|
-
writeVarUint(encoder.restEncoder, currClient);
|
|
3628
|
-
writeVarUint(encoder.restEncoder, currClock);
|
|
3207
|
+
encoding.writeVarUint(encoder.restEncoder, currClient);
|
|
3208
|
+
encoding.writeVarUint(encoder.restEncoder, currClock);
|
|
3629
3209
|
}
|
|
3630
|
-
const enc = createEncoder();
|
|
3631
|
-
writeVarUint(enc, size2);
|
|
3632
|
-
writeBinaryEncoder(enc, encoder.restEncoder);
|
|
3210
|
+
const enc = encoding.createEncoder();
|
|
3211
|
+
encoding.writeVarUint(enc, size2);
|
|
3212
|
+
encoding.writeBinaryEncoder(enc, encoder.restEncoder);
|
|
3633
3213
|
encoder.restEncoder = enc;
|
|
3634
3214
|
return encoder.toUint8Array();
|
|
3635
3215
|
} else {
|
|
3636
|
-
writeVarUint(encoder.restEncoder, 0);
|
|
3216
|
+
encoding.writeVarUint(encoder.restEncoder, 0);
|
|
3637
3217
|
return encoder.toUint8Array();
|
|
3638
3218
|
}
|
|
3639
3219
|
};
|
|
@@ -3641,7 +3221,7 @@ var encodeStateVectorFromUpdate = (update) => encodeStateVectorFromUpdateV2(upda
|
|
|
3641
3221
|
var parseUpdateMetaV2 = (update, YDecoder = UpdateDecoderV2) => {
|
|
3642
3222
|
const from3 = new Map;
|
|
3643
3223
|
const to = new Map;
|
|
3644
|
-
const updateDecoder = new LazyStructReader(new YDecoder(createDecoder(update)), false);
|
|
3224
|
+
const updateDecoder = new LazyStructReader(new YDecoder(decoding.createDecoder(update)), false);
|
|
3645
3225
|
let curr = updateDecoder.curr;
|
|
3646
3226
|
if (curr !== null) {
|
|
3647
3227
|
let currClient = curr.id.client;
|
|
@@ -3677,7 +3257,7 @@ var mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = UpdateEnco
|
|
|
3677
3257
|
if (updates.length === 1) {
|
|
3678
3258
|
return updates[0];
|
|
3679
3259
|
}
|
|
3680
|
-
const updateDecoders = updates.map((update) => new YDecoder(createDecoder(update)));
|
|
3260
|
+
const updateDecoders = updates.map((update) => new YDecoder(decoding.createDecoder(update)));
|
|
3681
3261
|
let lazyStructDecoders = updateDecoders.map((decoder) => new LazyStructReader(decoder, true));
|
|
3682
3262
|
let currWrite = null;
|
|
3683
3263
|
const updateEncoder = new YEncoder;
|
|
@@ -3764,7 +3344,7 @@ var diffUpdateV2 = (update, sv, YDecoder = UpdateDecoderV2, YEncoder = UpdateEnc
|
|
|
3764
3344
|
const state = decodeStateVector(sv);
|
|
3765
3345
|
const encoder = new YEncoder;
|
|
3766
3346
|
const lazyStructWriter = new LazyStructWriter(encoder);
|
|
3767
|
-
const decoder = new YDecoder(createDecoder(update));
|
|
3347
|
+
const decoder = new YDecoder(decoding.createDecoder(update));
|
|
3768
3348
|
const reader = new LazyStructReader(decoder, false);
|
|
3769
3349
|
while (reader.curr) {
|
|
3770
3350
|
const curr = reader.curr;
|
|
@@ -3795,8 +3375,8 @@ var diffUpdateV2 = (update, sv, YDecoder = UpdateDecoderV2, YEncoder = UpdateEnc
|
|
|
3795
3375
|
var diffUpdate = (update, sv) => diffUpdateV2(update, sv, UpdateDecoderV1, UpdateEncoderV1);
|
|
3796
3376
|
var flushLazyStructWriter = (lazyWriter) => {
|
|
3797
3377
|
if (lazyWriter.written > 0) {
|
|
3798
|
-
lazyWriter.clientStructs.push({ written: lazyWriter.written, restEncoder: toUint8Array(lazyWriter.encoder.restEncoder) });
|
|
3799
|
-
lazyWriter.encoder.restEncoder = createEncoder();
|
|
3378
|
+
lazyWriter.clientStructs.push({ written: lazyWriter.written, restEncoder: encoding.toUint8Array(lazyWriter.encoder.restEncoder) });
|
|
3379
|
+
lazyWriter.encoder.restEncoder = encoding.createEncoder();
|
|
3800
3380
|
lazyWriter.written = 0;
|
|
3801
3381
|
}
|
|
3802
3382
|
};
|
|
@@ -3807,7 +3387,7 @@ var writeStructToLazyStructWriter = (lazyWriter, struct, offset) => {
|
|
|
3807
3387
|
if (lazyWriter.written === 0) {
|
|
3808
3388
|
lazyWriter.currClient = struct.id.client;
|
|
3809
3389
|
lazyWriter.encoder.writeClient(struct.id.client);
|
|
3810
|
-
writeVarUint(lazyWriter.encoder.restEncoder, struct.id.clock + offset);
|
|
3390
|
+
encoding.writeVarUint(lazyWriter.encoder.restEncoder, struct.id.clock + offset);
|
|
3811
3391
|
}
|
|
3812
3392
|
struct.write(lazyWriter.encoder, offset);
|
|
3813
3393
|
lazyWriter.written++;
|
|
@@ -3815,15 +3395,15 @@ var writeStructToLazyStructWriter = (lazyWriter, struct, offset) => {
|
|
|
3815
3395
|
var finishLazyStructWriting = (lazyWriter) => {
|
|
3816
3396
|
flushLazyStructWriter(lazyWriter);
|
|
3817
3397
|
const restEncoder = lazyWriter.encoder.restEncoder;
|
|
3818
|
-
writeVarUint(restEncoder, lazyWriter.clientStructs.length);
|
|
3398
|
+
encoding.writeVarUint(restEncoder, lazyWriter.clientStructs.length);
|
|
3819
3399
|
for (let i = 0;i < lazyWriter.clientStructs.length; i++) {
|
|
3820
3400
|
const partStructs = lazyWriter.clientStructs[i];
|
|
3821
|
-
writeVarUint(restEncoder, partStructs.written);
|
|
3822
|
-
writeUint8Array(restEncoder, partStructs.restEncoder);
|
|
3401
|
+
encoding.writeVarUint(restEncoder, partStructs.written);
|
|
3402
|
+
encoding.writeUint8Array(restEncoder, partStructs.restEncoder);
|
|
3823
3403
|
}
|
|
3824
3404
|
};
|
|
3825
3405
|
var convertUpdateFormat = (update, blockTransformer, YDecoder, YEncoder) => {
|
|
3826
|
-
const updateDecoder = new YDecoder(createDecoder(update));
|
|
3406
|
+
const updateDecoder = new YDecoder(decoding.createDecoder(update));
|
|
3827
3407
|
const lazyDecoder = new LazyStructReader(updateDecoder, false);
|
|
3828
3408
|
const updateEncoder = new YEncoder;
|
|
3829
3409
|
const lazyWriter = new LazyStructWriter(updateEncoder);
|
|
@@ -3945,7 +3525,7 @@ class YEvent {
|
|
|
3945
3525
|
get keys() {
|
|
3946
3526
|
if (this._keys === null) {
|
|
3947
3527
|
if (this.transaction.doc._transactionCleanups.length === 0) {
|
|
3948
|
-
throw
|
|
3528
|
+
throw create4(errorComputeChanges);
|
|
3949
3529
|
}
|
|
3950
3530
|
const keys2 = new Map;
|
|
3951
3531
|
const target = this.target;
|
|
@@ -4001,7 +3581,7 @@ class YEvent {
|
|
|
4001
3581
|
let changes = this._changes;
|
|
4002
3582
|
if (changes === null) {
|
|
4003
3583
|
if (this.transaction.doc._transactionCleanups.length === 0) {
|
|
4004
|
-
throw
|
|
3584
|
+
throw create4(errorComputeChanges);
|
|
4005
3585
|
}
|
|
4006
3586
|
const target = this.target;
|
|
4007
3587
|
const added = create2();
|
|
@@ -4430,7 +4010,7 @@ var typeListInsertGenericsAfter = (transaction, parent, referenceItem, content)
|
|
|
4430
4010
|
});
|
|
4431
4011
|
packJsonContent();
|
|
4432
4012
|
};
|
|
4433
|
-
var lengthExceeded = () =>
|
|
4013
|
+
var lengthExceeded = () => create4("Length exceeded!");
|
|
4434
4014
|
var typeListInsertGenerics = (transaction, parent, index, content) => {
|
|
4435
4015
|
if (index > parent._length) {
|
|
4436
4016
|
throw lengthExceeded();
|
|
@@ -4478,12 +4058,12 @@ var typeListPushGenerics = (transaction, parent, content) => {
|
|
|
4478
4058
|
}
|
|
4479
4059
|
return typeListInsertGenericsAfter(transaction, parent, n, content);
|
|
4480
4060
|
};
|
|
4481
|
-
var typeListDelete = (transaction, parent, index,
|
|
4482
|
-
if (
|
|
4061
|
+
var typeListDelete = (transaction, parent, index, length) => {
|
|
4062
|
+
if (length === 0) {
|
|
4483
4063
|
return;
|
|
4484
4064
|
}
|
|
4485
4065
|
const startIndex = index;
|
|
4486
|
-
const startLength =
|
|
4066
|
+
const startLength = length;
|
|
4487
4067
|
const marker = findMarker(parent, index);
|
|
4488
4068
|
let n = parent._start;
|
|
4489
4069
|
if (marker !== null) {
|
|
@@ -4498,21 +4078,21 @@ var typeListDelete = (transaction, parent, index, length2) => {
|
|
|
4498
4078
|
index -= n.length;
|
|
4499
4079
|
}
|
|
4500
4080
|
}
|
|
4501
|
-
while (
|
|
4081
|
+
while (length > 0 && n !== null) {
|
|
4502
4082
|
if (!n.deleted) {
|
|
4503
|
-
if (
|
|
4504
|
-
getItemCleanStart(transaction, createID(n.id.client, n.id.clock +
|
|
4083
|
+
if (length < n.length) {
|
|
4084
|
+
getItemCleanStart(transaction, createID(n.id.client, n.id.clock + length));
|
|
4505
4085
|
}
|
|
4506
4086
|
n.delete(transaction);
|
|
4507
|
-
|
|
4087
|
+
length -= n.length;
|
|
4508
4088
|
}
|
|
4509
4089
|
n = n.right;
|
|
4510
4090
|
}
|
|
4511
|
-
if (
|
|
4091
|
+
if (length > 0) {
|
|
4512
4092
|
throw lengthExceeded();
|
|
4513
4093
|
}
|
|
4514
4094
|
if (parent._searchMarker) {
|
|
4515
|
-
updateMarkerChanges(parent._searchMarker, startIndex, -startLength +
|
|
4095
|
+
updateMarkerChanges(parent._searchMarker, startIndex, -startLength + length);
|
|
4516
4096
|
}
|
|
4517
4097
|
};
|
|
4518
4098
|
var typeMapDelete = (transaction, parent, key) => {
|
|
@@ -4656,13 +4236,13 @@ class YArray extends AbstractType {
|
|
|
4656
4236
|
unshift(content) {
|
|
4657
4237
|
this.insert(0, content);
|
|
4658
4238
|
}
|
|
4659
|
-
delete(index,
|
|
4239
|
+
delete(index, length = 1) {
|
|
4660
4240
|
if (this.doc !== null) {
|
|
4661
4241
|
transact(this.doc, (transaction) => {
|
|
4662
|
-
typeListDelete(transaction, this, index,
|
|
4242
|
+
typeListDelete(transaction, this, index, length);
|
|
4663
4243
|
});
|
|
4664
4244
|
} else {
|
|
4665
|
-
this._prelimContent.splice(index,
|
|
4245
|
+
this._prelimContent.splice(index, length);
|
|
4666
4246
|
}
|
|
4667
4247
|
}
|
|
4668
4248
|
get(index) {
|
|
@@ -4944,13 +4524,13 @@ var insertText = (transaction, parent, currPos, text2, attributes) => {
|
|
|
4944
4524
|
currPos.forward();
|
|
4945
4525
|
insertNegatedAttributes(transaction, parent, currPos, negatedAttributes);
|
|
4946
4526
|
};
|
|
4947
|
-
var formatText = (transaction, parent, currPos,
|
|
4527
|
+
var formatText = (transaction, parent, currPos, length, attributes) => {
|
|
4948
4528
|
const doc2 = transaction.doc;
|
|
4949
4529
|
const ownClientId = doc2.clientID;
|
|
4950
4530
|
minimizeAttributeChanges(currPos, attributes);
|
|
4951
4531
|
const negatedAttributes = insertAttributes(transaction, parent, currPos, attributes);
|
|
4952
4532
|
iterationLoop:
|
|
4953
|
-
while (currPos.right !== null && (
|
|
4533
|
+
while (currPos.right !== null && (length > 0 || negatedAttributes.size > 0 && (currPos.right.deleted || currPos.right.content.constructor === ContentFormat))) {
|
|
4954
4534
|
if (!currPos.right.deleted) {
|
|
4955
4535
|
switch (currPos.right.content.constructor) {
|
|
4956
4536
|
case ContentFormat: {
|
|
@@ -4960,7 +4540,7 @@ var formatText = (transaction, parent, currPos, length2, attributes) => {
|
|
|
4960
4540
|
if (equalAttrs(attr, value)) {
|
|
4961
4541
|
negatedAttributes.delete(key);
|
|
4962
4542
|
} else {
|
|
4963
|
-
if (
|
|
4543
|
+
if (length === 0) {
|
|
4964
4544
|
break iterationLoop;
|
|
4965
4545
|
}
|
|
4966
4546
|
negatedAttributes.set(key, value);
|
|
@@ -4972,18 +4552,18 @@ var formatText = (transaction, parent, currPos, length2, attributes) => {
|
|
|
4972
4552
|
break;
|
|
4973
4553
|
}
|
|
4974
4554
|
default:
|
|
4975
|
-
if (
|
|
4976
|
-
getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock +
|
|
4555
|
+
if (length < currPos.right.length) {
|
|
4556
|
+
getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock + length));
|
|
4977
4557
|
}
|
|
4978
|
-
|
|
4558
|
+
length -= currPos.right.length;
|
|
4979
4559
|
break;
|
|
4980
4560
|
}
|
|
4981
4561
|
}
|
|
4982
4562
|
currPos.forward();
|
|
4983
4563
|
}
|
|
4984
|
-
if (
|
|
4564
|
+
if (length > 0) {
|
|
4985
4565
|
let newlines = "";
|
|
4986
|
-
for (;
|
|
4566
|
+
for (;length > 0; length--) {
|
|
4987
4567
|
newlines += `
|
|
4988
4568
|
`;
|
|
4989
4569
|
}
|
|
@@ -5110,20 +4690,20 @@ var cleanupYTextAfterTransaction = (transaction) => {
|
|
|
5110
4690
|
}
|
|
5111
4691
|
});
|
|
5112
4692
|
};
|
|
5113
|
-
var deleteText = (transaction, currPos,
|
|
5114
|
-
const startLength =
|
|
4693
|
+
var deleteText = (transaction, currPos, length) => {
|
|
4694
|
+
const startLength = length;
|
|
5115
4695
|
const startAttrs = copy(currPos.currentAttributes);
|
|
5116
4696
|
const start = currPos.right;
|
|
5117
|
-
while (
|
|
4697
|
+
while (length > 0 && currPos.right !== null) {
|
|
5118
4698
|
if (currPos.right.deleted === false) {
|
|
5119
4699
|
switch (currPos.right.content.constructor) {
|
|
5120
4700
|
case ContentType:
|
|
5121
4701
|
case ContentEmbed:
|
|
5122
4702
|
case ContentString:
|
|
5123
|
-
if (
|
|
5124
|
-
getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock +
|
|
4703
|
+
if (length < currPos.right.length) {
|
|
4704
|
+
getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock + length));
|
|
5125
4705
|
}
|
|
5126
|
-
|
|
4706
|
+
length -= currPos.right.length;
|
|
5127
4707
|
currPos.right.delete(transaction);
|
|
5128
4708
|
break;
|
|
5129
4709
|
}
|
|
@@ -5135,7 +4715,7 @@ var deleteText = (transaction, currPos, length2) => {
|
|
|
5135
4715
|
}
|
|
5136
4716
|
const parent = (currPos.left || currPos.right).parent;
|
|
5137
4717
|
if (parent._searchMarker) {
|
|
5138
|
-
updateMarkerChanges(parent._searchMarker, currPos.index, -startLength +
|
|
4718
|
+
updateMarkerChanges(parent._searchMarker, currPos.index, -startLength + length);
|
|
5139
4719
|
}
|
|
5140
4720
|
return currPos;
|
|
5141
4721
|
};
|
|
@@ -5531,21 +5111,21 @@ class YText extends AbstractType {
|
|
|
5531
5111
|
this._pending.push(() => this.insertEmbed(index, embed, attributes || {}));
|
|
5532
5112
|
}
|
|
5533
5113
|
}
|
|
5534
|
-
delete(index,
|
|
5535
|
-
if (
|
|
5114
|
+
delete(index, length) {
|
|
5115
|
+
if (length === 0) {
|
|
5536
5116
|
return;
|
|
5537
5117
|
}
|
|
5538
5118
|
const y = this.doc;
|
|
5539
5119
|
if (y !== null) {
|
|
5540
5120
|
transact(y, (transaction) => {
|
|
5541
|
-
deleteText(transaction, findPosition(transaction, this, index, true),
|
|
5121
|
+
deleteText(transaction, findPosition(transaction, this, index, true), length);
|
|
5542
5122
|
});
|
|
5543
5123
|
} else {
|
|
5544
|
-
this._pending.push(() => this.delete(index,
|
|
5124
|
+
this._pending.push(() => this.delete(index, length));
|
|
5545
5125
|
}
|
|
5546
5126
|
}
|
|
5547
|
-
format(index,
|
|
5548
|
-
if (
|
|
5127
|
+
format(index, length, attributes) {
|
|
5128
|
+
if (length === 0) {
|
|
5549
5129
|
return;
|
|
5550
5130
|
}
|
|
5551
5131
|
const y = this.doc;
|
|
@@ -5555,10 +5135,10 @@ class YText extends AbstractType {
|
|
|
5555
5135
|
if (pos.right === null) {
|
|
5556
5136
|
return;
|
|
5557
5137
|
}
|
|
5558
|
-
formatText(transaction, this, pos,
|
|
5138
|
+
formatText(transaction, this, pos, length, attributes);
|
|
5559
5139
|
});
|
|
5560
5140
|
} else {
|
|
5561
|
-
this._pending.push(() => this.format(index,
|
|
5141
|
+
this._pending.push(() => this.format(index, length, attributes));
|
|
5562
5142
|
}
|
|
5563
5143
|
}
|
|
5564
5144
|
removeAttribute(attributeName) {
|
|
@@ -5715,18 +5295,18 @@ class YXmlFragment extends AbstractType {
|
|
|
5715
5295
|
const pc = this._prelimContent;
|
|
5716
5296
|
const index = ref === null ? 0 : pc.findIndex((el) => el === ref) + 1;
|
|
5717
5297
|
if (index === 0 && ref !== null) {
|
|
5718
|
-
throw
|
|
5298
|
+
throw create4("Reference item not found");
|
|
5719
5299
|
}
|
|
5720
5300
|
pc.splice(index, 0, ...content);
|
|
5721
5301
|
}
|
|
5722
5302
|
}
|
|
5723
|
-
delete(index,
|
|
5303
|
+
delete(index, length = 1) {
|
|
5724
5304
|
if (this.doc !== null) {
|
|
5725
5305
|
transact(this.doc, (transaction) => {
|
|
5726
|
-
typeListDelete(transaction, this, index,
|
|
5306
|
+
typeListDelete(transaction, this, index, length);
|
|
5727
5307
|
});
|
|
5728
5308
|
} else {
|
|
5729
|
-
this._prelimContent.splice(index,
|
|
5309
|
+
this._prelimContent.splice(index, length);
|
|
5730
5310
|
}
|
|
5731
5311
|
}
|
|
5732
5312
|
toArray() {
|
|
@@ -5968,9 +5548,9 @@ class YXmlText extends YText {
|
|
|
5968
5548
|
var readYXmlText = (decoder) => new YXmlText;
|
|
5969
5549
|
|
|
5970
5550
|
class AbstractStruct {
|
|
5971
|
-
constructor(id2,
|
|
5551
|
+
constructor(id2, length) {
|
|
5972
5552
|
this.id = id2;
|
|
5973
|
-
this.length =
|
|
5553
|
+
this.length = length;
|
|
5974
5554
|
}
|
|
5975
5555
|
get deleted() {
|
|
5976
5556
|
throw methodUnimplemented();
|
|
@@ -6879,7 +6459,7 @@ class Skip extends AbstractStruct {
|
|
|
6879
6459
|
}
|
|
6880
6460
|
write(encoder, offset) {
|
|
6881
6461
|
encoder.writeInfo(structSkipRefNumber);
|
|
6882
|
-
writeVarUint(encoder.restEncoder, this.length - offset);
|
|
6462
|
+
encoding.writeVarUint(encoder.restEncoder, this.length - offset);
|
|
6883
6463
|
}
|
|
6884
6464
|
getMissing(transaction, store) {
|
|
6885
6465
|
return null;
|
|
@@ -6892,7 +6472,7 @@ if (glo[importIdentifier] === true) {
|
|
|
6892
6472
|
}
|
|
6893
6473
|
glo[importIdentifier] = true;
|
|
6894
6474
|
|
|
6895
|
-
// synth:/
|
|
6475
|
+
// synth:/Users/iagh/git/claude-design/plugins/design/dev-server/.runtime-bundle-yjs-entry.tsx
|
|
6896
6476
|
var {
|
|
6897
6477
|
AbsolutePosition: AbsolutePosition2,
|
|
6898
6478
|
AbstractConnector: AbstractConnector2,
|