@liveblocks/client 0.15.0-alpha.2 → 0.15.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 (62) hide show
  1. package/lib/esm/index.js +2991 -5
  2. package/lib/esm/index.mjs +2991 -0
  3. package/lib/esm/internal.js +149 -0
  4. package/lib/esm/internal.mjs +149 -0
  5. package/lib/{esm/types.d.ts → index.d.ts} +255 -50
  6. package/lib/index.js +4237 -0
  7. package/lib/{esm/live.d.ts → internal.d.ts} +46 -34
  8. package/lib/internal.js +193 -0
  9. package/package.json +36 -9
  10. package/lib/cjs/AbstractCrdt.d.ts +0 -67
  11. package/lib/cjs/AbstractCrdt.js +0 -95
  12. package/lib/cjs/LiveList.d.ts +0 -144
  13. package/lib/cjs/LiveList.js +0 -527
  14. package/lib/cjs/LiveMap.d.ts +0 -91
  15. package/lib/cjs/LiveMap.js +0 -322
  16. package/lib/cjs/LiveObject.d.ts +0 -80
  17. package/lib/cjs/LiveObject.js +0 -453
  18. package/lib/cjs/LiveRegister.d.ts +0 -29
  19. package/lib/cjs/LiveRegister.js +0 -88
  20. package/lib/cjs/authentication.d.ts +0 -3
  21. package/lib/cjs/authentication.js +0 -71
  22. package/lib/cjs/client.d.ts +0 -27
  23. package/lib/cjs/client.js +0 -80
  24. package/lib/cjs/immutable.d.ts +0 -9
  25. package/lib/cjs/immutable.js +0 -291
  26. package/lib/cjs/index.d.ts +0 -6
  27. package/lib/cjs/index.js +0 -18
  28. package/lib/cjs/live.d.ts +0 -181
  29. package/lib/cjs/live.js +0 -49
  30. package/lib/cjs/position.d.ts +0 -6
  31. package/lib/cjs/position.js +0 -113
  32. package/lib/cjs/room.d.ts +0 -159
  33. package/lib/cjs/room.js +0 -1094
  34. package/lib/cjs/types.d.ts +0 -489
  35. package/lib/cjs/types.js +0 -2
  36. package/lib/cjs/utils.d.ts +0 -11
  37. package/lib/cjs/utils.js +0 -175
  38. package/lib/esm/AbstractCrdt.d.ts +0 -67
  39. package/lib/esm/AbstractCrdt.js +0 -91
  40. package/lib/esm/LiveList.d.ts +0 -144
  41. package/lib/esm/LiveList.js +0 -523
  42. package/lib/esm/LiveMap.d.ts +0 -91
  43. package/lib/esm/LiveMap.js +0 -318
  44. package/lib/esm/LiveObject.d.ts +0 -80
  45. package/lib/esm/LiveObject.js +0 -449
  46. package/lib/esm/LiveRegister.d.ts +0 -29
  47. package/lib/esm/LiveRegister.js +0 -84
  48. package/lib/esm/authentication.d.ts +0 -3
  49. package/lib/esm/authentication.js +0 -66
  50. package/lib/esm/client.d.ts +0 -27
  51. package/lib/esm/client.js +0 -76
  52. package/lib/esm/immutable.d.ts +0 -9
  53. package/lib/esm/immutable.js +0 -282
  54. package/lib/esm/index.d.ts +0 -6
  55. package/lib/esm/live.js +0 -46
  56. package/lib/esm/position.d.ts +0 -6
  57. package/lib/esm/position.js +0 -106
  58. package/lib/esm/room.d.ts +0 -159
  59. package/lib/esm/room.js +0 -1069
  60. package/lib/esm/types.js +0 -1
  61. package/lib/esm/utils.d.ts +0 -11
  62. package/lib/esm/utils.js +0 -164
package/lib/cjs/client.js DELETED
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createClient = void 0;
4
- const room_1 = require("./room");
5
- /**
6
- * Create a client that will be responsible to communicate with liveblocks servers.
7
- *
8
- * @example
9
- * const client = createClient({
10
- * authEndpoint: "/api/auth"
11
- * });
12
- *
13
- * // It's also possible to use a function to call your authentication endpoint.
14
- * // Useful to add additional headers or use an API wrapper (like Firebase functions)
15
- * const client = createClient({
16
- * authEndpoint: async (room) => {
17
- * const response = await fetch("/api/auth", {
18
- * method: "POST",
19
- * headers: {
20
- * Authentication: "token",
21
- * "Content-Type": "application/json"
22
- * },
23
- * body: JSON.stringify({ room })
24
- * });
25
- *
26
- * return await response.json();
27
- * }
28
- * });
29
- */
30
- function createClient(options) {
31
- const clientOptions = options;
32
- if (typeof clientOptions.throttle === "number") {
33
- if (clientOptions.throttle < 80 || clientOptions.throttle > 1000) {
34
- throw new Error("Liveblocks client throttle should be between 80 and 1000 ms");
35
- }
36
- }
37
- const rooms = new Map();
38
- function getRoom(roomId) {
39
- const internalRoom = rooms.get(roomId);
40
- return internalRoom ? internalRoom.room : null;
41
- }
42
- function enter(roomId, options = {}) {
43
- let internalRoom = rooms.get(roomId);
44
- if (internalRoom) {
45
- return internalRoom.room;
46
- }
47
- internalRoom = (0, room_1.createRoom)(roomId, Object.assign(Object.assign({}, clientOptions), options));
48
- rooms.set(roomId, internalRoom);
49
- internalRoom.connect();
50
- return internalRoom.room;
51
- }
52
- function leave(roomId) {
53
- let room = rooms.get(roomId);
54
- if (room) {
55
- room.disconnect();
56
- rooms.delete(roomId);
57
- }
58
- }
59
- if (typeof window !== "undefined") {
60
- // TODO: Expose a way to clear these
61
- window.addEventListener("online", () => {
62
- for (const [, room] of rooms) {
63
- room.onNavigatorOnline();
64
- }
65
- });
66
- }
67
- if (typeof document !== "undefined") {
68
- document.addEventListener("visibilitychange", () => {
69
- for (const [, room] of rooms) {
70
- room.onVisibilityChange(document.visibilityState);
71
- }
72
- });
73
- }
74
- return {
75
- getRoom,
76
- enter,
77
- leave,
78
- };
79
- }
80
- exports.createClient = createClient;
@@ -1,9 +0,0 @@
1
- import { LiveList } from "./LiveList";
2
- import { LiveObject } from "./LiveObject";
3
- import { StorageUpdate } from "./types";
4
- export declare function liveObjectToJson(liveObject: LiveObject<any>): any;
5
- export declare function liveNodeToJson(value: any): any;
6
- export declare function patchLiveList<T>(liveList: LiveList<T>, prev: Array<T>, next: Array<T>): void;
7
- export declare function patchLiveObjectKey<T>(liveObject: LiveObject<T>, key: keyof T, prev: any, next: any): void;
8
- export declare function patchLiveObject<T extends Record<string, any>>(root: LiveObject<T>, prev: T, next: T): void;
9
- export declare function patchImmutableObject<T>(state: T, updates: StorageUpdate[]): T;
@@ -1,291 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.patchImmutableObject = exports.patchLiveObject = exports.patchLiveObjectKey = exports.patchLiveList = exports.liveNodeToJson = exports.liveObjectToJson = void 0;
4
- const LiveList_1 = require("./LiveList");
5
- const LiveMap_1 = require("./LiveMap");
6
- const LiveObject_1 = require("./LiveObject");
7
- const LiveRegister_1 = require("./LiveRegister");
8
- function liveObjectToJson(liveObject) {
9
- const result = {};
10
- const obj = liveObject.toObject();
11
- for (const key in obj) {
12
- result[key] = liveNodeToJson(obj[key]);
13
- }
14
- return result;
15
- }
16
- exports.liveObjectToJson = liveObjectToJson;
17
- function liveMapToJson(map) {
18
- const result = {};
19
- const obj = Object.fromEntries(map);
20
- for (const key in obj) {
21
- result[key] = liveNodeToJson(obj[key]);
22
- }
23
- return result;
24
- }
25
- function liveListToJson(value) {
26
- return value.toArray().map(liveNodeToJson);
27
- }
28
- function liveNodeToJson(value) {
29
- if (value instanceof LiveObject_1.LiveObject) {
30
- return liveObjectToJson(value);
31
- }
32
- else if (value instanceof LiveList_1.LiveList) {
33
- return liveListToJson(value);
34
- }
35
- else if (value instanceof LiveMap_1.LiveMap) {
36
- return liveMapToJson(value);
37
- }
38
- else if (value instanceof LiveRegister_1.LiveRegister) {
39
- return value.data;
40
- }
41
- return value;
42
- }
43
- exports.liveNodeToJson = liveNodeToJson;
44
- function isPlainObject(obj) {
45
- return Object.prototype.toString.call(obj) === "[object Object]";
46
- }
47
- function anyToCrdt(obj) {
48
- if (obj == null) {
49
- return obj;
50
- }
51
- if (Array.isArray(obj)) {
52
- return new LiveList_1.LiveList(obj.map(anyToCrdt));
53
- }
54
- if (isPlainObject(obj)) {
55
- const init = {};
56
- for (const key in obj) {
57
- init[key] = anyToCrdt(obj[key]);
58
- }
59
- return new LiveObject_1.LiveObject(init);
60
- }
61
- return obj;
62
- }
63
- function patchLiveList(liveList, prev, next) {
64
- let i = 0;
65
- let prevEnd = prev.length - 1;
66
- let nextEnd = next.length - 1;
67
- let prevNode = prev[0];
68
- let nextNode = next[0];
69
- /**
70
- * For A,B,C => A,B,C,D
71
- * i = 3, prevEnd = 2, nextEnd = 3
72
- *
73
- * For A,B,C => B,C
74
- * i = 2, prevEnd = 2, nextEnd = 1
75
- *
76
- * For B,C => A,B,C
77
- * i = 0, pre
78
- */
79
- outer: {
80
- while (prevNode === nextNode) {
81
- ++i;
82
- if (i > prevEnd || i > nextEnd) {
83
- break outer;
84
- }
85
- prevNode = prev[i];
86
- nextNode = next[i];
87
- }
88
- prevNode = prev[prevEnd];
89
- nextNode = next[nextEnd];
90
- while (prevNode === nextNode) {
91
- prevEnd--;
92
- nextEnd--;
93
- if (i > prevEnd || i > nextEnd) {
94
- break outer;
95
- }
96
- prevNode = prev[prevEnd];
97
- nextNode = next[nextEnd];
98
- }
99
- }
100
- if (i > prevEnd) {
101
- if (i <= nextEnd) {
102
- while (i <= nextEnd) {
103
- liveList.insert(anyToCrdt(next[i]), i);
104
- i++;
105
- }
106
- }
107
- }
108
- else if (i > nextEnd) {
109
- let localI = i;
110
- while (localI <= prevEnd) {
111
- liveList.delete(i);
112
- localI++;
113
- }
114
- }
115
- else {
116
- while (i <= prevEnd && i <= nextEnd) {
117
- prevNode = prev[i];
118
- nextNode = next[i];
119
- const liveListNode = liveList.get(i);
120
- if (liveListNode instanceof LiveObject_1.LiveObject &&
121
- isPlainObject(prevNode) &&
122
- isPlainObject(nextNode)) {
123
- patchLiveObject(liveListNode, prevNode, nextNode);
124
- }
125
- else {
126
- liveList.delete(i);
127
- liveList.insert(anyToCrdt(nextNode), i);
128
- }
129
- i++;
130
- }
131
- while (i <= nextEnd) {
132
- liveList.insert(anyToCrdt(next[i]), i);
133
- i++;
134
- }
135
- while (i <= prevEnd) {
136
- liveList.delete(i);
137
- i++;
138
- }
139
- }
140
- }
141
- exports.patchLiveList = patchLiveList;
142
- function patchLiveObjectKey(liveObject, key, prev, next) {
143
- const value = liveObject.get(key);
144
- if (next === undefined) {
145
- liveObject.delete(key);
146
- }
147
- else if (value === undefined) {
148
- liveObject.set(key, anyToCrdt(next));
149
- }
150
- else if (prev === next) {
151
- return;
152
- }
153
- else if (value instanceof LiveList_1.LiveList &&
154
- Array.isArray(prev) &&
155
- Array.isArray(next)) {
156
- patchLiveList(value, prev, next);
157
- }
158
- else if (value instanceof LiveObject_1.LiveObject &&
159
- isPlainObject(prev) &&
160
- isPlainObject(next)) {
161
- patchLiveObject(value, prev, next);
162
- }
163
- else {
164
- liveObject.set(key, anyToCrdt(next));
165
- }
166
- }
167
- exports.patchLiveObjectKey = patchLiveObjectKey;
168
- function patchLiveObject(root, prev, next) {
169
- const updates = {};
170
- for (const key in next) {
171
- patchLiveObjectKey(root, key, prev[key], next[key]);
172
- }
173
- for (const key in prev) {
174
- if (next[key] === undefined) {
175
- root.delete(key);
176
- }
177
- }
178
- if (Object.keys(updates).length > 0) {
179
- root.update(updates);
180
- }
181
- }
182
- exports.patchLiveObject = patchLiveObject;
183
- function getParentsPath(node) {
184
- const path = [];
185
- while (node._parentKey != null && node._parent != null) {
186
- if (node._parent instanceof LiveList_1.LiveList) {
187
- path.push(node._parent._indexOfPosition(node._parentKey));
188
- }
189
- else {
190
- path.push(node._parentKey);
191
- }
192
- node = node._parent;
193
- }
194
- return path;
195
- }
196
- function patchImmutableObject(state, updates) {
197
- return updates.reduce((state, update) => patchImmutableObjectWithUpdate(state, update), state);
198
- }
199
- exports.patchImmutableObject = patchImmutableObject;
200
- function patchImmutableObjectWithUpdate(state, update) {
201
- const path = getParentsPath(update.node);
202
- return patchImmutableNode(state, path, update);
203
- }
204
- function patchImmutableNode(state, path, update) {
205
- var _a, _b, _c, _d;
206
- const pathItem = path.pop();
207
- if (pathItem === undefined) {
208
- switch (update.type) {
209
- case "LiveObject": {
210
- if (typeof state !== "object") {
211
- throw new Error("Internal: received update on LiveObject but state was not an object");
212
- }
213
- let newState = Object.assign({}, state);
214
- for (const key in update.updates) {
215
- if (((_a = update.updates[key]) === null || _a === void 0 ? void 0 : _a.type) === "update") {
216
- newState[key] = liveNodeToJson(update.node.get(key));
217
- }
218
- else if (((_b = update.updates[key]) === null || _b === void 0 ? void 0 : _b.type) === "delete") {
219
- delete newState[key];
220
- }
221
- }
222
- return newState;
223
- }
224
- case "LiveList": {
225
- if (Array.isArray(state) === false) {
226
- throw new Error("Internal: received update on LiveList but state was not an array");
227
- }
228
- let newState = state.map((x) => x);
229
- for (const listUpdate of update.updates) {
230
- if (listUpdate.type === "insert") {
231
- if (listUpdate.index === newState.length) {
232
- newState.push(liveNodeToJson(listUpdate.item));
233
- }
234
- else {
235
- newState = [
236
- ...newState.slice(0, listUpdate.index),
237
- liveNodeToJson(listUpdate.item),
238
- ...newState.slice(listUpdate.index),
239
- ];
240
- }
241
- }
242
- else if (listUpdate.type === "delete") {
243
- newState.splice(listUpdate.index, 1);
244
- }
245
- else if (listUpdate.type === "move") {
246
- if (listUpdate.previousIndex > listUpdate.index) {
247
- newState = [
248
- ...newState.slice(0, listUpdate.index),
249
- liveNodeToJson(listUpdate.item),
250
- ...newState.slice(listUpdate.index, listUpdate.previousIndex),
251
- ...newState.slice(listUpdate.previousIndex + 1),
252
- ];
253
- }
254
- else {
255
- newState = [
256
- ...newState.slice(0, listUpdate.previousIndex),
257
- ...newState.slice(listUpdate.previousIndex + 1, listUpdate.index + 1),
258
- liveNodeToJson(listUpdate.item),
259
- ...newState.slice(listUpdate.index + 1),
260
- ];
261
- }
262
- }
263
- }
264
- return newState;
265
- }
266
- case "LiveMap": {
267
- if (typeof state !== "object") {
268
- throw new Error("Internal: received update on LiveMap but state was not an object");
269
- }
270
- let newState = Object.assign({}, state);
271
- for (const key in update.updates) {
272
- if (((_c = update.updates[key]) === null || _c === void 0 ? void 0 : _c.type) === "update") {
273
- newState[key] = liveNodeToJson(update.node.get(key));
274
- }
275
- else if (((_d = update.updates[key]) === null || _d === void 0 ? void 0 : _d.type) === "delete") {
276
- delete newState[key];
277
- }
278
- }
279
- return newState;
280
- }
281
- }
282
- }
283
- if (Array.isArray(state)) {
284
- const newArray = [...state];
285
- newArray[pathItem] = patchImmutableNode(state[pathItem], path, update);
286
- return newArray;
287
- }
288
- else {
289
- return Object.assign(Object.assign({}, state), { [pathItem]: patchImmutableNode(state[pathItem], path, update) });
290
- }
291
- }
@@ -1,6 +0,0 @@
1
- export { LiveObject } from "./LiveObject";
2
- export { LiveMap } from "./LiveMap";
3
- export { LiveList } from "./LiveList";
4
- export type { Others, Presence, Room, Client, User, BroadcastOptions, } from "./types";
5
- export { createClient } from "./client";
6
- export { liveObjectToJson, liveNodeToJson, patchLiveList, patchImmutableObject, patchLiveObject, patchLiveObjectKey, } from "./immutable";
package/lib/cjs/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.patchLiveObjectKey = exports.patchLiveObject = exports.patchImmutableObject = exports.patchLiveList = exports.liveNodeToJson = exports.liveObjectToJson = exports.createClient = exports.LiveList = exports.LiveMap = exports.LiveObject = void 0;
4
- var LiveObject_1 = require("./LiveObject");
5
- Object.defineProperty(exports, "LiveObject", { enumerable: true, get: function () { return LiveObject_1.LiveObject; } });
6
- var LiveMap_1 = require("./LiveMap");
7
- Object.defineProperty(exports, "LiveMap", { enumerable: true, get: function () { return LiveMap_1.LiveMap; } });
8
- var LiveList_1 = require("./LiveList");
9
- Object.defineProperty(exports, "LiveList", { enumerable: true, get: function () { return LiveList_1.LiveList; } });
10
- var client_1 = require("./client");
11
- Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_1.createClient; } });
12
- var immutable_1 = require("./immutable");
13
- Object.defineProperty(exports, "liveObjectToJson", { enumerable: true, get: function () { return immutable_1.liveObjectToJson; } });
14
- Object.defineProperty(exports, "liveNodeToJson", { enumerable: true, get: function () { return immutable_1.liveNodeToJson; } });
15
- Object.defineProperty(exports, "patchLiveList", { enumerable: true, get: function () { return immutable_1.patchLiveList; } });
16
- Object.defineProperty(exports, "patchImmutableObject", { enumerable: true, get: function () { return immutable_1.patchImmutableObject; } });
17
- Object.defineProperty(exports, "patchLiveObject", { enumerable: true, get: function () { return immutable_1.patchLiveObject; } });
18
- Object.defineProperty(exports, "patchLiveObjectKey", { enumerable: true, get: function () { return immutable_1.patchLiveObjectKey; } });
package/lib/cjs/live.d.ts DELETED
@@ -1,181 +0,0 @@
1
- import { Presence } from "./types";
2
- export declare type ServerMessage = UpdatePresenceMessage | UserJoinMessage | UserLeftMessage | EventMessage | RoomStateMessage | InitialDocumentStateMessage | UpdateStorageMessage;
3
- export declare enum ServerMessageType {
4
- UpdatePresence = 100,
5
- UserJoined = 101,
6
- UserLeft = 102,
7
- Event = 103,
8
- RoomState = 104,
9
- InitialStorageState = 200,
10
- UpdateStorage = 201
11
- }
12
- export declare type RoomStateMessage = {
13
- type: ServerMessageType.RoomState;
14
- users: {
15
- [actor: number]: {
16
- id?: string;
17
- info?: any;
18
- };
19
- };
20
- };
21
- export declare type UpdatePresenceMessage = {
22
- type: ServerMessageType.UpdatePresence;
23
- actor: number;
24
- data: Presence;
25
- };
26
- export declare type UserJoinMessage = {
27
- type: ServerMessageType.UserJoined;
28
- actor: number;
29
- id?: string;
30
- info?: string;
31
- };
32
- export declare type UserLeftMessage = {
33
- type: ServerMessageType.UserLeft;
34
- actor: number;
35
- };
36
- export declare type EventMessage = {
37
- type: ServerMessageType.Event;
38
- actor: number;
39
- event: any;
40
- };
41
- export declare type SerializedCrdtWithId = [id: string, crdt: SerializedCrdt];
42
- export declare type InitialDocumentStateMessage = {
43
- type: ServerMessageType.InitialStorageState;
44
- items: SerializedCrdtWithId[];
45
- };
46
- export declare type UpdateStorageMessage = {
47
- type: ServerMessageType.UpdateStorage;
48
- ops: Op[];
49
- };
50
- export declare type ClientMessage = ClientEventMessage | UpdatePresenceClientMessage | UpdateStorageClientMessage | FetchStorageClientMessage;
51
- export declare enum ClientMessageType {
52
- UpdatePresence = 100,
53
- ClientEvent = 103,
54
- FetchStorage = 200,
55
- UpdateStorage = 201
56
- }
57
- export declare type ClientEventMessage = {
58
- type: ClientMessageType.ClientEvent;
59
- event: any;
60
- };
61
- export declare type UpdatePresenceClientMessage = {
62
- type: ClientMessageType.UpdatePresence;
63
- data: Presence;
64
- targetActor?: number;
65
- };
66
- export declare type UpdateStorageClientMessage = {
67
- type: ClientMessageType.UpdateStorage;
68
- ops: Op[];
69
- };
70
- export declare type FetchStorageClientMessage = {
71
- type: ClientMessageType.FetchStorage;
72
- };
73
- export declare enum CrdtType {
74
- Object = 0,
75
- List = 1,
76
- Map = 2,
77
- Register = 3
78
- }
79
- export declare type SerializedObject = {
80
- type: CrdtType.Object;
81
- parentId?: string;
82
- parentKey?: string;
83
- data: {
84
- [key: string]: any;
85
- };
86
- };
87
- export declare type SerializedList = {
88
- type: CrdtType.List;
89
- parentId: string;
90
- parentKey: string;
91
- };
92
- export declare type SerializedMap = {
93
- type: CrdtType.Map;
94
- parentId: string;
95
- parentKey: string;
96
- };
97
- export declare type SerializedRegister = {
98
- type: CrdtType.Register;
99
- parentId: string;
100
- parentKey: string;
101
- data: any;
102
- };
103
- export declare type SerializedCrdt = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
104
- export declare enum OpType {
105
- Init = 0,
106
- SetParentKey = 1,
107
- CreateList = 2,
108
- UpdateObject = 3,
109
- CreateObject = 4,
110
- DeleteCrdt = 5,
111
- DeleteObjectKey = 6,
112
- CreateMap = 7,
113
- CreateRegister = 8
114
- }
115
- export declare type Op = CreateObjectOp | UpdateObjectOp | DeleteCrdtOp | CreateListOp | SetParentKeyOp | DeleteObjectKeyOp | CreateMapOp | CreateRegisterOp;
116
- export declare type UpdateObjectOp = {
117
- opId?: string;
118
- id: string;
119
- type: OpType.UpdateObject;
120
- data: {
121
- [key: string]: any;
122
- };
123
- };
124
- export declare type CreateObjectOp = {
125
- opId?: string;
126
- id: string;
127
- type: OpType.CreateObject;
128
- parentId?: string;
129
- parentKey?: string;
130
- data: {
131
- [key: string]: any;
132
- };
133
- };
134
- export declare type CreateListOp = {
135
- opId?: string;
136
- id: string;
137
- type: OpType.CreateList;
138
- parentId: string;
139
- parentKey: string;
140
- };
141
- export declare type CreateMapOp = {
142
- opId?: string;
143
- id: string;
144
- type: OpType.CreateMap;
145
- parentId: string;
146
- parentKey: string;
147
- };
148
- export declare type CreateRegisterOp = {
149
- opId?: string;
150
- id: string;
151
- type: OpType.CreateRegister;
152
- parentId: string;
153
- parentKey: string;
154
- data: any;
155
- };
156
- export declare type DeleteCrdtOp = {
157
- opId?: string;
158
- id: string;
159
- type: OpType.DeleteCrdt;
160
- };
161
- export declare type SetParentKeyOp = {
162
- opId?: string;
163
- id: string;
164
- type: OpType.SetParentKey;
165
- parentKey: string;
166
- };
167
- export declare type DeleteObjectKeyOp = {
168
- opId?: string;
169
- id: string;
170
- type: OpType.DeleteObjectKey;
171
- key: string;
172
- };
173
- export declare enum WebsocketCloseCodes {
174
- CLOSE_ABNORMAL = 1006,
175
- INVALID_MESSAGE_FORMAT = 4000,
176
- NOT_ALLOWED = 4001,
177
- MAX_NUMBER_OF_MESSAGES_PER_SECONDS = 4002,
178
- MAX_NUMBER_OF_CONCURRENT_CONNECTIONS = 4003,
179
- MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP = 4004,
180
- MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM = 4005
181
- }
package/lib/cjs/live.js DELETED
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebsocketCloseCodes = exports.OpType = exports.CrdtType = exports.ClientMessageType = exports.ServerMessageType = void 0;
4
- var ServerMessageType;
5
- (function (ServerMessageType) {
6
- ServerMessageType[ServerMessageType["UpdatePresence"] = 100] = "UpdatePresence";
7
- ServerMessageType[ServerMessageType["UserJoined"] = 101] = "UserJoined";
8
- ServerMessageType[ServerMessageType["UserLeft"] = 102] = "UserLeft";
9
- ServerMessageType[ServerMessageType["Event"] = 103] = "Event";
10
- ServerMessageType[ServerMessageType["RoomState"] = 104] = "RoomState";
11
- ServerMessageType[ServerMessageType["InitialStorageState"] = 200] = "InitialStorageState";
12
- ServerMessageType[ServerMessageType["UpdateStorage"] = 201] = "UpdateStorage";
13
- })(ServerMessageType = exports.ServerMessageType || (exports.ServerMessageType = {}));
14
- var ClientMessageType;
15
- (function (ClientMessageType) {
16
- ClientMessageType[ClientMessageType["UpdatePresence"] = 100] = "UpdatePresence";
17
- ClientMessageType[ClientMessageType["ClientEvent"] = 103] = "ClientEvent";
18
- ClientMessageType[ClientMessageType["FetchStorage"] = 200] = "FetchStorage";
19
- ClientMessageType[ClientMessageType["UpdateStorage"] = 201] = "UpdateStorage";
20
- })(ClientMessageType = exports.ClientMessageType || (exports.ClientMessageType = {}));
21
- var CrdtType;
22
- (function (CrdtType) {
23
- CrdtType[CrdtType["Object"] = 0] = "Object";
24
- CrdtType[CrdtType["List"] = 1] = "List";
25
- CrdtType[CrdtType["Map"] = 2] = "Map";
26
- CrdtType[CrdtType["Register"] = 3] = "Register";
27
- })(CrdtType = exports.CrdtType || (exports.CrdtType = {}));
28
- var OpType;
29
- (function (OpType) {
30
- OpType[OpType["Init"] = 0] = "Init";
31
- OpType[OpType["SetParentKey"] = 1] = "SetParentKey";
32
- OpType[OpType["CreateList"] = 2] = "CreateList";
33
- OpType[OpType["UpdateObject"] = 3] = "UpdateObject";
34
- OpType[OpType["CreateObject"] = 4] = "CreateObject";
35
- OpType[OpType["DeleteCrdt"] = 5] = "DeleteCrdt";
36
- OpType[OpType["DeleteObjectKey"] = 6] = "DeleteObjectKey";
37
- OpType[OpType["CreateMap"] = 7] = "CreateMap";
38
- OpType[OpType["CreateRegister"] = 8] = "CreateRegister";
39
- })(OpType = exports.OpType || (exports.OpType = {}));
40
- var WebsocketCloseCodes;
41
- (function (WebsocketCloseCodes) {
42
- WebsocketCloseCodes[WebsocketCloseCodes["CLOSE_ABNORMAL"] = 1006] = "CLOSE_ABNORMAL";
43
- WebsocketCloseCodes[WebsocketCloseCodes["INVALID_MESSAGE_FORMAT"] = 4000] = "INVALID_MESSAGE_FORMAT";
44
- WebsocketCloseCodes[WebsocketCloseCodes["NOT_ALLOWED"] = 4001] = "NOT_ALLOWED";
45
- WebsocketCloseCodes[WebsocketCloseCodes["MAX_NUMBER_OF_MESSAGES_PER_SECONDS"] = 4002] = "MAX_NUMBER_OF_MESSAGES_PER_SECONDS";
46
- WebsocketCloseCodes[WebsocketCloseCodes["MAX_NUMBER_OF_CONCURRENT_CONNECTIONS"] = 4003] = "MAX_NUMBER_OF_CONCURRENT_CONNECTIONS";
47
- WebsocketCloseCodes[WebsocketCloseCodes["MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP"] = 4004] = "MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP";
48
- WebsocketCloseCodes[WebsocketCloseCodes["MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM"] = 4005] = "MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM";
49
- })(WebsocketCloseCodes = exports.WebsocketCloseCodes || (exports.WebsocketCloseCodes = {}));
@@ -1,6 +0,0 @@
1
- export declare const min = 32;
2
- export declare const max = 126;
3
- export declare function makePosition(before?: string, after?: string): string;
4
- export declare function posCodes(str: string): number[];
5
- export declare function pos(codes: number[]): string;
6
- export declare function compare(posA: string, posB: string): number;