@sanity/sdk-react 2.9.0 → 2.11.0
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/index.d.ts +338 -215
- package/dist/index.js +564 -342
- package/dist/index.js.map +1 -1
- package/package.json +9 -14
- package/src/_exports/index.ts +2 -0
- package/src/_exports/sdk-react.ts +8 -0
- package/src/components/SDKProvider.test.tsx +5 -12
- package/src/components/SDKProvider.tsx +58 -28
- package/src/components/SanityApp.tsx +2 -2
- package/src/components/auth/AuthBoundary.tsx +8 -1
- package/src/components/auth/DashboardAccessRequest.tsx +37 -0
- package/src/components/auth/LoginError.test.tsx +191 -5
- package/src/components/auth/LoginError.tsx +100 -56
- package/src/components/errors/ChunkLoadError.test.tsx +59 -0
- package/src/components/errors/ChunkLoadError.tsx +56 -0
- package/src/components/errors/chunkReloadStorage.ts +57 -0
- package/src/config/handles.ts +55 -0
- package/src/constants.ts +5 -0
- package/src/context/DefaultResourceContext.ts +10 -0
- package/src/context/PerspectiveContext.ts +12 -0
- package/src/context/ResourceProvider.test.tsx +2 -2
- package/src/context/ResourceProvider.tsx +56 -51
- package/src/context/ResourcesContext.tsx +7 -0
- package/src/context/SanityInstanceProvider.test.tsx +100 -0
- package/src/context/SanityInstanceProvider.tsx +71 -0
- package/src/hooks/agent/agentActions.ts +55 -38
- package/src/hooks/auth/useVerifyOrgProjects.tsx +13 -6
- package/src/hooks/context/useResource.test.tsx +32 -0
- package/src/hooks/context/useResource.ts +24 -0
- package/src/hooks/context/useSanityInstance.test.tsx +42 -111
- package/src/hooks/context/useSanityInstance.ts +28 -50
- package/src/hooks/dashboard/useDispatchIntent.test.ts +11 -7
- package/src/hooks/dashboard/useDispatchIntent.ts +7 -7
- package/src/hooks/dashboard/useManageFavorite.test.tsx +16 -12
- package/src/hooks/dashboard/utils/useResourceIdFromDocumentHandle.test.ts +15 -15
- package/src/hooks/dashboard/utils/useResourceIdFromDocumentHandle.ts +13 -17
- package/src/hooks/document/{useApplyDocumentActions.test.ts → useApplyDocumentActions.test.tsx} +46 -81
- package/src/hooks/document/useApplyDocumentActions.ts +33 -67
- package/src/hooks/document/useDocument.ts +4 -6
- package/src/hooks/document/useDocumentEvent.ts +8 -7
- package/src/hooks/document/useDocumentPermissions.test.tsx +60 -152
- package/src/hooks/document/useDocumentPermissions.ts +78 -55
- package/src/hooks/document/useDocumentSyncStatus.ts +2 -2
- package/src/hooks/document/useEditDocument.test.tsx +25 -60
- package/src/hooks/document/useEditDocument.ts +3 -3
- package/src/hooks/documents/useDocuments.ts +19 -11
- package/src/hooks/helpers/createStateSourceHook.tsx +1 -2
- package/src/hooks/helpers/useNormalizedResourceOptions.test.tsx +253 -0
- package/src/hooks/helpers/useNormalizedResourceOptions.ts +169 -0
- package/src/hooks/helpers/useTrackHookUsage.ts +2 -2
- package/src/hooks/organizations/useOrganization.test-d.ts +53 -0
- package/src/hooks/organizations/useOrganization.test.ts +65 -0
- package/src/hooks/organizations/useOrganization.ts +40 -0
- package/src/hooks/organizations/useOrganizations.test-d.ts +55 -0
- package/src/hooks/organizations/useOrganizations.test.ts +85 -0
- package/src/hooks/organizations/useOrganizations.ts +45 -0
- package/src/hooks/paginatedDocuments/usePaginatedDocuments.ts +29 -14
- package/src/hooks/presence/usePresence.test.tsx +56 -9
- package/src/hooks/presence/usePresence.ts +16 -4
- package/src/hooks/preview/useDocumentPreview.tsx +8 -10
- package/src/hooks/projection/useDocumentProjection.ts +7 -9
- package/src/hooks/projects/useProject.test-d.ts +49 -0
- package/src/hooks/projects/useProject.ts +33 -41
- package/src/hooks/projects/useProjects.test-d.ts +49 -0
- package/src/hooks/projects/useProjects.ts +17 -23
- package/src/hooks/query/useQuery.ts +11 -10
- package/src/hooks/releases/useActiveReleases.ts +14 -14
- package/src/hooks/releases/usePerspective.ts +11 -16
- package/src/hooks/users/useUser.ts +1 -1
- package/src/hooks/users/useUsers.ts +1 -1
- package/src/context/SourcesContext.tsx +0 -7
- package/src/hooks/helpers/useNormalizedSourceOptions.ts +0 -107
package/dist/index.js
CHANGED
|
@@ -1,41 +1,34 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { ClientError, CorsOriginError } from "@sanity/client";
|
|
4
|
-
import { getAuthState, getNodeState, getIsInDashboardState, isStudioConfig, setAuthToken, AuthStateType, getLoginUrlState, observeOrganizationVerificationState, handleAuthCallback, logout, isProjectUserNotFoundClientError, getClientErrorApiDescription, getClientErrorApiBody, getCorsErrorProjectId, createSanityInstance,
|
|
4
|
+
import { getAuthState, getNodeState, getIsInDashboardState, isStudioConfig, setAuthToken, AuthStateType, getLoginUrlState, observeOrganizationVerificationState, handleAuthCallback, logout, isProjectUserNotFoundClientError, getClientErrorApiDescription, getClientErrorApiBody, isImportError, getCorsErrorProjectId, createSanityInstance, isDatasetResource, agentGenerate, agentPatch, agentPrompt, agentTransform, agentTranslate, getTokenState, getCurrentUserState, getDashboardOrganizationId, getClientState, getOrCreateController, getOrCreateChannel, releaseChannel, isMediaLibraryResource, isCanvasResource, getFavoritesState, resolveFavoritesState, resolveDatasets, getDatasetsState, applyDocumentActions, resolveDocument, getDocumentState, subscribeDocumentEvents, getPermissionsState, getDocumentSyncStatus, editDocument, getQueryKey, parseQueryKey, getQueryState, resolveQuery, createGroqSearchFilter, resolveOrganization, getOrganizationState, resolveOrganizations, getOrganizationsState, getPresence, getProjectionState, resolveProjection, transformProjectionToPreview, PREVIEW_PROJECTION, resolveProject, getProjectState, resolveProjects, getProjectsState, getActiveReleasesState, getPerspectiveState, getUsersKey, parseUsersKey, getUsersState, resolveUsers, loadMoreUsers } from "@sanity/sdk";
|
|
5
5
|
export * from "@sanity/sdk";
|
|
6
|
-
import { createContext, useContext, useSyncExternalStore, useRef, useEffect, useState,
|
|
6
|
+
import { createContext, useContext, useSyncExternalStore, useRef, useEffect, useState, Suspense, StrictMode, useCallback, useMemo, useInsertionEffect, useTransition } from "react";
|
|
7
7
|
import { ErrorBoundary } from "react-error-boundary";
|
|
8
8
|
import { SDK_CHANNEL_NAME, SDK_NODE_NAME } from "@sanity/message-protocol";
|
|
9
9
|
import { firstValueFrom, filter, identity, Observable, startWith, distinctUntilChanged, switchMap, EMPTY } from "rxjs";
|
|
10
|
-
import { initTelemetry, trackHookMounted } from "@sanity/sdk/_internal";
|
|
10
|
+
import { initTelemetry, isDeepEqual, trackHookMounted, pickProperties } from "@sanity/sdk/_internal";
|
|
11
11
|
import { createRoot } from "react-dom/client";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const SanityInstanceContext = createContext(null), warnedCallers = /* @__PURE__ */ new Set(), useSanityInstance = (config) => {
|
|
13
|
+
if (config !== void 0) {
|
|
14
|
+
const caller = new Error().stack?.split(`
|
|
15
|
+
`)[2]?.trim() ?? "unknown";
|
|
16
|
+
warnedCallers.has(caller) || (warnedCallers.add(caller), console.warn("[useSanityInstance] Passing a config argument is deprecated and has no effect. SDK apps use a single instance for all resources, so the config argument is no longer needed. Call useSanityInstance() without arguments instead, or useResource() to get your currently active resource."));
|
|
17
|
+
}
|
|
18
|
+
const instance = useContext(SanityInstanceContext);
|
|
15
19
|
if (!instance)
|
|
16
|
-
throw new Error(
|
|
17
|
-
|
|
18
|
-
return instance;
|
|
19
|
-
let t0;
|
|
20
|
-
$[0] !== config || $[1] !== instance ? (t0 = instance.match(config), $[0] = config, $[1] = instance, $[2] = t0) : t0 = $[2];
|
|
21
|
-
const match = t0;
|
|
22
|
-
if (!match)
|
|
23
|
-
throw new Error(`Could not find a matching Sanity instance for the requested configuration: ${JSON.stringify(config, null, 2)}.
|
|
24
|
-
Please ensure there is a ResourceProvider component with a matching configuration in the component hierarchy.`);
|
|
25
|
-
return match;
|
|
20
|
+
throw new Error("SanityInstance context not found. Please ensure that your component is wrapped in a ResourceProvider or a SanityApp component.");
|
|
21
|
+
return instance;
|
|
26
22
|
};
|
|
27
23
|
function createStateSourceHook(options) {
|
|
28
|
-
const getState = typeof options == "function" ? options : options.getState,
|
|
24
|
+
const getState = typeof options == "function" ? options : options.getState, suspense = "shouldSuspend" in options && "suspender" in options ? options : void 0;
|
|
29
25
|
function useHook(...t0) {
|
|
30
|
-
const $ = c(
|
|
31
|
-
let t1;
|
|
32
|
-
$[0] !== params ? (t1 = getConfig?.(...params), $[0] = params, $[1] = t1) : t1 = $[1];
|
|
33
|
-
const instance = useSanityInstance(t1);
|
|
26
|
+
const $ = c(3), params = t0, instance = useSanityInstance();
|
|
34
27
|
if (suspense?.suspender && suspense?.shouldSuspend?.(instance, ...params))
|
|
35
28
|
throw suspense.suspender(instance, ...params);
|
|
36
|
-
let
|
|
37
|
-
$[
|
|
38
|
-
const state =
|
|
29
|
+
let t1;
|
|
30
|
+
$[0] !== instance || $[1] !== params ? (t1 = getState(instance, ...params), $[0] = instance, $[1] = params, $[2] = t1) : t1 = $[2];
|
|
31
|
+
const state = t1;
|
|
39
32
|
return useSyncExternalStore(state.subscribe, state.getCurrent);
|
|
40
33
|
}
|
|
41
34
|
return useHook;
|
|
@@ -163,20 +156,41 @@ function useLoginUrl() {
|
|
|
163
156
|
return useSyncExternalStore(subscribe, getCurrent);
|
|
164
157
|
}
|
|
165
158
|
function useVerifyOrgProjects(t0, projectIds) {
|
|
166
|
-
const $ = c(
|
|
159
|
+
const $ = c(5), disabled = t0 === void 0 ? !1 : t0, instance = useSanityInstance(), [error, setError] = useState(null), isInactive = disabled || !projectIds || projectIds.length === 0, [prevInactive, setPrevInactive] = useState(isInactive);
|
|
160
|
+
prevInactive !== isInactive && (setPrevInactive(isInactive), isInactive && setError(null));
|
|
167
161
|
let t1, t2;
|
|
168
|
-
return $[0] !==
|
|
169
|
-
if (
|
|
170
|
-
error !== null && setError(null);
|
|
162
|
+
return $[0] !== instance || $[1] !== isInactive || $[2] !== projectIds ? (t1 = () => {
|
|
163
|
+
if (isInactive)
|
|
171
164
|
return;
|
|
172
|
-
}
|
|
173
165
|
const subscription = observeOrganizationVerificationState(instance, projectIds).subscribe((result) => {
|
|
174
166
|
setError(result.error);
|
|
175
167
|
});
|
|
176
168
|
return () => {
|
|
177
169
|
subscription.unsubscribe();
|
|
178
170
|
};
|
|
179
|
-
}, t2 = [instance,
|
|
171
|
+
}, t2 = [instance, isInactive, projectIds], $[0] = instance, $[1] = isInactive, $[2] = projectIds, $[3] = t1, $[4] = t2) : (t1 = $[3], t2 = $[4]), useEffect(t1, t2), error;
|
|
172
|
+
}
|
|
173
|
+
const CHUNK_RELOAD_STORAGE_KEY = "__sanity_sdk_chunk_reload_attempted";
|
|
174
|
+
function readChunkReloadFlag() {
|
|
175
|
+
try {
|
|
176
|
+
return typeof window > "u" || typeof window.sessionStorage > "u" ? !1 : window.sessionStorage.getItem(CHUNK_RELOAD_STORAGE_KEY) !== null;
|
|
177
|
+
} catch {
|
|
178
|
+
return !1;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function setChunkReloadFlag() {
|
|
182
|
+
try {
|
|
183
|
+
if (typeof window > "u" || typeof window.sessionStorage > "u") return;
|
|
184
|
+
window.sessionStorage.setItem(CHUNK_RELOAD_STORAGE_KEY, "1");
|
|
185
|
+
} catch {
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function clearChunkReloadFlag() {
|
|
189
|
+
try {
|
|
190
|
+
if (typeof window > "u" || typeof window.sessionStorage > "u") return;
|
|
191
|
+
window.sessionStorage.removeItem(CHUNK_RELOAD_STORAGE_KEY);
|
|
192
|
+
} catch {
|
|
193
|
+
}
|
|
180
194
|
}
|
|
181
195
|
const FONT_SANS_SERIF = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica, Arial, system-ui, sans-serif", FONT_MONOSPACE = "-apple-system-ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace", styles = {
|
|
182
196
|
container: {
|
|
@@ -233,6 +247,31 @@ function Error$1(t0) {
|
|
|
233
247
|
t4
|
|
234
248
|
] }), $[8] = t1, $[9] = t2, $[10] = t3, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
|
|
235
249
|
}
|
|
250
|
+
function reload() {
|
|
251
|
+
try {
|
|
252
|
+
window.location.reload();
|
|
253
|
+
} catch {
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function ChunkLoadError(_props) {
|
|
257
|
+
const $ = c(4);
|
|
258
|
+
let t0;
|
|
259
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = readChunkReloadFlag(), $[0] = t0) : t0 = $[0];
|
|
260
|
+
const alreadyAttempted = t0;
|
|
261
|
+
let t1, t2;
|
|
262
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => {
|
|
263
|
+
alreadyAttempted || (setChunkReloadFlag(), reload());
|
|
264
|
+
}, t2 = [alreadyAttempted], $[1] = t1, $[2] = t2) : (t1 = $[1], t2 = $[2]), useEffect(t1, t2), !alreadyAttempted)
|
|
265
|
+
return null;
|
|
266
|
+
let t3;
|
|
267
|
+
return $[3] === Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(Error$1, { heading: "A new version is available", description: "The page tried to load an asset that no longer exists. Reload to continue with the latest version.", cta: {
|
|
268
|
+
text: "Reload page",
|
|
269
|
+
onClick: _temp$6
|
|
270
|
+
} }), $[3] = t3) : t3 = $[3], t3;
|
|
271
|
+
}
|
|
272
|
+
function _temp$6() {
|
|
273
|
+
clearChunkReloadFlag(), reload();
|
|
274
|
+
}
|
|
236
275
|
function CorsErrorComponent(t0) {
|
|
237
276
|
const $ = c(6), {
|
|
238
277
|
projectId,
|
|
@@ -291,67 +330,100 @@ function LoginCallback() {
|
|
|
291
330
|
let t0, t1;
|
|
292
331
|
return $[0] !== handleAuthCallback2 ? (t0 = () => {
|
|
293
332
|
const url = new URL(location.href);
|
|
294
|
-
handleAuthCallback2(url.toString()).then(_temp$
|
|
333
|
+
handleAuthCallback2(url.toString()).then(_temp$5);
|
|
295
334
|
}, t1 = [handleAuthCallback2], $[0] = handleAuthCallback2, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1), null;
|
|
296
335
|
}
|
|
297
|
-
function _temp$
|
|
336
|
+
function _temp$5(replacementLocation) {
|
|
298
337
|
replacementLocation && history.replaceState(null, "", replacementLocation);
|
|
299
338
|
}
|
|
300
339
|
const useLogOut = createCallbackHook(logout);
|
|
340
|
+
function DashboardAccessRequest(t0) {
|
|
341
|
+
const $ = c(5), {
|
|
342
|
+
projectId
|
|
343
|
+
} = t0;
|
|
344
|
+
let t1;
|
|
345
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
|
|
346
|
+
name: SDK_NODE_NAME,
|
|
347
|
+
connectTo: SDK_CHANNEL_NAME
|
|
348
|
+
}, $[0] = t1) : t1 = $[0];
|
|
349
|
+
const {
|
|
350
|
+
fetch
|
|
351
|
+
} = useWindowConnection(t1);
|
|
352
|
+
let t2, t3;
|
|
353
|
+
return $[1] !== fetch || $[2] !== projectId ? (t2 = () => {
|
|
354
|
+
fetch("dashboard/v1/auth/access/request", {
|
|
355
|
+
resourceType: "project",
|
|
356
|
+
resourceId: projectId
|
|
357
|
+
});
|
|
358
|
+
}, t3 = [fetch, projectId], $[1] = fetch, $[2] = projectId, $[3] = t2, $[4] = t3) : (t2 = $[3], t3 = $[4]), useEffect(t2, t3), null;
|
|
359
|
+
}
|
|
301
360
|
function LoginError(t0) {
|
|
302
|
-
const $ = c(
|
|
361
|
+
const $ = c(30), {
|
|
303
362
|
error,
|
|
304
363
|
resetErrorBoundary
|
|
305
364
|
} = t0;
|
|
306
365
|
if (!(error instanceof AuthError || error instanceof ConfigurationError || error instanceof ClientError))
|
|
307
366
|
throw error;
|
|
308
|
-
const logout2 = useLogOut(), authState = useAuthState(), {
|
|
367
|
+
const logout2 = useLogOut(), authState = useAuthState(), instance = useSanityInstance(), {
|
|
309
368
|
config: t1
|
|
310
|
-
} =
|
|
369
|
+
} = instance, {
|
|
311
370
|
projectId
|
|
312
|
-
} = t1,
|
|
371
|
+
} = t1, clientError = error instanceof ClientError ? error : error instanceof AuthError && error.cause instanceof ClientError ? error.cause : null;
|
|
313
372
|
let t2;
|
|
314
|
-
$[0]
|
|
315
|
-
|
|
316
|
-
connectTo: SDK_CHANNEL_NAME
|
|
317
|
-
}, $[0] = t2) : t2 = $[0];
|
|
318
|
-
const {
|
|
319
|
-
fetch
|
|
320
|
-
} = useWindowConnection(t2);
|
|
373
|
+
$[0] !== instance ? (t2 = getIsInDashboardState(instance).getCurrent(), $[0] = instance, $[1] = t2) : t2 = $[1];
|
|
374
|
+
const isInDashboard = t2;
|
|
321
375
|
let t3;
|
|
322
|
-
$[
|
|
323
|
-
|
|
324
|
-
}, $[1] = logout2, $[2] = resetErrorBoundary, $[3] = t3) : t3 = $[3];
|
|
325
|
-
const handleRetry = t3;
|
|
376
|
+
$[2] !== clientError ? (t3 = !!clientError && clientError.statusCode === 401 && isProjectUserNotFoundClientError(clientError), $[2] = clientError, $[3] = t3) : t3 = $[3];
|
|
377
|
+
const isProjectUserNotFound = t3, dashboardAccessProjectId = isProjectUserNotFound && projectId && isInDashboard ? projectId : null;
|
|
326
378
|
let t4;
|
|
327
|
-
$[4] !==
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
379
|
+
$[4] !== logout2 || $[5] !== resetErrorBoundary ? (t4 = async () => {
|
|
380
|
+
await logout2(), resetErrorBoundary();
|
|
381
|
+
}, $[4] = logout2, $[5] = resetErrorBoundary, $[6] = t4) : t4 = $[6];
|
|
382
|
+
const handleRetry = t4;
|
|
383
|
+
let t5, message = "Please try again or contact support if the problem persists.", retry = !0;
|
|
384
|
+
if (clientError) {
|
|
385
|
+
if (clientError.statusCode === 401)
|
|
386
|
+
if (isProjectUserNotFound) {
|
|
387
|
+
let t62;
|
|
388
|
+
$[7] !== clientError ? (t62 = getClientErrorApiDescription(clientError), $[7] = clientError, $[8] = t62) : t62 = $[8];
|
|
389
|
+
const description = t62;
|
|
390
|
+
description && (message = description), retry = !1;
|
|
391
|
+
} else
|
|
392
|
+
isInDashboard || (message = "Signing you out and returning to login...", retry = !0);
|
|
393
|
+
else if (clientError.statusCode === 404) {
|
|
394
|
+
const errorMessage = getClientErrorApiBody(clientError)?.message || "";
|
|
395
|
+
message = errorMessage.startsWith("Session with sid") && errorMessage.endsWith("not found") ? "The session ID is invalid or expired." : "The login link is invalid or expired. Please try again.", retry = !0;
|
|
342
396
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
let
|
|
346
|
-
$[
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
$[
|
|
397
|
+
}
|
|
398
|
+
authState.type !== AuthStateType.ERROR && error instanceof ConfigurationError && (message = error.message, retry = !0);
|
|
399
|
+
let t6;
|
|
400
|
+
$[9] !== message || $[10] !== retry ? (t6 = {
|
|
401
|
+
authErrorMessage: message,
|
|
402
|
+
showRetryCta: retry
|
|
403
|
+
}, $[9] = message, $[10] = retry, $[11] = t6) : t6 = $[11], t5 = t6;
|
|
404
|
+
const {
|
|
405
|
+
authErrorMessage,
|
|
406
|
+
showRetryCta
|
|
407
|
+
} = t5, hasAutoLoggedOutRef = useRef(!1);
|
|
408
|
+
let t7, t8;
|
|
409
|
+
$[12] !== clientError || $[13] !== handleRetry || $[14] !== isInDashboard || $[15] !== isProjectUserNotFound ? (t7 = () => {
|
|
410
|
+
clientError && clientError.statusCode === 401 && !isProjectUserNotFound && !isInDashboard && !hasAutoLoggedOutRef.current && (hasAutoLoggedOutRef.current = !0, handleRetry());
|
|
411
|
+
}, t8 = [clientError, handleRetry, isInDashboard, isProjectUserNotFound], $[12] = clientError, $[13] = handleRetry, $[14] = isInDashboard, $[15] = isProjectUserNotFound, $[16] = t7, $[17] = t8) : (t7 = $[16], t8 = $[17]), useEffect(t7, t8);
|
|
412
|
+
let t9;
|
|
413
|
+
$[18] !== dashboardAccessProjectId ? (t9 = dashboardAccessProjectId && /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(DashboardAccessRequest, { projectId: dashboardAccessProjectId }) }), $[18] = dashboardAccessProjectId, $[19] = t9) : t9 = $[19];
|
|
414
|
+
const t10 = error instanceof ConfigurationError ? "Configuration Error" : "Authentication Error";
|
|
415
|
+
let t11;
|
|
416
|
+
$[20] !== handleRetry || $[21] !== showRetryCta ? (t11 = showRetryCta ? {
|
|
350
417
|
text: "Retry",
|
|
351
418
|
onClick: handleRetry
|
|
352
|
-
} : void 0, $[
|
|
353
|
-
let
|
|
354
|
-
|
|
419
|
+
} : void 0, $[20] = handleRetry, $[21] = showRetryCta, $[22] = t11) : t11 = $[22];
|
|
420
|
+
let t12;
|
|
421
|
+
$[23] !== authErrorMessage || $[24] !== t10 || $[25] !== t11 ? (t12 = /* @__PURE__ */ jsx(Error$1, { heading: t10, description: authErrorMessage, cta: t11 }), $[23] = authErrorMessage, $[24] = t10, $[25] = t11, $[26] = t12) : t12 = $[26];
|
|
422
|
+
let t13;
|
|
423
|
+
return $[27] !== t12 || $[28] !== t9 ? (t13 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
424
|
+
t9,
|
|
425
|
+
t12
|
|
426
|
+
] }), $[27] = t12, $[28] = t9, $[29] = t13) : t13 = $[29], t13;
|
|
355
427
|
}
|
|
356
428
|
if (isInIframe() && !document.querySelector("[data-sanity-core]")) {
|
|
357
429
|
const parsedUrl = new URL(window.location.href), mode = new URLSearchParams(parsedUrl.hash.slice(1)).get("mode"), script = document.createElement("script");
|
|
@@ -367,7 +439,7 @@ function AuthBoundary(t0) {
|
|
|
367
439
|
const LoginErrorComponent = t1 === void 0 ? LoginError : t1;
|
|
368
440
|
let t2, t3;
|
|
369
441
|
$[3] !== LoginErrorComponent ? (t3 = function(fallbackProps) {
|
|
370
|
-
return fallbackProps.error instanceof CorsOriginError ? /* @__PURE__ */ jsx(CorsErrorComponent, { ...fallbackProps, projectId: getCorsErrorProjectId(fallbackProps.error) }) : /* @__PURE__ */ jsx(LoginErrorComponent, { ...fallbackProps });
|
|
442
|
+
return isImportError(fallbackProps.error) ? /* @__PURE__ */ jsx(ChunkLoadError, { ...fallbackProps }) : fallbackProps.error instanceof CorsOriginError ? /* @__PURE__ */ jsx(CorsErrorComponent, { ...fallbackProps, projectId: getCorsErrorProjectId(fallbackProps.error) }) : /* @__PURE__ */ jsx(LoginErrorComponent, { ...fallbackProps });
|
|
371
443
|
}, $[3] = LoginErrorComponent, $[4] = t3) : t3 = $[4], t2 = t3;
|
|
372
444
|
const FallbackComponent = t2;
|
|
373
445
|
let t4;
|
|
@@ -413,29 +485,85 @@ function AuthSwitch(t0) {
|
|
|
413
485
|
}
|
|
414
486
|
const SDKStudioContext = createContext(null);
|
|
415
487
|
SDKStudioContext.displayName = "SDKStudioContext";
|
|
488
|
+
const DEFAULT_RESOURCE_NAME = "default", ResourceContext = createContext(void 0), PerspectiveContext = createContext(void 0);
|
|
489
|
+
function SanityInstanceProvider(t0) {
|
|
490
|
+
const $ = c(6), {
|
|
491
|
+
instance,
|
|
492
|
+
fallback,
|
|
493
|
+
children
|
|
494
|
+
} = t0;
|
|
495
|
+
let t1;
|
|
496
|
+
$[0] !== children || $[1] !== fallback ? (t1 = /* @__PURE__ */ jsx(Suspense, { fallback, children }), $[0] = children, $[1] = fallback, $[2] = t1) : t1 = $[2];
|
|
497
|
+
let t2;
|
|
498
|
+
return $[3] !== instance || $[4] !== t1 ? (t2 = /* @__PURE__ */ jsx(SanityInstanceContext.Provider, { value: instance, children: t1 }), $[3] = instance, $[4] = t1, $[5] = t2) : t2 = $[5], t2;
|
|
499
|
+
}
|
|
416
500
|
const DEFAULT_FALLBACK = /* @__PURE__ */ jsx(Fragment, { children: "Warning: No fallback provided. Please supply a fallback prop to ensure proper Suspense handling." });
|
|
417
|
-
function ResourceProvider({
|
|
418
|
-
|
|
419
|
-
fallback,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}, [
|
|
501
|
+
function ResourceProvider(t0) {
|
|
502
|
+
const $ = c(29);
|
|
503
|
+
let children, config, fallback, resource;
|
|
504
|
+
$[0] !== t0 ? ({
|
|
505
|
+
children,
|
|
506
|
+
fallback,
|
|
507
|
+
resource,
|
|
508
|
+
...config
|
|
509
|
+
} = t0, $[0] = t0, $[1] = children, $[2] = config, $[3] = fallback, $[4] = resource) : (children = $[1], config = $[2], fallback = $[3], resource = $[4]);
|
|
510
|
+
const parentPerspective = useContext(PerspectiveContext), parentResource = useContext(ResourceContext), parentInstance = useContext(SanityInstanceContext), {
|
|
511
|
+
projectId,
|
|
512
|
+
dataset,
|
|
513
|
+
perspective
|
|
514
|
+
} = config;
|
|
515
|
+
let t1;
|
|
516
|
+
$[5] !== config || $[6] !== parentInstance ? (t1 = () => parentInstance ?? createSanityInstance(config), $[5] = config, $[6] = parentInstance, $[7] = t1) : t1 = $[7];
|
|
517
|
+
const [instance] = useState(t1);
|
|
518
|
+
let t2;
|
|
519
|
+
bb0: {
|
|
520
|
+
if (projectId && dataset) {
|
|
521
|
+
let t32;
|
|
522
|
+
$[8] !== dataset || $[9] !== projectId ? (t32 = {
|
|
523
|
+
projectId,
|
|
524
|
+
dataset
|
|
525
|
+
}, $[8] = dataset, $[9] = projectId, $[10] = t32) : t32 = $[10], t2 = t32;
|
|
526
|
+
break bb0;
|
|
527
|
+
}
|
|
528
|
+
t2 = void 0;
|
|
529
|
+
}
|
|
530
|
+
const configResource = t2;
|
|
531
|
+
let t3;
|
|
532
|
+
t3 = resource ?? configResource ?? parentResource;
|
|
533
|
+
const effectiveResource = t3;
|
|
534
|
+
let t4, t5;
|
|
535
|
+
$[11] !== effectiveResource || $[12] !== instance ? (t4 = () => {
|
|
536
|
+
effectiveResource && isDatasetResource(effectiveResource) && initTelemetry(instance, effectiveResource.projectId);
|
|
537
|
+
}, t5 = [instance, effectiveResource], $[11] = effectiveResource, $[12] = instance, $[13] = t4, $[14] = t5) : (t4 = $[13], t5 = $[14]), useEffect(t4, t5);
|
|
426
538
|
const disposal = useRef(null);
|
|
427
|
-
|
|
539
|
+
let t6, t7;
|
|
540
|
+
$[15] !== instance || $[16] !== parentInstance ? (t6 = () => (disposal.current !== null && instance === disposal.current.instance && (clearTimeout(disposal.current.timeoutId), disposal.current = null), () => {
|
|
428
541
|
disposal.current = {
|
|
429
542
|
instance,
|
|
430
543
|
timeoutId: setTimeout(() => {
|
|
431
|
-
instance.isDisposed()
|
|
544
|
+
!instance.isDisposed() && instance !== parentInstance && instance.dispose();
|
|
432
545
|
}, 0)
|
|
433
546
|
};
|
|
434
|
-
}), [instance]
|
|
547
|
+
}), t7 = [instance, parentInstance], $[15] = instance, $[16] = parentInstance, $[17] = t6, $[18] = t7) : (t6 = $[17], t7 = $[18]), useEffect(t6, t7);
|
|
548
|
+
const t8 = fallback ?? DEFAULT_FALLBACK, t9 = perspective ?? parentPerspective;
|
|
549
|
+
let t10;
|
|
550
|
+
$[19] !== children || $[20] !== t9 ? (t10 = /* @__PURE__ */ jsx(PerspectiveContext.Provider, { value: t9, children }), $[19] = children, $[20] = t9, $[21] = t10) : t10 = $[21];
|
|
551
|
+
let t11;
|
|
552
|
+
$[22] !== effectiveResource || $[23] !== t10 ? (t11 = /* @__PURE__ */ jsx(ResourceContext.Provider, { value: effectiveResource, children: t10 }), $[22] = effectiveResource, $[23] = t10, $[24] = t11) : t11 = $[24];
|
|
553
|
+
let t12;
|
|
554
|
+
return $[25] !== instance || $[26] !== t11 || $[27] !== t8 ? (t12 = /* @__PURE__ */ jsx(SanityInstanceProvider, { instance, fallback: t8, children: t11 }), $[25] = instance, $[26] = t11, $[27] = t8, $[28] = t12) : t12 = $[28], t12;
|
|
555
|
+
}
|
|
556
|
+
const ResourcesContext = createContext({});
|
|
557
|
+
function ResetChunkReloadFlagOnMount() {
|
|
558
|
+
const $ = c(1);
|
|
559
|
+
let t0;
|
|
560
|
+
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0], useEffect(_temp$4, t0), null;
|
|
561
|
+
}
|
|
562
|
+
function _temp$4() {
|
|
563
|
+
clearChunkReloadFlag();
|
|
435
564
|
}
|
|
436
|
-
const SourcesContext = createContext({});
|
|
437
565
|
function SDKProvider(t0) {
|
|
438
|
-
const $ = c(
|
|
566
|
+
const $ = c(29);
|
|
439
567
|
let children, config, fallback, props;
|
|
440
568
|
$[0] !== t0 ? ({
|
|
441
569
|
children,
|
|
@@ -445,26 +573,57 @@ function SDKProvider(t0) {
|
|
|
445
573
|
} = t0, $[0] = t0, $[1] = children, $[2] = config, $[3] = fallback, $[4] = props) : (children = $[1], config = $[2], fallback = $[3], props = $[4]);
|
|
446
574
|
let t1;
|
|
447
575
|
$[5] !== config ? (t1 = Array.isArray(config) ? config : [config], $[5] = config, $[6] = t1) : t1 = $[6];
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
576
|
+
const allConfigs = t1, resolvedConfig = allConfigs[0];
|
|
577
|
+
let t2;
|
|
578
|
+
$[7] !== allConfigs ? (t2 = allConfigs.map(_temp2$1).filter(_temp3$1), $[7] = allConfigs, $[8] = t2) : t2 = $[8];
|
|
579
|
+
const projectIds = t2, singleConfig = Array.isArray(config) ? null : config, defaultProjectId = singleConfig?.projectId, defaultDataset = singleConfig?.dataset;
|
|
580
|
+
let t3;
|
|
581
|
+
bb0: {
|
|
582
|
+
let t42;
|
|
583
|
+
$[9] !== props.resources ? (t42 = props.resources ?? {}, $[9] = props.resources, $[10] = t42) : t42 = $[10];
|
|
584
|
+
const explicit = t42;
|
|
585
|
+
if (defaultProjectId && defaultDataset && !Object.hasOwn(explicit, DEFAULT_RESOURCE_NAME)) {
|
|
586
|
+
let t52;
|
|
587
|
+
$[11] !== defaultDataset || $[12] !== defaultProjectId ? (t52 = {
|
|
588
|
+
projectId: defaultProjectId,
|
|
589
|
+
dataset: defaultDataset
|
|
590
|
+
}, $[11] = defaultDataset, $[12] = defaultProjectId, $[13] = t52) : t52 = $[13];
|
|
591
|
+
let t62;
|
|
592
|
+
$[14] !== explicit || $[15] !== t52 ? (t62 = {
|
|
593
|
+
[DEFAULT_RESOURCE_NAME]: t52,
|
|
594
|
+
...explicit
|
|
595
|
+
}, $[14] = explicit, $[15] = t52, $[16] = t62) : t62 = $[16], t3 = t62;
|
|
596
|
+
break bb0;
|
|
597
|
+
}
|
|
598
|
+
t3 = explicit;
|
|
599
|
+
}
|
|
600
|
+
const resourcesValue = t3;
|
|
601
|
+
let t4;
|
|
602
|
+
$[17] === Symbol.for("react.memo_cache_sentinel") ? (t4 = /* @__PURE__ */ jsx(ResetChunkReloadFlagOnMount, {}), $[17] = t4) : t4 = $[17];
|
|
454
603
|
let t5;
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
604
|
+
$[18] !== children || $[19] !== resourcesValue ? (t5 = /* @__PURE__ */ jsx(ResourcesContext.Provider, { value: resourcesValue, children }), $[18] = children, $[19] = resourcesValue, $[20] = t5) : t5 = $[20];
|
|
605
|
+
let t6;
|
|
606
|
+
$[21] !== projectIds || $[22] !== props || $[23] !== t5 ? (t6 = /* @__PURE__ */ jsx(AuthBoundary, { ...props, projectIds, children: t5 }), $[21] = projectIds, $[22] = props, $[23] = t5, $[24] = t6) : t6 = $[24];
|
|
607
|
+
let t7;
|
|
608
|
+
return $[25] !== fallback || $[26] !== resolvedConfig || $[27] !== t6 ? (t7 = /* @__PURE__ */ jsxs(ErrorBoundary, { FallbackComponent: ChunkAwareFallback, children: [
|
|
609
|
+
t4,
|
|
610
|
+
/* @__PURE__ */ jsx(ResourceProvider, { ...resolvedConfig, fallback, children: t6 })
|
|
611
|
+
] }), $[25] = fallback, $[26] = resolvedConfig, $[27] = t6, $[28] = t7) : t7 = $[28], t7;
|
|
461
612
|
}
|
|
462
|
-
function
|
|
613
|
+
function _temp3$1(id) {
|
|
463
614
|
return !!id;
|
|
464
615
|
}
|
|
465
|
-
function
|
|
616
|
+
function _temp2$1(c2) {
|
|
466
617
|
return c2.projectId;
|
|
467
618
|
}
|
|
619
|
+
function ChunkAwareFallback(fallbackProps) {
|
|
620
|
+
const $ = c(2);
|
|
621
|
+
if (isImportError(fallbackProps.error)) {
|
|
622
|
+
let t0;
|
|
623
|
+
return $[0] !== fallbackProps ? (t0 = /* @__PURE__ */ jsx(ChunkLoadError, { ...fallbackProps }), $[0] = fallbackProps, $[1] = t0) : t0 = $[1], t0;
|
|
624
|
+
}
|
|
625
|
+
throw fallbackProps.error;
|
|
626
|
+
}
|
|
468
627
|
const REDIRECT_URL = "https://sanity.io/welcome";
|
|
469
628
|
function deriveConfigFromWorkspace(workspace) {
|
|
470
629
|
return {
|
|
@@ -507,12 +666,12 @@ function SanityApp(t0) {
|
|
|
507
666
|
$[8] !== configProp || $[9] !== resolvedConfig || $[10] !== studioWorkspace ? (t2 = () => {
|
|
508
667
|
let timeout;
|
|
509
668
|
const primaryConfig = Array.isArray(resolvedConfig) ? resolvedConfig[0] : resolvedConfig, shouldRedirectWithoutConfig = configProp === void 0 && !studioWorkspace && !primaryConfig;
|
|
510
|
-
return !isInIframe() && !isLocalUrl(window) && (shouldRedirectWithoutConfig || primaryConfig && !isStudioConfig(primaryConfig)) && (timeout = setTimeout(_temp$
|
|
669
|
+
return !isInIframe() && !isLocalUrl(window) && (shouldRedirectWithoutConfig || primaryConfig && !isStudioConfig(primaryConfig)) && (timeout = setTimeout(_temp$3, 1e3)), () => clearTimeout(timeout);
|
|
511
670
|
}, t3 = [configProp, resolvedConfig, studioWorkspace], $[8] = configProp, $[9] = resolvedConfig, $[10] = studioWorkspace, $[11] = t2, $[12] = t3) : (t2 = $[11], t3 = $[12]), useEffect(t2, t3);
|
|
512
671
|
let t4;
|
|
513
672
|
return $[13] !== children || $[14] !== fallback || $[15] !== props || $[16] !== resolvedConfig ? (t4 = /* @__PURE__ */ jsx(SDKProvider, { ...props, fallback, config: resolvedConfig, children }), $[13] = children, $[14] = fallback, $[15] = props, $[16] = resolvedConfig, $[17] = t4) : t4 = $[17], t4;
|
|
514
673
|
}
|
|
515
|
-
function _temp$
|
|
674
|
+
function _temp$3() {
|
|
516
675
|
console.warn("Redirecting to core", REDIRECT_URL), window.location.replace(REDIRECT_URL);
|
|
517
676
|
}
|
|
518
677
|
function renderSanityApp(rootElement, namedSources, options, children) {
|
|
@@ -523,15 +682,121 @@ function renderSanityApp(rootElement, namedSources, options, children) {
|
|
|
523
682
|
} = options, root = createRoot(rootElement), config = Object.values(namedSources);
|
|
524
683
|
return root.render(reactStrictMode ? /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(SanityApp, { config, fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children }) }) : /* @__PURE__ */ jsx(SanityApp, { config, fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children })), () => root.unmount();
|
|
525
684
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
685
|
+
function normalizeResourceOptions(options, resources, contextResource, contextPerspective) {
|
|
686
|
+
const {
|
|
687
|
+
resourceName,
|
|
688
|
+
sourceName,
|
|
689
|
+
source,
|
|
690
|
+
projectId,
|
|
691
|
+
dataset,
|
|
692
|
+
...rest
|
|
693
|
+
} = options, effectiveResourceName = resourceName ?? sourceName, effectiveResource = options.resource ?? source;
|
|
694
|
+
if (effectiveResourceName && effectiveResource)
|
|
695
|
+
throw new Error(`Resource name ${JSON.stringify(effectiveResourceName)} and resource ${JSON.stringify(effectiveResource)} cannot be used together.`);
|
|
696
|
+
let resolvedResource;
|
|
697
|
+
if (effectiveResource)
|
|
698
|
+
resolvedResource = effectiveResource;
|
|
699
|
+
else if (effectiveResourceName) {
|
|
700
|
+
if (!Object.hasOwn(resources, effectiveResourceName))
|
|
701
|
+
throw new Error(`There's no resource named ${JSON.stringify(effectiveResourceName)} in context. Please use <ResourceProvider>.`);
|
|
702
|
+
resolvedResource = resources[effectiveResourceName];
|
|
703
|
+
}
|
|
704
|
+
!resolvedResource && projectId && dataset && (resolvedResource = {
|
|
705
|
+
projectId,
|
|
706
|
+
dataset
|
|
707
|
+
}), resolvedResource || (resolvedResource = contextResource);
|
|
708
|
+
const resolvedPerspective = Object.hasOwn(options, "perspective") ? options.perspective : contextPerspective;
|
|
709
|
+
return {
|
|
710
|
+
...rest,
|
|
711
|
+
...resolvedResource !== void 0 && {
|
|
712
|
+
resource: resolvedResource
|
|
713
|
+
},
|
|
714
|
+
...resolvedPerspective !== void 0 && {
|
|
715
|
+
perspective: resolvedPerspective
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
function useEffectiveContextResource() {
|
|
720
|
+
const $ = c(5), contextResource = useContext(ResourceContext), instance = useContext(SanityInstanceContext);
|
|
721
|
+
let t0;
|
|
722
|
+
$[0] !== instance?.config ? (t0 = instance?.config ?? {}, $[0] = instance?.config, $[1] = t0) : t0 = $[1];
|
|
723
|
+
const {
|
|
724
|
+
projectId,
|
|
725
|
+
dataset
|
|
726
|
+
} = t0;
|
|
727
|
+
let t1;
|
|
728
|
+
bb0: {
|
|
729
|
+
if (contextResource) {
|
|
730
|
+
t1 = contextResource;
|
|
731
|
+
break bb0;
|
|
732
|
+
}
|
|
733
|
+
if (projectId && dataset) {
|
|
734
|
+
let t2;
|
|
735
|
+
$[2] !== dataset || $[3] !== projectId ? (t2 = {
|
|
736
|
+
projectId,
|
|
737
|
+
dataset
|
|
738
|
+
}, $[2] = dataset, $[3] = projectId, $[4] = t2) : t2 = $[4], t1 = t2;
|
|
739
|
+
break bb0;
|
|
740
|
+
}
|
|
741
|
+
t1 = void 0;
|
|
742
|
+
}
|
|
743
|
+
return t1;
|
|
529
744
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
745
|
+
function useNormalizedResourceOptions(options) {
|
|
746
|
+
const $ = c(5), resources = useContext(ResourcesContext), effectiveContextResource = useEffectiveContextResource(), contextPerspective = useContext(PerspectiveContext);
|
|
747
|
+
let t0;
|
|
748
|
+
return $[0] !== contextPerspective || $[1] !== effectiveContextResource || $[2] !== options || $[3] !== resources ? (t0 = normalizeResourceOptions(options, resources, effectiveContextResource, contextPerspective), $[0] = contextPerspective, $[1] = effectiveContextResource, $[2] = options, $[3] = resources, $[4] = t0) : t0 = $[4], t0;
|
|
749
|
+
}
|
|
750
|
+
function useAgentGenerate(resourceHandle) {
|
|
751
|
+
const $ = c(5), instance = useSanityInstance();
|
|
752
|
+
let t0;
|
|
753
|
+
$[0] !== resourceHandle ? (t0 = resourceHandle ?? {}, $[0] = resourceHandle, $[1] = t0) : t0 = $[1];
|
|
754
|
+
const {
|
|
755
|
+
resource
|
|
756
|
+
} = useNormalizedResourceOptions(t0);
|
|
757
|
+
let t1;
|
|
758
|
+
return $[2] !== instance || $[3] !== resource ? (t1 = (options) => agentGenerate(instance, options, resource), $[2] = instance, $[3] = resource, $[4] = t1) : t1 = $[4], t1;
|
|
759
|
+
}
|
|
760
|
+
function useAgentTransform(resourceHandle) {
|
|
761
|
+
const $ = c(5), instance = useSanityInstance();
|
|
762
|
+
let t0;
|
|
763
|
+
$[0] !== resourceHandle ? (t0 = resourceHandle ?? {}, $[0] = resourceHandle, $[1] = t0) : t0 = $[1];
|
|
764
|
+
const {
|
|
765
|
+
resource
|
|
766
|
+
} = useNormalizedResourceOptions(t0);
|
|
767
|
+
let t1;
|
|
768
|
+
return $[2] !== instance || $[3] !== resource ? (t1 = (options) => agentTransform(instance, options, resource), $[2] = instance, $[3] = resource, $[4] = t1) : t1 = $[4], t1;
|
|
769
|
+
}
|
|
770
|
+
function useAgentTranslate(resourceHandle) {
|
|
771
|
+
const $ = c(5), instance = useSanityInstance();
|
|
772
|
+
let t0;
|
|
773
|
+
$[0] !== resourceHandle ? (t0 = resourceHandle ?? {}, $[0] = resourceHandle, $[1] = t0) : t0 = $[1];
|
|
774
|
+
const {
|
|
775
|
+
resource
|
|
776
|
+
} = useNormalizedResourceOptions(t0);
|
|
777
|
+
let t1;
|
|
778
|
+
return $[2] !== instance || $[3] !== resource ? (t1 = (options) => agentTranslate(instance, options, resource), $[2] = instance, $[3] = resource, $[4] = t1) : t1 = $[4], t1;
|
|
779
|
+
}
|
|
780
|
+
function useAgentPrompt(resourceHandle) {
|
|
781
|
+
const $ = c(5), instance = useSanityInstance();
|
|
782
|
+
let t0;
|
|
783
|
+
$[0] !== resourceHandle ? (t0 = resourceHandle ?? {}, $[0] = resourceHandle, $[1] = t0) : t0 = $[1];
|
|
784
|
+
const {
|
|
785
|
+
resource
|
|
786
|
+
} = useNormalizedResourceOptions(t0);
|
|
787
|
+
let t1;
|
|
788
|
+
return $[2] !== instance || $[3] !== resource ? (t1 = (options) => firstValueFrom(agentPrompt(instance, options, resource)), $[2] = instance, $[3] = resource, $[4] = t1) : t1 = $[4], t1;
|
|
789
|
+
}
|
|
790
|
+
function useAgentPatch(resourceHandle) {
|
|
791
|
+
const $ = c(5), instance = useSanityInstance();
|
|
792
|
+
let t0;
|
|
793
|
+
$[0] !== resourceHandle ? (t0 = resourceHandle ?? {}, $[0] = resourceHandle, $[1] = t0) : t0 = $[1];
|
|
794
|
+
const {
|
|
795
|
+
resource
|
|
796
|
+
} = useNormalizedResourceOptions(t0);
|
|
797
|
+
let t1;
|
|
798
|
+
return $[2] !== instance || $[3] !== resource ? (t1 = (options) => firstValueFrom(agentPatch(instance, options, resource)), $[2] = instance, $[3] = resource, $[4] = t1) : t1 = $[4], t1;
|
|
533
799
|
}
|
|
534
|
-
const useAgentPatch = createCallbackHook(patchAdapter);
|
|
535
800
|
function useAgentResourceContext(options) {
|
|
536
801
|
const $ = c(9), {
|
|
537
802
|
projectId,
|
|
@@ -620,7 +885,7 @@ function useFrameConnection(options) {
|
|
|
620
885
|
const [type, handler] = t22, unsubscribe = channel.on(type, handler);
|
|
621
886
|
messageUnsubscribers.push(unsubscribe);
|
|
622
887
|
}), () => {
|
|
623
|
-
messageUnsubscribers.forEach(_temp$
|
|
888
|
+
messageUnsubscribers.forEach(_temp$2), releaseChannel(instance, name), channelRef.current = null, controllerRef.current = null;
|
|
624
889
|
};
|
|
625
890
|
}, t1 = [targetOrigin, name, connectTo, heartbeat, onMessage, instance, onStatus], $[0] = connectTo, $[1] = heartbeat, $[2] = instance, $[3] = name, $[4] = onMessage, $[5] = onStatus, $[6] = targetOrigin, $[7] = t0, $[8] = t1) : (t0 = $[7], t1 = $[8]), useEffect(t0, t1);
|
|
626
891
|
let t2;
|
|
@@ -642,9 +907,12 @@ function useFrameConnection(options) {
|
|
|
642
907
|
sendMessage
|
|
643
908
|
}, $[11] = t4) : t4 = $[11], t4;
|
|
644
909
|
}
|
|
645
|
-
function _temp$
|
|
910
|
+
function _temp$2(unsub) {
|
|
646
911
|
return unsub();
|
|
647
912
|
}
|
|
913
|
+
function useResource() {
|
|
914
|
+
return useEffectiveContextResource();
|
|
915
|
+
}
|
|
648
916
|
function useDashboardNavigate(navigateFn) {
|
|
649
917
|
const $ = c(2);
|
|
650
918
|
let t0;
|
|
@@ -658,36 +926,12 @@ function useDashboardNavigate(navigateFn) {
|
|
|
658
926
|
}
|
|
659
927
|
}, $[0] = navigateFn, $[1] = t0) : t0 = $[1], useWindowConnection(t0);
|
|
660
928
|
}
|
|
661
|
-
function normalizeSourceOptions(options, sources) {
|
|
662
|
-
const {
|
|
663
|
-
sourceName,
|
|
664
|
-
...rest
|
|
665
|
-
} = options;
|
|
666
|
-
if (!sourceName && !options.source)
|
|
667
|
-
return options;
|
|
668
|
-
if (sourceName && Object.hasOwn(options, "source"))
|
|
669
|
-
throw new Error(`Source name ${JSON.stringify(sourceName)} and source ${JSON.stringify(options.source)} cannot be used together.`);
|
|
670
|
-
let resolvedSource;
|
|
671
|
-
if (options.source && (resolvedSource = options.source), sourceName && !Object.hasOwn(sources, sourceName))
|
|
672
|
-
throw new Error(`There's no source named ${JSON.stringify(sourceName)} in context. Please use <SourceProvider>.`);
|
|
673
|
-
return sourceName && sources[sourceName] && (resolvedSource = sources[sourceName]), {
|
|
674
|
-
...rest,
|
|
675
|
-
source: resolvedSource
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
function useNormalizedSourceOptions(options) {
|
|
679
|
-
const $ = c(3), sources = useContext(SourcesContext);
|
|
680
|
-
let t0;
|
|
681
|
-
return $[0] !== options || $[1] !== sources ? (t0 = normalizeSourceOptions(options, sources), $[0] = options, $[1] = sources, $[2] = t0) : t0 = $[2], t0;
|
|
682
|
-
}
|
|
683
929
|
function useResourceIdFromDocumentHandle(documentHandle) {
|
|
684
|
-
const $ = c(3), options =
|
|
685
|
-
|
|
686
|
-
dataset,
|
|
687
|
-
source
|
|
930
|
+
const $ = c(3), options = useNormalizedResourceOptions(documentHandle), {
|
|
931
|
+
resource
|
|
688
932
|
} = options;
|
|
689
933
|
let resourceId = "", resourceType;
|
|
690
|
-
|
|
934
|
+
resource && (isDatasetResource(resource) ? (resourceId = `${resource.projectId}.${resource.dataset}`, resourceType = void 0) : isMediaLibraryResource(resource) ? (resourceId = resource.mediaLibraryId, resourceType = "media-library") : isCanvasResource(resource) && (resourceId = resource.canvasId, resourceType = "canvas"));
|
|
691
935
|
let t0;
|
|
692
936
|
return $[0] !== resourceId || $[1] !== resourceType ? (t0 = {
|
|
693
937
|
id: resourceId,
|
|
@@ -712,7 +956,7 @@ function useDispatchIntent(params) {
|
|
|
712
956
|
if (!action && !intentId)
|
|
713
957
|
throw new Error("useDispatchIntent: Either `action` or `intentId` must be provided.");
|
|
714
958
|
if (action && intentId && console.warn("useDispatchIntent: Both `action` and `intentId` were provided. Using `intentId` and ignoring `action`."), !resource.id)
|
|
715
|
-
throw new Error("useDispatchIntent: Unable to determine resource. Either `
|
|
959
|
+
throw new Error("useDispatchIntent: Unable to determine resource. Either `resource`, `resourceName`, or both `projectId` and `dataset` must be provided in documentHandle.");
|
|
716
960
|
const message = {
|
|
717
961
|
type: "dashboard/v1/events/intents/dispatch-intent",
|
|
718
962
|
data: {
|
|
@@ -1001,54 +1245,28 @@ const useDatasets = createStateSourceHook({
|
|
|
1001
1245
|
suspender: resolveDatasets,
|
|
1002
1246
|
getConfig: identity
|
|
1003
1247
|
}), useApplyDocumentActions = () => {
|
|
1004
|
-
const $ = c(
|
|
1248
|
+
const $ = c(4), instance = useSanityInstance(), resources = useContext(ResourcesContext), effectiveContextResource = useEffectiveContextResource();
|
|
1005
1249
|
let t0;
|
|
1006
|
-
return $[0] !==
|
|
1007
|
-
const actions = Array.isArray(actionOrActions) ? actionOrActions : [actionOrActions],
|
|
1008
|
-
let
|
|
1009
|
-
for (const
|
|
1010
|
-
if (
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
}
|
|
1018
|
-
if (action.source) {
|
|
1019
|
-
if (source || (source = action.source), action.source !== source)
|
|
1020
|
-
throw new Error(`Mismatched sources found in actions. All actions must belong to the same source. Found "${action.source}" but expected "${source}".`);
|
|
1021
|
-
if (projectId || dataset)
|
|
1022
|
-
throw new Error(`Mismatches between projectId/dataset options and source in actions. Found "${action.source}" but expected project "${projectId}" and dataset "${dataset}".`);
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
if (projectId || dataset) {
|
|
1026
|
-
const actualInstance = instance.match({
|
|
1027
|
-
projectId,
|
|
1028
|
-
dataset
|
|
1029
|
-
});
|
|
1030
|
-
if (!actualInstance)
|
|
1031
|
-
throw new Error(`Could not find a matching Sanity instance for the requested action: ${JSON.stringify({
|
|
1032
|
-
projectId,
|
|
1033
|
-
dataset
|
|
1034
|
-
}, null, 2)}.
|
|
1035
|
-
Please ensure there is a ResourceProvider component with a matching configuration in the component hierarchy.`);
|
|
1036
|
-
return applyDocumentActions(actualInstance, {
|
|
1037
|
-
actions,
|
|
1038
|
-
source,
|
|
1039
|
-
...normalizedOptions
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1250
|
+
return $[0] !== effectiveContextResource || $[1] !== instance || $[2] !== resources ? (t0 = (actionOrActions, options) => {
|
|
1251
|
+
const actions = Array.isArray(actionOrActions) ? actionOrActions : [actionOrActions], optionsResource = options ? normalizeResourceOptions(options, resources, effectiveContextResource).resource : void 0, normalizedActions = actions.map((action) => normalizeResourceOptions(action, resources, effectiveContextResource));
|
|
1252
|
+
let resource;
|
|
1253
|
+
for (const action_0 of normalizedActions)
|
|
1254
|
+
if (!resource && action_0.resource && (resource = action_0.resource), !isDeepEqual(action_0.resource, resource))
|
|
1255
|
+
throw new Error(`Mismatched resources found in actions. All actions must belong to the same resource. Found "${JSON.stringify(action_0.resource)}" but expected "${JSON.stringify(resource)}".`);
|
|
1256
|
+
if (optionsResource && resource && !isDeepEqual(optionsResource, resource))
|
|
1257
|
+
throw new Error(`Mismatched resources found in actions. Found top-level resource "${JSON.stringify(optionsResource)}" but expected resource from action handles "${JSON.stringify(resource)}".`);
|
|
1258
|
+
const effectiveResource = resource ?? optionsResource ?? effectiveContextResource;
|
|
1259
|
+
if (!effectiveResource)
|
|
1260
|
+
throw new Error("No resource found. Provide a resource via the action handle or context.");
|
|
1042
1261
|
return applyDocumentActions(instance, {
|
|
1043
|
-
actions,
|
|
1044
|
-
|
|
1045
|
-
...normalizedOptions
|
|
1262
|
+
actions: normalizedActions,
|
|
1263
|
+
resource: effectiveResource
|
|
1046
1264
|
});
|
|
1047
|
-
}, $[0] =
|
|
1265
|
+
}, $[0] = effectiveContextResource, $[1] = instance, $[2] = resources, $[3] = t0) : t0 = $[3], t0;
|
|
1048
1266
|
};
|
|
1049
1267
|
function useTrackHookUsage(hookName) {
|
|
1050
|
-
const instance = useSanityInstance(), tracked = useRef(
|
|
1051
|
-
tracked.current
|
|
1268
|
+
const instance = useSanityInstance(), tracked = useRef(null);
|
|
1269
|
+
tracked.current === null && (tracked.current = !0, trackHookMounted(instance, hookName));
|
|
1052
1270
|
}
|
|
1053
1271
|
function trackHookUsage(instance, hookName) {
|
|
1054
1272
|
trackHookMounted(instance, hookName);
|
|
@@ -1073,13 +1291,13 @@ const useDocumentValue = createStateSourceHook({
|
|
|
1073
1291
|
return useHook;
|
|
1074
1292
|
}, useDocument = wrapHookWithData((options) => {
|
|
1075
1293
|
useTrackHookUsage("useDocument");
|
|
1076
|
-
const normalizedOptions =
|
|
1294
|
+
const normalizedOptions = useNormalizedResourceOptions(options);
|
|
1077
1295
|
return useDocumentValue(normalizedOptions);
|
|
1078
1296
|
});
|
|
1079
1297
|
function useDocumentEvent(options) {
|
|
1080
1298
|
const $ = c(10);
|
|
1081
1299
|
useTrackHookUsage("useDocumentEvent");
|
|
1082
|
-
const normalizedOptions =
|
|
1300
|
+
const normalizedOptions = useNormalizedResourceOptions(options);
|
|
1083
1301
|
let datasetHandle, onEvent;
|
|
1084
1302
|
$[0] !== normalizedOptions ? ({
|
|
1085
1303
|
onEvent,
|
|
@@ -1092,63 +1310,49 @@ function useDocumentEvent(options) {
|
|
|
1092
1310
|
}, $[3] = onEvent, $[4] = t0) : t0 = $[4], useInsertionEffect(t0);
|
|
1093
1311
|
let t1;
|
|
1094
1312
|
$[5] === Symbol.for("react.memo_cache_sentinel") ? (t1 = (documentEvent) => ref.current(documentEvent), $[5] = t1) : t1 = $[5];
|
|
1095
|
-
const stableHandler = t1, instance = useSanityInstance(
|
|
1313
|
+
const stableHandler = t1, instance = useSanityInstance();
|
|
1096
1314
|
let t2, t3;
|
|
1097
|
-
$[6] !== datasetHandle.
|
|
1315
|
+
$[6] !== datasetHandle.resource || $[7] !== instance ? (t2 = () => subscribeDocumentEvents(instance, {
|
|
1098
1316
|
eventHandler: stableHandler,
|
|
1099
|
-
|
|
1100
|
-
}), t3 = [instance, datasetHandle.
|
|
1317
|
+
resource: datasetHandle.resource
|
|
1318
|
+
}), t3 = [instance, datasetHandle.resource, stableHandler], $[6] = datasetHandle.resource, $[7] = instance, $[8] = t2, $[9] = t3) : (t2 = $[8], t3 = $[9]), useEffect(t2, t3);
|
|
1101
1319
|
}
|
|
1320
|
+
const noopSubscribe = () => () => {
|
|
1321
|
+
}, returnUndefined = () => {
|
|
1322
|
+
};
|
|
1102
1323
|
function useDocumentPermissions(actionOrActions) {
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
actions
|
|
1136
|
-
}).getCurrent() === void 0)
|
|
1137
|
-
throw firstValueFrom(getPermissionsState(instance, {
|
|
1138
|
-
actions
|
|
1139
|
-
}).observable.pipe(filter(_temp$2)));
|
|
1140
|
-
let t3, t4;
|
|
1141
|
-
$[12] !== actions || $[13] !== instance ? (t4 = getPermissionsState(instance, {
|
|
1142
|
-
actions
|
|
1143
|
-
}), $[12] = actions, $[13] = instance, $[14] = t4) : t4 = $[14], t3 = t4;
|
|
1144
|
-
const {
|
|
1145
|
-
subscribe,
|
|
1146
|
-
getCurrent
|
|
1147
|
-
} = t3;
|
|
1148
|
-
return useSyncExternalStore(subscribe, getCurrent);
|
|
1149
|
-
}
|
|
1150
|
-
function _temp$2(result) {
|
|
1151
|
-
return result !== void 0;
|
|
1324
|
+
const instance = useSanityInstance();
|
|
1325
|
+
trackHookUsage(instance, "useDocumentPermissions");
|
|
1326
|
+
const effectiveContextResource = useEffectiveContextResource(), resources = useContext(ResourcesContext), {
|
|
1327
|
+
actions: normalizedActions,
|
|
1328
|
+
resource: actionResource,
|
|
1329
|
+
error: validationError
|
|
1330
|
+
} = useMemo(() => {
|
|
1331
|
+
const normalized = Array.isArray(actionOrActions) ? actionOrActions.map((action) => normalizeResourceOptions(action, resources, effectiveContextResource)) : [normalizeResourceOptions(actionOrActions, resources, effectiveContextResource)];
|
|
1332
|
+
let resource;
|
|
1333
|
+
for (const action_0 of normalized)
|
|
1334
|
+
if (action_0.resource && (resource || (resource = action_0.resource), !isDeepEqual(action_0.resource, resource)))
|
|
1335
|
+
return {
|
|
1336
|
+
actions: normalized,
|
|
1337
|
+
resource,
|
|
1338
|
+
error: new Error(`Mismatched resources found in actions. All actions must belong to the same resource. Found "${JSON.stringify(action_0.resource)}" but expected "${JSON.stringify(resource)}".`)
|
|
1339
|
+
};
|
|
1340
|
+
return {
|
|
1341
|
+
actions: normalized,
|
|
1342
|
+
resource,
|
|
1343
|
+
error: void 0
|
|
1344
|
+
};
|
|
1345
|
+
}, [actionOrActions, resources, effectiveContextResource]), effectiveResource = actionResource ?? effectiveContextResource, permissionsOptions = useMemo(() => effectiveResource ? {
|
|
1346
|
+
resource: effectiveResource,
|
|
1347
|
+
// `Omit<>` on `DocumentAction` loses the discriminant; runtime values are still actions.
|
|
1348
|
+
actions: normalizedActions
|
|
1349
|
+
} : void 0, [effectiveResource, normalizedActions]), stateSource = useMemo(() => permissionsOptions ? getPermissionsState(instance, permissionsOptions) : void 0, [permissionsOptions, instance]), isDocumentReady = useCallback(() => stateSource !== void 0 && stateSource.getCurrent() !== void 0, [stateSource]), result = useSyncExternalStore(stateSource?.subscribe ?? noopSubscribe, stateSource?.getCurrent ?? returnUndefined);
|
|
1350
|
+
if (validationError) throw validationError;
|
|
1351
|
+
if (!effectiveResource)
|
|
1352
|
+
throw new Error("No resource found. Provide a resource via the action handle or wrap with a resource context.");
|
|
1353
|
+
if (!isDocumentReady())
|
|
1354
|
+
throw firstValueFrom(stateSource.observable.pipe(filter((permissions) => permissions !== void 0)));
|
|
1355
|
+
return result;
|
|
1152
1356
|
}
|
|
1153
1357
|
const useDocumentSyncStatusValue = createStateSourceHook({
|
|
1154
1358
|
getState: getDocumentSyncStatus,
|
|
@@ -1156,7 +1360,7 @@ const useDocumentSyncStatusValue = createStateSourceHook({
|
|
|
1156
1360
|
suspender: (instance, doc) => resolveDocument(instance, doc),
|
|
1157
1361
|
getConfig: identity
|
|
1158
1362
|
}), useDocumentSyncStatus = (options) => {
|
|
1159
|
-
const normalizedOptions =
|
|
1363
|
+
const normalizedOptions = useNormalizedResourceOptions(options);
|
|
1160
1364
|
return useDocumentSyncStatusValue(normalizedOptions);
|
|
1161
1365
|
}, ignoredKeys = ["_id", "_type", "_createdAt", "_updatedAt", "_rev"];
|
|
1162
1366
|
function useEditDocument(t0) {
|
|
@@ -1166,9 +1370,9 @@ function useEditDocument(t0) {
|
|
|
1166
1370
|
path,
|
|
1167
1371
|
...doc
|
|
1168
1372
|
} = t0, $[0] = t0, $[1] = doc, $[2] = path) : (doc = $[1], path = $[2]);
|
|
1169
|
-
const instance = useSanityInstance(
|
|
1373
|
+
const instance = useSanityInstance();
|
|
1170
1374
|
trackHookUsage(instance, "useEditDocument");
|
|
1171
|
-
const normalizedDoc =
|
|
1375
|
+
const normalizedDoc = useNormalizedResourceOptions(doc), apply = useApplyDocumentActions();
|
|
1172
1376
|
if (getDocumentState(instance, normalizedDoc).getCurrent() === void 0)
|
|
1173
1377
|
throw resolveDocument(instance, normalizedDoc);
|
|
1174
1378
|
let t1;
|
|
@@ -1208,9 +1412,9 @@ function _temp$1(key) {
|
|
|
1208
1412
|
return !ignoredKeys.includes(key);
|
|
1209
1413
|
}
|
|
1210
1414
|
function useQuery(options) {
|
|
1211
|
-
const instance = useSanityInstance(
|
|
1415
|
+
const instance = useSanityInstance();
|
|
1212
1416
|
trackHookUsage(instance, "useQuery");
|
|
1213
|
-
const normalized =
|
|
1417
|
+
const normalized = useNormalizedResourceOptions(options), [isPending, startTransition] = useTransition(), queryKey = getQueryKey(normalized), [deferredQueryKey, setDeferredQueryKey] = useState(queryKey), ref = useRef(new AbortController());
|
|
1214
1418
|
useEffect(() => {
|
|
1215
1419
|
queryKey !== deferredQueryKey && startTransition(() => {
|
|
1216
1420
|
ref && !ref.current.signal.aborted && (ref.current.abort(), ref.current = new AbortController()), setDeferredQueryKey(queryKey);
|
|
@@ -1244,10 +1448,10 @@ function useDocuments({
|
|
|
1244
1448
|
filter: filter2,
|
|
1245
1449
|
orderings,
|
|
1246
1450
|
documentType,
|
|
1247
|
-
...
|
|
1451
|
+
...rawOptions
|
|
1248
1452
|
}) {
|
|
1249
1453
|
useTrackHookUsage("useDocuments");
|
|
1250
|
-
const
|
|
1454
|
+
const options = useNormalizedResourceOptions(rawOptions), [limit, setLimit] = useState(batchSize), documentTypes = useMemo(() => (Array.isArray(documentType) ? documentType : [documentType]).filter((i) => typeof i == "string"), [documentType]), key = JSON.stringify({
|
|
1251
1455
|
filter: filter2,
|
|
1252
1456
|
search,
|
|
1253
1457
|
params,
|
|
@@ -1255,10 +1459,8 @@ function useDocuments({
|
|
|
1255
1459
|
batchSize,
|
|
1256
1460
|
types: documentTypes,
|
|
1257
1461
|
...options
|
|
1258
|
-
});
|
|
1259
|
-
|
|
1260
|
-
setLimit(batchSize);
|
|
1261
|
-
}, [key, batchSize]);
|
|
1462
|
+
}), [prevKey, setPrevKey] = useState(key);
|
|
1463
|
+
prevKey !== key && (setPrevKey(key), setLimit(batchSize));
|
|
1262
1464
|
const filterClause = useMemo(() => {
|
|
1263
1465
|
const conditions = [], trimmedSearch = search?.trim();
|
|
1264
1466
|
if (trimmedSearch) {
|
|
@@ -1277,9 +1479,12 @@ function useDocuments({
|
|
|
1277
1479
|
query: `{"count":${countQuery},"data":${dataQuery}}`,
|
|
1278
1480
|
params: {
|
|
1279
1481
|
...params,
|
|
1482
|
+
// these are passed back to the user as part of each document handle
|
|
1280
1483
|
__handle: {
|
|
1281
|
-
|
|
1282
|
-
|
|
1484
|
+
// keep projectId/dataset for backward compat until v4; resource is added
|
|
1485
|
+
// intentionally so that hook consumers can resolve the correct resource
|
|
1486
|
+
...options.resource && isDatasetResource(options.resource) ? pickProperties(options.resource, ["projectId", "dataset"]) : {},
|
|
1487
|
+
...pickProperties(options, ["perspective", "resource"])
|
|
1283
1488
|
},
|
|
1284
1489
|
__types: documentTypes
|
|
1285
1490
|
}
|
|
@@ -1294,9 +1499,18 @@ function useDocuments({
|
|
|
1294
1499
|
loadMore
|
|
1295
1500
|
}), [count, data, hasMore, isPending, loadMore]);
|
|
1296
1501
|
}
|
|
1502
|
+
const useOrganization = createStateSourceHook({
|
|
1503
|
+
getState: getOrganizationState,
|
|
1504
|
+
shouldSuspend: (instance, ...params) => getOrganizationState(instance, ...params).getCurrent() === void 0,
|
|
1505
|
+
suspender: resolveOrganization
|
|
1506
|
+
}), useOrganizations = createStateSourceHook({
|
|
1507
|
+
getState: getOrganizationsState,
|
|
1508
|
+
shouldSuspend: (instance, ...params) => getOrganizationsState(instance, ...params).getCurrent() === void 0,
|
|
1509
|
+
suspender: resolveOrganizations
|
|
1510
|
+
});
|
|
1297
1511
|
function usePaginatedDocuments(t0) {
|
|
1298
|
-
const $ = c(
|
|
1299
|
-
let documentType,
|
|
1512
|
+
const $ = c(60);
|
|
1513
|
+
let documentType, orderings, rawOptions, search, t1, t2, t3;
|
|
1300
1514
|
$[0] !== t0 ? ({
|
|
1301
1515
|
documentType,
|
|
1302
1516
|
filter: t1,
|
|
@@ -1304,90 +1518,86 @@ function usePaginatedDocuments(t0) {
|
|
|
1304
1518
|
params: t3,
|
|
1305
1519
|
orderings,
|
|
1306
1520
|
search,
|
|
1307
|
-
...
|
|
1308
|
-
} = t0, $[0] = t0, $[1] = documentType, $[2] =
|
|
1521
|
+
...rawOptions
|
|
1522
|
+
} = t0, $[0] = t0, $[1] = documentType, $[2] = orderings, $[3] = rawOptions, $[4] = search, $[5] = t1, $[6] = t2, $[7] = t3) : (documentType = $[1], orderings = $[2], rawOptions = $[3], search = $[4], t1 = $[5], t2 = $[6], t3 = $[7]);
|
|
1309
1523
|
const filter2 = t1 === void 0 ? "" : t1, pageSize = t2 === void 0 ? 25 : t2;
|
|
1310
1524
|
let t4;
|
|
1311
1525
|
$[8] !== t3 ? (t4 = t3 === void 0 ? {} : t3, $[8] = t3, $[9] = t4) : t4 = $[9];
|
|
1312
1526
|
const params = t4;
|
|
1313
1527
|
useTrackHookUsage("usePaginatedDocuments");
|
|
1314
|
-
const
|
|
1528
|
+
const options = useNormalizedResourceOptions(rawOptions), [pageIndex, setPageIndex] = useState(0);
|
|
1315
1529
|
let t5;
|
|
1316
|
-
$[10] !== filter2 || $[11] !==
|
|
1530
|
+
$[10] !== filter2 || $[11] !== options || $[12] !== orderings || $[13] !== pageSize || $[14] !== params || $[15] !== search ? (t5 = JSON.stringify({
|
|
1317
1531
|
filter: filter2,
|
|
1318
1532
|
search,
|
|
1319
1533
|
params,
|
|
1320
1534
|
orderings,
|
|
1321
|
-
pageSize
|
|
1322
|
-
|
|
1323
|
-
|
|
1535
|
+
pageSize,
|
|
1536
|
+
...options
|
|
1537
|
+
}), $[10] = filter2, $[11] = options, $[12] = orderings, $[13] = pageSize, $[14] = params, $[15] = search, $[16] = t5) : t5 = $[16];
|
|
1538
|
+
const key = t5, [prevKey, setPrevKey] = useState(key);
|
|
1539
|
+
prevKey !== key && (setPrevKey(key), setPageIndex(0));
|
|
1540
|
+
const startIndex = pageIndex * pageSize, endIndex = (pageIndex + 1) * pageSize;
|
|
1324
1541
|
let t6;
|
|
1325
|
-
$[
|
|
1326
|
-
setPageIndex(0);
|
|
1327
|
-
}, $[16] = t6) : t6 = $[16];
|
|
1542
|
+
$[17] !== documentType ? (t6 = Array.isArray(documentType) ? documentType : [documentType], $[17] = documentType, $[18] = t6) : t6 = $[18];
|
|
1328
1543
|
let t7;
|
|
1329
|
-
$[
|
|
1330
|
-
const
|
|
1544
|
+
$[19] !== t6 ? (t7 = t6.filter(_temp), $[19] = t6, $[20] = t7) : t7 = $[20];
|
|
1545
|
+
const documentTypes = t7;
|
|
1331
1546
|
let t8;
|
|
1332
|
-
$[19] !== documentType ? (t8 = Array.isArray(documentType) ? documentType : [documentType], $[19] = documentType, $[20] = t8) : t8 = $[20];
|
|
1333
|
-
let t9;
|
|
1334
|
-
$[21] !== t8 ? (t9 = t8.filter(_temp), $[21] = t8, $[22] = t9) : t9 = $[22];
|
|
1335
|
-
const documentTypes = t9;
|
|
1336
|
-
let t10;
|
|
1337
1547
|
const conditions = [], trimmedSearch = search?.trim();
|
|
1338
1548
|
if (trimmedSearch) {
|
|
1339
1549
|
const searchFilter = createGroqSearchFilter(trimmedSearch);
|
|
1340
1550
|
searchFilter && conditions.push(searchFilter);
|
|
1341
1551
|
}
|
|
1342
|
-
documentTypes?.length && conditions.push("(_type in $__types)"), filter2 && conditions.push(`(${filter2})`),
|
|
1343
|
-
const filterClause =
|
|
1552
|
+
documentTypes?.length && conditions.push("(_type in $__types)"), filter2 && conditions.push(`(${filter2})`), t8 = conditions.length ? `[${conditions.join(" && ")}]` : "";
|
|
1553
|
+
const filterClause = t8, orderClause = orderings ? `| order(${orderings.map(_temp3).join(",")})` : "", dataQuery = `*${filterClause}${orderClause}[${startIndex}...${endIndex}]{"documentId":_id,"documentType":_type,...$__handle}`, countQuery = `count(*${filterClause})`, t9 = `{"data":${dataQuery},"count":${countQuery}}`;
|
|
1554
|
+
let t10;
|
|
1555
|
+
$[21] !== options.resource ? (t10 = options.resource && isDatasetResource(options.resource) ? pickProperties(options.resource, ["projectId", "dataset"]) : {}, $[21] = options.resource, $[22] = t10) : t10 = $[22];
|
|
1556
|
+
let t11;
|
|
1557
|
+
$[23] !== options ? (t11 = pickProperties(options, ["perspective", "resource"]), $[23] = options, $[24] = t11) : t11 = $[24];
|
|
1344
1558
|
let t12;
|
|
1345
|
-
$[
|
|
1559
|
+
$[25] !== t10 || $[26] !== t11 ? (t12 = {
|
|
1560
|
+
...t10,
|
|
1561
|
+
...t11
|
|
1562
|
+
}, $[25] = t10, $[26] = t11, $[27] = t12) : t12 = $[27];
|
|
1346
1563
|
let t13;
|
|
1347
|
-
$[
|
|
1348
|
-
let t14;
|
|
1349
|
-
$[27] !== t12 || $[28] !== t13 ? (t14 = {
|
|
1350
|
-
...t12,
|
|
1351
|
-
...t13
|
|
1352
|
-
}, $[27] = t12, $[28] = t13, $[29] = t14) : t14 = $[29];
|
|
1353
|
-
let t15;
|
|
1354
|
-
$[30] !== documentTypes || $[31] !== params || $[32] !== t14 ? (t15 = {
|
|
1564
|
+
$[28] !== documentTypes || $[29] !== params || $[30] !== t12 ? (t13 = {
|
|
1355
1565
|
...params,
|
|
1356
1566
|
__types: documentTypes,
|
|
1357
|
-
__handle:
|
|
1358
|
-
}, $[
|
|
1359
|
-
let
|
|
1360
|
-
$[
|
|
1567
|
+
__handle: t12
|
|
1568
|
+
}, $[28] = documentTypes, $[29] = params, $[30] = t12, $[31] = t13) : t13 = $[31];
|
|
1569
|
+
let t14;
|
|
1570
|
+
$[32] !== options || $[33] !== t13 || $[34] !== t9 ? (t14 = {
|
|
1361
1571
|
...options,
|
|
1362
|
-
query:
|
|
1363
|
-
params:
|
|
1364
|
-
}, $[
|
|
1572
|
+
query: t9,
|
|
1573
|
+
params: t13
|
|
1574
|
+
}, $[32] = options, $[33] = t13, $[34] = t9, $[35] = t14) : t14 = $[35];
|
|
1365
1575
|
const {
|
|
1366
|
-
data:
|
|
1576
|
+
data: t15,
|
|
1367
1577
|
isPending
|
|
1368
|
-
} = useQuery(
|
|
1578
|
+
} = useQuery(t14), {
|
|
1369
1579
|
data,
|
|
1370
1580
|
count
|
|
1371
|
-
} =
|
|
1581
|
+
} = t15, totalPages = Math.ceil(count / pageSize), currentPage = pageIndex + 1;
|
|
1582
|
+
let t16;
|
|
1583
|
+
$[36] === Symbol.for("react.memo_cache_sentinel") ? (t16 = () => setPageIndex(0), $[36] = t16) : t16 = $[36];
|
|
1584
|
+
const firstPage = t16;
|
|
1585
|
+
let t17;
|
|
1586
|
+
$[37] === Symbol.for("react.memo_cache_sentinel") ? (t17 = () => setPageIndex(_temp4), $[37] = t17) : t17 = $[37];
|
|
1587
|
+
const previousPage = t17;
|
|
1372
1588
|
let t18;
|
|
1373
|
-
$[38]
|
|
1374
|
-
const
|
|
1589
|
+
$[38] !== totalPages ? (t18 = () => setPageIndex((prev_0) => Math.min(prev_0 + 1, totalPages - 1)), $[38] = totalPages, $[39] = t18) : t18 = $[39];
|
|
1590
|
+
const nextPage = t18;
|
|
1375
1591
|
let t19;
|
|
1376
|
-
$[
|
|
1377
|
-
const
|
|
1592
|
+
$[40] !== totalPages ? (t19 = () => setPageIndex(totalPages - 1), $[40] = totalPages, $[41] = t19) : t19 = $[41];
|
|
1593
|
+
const lastPage = t19;
|
|
1378
1594
|
let t20;
|
|
1379
|
-
$[
|
|
1380
|
-
const nextPage = t20;
|
|
1381
|
-
let t21;
|
|
1382
|
-
$[42] !== totalPages ? (t21 = () => setPageIndex(totalPages - 1), $[42] = totalPages, $[43] = t21) : t21 = $[43];
|
|
1383
|
-
const lastPage = t21;
|
|
1384
|
-
let t22;
|
|
1385
|
-
$[44] !== totalPages ? (t22 = (pageNumber) => {
|
|
1595
|
+
$[42] !== totalPages ? (t20 = (pageNumber) => {
|
|
1386
1596
|
pageNumber < 1 || pageNumber > totalPages || setPageIndex(pageNumber - 1);
|
|
1387
|
-
}, $[
|
|
1388
|
-
const goToPage =
|
|
1389
|
-
let
|
|
1390
|
-
return $[
|
|
1597
|
+
}, $[42] = totalPages, $[43] = t20) : t20 = $[43];
|
|
1598
|
+
const goToPage = t20, hasFirstPage = pageIndex > 0, hasPreviousPage = pageIndex > 0, hasNextPage = pageIndex < totalPages - 1, hasLastPage = pageIndex < totalPages - 1;
|
|
1599
|
+
let t21;
|
|
1600
|
+
return $[44] !== count || $[45] !== currentPage || $[46] !== data || $[47] !== endIndex || $[48] !== goToPage || $[49] !== hasFirstPage || $[50] !== hasLastPage || $[51] !== hasNextPage || $[52] !== hasPreviousPage || $[53] !== isPending || $[54] !== lastPage || $[55] !== nextPage || $[56] !== pageSize || $[57] !== startIndex || $[58] !== totalPages ? (t21 = {
|
|
1391
1601
|
data,
|
|
1392
1602
|
isPending,
|
|
1393
1603
|
pageSize,
|
|
@@ -1405,7 +1615,7 @@ function usePaginatedDocuments(t0) {
|
|
|
1405
1615
|
lastPage,
|
|
1406
1616
|
hasLastPage,
|
|
1407
1617
|
goToPage
|
|
1408
|
-
}, $[
|
|
1618
|
+
}, $[44] = count, $[45] = currentPage, $[46] = data, $[47] = endIndex, $[48] = goToPage, $[49] = hasFirstPage, $[50] = hasLastPage, $[51] = hasNextPage, $[52] = hasPreviousPage, $[53] = isPending, $[54] = lastPage, $[55] = nextPage, $[56] = pageSize, $[57] = startIndex, $[58] = totalPages, $[59] = t21) : t21 = $[59], t21;
|
|
1409
1619
|
}
|
|
1410
1620
|
function _temp4(prev) {
|
|
1411
1621
|
return Math.max(prev - 1, 0);
|
|
@@ -1419,33 +1629,39 @@ function _temp2(str) {
|
|
|
1419
1629
|
function _temp(i) {
|
|
1420
1630
|
return typeof i == "string";
|
|
1421
1631
|
}
|
|
1422
|
-
function usePresence() {
|
|
1423
|
-
const $ = c(
|
|
1632
|
+
function usePresence(t0) {
|
|
1633
|
+
const $ = c(14);
|
|
1634
|
+
let t1;
|
|
1635
|
+
$[0] !== t0 ? (t1 = t0 === void 0 ? {} : t0, $[0] = t0, $[1] = t1) : t1 = $[1];
|
|
1636
|
+
const normalizedOptions = useNormalizedResourceOptions(t1);
|
|
1637
|
+
if (normalizedOptions.resource && isMediaLibraryResource(normalizedOptions.resource))
|
|
1638
|
+
throw new Error("usePresence() does not support media library resources. Presence tracking requires a canvas or dataset resource.");
|
|
1639
|
+
const sanityInstance = useSanityInstance();
|
|
1424
1640
|
trackHookUsage(sanityInstance, "usePresence");
|
|
1425
|
-
let
|
|
1426
|
-
$[
|
|
1427
|
-
const source =
|
|
1428
|
-
let
|
|
1429
|
-
$[
|
|
1430
|
-
const subscribe =
|
|
1431
|
-
let
|
|
1432
|
-
$[
|
|
1433
|
-
const locations = useSyncExternalStore(subscribe,
|
|
1434
|
-
let
|
|
1435
|
-
$[
|
|
1436
|
-
let
|
|
1437
|
-
return $[
|
|
1438
|
-
locations:
|
|
1439
|
-
}, $[
|
|
1641
|
+
let t2, t3;
|
|
1642
|
+
$[2] !== normalizedOptions || $[3] !== sanityInstance ? (t3 = getPresence(sanityInstance, normalizedOptions), $[2] = normalizedOptions, $[3] = sanityInstance, $[4] = t3) : t3 = $[4], t2 = t3;
|
|
1643
|
+
const source = t2;
|
|
1644
|
+
let t4;
|
|
1645
|
+
$[5] !== source ? (t4 = (callback) => source.subscribe(callback), $[5] = source, $[6] = t4) : t4 = $[6];
|
|
1646
|
+
const subscribe = t4;
|
|
1647
|
+
let t5, t6;
|
|
1648
|
+
$[7] !== source ? (t5 = () => source.getCurrent(), t6 = () => source.getCurrent(), $[7] = source, $[8] = t5, $[9] = t6) : (t5 = $[8], t6 = $[9]);
|
|
1649
|
+
const locations = useSyncExternalStore(subscribe, t5, t6);
|
|
1650
|
+
let t7;
|
|
1651
|
+
$[10] !== locations ? (t7 = locations || [], $[10] = locations, $[11] = t7) : t7 = $[11];
|
|
1652
|
+
let t8;
|
|
1653
|
+
return $[12] !== t7 ? (t8 = {
|
|
1654
|
+
locations: t7
|
|
1655
|
+
}, $[12] = t7, $[13] = t8) : t8 = $[13], t8;
|
|
1440
1656
|
}
|
|
1441
1657
|
function useDocumentProjection({
|
|
1442
1658
|
ref,
|
|
1443
1659
|
projection,
|
|
1444
1660
|
...docHandle
|
|
1445
1661
|
}) {
|
|
1446
|
-
const instance = useSanityInstance(
|
|
1662
|
+
const instance = useSanityInstance();
|
|
1447
1663
|
trackHookUsage(instance, "useDocumentProjection");
|
|
1448
|
-
const normalizedProjection = useMemo(() => projection.trim(), [projection]), normalizedDocHandle =
|
|
1664
|
+
const normalizedProjection = useMemo(() => projection.trim(), [projection]), normalizedDocHandle = useNormalizedResourceOptions(docHandle), stateSource = useMemo(() => getProjectionState(instance, {
|
|
1449
1665
|
...normalizedDocHandle,
|
|
1450
1666
|
projection: normalizedProjection
|
|
1451
1667
|
}), [instance, normalizedDocHandle, normalizedProjection]);
|
|
@@ -1479,9 +1695,9 @@ function useDocumentPreview(t0) {
|
|
|
1479
1695
|
ref,
|
|
1480
1696
|
...docHandle
|
|
1481
1697
|
} = t0, $[0] = t0, $[1] = docHandle, $[2] = ref) : (docHandle = $[1], ref = $[2]);
|
|
1482
|
-
const instance = useSanityInstance(
|
|
1698
|
+
const instance = useSanityInstance();
|
|
1483
1699
|
trackHookUsage(instance, "useDocumentPreview");
|
|
1484
|
-
const normalizedDocHandle =
|
|
1700
|
+
const normalizedDocHandle = useNormalizedResourceOptions(docHandle);
|
|
1485
1701
|
let t1;
|
|
1486
1702
|
$[3] !== normalizedDocHandle || $[4] !== ref ? (t1 = {
|
|
1487
1703
|
...normalizedDocHandle,
|
|
@@ -1490,7 +1706,7 @@ function useDocumentPreview(t0) {
|
|
|
1490
1706
|
}, $[3] = normalizedDocHandle, $[4] = ref, $[5] = t1) : t1 = $[5];
|
|
1491
1707
|
const projectionResult = useDocumentProjection(t1);
|
|
1492
1708
|
let t2, t3;
|
|
1493
|
-
$[6] !== instance || $[7] !== normalizedDocHandle.
|
|
1709
|
+
$[6] !== instance || $[7] !== normalizedDocHandle.resource || $[8] !== projectionResult.data ? (t3 = transformProjectionToPreview(instance, projectionResult.data, normalizedDocHandle.resource), $[6] = instance, $[7] = normalizedDocHandle.resource, $[8] = projectionResult.data, $[9] = t3) : t3 = $[9], t2 = t3;
|
|
1494
1710
|
const previewValue = t2;
|
|
1495
1711
|
let t4;
|
|
1496
1712
|
return $[10] !== previewValue || $[11] !== projectionResult.isPending ? (t4 = {
|
|
@@ -1499,38 +1715,40 @@ function useDocumentPreview(t0) {
|
|
|
1499
1715
|
}, $[10] = previewValue, $[11] = projectionResult.isPending, $[12] = t4) : t4 = $[12], t4;
|
|
1500
1716
|
}
|
|
1501
1717
|
const useProject = createStateSourceHook({
|
|
1502
|
-
// remove `undefined` since we're suspending when that is the case
|
|
1503
1718
|
getState: getProjectState,
|
|
1504
|
-
shouldSuspend: (instance,
|
|
1719
|
+
shouldSuspend: (instance, ...params) => getProjectState(instance, ...params).getCurrent() === void 0,
|
|
1505
1720
|
suspender: resolveProject,
|
|
1506
1721
|
getConfig: identity
|
|
1507
1722
|
}), useProjects = createStateSourceHook({
|
|
1508
1723
|
getState: getProjectsState,
|
|
1509
|
-
shouldSuspend: (instance,
|
|
1724
|
+
shouldSuspend: (instance, ...params) => getProjectsState(instance, ...params).getCurrent() === void 0,
|
|
1510
1725
|
suspender: resolveProjects
|
|
1511
1726
|
}), useActiveReleasesValue = createStateSourceHook({
|
|
1512
1727
|
getState: getActiveReleasesState,
|
|
1513
1728
|
shouldSuspend: (instance, options) => getActiveReleasesState(instance, options ?? {}).getCurrent() === void 0,
|
|
1514
1729
|
suspender: (instance, options) => firstValueFrom(getActiveReleasesState(instance, options ?? {}).observable.pipe(filter(Boolean)))
|
|
1515
|
-
})
|
|
1730
|
+
});
|
|
1731
|
+
function useActiveReleases(options) {
|
|
1516
1732
|
const $ = c(2);
|
|
1517
1733
|
let t0;
|
|
1518
1734
|
$[0] !== options ? (t0 = options ?? {}, $[0] = options, $[1] = t0) : t0 = $[1];
|
|
1519
|
-
const normalizedOptions =
|
|
1735
|
+
const normalizedOptions = useNormalizedResourceOptions(t0);
|
|
1520
1736
|
return useActiveReleasesValue(normalizedOptions);
|
|
1521
|
-
}
|
|
1737
|
+
}
|
|
1738
|
+
const usePerspectiveValue = createStateSourceHook({
|
|
1522
1739
|
getState: getPerspectiveState,
|
|
1523
1740
|
shouldSuspend: (instance, options) => getPerspectiveState(instance, options).getCurrent() === void 0,
|
|
1524
1741
|
suspender: (instance, _options) => firstValueFrom(getPerspectiveState(instance, _options ?? {}).observable.pipe(filter(Boolean)))
|
|
1525
|
-
})
|
|
1742
|
+
});
|
|
1743
|
+
function usePerspective(perspectiveHandle) {
|
|
1526
1744
|
const $ = c(2);
|
|
1527
1745
|
let t0;
|
|
1528
|
-
$[0] !==
|
|
1529
|
-
const normalizedOptions =
|
|
1746
|
+
$[0] !== perspectiveHandle ? (t0 = perspectiveHandle ?? {}, $[0] = perspectiveHandle, $[1] = t0) : t0 = $[1];
|
|
1747
|
+
const normalizedOptions = useNormalizedResourceOptions(t0);
|
|
1530
1748
|
return usePerspectiveValue(normalizedOptions);
|
|
1531
|
-
}
|
|
1749
|
+
}
|
|
1532
1750
|
function useUser(options) {
|
|
1533
|
-
const instance = useSanityInstance(
|
|
1751
|
+
const instance = useSanityInstance();
|
|
1534
1752
|
trackHookUsage(instance, "useUser");
|
|
1535
1753
|
const [isPending, startTransition] = useTransition(), key = getUsersKey(instance, options), [deferredKey, setDeferredKey] = useState(key), deferred = useMemo(() => parseUsersKey(deferredKey), [deferredKey]), [ref, setRef] = useState(new AbortController());
|
|
1536
1754
|
useEffect(() => {
|
|
@@ -1553,7 +1771,7 @@ function useUser(options) {
|
|
|
1553
1771
|
};
|
|
1554
1772
|
}
|
|
1555
1773
|
function useUsers(options) {
|
|
1556
|
-
const instance = useSanityInstance(
|
|
1774
|
+
const instance = useSanityInstance();
|
|
1557
1775
|
trackHookUsage(instance, "useUsers");
|
|
1558
1776
|
const [isPending, startTransition] = useTransition(), key = getUsersKey(instance, options), [deferredKey, setDeferredKey] = useState(key), deferred = useMemo(() => parseUsersKey(deferredKey), [deferredKey]), [ref, setRef] = useState(new AbortController());
|
|
1559
1777
|
useEffect(() => {
|
|
@@ -1583,7 +1801,7 @@ function useUsers(options) {
|
|
|
1583
1801
|
loadMore
|
|
1584
1802
|
};
|
|
1585
1803
|
}
|
|
1586
|
-
var version = "2.
|
|
1804
|
+
var version = "2.11.0";
|
|
1587
1805
|
function getEnv(key) {
|
|
1588
1806
|
if (typeof import.meta < "u" && import.meta.env)
|
|
1589
1807
|
return import.meta.env[key];
|
|
@@ -1601,6 +1819,7 @@ export {
|
|
|
1601
1819
|
SDKProvider,
|
|
1602
1820
|
SDKStudioContext,
|
|
1603
1821
|
SanityApp,
|
|
1822
|
+
SanityInstanceProvider,
|
|
1604
1823
|
renderSanityApp,
|
|
1605
1824
|
useActiveReleases,
|
|
1606
1825
|
useAgentGenerate,
|
|
@@ -1632,6 +1851,8 @@ export {
|
|
|
1632
1851
|
useLoginUrl,
|
|
1633
1852
|
useManageFavorite,
|
|
1634
1853
|
useNavigateToStudioDocument,
|
|
1854
|
+
useOrganization,
|
|
1855
|
+
useOrganizations,
|
|
1635
1856
|
usePaginatedDocuments,
|
|
1636
1857
|
usePerspective,
|
|
1637
1858
|
usePresence,
|
|
@@ -1639,6 +1860,7 @@ export {
|
|
|
1639
1860
|
useProjects,
|
|
1640
1861
|
useQuery,
|
|
1641
1862
|
useRecordDocumentHistoryEvent,
|
|
1863
|
+
useResource,
|
|
1642
1864
|
useSanityInstance,
|
|
1643
1865
|
useStudioWorkspacesByProjectIdDataset,
|
|
1644
1866
|
useUser,
|