@liveblocks/client 0.16.2 → 0.16.4-beta2
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/index.d.ts +3 -727
- package/index.js +100 -2523
- package/index.mjs +1641 -0
- package/internal.d.ts +15 -19
- package/internal.js +32 -190
- package/internal.mjs +1 -0
- package/package.json +7 -18
- package/shared.d.ts +753 -0
- package/shared.js +2488 -0
- package/shared.mjs +1947 -0
- package/esm/index.js +0 -3060
- package/esm/index.mjs +0 -3060
- package/esm/internal.js +0 -150
- package/esm/internal.mjs +0 -150
package/internal.d.ts
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* four types that make up the Json family:
|
|
4
|
-
*
|
|
5
|
-
* - Json any legal JSON value
|
|
6
|
-
* - JsonScalar any legal JSON leaf value (no lists or objects)
|
|
7
|
-
* - JsonArray a JSON value whose outer type is an array
|
|
8
|
-
* - JsonObject a JSON value whose outer type is an object
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
declare type Json = JsonScalar | JsonArray | JsonObject;
|
|
12
|
-
declare type JsonScalar = string | number | boolean | null;
|
|
13
|
-
declare type JsonArray = Json[];
|
|
14
|
-
declare type JsonObject = {
|
|
15
|
-
[key: string]: Json | undefined;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
declare type Presence = Record<string, unknown>;
|
|
1
|
+
import { J as Json, P as Presence, d as JsonObject } from './shared';
|
|
2
|
+
export { g as Resolve } from './shared';
|
|
19
3
|
|
|
20
4
|
/**
|
|
21
5
|
* Messages that can be sent from the server to the client.
|
|
@@ -284,4 +268,16 @@ declare function posCodes(str: string): number[];
|
|
|
284
268
|
declare function pos(codes: number[]): string;
|
|
285
269
|
declare function compare(posA: string, posB: string): number;
|
|
286
270
|
|
|
287
|
-
|
|
271
|
+
/**
|
|
272
|
+
* Displays a deprecation warning in the dev console. Only in dev mode, and
|
|
273
|
+
* only once per message/key. In production, this is a no-op.
|
|
274
|
+
*/
|
|
275
|
+
declare function deprecate(message: string, key?: string): void;
|
|
276
|
+
/**
|
|
277
|
+
* Conditionally displays a deprecation warning in the dev
|
|
278
|
+
* console if the first argument is truthy. Only in dev mode, and
|
|
279
|
+
* only once per message/key. In production, this is a no-op.
|
|
280
|
+
*/
|
|
281
|
+
declare function deprecateIf(condition: unknown, message: string, key?: string): void;
|
|
282
|
+
|
|
283
|
+
export { ClientEventMessage, ClientMessage, ClientMessageType, CrdtType, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, DeleteCrdtOp, DeleteObjectKeyOp, EventMessage, FetchStorageClientMessage, InitialDocumentStateMessage, Op, OpType, RoomStateMessage, SerializedCrdt, SerializedCrdtWithId, SerializedList, SerializedMap, SerializedObject, SerializedRegister, ServerMessage, ServerMessageType, SetParentKeyOp, UpdateObjectOp, UpdatePresenceClientMessage, UpdatePresenceMessage, UpdateStorageClientMessage, UpdateStorageMessage, UserJoinMessage, UserLeftMessage, WebsocketCloseCodes, compare, deprecate, deprecateIf, makePosition, max, min, pos, posCodes };
|
package/internal.js
CHANGED
|
@@ -2,193 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exports
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
exports.
|
|
36
|
-
|
|
37
|
-
(function (OpType) {
|
|
38
|
-
OpType[OpType["Init"] = 0] = "Init";
|
|
39
|
-
OpType[OpType["SetParentKey"] = 1] = "SetParentKey";
|
|
40
|
-
OpType[OpType["CreateList"] = 2] = "CreateList";
|
|
41
|
-
OpType[OpType["UpdateObject"] = 3] = "UpdateObject";
|
|
42
|
-
OpType[OpType["CreateObject"] = 4] = "CreateObject";
|
|
43
|
-
OpType[OpType["DeleteCrdt"] = 5] = "DeleteCrdt";
|
|
44
|
-
OpType[OpType["DeleteObjectKey"] = 6] = "DeleteObjectKey";
|
|
45
|
-
OpType[OpType["CreateMap"] = 7] = "CreateMap";
|
|
46
|
-
OpType[OpType["CreateRegister"] = 8] = "CreateRegister";
|
|
47
|
-
})(exports.OpType || (exports.OpType = {}));
|
|
48
|
-
|
|
49
|
-
exports.WebsocketCloseCodes = void 0;
|
|
50
|
-
|
|
51
|
-
(function (WebsocketCloseCodes) {
|
|
52
|
-
WebsocketCloseCodes[WebsocketCloseCodes["CLOSE_ABNORMAL"] = 1006] = "CLOSE_ABNORMAL";
|
|
53
|
-
WebsocketCloseCodes[WebsocketCloseCodes["INVALID_MESSAGE_FORMAT"] = 4000] = "INVALID_MESSAGE_FORMAT";
|
|
54
|
-
WebsocketCloseCodes[WebsocketCloseCodes["NOT_ALLOWED"] = 4001] = "NOT_ALLOWED";
|
|
55
|
-
WebsocketCloseCodes[WebsocketCloseCodes["MAX_NUMBER_OF_MESSAGES_PER_SECONDS"] = 4002] = "MAX_NUMBER_OF_MESSAGES_PER_SECONDS";
|
|
56
|
-
WebsocketCloseCodes[WebsocketCloseCodes["MAX_NUMBER_OF_CONCURRENT_CONNECTIONS"] = 4003] = "MAX_NUMBER_OF_CONCURRENT_CONNECTIONS";
|
|
57
|
-
WebsocketCloseCodes[WebsocketCloseCodes["MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP"] = 4004] = "MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP";
|
|
58
|
-
WebsocketCloseCodes[WebsocketCloseCodes["MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM"] = 4005] = "MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM";
|
|
59
|
-
WebsocketCloseCodes[WebsocketCloseCodes["CLOSE_WITHOUT_RETRY"] = 4999] = "CLOSE_WITHOUT_RETRY";
|
|
60
|
-
})(exports.WebsocketCloseCodes || (exports.WebsocketCloseCodes = {}));
|
|
61
|
-
|
|
62
|
-
var min = 32;
|
|
63
|
-
var max = 126;
|
|
64
|
-
function makePosition(before, after) {
|
|
65
|
-
if (before == null && after == null) {
|
|
66
|
-
return pos([min + 1]);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (before != null && after == null) {
|
|
70
|
-
return getNextPosition(before);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (before == null && after != null) {
|
|
74
|
-
return getPreviousPosition(after);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return pos(makePositionFromCodes(posCodes(before), posCodes(after)));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function getPreviousPosition(after) {
|
|
81
|
-
var result = [];
|
|
82
|
-
var afterCodes = posCodes(after);
|
|
83
|
-
|
|
84
|
-
for (var i = 0; i < afterCodes.length; i++) {
|
|
85
|
-
var code = afterCodes[i];
|
|
86
|
-
|
|
87
|
-
if (code <= min + 1) {
|
|
88
|
-
result.push(min);
|
|
89
|
-
|
|
90
|
-
if (afterCodes.length - 1 === i) {
|
|
91
|
-
result.push(max);
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
result.push(code - 1);
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return pos(result);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function getNextPosition(before) {
|
|
104
|
-
var result = [];
|
|
105
|
-
var beforeCodes = posCodes(before);
|
|
106
|
-
|
|
107
|
-
for (var i = 0; i < beforeCodes.length; i++) {
|
|
108
|
-
var code = beforeCodes[i];
|
|
109
|
-
|
|
110
|
-
if (code === max) {
|
|
111
|
-
result.push(code);
|
|
112
|
-
|
|
113
|
-
if (beforeCodes.length - 1 === i) {
|
|
114
|
-
result.push(min + 1);
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
} else {
|
|
118
|
-
result.push(code + 1);
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return pos(result);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function makePositionFromCodes(before, after) {
|
|
127
|
-
var index = 0;
|
|
128
|
-
var result = [];
|
|
129
|
-
|
|
130
|
-
while (true) {
|
|
131
|
-
var beforeDigit = before[index] || min;
|
|
132
|
-
var afterDigit = after[index] || max;
|
|
133
|
-
|
|
134
|
-
if (beforeDigit > afterDigit) {
|
|
135
|
-
throw new Error("Impossible to generate position between " + before + " and " + after);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (beforeDigit === afterDigit) {
|
|
139
|
-
result.push(beforeDigit);
|
|
140
|
-
index++;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (afterDigit - beforeDigit === 1) {
|
|
145
|
-
result.push(beforeDigit);
|
|
146
|
-
result.push.apply(result, makePositionFromCodes(before.slice(index + 1), []));
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
var mid = afterDigit + beforeDigit >> 1;
|
|
151
|
-
result.push(mid);
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return result;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function posCodes(str) {
|
|
159
|
-
var codes = [];
|
|
160
|
-
|
|
161
|
-
for (var i = 0; i < str.length; i++) {
|
|
162
|
-
codes.push(str.charCodeAt(i));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return codes;
|
|
166
|
-
}
|
|
167
|
-
function pos(codes) {
|
|
168
|
-
return String.fromCharCode.apply(String, codes);
|
|
169
|
-
}
|
|
170
|
-
function compare(posA, posB) {
|
|
171
|
-
var aCodes = posCodes(posA);
|
|
172
|
-
var bCodes = posCodes(posB);
|
|
173
|
-
var maxLength = Math.max(aCodes.length, bCodes.length);
|
|
174
|
-
|
|
175
|
-
for (var i = 0; i < maxLength; i++) {
|
|
176
|
-
var a = aCodes[i] == null ? min : aCodes[i];
|
|
177
|
-
var b = bCodes[i] == null ? min : bCodes[i];
|
|
178
|
-
|
|
179
|
-
if (a === b) {
|
|
180
|
-
continue;
|
|
181
|
-
} else {
|
|
182
|
-
return a - b;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
throw new Error("Impossible to compare similar position \"" + posA + "\" and \"" + posB + "\"");
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
exports.compare = compare;
|
|
190
|
-
exports.makePosition = makePosition;
|
|
191
|
-
exports.max = max;
|
|
192
|
-
exports.min = min;
|
|
193
|
-
exports.pos = pos;
|
|
194
|
-
exports.posCodes = posCodes;
|
|
5
|
+
var LiveObject = require('./shared.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, 'ClientMessageType', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return LiveObject.ClientMessageType; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, 'CrdtType', {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return LiveObject.CrdtType; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, 'OpType', {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return LiveObject.OpType; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, 'ServerMessageType', {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return LiveObject.ServerMessageType; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, 'WebsocketCloseCodes', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return LiveObject.WebsocketCloseCodes; }
|
|
28
|
+
});
|
|
29
|
+
exports.compare = LiveObject.compare;
|
|
30
|
+
exports.deprecate = LiveObject.deprecate;
|
|
31
|
+
exports.deprecateIf = LiveObject.deprecateIf;
|
|
32
|
+
exports.makePosition = LiveObject.makePosition;
|
|
33
|
+
exports.max = LiveObject.max;
|
|
34
|
+
exports.min = LiveObject.min;
|
|
35
|
+
exports.pos = LiveObject.pos;
|
|
36
|
+
exports.posCodes = LiveObject.posCodes;
|
package/internal.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { C as ClientMessageType, n as CrdtType, O as OpType, S as ServerMessageType, W as WebsocketCloseCodes, v as compare, k as deprecate, l as deprecateIf, s as makePosition, q as max, o as min, u as pos, t as posCodes } from './shared.mjs';
|
package/package.json
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/client",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4-beta2",
|
|
4
4
|
"description": "A client that lets you interact with Liveblocks servers.",
|
|
5
5
|
"main": "./index.js",
|
|
6
|
+
"module": "./index.mjs",
|
|
6
7
|
"types": "./index.d.ts",
|
|
7
8
|
"files": [
|
|
8
9
|
"**"
|
|
9
10
|
],
|
|
10
|
-
"exports": {
|
|
11
|
-
"./package.json": "./package.json",
|
|
12
|
-
".": {
|
|
13
|
-
"types": "./index.d.ts",
|
|
14
|
-
"module": "./esm/index.js",
|
|
15
|
-
"import": "./esm/index.mjs",
|
|
16
|
-
"default": "./index.js"
|
|
17
|
-
},
|
|
18
|
-
"./internal": {
|
|
19
|
-
"types": "./internal.d.ts",
|
|
20
|
-
"module": "./esm/internal.js",
|
|
21
|
-
"import": "./esm/internal.mjs",
|
|
22
|
-
"default": "./internal.js"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
11
|
"keywords": [
|
|
26
12
|
"liveblocks",
|
|
27
13
|
"multiplayer",
|
|
@@ -33,6 +19,7 @@
|
|
|
33
19
|
},
|
|
34
20
|
"scripts": {
|
|
35
21
|
"build": "rollup -c && cp ./package.json ./README.md ./lib",
|
|
22
|
+
"lint": "eslint src/ test/",
|
|
36
23
|
"test": "jest --watch",
|
|
37
24
|
"test-ci": "jest"
|
|
38
25
|
},
|
|
@@ -45,6 +32,7 @@
|
|
|
45
32
|
"@babel/preset-typescript": "^7.12.16",
|
|
46
33
|
"@rollup/plugin-babel": "^5.3.1",
|
|
47
34
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
35
|
+
"@rollup/plugin-replace": "^4.0.0",
|
|
48
36
|
"@rollup/plugin-typescript": "^8.3.1",
|
|
49
37
|
"@types/jest": "^26.0.21",
|
|
50
38
|
"@types/node-fetch": "^2.6.1",
|
|
@@ -58,8 +46,8 @@
|
|
|
58
46
|
"msw": "^0.39.1",
|
|
59
47
|
"node-fetch": "2.6.7",
|
|
60
48
|
"rollup": "^2.68.0",
|
|
49
|
+
"rollup-plugin-command": "^1.1.3",
|
|
61
50
|
"rollup-plugin-dts": "^4.1.0",
|
|
62
|
-
"rollup-plugin-esbuild": "^4.8.2",
|
|
63
51
|
"typescript": "^4.4.0",
|
|
64
52
|
"whatwg-fetch": "^3.6.2",
|
|
65
53
|
"ws": "^8.5.0"
|
|
@@ -68,5 +56,6 @@
|
|
|
68
56
|
"type": "git",
|
|
69
57
|
"url": "https://github.com/liveblocks/liveblocks.git",
|
|
70
58
|
"directory": "packages/liveblocks-client"
|
|
71
|
-
}
|
|
59
|
+
},
|
|
60
|
+
"sideEffects": false
|
|
72
61
|
}
|