@yorkie-js/sdk 0.6.11-rc → 0.6.13

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.
@@ -285,7 +285,8 @@ declare class Change_2 extends Message<Change_2> {
285
285
  * Finally returns a Change after the modification has been completed.
286
286
  */
287
287
  declare class ChangeContext<P extends Indexable = Indexable> {
288
- private id;
288
+ private prevID;
289
+ private nextID;
289
290
  private delimiter;
290
291
  private message?;
291
292
  private root;
@@ -301,11 +302,11 @@ declare class ChangeContext<P extends Indexable = Indexable> {
301
302
  * presence changes.
302
303
  */
303
304
  private reversePresenceKeys;
304
- constructor(id: ChangeID, root: CRDTRoot, presence: P, message?: string);
305
+ constructor(prevID: ChangeID, root: CRDTRoot, presence: P, message?: string);
305
306
  /**
306
307
  * `create` creates a new instance of ChangeContext.
307
308
  */
308
- static create<P extends Indexable>(id: ChangeID, root: CRDTRoot, presence: P, message?: string): ChangeContext<P>;
309
+ static create<P extends Indexable>(prevID: ChangeID, root: CRDTRoot, presence: P, message?: string): ChangeContext<P>;
309
310
  /**
310
311
  * `push` pushes the given operation to this context.
311
312
  */
@@ -323,9 +324,19 @@ declare class ChangeContext<P extends Indexable = Indexable> {
323
324
  */
324
325
  registerGCPair(pair: GCPair): void;
325
326
  /**
326
- * `getChange` creates a new instance of Change in this context.
327
+ * `getNextID` returns the next ID of this context. It will be set to the
328
+ * document for the next change.returns the next ID of this context.
329
+ */
330
+ getNextID(): ChangeID;
331
+ /**
332
+ * `toChange` creates a new instance of Change in this context.
327
333
  */
328
- getChange(): Change<P>;
334
+ toChange(): Change<P>;
335
+ /**
336
+ * `isPresenceOnlyChange` returns whether this context is only for presence
337
+ * change or not.
338
+ */
339
+ isPresenceOnlyChange(): boolean;
329
340
  /**
330
341
  * `hasChange` returns whether this context has change or not.
331
342
  */
@@ -352,6 +363,10 @@ declare class ChangeContext<P extends Indexable = Indexable> {
352
363
  * `getLastTimeTicket` returns the last time ticket issued in this context.
353
364
  */
354
365
  getLastTimeTicket(): TimeTicket;
366
+ /**
367
+ * `acc` accumulates the given DataSize to Live size of the root.
368
+ */
369
+ acc(diff: DataSize): void;
355
370
  }
356
371
 
357
372
  /**
@@ -360,10 +375,14 @@ declare class ChangeContext<P extends Indexable = Indexable> {
360
375
  declare class ChangeID {
361
376
  private clientSeq;
362
377
  private serverSeq?;
363
- private lamport;
364
378
  private actor;
379
+ private lamport;
365
380
  private versionVector;
366
381
  constructor(clientSeq: number, lamport: bigint, actor: ActorID, vector: VersionVector, serverSeq?: bigint);
382
+ /**
383
+ * `hasClocks` returns true if this ID has logical clocks.
384
+ */
385
+ hasClocks(): boolean;
367
386
  /**
368
387
  * `of` creates a new instance of ChangeID.
369
388
  */
@@ -371,9 +390,10 @@ declare class ChangeID {
371
390
  /**
372
391
  * `next` creates a next ID of this ID.
373
392
  */
374
- next(): ChangeID;
393
+ next(excludeClocks?: boolean): ChangeID;
375
394
  /**
376
- * `syncClocks` syncs logical clocks with the given ID.
395
+ * `syncClocks` syncs logical clocks with the given ID. If the given ID
396
+ * doesn't have logical clocks, this ID is returned.
377
397
  */
378
398
  syncClocks(other: ChangeID): ChangeID;
379
399
  /**
@@ -389,6 +409,10 @@ declare class ChangeID {
389
409
  * `setActor` sets the given actor.
390
410
  */
391
411
  setActor(actorID: ActorID): ChangeID;
412
+ /**
413
+ * `setLamport` sets the given lamport clock.
414
+ */
415
+ setLamport(lamport: bigint): ChangeID;
392
416
  /**
393
417
  * `setVersionVector` sets the given version vector.
394
418
  */
@@ -761,6 +785,7 @@ export declare class Client {
761
785
  */
762
786
  detach<R, P extends Indexable>(doc: Document_2<R, P>, opts?: {
763
787
  removeIfNotAttached?: boolean;
788
+ keepalive?: boolean;
764
789
  }): Promise<Document_2<R, P>>;
765
790
  /**
766
791
  * `changeRealtimeSync` changes the synchronization mode of the given document.
@@ -1191,6 +1216,10 @@ declare class CRDTRoot {
1191
1216
  * element itself and its parent.
1192
1217
  */
1193
1218
  private gcPairMap;
1219
+ /**
1220
+ * `docSize` is a structure that represents the size of the document.
1221
+ */
1222
+ private docSize;
1194
1223
  constructor(rootObject: CRDTObject);
1195
1224
  /**
1196
1225
  * `create` creates a new instance of Root.
@@ -1270,6 +1299,10 @@ declare class CRDTRoot {
1270
1299
  * This includes counts of various types of elements and structural information.
1271
1300
  */
1272
1301
  getStats(): RootStats;
1302
+ /**
1303
+ * `acc` accumulates the given DataSize to Live.
1304
+ */
1305
+ acc(diff: DataSize): void;
1273
1306
  }
1274
1307
 
1275
1308
  /**
@@ -1435,22 +1468,22 @@ declare class CRDTTree extends CRDTElement implements GCParent {
1435
1468
  * If `editedAt` is given, then it is used to find the appropriate left node
1436
1469
  * for concurrent insertion.
1437
1470
  */
1438
- findNodesAndSplitText(pos: CRDTTreePos, editedAt?: TimeTicket): TreeNodePair;
1471
+ findNodesAndSplitText(pos: CRDTTreePos, editedAt?: TimeTicket): [TreeNodePair, DataSize];
1439
1472
  /**
1440
1473
  * `style` applies the given attributes of the given range.
1441
1474
  */
1442
1475
  style(range: [CRDTTreePos, CRDTTreePos], attributes: {
1443
1476
  [key: string]: string;
1444
- } | undefined, editedAt: TimeTicket, versionVector?: VersionVector): [Array<GCPair>, Array<TreeChange>];
1477
+ } | undefined, editedAt: TimeTicket, versionVector?: VersionVector): [Array<GCPair>, Array<TreeChange>, DataSize];
1445
1478
  /**
1446
1479
  * `removeStyle` removes the given attributes of the given range.
1447
1480
  */
1448
- removeStyle(range: [CRDTTreePos, CRDTTreePos], attributesToRemove: Array<string>, editedAt: TimeTicket, versionVector?: VersionVector): [Array<GCPair>, Array<TreeChange>];
1481
+ removeStyle(range: [CRDTTreePos, CRDTTreePos], attributesToRemove: Array<string>, editedAt: TimeTicket, versionVector?: VersionVector): [Array<GCPair>, Array<TreeChange>, DataSize];
1449
1482
  /**
1450
1483
  * `edit` edits the tree with the given range and content.
1451
1484
  * If the content is undefined, the range will be removed.
1452
1485
  */
1453
- edit(range: [CRDTTreePos, CRDTTreePos], contents: Array<CRDTTreeNode> | undefined, splitLevel: number, editedAt: TimeTicket, issueTimeTicket: (() => TimeTicket) | undefined, versionVector?: VersionVector): [Array<TreeChange>, Array<GCPair>];
1486
+ edit(range: [CRDTTreePos, CRDTTreePos], contents: Array<CRDTTreeNode> | undefined, splitLevel: number, editedAt: TimeTicket, issueTimeTicket: (() => TimeTicket) | undefined, versionVector?: VersionVector): [Array<TreeChange>, Array<GCPair>, DataSize];
1454
1487
  /**
1455
1488
  * `editT` edits the given range with the given value.
1456
1489
  * This method uses indexes instead of a pair of TreePos for testing.
@@ -1645,7 +1678,7 @@ declare class CRDTTreeNode extends IndexTreeNode<CRDTTreeNode> implements GCPare
1645
1678
  /**
1646
1679
  * `split` splits the given offset of this node.
1647
1680
  */
1648
- split(tree: CRDTTree, offset: number, issueTimeTicket?: () => TimeTicket): CRDTTreeNode | undefined;
1681
+ split(tree: CRDTTree, offset: number, issueTimeTicket?: () => TimeTicket): [CRDTTreeNode | undefined, DataSize];
1649
1682
  /**
1650
1683
  * `getCreatedAt` returns the creation time of this element.
1651
1684
  */
@@ -2283,6 +2316,7 @@ declare class Document_2<R, P extends Indexable = Indexable> {
2283
2316
  private changeID;
2284
2317
  private checkpoint;
2285
2318
  private localChanges;
2319
+ private maxSizeLimit;
2286
2320
  private root;
2287
2321
  private clone?;
2288
2322
  private eventStream;
@@ -2414,6 +2448,13 @@ declare class Document_2<R, P extends Indexable = Indexable> {
2414
2448
  * `getStatus` returns the status of this document.
2415
2449
  */
2416
2450
  getStatus(): DocStatus;
2451
+ /**
2452
+ * `getClone` returns this clone.
2453
+ */
2454
+ getClone(): {
2455
+ root: CRDTRoot;
2456
+ presences: Map<string, P>;
2457
+ } | undefined;
2417
2458
  /* Excluded from this release type: getCloneRoot */
2418
2459
  /**
2419
2460
  * `getRoot` returns a new proxy of cloned root.
@@ -2423,6 +2464,14 @@ declare class Document_2<R, P extends Indexable = Indexable> {
2423
2464
  * `getDocSize` returns the size of this document.
2424
2465
  */
2425
2466
  getDocSize(): DocSize;
2467
+ /**
2468
+ * `getMaxSizePerDocument` gets the maximum size of this document.
2469
+ */
2470
+ getMaxSizePerDocument(): number;
2471
+ /**
2472
+ * `setMaxSizePerDocument` sets the maximum size of this document.
2473
+ */
2474
+ setMaxSizePerDocument(size: number): void;
2426
2475
  /* Excluded from this release type: garbageCollect */
2427
2476
  /* Excluded from this release type: getRootObject */
2428
2477
  /* Excluded from this release type: getGarbageLen */
@@ -2505,10 +2554,6 @@ declare class Document_2<R, P extends Indexable = Indexable> {
2505
2554
  * `canUndo` returns whether there are any operations to undo.
2506
2555
  */
2507
2556
  private canUndo;
2508
- /**
2509
- * 'filterVersionVector' filters detached client's lamport from version vector.
2510
- */
2511
- private filterVersionVector;
2512
2557
  /**
2513
2558
  * `canRedo` returns whether there are any operations to redo.
2514
2559
  */
@@ -2976,10 +3021,14 @@ declare abstract class IndexTreeNode<T extends IndexTreeNode<T>> {
2976
3021
  * `value` sets the value of the node.
2977
3022
  */
2978
3023
  abstract set value(v: string);
3024
+ /**
3025
+ * `getDataSize` returns the size of the node.
3026
+ */
3027
+ abstract getDataSize(): DataSize;
2979
3028
  /**
2980
3029
  * `splitText` splits the given node at the given offset.
2981
3030
  */
2982
- splitText(offset: number, absOffset: number): T | undefined;
3031
+ splitText(offset: number, absOffset: number): [T | undefined, DataSize];
2983
3032
  /**
2984
3033
  * `children` returns the children of the node.
2985
3034
  */
@@ -3025,7 +3074,7 @@ declare abstract class IndexTreeNode<T extends IndexTreeNode<T>> {
3025
3074
  /**
3026
3075
  * `splitElement` splits the given element at the given offset.
3027
3076
  */
3028
- splitElement(offset: number, issueTimeTicket: () => TimeTicket): T | undefined;
3077
+ splitElement(offset: number, issueTimeTicket: () => TimeTicket): [T | undefined, DataSize];
3029
3078
  /**
3030
3079
  * `insertAfterInternal` inserts the given node after the given child.
3031
3080
  * This method does not update the size of the ancestors.
@@ -4435,7 +4484,7 @@ declare class RGATreeSplit<T extends RGATreeSplitValue> implements GCParent {
4435
4484
  * @param value - value
4436
4485
  * @returns `[RGATreeSplitPos, Array<GCPair>, Array<Change>]`
4437
4486
  */
4438
- edit(range: RGATreeSplitPosRange, editedAt: TimeTicket, value?: T, versionVector?: VersionVector): [RGATreeSplitPos, Array<GCPair>, Array<ValueChange<T>>];
4487
+ edit(range: RGATreeSplitPosRange, editedAt: TimeTicket, value?: T, versionVector?: VersionVector): [RGATreeSplitPos, Array<GCPair>, DataSize, Array<ValueChange<T>>];
4439
4488
  /**
4440
4489
  * `indexToPos` finds RGATreeSplitPos of given offset.
4441
4490
  */
@@ -4489,7 +4538,7 @@ declare class RGATreeSplit<T extends RGATreeSplitValue> implements GCParent {
4489
4538
  /**
4490
4539
  * `findNodeWithSplit` splits and return nodes of the given position.
4491
4540
  */
4492
- findNodeWithSplit(pos: RGATreeSplitPos, editedAt: TimeTicket): [RGATreeSplitNode<T>, RGATreeSplitNode<T>];
4541
+ findNodeWithSplit(pos: RGATreeSplitPos, editedAt: TimeTicket): [RGATreeSplitNode<T>, DataSize, RGATreeSplitNode<T>];
4493
4542
  private findFloorNodePreferToLeft;
4494
4543
  private findFloorNode;
4495
4544
  /**