@liveblocks/core 0.18.4 → 0.19.0-beta0
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/index.d.ts +8 -7
- package/dist/index.js +5 -5
- package/package.json +7 -19
package/dist/index.d.ts
CHANGED
|
@@ -238,7 +238,7 @@ declare type ImmutableMap = ReadonlyMap<string, Immutable>;
|
|
|
238
238
|
* ToImmutable<string> // string
|
|
239
239
|
* ToImmutable<string | LiveList<number>> // string | readonly number[]
|
|
240
240
|
* ToImmutable<LiveMap<string, LiveList<number>>>
|
|
241
|
-
* //
|
|
241
|
+
* // ReadonlyMap<string, readonly number[]>
|
|
242
242
|
* ToImmutable<LiveObject<{ a: number, b: LiveList<string>, c?: number }>>
|
|
243
243
|
* // { readonly a: null, readonly b: readonly string[], readonly c?: number }
|
|
244
244
|
*
|
|
@@ -357,6 +357,9 @@ declare class LiveList<TItem extends Lson> extends AbstractCrdt {
|
|
|
357
357
|
toImmutable(): readonly ToImmutable<TItem>[];
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
+
/**
|
|
361
|
+
* This type is used by clients to define the metadata for a user.
|
|
362
|
+
*/
|
|
360
363
|
declare type BaseUserMeta = {
|
|
361
364
|
/**
|
|
362
365
|
* The id of the user that has been set in the authentication endpoint.
|
|
@@ -367,10 +370,6 @@ declare type BaseUserMeta = {
|
|
|
367
370
|
* Additional user information that has been set in the authentication endpoint.
|
|
368
371
|
*/
|
|
369
372
|
info?: Json;
|
|
370
|
-
/**
|
|
371
|
-
* Permissions that the user has in the room.
|
|
372
|
-
*/
|
|
373
|
-
scopes: string[];
|
|
374
373
|
};
|
|
375
374
|
|
|
376
375
|
declare enum OpCode {
|
|
@@ -680,7 +679,9 @@ declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
|
|
|
680
679
|
declare type RoomStateServerMsg<TUserMeta extends BaseUserMeta> = {
|
|
681
680
|
type: ServerMsgCode.ROOM_STATE;
|
|
682
681
|
users: {
|
|
683
|
-
[actor: number]: TUserMeta
|
|
682
|
+
[actor: number]: TUserMeta & {
|
|
683
|
+
scopes: string[];
|
|
684
|
+
};
|
|
684
685
|
};
|
|
685
686
|
};
|
|
686
687
|
/**
|
|
@@ -1323,7 +1324,7 @@ declare function throwUsageError(message: string): void;
|
|
|
1323
1324
|
declare function errorIf(condition: unknown, message: string): void;
|
|
1324
1325
|
|
|
1325
1326
|
declare function lsonToJson(value: Lson): Json;
|
|
1326
|
-
declare function patchLiveObjectKey<O extends LsonObject, K extends keyof O, V extends
|
|
1327
|
+
declare function patchLiveObjectKey<O extends LsonObject, K extends keyof O, V extends Json>(liveObject: LiveObject<O>, key: K, prev?: V, next?: V): void;
|
|
1327
1328
|
declare function legacy_patchImmutableObject<S extends JsonObject>(state: S, updates: StorageUpdate[]): S;
|
|
1328
1329
|
|
|
1329
1330
|
declare function makePosition(before?: string, after?: string): string;
|
package/dist/index.js
CHANGED
|
@@ -3091,7 +3091,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3091
3091
|
});
|
|
3092
3092
|
}
|
|
3093
3093
|
}
|
|
3094
|
-
function
|
|
3094
|
+
function isStorageReadOnly(scopes) {
|
|
3095
3095
|
return scopes.includes("room:read" /* Read */) && scopes.includes("room:presence:write" /* PresenceWrite */) && !scopes.includes("room:write" /* Write */);
|
|
3096
3096
|
}
|
|
3097
3097
|
function authenticationSuccess(token, socket) {
|
|
@@ -3105,7 +3105,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3105
3105
|
id: token.actor,
|
|
3106
3106
|
userInfo: token.info,
|
|
3107
3107
|
userId: token.id,
|
|
3108
|
-
isReadOnly:
|
|
3108
|
+
isReadOnly: isStorageReadOnly(token.scopes)
|
|
3109
3109
|
},
|
|
3110
3110
|
batchUpdates
|
|
3111
3111
|
);
|
|
@@ -3165,7 +3165,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3165
3165
|
connectionId,
|
|
3166
3166
|
user.id,
|
|
3167
3167
|
user.info,
|
|
3168
|
-
|
|
3168
|
+
isStorageReadOnly(user.scopes)
|
|
3169
3169
|
);
|
|
3170
3170
|
}
|
|
3171
3171
|
return { type: "reset" };
|
|
@@ -3186,7 +3186,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3186
3186
|
message.actor,
|
|
3187
3187
|
message.id,
|
|
3188
3188
|
message.info,
|
|
3189
|
-
|
|
3189
|
+
isStorageReadOnly(message.scopes)
|
|
3190
3190
|
);
|
|
3191
3191
|
state.buffer.messages.push({
|
|
3192
3192
|
type: 100 /* UPDATE_PRESENCE */,
|
|
@@ -3793,7 +3793,7 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
|
|
|
3793
3793
|
const ws = WebSocketPolyfill || WebSocket;
|
|
3794
3794
|
return (token) => {
|
|
3795
3795
|
return new ws(
|
|
3796
|
-
`${liveblocksServer}/?token=${token}&version=${true ? "0.
|
|
3796
|
+
`${liveblocksServer}/?token=${token}&version=${true ? "0.19.0-beta0" : "dev"}`
|
|
3797
3797
|
);
|
|
3798
3798
|
};
|
|
3799
3799
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0-beta0",
|
|
4
4
|
"description": "Shared code and foundational internals for Liveblocks",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -19,35 +19,23 @@
|
|
|
19
19
|
"url": "https://github.com/liveblocks/liveblocks/issues"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
+
"dev": "tsup --watch --onSuccess ../../scripts/build.sh",
|
|
22
23
|
"build": "tsup && ../../scripts/build.sh",
|
|
23
24
|
"format": "eslint --fix src/ && prettier --write src/",
|
|
24
25
|
"lint": "eslint src/",
|
|
25
|
-
"test": "jest --
|
|
26
|
-
"test
|
|
26
|
+
"test": "jest --silent --verbose",
|
|
27
|
+
"test:watch": "jest --silent --verbose --watch",
|
|
27
28
|
"test-e2e": "jest --silent --verbose --config=./jest.config.e2e.js"
|
|
28
29
|
},
|
|
29
30
|
"license": "Apache-2.0",
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
32
|
+
"@liveblocks/eslint-config": "*",
|
|
33
|
+
"@liveblocks/jest-config": "*",
|
|
33
34
|
"@types/ws": "^8.5.3",
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^5.26.0",
|
|
35
|
-
"@typescript-eslint/parser": "^5.26.0",
|
|
36
35
|
"dotenv": "^16.0.3",
|
|
37
|
-
"eslint": "^8.12.0",
|
|
38
|
-
"eslint-plugin-import": "^2.26.0",
|
|
39
36
|
"eslint-plugin-rulesdir": "^0.2.1",
|
|
40
|
-
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
41
37
|
"fast-check": "^3.0.1",
|
|
42
|
-
"
|
|
43
|
-
"jest-environment-jsdom": "^29.1.2",
|
|
44
|
-
"msw": "^0.39.1",
|
|
45
|
-
"node-fetch": "2.6.7",
|
|
46
|
-
"prettier": "^2.7.1",
|
|
47
|
-
"ts-jest": "^29.0.3",
|
|
48
|
-
"tsup": "^6.2.2",
|
|
49
|
-
"typescript": "^4.7.2",
|
|
50
|
-
"whatwg-fetch": "^3.6.2",
|
|
38
|
+
"msw": "^0.47.4",
|
|
51
39
|
"ws": "^8.5.0"
|
|
52
40
|
},
|
|
53
41
|
"repository": {
|