@liveblocks/react 3.22.0-rc1 → 3.23.0-file1
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.
- package/dist/_private.cjs +9 -7
- package/dist/_private.cjs.map +1 -1
- package/dist/_private.d.cts +2 -2
- package/dist/_private.d.ts +2 -2
- package/dist/_private.js +3 -1
- package/dist/_private.js.map +1 -1
- package/dist/{chunk-YJ3VWMRC.js → chunk-B63FZ2MX.js} +2 -2
- package/dist/{chunk-EEEE2AWI.cjs → chunk-CACTXCDP.cjs} +2 -2
- package/dist/{chunk-EEEE2AWI.cjs.map → chunk-CACTXCDP.cjs.map} +1 -1
- package/dist/{chunk-BTNBUDWN.js → chunk-CTG3FMRO.js} +169 -2
- package/dist/chunk-CTG3FMRO.js.map +1 -0
- package/dist/{chunk-X6E4Y65Y.cjs → chunk-L5JH73RJ.cjs} +172 -5
- package/dist/chunk-L5JH73RJ.cjs.map +1 -0
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/{room-C5ak1P_z.d.cts → room-BRD10hWb.d.cts} +102 -2
- package/dist/{room-C5ak1P_z.d.ts → room-BRD10hWb.d.ts} +102 -2
- package/dist/suspense.cjs +6 -4
- package/dist/suspense.cjs.map +1 -1
- package/dist/suspense.d.cts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +4 -2
- package/dist/suspense.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-BTNBUDWN.js.map +0 -1
- package/dist/chunk-X6E4Y65Y.cjs.map +0 -1
- /package/dist/{chunk-YJ3VWMRC.js.map → chunk-B63FZ2MX.js.map} +0 -0
package/dist/_private.cjs
CHANGED
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
var _chunkL5JH73RJcjs = require('./chunk-L5JH73RJ.cjs');
|
|
33
34
|
|
|
34
35
|
// src/lib/use-layout-effect.ts
|
|
35
36
|
var _react = require('react');
|
|
@@ -54,7 +55,7 @@ function selectorFor_useGroup(state) {
|
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
function useGroup(groupId) {
|
|
57
|
-
const client =
|
|
58
|
+
const client = _chunkL5JH73RJcjs.useClient.call(void 0, );
|
|
58
59
|
const store = client[_core.kInternal].httpClient.groupsStore;
|
|
59
60
|
const getGroupState = _react.useCallback.call(void 0,
|
|
60
61
|
() => store.getItemState(groupId),
|
|
@@ -63,7 +64,7 @@ function useGroup(groupId) {
|
|
|
63
64
|
_react.useEffect.call(void 0, () => {
|
|
64
65
|
void store.enqueue(groupId);
|
|
65
66
|
}, [store, groupId]);
|
|
66
|
-
return
|
|
67
|
+
return _chunkL5JH73RJcjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
67
68
|
store.subscribe,
|
|
68
69
|
getGroupState,
|
|
69
70
|
getGroupState,
|
|
@@ -84,8 +85,8 @@ function normalizeMentionSuggestions(suggestions) {
|
|
|
84
85
|
function useMentionSuggestions(roomId, search) {
|
|
85
86
|
const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
|
|
86
87
|
const lastInvokedAt = _react.useRef.call(void 0, );
|
|
87
|
-
const resolveMentionSuggestions =
|
|
88
|
-
const mentionSuggestionsCache =
|
|
88
|
+
const resolveMentionSuggestions = _chunkL5JH73RJcjs.useResolveMentionSuggestions.call(void 0, );
|
|
89
|
+
const mentionSuggestionsCache = _chunkL5JH73RJcjs.useMentionSuggestionsCache.call(void 0, );
|
|
89
90
|
_react.useEffect.call(void 0, () => {
|
|
90
91
|
if (search === void 0 || !resolveMentionSuggestions) {
|
|
91
92
|
return;
|
|
@@ -140,7 +141,7 @@ function useMentionSuggestions(roomId, search) {
|
|
|
140
141
|
|
|
141
142
|
|
|
142
143
|
function useSyncSource() {
|
|
143
|
-
const client =
|
|
144
|
+
const client = _chunkL5JH73RJcjs.useClient.call(void 0, );
|
|
144
145
|
const createSyncSource = client[_core.kInternal].createSyncSource;
|
|
145
146
|
const [syncSource, setSyncSource] = _react.useState.call(void 0, );
|
|
146
147
|
_react.useEffect.call(void 0, () => {
|
|
@@ -184,5 +185,6 @@ function useSyncSource() {
|
|
|
184
185
|
|
|
185
186
|
|
|
186
187
|
|
|
187
|
-
|
|
188
|
+
|
|
189
|
+
exports.getUmbrellaStoreForClient = _chunkL5JH73RJcjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkL5JH73RJcjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkL5JH73RJcjs.useClientOrNull; exports.useCreateRoomComment = _chunkL5JH73RJcjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkL5JH73RJcjs.useCreateRoomThread; exports.useCreateTextMention = _chunkL5JH73RJcjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkL5JH73RJcjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkL5JH73RJcjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkL5JH73RJcjs.useDeleteTextMention; exports.useEditRoomComment = _chunkL5JH73RJcjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkL5JH73RJcjs.useEditRoomThreadMetadata; exports.useGroup = useGroup; exports.useHasPermissionAccess = _chunkL5JH73RJcjs.useHasPermissionAccess; exports.useInitial = _chunkL5JH73RJcjs.useInitial; exports.useLatest = _chunkL5JH73RJcjs.useLatest; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkL5JH73RJcjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkL5JH73RJcjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkL5JH73RJcjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkL5JH73RJcjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkL5JH73RJcjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkL5JH73RJcjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkL5JH73RJcjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkL5JH73RJcjs.useRoomAttachmentUrl; exports.useRoomFileUrl = _chunkL5JH73RJcjs.useRoomFileUrl; exports.useRoomPermissions = _chunkL5JH73RJcjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunkL5JH73RJcjs.useRoomThreadSubscription; exports.useSignal = _chunkL5JH73RJcjs.useSignal; exports.useSuspendUntilPresenceReady = _chunkL5JH73RJcjs.useSuspendUntilPresenceReady; exports.useSuspendUntilStorageReady = _chunkL5JH73RJcjs.useSuspendUntilStorageReady; exports.useSyncExternalStoreWithSelector = _chunkL5JH73RJcjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkL5JH73RJcjs.useYjsProvider;
|
|
188
190
|
//# sourceMappingURL=_private.cjs.map
|
package/dist/_private.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/_private.cjs","../src/lib/use-layout-effect.ts","../src/use-group.ts","../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"names":["useEffect","kInternal","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;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC/BA,8BAAsE;AAI/D,IAAM,gBAAA,EACX,OAAO,OAAA,IAAW,YAAA,EAAc,uBAAA,EAA0B,gBAAA;AD6B5D;AACA;AErCA;AAGE;AACA;AAAA,wCACK;AACP;AAMA,SAAS,oBAAA,CACP,KAAA,EACkB;AAClB,EA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AA;AAAA,EACrC,CAAA,EAAG,CAAC,gBAAgB,CAAC,CAAA;AAErB,EAAA,OAAO,UAAA;AACT;AJkIA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACF,gwEAAC","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 {\n type AsyncResult,\n type GroupData,\n kInternal,\n shallow,\n} from \"@liveblocks/core\";\nimport { useCallback, useEffect } from \"react\";\n\nimport { useClient } from \"./contexts\";\nimport type { GroupAsyncResult } from \"./types\";\nimport { useSyncExternalStoreWithSelector } from \"./use-sync-external-store-with-selector\";\n\nfunction selectorFor_useGroup(\n state: AsyncResult<GroupData | undefined> | undefined\n): GroupAsyncResult {\n if (state === undefined || state?.isLoading) {\n return state ?? { isLoading: true };\n }\n\n if (state.error) {\n return state;\n }\n\n return {\n isLoading: false,\n group: state.data,\n };\n}\n\n/** @private - Internal API, do not rely on it. */\nexport function useGroup(groupId: string): GroupAsyncResult {\n const client = useClient();\n const store = client[kInternal].httpClient.groupsStore;\n\n const getGroupState = useCallback(\n () => store.getItemState(groupId),\n [store, groupId]\n );\n\n useEffect(() => {\n void store.enqueue(groupId);\n }, [store, groupId]);\n\n return useSyncExternalStoreWithSelector(\n store.subscribe,\n getGroupState,\n getGroupState,\n selectorFor_useGroup,\n shallow\n );\n}\n","import { type MentionData, 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 * Normalize mention suggestions as `MentionData[]`.\n *\n * Mention suggestions were previously typed as `string[]`, a list of user IDs,\n * but to support multiple mention kinds (user, group, etc), they're now\n * typed as `MentionData[]`.\n */\nfunction normalizeMentionSuggestions<T extends string[] | MentionData[]>(\n suggestions: T\n): MentionData[] {\n return suggestions.map(\n (suggestion): MentionData =>\n typeof suggestion === \"string\"\n ? { kind: \"user\" as const, id: suggestion }\n : suggestion\n );\n}\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<MentionData[]>();\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 rawMentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n const normalizedSuggestions = normalizeMentionSuggestions(\n rawMentionSuggestions\n );\n setMentionSuggestions(normalizedSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n normalizedSuggestions\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 const cachedSuggestions = mentionSuggestionsCache.get(\n mentionSuggestionsCacheKey\n );\n setMentionSuggestions(cachedSuggestions);\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 \"./contexts\";\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":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/_private.cjs","../src/lib/use-layout-effect.ts","../src/use-group.ts","../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"names":["useEffect","kInternal","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;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AChCA,8BAAsE;AAI/D,IAAM,gBAAA,EACX,OAAO,OAAA,IAAW,YAAA,EAAc,uBAAA,EAA0B,gBAAA;AD8B5D;AACA;AE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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;AJmIA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2zEAAC","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 {\n type AsyncResult,\n type GroupData,\n kInternal,\n shallow,\n} from \"@liveblocks/core\";\nimport { useCallback, useEffect } from \"react\";\n\nimport { useClient } from \"./contexts\";\nimport type { GroupAsyncResult } from \"./types\";\nimport { useSyncExternalStoreWithSelector } from \"./use-sync-external-store-with-selector\";\n\nfunction selectorFor_useGroup(\n state: AsyncResult<GroupData | undefined> | undefined\n): GroupAsyncResult {\n if (state === undefined || state?.isLoading) {\n return state ?? { isLoading: true };\n }\n\n if (state.error) {\n return state;\n }\n\n return {\n isLoading: false,\n group: state.data,\n };\n}\n\n/** @private - Internal API, do not rely on it. */\nexport function useGroup(groupId: string): GroupAsyncResult {\n const client = useClient();\n const store = client[kInternal].httpClient.groupsStore;\n\n const getGroupState = useCallback(\n () => store.getItemState(groupId),\n [store, groupId]\n );\n\n useEffect(() => {\n void store.enqueue(groupId);\n }, [store, groupId]);\n\n return useSyncExternalStoreWithSelector(\n store.subscribe,\n getGroupState,\n getGroupState,\n selectorFor_useGroup,\n shallow\n );\n}\n","import { type MentionData, 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 * Normalize mention suggestions as `MentionData[]`.\n *\n * Mention suggestions were previously typed as `string[]`, a list of user IDs,\n * but to support multiple mention kinds (user, group, etc), they're now\n * typed as `MentionData[]`.\n */\nfunction normalizeMentionSuggestions<T extends string[] | MentionData[]>(\n suggestions: T\n): MentionData[] {\n return suggestions.map(\n (suggestion): MentionData =>\n typeof suggestion === \"string\"\n ? { kind: \"user\" as const, id: suggestion }\n : suggestion\n );\n}\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<MentionData[]>();\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 rawMentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n const normalizedSuggestions = normalizeMentionSuggestions(\n rawMentionSuggestions\n );\n setMentionSuggestions(normalizedSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n normalizedSuggestions\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 const cachedSuggestions = mentionSuggestionsCache.get(\n mentionSuggestionsCacheKey\n );\n setMentionSuggestions(cachedSuggestions);\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 \"./contexts\";\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"]}
|
package/dist/_private.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GroupAsyncResult } from './room-
|
|
2
|
-
export { g as getUmbrellaStoreForClient, u as useAddRoomCommentReaction, a as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useHasPermissionAccess, l as useMarkRoomThreadAsRead, m as useMarkRoomThreadAsResolved, n as useMarkRoomThreadAsUnresolved, o as useMentionSuggestionsCache, p as useRemoveRoomCommentReaction, q as useReportTextEditor, r as useResolveMentionSuggestions, s as useRoomAttachmentUrl, t as
|
|
1
|
+
import { G as GroupAsyncResult } from './room-BRD10hWb.cjs';
|
|
2
|
+
export { g as getUmbrellaStoreForClient, u as useAddRoomCommentReaction, a as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useHasPermissionAccess, l as useMarkRoomThreadAsRead, m as useMarkRoomThreadAsResolved, n as useMarkRoomThreadAsUnresolved, o as useMentionSuggestionsCache, p as useRemoveRoomCommentReaction, q as useReportTextEditor, r as useResolveMentionSuggestions, s as useRoomAttachmentUrl, t as useRoomFileUrl, v as useRoomPermissions, w as useRoomThreadSubscription, x as useSuspendUntilPresenceReady, y as useSuspendUntilStorageReady, z as useYjsProvider } from './room-BRD10hWb.cjs';
|
|
3
3
|
import { MutableRefObject, useEffect } from 'react';
|
|
4
4
|
import { MentionData, ISignal, SyncSource } from '@liveblocks/core';
|
|
5
5
|
import '@liveblocks/client';
|
package/dist/_private.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GroupAsyncResult } from './room-
|
|
2
|
-
export { g as getUmbrellaStoreForClient, u as useAddRoomCommentReaction, a as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useHasPermissionAccess, l as useMarkRoomThreadAsRead, m as useMarkRoomThreadAsResolved, n as useMarkRoomThreadAsUnresolved, o as useMentionSuggestionsCache, p as useRemoveRoomCommentReaction, q as useReportTextEditor, r as useResolveMentionSuggestions, s as useRoomAttachmentUrl, t as
|
|
1
|
+
import { G as GroupAsyncResult } from './room-BRD10hWb.js';
|
|
2
|
+
export { g as getUmbrellaStoreForClient, u as useAddRoomCommentReaction, a as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useHasPermissionAccess, l as useMarkRoomThreadAsRead, m as useMarkRoomThreadAsResolved, n as useMarkRoomThreadAsUnresolved, o as useMentionSuggestionsCache, p as useRemoveRoomCommentReaction, q as useReportTextEditor, r as useResolveMentionSuggestions, s as useRoomAttachmentUrl, t as useRoomFileUrl, v as useRoomPermissions, w as useRoomThreadSubscription, x as useSuspendUntilPresenceReady, y as useSuspendUntilStorageReady, z as useYjsProvider } from './room-BRD10hWb.js';
|
|
3
3
|
import { MutableRefObject, useEffect } from 'react';
|
|
4
4
|
import { MentionData, ISignal, SyncSource } from '@liveblocks/core';
|
|
5
5
|
import '@liveblocks/client';
|
package/dist/_private.js
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
useReportTextEditor,
|
|
23
23
|
useResolveMentionSuggestions,
|
|
24
24
|
useRoomAttachmentUrl,
|
|
25
|
+
useRoomFileUrl,
|
|
25
26
|
useRoomPermissions,
|
|
26
27
|
useRoomThreadSubscription,
|
|
27
28
|
useSignal,
|
|
@@ -29,7 +30,7 @@ import {
|
|
|
29
30
|
useSuspendUntilStorageReady,
|
|
30
31
|
useSyncExternalStoreWithSelector,
|
|
31
32
|
useYjsProvider
|
|
32
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-CTG3FMRO.js";
|
|
33
34
|
|
|
34
35
|
// src/lib/use-layout-effect.ts
|
|
35
36
|
import { useEffect, useLayoutEffect as useOriginalLayoutEffect } from "react";
|
|
@@ -176,6 +177,7 @@ export {
|
|
|
176
177
|
useReportTextEditor,
|
|
177
178
|
useResolveMentionSuggestions,
|
|
178
179
|
useRoomAttachmentUrl,
|
|
180
|
+
useRoomFileUrl,
|
|
179
181
|
useRoomPermissions,
|
|
180
182
|
useRoomThreadSubscription,
|
|
181
183
|
useSignal,
|
package/dist/_private.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/use-layout-effect.ts","../src/use-group.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 {\n type AsyncResult,\n type GroupData,\n kInternal,\n shallow,\n} from \"@liveblocks/core\";\nimport { useCallback, useEffect } from \"react\";\n\nimport { useClient } from \"./contexts\";\nimport type { GroupAsyncResult } from \"./types\";\nimport { useSyncExternalStoreWithSelector } from \"./use-sync-external-store-with-selector\";\n\nfunction selectorFor_useGroup(\n state: AsyncResult<GroupData | undefined> | undefined\n): GroupAsyncResult {\n if (state === undefined || state?.isLoading) {\n return state ?? { isLoading: true };\n }\n\n if (state.error) {\n return state;\n }\n\n return {\n isLoading: false,\n group: state.data,\n };\n}\n\n/** @private - Internal API, do not rely on it. */\nexport function useGroup(groupId: string): GroupAsyncResult {\n const client = useClient();\n const store = client[kInternal].httpClient.groupsStore;\n\n const getGroupState = useCallback(\n () => store.getItemState(groupId),\n [store, groupId]\n );\n\n useEffect(() => {\n void store.enqueue(groupId);\n }, [store, groupId]);\n\n return useSyncExternalStoreWithSelector(\n store.subscribe,\n getGroupState,\n getGroupState,\n selectorFor_useGroup,\n shallow\n );\n}\n","import { type MentionData, 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 * Normalize mention suggestions as `MentionData[]`.\n *\n * Mention suggestions were previously typed as `string[]`, a list of user IDs,\n * but to support multiple mention kinds (user, group, etc), they're now\n * typed as `MentionData[]`.\n */\nfunction normalizeMentionSuggestions<T extends string[] | MentionData[]>(\n suggestions: T\n): MentionData[] {\n return suggestions.map(\n (suggestion): MentionData =>\n typeof suggestion === \"string\"\n ? { kind: \"user\" as const, id: suggestion }\n : suggestion\n );\n}\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<MentionData[]>();\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 rawMentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n const normalizedSuggestions = normalizeMentionSuggestions(\n rawMentionSuggestions\n );\n setMentionSuggestions(normalizedSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n normalizedSuggestions\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 const cachedSuggestions = mentionSuggestionsCache.get(\n mentionSuggestionsCacheKey\n );\n setMentionSuggestions(cachedSuggestions);\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 \"./contexts\";\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":"
|
|
1
|
+
{"version":3,"sources":["../src/lib/use-layout-effect.ts","../src/use-group.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 {\n type AsyncResult,\n type GroupData,\n kInternal,\n shallow,\n} from \"@liveblocks/core\";\nimport { useCallback, useEffect } from \"react\";\n\nimport { useClient } from \"./contexts\";\nimport type { GroupAsyncResult } from \"./types\";\nimport { useSyncExternalStoreWithSelector } from \"./use-sync-external-store-with-selector\";\n\nfunction selectorFor_useGroup(\n state: AsyncResult<GroupData | undefined> | undefined\n): GroupAsyncResult {\n if (state === undefined || state?.isLoading) {\n return state ?? { isLoading: true };\n }\n\n if (state.error) {\n return state;\n }\n\n return {\n isLoading: false,\n group: state.data,\n };\n}\n\n/** @private - Internal API, do not rely on it. */\nexport function useGroup(groupId: string): GroupAsyncResult {\n const client = useClient();\n const store = client[kInternal].httpClient.groupsStore;\n\n const getGroupState = useCallback(\n () => store.getItemState(groupId),\n [store, groupId]\n );\n\n useEffect(() => {\n void store.enqueue(groupId);\n }, [store, groupId]);\n\n return useSyncExternalStoreWithSelector(\n store.subscribe,\n getGroupState,\n getGroupState,\n selectorFor_useGroup,\n shallow\n );\n}\n","import { type MentionData, 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 * Normalize mention suggestions as `MentionData[]`.\n *\n * Mention suggestions were previously typed as `string[]`, a list of user IDs,\n * but to support multiple mention kinds (user, group, etc), they're now\n * typed as `MentionData[]`.\n */\nfunction normalizeMentionSuggestions<T extends string[] | MentionData[]>(\n suggestions: T\n): MentionData[] {\n return suggestions.map(\n (suggestion): MentionData =>\n typeof suggestion === \"string\"\n ? { kind: \"user\" as const, id: suggestion }\n : suggestion\n );\n}\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<MentionData[]>();\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 rawMentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n const normalizedSuggestions = normalizeMentionSuggestions(\n rawMentionSuggestions\n );\n setMentionSuggestions(normalizedSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n normalizedSuggestions\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 const cachedSuggestions = mentionSuggestionsCache.get(\n mentionSuggestionsCacheKey\n );\n setMentionSuggestions(cachedSuggestions);\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 \"./contexts\";\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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C,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO;AACT;","names":["useEffect","useEffect","useEffect","useEffect","kInternal","useEffect","useState","kInternal","useState","useEffect"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "3.
|
|
3
|
+
var PKG_VERSION = "3.23.0-file1";
|
|
4
4
|
var PKG_FORMAT = "esm";
|
|
5
5
|
|
|
6
6
|
// src/ClientSideSuspense.tsx
|
|
@@ -20,4 +20,4 @@ export {
|
|
|
20
20
|
PKG_FORMAT,
|
|
21
21
|
ClientSideSuspense
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-B63FZ2MX.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/version.ts
|
|
2
2
|
var PKG_NAME = "@liveblocks/react";
|
|
3
|
-
var PKG_VERSION = "3.
|
|
3
|
+
var PKG_VERSION = "3.23.0-file1";
|
|
4
4
|
var PKG_FORMAT = "cjs";
|
|
5
5
|
|
|
6
6
|
// src/ClientSideSuspense.tsx
|
|
@@ -20,4 +20,4 @@ function ClientSideSuspense(props) {
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense;
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-CACTXCDP.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-CACTXCDP.cjs","../src/version.ts","../src/ClientSideSuspense.tsx"],"names":[],"mappings":"AAAA;ACGO,IAAM,SAAA,EAAW,mBAAA;AACjB,IAAM,YAAA,EAAiD,cAAA;AACvD,IAAM,WAAA,EAAgD,KAAA;ADD7D;AACA;AEJA,8BAA8C;AAkC1C,+CAAA;AAVG,SAAS,kBAAA,CAAmB,KAAA,EAAc;AAC/C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAE5C,EAAA,8BAAA,CAAU,EAAA,GAAM;AAGd,IAAA,UAAA,CAAW,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,CAAC,CAAC,CAAA;AAEL,EAAA,uBACE,6BAAA,eAAC,EAAA,EAAS,QAAA,EAAU,KAAA,CAAM,QAAA,EACvB,QAAA,EAAA,QAAA,EACG,OAAO,KAAA,CAAM,SAAA,IAAa,WAAA,EACxB,KAAA,CAAM,QAAA,CAAS,EAAA,EACf,KAAA,CAAM,SAAA,EACR,KAAA,CAAM,SAAA,CACZ,CAAA;AAEJ;AF5BA;AACA;AACE;AACA;AACA;AACA;AACF,iJAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-CACTXCDP.cjs","sourcesContent":[null,"declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n","import type { ReactNode } from \"react\";\nimport { Suspense, useEffect, useState } from \"react\";\n\ntype Props = {\n fallback: ReactNode;\n children: (() => ReactNode | undefined) | ReactNode | undefined;\n};\n\n/**\n * Almost like a normal <Suspense> component, except that for server-side\n * renders, the fallback will be used.\n *\n * The child props will have to be provided in a function, i.e. change:\n *\n * <Suspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </Suspense>\n *\n * To:\n *\n * <ClientSideSuspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </ClientSideSuspense>\n *\n */\nexport function ClientSideSuspense(props: Props) {\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n // Effects are never executed on the server side. The point of this is to\n // delay the flipping of this boolean until after hydration has happened.\n setMounted(true);\n }, []);\n\n return (\n <Suspense fallback={props.fallback}>\n {mounted\n ? typeof props.children === \"function\"\n ? props.children()\n : props.children\n : props.fallback}\n </Suspense>\n );\n}\n"]}
|
|
@@ -3570,6 +3570,7 @@ import {
|
|
|
3570
3570
|
createThreadId,
|
|
3571
3571
|
DefaultMap as DefaultMap3,
|
|
3572
3572
|
errorIf,
|
|
3573
|
+
getLiveFileId,
|
|
3573
3574
|
getSubscriptionKey as getSubscriptionKey3,
|
|
3574
3575
|
hasPermissionAccess,
|
|
3575
3576
|
HttpError as HttpError2,
|
|
@@ -5330,6 +5331,41 @@ function useRoomSubscriptionSettingsSuspense_withRoomContext(RoomContext) {
|
|
|
5330
5331
|
function useRoomSubscriptionSettingsSuspense() {
|
|
5331
5332
|
return useRoomSubscriptionSettingsSuspense_withRoomContext(GlobalRoomContext);
|
|
5332
5333
|
}
|
|
5334
|
+
function parseStorageVersionNodes(ndjson) {
|
|
5335
|
+
return ndjson.split("\n").filter((line) => line.length > 0).map((line) => JSON.parse(line));
|
|
5336
|
+
}
|
|
5337
|
+
function useHistoryVersionStorageData_withRoomContext(RoomContext, versionId) {
|
|
5338
|
+
const [state, setState] = useState3({
|
|
5339
|
+
isLoading: true
|
|
5340
|
+
});
|
|
5341
|
+
const room = useRoom_withRoomContext(RoomContext);
|
|
5342
|
+
useEffect6(() => {
|
|
5343
|
+
setState({ isLoading: true });
|
|
5344
|
+
const load = async () => {
|
|
5345
|
+
try {
|
|
5346
|
+
const response = await room[kInternal4].fetchStorageHistoryVersion(versionId);
|
|
5347
|
+
const nodes = parseStorageVersionNodes(await response.text());
|
|
5348
|
+
const data = room[kInternal4].liveObjectFromNodeStream(nodes);
|
|
5349
|
+
setState({ isLoading: false, data });
|
|
5350
|
+
} catch (error) {
|
|
5351
|
+
setState({
|
|
5352
|
+
isLoading: false,
|
|
5353
|
+
error: error instanceof Error ? error : new Error(
|
|
5354
|
+
"An unknown error occurred while loading this version"
|
|
5355
|
+
)
|
|
5356
|
+
});
|
|
5357
|
+
}
|
|
5358
|
+
};
|
|
5359
|
+
void load();
|
|
5360
|
+
}, [room, versionId]);
|
|
5361
|
+
return state;
|
|
5362
|
+
}
|
|
5363
|
+
function useHistoryVersionStorageData(versionId) {
|
|
5364
|
+
return useHistoryVersionStorageData_withRoomContext(
|
|
5365
|
+
GlobalRoomContext,
|
|
5366
|
+
versionId
|
|
5367
|
+
);
|
|
5368
|
+
}
|
|
5333
5369
|
function useHistoryVersionYjsData_withRoomContext(RoomContext, versionId) {
|
|
5334
5370
|
const [state, setState] = useState3({
|
|
5335
5371
|
isLoading: true
|
|
@@ -5339,7 +5375,7 @@ function useHistoryVersionYjsData_withRoomContext(RoomContext, versionId) {
|
|
|
5339
5375
|
setState({ isLoading: true });
|
|
5340
5376
|
const load = async () => {
|
|
5341
5377
|
try {
|
|
5342
|
-
const response = await room[kInternal4].
|
|
5378
|
+
const response = await room[kInternal4].fetchYjsHistoryVersion(versionId);
|
|
5343
5379
|
const buffer = await response.arrayBuffer();
|
|
5344
5380
|
const data = new Uint8Array(buffer);
|
|
5345
5381
|
setState({
|
|
@@ -5388,6 +5424,30 @@ function useHistoryVersions_withRoomContext(RoomContext) {
|
|
|
5388
5424
|
);
|
|
5389
5425
|
return useSignal(store.outputs.versionsByRoomId.getOrCreate(room.id).signal);
|
|
5390
5426
|
}
|
|
5427
|
+
function useDeleteHistoryVersion_withRoomContext(RoomContext) {
|
|
5428
|
+
const room = useRoom_withRoomContext(RoomContext);
|
|
5429
|
+
return useCallback3(
|
|
5430
|
+
(versionId) => room[kInternal4].deleteHistoryVersion(versionId),
|
|
5431
|
+
[room]
|
|
5432
|
+
);
|
|
5433
|
+
}
|
|
5434
|
+
function useDeleteHistoryVersion() {
|
|
5435
|
+
return useDeleteHistoryVersion_withRoomContext(GlobalRoomContext);
|
|
5436
|
+
}
|
|
5437
|
+
function useRestoreToStorageVersion_withRoomContext(RoomContext, versionId) {
|
|
5438
|
+
const room = useRoom_withRoomContext(RoomContext);
|
|
5439
|
+
return useCallback3(async () => {
|
|
5440
|
+
const response = await room[kInternal4].fetchStorageHistoryVersion(versionId);
|
|
5441
|
+
const nodes = parseStorageVersionNodes(await response.text());
|
|
5442
|
+
room[kInternal4].reconcileStorageWithNodes(nodes);
|
|
5443
|
+
}, [room, versionId]);
|
|
5444
|
+
}
|
|
5445
|
+
function useRestoreToStorageVersion(versionId) {
|
|
5446
|
+
return useRestoreToStorageVersion_withRoomContext(
|
|
5447
|
+
GlobalRoomContext,
|
|
5448
|
+
versionId
|
|
5449
|
+
);
|
|
5450
|
+
}
|
|
5391
5451
|
function useHistoryVersions() {
|
|
5392
5452
|
return useHistoryVersions_withRoomContext(GlobalRoomContext);
|
|
5393
5453
|
}
|
|
@@ -5573,6 +5633,19 @@ function selectorFor_useAttachmentUrl(state) {
|
|
|
5573
5633
|
url: state.data
|
|
5574
5634
|
};
|
|
5575
5635
|
}
|
|
5636
|
+
function selectorFor_useFileUrl(state) {
|
|
5637
|
+
if (state === void 0 || state?.isLoading) {
|
|
5638
|
+
return state ?? { isLoading: true };
|
|
5639
|
+
}
|
|
5640
|
+
if (state.error) {
|
|
5641
|
+
return state;
|
|
5642
|
+
}
|
|
5643
|
+
assert2(state.data !== void 0, "Unexpected missing file URL");
|
|
5644
|
+
return {
|
|
5645
|
+
isLoading: false,
|
|
5646
|
+
url: state.data
|
|
5647
|
+
};
|
|
5648
|
+
}
|
|
5576
5649
|
function useAttachmentUrl_withRoomContext(RoomContext, attachmentId) {
|
|
5577
5650
|
const room = useRoom_withRoomContext(RoomContext);
|
|
5578
5651
|
return useRoomAttachmentUrl(attachmentId, room.id);
|
|
@@ -5598,6 +5671,32 @@ function useRoomAttachmentUrl(attachmentId, roomId) {
|
|
|
5598
5671
|
shallow4
|
|
5599
5672
|
);
|
|
5600
5673
|
}
|
|
5674
|
+
function useFileUrl_withRoomContext(RoomContext, file) {
|
|
5675
|
+
const room = useRoom_withRoomContext(RoomContext);
|
|
5676
|
+
return useRoomFileUrl(file, room.id);
|
|
5677
|
+
}
|
|
5678
|
+
function useFileUrl(file) {
|
|
5679
|
+
return useFileUrl_withRoomContext(GlobalRoomContext, file);
|
|
5680
|
+
}
|
|
5681
|
+
function useRoomFileUrl(file, roomId) {
|
|
5682
|
+
const fileId = getLiveFileId(file);
|
|
5683
|
+
const client = useClient();
|
|
5684
|
+
const store = client[kInternal4].httpClient.getOrCreateFileUrlsStore(roomId);
|
|
5685
|
+
const getFileUrlState = useCallback3(
|
|
5686
|
+
() => store.getItemState(fileId),
|
|
5687
|
+
[store, fileId]
|
|
5688
|
+
);
|
|
5689
|
+
useEffect6(() => {
|
|
5690
|
+
void store.enqueue(fileId);
|
|
5691
|
+
}, [store, fileId]);
|
|
5692
|
+
return useSyncExternalStoreWithSelector(
|
|
5693
|
+
store.subscribe,
|
|
5694
|
+
getFileUrlState,
|
|
5695
|
+
getFileUrlState,
|
|
5696
|
+
selectorFor_useFileUrl,
|
|
5697
|
+
shallow4
|
|
5698
|
+
);
|
|
5699
|
+
}
|
|
5601
5700
|
function useAttachmentUrlSuspense_withRoomContext(RoomContext, attachmentId) {
|
|
5602
5701
|
const room = useRoom_withRoomContext(RoomContext);
|
|
5603
5702
|
const { attachmentUrlsStore } = room[kInternal4];
|
|
@@ -5632,6 +5731,38 @@ function useAttachmentUrlSuspense(attachmentId) {
|
|
|
5632
5731
|
attachmentId
|
|
5633
5732
|
);
|
|
5634
5733
|
}
|
|
5734
|
+
function useFileUrlSuspense_withRoomContext(RoomContext, file) {
|
|
5735
|
+
const fileId = getLiveFileId(file);
|
|
5736
|
+
const room = useRoom_withRoomContext(RoomContext);
|
|
5737
|
+
const { fileUrlsStore } = room[kInternal4];
|
|
5738
|
+
const getFileUrlState = useCallback3(
|
|
5739
|
+
() => fileUrlsStore.getItemState(fileId),
|
|
5740
|
+
[fileUrlsStore, fileId]
|
|
5741
|
+
);
|
|
5742
|
+
const fileUrlState = getFileUrlState();
|
|
5743
|
+
if (!fileUrlState || fileUrlState.isLoading) {
|
|
5744
|
+
throw fileUrlsStore.enqueue(fileId);
|
|
5745
|
+
}
|
|
5746
|
+
if (fileUrlState.error) {
|
|
5747
|
+
throw fileUrlState.error;
|
|
5748
|
+
}
|
|
5749
|
+
const state = useSyncExternalStore3(
|
|
5750
|
+
fileUrlsStore.subscribe,
|
|
5751
|
+
getFileUrlState,
|
|
5752
|
+
getFileUrlState
|
|
5753
|
+
);
|
|
5754
|
+
assert2(state !== void 0, "Unexpected missing state");
|
|
5755
|
+
assert2(!state.isLoading, "Unexpected loading state");
|
|
5756
|
+
assert2(!state.error, "Unexpected error state");
|
|
5757
|
+
return {
|
|
5758
|
+
isLoading: false,
|
|
5759
|
+
url: state.data,
|
|
5760
|
+
error: void 0
|
|
5761
|
+
};
|
|
5762
|
+
}
|
|
5763
|
+
function useFileUrlSuspense(file) {
|
|
5764
|
+
return useFileUrlSuspense_withRoomContext(GlobalRoomContext, file);
|
|
5765
|
+
}
|
|
5635
5766
|
function useRoomPermissions(roomId) {
|
|
5636
5767
|
const client = useClient();
|
|
5637
5768
|
const store = getRoomExtrasForClient(client).store;
|
|
@@ -5826,9 +5957,15 @@ function createRoomContext(client) {
|
|
|
5826
5957
|
function useAttachmentUrl_withBoundRoomContext(...args) {
|
|
5827
5958
|
return useAttachmentUrl_withRoomContext(BoundRoomContext, ...args);
|
|
5828
5959
|
}
|
|
5960
|
+
function useFileUrl_withBoundRoomContext(...args) {
|
|
5961
|
+
return useFileUrl_withRoomContext(BoundRoomContext, ...args);
|
|
5962
|
+
}
|
|
5829
5963
|
function useAttachmentUrlSuspense_withBoundRoomContext(...args) {
|
|
5830
5964
|
return useAttachmentUrlSuspense_withRoomContext(BoundRoomContext, ...args);
|
|
5831
5965
|
}
|
|
5966
|
+
function useFileUrlSuspense_withBoundRoomContext(...args) {
|
|
5967
|
+
return useFileUrlSuspense_withRoomContext(BoundRoomContext, ...args);
|
|
5968
|
+
}
|
|
5832
5969
|
function useSearchComments_withBoundRoomContext(...args) {
|
|
5833
5970
|
return useSearchComments_withRoomContext(BoundRoomContext, ...args);
|
|
5834
5971
|
}
|
|
@@ -5838,9 +5975,24 @@ function createRoomContext(client) {
|
|
|
5838
5975
|
function useHistoryVersionsSuspense_withBoundRoomContext() {
|
|
5839
5976
|
return useHistoryVersionsSuspense_withRoomContext(BoundRoomContext);
|
|
5840
5977
|
}
|
|
5978
|
+
function useHistoryVersionStorageData_withBoundRoomContext(...args) {
|
|
5979
|
+
return useHistoryVersionStorageData_withRoomContext(
|
|
5980
|
+
BoundRoomContext,
|
|
5981
|
+
...args
|
|
5982
|
+
);
|
|
5983
|
+
}
|
|
5841
5984
|
function useHistoryVersionYjsData_withBoundRoomContext(...args) {
|
|
5842
5985
|
return useHistoryVersionYjsData_withRoomContext(BoundRoomContext, ...args);
|
|
5843
5986
|
}
|
|
5987
|
+
function useDeleteHistoryVersion_withBoundRoomContext() {
|
|
5988
|
+
return useDeleteHistoryVersion_withRoomContext(BoundRoomContext);
|
|
5989
|
+
}
|
|
5990
|
+
function useRestoreToStorageVersion_withBoundRoomContext(...args) {
|
|
5991
|
+
return useRestoreToStorageVersion_withRoomContext(
|
|
5992
|
+
BoundRoomContext,
|
|
5993
|
+
...args
|
|
5994
|
+
);
|
|
5995
|
+
}
|
|
5844
5996
|
function useRoomSubscriptionSettings_withBoundRoomContext() {
|
|
5845
5997
|
return useRoomSubscriptionSettings_withRoomContext(BoundRoomContext);
|
|
5846
5998
|
}
|
|
@@ -5979,14 +6131,21 @@ function createRoomContext(client) {
|
|
|
5979
6131
|
// prettier-ignore
|
|
5980
6132
|
useAttachmentUrl: useAttachmentUrl_withBoundRoomContext,
|
|
5981
6133
|
// prettier-ignore
|
|
6134
|
+
useFileUrl: useFileUrl_withBoundRoomContext,
|
|
6135
|
+
// prettier-ignore
|
|
5982
6136
|
useSearchComments: useSearchComments_withBoundRoomContext,
|
|
5983
6137
|
// prettier-ignore
|
|
5984
6138
|
useHistoryVersions: useHistoryVersions_withBoundRoomContext,
|
|
5985
6139
|
// prettier-ignore
|
|
5986
6140
|
useHistoryVersionData: useHistoryVersionYjsData_withBoundRoomContext,
|
|
5987
6141
|
// prettier-ignore
|
|
6142
|
+
useHistoryVersionStorageData: useHistoryVersionStorageData_withBoundRoomContext,
|
|
5988
6143
|
useHistoryVersionYjsData: useHistoryVersionYjsData_withBoundRoomContext,
|
|
5989
6144
|
// prettier-ignore
|
|
6145
|
+
useDeleteHistoryVersion: useDeleteHistoryVersion_withBoundRoomContext,
|
|
6146
|
+
// prettier-ignore
|
|
6147
|
+
useRestoreToStorageVersion: useRestoreToStorageVersion_withBoundRoomContext,
|
|
6148
|
+
// prettier-ignore
|
|
5990
6149
|
useRoomSubscriptionSettings: useRoomSubscriptionSettings_withBoundRoomContext,
|
|
5991
6150
|
// prettier-ignore
|
|
5992
6151
|
useUpdateRoomSubscriptionSettings: useUpdateRoomSubscriptionSettings_withBoundRoomContext,
|
|
@@ -6087,6 +6246,8 @@ function createRoomContext(client) {
|
|
|
6087
6246
|
// prettier-ignore
|
|
6088
6247
|
useAttachmentUrl: useAttachmentUrlSuspense_withBoundRoomContext,
|
|
6089
6248
|
// prettier-ignore
|
|
6249
|
+
useFileUrl: useFileUrlSuspense_withBoundRoomContext,
|
|
6250
|
+
// prettier-ignore
|
|
6090
6251
|
useHistoryVersions: useHistoryVersionsSuspense_withBoundRoomContext,
|
|
6091
6252
|
// prettier-ignore
|
|
6092
6253
|
useRoomSubscriptionSettings: useRoomSubscriptionSettingsSuspense_withBoundRoomContext,
|
|
@@ -6236,15 +6397,21 @@ export {
|
|
|
6236
6397
|
useUnsubscribeFromThread,
|
|
6237
6398
|
useThreadSubscription,
|
|
6238
6399
|
useRoomThreadSubscription,
|
|
6400
|
+
useHistoryVersionStorageData,
|
|
6239
6401
|
useHistoryVersionData,
|
|
6240
6402
|
useHistoryVersionYjsData,
|
|
6403
|
+
useDeleteHistoryVersion,
|
|
6404
|
+
useRestoreToStorageVersion,
|
|
6241
6405
|
useUpdateRoomSubscriptionSettings,
|
|
6242
6406
|
useSuspendUntilPresenceReady,
|
|
6243
6407
|
useOthersConnectionIdsSuspense,
|
|
6244
6408
|
useSuspendUntilStorageReady,
|
|
6245
6409
|
useAttachmentUrl,
|
|
6246
6410
|
useRoomAttachmentUrl,
|
|
6411
|
+
useFileUrl,
|
|
6412
|
+
useRoomFileUrl,
|
|
6247
6413
|
useAttachmentUrlSuspense,
|
|
6414
|
+
useFileUrlSuspense,
|
|
6248
6415
|
useRoomPermissions,
|
|
6249
6416
|
useHasPermissionAccess,
|
|
6250
6417
|
createRoomContext,
|
|
@@ -6287,4 +6454,4 @@ export {
|
|
|
6287
6454
|
_useStorageRoot,
|
|
6288
6455
|
_useUpdateMyPresence
|
|
6289
6456
|
};
|
|
6290
|
-
//# sourceMappingURL=chunk-
|
|
6457
|
+
//# sourceMappingURL=chunk-CTG3FMRO.js.map
|