@liveblocks/react 2.13.1 → 2.13.3-emails1

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
- export { C as CreateThreadError, g as getUmbrellaStoreForClient, b as useAddRoomCommentReaction, a as useClientOrNull, c as useCreateRoomComment, d as useCreateRoomThread, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useEditRoomComment, i as useEditRoomThreadMetadata, j as useMarkRoomThreadAsRead, k as useMarkRoomThreadAsResolved, l as useMarkRoomThreadAsUnresolved, m as useRemoveRoomCommentReaction, n as useRoomAttachmentUrl, u as useRoomOrNull, o as useRoomPermissions } from './room-jhgb5WaA.mjs';
1
+ export { C as CreateThreadError, g as getUmbrellaStoreForClient, b as useAddRoomCommentReaction, a as useClientOrNull, c as useCreateRoomComment, d as useCreateRoomThread, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useEditRoomComment, i as useEditRoomThreadMetadata, j as useMarkRoomThreadAsRead, k as useMarkRoomThreadAsResolved, l as useMarkRoomThreadAsUnresolved, m as useRemoveRoomCommentReaction, n as useReportTextEditor, o as useRoomAttachmentUrl, u as useRoomOrNull, p as useRoomPermissions } from './room-Rl_QnQMY.mjs';
2
2
  import { SyncSource } from '@liveblocks/core';
3
3
  import '@liveblocks/client';
4
4
  import 'react';
@@ -1,4 +1,4 @@
1
- export { C as CreateThreadError, g as getUmbrellaStoreForClient, b as useAddRoomCommentReaction, a as useClientOrNull, c as useCreateRoomComment, d as useCreateRoomThread, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useEditRoomComment, i as useEditRoomThreadMetadata, j as useMarkRoomThreadAsRead, k as useMarkRoomThreadAsResolved, l as useMarkRoomThreadAsUnresolved, m as useRemoveRoomCommentReaction, n as useRoomAttachmentUrl, u as useRoomOrNull, o as useRoomPermissions } from './room-jhgb5WaA.js';
1
+ export { C as CreateThreadError, g as getUmbrellaStoreForClient, b as useAddRoomCommentReaction, a as useClientOrNull, c as useCreateRoomComment, d as useCreateRoomThread, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useEditRoomComment, i as useEditRoomThreadMetadata, j as useMarkRoomThreadAsRead, k as useMarkRoomThreadAsResolved, l as useMarkRoomThreadAsUnresolved, m as useRemoveRoomCommentReaction, n as useReportTextEditor, o as useRoomAttachmentUrl, u as useRoomOrNull, p as useRoomPermissions } from './room-Rl_QnQMY.js';
2
2
  import { SyncSource } from '@liveblocks/core';
3
3
  import '@liveblocks/client';
4
4
  import 'react';
package/dist/_private.js CHANGED
@@ -17,14 +17,15 @@
17
17
 
18
18
 
19
19
 
20
- var _chunkSLZNMBCLjs = require('./chunk-SLZNMBCL.js');
20
+
21
+ var _chunkX4DDEZYLjs = require('./chunk-X4DDEZYL.js');
21
22
 
22
23
  // src/use-mention-suggestions.ts
23
24
  var _core = require('@liveblocks/core');
24
25
  var _react = require('react'); var _react2 = _interopRequireDefault(_react);
25
26
  var MENTION_SUGGESTIONS_DEBOUNCE = 500;
26
27
  function useMentionSuggestions(roomId, search) {
27
- const client = _chunkSLZNMBCLjs.useClient.call(void 0, );
28
+ const client = _chunkX4DDEZYLjs.useClient.call(void 0, );
28
29
  const [mentionSuggestions, setMentionSuggestions] = _react2.default.useState();
29
30
  const lastInvokedAt = _react2.default.useRef();
30
31
  _react2.default.useEffect(() => {
@@ -77,7 +78,7 @@ function useMentionSuggestions(roomId, search) {
77
78
 
78
79
 
79
80
  function useSyncSource() {
80
- const client = _chunkSLZNMBCLjs.useClient.call(void 0, );
81
+ const client = _chunkX4DDEZYLjs.useClient.call(void 0, );
81
82
  const createSyncSource = client[_core.kInternal].createSyncSource;
82
83
  const [syncSource, setSyncSource] = _react2.default.useState();
83
84
  _react2.default.useEffect(() => {
@@ -107,5 +108,6 @@ function useSyncSource() {
107
108
 
108
109
 
109
110
 
110
- exports.CreateThreadError = _chunkSLZNMBCLjs.CreateThreadError; exports.getUmbrellaStoreForClient = _chunkSLZNMBCLjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkSLZNMBCLjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkSLZNMBCLjs.useClientOrNull; exports.useCreateRoomComment = _chunkSLZNMBCLjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkSLZNMBCLjs.useCreateRoomThread; exports.useDeleteRoomComment = _chunkSLZNMBCLjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkSLZNMBCLjs.useDeleteRoomThread; exports.useEditRoomComment = _chunkSLZNMBCLjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkSLZNMBCLjs.useEditRoomThreadMetadata; exports.useMarkRoomThreadAsRead = _chunkSLZNMBCLjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkSLZNMBCLjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkSLZNMBCLjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useRemoveRoomCommentReaction = _chunkSLZNMBCLjs.useRemoveRoomCommentReaction; exports.useRoomAttachmentUrl = _chunkSLZNMBCLjs.useRoomAttachmentUrl; exports.useRoomOrNull = _chunkSLZNMBCLjs.useRoomOrNull; exports.useRoomPermissions = _chunkSLZNMBCLjs.useRoomPermissions; exports.useSyncSource = useSyncSource;
111
+
112
+ exports.CreateThreadError = _chunkX4DDEZYLjs.CreateThreadError; exports.getUmbrellaStoreForClient = _chunkX4DDEZYLjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkX4DDEZYLjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkX4DDEZYLjs.useClientOrNull; exports.useCreateRoomComment = _chunkX4DDEZYLjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkX4DDEZYLjs.useCreateRoomThread; exports.useDeleteRoomComment = _chunkX4DDEZYLjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkX4DDEZYLjs.useDeleteRoomThread; exports.useEditRoomComment = _chunkX4DDEZYLjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkX4DDEZYLjs.useEditRoomThreadMetadata; exports.useMarkRoomThreadAsRead = _chunkX4DDEZYLjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkX4DDEZYLjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkX4DDEZYLjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useRemoveRoomCommentReaction = _chunkX4DDEZYLjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkX4DDEZYLjs.useReportTextEditor; exports.useRoomAttachmentUrl = _chunkX4DDEZYLjs.useRoomAttachmentUrl; exports.useRoomOrNull = _chunkX4DDEZYLjs.useRoomOrNull; exports.useRoomPermissions = _chunkX4DDEZYLjs.useRoomPermissions; exports.useSyncSource = useSyncSource;
111
113
  //# sourceMappingURL=_private.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"names":["mentionSuggestions","kInternal","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,iBAAiB;AACrC,OAAO,WAAW;AAIlB,IAAM,+BAA+B;AAQ9B,SAAS,sBAAsB,QAAgB,QAAiB;AACrE,QAAM,SAAS,UAAU;AAEzB,QAAM,CAAC,oBAAoB,qBAAqB,IAC9C,MAAM,SAAmB;AAC3B,QAAM,gBAAgB,MAAM,OAAe;AAE3C,QAAM,UAAU,MAAM;AACpB,UAAM,0BAA0B,OAAO,SAAS,EAAE;AAClD,UAAM,4BACJ,OAAO,SAAS,EAAE;AAEpB,QAAI,WAAW,UAAa,CAAC,2BAA2B;AACtD;AAAA,IACF;AAEA,UAAM,gCAAgC,EAAE,MAAM,QAAQ,OAAO;AAC7D,UAAM,6BAA6B,UAAU,6BAA6B;AAC1E,QAAI;AACJ,QAAI,aAAa;AAEjB,UAAM,wBAAwB,YAAY;AACxC,UAAI;AACF,sBAAc,UAAU,YAAY,IAAI;AACxC,cAAMA,sBAAqB,MAAM;AAAA,UAC/B;AAAA,QACF;AAEA,YAAI,CAAC,YAAY;AACf,gCAAsBA,mBAAkB;AACxC,kCAAwB;AAAA,YACtB;AAAA,YACAA;AAAA,UACF;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAO,OAAiB,OAAO;AAAA,MACzC;AAAA,IACF;AAEA,QAAI,wBAAwB,IAAI,0BAA0B,GAAG;AAE3D;AAAA,QACE,wBAAwB,IAAI,0BAA0B;AAAA,MACxD;AAAA,IACF,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,MAAM,CAAC;AAE3B,SAAO;AACT;;;AC/EA,SAAS,aAAAC,kBAAiB;AAC1B,OAAOC,YAAW;AAOX,SAAS,gBAAwC;AACtD,QAAM,SAAS,UAAU;AACzB,QAAM,mBAAmB,OAAOD,UAAS,EAAE;AAC3C,QAAM,CAAC,YAAY,aAAa,IAAIC,OAAM,SAAiC;AAE3E,EAAAA,OAAM,UAAU,MAAM;AAEpB,UAAM,gBAAgB,iBAAiB;AACvC,kBAAc,aAAa;AAC3B,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO;AACT","sourcesContent":["import { kInternal, stringify } from \"@liveblocks/core\";\nimport React from \"react\";\n\nimport { useClient } from \"./liveblocks\";\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 client = useClient();\n\n const [mentionSuggestions, setMentionSuggestions] =\n React.useState<string[]>();\n const lastInvokedAt = React.useRef<number>();\n\n React.useEffect(() => {\n const mentionSuggestionsCache = client[kInternal].mentionSuggestionsCache;\n const resolveMentionSuggestions =\n client[kInternal].resolveMentionSuggestions;\n\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId };\n const mentionSuggestionsCacheKey = stringify(resolveMentionSuggestionsArgs);\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 }, [client, search, roomId]);\n\n return mentionSuggestions;\n}\n","import type { SyncSource } from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport React from \"react\";\n\nimport { useClient } from \"./liveblocks\";\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] = React.useState<SyncSource | undefined>();\n\n React.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":["../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"names":["mentionSuggestions","kInternal","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,iBAAiB;AACrC,OAAO,WAAW;AAIlB,IAAM,+BAA+B;AAQ9B,SAAS,sBAAsB,QAAgB,QAAiB;AACrE,QAAM,SAAS,UAAU;AAEzB,QAAM,CAAC,oBAAoB,qBAAqB,IAC9C,MAAM,SAAmB;AAC3B,QAAM,gBAAgB,MAAM,OAAe;AAE3C,QAAM,UAAU,MAAM;AACpB,UAAM,0BAA0B,OAAO,SAAS,EAAE;AAClD,UAAM,4BACJ,OAAO,SAAS,EAAE;AAEpB,QAAI,WAAW,UAAa,CAAC,2BAA2B;AACtD;AAAA,IACF;AAEA,UAAM,gCAAgC,EAAE,MAAM,QAAQ,OAAO;AAC7D,UAAM,6BAA6B,UAAU,6BAA6B;AAC1E,QAAI;AACJ,QAAI,aAAa;AAEjB,UAAM,wBAAwB,YAAY;AACxC,UAAI;AACF,sBAAc,UAAU,YAAY,IAAI;AACxC,cAAMA,sBAAqB,MAAM;AAAA,UAC/B;AAAA,QACF;AAEA,YAAI,CAAC,YAAY;AACf,gCAAsBA,mBAAkB;AACxC,kCAAwB;AAAA,YACtB;AAAA,YACAA;AAAA,UACF;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAO,OAAiB,OAAO;AAAA,MACzC;AAAA,IACF;AAEA,QAAI,wBAAwB,IAAI,0BAA0B,GAAG;AAE3D;AAAA,QACE,wBAAwB,IAAI,0BAA0B;AAAA,MACxD;AAAA,IACF,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,MAAM,CAAC;AAE3B,SAAO;AACT;;;AC/EA,SAAS,aAAAC,kBAAiB;AAC1B,OAAOC,YAAW;AAOX,SAAS,gBAAwC;AACtD,QAAM,SAAS,UAAU;AACzB,QAAM,mBAAmB,OAAOD,UAAS,EAAE;AAC3C,QAAM,CAAC,YAAY,aAAa,IAAIC,OAAM,SAAiC;AAE3E,EAAAA,OAAM,UAAU,MAAM;AAEpB,UAAM,gBAAgB,iBAAiB;AACvC,kBAAc,aAAa;AAC3B,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO;AACT","sourcesContent":["import { kInternal, stringify } from \"@liveblocks/core\";\nimport React from \"react\";\n\nimport { useClient } from \"./liveblocks\";\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 client = useClient();\n\n const [mentionSuggestions, setMentionSuggestions] =\n React.useState<string[]>();\n const lastInvokedAt = React.useRef<number>();\n\n React.useEffect(() => {\n const mentionSuggestionsCache = client[kInternal].mentionSuggestionsCache;\n const resolveMentionSuggestions =\n client[kInternal].resolveMentionSuggestions;\n\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId };\n const mentionSuggestionsCacheKey = stringify(resolveMentionSuggestionsArgs);\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 }, [client, search, roomId]);\n\n return mentionSuggestions;\n}\n","import type { SyncSource } from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport React from \"react\";\n\nimport { useClient } from \"./liveblocks\";\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] = React.useState<SyncSource | undefined>();\n\n React.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"]}
package/dist/_private.mjs CHANGED
@@ -14,10 +14,11 @@ import {
14
14
  useMarkRoomThreadAsResolved,
15
15
  useMarkRoomThreadAsUnresolved,
16
16
  useRemoveRoomCommentReaction,
17
+ useReportTextEditor,
17
18
  useRoomAttachmentUrl,
18
19
  useRoomOrNull,
19
20
  useRoomPermissions
20
- } from "./chunk-C6WQQPFA.mjs";
21
+ } from "./chunk-BRCWZCNY.mjs";
21
22
 
22
23
  // src/use-mention-suggestions.ts
23
24
  import { kInternal, stringify } from "@liveblocks/core";
@@ -103,6 +104,7 @@ export {
103
104
  useMarkRoomThreadAsUnresolved,
104
105
  useMentionSuggestions,
105
106
  useRemoveRoomCommentReaction,
107
+ useReportTextEditor,
106
108
  useRoomAttachmentUrl,
107
109
  useRoomOrNull,
108
110
  useRoomPermissions,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"sourcesContent":["import { kInternal, stringify } from \"@liveblocks/core\";\nimport React from \"react\";\n\nimport { useClient } from \"./liveblocks\";\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 client = useClient();\n\n const [mentionSuggestions, setMentionSuggestions] =\n React.useState<string[]>();\n const lastInvokedAt = React.useRef<number>();\n\n React.useEffect(() => {\n const mentionSuggestionsCache = client[kInternal].mentionSuggestionsCache;\n const resolveMentionSuggestions =\n client[kInternal].resolveMentionSuggestions;\n\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId };\n const mentionSuggestionsCacheKey = stringify(resolveMentionSuggestionsArgs);\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 }, [client, search, roomId]);\n\n return mentionSuggestions;\n}\n","import type { SyncSource } from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport React from \"react\";\n\nimport { useClient } from \"./liveblocks\";\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] = React.useState<SyncSource | undefined>();\n\n React.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":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,iBAAiB;AACrC,OAAO,WAAW;AAIlB,IAAM,+BAA+B;AAQ9B,SAAS,sBAAsB,QAAgB,QAAiB;AACrE,QAAM,SAAS,UAAU;AAEzB,QAAM,CAAC,oBAAoB,qBAAqB,IAC9C,MAAM,SAAmB;AAC3B,QAAM,gBAAgB,MAAM,OAAe;AAE3C,QAAM,UAAU,MAAM;AACpB,UAAM,0BAA0B,OAAO,SAAS,EAAE;AAClD,UAAM,4BACJ,OAAO,SAAS,EAAE;AAEpB,QAAI,WAAW,UAAa,CAAC,2BAA2B;AACtD;AAAA,IACF;AAEA,UAAM,gCAAgC,EAAE,MAAM,QAAQ,OAAO;AAC7D,UAAM,6BAA6B,UAAU,6BAA6B;AAC1E,QAAI;AACJ,QAAI,aAAa;AAEjB,UAAM,wBAAwB,YAAY;AACxC,UAAI;AACF,sBAAc,UAAU,YAAY,IAAI;AACxC,cAAMA,sBAAqB,MAAM;AAAA,UAC/B;AAAA,QACF;AAEA,YAAI,CAAC,YAAY;AACf,gCAAsBA,mBAAkB;AACxC,kCAAwB;AAAA,YACtB;AAAA,YACAA;AAAA,UACF;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAO,OAAiB,OAAO;AAAA,MACzC;AAAA,IACF;AAEA,QAAI,wBAAwB,IAAI,0BAA0B,GAAG;AAE3D;AAAA,QACE,wBAAwB,IAAI,0BAA0B;AAAA,MACxD;AAAA,IACF,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,MAAM,CAAC;AAE3B,SAAO;AACT;;;AC/EA,SAAS,aAAAC,kBAAiB;AAC1B,OAAOC,YAAW;AAOX,SAAS,gBAAwC;AACtD,QAAM,SAAS,UAAU;AACzB,QAAM,mBAAmB,OAAOC,UAAS,EAAE;AAC3C,QAAM,CAAC,YAAY,aAAa,IAAIC,OAAM,SAAiC;AAE3E,EAAAA,OAAM,UAAU,MAAM;AAEpB,UAAM,gBAAgB,iBAAiB;AACvC,kBAAc,aAAa;AAC3B,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO;AACT;","names":["mentionSuggestions","kInternal","React","kInternal","React"]}
1
+ {"version":3,"sources":["../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"sourcesContent":["import { kInternal, stringify } from \"@liveblocks/core\";\nimport React from \"react\";\n\nimport { useClient } from \"./liveblocks\";\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 client = useClient();\n\n const [mentionSuggestions, setMentionSuggestions] =\n React.useState<string[]>();\n const lastInvokedAt = React.useRef<number>();\n\n React.useEffect(() => {\n const mentionSuggestionsCache = client[kInternal].mentionSuggestionsCache;\n const resolveMentionSuggestions =\n client[kInternal].resolveMentionSuggestions;\n\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId };\n const mentionSuggestionsCacheKey = stringify(resolveMentionSuggestionsArgs);\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 }, [client, search, roomId]);\n\n return mentionSuggestions;\n}\n","import type { SyncSource } from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport React from \"react\";\n\nimport { useClient } from \"./liveblocks\";\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] = React.useState<SyncSource | undefined>();\n\n React.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":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,iBAAiB;AACrC,OAAO,WAAW;AAIlB,IAAM,+BAA+B;AAQ9B,SAAS,sBAAsB,QAAgB,QAAiB;AACrE,QAAM,SAAS,UAAU;AAEzB,QAAM,CAAC,oBAAoB,qBAAqB,IAC9C,MAAM,SAAmB;AAC3B,QAAM,gBAAgB,MAAM,OAAe;AAE3C,QAAM,UAAU,MAAM;AACpB,UAAM,0BAA0B,OAAO,SAAS,EAAE;AAClD,UAAM,4BACJ,OAAO,SAAS,EAAE;AAEpB,QAAI,WAAW,UAAa,CAAC,2BAA2B;AACtD;AAAA,IACF;AAEA,UAAM,gCAAgC,EAAE,MAAM,QAAQ,OAAO;AAC7D,UAAM,6BAA6B,UAAU,6BAA6B;AAC1E,QAAI;AACJ,QAAI,aAAa;AAEjB,UAAM,wBAAwB,YAAY;AACxC,UAAI;AACF,sBAAc,UAAU,YAAY,IAAI;AACxC,cAAMA,sBAAqB,MAAM;AAAA,UAC/B;AAAA,QACF;AAEA,YAAI,CAAC,YAAY;AACf,gCAAsBA,mBAAkB;AACxC,kCAAwB;AAAA,YACtB;AAAA,YACAA;AAAA,UACF;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAO,OAAiB,OAAO;AAAA,MACzC;AAAA,IACF;AAEA,QAAI,wBAAwB,IAAI,0BAA0B,GAAG;AAE3D;AAAA,QACE,wBAAwB,IAAI,0BAA0B;AAAA,MACxD;AAAA,IACF,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,MAAM,CAAC;AAE3B,SAAO;AACT;;;AC/EA,SAAS,aAAAC,kBAAiB;AAC1B,OAAOC,YAAW;AAOX,SAAS,gBAAwC;AACtD,QAAM,SAAS,UAAU;AACzB,QAAM,mBAAmB,OAAOC,UAAS,EAAE;AAC3C,QAAM,CAAC,YAAY,aAAa,IAAIC,OAAM,SAAiC;AAE3E,EAAAA,OAAM,UAAU,MAAM;AAEpB,UAAM,gBAAgB,iBAAiB;AACvC,kBAAc,aAAa;AAC3B,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO;AACT;","names":["mentionSuggestions","kInternal","React","kInternal","React"]}
@@ -2734,6 +2734,22 @@ function useStatus() {
2734
2734
  const getServerSnapshot = room.getStatus;
2735
2735
  return useSyncExternalStore2(subscribe, getSnapshot, getServerSnapshot);
2736
2736
  }
2737
+ function useReportTextEditor(editor, rootKey) {
2738
+ const isReported = React4.useRef(false);
2739
+ const room = useRoom();
2740
+ React4.useEffect(() => {
2741
+ if (isReported.current) {
2742
+ return;
2743
+ }
2744
+ const unsubscribe = room.events.status.subscribe((status) => {
2745
+ if (status === "connected" && !isReported.current) {
2746
+ isReported.current = true;
2747
+ void room[kInternal3].reportTextEditor(editor, rootKey);
2748
+ }
2749
+ });
2750
+ return unsubscribe;
2751
+ }, [room, editor, rootKey]);
2752
+ }
2737
2753
  function useStorageStatus(options) {
2738
2754
  const smooth = useInitial(options?.smooth ?? false);
2739
2755
  if (smooth) {
@@ -3921,6 +3937,7 @@ export {
3921
3937
  useSyncStatus,
3922
3938
  CreateThreadError,
3923
3939
  useStatus,
3940
+ useReportTextEditor,
3924
3941
  useStorageStatus,
3925
3942
  useBatch,
3926
3943
  useLostConnectionListener,
@@ -3991,4 +4008,4 @@ export {
3991
4008
  _useStorageRoot,
3992
4009
  _useUpdateMyPresence
3993
4010
  };
3994
- //# sourceMappingURL=chunk-C6WQQPFA.mjs.map
4011
+ //# sourceMappingURL=chunk-BRCWZCNY.mjs.map