@liveblocks/react 3.6.2 → 3.7.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.
package/dist/_private.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
4
 
@@ -25,15 +25,52 @@
25
25
 
26
26
 
27
27
 
28
- var _chunkEEINMYNIcjs = require('./chunk-EEINMYNI.cjs');
28
+ var _chunkW2H56LB3cjs = require('./chunk-W2H56LB3.cjs');
29
29
 
30
30
  // src/lib/use-layout-effect.ts
31
31
  var _react = require('react');
32
32
  var useLayoutEffect = typeof window !== "undefined" ? _react.useLayoutEffect : _react.useEffect;
33
33
 
34
- // src/use-mention-suggestions.ts
34
+ // src/use-group.ts
35
+
36
+
37
+
35
38
  var _core = require('@liveblocks/core');
36
39
 
40
+ function selectorFor_useGroup(state) {
41
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _ => _.isLoading])) {
42
+ return _nullishCoalesce(state, () => ( { isLoading: true }));
43
+ }
44
+ if (state.error) {
45
+ return state;
46
+ }
47
+ return {
48
+ isLoading: false,
49
+ group: state.data
50
+ };
51
+ }
52
+ function useGroup(groupId) {
53
+ const client = _chunkW2H56LB3cjs.useClient.call(void 0, );
54
+ const store = client[_core.kInternal].httpClient.groupsStore;
55
+ const getGroupState = _react.useCallback.call(void 0,
56
+ () => store.getItemState(groupId),
57
+ [store, groupId]
58
+ );
59
+ _react.useEffect.call(void 0, () => {
60
+ void store.enqueue(groupId);
61
+ }, [store, groupId]);
62
+ return _chunkW2H56LB3cjs.useSyncExternalStoreWithSelector.call(void 0,
63
+ store.subscribe,
64
+ getGroupState,
65
+ getGroupState,
66
+ selectorFor_useGroup,
67
+ _core.shallow
68
+ );
69
+ }
70
+
71
+ // src/use-mention-suggestions.ts
72
+
73
+
37
74
  var MENTION_SUGGESTIONS_DEBOUNCE = 500;
38
75
  function normalizeMentionSuggestions(suggestions) {
39
76
  return suggestions.map(
@@ -43,8 +80,8 @@ function normalizeMentionSuggestions(suggestions) {
43
80
  function useMentionSuggestions(roomId, search) {
44
81
  const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
45
82
  const lastInvokedAt = _react.useRef.call(void 0, );
46
- const resolveMentionSuggestions = _chunkEEINMYNIcjs.useResolveMentionSuggestions.call(void 0, );
47
- const mentionSuggestionsCache = _chunkEEINMYNIcjs.useMentionSuggestionsCache.call(void 0, );
83
+ const resolveMentionSuggestions = _chunkW2H56LB3cjs.useResolveMentionSuggestions.call(void 0, );
84
+ const mentionSuggestionsCache = _chunkW2H56LB3cjs.useMentionSuggestionsCache.call(void 0, );
48
85
  _react.useEffect.call(void 0, () => {
49
86
  if (search === void 0 || !resolveMentionSuggestions) {
50
87
  return;
@@ -72,7 +109,7 @@ function useMentionSuggestions(roomId, search) {
72
109
  );
73
110
  }
74
111
  } catch (error) {
75
- console.error(_optionalChain([error, 'optionalAccess', _ => _.message]));
112
+ console.error(_optionalChain([error, 'optionalAccess', _2 => _2.message]));
76
113
  }
77
114
  };
78
115
  if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {
@@ -99,7 +136,7 @@ function useMentionSuggestions(roomId, search) {
99
136
 
100
137
 
101
138
  function useSyncSource() {
102
- const client = _chunkEEINMYNIcjs.useClient.call(void 0, );
139
+ const client = _chunkW2H56LB3cjs.useClient.call(void 0, );
103
140
  const createSyncSource = client[_core.kInternal].createSyncSource;
104
141
  const [syncSource, setSyncSource] = _react.useState.call(void 0, );
105
142
  _react.useEffect.call(void 0, () => {
@@ -138,5 +175,6 @@ function useSyncSource() {
138
175
 
139
176
 
140
177
 
141
- exports.getUmbrellaStoreForClient = _chunkEEINMYNIcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkEEINMYNIcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkEEINMYNIcjs.useClientOrNull; exports.useCreateRoomComment = _chunkEEINMYNIcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkEEINMYNIcjs.useCreateRoomThread; exports.useCreateTextMention = _chunkEEINMYNIcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkEEINMYNIcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkEEINMYNIcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkEEINMYNIcjs.useDeleteTextMention; exports.useEditRoomComment = _chunkEEINMYNIcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkEEINMYNIcjs.useEditRoomThreadMetadata; exports.useLatest = _chunkEEINMYNIcjs.useLatest; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkEEINMYNIcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkEEINMYNIcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkEEINMYNIcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkEEINMYNIcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkEEINMYNIcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkEEINMYNIcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkEEINMYNIcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkEEINMYNIcjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunkEEINMYNIcjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunkEEINMYNIcjs.useRoomThreadSubscription; exports.useSignal = _chunkEEINMYNIcjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunkEEINMYNIcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkEEINMYNIcjs.useYjsProvider;
178
+
179
+ exports.getUmbrellaStoreForClient = _chunkW2H56LB3cjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkW2H56LB3cjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkW2H56LB3cjs.useClientOrNull; exports.useCreateRoomComment = _chunkW2H56LB3cjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkW2H56LB3cjs.useCreateRoomThread; exports.useCreateTextMention = _chunkW2H56LB3cjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkW2H56LB3cjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkW2H56LB3cjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkW2H56LB3cjs.useDeleteTextMention; exports.useEditRoomComment = _chunkW2H56LB3cjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkW2H56LB3cjs.useEditRoomThreadMetadata; exports.useGroup = useGroup; exports.useLatest = _chunkW2H56LB3cjs.useLatest; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkW2H56LB3cjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkW2H56LB3cjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkW2H56LB3cjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkW2H56LB3cjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkW2H56LB3cjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkW2H56LB3cjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkW2H56LB3cjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkW2H56LB3cjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunkW2H56LB3cjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunkW2H56LB3cjs.useRoomThreadSubscription; exports.useSignal = _chunkW2H56LB3cjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunkW2H56LB3cjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkW2H56LB3cjs.useYjsProvider;
142
180
  //# 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;AACA;AACF,wDAA6B;AAC7B;AACA;AC3BA,8BAAsE;AAI/D,IAAM,gBAAA,EACX,OAAO,OAAA,IAAW,YAAA,EAAc,uBAAA,EAA0B,gBAAA;ADyB5D;AACA;AEjCA,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,O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AAA,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
+ {"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,EACX,OAAO,OAAA,IAAW,YAAA,EAAc,uBAAA,EAA0B,gBAAA;ADyB5D;AACA;AEjCA;AAGE;AACA;AAAA,wCACK;AACP;AAMA,SAAS,oBAAA,CACP,KAAA,EACkB;AAClB,EAAA,GAAA,CAAI,MAAA,IAAU,KAAA,EAAA,mBAAa,KAAA,2BAAO,WAAA,EAAW;AAC3C,IAAA,wBAAO,KAAA,UAAS,EAAE,SAAA,EAAW,KAAK,GAAA;AAAA,EACpC;AAEA,EAAA,GAAA,CAAI,KAAA,CAAM,KAAA,EAAO;AACf,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,KAAA;AAAA,IACX,KAAA,EAAO,KAAA,CAAM;AAAA,EACf,CAAA;AACF;AAGO,SAAS,QAAA,CAAS,OAAA,EAAmC;AAC1D,EAAA,MAAM,OAAA,EAAS,yCAAA,CAAU;AACzB,EAAA,MAAM,MAAA,EAAQ,MAAA,CAAO,eAAS,CAAA,CAAE,UAAA,CAAW,WAAA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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;AH8BA;AACA;AIrIA;AACA;AAOO,SAAS,aAAA,CAAA,EAAwC;AACtD,EAAA,MAAM,OAAA,EAAS,yCAAA,CAAU;AACzB,EAAA,MAAM,iBAAA,EAAmB,MAAA,CAAOC,eAAS,CAAA,CAAE,gBAAA;AAC3C,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,EAAA,EAAIC,6BAAAA,CAAiC;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;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,6 +1,7 @@
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-BE4TZf40.cjs';
1
+ import { G as GroupAsyncResult } from './room-mUz5TTmo.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-mUz5TTmo.cjs';
2
3
  import { MutableRefObject, useEffect } from 'react';
3
- import { ISignal, SyncSource } from '@liveblocks/core';
4
+ import { MentionData, ISignal, SyncSource } from '@liveblocks/core';
4
5
  import '@liveblocks/client';
5
6
  import 'react/jsx-runtime';
6
7
 
@@ -16,16 +17,16 @@ declare function useLatest<T>(value: T): MutableRefObject<T>;
16
17
 
17
18
  declare const useLayoutEffect: typeof useEffect;
18
19
 
20
+ /** @private - Internal API, do not rely on it. */
21
+ declare function useGroup(groupId: string): GroupAsyncResult;
22
+
19
23
  /**
20
24
  * @private For internal use only. Do not rely on this hook.
21
25
  *
22
26
  * Simplistic debounced search, we don't need to worry too much about deduping
23
27
  * and race conditions as there can only be one search at a time.
24
28
  */
25
- declare function useMentionSuggestions(roomId: string, search?: string): {
26
- kind: "user";
27
- id: string;
28
- }[] | undefined;
29
+ declare function useMentionSuggestions(roomId: string, search?: string): MentionData[] | undefined;
29
30
 
30
31
  declare function useSignal<T>(signal: ISignal<T>): T;
31
32
  declare function useSignal<T, V>(signal: ISignal<T>, selector: (value: T) => V, isEqual?: (a: V, b: V) => boolean): V;
@@ -37,4 +38,4 @@ declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe
37
38
  */
38
39
  declare function useSyncSource(): SyncSource | undefined;
39
40
 
40
- export { useLatest, useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
41
+ export { useGroup, useLatest, useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
@@ -1,6 +1,7 @@
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-BE4TZf40.js';
1
+ import { G as GroupAsyncResult } from './room-mUz5TTmo.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-mUz5TTmo.js';
2
3
  import { MutableRefObject, useEffect } from 'react';
3
- import { ISignal, SyncSource } from '@liveblocks/core';
4
+ import { MentionData, ISignal, SyncSource } from '@liveblocks/core';
4
5
  import '@liveblocks/client';
5
6
  import 'react/jsx-runtime';
6
7
 
@@ -16,16 +17,16 @@ declare function useLatest<T>(value: T): MutableRefObject<T>;
16
17
 
17
18
  declare const useLayoutEffect: typeof useEffect;
18
19
 
20
+ /** @private - Internal API, do not rely on it. */
21
+ declare function useGroup(groupId: string): GroupAsyncResult;
22
+
19
23
  /**
20
24
  * @private For internal use only. Do not rely on this hook.
21
25
  *
22
26
  * Simplistic debounced search, we don't need to worry too much about deduping
23
27
  * and race conditions as there can only be one search at a time.
24
28
  */
25
- declare function useMentionSuggestions(roomId: string, search?: string): {
26
- kind: "user";
27
- id: string;
28
- }[] | undefined;
29
+ declare function useMentionSuggestions(roomId: string, search?: string): MentionData[] | undefined;
29
30
 
30
31
  declare function useSignal<T>(signal: ISignal<T>): T;
31
32
  declare function useSignal<T, V>(signal: ISignal<T>, selector: (value: T) => V, isEqual?: (a: V, b: V) => boolean): V;
@@ -37,4 +38,4 @@ declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe
37
38
  */
38
39
  declare function useSyncSource(): SyncSource | undefined;
39
40
 
40
- export { useLatest, useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
41
+ export { useGroup, useLatest, useLayoutEffect, useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
package/dist/_private.js CHANGED
@@ -25,15 +25,52 @@ import {
25
25
  useSignal,
26
26
  useSyncExternalStoreWithSelector,
27
27
  useYjsProvider
28
- } from "./chunk-I2UW4JM4.js";
28
+ } from "./chunk-WGUV4Z4E.js";
29
29
 
30
30
  // src/lib/use-layout-effect.ts
31
31
  import { useEffect, useLayoutEffect as useOriginalLayoutEffect } from "react";
32
32
  var useLayoutEffect = typeof window !== "undefined" ? useOriginalLayoutEffect : useEffect;
33
33
 
34
+ // src/use-group.ts
35
+ import {
36
+ kInternal,
37
+ shallow
38
+ } from "@liveblocks/core";
39
+ import { useCallback, useEffect as useEffect2 } from "react";
40
+ function selectorFor_useGroup(state) {
41
+ if (state === void 0 || state?.isLoading) {
42
+ return state ?? { isLoading: true };
43
+ }
44
+ if (state.error) {
45
+ return state;
46
+ }
47
+ return {
48
+ isLoading: false,
49
+ group: state.data
50
+ };
51
+ }
52
+ function useGroup(groupId) {
53
+ const client = useClient();
54
+ const store = client[kInternal].httpClient.groupsStore;
55
+ const getGroupState = useCallback(
56
+ () => store.getItemState(groupId),
57
+ [store, groupId]
58
+ );
59
+ useEffect2(() => {
60
+ void store.enqueue(groupId);
61
+ }, [store, groupId]);
62
+ return useSyncExternalStoreWithSelector(
63
+ store.subscribe,
64
+ getGroupState,
65
+ getGroupState,
66
+ selectorFor_useGroup,
67
+ shallow
68
+ );
69
+ }
70
+
34
71
  // src/use-mention-suggestions.ts
35
72
  import { stableStringify } from "@liveblocks/core";
36
- import { useEffect as useEffect2, useRef, useState } from "react";
73
+ import { useEffect as useEffect3, useRef, useState } from "react";
37
74
  var MENTION_SUGGESTIONS_DEBOUNCE = 500;
38
75
  function normalizeMentionSuggestions(suggestions) {
39
76
  return suggestions.map(
@@ -45,7 +82,7 @@ function useMentionSuggestions(roomId, search) {
45
82
  const lastInvokedAt = useRef();
46
83
  const resolveMentionSuggestions = useResolveMentionSuggestions();
47
84
  const mentionSuggestionsCache = useMentionSuggestionsCache();
48
- useEffect2(() => {
85
+ useEffect3(() => {
49
86
  if (search === void 0 || !resolveMentionSuggestions) {
50
87
  return;
51
88
  }
@@ -96,13 +133,13 @@ function useMentionSuggestions(roomId, search) {
96
133
  }
97
134
 
98
135
  // src/use-sync-source.ts
99
- import { kInternal } from "@liveblocks/core";
100
- import { useEffect as useEffect3, useState as useState2 } from "react";
136
+ import { kInternal as kInternal2 } from "@liveblocks/core";
137
+ import { useEffect as useEffect4, useState as useState2 } from "react";
101
138
  function useSyncSource() {
102
139
  const client = useClient();
103
- const createSyncSource = client[kInternal].createSyncSource;
140
+ const createSyncSource = client[kInternal2].createSyncSource;
104
141
  const [syncSource, setSyncSource] = useState2();
105
- useEffect3(() => {
142
+ useEffect4(() => {
106
143
  const newSyncSource = createSyncSource();
107
144
  setSyncSource(newSyncSource);
108
145
  return () => newSyncSource.destroy();
@@ -121,6 +158,7 @@ export {
121
158
  useDeleteTextMention,
122
159
  useEditRoomComment,
123
160
  useEditRoomThreadMetadata,
161
+ useGroup,
124
162
  useLatest,
125
163
  useLayoutEffect,
126
164
  useMarkRoomThreadAsRead,
@@ -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,EAAA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AM;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
+ {"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,WAA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,QAAI,wBAAwB,IAAI,0BAA0B,GAAG;AAE3D,YAAM,oBAAoB,wBAAwB;AAAA,QAChD;AAAA,MACF;AACA,4BAAsB,iBAAiB;AAAA,IACzC,WACE,CAAC,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,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,6 +1,6 @@
1
1
  // src/version.ts
2
2
  var PKG_NAME = "@liveblocks/react";
3
- var PKG_VERSION = "3.6.2";
3
+ var PKG_VERSION = "3.7.0";
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-GQPV5XSP.js.map
23
+ //# sourceMappingURL=chunk-KYXF6473.js.map
@@ -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.6.2";
3
+ var PKG_VERSION = "3.7.0";
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-TCOWBBRU.cjs.map
23
+ //# sourceMappingURL=chunk-OXA6JGB4.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-TCOWBBRU.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-TCOWBBRU.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-OXA6JGB4.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-OXA6JGB4.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"]}