@liveblocks/react 2.25.0-aiprivatebeta14 → 2.25.0-aiprivatebeta16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  {
2
- "main": "../dist/_private.js",
3
- "types": "../dist/_private.d.ts"
2
+ "main": "../dist/_private.cjs",
3
+ "types": "../dist/_private.d.cts"
4
4
  }
package/dist/_private.cjs CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- var _chunk7DJASH5Hcjs = require('./chunk-7DJASH5H.cjs');
27
+ var _chunkQDQQBWCTcjs = require('./chunk-QDQQBWCT.cjs');
28
28
 
29
29
  // src/lib/use-layout-effect.ts
30
30
  var _react = require('react');
@@ -34,11 +34,16 @@ var useLayoutEffect = typeof window !== "undefined" ? _react.useLayoutEffect : _
34
34
  var _core = require('@liveblocks/core');
35
35
 
36
36
  var MENTION_SUGGESTIONS_DEBOUNCE = 500;
37
+ function normalizeMentionSuggestions(suggestions) {
38
+ return suggestions.map(
39
+ (suggestion) => typeof suggestion === "string" ? { kind: "user", id: suggestion } : suggestion
40
+ );
41
+ }
37
42
  function useMentionSuggestions(roomId, search) {
38
43
  const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
39
44
  const lastInvokedAt = _react.useRef.call(void 0, );
40
- const resolveMentionSuggestions = _chunk7DJASH5Hcjs.useResolveMentionSuggestions.call(void 0, );
41
- const mentionSuggestionsCache = _chunk7DJASH5Hcjs.useMentionSuggestionsCache.call(void 0, );
45
+ const resolveMentionSuggestions = _chunkQDQQBWCTcjs.useResolveMentionSuggestions.call(void 0, );
46
+ const mentionSuggestionsCache = _chunkQDQQBWCTcjs.useMentionSuggestionsCache.call(void 0, );
42
47
  _react.useEffect.call(void 0, () => {
43
48
  if (search === void 0 || !resolveMentionSuggestions) {
44
49
  return;
@@ -52,14 +57,17 @@ function useMentionSuggestions(roomId, search) {
52
57
  const getMentionSuggestions = async () => {
53
58
  try {
54
59
  lastInvokedAt.current = performance.now();
55
- const mentionSuggestions2 = await resolveMentionSuggestions(
60
+ const rawMentionSuggestions = await resolveMentionSuggestions(
56
61
  resolveMentionSuggestionsArgs
57
62
  );
58
63
  if (!isCanceled) {
59
- setMentionSuggestions(mentionSuggestions2);
64
+ const normalizedSuggestions = normalizeMentionSuggestions(
65
+ rawMentionSuggestions
66
+ );
67
+ setMentionSuggestions(normalizedSuggestions);
60
68
  mentionSuggestionsCache.set(
61
69
  mentionSuggestionsCacheKey,
62
- mentionSuggestions2
70
+ normalizedSuggestions
63
71
  );
64
72
  }
65
73
  } catch (error) {
@@ -67,9 +75,10 @@ function useMentionSuggestions(roomId, search) {
67
75
  }
68
76
  };
69
77
  if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {
70
- setMentionSuggestions(
71
- mentionSuggestionsCache.get(mentionSuggestionsCacheKey)
78
+ const cachedSuggestions = mentionSuggestionsCache.get(
79
+ mentionSuggestionsCacheKey
72
80
  );
81
+ setMentionSuggestions(cachedSuggestions);
73
82
  } else if (!lastInvokedAt.current || Math.abs(performance.now() - lastInvokedAt.current) > MENTION_SUGGESTIONS_DEBOUNCE) {
74
83
  void getMentionSuggestions();
75
84
  } else {
@@ -89,7 +98,7 @@ function useMentionSuggestions(roomId, search) {
89
98
 
90
99
 
91
100
  function useSyncSource() {
92
- const client = _chunk7DJASH5Hcjs.useClient.call(void 0, );
101
+ const client = _chunkQDQQBWCTcjs.useClient.call(void 0, );
93
102
  const createSyncSource = client[_core.kInternal].createSyncSource;
94
103
  const [syncSource, setSyncSource] = _react.useState.call(void 0, );
95
104
  _react.useEffect.call(void 0, () => {
@@ -127,5 +136,5 @@ function useSyncSource() {
127
136
 
128
137
 
129
138
 
130
- exports.getUmbrellaStoreForClient = _chunk7DJASH5Hcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunk7DJASH5Hcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunk7DJASH5Hcjs.useClientOrNull; exports.useCreateRoomComment = _chunk7DJASH5Hcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunk7DJASH5Hcjs.useCreateRoomThread; exports.useCreateTextMention = _chunk7DJASH5Hcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunk7DJASH5Hcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunk7DJASH5Hcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunk7DJASH5Hcjs.useDeleteTextMention; exports.useEditRoomComment = _chunk7DJASH5Hcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunk7DJASH5Hcjs.useEditRoomThreadMetadata; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunk7DJASH5Hcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunk7DJASH5Hcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunk7DJASH5Hcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunk7DJASH5Hcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunk7DJASH5Hcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunk7DJASH5Hcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunk7DJASH5Hcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunk7DJASH5Hcjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunk7DJASH5Hcjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunk7DJASH5Hcjs.useRoomThreadSubscription; exports.useSignal = _chunk7DJASH5Hcjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunk7DJASH5Hcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunk7DJASH5Hcjs.useYjsProvider;
139
+ exports.getUmbrellaStoreForClient = _chunkQDQQBWCTcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkQDQQBWCTcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkQDQQBWCTcjs.useClientOrNull; exports.useCreateRoomComment = _chunkQDQQBWCTcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkQDQQBWCTcjs.useCreateRoomThread; exports.useCreateTextMention = _chunkQDQQBWCTcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkQDQQBWCTcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkQDQQBWCTcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkQDQQBWCTcjs.useDeleteTextMention; exports.useEditRoomComment = _chunkQDQQBWCTcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkQDQQBWCTcjs.useEditRoomThreadMetadata; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkQDQQBWCTcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkQDQQBWCTcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkQDQQBWCTcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkQDQQBWCTcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkQDQQBWCTcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkQDQQBWCTcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkQDQQBWCTcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkQDQQBWCTcjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunkQDQQBWCTcjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunkQDQQBWCTcjs.useRoomThreadSubscription; exports.useSignal = _chunkQDQQBWCTcjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunkQDQQBWCTcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkQDQQBWCTcjs.useYjsProvider;
131
140
  //# 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","mentionSuggestions","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,wCAAgC;AAChC;AAOA,IAAM,6BAAA,EAA+B,GAAA;AAQ9B,SAAS,qBAAA,CAAsB,MAAA,EAAgB,MAAA,EAAiB;AACrE,EAAA,MAAM,CAAC,kBAAA,EAAoB,qBAAqB,EAAA,EAAI,6BAAA,CAAmB;AACvE,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,MAAM,2BAAA,EAA6B,mCAAA;AAAA,MACjC;AAAA,IACF,CAAA;AACA,IAAA,IAAI,eAAA;AACJ,IAAA,IAAI,WAAA,EAAa,KAAA;AAEjB,IAAA,MAAM,sBAAA,EAAwB,MAAA,CAAA,EAAA,GAAY;AACxC,MAAA,IAAI;AACF,QAAA,aAAA,CAAc,QAAA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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,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;AH+EA;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 { 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 * @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<string[]>();\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 mentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n setMentionSuggestions(mentionSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n mentionSuggestions\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 setMentionSuggestions(\n mentionSuggestionsCache.get(mentionSuggestionsCacheKey)\n );\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;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,MA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;AAEL,MAAA,gBAAA,EAAkB,MAAA,CAAO,UAAA,CAAW,CAAA,EAAA,GAAM;AACxC,QAAA,KAAK,qBAAA,CAAsB,CAAA;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,4 +1,4 @@
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-qnTepKOd.cjs';
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-BzmUELIi.cjs';
2
2
  import { useLayoutEffect as useLayoutEffect$1 } from 'react';
3
3
  import { ISignal, SyncSource } from '@liveblocks/core';
4
4
  import '@liveblocks/client';
@@ -12,7 +12,10 @@ declare const useLayoutEffect: typeof useLayoutEffect$1;
12
12
  * Simplistic debounced search, we don't need to worry too much about deduping
13
13
  * and race conditions as there can only be one search at a time.
14
14
  */
15
- declare function useMentionSuggestions(roomId: string, search?: string): string[] | undefined;
15
+ declare function useMentionSuggestions(roomId: string, search?: string): {
16
+ kind: "user";
17
+ id: string;
18
+ }[] | undefined;
16
19
 
17
20
  declare function useSignal<T>(signal: ISignal<T>): T;
18
21
  declare function useSignal<T, V>(signal: ISignal<T>, selector: (value: T) => V, isEqual?: (a: V, b: V) => boolean): V;
@@ -1,4 +1,4 @@
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-qnTepKOd.js';
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-BzmUELIi.js';
2
2
  import { useLayoutEffect as useLayoutEffect$1 } from 'react';
3
3
  import { ISignal, SyncSource } from '@liveblocks/core';
4
4
  import '@liveblocks/client';
@@ -12,7 +12,10 @@ declare const useLayoutEffect: typeof useLayoutEffect$1;
12
12
  * Simplistic debounced search, we don't need to worry too much about deduping
13
13
  * and race conditions as there can only be one search at a time.
14
14
  */
15
- declare function useMentionSuggestions(roomId: string, search?: string): string[] | undefined;
15
+ declare function useMentionSuggestions(roomId: string, search?: string): {
16
+ kind: "user";
17
+ id: string;
18
+ }[] | undefined;
16
19
 
17
20
  declare function useSignal<T>(signal: ISignal<T>): T;
18
21
  declare function useSignal<T, V>(signal: ISignal<T>, selector: (value: T) => V, isEqual?: (a: V, b: V) => boolean): V;
package/dist/_private.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  useSignal,
25
25
  useSyncExternalStoreWithSelector,
26
26
  useYjsProvider
27
- } from "./chunk-KLANVQIZ.js";
27
+ } from "./chunk-PJG72DS4.js";
28
28
 
29
29
  // src/lib/use-layout-effect.ts
30
30
  import { useEffect, useLayoutEffect as useOriginalLayoutEffect } from "react";
@@ -34,6 +34,11 @@ var useLayoutEffect = typeof window !== "undefined" ? useOriginalLayoutEffect :
34
34
  import { stableStringify } from "@liveblocks/core";
35
35
  import { useEffect as useEffect2, useRef, useState } from "react";
36
36
  var MENTION_SUGGESTIONS_DEBOUNCE = 500;
37
+ function normalizeMentionSuggestions(suggestions) {
38
+ return suggestions.map(
39
+ (suggestion) => typeof suggestion === "string" ? { kind: "user", id: suggestion } : suggestion
40
+ );
41
+ }
37
42
  function useMentionSuggestions(roomId, search) {
38
43
  const [mentionSuggestions, setMentionSuggestions] = useState();
39
44
  const lastInvokedAt = useRef();
@@ -52,14 +57,17 @@ function useMentionSuggestions(roomId, search) {
52
57
  const getMentionSuggestions = async () => {
53
58
  try {
54
59
  lastInvokedAt.current = performance.now();
55
- const mentionSuggestions2 = await resolveMentionSuggestions(
60
+ const rawMentionSuggestions = await resolveMentionSuggestions(
56
61
  resolveMentionSuggestionsArgs
57
62
  );
58
63
  if (!isCanceled) {
59
- setMentionSuggestions(mentionSuggestions2);
64
+ const normalizedSuggestions = normalizeMentionSuggestions(
65
+ rawMentionSuggestions
66
+ );
67
+ setMentionSuggestions(normalizedSuggestions);
60
68
  mentionSuggestionsCache.set(
61
69
  mentionSuggestionsCacheKey,
62
- mentionSuggestions2
70
+ normalizedSuggestions
63
71
  );
64
72
  }
65
73
  } catch (error) {
@@ -67,9 +75,10 @@ function useMentionSuggestions(roomId, search) {
67
75
  }
68
76
  };
69
77
  if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {
70
- setMentionSuggestions(
71
- mentionSuggestionsCache.get(mentionSuggestionsCacheKey)
78
+ const cachedSuggestions = mentionSuggestionsCache.get(
79
+ mentionSuggestionsCacheKey
72
80
  );
81
+ setMentionSuggestions(cachedSuggestions);
73
82
  } else if (!lastInvokedAt.current || Math.abs(performance.now() - lastInvokedAt.current) > MENTION_SUGGESTIONS_DEBOUNCE) {
74
83
  void getMentionSuggestions();
75
84
  } else {
@@ -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 { 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 * @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<string[]>();\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 mentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n setMentionSuggestions(mentionSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n mentionSuggestions\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 setMentionSuggestions(\n mentionSuggestionsCache.get(mentionSuggestionsCacheKey)\n );\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,SAAS,uBAAuB;AAChC,SAAS,aAAAA,YAAW,QAAQ,gBAAgB;AAO5C,IAAM,+BAA+B;AAQ9B,SAAS,sBAAsB,QAAgB,QAAiB;AACrE,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAmB;AACvE,QAAM,gBAAgB,OAAe;AAErC,QAAM,4BAA4B,6BAA6B;AAC/D,QAAM,0BAA0B,2BAA2B;AAE3D,EAAAC,WAAU,MAAM;AACd,QAAI,WAAW,UAAa,CAAC,2BAA2B;AACtD;AAAA,IACF;AAEA,UAAM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useEffect","useEffect","mentionSuggestions","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 }, [createSyncSource]);\n\n return syncSource;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,WAAW,mB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7B,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 = "2.25.0-aiprivatebeta14";
3
+ var PKG_VERSION = "2.25.0-aiprivatebeta16";
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-SQ3SBXBT.js.map
23
+ //# sourceMappingURL=chunk-MVM43YJM.js.map
@@ -294,7 +294,7 @@ import {
294
294
  createNotificationSettings,
295
295
  DefaultMap,
296
296
  DerivedSignal,
297
- getMentionedIdsFromCommentBody,
297
+ getMentionsFromCommentBody,
298
298
  getSubscriptionKey,
299
299
  kInternal as kInternal2,
300
300
  MutableSignal as MutableSignal3,
@@ -1953,8 +1953,11 @@ function isThreadParticipant(thread, userId) {
1953
1953
  isParticipant = true;
1954
1954
  break;
1955
1955
  }
1956
- const mentionedIds = getMentionedIdsFromCommentBody(comment.body);
1957
- if (mentionedIds.includes(userId)) {
1956
+ const mentions = getMentionsFromCommentBody(
1957
+ comment.body,
1958
+ (mention) => mention.kind === "user" && mention.id === userId
1959
+ );
1960
+ if (mentions.length > 0) {
1958
1961
  isParticipant = true;
1959
1962
  break;
1960
1963
  }
@@ -2353,7 +2356,7 @@ function useUpdateNotificationSettings_withClient(client) {
2353
2356
  }
2354
2357
  client[kInternal3].emitError(
2355
2358
  {
2356
- type: "UPDATE_USER_NOTIFICATION_SETTINGS_ERROR"
2359
+ type: "UPDATE_NOTIFICATION_SETTINGS_ERROR"
2357
2360
  },
2358
2361
  err
2359
2362
  );
@@ -2710,7 +2713,6 @@ function LiveblocksProvider(props) {
2710
2713
  backgroundKeepAliveTimeout: useInitial(o.backgroundKeepAliveTimeout),
2711
2714
  polyfills: useInitial(o.polyfills),
2712
2715
  largeMessageStrategy: useInitial(o.largeMessageStrategy),
2713
- unstable_fallbackToHTTP: useInitial(o.unstable_fallbackToHTTP),
2714
2716
  unstable_streamData: useInitial(o.unstable_streamData),
2715
2717
  preventUnsavedChanges: useInitial(o.preventUnsavedChanges),
2716
2718
  authEndpoint: useInitialUnlessFunction(o.authEndpoint),
@@ -3102,8 +3104,6 @@ function makeRoomContextBundle(client) {
3102
3104
  RoomProvider: RoomProvider_withImplicitLiveblocksProvider,
3103
3105
  useRoom,
3104
3106
  useStatus,
3105
- useStorageStatus,
3106
- useBatch,
3107
3107
  useBroadcastEvent,
3108
3108
  useOthersListener,
3109
3109
  useLostConnectionListener,
@@ -3141,9 +3141,7 @@ function makeRoomContextBundle(client) {
3141
3141
  useAttachmentUrl,
3142
3142
  useHistoryVersions,
3143
3143
  useHistoryVersionData,
3144
- useRoomNotificationSettings,
3145
3144
  useRoomSubscriptionSettings,
3146
- useUpdateRoomNotificationSettings,
3147
3145
  useUpdateRoomSubscriptionSettings,
3148
3146
  ...shared.classic,
3149
3147
  suspense: {
@@ -3151,8 +3149,6 @@ function makeRoomContextBundle(client) {
3151
3149
  RoomProvider: RoomProvider_withImplicitLiveblocksProvider,
3152
3150
  useRoom,
3153
3151
  useStatus,
3154
- useStorageStatus: useStorageStatusSuspense,
3155
- useBatch,
3156
3152
  useBroadcastEvent,
3157
3153
  useOthersListener,
3158
3154
  useLostConnectionListener,
@@ -3190,9 +3186,7 @@ function makeRoomContextBundle(client) {
3190
3186
  useAttachmentUrl: useAttachmentUrlSuspense,
3191
3187
  // TODO: useHistoryVersionData: useHistoryVersionDataSuspense,
3192
3188
  useHistoryVersions: useHistoryVersionsSuspense,
3193
- useRoomNotificationSettings: useRoomNotificationSettingsSuspense,
3194
3189
  useRoomSubscriptionSettings: useRoomSubscriptionSettingsSuspense,
3195
- useUpdateRoomNotificationSettings,
3196
3190
  useUpdateRoomSubscriptionSettings,
3197
3191
  ...shared.suspense
3198
3192
  }
@@ -3396,45 +3390,6 @@ function useMentionSuggestionsCache() {
3396
3390
  const client = useClient();
3397
3391
  return client[kInternal4].mentionSuggestionsCache;
3398
3392
  }
3399
- function useStorageStatus(options) {
3400
- const smooth = useInitial(options?.smooth ?? false);
3401
- if (smooth) {
3402
- return useStorageStatusSmooth();
3403
- } else {
3404
- return useStorageStatusImmediate();
3405
- }
3406
- }
3407
- function useStorageStatusImmediate() {
3408
- const room = useRoom();
3409
- const subscribe = room.events.storageStatus.subscribe;
3410
- const getSnapshot = room.getStorageStatus;
3411
- const getServerSnapshot = room.getStorageStatus;
3412
- return useSyncExternalStore3(subscribe, getSnapshot, getServerSnapshot);
3413
- }
3414
- function useStorageStatusSmooth() {
3415
- const room = useRoom();
3416
- const [status, setStatus] = useState3(room.getStorageStatus);
3417
- const oldStatus = useLatest(room.getStorageStatus());
3418
- useEffect6(() => {
3419
- let timeoutId;
3420
- const unsub = room.events.storageStatus.subscribe((newStatus) => {
3421
- if (oldStatus.current === "synchronizing" && newStatus === "synchronized") {
3422
- timeoutId = setTimeout(() => setStatus(newStatus), config.SMOOTH_DELAY);
3423
- } else {
3424
- clearTimeout(timeoutId);
3425
- setStatus(newStatus);
3426
- }
3427
- });
3428
- return () => {
3429
- clearTimeout(timeoutId);
3430
- unsub();
3431
- };
3432
- }, [room, oldStatus]);
3433
- return status;
3434
- }
3435
- function useBatch() {
3436
- return useRoom().batch;
3437
- }
3438
3393
  function useBroadcastEvent() {
3439
3394
  const room = useRoom();
3440
3395
  return useCallback3(
@@ -4245,37 +4200,6 @@ function useRoomThreadSubscription(roomId, threadId) {
4245
4200
  );
4246
4201
  return useSignal(signal, selector, shallow4);
4247
4202
  }
4248
- function useRoomNotificationSettings() {
4249
- const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
4250
- const client = useClient();
4251
- const room = useRoom();
4252
- const { store, getOrCreateSubscriptionSettingsPollerForRoomId } = getRoomExtrasForClient(client);
4253
- const poller = getOrCreateSubscriptionSettingsPollerForRoomId(room.id);
4254
- useEffect6(
4255
- () => void store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).waitUntilLoaded()
4256
- // NOTE: Deliberately *not* using a dependency array here!
4257
- //
4258
- // It is important to call waitUntil on *every* render.
4259
- // This is harmless though, on most renders, except:
4260
- // 1. The very first render, in which case we'll want to trigger the initial page fetch.
4261
- // 2. All other subsequent renders now "just" return the same promise (a quick operation).
4262
- // 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
4263
- // *next* render after that, a *new* fetch/promise will get created.
4264
- );
4265
- useEffect6(() => {
4266
- poller.inc();
4267
- poller.pollNowIfStale();
4268
- return () => {
4269
- poller.dec();
4270
- };
4271
- }, [poller]);
4272
- const settings = useSignal(
4273
- store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).signal
4274
- );
4275
- return useMemo3(() => {
4276
- return [settings, updateRoomNotificationSettings];
4277
- }, [settings, updateRoomNotificationSettings]);
4278
- }
4279
4203
  function useRoomSubscriptionSettings() {
4280
4204
  const updateRoomSubscriptionSettings = useUpdateRoomSubscriptionSettings();
4281
4205
  const client = useClient();
@@ -4307,21 +4231,6 @@ function useRoomSubscriptionSettings() {
4307
4231
  return [settings, updateRoomSubscriptionSettings];
4308
4232
  }, [settings, updateRoomSubscriptionSettings]);
4309
4233
  }
4310
- function useRoomNotificationSettingsSuspense() {
4311
- ensureNotServerSide();
4312
- const client = useClient();
4313
- const store = getRoomExtrasForClient(client).store;
4314
- const room = useRoom();
4315
- use(
4316
- store.outputs.roomSubscriptionSettingsByRoomId.getOrCreate(room.id).waitUntilLoaded()
4317
- );
4318
- const [settings, updateRoomNotificationSettings] = useRoomNotificationSettings();
4319
- assert2(!settings.error, "Did not expect error");
4320
- assert2(!settings.isLoading, "Did not expect loading");
4321
- return useMemo3(() => {
4322
- return [settings, updateRoomNotificationSettings];
4323
- }, [settings, updateRoomNotificationSettings]);
4324
- }
4325
4234
  function useRoomSubscriptionSettingsSuspense() {
4326
4235
  ensureNotServerSide();
4327
4236
  const client = useClient();
@@ -4400,40 +4309,6 @@ function useHistoryVersionsSuspense() {
4400
4309
  assert2(!result.isLoading, "Did not expect loading");
4401
4310
  return result;
4402
4311
  }
4403
- function useUpdateRoomNotificationSettings() {
4404
- const client = useClient();
4405
- const room = useRoom();
4406
- return useCallback3(
4407
- (settings) => {
4408
- const { store, onMutationFailure, pollThreadsForRoomId } = getRoomExtrasForClient(client);
4409
- const userId = getCurrentUserId(client);
4410
- const optimisticId = store.optimisticUpdates.add({
4411
- type: "update-room-subscription-settings",
4412
- roomId: room.id,
4413
- userId,
4414
- settings
4415
- });
4416
- room.updateSubscriptionSettings(settings).then(
4417
- (updatedSettings) => {
4418
- store.updateRoomSubscriptionSettings(
4419
- room.id,
4420
- optimisticId,
4421
- updatedSettings
4422
- );
4423
- if (settings.threads) {
4424
- pollThreadsForRoomId(room.id);
4425
- }
4426
- },
4427
- (err) => onMutationFailure(
4428
- optimisticId,
4429
- { type: "UPDATE_NOTIFICATION_SETTINGS_ERROR", roomId: room.id },
4430
- err
4431
- )
4432
- );
4433
- },
4434
- [client, room]
4435
- );
4436
- }
4437
4312
  function useUpdateRoomSubscriptionSettings() {
4438
4313
  const client = useClient();
4439
4314
  const room = useRoom();
@@ -4514,10 +4389,6 @@ function useStorageSuspense(selector, isEqual) {
4514
4389
  isEqual
4515
4390
  );
4516
4391
  }
4517
- function useStorageStatusSuspense(options) {
4518
- useSuspendUntilStorageReady();
4519
- return useStorageStatus(options);
4520
- }
4521
4392
  function useThreadsSuspense(options = {}) {
4522
4393
  ensureNotServerSide();
4523
4394
  const client = useClient();
@@ -4617,9 +4488,7 @@ var _useOthersMapped = useOthersMapped;
4617
4488
  var _useOthersMappedSuspense = useOthersMappedSuspense;
4618
4489
  var _useThreads = useThreads;
4619
4490
  var _useThreadsSuspense = useThreadsSuspense;
4620
- var _useRoomNotificationSettings = useRoomNotificationSettings;
4621
4491
  var _useRoomSubscriptionSettings = useRoomSubscriptionSettings;
4622
- var _useRoomNotificationSettingsSuspense = useRoomNotificationSettingsSuspense;
4623
4492
  var _useRoomSubscriptionSettingsSuspense = useRoomSubscriptionSettingsSuspense;
4624
4493
  var _useHistoryVersions = useHistoryVersions;
4625
4494
  var _useHistoryVersionsSuspense = useHistoryVersionsSuspense;
@@ -4690,8 +4559,6 @@ export {
4690
4559
  useDeleteTextMention,
4691
4560
  useResolveMentionSuggestions,
4692
4561
  useMentionSuggestionsCache,
4693
- useStorageStatus,
4694
- useBatch,
4695
4562
  useLostConnectionListener,
4696
4563
  useHistory,
4697
4564
  useUndo,
@@ -4722,10 +4589,8 @@ export {
4722
4589
  useThreadSubscription,
4723
4590
  useRoomThreadSubscription,
4724
4591
  useHistoryVersionData,
4725
- useUpdateRoomNotificationSettings,
4726
4592
  useUpdateRoomSubscriptionSettings,
4727
4593
  useOthersConnectionIdsSuspense,
4728
- useStorageStatusSuspense,
4729
4594
  useAttachmentUrl,
4730
4595
  useRoomAttachmentUrl,
4731
4596
  useAttachmentUrlSuspense,
@@ -4747,9 +4612,7 @@ export {
4747
4612
  _useOthersMappedSuspense,
4748
4613
  _useThreads,
4749
4614
  _useThreadsSuspense,
4750
- _useRoomNotificationSettings,
4751
4615
  _useRoomSubscriptionSettings,
4752
- _useRoomNotificationSettingsSuspense,
4753
4616
  _useRoomSubscriptionSettingsSuspense,
4754
4617
  _useHistoryVersions,
4755
4618
  _useHistoryVersionsSuspense,
@@ -4764,4 +4627,4 @@ export {
4764
4627
  _useStorageRoot,
4765
4628
  _useUpdateMyPresence
4766
4629
  };
4767
- //# sourceMappingURL=chunk-KLANVQIZ.js.map
4630
+ //# sourceMappingURL=chunk-PJG72DS4.js.map