@vite-hub/sandbox 0.5.0 → 0.6.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.
Files changed (57) hide show
  1. package/README.md +20 -0
  2. package/dist/{abortable-CR01hzfi.js → abortable-DrHeTo1e.js} +1 -2
  3. package/dist/{cloudflare-DOrMY3MJ.js → cloudflare-DrNRQPeh.js} +13 -17
  4. package/dist/{cloudflare-env-lookup-DzI6Xv1Y.js → cloudflare-env-lookup-BNbNil7g.js} +1 -2
  5. package/dist/{cloudflare-failure-CFQhalfh.js → cloudflare-failure-f-3P3ul-.js} +1 -2
  6. package/dist/{container-BVb0fw3z.js → container-DOadzngt.js} +7 -9
  7. package/dist/{crabbox-BU8W1gVC.js → crabbox-C7KeIKnH.js} +7 -8
  8. package/dist/{error-diagnostics-BJtLRL9w.js → error-diagnostics-CApUyzzu.js} +1 -2
  9. package/dist/{error-diagnostics-BNQwU9yq.js → error-diagnostics-D9n0ZmdN.js} +8 -5
  10. package/dist/{file-listing-CHtRrfo1.js → file-listing-BF122soX.js} +3 -4
  11. package/dist/{file-lock-D0-XPogS.js → file-lock-CqA7b491.js} +3 -4
  12. package/dist/{index-DHl0T43e.d.ts → index-D9DogaoF.d.ts} +0 -14
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +12 -13
  15. package/dist/internal/cloudflare.d.ts +2 -5
  16. package/dist/internal/cloudflare.js +3 -4
  17. package/dist/internal/host-toolchain.d.ts +2 -4
  18. package/dist/internal/host-toolchain.js +4 -5
  19. package/dist/internal/vercel.d.ts +2 -4
  20. package/dist/internal/vercel.js +3 -4
  21. package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
  22. package/dist/{module-types-B0LQ5H2S.js → module-types-CWcBHyEs.js} +1 -2
  23. package/dist/{module-types-NYnG3NGz.d.ts → module-types-DHr6oC3h.d.ts} +18 -13
  24. package/dist/{process-sweep-CMaujWE5.js → process-sweep-DVaTb2pO.js} +1 -2
  25. package/dist/{provider-loader-Cvqoz7_Z.d.ts → provider-loader-CLIIEEmR.d.ts} +2 -6
  26. package/dist/{provider-resolution-BrQfEQo0.js → provider-resolution-qvRcW1PC.js} +13 -10
  27. package/dist/{remote-fjUPBiLJ.js → remote-DlyX1drC.js} +5 -6
  28. package/dist/{rolldown-runtime-8H4AJuhK.js → rolldown-runtime-BJohB4LM.js} +1 -2
  29. package/dist/{runtime-DHp6ImeP.js → runtime-EtWFVKud.js} +1 -2
  30. package/dist/{runtime-type-Deo4qzxN.js → runtime-type-Dk-rJXlr.js} +1 -2
  31. package/dist/{session-e0lyzjJ3.js → session-DmUiyj4O.js} +5 -8
  32. package/dist/{shell-quote-Q3u3plif.js → shell-quote-MrD49m3N.js} +1 -2
  33. package/dist/ssh.d.ts +1 -3
  34. package/dist/ssh.js +5 -7
  35. package/dist/task/index.d.ts +2 -16
  36. package/dist/task/index.js +345 -142
  37. package/dist/task/runtime/empty-registry.d.ts +0 -2
  38. package/dist/task/runtime/empty-registry.js +1 -2
  39. package/dist/task/runtime/provider-loader.d.ts +1 -1
  40. package/dist/task/runtime/provider-loader.js +2 -3
  41. package/dist/task/runtime/providers/cloudflare.d.ts +3 -4
  42. package/dist/task/runtime/providers/cloudflare.js +3 -4
  43. package/dist/task/runtime/providers/local.d.ts +2 -4
  44. package/dist/task/runtime/providers/local.js +3 -4
  45. package/dist/task/runtime/providers/vercel.d.ts +3 -4
  46. package/dist/task/runtime/providers/vercel.js +6 -8
  47. package/dist/task/runtime/state.d.ts +3 -4
  48. package/dist/task/runtime/state.js +2 -3
  49. package/dist/task/vite.d.ts +23 -24
  50. package/dist/task/vite.js +63 -74
  51. package/dist/{toolchain-DF9eutyQ.js → toolchain-DFFxmw3N.js} +6 -7
  52. package/dist/transfer-options-LTUzbHDw.js +18 -0
  53. package/dist/{trusted-host-DLYiKP8a.js → trusted-host-CwMs64h1.js} +8 -9
  54. package/dist/{trusted-host-environment-CWKJ7DD_.js → trusted-host-environment-BJE5hGtQ.js} +1 -2
  55. package/dist/{vercel-qyDr7NvU.js → vercel-DT74kDyI.js} +9 -13
  56. package/dist/{vercel-credentials-BNTh2X-Y.js → vercel-credentials-BH5lPJxs.js} +3 -5
  57. package/package.json +10 -10
@@ -1,6 +1,4 @@
1
- //#region src/task/runtime/empty-registry.d.ts
2
1
  type SandboxTaskRegistry = Record<string, unknown>;
3
2
  export interface SandboxTaskDefinitionModules {}
4
3
  declare const registry: SandboxTaskRegistry;
5
- //#endregion
6
4
  export { registry as default };
@@ -1,4 +1,4 @@
1
- //#region src/task/runtime/empty-registry.ts
1
+ // src/task/runtime/empty-registry.ts
2
2
  function getRuntimeRegistry() {
3
3
  return globalThis.__vitehubSandboxTaskRegistry || {};
4
4
  }
@@ -16,5 +16,4 @@ const registry = new Proxy({}, {
16
16
  return Object.getOwnPropertyDescriptor(getRuntimeRegistry(), key);
17
17
  }
18
18
  });
19
- //#endregion
20
19
  export { registry as default };
@@ -1,2 +1,2 @@
1
- import { n as SandboxTaskRuntimeProvider, r as loadSandboxTaskRuntimeProvider, t as ResolvedTaskSandbox } from "../../provider-loader-Cvqoz7_Z.js";
1
+ import { n as SandboxTaskRuntimeProvider, r as loadSandboxTaskRuntimeProvider, t as ResolvedTaskSandbox } from "../../provider-loader-CLIIEEmR.js";
2
2
  export { ResolvedTaskSandbox, SandboxTaskRuntimeProvider, loadSandboxTaskRuntimeProvider };
@@ -1,5 +1,5 @@
1
- import { t as sandboxTaskErrorDiagnostics } from "../../error-diagnostics-BNQwU9yq.js";
2
- //#region src/task/runtime/provider-loader.ts
1
+ import { t as sandboxTaskErrorDiagnostics } from "../../error-diagnostics-D9n0ZmdN.js";
2
+ // src/task/runtime/provider-loader.ts
3
3
  const dynamicImport = new Function("specifier", "return import(specifier)");
4
4
  async function loadSandboxTaskRuntimeProvider(provider) {
5
5
  if (provider === "cloudflare") {
@@ -12,5 +12,4 @@ async function loadSandboxTaskRuntimeProvider(provider) {
12
12
  }
13
13
  throw sandboxTaskErrorDiagnostics.SANDBOX_TASK_R0068({ message: `[vitehub] Unsupported sandbox provider: ${provider}` });
14
14
  }
15
- //#endregion
16
15
  export { loadSandboxTaskRuntimeProvider };
@@ -1,6 +1,5 @@
1
- import { l as Sandbox } from "../../../index-DHl0T43e.js";
2
- import { n as CloudflareSandboxTaskDefinitionDriverOptions, u as SandboxTaskDefinitionOptions } from "../../../module-types-NYnG3NGz.js";
3
- //#region src/task/runtime/providers/cloudflare.d.ts
1
+ import { l as Sandbox } from "../../../index-D9DogaoF.js";
2
+ import { n as CloudflareSandboxTaskDefinitionDriverOptions, u as SandboxTaskDefinitionOptions } from "../../../module-types-DHr6oC3h.js";
4
3
  type SandboxTaskOptions = {
5
4
  local: SandboxTaskDefinitionOptions;
6
5
  provider: CloudflareSandboxTaskDefinitionDriverOptions;
@@ -11,4 +10,4 @@ export declare function resolveCloudflareTaskSandbox(options: SandboxTaskOptions
11
10
  sandboxId: string | undefined;
12
11
  resolveSandbox: (requirements: readonly string[]) => Promise<Sandbox>;
13
12
  }>;
14
- //#endregion
13
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { resolveCloudflareSandbox } from "../../../internal/cloudflare.js";
2
- import { t as sandboxTaskErrorDiagnostics } from "../../../error-diagnostics-BNQwU9yq.js";
3
- import { t as getActiveCloudflareEnv } from "../../../cloudflare-env-lookup-DzI6Xv1Y.js";
4
- //#region src/task/runtime/providers/cloudflare.ts
2
+ import { t as getActiveCloudflareEnv } from "../../../cloudflare-env-lookup-BNbNil7g.js";
3
+ import { t as sandboxTaskErrorDiagnostics } from "../../../error-diagnostics-D9n0ZmdN.js";
4
+ // src/task/runtime/providers/cloudflare.ts
5
5
  /** Resolve the Sandbox namespace from the bindings of the active Cloudflare request. */
6
6
  async function resolveCloudflareTaskSandbox(options) {
7
7
  const env = getActiveCloudflareEnv();
@@ -23,5 +23,4 @@ async function resolveCloudflareTaskSandbox(options) {
23
23
  }, requirements)
24
24
  };
25
25
  }
26
- //#endregion
27
26
  export { resolveCloudflareTaskSandbox };
@@ -1,8 +1,6 @@
1
- import { t as ResolvedTaskSandbox } from "../../../provider-loader-Cvqoz7_Z.js";
2
- //#region src/task/runtime/providers/local.d.ts
1
+ import { t as ResolvedTaskSandbox } from "../../../provider-loader-CLIIEEmR.js";
3
2
  /**
4
3
  * `vite dev` runs each Sandbox Task as a Node process on this machine, in a temporary directory that the run removes.
5
4
  * The process is not isolated: the Sandbox `executionAuthority` says `isolation: "none"`.
6
5
  */
7
- export declare function resolveLocalTaskSandbox(): ResolvedTaskSandbox;
8
- //#endregion
6
+ export declare function resolveLocalTaskSandbox(): ResolvedTaskSandbox;
@@ -1,6 +1,6 @@
1
- import { a as resolveRemoteSandboxRuntime } from "../../../remote-fjUPBiLJ.js";
2
- import { t as createTrustedHostRuntime } from "../../../trusted-host-DLYiKP8a.js";
3
- //#region src/task/runtime/providers/local.ts
1
+ import { a as resolveRemoteSandboxRuntime } from "../../../remote-DlyX1drC.js";
2
+ import { t as createTrustedHostRuntime } from "../../../trusted-host-CwMs64h1.js";
3
+ // src/task/runtime/providers/local.ts
4
4
  /**
5
5
  * `vite dev` runs each Sandbox Task as a Node process on this machine, in a temporary directory that the run removes.
6
6
  * The process is not isolated: the Sandbox `executionAuthority` says `isolation: "none"`.
@@ -11,5 +11,4 @@ function resolveLocalTaskSandbox() {
11
11
  resolveSandbox: async (requirements) => await resolveRemoteSandboxRuntime(createTrustedHostRuntime(), requirements)
12
12
  };
13
13
  }
14
- //#endregion
15
14
  export { resolveLocalTaskSandbox };
@@ -1,6 +1,5 @@
1
- import { l as Sandbox } from "../../../index-DHl0T43e.js";
2
- import { _ as VercelSandboxTaskDriverOptions, u as SandboxTaskDefinitionOptions } from "../../../module-types-NYnG3NGz.js";
3
- //#region src/task/runtime/providers/vercel.d.ts
1
+ import { l as Sandbox } from "../../../index-D9DogaoF.js";
2
+ import { u as SandboxTaskDefinitionOptions, v as VercelSandboxTaskDriverOptions } from "../../../module-types-DHr6oC3h.js";
4
3
  type SandboxTaskOptions = {
5
4
  local: SandboxTaskDefinitionOptions;
6
5
  provider: VercelSandboxTaskDriverOptions;
@@ -9,4 +8,4 @@ export declare function resolveVercelTaskSandbox(options: SandboxTaskOptions): P
9
8
  provider: "vercel";
10
9
  resolveSandbox: (requirements: readonly string[]) => Promise<Sandbox>;
11
10
  }>;
12
- //#endregion
11
+ export {};
@@ -1,9 +1,9 @@
1
- import { n as loadVercelSandbox } from "../../../vercel-qyDr7NvU.js";
2
1
  import { resolveVercelSandbox } from "../../../internal/vercel.js";
3
- import { t as sandboxTaskErrorDiagnostics } from "../../../error-diagnostics-BNQwU9yq.js";
4
- import "../../../provider-resolution-BrQfEQo0.js";
5
- import { o as resolveVercelSandboxTaskVcpus, t as vercelCredentialEnv } from "../../../vercel-credentials-BNTh2X-Y.js";
6
- //#region ../internal/src/env.ts
2
+ import { n as loadVercelSandbox } from "../../../vercel-DT74kDyI.js";
3
+ import { o as resolveVercelSandboxTaskVcpus, t as vercelCredentialEnv } from "../../../vercel-credentials-BH5lPJxs.js";
4
+ import { t as sandboxTaskErrorDiagnostics } from "../../../error-diagnostics-D9n0ZmdN.js";
5
+ import "../../../provider-resolution-qvRcW1PC.js";
6
+ // ../internal/src/env.ts
7
7
  function trimmed(value) {
8
8
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
9
9
  }
@@ -13,8 +13,7 @@ function readEnv(env, ...names) {
13
13
  if (value) return value;
14
14
  }
15
15
  }
16
- //#endregion
17
- //#region src/task/runtime/providers/vercel.ts
16
+ // src/task/runtime/providers/vercel.ts
18
17
  const VERCEL_TASK_SANDBOX_HEADROOM_MS = 3e4;
19
18
  function readConfigCredential(value) {
20
19
  return value?.trim() || void 0;
@@ -76,5 +75,4 @@ function withPlanLimitError(create) {
76
75
  function vercelTimeoutLimit(message) {
77
76
  return /`timeout` restricted to [^\n]+/.exec(message)?.[0];
78
77
  }
79
- //#endregion
80
78
  export { resolveVercelTaskSandbox };
@@ -1,6 +1,5 @@
1
- import { a as SandboxTaskDefinitionBundle, t as AgentSandboxTaskConfig, u as SandboxTaskDefinitionOptions } from "../../module-types-NYnG3NGz.js";
2
- import { t as ResolvedTaskSandbox } from "../../provider-loader-Cvqoz7_Z.js";
3
- //#region src/task/runtime/state.d.ts
1
+ import { a as SandboxTaskDefinitionBundle, t as AgentSandboxTaskConfig, u as SandboxTaskDefinitionOptions } from "../../module-types-DHr6oC3h.js";
2
+ import { t as ResolvedTaskSandbox } from "../../provider-loader-CLIIEEmR.js";
4
3
  export type SandboxTaskRegistryEntry = {
5
4
  bundle: SandboxTaskDefinitionBundle;
6
5
  options?: SandboxTaskDefinitionOptions;
@@ -25,4 +24,4 @@ export declare function getSandboxTaskRuntimeLocalProvider(): (() => Promise<Res
25
24
  export declare function setSandboxTaskRuntimeLocalProvider(provider: (() => Promise<ResolvedTaskSandbox>) | undefined): void;
26
25
  export declare function setSandboxTaskRuntimeRegistry(registry: SandboxTaskRuntimeRegistry | undefined): void;
27
26
  export declare function resetSandboxTaskRuntimeState(): void;
28
- //#endregion
27
+ export {};
@@ -1,6 +1,6 @@
1
- import { t as sandboxTaskErrorDiagnostics } from "../../error-diagnostics-BNQwU9yq.js";
1
+ import { t as sandboxTaskErrorDiagnostics } from "../../error-diagnostics-D9n0ZmdN.js";
2
2
  import { pathToFileURL } from "node:url";
3
- //#region src/task/runtime/state.ts
3
+ // src/task/runtime/state.ts
4
4
  let sandboxTaskConfig;
5
5
  let sandboxTaskLocalProvider;
6
6
  let sandboxTaskRegistry;
@@ -78,5 +78,4 @@ function resetSandboxTaskRuntimeState() {
78
78
  sandboxTaskRegistry = void 0;
79
79
  generatedRegistries.clear();
80
80
  }
81
- //#endregion
82
81
  export { createGeneratedSandboxTaskModuleSpecifier, createGeneratedSandboxTaskRuntimeRegistry, getSandboxTaskRuntimeConfig, getSandboxTaskRuntimeLocalProvider, getSandboxTaskRuntimeRegistry, resetSandboxTaskRuntimeState, setSandboxTaskRuntimeConfig, setSandboxTaskRuntimeLocalProvider, setSandboxTaskRuntimeRegistry };
@@ -1,10 +1,7 @@
1
- import { t as AgentSandboxTaskConfig } from "../module-types-NYnG3NGz.js";
1
+ import { t as AgentSandboxTaskConfig } from "../module-types-DHr6oC3h.js";
2
2
  import { Plugin } from "vite";
3
- //#region ../internal/src/deployment.d.ts
4
3
  /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
5
4
  type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
6
- //#endregion
7
- //#region ../internal/src/inspect.d.ts
8
5
  interface ViteHubDefinitionField {
9
6
  label: string;
10
7
  value: string;
@@ -66,8 +63,6 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
66
63
  interface ViteHubInspectionPluginMetadata {
67
64
  inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
68
65
  }
69
- //#endregion
70
- //#region ../internal/src/build/deployment-plan-output.d.ts
71
66
  /**
72
67
  * One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
73
68
  * a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
@@ -97,8 +92,6 @@ interface DeploymentEnvContext {
97
92
  * Return names only, never values.
98
93
  */
99
94
  type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
100
- //#endregion
101
- //#region src/task/internal/shared/feature-definitions.d.ts
102
95
  interface ScannedDefinition {
103
96
  name: string;
104
97
  handler: string;
@@ -107,8 +100,6 @@ interface ScannedDefinition {
107
100
  sourcePath: string;
108
101
  };
109
102
  }
110
- //#endregion
111
- //#region src/task/discovery.d.ts
112
103
  interface DiscoveredSandboxTaskDefinition extends ScannedDefinition {
113
104
  kind: 'definition' | 'package-entry';
114
105
  source: 'server-sandbox-tasks' | 'vite-suffix';
@@ -121,8 +112,6 @@ export declare function discoverSandboxTaskDefinitions(options: {
121
112
  mode: 'server-sandbox-tasks';
122
113
  scanDirs: string[];
123
114
  }): DiscoveredSandboxTaskDefinition[];
124
- //#endregion
125
- //#region ../internal/src/console.d.ts
126
115
  type MaybePromise<T> = T | Promise<T>;
127
116
  /** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
128
117
  interface ViteHubConsoleDefinitionCatalogView {
@@ -191,7 +180,7 @@ interface ViteHubConsoleOperationAction {
191
180
  operation: string;
192
181
  input: Readonly<Record<string, string>>;
193
182
  /**
194
- * The result is `{ url }`, such as a one-time link or a provider sign-in: the Console opens it in a new tab, and loads
183
+ * The result is `{ url }`, such as a provider sign-in: the Console opens it in a new tab, and loads
195
184
  * the list again when the person comes back. The URL must be `https:`, or `http:` on a loopback host.
196
185
  */
197
186
  tab?: true;
@@ -454,8 +443,6 @@ interface ViteHubConsoleDocumentSetup {
454
443
  */
455
444
  schedule?: ViteHubConsoleDocumentHint;
456
445
  }
457
- //#endregion
458
- //#region src/task/inspect.d.ts
459
446
  interface SandboxTaskInspectionOptions {
460
447
  projectRoot: string;
461
448
  rootDir: string;
@@ -464,9 +451,27 @@ interface SandboxTaskInspectionOptions {
464
451
  export declare function inspectSandboxTaskDefinitions(options: SandboxTaskInspectionOptions): ViteHubDefinitionSummary[];
465
452
  /** Console section that lists discovered Sandbox Task Definitions. `vitehub inspect definitions` reads the same data. */
466
453
  export declare const sandboxTaskConsoleSection: ViteHubConsoleSectionContribution<SandboxTaskInspectionOptions>;
467
- //#endregion
468
- //#region src/task/vite.d.ts
469
454
  export type SandboxTaskOptions = AgentSandboxTaskConfig | false;
455
+ type SandboxTaskNitroBuildConfig = {
456
+ builder: string;
457
+ rolldown?: {
458
+ resolve?: {
459
+ alias?: Record<string, string | string[] | false>;
460
+ };
461
+ };
462
+ };
463
+ type SandboxTaskNitroHost = {
464
+ hooks: {
465
+ hook(name: 'build:before', callback: () => void): void;
466
+ hook(name: 'build:config', callback: (nitro: unknown, config: SandboxTaskNitroBuildConfig) => void): void;
467
+ };
468
+ options: {
469
+ alias?: unknown;
470
+ dev?: boolean;
471
+ devServer?: unknown;
472
+ noExternals?: unknown;
473
+ };
474
+ };
470
475
  export type SandboxTaskVitePlugin = Plugin & {
471
476
  /** The variables that Sandbox Tasks read on the deployed host. See `sandboxDeploymentEnv()`. */
472
477
  api: {
@@ -475,16 +480,10 @@ export type SandboxTaskVitePlugin = Plugin & {
475
480
  vitehub: ViteHubInspectionPluginMetadata;
476
481
  nitro: {
477
482
  name: string;
478
- setup: (nitro: {
479
- hooks: {
480
- hook: (name: 'build:before', callback: () => void) => void;
481
- };
482
- options: Record<string, unknown>;
483
- }) => void;
483
+ setup: (nitro: SandboxTaskNitroHost) => void;
484
484
  };
485
485
  };
486
486
  /** The path of the Sandbox Task runtime state module. Generated code of other owners imports it by path. */
487
487
  export declare const sandboxTaskRuntimeStateModule: string;
488
488
  export declare function hubSandboxTask(options?: SandboxTaskOptions): SandboxTaskVitePlugin;
489
- //#endregion
490
489
  export type { DiscoveredSandboxTaskDefinition, SandboxTaskInspectionOptions };