@liveblocks/core 3.25.0 → 3.25.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.cjs +22 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1730,7 +1730,7 @@ type InboxNotificationCustomData<K extends keyof DAD = keyof DAD> = {
|
|
|
1730
1730
|
readAt: Date | null;
|
|
1731
1731
|
activities: InboxNotificationActivity<K>[];
|
|
1732
1732
|
};
|
|
1733
|
-
type InboxNotificationData = InboxNotificationThreadData | InboxNotificationCustomData | InboxNotificationTextMentionData
|
|
1733
|
+
type InboxNotificationData = Relax<InboxNotificationThreadData | InboxNotificationCustomData | InboxNotificationTextMentionData>;
|
|
1734
1734
|
type InboxNotificationThreadDataPlain = DateToString<InboxNotificationThreadData>;
|
|
1735
1735
|
type InboxNotificationCustomDataPlain = Omit<DateToString<InboxNotificationCustomData>, "activities"> & {
|
|
1736
1736
|
activities: DateToString<InboxNotificationActivity>[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1730,7 +1730,7 @@ type InboxNotificationCustomData<K extends keyof DAD = keyof DAD> = {
|
|
|
1730
1730
|
readAt: Date | null;
|
|
1731
1731
|
activities: InboxNotificationActivity<K>[];
|
|
1732
1732
|
};
|
|
1733
|
-
type InboxNotificationData = InboxNotificationThreadData | InboxNotificationCustomData | InboxNotificationTextMentionData
|
|
1733
|
+
type InboxNotificationData = Relax<InboxNotificationThreadData | InboxNotificationCustomData | InboxNotificationTextMentionData>;
|
|
1734
1734
|
type InboxNotificationThreadDataPlain = DateToString<InboxNotificationThreadData>;
|
|
1735
1735
|
type InboxNotificationCustomDataPlain = Omit<DateToString<InboxNotificationCustomData>, "activities"> & {
|
|
1736
1736
|
activities: DateToString<InboxNotificationActivity>[];
|
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 = "3.25.
|
|
9
|
+
var PKG_VERSION = "3.25.2";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1496,9 +1496,13 @@ function toNewConnectionStatus(machine) {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
var BACKOFF_DELAYS = [250, 500, 1e3, 2e3, 4e3, 8e3, 1e4];
|
|
1498
1498
|
var RESET_DELAY = BACKOFF_DELAYS[0] - 1;
|
|
1499
|
+
function withJitter(delay) {
|
|
1500
|
+
return Math.round(delay * (1 + Math.random() * 0.2));
|
|
1501
|
+
}
|
|
1499
1502
|
var BACKOFF_DELAYS_SLOW = [2e3, 3e4, 6e4, 3e5];
|
|
1500
1503
|
var HEARTBEAT_INTERVAL = 3e4;
|
|
1501
1504
|
var PONG_TIMEOUT = 2e3;
|
|
1505
|
+
var HEALTHY_CONNECTION_THRESHOLD = 1e4;
|
|
1502
1506
|
var AUTH_TIMEOUT = 1e4;
|
|
1503
1507
|
var SOCKET_CONNECT_TIMEOUT = 2e4;
|
|
1504
1508
|
var StopRetrying = class extends Error {
|
|
@@ -1519,6 +1523,9 @@ function increaseBackoffDelayAggressively(context) {
|
|
|
1519
1523
|
backoffDelay: nextBackoffDelay(context.backoffDelay, BACKOFF_DELAYS_SLOW)
|
|
1520
1524
|
});
|
|
1521
1525
|
}
|
|
1526
|
+
function resetBackoffDelay(context) {
|
|
1527
|
+
context.patch({ backoffDelay: RESET_DELAY });
|
|
1528
|
+
}
|
|
1522
1529
|
function resetSuccessCount(context) {
|
|
1523
1530
|
context.patch({ successCount: 0 });
|
|
1524
1531
|
}
|
|
@@ -1626,10 +1633,12 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
1626
1633
|
};
|
|
1627
1634
|
const machine = new FSM(initialContext).addState("@idle.initial").addState("@idle.failed").addState("@idle.zombie").addState("@auth.busy").addState("@auth.backoff").addState("@connecting.busy").addState("@connecting.backoff").addState("@ok.connected").addState("@ok.awaiting-pong");
|
|
1628
1635
|
machine.addTransitions("*", {
|
|
1629
|
-
RECONNECT: {
|
|
1636
|
+
RECONNECT: (_, ctx) => ({
|
|
1630
1637
|
target: "@auth.backoff",
|
|
1631
|
-
|
|
1632
|
-
|
|
1638
|
+
// Closing a connection is the app's choice, so it should not count as
|
|
1639
|
+
// a failed attempt that would increase the backoff delay
|
|
1640
|
+
effect: ctx.socket !== null ? [resetBackoffDelay, increaseBackoffDelay, resetSuccessCount] : [increaseBackoffDelay, resetSuccessCount]
|
|
1641
|
+
}),
|
|
1633
1642
|
DISCONNECT: "@idle.initial"
|
|
1634
1643
|
});
|
|
1635
1644
|
machine.onEnter("@idle.*", resetSuccessCount).addTransitions("@idle.*", {
|
|
@@ -1646,7 +1655,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
1646
1655
|
}
|
|
1647
1656
|
}).addTimedTransition(
|
|
1648
1657
|
"@auth.backoff",
|
|
1649
|
-
(ctx) => ctx.backoffDelay,
|
|
1658
|
+
(ctx) => withJitter(ctx.backoffDelay),
|
|
1650
1659
|
"@auth.busy"
|
|
1651
1660
|
).onEnterAsync(
|
|
1652
1661
|
"@auth.busy",
|
|
@@ -1708,7 +1717,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
1708
1717
|
}
|
|
1709
1718
|
}).addTimedTransition(
|
|
1710
1719
|
"@connecting.backoff",
|
|
1711
|
-
(ctx) => ctx.backoffDelay,
|
|
1720
|
+
(ctx) => withJitter(ctx.backoffDelay),
|
|
1712
1721
|
"@connecting.busy"
|
|
1713
1722
|
).onEnterAsync(
|
|
1714
1723
|
"@connecting.busy",
|
|
@@ -1817,10 +1826,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
1817
1826
|
// Only transition to OK state after a successfully opened WebSocket connection
|
|
1818
1827
|
(okEvent) => ({
|
|
1819
1828
|
target: "@ok.connected",
|
|
1820
|
-
effect: assign({
|
|
1821
|
-
socket: okEvent.data,
|
|
1822
|
-
backoffDelay: RESET_DELAY
|
|
1823
|
-
})
|
|
1829
|
+
effect: assign({ socket: okEvent.data })
|
|
1824
1830
|
}),
|
|
1825
1831
|
// If the WebSocket connection cannot be established
|
|
1826
1832
|
(failure) => {
|
|
@@ -1892,6 +1898,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
1892
1898
|
});
|
|
1893
1899
|
machine.onEnter("@ok.*", (ctx) => {
|
|
1894
1900
|
ctx.patch({ successCount: ctx.successCount + 1 });
|
|
1901
|
+
const connectedAt = Date.now();
|
|
1895
1902
|
const timerID = setTimeout(
|
|
1896
1903
|
// On the next tick, start delivering all messages that have already
|
|
1897
1904
|
// been received, and continue synchronous delivery of all future
|
|
@@ -1901,7 +1908,11 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
1901
1908
|
);
|
|
1902
1909
|
return (ctx2) => {
|
|
1903
1910
|
teardownSocket(ctx2.socket);
|
|
1904
|
-
|
|
1911
|
+
if (Date.now() - connectedAt >= HEALTHY_CONNECTION_THRESHOLD) {
|
|
1912
|
+
ctx2.patch({ socket: null, backoffDelay: RESET_DELAY });
|
|
1913
|
+
} else {
|
|
1914
|
+
ctx2.patch({ socket: null });
|
|
1915
|
+
}
|
|
1905
1916
|
clearTimeout(timerID);
|
|
1906
1917
|
onMessage.pause();
|
|
1907
1918
|
};
|