loro-crdt 1.2.1 → 1.2.3
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/CHANGELOG.md +17 -0
- package/base64/index.js +266 -38
- package/base64/loro_wasm.d.ts +215 -22
- package/base64/loro_wasm_bg-c9740ed0.js +64 -0
- package/bundler/index.js +47 -0
- package/bundler/index.js.map +1 -1
- package/bundler/loro_wasm.d.ts +215 -22
- package/bundler/loro_wasm_bg.js +219 -38
- package/bundler/loro_wasm_bg.wasm +0 -0
- package/bundler/loro_wasm_bg.wasm.d.ts +7 -0
- package/nodejs/index.js +47 -0
- package/nodejs/index.js.map +1 -1
- package/nodejs/loro_wasm.d.ts +215 -22
- package/nodejs/loro_wasm.js +219 -38
- package/nodejs/loro_wasm_bg.wasm +0 -0
- package/nodejs/loro_wasm_bg.wasm.d.ts +7 -0
- package/package.json +1 -1
- package/web/index.js +47 -0
- package/web/index.js.map +1 -1
- package/web/loro_wasm.d.ts +222 -22
- package/web/loro_wasm.js +218 -37
- package/web/loro_wasm_bg.wasm +0 -0
- package/web/loro_wasm_bg.wasm.d.ts +7 -0
- package/base64/loro_wasm_bg-101e42d1.js +0 -64
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 42949c0: Fix VersionVector ownership issue in WASM binding
|
|
8
|
+
- 1ca1275: feat: UndoManager's onPush now can access the change event
|
|
9
|
+
|
|
10
|
+
## 1.2.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 3b7a738: Add getShallowValue and toJsonWIthReplacer
|
|
15
|
+
|
|
16
|
+
- Add getShallowValue for each container (#581)
|
|
17
|
+
- Implement toJsonWithReplacer method for LoroDoc to customize JSON serialization (#582)
|
|
18
|
+
- Rename importUpdateBatch into importBatch & refine type (#580)
|
|
19
|
+
|
|
3
20
|
## 1.2.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/base64/index.js
CHANGED
|
@@ -861,6 +861,14 @@ class LoroCounter {
|
|
|
861
861
|
const ret = wasm.lorocounter_getAttached(this.__wbg_ptr);
|
|
862
862
|
return takeObject(ret);
|
|
863
863
|
}
|
|
864
|
+
/**
|
|
865
|
+
* Get the value of the counter.
|
|
866
|
+
* @returns {number}
|
|
867
|
+
*/
|
|
868
|
+
getShallowValue() {
|
|
869
|
+
const ret = wasm.lorocounter_getShallowValue(this.__wbg_ptr);
|
|
870
|
+
return ret;
|
|
871
|
+
}
|
|
864
872
|
}
|
|
865
873
|
|
|
866
874
|
const LoroDocFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -1807,18 +1815,13 @@ class LoroDoc {
|
|
|
1807
1815
|
* // get updates from specific version to the latest version
|
|
1808
1816
|
* const updates2 = doc.exportFrom(version);
|
|
1809
1817
|
* ```
|
|
1810
|
-
* @param {
|
|
1818
|
+
* @param {any} vv
|
|
1811
1819
|
* @returns {Uint8Array}
|
|
1812
1820
|
*/
|
|
1813
1821
|
exportFrom(vv) {
|
|
1814
1822
|
try {
|
|
1815
1823
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1816
|
-
|
|
1817
|
-
if (!isLikeNone(vv)) {
|
|
1818
|
-
_assertClass(vv, VersionVector);
|
|
1819
|
-
ptr0 = vv.__destroy_into_raw();
|
|
1820
|
-
}
|
|
1821
|
-
wasm.lorodoc_exportFrom(retptr, this.__wbg_ptr, ptr0);
|
|
1824
|
+
wasm.lorodoc_exportFrom(retptr, this.__wbg_ptr, addHeapObject(vv));
|
|
1822
1825
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
1823
1826
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
1824
1827
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -1826,9 +1829,9 @@ class LoroDoc {
|
|
|
1826
1829
|
if (r3) {
|
|
1827
1830
|
throw takeObject(r2);
|
|
1828
1831
|
}
|
|
1829
|
-
var
|
|
1832
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1830
1833
|
wasm.__wbindgen_export_5(r0, r1 * 1, 1);
|
|
1831
|
-
return
|
|
1834
|
+
return v1;
|
|
1832
1835
|
} finally {
|
|
1833
1836
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1834
1837
|
}
|
|
@@ -1892,24 +1895,14 @@ class LoroDoc {
|
|
|
1892
1895
|
}
|
|
1893
1896
|
/**
|
|
1894
1897
|
* Export updates in the given range in JSON format.
|
|
1895
|
-
* @param {
|
|
1896
|
-
* @param {
|
|
1898
|
+
* @param {any} start_vv
|
|
1899
|
+
* @param {any} end_vv
|
|
1897
1900
|
* @returns {JsonSchema}
|
|
1898
1901
|
*/
|
|
1899
1902
|
exportJsonUpdates(start_vv, end_vv) {
|
|
1900
1903
|
try {
|
|
1901
1904
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1902
|
-
|
|
1903
|
-
if (!isLikeNone(start_vv)) {
|
|
1904
|
-
_assertClass(start_vv, VersionVector);
|
|
1905
|
-
ptr0 = start_vv.__destroy_into_raw();
|
|
1906
|
-
}
|
|
1907
|
-
let ptr1 = 0;
|
|
1908
|
-
if (!isLikeNone(end_vv)) {
|
|
1909
|
-
_assertClass(end_vv, VersionVector);
|
|
1910
|
-
ptr1 = end_vv.__destroy_into_raw();
|
|
1911
|
-
}
|
|
1912
|
-
wasm.lorodoc_exportJsonUpdates(retptr, this.__wbg_ptr, ptr0, ptr1);
|
|
1905
|
+
wasm.lorodoc_exportJsonUpdates(retptr, this.__wbg_ptr, addHeapObject(start_vv), addHeapObject(end_vv));
|
|
1913
1906
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
1914
1907
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
1915
1908
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -1987,10 +1980,12 @@ class LoroDoc {
|
|
|
1987
1980
|
}
|
|
1988
1981
|
}
|
|
1989
1982
|
/**
|
|
1990
|
-
* Import a batch of updates.
|
|
1983
|
+
* Import a batch of updates and snapshots.
|
|
1991
1984
|
*
|
|
1992
1985
|
* It's more efficient than importing updates one by one.
|
|
1993
1986
|
*
|
|
1987
|
+
* @deprecated Use `importBatch` instead.
|
|
1988
|
+
*
|
|
1994
1989
|
* @example
|
|
1995
1990
|
* ```ts
|
|
1996
1991
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -2001,9 +1996,9 @@ class LoroDoc {
|
|
|
2001
1996
|
* const updates = doc.export({ mode: "update" });
|
|
2002
1997
|
* const snapshot = doc.export({ mode: "snapshot" });
|
|
2003
1998
|
* const doc2 = new LoroDoc();
|
|
2004
|
-
* doc2.
|
|
1999
|
+
* doc2.importBatch([snapshot, updates]);
|
|
2005
2000
|
* ```
|
|
2006
|
-
* @param {
|
|
2001
|
+
* @param {Uint8Array[]} data
|
|
2007
2002
|
* @returns {ImportStatus}
|
|
2008
2003
|
*/
|
|
2009
2004
|
importUpdateBatch(data) {
|
|
@@ -2022,8 +2017,46 @@ class LoroDoc {
|
|
|
2022
2017
|
}
|
|
2023
2018
|
}
|
|
2024
2019
|
/**
|
|
2020
|
+
* Import a batch of updates or snapshots.
|
|
2021
|
+
*
|
|
2022
|
+
* It's more efficient than importing updates one by one.
|
|
2023
|
+
*
|
|
2024
|
+
* @example
|
|
2025
|
+
* ```ts
|
|
2026
|
+
* import { LoroDoc } from "loro-crdt";
|
|
2027
|
+
*
|
|
2028
|
+
* const doc = new LoroDoc();
|
|
2029
|
+
* const text = doc.getText("text");
|
|
2030
|
+
* text.insert(0, "Hello");
|
|
2031
|
+
* const updates = doc.export({ mode: "update" });
|
|
2032
|
+
* const snapshot = doc.export({ mode: "snapshot" });
|
|
2033
|
+
* const doc2 = new LoroDoc();
|
|
2034
|
+
* doc2.importBatch([snapshot, updates]);
|
|
2035
|
+
* ```
|
|
2036
|
+
* @param {Uint8Array[]} data
|
|
2037
|
+
* @returns {ImportStatus}
|
|
2038
|
+
*/
|
|
2039
|
+
importBatch(data) {
|
|
2040
|
+
try {
|
|
2041
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2042
|
+
wasm.lorodoc_importBatch(retptr, this.__wbg_ptr, addHeapObject(data));
|
|
2043
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
2044
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
2045
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
2046
|
+
if (r2) {
|
|
2047
|
+
throw takeObject(r1);
|
|
2048
|
+
}
|
|
2049
|
+
return takeObject(r0);
|
|
2050
|
+
} finally {
|
|
2051
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
/**
|
|
2025
2055
|
* Get the shallow json format of the document state.
|
|
2026
2056
|
*
|
|
2057
|
+
* Unlike `toJSON()` which recursively resolves all containers to their values,
|
|
2058
|
+
* `getShallowValue()` returns container IDs as strings for any nested containers.
|
|
2059
|
+
*
|
|
2027
2060
|
* @example
|
|
2028
2061
|
* ```ts
|
|
2029
2062
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -2033,12 +2066,17 @@ class LoroDoc {
|
|
|
2033
2066
|
* const tree = doc.getTree("tree");
|
|
2034
2067
|
* const map = doc.getMap("map");
|
|
2035
2068
|
* const shallowValue = doc.getShallowValue();
|
|
2036
|
-
* /*
|
|
2037
|
-
* {"list": ..., "tree": ..., "map": ...}
|
|
2038
|
-
* *\/
|
|
2039
2069
|
* console.log(shallowValue);
|
|
2070
|
+
* // {
|
|
2071
|
+
* // list: 'cid:root-list:List',
|
|
2072
|
+
* // tree: 'cid:root-tree:Tree',
|
|
2073
|
+
* // map: 'cid:root-map:Map'
|
|
2074
|
+
* // }
|
|
2075
|
+
*
|
|
2076
|
+
* // It points to the same container as `list`
|
|
2077
|
+
* const listB = doc.getContainerById(shallowValue.list);
|
|
2040
2078
|
* ```
|
|
2041
|
-
* @returns {
|
|
2079
|
+
* @returns {Record<string, ContainerID>}
|
|
2042
2080
|
*/
|
|
2043
2081
|
getShallowValue() {
|
|
2044
2082
|
try {
|
|
@@ -2058,9 +2096,12 @@ class LoroDoc {
|
|
|
2058
2096
|
/**
|
|
2059
2097
|
* Get the json format of the entire document state.
|
|
2060
2098
|
*
|
|
2099
|
+
* Unlike `getShallowValue()` which returns container IDs as strings,
|
|
2100
|
+
* `toJSON()` recursively resolves all containers to their actual values.
|
|
2101
|
+
*
|
|
2061
2102
|
* @example
|
|
2062
2103
|
* ```ts
|
|
2063
|
-
* import { LoroDoc, LoroText
|
|
2104
|
+
* import { LoroDoc, LoroText } from "loro-crdt";
|
|
2064
2105
|
*
|
|
2065
2106
|
* const doc = new LoroDoc();
|
|
2066
2107
|
* const list = doc.getList("list");
|
|
@@ -2069,10 +2110,8 @@ class LoroDoc {
|
|
|
2069
2110
|
* text.insert(0, "Hello");
|
|
2070
2111
|
* const map = list.insertContainer(1, new LoroMap());
|
|
2071
2112
|
* map.set("foo", "bar");
|
|
2072
|
-
* /*
|
|
2073
|
-
* {"list": ["Hello", {"foo": "bar"}]}
|
|
2074
|
-
* *\/
|
|
2075
2113
|
* console.log(doc.toJSON());
|
|
2114
|
+
* // {"list": ["Hello", {"foo": "bar"}]}
|
|
2076
2115
|
* ```
|
|
2077
2116
|
* @returns {any}
|
|
2078
2117
|
*/
|
|
@@ -2827,6 +2866,29 @@ class LoroList {
|
|
|
2827
2866
|
const ret = wasm.lorolist_isDeleted(this.__wbg_ptr);
|
|
2828
2867
|
return ret !== 0;
|
|
2829
2868
|
}
|
|
2869
|
+
/**
|
|
2870
|
+
* Get the shallow value of the list.
|
|
2871
|
+
*
|
|
2872
|
+
* Unlike `toJSON()` which recursively resolves all containers to their values,
|
|
2873
|
+
* `getShallowValue()` returns container IDs as strings for any nested containers.
|
|
2874
|
+
*
|
|
2875
|
+
* ```js
|
|
2876
|
+
* const doc = new LoroDoc();
|
|
2877
|
+
* doc.setPeerId("1");
|
|
2878
|
+
* const list = doc.getList("list");
|
|
2879
|
+
* list.insert(0, 1);
|
|
2880
|
+
* list.insert(1, "two");
|
|
2881
|
+
* const subList = list.insertContainer(2, new LoroList());
|
|
2882
|
+
* subList.insert(0, "sub");
|
|
2883
|
+
* list.getShallowValue(); // [1, "two", "cid:2@1:List"]
|
|
2884
|
+
* list.toJSON(); // [1, "two", ["sub"]]
|
|
2885
|
+
* ```
|
|
2886
|
+
* @returns {Value[]}
|
|
2887
|
+
*/
|
|
2888
|
+
getShallowValue() {
|
|
2889
|
+
const ret = wasm.lorolist_getShallowValue(this.__wbg_ptr);
|
|
2890
|
+
return takeObject(ret);
|
|
2891
|
+
}
|
|
2830
2892
|
}
|
|
2831
2893
|
|
|
2832
2894
|
const LoroMapFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -3277,6 +3339,37 @@ class LoroMap {
|
|
|
3277
3339
|
const ret = wasm.loromap_isDeleted(this.__wbg_ptr);
|
|
3278
3340
|
return ret !== 0;
|
|
3279
3341
|
}
|
|
3342
|
+
/**
|
|
3343
|
+
* Get the shallow value of the map.
|
|
3344
|
+
*
|
|
3345
|
+
* Unlike `toJSON()` which recursively resolves all containers to their values,
|
|
3346
|
+
* `getShallowValue()` returns container IDs as strings for any nested containers.
|
|
3347
|
+
*
|
|
3348
|
+
* @example
|
|
3349
|
+
* ```ts
|
|
3350
|
+
* import { LoroDoc } from "loro-crdt";
|
|
3351
|
+
*
|
|
3352
|
+
* const doc = new LoroDoc();
|
|
3353
|
+
* doc.setPeerId("1");
|
|
3354
|
+
* const map = doc.getMap("map");
|
|
3355
|
+
* map.set("key", "value");
|
|
3356
|
+
* const subText = map.setContainer("text", new LoroText());
|
|
3357
|
+
* subText.insert(0, "Hello");
|
|
3358
|
+
*
|
|
3359
|
+
* // Get shallow value - nested containers are represented by their IDs
|
|
3360
|
+
* console.log(map.getShallowValue());
|
|
3361
|
+
* // Output: { key: "value", text: "cid:1@1:Text" }
|
|
3362
|
+
*
|
|
3363
|
+
* // Get full value with nested containers resolved by `toJSON()`
|
|
3364
|
+
* console.log(map.toJSON());
|
|
3365
|
+
* // Output: { key: "value", text: "Hello" }
|
|
3366
|
+
* ```
|
|
3367
|
+
* @returns {Record<string, Value>}
|
|
3368
|
+
*/
|
|
3369
|
+
getShallowValue() {
|
|
3370
|
+
const ret = wasm.loromap_getShallowValue(this.__wbg_ptr);
|
|
3371
|
+
return takeObject(ret);
|
|
3372
|
+
}
|
|
3280
3373
|
}
|
|
3281
3374
|
|
|
3282
3375
|
const LoroMovableListFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -3784,6 +3877,29 @@ class LoroMovableList {
|
|
|
3784
3877
|
const ret = wasm.loromovablelist_isDeleted(this.__wbg_ptr);
|
|
3785
3878
|
return ret !== 0;
|
|
3786
3879
|
}
|
|
3880
|
+
/**
|
|
3881
|
+
* Get the shallow value of the movable list.
|
|
3882
|
+
*
|
|
3883
|
+
* Unlike `toJSON()` which recursively resolves all containers to their values,
|
|
3884
|
+
* `getShallowValue()` returns container IDs as strings for any nested containers.
|
|
3885
|
+
*
|
|
3886
|
+
* ```js
|
|
3887
|
+
* const doc = new LoroDoc();
|
|
3888
|
+
* doc.setPeerId("1");
|
|
3889
|
+
* const list = doc.getMovableList("list");
|
|
3890
|
+
* list.insert(0, 1);
|
|
3891
|
+
* list.insert(1, "two");
|
|
3892
|
+
* const subList = list.insertContainer(2, new LoroList());
|
|
3893
|
+
* subList.insert(0, "sub");
|
|
3894
|
+
* list.getShallowValue(); // [1, "two", "cid:2@1:List"]
|
|
3895
|
+
* list.toJSON(); // [1, "two", ["sub"]]
|
|
3896
|
+
* ```
|
|
3897
|
+
* @returns {Value[]}
|
|
3898
|
+
*/
|
|
3899
|
+
getShallowValue() {
|
|
3900
|
+
const ret = wasm.loromovablelist_getShallowValue(this.__wbg_ptr);
|
|
3901
|
+
return takeObject(ret);
|
|
3902
|
+
}
|
|
3787
3903
|
}
|
|
3788
3904
|
|
|
3789
3905
|
const LoroTextFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -4439,6 +4555,26 @@ class LoroText {
|
|
|
4439
4555
|
const ret = wasm.lorotext_isDeleted(this.__wbg_ptr);
|
|
4440
4556
|
return ret !== 0;
|
|
4441
4557
|
}
|
|
4558
|
+
/**
|
|
4559
|
+
* Get the shallow value of the text. This equals to `text.toString()`.
|
|
4560
|
+
* @returns {string}
|
|
4561
|
+
*/
|
|
4562
|
+
getShallowValue() {
|
|
4563
|
+
let deferred1_0;
|
|
4564
|
+
let deferred1_1;
|
|
4565
|
+
try {
|
|
4566
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
4567
|
+
wasm.lorotext_getShallowValue(retptr, this.__wbg_ptr);
|
|
4568
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
4569
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
4570
|
+
deferred1_0 = r0;
|
|
4571
|
+
deferred1_1 = r1;
|
|
4572
|
+
return getStringFromWasm0(r0, r1);
|
|
4573
|
+
} finally {
|
|
4574
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
4575
|
+
wasm.__wbindgen_export_5(deferred1_0, deferred1_1, 1);
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4442
4578
|
}
|
|
4443
4579
|
|
|
4444
4580
|
const LoroTreeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -4886,6 +5022,51 @@ class LoroTree {
|
|
|
4886
5022
|
const ret = wasm.lorotree_isDeleted(this.__wbg_ptr);
|
|
4887
5023
|
return ret !== 0;
|
|
4888
5024
|
}
|
|
5025
|
+
/**
|
|
5026
|
+
* Get the shallow value of the tree.
|
|
5027
|
+
*
|
|
5028
|
+
* Unlike `toJSON()` which recursively resolves nested containers to their values,
|
|
5029
|
+
* `getShallowValue()` returns container IDs as strings for any nested containers.
|
|
5030
|
+
*
|
|
5031
|
+
* @example
|
|
5032
|
+
* ```ts
|
|
5033
|
+
* const doc = new LoroDoc();
|
|
5034
|
+
* doc.setPeerId("1");
|
|
5035
|
+
* const tree = doc.getTree("tree");
|
|
5036
|
+
* const root = tree.createNode();
|
|
5037
|
+
* root.data.set("name", "root");
|
|
5038
|
+
* const text = root.data.setContainer("content", new LoroText());
|
|
5039
|
+
* text.insert(0, "Hello");
|
|
5040
|
+
*
|
|
5041
|
+
* console.log(tree.getShallowValue());
|
|
5042
|
+
* // [{
|
|
5043
|
+
* // id: "0@1",
|
|
5044
|
+
* // parent: null,
|
|
5045
|
+
* // index: 0,
|
|
5046
|
+
* // fractional_index: "80",
|
|
5047
|
+
* // meta: "cid:0@1:Map",
|
|
5048
|
+
* // children: []
|
|
5049
|
+
* // }]
|
|
5050
|
+
*
|
|
5051
|
+
* console.log(tree.toJSON());
|
|
5052
|
+
* // [{
|
|
5053
|
+
* // id: "0@1",
|
|
5054
|
+
* // parent: null,
|
|
5055
|
+
* // index: 0,
|
|
5056
|
+
* // fractional_index: "80",
|
|
5057
|
+
* // meta: {
|
|
5058
|
+
* // name: "root",
|
|
5059
|
+
* // content: "Hello"
|
|
5060
|
+
* // },
|
|
5061
|
+
* // children: []
|
|
5062
|
+
* // }]
|
|
5063
|
+
* ```
|
|
5064
|
+
* @returns {TreeNodeShallowValue[]}
|
|
5065
|
+
*/
|
|
5066
|
+
getShallowValue() {
|
|
5067
|
+
const ret = wasm.lorotree_getShallowValue(this.__wbg_ptr);
|
|
5068
|
+
return takeObject(ret);
|
|
5069
|
+
}
|
|
4889
5070
|
}
|
|
4890
5071
|
|
|
4891
5072
|
const LoroTreeNodeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -5753,6 +5934,10 @@ function __wbindgen_is_string(arg0) {
|
|
|
5753
5934
|
const ret = typeof(getObject(arg0)) === 'string';
|
|
5754
5935
|
return ret;
|
|
5755
5936
|
}
|
|
5937
|
+
function __wbindgen_is_null(arg0) {
|
|
5938
|
+
const ret = getObject(arg0) === null;
|
|
5939
|
+
return ret;
|
|
5940
|
+
}
|
|
5756
5941
|
function __wbindgen_number_new(arg0) {
|
|
5757
5942
|
const ret = arg0;
|
|
5758
5943
|
return addHeapObject(ret);
|
|
@@ -5761,10 +5946,6 @@ function __wbindgen_typeof(arg0) {
|
|
|
5761
5946
|
const ret = typeof getObject(arg0);
|
|
5762
5947
|
return addHeapObject(ret);
|
|
5763
5948
|
}
|
|
5764
|
-
function __wbindgen_is_null(arg0) {
|
|
5765
|
-
const ret = getObject(arg0) === null;
|
|
5766
|
-
return ret;
|
|
5767
|
-
}
|
|
5768
5949
|
function __wbg_error_c8c2cca30a630316(arg0, arg1) {
|
|
5769
5950
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
5770
5951
|
}
|
|
@@ -6257,7 +6438,7 @@ var imports = /*#__PURE__*/Object.freeze({
|
|
|
6257
6438
|
// Without this patch, Cloudflare Worker would raise issue like: "Uncaught TypeError: wasm2.__wbindgen_start is not a function"
|
|
6258
6439
|
|
|
6259
6440
|
|
|
6260
|
-
import loro_wasm_bg_js from './loro_wasm_bg-
|
|
6441
|
+
import loro_wasm_bg_js from './loro_wasm_bg-c9740ed0.js';
|
|
6261
6442
|
const instance = new WebAssembly.Instance(loro_wasm_bg_js(), {
|
|
6262
6443
|
"./loro_wasm_bg.js": imports,
|
|
6263
6444
|
});
|
|
@@ -6414,5 +6595,52 @@ class Awareness {
|
|
|
6414
6595
|
}, this.timeout / 2);
|
|
6415
6596
|
}
|
|
6416
6597
|
}
|
|
6598
|
+
LoroDoc.prototype.toJsonWithReplacer = function (replacer) {
|
|
6599
|
+
const doc = this;
|
|
6600
|
+
const m = (key, value) => {
|
|
6601
|
+
if (typeof value === "string") {
|
|
6602
|
+
if (isContainerId(value)) {
|
|
6603
|
+
const container = doc.getContainerById(value);
|
|
6604
|
+
if (container == null) {
|
|
6605
|
+
throw new Error(`ContainerID not found: ${value}`);
|
|
6606
|
+
}
|
|
6607
|
+
const ans = replacer(key, container);
|
|
6608
|
+
if (ans === container) {
|
|
6609
|
+
const ans = container.getShallowValue();
|
|
6610
|
+
if (typeof ans === "object") {
|
|
6611
|
+
return run(ans);
|
|
6612
|
+
}
|
|
6613
|
+
return ans;
|
|
6614
|
+
}
|
|
6615
|
+
if (isContainer(ans)) {
|
|
6616
|
+
throw new Error("Using new container is not allowed in toJsonWithReplacer");
|
|
6617
|
+
}
|
|
6618
|
+
return ans;
|
|
6619
|
+
}
|
|
6620
|
+
}
|
|
6621
|
+
const ans = replacer(key, value);
|
|
6622
|
+
if (isContainer(ans)) {
|
|
6623
|
+
throw new Error("Using new container is not allowed in toJsonWithReplacer");
|
|
6624
|
+
}
|
|
6625
|
+
return ans;
|
|
6626
|
+
};
|
|
6627
|
+
const run = (layer) => {
|
|
6628
|
+
if (Array.isArray(layer)) {
|
|
6629
|
+
return layer.map((item, index) => {
|
|
6630
|
+
return m(index, item);
|
|
6631
|
+
}).filter((item) => item !== undefined);
|
|
6632
|
+
}
|
|
6633
|
+
const result = {};
|
|
6634
|
+
for (const [key, value] of Object.entries(layer)) {
|
|
6635
|
+
const ans = m(key, value);
|
|
6636
|
+
if (ans !== undefined) {
|
|
6637
|
+
result[key] = ans;
|
|
6638
|
+
}
|
|
6639
|
+
}
|
|
6640
|
+
return result;
|
|
6641
|
+
};
|
|
6642
|
+
const layer = this.getShallowValue();
|
|
6643
|
+
return run(layer);
|
|
6644
|
+
};
|
|
6417
6645
|
|
|
6418
6646
|
export { Awareness, AwarenessWasm, Cursor, Loro, LoroCounter, LoroDoc, LoroList, LoroMap, LoroMovableList, LoroText, LoroTree, LoroTreeNode, UndoManager, VersionVector, __wbg_String_b9412f8799faab3e, __wbg_apply_0a5aa603881e6d79, __wbg_buffer_12d079cc21e14bdb, __wbg_call_27c0f87801dedf93, __wbg_call_8e7cb608789c2528, __wbg_call_938992c832f74314, __wbg_call_b3ca7c6051f9bec1, __wbg_crypto_1d1f22824a6a080c, __wbg_cursor_new, __wbg_done_298b57d23c0fc80c, __wbg_entries_95cc2c823b285a09, __wbg_entries_ce844941d0c51880, __wbg_error_c8c2cca30a630316, __wbg_error_f851667af71bcfc6, __wbg_getRandomValues_3aa56aa6edec874c, __wbg_get_bd8e338fbd5f5cc8, __wbg_get_e3c254076557e348, __wbg_getindex_03d06b4e7ea3475e, __wbg_getwithrefkey_edc2c8960f0f1191, __wbg_globalThis_d1e6af4856ba331b, __wbg_global_207b558942527489, __wbg_instanceof_ArrayBuffer_836825be07d4c9d2, __wbg_instanceof_Map_87917e0a7aaf4012, __wbg_instanceof_Object_71ca3c0a59266746, __wbg_instanceof_Uint8Array_2b3bbecd033d19f6, __wbg_isArray_2ab64d95e09ea0ae, __wbg_isSafeInteger_f7b04ef02296c4d2, __wbg_iterator_2cee6dadfd956dfa, __wbg_length_c20a40f15020d68a, __wbg_length_cd7af8117672b8b8, __wbg_log_aba5996d9bde071f, __wbg_log_c9486ca5d8e2cbe8, __wbg_log_d8fdbde28117925d, __wbg_lorocounter_new, __wbg_lorolist_new, __wbg_loromap_new, __wbg_loromovablelist_new, __wbg_lorotext_new, __wbg_lorotree_new, __wbg_lorotreenode_new, __wbg_mark_40e050a77cc39fea, __wbg_measure_aa7a73f17813f708, __wbg_msCrypto_eb05e62b530a1508, __wbg_new_16b304a2cfa7ff4a, __wbg_new_63b92bc8671ed464, __wbg_new_72fb9a18b5ae2624, __wbg_new_abda76e883ba8a5f, __wbg_new_d9bc3a0147634640, __wbg_newnoargs_e258087cd0daa0ea, __wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb, __wbg_newwithlength_66ae46612e7f0234, __wbg_newwithlength_e9b4878cebadb3d3, __wbg_next_196c84450b364254, __wbg_next_40fc327bfc8770e6, __wbg_node_104a2ff8d6ea03a2, __wbg_now_11683c634f92ae89, __wbg_ownKeys_658942b7f28d1fe9, __wbg_process_4a72847cc503995b, __wbg_push_a5b05aedc7234f9f, __wbg_randomFillSync_5c9c955aa56b6049, __wbg_require_cca90b1a94a0255b, __wbg_resolve_b0083a7967828ec8, __wbg_self_ce0dbfc45cf2f5be, __wbg_set_1f9b04f170055d33, __wbg_set_8417257aaedc936b, __wbg_set_a47bac70306a19a7, __wbg_set_d4638f722068f043, __wbg_set_f975102236d3c502, __wbg_set_wasm, __wbg_setindex_0b7ede192dc5eca8, __wbg_stack_658279fe44541cf6, __wbg_subarray_a1f73cd4b5b42fe1, __wbg_then_0c86a60e8fcfe9f6, __wbg_value_d93c65011f51a456, __wbg_versions_f686565e586dd935, __wbg_versionvector_new, __wbg_window_c6fb939a7f436783, __wbindgen_as_number, __wbindgen_bigint_from_i64, __wbindgen_bigint_from_u64, __wbindgen_bigint_get_as_i64, __wbindgen_boolean_get, __wbindgen_cb_drop, __wbindgen_closure_wrapper487, __wbindgen_closure_wrapper489, __wbindgen_debug_string, __wbindgen_error_new, __wbindgen_in, __wbindgen_is_bigint, __wbindgen_is_falsy, __wbindgen_is_function, __wbindgen_is_null, __wbindgen_is_object, __wbindgen_is_string, __wbindgen_is_undefined, __wbindgen_jsval_eq, __wbindgen_jsval_loose_eq, __wbindgen_memory, __wbindgen_number_get, __wbindgen_number_new, __wbindgen_object_clone_ref, __wbindgen_object_drop_ref, __wbindgen_rethrow, __wbindgen_string_get, __wbindgen_string_new, __wbindgen_throw, __wbindgen_typeof, decodeFrontiers, decodeImportBlobMeta, encodeFrontiers, getType, isContainer, isContainerId, newContainerID, newRootContainerID, run, setDebug };
|