@cr_docs_t/dts 0.28.1 → 0.30.0

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.
Files changed (36) hide show
  1. package/dist/dts/FugueTree/FTree.d.ts +1 -0
  2. package/dist/dts/FugueTree/FTree.d.ts.map +1 -1
  3. package/dist/dts/FugueTree/FTree.js +9 -16
  4. package/dist/dts/FugueTree/FugueTree.d.ts +2 -1
  5. package/dist/dts/FugueTree/FugueTree.d.ts.map +1 -1
  6. package/dist/dts/FugueTree/FugueTree.js +9 -0
  7. package/dist/dts/Serailizers/FugueTree/Message.d.ts +1 -5
  8. package/dist/dts/Serailizers/FugueTree/Message.d.ts.map +1 -1
  9. package/dist/dts/Serailizers/FugueTree/Message.js +14 -12
  10. package/dist/dts/Serailizers/General.d.ts +12 -0
  11. package/dist/dts/Serailizers/General.d.ts.map +1 -0
  12. package/dist/dts/Serailizers/General.js +37 -0
  13. package/dist/dts/Serailizers/Presence.d.ts +9 -0
  14. package/dist/dts/Serailizers/Presence.d.ts.map +1 -0
  15. package/dist/dts/Serailizers/Presence.js +23 -0
  16. package/dist/dts/Serailizers/index.d.ts +2 -0
  17. package/dist/dts/Serailizers/index.d.ts.map +1 -1
  18. package/dist/dts/Serailizers/index.js +2 -0
  19. package/dist/treesitter/parser.d.ts.map +1 -1
  20. package/dist/treesitter/parser.js +0 -1
  21. package/dist/types/FugueTree/Message.d.ts +5 -5
  22. package/dist/types/FugueTree/Message.d.ts.map +1 -1
  23. package/dist/types/FugueTree/Message.js +7 -0
  24. package/dist/types/Message.d.ts +10 -0
  25. package/dist/types/Message.d.ts.map +1 -0
  26. package/dist/types/Message.js +5 -0
  27. package/dist/types/Presence.d.ts +14 -0
  28. package/dist/types/Presence.d.ts.map +1 -0
  29. package/dist/types/Presence.js +12 -0
  30. package/dist/types/index.d.ts +2 -0
  31. package/dist/types/index.d.ts.map +1 -1
  32. package/dist/types/index.js +2 -0
  33. package/dist/utils/index.d.ts +5 -0
  34. package/dist/utils/index.d.ts.map +1 -1
  35. package/dist/utils/index.js +23 -0
  36. package/package.json +1 -1
@@ -143,5 +143,6 @@ export declare class FTree {
143
143
  * @param saveData - a Uint8Array containing the serialized tree data to load
144
144
  */
145
145
  load(saveData: Uint8Array): void;
146
+ getNodes(): Map<string, FNode[]>;
146
147
  }
147
148
  //# sourceMappingURL=FTree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FTree.d.ts","sourceRoot":"","sources":["../../../src/dts/FugueTree/FTree.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,GAAG,CAAC;AAEjC;;;GAGG;AACH,MAAM,MAAM,EAAE,GAAG;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,KAAK;IAClB,EAAE,EAAE,EAAE,CAAC;IACP,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,KAAK,EAAE,CAAC;IACtB,aAAa,EAAE,KAAK,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,qBAAa,KAAK;IAGd,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;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IACH,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ5C;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK;IAkC7C;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM;IAoCpC;;;;;OAKG;IACH,kBAAkB,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK;IAMtC;;;;;OAKG;IACH,iBAAiB,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,IAAI;IAoB5C;;;OAGG;IACF,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAiChD;;;;;OAKG;IACH,IAAI,IAAI,UAAU;IAqBlB;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,EAAE,UAAU;IA2EzB,QAAQ;CAGX"}
@@ -317,9 +317,7 @@ export class FTree {
317
317
  */
318
318
  *traverse(node) {
319
319
  let current = node;
320
- // Stack records the next child to visit for that node.
321
- // We don't need to store node because we can infer it from the
322
- // current node's parent etc.
320
+ // Stack based inorder traversal
323
321
  const S = [{ side: "L", childIndex: 0 }];
324
322
  while (true) {
325
323
  const top = S[S.length - 1];
@@ -377,7 +375,7 @@ export class FTree {
377
375
  return nodeSave;
378
376
  });
379
377
  }
380
- return new Uint8Array(Buffer.from(JSON.stringify(save)));
378
+ return new TextEncoder().encode(JSON.stringify(save)); //allows us to encode from the frontend
381
379
  }
382
380
  /**
383
381
  * Load the tree from a Uint8Array containing serialized tree data in the format produced by the save() method.
@@ -387,8 +385,7 @@ export class FTree {
387
385
  */
388
386
  load(saveData) {
389
387
  const save = JSON.parse(new TextDecoder().decode(saveData));
390
- // First create all nodes without pointers to other nodes (parent, children,
391
- // rightOrigin).
388
+ // Create nodes without pointers
392
389
  for (const [sender, bySenderSave] of Object.entries(save)) {
393
390
  if (sender === "") {
394
391
  // Root node. Just set its size.
@@ -406,7 +403,7 @@ export class FTree {
406
403
  rightChildren: [],
407
404
  })));
408
405
  }
409
- // Next, fill in the parent and rightOrigin pointers.
406
+ // Fill in the parent and rightOrigin pointers.
410
407
  for (const [sender, bySender] of this.nodes) {
411
408
  if (sender === "")
412
409
  continue;
@@ -422,14 +419,8 @@ export class FTree {
422
419
  }
423
420
  }
424
421
  }
425
- // Finally, call insertIntoSiblings on each node to fill in the children
426
- // arrays.
427
- // We must be careful to wait until after doing so for node.rightOrigin
428
- // and its ancestors, since insertIntoSiblings references the existing list order
429
- // on node.rightOrigin.
430
- // Nodes go from "pending" -> "ready" (rightOrigin valid) ->
431
- // "valid" (insertIntoSiblings called).
432
- // readyNodes is a stack; pendingNodes maps from a node to its dependencies.
422
+ // Call insertIntoSiblings on each node to fill in the children arrays. Making sure to buffer nodes
423
+ // until their rightOrigin exists because insertIntoSiblings uses it to maintain sibling order
433
424
  const readyNodes = [];
434
425
  const pendingNodes = new Map();
435
426
  for (const [sender, bySender] of this.nodes) {
@@ -454,7 +445,6 @@ export class FTree {
454
445
  while (readyNodes.length !== 0) {
455
446
  const node = readyNodes.pop();
456
447
  this.insertIntoSiblings(node);
457
- // node's dependencies are now ready.
458
448
  const deps = pendingNodes.get(node);
459
449
  if (deps !== undefined)
460
450
  readyNodes.push(...deps);
@@ -464,4 +454,7 @@ export class FTree {
464
454
  throw new Error("Failed to validate all nodes");
465
455
  }
466
456
  }
457
+ getNodes() {
458
+ return this.nodes;
459
+ }
467
460
  }
@@ -1,5 +1,5 @@
1
1
  import { FugueMessage } from "../../types/FugueTree/Message.js";
2
- import { FNode, ID } from "./FTree.js";
2
+ import { FNode, FTree, ID } from "./FTree.js";
3
3
  /**
4
4
  * A Fugue Tree CRDT, with insert and delete operations.
5
5
  */
@@ -123,5 +123,6 @@ export declare class FugueTree {
123
123
  * @returns the index of the given node in the visible string
124
124
  */
125
125
  getVisibleIndex(node: FNode): number;
126
+ getState(): FTree;
126
127
  }
127
128
  //# sourceMapp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;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAuBlB;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IA4B5C;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM;IAKpB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAgCnB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAkBtB;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,EAAE,GAAG,YAAY,EAAE;IAuB1D;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAS1B;;;OAGG;IACH,MAAM,IAAI,MAAM;IAIhB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAWjB;;;OAGG;IACH,IAAI,IAAI,UAAU;IAKlB;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAK5B;;;;;OAKG;IACH,SAAS,IAAI,MAAM;IAInB;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,EAAE;IAId;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,KAAK;IAI3B,QAAQ;CAGX"}
@@ -1,4 +1,5 @@
1
1
  import { Operation } from "../../types/FugueTree/Message.js";
2
+ import { MessageType } from "../../types/Message.js";
2
3
  import { randomString } from "../../utils/index.js";
3
4
  import { FugueMessageSerialzier } from "../Serailizers/FugueTree/index.js";
4
5
  import { FTree } from "./FTree.js";
@@ -53,6 +54,7 @@ export class FugueTree {
53
54
  // leftOrigin has no right children, so the new node becomes
54
55
  // a right child of leftOrigin.
55
56
  msg = {
57
+ msgType: MessageType.FUGUE,
56
58
  userIdentity: this.userIdentity,
57
59
  operation: Operation.INSERT,
58
60
  id,
@@ -74,6 +76,7 @@ export class FugueTree {
74
76
  // first right child.
75
77
  const rightOrigin = this.tree.leftmostDescendant(leftOrigin.rightChildren[0]);
76
78
  msg = {
79
+ msgType: MessageType.FUGUE,
77
80
  userIdentity: this.userIdentity,
78
81
  operation: Operation.INSERT,
79
82
  id,
@@ -142,6 +145,7 @@ export class FugueTree {
142
145
  this.tree.updateSize(node, -1);
143
146
  }
144
147
  const msg = {
148
+ msgType: MessageType.FUGUE,
145
149
  operation: Operation.DELETE,
146
150
  documentID: this.documentID,
147
151
  replicaId: this.replicaID,
@@ -207,6 +211,7 @@ export class FugueTree {
207
211
  return true;
208
212
  }
209
213
  catch (e) {
214
+ //console.log('Error from insert -> ', e);
210
215
  return false;
211
216
  }
212
217
  case Operation.DELETE:
@@ -220,6 +225,7 @@ export class FugueTree {
220
225
  return true;
221
226
  }
222
227
  catch (e) {
228
+ //console.log('Error from delete -> ', e);
223
229
  return false;
224
230
  }
225
231
  default:
@@ -348,4 +354,7 @@ export class FugueTree {
348
354
  getVisibleIndex(node) {
349
355
  return this.tree.getVisibleIndex(node);
350
356
  }
357
+ getState() {
358
+ return this.tree;
359
+ }
351
360
  }
@@ -1,13 +1,9 @@
1
- import { BaseFugueMessage, FugueMessageType } from "../../../types/FugueTree/index.js";
1
+ import { BaseFugueMessage } from "../../../types/FugueTree/index.js";
2
2
  declare function serialize(msgs: BaseFugueMessage[]): Uint8Array<ArrayBuffer>;
3
- declare function serializeSingleMessage(msg: FugueMessageType): Uint8Array<ArrayBuffer>;
4
3
  declare function deserialize(data: Uint8Array): BaseFugueMessage[];
5
- declare function deserializeSingleMessage(data: Uint8Array): BaseFugueMessage;
6
4
  export declare const FugueMessageSerialzier: {
7
5
  serialize: typeof serialize;
8
- serializeSingleMessage: typeof serializeSingleMessage;
9
6
  deserialize: typeof deserialize;
10
- deserializeSingleMessage: typeof deserializeSingleMessage;
11
7
  };
12
8
  export {};
13
9
  //# sourceMappingURL=Message.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../../src/dts/Serailizers/FugueTree/Message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAEvF,iBAAS,SAAS,CAAC,IAAI,EAAE,gBAAgB,EAAE,2BAE1C;AAED,iBAAS,sBAAsB,CAAC,GAAG,EAAE,gBAAgB,2BAEpD;AAED,iBAAS,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,gBAAgB,EAAE,CAGzD;AAED,iBAAS,wBAAwB,CAAC,IAAI,EAAE,UAAU,GAAG,gBAAgB,CAGpE;AAED,eAAO,MAAM,sBAAsB;;;;;CAKlC,CAAC"}
1
+ {"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../../src/dts/Serailizers/FugueTree/Message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,mCAAmC,CAAC;AAGvF,iBAAS,SAAS,CAAC,IAAI,EAAE,gBAAgB,EAAE,2BAS1C;AAED,iBAAS,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,gBAAgB,EAAE,CAMzD;AAED,eAAO,MAAM,sBAAsB;;;CAGlC,CAAC"}
@@ -1,21 +1,23 @@
1
1
  import { encode, decode } from "@msgpack/msgpack";
2
+ import { MessageType } from "../../../types/Message.js";
2
3
  function serialize(msgs) {
3
- return encode(msgs);
4
- }
5
- function serializeSingleMessage(msg) {
6
- return encode(msg);
4
+ if (msgs.length === 0)
5
+ return new Uint8Array();
6
+ const enced = encode(msgs);
7
+ // Add magic byte at the beginning to indicate message type
8
+ const buff = new Uint8Array(enced.length + 1);
9
+ buff[0] = MessageType.FUGUE;
10
+ buff.set(enced, 1);
11
+ return buff;
7
12
  }
8
13
  function deserialize(data) {
9
- const dec = decode(data);
10
- return dec;
11
- }
12
- function deserializeSingleMessage(data) {
13
- const dec = decode(data);
14
- return dec;
14
+ if (data.length === 0)
15
+ return [];
16
+ const type = data[0];
17
+ const payload = data.slice(1);
18
+ return decode(payload);
15
19
  }
16
20
  export const FugueMessageSerialzier = {
17
21
  serialize,
18
- serializeSingleMessage,
19
22
  deserialize,
20
- deserializeSingleMessage,
21
23
  };
@@ -0,0 +1,12 @@
1
+ import { BasePresenceMessage } from "../../types/Presence.js";
2
+ import { BaseMessage } from "../../types/Message.js";
3
+ import { BaseFugueMessage } from "../../types/index.js";
4
+ export type Message = BaseFugueMessage[] | BasePresenceMessage[];
5
+ declare function serialize(msgs: BaseMessage | BaseMessage[]): Uint8Array;
6
+ declare function deserialize(bytes: Uint8Array): Message;
7
+ export declare const Seralizer: {
8
+ serialize: typeof serialize;
9
+ deserialize: typeof deserialize;
10
+ };
11
+ export {};
12
+ //# sourceMappingURL=General.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"General.d.ts","sourceRoot":"","sources":["../../../src/dts/Serailizers/General.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAe,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD,MAAM,MAAM,OAAO,GAAG,gBAAgB,EAAE,GAAG,mBAAmB,EAAE,CAAC;AAEjE,iBAAS,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,EAAE,GAAG,UAAU,CAchE;AAED,iBAAS,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAgB/C;AAED,eAAO,MAAM,SAAS;;;CAGrB,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { MessageType } from "../../types/Message.js";
2
+ import { FugueMessageSerialzier } from "./FugueTree/Message.js";
3
+ import { PresenceMessageSerializer } from "./Presence.js";
4
+ function serialize(msgs) {
5
+ const msgArr = Array.isArray(msgs) ? msgs : [msgs];
6
+ const type = msgArr[0].msgType;
7
+ switch (type) {
8
+ case MessageType.FUGUE:
9
+ return FugueMessageSerialzier.serialize(msgArr);
10
+ case MessageType.PRESENCE:
11
+ return PresenceMessageSerializer.serialize(msgArr);
12
+ default:
13
+ // Exhastive check to make sure we handled all message types
14
+ const _exhaustiveCheck = type;
15
+ throw new Error(`Unsupported message type: ${type}`);
16
+ }
17
+ }
18
+ function deserialize(bytes) {
19
+ if (bytes.length === 0)
20
+ return [];
21
+ // Read magic byte to determine message type
22
+ const type = bytes[0];
23
+ switch (type) {
24
+ case MessageType.FUGUE:
25
+ return FugueMessageSerialzier.deserialize(bytes);
26
+ case MessageType.PRESENCE:
27
+ return PresenceMessageSerializer.deserialize(bytes);
28
+ default:
29
+ // Exhastive check to make sure we handled all message types
30
+ const _exhaustiveCheck = type;
31
+ throw new Error(`Unsupported message type: ${type}`);
32
+ }
33
+ }
34
+ export const Seralizer = {
35
+ serialize,
36
+ deserialize,
37
+ };
@@ -0,0 +1,9 @@
1
+ import { BasePresenceMessage } from "../../types/Presence.js";
2
+ declare function serialize(msgs: BasePresenceMessage[]): Uint8Array<ArrayBuffer>;
3
+ declare function deserialize(data: Uint8Array): BasePresenceMessage[];
4
+ export declare const PresenceMessageSerializer: {
5
+ serialize: typeof serialize;
6
+ deserialize: typeof deserialize;
7
+ };
8
+ export {};
9
+ //# sourceMappingURL=Presence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Presence.d.ts","sourceRoot":"","sources":["../../../src/dts/Serailizers/Presence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,iBAAS,SAAS,CAAC,IAAI,EAAE,mBAAmB,EAAE,2BAS7C;AAED,iBAAS,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,mBAAmB,EAAE,CAM5D;AAED,eAAO,MAAM,yBAAyB;;;CAGrC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { encode, decode } from "@msgpack/msgpack";
2
+ import { MessageType } from "../../types/Message.js";
3
+ function serialize(msgs) {
4
+ if (msgs.length === 0)
5
+ return new Uint8Array();
6
+ const enced = encode(msgs);
7
+ // Add magic byte at the beginning to indicate message type
8
+ const buff = new Uint8Array(enced.length + 1);
9
+ buff[0] = MessageType.PRESENCE;
10
+ buff.set(enced, 1);
11
+ return buff;
12
+ }
13
+ function deserialize(data) {
14
+ if (data.length === 0)
15
+ return [];
16
+ const type = data[0];
17
+ const payload = data.slice(1);
18
+ return decode(payload);
19
+ }
20
+ export const PresenceMessageSerializer = {
21
+ serialize,
22
+ deserialize,
23
+ };
@@ -1,2 +1,4 @@
1
1
  export * from "./FugueTree/index.js";
2
+ export * from "./Presence.js";
3
+ export * from "./General.js";
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dts/Serailizers/index.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dts/Serailizers/index.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
@@ -1,2 +1,4 @@
1
1
  // export * from "./Fugue/index.js";
2
2
  export * from "./FugueTree/index.js";
3
+ export * from "./Presence.js";
4
+ export * from "./General.js";
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/treesitter/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAI1D,eAAO,MAAM,SAAS,GAAU,qBAAqB,MAAM,EAAE,eAAe,MAAM;YAF/C,MAAM;WAAS,KAAK;EA8BtD,CAAC"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/treesitter/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAI1D,eAAO,MAAM,SAAS,GAAU,qBAAqB,MAAM,EAAE,eAAe,MAAM;YAF/C,MAAM;WAAS,KAAK;EA6BtD,CAAC"}
@@ -7,7 +7,6 @@ export const newParser = async (treeSitterLatexPath, queryFilePath) => {
7
7
  try {
8
8
  await Parser.init({
9
9
  locateFile: (name, dir) => {
10
- console.log({ name, dir });
11
10
  // return `/${name}`;
12
11
  return "/tree-sitter.wasm";
13
12
  },
@@ -1,4 +1,5 @@
1
- import { ID, NodeSide } from "../../dts/FugueTree/FTree";
1
+ import { ID, NodeSide } from "../../dts/FugueTree/FTree.js";
2
+ import { BaseMessage, MessageType } from "../Message.js";
2
3
  export declare enum Operation {
3
4
  INSERT = 0,
4
5
  DELETE = 1,
@@ -9,11 +10,9 @@ export declare enum Operation {
9
10
  }
10
11
  export declare function operationToString(op: Operation): string;
11
12
  export type Data = string;
12
- export interface BaseFugueMessage<T extends Operation = Operation> {
13
+ export interface BaseFugueMessage<T extends Operation = Operation> extends BaseMessage<MessageType.FUGUE> {
13
14
  operation: T;
14
- documentID: string;
15
15
  replicaId: string;
16
- userIdentity: string;
17
16
  }
18
17
  export interface FugueMessage extends BaseFugueMessage<Operation.INSERT | Operation.DELETE> {
19
18
  id: ID;
@@ -24,7 +23,6 @@ export interface FugueMessage extends BaseFugueMessage<Operation.INSERT | Operat
24
23
  }
25
24
  export interface FugueJoinMessage extends BaseFugueMessage<Operation.INITIAL_SYNC> {
26
25
  state: Uint8Array<ArrayBufferLike> | null;
27
- bufferedOperations?: Buffer<ArrayBuffer>[];
28
26
  }
29
27
  export interface FugueRejectMessage extends BaseFugueMessage<Operation.REJECT> {
30
28
  documentID: string;
@@ -36,7 +34,9 @@ export interface FugueLeaveMessage extends BaseFugueMessage<Operation.LEAVE> {
36
34
  }
37
35
  export interface FugueUserJoinMessage extends BaseFugueMessage<Operation.USER_JOIN> {
38
36
  collaborators: string[];
37
+ offlineState?: Uint8Array<ArrayBufferLike>;
39
38
  }
40
39
  export type FugueMessageType = FugueMessage | FugueJoinMessage | FugueRejectMessage | FugueLeaveMessage | FugueUserJoinMessage;
41
40
  export type FugueMutationMessageTypes = Extract<FugueMessageType, FugueMessage | FugueJoinMessage>;
41
+ export declare const makeFugueMessage: <T extends FugueMessageType>(msg: Omit<T, "msgType">) => BaseFugueMessage;
42
42
  //# sourceMappingURL=Message.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/types/FugueTree/Message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEzD,oBAAY,SAAS;IACjB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,YAAY,IAAA;IACZ,SAAS,IAAA;IACT,MAAM,IAAA;IACN,KAAK,IAAA;CACR;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAiBvD;AAED,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAG1B,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC7D,SAAS,EAAE,CAAC,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAa,SAAQ,gBAAgB,CAAC,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IACvF,EAAE,EAAE,EAAE,CAAC;IACP,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,EAAE,CAAC;IACZ,WAAW,CAAC,EAAE,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB,CAAC,SAAS,CAAC,YAAY,CAAC;IAC9E,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC;IAE1C,kBAAkB,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;CAE9C;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB,CAAC,SAAS,CAAC,MAAM,CAAC;IAC1E,UAAU,EAAE,MAAM,CAAC;I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IACP,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,EAAE,CAAC;IACZ,WAAW,CAAC,EAAE,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB,CAAC,SAAS,CAAC,YAAY,CAAC;IAC9E,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC;CAE7C;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB,CAAC,SAAS,CAAC,MAAM,CAAC;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB,CAAC,SAAS,CAAC,KAAK,CAAC;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC;IAC/E,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;CAC9C;AAED,MAAM,MAAM,gBAAgB,GACtB,YAAY,GACZ,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,oBAAoB,CAAC;AAE3B,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,gBAAgB,EAAE,YAAY,GAAG,gBAAgB,CAAC,CAAC;AAEnG,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,gBAAgB,EAAE,KAAK,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,KAAG,gBAKtF,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { MessageType } from "../Message.js";
1
2
  export var Operation;
2
3
  (function (Operation) {
3
4
  Operation[Operation["INSERT"] = 0] = "INSERT";
@@ -25,3 +26,9 @@ export function operationToString(op) {
25
26
  return "UNKNOWN_OPERATION";
26
27
  }
27
28
  }
29
+ export const makeFugueMessage = (msg) => {
30
+ return {
31
+ ...msg,
32
+ msgType: MessageType.FUGUE,
33
+ };
34
+ };
@@ -0,0 +1,10 @@
1
+ export declare enum MessageType {
2
+ FUGUE = 0,
3
+ PRESENCE = 1
4
+ }
5
+ export interface BaseMessage<T extends MessageType = MessageType> {
6
+ msgType: T;
7
+ documentID: string;
8
+ userIdentity: string;
9
+ }
10
+ //# sourceMappingURL=Message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../src/types/Message.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACnB,KAAK,IAAA;IACL,QAAQ,IAAA;CACX;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IAC5D,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,5 @@
1
+ export var MessageType;
2
+ (function (MessageType) {
3
+ MessageType[MessageType["FUGUE"] = 0] = "FUGUE";
4
+ MessageType[MessageType["PRESENCE"] = 1] = "PRESENCE";
5
+ })(MessageType || (MessageType = {}));
@@ -0,0 +1,14 @@
1
+ import { BaseMessage, MessageType } from "./Message.js";
2
+ export declare enum PresenceMessageType {
3
+ CURSOR = 0,
4
+ SELECTION = 1
5
+ }
6
+ export interface BasePresenceMessage<T extends PresenceMessageType = PresenceMessageType> extends BaseMessage<MessageType.PRESENCE> {
7
+ type: T;
8
+ }
9
+ export interface PresenceCursorMessage extends BasePresenceMessage<PresenceMessageType.CURSOR> {
10
+ pos: number;
11
+ }
12
+ export type PresenceMessage = PresenceCursorMessage;
13
+ export declare const makePresenceMsg: <T extends PresenceMessage>(msg: Omit<T, "msgType">) => BasePresenceMessage;
14
+ //# sourceMappingURL=Presence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Presence.d.ts","sourceRoot":"","sources":["../../src/types/Presence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAExD,oBAAY,mBAAmB;IAC3B,MAAM,IAAA;IACN,SAAS,IAAA;CACZ;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,mBAAmB,GAAG,mBAAmB,CACpF,SAAQ,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC;CACX;AAED,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB,CAAC,mBAAmB,CAAC,MAAM,CAAC;IAC1F,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAEpD,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,eAAe,EAAE,KAAK,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,KAAG,mBAKpF,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { MessageType } from "./Message.js";
2
+ export var PresenceMessageType;
3
+ (function (PresenceMessageType) {
4
+ PresenceMessageType[PresenceMessageType["CURSOR"] = 0] = "CURSOR";
5
+ PresenceMessageType[PresenceMessageType["SELECTION"] = 1] = "SELECTION";
6
+ })(PresenceMessageType || (PresenceMessageType = {}));
7
+ export const makePresenceMsg = (msg) => {
8
+ return {
9
+ ...msg,
10
+ msgType: MessageType.PRESENCE,
11
+ };
12
+ };
@@ -2,4 +2,6 @@ export * from "./FugueTree/index.js";
2
2
  export * from "./Enums.js";
3
3
  export * from "./Models/index.js";
4
4
  export * from "./Pagination.js";
5
+ export * from "./Presence.js";
6
+ export * from "./Message.js";
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
@@ -3,3 +3,5 @@ export * from "./FugueTree/index.js";
3
3
  export * from "./Enums.js";
4
4
  export * from "./Models/index.js";
5
5
  export * from "./Pagination.js";
6
+ export * from "./Presence.js";
7
+ export * from "./Message.js";
@@ -1,2 +1,7 @@
1
+ import { FNode, FTree } from "../dts";
1
2
  export declare function randomString(length?: number): string;
3
+ /**
4
+ * Provides a list of ndes that are in tree A that are not in tree B
5
+ */
6
+ export declare function diff(treeA: FTree, treeB: FTree): FNode[];
2
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM,CAIxD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEtC,wBAAgB,YAAY,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM,CAIxD;AAWD;;GAEG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,CAgBxD"}
@@ -4,3 +4,26 @@ export function randomString(length = 10) {
4
4
  res[i] = String.fromCharCode(97 + Math.floor(Math.random() * 26));
5
5
  return res.join("");
6
6
  }
7
+ function buildValueSet(nodes) {
8
+ const set = new Map();
9
+ for (const node of nodes) {
10
+ set.set(JSON.stringify(node.id), node);
11
+ }
12
+ return set;
13
+ }
14
+ /**
15
+ * Provides a list of ndes that are in tree A that are not in tree B
16
+ */
17
+ export function diff(treeA, treeB) {
18
+ const nodesA = Array.from(treeA.getNodes().values()).flat();
19
+ const nodesB = Array.from(treeB.getNodes().values()).flat();
20
+ const setA = buildValueSet(nodesA);
21
+ const setB = buildValueSet(nodesB);
22
+ const nodeDiff = [];
23
+ for (const [key, node] of setA.entries()) {
24
+ if (!setB.has(key)) {
25
+ nodeDiff.push(node);
26
+ }
27
+ }
28
+ return nodeDiff;
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cr_docs_t/dts",
3
- "version": "0.28.1",
3
+ "version": "0.30.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",