@cr_docs_t/dts 0.29.0 → 0.31.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.
- package/dist/dts/FugueTree/FTree.d.ts +1 -0
- package/dist/dts/FugueTree/FTree.d.ts.map +1 -1
- package/dist/dts/FugueTree/FTree.js +7 -0
- package/dist/dts/FugueTree/FugueTree.d.ts +1 -0
- package/dist/dts/FugueTree/FugueTree.d.ts.map +1 -1
- package/dist/dts/FugueTree/FugueTree.js +7 -0
- package/dist/dts/Serailizers/FugueTree/Message.d.ts +1 -5
- package/dist/dts/Serailizers/FugueTree/Message.d.ts.map +1 -1
- package/dist/dts/Serailizers/FugueTree/Message.js +14 -12
- package/dist/dts/Serailizers/General.d.ts +12 -0
- package/dist/dts/Serailizers/General.d.ts.map +1 -0
- package/dist/dts/Serailizers/General.js +37 -0
- package/dist/dts/Serailizers/Presence.d.ts +9 -0
- package/dist/dts/Serailizers/Presence.d.ts.map +1 -0
- package/dist/dts/Serailizers/Presence.js +23 -0
- package/dist/dts/Serailizers/index.d.ts +2 -0
- package/dist/dts/Serailizers/index.d.ts.map +1 -1
- package/dist/dts/Serailizers/index.js +2 -0
- package/dist/types/FugueTree/Message.d.ts +4 -4
- package/dist/types/FugueTree/Message.d.ts.map +1 -1
- package/dist/types/FugueTree/Message.js +7 -0
- package/dist/types/Message.d.ts +10 -0
- package/dist/types/Message.d.ts.map +1 -0
- package/dist/types/Message.js +5 -0
- package/dist/types/Presence.d.ts +14 -0
- package/dist/types/Presence.d.ts.map +1 -0
- package/dist/types/Presence.js +12 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/package.json +1 -1
|
@@ -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,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G;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;IA0EzB,QAAQ;IAIR,KAAK;CASR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FugueTree.d.ts","sourceRoot":"","sources":["../../../src/dts/FugueTree/FugueTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"FugueTree.d.ts","sourceRoot":"","sources":["../../../src/dts/FugueTree/FugueTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA+B,MAAM,kCAAkC,CAAC;AAI7F,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,qBAAa,SAAS;IAClB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,IAAI,CAAQ;IACpB,EAAE,EAAE,SAAS,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,SAAS,SAAmB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,4BAAmC;IAE9C,QAAQ,CAAC,SAAS,OAAO;gBAEb,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAO1E;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAIlB;;;OAGG;IACH,OAAO,CAAC,SAAS;IAQjB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAiDlB;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IA+B5C;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAOnC;;;;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;IAIR,KAAK;CAGR"}
|
|
@@ -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,
|
|
@@ -353,4 +357,7 @@ export class FugueTree {
|
|
|
353
357
|
getState() {
|
|
354
358
|
return this.tree;
|
|
355
359
|
}
|
|
360
|
+
clear() {
|
|
361
|
+
return this.tree.clear();
|
|
362
|
+
}
|
|
356
363
|
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { BaseFugueMessage
|
|
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,
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 +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,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;
|
|
@@ -39,4 +38,5 @@ export interface FugueUserJoinMessage extends BaseFugueMessage<Operation.USER_JO
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/types/FugueTree/Message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEzD,oBAAY,SAAS;IACjB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,YAAY,IAAA;IACZ,SAAS,IA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,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 @@
|
|
|
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,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
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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"}
|
package/dist/types/index.js
CHANGED