@yorkie-js/sdk 0.7.3-alpha → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1882,6 +1882,16 @@ declare class CRDTTree extends CRDTElement implements GCParent {
1882
1882
  private indexTree;
1883
1883
  private nodeMapByID;
1884
1884
  constructor(root: CRDTTreeNode, createdAt: TimeTicket);
1885
+ /**
1886
+ * `rebuildMergeState` reconstructs the `mergedInto` cache on source
1887
+ * parents from the persisted `mergedFrom` field on moved children.
1888
+ * For snapshots written before `mergedAt` was added to the proto,
1889
+ * it also falls back to the source's `removedAt` — an approximation
1890
+ * that may be wrong if the source was later overwritten by a
1891
+ * concurrent delete, but this is the best we can do without the
1892
+ * persisted merge ticket.
1893
+ */
1894
+ private rebuildMergeState;
1885
1895
  /**
1886
1896
  * `create` creates a new instance of `CRDTTree`.
1887
1897
  */
@@ -1890,6 +1900,19 @@ declare class CRDTTree extends CRDTElement implements GCParent {
1890
1900
  * `findFloorNode` finds node of given id.
1891
1901
  */
1892
1902
  findFloorNode(id: CRDTTreeNodeID): CRDTTreeNode | undefined;
1903
+ /**
1904
+ * `advancePastUnknownSplitSiblings` follows the insNextID chain of the
1905
+ * given node, advancing past element-type split siblings that the editing
1906
+ * client did not know about (not in versionVector).
1907
+ */
1908
+ private advancePastUnknownSplitSiblings;
1909
+ /**
1910
+ * `hasUnknownSplitSibling` checks whether the given element node has a
1911
+ * split sibling (via insNextID) whose creation the editor did not know
1912
+ * about. Used to prevent styling via End tokens when a concurrent split
1913
+ * extended the range into the split sibling.
1914
+ */
1915
+ private hasUnknownSplitSibling;
1893
1916
  /**
1894
1917
  * `registerNode` registers the given node to the tree.
1895
1918
  */
@@ -2079,6 +2102,29 @@ declare class CRDTTreeNode extends IndexTreeNode<CRDTTreeNode> implements GCPare
2079
2102
  * `insNextID` is the previous node id of this node after the node is split.
2080
2103
  */
2081
2104
  insNextID?: CRDTTreeNodeID;
2105
+ /**
2106
+ * `mergedFrom` records the source parent's ID when this node was moved
2107
+ * by a concurrent merge. Persisted in the snapshot encoding as the
2108
+ * witness of the merge relationship.
2109
+ */
2110
+ mergedFrom?: CRDTTreeNodeID;
2111
+ /**
2112
+ * `mergedAt` records the immutable ticket of the merge operation.
2113
+ * Persisted alongside `mergedFrom` because the source parent's
2114
+ * `removedAt` may be overwritten by later LWW tombstones and thus
2115
+ * cannot serve as the merge-time causal boundary for splitElement's
2116
+ * Fix 8 version-vector check.
2117
+ */
2118
+ mergedAt?: TimeTicket;
2119
+ /**
2120
+ * `mergedInto` is a runtime cache set on the source parent pointing
2121
+ * at the merge target. Set locally during merge execution and rebuilt
2122
+ * from `mergedFrom` on snapshot load. Used for the fast
2123
+ * "is this tombstoned parent a merge source?" check in
2124
+ * `FindTreeNodesWithSplitText`; the alternative (scanning
2125
+ * `nodeMapByID` on every position resolution) would be too expensive.
2126
+ */
2127
+ mergedInto?: CRDTTreeNodeID;
2082
2128
  _value: string;
2083
2129
  constructor(id: CRDTTreeNodeID, type: string, opts?: string | Array<CRDTTreeNode>, attributes?: RHT, removedAt?: TimeTicket);
2084
2130
  /**
@@ -2124,7 +2170,7 @@ declare class CRDTTreeNode extends IndexTreeNode<CRDTTreeNode> implements GCPare
2124
2170
  /**
2125
2171
  * `split` splits the given offset of this node.
2126
2172
  */
2127
- split(tree: CRDTTree, offset: number, issueTimeTicket?: () => TimeTicket): [CRDTTreeNode | undefined, DataSize];
2173
+ split(tree: CRDTTree, offset: number, issueTimeTicket?: () => TimeTicket, versionVector?: VersionVector): [CRDTTreeNode | undefined, DataSize];
2128
2174
  /**
2129
2175
  * `getCreatedAt` returns the creation time of this element.
2130
2176
  */
@@ -2398,7 +2444,7 @@ export { Devtools }
2398
2444
  * `DocEvent` is an event that occurs in `Document`. It can be delivered
2399
2445
  * using `Document.subscribe()`.
2400
2446
  */
2401
- export declare type DocEvent<P extends Indexable = Indexable, T = OpInfo> = StatusChangedEvent_2 | ConnectionChangedEvent | SyncStatusChangedEvent | SnapshotEvent | LocalChangeEvent<T, P> | RemoteChangeEvent<T, P> | PresenceEvent_2<P> | AuthErrorEvent_2;
2447
+ export declare type DocEvent<P extends Indexable = Indexable, T = OpInfo> = StatusChangedEvent_2 | ConnectionChangedEvent | SyncStatusChangedEvent | SnapshotEvent | LocalChangeEvent<T, P> | RemoteChangeEvent<T, P> | PresenceEvent_2<P> | AuthErrorEvent_2 | EpochMismatchEvent;
2402
2448
 
2403
2449
  /**
2404
2450
  * `DocEvent` is an event that occurs in `Document`. It can be delivered
@@ -2412,7 +2458,8 @@ declare type DocEvent_2<P extends Indexable_2 = Indexable_2, T = OpInfo_2> =
2412
2458
  | LocalChangeEvent_2<T, P>
2413
2459
  | RemoteChangeEvent_2<T, P>
2414
2460
  | PresenceEvent<P>
2415
- | AuthErrorEvent;
2461
+ | AuthErrorEvent
2462
+ | EpochMismatchEvent_2;
2416
2463
 
2417
2464
  declare type DocEventCallbackMap<P extends Indexable> = {
2418
2465
  default: NextFn<LocalChangeEvent<OpInfo, P> | RemoteChangeEvent<OpInfo, P> | SnapshotEvent>;
@@ -2423,6 +2470,7 @@ declare type DocEventCallbackMap<P extends Indexable> = {
2423
2470
  status: NextFn<StatusChangedEvent_2>;
2424
2471
  sync: NextFn<SyncStatusChangedEvent>;
2425
2472
  'auth-error': NextFn<AuthErrorEvent_2>;
2473
+ 'epoch-mismatch': NextFn<EpochMismatchEvent>;
2426
2474
  all: NextFn<DocEvents<P>>;
2427
2475
  };
2428
2476
 
@@ -2508,7 +2556,12 @@ export declare enum DocEventType {
2508
2556
  /**
2509
2557
  * `AuthError` indicates an authorization failure in syncLoop or watchLoop.
2510
2558
  */
2511
- AuthError = "auth-error"
2559
+ AuthError = "auth-error",
2560
+ /**
2561
+ * `EpochMismatch` indicates the document was compacted on the server
2562
+ * and this client must detach and reattach to recover.
2563
+ */
2564
+ EpochMismatch = "epoch-mismatch"
2512
2565
  }
2513
2566
 
2514
2567
  /**
@@ -2570,6 +2623,12 @@ declare enum DocEventType_2 {
2570
2623
  * `AuthError` indicates an authorization failure in syncLoop or watchLoop.
2571
2624
  */
2572
2625
  AuthError = 'auth-error',
2626
+
2627
+ /**
2628
+ * `EpochMismatch` indicates the document was compacted on the server
2629
+ * and this client must detach and reattach to recover.
2630
+ */
2631
+ EpochMismatch = 'epoch-mismatch',
2573
2632
  }
2574
2633
 
2575
2634
  /**
@@ -2762,6 +2821,11 @@ declare class Document_2<R, P extends Indexable = Indexable> implements Attachab
2762
2821
  * The callback will be called when the authentification error occurs.
2763
2822
  */
2764
2823
  subscribe(type: 'auth-error', next: DocEventCallbackMap<P>['auth-error'], error?: ErrorFn): Unsubscribe;
2824
+ /**
2825
+ * `subscribe` registers a callback to subscribe to events on the document.
2826
+ * The callback will be called when an epoch mismatch error occurs.
2827
+ */
2828
+ subscribe(type: 'epoch-mismatch', next: DocEventCallbackMap<P>['epoch-mismatch'], error?: ErrorFn): Unsubscribe;
2765
2829
  /**
2766
2830
  * `subscribe` registers a callback to subscribe to events on the document.
2767
2831
  */
@@ -3154,6 +3218,20 @@ declare interface Entry<K, V> {
3154
3218
  value: V;
3155
3219
  }
3156
3220
 
3221
+ export declare interface EpochMismatchEvent extends BaseDocEvent_2 {
3222
+ type: DocEventType.EpochMismatch;
3223
+ value: {
3224
+ method: 'PushPull';
3225
+ };
3226
+ }
3227
+
3228
+ declare interface EpochMismatchEvent_2 extends BaseDocEvent {
3229
+ type: DocEventType_2.EpochMismatch;
3230
+ value: {
3231
+ method: 'PushPull';
3232
+ };
3233
+ }
3234
+
3157
3235
  export declare type ErrorFn = (error: Error) => void;
3158
3236
 
3159
3237
  /**
@@ -3461,10 +3539,17 @@ declare abstract class IndexTreeNode<T extends IndexTreeNode<T>> {
3461
3539
  * In this method, the child is physically removed from the tree.
3462
3540
  */
3463
3541
  removeChild(child: T): void;
3542
+ /**
3543
+ * `detachChild` removes the given child from this node's children list
3544
+ * and updates both visibleSize and totalSize. Unlike `removeChild` which
3545
+ * is used for GC purge of tombstoned nodes, `detachChild` is used for
3546
+ * moving alive nodes between parents.
3547
+ */
3548
+ detachChild(child: T): void;
3464
3549
  /**
3465
3550
  * `splitElement` splits the given element at the given offset.
3466
3551
  */
3467
- splitElement(offset: number, issueTimeTicket: () => TimeTicket): [T | undefined, DataSize];
3552
+ splitElement(offset: number, issueTimeTicket: () => TimeTicket, versionVector?: VersionVector): [T | undefined, DataSize];
3468
3553
  /**
3469
3554
  * `insertAfterInternal` inserts the given node after the given child.
3470
3555
  * This method does not update the size of the ancestors.
@@ -6231,11 +6316,19 @@ export declare class Tree {
6231
6316
  */
6232
6317
  mergeByPath(path: Array<number>): void;
6233
6318
  /**
6234
- * `styleByPath` sets the attributes to the elements of the given path.
6319
+ * `styleByPath` sets the attributes to the element at the given
6320
+ * path.
6235
6321
  */
6236
6322
  styleByPath(path: Array<number>, attributes: {
6237
6323
  [key: string]: any;
6238
6324
  }): void;
6325
+ /**
6326
+ * `styleByPath` sets the attributes to the elements in the given
6327
+ * path range.
6328
+ */
6329
+ styleByPath(fromPath: Array<number>, toPath: Array<number>, attributes: {
6330
+ [key: string]: any;
6331
+ }): void;
6239
6332
  /**
6240
6333
  * `style` sets the attributes to the elements of the given range.
6241
6334
  */
@@ -6246,6 +6339,11 @@ export declare class Tree {
6246
6339
  * `removeStyle` removes the attributes to the elements of the given range.
6247
6340
  */
6248
6341
  removeStyle(fromIdx: number, toIdx: number, attributesToRemove: Array<string>): void;
6342
+ /**
6343
+ * `removeStyleByPath` removes the attributes of the elements in
6344
+ * the given path range.
6345
+ */
6346
+ removeStyleByPath(fromPath: Array<number>, toPath: Array<number>, attributesToRemove: Array<string>): void;
6249
6347
  private editInternal;
6250
6348
  /**
6251
6349
  * `editByPath` edits this tree with the given node and path.
@@ -6428,6 +6526,22 @@ declare type TreeNode_3 = Message<"yorkie.v1.TreeNode"> & {
6428
6526
  attributes: {
6429
6527
  [key: string]: NodeAttr;
6430
6528
  };
6529
+ /**
6530
+ * merged_from is set when this node was moved to a new parent by a
6531
+ * concurrent merge. It points to the source parent's ID.
6532
+ *
6533
+ * @generated from field: yorkie.v1.TreeNodeID merged_from = 9;
6534
+ */
6535
+ mergedFrom?: TreeNodeID;
6536
+ /**
6537
+ * merged_at records the immutable ticket of the merge operation.
6538
+ * Stored alongside merged_from because the source parent's removed_at
6539
+ * may be overwritten by later LWW tombstones and thus cannot serve as
6540
+ * the merge-time causal boundary for SplitElement.
6541
+ *
6542
+ * @generated from field: yorkie.v1.TimeTicket merged_at = 10;
6543
+ */
6544
+ mergedAt?: TimeTicket_2;
6431
6545
  };
6432
6546
 
6433
6547
  /**