@liveblocks/react 3.16.0-feeds1 → 3.16.0-flow2

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
@@ -25,7 +25,10 @@
25
25
 
26
26
 
27
27
 
28
- var _chunk6VGVFTSYcjs = require('./chunk-6VGVFTSY.cjs');
28
+
29
+
30
+
31
+ var _chunkQEGVIJNNcjs = require('./chunk-QEGVIJNN.cjs');
29
32
 
30
33
  // src/lib/use-layout-effect.ts
31
34
  var _react = require('react');
@@ -50,7 +53,7 @@ function selectorFor_useGroup(state) {
50
53
  };
51
54
  }
52
55
  function useGroup(groupId) {
53
- const client = _chunk6VGVFTSYcjs.useClient.call(void 0, );
56
+ const client = _chunkQEGVIJNNcjs.useClient.call(void 0, );
54
57
  const store = client[_core.kInternal].httpClient.groupsStore;
55
58
  const getGroupState = _react.useCallback.call(void 0,
56
59
  () => store.getItemState(groupId),
@@ -59,7 +62,7 @@ function useGroup(groupId) {
59
62
  _react.useEffect.call(void 0, () => {
60
63
  void store.enqueue(groupId);
61
64
  }, [store, groupId]);
62
- return _chunk6VGVFTSYcjs.useSyncExternalStoreWithSelector.call(void 0,
65
+ return _chunkQEGVIJNNcjs.useSyncExternalStoreWithSelector.call(void 0,
63
66
  store.subscribe,
64
67
  getGroupState,
65
68
  getGroupState,
@@ -80,8 +83,8 @@ function normalizeMentionSuggestions(suggestions) {
80
83
  function useMentionSuggestions(roomId, search) {
81
84
  const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
82
85
  const lastInvokedAt = _react.useRef.call(void 0, );
83
- const resolveMentionSuggestions = _chunk6VGVFTSYcjs.useResolveMentionSuggestions.call(void 0, );
84
- const mentionSuggestionsCache = _chunk6VGVFTSYcjs.useMentionSuggestionsCache.call(void 0, );
86
+ const resolveMentionSuggestions = _chunkQEGVIJNNcjs.useResolveMentionSuggestions.call(void 0, );
87
+ const mentionSuggestionsCache = _chunkQEGVIJNNcjs.useMentionSuggestionsCache.call(void 0, );
85
88
  _react.useEffect.call(void 0, () => {
86
89
  if (search === void 0 || !resolveMentionSuggestions) {
87
90
  return;
@@ -136,7 +139,7 @@ function useMentionSuggestions(roomId, search) {
136
139
 
137
140
 
138
141
  function useSyncSource() {
139
- const client = _chunk6VGVFTSYcjs.useClient.call(void 0, );
142
+ const client = _chunkQEGVIJNNcjs.useClient.call(void 0, );
140
143
  const createSyncSource = client[_core.kInternal].createSyncSource;
141
144
  const [syncSource, setSyncSource] = _react.useState.call(void 0, );
142
145
  _react.useEffect.call(void 0, () => {
@@ -176,5 +179,8 @@ function useSyncSource() {
176
179
 
177
180
 
178
181
 
179
- exports.getUmbrellaStoreForClient = _chunk6VGVFTSYcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunk6VGVFTSYcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunk6VGVFTSYcjs.useClientOrNull; exports.useCreateRoomComment = _chunk6VGVFTSYcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunk6VGVFTSYcjs.useCreateRoomThread; exports.useCreateTextMention = _chunk6VGVFTSYcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunk6VGVFTSYcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunk6VGVFTSYcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunk6VGVFTSYcjs.useDeleteTextMention; exports.useEditRoomComment = _chunk6VGVFTSYcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunk6VGVFTSYcjs.useEditRoomThreadMetadata; exports.useGroup = useGroup; exports.useLatest = _chunk6VGVFTSYcjs.useLatest; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunk6VGVFTSYcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunk6VGVFTSYcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunk6VGVFTSYcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunk6VGVFTSYcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunk6VGVFTSYcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunk6VGVFTSYcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunk6VGVFTSYcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunk6VGVFTSYcjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunk6VGVFTSYcjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunk6VGVFTSYcjs.useRoomThreadSubscription; exports.useSignal = _chunk6VGVFTSYcjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunk6VGVFTSYcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunk6VGVFTSYcjs.useYjsProvider;
182
+
183
+
184
+
185
+ exports.getUmbrellaStoreForClient = _chunkQEGVIJNNcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkQEGVIJNNcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkQEGVIJNNcjs.useClientOrNull; exports.useCreateRoomComment = _chunkQEGVIJNNcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkQEGVIJNNcjs.useCreateRoomThread; exports.useCreateTextMention = _chunkQEGVIJNNcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkQEGVIJNNcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkQEGVIJNNcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkQEGVIJNNcjs.useDeleteTextMention; exports.useEditRoomComment = _chunkQEGVIJNNcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkQEGVIJNNcjs.useEditRoomThreadMetadata; exports.useGroup = useGroup; exports.useInitial = _chunkQEGVIJNNcjs.useInitial; exports.useLatest = _chunkQEGVIJNNcjs.useLatest; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkQEGVIJNNcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkQEGVIJNNcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkQEGVIJNNcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkQEGVIJNNcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkQEGVIJNNcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkQEGVIJNNcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkQEGVIJNNcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkQEGVIJNNcjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunkQEGVIJNNcjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunkQEGVIJNNcjs.useRoomThreadSubscription; exports.useSignal = _chunkQEGVIJNNcjs.useSignal; exports.useSuspendUntilPresenceReady = _chunkQEGVIJNNcjs.useSuspendUntilPresenceReady; exports.useSuspendUntilStorageReady = _chunkQEGVIJNNcjs.useSuspendUntilStorageReady; exports.useSyncExternalStoreWithSelector = _chunkQEGVIJNNcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkQEGVIJNNcjs.useYjsProvider;
180
186
  //# 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-group.ts","../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"names":["useEffect","kInternal","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,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d,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;AJ8HA;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;AACA;AACF,s9DAAC","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 {\n type AsyncResult,\n type GroupData,\n kInternal,\n shallow,\n} from \"@liveblocks/core\";\nimport { useCallback, useEffect } from \"react\";\n\nimport { useClient } from \"./contexts\";\nimport type { GroupAsyncResult } from \"./types\";\nimport { useSyncExternalStoreWithSelector } from \"./use-sync-external-store-with-selector\";\n\nfunction selectorFor_useGroup(\n state: AsyncResult<GroupData | undefined> | undefined\n): GroupAsyncResult {\n if (state === undefined || state?.isLoading) {\n return state ?? { isLoading: true };\n }\n\n if (state.error) {\n return state;\n }\n\n return {\n isLoading: false,\n group: state.data,\n };\n}\n\n/** @private - Internal API, do not rely on it. */\nexport function useGroup(groupId: string): GroupAsyncResult {\n const client = useClient();\n const store = client[kInternal].httpClient.groupsStore;\n\n const getGroupState = useCallback(\n () => store.getItemState(groupId),\n [store, groupId]\n );\n\n useEffect(() => {\n void store.enqueue(groupId);\n }, [store, groupId]);\n\n return useSyncExternalStoreWithSelector(\n store.subscribe,\n getGroupState,\n getGroupState,\n selectorFor_useGroup,\n shallow\n );\n}\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-group.ts","../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"names":["useEffect","kInternal","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;AACA;AACA;AACA;AACF,wDAA6B;AAC7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AAErE,EAAAF,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;AJiIA;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;AACA;AACA;AACA;AACA;AACF,qrEAAC","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 {\n type AsyncResult,\n type GroupData,\n kInternal,\n shallow,\n} from \"@liveblocks/core\";\nimport { useCallback, useEffect } from \"react\";\n\nimport { useClient } from \"./contexts\";\nimport type { GroupAsyncResult } from \"./types\";\nimport { useSyncExternalStoreWithSelector } from \"./use-sync-external-store-with-selector\";\n\nfunction selectorFor_useGroup(\n state: AsyncResult<GroupData | undefined> | undefined\n): GroupAsyncResult {\n if (state === undefined || state?.isLoading) {\n return state ?? { isLoading: true };\n }\n\n if (state.error) {\n return state;\n }\n\n return {\n isLoading: false,\n group: state.data,\n };\n}\n\n/** @private - Internal API, do not rely on it. */\nexport function useGroup(groupId: string): GroupAsyncResult {\n const client = useClient();\n const store = client[kInternal].httpClient.groupsStore;\n\n const getGroupState = useCallback(\n () => store.getItemState(groupId),\n [store, groupId]\n );\n\n useEffect(() => {\n void store.enqueue(groupId);\n }, [store, groupId]);\n\n return useSyncExternalStoreWithSelector(\n store.subscribe,\n getGroupState,\n getGroupState,\n selectorFor_useGroup,\n shallow\n );\n}\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,18 @@
1
- import { G as GroupAsyncResult } from './room-C2TwdMi3.cjs';
2
- 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-C2TwdMi3.cjs';
1
+ import { G as GroupAsyncResult } from './room-BvPZu216.cjs';
2
+ 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 useSuspendUntilPresenceReady, w as useSuspendUntilStorageReady, x as useYjsProvider } from './room-BvPZu216.cjs';
3
3
  import { MutableRefObject, useEffect } from 'react';
4
4
  import { MentionData, ISignal, SyncSource } from '@liveblocks/core';
5
5
  import '@liveblocks/client';
6
6
  import 'react/jsx-runtime';
7
7
 
8
+ /**
9
+ * "Freezes" a given value, so that it will return the same value/instance on
10
+ * each subsequent render. This can be used to freeze "initial" values for
11
+ * custom hooks, much like how `useState(initialState)` or
12
+ * `useRef(initialValue)` works.
13
+ */
14
+ declare function useInitial<T>(value: T, roomId?: string): T;
15
+
8
16
  /**
9
17
  * Keeps a ref in sync with a given value that may or may not change on
10
18
  * every render.
@@ -38,4 +46,4 @@ declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe
38
46
  */
39
47
  declare function useSyncSource(): SyncSource | undefined;
40
48
 
41
- export { useGroup, useLatest, useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
49
+ export { useGroup, useInitial, useLatest, useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
@@ -1,10 +1,18 @@
1
- import { G as GroupAsyncResult } from './room-C2TwdMi3.js';
2
- 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-C2TwdMi3.js';
1
+ import { G as GroupAsyncResult } from './room-BvPZu216.js';
2
+ 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 useSuspendUntilPresenceReady, w as useSuspendUntilStorageReady, x as useYjsProvider } from './room-BvPZu216.js';
3
3
  import { MutableRefObject, useEffect } from 'react';
4
4
  import { MentionData, ISignal, SyncSource } from '@liveblocks/core';
5
5
  import '@liveblocks/client';
6
6
  import 'react/jsx-runtime';
7
7
 
8
+ /**
9
+ * "Freezes" a given value, so that it will return the same value/instance on
10
+ * each subsequent render. This can be used to freeze "initial" values for
11
+ * custom hooks, much like how `useState(initialState)` or
12
+ * `useRef(initialValue)` works.
13
+ */
14
+ declare function useInitial<T>(value: T, roomId?: string): T;
15
+
8
16
  /**
9
17
  * Keeps a ref in sync with a given value that may or may not change on
10
18
  * every render.
@@ -38,4 +46,4 @@ declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe
38
46
  */
39
47
  declare function useSyncSource(): SyncSource | undefined;
40
48
 
41
- export { useGroup, useLatest, useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
49
+ export { useGroup, useInitial, 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
+ useInitial,
14
15
  useLatest,
15
16
  useMarkRoomThreadAsRead,
16
17
  useMarkRoomThreadAsResolved,
@@ -23,9 +24,11 @@ import {
23
24
  useRoomPermissions,
24
25
  useRoomThreadSubscription,
25
26
  useSignal,
27
+ useSuspendUntilPresenceReady,
28
+ useSuspendUntilStorageReady,
26
29
  useSyncExternalStoreWithSelector,
27
30
  useYjsProvider
28
- } from "./chunk-2HO3EZRC.js";
31
+ } from "./chunk-2VF57BZV.js";
29
32
 
30
33
  // src/lib/use-layout-effect.ts
31
34
  import { useEffect, useLayoutEffect as useOriginalLayoutEffect } from "react";
@@ -159,6 +162,7 @@ export {
159
162
  useEditRoomComment,
160
163
  useEditRoomThreadMetadata,
161
164
  useGroup,
165
+ useInitial,
162
166
  useLatest,
163
167
  useLayoutEffect,
164
168
  useMarkRoomThreadAsRead,
@@ -173,6 +177,8 @@ export {
173
177
  useRoomPermissions,
174
178
  useRoomThreadSubscription,
175
179
  useSignal,
180
+ useSuspendUntilPresenceReady,
181
+ useSuspendUntilStorageReady,
176
182
  useSyncExternalStoreWithSelector,
177
183
  useSyncSource,
178
184
  useYjsProvider
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/use-layout-effect.ts","../src/use-group.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 {\n type AsyncResult,\n type GroupData,\n kInternal,\n shallow,\n} from \"@liveblocks/core\";\nimport { useCallback, useEffect } from \"react\";\n\nimport { useClient } from \"./contexts\";\nimport type { GroupAsyncResult } from \"./types\";\nimport { useSyncExternalStoreWithSelector } from \"./use-sync-external-store-with-selector\";\n\nfunction selectorFor_useGroup(\n state: AsyncResult<GroupData | undefined> | undefined\n): GroupAsyncResult {\n if (state === undefined || state?.isLoading) {\n return state ?? { isLoading: true };\n }\n\n if (state.error) {\n return state;\n }\n\n return {\n isLoading: false,\n group: state.data,\n };\n}\n\n/** @private - Internal API, do not rely on it. */\nexport function useGroup(groupId: string): GroupAsyncResult {\n const client = useClient();\n const store = client[kInternal].httpClient.groupsStore;\n\n const getGroupState = useCallback(\n () => store.getItemState(groupId),\n [store, groupId]\n );\n\n useEffect(() => {\n void store.enqueue(groupId);\n }, [store, groupId]);\n\n return useSyncExternalStoreWithSelector(\n store.subscribe,\n getGroupState,\n getGroupState,\n selectorFor_useGroup,\n shallow\n );\n}\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;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,aAAAA,kBAAiB;AAMvC,SAAS,qBACP,OACkB;AAClB,MAAI,UAAU,UAAa,OAAO,WAAW;AAC3C,WAAO,SAAS,EAAE,WAAW,KAAK;AAAA,EACpC;AAEA,MAAI,MAAM,OAAO;AACf,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,WAAW;AAAA,IACX,OAAO,MAAM;AAAA,EACf;AACF;AAGO,SAAS,SAAS,SAAmC;AAC1D,QAAM,SAAS,UAAU;AACzB,QAAM,QAAQ,OAAO,SAAS,EAAE,WAAW;AAE3C,QAAM,gBAAgB;AAAA,IACpB,MAAM,MAAM,aAAa,OAAO;AAAA,IAChC,CAAC,OAAO,OAAO;AAAA,EACjB;AAEA,EAAAC,WAAU,MAAM;AACd,SAAK,MAAM,QAAQ,OAAO;AAAA,EAC5B,GAAG,CAAC,OAAO,OAAO,CAAC;AAEnB,SAAO;AAAA,IACL,MAAM;AAAA,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;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,aAAAC,kBAAiB;AAC1B,SAAS,aAAAC,YAAW,YAAAC,iBAAgB;AAO7B,SAAS,gBAAwC;AACtD,QAAM,SAAS,UAAU;AACzB,QAAM,mBAAmB,OAAOC,UAAS,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","useEffect","kInternal","useEffect","useState","kInternal","useState","useEffect"]}
1
+ {"version":3,"sources":["../src/lib/use-layout-effect.ts","../src/use-group.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 {\n type AsyncResult,\n type GroupData,\n kInternal,\n shallow,\n} from \"@liveblocks/core\";\nimport { useCallback, useEffect } from \"react\";\n\nimport { useClient } from \"./contexts\";\nimport type { GroupAsyncResult } from \"./types\";\nimport { useSyncExternalStoreWithSelector } from \"./use-sync-external-store-with-selector\";\n\nfunction selectorFor_useGroup(\n state: AsyncResult<GroupData | undefined> | undefined\n): GroupAsyncResult {\n if (state === undefined || state?.isLoading) {\n return state ?? { isLoading: true };\n }\n\n if (state.error) {\n return state;\n }\n\n return {\n isLoading: false,\n group: state.data,\n };\n}\n\n/** @private - Internal API, do not rely on it. */\nexport function useGroup(groupId: string): GroupAsyncResult {\n const client = useClient();\n const store = client[kInternal].httpClient.groupsStore;\n\n const getGroupState = useCallback(\n () => store.getItemState(groupId),\n [store, groupId]\n );\n\n useEffect(() => {\n void store.enqueue(groupId);\n }, [store, groupId]);\n\n return useSyncExternalStoreWithSelector(\n store.subscribe,\n getGroupState,\n getGroupState,\n selectorFor_useGroup,\n shallow\n );\n}\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":";;;;;;;;;;;;;;;;;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AAc,aAAa;AAC3B,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO;AACT;","names":["useEffect","useEffect","useEffect","useEffect","kInternal","useEffect","useState","kInternal","useState","useEffect"]}
@@ -1,6 +1,6 @@
1
1
  // src/version.ts
2
2
  var PKG_NAME = "@liveblocks/react";
3
- var PKG_VERSION = "3.16.0-feeds1";
3
+ var PKG_VERSION = "3.16.0-flow2";
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-LYXD3YYH.js.map
23
+ //# sourceMappingURL=chunk-2AIWAOIV.js.map