@sanity/sdk 3.15.0 → 3.16.0-next.20261120142616
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_exports/_internal.d.ts +5 -5
- package/dist/_exports/_internal.js +2 -2
- package/dist/_exports/agent.d.ts +1 -1
- package/dist/_exports/collaboration.d.ts +3 -3
- package/dist/_exports/collaboration.js +2 -2
- package/dist/_exports/comlink.d.ts +2 -2
- package/dist/_exports/dashboard.d.ts +2 -2
- package/dist/{applications-DV6XreC6.d.ts → applications-D84Jz932.d.ts} +10 -3
- package/dist/applications-D84Jz932.d.ts.map +1 -0
- package/dist/{buildCommentThreads-C1hKJdCg.js → buildCommentThreads-C_XIm6jE.js} +2 -2
- package/dist/{buildCommentThreads-C1hKJdCg.js.map → buildCommentThreads-C_XIm6jE.js.map} +1 -1
- package/dist/{bus-BsPCAXk3.d.ts → bus-CdYznZ0s.d.ts} +2 -2
- package/dist/{bus-BsPCAXk3.d.ts.map → bus-CdYznZ0s.d.ts.map} +1 -1
- package/dist/{types-Dp4-_rxL.js → commentFieldPath-32Sd8yky.js} +17 -9
- package/dist/commentFieldPath-32Sd8yky.js.map +1 -0
- package/dist/{commentsOptions-DuLgrFc5.d.ts → commentsOptions-ChZhk8mb.d.ts} +2 -2
- package/dist/{commentsOptions-DuLgrFc5.d.ts.map → commentsOptions-ChZhk8mb.d.ts.map} +1 -1
- package/dist/{createSanityInstance-BtgGknwT.d.ts → createSanityInstance-C1wD7RmA.d.ts} +13 -1
- package/dist/{createSanityInstance-BtgGknwT.d.ts.map → createSanityInstance-C1wD7RmA.d.ts.map} +1 -1
- package/dist/createStateSourceAction-Bn0po7Z3.js.map +1 -1
- package/dist/{createStateSourceAction-CzAwbNjw.d.ts → createStateSourceAction-Cb7ZjAd8.d.ts} +2 -2
- package/dist/{createStateSourceAction-CzAwbNjw.d.ts.map → createStateSourceAction-Cb7ZjAd8.d.ts.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1207 -6
- package/dist/index.js.map +1 -1
- package/dist/{version-BbLOOPMX.js → version-CiC6TBKI.js} +7 -1208
- package/dist/version-CiC6TBKI.js.map +1 -0
- package/package.json +1 -1
- package/src/config/sanityConfig.ts +12 -0
- package/src/store/fetcherStore.test.ts +129 -2
- package/src/store/fetcherStore.ts +45 -10
- package/dist/applications-DV6XreC6.d.ts.map +0 -1
- package/dist/types-Dp4-_rxL.js.map +0 -1
- package/dist/version-BbLOOPMX.js.map +0 -1
|
@@ -238,6 +238,18 @@ interface SanityConfig extends DatasetHandle, PerspectiveHandle {
|
|
|
238
238
|
* library and canvas requests never use the project subdomain.
|
|
239
239
|
*/
|
|
240
240
|
useProjectHostname?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Whether the cached API data the app shows, such as projects, applications and preferences, is
|
|
243
|
+
* fetched again when someone comes back to the app's tab. Data fetched in the last 30 seconds
|
|
244
|
+
* isn't. Defaults to `true`. Like TanStack Query's option of the same name, it follows the tab's
|
|
245
|
+
* visibility, not window focus.
|
|
246
|
+
*
|
|
247
|
+
* Data another SDK instance on the page also shows, such as an organization's projects, follows
|
|
248
|
+
* the setting of whichever instance started showing it last.
|
|
249
|
+
*
|
|
250
|
+
* @beta
|
|
251
|
+
*/
|
|
252
|
+
refetchOnWindowFocus?: boolean;
|
|
241
253
|
}
|
|
242
254
|
/**
|
|
243
255
|
* A document resource can be used for querying.
|
|
@@ -318,4 +330,4 @@ interface SanityInstance {
|
|
|
318
330
|
*/
|
|
319
331
|
declare function createSanityInstance(config?: SanityConfig): SanityInstance;
|
|
320
332
|
export { isCanvasResource as _, DatasetResource as a, AuthConfig as b, DocumentTypeHandle as c, ProjectHandle as d, ReleaseHandle as f, TokenSource as g, StudioConfig as h, DatasetHandle as i, MediaLibraryResource as l, SanityConfig as m, createSanityInstance as n, DocumentHandle as o, ReleasePerspective as p, CanvasResource as r, DocumentResource as s, SanityInstance as t, PerspectiveHandle as u, isDatasetResource as v, AuthProvider as x, isMediaLibraryResource as y };
|
|
321
|
-
//# sourceMappingURL=createSanityInstance-
|
|
333
|
+
//# sourceMappingURL=createSanityInstance-C1wD7RmA.d.ts.map
|
package/dist/{createSanityInstance-BtgGknwT.d.ts.map → createSanityInstance-C1wD7RmA.d.ts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSanityInstance-
|
|
1
|
+
{"version":3,"file":"createSanityInstance-C1wD7RmA.d.ts","names":[],"sources":["../src/config/authConfig.ts","../src/config/sanityConfig.ts","../src/store/createSanityInstance.ts"],"mappings":";;;;;UAMiB;;;;EAIf;;;;EAKA;;;;EAKA;;;;EAKA;;;;;;;UAQe;;;;;EAKf;;;;;EAMA,iBAAiB,QAAQ,iBAAiB;;;;;;EAO1C,YAAY,mBAAmB,MAAM,mBAAmB,iBAAiB,QAAQ;;;;;;EAOjF;;;;;EAMA,cAAc;;;;;;EAOd;;;;;;EAOA;EAEA;;;;IAIE;;;;;IAMA;;;;;;;IAQA;;;;;;;;;;;UCtFa;;EAEf,UAAU;IAAW,OAAO;;IAAkC;;;;;;;;;;UAU/C;;;;;;EAMf;;EAEA;;;;;;;;IAQE,QAAQ;;;;;;;UAQK,cAAc;EAC7B,YAAY;;;;;KAMF;EACV;EACA,uBAAuB;;;;;UAMR;EACf,cAAc,oBAAoB;;;;;UAMnB,cAAc,kCAAkC,4CACvD,cAAc,aAAa;EACnC,UAAU;;;;;;;EAOV,WAAW;;;;;;;;UASI,mBACf,uCACA,kCACA,4CACQ,cAAc,UAAU;EAChC;EACA,cAAc;;;;;;EAMd;;;;;;;;UASe,eACf,uCACA,kCACA,4CACQ,mBAAmB,eAAe,UAAU;EACpD;;;;;;;;;;UAWe,sBAAsB;EACrC;;;;;;UAOe,qBAAqB,eAAe;;;;;;;;;;;;;;;EAenD;;;;EAIA,OAAO;;;;;;;;;EASP,SAAS;;;;;;;;;EAST;;;;;;;;;;;;EAYA;;;;;;;;KASU,mBAAmB,kBAAkB,uBAAuB;;;;KAK5D;EAAmB;EAAmB;;;;;KAKtC;EAAwB;;;;;KAKxB;EAAkB;;;;;iBAKd,kBAAkB,UAAU,mBAAmB,YAAY;;;;iBAO3D,uBACd,UAAU,mBACT,YAAY;;;;iBAOC,iBAAiB,UAAU,mBAAmB,YAAY;;;;;;UC1NzD;;;;;WAKN;;;;WAKA,QAAQ;;;;;EAMjB;;;;;EAMA;;;;;;EAOA,UAAU;;;;;;;;;iBAUI,qBAAqB,SAAQ,eAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createStateSourceAction-Bn0po7Z3.js","names":[],"sources":["../src/config/sanityConfig.ts","../src/releases/utils/isReleasePerspective.ts","../src/utils/getEnv.ts","../src/utils/setCleanupTimeout.ts","../src/store/createStoreState.ts","../src/store/defineStore.ts","../src/store/createStoreInstance.ts","../src/store/createActionBinder.ts","../src/store/createStateSourceAction.ts"],"sourcesContent":["import {type ClientPerspective, type StackablePerspective} from '@sanity/client'\n\nimport {type AuthConfig} from './authConfig'\n\n/**\n * A minimal Observable-compatible interface for subscribing to token changes.\n * Any object with a `subscribe` method that follows this contract will work,\n * including RxJS Observables. This avoids coupling the SDK to a specific\n * reactive library.\n *\n * @public\n */\nexport interface TokenSource {\n /** Subscribe to token emissions. Emits `null` when logged out. */\n subscribe(observer: {next: (token: string | null) => void}): {unsubscribe(): void}\n}\n\n/**\n * Studio-specific configuration for the SDK.\n * When present, the SDK operates in studio mode and derives auth from the\n * provided token source instead of discovering tokens independently.\n *\n * @public\n */\nexport interface StudioConfig {\n /**\n * Whether the Studio has already determined the user is authenticated.\n * When `true` and the token source emits `null`, the SDK infers\n * cookie-based auth is in use rather than transitioning to logged-out.\n */\n authenticated?: boolean\n /** Reactive auth token source from the Studio's auth store. */\n auth?: {\n /**\n * A reactive token source. The SDK subscribes and stays in sync — the\n * Studio is the single authority for auth and handles token refresh.\n *\n * Optional because older Studios may not expose it. When absent, the\n * SDK falls back to localStorage/cookie discovery.\n */\n token?: TokenSource\n }\n}\n\n/**\n * Represents the minimal configuration required to identify a Sanity project.\n * @public\n */\nexport interface ProjectHandle<TProjectId extends string = string> {\n projectId?: TProjectId\n}\n\n/**\n * @public\n */\nexport type ReleasePerspective = {\n releaseName: string\n excludedPerspectives?: StackablePerspective[]\n}\n\n/**\n * @public\n */\nexport interface PerspectiveHandle {\n perspective?: ClientPerspective | ReleasePerspective\n}\n\n/**\n * @public\n */\nexport interface DatasetHandle<TDataset extends string = string, TProjectId extends string = string>\n extends ProjectHandle<TProjectId>, PerspectiveHandle {\n dataset?: TDataset\n /**\n * @beta\n * Explicit resource to use. On an individual operation this overrides any default;\n * on a `SanityConfig` it becomes the instance's default resource. Unlike\n * `projectId`/`dataset`, this can also be a media library or canvas resource.\n */\n resource?: DocumentResource\n}\n\n/**\n * Identifies a specific document type within a Sanity dataset and project.\n * Includes `projectId`, `dataset`, and `documentType`.\n * Optionally includes a `documentId` and `liveEdit` flag.\n * @public\n */\nexport interface DocumentTypeHandle<\n TDocumentType extends string = string,\n TDataset extends string = string,\n TProjectId extends string = string,\n> extends DatasetHandle<TDataset, TProjectId> {\n documentId?: string\n documentType: TDocumentType\n /**\n * Indicates whether this document uses liveEdit mode.\n * When `true`, the document does not use the draft/published model and edits are applied directly to the document.\n * @see https://www.sanity.io/docs/content-lake/drafts#ca0663a8f002\n */\n liveEdit?: boolean\n}\n\n/**\n * Uniquely identifies a specific document within a Sanity dataset and project.\n * Includes `projectId`, `dataset`, `documentType`, and the required `documentId`.\n * Commonly used by document-related hooks and components to reference a document without fetching its full content initially.\n * @public\n */\nexport interface DocumentHandle<\n TDocumentType extends string = string,\n TDataset extends string = string,\n TProjectId extends string = string,\n> extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {\n documentId: string\n}\n\n/**\n * Identifies a release within a Sanity dataset and project. `releaseId` is the\n * `name` parameter on the release document (e.g. `{name: 'r41035a4'}`).\n * The underlying release document ID is `_.releases.<releaseId>`.\n * It's also the `id` parameter sent to the Actions API.\n * (This type doesn't need to have ProjectId / Dataset generics since it's always the same shape)\n * @beta\n */\nexport interface ReleaseHandle extends DatasetHandle {\n releaseId: string\n}\n\n/**\n * Represents the complete configuration for a Sanity SDK instance\n * @public\n */\nexport interface SanityConfig extends DatasetHandle, PerspectiveHandle {\n /**\n * The organization this app belongs to.\n *\n * Only needed outside the Sanity Dashboard, which tells the app which\n * organization it was opened in; that always wins over this. Set it when\n * running standalone and something organization-scoped, such as an\n * organization user list, needs to know. Left unset, features that can fall\n * back to the organization owning the project do so.\n *\n * Unrelated to `auth.oauth.organizationId`, which restricts the tokens the\n * OAuth flow issues. Neither is derived from the other.\n *\n * @beta\n */\n organizationId?: string\n /**\n * Authentication configuration for the instance\n */\n auth?: AuthConfig\n /**\n * Studio configuration provided by a Sanity Studio workspace.\n * When present, the SDK operates in studio mode and derives auth from the\n * workspace's reactive token source — no manual configuration needed.\n *\n * @remarks Typically set automatically by `SanityApp` when it detects an\n * `SDKStudioContext` provider. Can also be set explicitly for programmatic use.\n */\n studio?: StudioConfig\n /**\n * Whether requests for a project, such as queries, documents, users and presence, go to\n * the project subdomain `<projectId>.<apiHost>`. Defaults to `true`.\n *\n * Set it to `false` when `auth.apiHost` already identifies the project, for example a\n * Content Lake-compatible proxy at `https://example.com/api/<projectId>`. Global, media\n * library and canvas requests never use the project subdomain.\n */\n useProjectHostname?: boolean\n}\n\n/**\n * A document resource can be used for querying.\n * This will soon be the default way to identify where you are querying from.\n *\n * @beta\n */\nexport type DocumentResource = DatasetResource | MediaLibraryResource | CanvasResource\n\n/**\n * @beta\n */\nexport type DatasetResource = {projectId: string; dataset: string}\n\n/**\n * @beta\n */\nexport type MediaLibraryResource = {mediaLibraryId: string}\n\n/**\n * @beta\n */\nexport type CanvasResource = {canvasId: string}\n\n/**\n * @beta\n */\nexport function isDatasetResource(resource: DocumentResource): resource is DatasetResource {\n return 'projectId' in resource && 'dataset' in resource\n}\n\n/**\n * @beta\n */\nexport function isMediaLibraryResource(\n resource: DocumentResource,\n): resource is MediaLibraryResource {\n return 'mediaLibraryId' in resource\n}\n\n/**\n * @beta\n */\nexport function isCanvasResource(resource: DocumentResource): resource is CanvasResource {\n return 'canvasId' in resource\n}\n","import {type PerspectiveHandle, type ReleasePerspective} from '../../config/sanityConfig'\n\nexport const isReleasePerspective = (\n perspective: PerspectiveHandle['perspective'],\n): perspective is ReleasePerspective => {\n return typeof perspective === 'object' && perspective !== null && 'releaseName' in perspective\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 {Observable} from 'rxjs'\n\n// Calls `.unref()` on a timer when running in Node.js. In Node.js, timers are\n// objects with an `unref()` method; in browsers they are numbers. Narrow at\n// runtime so this works in both environments without type assertions.\nfunction unref(timer: ReturnType<typeof setTimeout> | ReturnType<typeof setInterval>): void {\n const t: unknown = timer\n if (typeof t === 'object' && t !== null && 'unref' in t && typeof t.unref === 'function') {\n t.unref()\n }\n}\n\n/**\n * Like `setTimeout`, but calls `.unref()` on the timer when running in Node.js.\n *\n * In Node.js, active timers prevent the process from exiting. Cleanup timers\n * (e.g. deferred subscription removal) should not keep the process alive -\n * `.unref()` lets the process exit naturally while still firing the timer if\n * the process happens to still be running.\n *\n * In browsers, `setTimeout` returns a number and has no `.unref()` method,\n * so this is a no-op there.\n */\nexport function setCleanupTimeout(fn: () => void, delay: number): ReturnType<typeof setTimeout> {\n const timer = setTimeout(fn, delay)\n unref(timer)\n return timer\n}\n\n/**\n * Like `setInterval`, but calls `.unref()` on the timer when running in Node.js\n * so a recurring poll never keeps the process alive. See {@link setCleanupTimeout}\n * for why cleanup and background timers must not block process exit.\n */\nexport function setCleanupInterval(fn: () => void, delay: number): ReturnType<typeof setInterval> {\n const timer = setInterval(fn, delay)\n unref(timer)\n return timer\n}\n\n/**\n * Emits once after `delay` on a cleanup timer. For rxjs reset notifiers such as\n * `share({resetOnRefCountZero})`, which would otherwise use a timer that keeps\n * Node.js alive. See {@link setCleanupTimeout}.\n */\nexport function cleanupTimer(delay: number): Observable<void> {\n return new Observable<void>((subscriber) => {\n const timer = setCleanupTimeout(() => subscriber.next(), delay)\n return () => clearTimeout(timer)\n })\n}\n","import {Observable} from 'rxjs'\nimport {devtools, type DevtoolsOptions} from 'zustand/middleware'\nimport {createStore} from 'zustand/vanilla'\n\n/**\n * Represents a reactive store state container with multiple access patterns\n */\nexport interface StoreState<TState> {\n /**\n * Gets the current state value\n *\n * @remarks\n * This is a direct synchronous accessor that doesn't trigger subscriptions\n */\n get: () => TState\n\n /**\n * Updates the store state\n * @param name - Action name for devtools tracking\n * @param updatedState - New state value or updater function\n *\n * @remarks\n * When providing a partial object, previous top-level keys not included in\n * the update will be preserved.\n */\n set: (name: string, updatedState: Partial<TState> | ((s: TState) => Partial<TState>)) => void\n\n /**\n * Observable stream of state changes\n * @remarks\n * - Emits immediately with current state on subscription\n * - Shares underlying subscription between observers\n * - Only emits when state reference changes\n * - Completes when store is disposed\n */\n observable: Observable<TState>\n}\n\n/**\n * Creates a reactive store state container with multiple access patterns\n * @param initialState - Initial state value for the store\n * @param devToolsOptions - Configuration for Zustand devtools integration\n * @returns StoreState instance with get/set/observable interface\n *\n * @example\n * ```typescript\n * // Create a simple counter store\n * const counterStore = createStoreState({ count: 0 });\n *\n * // Update state\n * counterStore.set('increment', { count: 1 });\n *\n * // Observe changes\n * counterStore.observable.subscribe(console.log);\n * ```\n *\n * @remarks\n * Uses Zustand for state management under the hood with RxJS for observable interface.\n * Designed to work with both imperative and reactive programming patterns.\n */\nexport function createStoreState<TState>(\n initialState: TState,\n devToolsOptions?: Omit<DevtoolsOptions, 'actionCreators'>,\n): StoreState<TState> {\n // Create underlying Zustand store with devtools integration\n const store = createStore<TState>()(devtools(() => initialState, devToolsOptions))\n\n return {\n get: store.getState,\n set: (actionKey, updatedState) => {\n const currentState = store.getState()\n const nextState =\n typeof updatedState === 'function' ? updatedState(currentState) : updatedState\n\n // Optimization: Skip update if state reference remains the same\n if (currentState !== nextState) {\n store.setState(nextState, false, actionKey)\n }\n },\n observable: new Observable((observer) => {\n // Emit current state immediately on subscription\n const emit = () => observer.next(store.getState())\n emit()\n\n // Subscribe to Zustand store changes\n const unsubscribe = store.subscribe(emit)\n\n // Cleanup when observable unsubscribed\n return () => unsubscribe()\n }),\n }\n}\n","import {type Observable, type Subscription} from 'rxjs'\n\nimport {type SanityInstance} from './createSanityInstance'\nimport {type StoreState} from './createStoreState'\n\n/**\n * Context object provided to store initialization functions\n */\nexport interface StoreContext<TState, TKey = unknown> {\n /**\n * Sanity instance associated with this store\n *\n * @remarks\n * Provides access to the Sanity configuration and instance lifecycle methods\n */\n instance: SanityInstance\n\n /**\n * Reactive store state management utilities\n *\n * @remarks\n * Contains methods for getting/setting state and observing changes\n */\n state: StoreState<TState>\n\n /**\n * The key used to instantiate the store.\n */\n key: TKey\n\n /**\n * The store's upstream subscription. Subscribing keeps it open. Provided to\n * actions bound through an action binder.\n */\n upstream$?: Observable<never>\n\n /**\n * Why the upstream last failed to open, if it did. Provided to actions bound\n * through an action binder.\n */\n upstreamError?: () => {error: unknown} | undefined\n}\n\n/**\n * Defines the structure and behavior of a store\n *\n * @remarks\n * Stores are isolated state containers that can be associated with Sanity instances.\n * Each store definition creates a separate state instance per composite key.\n */\nexport interface StoreDefinition<TState, TKey = unknown> {\n /**\n * Unique name for the store\n *\n * @remarks\n * Used for debugging, devtools integration, and store identification\n */\n name: string\n\n /**\n * Creates the initial state for the store\n * @param instance - Sanity instance the store is being created for\n * @returns Initial state value\n *\n * @remarks\n * Called when a new store instance is created. Can use Sanity instance\n * configuration to determine initial state.\n */\n getInitialState: (instance: SanityInstance, key: TKey) => TState\n\n /**\n * Optional initialization function\n * @param context - Store context with state and instance access\n * @returns Optional cleanup function for store disposal\n *\n * @remarks\n * Use this for:\n * - Setting up event listeners\n * - Initial data fetching\n * - Connecting external services\n *\n * Return a cleanup function to:\n * - Remove event listeners\n * - Cancel pending operations\n * - Dispose external connections\n */\n initialize?: (context: StoreContext<TState, TKey>) => (() => void) | undefined\n\n /**\n * Optional function that opens the store's upstream subscription, such as a\n * live event stream from Content Lake.\n *\n * @remarks\n * The store layer opens it when the store gets its first subscriber and closes\n * it shortly after the last one leaves, so the connection is only open while\n * something shows the store's data. This includes apps hidden by React\n * `<Activity>`, whose components unsubscribe while hidden. State is kept while\n * upstream is closed. `initialize` runs once for the store's whole life.\n */\n upstream?: (context: StoreContext<TState, TKey>) => Subscription\n}\n\n/**\n * Typescript helper function for creating store definitions\n *\n * @param storeDefinition - Configuration object defining the store\n * @returns The finalized store definition\n */\nexport function defineStore<TState, TKey = unknown>(\n storeDefinition: StoreDefinition<TState, TKey>,\n): StoreDefinition<TState, TKey> {\n return storeDefinition\n}\n","import {EMPTY, Observable, share, Subject, takeUntil} from 'rxjs'\n\nimport {getEnv} from '../utils/getEnv'\nimport {cleanupTimer, setCleanupTimeout} from '../utils/setCleanupTimeout'\nimport {type SanityInstance} from './createSanityInstance'\nimport {createStoreState, type StoreState} from './createStoreState'\nimport {type StoreDefinition} from './defineStore'\n\n/**\n * How long a store keeps its upstream open after its last subscriber leaves.\n * Matches the query and document entry clear delays, and covers Strict Mode\n * double effects and Suspense flicker without reconnecting.\n */\nexport const UPSTREAM_CLOSE_DELAY_MS = 1000\n\n/**\n * Represents a running instance of a store with its own state and lifecycle\n *\n * @remarks\n * Each StoreInstance is tied to a specific SanityInstance, manages its own state,\n * and can be independently disposed when no longer needed.\n */\nexport interface StoreInstance<TState> {\n /**\n * Access to the reactive state container for this store instance\n */\n state: StoreState<TState>\n\n /**\n * Checks if this store instance has been disposed\n * @returns Boolean indicating disposed state\n */\n isDisposed: () => void\n\n /**\n * Cleans up this store instance and runs any initialization cleanup functions\n * @remarks Triggers the cleanup function returned from the initialize method\n */\n dispose: () => void\n\n /**\n * The store's upstream subscription, shared by everything subscribed to it.\n * Emits nothing; subscribing keeps it open. Completes when the store is disposed.\n */\n upstream$: Observable<never>\n\n /**\n * Why the upstream last failed to open, boxed so a thrown `undefined` still counts.\n * State sources throw it from `getCurrent` so it reaches an error boundary.\n */\n upstreamError: () => {error: unknown} | undefined\n}\n\n/**\n * Creates a new instance of a store from a store definition\n *\n * @param instance - The Sanity instance this store will be associated with\n * @param storeDefinition - The store definition containing initial state and initialization logic\n * @returns A store instance with state management and lifecycle methods\n *\n * @remarks\n * The store instance maintains its own state that is scoped to the given Sanity instance.\n * If the store definition includes an initialize function, it will be called during\n * instance creation, and its cleanup function will be called during disposal.\n *\n * @example\n * ```ts\n * const counterStore = defineStore({\n * name: 'Counter',\n * getInitialState: () => ({ count: 0 }),\n * initialize: ({state}) => {\n * console.log('Counter store initialized')\n * return () => console.log('Counter store disposed')\n * }\n * })\n *\n * const instance = createStoreInstance(sanityInstance, counterStore)\n * // Later when done with the store:\n * instance.dispose()\n * ```\n */\nexport function createStoreInstance<TState, TKey extends {name: string}>(\n instance: SanityInstance,\n key: TKey,\n {name, getInitialState, initialize, upstream}: StoreDefinition<TState, TKey>,\n): StoreInstance<TState> {\n const state = createStoreState(getInitialState(instance, key), {\n enabled: !!getEnv('DEV'),\n name: `${name}-${key.name}`,\n })\n const dispose = initialize?.({state, instance, key})\n const disposed = {current: false}\n\n const disposed$ = new Subject<void>()\n let upstreamError: {error: unknown} | undefined\n let upstreamErrorTimer: ReturnType<typeof setTimeout> | undefined\n\n const upstream$ = upstream\n ? new Observable<never>((subscriber) => {\n if (disposed.current) return subscriber.complete()\n clearTimeout(upstreamErrorTimer)\n try {\n const subscription = upstream({state, instance, key})\n upstreamError = undefined\n return subscription\n } catch (error) {\n upstreamError = {error}\n // Kept for as long as a connection would stay open: long enough for a reader that\n // never subscribes (Suspense) to reach its error boundary, short enough that the\n // next mount opens again, as it did when a failed store was never kept\n upstreamErrorTimer = setCleanupTimeout(() => {\n upstreamError = undefined\n }, UPSTREAM_CLOSE_DELAY_MS)\n throw error\n }\n }).pipe(\n takeUntil(disposed$),\n share({\n resetOnComplete: false,\n resetOnRefCountZero: () => cleanupTimer(UPSTREAM_CLOSE_DELAY_MS),\n }),\n )\n : EMPTY\n\n return {\n state,\n upstream$,\n upstreamError: () => upstreamError,\n dispose: () => {\n if (disposed.current) return\n disposed.current = true\n // Before initialize's cleanup, which may own what upstream depends on\n disposed$.next()\n dispose?.()\n },\n isDisposed: () => disposed.current,\n }\n}\n","import {type ClientPerspective} from '@sanity/client'\n\nimport {\n type DatasetHandle,\n type DocumentResource,\n isCanvasResource,\n isDatasetResource,\n isMediaLibraryResource,\n type ReleasePerspective,\n} from '../config/sanityConfig'\nimport {isReleasePerspective} from '../releases/utils/isReleasePerspective'\nimport {type SanityInstance} from './createSanityInstance'\nimport {createStoreInstance, type StoreInstance} from './createStoreInstance'\nimport {type StoreState} from './createStoreState'\nimport {type StoreContext, type StoreDefinition} from './defineStore'\n\nexport interface BoundResourceKey {\n name: string\n resource: DocumentResource\n}\nexport interface BoundPerspectiveKey extends BoundResourceKey {\n perspective: ClientPerspective | ReleasePerspective\n}\n/**\n * Defines a store action that operates on a specific state type\n */\nexport type StoreAction<TState, TParams extends unknown[], TReturn, TKey = unknown> = (\n context: StoreContext<TState, TKey>,\n ...params: TParams\n) => TReturn\n\n/**\n * Represents a store action that has been bound to a specific store instance\n */\nexport type BoundStoreAction<_TState, TParams extends unknown[], TReturn> = (\n instance: SanityInstance,\n ...params: TParams\n) => TReturn\n\n/**\n * Creates an action binder function that uses the provided key function\n * to determine how store instances are shared between Sanity instances\n *\n * @param keyFn - Function that generates a key from a Sanity config\n * @returns A function that binds store actions to Sanity instances\n *\n * @remarks\n * Action binders determine how store instances are shared across multiple\n * Sanity instances. The key function determines which instances share state.\n *\n * @example\n * ```ts\n * // Create a custom binder that uses a tenant ID for isolation\n * const bindActionByTenant = createActionBinder(config => config.tenantId || 'default')\n *\n * // Use the custom binder with a store definition\n * const getTenantUsers = bindActionByTenant(\n * userStore,\n * ({state}) => state.get().users\n * )\n * ```\n */\nexport function createActionBinder<\n TKey extends {name: string},\n TKeyParams extends unknown[] = unknown[],\n>(keyFn: (instance: SanityInstance, ...params: TKeyParams) => TKey) {\n const instanceRegistry = new Map<string, Set<string>>()\n const storeRegistry = new Map<string, StoreInstance<unknown>>()\n\n /**\n * Binds a store action to a store definition\n *\n * @param storeDefinition - The store definition\n * @param action - The action to bind\n * @returns A function that executes the action with a Sanity instance\n */\n return function bindAction<TState, TParams extends TKeyParams, TReturn>(\n storeDefinition: StoreDefinition<TState, TKey>,\n action: StoreAction<TState, TParams, TReturn, TKey>,\n ): BoundStoreAction<TState, TParams, TReturn> {\n return function boundAction(instance: SanityInstance, ...params: TParams) {\n const key = keyFn(instance, ...params)\n const compositeKey = storeDefinition.name + (key.name ? `:${key.name}` : '')\n\n // Get or create instance set for this composite key\n let instances = instanceRegistry.get(compositeKey)\n if (!instances) {\n instances = new Set<string>()\n instanceRegistry.set(compositeKey, instances)\n }\n\n // Register instance for disposal tracking\n if (!instances.has(instance.instanceId)) {\n instances.add(instance.instanceId)\n instance.onDispose(() => {\n instances.delete(instance.instanceId)\n\n // Clean up when last instance is disposed\n if (instances.size === 0) {\n storeRegistry.get(compositeKey)?.dispose()\n storeRegistry.delete(compositeKey)\n instanceRegistry.delete(compositeKey)\n }\n })\n }\n\n // Get or create store instance\n let storeInstance = storeRegistry.get(compositeKey)\n if (!storeInstance) {\n storeInstance = createStoreInstance(instance, key, storeDefinition)\n storeRegistry.set(compositeKey, storeInstance)\n }\n\n // Execute action with store context\n return action(\n {\n instance,\n state: storeInstance.state as StoreState<TState>,\n key,\n upstream$: storeInstance.upstream$,\n upstreamError: storeInstance.upstreamError,\n },\n ...params,\n )\n }\n }\n}\n\nconst createResourceKey = (\n instance: SanityInstance,\n resource?: DocumentResource,\n): BoundResourceKey => {\n let name: string | undefined\n let resourceForKey: DocumentResource | undefined\n // A per-call resource wins; otherwise use the instance's default resource.\n const effectiveResource = resource ?? instance.config.resource\n if (effectiveResource) {\n resourceForKey = effectiveResource\n if (isDatasetResource(effectiveResource)) {\n name = `${effectiveResource.projectId}.${effectiveResource.dataset}`\n } else if (isMediaLibraryResource(effectiveResource)) {\n name = `media-library:${effectiveResource.mediaLibraryId}`\n } else if (isCanvasResource(effectiveResource)) {\n name = `canvas:${effectiveResource.canvasId}`\n } else {\n throw new Error(`Received invalid resource: ${JSON.stringify(effectiveResource)}`)\n }\n return {name, resource: resourceForKey}\n }\n\n // `projectId`/`dataset` on the config are shorthand for a dataset resource.\n const {projectId, dataset} = instance.config\n if (!projectId || !dataset) {\n throw new Error('This API requires a project ID and dataset configured.')\n }\n return {name: `${projectId}.${dataset}`, resource: {projectId, dataset}}\n}\n\n/**\n * Binds an action to a store that's scoped to a specific document resource.\n **/\nexport const bindActionByResource = createActionBinder<\n BoundResourceKey,\n // `resource` is optional because it falls back to the instance config in\n // `createResourceKey` — see the note there on why that fallback still exists.\n [{resource?: DocumentResource}, ...unknown[]]\n>((instance, {resource}) => {\n return createResourceKey(instance, resource)\n})\n\n/**\n * Binds an action to a store that's scoped to a specific document resource and perspective.\n *\n * @remarks\n * This creates actions that operate on state isolated to a specific document resource and perspective.\n * Different document resources and perspectives will have separate states.\n *\n * This is mostly useful for stores that do batch fetching operations, since the query store\n * can isolate single queries by perspective.\n *\n * @throws Error if resource or perspective is missing from the Sanity instance config\n *\n * @example\n * ```ts\n * // Define a store\n * const documentStore = defineStore<DocumentState>({\n * name: 'Document',\n * getInitialState: () => ({ documents: {} }),\n * // ...\n * })\n *\n * // Create resource-and-perspective-specific actions\n * export const fetchDocuments = bindActionByResourceAndPerspective(\n * documentStore,\n * ({instance, state}, documentId) => {\n * // This state is isolated to the specific document resource and perspective\n * // ...fetch logic...\n * }\n * )\n *\n * // Usage\n * fetchDocument(sanityInstance, 'doc123')\n * ```\n */\nexport const bindActionByResourceAndPerspective = createActionBinder<\n BoundPerspectiveKey,\n [DatasetHandle, ...unknown[]]\n>((instance, options): BoundPerspectiveKey => {\n const {resource, perspective} = options\n // Same trade-off as the resource fallback in `createResourceKey`: configured once on the\n // instance rather than passed to every call. Kept for the same reason.\n const utilizedPerspective = perspective ?? instance.config.perspective ?? 'drafts'\n let perspectiveKey: string\n if (isReleasePerspective(utilizedPerspective)) {\n perspectiveKey = utilizedPerspective.releaseName\n } else if (typeof utilizedPerspective === 'string') {\n perspectiveKey = utilizedPerspective\n } else {\n // \"StackablePerspective\", shouldn't be a common case, but just in case\n perspectiveKey = JSON.stringify(utilizedPerspective)\n }\n const sourceKey = createResourceKey(instance, resource)\n\n return {\n name: `${sourceKey.name}:${perspectiveKey}`,\n resource: sourceKey.resource,\n perspective: utilizedPerspective,\n }\n})\n\n/**\n * Binds an action to a global store that's shared across all Sanity instances\n *\n * @remarks\n * This creates actions that operate on state shared globally across all Sanity instances.\n * Use this for features like authentication where the state should be the same\n * regardless of which project or dataset is being used.\n *\n * @example\n * ```ts\n * // Define a store\n * const authStore = defineStore<AuthState>({\n * name: 'Auth',\n * getInitialState: () => ({\n * user: null,\n * isAuthenticated: false\n * }),\n * // ...\n * })\n *\n * // Create global actions\n * export const getCurrentUser = bindActionGlobally(\n * authStore,\n * ({state}) => state.get().user\n * )\n *\n * export const login = bindActionGlobally(\n * authStore,\n * ({state, instance}, credentials) => {\n * // Login logic that affects global state\n * // ...\n * }\n * )\n *\n * // Usage with any instance\n * getCurrentUser(sanityInstance)\n * ```\n */\nexport const bindActionGlobally = createActionBinder((..._rest) => ({name: 'global'}))\n","import {\n defer,\n distinctUntilChanged,\n finalize,\n map,\n merge,\n Observable,\n shareReplay,\n skip,\n} from 'rxjs'\n\nimport {type StoreAction} from './createActionBinder'\nimport {type SanityInstance} from './createSanityInstance'\nimport {type StoreContext} from './defineStore'\n\n/**\n * Represents a reactive state source that provides synchronized access to store data\n *\n * @remarks\n * Designed to work with React's useSyncExternalStore hook. Provides three ways to access data:\n * 1. `getCurrent()` for synchronous current value access\n * 2. `subscribe()` for imperative change notifications\n * 3. `observable` for reactive stream access\n *\n * @public\n */\nexport interface StateSource<T> {\n /**\n * Subscribes to state changes with optional callback\n * @param onStoreChanged - Called whenever relevant state changes occur\n * @returns Unsubscribe function to clean up the subscription\n */\n subscribe: (onStoreChanged?: () => void) => () => void\n\n /**\n * Gets the current derived state value\n *\n * @remarks\n * Safe to call without subscription. Will always return the latest value\n * based on the current store state and selector parameters.\n */\n getCurrent: () => T\n\n /**\n * Observable stream of state values\n *\n * @remarks\n * Shares a single underlying subscription between all observers. Emits:\n * - Immediately with current value on subscription\n * - On every relevant state change\n * - Errors if selector throws\n */\n observable: Observable<T>\n}\n\n/**\n * Context passed to selectors when deriving state\n *\n * @remarks\n * Provides access to both the current state value and the Sanity instance,\n * allowing selectors to use configuration values when computing derived state.\n * The context is memoized for each state object and instance combination\n * to optimize performance and prevent unnecessary recalculations.\n *\n * @example\n * ```ts\n * // Using both state and instance in a selector (psuedo example)\n * const getUserByProjectId = createStateSourceAction(\n * ({ state, instance }: SelectorContext<UsersState>, options?: ProjectHandle) => {\n * const allUsers = state.users\n * const projectId = options?.projectId ?? instance.config.projectId\n * return allUsers.filter(user => user.projectId === projectId)\n * }\n * )\n * ```\n */\nexport interface SelectorContext<TState> {\n /**\n * The current state object from the store\n */\n state: TState\n\n /**\n * The Sanity instance associated with this state\n */\n instance: SanityInstance\n}\n\n/**\n * Function type for selecting derived state from store state and parameters\n * @public\n */\nexport type Selector<TState, TParams extends unknown[], TReturn> = (\n context: SelectorContext<TState>,\n ...params: TParams\n) => TReturn\n\n/**\n * Configuration options for creating a state source action\n */\ninterface StateSourceOptions<TState, TParams extends unknown[], TReturn, TKey> {\n /**\n * Selector function that derives the desired value from store state\n *\n * @remarks\n * Will be called on every store change. Should be pure function.\n * Thrown errors will propagate to observable subscribers.\n */\n selector: Selector<TState, TParams, TReturn>\n\n /**\n * Optional setup/cleanup handler for subscriptions\n *\n * @param context - Store context containing state and instance\n * @param params - Action parameters provided during invocation\n * @returns Optional cleanup function called when subscription ends\n */\n onSubscribe?: (context: StoreContext<TState, TKey>, ...params: TParams) => void | (() => void)\n\n /**\n * Equality function to prevent unnecessary updates\n */\n isEqual?: (prev: TReturn, curr: TReturn) => boolean\n}\n\n/**\n * Creates a state source action that generates StateSource instances\n *\n * @remarks\n * The returned action can be bound to a store using createActionBinder.\n * When invoked, returns a StateSource that stays synchronized with the store.\n *\n * Key performance features:\n * - Memoizes selector contexts to prevent redundant object creation\n * - Only runs selectors when the underlying state changes\n *\n * For complex data transformations, consider using memoized selectors\n * (like those from Reselect) to prevent expensive recalculations.\n *\n * @example\n * ```ts\n * // Create a simple counter source\n * const getCount = createStateSourceAction(({state}: SelectorContext<CounterState>) => state.count)\n * ```\n *\n * @example\n * ```ts\n * // Create a parameterized source with setup/cleanup\n * const getItem = createStateSourceAction({\n * selector: ({state}, index: number) => state.items[index],\n * onSubscribe: (context, index) => {\n * trackItemSubscription(index)\n * return () => untrackItem(index)\n * }\n * })\n * ```\n *\n * @example\n * ```ts\n * // Binding a state source to a specific store\n * const documentStore = defineStore<DocumentState>({\n * name: 'Documents',\n * getInitialState: () => ({ documents: {} }),\n * // ...\n * })\n *\n * const getDocument = bindActionByResource(\n * documentStore,\n * createStateSourceAction(({state}, documentId: string) => state.documents[documentId])\n * )\n *\n * // Usage\n * const documentSource = getDocument(sanityInstance, 'doc123')\n * const doc = documentSource.getCurrent()\n * const subscription = documentSource.observable.subscribe(updatedDoc => {\n * console.log('Document changed:', updatedDoc)\n * })\n * ```\n */\nexport function createStateSourceAction<TState, TParams extends unknown[], TReturn, TKey = unknown>(\n options: Selector<TState, TParams, TReturn> | StateSourceOptions<TState, TParams, TReturn, TKey>,\n): StoreAction<TState, TParams, StateSource<TReturn>, TKey> {\n const selector = typeof options === 'function' ? options : options.selector\n const subscribeHandler = options && 'onSubscribe' in options ? options.onSubscribe : undefined\n const isEqual = options && 'isEqual' in options ? (options.isEqual ?? Object.is) : Object.is\n const selectorContextCache = new WeakMap<\n object,\n WeakMap<SanityInstance, SelectorContext<TState>>\n >()\n\n /**\n * The state source action implementation\n * @param context - Store context providing access to state and instance\n * @param params - Parameters provided when invoking the bound action\n */\n function stateSourceAction(context: StoreContext<TState, TKey>, ...params: TParams) {\n const {state, instance} = context\n\n const getCurrent = (currentState: TState) => {\n if (typeof currentState !== 'object' || currentState === null) {\n throw new Error(\n `Expected store state to be an object but got \"${typeof currentState}\" instead`,\n )\n }\n\n let instanceCache = selectorContextCache.get(currentState)\n if (!instanceCache) {\n instanceCache = new WeakMap<SanityInstance, SelectorContext<TState>>()\n selectorContextCache.set(currentState, instanceCache)\n }\n let selectorContext = instanceCache.get(instance)\n if (!selectorContext) {\n selectorContext = {state: currentState, instance}\n instanceCache.set(instance, selectorContext)\n }\n return selector(selectorContext, ...params)\n }\n\n // `state.observable` will emit the current value immediately and\n // hence we inherit the same behavior here.\n let values = state.observable.pipe(map(getCurrent), distinctUntilChanged(isEqual))\n\n if (subscribeHandler) {\n values = withSubscribeHook(values, () => subscribeHandler(context, ...params))\n }\n // Before `shareReplay`, so each source holds upstream once however many subscribe to it\n if (context.upstream$) values = merge(values, context.upstream$)\n\n // Share but replay the latest value so every subscriber gets an\n // initial synchronous emission, matching `state.observable`. That keeps\n // `skip(1)` in `subscribe()` aligned with \"skip current snapshot\" rather than\n // silently eating the first real update after multicasting.\n const sharedValues = values.pipe(shareReplay({bufferSize: 1, refCount: true}))\n\n const subscribe = (onStoreChanged?: () => void) => {\n const subscription = sharedValues.pipe(skip(1)).subscribe({\n next: () => onStoreChanged?.(),\n // Propagate selector errors to both subscription types\n error: () => onStoreChanged?.(),\n })\n\n return () => {\n subscription.unsubscribe()\n }\n }\n\n return {\n getCurrent: () => {\n // The subscribe error handler above re-renders on a failed open, and relies on this throwing\n const upstreamError = context.upstreamError?.()\n if (upstreamError) throw upstreamError.error\n return getCurrent(state.get())\n },\n subscribe,\n observable: sharedValues,\n }\n }\n\n return stateSourceAction\n}\n\n/**\n * Creates a new Observable which wraps an existing Observable which will invoke\n * the function when a new subscriber appears.\n */\nfunction withSubscribeHook<T>(obs: Observable<T>, fn: () => void | (() => void)): Observable<T> {\n return defer(() => {\n const cleanup = fn()\n return cleanup ? obs.pipe(finalize(() => cleanup())) : obs\n })\n}\n"],"mappings":";;;;;;;AAuMA,SAAgB,kBAAkB,UAAyD;CACzF,OAAO,eAAe,YAAY,aAAa;AACjD;;;;AAKA,SAAgB,uBACd,UACkC;CAClC,OAAO,oBAAoB;AAC7B;;;;AAKA,SAAgB,iBAAiB,UAAwD;CACvF,OAAO,cAAc;AACvB;ACvNA,MAAa,wBACX,gBAEO,OAAO,eAAgB,cAAY,eAAwB,iBAAiB;ACGrF,SAAgB,OAAO,KAA2B;CAChD,IAA0C,YAAY,KAEpD,OAAQ,YAAY,IAA2C;CAC1D,IAAI,OAAO,UAAY,OAAe,QAAQ,KAEnD,OAAO,QAAQ,IAAI;CACd,IAAI,OAAO,SAAW,OAAgB,OAAyB,KAEpE,OAAQ,OAAyB,MAAM;AAG3C;ACfA,SAAS,MAAM,OAA6E;CAC1F,IAAM,IAAa;CACnB,AAAI,OAAO,KAAM,YAAY,KAAc,WAAW,KAAK,OAAO,EAAE,SAAU,cAC5E,EAAE,MAAM;AAEZ;;;;;;;;;;;;AAaA,SAAgB,kBAAkB,IAAgB,OAA8C;CAC9F,IAAM,QAAQ,WAAW,IAAI,KAAK;CAElC,OADA,MAAM,KAAK,GACJ;AACT;;;;;;AAOA,SAAgB,mBAAmB,IAAgB,OAA+C;CAChG,IAAM,QAAQ,YAAY,IAAI,KAAK;CAEnC,OADA,MAAM,KAAK,GACJ;AACT;;;;;;AAOA,SAAgB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AAC;GAC/B;GACA;GACA,YAAY;EACd;CACF;CAEA,OAAO;AACT;;;;;AAMA,SAAS,kBAAqB,KAAoB,IAA8C;CAC9F,OAAO,YAAY;EACjB,IAAM,UAAU,GAAG;EACnB,OAAO,UAAU,IAAI,KAAK,eAAe,QAAQ,CAAC,CAAC,IAAI;CACzD,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"createStateSourceAction-Bn0po7Z3.js","names":[],"sources":["../src/config/sanityConfig.ts","../src/releases/utils/isReleasePerspective.ts","../src/utils/getEnv.ts","../src/utils/setCleanupTimeout.ts","../src/store/createStoreState.ts","../src/store/defineStore.ts","../src/store/createStoreInstance.ts","../src/store/createActionBinder.ts","../src/store/createStateSourceAction.ts"],"sourcesContent":["import {type ClientPerspective, type StackablePerspective} from '@sanity/client'\n\nimport {type AuthConfig} from './authConfig'\n\n/**\n * A minimal Observable-compatible interface for subscribing to token changes.\n * Any object with a `subscribe` method that follows this contract will work,\n * including RxJS Observables. This avoids coupling the SDK to a specific\n * reactive library.\n *\n * @public\n */\nexport interface TokenSource {\n /** Subscribe to token emissions. Emits `null` when logged out. */\n subscribe(observer: {next: (token: string | null) => void}): {unsubscribe(): void}\n}\n\n/**\n * Studio-specific configuration for the SDK.\n * When present, the SDK operates in studio mode and derives auth from the\n * provided token source instead of discovering tokens independently.\n *\n * @public\n */\nexport interface StudioConfig {\n /**\n * Whether the Studio has already determined the user is authenticated.\n * When `true` and the token source emits `null`, the SDK infers\n * cookie-based auth is in use rather than transitioning to logged-out.\n */\n authenticated?: boolean\n /** Reactive auth token source from the Studio's auth store. */\n auth?: {\n /**\n * A reactive token source. The SDK subscribes and stays in sync — the\n * Studio is the single authority for auth and handles token refresh.\n *\n * Optional because older Studios may not expose it. When absent, the\n * SDK falls back to localStorage/cookie discovery.\n */\n token?: TokenSource\n }\n}\n\n/**\n * Represents the minimal configuration required to identify a Sanity project.\n * @public\n */\nexport interface ProjectHandle<TProjectId extends string = string> {\n projectId?: TProjectId\n}\n\n/**\n * @public\n */\nexport type ReleasePerspective = {\n releaseName: string\n excludedPerspectives?: StackablePerspective[]\n}\n\n/**\n * @public\n */\nexport interface PerspectiveHandle {\n perspective?: ClientPerspective | ReleasePerspective\n}\n\n/**\n * @public\n */\nexport interface DatasetHandle<TDataset extends string = string, TProjectId extends string = string>\n extends ProjectHandle<TProjectId>, PerspectiveHandle {\n dataset?: TDataset\n /**\n * @beta\n * Explicit resource to use. On an individual operation this overrides any default;\n * on a `SanityConfig` it becomes the instance's default resource. Unlike\n * `projectId`/`dataset`, this can also be a media library or canvas resource.\n */\n resource?: DocumentResource\n}\n\n/**\n * Identifies a specific document type within a Sanity dataset and project.\n * Includes `projectId`, `dataset`, and `documentType`.\n * Optionally includes a `documentId` and `liveEdit` flag.\n * @public\n */\nexport interface DocumentTypeHandle<\n TDocumentType extends string = string,\n TDataset extends string = string,\n TProjectId extends string = string,\n> extends DatasetHandle<TDataset, TProjectId> {\n documentId?: string\n documentType: TDocumentType\n /**\n * Indicates whether this document uses liveEdit mode.\n * When `true`, the document does not use the draft/published model and edits are applied directly to the document.\n * @see https://www.sanity.io/docs/content-lake/drafts#ca0663a8f002\n */\n liveEdit?: boolean\n}\n\n/**\n * Uniquely identifies a specific document within a Sanity dataset and project.\n * Includes `projectId`, `dataset`, `documentType`, and the required `documentId`.\n * Commonly used by document-related hooks and components to reference a document without fetching its full content initially.\n * @public\n */\nexport interface DocumentHandle<\n TDocumentType extends string = string,\n TDataset extends string = string,\n TProjectId extends string = string,\n> extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {\n documentId: string\n}\n\n/**\n * Identifies a release within a Sanity dataset and project. `releaseId` is the\n * `name` parameter on the release document (e.g. `{name: 'r41035a4'}`).\n * The underlying release document ID is `_.releases.<releaseId>`.\n * It's also the `id` parameter sent to the Actions API.\n * (This type doesn't need to have ProjectId / Dataset generics since it's always the same shape)\n * @beta\n */\nexport interface ReleaseHandle extends DatasetHandle {\n releaseId: string\n}\n\n/**\n * Represents the complete configuration for a Sanity SDK instance\n * @public\n */\nexport interface SanityConfig extends DatasetHandle, PerspectiveHandle {\n /**\n * The organization this app belongs to.\n *\n * Only needed outside the Sanity Dashboard, which tells the app which\n * organization it was opened in; that always wins over this. Set it when\n * running standalone and something organization-scoped, such as an\n * organization user list, needs to know. Left unset, features that can fall\n * back to the organization owning the project do so.\n *\n * Unrelated to `auth.oauth.organizationId`, which restricts the tokens the\n * OAuth flow issues. Neither is derived from the other.\n *\n * @beta\n */\n organizationId?: string\n /**\n * Authentication configuration for the instance\n */\n auth?: AuthConfig\n /**\n * Studio configuration provided by a Sanity Studio workspace.\n * When present, the SDK operates in studio mode and derives auth from the\n * workspace's reactive token source — no manual configuration needed.\n *\n * @remarks Typically set automatically by `SanityApp` when it detects an\n * `SDKStudioContext` provider. Can also be set explicitly for programmatic use.\n */\n studio?: StudioConfig\n /**\n * Whether requests for a project, such as queries, documents, users and presence, go to\n * the project subdomain `<projectId>.<apiHost>`. Defaults to `true`.\n *\n * Set it to `false` when `auth.apiHost` already identifies the project, for example a\n * Content Lake-compatible proxy at `https://example.com/api/<projectId>`. Global, media\n * library and canvas requests never use the project subdomain.\n */\n useProjectHostname?: boolean\n /**\n * Whether the cached API data the app shows, such as projects, applications and preferences, is\n * fetched again when someone comes back to the app's tab. Data fetched in the last 30 seconds\n * isn't. Defaults to `true`. Like TanStack Query's option of the same name, it follows the tab's\n * visibility, not window focus.\n *\n * Data another SDK instance on the page also shows, such as an organization's projects, follows\n * the setting of whichever instance started showing it last.\n *\n * @beta\n */\n refetchOnWindowFocus?: boolean\n}\n\n/**\n * A document resource can be used for querying.\n * This will soon be the default way to identify where you are querying from.\n *\n * @beta\n */\nexport type DocumentResource = DatasetResource | MediaLibraryResource | CanvasResource\n\n/**\n * @beta\n */\nexport type DatasetResource = {projectId: string; dataset: string}\n\n/**\n * @beta\n */\nexport type MediaLibraryResource = {mediaLibraryId: string}\n\n/**\n * @beta\n */\nexport type CanvasResource = {canvasId: string}\n\n/**\n * @beta\n */\nexport function isDatasetResource(resource: DocumentResource): resource is DatasetResource {\n return 'projectId' in resource && 'dataset' in resource\n}\n\n/**\n * @beta\n */\nexport function isMediaLibraryResource(\n resource: DocumentResource,\n): resource is MediaLibraryResource {\n return 'mediaLibraryId' in resource\n}\n\n/**\n * @beta\n */\nexport function isCanvasResource(resource: DocumentResource): resource is CanvasResource {\n return 'canvasId' in resource\n}\n","import {type PerspectiveHandle, type ReleasePerspective} from '../../config/sanityConfig'\n\nexport const isReleasePerspective = (\n perspective: PerspectiveHandle['perspective'],\n): perspective is ReleasePerspective => {\n return typeof perspective === 'object' && perspective !== null && 'releaseName' in perspective\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 {Observable} from 'rxjs'\n\n// Calls `.unref()` on a timer when running in Node.js. In Node.js, timers are\n// objects with an `unref()` method; in browsers they are numbers. Narrow at\n// runtime so this works in both environments without type assertions.\nfunction unref(timer: ReturnType<typeof setTimeout> | ReturnType<typeof setInterval>): void {\n const t: unknown = timer\n if (typeof t === 'object' && t !== null && 'unref' in t && typeof t.unref === 'function') {\n t.unref()\n }\n}\n\n/**\n * Like `setTimeout`, but calls `.unref()` on the timer when running in Node.js.\n *\n * In Node.js, active timers prevent the process from exiting. Cleanup timers\n * (e.g. deferred subscription removal) should not keep the process alive -\n * `.unref()` lets the process exit naturally while still firing the timer if\n * the process happens to still be running.\n *\n * In browsers, `setTimeout` returns a number and has no `.unref()` method,\n * so this is a no-op there.\n */\nexport function setCleanupTimeout(fn: () => void, delay: number): ReturnType<typeof setTimeout> {\n const timer = setTimeout(fn, delay)\n unref(timer)\n return timer\n}\n\n/**\n * Like `setInterval`, but calls `.unref()` on the timer when running in Node.js\n * so a recurring poll never keeps the process alive. See {@link setCleanupTimeout}\n * for why cleanup and background timers must not block process exit.\n */\nexport function setCleanupInterval(fn: () => void, delay: number): ReturnType<typeof setInterval> {\n const timer = setInterval(fn, delay)\n unref(timer)\n return timer\n}\n\n/**\n * Emits once after `delay` on a cleanup timer. For rxjs reset notifiers such as\n * `share({resetOnRefCountZero})`, which would otherwise use a timer that keeps\n * Node.js alive. See {@link setCleanupTimeout}.\n */\nexport function cleanupTimer(delay: number): Observable<void> {\n return new Observable<void>((subscriber) => {\n const timer = setCleanupTimeout(() => subscriber.next(), delay)\n return () => clearTimeout(timer)\n })\n}\n","import {Observable} from 'rxjs'\nimport {devtools, type DevtoolsOptions} from 'zustand/middleware'\nimport {createStore} from 'zustand/vanilla'\n\n/**\n * Represents a reactive store state container with multiple access patterns\n */\nexport interface StoreState<TState> {\n /**\n * Gets the current state value\n *\n * @remarks\n * This is a direct synchronous accessor that doesn't trigger subscriptions\n */\n get: () => TState\n\n /**\n * Updates the store state\n * @param name - Action name for devtools tracking\n * @param updatedState - New state value or updater function\n *\n * @remarks\n * When providing a partial object, previous top-level keys not included in\n * the update will be preserved.\n */\n set: (name: string, updatedState: Partial<TState> | ((s: TState) => Partial<TState>)) => void\n\n /**\n * Observable stream of state changes\n * @remarks\n * - Emits immediately with current state on subscription\n * - Shares underlying subscription between observers\n * - Only emits when state reference changes\n * - Completes when store is disposed\n */\n observable: Observable<TState>\n}\n\n/**\n * Creates a reactive store state container with multiple access patterns\n * @param initialState - Initial state value for the store\n * @param devToolsOptions - Configuration for Zustand devtools integration\n * @returns StoreState instance with get/set/observable interface\n *\n * @example\n * ```typescript\n * // Create a simple counter store\n * const counterStore = createStoreState({ count: 0 });\n *\n * // Update state\n * counterStore.set('increment', { count: 1 });\n *\n * // Observe changes\n * counterStore.observable.subscribe(console.log);\n * ```\n *\n * @remarks\n * Uses Zustand for state management under the hood with RxJS for observable interface.\n * Designed to work with both imperative and reactive programming patterns.\n */\nexport function createStoreState<TState>(\n initialState: TState,\n devToolsOptions?: Omit<DevtoolsOptions, 'actionCreators'>,\n): StoreState<TState> {\n // Create underlying Zustand store with devtools integration\n const store = createStore<TState>()(devtools(() => initialState, devToolsOptions))\n\n return {\n get: store.getState,\n set: (actionKey, updatedState) => {\n const currentState = store.getState()\n const nextState =\n typeof updatedState === 'function' ? updatedState(currentState) : updatedState\n\n // Optimization: Skip update if state reference remains the same\n if (currentState !== nextState) {\n store.setState(nextState, false, actionKey)\n }\n },\n observable: new Observable((observer) => {\n // Emit current state immediately on subscription\n const emit = () => observer.next(store.getState())\n emit()\n\n // Subscribe to Zustand store changes\n const unsubscribe = store.subscribe(emit)\n\n // Cleanup when observable unsubscribed\n return () => unsubscribe()\n }),\n }\n}\n","import {type Observable, type Subscription} from 'rxjs'\n\nimport {type SanityInstance} from './createSanityInstance'\nimport {type StoreState} from './createStoreState'\n\n/**\n * Context object provided to store initialization functions\n */\nexport interface StoreContext<TState, TKey = unknown> {\n /**\n * Sanity instance associated with this store\n *\n * @remarks\n * Provides access to the Sanity configuration and instance lifecycle methods\n */\n instance: SanityInstance\n\n /**\n * Reactive store state management utilities\n *\n * @remarks\n * Contains methods for getting/setting state and observing changes\n */\n state: StoreState<TState>\n\n /**\n * The key used to instantiate the store.\n */\n key: TKey\n\n /**\n * The store's upstream subscription. Subscribing keeps it open. Provided to\n * actions bound through an action binder.\n */\n upstream$?: Observable<never>\n\n /**\n * Why the upstream last failed to open, if it did. Provided to actions bound\n * through an action binder.\n */\n upstreamError?: () => {error: unknown} | undefined\n}\n\n/**\n * Defines the structure and behavior of a store\n *\n * @remarks\n * Stores are isolated state containers that can be associated with Sanity instances.\n * Each store definition creates a separate state instance per composite key.\n */\nexport interface StoreDefinition<TState, TKey = unknown> {\n /**\n * Unique name for the store\n *\n * @remarks\n * Used for debugging, devtools integration, and store identification\n */\n name: string\n\n /**\n * Creates the initial state for the store\n * @param instance - Sanity instance the store is being created for\n * @returns Initial state value\n *\n * @remarks\n * Called when a new store instance is created. Can use Sanity instance\n * configuration to determine initial state.\n */\n getInitialState: (instance: SanityInstance, key: TKey) => TState\n\n /**\n * Optional initialization function\n * @param context - Store context with state and instance access\n * @returns Optional cleanup function for store disposal\n *\n * @remarks\n * Use this for:\n * - Setting up event listeners\n * - Initial data fetching\n * - Connecting external services\n *\n * Return a cleanup function to:\n * - Remove event listeners\n * - Cancel pending operations\n * - Dispose external connections\n */\n initialize?: (context: StoreContext<TState, TKey>) => (() => void) | undefined\n\n /**\n * Optional function that opens the store's upstream subscription, such as a\n * live event stream from Content Lake.\n *\n * @remarks\n * The store layer opens it when the store gets its first subscriber and closes\n * it shortly after the last one leaves, so the connection is only open while\n * something shows the store's data. This includes apps hidden by React\n * `<Activity>`, whose components unsubscribe while hidden. State is kept while\n * upstream is closed. `initialize` runs once for the store's whole life.\n */\n upstream?: (context: StoreContext<TState, TKey>) => Subscription\n}\n\n/**\n * Typescript helper function for creating store definitions\n *\n * @param storeDefinition - Configuration object defining the store\n * @returns The finalized store definition\n */\nexport function defineStore<TState, TKey = unknown>(\n storeDefinition: StoreDefinition<TState, TKey>,\n): StoreDefinition<TState, TKey> {\n return storeDefinition\n}\n","import {EMPTY, Observable, share, Subject, takeUntil} from 'rxjs'\n\nimport {getEnv} from '../utils/getEnv'\nimport {cleanupTimer, setCleanupTimeout} from '../utils/setCleanupTimeout'\nimport {type SanityInstance} from './createSanityInstance'\nimport {createStoreState, type StoreState} from './createStoreState'\nimport {type StoreDefinition} from './defineStore'\n\n/**\n * How long a store keeps its upstream open after its last subscriber leaves.\n * Matches the query and document entry clear delays, and covers Strict Mode\n * double effects and Suspense flicker without reconnecting.\n */\nexport const UPSTREAM_CLOSE_DELAY_MS = 1000\n\n/**\n * Represents a running instance of a store with its own state and lifecycle\n *\n * @remarks\n * Each StoreInstance is tied to a specific SanityInstance, manages its own state,\n * and can be independently disposed when no longer needed.\n */\nexport interface StoreInstance<TState> {\n /**\n * Access to the reactive state container for this store instance\n */\n state: StoreState<TState>\n\n /**\n * Checks if this store instance has been disposed\n * @returns Boolean indicating disposed state\n */\n isDisposed: () => void\n\n /**\n * Cleans up this store instance and runs any initialization cleanup functions\n * @remarks Triggers the cleanup function returned from the initialize method\n */\n dispose: () => void\n\n /**\n * The store's upstream subscription, shared by everything subscribed to it.\n * Emits nothing; subscribing keeps it open. Completes when the store is disposed.\n */\n upstream$: Observable<never>\n\n /**\n * Why the upstream last failed to open, boxed so a thrown `undefined` still counts.\n * State sources throw it from `getCurrent` so it reaches an error boundary.\n */\n upstreamError: () => {error: unknown} | undefined\n}\n\n/**\n * Creates a new instance of a store from a store definition\n *\n * @param instance - The Sanity instance this store will be associated with\n * @param storeDefinition - The store definition containing initial state and initialization logic\n * @returns A store instance with state management and lifecycle methods\n *\n * @remarks\n * The store instance maintains its own state that is scoped to the given Sanity instance.\n * If the store definition includes an initialize function, it will be called during\n * instance creation, and its cleanup function will be called during disposal.\n *\n * @example\n * ```ts\n * const counterStore = defineStore({\n * name: 'Counter',\n * getInitialState: () => ({ count: 0 }),\n * initialize: ({state}) => {\n * console.log('Counter store initialized')\n * return () => console.log('Counter store disposed')\n * }\n * })\n *\n * const instance = createStoreInstance(sanityInstance, counterStore)\n * // Later when done with the store:\n * instance.dispose()\n * ```\n */\nexport function createStoreInstance<TState, TKey extends {name: string}>(\n instance: SanityInstance,\n key: TKey,\n {name, getInitialState, initialize, upstream}: StoreDefinition<TState, TKey>,\n): StoreInstance<TState> {\n const state = createStoreState(getInitialState(instance, key), {\n enabled: !!getEnv('DEV'),\n name: `${name}-${key.name}`,\n })\n const dispose = initialize?.({state, instance, key})\n const disposed = {current: false}\n\n const disposed$ = new Subject<void>()\n let upstreamError: {error: unknown} | undefined\n let upstreamErrorTimer: ReturnType<typeof setTimeout> | undefined\n\n const upstream$ = upstream\n ? new Observable<never>((subscriber) => {\n if (disposed.current) return subscriber.complete()\n clearTimeout(upstreamErrorTimer)\n try {\n const subscription = upstream({state, instance, key})\n upstreamError = undefined\n return subscription\n } catch (error) {\n upstreamError = {error}\n // Kept for as long as a connection would stay open: long enough for a reader that\n // never subscribes (Suspense) to reach its error boundary, short enough that the\n // next mount opens again, as it did when a failed store was never kept\n upstreamErrorTimer = setCleanupTimeout(() => {\n upstreamError = undefined\n }, UPSTREAM_CLOSE_DELAY_MS)\n throw error\n }\n }).pipe(\n takeUntil(disposed$),\n share({\n resetOnComplete: false,\n resetOnRefCountZero: () => cleanupTimer(UPSTREAM_CLOSE_DELAY_MS),\n }),\n )\n : EMPTY\n\n return {\n state,\n upstream$,\n upstreamError: () => upstreamError,\n dispose: () => {\n if (disposed.current) return\n disposed.current = true\n // Before initialize's cleanup, which may own what upstream depends on\n disposed$.next()\n dispose?.()\n },\n isDisposed: () => disposed.current,\n }\n}\n","import {type ClientPerspective} from '@sanity/client'\n\nimport {\n type DatasetHandle,\n type DocumentResource,\n isCanvasResource,\n isDatasetResource,\n isMediaLibraryResource,\n type ReleasePerspective,\n} from '../config/sanityConfig'\nimport {isReleasePerspective} from '../releases/utils/isReleasePerspective'\nimport {type SanityInstance} from './createSanityInstance'\nimport {createStoreInstance, type StoreInstance} from './createStoreInstance'\nimport {type StoreState} from './createStoreState'\nimport {type StoreContext, type StoreDefinition} from './defineStore'\n\nexport interface BoundResourceKey {\n name: string\n resource: DocumentResource\n}\nexport interface BoundPerspectiveKey extends BoundResourceKey {\n perspective: ClientPerspective | ReleasePerspective\n}\n/**\n * Defines a store action that operates on a specific state type\n */\nexport type StoreAction<TState, TParams extends unknown[], TReturn, TKey = unknown> = (\n context: StoreContext<TState, TKey>,\n ...params: TParams\n) => TReturn\n\n/**\n * Represents a store action that has been bound to a specific store instance\n */\nexport type BoundStoreAction<_TState, TParams extends unknown[], TReturn> = (\n instance: SanityInstance,\n ...params: TParams\n) => TReturn\n\n/**\n * Creates an action binder function that uses the provided key function\n * to determine how store instances are shared between Sanity instances\n *\n * @param keyFn - Function that generates a key from a Sanity config\n * @returns A function that binds store actions to Sanity instances\n *\n * @remarks\n * Action binders determine how store instances are shared across multiple\n * Sanity instances. The key function determines which instances share state.\n *\n * @example\n * ```ts\n * // Create a custom binder that uses a tenant ID for isolation\n * const bindActionByTenant = createActionBinder(config => config.tenantId || 'default')\n *\n * // Use the custom binder with a store definition\n * const getTenantUsers = bindActionByTenant(\n * userStore,\n * ({state}) => state.get().users\n * )\n * ```\n */\nexport function createActionBinder<\n TKey extends {name: string},\n TKeyParams extends unknown[] = unknown[],\n>(keyFn: (instance: SanityInstance, ...params: TKeyParams) => TKey) {\n const instanceRegistry = new Map<string, Set<string>>()\n const storeRegistry = new Map<string, StoreInstance<unknown>>()\n\n /**\n * Binds a store action to a store definition\n *\n * @param storeDefinition - The store definition\n * @param action - The action to bind\n * @returns A function that executes the action with a Sanity instance\n */\n return function bindAction<TState, TParams extends TKeyParams, TReturn>(\n storeDefinition: StoreDefinition<TState, TKey>,\n action: StoreAction<TState, TParams, TReturn, TKey>,\n ): BoundStoreAction<TState, TParams, TReturn> {\n return function boundAction(instance: SanityInstance, ...params: TParams) {\n const key = keyFn(instance, ...params)\n const compositeKey = storeDefinition.name + (key.name ? `:${key.name}` : '')\n\n // Get or create instance set for this composite key\n let instances = instanceRegistry.get(compositeKey)\n if (!instances) {\n instances = new Set<string>()\n instanceRegistry.set(compositeKey, instances)\n }\n\n // Register instance for disposal tracking\n if (!instances.has(instance.instanceId)) {\n instances.add(instance.instanceId)\n instance.onDispose(() => {\n instances.delete(instance.instanceId)\n\n // Clean up when last instance is disposed\n if (instances.size === 0) {\n storeRegistry.get(compositeKey)?.dispose()\n storeRegistry.delete(compositeKey)\n instanceRegistry.delete(compositeKey)\n }\n })\n }\n\n // Get or create store instance\n let storeInstance = storeRegistry.get(compositeKey)\n if (!storeInstance) {\n storeInstance = createStoreInstance(instance, key, storeDefinition)\n storeRegistry.set(compositeKey, storeInstance)\n }\n\n // Execute action with store context\n return action(\n {\n instance,\n state: storeInstance.state as StoreState<TState>,\n key,\n upstream$: storeInstance.upstream$,\n upstreamError: storeInstance.upstreamError,\n },\n ...params,\n )\n }\n }\n}\n\nconst createResourceKey = (\n instance: SanityInstance,\n resource?: DocumentResource,\n): BoundResourceKey => {\n let name: string | undefined\n let resourceForKey: DocumentResource | undefined\n // A per-call resource wins; otherwise use the instance's default resource.\n const effectiveResource = resource ?? instance.config.resource\n if (effectiveResource) {\n resourceForKey = effectiveResource\n if (isDatasetResource(effectiveResource)) {\n name = `${effectiveResource.projectId}.${effectiveResource.dataset}`\n } else if (isMediaLibraryResource(effectiveResource)) {\n name = `media-library:${effectiveResource.mediaLibraryId}`\n } else if (isCanvasResource(effectiveResource)) {\n name = `canvas:${effectiveResource.canvasId}`\n } else {\n throw new Error(`Received invalid resource: ${JSON.stringify(effectiveResource)}`)\n }\n return {name, resource: resourceForKey}\n }\n\n // `projectId`/`dataset` on the config are shorthand for a dataset resource.\n const {projectId, dataset} = instance.config\n if (!projectId || !dataset) {\n throw new Error('This API requires a project ID and dataset configured.')\n }\n return {name: `${projectId}.${dataset}`, resource: {projectId, dataset}}\n}\n\n/**\n * Binds an action to a store that's scoped to a specific document resource.\n **/\nexport const bindActionByResource = createActionBinder<\n BoundResourceKey,\n // `resource` is optional because it falls back to the instance config in\n // `createResourceKey` — see the note there on why that fallback still exists.\n [{resource?: DocumentResource}, ...unknown[]]\n>((instance, {resource}) => {\n return createResourceKey(instance, resource)\n})\n\n/**\n * Binds an action to a store that's scoped to a specific document resource and perspective.\n *\n * @remarks\n * This creates actions that operate on state isolated to a specific document resource and perspective.\n * Different document resources and perspectives will have separate states.\n *\n * This is mostly useful for stores that do batch fetching operations, since the query store\n * can isolate single queries by perspective.\n *\n * @throws Error if resource or perspective is missing from the Sanity instance config\n *\n * @example\n * ```ts\n * // Define a store\n * const documentStore = defineStore<DocumentState>({\n * name: 'Document',\n * getInitialState: () => ({ documents: {} }),\n * // ...\n * })\n *\n * // Create resource-and-perspective-specific actions\n * export const fetchDocuments = bindActionByResourceAndPerspective(\n * documentStore,\n * ({instance, state}, documentId) => {\n * // This state is isolated to the specific document resource and perspective\n * // ...fetch logic...\n * }\n * )\n *\n * // Usage\n * fetchDocument(sanityInstance, 'doc123')\n * ```\n */\nexport const bindActionByResourceAndPerspective = createActionBinder<\n BoundPerspectiveKey,\n [DatasetHandle, ...unknown[]]\n>((instance, options): BoundPerspectiveKey => {\n const {resource, perspective} = options\n // Same trade-off as the resource fallback in `createResourceKey`: configured once on the\n // instance rather than passed to every call. Kept for the same reason.\n const utilizedPerspective = perspective ?? instance.config.perspective ?? 'drafts'\n let perspectiveKey: string\n if (isReleasePerspective(utilizedPerspective)) {\n perspectiveKey = utilizedPerspective.releaseName\n } else if (typeof utilizedPerspective === 'string') {\n perspectiveKey = utilizedPerspective\n } else {\n // \"StackablePerspective\", shouldn't be a common case, but just in case\n perspectiveKey = JSON.stringify(utilizedPerspective)\n }\n const sourceKey = createResourceKey(instance, resource)\n\n return {\n name: `${sourceKey.name}:${perspectiveKey}`,\n resource: sourceKey.resource,\n perspective: utilizedPerspective,\n }\n})\n\n/**\n * Binds an action to a global store that's shared across all Sanity instances\n *\n * @remarks\n * This creates actions that operate on state shared globally across all Sanity instances.\n * Use this for features like authentication where the state should be the same\n * regardless of which project or dataset is being used.\n *\n * @example\n * ```ts\n * // Define a store\n * const authStore = defineStore<AuthState>({\n * name: 'Auth',\n * getInitialState: () => ({\n * user: null,\n * isAuthenticated: false\n * }),\n * // ...\n * })\n *\n * // Create global actions\n * export const getCurrentUser = bindActionGlobally(\n * authStore,\n * ({state}) => state.get().user\n * )\n *\n * export const login = bindActionGlobally(\n * authStore,\n * ({state, instance}, credentials) => {\n * // Login logic that affects global state\n * // ...\n * }\n * )\n *\n * // Usage with any instance\n * getCurrentUser(sanityInstance)\n * ```\n */\nexport const bindActionGlobally = createActionBinder((..._rest) => ({name: 'global'}))\n","import {\n defer,\n distinctUntilChanged,\n finalize,\n map,\n merge,\n Observable,\n shareReplay,\n skip,\n} from 'rxjs'\n\nimport {type StoreAction} from './createActionBinder'\nimport {type SanityInstance} from './createSanityInstance'\nimport {type StoreContext} from './defineStore'\n\n/**\n * Represents a reactive state source that provides synchronized access to store data\n *\n * @remarks\n * Designed to work with React's useSyncExternalStore hook. Provides three ways to access data:\n * 1. `getCurrent()` for synchronous current value access\n * 2. `subscribe()` for imperative change notifications\n * 3. `observable` for reactive stream access\n *\n * @public\n */\nexport interface StateSource<T> {\n /**\n * Subscribes to state changes with optional callback\n * @param onStoreChanged - Called whenever relevant state changes occur\n * @returns Unsubscribe function to clean up the subscription\n */\n subscribe: (onStoreChanged?: () => void) => () => void\n\n /**\n * Gets the current derived state value\n *\n * @remarks\n * Safe to call without subscription. Will always return the latest value\n * based on the current store state and selector parameters.\n */\n getCurrent: () => T\n\n /**\n * Observable stream of state values\n *\n * @remarks\n * Shares a single underlying subscription between all observers. Emits:\n * - Immediately with current value on subscription\n * - On every relevant state change\n * - Errors if selector throws\n */\n observable: Observable<T>\n}\n\n/**\n * Context passed to selectors when deriving state\n *\n * @remarks\n * Provides access to both the current state value and the Sanity instance,\n * allowing selectors to use configuration values when computing derived state.\n * The context is memoized for each state object and instance combination\n * to optimize performance and prevent unnecessary recalculations.\n *\n * @example\n * ```ts\n * // Using both state and instance in a selector (psuedo example)\n * const getUserByProjectId = createStateSourceAction(\n * ({ state, instance }: SelectorContext<UsersState>, options?: ProjectHandle) => {\n * const allUsers = state.users\n * const projectId = options?.projectId ?? instance.config.projectId\n * return allUsers.filter(user => user.projectId === projectId)\n * }\n * )\n * ```\n */\nexport interface SelectorContext<TState> {\n /**\n * The current state object from the store\n */\n state: TState\n\n /**\n * The Sanity instance associated with this state\n */\n instance: SanityInstance\n}\n\n/**\n * Function type for selecting derived state from store state and parameters\n * @public\n */\nexport type Selector<TState, TParams extends unknown[], TReturn> = (\n context: SelectorContext<TState>,\n ...params: TParams\n) => TReturn\n\n/**\n * Configuration options for creating a state source action\n */\ninterface StateSourceOptions<TState, TParams extends unknown[], TReturn, TKey> {\n /**\n * Selector function that derives the desired value from store state\n *\n * @remarks\n * Will be called on every store change. Should be pure function.\n * Thrown errors will propagate to observable subscribers.\n */\n selector: Selector<TState, TParams, TReturn>\n\n /**\n * Optional setup/cleanup handler for subscriptions\n *\n * @param context - Store context containing state and instance\n * @param params - Action parameters provided during invocation\n * @returns Optional cleanup function called when subscription ends\n */\n onSubscribe?: (context: StoreContext<TState, TKey>, ...params: TParams) => void | (() => void)\n\n /**\n * Equality function to prevent unnecessary updates\n */\n isEqual?: (prev: TReturn, curr: TReturn) => boolean\n}\n\n/**\n * Creates a state source action that generates StateSource instances\n *\n * @remarks\n * The returned action can be bound to a store using createActionBinder.\n * When invoked, returns a StateSource that stays synchronized with the store.\n *\n * Key performance features:\n * - Memoizes selector contexts to prevent redundant object creation\n * - Only runs selectors when the underlying state changes\n *\n * For complex data transformations, consider using memoized selectors\n * (like those from Reselect) to prevent expensive recalculations.\n *\n * @example\n * ```ts\n * // Create a simple counter source\n * const getCount = createStateSourceAction(({state}: SelectorContext<CounterState>) => state.count)\n * ```\n *\n * @example\n * ```ts\n * // Create a parameterized source with setup/cleanup\n * const getItem = createStateSourceAction({\n * selector: ({state}, index: number) => state.items[index],\n * onSubscribe: (context, index) => {\n * trackItemSubscription(index)\n * return () => untrackItem(index)\n * }\n * })\n * ```\n *\n * @example\n * ```ts\n * // Binding a state source to a specific store\n * const documentStore = defineStore<DocumentState>({\n * name: 'Documents',\n * getInitialState: () => ({ documents: {} }),\n * // ...\n * })\n *\n * const getDocument = bindActionByResource(\n * documentStore,\n * createStateSourceAction(({state}, documentId: string) => state.documents[documentId])\n * )\n *\n * // Usage\n * const documentSource = getDocument(sanityInstance, 'doc123')\n * const doc = documentSource.getCurrent()\n * const subscription = documentSource.observable.subscribe(updatedDoc => {\n * console.log('Document changed:', updatedDoc)\n * })\n * ```\n */\nexport function createStateSourceAction<TState, TParams extends unknown[], TReturn, TKey = unknown>(\n options: Selector<TState, TParams, TReturn> | StateSourceOptions<TState, TParams, TReturn, TKey>,\n): StoreAction<TState, TParams, StateSource<TReturn>, TKey> {\n const selector = typeof options === 'function' ? options : options.selector\n const subscribeHandler = options && 'onSubscribe' in options ? options.onSubscribe : undefined\n const isEqual = options && 'isEqual' in options ? (options.isEqual ?? Object.is) : Object.is\n const selectorContextCache = new WeakMap<\n object,\n WeakMap<SanityInstance, SelectorContext<TState>>\n >()\n\n /**\n * The state source action implementation\n * @param context - Store context providing access to state and instance\n * @param params - Parameters provided when invoking the bound action\n */\n function stateSourceAction(context: StoreContext<TState, TKey>, ...params: TParams) {\n const {state, instance} = context\n\n const getCurrent = (currentState: TState) => {\n if (typeof currentState !== 'object' || currentState === null) {\n throw new Error(\n `Expected store state to be an object but got \"${typeof currentState}\" instead`,\n )\n }\n\n let instanceCache = selectorContextCache.get(currentState)\n if (!instanceCache) {\n instanceCache = new WeakMap<SanityInstance, SelectorContext<TState>>()\n selectorContextCache.set(currentState, instanceCache)\n }\n let selectorContext = instanceCache.get(instance)\n if (!selectorContext) {\n selectorContext = {state: currentState, instance}\n instanceCache.set(instance, selectorContext)\n }\n return selector(selectorContext, ...params)\n }\n\n // `state.observable` will emit the current value immediately and\n // hence we inherit the same behavior here.\n let values = state.observable.pipe(map(getCurrent), distinctUntilChanged(isEqual))\n\n if (subscribeHandler) {\n values = withSubscribeHook(values, () => subscribeHandler(context, ...params))\n }\n // Before `shareReplay`, so each source holds upstream once however many subscribe to it\n if (context.upstream$) values = merge(values, context.upstream$)\n\n // Share but replay the latest value so every subscriber gets an\n // initial synchronous emission, matching `state.observable`. That keeps\n // `skip(1)` in `subscribe()` aligned with \"skip current snapshot\" rather than\n // silently eating the first real update after multicasting.\n const sharedValues = values.pipe(shareReplay({bufferSize: 1, refCount: true}))\n\n const subscribe = (onStoreChanged?: () => void) => {\n const subscription = sharedValues.pipe(skip(1)).subscribe({\n next: () => onStoreChanged?.(),\n // Propagate selector errors to both subscription types\n error: () => onStoreChanged?.(),\n })\n\n return () => {\n subscription.unsubscribe()\n }\n }\n\n return {\n getCurrent: () => {\n // The subscribe error handler above re-renders on a failed open, and relies on this throwing\n const upstreamError = context.upstreamError?.()\n if (upstreamError) throw upstreamError.error\n return getCurrent(state.get())\n },\n subscribe,\n observable: sharedValues,\n }\n }\n\n return stateSourceAction\n}\n\n/**\n * Creates a new Observable which wraps an existing Observable which will invoke\n * the function when a new subscriber appears.\n */\nfunction withSubscribeHook<T>(obs: Observable<T>, fn: () => void | (() => void)): Observable<T> {\n return defer(() => {\n const cleanup = fn()\n return cleanup ? obs.pipe(finalize(() => cleanup())) : obs\n })\n}\n"],"mappings":";;;;;;;AAmNA,SAAgB,kBAAkB,UAAyD;CACzF,OAAO,eAAe,YAAY,aAAa;AACjD;;;;AAKA,SAAgB,uBACd,UACkC;CAClC,OAAO,oBAAoB;AAC7B;;;;AAKA,SAAgB,iBAAiB,UAAwD;CACvF,OAAO,cAAc;AACvB;ACnOA,MAAa,wBACX,gBAEO,OAAO,eAAgB,cAAY,eAAwB,iBAAiB;ACGrF,SAAgB,OAAO,KAA2B;CAChD,IAA0C,YAAY,KAEpD,OAAQ,YAAY,IAA2C;CAC1D,IAAI,OAAO,UAAY,OAAe,QAAQ,KAEnD,OAAO,QAAQ,IAAI;CACd,IAAI,OAAO,SAAW,OAAgB,OAAyB,KAEpE,OAAQ,OAAyB,MAAM;AAG3C;ACfA,SAAS,MAAM,OAA6E;CAC1F,IAAM,IAAa;CACnB,AAAI,OAAO,KAAM,YAAY,KAAc,WAAW,KAAK,OAAO,EAAE,SAAU,cAC5E,EAAE,MAAM;AAEZ;;;;;;;;;;;;AAaA,SAAgB,kBAAkB,IAAgB,OAA8C;CAC9F,IAAM,QAAQ,WAAW,IAAI,KAAK;CAElC,OADA,MAAM,KAAK,GACJ;AACT;;;;;;AAOA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A,OAAO;GACL,kBAAkB;IAEhB,IAAM,gBAAgB,QAAQ,gBAAgB;IAC9C,IAAI,eAAe,MAAM,cAAc;IACvC,OAAO,WAAW,MAAM,IAAI,CAAC;GAC/B;GACA;GACA,YAAY;EACd;CACF;CAEA,OAAO;AACT;;;;;AAMA,SAAS,kBAAqB,KAAoB,IAA8C;CAC9F,OAAO,YAAY;EACjB,IAAM,UAAU,GAAG;EACnB,OAAO,UAAU,IAAI,KAAK,eAAe,QAAQ,CAAC,CAAC,IAAI;CACzD,CAAC;AACH"}
|
package/dist/{createStateSourceAction-CzAwbNjw.d.ts → createStateSourceAction-Cb7ZjAd8.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SanityInstance } from "./createSanityInstance-
|
|
1
|
+
import { t as SanityInstance } from "./createSanityInstance-C1wD7RmA.js";
|
|
2
2
|
import { ClientPerspective } from "@sanity/client";
|
|
3
3
|
import { Observable, Subscription } from "rxjs";
|
|
4
4
|
import "zustand/middleware";
|
|
@@ -150,4 +150,4 @@ interface SelectorContext<TState> {
|
|
|
150
150
|
*/
|
|
151
151
|
type Selector<TState, TParams extends unknown[], TReturn> = (context: SelectorContext<TState>, ...params: TParams) => TReturn;
|
|
152
152
|
export { StoreAction as i, StateSource as n, BoundStoreAction as r, Selector as t };
|
|
153
|
-
//# sourceMappingURL=createStateSourceAction-
|
|
153
|
+
//# sourceMappingURL=createStateSourceAction-Cb7ZjAd8.d.ts.map
|
package/dist/{createStateSourceAction-CzAwbNjw.d.ts.map → createStateSourceAction-Cb7ZjAd8.d.ts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createStateSourceAction-
|
|
1
|
+
{"version":3,"file":"createStateSourceAction-Cb7ZjAd8.d.ts","names":[],"sources":["../src/store/createStoreState.ts","../src/store/defineStore.ts","../src/store/createActionBinder.ts","../src/store/createStateSourceAction.ts"],"mappings":";;;;;;;UAOiB,WAAW;;;;;;;EAO1B,WAAW;;;;;;;;;;EAWX,MAAM,cAAc,cAAc,QAAQ,YAAY,GAAG,WAAW,QAAQ;;;;;;;;;EAU5E,YAAY,WAAW;;;;;UC3BR,aAAa,QAAQ;;;;;;;EAOpC,UAAU;;;;;;;EAQV,OAAO,WAAW;;;;EAKlB,KAAK;;;;;EAML,YAAY;;;;;EAMZ;IAAuB;;;;;;KCdb,YAAY,QAAQ,2BAA2B,SAAS,mBAClE,SAAS,aAAa,QAAQ,UAC3B,QAAQ,YACR;;;;KAKO,iBAAiB,SAAS,2BAA2B,YAC/D,UAAU,mBACP,QAAQ,YACR;;;;;;;;;;;;UCXY,YAAY;;;;;;EAM3B,YAAY;;;;;;;;EASZ,kBAAkB;;;;;;;;;;EAWlB,YAAY,WAAW;;;;;;;;;;;;;;;;;;;;;;;UAwBR,gBAAgB;;;;EAI/B,OAAO;;;;EAKP,UAAU;;;;;;KAOA,SAAS,QAAQ,2BAA2B,YACtD,SAAS,gBAAgB,YACtB,QAAQ,YACR"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as isCanvasResource, a as DatasetResource, b as AuthConfig, c as DocumentTypeHandle, d as ProjectHandle, f as ReleaseHandle, g as TokenSource, h as StudioConfig, i as DatasetHandle, l as MediaLibraryResource, m as SanityConfig, n as createSanityInstance, o as DocumentHandle, p as ReleasePerspective, r as CanvasResource, s as DocumentResource, t as SanityInstance, u as PerspectiveHandle, v as isDatasetResource, x as AuthProvider, y as isMediaLibraryResource } from "./createSanityInstance-
|
|
2
|
-
import { n as StateSource, t as Selector } from "./createStateSourceAction-
|
|
3
|
-
import { $ as getProjectionState, $i as CommentMessage, $n as DiscardDocumentAction, $t as PreferenceLevelsOf, A as stringifyPath, Aa as getIsInDashboardState, Ai as createDocumentHandle, An as TransactionAcceptedEvent, At as ResolveUserOptions, B as defineProjection, Bn as DocumentPermissionsResult, Bt as updateUserPreferenceListItem, C as SanityDocument, Ca as AuthStoreState, Ci as LogContext, Cn as DocumentDiscardedEvent, Cr as unpublishDocument, Ct as RollCallEvent, D as joinPaths, Da as LoggingInAuthState, Di as LoggerConfig, Dn as DocumentRemotePatchesEvent, Dr as ResolveQueryResult, Dt as GetUserOptions, E as getPathDepth, Ea as LoggedOutAuthState, Ei as Logger, En as DocumentPublishedEvent, Er as ResolveProjectionResult, Et as UserPresence, F as getUsersState, Fa as AuthStateType, Fi as resolveCommentThreads, Fn as getDocumentSyncStatus, Ft as UsersGroupState, G as QueryOptions, Gi as UpdateCommentOptions, Gn as processMutations, Gt as UserPreferenceOrganizationOptions, H as ReleaseState, Hi as RemoveCommentOptions, Hn as DocumentSet, Ht as UpdateUserPreferenceInput, I as loadMoreUsers, Ia as AccessResourceType, Ii as resolveComments, In as getPermissionsState, It as UsersStoreState, Ji as replyToComment, Jn as ArchiveReleaseAction, Jt as updateUserPreference, Ki as createComment, Kn as JsonMatch, Kt as UserPreferenceProjectOptions, L as resolveUser, La as checkPermissions, Li as CommentsOptions, Ln as resolveDocument, Lt as UpdateUserPreferenceListItemInput, M as isImportError, Ma as getTokenState, Mi as createProjectHandle, Mn as TransactionSubmissionFailedEvent, Mt as SanityUser, N as getCorsErrorProjectId, Na as setAuthToken, Ni as getCommentThreadsState, Nn as DocumentOptions, Nt as SanityUserResponse, O as jsonMatch, Oa as getAuthState, On as DocumentTransactionSubmissionResult, Or as datasets, Ot as GetUsersOptions, P as getUserState, Pa as OAuthTokens, Pi as getCommentsState, Pn as getDocumentState, Pt as UserProfile, Q as resolveProjection, Qi as CommentLocalState, Qn as DeleteReleaseAction, Qt as PreferenceKey, R as resolveUsers, Ri as ResolveCommentsOptions, Rn as resolvePermissions, Rt as UserPreferenceListItem, S as Role, Sa as AuthState, Si as InstanceContext, Sn as DocumentDeletedEvent, Sr as unarchiveRelease, St as ReportPresenceOptions, T as getIndexForKey, Ta as LoggedInAuthState, Ti as LogNamespace, Tn as DocumentEvent, Tr as ResolveDocument, Tt as TransportEvent, U as getActiveReleasesState, Ui as ReplyToCommentOptions, Un as ProcessMutationsOptions, Ut as UserPreference, V as getPerspectiveState, Vi as CreateCommentOptions, Vn as PermissionDeniedReason, Vt as userPreferenceList, W as getAllReleasesState, Wi as SetCommentStatusOptions, Wn as patchOperations, Wt as UserPreferenceOptions, X as ProjectsOptions, Xi as updateComment, Xn as CreateReleaseAction, Xt as whenOrganizationKnown, Y as resolveQuery, Yi as setCommentStatus, Yn as CreateDocumentAction, Yt as userPreference, Z as projects, Zi as Comment, Zn as DeleteDocumentAction, Zt as PreferenceEdit, _ as applications, _a as startOAuthAuthorization, _i as InstallationsOptions, _n as ActionsResult, _r as editDocument, _t as DocumentPresenceOptions, a as ApplicationInclude, aa as ClientOptions, an as StoredLevel, ar as PublishReleaseAction, at as ProjectOptions, b as CurrentUser, ba as observeOrganizationVerificationState, bi as installations, bn as ActionErrorEvent, br as publishRelease, bt as PresenceSelection, c as ApplicationStudioConfig, ca as getClientState, ci as OrganizationBase, cn as Organizations, cr as UnarchiveReleaseAction, ct as PreviewQueryResult, d as ApplicationsOptions, da as getProjectAccessErrorProjectId, di as organization, dn as FavoriteDocumentContext, dr as archiveRelease, dt as ProjectionValuePending, ea as CommentReaction, en as PreferenceListItem, er as DocumentAction, et as Project, f as ApplicationsResponse, fi as Installation, fn as FavoriteStatusResponse, fr as createDocument, ft as getDocumentPresence, g as application, ga as revokeOAuthTokens, gi as InstallationInclude, gn as getReleaseDocumentId, gr as discardDocument, gt as DocumentPresence, h as UpdateApplicationInput, ha as refreshOAuthTokens, hi as InstallationBase, hn as setFavorite, hr as deleteRelease, ht as DisconnectEvent, i as ApplicationDeployment, ia as CommentThread, in as PreferenceValue, ir as PublishDocumentAction, it as ProjectMetadata, j as CORE_SDK_VERSION, ja as getLoginUrlState, ji as createDocumentTypeHandle, jn as TransactionRevertedEvent, jr as getDashboardOrganizationId, jt as ResolveUsersOptions, k as slicePath, ka as getCurrentUserState, ki as createDatasetHandle, kn as DocumentUnpublishedEvent, kt as Membership, l as ApplicationVisibility, li as OrganizationMember, ln as OrganizationsOptions, lr as UnpublishDocumentAction, lt as PreviewValue, m as DeletedResult, ma as handleOAuthCallback, mi as InstallationActiveConfig, mn as favorites, mr as deleteDocument, mt as reportPresence, n as ApplicationAccess, na as CommentTextSelection, nn as PreferenceListKey, nr as EditDocumentOptions, nt as ProjectMember, o as ApplicationInterface, oa as ClientStoreState, on as PreferenceError, or as ReleaseAction, ot as project, p as DeleteApplicationInput, pa as getOAuthTokensState, pi as InstallationAccess, pn as SetFavoriteInput, pr as createRelease, pt as getPresence, q as getQueryState, qi as removeComment, qn as Action, qt as UserPreferenceUserOptions, r as ApplicationBase, ra as CommentTextSelectionItem, rn as PreferenceResourceType, rr as EditReleaseAction, rt as ProjectMemberRole, s as ApplicationInterfacePlacementMetadata, sa as getClient, si as Organization, sn as PreferenceErrorCode, sr as ScheduleReleaseAction, st as PreviewMedia, t as Application, ta as CommentStatus, tn as PreferenceListItemValue, tr as EditDocumentAction, tt as ProjectBase, u as ApplicationWorkspace, ui as OrganizationOptions, un as organizations, ur as UnscheduleReleaseAction, ut as DocumentStatus, v as deleteApplication, va as logout, vi as InstallationsResponse, vn as ApplyDocumentActionsOptions, vr as editRelease, vt as PresenceLocation, w as SanityProject, wa as ErrorAuthState, wi as LogLevel, wn as DocumentEditedEvent, wr as unscheduleRelease, wt as StateEvent, x as ReleaseDocument, xa as OrgVerificationResult, xi as configureLogging, xn as DocumentCreatedEvent, xr as scheduleRelease, xt as PresenceSelectionPoint, y as updateApplication, ya as handleAuthCallback, yi as installation, yn as applyDocumentActions, yr as publishDocument, yt as PresencePerspectiveOptions, z as users, zn as subscribeDocumentEvents, zt as UserPreferenceListPage } from "./applications-
|
|
1
|
+
import { _ as isCanvasResource, a as DatasetResource, b as AuthConfig, c as DocumentTypeHandle, d as ProjectHandle, f as ReleaseHandle, g as TokenSource, h as StudioConfig, i as DatasetHandle, l as MediaLibraryResource, m as SanityConfig, n as createSanityInstance, o as DocumentHandle, p as ReleasePerspective, r as CanvasResource, s as DocumentResource, t as SanityInstance, u as PerspectiveHandle, v as isDatasetResource, x as AuthProvider, y as isMediaLibraryResource } from "./createSanityInstance-C1wD7RmA.js";
|
|
2
|
+
import { n as StateSource, t as Selector } from "./createStateSourceAction-Cb7ZjAd8.js";
|
|
3
|
+
import { $ as getProjectionState, $i as CommentMessage, $n as DiscardDocumentAction, $t as PreferenceLevelsOf, A as stringifyPath, Aa as getIsInDashboardState, Ai as createDocumentHandle, An as TransactionAcceptedEvent, At as ResolveUserOptions, B as defineProjection, Bn as DocumentPermissionsResult, Bt as updateUserPreferenceListItem, C as SanityDocument, Ca as AuthStoreState, Ci as LogContext, Cn as DocumentDiscardedEvent, Cr as unpublishDocument, Ct as RollCallEvent, D as joinPaths, Da as LoggingInAuthState, Di as LoggerConfig, Dn as DocumentRemotePatchesEvent, Dr as ResolveQueryResult, Dt as GetUserOptions, E as getPathDepth, Ea as LoggedOutAuthState, Ei as Logger, En as DocumentPublishedEvent, Er as ResolveProjectionResult, Et as UserPresence, F as getUsersState, Fa as AuthStateType, Fi as resolveCommentThreads, Fn as getDocumentSyncStatus, Ft as UsersGroupState, G as QueryOptions, Gi as UpdateCommentOptions, Gn as processMutations, Gt as UserPreferenceOrganizationOptions, H as ReleaseState, Hi as RemoveCommentOptions, Hn as DocumentSet, Ht as UpdateUserPreferenceInput, I as loadMoreUsers, Ia as AccessResourceType, Ii as resolveComments, In as getPermissionsState, It as UsersStoreState, Ji as replyToComment, Jn as ArchiveReleaseAction, Jt as updateUserPreference, Ki as createComment, Kn as JsonMatch, Kt as UserPreferenceProjectOptions, L as resolveUser, La as checkPermissions, Li as CommentsOptions, Ln as resolveDocument, Lt as UpdateUserPreferenceListItemInput, M as isImportError, Ma as getTokenState, Mi as createProjectHandle, Mn as TransactionSubmissionFailedEvent, Mt as SanityUser, N as getCorsErrorProjectId, Na as setAuthToken, Ni as getCommentThreadsState, Nn as DocumentOptions, Nt as SanityUserResponse, O as jsonMatch, Oa as getAuthState, On as DocumentTransactionSubmissionResult, Or as datasets, Ot as GetUsersOptions, P as getUserState, Pa as OAuthTokens, Pi as getCommentsState, Pn as getDocumentState, Pt as UserProfile, Q as resolveProjection, Qi as CommentLocalState, Qn as DeleteReleaseAction, Qt as PreferenceKey, R as resolveUsers, Ri as ResolveCommentsOptions, Rn as resolvePermissions, Rt as UserPreferenceListItem, S as Role, Sa as AuthState, Si as InstanceContext, Sn as DocumentDeletedEvent, Sr as unarchiveRelease, St as ReportPresenceOptions, T as getIndexForKey, Ta as LoggedInAuthState, Ti as LogNamespace, Tn as DocumentEvent, Tr as ResolveDocument, Tt as TransportEvent, U as getActiveReleasesState, Ui as ReplyToCommentOptions, Un as ProcessMutationsOptions, Ut as UserPreference, V as getPerspectiveState, Vi as CreateCommentOptions, Vn as PermissionDeniedReason, Vt as userPreferenceList, W as getAllReleasesState, Wi as SetCommentStatusOptions, Wn as patchOperations, Wt as UserPreferenceOptions, X as ProjectsOptions, Xi as updateComment, Xn as CreateReleaseAction, Xt as whenOrganizationKnown, Y as resolveQuery, Yi as setCommentStatus, Yn as CreateDocumentAction, Yt as userPreference, Z as projects, Zi as Comment, Zn as DeleteDocumentAction, Zt as PreferenceEdit, _ as applications, _a as startOAuthAuthorization, _i as InstallationsOptions, _n as ActionsResult, _r as editDocument, _t as DocumentPresenceOptions, a as ApplicationInclude, aa as ClientOptions, an as StoredLevel, ar as PublishReleaseAction, at as ProjectOptions, b as CurrentUser, ba as observeOrganizationVerificationState, bi as installations, bn as ActionErrorEvent, br as publishRelease, bt as PresenceSelection, c as ApplicationStudioConfig, ca as getClientState, ci as OrganizationBase, cn as Organizations, cr as UnarchiveReleaseAction, ct as PreviewQueryResult, d as ApplicationsOptions, da as getProjectAccessErrorProjectId, di as organization, dn as FavoriteDocumentContext, dr as archiveRelease, dt as ProjectionValuePending, ea as CommentReaction, en as PreferenceListItem, er as DocumentAction, et as Project, f as ApplicationsResponse, fi as Installation, fn as FavoriteStatusResponse, fr as createDocument, ft as getDocumentPresence, g as application, ga as revokeOAuthTokens, gi as InstallationInclude, gn as getReleaseDocumentId, gr as discardDocument, gt as DocumentPresence, h as UpdateApplicationInput, ha as refreshOAuthTokens, hi as InstallationBase, hn as setFavorite, hr as deleteRelease, ht as DisconnectEvent, i as ApplicationDeployment, ia as CommentThread, in as PreferenceValue, ir as PublishDocumentAction, it as ProjectMetadata, j as CORE_SDK_VERSION, ja as getLoginUrlState, ji as createDocumentTypeHandle, jn as TransactionRevertedEvent, jr as getDashboardOrganizationId, jt as ResolveUsersOptions, k as slicePath, ka as getCurrentUserState, ki as createDatasetHandle, kn as DocumentUnpublishedEvent, kt as Membership, l as ApplicationVisibility, li as OrganizationMember, ln as OrganizationsOptions, lr as UnpublishDocumentAction, lt as PreviewValue, m as DeletedResult, ma as handleOAuthCallback, mi as InstallationActiveConfig, mn as favorites, mr as deleteDocument, mt as reportPresence, n as ApplicationAccess, na as CommentTextSelection, nn as PreferenceListKey, nr as EditDocumentOptions, nt as ProjectMember, o as ApplicationInterface, oa as ClientStoreState, on as PreferenceError, or as ReleaseAction, ot as project, p as DeleteApplicationInput, pa as getOAuthTokensState, pi as InstallationAccess, pn as SetFavoriteInput, pr as createRelease, pt as getPresence, q as getQueryState, qi as removeComment, qn as Action, qt as UserPreferenceUserOptions, r as ApplicationBase, ra as CommentTextSelectionItem, rn as PreferenceResourceType, rr as EditReleaseAction, rt as ProjectMemberRole, s as ApplicationInterfacePlacementMetadata, sa as getClient, si as Organization, sn as PreferenceErrorCode, sr as ScheduleReleaseAction, st as PreviewMedia, t as Application, ta as CommentStatus, tn as PreferenceListItemValue, tr as EditDocumentAction, tt as ProjectBase, u as ApplicationWorkspace, ui as OrganizationOptions, un as organizations, ur as UnscheduleReleaseAction, ut as DocumentStatus, v as deleteApplication, va as logout, vi as InstallationsResponse, vn as ApplyDocumentActionsOptions, vr as editRelease, vt as PresenceLocation, w as SanityProject, wa as ErrorAuthState, wi as LogLevel, wn as DocumentEditedEvent, wr as unscheduleRelease, wt as StateEvent, x as ReleaseDocument, xa as OrgVerificationResult, xi as configureLogging, xn as DocumentCreatedEvent, xr as scheduleRelease, xt as PresenceSelectionPoint, y as updateApplication, ya as handleAuthCallback, yi as installation, yn as applyDocumentActions, yr as publishDocument, yt as PresencePerspectiveOptions, z as users, zn as subscribeDocumentEvents, zt as UserPreferenceListPage } from "./applications-D84Jz932.js";
|
|
4
4
|
export { type AccessResourceType, type Action, type ActionErrorEvent, type ActionsResult, type Application, type ApplicationAccess, type ApplicationBase, type ApplicationDeployment, type ApplicationInclude, type ApplicationInterface, type ApplicationInterfacePlacementMetadata, type ApplicationStudioConfig, type ApplicationVisibility, type ApplicationWorkspace, type ApplicationsOptions, type ApplicationsResponse, type ApplyDocumentActionsOptions, type ArchiveReleaseAction, type AuthConfig, type AuthProvider, type AuthState, AuthStateType, type AuthStoreState, CORE_SDK_VERSION, type CanvasResource, type ClientOptions, type ClientStoreState as ClientState, type Comment, type CommentLocalState, type CommentMessage, type CommentReaction, type CommentStatus, type CommentTextSelection, type CommentTextSelectionItem, type CommentThread, type CommentsOptions, type CreateCommentOptions, type CreateDocumentAction, type CreateReleaseAction, type CurrentUser, type DatasetHandle, type DatasetResource, type DeleteApplicationInput, type DeleteDocumentAction, type DeleteReleaseAction, type DeletedResult, type DiscardDocumentAction, type DisconnectEvent, type DocumentAction, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentDiscardedEvent, type DocumentEditedEvent, type DocumentEvent, type DocumentHandle, type DocumentOptions, type DocumentPermissionsResult, type DocumentPresence, type DocumentPresenceOptions, type DocumentPublishedEvent, type DocumentRemotePatchesEvent, type DocumentResource, type DocumentSet, type DocumentStatus, type DocumentTransactionSubmissionResult, type DocumentTypeHandle, type DocumentUnpublishedEvent, type EditDocumentAction, type EditDocumentOptions, type EditReleaseAction, type ErrorAuthState, type FavoriteDocumentContext, type FavoriteStatusResponse, type GetUserOptions, type GetUsersOptions, type Installation, type InstallationAccess, type InstallationActiveConfig, type InstallationBase, type InstallationInclude, type InstallationsOptions, type InstallationsResponse, type InstanceContext, type JsonMatch, type LogContext, type LogLevel, type LogNamespace, type LoggedInAuthState, type LoggedOutAuthState, type Logger, type LoggerConfig, type LoggingInAuthState, type MediaLibraryResource, type Membership, type OAuthTokens, type OrgVerificationResult, type Organization, type OrganizationBase, type OrganizationMember, type OrganizationOptions, type Organizations, type OrganizationsOptions, type PermissionDeniedReason, type PerspectiveHandle, type PreferenceEdit, PreferenceError, type PreferenceErrorCode, type PreferenceKey, type PreferenceLevelsOf, type PreferenceListItem, type PreferenceListItemValue, type PreferenceListKey, type PreferenceResourceType, type PreferenceValue, type PresenceLocation, type PresencePerspectiveOptions, type PresenceSelection, type PresenceSelectionPoint, type PreviewMedia, type PreviewQueryResult, type PreviewValue, type ProcessMutationsOptions, type Project, type ProjectBase, type ProjectHandle, type ProjectMember, type ProjectMemberRole, type ProjectMetadata, type ProjectOptions, type ProjectionValuePending, type ProjectsOptions, type PublishDocumentAction, type PublishReleaseAction, type QueryOptions, type ReleaseAction, type ReleaseDocument, type ReleaseHandle, type ReleasePerspective, type ReleaseState, type RemoveCommentOptions, type ReplyToCommentOptions, type ReportPresenceOptions, type ResolveCommentsOptions, type ResolveDocument, type ResolveProjectionResult, type ResolveQueryResult, type ResolveUserOptions, type ResolveUsersOptions, type Role, type RollCallEvent, type SanityConfig, type SanityDocument, type SanityInstance, SanityProject, type SanityUser, type SanityUserResponse, type ScheduleReleaseAction, type Selector, type SetCommentStatusOptions, type SetFavoriteInput, type StateEvent, type StateSource, type StoredLevel, type StudioConfig, type TokenSource, type TransactionAcceptedEvent, type TransactionRevertedEvent, type TransactionSubmissionFailedEvent, type TransportEvent, type UnarchiveReleaseAction, type UnpublishDocumentAction, type UnscheduleReleaseAction, type UpdateApplicationInput, type UpdateCommentOptions, type UpdateUserPreferenceInput, type UpdateUserPreferenceListItemInput, type UserPreference, type UserPreferenceListItem, type UserPreferenceListPage, type UserPreferenceOptions, type UserPreferenceOrganizationOptions, type UserPreferenceProjectOptions, type UserPreferenceUserOptions, type UserPresence, type UserProfile, type UsersGroupState, type UsersStoreState, application, applications, applyDocumentActions, archiveRelease, checkPermissions, configureLogging, createComment, createDatasetHandle, createDocument, createDocumentHandle, createDocumentTypeHandle, createProjectHandle, createRelease, createSanityInstance, datasets, defineProjection, deleteApplication, deleteDocument, deleteRelease, discardDocument, editDocument, editRelease, favorites, getActiveReleasesState, getAllReleasesState, getAuthState, getClient, getClientState, getCommentThreadsState, getCommentsState, getCorsErrorProjectId, getCurrentUserState, getDashboardOrganizationId, getDocumentPresence, getDocumentState, getDocumentSyncStatus, getIndexForKey, getIsInDashboardState, getLoginUrlState, getOAuthTokensState, getPathDepth, getPermissionsState, getPerspectiveState, getPresence, getProjectAccessErrorProjectId, getProjectionState, getQueryState, getReleaseDocumentId, getTokenState, getUserState, getUsersState, handleAuthCallback, handleOAuthCallback, installation, installations, isCanvasResource, isDatasetResource, isImportError, isMediaLibraryResource, joinPaths, jsonMatch, loadMoreUsers, logout, observeOrganizationVerificationState, organization, organizations, patchOperations, processMutations, project, projects, publishDocument, publishRelease, refreshOAuthTokens, removeComment, replyToComment, reportPresence, resolveCommentThreads, resolveComments, resolveDocument, resolvePermissions, resolveProjection, resolveQuery, resolveUser, resolveUsers, revokeOAuthTokens, scheduleRelease, setAuthToken, setCommentStatus, setFavorite, slicePath, startOAuthAuthorization, stringifyPath, subscribeDocumentEvents, unarchiveRelease, unpublishDocument, unscheduleRelease, updateApplication, updateComment, updateUserPreference, updateUserPreferenceListItem, userPreference, userPreferenceList, users, whenOrganizationKnown };
|