loro-crdt 1.4.1 → 1.4.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 +7 -0
- package/base64/index.js +67 -21
- package/base64/loro_wasm.d.ts +35 -1
- package/base64/loro_wasm_bg-b04f3476.js +64 -0
- package/bundler/loro_wasm.d.ts +35 -1
- package/bundler/loro_wasm_bg.js +65 -19
- package/bundler/loro_wasm_bg.wasm +0 -0
- package/bundler/loro_wasm_bg.wasm.d.ts +1 -0
- package/nodejs/loro_wasm.d.ts +35 -1
- package/nodejs/loro_wasm.js +65 -19
- package/nodejs/loro_wasm_bg.wasm +0 -0
- package/nodejs/loro_wasm_bg.wasm.d.ts +1 -0
- package/package.json +1 -1
- package/web/loro_wasm.d.ts +36 -1
- package/web/loro_wasm.js +64 -18
- package/web/loro_wasm_bg.wasm +0 -0
- package/web/loro_wasm_bg.wasm.d.ts +1 -0
- package/base64/loro_wasm_bg-4116d6d8.js +0 -64
package/bundler/loro_wasm.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ interface LoroDoc {
|
|
|
109
109
|
* text = doc.getContainerById(textId);
|
|
110
110
|
* ```
|
|
111
111
|
*/
|
|
112
|
-
getContainerById(id: ContainerID): Container;
|
|
112
|
+
getContainerById(id: ContainerID): Container | undefined;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Subscribe to updates from local edits.
|
|
@@ -1859,6 +1859,8 @@ export class LoroDoc {
|
|
|
1859
1859
|
* The object returned is a new js object each time because it need to cross
|
|
1860
1860
|
* the WASM boundary.
|
|
1861
1861
|
*
|
|
1862
|
+
* If the container does not exist, an error will be thrown.
|
|
1863
|
+
*
|
|
1862
1864
|
* @example
|
|
1863
1865
|
* ```ts
|
|
1864
1866
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1872,11 +1874,43 @@ export class LoroDoc {
|
|
|
1872
1874
|
getText(cid: ContainerID | string): LoroText;
|
|
1873
1875
|
/**
|
|
1874
1876
|
* Get a LoroCounter by container id
|
|
1877
|
+
*
|
|
1878
|
+
* If the container does not exist, an error will be thrown.
|
|
1875
1879
|
* @param {ContainerID | string} cid
|
|
1876
1880
|
* @returns {LoroCounter}
|
|
1877
1881
|
*/
|
|
1878
1882
|
getCounter(cid: ContainerID | string): LoroCounter;
|
|
1879
1883
|
/**
|
|
1884
|
+
* Check if the doc contains the target container.
|
|
1885
|
+
*
|
|
1886
|
+
* A root container always exists, while a normal container exists
|
|
1887
|
+
* if it has ever been created on the doc.
|
|
1888
|
+
*
|
|
1889
|
+
* @example
|
|
1890
|
+
* ```ts
|
|
1891
|
+
* import { LoroDoc, LoroMap, LoroText, LoroList } from "loro-crdt";
|
|
1892
|
+
*
|
|
1893
|
+
* const doc = new LoroDoc();
|
|
1894
|
+
* doc.setPeerId("1");
|
|
1895
|
+
* const text = doc.getMap("map").setContainer("text", new LoroText());
|
|
1896
|
+
* const list = doc.getMap("map").setContainer("list", new LoroList());
|
|
1897
|
+
* expect(doc.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1898
|
+
* expect(doc.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1899
|
+
* expect(doc.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1900
|
+
*
|
|
1901
|
+
* const doc2 = new LoroDoc();
|
|
1902
|
+
* // Containers exist, as long as the history or the doc state include it
|
|
1903
|
+
* doc.detach();
|
|
1904
|
+
* doc2.import(doc.export({ mode: "update" }));
|
|
1905
|
+
* expect(doc2.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1906
|
+
* expect(doc2.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1907
|
+
* expect(doc2.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1908
|
+
* ```
|
|
1909
|
+
* @param {ContainerID} container_id
|
|
1910
|
+
* @returns {boolean}
|
|
1911
|
+
*/
|
|
1912
|
+
hasContainer(container_id: ContainerID): boolean;
|
|
1913
|
+
/**
|
|
1880
1914
|
* Set the commit message of the next commit
|
|
1881
1915
|
* @param {string} msg
|
|
1882
1916
|
*/
|
package/bundler/loro_wasm_bg.js
CHANGED
|
@@ -1457,6 +1457,8 @@ export class LoroDoc {
|
|
|
1457
1457
|
* The object returned is a new js object each time because it need to cross
|
|
1458
1458
|
* the WASM boundary.
|
|
1459
1459
|
*
|
|
1460
|
+
* If the container does not exist, an error will be thrown.
|
|
1461
|
+
*
|
|
1460
1462
|
* @example
|
|
1461
1463
|
* ```ts
|
|
1462
1464
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1489,6 +1491,8 @@ export class LoroDoc {
|
|
|
1489
1491
|
* The object returned is a new js object each time because it need to cross
|
|
1490
1492
|
* the WASM boundary.
|
|
1491
1493
|
*
|
|
1494
|
+
* If the container does not exist, an error will be thrown.
|
|
1495
|
+
*
|
|
1492
1496
|
* @example
|
|
1493
1497
|
* ```ts
|
|
1494
1498
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1521,6 +1525,8 @@ export class LoroDoc {
|
|
|
1521
1525
|
* The object returned is a new js object each time because it need to cross
|
|
1522
1526
|
* the WASM boundary.
|
|
1523
1527
|
*
|
|
1528
|
+
* If the container does not exist, an error will be thrown.
|
|
1529
|
+
*
|
|
1524
1530
|
* @example
|
|
1525
1531
|
* ```ts
|
|
1526
1532
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1553,6 +1559,8 @@ export class LoroDoc {
|
|
|
1553
1559
|
* The object returned is a new js object each time because it need to cross
|
|
1554
1560
|
* the WASM boundary.
|
|
1555
1561
|
*
|
|
1562
|
+
* If the container does not exist, an error will be thrown.
|
|
1563
|
+
*
|
|
1556
1564
|
* @example
|
|
1557
1565
|
* ```ts
|
|
1558
1566
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1581,6 +1589,8 @@ export class LoroDoc {
|
|
|
1581
1589
|
}
|
|
1582
1590
|
/**
|
|
1583
1591
|
* Get a LoroCounter by container id
|
|
1592
|
+
*
|
|
1593
|
+
* If the container does not exist, an error will be thrown.
|
|
1584
1594
|
* @param {ContainerID | string} cid
|
|
1585
1595
|
* @returns {LoroCounter}
|
|
1586
1596
|
*/
|
|
@@ -1606,6 +1616,8 @@ export class LoroDoc {
|
|
|
1606
1616
|
* The object returned is a new js object each time because it need to cross
|
|
1607
1617
|
* the WASM boundary.
|
|
1608
1618
|
*
|
|
1619
|
+
* If the container does not exist, an error will be thrown.
|
|
1620
|
+
*
|
|
1609
1621
|
* @example
|
|
1610
1622
|
* ```ts
|
|
1611
1623
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1633,8 +1645,42 @@ export class LoroDoc {
|
|
|
1633
1645
|
}
|
|
1634
1646
|
}
|
|
1635
1647
|
/**
|
|
1636
|
-
*
|
|
1648
|
+
* Check if the doc contains the target container.
|
|
1637
1649
|
*
|
|
1650
|
+
* A root container always exists, while a normal container exists
|
|
1651
|
+
* if it has ever been created on the doc.
|
|
1652
|
+
*
|
|
1653
|
+
* @example
|
|
1654
|
+
* ```ts
|
|
1655
|
+
* import { LoroDoc, LoroMap, LoroText, LoroList } from "loro-crdt";
|
|
1656
|
+
*
|
|
1657
|
+
* const doc = new LoroDoc();
|
|
1658
|
+
* doc.setPeerId("1");
|
|
1659
|
+
* const text = doc.getMap("map").setContainer("text", new LoroText());
|
|
1660
|
+
* const list = doc.getMap("map").setContainer("list", new LoroList());
|
|
1661
|
+
* expect(doc.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1662
|
+
* expect(doc.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1663
|
+
* expect(doc.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1664
|
+
*
|
|
1665
|
+
* const doc2 = new LoroDoc();
|
|
1666
|
+
* // Containers exist, as long as the history or the doc state include it
|
|
1667
|
+
* doc.detach();
|
|
1668
|
+
* doc2.import(doc.export({ mode: "update" }));
|
|
1669
|
+
* expect(doc2.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1670
|
+
* expect(doc2.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1671
|
+
* expect(doc2.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1672
|
+
* ```
|
|
1673
|
+
* @param {ContainerID} container_id
|
|
1674
|
+
* @returns {boolean}
|
|
1675
|
+
*/
|
|
1676
|
+
hasContainer(container_id) {
|
|
1677
|
+
const ret = wasm.lorodoc_hasContainer(this.__wbg_ptr, addHeapObject(container_id));
|
|
1678
|
+
return ret !== 0;
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* Get the container corresponding to the container id.
|
|
1682
|
+
*
|
|
1683
|
+
* If the container does not exist, it returns `undefined`.
|
|
1638
1684
|
*
|
|
1639
1685
|
* @example
|
|
1640
1686
|
* ```ts
|
|
@@ -6013,28 +6059,33 @@ export function __wbindgen_object_drop_ref(arg0) {
|
|
|
6013
6059
|
takeObject(arg0);
|
|
6014
6060
|
};
|
|
6015
6061
|
|
|
6062
|
+
export function __wbg_lorocounter_new(arg0) {
|
|
6063
|
+
const ret = LoroCounter.__wrap(arg0);
|
|
6064
|
+
return addHeapObject(ret);
|
|
6065
|
+
};
|
|
6066
|
+
|
|
6016
6067
|
export function __wbg_lorotreenode_new(arg0) {
|
|
6017
6068
|
const ret = LoroTreeNode.__wrap(arg0);
|
|
6018
6069
|
return addHeapObject(ret);
|
|
6019
6070
|
};
|
|
6020
6071
|
|
|
6021
|
-
export function
|
|
6022
|
-
const ret =
|
|
6072
|
+
export function __wbg_cursor_new(arg0) {
|
|
6073
|
+
const ret = Cursor.__wrap(arg0);
|
|
6023
6074
|
return addHeapObject(ret);
|
|
6024
6075
|
};
|
|
6025
6076
|
|
|
6026
|
-
export function
|
|
6027
|
-
const ret =
|
|
6077
|
+
export function __wbg_loromap_new(arg0) {
|
|
6078
|
+
const ret = LoroMap.__wrap(arg0);
|
|
6028
6079
|
return addHeapObject(ret);
|
|
6029
6080
|
};
|
|
6030
6081
|
|
|
6031
|
-
export function
|
|
6032
|
-
const ret =
|
|
6082
|
+
export function __wbg_lorotext_new(arg0) {
|
|
6083
|
+
const ret = LoroText.__wrap(arg0);
|
|
6033
6084
|
return addHeapObject(ret);
|
|
6034
6085
|
};
|
|
6035
6086
|
|
|
6036
|
-
export function
|
|
6037
|
-
const ret =
|
|
6087
|
+
export function __wbg_lorotree_new(arg0) {
|
|
6088
|
+
const ret = LoroTree.__wrap(arg0);
|
|
6038
6089
|
return addHeapObject(ret);
|
|
6039
6090
|
};
|
|
6040
6091
|
|
|
@@ -6043,13 +6094,8 @@ export function __wbg_loromovablelist_new(arg0) {
|
|
|
6043
6094
|
return addHeapObject(ret);
|
|
6044
6095
|
};
|
|
6045
6096
|
|
|
6046
|
-
export function
|
|
6047
|
-
const ret =
|
|
6048
|
-
return addHeapObject(ret);
|
|
6049
|
-
};
|
|
6050
|
-
|
|
6051
|
-
export function __wbg_cursor_new(arg0) {
|
|
6052
|
-
const ret = Cursor.__wrap(arg0);
|
|
6097
|
+
export function __wbg_lorolist_new(arg0) {
|
|
6098
|
+
const ret = LoroList.__wrap(arg0);
|
|
6053
6099
|
return addHeapObject(ret);
|
|
6054
6100
|
};
|
|
6055
6101
|
|
|
@@ -6281,7 +6327,7 @@ export function __wbg_error_f851667af71bcfc6(arg0, arg1) {
|
|
|
6281
6327
|
}
|
|
6282
6328
|
};
|
|
6283
6329
|
|
|
6284
|
-
export const
|
|
6330
|
+
export const __wbg_now_cd30a09c9b727b65 = typeof Date.now == 'function' ? Date.now : notDefined('Date.now');
|
|
6285
6331
|
|
|
6286
6332
|
export function __wbg_crypto_1d1f22824a6a080c(arg0) {
|
|
6287
6333
|
const ret = getObject(arg0).crypto;
|
|
@@ -6606,12 +6652,12 @@ export function __wbindgen_memory() {
|
|
|
6606
6652
|
};
|
|
6607
6653
|
|
|
6608
6654
|
export function __wbindgen_closure_wrapper482(arg0, arg1, arg2) {
|
|
6609
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6655
|
+
const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_60);
|
|
6610
6656
|
return addHeapObject(ret);
|
|
6611
6657
|
};
|
|
6612
6658
|
|
|
6613
6659
|
export function __wbindgen_closure_wrapper485(arg0, arg1, arg2) {
|
|
6614
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6660
|
+
const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_63);
|
|
6615
6661
|
return addHeapObject(ret);
|
|
6616
6662
|
};
|
|
6617
6663
|
|
|
Binary file
|
|
@@ -59,6 +59,7 @@ export function lorodoc_getList(a: number, b: number, c: number): void;
|
|
|
59
59
|
export function lorodoc_getMovableList(a: number, b: number, c: number): void;
|
|
60
60
|
export function lorodoc_getCounter(a: number, b: number, c: number): void;
|
|
61
61
|
export function lorodoc_getTree(a: number, b: number, c: number): void;
|
|
62
|
+
export function lorodoc_hasContainer(a: number, b: number): number;
|
|
62
63
|
export function lorodoc_getContainerById(a: number, b: number, c: number): void;
|
|
63
64
|
export function lorodoc_setNextCommitMessage(a: number, b: number, c: number): void;
|
|
64
65
|
export function lorodoc_getDeepValueWithID(a: number): number;
|
package/nodejs/loro_wasm.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ interface LoroDoc {
|
|
|
109
109
|
* text = doc.getContainerById(textId);
|
|
110
110
|
* ```
|
|
111
111
|
*/
|
|
112
|
-
getContainerById(id: ContainerID): Container;
|
|
112
|
+
getContainerById(id: ContainerID): Container | undefined;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Subscribe to updates from local edits.
|
|
@@ -1859,6 +1859,8 @@ export class LoroDoc {
|
|
|
1859
1859
|
* The object returned is a new js object each time because it need to cross
|
|
1860
1860
|
* the WASM boundary.
|
|
1861
1861
|
*
|
|
1862
|
+
* If the container does not exist, an error will be thrown.
|
|
1863
|
+
*
|
|
1862
1864
|
* @example
|
|
1863
1865
|
* ```ts
|
|
1864
1866
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1872,11 +1874,43 @@ export class LoroDoc {
|
|
|
1872
1874
|
getText(cid: ContainerID | string): LoroText;
|
|
1873
1875
|
/**
|
|
1874
1876
|
* Get a LoroCounter by container id
|
|
1877
|
+
*
|
|
1878
|
+
* If the container does not exist, an error will be thrown.
|
|
1875
1879
|
* @param {ContainerID | string} cid
|
|
1876
1880
|
* @returns {LoroCounter}
|
|
1877
1881
|
*/
|
|
1878
1882
|
getCounter(cid: ContainerID | string): LoroCounter;
|
|
1879
1883
|
/**
|
|
1884
|
+
* Check if the doc contains the target container.
|
|
1885
|
+
*
|
|
1886
|
+
* A root container always exists, while a normal container exists
|
|
1887
|
+
* if it has ever been created on the doc.
|
|
1888
|
+
*
|
|
1889
|
+
* @example
|
|
1890
|
+
* ```ts
|
|
1891
|
+
* import { LoroDoc, LoroMap, LoroText, LoroList } from "loro-crdt";
|
|
1892
|
+
*
|
|
1893
|
+
* const doc = new LoroDoc();
|
|
1894
|
+
* doc.setPeerId("1");
|
|
1895
|
+
* const text = doc.getMap("map").setContainer("text", new LoroText());
|
|
1896
|
+
* const list = doc.getMap("map").setContainer("list", new LoroList());
|
|
1897
|
+
* expect(doc.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1898
|
+
* expect(doc.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1899
|
+
* expect(doc.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1900
|
+
*
|
|
1901
|
+
* const doc2 = new LoroDoc();
|
|
1902
|
+
* // Containers exist, as long as the history or the doc state include it
|
|
1903
|
+
* doc.detach();
|
|
1904
|
+
* doc2.import(doc.export({ mode: "update" }));
|
|
1905
|
+
* expect(doc2.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1906
|
+
* expect(doc2.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1907
|
+
* expect(doc2.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1908
|
+
* ```
|
|
1909
|
+
* @param {ContainerID} container_id
|
|
1910
|
+
* @returns {boolean}
|
|
1911
|
+
*/
|
|
1912
|
+
hasContainer(container_id: ContainerID): boolean;
|
|
1913
|
+
/**
|
|
1880
1914
|
* Set the commit message of the next commit
|
|
1881
1915
|
* @param {string} msg
|
|
1882
1916
|
*/
|
package/nodejs/loro_wasm.js
CHANGED
|
@@ -1455,6 +1455,8 @@ class LoroDoc {
|
|
|
1455
1455
|
* The object returned is a new js object each time because it need to cross
|
|
1456
1456
|
* the WASM boundary.
|
|
1457
1457
|
*
|
|
1458
|
+
* If the container does not exist, an error will be thrown.
|
|
1459
|
+
*
|
|
1458
1460
|
* @example
|
|
1459
1461
|
* ```ts
|
|
1460
1462
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1487,6 +1489,8 @@ class LoroDoc {
|
|
|
1487
1489
|
* The object returned is a new js object each time because it need to cross
|
|
1488
1490
|
* the WASM boundary.
|
|
1489
1491
|
*
|
|
1492
|
+
* If the container does not exist, an error will be thrown.
|
|
1493
|
+
*
|
|
1490
1494
|
* @example
|
|
1491
1495
|
* ```ts
|
|
1492
1496
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1519,6 +1523,8 @@ class LoroDoc {
|
|
|
1519
1523
|
* The object returned is a new js object each time because it need to cross
|
|
1520
1524
|
* the WASM boundary.
|
|
1521
1525
|
*
|
|
1526
|
+
* If the container does not exist, an error will be thrown.
|
|
1527
|
+
*
|
|
1522
1528
|
* @example
|
|
1523
1529
|
* ```ts
|
|
1524
1530
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1551,6 +1557,8 @@ class LoroDoc {
|
|
|
1551
1557
|
* The object returned is a new js object each time because it need to cross
|
|
1552
1558
|
* the WASM boundary.
|
|
1553
1559
|
*
|
|
1560
|
+
* If the container does not exist, an error will be thrown.
|
|
1561
|
+
*
|
|
1554
1562
|
* @example
|
|
1555
1563
|
* ```ts
|
|
1556
1564
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1579,6 +1587,8 @@ class LoroDoc {
|
|
|
1579
1587
|
}
|
|
1580
1588
|
/**
|
|
1581
1589
|
* Get a LoroCounter by container id
|
|
1590
|
+
*
|
|
1591
|
+
* If the container does not exist, an error will be thrown.
|
|
1582
1592
|
* @param {ContainerID | string} cid
|
|
1583
1593
|
* @returns {LoroCounter}
|
|
1584
1594
|
*/
|
|
@@ -1604,6 +1614,8 @@ class LoroDoc {
|
|
|
1604
1614
|
* The object returned is a new js object each time because it need to cross
|
|
1605
1615
|
* the WASM boundary.
|
|
1606
1616
|
*
|
|
1617
|
+
* If the container does not exist, an error will be thrown.
|
|
1618
|
+
*
|
|
1607
1619
|
* @example
|
|
1608
1620
|
* ```ts
|
|
1609
1621
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1631,8 +1643,42 @@ class LoroDoc {
|
|
|
1631
1643
|
}
|
|
1632
1644
|
}
|
|
1633
1645
|
/**
|
|
1634
|
-
*
|
|
1646
|
+
* Check if the doc contains the target container.
|
|
1635
1647
|
*
|
|
1648
|
+
* A root container always exists, while a normal container exists
|
|
1649
|
+
* if it has ever been created on the doc.
|
|
1650
|
+
*
|
|
1651
|
+
* @example
|
|
1652
|
+
* ```ts
|
|
1653
|
+
* import { LoroDoc, LoroMap, LoroText, LoroList } from "loro-crdt";
|
|
1654
|
+
*
|
|
1655
|
+
* const doc = new LoroDoc();
|
|
1656
|
+
* doc.setPeerId("1");
|
|
1657
|
+
* const text = doc.getMap("map").setContainer("text", new LoroText());
|
|
1658
|
+
* const list = doc.getMap("map").setContainer("list", new LoroList());
|
|
1659
|
+
* expect(doc.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1660
|
+
* expect(doc.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1661
|
+
* expect(doc.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1662
|
+
*
|
|
1663
|
+
* const doc2 = new LoroDoc();
|
|
1664
|
+
* // Containers exist, as long as the history or the doc state include it
|
|
1665
|
+
* doc.detach();
|
|
1666
|
+
* doc2.import(doc.export({ mode: "update" }));
|
|
1667
|
+
* expect(doc2.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1668
|
+
* expect(doc2.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1669
|
+
* expect(doc2.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1670
|
+
* ```
|
|
1671
|
+
* @param {ContainerID} container_id
|
|
1672
|
+
* @returns {boolean}
|
|
1673
|
+
*/
|
|
1674
|
+
hasContainer(container_id) {
|
|
1675
|
+
const ret = wasm.lorodoc_hasContainer(this.__wbg_ptr, addHeapObject(container_id));
|
|
1676
|
+
return ret !== 0;
|
|
1677
|
+
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Get the container corresponding to the container id.
|
|
1680
|
+
*
|
|
1681
|
+
* If the container does not exist, it returns `undefined`.
|
|
1636
1682
|
*
|
|
1637
1683
|
* @example
|
|
1638
1684
|
* ```ts
|
|
@@ -6020,28 +6066,33 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
6020
6066
|
takeObject(arg0);
|
|
6021
6067
|
};
|
|
6022
6068
|
|
|
6069
|
+
module.exports.__wbg_lorocounter_new = function(arg0) {
|
|
6070
|
+
const ret = LoroCounter.__wrap(arg0);
|
|
6071
|
+
return addHeapObject(ret);
|
|
6072
|
+
};
|
|
6073
|
+
|
|
6023
6074
|
module.exports.__wbg_lorotreenode_new = function(arg0) {
|
|
6024
6075
|
const ret = LoroTreeNode.__wrap(arg0);
|
|
6025
6076
|
return addHeapObject(ret);
|
|
6026
6077
|
};
|
|
6027
6078
|
|
|
6028
|
-
module.exports.
|
|
6029
|
-
const ret =
|
|
6079
|
+
module.exports.__wbg_cursor_new = function(arg0) {
|
|
6080
|
+
const ret = Cursor.__wrap(arg0);
|
|
6030
6081
|
return addHeapObject(ret);
|
|
6031
6082
|
};
|
|
6032
6083
|
|
|
6033
|
-
module.exports.
|
|
6034
|
-
const ret =
|
|
6084
|
+
module.exports.__wbg_loromap_new = function(arg0) {
|
|
6085
|
+
const ret = LoroMap.__wrap(arg0);
|
|
6035
6086
|
return addHeapObject(ret);
|
|
6036
6087
|
};
|
|
6037
6088
|
|
|
6038
|
-
module.exports.
|
|
6039
|
-
const ret =
|
|
6089
|
+
module.exports.__wbg_lorotext_new = function(arg0) {
|
|
6090
|
+
const ret = LoroText.__wrap(arg0);
|
|
6040
6091
|
return addHeapObject(ret);
|
|
6041
6092
|
};
|
|
6042
6093
|
|
|
6043
|
-
module.exports.
|
|
6044
|
-
const ret =
|
|
6094
|
+
module.exports.__wbg_lorotree_new = function(arg0) {
|
|
6095
|
+
const ret = LoroTree.__wrap(arg0);
|
|
6045
6096
|
return addHeapObject(ret);
|
|
6046
6097
|
};
|
|
6047
6098
|
|
|
@@ -6050,13 +6101,8 @@ module.exports.__wbg_loromovablelist_new = function(arg0) {
|
|
|
6050
6101
|
return addHeapObject(ret);
|
|
6051
6102
|
};
|
|
6052
6103
|
|
|
6053
|
-
module.exports.
|
|
6054
|
-
const ret =
|
|
6055
|
-
return addHeapObject(ret);
|
|
6056
|
-
};
|
|
6057
|
-
|
|
6058
|
-
module.exports.__wbg_cursor_new = function(arg0) {
|
|
6059
|
-
const ret = Cursor.__wrap(arg0);
|
|
6104
|
+
module.exports.__wbg_lorolist_new = function(arg0) {
|
|
6105
|
+
const ret = LoroList.__wrap(arg0);
|
|
6060
6106
|
return addHeapObject(ret);
|
|
6061
6107
|
};
|
|
6062
6108
|
|
|
@@ -6288,7 +6334,7 @@ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
|
6288
6334
|
}
|
|
6289
6335
|
};
|
|
6290
6336
|
|
|
6291
|
-
module.exports.
|
|
6337
|
+
module.exports.__wbg_now_cd30a09c9b727b65 = typeof Date.now == 'function' ? Date.now : notDefined('Date.now');
|
|
6292
6338
|
|
|
6293
6339
|
module.exports.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
|
|
6294
6340
|
const ret = getObject(arg0).crypto;
|
|
@@ -6613,12 +6659,12 @@ module.exports.__wbindgen_memory = function() {
|
|
|
6613
6659
|
};
|
|
6614
6660
|
|
|
6615
6661
|
module.exports.__wbindgen_closure_wrapper482 = function(arg0, arg1, arg2) {
|
|
6616
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6662
|
+
const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_60);
|
|
6617
6663
|
return addHeapObject(ret);
|
|
6618
6664
|
};
|
|
6619
6665
|
|
|
6620
6666
|
module.exports.__wbindgen_closure_wrapper485 = function(arg0, arg1, arg2) {
|
|
6621
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6667
|
+
const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_63);
|
|
6622
6668
|
return addHeapObject(ret);
|
|
6623
6669
|
};
|
|
6624
6670
|
|
package/nodejs/loro_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -59,6 +59,7 @@ export function lorodoc_getList(a: number, b: number, c: number): void;
|
|
|
59
59
|
export function lorodoc_getMovableList(a: number, b: number, c: number): void;
|
|
60
60
|
export function lorodoc_getCounter(a: number, b: number, c: number): void;
|
|
61
61
|
export function lorodoc_getTree(a: number, b: number, c: number): void;
|
|
62
|
+
export function lorodoc_hasContainer(a: number, b: number): number;
|
|
62
63
|
export function lorodoc_getContainerById(a: number, b: number, c: number): void;
|
|
63
64
|
export function lorodoc_setNextCommitMessage(a: number, b: number, c: number): void;
|
|
64
65
|
export function lorodoc_getDeepValueWithID(a: number): number;
|
package/package.json
CHANGED
package/web/loro_wasm.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ interface LoroDoc {
|
|
|
109
109
|
* text = doc.getContainerById(textId);
|
|
110
110
|
* ```
|
|
111
111
|
*/
|
|
112
|
-
getContainerById(id: ContainerID): Container;
|
|
112
|
+
getContainerById(id: ContainerID): Container | undefined;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Subscribe to updates from local edits.
|
|
@@ -1859,6 +1859,8 @@ export class LoroDoc {
|
|
|
1859
1859
|
* The object returned is a new js object each time because it need to cross
|
|
1860
1860
|
* the WASM boundary.
|
|
1861
1861
|
*
|
|
1862
|
+
* If the container does not exist, an error will be thrown.
|
|
1863
|
+
*
|
|
1862
1864
|
* @example
|
|
1863
1865
|
* ```ts
|
|
1864
1866
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1872,11 +1874,43 @@ export class LoroDoc {
|
|
|
1872
1874
|
getText(cid: ContainerID | string): LoroText;
|
|
1873
1875
|
/**
|
|
1874
1876
|
* Get a LoroCounter by container id
|
|
1877
|
+
*
|
|
1878
|
+
* If the container does not exist, an error will be thrown.
|
|
1875
1879
|
* @param {ContainerID | string} cid
|
|
1876
1880
|
* @returns {LoroCounter}
|
|
1877
1881
|
*/
|
|
1878
1882
|
getCounter(cid: ContainerID | string): LoroCounter;
|
|
1879
1883
|
/**
|
|
1884
|
+
* Check if the doc contains the target container.
|
|
1885
|
+
*
|
|
1886
|
+
* A root container always exists, while a normal container exists
|
|
1887
|
+
* if it has ever been created on the doc.
|
|
1888
|
+
*
|
|
1889
|
+
* @example
|
|
1890
|
+
* ```ts
|
|
1891
|
+
* import { LoroDoc, LoroMap, LoroText, LoroList } from "loro-crdt";
|
|
1892
|
+
*
|
|
1893
|
+
* const doc = new LoroDoc();
|
|
1894
|
+
* doc.setPeerId("1");
|
|
1895
|
+
* const text = doc.getMap("map").setContainer("text", new LoroText());
|
|
1896
|
+
* const list = doc.getMap("map").setContainer("list", new LoroList());
|
|
1897
|
+
* expect(doc.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1898
|
+
* expect(doc.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1899
|
+
* expect(doc.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1900
|
+
*
|
|
1901
|
+
* const doc2 = new LoroDoc();
|
|
1902
|
+
* // Containers exist, as long as the history or the doc state include it
|
|
1903
|
+
* doc.detach();
|
|
1904
|
+
* doc2.import(doc.export({ mode: "update" }));
|
|
1905
|
+
* expect(doc2.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1906
|
+
* expect(doc2.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1907
|
+
* expect(doc2.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1908
|
+
* ```
|
|
1909
|
+
* @param {ContainerID} container_id
|
|
1910
|
+
* @returns {boolean}
|
|
1911
|
+
*/
|
|
1912
|
+
hasContainer(container_id: ContainerID): boolean;
|
|
1913
|
+
/**
|
|
1880
1914
|
* Set the commit message of the next commit
|
|
1881
1915
|
* @param {string} msg
|
|
1882
1916
|
*/
|
|
@@ -3695,6 +3729,7 @@ export interface InitOutput {
|
|
|
3695
3729
|
readonly lorodoc_getMovableList: (a: number, b: number, c: number) => void;
|
|
3696
3730
|
readonly lorodoc_getCounter: (a: number, b: number, c: number) => void;
|
|
3697
3731
|
readonly lorodoc_getTree: (a: number, b: number, c: number) => void;
|
|
3732
|
+
readonly lorodoc_hasContainer: (a: number, b: number) => number;
|
|
3698
3733
|
readonly lorodoc_getContainerById: (a: number, b: number, c: number) => void;
|
|
3699
3734
|
readonly lorodoc_setNextCommitMessage: (a: number, b: number, c: number) => void;
|
|
3700
3735
|
readonly lorodoc_getDeepValueWithID: (a: number) => number;
|