@liveblocks/react 2.18.3 → 2.18.4-uns1

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.
Files changed (38) hide show
  1. package/dist/_private.cjs +131 -0
  2. package/dist/_private.cjs.map +1 -0
  3. package/dist/{_private.d.mts → _private.d.cts} +1 -1
  4. package/dist/_private.d.ts +1 -1
  5. package/dist/_private.js +73 -73
  6. package/dist/_private.js.map +1 -1
  7. package/dist/{chunk-5RVW253W.js → chunk-EC62ST5F.cjs} +29 -50
  8. package/dist/chunk-EC62ST5F.cjs.map +1 -0
  9. package/dist/{chunk-ZDS6KSNG.mjs → chunk-FKN4BSVX.js} +2 -2
  10. package/dist/{chunk-XU3ECI3P.mjs → chunk-OVSZW7FP.js} +13 -34
  11. package/dist/chunk-OVSZW7FP.js.map +1 -0
  12. package/dist/{chunk-IBC3TDQO.js → chunk-XFNPHHAO.cjs} +2 -2
  13. package/dist/chunk-XFNPHHAO.cjs.map +1 -0
  14. package/dist/index.cjs +145 -0
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/{index.d.mts → index.d.cts} +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +142 -142
  19. package/dist/index.js.map +1 -1
  20. package/dist/{room-Bf3S78LF.d.mts → room-1E8LCqCD.d.cts} +17 -0
  21. package/dist/{room-Bf3S78LF.d.ts → room-1E8LCqCD.d.ts} +17 -0
  22. package/dist/suspense.cjs +139 -0
  23. package/dist/suspense.cjs.map +1 -0
  24. package/dist/{suspense.d.mts → suspense.d.cts} +2 -2
  25. package/dist/suspense.d.ts +1 -1
  26. package/dist/suspense.js +136 -136
  27. package/dist/suspense.js.map +1 -1
  28. package/package.json +21 -21
  29. package/dist/_private.mjs +0 -131
  30. package/dist/_private.mjs.map +0 -1
  31. package/dist/chunk-5RVW253W.js.map +0 -1
  32. package/dist/chunk-IBC3TDQO.js.map +0 -1
  33. package/dist/chunk-XU3ECI3P.mjs.map +0 -1
  34. package/dist/index.mjs +0 -145
  35. package/dist/index.mjs.map +0 -1
  36. package/dist/suspense.mjs +0 -139
  37. package/dist/suspense.mjs.map +0 -1
  38. /package/dist/{chunk-ZDS6KSNG.mjs.map → chunk-FKN4BSVX.js.map} +0 -0
@@ -0,0 +1,131 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ var _chunkEC62ST5Fcjs = require('./chunk-EC62ST5F.cjs');
28
+
29
+ // src/lib/use-layout-effect.ts
30
+ var _react = require('react');
31
+ var useLayoutEffect = typeof window !== "undefined" ? _react.useLayoutEffect : _react.useEffect;
32
+
33
+ // src/use-mention-suggestions.ts
34
+ var _core = require('@liveblocks/core');
35
+
36
+ var MENTION_SUGGESTIONS_DEBOUNCE = 500;
37
+ function useMentionSuggestions(roomId, search) {
38
+ const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
39
+ const lastInvokedAt = _react.useRef.call(void 0, );
40
+ const resolveMentionSuggestions = _chunkEC62ST5Fcjs.useResolveMentionSuggestions.call(void 0, );
41
+ const mentionSuggestionsCache = _chunkEC62ST5Fcjs.useMentionSuggestionsCache.call(void 0, );
42
+ _react.useEffect.call(void 0, () => {
43
+ if (search === void 0 || !resolveMentionSuggestions) {
44
+ return;
45
+ }
46
+ const resolveMentionSuggestionsArgs = { text: search, roomId };
47
+ const mentionSuggestionsCacheKey = _core.stableStringify.call(void 0,
48
+ resolveMentionSuggestionsArgs
49
+ );
50
+ let debounceTimeout;
51
+ let isCanceled = false;
52
+ const getMentionSuggestions = async () => {
53
+ try {
54
+ lastInvokedAt.current = performance.now();
55
+ const mentionSuggestions2 = await resolveMentionSuggestions(
56
+ resolveMentionSuggestionsArgs
57
+ );
58
+ if (!isCanceled) {
59
+ setMentionSuggestions(mentionSuggestions2);
60
+ mentionSuggestionsCache.set(
61
+ mentionSuggestionsCacheKey,
62
+ mentionSuggestions2
63
+ );
64
+ }
65
+ } catch (error) {
66
+ console.error(_optionalChain([error, 'optionalAccess', _ => _.message]));
67
+ }
68
+ };
69
+ if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {
70
+ setMentionSuggestions(
71
+ mentionSuggestionsCache.get(mentionSuggestionsCacheKey)
72
+ );
73
+ } else if (!lastInvokedAt.current || Math.abs(performance.now() - lastInvokedAt.current) > MENTION_SUGGESTIONS_DEBOUNCE) {
74
+ void getMentionSuggestions();
75
+ } else {
76
+ debounceTimeout = window.setTimeout(() => {
77
+ void getMentionSuggestions();
78
+ }, MENTION_SUGGESTIONS_DEBOUNCE);
79
+ }
80
+ return () => {
81
+ isCanceled = true;
82
+ window.clearTimeout(debounceTimeout);
83
+ };
84
+ }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);
85
+ return mentionSuggestions;
86
+ }
87
+
88
+ // src/use-sync-source.ts
89
+
90
+
91
+ function useSyncSource() {
92
+ const client = _chunkEC62ST5Fcjs.useClient.call(void 0, );
93
+ const createSyncSource = client[_core.kInternal].createSyncSource;
94
+ const [syncSource, setSyncSource] = _react.useState.call(void 0, );
95
+ _react.useEffect.call(void 0, () => {
96
+ const newSyncSource = createSyncSource();
97
+ setSyncSource(newSyncSource);
98
+ return () => newSyncSource.destroy();
99
+ }, [createSyncSource]);
100
+ return syncSource;
101
+ }
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+ exports.getUmbrellaStoreForClient = _chunkEC62ST5Fcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkEC62ST5Fcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkEC62ST5Fcjs.useClientOrNull; exports.useCreateRoomComment = _chunkEC62ST5Fcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkEC62ST5Fcjs.useCreateRoomThread; exports.useCreateTextMention = _chunkEC62ST5Fcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkEC62ST5Fcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkEC62ST5Fcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkEC62ST5Fcjs.useDeleteTextMention; exports.useEditRoomComment = _chunkEC62ST5Fcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkEC62ST5Fcjs.useEditRoomThreadMetadata; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkEC62ST5Fcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkEC62ST5Fcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkEC62ST5Fcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkEC62ST5Fcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkEC62ST5Fcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkEC62ST5Fcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkEC62ST5Fcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkEC62ST5Fcjs.useRoomAttachmentUrl; exports.useRoomOrNull = _chunkEC62ST5Fcjs.useRoomOrNull; exports.useRoomPermissions = _chunkEC62ST5Fcjs.useRoomPermissions; exports.useSignal = _chunkEC62ST5Fcjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunkEC62ST5Fcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkEC62ST5Fcjs.useYjsProvider;
131
+ //# sourceMappingURL=_private.cjs.map
@@ -0,0 +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;A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A;AAAA,EACF,CAAA,EAAG,CAAC,MAAA,EAAQ,MAAA,EAAQ,yBAAA,EAA2B,uBAAuB,CAAC,CAAA;AAEvE,EAAA,OAAO,kBAAA;AACT;AFKA;AACA;AGtFA;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,g3DAAC","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 \"./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] = 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, 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-Bf3S78LF.mjs';
1
+ export { 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-1E8LCqCD.cjs';
2
2
  import { useLayoutEffect as useLayoutEffect$1 } from 'react';
3
3
  import { ISignal, SyncSource } from '@liveblocks/core';
4
4
  import '@liveblocks/client';
@@ -1,4 +1,4 @@
1
- export { 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-Bf3S78LF.js';
1
+ export { 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-1E8LCqCD.js';
2
2
  import { useLayoutEffect as useLayoutEffect$1 } from 'react';
3
3
  import { ISignal, SyncSource } from '@liveblocks/core';
4
4
  import '@liveblocks/client';
package/dist/_private.js CHANGED
@@ -1,50 +1,50 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
- var _chunk5RVW253Wjs = require('./chunk-5RVW253W.js');
1
+ import {
2
+ getUmbrellaStoreForClient,
3
+ useAddRoomCommentReaction,
4
+ useClient,
5
+ useClientOrNull,
6
+ useCreateRoomComment,
7
+ useCreateRoomThread,
8
+ useCreateTextMention,
9
+ useDeleteRoomComment,
10
+ useDeleteRoomThread,
11
+ useDeleteTextMention,
12
+ useEditRoomComment,
13
+ useEditRoomThreadMetadata,
14
+ useMarkRoomThreadAsRead,
15
+ useMarkRoomThreadAsResolved,
16
+ useMarkRoomThreadAsUnresolved,
17
+ useMentionSuggestionsCache,
18
+ useRemoveRoomCommentReaction,
19
+ useReportTextEditor,
20
+ useResolveMentionSuggestions,
21
+ useRoomAttachmentUrl,
22
+ useRoomOrNull,
23
+ useRoomPermissions,
24
+ useSignal,
25
+ useSyncExternalStoreWithSelector,
26
+ useYjsProvider
27
+ } from "./chunk-OVSZW7FP.js";
28
28
 
29
29
  // src/lib/use-layout-effect.ts
30
- var _react = require('react');
31
- var useLayoutEffect = typeof window !== "undefined" ? _react.useLayoutEffect : _react.useEffect;
30
+ import { useEffect, useLayoutEffect as useOriginalLayoutEffect } from "react";
31
+ var useLayoutEffect = typeof window !== "undefined" ? useOriginalLayoutEffect : useEffect;
32
32
 
33
33
  // src/use-mention-suggestions.ts
34
- var _core = require('@liveblocks/core');
35
-
34
+ import { stableStringify } from "@liveblocks/core";
35
+ import { useEffect as useEffect2, useRef, useState } from "react";
36
36
  var MENTION_SUGGESTIONS_DEBOUNCE = 500;
37
37
  function useMentionSuggestions(roomId, search) {
38
- const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
39
- const lastInvokedAt = _react.useRef.call(void 0, );
40
- const resolveMentionSuggestions = _chunk5RVW253Wjs.useResolveMentionSuggestions.call(void 0, );
41
- const mentionSuggestionsCache = _chunk5RVW253Wjs.useMentionSuggestionsCache.call(void 0, );
42
- _react.useEffect.call(void 0, () => {
38
+ const [mentionSuggestions, setMentionSuggestions] = useState();
39
+ const lastInvokedAt = useRef();
40
+ const resolveMentionSuggestions = useResolveMentionSuggestions();
41
+ const mentionSuggestionsCache = useMentionSuggestionsCache();
42
+ useEffect2(() => {
43
43
  if (search === void 0 || !resolveMentionSuggestions) {
44
44
  return;
45
45
  }
46
46
  const resolveMentionSuggestionsArgs = { text: search, roomId };
47
- const mentionSuggestionsCacheKey = _core.stableStringify.call(void 0,
47
+ const mentionSuggestionsCacheKey = stableStringify(
48
48
  resolveMentionSuggestionsArgs
49
49
  );
50
50
  let debounceTimeout;
@@ -63,7 +63,7 @@ function useMentionSuggestions(roomId, search) {
63
63
  );
64
64
  }
65
65
  } catch (error) {
66
- console.error(_optionalChain([error, 'optionalAccess', _ => _.message]));
66
+ console.error(error?.message);
67
67
  }
68
68
  };
69
69
  if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {
@@ -86,46 +86,46 @@ function useMentionSuggestions(roomId, search) {
86
86
  }
87
87
 
88
88
  // src/use-sync-source.ts
89
-
90
-
89
+ import { kInternal } from "@liveblocks/core";
90
+ import { useEffect as useEffect3, useState as useState2 } from "react";
91
91
  function useSyncSource() {
92
- const client = _chunk5RVW253Wjs.useClient.call(void 0, );
93
- const createSyncSource = client[_core.kInternal].createSyncSource;
94
- const [syncSource, setSyncSource] = _react.useState.call(void 0, );
95
- _react.useEffect.call(void 0, () => {
92
+ const client = useClient();
93
+ const createSyncSource = client[kInternal].createSyncSource;
94
+ const [syncSource, setSyncSource] = useState2();
95
+ useEffect3(() => {
96
96
  const newSyncSource = createSyncSource();
97
97
  setSyncSource(newSyncSource);
98
98
  return () => newSyncSource.destroy();
99
99
  }, [createSyncSource]);
100
100
  return syncSource;
101
101
  }
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
- exports.getUmbrellaStoreForClient = _chunk5RVW253Wjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunk5RVW253Wjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunk5RVW253Wjs.useClientOrNull; exports.useCreateRoomComment = _chunk5RVW253Wjs.useCreateRoomComment; exports.useCreateRoomThread = _chunk5RVW253Wjs.useCreateRoomThread; exports.useCreateTextMention = _chunk5RVW253Wjs.useCreateTextMention; exports.useDeleteRoomComment = _chunk5RVW253Wjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunk5RVW253Wjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunk5RVW253Wjs.useDeleteTextMention; exports.useEditRoomComment = _chunk5RVW253Wjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunk5RVW253Wjs.useEditRoomThreadMetadata; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunk5RVW253Wjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunk5RVW253Wjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunk5RVW253Wjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunk5RVW253Wjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunk5RVW253Wjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunk5RVW253Wjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunk5RVW253Wjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunk5RVW253Wjs.useRoomAttachmentUrl; exports.useRoomOrNull = _chunk5RVW253Wjs.useRoomOrNull; exports.useRoomPermissions = _chunk5RVW253Wjs.useRoomPermissions; exports.useSignal = _chunk5RVW253Wjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunk5RVW253Wjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunk5RVW253Wjs.useYjsProvider;
102
+ export {
103
+ getUmbrellaStoreForClient,
104
+ useAddRoomCommentReaction,
105
+ useClientOrNull,
106
+ useCreateRoomComment,
107
+ useCreateRoomThread,
108
+ useCreateTextMention,
109
+ useDeleteRoomComment,
110
+ useDeleteRoomThread,
111
+ useDeleteTextMention,
112
+ useEditRoomComment,
113
+ useEditRoomThreadMetadata,
114
+ useLayoutEffect,
115
+ useMarkRoomThreadAsRead,
116
+ useMarkRoomThreadAsResolved,
117
+ useMarkRoomThreadAsUnresolved,
118
+ useMentionSuggestions,
119
+ useMentionSuggestionsCache,
120
+ useRemoveRoomCommentReaction,
121
+ useReportTextEditor,
122
+ useResolveMentionSuggestions,
123
+ useRoomAttachmentUrl,
124
+ useRoomOrNull,
125
+ useRoomPermissions,
126
+ useSignal,
127
+ useSyncExternalStoreWithSelector,
128
+ useSyncSource,
129
+ useYjsProvider
130
+ };
131
131
  //# sourceMappingURL=_private.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/_private.js","../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,sDAA4B;AAC5B;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,E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C","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/_private.js","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 \"./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] = 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":["../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 \"./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] = 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,gCAAgC,EAAE,MAAM,QAAQ,OAAO;AAC7D,UAAM,6BAA6B;AAAA,MACjC;AAAA,IACF;AACA,QAAI;AACJ,QAAI,aAAa;AAEjB,UAAM,wBAAwB,YAAY;AACxC,UAAI;AACF,sBAAc,UAAU,YAAY,IAAI;AACxC,cAAMC,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,2BAA2B,uBAAuB,CAAC;AAEvE,SAAO;AACT;;;AChFA,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","mentionSuggestions","useEffect","useState","useState","useEffect"]}
@@ -258,7 +258,7 @@ function autobind(self) {
258
258
  for (const key of Reflect.ownKeys(obj)) {
259
259
  if (seen.has(key)) continue;
260
260
  const descriptor = Reflect.getOwnPropertyDescriptor(obj, key);
261
- if (typeof _optionalChain([descriptor, 'optionalAccess', _2 => _2.value]) === "function") {
261
+ if (typeof _optionalChain([descriptor, 'optionalAccess', _ => _.value]) === "function") {
262
262
  seen.add(key);
263
263
  self[key] = self[key].bind(self);
264
264
  }
@@ -358,7 +358,7 @@ var ThreadDB = class _ThreadDB {
358
358
  /** Returns an existing thread by ID. Will never return a deleted thread. */
359
359
  get(threadId) {
360
360
  const thread = this.getEvenIfDeleted(threadId);
361
- return _optionalChain([thread, 'optionalAccess', _3 => _3.deletedAt]) ? void 0 : thread;
361
+ return _optionalChain([thread, 'optionalAccess', _2 => _2.deletedAt]) ? void 0 : thread;
362
362
  }
363
363
  /** Returns the (possibly deleted) thread by ID. */
364
364
  getEvenIfDeleted(threadId) {
@@ -484,7 +484,7 @@ var PaginatedResource = class {
484
484
  }
485
485
  async #fetchMore() {
486
486
  const state = this.#signal.get();
487
- if (!_optionalChain([state, 'access', _4 => _4.data, 'optionalAccess', _5 => _5.cursor]) || state.data.isFetchingMore) {
487
+ if (!_optionalChain([state, 'access', _3 => _3.data, 'optionalAccess', _4 => _4.cursor]) || state.data.isFetchingMore) {
488
488
  return;
489
489
  }
490
490
  this.#patch({ isFetchingMore: true });
@@ -505,7 +505,7 @@ var PaginatedResource = class {
505
505
  }
506
506
  fetchMore() {
507
507
  const state = this.#signal.get();
508
- if (!_optionalChain([state, 'access', _6 => _6.data, 'optionalAccess', _7 => _7.cursor])) return noop2;
508
+ if (!_optionalChain([state, 'access', _5 => _5.data, 'optionalAccess', _6 => _6.cursor])) return noop2;
509
509
  if (!this.#pendingFetchMore) {
510
510
  this.#pendingFetchMore = this.#fetchMore().finally(() => {
511
511
  this.#pendingFetchMore = null;
@@ -731,14 +731,11 @@ function createStore_forPermissionHints() {
731
731
  };
732
732
  }
733
733
  function createStore_forUserNotificationSettings(updates) {
734
- const signal = new (0, _core.Signal)({});
734
+ const signal = new (0, _core.Signal)(
735
+ _core.createUserNotificationSettings.call(void 0, {})
736
+ );
735
737
  function update(settings) {
736
- signal.set((prevSettings) => {
737
- return {
738
- ...prevSettings,
739
- ...settings
740
- };
741
- });
738
+ signal.set(settings);
742
739
  }
743
740
  return {
744
741
  signal: _core.DerivedSignal.from(
@@ -1499,32 +1496,14 @@ function applyOptimisticUpdates_forSettings(settingsLUT, optimisticUpdates) {
1499
1496
  }
1500
1497
  return settingsByRoomId;
1501
1498
  }
1502
- function applyOptimisticUpdates_forUserNotificationSettings(baseSettings, optimisticUpdates) {
1503
- const outcomingSettings = { ...baseSettings };
1504
- for (const optimisticUpdate of optimisticUpdates) {
1505
- switch (optimisticUpdate.type) {
1506
- case "update-user-notification-settings": {
1507
- const incomingSettings = optimisticUpdate.settings;
1508
- for (const channelKey of _core.keys.call(void 0, incomingSettings)) {
1509
- const key = channelKey;
1510
- const channelUpdates = incomingSettings[key];
1511
- if (channelUpdates) {
1512
- const realChannelUpdates = Object.fromEntries(
1513
- _core.entries.call(void 0, channelUpdates).filter(
1514
- ([_, value]) => value !== void 0
1515
- )
1516
- );
1517
- outcomingSettings[key] = {
1518
- ...outcomingSettings[key],
1519
- ...realChannelUpdates
1520
- };
1521
- }
1522
- }
1523
- break;
1524
- }
1499
+ function applyOptimisticUpdates_forUserNotificationSettings(settings, optimisticUpdates) {
1500
+ let outcoming = settings;
1501
+ for (const update of optimisticUpdates) {
1502
+ if (update.type === "update-user-notification-settings") {
1503
+ outcoming = _core.patchUserNotificationSettings.call(void 0, outcoming, update.settings);
1525
1504
  }
1526
1505
  }
1527
- return outcomingSettings;
1506
+ return outcoming;
1528
1507
  }
1529
1508
  function compareInboxNotifications(inboxNotificationA, inboxNotificationB) {
1530
1509
  if (inboxNotificationA.notifiedAt > inboxNotificationB.notifiedAt) {
@@ -1575,7 +1554,7 @@ function applyUpsertComment(thread, comment) {
1575
1554
  updatedAt: new Date(
1576
1555
  Math.max(
1577
1556
  thread.updatedAt.getTime(),
1578
- _optionalChain([comment, 'access', _8 => _8.editedAt, 'optionalAccess', _9 => _9.getTime, 'call', _10 => _10()]) || comment.createdAt.getTime()
1557
+ _optionalChain([comment, 'access', _7 => _7.editedAt, 'optionalAccess', _8 => _8.getTime, 'call', _9 => _9()]) || comment.createdAt.getTime()
1579
1558
  )
1580
1559
  ),
1581
1560
  comments: updatedComments
@@ -1734,7 +1713,7 @@ function selectorFor_useUnreadInboxNotificationsCount(result) {
1734
1713
  );
1735
1714
  }
1736
1715
  function selectorFor_useUser(state, userId) {
1737
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _11 => _11.isLoading])) {
1716
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _10 => _10.isLoading])) {
1738
1717
  return _nullishCoalesce(state, () => ( { isLoading: true }));
1739
1718
  }
1740
1719
  if (state.error) {
@@ -1752,7 +1731,7 @@ function selectorFor_useUser(state, userId) {
1752
1731
  };
1753
1732
  }
1754
1733
  function selectorFor_useRoomInfo(state, roomId) {
1755
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _12 => _12.isLoading])) {
1734
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _11 => _11.isLoading])) {
1756
1735
  return _nullishCoalesce(state, () => ( { isLoading: true }));
1757
1736
  }
1758
1737
  if (state.error) {
@@ -2079,7 +2058,7 @@ function useUpdateNotificationSettings_withClient(client) {
2079
2058
  store.optimisticUpdates.remove(optimisticUpdateId);
2080
2059
  if (err instanceof _core.HttpError) {
2081
2060
  if (err.status === 422) {
2082
- const msg = [_optionalChain([err, 'access', _13 => _13.details, 'optionalAccess', _14 => _14.error]), _optionalChain([err, 'access', _15 => _15.details, 'optionalAccess', _16 => _16.reason])].filter(Boolean).join("\n");
2061
+ const msg = [_optionalChain([err, 'access', _12 => _12.details, 'optionalAccess', _13 => _13.error]), _optionalChain([err, 'access', _14 => _14.details, 'optionalAccess', _15 => _15.reason])].filter(Boolean).join("\n");
2083
2062
  console.error(msg);
2084
2063
  }
2085
2064
  client[_core.kInternal].emitError(
@@ -2275,7 +2254,7 @@ function createSharedContext(client) {
2275
2254
  }
2276
2255
  function useEnsureNoLiveblocksProvider(options) {
2277
2256
  const existing = useClientOrNull();
2278
- if (!_optionalChain([options, 'optionalAccess', _17 => _17.allowNesting]) && existing !== null) {
2257
+ if (!_optionalChain([options, 'optionalAccess', _16 => _16.allowNesting]) && existing !== null) {
2279
2258
  throw new Error(
2280
2259
  "You cannot nest multiple LiveblocksProvider instances in the same React tree."
2281
2260
  );
@@ -2420,7 +2399,7 @@ var _useUserSuspense = useUserSuspense;
2420
2399
  var _useUserThreads_experimental = useUserThreads_experimental;
2421
2400
  var _useUserThreadsSuspense_experimental = useUserThreadsSuspense_experimental;
2422
2401
  function useSyncStatus_withClient(client, options) {
2423
- const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _18 => _18.smooth]), () => ( false)));
2402
+ const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _17 => _17.smooth]), () => ( false)));
2424
2403
  if (smooth) {
2425
2404
  return useSyncStatusSmooth_withClient(client);
2426
2405
  } else {
@@ -2598,8 +2577,8 @@ function makeRoomExtrasForClient(client) {
2598
2577
  if (innerError.status === 403) {
2599
2578
  const detailedMessage = [
2600
2579
  innerError.message,
2601
- _optionalChain([innerError, 'access', _19 => _19.details, 'optionalAccess', _20 => _20.suggestion]),
2602
- _optionalChain([innerError, 'access', _21 => _21.details, 'optionalAccess', _22 => _22.docs])
2580
+ _optionalChain([innerError, 'access', _18 => _18.details, 'optionalAccess', _19 => _19.suggestion]),
2581
+ _optionalChain([innerError, 'access', _20 => _20.details, 'optionalAccess', _21 => _21.docs])
2603
2582
  ].filter(Boolean).join("\n");
2604
2583
  _core.console.error(detailedMessage);
2605
2584
  }
@@ -2953,7 +2932,7 @@ function useMentionSuggestionsCache() {
2953
2932
  return client[_core.kInternal].mentionSuggestionsCache;
2954
2933
  }
2955
2934
  function useStorageStatus(options) {
2956
- const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _23 => _23.smooth]), () => ( false)));
2935
+ const smooth = useInitial(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.smooth]), () => ( false)));
2957
2936
  if (smooth) {
2958
2937
  return useStorageStatusSmooth();
2959
2938
  } else {
@@ -3267,7 +3246,7 @@ function useCreateRoomThread(roomId) {
3267
3246
  thread: newThread,
3268
3247
  roomId
3269
3248
  });
3270
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _24 => _24.map, 'call', _25 => _25((attachment) => attachment.id)]);
3249
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _23 => _23.map, 'call', _24 => _24((attachment) => attachment.id)]);
3271
3250
  client[_core.kInternal].httpClient.createThread({
3272
3251
  roomId,
3273
3252
  threadId,
@@ -3307,7 +3286,7 @@ function useDeleteRoomThread(roomId) {
3307
3286
  const { store, onMutationFailure } = getRoomExtrasForClient(client);
3308
3287
  const userId = getCurrentUserId(client);
3309
3288
  const existing = store.outputs.threads.get().get(threadId);
3310
- if (_optionalChain([existing, 'optionalAccess', _26 => _26.comments, 'optionalAccess', _27 => _27[0], 'optionalAccess', _28 => _28.userId]) !== userId) {
3289
+ if (_optionalChain([existing, 'optionalAccess', _25 => _25.comments, 'optionalAccess', _26 => _26[0], 'optionalAccess', _27 => _27.userId]) !== userId) {
3311
3290
  throw new Error("Only the thread creator can delete the thread");
3312
3291
  }
3313
3292
  const optimisticId = store.optimisticUpdates.add({
@@ -3395,7 +3374,7 @@ function useCreateRoomComment(roomId) {
3395
3374
  type: "create-comment",
3396
3375
  comment
3397
3376
  });
3398
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _29 => _29.map, 'call', _30 => _30((attachment) => attachment.id)]);
3377
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _28 => _28.map, 'call', _29 => _29((attachment) => attachment.id)]);
3399
3378
  client[_core.kInternal].httpClient.createComment({ roomId, threadId, commentId, body, attachmentIds }).then(
3400
3379
  (newComment) => {
3401
3380
  store.createComment(newComment, optimisticId);
@@ -3451,7 +3430,7 @@ function useEditRoomComment(roomId) {
3451
3430
  attachments: _nullishCoalesce(attachments, () => ( []))
3452
3431
  }
3453
3432
  });
3454
- const attachmentIds = _optionalChain([attachments, 'optionalAccess', _31 => _31.map, 'call', _32 => _32((attachment) => attachment.id)]);
3433
+ const attachmentIds = _optionalChain([attachments, 'optionalAccess', _30 => _30.map, 'call', _31 => _31((attachment) => attachment.id)]);
3455
3434
  client[_core.kInternal].httpClient.editComment({ roomId, threadId, commentId, body, attachmentIds }).then(
3456
3435
  (editedComment) => {
3457
3436
  store.editComment(threadId, optimisticId, editedComment);
@@ -3915,7 +3894,7 @@ function useThreadsSuspense(options = {}) {
3915
3894
  return result;
3916
3895
  }
3917
3896
  function selectorFor_useAttachmentUrl(state) {
3918
- if (state === void 0 || _optionalChain([state, 'optionalAccess', _33 => _33.isLoading])) {
3897
+ if (state === void 0 || _optionalChain([state, 'optionalAccess', _32 => _32.isLoading])) {
3919
3898
  return _nullishCoalesce(state, () => ( { isLoading: true }));
3920
3899
  }
3921
3900
  if (state.error) {
@@ -4134,4 +4113,4 @@ var _useUpdateMyPresence = useUpdateMyPresence;
4134
4113
 
4135
4114
 
4136
4115
  exports.RoomContext = RoomContext; exports.useRoomOrNull = useRoomOrNull; exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; exports.useSignal = useSignal; exports.ClientContext = ClientContext; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useClientOrNull = useClientOrNull; exports.useClient = useClient; exports.LiveblocksProvider = LiveblocksProvider; exports.createLiveblocksContext = createLiveblocksContext; exports.useInboxNotifications = useInboxNotifications; exports.useInboxNotificationsSuspense = useInboxNotificationsSuspense; exports.useMarkAllInboxNotificationsAsRead = useMarkAllInboxNotificationsAsRead; exports.useMarkInboxNotificationAsRead = useMarkInboxNotificationAsRead; exports.useDeleteAllInboxNotifications = useDeleteAllInboxNotifications; exports.useDeleteInboxNotification = useDeleteInboxNotification; exports.useUnreadInboxNotificationsCount = useUnreadInboxNotificationsCount; exports.useUnreadInboxNotificationsCountSuspense = useUnreadInboxNotificationsCountSuspense; exports.useNotificationSettings = useNotificationSettings; exports.useNotificationSettingsSuspense = useNotificationSettingsSuspense; exports.useUpdateNotificationSettings = useUpdateNotificationSettings; exports.useRoomInfo = useRoomInfo; exports.useRoomInfoSuspense = useRoomInfoSuspense; exports._useInboxNotificationThread = _useInboxNotificationThread; exports._useUser = _useUser; exports._useUserSuspense = _useUserSuspense; exports._useUserThreads_experimental = _useUserThreads_experimental; exports._useUserThreadsSuspense_experimental = _useUserThreadsSuspense_experimental; exports.useSyncStatus = useSyncStatus; exports.useErrorListener = useErrorListener; exports.useStatus = useStatus; exports.useReportTextEditor = useReportTextEditor; exports.useYjsProvider = useYjsProvider; exports.useCreateTextMention = useCreateTextMention; exports.useDeleteTextMention = useDeleteTextMention; exports.useResolveMentionSuggestions = useResolveMentionSuggestions; exports.useMentionSuggestionsCache = useMentionSuggestionsCache; exports.useStorageStatus = useStorageStatus; exports.useBatch = useBatch; exports.useLostConnectionListener = useLostConnectionListener; exports.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; exports.useCreateRoomThread = useCreateRoomThread; exports.useDeleteRoomThread = useDeleteRoomThread; exports.useEditRoomThreadMetadata = useEditRoomThreadMetadata; exports.useCreateComment = useCreateComment; exports.useCreateRoomComment = useCreateRoomComment; exports.useEditComment = useEditComment; exports.useEditRoomComment = useEditRoomComment; exports.useDeleteComment = useDeleteComment; exports.useDeleteRoomComment = useDeleteRoomComment; exports.useAddRoomCommentReaction = useAddRoomCommentReaction; exports.useRemoveReaction = useRemoveReaction; exports.useRemoveRoomCommentReaction = useRemoveRoomCommentReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkRoomThreadAsRead = useMarkRoomThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkRoomThreadAsResolved = useMarkRoomThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useMarkRoomThreadAsUnresolved = useMarkRoomThreadAsUnresolved; exports.useThreadSubscription = useThreadSubscription; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useStorageStatusSuspense = useStorageStatusSuspense; exports.useAttachmentUrl = useAttachmentUrl; exports.useRoomAttachmentUrl = useRoomAttachmentUrl; exports.useAttachmentUrlSuspense = useAttachmentUrlSuspense; exports.useRoomPermissions = useRoomPermissions; exports.createRoomContext = createRoomContext; exports._RoomProvider = _RoomProvider; exports._useBroadcastEvent = _useBroadcastEvent; exports._useOthersListener = _useOthersListener; exports._useRoom = _useRoom; exports._useIsInsideRoom = _useIsInsideRoom; exports._useAddReaction = _useAddReaction; exports._useMutation = _useMutation; exports._useCreateThread = _useCreateThread; exports._useDeleteThread = _useDeleteThread; exports._useEditThreadMetadata = _useEditThreadMetadata; exports._useEventListener = _useEventListener; exports._useMyPresence = _useMyPresence; exports._useOthersMapped = _useOthersMapped; exports._useOthersMappedSuspense = _useOthersMappedSuspense; exports._useThreads = _useThreads; exports._useThreadsSuspense = _useThreadsSuspense; exports._useRoomNotificationSettings = _useRoomNotificationSettings; exports._useRoomNotificationSettingsSuspense = _useRoomNotificationSettingsSuspense; exports._useHistoryVersions = _useHistoryVersions; exports._useHistoryVersionsSuspense = _useHistoryVersionsSuspense; exports._useOther = _useOther; exports._useOthers = _useOthers; exports._useOtherSuspense = _useOtherSuspense; exports._useOthersSuspense = _useOthersSuspense; exports._useStorage = _useStorage; exports._useStorageSuspense = _useStorageSuspense; exports._useSelf = _useSelf; exports._useSelfSuspense = _useSelfSuspense; exports._useStorageRoot = _useStorageRoot; exports._useUpdateMyPresence = _useUpdateMyPresence;
4137
- //# sourceMappingURL=chunk-5RVW253W.js.map
4116
+ //# sourceMappingURL=chunk-EC62ST5F.cjs.map