sandboxedjs 0.2.21 → 0.2.23
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/agent.cjs +20 -14
- package/dist/agent.d.cts +4 -4
- package/dist/agent.d.ts +4 -4
- package/dist/agent.js +20 -14
- package/dist/{container-D-e5SMXQ.d.ts → container-CPwPlvmB.d.cts} +9 -1
- package/dist/{container-BQx27_d-.d.cts → container-DZabLWLy.d.ts} +9 -1
- package/dist/{contracts-BHo4LdY2.d.cts → contracts-BFG82pSs.d.cts} +40 -2
- package/dist/{contracts-BHo4LdY2.d.ts → contracts-BFG82pSs.d.ts} +40 -2
- package/dist/index.cjs +1033 -783
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1033 -783
- package/dist/{memory-volume-meoRW8ST.d.ts → memory-volume-DhGUwDqX.d.ts} +1 -1
- package/dist/{memory-volume-e-uJFRnG.d.cts → memory-volume-Din7xmmT.d.cts} +1 -1
- package/dist/python-abi.d.cts +3 -3
- package/dist/python-abi.d.ts +3 -3
- package/dist/worker-entry.js +24296 -2666
- package/docs/nextjs-compatibility.md +17 -0
- package/docs/to_implement/agent.md +178 -44
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,12 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var pako = require('pako');
|
|
6
6
|
var sha256 = require('@noble/hashes/sha256');
|
|
7
|
-
var acorn = require('acorn');
|
|
8
|
-
var jsx = require('acorn-jsx');
|
|
9
7
|
var index_js = require('buffer/index.js');
|
|
10
8
|
var sha512 = require('@noble/hashes/sha512');
|
|
11
9
|
var sha1 = require('@noble/hashes/sha1');
|
|
12
10
|
var semver = require('semver');
|
|
11
|
+
var acorn = require('acorn');
|
|
12
|
+
var jsx = require('acorn-jsx');
|
|
13
|
+
var sucrase = require('sucrase');
|
|
13
14
|
var EventEmitter4 = require('events/events.js');
|
|
14
15
|
var resolve_exports = require('resolve.exports');
|
|
15
16
|
var pathModule = require('path-browserify');
|
|
@@ -4146,9 +4147,9 @@ async function randomUuid() {
|
|
|
4146
4147
|
const { randomUUID } = await nodeCrypto();
|
|
4147
4148
|
return randomUUID();
|
|
4148
4149
|
}
|
|
4149
|
-
function toHex(
|
|
4150
|
+
function toHex(bytes3) {
|
|
4150
4151
|
let out = "";
|
|
4151
|
-
for (const byte of
|
|
4152
|
+
for (const byte of bytes3) out += byte.toString(16).padStart(2, "0");
|
|
4152
4153
|
return out;
|
|
4153
4154
|
}
|
|
4154
4155
|
function md5Hex(input) {
|
|
@@ -4886,12 +4887,12 @@ var Vfs = class {
|
|
|
4886
4887
|
writeFile(abs, data, opts = {}) {
|
|
4887
4888
|
const cred = opts.privileged ? void 0 : opts.cred;
|
|
4888
4889
|
const real = this.resolvePath(abs, { cred });
|
|
4889
|
-
const
|
|
4890
|
+
const bytes3 = typeof data === "string" ? encoder.encode(data) : data;
|
|
4890
4891
|
const virt = this.lookupVirtual(real);
|
|
4891
4892
|
if (virt) {
|
|
4892
4893
|
if (!virt.write) throw new exports.SysError("EACCES", "write", real);
|
|
4893
4894
|
this.require(this.statFromVirtual(real, virt), W_OK, cred, "open", real);
|
|
4894
|
-
virt.write(
|
|
4895
|
+
virt.write(bytes3, opts.append ?? false);
|
|
4895
4896
|
return;
|
|
4896
4897
|
}
|
|
4897
4898
|
if (this.isUnderProvider(real)) throw new exports.SysError("ENOENT", "open", real);
|
|
@@ -4906,8 +4907,8 @@ var Vfs = class {
|
|
|
4906
4907
|
this.require(pst, W_OK | X_OK, cred, "open", real);
|
|
4907
4908
|
}
|
|
4908
4909
|
try {
|
|
4909
|
-
if (opts.append && existing) this.volume.appendFileSync(real,
|
|
4910
|
-
else this.volume.writeFileSync(real,
|
|
4910
|
+
if (opts.append && existing) this.volume.appendFileSync(real, bytes3);
|
|
4911
|
+
else this.volume.writeFileSync(real, bytes3);
|
|
4911
4912
|
} catch (e) {
|
|
4912
4913
|
throw toSysError(e, "open", real);
|
|
4913
4914
|
}
|
|
@@ -5159,7 +5160,7 @@ var Vfs = class {
|
|
|
5159
5160
|
usage(abs = "/") {
|
|
5160
5161
|
let files = 0;
|
|
5161
5162
|
let dirs = 0;
|
|
5162
|
-
let
|
|
5163
|
+
let bytes3 = 0;
|
|
5163
5164
|
for (const p of this.walk(abs)) {
|
|
5164
5165
|
let st = null;
|
|
5165
5166
|
try {
|
|
@@ -5170,10 +5171,10 @@ var Vfs = class {
|
|
|
5170
5171
|
if (st.isDirectory()) dirs++;
|
|
5171
5172
|
else {
|
|
5172
5173
|
files++;
|
|
5173
|
-
|
|
5174
|
+
bytes3 += st.size;
|
|
5174
5175
|
}
|
|
5175
5176
|
}
|
|
5176
|
-
return { files, dirs, bytes:
|
|
5177
|
+
return { files, dirs, bytes: bytes3 };
|
|
5177
5178
|
}
|
|
5178
5179
|
};
|
|
5179
5180
|
|
|
@@ -5257,10 +5258,10 @@ var Pipe = class _Pipe {
|
|
|
5257
5258
|
write(data) {
|
|
5258
5259
|
if (this.readerClosed) throw new exports.SysError("EPIPE", "write");
|
|
5259
5260
|
if (this.writerClosed) return;
|
|
5260
|
-
const
|
|
5261
|
-
if (
|
|
5262
|
-
this.chunks.push(
|
|
5263
|
-
this.buffered +=
|
|
5261
|
+
const bytes3 = this.icrnl && !this.raw ? translateCarriageReturns(toBytes(data)) : toBytes(data);
|
|
5262
|
+
if (bytes3.length === 0) return;
|
|
5263
|
+
this.chunks.push(bytes3);
|
|
5264
|
+
this.buffered += bytes3.length;
|
|
5264
5265
|
this.wake();
|
|
5265
5266
|
}
|
|
5266
5267
|
end() {
|
|
@@ -5350,15 +5351,15 @@ var Pipe = class _Pipe {
|
|
|
5350
5351
|
return p;
|
|
5351
5352
|
}
|
|
5352
5353
|
};
|
|
5353
|
-
function translateCarriageReturns(
|
|
5354
|
-
if (!
|
|
5355
|
-
const out = new Uint8Array(
|
|
5354
|
+
function translateCarriageReturns(bytes3) {
|
|
5355
|
+
if (!bytes3.includes(CR)) return bytes3;
|
|
5356
|
+
const out = new Uint8Array(bytes3.length);
|
|
5356
5357
|
let length = 0;
|
|
5357
|
-
for (let index = 0; index <
|
|
5358
|
-
const byte =
|
|
5358
|
+
for (let index = 0; index < bytes3.length; index += 1) {
|
|
5359
|
+
const byte = bytes3[index];
|
|
5359
5360
|
if (byte === CR) {
|
|
5360
5361
|
out[length++] = LF;
|
|
5361
|
-
if (
|
|
5362
|
+
if (bytes3[index + 1] === LF) index += 1;
|
|
5362
5363
|
} else {
|
|
5363
5364
|
out[length++] = byte;
|
|
5364
5365
|
}
|
|
@@ -5404,11 +5405,11 @@ var BufferSink = class {
|
|
|
5404
5405
|
}
|
|
5405
5406
|
write(data) {
|
|
5406
5407
|
if (this._closed) return;
|
|
5407
|
-
const
|
|
5408
|
-
if (
|
|
5409
|
-
this.chunks.push(
|
|
5410
|
-
this.total +=
|
|
5411
|
-
this.onWrite?.(
|
|
5408
|
+
const bytes3 = toBytes(data);
|
|
5409
|
+
if (bytes3.length === 0) return;
|
|
5410
|
+
this.chunks.push(bytes3);
|
|
5411
|
+
this.total += bytes3.length;
|
|
5412
|
+
this.onWrite?.(bytes3);
|
|
5412
5413
|
}
|
|
5413
5414
|
end() {
|
|
5414
5415
|
this._closed = true;
|
|
@@ -6297,8 +6298,8 @@ var SIZEOF_FDSTAT = 24;
|
|
|
6297
6298
|
var SIZEOF_DIRENT = 24;
|
|
6298
6299
|
var SIZEOF_SUBSCRIPTION = 48;
|
|
6299
6300
|
var SIZEOF_EVENT = 32;
|
|
6300
|
-
function isWasmBinary(
|
|
6301
|
-
return
|
|
6301
|
+
function isWasmBinary(bytes3) {
|
|
6302
|
+
return bytes3.length >= 4 && bytes3[0] === 0 && bytes3[1] === 97 && bytes3[2] === 115 && bytes3[3] === 109;
|
|
6302
6303
|
}
|
|
6303
6304
|
|
|
6304
6305
|
// src/wasi/host.ts
|
|
@@ -7088,8 +7089,8 @@ function defaultSleep(milliseconds) {
|
|
|
7088
7089
|
// src/wasi/run.ts
|
|
7089
7090
|
var compiled = /* @__PURE__ */ new Map();
|
|
7090
7091
|
var MAX_CACHED_MODULES = 32;
|
|
7091
|
-
async function runWasi(ctx,
|
|
7092
|
-
if (!isWasmBinary(
|
|
7092
|
+
async function runWasi(ctx, bytes3, options = {}) {
|
|
7093
|
+
if (!isWasmBinary(bytes3)) {
|
|
7093
7094
|
ctx.warn("cannot execute binary file: not a WebAssembly module");
|
|
7094
7095
|
return EXIT_NOT_EXECUTABLE;
|
|
7095
7096
|
}
|
|
@@ -7113,7 +7114,7 @@ async function runWasi(ctx, bytes2, options = {}) {
|
|
|
7113
7114
|
});
|
|
7114
7115
|
let instance;
|
|
7115
7116
|
try {
|
|
7116
|
-
const module = await compile(
|
|
7117
|
+
const module = await compile(bytes3);
|
|
7117
7118
|
instance = await WebAssembly.instantiate(module, {
|
|
7118
7119
|
...options.imports,
|
|
7119
7120
|
wasi_snapshot_preview1: host2.wasiImport,
|
|
@@ -7149,15 +7150,15 @@ async function runWasi(ctx, bytes2, options = {}) {
|
|
|
7149
7150
|
}
|
|
7150
7151
|
}
|
|
7151
7152
|
}
|
|
7152
|
-
async function compile(
|
|
7153
|
-
const key = await digest(
|
|
7153
|
+
async function compile(bytes3) {
|
|
7154
|
+
const key = await digest(bytes3);
|
|
7154
7155
|
const hit = compiled.get(key);
|
|
7155
7156
|
if (hit) {
|
|
7156
7157
|
compiled.delete(key);
|
|
7157
7158
|
compiled.set(key, hit);
|
|
7158
7159
|
return hit;
|
|
7159
7160
|
}
|
|
7160
|
-
const module = await WebAssembly.compile(sliceForWasm(
|
|
7161
|
+
const module = await WebAssembly.compile(sliceForWasm(bytes3));
|
|
7161
7162
|
compiled.set(key, module);
|
|
7162
7163
|
if (compiled.size > MAX_CACHED_MODULES) {
|
|
7163
7164
|
const oldest = compiled.keys().next().value;
|
|
@@ -7165,12 +7166,12 @@ async function compile(bytes2) {
|
|
|
7165
7166
|
}
|
|
7166
7167
|
return module;
|
|
7167
7168
|
}
|
|
7168
|
-
async function digest(
|
|
7169
|
-
const hash = await crypto.subtle.digest("SHA-256", sliceForWasm(
|
|
7169
|
+
async function digest(bytes3) {
|
|
7170
|
+
const hash = await crypto.subtle.digest("SHA-256", sliceForWasm(bytes3));
|
|
7170
7171
|
return Array.from(new Uint8Array(hash, 0, 16), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
7171
7172
|
}
|
|
7172
|
-
function sliceForWasm(
|
|
7173
|
-
return
|
|
7173
|
+
function sliceForWasm(bytes3) {
|
|
7174
|
+
return bytes3.buffer.slice(bytes3.byteOffset, bytes3.byteOffset + bytes3.byteLength);
|
|
7174
7175
|
}
|
|
7175
7176
|
async function primeStdin(ctx) {
|
|
7176
7177
|
let pending = new Uint8Array(0);
|
|
@@ -7202,19 +7203,19 @@ function describeStartupFailure(error) {
|
|
|
7202
7203
|
}
|
|
7203
7204
|
|
|
7204
7205
|
// src/compat/execution.ts
|
|
7205
|
-
function binaryDigest(
|
|
7206
|
-
return Array.from(sha256.sha256(
|
|
7206
|
+
function binaryDigest(bytes3) {
|
|
7207
|
+
return Array.from(sha256.sha256(bytes3), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
7207
7208
|
}
|
|
7208
|
-
function isElfBinary(
|
|
7209
|
-
return
|
|
7209
|
+
function isElfBinary(bytes3) {
|
|
7210
|
+
return bytes3[0] === 127 && bytes3[1] === 69 && bytes3[2] === 76 && bytes3[3] === 70;
|
|
7210
7211
|
}
|
|
7211
|
-
function inspectElf(
|
|
7212
|
-
if (!isElfBinary(
|
|
7213
|
-
const littleEndian =
|
|
7214
|
-
const machine = new DataView(
|
|
7212
|
+
function inspectElf(bytes3) {
|
|
7213
|
+
if (!isElfBinary(bytes3) || ![1, 2].includes(bytes3[4]) || ![1, 2].includes(bytes3[5]) || bytes3[6] !== 1 || bytes3.length < (bytes3[4] === 2 ? 64 : 52)) throw new Error("invalid or truncated ELF header");
|
|
7214
|
+
const littleEndian = bytes3[5] === 1;
|
|
7215
|
+
const machine = new DataView(bytes3.buffer, bytes3.byteOffset, bytes3.byteLength).getUint16(18, littleEndian);
|
|
7215
7216
|
return {
|
|
7216
7217
|
format: "elf",
|
|
7217
|
-
bits:
|
|
7218
|
+
bits: bytes3[4] === 2 ? 64 : 32,
|
|
7218
7219
|
machine,
|
|
7219
7220
|
littleEndian,
|
|
7220
7221
|
architecture: { 3: "x86", 62: "x86_64", 40: "arm", 183: "aarch64", 243: "riscv" }[machine] ?? `machine-${machine}`
|
|
@@ -7241,14 +7242,14 @@ var BinaryExecutionRegistry = class {
|
|
|
7241
7242
|
return this.backends.map(({ id, tier }) => ({ id, tier }));
|
|
7242
7243
|
}
|
|
7243
7244
|
async run(ctx, path) {
|
|
7244
|
-
const
|
|
7245
|
+
const bytes3 = ctx.vfs.readFile(path, ctx.cred);
|
|
7245
7246
|
let info2;
|
|
7246
7247
|
try {
|
|
7247
|
-
info2 = inspectElf(
|
|
7248
|
+
info2 = inspectElf(bytes3);
|
|
7248
7249
|
} catch (error) {
|
|
7249
7250
|
return ctx.fail(String(error), 126);
|
|
7250
7251
|
}
|
|
7251
|
-
const request = { path, bytes:
|
|
7252
|
+
const request = { path, bytes: bytes3, info: info2, sha256: binaryDigest(bytes3) };
|
|
7252
7253
|
const reasons = [];
|
|
7253
7254
|
const backends = [...this.backends];
|
|
7254
7255
|
for (const tier of ["compatibility", "translation", "emulation"]) {
|
|
@@ -7271,10 +7272,10 @@ var BinaryExecutionRegistry = class {
|
|
|
7271
7272
|
}
|
|
7272
7273
|
};
|
|
7273
7274
|
function checkedWasm(artifact) {
|
|
7274
|
-
const
|
|
7275
|
-
if (!/^[a-f0-9]{64}$/i.test(artifact.sha256) || binaryDigest(
|
|
7276
|
-
if (!WebAssembly.validate(
|
|
7277
|
-
return
|
|
7275
|
+
const bytes3 = artifact.bytes.slice();
|
|
7276
|
+
if (!/^[a-f0-9]{64}$/i.test(artifact.sha256) || binaryDigest(bytes3) !== artifact.sha256.toLowerCase()) throw new Error("Wasm artifact integrity mismatch");
|
|
7277
|
+
if (!WebAssembly.validate(bytes3)) throw new Error("invalid WebAssembly artifact");
|
|
7278
|
+
return bytes3;
|
|
7278
7279
|
}
|
|
7279
7280
|
function installWasmCommands(kernel, artifacts) {
|
|
7280
7281
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -7283,7 +7284,7 @@ function installWasmCommands(kernel, artifacts) {
|
|
|
7283
7284
|
names.add(artifact.name);
|
|
7284
7285
|
return { name: artifact.name, bytes: checkedWasm(artifact) };
|
|
7285
7286
|
});
|
|
7286
|
-
for (const { name, bytes:
|
|
7287
|
+
for (const { name, bytes: bytes3 } of checked) kernel.installCommand({ name, run: (ctx) => runWasi(ctx, bytes3) });
|
|
7287
7288
|
}
|
|
7288
7289
|
function createWasmCompatibilityBackend(id, entries) {
|
|
7289
7290
|
const ports = new Map(entries.map((entry) => {
|
|
@@ -7291,8 +7292,8 @@ function createWasmCompatibilityBackend(id, entries) {
|
|
|
7291
7292
|
return [entry.elfSha256.toLowerCase(), checkedWasm(entry.wasm)];
|
|
7292
7293
|
}));
|
|
7293
7294
|
return { id, tier: "compatibility", prepare(request) {
|
|
7294
|
-
const
|
|
7295
|
-
return
|
|
7295
|
+
const bytes3 = ports.get(request.sha256);
|
|
7296
|
+
return bytes3 ? { supported: true, program: { run: (ctx) => runWasi(ctx, bytes3, { argv: [request.path, ...ctx.args] }) } } : { supported: false, reason: "no port for this binary digest" };
|
|
7296
7297
|
} };
|
|
7297
7298
|
}
|
|
7298
7299
|
function createTranslationBackend(translator, maxCacheBytes = 32 * 1024 * 1024) {
|
|
@@ -7301,32 +7302,32 @@ function createTranslationBackend(translator, maxCacheBytes = 32 * 1024 * 1024)
|
|
|
7301
7302
|
let size = 0;
|
|
7302
7303
|
return { id: translator.id, tier: "translation", async prepare(request, signal) {
|
|
7303
7304
|
if (!translator.supports(request.info)) return { supported: false, reason: "unsupported ELF architecture" };
|
|
7304
|
-
let
|
|
7305
|
-
if (
|
|
7305
|
+
let bytes3 = cache.get(request.sha256);
|
|
7306
|
+
if (bytes3) {
|
|
7306
7307
|
cache.delete(request.sha256);
|
|
7307
|
-
cache.set(request.sha256,
|
|
7308
|
+
cache.set(request.sha256, bytes3);
|
|
7308
7309
|
} else {
|
|
7309
7310
|
const output = await translator.translate(request, signal);
|
|
7310
7311
|
if (signal.aborted) return { supported: false, reason: "cancelled" };
|
|
7311
7312
|
if (!output) return { supported: false, reason: "translator declined this program" };
|
|
7312
|
-
|
|
7313
|
-
if (!WebAssembly.validate(
|
|
7314
|
-
if (
|
|
7313
|
+
bytes3 = output.slice();
|
|
7314
|
+
if (!WebAssembly.validate(bytes3.slice())) throw new Error(`${translator.id}: invalid translator output`);
|
|
7315
|
+
if (bytes3.byteLength <= maxCacheBytes) {
|
|
7315
7316
|
const previous = cache.get(request.sha256);
|
|
7316
7317
|
if (previous) {
|
|
7317
7318
|
size -= previous.byteLength;
|
|
7318
7319
|
cache.delete(request.sha256);
|
|
7319
7320
|
}
|
|
7320
|
-
while (size +
|
|
7321
|
+
while (size + bytes3.byteLength > maxCacheBytes && cache.size) {
|
|
7321
7322
|
const key = cache.keys().next().value;
|
|
7322
7323
|
size -= cache.get(key).byteLength;
|
|
7323
7324
|
cache.delete(key);
|
|
7324
7325
|
}
|
|
7325
|
-
cache.set(request.sha256,
|
|
7326
|
-
size +=
|
|
7326
|
+
cache.set(request.sha256, bytes3);
|
|
7327
|
+
size += bytes3.byteLength;
|
|
7327
7328
|
}
|
|
7328
7329
|
}
|
|
7329
|
-
const artifact =
|
|
7330
|
+
const artifact = bytes3;
|
|
7330
7331
|
return { supported: true, program: { run: (ctx) => runWasi(ctx, artifact, { argv: [request.path, ...ctx.args] }) } };
|
|
7331
7332
|
} };
|
|
7332
7333
|
}
|
|
@@ -8375,18 +8376,18 @@ function createSysProvider(kernel) {
|
|
|
8375
8376
|
}
|
|
8376
8377
|
|
|
8377
8378
|
// src/net/proxy-fetch.ts
|
|
8378
|
-
function toBase64(
|
|
8379
|
+
function toBase64(bytes3) {
|
|
8379
8380
|
let text2 = "";
|
|
8380
|
-
for (let at = 0; at <
|
|
8381
|
-
text2 += String.fromCharCode(...
|
|
8381
|
+
for (let at = 0; at < bytes3.length; at += 32768) {
|
|
8382
|
+
text2 += String.fromCharCode(...bytes3.subarray(at, at + 32768));
|
|
8382
8383
|
}
|
|
8383
8384
|
return btoa(text2);
|
|
8384
8385
|
}
|
|
8385
8386
|
function fromBase64(text2) {
|
|
8386
8387
|
const binary = atob(text2);
|
|
8387
|
-
const
|
|
8388
|
-
for (let at = 0; at < binary.length; at += 1)
|
|
8389
|
-
return
|
|
8388
|
+
const bytes3 = new Uint8Array(binary.length);
|
|
8389
|
+
for (let at = 0; at < binary.length; at += 1) bytes3[at] = binary.charCodeAt(at);
|
|
8390
|
+
return bytes3;
|
|
8390
8391
|
}
|
|
8391
8392
|
async function proxyExchange(proxy, request, fetchImpl = fetch) {
|
|
8392
8393
|
let answer;
|
|
@@ -8473,6 +8474,93 @@ async function discoverEgress(fetchImpl = fetch) {
|
|
|
8473
8474
|
return await found;
|
|
8474
8475
|
}
|
|
8475
8476
|
|
|
8477
|
+
// src/net/secrets.ts
|
|
8478
|
+
var PLACEHOLDER = /\{\{secret:([A-Za-z_][A-Za-z0-9_]*)\}\}/g;
|
|
8479
|
+
var REDACTED = "[sealed]";
|
|
8480
|
+
var SecretRefused = class extends Error {
|
|
8481
|
+
code = "EACCES";
|
|
8482
|
+
};
|
|
8483
|
+
function hostBound(secret, hostname) {
|
|
8484
|
+
return secret.hosts.some((host2) => hostname === host2 || hostname.endsWith(`.${host2}`));
|
|
8485
|
+
}
|
|
8486
|
+
function mentionsSecret(text2) {
|
|
8487
|
+
PLACEHOLDER.lastIndex = 0;
|
|
8488
|
+
return PLACEHOLDER.test(text2);
|
|
8489
|
+
}
|
|
8490
|
+
function substituteSecrets(text2, hostname, secrets) {
|
|
8491
|
+
return text2.replace(PLACEHOLDER, (_match, name) => {
|
|
8492
|
+
const secret = Object.prototype.hasOwnProperty.call(secrets, name) ? secrets[name] : void 0;
|
|
8493
|
+
if (!secret) {
|
|
8494
|
+
throw new SecretRefused(`no sealed secret named ${name} is configured for this container`);
|
|
8495
|
+
}
|
|
8496
|
+
if (!hostBound(secret, hostname)) {
|
|
8497
|
+
throw new SecretRefused(
|
|
8498
|
+
`the sealed secret ${name} is not bound to ${hostname}; it may only be sent to ${secret.hosts.join(", ") || "no host"}`
|
|
8499
|
+
);
|
|
8500
|
+
}
|
|
8501
|
+
return secret.value;
|
|
8502
|
+
});
|
|
8503
|
+
}
|
|
8504
|
+
function sealRequest(request, secrets) {
|
|
8505
|
+
const url = new URL(request.url);
|
|
8506
|
+
if (mentionsSecret(decodeURIComponent(url.href))) {
|
|
8507
|
+
throw new SecretRefused("a sealed secret can only be used in a request header, not in the URL");
|
|
8508
|
+
}
|
|
8509
|
+
const used = [];
|
|
8510
|
+
let headers = null;
|
|
8511
|
+
request.headers.forEach((value, name) => {
|
|
8512
|
+
if (!mentionsSecret(value)) return;
|
|
8513
|
+
headers ??= new Headers(request.headers);
|
|
8514
|
+
headers.set(name, substituteSecrets(value, url.hostname, secrets));
|
|
8515
|
+
PLACEHOLDER.lastIndex = 0;
|
|
8516
|
+
for (const match2 of value.matchAll(PLACEHOLDER)) used.push(match2[1]);
|
|
8517
|
+
});
|
|
8518
|
+
return headers ? { request: new Request(request, { headers }), used } : { request, used };
|
|
8519
|
+
}
|
|
8520
|
+
function redactResponse(response, secrets) {
|
|
8521
|
+
const values = Object.values(secrets).map((secret) => secret.value).filter((value) => value.length > 0);
|
|
8522
|
+
if (values.length === 0) return response;
|
|
8523
|
+
const headers = new Headers();
|
|
8524
|
+
response.headers.forEach((value, name) => headers.set(name, redactText(value, values)));
|
|
8525
|
+
const init = { status: response.status, statusText: response.statusText, headers };
|
|
8526
|
+
if (!response.body) return new Response(null, init);
|
|
8527
|
+
headers.delete("content-length");
|
|
8528
|
+
return new Response(response.body.pipeThrough(redactingStream(values)), init);
|
|
8529
|
+
}
|
|
8530
|
+
function redactText(text2, values) {
|
|
8531
|
+
let out = text2;
|
|
8532
|
+
for (const value of values) out = out.split(value).join(REDACTED);
|
|
8533
|
+
return out;
|
|
8534
|
+
}
|
|
8535
|
+
function redactingStream(values) {
|
|
8536
|
+
const needles = values.map((value) => latin1(new TextEncoder().encode(value)));
|
|
8537
|
+
const hold = Math.max(...needles.map((needle) => needle.length)) - 1;
|
|
8538
|
+
let pending = "";
|
|
8539
|
+
return new TransformStream({
|
|
8540
|
+
transform(chunk, controller) {
|
|
8541
|
+
pending = redactText(pending + latin1(chunk), needles);
|
|
8542
|
+
if (pending.length <= hold) return;
|
|
8543
|
+
controller.enqueue(bytes(pending.slice(0, pending.length - hold)));
|
|
8544
|
+
pending = pending.slice(pending.length - hold);
|
|
8545
|
+
},
|
|
8546
|
+
flush(controller) {
|
|
8547
|
+
if (pending) controller.enqueue(bytes(redactText(pending, needles)));
|
|
8548
|
+
}
|
|
8549
|
+
});
|
|
8550
|
+
}
|
|
8551
|
+
function latin1(chunk) {
|
|
8552
|
+
let out = "";
|
|
8553
|
+
for (let at = 0; at < chunk.length; at += 32768) {
|
|
8554
|
+
out += String.fromCharCode(...chunk.subarray(at, at + 32768));
|
|
8555
|
+
}
|
|
8556
|
+
return out;
|
|
8557
|
+
}
|
|
8558
|
+
function bytes(text2) {
|
|
8559
|
+
const out = new Uint8Array(text2.length);
|
|
8560
|
+
for (let index = 0; index < text2.length; index += 1) out[index] = text2.charCodeAt(index);
|
|
8561
|
+
return out;
|
|
8562
|
+
}
|
|
8563
|
+
|
|
8476
8564
|
// src/net/policy.ts
|
|
8477
8565
|
function isLoopbackHostname(hostname) {
|
|
8478
8566
|
const host2 = hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
@@ -8510,6 +8598,24 @@ function requestUrl(input) {
|
|
|
8510
8598
|
return input.url;
|
|
8511
8599
|
}
|
|
8512
8600
|
function policedFetch(policy, fetchImpl) {
|
|
8601
|
+
const secrets = policy.secrets && Object.keys(policy.secrets).length > 0 ? policy.secrets : null;
|
|
8602
|
+
if (!secrets) return policedPlainFetch(policy, fetchImpl);
|
|
8603
|
+
const plain = policedPlainFetch(policy, fetchImpl);
|
|
8604
|
+
return (async (input, init) => {
|
|
8605
|
+
const url = requestUrl(input);
|
|
8606
|
+
if (!outboundAllowed(policy, url)) {
|
|
8607
|
+
throw Object.assign(new TypeError("fetch failed"), { cause: outboundBlockedError(url) });
|
|
8608
|
+
}
|
|
8609
|
+
let sealed;
|
|
8610
|
+
try {
|
|
8611
|
+
sealed = sealRequest(new Request(input, init), secrets).request;
|
|
8612
|
+
} catch (error) {
|
|
8613
|
+
throw Object.assign(new TypeError("fetch failed"), { cause: error });
|
|
8614
|
+
}
|
|
8615
|
+
return redactResponse(await plain(sealed), secrets);
|
|
8616
|
+
});
|
|
8617
|
+
}
|
|
8618
|
+
function policedPlainFetch(policy, fetchImpl) {
|
|
8513
8619
|
return (async (input, init) => {
|
|
8514
8620
|
const url = requestUrl(input);
|
|
8515
8621
|
if (!outboundAllowed(policy, url)) {
|
|
@@ -8746,22 +8852,22 @@ var NetworkStack = class {
|
|
|
8746
8852
|
`;
|
|
8747
8853
|
return out;
|
|
8748
8854
|
}
|
|
8749
|
-
countTx(
|
|
8855
|
+
countTx(bytes3, iface = "eth0") {
|
|
8750
8856
|
const i = this.interface(iface);
|
|
8751
8857
|
if (!i) return;
|
|
8752
|
-
i.txBytes +=
|
|
8753
|
-
i.txPackets += Math.max(1, Math.ceil(
|
|
8858
|
+
i.txBytes += bytes3;
|
|
8859
|
+
i.txPackets += Math.max(1, Math.ceil(bytes3 / 1400));
|
|
8754
8860
|
}
|
|
8755
|
-
countRx(
|
|
8861
|
+
countRx(bytes3, iface = "eth0") {
|
|
8756
8862
|
const i = this.interface(iface);
|
|
8757
8863
|
if (!i) return;
|
|
8758
|
-
i.rxBytes +=
|
|
8759
|
-
i.rxPackets += Math.max(1, Math.ceil(
|
|
8864
|
+
i.rxBytes += bytes3;
|
|
8865
|
+
i.rxPackets += Math.max(1, Math.ceil(bytes3 / 1400));
|
|
8760
8866
|
}
|
|
8761
8867
|
};
|
|
8762
8868
|
function randomMac() {
|
|
8763
|
-
const
|
|
8764
|
-
return
|
|
8869
|
+
const bytes3 = [2, 66, 172, 17, 0, 2];
|
|
8870
|
+
return bytes3.map((b) => b.toString(16).padStart(2, "0")).join(":");
|
|
8765
8871
|
}
|
|
8766
8872
|
function hexIp(ip2) {
|
|
8767
8873
|
return ip2.split(".").reverse().map((o) => Number(o).toString(16).padStart(2, "0").toUpperCase()).join("");
|
|
@@ -9206,15 +9312,15 @@ var Parser = class {
|
|
|
9206
9312
|
if (this.isWord("-p")) this.next();
|
|
9207
9313
|
}
|
|
9208
9314
|
}
|
|
9209
|
-
const
|
|
9315
|
+
const commands13 = [this.parseCommand()];
|
|
9210
9316
|
const stderrToo = [];
|
|
9211
9317
|
while (this.isOp("|") || this.isOp("|&")) {
|
|
9212
9318
|
stderrToo.push(this.next().value === "|&");
|
|
9213
9319
|
this.skipNewlines();
|
|
9214
|
-
|
|
9320
|
+
commands13.push(this.parseCommand());
|
|
9215
9321
|
}
|
|
9216
|
-
if (
|
|
9217
|
-
return { type: "pipeline", commands:
|
|
9322
|
+
if (commands13.length === 1 && !negated && !timed) return commands13[0];
|
|
9323
|
+
return { type: "pipeline", commands: commands13, negated, stderrToo, timed };
|
|
9218
9324
|
}
|
|
9219
9325
|
// ── commands ─────────────────────────────────────────────────────────────
|
|
9220
9326
|
parseCommand() {
|
|
@@ -10834,8 +10940,8 @@ var decoder4 = new TextDecoder();
|
|
|
10834
10940
|
async function readInputs(ctx, operands, opts = {}) {
|
|
10835
10941
|
const stdinName = opts.stdinName ?? "-";
|
|
10836
10942
|
if (operands.length === 0) {
|
|
10837
|
-
const
|
|
10838
|
-
return { sources: [{ name: stdinName, bytes:
|
|
10943
|
+
const bytes3 = await ctx.stdin.readAll();
|
|
10944
|
+
return { sources: [{ name: stdinName, bytes: bytes3 }], ok: true };
|
|
10839
10945
|
}
|
|
10840
10946
|
const sources = [];
|
|
10841
10947
|
let ok2 = true;
|
|
@@ -10860,8 +10966,8 @@ async function readInputs(ctx, operands, opts = {}) {
|
|
|
10860
10966
|
}
|
|
10861
10967
|
return { sources, ok: ok2 };
|
|
10862
10968
|
}
|
|
10863
|
-
function splitLines(
|
|
10864
|
-
const text2 = decoder4.decode(
|
|
10969
|
+
function splitLines(bytes3) {
|
|
10970
|
+
const text2 = decoder4.decode(bytes3);
|
|
10865
10971
|
if (text2 === "") return { lines: [], trailingNewline: true };
|
|
10866
10972
|
const trailingNewline = text2.endsWith("\n");
|
|
10867
10973
|
const body = trailingNewline ? text2.slice(0, -1) : text2;
|
|
@@ -10873,11 +10979,11 @@ function joinLines(lines, trailingNewline = true) {
|
|
|
10873
10979
|
}
|
|
10874
10980
|
var SI_UNITS = ["", "k", "M", "G", "T", "P", "E"];
|
|
10875
10981
|
var IEC_UNITS = ["", "K", "M", "G", "T", "P", "E"];
|
|
10876
|
-
function humanSize(
|
|
10982
|
+
function humanSize(bytes3, opts = {}) {
|
|
10877
10983
|
const base2 = opts.si ? 1e3 : 1024;
|
|
10878
10984
|
const units = opts.si ? SI_UNITS : IEC_UNITS;
|
|
10879
|
-
if (
|
|
10880
|
-
let value =
|
|
10985
|
+
if (bytes3 < base2) return String(bytes3);
|
|
10986
|
+
let value = bytes3;
|
|
10881
10987
|
let unit = 0;
|
|
10882
10988
|
while (value >= base2 && unit < units.length - 1) {
|
|
10883
10989
|
value /= base2;
|
|
@@ -11167,7 +11273,7 @@ var cat = defineCommand({
|
|
|
11167
11273
|
let lineNumber = 1;
|
|
11168
11274
|
let lastWasBlank = false;
|
|
11169
11275
|
for (const operand of operands) {
|
|
11170
|
-
let
|
|
11276
|
+
let bytes3;
|
|
11171
11277
|
if (operand === "-") {
|
|
11172
11278
|
if (plain) {
|
|
11173
11279
|
for (; ; ) {
|
|
@@ -11178,7 +11284,7 @@ var cat = defineCommand({
|
|
|
11178
11284
|
}
|
|
11179
11285
|
continue;
|
|
11180
11286
|
}
|
|
11181
|
-
|
|
11287
|
+
bytes3 = await ctx.stdin.readAll();
|
|
11182
11288
|
} else {
|
|
11183
11289
|
try {
|
|
11184
11290
|
const abs = ctx.path(operand);
|
|
@@ -11188,17 +11294,17 @@ var cat = defineCommand({
|
|
|
11188
11294
|
status = 1;
|
|
11189
11295
|
continue;
|
|
11190
11296
|
}
|
|
11191
|
-
|
|
11297
|
+
bytes3 = ctx.vfs.readFile(abs, ctx.cred);
|
|
11192
11298
|
} catch (e) {
|
|
11193
11299
|
status = ctx.reportError(e, operand);
|
|
11194
11300
|
continue;
|
|
11195
11301
|
}
|
|
11196
11302
|
}
|
|
11197
11303
|
if (plain) {
|
|
11198
|
-
ctx.write(
|
|
11304
|
+
ctx.write(bytes3);
|
|
11199
11305
|
continue;
|
|
11200
11306
|
}
|
|
11201
|
-
const text2 = new TextDecoder().decode(
|
|
11307
|
+
const text2 = new TextDecoder().decode(bytes3);
|
|
11202
11308
|
const hadTrailing = text2.endsWith("\n");
|
|
11203
11309
|
const parts = (hadTrailing ? text2.slice(0, -1) : text2).split("\n");
|
|
11204
11310
|
for (const raw of parts) {
|
|
@@ -12052,15 +12158,15 @@ function describeFile(ctx, abs, st, mime) {
|
|
|
12052
12158
|
}
|
|
12053
12159
|
if (st.isCharacterDevice()) return mime ? "inode/chardevice" : "character special";
|
|
12054
12160
|
if (st.size === 0) return mime ? "inode/x-empty" : "empty";
|
|
12055
|
-
const
|
|
12056
|
-
const magic = [...
|
|
12161
|
+
const bytes3 = ctx.vfs.readFile(abs, ctx.cred).subarray(0, 512);
|
|
12162
|
+
const magic = [...bytes3.subarray(0, 4)];
|
|
12057
12163
|
if (magic[0] === 127 && magic[1] === 69 && magic[2] === 76 && magic[3] === 70) {
|
|
12058
12164
|
return mime ? "application/x-executable" : "ELF 64-bit LSB executable, x86-64";
|
|
12059
12165
|
}
|
|
12060
12166
|
if (magic[0] === 31 && magic[1] === 139) return mime ? "application/gzip" : "gzip compressed data";
|
|
12061
12167
|
if (magic[0] === 80 && magic[1] === 75) return mime ? "application/zip" : "Zip archive data";
|
|
12062
12168
|
if (magic[0] === 137 && magic[1] === 80) return mime ? "image/png" : "PNG image data";
|
|
12063
|
-
const text2 = new TextDecoder().decode(
|
|
12169
|
+
const text2 = new TextDecoder().decode(bytes3);
|
|
12064
12170
|
const printable = [...text2].every((c) => c === "\n" || c === " " || c === "\r" || c >= " " && c <= "~" || c.charCodeAt(0) > 127);
|
|
12065
12171
|
if (!printable) return mime ? "application/octet-stream" : "data";
|
|
12066
12172
|
if (text2.startsWith("#!")) {
|
|
@@ -12963,6 +13069,523 @@ var commands3 = [
|
|
|
12963
13069
|
clear,
|
|
12964
13070
|
sync
|
|
12965
13071
|
];
|
|
13072
|
+
var platformBuffer = globalThis.Buffer;
|
|
13073
|
+
addUint8ArraySupport(addBase64UrlSupport(index_js.Buffer));
|
|
13074
|
+
var Buffer2 = platformBuffer ?? index_js.Buffer;
|
|
13075
|
+
function addUint8ArraySupport(BufferClass) {
|
|
13076
|
+
const target = BufferClass;
|
|
13077
|
+
if (target.__sandboxedUint8Array) return BufferClass;
|
|
13078
|
+
Object.defineProperty(target, "__sandboxedUint8Array", { value: true });
|
|
13079
|
+
const asBuffer = (value) => value instanceof Uint8Array && !target.isBuffer(value) ? target.from(value.buffer, value.byteOffset, value.byteLength) : value;
|
|
13080
|
+
for (const method of ["indexOf", "lastIndexOf", "includes"]) {
|
|
13081
|
+
const original = target.prototype[method];
|
|
13082
|
+
target.prototype[method] = function(value, ...rest) {
|
|
13083
|
+
return original.call(this, asBuffer(value), ...rest);
|
|
13084
|
+
};
|
|
13085
|
+
}
|
|
13086
|
+
const equals = target.prototype.equals;
|
|
13087
|
+
target.prototype.equals = function(other) {
|
|
13088
|
+
return equals.call(this, asBuffer(other));
|
|
13089
|
+
};
|
|
13090
|
+
return BufferClass;
|
|
13091
|
+
}
|
|
13092
|
+
function addBase64UrlSupport(BufferClass) {
|
|
13093
|
+
const target = BufferClass;
|
|
13094
|
+
if (target.__sandboxedBase64Url) return BufferClass;
|
|
13095
|
+
Object.defineProperty(target, "__sandboxedBase64Url", { value: true });
|
|
13096
|
+
const from = target.from.bind(target);
|
|
13097
|
+
target.from = (value, encodingOrOffset, length) => from(value, normalizeEncoding(encodingOrOffset), length);
|
|
13098
|
+
const byteLength = target.byteLength.bind(target);
|
|
13099
|
+
target.byteLength = (value, encoding) => byteLength(value, normalizeEncoding(encoding));
|
|
13100
|
+
const isEncoding = target.isEncoding?.bind(target);
|
|
13101
|
+
if (isEncoding) target.isEncoding = (encoding) => encoding.toLowerCase() === "base64url" || isEncoding(encoding);
|
|
13102
|
+
const toString = target.prototype.toString;
|
|
13103
|
+
target.prototype.toString = function(encoding, start2, end) {
|
|
13104
|
+
if (encoding?.toLowerCase() !== "base64url") return toString.call(this, encoding, start2, end);
|
|
13105
|
+
return toString.call(this, "base64", start2, end).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
13106
|
+
};
|
|
13107
|
+
const write = target.prototype.write;
|
|
13108
|
+
target.prototype.write = function(...args) {
|
|
13109
|
+
const index = typeof args[1] === "string" ? 1 : typeof args[2] === "string" ? 2 : 3;
|
|
13110
|
+
if (typeof args[index] === "string") args[index] = normalizeEncoding(args[index]);
|
|
13111
|
+
return write.apply(this, args);
|
|
13112
|
+
};
|
|
13113
|
+
return BufferClass;
|
|
13114
|
+
}
|
|
13115
|
+
function normalizeEncoding(value) {
|
|
13116
|
+
return typeof value === "string" && value.toLowerCase() === "base64url" ? "base64" : value;
|
|
13117
|
+
}
|
|
13118
|
+
|
|
13119
|
+
// src/pkg/clean-installer.ts
|
|
13120
|
+
init_path();
|
|
13121
|
+
|
|
13122
|
+
// src/browser/playwright-browsers.ts
|
|
13123
|
+
init_path();
|
|
13124
|
+
var PLAYWRIGHT_REGISTRY = "/root/.cache/ms-playwright";
|
|
13125
|
+
var LAYOUTS = {
|
|
13126
|
+
"chromium": ["chrome-linux64", "chrome"],
|
|
13127
|
+
"chromium-headless-shell": ["chrome-headless-shell-linux64", "chrome-headless-shell"]
|
|
13128
|
+
};
|
|
13129
|
+
function virtualBrowserFiles(browsersJson) {
|
|
13130
|
+
let manifest;
|
|
13131
|
+
try {
|
|
13132
|
+
manifest = JSON.parse(browsersJson);
|
|
13133
|
+
} catch {
|
|
13134
|
+
return [];
|
|
13135
|
+
}
|
|
13136
|
+
const encoder9 = new TextEncoder();
|
|
13137
|
+
const files = [];
|
|
13138
|
+
for (const browser of manifest.browsers ?? []) {
|
|
13139
|
+
const layout = LAYOUTS[browser.name];
|
|
13140
|
+
if (!layout) continue;
|
|
13141
|
+
const dir3 = join(PLAYWRIGHT_REGISTRY, `${browser.name.replace(/-/g, "_")}-${browser.revision}`);
|
|
13142
|
+
files.push({ path: join(dir3, ...layout), data: encoder9.encode(`#!${BUILTIN_INTERPRETER} chrome
|
|
13143
|
+
`), mode: 493 });
|
|
13144
|
+
files.push({ path: join(dir3, "INSTALLATION_COMPLETE"), data: new Uint8Array() });
|
|
13145
|
+
}
|
|
13146
|
+
return files;
|
|
13147
|
+
}
|
|
13148
|
+
function mkdirp(volume, path) {
|
|
13149
|
+
let current2 = "";
|
|
13150
|
+
for (const part of segments(path)) {
|
|
13151
|
+
current2 += `/${part}`;
|
|
13152
|
+
try {
|
|
13153
|
+
volume.mkdirSync(current2, { mode: 493 });
|
|
13154
|
+
} catch (error) {
|
|
13155
|
+
if (error.code !== "EEXIST") throw error;
|
|
13156
|
+
}
|
|
13157
|
+
}
|
|
13158
|
+
}
|
|
13159
|
+
function installVirtualPlaywrightBrowsers(volume, packageDir) {
|
|
13160
|
+
let text2;
|
|
13161
|
+
try {
|
|
13162
|
+
text2 = new TextDecoder().decode(volume.readFileSync(join(packageDir, "browsers.json")));
|
|
13163
|
+
} catch {
|
|
13164
|
+
return [];
|
|
13165
|
+
}
|
|
13166
|
+
const written = [];
|
|
13167
|
+
for (const file3 of virtualBrowserFiles(text2)) {
|
|
13168
|
+
mkdirp(volume, dirname(file3.path));
|
|
13169
|
+
volume.writeFileSync(file3.path, file3.data);
|
|
13170
|
+
if (file3.mode !== void 0) {
|
|
13171
|
+
volume.chmodSync(file3.path, file3.mode);
|
|
13172
|
+
written.push(file3.path);
|
|
13173
|
+
}
|
|
13174
|
+
}
|
|
13175
|
+
return written;
|
|
13176
|
+
}
|
|
13177
|
+
|
|
13178
|
+
// src/pkg/clean-installer.ts
|
|
13179
|
+
var RUNTIME_PACKAGE_FALLBACKS = {
|
|
13180
|
+
esbuild: "esbuild-wasm",
|
|
13181
|
+
rollup: "@rollup/wasm-node"
|
|
13182
|
+
};
|
|
13183
|
+
var CleanPackageInstaller = class _CleanPackageInstaller {
|
|
13184
|
+
constructor(volume, options = {}) {
|
|
13185
|
+
this.volume = volume;
|
|
13186
|
+
this.options = options;
|
|
13187
|
+
this.registry = (options.registry ?? "https://registry.npmjs.org").replace(/\/$/, "");
|
|
13188
|
+
this.fetcher = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
13189
|
+
}
|
|
13190
|
+
volume;
|
|
13191
|
+
options;
|
|
13192
|
+
registry;
|
|
13193
|
+
fetcher;
|
|
13194
|
+
metadata = /* @__PURE__ */ new Map();
|
|
13195
|
+
tarballs = /* @__PURE__ */ new Map();
|
|
13196
|
+
/** Single-version manifests, for the fields the packument omits. */
|
|
13197
|
+
details = /* @__PURE__ */ new Map();
|
|
13198
|
+
forCwd(cwd) {
|
|
13199
|
+
const installer = new _CleanPackageInstaller(this.volume, { ...this.options, cwd });
|
|
13200
|
+
installer.metadata = this.metadata;
|
|
13201
|
+
installer.tarballs = this.tarballs;
|
|
13202
|
+
installer.details = this.details;
|
|
13203
|
+
return installer;
|
|
13204
|
+
}
|
|
13205
|
+
async install(name, version = "latest", options = {}) {
|
|
13206
|
+
const cwd = this.options.cwd ?? "/";
|
|
13207
|
+
const manifest = await this.installAt(name, version || "latest", join(cwd, "node_modules"), options, /* @__PURE__ */ new Set());
|
|
13208
|
+
if (options.persist !== false) this.persist(cwd, name, version, options.persistDev === true);
|
|
13209
|
+
return manifest;
|
|
13210
|
+
}
|
|
13211
|
+
async installFromManifest(path, options = {}) {
|
|
13212
|
+
const project = this.readJson(path);
|
|
13213
|
+
const cwd = dirname(path);
|
|
13214
|
+
const dependencies = {
|
|
13215
|
+
...project.dependencies ?? {},
|
|
13216
|
+
...options.withDevDeps === false ? {} : project.devDependencies ?? {}
|
|
13217
|
+
};
|
|
13218
|
+
await this.prefetch(dependencies);
|
|
13219
|
+
for (const [name, range] of Object.entries(dependencies)) {
|
|
13220
|
+
await this.installAt(name, range, join(cwd, "node_modules"), options, /* @__PURE__ */ new Set());
|
|
13221
|
+
}
|
|
13222
|
+
}
|
|
13223
|
+
async installAt(name, range, modulesRoot, options, ancestry) {
|
|
13224
|
+
const metadata = await this.getMetadata(name);
|
|
13225
|
+
const version = resolveVersion(metadata, range);
|
|
13226
|
+
const manifest = metadata.versions[version];
|
|
13227
|
+
if (!manifest) throw new Error(`No matching version found for ${name}@${range}`);
|
|
13228
|
+
const identity = `${name}@${version}`;
|
|
13229
|
+
if (!supportsPlatform(manifest)) throw new IncompatiblePlatform(identity, "");
|
|
13230
|
+
if (manifest.os?.length || manifest.cpu?.length) {
|
|
13231
|
+
const detail = await this.platformDetail(name, version);
|
|
13232
|
+
if (!platformListAllows(detail.libc, PLATFORM.libc)) {
|
|
13233
|
+
throw new IncompatiblePlatform(identity, ` (needs ${detail.libc?.join(", ")})`);
|
|
13234
|
+
}
|
|
13235
|
+
if (detail.main?.endsWith(".node")) {
|
|
13236
|
+
throw new IncompatiblePlatform(identity, " (native addon; this runtime cannot dlopen)");
|
|
13237
|
+
}
|
|
13238
|
+
}
|
|
13239
|
+
const target = join(modulesRoot, name);
|
|
13240
|
+
const installed3 = this.tryReadJson(join(target, "package.json"));
|
|
13241
|
+
if (ancestry.has(identity)) return manifest;
|
|
13242
|
+
if (installed3?.version !== version) {
|
|
13243
|
+
options.onProgress?.(`Fetching ${identity}`);
|
|
13244
|
+
const archive = await this.getTarball(manifest.dist.tarball);
|
|
13245
|
+
verifyIntegrity(archive, manifest.dist.integrity, manifest.dist.shasum, identity);
|
|
13246
|
+
this.removeIfPresent(target);
|
|
13247
|
+
mkdirp2(this.volume, target);
|
|
13248
|
+
extractNpmTarball(this.volume, archive, target);
|
|
13249
|
+
options.onProgress?.(`Installed ${identity}`);
|
|
13250
|
+
}
|
|
13251
|
+
this.createBinLinks(manifest, target, modulesRoot);
|
|
13252
|
+
if (name === "playwright-core") {
|
|
13253
|
+
for (const executable of installVirtualPlaywrightBrowsers(this.volume, target)) {
|
|
13254
|
+
options.onProgress?.(`Linked ${executable} to the virtual browser`);
|
|
13255
|
+
}
|
|
13256
|
+
}
|
|
13257
|
+
const nextAncestry = new Set(ancestry).add(identity);
|
|
13258
|
+
const fallback = RUNTIME_PACKAGE_FALLBACKS[name];
|
|
13259
|
+
if (fallback && fallback !== name) {
|
|
13260
|
+
await this.installAt(fallback, version, modulesRoot, options, nextAncestry);
|
|
13261
|
+
}
|
|
13262
|
+
const childRoot = join(target, "node_modules");
|
|
13263
|
+
const required = Object.fromEntries(Object.entries(manifest.dependencies ?? {}).filter(([name2]) => !(name2 in (manifest.optionalDependencies ?? {}))));
|
|
13264
|
+
await this.prefetch(required);
|
|
13265
|
+
for (const [dependency, dependencyRange] of Object.entries(required)) {
|
|
13266
|
+
await this.installAt(dependency, dependencyRange, childRoot, options, nextAncestry);
|
|
13267
|
+
}
|
|
13268
|
+
for (const [dependency, dependencyRange] of Object.entries(manifest.optionalDependencies ?? {})) {
|
|
13269
|
+
try {
|
|
13270
|
+
await this.installAt(dependency, dependencyRange, childRoot, options, nextAncestry);
|
|
13271
|
+
} catch (error) {
|
|
13272
|
+
if (error instanceof IncompatiblePlatform) continue;
|
|
13273
|
+
options.onProgress?.(`Skipped optional ${dependency}: ${error instanceof Error ? error.message : String(error)}`);
|
|
13274
|
+
}
|
|
13275
|
+
}
|
|
13276
|
+
return manifest;
|
|
13277
|
+
}
|
|
13278
|
+
/**
|
|
13279
|
+
* The `libc` and `main` fields, which the abbreviated packument leaves out.
|
|
13280
|
+
*
|
|
13281
|
+
* Fetched per version rather than as a full packument: the single-version
|
|
13282
|
+
* document is a few kilobytes, while the full one for a popular package runs
|
|
13283
|
+
* to megabytes. Only packages that already declare `os` or `cpu` ask for it,
|
|
13284
|
+
* so an ordinary install of pure-JavaScript dependencies makes no extra
|
|
13285
|
+
* requests at all — it is the prebuilt binaries, a handful per project, that
|
|
13286
|
+
* need the answer.
|
|
13287
|
+
*
|
|
13288
|
+
* A failure here is not fatal. Being unable to read `libc` puts the check
|
|
13289
|
+
* back where it was before this existed, which is worth strictly less than
|
|
13290
|
+
* being right and strictly more than refusing to install.
|
|
13291
|
+
*/
|
|
13292
|
+
async platformDetail(name, version) {
|
|
13293
|
+
const key = `${name}@${version}`;
|
|
13294
|
+
let request = this.details.get(key);
|
|
13295
|
+
if (!request) {
|
|
13296
|
+
request = (async () => {
|
|
13297
|
+
try {
|
|
13298
|
+
const encoded = name.startsWith("@") ? name.replace("/", "%2F") : encodeURIComponent(name);
|
|
13299
|
+
const response = await this.fetcher(`${this.registry}/${encoded}/${version}`);
|
|
13300
|
+
if (!response.ok) return {};
|
|
13301
|
+
return await response.json();
|
|
13302
|
+
} catch {
|
|
13303
|
+
return {};
|
|
13304
|
+
}
|
|
13305
|
+
})();
|
|
13306
|
+
this.details.set(key, request);
|
|
13307
|
+
}
|
|
13308
|
+
return request;
|
|
13309
|
+
}
|
|
13310
|
+
/** Overlap up to six sibling downloads; filesystem writes remain ordered. */
|
|
13311
|
+
async prefetch(dependencies) {
|
|
13312
|
+
const entries = Object.entries(dependencies);
|
|
13313
|
+
let next = 0;
|
|
13314
|
+
await Promise.all(Array.from({ length: Math.min(6, entries.length) }, async () => {
|
|
13315
|
+
while (next < entries.length) {
|
|
13316
|
+
const [name, range] = entries[next++];
|
|
13317
|
+
try {
|
|
13318
|
+
const metadata = await this.getMetadata(name);
|
|
13319
|
+
const manifest = metadata.versions[resolveVersion(metadata, range)];
|
|
13320
|
+
if (!manifest.os?.length && !manifest.cpu?.length && supportsPlatform(manifest)) {
|
|
13321
|
+
await this.getTarball(manifest.dist.tarball);
|
|
13322
|
+
}
|
|
13323
|
+
} catch {
|
|
13324
|
+
}
|
|
13325
|
+
}
|
|
13326
|
+
}));
|
|
13327
|
+
}
|
|
13328
|
+
async getMetadata(name) {
|
|
13329
|
+
let request = this.metadata.get(name);
|
|
13330
|
+
if (!request) {
|
|
13331
|
+
request = (async () => {
|
|
13332
|
+
const encoded = name.startsWith("@") ? name.replace("/", "%2F") : encodeURIComponent(name);
|
|
13333
|
+
const response = await this.fetcher(`${this.registry}/${encoded}`, {
|
|
13334
|
+
headers: { Accept: "application/vnd.npm.install-v1+json" }
|
|
13335
|
+
});
|
|
13336
|
+
if (!response.ok) throw new Error(`registry returned ${response.status} for ${name}`);
|
|
13337
|
+
return await response.json();
|
|
13338
|
+
})();
|
|
13339
|
+
this.metadata.set(name, request);
|
|
13340
|
+
void request.catch(() => {
|
|
13341
|
+
this.metadata.delete(name);
|
|
13342
|
+
});
|
|
13343
|
+
}
|
|
13344
|
+
return request;
|
|
13345
|
+
}
|
|
13346
|
+
async getTarball(url) {
|
|
13347
|
+
let request = this.tarballs.get(url);
|
|
13348
|
+
if (!request) {
|
|
13349
|
+
request = (async () => {
|
|
13350
|
+
const response = await this.fetcher(url);
|
|
13351
|
+
if (!response.ok) throw new Error(`tarball returned ${response.status}: ${url}`);
|
|
13352
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
13353
|
+
})();
|
|
13354
|
+
this.tarballs.set(url, request);
|
|
13355
|
+
void request.catch(() => {
|
|
13356
|
+
this.tarballs.delete(url);
|
|
13357
|
+
});
|
|
13358
|
+
}
|
|
13359
|
+
return request;
|
|
13360
|
+
}
|
|
13361
|
+
createBinLinks(manifest, target, modulesRoot) {
|
|
13362
|
+
if (!manifest.bin) return;
|
|
13363
|
+
const bins = typeof manifest.bin === "string" ? { [unscoped(manifest.name)]: manifest.bin } : manifest.bin;
|
|
13364
|
+
const binDir = join(modulesRoot, ".bin");
|
|
13365
|
+
mkdirp2(this.volume, binDir);
|
|
13366
|
+
for (const [name, path] of Object.entries(bins)) {
|
|
13367
|
+
const link = join(binDir, name);
|
|
13368
|
+
this.removeIfPresent(link);
|
|
13369
|
+
this.volume.symlinkSync(relative(binDir, join(target, path)), link);
|
|
13370
|
+
}
|
|
13371
|
+
}
|
|
13372
|
+
persist(cwd, name, range, dev) {
|
|
13373
|
+
const path = join(cwd, "package.json");
|
|
13374
|
+
const manifest = this.tryReadJson(path) ?? {};
|
|
13375
|
+
const key = dev ? "devDependencies" : "dependencies";
|
|
13376
|
+
manifest[key] = { ...manifest[key] ?? {}, [name]: range === "latest" ? "*" : range };
|
|
13377
|
+
this.volume.writeFileSync(path, JSON.stringify(manifest, null, 2) + "\n");
|
|
13378
|
+
}
|
|
13379
|
+
removeIfPresent(path) {
|
|
13380
|
+
let stat2;
|
|
13381
|
+
try {
|
|
13382
|
+
stat2 = this.volume.lstatSync(path);
|
|
13383
|
+
} catch {
|
|
13384
|
+
return;
|
|
13385
|
+
}
|
|
13386
|
+
if (!stat2.isDirectory()) return this.volume.unlinkSync(path);
|
|
13387
|
+
for (const name of this.volume.readdirSync(path)) this.removeIfPresent(join(path, name));
|
|
13388
|
+
this.volume.rmdirSync(path);
|
|
13389
|
+
}
|
|
13390
|
+
readJson(path) {
|
|
13391
|
+
return JSON.parse(new TextDecoder().decode(this.volume.readFileSync(path)));
|
|
13392
|
+
}
|
|
13393
|
+
tryReadJson(path) {
|
|
13394
|
+
try {
|
|
13395
|
+
return this.readJson(path);
|
|
13396
|
+
} catch {
|
|
13397
|
+
return null;
|
|
13398
|
+
}
|
|
13399
|
+
}
|
|
13400
|
+
};
|
|
13401
|
+
var PLATFORM = { os: "linux", cpu: "x64", libc: "glibc" };
|
|
13402
|
+
var IncompatiblePlatform = class extends Error {
|
|
13403
|
+
constructor(identity, detail) {
|
|
13404
|
+
super(`${identity} is not compatible with ${PLATFORM.os}/${PLATFORM.cpu}/${PLATFORM.libc}${detail}`);
|
|
13405
|
+
this.name = "IncompatiblePlatform";
|
|
13406
|
+
}
|
|
13407
|
+
};
|
|
13408
|
+
function supportsPlatform(manifest) {
|
|
13409
|
+
return platformListAllows(manifest.os, PLATFORM.os) && platformListAllows(manifest.cpu, PLATFORM.cpu) && platformListAllows(manifest.libc, PLATFORM.libc);
|
|
13410
|
+
}
|
|
13411
|
+
function platformListAllows(values, current2) {
|
|
13412
|
+
if (!values?.length) return true;
|
|
13413
|
+
if (values.includes(`!${current2}`)) return false;
|
|
13414
|
+
const positive = values.filter((value) => !value.startsWith("!"));
|
|
13415
|
+
return positive.length === 0 || positive.includes(current2) || positive.includes("any");
|
|
13416
|
+
}
|
|
13417
|
+
function resolveVersion(metadata, range) {
|
|
13418
|
+
const tag2 = metadata["dist-tags"]?.[range];
|
|
13419
|
+
if (tag2) return tag2;
|
|
13420
|
+
if (semver.valid(range) && metadata.versions[range]) return range;
|
|
13421
|
+
const found2 = semver.maxSatisfying(Object.keys(metadata.versions), range === "latest" ? "*" : range, { includePrerelease: false });
|
|
13422
|
+
if (!found2) throw new Error(`No matching version found for ${metadata.name}@${range}`);
|
|
13423
|
+
return found2;
|
|
13424
|
+
}
|
|
13425
|
+
function verifyIntegrity(data, integrity, shasum, identity) {
|
|
13426
|
+
if (integrity) {
|
|
13427
|
+
const choices = integrity.trim().split(/\s+/);
|
|
13428
|
+
for (const choice of choices) {
|
|
13429
|
+
const dash = choice.indexOf("-");
|
|
13430
|
+
const algorithm = choice.slice(0, dash);
|
|
13431
|
+
const expected = choice.slice(dash + 1).replace(/\?.*$/, "");
|
|
13432
|
+
const digest2 = algorithm === "sha512" ? sha512.sha512(data) : algorithm === "sha256" ? sha256.sha256(data) : null;
|
|
13433
|
+
if (digest2 && Buffer2.from(digest2).toString("base64") === expected) return;
|
|
13434
|
+
}
|
|
13435
|
+
throw new Error(`Integrity check failed for ${identity}`);
|
|
13436
|
+
}
|
|
13437
|
+
if (shasum && Buffer2.from(sha1.sha1(data)).toString("hex") === shasum) return;
|
|
13438
|
+
if (shasum) throw new Error(`Legacy checksum check failed for ${identity}`);
|
|
13439
|
+
}
|
|
13440
|
+
function extractNpmTarball(volume, compressed, destination) {
|
|
13441
|
+
const tar2 = pako.ungzip(compressed);
|
|
13442
|
+
let offset = 0;
|
|
13443
|
+
let longPath = null;
|
|
13444
|
+
let paxPath = null;
|
|
13445
|
+
while (offset + 512 <= tar2.length) {
|
|
13446
|
+
const header = tar2.subarray(offset, offset + 512);
|
|
13447
|
+
if (header.every((byte) => byte === 0)) break;
|
|
13448
|
+
const size = octal(header, 124, 12);
|
|
13449
|
+
const type = String.fromCharCode(header[156] || 48);
|
|
13450
|
+
const prefix = text(header, 345, 155);
|
|
13451
|
+
let name = longPath ?? paxPath ?? [prefix, text(header, 0, 100)].filter(Boolean).join("/");
|
|
13452
|
+
longPath = null;
|
|
13453
|
+
paxPath = null;
|
|
13454
|
+
const data = tar2.subarray(offset + 512, offset + 512 + size);
|
|
13455
|
+
offset += 512 + Math.ceil(size / 512) * 512;
|
|
13456
|
+
if (type === "L") {
|
|
13457
|
+
longPath = new TextDecoder().decode(data).replace(/\0.*$/, "").trim();
|
|
13458
|
+
continue;
|
|
13459
|
+
}
|
|
13460
|
+
if (type === "x" || type === "g") {
|
|
13461
|
+
paxPath = parsePax(data).path ?? null;
|
|
13462
|
+
continue;
|
|
13463
|
+
}
|
|
13464
|
+
name = stripPackageRoot(name);
|
|
13465
|
+
if (!name) continue;
|
|
13466
|
+
const target = safeTarget(destination, name);
|
|
13467
|
+
const mode = octal(header, 100, 8) || 420;
|
|
13468
|
+
if (type === "5") {
|
|
13469
|
+
mkdirp2(volume, target, mode);
|
|
13470
|
+
} else if (type === "2") {
|
|
13471
|
+
mkdirp2(volume, dirname(target));
|
|
13472
|
+
volume.symlinkSync(text(header, 157, 100), target);
|
|
13473
|
+
} else if (type === "1") {
|
|
13474
|
+
mkdirp2(volume, dirname(target));
|
|
13475
|
+
volume.linkSync(safeTarget(destination, stripPackageRoot(text(header, 157, 100))), target);
|
|
13476
|
+
} else if (type === "0" || type === "\0" || type === "7") {
|
|
13477
|
+
mkdirp2(volume, dirname(target));
|
|
13478
|
+
volume.writeFileSync(target, data.slice());
|
|
13479
|
+
volume.chmodSync(target, mode);
|
|
13480
|
+
}
|
|
13481
|
+
}
|
|
13482
|
+
}
|
|
13483
|
+
function mkdirp2(volume, path, mode = 493) {
|
|
13484
|
+
let current2 = "";
|
|
13485
|
+
for (const part of segments(path)) {
|
|
13486
|
+
current2 += `/${part}`;
|
|
13487
|
+
try {
|
|
13488
|
+
volume.mkdirSync(current2, { mode });
|
|
13489
|
+
} catch (error) {
|
|
13490
|
+
if (error.code !== "EEXIST") throw error;
|
|
13491
|
+
if (!volume.lstatSync(current2).isDirectory()) throw error;
|
|
13492
|
+
}
|
|
13493
|
+
}
|
|
13494
|
+
}
|
|
13495
|
+
function safeTarget(destination, name) {
|
|
13496
|
+
const clean2 = clean(`/${name}`).slice(1);
|
|
13497
|
+
if (!clean2 || clean2 === ".." || clean2.startsWith("../") || name.startsWith("/")) throw new Error(`Unsafe path in package: ${name}`);
|
|
13498
|
+
return join(destination, clean2);
|
|
13499
|
+
}
|
|
13500
|
+
function stripPackageRoot(name) {
|
|
13501
|
+
const clean2 = name.replace(/^\.\//, "").replace(/\/$/, "");
|
|
13502
|
+
const slash = clean2.indexOf("/");
|
|
13503
|
+
return slash === -1 ? "" : clean2.slice(slash + 1);
|
|
13504
|
+
}
|
|
13505
|
+
function text(bytes3, start2, length) {
|
|
13506
|
+
return new TextDecoder().decode(bytes3.subarray(start2, start2 + length)).replace(/\0.*$/, "").trim();
|
|
13507
|
+
}
|
|
13508
|
+
function octal(bytes3, start2, length) {
|
|
13509
|
+
return parseInt(text(bytes3, start2, length).replace(/^0+/, "") || "0", 8);
|
|
13510
|
+
}
|
|
13511
|
+
function parsePax(data) {
|
|
13512
|
+
const value = new TextDecoder().decode(data);
|
|
13513
|
+
const result = {};
|
|
13514
|
+
let offset = 0;
|
|
13515
|
+
while (offset < value.length) {
|
|
13516
|
+
const space = value.indexOf(" ", offset);
|
|
13517
|
+
if (space < 0) break;
|
|
13518
|
+
const length = Number(value.slice(offset, space));
|
|
13519
|
+
if (!Number.isFinite(length) || length <= 0) break;
|
|
13520
|
+
const record2 = value.slice(space + 1, offset + length - 1);
|
|
13521
|
+
const equal2 = record2.indexOf("=");
|
|
13522
|
+
if (equal2 > 0) result[record2.slice(0, equal2)] = record2.slice(equal2 + 1);
|
|
13523
|
+
offset += length;
|
|
13524
|
+
}
|
|
13525
|
+
return result;
|
|
13526
|
+
}
|
|
13527
|
+
function unscoped(name) {
|
|
13528
|
+
return name.startsWith("@") ? name.slice(name.indexOf("/") + 1) : name;
|
|
13529
|
+
}
|
|
13530
|
+
|
|
13531
|
+
// src/bin/capabilities.ts
|
|
13532
|
+
function report(ctx) {
|
|
13533
|
+
const commands13 = ctx.kernel.commands.names();
|
|
13534
|
+
const has = (name) => commands13.includes(name);
|
|
13535
|
+
return {
|
|
13536
|
+
schemaVersion: 1,
|
|
13537
|
+
runtime: "sandboxedjs",
|
|
13538
|
+
platform: { os: "linux", arch: "x64", libc: "glibc" },
|
|
13539
|
+
filesystem: { writable: true, root: "/", persistence: "container-lifetime", hostAccess: false },
|
|
13540
|
+
shell: { posix: true, pipelines: true, redirection: true, backgroundProcesses: true },
|
|
13541
|
+
languages: { node: has("node"), python: has("python3"), wasmWasi: has("wasi") },
|
|
13542
|
+
packages: {
|
|
13543
|
+
npm: has("npm"),
|
|
13544
|
+
pip: has("pip"),
|
|
13545
|
+
applicationRegistry: has("pm"),
|
|
13546
|
+
nativeAddons: false,
|
|
13547
|
+
fallbacks: RUNTIME_PACKAGE_FALLBACKS
|
|
13548
|
+
},
|
|
13549
|
+
network: {
|
|
13550
|
+
virtualServers: true,
|
|
13551
|
+
loopback: true,
|
|
13552
|
+
outbound: ctx.kernel.net.policy.allowOutbound,
|
|
13553
|
+
allowedHosts: ctx.kernel.net.policy.allowedHosts,
|
|
13554
|
+
proxy: ctx.kernel.net.proxy !== null,
|
|
13555
|
+
listeningPorts: ctx.kernel.net.listening().map(({ port, proto, program }) => ({ port, proto, program }))
|
|
13556
|
+
},
|
|
13557
|
+
interfaces: {
|
|
13558
|
+
desktopGui: false,
|
|
13559
|
+
hostFilesystem: false,
|
|
13560
|
+
systemPackageManager: false,
|
|
13561
|
+
docker: false
|
|
13562
|
+
},
|
|
13563
|
+
commands: commands13
|
|
13564
|
+
};
|
|
13565
|
+
}
|
|
13566
|
+
var sandboxedjsCapabilities = defineCommand({
|
|
13567
|
+
name: "sandboxedjs-capabilities",
|
|
13568
|
+
aliases: ["sbx-capabilities"],
|
|
13569
|
+
path: "/usr/bin/sandboxedjs-capabilities",
|
|
13570
|
+
summary: "report the runtime capabilities available to tools and agents",
|
|
13571
|
+
usage: "sandboxedjs-capabilities [--json]",
|
|
13572
|
+
run(ctx) {
|
|
13573
|
+
const result = report(ctx);
|
|
13574
|
+
if (ctx.args.includes("--json")) {
|
|
13575
|
+
ctx.line(JSON.stringify(result, null, 2));
|
|
13576
|
+
return 0;
|
|
13577
|
+
}
|
|
13578
|
+
ctx.line("SandboxedJS runtime capabilities");
|
|
13579
|
+
ctx.line(` commands: ${result.commands.length}`);
|
|
13580
|
+
ctx.line(` languages: ${Object.entries(result.languages).filter(([, enabled]) => enabled).map(([name]) => name).join(", ")}`);
|
|
13581
|
+
ctx.line(` outbound network: ${result.network.outbound ? "enabled" : "disabled"}`);
|
|
13582
|
+
ctx.line(` writable filesystem: ${result.filesystem.root} (${result.filesystem.persistence})`);
|
|
13583
|
+
ctx.line(` package fallbacks: ${Object.entries(result.packages.fallbacks).map(([from, to]) => `${from} -> ${to}`).join(", ") || "none"}`);
|
|
13584
|
+
ctx.line("Run with --json for the complete machine-readable inventory.");
|
|
13585
|
+
return 0;
|
|
13586
|
+
}
|
|
13587
|
+
});
|
|
13588
|
+
var commands4 = [sandboxedjsCapabilities];
|
|
12966
13589
|
|
|
12967
13590
|
// src/bin/sed.ts
|
|
12968
13591
|
var SedParseError = class extends Error {
|
|
@@ -15405,8 +16028,8 @@ async function runAwk(ctx) {
|
|
|
15405
16028
|
continue;
|
|
15406
16029
|
}
|
|
15407
16030
|
try {
|
|
15408
|
-
const
|
|
15409
|
-
inputs.push({ name: operand, lines: splitLines(
|
|
16031
|
+
const bytes3 = ctx.vfs.readFile(ctx.path(operand), ctx.cred);
|
|
16032
|
+
inputs.push({ name: operand, lines: splitLines(bytes3).lines });
|
|
15410
16033
|
} catch (e) {
|
|
15411
16034
|
ctx.reportError(e, operand);
|
|
15412
16035
|
return 2;
|
|
@@ -15549,12 +16172,12 @@ async function followFiles(ctx, paths, intervalMs) {
|
|
|
15549
16172
|
if (ctx.signal.aborted) break;
|
|
15550
16173
|
for (const path of paths) {
|
|
15551
16174
|
try {
|
|
15552
|
-
const
|
|
16175
|
+
const bytes3 = ctx.vfs.readFile(ctx.path(path), ctx.cred);
|
|
15553
16176
|
const previous = offsets.get(path) ?? 0;
|
|
15554
|
-
if (
|
|
15555
|
-
ctx.write(
|
|
15556
|
-
offsets.set(path,
|
|
15557
|
-
} else if (
|
|
16177
|
+
if (bytes3.length > previous) {
|
|
16178
|
+
ctx.write(bytes3.subarray(previous));
|
|
16179
|
+
offsets.set(path, bytes3.length);
|
|
16180
|
+
} else if (bytes3.length < previous) {
|
|
15558
16181
|
offsets.set(path, 0);
|
|
15559
16182
|
}
|
|
15560
16183
|
} catch {
|
|
@@ -15937,14 +16560,14 @@ var tee = defineCommand({
|
|
|
15937
16560
|
{ short: "a", long: "append" },
|
|
15938
16561
|
{ short: "i", long: "ignore-interrupts" }
|
|
15939
16562
|
]);
|
|
15940
|
-
const
|
|
15941
|
-
ctx.write(
|
|
16563
|
+
const bytes3 = await ctx.stdin.readAll();
|
|
16564
|
+
ctx.write(bytes3);
|
|
15942
16565
|
let status = 0;
|
|
15943
16566
|
for (const target of args.positional) {
|
|
15944
16567
|
try {
|
|
15945
16568
|
const abs = ctx.path(target);
|
|
15946
|
-
if (args.has("append")) ctx.vfs.appendFile(abs,
|
|
15947
|
-
else ctx.vfs.writeFile(abs,
|
|
16569
|
+
if (args.has("append")) ctx.vfs.appendFile(abs, bytes3, { cred: ctx.cred });
|
|
16570
|
+
else ctx.vfs.writeFile(abs, bytes3, { cred: ctx.cred });
|
|
15948
16571
|
} catch (e) {
|
|
15949
16572
|
status = ctx.reportError(e, target);
|
|
15950
16573
|
}
|
|
@@ -16257,16 +16880,16 @@ var split = defineCommand({
|
|
|
16257
16880
|
const [input, prefixRaw] = args.positional;
|
|
16258
16881
|
const prefix = prefixRaw ?? "x";
|
|
16259
16882
|
const { sources, ok: ok2 } = await readInputs(ctx, input ? [input] : []);
|
|
16260
|
-
const
|
|
16883
|
+
const bytes3 = sources[0]?.bytes ?? new Uint8Array(0);
|
|
16261
16884
|
const suffixLength = args.num("suffix-length", 2);
|
|
16262
16885
|
const chunks = [];
|
|
16263
16886
|
const byteSpec = args.str("bytes");
|
|
16264
16887
|
if (byteSpec !== void 0) {
|
|
16265
16888
|
const size = parseSize(byteSpec) ?? 1024;
|
|
16266
|
-
for (let i = 0; i <
|
|
16889
|
+
for (let i = 0; i < bytes3.length; i += size) chunks.push(bytes3.subarray(i, i + size));
|
|
16267
16890
|
} else {
|
|
16268
16891
|
const perChunk = args.num("lines", 1e3);
|
|
16269
|
-
const { lines } = splitLines(
|
|
16892
|
+
const { lines } = splitLines(bytes3);
|
|
16270
16893
|
for (let i = 0; i < lines.length; i += perChunk) {
|
|
16271
16894
|
chunks.push(new TextEncoder().encode(joinLines(lines.slice(i, i + perChunk), true)));
|
|
16272
16895
|
}
|
|
@@ -16330,7 +16953,7 @@ var awk = defineCommand({
|
|
|
16330
16953
|
usage: "awk [-F fs] [-v var=value] 'program' [FILE]...",
|
|
16331
16954
|
run: runAwk
|
|
16332
16955
|
});
|
|
16333
|
-
var
|
|
16956
|
+
var commands5 = [
|
|
16334
16957
|
head,
|
|
16335
16958
|
tail,
|
|
16336
16959
|
wc,
|
|
@@ -16476,19 +17099,19 @@ var grep = defineCommand({
|
|
|
16476
17099
|
let anyMatch = false;
|
|
16477
17100
|
let status = 1;
|
|
16478
17101
|
for (const target of targets) {
|
|
16479
|
-
let
|
|
17102
|
+
let bytes3;
|
|
16480
17103
|
if (target === "-") {
|
|
16481
|
-
|
|
17104
|
+
bytes3 = await ctx.stdin.readAll();
|
|
16482
17105
|
} else {
|
|
16483
17106
|
try {
|
|
16484
|
-
|
|
17107
|
+
bytes3 = ctx.vfs.readFile(ctx.path(target), ctx.cred);
|
|
16485
17108
|
} catch (e) {
|
|
16486
17109
|
if (!args.has("no-messages")) ctx.reportError(e, target);
|
|
16487
17110
|
status = 2;
|
|
16488
17111
|
continue;
|
|
16489
17112
|
}
|
|
16490
17113
|
}
|
|
16491
|
-
const { lines } = splitLines(
|
|
17114
|
+
const { lines } = splitLines(bytes3);
|
|
16492
17115
|
const matched = [];
|
|
16493
17116
|
let count = 0;
|
|
16494
17117
|
for (let i = 0; i < lines.length && count < maxCount; i++) {
|
|
@@ -17061,7 +17684,7 @@ var cmp = defineCommand({
|
|
|
17061
17684
|
return 0;
|
|
17062
17685
|
}
|
|
17063
17686
|
});
|
|
17064
|
-
var
|
|
17687
|
+
var commands6 = [grep, find, xargs, diff, cmp];
|
|
17065
17688
|
|
|
17066
17689
|
// src/bin/archive.ts
|
|
17067
17690
|
init_mode();
|
|
@@ -17071,8 +17694,8 @@ var BLOCK = 512;
|
|
|
17071
17694
|
var encoder5 = new TextEncoder();
|
|
17072
17695
|
var decoder7 = new TextDecoder();
|
|
17073
17696
|
function writeString(block, offset, value, length) {
|
|
17074
|
-
const
|
|
17075
|
-
for (let i = 0; i < length; i++) block[offset + i] = i <
|
|
17697
|
+
const bytes3 = encoder5.encode(value);
|
|
17698
|
+
for (let i = 0; i < length; i++) block[offset + i] = i < bytes3.length ? bytes3[i] : 0;
|
|
17076
17699
|
}
|
|
17077
17700
|
function writeOctal(block, offset, value, length) {
|
|
17078
17701
|
const text2 = value.toString(8).padStart(length - 1, "0");
|
|
@@ -17223,23 +17846,23 @@ var tar = defineCommand({
|
|
|
17223
17846
|
if (args.has("verbose")) ctx.line(name);
|
|
17224
17847
|
};
|
|
17225
17848
|
for (const operand of args.positional) add(resolve(baseDir, operand), operand);
|
|
17226
|
-
let
|
|
17227
|
-
if (compressed)
|
|
17228
|
-
if (archive === void 0 || archive === "-") ctx.write(
|
|
17229
|
-
else ctx.vfs.writeFile(ctx.path(archive),
|
|
17849
|
+
let bytes4 = createTar(entries2);
|
|
17850
|
+
if (compressed) bytes4 = await gzip(bytes4);
|
|
17851
|
+
if (archive === void 0 || archive === "-") ctx.write(bytes4);
|
|
17852
|
+
else ctx.vfs.writeFile(ctx.path(archive), bytes4, { cred: ctx.cred, mode: 420 });
|
|
17230
17853
|
return 0;
|
|
17231
17854
|
}
|
|
17232
|
-
let
|
|
17233
|
-
if (archive === void 0 || archive === "-")
|
|
17855
|
+
let bytes3;
|
|
17856
|
+
if (archive === void 0 || archive === "-") bytes3 = await ctx.stdin.readAll();
|
|
17234
17857
|
else {
|
|
17235
17858
|
try {
|
|
17236
|
-
|
|
17859
|
+
bytes3 = ctx.vfs.readFile(ctx.path(archive), ctx.cred);
|
|
17237
17860
|
} catch (e) {
|
|
17238
17861
|
return ctx.reportError(e, archive);
|
|
17239
17862
|
}
|
|
17240
17863
|
}
|
|
17241
|
-
if (
|
|
17242
|
-
const entries = readTar(
|
|
17864
|
+
if (bytes3[0] === 31 && bytes3[1] === 139) bytes3 = await gunzip(bytes3);
|
|
17865
|
+
const entries = readTar(bytes3);
|
|
17243
17866
|
const strip = args.num("strip-components", 0);
|
|
17244
17867
|
if (args.has("list")) {
|
|
17245
17868
|
for (const entry of entries) {
|
|
@@ -17376,7 +17999,7 @@ var zlibCompress = defineCommand({
|
|
|
17376
17999
|
});
|
|
17377
18000
|
}
|
|
17378
18001
|
});
|
|
17379
|
-
var
|
|
18002
|
+
var commands7 = [tar, gzip2, gunzip2, zcat, zlibCompress];
|
|
17380
18003
|
|
|
17381
18004
|
// src/bin/hash.ts
|
|
17382
18005
|
init_binary();
|
|
@@ -17418,8 +18041,8 @@ async function checkSums(ctx, algorithm, files, quiet) {
|
|
|
17418
18041
|
checked++;
|
|
17419
18042
|
const [, expected, name] = m;
|
|
17420
18043
|
try {
|
|
17421
|
-
const
|
|
17422
|
-
const actual = await digestHex(algorithm,
|
|
18044
|
+
const bytes3 = ctx.vfs.readFile(ctx.path(name), ctx.cred);
|
|
18045
|
+
const actual = await digestHex(algorithm, bytes3);
|
|
17423
18046
|
if (actual === expected.toLowerCase()) {
|
|
17424
18047
|
if (!quiet) ctx.line(`${name}: OK`);
|
|
17425
18048
|
} else {
|
|
@@ -17584,7 +18207,7 @@ var mktemp = defineCommand({
|
|
|
17584
18207
|
return 0;
|
|
17585
18208
|
}
|
|
17586
18209
|
});
|
|
17587
|
-
var
|
|
18210
|
+
var commands8 = [
|
|
17588
18211
|
md5sum,
|
|
17589
18212
|
sha1sum,
|
|
17590
18213
|
sha224sum,
|
|
@@ -18060,7 +18683,7 @@ var host = defineCommand({
|
|
|
18060
18683
|
return 0;
|
|
18061
18684
|
}
|
|
18062
18685
|
});
|
|
18063
|
-
var
|
|
18686
|
+
var commands9 = [curl, wget, ping, ip, ifconfig, ss, netstat, nc, host];
|
|
18064
18687
|
|
|
18065
18688
|
// src/bin/admin.ts
|
|
18066
18689
|
init_mode();
|
|
@@ -18497,7 +19120,7 @@ sys ${fmt2(Math.floor(ms * 0.2))}
|
|
|
18497
19120
|
return code;
|
|
18498
19121
|
}
|
|
18499
19122
|
});
|
|
18500
|
-
var
|
|
19123
|
+
var commands10 = [
|
|
18501
19124
|
suCmd,
|
|
18502
19125
|
sudo,
|
|
18503
19126
|
useradd,
|
|
@@ -18673,7 +19296,7 @@ var helpCmd = defineCommand({
|
|
|
18673
19296
|
return 0;
|
|
18674
19297
|
}
|
|
18675
19298
|
});
|
|
18676
|
-
var
|
|
19299
|
+
var commands11 = [man, whatis, apropos, less, helpCmd];
|
|
18677
19300
|
|
|
18678
19301
|
// src/bin/clipboard.ts
|
|
18679
19302
|
init_path();
|
|
@@ -18688,12 +19311,12 @@ function readSelection(ctx, selection) {
|
|
|
18688
19311
|
return new Uint8Array();
|
|
18689
19312
|
}
|
|
18690
19313
|
}
|
|
18691
|
-
function writeSelection(ctx, selection,
|
|
19314
|
+
function writeSelection(ctx, selection, bytes3) {
|
|
18692
19315
|
try {
|
|
18693
19316
|
ctx.vfs.mkdir(CLIPBOARD_DIR, { recursive: true, mode: 511 });
|
|
18694
19317
|
} catch {
|
|
18695
19318
|
}
|
|
18696
|
-
ctx.vfs.writeFile(selectionPath(selection),
|
|
19319
|
+
ctx.vfs.writeFile(selectionPath(selection), bytes3, { privileged: true, mode: 438 });
|
|
18697
19320
|
}
|
|
18698
19321
|
var xsel = defineCommand({
|
|
18699
19322
|
name: "xsel",
|
|
@@ -18795,8 +19418,8 @@ var wlCopy = defineCommand({
|
|
|
18795
19418
|
async run(ctx) {
|
|
18796
19419
|
const selection = ctx.args.includes("--primary") || ctx.args.includes("-p") ? "primary" : "clipboard";
|
|
18797
19420
|
const operands = ctx.args.filter((arg) => !arg.startsWith("-"));
|
|
18798
|
-
const
|
|
18799
|
-
writeSelection(ctx, selection,
|
|
19421
|
+
const bytes3 = operands.length ? new TextEncoder().encode(operands.join(" ")) : await ctx.stdin.readAll();
|
|
19422
|
+
writeSelection(ctx, selection, bytes3);
|
|
18800
19423
|
return 0;
|
|
18801
19424
|
}
|
|
18802
19425
|
});
|
|
@@ -18806,13 +19429,13 @@ var wlPaste = defineCommand({
|
|
|
18806
19429
|
usage: "wl-paste [--primary] [-n]",
|
|
18807
19430
|
run(ctx) {
|
|
18808
19431
|
const selection = ctx.args.includes("--primary") || ctx.args.includes("-p") ? "primary" : "clipboard";
|
|
18809
|
-
const
|
|
18810
|
-
ctx.write(
|
|
19432
|
+
const bytes3 = readSelection(ctx, selection);
|
|
19433
|
+
ctx.write(bytes3);
|
|
18811
19434
|
if (!ctx.args.includes("-n") && !ctx.args.includes("--no-newline")) ctx.write("\n");
|
|
18812
19435
|
return 0;
|
|
18813
19436
|
}
|
|
18814
19437
|
});
|
|
18815
|
-
var
|
|
19438
|
+
var commands12 = [xsel, xclip, pbcopy, pbpaste, wlCopy, wlPaste];
|
|
18816
19439
|
|
|
18817
19440
|
// src/node/node.ts
|
|
18818
19441
|
init_path();
|
|
@@ -19260,8 +19883,6 @@ ${lines[index]}`;
|
|
|
19260
19883
|
}
|
|
19261
19884
|
return out;
|
|
19262
19885
|
}
|
|
19263
|
-
|
|
19264
|
-
// src/node/node.ts
|
|
19265
19886
|
var NODE_VERSION = "v22.12.0";
|
|
19266
19887
|
new TextEncoder();
|
|
19267
19888
|
var tempCounter = 0;
|
|
@@ -19405,10 +20026,10 @@ async function execute(ctx, invocation) {
|
|
|
19405
20026
|
}
|
|
19406
20027
|
async function captureStdin(ctx) {
|
|
19407
20028
|
if (ctx.stdin.isTTY || ctx.stdin.interactive) return null;
|
|
19408
|
-
const
|
|
19409
|
-
if (
|
|
20029
|
+
const bytes3 = await ctx.stdin.readAll();
|
|
20030
|
+
if (bytes3.length === 0) return null;
|
|
19410
20031
|
const path = tempPath("stdin", ctx.proc.pid, ".dat");
|
|
19411
|
-
ctx.vfs.writeFile(path,
|
|
20032
|
+
ctx.vfs.writeFile(path, bytes3, { privileged: true, mode: 384 });
|
|
19412
20033
|
return path;
|
|
19413
20034
|
}
|
|
19414
20035
|
var node = defineCommand({
|
|
@@ -19635,7 +20256,7 @@ ${prelude}${preloadRequires(preloads)}${source}
|
|
|
19635
20256
|
}
|
|
19636
20257
|
function resolveScript(ctx, operand) {
|
|
19637
20258
|
const base2 = ctx.path(operand);
|
|
19638
|
-
const candidates2 = [base2, `${base2}.js`, `${base2}.mjs`, `${base2}.cjs`, `${base2}.json`];
|
|
20259
|
+
const candidates2 = [base2, `${base2}.js`, `${base2}.mjs`, `${base2}.cjs`, `${base2}.ts`, `${base2}.tsx`, `${base2}.json`];
|
|
19639
20260
|
for (const candidate of candidates2) {
|
|
19640
20261
|
try {
|
|
19641
20262
|
const st = ctx.vfs.stat(candidate, { cred: ctx.cred });
|
|
@@ -19653,7 +20274,7 @@ function resolveScript(ctx, operand) {
|
|
|
19653
20274
|
} catch {
|
|
19654
20275
|
}
|
|
19655
20276
|
}
|
|
19656
|
-
for (const index of ["index.js", "index.mjs", "index.cjs"]) {
|
|
20277
|
+
for (const index of ["index.js", "index.mjs", "index.cjs", "index.ts", "index.tsx"]) {
|
|
19657
20278
|
const path = join(candidate, index);
|
|
19658
20279
|
if (ctx.vfs.lexists(path)) return ctx.vfs.realpath(path, ctx.cred);
|
|
19659
20280
|
}
|
|
@@ -19770,6 +20391,13 @@ function checkSyntax(ctx, script) {
|
|
|
19770
20391
|
let source = ctx.vfs.readText(script, ctx.cred);
|
|
19771
20392
|
if (source.startsWith("#!")) source = `//${source.slice(2)}`;
|
|
19772
20393
|
try {
|
|
20394
|
+
if (script.endsWith(".ts") || script.endsWith(".tsx")) {
|
|
20395
|
+
source = sucrase.transform(source, {
|
|
20396
|
+
transforms: script.endsWith(".tsx") ? ["typescript", "jsx"] : ["typescript"],
|
|
20397
|
+
filePath: script,
|
|
20398
|
+
production: true
|
|
20399
|
+
}).code;
|
|
20400
|
+
}
|
|
19773
20401
|
const esm = script.endsWith(".mjs") || !script.endsWith(".cjs") && looksLikeEsm(source);
|
|
19774
20402
|
const transformed = esm ? transformEsm(source, script) : null;
|
|
19775
20403
|
new AsyncFunction("exports", "require", "module", "__filename", "__dirname", transformed?.code ?? source);
|
|
@@ -21103,7 +21731,7 @@ var wheels_default = {
|
|
|
21103
21731
|
|
|
21104
21732
|
// package.json
|
|
21105
21733
|
var package_default = {
|
|
21106
|
-
version: "0.2.
|
|
21734
|
+
version: "0.2.23"};
|
|
21107
21735
|
|
|
21108
21736
|
// src/python/extension-abi.ts
|
|
21109
21737
|
var EXTENSION_ABI = {
|
|
@@ -21954,9 +22582,9 @@ var Reader = class {
|
|
|
21954
22582
|
at = 0;
|
|
21955
22583
|
view;
|
|
21956
22584
|
bytes;
|
|
21957
|
-
constructor(
|
|
21958
|
-
this.bytes =
|
|
21959
|
-
this.view = new DataView(
|
|
22585
|
+
constructor(bytes3) {
|
|
22586
|
+
this.bytes = bytes3;
|
|
22587
|
+
this.view = new DataView(bytes3.buffer, bytes3.byteOffset, bytes3.byteLength);
|
|
21960
22588
|
}
|
|
21961
22589
|
need(count) {
|
|
21962
22590
|
if (this.at + count > this.bytes.length) throw new ProtocolError("payload underrun");
|
|
@@ -22042,9 +22670,9 @@ var ByteQueue = class {
|
|
|
22042
22670
|
chunks = [];
|
|
22043
22671
|
length = 0;
|
|
22044
22672
|
waiters = /* @__PURE__ */ new Set();
|
|
22045
|
-
push(
|
|
22046
|
-
if (
|
|
22047
|
-
const copy =
|
|
22673
|
+
push(bytes3) {
|
|
22674
|
+
if (bytes3.length === 0) return;
|
|
22675
|
+
const copy = bytes3.slice();
|
|
22048
22676
|
this.chunks.push(copy);
|
|
22049
22677
|
this.length += copy.length;
|
|
22050
22678
|
this.wake();
|
|
@@ -22104,10 +22732,10 @@ var VirtualTcpConnection = class {
|
|
|
22104
22732
|
if (this.eof) return new Uint8Array();
|
|
22105
22733
|
throw new PosixError(Errno.EAGAIN, "socket read would block");
|
|
22106
22734
|
}
|
|
22107
|
-
write(
|
|
22735
|
+
write(bytes3) {
|
|
22108
22736
|
if (!this.writable) throw new PosixError(this.closed || this.writeClosed ? Errno.EPIPE : Errno.ECONNRESET);
|
|
22109
|
-
this.peer.incoming.push(
|
|
22110
|
-
return
|
|
22737
|
+
this.peer.incoming.push(bytes3);
|
|
22738
|
+
return bytes3.length;
|
|
22111
22739
|
}
|
|
22112
22740
|
async waitForChange() {
|
|
22113
22741
|
if (this.readable || this.closed) return;
|
|
@@ -22390,9 +23018,9 @@ var SO_ERROR = 4;
|
|
|
22390
23018
|
var SO_TYPE = 3;
|
|
22391
23019
|
var SOCK_STREAM = 1;
|
|
22392
23020
|
function int32(value) {
|
|
22393
|
-
const
|
|
22394
|
-
new DataView(
|
|
22395
|
-
return
|
|
23021
|
+
const bytes3 = new Uint8Array(4);
|
|
23022
|
+
new DataView(bytes3.buffer).setInt32(0, value, true);
|
|
23023
|
+
return bytes3;
|
|
22396
23024
|
}
|
|
22397
23025
|
function isLoopback(address) {
|
|
22398
23026
|
if (address === "" || address === "localhost" || address === "0.0.0.0") return true;
|
|
@@ -22783,9 +23411,9 @@ function createHostAbiServer(proc) {
|
|
|
22783
23411
|
/* ---------------------------------------------------------- entropy */
|
|
22784
23412
|
case Op.getrandom: {
|
|
22785
23413
|
const length = Math.min(r.u32(), 65536);
|
|
22786
|
-
const
|
|
22787
|
-
crypto.getRandomValues(
|
|
22788
|
-
return { status: length, payload:
|
|
23414
|
+
const bytes3 = new Uint8Array(length);
|
|
23415
|
+
crypto.getRandomValues(bytes3);
|
|
23416
|
+
return { status: length, payload: bytes3 };
|
|
22789
23417
|
}
|
|
22790
23418
|
/* ----------------------------------------------------------- sockets */
|
|
22791
23419
|
case Op.socket: {
|
|
@@ -23271,9 +23899,9 @@ var FIRST_EGRESS_PORT = 48e3;
|
|
|
23271
23899
|
var MAX_HEADER_BYTES = 64 * 1024;
|
|
23272
23900
|
var MAX_BODY_BYTES = 32 * 1024 * 1024;
|
|
23273
23901
|
var CRLF = "\r\n";
|
|
23274
|
-
function indexOfDoubleCrlf(
|
|
23275
|
-
for (let i = 3; i <
|
|
23276
|
-
if (
|
|
23902
|
+
function indexOfDoubleCrlf(bytes3) {
|
|
23903
|
+
for (let i = 3; i < bytes3.length; i++) {
|
|
23904
|
+
if (bytes3[i] === 10 && bytes3[i - 1] === 13 && bytes3[i - 2] === 10 && bytes3[i - 3] === 13) return i + 1;
|
|
23277
23905
|
}
|
|
23278
23906
|
return -1;
|
|
23279
23907
|
}
|
|
@@ -23538,62 +24166,6 @@ function splitOnce(text2, separator) {
|
|
|
23538
24166
|
return at < 0 ? [text2] : [text2.slice(0, at), text2.slice(at + 1)];
|
|
23539
24167
|
}
|
|
23540
24168
|
|
|
23541
|
-
// src/browser/playwright-browsers.ts
|
|
23542
|
-
init_path();
|
|
23543
|
-
var PLAYWRIGHT_REGISTRY = "/root/.cache/ms-playwright";
|
|
23544
|
-
var LAYOUTS = {
|
|
23545
|
-
"chromium": ["chrome-linux64", "chrome"],
|
|
23546
|
-
"chromium-headless-shell": ["chrome-headless-shell-linux64", "chrome-headless-shell"]
|
|
23547
|
-
};
|
|
23548
|
-
function virtualBrowserFiles(browsersJson) {
|
|
23549
|
-
let manifest;
|
|
23550
|
-
try {
|
|
23551
|
-
manifest = JSON.parse(browsersJson);
|
|
23552
|
-
} catch {
|
|
23553
|
-
return [];
|
|
23554
|
-
}
|
|
23555
|
-
const encoder9 = new TextEncoder();
|
|
23556
|
-
const files = [];
|
|
23557
|
-
for (const browser of manifest.browsers ?? []) {
|
|
23558
|
-
const layout = LAYOUTS[browser.name];
|
|
23559
|
-
if (!layout) continue;
|
|
23560
|
-
const dir3 = join(PLAYWRIGHT_REGISTRY, `${browser.name.replace(/-/g, "_")}-${browser.revision}`);
|
|
23561
|
-
files.push({ path: join(dir3, ...layout), data: encoder9.encode(`#!${BUILTIN_INTERPRETER} chrome
|
|
23562
|
-
`), mode: 493 });
|
|
23563
|
-
files.push({ path: join(dir3, "INSTALLATION_COMPLETE"), data: new Uint8Array() });
|
|
23564
|
-
}
|
|
23565
|
-
return files;
|
|
23566
|
-
}
|
|
23567
|
-
function mkdirp(volume, path) {
|
|
23568
|
-
let current2 = "";
|
|
23569
|
-
for (const part of segments(path)) {
|
|
23570
|
-
current2 += `/${part}`;
|
|
23571
|
-
try {
|
|
23572
|
-
volume.mkdirSync(current2, { mode: 493 });
|
|
23573
|
-
} catch (error) {
|
|
23574
|
-
if (error.code !== "EEXIST") throw error;
|
|
23575
|
-
}
|
|
23576
|
-
}
|
|
23577
|
-
}
|
|
23578
|
-
function installVirtualPlaywrightBrowsers(volume, packageDir) {
|
|
23579
|
-
let text2;
|
|
23580
|
-
try {
|
|
23581
|
-
text2 = new TextDecoder().decode(volume.readFileSync(join(packageDir, "browsers.json")));
|
|
23582
|
-
} catch {
|
|
23583
|
-
return [];
|
|
23584
|
-
}
|
|
23585
|
-
const written = [];
|
|
23586
|
-
for (const file3 of virtualBrowserFiles(text2)) {
|
|
23587
|
-
mkdirp(volume, dirname(file3.path));
|
|
23588
|
-
volume.writeFileSync(file3.path, file3.data);
|
|
23589
|
-
if (file3.mode !== void 0) {
|
|
23590
|
-
volume.chmodSync(file3.path, file3.mode);
|
|
23591
|
-
written.push(file3.path);
|
|
23592
|
-
}
|
|
23593
|
-
}
|
|
23594
|
-
return written;
|
|
23595
|
-
}
|
|
23596
|
-
|
|
23597
24169
|
// src/python/substitutions.ts
|
|
23598
24170
|
var SUBSTITUTED_WHEELS = {
|
|
23599
24171
|
playwright: /-py3-none-manylinux1_x86_64\.whl$/
|
|
@@ -24160,27 +24732,27 @@ async function installRequirements(options) {
|
|
|
24160
24732
|
continue;
|
|
24161
24733
|
}
|
|
24162
24734
|
options.progress.downloading(distribution.name, distribution.version);
|
|
24163
|
-
const
|
|
24164
|
-
const files = stageWheel(readZip(
|
|
24735
|
+
const bytes3 = await download(options.client, distribution);
|
|
24736
|
+
const files = stageWheel(readZip(bytes3));
|
|
24165
24737
|
staged.push(...distribution.kind === "substituted" ? substituteFiles(distribution.name, files, SITE_PACKAGES) : files);
|
|
24166
24738
|
installed3.push({ name: distribution.name, version: distribution.version });
|
|
24167
24739
|
}
|
|
24168
24740
|
commit(options.vfs, options.cred, staged);
|
|
24169
24741
|
return { installed: installed3, skipped: solved.skipped };
|
|
24170
24742
|
}
|
|
24171
|
-
function requireArchive(distribution,
|
|
24172
|
-
if (
|
|
24173
|
-
const opening = new TextDecoder().decode(
|
|
24743
|
+
function requireArchive(distribution, bytes3) {
|
|
24744
|
+
if (bytes3.length > 1 && bytes3[0] === 80 && bytes3[1] === 75) return;
|
|
24745
|
+
const opening = new TextDecoder().decode(bytes3.subarray(0, 80)).replace(/\s+/g, " ").trim();
|
|
24174
24746
|
const looksLikeMarkup = /^<!doctype|^<html/i.test(opening);
|
|
24175
24747
|
throw new Error(
|
|
24176
|
-
`${distribution.filename} did not arrive as a wheel from ${distribution.url}: ` + (looksLikeMarkup ? "the server answered with an HTML page, which usually means the wheel is not published at that address and the server returned its index page instead" : `expected a zip archive, got ${
|
|
24748
|
+
`${distribution.filename} did not arrive as a wheel from ${distribution.url}: ` + (looksLikeMarkup ? "the server answered with an HTML page, which usually means the wheel is not published at that address and the server returned its index page instead" : `expected a zip archive, got ${bytes3.length} bytes beginning ${JSON.stringify(opening)}`)
|
|
24177
24749
|
);
|
|
24178
24750
|
}
|
|
24179
24751
|
async function download(client, distribution) {
|
|
24180
|
-
const
|
|
24181
|
-
requireArchive(distribution,
|
|
24182
|
-
const mismatch = digestMismatch(distribution,
|
|
24183
|
-
if (!mismatch) return
|
|
24752
|
+
const bytes3 = await client.bytes(distribution.url, { timeoutMs: 12e4 });
|
|
24753
|
+
requireArchive(distribution, bytes3);
|
|
24754
|
+
const mismatch = digestMismatch(distribution, bytes3);
|
|
24755
|
+
if (!mismatch) return bytes3;
|
|
24184
24756
|
const fresh = await refetch(client, distribution);
|
|
24185
24757
|
if (fresh && !digestMismatch(distribution, fresh)) {
|
|
24186
24758
|
requireArchive(distribution, fresh);
|
|
@@ -24193,22 +24765,22 @@ async function download(client, distribution) {
|
|
|
24193
24765
|
async function refetch(client, distribution) {
|
|
24194
24766
|
const separator = distribution.url.includes("?") ? "&" : "?";
|
|
24195
24767
|
try {
|
|
24196
|
-
const
|
|
24768
|
+
const bytes3 = await client.bytes(
|
|
24197
24769
|
`${distribution.url}${separator}sha256=${distribution.sha256}`,
|
|
24198
24770
|
{ timeoutMs: 6e4 }
|
|
24199
24771
|
);
|
|
24200
|
-
return
|
|
24772
|
+
return bytes3.length > 1 && bytes3[0] === 80 && bytes3[1] === 75 ? bytes3 : null;
|
|
24201
24773
|
} catch {
|
|
24202
24774
|
return null;
|
|
24203
24775
|
}
|
|
24204
24776
|
}
|
|
24205
|
-
function digestMismatch(distribution,
|
|
24777
|
+
function digestMismatch(distribution, bytes3) {
|
|
24206
24778
|
if (!distribution.sha256) {
|
|
24207
24779
|
throw new Error(
|
|
24208
24780
|
`${distribution.filename} was published without a sha256 digest, so it cannot be verified`
|
|
24209
24781
|
);
|
|
24210
24782
|
}
|
|
24211
|
-
const actual = [...sha256.sha256(
|
|
24783
|
+
const actual = [...sha256.sha256(bytes3)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
24212
24784
|
if (actual === distribution.sha256) return null;
|
|
24213
24785
|
return `${distribution.filename} failed verification: the index published sha256 ${distribution.sha256} but the download hashes to ${actual}.`;
|
|
24214
24786
|
}
|
|
@@ -24338,9 +24910,9 @@ function outputFor(description, fallback) {
|
|
|
24338
24910
|
return {
|
|
24339
24911
|
write(data) {
|
|
24340
24912
|
if (broken) return;
|
|
24341
|
-
const
|
|
24342
|
-
if (
|
|
24343
|
-
queue.push(
|
|
24913
|
+
const bytes3 = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
24914
|
+
if (bytes3.length === 0) return;
|
|
24915
|
+
queue.push(bytes3.slice());
|
|
24344
24916
|
if (!active) done = pump();
|
|
24345
24917
|
},
|
|
24346
24918
|
end() {
|
|
@@ -25705,9 +26277,9 @@ environments. A package with no usable wheel is an error, never a silent skip.`,
|
|
|
25705
26277
|
)];
|
|
25706
26278
|
if (embedded) {
|
|
25707
26279
|
const binary = atob(embedded);
|
|
25708
|
-
const
|
|
25709
|
-
for (let i = 0; i < binary.length; i += 1)
|
|
25710
|
-
return await read(new Response(
|
|
26280
|
+
const bytes3 = new Uint8Array(binary.length);
|
|
26281
|
+
for (let i = 0; i < binary.length; i += 1) bytes3[i] = binary.charCodeAt(i);
|
|
26282
|
+
return await read(new Response(bytes3));
|
|
25711
26283
|
}
|
|
25712
26284
|
if (url.startsWith("sbx-wheel:")) {
|
|
25713
26285
|
const filename = decodeURIComponent(url.slice("sbx-wheel:".length).replace(/^\/+/, ""));
|
|
@@ -25776,7 +26348,7 @@ environments. A package with no usable wheel is an error, never a silent skip.`,
|
|
|
25776
26348
|
let attemptsLeft = 12;
|
|
25777
26349
|
for (; ; ) {
|
|
25778
26350
|
try {
|
|
25779
|
-
const
|
|
26351
|
+
const report2 = await installRequirements({
|
|
25780
26352
|
index,
|
|
25781
26353
|
client,
|
|
25782
26354
|
vfs: ctx.vfs,
|
|
@@ -25797,11 +26369,11 @@ environments. A package with no usable wheel is an error, never a silent skip.`,
|
|
|
25797
26369
|
}
|
|
25798
26370
|
}
|
|
25799
26371
|
});
|
|
25800
|
-
for (const skipped of
|
|
26372
|
+
for (const skipped of report2.skipped) {
|
|
25801
26373
|
ctx.line(` Skipping ${skipped.name} (marker: ${skipped.marker})`);
|
|
25802
26374
|
}
|
|
25803
26375
|
ctx.line(
|
|
25804
|
-
`Successfully installed ${
|
|
26376
|
+
`Successfully installed ${report2.installed.map((p) => `${p.name}-${p.version}`).join(" ")}`
|
|
25805
26377
|
);
|
|
25806
26378
|
return 0;
|
|
25807
26379
|
} catch (error) {
|
|
@@ -26187,11 +26759,11 @@ async function loadFactory() {
|
|
|
26187
26759
|
function getCompiled() {
|
|
26188
26760
|
compiled2 ??= (async () => {
|
|
26189
26761
|
const { factory, wasm } = await loadFactory();
|
|
26190
|
-
const
|
|
26762
|
+
const bytes3 = wasm.buffer.slice(
|
|
26191
26763
|
wasm.byteOffset,
|
|
26192
26764
|
wasm.byteOffset + wasm.byteLength
|
|
26193
26765
|
);
|
|
26194
|
-
return { factory, module: await WebAssembly.compile(
|
|
26766
|
+
return { factory, module: await WebAssembly.compile(bytes3) };
|
|
26195
26767
|
})();
|
|
26196
26768
|
void compiled2.catch(() => compiled2 = null);
|
|
26197
26769
|
return compiled2;
|
|
@@ -26339,18 +26911,18 @@ than a packet path, and socket calls report ENOTSUP.`,
|
|
|
26339
26911
|
}
|
|
26340
26912
|
if (module === void 0) return ctx.reportError(new UsageError("a module is required"));
|
|
26341
26913
|
const abs = ctx.path(module);
|
|
26342
|
-
let
|
|
26914
|
+
let bytes3;
|
|
26343
26915
|
try {
|
|
26344
|
-
|
|
26916
|
+
bytes3 = ctx.vfs.readFile(abs, ctx.cred);
|
|
26345
26917
|
} catch (error) {
|
|
26346
26918
|
ctx.reportError(error, abs);
|
|
26347
26919
|
return EXIT_NOT_FOUND;
|
|
26348
26920
|
}
|
|
26349
|
-
if (!isWasmBinary(
|
|
26921
|
+
if (!isWasmBinary(bytes3)) {
|
|
26350
26922
|
return ctx.fail(`${abs}: not a WebAssembly module`, 126);
|
|
26351
26923
|
}
|
|
26352
26924
|
Object.assign(ctx.env, env2);
|
|
26353
|
-
return await runWasi(ctx,
|
|
26925
|
+
return await runWasi(ctx, bytes3, {
|
|
26354
26926
|
/* argv[0] is the path as the user wrote it, not the resolved one: a
|
|
26355
26927
|
* program printing its own usage should echo what was typed. */
|
|
26356
26928
|
argv: [module, ...rest],
|
|
@@ -26361,398 +26933,6 @@ than a packet path, and socket calls report ENOTSUP.`,
|
|
|
26361
26933
|
function wasiCommands() {
|
|
26362
26934
|
return [wasi];
|
|
26363
26935
|
}
|
|
26364
|
-
var platformBuffer = globalThis.Buffer;
|
|
26365
|
-
addUint8ArraySupport(addBase64UrlSupport(index_js.Buffer));
|
|
26366
|
-
var Buffer2 = platformBuffer ?? index_js.Buffer;
|
|
26367
|
-
function addUint8ArraySupport(BufferClass) {
|
|
26368
|
-
const target = BufferClass;
|
|
26369
|
-
if (target.__sandboxedUint8Array) return BufferClass;
|
|
26370
|
-
Object.defineProperty(target, "__sandboxedUint8Array", { value: true });
|
|
26371
|
-
const asBuffer = (value) => value instanceof Uint8Array && !target.isBuffer(value) ? target.from(value.buffer, value.byteOffset, value.byteLength) : value;
|
|
26372
|
-
for (const method of ["indexOf", "lastIndexOf", "includes"]) {
|
|
26373
|
-
const original = target.prototype[method];
|
|
26374
|
-
target.prototype[method] = function(value, ...rest) {
|
|
26375
|
-
return original.call(this, asBuffer(value), ...rest);
|
|
26376
|
-
};
|
|
26377
|
-
}
|
|
26378
|
-
const equals = target.prototype.equals;
|
|
26379
|
-
target.prototype.equals = function(other) {
|
|
26380
|
-
return equals.call(this, asBuffer(other));
|
|
26381
|
-
};
|
|
26382
|
-
return BufferClass;
|
|
26383
|
-
}
|
|
26384
|
-
function addBase64UrlSupport(BufferClass) {
|
|
26385
|
-
const target = BufferClass;
|
|
26386
|
-
if (target.__sandboxedBase64Url) return BufferClass;
|
|
26387
|
-
Object.defineProperty(target, "__sandboxedBase64Url", { value: true });
|
|
26388
|
-
const from = target.from.bind(target);
|
|
26389
|
-
target.from = (value, encodingOrOffset, length) => from(value, normalizeEncoding(encodingOrOffset), length);
|
|
26390
|
-
const byteLength = target.byteLength.bind(target);
|
|
26391
|
-
target.byteLength = (value, encoding) => byteLength(value, normalizeEncoding(encoding));
|
|
26392
|
-
const isEncoding = target.isEncoding?.bind(target);
|
|
26393
|
-
if (isEncoding) target.isEncoding = (encoding) => encoding.toLowerCase() === "base64url" || isEncoding(encoding);
|
|
26394
|
-
const toString = target.prototype.toString;
|
|
26395
|
-
target.prototype.toString = function(encoding, start2, end) {
|
|
26396
|
-
if (encoding?.toLowerCase() !== "base64url") return toString.call(this, encoding, start2, end);
|
|
26397
|
-
return toString.call(this, "base64", start2, end).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
26398
|
-
};
|
|
26399
|
-
const write = target.prototype.write;
|
|
26400
|
-
target.prototype.write = function(...args) {
|
|
26401
|
-
const index = typeof args[1] === "string" ? 1 : typeof args[2] === "string" ? 2 : 3;
|
|
26402
|
-
if (typeof args[index] === "string") args[index] = normalizeEncoding(args[index]);
|
|
26403
|
-
return write.apply(this, args);
|
|
26404
|
-
};
|
|
26405
|
-
return BufferClass;
|
|
26406
|
-
}
|
|
26407
|
-
function normalizeEncoding(value) {
|
|
26408
|
-
return typeof value === "string" && value.toLowerCase() === "base64url" ? "base64" : value;
|
|
26409
|
-
}
|
|
26410
|
-
|
|
26411
|
-
// src/pkg/clean-installer.ts
|
|
26412
|
-
init_path();
|
|
26413
|
-
var CleanPackageInstaller = class _CleanPackageInstaller {
|
|
26414
|
-
constructor(volume, options = {}) {
|
|
26415
|
-
this.volume = volume;
|
|
26416
|
-
this.options = options;
|
|
26417
|
-
this.registry = (options.registry ?? "https://registry.npmjs.org").replace(/\/$/, "");
|
|
26418
|
-
this.fetcher = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
26419
|
-
}
|
|
26420
|
-
volume;
|
|
26421
|
-
options;
|
|
26422
|
-
registry;
|
|
26423
|
-
fetcher;
|
|
26424
|
-
metadata = /* @__PURE__ */ new Map();
|
|
26425
|
-
tarballs = /* @__PURE__ */ new Map();
|
|
26426
|
-
/** Single-version manifests, for the fields the packument omits. */
|
|
26427
|
-
details = /* @__PURE__ */ new Map();
|
|
26428
|
-
forCwd(cwd) {
|
|
26429
|
-
const installer = new _CleanPackageInstaller(this.volume, { ...this.options, cwd });
|
|
26430
|
-
installer.metadata = this.metadata;
|
|
26431
|
-
installer.tarballs = this.tarballs;
|
|
26432
|
-
installer.details = this.details;
|
|
26433
|
-
return installer;
|
|
26434
|
-
}
|
|
26435
|
-
async install(name, version = "latest", options = {}) {
|
|
26436
|
-
const cwd = this.options.cwd ?? "/";
|
|
26437
|
-
const manifest = await this.installAt(name, version || "latest", join(cwd, "node_modules"), options, /* @__PURE__ */ new Set());
|
|
26438
|
-
if (options.persist !== false) this.persist(cwd, name, version, options.persistDev === true);
|
|
26439
|
-
return manifest;
|
|
26440
|
-
}
|
|
26441
|
-
async installFromManifest(path, options = {}) {
|
|
26442
|
-
const project = this.readJson(path);
|
|
26443
|
-
const cwd = dirname(path);
|
|
26444
|
-
const dependencies = {
|
|
26445
|
-
...project.dependencies ?? {},
|
|
26446
|
-
...options.withDevDeps === false ? {} : project.devDependencies ?? {}
|
|
26447
|
-
};
|
|
26448
|
-
await this.prefetch(dependencies);
|
|
26449
|
-
for (const [name, range] of Object.entries(dependencies)) {
|
|
26450
|
-
await this.installAt(name, range, join(cwd, "node_modules"), options, /* @__PURE__ */ new Set());
|
|
26451
|
-
}
|
|
26452
|
-
}
|
|
26453
|
-
async installAt(name, range, modulesRoot, options, ancestry) {
|
|
26454
|
-
const metadata = await this.getMetadata(name);
|
|
26455
|
-
const version = resolveVersion(metadata, range);
|
|
26456
|
-
const manifest = metadata.versions[version];
|
|
26457
|
-
if (!manifest) throw new Error(`No matching version found for ${name}@${range}`);
|
|
26458
|
-
const identity = `${name}@${version}`;
|
|
26459
|
-
if (!supportsPlatform(manifest)) throw new IncompatiblePlatform(identity, "");
|
|
26460
|
-
if (manifest.os?.length || manifest.cpu?.length) {
|
|
26461
|
-
const detail = await this.platformDetail(name, version);
|
|
26462
|
-
if (!platformListAllows(detail.libc, PLATFORM.libc)) {
|
|
26463
|
-
throw new IncompatiblePlatform(identity, ` (needs ${detail.libc?.join(", ")})`);
|
|
26464
|
-
}
|
|
26465
|
-
if (detail.main?.endsWith(".node")) {
|
|
26466
|
-
throw new IncompatiblePlatform(identity, " (native addon; this runtime cannot dlopen)");
|
|
26467
|
-
}
|
|
26468
|
-
}
|
|
26469
|
-
const target = join(modulesRoot, name);
|
|
26470
|
-
const installed3 = this.tryReadJson(join(target, "package.json"));
|
|
26471
|
-
if (ancestry.has(identity)) return manifest;
|
|
26472
|
-
if (installed3?.version !== version) {
|
|
26473
|
-
options.onProgress?.(`Fetching ${identity}`);
|
|
26474
|
-
const archive = await this.getTarball(manifest.dist.tarball);
|
|
26475
|
-
verifyIntegrity(archive, manifest.dist.integrity, manifest.dist.shasum, identity);
|
|
26476
|
-
this.removeIfPresent(target);
|
|
26477
|
-
mkdirp2(this.volume, target);
|
|
26478
|
-
extractNpmTarball(this.volume, archive, target);
|
|
26479
|
-
options.onProgress?.(`Installed ${identity}`);
|
|
26480
|
-
}
|
|
26481
|
-
this.createBinLinks(manifest, target, modulesRoot);
|
|
26482
|
-
if (name === "playwright-core") {
|
|
26483
|
-
for (const executable of installVirtualPlaywrightBrowsers(this.volume, target)) {
|
|
26484
|
-
options.onProgress?.(`Linked ${executable} to the virtual browser`);
|
|
26485
|
-
}
|
|
26486
|
-
}
|
|
26487
|
-
const nextAncestry = new Set(ancestry).add(identity);
|
|
26488
|
-
const childRoot = join(target, "node_modules");
|
|
26489
|
-
const required = Object.fromEntries(Object.entries(manifest.dependencies ?? {}).filter(([name2]) => !(name2 in (manifest.optionalDependencies ?? {}))));
|
|
26490
|
-
await this.prefetch(required);
|
|
26491
|
-
for (const [dependency, dependencyRange] of Object.entries(required)) {
|
|
26492
|
-
await this.installAt(dependency, dependencyRange, childRoot, options, nextAncestry);
|
|
26493
|
-
}
|
|
26494
|
-
for (const [dependency, dependencyRange] of Object.entries(manifest.optionalDependencies ?? {})) {
|
|
26495
|
-
try {
|
|
26496
|
-
await this.installAt(dependency, dependencyRange, childRoot, options, nextAncestry);
|
|
26497
|
-
} catch (error) {
|
|
26498
|
-
if (error instanceof IncompatiblePlatform) continue;
|
|
26499
|
-
options.onProgress?.(`Skipped optional ${dependency}: ${error instanceof Error ? error.message : String(error)}`);
|
|
26500
|
-
}
|
|
26501
|
-
}
|
|
26502
|
-
return manifest;
|
|
26503
|
-
}
|
|
26504
|
-
/**
|
|
26505
|
-
* The `libc` and `main` fields, which the abbreviated packument leaves out.
|
|
26506
|
-
*
|
|
26507
|
-
* Fetched per version rather than as a full packument: the single-version
|
|
26508
|
-
* document is a few kilobytes, while the full one for a popular package runs
|
|
26509
|
-
* to megabytes. Only packages that already declare `os` or `cpu` ask for it,
|
|
26510
|
-
* so an ordinary install of pure-JavaScript dependencies makes no extra
|
|
26511
|
-
* requests at all — it is the prebuilt binaries, a handful per project, that
|
|
26512
|
-
* need the answer.
|
|
26513
|
-
*
|
|
26514
|
-
* A failure here is not fatal. Being unable to read `libc` puts the check
|
|
26515
|
-
* back where it was before this existed, which is worth strictly less than
|
|
26516
|
-
* being right and strictly more than refusing to install.
|
|
26517
|
-
*/
|
|
26518
|
-
async platformDetail(name, version) {
|
|
26519
|
-
const key = `${name}@${version}`;
|
|
26520
|
-
let request = this.details.get(key);
|
|
26521
|
-
if (!request) {
|
|
26522
|
-
request = (async () => {
|
|
26523
|
-
try {
|
|
26524
|
-
const encoded = name.startsWith("@") ? name.replace("/", "%2F") : encodeURIComponent(name);
|
|
26525
|
-
const response = await this.fetcher(`${this.registry}/${encoded}/${version}`);
|
|
26526
|
-
if (!response.ok) return {};
|
|
26527
|
-
return await response.json();
|
|
26528
|
-
} catch {
|
|
26529
|
-
return {};
|
|
26530
|
-
}
|
|
26531
|
-
})();
|
|
26532
|
-
this.details.set(key, request);
|
|
26533
|
-
}
|
|
26534
|
-
return request;
|
|
26535
|
-
}
|
|
26536
|
-
/** Overlap up to six sibling downloads; filesystem writes remain ordered. */
|
|
26537
|
-
async prefetch(dependencies) {
|
|
26538
|
-
const entries = Object.entries(dependencies);
|
|
26539
|
-
let next = 0;
|
|
26540
|
-
await Promise.all(Array.from({ length: Math.min(6, entries.length) }, async () => {
|
|
26541
|
-
while (next < entries.length) {
|
|
26542
|
-
const [name, range] = entries[next++];
|
|
26543
|
-
try {
|
|
26544
|
-
const metadata = await this.getMetadata(name);
|
|
26545
|
-
const manifest = metadata.versions[resolveVersion(metadata, range)];
|
|
26546
|
-
if (!manifest.os?.length && !manifest.cpu?.length && supportsPlatform(manifest)) {
|
|
26547
|
-
await this.getTarball(manifest.dist.tarball);
|
|
26548
|
-
}
|
|
26549
|
-
} catch {
|
|
26550
|
-
}
|
|
26551
|
-
}
|
|
26552
|
-
}));
|
|
26553
|
-
}
|
|
26554
|
-
async getMetadata(name) {
|
|
26555
|
-
let request = this.metadata.get(name);
|
|
26556
|
-
if (!request) {
|
|
26557
|
-
request = (async () => {
|
|
26558
|
-
const encoded = name.startsWith("@") ? name.replace("/", "%2F") : encodeURIComponent(name);
|
|
26559
|
-
const response = await this.fetcher(`${this.registry}/${encoded}`, {
|
|
26560
|
-
headers: { Accept: "application/vnd.npm.install-v1+json" }
|
|
26561
|
-
});
|
|
26562
|
-
if (!response.ok) throw new Error(`registry returned ${response.status} for ${name}`);
|
|
26563
|
-
return await response.json();
|
|
26564
|
-
})();
|
|
26565
|
-
this.metadata.set(name, request);
|
|
26566
|
-
void request.catch(() => {
|
|
26567
|
-
this.metadata.delete(name);
|
|
26568
|
-
});
|
|
26569
|
-
}
|
|
26570
|
-
return request;
|
|
26571
|
-
}
|
|
26572
|
-
async getTarball(url) {
|
|
26573
|
-
let request = this.tarballs.get(url);
|
|
26574
|
-
if (!request) {
|
|
26575
|
-
request = (async () => {
|
|
26576
|
-
const response = await this.fetcher(url);
|
|
26577
|
-
if (!response.ok) throw new Error(`tarball returned ${response.status}: ${url}`);
|
|
26578
|
-
return new Uint8Array(await response.arrayBuffer());
|
|
26579
|
-
})();
|
|
26580
|
-
this.tarballs.set(url, request);
|
|
26581
|
-
void request.catch(() => {
|
|
26582
|
-
this.tarballs.delete(url);
|
|
26583
|
-
});
|
|
26584
|
-
}
|
|
26585
|
-
return request;
|
|
26586
|
-
}
|
|
26587
|
-
createBinLinks(manifest, target, modulesRoot) {
|
|
26588
|
-
if (!manifest.bin) return;
|
|
26589
|
-
const bins = typeof manifest.bin === "string" ? { [unscoped(manifest.name)]: manifest.bin } : manifest.bin;
|
|
26590
|
-
const binDir = join(modulesRoot, ".bin");
|
|
26591
|
-
mkdirp2(this.volume, binDir);
|
|
26592
|
-
for (const [name, path] of Object.entries(bins)) {
|
|
26593
|
-
const link = join(binDir, name);
|
|
26594
|
-
this.removeIfPresent(link);
|
|
26595
|
-
this.volume.symlinkSync(relative(binDir, join(target, path)), link);
|
|
26596
|
-
}
|
|
26597
|
-
}
|
|
26598
|
-
persist(cwd, name, range, dev) {
|
|
26599
|
-
const path = join(cwd, "package.json");
|
|
26600
|
-
const manifest = this.tryReadJson(path) ?? {};
|
|
26601
|
-
const key = dev ? "devDependencies" : "dependencies";
|
|
26602
|
-
manifest[key] = { ...manifest[key] ?? {}, [name]: range === "latest" ? "*" : range };
|
|
26603
|
-
this.volume.writeFileSync(path, JSON.stringify(manifest, null, 2) + "\n");
|
|
26604
|
-
}
|
|
26605
|
-
removeIfPresent(path) {
|
|
26606
|
-
let stat2;
|
|
26607
|
-
try {
|
|
26608
|
-
stat2 = this.volume.lstatSync(path);
|
|
26609
|
-
} catch {
|
|
26610
|
-
return;
|
|
26611
|
-
}
|
|
26612
|
-
if (!stat2.isDirectory()) return this.volume.unlinkSync(path);
|
|
26613
|
-
for (const name of this.volume.readdirSync(path)) this.removeIfPresent(join(path, name));
|
|
26614
|
-
this.volume.rmdirSync(path);
|
|
26615
|
-
}
|
|
26616
|
-
readJson(path) {
|
|
26617
|
-
return JSON.parse(new TextDecoder().decode(this.volume.readFileSync(path)));
|
|
26618
|
-
}
|
|
26619
|
-
tryReadJson(path) {
|
|
26620
|
-
try {
|
|
26621
|
-
return this.readJson(path);
|
|
26622
|
-
} catch {
|
|
26623
|
-
return null;
|
|
26624
|
-
}
|
|
26625
|
-
}
|
|
26626
|
-
};
|
|
26627
|
-
var PLATFORM = { os: "linux", cpu: "x64", libc: "glibc" };
|
|
26628
|
-
var IncompatiblePlatform = class extends Error {
|
|
26629
|
-
constructor(identity, detail) {
|
|
26630
|
-
super(`${identity} is not compatible with ${PLATFORM.os}/${PLATFORM.cpu}/${PLATFORM.libc}${detail}`);
|
|
26631
|
-
this.name = "IncompatiblePlatform";
|
|
26632
|
-
}
|
|
26633
|
-
};
|
|
26634
|
-
function supportsPlatform(manifest) {
|
|
26635
|
-
return platformListAllows(manifest.os, PLATFORM.os) && platformListAllows(manifest.cpu, PLATFORM.cpu) && platformListAllows(manifest.libc, PLATFORM.libc);
|
|
26636
|
-
}
|
|
26637
|
-
function platformListAllows(values, current2) {
|
|
26638
|
-
if (!values?.length) return true;
|
|
26639
|
-
if (values.includes(`!${current2}`)) return false;
|
|
26640
|
-
const positive = values.filter((value) => !value.startsWith("!"));
|
|
26641
|
-
return positive.length === 0 || positive.includes(current2) || positive.includes("any");
|
|
26642
|
-
}
|
|
26643
|
-
function resolveVersion(metadata, range) {
|
|
26644
|
-
const tag2 = metadata["dist-tags"]?.[range];
|
|
26645
|
-
if (tag2) return tag2;
|
|
26646
|
-
if (semver.valid(range) && metadata.versions[range]) return range;
|
|
26647
|
-
const found2 = semver.maxSatisfying(Object.keys(metadata.versions), range === "latest" ? "*" : range, { includePrerelease: false });
|
|
26648
|
-
if (!found2) throw new Error(`No matching version found for ${metadata.name}@${range}`);
|
|
26649
|
-
return found2;
|
|
26650
|
-
}
|
|
26651
|
-
function verifyIntegrity(data, integrity, shasum, identity) {
|
|
26652
|
-
if (integrity) {
|
|
26653
|
-
const choices = integrity.trim().split(/\s+/);
|
|
26654
|
-
for (const choice of choices) {
|
|
26655
|
-
const dash = choice.indexOf("-");
|
|
26656
|
-
const algorithm = choice.slice(0, dash);
|
|
26657
|
-
const expected = choice.slice(dash + 1).replace(/\?.*$/, "");
|
|
26658
|
-
const digest2 = algorithm === "sha512" ? sha512.sha512(data) : algorithm === "sha256" ? sha256.sha256(data) : null;
|
|
26659
|
-
if (digest2 && Buffer2.from(digest2).toString("base64") === expected) return;
|
|
26660
|
-
}
|
|
26661
|
-
throw new Error(`Integrity check failed for ${identity}`);
|
|
26662
|
-
}
|
|
26663
|
-
if (shasum && Buffer2.from(sha1.sha1(data)).toString("hex") === shasum) return;
|
|
26664
|
-
if (shasum) throw new Error(`Legacy checksum check failed for ${identity}`);
|
|
26665
|
-
}
|
|
26666
|
-
function extractNpmTarball(volume, compressed, destination) {
|
|
26667
|
-
const tar2 = pako.ungzip(compressed);
|
|
26668
|
-
let offset = 0;
|
|
26669
|
-
let longPath = null;
|
|
26670
|
-
let paxPath = null;
|
|
26671
|
-
while (offset + 512 <= tar2.length) {
|
|
26672
|
-
const header = tar2.subarray(offset, offset + 512);
|
|
26673
|
-
if (header.every((byte) => byte === 0)) break;
|
|
26674
|
-
const size = octal(header, 124, 12);
|
|
26675
|
-
const type = String.fromCharCode(header[156] || 48);
|
|
26676
|
-
const prefix = text(header, 345, 155);
|
|
26677
|
-
let name = longPath ?? paxPath ?? [prefix, text(header, 0, 100)].filter(Boolean).join("/");
|
|
26678
|
-
longPath = null;
|
|
26679
|
-
paxPath = null;
|
|
26680
|
-
const data = tar2.subarray(offset + 512, offset + 512 + size);
|
|
26681
|
-
offset += 512 + Math.ceil(size / 512) * 512;
|
|
26682
|
-
if (type === "L") {
|
|
26683
|
-
longPath = new TextDecoder().decode(data).replace(/\0.*$/, "").trim();
|
|
26684
|
-
continue;
|
|
26685
|
-
}
|
|
26686
|
-
if (type === "x" || type === "g") {
|
|
26687
|
-
paxPath = parsePax(data).path ?? null;
|
|
26688
|
-
continue;
|
|
26689
|
-
}
|
|
26690
|
-
name = stripPackageRoot(name);
|
|
26691
|
-
if (!name) continue;
|
|
26692
|
-
const target = safeTarget(destination, name);
|
|
26693
|
-
const mode = octal(header, 100, 8) || 420;
|
|
26694
|
-
if (type === "5") {
|
|
26695
|
-
mkdirp2(volume, target, mode);
|
|
26696
|
-
} else if (type === "2") {
|
|
26697
|
-
mkdirp2(volume, dirname(target));
|
|
26698
|
-
volume.symlinkSync(text(header, 157, 100), target);
|
|
26699
|
-
} else if (type === "1") {
|
|
26700
|
-
mkdirp2(volume, dirname(target));
|
|
26701
|
-
volume.linkSync(safeTarget(destination, stripPackageRoot(text(header, 157, 100))), target);
|
|
26702
|
-
} else if (type === "0" || type === "\0" || type === "7") {
|
|
26703
|
-
mkdirp2(volume, dirname(target));
|
|
26704
|
-
volume.writeFileSync(target, data.slice());
|
|
26705
|
-
volume.chmodSync(target, mode);
|
|
26706
|
-
}
|
|
26707
|
-
}
|
|
26708
|
-
}
|
|
26709
|
-
function mkdirp2(volume, path, mode = 493) {
|
|
26710
|
-
let current2 = "";
|
|
26711
|
-
for (const part of segments(path)) {
|
|
26712
|
-
current2 += `/${part}`;
|
|
26713
|
-
try {
|
|
26714
|
-
volume.mkdirSync(current2, { mode });
|
|
26715
|
-
} catch (error) {
|
|
26716
|
-
if (error.code !== "EEXIST") throw error;
|
|
26717
|
-
if (!volume.lstatSync(current2).isDirectory()) throw error;
|
|
26718
|
-
}
|
|
26719
|
-
}
|
|
26720
|
-
}
|
|
26721
|
-
function safeTarget(destination, name) {
|
|
26722
|
-
const clean2 = clean(`/${name}`).slice(1);
|
|
26723
|
-
if (!clean2 || clean2 === ".." || clean2.startsWith("../") || name.startsWith("/")) throw new Error(`Unsafe path in package: ${name}`);
|
|
26724
|
-
return join(destination, clean2);
|
|
26725
|
-
}
|
|
26726
|
-
function stripPackageRoot(name) {
|
|
26727
|
-
const clean2 = name.replace(/^\.\//, "").replace(/\/$/, "");
|
|
26728
|
-
const slash = clean2.indexOf("/");
|
|
26729
|
-
return slash === -1 ? "" : clean2.slice(slash + 1);
|
|
26730
|
-
}
|
|
26731
|
-
function text(bytes2, start2, length) {
|
|
26732
|
-
return new TextDecoder().decode(bytes2.subarray(start2, start2 + length)).replace(/\0.*$/, "").trim();
|
|
26733
|
-
}
|
|
26734
|
-
function octal(bytes2, start2, length) {
|
|
26735
|
-
return parseInt(text(bytes2, start2, length).replace(/^0+/, "") || "0", 8);
|
|
26736
|
-
}
|
|
26737
|
-
function parsePax(data) {
|
|
26738
|
-
const value = new TextDecoder().decode(data);
|
|
26739
|
-
const result = {};
|
|
26740
|
-
let offset = 0;
|
|
26741
|
-
while (offset < value.length) {
|
|
26742
|
-
const space = value.indexOf(" ", offset);
|
|
26743
|
-
if (space < 0) break;
|
|
26744
|
-
const length = Number(value.slice(offset, space));
|
|
26745
|
-
if (!Number.isFinite(length) || length <= 0) break;
|
|
26746
|
-
const record2 = value.slice(space + 1, offset + length - 1);
|
|
26747
|
-
const equal2 = record2.indexOf("=");
|
|
26748
|
-
if (equal2 > 0) result[record2.slice(0, equal2)] = record2.slice(equal2 + 1);
|
|
26749
|
-
offset += length;
|
|
26750
|
-
}
|
|
26751
|
-
return result;
|
|
26752
|
-
}
|
|
26753
|
-
function unscoped(name) {
|
|
26754
|
-
return name.startsWith("@") ? name.slice(name.indexOf("/") + 1) : name;
|
|
26755
|
-
}
|
|
26756
26936
|
var DECLARES_EXPORTS = /(?:^|[\s;{)])(?:var|let|const|function|class)\s+exports\b/;
|
|
26757
26937
|
var NAME = "exports";
|
|
26758
26938
|
function renameShadowedExports(source) {
|
|
@@ -28465,8 +28645,8 @@ var VireoEngine = class _VireoEngine {
|
|
|
28465
28645
|
const app = installedVireo(ctx);
|
|
28466
28646
|
if (!app?.browserEngine) return null;
|
|
28467
28647
|
const manifest = app.browserEngine;
|
|
28468
|
-
const
|
|
28469
|
-
const loaded = await WebAssembly.instantiate(
|
|
28648
|
+
const bytes3 = ctx.vfs.readFile(`${app.root}/${manifest.wasm}`, ctx.cred);
|
|
28649
|
+
const loaded = await WebAssembly.instantiate(bytes3, {});
|
|
28470
28650
|
const instance = loaded instanceof WebAssembly.Instance ? loaded : loaded.instance;
|
|
28471
28651
|
const wasm = instance.exports;
|
|
28472
28652
|
for (const name of ["memory", "vireo_alloc", "vireo_load_html", "vireo_snapshot_pointer", "vireo_snapshot_length", "vireo_free_document"]) {
|
|
@@ -28490,11 +28670,11 @@ var VireoEngine = class _VireoEngine {
|
|
|
28490
28670
|
this.wasm.vireo_free_document(handle);
|
|
28491
28671
|
}
|
|
28492
28672
|
}
|
|
28493
|
-
copy(
|
|
28494
|
-
if (!
|
|
28495
|
-
const pointer = this.wasm.vireo_alloc(
|
|
28673
|
+
copy(bytes3) {
|
|
28674
|
+
if (!bytes3.length) return 0;
|
|
28675
|
+
const pointer = this.wasm.vireo_alloc(bytes3.length);
|
|
28496
28676
|
if (!pointer) throw new Error("Vireo ran out of memory");
|
|
28497
|
-
new Uint8Array(this.wasm.memory.buffer, pointer,
|
|
28677
|
+
new Uint8Array(this.wasm.memory.buffer, pointer, bytes3.length).set(bytes3);
|
|
28498
28678
|
return pointer;
|
|
28499
28679
|
}
|
|
28500
28680
|
};
|
|
@@ -28680,8 +28860,8 @@ var SIGNATURE_PATH = "META/signature.json";
|
|
|
28680
28860
|
var TRUSTED_KEYS_PATH = "/etc/pm/trusted-keys.json";
|
|
28681
28861
|
var PackageError = class extends Error {
|
|
28682
28862
|
};
|
|
28683
|
-
async function openPackage(
|
|
28684
|
-
const entries = readZip(
|
|
28863
|
+
async function openPackage(bytes3, trusted) {
|
|
28864
|
+
const entries = readZip(bytes3);
|
|
28685
28865
|
const byName = new Map(entries.map((entry) => [entry.name, entry]));
|
|
28686
28866
|
const manifestEntry = byName.get(MANIFEST_PATH);
|
|
28687
28867
|
if (!manifestEntry) {
|
|
@@ -28724,10 +28904,10 @@ async function openPackage(bytes2, trusted) {
|
|
|
28724
28904
|
const trustedBy = trusted.find((key) => key.publicKey === signature.publicKey) ?? null;
|
|
28725
28905
|
return { manifest, signature, entries, trustedBy };
|
|
28726
28906
|
}
|
|
28727
|
-
function parseManifest(
|
|
28907
|
+
function parseManifest(bytes3) {
|
|
28728
28908
|
let parsed;
|
|
28729
28909
|
try {
|
|
28730
|
-
parsed = JSON.parse(new TextDecoder().decode(
|
|
28910
|
+
parsed = JSON.parse(new TextDecoder().decode(bytes3));
|
|
28731
28911
|
} catch (error) {
|
|
28732
28912
|
throw new PackageError(`${MANIFEST_PATH} is not JSON: ${error.message}`);
|
|
28733
28913
|
}
|
|
@@ -28743,10 +28923,10 @@ function parseManifest(bytes2) {
|
|
|
28743
28923
|
}
|
|
28744
28924
|
return manifest;
|
|
28745
28925
|
}
|
|
28746
|
-
function parseSignature(
|
|
28926
|
+
function parseSignature(bytes3) {
|
|
28747
28927
|
let parsed;
|
|
28748
28928
|
try {
|
|
28749
|
-
parsed = JSON.parse(new TextDecoder().decode(
|
|
28929
|
+
parsed = JSON.parse(new TextDecoder().decode(bytes3));
|
|
28750
28930
|
} catch (error) {
|
|
28751
28931
|
throw new PackageError(`${SIGNATURE_PATH} is not JSON: ${error.message}`);
|
|
28752
28932
|
}
|
|
@@ -28794,16 +28974,16 @@ async function verifySignature(manifestBytes, signature) {
|
|
|
28794
28974
|
intoBuffer(manifestBytes)
|
|
28795
28975
|
);
|
|
28796
28976
|
}
|
|
28797
|
-
function intoBuffer(
|
|
28798
|
-
return
|
|
28977
|
+
function intoBuffer(bytes3) {
|
|
28978
|
+
return bytes3.slice().buffer;
|
|
28799
28979
|
}
|
|
28800
28980
|
function base64ToBytes(text2) {
|
|
28801
28981
|
const binary = atob(text2);
|
|
28802
|
-
const
|
|
28982
|
+
const bytes3 = new Uint8Array(binary.length);
|
|
28803
28983
|
for (let index = 0; index < binary.length; index += 1) {
|
|
28804
|
-
|
|
28984
|
+
bytes3[index] = binary.charCodeAt(index);
|
|
28805
28985
|
}
|
|
28806
|
-
return
|
|
28986
|
+
return bytes3;
|
|
28807
28987
|
}
|
|
28808
28988
|
async function fingerprint(publicKey) {
|
|
28809
28989
|
const digest2 = await digestHex("sha256", base64ToBytes(publicKey));
|
|
@@ -29176,8 +29356,8 @@ function listInstalled2(ctx) {
|
|
|
29176
29356
|
return 0;
|
|
29177
29357
|
}
|
|
29178
29358
|
for (const app of apps.slice().sort((a, b) => a.name.localeCompare(b.name))) {
|
|
29179
|
-
const
|
|
29180
|
-
ctx.line(`${app.name} ${app.version}${
|
|
29359
|
+
const commands13 = app.installedBins.length > 0 ? ` (${app.installedBins.join(", ")})` : "";
|
|
29360
|
+
ctx.line(`${app.name} ${app.version}${commands13}`);
|
|
29181
29361
|
}
|
|
29182
29362
|
return 0;
|
|
29183
29363
|
}
|
|
@@ -29286,6 +29466,7 @@ function allCommands() {
|
|
|
29286
29466
|
...commands9,
|
|
29287
29467
|
...commands10,
|
|
29288
29468
|
...commands11,
|
|
29469
|
+
...commands12,
|
|
29289
29470
|
...nodeCommands(),
|
|
29290
29471
|
...pythonCommands(),
|
|
29291
29472
|
...ffmpegCommands(),
|
|
@@ -29330,8 +29511,8 @@ var ContainerFs = class {
|
|
|
29330
29511
|
return this.kernel.vfs;
|
|
29331
29512
|
}
|
|
29332
29513
|
async readFile(path, encoding) {
|
|
29333
|
-
const
|
|
29334
|
-
return encoding ? new TextDecoder().decode(
|
|
29514
|
+
const bytes3 = this.vfs.readFile(clean(path));
|
|
29515
|
+
return encoding ? new TextDecoder().decode(bytes3) : bytes3;
|
|
29335
29516
|
}
|
|
29336
29517
|
async writeFile(path, data, opts = {}) {
|
|
29337
29518
|
const abs = clean(path);
|
|
@@ -29657,9 +29838,9 @@ var KernelChildProcess = class {
|
|
|
29657
29838
|
this.exitCode = code;
|
|
29658
29839
|
this.emit("exit", code);
|
|
29659
29840
|
}
|
|
29660
|
-
append(stream, text2) {
|
|
29841
|
+
append(stream, value, text2 = typeof value === "string" ? value : new TextDecoder().decode(value)) {
|
|
29661
29842
|
this[stream] += text2;
|
|
29662
|
-
this.emit(stream,
|
|
29843
|
+
this.emit(stream, value);
|
|
29663
29844
|
}
|
|
29664
29845
|
};
|
|
29665
29846
|
var ChildOutput = class {
|
|
@@ -29678,7 +29859,7 @@ var ChildOutput = class {
|
|
|
29678
29859
|
write(data) {
|
|
29679
29860
|
if (this.closedState) return;
|
|
29680
29861
|
const text2 = typeof data === "string" ? data : this.decoder.decode(data, { stream: true });
|
|
29681
|
-
if (text2) this.child.append(this.stream, text2);
|
|
29862
|
+
if (text2 || data instanceof Uint8Array) this.child.append(this.stream, data, text2);
|
|
29682
29863
|
}
|
|
29683
29864
|
end() {
|
|
29684
29865
|
if (this.closedState) return;
|
|
@@ -30179,6 +30360,13 @@ var CommonJsEngine = class {
|
|
|
30179
30360
|
}
|
|
30180
30361
|
evaluate(module, source) {
|
|
30181
30362
|
if (source.startsWith("#!")) source = source.replace(/^#![^\n]*(?:\n|$)/, "");
|
|
30363
|
+
if (isTypeScript(module.filename)) {
|
|
30364
|
+
source = sucrase.transform(source, {
|
|
30365
|
+
transforms: module.filename.endsWith(".tsx") ? ["typescript", "jsx"] : ["typescript"],
|
|
30366
|
+
filePath: module.filename,
|
|
30367
|
+
production: true
|
|
30368
|
+
}).code;
|
|
30369
|
+
}
|
|
30182
30370
|
const transformed = transformEsm(source, module.filename);
|
|
30183
30371
|
const esmBody = transformed?.code ?? source;
|
|
30184
30372
|
const body = transformAsyncContext(esmBody, module.filename) ?? esmBody;
|
|
@@ -30441,6 +30629,9 @@ Require stack:
|
|
|
30441
30629
|
return error;
|
|
30442
30630
|
}
|
|
30443
30631
|
};
|
|
30632
|
+
function isTypeScript(filename) {
|
|
30633
|
+
return filename.endsWith(".ts") || filename.endsWith(".tsx");
|
|
30634
|
+
}
|
|
30444
30635
|
var namespaces = /* @__PURE__ */ new WeakMap();
|
|
30445
30636
|
function namespaceOf(exports) {
|
|
30446
30637
|
if (exports === null || typeof exports !== "object" && typeof exports !== "function") {
|
|
@@ -31726,13 +31917,13 @@ var Z_NO_FLUSH = 0;
|
|
|
31726
31917
|
var Z_SYNC_FLUSH = 2;
|
|
31727
31918
|
var Z_FULL_FLUSH = 3;
|
|
31728
31919
|
var Z_FINISH = 4;
|
|
31729
|
-
var
|
|
31920
|
+
var bytes2 = (data) => {
|
|
31730
31921
|
if (typeof data === "string") return new Uint8Array(Buffer2.from(data, "utf8"));
|
|
31731
31922
|
if (data instanceof ArrayBuffer) return new Uint8Array(data);
|
|
31732
31923
|
return data;
|
|
31733
31924
|
};
|
|
31734
31925
|
function codec(run3) {
|
|
31735
|
-
const sync2 = (data, options) => Buffer2.from(run3(
|
|
31926
|
+
const sync2 = (data, options) => Buffer2.from(run3(bytes2(data), options));
|
|
31736
31927
|
const async_ = (data, options, callback) => {
|
|
31737
31928
|
const done = typeof options === "function" ? options : callback;
|
|
31738
31929
|
const settings = typeof options === "function" ? void 0 : options;
|
|
@@ -32082,6 +32273,8 @@ var VirtualServerResponse = class extends streamModule5__default.default.Writabl
|
|
|
32082
32273
|
completed;
|
|
32083
32274
|
constructor(request) {
|
|
32084
32275
|
super();
|
|
32276
|
+
this.on("error", () => {
|
|
32277
|
+
});
|
|
32085
32278
|
this.req = request;
|
|
32086
32279
|
this.completed = new Promise((resolve3) => {
|
|
32087
32280
|
this.resolve = resolve3;
|
|
@@ -32211,9 +32404,9 @@ var VirtualSocket = class extends streamModule5__default.default.Duplex {
|
|
|
32211
32404
|
_read() {
|
|
32212
32405
|
}
|
|
32213
32406
|
_write(chunk, encoding, callback) {
|
|
32214
|
-
const
|
|
32407
|
+
const bytes3 = Buffer2.isBuffer(chunk) ? chunk : Buffer2.from(chunk, encoding);
|
|
32215
32408
|
try {
|
|
32216
|
-
this.peer?.data(new Uint8Array(
|
|
32409
|
+
this.peer?.data(new Uint8Array(bytes3));
|
|
32217
32410
|
callback();
|
|
32218
32411
|
} catch (error) {
|
|
32219
32412
|
callback(error);
|
|
@@ -32237,9 +32430,9 @@ var VirtualSocket = class extends streamModule5__default.default.Duplex {
|
|
|
32237
32430
|
this.peer = null;
|
|
32238
32431
|
}
|
|
32239
32432
|
/** Bytes arriving from the far end. */
|
|
32240
|
-
deliver(
|
|
32433
|
+
deliver(bytes3) {
|
|
32241
32434
|
if (this.destroyed || this.hungUp) return;
|
|
32242
|
-
this.push(Buffer2.from(
|
|
32435
|
+
this.push(Buffer2.from(bytes3));
|
|
32243
32436
|
}
|
|
32244
32437
|
/** The far end went away; let the server's stream end cleanly. */
|
|
32245
32438
|
peerClosed() {
|
|
@@ -32394,7 +32587,7 @@ var VirtualHttpRouter = class {
|
|
|
32394
32587
|
request.socket = socket;
|
|
32395
32588
|
item.server.emit("upgrade", request, socket, Buffer2.alloc(0));
|
|
32396
32589
|
return {
|
|
32397
|
-
send: (
|
|
32590
|
+
send: (bytes3) => socket.deliver(bytes3),
|
|
32398
32591
|
close: () => socket.peerClosed()
|
|
32399
32592
|
};
|
|
32400
32593
|
}
|
|
@@ -32620,9 +32813,9 @@ var VirtualClientRequest = class extends streamModule5__default.default.Writable
|
|
|
32620
32813
|
}
|
|
32621
32814
|
const result = remote ?? await this.router.request(this.target.port, init);
|
|
32622
32815
|
const body_ = result.body;
|
|
32623
|
-
const
|
|
32816
|
+
const bytes3 = typeof body_ === "string" ? new TextEncoder().encode(body_) : body_ instanceof ArrayBuffer ? new Uint8Array(body_) : body_ ?? new Uint8Array();
|
|
32624
32817
|
const status = result.statusCode ?? 200;
|
|
32625
|
-
return new VirtualClientResponse(status, result.statusMessage ?? STATUS_CODES[status] ?? "", lowercaseHeaders(result.headers),
|
|
32818
|
+
return new VirtualClientResponse(status, result.statusMessage ?? STATUS_CODES[status] ?? "", lowercaseHeaders(result.headers), bytes3);
|
|
32626
32819
|
}
|
|
32627
32820
|
async viaFetch(body) {
|
|
32628
32821
|
const fetchImpl = this.fetchImpl ?? globalThis.fetch;
|
|
@@ -32646,8 +32839,8 @@ var VirtualClientRequest = class extends streamModule5__default.default.Writable
|
|
|
32646
32839
|
response.headers.forEach((value, key) => {
|
|
32647
32840
|
received[key.toLowerCase()] = value;
|
|
32648
32841
|
});
|
|
32649
|
-
const
|
|
32650
|
-
return new VirtualClientResponse(response.status, response.statusText, received,
|
|
32842
|
+
const bytes3 = new Uint8Array(await response.arrayBuffer());
|
|
32843
|
+
return new VirtualClientResponse(response.status, response.statusText, received, bytes3);
|
|
32651
32844
|
}
|
|
32652
32845
|
};
|
|
32653
32846
|
function lowercaseHeaders(headers) {
|
|
@@ -32739,9 +32932,9 @@ function createVirtualFetch(router, options = {}) {
|
|
|
32739
32932
|
for (const part of Array.isArray(value) ? value : [value]) responseHeaders.append(name, String(part));
|
|
32740
32933
|
}
|
|
32741
32934
|
const raw = result.body;
|
|
32742
|
-
const
|
|
32935
|
+
const bytes3 = typeof raw === "string" ? new TextEncoder().encode(raw) : raw instanceof ArrayBuffer ? new Uint8Array(raw) : raw ?? new Uint8Array();
|
|
32743
32936
|
const nullBody = status === 204 || status === 205 || status === 304 || request.method === "HEAD";
|
|
32744
|
-
return new Response(nullBody ? null : new Uint8Array(
|
|
32937
|
+
return new Response(nullBody ? null : new Uint8Array(bytes3), {
|
|
32745
32938
|
status,
|
|
32746
32939
|
statusText: result.statusMessage ?? STATUS_CODES[status] ?? "",
|
|
32747
32940
|
headers: responseHeaders
|
|
@@ -32987,7 +33180,7 @@ function createTestModule(host2) {
|
|
|
32987
33180
|
});
|
|
32988
33181
|
};
|
|
32989
33182
|
const hasOnly = (node2) => Boolean(node2.options.only) || node2.kind === "suite" && node2.children.some(hasOnly);
|
|
32990
|
-
const
|
|
33183
|
+
const report2 = (depth, outcome, name, started, detail) => {
|
|
32991
33184
|
if (tap()) {
|
|
32992
33185
|
tapIndex += 1;
|
|
32993
33186
|
const ok2 = outcome === "fail" ? "not ok" : "ok";
|
|
@@ -33034,13 +33227,13 @@ ${indent(detail, 4)}
|
|
|
33034
33227
|
if (runOnly && !options.only) return true;
|
|
33035
33228
|
if (options.skip) {
|
|
33036
33229
|
record2("skip", display);
|
|
33037
|
-
|
|
33230
|
+
report2(depth, "skip", name, started);
|
|
33038
33231
|
return true;
|
|
33039
33232
|
}
|
|
33040
33233
|
if (!fn) {
|
|
33041
33234
|
const outcome = options.todo ? "todo" : "skip";
|
|
33042
33235
|
record2(outcome, display);
|
|
33043
|
-
|
|
33236
|
+
report2(depth, outcome, name, started);
|
|
33044
33237
|
return true;
|
|
33045
33238
|
}
|
|
33046
33239
|
const controller = new AbortController();
|
|
@@ -33104,21 +33297,21 @@ ${indent(detail, 4)}
|
|
|
33104
33297
|
}
|
|
33105
33298
|
if (skipped) {
|
|
33106
33299
|
record2("skip", display);
|
|
33107
|
-
|
|
33300
|
+
report2(depth, "skip", name, started);
|
|
33108
33301
|
return true;
|
|
33109
33302
|
}
|
|
33110
33303
|
if (error !== void 0) {
|
|
33111
33304
|
if (todo) {
|
|
33112
33305
|
record2("todo", display);
|
|
33113
|
-
|
|
33306
|
+
report2(depth, "todo", name, started);
|
|
33114
33307
|
return true;
|
|
33115
33308
|
}
|
|
33116
33309
|
record2("fail", display, error);
|
|
33117
|
-
|
|
33310
|
+
report2(depth, "fail", name, started, errorText(error));
|
|
33118
33311
|
return false;
|
|
33119
33312
|
}
|
|
33120
33313
|
record2(todo ? "todo" : "pass", display);
|
|
33121
|
-
|
|
33314
|
+
report2(depth, todo ? "todo" : "pass", name, started);
|
|
33122
33315
|
return true;
|
|
33123
33316
|
};
|
|
33124
33317
|
const runSuite = async (suite, depth, runOnly) => {
|
|
@@ -33133,7 +33326,7 @@ ${indent(detail, 4)}
|
|
|
33133
33326
|
`);
|
|
33134
33327
|
if (suite.options.skip) {
|
|
33135
33328
|
for (const child of suite.children) if (child.kind === "test") record2("skip", fullName(child));
|
|
33136
|
-
|
|
33329
|
+
report2(depth, "skip", suite.name, started);
|
|
33137
33330
|
return true;
|
|
33138
33331
|
}
|
|
33139
33332
|
}
|
|
@@ -33145,10 +33338,10 @@ ${indent(detail, 4)}
|
|
|
33145
33338
|
for (const child of suite.children) {
|
|
33146
33339
|
if (child.kind === "test") {
|
|
33147
33340
|
record2("cancelled", fullName(child), error);
|
|
33148
|
-
|
|
33341
|
+
report2(depth + (isRoot ? 0 : 1), "cancelled", child.name, started, errorText(error));
|
|
33149
33342
|
}
|
|
33150
33343
|
}
|
|
33151
|
-
if (!isRoot)
|
|
33344
|
+
if (!isRoot) report2(depth, "fail", suite.name, started);
|
|
33152
33345
|
return false;
|
|
33153
33346
|
}
|
|
33154
33347
|
const only = runOnly || settings().only === true && suite.children.some(hasOnly);
|
|
@@ -33528,7 +33721,7 @@ var ChildProcess = class extends EventEmitter4__default.default {
|
|
|
33528
33721
|
this.stdin = new streamModule5__default.default.Writable({
|
|
33529
33722
|
write: (chunk, _encoding, done) => {
|
|
33530
33723
|
try {
|
|
33531
|
-
handle.sendStdin(typeof chunk === "string" ? chunk :
|
|
33724
|
+
handle.sendStdin(typeof chunk === "string" ? chunk : new Uint8Array(chunk));
|
|
33532
33725
|
} catch {
|
|
33533
33726
|
}
|
|
33534
33727
|
done();
|
|
@@ -33547,8 +33740,8 @@ var ChildProcess = class extends EventEmitter4__default.default {
|
|
|
33547
33740
|
const pipe = this.stdio[event.fd];
|
|
33548
33741
|
pipe?.push(Buffer2.from(event.text));
|
|
33549
33742
|
});
|
|
33550
|
-
handle.on("stdout", (
|
|
33551
|
-
handle.on("stderr", (
|
|
33743
|
+
handle.on("stdout", (value) => this.stdout.write(typeof value === "string" ? value : Buffer2.from(value)));
|
|
33744
|
+
handle.on("stderr", (value) => this.stderr.write(typeof value === "string" ? value : Buffer2.from(value)));
|
|
33552
33745
|
handle.on("exit", (code) => this.finish(code));
|
|
33553
33746
|
referenceChanged(1);
|
|
33554
33747
|
try {
|
|
@@ -34535,7 +34728,7 @@ function createCoreModules(options) {
|
|
|
34535
34728
|
});
|
|
34536
34729
|
processObject.stdin = stdin;
|
|
34537
34730
|
Reflect.deleteProperty(processObject, "browser");
|
|
34538
|
-
const fs = createFsModule(volume, () => cwd, options.stdinPath, defer);
|
|
34731
|
+
const fs = createFsModule(volume, () => cwd, options.stdinPath, defer, stdin);
|
|
34539
34732
|
processObject.loadEnvFile = (path2 = ".env") => {
|
|
34540
34733
|
const parsed = parseEnv(fs.readFileSync(path2, "utf8"));
|
|
34541
34734
|
for (const [key, value] of Object.entries(parsed)) {
|
|
@@ -34907,7 +35100,7 @@ function createPathModule(cwd) {
|
|
|
34907
35100
|
path.default = path;
|
|
34908
35101
|
return path;
|
|
34909
35102
|
}
|
|
34910
|
-
function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
35103
|
+
function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask, stdin) {
|
|
34911
35104
|
const fds = /* @__PURE__ */ new Map();
|
|
34912
35105
|
let nextFd = 3;
|
|
34913
35106
|
if (stdinPath) fds.set(0, { path: stdinPath, position: 0, flags: "r" });
|
|
@@ -34918,7 +35111,7 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
34918
35111
|
if (typeof value !== "string") throw new TypeError("path must be a string, Buffer, or URL");
|
|
34919
35112
|
return value.startsWith("/") ? clean(value) : resolve(cwd(), value);
|
|
34920
35113
|
};
|
|
34921
|
-
const
|
|
35114
|
+
const bytes3 = (data, encoding) => {
|
|
34922
35115
|
if (typeof data === "string") return new Uint8Array(Buffer2.from(data, encoding));
|
|
34923
35116
|
if (Buffer2.isBuffer(data) || data instanceof Uint8Array) return new Uint8Array(data);
|
|
34924
35117
|
if (data instanceof ArrayBuffer) return new Uint8Array(data);
|
|
@@ -34980,12 +35173,12 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
34980
35173
|
readFileSync: (path, options) => read(path, typeof options === "object" && options ? options.encoding : options),
|
|
34981
35174
|
writeFileSync: (path, data, options) => {
|
|
34982
35175
|
const encoding = typeof options === "object" && options ? options.encoding : options === "buffer" ? void 0 : options ?? void 0;
|
|
34983
|
-
volume.writeFileSync(abs(path),
|
|
35176
|
+
volume.writeFileSync(abs(path), bytes3(data, encoding ?? void 0));
|
|
34984
35177
|
if (typeof options === "object" && options?.mode !== void 0) volume.chmodSync(abs(path), options.mode);
|
|
34985
35178
|
},
|
|
34986
35179
|
appendFileSync: (path, data, options) => {
|
|
34987
35180
|
const encoding = typeof options === "object" && options ? options.encoding : options === "buffer" ? void 0 : options ?? void 0;
|
|
34988
|
-
volume.appendFileSync(abs(path),
|
|
35181
|
+
volume.appendFileSync(abs(path), bytes3(data, encoding ?? void 0));
|
|
34989
35182
|
},
|
|
34990
35183
|
existsSync: (path) => {
|
|
34991
35184
|
try {
|
|
@@ -35076,7 +35269,7 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
35076
35269
|
offset = 0;
|
|
35077
35270
|
length = data.length;
|
|
35078
35271
|
}
|
|
35079
|
-
const input =
|
|
35272
|
+
const input = bytes3(data);
|
|
35080
35273
|
const chunk = input.subarray(offset ?? 0, (offset ?? 0) + (length ?? input.length));
|
|
35081
35274
|
const size = volume.lstatSync(file3.path).size;
|
|
35082
35275
|
const append = file3.flags.startsWith("a") || (position ?? file3.position) >= size;
|
|
@@ -35201,9 +35394,9 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
35201
35394
|
const self = this;
|
|
35202
35395
|
const append = () => {
|
|
35203
35396
|
try {
|
|
35204
|
-
const
|
|
35205
|
-
volume.appendFileSync(self.path, new Uint8Array(
|
|
35206
|
-
self.bytesWritten +=
|
|
35397
|
+
const bytes4 = typeof chunk === "string" ? Buffer2.from(chunk, encoding) : chunk;
|
|
35398
|
+
volume.appendFileSync(self.path, new Uint8Array(bytes4));
|
|
35399
|
+
self.bytesWritten += bytes4.length;
|
|
35207
35400
|
done();
|
|
35208
35401
|
} catch (error) {
|
|
35209
35402
|
done(error);
|
|
@@ -35404,6 +35597,57 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
35404
35597
|
({ offset, length, position } = options);
|
|
35405
35598
|
}
|
|
35406
35599
|
const start2 = offset ?? 0;
|
|
35600
|
+
if (fd === 0 && stdin) {
|
|
35601
|
+
const requested = length ?? buffer.byteLength - start2;
|
|
35602
|
+
const finish = (chunk) => {
|
|
35603
|
+
const source = Buffer2.isBuffer(chunk) ? chunk : Buffer2.from(chunk);
|
|
35604
|
+
const count = Math.min(requested, source.byteLength);
|
|
35605
|
+
buffer.set(source.subarray(0, count), start2);
|
|
35606
|
+
if (count < source.byteLength && typeof stdin.unshift === "function") {
|
|
35607
|
+
stdin.unshift(source.subarray(count));
|
|
35608
|
+
}
|
|
35609
|
+
cb(null, count, buffer);
|
|
35610
|
+
};
|
|
35611
|
+
const available2 = stdin.read();
|
|
35612
|
+
if (available2 !== null) {
|
|
35613
|
+
defer(() => finish(available2));
|
|
35614
|
+
return;
|
|
35615
|
+
}
|
|
35616
|
+
if (stdin.readableEnded || stdin.destroyed) {
|
|
35617
|
+
defer(() => cb(null, 0, buffer));
|
|
35618
|
+
return;
|
|
35619
|
+
}
|
|
35620
|
+
let settled = false;
|
|
35621
|
+
const cleanup = () => {
|
|
35622
|
+
stdin.removeListener("readable", onReadable);
|
|
35623
|
+
stdin.removeListener("end", onEnd);
|
|
35624
|
+
stdin.removeListener("error", onError);
|
|
35625
|
+
};
|
|
35626
|
+
const onReadable = () => {
|
|
35627
|
+
if (settled) return;
|
|
35628
|
+
const chunk = stdin.read();
|
|
35629
|
+
if (chunk === null) return;
|
|
35630
|
+
settled = true;
|
|
35631
|
+
cleanup();
|
|
35632
|
+
finish(chunk);
|
|
35633
|
+
};
|
|
35634
|
+
const onEnd = () => {
|
|
35635
|
+
if (settled) return;
|
|
35636
|
+
settled = true;
|
|
35637
|
+
cleanup();
|
|
35638
|
+
cb(null, 0, buffer);
|
|
35639
|
+
};
|
|
35640
|
+
const onError = (error) => {
|
|
35641
|
+
if (settled) return;
|
|
35642
|
+
settled = true;
|
|
35643
|
+
cleanup();
|
|
35644
|
+
cb(error);
|
|
35645
|
+
};
|
|
35646
|
+
stdin.on("readable", onReadable);
|
|
35647
|
+
stdin.once("end", onEnd);
|
|
35648
|
+
stdin.once("error", onError);
|
|
35649
|
+
return;
|
|
35650
|
+
}
|
|
35407
35651
|
runThenCall(() => [fs.readSync(fd, buffer, start2, length ?? buffer.byteLength - start2, position ?? null), buffer], cb);
|
|
35408
35652
|
};
|
|
35409
35653
|
fs.write = (fd, data, ...rest) => {
|
|
@@ -35495,8 +35739,8 @@ function createBufferBuiltin() {
|
|
|
35495
35739
|
}
|
|
35496
35740
|
},
|
|
35497
35741
|
isAscii: (input) => {
|
|
35498
|
-
const
|
|
35499
|
-
for (const byte of
|
|
35742
|
+
const bytes3 = input instanceof ArrayBuffer ? new Uint8Array(input) : new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
35743
|
+
for (const byte of bytes3) if (byte > 127) return false;
|
|
35500
35744
|
return true;
|
|
35501
35745
|
}
|
|
35502
35746
|
};
|
|
@@ -36135,37 +36379,37 @@ var MemoryVolume = class {
|
|
|
36135
36379
|
writeFileSync(path, data) {
|
|
36136
36380
|
const key = this.key(path);
|
|
36137
36381
|
this.requireParent(key, "open");
|
|
36138
|
-
const
|
|
36382
|
+
const bytes3 = typeof data === "string" ? encoder7.encode(data) : data.slice();
|
|
36139
36383
|
const current2 = this.entries.get(key);
|
|
36140
36384
|
if (current2?.kind === "directory") throw new VolumeError("EISDIR", "open", key);
|
|
36141
36385
|
if (current2?.kind === "symlink") throw new VolumeError("EINVAL", "open", key);
|
|
36142
36386
|
if (current2) {
|
|
36143
|
-
current2.data =
|
|
36387
|
+
current2.data = bytes3;
|
|
36144
36388
|
this.touchChanged(current2, true);
|
|
36145
36389
|
} else {
|
|
36146
|
-
this.entries.set(key, this.inode("file", 438,
|
|
36390
|
+
this.entries.set(key, this.inode("file", 438, bytes3));
|
|
36147
36391
|
}
|
|
36148
36392
|
}
|
|
36149
36393
|
appendFileSync(path, data) {
|
|
36150
36394
|
const key = this.key(path);
|
|
36151
|
-
const
|
|
36395
|
+
const bytes3 = typeof data === "string" ? encoder7.encode(data) : data;
|
|
36152
36396
|
const current2 = this.entries.get(key);
|
|
36153
|
-
if (!current2) return this.writeFileSync(key,
|
|
36397
|
+
if (!current2) return this.writeFileSync(key, bytes3);
|
|
36154
36398
|
if (current2.kind !== "file") throw new VolumeError(current2.kind === "directory" ? "EISDIR" : "EINVAL", "open", key);
|
|
36155
36399
|
const length = current2.data.length;
|
|
36156
|
-
const needed = length +
|
|
36400
|
+
const needed = length + bytes3.length;
|
|
36157
36401
|
const backing = current2.data.buffer;
|
|
36158
36402
|
const ownsTail = current2.data.byteOffset === 0 && backing instanceof ArrayBuffer && backing.byteLength >= needed && appendCapacity.get(current2) === backing;
|
|
36159
36403
|
if (ownsTail) {
|
|
36160
36404
|
const grown = new Uint8Array(backing, 0, needed);
|
|
36161
|
-
grown.set(
|
|
36405
|
+
grown.set(bytes3, length);
|
|
36162
36406
|
current2.data = grown;
|
|
36163
36407
|
} else {
|
|
36164
36408
|
const capacity = Math.max(needed, length * 2, 64 * 1024);
|
|
36165
36409
|
const buffer = new ArrayBuffer(capacity);
|
|
36166
36410
|
const grown = new Uint8Array(buffer, 0, needed);
|
|
36167
36411
|
grown.set(current2.data);
|
|
36168
|
-
grown.set(
|
|
36412
|
+
grown.set(bytes3, length);
|
|
36169
36413
|
current2.data = grown;
|
|
36170
36414
|
appendCapacity.set(current2, buffer);
|
|
36171
36415
|
}
|
|
@@ -36738,9 +36982,9 @@ var MirroringVolume = class {
|
|
|
36738
36982
|
} catch {
|
|
36739
36983
|
}
|
|
36740
36984
|
try {
|
|
36741
|
-
const
|
|
36985
|
+
const bytes3 = mirror.readFileSync(source);
|
|
36742
36986
|
this.ensureDirectory(dirname(destination));
|
|
36743
|
-
this.inner.writeFileSync(destination,
|
|
36987
|
+
this.inner.writeFileSync(destination, bytes3);
|
|
36744
36988
|
} catch {
|
|
36745
36989
|
}
|
|
36746
36990
|
};
|
|
@@ -37122,9 +37366,9 @@ var OutboundTcp = class {
|
|
|
37122
37366
|
const bridge = new VirtualTcpConnection({ address, port }, { address: local.address, port: local.port });
|
|
37123
37367
|
guest.pairWith(bridge);
|
|
37124
37368
|
bridge.pairWith(guest);
|
|
37125
|
-
host2.onData((
|
|
37369
|
+
host2.onData((bytes3) => {
|
|
37126
37370
|
try {
|
|
37127
|
-
bridge.write(
|
|
37371
|
+
bridge.write(bytes3);
|
|
37128
37372
|
} catch {
|
|
37129
37373
|
host2.close();
|
|
37130
37374
|
}
|
|
@@ -37179,9 +37423,9 @@ function createNodeTcpDialer() {
|
|
|
37179
37423
|
let onClose = null;
|
|
37180
37424
|
let closed = false;
|
|
37181
37425
|
socket.on("data", (chunk) => {
|
|
37182
|
-
const
|
|
37183
|
-
if (onData) onData(
|
|
37184
|
-
else pending.push(
|
|
37426
|
+
const bytes3 = new Uint8Array(chunk);
|
|
37427
|
+
if (onData) onData(bytes3);
|
|
37428
|
+
else pending.push(bytes3);
|
|
37185
37429
|
});
|
|
37186
37430
|
const finish = () => {
|
|
37187
37431
|
if (closed) return;
|
|
@@ -37200,8 +37444,8 @@ function createNodeTcpDialer() {
|
|
|
37200
37444
|
socket.on("connect", () => {
|
|
37201
37445
|
socket.setNoDelay(true);
|
|
37202
37446
|
resolve3({
|
|
37203
|
-
write(
|
|
37204
|
-
socket.write(
|
|
37447
|
+
write(bytes3) {
|
|
37448
|
+
socket.write(bytes3);
|
|
37205
37449
|
},
|
|
37206
37450
|
end() {
|
|
37207
37451
|
socket.end();
|
|
@@ -37253,8 +37497,7 @@ function translate(error, host2, port) {
|
|
|
37253
37497
|
|
|
37254
37498
|
// src/worker/local-runtime-pod.ts
|
|
37255
37499
|
var WASM_ALIASES = {
|
|
37256
|
-
|
|
37257
|
-
rollup: "@rollup/wasm-node"
|
|
37500
|
+
...RUNTIME_PACKAGE_FALLBACKS
|
|
37258
37501
|
};
|
|
37259
37502
|
var ProcessExit = class extends Error {
|
|
37260
37503
|
constructor(code) {
|
|
@@ -37414,7 +37657,7 @@ var PodChildProcess = class {
|
|
|
37414
37657
|
/* The child is launched asynchronously, but a parent may write and close
|
|
37415
37658
|
* its input synchronously right after spawning. Holding both until the
|
|
37416
37659
|
* child exists is what keeps `echo hi | child` from losing the `hi`. */
|
|
37417
|
-
pendingInput =
|
|
37660
|
+
pendingInput = [];
|
|
37418
37661
|
inputEnded = false;
|
|
37419
37662
|
on(event, listener) {
|
|
37420
37663
|
let set = this.listeners.get(event);
|
|
@@ -37438,15 +37681,13 @@ var PodChildProcess = class {
|
|
|
37438
37681
|
(child) => {
|
|
37439
37682
|
this.child = child;
|
|
37440
37683
|
if (this.cancelled) child.kill();
|
|
37441
|
-
|
|
37442
|
-
child.write(this.pendingInput);
|
|
37443
|
-
this.pendingInput = "";
|
|
37444
|
-
}
|
|
37684
|
+
for (const chunk of this.pendingInput.splice(0)) child.write(chunk);
|
|
37445
37685
|
if (this.inputEnded) child.endInput?.();
|
|
37446
|
-
child.
|
|
37686
|
+
const outputEvent = child.rawOutput ? "raw-output" : "output";
|
|
37687
|
+
child.on(outputEvent, (chunk) => {
|
|
37447
37688
|
const text2 = typeof chunk === "string" ? chunk : this.outText.decode(chunk, { stream: true });
|
|
37448
37689
|
this.stdout += text2;
|
|
37449
|
-
this.emit("stdout",
|
|
37690
|
+
this.emit("stdout", chunk);
|
|
37450
37691
|
});
|
|
37451
37692
|
child.on("error", (chunk) => {
|
|
37452
37693
|
const text2 = typeof chunk === "string" ? chunk : this.errText.decode(chunk, { stream: true });
|
|
@@ -37468,7 +37709,7 @@ var PodChildProcess = class {
|
|
|
37468
37709
|
}
|
|
37469
37710
|
sendStdin(data) {
|
|
37470
37711
|
if (this.child) this.child.write(data);
|
|
37471
|
-
else this.pendingInput
|
|
37712
|
+
else this.pendingInput.push(data);
|
|
37472
37713
|
}
|
|
37473
37714
|
/** Signal EOF, so a child reading stdin to the end can finish. */
|
|
37474
37715
|
endStdin() {
|
|
@@ -37828,14 +38069,14 @@ ${headers.join("\r\n")}\r
|
|
|
37828
38069
|
`);
|
|
37829
38070
|
connection.write(request);
|
|
37830
38071
|
if (body.length) connection.write(body);
|
|
37831
|
-
const
|
|
38072
|
+
const bytes3 = [];
|
|
37832
38073
|
let combined = new Uint8Array();
|
|
37833
38074
|
for (; ; ) {
|
|
37834
38075
|
try {
|
|
37835
38076
|
const chunk = connection.read(64 * 1024);
|
|
37836
38077
|
if (chunk.length === 0) break;
|
|
37837
|
-
|
|
37838
|
-
combined = joinBytes(
|
|
38078
|
+
bytes3.push(chunk);
|
|
38079
|
+
combined = joinBytes(bytes3);
|
|
37839
38080
|
const headerEnd = findBytes(combined, new Uint8Array([13, 10, 13, 10]));
|
|
37840
38081
|
if (headerEnd < 0) continue;
|
|
37841
38082
|
const headerText = new TextDecoder().decode(combined.subarray(0, headerEnd));
|
|
@@ -37901,11 +38142,11 @@ function findBytes(haystack, needle) {
|
|
|
37901
38142
|
}
|
|
37902
38143
|
return -1;
|
|
37903
38144
|
}
|
|
37904
|
-
function parseHttpResponse(
|
|
38145
|
+
function parseHttpResponse(bytes3) {
|
|
37905
38146
|
const marker = new Uint8Array([13, 10, 13, 10]);
|
|
37906
|
-
const headerEnd = findBytes(
|
|
38147
|
+
const headerEnd = findBytes(bytes3, marker);
|
|
37907
38148
|
if (headerEnd < 0) throw new Error("Python server returned an incomplete HTTP response");
|
|
37908
|
-
const text2 = new TextDecoder().decode(
|
|
38149
|
+
const text2 = new TextDecoder().decode(bytes3.subarray(0, headerEnd));
|
|
37909
38150
|
const lines = text2.split("\r\n");
|
|
37910
38151
|
const status = /HTTP\/\d\.\d\s+(\d+)(?:\s+(.*))?/.exec(lines.shift() ?? "");
|
|
37911
38152
|
if (!status) throw new Error("Python server returned an invalid HTTP status line");
|
|
@@ -37914,7 +38155,7 @@ function parseHttpResponse(bytes2) {
|
|
|
37914
38155
|
const separator = line.indexOf(":");
|
|
37915
38156
|
if (separator > 0) headers[line.slice(0, separator).toLowerCase()] = line.slice(separator + 1).trim();
|
|
37916
38157
|
}
|
|
37917
|
-
let body =
|
|
38158
|
+
let body = bytes3.slice(headerEnd + marker.length);
|
|
37918
38159
|
if (CHUNKED.test(headers["transfer-encoding"] ?? "")) {
|
|
37919
38160
|
body = decodeChunked(body).body;
|
|
37920
38161
|
delete headers["transfer-encoding"];
|
|
@@ -37928,19 +38169,19 @@ function parseHttpResponse(bytes2) {
|
|
|
37928
38169
|
};
|
|
37929
38170
|
}
|
|
37930
38171
|
var CHUNKED = /^(?:transfer-encoding:.*)?\bchunked\b/im;
|
|
37931
|
-
function decodeChunked(
|
|
38172
|
+
function decodeChunked(bytes3) {
|
|
37932
38173
|
const parts = [];
|
|
37933
38174
|
const crlf = new Uint8Array([13, 10]);
|
|
37934
38175
|
for (let at = 0; ; ) {
|
|
37935
|
-
const lineEnd = findBytes(
|
|
38176
|
+
const lineEnd = findBytes(bytes3.subarray(at), crlf);
|
|
37936
38177
|
if (lineEnd < 0) return { body: joinBytes(parts), complete: false };
|
|
37937
|
-
const header = new TextDecoder().decode(
|
|
38178
|
+
const header = new TextDecoder().decode(bytes3.subarray(at, at + lineEnd)).split(";")[0].trim();
|
|
37938
38179
|
const size = /^[0-9a-f]+$/i.test(header) ? Number.parseInt(header, 16) : Number.NaN;
|
|
37939
38180
|
if (!Number.isInteger(size)) throw new Error("Python server returned an invalid chunked response");
|
|
37940
38181
|
at += lineEnd + crlf.length;
|
|
37941
38182
|
if (size === 0) return { body: joinBytes(parts), complete: true };
|
|
37942
|
-
if (at + size + crlf.length >
|
|
37943
|
-
parts.push(
|
|
38183
|
+
if (at + size + crlf.length > bytes3.length) return { body: joinBytes(parts), complete: false };
|
|
38184
|
+
parts.push(bytes3.subarray(at, at + size));
|
|
37944
38185
|
at += size + crlf.length;
|
|
37945
38186
|
}
|
|
37946
38187
|
}
|
|
@@ -38123,7 +38364,7 @@ var WorkerProcess = class extends EventEmitter4__default.default {
|
|
|
38123
38364
|
*/
|
|
38124
38365
|
write(data) {
|
|
38125
38366
|
if (this.inheritedInput) {
|
|
38126
|
-
this.inheritedInput.sendStdin(
|
|
38367
|
+
this.inheritedInput.sendStdin(data);
|
|
38127
38368
|
return;
|
|
38128
38369
|
}
|
|
38129
38370
|
if (this.started) this.worker.postMessage({ type: "stdin", data });
|
|
@@ -38287,7 +38528,9 @@ var WorkerRuntimePod = class _WorkerRuntimePod extends LocalRuntimePod {
|
|
|
38287
38528
|
this.startChild(worker, children, message, ownedChildren);
|
|
38288
38529
|
return;
|
|
38289
38530
|
case "child-stdin":
|
|
38290
|
-
children.get(message.id)?.sendStdin?.(
|
|
38531
|
+
children.get(message.id)?.sendStdin?.(
|
|
38532
|
+
message.data instanceof Uint8Array ? message.data : String(message.data)
|
|
38533
|
+
);
|
|
38291
38534
|
return;
|
|
38292
38535
|
case "child-stdin-end":
|
|
38293
38536
|
children.get(message.id)?.endStdin?.();
|
|
@@ -38329,20 +38572,22 @@ var WorkerRuntimePod = class _WorkerRuntimePod extends LocalRuntimePod {
|
|
|
38329
38572
|
return;
|
|
38330
38573
|
}
|
|
38331
38574
|
});
|
|
38332
|
-
|
|
38333
|
-
|
|
38334
|
-
|
|
38335
|
-
|
|
38336
|
-
|
|
38337
|
-
|
|
38338
|
-
|
|
38339
|
-
|
|
38340
|
-
|
|
38341
|
-
|
|
38342
|
-
|
|
38343
|
-
|
|
38344
|
-
|
|
38345
|
-
|
|
38575
|
+
setTimeout(() => {
|
|
38576
|
+
worker.postMessage({
|
|
38577
|
+
type: "start",
|
|
38578
|
+
buffers,
|
|
38579
|
+
script,
|
|
38580
|
+
cwd,
|
|
38581
|
+
env: env2,
|
|
38582
|
+
argv: Array.isArray(options.argv) ? options.argv : ["/usr/bin/node", script, ...args.slice(1)],
|
|
38583
|
+
aliases: this.aliases,
|
|
38584
|
+
...typeof options.stdinPath === "string" ? { stdinPath: options.stdinPath } : {},
|
|
38585
|
+
...options.interactiveStdin ? { interactiveStdin: true } : {},
|
|
38586
|
+
...options.tty ? { tty: true } : {},
|
|
38587
|
+
...this.networkPolicy ? { network: this.networkPolicy } : {}
|
|
38588
|
+
});
|
|
38589
|
+
process2.begin();
|
|
38590
|
+
}, 0);
|
|
38346
38591
|
return process2;
|
|
38347
38592
|
}
|
|
38348
38593
|
/** Start an asynchronous child on the host's behalf and relay its events. */
|
|
@@ -38380,16 +38625,20 @@ var WorkerRuntimePod = class _WorkerRuntimePod extends LocalRuntimePod {
|
|
|
38380
38625
|
handle.on("exit", () => owned.delete(handle));
|
|
38381
38626
|
let stdout = "";
|
|
38382
38627
|
let stderr = "";
|
|
38628
|
+
const stdoutDecoder = new TextDecoder();
|
|
38629
|
+
const stderrDecoder = new TextDecoder();
|
|
38383
38630
|
const live = request.inheritStdio ? streamTo : null;
|
|
38384
38631
|
const restoreInput = live?.inheritInput(handle);
|
|
38385
38632
|
if (restoreInput) handle.on("exit", restoreInput);
|
|
38386
|
-
handle.on("stdout", (
|
|
38633
|
+
handle.on("stdout", (value) => {
|
|
38634
|
+
const text2 = typeof value === "string" ? value : stdoutDecoder.decode(value, { stream: true });
|
|
38387
38635
|
stdout += text2;
|
|
38388
|
-
live?.output(
|
|
38636
|
+
live?.output(value);
|
|
38389
38637
|
});
|
|
38390
|
-
handle.on("stderr", (
|
|
38638
|
+
handle.on("stderr", (value) => {
|
|
38639
|
+
const text2 = typeof value === "string" ? value : stderrDecoder.decode(value, { stream: true });
|
|
38391
38640
|
stderr += text2;
|
|
38392
|
-
live?.error(
|
|
38641
|
+
live?.error(value);
|
|
38393
38642
|
});
|
|
38394
38643
|
handle.on("exit", (code) => resolve3({ status: code, stdout, stderr, signal: null }));
|
|
38395
38644
|
handle.exec();
|
|
@@ -38460,8 +38709,8 @@ var WorkerRuntimePod = class _WorkerRuntimePod extends LocalRuntimePod {
|
|
|
38460
38709
|
const id = this.nextRequestId++;
|
|
38461
38710
|
this.upgraded.set(id, socket);
|
|
38462
38711
|
socket.on("data", (chunk) => {
|
|
38463
|
-
const
|
|
38464
|
-
worker.postMessage({ type: "ws-data", id, data:
|
|
38712
|
+
const bytes3 = new Uint8Array(chunk);
|
|
38713
|
+
worker.postMessage({ type: "ws-data", id, data: bytes3 });
|
|
38465
38714
|
});
|
|
38466
38715
|
const drop = () => {
|
|
38467
38716
|
if (!this.upgraded.delete(id)) return;
|
|
@@ -38601,7 +38850,8 @@ var Container = class _Container {
|
|
|
38601
38850
|
const network = {
|
|
38602
38851
|
allowOutbound: opts.network?.allowOutbound ?? false,
|
|
38603
38852
|
allowedHosts: opts.network?.allowedHosts ?? null,
|
|
38604
|
-
...opts.network?.proxy ? { proxy: opts.network.proxy } : {}
|
|
38853
|
+
...opts.network?.proxy ? { proxy: opts.network.proxy } : {},
|
|
38854
|
+
...opts.network?.secrets ? { secrets: opts.network.secrets } : {}
|
|
38605
38855
|
};
|
|
38606
38856
|
const podOptions = {
|
|
38607
38857
|
workdir: opts.cwd ?? "/",
|
|
@@ -38917,17 +39167,17 @@ var Container = class _Container {
|
|
|
38917
39167
|
body: init.body ?? null
|
|
38918
39168
|
});
|
|
38919
39169
|
const bodyRaw = res.body;
|
|
38920
|
-
const
|
|
39170
|
+
const bytes3 = bodyRaw instanceof Uint8Array ? bodyRaw : (
|
|
38921
39171
|
// The binary dispatcher answers with an ArrayBuffer.
|
|
38922
39172
|
bodyRaw instanceof ArrayBuffer ? new Uint8Array(bodyRaw) : typeof bodyRaw === "string" ? new TextEncoder().encode(bodyRaw) : new Uint8Array(0)
|
|
38923
39173
|
);
|
|
38924
|
-
const body = typeof bodyRaw === "string" ? bodyRaw : new TextDecoder().decode(
|
|
39174
|
+
const body = typeof bodyRaw === "string" ? bodyRaw : new TextDecoder().decode(bytes3);
|
|
38925
39175
|
return {
|
|
38926
39176
|
status: res.statusCode ?? 200,
|
|
38927
39177
|
statusText: res.statusMessage ?? "",
|
|
38928
39178
|
headers: res.headers ?? {},
|
|
38929
39179
|
body,
|
|
38930
|
-
bytes:
|
|
39180
|
+
bytes: bytes3,
|
|
38931
39181
|
json() {
|
|
38932
39182
|
return JSON.parse(body);
|
|
38933
39183
|
}
|
|
@@ -39560,7 +39810,7 @@ function serveContainerOn(port, box) {
|
|
|
39560
39810
|
headers: request.headers,
|
|
39561
39811
|
...request.body ? { body: new Uint8Array(request.body) } : {}
|
|
39562
39812
|
});
|
|
39563
|
-
const
|
|
39813
|
+
const bytes3 = response.bytes.slice();
|
|
39564
39814
|
port.postMessage(
|
|
39565
39815
|
{
|
|
39566
39816
|
id: request.id,
|
|
@@ -39568,10 +39818,10 @@ function serveContainerOn(port, box) {
|
|
|
39568
39818
|
status: response.status,
|
|
39569
39819
|
statusText: response.statusText,
|
|
39570
39820
|
headers: response.headers,
|
|
39571
|
-
body:
|
|
39821
|
+
body: bytes3.buffer
|
|
39572
39822
|
}
|
|
39573
39823
|
},
|
|
39574
|
-
[
|
|
39824
|
+
[bytes3.buffer]
|
|
39575
39825
|
);
|
|
39576
39826
|
} catch (error) {
|
|
39577
39827
|
const message = new TextEncoder().encode(error instanceof Error ? error.message : String(error));
|
|
@@ -39657,8 +39907,8 @@ async function createPreview(box, options = {}) {
|
|
|
39657
39907
|
Number(data.port),
|
|
39658
39908
|
{ method: "GET", path: data.path ?? "/", headers: data.headers ?? {} },
|
|
39659
39909
|
{
|
|
39660
|
-
data: (
|
|
39661
|
-
const carrier =
|
|
39910
|
+
data: (bytes3) => {
|
|
39911
|
+
const carrier = bytes3.slice().buffer;
|
|
39662
39912
|
reply({ type: WS_DATA, id, data: carrier }, [carrier]);
|
|
39663
39913
|
},
|
|
39664
39914
|
close: () => {
|
|
@@ -39740,8 +39990,8 @@ function gitFilesystem(ctx) {
|
|
|
39740
39990
|
const encoding = (opts) => typeof opts === "string" ? opts : opts?.encoding;
|
|
39741
39991
|
return { promises: {
|
|
39742
39992
|
async readFile(path, opts) {
|
|
39743
|
-
const
|
|
39744
|
-
return encoding(opts) ?
|
|
39993
|
+
const bytes3 = Buffer2.from(ctx.vfs.readFile(ctx.path(path), ctx.cred));
|
|
39994
|
+
return encoding(opts) ? bytes3.toString(encoding(opts)) : bytes3;
|
|
39745
39995
|
},
|
|
39746
39996
|
async writeFile(path, data, opts) {
|
|
39747
39997
|
ctx.vfs.writeFile(ctx.path(path), data, { cred: ctx.cred, mode: opts?.mode });
|
|
@@ -39933,8 +40183,8 @@ var signed = (value) => {
|
|
|
39933
40183
|
}
|
|
39934
40184
|
};
|
|
39935
40185
|
var str = (s) => {
|
|
39936
|
-
const
|
|
39937
|
-
return [...leb(
|
|
40186
|
+
const bytes3 = [...new TextEncoder().encode(s)];
|
|
40187
|
+
return [...leb(bytes3.length), ...bytes3];
|
|
39938
40188
|
};
|
|
39939
40189
|
var section = (id, data) => [id, ...leb(data.length), ...data];
|
|
39940
40190
|
function compileInstruction({ op, next }) {
|