@liveblocks/core 1.9.8-pre1 → 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 +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -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.8
|
|
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
|
}
|
|
@@ -730,6 +736,7 @@ var StopRetrying = class extends Error {
|
|
|
730
736
|
}
|
|
731
737
|
};
|
|
732
738
|
var LiveblocksError = class extends Error {
|
|
739
|
+
/** @internal */
|
|
733
740
|
constructor(message, code) {
|
|
734
741
|
super(message);
|
|
735
742
|
this.code = code;
|
|
@@ -944,14 +951,16 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
944
951
|
// When the "open" event happens, we're ready to transition to the
|
|
945
952
|
// OK state. This is done by resolving the Promise.
|
|
946
953
|
//
|
|
947
|
-
async (ctx) => {
|
|
954
|
+
async (ctx, signal) => {
|
|
948
955
|
let capturedPrematureEvent = null;
|
|
956
|
+
let unconfirmedSocket = null;
|
|
949
957
|
const connect$ = new Promise(
|
|
950
958
|
(resolve, rej) => {
|
|
951
959
|
if (ctx.authValue === null) {
|
|
952
960
|
throw new Error("No auth authValue");
|
|
953
961
|
}
|
|
954
962
|
const socket = delegates.createSocket(ctx.authValue);
|
|
963
|
+
unconfirmedSocket = socket;
|
|
955
964
|
function reject(event) {
|
|
956
965
|
capturedPrematureEvent = event;
|
|
957
966
|
socket.removeEventListener("message", onSocketMessage);
|
|
@@ -1007,12 +1016,18 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
1007
1016
|
//
|
|
1008
1017
|
([socket, unsub]) => {
|
|
1009
1018
|
unsub();
|
|
1019
|
+
if (signal.aborted) {
|
|
1020
|
+
throw new Error("Aborted");
|
|
1021
|
+
}
|
|
1010
1022
|
if (capturedPrematureEvent) {
|
|
1011
1023
|
throw capturedPrematureEvent;
|
|
1012
1024
|
}
|
|
1013
1025
|
return socket;
|
|
1014
1026
|
}
|
|
1015
|
-
)
|
|
1027
|
+
).catch((e) => {
|
|
1028
|
+
teardownSocket(unconfirmedSocket);
|
|
1029
|
+
throw e;
|
|
1030
|
+
});
|
|
1016
1031
|
},
|
|
1017
1032
|
// Only transition to OK state after a successfully opened WebSocket connection
|
|
1018
1033
|
(okEvent) => ({
|