@liveblocks/client 0.15.11 → 0.16.2
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/README.md +2 -0
- package/{lib/esm → esm}/index.js +226 -110
- package/{lib/esm → esm}/index.mjs +226 -110
- package/{lib/esm → esm}/internal.js +0 -0
- package/{lib/esm → esm}/internal.mjs +0 -0
- package/{lib/index.d.ts → index.d.ts} +211 -154
- package/{lib/index.js → index.js} +301 -155
- package/{lib/internal.d.ts → internal.d.ts} +110 -16
- package/{lib/internal.js → internal.js} +0 -0
- package/package.json +14 -14
|
@@ -1,5 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an indefinitely deep arbitrary JSON data structure. There are
|
|
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
|
+
|
|
1
18
|
declare type Presence = Record<string, unknown>;
|
|
2
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Messages that can be sent from the server to the client.
|
|
22
|
+
*/
|
|
3
23
|
declare type ServerMessage = UpdatePresenceMessage | UserJoinMessage | UserLeftMessage | EventMessage | RoomStateMessage | InitialDocumentStateMessage | UpdateStorageMessage;
|
|
4
24
|
declare enum ServerMessageType {
|
|
5
25
|
UpdatePresence = 100,
|
|
@@ -10,45 +30,116 @@ declare enum ServerMessageType {
|
|
|
10
30
|
InitialStorageState = 200,
|
|
11
31
|
UpdateStorage = 201
|
|
12
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Sent by the WebSocket server to a single client in response to the client
|
|
35
|
+
* joining the Room, to provide the initial state of the Room. The payload
|
|
36
|
+
* includes a list of all other Users that already are in the Room.
|
|
37
|
+
*/
|
|
13
38
|
declare type RoomStateMessage = {
|
|
14
39
|
type: ServerMessageType.RoomState;
|
|
15
40
|
users: {
|
|
16
41
|
[actor: number]: {
|
|
17
42
|
id?: string;
|
|
18
|
-
info?:
|
|
43
|
+
info?: Json;
|
|
19
44
|
};
|
|
20
45
|
};
|
|
21
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
49
|
+
* a User updated their presence. For example, when a user moves their cursor.
|
|
50
|
+
*
|
|
51
|
+
* In most cases, the data payload will only include the fields from the
|
|
52
|
+
* Presence that have been changed since the last announcement. However, after
|
|
53
|
+
* a new user joins a room, a "full presence" will be announced so the newly
|
|
54
|
+
* connected user will get each other's user full presence at least once. In
|
|
55
|
+
* those cases, the `targetActor` field indicates the newly connected client,
|
|
56
|
+
* so all other existing clients can ignore this broadcasted message.
|
|
57
|
+
*/
|
|
22
58
|
declare type UpdatePresenceMessage = {
|
|
23
59
|
type: ServerMessageType.UpdatePresence;
|
|
60
|
+
/**
|
|
61
|
+
* The User whose Presence has changed.
|
|
62
|
+
*/
|
|
24
63
|
actor: number;
|
|
64
|
+
/**
|
|
65
|
+
* The partial or full Presence of a User. If the `targetActor` field is set,
|
|
66
|
+
* this will be the full Presence, otherwise it only contain the fields that
|
|
67
|
+
* have changed since the last broadcast.
|
|
68
|
+
*/
|
|
25
69
|
data: Presence;
|
|
70
|
+
/**
|
|
71
|
+
* If this message was sent in response to a newly joined user, this field
|
|
72
|
+
* indicates which client this message is for. Other existing clients may
|
|
73
|
+
* ignore this message if this message isn't targeted for them.
|
|
74
|
+
*/
|
|
26
75
|
targetActor?: number;
|
|
27
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
79
|
+
* a new User has joined the Room.
|
|
80
|
+
*/
|
|
28
81
|
declare type UserJoinMessage = {
|
|
29
82
|
type: ServerMessageType.UserJoined;
|
|
30
83
|
actor: number;
|
|
84
|
+
/**
|
|
85
|
+
* The id of the User that has been set in the authentication endpoint.
|
|
86
|
+
* Useful to get additional information about the connected user.
|
|
87
|
+
*/
|
|
31
88
|
id?: string;
|
|
32
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Additional user information that has been set in the authentication
|
|
91
|
+
* endpoint.
|
|
92
|
+
*/
|
|
93
|
+
info?: Json;
|
|
33
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
97
|
+
* a new User has left the Room.
|
|
98
|
+
*/
|
|
34
99
|
declare type UserLeftMessage = {
|
|
35
100
|
type: ServerMessageType.UserLeft;
|
|
36
101
|
actor: number;
|
|
37
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
105
|
+
* a User broadcasted an Event to everyone in the Room.
|
|
106
|
+
*/
|
|
38
107
|
declare type EventMessage = {
|
|
39
108
|
type: ServerMessageType.Event;
|
|
109
|
+
/**
|
|
110
|
+
* The User who broadcasted the Event.
|
|
111
|
+
*/
|
|
40
112
|
actor: number;
|
|
41
|
-
|
|
113
|
+
/**
|
|
114
|
+
* The arbitrary payload of the Event. This can be any JSON value. Clients
|
|
115
|
+
* will have to manually verify/decode this event.
|
|
116
|
+
*/
|
|
117
|
+
event: Json;
|
|
42
118
|
};
|
|
43
119
|
declare type SerializedCrdtWithId = [id: string, crdt: SerializedCrdt];
|
|
120
|
+
/**
|
|
121
|
+
* Sent by the WebSocket server to a single client in response to the client
|
|
122
|
+
* joining the Room, to provide the initial Storage state of the Room. The
|
|
123
|
+
* payload includes the entire Storage document.
|
|
124
|
+
*/
|
|
44
125
|
declare type InitialDocumentStateMessage = {
|
|
45
126
|
type: ServerMessageType.InitialStorageState;
|
|
46
127
|
items: SerializedCrdtWithId[];
|
|
47
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
131
|
+
* a change occurred in the Storage document.
|
|
132
|
+
*
|
|
133
|
+
* The payload of this message contains a list of Ops (aka incremental
|
|
134
|
+
* mutations to make to the initially loaded document).
|
|
135
|
+
*/
|
|
48
136
|
declare type UpdateStorageMessage = {
|
|
49
137
|
type: ServerMessageType.UpdateStorage;
|
|
50
138
|
ops: Op[];
|
|
51
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* Messages that can be sent from the client to the server.
|
|
142
|
+
*/
|
|
52
143
|
declare type ClientMessage = ClientEventMessage | UpdatePresenceClientMessage | UpdateStorageClientMessage | FetchStorageClientMessage;
|
|
53
144
|
declare enum ClientMessageType {
|
|
54
145
|
UpdatePresence = 100,
|
|
@@ -58,7 +149,7 @@ declare enum ClientMessageType {
|
|
|
58
149
|
}
|
|
59
150
|
declare type ClientEventMessage = {
|
|
60
151
|
type: ClientMessageType.ClientEvent;
|
|
61
|
-
event:
|
|
152
|
+
event: Json;
|
|
62
153
|
};
|
|
63
154
|
declare type UpdatePresenceClientMessage = {
|
|
64
155
|
type: ClientMessageType.UpdatePresence;
|
|
@@ -82,9 +173,7 @@ declare type SerializedObject = {
|
|
|
82
173
|
type: CrdtType.Object;
|
|
83
174
|
parentId?: string;
|
|
84
175
|
parentKey?: string;
|
|
85
|
-
data:
|
|
86
|
-
[key: string]: any;
|
|
87
|
-
};
|
|
176
|
+
data: JsonObject;
|
|
88
177
|
};
|
|
89
178
|
declare type SerializedList = {
|
|
90
179
|
type: CrdtType.List;
|
|
@@ -100,7 +189,7 @@ declare type SerializedRegister = {
|
|
|
100
189
|
type: CrdtType.Register;
|
|
101
190
|
parentId: string;
|
|
102
191
|
parentKey: string;
|
|
103
|
-
data:
|
|
192
|
+
data: Json;
|
|
104
193
|
};
|
|
105
194
|
declare type SerializedCrdt = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
106
195
|
declare enum OpType {
|
|
@@ -114,28 +203,31 @@ declare enum OpType {
|
|
|
114
203
|
CreateMap = 7,
|
|
115
204
|
CreateRegister = 8
|
|
116
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* These operations are the payload for {@link UpdateStorageMessage} messages
|
|
208
|
+
* only.
|
|
209
|
+
*/
|
|
117
210
|
declare type Op = CreateObjectOp | UpdateObjectOp | DeleteCrdtOp | CreateListOp | SetParentKeyOp | DeleteObjectKeyOp | CreateMapOp | CreateRegisterOp;
|
|
211
|
+
declare type CreateOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
|
|
118
212
|
declare type UpdateObjectOp = {
|
|
119
213
|
opId?: string;
|
|
120
214
|
id: string;
|
|
121
215
|
type: OpType.UpdateObject;
|
|
122
|
-
data:
|
|
123
|
-
[key: string]: any;
|
|
124
|
-
};
|
|
216
|
+
data: Partial<JsonObject>;
|
|
125
217
|
};
|
|
126
218
|
declare type CreateObjectOp = {
|
|
127
219
|
opId?: string;
|
|
128
220
|
id: string;
|
|
221
|
+
intent?: "set";
|
|
129
222
|
type: OpType.CreateObject;
|
|
130
223
|
parentId?: string;
|
|
131
224
|
parentKey?: string;
|
|
132
|
-
data:
|
|
133
|
-
[key: string]: any;
|
|
134
|
-
};
|
|
225
|
+
data: JsonObject;
|
|
135
226
|
};
|
|
136
227
|
declare type CreateListOp = {
|
|
137
228
|
opId?: string;
|
|
138
229
|
id: string;
|
|
230
|
+
intent?: "set";
|
|
139
231
|
type: OpType.CreateList;
|
|
140
232
|
parentId: string;
|
|
141
233
|
parentKey: string;
|
|
@@ -143,6 +235,7 @@ declare type CreateListOp = {
|
|
|
143
235
|
declare type CreateMapOp = {
|
|
144
236
|
opId?: string;
|
|
145
237
|
id: string;
|
|
238
|
+
intent?: "set";
|
|
146
239
|
type: OpType.CreateMap;
|
|
147
240
|
parentId: string;
|
|
148
241
|
parentKey: string;
|
|
@@ -150,10 +243,11 @@ declare type CreateMapOp = {
|
|
|
150
243
|
declare type CreateRegisterOp = {
|
|
151
244
|
opId?: string;
|
|
152
245
|
id: string;
|
|
246
|
+
intent?: "set";
|
|
153
247
|
type: OpType.CreateRegister;
|
|
154
248
|
parentId: string;
|
|
155
249
|
parentKey: string;
|
|
156
|
-
data:
|
|
250
|
+
data: Json;
|
|
157
251
|
};
|
|
158
252
|
declare type DeleteCrdtOp = {
|
|
159
253
|
opId?: string;
|
|
@@ -190,4 +284,4 @@ declare function posCodes(str: string): number[];
|
|
|
190
284
|
declare function pos(codes: number[]): string;
|
|
191
285
|
declare function compare(posA: string, posB: string): number;
|
|
192
286
|
|
|
193
|
-
export { ClientEventMessage, ClientMessage, ClientMessageType, CrdtType, CreateListOp, CreateMapOp, CreateObjectOp, 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, makePosition, max, min, pos, posCodes };
|
|
287
|
+
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, makePosition, max, min, pos, posCodes };
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "./
|
|
6
|
-
"types": "./
|
|
3
|
+
"version": "0.16.2",
|
|
4
|
+
"description": "A client that lets you interact with Liveblocks servers.",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"
|
|
8
|
+
"**"
|
|
9
9
|
],
|
|
10
10
|
"exports": {
|
|
11
11
|
"./package.json": "./package.json",
|
|
12
12
|
".": {
|
|
13
|
-
"types": "./
|
|
14
|
-
"module": "./
|
|
15
|
-
"import": "./
|
|
16
|
-
"default": "./
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"module": "./esm/index.js",
|
|
15
|
+
"import": "./esm/index.mjs",
|
|
16
|
+
"default": "./index.js"
|
|
17
17
|
},
|
|
18
18
|
"./internal": {
|
|
19
|
-
"types": "./
|
|
20
|
-
"module": "./
|
|
21
|
-
"import": "./
|
|
22
|
-
"default": "./
|
|
19
|
+
"types": "./internal.d.ts",
|
|
20
|
+
"module": "./esm/internal.js",
|
|
21
|
+
"import": "./esm/internal.mjs",
|
|
22
|
+
"default": "./internal.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"url": "https://github.com/liveblocks/liveblocks/issues"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "rollup -c",
|
|
35
|
+
"build": "rollup -c && cp ./package.json ./README.md ./lib",
|
|
36
36
|
"test": "jest --watch",
|
|
37
37
|
"test-ci": "jest"
|
|
38
38
|
},
|