loro-crdt 1.2.1 → 1.2.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.
- package/CHANGELOG.md +10 -0
- package/base64/index.js +255 -12
- package/base64/loro_wasm.d.ts +206 -14
- package/base64/loro_wasm_bg-8056e30c.js +64 -0
- package/bundler/index.js +47 -0
- package/bundler/index.js.map +1 -1
- package/bundler/loro_wasm.d.ts +206 -14
- package/bundler/loro_wasm_bg.js +207 -11
- 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 +206 -14
- package/nodejs/loro_wasm.js +207 -11
- 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 +213 -14
- package/web/loro_wasm.js +207 -11
- 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/bundler/loro_wasm_bg.js
CHANGED
|
@@ -861,6 +861,14 @@ export 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')
|
|
@@ -1987,10 +1995,12 @@ export class LoroDoc {
|
|
|
1987
1995
|
}
|
|
1988
1996
|
}
|
|
1989
1997
|
/**
|
|
1990
|
-
* Import a batch of updates.
|
|
1998
|
+
* Import a batch of updates and snapshots.
|
|
1991
1999
|
*
|
|
1992
2000
|
* It's more efficient than importing updates one by one.
|
|
1993
2001
|
*
|
|
2002
|
+
* @deprecated Use `importBatch` instead.
|
|
2003
|
+
*
|
|
1994
2004
|
* @example
|
|
1995
2005
|
* ```ts
|
|
1996
2006
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -2001,9 +2011,9 @@ export class LoroDoc {
|
|
|
2001
2011
|
* const updates = doc.export({ mode: "update" });
|
|
2002
2012
|
* const snapshot = doc.export({ mode: "snapshot" });
|
|
2003
2013
|
* const doc2 = new LoroDoc();
|
|
2004
|
-
* doc2.
|
|
2014
|
+
* doc2.importBatch([snapshot, updates]);
|
|
2005
2015
|
* ```
|
|
2006
|
-
* @param {
|
|
2016
|
+
* @param {Uint8Array[]} data
|
|
2007
2017
|
* @returns {ImportStatus}
|
|
2008
2018
|
*/
|
|
2009
2019
|
importUpdateBatch(data) {
|
|
@@ -2022,8 +2032,46 @@ export class LoroDoc {
|
|
|
2022
2032
|
}
|
|
2023
2033
|
}
|
|
2024
2034
|
/**
|
|
2035
|
+
* Import a batch of updates or snapshots.
|
|
2036
|
+
*
|
|
2037
|
+
* It's more efficient than importing updates one by one.
|
|
2038
|
+
*
|
|
2039
|
+
* @example
|
|
2040
|
+
* ```ts
|
|
2041
|
+
* import { LoroDoc } from "loro-crdt";
|
|
2042
|
+
*
|
|
2043
|
+
* const doc = new LoroDoc();
|
|
2044
|
+
* const text = doc.getText("text");
|
|
2045
|
+
* text.insert(0, "Hello");
|
|
2046
|
+
* const updates = doc.export({ mode: "update" });
|
|
2047
|
+
* const snapshot = doc.export({ mode: "snapshot" });
|
|
2048
|
+
* const doc2 = new LoroDoc();
|
|
2049
|
+
* doc2.importBatch([snapshot, updates]);
|
|
2050
|
+
* ```
|
|
2051
|
+
* @param {Uint8Array[]} data
|
|
2052
|
+
* @returns {ImportStatus}
|
|
2053
|
+
*/
|
|
2054
|
+
importBatch(data) {
|
|
2055
|
+
try {
|
|
2056
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2057
|
+
wasm.lorodoc_importBatch(retptr, this.__wbg_ptr, addHeapObject(data));
|
|
2058
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
2059
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
2060
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
2061
|
+
if (r2) {
|
|
2062
|
+
throw takeObject(r1);
|
|
2063
|
+
}
|
|
2064
|
+
return takeObject(r0);
|
|
2065
|
+
} finally {
|
|
2066
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2025
2070
|
* Get the shallow json format of the document state.
|
|
2026
2071
|
*
|
|
2072
|
+
* Unlike `toJSON()` which recursively resolves all containers to their values,
|
|
2073
|
+
* `getShallowValue()` returns container IDs as strings for any nested containers.
|
|
2074
|
+
*
|
|
2027
2075
|
* @example
|
|
2028
2076
|
* ```ts
|
|
2029
2077
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -2033,12 +2081,17 @@ export class LoroDoc {
|
|
|
2033
2081
|
* const tree = doc.getTree("tree");
|
|
2034
2082
|
* const map = doc.getMap("map");
|
|
2035
2083
|
* const shallowValue = doc.getShallowValue();
|
|
2036
|
-
* /*
|
|
2037
|
-
* {"list": ..., "tree": ..., "map": ...}
|
|
2038
|
-
* *\/
|
|
2039
2084
|
* console.log(shallowValue);
|
|
2085
|
+
* // {
|
|
2086
|
+
* // list: 'cid:root-list:List',
|
|
2087
|
+
* // tree: 'cid:root-tree:Tree',
|
|
2088
|
+
* // map: 'cid:root-map:Map'
|
|
2089
|
+
* // }
|
|
2090
|
+
*
|
|
2091
|
+
* // It points to the same container as `list`
|
|
2092
|
+
* const listB = doc.getContainerById(shallowValue.list);
|
|
2040
2093
|
* ```
|
|
2041
|
-
* @returns {
|
|
2094
|
+
* @returns {Record<string, ContainerID>}
|
|
2042
2095
|
*/
|
|
2043
2096
|
getShallowValue() {
|
|
2044
2097
|
try {
|
|
@@ -2058,9 +2111,12 @@ export class LoroDoc {
|
|
|
2058
2111
|
/**
|
|
2059
2112
|
* Get the json format of the entire document state.
|
|
2060
2113
|
*
|
|
2114
|
+
* Unlike `getShallowValue()` which returns container IDs as strings,
|
|
2115
|
+
* `toJSON()` recursively resolves all containers to their actual values.
|
|
2116
|
+
*
|
|
2061
2117
|
* @example
|
|
2062
2118
|
* ```ts
|
|
2063
|
-
* import { LoroDoc, LoroText
|
|
2119
|
+
* import { LoroDoc, LoroText } from "loro-crdt";
|
|
2064
2120
|
*
|
|
2065
2121
|
* const doc = new LoroDoc();
|
|
2066
2122
|
* const list = doc.getList("list");
|
|
@@ -2069,10 +2125,8 @@ export class LoroDoc {
|
|
|
2069
2125
|
* text.insert(0, "Hello");
|
|
2070
2126
|
* const map = list.insertContainer(1, new LoroMap());
|
|
2071
2127
|
* map.set("foo", "bar");
|
|
2072
|
-
* /*
|
|
2073
|
-
* {"list": ["Hello", {"foo": "bar"}]}
|
|
2074
|
-
* *\/
|
|
2075
2128
|
* console.log(doc.toJSON());
|
|
2129
|
+
* // {"list": ["Hello", {"foo": "bar"}]}
|
|
2076
2130
|
* ```
|
|
2077
2131
|
* @returns {any}
|
|
2078
2132
|
*/
|
|
@@ -2827,6 +2881,29 @@ export class LoroList {
|
|
|
2827
2881
|
const ret = wasm.lorolist_isDeleted(this.__wbg_ptr);
|
|
2828
2882
|
return ret !== 0;
|
|
2829
2883
|
}
|
|
2884
|
+
/**
|
|
2885
|
+
* Get the shallow value of the list.
|
|
2886
|
+
*
|
|
2887
|
+
* Unlike `toJSON()` which recursively resolves all containers to their values,
|
|
2888
|
+
* `getShallowValue()` returns container IDs as strings for any nested containers.
|
|
2889
|
+
*
|
|
2890
|
+
* ```js
|
|
2891
|
+
* const doc = new LoroDoc();
|
|
2892
|
+
* doc.setPeerId("1");
|
|
2893
|
+
* const list = doc.getList("list");
|
|
2894
|
+
* list.insert(0, 1);
|
|
2895
|
+
* list.insert(1, "two");
|
|
2896
|
+
* const subList = list.insertContainer(2, new LoroList());
|
|
2897
|
+
* subList.insert(0, "sub");
|
|
2898
|
+
* list.getShallowValue(); // [1, "two", "cid:2@1:List"]
|
|
2899
|
+
* list.toJSON(); // [1, "two", ["sub"]]
|
|
2900
|
+
* ```
|
|
2901
|
+
* @returns {Value[]}
|
|
2902
|
+
*/
|
|
2903
|
+
getShallowValue() {
|
|
2904
|
+
const ret = wasm.lorolist_getShallowValue(this.__wbg_ptr);
|
|
2905
|
+
return takeObject(ret);
|
|
2906
|
+
}
|
|
2830
2907
|
}
|
|
2831
2908
|
|
|
2832
2909
|
const LoroMapFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -3277,6 +3354,37 @@ export class LoroMap {
|
|
|
3277
3354
|
const ret = wasm.loromap_isDeleted(this.__wbg_ptr);
|
|
3278
3355
|
return ret !== 0;
|
|
3279
3356
|
}
|
|
3357
|
+
/**
|
|
3358
|
+
* Get the shallow value of the map.
|
|
3359
|
+
*
|
|
3360
|
+
* Unlike `toJSON()` which recursively resolves all containers to their values,
|
|
3361
|
+
* `getShallowValue()` returns container IDs as strings for any nested containers.
|
|
3362
|
+
*
|
|
3363
|
+
* @example
|
|
3364
|
+
* ```ts
|
|
3365
|
+
* import { LoroDoc } from "loro-crdt";
|
|
3366
|
+
*
|
|
3367
|
+
* const doc = new LoroDoc();
|
|
3368
|
+
* doc.setPeerId("1");
|
|
3369
|
+
* const map = doc.getMap("map");
|
|
3370
|
+
* map.set("key", "value");
|
|
3371
|
+
* const subText = map.setContainer("text", new LoroText());
|
|
3372
|
+
* subText.insert(0, "Hello");
|
|
3373
|
+
*
|
|
3374
|
+
* // Get shallow value - nested containers are represented by their IDs
|
|
3375
|
+
* console.log(map.getShallowValue());
|
|
3376
|
+
* // Output: { key: "value", text: "cid:1@1:Text" }
|
|
3377
|
+
*
|
|
3378
|
+
* // Get full value with nested containers resolved by `toJSON()`
|
|
3379
|
+
* console.log(map.toJSON());
|
|
3380
|
+
* // Output: { key: "value", text: "Hello" }
|
|
3381
|
+
* ```
|
|
3382
|
+
* @returns {Record<string, Value>}
|
|
3383
|
+
*/
|
|
3384
|
+
getShallowValue() {
|
|
3385
|
+
const ret = wasm.loromap_getShallowValue(this.__wbg_ptr);
|
|
3386
|
+
return takeObject(ret);
|
|
3387
|
+
}
|
|
3280
3388
|
}
|
|
3281
3389
|
|
|
3282
3390
|
const LoroMovableListFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -3784,6 +3892,29 @@ export class LoroMovableList {
|
|
|
3784
3892
|
const ret = wasm.loromovablelist_isDeleted(this.__wbg_ptr);
|
|
3785
3893
|
return ret !== 0;
|
|
3786
3894
|
}
|
|
3895
|
+
/**
|
|
3896
|
+
* Get the shallow value of the movable list.
|
|
3897
|
+
*
|
|
3898
|
+
* Unlike `toJSON()` which recursively resolves all containers to their values,
|
|
3899
|
+
* `getShallowValue()` returns container IDs as strings for any nested containers.
|
|
3900
|
+
*
|
|
3901
|
+
* ```js
|
|
3902
|
+
* const doc = new LoroDoc();
|
|
3903
|
+
* doc.setPeerId("1");
|
|
3904
|
+
* const list = doc.getMovableList("list");
|
|
3905
|
+
* list.insert(0, 1);
|
|
3906
|
+
* list.insert(1, "two");
|
|
3907
|
+
* const subList = list.insertContainer(2, new LoroList());
|
|
3908
|
+
* subList.insert(0, "sub");
|
|
3909
|
+
* list.getShallowValue(); // [1, "two", "cid:2@1:List"]
|
|
3910
|
+
* list.toJSON(); // [1, "two", ["sub"]]
|
|
3911
|
+
* ```
|
|
3912
|
+
* @returns {Value[]}
|
|
3913
|
+
*/
|
|
3914
|
+
getShallowValue() {
|
|
3915
|
+
const ret = wasm.loromovablelist_getShallowValue(this.__wbg_ptr);
|
|
3916
|
+
return takeObject(ret);
|
|
3917
|
+
}
|
|
3787
3918
|
}
|
|
3788
3919
|
|
|
3789
3920
|
const LoroTextFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -4439,6 +4570,26 @@ export class LoroText {
|
|
|
4439
4570
|
const ret = wasm.lorotext_isDeleted(this.__wbg_ptr);
|
|
4440
4571
|
return ret !== 0;
|
|
4441
4572
|
}
|
|
4573
|
+
/**
|
|
4574
|
+
* Get the shallow value of the text. This equals to `text.toString()`.
|
|
4575
|
+
* @returns {string}
|
|
4576
|
+
*/
|
|
4577
|
+
getShallowValue() {
|
|
4578
|
+
let deferred1_0;
|
|
4579
|
+
let deferred1_1;
|
|
4580
|
+
try {
|
|
4581
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
4582
|
+
wasm.lorotext_getShallowValue(retptr, this.__wbg_ptr);
|
|
4583
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
4584
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
4585
|
+
deferred1_0 = r0;
|
|
4586
|
+
deferred1_1 = r1;
|
|
4587
|
+
return getStringFromWasm0(r0, r1);
|
|
4588
|
+
} finally {
|
|
4589
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
4590
|
+
wasm.__wbindgen_export_5(deferred1_0, deferred1_1, 1);
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4442
4593
|
}
|
|
4443
4594
|
|
|
4444
4595
|
const LoroTreeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -4886,6 +5037,51 @@ export class LoroTree {
|
|
|
4886
5037
|
const ret = wasm.lorotree_isDeleted(this.__wbg_ptr);
|
|
4887
5038
|
return ret !== 0;
|
|
4888
5039
|
}
|
|
5040
|
+
/**
|
|
5041
|
+
* Get the shallow value of the tree.
|
|
5042
|
+
*
|
|
5043
|
+
* Unlike `toJSON()` which recursively resolves nested containers to their values,
|
|
5044
|
+
* `getShallowValue()` returns container IDs as strings for any nested containers.
|
|
5045
|
+
*
|
|
5046
|
+
* @example
|
|
5047
|
+
* ```ts
|
|
5048
|
+
* const doc = new LoroDoc();
|
|
5049
|
+
* doc.setPeerId("1");
|
|
5050
|
+
* const tree = doc.getTree("tree");
|
|
5051
|
+
* const root = tree.createNode();
|
|
5052
|
+
* root.data.set("name", "root");
|
|
5053
|
+
* const text = root.data.setContainer("content", new LoroText());
|
|
5054
|
+
* text.insert(0, "Hello");
|
|
5055
|
+
*
|
|
5056
|
+
* console.log(tree.getShallowValue());
|
|
5057
|
+
* // [{
|
|
5058
|
+
* // id: "0@1",
|
|
5059
|
+
* // parent: null,
|
|
5060
|
+
* // index: 0,
|
|
5061
|
+
* // fractional_index: "80",
|
|
5062
|
+
* // meta: "cid:0@1:Map",
|
|
5063
|
+
* // children: []
|
|
5064
|
+
* // }]
|
|
5065
|
+
*
|
|
5066
|
+
* console.log(tree.toJSON());
|
|
5067
|
+
* // [{
|
|
5068
|
+
* // id: "0@1",
|
|
5069
|
+
* // parent: null,
|
|
5070
|
+
* // index: 0,
|
|
5071
|
+
* // fractional_index: "80",
|
|
5072
|
+
* // meta: {
|
|
5073
|
+
* // name: "root",
|
|
5074
|
+
* // content: "Hello"
|
|
5075
|
+
* // },
|
|
5076
|
+
* // children: []
|
|
5077
|
+
* // }]
|
|
5078
|
+
* ```
|
|
5079
|
+
* @returns {TreeNodeShallowValue[]}
|
|
5080
|
+
*/
|
|
5081
|
+
getShallowValue() {
|
|
5082
|
+
const ret = wasm.lorotree_getShallowValue(this.__wbg_ptr);
|
|
5083
|
+
return takeObject(ret);
|
|
5084
|
+
}
|
|
4889
5085
|
}
|
|
4890
5086
|
|
|
4891
5087
|
const LoroTreeNodeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
Binary file
|
|
@@ -10,6 +10,7 @@ export function lorocounter_subscribe(a: number, b: number, c: number): void;
|
|
|
10
10
|
export function lorocounter_parent(a: number): number;
|
|
11
11
|
export function lorocounter_isAttached(a: number): number;
|
|
12
12
|
export function lorocounter_getAttached(a: number): number;
|
|
13
|
+
export function lorocounter_getShallowValue(a: number): number;
|
|
13
14
|
export function __wbg_awarenesswasm_free(a: number): void;
|
|
14
15
|
export function awarenesswasm_new(a: number, b: number): number;
|
|
15
16
|
export function awarenesswasm_encode(a: number, b: number, c: number): void;
|
|
@@ -76,6 +77,7 @@ export function lorodoc_exportJsonUpdates(a: number, b: number, c: number, d: nu
|
|
|
76
77
|
export function lorodoc_importJsonUpdates(a: number, b: number, c: number): void;
|
|
77
78
|
export function lorodoc_import(a: number, b: number, c: number, d: number): void;
|
|
78
79
|
export function lorodoc_importUpdateBatch(a: number, b: number, c: number): void;
|
|
80
|
+
export function lorodoc_importBatch(a: number, b: number, c: number): void;
|
|
79
81
|
export function lorodoc_getShallowValue(a: number, b: number): void;
|
|
80
82
|
export function lorodoc_toJSON(a: number, b: number): void;
|
|
81
83
|
export function lorodoc_subscribe(a: number, b: number): number;
|
|
@@ -119,6 +121,7 @@ export function lorotext_getCursor(a: number, b: number, c: number): number;
|
|
|
119
121
|
export function lorotext_push(a: number, b: number, c: number, d: number): void;
|
|
120
122
|
export function lorotext_getEditorOf(a: number, b: number): number;
|
|
121
123
|
export function lorotext_isDeleted(a: number): number;
|
|
124
|
+
export function lorotext_getShallowValue(a: number, b: number): void;
|
|
122
125
|
export function __wbg_loromap_free(a: number): void;
|
|
123
126
|
export function loromap_new(): number;
|
|
124
127
|
export function loromap_kind(a: number): number;
|
|
@@ -139,6 +142,7 @@ export function loromap_getAttached(a: number): number;
|
|
|
139
142
|
export function loromap_clear(a: number, b: number): void;
|
|
140
143
|
export function loromap_getLastEditor(a: number, b: number, c: number): number;
|
|
141
144
|
export function loromap_isDeleted(a: number): number;
|
|
145
|
+
export function loromap_getShallowValue(a: number): number;
|
|
142
146
|
export function __wbg_lorolist_free(a: number): void;
|
|
143
147
|
export function lorolist_new(): number;
|
|
144
148
|
export function lorolist_kind(a: number): number;
|
|
@@ -161,6 +165,7 @@ export function lorolist_pop(a: number, b: number): void;
|
|
|
161
165
|
export function lorolist_clear(a: number, b: number): void;
|
|
162
166
|
export function lorolist_getIdAt(a: number, b: number): number;
|
|
163
167
|
export function lorolist_isDeleted(a: number): number;
|
|
168
|
+
export function lorolist_getShallowValue(a: number): number;
|
|
164
169
|
export function loromovablelist_new(): number;
|
|
165
170
|
export function loromovablelist_kind(a: number): number;
|
|
166
171
|
export function loromovablelist_insert(a: number, b: number, c: number, d: number): void;
|
|
@@ -185,6 +190,7 @@ export function loromovablelist_getCreatorAt(a: number, b: number): number;
|
|
|
185
190
|
export function loromovablelist_getLastMoverAt(a: number, b: number): number;
|
|
186
191
|
export function loromovablelist_getLastEditorAt(a: number, b: number): number;
|
|
187
192
|
export function loromovablelist_isDeleted(a: number): number;
|
|
193
|
+
export function loromovablelist_getShallowValue(a: number): number;
|
|
188
194
|
export function __wbg_lorotree_free(a: number): void;
|
|
189
195
|
export function lorotreenode___getClassname(a: number, b: number): void;
|
|
190
196
|
export function __wbg_lorotreenode_free(a: number): void;
|
|
@@ -225,6 +231,7 @@ export function lorotree_enableFractionalIndex(a: number, b: number): void;
|
|
|
225
231
|
export function lorotree_disableFractionalIndex(a: number): void;
|
|
226
232
|
export function lorotree_isFractionalIndexEnabled(a: number): number;
|
|
227
233
|
export function lorotree_isDeleted(a: number): number;
|
|
234
|
+
export function lorotree_getShallowValue(a: number): number;
|
|
228
235
|
export function __wbg_cursor_free(a: number): void;
|
|
229
236
|
export function cursor_containerId(a: number): number;
|
|
230
237
|
export function cursor_pos(a: number): number;
|
package/nodejs/index.js
CHANGED
|
@@ -152,6 +152,53 @@ class Awareness {
|
|
|
152
152
|
}, this.timeout / 2);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
+
loroWasm.LoroDoc.prototype.toJsonWithReplacer = function (replacer) {
|
|
156
|
+
const doc = this;
|
|
157
|
+
const m = (key, value) => {
|
|
158
|
+
if (typeof value === "string") {
|
|
159
|
+
if (isContainerId(value)) {
|
|
160
|
+
const container = doc.getContainerById(value);
|
|
161
|
+
if (container == null) {
|
|
162
|
+
throw new Error(`ContainerID not found: ${value}`);
|
|
163
|
+
}
|
|
164
|
+
const ans = replacer(key, container);
|
|
165
|
+
if (ans === container) {
|
|
166
|
+
const ans = container.getShallowValue();
|
|
167
|
+
if (typeof ans === "object") {
|
|
168
|
+
return run(ans);
|
|
169
|
+
}
|
|
170
|
+
return ans;
|
|
171
|
+
}
|
|
172
|
+
if (isContainer(ans)) {
|
|
173
|
+
throw new Error("Using new container is not allowed in toJsonWithReplacer");
|
|
174
|
+
}
|
|
175
|
+
return ans;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const ans = replacer(key, value);
|
|
179
|
+
if (isContainer(ans)) {
|
|
180
|
+
throw new Error("Using new container is not allowed in toJsonWithReplacer");
|
|
181
|
+
}
|
|
182
|
+
return ans;
|
|
183
|
+
};
|
|
184
|
+
const run = (layer) => {
|
|
185
|
+
if (Array.isArray(layer)) {
|
|
186
|
+
return layer.map((item, index) => {
|
|
187
|
+
return m(index, item);
|
|
188
|
+
}).filter((item) => item !== undefined);
|
|
189
|
+
}
|
|
190
|
+
const result = {};
|
|
191
|
+
for (const [key, value] of Object.entries(layer)) {
|
|
192
|
+
const ans = m(key, value);
|
|
193
|
+
if (ans !== undefined) {
|
|
194
|
+
result[key] = ans;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return result;
|
|
198
|
+
};
|
|
199
|
+
const layer = this.getShallowValue();
|
|
200
|
+
return run(layer);
|
|
201
|
+
};
|
|
155
202
|
|
|
156
203
|
exports.Awareness = Awareness;
|
|
157
204
|
exports.Loro = Loro;
|
package/nodejs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../index.ts"],"sourcesContent":[null],"names":["LoroDoc","AwarenessWasm"],"mappings":";;;;AAmBA;;AAEG;AACG,MAAO,IAAK,SAAQA,gBAAO,CAAA;AAAI,CAAA;AAErC,MAAM,eAAe,GAAG;IACpB,KAAK;IACL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