@liveblocks/react 3.1.4 → 3.2.1

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.1.4";
3
+ var PKG_VERSION = "3.2.1";
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-RA4OFBFY.cjs.map
23
+ //# sourceMappingURL=chunk-VARKVHO4.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-RA4OFBFY.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-RA4OFBFY.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-VARKVHO4.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-VARKVHO4.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"]}
@@ -17,9 +17,19 @@ function useIsInsideRoom() {
17
17
  return room !== null;
18
18
  }
19
19
 
20
+ // src/lib/use-latest.ts
21
+ import { useEffect, useRef } from "react";
22
+ function useLatest(value) {
23
+ const ref = useRef(value);
24
+ useEffect(() => {
25
+ ref.current = value;
26
+ }, [value]);
27
+ return ref;
28
+ }
29
+
20
30
  // src/ai.tsx
21
31
  import { kInternal, nanoid } from "@liveblocks/core";
22
- import { memo, useEffect, useId, useState } from "react";
32
+ import { memo, useEffect as useEffect2, useId, useState } from "react";
23
33
  function useAi() {
24
34
  return useClient()[kInternal].ai;
25
35
  }
@@ -31,7 +41,7 @@ var RegisterAiKnowledge = memo(function RegisterAiKnowledge2(props) {
31
41
  const ai = useAi();
32
42
  const { description, value } = props;
33
43
  const [layerKey, setLayerKey] = useState();
34
- useEffect(() => {
44
+ useEffect2(() => {
35
45
  const layerKey2 = ai.registerKnowledgeLayer(layerId);
36
46
  setLayerKey(layerKey2);
37
47
  return () => {
@@ -41,7 +51,7 @@ var RegisterAiKnowledge = memo(function RegisterAiKnowledge2(props) {
41
51
  }, [ai, layerId]);
42
52
  const randomKey = useRandom();
43
53
  const knowledgeKey = props.id ?? randomKey;
44
- useEffect(() => {
54
+ useEffect2(() => {
45
55
  if (layerKey !== void 0) {
46
56
  ai.updateKnowledge(layerKey, { description, value }, knowledgeKey);
47
57
  }
@@ -56,7 +66,7 @@ var RegisterAiTool = memo(function RegisterAiTool2({
56
66
  }) {
57
67
  const client = useClient();
58
68
  const ai = client[kInternal].ai;
59
- useEffect(() => {
69
+ useEffect2(() => {
60
70
  const toolWithEnabled = enabled !== void 0 ? { ...tool, enabled } : tool;
61
71
  return ai.registerTool(name, toolWithEnabled, chatId);
62
72
  }, [ai, chatId, name, tool, enabled]);
@@ -66,16 +76,16 @@ var RegisterAiTool = memo(function RegisterAiTool2({
66
76
  // src/use-sync-external-store-with-selector.ts
67
77
  import {
68
78
  useDebugValue,
69
- useEffect as useEffect2,
79
+ useEffect as useEffect3,
70
80
  useMemo,
71
- useRef,
81
+ useRef as useRef2,
72
82
  useSyncExternalStore
73
83
  } from "react";
74
84
  function is(x, y) {
75
85
  return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
76
86
  }
77
87
  function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
78
- const instRef = useRef(null);
88
+ const instRef = useRef2(null);
79
89
  let inst;
80
90
  if (instRef.current === null) {
81
91
  inst = {
@@ -131,7 +141,7 @@ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnaps
131
141
  getSelection,
132
142
  getServerSelection
133
143
  );
134
- useEffect2(() => {
144
+ useEffect3(() => {
135
145
  inst.hasValue = true;
136
146
  inst.value = value;
137
147
  }, [value]);
@@ -231,18 +241,6 @@ function ensureNotServerSide() {
231
241
 
232
242
  // src/lib/use-initial.ts
233
243
  import { useCallback, useReducer } from "react";
234
-
235
- // src/lib/use-latest.ts
236
- import { useEffect as useEffect3, useRef as useRef2 } from "react";
237
- function useLatest(value) {
238
- const ref = useRef2(value);
239
- useEffect3(() => {
240
- ref.current = value;
241
- }, [value]);
242
- return ref;
243
- }
244
-
245
- // src/lib/use-initial.ts
246
244
  var noop = (state) => state;
247
245
  function useInitial(value) {
248
246
  return useReducer(noop, value)[0];
@@ -4529,6 +4527,7 @@ export {
4529
4527
  useClientOrNull,
4530
4528
  useClient,
4531
4529
  RoomContext,
4530
+ useLatest,
4532
4531
  RegisterAiKnowledge,
4533
4532
  RegisterAiTool,
4534
4533
  useSyncExternalStoreWithSelector,
@@ -4640,4 +4639,4 @@ export {
4640
4639
  _useStorageRoot,
4641
4640
  _useUpdateMyPresence
4642
4641
  };
4643
- //# sourceMappingURL=chunk-MXMOBMOL.js.map
4642
+ //# sourceMappingURL=chunk-YZRXMG3Z.js.map