@liveblocks/react 2.18.3 → 2.18.4-uns2

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-IBC3TDQO.js → chunk-3Q3PQKVX.cjs} +2 -2
  8. package/dist/chunk-3Q3PQKVX.cjs.map +1 -0
  9. package/dist/{chunk-ZDS6KSNG.mjs → chunk-6WL36X3I.js} +2 -2
  10. package/dist/{chunk-5RVW253W.js → chunk-EC62ST5F.cjs} +29 -50
  11. package/dist/chunk-EC62ST5F.cjs.map +1 -0
  12. package/dist/{chunk-XU3ECI3P.mjs → chunk-OVSZW7FP.js} +13 -34
  13. package/dist/chunk-OVSZW7FP.js.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-6WL36X3I.js.map} +0 -0
package/dist/_private.mjs DELETED
@@ -1,131 +0,0 @@
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-XU3ECI3P.mjs";
28
-
29
- // src/lib/use-layout-effect.ts
30
- import { useEffect, useLayoutEffect as useOriginalLayoutEffect } from "react";
31
- var useLayoutEffect = typeof window !== "undefined" ? useOriginalLayoutEffect : useEffect;
32
-
33
- // src/use-mention-suggestions.ts
34
- import { stableStringify } from "@liveblocks/core";
35
- import { useEffect as useEffect2, useRef, useState } from "react";
36
- var MENTION_SUGGESTIONS_DEBOUNCE = 500;
37
- function useMentionSuggestions(roomId, search) {
38
- const [mentionSuggestions, setMentionSuggestions] = useState();
39
- const lastInvokedAt = useRef();
40
- const resolveMentionSuggestions = useResolveMentionSuggestions();
41
- const mentionSuggestionsCache = useMentionSuggestionsCache();
42
- useEffect2(() => {
43
- if (search === void 0 || !resolveMentionSuggestions) {
44
- return;
45
- }
46
- const resolveMentionSuggestionsArgs = { text: search, roomId };
47
- const mentionSuggestionsCacheKey = stableStringify(
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(error?.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
- import { kInternal } from "@liveblocks/core";
90
- import { useEffect as useEffect3, useState as useState2 } from "react";
91
- function useSyncSource() {
92
- const client = useClient();
93
- const createSyncSource = client[kInternal].createSyncSource;
94
- const [syncSource, setSyncSource] = useState2();
95
- useEffect3(() => {
96
- const newSyncSource = createSyncSource();
97
- setSyncSource(newSyncSource);
98
- return () => newSyncSource.destroy();
99
- }, [createSyncSource]);
100
- return syncSource;
101
- }
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
- //# sourceMappingURL=_private.mjs.map
@@ -1 +0,0 @@
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,kBAC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