@vite-hub/sandbox 0.0.1 → 0.0.3
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/README.md +35 -37
- package/dist/cloudflare-env-2NctU8i7.js +12 -0
- package/dist/index.d.ts +23 -32
- package/dist/index.js +688 -265
- package/dist/module-types-DfXe133f.d.ts +91 -0
- package/dist/provider-loader-hL7uHVWp.d.ts +21 -0
- package/dist/runtime/provider-loader.d.ts +2 -17
- package/dist/runtime/provider-loader.js +4 -10
- package/dist/runtime/providers/cloudflare.d.ts +5 -11
- package/dist/runtime/providers/cloudflare.js +14 -11
- package/dist/runtime/providers/vercel.d.ts +103 -12
- package/dist/runtime/providers/vercel.js +16 -30
- package/dist/runtime/state.d.ts +1 -1
- package/dist/vite.d.ts +12 -28
- package/dist/vite.js +2280 -354
- package/package.json +60 -59
- package/dist/_shared-CJ2_pS4E.js +0 -53
- package/dist/cloudflare-retry-Cfra7MvS.js +0 -21
- package/dist/common-CS4FcWrh.d.ts +0 -369
- package/dist/index-B4j3Mvzr.d.ts +0 -146
- package/dist/integration-wkNE8jMO.js +0 -2032
- package/dist/module-types-CUcY8iuI.d.ts +0 -88
- package/dist/nitro.d.ts +0 -19
- package/dist/nitro.js +0 -488
- package/dist/provider-detection-IbezCeoR.js +0 -25
- package/dist/runtime/nitro-plugin.d.ts +0 -4
- package/dist/runtime/nitro-plugin.js +0 -8
- package/dist/sandbox/providers/cloudflare.d.ts +0 -7
- package/dist/sandbox/providers/cloudflare.js +0 -339
- package/dist/sandbox/providers/vercel.d.ts +0 -17
- package/dist/sandbox/providers/vercel.js +0 -538
- package/dist/shared-pqTHYWg1.d.ts +0 -8
- package/dist/utils-V7ODsDW_.js +0 -44
- package/dist/vercel-runtime-BPzvh_6V.js +0 -11
- /package/dist/{module-types-BomzaqnM.js → module-types-Dj1MFmHT.js} +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ViteHubError } from "@vite-hub/runtime";
|
|
2
|
+
import { VercelBoxNetworkPolicy, VercelBoxSource } from "@vite-hub/box";
|
|
3
|
+
|
|
4
|
+
//#region src/project.d.ts
|
|
5
|
+
type SandboxPackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
|
|
6
|
+
interface SandboxProjectFile {
|
|
7
|
+
contents: string;
|
|
8
|
+
encoding: 'base64';
|
|
9
|
+
mode?: number;
|
|
10
|
+
}
|
|
11
|
+
interface SandboxProject {
|
|
12
|
+
digest: string;
|
|
13
|
+
files: Record<string, SandboxProjectFile>;
|
|
14
|
+
install: {
|
|
15
|
+
args: string[];
|
|
16
|
+
command: SandboxPackageManager;
|
|
17
|
+
cwd: string;
|
|
18
|
+
};
|
|
19
|
+
options?: SandboxProjectOptions;
|
|
20
|
+
packagePath: string;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/module-types.d.ts
|
|
24
|
+
type SandboxProvider = 'cloudflare' | 'vercel';
|
|
25
|
+
interface CloudflareSandboxOptions {
|
|
26
|
+
sleepAfter?: string | number;
|
|
27
|
+
keepAlive?: boolean;
|
|
28
|
+
normalizeId?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface VercelSandboxProviderOptions {
|
|
31
|
+
provider: 'vercel';
|
|
32
|
+
runtime?: string;
|
|
33
|
+
timeout?: number;
|
|
34
|
+
cpu?: number;
|
|
35
|
+
ports?: number[];
|
|
36
|
+
source?: VercelBoxSource;
|
|
37
|
+
networkPolicy?: VercelBoxNetworkPolicy;
|
|
38
|
+
token?: string;
|
|
39
|
+
teamId?: string;
|
|
40
|
+
projectId?: string;
|
|
41
|
+
}
|
|
42
|
+
interface CloudflareSandboxDefinitionProviderOptions {
|
|
43
|
+
provider: 'cloudflare';
|
|
44
|
+
binding?: string;
|
|
45
|
+
className?: string;
|
|
46
|
+
migrationTag?: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
sandboxId?: string;
|
|
49
|
+
sleepAfter?: CloudflareSandboxOptions['sleepAfter'];
|
|
50
|
+
keepAlive?: CloudflareSandboxOptions['keepAlive'];
|
|
51
|
+
normalizeId?: CloudflareSandboxOptions['normalizeId'];
|
|
52
|
+
}
|
|
53
|
+
type SandboxDefinitionProviderOptions = VercelSandboxProviderOptions | CloudflareSandboxDefinitionProviderOptions;
|
|
54
|
+
type AgentSandboxConfig = SandboxDefinitionProviderOptions | {
|
|
55
|
+
provider?: undefined;
|
|
56
|
+
name?: string;
|
|
57
|
+
};
|
|
58
|
+
interface SandboxDefinitionBundle {
|
|
59
|
+
entry: string;
|
|
60
|
+
execution?: 'definition' | 'module';
|
|
61
|
+
modules: Record<string, string>;
|
|
62
|
+
project?: SandboxProject;
|
|
63
|
+
}
|
|
64
|
+
interface SandboxExecutionOptions {
|
|
65
|
+
context?: Record<string, unknown>;
|
|
66
|
+
sandboxId?: string;
|
|
67
|
+
}
|
|
68
|
+
type SandboxDefinitionHandler<TPayload = unknown, TResult = unknown> = (payload?: TPayload, context?: Record<string, unknown>) => TResult | Promise<TResult>;
|
|
69
|
+
type SandboxDefinitionPayload<THandler extends (...args: any[]) => any> = Parameters<THandler> extends [infer TPayload, ...unknown[]] ? TPayload : unknown;
|
|
70
|
+
type SandboxDefinitionResult<THandler extends (...args: any[]) => any> = Awaited<ReturnType<THandler>>;
|
|
71
|
+
interface SandboxDefinitionOptions {
|
|
72
|
+
timeout?: number;
|
|
73
|
+
env?: Record<string, string>;
|
|
74
|
+
}
|
|
75
|
+
interface SandboxProjectOptions {
|
|
76
|
+
timeout?: number;
|
|
77
|
+
}
|
|
78
|
+
interface SandboxDefinitionInput<TPayload = unknown, TResult = unknown> extends SandboxDefinitionOptions {
|
|
79
|
+
run: SandboxDefinitionHandler<TPayload, TResult>;
|
|
80
|
+
}
|
|
81
|
+
interface SandboxDefinition<TPayload = unknown, TResult = unknown> {
|
|
82
|
+
run: SandboxDefinitionHandler<TPayload, TResult>;
|
|
83
|
+
options?: SandboxDefinitionOptions;
|
|
84
|
+
}
|
|
85
|
+
type SandboxDefinitionFromHandler<THandler extends (...args: any[]) => any> = SandboxDefinition<SandboxDefinitionPayload<THandler>, SandboxDefinitionResult<THandler>> & {
|
|
86
|
+
run: THandler;
|
|
87
|
+
};
|
|
88
|
+
type SandboxRunResult<TResult = unknown> = [error: null, value: TResult] | [error: ViteHubError<`SANDBOX_${string}`>, value: undefined];
|
|
89
|
+
declare function getSandboxFeatureProvider(config?: AgentSandboxConfig | false): SandboxDefinitionProviderOptions | undefined;
|
|
90
|
+
//#endregion
|
|
91
|
+
export { SandboxDefinitionBundle as a, SandboxDefinitionInput as c, SandboxExecutionOptions as d, SandboxProjectOptions as f, getSandboxFeatureProvider as g, VercelSandboxProviderOptions as h, SandboxDefinition as i, SandboxDefinitionOptions as l, SandboxRunResult as m, CloudflareSandboxDefinitionProviderOptions as n, SandboxDefinitionFromHandler as o, SandboxProvider as p, CloudflareSandboxOptions as r, SandboxDefinitionHandler as s, AgentSandboxConfig as t, SandboxDefinitionProviderOptions as u };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { l as SandboxDefinitionOptions, p as SandboxProvider, u as SandboxDefinitionProviderOptions } from "./module-types-DfXe133f.js";
|
|
2
|
+
import { Box } from "@vite-hub/box";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/provider-loader.d.ts
|
|
5
|
+
interface ResolvedSandboxBox {
|
|
6
|
+
closeAfterRun?: boolean;
|
|
7
|
+
provider: SandboxProvider;
|
|
8
|
+
resolveBox: (requirements: readonly string[]) => Promise<Box>;
|
|
9
|
+
sandboxId?: string;
|
|
10
|
+
}
|
|
11
|
+
interface SandboxRuntimeProvider {
|
|
12
|
+
resolveSandboxBox: (options: {
|
|
13
|
+
local: SandboxDefinitionOptions;
|
|
14
|
+
provider: SandboxDefinitionProviderOptions & {
|
|
15
|
+
provider: SandboxProvider;
|
|
16
|
+
};
|
|
17
|
+
} | any, context?: any) => Promise<ResolvedSandboxBox>;
|
|
18
|
+
}
|
|
19
|
+
declare function loadSandboxRuntimeProvider(provider: SandboxProvider): Promise<SandboxRuntimeProvider>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { SandboxRuntimeProvider as n, loadSandboxRuntimeProvider as r, ResolvedSandboxBox as t };
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { c as SandboxDefinitionProviderOptions, s as SandboxDefinitionOptions } from "../module-types-CUcY8iuI.js";
|
|
4
|
-
|
|
5
|
-
//#region src/runtime/provider-loader.d.ts
|
|
6
|
-
interface SandboxRuntimeProvider {
|
|
7
|
-
resolveSandboxProvider: (options: {
|
|
8
|
-
local: SandboxDefinitionOptions;
|
|
9
|
-
provider: SandboxDefinitionProviderOptions & {
|
|
10
|
-
provider: SandboxProvider;
|
|
11
|
-
};
|
|
12
|
-
} | any, context?: any) => Promise<SandboxProviderOptions>;
|
|
13
|
-
createSandboxClient: (provider: SandboxProviderOptions | any) => Promise<SandboxClient>;
|
|
14
|
-
}
|
|
15
|
-
declare function loadSandboxRuntimeProvider(provider: SandboxProvider): Promise<SandboxRuntimeProvider>;
|
|
16
|
-
//#endregion
|
|
17
|
-
export { SandboxRuntimeProvider, loadSandboxRuntimeProvider };
|
|
1
|
+
import { n as SandboxRuntimeProvider, r as loadSandboxRuntimeProvider, t as ResolvedSandboxBox } from "../provider-loader-hL7uHVWp.js";
|
|
2
|
+
export { ResolvedSandboxBox, SandboxRuntimeProvider, loadSandboxRuntimeProvider };
|
|
@@ -2,18 +2,12 @@
|
|
|
2
2
|
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
3
3
|
async function loadSandboxRuntimeProvider(provider) {
|
|
4
4
|
if (provider === "cloudflare") {
|
|
5
|
-
const
|
|
6
|
-
return {
|
|
7
|
-
resolveSandboxProvider,
|
|
8
|
-
createSandboxClient: createCloudflareSandboxClient
|
|
9
|
-
};
|
|
5
|
+
const { resolveCloudflareSandboxBox } = await dynamicImport("./providers/cloudflare.js");
|
|
6
|
+
return { resolveSandboxBox: resolveCloudflareSandboxBox };
|
|
10
7
|
}
|
|
11
8
|
if (provider === "vercel") {
|
|
12
|
-
const
|
|
13
|
-
return {
|
|
14
|
-
resolveSandboxProvider,
|
|
15
|
-
createSandboxClient: createVercelSandboxClient
|
|
16
|
-
};
|
|
9
|
+
const { resolveVercelSandboxBox } = await dynamicImport("./providers/vercel.js");
|
|
10
|
+
return { resolveSandboxBox: resolveVercelSandboxBox };
|
|
17
11
|
}
|
|
18
12
|
throw new Error(`[vitehub] Unsupported sandbox provider: ${provider}`);
|
|
19
13
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as CloudflareSandboxDefinitionProviderOptions, s as SandboxDefinitionOptions } from "../../module-types-CUcY8iuI.js";
|
|
1
|
+
import { l as SandboxDefinitionOptions, n as CloudflareSandboxDefinitionProviderOptions } from "../../module-types-DfXe133f.js";
|
|
3
2
|
|
|
4
3
|
//#region src/runtime/providers/cloudflare.d.ts
|
|
5
4
|
type SandboxOptions = {
|
|
@@ -18,18 +17,13 @@ type SandboxEvent = {
|
|
|
18
17
|
};
|
|
19
18
|
};
|
|
20
19
|
};
|
|
21
|
-
declare function
|
|
20
|
+
declare function resolveCloudflareSandboxBox(options: SandboxOptions, context?: {
|
|
22
21
|
event?: SandboxEvent;
|
|
23
22
|
}): Promise<{
|
|
23
|
+
closeAfterRun: boolean;
|
|
24
24
|
provider: "cloudflare";
|
|
25
|
-
namespace: DurableObjectNamespaceLike;
|
|
26
25
|
sandboxId: string | undefined;
|
|
27
|
-
|
|
28
|
-
sleepAfter: string | number | undefined;
|
|
29
|
-
keepAlive: boolean | undefined;
|
|
30
|
-
normalizeId: boolean | undefined;
|
|
31
|
-
};
|
|
32
|
-
getSandbox: (ns: DurableObjectNamespaceLike, sandboxId: string, opts?: CloudflareSandboxOptions) => CloudflareSandboxStub;
|
|
26
|
+
resolveBox: (requirements: readonly string[]) => Promise<import("@vite-hub/box").Box>;
|
|
33
27
|
}>;
|
|
34
28
|
//#endregion
|
|
35
|
-
export {
|
|
29
|
+
export { resolveCloudflareSandboxBox };
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as getCloudflareEnv } from "../../cloudflare-env-2NctU8i7.js";
|
|
2
|
+
import { resolveCloudflareBox } from "@vite-hub/box/_internal/cloudflare";
|
|
3
3
|
//#region src/runtime/providers/cloudflare.ts
|
|
4
|
-
async function
|
|
4
|
+
async function resolveCloudflareSandboxBox(options, context = {}) {
|
|
5
5
|
const env = getCloudflareEnv(context.event);
|
|
6
6
|
const bindingName = options.provider.binding || "SANDBOX";
|
|
7
7
|
const namespace = env?.[bindingName];
|
|
8
8
|
if (!namespace) throw new Error(`Cloudflare sandbox requires the "${bindingName}" binding. Set sandbox.binding or run inside Cloudflare.`);
|
|
9
9
|
return {
|
|
10
|
+
closeAfterRun: options.provider.keepAlive === true,
|
|
10
11
|
provider: "cloudflare",
|
|
11
|
-
namespace,
|
|
12
12
|
sandboxId: options.provider.sandboxId,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
resolveBox: async (requirements) => await resolveCloudflareBox({
|
|
14
|
+
namespace,
|
|
15
|
+
sandboxId: options.provider.sandboxId,
|
|
16
|
+
cloudflare: {
|
|
17
|
+
sleepAfter: options.provider.sleepAfter ?? "5m",
|
|
18
|
+
keepAlive: options.provider.keepAlive,
|
|
19
|
+
normalizeId: options.provider.normalizeId
|
|
20
|
+
}
|
|
21
|
+
}, requirements)
|
|
19
22
|
};
|
|
20
23
|
}
|
|
21
24
|
//#endregion
|
|
22
|
-
export {
|
|
25
|
+
export { resolveCloudflareSandboxBox };
|
|
@@ -1,21 +1,112 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { s as SandboxDefinitionOptions } from "../../module-types-CUcY8iuI.js";
|
|
1
|
+
import { h as VercelSandboxProviderOptions, l as SandboxDefinitionOptions } from "../../module-types-DfXe133f.js";
|
|
2
|
+
import { ExecutionAuthority } from "@vite-hub/runtime";
|
|
4
3
|
|
|
4
|
+
//#region ../box/dist/index-B2Wqvvhr.d.ts
|
|
5
|
+
interface BoxOpenOptions {
|
|
6
|
+
id?: string;
|
|
7
|
+
initialize?: (session: BoxSession, context: {
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
interface BoxExecOptions {
|
|
13
|
+
cwd?: string;
|
|
14
|
+
env?: Readonly<Record<string, string>>;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
}
|
|
18
|
+
interface BoxExecResult {
|
|
19
|
+
readonly code: number;
|
|
20
|
+
readonly ok: boolean;
|
|
21
|
+
readonly stderr: string;
|
|
22
|
+
readonly stdout: string;
|
|
23
|
+
}
|
|
24
|
+
interface BoxProcessExit {
|
|
25
|
+
readonly code: number;
|
|
26
|
+
}
|
|
27
|
+
interface BoxProcess {
|
|
28
|
+
readonly pid?: number;
|
|
29
|
+
readonly stderr: ReadableStream<Uint8Array>;
|
|
30
|
+
readonly stdout: ReadableStream<Uint8Array>;
|
|
31
|
+
kill(signal?: string): Promise<void>;
|
|
32
|
+
wait(): Promise<BoxProcessExit>;
|
|
33
|
+
}
|
|
34
|
+
interface BoxFileEntry {
|
|
35
|
+
readonly path: string;
|
|
36
|
+
readonly size?: number;
|
|
37
|
+
readonly type: "directory" | "file" | "symlink";
|
|
38
|
+
}
|
|
39
|
+
interface BoxFileOptions {
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
}
|
|
42
|
+
interface BoxListFilesOptions extends BoxFileOptions {
|
|
43
|
+
recursive?: boolean;
|
|
44
|
+
}
|
|
45
|
+
interface BoxRemoveFileOptions extends BoxFileOptions {
|
|
46
|
+
recursive?: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface BoxFiles {
|
|
49
|
+
exists(path: string, options?: BoxFileOptions): Promise<boolean>;
|
|
50
|
+
list(path: string, options?: BoxListFilesOptions): Promise<readonly BoxFileEntry[]>;
|
|
51
|
+
mkdir(path: string, options?: BoxFileOptions & {
|
|
52
|
+
recursive?: boolean;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
move?(source: string, destination: string, options?: BoxFileOptions): Promise<void>;
|
|
55
|
+
read(path: string, options?: BoxFileOptions): Promise<Uint8Array | null>;
|
|
56
|
+
remove(path: string, options?: BoxRemoveFileOptions): Promise<void>;
|
|
57
|
+
write(path: string, contents: Uint8Array, options?: BoxFileOptions): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
interface BoxPorts {
|
|
60
|
+
readonly values: readonly number[];
|
|
61
|
+
expose(port: number, options?: {
|
|
62
|
+
protocol?: "http" | "https" | "ws";
|
|
63
|
+
}): Promise<URL>;
|
|
64
|
+
}
|
|
65
|
+
interface BoxSession {
|
|
66
|
+
readonly cwd: string;
|
|
67
|
+
readonly executionAuthority: ExecutionAuthority;
|
|
68
|
+
readonly files: BoxFiles;
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly ports?: BoxPorts;
|
|
71
|
+
readonly spawn?: (command: string, args?: readonly string[], options?: BoxExecOptions) => Promise<BoxProcess>;
|
|
72
|
+
close(): Promise<void>;
|
|
73
|
+
exec(command: string, args?: readonly string[], options?: BoxExecOptions): Promise<BoxExecResult>;
|
|
74
|
+
}
|
|
75
|
+
interface BoxEnvironment {
|
|
76
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
77
|
+
}
|
|
78
|
+
interface BoxResolvedRequirement {
|
|
79
|
+
readonly command: string;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
}
|
|
82
|
+
interface BoxPlan {
|
|
83
|
+
readonly cache: {
|
|
84
|
+
readonly state: "disposable";
|
|
85
|
+
};
|
|
86
|
+
readonly environment: BoxEnvironment;
|
|
87
|
+
readonly executionAuthority: ExecutionAuthority;
|
|
88
|
+
readonly identity: string;
|
|
89
|
+
readonly requirements: readonly BoxResolvedRequirement[];
|
|
90
|
+
readonly runtime: string;
|
|
91
|
+
readonly workspace: {
|
|
92
|
+
readonly path?: string;
|
|
93
|
+
readonly state: "authoritative" | "disposable";
|
|
94
|
+
readonly workDir?: "." | "workspace";
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
interface Box {
|
|
98
|
+
readonly plan: BoxPlan;
|
|
99
|
+
open(options?: BoxOpenOptions): Promise<BoxSession>;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
5
102
|
//#region src/runtime/providers/vercel.d.ts
|
|
6
103
|
type SandboxOptions = {
|
|
7
104
|
local: SandboxDefinitionOptions;
|
|
8
105
|
provider: VercelSandboxProviderOptions;
|
|
9
106
|
};
|
|
10
|
-
declare function
|
|
107
|
+
declare function resolveVercelSandboxBox(options: SandboxOptions): Promise<{
|
|
11
108
|
provider: "vercel";
|
|
12
|
-
|
|
13
|
-
timeout: number | undefined;
|
|
14
|
-
cpu: number | undefined;
|
|
15
|
-
ports: number[] | undefined;
|
|
16
|
-
credentials: ResolvedVercelSandboxCredentials | undefined;
|
|
17
|
-
source: VercelSandboxSource | undefined;
|
|
18
|
-
networkPolicy: SandboxNetworkPolicy | undefined;
|
|
109
|
+
resolveBox: (requirements: readonly string[]) => Promise<Box>;
|
|
19
110
|
}>;
|
|
20
111
|
//#endregion
|
|
21
|
-
export {
|
|
112
|
+
export { resolveVercelSandboxBox };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveVercelBox } from "@vite-hub/box/_internal/vercel";
|
|
2
2
|
//#region src/internal/shared/env.ts
|
|
3
3
|
function readNonEmptyEnv(env, ...keys) {
|
|
4
4
|
for (const key of keys) {
|
|
@@ -6,9 +6,6 @@ function readNonEmptyEnv(env, ...keys) {
|
|
|
6
6
|
if (trimmed) return trimmed;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
function readFrameworkEnv(env, options) {
|
|
10
|
-
return readNonEmptyEnv(env, ...options.nitro || [], ...options.nuxt || [], ...options.vite || [], ...options.plain || []);
|
|
11
|
-
}
|
|
12
9
|
//#endregion
|
|
13
10
|
//#region src/runtime/providers/vercel.ts
|
|
14
11
|
function readConfigCredential(value) {
|
|
@@ -17,24 +14,9 @@ function readConfigCredential(value) {
|
|
|
17
14
|
function resolveEnvCredentials() {
|
|
18
15
|
const env = typeof process !== "undefined" ? process.env : {};
|
|
19
16
|
return {
|
|
20
|
-
token:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
vite: ["VITE_SANDBOX_TOKEN"],
|
|
24
|
-
plain: ["VERCEL_TOKEN"]
|
|
25
|
-
}),
|
|
26
|
-
teamId: readFrameworkEnv(env, {
|
|
27
|
-
nitro: ["NITRO_SANDBOX_TEAM_ID"],
|
|
28
|
-
nuxt: ["NUXT_SANDBOX_TEAM_ID"],
|
|
29
|
-
vite: ["VITE_SANDBOX_TEAM_ID"],
|
|
30
|
-
plain: ["VERCEL_TEAM_ID"]
|
|
31
|
-
}),
|
|
32
|
-
projectId: readFrameworkEnv(env, {
|
|
33
|
-
nitro: ["NITRO_SANDBOX_PROJECT_ID"],
|
|
34
|
-
nuxt: ["NUXT_SANDBOX_PROJECT_ID"],
|
|
35
|
-
vite: ["VITE_SANDBOX_PROJECT_ID"],
|
|
36
|
-
plain: ["VERCEL_PROJECT_ID"]
|
|
37
|
-
})
|
|
17
|
+
token: readNonEmptyEnv(env, "VITE_SANDBOX_TOKEN", "VERCEL_TOKEN"),
|
|
18
|
+
teamId: readNonEmptyEnv(env, "VITE_SANDBOX_TEAM_ID", "VERCEL_TEAM_ID"),
|
|
19
|
+
projectId: readNonEmptyEnv(env, "VITE_SANDBOX_PROJECT_ID", "VERCEL_PROJECT_ID")
|
|
38
20
|
};
|
|
39
21
|
}
|
|
40
22
|
function resolveCredentials(provider) {
|
|
@@ -49,17 +31,21 @@ function resolveCredentials(provider) {
|
|
|
49
31
|
projectId
|
|
50
32
|
};
|
|
51
33
|
}
|
|
52
|
-
async function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
runtime:
|
|
56
|
-
timeout: typeof options.local.timeout === "number" ? options.local.timeout :
|
|
34
|
+
async function resolveVercelSandboxBox(options) {
|
|
35
|
+
const credentials = resolveCredentials(options.provider);
|
|
36
|
+
const boxOptions = {
|
|
37
|
+
runtime: options.provider.runtime || "node24",
|
|
38
|
+
timeout: typeof options.local.timeout === "number" ? options.local.timeout : options.provider.timeout,
|
|
57
39
|
cpu: options.provider.cpu,
|
|
58
40
|
ports: options.provider.ports,
|
|
59
|
-
credentials: resolveCredentials(options.provider),
|
|
60
41
|
source: options.provider.source,
|
|
61
|
-
networkPolicy: options.provider.networkPolicy
|
|
42
|
+
networkPolicy: options.provider.networkPolicy,
|
|
43
|
+
...credentials
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
provider: "vercel",
|
|
47
|
+
resolveBox: async (requirements) => await resolveVercelBox(boxOptions, requirements)
|
|
62
48
|
};
|
|
63
49
|
}
|
|
64
50
|
//#endregion
|
|
65
|
-
export {
|
|
51
|
+
export { resolveVercelSandboxBox };
|
package/dist/runtime/state.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SandboxDefinitionBundle, l as SandboxDefinitionOptions, t as AgentSandboxConfig } from "../module-types-DfXe133f.js";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/state.d.ts
|
|
4
4
|
type SandboxRegistryEntry = {
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
import { t as AgentSandboxConfig } from "./module-types-
|
|
2
|
-
import { ScanDir } from "unimport";
|
|
3
|
-
import { NitroModule } from "nitro/types";
|
|
1
|
+
import { t as AgentSandboxConfig } from "./module-types-DfXe133f.js";
|
|
4
2
|
import { Plugin } from "vite";
|
|
5
3
|
|
|
6
|
-
//#region src/integration.d.ts
|
|
7
|
-
type SandboxPublicOptions = AgentSandboxConfig | false;
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/internal/shared/server-imports.d.ts
|
|
10
|
-
type NitroImportsOptions = false | {
|
|
11
|
-
autoImport?: boolean;
|
|
12
|
-
dirs?: Array<string | ScanDir>;
|
|
13
|
-
presets?: unknown[];
|
|
14
|
-
} | undefined;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/internal/shared/vitehub-server-imports.d.ts
|
|
17
|
-
type ViteHubFeatureName = 'blob' | 'browser' | 'cache' | 'analytics' | 'cron' | 'db' | 'email' | 'kv' | 'queue' | 'sandbox' | 'vector' | 'workflow';
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/internal/shared/vitehub-auto-imports.d.ts
|
|
20
|
-
interface ViteHubDefinitionAutoImportsPluginOptions {
|
|
21
|
-
rootDir?: string;
|
|
22
|
-
scanRoots?: string[];
|
|
23
|
-
features?: ViteHubFeatureName[];
|
|
24
|
-
include?: RegExp;
|
|
25
|
-
nitroImports?: NitroImportsOptions;
|
|
26
|
-
}
|
|
27
|
-
declare function createViteHubDefinitionAutoImportsPlugin(options?: ViteHubDefinitionAutoImportsPluginOptions): Plugin;
|
|
28
|
-
//#endregion
|
|
29
4
|
//#region src/vite.d.ts
|
|
5
|
+
type SandboxPublicOptions = AgentSandboxConfig | false;
|
|
30
6
|
type SandboxVitePlugin = Plugin & {
|
|
31
|
-
nitro:
|
|
7
|
+
nitro: {
|
|
8
|
+
name: string;
|
|
9
|
+
setup: (nitro: {
|
|
10
|
+
hooks: {
|
|
11
|
+
hook: (name: 'build:before', callback: () => void) => void;
|
|
12
|
+
};
|
|
13
|
+
options: Record<string, unknown>;
|
|
14
|
+
}) => void;
|
|
15
|
+
};
|
|
32
16
|
};
|
|
33
17
|
declare function hubSandbox(options?: SandboxPublicOptions): SandboxVitePlugin;
|
|
34
18
|
declare module 'vite' {
|
|
@@ -37,4 +21,4 @@ declare module 'vite' {
|
|
|
37
21
|
}
|
|
38
22
|
}
|
|
39
23
|
//#endregion
|
|
40
|
-
export {
|
|
24
|
+
export { SandboxPublicOptions, SandboxVitePlugin, hubSandbox };
|