loro-crdt 1.4.1 → 1.4.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 +14 -0
- package/base64/index.js +128 -21
- package/base64/loro_wasm.d.ts +59 -1
- package/base64/loro_wasm_bg-231c2a2e.js +64 -0
- package/bundler/loro_wasm.d.ts +59 -1
- package/bundler/loro_wasm_bg.js +125 -19
- package/bundler/loro_wasm_bg.wasm +0 -0
- package/bundler/loro_wasm_bg.wasm.d.ts +6 -0
- package/nodejs/loro_wasm.d.ts +59 -1
- package/nodejs/loro_wasm.js +125 -19
- package/nodejs/loro_wasm_bg.wasm +0 -0
- package/nodejs/loro_wasm_bg.wasm.d.ts +6 -0
- package/package.json +1 -1
- package/web/loro_wasm.d.ts +65 -1
- package/web/loro_wasm.js +124 -18
- package/web/loro_wasm_bg.wasm +0 -0
- package/web/loro_wasm_bg.wasm.d.ts +6 -0
- package/base64/loro_wasm_bg-4116d6d8.js +0 -64
package/nodejs/loro_wasm.js
CHANGED
|
@@ -271,6 +271,27 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
271
271
|
}
|
|
272
272
|
return result;
|
|
273
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Get the version of Loro
|
|
276
|
+
* @returns {string}
|
|
277
|
+
*/
|
|
278
|
+
module.exports.LORO_VERSION = function() {
|
|
279
|
+
let deferred1_0;
|
|
280
|
+
let deferred1_1;
|
|
281
|
+
try {
|
|
282
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
283
|
+
wasm.LORO_VERSION(retptr);
|
|
284
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
285
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
286
|
+
deferred1_0 = r0;
|
|
287
|
+
deferred1_1 = r1;
|
|
288
|
+
return getStringFromWasm0(r0, r1);
|
|
289
|
+
} finally {
|
|
290
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
291
|
+
wasm.__wbindgen_export_5(deferred1_0, deferred1_1, 1);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
274
295
|
/**
|
|
275
296
|
*/
|
|
276
297
|
module.exports.run = function() {
|
|
@@ -1455,6 +1476,8 @@ class LoroDoc {
|
|
|
1455
1476
|
* The object returned is a new js object each time because it need to cross
|
|
1456
1477
|
* the WASM boundary.
|
|
1457
1478
|
*
|
|
1479
|
+
* If the container does not exist, an error will be thrown.
|
|
1480
|
+
*
|
|
1458
1481
|
* @example
|
|
1459
1482
|
* ```ts
|
|
1460
1483
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1487,6 +1510,8 @@ class LoroDoc {
|
|
|
1487
1510
|
* The object returned is a new js object each time because it need to cross
|
|
1488
1511
|
* the WASM boundary.
|
|
1489
1512
|
*
|
|
1513
|
+
* If the container does not exist, an error will be thrown.
|
|
1514
|
+
*
|
|
1490
1515
|
* @example
|
|
1491
1516
|
* ```ts
|
|
1492
1517
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1519,6 +1544,8 @@ class LoroDoc {
|
|
|
1519
1544
|
* The object returned is a new js object each time because it need to cross
|
|
1520
1545
|
* the WASM boundary.
|
|
1521
1546
|
*
|
|
1547
|
+
* If the container does not exist, an error will be thrown.
|
|
1548
|
+
*
|
|
1522
1549
|
* @example
|
|
1523
1550
|
* ```ts
|
|
1524
1551
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1551,6 +1578,8 @@ class LoroDoc {
|
|
|
1551
1578
|
* The object returned is a new js object each time because it need to cross
|
|
1552
1579
|
* the WASM boundary.
|
|
1553
1580
|
*
|
|
1581
|
+
* If the container does not exist, an error will be thrown.
|
|
1582
|
+
*
|
|
1554
1583
|
* @example
|
|
1555
1584
|
* ```ts
|
|
1556
1585
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1579,6 +1608,8 @@ class LoroDoc {
|
|
|
1579
1608
|
}
|
|
1580
1609
|
/**
|
|
1581
1610
|
* Get a LoroCounter by container id
|
|
1611
|
+
*
|
|
1612
|
+
* If the container does not exist, an error will be thrown.
|
|
1582
1613
|
* @param {ContainerID | string} cid
|
|
1583
1614
|
* @returns {LoroCounter}
|
|
1584
1615
|
*/
|
|
@@ -1604,6 +1635,8 @@ class LoroDoc {
|
|
|
1604
1635
|
* The object returned is a new js object each time because it need to cross
|
|
1605
1636
|
* the WASM boundary.
|
|
1606
1637
|
*
|
|
1638
|
+
* If the container does not exist, an error will be thrown.
|
|
1639
|
+
*
|
|
1607
1640
|
* @example
|
|
1608
1641
|
* ```ts
|
|
1609
1642
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1631,8 +1664,42 @@ class LoroDoc {
|
|
|
1631
1664
|
}
|
|
1632
1665
|
}
|
|
1633
1666
|
/**
|
|
1634
|
-
*
|
|
1667
|
+
* Check if the doc contains the target container.
|
|
1635
1668
|
*
|
|
1669
|
+
* A root container always exists, while a normal container exists
|
|
1670
|
+
* if it has ever been created on the doc.
|
|
1671
|
+
*
|
|
1672
|
+
* @example
|
|
1673
|
+
* ```ts
|
|
1674
|
+
* import { LoroDoc, LoroMap, LoroText, LoroList } from "loro-crdt";
|
|
1675
|
+
*
|
|
1676
|
+
* const doc = new LoroDoc();
|
|
1677
|
+
* doc.setPeerId("1");
|
|
1678
|
+
* const text = doc.getMap("map").setContainer("text", new LoroText());
|
|
1679
|
+
* const list = doc.getMap("map").setContainer("list", new LoroList());
|
|
1680
|
+
* expect(doc.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1681
|
+
* expect(doc.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1682
|
+
* expect(doc.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1683
|
+
*
|
|
1684
|
+
* const doc2 = new LoroDoc();
|
|
1685
|
+
* // Containers exist, as long as the history or the doc state include it
|
|
1686
|
+
* doc.detach();
|
|
1687
|
+
* doc2.import(doc.export({ mode: "update" }));
|
|
1688
|
+
* expect(doc2.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1689
|
+
* expect(doc2.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1690
|
+
* expect(doc2.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1691
|
+
* ```
|
|
1692
|
+
* @param {ContainerID} container_id
|
|
1693
|
+
* @returns {boolean}
|
|
1694
|
+
*/
|
|
1695
|
+
hasContainer(container_id) {
|
|
1696
|
+
const ret = wasm.lorodoc_hasContainer(this.__wbg_ptr, addHeapObject(container_id));
|
|
1697
|
+
return ret !== 0;
|
|
1698
|
+
}
|
|
1699
|
+
/**
|
|
1700
|
+
* Get the container corresponding to the container id.
|
|
1701
|
+
*
|
|
1702
|
+
* If the container does not exist, it returns `undefined`.
|
|
1636
1703
|
*
|
|
1637
1704
|
* @example
|
|
1638
1705
|
* ```ts
|
|
@@ -1671,6 +1738,45 @@ class LoroDoc {
|
|
|
1671
1738
|
wasm.lorodoc_setNextCommitMessage(this.__wbg_ptr, ptr0, len0);
|
|
1672
1739
|
}
|
|
1673
1740
|
/**
|
|
1741
|
+
* Set the origin of the next commit
|
|
1742
|
+
* @param {string} origin
|
|
1743
|
+
*/
|
|
1744
|
+
setNextCommitOrigin(origin) {
|
|
1745
|
+
const ptr0 = passStringToWasm0(origin, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
1746
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1747
|
+
wasm.lorodoc_setNextCommitOrigin(this.__wbg_ptr, ptr0, len0);
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* Set the timestamp of the next commit
|
|
1751
|
+
* @param {number} timestamp
|
|
1752
|
+
*/
|
|
1753
|
+
setNextCommitTimestamp(timestamp) {
|
|
1754
|
+
wasm.lorodoc_setNextCommitTimestamp(this.__wbg_ptr, timestamp);
|
|
1755
|
+
}
|
|
1756
|
+
/**
|
|
1757
|
+
* Set the options of the next commit
|
|
1758
|
+
* @param {{ origin?: string, timestamp?: number, message?: string }} options
|
|
1759
|
+
*/
|
|
1760
|
+
setNextCommitOptions(options) {
|
|
1761
|
+
try {
|
|
1762
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1763
|
+
wasm.lorodoc_setNextCommitOptions(retptr, this.__wbg_ptr, addHeapObject(options));
|
|
1764
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
1765
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
1766
|
+
if (r1) {
|
|
1767
|
+
throw takeObject(r0);
|
|
1768
|
+
}
|
|
1769
|
+
} finally {
|
|
1770
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* Clear the options of the next commit
|
|
1775
|
+
*/
|
|
1776
|
+
clearNextCommitOptions() {
|
|
1777
|
+
wasm.lorodoc_clearNextCommitOptions(this.__wbg_ptr);
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1674
1780
|
* Get deep value of the document with container id
|
|
1675
1781
|
* @returns {any}
|
|
1676
1782
|
*/
|
|
@@ -6020,28 +6126,33 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
6020
6126
|
takeObject(arg0);
|
|
6021
6127
|
};
|
|
6022
6128
|
|
|
6129
|
+
module.exports.__wbg_lorocounter_new = function(arg0) {
|
|
6130
|
+
const ret = LoroCounter.__wrap(arg0);
|
|
6131
|
+
return addHeapObject(ret);
|
|
6132
|
+
};
|
|
6133
|
+
|
|
6023
6134
|
module.exports.__wbg_lorotreenode_new = function(arg0) {
|
|
6024
6135
|
const ret = LoroTreeNode.__wrap(arg0);
|
|
6025
6136
|
return addHeapObject(ret);
|
|
6026
6137
|
};
|
|
6027
6138
|
|
|
6028
|
-
module.exports.
|
|
6029
|
-
const ret =
|
|
6139
|
+
module.exports.__wbg_cursor_new = function(arg0) {
|
|
6140
|
+
const ret = Cursor.__wrap(arg0);
|
|
6030
6141
|
return addHeapObject(ret);
|
|
6031
6142
|
};
|
|
6032
6143
|
|
|
6033
|
-
module.exports.
|
|
6034
|
-
const ret =
|
|
6144
|
+
module.exports.__wbg_loromap_new = function(arg0) {
|
|
6145
|
+
const ret = LoroMap.__wrap(arg0);
|
|
6035
6146
|
return addHeapObject(ret);
|
|
6036
6147
|
};
|
|
6037
6148
|
|
|
6038
|
-
module.exports.
|
|
6039
|
-
const ret =
|
|
6149
|
+
module.exports.__wbg_lorotext_new = function(arg0) {
|
|
6150
|
+
const ret = LoroText.__wrap(arg0);
|
|
6040
6151
|
return addHeapObject(ret);
|
|
6041
6152
|
};
|
|
6042
6153
|
|
|
6043
|
-
module.exports.
|
|
6044
|
-
const ret =
|
|
6154
|
+
module.exports.__wbg_lorotree_new = function(arg0) {
|
|
6155
|
+
const ret = LoroTree.__wrap(arg0);
|
|
6045
6156
|
return addHeapObject(ret);
|
|
6046
6157
|
};
|
|
6047
6158
|
|
|
@@ -6050,13 +6161,8 @@ module.exports.__wbg_loromovablelist_new = function(arg0) {
|
|
|
6050
6161
|
return addHeapObject(ret);
|
|
6051
6162
|
};
|
|
6052
6163
|
|
|
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);
|
|
6164
|
+
module.exports.__wbg_lorolist_new = function(arg0) {
|
|
6165
|
+
const ret = LoroList.__wrap(arg0);
|
|
6060
6166
|
return addHeapObject(ret);
|
|
6061
6167
|
};
|
|
6062
6168
|
|
|
@@ -6288,7 +6394,7 @@ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
|
6288
6394
|
}
|
|
6289
6395
|
};
|
|
6290
6396
|
|
|
6291
|
-
module.exports.
|
|
6397
|
+
module.exports.__wbg_now_cd30a09c9b727b65 = typeof Date.now == 'function' ? Date.now : notDefined('Date.now');
|
|
6292
6398
|
|
|
6293
6399
|
module.exports.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
|
|
6294
6400
|
const ret = getObject(arg0).crypto;
|
|
@@ -6613,12 +6719,12 @@ module.exports.__wbindgen_memory = function() {
|
|
|
6613
6719
|
};
|
|
6614
6720
|
|
|
6615
6721
|
module.exports.__wbindgen_closure_wrapper482 = function(arg0, arg1, arg2) {
|
|
6616
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6722
|
+
const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_60);
|
|
6617
6723
|
return addHeapObject(ret);
|
|
6618
6724
|
};
|
|
6619
6725
|
|
|
6620
6726
|
module.exports.__wbindgen_closure_wrapper485 = function(arg0, arg1, arg2) {
|
|
6621
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6727
|
+
const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_63);
|
|
6622
6728
|
return addHeapObject(ret);
|
|
6623
6729
|
};
|
|
6624
6730
|
|
package/nodejs/loro_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -27,6 +27,7 @@ export function awarenesswasm_removeOutdated(a: number, b: number): void;
|
|
|
27
27
|
export function awarenesswasm_length(a: number): number;
|
|
28
28
|
export function awarenesswasm_isEmpty(a: number): number;
|
|
29
29
|
export function awarenesswasm_peers(a: number, b: number): void;
|
|
30
|
+
export function LORO_VERSION(a: number): void;
|
|
30
31
|
export function run(): void;
|
|
31
32
|
export function encodeFrontiers(a: number, b: number, c: number): void;
|
|
32
33
|
export function decodeFrontiers(a: number, b: number, c: number): void;
|
|
@@ -59,8 +60,13 @@ export function lorodoc_getList(a: number, b: number, c: number): void;
|
|
|
59
60
|
export function lorodoc_getMovableList(a: number, b: number, c: number): void;
|
|
60
61
|
export function lorodoc_getCounter(a: number, b: number, c: number): void;
|
|
61
62
|
export function lorodoc_getTree(a: number, b: number, c: number): void;
|
|
63
|
+
export function lorodoc_hasContainer(a: number, b: number): number;
|
|
62
64
|
export function lorodoc_getContainerById(a: number, b: number, c: number): void;
|
|
63
65
|
export function lorodoc_setNextCommitMessage(a: number, b: number, c: number): void;
|
|
66
|
+
export function lorodoc_setNextCommitOrigin(a: number, b: number, c: number): void;
|
|
67
|
+
export function lorodoc_setNextCommitTimestamp(a: number, b: number): void;
|
|
68
|
+
export function lorodoc_setNextCommitOptions(a: number, b: number, c: number): void;
|
|
69
|
+
export function lorodoc_clearNextCommitOptions(a: number): void;
|
|
64
70
|
export function lorodoc_getDeepValueWithID(a: number): number;
|
|
65
71
|
export function lorodoc_getPathToContainer(a: number, b: number, c: number): void;
|
|
66
72
|
export function lorodoc_JSONPath(a: number, b: number, c: number, d: number): void;
|
package/package.json
CHANGED
package/web/loro_wasm.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
+
* Get the version of Loro
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function LORO_VERSION(): string;
|
|
8
|
+
/**
|
|
4
9
|
*/
|
|
5
10
|
export function run(): void;
|
|
6
11
|
/**
|
|
@@ -109,7 +114,7 @@ interface LoroDoc {
|
|
|
109
114
|
* text = doc.getContainerById(textId);
|
|
110
115
|
* ```
|
|
111
116
|
*/
|
|
112
|
-
getContainerById(id: ContainerID): Container;
|
|
117
|
+
getContainerById(id: ContainerID): Container | undefined;
|
|
113
118
|
|
|
114
119
|
/**
|
|
115
120
|
* Subscribe to updates from local edits.
|
|
@@ -1859,6 +1864,8 @@ export class LoroDoc {
|
|
|
1859
1864
|
* The object returned is a new js object each time because it need to cross
|
|
1860
1865
|
* the WASM boundary.
|
|
1861
1866
|
*
|
|
1867
|
+
* If the container does not exist, an error will be thrown.
|
|
1868
|
+
*
|
|
1862
1869
|
* @example
|
|
1863
1870
|
* ```ts
|
|
1864
1871
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1872,16 +1879,67 @@ export class LoroDoc {
|
|
|
1872
1879
|
getText(cid: ContainerID | string): LoroText;
|
|
1873
1880
|
/**
|
|
1874
1881
|
* Get a LoroCounter by container id
|
|
1882
|
+
*
|
|
1883
|
+
* If the container does not exist, an error will be thrown.
|
|
1875
1884
|
* @param {ContainerID | string} cid
|
|
1876
1885
|
* @returns {LoroCounter}
|
|
1877
1886
|
*/
|
|
1878
1887
|
getCounter(cid: ContainerID | string): LoroCounter;
|
|
1879
1888
|
/**
|
|
1889
|
+
* Check if the doc contains the target container.
|
|
1890
|
+
*
|
|
1891
|
+
* A root container always exists, while a normal container exists
|
|
1892
|
+
* if it has ever been created on the doc.
|
|
1893
|
+
*
|
|
1894
|
+
* @example
|
|
1895
|
+
* ```ts
|
|
1896
|
+
* import { LoroDoc, LoroMap, LoroText, LoroList } from "loro-crdt";
|
|
1897
|
+
*
|
|
1898
|
+
* const doc = new LoroDoc();
|
|
1899
|
+
* doc.setPeerId("1");
|
|
1900
|
+
* const text = doc.getMap("map").setContainer("text", new LoroText());
|
|
1901
|
+
* const list = doc.getMap("map").setContainer("list", new LoroList());
|
|
1902
|
+
* expect(doc.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1903
|
+
* expect(doc.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1904
|
+
* expect(doc.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1905
|
+
*
|
|
1906
|
+
* const doc2 = new LoroDoc();
|
|
1907
|
+
* // Containers exist, as long as the history or the doc state include it
|
|
1908
|
+
* doc.detach();
|
|
1909
|
+
* doc2.import(doc.export({ mode: "update" }));
|
|
1910
|
+
* expect(doc2.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1911
|
+
* expect(doc2.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1912
|
+
* expect(doc2.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1913
|
+
* ```
|
|
1914
|
+
* @param {ContainerID} container_id
|
|
1915
|
+
* @returns {boolean}
|
|
1916
|
+
*/
|
|
1917
|
+
hasContainer(container_id: ContainerID): boolean;
|
|
1918
|
+
/**
|
|
1880
1919
|
* Set the commit message of the next commit
|
|
1881
1920
|
* @param {string} msg
|
|
1882
1921
|
*/
|
|
1883
1922
|
setNextCommitMessage(msg: string): void;
|
|
1884
1923
|
/**
|
|
1924
|
+
* Set the origin of the next commit
|
|
1925
|
+
* @param {string} origin
|
|
1926
|
+
*/
|
|
1927
|
+
setNextCommitOrigin(origin: string): void;
|
|
1928
|
+
/**
|
|
1929
|
+
* Set the timestamp of the next commit
|
|
1930
|
+
* @param {number} timestamp
|
|
1931
|
+
*/
|
|
1932
|
+
setNextCommitTimestamp(timestamp: number): void;
|
|
1933
|
+
/**
|
|
1934
|
+
* Set the options of the next commit
|
|
1935
|
+
* @param {{ origin?: string, timestamp?: number, message?: string }} options
|
|
1936
|
+
*/
|
|
1937
|
+
setNextCommitOptions(options: { origin?: string, timestamp?: number, message?: string }): void;
|
|
1938
|
+
/**
|
|
1939
|
+
* Clear the options of the next commit
|
|
1940
|
+
*/
|
|
1941
|
+
clearNextCommitOptions(): void;
|
|
1942
|
+
/**
|
|
1885
1943
|
* Get deep value of the document with container id
|
|
1886
1944
|
* @returns {any}
|
|
1887
1945
|
*/
|
|
@@ -3663,6 +3721,7 @@ export interface InitOutput {
|
|
|
3663
3721
|
readonly awarenesswasm_length: (a: number) => number;
|
|
3664
3722
|
readonly awarenesswasm_isEmpty: (a: number) => number;
|
|
3665
3723
|
readonly awarenesswasm_peers: (a: number, b: number) => void;
|
|
3724
|
+
readonly LORO_VERSION: (a: number) => void;
|
|
3666
3725
|
readonly run: () => void;
|
|
3667
3726
|
readonly encodeFrontiers: (a: number, b: number, c: number) => void;
|
|
3668
3727
|
readonly decodeFrontiers: (a: number, b: number, c: number) => void;
|
|
@@ -3695,8 +3754,13 @@ export interface InitOutput {
|
|
|
3695
3754
|
readonly lorodoc_getMovableList: (a: number, b: number, c: number) => void;
|
|
3696
3755
|
readonly lorodoc_getCounter: (a: number, b: number, c: number) => void;
|
|
3697
3756
|
readonly lorodoc_getTree: (a: number, b: number, c: number) => void;
|
|
3757
|
+
readonly lorodoc_hasContainer: (a: number, b: number) => number;
|
|
3698
3758
|
readonly lorodoc_getContainerById: (a: number, b: number, c: number) => void;
|
|
3699
3759
|
readonly lorodoc_setNextCommitMessage: (a: number, b: number, c: number) => void;
|
|
3760
|
+
readonly lorodoc_setNextCommitOrigin: (a: number, b: number, c: number) => void;
|
|
3761
|
+
readonly lorodoc_setNextCommitTimestamp: (a: number, b: number) => void;
|
|
3762
|
+
readonly lorodoc_setNextCommitOptions: (a: number, b: number, c: number) => void;
|
|
3763
|
+
readonly lorodoc_clearNextCommitOptions: (a: number) => void;
|
|
3700
3764
|
readonly lorodoc_getDeepValueWithID: (a: number) => number;
|
|
3701
3765
|
readonly lorodoc_getPathToContainer: (a: number, b: number, c: number) => void;
|
|
3702
3766
|
readonly lorodoc_JSONPath: (a: number, b: number, c: number, d: number) => void;
|
package/web/loro_wasm.js
CHANGED
|
@@ -268,6 +268,27 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
268
268
|
}
|
|
269
269
|
return result;
|
|
270
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Get the version of Loro
|
|
273
|
+
* @returns {string}
|
|
274
|
+
*/
|
|
275
|
+
export function LORO_VERSION() {
|
|
276
|
+
let deferred1_0;
|
|
277
|
+
let deferred1_1;
|
|
278
|
+
try {
|
|
279
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
280
|
+
wasm.LORO_VERSION(retptr);
|
|
281
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
282
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
283
|
+
deferred1_0 = r0;
|
|
284
|
+
deferred1_1 = r1;
|
|
285
|
+
return getStringFromWasm0(r0, r1);
|
|
286
|
+
} finally {
|
|
287
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
288
|
+
wasm.__wbindgen_export_5(deferred1_0, deferred1_1, 1);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
271
292
|
/**
|
|
272
293
|
*/
|
|
273
294
|
export function run() {
|
|
@@ -1449,6 +1470,8 @@ export class LoroDoc {
|
|
|
1449
1470
|
* The object returned is a new js object each time because it need to cross
|
|
1450
1471
|
* the WASM boundary.
|
|
1451
1472
|
*
|
|
1473
|
+
* If the container does not exist, an error will be thrown.
|
|
1474
|
+
*
|
|
1452
1475
|
* @example
|
|
1453
1476
|
* ```ts
|
|
1454
1477
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1481,6 +1504,8 @@ export class LoroDoc {
|
|
|
1481
1504
|
* The object returned is a new js object each time because it need to cross
|
|
1482
1505
|
* the WASM boundary.
|
|
1483
1506
|
*
|
|
1507
|
+
* If the container does not exist, an error will be thrown.
|
|
1508
|
+
*
|
|
1484
1509
|
* @example
|
|
1485
1510
|
* ```ts
|
|
1486
1511
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1513,6 +1538,8 @@ export class LoroDoc {
|
|
|
1513
1538
|
* The object returned is a new js object each time because it need to cross
|
|
1514
1539
|
* the WASM boundary.
|
|
1515
1540
|
*
|
|
1541
|
+
* If the container does not exist, an error will be thrown.
|
|
1542
|
+
*
|
|
1516
1543
|
* @example
|
|
1517
1544
|
* ```ts
|
|
1518
1545
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1545,6 +1572,8 @@ export class LoroDoc {
|
|
|
1545
1572
|
* The object returned is a new js object each time because it need to cross
|
|
1546
1573
|
* the WASM boundary.
|
|
1547
1574
|
*
|
|
1575
|
+
* If the container does not exist, an error will be thrown.
|
|
1576
|
+
*
|
|
1548
1577
|
* @example
|
|
1549
1578
|
* ```ts
|
|
1550
1579
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1573,6 +1602,8 @@ export class LoroDoc {
|
|
|
1573
1602
|
}
|
|
1574
1603
|
/**
|
|
1575
1604
|
* Get a LoroCounter by container id
|
|
1605
|
+
*
|
|
1606
|
+
* If the container does not exist, an error will be thrown.
|
|
1576
1607
|
* @param {ContainerID | string} cid
|
|
1577
1608
|
* @returns {LoroCounter}
|
|
1578
1609
|
*/
|
|
@@ -1598,6 +1629,8 @@ export class LoroDoc {
|
|
|
1598
1629
|
* The object returned is a new js object each time because it need to cross
|
|
1599
1630
|
* the WASM boundary.
|
|
1600
1631
|
*
|
|
1632
|
+
* If the container does not exist, an error will be thrown.
|
|
1633
|
+
*
|
|
1601
1634
|
* @example
|
|
1602
1635
|
* ```ts
|
|
1603
1636
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -1625,8 +1658,42 @@ export class LoroDoc {
|
|
|
1625
1658
|
}
|
|
1626
1659
|
}
|
|
1627
1660
|
/**
|
|
1628
|
-
*
|
|
1661
|
+
* Check if the doc contains the target container.
|
|
1629
1662
|
*
|
|
1663
|
+
* A root container always exists, while a normal container exists
|
|
1664
|
+
* if it has ever been created on the doc.
|
|
1665
|
+
*
|
|
1666
|
+
* @example
|
|
1667
|
+
* ```ts
|
|
1668
|
+
* import { LoroDoc, LoroMap, LoroText, LoroList } from "loro-crdt";
|
|
1669
|
+
*
|
|
1670
|
+
* const doc = new LoroDoc();
|
|
1671
|
+
* doc.setPeerId("1");
|
|
1672
|
+
* const text = doc.getMap("map").setContainer("text", new LoroText());
|
|
1673
|
+
* const list = doc.getMap("map").setContainer("list", new LoroList());
|
|
1674
|
+
* expect(doc.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1675
|
+
* expect(doc.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1676
|
+
* expect(doc.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1677
|
+
*
|
|
1678
|
+
* const doc2 = new LoroDoc();
|
|
1679
|
+
* // Containers exist, as long as the history or the doc state include it
|
|
1680
|
+
* doc.detach();
|
|
1681
|
+
* doc2.import(doc.export({ mode: "update" }));
|
|
1682
|
+
* expect(doc2.isContainerExists("cid:root-map:Map")).toBe(true);
|
|
1683
|
+
* expect(doc2.isContainerExists("cid:0@1:Text")).toBe(true);
|
|
1684
|
+
* expect(doc2.isContainerExists("cid:1@1:List")).toBe(true);
|
|
1685
|
+
* ```
|
|
1686
|
+
* @param {ContainerID} container_id
|
|
1687
|
+
* @returns {boolean}
|
|
1688
|
+
*/
|
|
1689
|
+
hasContainer(container_id) {
|
|
1690
|
+
const ret = wasm.lorodoc_hasContainer(this.__wbg_ptr, addHeapObject(container_id));
|
|
1691
|
+
return ret !== 0;
|
|
1692
|
+
}
|
|
1693
|
+
/**
|
|
1694
|
+
* Get the container corresponding to the container id.
|
|
1695
|
+
*
|
|
1696
|
+
* If the container does not exist, it returns `undefined`.
|
|
1630
1697
|
*
|
|
1631
1698
|
* @example
|
|
1632
1699
|
* ```ts
|
|
@@ -1665,6 +1732,45 @@ export class LoroDoc {
|
|
|
1665
1732
|
wasm.lorodoc_setNextCommitMessage(this.__wbg_ptr, ptr0, len0);
|
|
1666
1733
|
}
|
|
1667
1734
|
/**
|
|
1735
|
+
* Set the origin of the next commit
|
|
1736
|
+
* @param {string} origin
|
|
1737
|
+
*/
|
|
1738
|
+
setNextCommitOrigin(origin) {
|
|
1739
|
+
const ptr0 = passStringToWasm0(origin, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
1740
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1741
|
+
wasm.lorodoc_setNextCommitOrigin(this.__wbg_ptr, ptr0, len0);
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Set the timestamp of the next commit
|
|
1745
|
+
* @param {number} timestamp
|
|
1746
|
+
*/
|
|
1747
|
+
setNextCommitTimestamp(timestamp) {
|
|
1748
|
+
wasm.lorodoc_setNextCommitTimestamp(this.__wbg_ptr, timestamp);
|
|
1749
|
+
}
|
|
1750
|
+
/**
|
|
1751
|
+
* Set the options of the next commit
|
|
1752
|
+
* @param {{ origin?: string, timestamp?: number, message?: string }} options
|
|
1753
|
+
*/
|
|
1754
|
+
setNextCommitOptions(options) {
|
|
1755
|
+
try {
|
|
1756
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1757
|
+
wasm.lorodoc_setNextCommitOptions(retptr, this.__wbg_ptr, addHeapObject(options));
|
|
1758
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
1759
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
1760
|
+
if (r1) {
|
|
1761
|
+
throw takeObject(r0);
|
|
1762
|
+
}
|
|
1763
|
+
} finally {
|
|
1764
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* Clear the options of the next commit
|
|
1769
|
+
*/
|
|
1770
|
+
clearNextCommitOptions() {
|
|
1771
|
+
wasm.lorodoc_clearNextCommitOptions(this.__wbg_ptr);
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1668
1774
|
* Get deep value of the document with container id
|
|
1669
1775
|
* @returns {any}
|
|
1670
1776
|
*/
|
|
@@ -6038,36 +6144,36 @@ function __wbg_get_imports() {
|
|
|
6038
6144
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
6039
6145
|
takeObject(arg0);
|
|
6040
6146
|
};
|
|
6147
|
+
imports.wbg.__wbg_lorocounter_new = function(arg0) {
|
|
6148
|
+
const ret = LoroCounter.__wrap(arg0);
|
|
6149
|
+
return addHeapObject(ret);
|
|
6150
|
+
};
|
|
6041
6151
|
imports.wbg.__wbg_lorotreenode_new = function(arg0) {
|
|
6042
6152
|
const ret = LoroTreeNode.__wrap(arg0);
|
|
6043
6153
|
return addHeapObject(ret);
|
|
6044
6154
|
};
|
|
6045
|
-
imports.wbg.
|
|
6046
|
-
const ret =
|
|
6155
|
+
imports.wbg.__wbg_cursor_new = function(arg0) {
|
|
6156
|
+
const ret = Cursor.__wrap(arg0);
|
|
6047
6157
|
return addHeapObject(ret);
|
|
6048
6158
|
};
|
|
6049
|
-
imports.wbg.
|
|
6050
|
-
const ret =
|
|
6159
|
+
imports.wbg.__wbg_loromap_new = function(arg0) {
|
|
6160
|
+
const ret = LoroMap.__wrap(arg0);
|
|
6051
6161
|
return addHeapObject(ret);
|
|
6052
6162
|
};
|
|
6053
|
-
imports.wbg.
|
|
6054
|
-
const ret =
|
|
6163
|
+
imports.wbg.__wbg_lorotext_new = function(arg0) {
|
|
6164
|
+
const ret = LoroText.__wrap(arg0);
|
|
6055
6165
|
return addHeapObject(ret);
|
|
6056
6166
|
};
|
|
6057
|
-
imports.wbg.
|
|
6058
|
-
const ret =
|
|
6167
|
+
imports.wbg.__wbg_lorotree_new = function(arg0) {
|
|
6168
|
+
const ret = LoroTree.__wrap(arg0);
|
|
6059
6169
|
return addHeapObject(ret);
|
|
6060
6170
|
};
|
|
6061
6171
|
imports.wbg.__wbg_loromovablelist_new = function(arg0) {
|
|
6062
6172
|
const ret = LoroMovableList.__wrap(arg0);
|
|
6063
6173
|
return addHeapObject(ret);
|
|
6064
6174
|
};
|
|
6065
|
-
imports.wbg.
|
|
6066
|
-
const ret =
|
|
6067
|
-
return addHeapObject(ret);
|
|
6068
|
-
};
|
|
6069
|
-
imports.wbg.__wbg_cursor_new = function(arg0) {
|
|
6070
|
-
const ret = Cursor.__wrap(arg0);
|
|
6175
|
+
imports.wbg.__wbg_lorolist_new = function(arg0) {
|
|
6176
|
+
const ret = LoroList.__wrap(arg0);
|
|
6071
6177
|
return addHeapObject(ret);
|
|
6072
6178
|
};
|
|
6073
6179
|
imports.wbg.__wbg_versionvector_new = function(arg0) {
|
|
@@ -6262,7 +6368,7 @@ function __wbg_get_imports() {
|
|
|
6262
6368
|
wasm.__wbindgen_export_5(deferred0_0, deferred0_1, 1);
|
|
6263
6369
|
}
|
|
6264
6370
|
};
|
|
6265
|
-
imports.wbg.
|
|
6371
|
+
imports.wbg.__wbg_now_cd30a09c9b727b65 = typeof Date.now == 'function' ? Date.now : notDefined('Date.now');
|
|
6266
6372
|
imports.wbg.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
|
|
6267
6373
|
const ret = getObject(arg0).crypto;
|
|
6268
6374
|
return addHeapObject(ret);
|
|
@@ -6526,11 +6632,11 @@ function __wbg_get_imports() {
|
|
|
6526
6632
|
return addHeapObject(ret);
|
|
6527
6633
|
};
|
|
6528
6634
|
imports.wbg.__wbindgen_closure_wrapper482 = function(arg0, arg1, arg2) {
|
|
6529
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6635
|
+
const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_60);
|
|
6530
6636
|
return addHeapObject(ret);
|
|
6531
6637
|
};
|
|
6532
6638
|
imports.wbg.__wbindgen_closure_wrapper485 = function(arg0, arg1, arg2) {
|
|
6533
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6639
|
+
const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_63);
|
|
6534
6640
|
return addHeapObject(ret);
|
|
6535
6641
|
};
|
|
6536
6642
|
|
package/web/loro_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -27,6 +27,7 @@ export function awarenesswasm_removeOutdated(a: number, b: number): void;
|
|
|
27
27
|
export function awarenesswasm_length(a: number): number;
|
|
28
28
|
export function awarenesswasm_isEmpty(a: number): number;
|
|
29
29
|
export function awarenesswasm_peers(a: number, b: number): void;
|
|
30
|
+
export function LORO_VERSION(a: number): void;
|
|
30
31
|
export function run(): void;
|
|
31
32
|
export function encodeFrontiers(a: number, b: number, c: number): void;
|
|
32
33
|
export function decodeFrontiers(a: number, b: number, c: number): void;
|
|
@@ -59,8 +60,13 @@ export function lorodoc_getList(a: number, b: number, c: number): void;
|
|
|
59
60
|
export function lorodoc_getMovableList(a: number, b: number, c: number): void;
|
|
60
61
|
export function lorodoc_getCounter(a: number, b: number, c: number): void;
|
|
61
62
|
export function lorodoc_getTree(a: number, b: number, c: number): void;
|
|
63
|
+
export function lorodoc_hasContainer(a: number, b: number): number;
|
|
62
64
|
export function lorodoc_getContainerById(a: number, b: number, c: number): void;
|
|
63
65
|
export function lorodoc_setNextCommitMessage(a: number, b: number, c: number): void;
|
|
66
|
+
export function lorodoc_setNextCommitOrigin(a: number, b: number, c: number): void;
|
|
67
|
+
export function lorodoc_setNextCommitTimestamp(a: number, b: number): void;
|
|
68
|
+
export function lorodoc_setNextCommitOptions(a: number, b: number, c: number): void;
|
|
69
|
+
export function lorodoc_clearNextCommitOptions(a: number): void;
|
|
64
70
|
export function lorodoc_getDeepValueWithID(a: number): number;
|
|
65
71
|
export function lorodoc_getPathToContainer(a: number, b: number, c: number): void;
|
|
66
72
|
export function lorodoc_JSONPath(a: number, b: number, c: number, d: number): void;
|