@sanity/cli-core 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SanityCommand.d.ts +12 -0
- package/dist/_exports/config.d.ts +12 -0
- package/dist/_exports/index.d.ts +34 -7
- package/dist/_exports/index.js +1 -0
- package/dist/_exports/index.js.map +1 -1
- package/dist/_exports/package-manager.d.ts +1 -2
- package/dist/_exports/schemas.d.ts +8 -0
- package/dist/_exports/tasks.d.ts +6 -6
- package/dist/_exports/types.d.ts +13 -0
- package/dist/_exports/undeploy.d.ts +1 -2
- package/dist/_exports/ux.d.ts +1 -2
- package/dist/config/cli/schemas.js +3 -1
- package/dist/config/cli/schemas.js.map +1 -1
- package/dist/config/cli/types/cliConfig.js +7 -5
- package/dist/config/cli/types/cliConfig.js.map +1 -1
- package/dist/loaders/studio/studioWorkerLifecycle.js +85 -0
- package/dist/loaders/studio/studioWorkerLifecycle.js.map +1 -0
- package/dist/loaders/studio/studioWorkerLoader.worker.js +86 -54
- package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -1
- package/dist/loaders/studio/studioWorkerTask.js +17 -1
- package/dist/loaders/studio/studioWorkerTask.js.map +1 -1
- package/dist/manifest.js +1 -0
- package/dist/manifest.js.map +1 -1
- package/dist/util/promisifyWorker.js +21 -6
- package/dist/util/promisifyWorker.js.map +1 -1
- package/package.json +13 -13
package/dist/SanityCommand.d.ts
CHANGED
|
@@ -7,6 +7,16 @@ import { Interfaces } from "@oclif/core";
|
|
|
7
7
|
import { PluginOptions } from "babel-plugin-react-compiler";
|
|
8
8
|
import { SanityClient } from "sanity";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Dashboard visibility an application can declare. Mirrors Brett's canonical
|
|
12
|
+
* `VISIBILITIES` — the source of truth lives in the application service.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
declare const APP_VISIBILITIES: readonly ["default", "unlisted", "disabled"];
|
|
16
|
+
|
|
17
|
+
/** @public */
|
|
18
|
+
declare type AppVisibility = (typeof APP_VISIBILITIES)[number];
|
|
19
|
+
|
|
10
20
|
declare type Args<T extends typeof Command> = Interfaces.InferredArgs<
|
|
11
21
|
T["args"]
|
|
12
22
|
>;
|
|
@@ -39,6 +49,8 @@ declare interface CliConfig {
|
|
|
39
49
|
priority?: number;
|
|
40
50
|
/** The title of the custom app, as it is seen in Dashboard UI */
|
|
41
51
|
title?: string;
|
|
52
|
+
/** Dashboard visibility of the application. Defaults to `default`. */
|
|
53
|
+
visibility?: AppVisibility;
|
|
42
54
|
};
|
|
43
55
|
/** @deprecated Use deployment.autoUpdates */
|
|
44
56
|
autoUpdates?: boolean;
|
|
@@ -4,6 +4,16 @@ import { PluginOptions } from "babel-plugin-react-compiler";
|
|
|
4
4
|
import { Workspace } from "sanity";
|
|
5
5
|
import { z } from "zod/mini";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Dashboard visibility an application can declare. Mirrors Brett's canonical
|
|
9
|
+
* `VISIBILITIES` — the source of truth lives in the application service.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
declare const APP_VISIBILITIES: readonly ["default", "unlisted", "disabled"];
|
|
13
|
+
|
|
14
|
+
/** @public */
|
|
15
|
+
declare type AppVisibility = (typeof APP_VISIBILITIES)[number];
|
|
16
|
+
|
|
7
17
|
/**
|
|
8
18
|
* Clear the in-process token cache so the next `getCliToken()` call
|
|
9
19
|
* re-reads from disk or the environment.
|
|
@@ -42,6 +52,8 @@ export declare interface CliConfig {
|
|
|
42
52
|
priority?: number;
|
|
43
53
|
/** The title of the custom app, as it is seen in Dashboard UI */
|
|
44
54
|
title?: string;
|
|
55
|
+
/** Dashboard visibility of the application. Defaults to `default`. */
|
|
56
|
+
visibility?: AppVisibility;
|
|
45
57
|
};
|
|
46
58
|
/** @deprecated Use deployment.autoUpdates */
|
|
47
59
|
autoUpdates?: boolean;
|
package/dist/_exports/index.d.ts
CHANGED
|
@@ -11,10 +11,21 @@ import { SanityClient } from "@sanity/client";
|
|
|
11
11
|
import { SanityClient as SanityClient_2 } from "sanity";
|
|
12
12
|
import { URL as URL_2 } from "node:url";
|
|
13
13
|
import { Worker as Worker_2 } from "node:worker_threads";
|
|
14
|
-
import { WorkerOptions
|
|
14
|
+
import { WorkerOptions } from "node:worker_threads";
|
|
15
15
|
import { Workspace } from "sanity";
|
|
16
16
|
import { z } from "zod/mini";
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Dashboard visibility an application can declare. Mirrors Brett's canonical
|
|
20
|
+
* `VISIBILITIES` — the source of truth lives in the application service.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const APP_VISIBILITIES: readonly [
|
|
24
|
+
"default",
|
|
25
|
+
"unlisted",
|
|
26
|
+
"disabled",
|
|
27
|
+
];
|
|
28
|
+
|
|
18
29
|
declare const APPLICATION_TYPES: readonly [
|
|
19
30
|
"coreApp",
|
|
20
31
|
"studio",
|
|
@@ -26,6 +37,9 @@ declare const APPLICATION_TYPES: readonly [
|
|
|
26
37
|
/** The resolved kind of a workbench app — `studio` or one of the SDK app types. */
|
|
27
38
|
export declare type ApplicationType = (typeof APPLICATION_TYPES)[number];
|
|
28
39
|
|
|
40
|
+
/** @public */
|
|
41
|
+
export declare type AppVisibility = (typeof APP_VISIBILITIES)[number];
|
|
42
|
+
|
|
29
43
|
declare type Args<T extends typeof Command> = Interfaces.InferredArgs<
|
|
30
44
|
T["args"]
|
|
31
45
|
>;
|
|
@@ -81,6 +95,8 @@ export declare interface CliConfig {
|
|
|
81
95
|
priority?: number;
|
|
82
96
|
/** The title of the custom app, as it is seen in Dashboard UI */
|
|
83
97
|
title?: string;
|
|
98
|
+
/** Dashboard visibility of the application. Defaults to `default`. */
|
|
99
|
+
visibility?: AppVisibility;
|
|
84
100
|
};
|
|
85
101
|
/** @deprecated Use deployment.autoUpdates */
|
|
86
102
|
autoUpdates?: boolean;
|
|
@@ -251,6 +267,7 @@ export declare const coreAppManifestSchema: z.ZodMiniObject<
|
|
|
251
267
|
group: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
252
268
|
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
253
269
|
priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
270
|
+
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
254
271
|
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
255
272
|
version: z.ZodMiniString<string>;
|
|
256
273
|
},
|
|
@@ -992,7 +1009,8 @@ export declare interface ProjectRootResult {
|
|
|
992
1009
|
* Creates a Node.js Worker from the given file path and options, and wraps it
|
|
993
1010
|
* in a Promise that resolves with the first message the worker sends, and
|
|
994
1011
|
* rejects on error, message deserialization failure, or non-zero exit code.
|
|
995
|
-
*
|
|
1012
|
+
* By default, the worker is terminated after a message or error is received.
|
|
1013
|
+
* Callers can instead unref it and allow natural process teardown.
|
|
996
1014
|
*
|
|
997
1015
|
* @param filePath - URL to the worker file
|
|
998
1016
|
* @param options - Options to pass to the Worker constructor
|
|
@@ -1005,8 +1023,17 @@ export declare function promisifyWorker<T = unknown>(
|
|
|
1005
1023
|
options?: PromisifyWorkerOptions,
|
|
1006
1024
|
): Promise<T>;
|
|
1007
1025
|
|
|
1008
|
-
declare interface PromisifyWorkerOptions extends
|
|
1009
|
-
/**
|
|
1026
|
+
declare interface PromisifyWorkerOptions extends WorkerOptions {
|
|
1027
|
+
/**
|
|
1028
|
+
* Whether to forcibly terminate the worker after settling. Disable this for
|
|
1029
|
+
* workers that host native addons (e.g. rolldown via Vite 8) whose threads
|
|
1030
|
+
* must tear down with the process: terminating such a worker while native
|
|
1031
|
+
* threads are live can abort the whole process with a silent SIGABRT. A
|
|
1032
|
+
* disabled worker is unrefed and may continue running until the process
|
|
1033
|
+
* exits, including after a timeout.
|
|
1034
|
+
*/
|
|
1035
|
+
terminateOnSettle?: boolean;
|
|
1036
|
+
/** Optional timeout in milliseconds. If the worker does not respond within this time, the promise is rejected. */
|
|
1010
1037
|
timeout?: number;
|
|
1011
1038
|
}
|
|
1012
1039
|
|
|
@@ -1492,11 +1519,11 @@ export declare function studioWorkerTask<T = unknown>(
|
|
|
1492
1519
|
* @internal
|
|
1493
1520
|
*/
|
|
1494
1521
|
declare interface StudioWorkerTaskOptions extends RequireProps<
|
|
1495
|
-
|
|
1522
|
+
WorkerOptions,
|
|
1496
1523
|
"name"
|
|
1497
1524
|
> {
|
|
1498
1525
|
studioRootPath: string;
|
|
1499
|
-
/** Optional timeout in milliseconds. If the worker does not respond within this time,
|
|
1526
|
+
/** Optional timeout in milliseconds. If the worker does not respond within this time, the promise is rejected. */
|
|
1500
1527
|
timeout?: number;
|
|
1501
1528
|
}
|
|
1502
1529
|
|
|
@@ -1607,7 +1634,7 @@ export declare function tsxWorkerTask<T = unknown>(
|
|
|
1607
1634
|
* @internal
|
|
1608
1635
|
*/
|
|
1609
1636
|
declare interface TsxWorkerTaskOptions extends RequireProps<
|
|
1610
|
-
|
|
1637
|
+
WorkerOptions,
|
|
1611
1638
|
"name"
|
|
1612
1639
|
> {
|
|
1613
1640
|
rootPath: string;
|
package/dist/_exports/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { getGlobalCliClient, getProjectCliClient } from '../apiClient.js';
|
|
|
6
6
|
export { clearCliTokenCache, getCliToken, getCliUserConfig, getUserConfig, setCliUserConfig } from '../config/cli/cliUserConfig.js';
|
|
7
7
|
export { getCliConfig, getCliConfigUncached } from '../config/cli/getCliConfig.js';
|
|
8
8
|
export { getCliConfigSync } from '../config/cli/getCliConfigSync.js';
|
|
9
|
+
export { APP_VISIBILITIES } from '../config/cli/types/cliConfig.js';
|
|
9
10
|
export { isWorkbenchApp } from '../config/cli/workbenchApp.js';
|
|
10
11
|
export { findProjectRoot } from '../config/findProjectRoot.js';
|
|
11
12
|
export { findProjectRootSync } from '../config/findProjectRootSync.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/index.ts"],"sourcesContent":["// DO NOT ADD NEW EXPORTS TO THIS FILE!\n// These are left here for backwards compatibility.\n// If you came here looking to add new exports, instead take a look through the `exports` in package.json and think about which of those groups your new export belongs to. You may want to consider adding a _new_ export if there is no clean conceptual fit.\n// This is all in the name of minimizing 'barrel' export files and keeping `import`s fast. See the following for context: https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7/\nexport {\n getGlobalCliClient,\n getProjectCliClient,\n type GlobalCliClientOptions,\n type ProjectCliClientOptions,\n} from '../apiClient.js'\nexport {\n clearCliTokenCache,\n getCliToken,\n getCliUserConfig,\n getUserConfig,\n setCliUserConfig,\n} from '../config/cli/cliUserConfig.js'\nexport {getCliConfig, getCliConfigUncached} from '../config/cli/getCliConfig.js'\nexport {getCliConfigSync} from '../config/cli/getCliConfigSync.js'\nexport {type CliConfig
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/index.ts"],"sourcesContent":["// DO NOT ADD NEW EXPORTS TO THIS FILE!\n// These are left here for backwards compatibility.\n// If you came here looking to add new exports, instead take a look through the `exports` in package.json and think about which of those groups your new export belongs to. You may want to consider adding a _new_ export if there is no clean conceptual fit.\n// This is all in the name of minimizing 'barrel' export files and keeping `import`s fast. See the following for context: https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7/\nexport {\n getGlobalCliClient,\n getProjectCliClient,\n type GlobalCliClientOptions,\n type ProjectCliClientOptions,\n} from '../apiClient.js'\nexport {\n clearCliTokenCache,\n getCliToken,\n getCliUserConfig,\n getUserConfig,\n setCliUserConfig,\n} from '../config/cli/cliUserConfig.js'\nexport {getCliConfig, getCliConfigUncached} from '../config/cli/getCliConfig.js'\nexport {getCliConfigSync} from '../config/cli/getCliConfigSync.js'\nexport {\n APP_VISIBILITIES,\n type AppVisibility,\n type CliConfig,\n type ConfigStore,\n} from '../config/cli/types/cliConfig.js'\nexport {type UserViteConfig} from '../config/cli/types/userViteConfig.js'\nexport {type ApplicationType, isWorkbenchApp} from '../config/cli/workbenchApp.js'\nexport {findProjectRoot} from '../config/findProjectRoot.js'\nexport {findProjectRootSync} from '../config/findProjectRootSync.js'\nexport {getStudioConfig} from '../config/studio/getStudioConfig.js'\nexport {getStudioWorkspaces} from '../config/studio/getStudioWorkspaces.js'\nexport {isStudioConfig} from '../config/studio/isStudioConfig.js'\nexport {findPathForFiles} from '../config/util/findConfigsPaths.js'\nexport {findStudioConfigPath, tryFindStudioConfigPath} from '../config/util/findStudioConfigPath.js'\nexport {type ProjectRootResult} from '../config/util/recursivelyResolveProjectRoot.js'\nexport {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport {isNotFoundError, NotFoundError} from '../errors/NotFoundError.js'\nexport {\n isProjectRootNotFoundError,\n ProjectRootNotFoundError,\n} from '../errors/ProjectRootNotFoundError.js'\nexport {exitCodes} from '../exitCodes.js'\nexport {createStudioWorker, studioWorkerTask} from '../loaders/studio/studioWorkerTask.js'\nexport {tsxWorkerTask} from '../loaders/tsx/tsxWorkerTask.js'\nexport {SanityCommand, type SanityCommandInterface} from '../SanityCommand.js'\nexport {\n clearCliTelemetry,\n CLI_TELEMETRY_SYMBOL,\n getCliTelemetry,\n reportCliTraceError,\n setCliTelemetry,\n} from '../telemetry/getCliTelemetry.js'\nexport {getTelemetryBaseInfo} from '../telemetry/getTelemetryBaseInfo.js'\nexport {noopLogger} from '../telemetry/noopTelemetry.js'\nexport {\n type CLITelemetryStore,\n type ConsentInformation,\n type TelemetryUserProperties,\n} from '../telemetry/types.js'\nexport {type Output, type RequireProps, type SanityOrgUser} from '../types.js'\nexport {doImport} from '../util/doImport.js'\nexport {mockBrowserEnvironment} from '../util/environment/mockBrowserEnvironment.js'\nexport {getLocalPackageDir, getLocalPackageVersion} from '../util/getLocalPackageVersion.js'\nexport {getSanityConfigDir, getSanityDataDir} from '../util/getSanityConfigDir.js'\nexport {getSanityEnvVar} from '../util/getSanityEnvVar.js'\nexport {getSanityUrl} from '../util/getSanityUrl.js'\nexport {getWorkspace} from '../util/getWorkspace.js'\nexport {importModule} from '../util/importModule.js'\nexport {isCi} from '../util/isCi.js'\nexport {isInteractive} from '../util/isInteractive.js'\nexport {isStaging} from '../util/isStaging.js'\nexport {normalizePath} from '../util/normalizePath.js'\nexport {promisifyWorker} from '../util/promisifyWorker.js'\nexport {\n type PackageJson,\n readPackageJson,\n type ReadPackageJsonOptions,\n} from '../util/readPackageJson.js'\nexport {\n resolveLocalPackage,\n resolveLocalPackageFrom,\n resolveLocalPackagePath,\n} from '../util/resolveLocalPackage.js'\nexport {safeStructuredClone} from '../util/safeStructuredClone.js'\nexport {colorizeJson} from '../ux/colorizeJson.js'\nexport {getTimer} from '../ux/timer.js'\nexport {debug, subdebug} from './debug.js'\nexport {\n type CoreAppManifest,\n coreAppManifestSchema,\n type StudioManifest,\n studioManifestSchema,\n} from './schemas.js'\n"],"names":["getGlobalCliClient","getProjectCliClient","clearCliTokenCache","getCliToken","getCliUserConfig","getUserConfig","setCliUserConfig","getCliConfig","getCliConfigUncached","getCliConfigSync","APP_VISIBILITIES","isWorkbenchApp","findProjectRoot","findProjectRootSync","getStudioConfig","getStudioWorkspaces","isStudioConfig","findPathForFiles","findStudioConfigPath","tryFindStudioConfigPath","NonInteractiveError","isNotFoundError","NotFoundError","isProjectRootNotFoundError","ProjectRootNotFoundError","exitCodes","createStudioWorker","studioWorkerTask","tsxWorkerTask","SanityCommand","clearCliTelemetry","CLI_TELEMETRY_SYMBOL","getCliTelemetry","reportCliTraceError","setCliTelemetry","getTelemetryBaseInfo","noopLogger","doImport","mockBrowserEnvironment","getLocalPackageDir","getLocalPackageVersion","getSanityConfigDir","getSanityDataDir","getSanityEnvVar","getSanityUrl","getWorkspace","importModule","isCi","isInteractive","isStaging","normalizePath","promisifyWorker","readPackageJson","resolveLocalPackage","resolveLocalPackageFrom","resolveLocalPackagePath","safeStructuredClone","colorizeJson","getTimer","debug","subdebug","coreAppManifestSchema","studioManifestSchema"],"mappings":"AAAA,uCAAuC;AACvC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;AAClF,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,YAAY,QAAO,0BAAyB;AACpD,SAAQC,IAAI,QAAO,kBAAiB;AACpC,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,SAAS,QAAO,uBAAsB;AAC9C,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAEEC,eAAe,QAEV,6BAA4B;AACnC,SACEC,mBAAmB,EACnBC,uBAAuB,EACvBC,uBAAuB,QAClB,iCAAgC;AACvC,SAAQC,mBAAmB,QAAO,iCAAgC;AAClE,SAAQC,YAAY,QAAO,wBAAuB;AAClD,SAAQC,QAAQ,QAAO,iBAAgB;AACvC,SAAQC,KAAK,EAAEC,QAAQ,QAAO,aAAY;AAC1C,SAEEC,qBAAqB,EAErBC,oBAAoB,QACf,eAAc"}
|
|
@@ -49,8 +49,7 @@ export declare function getLocalPackageVersion(
|
|
|
49
49
|
* the detected package manager.
|
|
50
50
|
*/
|
|
51
51
|
export declare function getRunningPackageManager():
|
|
52
|
-
|
|
|
53
|
-
| undefined;
|
|
52
|
+
DetectedPackageManager | undefined;
|
|
54
53
|
|
|
55
54
|
/**
|
|
56
55
|
* Extract the yarn major version from a `npm_config_user_agent` string.
|
|
@@ -27,6 +27,13 @@ export declare const cliConfigSchema: z.ZodMiniObject<
|
|
|
27
27
|
id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
28
28
|
organizationId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
29
29
|
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
30
|
+
visibility: z.ZodMiniOptional<
|
|
31
|
+
z.ZodMiniEnum<{
|
|
32
|
+
default: "default";
|
|
33
|
+
unlisted: "unlisted";
|
|
34
|
+
disabled: "disabled";
|
|
35
|
+
}>
|
|
36
|
+
>;
|
|
30
37
|
},
|
|
31
38
|
z.core.$strip
|
|
32
39
|
>
|
|
@@ -187,6 +194,7 @@ export declare const coreAppManifestSchema: z.ZodMiniObject<
|
|
|
187
194
|
group: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
188
195
|
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
189
196
|
priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
197
|
+
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
190
198
|
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
191
199
|
version: z.ZodMiniString<string>;
|
|
192
200
|
},
|
package/dist/_exports/tasks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { URL as URL_2 } from "node:url";
|
|
2
|
-
import { Worker
|
|
3
|
-
import { WorkerOptions
|
|
2
|
+
import { Worker } from "node:worker_threads";
|
|
3
|
+
import { WorkerOptions } from "node:worker_threads";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Creates a new worker for a studio worker task.
|
|
@@ -33,7 +33,7 @@ import { WorkerOptions as WorkerOptions_2 } from "node:worker_threads";
|
|
|
33
33
|
export declare function createStudioWorker(
|
|
34
34
|
filePath: URL,
|
|
35
35
|
options: StudioWorkerTaskOptions,
|
|
36
|
-
):
|
|
36
|
+
): Worker;
|
|
37
37
|
|
|
38
38
|
declare type RequireProps<T, K extends keyof T> = Omit<T, K> &
|
|
39
39
|
Required<Pick<T, K>>;
|
|
@@ -77,11 +77,11 @@ export declare function studioWorkerTask<T = unknown>(
|
|
|
77
77
|
* @internal
|
|
78
78
|
*/
|
|
79
79
|
declare interface StudioWorkerTaskOptions extends RequireProps<
|
|
80
|
-
|
|
80
|
+
WorkerOptions,
|
|
81
81
|
"name"
|
|
82
82
|
> {
|
|
83
83
|
studioRootPath: string;
|
|
84
|
-
/** Optional timeout in milliseconds. If the worker does not respond within this time,
|
|
84
|
+
/** Optional timeout in milliseconds. If the worker does not respond within this time, the promise is rejected. */
|
|
85
85
|
timeout?: number;
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -111,7 +111,7 @@ export declare function tsxWorkerTask<T = unknown>(
|
|
|
111
111
|
* @internal
|
|
112
112
|
*/
|
|
113
113
|
declare interface TsxWorkerTaskOptions extends RequireProps<
|
|
114
|
-
|
|
114
|
+
WorkerOptions,
|
|
115
115
|
"name"
|
|
116
116
|
> {
|
|
117
117
|
rootPath: string;
|
package/dist/_exports/types.d.ts
CHANGED
|
@@ -4,6 +4,13 @@ import { InlineConfig } from "vite";
|
|
|
4
4
|
import { PluginOptions } from "babel-plugin-react-compiler";
|
|
5
5
|
import { z } from "zod/mini";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Dashboard visibility an application can declare. Mirrors Brett's canonical
|
|
9
|
+
* `VISIBILITIES` — the source of truth lives in the application service.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
declare const APP_VISIBILITIES: readonly ["default", "unlisted", "disabled"];
|
|
13
|
+
|
|
7
14
|
declare const APPLICATION_TYPES: readonly [
|
|
8
15
|
"coreApp",
|
|
9
16
|
"studio",
|
|
@@ -15,6 +22,9 @@ declare const APPLICATION_TYPES: readonly [
|
|
|
15
22
|
/** The resolved kind of a workbench app — `studio` or one of the SDK app types. */
|
|
16
23
|
export declare type ApplicationType = (typeof APPLICATION_TYPES)[number];
|
|
17
24
|
|
|
25
|
+
/** @public */
|
|
26
|
+
declare type AppVisibility = (typeof APP_VISIBILITIES)[number];
|
|
27
|
+
|
|
18
28
|
/**
|
|
19
29
|
* @public
|
|
20
30
|
*/
|
|
@@ -43,6 +53,8 @@ export declare interface CliConfig {
|
|
|
43
53
|
priority?: number;
|
|
44
54
|
/** The title of the custom app, as it is seen in Dashboard UI */
|
|
45
55
|
title?: string;
|
|
56
|
+
/** Dashboard visibility of the application. Defaults to `default`. */
|
|
57
|
+
visibility?: AppVisibility;
|
|
46
58
|
};
|
|
47
59
|
/** @deprecated Use deployment.autoUpdates */
|
|
48
60
|
autoUpdates?: boolean;
|
|
@@ -211,6 +223,7 @@ declare const coreAppManifestSchema: z.ZodMiniObject<
|
|
|
211
223
|
group: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
212
224
|
icon: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
213
225
|
priority: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
226
|
+
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
214
227
|
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
215
228
|
version: z.ZodMiniString<string>;
|
|
216
229
|
},
|
|
@@ -33,8 +33,7 @@ export declare interface UndeployConfigTarget extends UndeployTargetDetails {
|
|
|
33
33
|
* except the report-only `summary`.
|
|
34
34
|
*/
|
|
35
35
|
export declare type UndeployTarget =
|
|
36
|
-
|
|
|
37
|
-
| UndeployConfigTarget;
|
|
36
|
+
UndeployApplicationTarget | UndeployConfigTarget;
|
|
38
37
|
|
|
39
38
|
declare interface UndeployTargetDetails {
|
|
40
39
|
/** Details of the deployment currently being served; `null` when none is live. */
|
package/dist/_exports/ux.d.ts
CHANGED
|
@@ -24,8 +24,7 @@ export declare const checkbox: typeof inquirer.checkbox;
|
|
|
24
24
|
|
|
25
25
|
export declare function colorizeJson(input: unknown): string;
|
|
26
26
|
|
|
27
|
-
declare const
|
|
28
|
-
export { confirm_2 as confirm };
|
|
27
|
+
export declare const confirm: typeof inquirer.confirm;
|
|
29
28
|
|
|
30
29
|
export { CustomBorderStyle };
|
|
31
30
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod/mini';
|
|
2
|
+
import { APP_VISIBILITIES } from './types/cliConfig.js';
|
|
2
3
|
/**
|
|
3
4
|
* @public
|
|
4
5
|
*/ export const cliConfigSchema = z.object({
|
|
@@ -11,7 +12,8 @@ import { z } from 'zod/mini';
|
|
|
11
12
|
icon: z.optional(z.string()),
|
|
12
13
|
id: z.optional(z.string()),
|
|
13
14
|
organizationId: z.optional(z.string()),
|
|
14
|
-
title: z.optional(z.string())
|
|
15
|
+
title: z.optional(z.string()),
|
|
16
|
+
visibility: z.optional(z.enum(APP_VISIBILITIES))
|
|
15
17
|
})),
|
|
16
18
|
autoUpdates: z.optional(z.boolean()),
|
|
17
19
|
deployment: z.optional(z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/cli/schemas.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {z} from 'zod/mini'\n\nimport {type CliConfig, type TypeGenConfig} from './types/cliConfig'\nimport {type UserViteConfig} from './types/userViteConfig'\n\n/**\n * @public\n */\nexport const cliConfigSchema = z.object({\n api: z.optional(\n z.object({\n dataset: z.optional(z.string()),\n projectId: z.optional(z.string()),\n }),\n ),\n\n app: z.optional(\n z.object({\n entry: z.optional(z.string()),\n icon: z.optional(z.string()),\n id: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n title: z.optional(z.string()),\n }),\n ),\n\n autoUpdates: z.optional(z.boolean()),\n\n deployment: z.optional(\n z.object({\n appId: z.optional(z.string()),\n autoUpdates: z.optional(z.boolean()),\n }),\n ),\n\n graphql: z.optional(\n z.array(\n z.object({\n filterSuffix: z.optional(z.string()),\n generation: z.optional(z.enum(['gen1', 'gen2', 'gen3'])),\n id: z.optional(z.string()),\n nonNullDocumentFields: z.optional(z.boolean()),\n playground: z.optional(z.boolean()),\n source: z.optional(z.string()),\n tag: z.optional(z.string()),\n workspace: z.optional(z.string()),\n }),\n ),\n ),\n\n mediaLibrary: z.optional(\n z.object({\n aspectsPath: z.optional(z.string()),\n }),\n ),\n\n project: z.optional(\n z.object({\n basePath: z.optional(z.string()),\n }),\n ),\n\n reactCompiler: z.optional(z.custom<ReactCompilerConfig>()),\n\n reactStrictMode: z.optional(z.boolean()),\n\n schemaExtraction: z.optional(\n z.object({\n enabled: z.optional(z.boolean()),\n enforceRequiredFields: z.optional(z.boolean()),\n path: z.optional(z.string()),\n watchPatterns: z.optional(z.array(z.string())),\n workspace: z.optional(z.string()),\n }),\n ),\n\n server: z.optional(\n z.object({\n hostname: z.optional(z.string()),\n port: z.optional(z.number()),\n }),\n ),\n\n studioHost: z.optional(z.string()),\n\n unstable_bundledDev: z.optional(z.boolean()),\n\n vite: z.optional(z.custom<UserViteConfig>()),\n\n typegen: z.optional(z.custom<Partial<TypeGenConfig> & {enabled?: boolean}>()),\n}) satisfies z.core.$ZodType<CliConfig>\n"],"names":["z","cliConfigSchema","object","api","optional","dataset","string","projectId","app","entry","icon","id","organizationId","title","autoUpdates","boolean","deployment","appId","graphql","array","filterSuffix","generation","
|
|
1
|
+
{"version":3,"sources":["../../../src/config/cli/schemas.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {z} from 'zod/mini'\n\nimport {APP_VISIBILITIES, type CliConfig, type TypeGenConfig} from './types/cliConfig.js'\nimport {type UserViteConfig} from './types/userViteConfig'\n\n/**\n * @public\n */\nexport const cliConfigSchema = z.object({\n api: z.optional(\n z.object({\n dataset: z.optional(z.string()),\n projectId: z.optional(z.string()),\n }),\n ),\n\n app: z.optional(\n z.object({\n entry: z.optional(z.string()),\n icon: z.optional(z.string()),\n id: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n title: z.optional(z.string()),\n visibility: z.optional(z.enum(APP_VISIBILITIES)),\n }),\n ),\n\n autoUpdates: z.optional(z.boolean()),\n\n deployment: z.optional(\n z.object({\n appId: z.optional(z.string()),\n autoUpdates: z.optional(z.boolean()),\n }),\n ),\n\n graphql: z.optional(\n z.array(\n z.object({\n filterSuffix: z.optional(z.string()),\n generation: z.optional(z.enum(['gen1', 'gen2', 'gen3'])),\n id: z.optional(z.string()),\n nonNullDocumentFields: z.optional(z.boolean()),\n playground: z.optional(z.boolean()),\n source: z.optional(z.string()),\n tag: z.optional(z.string()),\n workspace: z.optional(z.string()),\n }),\n ),\n ),\n\n mediaLibrary: z.optional(\n z.object({\n aspectsPath: z.optional(z.string()),\n }),\n ),\n\n project: z.optional(\n z.object({\n basePath: z.optional(z.string()),\n }),\n ),\n\n reactCompiler: z.optional(z.custom<ReactCompilerConfig>()),\n\n reactStrictMode: z.optional(z.boolean()),\n\n schemaExtraction: z.optional(\n z.object({\n enabled: z.optional(z.boolean()),\n enforceRequiredFields: z.optional(z.boolean()),\n path: z.optional(z.string()),\n watchPatterns: z.optional(z.array(z.string())),\n workspace: z.optional(z.string()),\n }),\n ),\n\n server: z.optional(\n z.object({\n hostname: z.optional(z.string()),\n port: z.optional(z.number()),\n }),\n ),\n\n studioHost: z.optional(z.string()),\n\n unstable_bundledDev: z.optional(z.boolean()),\n\n vite: z.optional(z.custom<UserViteConfig>()),\n\n typegen: z.optional(z.custom<Partial<TypeGenConfig> & {enabled?: boolean}>()),\n}) satisfies z.core.$ZodType<CliConfig>\n"],"names":["z","APP_VISIBILITIES","cliConfigSchema","object","api","optional","dataset","string","projectId","app","entry","icon","id","organizationId","title","visibility","enum","autoUpdates","boolean","deployment","appId","graphql","array","filterSuffix","generation","nonNullDocumentFields","playground","source","tag","workspace","mediaLibrary","aspectsPath","project","basePath","reactCompiler","custom","reactStrictMode","schemaExtraction","enabled","enforceRequiredFields","path","watchPatterns","server","hostname","port","number","studioHost","unstable_bundledDev","vite","typegen"],"mappings":"AACA,SAAQA,CAAC,QAAO,WAAU;AAE1B,SAAQC,gBAAgB,QAA2C,uBAAsB;AAGzF;;CAEC,GACD,OAAO,MAAMC,kBAAkBF,EAAEG,MAAM,CAAC;IACtCC,KAAKJ,EAAEK,QAAQ,CACbL,EAAEG,MAAM,CAAC;QACPG,SAASN,EAAEK,QAAQ,CAACL,EAAEO,MAAM;QAC5BC,WAAWR,EAAEK,QAAQ,CAACL,EAAEO,MAAM;IAChC;IAGFE,KAAKT,EAAEK,QAAQ,CACbL,EAAEG,MAAM,CAAC;QACPO,OAAOV,EAAEK,QAAQ,CAACL,EAAEO,MAAM;QAC1BI,M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C,EAAEK,QAAQ,CAACL,EAAEmC,MAAM;IAElCC,iBAAiBpC,EAAEK,QAAQ,CAACL,EAAEkB,OAAO;IAErCmB,kBAAkBrC,EAAEK,QAAQ,CAC1BL,EAAEG,MAAM,CAAC;QACPmC,SAAStC,EAAEK,QAAQ,CAACL,EAAEkB,OAAO;QAC7BqB,uBAAuBvC,EAAEK,QAAQ,CAACL,EAAEkB,OAAO;QAC3CsB,MAAMxC,EAAEK,QAAQ,CAACL,EAAEO,MAAM;QACzBkC,eAAezC,EAAEK,QAAQ,CAACL,EAAEsB,KAAK,CAACtB,EAAEO,MAAM;QAC1CsB,WAAW7B,EAAEK,QAAQ,CAACL,EAAEO,MAAM;IAChC;IAGFmC,QAAQ1C,EAAEK,QAAQ,CAChBL,EAAEG,MAAM,CAAC;QACPwC,UAAU3C,EAAEK,QAAQ,CAACL,EAAEO,MAAM;QAC7BqC,MAAM5C,EAAEK,QAAQ,CAACL,EAAE6C,MAAM;IAC3B;IAGFC,YAAY9C,EAAEK,QAAQ,CAACL,EAAEO,MAAM;IAE/BwC,qBAAqB/C,EAAEK,QAAQ,CAACL,EAAEkB,OAAO;IAEzC8B,MAAMhD,EAAEK,QAAQ,CAACL,EAAEmC,MAAM;IAEzBc,SAASjD,EAAEK,QAAQ,CAACL,EAAEmC,MAAM;AAC9B,GAAuC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* arbitrary keys without schema validation.
|
|
5
|
-
*
|
|
2
|
+
* Dashboard visibility an application can declare. Mirrors Brett's canonical
|
|
3
|
+
* `VISIBILITIES` — the source of truth lives in the application service.
|
|
6
4
|
* @public
|
|
7
|
-
*/ export
|
|
5
|
+
*/ export const APP_VISIBILITIES = [
|
|
6
|
+
'default',
|
|
7
|
+
'unlisted',
|
|
8
|
+
'disabled'
|
|
9
|
+
];
|
|
8
10
|
|
|
9
11
|
//# sourceMappingURL=cliConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /** Dock group the app renders in. Defaults to `dock.applications`. */\n group?: 'dock.applications' | 'dock.system' | 'dock.user'\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** Sort position within the dock group, ascending. Defaults to `100`. */\n priority?: number\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /** Configuration options for React Compiler */\n reactCompiler?: boolean | ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /**\n * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled\n * files during development, which can speed up startup and reloads for large projects.\n * Defaults to `false`.\n *\n * Unstable: may change or be removed without notice while the underlying Vite\n * feature (`experimental.bundledDev`) is experimental.\n * {@link https://vite.dev/guide/rolldown#full-bundle-mode}\n */\n unstable_bundledDev?: boolean\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n\n/**\n * A raw key-value store for CLI user configuration.\n * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on\n * arbitrary keys without schema validation.\n *\n * @public\n */\nexport interface ConfigStore {\n /** Remove a key from the config file. */\n delete: (key: string) => void\n /** Read a value by key. Returns `undefined` if the key does not exist. */\n get: (key: string) => unknown\n /** Write a value by key, merging it into the existing config. */\n set: (key: string, value: unknown) => void\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * Dashboard visibility an application can declare. Mirrors Brett's canonical\n * `VISIBILITIES` — the source of truth lives in the application service.\n * @public\n */\nexport const APP_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const\n/** @public */\nexport type AppVisibility = (typeof APP_VISIBILITIES)[number]\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /** Dock group the app renders in. Defaults to `dock.applications`. */\n group?: 'dock.applications' | 'dock.system' | 'dock.user'\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** Sort position within the dock group, ascending. Defaults to `100`. */\n priority?: number\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n /** Dashboard visibility of the application. Defaults to `default`. */\n visibility?: AppVisibility\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /** Configuration options for React Compiler */\n reactCompiler?: boolean | ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /**\n * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled\n * files during development, which can speed up startup and reloads for large projects.\n * Defaults to `false`.\n *\n * Unstable: may change or be removed without notice while the underlying Vite\n * feature (`experimental.bundledDev`) is experimental.\n * {@link https://vite.dev/guide/rolldown#full-bundle-mode}\n */\n unstable_bundledDev?: boolean\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n\n/**\n * A raw key-value store for CLI user configuration.\n * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on\n * arbitrary keys without schema validation.\n *\n * @public\n */\nexport interface ConfigStore {\n /** Remove a key from the config file. */\n delete: (key: string) => void\n /** Read a value by key. Returns `undefined` if the key does not exist. */\n get: (key: string) => unknown\n /** Write a value by key, merging it into the existing config. */\n set: (key: string, value: unknown) => void\n}\n"],"names":["APP_VISIBILITIES"],"mappings":"AAYA;;;;CAIC,GACD,OAAO,MAAMA,mBAAmB;IAAC;IAAW;IAAY;CAAW,CAAS"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const DEFAULT_STUDIO_WORKER_CLOSE_TIMEOUT = 5000;
|
|
2
|
+
const STUDIO_WORKER_ERROR_MARKER = 'sanity.studioWorker.error';
|
|
3
|
+
/**
|
|
4
|
+
* Defers messages from a one-shot studio worker until its Vite server has had
|
|
5
|
+
* a bounded opportunity to close. With Vite 8 the server hosts rolldown — a
|
|
6
|
+
* native addon whose threads talk to JS via napi threadsafe functions — and
|
|
7
|
+
* tearing the worker down while those threads are live aborts the whole
|
|
8
|
+
* process (silent SIGABRT / exit 134, reliably on macOS). Closing is
|
|
9
|
+
* single-flight so the task's final message and the loader's finalizer can
|
|
10
|
+
* safely request it at the same time.
|
|
11
|
+
*/ export function createOneShotWorkerLifecycle(options) {
|
|
12
|
+
const { closeServer, onCloseError, parentPort, timeout = DEFAULT_STUDIO_WORKER_CLOSE_TIMEOUT } = options;
|
|
13
|
+
let closePromise;
|
|
14
|
+
const close = ()=>{
|
|
15
|
+
closePromise ??= closeServerWithTimeout(closeServer, timeout).catch((error)=>{
|
|
16
|
+
onCloseError(error);
|
|
17
|
+
});
|
|
18
|
+
return closePromise;
|
|
19
|
+
};
|
|
20
|
+
const originalPostMessage = parentPort.postMessage.bind(parentPort);
|
|
21
|
+
parentPort.postMessage = (...args)=>{
|
|
22
|
+
void close().then(()=>originalPostMessage(...args));
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
close,
|
|
26
|
+
async postError (error) {
|
|
27
|
+
await close();
|
|
28
|
+
originalPostMessage(serializeStudioWorkerError(error));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function deserializeStudioWorkerError(message) {
|
|
33
|
+
const cause = new Error(message.error.message);
|
|
34
|
+
cause.name = message.error.name;
|
|
35
|
+
if (message.error.stack) cause.stack = message.error.stack;
|
|
36
|
+
return new Error(`Worker error: ${message.error.message}`, {
|
|
37
|
+
cause
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function isStudioWorkerErrorMessage(value) {
|
|
41
|
+
if (typeof value !== 'object' || value === null || !('type' in value) || value.type !== STUDIO_WORKER_ERROR_MARKER || !('error' in value) || typeof value.error !== 'object' || value.error === null) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const { error } = value;
|
|
45
|
+
return 'message' in error && typeof error.message === 'string' && 'name' in error && typeof error.name === 'string' && (!('stack' in error) || error.stack === undefined || typeof error.stack === 'string');
|
|
46
|
+
}
|
|
47
|
+
function closeServerWithTimeout(closeServer, timeout) {
|
|
48
|
+
return new Promise((resolve, reject)=>{
|
|
49
|
+
const timeoutId = setTimeout(()=>{
|
|
50
|
+
// Vite does not expose cancellation for close(); stop waiting while the
|
|
51
|
+
// unrefed worker lets the still-pending close finish with process teardown.
|
|
52
|
+
reject(new Error(`Vite server close timed out after ${timeout}ms`));
|
|
53
|
+
}, timeout);
|
|
54
|
+
void Promise.resolve().then(closeServer).then(()=>{
|
|
55
|
+
clearTimeout(timeoutId);
|
|
56
|
+
resolve();
|
|
57
|
+
}, (error)=>{
|
|
58
|
+
clearTimeout(timeoutId);
|
|
59
|
+
reject(error);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function serializeStudioWorkerError(error) {
|
|
64
|
+
if (error instanceof Error) {
|
|
65
|
+
return {
|
|
66
|
+
error: {
|
|
67
|
+
message: error.message,
|
|
68
|
+
name: error.name,
|
|
69
|
+
...error.stack ? {
|
|
70
|
+
stack: error.stack
|
|
71
|
+
} : {}
|
|
72
|
+
},
|
|
73
|
+
type: STUDIO_WORKER_ERROR_MARKER
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
error: {
|
|
78
|
+
message: String(error),
|
|
79
|
+
name: 'Error'
|
|
80
|
+
},
|
|
81
|
+
type: STUDIO_WORKER_ERROR_MARKER
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=studioWorkerLifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/loaders/studio/studioWorkerLifecycle.ts"],"sourcesContent":["import {type MessagePort} from 'node:worker_threads'\n\nconst DEFAULT_STUDIO_WORKER_CLOSE_TIMEOUT = 5000\n\nconst STUDIO_WORKER_ERROR_MARKER = 'sanity.studioWorker.error'\n\ninterface SerializedStudioWorkerError {\n message: string\n name: string\n\n stack?: string\n}\n\nexport interface StudioWorkerErrorMessage {\n error: SerializedStudioWorkerError\n type: typeof STUDIO_WORKER_ERROR_MARKER\n}\n\ninterface OneShotWorkerLifecycle {\n close: () => Promise<void>\n postError: (error: unknown) => Promise<void>\n}\n\ninterface OneShotWorkerLifecycleOptions {\n closeServer: () => Promise<void>\n onCloseError: (error: unknown) => void\n parentPort: MessagePort\n\n timeout?: number\n}\n\n/**\n * Defers messages from a one-shot studio worker until its Vite server has had\n * a bounded opportunity to close. With Vite 8 the server hosts rolldown — a\n * native addon whose threads talk to JS via napi threadsafe functions — and\n * tearing the worker down while those threads are live aborts the whole\n * process (silent SIGABRT / exit 134, reliably on macOS). Closing is\n * single-flight so the task's final message and the loader's finalizer can\n * safely request it at the same time.\n */\nexport function createOneShotWorkerLifecycle(\n options: OneShotWorkerLifecycleOptions,\n): OneShotWorkerLifecycle {\n const {\n closeServer,\n onCloseError,\n parentPort,\n timeout = DEFAULT_STUDIO_WORKER_CLOSE_TIMEOUT,\n } = options\n let closePromise: Promise<void> | undefined\n\n const close = () => {\n closePromise ??= closeServerWithTimeout(closeServer, timeout).catch((error) => {\n onCloseError(error)\n })\n return closePromise\n }\n\n const originalPostMessage = parentPort.postMessage.bind(parentPort)\n parentPort.postMessage = (...args: Parameters<MessagePort['postMessage']>) => {\n void close().then(() => originalPostMessage(...args))\n }\n\n return {\n close,\n async postError(error) {\n await close()\n originalPostMessage(serializeStudioWorkerError(error))\n },\n }\n}\n\nexport function deserializeStudioWorkerError(message: StudioWorkerErrorMessage): Error {\n const cause = new Error(message.error.message)\n cause.name = message.error.name\n if (message.error.stack) cause.stack = message.error.stack\n\n return new Error(`Worker error: ${message.error.message}`, {cause})\n}\n\nexport function isStudioWorkerErrorMessage(value: unknown): value is StudioWorkerErrorMessage {\n if (\n typeof value !== 'object' ||\n value === null ||\n !('type' in value) ||\n value.type !== STUDIO_WORKER_ERROR_MARKER ||\n !('error' in value) ||\n typeof value.error !== 'object' ||\n value.error === null\n ) {\n return false\n }\n\n const {error} = value\n return (\n 'message' in error &&\n typeof error.message === 'string' &&\n 'name' in error &&\n typeof error.name === 'string' &&\n (!('stack' in error) || error.stack === undefined || typeof error.stack === 'string')\n )\n}\n\nfunction closeServerWithTimeout(closeServer: () => Promise<void>, timeout: number): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n // Vite does not expose cancellation for close(); stop waiting while the\n // unrefed worker lets the still-pending close finish with process teardown.\n reject(new Error(`Vite server close timed out after ${timeout}ms`))\n }, timeout)\n\n void Promise.resolve()\n .then(closeServer)\n .then(\n () => {\n clearTimeout(timeoutId)\n resolve()\n },\n (error: unknown) => {\n clearTimeout(timeoutId)\n reject(error)\n },\n )\n })\n}\n\nfunction serializeStudioWorkerError(error: unknown): StudioWorkerErrorMessage {\n if (error instanceof Error) {\n return {\n error: {\n message: error.message,\n name: error.name,\n ...(error.stack ? {stack: error.stack} : {}),\n },\n type: STUDIO_WORKER_ERROR_MARKER,\n }\n }\n\n return {\n error: {\n message: String(error),\n name: 'Error',\n },\n type: STUDIO_WORKER_ERROR_MARKER,\n }\n}\n"],"names":["DEFAULT_STUDIO_WORKER_CLOSE_TIMEOUT","STUDIO_WORKER_ERROR_MARKER","createOneShotWorkerLifecycle","options","closeServer","onCloseError","parentPort","timeout","closePromise","close","closeServerWithTimeout","catch","error","originalPostMessage","postMessage","bind","args","then","postError","serializeStudioWorkerError","deserializeStudioWorkerError","message","cause","Error","name","stack","isStudioWorkerErrorMessage","value","type","undefined","Promise","resolve","reject","timeoutId","setTimeout","clearTimeout","String"],"mappings":"AAEA,MAAMA,sCAAsC;AAE5C,MAAMC,6BAA6B;AA2BnC;;;;;;;;CAQC,GACD,OAAO,SAASC,6BACdC,OAAsC;IAEtC,MAAM,EACJC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,UAAUP,mCAAmC,EAC9C,GAAGG;IACJ,IAAIK;IAEJ,MAAMC,QAAQ;QACZD,iBAAiBE,uBAAuBN,aAAaG,SAASI,KAAK,CAAC,CAACC;YACnEP,aAAaO;QACf;QACA,OAAOJ;IACT;IAEA,MAAMK,sBAAsBP,WAAWQ,WAAW,CAACC,IAAI,CAACT;IACxDA,WAAWQ,WAAW,GAAG,CAAC,GAAGE;QAC3B,KAAKP,QAAQQ,IAAI,CAAC,IAAMJ,uBAAuBG;IACjD;IAEA,OAAO;QACLP;QACA,MAAMS,WAAUN,KAAK;YACnB,MAAMH;YACNI,oBAAoBM,2BAA2BP;QACjD;IACF;AACF;AAEA,OAAO,SAASQ,6BAA6BC,OAAiC;IAC5E,MAAMC,QAAQ,IAAIC,MAAMF,QAAQT,KAAK,CAACS,OAAO;IAC7CC,MAAME,IAAI,GAAGH,QAAQT,KAAK,CAACY,IAAI;IAC/B,IAAIH,QAAQT,KAAK,CAACa,KAAK,EAAEH,MAAMG,KAAK,GAAGJ,QAAQT,KAAK,CAACa,KAAK;IAE1D,OAAO,IAAIF,MAAM,CAAC,cAAc,EAAEF,QAAQT,KAAK,CAACS,OAAO,EAAE,EAAE;QAACC;IAAK;AACnE;AAEA,OAAO,SAASI,2BAA2BC,KAAc;IACvD,IACE,OAAOA,UAAU,YACjBA,UAAU,QACV,CAAE,CAAA,UAAUA,KAAI,KAChBA,MAAMC,IAAI,KAAK3B,8BACf,CAAE,CAAA,WAAW0B,KAAI,KACjB,OAAOA,MAAMf,KAAK,KAAK,YACvBe,MAAMf,KAAK,KAAK,MAChB;QACA,OAAO;IACT;IAEA,MAAM,EAACA,KAAK,EAAC,GAAGe;IAChB,OACE,aAAaf,SACb,OAAOA,MAAMS,OAAO,KAAK,YACzB,UAAUT,SACV,OAAOA,MAAMY,IAAI,KAAK,YACrB,CAAA,CAAE,CAAA,WAAWZ,KAAI,KAAMA,MAAMa,KAAK,KAAKI,aAAa,OAAOjB,MAAMa,KAAK,KAAK,QAAO;AAEvF;AAEA,SAASf,uBAAuBN,WAAgC,EAAEG,OAAe;IAC/E,OAAO,IAAIuB,QAAc,CAACC,SAASC;QACjC,MAAMC,YAAYC,WAAW;YAC3B,wEAAwE;YACxE,4EAA4E;YAC5EF,OAAO,IAAIT,MAAM,CAAC,kCAAkC,EAAEhB,QAAQ,EAAE,CAAC;QACnE,GAAGA;QAEH,KAAKuB,QAAQC,OAAO,GACjBd,IAAI,CAACb,aACLa,IAAI,CACH;YACEkB,aAAaF;YACbF;QACF,GACA,CAACnB;YACCuB,aAAaF;YACbD,OAAOpB;QACT;IAEN;AACF;AAEA,SAASO,2BAA2BP,KAAc;IAChD,IAAIA,iBAAiBW,OAAO;QAC1B,OAAO;YACLX,OAAO;gBACLS,SAAST,MAAMS,OAAO;gBACtBG,MAAMZ,MAAMY,IAAI;gBAChB,GAAIZ,MAAMa,KAAK,GAAG;oBAACA,OAAOb,MAAMa,KAAK;gBAAA,IAAI,CAAC,CAAC;YAC7C;YACAG,MAAM3B;QACR;IACF;IAEA,OAAO;QACLW,OAAO;YACLS,SAASe,OAAOxB;YAChBY,MAAM;QACR;QACAI,MAAM3B;IACR;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isMainThread } from 'node:worker_threads';
|
|
1
|
+
import { isMainThread, parentPort } from 'node:worker_threads';
|
|
2
2
|
import { createServer, loadEnv, mergeConfig } from 'vite';
|
|
3
3
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
4
4
|
import { ViteNodeServer } from 'vite-node/server';
|
|
@@ -9,6 +9,7 @@ import { isNotFoundError } from '../../errors/NotFoundError.js';
|
|
|
9
9
|
import { getStudioEnvironmentVariables } from '../../util/environment/getStudioEnvironmentVariables.js';
|
|
10
10
|
import { setupBrowserStubs } from '../../util/environment/setupBrowserStubs.js'; // TODO: this imports jsdom!!! Unpacked Size (module + dependencies): 26 MB
|
|
11
11
|
import { isRecord } from '../../util/isRecord.js';
|
|
12
|
+
import { createOneShotWorkerLifecycle } from './studioWorkerLifecycle.js';
|
|
12
13
|
if (isMainThread) {
|
|
13
14
|
throw new Error('Should be child of thread, not the main thread');
|
|
14
15
|
}
|
|
@@ -112,60 +113,91 @@ debug('Creating Vite server with config: %o', viteConfig);
|
|
|
112
113
|
// Vite will build the files we give it - targetting Node.js instead of the browser.
|
|
113
114
|
// We include the inject plugin in order to provide the stubs for the undefined global APIs.
|
|
114
115
|
const server = await createServer(viteConfig);
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const node = new ViteNodeServer(server);
|
|
129
|
-
// Should make it easier to debug any crashes in the imported code…
|
|
130
|
-
installSourcemapsSupport({
|
|
131
|
-
getSourceMap: (source)=>node.getSourceMap(source)
|
|
132
|
-
});
|
|
133
|
-
const runner = new ViteNodeRunner({
|
|
134
|
-
base: server.config.base,
|
|
135
|
-
async fetchModule (id) {
|
|
136
|
-
// Vite's SSR transform externalizes https:// imports, so Node's ESM loader
|
|
137
|
-
// would reject them. We fetch the module over HTTP and run it through Vite's
|
|
138
|
-
// SSR transform to rewrite ESM export/import syntax to the __vite_ssr_*
|
|
139
|
-
// format that ViteNodeRunner expects.
|
|
140
|
-
if (isHttpsUrl(id)) {
|
|
141
|
-
const { code: rawCode } = await fetchHttpModule(id);
|
|
142
|
-
const result = await server.ssrTransform(rawCode, null, id);
|
|
143
|
-
return {
|
|
144
|
-
code: result?.code || rawCode
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
return node.fetchModule(id);
|
|
116
|
+
// One-shot tasks (`studioWorkerTask`) resolve on their first message, and the
|
|
117
|
+
// main thread historically terminate()d the worker right after — destroying
|
|
118
|
+
// the worker's libuv loop while rolldown's native threads were still live.
|
|
119
|
+
// The next `napi_call_threadsafe_function` then locked a destroyed mutex and
|
|
120
|
+
// aborted the whole process (silent SIGABRT / exit code 134, reliably
|
|
121
|
+
// reproduced on macOS). The lifecycle closes the Vite server BEFORE any
|
|
122
|
+
// message reaches the main thread, and the main thread no longer terminates
|
|
123
|
+
// one-shot workers at all (see `terminateOnSettle` in promisifyWorker).
|
|
124
|
+
const lifecycle = process.env.STUDIO_WORKER_ONE_SHOT === '1' && parentPort ? createOneShotWorkerLifecycle({
|
|
125
|
+
closeServer: async ()=>{
|
|
126
|
+
debug('Closing Vite server');
|
|
127
|
+
await server.close();
|
|
128
|
+
debug('Vite server closed');
|
|
148
129
|
},
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
130
|
+
onCloseError: (error)=>debug('Failed to close Vite server: %o', error),
|
|
131
|
+
parentPort
|
|
132
|
+
}) : undefined;
|
|
133
|
+
try {
|
|
134
|
+
// Bit of a hack, but seems necessary based on the `node-vite` binary implementation
|
|
135
|
+
await server.pluginContainer.buildStart({});
|
|
136
|
+
// Load environment variables from `.env` files in the same way as Vite does.
|
|
137
|
+
// Note that Sanity also provides environment variables through `process.env.*` for compat reasons,
|
|
138
|
+
// and so we need to do the same here.
|
|
139
|
+
// Load ALL env vars from .env files (not just studio-prefixed ones) so non-Sanity-prefixed
|
|
140
|
+
// vars (e.g. NEXT_PUBLIC_*, VITE_*) are available via process.env at runtime.
|
|
141
|
+
// The ??= on the next line prevents overwriting existing process.env values.
|
|
142
|
+
const env = loadEnv(server.config.mode, server.config.envDir, '');
|
|
143
|
+
for(const key in env){
|
|
144
|
+
process.env[key] ??= env[key];
|
|
145
|
+
}
|
|
146
|
+
// Now we're providing the glue that ensures node-specific loading and execution works.
|
|
147
|
+
const node = new ViteNodeServer(server);
|
|
148
|
+
// Should make it easier to debug any crashes in the imported code…
|
|
149
|
+
installSourcemapsSupport({
|
|
150
|
+
getSourceMap: (source)=>node.getSourceMap(source)
|
|
151
|
+
});
|
|
152
|
+
const runner = new ViteNodeRunner({
|
|
153
|
+
base: server.config.base,
|
|
154
|
+
async fetchModule (id) {
|
|
155
|
+
// Vite's SSR transform externalizes https:// imports, so Node's ESM loader
|
|
156
|
+
// would reject them. We fetch the module over HTTP and run it through Vite's
|
|
157
|
+
// SSR transform to rewrite ESM export/import syntax to the __vite_ssr_*
|
|
158
|
+
// format that ViteNodeRunner expects.
|
|
159
|
+
if (isHttpsUrl(id)) {
|
|
160
|
+
const { code: rawCode } = await fetchHttpModule(id);
|
|
161
|
+
const result = await server.ssrTransform(rawCode, null, id);
|
|
162
|
+
return {
|
|
163
|
+
code: result?.code || rawCode
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return node.fetchModule(id);
|
|
167
|
+
},
|
|
168
|
+
resolveId (id, importer) {
|
|
169
|
+
// Prevent vite-node from trying to resolve HTTP URLs through Node's resolver
|
|
170
|
+
if (isHttpsUrl(id)) return {
|
|
171
|
+
id
|
|
159
172
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
// Resolve any import from an HTTP-fetched module against the remote origin
|
|
174
|
+
// (e.g. esm.sh returns `export * from '/pkg@1.0/es2022/pkg.mjs'`)
|
|
175
|
+
if (importer && isHttpsUrl(importer)) {
|
|
176
|
+
return {
|
|
177
|
+
id: new URL(id, importer).href
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
return node.resolveId(id, importer);
|
|
181
|
+
},
|
|
182
|
+
root: server.config.root
|
|
183
|
+
});
|
|
184
|
+
// Copied from `vite-node` - it appears that this applies the `define` config from
|
|
185
|
+
// vite, but it also takes a surprisingly long time to execute. Not clear at this
|
|
186
|
+
// point why this is, so we should investigate whether it's necessary or not.
|
|
187
|
+
await runner.executeId('/@vite/env');
|
|
188
|
+
await runner.executeId(workerScriptPath);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
// Long-lived workers keep the original behavior: the error surfaces as a
|
|
191
|
+
// Worker 'error' event.
|
|
192
|
+
if (!lifecycle) {
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
// One-shot workers close the server first and post a serialized error the
|
|
196
|
+
// main thread rethrows, so the worker exits cleanly (code 0) and the real
|
|
197
|
+
// error (e.g. a broken `sanity.config.ts`) isn't masked by a teardown abort.
|
|
198
|
+
await lifecycle.postError(error);
|
|
199
|
+
} finally{
|
|
200
|
+
await lifecycle?.close();
|
|
201
|
+
}
|
|
170
202
|
|
|
171
203
|
//# sourceMappingURL=studioWorkerLoader.worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loaders/studio/studioWorkerLoader.worker.ts"],"sourcesContent":["import {isMainThread} from 'node:worker_threads'\n\nimport {createServer, type InlineConfig, loadEnv, mergeConfig} from 'vite'\nimport {ViteNodeRunner} from 'vite-node/client'\nimport {ViteNodeServer} from 'vite-node/server'\nimport {installSourcemapsSupport} from 'vite-node/source-map'\n\nimport {subdebug} from '../../_exports/debug.js'\nimport {getCliConfig} from '../../config/cli/getCliConfig.js'\nimport {type CliConfig} from '../../config/cli/types/cliConfig.js'\nimport {isNotFoundError} from '../../errors/NotFoundError.js'\nimport {getStudioEnvironmentVariables} from '../../util/environment/getStudioEnvironmentVariables.js'\nimport {setupBrowserStubs} from '../../util/environment/setupBrowserStubs.js' // TODO: this imports jsdom!!! Unpacked Size (module + dependencies): 26 MB\nimport {isRecord} from '../../util/isRecord.js'\n\nif (isMainThread) {\n throw new Error('Should be child of thread, not the main thread')\n}\n\nconst rootPath = process.env.STUDIO_WORKER_STUDIO_ROOT_PATH\nif (!rootPath) {\n throw new Error('Missing `STUDIO_WORKER_STUDIO_ROOT_PATH` environment variable')\n}\n\nconst debug = subdebug('studio:worker')\n\nconst workerScriptPath = process.env.STUDIO_WORKER_TASK_FILE\nif (!workerScriptPath) {\n throw new Error('Missing `STUDIO_WORKER_TASK_FILE` environment variable')\n}\n\nawait setupBrowserStubs()\n\nconst studioEnvVars = await getStudioEnvironmentVariables(rootPath)\n\n// Allow the CLI config (`sanity.cli.(js|ts)`) to define a `vite` property which can\n// extend/modify the default vite configuration for the studio.\nlet cliConfig: CliConfig | undefined\ntry {\n cliConfig = await getCliConfig(rootPath)\n} catch (err) {\n debug('Failed to load CLI config: %o', err)\n if (!isNotFoundError(err)) {\n // eslint-disable-next-line no-console\n console.warn('[warn] Failed to load CLI config:', err)\n }\n}\n\n/**\n * Fetches and caches modules from HTTP/HTTPS URLs.\n * Vite's SSR transform treats `https://` imports as external and bypasses the plugin\n * resolve pipeline entirely, so we intercept them at the ViteNodeRunner level instead.\n */\nconst httpModuleCache = new Map<string, string>()\nasync function fetchHttpModule(url: string): Promise<{code: string}> {\n const cached = httpModuleCache.get(url)\n if (cached) return {code: cached}\n\n debug('Fetching HTTP import: %s', url)\n const response = await fetch(url, {signal: AbortSignal.timeout(30_000)})\n if (!response.ok) {\n throw new Error(`Failed to fetch module from ${url}: ${response.status} ${response.statusText}`)\n }\n\n const code = await response.text()\n httpModuleCache.set(url, code)\n return {code}\n}\n\nfunction isHttpsUrl(id: string): boolean {\n return id.startsWith('https://')\n}\n\nconst defaultViteConfig: InlineConfig = {\n build: {target: 'node'},\n configFile: false,\n // Inject environment variables as compile-time constants for Vite\n define: Object.fromEntries(\n Object.entries(studioEnvVars).map(([key, value]) => [\n `process.env.${key}`,\n JSON.stringify(value),\n ]),\n ),\n envPrefix: cliConfig && 'app' in cliConfig ? 'SANITY_APP_' : 'SANITY_STUDIO_',\n esbuild: {\n jsx: 'automatic',\n },\n logLevel: 'error',\n optimizeDeps: {\n include: undefined,\n noDiscovery: true,\n },\n resolve: {\n // Resolve the studio's tsconfig `paths` natively (Vite 8+), replacing the\n // custom alias mapping and the need for a user-added `vite-tsconfig-paths`.\n tsconfigPaths: true,\n },\n root: rootPath,\n server: {\n hmr: false,\n watch: null,\n },\n ssr: {\n /**\n * We don't want to externalize any dependencies, we want everything to run thru vite.\n * Especially for CJS compatibility, etc.\n */\n noExternal: true,\n },\n}\n\n// Merge the CLI config's Vite config with the default Vite config\nlet viteConfig = defaultViteConfig\nif (typeof cliConfig?.vite === 'function') {\n viteConfig = (await cliConfig.vite(viteConfig, {\n command: 'build',\n isSsrBuild: true,\n mode: 'production',\n })) as InlineConfig\n} else if (isRecord(cliConfig?.vite)) {\n viteConfig = mergeConfig(viteConfig, cliConfig.vite)\n}\n\ndebug('Creating Vite server with config: %o', viteConfig)\n// Vite will build the files we give it - targetting Node.js instead of the browser.\n// We include the inject plugin in order to provide the stubs for the undefined global APIs.\nconst server = await createServer(viteConfig)\n\n// Bit of a hack, but seems necessary based on the `node-vite` binary implementation\nawait server.pluginContainer.buildStart({})\n\n// Load environment variables from `.env` files in the same way as Vite does.\n// Note that Sanity also provides environment variables through `process.env.*` for compat reasons,\n// and so we need to do the same here.\n// Load ALL env vars from .env files (not just studio-prefixed ones) so non-Sanity-prefixed\n// vars (e.g. NEXT_PUBLIC_*, VITE_*) are available via process.env at runtime.\n// The ??= on the next line prevents overwriting existing process.env values.\nconst env = loadEnv(server.config.mode, server.config.envDir, '')\nfor (const key in env) {\n process.env[key] ??= env[key]\n}\n\n// Now we're providing the glue that ensures node-specific loading and execution works.\nconst node = new ViteNodeServer(server)\n\n// Should make it easier to debug any crashes in the imported code…\ninstallSourcemapsSupport({\n getSourceMap: (source) => node.getSourceMap(source),\n})\n\nconst runner = new ViteNodeRunner({\n base: server.config.base,\n async fetchModule(id) {\n // Vite's SSR transform externalizes https:// imports, so Node's ESM loader\n // would reject them. We fetch the module over HTTP and run it through Vite's\n // SSR transform to rewrite ESM export/import syntax to the __vite_ssr_*\n // format that ViteNodeRunner expects.\n if (isHttpsUrl(id)) {\n const {code: rawCode} = await fetchHttpModule(id)\n const result = await server.ssrTransform(rawCode, null, id)\n return {code: result?.code || rawCode}\n }\n return node.fetchModule(id)\n },\n resolveId(id, importer) {\n // Prevent vite-node from trying to resolve HTTP URLs through Node's resolver\n if (isHttpsUrl(id)) return {id}\n // Resolve any import from an HTTP-fetched module against the remote origin\n // (e.g. esm.sh returns `export * from '/pkg@1.0/es2022/pkg.mjs'`)\n if (importer && isHttpsUrl(importer)) {\n return {id: new URL(id, importer).href}\n }\n return node.resolveId(id, importer)\n },\n root: server.config.root,\n})\n\n// Copied from `vite-node` - it appears that this applies the `define` config from\n// vite, but it also takes a surprisingly long time to execute. Not clear at this\n// point why this is, so we should investigate whether it's necessary or not.\nawait runner.executeId('/@vite/env')\n\nawait runner.executeId(workerScriptPath)\n"],"names":["isMainThread","createServer","loadEnv","mergeConfig","ViteNodeRunner","ViteNodeServer","installSourcemapsSupport","subdebug","getCliConfig","isNotFoundError","getStudioEnvironmentVariables","setupBrowserStubs","isRecord","Error","rootPath","process","env","STUDIO_WORKER_STUDIO_ROOT_PATH","debug","workerScriptPath","STUDIO_WORKER_TASK_FILE","studioEnvVars","cliConfig","err","console","warn","httpModuleCache","Map","fetchHttpModule","url","cached","get","code","response","fetch","signal","AbortSignal","timeout","ok","status","statusText","text","set","isHttpsUrl","id","startsWith","defaultViteConfig","build","target","configFile","define","Object","fromEntries","entries","map","key","value","JSON","stringify","envPrefix","esbuild","jsx","logLevel","optimizeDeps","include","undefined","noDiscovery","resolve","tsconfigPaths","root","server","hmr","watch","ssr","noExternal","viteConfig","vite","command","isSsrBuild","mode","pluginContainer","buildStart","config","envDir","node","getSourceMap","source","runner","base","fetchModule","rawCode","result","ssrTransform","resolveId","importer","URL","href","executeId"],"mappings":"AAAA,SAAQA,YAAY,QAAO,sBAAqB;AAEhD,SAAQC,YAAY,EAAqBC,OAAO,EAAEC,WAAW,QAAO,OAAM;AAC1E,SAAQC,cAAc,QAAO,mBAAkB;AAC/C,SAAQC,cAAc,QAAO,mBAAkB;AAC/C,SAAQC,wBAAwB,QAAO,uBAAsB;AAE7D,SAAQC,QAAQ,QAAO,0BAAyB;AAChD,SAAQC,YAAY,QAAO,mCAAkC;AAE7D,SAAQC,eAAe,QAAO,gCAA+B;AAC7D,SAAQC,6BAA6B,QAAO,0DAAyD;AACrG,SAAQC,iBAAiB,QAAO,8CAA6C,CAAC,2EAA2E;AACzJ,SAAQC,QAAQ,QAAO,yBAAwB;AAE/C,IAAIZ,cAAc;IAChB,MAAM,IAAIa,MAAM;AAClB;AAEA,MAAMC,WAAWC,QAAQC,GAAG,CAACC,8BAA8B;AAC3D,IAAI,CAACH,UAAU;IACb,MAAM,IAAID,MAAM;AAClB;AAEA,MAAMK,QAAQX,SAAS;AAEvB,MAAMY,mBAAmBJ,QAAQC,GAAG,CAACI,uBAAuB;AAC5D,IAAI,CAACD,kBAAkB;IACrB,MAAM,IAAIN,MAAM;AAClB;AAEA,MAAMF;AAEN,MAAMU,gBAAgB,MAAMX,8BAA8BI;AAE1D,oFAAoF;AACpF,+DAA+D;AAC/D,IAAIQ;AACJ,IAAI;IACFA,YAAY,MAAMd,aAAaM;AACjC,EAAE,OAAOS,KAAK;IACZL,MAAM,iCAAiCK;IACvC,IAAI,CAACd,gBAAgBc,MAAM;QACzB,sCAAsC;QACtCC,QAAQC,IAAI,CAAC,qCAAqCF;IACpD;AACF;AAEA;;;;CAIC,GACD,MAAMG,kBAAkB,IAAIC;AAC5B,eAAeC,gBAAgBC,GAAW;IACxC,MAAMC,SAASJ,gBAAgBK,GAAG,CAACF;IACnC,IAAIC,QAAQ,OAAO;QAACE,MA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D,UAAUE,IAAI;YAAA;QACxC;QACA,OAAOZ,KAAKS,SAAS,CAACjD,IAAIkD;IAC5B;IACAzB,MAAMC,OAAOY,MAAM,CAACb,IAAI;AAC1B;AAEA,kFAAkF;AAClF,iFAAiF;AACjF,6EAA6E;AAC7E,MAAMkB,OAAOU,SAAS,CAAC;AAEvB,MAAMV,OAAOU,SAAS,CAAC9E"}
|
|
1
|
+
{"version":3,"sources":["../../../src/loaders/studio/studioWorkerLoader.worker.ts"],"sourcesContent":["import {isMainThread, parentPort} from 'node:worker_threads'\n\nimport {createServer, type InlineConfig, loadEnv, mergeConfig} from 'vite'\nimport {ViteNodeRunner} from 'vite-node/client'\nimport {ViteNodeServer} from 'vite-node/server'\nimport {installSourcemapsSupport} from 'vite-node/source-map'\n\nimport {subdebug} from '../../_exports/debug.js'\nimport {getCliConfig} from '../../config/cli/getCliConfig.js'\nimport {type CliConfig} from '../../config/cli/types/cliConfig.js'\nimport {isNotFoundError} from '../../errors/NotFoundError.js'\nimport {getStudioEnvironmentVariables} from '../../util/environment/getStudioEnvironmentVariables.js'\nimport {setupBrowserStubs} from '../../util/environment/setupBrowserStubs.js' // TODO: this imports jsdom!!! Unpacked Size (module + dependencies): 26 MB\nimport {isRecord} from '../../util/isRecord.js'\nimport {createOneShotWorkerLifecycle} from './studioWorkerLifecycle.js'\n\nif (isMainThread) {\n throw new Error('Should be child of thread, not the main thread')\n}\n\nconst rootPath = process.env.STUDIO_WORKER_STUDIO_ROOT_PATH\nif (!rootPath) {\n throw new Error('Missing `STUDIO_WORKER_STUDIO_ROOT_PATH` environment variable')\n}\n\nconst debug = subdebug('studio:worker')\n\nconst workerScriptPath = process.env.STUDIO_WORKER_TASK_FILE\nif (!workerScriptPath) {\n throw new Error('Missing `STUDIO_WORKER_TASK_FILE` environment variable')\n}\n\nawait setupBrowserStubs()\n\nconst studioEnvVars = await getStudioEnvironmentVariables(rootPath)\n\n// Allow the CLI config (`sanity.cli.(js|ts)`) to define a `vite` property which can\n// extend/modify the default vite configuration for the studio.\nlet cliConfig: CliConfig | undefined\ntry {\n cliConfig = await getCliConfig(rootPath)\n} catch (err) {\n debug('Failed to load CLI config: %o', err)\n if (!isNotFoundError(err)) {\n // eslint-disable-next-line no-console\n console.warn('[warn] Failed to load CLI config:', err)\n }\n}\n\n/**\n * Fetches and caches modules from HTTP/HTTPS URLs.\n * Vite's SSR transform treats `https://` imports as external and bypasses the plugin\n * resolve pipeline entirely, so we intercept them at the ViteNodeRunner level instead.\n */\nconst httpModuleCache = new Map<string, string>()\nasync function fetchHttpModule(url: string): Promise<{code: string}> {\n const cached = httpModuleCache.get(url)\n if (cached) return {code: cached}\n\n debug('Fetching HTTP import: %s', url)\n const response = await fetch(url, {signal: AbortSignal.timeout(30_000)})\n if (!response.ok) {\n throw new Error(`Failed to fetch module from ${url}: ${response.status} ${response.statusText}`)\n }\n\n const code = await response.text()\n httpModuleCache.set(url, code)\n return {code}\n}\n\nfunction isHttpsUrl(id: string): boolean {\n return id.startsWith('https://')\n}\n\nconst defaultViteConfig: InlineConfig = {\n build: {target: 'node'},\n configFile: false,\n // Inject environment variables as compile-time constants for Vite\n define: Object.fromEntries(\n Object.entries(studioEnvVars).map(([key, value]) => [\n `process.env.${key}`,\n JSON.stringify(value),\n ]),\n ),\n envPrefix: cliConfig && 'app' in cliConfig ? 'SANITY_APP_' : 'SANITY_STUDIO_',\n esbuild: {\n jsx: 'automatic',\n },\n logLevel: 'error',\n optimizeDeps: {\n include: undefined,\n noDiscovery: true,\n },\n resolve: {\n // Resolve the studio's tsconfig `paths` natively (Vite 8+), replacing the\n // custom alias mapping and the need for a user-added `vite-tsconfig-paths`.\n tsconfigPaths: true,\n },\n root: rootPath,\n server: {\n hmr: false,\n watch: null,\n },\n ssr: {\n /**\n * We don't want to externalize any dependencies, we want everything to run thru vite.\n * Especially for CJS compatibility, etc.\n */\n noExternal: true,\n },\n}\n\n// Merge the CLI config's Vite config with the default Vite config\nlet viteConfig = defaultViteConfig\nif (typeof cliConfig?.vite === 'function') {\n viteConfig = (await cliConfig.vite(viteConfig, {\n command: 'build',\n isSsrBuild: true,\n mode: 'production',\n })) as InlineConfig\n} else if (isRecord(cliConfig?.vite)) {\n viteConfig = mergeConfig(viteConfig, cliConfig.vite)\n}\n\ndebug('Creating Vite server with config: %o', viteConfig)\n// Vite will build the files we give it - targetting Node.js instead of the browser.\n// We include the inject plugin in order to provide the stubs for the undefined global APIs.\nconst server = await createServer(viteConfig)\n\n// One-shot tasks (`studioWorkerTask`) resolve on their first message, and the\n// main thread historically terminate()d the worker right after — destroying\n// the worker's libuv loop while rolldown's native threads were still live.\n// The next `napi_call_threadsafe_function` then locked a destroyed mutex and\n// aborted the whole process (silent SIGABRT / exit code 134, reliably\n// reproduced on macOS). The lifecycle closes the Vite server BEFORE any\n// message reaches the main thread, and the main thread no longer terminates\n// one-shot workers at all (see `terminateOnSettle` in promisifyWorker).\nconst lifecycle =\n process.env.STUDIO_WORKER_ONE_SHOT === '1' && parentPort\n ? createOneShotWorkerLifecycle({\n closeServer: async () => {\n debug('Closing Vite server')\n await server.close()\n debug('Vite server closed')\n },\n onCloseError: (error) => debug('Failed to close Vite server: %o', error),\n parentPort,\n })\n : undefined\n\ntry {\n // Bit of a hack, but seems necessary based on the `node-vite` binary implementation\n await server.pluginContainer.buildStart({})\n\n // Load environment variables from `.env` files in the same way as Vite does.\n // Note that Sanity also provides environment variables through `process.env.*` for compat reasons,\n // and so we need to do the same here.\n // Load ALL env vars from .env files (not just studio-prefixed ones) so non-Sanity-prefixed\n // vars (e.g. NEXT_PUBLIC_*, VITE_*) are available via process.env at runtime.\n // The ??= on the next line prevents overwriting existing process.env values.\n const env = loadEnv(server.config.mode, server.config.envDir, '')\n for (const key in env) {\n process.env[key] ??= env[key]\n }\n\n // Now we're providing the glue that ensures node-specific loading and execution works.\n const node = new ViteNodeServer(server)\n\n // Should make it easier to debug any crashes in the imported code…\n installSourcemapsSupport({\n getSourceMap: (source) => node.getSourceMap(source),\n })\n\n const runner = new ViteNodeRunner({\n base: server.config.base,\n async fetchModule(id) {\n // Vite's SSR transform externalizes https:// imports, so Node's ESM loader\n // would reject them. We fetch the module over HTTP and run it through Vite's\n // SSR transform to rewrite ESM export/import syntax to the __vite_ssr_*\n // format that ViteNodeRunner expects.\n if (isHttpsUrl(id)) {\n const {code: rawCode} = await fetchHttpModule(id)\n const result = await server.ssrTransform(rawCode, null, id)\n return {code: result?.code || rawCode}\n }\n return node.fetchModule(id)\n },\n resolveId(id, importer) {\n // Prevent vite-node from trying to resolve HTTP URLs through Node's resolver\n if (isHttpsUrl(id)) return {id}\n // Resolve any import from an HTTP-fetched module against the remote origin\n // (e.g. esm.sh returns `export * from '/pkg@1.0/es2022/pkg.mjs'`)\n if (importer && isHttpsUrl(importer)) {\n return {id: new URL(id, importer).href}\n }\n return node.resolveId(id, importer)\n },\n root: server.config.root,\n })\n\n // Copied from `vite-node` - it appears that this applies the `define` config from\n // vite, but it also takes a surprisingly long time to execute. Not clear at this\n // point why this is, so we should investigate whether it's necessary or not.\n await runner.executeId('/@vite/env')\n\n await runner.executeId(workerScriptPath)\n} catch (error) {\n // Long-lived workers keep the original behavior: the error surfaces as a\n // Worker 'error' event.\n if (!lifecycle) {\n throw error\n }\n\n // One-shot workers close the server first and post a serialized error the\n // main thread rethrows, so the worker exits cleanly (code 0) and the real\n // error (e.g. a broken `sanity.config.ts`) isn't masked by a teardown abort.\n await lifecycle.postError(error)\n} finally {\n await lifecycle?.close()\n}\n"],"names":["isMainThread","parentPort","createServer","loadEnv","mergeConfig","ViteNodeRunner","ViteNodeServer","installSourcemapsSupport","subdebug","getCliConfig","isNotFoundError","getStudioEnvironmentVariables","setupBrowserStubs","isRecord","createOneShotWorkerLifecycle","Error","rootPath","process","env","STUDIO_WORKER_STUDIO_ROOT_PATH","debug","workerScriptPath","STUDIO_WORKER_TASK_FILE","studioEnvVars","cliConfig","err","console","warn","httpModuleCache","Map","fetchHttpModule","url","cached","get","code","response","fetch","signal","AbortSignal","timeout","ok","status","statusText","text","set","isHttpsUrl","id","startsWith","defaultViteConfig","build","target","configFile","define","Object","fromEntries","entries","map","key","value","JSON","stringify","envPrefix","esbuild","jsx","logLevel","optimizeDeps","include","undefined","noDiscovery","resolve","tsconfigPaths","root","server","hmr","watch","ssr","noExternal","viteConfig","vite","command","isSsrBuild","mode","lifecycle","STUDIO_WORKER_ONE_SHOT","closeServer","close","onCloseError","error","pluginContainer","buildStart","config","envDir","node","getSourceMap","source","runner","base","fetchModule","rawCode","result","ssrTransform","resolveId","importer","URL","href","executeId","postError"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,QAAO,sBAAqB;AAE5D,SAAQC,YAAY,EAAqBC,OAAO,EAAEC,WAAW,QAAO,OAAM;AAC1E,SAAQC,cAAc,QAAO,mBAAkB;AAC/C,SAAQC,cAAc,QAAO,mBAAkB;AAC/C,SAAQC,wBAAwB,QAAO,uBAAsB;AAE7D,SAAQC,QAAQ,QAAO,0BAAyB;AAChD,SAAQC,YAAY,QAAO,mCAAkC;AAE7D,SAAQC,eAAe,QAAO,gCAA+B;AAC7D,SAAQC,6BAA6B,QAAO,0DAAyD;AACrG,SAAQC,iBAAiB,QAAO,8CAA6C,CAAC,2EAA2E;AACzJ,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,4BAA4B,QAAO,6BAA4B;AAEvE,IAAId,cAAc;IAChB,MAAM,IAAIe,MAAM;AAClB;AAEA,MAAMC,WAAWC,QAAQC,GAAG,CAACC,8BAA8B;AAC3D,IAAI,CAACH,UAAU;IACb,MAAM,IAAID,MAAM;AAClB;AAEA,MAAMK,QAAQZ,SAAS;AAEvB,MAAMa,mBAAmBJ,QAAQC,GAAG,CAACI,uBAAuB;AAC5D,IAAI,CAACD,kBAAkB;IACrB,MAAM,IAAIN,MAAM;AAClB;AAEA,MAAMH;AAEN,MAAMW,gBAAgB,MAAMZ,8BAA8BK;AAE1D,oFAAoF;AACpF,+DAA+D;AAC/D,IAAIQ;AACJ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|
3
3
|
import { isRecord } from '../../util/isRecord.js';
|
|
4
4
|
import { promisifyWorker } from '../../util/promisifyWorker.js';
|
|
5
|
+
import { deserializeStudioWorkerError, isStudioWorkerErrorMessage } from './studioWorkerLifecycle.js';
|
|
5
6
|
/**
|
|
6
7
|
* Executes a worker file in a Sanity Studio browser context.
|
|
7
8
|
*
|
|
@@ -35,15 +36,30 @@ import { promisifyWorker } from '../../util/promisifyWorker.js';
|
|
|
35
36
|
throw new Error('Studio worker tasks must include `.worker.(js|ts)` in path');
|
|
36
37
|
}
|
|
37
38
|
const { studioRootPath, timeout, ...workerOptions } = options;
|
|
38
|
-
|
|
39
|
+
const workerPromise = promisifyWorker(new URL('studioWorkerLoader.worker.js', import.meta.url), {
|
|
39
40
|
...workerOptions,
|
|
40
41
|
env: {
|
|
41
42
|
...isRecord(workerOptions.env) ? workerOptions.env : process.env,
|
|
43
|
+
// Tasks spawned here are one-shot: the loader closes its Vite
|
|
44
|
+
// (rolldown) server before any message reaches the main thread, so
|
|
45
|
+
// teardown can never race rolldown's native threads (SIGABRT on
|
|
46
|
+
// macOS). Long-lived workers (`createStudioWorker`) must NOT set it.
|
|
47
|
+
STUDIO_WORKER_ONE_SHOT: '1',
|
|
42
48
|
STUDIO_WORKER_STUDIO_ROOT_PATH: studioRootPath,
|
|
43
49
|
STUDIO_WORKER_TASK_FILE: normalizedFilePath
|
|
44
50
|
},
|
|
51
|
+
// Never terminate() a worker hosting rolldown's native threads — let it
|
|
52
|
+
// exit on its own (it closes its server first) or tear down with the
|
|
53
|
+
// process.
|
|
54
|
+
terminateOnSettle: false,
|
|
45
55
|
timeout
|
|
46
56
|
});
|
|
57
|
+
return workerPromise.then((result)=>{
|
|
58
|
+
if (isStudioWorkerErrorMessage(result)) {
|
|
59
|
+
throw deserializeStudioWorkerError(result);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
});
|
|
47
63
|
}
|
|
48
64
|
/**
|
|
49
65
|
* Creates a new worker for a studio worker task.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loaders/studio/studioWorkerTask.ts"],"sourcesContent":["import {fileURLToPath} from 'node:url'\nimport {Worker, type WorkerOptions} from 'node:worker_threads'\n\nimport {type RequireProps} from '../../types.js'\nimport {isRecord} from '../../util/isRecord.js'\nimport {promisifyWorker} from '../../util/promisifyWorker.js'\n\n/**\n * Options for the studio worker task\n *\n * @internal\n */\ninterface StudioWorkerTaskOptions extends RequireProps<WorkerOptions, 'name'> {\n studioRootPath: string\n\n /** Optional timeout in milliseconds. If the worker does not respond within this time,
|
|
1
|
+
{"version":3,"sources":["../../../src/loaders/studio/studioWorkerTask.ts"],"sourcesContent":["import {fileURLToPath} from 'node:url'\nimport {Worker, type WorkerOptions} from 'node:worker_threads'\n\nimport {type RequireProps} from '../../types.js'\nimport {isRecord} from '../../util/isRecord.js'\nimport {promisifyWorker} from '../../util/promisifyWorker.js'\nimport {\n deserializeStudioWorkerError,\n isStudioWorkerErrorMessage,\n type StudioWorkerErrorMessage,\n} from './studioWorkerLifecycle.js'\n\n/**\n * Options for the studio worker task\n *\n * @internal\n */\ninterface StudioWorkerTaskOptions extends RequireProps<WorkerOptions, 'name'> {\n studioRootPath: string\n\n /** Optional timeout in milliseconds. If the worker does not respond within this time, the promise is rejected. */\n timeout?: number\n}\n\n/**\n * Executes a worker file in a Sanity Studio browser context.\n *\n * This uses a combination of vite for \"bundling\" + jsdom for emulating a browser\n * environment under the hood, which means that the same thing that will work in vite\n * _should_ work in the worker - to a degree. If the user has defined any typescript\n * path aliases, these will have to be added as aliases to the vite config - the same\n * behavior as you would see with regular vite. Other things that are accounted for:\n *\n * - TypeScript support (+JSX, enums and other \"compilation needed\" features)\n * - CSS, font and other file imports will resolve to a file path\n * - CSS module imports will resolve to a javascript object of class names\n * - Environment variables are available both as `import.meta.env` and `process.env`,\n * and `.env` files are loaded in the same way that they would in a Sanity studio.\n * - Browser globals not available in a Node.js environment but _are_ provided by JSDOM\n * are defined directly to the Node environment as globals. While this polutes the\n * global namespace, it is done only in the worker thread.\n * - Certain browser globals that are _not_ available in JSDOM are also provided to the\n * global namespace - things like `requestIdleCallback`, `IntersectionObserver` etc.\n * These are provided with a minimal stub implementation to make them not crash.\n *\n * @param filePath - Path to the worker file (`.ts` works and is encouraged)\n * @param options - Options to pass to the worker\n * @returns A promise that resolves with the message from the worker\n * @throws If the file does not exist\n * @throws If the worker exits with a non-zero code\n * @internal\n */\nexport function studioWorkerTask<T = unknown>(\n filePath: URL,\n options: StudioWorkerTaskOptions,\n): Promise<T> {\n const normalizedFilePath = fileURLToPath(filePath)\n\n if (!/\\.worker\\.(js|ts)$/.test(normalizedFilePath)) {\n throw new Error('Studio worker tasks must include `.worker.(js|ts)` in path')\n }\n\n const {studioRootPath, timeout, ...workerOptions} = options\n const workerPromise = promisifyWorker<StudioWorkerErrorMessage | T>(\n new URL('studioWorkerLoader.worker.js', import.meta.url),\n {\n ...workerOptions,\n env: {\n ...(isRecord(workerOptions.env) ? workerOptions.env : process.env),\n // Tasks spawned here are one-shot: the loader closes its Vite\n // (rolldown) server before any message reaches the main thread, so\n // teardown can never race rolldown's native threads (SIGABRT on\n // macOS). Long-lived workers (`createStudioWorker`) must NOT set it.\n STUDIO_WORKER_ONE_SHOT: '1',\n STUDIO_WORKER_STUDIO_ROOT_PATH: studioRootPath,\n STUDIO_WORKER_TASK_FILE: normalizedFilePath,\n },\n // Never terminate() a worker hosting rolldown's native threads — let it\n // exit on its own (it closes its server first) or tear down with the\n // process.\n terminateOnSettle: false,\n timeout,\n },\n )\n\n return workerPromise.then((result) => {\n if (isStudioWorkerErrorMessage(result)) {\n throw deserializeStudioWorkerError(result)\n }\n\n return result\n })\n}\n\n/**\n * Creates a new worker for a studio worker task.\n *\n * This uses a combination of vite for \"bundling\" + jsdom for emulating a browser\n * environment under the hood, which means that the same thing that will work in vite\n * _should_ work in the worker - to a degree. If the user has defined any typescript\n * path aliases, these will have to be added as aliases to the vite config - the same\n * behavior as you would see with regular vite. Other things that are accounted for:\n *\n * - TypeScript support (+JSX, enums and other \"compilation needed\" features)\n * - CSS, font and other file imports will resolve to a file path\n * - CSS module imports will resolve to a javascript object of class names\n * - Environment variables are available both as `import.meta.env` and `process.env`,\n * and `.env` files are loaded in the same way that they would in a Sanity studio.\n * - Browser globals not available in a Node.js environment but _are_ provided by JSDOM\n * are defined directly to the Node environment as globals. While this polutes the\n * global namespace, it is done only in the worker thread.\n * - Certain browser globals that are _not_ available in JSDOM are also provided to the\n * global namespace - things like `requestIdleCallback`, `IntersectionObserver` etc.\n * These are provided with a minimal stub implementation to make them not crash.\n *\n * @param filePath - Path to the worker file (`.ts` works and is encouraged)\n * @param options - Options to pass to the worker\n * @returns A promise that resolves with the message from the worker\n * @throws If the file does not exist\n * @throws If the worker exits with a non-zero code\n * @internal\n */\nexport function createStudioWorker(filePath: URL, options: StudioWorkerTaskOptions) {\n const normalizedFilePath = fileURLToPath(filePath)\n\n if (!/\\.worker\\.(js|ts)$/.test(normalizedFilePath)) {\n throw new Error('Studio worker tasks must include `.worker.(js|ts)` in path')\n }\n\n return new Worker(new URL('studioWorkerLoader.worker.js', import.meta.url), {\n ...options,\n env: {\n ...(isRecord(options.env) ? options.env : process.env),\n STUDIO_WORKER_STUDIO_ROOT_PATH: options.studioRootPath,\n STUDIO_WORKER_TASK_FILE: normalizedFilePath,\n },\n })\n}\n"],"names":["fileURLToPath","Worker","isRecord","promisifyWorker","deserializeStudioWorkerError","isStudioWorkerErrorMessage","studioWorkerTask","filePath","options","normalizedFilePath","test","Error","studioRootPath","timeout","workerOptions","workerPromise","URL","url","env","process","STUDIO_WORKER_ONE_SHOT","STUDIO_WORKER_STUDIO_ROOT_PATH","STUDIO_WORKER_TASK_FILE","terminateOnSettle","then","result","createStudioWorker"],"mappings":"AAAA,SAAQA,aAAa,QAAO,WAAU;AACtC,SAAQC,MAAM,QAA2B,sBAAqB;AAG9D,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,e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,yBAAyBb;QAC3B;IACF;AACF"}
|
package/dist/manifest.js
CHANGED
package/dist/manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/manifest.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\n/**\n * Studio/app manifest schemas. They live in cli-core because more than one\n * package validates manifests: the CLI extracts and writes them, and the\n * workbench dev-server registry stores and rebroadcasts them. Keeping the\n * contract here lets both validate against the same schema without depending on\n * each other.\n */\n\n/**\n * Core-app application manifest. Mirrors the workbench's\n * `CoreAppUserApplicationManifest` schema. Strictly validated via zod since the\n * CLI produces the payload in full.\n */\nexport const coreAppManifestSchema = z.object({\n group: z.optional(z.string()),\n icon: z.optional(z.string()),\n priority: z.optional(z.number()),\n title: z.optional(z.string()),\n version: z.string(),\n})\n\nexport type CoreAppManifest = z.infer<typeof coreAppManifestSchema>\n\n/**\n * Studio application manifest (serialized `create-manifest.json`). Kept loose so\n * the CLI isn't coupled to the workbench's evolving client-side schema — the\n * workbench consumer is authoritative on the inner shape. See its\n * `ClientManifest` for the fields clients expect.\n */\nexport const studioManifestSchema = z.record(z.string(), z.unknown())\n\nexport type StudioManifest = z.infer<typeof studioManifestSchema>\n"],"names":["z","coreAppManifestSchema","object","group","optional","string","icon","priority","number","title","version","studioManifestSchema","record","unknown"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B;;;;;;CAMC,GAED;;;;CAIC,GACD,OAAO,MAAMC,wBAAwBD,EAAEE,MAAM,CAAC;IAC5CC,OAAOH,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IAC1BC,MAAMN,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IACzBE,UAAUP,EAAEI,QAAQ,CAACJ,EAAEQ,MAAM;IAC7BC,
|
|
1
|
+
{"version":3,"sources":["../src/manifest.ts"],"sourcesContent":["import {z} from 'zod/mini'\n\n/**\n * Studio/app manifest schemas. They live in cli-core because more than one\n * package validates manifests: the CLI extracts and writes them, and the\n * workbench dev-server registry stores and rebroadcasts them. Keeping the\n * contract here lets both validate against the same schema without depending on\n * each other.\n */\n\n/**\n * Core-app application manifest. Mirrors the workbench's\n * `CoreAppUserApplicationManifest` schema. Strictly validated via zod since the\n * CLI produces the payload in full.\n */\nexport const coreAppManifestSchema = z.object({\n group: z.optional(z.string()),\n icon: z.optional(z.string()),\n priority: z.optional(z.number()),\n slug: z.optional(z.string()),\n title: z.optional(z.string()),\n version: z.string(),\n})\n\nexport type CoreAppManifest = z.infer<typeof coreAppManifestSchema>\n\n/**\n * Studio application manifest (serialized `create-manifest.json`). Kept loose so\n * the CLI isn't coupled to the workbench's evolving client-side schema — the\n * workbench consumer is authoritative on the inner shape. See its\n * `ClientManifest` for the fields clients expect.\n */\nexport const studioManifestSchema = z.record(z.string(), z.unknown())\n\nexport type StudioManifest = z.infer<typeof studioManifestSchema>\n"],"names":["z","coreAppManifestSchema","object","group","optional","string","icon","priority","number","slug","title","version","studioManifestSchema","record","unknown"],"mappings":"AAAA,SAAQA,CAAC,QAAO,WAAU;AAE1B;;;;;;CAMC,GAED;;;;CAIC,GACD,OAAO,MAAMC,wBAAwBD,EAAEE,MAAM,CAAC;IAC5CC,OAAOH,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IAC1BC,MAAMN,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IACzBE,UAAUP,EAAEI,QAAQ,CAACJ,EAAEQ,MAAM;IAC7BC,MAAMT,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IACzBK,OAAOV,EAAEI,QAAQ,CAACJ,EAAEK,MAAM;IAC1BM,SAASX,EAAEK,MAAM;AACnB,GAAE;AAIF;;;;;CAKC,GACD,OAAO,MAAMO,uBAAuBZ,EAAEa,MAAM,CAACb,EAAEK,MAAM,IAAIL,EAAEc,OAAO,IAAG"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Worker } from 'node:worker_threads';
|
|
2
2
|
import { subdebug } from '../_exports/debug.js';
|
|
3
3
|
const debug = subdebug('promisifyWorker');
|
|
4
|
+
function onDetachedWorkerError(err) {
|
|
5
|
+
debug(`Detached worker error: ${err.message}`, err);
|
|
6
|
+
}
|
|
4
7
|
/**
|
|
5
8
|
* Creates a Node.js Worker from the given file path and options, and wraps it
|
|
6
9
|
* in a Promise that resolves with the first message the worker sends, and
|
|
7
10
|
* rejects on error, message deserialization failure, or non-zero exit code.
|
|
8
|
-
*
|
|
11
|
+
* By default, the worker is terminated after a message or error is received.
|
|
12
|
+
* Callers can instead unref it and allow natural process teardown.
|
|
9
13
|
*
|
|
10
14
|
* @param filePath - URL to the worker file
|
|
11
15
|
* @param options - Options to pass to the Worker constructor
|
|
@@ -13,7 +17,7 @@ const debug = subdebug('promisifyWorker');
|
|
|
13
17
|
* @throws If the worker emits an error, a message deserialization error, or exits with a non-zero code
|
|
14
18
|
* @internal
|
|
15
19
|
*/ export function promisifyWorker(filePath, options) {
|
|
16
|
-
const { timeout, ...workerOptions } = options ?? {};
|
|
20
|
+
const { terminateOnSettle = true, timeout, ...workerOptions } = options ?? {};
|
|
17
21
|
const worker = new Worker(filePath, workerOptions);
|
|
18
22
|
const fileName = `[${filePath.pathname}]`;
|
|
19
23
|
return new Promise((resolve, reject)=>{
|
|
@@ -23,8 +27,7 @@ const debug = subdebug('promisifyWorker');
|
|
|
23
27
|
timeoutId = setTimeout(()=>{
|
|
24
28
|
settled = true;
|
|
25
29
|
reject(new Error(`Worker timed out after ${timeout}ms`));
|
|
26
|
-
|
|
27
|
-
worker.removeAllListeners();
|
|
30
|
+
cleanup(false);
|
|
28
31
|
}, timeout);
|
|
29
32
|
}
|
|
30
33
|
worker.addListener('error', function onWorkerError(err) {
|
|
@@ -62,9 +65,21 @@ const debug = subdebug('promisifyWorker');
|
|
|
62
65
|
resolve(message);
|
|
63
66
|
cleanup();
|
|
64
67
|
});
|
|
65
|
-
function cleanup() {
|
|
66
|
-
|
|
68
|
+
function cleanup(deferTermination = true) {
|
|
69
|
+
if (terminateOnSettle) {
|
|
70
|
+
if (deferTermination) {
|
|
71
|
+
setImmediate(()=>void worker.terminate());
|
|
72
|
+
} else {
|
|
73
|
+
void worker.terminate();
|
|
74
|
+
}
|
|
75
|
+
worker.removeAllListeners();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
worker.unref();
|
|
67
79
|
worker.removeAllListeners();
|
|
80
|
+
// A detached worker may still fail before process teardown. Keep an error
|
|
81
|
+
// listener so EventEmitter does not rethrow it in the parent process.
|
|
82
|
+
worker.addListener('error', onDetachedWorkerError);
|
|
68
83
|
}
|
|
69
84
|
});
|
|
70
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/promisifyWorker.ts"],"sourcesContent":["import {Worker, type WorkerOptions} from 'node:worker_threads'\n\nimport {subdebug} from '../_exports/debug.js'\n\nconst debug = subdebug('promisifyWorker')\n\ninterface PromisifyWorkerOptions extends WorkerOptions {\n /** Optional timeout in milliseconds. If the worker does not respond within this time,
|
|
1
|
+
{"version":3,"sources":["../../src/util/promisifyWorker.ts"],"sourcesContent":["import {Worker, type WorkerOptions} from 'node:worker_threads'\n\nimport {subdebug} from '../_exports/debug.js'\n\nconst debug = subdebug('promisifyWorker')\n\nfunction onDetachedWorkerError(err: Error) {\n debug(`Detached worker error: ${err.message}`, err)\n}\n\ninterface PromisifyWorkerOptions extends WorkerOptions {\n /**\n * Whether to forcibly terminate the worker after settling. Disable this for\n * workers that host native addons (e.g. rolldown via Vite 8) whose threads\n * must tear down with the process: terminating such a worker while native\n * threads are live can abort the whole process with a silent SIGABRT. A\n * disabled worker is unrefed and may continue running until the process\n * exits, including after a timeout.\n */\n terminateOnSettle?: boolean\n\n /** Optional timeout in milliseconds. If the worker does not respond within this time, the promise is rejected. */\n timeout?: number\n}\n\n/**\n * Creates a Node.js Worker from the given file path and options, and wraps it\n * in a Promise that resolves with the first message the worker sends, and\n * rejects on error, message deserialization failure, or non-zero exit code.\n * By default, the worker is terminated after a message or error is received.\n * Callers can instead unref it and allow natural process teardown.\n *\n * @param filePath - URL to the worker file\n * @param options - Options to pass to the Worker constructor\n * @returns A promise that resolves with the first message from the worker\n * @throws If the worker emits an error, a message deserialization error, or exits with a non-zero code\n * @internal\n */\nexport function promisifyWorker<T = unknown>(\n filePath: URL,\n options?: PromisifyWorkerOptions,\n): Promise<T> {\n const {terminateOnSettle = true, timeout, ...workerOptions} = options ?? {}\n const worker = new Worker(filePath, workerOptions)\n\n const fileName = `[${filePath.pathname}]`\n\n return new Promise<T>((resolve, reject) => {\n let settled = false\n let timeoutId: ReturnType<typeof setTimeout> | undefined\n\n if (timeout !== undefined && timeout > 0) {\n timeoutId = setTimeout(() => {\n settled = true\n reject(new Error(`Worker timed out after ${timeout}ms`))\n cleanup(false)\n }, timeout)\n }\n\n worker.addListener('error', function onWorkerError(err) {\n settled = true\n clearTimeout(timeoutId)\n debug(`Worker error: ${err.message}`, err)\n reject(new Error(`Worker error: ${err.message}`, {cause: err}))\n cleanup()\n })\n // No cleanup() here — the worker is already dead after exiting,\n // so there is nothing to terminate or remove listeners from.\n worker.addListener('exit', function onWorkerExit(code) {\n clearTimeout(timeoutId)\n if (code > 0) {\n debug(`${fileName} exited with code ${code}`)\n reject(new Error(`Worker exited with code ${code}`))\n } else if (!settled) {\n debug(`${fileName} exited with code 0 without sending a message`)\n reject(new Error('Worker exited without sending a message'))\n }\n })\n worker.addListener('messageerror', function onWorkerMessageError(err) {\n settled = true\n clearTimeout(timeoutId)\n debug(`${fileName} message error: ${err.message}`, err)\n reject(new Error(`Failed to deserialize worker message: ${err}`))\n cleanup()\n })\n worker.addListener('message', function onWorkerMessage(message) {\n settled = true\n clearTimeout(timeoutId)\n debug(`${fileName} message %o`, message)\n resolve(message)\n cleanup()\n })\n\n function cleanup(deferTermination = true) {\n if (terminateOnSettle) {\n if (deferTermination) {\n setImmediate(() => void worker.terminate())\n } else {\n void worker.terminate()\n }\n worker.removeAllListeners()\n return\n }\n\n worker.unref()\n worker.removeAllListeners()\n // A detached worker may still fail before process teardown. Keep an error\n // listener so EventEmitter does not rethrow it in the parent process.\n worker.addListener('error', onDetachedWorkerError)\n }\n })\n}\n"],"names":["Worker","subdebug","debug","onDetachedWorkerError","err","message","promisifyWorker","filePath","options","terminateOnSettle","timeout","workerOptions","worker","fileName","pathname","Promise","resolve","reject","settled","timeoutId","undefined","setTimeout","Error","cleanup","addListener","onWorkerError","clearTimeout","cause","onWorkerExit","code","onWorkerMessageError","onWorkerMessage","deferTermination","setImmediate","terminate","removeAllListeners","unref"],"mappings":"AAAA,SAAQA,MAAM,QAA2B,sBAAqB;AAE9D,SAAQC,QAAQ,QAAO,uBAAsB;AAE7C,MAAMC,QAAQD,SAAS;AAEvB,SAASE,sBAAsBC,GAAU;IACvCF,MAAM,CAAC,uBAAuB,EAAEE,IAAIC,OAAO,EAAE,EAAED;AACjD;AAiBA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASE,gBACdC,QAAa,EACbC,OAAgC;IAEhC,MAAM,EAACC,oBAAoB,IAAI,EAAEC,OAAO,EAAE,GAAGC,eAAc,GAAGH,WAAW,CAAC;IAC1E,MAAMI,SAAS,IAAIZ,OAAOO,UAAUI;IAEpC,MAAME,WAAW,CAAC,CAAC,EAAEN,SAASO,QAAQ,CAAC,CAAC,CAAC;IAEzC,OAAO,IAAIC,QAAW,CAACC,SAASC;QAC9B,IAAIC,UAAU;QACd,IAAIC;QAEJ,IAAIT,YAAYU,aAAaV,UAAU,GAAG;YACxCS,YAAYE,WAAW;gBACrBH,UAAU;gBACVD,OAAO,IAAIK,MAAM,CAAC,uBAAuB,EAAEZ,QAAQ,EAAE,CAAC;gBACtDa,QAAQ;YACV,GAAGb;QACL;QAEAE,OAAOY,WAAW,CAAC,SAAS,SAASC,cAAcrB,GAAG;YACpDc,UAAU;YACVQ,aAAaP;YACbjB,MAAM,CAAC,cAAc,EAAEE,IAAIC,OAAO,EAAE,EAAED;YACtCa,OAAO,IAAIK,MAAM,CAAC,cAAc,EAAElB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3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Sanity CLI core package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
106
|
"@inquirer/prompts": "^8.5.2",
|
|
107
|
-
"@oclif/core": "^4.11.
|
|
108
|
-
"@sanity/client": "^7.23.
|
|
107
|
+
"@oclif/core": "^4.11.14",
|
|
108
|
+
"@sanity/client": "^7.23.2",
|
|
109
109
|
"boxen": "^8.0.1",
|
|
110
110
|
"debug": "^4.4.3",
|
|
111
111
|
"empathic": "^2.0.1",
|
|
@@ -118,29 +118,29 @@
|
|
|
118
118
|
"log-symbols": "^7.0.1",
|
|
119
119
|
"ora": "^9.0.0",
|
|
120
120
|
"rxjs": "^7.8.2",
|
|
121
|
-
"tsx": "^4.
|
|
122
|
-
"vite": "^8.1.
|
|
121
|
+
"tsx": "^4.23.1",
|
|
122
|
+
"vite": "^8.1.5",
|
|
123
123
|
"vite-node": "^6.0.0",
|
|
124
124
|
"zod": "^4.4.3"
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|
|
127
127
|
"@eslint/compat": "^2.1.0",
|
|
128
|
-
"@sanity/pkg-utils": "^
|
|
128
|
+
"@sanity/pkg-utils": "^11.0.9",
|
|
129
129
|
"@sanity/telemetry": "^1.1.0",
|
|
130
130
|
"@swc/cli": "^0.8.1",
|
|
131
|
-
"@swc/core": "^1.15.
|
|
131
|
+
"@swc/core": "^1.15.43",
|
|
132
132
|
"@types/debug": "^4.1.13",
|
|
133
133
|
"@types/jsdom": "^28.0.3",
|
|
134
134
|
"@types/node": "^22.20.0",
|
|
135
135
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
136
|
-
"eslint": "^10.
|
|
136
|
+
"eslint": "^10.7.0",
|
|
137
137
|
"publint": "^0.3.21",
|
|
138
|
-
"sanity": "^6.
|
|
139
|
-
"typescript": "^
|
|
140
|
-
"vitest": "^4.1.
|
|
138
|
+
"sanity": "^6.5.0",
|
|
139
|
+
"typescript": "^6.0.3",
|
|
140
|
+
"vitest": "^4.1.10",
|
|
141
141
|
"@repo/package.config": "0.0.1",
|
|
142
142
|
"@repo/tsconfig": "3.70.0",
|
|
143
|
-
"@sanity/eslint-config-cli": "1.1.
|
|
143
|
+
"@sanity/eslint-config-cli": "1.1.3"
|
|
144
144
|
},
|
|
145
145
|
"peerDependencies": {
|
|
146
146
|
"babel-plugin-react-compiler": "*"
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"node": ">=22.12"
|
|
155
155
|
},
|
|
156
156
|
"scripts": {
|
|
157
|
-
"build": "swc --delete-dir-on-start --strip-leading-paths --out-dir dist/ src
|
|
157
|
+
"build": "swc --delete-dir-on-start --strip-leading-paths --out-dir dist/ src",
|
|
158
158
|
"build:types": "pkg-utils build --emitDeclarationOnly",
|
|
159
159
|
"check:types": "tsc --noEmit",
|
|
160
160
|
"lint": "eslint .",
|