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/web/loro_wasm.js CHANGED
@@ -1449,6 +1449,8 @@ export class LoroDoc {
1449
1449
  * The object returned is a new js object each time because it need to cross
1450
1450
  * the WASM boundary.
1451
1451
  *
1452
+ * If the container does not exist, an error will be thrown.
1453
+ *
1452
1454
  * @example
1453
1455
  * ```ts
1454
1456
  * import { LoroDoc } from "loro-crdt";
@@ -1481,6 +1483,8 @@ export class LoroDoc {
1481
1483
  * The object returned is a new js object each time because it need to cross
1482
1484
  * the WASM boundary.
1483
1485
  *
1486
+ * If the container does not exist, an error will be thrown.
1487
+ *
1484
1488
  * @example
1485
1489
  * ```ts
1486
1490
  * import { LoroDoc } from "loro-crdt";
@@ -1513,6 +1517,8 @@ export class LoroDoc {
1513
1517
  * The object returned is a new js object each time because it need to cross
1514
1518
  * the WASM boundary.
1515
1519
  *
1520
+ * If the container does not exist, an error will be thrown.
1521
+ *
1516
1522
  * @example
1517
1523
  * ```ts
1518
1524
  * import { LoroDoc } from "loro-crdt";
@@ -1545,6 +1551,8 @@ export class LoroDoc {
1545
1551
  * The object returned is a new js object each time because it need to cross
1546
1552
  * the WASM boundary.
1547
1553
  *
1554
+ * If the container does not exist, an error will be thrown.
1555
+ *
1548
1556
  * @example
1549
1557
  * ```ts
1550
1558
  * import { LoroDoc } from "loro-crdt";
@@ -1573,6 +1581,8 @@ export class LoroDoc {
1573
1581
  }
1574
1582
  /**
1575
1583
  * Get a LoroCounter by container id
1584
+ *
1585
+ * If the container does not exist, an error will be thrown.
1576
1586
  * @param {ContainerID | string} cid
1577
1587
  * @returns {LoroCounter}
1578
1588
  */
@@ -1598,6 +1608,8 @@ export class LoroDoc {
1598
1608
  * The object returned is a new js object each time because it need to cross
1599
1609
  * the WASM boundary.
1600
1610
  *
1611
+ * If the container does not exist, an error will be thrown.
1612
+ *
1601
1613
  * @example
1602
1614
  * ```ts
1603
1615
  * import { LoroDoc } from "loro-crdt";
@@ -1625,8 +1637,42 @@ export class LoroDoc {
1625
1637
  }
1626
1638
  }
1627
1639
  /**
1628
- * Get the container corresponding to the container id
1640
+ * Check if the doc contains the target container.
1641
+ *
1642
+ * A root container always exists, while a normal container exists
1643
+ * if it has ever been created on the doc.
1644
+ *
1645
+ * @example
1646
+ * ```ts
1647
+ * import { LoroDoc, LoroMap, LoroText, LoroList } from "loro-crdt";
1648
+ *
1649
+ * const doc = new LoroDoc();
1650
+ * doc.setPeerId("1");
1651
+ * const text = doc.getMap("map").setContainer("text", new LoroText());
1652
+ * const list = doc.getMap("map").setContainer("list", new LoroList());
1653
+ * expect(doc.isContainerExists("cid:root-map:Map")).toBe(true);
1654
+ * expect(doc.isContainerExists("cid:0@1:Text")).toBe(true);
1655
+ * expect(doc.isContainerExists("cid:1@1:List")).toBe(true);
1656
+ *
1657
+ * const doc2 = new LoroDoc();
1658
+ * // Containers exist, as long as the history or the doc state include it
1659
+ * doc.detach();
1660
+ * doc2.import(doc.export({ mode: "update" }));
1661
+ * expect(doc2.isContainerExists("cid:root-map:Map")).toBe(true);
1662
+ * expect(doc2.isContainerExists("cid:0@1:Text")).toBe(true);
1663
+ * expect(doc2.isContainerExists("cid:1@1:List")).toBe(true);
1664
+ * ```
1665
+ * @param {ContainerID} container_id
1666
+ * @returns {boolean}
1667
+ */
1668
+ hasContainer(container_id) {
1669
+ const ret = wasm.lorodoc_hasContainer(this.__wbg_ptr, addHeapObject(container_id));
1670
+ return ret !== 0;
1671
+ }
1672
+ /**
1673
+ * Get the container corresponding to the container id.
1629
1674
  *
1675
+ * If the container does not exist, it returns `undefined`.
1630
1676
  *
1631
1677
  * @example
1632
1678
  * ```ts
@@ -6038,36 +6084,36 @@ function __wbg_get_imports() {
6038
6084
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
6039
6085
  takeObject(arg0);
6040
6086
  };
6087
+ imports.wbg.__wbg_lorocounter_new = function(arg0) {
6088
+ const ret = LoroCounter.__wrap(arg0);
6089
+ return addHeapObject(ret);
6090
+ };
6041
6091
  imports.wbg.__wbg_lorotreenode_new = function(arg0) {
6042
6092
  const ret = LoroTreeNode.__wrap(arg0);
6043
6093
  return addHeapObject(ret);
6044
6094
  };
6045
- imports.wbg.__wbg_lorotree_new = function(arg0) {
6046
- const ret = LoroTree.__wrap(arg0);
6095
+ imports.wbg.__wbg_cursor_new = function(arg0) {
6096
+ const ret = Cursor.__wrap(arg0);
6047
6097
  return addHeapObject(ret);
6048
6098
  };
6049
- imports.wbg.__wbg_lorolist_new = function(arg0) {
6050
- const ret = LoroList.__wrap(arg0);
6099
+ imports.wbg.__wbg_loromap_new = function(arg0) {
6100
+ const ret = LoroMap.__wrap(arg0);
6051
6101
  return addHeapObject(ret);
6052
6102
  };
6053
- imports.wbg.__wbg_lorocounter_new = function(arg0) {
6054
- const ret = LoroCounter.__wrap(arg0);
6103
+ imports.wbg.__wbg_lorotext_new = function(arg0) {
6104
+ const ret = LoroText.__wrap(arg0);
6055
6105
  return addHeapObject(ret);
6056
6106
  };
6057
- imports.wbg.__wbg_loromap_new = function(arg0) {
6058
- const ret = LoroMap.__wrap(arg0);
6107
+ imports.wbg.__wbg_lorotree_new = function(arg0) {
6108
+ const ret = LoroTree.__wrap(arg0);
6059
6109
  return addHeapObject(ret);
6060
6110
  };
6061
6111
  imports.wbg.__wbg_loromovablelist_new = function(arg0) {
6062
6112
  const ret = LoroMovableList.__wrap(arg0);
6063
6113
  return addHeapObject(ret);
6064
6114
  };
6065
- imports.wbg.__wbg_lorotext_new = function(arg0) {
6066
- const ret = LoroText.__wrap(arg0);
6067
- return addHeapObject(ret);
6068
- };
6069
- imports.wbg.__wbg_cursor_new = function(arg0) {
6070
- const ret = Cursor.__wrap(arg0);
6115
+ imports.wbg.__wbg_lorolist_new = function(arg0) {
6116
+ const ret = LoroList.__wrap(arg0);
6071
6117
  return addHeapObject(ret);
6072
6118
  };
6073
6119
  imports.wbg.__wbg_versionvector_new = function(arg0) {
@@ -6262,7 +6308,7 @@ function __wbg_get_imports() {
6262
6308
  wasm.__wbindgen_export_5(deferred0_0, deferred0_1, 1);
6263
6309
  }
6264
6310
  };
6265
- imports.wbg.__wbg_now_bc6f749123583eb9 = typeof Date.now == 'function' ? Date.now : notDefined('Date.now');
6311
+ imports.wbg.__wbg_now_cd30a09c9b727b65 = typeof Date.now == 'function' ? Date.now : notDefined('Date.now');
6266
6312
  imports.wbg.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
6267
6313
  const ret = getObject(arg0).crypto;
6268
6314
  return addHeapObject(ret);
@@ -6526,11 +6572,11 @@ function __wbg_get_imports() {
6526
6572
  return addHeapObject(ret);
6527
6573
  };
6528
6574
  imports.wbg.__wbindgen_closure_wrapper482 = function(arg0, arg1, arg2) {
6529
- const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_60);
6575
+ const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_60);
6530
6576
  return addHeapObject(ret);
6531
6577
  };
6532
6578
  imports.wbg.__wbindgen_closure_wrapper485 = function(arg0, arg1, arg2) {
6533
- const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_63);
6579
+ const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_63);
6534
6580
  return addHeapObject(ret);
6535
6581
  };
6536
6582
 
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;