@1agh/maude 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/doctor.mjs +87 -76
- package/cli/commands/hub.mjs +17 -3
- package/package.json +8 -8
- package/plugins/design/dev-server/dist/client.bundle.js +3 -3
- package/plugins/design/dev-server/dist/runtime/lib0_decoding.js +624 -0
- package/plugins/design/dev-server/dist/runtime/lib0_encoding.js +608 -0
- package/plugins/design/dev-server/dist/runtime/y-protocols_awareness.js +35 -242
- package/plugins/design/dev-server/dist/runtime/y-protocols_sync.js +11 -164
- package/plugins/design/dev-server/dist/runtime/yjs.js +298 -714
- package/plugins/design/dev-server/runtime-bundle.ts +11 -0
- package/plugins/design/templates/_shell.html +3 -1
|
@@ -227,7 +227,10 @@ var floor = Math.floor;
|
|
|
227
227
|
var abs = Math.abs;
|
|
228
228
|
var min = (a, b) => a < b ? a : b;
|
|
229
229
|
var max = (a, b) => a > b ? a : b;
|
|
230
|
-
|
|
230
|
+
|
|
231
|
+
// ../../../node_modules/.pnpm/yjs@13.6.30/node_modules/yjs/dist/yjs.mjs
|
|
232
|
+
import * as encoding from "lib0/encoding";
|
|
233
|
+
import * as decoding from "lib0/decoding";
|
|
231
234
|
|
|
232
235
|
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/binary.js
|
|
233
236
|
var BIT1 = 1;
|
|
@@ -253,7 +256,6 @@ var BIT30 = 1 << 29;
|
|
|
253
256
|
var BIT31 = 1 << 30;
|
|
254
257
|
var BIT32 = 1 << 31;
|
|
255
258
|
var BITS5 = 31;
|
|
256
|
-
var BITS6 = 63;
|
|
257
259
|
var BITS7 = 127;
|
|
258
260
|
var BITS17 = BIT18 - 1;
|
|
259
261
|
var BITS18 = BIT19 - 1;
|
|
@@ -269,13 +271,22 @@ var BITS27 = BIT28 - 1;
|
|
|
269
271
|
var BITS28 = BIT29 - 1;
|
|
270
272
|
var BITS29 = BIT30 - 1;
|
|
271
273
|
var BITS30 = BIT31 - 1;
|
|
272
|
-
var BITS31 = 2147483647;
|
|
273
274
|
|
|
274
|
-
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/
|
|
275
|
-
var
|
|
276
|
-
var
|
|
277
|
-
|
|
278
|
-
|
|
275
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/webcrypto.js
|
|
276
|
+
var subtle = crypto.subtle;
|
|
277
|
+
var getRandomValues = crypto.getRandomValues.bind(crypto);
|
|
278
|
+
|
|
279
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/random.js
|
|
280
|
+
var uint32 = () => getRandomValues(new Uint32Array(1))[0];
|
|
281
|
+
var uuidv4Template = [1e7] + -1000 + -4000 + -8000 + -100000000000;
|
|
282
|
+
var uuidv4 = () => uuidv4Template.replace(/[018]/g, (c) => (c ^ uint32() & 15 >> c / 4).toString(16));
|
|
283
|
+
|
|
284
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/time.js
|
|
285
|
+
var getUnixTime = Date.now;
|
|
286
|
+
|
|
287
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/promise.js
|
|
288
|
+
var create3 = (f) => new Promise(f);
|
|
289
|
+
var all = Promise.all.bind(Promise);
|
|
279
290
|
|
|
280
291
|
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/string.js
|
|
281
292
|
var fromCharCode = String.fromCharCode;
|
|
@@ -304,510 +315,6 @@ if (utf8TextDecoder && utf8TextDecoder.decode(new Uint8Array).length === 1) {
|
|
|
304
315
|
}
|
|
305
316
|
var repeat = (source, n) => unfold(n, () => source).join("");
|
|
306
317
|
|
|
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
318
|
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/conditions.js
|
|
812
319
|
var undefinedToNull = (v) => v === undefined ? null : v;
|
|
813
320
|
|
|
@@ -1014,6 +521,83 @@ var production = hasConf("production");
|
|
|
1014
521
|
var forceColor = isNode && isOneOf(process.env.FORCE_COLOR, ["true", "1", "2"]);
|
|
1015
522
|
var supportsColor = forceColor || !hasParam("--no-colors") && !hasConf("no-color") && (!isNode || process.stdout.isTTY) && (!isNode || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
|
|
1016
523
|
|
|
524
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/number.js
|
|
525
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
|
|
526
|
+
var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER;
|
|
527
|
+
var LOWEST_INT32 = 1 << 31;
|
|
528
|
+
|
|
529
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/encoding.js
|
|
530
|
+
var write = (encoder, num) => {
|
|
531
|
+
const bufferLen = encoder.cbuf.length;
|
|
532
|
+
if (encoder.cpos === bufferLen) {
|
|
533
|
+
encoder.bufs.push(encoder.cbuf);
|
|
534
|
+
encoder.cbuf = new Uint8Array(bufferLen * 2);
|
|
535
|
+
encoder.cpos = 0;
|
|
536
|
+
}
|
|
537
|
+
encoder.cbuf[encoder.cpos++] = num;
|
|
538
|
+
};
|
|
539
|
+
var writeVarUint = (encoder, num) => {
|
|
540
|
+
while (num > BITS7) {
|
|
541
|
+
write(encoder, BIT8 | BITS7 & num);
|
|
542
|
+
num = floor(num / 128);
|
|
543
|
+
}
|
|
544
|
+
write(encoder, BITS7 & num);
|
|
545
|
+
};
|
|
546
|
+
var _strBuffer = new Uint8Array(30000);
|
|
547
|
+
var _maxStrBSize = _strBuffer.length / 3;
|
|
548
|
+
var _writeVarStringNative = (encoder, str) => {
|
|
549
|
+
if (str.length < _maxStrBSize) {
|
|
550
|
+
const written = utf8TextEncoder.encodeInto(str, _strBuffer).written || 0;
|
|
551
|
+
writeVarUint(encoder, written);
|
|
552
|
+
for (let i = 0;i < written; i++) {
|
|
553
|
+
write(encoder, _strBuffer[i]);
|
|
554
|
+
}
|
|
555
|
+
} else {
|
|
556
|
+
writeVarUint8Array(encoder, encodeUtf8(str));
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
var _writeVarStringPolyfill = (encoder, str) => {
|
|
560
|
+
const encodedString = unescape(encodeURIComponent(str));
|
|
561
|
+
const len = encodedString.length;
|
|
562
|
+
writeVarUint(encoder, len);
|
|
563
|
+
for (let i = 0;i < len; i++) {
|
|
564
|
+
write(encoder, encodedString.codePointAt(i));
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
var writeVarString = utf8TextEncoder && utf8TextEncoder.encodeInto ? _writeVarStringNative : _writeVarStringPolyfill;
|
|
568
|
+
var writeUint8Array = (encoder, uint8Array) => {
|
|
569
|
+
const bufferLen = encoder.cbuf.length;
|
|
570
|
+
const cpos = encoder.cpos;
|
|
571
|
+
const leftCopyLen = min(bufferLen - cpos, uint8Array.length);
|
|
572
|
+
const rightCopyLen = uint8Array.length - leftCopyLen;
|
|
573
|
+
encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
|
|
574
|
+
encoder.cpos += leftCopyLen;
|
|
575
|
+
if (rightCopyLen > 0) {
|
|
576
|
+
encoder.bufs.push(encoder.cbuf);
|
|
577
|
+
encoder.cbuf = new Uint8Array(max(bufferLen * 2, rightCopyLen));
|
|
578
|
+
encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
|
|
579
|
+
encoder.cpos = rightCopyLen;
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
var writeVarUint8Array = (encoder, uint8Array) => {
|
|
583
|
+
writeVarUint(encoder, uint8Array.byteLength);
|
|
584
|
+
writeUint8Array(encoder, uint8Array);
|
|
585
|
+
};
|
|
586
|
+
var floatTestBed = new DataView(new ArrayBuffer(4));
|
|
587
|
+
|
|
588
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/error.js
|
|
589
|
+
var create4 = (s) => new Error(s);
|
|
590
|
+
var methodUnimplemented = () => {
|
|
591
|
+
throw create4("Method unimplemented");
|
|
592
|
+
};
|
|
593
|
+
var unexpectedCase = () => {
|
|
594
|
+
throw create4("Unexpected case");
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/decoding.js
|
|
598
|
+
var errorUnexpectedEndOfArray = create4("Unexpected end of array");
|
|
599
|
+
var errorIntegerOutOfRange = create4("Integer out of Range");
|
|
600
|
+
|
|
1017
601
|
// ../../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/buffer.js
|
|
1018
602
|
var createUint8ArrayFromLen = (len) => new Uint8Array(len);
|
|
1019
603
|
var copyUint8Array = (uint8Array) => {
|
|
@@ -1408,7 +992,7 @@ var $ = (o) => {
|
|
|
1408
992
|
var assert = production ? () => {} : (o, schema) => {
|
|
1409
993
|
const err = new ValidationError;
|
|
1410
994
|
if (!schema.check(o, err)) {
|
|
1411
|
-
throw
|
|
995
|
+
throw create4(`Expected value to be of type ${schema.constructor.name}.
|
|
1412
996
|
${err.toString()}`);
|
|
1413
997
|
}
|
|
1414
998
|
};
|
|
@@ -1433,7 +1017,7 @@ class PatternMatcher {
|
|
|
1433
1017
|
return p.h(o, s);
|
|
1434
1018
|
}
|
|
1435
1019
|
}
|
|
1436
|
-
throw
|
|
1020
|
+
throw create4("Unhandled pattern");
|
|
1437
1021
|
};
|
|
1438
1022
|
}
|
|
1439
1023
|
}
|
|
@@ -1733,8 +1317,8 @@ var mergeDeleteSets = (dss) => {
|
|
|
1733
1317
|
sortAndMergeDeleteSet(merged);
|
|
1734
1318
|
return merged;
|
|
1735
1319
|
};
|
|
1736
|
-
var addToDeleteSet = (ds, client, clock,
|
|
1737
|
-
setIfUndefined(ds.clients, client, () => []).push(new DeleteItem(clock,
|
|
1320
|
+
var addToDeleteSet = (ds, client, clock, length) => {
|
|
1321
|
+
setIfUndefined(ds.clients, client, () => []).push(new DeleteItem(clock, length));
|
|
1738
1322
|
};
|
|
1739
1323
|
var createDeleteSet = () => new DeleteSet;
|
|
1740
1324
|
var createDeleteSetFromStructStore = (ss) => {
|
|
@@ -1761,12 +1345,12 @@ var createDeleteSetFromStructStore = (ss) => {
|
|
|
1761
1345
|
return ds;
|
|
1762
1346
|
};
|
|
1763
1347
|
var writeDeleteSet = (encoder, ds) => {
|
|
1764
|
-
writeVarUint(encoder.restEncoder, ds.clients.size);
|
|
1348
|
+
encoding.writeVarUint(encoder.restEncoder, ds.clients.size);
|
|
1765
1349
|
from2(ds.clients.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, dsitems]) => {
|
|
1766
1350
|
encoder.resetDsCurVal();
|
|
1767
|
-
writeVarUint(encoder.restEncoder, client);
|
|
1351
|
+
encoding.writeVarUint(encoder.restEncoder, client);
|
|
1768
1352
|
const len = dsitems.length;
|
|
1769
|
-
writeVarUint(encoder.restEncoder, len);
|
|
1353
|
+
encoding.writeVarUint(encoder.restEncoder, len);
|
|
1770
1354
|
for (let i = 0;i < len; i++) {
|
|
1771
1355
|
const item = dsitems[i];
|
|
1772
1356
|
encoder.writeDsClock(item.clock);
|
|
@@ -1776,11 +1360,11 @@ var writeDeleteSet = (encoder, ds) => {
|
|
|
1776
1360
|
};
|
|
1777
1361
|
var readDeleteSet = (decoder) => {
|
|
1778
1362
|
const ds = new DeleteSet;
|
|
1779
|
-
const numClients = readVarUint(decoder.restDecoder);
|
|
1363
|
+
const numClients = decoding.readVarUint(decoder.restDecoder);
|
|
1780
1364
|
for (let i = 0;i < numClients; i++) {
|
|
1781
1365
|
decoder.resetDsCurVal();
|
|
1782
|
-
const client = readVarUint(decoder.restDecoder);
|
|
1783
|
-
const numberOfDeletes = readVarUint(decoder.restDecoder);
|
|
1366
|
+
const client = decoding.readVarUint(decoder.restDecoder);
|
|
1367
|
+
const numberOfDeletes = decoding.readVarUint(decoder.restDecoder);
|
|
1784
1368
|
if (numberOfDeletes > 0) {
|
|
1785
1369
|
const dsField = setIfUndefined(ds.clients, client, () => []);
|
|
1786
1370
|
for (let i2 = 0;i2 < numberOfDeletes; i2++) {
|
|
@@ -1792,11 +1376,11 @@ var readDeleteSet = (decoder) => {
|
|
|
1792
1376
|
};
|
|
1793
1377
|
var readAndApplyDeleteSet = (decoder, transaction, store) => {
|
|
1794
1378
|
const unappliedDS = new DeleteSet;
|
|
1795
|
-
const numClients = readVarUint(decoder.restDecoder);
|
|
1379
|
+
const numClients = decoding.readVarUint(decoder.restDecoder);
|
|
1796
1380
|
for (let i = 0;i < numClients; i++) {
|
|
1797
1381
|
decoder.resetDsCurVal();
|
|
1798
|
-
const client = readVarUint(decoder.restDecoder);
|
|
1799
|
-
const numberOfDeletes = readVarUint(decoder.restDecoder);
|
|
1382
|
+
const client = decoding.readVarUint(decoder.restDecoder);
|
|
1383
|
+
const numberOfDeletes = decoding.readVarUint(decoder.restDecoder);
|
|
1800
1384
|
const structs = store.clients.get(client) || [];
|
|
1801
1385
|
const state = getState(store, client);
|
|
1802
1386
|
for (let i2 = 0;i2 < numberOfDeletes; i2++) {
|
|
@@ -1832,7 +1416,7 @@ var readAndApplyDeleteSet = (decoder, transaction, store) => {
|
|
|
1832
1416
|
}
|
|
1833
1417
|
if (unappliedDS.clients.size > 0) {
|
|
1834
1418
|
const ds = new UpdateEncoderV2;
|
|
1835
|
-
writeVarUint(ds.restEncoder, 0);
|
|
1419
|
+
encoding.writeVarUint(ds.restEncoder, 0);
|
|
1836
1420
|
writeDeleteSet(ds, unappliedDS);
|
|
1837
1421
|
return ds.toUint8Array();
|
|
1838
1422
|
}
|
|
@@ -1877,13 +1461,13 @@ class Doc extends ObservableV2 {
|
|
|
1877
1461
|
this.isLoaded = false;
|
|
1878
1462
|
this.isSynced = false;
|
|
1879
1463
|
this.isDestroyed = false;
|
|
1880
|
-
this.whenLoaded =
|
|
1464
|
+
this.whenLoaded = create3((resolve) => {
|
|
1881
1465
|
this.on("load", () => {
|
|
1882
1466
|
this.isLoaded = true;
|
|
1883
1467
|
resolve(this);
|
|
1884
1468
|
});
|
|
1885
1469
|
});
|
|
1886
|
-
const provideSyncedPromise = () =>
|
|
1470
|
+
const provideSyncedPromise = () => create3((resolve) => {
|
|
1887
1471
|
const eventHandler = (isSynced) => {
|
|
1888
1472
|
if (isSynced === undefined || isSynced === true) {
|
|
1889
1473
|
this.off("sync", eventHandler);
|
|
@@ -2002,49 +1586,49 @@ class DSDecoderV1 {
|
|
|
2002
1586
|
}
|
|
2003
1587
|
resetDsCurVal() {}
|
|
2004
1588
|
readDsClock() {
|
|
2005
|
-
return readVarUint(this.restDecoder);
|
|
1589
|
+
return decoding.readVarUint(this.restDecoder);
|
|
2006
1590
|
}
|
|
2007
1591
|
readDsLen() {
|
|
2008
|
-
return readVarUint(this.restDecoder);
|
|
1592
|
+
return decoding.readVarUint(this.restDecoder);
|
|
2009
1593
|
}
|
|
2010
1594
|
}
|
|
2011
1595
|
|
|
2012
1596
|
class UpdateDecoderV1 extends DSDecoderV1 {
|
|
2013
1597
|
readLeftID() {
|
|
2014
|
-
return createID(readVarUint(this.restDecoder), readVarUint(this.restDecoder));
|
|
1598
|
+
return createID(decoding.readVarUint(this.restDecoder), decoding.readVarUint(this.restDecoder));
|
|
2015
1599
|
}
|
|
2016
1600
|
readRightID() {
|
|
2017
|
-
return createID(readVarUint(this.restDecoder), readVarUint(this.restDecoder));
|
|
1601
|
+
return createID(decoding.readVarUint(this.restDecoder), decoding.readVarUint(this.restDecoder));
|
|
2018
1602
|
}
|
|
2019
1603
|
readClient() {
|
|
2020
|
-
return readVarUint(this.restDecoder);
|
|
1604
|
+
return decoding.readVarUint(this.restDecoder);
|
|
2021
1605
|
}
|
|
2022
1606
|
readInfo() {
|
|
2023
|
-
return readUint8(this.restDecoder);
|
|
1607
|
+
return decoding.readUint8(this.restDecoder);
|
|
2024
1608
|
}
|
|
2025
1609
|
readString() {
|
|
2026
|
-
return readVarString(this.restDecoder);
|
|
1610
|
+
return decoding.readVarString(this.restDecoder);
|
|
2027
1611
|
}
|
|
2028
1612
|
readParentInfo() {
|
|
2029
|
-
return readVarUint(this.restDecoder) === 1;
|
|
1613
|
+
return decoding.readVarUint(this.restDecoder) === 1;
|
|
2030
1614
|
}
|
|
2031
1615
|
readTypeRef() {
|
|
2032
|
-
return readVarUint(this.restDecoder);
|
|
1616
|
+
return decoding.readVarUint(this.restDecoder);
|
|
2033
1617
|
}
|
|
2034
1618
|
readLen() {
|
|
2035
|
-
return readVarUint(this.restDecoder);
|
|
1619
|
+
return decoding.readVarUint(this.restDecoder);
|
|
2036
1620
|
}
|
|
2037
1621
|
readAny() {
|
|
2038
|
-
return readAny(this.restDecoder);
|
|
1622
|
+
return decoding.readAny(this.restDecoder);
|
|
2039
1623
|
}
|
|
2040
1624
|
readBuf() {
|
|
2041
|
-
return copyUint8Array(readVarUint8Array(this.restDecoder));
|
|
1625
|
+
return copyUint8Array(decoding.readVarUint8Array(this.restDecoder));
|
|
2042
1626
|
}
|
|
2043
1627
|
readJSON() {
|
|
2044
|
-
return JSON.parse(readVarString(this.restDecoder));
|
|
1628
|
+
return JSON.parse(decoding.readVarString(this.restDecoder));
|
|
2045
1629
|
}
|
|
2046
1630
|
readKey() {
|
|
2047
|
-
return readVarString(this.restDecoder);
|
|
1631
|
+
return decoding.readVarString(this.restDecoder);
|
|
2048
1632
|
}
|
|
2049
1633
|
}
|
|
2050
1634
|
|
|
@@ -2057,11 +1641,11 @@ class DSDecoderV2 {
|
|
|
2057
1641
|
this.dsCurrVal = 0;
|
|
2058
1642
|
}
|
|
2059
1643
|
readDsClock() {
|
|
2060
|
-
this.dsCurrVal += readVarUint(this.restDecoder);
|
|
1644
|
+
this.dsCurrVal += decoding.readVarUint(this.restDecoder);
|
|
2061
1645
|
return this.dsCurrVal;
|
|
2062
1646
|
}
|
|
2063
1647
|
readDsLen() {
|
|
2064
|
-
const diff = readVarUint(this.restDecoder) + 1;
|
|
1648
|
+
const diff = decoding.readVarUint(this.restDecoder) + 1;
|
|
2065
1649
|
this.dsCurrVal += diff;
|
|
2066
1650
|
return diff;
|
|
2067
1651
|
}
|
|
@@ -2071,16 +1655,16 @@ class UpdateDecoderV2 extends DSDecoderV2 {
|
|
|
2071
1655
|
constructor(decoder) {
|
|
2072
1656
|
super(decoder);
|
|
2073
1657
|
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));
|
|
1658
|
+
decoding.readVarUint(decoder);
|
|
1659
|
+
this.keyClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
1660
|
+
this.clientDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
1661
|
+
this.leftClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
1662
|
+
this.rightClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
1663
|
+
this.infoDecoder = new decoding.RleDecoder(decoding.readVarUint8Array(decoder), decoding.readUint8);
|
|
1664
|
+
this.stringDecoder = new decoding.StringDecoder(decoding.readVarUint8Array(decoder));
|
|
1665
|
+
this.parentInfoDecoder = new decoding.RleDecoder(decoding.readVarUint8Array(decoder), decoding.readUint8);
|
|
1666
|
+
this.typeRefDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
1667
|
+
this.lenDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder));
|
|
2084
1668
|
}
|
|
2085
1669
|
readLeftID() {
|
|
2086
1670
|
return new ID(this.clientDecoder.read(), this.leftClockDecoder.read());
|
|
@@ -2107,13 +1691,13 @@ class UpdateDecoderV2 extends DSDecoderV2 {
|
|
|
2107
1691
|
return this.lenDecoder.read();
|
|
2108
1692
|
}
|
|
2109
1693
|
readAny() {
|
|
2110
|
-
return readAny(this.restDecoder);
|
|
1694
|
+
return decoding.readAny(this.restDecoder);
|
|
2111
1695
|
}
|
|
2112
1696
|
readBuf() {
|
|
2113
|
-
return readVarUint8Array(this.restDecoder);
|
|
1697
|
+
return decoding.readVarUint8Array(this.restDecoder);
|
|
2114
1698
|
}
|
|
2115
1699
|
readJSON() {
|
|
2116
|
-
return readAny(this.restDecoder);
|
|
1700
|
+
return decoding.readAny(this.restDecoder);
|
|
2117
1701
|
}
|
|
2118
1702
|
readKey() {
|
|
2119
1703
|
const keyClock = this.keyClockDecoder.read();
|
|
@@ -2129,68 +1713,68 @@ class UpdateDecoderV2 extends DSDecoderV2 {
|
|
|
2129
1713
|
|
|
2130
1714
|
class DSEncoderV1 {
|
|
2131
1715
|
constructor() {
|
|
2132
|
-
this.restEncoder = createEncoder();
|
|
1716
|
+
this.restEncoder = encoding.createEncoder();
|
|
2133
1717
|
}
|
|
2134
1718
|
toUint8Array() {
|
|
2135
|
-
return toUint8Array(this.restEncoder);
|
|
1719
|
+
return encoding.toUint8Array(this.restEncoder);
|
|
2136
1720
|
}
|
|
2137
1721
|
resetDsCurVal() {}
|
|
2138
1722
|
writeDsClock(clock) {
|
|
2139
|
-
writeVarUint(this.restEncoder, clock);
|
|
1723
|
+
encoding.writeVarUint(this.restEncoder, clock);
|
|
2140
1724
|
}
|
|
2141
1725
|
writeDsLen(len) {
|
|
2142
|
-
writeVarUint(this.restEncoder, len);
|
|
1726
|
+
encoding.writeVarUint(this.restEncoder, len);
|
|
2143
1727
|
}
|
|
2144
1728
|
}
|
|
2145
1729
|
|
|
2146
1730
|
class UpdateEncoderV1 extends DSEncoderV1 {
|
|
2147
1731
|
writeLeftID(id2) {
|
|
2148
|
-
writeVarUint(this.restEncoder, id2.client);
|
|
2149
|
-
writeVarUint(this.restEncoder, id2.clock);
|
|
1732
|
+
encoding.writeVarUint(this.restEncoder, id2.client);
|
|
1733
|
+
encoding.writeVarUint(this.restEncoder, id2.clock);
|
|
2150
1734
|
}
|
|
2151
1735
|
writeRightID(id2) {
|
|
2152
|
-
writeVarUint(this.restEncoder, id2.client);
|
|
2153
|
-
writeVarUint(this.restEncoder, id2.clock);
|
|
1736
|
+
encoding.writeVarUint(this.restEncoder, id2.client);
|
|
1737
|
+
encoding.writeVarUint(this.restEncoder, id2.clock);
|
|
2154
1738
|
}
|
|
2155
1739
|
writeClient(client) {
|
|
2156
|
-
writeVarUint(this.restEncoder, client);
|
|
1740
|
+
encoding.writeVarUint(this.restEncoder, client);
|
|
2157
1741
|
}
|
|
2158
1742
|
writeInfo(info) {
|
|
2159
|
-
writeUint8(this.restEncoder, info);
|
|
1743
|
+
encoding.writeUint8(this.restEncoder, info);
|
|
2160
1744
|
}
|
|
2161
1745
|
writeString(s) {
|
|
2162
|
-
writeVarString(this.restEncoder, s);
|
|
1746
|
+
encoding.writeVarString(this.restEncoder, s);
|
|
2163
1747
|
}
|
|
2164
1748
|
writeParentInfo(isYKey) {
|
|
2165
|
-
writeVarUint(this.restEncoder, isYKey ? 1 : 0);
|
|
1749
|
+
encoding.writeVarUint(this.restEncoder, isYKey ? 1 : 0);
|
|
2166
1750
|
}
|
|
2167
1751
|
writeTypeRef(info) {
|
|
2168
|
-
writeVarUint(this.restEncoder, info);
|
|
1752
|
+
encoding.writeVarUint(this.restEncoder, info);
|
|
2169
1753
|
}
|
|
2170
1754
|
writeLen(len) {
|
|
2171
|
-
writeVarUint(this.restEncoder, len);
|
|
1755
|
+
encoding.writeVarUint(this.restEncoder, len);
|
|
2172
1756
|
}
|
|
2173
1757
|
writeAny(any2) {
|
|
2174
|
-
writeAny(this.restEncoder, any2);
|
|
1758
|
+
encoding.writeAny(this.restEncoder, any2);
|
|
2175
1759
|
}
|
|
2176
1760
|
writeBuf(buf) {
|
|
2177
|
-
writeVarUint8Array(this.restEncoder, buf);
|
|
1761
|
+
encoding.writeVarUint8Array(this.restEncoder, buf);
|
|
2178
1762
|
}
|
|
2179
1763
|
writeJSON(embed) {
|
|
2180
|
-
writeVarString(this.restEncoder, JSON.stringify(embed));
|
|
1764
|
+
encoding.writeVarString(this.restEncoder, JSON.stringify(embed));
|
|
2181
1765
|
}
|
|
2182
1766
|
writeKey(key) {
|
|
2183
|
-
writeVarString(this.restEncoder, key);
|
|
1767
|
+
encoding.writeVarString(this.restEncoder, key);
|
|
2184
1768
|
}
|
|
2185
1769
|
}
|
|
2186
1770
|
|
|
2187
1771
|
class DSEncoderV2 {
|
|
2188
1772
|
constructor() {
|
|
2189
|
-
this.restEncoder = createEncoder();
|
|
1773
|
+
this.restEncoder = encoding.createEncoder();
|
|
2190
1774
|
this.dsCurrVal = 0;
|
|
2191
1775
|
}
|
|
2192
1776
|
toUint8Array() {
|
|
2193
|
-
return toUint8Array(this.restEncoder);
|
|
1777
|
+
return encoding.toUint8Array(this.restEncoder);
|
|
2194
1778
|
}
|
|
2195
1779
|
resetDsCurVal() {
|
|
2196
1780
|
this.dsCurrVal = 0;
|
|
@@ -2198,13 +1782,13 @@ class DSEncoderV2 {
|
|
|
2198
1782
|
writeDsClock(clock) {
|
|
2199
1783
|
const diff = clock - this.dsCurrVal;
|
|
2200
1784
|
this.dsCurrVal = clock;
|
|
2201
|
-
writeVarUint(this.restEncoder, diff);
|
|
1785
|
+
encoding.writeVarUint(this.restEncoder, diff);
|
|
2202
1786
|
}
|
|
2203
1787
|
writeDsLen(len) {
|
|
2204
1788
|
if (len === 0) {
|
|
2205
1789
|
unexpectedCase();
|
|
2206
1790
|
}
|
|
2207
|
-
writeVarUint(this.restEncoder, len - 1);
|
|
1791
|
+
encoding.writeVarUint(this.restEncoder, len - 1);
|
|
2208
1792
|
this.dsCurrVal += len;
|
|
2209
1793
|
}
|
|
2210
1794
|
}
|
|
@@ -2214,30 +1798,30 @@ class UpdateEncoderV2 extends DSEncoderV2 {
|
|
|
2214
1798
|
super();
|
|
2215
1799
|
this.keyMap = new Map;
|
|
2216
1800
|
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;
|
|
1801
|
+
this.keyClockEncoder = new encoding.IntDiffOptRleEncoder;
|
|
1802
|
+
this.clientEncoder = new encoding.UintOptRleEncoder;
|
|
1803
|
+
this.leftClockEncoder = new encoding.IntDiffOptRleEncoder;
|
|
1804
|
+
this.rightClockEncoder = new encoding.IntDiffOptRleEncoder;
|
|
1805
|
+
this.infoEncoder = new encoding.RleEncoder(encoding.writeUint8);
|
|
1806
|
+
this.stringEncoder = new encoding.StringEncoder;
|
|
1807
|
+
this.parentInfoEncoder = new encoding.RleEncoder(encoding.writeUint8);
|
|
1808
|
+
this.typeRefEncoder = new encoding.UintOptRleEncoder;
|
|
1809
|
+
this.lenEncoder = new encoding.UintOptRleEncoder;
|
|
2226
1810
|
}
|
|
2227
1811
|
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);
|
|
1812
|
+
const encoder = encoding.createEncoder();
|
|
1813
|
+
encoding.writeVarUint(encoder, 0);
|
|
1814
|
+
encoding.writeVarUint8Array(encoder, this.keyClockEncoder.toUint8Array());
|
|
1815
|
+
encoding.writeVarUint8Array(encoder, this.clientEncoder.toUint8Array());
|
|
1816
|
+
encoding.writeVarUint8Array(encoder, this.leftClockEncoder.toUint8Array());
|
|
1817
|
+
encoding.writeVarUint8Array(encoder, this.rightClockEncoder.toUint8Array());
|
|
1818
|
+
encoding.writeVarUint8Array(encoder, encoding.toUint8Array(this.infoEncoder));
|
|
1819
|
+
encoding.writeVarUint8Array(encoder, this.stringEncoder.toUint8Array());
|
|
1820
|
+
encoding.writeVarUint8Array(encoder, encoding.toUint8Array(this.parentInfoEncoder));
|
|
1821
|
+
encoding.writeVarUint8Array(encoder, this.typeRefEncoder.toUint8Array());
|
|
1822
|
+
encoding.writeVarUint8Array(encoder, this.lenEncoder.toUint8Array());
|
|
1823
|
+
encoding.writeUint8Array(encoder, encoding.toUint8Array(this.restEncoder));
|
|
1824
|
+
return encoding.toUint8Array(encoder);
|
|
2241
1825
|
}
|
|
2242
1826
|
writeLeftID(id2) {
|
|
2243
1827
|
this.clientEncoder.write(id2.client);
|
|
@@ -2266,13 +1850,13 @@ class UpdateEncoderV2 extends DSEncoderV2 {
|
|
|
2266
1850
|
this.lenEncoder.write(len);
|
|
2267
1851
|
}
|
|
2268
1852
|
writeAny(any2) {
|
|
2269
|
-
writeAny(this.restEncoder, any2);
|
|
1853
|
+
encoding.writeAny(this.restEncoder, any2);
|
|
2270
1854
|
}
|
|
2271
1855
|
writeBuf(buf) {
|
|
2272
|
-
writeVarUint8Array(this.restEncoder, buf);
|
|
1856
|
+
encoding.writeVarUint8Array(this.restEncoder, buf);
|
|
2273
1857
|
}
|
|
2274
1858
|
writeJSON(embed) {
|
|
2275
|
-
writeAny(this.restEncoder, embed);
|
|
1859
|
+
encoding.writeAny(this.restEncoder, embed);
|
|
2276
1860
|
}
|
|
2277
1861
|
writeKey(key) {
|
|
2278
1862
|
const clock = this.keyMap.get(key);
|
|
@@ -2287,9 +1871,9 @@ class UpdateEncoderV2 extends DSEncoderV2 {
|
|
|
2287
1871
|
var writeStructs = (encoder, structs, client, clock) => {
|
|
2288
1872
|
clock = max(clock, structs[0].id.clock);
|
|
2289
1873
|
const startNewStructs = findIndexSS(structs, clock);
|
|
2290
|
-
writeVarUint(encoder.restEncoder, structs.length - startNewStructs);
|
|
1874
|
+
encoding.writeVarUint(encoder.restEncoder, structs.length - startNewStructs);
|
|
2291
1875
|
encoder.writeClient(client);
|
|
2292
|
-
writeVarUint(encoder.restEncoder, clock);
|
|
1876
|
+
encoding.writeVarUint(encoder.restEncoder, clock);
|
|
2293
1877
|
const firstStruct = structs[startNewStructs];
|
|
2294
1878
|
firstStruct.write(encoder, clock - firstStruct.id.clock);
|
|
2295
1879
|
for (let i = startNewStructs + 1;i < structs.length; i++) {
|
|
@@ -2308,19 +1892,19 @@ var writeClientsStructs = (encoder, store, _sm) => {
|
|
|
2308
1892
|
sm.set(client, 0);
|
|
2309
1893
|
}
|
|
2310
1894
|
});
|
|
2311
|
-
writeVarUint(encoder.restEncoder, sm.size);
|
|
1895
|
+
encoding.writeVarUint(encoder.restEncoder, sm.size);
|
|
2312
1896
|
from2(sm.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, clock]) => {
|
|
2313
1897
|
writeStructs(encoder, store.clients.get(client), client, clock);
|
|
2314
1898
|
});
|
|
2315
1899
|
};
|
|
2316
1900
|
var readClientsStructRefs = (decoder, doc2) => {
|
|
2317
1901
|
const clientRefs = create();
|
|
2318
|
-
const numOfStateUpdates = readVarUint(decoder.restDecoder);
|
|
1902
|
+
const numOfStateUpdates = decoding.readVarUint(decoder.restDecoder);
|
|
2319
1903
|
for (let i = 0;i < numOfStateUpdates; i++) {
|
|
2320
|
-
const numberOfStructs = readVarUint(decoder.restDecoder);
|
|
1904
|
+
const numberOfStructs = decoding.readVarUint(decoder.restDecoder);
|
|
2321
1905
|
const refs = new Array(numberOfStructs);
|
|
2322
1906
|
const client = decoder.readClient();
|
|
2323
|
-
let clock = readVarUint(decoder.restDecoder);
|
|
1907
|
+
let clock = decoding.readVarUint(decoder.restDecoder);
|
|
2324
1908
|
clientRefs.set(client, { i: 0, refs });
|
|
2325
1909
|
for (let i2 = 0;i2 < numberOfStructs; i2++) {
|
|
2326
1910
|
const info = decoder.readInfo();
|
|
@@ -2332,7 +1916,7 @@ var readClientsStructRefs = (decoder, doc2) => {
|
|
|
2332
1916
|
break;
|
|
2333
1917
|
}
|
|
2334
1918
|
case 10: {
|
|
2335
|
-
const len = readVarUint(decoder.restDecoder);
|
|
1919
|
+
const len = decoding.readVarUint(decoder.restDecoder);
|
|
2336
1920
|
refs[i2] = new Skip(createID(client, clock), len);
|
|
2337
1921
|
clock += len;
|
|
2338
1922
|
break;
|
|
@@ -2442,7 +2026,7 @@ var integrateStructs = (transaction, store, clientsStructRefs) => {
|
|
|
2442
2026
|
if (restStructs.clients.size > 0) {
|
|
2443
2027
|
const encoder = new UpdateEncoderV2;
|
|
2444
2028
|
writeClientsStructs(encoder, restStructs, new Map);
|
|
2445
|
-
writeVarUint(encoder.restEncoder, 0);
|
|
2029
|
+
encoding.writeVarUint(encoder.restEncoder, 0);
|
|
2446
2030
|
return { missing: missingSV, update: encoder.toUint8Array() };
|
|
2447
2031
|
}
|
|
2448
2032
|
return null;
|
|
@@ -2477,8 +2061,8 @@ var readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = new Update
|
|
|
2477
2061
|
}
|
|
2478
2062
|
const dsRest = readAndApplyDeleteSet(structDecoder, transaction, store);
|
|
2479
2063
|
if (store.pendingDs) {
|
|
2480
|
-
const pendingDSUpdate = new UpdateDecoderV2(createDecoder(store.pendingDs));
|
|
2481
|
-
readVarUint(pendingDSUpdate.restDecoder);
|
|
2064
|
+
const pendingDSUpdate = new UpdateDecoderV2(decoding.createDecoder(store.pendingDs));
|
|
2065
|
+
decoding.readVarUint(pendingDSUpdate.restDecoder);
|
|
2482
2066
|
const dsRest2 = readAndApplyDeleteSet(pendingDSUpdate, transaction, store);
|
|
2483
2067
|
if (dsRest && dsRest2) {
|
|
2484
2068
|
store.pendingDs = mergeUpdatesV2([dsRest, dsRest2]);
|
|
@@ -2496,7 +2080,7 @@ var readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = new Update
|
|
|
2496
2080
|
}, transactionOrigin, false);
|
|
2497
2081
|
var readUpdate = (decoder, ydoc, transactionOrigin) => readUpdateV2(decoder, ydoc, transactionOrigin, new UpdateDecoderV1(decoder));
|
|
2498
2082
|
var applyUpdateV2 = (ydoc, update, transactionOrigin, YDecoder = UpdateDecoderV2) => {
|
|
2499
|
-
const decoder = createDecoder(update);
|
|
2083
|
+
const decoder = decoding.createDecoder(update);
|
|
2500
2084
|
readUpdateV2(decoder, ydoc, transactionOrigin, new YDecoder(decoder));
|
|
2501
2085
|
};
|
|
2502
2086
|
var applyUpdate = (ydoc, update, transactionOrigin) => applyUpdateV2(ydoc, update, transactionOrigin, UpdateDecoderV1);
|
|
@@ -2526,20 +2110,20 @@ var encodeStateAsUpdateV2 = (doc2, encodedTargetStateVector = new Uint8Array([0]
|
|
|
2526
2110
|
var encodeStateAsUpdate = (doc2, encodedTargetStateVector) => encodeStateAsUpdateV2(doc2, encodedTargetStateVector, new UpdateEncoderV1);
|
|
2527
2111
|
var readStateVector = (decoder) => {
|
|
2528
2112
|
const ss = new Map;
|
|
2529
|
-
const ssLength = readVarUint(decoder.restDecoder);
|
|
2113
|
+
const ssLength = decoding.readVarUint(decoder.restDecoder);
|
|
2530
2114
|
for (let i = 0;i < ssLength; i++) {
|
|
2531
|
-
const client = readVarUint(decoder.restDecoder);
|
|
2532
|
-
const clock = readVarUint(decoder.restDecoder);
|
|
2115
|
+
const client = decoding.readVarUint(decoder.restDecoder);
|
|
2116
|
+
const clock = decoding.readVarUint(decoder.restDecoder);
|
|
2533
2117
|
ss.set(client, clock);
|
|
2534
2118
|
}
|
|
2535
2119
|
return ss;
|
|
2536
2120
|
};
|
|
2537
|
-
var decodeStateVector = (decodedState) => readStateVector(new DSDecoderV1(createDecoder(decodedState)));
|
|
2121
|
+
var decodeStateVector = (decodedState) => readStateVector(new DSDecoderV1(decoding.createDecoder(decodedState)));
|
|
2538
2122
|
var writeStateVector = (encoder, sv) => {
|
|
2539
|
-
writeVarUint(encoder.restEncoder, sv.size);
|
|
2123
|
+
encoding.writeVarUint(encoder.restEncoder, sv.size);
|
|
2540
2124
|
from2(sv.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, clock]) => {
|
|
2541
|
-
writeVarUint(encoder.restEncoder, client);
|
|
2542
|
-
writeVarUint(encoder.restEncoder, clock);
|
|
2125
|
+
encoding.writeVarUint(encoder.restEncoder, client);
|
|
2126
|
+
encoding.writeVarUint(encoder.restEncoder, clock);
|
|
2543
2127
|
});
|
|
2544
2128
|
return encoder;
|
|
2545
2129
|
};
|
|
@@ -2580,10 +2164,10 @@ class ID {
|
|
|
2580
2164
|
var compareIDs = (a, b) => a === b || a !== null && b !== null && a.client === b.client && a.clock === b.clock;
|
|
2581
2165
|
var createID = (client, clock) => new ID(client, clock);
|
|
2582
2166
|
var writeID = (encoder, id2) => {
|
|
2583
|
-
writeVarUint(encoder, id2.client);
|
|
2584
|
-
writeVarUint(encoder, id2.clock);
|
|
2167
|
+
encoding.writeVarUint(encoder, id2.client);
|
|
2168
|
+
encoding.writeVarUint(encoder, id2.clock);
|
|
2585
2169
|
};
|
|
2586
|
-
var readID = (decoder) => createID(readVarUint(decoder), readVarUint(decoder));
|
|
2170
|
+
var readID = (decoder) => createID(decoding.readVarUint(decoder), decoding.readVarUint(decoder));
|
|
2587
2171
|
var findRootTypeKey = (type) => {
|
|
2588
2172
|
for (const [key, value] of type.doc.share.entries()) {
|
|
2589
2173
|
if (value === type) {
|
|
@@ -2627,12 +2211,12 @@ class PermanentUserData {
|
|
|
2627
2211
|
event.changes.added.forEach((item) => {
|
|
2628
2212
|
item.content.getContent().forEach((encodedDs) => {
|
|
2629
2213
|
if (encodedDs instanceof Uint8Array) {
|
|
2630
|
-
this.dss.set(userDescription, mergeDeleteSets([this.dss.get(userDescription) || createDeleteSet(), readDeleteSet(new DSDecoderV1(createDecoder(encodedDs)))]));
|
|
2214
|
+
this.dss.set(userDescription, mergeDeleteSets([this.dss.get(userDescription) || createDeleteSet(), readDeleteSet(new DSDecoderV1(decoding.createDecoder(encodedDs)))]));
|
|
2631
2215
|
}
|
|
2632
2216
|
});
|
|
2633
2217
|
});
|
|
2634
2218
|
});
|
|
2635
|
-
this.dss.set(userDescription, mergeDeleteSets(ds.map((encodedDs) => readDeleteSet(new DSDecoderV1(createDecoder(encodedDs))))));
|
|
2219
|
+
this.dss.set(userDescription, mergeDeleteSets(ds.map((encodedDs) => readDeleteSet(new DSDecoderV1(decoding.createDecoder(encodedDs))))));
|
|
2636
2220
|
ids.observe((event) => event.changes.added.forEach((item) => item.content.getContent().forEach(addClientId)));
|
|
2637
2221
|
ids.forEach(addClientId);
|
|
2638
2222
|
};
|
|
@@ -2764,44 +2348,44 @@ var createRelativePositionFromTypeIndex = (type, index, assoc = 0) => {
|
|
|
2764
2348
|
var writeRelativePosition = (encoder, rpos) => {
|
|
2765
2349
|
const { type, tname, item, assoc } = rpos;
|
|
2766
2350
|
if (item !== null) {
|
|
2767
|
-
writeVarUint(encoder, 0);
|
|
2351
|
+
encoding.writeVarUint(encoder, 0);
|
|
2768
2352
|
writeID(encoder, item);
|
|
2769
2353
|
} else if (tname !== null) {
|
|
2770
|
-
writeUint8(encoder, 1);
|
|
2771
|
-
writeVarString(encoder, tname);
|
|
2354
|
+
encoding.writeUint8(encoder, 1);
|
|
2355
|
+
encoding.writeVarString(encoder, tname);
|
|
2772
2356
|
} else if (type !== null) {
|
|
2773
|
-
writeUint8(encoder, 2);
|
|
2357
|
+
encoding.writeUint8(encoder, 2);
|
|
2774
2358
|
writeID(encoder, type);
|
|
2775
2359
|
} else {
|
|
2776
2360
|
throw unexpectedCase();
|
|
2777
2361
|
}
|
|
2778
|
-
writeVarInt(encoder, assoc);
|
|
2362
|
+
encoding.writeVarInt(encoder, assoc);
|
|
2779
2363
|
return encoder;
|
|
2780
2364
|
};
|
|
2781
2365
|
var encodeRelativePosition = (rpos) => {
|
|
2782
|
-
const encoder = createEncoder();
|
|
2366
|
+
const encoder = encoding.createEncoder();
|
|
2783
2367
|
writeRelativePosition(encoder, rpos);
|
|
2784
|
-
return toUint8Array(encoder);
|
|
2368
|
+
return encoding.toUint8Array(encoder);
|
|
2785
2369
|
};
|
|
2786
2370
|
var readRelativePosition = (decoder) => {
|
|
2787
2371
|
let type = null;
|
|
2788
2372
|
let tname = null;
|
|
2789
2373
|
let itemID = null;
|
|
2790
|
-
switch (readVarUint(decoder)) {
|
|
2374
|
+
switch (decoding.readVarUint(decoder)) {
|
|
2791
2375
|
case 0:
|
|
2792
2376
|
itemID = readID(decoder);
|
|
2793
2377
|
break;
|
|
2794
2378
|
case 1:
|
|
2795
|
-
tname = readVarString(decoder);
|
|
2379
|
+
tname = decoding.readVarString(decoder);
|
|
2796
2380
|
break;
|
|
2797
2381
|
case 2: {
|
|
2798
2382
|
type = readID(decoder);
|
|
2799
2383
|
}
|
|
2800
2384
|
}
|
|
2801
|
-
const assoc = hasContent(decoder) ? readVarInt(decoder) : 0;
|
|
2385
|
+
const assoc = decoding.hasContent(decoder) ? decoding.readVarInt(decoder) : 0;
|
|
2802
2386
|
return new RelativePosition(type, tname, itemID, assoc);
|
|
2803
2387
|
};
|
|
2804
|
-
var decodeRelativePosition = (uint8Array) => readRelativePosition(createDecoder(uint8Array));
|
|
2388
|
+
var decodeRelativePosition = (uint8Array) => readRelativePosition(decoding.createDecoder(uint8Array));
|
|
2805
2389
|
var getItemWithOffset = (store, id2) => {
|
|
2806
2390
|
const item = getItem(store, id2);
|
|
2807
2391
|
const diff = id2.clock - item.id.clock;
|
|
@@ -2904,10 +2488,10 @@ var encodeSnapshotV2 = (snapshot, encoder = new DSEncoderV2) => {
|
|
|
2904
2488
|
return encoder.toUint8Array();
|
|
2905
2489
|
};
|
|
2906
2490
|
var encodeSnapshot = (snapshot) => encodeSnapshotV2(snapshot, new DSEncoderV1);
|
|
2907
|
-
var decodeSnapshotV2 = (buf, decoder = new DSDecoderV2(createDecoder(buf))) => {
|
|
2491
|
+
var decodeSnapshotV2 = (buf, decoder = new DSDecoderV2(decoding.createDecoder(buf))) => {
|
|
2908
2492
|
return new Snapshot(readDeleteSet(decoder), readStateVector(decoder));
|
|
2909
2493
|
};
|
|
2910
|
-
var decodeSnapshot = (buf) => decodeSnapshotV2(buf, new DSDecoderV1(createDecoder(buf)));
|
|
2494
|
+
var decodeSnapshot = (buf) => decodeSnapshotV2(buf, new DSDecoderV1(decoding.createDecoder(buf)));
|
|
2911
2495
|
var createSnapshot = (ds, sm) => new Snapshot(ds, sm);
|
|
2912
2496
|
var emptySnapshot = createSnapshot(createDeleteSet(), new Map);
|
|
2913
2497
|
var snapshot = (doc2) => createSnapshot(createDeleteSetFromStructStore(doc2.store), getStateVector(doc2.store));
|
|
@@ -2938,7 +2522,7 @@ var createDocFromSnapshot = (originDoc, snapshot2, newDoc = new Doc) => {
|
|
|
2938
2522
|
size2++;
|
|
2939
2523
|
}
|
|
2940
2524
|
});
|
|
2941
|
-
writeVarUint(encoder.restEncoder, size2);
|
|
2525
|
+
encoding.writeVarUint(encoder.restEncoder, size2);
|
|
2942
2526
|
for (const [client, clock] of sv) {
|
|
2943
2527
|
if (clock === 0) {
|
|
2944
2528
|
continue;
|
|
@@ -2948,9 +2532,9 @@ var createDocFromSnapshot = (originDoc, snapshot2, newDoc = new Doc) => {
|
|
|
2948
2532
|
}
|
|
2949
2533
|
const structs = originDoc.store.clients.get(client) || [];
|
|
2950
2534
|
const lastStructIndex = findIndexSS(structs, clock - 1);
|
|
2951
|
-
writeVarUint(encoder.restEncoder, lastStructIndex + 1);
|
|
2535
|
+
encoding.writeVarUint(encoder.restEncoder, lastStructIndex + 1);
|
|
2952
2536
|
encoder.writeClient(client);
|
|
2953
|
-
writeVarUint(encoder.restEncoder, 0);
|
|
2537
|
+
encoding.writeVarUint(encoder.restEncoder, 0);
|
|
2954
2538
|
for (let i = 0;i <= lastStructIndex; i++) {
|
|
2955
2539
|
structs[i].write(encoder, 0);
|
|
2956
2540
|
}
|
|
@@ -2961,7 +2545,7 @@ var createDocFromSnapshot = (originDoc, snapshot2, newDoc = new Doc) => {
|
|
|
2961
2545
|
return newDoc;
|
|
2962
2546
|
};
|
|
2963
2547
|
var snapshotContainsUpdateV2 = (snapshot2, update, YDecoder = UpdateDecoderV2) => {
|
|
2964
|
-
const updateDecoder = new YDecoder(createDecoder(update));
|
|
2548
|
+
const updateDecoder = new YDecoder(decoding.createDecoder(update));
|
|
2965
2549
|
const lazyDecoder = new LazyStructReader(updateDecoder, false);
|
|
2966
2550
|
for (let curr = lazyDecoder.curr;curr !== null; curr = lazyDecoder.next()) {
|
|
2967
2551
|
if ((snapshot2.sv.get(curr.id.client) || 0) < curr.id.clock + curr.length) {
|
|
@@ -3519,15 +3103,15 @@ class UndoManager extends ObservableV2 {
|
|
|
3519
3103
|
}
|
|
3520
3104
|
}
|
|
3521
3105
|
function* lazyStructReaderGenerator(decoder) {
|
|
3522
|
-
const numOfStateUpdates = readVarUint(decoder.restDecoder);
|
|
3106
|
+
const numOfStateUpdates = decoding.readVarUint(decoder.restDecoder);
|
|
3523
3107
|
for (let i = 0;i < numOfStateUpdates; i++) {
|
|
3524
|
-
const numberOfStructs = readVarUint(decoder.restDecoder);
|
|
3108
|
+
const numberOfStructs = decoding.readVarUint(decoder.restDecoder);
|
|
3525
3109
|
const client = decoder.readClient();
|
|
3526
|
-
let clock = readVarUint(decoder.restDecoder);
|
|
3110
|
+
let clock = decoding.readVarUint(decoder.restDecoder);
|
|
3527
3111
|
for (let i2 = 0;i2 < numberOfStructs; i2++) {
|
|
3528
3112
|
const info = decoder.readInfo();
|
|
3529
3113
|
if (info === 10) {
|
|
3530
|
-
const len = readVarUint(decoder.restDecoder);
|
|
3114
|
+
const len = decoding.readVarUint(decoder.restDecoder);
|
|
3531
3115
|
yield new Skip(createID(client, clock), len);
|
|
3532
3116
|
clock += len;
|
|
3533
3117
|
} else if ((BITS5 & info) !== 0) {
|
|
@@ -3562,7 +3146,7 @@ class LazyStructReader {
|
|
|
3562
3146
|
var logUpdate = (update) => logUpdateV2(update, UpdateDecoderV1);
|
|
3563
3147
|
var logUpdateV2 = (update, YDecoder = UpdateDecoderV2) => {
|
|
3564
3148
|
const structs = [];
|
|
3565
|
-
const updateDecoder = new YDecoder(createDecoder(update));
|
|
3149
|
+
const updateDecoder = new YDecoder(decoding.createDecoder(update));
|
|
3566
3150
|
const lazyDecoder = new LazyStructReader(updateDecoder, false);
|
|
3567
3151
|
for (let curr = lazyDecoder.curr;curr !== null; curr = lazyDecoder.next()) {
|
|
3568
3152
|
structs.push(curr);
|
|
@@ -3574,7 +3158,7 @@ var logUpdateV2 = (update, YDecoder = UpdateDecoderV2) => {
|
|
|
3574
3158
|
var decodeUpdate = (update) => decodeUpdateV2(update, UpdateDecoderV1);
|
|
3575
3159
|
var decodeUpdateV2 = (update, YDecoder = UpdateDecoderV2) => {
|
|
3576
3160
|
const structs = [];
|
|
3577
|
-
const updateDecoder = new YDecoder(createDecoder(update));
|
|
3161
|
+
const updateDecoder = new YDecoder(decoding.createDecoder(update));
|
|
3578
3162
|
const lazyDecoder = new LazyStructReader(updateDecoder, false);
|
|
3579
3163
|
for (let curr = lazyDecoder.curr;curr !== null; curr = lazyDecoder.next()) {
|
|
3580
3164
|
structs.push(curr);
|
|
@@ -3597,7 +3181,7 @@ class LazyStructWriter {
|
|
|
3597
3181
|
var mergeUpdates = (updates) => mergeUpdatesV2(updates, UpdateDecoderV1, UpdateEncoderV1);
|
|
3598
3182
|
var encodeStateVectorFromUpdateV2 = (update, YEncoder = DSEncoderV2, YDecoder = UpdateDecoderV2) => {
|
|
3599
3183
|
const encoder = new YEncoder;
|
|
3600
|
-
const updateDecoder = new LazyStructReader(new YDecoder(createDecoder(update)), false);
|
|
3184
|
+
const updateDecoder = new LazyStructReader(new YDecoder(decoding.createDecoder(update)), false);
|
|
3601
3185
|
let curr = updateDecoder.curr;
|
|
3602
3186
|
if (curr !== null) {
|
|
3603
3187
|
let size2 = 0;
|
|
@@ -3608,8 +3192,8 @@ var encodeStateVectorFromUpdateV2 = (update, YEncoder = DSEncoderV2, YDecoder =
|
|
|
3608
3192
|
if (currClient !== curr.id.client) {
|
|
3609
3193
|
if (currClock !== 0) {
|
|
3610
3194
|
size2++;
|
|
3611
|
-
writeVarUint(encoder.restEncoder, currClient);
|
|
3612
|
-
writeVarUint(encoder.restEncoder, currClock);
|
|
3195
|
+
encoding.writeVarUint(encoder.restEncoder, currClient);
|
|
3196
|
+
encoding.writeVarUint(encoder.restEncoder, currClock);
|
|
3613
3197
|
}
|
|
3614
3198
|
currClient = curr.id.client;
|
|
3615
3199
|
currClock = 0;
|
|
@@ -3624,16 +3208,16 @@ var encodeStateVectorFromUpdateV2 = (update, YEncoder = DSEncoderV2, YDecoder =
|
|
|
3624
3208
|
}
|
|
3625
3209
|
if (currClock !== 0) {
|
|
3626
3210
|
size2++;
|
|
3627
|
-
writeVarUint(encoder.restEncoder, currClient);
|
|
3628
|
-
writeVarUint(encoder.restEncoder, currClock);
|
|
3211
|
+
encoding.writeVarUint(encoder.restEncoder, currClient);
|
|
3212
|
+
encoding.writeVarUint(encoder.restEncoder, currClock);
|
|
3629
3213
|
}
|
|
3630
|
-
const enc = createEncoder();
|
|
3631
|
-
writeVarUint(enc, size2);
|
|
3632
|
-
writeBinaryEncoder(enc, encoder.restEncoder);
|
|
3214
|
+
const enc = encoding.createEncoder();
|
|
3215
|
+
encoding.writeVarUint(enc, size2);
|
|
3216
|
+
encoding.writeBinaryEncoder(enc, encoder.restEncoder);
|
|
3633
3217
|
encoder.restEncoder = enc;
|
|
3634
3218
|
return encoder.toUint8Array();
|
|
3635
3219
|
} else {
|
|
3636
|
-
writeVarUint(encoder.restEncoder, 0);
|
|
3220
|
+
encoding.writeVarUint(encoder.restEncoder, 0);
|
|
3637
3221
|
return encoder.toUint8Array();
|
|
3638
3222
|
}
|
|
3639
3223
|
};
|
|
@@ -3641,7 +3225,7 @@ var encodeStateVectorFromUpdate = (update) => encodeStateVectorFromUpdateV2(upda
|
|
|
3641
3225
|
var parseUpdateMetaV2 = (update, YDecoder = UpdateDecoderV2) => {
|
|
3642
3226
|
const from3 = new Map;
|
|
3643
3227
|
const to = new Map;
|
|
3644
|
-
const updateDecoder = new LazyStructReader(new YDecoder(createDecoder(update)), false);
|
|
3228
|
+
const updateDecoder = new LazyStructReader(new YDecoder(decoding.createDecoder(update)), false);
|
|
3645
3229
|
let curr = updateDecoder.curr;
|
|
3646
3230
|
if (curr !== null) {
|
|
3647
3231
|
let currClient = curr.id.client;
|
|
@@ -3677,7 +3261,7 @@ var mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = UpdateEnco
|
|
|
3677
3261
|
if (updates.length === 1) {
|
|
3678
3262
|
return updates[0];
|
|
3679
3263
|
}
|
|
3680
|
-
const updateDecoders = updates.map((update) => new YDecoder(createDecoder(update)));
|
|
3264
|
+
const updateDecoders = updates.map((update) => new YDecoder(decoding.createDecoder(update)));
|
|
3681
3265
|
let lazyStructDecoders = updateDecoders.map((decoder) => new LazyStructReader(decoder, true));
|
|
3682
3266
|
let currWrite = null;
|
|
3683
3267
|
const updateEncoder = new YEncoder;
|
|
@@ -3764,7 +3348,7 @@ var diffUpdateV2 = (update, sv, YDecoder = UpdateDecoderV2, YEncoder = UpdateEnc
|
|
|
3764
3348
|
const state = decodeStateVector(sv);
|
|
3765
3349
|
const encoder = new YEncoder;
|
|
3766
3350
|
const lazyStructWriter = new LazyStructWriter(encoder);
|
|
3767
|
-
const decoder = new YDecoder(createDecoder(update));
|
|
3351
|
+
const decoder = new YDecoder(decoding.createDecoder(update));
|
|
3768
3352
|
const reader = new LazyStructReader(decoder, false);
|
|
3769
3353
|
while (reader.curr) {
|
|
3770
3354
|
const curr = reader.curr;
|
|
@@ -3795,8 +3379,8 @@ var diffUpdateV2 = (update, sv, YDecoder = UpdateDecoderV2, YEncoder = UpdateEnc
|
|
|
3795
3379
|
var diffUpdate = (update, sv) => diffUpdateV2(update, sv, UpdateDecoderV1, UpdateEncoderV1);
|
|
3796
3380
|
var flushLazyStructWriter = (lazyWriter) => {
|
|
3797
3381
|
if (lazyWriter.written > 0) {
|
|
3798
|
-
lazyWriter.clientStructs.push({ written: lazyWriter.written, restEncoder: toUint8Array(lazyWriter.encoder.restEncoder) });
|
|
3799
|
-
lazyWriter.encoder.restEncoder = createEncoder();
|
|
3382
|
+
lazyWriter.clientStructs.push({ written: lazyWriter.written, restEncoder: encoding.toUint8Array(lazyWriter.encoder.restEncoder) });
|
|
3383
|
+
lazyWriter.encoder.restEncoder = encoding.createEncoder();
|
|
3800
3384
|
lazyWriter.written = 0;
|
|
3801
3385
|
}
|
|
3802
3386
|
};
|
|
@@ -3807,7 +3391,7 @@ var writeStructToLazyStructWriter = (lazyWriter, struct, offset) => {
|
|
|
3807
3391
|
if (lazyWriter.written === 0) {
|
|
3808
3392
|
lazyWriter.currClient = struct.id.client;
|
|
3809
3393
|
lazyWriter.encoder.writeClient(struct.id.client);
|
|
3810
|
-
writeVarUint(lazyWriter.encoder.restEncoder, struct.id.clock + offset);
|
|
3394
|
+
encoding.writeVarUint(lazyWriter.encoder.restEncoder, struct.id.clock + offset);
|
|
3811
3395
|
}
|
|
3812
3396
|
struct.write(lazyWriter.encoder, offset);
|
|
3813
3397
|
lazyWriter.written++;
|
|
@@ -3815,15 +3399,15 @@ var writeStructToLazyStructWriter = (lazyWriter, struct, offset) => {
|
|
|
3815
3399
|
var finishLazyStructWriting = (lazyWriter) => {
|
|
3816
3400
|
flushLazyStructWriter(lazyWriter);
|
|
3817
3401
|
const restEncoder = lazyWriter.encoder.restEncoder;
|
|
3818
|
-
writeVarUint(restEncoder, lazyWriter.clientStructs.length);
|
|
3402
|
+
encoding.writeVarUint(restEncoder, lazyWriter.clientStructs.length);
|
|
3819
3403
|
for (let i = 0;i < lazyWriter.clientStructs.length; i++) {
|
|
3820
3404
|
const partStructs = lazyWriter.clientStructs[i];
|
|
3821
|
-
writeVarUint(restEncoder, partStructs.written);
|
|
3822
|
-
writeUint8Array(restEncoder, partStructs.restEncoder);
|
|
3405
|
+
encoding.writeVarUint(restEncoder, partStructs.written);
|
|
3406
|
+
encoding.writeUint8Array(restEncoder, partStructs.restEncoder);
|
|
3823
3407
|
}
|
|
3824
3408
|
};
|
|
3825
3409
|
var convertUpdateFormat = (update, blockTransformer, YDecoder, YEncoder) => {
|
|
3826
|
-
const updateDecoder = new YDecoder(createDecoder(update));
|
|
3410
|
+
const updateDecoder = new YDecoder(decoding.createDecoder(update));
|
|
3827
3411
|
const lazyDecoder = new LazyStructReader(updateDecoder, false);
|
|
3828
3412
|
const updateEncoder = new YEncoder;
|
|
3829
3413
|
const lazyWriter = new LazyStructWriter(updateEncoder);
|
|
@@ -3945,7 +3529,7 @@ class YEvent {
|
|
|
3945
3529
|
get keys() {
|
|
3946
3530
|
if (this._keys === null) {
|
|
3947
3531
|
if (this.transaction.doc._transactionCleanups.length === 0) {
|
|
3948
|
-
throw
|
|
3532
|
+
throw create4(errorComputeChanges);
|
|
3949
3533
|
}
|
|
3950
3534
|
const keys2 = new Map;
|
|
3951
3535
|
const target = this.target;
|
|
@@ -4001,7 +3585,7 @@ class YEvent {
|
|
|
4001
3585
|
let changes = this._changes;
|
|
4002
3586
|
if (changes === null) {
|
|
4003
3587
|
if (this.transaction.doc._transactionCleanups.length === 0) {
|
|
4004
|
-
throw
|
|
3588
|
+
throw create4(errorComputeChanges);
|
|
4005
3589
|
}
|
|
4006
3590
|
const target = this.target;
|
|
4007
3591
|
const added = create2();
|
|
@@ -4430,7 +4014,7 @@ var typeListInsertGenericsAfter = (transaction, parent, referenceItem, content)
|
|
|
4430
4014
|
});
|
|
4431
4015
|
packJsonContent();
|
|
4432
4016
|
};
|
|
4433
|
-
var lengthExceeded = () =>
|
|
4017
|
+
var lengthExceeded = () => create4("Length exceeded!");
|
|
4434
4018
|
var typeListInsertGenerics = (transaction, parent, index, content) => {
|
|
4435
4019
|
if (index > parent._length) {
|
|
4436
4020
|
throw lengthExceeded();
|
|
@@ -4478,12 +4062,12 @@ var typeListPushGenerics = (transaction, parent, content) => {
|
|
|
4478
4062
|
}
|
|
4479
4063
|
return typeListInsertGenericsAfter(transaction, parent, n, content);
|
|
4480
4064
|
};
|
|
4481
|
-
var typeListDelete = (transaction, parent, index,
|
|
4482
|
-
if (
|
|
4065
|
+
var typeListDelete = (transaction, parent, index, length) => {
|
|
4066
|
+
if (length === 0) {
|
|
4483
4067
|
return;
|
|
4484
4068
|
}
|
|
4485
4069
|
const startIndex = index;
|
|
4486
|
-
const startLength =
|
|
4070
|
+
const startLength = length;
|
|
4487
4071
|
const marker = findMarker(parent, index);
|
|
4488
4072
|
let n = parent._start;
|
|
4489
4073
|
if (marker !== null) {
|
|
@@ -4498,21 +4082,21 @@ var typeListDelete = (transaction, parent, index, length2) => {
|
|
|
4498
4082
|
index -= n.length;
|
|
4499
4083
|
}
|
|
4500
4084
|
}
|
|
4501
|
-
while (
|
|
4085
|
+
while (length > 0 && n !== null) {
|
|
4502
4086
|
if (!n.deleted) {
|
|
4503
|
-
if (
|
|
4504
|
-
getItemCleanStart(transaction, createID(n.id.client, n.id.clock +
|
|
4087
|
+
if (length < n.length) {
|
|
4088
|
+
getItemCleanStart(transaction, createID(n.id.client, n.id.clock + length));
|
|
4505
4089
|
}
|
|
4506
4090
|
n.delete(transaction);
|
|
4507
|
-
|
|
4091
|
+
length -= n.length;
|
|
4508
4092
|
}
|
|
4509
4093
|
n = n.right;
|
|
4510
4094
|
}
|
|
4511
|
-
if (
|
|
4095
|
+
if (length > 0) {
|
|
4512
4096
|
throw lengthExceeded();
|
|
4513
4097
|
}
|
|
4514
4098
|
if (parent._searchMarker) {
|
|
4515
|
-
updateMarkerChanges(parent._searchMarker, startIndex, -startLength +
|
|
4099
|
+
updateMarkerChanges(parent._searchMarker, startIndex, -startLength + length);
|
|
4516
4100
|
}
|
|
4517
4101
|
};
|
|
4518
4102
|
var typeMapDelete = (transaction, parent, key) => {
|
|
@@ -4656,13 +4240,13 @@ class YArray extends AbstractType {
|
|
|
4656
4240
|
unshift(content) {
|
|
4657
4241
|
this.insert(0, content);
|
|
4658
4242
|
}
|
|
4659
|
-
delete(index,
|
|
4243
|
+
delete(index, length = 1) {
|
|
4660
4244
|
if (this.doc !== null) {
|
|
4661
4245
|
transact(this.doc, (transaction) => {
|
|
4662
|
-
typeListDelete(transaction, this, index,
|
|
4246
|
+
typeListDelete(transaction, this, index, length);
|
|
4663
4247
|
});
|
|
4664
4248
|
} else {
|
|
4665
|
-
this._prelimContent.splice(index,
|
|
4249
|
+
this._prelimContent.splice(index, length);
|
|
4666
4250
|
}
|
|
4667
4251
|
}
|
|
4668
4252
|
get(index) {
|
|
@@ -4944,13 +4528,13 @@ var insertText = (transaction, parent, currPos, text2, attributes) => {
|
|
|
4944
4528
|
currPos.forward();
|
|
4945
4529
|
insertNegatedAttributes(transaction, parent, currPos, negatedAttributes);
|
|
4946
4530
|
};
|
|
4947
|
-
var formatText = (transaction, parent, currPos,
|
|
4531
|
+
var formatText = (transaction, parent, currPos, length, attributes) => {
|
|
4948
4532
|
const doc2 = transaction.doc;
|
|
4949
4533
|
const ownClientId = doc2.clientID;
|
|
4950
4534
|
minimizeAttributeChanges(currPos, attributes);
|
|
4951
4535
|
const negatedAttributes = insertAttributes(transaction, parent, currPos, attributes);
|
|
4952
4536
|
iterationLoop:
|
|
4953
|
-
while (currPos.right !== null && (
|
|
4537
|
+
while (currPos.right !== null && (length > 0 || negatedAttributes.size > 0 && (currPos.right.deleted || currPos.right.content.constructor === ContentFormat))) {
|
|
4954
4538
|
if (!currPos.right.deleted) {
|
|
4955
4539
|
switch (currPos.right.content.constructor) {
|
|
4956
4540
|
case ContentFormat: {
|
|
@@ -4960,7 +4544,7 @@ var formatText = (transaction, parent, currPos, length2, attributes) => {
|
|
|
4960
4544
|
if (equalAttrs(attr, value)) {
|
|
4961
4545
|
negatedAttributes.delete(key);
|
|
4962
4546
|
} else {
|
|
4963
|
-
if (
|
|
4547
|
+
if (length === 0) {
|
|
4964
4548
|
break iterationLoop;
|
|
4965
4549
|
}
|
|
4966
4550
|
negatedAttributes.set(key, value);
|
|
@@ -4972,18 +4556,18 @@ var formatText = (transaction, parent, currPos, length2, attributes) => {
|
|
|
4972
4556
|
break;
|
|
4973
4557
|
}
|
|
4974
4558
|
default:
|
|
4975
|
-
if (
|
|
4976
|
-
getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock +
|
|
4559
|
+
if (length < currPos.right.length) {
|
|
4560
|
+
getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock + length));
|
|
4977
4561
|
}
|
|
4978
|
-
|
|
4562
|
+
length -= currPos.right.length;
|
|
4979
4563
|
break;
|
|
4980
4564
|
}
|
|
4981
4565
|
}
|
|
4982
4566
|
currPos.forward();
|
|
4983
4567
|
}
|
|
4984
|
-
if (
|
|
4568
|
+
if (length > 0) {
|
|
4985
4569
|
let newlines = "";
|
|
4986
|
-
for (;
|
|
4570
|
+
for (;length > 0; length--) {
|
|
4987
4571
|
newlines += `
|
|
4988
4572
|
`;
|
|
4989
4573
|
}
|
|
@@ -5110,20 +4694,20 @@ var cleanupYTextAfterTransaction = (transaction) => {
|
|
|
5110
4694
|
}
|
|
5111
4695
|
});
|
|
5112
4696
|
};
|
|
5113
|
-
var deleteText = (transaction, currPos,
|
|
5114
|
-
const startLength =
|
|
4697
|
+
var deleteText = (transaction, currPos, length) => {
|
|
4698
|
+
const startLength = length;
|
|
5115
4699
|
const startAttrs = copy(currPos.currentAttributes);
|
|
5116
4700
|
const start = currPos.right;
|
|
5117
|
-
while (
|
|
4701
|
+
while (length > 0 && currPos.right !== null) {
|
|
5118
4702
|
if (currPos.right.deleted === false) {
|
|
5119
4703
|
switch (currPos.right.content.constructor) {
|
|
5120
4704
|
case ContentType:
|
|
5121
4705
|
case ContentEmbed:
|
|
5122
4706
|
case ContentString:
|
|
5123
|
-
if (
|
|
5124
|
-
getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock +
|
|
4707
|
+
if (length < currPos.right.length) {
|
|
4708
|
+
getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock + length));
|
|
5125
4709
|
}
|
|
5126
|
-
|
|
4710
|
+
length -= currPos.right.length;
|
|
5127
4711
|
currPos.right.delete(transaction);
|
|
5128
4712
|
break;
|
|
5129
4713
|
}
|
|
@@ -5135,7 +4719,7 @@ var deleteText = (transaction, currPos, length2) => {
|
|
|
5135
4719
|
}
|
|
5136
4720
|
const parent = (currPos.left || currPos.right).parent;
|
|
5137
4721
|
if (parent._searchMarker) {
|
|
5138
|
-
updateMarkerChanges(parent._searchMarker, currPos.index, -startLength +
|
|
4722
|
+
updateMarkerChanges(parent._searchMarker, currPos.index, -startLength + length);
|
|
5139
4723
|
}
|
|
5140
4724
|
return currPos;
|
|
5141
4725
|
};
|
|
@@ -5531,21 +5115,21 @@ class YText extends AbstractType {
|
|
|
5531
5115
|
this._pending.push(() => this.insertEmbed(index, embed, attributes || {}));
|
|
5532
5116
|
}
|
|
5533
5117
|
}
|
|
5534
|
-
delete(index,
|
|
5535
|
-
if (
|
|
5118
|
+
delete(index, length) {
|
|
5119
|
+
if (length === 0) {
|
|
5536
5120
|
return;
|
|
5537
5121
|
}
|
|
5538
5122
|
const y = this.doc;
|
|
5539
5123
|
if (y !== null) {
|
|
5540
5124
|
transact(y, (transaction) => {
|
|
5541
|
-
deleteText(transaction, findPosition(transaction, this, index, true),
|
|
5125
|
+
deleteText(transaction, findPosition(transaction, this, index, true), length);
|
|
5542
5126
|
});
|
|
5543
5127
|
} else {
|
|
5544
|
-
this._pending.push(() => this.delete(index,
|
|
5128
|
+
this._pending.push(() => this.delete(index, length));
|
|
5545
5129
|
}
|
|
5546
5130
|
}
|
|
5547
|
-
format(index,
|
|
5548
|
-
if (
|
|
5131
|
+
format(index, length, attributes) {
|
|
5132
|
+
if (length === 0) {
|
|
5549
5133
|
return;
|
|
5550
5134
|
}
|
|
5551
5135
|
const y = this.doc;
|
|
@@ -5555,10 +5139,10 @@ class YText extends AbstractType {
|
|
|
5555
5139
|
if (pos.right === null) {
|
|
5556
5140
|
return;
|
|
5557
5141
|
}
|
|
5558
|
-
formatText(transaction, this, pos,
|
|
5142
|
+
formatText(transaction, this, pos, length, attributes);
|
|
5559
5143
|
});
|
|
5560
5144
|
} else {
|
|
5561
|
-
this._pending.push(() => this.format(index,
|
|
5145
|
+
this._pending.push(() => this.format(index, length, attributes));
|
|
5562
5146
|
}
|
|
5563
5147
|
}
|
|
5564
5148
|
removeAttribute(attributeName) {
|
|
@@ -5715,18 +5299,18 @@ class YXmlFragment extends AbstractType {
|
|
|
5715
5299
|
const pc = this._prelimContent;
|
|
5716
5300
|
const index = ref === null ? 0 : pc.findIndex((el) => el === ref) + 1;
|
|
5717
5301
|
if (index === 0 && ref !== null) {
|
|
5718
|
-
throw
|
|
5302
|
+
throw create4("Reference item not found");
|
|
5719
5303
|
}
|
|
5720
5304
|
pc.splice(index, 0, ...content);
|
|
5721
5305
|
}
|
|
5722
5306
|
}
|
|
5723
|
-
delete(index,
|
|
5307
|
+
delete(index, length = 1) {
|
|
5724
5308
|
if (this.doc !== null) {
|
|
5725
5309
|
transact(this.doc, (transaction) => {
|
|
5726
|
-
typeListDelete(transaction, this, index,
|
|
5310
|
+
typeListDelete(transaction, this, index, length);
|
|
5727
5311
|
});
|
|
5728
5312
|
} else {
|
|
5729
|
-
this._prelimContent.splice(index,
|
|
5313
|
+
this._prelimContent.splice(index, length);
|
|
5730
5314
|
}
|
|
5731
5315
|
}
|
|
5732
5316
|
toArray() {
|
|
@@ -5968,9 +5552,9 @@ class YXmlText extends YText {
|
|
|
5968
5552
|
var readYXmlText = (decoder) => new YXmlText;
|
|
5969
5553
|
|
|
5970
5554
|
class AbstractStruct {
|
|
5971
|
-
constructor(id2,
|
|
5555
|
+
constructor(id2, length) {
|
|
5972
5556
|
this.id = id2;
|
|
5973
|
-
this.length =
|
|
5557
|
+
this.length = length;
|
|
5974
5558
|
}
|
|
5975
5559
|
get deleted() {
|
|
5976
5560
|
throw methodUnimplemented();
|
|
@@ -6879,7 +6463,7 @@ class Skip extends AbstractStruct {
|
|
|
6879
6463
|
}
|
|
6880
6464
|
write(encoder, offset) {
|
|
6881
6465
|
encoder.writeInfo(structSkipRefNumber);
|
|
6882
|
-
writeVarUint(encoder.restEncoder, this.length - offset);
|
|
6466
|
+
encoding.writeVarUint(encoder.restEncoder, this.length - offset);
|
|
6883
6467
|
}
|
|
6884
6468
|
getMissing(transaction, store) {
|
|
6885
6469
|
return null;
|