@liveblocks/react 2.12.1-emails1 → 2.12.1-test2

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 } from './liveblocks-1ujmr05d.mjs';
1
+ export { C as CreateThreadError, g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, b as useCreateRoomComment, c as useCreateRoomThread, d as useDeleteRoomComment, e as useDeleteRoomThread, f as useEditRoomComment, h as useEditRoomThreadMetadata, i as useMarkRoomThreadAsRead, j as useMarkRoomThreadAsResolved, k as useMarkRoomThreadAsUnresolved, l as useRemoveRoomCommentReaction, m as useRoomAttachmentUrl, u as useRoomOrNull, n as useRoomPermissions } from './room-t_BUxm1-.mjs';
2
2
  import { SyncSource } from '@liveblocks/core';
3
3
  import '@liveblocks/client';
4
4
  import 'react';
@@ -9,7 +9,7 @@ import 'react';
9
9
  * Simplistic debounced search, we don't need to worry too much about deduping
10
10
  * and race conditions as there can only be one search at a time.
11
11
  */
12
- declare function useMentionSuggestions(search?: string): string[] | undefined;
12
+ declare function useMentionSuggestions(roomId: string, search?: string): string[] | undefined;
13
13
 
14
14
  /**
15
15
  * @private For internal use only. Do not rely on this hook.
@@ -1,4 +1,4 @@
1
- export { C as CreateThreadError, g as getUmbrellaStoreForClient } from './liveblocks-1ujmr05d.js';
1
+ export { C as CreateThreadError, g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, b as useCreateRoomComment, c as useCreateRoomThread, d as useDeleteRoomComment, e as useDeleteRoomThread, f as useEditRoomComment, h as useEditRoomThreadMetadata, i as useMarkRoomThreadAsRead, j as useMarkRoomThreadAsResolved, k as useMarkRoomThreadAsUnresolved, l as useRemoveRoomCommentReaction, m as useRoomAttachmentUrl, u as useRoomOrNull, n as useRoomPermissions } from './room-t_BUxm1-.js';
2
2
  import { SyncSource } from '@liveblocks/core';
3
3
  import '@liveblocks/client';
4
4
  import 'react';
@@ -9,7 +9,7 @@ import 'react';
9
9
  * Simplistic debounced search, we don't need to worry too much about deduping
10
10
  * and race conditions as there can only be one search at a time.
11
11
  */
12
- declare function useMentionSuggestions(search?: string): string[] | undefined;
12
+ declare function useMentionSuggestions(roomId: string, search?: string): string[] | undefined;
13
13
 
14
14
  /**
15
15
  * @private For internal use only. Do not rely on this hook.
package/dist/_private.js CHANGED
@@ -3,15 +3,27 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkIACZPXTYjs = require('./chunk-IACZPXTY.js');
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ var _chunkHVOJBD7Xjs = require('./chunk-HVOJBD7X.js');
7
20
 
8
21
  // src/use-mention-suggestions.ts
9
22
  var _core = require('@liveblocks/core');
10
23
  var _react = require('react'); var _react2 = _interopRequireDefault(_react);
11
24
  var MENTION_SUGGESTIONS_DEBOUNCE = 500;
12
- function useMentionSuggestions(search) {
13
- const client = _chunkIACZPXTYjs.useClient.call(void 0, );
14
- const room = _chunkIACZPXTYjs._useRoom.call(void 0, );
25
+ function useMentionSuggestions(roomId, search) {
26
+ const client = _chunkHVOJBD7Xjs.useClient.call(void 0, );
15
27
  const [mentionSuggestions, setMentionSuggestions] = _react2.default.useState();
16
28
  const lastInvokedAt = _react2.default.useRef();
17
29
  _react2.default.useEffect(() => {
@@ -20,7 +32,7 @@ function useMentionSuggestions(search) {
20
32
  if (search === void 0 || !resolveMentionSuggestions) {
21
33
  return;
22
34
  }
23
- const resolveMentionSuggestionsArgs = { text: search, roomId: room.id };
35
+ const resolveMentionSuggestionsArgs = { text: search, roomId };
24
36
  const mentionSuggestionsCacheKey = _core.stringify.call(void 0, resolveMentionSuggestionsArgs);
25
37
  let debounceTimeout;
26
38
  let isCanceled = false;
@@ -56,7 +68,7 @@ function useMentionSuggestions(search) {
56
68
  isCanceled = true;
57
69
  window.clearTimeout(debounceTimeout);
58
70
  };
59
- }, [client, room.id, search]);
71
+ }, [client, search, roomId]);
60
72
  return mentionSuggestions;
61
73
  }
62
74
 
@@ -64,7 +76,7 @@ function useMentionSuggestions(search) {
64
76
 
65
77
 
66
78
  function useSyncSource() {
67
- const client = _chunkIACZPXTYjs.useClient.call(void 0, );
79
+ const client = _chunkHVOJBD7Xjs.useClient.call(void 0, );
68
80
  const createSyncSource = client[_core.kInternal].createSyncSource;
69
81
  const [syncSource, setSyncSource] = _react2.default.useState();
70
82
  _react2.default.useEffect(() => {
@@ -79,5 +91,19 @@ function useSyncSource() {
79
91
 
80
92
 
81
93
 
82
- exports.CreateThreadError = _chunkIACZPXTYjs.CreateThreadError; exports.getUmbrellaStoreForClient = _chunkIACZPXTYjs.getUmbrellaStoreForClient; exports.useMentionSuggestions = useMentionSuggestions; exports.useSyncSource = useSyncSource;
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ exports.CreateThreadError = _chunkHVOJBD7Xjs.CreateThreadError; exports.getUmbrellaStoreForClient = _chunkHVOJBD7Xjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkHVOJBD7Xjs.useAddRoomCommentReaction; exports.useCreateRoomComment = _chunkHVOJBD7Xjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkHVOJBD7Xjs.useCreateRoomThread; exports.useDeleteRoomComment = _chunkHVOJBD7Xjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkHVOJBD7Xjs.useDeleteRoomThread; exports.useEditRoomComment = _chunkHVOJBD7Xjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkHVOJBD7Xjs.useEditRoomThreadMetadata; exports.useMarkRoomThreadAsRead = _chunkHVOJBD7Xjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkHVOJBD7Xjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkHVOJBD7Xjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useRemoveRoomCommentReaction = _chunkHVOJBD7Xjs.useRemoveRoomCommentReaction; exports.useRoomAttachmentUrl = _chunkHVOJBD7Xjs.useRoomAttachmentUrl; exports.useRoomOrNull = _chunkHVOJBD7Xjs.useRoomOrNull; exports.useRoomPermissions = _chunkHVOJBD7Xjs.useRoomPermissions; exports.useSyncSource = useSyncSource;
83
109
  //# 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;AAKlB,IAAM,+BAA+B;AAQ9B,SAAS,sBAAsB,QAAiB;AACrD,QAAM,SAAS,UAAU;AAEzB,QAAM,OAAO,SAAQ;AACrB,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,QAAQ,KAAK,GAAG;AACtE,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,KAAK,IAAI,MAAM,CAAC;AAE5B,SAAO;AACT;;;ACjFA,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\";\nimport { useRoom } 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(search?: string) {\n const client = useClient();\n\n const room = useRoom();\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: room.id };\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, room.id, search]);\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
@@ -1,17 +1,29 @@
1
1
  import {
2
2
  CreateThreadError,
3
- _useRoom,
4
3
  getUmbrellaStoreForClient,
5
- useClient
6
- } from "./chunk-CX62YECU.mjs";
4
+ useAddRoomCommentReaction,
5
+ useClient,
6
+ useCreateRoomComment,
7
+ useCreateRoomThread,
8
+ useDeleteRoomComment,
9
+ useDeleteRoomThread,
10
+ useEditRoomComment,
11
+ useEditRoomThreadMetadata,
12
+ useMarkRoomThreadAsRead,
13
+ useMarkRoomThreadAsResolved,
14
+ useMarkRoomThreadAsUnresolved,
15
+ useRemoveRoomCommentReaction,
16
+ useRoomAttachmentUrl,
17
+ useRoomOrNull,
18
+ useRoomPermissions
19
+ } from "./chunk-SEMVNYPJ.mjs";
7
20
 
8
21
  // src/use-mention-suggestions.ts
9
22
  import { kInternal, stringify } from "@liveblocks/core";
10
23
  import React from "react";
11
24
  var MENTION_SUGGESTIONS_DEBOUNCE = 500;
12
- function useMentionSuggestions(search) {
25
+ function useMentionSuggestions(roomId, search) {
13
26
  const client = useClient();
14
- const room = _useRoom();
15
27
  const [mentionSuggestions, setMentionSuggestions] = React.useState();
16
28
  const lastInvokedAt = React.useRef();
17
29
  React.useEffect(() => {
@@ -20,7 +32,7 @@ function useMentionSuggestions(search) {
20
32
  if (search === void 0 || !resolveMentionSuggestions) {
21
33
  return;
22
34
  }
23
- const resolveMentionSuggestionsArgs = { text: search, roomId: room.id };
35
+ const resolveMentionSuggestionsArgs = { text: search, roomId };
24
36
  const mentionSuggestionsCacheKey = stringify(resolveMentionSuggestionsArgs);
25
37
  let debounceTimeout;
26
38
  let isCanceled = false;
@@ -56,7 +68,7 @@ function useMentionSuggestions(search) {
56
68
  isCanceled = true;
57
69
  window.clearTimeout(debounceTimeout);
58
70
  };
59
- }, [client, room.id, search]);
71
+ }, [client, search, roomId]);
60
72
  return mentionSuggestions;
61
73
  }
62
74
 
@@ -77,7 +89,21 @@ function useSyncSource() {
77
89
  export {
78
90
  CreateThreadError,
79
91
  getUmbrellaStoreForClient,
92
+ useAddRoomCommentReaction,
93
+ useCreateRoomComment,
94
+ useCreateRoomThread,
95
+ useDeleteRoomComment,
96
+ useDeleteRoomThread,
97
+ useEditRoomComment,
98
+ useEditRoomThreadMetadata,
99
+ useMarkRoomThreadAsRead,
100
+ useMarkRoomThreadAsResolved,
101
+ useMarkRoomThreadAsUnresolved,
80
102
  useMentionSuggestions,
103
+ useRemoveRoomCommentReaction,
104
+ useRoomAttachmentUrl,
105
+ useRoomOrNull,
106
+ useRoomPermissions,
81
107
  useSyncSource
82
108
  };
83
109
  //# 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\";\nimport { useRoom } 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(search?: string) {\n const client = useClient();\n\n const room = useRoom();\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: room.id };\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, room.id, search]);\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;AAKlB,IAAM,+BAA+B;AAQ9B,SAAS,sBAAsB,QAAiB;AACrD,QAAM,SAAS,UAAU;AAEzB,QAAM,OAAO,SAAQ;AACrB,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,QAAQ,KAAK,GAAG;AACtE,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,KAAK,IAAI,MAAM,CAAC;AAE5B,SAAO;AACT;;;ACjFA,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"]}