@liveblocks/client 0.16.1 → 0.16.4-beta1
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 +31 -0
- package/index.js +1924 -0
- package/index.mjs +1641 -0
- package/{lib/internal.d.ts → internal.d.ts} +15 -19
- package/internal.js +36 -0
- package/internal.mjs +1 -0
- package/package.json +11 -22
- package/{lib/index.d.ts → shared.d.ts} +32 -34
- package/{lib/index.js → shared.js} +117 -1968
- package/shared.mjs +1947 -0
- package/lib/esm/index.js +0 -3054
- package/lib/esm/index.mjs +0 -3054
- package/lib/esm/internal.js +0 -150
- package/lib/esm/internal.mjs +0 -150
- package/lib/internal.js +0 -194
|
@@ -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;
|
|
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
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
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-beta1",
|
|
4
4
|
"description": "A client that lets you interact with Liveblocks servers.",
|
|
5
|
-
"main": "./
|
|
6
|
-
"
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"module": "./index.mjs",
|
|
7
|
+
"types": "./index.d.ts",
|
|
7
8
|
"files": [
|
|
8
|
-
"
|
|
9
|
+
"**"
|
|
9
10
|
],
|
|
10
|
-
"exports": {
|
|
11
|
-
"./package.json": "./package.json",
|
|
12
|
-
".": {
|
|
13
|
-
"types": "./lib/index.d.ts",
|
|
14
|
-
"module": "./lib/esm/index.js",
|
|
15
|
-
"import": "./lib/esm/index.mjs",
|
|
16
|
-
"default": "./lib/index.js"
|
|
17
|
-
},
|
|
18
|
-
"./internal": {
|
|
19
|
-
"types": "./lib/internal.d.ts",
|
|
20
|
-
"module": "./lib/esm/internal.js",
|
|
21
|
-
"import": "./lib/esm/internal.mjs",
|
|
22
|
-
"default": "./lib/internal.js"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
11
|
"keywords": [
|
|
26
12
|
"liveblocks",
|
|
27
13
|
"multiplayer",
|
|
@@ -32,7 +18,8 @@
|
|
|
32
18
|
"url": "https://github.com/liveblocks/liveblocks/issues"
|
|
33
19
|
},
|
|
34
20
|
"scripts": {
|
|
35
|
-
"build": "rollup -c",
|
|
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
|
}
|
|
@@ -12,7 +12,7 @@ declare type Json = JsonScalar | JsonArray | JsonObject;
|
|
|
12
12
|
declare type JsonScalar = string | number | boolean | null;
|
|
13
13
|
declare type JsonArray = Json[];
|
|
14
14
|
declare type JsonObject = {
|
|
15
|
-
[key: string]: Json;
|
|
15
|
+
[key: string]: Json | undefined;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -83,7 +83,7 @@ declare type Lson = Json | LiveObject<LsonObject> | LiveList<Lson> | LiveMap<str
|
|
|
83
83
|
* value or a Live storage data structure (LiveMap, LiveList, etc.)
|
|
84
84
|
*/
|
|
85
85
|
declare type LsonObject = {
|
|
86
|
-
[key: string]: Lson;
|
|
86
|
+
[key: string]: Lson | undefined;
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
/**
|
|
@@ -188,6 +188,31 @@ declare class LiveList<TItem extends Lson = Lson> extends AbstractCrdt {
|
|
|
188
188
|
[Symbol.iterator](): IterableIterator<TItem>;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
/**
|
|
192
|
+
* This helper type is effectively a no-op, but will force TypeScript to
|
|
193
|
+
* "evaluate" any named helper types in its definition. This can sometimes make
|
|
194
|
+
* API signatures clearer in IDEs.
|
|
195
|
+
*
|
|
196
|
+
* For example, in:
|
|
197
|
+
*
|
|
198
|
+
* type Payload<T> = { data: T };
|
|
199
|
+
*
|
|
200
|
+
* let r1: Payload<string>;
|
|
201
|
+
* let r2: Resolve<Payload<string>>;
|
|
202
|
+
*
|
|
203
|
+
* The inferred type of `r1` is going to be `Payload<string>` which shows up in
|
|
204
|
+
* editor hints, and it may be unclear what's inside if you don't know the
|
|
205
|
+
* definition of `Payload`.
|
|
206
|
+
*
|
|
207
|
+
* The inferred type of `r2` is going to be `{ data: string }`, which may be
|
|
208
|
+
* more helpful.
|
|
209
|
+
*
|
|
210
|
+
* This trick comes from:
|
|
211
|
+
* https://effectivetypescript.com/2022/02/25/gentips-4-display/
|
|
212
|
+
*/
|
|
213
|
+
declare type Resolve<T> = T extends Function ? T : {
|
|
214
|
+
[K in keyof T]: T[K];
|
|
215
|
+
};
|
|
191
216
|
declare type MyPresenceCallback<T extends Presence = Presence> = (me: T) => void;
|
|
192
217
|
declare type OthersEventCallback<T extends Presence = Presence> = (others: Others<T>, event: OthersEvent<T>) => void;
|
|
193
218
|
declare type EventCallback = ({ connectionId, event, }: {
|
|
@@ -278,9 +303,9 @@ declare type Client = {
|
|
|
278
303
|
* @param roomId The id of the room
|
|
279
304
|
* @param defaultPresence Optional. Should be serializable to JSON. If omitted, an empty object will be used.
|
|
280
305
|
*/
|
|
281
|
-
enter<
|
|
306
|
+
enter<TStorage extends Record<string, any> = Record<string, any>>(roomId: string, options?: {
|
|
282
307
|
defaultPresence?: Presence;
|
|
283
|
-
defaultStorageRoot?:
|
|
308
|
+
defaultStorageRoot?: TStorage;
|
|
284
309
|
}): Room;
|
|
285
310
|
/**
|
|
286
311
|
* Leaves a room.
|
|
@@ -660,8 +685,8 @@ declare type Room = {
|
|
|
660
685
|
* @example
|
|
661
686
|
* const { root } = await room.getStorage();
|
|
662
687
|
*/
|
|
663
|
-
getStorage: <
|
|
664
|
-
root: LiveObject<
|
|
688
|
+
getStorage: <TStorage extends LsonObject>() => Promise<{
|
|
689
|
+
root: LiveObject<TStorage>;
|
|
665
690
|
}>;
|
|
666
691
|
/**
|
|
667
692
|
* Batches modifications made during the given function.
|
|
@@ -725,31 +750,4 @@ declare class LiveObject<O extends LsonObject = LsonObject> extends AbstractCrdt
|
|
|
725
750
|
update(overrides: Partial<O>): void;
|
|
726
751
|
}
|
|
727
752
|
|
|
728
|
-
|
|
729
|
-
* Create a client that will be responsible to communicate with liveblocks servers.
|
|
730
|
-
*
|
|
731
|
-
* @example
|
|
732
|
-
* const client = createClient({
|
|
733
|
-
* authEndpoint: "/api/auth"
|
|
734
|
-
* });
|
|
735
|
-
*
|
|
736
|
-
* // It's also possible to use a function to call your authentication endpoint.
|
|
737
|
-
* // Useful to add additional headers or use an API wrapper (like Firebase functions)
|
|
738
|
-
* const client = createClient({
|
|
739
|
-
* authEndpoint: async (room) => {
|
|
740
|
-
* const response = await fetch("/api/auth", {
|
|
741
|
-
* method: "POST",
|
|
742
|
-
* headers: {
|
|
743
|
-
* Authentication: "token",
|
|
744
|
-
* "Content-Type": "application/json"
|
|
745
|
-
* },
|
|
746
|
-
* body: JSON.stringify({ room })
|
|
747
|
-
* });
|
|
748
|
-
*
|
|
749
|
-
* return await response.json();
|
|
750
|
-
* }
|
|
751
|
-
* });
|
|
752
|
-
*/
|
|
753
|
-
declare function createClient(options: ClientOptions): Client;
|
|
754
|
-
|
|
755
|
-
export { BroadcastOptions, Client, History, Json, JsonObject, LiveList, LiveMap, LiveObject, Lson, LsonObject, Others, Presence, Room, StorageUpdate, User, createClient };
|
|
753
|
+
export { BroadcastOptions as B, ClientOptions as C, History as H, Json as J, LiveObject as L, Others as O, Presence as P, Room as R, StorageUpdate as S, User as U, Client as a, LiveMap as b, LiveList as c, JsonObject as d, Lson as e, LsonObject as f, Resolve as g };
|