@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.
package/dist/_private.cjs CHANGED
@@ -24,7 +24,8 @@
24
24
 
25
25
 
26
26
 
27
- var _chunkKDGCCWHHcjs = require('./chunk-KDGCCWHH.cjs');
27
+
28
+ var _chunkLJQILG65cjs = require('./chunk-LJQILG65.cjs');
28
29
 
29
30
  // src/lib/use-layout-effect.ts
30
31
  var _react = require('react');
@@ -42,8 +43,8 @@ function normalizeMentionSuggestions(suggestions) {
42
43
  function useMentionSuggestions(roomId, search) {
43
44
  const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
44
45
  const lastInvokedAt = _react.useRef.call(void 0, );
45
- const resolveMentionSuggestions = _chunkKDGCCWHHcjs.useResolveMentionSuggestions.call(void 0, );
46
- const mentionSuggestionsCache = _chunkKDGCCWHHcjs.useMentionSuggestionsCache.call(void 0, );
46
+ const resolveMentionSuggestions = _chunkLJQILG65cjs.useResolveMentionSuggestions.call(void 0, );
47
+ const mentionSuggestionsCache = _chunkLJQILG65cjs.useMentionSuggestionsCache.call(void 0, );
47
48
  _react.useEffect.call(void 0, () => {
48
49
  if (search === void 0 || !resolveMentionSuggestions) {
49
50
  return;
@@ -98,7 +99,7 @@ function useMentionSuggestions(roomId, search) {
98
99
 
99
100
 
100
101
  function useSyncSource() {
101
- const client = _chunkKDGCCWHHcjs.useClient.call(void 0, );
102
+ const client = _chunkLJQILG65cjs.useClient.call(void 0, );
102
103
  const createSyncSource = client[_core.kInternal].createSyncSource;
103
104
  const [syncSource, setSyncSource] = _react.useState.call(void 0, );
104
105
  _react.useEffect.call(void 0, () => {
@@ -136,5 +137,6 @@ function useSyncSource() {
136
137
 
137
138
 
138
139
 
139
- exports.getUmbrellaStoreForClient = _chunkKDGCCWHHcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkKDGCCWHHcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkKDGCCWHHcjs.useClientOrNull; exports.useCreateRoomComment = _chunkKDGCCWHHcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkKDGCCWHHcjs.useCreateRoomThread; exports.useCreateTextMention = _chunkKDGCCWHHcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkKDGCCWHHcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkKDGCCWHHcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkKDGCCWHHcjs.useDeleteTextMention; exports.useEditRoomComment = _chunkKDGCCWHHcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkKDGCCWHHcjs.useEditRoomThreadMetadata; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkKDGCCWHHcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkKDGCCWHHcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkKDGCCWHHcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkKDGCCWHHcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkKDGCCWHHcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkKDGCCWHHcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkKDGCCWHHcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkKDGCCWHHcjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunkKDGCCWHHcjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunkKDGCCWHHcjs.useRoomThreadSubscription; exports.useSignal = _chunkKDGCCWHHcjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunkKDGCCWHHcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkKDGCCWHHcjs.useYjsProvider;
140
+
141
+ exports.getUmbrellaStoreForClient = _chunkLJQILG65cjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkLJQILG65cjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkLJQILG65cjs.useClientOrNull; exports.useCreateRoomComment = _chunkLJQILG65cjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkLJQILG65cjs.useCreateRoomThread; exports.useCreateTextMention = _chunkLJQILG65cjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkLJQILG65cjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkLJQILG65cjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkLJQILG65cjs.useDeleteTextMention; exports.useEditRoomComment = _chunkLJQILG65cjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkLJQILG65cjs.useEditRoomThreadMetadata; exports.useLatest = _chunkLJQILG65cjs.useLatest; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkLJQILG65cjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkLJQILG65cjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkLJQILG65cjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkLJQILG65cjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkLJQILG65cjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkLJQILG65cjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkLJQILG65cjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkLJQILG65cjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunkLJQILG65cjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunkLJQILG65cjs.useRoomThreadSubscription; exports.useSignal = _chunkLJQILG65cjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunkLJQILG65cjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkLJQILG65cjs.useYjsProvider;
140
142
  //# sourceMappingURL=_private.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/_private.cjs","../src/lib/use-layout-effect.ts","../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"names":["useEffect","useState"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC1BA,8BAAsE;AAI/D,IAAM,gBAAA,EACX,OAAO,OAAA,IAAW,YAAA,EAAc,uBAAA,EAA0B,gBAAA;ADwB5D;AACA;AEhCA,wCAAkD;AAClD;AAOA,IAAM,6BAAA,EAA+B,GAAA;AASrC,SAAS,2BAAA,CACP,WAAA,EACe;AACf,EAAA,OAAO,WAAA,CAAY,GAAA;AAAA,IACjB,CAAC,UAAA,EAAA,GACC,OAAO,WAAA,IAAe,SAAA,EAClB,EAAE,IAAA,EAAM,MAAA,EAAiB,EAAA,EAAI,WAAW,EAAA,EACxC;AAAA,EACR,CAAA;AACF;AAQO,SAAS,qBAAA,CAAsB,MAAA,EAAgB,MAAA,EAAiB;AACrE,EAAA,MAAM,CAAC,kBAAA,EAAoB,qBAAqB,EAAA,EAAI,6BAAA,CAAwB;AAC5E,EAAA,MAAM,cAAA,EAAgB,2BAAA,CAAe;AAErC,EAAA,MAAM,0BAAA,EAA4B,4DAAA,CAA6B;AAC/D,EAAA,MAAM,wBAAA,EAA0B,0DAAA,CAA2B;AAE3D,EAAAA,8BAAAA,CAAU,EAAA,GAAM;AACd,IAAA,GAAA,CAAI,OAAA,IAAW,KAAA,EAAA,GAAa,CAAC,yBAAA,EAA2B;AACtD,MAAA,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,8BAAA,EAAgC,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAO,CAAA;AAC7D,IAAA,MA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A;AAAA,MAC7B,CAAA,EAAG,4BAA4B,CAAA;AAAA,IACjC;AAEA,IAAA,OAAO,CAAA,EAAA,GAAM;AACX,MAAA,WAAA,EAAa,IAAA;AACb,MAAA,MAAA,CAAO,YAAA,CAAa,eAAe,CAAA;AAAA,IACrC,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,MAAA,EAAQ,MAAA,EAAQ,yBAAA,EAA2B,uBAAuB,CAAC,CAAA;AAEvE,EAAA,OAAO,kBAAA;AACT;AFRA;AACA;AG/FA;AACA;AAOO,SAAS,aAAA,CAAA,EAAwC;AACtD,EAAA,MAAM,OAAA,EAAS,yCAAA,CAAU;AACzB,EAAA,MAAM,iBAAA,EAAmB,MAAA,CAAO,eAAS,CAAA,CAAE,gBAAA;AAC3C,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,EAAA,EAAIC,6BAAAA,CAAiC;AAErE,EAAAD,8BAAAA,CAAU,EAAA,GAAM;AAEd,IAAA,MAAM,cAAA,EAAgB,gBAAA,CAAiB,CAAA;AACvC,IAAA,aAAA,CAAc,aAAa,CAAA;AAC3B,IAAA,OAAO,CAAA,EAAA,GAAM,aAAA,CAAc,OAAA,CAAQ,CAAA;AAAA,EACrC,CAAA,EAAG,CAAC,gBAAgB,CAAC,CAAA;AAErB,EAAA,OAAO,UAAA;AACT;AHwFA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,w4DAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/_private.cjs","sourcesContent":[null,"/* eslint-disable no-restricted-syntax */\n\nimport { useEffect, useLayoutEffect as useOriginalLayoutEffect } from \"react\";\n\n// On React 18.2.0 and earlier, useLayoutEffect triggers a warning when\n// executed on the server, so this workaround should be used instead.\nexport const useLayoutEffect =\n typeof window !== \"undefined\" ? useOriginalLayoutEffect : useEffect;\n","import { type MentionData, stableStringify } from \"@liveblocks/core\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport {\n useMentionSuggestionsCache,\n useResolveMentionSuggestions,\n} from \"./room\";\n\nconst MENTION_SUGGESTIONS_DEBOUNCE = 500;\n\n/**\n * Normalize mention suggestions as `MentionData[]`.\n *\n * Mention suggestions were previously typed as `string[]`, a list of user IDs,\n * but to support multiple mention kinds (user, group, etc), they're now\n * typed as `MentionData[]`.\n */\nfunction normalizeMentionSuggestions<T extends string[] | MentionData[]>(\n suggestions: T\n): MentionData[] {\n return suggestions.map(\n (suggestion): MentionData =>\n typeof suggestion === \"string\"\n ? { kind: \"user\" as const, id: suggestion }\n : suggestion\n );\n}\n\n/**\n * @private For internal use only. Do not rely on this hook.\n *\n * Simplistic debounced search, we don't need to worry too much about deduping\n * and race conditions as there can only be one search at a time.\n */\nexport function useMentionSuggestions(roomId: string, search?: string) {\n const [mentionSuggestions, setMentionSuggestions] = useState<MentionData[]>();\n const lastInvokedAt = useRef<number>();\n\n const resolveMentionSuggestions = useResolveMentionSuggestions();\n const mentionSuggestionsCache = useMentionSuggestionsCache();\n\n useEffect(() => {\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId };\n const mentionSuggestionsCacheKey = stableStringify(\n resolveMentionSuggestionsArgs\n );\n let debounceTimeout: number | undefined;\n let isCanceled = false;\n\n const getMentionSuggestions = async () => {\n try {\n lastInvokedAt.current = performance.now();\n const rawMentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n const normalizedSuggestions = normalizeMentionSuggestions(\n rawMentionSuggestions\n );\n setMentionSuggestions(normalizedSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n normalizedSuggestions\n );\n }\n } catch (error) {\n console.error((error as Error)?.message);\n }\n };\n\n if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {\n // If there are already cached mention suggestions, use them immediately.\n const cachedSuggestions = mentionSuggestionsCache.get(\n mentionSuggestionsCacheKey\n );\n setMentionSuggestions(cachedSuggestions);\n } else if (\n !lastInvokedAt.current ||\n Math.abs(performance.now() - lastInvokedAt.current) >\n MENTION_SUGGESTIONS_DEBOUNCE\n ) {\n // If on the debounce's leading edge (either because it's the first invokation or enough\n // time has passed since the last debounce), get mention suggestions immediately.\n void getMentionSuggestions();\n } else {\n // Otherwise, wait for the debounce delay.\n debounceTimeout = window.setTimeout(() => {\n void getMentionSuggestions();\n }, MENTION_SUGGESTIONS_DEBOUNCE);\n }\n\n return () => {\n isCanceled = true;\n window.clearTimeout(debounceTimeout);\n };\n }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);\n\n return mentionSuggestions;\n}\n","import type { SyncSource } from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport { useEffect, useState } from \"react\";\n\nimport { useClient } from \"./contexts\";\n\n/**\n * @private For internal use only. Do not rely on this hook.\n */\nexport function useSyncSource(): SyncSource | undefined {\n const client = useClient();\n const createSyncSource = client[kInternal].createSyncSource;\n const [syncSource, setSyncSource] = useState<SyncSource | undefined>();\n\n useEffect(() => {\n // Create new sync source on mount\n const newSyncSource = createSyncSource();\n setSyncSource(newSyncSource);\n return () => newSyncSource.destroy();\n }, [createSyncSource]);\n\n return syncSource;\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/_private.cjs","../src/lib/use-layout-effect.ts","../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"names":["useEffect","useState"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC3BA,8BAAsE;AAI/D,IAAM,gBAAA,EACX,OAAO,OAAA,IAAW,YAAA,EAAc,uBAAA,EAA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,MAAA,CAAO,eAAS,CAAA,CAAE,gBAAA;AAC3C,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,EAAA,EAAIC,6BAAAA,CAAiC;AAErE,EAAAD,8BAAAA,CAAU,EAAA,GAAM;AAEd,IAAA,MAAM,cAAA,EAAgB,gBAAA,CAAiB,CAAA;AACvC,IAAA,aAAA,CAAc,aAAa,CAAA;AAC3B,IAAA,OAAO,CAAA,EAAA,GAAM,aAAA,CAAc,OAAA,CAAQ,CAAA;AAAA,EACrC,CAAA,EAAG,CAAC,gBAAgB,CAAC,CAAA;AAErB,EAAA,OAAO,UAAA;AACT;AHyFA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,y7DAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/_private.cjs","sourcesContent":[null,"/* eslint-disable no-restricted-syntax */\n\nimport { useEffect, useLayoutEffect as useOriginalLayoutEffect } from \"react\";\n\n// On React 18.2.0 and earlier, useLayoutEffect triggers a warning when\n// executed on the server, so this workaround should be used instead.\nexport const useLayoutEffect =\n typeof window !== \"undefined\" ? useOriginalLayoutEffect : useEffect;\n","import { type MentionData, stableStringify } from \"@liveblocks/core\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport {\n useMentionSuggestionsCache,\n useResolveMentionSuggestions,\n} from \"./room\";\n\nconst MENTION_SUGGESTIONS_DEBOUNCE = 500;\n\n/**\n * Normalize mention suggestions as `MentionData[]`.\n *\n * Mention suggestions were previously typed as `string[]`, a list of user IDs,\n * but to support multiple mention kinds (user, group, etc), they're now\n * typed as `MentionData[]`.\n */\nfunction normalizeMentionSuggestions<T extends string[] | MentionData[]>(\n suggestions: T\n): MentionData[] {\n return suggestions.map(\n (suggestion): MentionData =>\n typeof suggestion === \"string\"\n ? { kind: \"user\" as const, id: suggestion }\n : suggestion\n );\n}\n\n/**\n * @private For internal use only. Do not rely on this hook.\n *\n * Simplistic debounced search, we don't need to worry too much about deduping\n * and race conditions as there can only be one search at a time.\n */\nexport function useMentionSuggestions(roomId: string, search?: string) {\n const [mentionSuggestions, setMentionSuggestions] = useState<MentionData[]>();\n const lastInvokedAt = useRef<number>();\n\n const resolveMentionSuggestions = useResolveMentionSuggestions();\n const mentionSuggestionsCache = useMentionSuggestionsCache();\n\n useEffect(() => {\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId };\n const mentionSuggestionsCacheKey = stableStringify(\n resolveMentionSuggestionsArgs\n );\n let debounceTimeout: number | undefined;\n let isCanceled = false;\n\n const getMentionSuggestions = async () => {\n try {\n lastInvokedAt.current = performance.now();\n const rawMentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n const normalizedSuggestions = normalizeMentionSuggestions(\n rawMentionSuggestions\n );\n setMentionSuggestions(normalizedSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n normalizedSuggestions\n );\n }\n } catch (error) {\n console.error((error as Error)?.message);\n }\n };\n\n if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {\n // If there are already cached mention suggestions, use them immediately.\n const cachedSuggestions = mentionSuggestionsCache.get(\n mentionSuggestionsCacheKey\n );\n setMentionSuggestions(cachedSuggestions);\n } else if (\n !lastInvokedAt.current ||\n Math.abs(performance.now() - lastInvokedAt.current) >\n MENTION_SUGGESTIONS_DEBOUNCE\n ) {\n // If on the debounce's leading edge (either because it's the first invokation or enough\n // time has passed since the last debounce), get mention suggestions immediately.\n void getMentionSuggestions();\n } else {\n // Otherwise, wait for the debounce delay.\n debounceTimeout = window.setTimeout(() => {\n void getMentionSuggestions();\n }, MENTION_SUGGESTIONS_DEBOUNCE);\n }\n\n return () => {\n isCanceled = true;\n window.clearTimeout(debounceTimeout);\n };\n }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);\n\n return mentionSuggestions;\n}\n","import type { SyncSource } from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport { useEffect, useState } from \"react\";\n\nimport { useClient } from \"./contexts\";\n\n/**\n * @private For internal use only. Do not rely on this hook.\n */\nexport function useSyncSource(): SyncSource | undefined {\n const client = useClient();\n const createSyncSource = client[kInternal].createSyncSource;\n const [syncSource, setSyncSource] = useState<SyncSource | undefined>();\n\n useEffect(() => {\n // Create new sync source on mount\n const newSyncSource = createSyncSource();\n setSyncSource(newSyncSource);\n return () => newSyncSource.destroy();\n }, [createSyncSource]);\n\n return syncSource;\n}\n"]}
@@ -1,10 +1,20 @@
1
1
  export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-DRYXmQT5.cjs';
2
- import { useLayoutEffect as useLayoutEffect$1 } from 'react';
2
+ import { MutableRefObject, useEffect } from 'react';
3
3
  import { ISignal, SyncSource } from '@liveblocks/core';
4
4
  import '@liveblocks/client';
5
5
  import 'react/jsx-runtime';
6
6
 
7
- declare const useLayoutEffect: typeof useLayoutEffect$1;
7
+ /**
8
+ * Keeps a ref in sync with a given value that may or may not change on
9
+ * every render.
10
+ *
11
+ * The purpose of this hook is to return a stable ref that can be passed
12
+ * to a callback function so the callback can be registered but still can
13
+ * access the latest value at a later point in time.
14
+ */
15
+ declare function useLatest<T>(value: T): MutableRefObject<T>;
16
+
17
+ declare const useLayoutEffect: typeof useEffect;
8
18
 
9
19
  /**
10
20
  * @private For internal use only. Do not rely on this hook.
@@ -27,4 +37,4 @@ declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe
27
37
  */
28
38
  declare function useSyncSource(): SyncSource | undefined;
29
39
 
30
- export { useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
40
+ export { useLatest, useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
@@ -1,10 +1,20 @@
1
1
  export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-DRYXmQT5.js';
2
- import { useLayoutEffect as useLayoutEffect$1 } from 'react';
2
+ import { MutableRefObject, useEffect } from 'react';
3
3
  import { ISignal, SyncSource } from '@liveblocks/core';
4
4
  import '@liveblocks/client';
5
5
  import 'react/jsx-runtime';
6
6
 
7
- declare const useLayoutEffect: typeof useLayoutEffect$1;
7
+ /**
8
+ * Keeps a ref in sync with a given value that may or may not change on
9
+ * every render.
10
+ *
11
+ * The purpose of this hook is to return a stable ref that can be passed
12
+ * to a callback function so the callback can be registered but still can
13
+ * access the latest value at a later point in time.
14
+ */
15
+ declare function useLatest<T>(value: T): MutableRefObject<T>;
16
+
17
+ declare const useLayoutEffect: typeof useEffect;
8
18
 
9
19
  /**
10
20
  * @private For internal use only. Do not rely on this hook.
@@ -27,4 +37,4 @@ declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe
27
37
  */
28
38
  declare function useSyncSource(): SyncSource | undefined;
29
39
 
30
- export { useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
40
+ export { useLatest, useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
package/dist/_private.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  useDeleteTextMention,
12
12
  useEditRoomComment,
13
13
  useEditRoomThreadMetadata,
14
+ useLatest,
14
15
  useMarkRoomThreadAsRead,
15
16
  useMarkRoomThreadAsResolved,
16
17
  useMarkRoomThreadAsUnresolved,
@@ -24,7 +25,7 @@ import {
24
25
  useSignal,
25
26
  useSyncExternalStoreWithSelector,
26
27
  useYjsProvider
27
- } from "./chunk-MXMOBMOL.js";
28
+ } from "./chunk-YZRXMG3Z.js";
28
29
 
29
30
  // src/lib/use-layout-effect.ts
30
31
  import { useEffect, useLayoutEffect as useOriginalLayoutEffect } from "react";
@@ -120,6 +121,7 @@ export {
120
121
  useDeleteTextMention,
121
122
  useEditRoomComment,
122
123
  useEditRoomThreadMetadata,
124
+ useLatest,
123
125
  useLayoutEffect,
124
126
  useMarkRoomThreadAsRead,
125
127
  useMarkRoomThreadAsResolved,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/use-layout-effect.ts","../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax */\n\nimport { useEffect, useLayoutEffect as useOriginalLayoutEffect } from \"react\";\n\n// On React 18.2.0 and earlier, useLayoutEffect triggers a warning when\n// executed on the server, so this workaround should be used instead.\nexport const useLayoutEffect =\n typeof window !== \"undefined\" ? useOriginalLayoutEffect : useEffect;\n","import { type MentionData, stableStringify } from \"@liveblocks/core\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport {\n useMentionSuggestionsCache,\n useResolveMentionSuggestions,\n} from \"./room\";\n\nconst MENTION_SUGGESTIONS_DEBOUNCE = 500;\n\n/**\n * Normalize mention suggestions as `MentionData[]`.\n *\n * Mention suggestions were previously typed as `string[]`, a list of user IDs,\n * but to support multiple mention kinds (user, group, etc), they're now\n * typed as `MentionData[]`.\n */\nfunction normalizeMentionSuggestions<T extends string[] | MentionData[]>(\n suggestions: T\n): MentionData[] {\n return suggestions.map(\n (suggestion): MentionData =>\n typeof suggestion === \"string\"\n ? { kind: \"user\" as const, id: suggestion }\n : suggestion\n );\n}\n\n/**\n * @private For internal use only. Do not rely on this hook.\n *\n * Simplistic debounced search, we don't need to worry too much about deduping\n * and race conditions as there can only be one search at a time.\n */\nexport function useMentionSuggestions(roomId: string, search?: string) {\n const [mentionSuggestions, setMentionSuggestions] = useState<MentionData[]>();\n const lastInvokedAt = useRef<number>();\n\n const resolveMentionSuggestions = useResolveMentionSuggestions();\n const mentionSuggestionsCache = useMentionSuggestionsCache();\n\n useEffect(() => {\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId };\n const mentionSuggestionsCacheKey = stableStringify(\n resolveMentionSuggestionsArgs\n );\n let debounceTimeout: number | undefined;\n let isCanceled = false;\n\n const getMentionSuggestions = async () => {\n try {\n lastInvokedAt.current = performance.now();\n const rawMentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n const normalizedSuggestions = normalizeMentionSuggestions(\n rawMentionSuggestions\n );\n setMentionSuggestions(normalizedSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n normalizedSuggestions\n );\n }\n } catch (error) {\n console.error((error as Error)?.message);\n }\n };\n\n if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {\n // If there are already cached mention suggestions, use them immediately.\n const cachedSuggestions = mentionSuggestionsCache.get(\n mentionSuggestionsCacheKey\n );\n setMentionSuggestions(cachedSuggestions);\n } else if (\n !lastInvokedAt.current ||\n Math.abs(performance.now() - lastInvokedAt.current) >\n MENTION_SUGGESTIONS_DEBOUNCE\n ) {\n // If on the debounce's leading edge (either because it's the first invokation or enough\n // time has passed since the last debounce), get mention suggestions immediately.\n void getMentionSuggestions();\n } else {\n // Otherwise, wait for the debounce delay.\n debounceTimeout = window.setTimeout(() => {\n void getMentionSuggestions();\n }, MENTION_SUGGESTIONS_DEBOUNCE);\n }\n\n return () => {\n isCanceled = true;\n window.clearTimeout(debounceTimeout);\n };\n }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);\n\n return mentionSuggestions;\n}\n","import type { SyncSource } from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport { useEffect, useState } from \"react\";\n\nimport { useClient } from \"./contexts\";\n\n/**\n * @private For internal use only. Do not rely on this hook.\n */\nexport function useSyncSource(): SyncSource | undefined {\n const client = useClient();\n const createSyncSource = client[kInternal].createSyncSource;\n const [syncSource, setSyncSource] = useState<SyncSource | undefined>();\n\n useEffect(() => {\n // Create new sync source on mount\n const newSyncSource = createSyncSource();\n setSyncSource(newSyncSource);\n return () => newSyncSource.destroy();\n }, [createSyncSource]);\n\n return syncSource;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,WAAW,mBAAmB,+BAA+B;AAI/D,IAAM,kBACX,OAAO,WAAW,cAAc,0BAA0B;;;ACP5D,SAA2B,uBAAuB;AAClD,SAAS,aAAAA,YAAW,QAAQ,gBAAgB;AAO5C,IAAM,+BAA+B;AASrC,SAAS,4BACP,aACe;AACf,SAAO,YAAY;AAAA,IACjB,CAAC,eACC,OAAO,eAAe,WAClB,EAAE,MAAM,QAAiB,IAAI,WAAW,IACxC;AAAA,EACR;AACF;AAQO,SAAS,sBAAsB,QAAgB,QAAiB;AACrE,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAwB;AAC5E,QAAM,gBAAgB,OAAe;AAErC,QAAM,4BAA4B,6BAA6B;AAC/D,QAAM,0BAA0B,2BAA2B;AAE3D,EAAAC,WAAU,MAAM;AACd,QAAI,WAAW,UAAa,CA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BAAc,aAAa;AAC3B,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO;AACT;","names":["useEffect","useEffect","useEffect","useState","useState","useEffect"]}
1
+ {"version":3,"sources":["../src/lib/use-layout-effect.ts","../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax */\n\nimport { useEffect, useLayoutEffect as useOriginalLayoutEffect } from \"react\";\n\n// On React 18.2.0 and earlier, useLayoutEffect triggers a warning when\n// executed on the server, so this workaround should be used instead.\nexport const useLayoutEffect =\n typeof window !== \"undefined\" ? useOriginalLayoutEffect : useEffect;\n","import { type MentionData, stableStringify } from \"@liveblocks/core\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport {\n useMentionSuggestionsCache,\n useResolveMentionSuggestions,\n} from \"./room\";\n\nconst MENTION_SUGGESTIONS_DEBOUNCE = 500;\n\n/**\n * Normalize mention suggestions as `MentionData[]`.\n *\n * Mention suggestions were previously typed as `string[]`, a list of user IDs,\n * but to support multiple mention kinds (user, group, etc), they're now\n * typed as `MentionData[]`.\n */\nfunction normalizeMentionSuggestions<T extends string[] | MentionData[]>(\n suggestions: T\n): MentionData[] {\n return suggestions.map(\n (suggestion): MentionData =>\n typeof suggestion === \"string\"\n ? { kind: \"user\" as const, id: suggestion }\n : suggestion\n );\n}\n\n/**\n * @private For internal use only. Do not rely on this hook.\n *\n * Simplistic debounced search, we don't need to worry too much about deduping\n * and race conditions as there can only be one search at a time.\n */\nexport function useMentionSuggestions(roomId: string, search?: string) {\n const [mentionSuggestions, setMentionSuggestions] = useState<MentionData[]>();\n const lastInvokedAt = useRef<number>();\n\n const resolveMentionSuggestions = useResolveMentionSuggestions();\n const mentionSuggestionsCache = useMentionSuggestionsCache();\n\n useEffect(() => {\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId };\n const mentionSuggestionsCacheKey = stableStringify(\n resolveMentionSuggestionsArgs\n );\n let debounceTimeout: number | undefined;\n let isCanceled = false;\n\n const getMentionSuggestions = async () => {\n try {\n lastInvokedAt.current = performance.now();\n const rawMentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n const normalizedSuggestions = normalizeMentionSuggestions(\n rawMentionSuggestions\n );\n setMentionSuggestions(normalizedSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n normalizedSuggestions\n );\n }\n } catch (error) {\n console.error((error as Error)?.message);\n }\n };\n\n if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {\n // If there are already cached mention suggestions, use them immediately.\n const cachedSuggestions = mentionSuggestionsCache.get(\n mentionSuggestionsCacheKey\n );\n setMentionSuggestions(cachedSuggestions);\n } else if (\n !lastInvokedAt.current ||\n Math.abs(performance.now() - lastInvokedAt.current) >\n MENTION_SUGGESTIONS_DEBOUNCE\n ) {\n // If on the debounce's leading edge (either because it's the first invokation or enough\n // time has passed since the last debounce), get mention suggestions immediately.\n void getMentionSuggestions();\n } else {\n // Otherwise, wait for the debounce delay.\n debounceTimeout = window.setTimeout(() => {\n void getMentionSuggestions();\n }, MENTION_SUGGESTIONS_DEBOUNCE);\n }\n\n return () => {\n isCanceled = true;\n window.clearTimeout(debounceTimeout);\n };\n }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);\n\n return mentionSuggestions;\n}\n","import type { SyncSource } from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport { useEffect, useState } from \"react\";\n\nimport { useClient } from \"./contexts\";\n\n/**\n * @private For internal use only. Do not rely on this hook.\n */\nexport function useSyncSource(): SyncSource | undefined {\n const client = useClient();\n const createSyncSource = client[kInternal].createSyncSource;\n const [syncSource, setSyncSource] = useState<SyncSource | undefined>();\n\n useEffect(() => {\n // Create new sync source on mount\n const newSyncSource = createSyncSource();\n setSyncSource(newSyncSource);\n return () => newSyncSource.destroy();\n }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cAAc,WACf,KAAK,IAAI,YAAY,IAAI,IAAI,cAAc,OAAO,IAChD,8BACF;AAGA,WAAK,sBAAsB;AAAA,IAC7B,OAAO;AAEL,wBAAkB,OAAO,WAAW,MAAM;AACxC,aAAK,sBAAsB;AAAA,MAC7B,GAAG,4BAA4B;AAAA,IACjC;AAEA,WAAO,MAAM;AACX,mBAAa;AACb,aAAO,aAAa,eAAe;AAAA,IACrC;AAAA,EACF,GAAG,CAAC,QAAQ,QAAQ,2BAA2B,uBAAuB,CAAC;AAEvE,SAAO;AACT;;;ACtGA,SAAS,iBAAiB;AAC1B,SAAS,aAAAC,YAAW,YAAAC,iBAAgB;AAO7B,SAAS,gBAAwC;AACtD,QAAM,SAAS,UAAU;AACzB,QAAM,mBAAmB,OAAO,SAAS,EAAE;AAC3C,QAAM,CAAC,YAAY,aAAa,IAAIC,UAAiC;AAErE,EAAAC,WAAU,MAAM;AAEd,UAAM,gBAAgB,iBAAiB;AACvC,kBAAc,aAAa;AAC3B,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO;AACT;","names":["useEffect","useEffect","useEffect","useState","useState","useEffect"]}
@@ -1,6 +1,6 @@
1
1
  // 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 = "esm";
5
5
 
6
6
  // src/ClientSideSuspense.tsx
@@ -20,4 +20,4 @@ export {
20
20
  PKG_FORMAT,
21
21
  ClientSideSuspense
22
22
  };
23
- //# sourceMappingURL=chunk-OAAIGG7E.js.map
23
+ //# sourceMappingURL=chunk-G4GBR6VV.js.map
@@ -17,6 +17,16 @@ function useIsInsideRoom() {
17
17
  return room !== null;
18
18
  }
19
19
 
20
+ // src/lib/use-latest.ts
21
+
22
+ function useLatest(value) {
23
+ const ref = _react.useRef.call(void 0, value);
24
+ _react.useEffect.call(void 0, () => {
25
+ ref.current = value;
26
+ }, [value]);
27
+ return ref;
28
+ }
29
+
20
30
  // src/ai.tsx
21
31
 
22
32
 
@@ -231,18 +241,6 @@ function ensureNotServerSide() {
231
241
 
232
242
  // src/lib/use-initial.ts
233
243
 
234
-
235
- // src/lib/use-latest.ts
236
-
237
- function useLatest(value) {
238
- const ref = _react.useRef.call(void 0, value);
239
- _react.useEffect.call(void 0, () => {
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 _react.useReducer.call(void 0, noop, value)[0];
@@ -4639,5 +4637,6 @@ var _useUpdateMyPresence = useUpdateMyPresence;
4639
4637
 
4640
4638
 
4641
4639
 
4642
- exports.ClientContext = ClientContext; exports.useClientOrNull = useClientOrNull; exports.useClient = useClient; exports.RoomContext = RoomContext; exports.RegisterAiKnowledge = RegisterAiKnowledge; exports.RegisterAiTool = RegisterAiTool; exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; exports.useSignal = useSignal; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useCreateAiChat = useCreateAiChat; exports.useDeleteAiChat = useDeleteAiChat; exports.useSendAiMessage = useSendAiMessage; exports.LiveblocksProvider = LiveblocksProvider; exports.createLiveblocksContext = createLiveblocksContext; exports.useInboxNotifications = useInboxNotifications; exports.useInboxNotificationsSuspense = useInboxNotificationsSuspense; exports.useMarkAllInboxNotificationsAsRead = useMarkAllInboxNotificationsAsRead; exports.useMarkInboxNotificationAsRead = useMarkInboxNotificationAsRead; exports.useDeleteAllInboxNotifications = useDeleteAllInboxNotifications; exports.useDeleteInboxNotification = useDeleteInboxNotification; exports.useUnreadInboxNotificationsCount = useUnreadInboxNotificationsCount; exports.useUnreadInboxNotificationsCountSuspense = useUnreadInboxNotificationsCountSuspense; exports.useNotificationSettings = useNotificationSettings; exports.useNotificationSettingsSuspense = useNotificationSettingsSuspense; exports.useUpdateNotificationSettings = useUpdateNotificationSettings; exports.useRoomInfo = useRoomInfo; exports.useRoomInfoSuspense = useRoomInfoSuspense; exports._useInboxNotificationThread = _useInboxNotificationThread; exports._useUser = _useUser; exports._useUserSuspense = _useUserSuspense; exports._useUserThreads_experimental = _useUserThreads_experimental; exports._useUserThreadsSuspense_experimental = _useUserThreadsSuspense_experimental; exports._useAiChats = _useAiChats; exports._useAiChatsSuspense = _useAiChatsSuspense; exports._useAiChat = _useAiChat; exports._useAiChatSuspense = _useAiChatSuspense; exports._useAiChatMessages = _useAiChatMessages; exports._useAiChatMessagesSuspense = _useAiChatMessagesSuspense; exports.useSyncStatus = useSyncStatus; exports.useErrorListener = useErrorListener; exports.useStatus = useStatus; exports.useReportTextEditor = useReportTextEditor; exports.useYjsProvider = useYjsProvider; exports.useCreateTextMention = useCreateTextMention; exports.useDeleteTextMention = useDeleteTextMention; exports.useResolveMentionSuggestions = useResolveMentionSuggestions; exports.useMentionSuggestionsCache = useMentionSuggestionsCache; exports.useLostConnectionListener = useLostConnectionListener; exports.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; exports.useCreateRoomThread = useCreateRoomThread; exports.useDeleteRoomThread = useDeleteRoomThread; exports.useEditRoomThreadMetadata = useEditRoomThreadMetadata; exports.useCreateComment = useCreateComment; exports.useCreateRoomComment = useCreateRoomComment; exports.useEditComment = useEditComment; exports.useEditRoomComment = useEditRoomComment; exports.useDeleteComment = useDeleteComment; exports.useDeleteRoomComment = useDeleteRoomComment; exports.useAddRoomCommentReaction = useAddRoomCommentReaction; exports.useRemoveReaction = useRemoveReaction; exports.useRemoveRoomCommentReaction = useRemoveRoomCommentReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkRoomThreadAsRead = useMarkRoomThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkRoomThreadAsResolved = useMarkRoomThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useMarkRoomThreadAsUnresolved = useMarkRoomThreadAsUnresolved; exports.useSubscribeToThread = useSubscribeToThread; exports.useUnsubscribeFromThread = useUnsubscribeFromThread; exports.useThreadSubscription = useThreadSubscription; exports.useRoomThreadSubscription = useRoomThreadSubscription; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomSubscriptionSettings = useUpdateRoomSubscriptionSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useAttachmentUrl = useAttachmentUrl; exports.useRoomAttachmentUrl = useRoomAttachmentUrl; exports.useAttachmentUrlSuspense = useAttachmentUrlSuspense; exports.useRoomPermissions = useRoomPermissions; exports.createRoomContext = createRoomContext; exports._RoomProvider = _RoomProvider; exports._useBroadcastEvent = _useBroadcastEvent; exports._useOthersListener = _useOthersListener; exports._useRoom = _useRoom; exports._useIsInsideRoom = _useIsInsideRoom; exports._useAddReaction = _useAddReaction; exports._useMutation = _useMutation; exports._useCreateThread = _useCreateThread; exports._useDeleteThread = _useDeleteThread; exports._useEditThreadMetadata = _useEditThreadMetadata; exports._useEventListener = _useEventListener; exports._useMyPresence = _useMyPresence; exports._useOthersMapped = _useOthersMapped; exports._useOthersMappedSuspense = _useOthersMappedSuspense; exports._useThreads = _useThreads; exports._useThreadsSuspense = _useThreadsSuspense; exports._useRoomSubscriptionSettings = _useRoomSubscriptionSettings; exports._useRoomSubscriptionSettingsSuspense = _useRoomSubscriptionSettingsSuspense; exports._useHistoryVersions = _useHistoryVersions; exports._useHistoryVersionsSuspense = _useHistoryVersionsSuspense; exports._useOther = _useOther; exports._useOthers = _useOthers; exports._useOtherSuspense = _useOtherSuspense; exports._useOthersSuspense = _useOthersSuspense; exports._useStorage = _useStorage; exports._useStorageSuspense = _useStorageSuspense; exports._useSelf = _useSelf; exports._useSelfSuspense = _useSelfSuspense; exports._useStorageRoot = _useStorageRoot; exports._useUpdateMyPresence = _useUpdateMyPresence;
4643
- //# sourceMappingURL=chunk-KDGCCWHH.cjs.map
4640
+
4641
+ exports.ClientContext = ClientContext; exports.useClientOrNull = useClientOrNull; exports.useClient = useClient; exports.RoomContext = RoomContext; exports.useLatest = useLatest; exports.RegisterAiKnowledge = RegisterAiKnowledge; exports.RegisterAiTool = RegisterAiTool; exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; exports.useSignal = useSignal; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useCreateAiChat = useCreateAiChat; exports.useDeleteAiChat = useDeleteAiChat; exports.useSendAiMessage = useSendAiMessage; exports.LiveblocksProvider = LiveblocksProvider; exports.createLiveblocksContext = createLiveblocksContext; exports.useInboxNotifications = useInboxNotifications; exports.useInboxNotificationsSuspense = useInboxNotificationsSuspense; exports.useMarkAllInboxNotificationsAsRead = useMarkAllInboxNotificationsAsRead; exports.useMarkInboxNotificationAsRead = useMarkInboxNotificationAsRead; exports.useDeleteAllInboxNotifications = useDeleteAllInboxNotifications; exports.useDeleteInboxNotification = useDeleteInboxNotification; exports.useUnreadInboxNotificationsCount = useUnreadInboxNotificationsCount; exports.useUnreadInboxNotificationsCountSuspense = useUnreadInboxNotificationsCountSuspense; exports.useNotificationSettings = useNotificationSettings; exports.useNotificationSettingsSuspense = useNotificationSettingsSuspense; exports.useUpdateNotificationSettings = useUpdateNotificationSettings; exports.useRoomInfo = useRoomInfo; exports.useRoomInfoSuspense = useRoomInfoSuspense; exports._useInboxNotificationThread = _useInboxNotificationThread; exports._useUser = _useUser; exports._useUserSuspense = _useUserSuspense; exports._useUserThreads_experimental = _useUserThreads_experimental; exports._useUserThreadsSuspense_experimental = _useUserThreadsSuspense_experimental; exports._useAiChats = _useAiChats; exports._useAiChatsSuspense = _useAiChatsSuspense; exports._useAiChat = _useAiChat; exports._useAiChatSuspense = _useAiChatSuspense; exports._useAiChatMessages = _useAiChatMessages; exports._useAiChatMessagesSuspense = _useAiChatMessagesSuspense; exports.useSyncStatus = useSyncStatus; exports.useErrorListener = useErrorListener; exports.useStatus = useStatus; exports.useReportTextEditor = useReportTextEditor; exports.useYjsProvider = useYjsProvider; exports.useCreateTextMention = useCreateTextMention; exports.useDeleteTextMention = useDeleteTextMention; exports.useResolveMentionSuggestions = useResolveMentionSuggestions; exports.useMentionSuggestionsCache = useMentionSuggestionsCache; exports.useLostConnectionListener = useLostConnectionListener; exports.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; exports.useCreateRoomThread = useCreateRoomThread; exports.useDeleteRoomThread = useDeleteRoomThread; exports.useEditRoomThreadMetadata = useEditRoomThreadMetadata; exports.useCreateComment = useCreateComment; exports.useCreateRoomComment = useCreateRoomComment; exports.useEditComment = useEditComment; exports.useEditRoomComment = useEditRoomComment; exports.useDeleteComment = useDeleteComment; exports.useDeleteRoomComment = useDeleteRoomComment; exports.useAddRoomCommentReaction = useAddRoomCommentReaction; exports.useRemoveReaction = useRemoveReaction; exports.useRemoveRoomCommentReaction = useRemoveRoomCommentReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkRoomThreadAsRead = useMarkRoomThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkRoomThreadAsResolved = useMarkRoomThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useMarkRoomThreadAsUnresolved = useMarkRoomThreadAsUnresolved; exports.useSubscribeToThread = useSubscribeToThread; exports.useUnsubscribeFromThread = useUnsubscribeFromThread; exports.useThreadSubscription = useThreadSubscription; exports.useRoomThreadSubscription = useRoomThreadSubscription; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomSubscriptionSettings = useUpdateRoomSubscriptionSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useAttachmentUrl = useAttachmentUrl; exports.useRoomAttachmentUrl = useRoomAttachmentUrl; exports.useAttachmentUrlSuspense = useAttachmentUrlSuspense; exports.useRoomPermissions = useRoomPermissions; exports.createRoomContext = createRoomContext; exports._RoomProvider = _RoomProvider; exports._useBroadcastEvent = _useBroadcastEvent; exports._useOthersListener = _useOthersListener; exports._useRoom = _useRoom; exports._useIsInsideRoom = _useIsInsideRoom; exports._useAddReaction = _useAddReaction; exports._useMutation = _useMutation; exports._useCreateThread = _useCreateThread; exports._useDeleteThread = _useDeleteThread; exports._useEditThreadMetadata = _useEditThreadMetadata; exports._useEventListener = _useEventListener; exports._useMyPresence = _useMyPresence; exports._useOthersMapped = _useOthersMapped; exports._useOthersMappedSuspense = _useOthersMappedSuspense; exports._useThreads = _useThreads; exports._useThreadsSuspense = _useThreadsSuspense; exports._useRoomSubscriptionSettings = _useRoomSubscriptionSettings; exports._useRoomSubscriptionSettingsSuspense = _useRoomSubscriptionSettingsSuspense; exports._useHistoryVersions = _useHistoryVersions; exports._useHistoryVersionsSuspense = _useHistoryVersionsSuspense; exports._useOther = _useOther; exports._useOthers = _useOthers; exports._useOtherSuspense = _useOtherSuspense; exports._useOthersSuspense = _useOthersSuspense; exports._useStorage = _useStorage; exports._useStorageSuspense = _useStorageSuspense; exports._useSelf = _useSelf; exports._useSelfSuspense = _useSelfSuspense; exports._useStorageRoot = _useStorageRoot; exports._useUpdateMyPresence = _useUpdateMyPresence;
4642
+ //# sourceMappingURL=chunk-LJQILG65.cjs.map