@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.
Files changed (72) hide show
  1. package/dist/index.d.ts +338 -215
  2. package/dist/index.js +564 -342
  3. package/dist/index.js.map +1 -1
  4. package/package.json +9 -14
  5. package/src/_exports/index.ts +2 -0
  6. package/src/_exports/sdk-react.ts +8 -0
  7. package/src/components/SDKProvider.test.tsx +5 -12
  8. package/src/components/SDKProvider.tsx +58 -28
  9. package/src/components/SanityApp.tsx +2 -2
  10. package/src/components/auth/AuthBoundary.tsx +8 -1
  11. package/src/components/auth/DashboardAccessRequest.tsx +37 -0
  12. package/src/components/auth/LoginError.test.tsx +191 -5
  13. package/src/components/auth/LoginError.tsx +100 -56
  14. package/src/components/errors/ChunkLoadError.test.tsx +59 -0
  15. package/src/components/errors/ChunkLoadError.tsx +56 -0
  16. package/src/components/errors/chunkReloadStorage.ts +57 -0
  17. package/src/config/handles.ts +55 -0
  18. package/src/constants.ts +5 -0
  19. package/src/context/DefaultResourceContext.ts +10 -0
  20. package/src/context/PerspectiveContext.ts +12 -0
  21. package/src/context/ResourceProvider.test.tsx +2 -2
  22. package/src/context/ResourceProvider.tsx +56 -51
  23. package/src/context/ResourcesContext.tsx +7 -0
  24. package/src/context/SanityInstanceProvider.test.tsx +100 -0
  25. package/src/context/SanityInstanceProvider.tsx +71 -0
  26. package/src/hooks/agent/agentActions.ts +55 -38
  27. package/src/hooks/auth/useVerifyOrgProjects.tsx +13 -6
  28. package/src/hooks/context/useResource.test.tsx +32 -0
  29. package/src/hooks/context/useResource.ts +24 -0
  30. package/src/hooks/context/useSanityInstance.test.tsx +42 -111
  31. package/src/hooks/context/useSanityInstance.ts +28 -50
  32. package/src/hooks/dashboard/useDispatchIntent.test.ts +11 -7
  33. package/src/hooks/dashboard/useDispatchIntent.ts +7 -7
  34. package/src/hooks/dashboard/useManageFavorite.test.tsx +16 -12
  35. package/src/hooks/dashboard/utils/useResourceIdFromDocumentHandle.test.ts +15 -15
  36. package/src/hooks/dashboard/utils/useResourceIdFromDocumentHandle.ts +13 -17
  37. package/src/hooks/document/{useApplyDocumentActions.test.ts → useApplyDocumentActions.test.tsx} +46 -81
  38. package/src/hooks/document/useApplyDocumentActions.ts +33 -67
  39. package/src/hooks/document/useDocument.ts +4 -6
  40. package/src/hooks/document/useDocumentEvent.ts +8 -7
  41. package/src/hooks/document/useDocumentPermissions.test.tsx +60 -152
  42. package/src/hooks/document/useDocumentPermissions.ts +78 -55
  43. package/src/hooks/document/useDocumentSyncStatus.ts +2 -2
  44. package/src/hooks/document/useEditDocument.test.tsx +25 -60
  45. package/src/hooks/document/useEditDocument.ts +3 -3
  46. package/src/hooks/documents/useDocuments.ts +19 -11
  47. package/src/hooks/helpers/createStateSourceHook.tsx +1 -2
  48. package/src/hooks/helpers/useNormalizedResourceOptions.test.tsx +253 -0
  49. package/src/hooks/helpers/useNormalizedResourceOptions.ts +169 -0
  50. package/src/hooks/helpers/useTrackHookUsage.ts +2 -2
  51. package/src/hooks/organizations/useOrganization.test-d.ts +53 -0
  52. package/src/hooks/organizations/useOrganization.test.ts +65 -0
  53. package/src/hooks/organizations/useOrganization.ts +40 -0
  54. package/src/hooks/organizations/useOrganizations.test-d.ts +55 -0
  55. package/src/hooks/organizations/useOrganizations.test.ts +85 -0
  56. package/src/hooks/organizations/useOrganizations.ts +45 -0
  57. package/src/hooks/paginatedDocuments/usePaginatedDocuments.ts +29 -14
  58. package/src/hooks/presence/usePresence.test.tsx +56 -9
  59. package/src/hooks/presence/usePresence.ts +16 -4
  60. package/src/hooks/preview/useDocumentPreview.tsx +8 -10
  61. package/src/hooks/projection/useDocumentProjection.ts +7 -9
  62. package/src/hooks/projects/useProject.test-d.ts +49 -0
  63. package/src/hooks/projects/useProject.ts +33 -41
  64. package/src/hooks/projects/useProjects.test-d.ts +49 -0
  65. package/src/hooks/projects/useProjects.ts +17 -23
  66. package/src/hooks/query/useQuery.ts +11 -10
  67. package/src/hooks/releases/useActiveReleases.ts +14 -14
  68. package/src/hooks/releases/usePerspective.ts +11 -16
  69. package/src/hooks/users/useUser.ts +1 -1
  70. package/src/hooks/users/useUsers.ts +1 -1
  71. package/src/context/SourcesContext.tsx +0 -7
  72. 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, agentGenerate, agentTransform, agentTranslate, agentPrompt, agentPatch, getTokenState, getCurrentUserState, getDashboardOrganizationId, getClientState, getOrCreateController, getOrCreateChannel, releaseChannel, isDatasetSource, isMediaLibrarySource, isCanvasSource, getFavoritesState, resolveFavoritesState, resolveDatasets, getDatasetsState, applyDocumentActions, resolveDocument, getDocumentState, subscribeDocumentEvents, getPermissionsState, getDocumentSyncStatus, editDocument, getQueryKey, parseQueryKey, getQueryState, resolveQuery, createGroqSearchFilter, getPresence, getProjectionState, resolveProjection, transformProjectionToPreview, PREVIEW_PROJECTION, resolveProject, getProjectState, resolveProjects, getProjectsState, getActiveReleasesState, getPerspectiveState, getUsersKey, parseUsersKey, getUsersState, resolveUsers, loadMoreUsers } from "@sanity/sdk";
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, useMemo, Suspense, StrictMode, useCallback, useInsertionEffect, useTransition } from "react";
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
- import { pick } from "lodash-es";
13
- const SanityInstanceContext = createContext(null), useSanityInstance = (config) => {
14
- const $ = c(3), instance = useContext(SanityInstanceContext);
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(`SanityInstance context not found. ${config ? `Requested config: ${JSON.stringify(config, null, 2)}. ` : ""}Please ensure that your component is wrapped in a ResourceProvider or a SanityApp component.`);
17
- if (!config)
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, getConfig = "getConfig" in options ? options.getConfig : void 0, suspense = "shouldSuspend" in options && "suspender" in options ? options : void 0;
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(5), params = t0;
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 t2;
37
- $[2] !== instance || $[3] !== params ? (t2 = getState(instance, ...params), $[2] = instance, $[3] = params, $[4] = t2) : t2 = $[4];
38
- const state = t2;
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(6), disabled = t0 === void 0 ? !1 : t0, instance = useSanityInstance(), [error, setError] = useState(null);
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] !== disabled || $[1] !== error || $[2] !== instance || $[3] !== projectIds ? (t1 = () => {
169
- if (disabled || !projectIds || projectIds.length === 0) {
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, disabled, error, projectIds], $[0] = disabled, $[1] = error, $[2] = instance, $[3] = projectIds, $[4] = t1, $[5] = t2) : (t1 = $[4], t2 = $[5]), useEffect(t1, t2), error;
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$6);
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$6(replacementLocation) {
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(23), {
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
- } = useSanityInstance(), {
369
+ } = instance, {
311
370
  projectId
312
- } = t1, [authErrorMessage, setAuthErrorMessage] = useState("Please try again or contact support if the problem persists."), [showRetryCta, setShowRetryCta] = useState(!0);
371
+ } = t1, clientError = error instanceof ClientError ? error : error instanceof AuthError && error.cause instanceof ClientError ? error.cause : null;
313
372
  let t2;
314
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
315
- name: SDK_NODE_NAME,
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
- $[1] !== logout2 || $[2] !== resetErrorBoundary ? (t3 = async () => {
323
- await logout2(), resetErrorBoundary();
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] !== authState.type || $[5] !== error || $[6] !== fetch || $[7] !== handleRetry || $[8] !== projectId ? (t4 = () => {
328
- if (error instanceof ClientError) {
329
- if (error.statusCode === 401)
330
- if (isProjectUserNotFoundClientError(error)) {
331
- const description = getClientErrorApiDescription(error);
332
- description && setAuthErrorMessage(description), setShowRetryCta(!1), fetch("dashboard/v1/auth/access/request", {
333
- resourceType: "project",
334
- resourceId: projectId
335
- });
336
- } else
337
- setShowRetryCta(!0), handleRetry();
338
- else if (error.statusCode === 404) {
339
- const errorMessage = getClientErrorApiBody(error)?.message || "";
340
- errorMessage.startsWith("Session with sid") && errorMessage.endsWith("not found") ? setAuthErrorMessage("The session ID is invalid or expired.") : setAuthErrorMessage("The login link is invalid or expired. Please try again."), setShowRetryCta(!0);
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
- authState.type !== AuthStateType.ERROR && error instanceof ConfigurationError && (setAuthErrorMessage(error.message), setShowRetryCta(!0));
344
- }, $[4] = authState.type, $[5] = error, $[6] = fetch, $[7] = handleRetry, $[8] = projectId, $[9] = t4) : t4 = $[9];
345
- let t5;
346
- $[10] !== authState || $[11] !== error || $[12] !== fetch || $[13] !== handleRetry || $[14] !== projectId ? (t5 = [authState, handleRetry, error, fetch, projectId], $[10] = authState, $[11] = error, $[12] = fetch, $[13] = handleRetry, $[14] = projectId, $[15] = t5) : t5 = $[15], useEffect(t4, t5);
347
- const t6 = error instanceof AuthError ? "Authentication Error" : "Configuration Error";
348
- let t7;
349
- $[16] !== handleRetry || $[17] !== showRetryCta ? (t7 = showRetryCta ? {
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, $[16] = handleRetry, $[17] = showRetryCta, $[18] = t7) : t7 = $[18];
353
- let t8;
354
- return $[19] !== authErrorMessage || $[20] !== t6 || $[21] !== t7 ? (t8 = /* @__PURE__ */ jsx(Error$1, { heading: t6, description: authErrorMessage, cta: t7 }), $[19] = authErrorMessage, $[20] = t6, $[21] = t7, $[22] = t8) : t8 = $[22], t8;
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
- children,
419
- fallback,
420
- ...config
421
- }) {
422
- const parent = useContext(SanityInstanceContext), instance = useMemo(() => parent ? parent.createChild(config) : createSanityInstance(config), [config, parent]), projectId = config.projectId ?? "";
423
- useMemo(() => {
424
- projectId && !parent && initTelemetry(instance, projectId);
425
- }, [instance, projectId, parent]);
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
- return useEffect(() => (disposal.current !== null && instance === disposal.current.instance && (clearTimeout(disposal.current.timeoutId), disposal.current = null), () => {
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() || instance.dispose();
544
+ !instance.isDisposed() && instance !== parentInstance && instance.dispose();
432
545
  }, 0)
433
546
  };
434
- }), [instance]), /* @__PURE__ */ jsx(SanityInstanceContext.Provider, { value: instance, children: /* @__PURE__ */ jsx(Suspense, { fallback: fallback ?? DEFAULT_FALLBACK, children }) });
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(19);
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
- let configs, t2;
449
- $[7] !== t1 ? (configs = t1.slice().reverse(), t2 = configs.map(_temp$5).filter(_temp2$1), $[7] = t1, $[8] = configs, $[9] = t2) : (configs = $[8], t2 = $[9]);
450
- const projectIds = t2;
451
- let t3, t4;
452
- $[10] !== props.sources ? (t4 = props.sources ?? {}, $[10] = props.sources, $[11] = t4) : t4 = $[11], t3 = t4;
453
- const sourcesValue = t3;
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
- if ($[12] !== children || $[13] !== configs || $[14] !== fallback || $[15] !== projectIds || $[16] !== props || $[17] !== sourcesValue) {
456
- const createNestedProviders = (index) => index >= configs.length ? /* @__PURE__ */ jsx(AuthBoundary, { ...props, projectIds, children: /* @__PURE__ */ jsx(SourcesContext.Provider, { value: sourcesValue, children }) }) : /* @__PURE__ */ jsx(ResourceProvider, { ...configs[index], fallback, children: createNestedProviders(index + 1) });
457
- t5 = createNestedProviders(0), $[12] = children, $[13] = configs, $[14] = fallback, $[15] = projectIds, $[16] = props, $[17] = sourcesValue, $[18] = t5;
458
- } else
459
- t5 = $[18];
460
- 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;
461
612
  }
462
- function _temp2$1(id) {
613
+ function _temp3$1(id) {
463
614
  return !!id;
464
615
  }
465
- function _temp$5(c2) {
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$4, 1e3)), () => clearTimeout(timeout);
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$4() {
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
- const useAgentGenerate = createCallbackHook(agentGenerate), useAgentTransform = createCallbackHook(agentTransform), useAgentTranslate = createCallbackHook(agentTranslate);
527
- function promptAdapter(instance, options) {
528
- return firstValueFrom(agentPrompt(instance, options));
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
- const useAgentPrompt = createCallbackHook(promptAdapter);
531
- function patchAdapter(instance, options) {
532
- return firstValueFrom(agentPatch(instance, options));
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$3), releaseChannel(instance, name), channelRef.current = null, controllerRef.current = null;
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$3(unsub) {
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 = useNormalizedSourceOptions(documentHandle), {
685
- projectId,
686
- dataset,
687
- source
930
+ const $ = c(3), options = useNormalizedResourceOptions(documentHandle), {
931
+ resource
688
932
  } = options;
689
933
  let resourceId = "", resourceType;
690
- projectId && dataset && (resourceId = `${projectId}.${dataset}`), source && (isDatasetSource(source) ? (resourceId = `${source.projectId}.${source.dataset}`, resourceType = void 0) : isMediaLibrarySource(source) ? (resourceId = source.mediaLibraryId, resourceType = "media-library") : isCanvasSource(source) && (resourceId = source.canvasId, resourceType = "canvas"));
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 `source`, `sourceName`, or both `projectId` and `dataset` must be provided in documentHandle.");
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(3), instance = useSanityInstance(), sources = useContext(SourcesContext);
1248
+ const $ = c(4), instance = useSanityInstance(), resources = useContext(ResourcesContext), effectiveContextResource = useEffectiveContextResource();
1005
1249
  let t0;
1006
- return $[0] !== instance || $[1] !== sources ? (t0 = (actionOrActions, options) => {
1007
- const actions = Array.isArray(actionOrActions) ? actionOrActions : [actionOrActions], normalizedOptions = options ? normalizeSourceOptions(options, sources) : void 0;
1008
- let projectId, dataset, source;
1009
- for (const action of actions) {
1010
- if (action.projectId) {
1011
- if (source)
1012
- throw new Error(`Mismatches between projectId/dataset options and source in actions. Found projectId "${action.projectId}" and dataset "${action.dataset}" but expected source "${source}".`);
1013
- if (projectId || (projectId = action.projectId), action.projectId !== projectId)
1014
- throw new Error(`Mismatched project IDs found in actions. All actions must belong to the same project. Found "${action.projectId}" but expected "${projectId}".`);
1015
- if (action.dataset && (dataset || (dataset = action.dataset), action.dataset !== dataset))
1016
- throw new Error(`Mismatched datasets found in actions. All actions must belong to the same dataset. Found "${action.dataset}" but expected "${dataset}".`);
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
- source,
1045
- ...normalizedOptions
1262
+ actions: normalizedActions,
1263
+ resource: effectiveResource
1046
1264
  });
1047
- }, $[0] = instance, $[1] = sources, $[2] = t0) : t0 = $[2], t0;
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(!1);
1051
- tracked.current || (tracked.current = !0, trackHookMounted(instance, hookName));
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 = useNormalizedSourceOptions(options);
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 = useNormalizedSourceOptions(options);
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(datasetHandle);
1313
+ const stableHandler = t1, instance = useSanityInstance();
1096
1314
  let t2, t3;
1097
- $[6] !== datasetHandle.source || $[7] !== instance ? (t2 = () => subscribeDocumentEvents(instance, {
1315
+ $[6] !== datasetHandle.resource || $[7] !== instance ? (t2 = () => subscribeDocumentEvents(instance, {
1098
1316
  eventHandler: stableHandler,
1099
- source: datasetHandle.source
1100
- }), t3 = [instance, datasetHandle.source, stableHandler], $[6] = datasetHandle.source, $[7] = instance, $[8] = t2, $[9] = t3) : (t2 = $[8], t3 = $[9]), useEffect(t2, t3);
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 $ = c(15);
1104
- let t0, t1;
1105
- $[0] !== actionOrActions ? (t1 = Array.isArray(actionOrActions) ? actionOrActions : [actionOrActions], $[0] = actionOrActions, $[1] = t1) : t1 = $[1], t0 = t1;
1106
- const actions = t0;
1107
- let projectId, dataset, source;
1108
- if ($[2] !== actions || $[3] !== dataset || $[4] !== projectId || $[5] !== source) {
1109
- for (const action of actions) {
1110
- if (action.projectId) {
1111
- if (source)
1112
- throw new Error(`Mismatches between projectId/dataset options and source in actions. Found projectId "${action.projectId}" and dataset "${action.dataset}" but expected source "${source}".`);
1113
- if (projectId || (projectId = action.projectId), action.projectId !== projectId)
1114
- throw new Error(`Mismatched project IDs found in actions. All actions must belong to the same project. Found "${action.projectId}" but expected "${projectId}".`);
1115
- if (action.dataset && (dataset || (dataset = action.dataset), action.dataset !== dataset))
1116
- throw new Error(`Mismatched datasets found in actions. All actions must belong to the same dataset. Found "${action.dataset}" but expected "${dataset}".`);
1117
- }
1118
- if (action.source) {
1119
- if (source || (source = action.source), action.source !== source)
1120
- throw new Error(`Mismatched sources found in actions. All actions must belong to the same source. Found "${action.source}" but expected "${source}".`);
1121
- if (projectId || dataset)
1122
- throw new Error(`Mismatches between projectId/dataset options and source in actions. Found "${action.source}" but expected project "${projectId}" and dataset "${dataset}".`);
1123
- }
1124
- }
1125
- $[2] = actions, $[3] = dataset, $[4] = projectId, $[5] = source, $[6] = projectId, $[7] = dataset, $[8] = source;
1126
- } else
1127
- projectId = $[6], dataset = $[7], source = $[8];
1128
- let t2;
1129
- $[9] !== dataset || $[10] !== projectId ? (t2 = {
1130
- projectId,
1131
- dataset
1132
- }, $[9] = dataset, $[10] = projectId, $[11] = t2) : t2 = $[11];
1133
- const instance = useSanityInstance(t2);
1134
- if (trackHookUsage(instance, "useDocumentPermissions"), getPermissionsState(instance, {
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 = useNormalizedSourceOptions(options);
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(doc);
1373
+ const instance = useSanityInstance();
1170
1374
  trackHookUsage(instance, "useEditDocument");
1171
- const normalizedDoc = useNormalizedSourceOptions(doc), apply = useApplyDocumentActions();
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(options);
1415
+ const instance = useSanityInstance();
1212
1416
  trackHookUsage(instance, "useQuery");
1213
- const normalized = useNormalizedSourceOptions(options), [isPending, startTransition] = useTransition(), queryKey = getQueryKey(normalized), [deferredQueryKey, setDeferredQueryKey] = useState(queryKey), ref = useRef(new AbortController());
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
- ...options
1451
+ ...rawOptions
1248
1452
  }) {
1249
1453
  useTrackHookUsage("useDocuments");
1250
- const instance = useSanityInstance(options), [limit, setLimit] = useState(batchSize), documentTypes = useMemo(() => (Array.isArray(documentType) ? documentType : [documentType]).filter((i) => typeof i == "string"), [documentType]), key = JSON.stringify({
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
- useEffect(() => {
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
- ...pick(instance.config, "projectId", "dataset", "perspective"),
1282
- ...pick(options, "projectId", "dataset", "perspective")
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(62);
1299
- let documentType, options, orderings, search, t1, t2, t3;
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
- ...options
1308
- } = t0, $[0] = t0, $[1] = documentType, $[2] = options, $[3] = orderings, $[4] = search, $[5] = t1, $[6] = t2, $[7] = t3) : (documentType = $[1], options = $[2], orderings = $[3], search = $[4], t1 = $[5], t2 = $[6], t3 = $[7]);
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 instance = useSanityInstance(options), [pageIndex, setPageIndex] = useState(0);
1528
+ const options = useNormalizedResourceOptions(rawOptions), [pageIndex, setPageIndex] = useState(0);
1315
1529
  let t5;
1316
- $[10] !== filter2 || $[11] !== orderings || $[12] !== pageSize || $[13] !== params || $[14] !== search ? (t5 = JSON.stringify({
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
- }), $[10] = filter2, $[11] = orderings, $[12] = pageSize, $[13] = params, $[14] = search, $[15] = t5) : t5 = $[15];
1323
- const key = t5;
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
- $[16] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => {
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
- $[17] !== key ? (t7 = [key], $[17] = key, $[18] = t7) : t7 = $[18], useEffect(t6, t7);
1330
- const startIndex = pageIndex * pageSize, endIndex = (pageIndex + 1) * pageSize;
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})`), t10 = conditions.length ? `[${conditions.join(" && ")}]` : "";
1343
- const filterClause = t10, orderClause = orderings ? `| order(${orderings.map(_temp3).join(",")})` : "", dataQuery = `*${filterClause}${orderClause}[${startIndex}...${endIndex}]{"documentId":_id,"documentType":_type,...$__handle}`, countQuery = `count(*${filterClause})`, t11 = `{"data":${dataQuery},"count":${countQuery}}`;
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
- $[23] !== instance.config ? (t12 = pick(instance.config, "projectId", "dataset", "perspective"), $[23] = instance.config, $[24] = t12) : t12 = $[24];
1559
+ $[25] !== t10 || $[26] !== t11 ? (t12 = {
1560
+ ...t10,
1561
+ ...t11
1562
+ }, $[25] = t10, $[26] = t11, $[27] = t12) : t12 = $[27];
1346
1563
  let t13;
1347
- $[25] !== options ? (t13 = pick(options, "projectId", "dataset", "perspective"), $[25] = options, $[26] = t13) : t13 = $[26];
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: t14
1358
- }, $[30] = documentTypes, $[31] = params, $[32] = t14, $[33] = t15) : t15 = $[33];
1359
- let t16;
1360
- $[34] !== options || $[35] !== t11 || $[36] !== t15 ? (t16 = {
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: t11,
1363
- params: t15
1364
- }, $[34] = options, $[35] = t11, $[36] = t15, $[37] = t16) : t16 = $[37];
1572
+ query: t9,
1573
+ params: t13
1574
+ }, $[32] = options, $[33] = t13, $[34] = t9, $[35] = t14) : t14 = $[35];
1365
1575
  const {
1366
- data: t17,
1576
+ data: t15,
1367
1577
  isPending
1368
- } = useQuery(t16), {
1578
+ } = useQuery(t14), {
1369
1579
  data,
1370
1580
  count
1371
- } = t17, totalPages = Math.ceil(count / pageSize), currentPage = pageIndex + 1;
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] === Symbol.for("react.memo_cache_sentinel") ? (t18 = () => setPageIndex(0), $[38] = t18) : t18 = $[38];
1374
- const firstPage = t18;
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
- $[39] === Symbol.for("react.memo_cache_sentinel") ? (t19 = () => setPageIndex(_temp4), $[39] = t19) : t19 = $[39];
1377
- const previousPage = t19;
1592
+ $[40] !== totalPages ? (t19 = () => setPageIndex(totalPages - 1), $[40] = totalPages, $[41] = t19) : t19 = $[41];
1593
+ const lastPage = t19;
1378
1594
  let t20;
1379
- $[40] !== totalPages ? (t20 = () => setPageIndex((prev_0) => Math.min(prev_0 + 1, totalPages - 1)), $[40] = totalPages, $[41] = t20) : t20 = $[41];
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
- }, $[44] = totalPages, $[45] = t22) : t22 = $[45];
1388
- const goToPage = t22, hasFirstPage = pageIndex > 0, hasPreviousPage = pageIndex > 0, hasNextPage = pageIndex < totalPages - 1, hasLastPage = pageIndex < totalPages - 1;
1389
- let t23;
1390
- return $[46] !== count || $[47] !== currentPage || $[48] !== data || $[49] !== endIndex || $[50] !== goToPage || $[51] !== hasFirstPage || $[52] !== hasLastPage || $[53] !== hasNextPage || $[54] !== hasPreviousPage || $[55] !== isPending || $[56] !== lastPage || $[57] !== nextPage || $[58] !== pageSize || $[59] !== startIndex || $[60] !== totalPages ? (t23 = {
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
- }, $[46] = count, $[47] = currentPage, $[48] = data, $[49] = endIndex, $[50] = goToPage, $[51] = hasFirstPage, $[52] = hasLastPage, $[53] = hasNextPage, $[54] = hasPreviousPage, $[55] = isPending, $[56] = lastPage, $[57] = nextPage, $[58] = pageSize, $[59] = startIndex, $[60] = totalPages, $[61] = t23) : t23 = $[61], t23;
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(11), sanityInstance = useSanityInstance();
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 t0, t1;
1426
- $[0] !== sanityInstance ? (t1 = getPresence(sanityInstance), $[0] = sanityInstance, $[1] = t1) : t1 = $[1], t0 = t1;
1427
- const source = t0;
1428
- let t2;
1429
- $[2] !== source ? (t2 = (callback) => source.subscribe(callback), $[2] = source, $[3] = t2) : t2 = $[3];
1430
- const subscribe = t2;
1431
- let t3, t4;
1432
- $[4] !== source ? (t3 = () => source.getCurrent(), t4 = () => source.getCurrent(), $[4] = source, $[5] = t3, $[6] = t4) : (t3 = $[5], t4 = $[6]);
1433
- const locations = useSyncExternalStore(subscribe, t3, t4);
1434
- let t5;
1435
- $[7] !== locations ? (t5 = locations || [], $[7] = locations, $[8] = t5) : t5 = $[8];
1436
- let t6;
1437
- return $[9] !== t5 ? (t6 = {
1438
- locations: t5
1439
- }, $[9] = t5, $[10] = t6) : t6 = $[10], t6;
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(docHandle);
1662
+ const instance = useSanityInstance();
1447
1663
  trackHookUsage(instance, "useDocumentProjection");
1448
- const normalizedProjection = useMemo(() => projection.trim(), [projection]), normalizedDocHandle = useNormalizedSourceOptions(docHandle), stateSource = useMemo(() => getProjectionState(instance, {
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(docHandle);
1698
+ const instance = useSanityInstance();
1483
1699
  trackHookUsage(instance, "useDocumentPreview");
1484
- const normalizedDocHandle = useNormalizedSourceOptions(docHandle);
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.source || $[8] !== projectionResult.data ? (t3 = transformProjectionToPreview(instance, projectionResult.data, normalizedDocHandle.source), $[6] = instance, $[7] = normalizedDocHandle.source, $[8] = projectionResult.data, $[9] = t3) : t3 = $[9], t2 = t3;
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, projectHandle) => getProjectState(instance, projectHandle).getCurrent() === void 0,
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, options) => getProjectsState(instance, options).getCurrent() === void 0,
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
- }), useActiveReleases = (options) => {
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 = useNormalizedSourceOptions(t0);
1735
+ const normalizedOptions = useNormalizedResourceOptions(t0);
1520
1736
  return useActiveReleasesValue(normalizedOptions);
1521
- }, usePerspectiveValue = createStateSourceHook({
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
- }), usePerspective = (options) => {
1742
+ });
1743
+ function usePerspective(perspectiveHandle) {
1526
1744
  const $ = c(2);
1527
1745
  let t0;
1528
- $[0] !== options ? (t0 = options ?? {}, $[0] = options, $[1] = t0) : t0 = $[1];
1529
- const normalizedOptions = useNormalizedSourceOptions(t0);
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(options);
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(options);
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.9.0";
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,