loro-crdt 1.2.5 → 1.2.7

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.
@@ -397,11 +397,6 @@ export type TreeNodeJSON<T> = Omit<TreeNodeValue, 'meta' | 'children'> & {
397
397
  children: TreeNodeJSON<T>[],
398
398
  }
399
399
 
400
- interface LoroTree{
401
- toArray(): TreeNodeValue[];
402
- getNodes(options?: { withDeleted?: boolean } ): LoroTreeNode[];
403
- }
404
-
405
400
  interface LoroMovableList {
406
401
  /**
407
402
  * Get the cursor position at the given pos.
@@ -1129,6 +1124,8 @@ interface LoroTree<T extends Record<string, unknown> = Record<string, unknown>>
1129
1124
  */
1130
1125
  getNodeByID(target: TreeID): LoroTreeNode<T>;
1131
1126
  subscribe(listener: Listener): Subscription;
1127
+ toArray(): TreeNodeValue[];
1128
+ getNodes(options?: { withDeleted?: boolean } ): LoroTreeNode<T>[];
1132
1129
  }
1133
1130
  interface LoroTreeNode<T extends Record<string, unknown> = Record<string, unknown>> {
1134
1131
  /**
@@ -1156,7 +1153,36 @@ interface LoroTreeNode<T extends Record<string, unknown> = Record<string, unknow
1156
1153
  * ```
1157
1154
  */
1158
1155
  createNode(index?: number): LoroTreeNode<T>;
1156
+ /**
1157
+ * Move this tree node to be a child of the parent.
1158
+ * If the parent is undefined, this node will be a root node.
1159
+ *
1160
+ * If the index is not provided, the node will be appended to the end.
1161
+ *
1162
+ * It's not allowed that the target is an ancestor of the parent.
1163
+ *
1164
+ * @example
1165
+ * ```ts
1166
+ * const doc = new LoroDoc();
1167
+ * const tree = doc.getTree("tree");
1168
+ * const root = tree.createNode();
1169
+ * const node = root.createNode();
1170
+ * const node2 = node.createNode();
1171
+ * node2.move(undefined, 0);
1172
+ * // node2 root
1173
+ * // |
1174
+ * // node
1175
+ *
1176
+ * ```
1177
+ */
1159
1178
  move(parent?: LoroTreeNode<T>, index?: number): void;
1179
+ /**
1180
+ * Get the parent node of this node.
1181
+ *
1182
+ * - The parent of the root node is `undefined`.
1183
+ * - The object returned is a new js object each time because it need to cross
1184
+ * the WASM boundary.
1185
+ */
1160
1186
  parent(): LoroTreeNode<T> | undefined;
1161
1187
  /**
1162
1188
  * Get the children of this node.
@@ -2099,6 +2125,21 @@ export class LoroDoc {
2099
2125
  /**
2100
2126
  * Get the value or container at the given path
2101
2127
  *
2128
+ * The path can be specified in different ways depending on the container type:
2129
+ *
2130
+ * For Tree:
2131
+ * 1. Using node IDs: `tree/{node_id}/property`
2132
+ * 2. Using indices: `tree/0/1/property`
2133
+ *
2134
+ * For List and MovableList:
2135
+ * - Using indices: `list/0` or `list/1/property`
2136
+ *
2137
+ * For Map:
2138
+ * - Using keys: `map/key` or `map/nested/property`
2139
+ *
2140
+ * For tree structures, index-based paths follow depth-first traversal order.
2141
+ * The indices start from 0 and represent the position of a node among its siblings.
2142
+ *
2102
2143
  * @example
2103
2144
  * ```ts
2104
2145
  * import { LoroDoc } from "loro-crdt";
@@ -3179,31 +3220,6 @@ export class LoroTreeNode {
3179
3220
  */
3180
3221
  __getClassname(): string;
3181
3222
  /**
3182
- * Move this tree node to be a child of the parent.
3183
- * If the parent is undefined, this node will be a root node.
3184
- *
3185
- * If the index is not provided, the node will be appended to the end.
3186
- *
3187
- * It's not allowed that the target is an ancestor of the parent.
3188
- *
3189
- * @example
3190
- * ```ts
3191
- * const doc = new LoroDoc();
3192
- * const tree = doc.getTree("tree");
3193
- * const root = tree.createNode();
3194
- * const node = root.createNode();
3195
- * const node2 = node.createNode();
3196
- * node2.move(undefined, 0);
3197
- * // node2 root
3198
- * // |
3199
- * // node
3200
- *
3201
- * ```
3202
- * @param {LoroTreeNode | undefined} parent
3203
- * @param {number | undefined} [index]
3204
- */
3205
- move(parent: LoroTreeNode | undefined, index?: number): void;
3206
- /**
3207
3223
  * Move the tree node to be after the target node.
3208
3224
  *
3209
3225
  * @example
@@ -3256,15 +3272,6 @@ export class LoroTreeNode {
3256
3272
  */
3257
3273
  fractionalIndex(): string | undefined;
3258
3274
  /**
3259
- * Get the parent node of this node.
3260
- *
3261
- * - The parent of the root node is `undefined`.
3262
- * - The object returned is a new js object each time because it need to cross
3263
- * the WASM boundary.
3264
- * @returns {LoroTreeNode | undefined}
3265
- */
3266
- parent(): LoroTreeNode | undefined;
3267
- /**
3268
3275
  * Check if the node is deleted.
3269
3276
  * @returns {boolean}
3270
3277
  */
@@ -2359,6 +2359,21 @@ export class LoroDoc {
2359
2359
  /**
2360
2360
  * Get the value or container at the given path
2361
2361
  *
2362
+ * The path can be specified in different ways depending on the container type:
2363
+ *
2364
+ * For Tree:
2365
+ * 1. Using node IDs: `tree/{node_id}/property`
2366
+ * 2. Using indices: `tree/0/1/property`
2367
+ *
2368
+ * For List and MovableList:
2369
+ * - Using indices: `list/0` or `list/1/property`
2370
+ *
2371
+ * For Map:
2372
+ * - Using keys: `map/key` or `map/nested/property`
2373
+ *
2374
+ * For tree structures, index-based paths follow depth-first traversal order.
2375
+ * The indices start from 0 and represent the position of a node among its siblings.
2376
+ *
2362
2377
  * @example
2363
2378
  * ```ts
2364
2379
  * import { LoroDoc } from "loro-crdt";
@@ -5161,26 +5176,6 @@ export class LoroTreeNode {
5161
5176
  }
5162
5177
  }
5163
5178
  /**
5164
- * Move this tree node to be a child of the parent.
5165
- * If the parent is undefined, this node will be a root node.
5166
- *
5167
- * If the index is not provided, the node will be appended to the end.
5168
- *
5169
- * It's not allowed that the target is an ancestor of the parent.
5170
- *
5171
- * @example
5172
- * ```ts
5173
- * const doc = new LoroDoc();
5174
- * const tree = doc.getTree("tree");
5175
- * const root = tree.createNode();
5176
- * const node = root.createNode();
5177
- * const node2 = node.createNode();
5178
- * node2.move(undefined, 0);
5179
- * // node2 root
5180
- * // |
5181
- * // node
5182
- *
5183
- * ```
5184
5179
  * @param {LoroTreeNode | undefined} parent
5185
5180
  * @param {number | undefined} [index]
5186
5181
  */
@@ -5343,11 +5338,6 @@ export class LoroTreeNode {
5343
5338
  }
5344
5339
  }
5345
5340
  /**
5346
- * Get the parent node of this node.
5347
- *
5348
- * - The parent of the root node is `undefined`.
5349
- * - The object returned is a new js object each time because it need to cross
5350
- * the WASM boundary.
5351
5341
  * @returns {LoroTreeNode | undefined}
5352
5342
  */
5353
5343
  parent() {
Binary file
@@ -397,11 +397,6 @@ export type TreeNodeJSON<T> = Omit<TreeNodeValue, 'meta' | 'children'> & {
397
397
  children: TreeNodeJSON<T>[],
398
398
  }
399
399
 
400
- interface LoroTree{
401
- toArray(): TreeNodeValue[];
402
- getNodes(options?: { withDeleted?: boolean } ): LoroTreeNode[];
403
- }
404
-
405
400
  interface LoroMovableList {
406
401
  /**
407
402
  * Get the cursor position at the given pos.
@@ -1129,6 +1124,8 @@ interface LoroTree<T extends Record<string, unknown> = Record<string, unknown>>
1129
1124
  */
1130
1125
  getNodeByID(target: TreeID): LoroTreeNode<T>;
1131
1126
  subscribe(listener: Listener): Subscription;
1127
+ toArray(): TreeNodeValue[];
1128
+ getNodes(options?: { withDeleted?: boolean } ): LoroTreeNode<T>[];
1132
1129
  }
1133
1130
  interface LoroTreeNode<T extends Record<string, unknown> = Record<string, unknown>> {
1134
1131
  /**
@@ -1156,7 +1153,36 @@ interface LoroTreeNode<T extends Record<string, unknown> = Record<string, unknow
1156
1153
  * ```
1157
1154
  */
1158
1155
  createNode(index?: number): LoroTreeNode<T>;
1156
+ /**
1157
+ * Move this tree node to be a child of the parent.
1158
+ * If the parent is undefined, this node will be a root node.
1159
+ *
1160
+ * If the index is not provided, the node will be appended to the end.
1161
+ *
1162
+ * It's not allowed that the target is an ancestor of the parent.
1163
+ *
1164
+ * @example
1165
+ * ```ts
1166
+ * const doc = new LoroDoc();
1167
+ * const tree = doc.getTree("tree");
1168
+ * const root = tree.createNode();
1169
+ * const node = root.createNode();
1170
+ * const node2 = node.createNode();
1171
+ * node2.move(undefined, 0);
1172
+ * // node2 root
1173
+ * // |
1174
+ * // node
1175
+ *
1176
+ * ```
1177
+ */
1159
1178
  move(parent?: LoroTreeNode<T>, index?: number): void;
1179
+ /**
1180
+ * Get the parent node of this node.
1181
+ *
1182
+ * - The parent of the root node is `undefined`.
1183
+ * - The object returned is a new js object each time because it need to cross
1184
+ * the WASM boundary.
1185
+ */
1160
1186
  parent(): LoroTreeNode<T> | undefined;
1161
1187
  /**
1162
1188
  * Get the children of this node.
@@ -2099,6 +2125,21 @@ export class LoroDoc {
2099
2125
  /**
2100
2126
  * Get the value or container at the given path
2101
2127
  *
2128
+ * The path can be specified in different ways depending on the container type:
2129
+ *
2130
+ * For Tree:
2131
+ * 1. Using node IDs: `tree/{node_id}/property`
2132
+ * 2. Using indices: `tree/0/1/property`
2133
+ *
2134
+ * For List and MovableList:
2135
+ * - Using indices: `list/0` or `list/1/property`
2136
+ *
2137
+ * For Map:
2138
+ * - Using keys: `map/key` or `map/nested/property`
2139
+ *
2140
+ * For tree structures, index-based paths follow depth-first traversal order.
2141
+ * The indices start from 0 and represent the position of a node among its siblings.
2142
+ *
2102
2143
  * @example
2103
2144
  * ```ts
2104
2145
  * import { LoroDoc } from "loro-crdt";
@@ -3179,31 +3220,6 @@ export class LoroTreeNode {
3179
3220
  */
3180
3221
  __getClassname(): string;
3181
3222
  /**
3182
- * Move this tree node to be a child of the parent.
3183
- * If the parent is undefined, this node will be a root node.
3184
- *
3185
- * If the index is not provided, the node will be appended to the end.
3186
- *
3187
- * It's not allowed that the target is an ancestor of the parent.
3188
- *
3189
- * @example
3190
- * ```ts
3191
- * const doc = new LoroDoc();
3192
- * const tree = doc.getTree("tree");
3193
- * const root = tree.createNode();
3194
- * const node = root.createNode();
3195
- * const node2 = node.createNode();
3196
- * node2.move(undefined, 0);
3197
- * // node2 root
3198
- * // |
3199
- * // node
3200
- *
3201
- * ```
3202
- * @param {LoroTreeNode | undefined} parent
3203
- * @param {number | undefined} [index]
3204
- */
3205
- move(parent: LoroTreeNode | undefined, index?: number): void;
3206
- /**
3207
3223
  * Move the tree node to be after the target node.
3208
3224
  *
3209
3225
  * @example
@@ -3256,15 +3272,6 @@ export class LoroTreeNode {
3256
3272
  */
3257
3273
  fractionalIndex(): string | undefined;
3258
3274
  /**
3259
- * Get the parent node of this node.
3260
- *
3261
- * - The parent of the root node is `undefined`.
3262
- * - The object returned is a new js object each time because it need to cross
3263
- * the WASM boundary.
3264
- * @returns {LoroTreeNode | undefined}
3265
- */
3266
- parent(): LoroTreeNode | undefined;
3267
- /**
3268
3275
  * Check if the node is deleted.
3269
3276
  * @returns {boolean}
3270
3277
  */
@@ -2357,6 +2357,21 @@ class LoroDoc {
2357
2357
  /**
2358
2358
  * Get the value or container at the given path
2359
2359
  *
2360
+ * The path can be specified in different ways depending on the container type:
2361
+ *
2362
+ * For Tree:
2363
+ * 1. Using node IDs: `tree/{node_id}/property`
2364
+ * 2. Using indices: `tree/0/1/property`
2365
+ *
2366
+ * For List and MovableList:
2367
+ * - Using indices: `list/0` or `list/1/property`
2368
+ *
2369
+ * For Map:
2370
+ * - Using keys: `map/key` or `map/nested/property`
2371
+ *
2372
+ * For tree structures, index-based paths follow depth-first traversal order.
2373
+ * The indices start from 0 and represent the position of a node among its siblings.
2374
+ *
2360
2375
  * @example
2361
2376
  * ```ts
2362
2377
  * import { LoroDoc } from "loro-crdt";
@@ -5165,26 +5180,6 @@ class LoroTreeNode {
5165
5180
  }
5166
5181
  }
5167
5182
  /**
5168
- * Move this tree node to be a child of the parent.
5169
- * If the parent is undefined, this node will be a root node.
5170
- *
5171
- * If the index is not provided, the node will be appended to the end.
5172
- *
5173
- * It's not allowed that the target is an ancestor of the parent.
5174
- *
5175
- * @example
5176
- * ```ts
5177
- * const doc = new LoroDoc();
5178
- * const tree = doc.getTree("tree");
5179
- * const root = tree.createNode();
5180
- * const node = root.createNode();
5181
- * const node2 = node.createNode();
5182
- * node2.move(undefined, 0);
5183
- * // node2 root
5184
- * // |
5185
- * // node
5186
- *
5187
- * ```
5188
5183
  * @param {LoroTreeNode | undefined} parent
5189
5184
  * @param {number | undefined} [index]
5190
5185
  */
@@ -5347,11 +5342,6 @@ class LoroTreeNode {
5347
5342
  }
5348
5343
  }
5349
5344
  /**
5350
- * Get the parent node of this node.
5351
- *
5352
- * - The parent of the root node is `undefined`.
5353
- * - The object returned is a new js object each time because it need to cross
5354
- * the WASM boundary.
5355
5345
  * @returns {LoroTreeNode | undefined}
5356
5346
  */
5357
5347
  parent() {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loro-crdt",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Loro CRDTs is a high-performance CRDT framework that makes your app state synchronized, collaborative and maintainable effortlessly.",
5
5
  "keywords": [
6
6
  "crdt",
@@ -397,11 +397,6 @@ export type TreeNodeJSON<T> = Omit<TreeNodeValue, 'meta' | 'children'> & {
397
397
  children: TreeNodeJSON<T>[],
398
398
  }
399
399
 
400
- interface LoroTree{
401
- toArray(): TreeNodeValue[];
402
- getNodes(options?: { withDeleted?: boolean } ): LoroTreeNode[];
403
- }
404
-
405
400
  interface LoroMovableList {
406
401
  /**
407
402
  * Get the cursor position at the given pos.
@@ -1129,6 +1124,8 @@ interface LoroTree<T extends Record<string, unknown> = Record<string, unknown>>
1129
1124
  */
1130
1125
  getNodeByID(target: TreeID): LoroTreeNode<T>;
1131
1126
  subscribe(listener: Listener): Subscription;
1127
+ toArray(): TreeNodeValue[];
1128
+ getNodes(options?: { withDeleted?: boolean } ): LoroTreeNode<T>[];
1132
1129
  }
1133
1130
  interface LoroTreeNode<T extends Record<string, unknown> = Record<string, unknown>> {
1134
1131
  /**
@@ -1156,7 +1153,36 @@ interface LoroTreeNode<T extends Record<string, unknown> = Record<string, unknow
1156
1153
  * ```
1157
1154
  */
1158
1155
  createNode(index?: number): LoroTreeNode<T>;
1156
+ /**
1157
+ * Move this tree node to be a child of the parent.
1158
+ * If the parent is undefined, this node will be a root node.
1159
+ *
1160
+ * If the index is not provided, the node will be appended to the end.
1161
+ *
1162
+ * It's not allowed that the target is an ancestor of the parent.
1163
+ *
1164
+ * @example
1165
+ * ```ts
1166
+ * const doc = new LoroDoc();
1167
+ * const tree = doc.getTree("tree");
1168
+ * const root = tree.createNode();
1169
+ * const node = root.createNode();
1170
+ * const node2 = node.createNode();
1171
+ * node2.move(undefined, 0);
1172
+ * // node2 root
1173
+ * // |
1174
+ * // node
1175
+ *
1176
+ * ```
1177
+ */
1159
1178
  move(parent?: LoroTreeNode<T>, index?: number): void;
1179
+ /**
1180
+ * Get the parent node of this node.
1181
+ *
1182
+ * - The parent of the root node is `undefined`.
1183
+ * - The object returned is a new js object each time because it need to cross
1184
+ * the WASM boundary.
1185
+ */
1160
1186
  parent(): LoroTreeNode<T> | undefined;
1161
1187
  /**
1162
1188
  * Get the children of this node.
@@ -2099,6 +2125,21 @@ export class LoroDoc {
2099
2125
  /**
2100
2126
  * Get the value or container at the given path
2101
2127
  *
2128
+ * The path can be specified in different ways depending on the container type:
2129
+ *
2130
+ * For Tree:
2131
+ * 1. Using node IDs: `tree/{node_id}/property`
2132
+ * 2. Using indices: `tree/0/1/property`
2133
+ *
2134
+ * For List and MovableList:
2135
+ * - Using indices: `list/0` or `list/1/property`
2136
+ *
2137
+ * For Map:
2138
+ * - Using keys: `map/key` or `map/nested/property`
2139
+ *
2140
+ * For tree structures, index-based paths follow depth-first traversal order.
2141
+ * The indices start from 0 and represent the position of a node among its siblings.
2142
+ *
2102
2143
  * @example
2103
2144
  * ```ts
2104
2145
  * import { LoroDoc } from "loro-crdt";
@@ -3179,31 +3220,6 @@ export class LoroTreeNode {
3179
3220
  */
3180
3221
  __getClassname(): string;
3181
3222
  /**
3182
- * Move this tree node to be a child of the parent.
3183
- * If the parent is undefined, this node will be a root node.
3184
- *
3185
- * If the index is not provided, the node will be appended to the end.
3186
- *
3187
- * It's not allowed that the target is an ancestor of the parent.
3188
- *
3189
- * @example
3190
- * ```ts
3191
- * const doc = new LoroDoc();
3192
- * const tree = doc.getTree("tree");
3193
- * const root = tree.createNode();
3194
- * const node = root.createNode();
3195
- * const node2 = node.createNode();
3196
- * node2.move(undefined, 0);
3197
- * // node2 root
3198
- * // |
3199
- * // node
3200
- *
3201
- * ```
3202
- * @param {LoroTreeNode | undefined} parent
3203
- * @param {number | undefined} [index]
3204
- */
3205
- move(parent: LoroTreeNode | undefined, index?: number): void;
3206
- /**
3207
3223
  * Move the tree node to be after the target node.
3208
3224
  *
3209
3225
  * @example
@@ -3256,15 +3272,6 @@ export class LoroTreeNode {
3256
3272
  */
3257
3273
  fractionalIndex(): string | undefined;
3258
3274
  /**
3259
- * Get the parent node of this node.
3260
- *
3261
- * - The parent of the root node is `undefined`.
3262
- * - The object returned is a new js object each time because it need to cross
3263
- * the WASM boundary.
3264
- * @returns {LoroTreeNode | undefined}
3265
- */
3266
- parent(): LoroTreeNode | undefined;
3267
- /**
3268
3275
  * Check if the node is deleted.
3269
3276
  * @returns {boolean}
3270
3277
  */
package/web/loro_wasm.js CHANGED
@@ -2351,6 +2351,21 @@ export class LoroDoc {
2351
2351
  /**
2352
2352
  * Get the value or container at the given path
2353
2353
  *
2354
+ * The path can be specified in different ways depending on the container type:
2355
+ *
2356
+ * For Tree:
2357
+ * 1. Using node IDs: `tree/{node_id}/property`
2358
+ * 2. Using indices: `tree/0/1/property`
2359
+ *
2360
+ * For List and MovableList:
2361
+ * - Using indices: `list/0` or `list/1/property`
2362
+ *
2363
+ * For Map:
2364
+ * - Using keys: `map/key` or `map/nested/property`
2365
+ *
2366
+ * For tree structures, index-based paths follow depth-first traversal order.
2367
+ * The indices start from 0 and represent the position of a node among its siblings.
2368
+ *
2354
2369
  * @example
2355
2370
  * ```ts
2356
2371
  * import { LoroDoc } from "loro-crdt";
@@ -5153,26 +5168,6 @@ export class LoroTreeNode {
5153
5168
  }
5154
5169
  }
5155
5170
  /**
5156
- * Move this tree node to be a child of the parent.
5157
- * If the parent is undefined, this node will be a root node.
5158
- *
5159
- * If the index is not provided, the node will be appended to the end.
5160
- *
5161
- * It's not allowed that the target is an ancestor of the parent.
5162
- *
5163
- * @example
5164
- * ```ts
5165
- * const doc = new LoroDoc();
5166
- * const tree = doc.getTree("tree");
5167
- * const root = tree.createNode();
5168
- * const node = root.createNode();
5169
- * const node2 = node.createNode();
5170
- * node2.move(undefined, 0);
5171
- * // node2 root
5172
- * // |
5173
- * // node
5174
- *
5175
- * ```
5176
5171
  * @param {LoroTreeNode | undefined} parent
5177
5172
  * @param {number | undefined} [index]
5178
5173
  */
@@ -5335,11 +5330,6 @@ export class LoroTreeNode {
5335
5330
  }
5336
5331
  }
5337
5332
  /**
5338
- * Get the parent node of this node.
5339
- *
5340
- * - The parent of the root node is `undefined`.
5341
- * - The object returned is a new js object each time because it need to cross
5342
- * the WASM boundary.
5343
5333
  * @returns {LoroTreeNode | undefined}
5344
5334
  */
5345
5335
  parent() {
Binary file