@liveblocks/core 1.9.7 → 1.9.8
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 +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
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.9.
|
|
9
|
+
var PKG_VERSION = "1.9.8";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -362,23 +362,29 @@ var FSM = class {
|
|
|
362
362
|
}
|
|
363
363
|
onEnterAsync(nameOrPattern, promiseFn, onOK, onError) {
|
|
364
364
|
return this.onEnter(nameOrPattern, () => {
|
|
365
|
-
|
|
366
|
-
|
|
365
|
+
const abortController = new AbortController();
|
|
366
|
+
const signal = abortController.signal;
|
|
367
|
+
let done = false;
|
|
368
|
+
void promiseFn(this.currentContext.current, signal).then(
|
|
367
369
|
// On OK
|
|
368
370
|
(data) => {
|
|
369
|
-
if (!
|
|
371
|
+
if (!signal.aborted) {
|
|
372
|
+
done = true;
|
|
370
373
|
this.transition({ type: "ASYNC_OK", data }, onOK);
|
|
371
374
|
}
|
|
372
375
|
},
|
|
373
376
|
// On Error
|
|
374
377
|
(reason) => {
|
|
375
|
-
if (!
|
|
378
|
+
if (!signal.aborted) {
|
|
379
|
+
done = true;
|
|
376
380
|
this.transition({ type: "ASYNC_ERROR", reason }, onError);
|
|
377
381
|
}
|
|
378
382
|
}
|
|
379
383
|
);
|
|
380
384
|
return () => {
|
|
381
|
-
|
|
385
|
+
if (!done) {
|
|
386
|
+
abortController.abort();
|
|
387
|
+
}
|
|
382
388
|
};
|
|
383
389
|
});
|
|
384
390
|
}
|
|
@@ -652,6 +658,7 @@ var ServerMsgCode = /* @__PURE__ */ ((ServerMsgCode2) => {
|
|
|
652
658
|
|
|
653
659
|
// src/types/IWebSocket.ts
|
|
654
660
|
var WebsocketCloseCodes = /* @__PURE__ */ ((WebsocketCloseCodes2) => {
|
|
661
|
+
WebsocketCloseCodes2[WebsocketCloseCodes2["CLOSE_NORMAL"] = 1e3] = "CLOSE_NORMAL";
|
|
655
662
|
WebsocketCloseCodes2[WebsocketCloseCodes2["CLOSE_ABNORMAL"] = 1006] = "CLOSE_ABNORMAL";
|
|
656
663
|
WebsocketCloseCodes2[WebsocketCloseCodes2["UNEXPECTED_CONDITION"] = 1011] = "UNEXPECTED_CONDITION";
|
|
657
664
|
WebsocketCloseCodes2[WebsocketCloseCodes2["TRY_AGAIN_LATER"] = 1013] = "TRY_AGAIN_LATER";
|
|
@@ -661,6 +668,7 @@ var WebsocketCloseCodes = /* @__PURE__ */ ((WebsocketCloseCodes2) => {
|
|
|
661
668
|
WebsocketCloseCodes2[WebsocketCloseCodes2["MAX_NUMBER_OF_CONCURRENT_CONNECTIONS"] = 4003] = "MAX_NUMBER_OF_CONCURRENT_CONNECTIONS";
|
|
662
669
|
WebsocketCloseCodes2[WebsocketCloseCodes2["MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP"] = 4004] = "MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP";
|
|
663
670
|
WebsocketCloseCodes2[WebsocketCloseCodes2["MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM"] = 4005] = "MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM";
|
|
671
|
+
WebsocketCloseCodes2[WebsocketCloseCodes2["KICKED"] = 4100] = "KICKED";
|
|
664
672
|
WebsocketCloseCodes2[WebsocketCloseCodes2["TOKEN_EXPIRED"] = 4109] = "TOKEN_EXPIRED";
|
|
665
673
|
WebsocketCloseCodes2[WebsocketCloseCodes2["CLOSE_WITHOUT_RETRY"] = 4999] = "CLOSE_WITHOUT_RETRY";
|
|
666
674
|
return WebsocketCloseCodes2;
|
|
@@ -728,6 +736,7 @@ var StopRetrying = class extends Error {
|
|
|
728
736
|
}
|
|
729
737
|
};
|
|
730
738
|
var LiveblocksError = class extends Error {
|
|
739
|
+
/** @internal */
|
|
731
740
|
constructor(message, code) {
|
|
732
741
|
super(message);
|
|
733
742
|
this.code = code;
|
|
@@ -942,14 +951,16 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
942
951
|
// When the "open" event happens, we're ready to transition to the
|
|
943
952
|
// OK state. This is done by resolving the Promise.
|
|
944
953
|
//
|
|
945
|
-
async (ctx) => {
|
|
954
|
+
async (ctx, signal) => {
|
|
946
955
|
let capturedPrematureEvent = null;
|
|
956
|
+
let unconfirmedSocket = null;
|
|
947
957
|
const connect$ = new Promise(
|
|
948
958
|
(resolve, rej) => {
|
|
949
959
|
if (ctx.authValue === null) {
|
|
950
960
|
throw new Error("No auth authValue");
|
|
951
961
|
}
|
|
952
962
|
const socket = delegates.createSocket(ctx.authValue);
|
|
963
|
+
unconfirmedSocket = socket;
|
|
953
964
|
function reject(event) {
|
|
954
965
|
capturedPrematureEvent = event;
|
|
955
966
|
socket.removeEventListener("message", onSocketMessage);
|
|
@@ -1005,12 +1016,18 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
1005
1016
|
//
|
|
1006
1017
|
([socket, unsub]) => {
|
|
1007
1018
|
unsub();
|
|
1019
|
+
if (signal.aborted) {
|
|
1020
|
+
throw new Error("Aborted");
|
|
1021
|
+
}
|
|
1008
1022
|
if (capturedPrematureEvent) {
|
|
1009
1023
|
throw capturedPrematureEvent;
|
|
1010
1024
|
}
|
|
1011
1025
|
return socket;
|
|
1012
1026
|
}
|
|
1013
|
-
)
|
|
1027
|
+
).catch((e) => {
|
|
1028
|
+
teardownSocket(unconfirmedSocket);
|
|
1029
|
+
throw e;
|
|
1030
|
+
});
|
|
1014
1031
|
},
|
|
1015
1032
|
// Only transition to OK state after a successfully opened WebSocket connection
|
|
1016
1033
|
(okEvent) => ({
|