@liveblocks/react 2.13.3-emails1 → 2.14.0-v2encoding

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 useReportTextEditor, o as useRoomAttachmentUrl, u as useRoomOrNull, p as useRoomPermissions } from './room-Rl_QnQMY.mjs';
1
+ export { C as CreateThreadError, g as getUmbrellaStoreForClient, b as useAddRoomCommentReaction, a as useClientOrNull, c as useCreateRoomComment, d as useCreateRoomThread, e as useCreateTextMention, f as useDeleteRoomComment, h as useDeleteRoomThread, i as useDeleteTextMention, j as useEditRoomComment, k as useEditRoomThreadMetadata, l as useMarkRoomThreadAsRead, m as useMarkRoomThreadAsResolved, n as useMarkRoomThreadAsUnresolved, o as useMentionSuggestionsCache, p as useRemoveRoomCommentReaction, q as useReportTextEditor, r as useResolveMentionSuggestions, s as useRoomAttachmentUrl, u as useRoomOrNull, t as useRoomPermissions, v as useYjsProvider } from './room-gbqt3lTY.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 useReportTextEditor, o as useRoomAttachmentUrl, u as useRoomOrNull, p as useRoomPermissions } from './room-Rl_QnQMY.js';
1
+ export { C as CreateThreadError, g as getUmbrellaStoreForClient, b as useAddRoomCommentReaction, a as useClientOrNull, c as useCreateRoomComment, d as useCreateRoomThread, e as useCreateTextMention, f as useDeleteRoomComment, h as useDeleteRoomThread, i as useDeleteTextMention, j as useEditRoomComment, k as useEditRoomThreadMetadata, l as useMarkRoomThreadAsRead, m as useMarkRoomThreadAsResolved, n as useMarkRoomThreadAsUnresolved, o as useMentionSuggestionsCache, p as useRemoveRoomCommentReaction, q as useReportTextEditor, r as useResolveMentionSuggestions, s as useRoomAttachmentUrl, u as useRoomOrNull, t as useRoomPermissions, v as useYjsProvider } from './room-gbqt3lTY.js';
2
2
  import { SyncSource } from '@liveblocks/core';
3
3
  import '@liveblocks/client';
4
4
  import 'react';
package/dist/_private.js CHANGED
@@ -18,19 +18,23 @@
18
18
 
19
19
 
20
20
 
21
- var _chunkX4DDEZYLjs = require('./chunk-X4DDEZYL.js');
21
+
22
+
23
+
24
+
25
+
26
+ var _chunk7ZCTUIE6js = require('./chunk-7ZCTUIE6.js');
22
27
 
23
28
  // src/use-mention-suggestions.ts
24
29
  var _core = require('@liveblocks/core');
25
30
  var _react = require('react'); var _react2 = _interopRequireDefault(_react);
26
31
  var MENTION_SUGGESTIONS_DEBOUNCE = 500;
27
32
  function useMentionSuggestions(roomId, search) {
28
- const client = _chunkX4DDEZYLjs.useClient.call(void 0, );
29
33
  const [mentionSuggestions, setMentionSuggestions] = _react2.default.useState();
30
34
  const lastInvokedAt = _react2.default.useRef();
35
+ const resolveMentionSuggestions = _chunk7ZCTUIE6js.useResolveMentionSuggestions.call(void 0, );
36
+ const mentionSuggestionsCache = _chunk7ZCTUIE6js.useMentionSuggestionsCache.call(void 0, );
31
37
  _react2.default.useEffect(() => {
32
- const mentionSuggestionsCache = client[_core.kInternal].mentionSuggestionsCache;
33
- const resolveMentionSuggestions = client[_core.kInternal].resolveMentionSuggestions;
34
38
  if (search === void 0 || !resolveMentionSuggestions) {
35
39
  return;
36
40
  }
@@ -70,7 +74,7 @@ function useMentionSuggestions(roomId, search) {
70
74
  isCanceled = true;
71
75
  window.clearTimeout(debounceTimeout);
72
76
  };
73
- }, [client, search, roomId]);
77
+ }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);
74
78
  return mentionSuggestions;
75
79
  }
76
80
 
@@ -78,7 +82,7 @@ function useMentionSuggestions(roomId, search) {
78
82
 
79
83
 
80
84
  function useSyncSource() {
81
- const client = _chunkX4DDEZYLjs.useClient.call(void 0, );
85
+ const client = _chunk7ZCTUIE6js.useClient.call(void 0, );
82
86
  const createSyncSource = client[_core.kInternal].createSyncSource;
83
87
  const [syncSource, setSyncSource] = _react2.default.useState();
84
88
  _react2.default.useEffect(() => {
@@ -109,5 +113,10 @@ function useSyncSource() {
109
113
 
110
114
 
111
115
 
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;
116
+
117
+
118
+
119
+
120
+
121
+ exports.CreateThreadError = _chunk7ZCTUIE6js.CreateThreadError; exports.getUmbrellaStoreForClient = _chunk7ZCTUIE6js.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunk7ZCTUIE6js.useAddRoomCommentReaction; exports.useClientOrNull = _chunk7ZCTUIE6js.useClientOrNull; exports.useCreateRoomComment = _chunk7ZCTUIE6js.useCreateRoomComment; exports.useCreateRoomThread = _chunk7ZCTUIE6js.useCreateRoomThread; exports.useCreateTextMention = _chunk7ZCTUIE6js.useCreateTextMention; exports.useDeleteRoomComment = _chunk7ZCTUIE6js.useDeleteRoomComment; exports.useDeleteRoomThread = _chunk7ZCTUIE6js.useDeleteRoomThread; exports.useDeleteTextMention = _chunk7ZCTUIE6js.useDeleteTextMention; exports.useEditRoomComment = _chunk7ZCTUIE6js.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunk7ZCTUIE6js.useEditRoomThreadMetadata; exports.useMarkRoomThreadAsRead = _chunk7ZCTUIE6js.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunk7ZCTUIE6js.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunk7ZCTUIE6js.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunk7ZCTUIE6js.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunk7ZCTUIE6js.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunk7ZCTUIE6js.useReportTextEditor; exports.useResolveMentionSuggestions = _chunk7ZCTUIE6js.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunk7ZCTUIE6js.useRoomAttachmentUrl; exports.useRoomOrNull = _chunk7ZCTUIE6js.useRoomOrNull; exports.useRoomPermissions = _chunk7ZCTUIE6js.useRoomPermissions; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunk7ZCTUIE6js.useYjsProvider;
113
122
  //# 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":["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GAAG,CAAC,QAAQ,QAAQ,2BAA2B,uBAAuB,CAAC;AAEvE,SAAO;AACT;;;AC/EA,SAAS,iBAAiB;AAC1B,OAAOC,YAAW;AAOX,SAAS,gBAAwC;AACtD,QAAM,SAAS,UAAU;AACzB,QAAM,mBAAmB,OAAO,SAAS,EAAE;AAC3C,QAAM,CAAC,YAAY,aAAa,IAAIA,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 { stringify } from \"@liveblocks/core\";\nimport React 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] =\n React.useState<string[]>();\n const lastInvokedAt = React.useRef<number>();\n\n const resolveMentionSuggestions = useResolveMentionSuggestions();\n const mentionSuggestionsCache = useMentionSuggestionsCache();\n\n React.useEffect(() => {\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 }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);\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
@@ -6,31 +6,35 @@ import {
6
6
  useClientOrNull,
7
7
  useCreateRoomComment,
8
8
  useCreateRoomThread,
9
+ useCreateTextMention,
9
10
  useDeleteRoomComment,
10
11
  useDeleteRoomThread,
12
+ useDeleteTextMention,
11
13
  useEditRoomComment,
12
14
  useEditRoomThreadMetadata,
13
15
  useMarkRoomThreadAsRead,
14
16
  useMarkRoomThreadAsResolved,
15
17
  useMarkRoomThreadAsUnresolved,
18
+ useMentionSuggestionsCache,
16
19
  useRemoveRoomCommentReaction,
17
20
  useReportTextEditor,
21
+ useResolveMentionSuggestions,
18
22
  useRoomAttachmentUrl,
19
23
  useRoomOrNull,
20
- useRoomPermissions
21
- } from "./chunk-BRCWZCNY.mjs";
24
+ useRoomPermissions,
25
+ useYjsProvider
26
+ } from "./chunk-BYPL4Y26.mjs";
22
27
 
23
28
  // src/use-mention-suggestions.ts
24
- import { kInternal, stringify } from "@liveblocks/core";
29
+ import { stringify } from "@liveblocks/core";
25
30
  import React from "react";
26
31
  var MENTION_SUGGESTIONS_DEBOUNCE = 500;
27
32
  function useMentionSuggestions(roomId, search) {
28
- const client = useClient();
29
33
  const [mentionSuggestions, setMentionSuggestions] = React.useState();
30
34
  const lastInvokedAt = React.useRef();
35
+ const resolveMentionSuggestions = useResolveMentionSuggestions();
36
+ const mentionSuggestionsCache = useMentionSuggestionsCache();
31
37
  React.useEffect(() => {
32
- const mentionSuggestionsCache = client[kInternal].mentionSuggestionsCache;
33
- const resolveMentionSuggestions = client[kInternal].resolveMentionSuggestions;
34
38
  if (search === void 0 || !resolveMentionSuggestions) {
35
39
  return;
36
40
  }
@@ -70,16 +74,16 @@ function useMentionSuggestions(roomId, search) {
70
74
  isCanceled = true;
71
75
  window.clearTimeout(debounceTimeout);
72
76
  };
73
- }, [client, search, roomId]);
77
+ }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);
74
78
  return mentionSuggestions;
75
79
  }
76
80
 
77
81
  // src/use-sync-source.ts
78
- import { kInternal as kInternal2 } from "@liveblocks/core";
82
+ import { kInternal } from "@liveblocks/core";
79
83
  import React2 from "react";
80
84
  function useSyncSource() {
81
85
  const client = useClient();
82
- const createSyncSource = client[kInternal2].createSyncSource;
86
+ const createSyncSource = client[kInternal].createSyncSource;
83
87
  const [syncSource, setSyncSource] = React2.useState();
84
88
  React2.useEffect(() => {
85
89
  const newSyncSource = createSyncSource();
@@ -95,19 +99,24 @@ export {
95
99
  useClientOrNull,
96
100
  useCreateRoomComment,
97
101
  useCreateRoomThread,
102
+ useCreateTextMention,
98
103
  useDeleteRoomComment,
99
104
  useDeleteRoomThread,
105
+ useDeleteTextMention,
100
106
  useEditRoomComment,
101
107
  useEditRoomThreadMetadata,
102
108
  useMarkRoomThreadAsRead,
103
109
  useMarkRoomThreadAsResolved,
104
110
  useMarkRoomThreadAsUnresolved,
105
111
  useMentionSuggestions,
112
+ useMentionSuggestionsCache,
106
113
  useRemoveRoomCommentReaction,
107
114
  useReportTextEditor,
115
+ useResolveMentionSuggestions,
108
116
  useRoomAttachmentUrl,
109
117
  useRoomOrNull,
110
118
  useRoomPermissions,
111
- useSyncSource
119
+ useSyncSource,
120
+ useYjsProvider
112
121
  };
113
122
  //# sourceMappingURL=_private.mjs.map
@@ -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;AAC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AgB,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 { stringify } from \"@liveblocks/core\";\nimport React 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] =\n React.useState<string[]>();\n const lastInvokedAt = React.useRef<number>();\n\n const resolveMentionSuggestions = useResolveMentionSuggestions();\n const mentionSuggestionsCache = useMentionSuggestionsCache();\n\n React.useEffect(() => {\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 }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);\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,iBAAiB;AAC1B,OAAO,WAAW;AAOlB,IAAM,+BAA+B;AAQ9B,SAAS,sBAAsB,QAAgB,QAAiB;AACrE,QAAM,CAAC,oBAAoB,qBAAqB,IAC9C,MAAM,SAAmB;AAC3B,QAAM,gBAAgB,MAAM,OAAe;AAE3C,QAAM,4BAA4B,6BAA6B;AAC/D,QAAM,0BAA0B,2BAA2B;AAE3D,QAAM,UAAU,MAAM;AACpB,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;A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