sanity 5.3.0-next.11 → 5.3.0-next.14

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.
@@ -96,7 +96,7 @@ function shouldAutoUpdate({
96
96
  return hasOldCliConfigFlag && output?.warn(chalk.yellow(`The \`autoUpdates\` config has moved to \`deployment.autoUpdates\`.
97
97
  Please update \`sanity.cli.ts\` or \`sanity.cli.js\` and make the following change:
98
98
  ${chalk.red(`- autoUpdates: ${cliConfig.autoUpdates},`)}
99
- ${chalk.green(`+ deployment: {autoUpdates: ${cliConfig.autoUpdates}}}`)}
99
+ ${chalk.green(`+ deployment: {autoUpdates: ${cliConfig.autoUpdates}},`)}
100
100
  `)), !!(hasOldCliConfigFlag ? cliConfig.autoUpdates : cliConfig?.deployment?.autoUpdates);
101
101
  }
102
102
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"shouldAutoUpdate.js","sources":["../../src/_internal/cli/util/getAutoUpdatesImportMap.ts","../../src/_internal/cli/util/compareDependencyVersions.ts","../../src/_internal/cli/util/shouldAutoUpdate.ts"],"sourcesContent":["const MODULES_HOST =\n process.env.SANITY_MODULES_HOST ||\n (process.env.SANITY_INTERNAL_ENV === 'staging'\n ? 'https://sanity-cdn.work'\n : 'https://sanity-cdn.com')\n\nfunction currentUnixTime(): number {\n return Math.floor(Date.now() / 1000)\n}\n\ntype Package = {version: string; name: string}\n/**\n * @internal\n */\nexport function getAutoUpdatesImportMap<const Pkg extends Package>(\n packages: Pkg[],\n options: {timestamp?: number; baseUrl?: string; appId?: string} = {},\n) {\n return Object.fromEntries(\n packages.flatMap((pkg) => getAppAutoUpdateImportMapForPackage(pkg, options)),\n ) as {[K in Pkg['name'] | `${Pkg['name']}/`]: string}\n}\n\nfunction getAppAutoUpdateImportMapForPackage<const Pkg extends Package>(\n pkg: Pkg,\n options: {timestamp?: number; baseUrl?: string; appId?: string} = {},\n): [[Pkg['name'], string], [`${Pkg['name']}/`, string]] {\n const moduleUrl = getModuleUrl(pkg, options)\n\n return [\n [pkg.name, moduleUrl],\n [`${pkg.name}/`, `${moduleUrl}/`],\n ]\n}\n\nexport function getModuleUrl(\n pkg: Package,\n options: {timestamp?: number; baseUrl?: string; appId?: string} = {},\n) {\n const {timestamp = currentUnixTime()} = options\n return options.appId\n ? getByAppModuleUrl(pkg, {appId: options.appId, baseUrl: options.baseUrl, timestamp})\n : getLegacyModuleUrl(pkg, {timestamp, baseUrl: options.baseUrl})\n}\n\nfunction getLegacyModuleUrl(pkg: Package, options: {timestamp: number; baseUrl?: string}) {\n const encodedMinVer = encodeURIComponent(`^${pkg.version}`)\n return `${options.baseUrl || MODULES_HOST}/v1/modules/${rewriteScopedPackage(pkg.name)}/default/${encodedMinVer}/t${options.timestamp}`\n}\n\nfunction getByAppModuleUrl(\n pkg: Package,\n options: {appId: string; baseUrl?: string; timestamp: number},\n) {\n const encodedMinVer = encodeURIComponent(`^${pkg.version}`)\n return `${options.baseUrl || MODULES_HOST}/v1/modules/by-app/${options.appId}/t${options.timestamp}/${encodedMinVer}/${rewriteScopedPackage(pkg.name)}`\n}\n\n/**\n * replaces '/' with '__' similar to how eg `@types/scope__pkg` are rewritten\n * scoped packages are stored this way both in the manifest and in the cloud storage bucket\n */\nfunction rewriteScopedPackage(pkgName: string) {\n if (!pkgName.includes('@')) {\n return pkgName\n }\n const [scope, ...pkg] = pkgName.split('/')\n return `${scope}__${pkg.join('')}`\n}\n","import path from 'node:path'\n\nimport resolveFrom from 'resolve-from'\nimport semver from 'semver'\n\nimport {getModuleUrl} from './getAutoUpdatesImportMap'\nimport {readPackageManifest} from './readPackageManifest'\n\nfunction getRemoteResolvedVersion(fetchFn: typeof fetch, url: string) {\n return fetchFn(url, {\n method: 'HEAD',\n redirect: 'manual',\n }).then(\n (res) => {\n // 302 is expected, but lets also handle 2xx\n if (res.ok || res.status < 400) {\n const resolved = res.headers.get('x-resolved-version')\n if (!resolved) {\n throw new Error(`Missing 'x-resolved-version' header on response from HEAD ${url}`)\n }\n return resolved\n }\n throw new Error(`Unexpected HTTP response: ${res.status} ${res.statusText}`)\n },\n (err) => {\n throw new Error(`Failed to fetch remote version for ${url}: ${err.message}`, {cause: err})\n },\n )\n}\n\ninterface CompareDependencyVersions {\n pkg: string\n installed: string\n remote: string\n}\n\n/**\n * Compares the versions of dependencies in the studio or app with their remote versions.\n *\n * This function reads the package.json file in the provided working directory, and compares the versions of the dependencies\n * specified in the `autoUpdatesImports` parameter with their remote versions. If the versions do not match, the dependency is\n * added to a list of failed dependencies, which is returned by the function.\n *\n * The failed dependencies are anything that does not strictly match the remote version.\n * This means that if a version is lower or greater by even a patch it will be marked as failed.\n *\n * @param autoUpdatesImports - An object mapping package names to their remote import URLs.\n * @param workDir - The path to the working directory containing the package.json file.\n * @param fetchFn - Optional {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | Fetch}-compatible function to use for requesting the current remote version of a module\n *\n * @returns A promise that resolves to an array of objects, each containing\n * the name of a package whose local and remote versions do not match, along with the local and remote versions.\n *\n * @throws Throws an error if the remote version of a package cannot be fetched, or if the local version of a package\n * cannot be parsed.\n */\nexport async function compareDependencyVersions(\n packages: {version: string; name: string}[],\n workDir: string,\n {fetchFn = globalThis.fetch}: {appId?: string; fetchFn?: typeof fetch} = {},\n): Promise<Array<CompareDependencyVersions>> {\n const manifest = await readPackageManifest(path.join(workDir, 'package.json'))\n const dependencies = {...manifest.dependencies, ...manifest.devDependencies}\n\n const failedDependencies: Array<CompareDependencyVersions> = []\n\n for (const pkg of packages) {\n const resolvedVersion = await getRemoteResolvedVersion(fetchFn, getModuleUrl(pkg))\n\n const manifestPath = resolveFrom.silent(workDir, path.join(pkg.name, 'package.json'))\n\n const manifestVersion = dependencies[pkg.name]\n\n const installed = semver.coerce(\n manifestPath\n ? semver.parse((await readPackageManifest(manifestPath)).version)\n : semver.coerce(manifestVersion),\n )\n\n if (!installed) {\n throw new Error(`Failed to parse installed version for ${pkg}`)\n }\n\n if (!semver.eq(resolvedVersion, installed.version)) {\n failedDependencies.push({\n pkg: pkg.name,\n installed: installed.version,\n remote: resolvedVersion,\n })\n }\n }\n\n return failedDependencies\n}\n","import {type CliConfig} from '@sanity/cli'\nimport chalk from 'chalk'\n\ninterface AutoUpdateSources {\n flags: {['auto-updates']?: boolean}\n cliConfig?: CliConfig\n output?: {warn: (message: string) => void}\n}\n\n/**\n * Compares parameters from various sources to determine whether or not to auto-update\n * @param sources - The sources of the auto-update parameter, including CLI flags and the CLI config\n * @returns boolean\n * @internal\n */\nexport function shouldAutoUpdate({flags, cliConfig, output}: AutoUpdateSources): boolean {\n // cli flags (for example, '--no-auto-updates') should take precedence\n if ('auto-updates' in flags) {\n if (output) {\n const flagUsed = flags['auto-updates'] ? '--auto-updates' : '--no-auto-updates'\n output.warn(\n chalk.yellow(\n `The ${flagUsed} flag is deprecated for \\`deploy\\` and \\`build\\` commands. Set the \\`autoUpdates\\` option in \\`sanity.cli.ts\\` or \\`sanity.cli.js\\` instead.`,\n ),\n )\n }\n return Boolean(flags['auto-updates'])\n }\n\n const hasOldCliConfigFlag = cliConfig && 'autoUpdates' in cliConfig\n const hasNewCliConfigFlag =\n cliConfig &&\n 'deployment' in cliConfig &&\n cliConfig.deployment &&\n 'autoUpdates' in cliConfig.deployment\n\n if (hasOldCliConfigFlag && hasNewCliConfigFlag) {\n throw new Error(\n 'Found both `autoUpdates` (deprecated) and `deployment.autoUpdates` in sanity.cli.js. Please remove the deprecated top level `autoUpdates` config.',\n )\n }\n if (hasOldCliConfigFlag) {\n output?.warn(\n chalk.yellow(\n `The \\`autoUpdates\\` config has moved to \\`deployment.autoUpdates\\`.\nPlease update \\`sanity.cli.ts\\` or \\`sanity.cli.js\\` and make the following change:\n${chalk.red(`- autoUpdates: ${cliConfig.autoUpdates},`)}\n${chalk.green(`+ deployment: {autoUpdates: ${cliConfig.autoUpdates}}}`)}\n`,\n ),\n )\n }\n return Boolean(hasOldCliConfigFlag ? cliConfig.autoUpdates : cliConfig?.deployment?.autoUpdates)\n}\n"],"names":["MODULES_HOST","process","env","SANITY_MODULES_HOST","SANITY_INTERNAL_ENV","currentUnixTime","Math","floor","Date","now","getAutoUpdatesImportMap","packages","options","Object","fromEntries","flatMap","pkg","getAppAutoUpdateImportMapForPackage","moduleUrl","getModuleUrl","name","timestamp","appId","getByAppModuleUrl","baseUrl","getLegacyModuleUrl","encodedMinVer","encodeURIComponent","version","rewriteScopedPackage","pkgName","includes","scope","split","join","getRemoteResolvedVersion","fetchFn","url","method","redirect","then","res","ok","status","resolved","headers","get","Error","statusText","err","message","cause","compareDependencyVersions","workDir","globalThis","fetch","manifest","readPackageManifest","path","dependencies","devDependencies","failedDependencies","resolvedVersion","manifestPath","resolveFrom","silent","manifestVersion","installed","semver","coerce","parse","eq","push","remote","shouldAutoUpdate","flags","cliConfig","output","flagUsed","warn","chalk","yellow","Boolean","hasOldCliConfigFlag","hasNewCliConfigFlag","deployment","red","autoUpdates","green"],"mappings":";;;;;AAAA,MAAMA,eACJC,QAAQC,IAAIC,wBACXF,QAAQC,IAAIE,wBAAwB,YACjC,4BACA;AAEN,SAASC,kBAA0B;AACjC,SAAOC,KAAKC,MAAMC,KAAKC,IAAAA,IAAQ,GAAI;AACrC;AAMO,SAASC,wBACdC,UACAC,UAAkE,IAClE;AACA,SAAOC,OAAOC,YACZH,SAASI,QAASC,SAAQC,oCAAoCD,KAAKJ,OAAO,CAAC,CAC7E;AACF;AAEA,SAASK,oCACPD,KACAJ,UAAkE,IACZ;AACtD,QAAMM,YAAYC,aAAaH,KAAKJ,OAAO;AAE3C,SAAO,CACL,CAACI,IAAII,MAAMF,SAAS,GACpB,CAAC,GAAGF,IAAII,IAAI,KAAK,GAAGF,SAAS,GAAG,CAAC;AAErC;AAEO,SAASC,aACdH,KACAJ,UAAkE,IAClE;AACA,QAAM;AAAA,IAACS,YAAYhB,gBAAAA;AAAAA,EAAgB,IAAKO;AACxC,SAAOA,QAAQU,QACXC,kBAAkBP,KAAK;AAAA,IAACM,OAA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,OAAOH,QAAQ,8IACjB,CACF;AAAA,IACF;AACA,WAAOI,CAAAA,CAAQP,MAAM,cAAc;AAAA,EACrC;AAEA,QAAMQ,sBAAsBP,aAAa,iBAAiBA,WACpDQ,sBACJR,aACA,gBAAgBA,aAChBA,UAAUS,cACV,iBAAiBT,UAAUS;AAE7B,MAAIF,uBAAuBC;AACzB,UAAM,IAAIrC,MACR,mJACF;AAEF,SAAIoC,uBACFN,QAAQE,KACNC,MAAMC,OACJ;AAAA;AAAA,EAEND,MAAMM,IAAI,mBAAmBV,UAAUW,WAAW,GAAG,CAAC;AAAA,EACtDP,MAAMQ,MAAM,gCAAgCZ,UAAUW,WAAW,IAAI,CAAC;AAAA,CAElE,CACF,GAEKL,CAAAA,EAAQC,sBAAsBP,UAAUW,cAAcX,WAAWS,YAAYE;AACtF;"}
1
+ {"version":3,"file":"shouldAutoUpdate.js","sources":["../../src/_internal/cli/util/getAutoUpdatesImportMap.ts","../../src/_internal/cli/util/compareDependencyVersions.ts","../../src/_internal/cli/util/shouldAutoUpdate.ts"],"sourcesContent":["const MODULES_HOST =\n process.env.SANITY_MODULES_HOST ||\n (process.env.SANITY_INTERNAL_ENV === 'staging'\n ? 'https://sanity-cdn.work'\n : 'https://sanity-cdn.com')\n\nfunction currentUnixTime(): number {\n return Math.floor(Date.now() / 1000)\n}\n\ntype Package = {version: string; name: string}\n/**\n * @internal\n */\nexport function getAutoUpdatesImportMap<const Pkg extends Package>(\n packages: Pkg[],\n options: {timestamp?: number; baseUrl?: string; appId?: string} = {},\n) {\n return Object.fromEntries(\n packages.flatMap((pkg) => getAppAutoUpdateImportMapForPackage(pkg, options)),\n ) as {[K in Pkg['name'] | `${Pkg['name']}/`]: string}\n}\n\nfunction getAppAutoUpdateImportMapForPackage<const Pkg extends Package>(\n pkg: Pkg,\n options: {timestamp?: number; baseUrl?: string; appId?: string} = {},\n): [[Pkg['name'], string], [`${Pkg['name']}/`, string]] {\n const moduleUrl = getModuleUrl(pkg, options)\n\n return [\n [pkg.name, moduleUrl],\n [`${pkg.name}/`, `${moduleUrl}/`],\n ]\n}\n\nexport function getModuleUrl(\n pkg: Package,\n options: {timestamp?: number; baseUrl?: string; appId?: string} = {},\n) {\n const {timestamp = currentUnixTime()} = options\n return options.appId\n ? getByAppModuleUrl(pkg, {appId: options.appId, baseUrl: options.baseUrl, timestamp})\n : getLegacyModuleUrl(pkg, {timestamp, baseUrl: options.baseUrl})\n}\n\nfunction getLegacyModuleUrl(pkg: Package, options: {timestamp: number; baseUrl?: string}) {\n const encodedMinVer = encodeURIComponent(`^${pkg.version}`)\n return `${options.baseUrl || MODULES_HOST}/v1/modules/${rewriteScopedPackage(pkg.name)}/default/${encodedMinVer}/t${options.timestamp}`\n}\n\nfunction getByAppModuleUrl(\n pkg: Package,\n options: {appId: string; baseUrl?: string; timestamp: number},\n) {\n const encodedMinVer = encodeURIComponent(`^${pkg.version}`)\n return `${options.baseUrl || MODULES_HOST}/v1/modules/by-app/${options.appId}/t${options.timestamp}/${encodedMinVer}/${rewriteScopedPackage(pkg.name)}`\n}\n\n/**\n * replaces '/' with '__' similar to how eg `@types/scope__pkg` are rewritten\n * scoped packages are stored this way both in the manifest and in the cloud storage bucket\n */\nfunction rewriteScopedPackage(pkgName: string) {\n if (!pkgName.includes('@')) {\n return pkgName\n }\n const [scope, ...pkg] = pkgName.split('/')\n return `${scope}__${pkg.join('')}`\n}\n","import path from 'node:path'\n\nimport resolveFrom from 'resolve-from'\nimport semver from 'semver'\n\nimport {getModuleUrl} from './getAutoUpdatesImportMap'\nimport {readPackageManifest} from './readPackageManifest'\n\nfunction getRemoteResolvedVersion(fetchFn: typeof fetch, url: string) {\n return fetchFn(url, {\n method: 'HEAD',\n redirect: 'manual',\n }).then(\n (res) => {\n // 302 is expected, but lets also handle 2xx\n if (res.ok || res.status < 400) {\n const resolved = res.headers.get('x-resolved-version')\n if (!resolved) {\n throw new Error(`Missing 'x-resolved-version' header on response from HEAD ${url}`)\n }\n return resolved\n }\n throw new Error(`Unexpected HTTP response: ${res.status} ${res.statusText}`)\n },\n (err) => {\n throw new Error(`Failed to fetch remote version for ${url}: ${err.message}`, {cause: err})\n },\n )\n}\n\ninterface CompareDependencyVersions {\n pkg: string\n installed: string\n remote: string\n}\n\n/**\n * Compares the versions of dependencies in the studio or app with their remote versions.\n *\n * This function reads the package.json file in the provided working directory, and compares the versions of the dependencies\n * specified in the `autoUpdatesImports` parameter with their remote versions. If the versions do not match, the dependency is\n * added to a list of failed dependencies, which is returned by the function.\n *\n * The failed dependencies are anything that does not strictly match the remote version.\n * This means that if a version is lower or greater by even a patch it will be marked as failed.\n *\n * @param autoUpdatesImports - An object mapping package names to their remote import URLs.\n * @param workDir - The path to the working directory containing the package.json file.\n * @param fetchFn - Optional {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | Fetch}-compatible function to use for requesting the current remote version of a module\n *\n * @returns A promise that resolves to an array of objects, each containing\n * the name of a package whose local and remote versions do not match, along with the local and remote versions.\n *\n * @throws Throws an error if the remote version of a package cannot be fetched, or if the local version of a package\n * cannot be parsed.\n */\nexport async function compareDependencyVersions(\n packages: {version: string; name: string}[],\n workDir: string,\n {fetchFn = globalThis.fetch}: {appId?: string; fetchFn?: typeof fetch} = {},\n): Promise<Array<CompareDependencyVersions>> {\n const manifest = await readPackageManifest(path.join(workDir, 'package.json'))\n const dependencies = {...manifest.dependencies, ...manifest.devDependencies}\n\n const failedDependencies: Array<CompareDependencyVersions> = []\n\n for (const pkg of packages) {\n const resolvedVersion = await getRemoteResolvedVersion(fetchFn, getModuleUrl(pkg))\n\n const manifestPath = resolveFrom.silent(workDir, path.join(pkg.name, 'package.json'))\n\n const manifestVersion = dependencies[pkg.name]\n\n const installed = semver.coerce(\n manifestPath\n ? semver.parse((await readPackageManifest(manifestPath)).version)\n : semver.coerce(manifestVersion),\n )\n\n if (!installed) {\n throw new Error(`Failed to parse installed version for ${pkg}`)\n }\n\n if (!semver.eq(resolvedVersion, installed.version)) {\n failedDependencies.push({\n pkg: pkg.name,\n installed: installed.version,\n remote: resolvedVersion,\n })\n }\n }\n\n return failedDependencies\n}\n","import {type CliConfig} from '@sanity/cli'\nimport chalk from 'chalk'\n\ninterface AutoUpdateSources {\n flags: {['auto-updates']?: boolean}\n cliConfig?: CliConfig\n output?: {warn: (message: string) => void}\n}\n\n/**\n * Compares parameters from various sources to determine whether or not to auto-update\n * @param sources - The sources of the auto-update parameter, including CLI flags and the CLI config\n * @returns boolean\n * @internal\n */\nexport function shouldAutoUpdate({flags, cliConfig, output}: AutoUpdateSources): boolean {\n // cli flags (for example, '--no-auto-updates') should take precedence\n if ('auto-updates' in flags) {\n if (output) {\n const flagUsed = flags['auto-updates'] ? '--auto-updates' : '--no-auto-updates'\n output.warn(\n chalk.yellow(\n `The ${flagUsed} flag is deprecated for \\`deploy\\` and \\`build\\` commands. Set the \\`autoUpdates\\` option in \\`sanity.cli.ts\\` or \\`sanity.cli.js\\` instead.`,\n ),\n )\n }\n return Boolean(flags['auto-updates'])\n }\n\n const hasOldCliConfigFlag = cliConfig && 'autoUpdates' in cliConfig\n const hasNewCliConfigFlag =\n cliConfig &&\n 'deployment' in cliConfig &&\n cliConfig.deployment &&\n 'autoUpdates' in cliConfig.deployment\n\n if (hasOldCliConfigFlag && hasNewCliConfigFlag) {\n throw new Error(\n 'Found both `autoUpdates` (deprecated) and `deployment.autoUpdates` in sanity.cli.js. Please remove the deprecated top level `autoUpdates` config.',\n )\n }\n if (hasOldCliConfigFlag) {\n output?.warn(\n chalk.yellow(\n `The \\`autoUpdates\\` config has moved to \\`deployment.autoUpdates\\`.\nPlease update \\`sanity.cli.ts\\` or \\`sanity.cli.js\\` and make the following change:\n${chalk.red(`- autoUpdates: ${cliConfig.autoUpdates},`)}\n${chalk.green(`+ deployment: {autoUpdates: ${cliConfig.autoUpdates}},`)}\n`,\n ),\n )\n }\n return Boolean(hasOldCliConfigFlag ? cliConfig.autoUpdates : cliConfig?.deployment?.autoUpdates)\n}\n"],"names":["MODULES_HOST","process","env","SANITY_MODULES_HOST","SANITY_INTERNAL_ENV","currentUnixTime","Math","floor","Date","now","getAutoUpdatesImportMap","packages","options","Object","fromEntries","flatMap","pkg","getAppAutoUpdateImportMapForPackage","moduleUrl","getModuleUrl","name","timestamp","appId","getByAppModuleUrl","baseUrl","getLegacyModuleUrl","encodedMinVer","encodeURIComponent","version","rewriteScopedPackage","pkgName","includes","scope","split","join","getRemoteResolvedVersion","fetchFn","url","method","redirect","then","res","ok","status","resolved","headers","get","Error","statusText","err","message","cause","compareDependencyVersions","workDir","globalThis","fetch","manifest","readPackageManifest","path","dependencies","devDependencies","failedDependencies","resolvedVersion","manifestPath","resolveFrom","silent","manifestVersion","installed","semver","coerce","parse","eq","push","remote","shouldAutoUpdate","flags","cliConfig","output","flagUsed","warn","chalk","yellow","Boolean","hasOldCliConfigFlag","hasNewCliConfigFlag","deployment","red","autoUpdates","green"],"mappings":";;;;;AAAA,MAAMA,eACJC,QAAQC,IAAIC,wBACXF,QAAQC,IAAIE,wBAAwB,YACjC,4BACA;AAEN,SAASC,kBAA0B;AACjC,SAAOC,KAAKC,MAAMC,KAAKC,IAAAA,IAAQ,GAAI;AACrC;AAMO,SAASC,wBACdC,UACAC,UAAkE,IAClE;AACA,SAAOC,OAAOC,YACZH,SAASI,QAASC,SAAQC,oCAAoCD,KAAKJ,OAAO,CAAC,CAC7E;AACF;AAEA,SAASK,oCACPD,KACAJ,UAAkE,IACZ;AACtD,QAAMM,YAAYC,aAAaH,KAAKJ,OAAO;AAE3C,SAAO,CACL,CAACI,IAAII,MAAMF,SAAS,GACpB,CAAC,GAAGF,IAAII,IAAI,KAAK,GAAGF,SAAS,GAAG,CAAC;AAErC;AAEO,SAASC,aACdH,KACAJ,UAAkE,IAClE;AACA,QAAM;AAAA,IAACS,YAAYhB,gBAAAA;AAAAA,EAAgB,IAAKO;AACxC,SAAOA,QAAQU,QACXC,kBAAkBP,KAAK;AAAA,IAACM,OAAOV,QAAQU;AAAAA,IAAOE,S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F;AAAA,IACF;AACA,WAAOI,CAAAA,CAAQP,MAAM,cAAc;AAAA,EACrC;AAEA,QAAMQ,sBAAsBP,aAAa,iBAAiBA,WACpDQ,sBACJR,aACA,gBAAgBA,aAChBA,UAAUS,cACV,iBAAiBT,UAAUS;AAE7B,MAAIF,uBAAuBC;AACzB,UAAM,IAAIrC,MACR,mJACF;AAEF,SAAIoC,uBACFN,QAAQE,KACNC,MAAMC,OACJ;AAAA;AAAA,EAEND,MAAMM,IAAI,mBAAmBV,UAAUW,WAAW,GAAG,CAAC;AAAA,EACtDP,MAAMQ,MAAM,gCAAgCZ,UAAUW,WAAW,IAAI,CAAC;AAAA,CAElE,CACF,GAEKL,CAAAA,EAAQC,sBAAsBP,UAAUW,cAAcX,WAAWS,YAAYE;AACtF;"}
@@ -7,7 +7,7 @@ try {
7
7
  try {
8
8
  buildVersion = buildVersion || // This is replaced by `@sanity/pkg-utils` at build time
9
9
  // and must always be references by its full static name, e.g. no optional chaining, no `if (process && process.env)` etc.
10
- "5.3.0-next.11+0309df2a6d";
10
+ "5.3.0-next.14+27686cb16d";
11
11
  } catch {
12
12
  }
13
13
  const SANITY_VERSION = buildVersion || `${version}-dev`;
package/lib/index.d.ts CHANGED
@@ -16167,31 +16167,24 @@ export declare interface UnscheduleDocumentVersionEvent extends BaseEvent {
16167
16167
  export declare function unset(path?: Path): FormUnsetPatch
16168
16168
 
16169
16169
  /**
16170
+ * @deprecated Use `useUnstableObserveDocument` instead
16170
16171
  * @internal
16171
16172
  * @beta
16172
- *
16173
- * Observes a document by its ID and returns the document and loading state
16174
- * it will listen to the document changes.
16175
16173
  */
16176
- export declare function unstable_useObserveDocument<T extends SanityDocument_2>(
16177
- documentId: string,
16178
- apiConfig?: ObserveDocumentAPIConfig,
16179
- ): {
16180
- document: T | null
16174
+ export declare const unstable_useObserveDocument: (
16175
+ args: Parameters<typeof useUnstableObserveDocument>,
16176
+ ) => {
16177
+ document: SanityDocument_2 | null
16181
16178
  loading: boolean
16182
16179
  }
16183
16180
 
16184
16181
  /**
16185
16182
  * @internal
16186
- * @deprecated FOR INTERNAL USE.
16183
+ * @deprecated use useValuePreview instead
16187
16184
  */
16188
- export declare function unstable_useValuePreview(props: {
16189
- enabled?: boolean
16190
- ordering?: SortOrdering
16191
- schemaType?: SchemaType
16192
- value: unknown | undefined
16193
- perspectiveStack?: PerspectiveStack
16194
- }): State_2
16185
+ export declare function unstable_useValuePreview(
16186
+ args: Parameters<typeof useValuePreview>[0],
16187
+ ): State_2
16195
16188
 
16196
16189
  /**
16197
16190
  * @hidden
@@ -17813,6 +17806,21 @@ export declare type UseUnitFormatterOptions = Pick<
17813
17806
  'notation' | 'signDisplay' | 'unitDisplay' | 'maximumFractionDigits' | 'minimumFractionDigits'
17814
17807
  >
17815
17808
 
17809
+ /**
17810
+ * @internal
17811
+ * @beta
17812
+ *
17813
+ * Observes a document by its ID and returns the document and loading state
17814
+ * it will listen to the document changes.
17815
+ */
17816
+ export declare function useUnstableObserveDocument<T extends SanityDocument_2>(
17817
+ documentId: string,
17818
+ apiConfig?: ObserveDocumentAPIConfig,
17819
+ ): {
17820
+ document: T | null
17821
+ loading: boolean
17822
+ }
17823
+
17816
17824
  /** @internal */
17817
17825
  export declare function useUser(userId: string): LoadingTuple<User | null | undefined>
17818
17826
 
@@ -17843,6 +17851,17 @@ export declare function useValidationStatus(
17843
17851
  requirePublishedReferences: boolean,
17844
17852
  ): ValidationStatus
17845
17853
 
17854
+ /**
17855
+ * @internal
17856
+ */
17857
+ export declare function useValuePreview(props: {
17858
+ enabled?: boolean
17859
+ ordering?: SortOrdering
17860
+ schemaType?: SchemaType
17861
+ value: unknown | undefined
17862
+ perspectiveStack?: PerspectiveStack
17863
+ }): State_2
17864
+
17846
17865
  /** @internal */
17847
17866
  export declare function useVersionOperations(): VersionOperationsValue
17848
17867
 
package/lib/index.js CHANGED
@@ -22949,6 +22949,9 @@ function useSearchableList(items) {
22949
22949
  function isGoingToUnpublish(document2) {
22950
22950
  return document2._system?.delete === !0;
22951
22951
  }
22952
+ function unstable_useValuePreview(args) {
22953
+ return useValuePreview(args);
22954
+ }
22952
22955
  const INITIAL_STATE$9 = {
22953
22956
  isLoading: !0
22954
22957
  }, IDLE_STATE = {
@@ -22958,7 +22961,7 @@ const INITIAL_STATE$9 = {
22958
22961
  description: void 0
22959
22962
  }
22960
22963
  };
22961
- function useDocumentPreview(props2) {
22964
+ function useValuePreview(props2) {
22962
22965
  const $ = c(10);
22963
22966
  let t0;
22964
22967
  $[0] !== props2 ? (t0 = props2 || {}, $[0] = props2, $[1] = t0) : t0 = $[1];
@@ -23013,7 +23016,7 @@ function _temp$3l(event) {
23013
23016
  };
23014
23017
  }
23015
23018
  function useValuePreviewWithFallback(props2) {
23016
- const $ = c(9), preview = useDocumentPreview(props2), {
23019
+ const $ = c(9), preview = useValuePreview(props2), {
23017
23020
  t
23018
23021
  } = useTranslation(), t0 = preview?.value;
23019
23022
  let t1;
@@ -42099,7 +42102,7 @@ function PreviewLoader(props2) {
42099
42102
  value,
42100
42103
  perspectiveStack
42101
42104
  }, $[9] = perspectiveStack, $[10] = schemaType, $[11] = t0, $[12] = value, $[13] = t1) : t1 = $[13];
42102
- const preview = useDocumentPreview(t1), t2 = styleProp?.minWidth || 1, t3 = styleProp?.minHeight || 1;
42105
+ const preview = useValuePreview(t1), t2 = styleProp?.minWidth || 1, t3 = styleProp?.minHeight || 1;
42103
42106
  let t4;
42104
42107
  $[14] !== styleProp || $[15] !== t2 || $[16] !== t3 ? (t4 = {
42105
42108
  ...styleProp,
@@ -43845,7 +43848,7 @@ const INITIAL_STATE$6 = {
43845
43848
  loading: !0,
43846
43849
  document: null
43847
43850
  };
43848
- function useObserveDocument(documentId, apiConfig) {
43851
+ function useUnstableObserveDocument(documentId, apiConfig) {
43849
43852
  const $ = c(4), documentPreviewStore = useDocumentPreviewStore();
43850
43853
  let t0;
43851
43854
  return $[0] !== apiConfig || $[1] !== documentId || $[2] !== documentPreviewStore ? (t0 = documentPreviewStore.unstable_observeDocument(documentId, apiConfig).pipe(map(_temp$2h)), $[0] = apiConfig, $[1] = documentId, $[2] = documentPreviewStore, $[3] = t0) : t0 = $[3], useObservable(t0, INITIAL_STATE$6);
@@ -43856,6 +43859,7 @@ function _temp$2h(document2) {
43856
43859
  document: document2
43857
43860
  };
43858
43861
  }
43862
+ const unstable_useObserveDocument = (args) => useUnstableObserveDocument(...args);
43859
43863
  function getPreviewStateObservable$1(documentPreviewStore, schemaType, documentId, perspective, viewOptions) {
43860
43864
  const perspectiveSnapshot = documentPreviewStore.observeForPreview({
43861
43865
  _id: getPublishedId(documentId)
@@ -45168,7 +45172,7 @@ function UnpublishVersionDialog(props2) {
45168
45172
  schemaType,
45169
45173
  value: t2
45170
45174
  }, $[12] = schemaType, $[13] = t2, $[14] = t3) : t3 = $[14];
45171
- const preview = useDocumentPreview(t3);
45175
+ const preview = useValuePreview(t3);
45172
45176
  let t4;
45173
45177
  $[15] !== coreT || $[16] !== documentVersionId || $[17] !== onClose || $[18] !== preview?.value?.title || $[19] !== toast || $[20] !== unpublishVersion ? (t4 = async () => {
45174
45178
  setIsUnpublishing(!0);
@@ -51541,7 +51545,7 @@ function SearchResultItem(t0) {
51541
51545
  schemaType: type,
51542
51546
  value: documentStub
51543
51547
  }, $[31] = documentStub, $[32] = type, $[33] = t10) : t10 = $[33];
51544
- const preview = useDocumentPreview(t10);
51548
+ const preview = useValuePreview(t10);
51545
51549
  let t11;
51546
51550
  $[34] !== disableIntentLink || $[35] !== documentId || $[36] !== documentType || $[37] !== onClick2 || $[38] !== onIntentClick || $[39] !== onItemSelect || $[40] !== preview ? (t11 = (e) => {
51547
51551
  onItemSelect?.({
@@ -53817,7 +53821,7 @@ function useScheduledDraftDocument(releaseDocumentId, t0) {
53817
53821
  const {
53818
53822
  value: previewValue,
53819
53823
  isLoading: previewLoading
53820
- } = useDocumentPreview(t7), t8 = includePreview ? previewValue : void 0, t9 = includePreview ? previewLoading : !1;
53824
+ } = unstable_useValuePreview(t7), t8 = includePreview ? previewValue : void 0, t9 = includePreview ? previewLoading : !1;
53821
53825
  let t10;
53822
53826
  return $[11] !== documentsCount || $[12] !== error || $[13] !== firstDocument || $[14] !== firstDocumentValidation || $[15] !== loading || $[16] !== t8 || $[17] !== t9 ? (t10 = {
53823
53827
  firstDocument,
@@ -64820,7 +64824,7 @@ const useDocumentTitle = (t0) => {
64820
64824
  const {
64821
64825
  error,
64822
64826
  value
64823
- } = useDocumentPreview(t3);
64827
+ } = useValuePreview(t3);
64824
64828
  if (!schemaType) {
64825
64829
  let t42;
64826
64830
  return $[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t42 = {
@@ -90485,8 +90489,8 @@ export {
90485
90489
  truncateString,
90486
90490
  uncaughtErrorHandler,
90487
90491
  unset,
90488
- useObserveDocument as unstable_useObserveDocument,
90489
- useDocumentPreview as unstable_useValuePreview,
90492
+ unstable_useObserveDocument,
90493
+ unstable_useValuePreview,
90490
90494
  usEnglishLocale,
90491
90495
  useActiveReleases,
90492
90496
  useActiveWorkspace,
@@ -90613,12 +90617,14 @@ export {
90613
90617
  useTranslation,
90614
90618
  useUnique,
90615
90619
  useUnitFormatter,
90620
+ useUnstableObserveDocument,
90616
90621
  useUser,
90617
90622
  useUserColor,
90618
90623
  useUserColorManager,
90619
90624
  useUserListWithPermissions,
90620
90625
  useUserStore,
90621
90626
  useValidationStatus,
90627
+ useValuePreview,
90622
90628
  useVersionOperations,
90623
90629
  useVirtualizerScrollInstance,
90624
90630
  useWorkspace,