@vite-hub/sandbox 0.4.1 → 0.5.1
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/{abortable-CR01hzfi.js → abortable-DrHeTo1e.js} +1 -2
- package/dist/{cloudflare-Cog_r2Me.js → cloudflare-DrNRQPeh.js} +13 -27
- package/dist/{cloudflare-env-lookup-DzI6Xv1Y.js → cloudflare-env-lookup-BNbNil7g.js} +1 -2
- package/dist/{cloudflare-failure-CFQhalfh.js → cloudflare-failure-f-3P3ul-.js} +1 -2
- package/dist/{container-CqfD8yuE.js → container-DOadzngt.js} +7 -13
- package/dist/{crabbox-sbV3Zjuo.js → crabbox-C7KeIKnH.js} +7 -12
- package/dist/{error-diagnostics-BJtLRL9w.js → error-diagnostics-CApUyzzu.js} +1 -2
- package/dist/{error-diagnostics-BNQwU9yq.js → error-diagnostics-ClSiUwCm.js} +1 -2
- package/dist/{file-listing-CHtRrfo1.js → file-listing-BF122soX.js} +3 -4
- package/dist/{file-lock-D0-XPogS.js → file-lock-CqA7b491.js} +3 -4
- package/dist/{index-DsoQAUb7.d.ts → index-D9DogaoF.d.ts} +0 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -14
- package/dist/internal/cloudflare.d.ts +2 -5
- package/dist/internal/cloudflare.js +3 -4
- package/dist/internal/host-toolchain.d.ts +2 -4
- package/dist/internal/host-toolchain.js +4 -5
- package/dist/internal/vercel.d.ts +2 -4
- package/dist/internal/vercel.js +3 -4
- package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
- package/dist/{module-types-BoOZiNN4.d.ts → module-types-B3uJG1po.d.ts} +1 -9
- package/dist/{module-types-B0LQ5H2S.js → module-types-CWcBHyEs.js} +1 -2
- package/dist/{process-sweep-CMaujWE5.js → process-sweep-DVaTb2pO.js} +1 -2
- package/dist/{provider-loader-BDgDJ6bX.d.ts → provider-loader-CNKHrWXG.d.ts} +2 -6
- package/dist/{provider-resolution-BrQfEQo0.js → provider-resolution-Cl2NKhRP.js} +5 -8
- package/dist/{remote-70ZVZZlq.js → remote-DlyX1drC.js} +5 -10
- package/dist/{rolldown-runtime-8H4AJuhK.js → rolldown-runtime-BJohB4LM.js} +1 -2
- package/dist/{runtime-DHp6ImeP.js → runtime-EtWFVKud.js} +1 -2
- package/dist/{runtime-type-Deo4qzxN.js → runtime-type-Dk-rJXlr.js} +1 -2
- package/dist/{session-e0lyzjJ3.js → session-DmUiyj4O.js} +5 -8
- package/dist/{shell-quote-Q3u3plif.js → shell-quote-MrD49m3N.js} +1 -2
- package/dist/ssh.d.ts +1 -3
- package/dist/ssh.js +11 -9
- package/dist/task/index.d.ts +1 -16
- package/dist/task/index.js +23 -44
- package/dist/task/runtime/empty-registry.d.ts +0 -2
- package/dist/task/runtime/empty-registry.js +1 -2
- package/dist/task/runtime/provider-loader.d.ts +1 -1
- package/dist/task/runtime/provider-loader.js +2 -3
- package/dist/task/runtime/providers/cloudflare.d.ts +3 -4
- package/dist/task/runtime/providers/cloudflare.js +3 -4
- package/dist/task/runtime/providers/local.d.ts +2 -4
- package/dist/task/runtime/providers/local.js +3 -4
- package/dist/task/runtime/providers/vercel.d.ts +3 -4
- package/dist/task/runtime/providers/vercel.js +9 -16
- package/dist/task/runtime/state.d.ts +3 -4
- package/dist/task/runtime/state.js +2 -3
- package/dist/task/vite.d.ts +24 -23
- package/dist/task/vite.js +108 -116
- package/dist/{toolchain-BIVGMRty.js → toolchain-DFFxmw3N.js} +6 -13
- package/dist/{trusted-host-RanFsFSB.js → trusted-host-CwMs64h1.js} +39 -24
- package/dist/{trusted-host-environment-CWKJ7DD_.js → trusted-host-environment-BJE5hGtQ.js} +1 -2
- package/dist/{vercel-BGGrNpza.js → vercel-DT74kDyI.js} +33 -29
- package/dist/{size-DJNpXeAt.js → vercel-credentials-BGuXoKxG.js} +18 -4
- package/package.json +10 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/abortable.ts
|
|
2
2
|
/**
|
|
3
3
|
* Wait for a promise until the caller's signal aborts.
|
|
4
4
|
*
|
|
@@ -53,5 +53,4 @@ function killOnAbort(process, signal) {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
//#endregion
|
|
57
56
|
export { killOnAbort as n, abortable as t };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { n as killOnAbort } from "./abortable-
|
|
10
|
-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
|
|
2
|
+
import { t as listCommandFiles } from "./file-listing-BF122soX.js";
|
|
3
|
+
import { i as resolveRemoteEnvironment, n as openRemoteSandbox, o as snapshotStream, r as remoteSandboxPlan } from "./remote-DlyX1drC.js";
|
|
4
|
+
import { t as shellQuote } from "./shell-quote-MrD49m3N.js";
|
|
5
|
+
import { n as invariantError } from "./invariant-Dj2R1eMr.js";
|
|
6
|
+
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
|
|
7
|
+
import { n as cloudflareRetryDelays, r as readCloudflareFailure, t as canRetryCloudflareRequest } from "./cloudflare-failure-f-3P3ul-.js";
|
|
8
|
+
import { r as markBuiltInSandboxRuntime } from "./runtime-EtWFVKud.js";
|
|
9
|
+
import { n as killOnAbort } from "./abortable-DrHeTo1e.js";
|
|
10
|
+
// src/internal/cloudflare-transport.ts
|
|
11
11
|
const cloudflareControlPlaneTimeout = 15e3;
|
|
12
12
|
const cloudflareReadTimeout = 15e3;
|
|
13
13
|
const cloudflareStopTimeout = 1e4;
|
|
@@ -66,8 +66,7 @@ async function waitForRetry(timeout, signal) {
|
|
|
66
66
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
//#region src/internal/cloudflare-durable-object.ts
|
|
69
|
+
// src/internal/cloudflare-durable-object.ts
|
|
71
70
|
const configurationKey = "vitehub:configuration";
|
|
72
71
|
const defaultSleepAfter = 6e5;
|
|
73
72
|
const keepAliveTimeout = 216e5;
|
|
@@ -148,7 +147,6 @@ var SandboxProcessRecord = class {
|
|
|
148
147
|
logs() {
|
|
149
148
|
return { ...this.#output };
|
|
150
149
|
}
|
|
151
|
-
/** Server-sent events: buffered output, then live output, then `exit`. Same format as @cloudflare/sandbox 0.12. */
|
|
152
150
|
stream() {
|
|
153
151
|
const encoder = new TextEncoder();
|
|
154
152
|
let listener;
|
|
@@ -506,8 +504,7 @@ function encodeBase64$1(value) {
|
|
|
506
504
|
for (let offset = 0; offset < value.length; offset += 8192) binary += String.fromCharCode(...value.subarray(offset, offset + 8192));
|
|
507
505
|
return btoa(binary);
|
|
508
506
|
}
|
|
509
|
-
|
|
510
|
-
//#region src/internal/network-policy.ts
|
|
507
|
+
// src/internal/network-policy.ts
|
|
511
508
|
const maxCloudflareAllowedHosts = 64;
|
|
512
509
|
const label = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
|
|
513
510
|
const hostPattern = new RegExp(`^(?:\\*\\.)?(?:${label}\\.)+${label}$|^${label}$`);
|
|
@@ -539,10 +536,6 @@ function sandboxNetworkAuthority(policy) {
|
|
|
539
536
|
if (policy === "deny-all") return "none";
|
|
540
537
|
return "restricted";
|
|
541
538
|
}
|
|
542
|
-
/**
|
|
543
|
-
* Cloudflare decrypts HTTPS to allowed hosts and signs it again with this CA. It exists while HTTPS interception is on.
|
|
544
|
-
* `exec()` does not inherit the environment of the Container start, so every command gets these variables.
|
|
545
|
-
*/
|
|
546
539
|
const cloudflareContainerCa = "/etc/cloudflare/certs/cloudflare-containers-ca.crt";
|
|
547
540
|
const cloudflareInterceptedHttpsEnv = Object.freeze({
|
|
548
541
|
CURL_CA_BUNDLE: cloudflareContainerCa,
|
|
@@ -551,8 +544,7 @@ const cloudflareInterceptedHttpsEnv = Object.freeze({
|
|
|
551
544
|
REQUESTS_CA_BUNDLE: cloudflareContainerCa,
|
|
552
545
|
SSL_CERT_FILE: cloudflareContainerCa
|
|
553
546
|
});
|
|
554
|
-
|
|
555
|
-
//#region src/cloudflare.ts
|
|
547
|
+
// src/cloudflare.ts
|
|
556
548
|
var cloudflare_exports = /* @__PURE__ */ __exportAll({ createCloudflareRuntime: () => createCloudflareRuntime });
|
|
557
549
|
const cloudflareExecutionAuthority = {
|
|
558
550
|
credentials: "unknown",
|
|
@@ -600,10 +592,6 @@ function createCloudflareRuntime(options) {
|
|
|
600
592
|
}
|
|
601
593
|
});
|
|
602
594
|
}
|
|
603
|
-
/**
|
|
604
|
-
* Reaches the Sandbox Durable Object that the ViteHub Cloudflare host integration exports.
|
|
605
|
-
* @cloudflare/sandbox 1.0 has no `getSandbox`; the generated class implements this stub over RPC.
|
|
606
|
-
*/
|
|
607
595
|
function getCloudflareSandbox(namespace, id, options = {}, networkPolicy = "allow-all") {
|
|
608
596
|
const target = namespace.get(namespace.idFromName(options.normalizeId ? id.toLowerCase() : id));
|
|
609
597
|
let configured;
|
|
@@ -820,7 +808,6 @@ function exitedProcessLogs(logs) {
|
|
|
820
808
|
stdout: snapshotStream(async () => (await logs).stdout)
|
|
821
809
|
};
|
|
822
810
|
}
|
|
823
|
-
/** Bounds each channel independently so an unread channel cannot stall its sibling. */
|
|
824
811
|
function processLogStreams(logs) {
|
|
825
812
|
const bufferLimit = 1048576;
|
|
826
813
|
const encoder = new TextEncoder();
|
|
@@ -906,5 +893,4 @@ async function abortable(operation, signal, abort) {
|
|
|
906
893
|
});
|
|
907
894
|
});
|
|
908
895
|
}
|
|
909
|
-
//#endregion
|
|
910
896
|
export { createCloudflareSandboxOutbound as i, createCloudflareRuntime as n, createCloudflareSandboxDurableObject as r, cloudflare_exports as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../internal/src/runtime/cloudflare-env-lookup.ts
|
|
2
2
|
/** The key of the AsyncLocalStorage store on `globalThis`. Every bundled copy of this module shares the store. */
|
|
3
3
|
const activeEnvStorageKey = Symbol.for("vitehub.cloudflare.env-storage");
|
|
4
4
|
let activeEnv;
|
|
@@ -12,5 +12,4 @@ function getActiveCloudflareEnv() {
|
|
|
12
12
|
const host = globalThis;
|
|
13
13
|
return Object.hasOwn(host, "__env__") && host.__env__ !== void 0 ? host.__env__ : activeEnv;
|
|
14
14
|
}
|
|
15
|
-
//#endregion
|
|
16
15
|
export { getActiveCloudflareEnv as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/cloudflare-failure.ts
|
|
2
2
|
/** Waits before each retry of a Cloudflare Sandbox request or Sandbox Task run. */
|
|
3
3
|
const cloudflareRetryDelays = [
|
|
4
4
|
1e3,
|
|
@@ -46,5 +46,4 @@ function errorFlag(error, name) {
|
|
|
46
46
|
function errorProperty(error, name) {
|
|
47
47
|
return typeof error === "object" && error !== null && name in error ? Reflect.get(error, name) : void 0;
|
|
48
48
|
}
|
|
49
|
-
//#endregion
|
|
50
49
|
export { cloudflareRetryDelays as n, readCloudflareFailure as r, canRetryCloudflareRequest as t };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
|
|
2
|
+
import { t as listCommandFiles } from "./file-listing-BF122soX.js";
|
|
3
|
+
import { i as resolveRemoteEnvironment, n as openRemoteSandbox, r as remoteSandboxPlan } from "./remote-DlyX1drC.js";
|
|
4
|
+
import { r as markBuiltInSandboxRuntime } from "./runtime-EtWFVKud.js";
|
|
5
|
+
import { t as shellQuote } from "./shell-quote-MrD49m3N.js";
|
|
6
6
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
7
7
|
import { posix } from "node:path";
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
9
9
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
10
10
|
import { Readable, Writable } from "node:stream";
|
|
11
|
-
|
|
11
|
+
// src/internal/container-broker.ts
|
|
12
12
|
/**
|
|
13
13
|
* mitmproxy addon for the container runtime broker. It is the only network exit of a
|
|
14
14
|
* caged Sandbox. It enforces the egress allowlist and swaps credential placeholders for
|
|
@@ -185,8 +185,7 @@ const containerBrokerEntrypoint = [
|
|
|
185
185
|
"exec mitmdump --listen-host 0.0.0.0 --listen-port 8080 --quiet --set connection_strategy=lazy --set rawtcp=false --set confdir=/tmp/vitehub-broker -s /tmp/vitehub-broker/addon.py"
|
|
186
186
|
].join("\n");
|
|
187
187
|
const containerBrokerCaPath = "/tmp/vitehub-broker/mitmproxy-ca-cert.pem";
|
|
188
|
-
|
|
189
|
-
//#region src/internal/container.ts
|
|
188
|
+
// src/internal/container.ts
|
|
190
189
|
const defaultContainerBrokerImage = "mitmproxy/mitmproxy:12.2.3";
|
|
191
190
|
const brokerAlias = "vitehub-broker";
|
|
192
191
|
const brokerPort = 8080;
|
|
@@ -218,7 +217,6 @@ const reservedCredentialNames = /* @__PURE__ */ new Set([
|
|
|
218
217
|
"XDG_CONFIG_HOME",
|
|
219
218
|
"XDG_STATE_HOME"
|
|
220
219
|
]);
|
|
221
|
-
/** Names that the Docker CLI reads itself. Their Sandbox values travel on the command line instead of the CLI environment. */
|
|
222
220
|
const cliEnvironment = (name) => name === "PATH" || name === "HOME" || name.startsWith("DOCKER_") || name.startsWith("XDG_");
|
|
223
221
|
function createContainerRuntime(options) {
|
|
224
222
|
const normalized = normalizeContainerOptions(options);
|
|
@@ -335,7 +333,6 @@ function assertCredentialNames(input, options) {
|
|
|
335
333
|
function invalid(message) {
|
|
336
334
|
return sandboxErrorDiagnostics.SANDBOX_R0160({ message: `[vitehub] ${message}` });
|
|
337
335
|
}
|
|
338
|
-
/** Docker object names allow [a-zA-Z0-9][a-zA-Z0-9_.-]. */
|
|
339
336
|
function dockerName(id) {
|
|
340
337
|
return `vitehub-sandbox-${id.replace(/[^a-zA-Z0-9_.-]/g, "-").replace(/^[^a-zA-Z0-9]+/, "").slice(0, 40) || "session"}-${randomBytes(4).toString("hex")}`;
|
|
341
338
|
}
|
|
@@ -637,7 +634,6 @@ async function writeContainerFile(docker, container, path, content, signal, user
|
|
|
637
634
|
function createContainerSession(state) {
|
|
638
635
|
const children = /* @__PURE__ */ new Set();
|
|
639
636
|
let destroyPromise;
|
|
640
|
-
/** Starts `command` in the Sandbox. The wrapper records the process id so kill() reaches the Sandbox process, not only the Docker CLI. */
|
|
641
637
|
const start = (options, stdin) => {
|
|
642
638
|
const pidFile = `${pidDirectory}/${randomUUID()}`;
|
|
643
639
|
const environment = {
|
|
@@ -857,12 +853,10 @@ function createContainerSession(state) {
|
|
|
857
853
|
}
|
|
858
854
|
};
|
|
859
855
|
}
|
|
860
|
-
/** Relative file paths are relative to the Sandbox workspace, like command working directories. */
|
|
861
856
|
function sandboxPath(path) {
|
|
862
857
|
return posix.isAbsolute(path) ? path : posix.join(sandboxWorkspace, path);
|
|
863
858
|
}
|
|
864
859
|
function messageOf(error) {
|
|
865
860
|
return error instanceof Error ? error.message || error.name : String(error);
|
|
866
861
|
}
|
|
867
|
-
//#endregion
|
|
868
862
|
export { createContainerRuntime };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
1
|
+
import { t as listCommandFiles } from "./file-listing-BF122soX.js";
|
|
2
|
+
import { a as sandboxRequirementSecrets, i as sandboxRequirementPlan, o as sandboxRequirementSignal, r as sandboxRequirementError, s as materializeGitCheckout, t as createSandboxSession } from "./session-DmUiyj4O.js";
|
|
3
|
+
import { r as markBuiltInSandboxRuntime } from "./runtime-EtWFVKud.js";
|
|
4
|
+
import { t as shellQuote } from "./shell-quote-MrD49m3N.js";
|
|
5
|
+
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
|
|
6
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
7
|
import { cp, lstat, mkdtemp, readFile, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
8
8
|
import { dirname, join, posix, resolve } from "node:path";
|
|
9
9
|
import { spawn } from "node:child_process";
|
|
10
10
|
import { tmpdir } from "node:os";
|
|
11
11
|
import { Readable, Writable } from "node:stream";
|
|
12
|
-
|
|
12
|
+
// src/internal/crabbox.ts
|
|
13
13
|
const workspaceSessions = /* @__PURE__ */ new Map();
|
|
14
14
|
const crabboxSessionEnvironmentKey = "VITEHUB_SANDBOX_SESSION";
|
|
15
15
|
const runtimeEnvironmentKeys = /* @__PURE__ */ new Set([
|
|
@@ -286,13 +286,9 @@ function environmentWrapper(assignments) {
|
|
|
286
286
|
const values = Object.entries(assignments).map(([name, value]) => `${name}=${shellQuote(value)}`).join(" ");
|
|
287
287
|
return new TextEncoder().encode(`#!/bin/sh\nexec env -i ${values} "$@"\n`);
|
|
288
288
|
}
|
|
289
|
-
/**
|
|
290
|
-
* Install into the shared target cache, then rewrite the command wrapper so
|
|
291
|
-
* every Sandbox command sees the toolchain first on PATH.
|
|
292
|
-
*/
|
|
293
289
|
async function provisionCrabboxToolchain(toolchain, session, context) {
|
|
294
290
|
const { abortSignal, leaseId, options } = context;
|
|
295
|
-
const { provisionToolchain, readProjectFilesWithShell, verifyToolchain } = await import("./toolchain-
|
|
291
|
+
const { provisionToolchain, readProjectFilesWithShell, verifyToolchain } = await import("./toolchain-DFFxmw3N.js").then((n) => n.i);
|
|
296
292
|
const run = async (script) => await runCrabbox(options, leaseId, {
|
|
297
293
|
abortSignal,
|
|
298
294
|
command: `sh -c ${shellQuote(script)}`
|
|
@@ -1106,5 +1102,4 @@ function waitForExit(child) {
|
|
|
1106
1102
|
if (child.exitCode !== null || child.signalCode !== null) return Promise.resolve();
|
|
1107
1103
|
return new Promise((resolvePromise) => child.once("close", () => resolvePromise()));
|
|
1108
1104
|
}
|
|
1109
|
-
//#endregion
|
|
1110
1105
|
export { createCrabboxRuntime };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
|
-
|
|
2
|
+
// src/error-diagnostics.ts
|
|
3
3
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
4
|
const sandboxErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
5
|
docsBase: "https://vitehub.dev/docs/sandbox/diagnostics",
|
|
@@ -532,5 +532,4 @@ const sandboxErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
534
|
});
|
|
535
|
-
//#endregion
|
|
536
535
|
export { sandboxErrorDiagnostics as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
|
-
|
|
2
|
+
// src/task/error-diagnostics.ts
|
|
3
3
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
4
|
const sandboxTaskErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
5
|
docsBase: "https://vitehub.dev/docs/sandbox/diagnostics",
|
|
@@ -362,5 +362,4 @@ const sandboxTaskErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
});
|
|
365
|
-
//#endregion
|
|
366
365
|
export { sandboxTaskErrorDiagnostics as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { t as shellQuote } from "./shell-quote-
|
|
3
|
-
|
|
1
|
+
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
|
|
2
|
+
import { t as shellQuote } from "./shell-quote-MrD49m3N.js";
|
|
3
|
+
// src/internal/file-listing.ts
|
|
4
4
|
async function listCommandFiles(run, options, failure) {
|
|
5
5
|
options.abortSignal?.throwIfAborted();
|
|
6
6
|
const result = await run({
|
|
@@ -22,5 +22,4 @@ async function listCommandFiles(run, options, failure) {
|
|
|
22
22
|
};
|
|
23
23
|
}).sort((left, right) => left.path.localeCompare(right.path));
|
|
24
24
|
}
|
|
25
|
-
//#endregion
|
|
26
25
|
export { listCommandFiles as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as abortable } from "./abortable-
|
|
2
|
-
import { t as runtimeRecord } from "./runtime-type-
|
|
1
|
+
import { t as abortable } from "./abortable-DrHeTo1e.js";
|
|
2
|
+
import { t as runtimeRecord } from "./runtime-type-Dk-rJXlr.js";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { hostname } from "node:os";
|
|
7
|
-
|
|
7
|
+
// src/internal/file-lock.ts
|
|
8
8
|
/**
|
|
9
9
|
* Acquire a cross-process lock directory. A lock whose owner process is gone
|
|
10
10
|
* on this host, or whose owner record stays unreadable, is treated as stale.
|
|
@@ -70,5 +70,4 @@ async function staleLock(path) {
|
|
|
70
70
|
return error instanceof Error && "code" in error && error.code === "ESRCH" ? token : void 0;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
//#endregion
|
|
74
73
|
export { acquireFileLock as t };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ExecutionAuthority } from "@vite-hub/runtime";
|
|
2
|
-
//#region src/internal/network-policy.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* The outbound network of a Sandbox. The `vercel` and `cloudflare` runtimes take this form.
|
|
5
4
|
* - `"allow-all"`: no limit. This is the default.
|
|
@@ -10,8 +9,6 @@ import { ExecutionAuthority } from "@vite-hub/runtime";
|
|
|
10
9
|
type SandboxNetworkPolicy = "allow-all" | "deny-all" | {
|
|
11
10
|
allow: readonly string[];
|
|
12
11
|
};
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/cloudflare.d.ts
|
|
15
12
|
interface CloudflareSandboxOptions {
|
|
16
13
|
cloudflare?: {
|
|
17
14
|
keepAlive?: boolean;
|
|
@@ -108,8 +105,6 @@ interface CloudflareSandboxStub {
|
|
|
108
105
|
success: boolean;
|
|
109
106
|
} | void>;
|
|
110
107
|
}
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/internal/container.d.ts
|
|
113
108
|
/** A credential that stays on the ViteHub host. The Sandbox sees only a placeholder. */
|
|
114
109
|
interface ContainerSandboxCredential {
|
|
115
110
|
/** Hosts that receive the real value, such as `api.github.com` or `*.example.com:8443`. */
|
|
@@ -149,8 +144,6 @@ interface ContainerSandboxOptions {
|
|
|
149
144
|
/** Container user, as for `docker run --user`. Defaults to the image user. */
|
|
150
145
|
user?: string;
|
|
151
146
|
}
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/internal/crabbox.d.ts
|
|
154
147
|
interface CrabboxOptions {
|
|
155
148
|
/** Enables loopback port URLs when the target shares the ViteHub process network namespace. */
|
|
156
149
|
network?: "direct";
|
|
@@ -160,13 +153,9 @@ interface CrabboxOptions {
|
|
|
160
153
|
/** Private durable storage on the target host for writable Sandbox state. */
|
|
161
154
|
stateRoot?: string;
|
|
162
155
|
}
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region src/internal/trusted-host.d.ts
|
|
165
156
|
interface TrustedHostOptions {
|
|
166
157
|
stateRoot?: string;
|
|
167
158
|
}
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/vercel.d.ts
|
|
170
159
|
type VercelSandboxSource = {
|
|
171
160
|
depth?: number;
|
|
172
161
|
revision?: string;
|
|
@@ -221,7 +210,6 @@ interface VercelSandboxCreateOptions {
|
|
|
221
210
|
timeout?: number;
|
|
222
211
|
token?: string;
|
|
223
212
|
}
|
|
224
|
-
/** The signals that the Vercel Sandbox SDK sends by name. Other signals use their number. */
|
|
225
213
|
declare const vercelSignalNames: readonly ["SIGHUP", "SIGINT", "SIGQUIT", "SIGKILL", "SIGTERM", "SIGCONT", "SIGSTOP"];
|
|
226
214
|
type VercelSandboxSignal = typeof vercelSignalNames[number] | number;
|
|
227
215
|
interface VercelSandboxCommand {
|
|
@@ -312,8 +300,6 @@ interface VercelFileStat {
|
|
|
312
300
|
isSymbolicLink(): boolean;
|
|
313
301
|
size: number;
|
|
314
302
|
}
|
|
315
|
-
//#endregion
|
|
316
|
-
//#region src/index.d.ts
|
|
317
303
|
type SandboxRequirement = string | {
|
|
318
304
|
args?: readonly string[];
|
|
319
305
|
command: string;
|
|
@@ -590,5 +576,4 @@ interface ResolveSandboxOptions {
|
|
|
590
576
|
requires?: readonly SandboxRequirement[];
|
|
591
577
|
}
|
|
592
578
|
declare function resolveSandbox<Context>(definition: SandboxDefinition<Context>, context: Context, options?: ResolveSandboxOptions): Promise<Sandbox>;
|
|
593
|
-
//#endregion
|
|
594
579
|
export { TrustedHostOptions as $, SandboxRuntime as A, SandboxToolchainPackageManagerPin as B, SandboxPorts as C, SandboxRequirement as D, SandboxRemoveFileOptions as E, SandboxSession as F, resolveSandbox as G, SandboxToolchainPins as H, SandboxSpawnOptions as I, VercelSandboxCreateOptions as J, VercelFileStat as K, SandboxToolchain as L, SandboxRuntimeInput as M, SandboxRuntimeOpenOptions as N, SandboxResolvedRequirement as O, SandboxRuntimePlan as P, VercelSandboxSource as Q, SandboxToolchainInput as R, SandboxPlan as S, SandboxProcessExit as T, SandboxToolchainPlan as U, SandboxToolchainPin as V, SandboxValue as W, VercelSandboxNetworkPolicy as X, VercelSandboxInstance as Y, VercelSandboxOptions as Z, SandboxFileOptions as _, ResolvedSandboxFile as a, CloudflareSandboxOptions as at, SandboxListFilesOptions as b, ResolvedSandboxState as c, SandboxDefinition as d, CrabboxOptions as et, SandboxEnvironment as f, SandboxFileEntry as g, SandboxFile as h, ResolvedSandboxCheckout as i, CloudflareDurableObjectNamespace as it, SandboxRuntimeDefinition as j, SandboxResolvedToolchain as k, Sandbox as l, SandboxExecResult as m, BuiltInSandboxRuntimeName as n, ContainerSandboxEgress as nt, ResolvedSandboxPlan as o, CloudflareSandboxStub as ot, SandboxExecOptions as p, VercelSandboxCommand as q, ResolveSandboxOptions as r, ContainerSandboxOptions as rt, ResolvedSandboxRequirementInput as s, SandboxNetworkPolicy as st, BuiltInSandboxRuntime as t, ContainerSandboxCredential as tt, SandboxCheckout as u, SandboxFiles as v, SandboxProcess as w, SandboxOpenOptions as x, SandboxHome as y, SandboxToolchainOptions as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as TrustedHostOptions, A as SandboxRuntime, B as SandboxToolchainPackageManagerPin, C as SandboxPorts, D as SandboxRequirement, E as SandboxRemoveFileOptions, F as SandboxSession, G as resolveSandbox, H as SandboxToolchainPins, I as SandboxSpawnOptions, J as VercelSandboxCreateOptions, K as VercelFileStat, L as SandboxToolchain, M as SandboxRuntimeInput, N as SandboxRuntimeOpenOptions, O as SandboxResolvedRequirement, P as SandboxRuntimePlan, Q as VercelSandboxSource, R as SandboxToolchainInput, S as SandboxPlan, T as SandboxProcessExit, U as SandboxToolchainPlan, V as SandboxToolchainPin, W as SandboxValue, X as VercelSandboxNetworkPolicy, Y as VercelSandboxInstance, Z as VercelSandboxOptions, _ as SandboxFileOptions, a as ResolvedSandboxFile, at as CloudflareSandboxOptions, b as SandboxListFilesOptions, c as ResolvedSandboxState, d as SandboxDefinition, et as CrabboxOptions, f as SandboxEnvironment, g as SandboxFileEntry, h as SandboxFile, i as ResolvedSandboxCheckout, it as CloudflareDurableObjectNamespace, j as SandboxRuntimeDefinition, k as SandboxResolvedToolchain, l as Sandbox, m as SandboxExecResult, n as BuiltInSandboxRuntimeName, nt as ContainerSandboxEgress, o as ResolvedSandboxPlan, ot as CloudflareSandboxStub, p as SandboxExecOptions, q as VercelSandboxCommand, r as ResolveSandboxOptions, rt as ContainerSandboxOptions, s as ResolvedSandboxRequirementInput, st as SandboxNetworkPolicy, t as BuiltInSandboxRuntime, tt as ContainerSandboxCredential, u as SandboxCheckout, v as SandboxFiles, w as SandboxProcess, x as SandboxOpenOptions, y as SandboxHome, z as SandboxToolchainOptions } from "./index-
|
|
1
|
+
import { $ as TrustedHostOptions, A as SandboxRuntime, B as SandboxToolchainPackageManagerPin, C as SandboxPorts, D as SandboxRequirement, E as SandboxRemoveFileOptions, F as SandboxSession, G as resolveSandbox, H as SandboxToolchainPins, I as SandboxSpawnOptions, J as VercelSandboxCreateOptions, K as VercelFileStat, L as SandboxToolchain, M as SandboxRuntimeInput, N as SandboxRuntimeOpenOptions, O as SandboxResolvedRequirement, P as SandboxRuntimePlan, Q as VercelSandboxSource, R as SandboxToolchainInput, S as SandboxPlan, T as SandboxProcessExit, U as SandboxToolchainPlan, V as SandboxToolchainPin, W as SandboxValue, X as VercelSandboxNetworkPolicy, Y as VercelSandboxInstance, Z as VercelSandboxOptions, _ as SandboxFileOptions, a as ResolvedSandboxFile, at as CloudflareSandboxOptions, b as SandboxListFilesOptions, c as ResolvedSandboxState, d as SandboxDefinition, et as CrabboxOptions, f as SandboxEnvironment, g as SandboxFileEntry, h as SandboxFile, i as ResolvedSandboxCheckout, it as CloudflareDurableObjectNamespace, j as SandboxRuntimeDefinition, k as SandboxResolvedToolchain, l as Sandbox, m as SandboxExecResult, n as BuiltInSandboxRuntimeName, nt as ContainerSandboxEgress, o as ResolvedSandboxPlan, ot as CloudflareSandboxStub, p as SandboxExecOptions, q as VercelSandboxCommand, r as ResolveSandboxOptions, rt as ContainerSandboxOptions, s as ResolvedSandboxRequirementInput, st as SandboxNetworkPolicy, t as BuiltInSandboxRuntime, tt as ContainerSandboxCredential, u as SandboxCheckout, v as SandboxFiles, w as SandboxProcess, x as SandboxOpenOptions, y as SandboxHome, z as SandboxToolchainOptions } from "./index-D9DogaoF.js";
|
|
2
2
|
export { BuiltInSandboxRuntime, BuiltInSandboxRuntimeName, type CloudflareDurableObjectNamespace, type CloudflareSandboxOptions, type CloudflareSandboxStub, type ContainerSandboxCredential, type ContainerSandboxEgress, type ContainerSandboxOptions, type CrabboxOptions, ResolveSandboxOptions, ResolvedSandboxCheckout, ResolvedSandboxFile, ResolvedSandboxPlan, ResolvedSandboxRequirementInput, ResolvedSandboxState, Sandbox, SandboxCheckout, SandboxDefinition, SandboxEnvironment, SandboxExecOptions, SandboxExecResult, SandboxFile, SandboxFileEntry, SandboxFileOptions, SandboxFiles, SandboxHome, SandboxListFilesOptions, type SandboxNetworkPolicy, SandboxOpenOptions, SandboxPlan, SandboxPorts, SandboxProcess, SandboxProcessExit, SandboxRemoveFileOptions, SandboxRequirement, SandboxResolvedRequirement, SandboxResolvedToolchain, SandboxRuntime, SandboxRuntimeDefinition, SandboxRuntimeInput, SandboxRuntimeOpenOptions, SandboxRuntimePlan, SandboxSession, SandboxSpawnOptions, SandboxToolchain, SandboxToolchainInput, SandboxToolchainOptions, SandboxToolchainPackageManagerPin, SandboxToolchainPin, SandboxToolchainPins, SandboxToolchainPlan, SandboxValue, type TrustedHostOptions, type VercelFileStat, type VercelSandboxCommand, type VercelSandboxCreateOptions, type VercelSandboxInstance, type VercelSandboxNetworkPolicy, type VercelSandboxOptions, type VercelSandboxSource, resolveSandbox };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { n as isBuiltInSandboxRuntime, t as hasDeclaredSandboxRuntimeMember } from "./runtime-
|
|
2
|
-
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { n as isBuiltInSandboxRuntime, t as hasDeclaredSandboxRuntimeMember } from "./runtime-EtWFVKud.js";
|
|
2
|
+
import { t as sandboxErrorDiagnostics } from "./error-diagnostics-CApUyzzu.js";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { readFile, realpath } from "node:fs/promises";
|
|
5
5
|
import { isAbsolute, posix, relative, resolve } from "node:path";
|
|
6
6
|
import { normalizeExecutionAuthority } from "@vite-hub/runtime";
|
|
7
|
-
|
|
7
|
+
// src/index.ts
|
|
8
8
|
const reservedRuntimeNames = /* @__PURE__ */ new Set([
|
|
9
9
|
"cloudflare",
|
|
10
10
|
"container",
|
|
@@ -22,15 +22,15 @@ async function resolveSandboxRuntime(value) {
|
|
|
22
22
|
}
|
|
23
23
|
if (typeof value === "string") {
|
|
24
24
|
if (value === "crabbox") {
|
|
25
|
-
const { createCrabboxRuntime } = await import("./crabbox-
|
|
25
|
+
const { createCrabboxRuntime } = await import("./crabbox-C7KeIKnH.js");
|
|
26
26
|
return createCrabboxRuntime();
|
|
27
27
|
}
|
|
28
28
|
if (value === "trusted-host") {
|
|
29
|
-
const { createTrustedHostRuntime } = await import("./trusted-host-
|
|
29
|
+
const { createTrustedHostRuntime } = await import("./trusted-host-CwMs64h1.js").then((n) => n.n);
|
|
30
30
|
return createTrustedHostRuntime();
|
|
31
31
|
}
|
|
32
32
|
if (value === "vercel") {
|
|
33
|
-
const { createVercelRuntime } = await import("./vercel-
|
|
33
|
+
const { createVercelRuntime } = await import("./vercel-DT74kDyI.js").then((n) => n.r);
|
|
34
34
|
return createVercelRuntime();
|
|
35
35
|
}
|
|
36
36
|
throw sandboxErrorDiagnostics.SANDBOX_R0031({ message: `[vitehub] Unknown Sandbox runtime "${value}". Expected "crabbox", "trusted-host", "vercel", a tagged built-in configuration, or a custom runtime.` });
|
|
@@ -40,27 +40,27 @@ async function resolveSandboxRuntime(value) {
|
|
|
40
40
|
const kind = config.kind;
|
|
41
41
|
if (config.kind === "crabbox") {
|
|
42
42
|
const options = withoutKind(config);
|
|
43
|
-
const { createCrabboxRuntime } = await import("./crabbox-
|
|
43
|
+
const { createCrabboxRuntime } = await import("./crabbox-C7KeIKnH.js");
|
|
44
44
|
return createCrabboxRuntime(options);
|
|
45
45
|
}
|
|
46
46
|
if (config.kind === "trusted-host") {
|
|
47
47
|
const options = withoutKind(config);
|
|
48
|
-
const { createTrustedHostRuntime } = await import("./trusted-host-
|
|
48
|
+
const { createTrustedHostRuntime } = await import("./trusted-host-CwMs64h1.js").then((n) => n.n);
|
|
49
49
|
return createTrustedHostRuntime(options);
|
|
50
50
|
}
|
|
51
51
|
if (config.kind === "cloudflare") {
|
|
52
52
|
const options = withoutKind(config);
|
|
53
|
-
const { createCloudflareRuntime } = await import("./cloudflare-
|
|
53
|
+
const { createCloudflareRuntime } = await import("./cloudflare-DrNRQPeh.js").then((n) => n.t);
|
|
54
54
|
return createCloudflareRuntime(options);
|
|
55
55
|
}
|
|
56
56
|
if (config.kind === "vercel") {
|
|
57
57
|
const options = withoutKind(config);
|
|
58
|
-
const { createVercelRuntime } = await import("./vercel-
|
|
58
|
+
const { createVercelRuntime } = await import("./vercel-DT74kDyI.js").then((n) => n.r);
|
|
59
59
|
return createVercelRuntime(options);
|
|
60
60
|
}
|
|
61
61
|
if (config.kind === "container") {
|
|
62
62
|
const options = withoutKind(config);
|
|
63
|
-
const { createContainerRuntime } = await import("./container-
|
|
63
|
+
const { createContainerRuntime } = await import("./container-DOadzngt.js");
|
|
64
64
|
return createContainerRuntime(options);
|
|
65
65
|
}
|
|
66
66
|
throw sandboxErrorDiagnostics.SANDBOX_R0033({ message: `[vitehub] Unknown Sandbox runtime kind "${String(kind)}". Expected "crabbox", "trusted-host", "cloudflare", "container", or "vercel".` });
|
|
@@ -148,10 +148,9 @@ async function resolveSandbox(definition, context, options = {}) {
|
|
|
148
148
|
plan: sandboxPlan
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
/** Read toolchain pins now unless they come from a checkout that exists only after open. */
|
|
152
151
|
async function resolveToolchain(declaration, projectRoot) {
|
|
153
152
|
if (declaration === void 0) return;
|
|
154
|
-
const [{ normalizeToolchain, readToolchainPins, toolchainReadsProject }, { readHostProjectFiles }] = await Promise.all([import("./toolchain-
|
|
153
|
+
const [{ normalizeToolchain, readToolchainPins, toolchainReadsProject }, { readHostProjectFiles }] = await Promise.all([import("./toolchain-DFFxmw3N.js").then((n) => n.i), import("./internal/host-toolchain.js")]);
|
|
155
154
|
const toolchain = normalizeToolchain(declaration, "sandbox.toolchain");
|
|
156
155
|
if (!toolchain) return;
|
|
157
156
|
if (!projectRoot && toolchainReadsProject(toolchain)) return toolchain;
|
|
@@ -323,5 +322,4 @@ function resolveSha(value) {
|
|
|
323
322
|
async function resolveValue(value, context) {
|
|
324
323
|
return typeof value === "function" ? await value(context) : value;
|
|
325
324
|
}
|
|
326
|
-
//#endregion
|
|
327
325
|
export { resolveSandbox };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { at as CloudflareSandboxOptions, l as Sandbox } from "../index-
|
|
2
|
-
//#region src/internal/cloudflare-durable-object.d.ts
|
|
1
|
+
import { at as CloudflareSandboxOptions, l as Sandbox } from "../index-D9DogaoF.js";
|
|
3
2
|
interface CloudflareContainerExecProcess {
|
|
4
3
|
readonly exitCode: Promise<number>;
|
|
5
4
|
readonly stderr: ReadableStream<Uint8Array> | null;
|
|
@@ -170,7 +169,5 @@ export declare function createCloudflareSandboxOutbound(dependencies: Cloudflare
|
|
|
170
169
|
fetch(request: Request): Promise<Response>;
|
|
171
170
|
};
|
|
172
171
|
export declare function createCloudflareSandboxDurableObject(dependencies: CloudflareSandboxDurableObjectDependencies): new (ctx: CloudflareDurableObjectState, env: unknown) => CloudflareSandboxDurableObject;
|
|
173
|
-
//#endregion
|
|
174
|
-
//#region src/internal/cloudflare.d.ts
|
|
175
172
|
export declare function resolveCloudflareSandbox(options: CloudflareSandboxOptions, requirements: readonly string[]): Promise<Sandbox>;
|
|
176
|
-
|
|
173
|
+
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { i as createCloudflareSandboxOutbound, n as createCloudflareRuntime, r as createCloudflareSandboxDurableObject } from "../cloudflare-DrNRQPeh.js";
|
|
2
|
+
import { a as resolveRemoteSandboxRuntime } from "../remote-DlyX1drC.js";
|
|
3
|
+
// src/internal/cloudflare.ts
|
|
4
4
|
async function resolveCloudflareSandbox(options, requirements) {
|
|
5
5
|
return await resolveRemoteSandboxRuntime(createCloudflareRuntime(options), requirements);
|
|
6
6
|
}
|
|
7
|
-
//#endregion
|
|
8
7
|
export { createCloudflareSandboxDurableObject, createCloudflareSandboxOutbound, resolveCloudflareSandbox };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { L as SandboxToolchain, R as SandboxToolchainInput, k as SandboxResolvedToolchain } from "../index-
|
|
2
|
-
//#region src/internal/host-toolchain.d.ts
|
|
1
|
+
import { L as SandboxToolchain, R as SandboxToolchainInput, k as SandboxResolvedToolchain } from "../index-D9DogaoF.js";
|
|
3
2
|
export interface HostToolchainOptions {
|
|
4
3
|
abortSignal?: AbortSignal;
|
|
5
4
|
/** Shared cache directory. Defaults to `$XDG_CACHE_HOME/vitehub/toolchains`. */
|
|
@@ -18,5 +17,4 @@ export declare function provisionHostToolchain(toolchain: SandboxToolchainInput,
|
|
|
18
17
|
/** PATH with the toolchain entries before the base PATH. */
|
|
19
18
|
export declare function toolchainPath(toolchain: SandboxResolvedToolchain, base: string | undefined): string;
|
|
20
19
|
/** Validate a toolchain declaration and provision it for a host directory. */
|
|
21
|
-
export declare function prepareHostToolchain(declaration: SandboxToolchain, directory: string, options?: HostToolchainOptions): Promise<SandboxResolvedToolchain>;
|
|
22
|
-
//#endregion
|
|
20
|
+
export declare function prepareHostToolchain(declaration: SandboxToolchain, directory: string, options?: HostToolchainOptions): Promise<SandboxResolvedToolchain>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { t as sandboxErrorDiagnostics } from "../error-diagnostics-
|
|
2
|
-
import { t as acquireFileLock } from "../file-lock-
|
|
3
|
-
import { a as verifyToolchain, n as provisionToolchain, r as toolchainProjectFiles, t as normalizeToolchain } from "../toolchain-
|
|
1
|
+
import { t as sandboxErrorDiagnostics } from "../error-diagnostics-CApUyzzu.js";
|
|
2
|
+
import { t as acquireFileLock } from "../file-lock-CqA7b491.js";
|
|
3
|
+
import { a as verifyToolchain, n as provisionToolchain, r as toolchainProjectFiles, t as normalizeToolchain } from "../toolchain-DFFxmw3N.js";
|
|
4
4
|
import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
5
5
|
import { delimiter, dirname, join, resolve } from "node:path";
|
|
6
6
|
import { execFile } from "node:child_process";
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
|
-
|
|
9
|
+
// src/internal/host-toolchain.ts
|
|
10
10
|
/** Default host cache. A configured Sandbox stateRoot keeps toolchains beside durable state. */
|
|
11
11
|
function hostToolchainCacheRoot(stateRoot) {
|
|
12
12
|
return stateRoot ? join(stateRoot, "toolchains") : join(process.env.XDG_CACHE_HOME || join(homedir(), ".cache"), "vitehub", "toolchains");
|
|
@@ -92,5 +92,4 @@ function toolchainPath(toolchain, base) {
|
|
|
92
92
|
async function prepareHostToolchain(declaration, directory, options = {}) {
|
|
93
93
|
return await provisionHostToolchain(normalizeToolchain(declaration), directory, options);
|
|
94
94
|
}
|
|
95
|
-
//#endregion
|
|
96
95
|
export { hostToolchainCacheRoot, prepareHostToolchain, provisionHostToolchain, readHostProjectFiles, toolchainPath };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { Z as VercelSandboxOptions, l as Sandbox } from "../index-
|
|
2
|
-
|
|
3
|
-
export declare function resolveVercelSandbox(options: VercelSandboxOptions, requirements: readonly string[]): Promise<Sandbox>;
|
|
4
|
-
//#endregion
|
|
1
|
+
import { Z as VercelSandboxOptions, l as Sandbox } from "../index-D9DogaoF.js";
|
|
2
|
+
export declare function resolveVercelSandbox(options: VercelSandboxOptions, requirements: readonly string[]): Promise<Sandbox>;
|
package/dist/internal/vercel.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { t as createVercelRuntime } from "../vercel-DT74kDyI.js";
|
|
2
|
+
import { a as resolveRemoteSandboxRuntime } from "../remote-DlyX1drC.js";
|
|
3
|
+
// src/internal/vercel.ts
|
|
4
4
|
async function resolveVercelSandbox(options, requirements) {
|
|
5
5
|
return await resolveRemoteSandboxRuntime(createVercelRuntime(options), requirements);
|
|
6
6
|
}
|
|
7
|
-
//#endregion
|
|
8
7
|
export { resolveVercelSandbox };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
|
-
|
|
2
|
+
// ../internal/src/invariant.ts
|
|
3
3
|
const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
4
4
|
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
5
5
|
codes: { INTERNAL_INVARIANT_FAILED: {
|
|
@@ -18,5 +18,4 @@ function invariantError(what) {
|
|
|
18
18
|
function invariant(condition, what) {
|
|
19
19
|
if (!condition) throw invariantError(what);
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { invariantError as n, invariant as t };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Q as VercelSandboxSource, X as VercelSandboxNetworkPolicy, st as SandboxNetworkPolicy } from "./index-
|
|
1
|
+
import { Q as VercelSandboxSource, X as VercelSandboxNetworkPolicy, st as SandboxNetworkPolicy } from "./index-D9DogaoF.js";
|
|
2
2
|
import { ViteHubError } from "@vite-hub/runtime";
|
|
3
|
-
//#region src/task/project.d.ts
|
|
4
3
|
type SandboxTaskPackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
|
|
5
4
|
interface SandboxTaskProjectFile {
|
|
6
5
|
contents: string;
|
|
@@ -18,8 +17,6 @@ interface SandboxTaskProject {
|
|
|
18
17
|
options?: SandboxTaskProjectOptions;
|
|
19
18
|
packagePath: string;
|
|
20
19
|
}
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/task/runtime/result.d.ts
|
|
23
20
|
declare const sandboxTaskRunErrors: import("@vite-hub/runtime").ErrorCatalog<{
|
|
24
21
|
readonly SANDBOX_TASK_RUN_FAILED: {
|
|
25
22
|
readonly why: ({ name, code }: {
|
|
@@ -36,8 +33,6 @@ declare const sandboxTaskRunErrors: import("@vite-hub/runtime").ErrorCatalog<{
|
|
|
36
33
|
};
|
|
37
34
|
};
|
|
38
35
|
}>;
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/task/size.d.ts
|
|
41
36
|
/** The size of the machine that runs every Sandbox Task. Both values are minimums. */
|
|
42
37
|
interface SandboxTaskSizeOptions {
|
|
43
38
|
/** Minimum vCPUs. ViteHub picks the smallest provider size that gives at least this many. */
|
|
@@ -45,8 +40,6 @@ interface SandboxTaskSizeOptions {
|
|
|
45
40
|
/** Minimum memory in MiB. ViteHub picks the smallest provider size that gives at least this much. */
|
|
46
41
|
memory?: number;
|
|
47
42
|
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/task/module-types.d.ts
|
|
50
43
|
type SandboxTaskDriver = 'cloudflare' | 'vercel';
|
|
51
44
|
interface CloudflareSandboxTaskOptions {
|
|
52
45
|
sleepAfter?: string | number;
|
|
@@ -134,5 +127,4 @@ type SandboxTaskDefinitionFromHandler<THandler extends (...args: any[]) => any>
|
|
|
134
127
|
*/
|
|
135
128
|
type SandboxTaskRunResult<TResult = unknown> = [error: ReturnType<typeof sandboxTaskRunErrors.SANDBOX_TASK_RUN_FAILED>, data: undefined] | [error: undefined, data: TResult];
|
|
136
129
|
declare function getSandboxTaskFeatureDriver(config?: AgentSandboxTaskConfig | false): SandboxTaskDefinitionDriverOptions | undefined;
|
|
137
|
-
//#endregion
|
|
138
130
|
export { VercelSandboxTaskDriverOptions as _, SandboxTaskDefinitionBundle as a, SandboxTaskDefinitionHandler as c, SandboxTaskDevOptions as d, SandboxTaskDriver as f, SandboxTaskRunResult as g, SandboxTaskRunArguments as h, SandboxTaskDefinition as i, SandboxTaskDefinitionInput as l, SandboxTaskProjectOptions as m, CloudflareSandboxTaskDefinitionDriverOptions as n, SandboxTaskDefinitionDriverOptions as o, SandboxTaskExecutionOptions as p, CloudflareSandboxTaskOptions as r, SandboxTaskDefinitionFromHandler as s, AgentSandboxTaskConfig as t, SandboxTaskDefinitionOptions as u, getSandboxTaskFeatureDriver as v, SandboxTaskSizeOptions as y };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// src/task/module-types.ts
|
|
2
2
|
function getSandboxTaskFeatureDriver(config) {
|
|
3
3
|
if (!config || typeof config !== "object" || typeof config.driver !== "string") return void 0;
|
|
4
4
|
return config;
|
|
5
5
|
}
|
|
6
|
-
//#endregion
|
|
7
6
|
export { getSandboxTaskFeatureDriver as t };
|