sanity 3.72.1 → 3.72.2-use-live-content-api.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/lib/_chunks-cjs/LiveQueries.js +236 -163
  2. package/lib/_chunks-cjs/LiveQueries.js.map +1 -1
  3. package/lib/_chunks-cjs/PresentationToolGrantsCheck.js +3 -7
  4. package/lib/_chunks-cjs/PresentationToolGrantsCheck.js.map +1 -1
  5. package/lib/_chunks-cjs/buildAction.js +3 -0
  6. package/lib/_chunks-cjs/buildAction.js.map +1 -1
  7. package/lib/_chunks-cjs/presentation.js +3 -4
  8. package/lib/_chunks-cjs/presentation.js.map +1 -1
  9. package/lib/_chunks-cjs/version.js +1 -1
  10. package/lib/_chunks-es/LiveQueries.mjs +235 -162
  11. package/lib/_chunks-es/LiveQueries.mjs.map +1 -1
  12. package/lib/_chunks-es/PresentationToolGrantsCheck.mjs +2 -4
  13. package/lib/_chunks-es/PresentationToolGrantsCheck.mjs.map +1 -1
  14. package/lib/_chunks-es/presentation.mjs +3 -3
  15. package/lib/_chunks-es/presentation.mjs.map +1 -1
  16. package/lib/_chunks-es/version.mjs +1 -1
  17. package/lib/_internal/cli/threads/validateDocuments.js +1 -1
  18. package/lib/_internal/cli/threads/validateDocuments.js.map +1 -1
  19. package/lib/_legacy/LiveQueries.esm.js +235 -162
  20. package/lib/_legacy/LiveQueries.esm.js.map +1 -1
  21. package/lib/_legacy/PresentationToolGrantsCheck.esm.js +2 -4
  22. package/lib/_legacy/PresentationToolGrantsCheck.esm.js.map +1 -1
  23. package/lib/_legacy/presentation.esm.js +3 -3
  24. package/lib/_legacy/presentation.esm.js.map +1 -1
  25. package/lib/_legacy/version.esm.js +1 -1
  26. package/package.json +13 -14
  27. package/src/_internal/cli/server/buildVendorDependencies.ts +1 -0
  28. package/src/_internal/cli/threads/validateDocuments.ts +2 -2
  29. package/src/presentation/PresentationTool.tsx +10 -21
  30. package/src/presentation/constants.ts +4 -16
  31. package/src/presentation/loader/LiveQueries.tsx +79 -234
  32. package/src/presentation/loader/useLiveEvents.ts +75 -0
  33. package/src/presentation/loader/useLiveQueries.ts +127 -0
  34. package/src/presentation/loader/utils.ts +2 -125
  35. package/src/presentation/types.ts +1 -18
  36. package/lib/_chunks-cjs/LoaderQueries.js +0 -281
  37. package/lib/_chunks-cjs/LoaderQueries.js.map +0 -1
  38. package/lib/_chunks-cjs/utils.js +0 -70
  39. package/lib/_chunks-cjs/utils.js.map +0 -1
  40. package/lib/_chunks-es/LoaderQueries.mjs +0 -288
  41. package/lib/_chunks-es/LoaderQueries.mjs.map +0 -1
  42. package/lib/_chunks-es/utils.mjs +0 -74
  43. package/lib/_chunks-es/utils.mjs.map +0 -1
  44. package/lib/_legacy/LoaderQueries.esm.js +0 -288
  45. package/lib/_legacy/LoaderQueries.esm.js.map +0 -1
  46. package/lib/_legacy/utils.esm.js +0 -74
  47. package/lib/_legacy/utils.esm.js.map +0 -1
  48. package/src/presentation/loader/LoaderQueries.tsx +0 -564
@@ -125,6 +125,9 @@ async function buildVendorDependencies({
125
125
  "process.env.NODE_ENV": JSON.stringify("production")
126
126
  },
127
127
  build: {
128
+ commonjsOptions: {
129
+ strictRequires: "auto"
130
+ },
128
131
  minify: !0,
129
132
  emptyOutDir: !1,
130
133
  // Rely on CLI to do this
@@ -1 +1 @@
1
- {"version":3,"file":"buildAction.js","sources":["../../src/_internal/cli/actions/build/build.telemetry.ts","../../src/_internal/cli/server/buildVendorDependencies.ts","../../src/_internal/cli/util/compareStudioDependencyVersions.ts","../../src/_internal/cli/util/getAutoUpdatesImportMap.ts","../../src/_internal/cli/util/shouldAutoUpdate.ts","../../src/_internal/cli/actions/build/buildAction.ts"],"sourcesContent":["import {defineTrace} from '@sanity/telemetry'\n\nexport const BuildTrace = defineTrace<{outputSize: number}>({\n name: 'Studio Build Completed',\n version: 0,\n description: 'A Studio build completed',\n})\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport resolveFrom from 'resolve-from'\nimport semver from 'semver'\n\nimport {createExternalFromImportMap} from './createExternalFromImportMap'\n\n// Directory where vendor packages will be stored\nconst VENDOR_DIR = 'vendor'\n\n/**\n * A type representing the imports of vendor packages, defining specific entry\n * points for various versions and subpaths of the packages.\n *\n * The `VendorImports` object is used to build ESM browser-compatible versions\n * of the specified packages. This approach ensures that the appropriate version\n * and entry points are used for each package, enabling compatibility and proper\n * functionality in the browser environment.\n *\n * ## Rationale\n *\n * The rationale for this structure is to handle different versions of the\n * packages carefully, especially major versions. Major version bumps often\n * introduce breaking changes, so the module scheme for the package needs to be\n * checked when there is a major version update. However, minor and patch\n * versions are generally backward compatible, so they are handled more\n * leniently. By assuming that new minor versions are compatible, we avoid\n * unnecessary warnings and streamline the update process.\n *\n * If a new minor version introduces an additional subpath export within the\n * package of this version range, the corresponding package can add a more\n * specific version range that includes the new subpath. This design allows for\n * flexibility and ease of maintenance, ensuring that the latest features and\n * fixes are incorporated without extensive manual intervention.\n *\n * An additional subpath export within the package of this version range that\n * could cause the build to break if that new export is used, can be treated as\n * a bug fix. It might make more sense to our users that this new subpath isn't\n * supported yet until we address it as a bug fix. This approach helps maintain\n * stability and prevents unexpected issues during the build process.\n *\n * ## Structure\n * The `VendorImports` type is a nested object where:\n * - The keys at the first level represent the package names.\n * - The keys at the second level represent the version ranges (e.g., `^19.0.0`).\n * - The keys at the third level represent the subpaths within the package (e.g., `.` for the main entry point).\n * - The values at the third level are the relative paths to the corresponding entry points within the package.\n *\n * This structure allows for precise specification of the entry points for\n * different versions and subpaths, ensuring that the correct files are used\n * during the build process.\n */\ntype VendorImports = {\n [packageName: string]: {\n [versionRange: string]: {\n [subpath: string]: string\n }\n }\n}\n\n// Define the vendor packages and their corresponding versions and entry points\nconst VENDOR_IMPORTS: VendorImports = {\n 'react': {\n '^19.0.0': {\n '.': './cjs/react.production.js',\n './jsx-runtime': './cjs/react-jsx-runtime.production.js',\n './jsx-dev-runtime': './cjs/react-jsx-dev-runtime.production.js',\n './compiler-runtime': './cjs/react-compiler-runtime.production.js',\n './package.json': './package.json',\n },\n '^18.0.0': {\n '.': './cjs/react.production.min.js',\n './jsx-runtime': './cjs/react-jsx-runtime.production.min.js',\n './jsx-dev-runtime': './cjs/react-jsx-dev-runtime.production.min.js',\n './package.json': './package.json',\n },\n },\n 'react-dom': {\n '^19.0.0': {\n '.': './cjs/react-dom.production.js',\n './client': './cjs/react-dom-client.production.js',\n './server': './cjs/react-dom-server-legacy.browser.production.js',\n './server.browser': './cjs/react-dom-server-legacy.browser.production.js',\n './static': './cjs/react-dom-server.browser.production.js',\n './static.browser': './cjs/react-dom-server.browser.production.js',\n './package.json': './package.json',\n },\n '^18.0.0': {\n '.': './cjs/react-dom.production.min.js',\n './client': './cjs/react-dom.production.min.js',\n './server': './cjs/react-dom-server-legacy.browser.production.min.js',\n './server.browser': './cjs/react-dom-server-legacy.browser.production.min.js',\n './package.json': './package.json',\n },\n },\n 'styled-components': {\n '^6.1.0': {\n '.': './dist/styled-components.esm.js',\n './package.json': './package.json',\n },\n },\n}\n\ninterface VendorBuildOptions {\n cwd: string\n outputDir: string\n basePath: string\n}\n\n/**\n * Builds the ESM browser compatible versions of the vendor packages\n * specified in VENDOR_IMPORTS. Returns the `imports` object of an import map.\n */\nexport async function buildVendorDependencies({\n cwd,\n outputDir,\n basePath,\n}: VendorBuildOptions): Promise<Record<string, string>> {\n // normalize the CWD to a relative dir for better error messages\n const dir = path.relative(process.cwd(), path.resolve(cwd))\n const entry: Record<string, string> = {}\n const imports: Record<string, string> = {}\n\n // Iterate over each package and its version ranges in VENDOR_IMPORTS\n for (const [packageName, ranges] of Object.entries(VENDOR_IMPORTS)) {\n const packageJsonPath = resolveFrom.silent(cwd, path.join(packageName, 'package.json'))\n if (!packageJsonPath) {\n throw new Error(\n `Could not find package.json for package '${packageName}' from directory '${dir}'. Is it installed?`,\n )\n }\n\n let packageJson\n\n try {\n // Read and parse the package.json file\n packageJson = JSON.parse(await fs.promises.readFile(packageJsonPath, 'utf-8'))\n } catch (e) {\n const message = `Could not read package.json for package '${packageName}' from directory '${dir}'`\n if (typeof e?.message === 'string') {\n // Re-assign the error message so the stack trace is more visible\n e.message = `${message}: ${e.message}`\n throw e\n }\n\n throw new Error(message, {cause: e})\n }\n\n // Coerce the version to a semver-compatible version\n const version = semver.coerce(packageJson.version)?.version\n if (!version) {\n throw new Error(`Could not parse version '${packageJson.version}' from '${packageName}'`)\n }\n\n // Sort version ranges in descending order\n const sortedRanges = Object.keys(ranges).sort((range1, range2) => {\n const min1 = semver.minVersion(range1)\n const min2 = semver.minVersion(range2)\n\n if (!min1) throw new Error(`Could not parse range '${range1}'`)\n if (!min2) throw new Error(`Could not parse range '${range2}'`)\n\n // sort them in reverse so we can rely on array `.find` below\n return semver.rcompare(min1.version, min2.version)\n })\n\n // Find the first version range that satisfies the package version\n const matchedRange = sortedRanges.find((range) => semver.satisfies(version, range))\n\n if (!matchedRange) {\n const min = semver.minVersion(sortedRanges[sortedRanges.length - 1])\n if (!min) {\n throw new Error(`Could not find a minimum version for package '${packageName}'`)\n }\n\n if (semver.gt(min.version, version)) {\n throw new Error(`Package '${packageName}' requires at least ${min.version}.`)\n }\n\n throw new Error(`Version '${version}' of package '${packageName}' is not supported yet.`)\n }\n\n const subpaths = ranges[matchedRange]\n\n // Iterate over each subpath and its corresponding entry point\n for (const [subpath, relativeEntryPoint] of Object.entries(subpaths)) {\n const packagePath = path.dirname(packageJsonPath)\n const entryPoint = resolveFrom.silent(packagePath, relativeEntryPoint)\n\n if (!entryPoint) {\n throw new Error(\n `Failed to resolve entry point '${path.join(packageName, relativeEntryPoint)}'. `,\n )\n }\n\n const specifier = path.posix.join(packageName, subpath)\n const chunkName = path.posix.join(\n packageName,\n path.relative(packageName, specifier) || 'index',\n )\n\n entry[chunkName] = entryPoint\n imports[specifier] = path.posix.join('/', basePath, VENDOR_DIR, `${chunkName}.mjs`)\n }\n }\n\n // removes the `RollupWatcher` type\n type BuildResult = Exclude<Awaited<ReturnType<typeof build>>, {close: unknown}>\n\n const {build} = await import('vite')\n // Use Vite to build the packages into the output directory\n let buildResult = (await build({\n // Define a custom cache directory so that sanity's vite cache\n // does not conflict with any potential local vite projects\n cacheDir: 'node_modules/.sanity/vite-vendor',\n root: cwd,\n configFile: false,\n logLevel: 'silent',\n\n appType: 'custom',\n mode: 'production',\n define: {'process.env.NODE_ENV': JSON.stringify('production')},\n\n build: {\n minify: true,\n emptyOutDir: false, // Rely on CLI to do this\n outDir: path.join(outputDir, VENDOR_DIR),\n lib: {entry, formats: ['es']},\n rollupOptions: {\n external: createExternalFromImportMap({imports}),\n output: {\n entryFileNames: '[name]-[hash].mjs',\n chunkFileNames: '[name]-[hash].mjs',\n exports: 'named',\n format: 'es',\n },\n treeshake: {preset: 'recommended'},\n },\n },\n })) as BuildResult\n\n buildResult = Array.isArray(buildResult) ? buildResult : [buildResult]\n\n // Create a map of the original import specifiers to their hashed filenames\n const hashedImports: Record<string, string> = {}\n const output = buildResult.flatMap((i) => i.output)\n\n for (const chunk of output) {\n if (chunk.type === 'asset') continue\n\n for (const [specifier, originalPath] of Object.entries(imports)) {\n if (originalPath.endsWith(`${chunk.name}.mjs`)) {\n hashedImports[specifier] = path.posix.join('/', basePath, VENDOR_DIR, chunk.fileName)\n }\n }\n }\n\n return hashedImports\n}\n","import path from 'node:path'\n\nimport resolveFrom from 'resolve-from'\nimport semver from 'semver'\n\nimport {type AutoUpdatesImportMap} from './getAutoUpdatesImportMap'\nimport {readPackageJson} from './readPackageJson'\n\nasync function getRemoteResolvedVersion(fetchFn: typeof fetch, url: string) {\n try {\n const res = await fetchFn(url, {method: 'HEAD', redirect: 'manual'})\n return res.headers.get('x-resolved-version')\n } catch (err) {\n throw new Error(`Failed to fetch remote version for ${url}: ${err.message}`)\n }\n}\n\ninterface CompareStudioDependencyVersions {\n pkg: string\n installed: string\n remote: string\n}\n\n/**\n * Compares the versions of dependencies in the studio 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 compareStudioDependencyVersions(\n autoUpdatesImports: AutoUpdatesImportMap,\n workDir: string,\n fetchFn = globalThis.fetch,\n): Promise<Array<CompareStudioDependencyVersions>> {\n const manifest = readPackageJson(path.join(workDir, 'package.json'))\n const dependencies = {...manifest.dependencies, ...manifest.devDependencies}\n\n const failedDependencies: Array<CompareStudioDependencyVersions> = []\n\n // Filter out the packages that are wildcards in the import map\n const filteredAutoUpdatesImports = Object.entries(autoUpdatesImports).filter(\n ([pkg]) => !pkg.endsWith('/'),\n ) as Array<[string, string]>\n\n for (const [pkg, value] of filteredAutoUpdatesImports) {\n const resolvedVersion = await getRemoteResolvedVersion(fetchFn, value)\n\n if (!resolvedVersion) {\n throw new Error(`Failed to fetch remote version for ${value}`)\n }\n\n const dependency = dependencies[pkg]\n const manifestPath = resolveFrom.silent(workDir, path.join(pkg, 'package.json'))\n\n const installed = semver.coerce(\n manifestPath ? readPackageJson(manifestPath).version : dependency,\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({pkg, installed: installed.version, remote: resolvedVersion})\n }\n }\n\n return failedDependencies\n}\n","/**\n * @internal\n */\nexport interface AutoUpdatesImportMap {\n 'sanity': string\n 'sanity/': string\n '@sanity/vision': string\n '@sanity/vision/': string\n}\n\nconst MODULES_HOST =\n process.env.SANITY_INTERNAL_ENV === 'staging'\n ? 'https://sanity-cdn.work'\n : 'https://sanity-cdn.com'\n\n/**\n * @internal\n */\nexport function getAutoUpdateImportMap(version: string): AutoUpdatesImportMap {\n const timestamp = `t${Math.floor(Date.now() / 1000)}`\n\n const autoUpdatesImports = {\n 'sanity': `${MODULES_HOST}/v1/modules/sanity/default/${version}/${timestamp}`,\n 'sanity/': `${MODULES_HOST}/v1/modules/sanity/default/${version}/${timestamp}/`,\n '@sanity/vision': `${MODULES_HOST}/v1/modules/@sanity__vision/default/${version}/${timestamp}`,\n '@sanity/vision/': `${MODULES_HOST}/v1/modules/@sanity__vision/default/${version}/${timestamp}/`,\n }\n\n return autoUpdatesImports\n}\n","import {type CliConfig} from '@sanity/cli'\n\nimport {type BuildSanityStudioCommandFlags} from '../actions/build/buildAction'\n\ninterface AutoUpdateSources {\n flags: BuildSanityStudioCommandFlags\n cliConfig?: CliConfig\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}: AutoUpdateSources): boolean {\n // cli flags (for example, '--no-auto-updates') should take precedence\n if ('auto-updates' in flags) {\n return Boolean(flags['auto-updates'])\n }\n\n if (cliConfig && 'autoUpdates' in cliConfig) {\n return Boolean(cliConfig.autoUpdates)\n }\n\n return false\n}\n","import path from 'node:path'\n\nimport chalk from 'chalk'\nimport {info} from 'log-symbols'\nimport semver from 'semver'\nimport {noopLogger} from '@sanity/telemetry'\nimport {rimraf} from 'rimraf'\nimport type {CliCommandArguments, CliCommandContext} from '@sanity/cli'\n\nimport {buildStaticFiles, ChunkModule, ChunkStats} from '../../server'\nimport {checkStudioDependencyVersions} from '../../util/checkStudioDependencyVersions'\nimport {checkRequiredDependencies} from '../../util/checkRequiredDependencies'\nimport {getTimer} from '../../util/timing'\nimport {BuildTrace} from './build.telemetry'\nimport {buildVendorDependencies} from '../../server/buildVendorDependencies'\nimport {compareStudioDependencyVersions} from '../../util/compareStudioDependencyVersions'\nimport {getAutoUpdateImportMap} from '../../util/getAutoUpdatesImportMap'\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\n\nexport interface BuildSanityStudioCommandFlags {\n 'yes'?: boolean\n 'y'?: boolean\n 'minify'?: boolean\n 'stats'?: boolean\n 'source-maps'?: boolean\n 'auto-updates'?: boolean\n}\n\nexport default async function buildSanityStudio(\n args: CliCommandArguments<BuildSanityStudioCommandFlags>,\n context: CliCommandContext,\n overrides?: {basePath?: string},\n): Promise<{didCompile: boolean}> {\n const timer = getTimer()\n const {output, prompt, workDir, cliConfig, telemetry = noopLogger} = context\n const flags: BuildSanityStudioCommandFlags = {\n 'minify': true,\n 'stats': false,\n 'source-maps': false,\n ...args.extOptions,\n }\n\n /**\n * Unattended mode means that if there are any prompts it will use `YES` for them but will no change anything that doesn't have a prompt\n */\n const unattendedMode = Boolean(flags.yes || flags.y)\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(args.argsWithoutOptions[0] || defaultOutputDir)\n\n await checkStudioDependencyVersions(workDir)\n\n // If the check resulted in a dependency install, the CLI command will be re-run,\n // thus we want to exit early\n const {didInstall, installedSanityVersion} = await checkRequiredDependencies(context)\n if (didInstall) {\n return {didCompile: false}\n }\n\n const autoUpdatesEnabled = shouldAutoUpdate({flags, cliConfig})\n\n // Get the version without any tags if any\n const coercedSanityVersion = semver.coerce(installedSanityVersion)?.version\n if (autoUpdatesEnabled && !coercedSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n const version = encodeURIComponent(`^${coercedSanityVersion}`)\n const autoUpdatesImports = getAutoUpdateImportMap(version)\n\n if (autoUpdatesEnabled) {\n output.print(`${info} Building with auto-updates enabled`)\n\n // Check the versions\n try {\n const result = await compareStudioDependencyVersions(autoUpdatesImports, workDir)\n\n // If it is in unattended mode, we don't want to prompt\n if (result?.length && !unattendedMode) {\n const shouldContinue = await prompt.single({\n type: 'confirm',\n message: chalk.yellow(\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you test locally with the same versions before deploying. \\n\\n` +\n `${result.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')} \\n\\n` +\n `Continue anyway?`,\n ),\n default: false,\n })\n\n if (!shouldContinue) {\n return process.exit(0)\n }\n }\n } catch (err) {\n throw err\n }\n }\n\n const envVarKeys = getSanityEnvVars()\n if (envVarKeys.length > 0) {\n output.print(\n '\\nIncluding the following environment variables as part of the JavaScript bundle:',\n )\n envVarKeys.forEach((key) => output.print(`- ${key}`))\n output.print('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode) {\n shouldClean = await prompt.single({\n type: 'confirm',\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n default: true,\n })\n }\n\n // Determine base path for built studio\n let basePath = '/'\n const envBasePath = process.env.SANITY_STUDIO_BASEPATH\n const configBasePath = cliConfig?.project?.basePath\n\n // Allow `sanity deploy` to override base path\n if (overrides?.basePath) {\n basePath = overrides.basePath\n } else if (envBasePath) {\n // Environment variable (SANITY_STUDIO_BASEPATH)\n basePath = envBasePath\n } else if (configBasePath) {\n // `sanity.cli.ts`\n basePath = configBasePath\n }\n\n if (envBasePath && configBasePath) {\n output.warn(\n `Overriding configured base path (${configBasePath}) with value from environment variable (${envBasePath})`,\n )\n }\n\n let spin\n\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = output.spinner('Clean output folder').start()\n await rimraf(outputDir)\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed()}ms)`\n spin.succeed()\n }\n\n spin = output.spinner('Build Sanity Studio').start()\n\n const trace = telemetry.trace(BuildTrace)\n trace.start()\n\n let importMap\n\n if (autoUpdatesEnabled) {\n importMap = {\n imports: {\n ...(await buildVendorDependencies({cwd: workDir, outputDir, basePath})),\n ...autoUpdatesImports,\n },\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n cwd: workDir,\n outputDir,\n basePath,\n sourceMap: Boolean(flags['source-maps']),\n minify: Boolean(flags.minify),\n vite: cliConfig && 'vite' in cliConfig ? cliConfig.vite : undefined,\n importMap,\n reactCompiler:\n cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n })\n\n trace.log({\n outputSize: bundle.chunks\n .flatMap((chunk) => chunk.modules.flatMap((mod) => mod.renderedLength))\n .reduce((sum, n) => sum + n, 0),\n })\n const buildDuration = timer.end('bundleStudio')\n\n spin.text = `Build Sanity Studio (${buildDuration.toFixed()}ms)`\n spin.succeed()\n\n trace.complete()\n if (flags.stats) {\n output.print('\\nLargest module files:')\n output.print(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n } catch (err) {\n spin.fail()\n trace.error(err)\n throw err\n }\n\n return {didCompile: true}\n}\n\n// eslint-disable-next-line no-process-env\nfunction getSanityEnvVars(env: Record<string, string | undefined> = process.env): string[] {\n return Object.keys(env).filter((key) => key.toUpperCase().startsWith('SANITY_STUDIO_'))\n}\n\nfunction sortModulesBySize(chunks: ChunkStats[]): ChunkModule[] {\n return chunks\n .flatMap((chunk) => chunk.modules)\n .sort((modA, modB) => modB.renderedLength - modA.renderedLength)\n}\n\nfunction formatModuleSizes(modules: ChunkModule[]): string {\n const lines: string[] = []\n for (const mod of modules) {\n lines.push(` - ${formatModuleName(mod.name)} (${formatSize(mod.renderedLength)})`)\n }\n\n return lines.join('\\n')\n}\n\nfunction formatModuleName(modName: string): string {\n const delimiter = '/node_modules/'\n const nodeIndex = modName.lastIndexOf(delimiter)\n return nodeIndex === -1 ? modName : modName.slice(nodeIndex + delimiter.length)\n}\n\nfunction formatSize(bytes: number): string {\n return chalk.cyan(`${(bytes / 1024).toFixed()} kB`)\n}\n"],"names":["BuildTrace","defineTrace","name","version","description","VENDOR_DIR","VENDOR_IMPORTS","buildVendorDependencies","cwd","outputDir","basePath","dir","path","relative","process","resolve","entry","imports","packageName","ranges","Object","entries","packageJsonPath","resolveFrom","silent","join","Error","packageJson","JSON","parse","fs","promises","readFile","e","message","cause","semver","coerce","sortedRanges","keys","sort","range1","range2","min1","minVersion","min2","rcompare","matchedRange","find","range","satisfies","min","length","gt","subpaths","subpath","relativeEntryPoint","packagePath","dirname","entryPoint","specifier","posix","chunkName","build","buildResult","cacheDir","root","configFile","logLevel","appType","mode","define","stringify","minify","emptyOutDir","outDir","lib","formats","rollupOptions","external","createExternalFromImportMap","output","entryFileNames","chunkFileNames","exports","format","treeshake","preset","Array","isArray","hashedImports","flatMap","i","chunk","type","originalPath","endsWith","fileName","getRemoteResolvedVersion","fetchFn","url","method","redirect","headers","get","err","compareStudioDependencyVersions","autoUpdatesImports","workDir","globalThis","fetch","manifest","readPackageJson","dependencies","devDependencies","failedDependencies","filteredAutoUpdatesImports","filter","pkg","value","resolvedVersion","dependency","manifestPath","installed","eq","push","remote","MODULES_HOST","env","SANITY_INTERNAL_ENV","getAutoUpdateImportMap","timestamp","Math","floor","Date","now","shouldAutoUpdate","flags","cliConfig","Boolean","autoUpdates","buildSanityStudio","args","context","overrides","timer","getTimer","prompt","telemetry","noopLogger","extOptions","unattendedMode","yes","y","defaultOutputDir","argsWithoutOptions","checkStudioDependencyVersions","didInstall","installedSanityVersion","checkRequiredDependencies","didCompile","autoUpdatesEnabled","coercedSanityVersion","encodeURIComponent","print","info","result","single","chalk","yellow","map","mod","default","exit","envVarKeys","getSanityEnvVars","forEach","key","shouldClean","envBasePath","SANITY_STUDIO_BASEPATH","configBasePath","project","warn","spin","start","spinner","rimraf","cleanDuration","end","text","toFixed","succeed","trace","importMap","bundle","buildStaticFiles","sourceMap","vite","undefined","reactCompiler","log","outputSize","chunks","modules","renderedLength","reduce","sum","n","buildDuration","complete","stats","formatModuleSizes","sortModulesBySize","slice","fail","error","toUpperCase","startsWith","modA","modB","lines","formatModuleName","formatSize","modName","delimiter","nodeIndex","lastIndexOf","bytes","cyan"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAMA,aAAaC,UAAAA,YAAkC;AAAA,EAC1DC,MAAM;AAAA,EACNC,SAAS;AAAA,EACTC,aAAa;AACf,CAAC,GCGKC,aAAa,UAqDbC,iBAAgC;AAAA,EACpC,OAAS;AAAA,IACP,WAAW;AAAA,MACT,KAAK;AAAA,MACL,iBAAiB;AAAA,MACjB,qBAAqB;AAAA,MACrB,sBAAsB;AAAA,MACtB,kBAAkB;AAAA,IACpB;AAAA,IACA,WAAW;AAAA,MACT,KAAK;AAAA,MACL,iBAAiB;AAAA,MACjB,qBAAqB;AAAA,MACrB,kBAAkB;AAAA,IAAA;AAAA,EAEtB;AAAA,EACA,aAAa;AAAA,IACX,WAAW;AAAA,MACT,KAAK;AAAA,MACL,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,oBAAoB;AAAA,MACpB,YAAY;AAAA,MACZ,oBAAoB;AAAA,MACpB,kBAAkB;AAAA,IACpB;AAAA,IACA,WAAW;AAAA,MACT,KAAK;AAAA,MACL,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,oBAAoB;AAAA,MACpB,kBAAkB;AAAA,IAAA;AAAA,EAEtB;AAAA,EACA,qBAAqB;AAAA,IACnB,UAAU;AAAA,MACR,KAAK;AAAA,MACL,kBAAkB;AAAA,IAAA;AAAA,EACpB;AAEJ;AAYA,eAAsBC,wBAAwB;AAAA,EAC5CC;AAAAA,EACAC;AAAAA,EACAC;AACkB,GAAoC;AAEtD,QAAMC,MAAMC,cAAAA,QAAKC,SAASC,QAAQN,OAAOI,cAAAA,QAAKG,QAAQP,GAAG,CAAC,GACpDQ,QAAgC,CAAC,GACjCC,UAAkC,CAAC;AAGzC,aAAW,CAACC,aAAaC,MAAM,KAAKC,OAAOC,QAAQf,cAAc,G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F;AAEA,SAAS2K,WAAWK,OAAuB;AACzC,SAAO5D,uBAAM6D,KAAK,IAAID,QAAQ,MAAMrC,SAAS,KAAK;AACpD;;;;;;;;"}
1
+ {"version":3,"file":"buildAction.js","sources":["../../src/_internal/cli/actions/build/build.telemetry.ts","../../src/_internal/cli/server/buildVendorDependencies.ts","../../src/_internal/cli/util/compareStudioDependencyVersions.ts","../../src/_internal/cli/util/getAutoUpdatesImportMap.ts","../../src/_internal/cli/util/shouldAutoUpdate.ts","../../src/_internal/cli/actions/build/buildAction.ts"],"sourcesContent":["import {defineTrace} from '@sanity/telemetry'\n\nexport const BuildTrace = defineTrace<{outputSize: number}>({\n name: 'Studio Build Completed',\n version: 0,\n description: 'A Studio build completed',\n})\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport resolveFrom from 'resolve-from'\nimport semver from 'semver'\n\nimport {createExternalFromImportMap} from './createExternalFromImportMap'\n\n// Directory where vendor packages will be stored\nconst VENDOR_DIR = 'vendor'\n\n/**\n * A type representing the imports of vendor packages, defining specific entry\n * points for various versions and subpaths of the packages.\n *\n * The `VendorImports` object is used to build ESM browser-compatible versions\n * of the specified packages. This approach ensures that the appropriate version\n * and entry points are used for each package, enabling compatibility and proper\n * functionality in the browser environment.\n *\n * ## Rationale\n *\n * The rationale for this structure is to handle different versions of the\n * packages carefully, especially major versions. Major version bumps often\n * introduce breaking changes, so the module scheme for the package needs to be\n * checked when there is a major version update. However, minor and patch\n * versions are generally backward compatible, so they are handled more\n * leniently. By assuming that new minor versions are compatible, we avoid\n * unnecessary warnings and streamline the update process.\n *\n * If a new minor version introduces an additional subpath export within the\n * package of this version range, the corresponding package can add a more\n * specific version range that includes the new subpath. This design allows for\n * flexibility and ease of maintenance, ensuring that the latest features and\n * fixes are incorporated without extensive manual intervention.\n *\n * An additional subpath export within the package of this version range that\n * could cause the build to break if that new export is used, can be treated as\n * a bug fix. It might make more sense to our users that this new subpath isn't\n * supported yet until we address it as a bug fix. This approach helps maintain\n * stability and prevents unexpected issues during the build process.\n *\n * ## Structure\n * The `VendorImports` type is a nested object where:\n * - The keys at the first level represent the package names.\n * - The keys at the second level represent the version ranges (e.g., `^19.0.0`).\n * - The keys at the third level represent the subpaths within the package (e.g., `.` for the main entry point).\n * - The values at the third level are the relative paths to the corresponding entry points within the package.\n *\n * This structure allows for precise specification of the entry points for\n * different versions and subpaths, ensuring that the correct files are used\n * during the build process.\n */\ntype VendorImports = {\n [packageName: string]: {\n [versionRange: string]: {\n [subpath: string]: string\n }\n }\n}\n\n// Define the vendor packages and their corresponding versions and entry points\nconst VENDOR_IMPORTS: VendorImports = {\n 'react': {\n '^19.0.0': {\n '.': './cjs/react.production.js',\n './jsx-runtime': './cjs/react-jsx-runtime.production.js',\n './jsx-dev-runtime': './cjs/react-jsx-dev-runtime.production.js',\n './compiler-runtime': './cjs/react-compiler-runtime.production.js',\n './package.json': './package.json',\n },\n '^18.0.0': {\n '.': './cjs/react.production.min.js',\n './jsx-runtime': './cjs/react-jsx-runtime.production.min.js',\n './jsx-dev-runtime': './cjs/react-jsx-dev-runtime.production.min.js',\n './package.json': './package.json',\n },\n },\n 'react-dom': {\n '^19.0.0': {\n '.': './cjs/react-dom.production.js',\n './client': './cjs/react-dom-client.production.js',\n './server': './cjs/react-dom-server-legacy.browser.production.js',\n './server.browser': './cjs/react-dom-server-legacy.browser.production.js',\n './static': './cjs/react-dom-server.browser.production.js',\n './static.browser': './cjs/react-dom-server.browser.production.js',\n './package.json': './package.json',\n },\n '^18.0.0': {\n '.': './cjs/react-dom.production.min.js',\n './client': './cjs/react-dom.production.min.js',\n './server': './cjs/react-dom-server-legacy.browser.production.min.js',\n './server.browser': './cjs/react-dom-server-legacy.browser.production.min.js',\n './package.json': './package.json',\n },\n },\n 'styled-components': {\n '^6.1.0': {\n '.': './dist/styled-components.esm.js',\n './package.json': './package.json',\n },\n },\n}\n\ninterface VendorBuildOptions {\n cwd: string\n outputDir: string\n basePath: string\n}\n\n/**\n * Builds the ESM browser compatible versions of the vendor packages\n * specified in VENDOR_IMPORTS. Returns the `imports` object of an import map.\n */\nexport async function buildVendorDependencies({\n cwd,\n outputDir,\n basePath,\n}: VendorBuildOptions): Promise<Record<string, string>> {\n // normalize the CWD to a relative dir for better error messages\n const dir = path.relative(process.cwd(), path.resolve(cwd))\n const entry: Record<string, string> = {}\n const imports: Record<string, string> = {}\n\n // Iterate over each package and its version ranges in VENDOR_IMPORTS\n for (const [packageName, ranges] of Object.entries(VENDOR_IMPORTS)) {\n const packageJsonPath = resolveFrom.silent(cwd, path.join(packageName, 'package.json'))\n if (!packageJsonPath) {\n throw new Error(\n `Could not find package.json for package '${packageName}' from directory '${dir}'. Is it installed?`,\n )\n }\n\n let packageJson\n\n try {\n // Read and parse the package.json file\n packageJson = JSON.parse(await fs.promises.readFile(packageJsonPath, 'utf-8'))\n } catch (e) {\n const message = `Could not read package.json for package '${packageName}' from directory '${dir}'`\n if (typeof e?.message === 'string') {\n // Re-assign the error message so the stack trace is more visible\n e.message = `${message}: ${e.message}`\n throw e\n }\n\n throw new Error(message, {cause: e})\n }\n\n // Coerce the version to a semver-compatible version\n const version = semver.coerce(packageJson.version)?.version\n if (!version) {\n throw new Error(`Could not parse version '${packageJson.version}' from '${packageName}'`)\n }\n\n // Sort version ranges in descending order\n const sortedRanges = Object.keys(ranges).sort((range1, range2) => {\n const min1 = semver.minVersion(range1)\n const min2 = semver.minVersion(range2)\n\n if (!min1) throw new Error(`Could not parse range '${range1}'`)\n if (!min2) throw new Error(`Could not parse range '${range2}'`)\n\n // sort them in reverse so we can rely on array `.find` below\n return semver.rcompare(min1.version, min2.version)\n })\n\n // Find the first version range that satisfies the package version\n const matchedRange = sortedRanges.find((range) => semver.satisfies(version, range))\n\n if (!matchedRange) {\n const min = semver.minVersion(sortedRanges[sortedRanges.length - 1])\n if (!min) {\n throw new Error(`Could not find a minimum version for package '${packageName}'`)\n }\n\n if (semver.gt(min.version, version)) {\n throw new Error(`Package '${packageName}' requires at least ${min.version}.`)\n }\n\n throw new Error(`Version '${version}' of package '${packageName}' is not supported yet.`)\n }\n\n const subpaths = ranges[matchedRange]\n\n // Iterate over each subpath and its corresponding entry point\n for (const [subpath, relativeEntryPoint] of Object.entries(subpaths)) {\n const packagePath = path.dirname(packageJsonPath)\n const entryPoint = resolveFrom.silent(packagePath, relativeEntryPoint)\n\n if (!entryPoint) {\n throw new Error(\n `Failed to resolve entry point '${path.join(packageName, relativeEntryPoint)}'. `,\n )\n }\n\n const specifier = path.posix.join(packageName, subpath)\n const chunkName = path.posix.join(\n packageName,\n path.relative(packageName, specifier) || 'index',\n )\n\n entry[chunkName] = entryPoint\n imports[specifier] = path.posix.join('/', basePath, VENDOR_DIR, `${chunkName}.mjs`)\n }\n }\n\n // removes the `RollupWatcher` type\n type BuildResult = Exclude<Awaited<ReturnType<typeof build>>, {close: unknown}>\n\n const {build} = await import('vite')\n // Use Vite to build the packages into the output directory\n let buildResult = (await build({\n // Define a custom cache directory so that sanity's vite cache\n // does not conflict with any potential local vite projects\n cacheDir: 'node_modules/.sanity/vite-vendor',\n root: cwd,\n configFile: false,\n logLevel: 'silent',\n\n appType: 'custom',\n mode: 'production',\n define: {'process.env.NODE_ENV': JSON.stringify('production')},\n\n build: {\n commonjsOptions: {strictRequires: 'auto'},\n minify: true,\n emptyOutDir: false, // Rely on CLI to do this\n outDir: path.join(outputDir, VENDOR_DIR),\n lib: {entry, formats: ['es']},\n rollupOptions: {\n external: createExternalFromImportMap({imports}),\n output: {\n entryFileNames: '[name]-[hash].mjs',\n chunkFileNames: '[name]-[hash].mjs',\n exports: 'named',\n format: 'es',\n },\n treeshake: {preset: 'recommended'},\n },\n },\n })) as BuildResult\n\n buildResult = Array.isArray(buildResult) ? buildResult : [buildResult]\n\n // Create a map of the original import specifiers to their hashed filenames\n const hashedImports: Record<string, string> = {}\n const output = buildResult.flatMap((i) => i.output)\n\n for (const chunk of output) {\n if (chunk.type === 'asset') continue\n\n for (const [specifier, originalPath] of Object.entries(imports)) {\n if (originalPath.endsWith(`${chunk.name}.mjs`)) {\n hashedImports[specifier] = path.posix.join('/', basePath, VENDOR_DIR, chunk.fileName)\n }\n }\n }\n\n return hashedImports\n}\n","import path from 'node:path'\n\nimport resolveFrom from 'resolve-from'\nimport semver from 'semver'\n\nimport {type AutoUpdatesImportMap} from './getAutoUpdatesImportMap'\nimport {readPackageJson} from './readPackageJson'\n\nasync function getRemoteResolvedVersion(fetchFn: typeof fetch, url: string) {\n try {\n const res = await fetchFn(url, {method: 'HEAD', redirect: 'manual'})\n return res.headers.get('x-resolved-version')\n } catch (err) {\n throw new Error(`Failed to fetch remote version for ${url}: ${err.message}`)\n }\n}\n\ninterface CompareStudioDependencyVersions {\n pkg: string\n installed: string\n remote: string\n}\n\n/**\n * Compares the versions of dependencies in the studio 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 compareStudioDependencyVersions(\n autoUpdatesImports: AutoUpdatesImportMap,\n workDir: string,\n fetchFn = globalThis.fetch,\n): Promise<Array<CompareStudioDependencyVersions>> {\n const manifest = readPackageJson(path.join(workDir, 'package.json'))\n const dependencies = {...manifest.dependencies, ...manifest.devDependencies}\n\n const failedDependencies: Array<CompareStudioDependencyVersions> = []\n\n // Filter out the packages that are wildcards in the import map\n const filteredAutoUpdatesImports = Object.entries(autoUpdatesImports).filter(\n ([pkg]) => !pkg.endsWith('/'),\n ) as Array<[string, string]>\n\n for (const [pkg, value] of filteredAutoUpdatesImports) {\n const resolvedVersion = await getRemoteResolvedVersion(fetchFn, value)\n\n if (!resolvedVersion) {\n throw new Error(`Failed to fetch remote version for ${value}`)\n }\n\n const dependency = dependencies[pkg]\n const manifestPath = resolveFrom.silent(workDir, path.join(pkg, 'package.json'))\n\n const installed = semver.coerce(\n manifestPath ? readPackageJson(manifestPath).version : dependency,\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({pkg, installed: installed.version, remote: resolvedVersion})\n }\n }\n\n return failedDependencies\n}\n","/**\n * @internal\n */\nexport interface AutoUpdatesImportMap {\n 'sanity': string\n 'sanity/': string\n '@sanity/vision': string\n '@sanity/vision/': string\n}\n\nconst MODULES_HOST =\n process.env.SANITY_INTERNAL_ENV === 'staging'\n ? 'https://sanity-cdn.work'\n : 'https://sanity-cdn.com'\n\n/**\n * @internal\n */\nexport function getAutoUpdateImportMap(version: string): AutoUpdatesImportMap {\n const timestamp = `t${Math.floor(Date.now() / 1000)}`\n\n const autoUpdatesImports = {\n 'sanity': `${MODULES_HOST}/v1/modules/sanity/default/${version}/${timestamp}`,\n 'sanity/': `${MODULES_HOST}/v1/modules/sanity/default/${version}/${timestamp}/`,\n '@sanity/vision': `${MODULES_HOST}/v1/modules/@sanity__vision/default/${version}/${timestamp}`,\n '@sanity/vision/': `${MODULES_HOST}/v1/modules/@sanity__vision/default/${version}/${timestamp}/`,\n }\n\n return autoUpdatesImports\n}\n","import {type CliConfig} from '@sanity/cli'\n\nimport {type BuildSanityStudioCommandFlags} from '../actions/build/buildAction'\n\ninterface AutoUpdateSources {\n flags: BuildSanityStudioCommandFlags\n cliConfig?: CliConfig\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}: AutoUpdateSources): boolean {\n // cli flags (for example, '--no-auto-updates') should take precedence\n if ('auto-updates' in flags) {\n return Boolean(flags['auto-updates'])\n }\n\n if (cliConfig && 'autoUpdates' in cliConfig) {\n return Boolean(cliConfig.autoUpdates)\n }\n\n return false\n}\n","import path from 'node:path'\n\nimport chalk from 'chalk'\nimport {info} from 'log-symbols'\nimport semver from 'semver'\nimport {noopLogger} from '@sanity/telemetry'\nimport {rimraf} from 'rimraf'\nimport type {CliCommandArguments, CliCommandContext} from '@sanity/cli'\n\nimport {buildStaticFiles, ChunkModule, ChunkStats} from '../../server'\nimport {checkStudioDependencyVersions} from '../../util/checkStudioDependencyVersions'\nimport {checkRequiredDependencies} from '../../util/checkRequiredDependencies'\nimport {getTimer} from '../../util/timing'\nimport {BuildTrace} from './build.telemetry'\nimport {buildVendorDependencies} from '../../server/buildVendorDependencies'\nimport {compareStudioDependencyVersions} from '../../util/compareStudioDependencyVersions'\nimport {getAutoUpdateImportMap} from '../../util/getAutoUpdatesImportMap'\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\n\nexport interface BuildSanityStudioCommandFlags {\n 'yes'?: boolean\n 'y'?: boolean\n 'minify'?: boolean\n 'stats'?: boolean\n 'source-maps'?: boolean\n 'auto-updates'?: boolean\n}\n\nexport default async function buildSanityStudio(\n args: CliCommandArguments<BuildSanityStudioCommandFlags>,\n context: CliCommandContext,\n overrides?: {basePath?: string},\n): Promise<{didCompile: boolean}> {\n const timer = getTimer()\n const {output, prompt, workDir, cliConfig, telemetry = noopLogger} = context\n const flags: BuildSanityStudioCommandFlags = {\n 'minify': true,\n 'stats': false,\n 'source-maps': false,\n ...args.extOptions,\n }\n\n /**\n * Unattended mode means that if there are any prompts it will use `YES` for them but will no change anything that doesn't have a prompt\n */\n const unattendedMode = Boolean(flags.yes || flags.y)\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(args.argsWithoutOptions[0] || defaultOutputDir)\n\n await checkStudioDependencyVersions(workDir)\n\n // If the check resulted in a dependency install, the CLI command will be re-run,\n // thus we want to exit early\n const {didInstall, installedSanityVersion} = await checkRequiredDependencies(context)\n if (didInstall) {\n return {didCompile: false}\n }\n\n const autoUpdatesEnabled = shouldAutoUpdate({flags, cliConfig})\n\n // Get the version without any tags if any\n const coercedSanityVersion = semver.coerce(installedSanityVersion)?.version\n if (autoUpdatesEnabled && !coercedSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n const version = encodeURIComponent(`^${coercedSanityVersion}`)\n const autoUpdatesImports = getAutoUpdateImportMap(version)\n\n if (autoUpdatesEnabled) {\n output.print(`${info} Building with auto-updates enabled`)\n\n // Check the versions\n try {\n const result = await compareStudioDependencyVersions(autoUpdatesImports, workDir)\n\n // If it is in unattended mode, we don't want to prompt\n if (result?.length && !unattendedMode) {\n const shouldContinue = await prompt.single({\n type: 'confirm',\n message: chalk.yellow(\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you test locally with the same versions before deploying. \\n\\n` +\n `${result.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')} \\n\\n` +\n `Continue anyway?`,\n ),\n default: false,\n })\n\n if (!shouldContinue) {\n return process.exit(0)\n }\n }\n } catch (err) {\n throw err\n }\n }\n\n const envVarKeys = getSanityEnvVars()\n if (envVarKeys.length > 0) {\n output.print(\n '\\nIncluding the following environment variables as part of the JavaScript bundle:',\n )\n envVarKeys.forEach((key) => output.print(`- ${key}`))\n output.print('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode) {\n shouldClean = await prompt.single({\n type: 'confirm',\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n default: true,\n })\n }\n\n // Determine base path for built studio\n let basePath = '/'\n const envBasePath = process.env.SANITY_STUDIO_BASEPATH\n const configBasePath = cliConfig?.project?.basePath\n\n // Allow `sanity deploy` to override base path\n if (overrides?.basePath) {\n basePath = overrides.basePath\n } else if (envBasePath) {\n // Environment variable (SANITY_STUDIO_BASEPATH)\n basePath = envBasePath\n } else if (configBasePath) {\n // `sanity.cli.ts`\n basePath = configBasePath\n }\n\n if (envBasePath && configBasePath) {\n output.warn(\n `Overriding configured base path (${configBasePath}) with value from environment variable (${envBasePath})`,\n )\n }\n\n let spin\n\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = output.spinner('Clean output folder').start()\n await rimraf(outputDir)\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed()}ms)`\n spin.succeed()\n }\n\n spin = output.spinner('Build Sanity Studio').start()\n\n const trace = telemetry.trace(BuildTrace)\n trace.start()\n\n let importMap\n\n if (autoUpdatesEnabled) {\n importMap = {\n imports: {\n ...(await buildVendorDependencies({cwd: workDir, outputDir, basePath})),\n ...autoUpdatesImports,\n },\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n cwd: workDir,\n outputDir,\n basePath,\n sourceMap: Boolean(flags['source-maps']),\n minify: Boolean(flags.minify),\n vite: cliConfig && 'vite' in cliConfig ? cliConfig.vite : undefined,\n importMap,\n reactCompiler:\n cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n })\n\n trace.log({\n outputSize: bundle.chunks\n .flatMap((chunk) => chunk.modules.flatMap((mod) => mod.renderedLength))\n .reduce((sum, n) => sum + n, 0),\n })\n const buildDuration = timer.end('bundleStudio')\n\n spin.text = `Build Sanity Studio (${buildDuration.toFixed()}ms)`\n spin.succeed()\n\n trace.complete()\n if (flags.stats) {\n output.print('\\nLargest module files:')\n output.print(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n } catch (err) {\n spin.fail()\n trace.error(err)\n throw err\n }\n\n return {didCompile: true}\n}\n\n// eslint-disable-next-line no-process-env\nfunction getSanityEnvVars(env: Record<string, string | undefined> = process.env): string[] {\n return Object.keys(env).filter((key) => key.toUpperCase().startsWith('SANITY_STUDIO_'))\n}\n\nfunction sortModulesBySize(chunks: ChunkStats[]): ChunkModule[] {\n return chunks\n .flatMap((chunk) => chunk.modules)\n .sort((modA, modB) => modB.renderedLength - modA.renderedLength)\n}\n\nfunction formatModuleSizes(modules: ChunkModule[]): string {\n const lines: string[] = []\n for (const mod of modules) {\n lines.push(` - ${formatModuleName(mod.name)} (${formatSize(mod.renderedLength)})`)\n }\n\n return lines.join('\\n')\n}\n\nfunction formatModuleName(modName: string): string {\n const delimiter = '/node_modules/'\n const nodeIndex = modName.lastIndexOf(delimiter)\n return nodeIndex === -1 ? modName : modName.slice(nodeIndex + delimiter.length)\n}\n\nfunction formatSize(bytes: number): string {\n return chalk.cyan(`${(bytes / 1024).toFixed()} kB`)\n}\n"],"names":["BuildTrace","defineTrace","name","version","description","VENDOR_DIR","VENDOR_IMPORTS","buildVendorDependencies","cwd","outputDir","basePath","dir","path","relative","process","resolve","entry","imports","packageName","ranges","Object","entries","packageJsonPath","resolveFrom","silent","join","Error","packageJson","JSON","parse","fs","promises","readFile","e","message","cause","semver","coerce","sortedRanges","keys","sort","range1","range2","min1","minVersion","min2","rcompare","matchedRange","find","range","satisfies","min","length","gt","subpaths","subpath","relativeEntryPoint","packagePath","dirname","entryPoint","specifier","posix","chunkName","build","buildResult","cacheDir","root","configFile","logLevel","appType","mode","define","stringify","commonjsOptions","strictRequires","minify","emptyOutDir","outDir","lib","formats","rollupOptions","external","createExternalFromImportMap","output","entryFileNames","chunkFileNames","exports","format","treeshake","preset","Array","isArray","hashedImports","flatMap","i","chunk","type","originalPath","endsWith","fileName","getRemoteResolvedVersion","fetchFn","url","method","redirect","headers","get","err","compareStudioDependencyVersions","autoUpdatesImports","workDir","globalThis","fetch","manifest","readPackageJson","dependencies","devDependencies","failedDependencies","filteredAutoUpdatesImports","filter","pkg","value","resolvedVersion","dependency","manifestPath","installed","eq","push","remote","MODULES_HOST","env","SANITY_INTERNAL_ENV","getAutoUpdateImportMap","timestamp","Math","floor","Date","now","shouldAutoUpdate","flags","cliConfig","Boolean","autoUpdates","buildSanityStudio","args","context","overrides","timer","getTimer","prompt","telemetry","noopLogger","extOptions","unattendedMode","yes","y","defaultOutputDir","argsWithoutOptions","checkStudioDependencyVersions","didInstall","installedSanityVersion","checkRequiredDependencies","didCompile","autoUpdatesEnabled","coercedSanityVersion","encodeURIComponent","print","info","result","single","chalk","yellow","map","mod","default","exit","envVarKeys","getSanityEnvVars","forEach","key","shouldClean","envBasePath","SANITY_STUDIO_BASEPATH","configBasePath","project","warn","spin","start","spinner","rimraf","cleanDuration","end","text","toFixed","succeed","trace","importMap","bundle","buildStaticFiles","sourceMap","vite","undefined","reactCompiler","log","outputSize","chunks","modules","renderedLength","reduce","sum","n","buildDuration","complete","stats","formatModuleSizes","sortModulesBySize","slice","fail","error","toUpperCase","startsWith","modA","modB","lines","formatModuleName","formatSize","modName","delimiter","nodeIndex","lastIndexOf","bytes","cyan"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAMA,aAAaC,UAAAA,YAAkC;AAAA,EAC1DC,MAAM;AAAA,EACNC,SAAS;AAAA,EACTC,aAAa;AACf,CAAC,GCGKC,aAAa,UAqDbC,iBAAgC;AAAA,EACpC,OAAS;AAAA,IACP,WAAW;AAAA,MACT,KAAK;AAAA,MACL,iBAAiB;AAAA,MACjB,qBAAqB;AAAA,MACrB,sBAAsB;AAAA,MACtB,kBAAkB;AAAA,IACpB;AAAA,IACA,WAAW;AAAA,MACT,KAAK;AAAA,MACL,iBAAiB;AAAA,MACjB,qBAAqB;AAAA,MACrB,kBAAkB;AAAA,IAAA;AAAA,EAEtB;AAAA,EACA,aAAa;AAAA,IACX,WAAW;AAAA,MACT,KAAK;AAAA,MACL,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,oBAAoB;AAAA,MACpB,YAAY;AAAA,MACZ,oBAAoB;A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AIwC,YAAY,EAAEC,WAAW,gBAAgB,CAAC;AACxF;AAEA,SAASL,kBAAkBV,QAAqC;AAC9D,SAAOA,OACJhH,QAASE,CAAUA,UAAAA,MAAM+G,OAAO,EAChCtK,KAAK,CAACqL,MAAMC,SAASA,KAAKf,iBAAiBc,KAAKd,cAAc;AACnE;AAEA,SAASO,kBAAkBR,SAAgC;AACzD,QAAMiB,QAAkB,CAAE;AAC1B,aAAWlD,OAAOiC;AACV/E,UAAAA,KAAK,MAAMiG,iBAAiBnD,IAAI3K,IAAI,CAAC,KAAK+N,WAAWpD,IAAIkC,cAAc,CAAC,GAAG;AAGnF,SAAOgB,MAAMtM,KAAK;AAAA,CAAI;AACxB;AAEA,SAASuM,iBAAiBE,SAAyB;AACjD,QAAMC,YAAY,kBACZC,YAAYF,QAAQG,YAAYF,SAAS;AAC/C,SAAOC,cAAc,KAAKF,UAAUA,QAAQV,MAAMY,YAAYD,UAAU/K,MAAM;AAChF;AAEA,SAAS6K,WAAWK,OAAuB;AACzC,SAAO5D,uBAAM6D,KAAK,IAAID,QAAQ,MAAMrC,SAAS,KAAK;AACpD;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), _singletons = require("sanity/_singletons"), jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), icons = require("@sanity/icons"), ui = require("@sanity/ui"), styledComponents = require("styled-components"), get = require("lodash/get.js"), rxjs = require("rxjs"), router$1 = require("sanity/router"), useEffectEvent = require("use-effect-event"), uuid = require("@sanity/uuid"), valibot = require("valibot");
2
+ var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), _singletons = require("sanity/_singletons"), jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), icons = require("@sanity/icons"), constants = require("@sanity/preview-url-secret/constants"), ui = require("@sanity/ui"), styledComponents = require("styled-components"), get = require("lodash/get.js"), rxjs = require("rxjs"), router$1 = require("sanity/router"), useEffectEvent = require("use-effect-event"), uuid = require("@sanity/uuid"), valibot = require("valibot");
3
3
  function _interopDefaultCompat(e) {
4
4
  return e && typeof e == "object" && "default" in e ? e : { default: e };
5
5
  }
@@ -15,7 +15,7 @@ const useSharedState = (key, value) => {
15
15
  $[0] !== key || $[1] !== setValue || $[2] !== value ? (t0 = () => {
16
16
  setValue(key, value);
17
17
  }, t1 = [key, value, setValue], $[0] = key, $[1] = setValue, $[2] = value, $[3] = t0, $[4] = t1) : (t0 = $[3], t1 = $[4]), React.useEffect(t0, t1);
18
- }, DEFAULT_TOOL_ICON = icons.ComposeIcon, DEFAULT_TOOL_NAME = "presentation", DEFAULT_TOOL_TITLE = "Presentation", EDIT_INTENT_MODE = "presentation", MAX_TIME_TO_OVERLAYS_CONNECTION = 3e3, API_VERSION = "2023-10-16", MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = 1e3, LIVE_QUERY_CACHE_BATCH_SIZE = 100, LIVE_QUERY_CACHE_SIZE = 2048, POPUP_CHECK_INTERVAL = 1e3;
18
+ }, DEFAULT_TOOL_ICON = icons.ComposeIcon, DEFAULT_TOOL_NAME = "presentation", DEFAULT_TOOL_TITLE = "Presentation", EDIT_INTENT_MODE = "presentation", MAX_TIME_TO_OVERLAYS_CONNECTION = 3e3, API_VERSION = constants.apiVersion, MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = 1e3, LOADER_QUERY_GC_INTERVAL = 3e4, POPUP_CHECK_INTERVAL = 1e3;
19
19
  function keysOf(value) {
20
20
  return Object.keys(value);
21
21
  }
@@ -591,8 +591,7 @@ exports.ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE = ACTION_VISUAL_EDITING_OVERLAYS_T
591
591
  exports.API_VERSION = API_VERSION;
592
592
  exports.DEFAULT_TOOL_NAME = DEFAULT_TOOL_NAME;
593
593
  exports.EDIT_INTENT_MODE = EDIT_INTENT_MODE;
594
- exports.LIVE_QUERY_CACHE_BATCH_SIZE = LIVE_QUERY_CACHE_BATCH_SIZE;
595
- exports.LIVE_QUERY_CACHE_SIZE = LIVE_QUERY_CACHE_SIZE;
594
+ exports.LOADER_QUERY_GC_INTERVAL = LOADER_QUERY_GC_INTERVAL;
596
595
  exports.MAX_TIME_TO_OVERLAYS_CONNECTION = MAX_TIME_TO_OVERLAYS_CONNECTION;
597
596
  exports.MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL;
598
597
  exports.POPUP_CHECK_INTERVAL = POPUP_CHECK_INTERVAL;
@@ -1 +1 @@
1
- {"version":3,"file":"presentation.js","sources":["../../src/presentation/overlays/useSharedState.ts","../../src/presentation/constants.ts","../../src/presentation/util/props.ts","../../src/presentation/useDocumentLocations.ts","../../src/presentation/i18n/index.ts","../../src/presentation/usePresentationTool.ts","../../src/presentation/document/useCurrentPresentationToolName.ts","../../src/presentation/document/LocationsBanner.tsx","../../src/presentation/document/PresentationDocumentHeader.tsx","../../src/presentation/document/PresentationDocumentProvider.tsx","../../src/presentation/fieldActions/openInStructure.ts","../../src/presentation/getIntentState.ts","../../src/presentation/PresentationSpinner.tsx","../../src/presentation/router.ts","../../src/presentation/plugin.tsx","../../src/presentation/reducers/presentationReducer.ts","../../src/presentation/usePresentationNavigate.ts","../../src/presentation/usePresentationParams.ts"],"sourcesContent":["import {type Serializable} from '@sanity/presentation-comlink'\nimport {useContext, useEffect} from 'react'\nimport {PresentationSharedStateContext} from 'sanity/_singletons'\n\n/** @public */\nexport const useSharedState = (key: string, value: Serializable): undefined => {\n const context = useContext(PresentationSharedStateContext)\n\n if (!context) {\n throw new Error('Preview Snapshots context is missing')\n }\n\n const {setValue} = context\n\n useEffect(() => {\n setValue(key, value)\n }, [key, value, setValue])\n\n return undefined\n}\n","import {ComposeIcon} from '@sanity/icons'\n\nexport const DEFAULT_TOOL_ICON = ComposeIcon\nexport const DEFAULT_TOOL_NAME = 'presentation'\nexport const DEFAULT_TOOL_TITLE = 'Presentation'\n\nexport const EDIT_INTENT_MODE = 'presentation'\n\n// How long we wait until an iframe is loaded until we consider it to be slow and possibly failed\nexport const MAX_TIME_TO_OVERLAYS_CONNECTION = 3_000 // ms\n\n// The API version to use when using `@sanity/client`\nexport const API_VERSION = '2023-10-16'\n\n// Heartbeats shouldn't fire on intervals that are so short it causes performance issues\nexport const MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = 1000 // ms\n\n// Batch size for fetching documents building up the cache\nexport const LIVE_QUERY_CACHE_BATCH_SIZE = 100\n\n// Total cache size for documents that are live queried\nexport const LIVE_QUERY_CACHE_SIZE = 2048\n\n// The interval at which we check if existing popups have been closed\nexport const POPUP_CHECK_INTERVAL = 1000 // ms\n\ndeclare global {\n const PRESENTATION_ENABLE_LIVE_DRAFT_EVENTS: unknown\n}\n\n// Feature flag that uses the new Live Draft Content API instead of the Listen API + Mendoza events\nexport const LIVE_DRAFT_EVENTS_ENABLED =\n typeof PRESENTATION_ENABLE_LIVE_DRAFT_EVENTS === 'string'\n ? PRESENTATION_ENABLE_LIVE_DRAFT_EVENTS === 'true'\n : false\n","import {\n combineLatest,\n from,\n isObservable,\n map,\n mergeAll,\n Observable,\n of,\n scan,\n switchMap,\n} from 'rxjs'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Props<K extends keyof any, T> = {\n [P in K]: T | Observable<T>\n}\n\nfunction keysOf<T extends object>(value: T) {\n return Object.keys(value) as (keyof T)[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction setKey(source: Record<string, unknown>, key: any, value: unknown) {\n return {\n ...source,\n [key]: value,\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function props<K extends keyof any, T>(options: {wait?: boolean} = {}) {\n return (source: Observable<Props<K, T>>): Observable<Record<string, unknown>> => {\n return new Observable<Props<K, T>>((observer) => source.subscribe(observer)).pipe(\n switchMap((object) => {\n const keyObservables = keysOf(object).map((key) => {\n const value = object[key]\n return isObservable(value) ? from(value).pipe(map((val) => [key, val])) : of([key, value])\n })\n\n return options.wait\n ? combineLatest(keyObservables).pipe(\n map((pairs) => pairs.reduce((acc, [key, value]) => setKey(acc, key, value), {})),\n )\n : from(keyObservables).pipe(\n mergeAll(),\n scan((acc, [key, value]) => setKey(acc, key, value), {}),\n )\n }),\n )\n }\n}\n","/* eslint-disable @typescript-eslint/no-shadow */\nimport {get} from 'lodash'\nimport {useEffect, useMemo, useState} from 'react'\nimport {isObservable, map, type Observable, of, switchMap} from 'rxjs'\nimport {\n type DocumentStore,\n getDraftId,\n isRecord,\n isReference,\n type Previewable,\n type SanityDocument,\n useDocumentStore,\n} from 'sanity'\n\nimport {\n type DocumentLocationResolver,\n type DocumentLocationResolverObject,\n type DocumentLocationResolvers,\n type DocumentLocationsState,\n type DocumentLocationsStatus,\n} from './types'\nimport {props} from './util/props'\n\nconst INITIAL_STATE: DocumentLocationsState = {locations: []}\n\nfunction getDocumentId(value: Previewable) {\n if (isReference(value)) {\n return value._ref\n }\n return '_id' in value ? value._id : undefined\n}\n\nfunction cleanPreviewable(id: string | undefined, previewable: Previewable) {\n const clean: Record<string, unknown> = id ? {...previewable, _id: id} : {...previewable}\n\n if (clean._type === 'reference') {\n delete clean._type\n delete clean._ref\n delete clean._weak\n delete clean._dataset\n delete clean._projectId\n delete clean._strengthenOnPublish\n }\n\n return clean\n}\n\nfunction listen(id: string, fields: string[], store: DocumentStore) {\n const projection = fields.join(', ')\n const query = {\n fetch: `*[_id==$id][0]{${projection}}`,\n // TODO: is it more performant to use `||` instead of `in`?\n listen: `*[_id in [$id,$draftId]]`,\n }\n const params = {id, draftId: getDraftId(id)}\n return store.listenQuery(query, params, {\n perspective: 'previewDrafts',\n }) as Observable<SanityDocument | null>\n}\n\nfunction observeDocument(\n value: Previewable | null,\n paths: string[][],\n store: DocumentStore,\n): Observable<Record<string, unknown> | null> {\n if (!value || typeof value !== 'object') {\n return of(value)\n }\n\n const id = getDocumentId(value)\n const currentValue = cleanPreviewable(id, value)\n\n const headlessPaths = paths.filter((path) => !(path[0] in currentValue))\n\n if (id && headlessPaths.length) {\n const fields = [...new Set(headlessPaths.map((path: string[]) => path[0]))]\n return listen(id, fields, store).pipe(\n switchMap((snapshot) => {\n if (snapshot) {\n return observeDocument(snapshot, paths, store)\n }\n return of(null)\n }),\n )\n }\n\n const leads: Record<string, string[][]> = {}\n paths.forEach((path) => {\n const [head, ...tail] = path\n if (!leads[head]) {\n leads[head] = []\n }\n leads[head].push(tail)\n })\n const next = Object.keys(leads).reduce((res: Record<string, unknown>, head) => {\n const tails = leads[head].filter((tail) => tail.length > 0)\n if (tails.length === 0) {\n res[head] = isRecord(value) ? (value as Record<string, unknown>)[head] : undefined\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n res[head] = observeDocument((value as any)[head], tails, store)\n }\n return res\n }, currentValue)\n\n return of(next).pipe(props({wait: true}))\n}\n\nfunction observeForLocations(\n documentId: string,\n resolver: DocumentLocationResolverObject<string>,\n documentStore: DocumentStore,\n) {\n const {select} = resolver\n const paths = Object.values(select).map((value) => String(value).split('.')) || []\n const doc = {_type: 'reference', _ref: documentId}\n return observeDocument(doc, paths, documentStore).pipe(\n map((doc) => {\n return Object.keys(select).reduce<Record<string, unknown>>((acc, key) => {\n acc[key] = get(doc, select[key])\n return acc\n }, {})\n }),\n map(resolver.resolve),\n )\n}\n\nexport function useDocumentLocations(props: {\n id: string\n resolvers?: DocumentLocationResolver | DocumentLocationResolvers\n type: string\n}): {\n state: DocumentLocationsState\n status: DocumentLocationsStatus\n} {\n const {id, resolvers, type} = props\n const documentStore = useDocumentStore()\n const [locationsState, setLocationsState] = useState<DocumentLocationsState>(INITIAL_STATE)\n\n const resolver = resolvers && (typeof resolvers === 'function' ? resolvers : resolvers[type])\n\n const [locationsStatus, setLocationsStatus] = useState<DocumentLocationsStatus>(\n resolver ? 'resolving' : 'empty',\n )\n\n const result = useMemo(() => {\n if (!resolver) return undefined\n\n // Original/advanced resolver which requires explicit use of Observables\n if (typeof resolver === 'function') {\n const params = {id, type}\n const context = {documentStore}\n const _result = resolver(params, context)\n return isObservable(_result) ? _result : of(_result)\n }\n\n // Simplified resolver pattern which abstracts away Observable logic\n if ('select' in resolver && 'resolve' in resolver) {\n return observeForLocations(id, resolver, documentStore)\n }\n\n // Resolver is explicitly provided state\n return of(resolver)\n }, [documentStore, id, resolver, type])\n\n useEffect(() => {\n const sub = result?.subscribe((state) => {\n setLocationsState(state || INITIAL_STATE)\n setLocationsStatus(state ? 'resolved' : 'empty')\n })\n\n return () => sub?.unsubscribe()\n }, [result])\n\n return {\n state: locationsState,\n status: locationsStatus,\n }\n}\n","import {defineLocaleResourceBundle} from 'sanity'\n\n/**\n * The locale namespace for the presentation tool\n *\n * @public\n */\nexport const presentationLocaleNamespace = 'presentation' as const\n\n/**\n * The default locale bundle for the presentation tool, which is US English.\n *\n * @internal\n */\nexport const presentationUsEnglishLocaleBundle = defineLocaleResourceBundle({\n locale: 'en-US',\n namespace: presentationLocaleNamespace,\n resources: () => import('./resources'),\n})\n","import {useContext} from 'react'\nimport {PresentationContext} from 'sanity/_singletons'\n\nimport {type PresentationContextValue} from './types'\n\nexport function usePresentationTool(throwOnMissingContext?: true): PresentationContextValue\nexport function usePresentationTool(throwOnMissingContext: false): PresentationContextValue | null\nexport function usePresentationTool(throwOnMissingContext = true): PresentationContextValue | null {\n const presentation = useContext(PresentationContext)\n\n if (throwOnMissingContext && !presentation) {\n throw new Error('Presentation context is missing')\n }\n\n return presentation\n}\n","import {usePresentationTool} from '../usePresentationTool'\n\nexport function useCurrentPresentationToolName(): string | undefined {\n return usePresentationTool(false)?.name ?? undefined\n}\n","import {\n ChevronRightIcon,\n DesktopIcon,\n ErrorOutlineIcon,\n InfoOutlineIcon,\n WarningOutlineIcon,\n} from '@sanity/icons'\nimport {Box, Card, Flex, Spinner, Stack, Text} from '@sanity/ui'\nimport {type ComponentType, type ReactNode, useCallback, useContext, useState} from 'react'\nimport {type ObjectSchemaType, useTranslation} from 'sanity'\nimport {PresentationContext} from 'sanity/_singletons'\nimport {useIntentLink} from 'sanity/router'\n\nimport {DEFAULT_TOOL_NAME, DEFAULT_TOOL_TITLE} from '../constants'\nimport {presentationLocaleNamespace} from '../i18n'\nimport {\n type DocumentLocation,\n type DocumentLocationsState,\n type PresentationPluginOptions,\n} from '../types'\nimport {useCurrentPresentationToolName} from './useCurrentPresentationToolName'\n\nconst TONE_ICONS: Record<'positive' | 'caution' | 'critical', ComponentType> = {\n positive: InfoOutlineIcon,\n caution: WarningOutlineIcon,\n critical: ErrorOutlineIcon,\n}\n\nexport function LocationsBanner(props: {\n documentId: string\n isResolving: boolean\n options: PresentationPluginOptions\n schemaType: ObjectSchemaType\n showPresentationTitle: boolean\n state: DocumentLocationsState\n}): ReactNode {\n const {documentId, isResolving, options, schemaType, showPresentationTitle} = props\n const {locations, message, tone} = props.state\n const len = locations?.length || 0\n\n const {t} = useTranslation(presentationLocaleNamespace)\n const presentation = useContext(PresentationContext)\n const presentationName = presentation?.name\n const [expanded, setExpanded] = useState(false)\n const toggle = useCallback(() => {\n if (!len) return\n setExpanded((v) => !v)\n }, [len])\n\n const title = isResolving\n ? t('locations-banner.resolving.text')\n : message || t('locations-banner.locations-count', {count: len})\n\n const ToneIcon = tone ? TONE_ICONS[tone] : undefined\n\n return (\n <Card padding={1} radius={2} border tone={tone}>\n <div style={{margin: -1}}>\n {!locations && (\n <Flex align=\"flex-start\" gap={3} padding={3}>\n {tone && ToneIcon && (\n <Box flex=\"none\">\n <Text size={1}>\n <ToneIcon />\n </Text>\n </Box>\n )}\n <Box flex={1}>\n <Text size={1} weight=\"medium\">\n {showPresentationTitle && <>{options.title || DEFAULT_TOOL_TITLE} &middot; </>}\n {title}\n </Text>\n </Box>\n </Flex>\n )}\n {locations && (\n <>\n <Card\n as={len ? 'button' : undefined}\n onClick={toggle}\n padding={3}\n radius={1}\n tone=\"inherit\"\n >\n <Flex gap={3}>\n <Box flex=\"none\">\n {isResolving ? (\n <Spinner size={1} />\n ) : (\n <Text size={1}>\n {len === 0 ? (\n <InfoOutlineIcon />\n ) : (\n <ChevronRightIcon\n style={{\n transform: `rotate(${expanded ? '90deg' : 0})`,\n transition: 'transform 100ms ease-in-out',\n }}\n />\n )}\n </Text>\n )}\n </Box>\n <Box flex={1}>\n <Text size={1} weight=\"medium\">\n {showPresentationTitle && <>{options.title || DEFAULT_TOOL_TITLE} &middot; </>}\n {title}\n </Text>\n </Box>\n </Flex>\n </Card>\n <Stack hidden={!expanded} marginTop={1} space={1}>\n {locations.map((l, index) => (\n <LocationItem\n active={\n (options.name || DEFAULT_TOOL_NAME) === presentationName &&\n l.href === presentation?.params.preview\n }\n documentId={documentId}\n documentType={schemaType.name}\n key={index}\n node={l}\n toolName={options.name || DEFAULT_TOOL_NAME}\n />\n ))}\n </Stack>\n </>\n )}\n </div>\n </Card>\n )\n}\n\nfunction LocationItem(props: {\n active: boolean\n documentId: string\n documentType: string\n node: DocumentLocation\n toolName: string\n}) {\n const {documentId, documentType, node, active, toolName} = props\n const presentation = useContext(PresentationContext)\n const currentPresentationToolName = useCurrentPresentationToolName()\n const isCurrentTool = toolName === currentPresentationToolName\n const navigate = presentation?.navigate\n\n const presentationLinkProps = useIntentLink({\n intent: 'edit',\n params: {\n id: documentId,\n type: documentType,\n mode: 'presentation',\n presentation: toolName,\n ...presentation?.structureParams,\n preview: node.href,\n },\n })\n\n const handleCurrentToolClick = useCallback(() => {\n navigate?.({}, {preview: node.href})\n }, [node.href, navigate])\n\n return (\n <Card\n {...(isCurrentTool ? {} : presentationLinkProps)}\n as=\"a\"\n key={node.href}\n onClick={isCurrentTool ? handleCurrentToolClick : presentationLinkProps.onClick}\n padding={3}\n radius={1}\n pressed={active}\n tone=\"inherit\"\n >\n <Flex gap={3}>\n <Box flex=\"none\">\n <Text size={1}>\n <DesktopIcon />\n </Text>\n </Box>\n <Stack flex={1} space={2}>\n <Text size={1} weight=\"medium\">\n {node.title}\n </Text>\n <Text muted size={1} textOverflow=\"ellipsis\">\n {node.href}\n </Text>\n </Stack>\n </Flex>\n </Card>\n )\n}\n","import {rem, Stack} from '@sanity/ui'\nimport {type ReactNode, useContext} from 'react'\nimport {type ObjectSchemaType, type PublishedId} from 'sanity'\nimport {PresentationDocumentContext} from 'sanity/_singletons'\nimport {styled} from 'styled-components'\n\nimport {type PresentationPluginOptions} from '../types'\nimport {useDocumentLocations} from '../useDocumentLocations'\nimport {LocationsBanner} from './LocationsBanner'\n\nconst LocationStack = styled(Stack)`\n min-height: ${rem(42)};\n\n & + &:empty {\n display: none;\n }\n`\n\nexport function PresentationDocumentHeader(props: {\n documentId: PublishedId\n options: PresentationPluginOptions\n schemaType: ObjectSchemaType\n}): ReactNode {\n const {documentId, options, schemaType} = props\n\n const context = useContext(PresentationDocumentContext)\n const {state, status} = useDocumentLocations({\n id: documentId,\n resolvers: options.resolve?.locations || options.locate,\n type: schemaType.name,\n })\n\n if ((context && context.options[0] !== options) || status === 'empty') {\n return null\n }\n\n const contextOptions = context?.options || []\n\n return (\n <LocationStack marginBottom={5} space={5}>\n <Stack space={2}>\n {contextOptions.map(\n (\n // eslint-disable-next-line @typescript-eslint/no-shadow\n options,\n idx,\n ) => (\n <LocationsBanner\n documentId={documentId}\n isResolving={status === 'resolving'}\n key={idx}\n options={options}\n schemaType={schemaType}\n showPresentationTitle={contextOptions.length > 1}\n state={state}\n />\n ),\n )}\n </Stack>\n </LocationStack>\n )\n}\n","import {type ReactNode, useCallback, useContext, useLayoutEffect, useMemo, useState} from 'react'\nimport {PresentationDocumentContext} from 'sanity/_singletons'\nimport {useEffectEvent} from 'use-effect-event'\n\nimport {type PresentationPluginOptions} from '../types'\nimport {type PresentationDocumentContextValue} from './types'\n\n/** @internal */\nexport function PresentationDocumentProvider(props: {\n children?: ReactNode\n options: PresentationPluginOptions\n}): React.JSX.Element {\n const {children, options} = props\n const parent = useContext(PresentationDocumentContext)\n const parentRegister = parent?.register\n\n const [optionsArray, setOptionsArray] = useState<PresentationPluginOptions[]>(() => [])\n\n const register = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (options: PresentationPluginOptions) => {\n if (parentRegister) {\n return parentRegister(options)\n }\n\n setOptionsArray((prev) => [options].concat(prev))\n\n return () => {\n setOptionsArray((prev) => prev.filter((o) => o !== options))\n }\n },\n [parentRegister],\n )\n\n const context: PresentationDocumentContextValue = useMemo(\n () => ({\n options: parent?.options || optionsArray,\n register,\n }),\n [optionsArray, parent, register],\n )\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const registerEffectEvent = useEffectEvent((options: PresentationPluginOptions) =>\n register(options),\n )\n useLayoutEffect(() => registerEffectEvent(options), [registerEffectEvent, options])\n\n return (\n <PresentationDocumentContext.Provider value={context}>\n {children}\n </PresentationDocumentContext.Provider>\n )\n}\n","import {MasterDetailIcon} from '@sanity/icons'\nimport {useContext, useMemo} from 'react'\nimport {\n defineDocumentFieldAction,\n type DocumentFieldActionGroup,\n type DocumentFieldActionItem,\n type DocumentFieldActionProps,\n isRecord,\n pathToString,\n type Tool,\n useWorkspace,\n} from 'sanity'\nimport {PresentationContext} from 'sanity/_singletons'\nimport {useRouter} from 'sanity/router'\n\nimport {DEFAULT_TOOL_NAME} from '../constants'\n\nfunction useOpenInStructureAction(\n props: DocumentFieldActionProps,\n): DocumentFieldActionItem | DocumentFieldActionGroup {\n const {documentId, documentType, path} = props\n const workspace = useWorkspace()\n const {navigateIntent} = useRouter()\n const presentation = useContext(PresentationContext)\n\n const defaultStructureTool = useMemo(\n () =>\n findStructureTool(\n workspace.tools,\n documentId,\n documentType,\n presentation?.name || DEFAULT_TOOL_NAME,\n ),\n [documentId, documentType, workspace.tools, presentation],\n )\n\n return {\n type: 'action',\n hidden: !presentation || path.length > 0 || !defaultStructureTool,\n icon: defaultStructureTool?.icon || MasterDetailIcon,\n title: `Open in ${defaultStructureTool?.title || 'Structure'}`,\n onAction() {\n navigateIntent('edit', {\n id: documentId,\n type: documentType,\n mode: 'structure',\n path: pathToString(path),\n })\n },\n renderAsButton: true,\n }\n}\n\nexport const openInStructure = defineDocumentFieldAction({\n name: 'presentation/openInStructure',\n useAction: useOpenInStructureAction,\n})\n\nfunction findStructureTool(\n tools: Tool[],\n documentId: string,\n documentType: string,\n presentationToolName?: string,\n): Tool | undefined {\n const results = tools\n .filter((t) => t.name !== presentationToolName)\n .map((t) => {\n const match = t.canHandleIntent?.(\n 'edit',\n {\n id: documentId,\n type: documentType,\n mode: 'structure',\n },\n {},\n )\n\n return {tool: t, match}\n })\n\n const modeMatches = results.filter((t) => isRecord(t.match) && t.match.mode)\n\n if (modeMatches.length > 0) {\n return modeMatches[0].tool\n }\n\n const matches = results.filter((t) => t.match)\n\n return matches[0]?.tool\n}\n","import {uuid} from '@sanity/uuid'\nimport {getPublishedId} from 'sanity'\nimport {encodeJsonParams, type RouterState, type SearchParam} from 'sanity/router'\n\nimport {type PresentationSearchParams, type PresentationStateParams} from './types'\n\nconst preservedSearchParamKeys: Array<keyof PresentationSearchParams> = [\n 'preview',\n 'perspective',\n 'viewport',\n]\n\n/**\n * @internal\n */\nexport function getIntentState(\n intent: string,\n params: Record<string, string>,\n routerState: RouterState | undefined,\n payload: unknown,\n):\n | (PresentationStateParams & {_searchParams: SearchParam[]})\n | {intent: string; params: Record<string, string>; payload: unknown} {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {id, mode, path, presentation, type, ...searchParams} = params\n\n const preservedSearchParams = (routerState?._searchParams || [])\n // @todo Casting https://github.com/microsoft/TypeScript/issues/14520\n .filter(([key]) => preservedSearchParamKeys.includes(key as keyof PresentationSearchParams))\n .reduce((acc, [key, value]) => ({...acc, [key]: value}), {} as Record<string, string>)\n\n const _searchParams = {\n ...preservedSearchParams,\n ...searchParams,\n }\n\n if (intent === 'edit' && id) {\n _searchParams.preview =\n _searchParams.preview || new URLSearchParams(window.location.search).get('preview') || '/'\n return {\n type: type || '*',\n id: getPublishedId(id),\n path,\n _searchParams: Object.entries(_searchParams),\n }\n }\n\n if (intent === 'create') {\n _searchParams.preview =\n _searchParams.preview || new URLSearchParams(window.location.search).get('preview') || '/'\n\n if (payload && typeof payload === 'object') {\n _searchParams.templateParams = encodeJsonParams(payload as Record<string, unknown>)\n }\n\n return {\n type: type || '*',\n id: id || uuid(),\n _searchParams: Object.entries(_searchParams),\n }\n }\n return {intent, params, payload}\n}\n","import {Flex, Spinner} from '@sanity/ui'\n\nexport function PresentationSpinner(): React.JSX.Element {\n return (\n <Flex align=\"center\" direction=\"column\" height=\"fill\" justify=\"center\" style={{width: '100%'}}>\n <Spinner />\n </Flex>\n )\n}\n","import {route} from 'sanity/router'\n\n// eslint-disable-next-line camelcase\nexport const router = route.create('/', {__unsafe_disableScopedSearchParams: true}, [\n route.intents('/intent'),\n route.create(':type', [route.create(':id', [route.create(':path')])]),\n])\n","import {type SanityDocument} from '@sanity/client'\nimport {lazy, Suspense} from 'react'\nimport {definePlugin, getPublishedId, type InputProps, isDocumentSchemaType} from 'sanity'\n\nimport {DEFAULT_TOOL_ICON, DEFAULT_TOOL_NAME, EDIT_INTENT_MODE} from './constants'\nimport {PresentationDocumentHeader} from './document/PresentationDocumentHeader'\nimport {PresentationDocumentProvider} from './document/PresentationDocumentProvider'\nimport {openInStructure} from './fieldActions/openInStructure'\nimport {getIntentState} from './getIntentState'\nimport {presentationUsEnglishLocaleBundle} from './i18n'\nimport {PresentationSpinner} from './PresentationSpinner'\nimport {router} from './router'\nimport {\n type DocumentLocationResolverObject,\n type DocumentLocationsState,\n type DocumentResolver,\n type PresentationPluginOptions,\n} from './types'\n\nconst PresentationTool = lazy(() => import('./PresentationToolGrantsCheck'))\nconst BroadcastDisplayedDocument = lazy(() => import('./loader/BroadcastDisplayedDocument'))\n\n/**\n * Define locations for a given document type.\n * This function doesn't do anything itself, it is used to provide type information.\n * @param resolver - resolver that return locations for a document.\n * @public\n */\nexport function defineLocations<K extends string>(\n resolver: DocumentLocationResolverObject<K> | DocumentLocationsState,\n): typeof resolver {\n return resolver\n}\n\n/**\n * Define documents for a given location.\n * This function doesn't do anything itself, it is used to provide type information.\n * @param resolvers - resolvers that return documents.\n * @public\n */\nexport function defineDocuments(resolvers: DocumentResolver[]): typeof resolvers {\n return resolvers\n}\n\n/** @public */\nexport const presentationTool = definePlugin<PresentationPluginOptions>((options) => {\n const toolName = options.name || DEFAULT_TOOL_NAME\n\n if ('locate' in options) {\n // eslint-disable-next-line no-console\n console.warn('Presentation’s `locate` option is deprecated. Use `resolve.locations` instead.')\n }\n\n const hasLocationsResolver = !!(options.resolve?.locations || options.locate)\n\n function PresentationDocumentInput(props: InputProps) {\n const value = props.value as SanityDocument\n const documentId = value?._id ? getPublishedId(value?._id) : undefined\n\n if (isDocumentSchemaType(props.schemaType)) {\n return (\n <PresentationDocumentProvider options={options}>\n {hasLocationsResolver && documentId && (\n <PresentationDocumentHeader\n documentId={documentId}\n options={options}\n schemaType={props.schemaType}\n />\n )}\n <Suspense fallback={<PresentationSpinner />}>{props.renderDefault(props)}</Suspense>\n <Suspense key=\"broadcast-displayed-document\">\n <BroadcastDisplayedDocument key={documentId} value={value} />\n </Suspense>\n </PresentationDocumentProvider>\n )\n }\n\n return props.renderDefault(props)\n }\n\n function canHandleCreateIntent(params: Record<string, unknown>) {\n // We can't handle create intents without a `type` parameter\n if (!('type' in params)) {\n return false\n }\n\n if ('presentation' in params && params.presentation !== toolName) {\n return false\n }\n\n return 'template' in params ? {template: true} : true\n }\n\n function canHandleEditIntent(params: Record<string, unknown>) {\n // We can't handle edit intents without `type` or `id` parameters\n if (!('type' in params) || !('id' in params)) {\n return false\n }\n\n if ('presentation' in params && params.presentation !== toolName) {\n return false\n }\n\n return 'mode' in params ? {mode: params.mode === EDIT_INTENT_MODE} : true\n }\n\n return {\n i18n: {\n bundles: [presentationUsEnglishLocaleBundle],\n },\n document: {\n unstable_fieldActions: (prev) => {\n return [\n ...prev.filter((a) => a.name !== openInStructure.name), // prevent duplication\n openInStructure,\n ]\n },\n },\n\n form: {\n components: {\n input: PresentationDocumentInput,\n },\n },\n\n tools: [\n {\n icon: options.icon || DEFAULT_TOOL_ICON,\n name: toolName,\n title: options.title,\n component: PresentationTool,\n options,\n canHandleIntent(intent, params) {\n if (intent === 'create') return canHandleCreateIntent(params)\n if (intent === 'edit') return canHandleEditIntent(params)\n return false\n },\n getIntentState,\n router,\n __internalApplicationType: 'sanity/presentation',\n },\n ],\n }\n})\n","import {type Dispatch, type Reducer} from 'react'\nimport {boolean, fallback, object, parse, picklist} from 'valibot'\n\n/** @public */\nexport interface PresentationState {\n mainDocument: boolean\n iframe: {\n status: 'loading' | 'loaded' | 'refreshing' | 'reloading'\n }\n visualEditing: {\n overlaysEnabled: boolean\n }\n}\n\n/** @public */\nexport const ACTION_IFRAME_LOADED = 'ACTION_IFRAME_LOADED'\n/** @public */\nexport const ACTION_IFRAME_REFRESH = 'ACTION_IFRAME_REFRESH'\n/** @public */\nexport const ACTION_IFRAME_RELOAD = 'ACTION_IFRAME_RELOAD'\n/** @public */\nexport const ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE = 'ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE'\n\n/** @public */\nexport interface IframeLoadedAction {\n type: typeof ACTION_IFRAME_LOADED\n}\n/** @public */\nexport interface IframeRefreshAction {\n type: typeof ACTION_IFRAME_REFRESH\n}\n/** @public */\nexport interface IframeReloadAction {\n type: typeof ACTION_IFRAME_RELOAD\n}\n/** @public */\nexport interface VisualEditingOverlaysToggleAction {\n type: typeof ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE\n enabled: boolean\n}\n\n/** @public */\nexport type PresentationAction =\n | IframeLoadedAction\n | IframeRefreshAction\n | IframeReloadAction\n | VisualEditingOverlaysToggleAction\n\nexport const presentationReducer: Reducer<\n Readonly<PresentationState>,\n Readonly<PresentationAction>\n> = (state, action) => {\n switch (action.type) {\n case ACTION_IFRAME_LOADED:\n return state.iframe.status === 'loaded'\n ? state\n : {\n ...state,\n iframe: {\n ...state.iframe,\n status: 'loaded',\n },\n }\n case ACTION_IFRAME_REFRESH:\n return state.iframe.status === 'refreshing'\n ? state\n : {\n ...state,\n iframe: {\n ...state.iframe,\n status: 'refreshing',\n },\n }\n case ACTION_IFRAME_RELOAD:\n return state.iframe.status === 'reloading'\n ? state\n : {\n ...state,\n iframe: {\n ...state.iframe,\n status: 'reloading',\n },\n }\n case ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE:\n return toggleVisualEditingOverlays(state, action)\n default:\n return state\n }\n}\n\nconst toggleVisualEditingOverlays: Reducer<\n Readonly<PresentationState>,\n Readonly<VisualEditingOverlaysToggleAction>\n> = (state, action) => {\n if (state.visualEditing.overlaysEnabled === action.enabled) return state\n return {\n ...state,\n visualEditing: {\n ...state.visualEditing,\n overlaysEnabled: action.enabled,\n },\n }\n}\n\nconst mainDocumentSchema = fallback(boolean(), false)\n\nconst iframeStatusSchema = picklist(['loading', 'loaded', 'refreshing', 'reloading'])\n\nconst initStateSchema = object({\n mainDocument: mainDocumentSchema,\n iframe: object({\n status: iframeStatusSchema,\n }),\n visualEditing: object({overlaysEnabled: boolean()}),\n})\n\nconst INITIAL_PRESENTATION_STATE = {\n mainDocument: false,\n iframe: {\n status: 'loading',\n },\n visualEditing: {\n overlaysEnabled: false,\n },\n} as const satisfies PresentationState\n\nexport function presentationReducerInit(\n state: Readonly<Partial<PresentationState>>,\n): Readonly<PresentationState> {\n return parse(initStateSchema, {...INITIAL_PRESENTATION_STATE, ...state})\n}\n\n/** @public */\nexport type DispatchPresentationAction = Dispatch<Readonly<PresentationAction>>\n","import {useContext} from 'react'\nimport {PresentationNavigateContext} from 'sanity/_singletons'\n\nimport {type PresentationNavigateContextValue} from './types'\n\n/** @public */\nexport function usePresentationNavigate(): PresentationNavigateContextValue {\n const navigate = useContext(PresentationNavigateContext)\n\n if (!navigate) {\n throw new Error('Presentation navigate context is missing')\n }\n\n return navigate\n}\n\nexport type {PresentationNavigateContextValue}\n","import {useContext} from 'react'\nimport {PresentationParamsContext} from 'sanity/_singletons'\n\nimport {type PresentationParamsContextValue} from './types'\n\n/** @public */\nexport function usePresentationParams(throwOnMissingContext?: true): PresentationParamsContextValue\n/** @public */\nexport function usePresentationParams(\n throwOnMissingContext: false,\n): PresentationParamsContextValue | null\n/** @public */\nexport function usePresentationParams(\n throwOnMissingContext = true,\n): PresentationParamsContextValue | null {\n const params = useContext(PresentationParamsContext)\n\n if (throwOnMissingContext && !params) {\n throw new Error('Presentation params context is missing')\n }\n\n return params\n}\n"],"names":["useSharedState","key","value","$","_c","context","useContext","PresentationSharedStateContext","Error","setValue","t0","t1","useEffect","DEFAULT_TOOL_ICON","ComposeIcon","DEFAULT_TOOL_NAME","DEFAULT_TOOL_TITLE","EDIT_INTENT_MODE","MAX_TIME_TO_OVERLAYS_CONNECTION","API_VERSION","MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL","LIVE_QUERY_CACHE_BATCH_SIZE","LIVE_QUERY_CACHE_SIZE","POPUP_CHECK_INTERVAL","keysOf","Object","keys","setKey","source","props","options","Observable","observer","subscribe","pipe","switchMap","object","keyObservables","map","isObservable","from","val","of","wait","combineLatest","pairs","reduce","acc","mergeAll","scan","INITIAL_STATE","locations","getDocumentId","isReference","_ref","_id","undefined","cleanPreviewable","id","previewable","clean","_type","_weak","_dataset","_projectId","_strengthenOnPublish","listen","fields","store","query","fetch","join","params","draftId","getDraftId","listenQuery","perspective","observeDocument","paths","currentValue","headlessPaths","filter","path","length","Set","snapshot","leads","forEach","head","tail","push","next","res","tails","isRecord","observeForLocations","documentId","resolver","documentStore","select","values","String","split","doc","get","resolve","useDocumentLocations","resolvers","type","useDocumentStore","locationsState","setLocationsState","useState","locationsStatus","setLocationsStatus","bb0","_result","result","t2","sub","state","unsubscribe","t3","status","presentationLocaleNamespace","presentationUsEnglishLocaleBundle","defineLocaleResourceBundle","locale","namespace","resources","usePresentationTool","throwOnMissingContext","presentation","PresentationContext","useCurrentPresentationToolName","name","TONE_ICONS","positive","InfoOutlineIcon","caution","WarningOutlineIcon","critical","ErrorOutlineIcon","LocationsBanner","isResolving","schemaType","showPresentationTitle","message","tone","len","t","useTranslation","presentationName","expanded","setExpanded","_temp","toggle","count","title","ToneIcon","Symbol","for","margin","jsxs","Flex","jsx","Box","Text","t4","Fragment","Card","Spinner","ChevronRightIcon","transform","transition","Stack","l","index","href","preview","t5","t6","v","LocationItem","documentType","node","active","toolName","currentPresentationToolName","isCurrentTool","navigate","structureParams","intent","mode","presentationLinkProps","useIntentLink","handleCurrentToolClick","onClick","DesktopIcon","t7","t8","t9","LocationStack","styled","rem","PresentationDocumentHeader","PresentationDocumentContext","locate","contextOptions","options_0","idx","PresentationDocumentProvider","children","parent","parentRegister","register","optionsArray","setOptionsArray","prev","concat","prev_0","o","options_1","registerEffectEvent","useEffectEvent","useLayoutEffect","useOpenInStructureAction","workspace","useWorkspace","navigateIntent","useRouter","tools","findStructureTool","defaultStructureTool","icon","MasterDetailIcon","hidden","onAction","pathToString","renderAsButton","openInStructure","defineDocumentFieldAction","useAction","presentationToolName","results","match","canHandleIntent","tool","modeMatches","preservedSearchParamKeys","getIntentState","routerState","payload","searchParams","_searchParams","includes","URLSearchParams","window","location","search","getPublishedId","entries","templateParams","encodeJsonParams","uuid","PresentationSpinner","width","router","route","create","__unsafe_disableScopedSearchParams","intents","PresentationTool","lazy","BroadcastDisplayedDocument","defineLocations","defineDocuments","presentationTool","definePlugin","console","warn","hasLocationsResolver","PresentationDocumentInput","isDocumentSchemaType","renderDefault","Suspense","canHandleCreateIntent","template","canHandleEditIntent","i18n","bundles","document","unstable_fieldActions","a","form","components","input","component","__internalApplicationType","ACTION_IFRAME_LOADED","ACTION_IFRAME_REFRESH","ACTION_IFRAME_RELOAD","ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE","presentationReducer","action","iframe","toggleVisualEditingOverlays","visualEditing","overlaysEnabled","enabled","mainDocumentSchema","fallback","boolean","iframeStatusSchema","picklist","initStateSchema","mainDocument","INITIAL_PRESENTATION_STATE","presentationReducerInit","parse","useP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,qBAAqBC,QAAAA,SAAS,CAAC,WAAW,UAAU,cAAc,WAAW,CAAC,GAE9EC,kBAAkBvR,eAAO;AAAA,EAC7BwR,cAAcN;AAAAA,EACdL,QAAQ7Q,QAAAA,OAAO;AAAA,IACbuF,QAAQ8L;AAAAA,EAAAA,CACT;AAAA,EACDN,eAAe/Q,QAAAA,OAAO;AAAA,IAACgR,iBAAiBI,QAAQ,QAAA;AAAA,EAAE,CAAA;AACpD,CAAC,GAEKK,6BAA6B;AAAA,EACjCD,cAAc;AAAA,EACdX,QAAQ;AAAA,IACNtL,QAAQ;AAAA,EACV;AAAA,EACAwL,eAAe;AAAA,IACbC,iBAAiB;AAAA,EAAA;AAErB;AAEO,SAASU,wBACdtM,OAC6B;AAC7B,SAAOuM,QAAAA,MAAMJ,iBAAiB;AAAA,IAAC,GAAGE;AAAAA,IAA4B,GAAGrM;AAAAA,EAAAA,CAAM;AACzE;AC5HO,SAAAwM,0BAAA;AACLlI,QAAAA,WAAiBxL,iBAAA2T,uCAAsC;AAAC,MAAA,CAEnDnI;AAAQtL,UAAAA,IAAAA,MACK,0CAA0C;AAGrDsL,SAAAA;AAAQ;ACDV,SAAAoI,sBAAAxT,IAAA;AACL,QAAAyH,wBAAAzH,OAA4B8C,cAA5B9C,IAEA8D,SAAelE,iBAAA6T,qCAAoC;AAAC,MAEhDhM,0BAA0B3D;AAAMhE,UAAAA,IAAAA,MAClB,wCAAwC;AAGnDgE,SAAAA;AAAM;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"presentation.js","sources":["../../src/presentation/overlays/useSharedState.ts","../../src/presentation/constants.ts","../../src/presentation/util/props.ts","../../src/presentation/useDocumentLocations.ts","../../src/presentation/i18n/index.ts","../../src/presentation/usePresentationTool.ts","../../src/presentation/document/useCurrentPresentationToolName.ts","../../src/presentation/document/LocationsBanner.tsx","../../src/presentation/document/PresentationDocumentHeader.tsx","../../src/presentation/document/PresentationDocumentProvider.tsx","../../src/presentation/fieldActions/openInStructure.ts","../../src/presentation/getIntentState.ts","../../src/presentation/PresentationSpinner.tsx","../../src/presentation/router.ts","../../src/presentation/plugin.tsx","../../src/presentation/reducers/presentationReducer.ts","../../src/presentation/usePresentationNavigate.ts","../../src/presentation/usePresentationParams.ts"],"sourcesContent":["import {type Serializable} from '@sanity/presentation-comlink'\nimport {useContext, useEffect} from 'react'\nimport {PresentationSharedStateContext} from 'sanity/_singletons'\n\n/** @public */\nexport const useSharedState = (key: string, value: Serializable): undefined => {\n const context = useContext(PresentationSharedStateContext)\n\n if (!context) {\n throw new Error('Preview Snapshots context is missing')\n }\n\n const {setValue} = context\n\n useEffect(() => {\n setValue(key, value)\n }, [key, value, setValue])\n\n return undefined\n}\n","import {ComposeIcon} from '@sanity/icons'\nimport {apiVersion} from '@sanity/preview-url-secret/constants'\n\nexport const DEFAULT_TOOL_ICON = ComposeIcon\nexport const DEFAULT_TOOL_NAME = 'presentation'\nexport const DEFAULT_TOOL_TITLE = 'Presentation'\n\nexport const EDIT_INTENT_MODE = 'presentation'\n\n// How long we wait until an iframe is loaded until we consider it to be slow and possibly failed\nexport const MAX_TIME_TO_OVERLAYS_CONNECTION = 3_000 // ms\n\n// The API version to use when using `@sanity/client`\nexport const API_VERSION = apiVersion\n\n// Heartbeats shouldn't fire on intervals that are so short it causes performance issues\nexport const MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = 1000 // ms\n\n// How often the list over loader queries should be garbage collected\nexport const LOADER_QUERY_GC_INTERVAL = 30_000 // ms\n\n// The interval at which we check if existing popups have been closed\nexport const POPUP_CHECK_INTERVAL = 1000 // ms\n","import {\n combineLatest,\n from,\n isObservable,\n map,\n mergeAll,\n Observable,\n of,\n scan,\n switchMap,\n} from 'rxjs'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Props<K extends keyof any, T> = {\n [P in K]: T | Observable<T>\n}\n\nfunction keysOf<T extends object>(value: T) {\n return Object.keys(value) as (keyof T)[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction setKey(source: Record<string, unknown>, key: any, value: unknown) {\n return {\n ...source,\n [key]: value,\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function props<K extends keyof any, T>(options: {wait?: boolean} = {}) {\n return (source: Observable<Props<K, T>>): Observable<Record<string, unknown>> => {\n return new Observable<Props<K, T>>((observer) => source.subscribe(observer)).pipe(\n switchMap((object) => {\n const keyObservables = keysOf(object).map((key) => {\n const value = object[key]\n return isObservable(value) ? from(value).pipe(map((val) => [key, val])) : of([key, value])\n })\n\n return options.wait\n ? combineLatest(keyObservables).pipe(\n map((pairs) => pairs.reduce((acc, [key, value]) => setKey(acc, key, value), {})),\n )\n : from(keyObservables).pipe(\n mergeAll(),\n scan((acc, [key, value]) => setKey(acc, key, value), {}),\n )\n }),\n )\n }\n}\n","/* eslint-disable @typescript-eslint/no-shadow */\nimport {get} from 'lodash'\nimport {useEffect, useMemo, useState} from 'react'\nimport {isObservable, map, type Observable, of, switchMap} from 'rxjs'\nimport {\n type DocumentStore,\n getDraftId,\n isRecord,\n isReference,\n type Previewable,\n type SanityDocument,\n useDocumentStore,\n} from 'sanity'\n\nimport {\n type DocumentLocationResolver,\n type DocumentLocationResolverObject,\n type DocumentLocationResolvers,\n type DocumentLocationsState,\n type DocumentLocationsStatus,\n} from './types'\nimport {props} from './util/props'\n\nconst INITIAL_STATE: DocumentLocationsState = {locations: []}\n\nfunction getDocumentId(value: Previewable) {\n if (isReference(value)) {\n return value._ref\n }\n return '_id' in value ? value._id : undefined\n}\n\nfunction cleanPreviewable(id: string | undefined, previewable: Previewable) {\n const clean: Record<string, unknown> = id ? {...previewable, _id: id} : {...previewable}\n\n if (clean._type === 'reference') {\n delete clean._type\n delete clean._ref\n delete clean._weak\n delete clean._dataset\n delete clean._projectId\n delete clean._strengthenOnPublish\n }\n\n return clean\n}\n\nfunction listen(id: string, fields: string[], store: DocumentStore) {\n const projection = fields.join(', ')\n const query = {\n fetch: `*[_id==$id][0]{${projection}}`,\n // TODO: is it more performant to use `||` instead of `in`?\n listen: `*[_id in [$id,$draftId]]`,\n }\n const params = {id, draftId: getDraftId(id)}\n return store.listenQuery(query, params, {\n perspective: 'previewDrafts',\n }) as Observable<SanityDocument | null>\n}\n\nfunction observeDocument(\n value: Previewable | null,\n paths: string[][],\n store: DocumentStore,\n): Observable<Record<string, unknown> | null> {\n if (!value || typeof value !== 'object') {\n return of(value)\n }\n\n const id = getDocumentId(value)\n const currentValue = cleanPreviewable(id, value)\n\n const headlessPaths = paths.filter((path) => !(path[0] in currentValue))\n\n if (id && headlessPaths.length) {\n const fields = [...new Set(headlessPaths.map((path: string[]) => path[0]))]\n return listen(id, fields, store).pipe(\n switchMap((snapshot) => {\n if (snapshot) {\n return observeDocument(snapshot, paths, store)\n }\n return of(null)\n }),\n )\n }\n\n const leads: Record<string, string[][]> = {}\n paths.forEach((path) => {\n const [head, ...tail] = path\n if (!leads[head]) {\n leads[head] = []\n }\n leads[head].push(tail)\n })\n const next = Object.keys(leads).reduce((res: Record<string, unknown>, head) => {\n const tails = leads[head].filter((tail) => tail.length > 0)\n if (tails.length === 0) {\n res[head] = isRecord(value) ? (value as Record<string, unknown>)[head] : undefined\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n res[head] = observeDocument((value as any)[head], tails, store)\n }\n return res\n }, currentValue)\n\n return of(next).pipe(props({wait: true}))\n}\n\nfunction observeForLocations(\n documentId: string,\n resolver: DocumentLocationResolverObject<string>,\n documentStore: DocumentStore,\n) {\n const {select} = resolver\n const paths = Object.values(select).map((value) => String(value).split('.')) || []\n const doc = {_type: 'reference', _ref: documentId}\n return observeDocument(doc, paths, documentStore).pipe(\n map((doc) => {\n return Object.keys(select).reduce<Record<string, unknown>>((acc, key) => {\n acc[key] = get(doc, select[key])\n return acc\n }, {})\n }),\n map(resolver.resolve),\n )\n}\n\nexport function useDocumentLocations(props: {\n id: string\n resolvers?: DocumentLocationResolver | DocumentLocationResolvers\n type: string\n}): {\n state: DocumentLocationsState\n status: DocumentLocationsStatus\n} {\n const {id, resolvers, type} = props\n const documentStore = useDocumentStore()\n const [locationsState, setLocationsState] = useState<DocumentLocationsState>(INITIAL_STATE)\n\n const resolver = resolvers && (typeof resolvers === 'function' ? resolvers : resolvers[type])\n\n const [locationsStatus, setLocationsStatus] = useState<DocumentLocationsStatus>(\n resolver ? 'resolving' : 'empty',\n )\n\n const result = useMemo(() => {\n if (!resolver) return undefined\n\n // Original/advanced resolver which requires explicit use of Observables\n if (typeof resolver === 'function') {\n const params = {id, type}\n const context = {documentStore}\n const _result = resolver(params, context)\n return isObservable(_result) ? _result : of(_result)\n }\n\n // Simplified resolver pattern which abstracts away Observable logic\n if ('select' in resolver && 'resolve' in resolver) {\n return observeForLocations(id, resolver, documentStore)\n }\n\n // Resolver is explicitly provided state\n return of(resolver)\n }, [documentStore, id, resolver, type])\n\n useEffect(() => {\n const sub = result?.subscribe((state) => {\n setLocationsState(state || INITIAL_STATE)\n setLocationsStatus(state ? 'resolved' : 'empty')\n })\n\n return () => sub?.unsubscribe()\n }, [result])\n\n return {\n state: locationsState,\n status: locationsStatus,\n }\n}\n","import {defineLocaleResourceBundle} from 'sanity'\n\n/**\n * The locale namespace for the presentation tool\n *\n * @public\n */\nexport const presentationLocaleNamespace = 'presentation' as const\n\n/**\n * The default locale bundle for the presentation tool, which is US English.\n *\n * @internal\n */\nexport const presentationUsEnglishLocaleBundle = defineLocaleResourceBundle({\n locale: 'en-US',\n namespace: presentationLocaleNamespace,\n resources: () => import('./resources'),\n})\n","import {useContext} from 'react'\nimport {PresentationContext} from 'sanity/_singletons'\n\nimport {type PresentationContextValue} from './types'\n\nexport function usePresentationTool(throwOnMissingContext?: true): PresentationContextValue\nexport function usePresentationTool(throwOnMissingContext: false): PresentationContextValue | null\nexport function usePresentationTool(throwOnMissingContext = true): PresentationContextValue | null {\n const presentation = useContext(PresentationContext)\n\n if (throwOnMissingContext && !presentation) {\n throw new Error('Presentation context is missing')\n }\n\n return presentation\n}\n","import {usePresentationTool} from '../usePresentationTool'\n\nexport function useCurrentPresentationToolName(): string | undefined {\n return usePresentationTool(false)?.name ?? undefined\n}\n","import {\n ChevronRightIcon,\n DesktopIcon,\n ErrorOutlineIcon,\n InfoOutlineIcon,\n WarningOutlineIcon,\n} from '@sanity/icons'\nimport {Box, Card, Flex, Spinner, Stack, Text} from '@sanity/ui'\nimport {type ComponentType, type ReactNode, useCallback, useContext, useState} from 'react'\nimport {type ObjectSchemaType, useTranslation} from 'sanity'\nimport {PresentationContext} from 'sanity/_singletons'\nimport {useIntentLink} from 'sanity/router'\n\nimport {DEFAULT_TOOL_NAME, DEFAULT_TOOL_TITLE} from '../constants'\nimport {presentationLocaleNamespace} from '../i18n'\nimport {\n type DocumentLocation,\n type DocumentLocationsState,\n type PresentationPluginOptions,\n} from '../types'\nimport {useCurrentPresentationToolName} from './useCurrentPresentationToolName'\n\nconst TONE_ICONS: Record<'positive' | 'caution' | 'critical', ComponentType> = {\n positive: InfoOutlineIcon,\n caution: WarningOutlineIcon,\n critical: ErrorOutlineIcon,\n}\n\nexport function LocationsBanner(props: {\n documentId: string\n isResolving: boolean\n options: PresentationPluginOptions\n schemaType: ObjectSchemaType\n showPresentationTitle: boolean\n state: DocumentLocationsState\n}): ReactNode {\n const {documentId, isResolving, options, schemaType, showPresentationTitle} = props\n const {locations, message, tone} = props.state\n const len = locations?.length || 0\n\n const {t} = useTranslation(presentationLocaleNamespace)\n const presentation = useContext(PresentationContext)\n const presentationName = presentation?.name\n const [expanded, setExpanded] = useState(false)\n const toggle = useCallback(() => {\n if (!len) return\n setExpanded((v) => !v)\n }, [len])\n\n const title = isResolving\n ? t('locations-banner.resolving.text')\n : message || t('locations-banner.locations-count', {count: len})\n\n const ToneIcon = tone ? TONE_ICONS[tone] : undefined\n\n return (\n <Card padding={1} radius={2} border tone={tone}>\n <div style={{margin: -1}}>\n {!locations && (\n <Flex align=\"flex-start\" gap={3} padding={3}>\n {tone && ToneIcon && (\n <Box flex=\"none\">\n <Text size={1}>\n <ToneIcon />\n </Text>\n </Box>\n )}\n <Box flex={1}>\n <Text size={1} weight=\"medium\">\n {showPresentationTitle && <>{options.title || DEFAULT_TOOL_TITLE} &middot; </>}\n {title}\n </Text>\n </Box>\n </Flex>\n )}\n {locations && (\n <>\n <Card\n as={len ? 'button' : undefined}\n onClick={toggle}\n padding={3}\n radius={1}\n tone=\"inherit\"\n >\n <Flex gap={3}>\n <Box flex=\"none\">\n {isResolving ? (\n <Spinner size={1} />\n ) : (\n <Text size={1}>\n {len === 0 ? (\n <InfoOutlineIcon />\n ) : (\n <ChevronRightIcon\n style={{\n transform: `rotate(${expanded ? '90deg' : 0})`,\n transition: 'transform 100ms ease-in-out',\n }}\n />\n )}\n </Text>\n )}\n </Box>\n <Box flex={1}>\n <Text size={1} weight=\"medium\">\n {showPresentationTitle && <>{options.title || DEFAULT_TOOL_TITLE} &middot; </>}\n {title}\n </Text>\n </Box>\n </Flex>\n </Card>\n <Stack hidden={!expanded} marginTop={1} space={1}>\n {locations.map((l, index) => (\n <LocationItem\n active={\n (options.name || DEFAULT_TOOL_NAME) === presentationName &&\n l.href === presentation?.params.preview\n }\n documentId={documentId}\n documentType={schemaType.name}\n key={index}\n node={l}\n toolName={options.name || DEFAULT_TOOL_NAME}\n />\n ))}\n </Stack>\n </>\n )}\n </div>\n </Card>\n )\n}\n\nfunction LocationItem(props: {\n active: boolean\n documentId: string\n documentType: string\n node: DocumentLocation\n toolName: string\n}) {\n const {documentId, documentType, node, active, toolName} = props\n const presentation = useContext(PresentationContext)\n const currentPresentationToolName = useCurrentPresentationToolName()\n const isCurrentTool = toolName === currentPresentationToolName\n const navigate = presentation?.navigate\n\n const presentationLinkProps = useIntentLink({\n intent: 'edit',\n params: {\n id: documentId,\n type: documentType,\n mode: 'presentation',\n presentation: toolName,\n ...presentation?.structureParams,\n preview: node.href,\n },\n })\n\n const handleCurrentToolClick = useCallback(() => {\n navigate?.({}, {preview: node.href})\n }, [node.href, navigate])\n\n return (\n <Card\n {...(isCurrentTool ? {} : presentationLinkProps)}\n as=\"a\"\n key={node.href}\n onClick={isCurrentTool ? handleCurrentToolClick : presentationLinkProps.onClick}\n padding={3}\n radius={1}\n pressed={active}\n tone=\"inherit\"\n >\n <Flex gap={3}>\n <Box flex=\"none\">\n <Text size={1}>\n <DesktopIcon />\n </Text>\n </Box>\n <Stack flex={1} space={2}>\n <Text size={1} weight=\"medium\">\n {node.title}\n </Text>\n <Text muted size={1} textOverflow=\"ellipsis\">\n {node.href}\n </Text>\n </Stack>\n </Flex>\n </Card>\n )\n}\n","import {rem, Stack} from '@sanity/ui'\nimport {type ReactNode, useContext} from 'react'\nimport {type ObjectSchemaType, type PublishedId} from 'sanity'\nimport {PresentationDocumentContext} from 'sanity/_singletons'\nimport {styled} from 'styled-components'\n\nimport {type PresentationPluginOptions} from '../types'\nimport {useDocumentLocations} from '../useDocumentLocations'\nimport {LocationsBanner} from './LocationsBanner'\n\nconst LocationStack = styled(Stack)`\n min-height: ${rem(42)};\n\n & + &:empty {\n display: none;\n }\n`\n\nexport function PresentationDocumentHeader(props: {\n documentId: PublishedId\n options: PresentationPluginOptions\n schemaType: ObjectSchemaType\n}): ReactNode {\n const {documentId, options, schemaType} = props\n\n const context = useContext(PresentationDocumentContext)\n const {state, status} = useDocumentLocations({\n id: documentId,\n resolvers: options.resolve?.locations || options.locate,\n type: schemaType.name,\n })\n\n if ((context && context.options[0] !== options) || status === 'empty') {\n return null\n }\n\n const contextOptions = context?.options || []\n\n return (\n <LocationStack marginBottom={5} space={5}>\n <Stack space={2}>\n {contextOptions.map(\n (\n // eslint-disable-next-line @typescript-eslint/no-shadow\n options,\n idx,\n ) => (\n <LocationsBanner\n documentId={documentId}\n isResolving={status === 'resolving'}\n key={idx}\n options={options}\n schemaType={schemaType}\n showPresentationTitle={contextOptions.length > 1}\n state={state}\n />\n ),\n )}\n </Stack>\n </LocationStack>\n )\n}\n","import {type ReactNode, useCallback, useContext, useLayoutEffect, useMemo, useState} from 'react'\nimport {PresentationDocumentContext} from 'sanity/_singletons'\nimport {useEffectEvent} from 'use-effect-event'\n\nimport {type PresentationPluginOptions} from '../types'\nimport {type PresentationDocumentContextValue} from './types'\n\n/** @internal */\nexport function PresentationDocumentProvider(props: {\n children?: ReactNode\n options: PresentationPluginOptions\n}): React.JSX.Element {\n const {children, options} = props\n const parent = useContext(PresentationDocumentContext)\n const parentRegister = parent?.register\n\n const [optionsArray, setOptionsArray] = useState<PresentationPluginOptions[]>(() => [])\n\n const register = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (options: PresentationPluginOptions) => {\n if (parentRegister) {\n return parentRegister(options)\n }\n\n setOptionsArray((prev) => [options].concat(prev))\n\n return () => {\n setOptionsArray((prev) => prev.filter((o) => o !== options))\n }\n },\n [parentRegister],\n )\n\n const context: PresentationDocumentContextValue = useMemo(\n () => ({\n options: parent?.options || optionsArray,\n register,\n }),\n [optionsArray, parent, register],\n )\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const registerEffectEvent = useEffectEvent((options: PresentationPluginOptions) =>\n register(options),\n )\n useLayoutEffect(() => registerEffectEvent(options), [registerEffectEvent, options])\n\n return (\n <PresentationDocumentContext.Provider value={context}>\n {children}\n </PresentationDocumentContext.Provider>\n )\n}\n","import {MasterDetailIcon} from '@sanity/icons'\nimport {useContext, useMemo} from 'react'\nimport {\n defineDocumentFieldAction,\n type DocumentFieldActionGroup,\n type DocumentFieldActionItem,\n type DocumentFieldActionProps,\n isRecord,\n pathToString,\n type Tool,\n useWorkspace,\n} from 'sanity'\nimport {PresentationContext} from 'sanity/_singletons'\nimport {useRouter} from 'sanity/router'\n\nimport {DEFAULT_TOOL_NAME} from '../constants'\n\nfunction useOpenInStructureAction(\n props: DocumentFieldActionProps,\n): DocumentFieldActionItem | DocumentFieldActionGroup {\n const {documentId, documentType, path} = props\n const workspace = useWorkspace()\n const {navigateIntent} = useRouter()\n const presentation = useContext(PresentationContext)\n\n const defaultStructureTool = useMemo(\n () =>\n findStructureTool(\n workspace.tools,\n documentId,\n documentType,\n presentation?.name || DEFAULT_TOOL_NAME,\n ),\n [documentId, documentType, workspace.tools, presentation],\n )\n\n return {\n type: 'action',\n hidden: !presentation || path.length > 0 || !defaultStructureTool,\n icon: defaultStructureTool?.icon || MasterDetailIcon,\n title: `Open in ${defaultStructureTool?.title || 'Structure'}`,\n onAction() {\n navigateIntent('edit', {\n id: documentId,\n type: documentType,\n mode: 'structure',\n path: pathToString(path),\n })\n },\n renderAsButton: true,\n }\n}\n\nexport const openInStructure = defineDocumentFieldAction({\n name: 'presentation/openInStructure',\n useAction: useOpenInStructureAction,\n})\n\nfunction findStructureTool(\n tools: Tool[],\n documentId: string,\n documentType: string,\n presentationToolName?: string,\n): Tool | undefined {\n const results = tools\n .filter((t) => t.name !== presentationToolName)\n .map((t) => {\n const match = t.canHandleIntent?.(\n 'edit',\n {\n id: documentId,\n type: documentType,\n mode: 'structure',\n },\n {},\n )\n\n return {tool: t, match}\n })\n\n const modeMatches = results.filter((t) => isRecord(t.match) && t.match.mode)\n\n if (modeMatches.length > 0) {\n return modeMatches[0].tool\n }\n\n const matches = results.filter((t) => t.match)\n\n return matches[0]?.tool\n}\n","import {uuid} from '@sanity/uuid'\nimport {getPublishedId} from 'sanity'\nimport {encodeJsonParams, type RouterState, type SearchParam} from 'sanity/router'\n\nimport {type PresentationSearchParams, type PresentationStateParams} from './types'\n\nconst preservedSearchParamKeys: Array<keyof PresentationSearchParams> = [\n 'preview',\n 'perspective',\n 'viewport',\n]\n\n/**\n * @internal\n */\nexport function getIntentState(\n intent: string,\n params: Record<string, string>,\n routerState: RouterState | undefined,\n payload: unknown,\n):\n | (PresentationStateParams & {_searchParams: SearchParam[]})\n | {intent: string; params: Record<string, string>; payload: unknown} {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {id, mode, path, presentation, type, ...searchParams} = params\n\n const preservedSearchParams = (routerState?._searchParams || [])\n // @todo Casting https://github.com/microsoft/TypeScript/issues/14520\n .filter(([key]) => preservedSearchParamKeys.includes(key as keyof PresentationSearchParams))\n .reduce((acc, [key, value]) => ({...acc, [key]: value}), {} as Record<string, string>)\n\n const _searchParams = {\n ...preservedSearchParams,\n ...searchParams,\n }\n\n if (intent === 'edit' && id) {\n _searchParams.preview =\n _searchParams.preview || new URLSearchParams(window.location.search).get('preview') || '/'\n return {\n type: type || '*',\n id: getPublishedId(id),\n path,\n _searchParams: Object.entries(_searchParams),\n }\n }\n\n if (intent === 'create') {\n _searchParams.preview =\n _searchParams.preview || new URLSearchParams(window.location.search).get('preview') || '/'\n\n if (payload && typeof payload === 'object') {\n _searchParams.templateParams = encodeJsonParams(payload as Record<string, unknown>)\n }\n\n return {\n type: type || '*',\n id: id || uuid(),\n _searchParams: Object.entries(_searchParams),\n }\n }\n return {intent, params, payload}\n}\n","import {Flex, Spinner} from '@sanity/ui'\n\nexport function PresentationSpinner(): React.JSX.Element {\n return (\n <Flex align=\"center\" direction=\"column\" height=\"fill\" justify=\"center\" style={{width: '100%'}}>\n <Spinner />\n </Flex>\n )\n}\n","import {route} from 'sanity/router'\n\n// eslint-disable-next-line camelcase\nexport const router = route.create('/', {__unsafe_disableScopedSearchParams: true}, [\n route.intents('/intent'),\n route.create(':type', [route.create(':id', [route.create(':path')])]),\n])\n","import {type SanityDocument} from '@sanity/client'\nimport {lazy, Suspense} from 'react'\nimport {definePlugin, getPublishedId, type InputProps, isDocumentSchemaType} from 'sanity'\n\nimport {DEFAULT_TOOL_ICON, DEFAULT_TOOL_NAME, EDIT_INTENT_MODE} from './constants'\nimport {PresentationDocumentHeader} from './document/PresentationDocumentHeader'\nimport {PresentationDocumentProvider} from './document/PresentationDocumentProvider'\nimport {openInStructure} from './fieldActions/openInStructure'\nimport {getIntentState} from './getIntentState'\nimport {presentationUsEnglishLocaleBundle} from './i18n'\nimport {PresentationSpinner} from './PresentationSpinner'\nimport {router} from './router'\nimport {\n type DocumentLocationResolverObject,\n type DocumentLocationsState,\n type DocumentResolver,\n type PresentationPluginOptions,\n} from './types'\n\nconst PresentationTool = lazy(() => import('./PresentationToolGrantsCheck'))\nconst BroadcastDisplayedDocument = lazy(() => import('./loader/BroadcastDisplayedDocument'))\n\n/**\n * Define locations for a given document type.\n * This function doesn't do anything itself, it is used to provide type information.\n * @param resolver - resolver that return locations for a document.\n * @public\n */\nexport function defineLocations<K extends string>(\n resolver: DocumentLocationResolverObject<K> | DocumentLocationsState,\n): typeof resolver {\n return resolver\n}\n\n/**\n * Define documents for a given location.\n * This function doesn't do anything itself, it is used to provide type information.\n * @param resolvers - resolvers that return documents.\n * @public\n */\nexport function defineDocuments(resolvers: DocumentResolver[]): typeof resolvers {\n return resolvers\n}\n\n/** @public */\nexport const presentationTool = definePlugin<PresentationPluginOptions>((options) => {\n const toolName = options.name || DEFAULT_TOOL_NAME\n\n if ('locate' in options) {\n // eslint-disable-next-line no-console\n console.warn('Presentation’s `locate` option is deprecated. Use `resolve.locations` instead.')\n }\n\n const hasLocationsResolver = !!(options.resolve?.locations || options.locate)\n\n function PresentationDocumentInput(props: InputProps) {\n const value = props.value as SanityDocument\n const documentId = value?._id ? getPublishedId(value?._id) : undefined\n\n if (isDocumentSchemaType(props.schemaType)) {\n return (\n <PresentationDocumentProvider options={options}>\n {hasLocationsResolver && documentId && (\n <PresentationDocumentHeader\n documentId={documentId}\n options={options}\n schemaType={props.schemaType}\n />\n )}\n <Suspense fallback={<PresentationSpinner />}>{props.renderDefault(props)}</Suspense>\n <Suspense key=\"broadcast-displayed-document\">\n <BroadcastDisplayedDocument key={documentId} value={value} />\n </Suspense>\n </PresentationDocumentProvider>\n )\n }\n\n return props.renderDefault(props)\n }\n\n function canHandleCreateIntent(params: Record<string, unknown>) {\n // We can't handle create intents without a `type` parameter\n if (!('type' in params)) {\n return false\n }\n\n if ('presentation' in params && params.presentation !== toolName) {\n return false\n }\n\n return 'template' in params ? {template: true} : true\n }\n\n function canHandleEditIntent(params: Record<string, unknown>) {\n // We can't handle edit intents without `type` or `id` parameters\n if (!('type' in params) || !('id' in params)) {\n return false\n }\n\n if ('presentation' in params && params.presentation !== toolName) {\n return false\n }\n\n return 'mode' in params ? {mode: params.mode === EDIT_INTENT_MODE} : true\n }\n\n return {\n i18n: {\n bundles: [presentationUsEnglishLocaleBundle],\n },\n document: {\n unstable_fieldActions: (prev) => {\n return [\n ...prev.filter((a) => a.name !== openInStructure.name), // prevent duplication\n openInStructure,\n ]\n },\n },\n\n form: {\n components: {\n input: PresentationDocumentInput,\n },\n },\n\n tools: [\n {\n icon: options.icon || DEFAULT_TOOL_ICON,\n name: toolName,\n title: options.title,\n component: PresentationTool,\n options,\n canHandleIntent(intent, params) {\n if (intent === 'create') return canHandleCreateIntent(params)\n if (intent === 'edit') return canHandleEditIntent(params)\n return false\n },\n getIntentState,\n router,\n __internalApplicationType: 'sanity/presentation',\n },\n ],\n }\n})\n","import {type Dispatch, type Reducer} from 'react'\nimport {boolean, fallback, object, parse, picklist} from 'valibot'\n\n/** @public */\nexport interface PresentationState {\n mainDocument: boolean\n iframe: {\n status: 'loading' | 'loaded' | 'refreshing' | 'reloading'\n }\n visualEditing: {\n overlaysEnabled: boolean\n }\n}\n\n/** @public */\nexport const ACTION_IFRAME_LOADED = 'ACTION_IFRAME_LOADED'\n/** @public */\nexport const ACTION_IFRAME_REFRESH = 'ACTION_IFRAME_REFRESH'\n/** @public */\nexport const ACTION_IFRAME_RELOAD = 'ACTION_IFRAME_RELOAD'\n/** @public */\nexport const ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE = 'ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE'\n\n/** @public */\nexport interface IframeLoadedAction {\n type: typeof ACTION_IFRAME_LOADED\n}\n/** @public */\nexport interface IframeRefreshAction {\n type: typeof ACTION_IFRAME_REFRESH\n}\n/** @public */\nexport interface IframeReloadAction {\n type: typeof ACTION_IFRAME_RELOAD\n}\n/** @public */\nexport interface VisualEditingOverlaysToggleAction {\n type: typeof ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE\n enabled: boolean\n}\n\n/** @public */\nexport type PresentationAction =\n | IframeLoadedAction\n | IframeRefreshAction\n | IframeReloadAction\n | VisualEditingOverlaysToggleAction\n\nexport const presentationReducer: Reducer<\n Readonly<PresentationState>,\n Readonly<PresentationAction>\n> = (state, action) => {\n switch (action.type) {\n case ACTION_IFRAME_LOADED:\n return state.iframe.status === 'loaded'\n ? state\n : {\n ...state,\n iframe: {\n ...state.iframe,\n status: 'loaded',\n },\n }\n case ACTION_IFRAME_REFRESH:\n return state.iframe.status === 'refreshing'\n ? state\n : {\n ...state,\n iframe: {\n ...state.iframe,\n status: 'refreshing',\n },\n }\n case ACTION_IFRAME_RELOAD:\n return state.iframe.status === 'reloading'\n ? state\n : {\n ...state,\n iframe: {\n ...state.iframe,\n status: 'reloading',\n },\n }\n case ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE:\n return toggleVisualEditingOverlays(state, action)\n default:\n return state\n }\n}\n\nconst toggleVisualEditingOverlays: Reducer<\n Readonly<PresentationState>,\n Readonly<VisualEditingOverlaysToggleAction>\n> = (state, action) => {\n if (state.visualEditing.overlaysEnabled === action.enabled) return state\n return {\n ...state,\n visualEditing: {\n ...state.visualEditing,\n overlaysEnabled: action.enabled,\n },\n }\n}\n\nconst mainDocumentSchema = fallback(boolean(), false)\n\nconst iframeStatusSchema = picklist(['loading', 'loaded', 'refreshing', 'reloading'])\n\nconst initStateSchema = object({\n mainDocument: mainDocumentSchema,\n iframe: object({\n status: iframeStatusSchema,\n }),\n visualEditing: object({overlaysEnabled: boolean()}),\n})\n\nconst INITIAL_PRESENTATION_STATE = {\n mainDocument: false,\n iframe: {\n status: 'loading',\n },\n visualEditing: {\n overlaysEnabled: false,\n },\n} as const satisfies PresentationState\n\nexport function presentationReducerInit(\n state: Readonly<Partial<PresentationState>>,\n): Readonly<PresentationState> {\n return parse(initStateSchema, {...INITIAL_PRESENTATION_STATE, ...state})\n}\n\n/** @public */\nexport type DispatchPresentationAction = Dispatch<Readonly<PresentationAction>>\n","import {useContext} from 'react'\nimport {PresentationNavigateContext} from 'sanity/_singletons'\n\nimport {type PresentationNavigateContextValue} from './types'\n\n/** @public */\nexport function usePresentationNavigate(): PresentationNavigateContextValue {\n const navigate = useContext(PresentationNavigateContext)\n\n if (!navigate) {\n throw new Error('Presentation navigate context is missing')\n }\n\n return navigate\n}\n\nexport type {PresentationNavigateContextValue}\n","import {useContext} from 'react'\nimport {PresentationParamsContext} from 'sanity/_singletons'\n\nimport {type PresentationParamsContextValue} from './types'\n\n/** @public */\nexport function usePresentationParams(throwOnMissingContext?: true): PresentationParamsContextValue\n/** @public */\nexport function usePresentationParams(\n throwOnMissingContext: false,\n): PresentationParamsContextValue | null\n/** @public */\nexport function usePresentationParams(\n throwOnMissingContext = true,\n): PresentationParamsContextValue | null {\n const params = useContext(PresentationParamsContext)\n\n if (throwOnMissingContext && !params) {\n throw new Error('Presentation params context is missing')\n }\n\n return params\n}\n"],"names":["useSharedState","key","value","$","_c","context","useContext","PresentationSharedStateContext","Error","setValue","t0","t1","useEffect","DEFAULT_TOOL_ICON","ComposeIcon","DEFAULT_TOOL_NAME","DEFAULT_TOOL_TITLE","EDIT_INTENT_MODE","MAX_TIME_TO_OVERLAYS_CONNECTION","API_VERSION","apiVersion","MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL","LOADER_QUERY_GC_INTERVAL","POPUP_CHECK_INTERVAL","keysOf","Object","keys","setKey","source","props","options","Observable","observer","subscribe","pipe","switchMap","object","keyObservables","map","isObservable","from","val","of","wait","combineLatest","pairs","reduce","acc","mergeAll","scan","INITIAL_STATE","locations","getDocumentId","isReference","_ref","_id","undefined","cleanPreviewable","id","previewable","clean","_type","_weak","_dataset","_projectId","_strengthenOnPublish","listen","fields","store","query","fetch","join","params","draftId","getDraftId","listenQuery","perspective","observeDocument","paths","currentValue","headlessPaths","filter","path","length","Set","snapshot","leads","forEach","head","tail","push","next","res","tails","isRecord","observeForLocations","documentId","resolver","documentStore","select","values","String","split","doc","get","resolve","useDocumentLocations","resolvers","type","useDocumentStore","locationsState","setLocationsState","useState","locationsStatus","setLocationsStatus","bb0","_result","result","t2","sub","state","unsubscribe","t3","status","presentationLocaleNamespace","presentationUsEnglishLocaleBundle","defineLocaleResourceBundle","locale","namespace","resources","usePresentationTool","throwOnMissingContext","presentation","PresentationContext","useCurrentPresentationToolName","name","TONE_ICONS","positive","InfoOutlineIcon","caution","WarningOutlineIcon","critical","ErrorOutlineIcon","LocationsBanner","isResolving","schemaType","showPresentationTitle","message","tone","len","t","useTranslation","presentationName","expanded","setExpanded","_temp","toggle","count","title","ToneIcon","Symbol","for","margin","jsxs","Flex","jsx","Box","Text","t4","Fragment","Card","Spinner","ChevronRightIcon","transform","transition","Stack","l","index","href","preview","t5","t6","v","LocationItem","documentType","node","active","toolName","currentPresentationToolName","isCurrentTool","navigate","structureParams","intent","mode","presentationLinkProps","useIntentLink","handleCurrentToolClick","onClick","DesktopIcon","t7","t8","t9","LocationStack","styled","rem","PresentationDocumentHeader","PresentationDocumentContext","locate","contextOptions","options_0","idx","PresentationDocumentProvider","children","parent","parentRegister","register","optionsArray","setOptionsArray","prev","concat","prev_0","o","options_1","registerEffectEvent","useEffectEvent","useLayoutEffect","useOpenInStructureAction","workspace","useWorkspace","navigateIntent","useRouter","tools","findStructureTool","defaultStructureTool","icon","MasterDetailIcon","hidden","onAction","pathToString","renderAsButton","openInStructure","defineDocumentFieldAction","useAction","presentationToolName","results","match","canHandleIntent","tool","modeMatches","preservedSearchParamKeys","getIntentState","routerState","payload","searchParams","_searchParams","includes","URLSearchParams","window","location","search","getPublishedId","entries","templateParams","encodeJsonParams","uuid","PresentationSpinner","width","router","route","create","__unsafe_disableScopedSearchParams","intents","PresentationTool","lazy","BroadcastDisplayedDocument","defineLocations","defineDocuments","presentationTool","definePlugin","console","warn","hasLocationsResolver","PresentationDocumentInput","isDocumentSchemaType","renderDefault","Suspense","canHandleCreateIntent","template","canHandleEditIntent","i18n","bundles","document","unstable_fieldActions","a","form","components","input","component","__internalApplicationType","ACTION_IFRAME_LOADED","ACTION_IFRAME_REFRESH","ACTION_IFRAME_RELOAD","ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE","presentationReducer","action","iframe","toggleVisualEditingOverlays","visualEditing","overlaysEnabled","enabled","mainDocumentSchema","fallback","boolean","iframeStatusSchema","picklist","initStateSchema","mainDocument","INITIAL_PRESENTATION_STATE","presentationReducerInit","parse","usePresentationNavigate","PresentationNavigateContext","usePresentationParams","PresentationParamsContext"],"mappings":";;;;;;AAKaA,MAAAA,iBAAiBA,CAAAC,KAAAC,UAAA;AAAA,QAAAC,IAAAC,qBAAAA,EAAA,CAAA,GAC5BC,UAAgBC,iBAAAC,0CAAyC;AAAC,MAAA,CAErDF;AAAOG,UAAAA,IAAAA,MACM,sCAAsC;AAGxD,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAmBJ;AAAO,MAAAK,IAAAC;AAAAR,IAAAF,CAAAA,MAAAA,OAAAE,SAAAM,YAAAN,EAAA,CAAA,MAAAD,SAEhBQ,KAAAA,MAAA;AACRD,aAASR,KAAKC,KAAK;AAAA,EAAA,GAClBS,KAACV,CAAAA,KAAKC,OAAOO,QAAQ,GAACN,OAAAF,KAAAE,OAAAM,UAAAN,OAAAD,OAAAC,OAAAO,IAAAP,OAAAQ,OAAAD,KAAAP,EAAA,CAAA,GAAAQ,KAAAR,EAAA,CAAA,IAFzBS,MAAAA,UAAUF,IAEPC,EAAsB;AAAC,GCbfE,oBAAoBC,MAAAA,aACpBC,oBAAoB,gBACpBC,qBAAqB,gBAErBC,mBAAmB,gBAGnBC,kCAAkC,KAGlCC,cAAcC,UAAAA,YAGdC,6CAA6C,KAG7CC,2BAA2B,KAG3BC,uBAAuB;ACLpC,SAASC,OAAyBtB,OAAU;AACnCuB,SAAAA,OAAOC,KAAKxB,KAAK;AAC1B;AAGA,SAASyB,OAAOC,QAAiC3B,KAAUC,OAAgB;AAClE,SAAA;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-1,4 +1,4 @@
1
1
  "use strict";
2
- const SANITY_VERSION = "3.72.1";
2
+ const SANITY_VERSION = "3.72.2-use-live-content-api.9+9a60bd7465";
3
3
  exports.SANITY_VERSION = SANITY_VERSION;
4
4
  //# sourceMappingURL=version.js.map