sanity 5.0.0-next-major.20251215093220 → 5.0.0-next-major.20251215132654

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/sanity CHANGED
@@ -1,57 +1,171 @@
1
1
  #!/usr/bin/env node
2
- /* eslint-disable import/no-dynamic-require, no-sync, no-console, no-process-exit */
2
+ /**
3
+ * `npx sanity`: in order for this to work, the `sanity` module should be the one
4
+ * exposing a binary. However, the `@sanity/cli` module is the one who _actually_ ship
5
+ * the CLI binary.
6
+ *
7
+ * To solve this:
8
+ * 1. `@sanity/cli` is a dependency of the `sanity` module
9
+ * 2. The path to this file is configured as `bin.sanity` in the `sanity` module
10
+ * 3. This script resolves the `@sanity/cli` package, finds the path to the `sanity`
11
+ * binary from the `@sanity/cli` package declaration (`bin.sanity`)
12
+ * 4. Either imports the resolved path directly (if it's a Node.js script), or spawns it
13
+ * (if the path specified does not point to a Node.js script)
14
+ *
15
+ * See `runSanityCli()` for more details on the dual approach of importing vs spawning.
16
+ */
3
17
 
4
- import fs from 'node:fs'
5
- import path from 'node:path'
6
- import readPkgUp from 'read-pkg-up'
18
+ /* eslint-disable import/no-dynamic-require, no-process-exit */
19
+ import {readFile, open} from 'node:fs/promises'
7
20
  import {createRequire} from 'node:module'
8
- import {fileURLToPath} from 'node:url'
21
+ import {dirname, resolve} from 'node:path'
22
+ import execa from 'execa'
9
23
 
10
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
11
- const expectedPath = path.join(__dirname, '..', 'node_modules', '.bin', 'sanity')
12
24
  const require = createRequire(import.meta.url)
13
25
 
14
- if (fs.existsSync(expectedPath)) {
15
- isNodeScript(expectedPath).then((isScript) => {
16
- if (isScript) {
17
- require(expectedPath)
26
+ runSanityCli().catch((err) => {
27
+ // Use setImmediate/setTimeout to throw outside the promise chain
28
+ setImmediate(() => {
29
+ throw err
30
+ })
31
+ })
32
+
33
+ /**
34
+ * Resolves the Sanity CLI binary from `@sanity/cli` and executes it in the best
35
+ * possible way available to us, based on the module type:
36
+ *
37
+ * - If the binary is a Node.js script, we either `import()` or `require()` it based on
38
+ * the extension (cjs/mjs) or the package `type` field. This is prefered as it does
39
+ * not require spawning a new process.
40
+ * - If the binary is not a Node.js script, we spawn it using `execa`, which handles
41
+ * things correctly across platforms (windows doesn't enjoy shebangs etc). stdio is
42
+ * inherited from the parent process.
43
+ *
44
+ * Note:
45
+ * The "new" CLI is an ESM module, while the "old" CLI is CommonJS.
46
+ * In theory, Node.js now has support for transparently mixing CommonJS and ESM, but in
47
+ * practice we've seen some issues with this approach for the CLI specifically. Thus, we
48
+ * explicitly check the package type and use either `import()` or `require()` accordingly.
49
+ */
50
+ async function runSanityCli() {
51
+ const {bin, type} = await getSanityCliBin()
52
+
53
+ // The optimal case: the binary is a Node.js script - import/require it directly to
54
+ // prevent needing to spawn a new process
55
+ if (await isNodeScript(bin)) {
56
+ if (type === 'module') {
57
+ await import(bin)
18
58
  } else {
19
- runFromCli()
59
+ require(bin)
20
60
  }
61
+ return
62
+ }
63
+
64
+ // Fallback: spawn the binary as a child process
65
+ const child = execa(bin, process.argv.slice(2), {
66
+ stdio: 'inherit',
67
+ encoding: null,
68
+ buffer: false,
69
+ reject: false,
21
70
  })
22
- } else {
23
- runFromCli()
24
- }
25
71
 
26
- function runFromCli() {
27
- getSanityCliPath()
28
- .then((cliPath) => require(path.join(cliPath, 'bin', 'sanity')))
29
- .catch((err) => {
30
- console.error(err)
31
- process.exit(1)
32
- })
72
+ // Forward signals to the child process
73
+ const signals = ['SIGINT', 'SIGTERM', 'SIGHUP']
74
+ const signalHandlers = signals.map((signal) => {
75
+ const handler = () => child.kill(signal)
76
+ process.on(signal, handler)
77
+ return {signal, handler}
78
+ })
79
+
80
+ try {
81
+ const {exitCode} = await child
82
+ process.exitCode = exitCode
83
+ } finally {
84
+ // Clean up signal handlers
85
+ for (const {signal, handler} of signalHandlers) {
86
+ process.off(signal, handler)
87
+ }
88
+ }
33
89
  }
34
90
 
35
- async function getSanityCliPath() {
36
- const modulePath = require.resolve(
37
- // Resolve package.json from `@sanity/cli` instead of the main export to allow resolving before
38
- // the package is built. Used when running the CLI from source by setting the env var SANITY_CLI_RUN_FROM_SOURCE=1
39
- '@sanity/cli/package.json',
40
- )
41
- const pkg = await readPkgUp({cwd: path.dirname(modulePath)})
42
- if (pkg) {
43
- return path.dirname(pkg.path)
91
+ async function getSanityCliBin() {
92
+ // Resolve package.json from `@sanity/cli` instead of the main export to allow
93
+ // resolving before the package is built. Note that this might fail if `@sanity/cli`
94
+ // does not explicitly list `./package.json` in the exports field, but since control
95
+ // this module, this feels like a safe assumption.
96
+ const pkgPath = require.resolve('@sanity/cli/package.json')
97
+
98
+ let pkg
99
+ try {
100
+ pkg = JSON.parse(await readFile(pkgPath, 'utf8'))
101
+ } catch (err) {
102
+ throw new Error(`Failed to read @sanity/cli package.json: ${err.message}`)
103
+ }
104
+
105
+ if (!pkg.bin?.sanity) {
106
+ throw new Error('Failed to find `bin.sanity` field in @sanity/cli package.json')
44
107
  }
45
108
 
46
- throw new Error('Failed to resolve @sanity/cli path')
109
+ // Assuming `package.json` is located at the root of the package - anything else would
110
+ // be… wild, unconventional, unorthodox… I'd even say… heretical.
111
+ const cliDir = dirname(pkgPath)
112
+
113
+ // Note that npm normalizes bin paths: `./bin/sanity` -> `bin/sanity`
114
+ const bin = resolve(cliDir, pkg.bin.sanity)
115
+ const type = determineModuleType(bin, pkg)
116
+ return {bin, type}
47
117
  }
48
118
 
119
+ /**
120
+ * Determines if the file at `scriptPath` is a Node.js script by checking its shebang.
121
+ * Returns true if:
122
+ * - The shebang interpreter is `node` (e.g., `#!/usr/bin/node`, `#!/usr/bin/env node`)
123
+ * - The file has a `.js`, `.mjs`, or `.cjs` extension (fallback when no shebang)
124
+ */
49
125
  async function isNodeScript(scriptPath) {
50
- const file = await fs.promises.open(scriptPath)
51
- const {buffer} = await file.read({length: 256})
52
- await file.close()
126
+ let file
127
+ try {
128
+ file = await open(scriptPath)
129
+ } catch (err) {
130
+ throw new Error(
131
+ `Failed to read CLI binary at ${scriptPath}: ${err instanceof Error ? err.message : err}`,
132
+ )
133
+ }
134
+
135
+ try {
136
+ const {buffer, bytesRead} = await file.read({length: 256})
137
+ const content = buffer.toString('utf8', 0, bytesRead)
138
+
139
+ if (!content.startsWith('#!')) {
140
+ // No shebang - fall back to extension check (.js, .mjs, .cjs)
141
+ // This is not perfect - but it's better than nothing
142
+ return /\.(m?js|cjs)$/.test(scriptPath)
143
+ }
144
+
145
+ // Extract the interpreter, handling both direct paths and `env` invocations:
146
+ // `#!/usr/bin/node` => `node`
147
+ // `#!/usr/bin/env node` => `node`
148
+ // `#!/usr/bin/env -S node --flags` => `node`
149
+ const firstLine = content.slice(2, content.indexOf('\n')).trim()
150
+ const parts = firstLine.split(/\s+/)
151
+ const interpreter = parts[0].endsWith('/env')
152
+ ? parts.find((part, i) => i > 0 && !part.startsWith('-'))
153
+ : parts[0]
154
+
155
+ return interpreter && (interpreter.endsWith('node') || interpreter.endsWith('node.exe'))
156
+ } finally {
157
+ await file.close()
158
+ }
159
+ }
160
+
161
+ function determineModuleType(binPath, pkgJson) {
162
+ if (binPath.endsWith('.cjs')) {
163
+ return 'commonjs'
164
+ }
165
+
166
+ if (binPath.endsWith('.mjs')) {
167
+ return 'module'
168
+ }
53
169
 
54
- const content = buffer.toString('utf8')
55
- const firstLine = content.trimStart().slice(0, content.indexOf('\n'))
56
- return firstLine.endsWith('node')
170
+ return pkgJson.type === 'module' ? 'module' : 'commonjs'
57
171
  }
@@ -6,8 +6,8 @@ import { rimraf } from "rimraf";
6
6
  import semver from "semver";
7
7
  import { buildStaticFiles } from "./previewServer.js";
8
8
  import "./runtime.js";
9
- import { buildVendorDependencies, formatModuleSizes, sortModulesBySize } from "./moduleFormatUtils.js";
10
- import { shouldAutoUpdate, getAutoUpdatesImportMap, warnAboutMissingAppId, compareDependencyVersions } from "./warnAboutMissingAppId.js";
9
+ import { warnAboutMissingAppId, buildVendorDependencies, formatModuleSizes, sortModulesBySize } from "./warnAboutMissingAppId.js";
10
+ import { shouldAutoUpdate, getAutoUpdatesImportMap, compareDependencyVersions } from "./shouldAutoUpdate.js";
11
11
  import { getAppId } from "./getAppId.js";
12
12
  import { readModuleVersion, getTimer } from "./timing.js";
13
13
  const BuildTrace = defineTrace({
@@ -8,8 +8,8 @@ import { buildStaticFiles } from "./previewServer.js";
8
8
  import "./runtime.js";
9
9
  import { checkStudioDependencyVersions, checkRequiredDependencies, upgradePackages, getPackageManagerChoice } from "./upgradePackages.js";
10
10
  import { getTimer } from "./timing.js";
11
- import { buildVendorDependencies, formatModuleSizes, sortModulesBySize } from "./moduleFormatUtils.js";
12
- import { shouldAutoUpdate, getAutoUpdatesImportMap, warnAboutMissingAppId, compareDependencyVersions } from "./warnAboutMissingAppId.js";
11
+ import { warnAboutMissingAppId, buildVendorDependencies, formatModuleSizes, sortModulesBySize } from "./warnAboutMissingAppId.js";
12
+ import { shouldAutoUpdate, getAutoUpdatesImportMap, compareDependencyVersions } from "./shouldAutoUpdate.js";
13
13
  import { isInteractive } from "./_internal.js";
14
14
  import { getAppId } from "./getAppId.js";
15
15
  const BuildTrace = defineTrace({
@@ -2,7 +2,7 @@ import path from "node:path";
2
2
  import zlib from "node:zlib";
3
3
  import tar from "tar-fs";
4
4
  import { getAppId } from "./getAppId.js";
5
- import { shouldAutoUpdate } from "./warnAboutMissingAppId.js";
5
+ import { shouldAutoUpdate } from "./shouldAutoUpdate.js";
6
6
  import { getInstalledSanityVersion, dirIsEmptyOrNonExistent, getOrCreateUserApplicationFromConfig, getOrCreateApplication, debug, checkDir, createDeployment } from "./helpers.js";
7
7
  import buildSanityApp from "./buildAction.js";
8
8
  async function deployAppAction(args, context) {
@@ -2,7 +2,7 @@ import path from "node:path";
2
2
  import zlib from "node:zlib";
3
3
  import tar from "tar-fs";
4
4
  import { getAppId } from "./getAppId.js";
5
- import { shouldAutoUpdate } from "./warnAboutMissingAppId.js";
5
+ import { shouldAutoUpdate } from "./shouldAutoUpdate.js";
6
6
  import buildSanityStudio from "./buildAction2.js";
7
7
  import { deploySchemasAction } from "./deploySchemasAction.js";
8
8
  import { createManifestExtractor } from "./schemaStoreOutStrings.js";
@@ -8,7 +8,7 @@ import yargs from "yargs/yargs";
8
8
  import { isInteractive, debug as debug$2 } from "./_internal.js";
9
9
  import { debug as debug$1, writeSanityRuntime, getViteConfig, extendViteConfigWithUserConfig } from "./runtime.js";
10
10
  import { checkStudioDependencyVersions, checkRequiredDependencies, upgradePackages, getPackageManagerChoice } from "./upgradePackages.js";
11
- import { shouldAutoUpdate, warnAboutMissingAppId, compareDependencyVersions } from "./warnAboutMissingAppId.js";
11
+ import { shouldAutoUpdate, compareDependencyVersions } from "./shouldAutoUpdate.js";
12
12
  import { getAppId } from "./getAppId.js";
13
13
  import { gracefulServerDeath, getSharedServerConfig } from "./servers.js";
14
14
  import { getTimer } from "./timing.js";
@@ -113,8 +113,7 @@ async function startSanityDevServer(args, context) {
113
113
  apiClient,
114
114
  workDir,
115
115
  cliConfig,
116
- prompt,
117
- cliConfigPath
116
+ prompt
118
117
  } = context, {
119
118
  loadInDashboard
120
119
  } = flags;
@@ -143,12 +142,7 @@ async function startSanityDevServer(args, context) {
143
142
  cliConfig,
144
143
  output
145
144
  });
146
- output.print(`${logSymbols.info} Running with auto-updates enabled`), appId || warnAboutMissingAppId({
147
- appType: "studio",
148
- cliConfigPath,
149
- output,
150
- projectId: cliConfig?.api?.projectId
151
- });
145
+ output.print(`${logSymbols.info} Running with auto-updates enabled`);
152
146
  let result;
153
147
  try {
154
148
  result = await compareDependencyVersions(sanityDependencies, workDir, {
@@ -1 +1 @@
1
- {"version":3,"file":"devAction2.js","sources":["../../src/_internal/cli/server/devServer.ts","../../src/_internal/cli/actions/dev/devAction.ts"],"sourcesContent":["import {type ReactCompilerConfig, type UserViteConfig} from '@sanity/cli'\nimport {type ViteDevServer} from 'vite'\n\nimport {debug} from './debug'\nimport {extendViteConfigWithUserConfig, getViteConfig} from './getViteConfig'\nimport {writeSanityRuntime} from './runtime'\n\nexport interface DevServerOptions {\n cwd: string\n basePath: string\n staticPath: string\n\n httpPort: number\n httpHost?: string\n projectName?: string\n\n reactStrictMode: boolean\n reactCompiler: ReactCompilerConfig | undefined\n vite?: UserViteConfig\n entry?: string\n isApp?: boolean\n}\n\nexport interface DevServer {\n server: ViteDevServer\n close(): Promise<void>\n}\n\nexport async function startDevServer(options: DevServerOptions): Promise<DevServer> {\n const {\n cwd,\n httpPort,\n httpHost,\n basePath,\n reactStrictMode,\n vite: extendViteConfig,\n reactCompiler,\n entry,\n isApp,\n } = options\n\n debug('Writing Sanity runtime files')\n await writeSanityRuntime({cwd, reactStrictMode, watch: true, basePath, entry, isApp})\n\n debug('Resolving vite config')\n const mode = 'development'\n\n let viteConfig = await getViteConfig({\n basePath,\n mode: 'development',\n server: {port: httpPort, host: httpHost},\n cwd,\n reactCompiler,\n isApp,\n })\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'serve', mode},\n viteConfig,\n extendViteConfig,\n )\n }\n\n debug('Creating vite server')\n const {createServer} = await import('vite')\n const server = await createServer(viteConfig)\n\n debug('Listening on specified port')\n await server.listen()\n\n return {\n server,\n close: () => server.close(),\n }\n}\n","/* eslint-disable max-statements */\nimport path from 'node:path'\n\nimport {\n type CliCommandArguments,\n type CliCommandContext,\n type CliConfig,\n type CliOutputter,\n} from '@sanity/cli'\nimport {type SanityProject} from '@sanity/client'\nimport chalk from 'chalk'\nimport logSymbols from 'log-symbols'\nimport semver from 'semver'\nimport {version} from 'vite'\nimport {hideBin} from 'yargs/helpers'\nimport yargs from 'yargs/yargs'\n\nimport {debug as debugIt} from '../../debug'\nimport {type DevServerOptions, startDevServer} from '../../server/devServer'\nimport {checkRequiredDependencies} from '../../util/checkRequiredDependencies'\nimport {checkStudioDependencyVersions} from '../../util/checkStudioDependencyVersions'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions'\nimport {getAppId} from '../../util/getAppId'\nimport {isInteractive} from '../../util/isInteractive'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages'\nimport {getSharedServerConfig, gracefulServerDeath} from '../../util/servers'\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport {getTimer} from '../../util/timing'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId'\n\nexport interface StartDevServerCommandFlags {\n 'host'?: string\n 'port'?: string\n 'load-in-dashboard'?: boolean\n 'auto-updates'?: boolean\n 'force'?: boolean\n}\n\nconst debug = debugIt.extend('dev')\n\nconst baseUrl =\n process.env.SANITY_INTERNAL_ENV === 'staging' ? 'https://sanity.work' : 'https://sanity.io'\n\nconst getDefaultDashboardURL = ({\n organizationId,\n url,\n}: {\n organizationId: string\n url: string\n}): string => {\n return `${baseUrl}/@${organizationId}?${new URLSearchParams({\n dev: url,\n }).toString()}`\n}\n\nexport const getDashboardURL = async ({\n fetchFn = globalThis.fetch,\n timeout = 5000,\n organizationId,\n url,\n}: {\n fetchFn?: typeof globalThis.fetch\n timeout?: number\n organizationId: string\n url: string\n}): Promise<string> => {\n const abortController = new AbortController()\n // Wait for 5 seconds before aborting the request\n const timer = setTimeout(() => abortController.abort(), timeout)\n try {\n const queryParams = new URLSearchParams({\n organizationId,\n url,\n })\n\n const res = await fetchFn(\n `${baseUrl}/api/dashboard/mode/development/resolve-url?${queryParams.toString()}`,\n {\n signal: abortController.signal,\n },\n )\n\n if (!res.ok) {\n debug(`Failed to fetch dashboard URL: ${res.statusText}`)\n return getDefaultDashboardURL({organizationId, url})\n }\n\n const body = await res.json()\n return body.url\n } catch (err) {\n debug(`Failed to fetch dashboard URL: ${err.message}`)\n return getDefaultDashboardURL({organizationId, url})\n } finally {\n clearTimeout(timer)\n }\n}\n\n/**\n * Gets the dashboard URL from API or uses the default dashboard URL\n */\nexport const getDashboardAppURL = async ({\n organizationId,\n httpHost = 'localhost',\n httpPort = 3333,\n}: {\n organizationId: string\n httpHost?: string\n httpPort?: number\n}): Promise<string> => {\n const url = await getDashboardURL({\n organizationId,\n url: `http://${httpHost}:${httpPort}`,\n })\n\n // <dashboard-app-url>/<orgniazationId>?dev=<dev-server-url>\n return url\n}\n\nfunction parseCliFlags(args: {argv?: string[]}) {\n // Using slice(1) to remove the first argument, which is the command `dev` path to the CLI\n return yargs(hideBin(args.argv || process.argv).slice(1))\n .options('host', {type: 'string'})\n .options('port', {type: 'number'})\n .options('auto-updates', {type: 'boolean'})\n .option('load-in-dashboard', {type: 'boolean', default: false}).argv\n}\n\nexport default async function startSanityDevServer(\n args: CliCommandArguments<StartDevServerCommandFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const timers = getTimer()\n const flags = await parseCliFlags(args)\n const {output, apiClient, workDir, cliConfig, prompt, cliConfigPath} = context\n\n const {loadInDashboard} = flags\n\n timers.start('checkStudioDependencyVersions')\n await checkStudioDependencyVersions(workDir)\n timers.end('checkStudioDependencyVersions')\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 if ((await checkRequiredDependencies(context)).didInstall) {\n return\n }\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\n }\n\n const autoUpdatesEnabled = shouldAutoUpdate({flags, cliConfig})\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semver.parse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n const appId = getAppId({cliConfig, output})\n\n output.print(`${logSymbols.info} Running with auto-updates enabled`)\n if (!appId) {\n warnAboutMissingAppId({\n appType: 'studio',\n cliConfigPath,\n output,\n projectId: cliConfig?.api?.projectId,\n })\n }\n // Check local versions against deployed versions\n let result: Awaited<ReturnType<typeof compareDependencyVersions>> | undefined\n try {\n result = await compareDependencyVersions(sanityDependencies, workDir, {appId})\n } catch (err) {\n console.warn(\n new Error('Failed to compare local versions against auto-updating versions', {\n cause: err,\n }),\n )\n }\n if (result?.length) {\n const message =\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 run with the same versions locally as will be used when deploying. \\n\\n` +\n `${result.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')} \\n\\n`\n\n // mismatch between local and auto-updating dependencies\n if (isInteractive) {\n const shouldUpgrade = await prompt.single({\n type: 'confirm',\n message: chalk.yellow(`${message}Do you want to upgrade local versions?`),\n default: true,\n })\n if (shouldUpgrade) {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.map((res) => [res.pkg, res.remote]),\n },\n context,\n )\n }\n } else {\n // In this case we warn the user but we don't ask them if they want to upgrade because it's not interactive.\n output.print(chalk.yellow(message))\n }\n }\n }\n\n // Try to load CLI configuration from sanity.cli.(js|ts)\n const config = getDevServerConfig({flags, workDir, cliConfig, output})\n\n const projectId = cliConfig?.api?.projectId\n let organizationId: string | undefined | null\n\n if (loadInDashboard) {\n if (!projectId) {\n output.error('Project Id is required to load in dashboard')\n process.exit(1)\n }\n\n const client = apiClient({\n requireUser: true,\n requireProject: true,\n })\n\n try {\n const project = await client.request<SanityProject>({uri: `/projects/${projectId}`})\n organizationId = project.organizationId\n } catch (err) {\n debug(`Failed to get organization Id from project Id: ${err}`)\n output.error('Failed to get organization Id from project Id')\n process.exit(1)\n }\n }\n\n try {\n const startTime = Date.now()\n const spinner = output.spinner('Starting dev server').start()\n const {server} = await startDevServer({...config})\n\n const {info: loggerInfo} = server.config.logger\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n spinner.succeed()\n\n if (loadInDashboard) {\n if (!organizationId) {\n output.error('Organization Id not found for project')\n process.exit(1)\n }\n\n output.print(`Dev server started on ${config.httpPort} port`)\n output.print(`View your app in the Sanity dashboard here:`)\n output.print(\n chalk.blue(\n chalk.underline(\n await getDashboardAppURL({\n organizationId,\n httpHost: config.httpHost,\n httpPort: config.httpPort,\n }),\n ),\n ),\n )\n } else {\n const startupDuration = Date.now() - startTime\n const url = `http://${httpHost || 'localhost'}:${port}${config.basePath}`\n const appType = 'Sanity Studio'\n\n loggerInfo(\n `${appType} ` +\n `using ${chalk.cyan(`vite@${version}`)} ` +\n `ready in ${chalk.cyan(`${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${chalk.cyan(url)}`,\n )\n }\n } catch (err) {\n debug(`Failed to start dev server: ${err}`)\n gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n\nexport function getDevServerConfig({\n flags,\n workDir,\n cliConfig,\n output,\n}: {\n flags: {host?: string; port?: number}\n workDir: string\n cliConfig?: CliConfig\n output: CliOutputter\n}): Omit<DevServerOptions, 'spinner'> {\n const configSpinner = output.spinner('Checking configuration files...')\n const baseConfig = getSharedServerConfig({\n flags: {\n host: flags.host,\n port: flags.port,\n },\n workDir,\n cliConfig,\n })\n configSpinner.succeed()\n\n const env = process.env\n const reactStrictMode = env.SANITY_STUDIO_REACT_STRICT_MODE\n ? env.SANITY_STUDIO_REACT_STRICT_MODE === 'true'\n : Boolean(cliConfig?.reactStrictMode)\n\n if (env.SANITY_STUDIO_BASEPATH && cliConfig?.project?.basePath) {\n output.warn(\n `Overriding configured base path (${cliConfig.project.basePath}) with value from environment variable (${env.SANITY_STUDIO_BASEPATH})`,\n )\n }\n\n return {\n ...baseConfig,\n staticPath: path.join(workDir, 'static'),\n reactStrictMode,\n reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n }\n}\n"],"names":["startDevServer","options","cwd","httpPort","httpHost","basePath","reactStrictMode","vite","extendViteConfig","reactCompiler","entry","isApp","debug","writeSanityRuntime","watch","mode","viteConfig","getViteConfig","server","port","host","extendViteConfigWithUserConfig","command","createServer","listen","close","debugIt","extend","baseUrl","process","env","SANITY_INTERNAL_ENV","getDefaultDashboardURL","organizationId","url","URLSearchParams","dev","toString","getDashboardURL","fetchFn","globalThis","fetch","timeout","abortController","AbortController","timer","setTimeout","abort","queryParams","res","signal","ok","json","statusText","err","message","clearTimeout","getDashboardAppURL","parseCliFlags","args","yargs","hideBin","argv","slice","type","option","default","startSanityDevServer","context","timers","getTimer","flags","output","apiClient","workDir","cliConfig","prompt","cliConfigPath","loadInDashboard","start","checkStudioDependencyVersions","end","checkRequiredDependencies","didInstall","installedSanityVersion","shouldAutoUpdate","cleanSanityVersion","semver","parse","version","Error","sanityDependencies","name","appId","getAppId","print","logSymbols","info","warnAboutMissingAppId","appType","projectId","api","result","compareDependencyVersions","console","warn","cause","length","map","mod","pkg","installed","remote","join","isInteractive","single","chalk","yellow","upgradePackages","packageManager","getPackageManagerChoice","interactive","chosen","packages","config","getDevServerConfig","error","exit","client","requireUser","requireProject","request","uri","startTime","Date","now","spinner","loggerInfo","logger","succeed","blue","underline","startupDuration","cyan","Math","ceil","gracefulServerDeath","configSpinner","baseConfig","getSharedServerConfig","SANITY_STUDIO_REACT_STRICT_MODE","Boolean","SANITY_STUDIO_BASEPATH","project","staticPath","path","undefined"],"mappings":";;;;;;;;;;;;;;AA4BA,eAAsBA,eAAeC,SAA+C;AAClF,QAAM;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,MAAMC;AAAAA,IACNC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,EAAAA,IACEV;AAEJW,UAAM,8BAA8B,GACpC,MAAMC,mBAAmB;AAAA,IAACX;AAAAA,IAAKI;AAAAA,IAAiBQ,OAAO;AAAA,IAAMT;AAAAA,IAAUK;AAAAA,IAAOC;AAAAA,EAAAA,CAAM,GAEpFC,Q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MmD,MAAMnD;AAAAA,MACZD,MAAMoD,MAAMpD;AAAAA,IAAAA;AAAAA,IAEduD;AAAAA,IACAC;AAAAA,EAAAA,CACD;AACDwE,gBAAcR,QAAAA;AAEd,QAAM7G,MAAMD,QAAQC,KACdxB,kBAAkBwB,IAAIwH,kCACxBxH,IAAIwH,oCAAoC,SACxCC,CAAAA,CAAQ5E,WAAWrE;AAEvB,SAAIwB,IAAI0H,0BAA0B7E,WAAW8E,SAASpJ,YACpDmE,OAAOiC,KACL,oCAAoC9B,UAAU8E,QAAQpJ,QAAQ,2CAA2CyB,IAAI0H,sBAAsB,GACrI,GAGK;AAAA,IACL,GAAGJ;AAAAA,IACHM,YAAYC,KAAK1C,KAAKvC,SAAS,QAAQ;AAAA,IACvCpE;AAAAA,IACAG,eAAekE,aAAa,mBAAmBA,YAAYA,UAAUlE,gBAAgBmJ;AAAAA,EAAAA;AAEzF;;;;;;;;"}
1
+ {"version":3,"file":"devAction2.js","sources":["../../src/_internal/cli/server/devServer.ts","../../src/_internal/cli/actions/dev/devAction.ts"],"sourcesContent":["import {type ReactCompilerConfig, type UserViteConfig} from '@sanity/cli'\nimport {type ViteDevServer} from 'vite'\n\nimport {debug} from './debug'\nimport {extendViteConfigWithUserConfig, getViteConfig} from './getViteConfig'\nimport {writeSanityRuntime} from './runtime'\n\nexport interface DevServerOptions {\n cwd: string\n basePath: string\n staticPath: string\n\n httpPort: number\n httpHost?: string\n projectName?: string\n\n reactStrictMode: boolean\n reactCompiler: ReactCompilerConfig | undefined\n vite?: UserViteConfig\n entry?: string\n isApp?: boolean\n}\n\nexport interface DevServer {\n server: ViteDevServer\n close(): Promise<void>\n}\n\nexport async function startDevServer(options: DevServerOptions): Promise<DevServer> {\n const {\n cwd,\n httpPort,\n httpHost,\n basePath,\n reactStrictMode,\n vite: extendViteConfig,\n reactCompiler,\n entry,\n isApp,\n } = options\n\n debug('Writing Sanity runtime files')\n await writeSanityRuntime({cwd, reactStrictMode, watch: true, basePath, entry, isApp})\n\n debug('Resolving vite config')\n const mode = 'development'\n\n let viteConfig = await getViteConfig({\n basePath,\n mode: 'development',\n server: {port: httpPort, host: httpHost},\n cwd,\n reactCompiler,\n isApp,\n })\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'serve', mode},\n viteConfig,\n extendViteConfig,\n )\n }\n\n debug('Creating vite server')\n const {createServer} = await import('vite')\n const server = await createServer(viteConfig)\n\n debug('Listening on specified port')\n await server.listen()\n\n return {\n server,\n close: () => server.close(),\n }\n}\n","/* eslint-disable max-statements */\nimport path from 'node:path'\n\nimport {\n type CliCommandArguments,\n type CliCommandContext,\n type CliConfig,\n type CliOutputter,\n} from '@sanity/cli'\nimport {type SanityProject} from '@sanity/client'\nimport chalk from 'chalk'\nimport logSymbols from 'log-symbols'\nimport semver from 'semver'\nimport {version} from 'vite'\nimport {hideBin} from 'yargs/helpers'\nimport yargs from 'yargs/yargs'\n\nimport {debug as debugIt} from '../../debug'\nimport {type DevServerOptions, startDevServer} from '../../server/devServer'\nimport {checkRequiredDependencies} from '../../util/checkRequiredDependencies'\nimport {checkStudioDependencyVersions} from '../../util/checkStudioDependencyVersions'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions'\nimport {getAppId} from '../../util/getAppId'\nimport {isInteractive} from '../../util/isInteractive'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages'\nimport {getSharedServerConfig, gracefulServerDeath} from '../../util/servers'\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport {getTimer} from '../../util/timing'\n\nexport interface StartDevServerCommandFlags {\n 'host'?: string\n 'port'?: string\n 'load-in-dashboard'?: boolean\n 'auto-updates'?: boolean\n 'force'?: boolean\n}\n\nconst debug = debugIt.extend('dev')\n\nconst baseUrl =\n process.env.SANITY_INTERNAL_ENV === 'staging' ? 'https://sanity.work' : 'https://sanity.io'\n\nconst getDefaultDashboardURL = ({\n organizationId,\n url,\n}: {\n organizationId: string\n url: string\n}): string => {\n return `${baseUrl}/@${organizationId}?${new URLSearchParams({\n dev: url,\n }).toString()}`\n}\n\nexport const getDashboardURL = async ({\n fetchFn = globalThis.fetch,\n timeout = 5000,\n organizationId,\n url,\n}: {\n fetchFn?: typeof globalThis.fetch\n timeout?: number\n organizationId: string\n url: string\n}): Promise<string> => {\n const abortController = new AbortController()\n // Wait for 5 seconds before aborting the request\n const timer = setTimeout(() => abortController.abort(), timeout)\n try {\n const queryParams = new URLSearchParams({\n organizationId,\n url,\n })\n\n const res = await fetchFn(\n `${baseUrl}/api/dashboard/mode/development/resolve-url?${queryParams.toString()}`,\n {\n signal: abortController.signal,\n },\n )\n\n if (!res.ok) {\n debug(`Failed to fetch dashboard URL: ${res.statusText}`)\n return getDefaultDashboardURL({organizationId, url})\n }\n\n const body = await res.json()\n return body.url\n } catch (err) {\n debug(`Failed to fetch dashboard URL: ${err.message}`)\n return getDefaultDashboardURL({organizationId, url})\n } finally {\n clearTimeout(timer)\n }\n}\n\n/**\n * Gets the dashboard URL from API or uses the default dashboard URL\n */\nexport const getDashboardAppURL = async ({\n organizationId,\n httpHost = 'localhost',\n httpPort = 3333,\n}: {\n organizationId: string\n httpHost?: string\n httpPort?: number\n}): Promise<string> => {\n const url = await getDashboardURL({\n organizationId,\n url: `http://${httpHost}:${httpPort}`,\n })\n\n // <dashboard-app-url>/<orgniazationId>?dev=<dev-server-url>\n return url\n}\n\nfunction parseCliFlags(args: {argv?: string[]}) {\n // Using slice(1) to remove the first argument, which is the command `dev` path to the CLI\n return yargs(hideBin(args.argv || process.argv).slice(1))\n .options('host', {type: 'string'})\n .options('port', {type: 'number'})\n .options('auto-updates', {type: 'boolean'})\n .option('load-in-dashboard', {type: 'boolean', default: false}).argv\n}\n\nexport default async function startSanityDevServer(\n args: CliCommandArguments<StartDevServerCommandFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const timers = getTimer()\n const flags = await parseCliFlags(args)\n const {output, apiClient, workDir, cliConfig, prompt, cliConfigPath} = context\n\n const {loadInDashboard} = flags\n\n timers.start('checkStudioDependencyVersions')\n await checkStudioDependencyVersions(workDir)\n timers.end('checkStudioDependencyVersions')\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 if ((await checkRequiredDependencies(context)).didInstall) {\n return\n }\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\n }\n\n const autoUpdatesEnabled = shouldAutoUpdate({flags, cliConfig})\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semver.parse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n const appId = getAppId({cliConfig, output})\n\n output.print(`${logSymbols.info} Running with auto-updates enabled`)\n\n // Check local versions against deployed versions\n let result: Awaited<ReturnType<typeof compareDependencyVersions>> | undefined\n try {\n result = await compareDependencyVersions(sanityDependencies, workDir, {appId})\n } catch (err) {\n console.warn(\n new Error('Failed to compare local versions against auto-updating versions', {\n cause: err,\n }),\n )\n }\n if (result?.length) {\n const message =\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 run with the same versions locally as will be used when deploying. \\n\\n` +\n `${result.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')} \\n\\n`\n\n // mismatch between local and auto-updating dependencies\n if (isInteractive) {\n const shouldUpgrade = await prompt.single({\n type: 'confirm',\n message: chalk.yellow(`${message}Do you want to upgrade local versions?`),\n default: true,\n })\n if (shouldUpgrade) {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.map((res) => [res.pkg, res.remote]),\n },\n context,\n )\n }\n } else {\n // In this case we warn the user but we don't ask them if they want to upgrade because it's not interactive.\n output.print(chalk.yellow(message))\n }\n }\n }\n\n // Try to load CLI configuration from sanity.cli.(js|ts)\n const config = getDevServerConfig({flags, workDir, cliConfig, output})\n\n const projectId = cliConfig?.api?.projectId\n let organizationId: string | undefined | null\n\n if (loadInDashboard) {\n if (!projectId) {\n output.error('Project Id is required to load in dashboard')\n process.exit(1)\n }\n\n const client = apiClient({\n requireUser: true,\n requireProject: true,\n })\n\n try {\n const project = await client.request<SanityProject>({uri: `/projects/${projectId}`})\n organizationId = project.organizationId\n } catch (err) {\n debug(`Failed to get organization Id from project Id: ${err}`)\n output.error('Failed to get organization Id from project Id')\n process.exit(1)\n }\n }\n\n try {\n const startTime = Date.now()\n const spinner = output.spinner('Starting dev server').start()\n const {server} = await startDevServer({...config})\n\n const {info: loggerInfo} = server.config.logger\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n spinner.succeed()\n\n if (loadInDashboard) {\n if (!organizationId) {\n output.error('Organization Id not found for project')\n process.exit(1)\n }\n\n output.print(`Dev server started on ${config.httpPort} port`)\n output.print(`View your app in the Sanity dashboard here:`)\n output.print(\n chalk.blue(\n chalk.underline(\n await getDashboardAppURL({\n organizationId,\n httpHost: config.httpHost,\n httpPort: config.httpPort,\n }),\n ),\n ),\n )\n } else {\n const startupDuration = Date.now() - startTime\n const url = `http://${httpHost || 'localhost'}:${port}${config.basePath}`\n const appType = 'Sanity Studio'\n\n loggerInfo(\n `${appType} ` +\n `using ${chalk.cyan(`vite@${version}`)} ` +\n `ready in ${chalk.cyan(`${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${chalk.cyan(url)}`,\n )\n }\n } catch (err) {\n debug(`Failed to start dev server: ${err}`)\n gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n\nexport function getDevServerConfig({\n flags,\n workDir,\n cliConfig,\n output,\n}: {\n flags: {host?: string; port?: number}\n workDir: string\n cliConfig?: CliConfig\n output: CliOutputter\n}): Omit<DevServerOptions, 'spinner'> {\n const configSpinner = output.spinner('Checking configuration files...')\n const baseConfig = getSharedServerConfig({\n flags: {\n host: flags.host,\n port: flags.port,\n },\n workDir,\n cliConfig,\n })\n configSpinner.succeed()\n\n const env = process.env\n const reactStrictMode = env.SANITY_STUDIO_REACT_STRICT_MODE\n ? env.SANITY_STUDIO_REACT_STRICT_MODE === 'true'\n : Boolean(cliConfig?.reactStrictMode)\n\n if (env.SANITY_STUDIO_BASEPATH && cliConfig?.project?.basePath) {\n output.warn(\n `Overriding configured base path (${cliConfig.project.basePath}) with value from environment variable (${env.SANITY_STUDIO_BASEPATH})`,\n )\n }\n\n return {\n ...baseConfig,\n staticPath: path.join(workDir, 'static'),\n reactStrictMode,\n reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n }\n}\n"],"names":["startDevServer","options","cwd","httpPort","httpHost","basePath","reactStrictMode","vite","extendViteConfig","reactCompiler","entry","isApp","debug","writeSanityRuntime","watch","mode","viteConfig","getViteConfig","server","port","host","extendViteConfigWithUserConfig","command","createServer","listen","close","debugIt","extend","baseUrl","process","env","SANITY_INTERNAL_ENV","getDefaultDashboardURL","organizationId","url","URLSearchParams","dev","toString","getDashboardURL","fetchFn","globalThis","fetch","timeout","abortController","AbortController","timer","setTimeout","abort","queryParams","res","signal","ok","json","statusText","err","message","clearTimeout","getDashboardAppURL","parseCliFlags","args","yargs","hideBin","argv","slice","type","option","default","startSanityDevServer","context","timers","getTimer","flags","output","apiClient","workDir","cliConfig","prompt","loadInDashboard","start","checkStudioDependencyVersions","end","checkRequiredDependencies","didInstall","installedSanityVersion","shouldAutoUpdate","cleanSanityVersion","semver","parse","version","Error","sanityDependencies","name","appId","getAppId","print","logSymbols","info","result","compareDependencyVersions","console","warn","cause","length","map","mod","pkg","installed","remote","join","isInteractive","single","chalk","yellow","upgradePackages","packageManager","getPackageManagerChoice","interactive","chosen","packages","config","getDevServerConfig","projectId","api","error","exit","client","requireUser","requireProject","request","uri","startTime","Date","now","spinner","loggerInfo","logger","succeed","blue","underline","startupDuration","cyan","Math","ceil","gracefulServerDeath","configSpinner","baseConfig","getSharedServerConfig","SANITY_STUDIO_REACT_STRICT_MODE","Boolean","SANITY_STUDIO_BASEPATH","project","staticPath","path","undefined"],"mappings":";;;;;;;;;;;;;;AA4BA,eAAsBA,eAAeC,SAA+C;AAClF,QAAM;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,MAAMC;AAAAA,IACNC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,EAAAA,IACEV;AAEJW,UAAM,8BAA8B,GACpC,MAAMC,mBAAmB;AAAA,IAACX;AAAAA,IAAKI;AAAAA,IAAiBQ,OAAO;AAAA,IAAMT;AAAAA,IAAUK;AAAAA,IAAOC;AAAAA,EAAAA,CAAM,GAEpFC,QAAM,uBAAuB;AAC7B,QAAMG,OAAO;AAEb,MAAIC,aAAa,MAAMC,cAAc;AAAA,IACnCZ;AAAAA,IACAU,MAAM;AAAA,IACNG,QAAQ;AAAA,MAACC,MAAMhB;AAAAA,MAAUiB,MAAMhB;AAAAA,IAAAA;AAAAA,IAC/BF;AAAAA,IACAO;AAAAA,IACAE;AAAAA,EAAAA,CACD;AAGGH,uBACFQ,aAAa,MAAMK,+BACjB;AAAA,IAACC,SAAS;AAAA,IAASP;AAAAA,EAAAA,GACnBC,YACAR,gBACF,IAGFI,QAAM,sBAAsB;AAC5B,QAAM;AAAA,IAACW;AAAAA,EAAAA,IAAgB,MAAM,OAAO,MAAM,GACpCL,SAAS,MAAMK,aAAaP,UAAU;AAE5CJ,SAAAA,QAAM,6BAA6B,GACnC,MAAMM,OAAOM,UAEN;AAAA,IACLN;AAAAA,IACAO,OAAOA,MAAMP,OAAOO,MAAAA;AAAAA,EAAM;AAE9B;ACtCA,MAAMb,QAAQ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AAE,CAAC,aAC1BuB,MAAM6B,KAAK,GAAGC,KAAKC,KAAKH,eAAe,CAAC,IAAI,CAAC,mBACvC5B,MAAM6B,KAAK1G,GAAG,CAAC,EACrC;AAAA,IACF;AAAA,EACF,SAASoB,KAAK;AACZ1C,UAAM,+BAA+B0C,GAAG,EAAE,GAC1CyF,oBAAoB,OAAOxB,OAAOnH,UAAUmH,OAAOpH,UAAUmD,GAAG;AAAA,EAClE;AACF;AAEO,SAASkE,mBAAmB;AAAA,EACjCjD;AAAAA,EACAG;AAAAA,EACAC;AAAAA,EACAH;AAMF,GAAsC;AACpC,QAAMwE,gBAAgBxE,OAAO6D,QAAQ,iCAAiC,GAChEY,aAAaC,sBAAsB;AAAA,IACvC3E,OAAO;AAAA,MACLnD,MAAMmD,MAAMnD;AAAAA,MACZD,MAAMoD,MAAMpD;AAAAA,IAAAA;AAAAA,IAEduD;AAAAA,IACAC;AAAAA,EAAAA,CACD;AACDqE,gBAAcR,QAAAA;AAEd,QAAM1G,MAAMD,QAAQC,KACdxB,kBAAkBwB,IAAIqH,kCACxBrH,IAAIqH,oCAAoC,SACxCC,CAAAA,CAAQzE,WAAWrE;AAEvB,SAAIwB,IAAIuH,0BAA0B1E,WAAW2E,SAASjJ,YACpDmE,OAAO4B,KACL,oCAAoCzB,UAAU2E,QAAQjJ,QAAQ,2CAA2CyB,IAAIuH,sBAAsB,GACrI,GAGK;AAAA,IACL,GAAGJ;AAAAA,IACHM,YAAYC,KAAK5C,KAAKlC,SAAS,QAAQ;AAAA,IACvCpE;AAAAA,IACAG,eAAekE,aAAa,mBAAmBA,YAAYA,UAAUlE,gBAAgBgJ;AAAAA,EAAAA;AAEzF;;;;;;;;"}
@@ -441,7 +441,7 @@ function useResolvedPanes() {
441
441
  rootPaneNode,
442
442
  routerPanesStream,
443
443
  structureContext
444
- }).pipe(map(_temp5)).subscribe({
444
+ }).pipe(map(_temp5$1)).subscribe({
445
445
  next: (result) => setData(result),
446
446
  error: (e) => setError(e)
447
447
  });
@@ -465,7 +465,7 @@ function useResolvedPanes() {
465
465
  setMaximizedPane
466
466
  }, $[11] = data, $[12] = maximizedPane, $[13] = paneDataItemsWithMaximized, $[14] = t4) : t4 = $[14], t4;
467
467
  }
468
- function _temp5(resolvedPanes) {
468
+ function _temp5$1(resolvedPanes) {
469
469
  const routerPanes = resolvedPanes.reduce(_temp3$1, []), groupsLen = routerPanes.length, paneDataItems = resolvedPanes.map((pane) => {
470
470
  const {
471
471
  groupIndex,
@@ -493,10 +493,10 @@ function _temp5(resolvedPanes) {
493
493
  return {
494
494
  paneDataItems,
495
495
  routerPanes,
496
- resolvedPanes: paneDataItems.map(_temp4)
496
+ resolvedPanes: paneDataItems.map(_temp4$1)
497
497
  };
498
498
  }
499
- function _temp4(pane_0) {
499
+ function _temp4$1(pane_0) {
500
500
  return pane_0.pane;
501
501
  }
502
502
  function _temp3$1(acc, next) {
@@ -758,7 +758,7 @@ const StyledPaneLayout = styled(PaneLayout)`
758
758
  min-height: 100%;
759
759
  min-width: 320px;
760
760
  `, isSaveHotkey = isHotkey("mod+s"), StructureTool = memo(function(t0) {
761
- const $ = c(48), {
761
+ const $ = c(58), {
762
762
  onPaneChange
763
763
  } = t0, {
764
764
  push: pushToast
@@ -827,9 +827,25 @@ const StyledPaneLayout = styled(PaneLayout)`
827
827
  }
828
828
  }, $[13] = navigate, $[14] = routerState?.panes, $[15] = setMaximizedPane, $[16] = t9) : t9 = $[16];
829
829
  const onSetMaximizedPane = t9, previousSelectedIndexRef = useRef(-1);
830
- let t10, t11;
831
- if ($[17] !== maximizedPane || $[18] !== paneDataItems || $[19] !== setMaximizedPane ? (t10 = () => {
832
- const selectedIndex = paneDataItems.findIndex(_temp3), prevSelectedIndex = previousSelectedIndexRef.current;
830
+ let t10;
831
+ $[17] !== navigate || $[18] !== paneDataItems || $[19] !== routerState?.panes || $[20] !== setMaximizedPane ? (t10 = () => {
832
+ const focusedPaneAccordingToParams = paneDataItems.find(_temp3);
833
+ if (!focusedPaneAccordingToParams)
834
+ return;
835
+ focusedPaneAccordingToParams.pane !== LOADING_PANE && focusedPaneAccordingToParams.pane.type === "document" && setMaximizedPane(focusedPaneAccordingToParams);
836
+ const panesWithoutFocus = (routerState?.panes || []).map(_temp5);
837
+ navigate({
838
+ panes: panesWithoutFocus
839
+ }, {
840
+ replace: !0
841
+ });
842
+ }, $[17] = navigate, $[18] = paneDataItems, $[19] = routerState?.panes, $[20] = setMaximizedPane, $[21] = t10) : t10 = $[21];
843
+ const t11 = routerState?.panes;
844
+ let t12;
845
+ $[22] !== navigate || $[23] !== paneDataItems || $[24] !== setMaximizedPane || $[25] !== t11 ? (t12 = [navigate, paneDataItems, t11, setMaximizedPane], $[22] = navigate, $[23] = paneDataItems, $[24] = setMaximizedPane, $[25] = t11, $[26] = t12) : t12 = $[26], useEffect(t10, t12);
846
+ let t13, t14;
847
+ if ($[27] !== maximizedPane || $[28] !== paneDataItems || $[29] !== setMaximizedPane ? (t13 = () => {
848
+ const selectedIndex = paneDataItems.findIndex(_temp6), prevSelectedIndex = previousSelectedIndexRef.current;
833
849
  if (previousSelectedIndexRef.current = selectedIndex, !!maximizedPane) {
834
850
  if (maximizedPane.pane !== LOADING_PANE && maximizedPane.pane.type !== "document") {
835
851
  setMaximizedPane(null);
@@ -840,27 +856,27 @@ const StyledPaneLayout = styled(PaneLayout)`
840
856
  setMaximizedPane(selectedPane);
841
857
  return;
842
858
  }
843
- if (!paneDataItems.some((pane_2) => pane_2.key === maximizedPane.key)) {
844
- const fallbackPane = paneDataItems.find((pane_3) => pane_3.groupIndex === maximizedPane.groupIndex && pane_3.siblingIndex === maximizedPane.siblingIndex && pane_3.pane !== LOADING_PANE && pane_3.pane.type === "document");
859
+ if (!paneDataItems.some((pane_3) => pane_3.key === maximizedPane.key)) {
860
+ const fallbackPane = paneDataItems.find((pane_4) => pane_4.groupIndex === maximizedPane.groupIndex && pane_4.siblingIndex === maximizedPane.siblingIndex && pane_4.pane !== LOADING_PANE && pane_4.pane.type === "document");
845
861
  setMaximizedPane(fallbackPane || null);
846
862
  }
847
863
  }
848
- }, t11 = [maximizedPane, paneDataItems, setMaximizedPane], $[17] = maximizedPane, $[18] = paneDataItems, $[19] = setMaximizedPane, $[20] = t10, $[21] = t11) : (t10 = $[20], t11 = $[21]), useEffect(t10, t11), !hasDefinedDocumentTypes) {
849
- let t122;
850
- return $[22] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t122 = /* @__PURE__ */ jsx(NoDocumentTypesScreen, {}), $[22] = t122) : t122 = $[22], t122;
864
+ }, t14 = [maximizedPane, paneDataItems, setMaximizedPane], $[27] = maximizedPane, $[28] = paneDataItems, $[29] = setMaximizedPane, $[30] = t13, $[31] = t14) : (t13 = $[30], t14 = $[31]), useEffect(t13, t14), !hasDefinedDocumentTypes) {
865
+ let t152;
866
+ return $[32] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t152 = /* @__PURE__ */ jsx(NoDocumentTypesScreen, {}), $[32] = t152) : t152 = $[32], t152;
851
867
  }
852
- const t12 = portalElement || null, t13 = layoutCollapsed ? void 0 : "fill", t14 = media[1];
853
- let t15;
854
- if ($[23] !== onSetMaximizedPane || $[24] !== paneItemsToShow) {
855
- let t162;
856
- $[26] !== onSetMaximizedPane ? (t162 = (paneData_0) => {
868
+ const t15 = portalElement || null, t16 = layoutCollapsed ? void 0 : "fill", t17 = media[1];
869
+ let t18;
870
+ if ($[33] !== onSetMaximizedPane || $[34] !== paneItemsToShow) {
871
+ let t192;
872
+ $[36] !== onSetMaximizedPane ? (t192 = (paneData_0) => {
857
873
  const {
858
874
  active,
859
875
  childItemId,
860
876
  groupIndex,
861
877
  itemId,
862
878
  key: paneKey,
863
- pane: pane_4,
879
+ pane: pane_5,
864
880
  index: paneIndex,
865
881
  params: paneParams,
866
882
  path,
@@ -869,29 +885,29 @@ const StyledPaneLayout = styled(PaneLayout)`
869
885
  selected,
870
886
  maximized
871
887
  } = paneData_0;
872
- return /* @__PURE__ */ jsx(Fragment, { children: pane_4 === LOADING_PANE ? /* @__PURE__ */ jsx(LoadingPane, { paneKey, path, selected }) : /* @__PURE__ */ jsx(StructureToolPane, { active, groupIndex, index: paneIndex, pane: pane_4, childItemId, itemId, paneKey, params: paneParams, payload, path, selected, siblingIndex, maximized, onSetMaximizedPane: () => onSetMaximizedPane(paneData_0) }) }, `${pane_4 === LOADING_PANE ? "loading" : pane_4.type}-${paneIndex}`);
873
- }, $[26] = onSetMaximizedPane, $[27] = t162) : t162 = $[27], t15 = paneItemsToShow.map(t162), $[23] = onSetMaximizedPane, $[24] = paneItemsToShow, $[25] = t15;
888
+ return /* @__PURE__ */ jsx(Fragment, { children: pane_5 === LOADING_PANE ? /* @__PURE__ */ jsx(LoadingPane, { paneKey, path, selected }) : /* @__PURE__ */ jsx(StructureToolPane, { active, groupIndex, index: paneIndex, pane: pane_5, childItemId, itemId, paneKey, params: paneParams, payload, path, selected, siblingIndex, maximized, onSetMaximizedPane: () => onSetMaximizedPane(paneData_0) }) }, `${pane_5 === LOADING_PANE ? "loading" : pane_5.type}-${paneIndex}`);
889
+ }, $[36] = onSetMaximizedPane, $[37] = t192) : t192 = $[37], t18 = paneItemsToShow.map(t192), $[33] = onSetMaximizedPane, $[34] = paneItemsToShow, $[35] = t18;
874
890
  } else
875
- t15 = $[25];
876
- let t16;
877
- $[28] !== isResolvingIntent || $[29] !== paneDataItems.length ? (t16 = paneDataItems.length <= 1 && isResolvingIntent && /* @__PURE__ */ jsx(LoadingPane, { paneKey: "intent-resolver" }), $[28] = isResolvingIntent, $[29] = paneDataItems.length, $[30] = t16) : t16 = $[30];
878
- let t17;
879
- $[31] !== handleRootCollapse || $[32] !== handleRootExpand || $[33] !== media[1] || $[34] !== t13 || $[35] !== t15 || $[36] !== t16 ? (t17 = /* @__PURE__ */ jsxs(StyledPaneLayout, { flex: 1, height: t13, minWidth: t14, onCollapse: handleRootCollapse, onExpand: handleRootExpand, children: [
880
- t15,
881
- t16
882
- ] }), $[31] = handleRootCollapse, $[32] = handleRootExpand, $[33] = media[1], $[34] = t13, $[35] = t15, $[36] = t16, $[37] = t17) : t17 = $[37];
883
- let t18;
884
- $[38] !== resolvedPanes ? (t18 = /* @__PURE__ */ jsx(StructureTitle, { resolvedPanes }), $[38] = resolvedPanes, $[39] = t18) : t18 = $[39];
891
+ t18 = $[35];
885
892
  let t19;
886
- $[40] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t19 = /* @__PURE__ */ jsx("div", { "data-portal": "", ref: setPortalElement }), $[40] = t19) : t19 = $[40];
893
+ $[38] !== isResolvingIntent || $[39] !== paneDataItems.length ? (t19 = paneDataItems.length <= 1 && isResolvingIntent && /* @__PURE__ */ jsx(LoadingPane, { paneKey: "intent-resolver" }), $[38] = isResolvingIntent, $[39] = paneDataItems.length, $[40] = t19) : t19 = $[40];
887
894
  let t20;
888
- $[41] !== t12 || $[42] !== t17 || $[43] !== t18 ? (t20 = /* @__PURE__ */ jsxs(PortalProvider, { element: t12, children: [
889
- t17,
895
+ $[41] !== handleRootCollapse || $[42] !== handleRootExpand || $[43] !== media[1] || $[44] !== t16 || $[45] !== t18 || $[46] !== t19 ? (t20 = /* @__PURE__ */ jsxs(StyledPaneLayout, { flex: 1, height: t16, minWidth: t17, onCollapse: handleRootCollapse, onExpand: handleRootExpand, children: [
890
896
  t18,
891
897
  t19
892
- ] }), $[41] = t12, $[42] = t17, $[43] = t18, $[44] = t20) : t20 = $[44];
898
+ ] }), $[41] = handleRootCollapse, $[42] = handleRootExpand, $[43] = media[1], $[44] = t16, $[45] = t18, $[46] = t19, $[47] = t20) : t20 = $[47];
893
899
  let t21;
894
- return $[45] !== resolvedPanesValue || $[46] !== t20 ? (t21 = /* @__PURE__ */ jsx(ResolvedPanesProvider, { value: resolvedPanesValue, children: t20 }), $[45] = resolvedPanesValue, $[46] = t20, $[47] = t21) : t21 = $[47], t21;
900
+ $[48] !== resolvedPanes ? (t21 = /* @__PURE__ */ jsx(StructureTitle, { resolvedPanes }), $[48] = resolvedPanes, $[49] = t21) : t21 = $[49];
901
+ let t22;
902
+ $[50] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t22 = /* @__PURE__ */ jsx("div", { "data-portal": "", ref: setPortalElement }), $[50] = t22) : t22 = $[50];
903
+ let t23;
904
+ $[51] !== t15 || $[52] !== t20 || $[53] !== t21 ? (t23 = /* @__PURE__ */ jsxs(PortalProvider, { element: t15, children: [
905
+ t20,
906
+ t21,
907
+ t22
908
+ ] }), $[51] = t15, $[52] = t20, $[53] = t21, $[54] = t23) : t23 = $[54];
909
+ let t24;
910
+ return $[55] !== resolvedPanesValue || $[56] !== t23 ? (t24 = /* @__PURE__ */ jsx(ResolvedPanesProvider, { value: resolvedPanesValue, children: t23 }), $[55] = resolvedPanesValue, $[56] = t23, $[57] = t24) : t24 = $[57], t24;
895
911
  });
896
912
  function _temp$1(state) {
897
913
  return typeof state.intent == "string";
@@ -899,8 +915,24 @@ function _temp$1(state) {
899
915
  function _temp2$1(pane) {
900
916
  return pane.maximized;
901
917
  }
902
- function _temp3(pane_1) {
903
- return pane_1.selected;
918
+ function _temp3(p) {
919
+ return p.params?.mode === "focus";
920
+ }
921
+ function _temp4(pane_1) {
922
+ const {
923
+ mode: _omitMode,
924
+ ...rest
925
+ } = pane_1.params || {}, nextParams = Object.keys(rest).length ? rest : void 0;
926
+ return {
927
+ ...pane_1,
928
+ params: nextParams
929
+ };
930
+ }
931
+ function _temp5(group) {
932
+ return group.map(_temp4);
933
+ }
934
+ function _temp6(pane_2) {
935
+ return pane_2.selected;
904
936
  }
905
937
  function StructureToolBoundary(t0) {
906
938
  const $ = c(14), {