@yorkie-js/sdk 0.6.7 → 0.6.9

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/dist/counter.html CHANGED
@@ -15,9 +15,9 @@
15
15
  <button id="decreaseButton">-</button>
16
16
  </div>
17
17
  </div>
18
- <script src="./yorkie-js-sdk.js"></script>
19
18
  <script src="./util.js"></script>
20
- <script>
19
+ <script type="module">
20
+ import './src/yorkie.ts';
21
21
  const statusHolder = document.getElementById('network-status');
22
22
  const onlineClientsHolder = document.getElementById('online-clients');
23
23
  const counter = document.getElementById('counter');
package/dist/drawing.html CHANGED
@@ -19,8 +19,8 @@
19
19
  <pre style="white-space: pre-wrap"><code id="online-clients"></code></pre>
20
20
  <pre style="white-space: pre-wrap" id="log-holder"></pre>
21
21
  </div>
22
- <script src="./yorkie-js-sdk.js"></script>
23
- <script>
22
+ <script type="module">
23
+ import './src/yorkie.ts';
24
24
  const drawingPanel = document.getElementById('drawing-panel');
25
25
  const docPanel = document.getElementById('log-holder');
26
26
  const onlineClientsPanel = document.getElementById('online-clients');
package/dist/multi.html CHANGED
@@ -36,9 +36,9 @@
36
36
  <h2>yorkie document</h2>
37
37
  <pre style="white-space: pre-wrap" id="log-holder"></pre>
38
38
  </div>
39
- <script src="./yorkie-js-sdk.js"></script>
40
39
  <script src="./util.js"></script>
41
- <script>
40
+ <script type="module">
41
+ import './src/yorkie.ts';
42
42
  const statusHolder = document.getElementById('network-status');
43
43
  const placeholder = document.getElementById('placeholder');
44
44
  const onlineClientsHolder = document.getElementById('online-clients');
@@ -4,8 +4,6 @@
4
4
  <meta charset="UTF-8" />
5
5
  <title>ProseMirror Example</title>
6
6
  <link rel="stylesheet" href="prosemirror.css" />
7
- <script src="./yorkie-js-sdk.js"></script>
8
- <script src="./util.js"></script>
9
7
  </head>
10
8
  <body>
11
9
  <div class="layout">
@@ -29,10 +27,6 @@
29
27
  <h2>ProseMirror.Doc</h2>
30
28
  <div id="pm-log"></div>
31
29
  </div>
32
- <div class="data-item">
33
- <h2>Yorkie.Tree</h2>
34
- <div id="yorkie-log"></div>
35
- </div>
36
30
  </div>
37
31
  </div>
38
32
  </div>
@@ -40,18 +34,18 @@
40
34
  <script type="importmap">
41
35
  {
42
36
  "imports": {
37
+ "prosemirror-model": "https://cdn.jsdelivr.net/npm/prosemirror-model@1.23.0/+esm",
43
38
  "prosemirror-state": "https://cdn.jsdelivr.net/npm/prosemirror-state@1.4.3/+esm",
44
- "prosemirror-view": "https://cdn.jsdelivr.net/npm/prosemirror-view@1.31.4/+esm",
45
- "prosemirror-model": "https://cdn.jsdelivr.net/npm/prosemirror-model@1.19.4/+esm",
46
- "prosemirror-transform": "https://cdn.jsdelivr.net//npm/prosemirror-transform@1.7.3/+esm",
39
+ "prosemirror-view": "https://cdn.jsdelivr.net/npm/prosemirror-view@1.37.0/+esm",
40
+ "prosemirror-transform": "https://cdn.jsdelivr.net/npm/prosemirror-transform@1.10.2/+esm",
47
41
  "prosemirror-keymap": "https://cdn.jsdelivr.net/npm/prosemirror-keymap@1.2.2/+esm",
48
42
  "prosemirror-example-setup": "https://cdn.jsdelivr.net/npm/prosemirror-example-setup@1.2.2/+esm",
49
- "prosemirror-commands": "https://cdn.jsdelivr.net/npm/prosemirror-commands@1.5.2/+esm",
50
- "@yorkie-js/sdk": "./yorkie.js"
43
+ "prosemirror-commands": "https://cdn.jsdelivr.net/npm/prosemirror-commands@1.6.2/+esm"
51
44
  }
52
45
  }
53
46
  </script>
54
47
  <script type="module">
48
+ import './src/yorkie.ts';
55
49
  import {
56
50
  EditorState,
57
51
  Transaction,
@@ -274,11 +268,19 @@
274
268
  treeNodeToDoc(JSON.parse(doc.getRoot().tree.toJSON())),
275
269
  ),
276
270
  plugins: [
271
+ ...exampleSetup({ schema: mySchema }).reduce(
272
+ (uniquePlugins, plugin) => {
273
+ if (!uniquePlugins.some((p) => p.key === plugin.key)) {
274
+ uniquePlugins.push(plugin);
275
+ }
276
+ return uniquePlugins;
277
+ },
278
+ [],
279
+ ),
277
280
  keymap({
278
281
  'Ctrl-b': toggleMark(mySchema.marks.shouting),
279
282
  'Ctrl-u': insertStar,
280
283
  }),
281
- ...exampleSetup({ schema: mySchema }),
282
284
  ],
283
285
  });
284
286
 
@@ -511,7 +513,6 @@
511
513
  .join('');
512
514
 
513
515
  paintTree(view.state.doc, 'pm-log');
514
- paintTree(doc.getRoot().tree.tree.getRoot(), 'yorkie-log');
515
516
  paintTransaction();
516
517
  }
517
518
 
@@ -117,9 +117,9 @@
117
117
  <div class="online-clients"></div>
118
118
  </div>
119
119
  </div>
120
- <script src="./yorkie-js-sdk.js"></script>
121
120
  <script src="./util.js"></script>
122
- <script>
121
+ <script type="module">
122
+ import './src/yorkie.ts';
123
123
  const colorHash = new ColorHash();
124
124
  const clientAElem = document.getElementById('client-a');
125
125
  const clientBElem = document.getElementById('client-b');
package/dist/quill.html CHANGED
@@ -19,10 +19,9 @@
19
19
  <div id="editor"></div>
20
20
  <div id="document"></div>
21
21
  <div id="document-text"></div>
22
-
23
- <script src="./yorkie-js-sdk.js"></script>
24
22
  <script src="./util.js"></script>
25
- <script>
23
+ <script type="module">
24
+ import './src/yorkie.ts';
26
25
  const onlineClientsElem = document.getElementById('online-clients');
27
26
  const documentElem = document.getElementById('document');
28
27
  const documentTextElem = document.getElementById('document-text');
@@ -72,9 +72,9 @@
72
72
  </div>
73
73
  </div>
74
74
  </div>
75
- <script src="./yorkie-js-sdk.js"></script>
76
75
  <script src="./util.js"></script>
77
76
  <script type="module">
77
+ import './src/yorkie.ts';
78
78
  import devtool from './devtool/object.js';
79
79
  const statusHolder = document.getElementById('network-status');
80
80
  const onlineClientsHolder = document.getElementById('online-clients');
@@ -1037,9 +1037,9 @@ export declare type CounterOperationInfo = IncreaseOpInfo;
1037
1037
  */
1038
1038
  declare type CounterOperationInfo_2 = IncreaseOpInfo_2;
1039
1039
 
1040
- declare enum CounterType {
1041
- IntegerCnt = 0,
1042
- LongCnt = 1
1040
+ export declare enum CounterType {
1041
+ Int = 0,
1042
+ Long = 1
1043
1043
  }
1044
1044
 
1045
1045
  export declare type CounterValue = number | default_2;
@@ -1132,6 +1132,10 @@ declare class CRDTObject extends CRDTContainer {
1132
1132
  * `has` returns whether the element exists of the given key or not.
1133
1133
  */
1134
1134
  has(key: string): boolean;
1135
+ /**
1136
+ * `getDataSize` returns the data usage of this element.
1137
+ */
1138
+ getDataSize(): DataSize;
1135
1139
  /**
1136
1140
  * `toJSON` returns the JSON encoding of this object.
1137
1141
  */
@@ -1250,6 +1254,10 @@ declare class CRDTRoot {
1250
1254
  * `getGarbageLen` returns length of nodes which can be garbage collected.
1251
1255
  */
1252
1256
  getGarbageLen(): number;
1257
+ /**
1258
+ * `getDocSize` returns the size of the document.
1259
+ */
1260
+ getDocSize(): DocSize;
1253
1261
  /**
1254
1262
  * `deepcopy` copies itself deeply.
1255
1263
  */
@@ -1302,6 +1310,10 @@ declare class CRDTText<A extends Indexable = Indexable> extends CRDTElement {
1302
1310
  * `getTreeByID` returns the tree by ID for debugging.
1303
1311
  */
1304
1312
  getTreeByID(): LLRBTree<RGATreeSplitNodeID, RGATreeSplitNode<CRDTTextValue>>;
1313
+ /**
1314
+ * `getDataSize` returns the data usage of this element.
1315
+ */
1316
+ getDataSize(): DataSize;
1305
1317
  /**
1306
1318
  * `toJSON` returns the JSON encoding of this text.
1307
1319
  */
@@ -1376,6 +1388,10 @@ declare class CRDTTextValue {
1376
1388
  * `toString` returns the string representation of this value.
1377
1389
  */
1378
1390
  toString(): string;
1391
+ /**
1392
+ * `getDataSize` returns the data usage of this value.
1393
+ */
1394
+ getDataSize(): DataSize;
1379
1395
  /**
1380
1396
  * `toJSON` returns the JSON encoding of this value.
1381
1397
  */
@@ -1453,6 +1469,10 @@ declare class CRDTTree extends CRDTElement implements GCParent {
1453
1469
  * `move` move the given source range to the given target range.
1454
1470
  */
1455
1471
  move(target: [number, number], source: [number, number], ticket: TimeTicket): void;
1472
+ /**
1473
+ * `pathToTreePos` converts the given path of the node to the TreePos.
1474
+ */
1475
+ pathToTreePos(path: Array<number>): ReturnType<typeof CRDTTree.indexTree.pathToTreePos>;
1456
1476
  /**
1457
1477
  * `purge` physically purges the given node.
1458
1478
  */
@@ -1493,6 +1513,10 @@ declare class CRDTTree extends CRDTElement implements GCParent {
1493
1513
  * toXML returns the XML encoding of this tree.
1494
1514
  */
1495
1515
  toXML(): string;
1516
+ /**
1517
+ * `getDataSize` returns the data usage of this element.
1518
+ */
1519
+ getDataSize(): DataSize;
1496
1520
  /**
1497
1521
  * `toJSON` returns the JSON encoding of this tree.
1498
1522
  */
@@ -1657,6 +1681,10 @@ declare class CRDTTreeNode extends IndexTreeNode<CRDTTreeNode> implements GCPare
1657
1681
  * `purge` purges the given child node.
1658
1682
  */
1659
1683
  purge(node: RHTNode): void;
1684
+ /**
1685
+ * `getDataSize` returns the data size of the node.
1686
+ */
1687
+ getDataSize(): DataSize;
1660
1688
  /**
1661
1689
  * `getGCPairs` returns the pairs of GC.
1662
1690
  */
@@ -1806,6 +1834,20 @@ declare type CRDTTreePosStruct_2 = {
1806
1834
  leftSiblingID: CRDTTreeNodeIDStruct;
1807
1835
  };
1808
1836
 
1837
+ /**
1838
+ * `DataSize` represents the size of a resource in bytes.
1839
+ */
1840
+ declare type DataSize = {
1841
+ /**
1842
+ * `data` is the size of the data in bytes.
1843
+ */
1844
+ data: number;
1845
+ /**
1846
+ * `meta` is the size of the metadata in bytes.
1847
+ */
1848
+ meta: number;
1849
+ };
1850
+
1809
1851
  /**
1810
1852
  * `DecreasedDepthOf` represents the type of the decreased depth of the given depth.
1811
1853
  */
@@ -2149,6 +2191,20 @@ declare enum DocEventType_3 {
2149
2191
  */
2150
2192
  declare type DocKey = string;
2151
2193
 
2194
+ /**
2195
+ * `DocSize` represents the size of a document in bytes.
2196
+ */
2197
+ declare type DocSize = {
2198
+ /**
2199
+ * `live` is the size of the document in bytes.
2200
+ */
2201
+ live: DataSize;
2202
+ /**
2203
+ * `gc` is the size of the garbage collected data in bytes.
2204
+ */
2205
+ gc: DataSize;
2206
+ };
2207
+
2152
2208
  /**
2153
2209
  * `DocStatus` represents the status of the document.
2154
2210
  * @public
@@ -2372,6 +2428,10 @@ declare class Document_2<R, P extends Indexable = Indexable> {
2372
2428
  * `getRoot` returns a new proxy of cloned root.
2373
2429
  */
2374
2430
  getRoot(): JSONObject<R>;
2431
+ /**
2432
+ * `getDocSize` returns the size of this document.
2433
+ */
2434
+ getDocSize(): DocSize;
2375
2435
  /* Excluded from this release type: garbageCollect */
2376
2436
  /* Excluded from this release type: getRootObject */
2377
2437
  /* Excluded from this release type: getGarbageLen */
@@ -2694,6 +2754,7 @@ export declare type FullSDKToPanelMessage = SDKToPanelMessage & {
2694
2754
  declare interface GCChild {
2695
2755
  toIDString(): string;
2696
2756
  getRemovedAt(): TimeTicket | undefined;
2757
+ getDataSize(): DataSize;
2697
2758
  }
2698
2759
 
2699
2760
  /**
@@ -2941,6 +3002,10 @@ declare abstract class IndexTreeNode<T extends IndexTreeNode<T>> {
2941
3002
  * `hasTextChild` returns true if the node's children consist of only text children.
2942
3003
  */
2943
3004
  hasTextChild(): boolean;
3005
+ /**
3006
+ * `getChildrenText` returns text value of all text type children.
3007
+ */
3008
+ getChildrenText(): string;
2944
3009
  /**
2945
3010
  * `append` appends the given nodes to the children.
2946
3011
  */
@@ -4209,6 +4274,15 @@ export declare class Primitive extends CRDTElement {
4209
4274
  * `valueFromBytes` parses the given bytes into value.
4210
4275
  */
4211
4276
  static valueFromBytes(primitiveType: PrimitiveType, bytes: Uint8Array): PrimitiveValue;
4277
+ /**
4278
+ * `getValueSize` returns the size of the value. The size is similar to
4279
+ * the size of primitives in JavaScript.
4280
+ */
4281
+ private getValueSize;
4282
+ /**
4283
+ * `getDataSize` returns the data usage of this element.
4284
+ */
4285
+ getDataSize(): DataSize;
4212
4286
  /**
4213
4287
  * `toJSON` returns the JSON encoding of the value.
4214
4288
  */
@@ -4557,6 +4631,10 @@ declare class RGATreeSplitNode<T extends RGATreeSplitValue> extends SplayNode<T>
4557
4631
  * `createRange` creates ranges of RGATreeSplitPos.
4558
4632
  */
4559
4633
  createPosRange(): RGATreeSplitPosRange;
4634
+ /**
4635
+ * `getData` returns the data of this node.
4636
+ */
4637
+ getDataSize(): DataSize;
4560
4638
  /**
4561
4639
  * `deepcopy` returns a new instance of this RGATreeSplitNode without structural info.
4562
4640
  */
@@ -4688,6 +4766,7 @@ declare type RGATreeSplitPosStruct = {
4688
4766
  declare interface RGATreeSplitValue {
4689
4767
  length: number;
4690
4768
  substring(indexStart: number, indexEnd?: number): RGATreeSplitValue;
4769
+ getDataSize(): DataSize;
4691
4770
  }
4692
4771
 
4693
4772
  /**
@@ -4786,6 +4865,10 @@ declare class RHTNode implements GCChild {
4786
4865
  * `getRemovedAt` returns the time when this node was removed.
4787
4866
  */
4788
4867
  getRemovedAt(): TimeTicket | undefined;
4868
+ /**
4869
+ * `getDataSize` returns the size of this node.
4870
+ */
4871
+ getDataSize(): DataSize;
4789
4872
  }
4790
4873
 
4791
4874
  /**
@@ -5586,6 +5669,14 @@ export declare class Tree {
5586
5669
  * `getIndexTree` returns the index tree of this tree.
5587
5670
  */
5588
5671
  getIndexTree(): IndexTree<CRDTTreeNode>;
5672
+ /**
5673
+ * `splitByPath` splits the tree by the given path.
5674
+ */
5675
+ splitByPath(path: Array<number>): void;
5676
+ /**
5677
+ * `mergeByPath` merges the tree by the given path.
5678
+ */
5679
+ mergeByPath(path: Array<number>): void;
5589
5680
  /**
5590
5681
  * `styleByPath` sets the attributes to the elements of the given path.
5591
5682
  */