loro-crdt 1.10.1 → 1.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,17 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function callPendingEvents(): void;
4
+ /**
5
+ * Get the version of Loro
6
+ */
7
+ export function LORO_VERSION(): string;
8
+ /**
9
+ * Enable debug info of Loro
10
+ */
11
+ export function setDebug(): void;
12
+ export function encodeFrontiers(frontiers: ({ peer: PeerID, counter: number })[]): Uint8Array;
13
+ export function decodeFrontiers(bytes: Uint8Array): { peer: PeerID, counter: number }[];
14
+ export function run(): void;
3
15
  /**
4
16
  * Redacts sensitive content in JSON updates within the specified version range.
5
17
  *
@@ -33,18 +45,6 @@ export function redactJsonUpdates(json_updates: string | JsonSchema, version_ran
33
45
  * - changeNum
34
46
  */
35
47
  export function decodeImportBlobMeta(blob: Uint8Array, check_checksum: boolean): ImportBlobMetadata;
36
- export function decodeFrontiers(bytes: Uint8Array): { peer: PeerID, counter: number }[];
37
- export function run(): void;
38
- export function encodeFrontiers(frontiers: ({ peer: PeerID, counter: number })[]): Uint8Array;
39
- /**
40
- * Enable debug info of Loro
41
- */
42
- export function setDebug(): void;
43
- export function callPendingEvents(): void;
44
- /**
45
- * Get the version of Loro
46
- */
47
- export function LORO_VERSION(): string;
48
48
 
49
49
  /**
50
50
  * Container types supported by loro.
@@ -63,6 +63,7 @@ export function LORO_VERSION(): string;
63
63
  export type ContainerType = "Text" | "Map" | "List"| "Tree" | "MovableList" | "Counter";
64
64
 
65
65
  export type PeerID = `${number}`;
66
+ export type TextPosType = "unicode" | "utf16" | "utf8";
66
67
  /**
67
68
  * The unique id of each container.
68
69
  *
@@ -338,7 +339,7 @@ interface LoroDoc {
338
339
  export type Delta<T> =
339
340
  | {
340
341
  insert: T;
341
- attributes?: { [key in string]: {} };
342
+ attributes?: { [key in string]: Value };
342
343
  retain?: undefined;
343
344
  delete?: undefined;
344
345
  }
@@ -350,7 +351,7 @@ export type Delta<T> =
350
351
  }
351
352
  | {
352
353
  retain: number;
353
- attributes?: { [key in string]: {} };
354
+ attributes?: { [key in string]: Value };
354
355
  delete?: undefined;
355
356
  insert?: undefined;
356
357
  };
@@ -450,6 +451,11 @@ export interface ImportBlobMetadata {
450
451
  }
451
452
 
452
453
  interface LoroText {
454
+ /**
455
+ * Convert a position between coordinate systems.
456
+ */
457
+ convertPos(index: number, from: TextPosType, to: TextPosType): number | undefined;
458
+
453
459
  /**
454
460
  * Get the cursor position at the given pos.
455
461
  *
@@ -1264,6 +1270,10 @@ interface LoroText {
1264
1270
  insert(pos: number, text: string): void;
1265
1271
  delete(pos: number, len: number): void;
1266
1272
  subscribe(listener: Listener): Subscription;
1273
+ /**
1274
+ * Convert a position between coordinate systems.
1275
+ */
1276
+ convertPos(index: number, from: TextPosType, to: TextPosType): number | undefined;
1267
1277
  /**
1268
1278
  * Update the current text to the target text.
1269
1279
  *
@@ -3035,6 +3045,14 @@ export class LoroText {
3035
3045
  * ```
3036
3046
  */
3037
3047
  applyDelta(delta: Delta<string>[]): void;
3048
+ /**
3049
+ * Convert a position between coordinate systems.
3050
+ *
3051
+ * Supported values: `"unicode"`, `"utf16"`, `"utf8"`.
3052
+ *
3053
+ * Returns `undefined` when out of bounds or unsupported.
3054
+ */
3055
+ convertPos(index: number, from: string, to: string): any;
3038
3056
  /**
3039
3057
  * Delete elements from index to utf-8 index + len
3040
3058
  *
@@ -1,5 +1,17 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function callPendingEvents(): void;
4
+ /**
5
+ * Get the version of Loro
6
+ */
7
+ export function LORO_VERSION(): string;
8
+ /**
9
+ * Enable debug info of Loro
10
+ */
11
+ export function setDebug(): void;
12
+ export function encodeFrontiers(frontiers: ({ peer: PeerID, counter: number })[]): Uint8Array;
13
+ export function decodeFrontiers(bytes: Uint8Array): { peer: PeerID, counter: number }[];
14
+ export function run(): void;
3
15
  /**
4
16
  * Redacts sensitive content in JSON updates within the specified version range.
5
17
  *
@@ -33,18 +45,6 @@ export function redactJsonUpdates(json_updates: string | JsonSchema, version_ran
33
45
  * - changeNum
34
46
  */
35
47
  export function decodeImportBlobMeta(blob: Uint8Array, check_checksum: boolean): ImportBlobMetadata;
36
- export function decodeFrontiers(bytes: Uint8Array): { peer: PeerID, counter: number }[];
37
- export function run(): void;
38
- export function encodeFrontiers(frontiers: ({ peer: PeerID, counter: number })[]): Uint8Array;
39
- /**
40
- * Enable debug info of Loro
41
- */
42
- export function setDebug(): void;
43
- export function callPendingEvents(): void;
44
- /**
45
- * Get the version of Loro
46
- */
47
- export function LORO_VERSION(): string;
48
48
 
49
49
  /**
50
50
  * Container types supported by loro.
@@ -63,6 +63,7 @@ export function LORO_VERSION(): string;
63
63
  export type ContainerType = "Text" | "Map" | "List"| "Tree" | "MovableList" | "Counter";
64
64
 
65
65
  export type PeerID = `${number}`;
66
+ export type TextPosType = "unicode" | "utf16" | "utf8";
66
67
  /**
67
68
  * The unique id of each container.
68
69
  *
@@ -338,7 +339,7 @@ interface LoroDoc {
338
339
  export type Delta<T> =
339
340
  | {
340
341
  insert: T;
341
- attributes?: { [key in string]: {} };
342
+ attributes?: { [key in string]: Value };
342
343
  retain?: undefined;
343
344
  delete?: undefined;
344
345
  }
@@ -350,7 +351,7 @@ export type Delta<T> =
350
351
  }
351
352
  | {
352
353
  retain: number;
353
- attributes?: { [key in string]: {} };
354
+ attributes?: { [key in string]: Value };
354
355
  delete?: undefined;
355
356
  insert?: undefined;
356
357
  };
@@ -450,6 +451,11 @@ export interface ImportBlobMetadata {
450
451
  }
451
452
 
452
453
  interface LoroText {
454
+ /**
455
+ * Convert a position between coordinate systems.
456
+ */
457
+ convertPos(index: number, from: TextPosType, to: TextPosType): number | undefined;
458
+
453
459
  /**
454
460
  * Get the cursor position at the given pos.
455
461
  *
@@ -1264,6 +1270,10 @@ interface LoroText {
1264
1270
  insert(pos: number, text: string): void;
1265
1271
  delete(pos: number, len: number): void;
1266
1272
  subscribe(listener: Listener): Subscription;
1273
+ /**
1274
+ * Convert a position between coordinate systems.
1275
+ */
1276
+ convertPos(index: number, from: TextPosType, to: TextPosType): number | undefined;
1267
1277
  /**
1268
1278
  * Update the current text to the target text.
1269
1279
  *
@@ -3035,6 +3045,14 @@ export class LoroText {
3035
3045
  * ```
3036
3046
  */
3037
3047
  applyDelta(delta: Delta<string>[]): void;
3048
+ /**
3049
+ * Convert a position between coordinate systems.
3050
+ *
3051
+ * Supported values: `"unicode"`, `"utf16"`, `"utf8"`.
3052
+ *
3053
+ * Returns `undefined` when out of bounds or unsupported.
3054
+ */
3055
+ convertPos(index: number, from: string, to: string): any;
3038
3056
  /**
3039
3057
  * Delete elements from index to utf-8 index + len
3040
3058
  *
@@ -240,6 +240,78 @@ function getArrayJsValueFromWasm0(ptr, len) {
240
240
  wasm.__externref_drop_slice(ptr, len);
241
241
  return result;
242
242
  }
243
+
244
+ export function callPendingEvents() {
245
+ wasm.callPendingEvents();
246
+ }
247
+
248
+ /**
249
+ * Get the version of Loro
250
+ * @returns {string}
251
+ */
252
+ export function LORO_VERSION() {
253
+ let deferred1_0;
254
+ let deferred1_1;
255
+ try {
256
+ const ret = wasm.LORO_VERSION();
257
+ deferred1_0 = ret[0];
258
+ deferred1_1 = ret[1];
259
+ return getStringFromWasm0(ret[0], ret[1]);
260
+ } finally {
261
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Enable debug info of Loro
267
+ */
268
+ export function setDebug() {
269
+ wasm.setDebug();
270
+ }
271
+
272
+ function passArrayJsValueToWasm0(array, malloc) {
273
+ const ptr = malloc(array.length * 4, 4) >>> 0;
274
+ for (let i = 0; i < array.length; i++) {
275
+ const add = addToExternrefTable0(array[i]);
276
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
277
+ }
278
+ WASM_VECTOR_LEN = array.length;
279
+ return ptr;
280
+ }
281
+ /**
282
+ * @param {({ peer: PeerID, counter: number })[]} frontiers
283
+ * @returns {Uint8Array}
284
+ */
285
+ export function encodeFrontiers(frontiers) {
286
+ const ptr0 = passArrayJsValueToWasm0(frontiers, wasm.__wbindgen_malloc);
287
+ const len0 = WASM_VECTOR_LEN;
288
+ const ret = wasm.encodeFrontiers(ptr0, len0);
289
+ if (ret[3]) {
290
+ throw takeFromExternrefTable0(ret[2]);
291
+ }
292
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
293
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
294
+ return v2;
295
+ }
296
+
297
+ /**
298
+ * @param {Uint8Array} bytes
299
+ * @returns {{ peer: PeerID, counter: number }[]}
300
+ */
301
+ export function decodeFrontiers(bytes) {
302
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
303
+ const len0 = WASM_VECTOR_LEN;
304
+ const ret = wasm.decodeFrontiers(ptr0, len0);
305
+ if (ret[2]) {
306
+ throw takeFromExternrefTable0(ret[1]);
307
+ }
308
+ return takeFromExternrefTable0(ret[0]);
309
+ }
310
+
311
+ export function run() {
312
+ wasm.run();
313
+ }
314
+
243
315
  /**
244
316
  * Redacts sensitive content in JSON updates within the specified version range.
245
317
  *
@@ -295,83 +367,12 @@ export function decodeImportBlobMeta(blob, check_checksum) {
295
367
  return takeFromExternrefTable0(ret[0]);
296
368
  }
297
369
 
298
- /**
299
- * @param {Uint8Array} bytes
300
- * @returns {{ peer: PeerID, counter: number }[]}
301
- */
302
- export function decodeFrontiers(bytes) {
303
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
304
- const len0 = WASM_VECTOR_LEN;
305
- const ret = wasm.decodeFrontiers(ptr0, len0);
306
- if (ret[2]) {
307
- throw takeFromExternrefTable0(ret[1]);
308
- }
309
- return takeFromExternrefTable0(ret[0]);
310
- }
311
-
312
- export function run() {
313
- wasm.run();
314
- }
315
-
316
- function passArrayJsValueToWasm0(array, malloc) {
317
- const ptr = malloc(array.length * 4, 4) >>> 0;
318
- for (let i = 0; i < array.length; i++) {
319
- const add = addToExternrefTable0(array[i]);
320
- getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
321
- }
322
- WASM_VECTOR_LEN = array.length;
323
- return ptr;
324
- }
325
- /**
326
- * @param {({ peer: PeerID, counter: number })[]} frontiers
327
- * @returns {Uint8Array}
328
- */
329
- export function encodeFrontiers(frontiers) {
330
- const ptr0 = passArrayJsValueToWasm0(frontiers, wasm.__wbindgen_malloc);
331
- const len0 = WASM_VECTOR_LEN;
332
- const ret = wasm.encodeFrontiers(ptr0, len0);
333
- if (ret[3]) {
334
- throw takeFromExternrefTable0(ret[2]);
335
- }
336
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
337
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
338
- return v2;
339
- }
340
-
341
- /**
342
- * Enable debug info of Loro
343
- */
344
- export function setDebug() {
345
- wasm.setDebug();
346
- }
347
-
348
- export function callPendingEvents() {
349
- wasm.callPendingEvents();
350
- }
351
-
352
- /**
353
- * Get the version of Loro
354
- * @returns {string}
355
- */
356
- export function LORO_VERSION() {
357
- let deferred1_0;
358
- let deferred1_1;
359
- try {
360
- const ret = wasm.LORO_VERSION();
361
- deferred1_0 = ret[0];
362
- deferred1_1 = ret[1];
363
- return getStringFromWasm0(ret[0], ret[1]);
364
- } finally {
365
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
366
- }
367
- }
368
-
369
370
  function __wbg_adapter_62(arg0, arg1, arg2) {
370
371
  wasm.closure11_externref_shim(arg0, arg1, arg2);
371
372
  }
372
373
 
373
374
  function __wbg_adapter_65(arg0, arg1) {
374
- wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb782650185ad08f4(arg0, arg1);
375
+ wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha7d67e25add7f151(arg0, arg1);
375
376
  }
376
377
 
377
378
  const AwarenessWasmFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -3903,6 +3904,25 @@ export class LoroText {
3903
3904
  throw takeFromExternrefTable0(ret[0]);
3904
3905
  }
3905
3906
  }
3907
+ /**
3908
+ * Convert a position between coordinate systems.
3909
+ *
3910
+ * Supported values: `"unicode"`, `"utf16"`, `"utf8"`.
3911
+ *
3912
+ * Returns `undefined` when out of bounds or unsupported.
3913
+ * @param {number} index
3914
+ * @param {string} from
3915
+ * @param {string} to
3916
+ * @returns {any}
3917
+ */
3918
+ convertPos(index, from, to) {
3919
+ const ptr0 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3920
+ const len0 = WASM_VECTOR_LEN;
3921
+ const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3922
+ const len1 = WASM_VECTOR_LEN;
3923
+ const ret = wasm.lorotext_convertPos(this.__wbg_ptr, index, ptr0, len0, ptr1, len1);
3924
+ return ret;
3925
+ }
3906
3926
  /**
3907
3927
  * Delete elements from index to utf-8 index + len
3908
3928
  *
@@ -5509,6 +5529,10 @@ export function __wbg_entries_c8a90a7ed73e84ce(arg0) {
5509
5529
  return ret;
5510
5530
  };
5511
5531
 
5532
+ export function __wbg_error_4ac2b4fe53215e85(arg0, arg1) {
5533
+ console.error(getStringFromWasm0(arg0, arg1));
5534
+ };
5535
+
5512
5536
  export function __wbg_error_7534b8e9a36f1ab4(arg0, arg1) {
5513
5537
  let deferred0_0;
5514
5538
  let deferred0_1;
@@ -5521,10 +5545,6 @@ export function __wbg_error_7534b8e9a36f1ab4(arg0, arg1) {
5521
5545
  }
5522
5546
  };
5523
5547
 
5524
- export function __wbg_error_f6ddbf3300c73fe1(arg0, arg1) {
5525
- console.error(getStringFromWasm0(arg0, arg1));
5526
- };
5527
-
5528
5548
  export function __wbg_from_2a5d3e218e67aa85(arg0) {
5529
5549
  const ret = Array.from(arg0);
5530
5550
  return ret;
@@ -5640,7 +5660,7 @@ export function __wbg_log_0cc1b7768397bcfe(arg0, arg1, arg2, arg3, arg4, arg5, a
5640
5660
  }
5641
5661
  };
5642
5662
 
5643
- export function __wbg_log_3c0d0f235e1c209c(arg0, arg1) {
5663
+ export function __wbg_log_bd9aa71b996755d3(arg0, arg1) {
5644
5664
  console.log(getStringFromWasm0(arg0, arg1));
5645
5665
  };
5646
5666
 
@@ -5890,7 +5910,7 @@ export function __wbg_versionvector_new(arg0) {
5890
5910
  return ret;
5891
5911
  };
5892
5912
 
5893
- export function __wbg_warn_e3fad33818dd84d2(arg0, arg1) {
5913
+ export function __wbg_warn_ba32d63a72098111(arg0, arg1) {
5894
5914
  console.warn(getStringFromWasm0(arg0, arg1));
5895
5915
  };
5896
5916
 
@@ -5937,7 +5957,7 @@ export function __wbindgen_closure_wrapper718(arg0, arg1, arg2) {
5937
5957
  return ret;
5938
5958
  };
5939
5959
 
5940
- export function __wbindgen_closure_wrapper720(arg0, arg1, arg2) {
5960
+ export function __wbindgen_closure_wrapper721(arg0, arg1, arg2) {
5941
5961
  const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_65);
5942
5962
  return ret;
5943
5963
  };
Binary file
@@ -212,6 +212,7 @@ export const loromovablelist_toArray: (a: number) => [number, number];
212
212
  export const loromovablelist_toJSON: (a: number) => any;
213
213
  export const lorotext_applyDelta: (a: number, b: any) => [number, number];
214
214
  export const lorotext_charAt: (a: number, b: number) => [number, number, number];
215
+ export const lorotext_convertPos: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
215
216
  export const lorotext_delete: (a: number, b: number, c: number) => [number, number];
216
217
  export const lorotext_deleteUtf8: (a: number, b: number, c: number) => [number, number];
217
218
  export const lorotext_getAttached: (a: number) => any;
@@ -324,5 +325,5 @@ export const __wbindgen_export_6: WebAssembly.Table;
324
325
  export const __externref_table_dealloc: (a: number) => void;
325
326
  export const __externref_drop_slice: (a: number, b: number) => void;
326
327
  export const closure11_externref_shim: (a: number, b: number, c: any) => void;
327
- export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb782650185ad08f4: (a: number, b: number) => void;
328
+ export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha7d67e25add7f151: (a: number, b: number) => void;
328
329
  export const __wbindgen_start: () => void;
@@ -1,5 +1,17 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function callPendingEvents(): void;
4
+ /**
5
+ * Get the version of Loro
6
+ */
7
+ export function LORO_VERSION(): string;
8
+ /**
9
+ * Enable debug info of Loro
10
+ */
11
+ export function setDebug(): void;
12
+ export function encodeFrontiers(frontiers: ({ peer: PeerID, counter: number })[]): Uint8Array;
13
+ export function decodeFrontiers(bytes: Uint8Array): { peer: PeerID, counter: number }[];
14
+ export function run(): void;
3
15
  /**
4
16
  * Redacts sensitive content in JSON updates within the specified version range.
5
17
  *
@@ -33,18 +45,6 @@ export function redactJsonUpdates(json_updates: string | JsonSchema, version_ran
33
45
  * - changeNum
34
46
  */
35
47
  export function decodeImportBlobMeta(blob: Uint8Array, check_checksum: boolean): ImportBlobMetadata;
36
- export function decodeFrontiers(bytes: Uint8Array): { peer: PeerID, counter: number }[];
37
- export function run(): void;
38
- export function encodeFrontiers(frontiers: ({ peer: PeerID, counter: number })[]): Uint8Array;
39
- /**
40
- * Enable debug info of Loro
41
- */
42
- export function setDebug(): void;
43
- export function callPendingEvents(): void;
44
- /**
45
- * Get the version of Loro
46
- */
47
- export function LORO_VERSION(): string;
48
48
 
49
49
  /**
50
50
  * Container types supported by loro.
@@ -63,6 +63,7 @@ export function LORO_VERSION(): string;
63
63
  export type ContainerType = "Text" | "Map" | "List"| "Tree" | "MovableList" | "Counter";
64
64
 
65
65
  export type PeerID = `${number}`;
66
+ export type TextPosType = "unicode" | "utf16" | "utf8";
66
67
  /**
67
68
  * The unique id of each container.
68
69
  *
@@ -338,7 +339,7 @@ interface LoroDoc {
338
339
  export type Delta<T> =
339
340
  | {
340
341
  insert: T;
341
- attributes?: { [key in string]: {} };
342
+ attributes?: { [key in string]: Value };
342
343
  retain?: undefined;
343
344
  delete?: undefined;
344
345
  }
@@ -350,7 +351,7 @@ export type Delta<T> =
350
351
  }
351
352
  | {
352
353
  retain: number;
353
- attributes?: { [key in string]: {} };
354
+ attributes?: { [key in string]: Value };
354
355
  delete?: undefined;
355
356
  insert?: undefined;
356
357
  };
@@ -450,6 +451,11 @@ export interface ImportBlobMetadata {
450
451
  }
451
452
 
452
453
  interface LoroText {
454
+ /**
455
+ * Convert a position between coordinate systems.
456
+ */
457
+ convertPos(index: number, from: TextPosType, to: TextPosType): number | undefined;
458
+
453
459
  /**
454
460
  * Get the cursor position at the given pos.
455
461
  *
@@ -1264,6 +1270,10 @@ interface LoroText {
1264
1270
  insert(pos: number, text: string): void;
1265
1271
  delete(pos: number, len: number): void;
1266
1272
  subscribe(listener: Listener): Subscription;
1273
+ /**
1274
+ * Convert a position between coordinate systems.
1275
+ */
1276
+ convertPos(index: number, from: TextPosType, to: TextPosType): number | undefined;
1267
1277
  /**
1268
1278
  * Update the current text to the target text.
1269
1279
  *
@@ -3035,6 +3045,14 @@ export class LoroText {
3035
3045
  * ```
3036
3046
  */
3037
3047
  applyDelta(delta: Delta<string>[]): void;
3048
+ /**
3049
+ * Convert a position between coordinate systems.
3050
+ *
3051
+ * Supported values: `"unicode"`, `"utf16"`, `"utf8"`.
3052
+ *
3053
+ * Returns `undefined` when out of bounds or unsupported.
3054
+ */
3055
+ convertPos(index: number, from: string, to: string): any;
3038
3056
  /**
3039
3057
  * Delete elements from index to utf-8 index + len
3040
3058
  *