@vite-hub/sandbox 0.0.4 → 0.3.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/README.md +395 -37
- package/dist/abortable-CR01hzfi.js +57 -0
- package/dist/cloudflare-Cog_r2Me.js +910 -0
- package/dist/cloudflare-env-lookup-DzI6Xv1Y.js +16 -0
- package/dist/cloudflare-failure-CFQhalfh.js +50 -0
- package/dist/container-CqfD8yuE.js +868 -0
- package/dist/crabbox-sbV3Zjuo.js +1110 -0
- package/dist/error-diagnostics-5QT_BjbQ.js +354 -0
- package/dist/error-diagnostics-BJtLRL9w.js +536 -0
- package/dist/file-listing-CHtRrfo1.js +26 -0
- package/dist/file-lock-D0-XPogS.js +74 -0
- package/dist/index-DsoQAUb7.d.ts +594 -0
- package/dist/index.d.ts +2 -69
- package/dist/index.js +281 -1182
- package/dist/internal/cloudflare.d.ts +176 -0
- package/dist/internal/cloudflare.js +8 -0
- package/dist/internal/host-toolchain.d.ts +22 -0
- package/dist/internal/host-toolchain.js +96 -0
- package/dist/internal/vercel.d.ts +4 -0
- package/dist/internal/vercel.js +8 -0
- package/dist/invariant-DolT9EEx.js +22 -0
- package/dist/module-types-B0LQ5H2S.js +7 -0
- package/dist/module-types-DCeJbS9Z.d.ts +110 -0
- package/dist/process-sweep-CMaujWE5.js +33 -0
- package/dist/provider-resolution-C6AQzuFG.js +133 -0
- package/dist/remote-70ZVZZlq.js +265 -0
- package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
- package/dist/runtime-DHp6ImeP.js +32 -0
- package/dist/runtime-type-Deo4qzxN.js +9 -0
- package/dist/session-e0lyzjJ3.js +338 -0
- package/dist/shell-quote-Q3u3plif.js +6 -0
- package/dist/size-7AkVwGZb.js +118 -0
- package/dist/ssh.d.ts +63 -0
- package/dist/ssh.js +286 -0
- package/dist/task/index.d.ts +69 -0
- package/dist/task/index.js +1414 -0
- package/dist/task/runtime/empty-registry.d.ts +6 -0
- package/dist/{runtime → task/runtime}/empty-registry.js +2 -2
- package/dist/task/runtime/provider-loader.d.ts +18 -0
- package/dist/task/runtime/provider-loader.js +16 -0
- package/dist/task/runtime/providers/cloudflare.d.ts +14 -0
- package/dist/task/runtime/providers/cloudflare.js +27 -0
- package/dist/task/runtime/providers/vercel.d.ts +12 -0
- package/dist/task/runtime/providers/vercel.js +85 -0
- package/dist/task/runtime/state.d.ts +27 -0
- package/dist/task/runtime/state.js +82 -0
- package/dist/task/vite.d.ts +486 -0
- package/dist/task/vite.js +3966 -0
- package/dist/toolchain-BIVGMRty.js +528 -0
- package/dist/trusted-host-kxkpaQcs.js +714 -0
- package/dist/vercel-BGGrNpza.js +352 -0
- package/package.json +105 -51
- package/dist/cloudflare-env-QQV4uzCT.js +0 -14
- package/dist/module-types-DKYItiOu.d.ts +0 -93
- package/dist/module-types-Dj1MFmHT.js +0 -7
- package/dist/provider-loader-D0UihePq.d.ts +0 -21
- package/dist/runtime/empty-registry.d.ts +0 -6
- package/dist/runtime/provider-loader.d.ts +0 -2
- package/dist/runtime/provider-loader.js +0 -15
- package/dist/runtime/providers/cloudflare.d.ts +0 -29
- package/dist/runtime/providers/cloudflare.js +0 -25
- package/dist/runtime/providers/vercel.d.ts +0 -121
- package/dist/runtime/providers/vercel.js +0 -51
- package/dist/runtime/state.d.ts +0 -26
- package/dist/runtime/state.js +0 -72
- package/dist/vite.d.ts +0 -48
- package/dist/vite.js +0 -3324
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { l as SandboxDefinitionOptions, p as SandboxProvider, u as SandboxDefinitionProviderOptions } from "./module-types-DKYItiOu.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,15 +0,0 @@
|
|
|
1
|
-
//#region src/runtime/provider-loader.ts
|
|
2
|
-
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
3
|
-
async function loadSandboxRuntimeProvider(provider) {
|
|
4
|
-
if (provider === "cloudflare") {
|
|
5
|
-
const { resolveCloudflareSandboxBox } = await dynamicImport("./providers/cloudflare.js");
|
|
6
|
-
return { resolveSandboxBox: resolveCloudflareSandboxBox };
|
|
7
|
-
}
|
|
8
|
-
if (provider === "vercel") {
|
|
9
|
-
const { resolveVercelSandboxBox } = await dynamicImport("./providers/vercel.js");
|
|
10
|
-
return { resolveSandboxBox: resolveVercelSandboxBox };
|
|
11
|
-
}
|
|
12
|
-
throw new Error(`[vitehub] Unsupported sandbox provider: ${provider}`);
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { loadSandboxRuntimeProvider };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { l as SandboxDefinitionOptions, n as CloudflareSandboxDefinitionProviderOptions } from "../../module-types-DKYItiOu.js";
|
|
2
|
-
|
|
3
|
-
//#region src/runtime/providers/cloudflare.d.ts
|
|
4
|
-
type SandboxOptions = {
|
|
5
|
-
local: SandboxDefinitionOptions;
|
|
6
|
-
provider: CloudflareSandboxDefinitionProviderOptions;
|
|
7
|
-
};
|
|
8
|
-
type SandboxEvent = {
|
|
9
|
-
context?: {
|
|
10
|
-
cloudflare?: {
|
|
11
|
-
env?: Record<string, unknown>;
|
|
12
|
-
};
|
|
13
|
-
_platform?: {
|
|
14
|
-
cloudflare?: {
|
|
15
|
-
env?: Record<string, unknown>;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
declare function resolveCloudflareSandboxBox(options: SandboxOptions, context?: {
|
|
21
|
-
event?: SandboxEvent;
|
|
22
|
-
}): Promise<{
|
|
23
|
-
closeAfterRun: boolean;
|
|
24
|
-
provider: "cloudflare";
|
|
25
|
-
sandboxId: string | undefined;
|
|
26
|
-
resolveBox: (requirements: readonly string[]) => Promise<import("@vite-hub/box").Box>;
|
|
27
|
-
}>;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { resolveCloudflareSandboxBox };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { t as getCloudflareEnv } from "../../cloudflare-env-QQV4uzCT.js";
|
|
2
|
-
import { resolveCloudflareBox } from "@vite-hub/box/_internal/cloudflare";
|
|
3
|
-
//#region src/runtime/providers/cloudflare.ts
|
|
4
|
-
async function resolveCloudflareSandboxBox(options, context = {}) {
|
|
5
|
-
const env = getCloudflareEnv(context.event);
|
|
6
|
-
const bindingName = options.provider.binding || "SANDBOX";
|
|
7
|
-
const namespace = env?.[bindingName];
|
|
8
|
-
if (!namespace) throw new Error(`Cloudflare sandbox requires the "${bindingName}" binding. Set sandbox.binding or run inside Cloudflare.`);
|
|
9
|
-
return {
|
|
10
|
-
closeAfterRun: options.provider.keepAlive === true,
|
|
11
|
-
provider: "cloudflare",
|
|
12
|
-
sandboxId: options.provider.sandboxId,
|
|
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)
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { resolveCloudflareSandboxBox };
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { h as VercelSandboxProviderOptions, l as SandboxDefinitionOptions } from "../../module-types-DKYItiOu.js";
|
|
2
|
-
import { ExecutionAuthority } from "@vite-hub/runtime";
|
|
3
|
-
|
|
4
|
-
//#region ../box/dist/index-C37Q7osK.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
|
-
exclude?: readonly string[];
|
|
44
|
-
recursive?: boolean;
|
|
45
|
-
}
|
|
46
|
-
interface BoxRemoveFileOptions extends BoxFileOptions {
|
|
47
|
-
recursive?: boolean;
|
|
48
|
-
}
|
|
49
|
-
interface BoxFiles {
|
|
50
|
-
exists(path: string, options?: BoxFileOptions): Promise<boolean>;
|
|
51
|
-
list(path: string, options?: BoxListFilesOptions): Promise<readonly BoxFileEntry[]>;
|
|
52
|
-
mkdir(path: string, options?: BoxFileOptions & {
|
|
53
|
-
recursive?: boolean;
|
|
54
|
-
}): Promise<void>;
|
|
55
|
-
move?(source: string, destination: string, options?: BoxFileOptions): Promise<void>;
|
|
56
|
-
read(path: string, options?: BoxFileOptions): Promise<Uint8Array | null>;
|
|
57
|
-
remove(path: string, options?: BoxRemoveFileOptions): Promise<void>;
|
|
58
|
-
write(path: string, contents: Uint8Array, options?: BoxFileOptions): Promise<void>;
|
|
59
|
-
}
|
|
60
|
-
interface BoxPorts {
|
|
61
|
-
readonly values: readonly number[];
|
|
62
|
-
expose(port: number, options?: {
|
|
63
|
-
protocol?: "http" | "https" | "ws";
|
|
64
|
-
}): Promise<URL>;
|
|
65
|
-
}
|
|
66
|
-
interface BoxSession {
|
|
67
|
-
readonly cwd: string;
|
|
68
|
-
readonly executionAuthority: ExecutionAuthority;
|
|
69
|
-
readonly files: BoxFiles;
|
|
70
|
-
readonly id: string;
|
|
71
|
-
readonly inspectionConcurrency?: number;
|
|
72
|
-
readonly ports?: BoxPorts;
|
|
73
|
-
readonly spawn?: (command: string, args?: readonly string[], options?: BoxExecOptions) => Promise<BoxProcess>;
|
|
74
|
-
close(): Promise<void>;
|
|
75
|
-
exec(command: string, args?: readonly string[], options?: BoxExecOptions): Promise<BoxExecResult>;
|
|
76
|
-
}
|
|
77
|
-
interface BoxEnvironment {
|
|
78
|
-
readonly env: Readonly<Record<string, string | undefined>>;
|
|
79
|
-
}
|
|
80
|
-
interface BoxResolvedRequirement {
|
|
81
|
-
readonly command: string;
|
|
82
|
-
readonly name: string;
|
|
83
|
-
readonly timeout?: number;
|
|
84
|
-
}
|
|
85
|
-
interface BoxPlan {
|
|
86
|
-
readonly cache: {
|
|
87
|
-
readonly state: "disposable";
|
|
88
|
-
};
|
|
89
|
-
readonly environment: BoxEnvironment;
|
|
90
|
-
readonly executionAuthority: ExecutionAuthority;
|
|
91
|
-
readonly home: {
|
|
92
|
-
readonly state: readonly {
|
|
93
|
-
readonly identity: string;
|
|
94
|
-
readonly path: string;
|
|
95
|
-
}[];
|
|
96
|
-
};
|
|
97
|
-
readonly identity: string;
|
|
98
|
-
readonly requirements: readonly BoxResolvedRequirement[];
|
|
99
|
-
readonly runtime: string;
|
|
100
|
-
readonly workspace: {
|
|
101
|
-
readonly path?: string;
|
|
102
|
-
readonly state: "authoritative" | "disposable";
|
|
103
|
-
readonly workDir?: "." | "workspace";
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
interface Box {
|
|
107
|
-
readonly plan: BoxPlan;
|
|
108
|
-
open(options?: BoxOpenOptions): Promise<BoxSession>;
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/runtime/providers/vercel.d.ts
|
|
112
|
-
type SandboxOptions = {
|
|
113
|
-
local: SandboxDefinitionOptions;
|
|
114
|
-
provider: VercelSandboxProviderOptions;
|
|
115
|
-
};
|
|
116
|
-
declare function resolveVercelSandboxBox(options: SandboxOptions): Promise<{
|
|
117
|
-
provider: "vercel";
|
|
118
|
-
resolveBox: (requirements: readonly string[]) => Promise<Box>;
|
|
119
|
-
}>;
|
|
120
|
-
//#endregion
|
|
121
|
-
export { resolveVercelSandboxBox };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { resolveVercelBox } from "@vite-hub/box/_internal/vercel";
|
|
2
|
-
//#region src/internal/shared/env.ts
|
|
3
|
-
function readNonEmptyEnv(env, ...keys) {
|
|
4
|
-
for (const key of keys) {
|
|
5
|
-
const trimmed = env[key]?.trim();
|
|
6
|
-
if (trimmed) return trimmed;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/runtime/providers/vercel.ts
|
|
11
|
-
function readConfigCredential(value) {
|
|
12
|
-
return value?.trim() || void 0;
|
|
13
|
-
}
|
|
14
|
-
function resolveEnvCredentials() {
|
|
15
|
-
const env = typeof process !== "undefined" ? process.env : {};
|
|
16
|
-
return {
|
|
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")
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function resolveCredentials(provider) {
|
|
23
|
-
const env = resolveEnvCredentials();
|
|
24
|
-
const token = readConfigCredential(provider.token) || env.token;
|
|
25
|
-
const teamId = readConfigCredential(provider.teamId) || env.teamId;
|
|
26
|
-
const projectId = readConfigCredential(provider.projectId) || env.projectId;
|
|
27
|
-
if (!token || !teamId || !projectId) return void 0;
|
|
28
|
-
return {
|
|
29
|
-
token,
|
|
30
|
-
teamId,
|
|
31
|
-
projectId
|
|
32
|
-
};
|
|
33
|
-
}
|
|
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,
|
|
39
|
-
cpu: options.provider.cpu,
|
|
40
|
-
ports: options.provider.ports,
|
|
41
|
-
source: options.provider.source,
|
|
42
|
-
networkPolicy: options.provider.networkPolicy,
|
|
43
|
-
...credentials
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
provider: "vercel",
|
|
47
|
-
resolveBox: async (requirements) => await resolveVercelBox(boxOptions, requirements)
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
|
-
export { resolveVercelSandboxBox };
|
package/dist/runtime/state.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { a as SandboxDefinitionBundle, l as SandboxDefinitionOptions, t as AgentSandboxConfig } from "../module-types-DKYItiOu.js";
|
|
2
|
-
|
|
3
|
-
//#region src/runtime/state.d.ts
|
|
4
|
-
type SandboxRegistryEntry = {
|
|
5
|
-
bundle: SandboxDefinitionBundle;
|
|
6
|
-
options?: SandboxDefinitionOptions;
|
|
7
|
-
};
|
|
8
|
-
type SandboxRuntimeRegistry = Record<string, SandboxRegistryEntry | (() => Promise<{
|
|
9
|
-
default?: SandboxRegistryEntry;
|
|
10
|
-
}>)>;
|
|
11
|
-
type GeneratedSandboxRuntimeRegistryEntry = {
|
|
12
|
-
load: () => Promise<{
|
|
13
|
-
default?: SandboxRegistryEntry;
|
|
14
|
-
}>;
|
|
15
|
-
stablePath: string;
|
|
16
|
-
};
|
|
17
|
-
type GeneratedSandboxRuntimeRegistry = Record<string, GeneratedSandboxRuntimeRegistryEntry>;
|
|
18
|
-
declare function createGeneratedSandboxModuleSpecifier(path: string, recover?: boolean): string;
|
|
19
|
-
declare function createGeneratedSandboxRuntimeRegistry(scope: string, registry: GeneratedSandboxRuntimeRegistry): SandboxRuntimeRegistry;
|
|
20
|
-
declare function getSandboxRuntimeConfig(): false | AgentSandboxConfig | undefined;
|
|
21
|
-
declare function getSandboxRuntimeRegistry(): SandboxRuntimeRegistry | undefined;
|
|
22
|
-
declare function setSandboxRuntimeConfig(config: false | AgentSandboxConfig | undefined): void;
|
|
23
|
-
declare function setSandboxRuntimeRegistry(registry: SandboxRuntimeRegistry | undefined): void;
|
|
24
|
-
declare function resetSandboxRuntimeState(): void;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { SandboxRegistryEntry, SandboxRuntimeRegistry, createGeneratedSandboxModuleSpecifier, createGeneratedSandboxRuntimeRegistry, getSandboxRuntimeConfig, getSandboxRuntimeRegistry, resetSandboxRuntimeState, setSandboxRuntimeConfig, setSandboxRuntimeRegistry };
|
package/dist/runtime/state.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL } from "node:url";
|
|
2
|
-
//#region src/runtime/state.ts
|
|
3
|
-
let sandboxConfig;
|
|
4
|
-
let sandboxRegistry;
|
|
5
|
-
const generatedRegistries = /* @__PURE__ */ new Map();
|
|
6
|
-
const generatedRegistryOwnership = /* @__PURE__ */ new WeakMap();
|
|
7
|
-
let generatedRegistryRecoveryId = 0;
|
|
8
|
-
function isMissingGeneratedSandboxModule(error) {
|
|
9
|
-
const code = Reflect.get(Object(error), "code");
|
|
10
|
-
return code === "ENOENT" || code === "ERR_MODULE_NOT_FOUND";
|
|
11
|
-
}
|
|
12
|
-
function createGeneratedSandboxModuleSpecifier(path, recover = false) {
|
|
13
|
-
const normalizedPath = path.replaceAll("\\", "/");
|
|
14
|
-
const url = normalizedPath.startsWith("file:") ? new URL(normalizedPath) : pathToFileURL(normalizedPath);
|
|
15
|
-
if (recover) url.searchParams.set("vitehub-recovery", String(++generatedRegistryRecoveryId));
|
|
16
|
-
return url.href;
|
|
17
|
-
}
|
|
18
|
-
async function loadActiveGeneratedSandboxDefinition(scope, name) {
|
|
19
|
-
const activeEntry = (await import(
|
|
20
|
-
/* @vite-ignore */
|
|
21
|
-
createGeneratedSandboxModuleSpecifier(scope, true)
|
|
22
|
-
)).default?.[name];
|
|
23
|
-
if (!activeEntry) throw new Error(`[vitehub] Sandbox definition "${name}" is no longer generated.`);
|
|
24
|
-
return typeof activeEntry === "function" ? await activeEntry() : { default: activeEntry };
|
|
25
|
-
}
|
|
26
|
-
function createGeneratedSandboxRuntimeRegistry(scope, registry) {
|
|
27
|
-
const runtimeRegistry = Object.fromEntries(Object.keys(registry).map((name) => [name, async () => {
|
|
28
|
-
const activeRegistry = generatedRegistries.get(scope);
|
|
29
|
-
const entry = activeRegistry === void 0 ? registry[name] : activeRegistry[name];
|
|
30
|
-
if (!entry) throw new Error(`[vitehub] Sandbox definition "${name}" is no longer generated.`);
|
|
31
|
-
try {
|
|
32
|
-
return await entry.load();
|
|
33
|
-
} catch (error) {
|
|
34
|
-
if (!isMissingGeneratedSandboxModule(error)) throw error;
|
|
35
|
-
try {
|
|
36
|
-
return await import(
|
|
37
|
-
/* @vite-ignore */
|
|
38
|
-
createGeneratedSandboxModuleSpecifier(entry.stablePath, true)
|
|
39
|
-
);
|
|
40
|
-
} catch (stableError) {
|
|
41
|
-
if (!isMissingGeneratedSandboxModule(stableError)) throw stableError;
|
|
42
|
-
return await loadActiveGeneratedSandboxDefinition(scope, name);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}]));
|
|
46
|
-
generatedRegistryOwnership.set(runtimeRegistry, {
|
|
47
|
-
registry,
|
|
48
|
-
scope
|
|
49
|
-
});
|
|
50
|
-
return runtimeRegistry;
|
|
51
|
-
}
|
|
52
|
-
function getSandboxRuntimeConfig() {
|
|
53
|
-
return sandboxConfig;
|
|
54
|
-
}
|
|
55
|
-
function getSandboxRuntimeRegistry() {
|
|
56
|
-
return sandboxRegistry;
|
|
57
|
-
}
|
|
58
|
-
function setSandboxRuntimeConfig(config) {
|
|
59
|
-
sandboxConfig = config;
|
|
60
|
-
}
|
|
61
|
-
function setSandboxRuntimeRegistry(registry) {
|
|
62
|
-
sandboxRegistry = registry;
|
|
63
|
-
const generated = registry && generatedRegistryOwnership.get(registry);
|
|
64
|
-
if (generated) generatedRegistries.set(generated.scope, generated.registry);
|
|
65
|
-
}
|
|
66
|
-
function resetSandboxRuntimeState() {
|
|
67
|
-
sandboxConfig = void 0;
|
|
68
|
-
sandboxRegistry = void 0;
|
|
69
|
-
generatedRegistries.clear();
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
export { createGeneratedSandboxModuleSpecifier, createGeneratedSandboxRuntimeRegistry, getSandboxRuntimeConfig, getSandboxRuntimeRegistry, resetSandboxRuntimeState, setSandboxRuntimeConfig, setSandboxRuntimeRegistry };
|
package/dist/vite.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { t as AgentSandboxConfig } from "./module-types-DKYItiOu.js";
|
|
2
|
-
import { Plugin } from "vite";
|
|
3
|
-
|
|
4
|
-
//#region src/internal/shared/feature-definitions.d.ts
|
|
5
|
-
interface ScannedDefinition {
|
|
6
|
-
name: string;
|
|
7
|
-
handler: string;
|
|
8
|
-
_meta: {
|
|
9
|
-
filename: string;
|
|
10
|
-
sourcePath: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/discovery.d.ts
|
|
15
|
-
interface DiscoveredSandboxDefinition extends ScannedDefinition {
|
|
16
|
-
kind: 'definition' | 'package-entry';
|
|
17
|
-
source: 'server-sandboxes' | 'vite-suffix';
|
|
18
|
-
}
|
|
19
|
-
declare function discoverSandboxDefinitions(options: {
|
|
20
|
-
mode?: 'vite-suffix';
|
|
21
|
-
rootDir: string;
|
|
22
|
-
scanDirs?: string[];
|
|
23
|
-
} | {
|
|
24
|
-
mode: 'server-sandboxes';
|
|
25
|
-
scanDirs: string[];
|
|
26
|
-
}): DiscoveredSandboxDefinition[];
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/vite.d.ts
|
|
29
|
-
type SandboxPublicOptions = AgentSandboxConfig | false;
|
|
30
|
-
type SandboxVitePlugin = Plugin & {
|
|
31
|
-
nitro: {
|
|
32
|
-
name: string;
|
|
33
|
-
setup: (nitro: {
|
|
34
|
-
hooks: {
|
|
35
|
-
hook: (name: 'build:before', callback: () => void) => void;
|
|
36
|
-
};
|
|
37
|
-
options: Record<string, unknown>;
|
|
38
|
-
}) => void;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
declare function hubSandbox(options?: SandboxPublicOptions): SandboxVitePlugin;
|
|
42
|
-
declare module 'vite' {
|
|
43
|
-
interface UserConfig {
|
|
44
|
-
sandbox?: SandboxPublicOptions;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
export { type DiscoveredSandboxDefinition, SandboxPublicOptions, SandboxVitePlugin, discoverSandboxDefinitions, hubSandbox };
|