@liveblocks/core 1.3.0 → 1.3.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/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +21 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1103,7 +1103,8 @@ declare type YDocUpdate = {
|
|
|
1103
1103
|
declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
|
|
1104
1104
|
readonly type: ServerMsgCode.BROADCASTED_EVENT;
|
|
1105
1105
|
/**
|
|
1106
|
-
* The User who
|
|
1106
|
+
* The User who broadcast the Event. Absent when this event is broadcast from
|
|
1107
|
+
* the REST API in the backend.
|
|
1107
1108
|
*/
|
|
1108
1109
|
readonly actor: number;
|
|
1109
1110
|
/**
|
|
@@ -1223,6 +1224,11 @@ declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUse
|
|
|
1223
1224
|
};
|
|
1224
1225
|
|
|
1225
1226
|
declare type CustomEvent<TRoomEvent extends Json> = {
|
|
1227
|
+
/**
|
|
1228
|
+
* The connection ID of the client that sent the event.
|
|
1229
|
+
* If this message was broadcast from the server (via the REST API), then
|
|
1230
|
+
* this value will be -1.
|
|
1231
|
+
*/
|
|
1226
1232
|
connectionId: number;
|
|
1227
1233
|
event: TRoomEvent;
|
|
1228
1234
|
};
|
|
@@ -1273,6 +1279,10 @@ interface History {
|
|
|
1273
1279
|
* // room.history.canRedo() is false
|
|
1274
1280
|
*/
|
|
1275
1281
|
canRedo: () => boolean;
|
|
1282
|
+
/**
|
|
1283
|
+
* Clears the undo and redo stacks. This operation cannot be undone ;)
|
|
1284
|
+
*/
|
|
1285
|
+
clear: () => void;
|
|
1276
1286
|
/**
|
|
1277
1287
|
* All future modifications made on the Room will be merged together to create a single history item until resume is called.
|
|
1278
1288
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1103,7 +1103,8 @@ declare type YDocUpdate = {
|
|
|
1103
1103
|
declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
|
|
1104
1104
|
readonly type: ServerMsgCode.BROADCASTED_EVENT;
|
|
1105
1105
|
/**
|
|
1106
|
-
* The User who
|
|
1106
|
+
* The User who broadcast the Event. Absent when this event is broadcast from
|
|
1107
|
+
* the REST API in the backend.
|
|
1107
1108
|
*/
|
|
1108
1109
|
readonly actor: number;
|
|
1109
1110
|
/**
|
|
@@ -1223,6 +1224,11 @@ declare type OthersEvent<TPresence extends JsonObject, TUserMeta extends BaseUse
|
|
|
1223
1224
|
};
|
|
1224
1225
|
|
|
1225
1226
|
declare type CustomEvent<TRoomEvent extends Json> = {
|
|
1227
|
+
/**
|
|
1228
|
+
* The connection ID of the client that sent the event.
|
|
1229
|
+
* If this message was broadcast from the server (via the REST API), then
|
|
1230
|
+
* this value will be -1.
|
|
1231
|
+
*/
|
|
1226
1232
|
connectionId: number;
|
|
1227
1233
|
event: TRoomEvent;
|
|
1228
1234
|
};
|
|
@@ -1273,6 +1279,10 @@ interface History {
|
|
|
1273
1279
|
* // room.history.canRedo() is false
|
|
1274
1280
|
*/
|
|
1275
1281
|
canRedo: () => boolean;
|
|
1282
|
+
/**
|
|
1283
|
+
* Clears the undo and redo stacks. This operation cannot be undone ;)
|
|
1284
|
+
*/
|
|
1285
|
+
clear: () => void;
|
|
1276
1286
|
/**
|
|
1277
1287
|
* All future modifications made on the Room will be merged together to create a single history item until resume is called.
|
|
1278
1288
|
*
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "1.3.
|
|
9
|
+
var PKG_VERSION = "1.3.2";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1281,6 +1281,7 @@ function parseAuthToken(rawTokenString) {
|
|
|
1281
1281
|
// src/auth-manager.ts
|
|
1282
1282
|
function createAuthManager(authOptions) {
|
|
1283
1283
|
const authentication = prepareAuthentication(authOptions);
|
|
1284
|
+
const seenTokens = /* @__PURE__ */ new Set();
|
|
1284
1285
|
const tokens = [];
|
|
1285
1286
|
const expiryTimes = [];
|
|
1286
1287
|
const requestPromises = /* @__PURE__ */ new Map();
|
|
@@ -1304,8 +1305,6 @@ function createAuthManager(authOptions) {
|
|
|
1304
1305
|
}
|
|
1305
1306
|
if (token.parsed.k === "id" /* ID_TOKEN */) {
|
|
1306
1307
|
return token;
|
|
1307
|
-
} else if (token.parsed.k === "sec-legacy" /* SECRET_LEGACY */) {
|
|
1308
|
-
return void 0;
|
|
1309
1308
|
} else if (token.parsed.k === "acc" /* ACCESS_TOKEN */) {
|
|
1310
1309
|
for (const [resource, scopes] of Object.entries(token.parsed.perms)) {
|
|
1311
1310
|
if (resource.includes("*") && roomId.startsWith(resource.replace("*", "")) || roomId === resource && hasCorrespondingScopes(requestedScope, scopes)) {
|
|
@@ -1327,7 +1326,13 @@ function createAuthManager(authOptions) {
|
|
|
1327
1326
|
const response = await fetchAuthEndpoint(fetcher, authentication.url, {
|
|
1328
1327
|
room: roomId
|
|
1329
1328
|
});
|
|
1330
|
-
|
|
1329
|
+
const parsed = parseAuthToken(response.token);
|
|
1330
|
+
if (seenTokens.has(parsed.raw)) {
|
|
1331
|
+
throw new StopRetrying(
|
|
1332
|
+
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
1333
|
+
);
|
|
1334
|
+
}
|
|
1335
|
+
return parsed;
|
|
1331
1336
|
}
|
|
1332
1337
|
if (authentication.type === "custom") {
|
|
1333
1338
|
const response = await authentication.callback(roomId);
|
|
@@ -1368,8 +1373,11 @@ function createAuthManager(authOptions) {
|
|
|
1368
1373
|
const token = await currentPromise;
|
|
1369
1374
|
const BUFFER = 30;
|
|
1370
1375
|
const expiresAt = Math.floor(Date.now() / 1e3) + (token.parsed.exp - token.parsed.iat) - BUFFER;
|
|
1371
|
-
|
|
1372
|
-
|
|
1376
|
+
seenTokens.add(token.raw);
|
|
1377
|
+
if (token.parsed.k !== "sec-legacy" /* SECRET_LEGACY */) {
|
|
1378
|
+
tokens.push(token);
|
|
1379
|
+
expiryTimes.push(expiresAt);
|
|
1380
|
+
}
|
|
1373
1381
|
return { type: "secret", token };
|
|
1374
1382
|
} finally {
|
|
1375
1383
|
requestPromises.delete(roomId);
|
|
@@ -4754,7 +4762,7 @@ function createRoom(options, config) {
|
|
|
4754
4762
|
} else {
|
|
4755
4763
|
batchUpdates(() => {
|
|
4756
4764
|
addToUndoStack(reverse, doNotBatchUpdates);
|
|
4757
|
-
context.redoStack =
|
|
4765
|
+
context.redoStack.length = 0;
|
|
4758
4766
|
dispatchOps(ops);
|
|
4759
4767
|
notify({ storageUpdates }, doNotBatchUpdates);
|
|
4760
4768
|
});
|
|
@@ -5484,6 +5492,10 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
5484
5492
|
}
|
|
5485
5493
|
flushNowOrSoon();
|
|
5486
5494
|
}
|
|
5495
|
+
function clear() {
|
|
5496
|
+
context.undoStack.length = 0;
|
|
5497
|
+
context.redoStack.length = 0;
|
|
5498
|
+
}
|
|
5487
5499
|
function batch(callback) {
|
|
5488
5500
|
if (context.activeBatch) {
|
|
5489
5501
|
return callback();
|
|
@@ -5508,7 +5520,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
5508
5520
|
addToUndoStack(currentBatch.reverseOps, doNotBatchUpdates);
|
|
5509
5521
|
}
|
|
5510
5522
|
if (currentBatch.ops.length > 0) {
|
|
5511
|
-
context.redoStack =
|
|
5523
|
+
context.redoStack.length = 0;
|
|
5512
5524
|
}
|
|
5513
5525
|
if (currentBatch.ops.length > 0) {
|
|
5514
5526
|
dispatchOps(currentBatch.ops);
|
|
@@ -5612,6 +5624,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
5612
5624
|
redo,
|
|
5613
5625
|
canUndo,
|
|
5614
5626
|
canRedo,
|
|
5627
|
+
clear,
|
|
5615
5628
|
pause: pauseHistory,
|
|
5616
5629
|
resume: resumeHistory
|
|
5617
5630
|
},
|