@liveblocks/react 2.9.3-experimental1 → 2.10.0
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/_private/README.md +5 -0
- package/_private/package.json +4 -0
- package/dist/_private.d.mts +14 -0
- package/dist/_private.d.ts +14 -0
- package/dist/_private.js +69 -0
- package/dist/_private.js.map +1 -0
- package/dist/_private.mjs +69 -0
- package/dist/_private.mjs.map +1 -0
- package/dist/{chunk-SNEUTGU4.mjs → chunk-LMENFXCS.mjs} +85 -102
- package/dist/chunk-LMENFXCS.mjs.map +1 -0
- package/dist/chunk-PJN3AKDH.js +22 -0
- package/dist/chunk-PJN3AKDH.js.map +1 -0
- package/dist/chunk-PXKGBTHT.mjs +22 -0
- package/dist/chunk-PXKGBTHT.mjs.map +1 -0
- package/dist/{chunk-PZIVKFDZ.js → chunk-WJLAYICR.js} +74 -91
- package/dist/chunk-WJLAYICR.js.map +1 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -10
- package/dist/index.mjs.map +1 -1
- package/dist/{suspense-fYGGJ3D9.d.mts → liveblocks-X3qYz1Vg.d.mts} +10 -725
- package/dist/{suspense-fYGGJ3D9.d.ts → liveblocks-X3qYz1Vg.d.ts} +10 -725
- package/dist/suspense-pF_E-0CC.d.mts +721 -0
- package/dist/suspense-qQ0vzMgn.d.ts +721 -0
- package/dist/suspense.d.mts +2 -1
- package/dist/suspense.d.ts +2 -1
- package/dist/suspense.js +5 -3
- package/dist/suspense.js.map +1 -1
- package/dist/suspense.mjs +6 -4
- package/dist/suspense.mjs.map +1 -1
- package/package.json +15 -3
- package/dist/chunk-PZIVKFDZ.js.map +0 -1
- package/dist/chunk-SNEUTGU4.mjs.map +0 -1
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
// src/version.ts
|
|
2
|
-
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "2.9.3-experimental1";
|
|
4
|
-
var PKG_FORMAT = "esm";
|
|
5
|
-
|
|
6
|
-
// src/ClientSideSuspense.tsx
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
function ClientSideSuspense(props) {
|
|
9
|
-
const [mounted, setMounted] = React.useState(false);
|
|
10
|
-
React.useEffect(() => {
|
|
11
|
-
setMounted(true);
|
|
12
|
-
}, []);
|
|
13
|
-
return /* @__PURE__ */ React.createElement(React.Suspense, { fallback: props.fallback }, mounted ? typeof props.children === "function" ? props.children() : props.children : props.fallback);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
1
|
// src/contexts.ts
|
|
17
|
-
import * as
|
|
18
|
-
var RoomContext =
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
var RoomContext = React.createContext(null);
|
|
19
4
|
function useRoomOrNull() {
|
|
20
|
-
return
|
|
5
|
+
return React.useContext(RoomContext);
|
|
21
6
|
}
|
|
22
7
|
function useIsInsideRoom() {
|
|
23
8
|
const room = useRoomOrNull();
|
|
@@ -1370,11 +1355,11 @@ import {
|
|
|
1370
1355
|
raise,
|
|
1371
1356
|
shallow as shallow3
|
|
1372
1357
|
} from "@liveblocks/core";
|
|
1373
|
-
import
|
|
1358
|
+
import React2, {
|
|
1374
1359
|
createContext as createContext2,
|
|
1375
1360
|
useCallback as useCallback2,
|
|
1376
1361
|
useContext as useContext2,
|
|
1377
|
-
useEffect as
|
|
1362
|
+
useEffect as useEffect2,
|
|
1378
1363
|
useMemo
|
|
1379
1364
|
} from "react";
|
|
1380
1365
|
import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
|
|
@@ -1399,10 +1384,10 @@ function shallow2(a, b) {
|
|
|
1399
1384
|
import { useCallback, useReducer } from "react";
|
|
1400
1385
|
|
|
1401
1386
|
// src/lib/use-latest.ts
|
|
1402
|
-
import { useEffect
|
|
1387
|
+
import { useEffect, useRef } from "react";
|
|
1403
1388
|
function useLatest(value) {
|
|
1404
1389
|
const ref = useRef(value);
|
|
1405
|
-
|
|
1390
|
+
useEffect(() => {
|
|
1406
1391
|
ref.current = value;
|
|
1407
1392
|
}, [value]);
|
|
1408
1393
|
return ref;
|
|
@@ -1612,7 +1597,7 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1612
1597
|
const useDeleteAllInboxNotifications2 = () => useDeleteAllInboxNotifications_withClient(client);
|
|
1613
1598
|
function LiveblocksProvider2(props) {
|
|
1614
1599
|
useEnsureNoLiveblocksProvider();
|
|
1615
|
-
return /* @__PURE__ */
|
|
1600
|
+
return /* @__PURE__ */ React2.createElement(ClientContext.Provider, { value: client }, props.children);
|
|
1616
1601
|
}
|
|
1617
1602
|
const shared = createSharedContext(client);
|
|
1618
1603
|
const bundle = {
|
|
@@ -1646,11 +1631,11 @@ function useInboxNotifications_withClient(client, selector, isEqual) {
|
|
|
1646
1631
|
store,
|
|
1647
1632
|
subscribeToNotificationsDeltaUpdates: subscribeToDeltaUpdates
|
|
1648
1633
|
} = getLiveblocksExtrasForClient(client);
|
|
1649
|
-
|
|
1634
|
+
useEffect2(() => {
|
|
1650
1635
|
void store.waitUntilNotificationsLoaded().catch(() => {
|
|
1651
1636
|
});
|
|
1652
1637
|
});
|
|
1653
|
-
|
|
1638
|
+
useEffect2(subscribeToDeltaUpdates, [subscribeToDeltaUpdates]);
|
|
1654
1639
|
return useSyncExternalStoreWithSelector(
|
|
1655
1640
|
store.subscribeThreadsOrInboxNotifications,
|
|
1656
1641
|
store.getInboxNotificationsAsync,
|
|
@@ -1804,20 +1789,21 @@ function useUser_withClient(client, userId) {
|
|
|
1804
1789
|
() => usersStore.getState(userId),
|
|
1805
1790
|
[usersStore, userId]
|
|
1806
1791
|
);
|
|
1807
|
-
useEffect3(() => {
|
|
1808
|
-
void usersStore.get(userId);
|
|
1809
|
-
}, [usersStore, userId]);
|
|
1810
1792
|
const selector = useCallback2(
|
|
1811
1793
|
(state) => selectorFor_useUser(state, userId),
|
|
1812
1794
|
[userId]
|
|
1813
1795
|
);
|
|
1814
|
-
|
|
1796
|
+
const result = useSyncExternalStoreWithSelector(
|
|
1815
1797
|
usersStore.subscribe,
|
|
1816
1798
|
getUserState,
|
|
1817
1799
|
getUserState,
|
|
1818
1800
|
selector,
|
|
1819
1801
|
shallow3
|
|
1820
1802
|
);
|
|
1803
|
+
useEffect2(() => {
|
|
1804
|
+
void usersStore.get(userId);
|
|
1805
|
+
}, [usersStore, userId, result]);
|
|
1806
|
+
return result;
|
|
1821
1807
|
}
|
|
1822
1808
|
function useUserSuspense_withClient(client, userId) {
|
|
1823
1809
|
const usersStore = client[kInternal2].usersStore;
|
|
@@ -1859,16 +1845,17 @@ function useRoomInfo_withClient(client, roomId) {
|
|
|
1859
1845
|
(state) => selectorFor_useRoomInfo(state, roomId),
|
|
1860
1846
|
[roomId]
|
|
1861
1847
|
);
|
|
1862
|
-
|
|
1863
|
-
void roomsInfoStore.get(roomId);
|
|
1864
|
-
}, [roomsInfoStore, roomId]);
|
|
1865
|
-
return useSyncExternalStoreWithSelector(
|
|
1848
|
+
const result = useSyncExternalStoreWithSelector(
|
|
1866
1849
|
roomsInfoStore.subscribe,
|
|
1867
1850
|
getRoomInfoState,
|
|
1868
1851
|
getRoomInfoState,
|
|
1869
1852
|
selector,
|
|
1870
1853
|
shallow3
|
|
1871
1854
|
);
|
|
1855
|
+
useEffect2(() => {
|
|
1856
|
+
void roomsInfoStore.get(roomId);
|
|
1857
|
+
}, [roomsInfoStore, roomId, result]);
|
|
1858
|
+
return result;
|
|
1872
1859
|
}
|
|
1873
1860
|
function useRoomInfoSuspense_withClient(client, roomId) {
|
|
1874
1861
|
const roomsInfoStore = client[kInternal2].roomsInfoStore;
|
|
@@ -1934,7 +1921,7 @@ function useClient() {
|
|
|
1934
1921
|
}
|
|
1935
1922
|
function LiveblocksProviderWithClient(props) {
|
|
1936
1923
|
useEnsureNoLiveblocksProvider(props);
|
|
1937
|
-
return /* @__PURE__ */
|
|
1924
|
+
return /* @__PURE__ */ React2.createElement(ClientContext.Provider, { value: props.client }, props.children);
|
|
1938
1925
|
}
|
|
1939
1926
|
function LiveblocksProvider(props) {
|
|
1940
1927
|
const { children, ...o } = props;
|
|
@@ -1962,7 +1949,7 @@ function LiveblocksProvider(props) {
|
|
|
1962
1949
|
)
|
|
1963
1950
|
};
|
|
1964
1951
|
const client = useMemo(() => createClient(options), []);
|
|
1965
|
-
return /* @__PURE__ */
|
|
1952
|
+
return /* @__PURE__ */ React2.createElement(LiveblocksProviderWithClient, { client }, children);
|
|
1966
1953
|
}
|
|
1967
1954
|
function createLiveblocksContext(client) {
|
|
1968
1955
|
return getOrCreateContextBundle(client);
|
|
@@ -1974,7 +1961,7 @@ function useUserThreads_experimental(options = {
|
|
|
1974
1961
|
}) {
|
|
1975
1962
|
const client = useClient();
|
|
1976
1963
|
const { store, subscribeToUserThreadsDeltaUpdates: subscribeToDeltaUpdates } = getLiveblocksExtrasForClient(client);
|
|
1977
|
-
|
|
1964
|
+
useEffect2(
|
|
1978
1965
|
() => {
|
|
1979
1966
|
void store.waitUntilUserThreadsLoaded(options.query).catch(() => {
|
|
1980
1967
|
});
|
|
@@ -1988,7 +1975,7 @@ function useUserThreads_experimental(options = {
|
|
|
1988
1975
|
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
1989
1976
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
1990
1977
|
);
|
|
1991
|
-
|
|
1978
|
+
useEffect2(subscribeToDeltaUpdates, [subscribeToDeltaUpdates]);
|
|
1992
1979
|
const getter = useCallback2(
|
|
1993
1980
|
() => store.getUserThreadsAsync(options.query),
|
|
1994
1981
|
[store, options.query]
|
|
@@ -2179,7 +2166,7 @@ import {
|
|
|
2179
2166
|
NotificationsApiError,
|
|
2180
2167
|
ServerMsgCode
|
|
2181
2168
|
} from "@liveblocks/core";
|
|
2182
|
-
import * as
|
|
2169
|
+
import * as React4 from "react";
|
|
2183
2170
|
import { useSyncExternalStoreWithSelector as useSyncExternalStoreWithSelector2 } from "use-sync-external-store/shim/with-selector.js";
|
|
2184
2171
|
|
|
2185
2172
|
// src/lib/retry-error.ts
|
|
@@ -2194,7 +2181,7 @@ function retryError(action, retryCount) {
|
|
|
2194
2181
|
}
|
|
2195
2182
|
|
|
2196
2183
|
// src/use-scroll-to-comment-on-load-effect.ts
|
|
2197
|
-
import * as
|
|
2184
|
+
import * as React3 from "react";
|
|
2198
2185
|
function handleScrollToCommentOnLoad(shouldScrollOnLoad, state) {
|
|
2199
2186
|
if (shouldScrollOnLoad === false) return;
|
|
2200
2187
|
if (!state.threads) return;
|
|
@@ -2213,7 +2200,7 @@ function handleScrollToCommentOnLoad(shouldScrollOnLoad, state) {
|
|
|
2213
2200
|
comment.scrollIntoView();
|
|
2214
2201
|
}
|
|
2215
2202
|
function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
|
|
2216
|
-
|
|
2203
|
+
React3.useEffect(
|
|
2217
2204
|
() => {
|
|
2218
2205
|
handleScrollToCommentOnLoad(shouldScrollOnLoad, state);
|
|
2219
2206
|
},
|
|
@@ -2416,7 +2403,7 @@ function makeRoomExtrasForClient(client) {
|
|
|
2416
2403
|
}
|
|
2417
2404
|
function makeRoomContextBundle(client) {
|
|
2418
2405
|
function RoomProvider_withImplicitLiveblocksProvider(props) {
|
|
2419
|
-
return /* @__PURE__ */
|
|
2406
|
+
return /* @__PURE__ */ React4.createElement(LiveblocksProviderWithClient, { client, allowNesting: true }, /* @__PURE__ */ React4.createElement(RoomProvider, { ...props }));
|
|
2420
2407
|
}
|
|
2421
2408
|
const shared = createSharedContext(client);
|
|
2422
2409
|
const bundle = {
|
|
@@ -2520,10 +2507,10 @@ function makeRoomContextBundle(client) {
|
|
|
2520
2507
|
}
|
|
2521
2508
|
function RoomProvider(props) {
|
|
2522
2509
|
const client = useClient();
|
|
2523
|
-
const [cache] =
|
|
2510
|
+
const [cache] = React4.useState(
|
|
2524
2511
|
() => /* @__PURE__ */ new Map()
|
|
2525
2512
|
);
|
|
2526
|
-
const stableEnterRoom =
|
|
2513
|
+
const stableEnterRoom = React4.useCallback(
|
|
2527
2514
|
(roomId, options) => {
|
|
2528
2515
|
const cached = cache.get(roomId);
|
|
2529
2516
|
if (cached) return cached;
|
|
@@ -2538,7 +2525,7 @@ function RoomProvider(props) {
|
|
|
2538
2525
|
},
|
|
2539
2526
|
[client, cache]
|
|
2540
2527
|
);
|
|
2541
|
-
return /* @__PURE__ */
|
|
2528
|
+
return /* @__PURE__ */ React4.createElement(
|
|
2542
2529
|
RoomProviderInner,
|
|
2543
2530
|
{
|
|
2544
2531
|
...props,
|
|
@@ -2558,7 +2545,7 @@ function RoomProviderInner(props) {
|
|
|
2558
2545
|
if (!isString(roomId)) {
|
|
2559
2546
|
throw new Error("RoomProvider id property should be a string.");
|
|
2560
2547
|
}
|
|
2561
|
-
const majorReactVersion = parseInt(
|
|
2548
|
+
const majorReactVersion = parseInt(React4.version) || 1;
|
|
2562
2549
|
const oldReactVersion = majorReactVersion < 18;
|
|
2563
2550
|
errorIf(
|
|
2564
2551
|
oldReactVersion && props.unstable_batchedUpdates === void 0,
|
|
@@ -2575,14 +2562,14 @@ function RoomProviderInner(props) {
|
|
|
2575
2562
|
unstable_batchedUpdates: props.unstable_batchedUpdates,
|
|
2576
2563
|
autoConnect: props.autoConnect ?? typeof window !== "undefined"
|
|
2577
2564
|
});
|
|
2578
|
-
const [{ room }, setRoomLeavePair] =
|
|
2565
|
+
const [{ room }, setRoomLeavePair] = React4.useState(
|
|
2579
2566
|
() => stableEnterRoom(roomId, {
|
|
2580
2567
|
...frozenProps,
|
|
2581
2568
|
autoConnect: false
|
|
2582
2569
|
// Deliberately using false here on the first render, see below
|
|
2583
2570
|
})
|
|
2584
2571
|
);
|
|
2585
|
-
|
|
2572
|
+
React4.useEffect(() => {
|
|
2586
2573
|
const { store } = getRoomExtrasForClient(client);
|
|
2587
2574
|
async function handleCommentEvent(message) {
|
|
2588
2575
|
if (message.type === ServerMsgCode.THREAD_DELETED) {
|
|
@@ -2617,12 +2604,12 @@ function RoomProviderInner(props) {
|
|
|
2617
2604
|
(message) => void handleCommentEvent(message)
|
|
2618
2605
|
);
|
|
2619
2606
|
}, [client, room]);
|
|
2620
|
-
|
|
2607
|
+
React4.useEffect(() => {
|
|
2621
2608
|
const store = getRoomExtrasForClient(client).store;
|
|
2622
2609
|
void store.fetchRoomThreadsDeltaUpdate(room.id).catch(() => {
|
|
2623
2610
|
});
|
|
2624
2611
|
}, [client, room.id]);
|
|
2625
|
-
|
|
2612
|
+
React4.useEffect(() => {
|
|
2626
2613
|
function handleIsOnline() {
|
|
2627
2614
|
const store = getRoomExtrasForClient(client).store;
|
|
2628
2615
|
void store.fetchRoomThreadsDeltaUpdate(room.id).catch(() => {
|
|
@@ -2633,7 +2620,7 @@ function RoomProviderInner(props) {
|
|
|
2633
2620
|
window.removeEventListener("online", handleIsOnline);
|
|
2634
2621
|
};
|
|
2635
2622
|
}, [client, room.id]);
|
|
2636
|
-
|
|
2623
|
+
React4.useEffect(() => {
|
|
2637
2624
|
const pair = stableEnterRoom(roomId, frozenProps);
|
|
2638
2625
|
setRoomLeavePair(pair);
|
|
2639
2626
|
const { room: room2, leave } = pair;
|
|
@@ -2644,7 +2631,7 @@ function RoomProviderInner(props) {
|
|
|
2644
2631
|
leave();
|
|
2645
2632
|
};
|
|
2646
2633
|
}, [roomId, frozenProps, stableEnterRoom]);
|
|
2647
|
-
return /* @__PURE__ */
|
|
2634
|
+
return /* @__PURE__ */ React4.createElement(RoomContext.Provider, { value: room }, props.children);
|
|
2648
2635
|
}
|
|
2649
2636
|
function useRoom() {
|
|
2650
2637
|
const room = useRoomOrNull();
|
|
@@ -2677,9 +2664,9 @@ function useStorageStatusImmediate() {
|
|
|
2677
2664
|
}
|
|
2678
2665
|
function useStorageStatusSmooth() {
|
|
2679
2666
|
const room = useRoom();
|
|
2680
|
-
const [status, setStatus] =
|
|
2667
|
+
const [status, setStatus] = React4.useState(room.getStorageStatus);
|
|
2681
2668
|
const oldStatus = useLatest(room.getStorageStatus());
|
|
2682
|
-
|
|
2669
|
+
React4.useEffect(() => {
|
|
2683
2670
|
let timeoutId;
|
|
2684
2671
|
const unsub = room.events.storageStatus.subscribe((newStatus) => {
|
|
2685
2672
|
if (oldStatus.current === "synchronizing" && newStatus === "synchronized") {
|
|
@@ -2701,7 +2688,7 @@ function useBatch() {
|
|
|
2701
2688
|
}
|
|
2702
2689
|
function useBroadcastEvent() {
|
|
2703
2690
|
const room = useRoom();
|
|
2704
|
-
return
|
|
2691
|
+
return React4.useCallback(
|
|
2705
2692
|
(event, options = { shouldQueueEventIfNotReady: false }) => {
|
|
2706
2693
|
room.broadcastEvent(event, options);
|
|
2707
2694
|
},
|
|
@@ -2711,7 +2698,7 @@ function useBroadcastEvent() {
|
|
|
2711
2698
|
function useOthersListener(callback) {
|
|
2712
2699
|
const room = useRoom();
|
|
2713
2700
|
const savedCallback = useLatest(callback);
|
|
2714
|
-
|
|
2701
|
+
React4.useEffect(
|
|
2715
2702
|
() => room.events.others.subscribe((event) => savedCallback.current(event)),
|
|
2716
2703
|
[room, savedCallback]
|
|
2717
2704
|
);
|
|
@@ -2719,7 +2706,7 @@ function useOthersListener(callback) {
|
|
|
2719
2706
|
function useLostConnectionListener(callback) {
|
|
2720
2707
|
const room = useRoom();
|
|
2721
2708
|
const savedCallback = useLatest(callback);
|
|
2722
|
-
|
|
2709
|
+
React4.useEffect(
|
|
2723
2710
|
() => room.events.lostConnection.subscribe(
|
|
2724
2711
|
(event) => savedCallback.current(event)
|
|
2725
2712
|
),
|
|
@@ -2729,7 +2716,7 @@ function useLostConnectionListener(callback) {
|
|
|
2729
2716
|
function useErrorListener(callback) {
|
|
2730
2717
|
const room = useRoom();
|
|
2731
2718
|
const savedCallback = useLatest(callback);
|
|
2732
|
-
|
|
2719
|
+
React4.useEffect(
|
|
2733
2720
|
() => room.events.error.subscribe((e) => savedCallback.current(e)),
|
|
2734
2721
|
[room, savedCallback]
|
|
2735
2722
|
);
|
|
@@ -2737,7 +2724,7 @@ function useErrorListener(callback) {
|
|
|
2737
2724
|
function useEventListener(callback) {
|
|
2738
2725
|
const room = useRoom();
|
|
2739
2726
|
const savedCallback = useLatest(callback);
|
|
2740
|
-
|
|
2727
|
+
React4.useEffect(() => {
|
|
2741
2728
|
const listener = (eventData) => {
|
|
2742
2729
|
savedCallback.current(eventData);
|
|
2743
2730
|
};
|
|
@@ -2770,7 +2757,7 @@ function useSelf(maybeSelector, isEqual) {
|
|
|
2770
2757
|
const subscribe = room.events.self.subscribe;
|
|
2771
2758
|
const getSnapshot = room.getSelf;
|
|
2772
2759
|
const selector = maybeSelector ?? identity2;
|
|
2773
|
-
const wrappedSelector =
|
|
2760
|
+
const wrappedSelector = React4.useCallback(
|
|
2774
2761
|
(me) => me !== null ? selector(me) : null,
|
|
2775
2762
|
[selector]
|
|
2776
2763
|
);
|
|
@@ -2808,11 +2795,11 @@ function useOthers(selector, isEqual) {
|
|
|
2808
2795
|
);
|
|
2809
2796
|
}
|
|
2810
2797
|
function useOthersMapped(itemSelector, itemIsEqual) {
|
|
2811
|
-
const wrappedSelector =
|
|
2798
|
+
const wrappedSelector = React4.useCallback(
|
|
2812
2799
|
(others) => others.map((other) => [other.connectionId, itemSelector(other)]),
|
|
2813
2800
|
[itemSelector]
|
|
2814
2801
|
);
|
|
2815
|
-
const wrappedIsEqual =
|
|
2802
|
+
const wrappedIsEqual = React4.useCallback(
|
|
2816
2803
|
(a, b) => {
|
|
2817
2804
|
const eq = itemIsEqual ?? Object.is;
|
|
2818
2805
|
return a.length === b.length && a.every((atuple, index) => {
|
|
@@ -2829,14 +2816,14 @@ function useOthersConnectionIds() {
|
|
|
2829
2816
|
}
|
|
2830
2817
|
var NOT_FOUND = Symbol();
|
|
2831
2818
|
function useOther(connectionId, selector, isEqual) {
|
|
2832
|
-
const wrappedSelector =
|
|
2819
|
+
const wrappedSelector = React4.useCallback(
|
|
2833
2820
|
(others) => {
|
|
2834
2821
|
const other2 = others.find((other3) => other3.connectionId === connectionId);
|
|
2835
2822
|
return other2 !== void 0 ? selector(other2) : NOT_FOUND;
|
|
2836
2823
|
},
|
|
2837
2824
|
[connectionId, selector]
|
|
2838
2825
|
);
|
|
2839
|
-
const wrappedIsEqual =
|
|
2826
|
+
const wrappedIsEqual = React4.useCallback(
|
|
2840
2827
|
(prev, curr) => {
|
|
2841
2828
|
if (prev === NOT_FOUND || curr === NOT_FOUND) {
|
|
2842
2829
|
return prev === curr;
|
|
@@ -2867,15 +2854,15 @@ function useStorageRoot() {
|
|
|
2867
2854
|
function useStorage(selector, isEqual) {
|
|
2868
2855
|
const room = useRoom();
|
|
2869
2856
|
const rootOrNull = useMutableStorageRoot();
|
|
2870
|
-
const wrappedSelector =
|
|
2857
|
+
const wrappedSelector = React4.useCallback(
|
|
2871
2858
|
(rootOrNull2) => rootOrNull2 !== null ? selector(rootOrNull2) : null,
|
|
2872
2859
|
[selector]
|
|
2873
2860
|
);
|
|
2874
|
-
const subscribe =
|
|
2861
|
+
const subscribe = React4.useCallback(
|
|
2875
2862
|
(onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) : noop3,
|
|
2876
2863
|
[room, rootOrNull]
|
|
2877
2864
|
);
|
|
2878
|
-
const getSnapshot =
|
|
2865
|
+
const getSnapshot = React4.useCallback(() => {
|
|
2879
2866
|
if (rootOrNull === null) {
|
|
2880
2867
|
return null;
|
|
2881
2868
|
} else {
|
|
@@ -2895,7 +2882,7 @@ function useStorage(selector, isEqual) {
|
|
|
2895
2882
|
}
|
|
2896
2883
|
function useMutation(callback, deps) {
|
|
2897
2884
|
const room = useRoom();
|
|
2898
|
-
return
|
|
2885
|
+
return React4.useMemo(
|
|
2899
2886
|
() => {
|
|
2900
2887
|
return (...args) => (
|
|
2901
2888
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -2921,7 +2908,7 @@ function useThreads(options = {
|
|
|
2921
2908
|
const client = useClient();
|
|
2922
2909
|
const room = useRoom();
|
|
2923
2910
|
const { store, subscribeToRoomThreadsDeltaUpdates: subscribeToDeltaUpdates } = getRoomExtrasForClient(client);
|
|
2924
|
-
|
|
2911
|
+
React4.useEffect(
|
|
2925
2912
|
() => {
|
|
2926
2913
|
void store.waitUntilRoomThreadsLoaded(room.id, options.query).catch(() => {
|
|
2927
2914
|
});
|
|
@@ -2935,8 +2922,8 @@ function useThreads(options = {
|
|
|
2935
2922
|
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
2936
2923
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
2937
2924
|
);
|
|
2938
|
-
|
|
2939
|
-
const getter =
|
|
2925
|
+
React4.useEffect(subscribeToDeltaUpdates, [subscribeToDeltaUpdates]);
|
|
2926
|
+
const getter = React4.useCallback(
|
|
2940
2927
|
() => store.getRoomThreadsAsync(room.id, options.query),
|
|
2941
2928
|
[store, room.id, options.query]
|
|
2942
2929
|
);
|
|
@@ -2955,14 +2942,14 @@ function useCommentsErrorListener(callback) {
|
|
|
2955
2942
|
const client = useClient();
|
|
2956
2943
|
const savedCallback = useLatest(callback);
|
|
2957
2944
|
const { commentsErrorEventSource } = getRoomExtrasForClient(client);
|
|
2958
|
-
|
|
2945
|
+
React4.useEffect(() => {
|
|
2959
2946
|
return commentsErrorEventSource.subscribe(savedCallback.current);
|
|
2960
2947
|
}, [savedCallback, commentsErrorEventSource]);
|
|
2961
2948
|
}
|
|
2962
2949
|
function useCreateThread() {
|
|
2963
2950
|
const client = useClient();
|
|
2964
2951
|
const room = useRoom();
|
|
2965
|
-
return
|
|
2952
|
+
return React4.useCallback(
|
|
2966
2953
|
(options) => {
|
|
2967
2954
|
const body = options.body;
|
|
2968
2955
|
const metadata = options.metadata ?? {};
|
|
@@ -3022,7 +3009,7 @@ function useCreateThread() {
|
|
|
3022
3009
|
function useDeleteThread() {
|
|
3023
3010
|
const client = useClient();
|
|
3024
3011
|
const room = useRoom();
|
|
3025
|
-
return
|
|
3012
|
+
return React4.useCallback(
|
|
3026
3013
|
(threadId) => {
|
|
3027
3014
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3028
3015
|
const thread = store.getFullState().threadsById[threadId];
|
|
@@ -3053,7 +3040,7 @@ function useDeleteThread() {
|
|
|
3053
3040
|
function useEditThreadMetadata() {
|
|
3054
3041
|
const client = useClient();
|
|
3055
3042
|
const room = useRoom();
|
|
3056
|
-
return
|
|
3043
|
+
return React4.useCallback(
|
|
3057
3044
|
(options) => {
|
|
3058
3045
|
if (!options.metadata) {
|
|
3059
3046
|
return;
|
|
@@ -3095,7 +3082,7 @@ function useEditThreadMetadata() {
|
|
|
3095
3082
|
function useCreateComment() {
|
|
3096
3083
|
const client = useClient();
|
|
3097
3084
|
const room = useRoom();
|
|
3098
|
-
return
|
|
3085
|
+
return React4.useCallback(
|
|
3099
3086
|
({ threadId, body, attachments }) => {
|
|
3100
3087
|
const commentId = createCommentId();
|
|
3101
3088
|
const createdAt = /* @__PURE__ */ new Date();
|
|
@@ -3139,7 +3126,7 @@ function useCreateComment() {
|
|
|
3139
3126
|
function useEditComment() {
|
|
3140
3127
|
const client = useClient();
|
|
3141
3128
|
const room = useRoom();
|
|
3142
|
-
return
|
|
3129
|
+
return React4.useCallback(
|
|
3143
3130
|
({ threadId, commentId, body, attachments }) => {
|
|
3144
3131
|
const editedAt = /* @__PURE__ */ new Date();
|
|
3145
3132
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
@@ -3191,7 +3178,7 @@ function useEditComment() {
|
|
|
3191
3178
|
function useDeleteComment() {
|
|
3192
3179
|
const client = useClient();
|
|
3193
3180
|
const room = useRoom();
|
|
3194
|
-
return
|
|
3181
|
+
return React4.useCallback(
|
|
3195
3182
|
({ threadId, commentId }) => {
|
|
3196
3183
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
3197
3184
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
@@ -3228,7 +3215,7 @@ function useDeleteComment() {
|
|
|
3228
3215
|
function useAddReaction() {
|
|
3229
3216
|
const client = useClient();
|
|
3230
3217
|
const room = useRoom();
|
|
3231
|
-
return
|
|
3218
|
+
return React4.useCallback(
|
|
3232
3219
|
({ threadId, commentId, emoji }) => {
|
|
3233
3220
|
const createdAt = /* @__PURE__ */ new Date();
|
|
3234
3221
|
const userId = getCurrentUserId(room);
|
|
@@ -3271,7 +3258,7 @@ function useAddReaction() {
|
|
|
3271
3258
|
function useRemoveReaction() {
|
|
3272
3259
|
const client = useClient();
|
|
3273
3260
|
const room = useRoom();
|
|
3274
|
-
return
|
|
3261
|
+
return React4.useCallback(
|
|
3275
3262
|
({ threadId, commentId, emoji }) => {
|
|
3276
3263
|
const userId = getCurrentUserId(room);
|
|
3277
3264
|
const removedAt = /* @__PURE__ */ new Date();
|
|
@@ -3313,7 +3300,7 @@ function useRemoveReaction() {
|
|
|
3313
3300
|
function useMarkThreadAsRead() {
|
|
3314
3301
|
const client = useClient();
|
|
3315
3302
|
const room = useRoom();
|
|
3316
|
-
return
|
|
3303
|
+
return React4.useCallback(
|
|
3317
3304
|
(threadId) => {
|
|
3318
3305
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3319
3306
|
const inboxNotification = Object.values(
|
|
@@ -3354,7 +3341,7 @@ function useMarkThreadAsRead() {
|
|
|
3354
3341
|
function useMarkThreadAsResolved() {
|
|
3355
3342
|
const client = useClient();
|
|
3356
3343
|
const room = useRoom();
|
|
3357
|
-
return
|
|
3344
|
+
return React4.useCallback(
|
|
3358
3345
|
(threadId) => {
|
|
3359
3346
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
3360
3347
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
@@ -3388,7 +3375,7 @@ function useMarkThreadAsResolved() {
|
|
|
3388
3375
|
function useMarkThreadAsUnresolved() {
|
|
3389
3376
|
const client = useClient();
|
|
3390
3377
|
const room = useRoom();
|
|
3391
|
-
return
|
|
3378
|
+
return React4.useCallback(
|
|
3392
3379
|
(threadId) => {
|
|
3393
3380
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
3394
3381
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
@@ -3422,7 +3409,7 @@ function useMarkThreadAsUnresolved() {
|
|
|
3422
3409
|
function useThreadSubscription(threadId) {
|
|
3423
3410
|
const client = useClient();
|
|
3424
3411
|
const { store } = getRoomExtrasForClient(client);
|
|
3425
|
-
const selector =
|
|
3412
|
+
const selector = React4.useCallback(
|
|
3426
3413
|
(state) => {
|
|
3427
3414
|
const inboxNotification = state.notifications.find(
|
|
3428
3415
|
(inboxNotification2) => inboxNotification2.kind === "thread" && inboxNotification2.threadId === threadId
|
|
@@ -3452,11 +3439,11 @@ function useRoomNotificationSettings() {
|
|
|
3452
3439
|
const client = useClient();
|
|
3453
3440
|
const room = useRoom();
|
|
3454
3441
|
const { store } = getRoomExtrasForClient(client);
|
|
3455
|
-
const getter =
|
|
3442
|
+
const getter = React4.useCallback(
|
|
3456
3443
|
() => store.getNotificationSettingsAsync(room.id),
|
|
3457
3444
|
[store, room.id]
|
|
3458
3445
|
);
|
|
3459
|
-
|
|
3446
|
+
React4.useEffect(() => {
|
|
3460
3447
|
const { getInboxNotificationSettings } = getRoomExtrasForClient(client);
|
|
3461
3448
|
void getInboxNotificationSettings(room);
|
|
3462
3449
|
}, [client, room]);
|
|
@@ -3467,7 +3454,7 @@ function useRoomNotificationSettings() {
|
|
|
3467
3454
|
identity2,
|
|
3468
3455
|
shallow4
|
|
3469
3456
|
);
|
|
3470
|
-
return
|
|
3457
|
+
return React4.useMemo(() => {
|
|
3471
3458
|
return [settings, updateRoomNotificationSettings];
|
|
3472
3459
|
}, [settings, updateRoomNotificationSettings]);
|
|
3473
3460
|
}
|
|
@@ -3476,7 +3463,7 @@ function useRoomNotificationSettingsSuspense() {
|
|
|
3476
3463
|
const client = useClient();
|
|
3477
3464
|
const room = useRoom();
|
|
3478
3465
|
const { store } = getRoomExtrasForClient(client);
|
|
3479
|
-
const getter =
|
|
3466
|
+
const getter = React4.useCallback(
|
|
3480
3467
|
() => store.getNotificationSettingsAsync(room.id),
|
|
3481
3468
|
[store, room.id]
|
|
3482
3469
|
);
|
|
@@ -3493,16 +3480,16 @@ function useRoomNotificationSettingsSuspense() {
|
|
|
3493
3480
|
} else if (settings.error) {
|
|
3494
3481
|
throw settings.error;
|
|
3495
3482
|
}
|
|
3496
|
-
return
|
|
3483
|
+
return React4.useMemo(() => {
|
|
3497
3484
|
return [settings, updateRoomNotificationSettings];
|
|
3498
3485
|
}, [settings, updateRoomNotificationSettings]);
|
|
3499
3486
|
}
|
|
3500
3487
|
function useHistoryVersionData(versionId) {
|
|
3501
|
-
const [state, setState] =
|
|
3488
|
+
const [state, setState] = React4.useState({
|
|
3502
3489
|
isLoading: true
|
|
3503
3490
|
});
|
|
3504
3491
|
const room = useRoom();
|
|
3505
|
-
|
|
3492
|
+
React4.useEffect(() => {
|
|
3506
3493
|
setState({ isLoading: true });
|
|
3507
3494
|
const load = async () => {
|
|
3508
3495
|
try {
|
|
@@ -3530,11 +3517,11 @@ function useHistoryVersions() {
|
|
|
3530
3517
|
const client = useClient();
|
|
3531
3518
|
const room = useRoom();
|
|
3532
3519
|
const { store, getRoomVersions } = getRoomExtrasForClient(client);
|
|
3533
|
-
const getter =
|
|
3520
|
+
const getter = React4.useCallback(
|
|
3534
3521
|
() => store.getVersionsAsync(room.id),
|
|
3535
3522
|
[store, room.id]
|
|
3536
3523
|
);
|
|
3537
|
-
|
|
3524
|
+
React4.useEffect(() => {
|
|
3538
3525
|
void getRoomVersions(room);
|
|
3539
3526
|
}, [room]);
|
|
3540
3527
|
const state = useSyncExternalStoreWithSelector2(
|
|
@@ -3550,7 +3537,7 @@ function useHistoryVersionsSuspense() {
|
|
|
3550
3537
|
const client = useClient();
|
|
3551
3538
|
const room = useRoom();
|
|
3552
3539
|
const { store } = getRoomExtrasForClient(client);
|
|
3553
|
-
const getter =
|
|
3540
|
+
const getter = React4.useCallback(
|
|
3554
3541
|
() => store.getVersionsAsync(room.id),
|
|
3555
3542
|
[store, room.id]
|
|
3556
3543
|
);
|
|
@@ -3572,7 +3559,7 @@ function useHistoryVersionsSuspense() {
|
|
|
3572
3559
|
function useUpdateRoomNotificationSettings() {
|
|
3573
3560
|
const client = useClient();
|
|
3574
3561
|
const room = useRoom();
|
|
3575
|
-
return
|
|
3562
|
+
return React4.useCallback(
|
|
3576
3563
|
(settings) => {
|
|
3577
3564
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3578
3565
|
const optimisticUpdateId = store.addOptimisticUpdate({
|
|
@@ -3682,11 +3669,11 @@ function selectorFor_useAttachmentUrl(state) {
|
|
|
3682
3669
|
function useAttachmentUrl(attachmentId) {
|
|
3683
3670
|
const room = useRoom();
|
|
3684
3671
|
const { attachmentUrlsStore } = room[kInternal3];
|
|
3685
|
-
const getAttachmentUrlState =
|
|
3672
|
+
const getAttachmentUrlState = React4.useCallback(
|
|
3686
3673
|
() => attachmentUrlsStore.getState(attachmentId),
|
|
3687
3674
|
[attachmentUrlsStore, attachmentId]
|
|
3688
3675
|
);
|
|
3689
|
-
|
|
3676
|
+
React4.useEffect(() => {
|
|
3690
3677
|
void attachmentUrlsStore.get(attachmentId);
|
|
3691
3678
|
}, [attachmentUrlsStore, attachmentId]);
|
|
3692
3679
|
return useSyncExternalStoreWithSelector2(
|
|
@@ -3700,7 +3687,7 @@ function useAttachmentUrl(attachmentId) {
|
|
|
3700
3687
|
function useAttachmentUrlSuspense(attachmentId) {
|
|
3701
3688
|
const room = useRoom();
|
|
3702
3689
|
const { attachmentUrlsStore } = room[kInternal3];
|
|
3703
|
-
const getAttachmentUrlState =
|
|
3690
|
+
const getAttachmentUrlState = React4.useCallback(
|
|
3704
3691
|
() => attachmentUrlsStore.getState(attachmentId),
|
|
3705
3692
|
[attachmentUrlsStore, attachmentId]
|
|
3706
3693
|
);
|
|
@@ -3766,10 +3753,6 @@ var _useStorageRoot = useStorageRoot;
|
|
|
3766
3753
|
var _useUpdateMyPresence = useUpdateMyPresence;
|
|
3767
3754
|
|
|
3768
3755
|
export {
|
|
3769
|
-
PKG_NAME,
|
|
3770
|
-
PKG_VERSION,
|
|
3771
|
-
PKG_FORMAT,
|
|
3772
|
-
ClientSideSuspense,
|
|
3773
3756
|
RoomContext,
|
|
3774
3757
|
selectThreads,
|
|
3775
3758
|
ClientContext,
|
|
@@ -3850,4 +3833,4 @@ export {
|
|
|
3850
3833
|
_useStorageRoot,
|
|
3851
3834
|
_useUpdateMyPresence
|
|
3852
3835
|
};
|
|
3853
|
-
//# sourceMappingURL=chunk-
|
|
3836
|
+
//# sourceMappingURL=chunk-LMENFXCS.mjs.map
|