@sanity/sdk-react 2.10.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 +257 -200
- package/dist/index.js +364 -253
- package/dist/index.js.map +1 -1
- package/package.json +6 -9
- package/src/_exports/index.ts +2 -0
- package/src/_exports/sdk-react.ts +4 -0
- package/src/components/SDKProvider.test.tsx +5 -12
- package/src/components/SDKProvider.tsx +26 -24
- 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 +53 -49
- package/src/hooks/agent/agentActions.ts +55 -38
- 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 +5 -1
- package/src/hooks/dashboard/useDispatchIntent.ts +3 -3
- package/src/hooks/dashboard/useManageFavorite.test.tsx +16 -12
- package/src/hooks/dashboard/utils/useResourceIdFromDocumentHandle.ts +1 -5
- package/src/hooks/document/{useApplyDocumentActions.test.ts → useApplyDocumentActions.test.tsx} +42 -77
- package/src/hooks/document/useApplyDocumentActions.ts +28 -62
- package/src/hooks/document/useDocument.ts +3 -5
- package/src/hooks/document/useDocumentEvent.ts +4 -3
- package/src/hooks/document/useDocumentPermissions.test.tsx +58 -150
- package/src/hooks/document/useDocumentPermissions.ts +78 -55
- package/src/hooks/document/useEditDocument.test.tsx +25 -60
- package/src/hooks/document/useEditDocument.ts +1 -1
- package/src/hooks/documents/useDocuments.ts +13 -8
- package/src/hooks/helpers/createStateSourceHook.tsx +1 -2
- package/src/hooks/helpers/useNormalizedResourceOptions.test.tsx +253 -0
- package/src/hooks/helpers/useNormalizedResourceOptions.ts +85 -47
- 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 +23 -9
- package/src/hooks/presence/usePresence.ts +4 -11
- package/src/hooks/preview/useDocumentPreview.tsx +4 -7
- package/src/hooks/projection/useDocumentProjection.ts +5 -7
- 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 +1 -1
- package/src/hooks/releases/useActiveReleases.ts +6 -6
- package/src/hooks/releases/usePerspective.ts +7 -12
- package/src/hooks/users/useUser.ts +1 -1
- package/src/hooks/users/useUsers.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,40 +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, isImportError, 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, Suspense,
|
|
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
|
-
const SanityInstanceContext = createContext(null), useSanityInstance = (config) => {
|
|
13
|
-
|
|
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);
|
|
14
19
|
if (!instance)
|
|
15
|
-
throw new Error(
|
|
16
|
-
|
|
17
|
-
return instance;
|
|
18
|
-
let t0;
|
|
19
|
-
$[0] !== config || $[1] !== instance ? (t0 = instance.match(config), $[0] = config, $[1] = instance, $[2] = t0) : t0 = $[2];
|
|
20
|
-
const match = t0;
|
|
21
|
-
if (!match)
|
|
22
|
-
throw new Error(`Could not find a matching Sanity instance for the requested configuration: ${JSON.stringify(config, null, 2)}.
|
|
23
|
-
Please ensure there is a ResourceProvider component with a matching configuration in the component hierarchy.`);
|
|
24
|
-
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;
|
|
25
22
|
};
|
|
26
23
|
function createStateSourceHook(options) {
|
|
27
|
-
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;
|
|
28
25
|
function useHook(...t0) {
|
|
29
|
-
const $ = c(
|
|
30
|
-
let t1;
|
|
31
|
-
$[0] !== params ? (t1 = getConfig?.(...params), $[0] = params, $[1] = t1) : t1 = $[1];
|
|
32
|
-
const instance = useSanityInstance(t1);
|
|
26
|
+
const $ = c(3), params = t0, instance = useSanityInstance();
|
|
33
27
|
if (suspense?.suspender && suspense?.shouldSuspend?.(instance, ...params))
|
|
34
28
|
throw suspense.suspender(instance, ...params);
|
|
35
|
-
let
|
|
36
|
-
$[
|
|
37
|
-
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;
|
|
38
32
|
return useSyncExternalStore(state.subscribe, state.getCurrent);
|
|
39
33
|
}
|
|
40
34
|
return useHook;
|
|
@@ -66,7 +60,7 @@ function useWindowConnection(t0) {
|
|
|
66
60
|
const [type, handler] = t42, messageUnsubscribe = node.on(type, handler);
|
|
67
61
|
messageUnsubscribe && messageUnsubscribers.current.push(messageUnsubscribe);
|
|
68
62
|
}), () => {
|
|
69
|
-
messageUnsubscribers.current.forEach(_temp$
|
|
63
|
+
messageUnsubscribers.current.forEach(_temp$8), messageUnsubscribers.current = [];
|
|
70
64
|
}), $[4] = node, $[5] = onMessage, $[6] = t3) : t3 = $[6];
|
|
71
65
|
let t4;
|
|
72
66
|
$[7] !== instance || $[8] !== name || $[9] !== node || $[10] !== onMessage ? (t4 = [instance, name, onMessage, node], $[7] = instance, $[8] = name, $[9] = node, $[10] = onMessage, $[11] = t4) : t4 = $[11], useEffect(t3, t4);
|
|
@@ -84,7 +78,7 @@ function useWindowConnection(t0) {
|
|
|
84
78
|
fetch
|
|
85
79
|
}, $[16] = fetch, $[17] = sendMessage, $[18] = t7) : t7 = $[18], t7;
|
|
86
80
|
}
|
|
87
|
-
function _temp$
|
|
81
|
+
function _temp$8(unsubscribe) {
|
|
88
82
|
return unsubscribe();
|
|
89
83
|
}
|
|
90
84
|
const DEFAULT_RESPONSE_TIMEOUT = 1e4;
|
|
@@ -114,7 +108,7 @@ function DashboardTokenRefresh(t0) {
|
|
|
114
108
|
if (clearRefreshTimeout(), res.token) {
|
|
115
109
|
setAuthToken(instance, res.token);
|
|
116
110
|
const errorContainer = document.getElementById("__sanityError");
|
|
117
|
-
errorContainer && Array.from(errorContainer.getElementsByTagName("div")).some(_temp$
|
|
111
|
+
errorContainer && Array.from(errorContainer.getElementsByTagName("div")).some(_temp$7) && errorContainer.remove();
|
|
118
112
|
}
|
|
119
113
|
isTokenRefreshInProgress.current = !1;
|
|
120
114
|
} catch {
|
|
@@ -135,7 +129,7 @@ function DashboardTokenRefresh(t0) {
|
|
|
135
129
|
let t7;
|
|
136
130
|
return $[11] !== authState || $[12] !== requestNewToken ? (t7 = [authState, requestNewToken], $[11] = authState, $[12] = requestNewToken, $[13] = t7) : t7 = $[13], useEffect(t6, t7), children;
|
|
137
131
|
}
|
|
138
|
-
function _temp$
|
|
132
|
+
function _temp$7(div) {
|
|
139
133
|
return div.textContent?.includes("Uncaught error: Unauthorized - A valid session is required for this endpoint");
|
|
140
134
|
}
|
|
141
135
|
const ComlinkTokenRefreshProvider = (t0) => {
|
|
@@ -272,10 +266,10 @@ function ChunkLoadError(_props) {
|
|
|
272
266
|
let t3;
|
|
273
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: {
|
|
274
268
|
text: "Reload page",
|
|
275
|
-
onClick: _temp$
|
|
269
|
+
onClick: _temp$6
|
|
276
270
|
} }), $[3] = t3) : t3 = $[3], t3;
|
|
277
271
|
}
|
|
278
|
-
function _temp$
|
|
272
|
+
function _temp$6() {
|
|
279
273
|
clearChunkReloadFlag(), reload();
|
|
280
274
|
}
|
|
281
275
|
function CorsErrorComponent(t0) {
|
|
@@ -336,10 +330,10 @@ function LoginCallback() {
|
|
|
336
330
|
let t0, t1;
|
|
337
331
|
return $[0] !== handleAuthCallback2 ? (t0 = () => {
|
|
338
332
|
const url = new URL(location.href);
|
|
339
|
-
handleAuthCallback2(url.toString()).then(_temp$
|
|
333
|
+
handleAuthCallback2(url.toString()).then(_temp$5);
|
|
340
334
|
}, t1 = [handleAuthCallback2], $[0] = handleAuthCallback2, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1), null;
|
|
341
335
|
}
|
|
342
|
-
function _temp$
|
|
336
|
+
function _temp$5(replacementLocation) {
|
|
343
337
|
replacementLocation && history.replaceState(null, "", replacementLocation);
|
|
344
338
|
}
|
|
345
339
|
const useLogOut = createCallbackHook(logout);
|
|
@@ -491,6 +485,7 @@ function AuthSwitch(t0) {
|
|
|
491
485
|
}
|
|
492
486
|
const SDKStudioContext = createContext(null);
|
|
493
487
|
SDKStudioContext.displayName = "SDKStudioContext";
|
|
488
|
+
const DEFAULT_RESOURCE_NAME = "default", ResourceContext = createContext(void 0), PerspectiveContext = createContext(void 0);
|
|
494
489
|
function SanityInstanceProvider(t0) {
|
|
495
490
|
const $ = c(6), {
|
|
496
491
|
instance,
|
|
@@ -503,36 +498,72 @@ function SanityInstanceProvider(t0) {
|
|
|
503
498
|
return $[3] !== instance || $[4] !== t1 ? (t2 = /* @__PURE__ */ jsx(SanityInstanceContext.Provider, { value: instance, children: t1 }), $[3] = instance, $[4] = t1, $[5] = t2) : t2 = $[5], t2;
|
|
504
499
|
}
|
|
505
500
|
const DEFAULT_FALLBACK = /* @__PURE__ */ jsx(Fragment, { children: "Warning: No fallback provided. Please supply a fallback prop to ensure proper Suspense handling." });
|
|
506
|
-
function ResourceProvider({
|
|
507
|
-
|
|
508
|
-
fallback,
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}, [
|
|
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);
|
|
515
538
|
const disposal = useRef(null);
|
|
516
|
-
|
|
539
|
+
let t6, t7;
|
|
540
|
+
$[15] !== instance || $[16] !== parentInstance ? (t6 = () => (disposal.current !== null && instance === disposal.current.instance && (clearTimeout(disposal.current.timeoutId), disposal.current = null), () => {
|
|
517
541
|
disposal.current = {
|
|
518
542
|
instance,
|
|
519
543
|
timeoutId: setTimeout(() => {
|
|
520
|
-
instance.isDisposed()
|
|
544
|
+
!instance.isDisposed() && instance !== parentInstance && instance.dispose();
|
|
521
545
|
}, 0)
|
|
522
546
|
};
|
|
523
|
-
}), [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;
|
|
524
555
|
}
|
|
525
556
|
const ResourcesContext = createContext({});
|
|
526
557
|
function ResetChunkReloadFlagOnMount() {
|
|
527
558
|
const $ = c(1);
|
|
528
559
|
let t0;
|
|
529
|
-
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0], useEffect(_temp$
|
|
560
|
+
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0], useEffect(_temp$4, t0), null;
|
|
530
561
|
}
|
|
531
|
-
function _temp$
|
|
562
|
+
function _temp$4() {
|
|
532
563
|
clearChunkReloadFlag();
|
|
533
564
|
}
|
|
534
565
|
function SDKProvider(t0) {
|
|
535
|
-
const $ = c(
|
|
566
|
+
const $ = c(29);
|
|
536
567
|
let children, config, fallback, props;
|
|
537
568
|
$[0] !== t0 ? ({
|
|
538
569
|
children,
|
|
@@ -542,23 +573,42 @@ function SDKProvider(t0) {
|
|
|
542
573
|
} = t0, $[0] = t0, $[1] = children, $[2] = config, $[3] = fallback, $[4] = props) : (children = $[1], config = $[2], fallback = $[3], props = $[4]);
|
|
543
574
|
let t1;
|
|
544
575
|
$[5] !== config ? (t1 = Array.isArray(config) ? config : [config], $[5] = config, $[6] = t1) : t1 = $[6];
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
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
|
+
}
|
|
550
600
|
const resourcesValue = t3;
|
|
601
|
+
let t4;
|
|
602
|
+
$[17] === Symbol.for("react.memo_cache_sentinel") ? (t4 = /* @__PURE__ */ jsx(ResetChunkReloadFlagOnMount, {}), $[17] = t4) : t4 = $[17];
|
|
551
603
|
let t5;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
t5 = $[18];
|
|
561
|
-
return t5;
|
|
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;
|
|
562
612
|
}
|
|
563
613
|
function _temp3$1(id) {
|
|
564
614
|
return !!id;
|
|
@@ -616,12 +666,12 @@ function SanityApp(t0) {
|
|
|
616
666
|
$[8] !== configProp || $[9] !== resolvedConfig || $[10] !== studioWorkspace ? (t2 = () => {
|
|
617
667
|
let timeout;
|
|
618
668
|
const primaryConfig = Array.isArray(resolvedConfig) ? resolvedConfig[0] : resolvedConfig, shouldRedirectWithoutConfig = configProp === void 0 && !studioWorkspace && !primaryConfig;
|
|
619
|
-
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);
|
|
620
670
|
}, t3 = [configProp, resolvedConfig, studioWorkspace], $[8] = configProp, $[9] = resolvedConfig, $[10] = studioWorkspace, $[11] = t2, $[12] = t3) : (t2 = $[11], t3 = $[12]), useEffect(t2, t3);
|
|
621
671
|
let t4;
|
|
622
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;
|
|
623
673
|
}
|
|
624
|
-
function _temp$
|
|
674
|
+
function _temp$3() {
|
|
625
675
|
console.warn("Redirecting to core", REDIRECT_URL), window.location.replace(REDIRECT_URL);
|
|
626
676
|
}
|
|
627
677
|
function renderSanityApp(rootElement, namedSources, options, children) {
|
|
@@ -632,15 +682,121 @@ function renderSanityApp(rootElement, namedSources, options, children) {
|
|
|
632
682
|
} = options, root = createRoot(rootElement), config = Object.values(namedSources);
|
|
633
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();
|
|
634
684
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
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;
|
|
744
|
+
}
|
|
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;
|
|
638
789
|
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
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;
|
|
642
799
|
}
|
|
643
|
-
const useAgentPatch = createCallbackHook(patchAdapter);
|
|
644
800
|
function useAgentResourceContext(options) {
|
|
645
801
|
const $ = c(9), {
|
|
646
802
|
projectId,
|
|
@@ -729,7 +885,7 @@ function useFrameConnection(options) {
|
|
|
729
885
|
const [type, handler] = t22, unsubscribe = channel.on(type, handler);
|
|
730
886
|
messageUnsubscribers.push(unsubscribe);
|
|
731
887
|
}), () => {
|
|
732
|
-
messageUnsubscribers.forEach(_temp$
|
|
888
|
+
messageUnsubscribers.forEach(_temp$2), releaseChannel(instance, name), channelRef.current = null, controllerRef.current = null;
|
|
733
889
|
};
|
|
734
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);
|
|
735
891
|
let t2;
|
|
@@ -751,9 +907,12 @@ function useFrameConnection(options) {
|
|
|
751
907
|
sendMessage
|
|
752
908
|
}, $[11] = t4) : t4 = $[11], t4;
|
|
753
909
|
}
|
|
754
|
-
function _temp$
|
|
910
|
+
function _temp$2(unsub) {
|
|
755
911
|
return unsub();
|
|
756
912
|
}
|
|
913
|
+
function useResource() {
|
|
914
|
+
return useEffectiveContextResource();
|
|
915
|
+
}
|
|
757
916
|
function useDashboardNavigate(navigateFn) {
|
|
758
917
|
const $ = c(2);
|
|
759
918
|
let t0;
|
|
@@ -767,39 +926,12 @@ function useDashboardNavigate(navigateFn) {
|
|
|
767
926
|
}
|
|
768
927
|
}, $[0] = navigateFn, $[1] = t0) : t0 = $[1], useWindowConnection(t0);
|
|
769
928
|
}
|
|
770
|
-
function normalizeResourceOptions(options, resources) {
|
|
771
|
-
const {
|
|
772
|
-
resourceName,
|
|
773
|
-
sourceName,
|
|
774
|
-
source,
|
|
775
|
-
...rest
|
|
776
|
-
} = options, effectiveResourceName = resourceName ?? sourceName, effectiveResource = options.resource ?? source;
|
|
777
|
-
if (!effectiveResourceName && !effectiveResource)
|
|
778
|
-
return rest;
|
|
779
|
-
const hasNameKey = Object.hasOwn(options, "resourceName") || Object.hasOwn(options, "sourceName"), hasResourceKey = Object.hasOwn(options, "resource") || Object.hasOwn(options, "source");
|
|
780
|
-
if (hasNameKey && hasResourceKey)
|
|
781
|
-
throw new Error(`Resource name ${JSON.stringify(effectiveResourceName)} and resource ${JSON.stringify(effectiveResource)} cannot be used together.`);
|
|
782
|
-
let resolvedResource;
|
|
783
|
-
if (effectiveResource && (resolvedResource = effectiveResource), effectiveResourceName && !Object.hasOwn(resources, effectiveResourceName))
|
|
784
|
-
throw new Error(`There's no resource named ${JSON.stringify(effectiveResourceName)} in context. Please use <ResourceProvider>.`);
|
|
785
|
-
return effectiveResourceName && resources[effectiveResourceName] && (resolvedResource = resources[effectiveResourceName]), {
|
|
786
|
-
...rest,
|
|
787
|
-
resource: resolvedResource
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
function useNormalizedResourceOptions(options) {
|
|
791
|
-
const $ = c(3), resources = useContext(ResourcesContext);
|
|
792
|
-
let t0;
|
|
793
|
-
return $[0] !== options || $[1] !== resources ? (t0 = normalizeResourceOptions(options, resources), $[0] = options, $[1] = resources, $[2] = t0) : t0 = $[2], t0;
|
|
794
|
-
}
|
|
795
929
|
function useResourceIdFromDocumentHandle(documentHandle) {
|
|
796
930
|
const $ = c(3), options = useNormalizedResourceOptions(documentHandle), {
|
|
797
|
-
projectId,
|
|
798
|
-
dataset,
|
|
799
931
|
resource
|
|
800
932
|
} = options;
|
|
801
933
|
let resourceId = "", resourceType;
|
|
802
|
-
|
|
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"));
|
|
803
935
|
let t0;
|
|
804
936
|
return $[0] !== resourceId || $[1] !== resourceType ? (t0 = {
|
|
805
937
|
id: resourceId,
|
|
@@ -1113,50 +1245,24 @@ const useDatasets = createStateSourceHook({
|
|
|
1113
1245
|
suspender: resolveDatasets,
|
|
1114
1246
|
getConfig: identity
|
|
1115
1247
|
}), useApplyDocumentActions = () => {
|
|
1116
|
-
const $ = c(
|
|
1248
|
+
const $ = c(4), instance = useSanityInstance(), resources = useContext(ResourcesContext), effectiveContextResource = useEffectiveContextResource();
|
|
1117
1249
|
let t0;
|
|
1118
|
-
return $[0] !==
|
|
1119
|
-
const actions = Array.isArray(actionOrActions) ? actionOrActions : [actionOrActions],
|
|
1120
|
-
let
|
|
1121
|
-
for (const
|
|
1122
|
-
if (
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1130
|
-
if (action.resource) {
|
|
1131
|
-
if (resource || (resource = action.resource), action.resource !== resource)
|
|
1132
|
-
throw new Error(`Mismatched resources found in actions. All actions must belong to the same resource. Found "${action.resource}" but expected "${resource}".`);
|
|
1133
|
-
if (projectId || dataset)
|
|
1134
|
-
throw new Error(`Mismatches between projectId/dataset options and resource in actions. Found "${action.resource}" but expected project "${projectId}" and dataset "${dataset}".`);
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
if (projectId || dataset) {
|
|
1138
|
-
const actualInstance = instance.match({
|
|
1139
|
-
projectId,
|
|
1140
|
-
dataset
|
|
1141
|
-
});
|
|
1142
|
-
if (!actualInstance)
|
|
1143
|
-
throw new Error(`Could not find a matching Sanity instance for the requested action: ${JSON.stringify({
|
|
1144
|
-
projectId,
|
|
1145
|
-
dataset
|
|
1146
|
-
}, null, 2)}.
|
|
1147
|
-
Please ensure there is a ResourceProvider component with a matching configuration in the component hierarchy.`);
|
|
1148
|
-
return applyDocumentActions(actualInstance, {
|
|
1149
|
-
actions,
|
|
1150
|
-
resource,
|
|
1151
|
-
...normalizedOptions
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
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.");
|
|
1154
1261
|
return applyDocumentActions(instance, {
|
|
1155
|
-
actions,
|
|
1156
|
-
resource
|
|
1157
|
-
...normalizedOptions
|
|
1262
|
+
actions: normalizedActions,
|
|
1263
|
+
resource: effectiveResource
|
|
1158
1264
|
});
|
|
1159
|
-
}, $[0] =
|
|
1265
|
+
}, $[0] = effectiveContextResource, $[1] = instance, $[2] = resources, $[3] = t0) : t0 = $[3], t0;
|
|
1160
1266
|
};
|
|
1161
1267
|
function useTrackHookUsage(hookName) {
|
|
1162
1268
|
const instance = useSanityInstance(), tracked = useRef(null);
|
|
@@ -1204,63 +1310,49 @@ function useDocumentEvent(options) {
|
|
|
1204
1310
|
}, $[3] = onEvent, $[4] = t0) : t0 = $[4], useInsertionEffect(t0);
|
|
1205
1311
|
let t1;
|
|
1206
1312
|
$[5] === Symbol.for("react.memo_cache_sentinel") ? (t1 = (documentEvent) => ref.current(documentEvent), $[5] = t1) : t1 = $[5];
|
|
1207
|
-
const stableHandler = t1, instance = useSanityInstance(
|
|
1313
|
+
const stableHandler = t1, instance = useSanityInstance();
|
|
1208
1314
|
let t2, t3;
|
|
1209
1315
|
$[6] !== datasetHandle.resource || $[7] !== instance ? (t2 = () => subscribeDocumentEvents(instance, {
|
|
1210
1316
|
eventHandler: stableHandler,
|
|
1211
1317
|
resource: datasetHandle.resource
|
|
1212
1318
|
}), t3 = [instance, datasetHandle.resource, stableHandler], $[6] = datasetHandle.resource, $[7] = instance, $[8] = t2, $[9] = t3) : (t2 = $[8], t3 = $[9]), useEffect(t2, t3);
|
|
1213
1319
|
}
|
|
1320
|
+
const noopSubscribe = () => () => {
|
|
1321
|
+
}, returnUndefined = () => {
|
|
1322
|
+
};
|
|
1214
1323
|
function useDocumentPermissions(actionOrActions) {
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
actions
|
|
1248
|
-
}).getCurrent() === void 0)
|
|
1249
|
-
throw firstValueFrom(getPermissionsState(instance, {
|
|
1250
|
-
actions
|
|
1251
|
-
}).observable.pipe(filter(_temp$2)));
|
|
1252
|
-
let t3, t4;
|
|
1253
|
-
$[12] !== actions || $[13] !== instance ? (t4 = getPermissionsState(instance, {
|
|
1254
|
-
actions
|
|
1255
|
-
}), $[12] = actions, $[13] = instance, $[14] = t4) : t4 = $[14], t3 = t4;
|
|
1256
|
-
const {
|
|
1257
|
-
subscribe,
|
|
1258
|
-
getCurrent
|
|
1259
|
-
} = t3;
|
|
1260
|
-
return useSyncExternalStore(subscribe, getCurrent);
|
|
1261
|
-
}
|
|
1262
|
-
function _temp$2(result) {
|
|
1263
|
-
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;
|
|
1264
1356
|
}
|
|
1265
1357
|
const useDocumentSyncStatusValue = createStateSourceHook({
|
|
1266
1358
|
getState: getDocumentSyncStatus,
|
|
@@ -1278,7 +1370,7 @@ function useEditDocument(t0) {
|
|
|
1278
1370
|
path,
|
|
1279
1371
|
...doc
|
|
1280
1372
|
} = t0, $[0] = t0, $[1] = doc, $[2] = path) : (doc = $[1], path = $[2]);
|
|
1281
|
-
const instance = useSanityInstance(
|
|
1373
|
+
const instance = useSanityInstance();
|
|
1282
1374
|
trackHookUsage(instance, "useEditDocument");
|
|
1283
1375
|
const normalizedDoc = useNormalizedResourceOptions(doc), apply = useApplyDocumentActions();
|
|
1284
1376
|
if (getDocumentState(instance, normalizedDoc).getCurrent() === void 0)
|
|
@@ -1320,7 +1412,7 @@ function _temp$1(key) {
|
|
|
1320
1412
|
return !ignoredKeys.includes(key);
|
|
1321
1413
|
}
|
|
1322
1414
|
function useQuery(options) {
|
|
1323
|
-
const instance = useSanityInstance(
|
|
1415
|
+
const instance = useSanityInstance();
|
|
1324
1416
|
trackHookUsage(instance, "useQuery");
|
|
1325
1417
|
const normalized = useNormalizedResourceOptions(options), [isPending, startTransition] = useTransition(), queryKey = getQueryKey(normalized), [deferredQueryKey, setDeferredQueryKey] = useState(queryKey), ref = useRef(new AbortController());
|
|
1326
1418
|
useEffect(() => {
|
|
@@ -1356,10 +1448,10 @@ function useDocuments({
|
|
|
1356
1448
|
filter: filter2,
|
|
1357
1449
|
orderings,
|
|
1358
1450
|
documentType,
|
|
1359
|
-
...
|
|
1451
|
+
...rawOptions
|
|
1360
1452
|
}) {
|
|
1361
1453
|
useTrackHookUsage("useDocuments");
|
|
1362
|
-
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({
|
|
1363
1455
|
filter: filter2,
|
|
1364
1456
|
search,
|
|
1365
1457
|
params,
|
|
@@ -1389,9 +1481,10 @@ function useDocuments({
|
|
|
1389
1481
|
...params,
|
|
1390
1482
|
// these are passed back to the user as part of each document handle
|
|
1391
1483
|
__handle: {
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
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"])
|
|
1395
1488
|
},
|
|
1396
1489
|
__types: documentTypes
|
|
1397
1490
|
}
|
|
@@ -1406,9 +1499,18 @@ function useDocuments({
|
|
|
1406
1499
|
loadMore
|
|
1407
1500
|
}), [count, data, hasMore, isPending, loadMore]);
|
|
1408
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
|
+
});
|
|
1409
1511
|
function usePaginatedDocuments(t0) {
|
|
1410
|
-
const $ = c(
|
|
1411
|
-
let documentType,
|
|
1512
|
+
const $ = c(60);
|
|
1513
|
+
let documentType, orderings, rawOptions, search, t1, t2, t3;
|
|
1412
1514
|
$[0] !== t0 ? ({
|
|
1413
1515
|
documentType,
|
|
1414
1516
|
filter: t1,
|
|
@@ -1416,29 +1518,30 @@ function usePaginatedDocuments(t0) {
|
|
|
1416
1518
|
params: t3,
|
|
1417
1519
|
orderings,
|
|
1418
1520
|
search,
|
|
1419
|
-
...
|
|
1420
|
-
} = 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]);
|
|
1421
1523
|
const filter2 = t1 === void 0 ? "" : t1, pageSize = t2 === void 0 ? 25 : t2;
|
|
1422
1524
|
let t4;
|
|
1423
1525
|
$[8] !== t3 ? (t4 = t3 === void 0 ? {} : t3, $[8] = t3, $[9] = t4) : t4 = $[9];
|
|
1424
1526
|
const params = t4;
|
|
1425
1527
|
useTrackHookUsage("usePaginatedDocuments");
|
|
1426
|
-
const
|
|
1528
|
+
const options = useNormalizedResourceOptions(rawOptions), [pageIndex, setPageIndex] = useState(0);
|
|
1427
1529
|
let t5;
|
|
1428
|
-
$[10] !== filter2 || $[11] !==
|
|
1530
|
+
$[10] !== filter2 || $[11] !== options || $[12] !== orderings || $[13] !== pageSize || $[14] !== params || $[15] !== search ? (t5 = JSON.stringify({
|
|
1429
1531
|
filter: filter2,
|
|
1430
1532
|
search,
|
|
1431
1533
|
params,
|
|
1432
1534
|
orderings,
|
|
1433
|
-
pageSize
|
|
1434
|
-
|
|
1535
|
+
pageSize,
|
|
1536
|
+
...options
|
|
1537
|
+
}), $[10] = filter2, $[11] = options, $[12] = orderings, $[13] = pageSize, $[14] = params, $[15] = search, $[16] = t5) : t5 = $[16];
|
|
1435
1538
|
const key = t5, [prevKey, setPrevKey] = useState(key);
|
|
1436
1539
|
prevKey !== key && (setPrevKey(key), setPageIndex(0));
|
|
1437
1540
|
const startIndex = pageIndex * pageSize, endIndex = (pageIndex + 1) * pageSize;
|
|
1438
1541
|
let t6;
|
|
1439
|
-
$[
|
|
1542
|
+
$[17] !== documentType ? (t6 = Array.isArray(documentType) ? documentType : [documentType], $[17] = documentType, $[18] = t6) : t6 = $[18];
|
|
1440
1543
|
let t7;
|
|
1441
|
-
$[
|
|
1544
|
+
$[19] !== t6 ? (t7 = t6.filter(_temp), $[19] = t6, $[20] = t7) : t7 = $[20];
|
|
1442
1545
|
const documentTypes = t7;
|
|
1443
1546
|
let t8;
|
|
1444
1547
|
const conditions = [], trimmedSearch = search?.trim();
|
|
@@ -1447,51 +1550,54 @@ function usePaginatedDocuments(t0) {
|
|
|
1447
1550
|
searchFilter && conditions.push(searchFilter);
|
|
1448
1551
|
}
|
|
1449
1552
|
documentTypes?.length && conditions.push("(_type in $__types)"), filter2 && conditions.push(`(${filter2})`), t8 = conditions.length ? `[${conditions.join(" && ")}]` : "";
|
|
1450
|
-
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}}
|
|
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];
|
|
1558
|
+
let t12;
|
|
1559
|
+
$[25] !== t10 || $[26] !== t11 ? (t12 = {
|
|
1560
|
+
...t10,
|
|
1561
|
+
...t11
|
|
1562
|
+
}, $[25] = t10, $[26] = t11, $[27] = t12) : t12 = $[27];
|
|
1451
1563
|
let t13;
|
|
1452
|
-
$[
|
|
1453
|
-
projectId: t10,
|
|
1454
|
-
dataset: t11,
|
|
1455
|
-
perspective: t12
|
|
1456
|
-
}, $[20] = t10, $[21] = t11, $[22] = t12, $[23] = t13) : t13 = $[23];
|
|
1457
|
-
let t14;
|
|
1458
|
-
$[24] !== documentTypes || $[25] !== params || $[26] !== t13 ? (t14 = {
|
|
1564
|
+
$[28] !== documentTypes || $[29] !== params || $[30] !== t12 ? (t13 = {
|
|
1459
1565
|
...params,
|
|
1460
1566
|
__types: documentTypes,
|
|
1461
|
-
__handle:
|
|
1462
|
-
}, $[
|
|
1463
|
-
let
|
|
1464
|
-
$[
|
|
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 = {
|
|
1465
1571
|
...options,
|
|
1466
1572
|
query: t9,
|
|
1467
|
-
params:
|
|
1468
|
-
}, $[
|
|
1573
|
+
params: t13
|
|
1574
|
+
}, $[32] = options, $[33] = t13, $[34] = t9, $[35] = t14) : t14 = $[35];
|
|
1469
1575
|
const {
|
|
1470
|
-
data:
|
|
1576
|
+
data: t15,
|
|
1471
1577
|
isPending
|
|
1472
|
-
} = useQuery(
|
|
1578
|
+
} = useQuery(t14), {
|
|
1473
1579
|
data,
|
|
1474
1580
|
count
|
|
1475
|
-
} =
|
|
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;
|
|
1476
1585
|
let t17;
|
|
1477
|
-
$[
|
|
1478
|
-
const
|
|
1586
|
+
$[37] === Symbol.for("react.memo_cache_sentinel") ? (t17 = () => setPageIndex(_temp4), $[37] = t17) : t17 = $[37];
|
|
1587
|
+
const previousPage = t17;
|
|
1479
1588
|
let t18;
|
|
1480
|
-
$[
|
|
1481
|
-
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;
|
|
1482
1591
|
let t19;
|
|
1483
|
-
$[
|
|
1484
|
-
const
|
|
1592
|
+
$[40] !== totalPages ? (t19 = () => setPageIndex(totalPages - 1), $[40] = totalPages, $[41] = t19) : t19 = $[41];
|
|
1593
|
+
const lastPage = t19;
|
|
1485
1594
|
let t20;
|
|
1486
|
-
$[
|
|
1487
|
-
const lastPage = t20;
|
|
1488
|
-
let t21;
|
|
1489
|
-
$[38] !== totalPages ? (t21 = (pageNumber) => {
|
|
1595
|
+
$[42] !== totalPages ? (t20 = (pageNumber) => {
|
|
1490
1596
|
pageNumber < 1 || pageNumber > totalPages || setPageIndex(pageNumber - 1);
|
|
1491
|
-
}, $[
|
|
1492
|
-
const goToPage =
|
|
1493
|
-
let
|
|
1494
|
-
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 = {
|
|
1495
1601
|
data,
|
|
1496
1602
|
isPending,
|
|
1497
1603
|
pageSize,
|
|
@@ -1509,7 +1615,7 @@ function usePaginatedDocuments(t0) {
|
|
|
1509
1615
|
lastPage,
|
|
1510
1616
|
hasLastPage,
|
|
1511
1617
|
goToPage
|
|
1512
|
-
}, $[
|
|
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;
|
|
1513
1619
|
}
|
|
1514
1620
|
function _temp4(prev) {
|
|
1515
1621
|
return Math.max(prev - 1, 0);
|
|
@@ -1553,7 +1659,7 @@ function useDocumentProjection({
|
|
|
1553
1659
|
projection,
|
|
1554
1660
|
...docHandle
|
|
1555
1661
|
}) {
|
|
1556
|
-
const instance = useSanityInstance(
|
|
1662
|
+
const instance = useSanityInstance();
|
|
1557
1663
|
trackHookUsage(instance, "useDocumentProjection");
|
|
1558
1664
|
const normalizedProjection = useMemo(() => projection.trim(), [projection]), normalizedDocHandle = useNormalizedResourceOptions(docHandle), stateSource = useMemo(() => getProjectionState(instance, {
|
|
1559
1665
|
...normalizedDocHandle,
|
|
@@ -1589,7 +1695,7 @@ function useDocumentPreview(t0) {
|
|
|
1589
1695
|
ref,
|
|
1590
1696
|
...docHandle
|
|
1591
1697
|
} = t0, $[0] = t0, $[1] = docHandle, $[2] = ref) : (docHandle = $[1], ref = $[2]);
|
|
1592
|
-
const instance = useSanityInstance(
|
|
1698
|
+
const instance = useSanityInstance();
|
|
1593
1699
|
trackHookUsage(instance, "useDocumentPreview");
|
|
1594
1700
|
const normalizedDocHandle = useNormalizedResourceOptions(docHandle);
|
|
1595
1701
|
let t1;
|
|
@@ -1609,38 +1715,40 @@ function useDocumentPreview(t0) {
|
|
|
1609
1715
|
}, $[10] = previewValue, $[11] = projectionResult.isPending, $[12] = t4) : t4 = $[12], t4;
|
|
1610
1716
|
}
|
|
1611
1717
|
const useProject = createStateSourceHook({
|
|
1612
|
-
// remove `undefined` since we're suspending when that is the case
|
|
1613
1718
|
getState: getProjectState,
|
|
1614
|
-
shouldSuspend: (instance,
|
|
1719
|
+
shouldSuspend: (instance, ...params) => getProjectState(instance, ...params).getCurrent() === void 0,
|
|
1615
1720
|
suspender: resolveProject,
|
|
1616
1721
|
getConfig: identity
|
|
1617
1722
|
}), useProjects = createStateSourceHook({
|
|
1618
1723
|
getState: getProjectsState,
|
|
1619
|
-
shouldSuspend: (instance,
|
|
1724
|
+
shouldSuspend: (instance, ...params) => getProjectsState(instance, ...params).getCurrent() === void 0,
|
|
1620
1725
|
suspender: resolveProjects
|
|
1621
1726
|
}), useActiveReleasesValue = createStateSourceHook({
|
|
1622
1727
|
getState: getActiveReleasesState,
|
|
1623
1728
|
shouldSuspend: (instance, options) => getActiveReleasesState(instance, options ?? {}).getCurrent() === void 0,
|
|
1624
1729
|
suspender: (instance, options) => firstValueFrom(getActiveReleasesState(instance, options ?? {}).observable.pipe(filter(Boolean)))
|
|
1625
|
-
})
|
|
1730
|
+
});
|
|
1731
|
+
function useActiveReleases(options) {
|
|
1626
1732
|
const $ = c(2);
|
|
1627
1733
|
let t0;
|
|
1628
1734
|
$[0] !== options ? (t0 = options ?? {}, $[0] = options, $[1] = t0) : t0 = $[1];
|
|
1629
1735
|
const normalizedOptions = useNormalizedResourceOptions(t0);
|
|
1630
1736
|
return useActiveReleasesValue(normalizedOptions);
|
|
1631
|
-
}
|
|
1737
|
+
}
|
|
1738
|
+
const usePerspectiveValue = createStateSourceHook({
|
|
1632
1739
|
getState: getPerspectiveState,
|
|
1633
1740
|
shouldSuspend: (instance, options) => getPerspectiveState(instance, options).getCurrent() === void 0,
|
|
1634
1741
|
suspender: (instance, _options) => firstValueFrom(getPerspectiveState(instance, _options ?? {}).observable.pipe(filter(Boolean)))
|
|
1635
|
-
})
|
|
1742
|
+
});
|
|
1743
|
+
function usePerspective(perspectiveHandle) {
|
|
1636
1744
|
const $ = c(2);
|
|
1637
1745
|
let t0;
|
|
1638
|
-
$[0] !==
|
|
1746
|
+
$[0] !== perspectiveHandle ? (t0 = perspectiveHandle ?? {}, $[0] = perspectiveHandle, $[1] = t0) : t0 = $[1];
|
|
1639
1747
|
const normalizedOptions = useNormalizedResourceOptions(t0);
|
|
1640
1748
|
return usePerspectiveValue(normalizedOptions);
|
|
1641
|
-
}
|
|
1749
|
+
}
|
|
1642
1750
|
function useUser(options) {
|
|
1643
|
-
const instance = useSanityInstance(
|
|
1751
|
+
const instance = useSanityInstance();
|
|
1644
1752
|
trackHookUsage(instance, "useUser");
|
|
1645
1753
|
const [isPending, startTransition] = useTransition(), key = getUsersKey(instance, options), [deferredKey, setDeferredKey] = useState(key), deferred = useMemo(() => parseUsersKey(deferredKey), [deferredKey]), [ref, setRef] = useState(new AbortController());
|
|
1646
1754
|
useEffect(() => {
|
|
@@ -1663,7 +1771,7 @@ function useUser(options) {
|
|
|
1663
1771
|
};
|
|
1664
1772
|
}
|
|
1665
1773
|
function useUsers(options) {
|
|
1666
|
-
const instance = useSanityInstance(
|
|
1774
|
+
const instance = useSanityInstance();
|
|
1667
1775
|
trackHookUsage(instance, "useUsers");
|
|
1668
1776
|
const [isPending, startTransition] = useTransition(), key = getUsersKey(instance, options), [deferredKey, setDeferredKey] = useState(key), deferred = useMemo(() => parseUsersKey(deferredKey), [deferredKey]), [ref, setRef] = useState(new AbortController());
|
|
1669
1777
|
useEffect(() => {
|
|
@@ -1693,7 +1801,7 @@ function useUsers(options) {
|
|
|
1693
1801
|
loadMore
|
|
1694
1802
|
};
|
|
1695
1803
|
}
|
|
1696
|
-
var version = "2.
|
|
1804
|
+
var version = "2.11.0";
|
|
1697
1805
|
function getEnv(key) {
|
|
1698
1806
|
if (typeof import.meta < "u" && import.meta.env)
|
|
1699
1807
|
return import.meta.env[key];
|
|
@@ -1743,6 +1851,8 @@ export {
|
|
|
1743
1851
|
useLoginUrl,
|
|
1744
1852
|
useManageFavorite,
|
|
1745
1853
|
useNavigateToStudioDocument,
|
|
1854
|
+
useOrganization,
|
|
1855
|
+
useOrganizations,
|
|
1746
1856
|
usePaginatedDocuments,
|
|
1747
1857
|
usePerspective,
|
|
1748
1858
|
usePresence,
|
|
@@ -1750,6 +1860,7 @@ export {
|
|
|
1750
1860
|
useProjects,
|
|
1751
1861
|
useQuery,
|
|
1752
1862
|
useRecordDocumentHistoryEvent,
|
|
1863
|
+
useResource,
|
|
1753
1864
|
useSanityInstance,
|
|
1754
1865
|
useStudioWorkspacesByProjectIdDataset,
|
|
1755
1866
|
useUser,
|