@sanity/sdk-react 0.0.0-alpha.2 → 0.0.0-alpha.21
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/README.md +38 -67
- package/dist/index.d.ts +4811 -2
- package/dist/index.js +1069 -2
- package/dist/index.js.map +1 -1
- package/package.json +27 -58
- package/src/_exports/index.ts +66 -10
- package/src/components/Login/LoginLinks.test.tsx +4 -14
- package/src/components/Login/LoginLinks.tsx +16 -31
- package/src/components/SDKProvider.test.tsx +79 -0
- package/src/components/SDKProvider.tsx +42 -0
- package/src/components/SanityApp.test.tsx +156 -0
- package/src/components/SanityApp.tsx +90 -0
- package/src/components/auth/AuthBoundary.test.tsx +6 -19
- package/src/components/auth/AuthBoundary.tsx +20 -4
- package/src/components/auth/Login.test.tsx +2 -16
- package/src/components/auth/Login.tsx +11 -30
- package/src/components/auth/LoginCallback.test.tsx +5 -20
- package/src/components/auth/LoginCallback.tsx +9 -14
- package/src/components/auth/LoginError.test.tsx +2 -17
- package/src/components/auth/LoginError.tsx +11 -16
- package/src/components/auth/LoginFooter.test.tsx +2 -16
- package/src/components/auth/LoginFooter.tsx +8 -24
- package/src/components/auth/LoginLayout.test.tsx +2 -16
- package/src/components/auth/LoginLayout.tsx +8 -38
- package/src/components/auth/authTestHelpers.tsx +11 -0
- package/src/components/utils.ts +22 -0
- package/src/context/SanityInstanceContext.ts +4 -0
- package/src/{components/context → context}/SanityProvider.test.tsx +2 -2
- package/src/context/SanityProvider.tsx +50 -0
- package/src/hooks/_synchronous-groq-js.mjs +4 -0
- package/src/hooks/auth/useAuthState.tsx +4 -5
- package/src/hooks/auth/useAuthToken.tsx +1 -1
- package/src/hooks/auth/useCurrentUser.tsx +28 -4
- package/src/hooks/auth/useDashboardOrganizationId.test.tsx +42 -0
- package/src/hooks/auth/useDashboardOrganizationId.tsx +29 -0
- package/src/hooks/auth/useHandleAuthCallback.test.tsx +16 -0
- package/src/hooks/auth/{useHandleCallback.tsx → useHandleAuthCallback.tsx} +7 -6
- package/src/hooks/auth/useLogOut.test.tsx +2 -2
- package/src/hooks/auth/useLogOut.tsx +1 -1
- package/src/hooks/auth/useLoginUrls.tsx +1 -0
- package/src/hooks/client/useClient.ts +9 -30
- package/src/hooks/comlink/useFrameConnection.test.tsx +167 -0
- package/src/hooks/comlink/useFrameConnection.ts +107 -0
- package/src/hooks/comlink/useManageFavorite.test.ts +111 -0
- package/src/hooks/comlink/useManageFavorite.ts +130 -0
- package/src/hooks/comlink/useRecordDocumentHistoryEvent.test.ts +81 -0
- package/src/hooks/comlink/useRecordDocumentHistoryEvent.ts +106 -0
- package/src/hooks/comlink/useWindowConnection.test.ts +135 -0
- package/src/hooks/comlink/useWindowConnection.ts +122 -0
- package/src/hooks/context/useSanityInstance.test.tsx +2 -2
- package/src/hooks/context/useSanityInstance.ts +24 -8
- package/src/hooks/dashboard/useNavigateToStudioDocument.test.ts +178 -0
- package/src/hooks/dashboard/useNavigateToStudioDocument.ts +123 -0
- package/src/hooks/dashboard/useStudioWorkspacesByResourceId.test.tsx +278 -0
- package/src/hooks/dashboard/useStudioWorkspacesByResourceId.ts +92 -0
- package/src/hooks/datasets/useDatasets.ts +40 -0
- package/src/hooks/document/useApplyDocumentActions.test.ts +25 -0
- package/src/hooks/document/useApplyDocumentActions.ts +75 -0
- package/src/hooks/document/useDocument.test.ts +81 -0
- package/src/hooks/document/useDocument.ts +107 -0
- package/src/hooks/document/useDocumentEvent.test.ts +63 -0
- package/src/hooks/document/useDocumentEvent.ts +54 -0
- package/src/hooks/document/useDocumentPermissions.ts +84 -0
- package/src/hooks/document/useDocumentSyncStatus.test.ts +16 -0
- package/src/hooks/document/useDocumentSyncStatus.ts +33 -0
- package/src/hooks/document/useEditDocument.test.ts +179 -0
- package/src/hooks/document/useEditDocument.ts +195 -0
- package/src/hooks/documents/useDocuments.test.tsx +152 -0
- package/src/hooks/documents/useDocuments.ts +174 -0
- package/src/hooks/helpers/createCallbackHook.tsx +3 -2
- package/src/hooks/helpers/createStateSourceHook.test.tsx +66 -0
- package/src/hooks/helpers/createStateSourceHook.tsx +29 -10
- package/src/hooks/paginatedDocuments/usePaginatedDocuments.test.tsx +259 -0
- package/src/hooks/paginatedDocuments/usePaginatedDocuments.ts +290 -0
- package/src/hooks/preview/usePreview.test.tsx +19 -10
- package/src/hooks/preview/usePreview.tsx +67 -13
- package/src/hooks/projection/useProjection.test.tsx +218 -0
- package/src/hooks/projection/useProjection.ts +147 -0
- package/src/hooks/projects/useProject.ts +48 -0
- package/src/hooks/projects/useProjects.ts +45 -0
- package/src/hooks/query/useQuery.test.tsx +188 -0
- package/src/hooks/query/useQuery.ts +103 -0
- package/src/hooks/users/useUsers.test.ts +163 -0
- package/src/hooks/users/useUsers.ts +107 -0
- package/src/utils/getEnv.ts +21 -0
- package/src/version.ts +8 -0
- package/src/vite-env.d.ts +10 -0
- package/dist/_chunks-es/useLogOut.js +0 -44
- package/dist/_chunks-es/useLogOut.js.map +0 -1
- package/dist/assets/bundle-CcAyERuZ.css +0 -11
- package/dist/components.d.ts +0 -257
- package/dist/components.js +0 -316
- package/dist/components.js.map +0 -1
- package/dist/hooks.d.ts +0 -187
- package/dist/hooks.js +0 -81
- package/dist/hooks.js.map +0 -1
- package/src/_exports/components.ts +0 -13
- package/src/_exports/hooks.ts +0 -9
- package/src/components/DocumentGridLayout/DocumentGridLayout.stories.tsx +0 -113
- package/src/components/DocumentGridLayout/DocumentGridLayout.test.tsx +0 -42
- package/src/components/DocumentGridLayout/DocumentGridLayout.tsx +0 -21
- package/src/components/DocumentListLayout/DocumentListLayout.stories.tsx +0 -105
- package/src/components/DocumentListLayout/DocumentListLayout.test.tsx +0 -42
- package/src/components/DocumentListLayout/DocumentListLayout.tsx +0 -12
- package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.md +0 -49
- package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.stories.tsx +0 -39
- package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.test.tsx +0 -30
- package/src/components/DocumentPreviewLayout/DocumentPreviewLayout.tsx +0 -171
- package/src/components/context/SanityProvider.tsx +0 -42
- package/src/css/css.config.js +0 -220
- package/src/css/paramour.css +0 -2347
- package/src/css/styles.css +0 -11
- package/src/hooks/auth/useHandleCallback.test.tsx +0 -16
- package/src/hooks/client/useClient.test.tsx +0 -130
- package/src/hooks/documentCollection/useDocuments.test.ts +0 -130
- package/src/hooks/documentCollection/useDocuments.ts +0 -87
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/_exports/index.ts"],"sourcesContent":["/**\n * An example function that will be removed.\n * @public\n */\nexport function main(): void {\n //\n}\n\n// export * from './components'\n// export * from './hooks'\n"],"names":[],"mappings":"AAIO,SAAS,OAAa;AAE7B;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/context/SanityInstanceContext.ts","../src/hooks/context/useSanityInstance.ts","../src/hooks/helpers/createStateSourceHook.tsx","../src/hooks/auth/useAuthState.tsx","../src/components/utils.ts","../src/components/auth/AuthError.ts","../src/hooks/auth/useLoginUrls.tsx","../src/components/auth/LoginFooter.tsx","../src/components/auth/LoginLayout.tsx","../src/components/auth/Login.tsx","../src/hooks/helpers/createCallbackHook.tsx","../src/hooks/auth/useHandleAuthCallback.tsx","../src/components/auth/LoginCallback.tsx","../src/hooks/auth/useLogOut.tsx","../src/components/auth/LoginError.tsx","../src/components/auth/AuthBoundary.tsx","../src/context/SanityProvider.tsx","../src/components/SDKProvider.tsx","../src/components/SanityApp.tsx","../src/hooks/auth/useAuthToken.tsx","../src/hooks/auth/useCurrentUser.tsx","../src/hooks/auth/useDashboardOrganizationId.tsx","../src/hooks/client/useClient.ts","../src/hooks/comlink/useFrameConnection.ts","../src/hooks/comlink/useWindowConnection.ts","../src/hooks/comlink/useManageFavorite.ts","../src/hooks/comlink/useRecordDocumentHistoryEvent.ts","../src/hooks/dashboard/useStudioWorkspacesByResourceId.ts","../src/hooks/dashboard/useNavigateToStudioDocument.ts","../src/hooks/datasets/useDatasets.ts","../src/hooks/document/useApplyDocumentActions.ts","../src/hooks/document/useDocument.ts","../src/hooks/document/useDocumentEvent.ts","../src/hooks/document/useDocumentPermissions.ts","../src/hooks/document/useDocumentSyncStatus.ts","../src/hooks/document/useEditDocument.ts","../src/hooks/query/useQuery.ts","../src/hooks/documents/useDocuments.ts","../src/hooks/paginatedDocuments/usePaginatedDocuments.ts","../src/hooks/preview/usePreview.tsx","../src/hooks/projection/useProjection.ts","../src/hooks/projects/useProject.ts","../src/hooks/projects/useProjects.ts","../src/hooks/users/useUsers.ts","../src/utils/getEnv.ts","../src/version.ts"],"sourcesContent":["import {type SanityInstance} from '@sanity/sdk'\nimport {createContext} from 'react'\n\nexport const SanityInstanceContext = createContext<SanityInstance[] | null>(null)\n","import {type SanityInstance} from '@sanity/sdk'\nimport {useContext} from 'react'\n\nimport {SanityInstanceContext} from '../../context/SanityInstanceContext'\n\n/**\n * `useSanityInstance` returns the current Sanity instance from the application context.\n * This must be called from within a `SanityProvider` component.\n * @internal\n *\n * @param resourceId - The resourceId of the Sanity instance to return (optional)\n * @returns The current Sanity instance\n * @example\n * ```tsx\n * const instance = useSanityInstance('abc123.production')\n * ```\n */\nexport const useSanityInstance = (resourceId?: string): SanityInstance => {\n const sanityInstance = useContext(SanityInstanceContext)\n if (!sanityInstance) {\n throw new Error('useSanityInstance must be called from within the SanityProvider')\n }\n if (sanityInstance.length === 0) {\n throw new Error('No Sanity instances found')\n }\n if (sanityInstance.length === 1 || !resourceId) {\n return sanityInstance[0]\n }\n\n if (!resourceId) {\n throw new Error('resourceId is required when there are multiple Sanity instances')\n }\n\n const instance = sanityInstance.find((inst) => inst.identity.resourceId === resourceId)\n if (!instance) {\n throw new Error(`Sanity instance with resourceId ${resourceId} not found`)\n }\n return instance\n}\n","import {type ResourceId, type SanityInstance, type StateSource} from '@sanity/sdk'\nimport {useSyncExternalStore} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\ntype StateSourceFactory<TParams extends unknown[], TState> = (\n instance: SanityInstance,\n ...params: TParams\n) => StateSource<TState>\n\ninterface CreateStateSourceHookOptions<TParams extends unknown[], TState> {\n getState: StateSourceFactory<TParams, TState>\n shouldSuspend?: (instance: SanityInstance, ...params: TParams) => boolean\n suspender?: (instance: SanityInstance, ...params: TParams) => Promise<unknown>\n getResourceId?: (...params: TParams) => ResourceId | undefined\n}\n\nexport function createStateSourceHook<TParams extends unknown[], TState>(\n options: StateSourceFactory<TParams, TState> | CreateStateSourceHookOptions<TParams, TState>,\n): (...params: TParams) => TState {\n const getState = typeof options === 'function' ? options : options.getState\n const getResourceId = 'getResourceId' in options ? options.getResourceId : undefined\n const suspense = 'shouldSuspend' in options && 'suspender' in options ? options : undefined\n\n function useHook(...params: TParams) {\n let resourceId: ResourceId | undefined\n if (getResourceId) {\n resourceId = getResourceId(...params)\n }\n const instance = useSanityInstance(resourceId)\n if (suspense?.suspender && suspense?.shouldSuspend?.(instance, ...params)) {\n throw suspense.suspender(instance, ...params)\n }\n\n const state = getState(instance, ...params)\n return useSyncExternalStore(state.subscribe, state.getCurrent)\n }\n\n return useHook\n}\n","import {type AuthState, getAuthState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * @internal\n * A React hook that subscribes to authentication state changes.\n *\n * This hook provides access to the current authentication state type from the Sanity auth store.\n * It automatically re-renders when the authentication state changes.\n *\n * @remarks\n * The hook uses `useSyncExternalStore` to safely subscribe to auth state changes\n * and ensure consistency between server and client rendering.\n *\n * @returns The current authentication state type\n *\n * @example\n * ```tsx\n * function AuthStatus() {\n * const authState = useAuthState()\n * return <div>Current auth state: {authState}</div>\n * }\n * ```\n */\nexport const useAuthState: () => AuthState = createStateSourceHook(getAuthState)\n","export function isInIframe(): boolean {\n return typeof window !== 'undefined' && window.self !== window.top\n}\n\n/**\n * @internal\n *\n * Checks if the current URL is a local URL.\n *\n * @param window - The window object\n * @returns True if the current URL is a local URL, false otherwise\n */\nexport function isLocalUrl(window: Window): boolean {\n const url = typeof window !== 'undefined' ? window.location.href : ''\n\n return (\n url.startsWith('http://localhost') ||\n url.startsWith('https://localhost') ||\n url.startsWith('http://127.0.0.1') ||\n url.startsWith('https://127.0.0.1')\n )\n}\n","/**\n * Error class for authentication-related errors. Wraps errors thrown during the\n * authentication flow.\n *\n * @remarks\n * This class provides a consistent error type for authentication failures while\n * preserving the original error as the cause. If the original error has a\n * message property, it will be used as the error message.\n *\n * @alpha\n */\nexport class AuthError extends Error {\n constructor(error: unknown) {\n if (\n typeof error === 'object' &&\n !!error &&\n 'message' in error &&\n typeof error.message === 'string'\n ) {\n super(error.message)\n } else {\n super()\n }\n\n this.cause = error\n }\n}\n","import {type AuthProvider, fetchLoginUrls, getLoginUrlsState} from '@sanity/sdk'\nimport {useMemo, useSyncExternalStore} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @internal\n * A React hook that retrieves the available authentication provider URLs for login.\n *\n * @remarks\n * This hook fetches the login URLs from the Sanity auth store when the component mounts.\n * Each provider object contains information about an authentication method, including its URL.\n * The hook will suspend if the login URLs have not yet loaded.\n *\n * @example\n * ```tsx\n * // LoginProviders component that uses the hook\n * function LoginProviders() {\n * const providers = useLoginUrls()\n *\n * return (\n * <div>\n * {providers.map((provider) => (\n * <a key={provider.name} href={provider.url}>\n * Login with {provider.title}\n * </a>\n * ))}\n * </div>\n * )\n * }\n *\n * // Parent component with Suspense boundary\n * function LoginPage() {\n * return (\n * <Suspense fallback={<div>Loading authentication providers...</div>}>\n * <LoginProviders />\n * </Suspense>\n * )\n * }\n * ```\n *\n * @returns An array of {@link AuthProvider} objects containing login URLs and provider information\n * @public\n */\nexport function useLoginUrls(): AuthProvider[] {\n const instance = useSanityInstance()\n const {subscribe, getCurrent} = useMemo(() => getLoginUrlsState(instance), [instance])\n\n if (!getCurrent()) throw fetchLoginUrls(instance)\n\n return useSyncExternalStore(subscribe, getCurrent as () => AuthProvider[])\n}\n","import {SanityLogo} from '@sanity/logos'\nimport {Fragment} from 'react'\n\nconst LINKS = [\n {\n url: 'https://slack.sanity.io/',\n i18nKey: 'workspaces.community-title',\n title: 'Community',\n },\n {\n url: 'https://www.sanity.io/docs',\n i18nKey: 'workspaces.docs-title',\n title: 'Docs',\n },\n {\n url: 'https://www.sanity.io/legal/privacy',\n i18nKey: 'workspaces.privacy-title',\n title: 'Privacy',\n },\n {\n url: 'https://www.sanity.io',\n i18nKey: 'workspaces.sanity-io-title',\n title: 'sanity.io',\n },\n]\n\n/**\n * Default footer component for login screens showing Sanity branding and legal\n * links.\n *\n * @alpha\n */\nexport function LoginFooter(): React.ReactNode {\n return (\n <div className=\"sc-login-footer\">\n <SanityLogo className=\"sc-login-footer__logo\" />\n\n <ul className=\"sc-login-footer__links\">\n {LINKS.map((link) => (\n <Fragment key={link.title}>\n <li className=\"sc-login-footer__link\">\n <a href={link.url} target=\"_blank\" rel=\"noopener noreferrer\">\n {link.title}\n </a>\n </li>\n </Fragment>\n ))}\n </ul>\n </div>\n )\n}\n","import {LoginFooter} from './LoginFooter'\n\n/**\n * @alpha\n */\nexport interface LoginLayoutProps {\n /** Optional header content rendered at top of card */\n header?: React.ReactNode\n\n /** Optional footer content rendered below card. Defaults to an internal login footer */\n footer?: React.ReactNode\n\n /** Main content rendered in card body */\n children?: React.ReactNode\n}\n\n/**\n * Layout component for login-related screens providing consistent styling and structure.\n * Renders content in a centered card with optional header and footer sections.\n *\n * Can be used to build custom login screens for the AuthBoundary component, including:\n * - Login provider selection (LoginComponent)\n * - OAuth callback handling (CallbackComponent)\n * - Error states (LoginErrorComponent)\n *\n * @example\n * ```tsx\n * // Custom login screen using the layout\n * function CustomLogin({header, footer}: LoginLayoutProps) {\n * return (\n * <LoginLayout\n * header={header}\n * footer={footer}\n * >\n * <CustomLoginContent />\n * </LoginLayout>\n * )\n * }\n *\n * // Use with AuthBoundary\n * <AuthBoundary\n * LoginComponent={CustomLogin}\n * header={<Logo />}\n * >\n * <ProtectedContent />\n * </AuthBoundary>\n * ```\n *\n * @alpha\n */\nexport function LoginLayout({\n children,\n footer = <LoginFooter />,\n header,\n}: LoginLayoutProps): React.ReactNode {\n return (\n <div className=\"sc-login-layout\">\n <div className=\"sc-login-layout__container\">\n <div className=\"sc-login-layout__card\">\n {header && <div className=\"sc-login-layout__card-header\">{header}</div>}\n\n {children && <div className=\"sc-login-layout__card-body\">{children}</div>}\n </div>\n\n {footer}\n </div>\n </div>\n )\n}\n","import {type JSX, Suspense} from 'react'\n\nimport {useLoginUrls} from '../../hooks/auth/useLoginUrls'\nimport {LoginLayout, type LoginLayoutProps} from './LoginLayout'\n\n/**\n * Login component that displays available authentication providers.\n * Renders a list of login options with a loading fallback while providers load.\n *\n * @alpha\n * @internal\n */\nexport function Login({header, footer}: LoginLayoutProps): JSX.Element {\n return (\n <LoginLayout header={header} footer={footer}>\n <div className=\"sc-login\">\n <h1 className=\"sc-login__title\">Choose login provider</h1>\n\n <Suspense fallback={<div className=\"sc-login__loading\">Loading…</div>}>\n <Providers />\n </Suspense>\n </div>\n </LoginLayout>\n )\n}\n\nfunction Providers() {\n const loginUrls = useLoginUrls()\n\n return (\n <div className=\"sc-login-providers\">\n {loginUrls.map(({title, url}) => (\n <a key={url} href={url}>\n {title}\n </a>\n ))}\n </div>\n )\n}\n","import {type ResourceId, type SanityInstance} from '@sanity/sdk'\nimport {useCallback} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\nexport function createCallbackHook<TParams extends unknown[], TReturn>(\n callback: (instance: SanityInstance, ...params: TParams) => TReturn,\n resourceId?: ResourceId,\n): () => (...params: TParams) => TReturn {\n function useHook() {\n const instance = useSanityInstance(resourceId)\n return useCallback((...params: TParams) => callback(instance, ...params), [instance])\n }\n\n return useHook\n}\n","import {handleAuthCallback} from '@sanity/sdk'\n\nimport {createCallbackHook} from '../helpers/createCallbackHook'\n\n/**\n * @internal\n * A React hook that returns a function for handling authentication callbacks.\n *\n * @remarks\n * This hook provides access to the authentication store's callback handler,\n * which processes auth redirects by extracting the session ID and fetching the\n * authentication token. If fetching the long-lived token is successful,\n * `handleAuthCallback` will return a Promise that resolves a new location that\n * removes the short-lived token from the URL. Use this in combination with\n * `history.replaceState` or your own router's `replace` function to update the\n * current location without triggering a reload.\n *\n * @example\n * ```tsx\n * function AuthCallback() {\n * const handleAuthCallback = useHandleAuthCallback()\n * const router = useRouter() // Example router\n *\n * useEffect(() => {\n * async function processCallback() {\n * // Handle the callback and get the cleaned URL\n * const newUrl = await handleAuthCallback(window.location.href)\n *\n * if (newUrl) {\n * // Replace URL without triggering navigation\n * router.replace(newUrl, {shallow: true})\n * }\n * }\n *\n * processCallback().catch(console.error)\n * }, [handleAuthCallback, router])\n *\n * return <div>Completing login...</div>\n * }\n * ```\n *\n * @returns A callback handler function that processes OAuth redirects\n * @public\n */\nexport const useHandleAuthCallback = createCallbackHook(handleAuthCallback)\n","import {useEffect} from 'react'\n\nimport {useHandleAuthCallback} from '../../hooks/auth/useHandleAuthCallback'\nimport {LoginLayout, type LoginLayoutProps} from './LoginLayout'\n\n/**\n/**\n * Component shown during auth callback processing that handles login completion.\n * Automatically processes the auth callback when mounted and updates the URL\n * to remove callback parameters without triggering a page reload.\n *\n * @alpha\n */\nexport function LoginCallback({header, footer}: LoginLayoutProps): React.ReactNode {\n const handleAuthCallback = useHandleAuthCallback()\n\n useEffect(() => {\n const url = new URL(location.href)\n handleAuthCallback(url.toString()).then((replacementLocation) => {\n if (replacementLocation) {\n // history API with `replaceState` is used to prevent a reload but still\n // remove the short-lived token from the URL\n history.replaceState(null, '', replacementLocation)\n }\n })\n }, [handleAuthCallback])\n\n return (\n <LoginLayout header={header} footer={footer}>\n <div className=\"sc-login-callback\">\n <h1 className=\"sc-login-callback__title\">Logging you in…</h1>\n <div className=\"sc-login-callback__loading\">Loading…</div>\n </div>\n </LoginLayout>\n )\n}\n","import {logout} from '@sanity/sdk'\n\nimport {createCallbackHook} from '../helpers/createCallbackHook'\n\n/**\n * Hook to log out of the current session\n * @internal\n * @returns A function to log out of the current session\n */\nexport const useLogOut = createCallbackHook(logout)\n","import {useCallback} from 'react'\nimport {type FallbackProps} from 'react-error-boundary'\n\nimport {useLogOut} from '../../hooks/auth/useLogOut'\nimport {AuthError} from './AuthError'\nimport {LoginLayout, type LoginLayoutProps} from './LoginLayout'\n\n/**\n * @alpha\n */\nexport type LoginErrorProps = FallbackProps & LoginLayoutProps\n\n/**\n * Displays authentication error details and provides retry functionality.\n * Only handles {@link AuthError} instances - rethrows other error types.\n *\n * @alpha\n */\nexport function LoginError({\n error,\n resetErrorBoundary,\n header,\n footer,\n}: LoginErrorProps): React.ReactNode {\n if (!(error instanceof AuthError)) throw error\n const logout = useLogOut()\n\n const handleRetry = useCallback(async () => {\n await logout()\n resetErrorBoundary()\n }, [logout, resetErrorBoundary])\n\n return (\n <LoginLayout header={header} footer={footer}>\n <div className=\"sc-login-error\">\n <div className=\"sc-login-error__content\">\n <h2 className=\"sc-login-error__title\">Authentication Error</h2>\n <p className=\"sc-login-error__description\">\n Please try again or contact support if the problem persists.\n </p>\n </div>\n\n <button className=\"sc-login-error__button\" onClick={handleRetry}>\n Retry\n </button>\n </div>\n </LoginLayout>\n )\n}\n","import {AuthStateType} from '@sanity/sdk'\nimport {useMemo} from 'react'\nimport {ErrorBoundary, type FallbackProps} from 'react-error-boundary'\n\nimport {useAuthState} from '../../hooks/auth/useAuthState'\nimport {isInIframe} from '../utils'\nimport {AuthError} from './AuthError'\nimport {Login} from './Login'\nimport {LoginCallback} from './LoginCallback'\nimport {LoginError, type LoginErrorProps} from './LoginError'\nimport {type LoginLayoutProps} from './LoginLayout'\n\n// Only import bridge if we're in an iframe. This assumes that the app is\n// running within SanityOS if it is in an iframe.\nif (isInIframe()) {\n const parsedUrl = new URL(window.location.href)\n const mode = new URLSearchParams(parsedUrl.hash.slice(1)).get('mode')\n const script = document.createElement('script')\n script.src =\n mode === 'core-ui--staging'\n ? 'https://core.sanity-cdn.work/bridge.js'\n : 'https://core.sanity-cdn.com/bridge.js'\n script.type = 'module'\n script.async = true\n document.head.appendChild(script)\n}\n\n/**\n * @internal\n */\ninterface AuthBoundaryProps extends LoginLayoutProps {\n /**\n * Custom component to render the login screen.\n * Receives all login layout props. Defaults to {@link Login}.\n */\n LoginComponent?: React.ComponentType<LoginLayoutProps>\n\n /**\n * Custom component to render during OAuth callback processing.\n * Receives all login layout props. Defaults to {@link LoginCallback}.\n */\n CallbackComponent?: React.ComponentType<LoginLayoutProps>\n\n /**\n * Custom component to render when authentication errors occur.\n * Receives login layout props and error boundary props. Defaults to\n * {@link LoginError}\n */\n LoginErrorComponent?: React.ComponentType<LoginErrorProps>\n}\n\n/**\n * A component that handles authentication flow and error boundaries for a\n * protected section of the application.\n *\n * @remarks\n * This component manages different authentication states and renders the\n * appropriate components based on that state.\n *\n * @example\n * ```tsx\n * function App() {\n * return (\n * <AuthBoundary header={<MyLogo />}>\n * <ProtectedContent />\n * </AuthBoundary>\n * )\n * }\n * ```\n *\n * @internal\n */\nexport function AuthBoundary({\n LoginErrorComponent = LoginError,\n ...props\n}: AuthBoundaryProps): React.ReactNode {\n const {header, footer} = props\n const FallbackComponent = useMemo(() => {\n return function LoginComponentWithLayoutProps(fallbackProps: FallbackProps) {\n return <LoginErrorComponent {...fallbackProps} header={header} footer={footer} />\n }\n }, [header, footer, LoginErrorComponent])\n\n return (\n <ErrorBoundary FallbackComponent={FallbackComponent}>\n <AuthSwitch {...props} />\n </ErrorBoundary>\n )\n}\n\ninterface AuthSwitchProps extends LoginLayoutProps {\n LoginComponent?: React.ComponentType<LoginLayoutProps>\n CallbackComponent?: React.ComponentType<LoginLayoutProps>\n}\n\nfunction AuthSwitch({\n LoginComponent = Login,\n CallbackComponent = LoginCallback,\n children,\n ...props\n}: AuthSwitchProps) {\n const authState = useAuthState()\n\n switch (authState.type) {\n case AuthStateType.ERROR: {\n throw new AuthError(authState.error)\n }\n case AuthStateType.LOGGING_IN: {\n return <CallbackComponent {...props} />\n }\n case AuthStateType.LOGGED_IN: {\n return children\n }\n default: {\n return <LoginComponent {...props} />\n }\n }\n}\n","import {type SanityInstance} from '@sanity/sdk'\nimport {type ReactElement} from 'react'\n\nimport {SanityInstanceContext} from './SanityInstanceContext'\n\n/**\n * @internal\n */\nexport interface SanityProviderProps {\n children: React.ReactNode\n sanityInstances: SanityInstance[]\n}\n\n/**\n * @internal\n *\n * Top-level context provider that provides access to the Sanity configuration instance.\n * This must wrap any components making use of the Sanity SDK React hooks.\n *\n * @remarks In most cases, SanityApp should be used rather than SanityProvider directly; SanityApp bundles both SanityProvider and an authentication layer.\n * @param props - Sanity project and dataset configuration\n * @returns Rendered component\n * @example\n * ```tsx\n * import {createSanityInstance} from '@sanity/sdk'\n * import {SanityProvider} from '@sanity/sdk-react'\n *\n * import MyAppRoot from './Root'\n *\n * const sanityInstance = createSanityInstance({\n * projectId: 'your-project-id',\n * dataset: 'production',\n * })\n *\n * export default function MyApp() {\n * return (\n * <SanityProvider sanityInstance={sanityInstance}>\n * <MyAppRoot />\n * </SanityProvider>\n * )\n * }\n * ```\n */\nexport const SanityProvider = ({children, sanityInstances}: SanityProviderProps): ReactElement => {\n return (\n <SanityInstanceContext.Provider value={sanityInstances}>\n {children}\n </SanityInstanceContext.Provider>\n )\n}\n","import {createSanityInstance, type SanityConfig} from '@sanity/sdk'\nimport {type ReactElement, type ReactNode, Suspense, useMemo} from 'react'\n\nimport {SanityProvider} from '../context/SanityProvider'\nimport {AuthBoundary} from './auth/AuthBoundary'\n\nconst DEFAULT_FALLBACK = (\n <>\n Warning: No fallback provided. Please supply a fallback prop to ensure proper Suspense handling.\n </>\n)\n\n/**\n * @internal\n */\nexport interface SDKProviderProps {\n children: ReactNode\n sanityConfigs: SanityConfig[]\n fallback: ReactNode\n}\n\n/**\n * @internal\n *\n * Top-level context provider that provides access to the Sanity SDK.\n */\nexport function SDKProvider({children, sanityConfigs, fallback}: SDKProviderProps): ReactElement {\n const sanityInstances = useMemo(() => {\n return sanityConfigs.map((sanityConfig: SanityConfig) => createSanityInstance(sanityConfig))\n }, [sanityConfigs])\n\n return (\n <SanityProvider sanityInstances={sanityInstances}>\n {/* This Suspense boundary is necessary because some hooks may suspend.\n It ensures that the Sanity instance state created above remains stable\n before rendering the AuthBoundary and its children. */}\n <Suspense fallback={fallback ?? DEFAULT_FALLBACK}>\n <AuthBoundary>{children}</AuthBoundary>\n </Suspense>\n </SanityProvider>\n )\n}\n","import {type SanityConfig} from '@sanity/sdk'\nimport {type ReactElement, useEffect} from 'react'\n\nimport {SDKProvider} from './SDKProvider'\nimport {isInIframe, isLocalUrl} from './utils'\n\n/**\n * @public\n */\nexport interface SanityAppProps {\n sanityConfigs: SanityConfig[]\n children: React.ReactNode\n fallback: React.ReactNode\n}\n\nconst CORE_URL = 'https://core.sanity.io'\n\n/**\n * @public\n *\n * The SanityApp component provides your Sanity application with access to your Sanity configuration,\n * as well as application context and state which is used by the Sanity React hooks. Your application\n * must be wrapped with the SanityApp component to function properly.\n *\n * @param props - Your Sanity configuration and the React children to render\n * @returns Your Sanity application, integrated with your Sanity configuration and application context\n *\n * @example\n * ```tsx\n * import { SanityApp } from '@sanity/sdk-react'\n *\n * import MyAppRoot from './Root'\n *\n * // Single project configuration\n * const mySanityConfigs = [\n * {\n * projectId: 'my-project-id',\n * dataset: 'production',\n * },\n * ]\n *\n * // Or multiple project configurations\n * const multipleConfigs = [\n * // Configuration for your main project. This will be used as the default project for all hooks if no resource ID override is provided.\n * {\n * projectId: 'marketing-website-project',\n * dataset: 'production',\n * },\n * // Configuration for a separate blog project\n * {\n * projectId: 'blog-project',\n * dataset: 'production',\n * },\n * // Configuration for a separate ecommerce project\n * {\n * projectId: 'ecommerce-project',\n * dataset: 'production',\n * }\n * ]\n *\n * export default function MyApp() {\n * return (\n * <SanityApp sanityConfigs={mySanityConfigs}>\n * <MyAppRoot />\n * </SanityApp>\n * )\n * }\n * ```\n */\nexport function SanityApp({sanityConfigs, children, fallback}: SanityAppProps): ReactElement {\n useEffect(() => {\n let timeout: NodeJS.Timeout | undefined\n\n if (!isInIframe() && !isLocalUrl(window)) {\n // If the app is not running in an iframe and is not a local url, redirect to core.\n timeout = setTimeout(() => {\n // eslint-disable-next-line no-console\n console.warn('Redirecting to core', CORE_URL)\n window.location.replace(CORE_URL)\n }, 1000)\n }\n return () => clearTimeout(timeout)\n }, [sanityConfigs])\n\n return (\n <SDKProvider sanityConfigs={sanityConfigs} fallback={fallback}>\n {children}\n </SDKProvider>\n )\n}\n","import {getTokenState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * Hook to get the currently logged in user\n * @internal\n * @returns The current user or null if not authenticated\n */\nexport const useAuthToken = createStateSourceHook(getTokenState)\n","import {type CurrentUser, getCurrentUserState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\ntype UseCurrentUser = {\n /**\n * @public\n *\n * Provides the currently authenticated user’s profile information.\n *\n * @category Users\n * @returns The current user data\n *\n * @example Rendering a basic user profile\n * ```\n * const user = useCurrentUser()\n *\n * return (\n * <figure>\n * <img src={user?.profileImage} alt=`Profile image for ${user?.name}` />\n * <h2>{user?.name}</h2>\n * </figure>\n * )\n * ```\n */\n (): CurrentUser | null\n}\n\n/**\n * @public\n * @function\n * @TODO This should not return null — users of a custom app will always be authenticated via Core\n */\nexport const useCurrentUser: UseCurrentUser = createStateSourceHook(getCurrentUserState)\n","import {getDashboardOrganizationId} from '@sanity/sdk'\nimport {useMemo, useSyncExternalStore} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @remarks\n * A React hook that retrieves the dashboard organization ID that is currently selected in the Sanity Dashboard.\n *\n * @example\n * ```tsx\n * function DashboardComponent() {\n * const orgId = useDashboardOrganizationId()\n *\n * if (!orgId) return null\n *\n * return <div>Organization ID: {String(orgId)}</div>\n * }\n * ```\n *\n * @returns The dashboard organization ID (string | undefined)\n * @public\n */\nexport function useDashboardOrganizationId(): string | undefined {\n const instance = useSanityInstance()\n const {subscribe, getCurrent} = useMemo(() => getDashboardOrganizationId(instance), [instance])\n\n return useSyncExternalStore(subscribe, getCurrent)\n}\n","import {getClientState} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * A React hook that provides a client that subscribes to changes in your application,\n * such as user authentication changes.\n *\n * @remarks\n * The hook uses `useSyncExternalStore` to safely subscribe to changes\n * and ensure consistency between server and client rendering.\n *\n * @category Platform\n * @returns A Sanity client\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const client = useClient({apiVersion: '2024-11-12'})\n * const [document, setDocument] = useState(null)\n * useEffect(async () => {\n * const doc = client.fetch('*[_id == \"myDocumentId\"]')\n * setDocument(doc)\n * }, [])\n * return <div>{JSON.stringify(document) ?? 'Loading...'}</div>\n * }\n * ```\n *\n * @public\n * @function\n */\nexport const useClient = createStateSourceHook({\n getState: getClientState,\n getResourceId: (e) => e.resourceId,\n})\n","import {type ChannelInstance, type Controller, type Status} from '@sanity/comlink'\nimport {\n type FrameMessage,\n getOrCreateChannel,\n getOrCreateController,\n releaseChannel,\n type WindowMessage,\n} from '@sanity/sdk'\nimport {useCallback, useEffect, useRef} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @internal\n */\nexport type FrameMessageHandler<TWindowMessage extends WindowMessage> = (\n event: TWindowMessage['data'],\n) => TWindowMessage['response'] | Promise<TWindowMessage['response']>\n\n/**\n * @internal\n */\nexport interface UseFrameConnectionOptions<TWindowMessage extends WindowMessage> {\n name: string\n connectTo: string\n targetOrigin: string\n onMessage?: {\n [K in TWindowMessage['type']]: (data: Extract<TWindowMessage, {type: K}>['data']) => void\n }\n heartbeat?: boolean\n onStatus?: (status: Status) => void\n}\n\n/**\n * @internal\n */\nexport interface FrameConnection<TFrameMessage extends FrameMessage> {\n connect: (frameWindow: Window) => () => void // Return cleanup function\n sendMessage: <T extends TFrameMessage['type']>(\n ...params: Extract<TFrameMessage, {type: T}>['data'] extends undefined\n ? [type: T]\n : [type: T, data: Extract<TFrameMessage, {type: T}>['data']]\n ) => void\n}\n\n/**\n * @internal\n */\nexport function useFrameConnection<\n TFrameMessage extends FrameMessage,\n TWindowMessage extends WindowMessage,\n>(options: UseFrameConnectionOptions<TWindowMessage>): FrameConnection<TFrameMessage> {\n const {onMessage, targetOrigin, name, connectTo, heartbeat, onStatus} = options\n const instance = useSanityInstance()\n const controllerRef = useRef<Controller | null>(null)\n const channelRef = useRef<ChannelInstance<TFrameMessage, TWindowMessage> | null>(null)\n\n useEffect(() => {\n const controller = getOrCreateController(instance, targetOrigin)\n const channel = getOrCreateChannel(instance, {name, connectTo, heartbeat})\n controllerRef.current = controller\n channelRef.current = channel\n\n channel.onStatus((event) => {\n onStatus?.(event.status)\n })\n\n const messageUnsubscribers: Array<() => void> = []\n\n if (onMessage) {\n Object.entries(onMessage).forEach(([type, handler]) => {\n const unsubscribe = channel.on(type, handler as FrameMessageHandler<TWindowMessage>)\n messageUnsubscribers.push(unsubscribe)\n })\n }\n\n return () => {\n // Clean up all subscriptions and stop controller/channel\n messageUnsubscribers.forEach((unsub) => unsub())\n releaseChannel(instance, name)\n channelRef.current = null\n controllerRef.current = null\n }\n }, [targetOrigin, name, connectTo, heartbeat, onMessage, instance, onStatus])\n\n const connect = useCallback((frameWindow: Window) => {\n const removeTarget = controllerRef.current?.addTarget(frameWindow)\n return () => {\n removeTarget?.()\n }\n }, [])\n\n const sendMessage = useCallback(\n <T extends TFrameMessage['type']>(\n type: T,\n data?: Extract<TFrameMessage, {type: T}>['data'],\n ) => {\n channelRef.current?.post(type, data)\n },\n [],\n )\n\n return {\n connect,\n sendMessage,\n }\n}\n","import {type MessageData, type Node, type Status} from '@sanity/comlink'\nimport {type FrameMessage, getOrCreateNode, releaseNode, type WindowMessage} from '@sanity/sdk'\nimport {useCallback, useEffect, useRef} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @internal\n */\nexport type WindowMessageHandler<TFrameMessage extends FrameMessage> = (\n event: TFrameMessage['data'],\n) => TFrameMessage['response']\n\n/**\n * @internal\n */\nexport interface UseWindowConnectionOptions<TMessage extends FrameMessage> {\n name: string\n connectTo: string\n onMessage?: Record<TMessage['type'], WindowMessageHandler<TMessage>>\n onStatus?: (status: Status) => void\n}\n\n/**\n * @internal\n */\nexport interface WindowConnection<TMessage extends WindowMessage> {\n sendMessage: <TType extends TMessage['type']>(\n type: TType,\n data?: Extract<TMessage, {type: TType}>['data'],\n ) => void\n fetch: <TResponse>(\n type: string,\n data?: MessageData,\n options?: {\n signal?: AbortSignal\n suppressWarnings?: boolean\n responseTimeout?: number\n },\n ) => Promise<TResponse>\n}\n\n/**\n * @internal\n * Hook to wrap a Comlink node in a React hook.\n * Our store functionality takes care of the lifecycle of the node,\n * as well as sharing a single node between invocations if they share the same name.\n *\n * Generally not to be used directly, but to be used as a dependency of\n * Comlink-powered hooks like `useManageFavorite`.\n */\nexport function useWindowConnection<\n TWindowMessage extends WindowMessage,\n TFrameMessage extends FrameMessage,\n>({\n name,\n connectTo,\n onMessage,\n onStatus,\n}: UseWindowConnectionOptions<TFrameMessage>): WindowConnection<TWindowMessage> {\n const nodeRef = useRef<Node<TWindowMessage, TFrameMessage> | null>(null)\n const messageUnsubscribers = useRef<(() => void)[]>([])\n const instance = useSanityInstance()\n\n useEffect(() => {\n // the type cast is unfortunate, but the generic type of the node is not known here.\n // We know that the node is a WindowMessage node, but not the generic types.\n const node = getOrCreateNode(instance, {\n name,\n connectTo,\n }) as unknown as Node<TWindowMessage, TFrameMessage>\n nodeRef.current = node\n\n const statusUnsubscribe = node.onStatus((eventStatus) => {\n onStatus?.(eventStatus)\n })\n\n if (onMessage) {\n Object.entries(onMessage).forEach(([type, handler]) => {\n const messageUnsubscribe = node.on(type, handler as WindowMessageHandler<TFrameMessage>)\n messageUnsubscribers.current.push(messageUnsubscribe)\n })\n }\n\n return () => {\n statusUnsubscribe()\n messageUnsubscribers.current.forEach((unsubscribe) => unsubscribe())\n messageUnsubscribers.current = []\n releaseNode(instance, name)\n nodeRef.current = null\n }\n }, [instance, name, connectTo, onMessage, onStatus])\n\n const sendMessage = useCallback(\n (type: TWindowMessage['type'], data?: Extract<TWindowMessage, {type: typeof type}>['data']) => {\n if (!nodeRef.current) {\n throw new Error('Cannot send message before connection is established')\n }\n nodeRef.current.post(type, data)\n },\n [],\n )\n\n const fetch = useCallback(\n <TResponse>(\n type: string,\n data?: MessageData,\n fetchOptions?: {\n responseTimeout?: number\n signal?: AbortSignal\n suppressWarnings?: boolean\n },\n ): Promise<TResponse> => {\n return nodeRef.current?.fetch(type, data, fetchOptions ?? {}) as Promise<TResponse>\n },\n [],\n )\n return {\n sendMessage,\n fetch,\n }\n}\n","import {type Status} from '@sanity/comlink'\nimport {\n type CanvasResource,\n type Events,\n type MediaResource,\n SDK_CHANNEL_NAME,\n SDK_NODE_NAME,\n type StudioResource,\n} from '@sanity/message-protocol'\nimport {type FrameMessage} from '@sanity/sdk'\nimport {useCallback, useState} from 'react'\n\nimport {useWindowConnection} from './useWindowConnection'\n\n// should we import this whole type from the message protocol?\n\ninterface ManageFavorite {\n favorite: () => void\n unfavorite: () => void\n isFavorited: boolean\n isConnected: boolean\n}\n\ninterface UseManageFavoriteProps {\n documentId: string\n documentType: string\n resourceId?: string\n resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']\n}\n\n/**\n * @beta\n *\n * ## useManageFavorite\n * This hook provides functionality to add and remove documents from favorites,\n * and tracks the current favorite status of the document.\n * @category Dashboard Communication\n * @param documentHandle - The document handle containing document ID and type, like `{_id: '123', _type: 'book'}`\n * @returns An object containing:\n * - `favorite` - Function to add document to favorites\n * - `unfavorite` - Function to remove document from favorites\n * - `isFavorited` - Boolean indicating if document is currently favorited\n * - `isConnected` - Boolean indicating if connection to Dashboard UI is established\n *\n * @example\n * ```tsx\n * function MyDocumentAction(props: DocumentActionProps) {\n * const {documentId, documentType} = props\n * const {favorite, unfavorite, isFavorited, isConnected} = useManageFavorite({\n * documentId,\n * documentType\n * })\n *\n * return (\n * <Button\n * disabled={!isConnected}\n * onClick={() => isFavorited ? unfavorite() : favorite()}\n * text={isFavorited ? 'Remove from favorites' : 'Add to favorites'}\n * />\n * )\n * }\n * ```\n */\nexport function useManageFavorite({\n documentId,\n documentType,\n resourceId,\n resourceType,\n}: UseManageFavoriteProps): ManageFavorite {\n const [isFavorited, setIsFavorited] = useState(false) // should load this from a comlink fetch\n const [status, setStatus] = useState<Status>('idle')\n const {sendMessage} = useWindowConnection<Events.FavoriteMessage, FrameMessage>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n onStatus: setStatus,\n })\n\n if (resourceType !== 'studio' && !resourceId) {\n throw new Error('resourceId is required for media-library and canvas resources')\n }\n\n const handleFavoriteAction = useCallback(\n (action: 'added' | 'removed', setFavoriteState: boolean) => {\n if (!documentId || !documentType || !resourceType) return\n\n try {\n const message: Events.FavoriteMessage = {\n type: 'dashboard/v1/events/favorite/mutate',\n data: {\n eventType: action,\n documentId,\n documentType,\n resourceType,\n // Resource Id should exist for media-library and canvas resources\n resourceId: resourceId!,\n },\n response: {\n success: true,\n },\n }\n\n sendMessage(message.type, message.data)\n setIsFavorited(setFavoriteState)\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Failed to update favorite status')\n // eslint-disable-next-line no-console\n console.error(\n `Failed to ${action === 'added' ? 'favorite' : 'unfavorite'} document:`,\n error,\n )\n throw error\n }\n },\n [documentId, documentType, resourceId, resourceType, sendMessage],\n )\n\n const favorite = useCallback(() => handleFavoriteAction('added', true), [handleFavoriteAction])\n\n const unfavorite = useCallback(\n () => handleFavoriteAction('removed', false),\n [handleFavoriteAction],\n )\n\n return {\n favorite,\n unfavorite,\n isFavorited,\n isConnected: status === 'connected',\n }\n}\n","import {type Status} from '@sanity/comlink'\nimport {\n type CanvasResource,\n type Events,\n type MediaResource,\n SDK_CHANNEL_NAME,\n SDK_NODE_NAME,\n type StudioResource,\n} from '@sanity/message-protocol'\nimport {type FrameMessage} from '@sanity/sdk'\nimport {useCallback, useState} from 'react'\n\nimport {useWindowConnection} from './useWindowConnection'\n\ninterface DocumentInteractionHistory {\n recordEvent: (eventType: 'viewed' | 'edited' | 'created' | 'deleted') => void\n isConnected: boolean\n}\n\n/**\n * @public\n */\ninterface UseRecordDocumentHistoryEventProps {\n documentId: string\n documentType: string\n resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']\n resourceId?: string\n}\n\n/**\n * @public\n * Hook for managing document interaction history in Sanity Studio.\n * This hook provides functionality to record document interactions.\n * @category History\n * @param documentHandle - The document handle containing document ID and type, like `{_id: '123', _type: 'book'}`\n * @returns An object containing:\n * - `recordEvent` - Function to record document interactions\n * - `isConnected` - Boolean indicating if connection to Studio is established\n *\n * @example\n * ```tsx\n * function MyDocumentAction(props: DocumentActionProps) {\n * const {documentId, documentType, resourceType, resourceId} = props\n * const {recordEvent, isConnected} = useRecordDocumentHistoryEvent({\n * documentId,\n * documentType,\n * resourceType,\n * resourceId,\n * })\n *\n * return (\n * <Button\n * disabled={!isConnected}\n * onClick={() => recordEvent('viewed')}\n * text={'Viewed'}\n * />\n * )\n * }\n * ```\n */\nexport function useRecordDocumentHistoryEvent({\n documentId,\n documentType,\n resourceType,\n resourceId,\n}: UseRecordDocumentHistoryEventProps): DocumentInteractionHistory {\n const [status, setStatus] = useState<Status>('idle')\n const {sendMessage} = useWindowConnection<Events.HistoryMessage, FrameMessage>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n onStatus: setStatus,\n })\n\n if (resourceType !== 'studio' && !resourceId) {\n throw new Error('resourceId is required for media-library and canvas resources')\n }\n\n const recordEvent = useCallback(\n (eventType: 'viewed' | 'edited' | 'created' | 'deleted') => {\n try {\n const message: Events.HistoryMessage = {\n type: 'dashboard/v1/events/history',\n data: {\n eventType,\n documentId,\n documentType,\n resourceType,\n resourceId: resourceId!,\n },\n }\n\n sendMessage(message.type, message.data)\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to record history event:', error)\n throw error\n }\n },\n [documentId, documentType, resourceId, resourceType, sendMessage],\n )\n\n return {\n recordEvent,\n isConnected: status === 'connected',\n }\n}\n","import {type Status} from '@sanity/comlink'\nimport {SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\nimport {useEffect, useState} from 'react'\n\nimport {useWindowConnection} from '../comlink/useWindowConnection'\n\ninterface Workspace {\n name: string\n title: string\n basePath: string\n dataset: string\n userApplicationId: string\n url: string\n _ref: string\n}\n\ninterface WorkspacesByResourceId {\n [key: string]: Workspace[] // key format: `${projectId}:${dataset}`\n}\n\ninterface StudioWorkspacesResult {\n workspacesByResourceId: WorkspacesByResourceId\n error: string | null\n isConnected: boolean\n}\n\n/**\n * Hook that fetches studio workspaces and organizes them by projectId:dataset\n * @internal\n */\nexport function useStudioWorkspacesByResourceId(): StudioWorkspacesResult {\n const [workspacesByResourceId, setWorkspacesByResourceId] = useState<WorkspacesByResourceId>({})\n const [status, setStatus] = useState<Status>('idle')\n const [error, setError] = useState<string | null>(null)\n\n const {fetch} = useWindowConnection({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n onStatus: setStatus,\n })\n\n // Once computed, this should probably be in a store and poll for changes\n // However, our stores are currently being refactored\n useEffect(() => {\n if (!fetch || status !== 'connected') return\n\n async function fetchWorkspaces(signal: AbortSignal) {\n try {\n const data = await fetch<{\n context: {availableResources: Array<{projectId: string; workspaces: Workspace[]}>}\n }>('dashboard/v1/bridge/context', undefined, {signal})\n\n const workspaceMap: WorkspacesByResourceId = {}\n\n data.context.availableResources.forEach((resource) => {\n if (!resource.projectId || !resource.workspaces?.length) return\n\n resource.workspaces.forEach((workspace) => {\n const key = `${resource.projectId}:${workspace.dataset}`\n if (!workspaceMap[key]) {\n workspaceMap[key] = []\n }\n workspaceMap[key].push(workspace)\n })\n })\n\n setWorkspacesByResourceId(workspaceMap)\n setError(null)\n } catch (err: unknown) {\n if (err instanceof Error) {\n if (err.name === 'AbortError') {\n return\n }\n setError('Failed to fetch workspaces')\n }\n }\n }\n\n const controller = new AbortController()\n fetchWorkspaces(controller.signal)\n\n return () => {\n controller.abort()\n }\n }, [fetch, status])\n\n return {\n workspacesByResourceId,\n error,\n isConnected: status === 'connected',\n }\n}\n","import {type Status} from '@sanity/comlink'\nimport {SDK_CHANNEL_NAME, SDK_NODE_NAME} from '@sanity/message-protocol'\nimport {type DocumentHandle} from '@sanity/sdk'\nimport {useCallback, useState} from 'react'\n\nimport {useWindowConnection} from '../comlink/useWindowConnection'\nimport {useStudioWorkspacesByResourceId} from './useStudioWorkspacesByResourceId'\n\ninterface NavigateToResourceMessage {\n type: 'dashboard/v1/bridge/navigate-to-resource'\n data: {\n /**\n * Resource ID\n */\n resourceId: string\n /**\n * Resource type\n * @example 'application' | 'studio'\n */\n resourceType: string\n /**\n * Path within the resource to navigate to.\n */\n path?: string\n }\n}\n\ninterface NavigateToStudioResult {\n navigateToStudioDocument: () => void\n isConnected: boolean\n}\n\n/**\n * @public\n * Hook that provides a function to navigate to a studio document.\n * Currently, requires a document handle with a resourceId.\n * That resourceId is currently formatted like: `document:projectId.dataset:documentId`\n * If the hook you used to retrieve the document handle doesn't provide a resourceId like this,\n * you can construct it according to the above format with the document handle's _id.\n *\n * This will only work if you have deployed a studio with a workspace\n * with this projectId / dataset combination.\n * It may be able to take a custom URL in the future.\n *\n * This will likely change in the future.\n * @param documentHandle - The document handle containing document ID, type, and resource ID\n * @returns An object containing:\n * - navigateToStudioDocument - Function that when called will navigate to the studio document\n * - isConnected - Boolean indicating if connection to Dashboard is established\n *\n * @example\n * ```ts\n * import {navigateToStudioDocument, type DocumentHandle} from '@sanity/sdk'\n *\n * function MyComponent({documentHandle}: {documentHandle: DocumentHandle}) {\n * const {navigateToStudioDocument, isConnected} = useNavigateToStudioDocument(documentHandle)\n *\n * return (\n * <button onClick={navigateToStudioDocument} disabled={!isConnected}>\n * Navigate to Studio Document\n * </button>\n * )\n * }\n * ```\n */\nexport function useNavigateToStudioDocument(\n documentHandle: DocumentHandle,\n): NavigateToStudioResult {\n const {workspacesByResourceId, isConnected: workspacesConnected} =\n useStudioWorkspacesByResourceId()\n const [status, setStatus] = useState<Status>('idle')\n const {sendMessage} = useWindowConnection<NavigateToResourceMessage, never>({\n name: SDK_NODE_NAME,\n connectTo: SDK_CHANNEL_NAME,\n onStatus: setStatus,\n })\n\n const navigateToStudioDocument = useCallback(() => {\n if (!workspacesConnected || status !== 'connected' || !documentHandle.resourceId) {\n return\n }\n\n // Extract projectId and dataset from the resourceId (current format: document:projectId.dataset:documentId)\n const [, projectAndDataset] = documentHandle.resourceId.split(':')\n const [projectId, dataset] = projectAndDataset.split('.')\n if (!projectId || !dataset) {\n return\n }\n\n // Find the workspace for this document\n const workspaces = workspacesByResourceId[`${projectId}:${dataset}`]\n if (!workspaces?.length) {\n // eslint-disable-next-line no-console\n console.warn('No workspace found for document', documentHandle.resourceId)\n return\n }\n\n if (workspaces.length > 1) {\n // eslint-disable-next-line no-console\n console.warn('Multiple workspaces found for document', documentHandle.resourceId)\n // eslint-disable-next-line no-console\n console.warn('Using the first one', workspaces[0])\n }\n\n const workspace = workspaces[0]\n\n const message: NavigateToResourceMessage = {\n type: 'dashboard/v1/bridge/navigate-to-resource',\n data: {\n resourceId: workspace._ref,\n resourceType: 'studio',\n path: `/intent/edit/id=${documentHandle._id};type=${documentHandle._type}`,\n },\n }\n\n sendMessage(message.type, message.data)\n }, [documentHandle, workspacesConnected, status, sendMessage, workspacesByResourceId])\n\n return {\n navigateToStudioDocument,\n isConnected: workspacesConnected && status === 'connected',\n }\n}\n","import {type DatasetsResponse} from '@sanity/client'\nimport {getDatasetsState, resolveDatasets, type SanityInstance, type StateSource} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\ntype UseDatasets = {\n /**\n *\n * Returns metadata for each dataset the current user has access to.\n *\n * @category Datasets\n * @returns The metadata for your the datasets\n *\n * @example\n * ```tsx\n * const datasets = useDatasets()\n *\n * return (\n * <select>\n * {datasets.map((dataset) => (\n * <option key={dataset.name}>{dataset.name}</option>\n * ))}\n * </select>\n * )\n * ```\n *\n */\n (): DatasetsResponse\n}\n\n/**\n * @public\n * @function\n */\nexport const useDatasets: UseDatasets = createStateSourceHook({\n // remove `undefined` since we're suspending when that is the case\n getState: getDatasetsState as (instance: SanityInstance) => StateSource<DatasetsResponse>,\n shouldSuspend: (instance) => getDatasetsState(instance).getCurrent() === undefined,\n suspender: resolveDatasets,\n})\n","import {\n type ActionsResult,\n applyDocumentActions,\n type ApplyDocumentActionsOptions,\n type DocumentAction,\n type ResourceId,\n} from '@sanity/sdk'\nimport {type SanityDocument} from '@sanity/types'\n\nimport {createCallbackHook} from '../helpers/createCallbackHook'\n\n/**\n *\n * @beta\n *\n * Provides a callback for applying one or more actions to a document.\n *\n * @category Documents\n * @param resourceId - The resource ID of the document to apply actions to. If not provided, the document will use the default resource.\n * @returns A function that takes one more more {@link DocumentAction}s and returns a promise that resolves to an {@link ActionsResult}.\n * @example Publish or unpublish a document\n * ```\n * import { publishDocument, unpublishDocument } from '@sanity/sdk'\n * import { useApplyDocumentActions } from '@sanity/sdk-react'\n *\n * const apply = useApplyDocumentActions()\n * const myDocument = { _id: 'my-document-id', _type: 'my-document-type' }\n *\n * return (\n * <button onClick={() => apply(publishDocument(myDocument))}>Publish</button>\n * <button onClick={() => apply(unpublishDocument(myDocument))}>Unpublish</button>\n * )\n * ```\n *\n * @example Create and publish a new document\n * ```\n * import { createDocument, publishDocument } from '@sanity/sdk'\n * import { useApplyDocumentActions } from '@sanity/sdk-react'\n *\n * const apply = useApplyDocumentActions()\n *\n * const handleCreateAndPublish = () => {\n * const handle = { _id: window.crypto.randomUUID(), _type: 'my-document-type' }\n * apply([\n * createDocument(handle),\n * publishDocument(handle),\n * ])\n * }\n *\n * return (\n * <button onClick={handleCreateAndPublish}>\n * I’m feeling lucky\n * </button>\n * )\n * ```\n */\nexport function useApplyDocumentActions(\n resourceId?: ResourceId,\n): <TDocument extends SanityDocument>(\n action: DocumentAction<TDocument> | DocumentAction<TDocument>[],\n options?: ApplyDocumentActionsOptions,\n) => Promise<ActionsResult<TDocument>>\n\n/** @beta */\nexport function useApplyDocumentActions(\n resourceId?: ResourceId,\n): (\n action: DocumentAction | DocumentAction[],\n options?: ApplyDocumentActionsOptions,\n) => Promise<ActionsResult> {\n return _useApplyDocumentActions(resourceId)()\n}\n\nconst _useApplyDocumentActions = (resourceId?: ResourceId) =>\n createCallbackHook(applyDocumentActions, resourceId)\n","import {\n type DocumentHandle,\n getDocumentState,\n getResourceId,\n type JsonMatch,\n type JsonMatchPath,\n resolveDocument,\n} from '@sanity/sdk'\nimport {type SanityDocument} from '@sanity/types'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * @beta\n *\n * ## useDocument(doc, path)\n * Read and subscribe to nested values in a document\n * @category Documents\n * @param doc - The document to read state from. If you pass a `DocumentHandle` with a `resourceId` in the DocumentResourceId format (`document:projectId.dataset:documentId`)\n * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.\n * @param path - The path to the nested value to read from\n * @returns The value at the specified path\n * @example\n * ```tsx\n * import {type DocumentHandle, useDocument} from '@sanity/sdk-react'\n *\n * function OrderLink({documentHandle}: {documentHandle: DocumentHandle}) {\n * const title = useDocument(documentHandle, 'title')\n * const id = useDocument(documentHandle, '_id')\n *\n * return (\n * <a href=`/order/${id}`>Order {title} today!</a>\n * )\n * }\n * ```\n *\n */\nexport function useDocument<\n TDocument extends SanityDocument,\n TPath extends JsonMatchPath<TDocument>,\n>(doc: DocumentHandle<TDocument>, path: TPath): JsonMatch<TDocument, TPath> | undefined\n\n/**\n * @beta\n * ## useDocument(doc)\n * Read and subscribe to an entire document\n * @param doc - The document to read state from\n * @returns The document state as an object\n * @example\n * ```tsx\n * import {type SanityDocument, type DocumentHandle, useDocument} from '@sanity/sdk-react'\n *\n * interface Book extends SanityDocument {\n * title: string\n * author: string\n * summary: string\n * }\n *\n * function DocumentView({documentHandle}: {documentHandle: DocumentHandle}) {\n * const book = useDocument<Book>(documentHandle)\n *\n * return (\n * <article>\n * <h1>{book?.title}</h1>\n * <address>By {book?.author}</address>\n *\n * <h2>Summary</h2>\n * {book?.summary}\n *\n * <h2>Order</h2>\n * <a href=`/order/${book._id}`>Order {book?.title} today!</a>\n * </article>\n * )\n * }\n * ```\n *\n */\nexport function useDocument<TDocument extends SanityDocument>(\n doc: DocumentHandle<TDocument>,\n): TDocument | null\n\n/**\n * @beta\n * Reads and subscribes to a document’s realtime state, incorporating both local and remote changes.\n * When called with a `path` argument, the hook will return the nested value’s state.\n * When called without a `path` argument, the entire document’s state will be returned.\n *\n * @remarks\n * `useDocument` is designed to be used within a realtime context in which local updates to documents\n * need to be displayed before they are persisted to the remote copy. This can be useful within a collaborative\n * or realtime editing interface where local changes need to be reflected immediately.\n *\n * However, this hook can be too resource intensive for applications where static document values simply\n * need to be displayed (or when changes to documents don’t need to be reflected immediately);\n * consider using `usePreview` or `useQuery` for these use cases instead. These hooks leverage the Sanity\n * Live Content API to provide a more efficient way to read and subscribe to document state.\n */\nexport function useDocument(doc: DocumentHandle, path?: string): unknown {\n return _useDocument(doc, path)\n}\n\nconst _useDocument = createStateSourceHook<[doc: DocumentHandle, path?: string], unknown>({\n getState: getDocumentState,\n shouldSuspend: (instance, doc) => getDocumentState(instance, doc._id).getCurrent() === undefined,\n suspender: resolveDocument,\n getResourceId: (doc) => getResourceId(doc.resourceId),\n})\n","import {\n type DocumentEvent,\n type DocumentHandle,\n getResourceId,\n subscribeDocumentEvents,\n} from '@sanity/sdk'\nimport {useCallback, useEffect, useInsertionEffect, useRef} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n *\n * @beta\n *\n * Subscribes an event handler to events in your application’s document store, such as document\n * creation, deletion, and updates.\n *\n * @category Documents\n * @param handler - The event handler to register.\n * @param doc - The document to subscribe to events for. If you pass a `DocumentHandle` with a `resourceId` (in the format of `document:projectId.dataset:documentId`)\n * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.\n * @example\n * ```\n * import {useDocumentEvent} from '@sanity/sdk-react'\n * import {type DocumentEvent} from '@sanity/sdk'\n *\n * useDocumentEvent((event) => {\n * if (event.type === DocumentEvent.DocumentDeletedEvent) {\n * alert(`Document with ID ${event.documentId} deleted!`)\n * } else {\n * console.log(event)\n * }\n * })\n * ```\n */\nexport function useDocumentEvent(\n handler: (documentEvent: DocumentEvent) => void,\n doc: DocumentHandle,\n): void {\n const ref = useRef(handler)\n\n useInsertionEffect(() => {\n ref.current = handler\n })\n\n const stableHandler = useCallback((documentEvent: DocumentEvent) => {\n return ref.current(documentEvent)\n }, [])\n\n const instance = useSanityInstance(getResourceId(doc.resourceId))\n useEffect(() => {\n return subscribeDocumentEvents(instance, stableHandler)\n }, [instance, stableHandler])\n}\n","import {\n type DocumentAction,\n type DocumentPermissionsResult,\n getPermissionsState,\n getResourceId,\n} from '@sanity/sdk'\nimport {useCallback, useMemo, useSyncExternalStore} from 'react'\nimport {filter, firstValueFrom} from 'rxjs'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n *\n * @beta\n *\n * Check if the current user has the specified permissions for the given document actions.\n *\n * @category Permissions\n * @param actions - One more more calls to a particular document action function for a given document\n * @returns An object that specifies whether the action is allowed; if the action is not allowed, an explanatory message and list of reasons is also provided.\n *\n * @example Checking for permission to publish a document\n * ```ts\n * import {useDocumentPermissions, useApplyDocumentActions} from '@sanity/sdk-react'\n * import {publishDocument} from '@sanity/sdk'\n *\n * export function PublishButton({doc}: {doc: DocumentHandle}) {\n * const publishPermissions = useDocumentPermissions(publishDocument(doc))\n * const applyAction = useApplyDocumentActions()\n *\n * return (\n * <>\n * <button\n * disabled={!publishPermissions.allowed}\n * onClick={() => applyAction(publishDocument(doc))}\n * popoverTarget={`${publishPermissions.allowed ? undefined : 'publishButtonPopover'}`}\n * >\n * Publish\n * </button>\n * {!publishPermissions.allowed && (\n * <div popover id=\"publishButtonPopover\">\n * {publishPermissions.message}\n * </div>\n * )}\n * </>\n * )\n * }\n * ```\n */\nexport function useDocumentPermissions(\n actions: DocumentAction | DocumentAction[],\n): DocumentPermissionsResult {\n // if actions is an array, we need to check each action to see if the resourceId is the same\n if (Array.isArray(actions)) {\n const resourceIds = actions.map((action) => action.resourceId)\n const uniqueResourceIds = new Set(resourceIds)\n if (uniqueResourceIds.size !== 1) {\n throw new Error('All actions must have the same resourceId')\n }\n }\n const resourceId = Array.isArray(actions)\n ? getResourceId(actions[0].resourceId)\n : getResourceId(actions.resourceId)\n\n const instance = useSanityInstance(resourceId)\n const isDocumentReady = useCallback(\n () => getPermissionsState(instance, actions).getCurrent() !== undefined,\n [actions, instance],\n )\n if (!isDocumentReady()) {\n throw firstValueFrom(\n getPermissionsState(instance, actions).observable.pipe(\n filter((result) => result !== undefined),\n ),\n )\n }\n\n const {subscribe, getCurrent} = useMemo(\n () => getPermissionsState(instance, actions),\n [actions, instance],\n )\n\n return useSyncExternalStore(subscribe, getCurrent) as DocumentPermissionsResult\n}\n","import {type DocumentHandle, getDocumentSyncStatus} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\ntype UseDocumentSyncStatus = {\n /**\n * Exposes the document’s sync status between local and remote document states.\n *\n * @category Documents\n * @param doc - The document handle to get sync status for. If you pass a `DocumentHandle` with a `resourceId` (in the format of `document:projectId.dataset:documentId`)\n * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.\n * @returns `true` if local changes are synced with remote, `false` if the changes are not synced, and `undefined` if the document is not found\n * @example Disable a Save button when there are no changes to sync\n * ```\n * const myDocumentHandle = { _id: 'documentId', _type: 'documentType', resourceId: 'document:projectId:dataset:documentId' }\n * const documentSynced = useDocumentSyncStatus(myDocumentHandle)\n *\n * return (\n * <button disabled={documentSynced}>\n * Save Changes\n * </button>\n * )\n * ```\n */\n (doc: DocumentHandle): boolean | undefined\n}\n\n/**\n * @beta\n * @function\n */\nexport const useDocumentSyncStatus: UseDocumentSyncStatus =\n createStateSourceHook(getDocumentSyncStatus)\n","import {\n type ActionsResult,\n type DocumentHandle,\n editDocument,\n getDocumentState,\n getResourceId,\n type JsonMatch,\n type JsonMatchPath,\n resolveDocument,\n} from '@sanity/sdk'\nimport {type SanityDocument} from '@sanity/types'\nimport {useCallback} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\nimport {useApplyDocumentActions} from './useApplyDocumentActions'\n\nconst ignoredKeys = ['_id', '_type', '_createdAt', '_updatedAt', '_rev']\n\ntype Updater<TValue> = TValue | ((nextValue: TValue) => TValue)\n\n/**\n *\n * @beta\n *\n * ## useEditDocument(doc, path)\n * Edit a nested value within a document\n *\n * @category Documents\n * @param doc - The document to be edited; either as a document handle or the document’s ID a string\n * @param path - The path to the nested value to be edited\n * @returns A function to update the nested value. Accepts either a new value, or an updater function that exposes the previous value and returns a new value.\n * @example Update a document’s name by providing the new value directly\n * ```\n * const handle = { _id: 'documentId', _type: 'documentType' }\n * const name = useDocument(handle, 'name')\n * const editName = useEditDocument(handle, 'name')\n *\n * function handleNameChange(event: React.ChangeEvent<HTMLInputElement>) {\n * editName(event.target.value)\n * }\n *\n * return (\n * <input type='text' value={name} onChange={handleNameChange} />\n * )\n * ```\n *\n * @example Update a count on a document by providing an updater function\n * ```\n * const handle = { _id: 'documentId', _type: 'documentType' }\n * const count = useDocument(handle, 'count')\n * const editCount = useEditDocument(handle, 'count')\n *\n * function incrementCount() {\n * editCount(previousCount => previousCount + 1)\n * }\n *\n * return (\n * <>\n * <button onClick={incrementCount}>\n * Increment\n * </button>\n * Current count: {count}\n * </>\n * )\n * ```\n */\nexport function useEditDocument<\n TDocument extends SanityDocument,\n TPath extends JsonMatchPath<TDocument>,\n>(\n doc: DocumentHandle<TDocument>,\n path: TPath,\n): (nextValue: Updater<JsonMatch<TDocument, TPath>>) => Promise<ActionsResult<TDocument>>\n\n/**\n *\n * @beta\n *\n * ## useEditDocument(doc)\n * Edit an entire document\n * @param doc - The document to be edited; either as a document handle or the document’s ID a string. If you pass a `DocumentHandle` with a `resourceId` (in the format of `document:projectId.dataset:documentId`)\n * the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.\n * @returns A function to update the document state. Accepts either a new document state, or an updater function that exposes the previous document state and returns the new document state.\n * @example\n * ```\n * const myDocumentHandle = { _id: 'documentId', _type: 'documentType' }\n *\n * const myDocument = useDocument(myDocumentHandle)\n * const { title, price } = myDocument\n *\n * const editMyDocument = useEditDocument(myDocumentHandle)\n *\n * function handleFieldChange(e: React.ChangeEvent<HTMLInputElement>) {\n * const {name, value} = e.currentTarget\n * // Use an updater function to update the document state based on the previous state\n * editMyDocument(previousDocument => ({\n * ...previousDocument,\n * [name]: value\n * }))\n * }\n *\n * function handleSaleChange(e: React.ChangeEvent<HTMLInputElement>) {\n * const { checked } = e.currentTarget\n * if (checked) {\n * // Use an updater function to add a new salePrice field;\n * // set it at a 20% discount off the normal price\n * editMyDocument(previousDocument => ({\n * ...previousDocument,\n * salePrice: previousDocument.price * 0.8,\n * }))\n * } else {\n * // Get the document state without the salePrice field\n * const { salePrice, ...rest } = myDocument\n * // Update the document state to remove the salePrice field\n * editMyDocument(rest)\n * }\n * }\n *\n * return (\n * <>\n * <form onSubmit={e => e.preventDefault()}>\n * <input name='title' type='text' value={title} onChange={handleFieldChange} />\n * <input name='price' type='number' value={price} onChange={handleFieldChange} />\n * <input\n * name='salePrice'\n * type='checkbox'\n * checked={Object(myDocument).hasOwnProperty('salePrice')}\n * onChange={handleSaleChange}\n * />\n * </form>\n * <pre><code>\n * {JSON.stringify(myDocument, null, 2)}\n * </code></pre>\n * </>\n * )\n * ```\n */\nexport function useEditDocument<TDocument extends SanityDocument>(\n doc: DocumentHandle<TDocument>,\n): (nextValue: Updater<TDocument>) => Promise<ActionsResult<TDocument>>\n\n/**\n *\n * @beta\n *\n * Enables editing of a document’s state.\n * When called with a `path` argument, the hook will return a function for updating a nested value.\n * When called without a `path` argument, the hook will return a function for updating the entire document.\n */\nexport function useEditDocument(\n doc: DocumentHandle,\n path?: string,\n): (updater: Updater<unknown>) => Promise<ActionsResult> {\n const resourceId = getResourceId(doc.resourceId)!\n const documentId = doc._id\n const instance = useSanityInstance(resourceId)\n const apply = useApplyDocumentActions(resourceId)\n const isDocumentReady = useCallback(\n () => getDocumentState(instance, documentId).getCurrent() !== undefined,\n [instance, documentId],\n )\n if (!isDocumentReady()) throw resolveDocument(instance, documentId)\n\n return (updater: Updater<unknown>) => {\n if (path) {\n const nextValue =\n typeof updater === 'function'\n ? updater(getDocumentState(instance, documentId, path).getCurrent())\n : updater\n\n return apply(editDocument(doc, {set: {[path]: nextValue}}))\n }\n\n const current = getDocumentState(instance, documentId).getCurrent()\n const nextValue = typeof updater === 'function' ? updater(current) : updater\n\n if (typeof nextValue !== 'object' || !nextValue) {\n throw new Error(\n `No path was provided to \\`useEditDocument\\` and the value provided was not a document object.`,\n )\n }\n\n const allKeys = Object.keys({...current, ...nextValue})\n const editActions = allKeys\n .filter((key) => !ignoredKeys.includes(key))\n .filter((key) => current?.[key] !== nextValue[key])\n .map((key) =>\n key in nextValue\n ? editDocument(doc, {set: {[key]: nextValue[key]}})\n : editDocument(doc, {unset: [key]}),\n )\n\n return apply(editActions)\n }\n}\n","import {\n getQueryKey,\n getQueryState,\n parseQueryKey,\n type QueryOptions,\n resolveQuery,\n} from '@sanity/sdk'\nimport {useEffect, useMemo, useState, useSyncExternalStore, useTransition} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * Executes GROQ queries against a Sanity dataset.\n *\n * This hook provides a convenient way to fetch and subscribe to real-time updates\n * for your Sanity content. Changes made to the dataset’s content will trigger\n * automatic updates.\n *\n * @remarks\n * The returned `isPending` flag indicates when a React transition is in progress,\n * which can be used to show loading states for query changes.\n *\n * @beta\n * @category GROQ\n * @param query - GROQ query string to execute\n * @param options - Optional configuration for the query\n * @returns Object containing the query result and a pending state flag\n *\n * @example Basic usage\n * ```tsx\n * const {data, isPending} = useQuery<Movie[]>('*[_type == \"movie\"]')\n * ```\n *\n * @example Using parameters\n * ```tsx\n * // With parameters\n * const {data} = useQuery<Movie>('*[_type == \"movie\" && _id == $id][0]', {\n * params: { id: 'movie-123' }\n * })\n * ```\n *\n * @example With a loading state for transitions\n * ```tsx\n * const {data, isPending} = useQuery<Movie[]>('*[_type == \"movie\"]')\n * return (\n * <div>\n * {isPending && <div>Updating...</div>}\n * <ul>\n * {data.map(movie => <li key={movie._id}>{movie.title}</li>)}\n * </ul>\n * </div>\n * )\n * ```\n *\n */\nexport function useQuery<T>(query: string, options?: QueryOptions): {data: T; isPending: boolean} {\n const instance = useSanityInstance(options?.resourceId)\n // Use React's useTransition to avoid UI jank when queries change\n const [isPending, startTransition] = useTransition()\n\n // Get the unique key for this query and its options\n const queryKey = getQueryKey(query, options)\n // Use a deferred state to avoid immediate re-renders when the query changes\n const [deferredQueryKey, setDeferredQueryKey] = useState(queryKey)\n // Parse the deferred query key back into a query and options\n const deferred = useMemo(() => parseQueryKey(deferredQueryKey), [deferredQueryKey])\n\n // Create an AbortController to cancel in-flight requests when needed\n const [ref, setRef] = useState<AbortController>(new AbortController())\n\n // When the query or options change, start a transition to update the query\n useEffect(() => {\n if (queryKey === deferredQueryKey) return\n\n startTransition(() => {\n // Abort any in-flight requests for the previous query\n if (ref && !ref.signal.aborted) {\n ref.abort()\n setRef(new AbortController())\n }\n\n setDeferredQueryKey(queryKey)\n })\n }, [deferredQueryKey, queryKey, ref])\n\n // Get the state source for this query from the query store\n const {getCurrent, subscribe} = useMemo(\n () => getQueryState(instance, deferred.query, deferred.options),\n [instance, deferred],\n )\n\n // If data isn't available yet, suspend rendering until it is\n // This is the React Suspense integration - throwing a promise\n // will cause React to show the nearest Suspense fallback\n if (getCurrent() === undefined) {\n throw resolveQuery(instance, deferred.query, {...deferred.options, signal: ref.signal})\n }\n\n // Subscribe to updates and get the current data\n // useSyncExternalStore ensures the component re-renders when the data changes\n const data = useSyncExternalStore(subscribe, getCurrent) as T\n return {data, isPending}\n}\n","import {type DocumentHandle, type QueryOptions} from '@sanity/sdk'\nimport {type SortOrderingItem} from '@sanity/types'\nimport {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {useQuery} from '../query/useQuery'\n\nconst DEFAULT_BATCH_SIZE = 25\nconst DEFAULT_PERSPECTIVE = 'drafts'\n\n/**\n * Result structure returned from the infinite list query\n * @internal\n */\ninterface UseDocumentsQueryResult {\n count: number\n data: DocumentHandle[]\n}\n\n/**\n * Configuration options for the useDocuments hook\n *\n * @beta\n * @category Types\n */\nexport interface DocumentsOptions extends QueryOptions {\n /**\n * GROQ filter expression to apply to the query\n */\n filter?: string\n /**\n * Number of items to load per batch (defaults to 25)\n */\n batchSize?: number\n /**\n * Sorting configuration for the results\n */\n orderings?: SortOrderingItem[]\n /**\n * Text search query to filter results\n */\n search?: string\n}\n\n/**\n * Return value from the useDocuments hook\n *\n * @beta\n * @category Types\n */\nexport interface DocumentsResponse {\n /**\n * Array of document handles for the current batch\n */\n data: DocumentHandle[]\n /**\n * Whether there are more items available to load\n */\n hasMore: boolean\n /**\n * Total count of items matching the query\n */\n count: number\n /**\n * Whether a query is currently in progress\n */\n isPending: boolean\n /**\n * Function to load the next batch of results\n */\n loadMore: () => void\n}\n\n/**\n * Retrieves batches of {@link DocumentHandle}s, narrowed by optional filters, text searches, and custom ordering,\n * with infinite scrolling support. The number of document handles returned per batch is customizable,\n * and additional batches can be loaded using the supplied `loadMore` function.\n *\n * @beta\n * @category Documents\n * @param options - Configuration options for the infinite list\n * @returns An object containing the list of document handles, the loading state, the total count of retrieved document handles, and a function to load more\n * @example\n * ```tsx\n * const {data, hasMore, isPending, loadMore} = useDocuments({\n * filter: '_type == \"post\"',\n * search: searchTerm,\n * batchSize: 10,\n * orderings: [{field: '_createdAt', direction: 'desc'}]\n * })\n *\n * return (\n * <div>\n * Total documents: {count}\n * <ol>\n * {data.map((doc) => (\n * <li key={doc._id}>\n * <MyDocumentComponent doc={doc} />\n * </li>\n * ))}\n * </ol>\n * {hasMore && <button onClick={loadMore}>Load More</button>}\n * </div>\n * )\n * ```\n *\n */\nexport function useDocuments({\n batchSize = DEFAULT_BATCH_SIZE,\n params,\n search,\n filter,\n orderings,\n ...options\n}: DocumentsOptions): DocumentsResponse {\n const perspective = options.perspective ?? DEFAULT_PERSPECTIVE\n const [limit, setLimit] = useState(batchSize)\n\n // Reset the limit to the current batchSize whenever any query parameters\n // (filter, search, params, orderings) or batchSize changes\n const key = JSON.stringify({filter, search, params, orderings, batchSize})\n useEffect(() => {\n setLimit(batchSize)\n }, [key, batchSize])\n\n const filterClause = useMemo(() => {\n const conditions: string[] = []\n\n // Add search query if specified\n if (search?.trim()) {\n conditions.push(`[@] match text::query(\"${search.trim()}\")`)\n }\n\n // Add additional filter if specified\n if (filter) {\n conditions.push(`(${filter})`)\n }\n\n return conditions.length ? `[${conditions.join(' && ')}]` : ''\n }, [filter, search])\n\n const orderClause = orderings\n ? `| order(${orderings\n .map((ordering) =>\n [ordering.field, ordering.direction.toLowerCase()]\n .map((str) => str.trim())\n .filter(Boolean)\n .join(' '),\n )\n .join(',')})`\n : ''\n\n const dataQuery = `*${filterClause}${orderClause}[0...${limit}]{_id,_type}`\n const countQuery = `count(*${filterClause})`\n\n const {\n data: {count, data},\n isPending,\n } = useQuery<UseDocumentsQueryResult>(`{\"count\":${countQuery},\"data\":${dataQuery}}`, {\n ...options,\n params,\n perspective,\n })\n\n const hasMore = data.length < count\n\n const loadMore = useCallback(() => {\n setLimit((prev) => Math.min(prev + batchSize, count))\n }, [count, batchSize])\n\n return useMemo(\n () => ({data, hasMore, count, isPending, loadMore}),\n [data, hasMore, count, isPending, loadMore],\n )\n}\n","import {type DocumentHandle, type QueryOptions} from '@sanity/sdk'\nimport {type SortOrderingItem} from '@sanity/types'\nimport {useCallback, useEffect, useMemo, useState} from 'react'\n\nimport {useQuery} from '../query/useQuery'\n\nconst DEFAULT_PERSPECTIVE = 'drafts'\n\n/**\n * Configuration options for the usePaginatedDocuments hook\n *\n * @beta\n * @category Types\n */\nexport interface PaginatedDocumentsOptions extends QueryOptions {\n /**\n * GROQ filter expression to apply to the query\n */\n filter?: string\n /**\n * Number of items to display per page (defaults to 25)\n */\n pageSize?: number\n /**\n * Sorting configuration for the results\n */\n orderings?: SortOrderingItem[]\n /**\n * Text search query to filter results\n */\n search?: string\n}\n\n/**\n * Return value from the usePaginatedDocuments hook\n *\n * @beta\n * @category Types\n */\nexport interface PaginatedDocumentsResponse {\n /**\n * Array of document handles for the current page\n */\n data: DocumentHandle[]\n /**\n * Whether a query is currently in progress\n */\n isPending: boolean\n\n /**\n * Number of items displayed per page\n */\n pageSize: number\n /**\n * Current page number (1-indexed)\n */\n currentPage: number\n /**\n * Total number of pages available\n */\n totalPages: number\n\n /**\n * Starting index of the current page (0-indexed)\n */\n startIndex: number\n /**\n * Ending index of the current page (exclusive, 0-indexed)\n */\n endIndex: number\n /**\n * Total count of items matching the query\n */\n count: number\n\n /**\n * Navigate to the first page\n */\n firstPage: () => void\n /**\n * Whether there is a first page available to navigate to\n */\n hasFirstPage: boolean\n\n /**\n * Navigate to the previous page\n */\n previousPage: () => void\n /**\n * Whether there is a previous page available to navigate to\n */\n hasPreviousPage: boolean\n\n /**\n * Navigate to the next page\n */\n nextPage: () => void\n /**\n * Whether there is a next page available to navigate to\n */\n hasNextPage: boolean\n\n /**\n * Navigate to the last page\n */\n lastPage: () => void\n /**\n * Whether there is a last page available to navigate to\n */\n hasLastPage: boolean\n\n /**\n * Navigate to a specific page number\n * @param pageNumber - The page number to navigate to (1-indexed)\n */\n goToPage: (pageNumber: number) => void\n}\n\n/**\n * Retrieves pages of {@link DocumentHandle}s, narrowed by optional filters, text searches, and custom ordering,\n * with support for traditional paginated interfaces. The number of document handles returned per page is customizable,\n * while page navigation is handled via the included navigation functions.\n *\n * @beta\n * @category Documents\n * @param options - Configuration options for the paginated list\n * @returns An object containing the current page of document handles, the loading and pagination state, and navigation functions\n * @example\n * ```tsx\n * const {\n * data,\n * isPending,\n * currentPage,\n * totalPages,\n * nextPage,\n * previousPage,\n * hasNextPage,\n * hasPreviousPage\n * } = usePaginatedDocuments({\n * filter: '_type == \"post\"',\n * search: searchTerm,\n * pageSize: 10,\n * orderings: [{field: '_createdAt', direction: 'desc'}]\n * })\n *\n * return (\n * <>\n * <table>\n * {data.map(doc => (\n * <MyTableRowComponent key={doc._id} doc={doc} />\n * ))}\n * </table>\n * <>\n * {hasPreviousPage && <button onClick={previousPage}>Previous</button>}\n * {currentPage} / {totalPages}\n * {hasNextPage && <button onClick={nextPage}>Next</button>}\n * </>\n * </>\n * )\n * ```\n *\n */\nexport function usePaginatedDocuments({\n filter = '',\n pageSize = 25,\n params = {},\n orderings,\n search,\n ...options\n}: PaginatedDocumentsOptions = {}): PaginatedDocumentsResponse {\n const [pageIndex, setPageIndex] = useState(0)\n const key = JSON.stringify({filter, search, params, orderings, pageSize})\n // Reset the pageIndex to 0 whenever any query parameters (filter, search,\n // params, orderings) or pageSize changes\n useEffect(() => {\n setPageIndex(0)\n }, [key])\n\n const startIndex = pageIndex * pageSize\n const endIndex = (pageIndex + 1) * pageSize\n const perspective = options.perspective ?? DEFAULT_PERSPECTIVE\n\n const filterClause = useMemo(() => {\n const conditions: string[] = []\n\n // Add search query if specified\n if (search?.trim()) {\n conditions.push(`[@] match text::query(\"${search.trim()}\")`)\n }\n\n // Add additional filter if specified\n if (filter) {\n conditions.push(`(${filter})`)\n }\n\n return conditions.length ? `[${conditions.join(' && ')}]` : ''\n }, [filter, search])\n\n const orderClause = orderings\n ? `| order(${orderings\n .map((ordering) =>\n [ordering.field, ordering.direction.toLowerCase()]\n .map((str) => str.trim())\n .filter(Boolean)\n .join(' '),\n )\n .join(',')})`\n : ''\n\n const dataQuery = `*${filterClause}${orderClause}[${startIndex}...${endIndex}]{_id,_type}`\n const countQuery = `count(*${filterClause})`\n\n const {\n data: {data, count},\n isPending,\n } = useQuery<{data: DocumentHandle[]; count: number}>(\n `{\"data\":${dataQuery},\"count\":${countQuery}}`,\n {\n ...options,\n perspective,\n params,\n },\n )\n\n const totalPages = Math.ceil(count / pageSize)\n const currentPage = pageIndex + 1\n\n // Navigation methods\n const firstPage = useCallback(() => setPageIndex(0), [])\n const previousPage = useCallback(() => setPageIndex((prev) => Math.max(prev - 1, 0)), [])\n const nextPage = useCallback(\n () => setPageIndex((prev) => Math.min(prev + 1, totalPages - 1)),\n [totalPages],\n )\n const lastPage = useCallback(() => setPageIndex(totalPages - 1), [totalPages])\n const goToPage = useCallback(\n (pageNumber: number) => {\n if (pageNumber < 1 || pageNumber > totalPages) return\n setPageIndex(pageNumber - 1)\n },\n [totalPages],\n )\n\n // Boolean flags for page availability\n const hasFirstPage = pageIndex > 0\n const hasPreviousPage = pageIndex > 0\n const hasNextPage = pageIndex < totalPages - 1\n const hasLastPage = pageIndex < totalPages - 1\n\n return useMemo(\n () => ({\n data,\n isPending,\n pageSize,\n currentPage,\n totalPages,\n startIndex,\n endIndex,\n count,\n firstPage,\n hasFirstPage,\n previousPage,\n hasPreviousPage,\n nextPage,\n hasNextPage,\n lastPage,\n hasLastPage,\n goToPage,\n }),\n [\n data,\n isPending,\n pageSize,\n currentPage,\n totalPages,\n startIndex,\n endIndex,\n count,\n firstPage,\n hasFirstPage,\n previousPage,\n hasPreviousPage,\n nextPage,\n hasNextPage,\n lastPage,\n hasLastPage,\n goToPage,\n ],\n )\n}\n","import {type DocumentHandle, getPreviewState, type PreviewValue, resolvePreview} from '@sanity/sdk'\nimport {useCallback, useMemo, useSyncExternalStore} from 'react'\nimport {distinctUntilChanged, EMPTY, Observable, startWith, switchMap} from 'rxjs'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @beta\n * @category Types\n */\nexport interface UsePreviewOptions {\n document: DocumentHandle\n ref?: React.RefObject<unknown>\n}\n\n/**\n * @beta\n * @category Types\n */\nexport interface UsePreviewResults {\n /** The results of resolving the document’s preview values */\n data: PreviewValue\n /** True when preview values are being refreshed */\n isPending: boolean\n}\n\n/**\n * @beta\n *\n * Returns the preview values of a document (specified via a `DocumentHandle`),\n * including the document’s `title`, `subtitle`, `media`, and `status`. These values are live and will update in realtime.\n * To reduce unnecessary network requests for resolving the preview values, an optional `ref` can be passed to the hook so that preview\n * resolution will only occur if the `ref` is intersecting the current viewport.\n *\n * @category Documents\n * @param options - The document handle for the document you want to resolve preview values for, and an optional ref\n * @returns The preview values for the given document and a boolean to indicate whether the resolution is pending\n *\n * @example Combining with useDocuments to render a collection of document previews\n * ```\n * // PreviewComponent.jsx\n * export default function PreviewComponent({ document }) {\n * const { data: { title, subtitle, media }, isPending } = usePreview({ document })\n * return (\n * <article style={{ opacity: isPending ? 0.5 : 1}}>\n * {media?.type === 'image-asset' ? <img src={media.url} alt='' /> : ''}\n * <h2>{title}</h2>\n * <p>{subtitle}</p>\n * </article>\n * )\n * }\n *\n * // DocumentList.jsx\n * const { data } = useDocuments({ filter: '_type == \"movie\"' })\n * return (\n * <div>\n * <h1>Movies</h1>\n * <ul>\n * {data.map(movie => (\n * <li key={movie._id}>\n * <Suspense fallback='Loading…'>\n * <PreviewComponent document={movie} />\n * </Suspense>\n * </li>\n * ))}\n * </ul>\n * </div>\n * )\n * ```\n */\nexport function usePreview({document: {_id, _type}, ref}: UsePreviewOptions): UsePreviewResults {\n const instance = useSanityInstance()\n\n const stateSource = useMemo(\n () => getPreviewState(instance, {document: {_id, _type}}),\n [instance, _id, _type],\n )\n\n // Create subscribe function for useSyncExternalStore\n const subscribe = useCallback(\n (onStoreChanged: () => void) => {\n const subscription = new Observable<boolean>((observer) => {\n // for environments that don't have an intersection observer\n if (typeof IntersectionObserver === 'undefined' || typeof HTMLElement === 'undefined') {\n return\n }\n\n const intersectionObserver = new IntersectionObserver(\n ([entry]) => observer.next(entry.isIntersecting),\n {rootMargin: '0px', threshold: 0},\n )\n if (ref?.current && ref.current instanceof HTMLElement) {\n intersectionObserver.observe(ref.current)\n }\n return () => intersectionObserver.disconnect()\n })\n .pipe(\n startWith(false),\n distinctUntilChanged(),\n switchMap((isVisible) =>\n isVisible\n ? new Observable<void>((obs) => {\n return stateSource.subscribe(() => obs.next())\n })\n : EMPTY,\n ),\n )\n .subscribe({next: onStoreChanged})\n\n return () => subscription.unsubscribe()\n },\n [stateSource, ref],\n )\n\n // Create getSnapshot function to return current state\n const getSnapshot = useCallback(() => {\n const currentState = stateSource.getCurrent()\n if (currentState.data === null) throw resolvePreview(instance, {document: {_id, _type}})\n return currentState as UsePreviewResults\n }, [_id, _type, instance, stateSource])\n\n return useSyncExternalStore(subscribe, getSnapshot)\n}\n","import {\n type DocumentHandle,\n getProjectionState,\n resolveProjection,\n type ValidProjection,\n} from '@sanity/sdk'\nimport {useCallback, useMemo, useSyncExternalStore} from 'react'\nimport {distinctUntilChanged, EMPTY, Observable, startWith, switchMap} from 'rxjs'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @public\n * @category Types\n */\nexport interface UseProjectionOptions {\n document: DocumentHandle\n projection: ValidProjection\n ref?: React.RefObject<unknown>\n}\n\n/**\n * @public\n * @category Types\n */\nexport interface UseProjectionResults<TResult extends object> {\n data: TResult\n isPending: boolean\n}\n\n/**\n * @beta\n *\n * Returns the projection values of a document (specified via a `DocumentHandle`),\n * based on the provided projection string. These values are live and will update in realtime.\n * To reduce unnecessary network requests for resolving the projection values, an optional `ref` can be passed to the hook so that projection\n * resolution will only occur if the `ref` is intersecting the current viewport.\n *\n * @category Documents\n * @param options - The document handle for the document you want to project values from, the projection string, and an optional ref\n * @returns The projection values for the given document and a boolean to indicate whether the resolution is pending\n *\n * @example Using a projection to render a preview of document\n * ```\n * // ProjectionComponent.jsx\n * export default function ProjectionComponent({ document }) {\n * const ref = useRef(null)\n * const { results: { title, coverImage, authors }, isPending } = useProjection({\n * document,\n * ref,\n * projection: `{\n * title,\n * 'coverImage': cover.asset->url,\n * 'authors': array::join(authors[]->{'name': firstName + ' ' + lastName + ' '}.name, ', ')\n * }`,\n * })\n *\n * return (\n * <article ref={ref} style={{ opacity: isPending ? 0.5 : 1}}>\n * <h2>{title}</h2>\n * <img src={coverImage} alt={title} />\n * <p>{authors}</p>\n * </article>\n * )\n * }\n * ```\n *\n * @example Combining with useDocuments to render a collection with specific fields\n * ```\n * // DocumentList.jsx\n * const { data } = useDocuments({ filter: '_type == \"article\"' })\n * return (\n * <div>\n * <h1>Books</h1>\n * <ul>\n * {data.map(book => (\n * <li key={book._id}>\n * <Suspense fallback='Loading…'>\n * <ProjectionComponent\n * document={book}\n * />\n * </Suspense>\n * </li>\n * ))}\n * </ul>\n * </div>\n * )\n * ```\n */\nexport function useProjection<TResult extends object>({\n document: {_id, _type},\n projection,\n ref,\n}: UseProjectionOptions): UseProjectionResults<TResult> {\n const instance = useSanityInstance()\n\n const stateSource = useMemo(\n () => getProjectionState<TResult>(instance, {document: {_id, _type}, projection}),\n [instance, _id, _type, projection],\n )\n\n // Create subscribe function for useSyncExternalStore\n const subscribe = useCallback(\n (onStoreChanged: () => void) => {\n const subscription = new Observable<boolean>((observer) => {\n // for environments that don't have an intersection observer\n if (typeof IntersectionObserver === 'undefined' || typeof HTMLElement === 'undefined') {\n return\n }\n\n const intersectionObserver = new IntersectionObserver(\n ([entry]) => observer.next(entry.isIntersecting),\n {rootMargin: '0px', threshold: 0},\n )\n if (ref?.current && ref.current instanceof HTMLElement) {\n intersectionObserver.observe(ref.current)\n }\n return () => intersectionObserver.disconnect()\n })\n .pipe(\n startWith(false),\n distinctUntilChanged(),\n switchMap((isVisible) =>\n isVisible\n ? new Observable<void>((obs) => {\n return stateSource.subscribe(() => obs.next())\n })\n : EMPTY,\n ),\n )\n .subscribe({next: onStoreChanged})\n\n return () => subscription.unsubscribe()\n },\n [stateSource, ref],\n )\n\n // Create getSnapshot function to return current state\n const getSnapshot = useCallback(() => {\n const currentState = stateSource.getCurrent()\n if (currentState.data === null)\n throw resolveProjection(instance, {document: {_id, _type}, projection})\n return currentState as UseProjectionResults<TResult>\n }, [_id, _type, projection, instance, stateSource])\n\n return useSyncExternalStore(subscribe, getSnapshot)\n}\n","import {\n getProjectState,\n resolveProject,\n type SanityInstance,\n type SanityProject,\n type StateSource,\n} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\ntype UseProject = {\n /**\n *\n * Returns metadata for a given project\n *\n * @category Projects\n * @param projectId - The ID of the project to retrieve metadata for\n * @returns The metadata for the project\n * @example\n * ```tsx\n * function ProjectMetadata({ projectId }: { projectId: string }) {\n * const project = useProject(projectId)\n *\n * return (\n * <figure style={{ backgroundColor: project.metadata.color || 'lavender'}}>\n * <h1>{project.displayName}</h1>\n * </figure>\n * )\n * }\n * ```\n */\n (projectId: string): SanityProject\n}\n\n/**\n * @public\n * @function\n */\nexport const useProject: UseProject = createStateSourceHook({\n // remove `undefined` since we're suspending when that is the case\n getState: getProjectState as (\n instance: SanityInstance,\n projectId: string,\n ) => StateSource<SanityProject>,\n shouldSuspend: (instance, projectId) =>\n getProjectState(instance, projectId).getCurrent() === undefined,\n suspender: resolveProject,\n})\n","import {type SanityProject} from '@sanity/client'\nimport {getProjectsState, resolveProjects, type SanityInstance, type StateSource} from '@sanity/sdk'\n\nimport {createStateSourceHook} from '../helpers/createStateSourceHook'\n\n/**\n * @public\n * @category Types\n * @interface\n */\nexport type ProjectWithoutMembers = Omit<SanityProject, 'members'>\n\ntype UseProjects = {\n /**\n *\n * Returns metadata for each project you have access to.\n *\n * @category Projects\n * @returns An array of metadata (minus the projects’ members) for each project\n * @example\n * ```tsx\n * const projects = useProjects()\n *\n * return (\n * <select>\n * {projects.map((project) => (\n * <option key={project.id}>{project.displayName}</option>\n * ))}\n * </select>\n * )\n * ```\n */\n (): ProjectWithoutMembers[]\n}\n\n/**\n * @public\n * @function\n */\nexport const useProjects: UseProjects = createStateSourceHook({\n // remove `undefined` since we're suspending when that is the case\n getState: getProjectsState as (instance: SanityInstance) => StateSource<ProjectWithoutMembers[]>,\n shouldSuspend: (instance) => getProjectsState(instance).getCurrent() === undefined,\n suspender: resolveProjects,\n})\n","import {createUsersStore, type ResourceType, type SanityUser} from '@sanity/sdk'\nimport {useCallback, useEffect, useState, useSyncExternalStore} from 'react'\n\nimport {useSanityInstance} from '../context/useSanityInstance'\n\n/**\n * @public\n * @category Types\n */\nexport interface UseUsersParams {\n /**\n * The type of resource to fetch users for.\n */\n resourceType: ResourceType\n /**\n * The ID of the resource to fetch users for.\n */\n resourceId: string\n /**\n * The limit of users to fetch.\n */\n limit?: number\n}\n\n/**\n * @public\n * @category Types\n */\nexport interface UseUsersResult {\n /**\n * The users fetched.\n */\n users: SanityUser[]\n /**\n * Whether there are more users to fetch.\n */\n hasMore: boolean\n /**\n * Load more users.\n */\n loadMore: () => void\n}\n\n/**\n *\n * @public\n *\n * Retrieves the users for a given resource (either a project or an organization).\n *\n * @category Users\n * @param params - The resource type and its ID, and the limit of users to fetch\n * @returns A list of users, a boolean indicating whether there are more users to fetch, and a function to load more users\n *\n * @example\n * ```\n * const { users, hasMore, loadMore } = useUsers({\n * resourceType: 'organization',\n * resourceId: 'my-org-id',\n * limit: 10,\n * })\n *\n * return (\n * <div>\n * {users.map(user => (\n * <figure key={user.sanityUserId}>\n * <img src={user.profile.imageUrl} alt='' />\n * <figcaption>{user.profile.displayName}</figcaption>\n * <address>{user.profile.email}</address>\n * </figure>\n * ))}\n * {hasMore && <button onClick={loadMore}>Load More</button>}\n * </div>\n * )\n * ```\n */\nexport function useUsers(params: UseUsersParams): UseUsersResult {\n const instance = useSanityInstance(params.resourceId)\n const [store] = useState(() => createUsersStore(instance))\n\n useEffect(() => {\n store.setOptions({\n resourceType: params.resourceType,\n resourceId: params.resourceId,\n })\n }, [params.resourceType, params.resourceId, store])\n\n const subscribe = useCallback(\n (onStoreChanged: () => void) => {\n if (store.getState().getCurrent().initialFetchCompleted === false) {\n store.resolveUsers()\n }\n const unsubscribe = store.getState().subscribe(onStoreChanged)\n\n return () => {\n unsubscribe()\n store.dispose()\n }\n },\n [store],\n )\n\n const getSnapshot = useCallback(() => store.getState().getCurrent(), [store])\n\n const {users, hasMore} = useSyncExternalStore(subscribe, getSnapshot) || {}\n\n return {users, hasMore, loadMore: store.loadMore}\n}\n","// Local type declaration for Remix\ntype WindowWithEnv = Window &\n typeof globalThis & {\n ENV?: Record<string, unknown>\n }\n\ntype KnownEnvVar = 'DEV' | 'PKG_VERSION'\n\nexport function getEnv(key: KnownEnvVar): unknown {\n if (typeof import.meta !== 'undefined' && import.meta.env) {\n // Vite environment variables\n return (import.meta.env as unknown as Record<string, unknown>)[key]\n } else if (typeof process !== 'undefined' && process.env) {\n // Node.js or server-side environment variables\n return process.env[key]\n } else if (typeof window !== 'undefined' && (window as WindowWithEnv).ENV) {\n // Remix-style client-side environment variables\n return (window as WindowWithEnv).ENV?.[key]\n }\n return undefined\n}\n","import {version} from '../package.json'\nimport {getEnv} from './utils/getEnv'\n\n/**\n * This version is provided by pkg-utils at build time\n * @internal\n */\nexport const REACT_SDK_VERSION = getEnv('PKG_VERSION') || `${version}-development`\n"],"names":["SanityInstanceContext","createContext","useSanityInstance","resourceId","$","_c","sanityInstance","useContext","Error","length","t0","t1","inst","identity","find","instance","createStateSourceHook","options","getState","getResourceId","undefined","suspense","useHook","params","suspender","shouldSuspend","state","useSyncExternalStore","subscribe","getCurrent","useAuthState","getAuthState","isInIframe","window","self","top","isLocalUrl","url","location","href","startsWith","AuthError","constructor","error","message","cause","useLoginUrls","useMemo","getLoginUrlsState","fetchLoginUrls","LINKS","i18nKey","title","LoginFooter","Symbol","for","map","_temp","link","LoginLayout","children","footer","header","Login","t2","t3","Providers","loginUrls","createCallbackHook","callback","useHandleAuthCallback","handleAuthCallback","LoginCallback","URL","toString","then","useEffect","t4","replacementLocation","history","replaceState","useLogOut","logout","LoginError","resetErrorBoundary","handleRetry","parsedUrl","mode","URLSearchParams","hash","slice","get","script","document","createElement","src","type","async","head","appendChild","AuthBoundary","props","LoginErrorComponent","fallbackProps","FallbackComponent","t5","AuthSwitch","LoginComponent","CallbackComponent","authState","AuthStateType","ERROR","LOGGING_IN","LOGGED_IN","SanityProvider","sanityInstances","DEFAULT_FALLBACK","SDKProvider","sanityConfigs","fallback","t6","sanityConfig","createSanityInstance","CORE_URL","SanityApp","_temp2","timeout","clearTimeout","console","warn","replace","useAuthToken","getTokenState","useCurrentUser","getCurrentUserState","useDashboardOrganizationId","getDashboardOrganizationId","useClient","getClientState","e","useFrameConnection","onMessage","targetOrigin","name","connectTo","heartbeat","onStatus","controllerRef","useRef","channelRef","controller","getOrCreateController","channel","getOrCreateChannel","current","event","status","messageUnsubscribers","Object","entries","forEach","handler","unsubscribe","on","push","releaseChannel","frameWindow","removeTarget","addTarget","connect","type_0","data","post","sendMessage","unsub","useWindowConnection","nodeRef","node","getOrCreateNode","statusUnsubscribe","eventStatus","messageUnsubscribe","releaseNode","type_1","data_0","fetchOptions","fetch","useManageFavorite","documentId","documentType","resourceType","isFavorited","setIsFavorited","useState","setStatus","SDK_NODE_NAME","SDK_CHANNEL_NAME","action","setFavoriteState","eventType","response","success","err","handleFavoriteAction","favorite","unfavorite","isConnected","useRecordDocumentHistoryEvent","recordEvent","useStudioWorkspacesByResourceId","workspacesByResourceId","setWorkspacesByResourceId","setError","fetchWorkspaces","signal","workspaceMap","context","availableResources","resource","projectId","workspaces","workspace","key","dataset","AbortController","abort","useNavigateToStudioDocument","documentHandle","workspacesConnected","projectAndDataset","split","_ref","path","_id","_type","navigateToStudioDocument","useDatasets","getDatasetsState","resolveDatasets","useApplyDocumentActions","_useApplyDocumentActions","applyDocumentActions","useDocument","doc","_useDocument","getDocumentState","resolveDocument","useDocumentEvent","ref","useInsertionEffect","documentEvent","stableHandler","subscribeDocumentEvents","useDocumentPermissions","actions","Array","isArray","resourceIds","Set","size","getPermissionsState","firstValueFrom","observable","pipe","filter","result","useDocumentSyncStatus","getDocumentSyncStatus","ignoredKeys","useEditDocument","apply","updater","nextValue","editDocument","set","nextValue_0","editActions","keys","key_0","key_1","unset","includes","useQuery","query","isPending","startTransition","useTransition","queryKey","getQueryKey","deferredQueryKey","setDeferredQueryKey","deferred","parseQueryKey","setRef","aborted","getQueryState","resolveQuery","DEFAULT_BATCH_SIZE","DEFAULT_PERSPECTIVE","useDocuments","orderings","search","batchSize","perspective","limit","setLimit","JSON","stringify","conditions","trim","join","filterClause","orderClause","dataQuery","countQuery","t7","count","hasMore","t8","prev","Math","min","loadMore","t9","t10","ordering","field","direction","toLowerCase","Boolean","str","usePaginatedDocuments","pageSize","pageIndex","setPageIndex","startIndex","endIndex","t11","totalPages","ceil","currentPage","t12","firstPage","t13","_temp3","previousPage","t14","prev_0","nextPage","t15","lastPage","t16","pageNumber","goToPage","hasFirstPage","hasPreviousPage","hasNextPage","hasLastPage","t17","t18","max","usePreview","getPreviewState","stateSource","onStoreChanged","subscription","Observable","observer","IntersectionObserver","HTMLElement","intersectionObserver","entry","next","isIntersecting","rootMargin","threshold","observe","disconnect","startWith","distinctUntilChanged","switchMap","isVisible","obs","EMPTY","currentState","resolvePreview","useProjection","projection","getProjectionState","resolveProjection","useProject","getProjectState","resolveProject","useProjects","getProjectsState","resolveProjects","useUsers","createUsersStore","store","setOptions","initialFetchCompleted","resolveUsers","dispose","getSnapshot","users","getEnv","import","env","process","ENV","REACT_SDK_VERSION","version"],"mappings":";;;;;;;;AAGaA,MAAAA,wBAAwBC,cAAuC,IAAI,GCcnEC,oBAAoBC,CAAA,eAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAC/BC,iBAAuBC,WAAAP,qBAAgC;AAAC,MAAA,CACnDM;AAAcE,UAAAA,IAAAA,MACD,iEAAiE;AAAA,MAE/EF,eAAcG,WAAa;AAAAD,UAAAA,IAAAA,MACb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MAAAA,KAAArG,EAAA,EAAA,GAA1CqG;AAA0C;;ACjG5C,SAAS4S,OAAOvL,KAA2B;AAC5C,MAAA,OAAOwL,cAAgB,OAAeA,YAAYC;AAE5CD,WAAAA,YAAYC,IAA2CzL,GAAG;AACzD,MAAA,OAAO0L,UAAY,OAAeA,QAAQD;AAE5CC,WAAAA,QAAQD,IAAIzL,GAAG;AACb,MAAA,OAAO7L,SAAW,OAAgBA,OAAyBwX;AAE5DxX,WAAAA,OAAyBwX,MAAM3L,GAAG;AAG9C;ACbO,MAAM4L,oBAAoBL,OAAO,aAAa,KAAK,GAAGM,OAAO;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/sdk-react",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.21",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Sanity SDK React toolkit for Content OS",
|
|
6
6
|
"keywords": [
|
|
@@ -30,90 +30,60 @@
|
|
|
30
30
|
"import": "./dist/index.js",
|
|
31
31
|
"default": "./dist/index.js"
|
|
32
32
|
},
|
|
33
|
-
"./components": {
|
|
34
|
-
"source": "./src/_exports/components.ts",
|
|
35
|
-
"import": "./dist/components.js",
|
|
36
|
-
"default": "./dist/components.js"
|
|
37
|
-
},
|
|
38
|
-
"./hooks": {
|
|
39
|
-
"source": "./src/_exports/hooks.ts",
|
|
40
|
-
"import": "./dist/hooks.js",
|
|
41
|
-
"default": "./dist/hooks.js"
|
|
42
|
-
},
|
|
43
33
|
"./package.json": "./package.json"
|
|
44
34
|
},
|
|
45
35
|
"main": "./dist/index.js",
|
|
46
36
|
"module": "./dist/index.js",
|
|
47
37
|
"types": "./dist/index.d.ts",
|
|
48
|
-
"typesVersions": {
|
|
49
|
-
"*": {
|
|
50
|
-
"components": [
|
|
51
|
-
"./dist/components.d.ts"
|
|
52
|
-
],
|
|
53
|
-
"hooks": [
|
|
54
|
-
"./dist/hooks.d.ts"
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
38
|
"files": [
|
|
59
39
|
"dist",
|
|
60
40
|
"src"
|
|
61
41
|
],
|
|
62
|
-
"lint-staged": {
|
|
63
|
-
"!(*.{ts,tsx})": "prettier --write",
|
|
64
|
-
"*.{ts,tsx}": [
|
|
65
|
-
"eslint --fix",
|
|
66
|
-
"prettier --write"
|
|
67
|
-
]
|
|
68
|
-
},
|
|
69
42
|
"browserslist": "extends @sanity/browserslist-config",
|
|
70
43
|
"prettier": "@sanity/prettier-config",
|
|
71
44
|
"dependencies": {
|
|
72
|
-
"@paramour/css": "1.0.0-rc.2",
|
|
73
|
-
"@sanity/icons": "^3.5.2",
|
|
74
45
|
"@sanity/logos": "^2.1.13",
|
|
75
|
-
"@sanity/
|
|
76
|
-
"@types
|
|
77
|
-
"
|
|
78
|
-
"lodash-es": "^4.17.21",
|
|
79
|
-
"react-error-boundary": "^4.1.2",
|
|
80
|
-
"rollup-plugin-import-css": "^3.5.7",
|
|
46
|
+
"@sanity/message-protocol": "^0.6.0",
|
|
47
|
+
"@sanity/types": "^3.78.1",
|
|
48
|
+
"react-error-boundary": "^5.0.0",
|
|
81
49
|
"rxjs": "^7.8.1",
|
|
82
|
-
"
|
|
83
|
-
"@sanity/sdk": "0.0.0-alpha.2"
|
|
50
|
+
"@sanity/sdk": "0.0.0-alpha.20"
|
|
84
51
|
},
|
|
85
52
|
"devDependencies": {
|
|
86
|
-
"@sanity/
|
|
87
|
-
"@sanity/
|
|
53
|
+
"@sanity/browserslist-config": "^1.0.5",
|
|
54
|
+
"@sanity/client": "^6.28.3",
|
|
55
|
+
"@sanity/comlink": "^3.0.1",
|
|
56
|
+
"@sanity/pkg-utils": "^6.13.4",
|
|
88
57
|
"@sanity/prettier-config": "^1.0.3",
|
|
89
|
-
"@storybook/react": "^8.4.7",
|
|
90
58
|
"@testing-library/jest-dom": "^6.6.3",
|
|
91
|
-
"@testing-library/react": "^16.
|
|
92
|
-
"@types/react": "^
|
|
93
|
-
"@types/react-dom": "^
|
|
59
|
+
"@testing-library/react": "^16.2.0",
|
|
60
|
+
"@types/react": "^19.0.10",
|
|
61
|
+
"@types/react-dom": "^19.0.4",
|
|
94
62
|
"@vitejs/plugin-react": "^4.3.4",
|
|
95
|
-
"@vitest/coverage-v8": "
|
|
96
|
-
"
|
|
63
|
+
"@vitest/coverage-v8": "3.0.9",
|
|
64
|
+
"babel-plugin-react-compiler": "19.0.0-beta-bafa41b-20250307",
|
|
65
|
+
"eslint": "^9.22.0",
|
|
97
66
|
"jsdom": "^25.0.1",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"react": "^
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"vitest": "^
|
|
67
|
+
"prettier": "^3.5.3",
|
|
68
|
+
"react": "^19.0.0",
|
|
69
|
+
"react-dom": "^19.0.0",
|
|
70
|
+
"typescript": "^5.7.3",
|
|
71
|
+
"vite": "^6.2.2",
|
|
72
|
+
"vitest": "^3.0.9",
|
|
104
73
|
"@repo/config-eslint": "0.0.0",
|
|
105
|
-
"@repo/
|
|
74
|
+
"@repo/config-test": "0.0.1",
|
|
75
|
+
"@repo/package.config": "0.0.1",
|
|
76
|
+
"@repo/tsconfig": "0.0.1"
|
|
106
77
|
},
|
|
107
78
|
"peerDependencies": {
|
|
108
|
-
"react": "^18.0.0",
|
|
109
|
-
"react-dom": "^18.0.0"
|
|
110
|
-
"styled-components": "^6.1.13"
|
|
79
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
80
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
111
81
|
},
|
|
112
82
|
"engines": {
|
|
113
83
|
"node": ">=20.0.0"
|
|
114
84
|
},
|
|
115
85
|
"publishConfig": {
|
|
116
|
-
"access": "
|
|
86
|
+
"access": "public"
|
|
117
87
|
},
|
|
118
88
|
"scripts": {
|
|
119
89
|
"build": "pkg build --strict --clean --check",
|
|
@@ -122,7 +92,6 @@
|
|
|
122
92
|
"docs": "typedoc --out docs --tsconfig ../../tsconfig.tsdoc.json",
|
|
123
93
|
"format": "prettier --write --cache --ignore-unknown .",
|
|
124
94
|
"lint": "eslint .",
|
|
125
|
-
"paramour": "npx paramour --config=./src/css/css.config.js --output=./src/css/paramour.css",
|
|
126
95
|
"test": "vitest run",
|
|
127
96
|
"test:coverage": "vitest run --coverage",
|
|
128
97
|
"test:watch": "vitest",
|
package/src/_exports/index.ts
CHANGED
|
@@ -1,10 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
export {AuthBoundary} from '../components/auth/AuthBoundary'
|
|
2
|
+
export {SanityApp, type SanityAppProps} from '../components/SanityApp'
|
|
3
|
+
export {SDKProvider, type SDKProviderProps} from '../components/SDKProvider'
|
|
4
|
+
export type {SanityProviderProps} from '../context/SanityProvider'
|
|
5
|
+
export {SanityProvider} from '../context/SanityProvider'
|
|
6
|
+
export {useAuthState} from '../hooks/auth/useAuthState'
|
|
7
|
+
export {useAuthToken} from '../hooks/auth/useAuthToken'
|
|
8
|
+
export {useCurrentUser} from '../hooks/auth/useCurrentUser'
|
|
9
|
+
export {useDashboardOrganizationId} from '../hooks/auth/useDashboardOrganizationId'
|
|
10
|
+
export {useHandleAuthCallback} from '../hooks/auth/useHandleAuthCallback'
|
|
11
|
+
export {useLoginUrls} from '../hooks/auth/useLoginUrls'
|
|
12
|
+
export {useLogOut} from '../hooks/auth/useLogOut'
|
|
13
|
+
export {useClient} from '../hooks/client/useClient'
|
|
14
|
+
export {
|
|
15
|
+
type FrameConnection,
|
|
16
|
+
type FrameMessageHandler as MessageHandler,
|
|
17
|
+
useFrameConnection,
|
|
18
|
+
type UseFrameConnectionOptions,
|
|
19
|
+
} from '../hooks/comlink/useFrameConnection'
|
|
20
|
+
export {useManageFavorite} from '../hooks/comlink/useManageFavorite'
|
|
21
|
+
export {useRecordDocumentHistoryEvent} from '../hooks/comlink/useRecordDocumentHistoryEvent'
|
|
22
|
+
export {
|
|
23
|
+
useWindowConnection,
|
|
24
|
+
type UseWindowConnectionOptions,
|
|
25
|
+
type WindowConnection,
|
|
26
|
+
type WindowMessageHandler,
|
|
27
|
+
} from '../hooks/comlink/useWindowConnection'
|
|
28
|
+
export {useSanityInstance} from '../hooks/context/useSanityInstance'
|
|
29
|
+
export {useNavigateToStudioDocument} from '../hooks/dashboard/useNavigateToStudioDocument'
|
|
30
|
+
export {useStudioWorkspacesByResourceId} from '../hooks/dashboard/useStudioWorkspacesByResourceId'
|
|
31
|
+
export {useDatasets} from '../hooks/datasets/useDatasets'
|
|
32
|
+
export {useApplyDocumentActions} from '../hooks/document/useApplyDocumentActions'
|
|
33
|
+
export {useDocument} from '../hooks/document/useDocument'
|
|
34
|
+
export {useDocumentEvent} from '../hooks/document/useDocumentEvent'
|
|
35
|
+
export {useDocumentPermissions} from '../hooks/document/useDocumentPermissions'
|
|
36
|
+
export {useDocumentSyncStatus} from '../hooks/document/useDocumentSyncStatus'
|
|
37
|
+
export {useEditDocument} from '../hooks/document/useEditDocument'
|
|
38
|
+
export {
|
|
39
|
+
type DocumentsOptions,
|
|
40
|
+
type DocumentsResponse,
|
|
41
|
+
useDocuments,
|
|
42
|
+
} from '../hooks/documents/useDocuments'
|
|
43
|
+
export {
|
|
44
|
+
type PaginatedDocumentsOptions,
|
|
45
|
+
type PaginatedDocumentsResponse,
|
|
46
|
+
usePaginatedDocuments,
|
|
47
|
+
} from '../hooks/paginatedDocuments/usePaginatedDocuments'
|
|
48
|
+
export {
|
|
49
|
+
usePreview,
|
|
50
|
+
type UsePreviewOptions,
|
|
51
|
+
type UsePreviewResults,
|
|
52
|
+
} from '../hooks/preview/usePreview'
|
|
53
|
+
export {
|
|
54
|
+
useProjection,
|
|
55
|
+
type UseProjectionOptions,
|
|
56
|
+
type UseProjectionResults,
|
|
57
|
+
} from '../hooks/projection/useProjection'
|
|
58
|
+
export {useProject} from '../hooks/projects/useProject'
|
|
59
|
+
export {type ProjectWithoutMembers, useProjects} from '../hooks/projects/useProjects'
|
|
60
|
+
export {useQuery} from '../hooks/query/useQuery'
|
|
61
|
+
export {useUsers, type UseUsersParams, type UseUsersResult} from '../hooks/users/useUsers'
|
|
62
|
+
export {REACT_SDK_VERSION} from '../version'
|
|
63
|
+
export {type DatasetsResponse, type SanityProject, type SanityProjectMember} from '@sanity/client'
|
|
64
|
+
export {type Status as ComlinkStatus} from '@sanity/comlink'
|
|
65
|
+
export {type CurrentUser, type DocumentHandle} from '@sanity/sdk'
|
|
66
|
+
export {type SanityDocument, type SortOrderingItem} from '@sanity/types'
|