@liveblocks/react 3.3.4 → 3.4.0-alpha1

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/version.ts
2
2
  var PKG_NAME = "@liveblocks/react";
3
- var PKG_VERSION = "3.3.4";
3
+ var PKG_VERSION = "3.4.0-alpha1";
4
4
  var PKG_FORMAT = "cjs";
5
5
 
6
6
  // src/ClientSideSuspense.tsx
@@ -20,4 +20,4 @@ function ClientSideSuspense(props) {
20
20
 
21
21
 
22
22
  exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense;
23
- //# sourceMappingURL=chunk-FRJTGF46.cjs.map
23
+ //# sourceMappingURL=chunk-M3QELTRL.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-FRJTGF46.cjs","../src/version.ts","../src/ClientSideSuspense.tsx"],"names":[],"mappings":"AAAA;ACGO,IAAM,SAAA,EAAW,mBAAA;AACjB,IAAM,YAAA,EAAiD,OAAA;AACvD,IAAM,WAAA,EAAgD,KAAA;ADD7D;AACA;AEJA,8BAA8C;AAkC1C,+CAAA;AAVG,SAAS,kBAAA,CAAmB,KAAA,EAAc;AAC/C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAE5C,EAAA,8BAAA,CAAU,EAAA,GAAM;AAGd,IAAA,UAAA,CAAW,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,CAAC,CAAC,CAAA;AAEL,EAAA,uBACE,6BAAA,eAAC,EAAA,EAAS,QAAA,EAAU,KAAA,CAAM,QAAA,EACvB,QAAA,EAAA,QAAA,EACG,OAAO,KAAA,CAAM,SAAA,IAAa,WAAA,EACxB,KAAA,CAAM,QAAA,CAAS,EAAA,EACf,KAAA,CAAM,SAAA,EACR,KAAA,CAAM,SAAA,CACZ,CAAA;AAEJ;AF5BA;AACA;AACE;AACA;AACA;AACA;AACF,iJAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-FRJTGF46.cjs","sourcesContent":[null,"declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n","import type { ReactNode } from \"react\";\nimport { Suspense, useEffect, useState } from \"react\";\n\ntype Props = {\n fallback: ReactNode;\n children: (() => ReactNode | undefined) | ReactNode | undefined;\n};\n\n/**\n * Almost like a normal <Suspense> component, except that for server-side\n * renders, the fallback will be used.\n *\n * The child props will have to be provided in a function, i.e. change:\n *\n * <Suspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </Suspense>\n *\n * To:\n *\n * <ClientSideSuspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </ClientSideSuspense>\n *\n */\nexport function ClientSideSuspense(props: Props) {\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n // Effects are never executed on the server side. The point of this is to\n // delay the flipping of this boolean until after hydration has happened.\n setMounted(true);\n }, []);\n\n return (\n <Suspense fallback={props.fallback}>\n {mounted\n ? typeof props.children === \"function\"\n ? props.children()\n : props.children\n : props.fallback}\n </Suspense>\n );\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-M3QELTRL.cjs","../src/version.ts","../src/ClientSideSuspense.tsx"],"names":[],"mappings":"AAAA;ACGO,IAAM,SAAA,EAAW,mBAAA;AACjB,IAAM,YAAA,EAAiD,cAAA;AACvD,IAAM,WAAA,EAAgD,KAAA;ADD7D;AACA;AEJA,8BAA8C;AAkC1C,+CAAA;AAVG,SAAS,kBAAA,CAAmB,KAAA,EAAc;AAC/C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAE5C,EAAA,8BAAA,CAAU,EAAA,GAAM;AAGd,IAAA,UAAA,CAAW,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,CAAC,CAAC,CAAA;AAEL,EAAA,uBACE,6BAAA,eAAC,EAAA,EAAS,QAAA,EAAU,KAAA,CAAM,QAAA,EACvB,QAAA,EAAA,QAAA,EACG,OAAO,KAAA,CAAM,SAAA,IAAa,WAAA,EACxB,KAAA,CAAM,QAAA,CAAS,EAAA,EACf,KAAA,CAAM,SAAA,EACR,KAAA,CAAM,SAAA,CACZ,CAAA;AAEJ;AF5BA;AACA;AACE;AACA;AACA;AACA;AACF,iJAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-M3QELTRL.cjs","sourcesContent":[null,"declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n","import type { ReactNode } from \"react\";\nimport { Suspense, useEffect, useState } from \"react\";\n\ntype Props = {\n fallback: ReactNode;\n children: (() => ReactNode | undefined) | ReactNode | undefined;\n};\n\n/**\n * Almost like a normal <Suspense> component, except that for server-side\n * renders, the fallback will be used.\n *\n * The child props will have to be provided in a function, i.e. change:\n *\n * <Suspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </Suspense>\n *\n * To:\n *\n * <ClientSideSuspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </ClientSideSuspense>\n *\n */\nexport function ClientSideSuspense(props: Props) {\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n // Effects are never executed on the server side. The point of this is to\n // delay the flipping of this boolean until after hydration has happened.\n setMounted(true);\n }, []);\n\n return (\n <Suspense fallback={props.fallback}>\n {mounted\n ? typeof props.children === \"function\"\n ? props.children()\n : props.children\n : props.fallback}\n </Suspense>\n );\n}\n"]}
@@ -180,7 +180,7 @@ import {
180
180
  import {
181
181
  useCallback as useCallback2,
182
182
  useEffect as useEffect4,
183
- useMemo as useMemo2,
183
+ useMemo as useMemo3,
184
184
  useState as useState2,
185
185
  useSyncExternalStore as useSyncExternalStore2
186
186
  } from "react";
@@ -240,18 +240,19 @@ function ensureNotServerSide() {
240
240
  }
241
241
 
242
242
  // src/lib/use-initial.ts
243
- import { useCallback, useReducer } from "react";
244
- var noop = (state) => state;
245
- function useInitial(value) {
246
- return useReducer(noop, value)[0];
247
- }
248
- function useInitialUnlessFunction(latestValue) {
249
- const frozenValue = useInitial(latestValue);
243
+ import { useCallback, useMemo as useMemo2 } from "react";
244
+ function useInitial(value, roomId) {
245
+ return useMemo2(() => value, [roomId]);
246
+ }
247
+ function useInitialUnlessFunction(latestValue, roomId) {
248
+ const frozenValue = useInitial(latestValue, roomId);
249
+ const ref = useLatest(latestValue);
250
+ const wrapper = useCallback(
251
+ (...args) => ref.current(...args),
252
+ [ref]
253
+ );
250
254
  if (typeof frozenValue === "function") {
251
- const ref = useLatest(latestValue);
252
- return useCallback((...args) => ref.current(...args), [
253
- ref
254
- ]);
255
+ return wrapper;
255
256
  } else {
256
257
  return frozenValue;
257
258
  }
@@ -508,7 +509,7 @@ function usify(promise) {
508
509
  );
509
510
  return usable;
510
511
  }
511
- var noop2 = Promise.resolve();
512
+ var noop = Promise.resolve();
512
513
  var PaginatedResource = class {
513
514
  #signal;
514
515
  signal;
@@ -552,7 +553,7 @@ var PaginatedResource = class {
552
553
  }
553
554
  fetchMore() {
554
555
  const state = this.#signal.get();
555
- if (!state.data?.cursor) return noop2;
556
+ if (!state.data?.cursor) return noop;
556
557
  if (!this.#pendingFetchMore) {
557
558
  this.#pendingFetchMore = this.#fetchMore().finally(() => {
558
559
  this.#pendingFetchMore = null;
@@ -2393,7 +2394,7 @@ function useNotificationSettings_withClient(client) {
2393
2394
  };
2394
2395
  }, [poller]);
2395
2396
  const result = useSignal(store.outputs.notificationSettings.signal);
2396
- return useMemo2(() => {
2397
+ return useMemo3(() => {
2397
2398
  return [result, updateNotificationSettings];
2398
2399
  }, [result, updateNotificationSettings]);
2399
2400
  }
@@ -2404,7 +2405,7 @@ function useNotificationSettingsSuspense_withClient(client) {
2404
2405
  const [result, updateNotificationSettings] = useNotificationSettings_withClient(client);
2405
2406
  assert(!result.error, "Did not expect error");
2406
2407
  assert(!result.isLoading, "Did not expect loading");
2407
- return useMemo2(() => {
2408
+ return useMemo3(() => {
2408
2409
  return [result, updateNotificationSettings];
2409
2410
  }, [result, updateNotificationSettings]);
2410
2411
  }
@@ -2775,7 +2776,7 @@ function LiveblocksProvider(props) {
2775
2776
  o.enableDebugLogging
2776
2777
  )
2777
2778
  };
2778
- const client = useMemo2(() => createClient(options), []);
2779
+ const client = useMemo3(() => createClient(options), []);
2779
2780
  useEffect4(() => {
2780
2781
  return () => {
2781
2782
  client[kInternal3].ai.disconnect();
@@ -2954,7 +2955,7 @@ import {
2954
2955
  import {
2955
2956
  useCallback as useCallback3,
2956
2957
  useEffect as useEffect6,
2957
- useMemo as useMemo3,
2958
+ useMemo as useMemo4,
2958
2959
  useRef as useRef3,
2959
2960
  useState as useState3,
2960
2961
  useSyncExternalStore as useSyncExternalStore3,
@@ -2992,7 +2993,7 @@ function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
2992
2993
 
2993
2994
  // src/room.tsx
2994
2995
  import { jsx as jsx2 } from "react/jsx-runtime";
2995
- var noop3 = () => {
2996
+ var noop2 = () => {
2996
2997
  };
2997
2998
  var identity3 = (x) => x;
2998
2999
  var STABLE_EMPTY_LIST = Object.freeze([]);
@@ -3286,11 +3287,14 @@ function RoomProviderInner(props) {
3286
3287
  `React ${requiredVersion} or higher is required (you\u2019re on ${reactVersion})`
3287
3288
  );
3288
3289
  }
3289
- const frozenProps = useInitial({
3290
- initialPresence: props.initialPresence,
3291
- initialStorage: props.initialStorage,
3292
- autoConnect: props.autoConnect ?? typeof window !== "undefined"
3293
- });
3290
+ const frozenProps = useInitial(
3291
+ {
3292
+ initialPresence: props.initialPresence,
3293
+ initialStorage: props.initialStorage,
3294
+ autoConnect: props.autoConnect ?? typeof window !== "undefined"
3295
+ },
3296
+ roomId
3297
+ );
3294
3298
  const [{ room }, setRoomLeavePair] = useState3(
3295
3299
  () => stableEnterRoom(roomId, {
3296
3300
  ...frozenProps,
@@ -3599,7 +3603,7 @@ function useStorage(selector, isEqual) {
3599
3603
  [selector]
3600
3604
  );
3601
3605
  const subscribe = useCallback3(
3602
- (onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) : noop3,
3606
+ (onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) : noop2,
3603
3607
  [room, rootOrNull]
3604
3608
  );
3605
3609
  const getSnapshot = useCallback3(() => {
@@ -3622,7 +3626,7 @@ function useStorage(selector, isEqual) {
3622
3626
  }
3623
3627
  function useMutation(callback, deps) {
3624
3628
  const room = useRoom();
3625
- return useMemo3(
3629
+ return useMemo4(
3626
3630
  () => {
3627
3631
  return (...args) => (
3628
3632
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
@@ -4209,7 +4213,7 @@ function useThreadSubscription(threadId) {
4209
4213
  function useRoomThreadSubscription(roomId, threadId) {
4210
4214
  const client = useClient();
4211
4215
  const { store } = getRoomExtrasForClient(client);
4212
- const subscriptionKey = useMemo3(
4216
+ const subscriptionKey = useMemo4(
4213
4217
  () => getSubscriptionKey2("thread", threadId),
4214
4218
  [threadId]
4215
4219
  );
@@ -4271,7 +4275,7 @@ function useRoomSubscriptionSettings() {
4271
4275
  const settings = useSignal(
4272
4276
  store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).signal
4273
4277
  );
4274
- return useMemo3(() => {
4278
+ return useMemo4(() => {
4275
4279
  return [settings, updateRoomSubscriptionSettings];
4276
4280
  }, [settings, updateRoomSubscriptionSettings]);
4277
4281
  }
@@ -4286,7 +4290,7 @@ function useRoomSubscriptionSettingsSuspense() {
4286
4290
  const [settings, updateRoomSubscriptionSettings] = useRoomSubscriptionSettings();
4287
4291
  assert2(!settings.error, "Did not expect error");
4288
4292
  assert2(!settings.isLoading, "Did not expect loading");
4289
- return useMemo3(() => {
4293
+ return useMemo4(() => {
4290
4294
  return [settings, updateRoomSubscriptionSettings];
4291
4295
  }, [settings, updateRoomSubscriptionSettings]);
4292
4296
  }
@@ -4672,4 +4676,4 @@ export {
4672
4676
  _useStorageRoot,
4673
4677
  _useUpdateMyPresence
4674
4678
  };
4675
- //# sourceMappingURL=chunk-BZXNKY7M.js.map
4679
+ //# sourceMappingURL=chunk-TYQDESJE.js.map