@cr_docs_t/dts 0.2.1 → 0.3.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.
@@ -275,10 +275,10 @@ export class FugueList {
275
275
  const nodes = idx
276
276
  .filter((n) => n.value !== undefined)
277
277
  .sort((a, b) => this.totalOrder.compare(a.position, b.position));
278
- // Then append to resultdkjand if somehow
279
- //a value is undefined append the placeholder thorn
278
+ // Then append to result jand if somehow
279
+ // a value is undefined append empty string
280
280
  for (const n of nodes) {
281
- res += n.value || "Þ";
281
+ res += n.value || "";
282
282
  }
283
283
  }
284
284
  return res.toString();
@@ -0,0 +1,9 @@
1
+ import { FugueMessageType } from "../../types/Message.js";
2
+ declare function serialize<P>(msgs: FugueMessageType<P>[]): Uint8Array<ArrayBuffer>;
3
+ declare function deserialize<P>(data: Uint8Array): FugueMessageType<P>[];
4
+ export declare const FugueMessageSerialzier: {
5
+ serialize: typeof serialize;
6
+ deserialize: typeof deserialize;
7
+ };
8
+ export {};
9
+ //# sourceMappingURL=Message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/Serailizers/Fugue/Message.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,gBAAgB,EAAa,MAAM,wBAAwB,CAAC;AAErG,iBAAS,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,2BAEhD;AAED,iBAAS,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAM/D;AAmCD,eAAO,MAAM,sBAAsB;;;CAGlC,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { encode, decode } from "@msgpack/msgpack";
2
+ import { Operation } from "../../types/Message.js";
3
+ function serialize(msgs) {
4
+ return encode(msgs.map((m) => toTuple(m)));
5
+ }
6
+ function deserialize(data) {
7
+ const dec = decode(data);
8
+ if (Array.isArray(dec) && Array.isArray(dec[0])) {
9
+ return dec.map((t) => fromTuple(t));
10
+ }
11
+ return [fromTuple(dec)];
12
+ }
13
+ function toTuple(msg) {
14
+ // Check if msg is of FugueJoinMessage type
15
+ switch (msg.operation) {
16
+ case Operation.JOIN:
17
+ return [msg.operation, msg.documentID, msg.state];
18
+ case Operation.INSERT:
19
+ case Operation.DELETE:
20
+ return [msg.operation, msg.documentID, msg.replicaId, msg.position, msg.data];
21
+ }
22
+ throw new Error("Unknown message type");
23
+ }
24
+ function fromTuple(tuple) {
25
+ switch (tuple[0]) {
26
+ case Operation.JOIN:
27
+ return {
28
+ operation: tuple[0],
29
+ documentID: tuple[1],
30
+ state: tuple[2],
31
+ };
32
+ case Operation.INSERT:
33
+ case Operation.DELETE:
34
+ return {
35
+ operation: tuple[0],
36
+ documentID: tuple[1],
37
+ replicaId: tuple[2],
38
+ position: tuple[3],
39
+ data: tuple[4],
40
+ };
41
+ }
42
+ throw new Error("Unknown tuple format");
43
+ }
44
+ export const FugueMessageSerialzier = {
45
+ serialize,
46
+ deserialize,
47
+ };
@@ -0,0 +1,9 @@
1
+ import { FugueState } from "../../types/Fugue.js";
2
+ declare function serialize(state: FugueState<string>): Uint8Array<ArrayBufferLike>;
3
+ declare function deserialize(compressed: Uint8Array<ArrayBufferLike>): FugueState<string>;
4
+ export declare const FugueStateSerializer: {
5
+ serialize: typeof serialize;
6
+ deserialize: typeof deserialize;
7
+ };
8
+ export {};
9
+ //# sourceMappingURL=State.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../src/Serailizers/Fugue/State.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,iBAAS,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,eAAe,CAAC,CAKzE;AAED,iBAAS,WAAW,CAAC,UAAU,EAAE,UAAU,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAIhF;AAED,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { encode, decode } from "@msgpack/msgpack";
2
+ import { compress, decompress } from "lz4js";
3
+ function serialize(state) {
4
+ // const flat = state.flatMap((c) => c.map((n) => [n.position, n.value]));
5
+ const bin = encode(state);
6
+ const com = compress(bin);
7
+ return com;
8
+ }
9
+ function deserialize(compressed) {
10
+ const raw = decompress(compressed);
11
+ const state = decode(raw);
12
+ return state;
13
+ }
14
+ export const FugueStateSerializer = {
15
+ serialize,
16
+ deserialize,
17
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./Fugue/State.js";
2
+ export * from "./Fugue/Message.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Serailizers/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./Fugue/State.js";
2
+ export * from "./Fugue/Message.js";
package/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from "./TotalOrder/UniquelyDenseTotalOrder.js";
4
4
  export * from "./TotalOrder/StringTotalOrder.js";
5
5
  export * from "./types/Message.js";
6
6
  export * from "./types/Fugue.js";
7
+ export * from "./Serailizers/index.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,yCAAyC,CAAC;AACxD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,yCAAyC,CAAC;AACxD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -4,3 +4,4 @@ export * from "./TotalOrder/UniquelyDenseTotalOrder.js";
4
4
  export * from "./TotalOrder/StringTotalOrder.js";
5
5
  export * from "./types/Message.js";
6
6
  export * from "./types/Fugue.js";
7
+ export * from "./Serailizers/index.js";
@@ -6,13 +6,16 @@ export declare enum Operation {
6
6
  }
7
7
  export type Data = string;
8
8
  export interface FugueMessage<P> {
9
+ operation: Operation.INSERT | Operation.DELETE;
9
10
  documentID: string;
10
11
  replicaId: string;
11
- operation: Operation;
12
12
  position: P;
13
13
  data: Data | null;
14
14
  }
15
15
  export interface FugueJoinMessage<P> {
16
- state: FugueState<P>;
16
+ operation: Operation.JOIN;
17
+ documentID: string;
18
+ state: FugueState<P> | null;
17
19
  }
20
+ export type FugueMessageType<P> = FugueMessage<P> | FugueJoinMessage<P>;
18
21
  //# sourceMappingURL=Message.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../src/types/Message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,oBAAY,SAAS;IACjB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,IAAI,IAAA;CACP;AAED,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,MAAM,WAAW,YAAY,CAAC,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,CAAC,CAAC;IACZ,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC;IAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;CACxB"}
1
+ {"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../src/types/Message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,oBAAY,SAAS;IACjB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,IAAI,IAAA;CACP;AAED,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,MAAM,WAAW,YAAY,CAAC,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,CAAC;IACZ,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@cr_docs_t/dts",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
+ "type": "module",
6
7
  "types": "dist/index.d.ts",
7
8
  "scripts": {
8
9
  "build": "tsc",
@@ -56,11 +57,16 @@
56
57
  "devDependencies": {
57
58
  "@semantic-release/changelog": "^6.0.3",
58
59
  "@semantic-release/git": "^10.0.1",
60
+ "@types/lz4js": "^0.2.2",
59
61
  "@types/node": "^24.10.1",
60
62
  "semantic-release": "^25.0.2",
61
63
  "typescript": "^5.9.3"
62
64
  },
63
65
  "files": [
64
66
  "dist"
65
- ]
67
+ ],
68
+ "dependencies": {
69
+ "@msgpack/msgpack": "^3.1.3",
70
+ "lz4js": "^0.2.0"
71
+ }
66
72
  }