@liveblocks/react 3.1.3 → 3.2.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.
@@ -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