sandboxedjs 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +293 -204
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +293 -204
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -4044,6 +4044,294 @@ var init_builtins = __esm({
|
|
|
4044
4044
|
}
|
|
4045
4045
|
});
|
|
4046
4046
|
|
|
4047
|
+
// src/util/binary.ts
|
|
4048
|
+
var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
4049
|
+
async function nodeBuiltin(name) {
|
|
4050
|
+
const specifier = `node:${name}`;
|
|
4051
|
+
return await import(
|
|
4052
|
+
/* @vite-ignore */
|
|
4053
|
+
/* webpackIgnore: true */
|
|
4054
|
+
specifier
|
|
4055
|
+
);
|
|
4056
|
+
}
|
|
4057
|
+
var zlibPromise = null;
|
|
4058
|
+
function nodeZlib() {
|
|
4059
|
+
zlibPromise ??= nodeBuiltin("zlib");
|
|
4060
|
+
return zlibPromise;
|
|
4061
|
+
}
|
|
4062
|
+
async function throughStream(data, stream) {
|
|
4063
|
+
const source = new Blob([data]).stream();
|
|
4064
|
+
const piped = source.pipeThrough(stream);
|
|
4065
|
+
return new Uint8Array(await new Response(piped).arrayBuffer());
|
|
4066
|
+
}
|
|
4067
|
+
async function gzip(data) {
|
|
4068
|
+
if (isNode) return new Uint8Array((await nodeZlib()).gzipSync(data));
|
|
4069
|
+
return throughStream(data, new CompressionStream("gzip"));
|
|
4070
|
+
}
|
|
4071
|
+
async function gunzip(data) {
|
|
4072
|
+
if (isNode) return new Uint8Array((await nodeZlib()).gunzipSync(data));
|
|
4073
|
+
return throughStream(data, new DecompressionStream("gzip"));
|
|
4074
|
+
}
|
|
4075
|
+
async function deflate(data) {
|
|
4076
|
+
if (isNode) return new Uint8Array((await nodeZlib()).deflateSync(data));
|
|
4077
|
+
return throughStream(data, new CompressionStream("deflate"));
|
|
4078
|
+
}
|
|
4079
|
+
async function inflate(data) {
|
|
4080
|
+
if (isNode) return new Uint8Array((await nodeZlib()).inflateSync(data));
|
|
4081
|
+
return throughStream(data, new DecompressionStream("deflate"));
|
|
4082
|
+
}
|
|
4083
|
+
async function inflateRaw(data) {
|
|
4084
|
+
if (isNode) return new Uint8Array((await nodeZlib()).inflateRawSync(data));
|
|
4085
|
+
return throughStream(data, new DecompressionStream("deflate-raw"));
|
|
4086
|
+
}
|
|
4087
|
+
var cryptoPromise = null;
|
|
4088
|
+
function nodeCrypto() {
|
|
4089
|
+
cryptoPromise ??= nodeBuiltin("crypto");
|
|
4090
|
+
return cryptoPromise;
|
|
4091
|
+
}
|
|
4092
|
+
var SUBTLE_NAMES = {
|
|
4093
|
+
sha1: "SHA-1",
|
|
4094
|
+
sha256: "SHA-256",
|
|
4095
|
+
sha384: "SHA-384",
|
|
4096
|
+
sha512: "SHA-512"
|
|
4097
|
+
};
|
|
4098
|
+
var UnsupportedAlgorithmError = class extends Error {
|
|
4099
|
+
constructor(algorithm) {
|
|
4100
|
+
super(`${algorithm} is not available in this environment`);
|
|
4101
|
+
this.name = "UnsupportedAlgorithmError";
|
|
4102
|
+
}
|
|
4103
|
+
};
|
|
4104
|
+
async function digestHex(algorithm, data) {
|
|
4105
|
+
if (isNode) {
|
|
4106
|
+
const { createHash } = await nodeCrypto();
|
|
4107
|
+
return createHash(algorithm).update(data).digest("hex");
|
|
4108
|
+
}
|
|
4109
|
+
if (algorithm === "md5") return md5Hex(data);
|
|
4110
|
+
const name = SUBTLE_NAMES[algorithm];
|
|
4111
|
+
if (!name) throw new UnsupportedAlgorithmError(algorithm);
|
|
4112
|
+
const buffer = await crypto.subtle.digest(name, data);
|
|
4113
|
+
return toHex(new Uint8Array(buffer));
|
|
4114
|
+
}
|
|
4115
|
+
async function randomUuid() {
|
|
4116
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
|
|
4117
|
+
const { randomUUID } = await nodeCrypto();
|
|
4118
|
+
return randomUUID();
|
|
4119
|
+
}
|
|
4120
|
+
function toHex(bytes) {
|
|
4121
|
+
let out = "";
|
|
4122
|
+
for (const byte of bytes) out += byte.toString(16).padStart(2, "0");
|
|
4123
|
+
return out;
|
|
4124
|
+
}
|
|
4125
|
+
function md5Hex(input) {
|
|
4126
|
+
const S = [
|
|
4127
|
+
7,
|
|
4128
|
+
12,
|
|
4129
|
+
17,
|
|
4130
|
+
22,
|
|
4131
|
+
7,
|
|
4132
|
+
12,
|
|
4133
|
+
17,
|
|
4134
|
+
22,
|
|
4135
|
+
7,
|
|
4136
|
+
12,
|
|
4137
|
+
17,
|
|
4138
|
+
22,
|
|
4139
|
+
7,
|
|
4140
|
+
12,
|
|
4141
|
+
17,
|
|
4142
|
+
22,
|
|
4143
|
+
5,
|
|
4144
|
+
9,
|
|
4145
|
+
14,
|
|
4146
|
+
20,
|
|
4147
|
+
5,
|
|
4148
|
+
9,
|
|
4149
|
+
14,
|
|
4150
|
+
20,
|
|
4151
|
+
5,
|
|
4152
|
+
9,
|
|
4153
|
+
14,
|
|
4154
|
+
20,
|
|
4155
|
+
5,
|
|
4156
|
+
9,
|
|
4157
|
+
14,
|
|
4158
|
+
20,
|
|
4159
|
+
4,
|
|
4160
|
+
11,
|
|
4161
|
+
16,
|
|
4162
|
+
23,
|
|
4163
|
+
4,
|
|
4164
|
+
11,
|
|
4165
|
+
16,
|
|
4166
|
+
23,
|
|
4167
|
+
4,
|
|
4168
|
+
11,
|
|
4169
|
+
16,
|
|
4170
|
+
23,
|
|
4171
|
+
4,
|
|
4172
|
+
11,
|
|
4173
|
+
16,
|
|
4174
|
+
23,
|
|
4175
|
+
6,
|
|
4176
|
+
10,
|
|
4177
|
+
15,
|
|
4178
|
+
21,
|
|
4179
|
+
6,
|
|
4180
|
+
10,
|
|
4181
|
+
15,
|
|
4182
|
+
21,
|
|
4183
|
+
6,
|
|
4184
|
+
10,
|
|
4185
|
+
15,
|
|
4186
|
+
21,
|
|
4187
|
+
6,
|
|
4188
|
+
10,
|
|
4189
|
+
15,
|
|
4190
|
+
21
|
|
4191
|
+
];
|
|
4192
|
+
const K = new Uint32Array(64);
|
|
4193
|
+
for (let i = 0; i < 64; i++) K[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 2 ** 32);
|
|
4194
|
+
const bitLength = input.length * 8;
|
|
4195
|
+
const padded = new Uint8Array(((input.length + 8 >> 6) + 1) * 64);
|
|
4196
|
+
padded.set(input);
|
|
4197
|
+
padded[input.length] = 128;
|
|
4198
|
+
const view = new DataView(padded.buffer);
|
|
4199
|
+
view.setUint32(padded.length - 8, bitLength >>> 0, true);
|
|
4200
|
+
view.setUint32(padded.length - 4, Math.floor(bitLength / 2 ** 32), true);
|
|
4201
|
+
let a0 = 1732584193;
|
|
4202
|
+
let b0 = 4023233417;
|
|
4203
|
+
let c0 = 2562383102;
|
|
4204
|
+
let d0 = 271733878;
|
|
4205
|
+
for (let chunk = 0; chunk < padded.length; chunk += 64) {
|
|
4206
|
+
const M = new Uint32Array(16);
|
|
4207
|
+
for (let i = 0; i < 16; i++) M[i] = view.getUint32(chunk + i * 4, true);
|
|
4208
|
+
let [a, b, c, d] = [a0, b0, c0, d0];
|
|
4209
|
+
for (let i = 0; i < 64; i++) {
|
|
4210
|
+
let f;
|
|
4211
|
+
let g;
|
|
4212
|
+
if (i < 16) {
|
|
4213
|
+
f = b & c | ~b & d;
|
|
4214
|
+
g = i;
|
|
4215
|
+
} else if (i < 32) {
|
|
4216
|
+
f = d & b | ~d & c;
|
|
4217
|
+
g = (5 * i + 1) % 16;
|
|
4218
|
+
} else if (i < 48) {
|
|
4219
|
+
f = b ^ c ^ d;
|
|
4220
|
+
g = (3 * i + 5) % 16;
|
|
4221
|
+
} else {
|
|
4222
|
+
f = c ^ (b | ~d);
|
|
4223
|
+
g = 7 * i % 16;
|
|
4224
|
+
}
|
|
4225
|
+
const tmp = d;
|
|
4226
|
+
d = c;
|
|
4227
|
+
c = b;
|
|
4228
|
+
const sum = a + f + K[i] + M[g] >>> 0;
|
|
4229
|
+
b = b + (sum << S[i] | sum >>> 32 - S[i]) >>> 0;
|
|
4230
|
+
a = tmp;
|
|
4231
|
+
}
|
|
4232
|
+
a0 = a0 + a >>> 0;
|
|
4233
|
+
b0 = b0 + b >>> 0;
|
|
4234
|
+
c0 = c0 + c >>> 0;
|
|
4235
|
+
d0 = d0 + d >>> 0;
|
|
4236
|
+
}
|
|
4237
|
+
const out = new Uint8Array(16);
|
|
4238
|
+
new DataView(out.buffer).setUint32(0, a0, true);
|
|
4239
|
+
new DataView(out.buffer).setUint32(4, b0, true);
|
|
4240
|
+
new DataView(out.buffer).setUint32(8, c0, true);
|
|
4241
|
+
new DataView(out.buffer).setUint32(12, d0, true);
|
|
4242
|
+
return toHex(out);
|
|
4243
|
+
}
|
|
4244
|
+
|
|
4245
|
+
// src/runtime/esbuild-host.ts
|
|
4246
|
+
var INITIALIZE_CALLS = /\.initialize\(\s*\{\s*wasmURL:[^}]*\}\s*\)/g;
|
|
4247
|
+
var installed = null;
|
|
4248
|
+
function installEsbuildRuntime() {
|
|
4249
|
+
installed ??= install().catch((error) => {
|
|
4250
|
+
if (process.env.SANDBOXEDJS_DEBUG) {
|
|
4251
|
+
console.error("[sandboxedjs] esbuild runtime unavailable:", error);
|
|
4252
|
+
}
|
|
4253
|
+
});
|
|
4254
|
+
return installed;
|
|
4255
|
+
}
|
|
4256
|
+
async function install() {
|
|
4257
|
+
const workerPath = await buildPatchedWorker();
|
|
4258
|
+
if (!workerPath) return;
|
|
4259
|
+
const { createNodeHost, setRuntimeHost } = await import('@scelar/nodepod/headless');
|
|
4260
|
+
setRuntimeHost(createNodeHost({ workerPath }));
|
|
4261
|
+
}
|
|
4262
|
+
async function buildPatchedWorker() {
|
|
4263
|
+
const { createRequire } = await nodeBuiltin("module");
|
|
4264
|
+
const fs = await nodeBuiltin("fs/promises");
|
|
4265
|
+
const os = await nodeBuiltin("os");
|
|
4266
|
+
const path = await nodeBuiltin("path");
|
|
4267
|
+
const url = await nodeBuiltin("url");
|
|
4268
|
+
const crypto2 = await nodeBuiltin("crypto");
|
|
4269
|
+
const require2 = createRequire(path.join(process.cwd(), "index.js"));
|
|
4270
|
+
let workerPath;
|
|
4271
|
+
let wasmPath;
|
|
4272
|
+
let browserEntry;
|
|
4273
|
+
try {
|
|
4274
|
+
workerPath = path.join(
|
|
4275
|
+
path.dirname(require2.resolve("@scelar/nodepod/headless")),
|
|
4276
|
+
"__worker__.js"
|
|
4277
|
+
);
|
|
4278
|
+
const esbuildRoot = path.dirname(require2.resolve("esbuild-wasm/package.json"));
|
|
4279
|
+
wasmPath = path.join(esbuildRoot, "esbuild.wasm");
|
|
4280
|
+
browserEntry = path.join(esbuildRoot, "esm", "browser.min.js");
|
|
4281
|
+
} catch {
|
|
4282
|
+
return null;
|
|
4283
|
+
}
|
|
4284
|
+
const [source, wasmStat] = await Promise.all([
|
|
4285
|
+
fs.readFile(workerPath, "utf8"),
|
|
4286
|
+
fs.stat(wasmPath)
|
|
4287
|
+
]);
|
|
4288
|
+
if (!INITIALIZE_CALLS.test(source)) {
|
|
4289
|
+
return null;
|
|
4290
|
+
}
|
|
4291
|
+
INITIALIZE_CALLS.lastIndex = 0;
|
|
4292
|
+
const WASM_URL = /`https:\/\/esm\.sh\/esbuild-wasm@\$\{[A-Za-z0-9_$]+\}\/esbuild\.wasm`/g;
|
|
4293
|
+
const MODULE_URL = /`https:\/\/esm\.sh\/esbuild-wasm@\$\{[A-Za-z0-9_$]+\}`/g;
|
|
4294
|
+
const initCall = `.initialize(await __sandboxedjsEsbuildInit(${JSON.stringify(wasmPath)}, ${JSON.stringify(url.pathToFileURL(wasmPath).href)}))`;
|
|
4295
|
+
const patched = [
|
|
4296
|
+
// The helper is needed by the bundle itself and again inside the nested
|
|
4297
|
+
// worker it builds from a template, which is a separate script.
|
|
4298
|
+
INIT_HELPER,
|
|
4299
|
+
source.replace(WASM_URL, JSON.stringify(url.pathToFileURL(wasmPath).href)).replace(MODULE_URL, JSON.stringify(url.pathToFileURL(browserEntry).href)).replace(INITIALIZE_CALLS, initCall).replace("function ensureEsbuild() {", `${INIT_HELPER}
|
|
4300
|
+
|
|
4301
|
+
function ensureEsbuild() {`)
|
|
4302
|
+
].join("\n");
|
|
4303
|
+
const fingerprint = crypto2.createHash("sha256").update(`${source.length}:${wasmStat.size}:${patched.length}`).digest("hex").slice(0, 16);
|
|
4304
|
+
const cached = path.join(os.tmpdir(), `sandboxedjs-worker-${fingerprint}.js`);
|
|
4305
|
+
try {
|
|
4306
|
+
await fs.access(cached);
|
|
4307
|
+
} catch {
|
|
4308
|
+
const staging = `${cached}.${process.pid}.tmp`;
|
|
4309
|
+
await fs.writeFile(staging, patched, "utf8");
|
|
4310
|
+
await fs.rename(staging, cached);
|
|
4311
|
+
}
|
|
4312
|
+
return cached;
|
|
4313
|
+
}
|
|
4314
|
+
var INIT_HELPER = `let __sandboxedjsWasmUrl = null;
|
|
4315
|
+
async function __sandboxedjsEsbuildInit(wasmPath, wasmUrl) {
|
|
4316
|
+
// esbuild-wasm is a browser build: it resolves its wasm against document
|
|
4317
|
+
// location. There is no document here, and a bare origin is enough.
|
|
4318
|
+
if (typeof globalThis.location === "undefined") {
|
|
4319
|
+
globalThis.location = { href: "file:///", origin: "null", protocol: "file:" };
|
|
4320
|
+
}
|
|
4321
|
+
// esbuild-wasm fetches its wasm, and fetch cannot read a file: URL, so the
|
|
4322
|
+
// bytes are inlined as a data: URL instead \u2014 the one scheme both the ESM
|
|
4323
|
+
// loader and fetch accept. Built once and reused; it is ~15MB of base64.
|
|
4324
|
+
// Handing over a pre-compiled WebAssembly.Module instead does not work: the
|
|
4325
|
+
// Go glue supplies its own import object and rejects a foreign module.
|
|
4326
|
+
try {
|
|
4327
|
+
if (__sandboxedjsWasmUrl === null && typeof require === "function") {
|
|
4328
|
+
const bytes = require("node:fs").readFileSync(wasmPath);
|
|
4329
|
+
__sandboxedjsWasmUrl = "data:application/wasm;base64," + bytes.toString("base64");
|
|
4330
|
+
}
|
|
4331
|
+
} catch (err) { /* fall back to the file URL below */ }
|
|
4332
|
+
return { wasmURL: __sandboxedjsWasmUrl || wasmUrl, worker: false };
|
|
4333
|
+
}`;
|
|
4334
|
+
|
|
4047
4335
|
// src/fs/vfs.ts
|
|
4048
4336
|
init_errno();
|
|
4049
4337
|
init_path();
|
|
@@ -15136,206 +15424,6 @@ var commands5 = [grep, find, xargs, diff, cmp];
|
|
|
15136
15424
|
// src/bin/archive.ts
|
|
15137
15425
|
init_mode();
|
|
15138
15426
|
init_path();
|
|
15139
|
-
|
|
15140
|
-
// src/util/binary.ts
|
|
15141
|
-
var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
15142
|
-
async function nodeBuiltin(name) {
|
|
15143
|
-
const specifier = `node:${name}`;
|
|
15144
|
-
return await import(
|
|
15145
|
-
/* @vite-ignore */
|
|
15146
|
-
/* webpackIgnore: true */
|
|
15147
|
-
specifier
|
|
15148
|
-
);
|
|
15149
|
-
}
|
|
15150
|
-
var zlibPromise = null;
|
|
15151
|
-
function nodeZlib() {
|
|
15152
|
-
zlibPromise ??= nodeBuiltin("zlib");
|
|
15153
|
-
return zlibPromise;
|
|
15154
|
-
}
|
|
15155
|
-
async function throughStream(data, stream) {
|
|
15156
|
-
const source = new Blob([data]).stream();
|
|
15157
|
-
const piped = source.pipeThrough(stream);
|
|
15158
|
-
return new Uint8Array(await new Response(piped).arrayBuffer());
|
|
15159
|
-
}
|
|
15160
|
-
async function gzip(data) {
|
|
15161
|
-
if (isNode) return new Uint8Array((await nodeZlib()).gzipSync(data));
|
|
15162
|
-
return throughStream(data, new CompressionStream("gzip"));
|
|
15163
|
-
}
|
|
15164
|
-
async function gunzip(data) {
|
|
15165
|
-
if (isNode) return new Uint8Array((await nodeZlib()).gunzipSync(data));
|
|
15166
|
-
return throughStream(data, new DecompressionStream("gzip"));
|
|
15167
|
-
}
|
|
15168
|
-
async function deflate(data) {
|
|
15169
|
-
if (isNode) return new Uint8Array((await nodeZlib()).deflateSync(data));
|
|
15170
|
-
return throughStream(data, new CompressionStream("deflate"));
|
|
15171
|
-
}
|
|
15172
|
-
async function inflate(data) {
|
|
15173
|
-
if (isNode) return new Uint8Array((await nodeZlib()).inflateSync(data));
|
|
15174
|
-
return throughStream(data, new DecompressionStream("deflate"));
|
|
15175
|
-
}
|
|
15176
|
-
async function inflateRaw(data) {
|
|
15177
|
-
if (isNode) return new Uint8Array((await nodeZlib()).inflateRawSync(data));
|
|
15178
|
-
return throughStream(data, new DecompressionStream("deflate-raw"));
|
|
15179
|
-
}
|
|
15180
|
-
var cryptoPromise = null;
|
|
15181
|
-
function nodeCrypto() {
|
|
15182
|
-
cryptoPromise ??= nodeBuiltin("crypto");
|
|
15183
|
-
return cryptoPromise;
|
|
15184
|
-
}
|
|
15185
|
-
var SUBTLE_NAMES = {
|
|
15186
|
-
sha1: "SHA-1",
|
|
15187
|
-
sha256: "SHA-256",
|
|
15188
|
-
sha384: "SHA-384",
|
|
15189
|
-
sha512: "SHA-512"
|
|
15190
|
-
};
|
|
15191
|
-
var UnsupportedAlgorithmError = class extends Error {
|
|
15192
|
-
constructor(algorithm) {
|
|
15193
|
-
super(`${algorithm} is not available in this environment`);
|
|
15194
|
-
this.name = "UnsupportedAlgorithmError";
|
|
15195
|
-
}
|
|
15196
|
-
};
|
|
15197
|
-
async function digestHex(algorithm, data) {
|
|
15198
|
-
if (isNode) {
|
|
15199
|
-
const { createHash } = await nodeCrypto();
|
|
15200
|
-
return createHash(algorithm).update(data).digest("hex");
|
|
15201
|
-
}
|
|
15202
|
-
if (algorithm === "md5") return md5Hex(data);
|
|
15203
|
-
const name = SUBTLE_NAMES[algorithm];
|
|
15204
|
-
if (!name) throw new UnsupportedAlgorithmError(algorithm);
|
|
15205
|
-
const buffer = await crypto.subtle.digest(name, data);
|
|
15206
|
-
return toHex(new Uint8Array(buffer));
|
|
15207
|
-
}
|
|
15208
|
-
async function randomUuid() {
|
|
15209
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
|
|
15210
|
-
const { randomUUID } = await nodeCrypto();
|
|
15211
|
-
return randomUUID();
|
|
15212
|
-
}
|
|
15213
|
-
function toHex(bytes) {
|
|
15214
|
-
let out = "";
|
|
15215
|
-
for (const byte of bytes) out += byte.toString(16).padStart(2, "0");
|
|
15216
|
-
return out;
|
|
15217
|
-
}
|
|
15218
|
-
function md5Hex(input) {
|
|
15219
|
-
const S = [
|
|
15220
|
-
7,
|
|
15221
|
-
12,
|
|
15222
|
-
17,
|
|
15223
|
-
22,
|
|
15224
|
-
7,
|
|
15225
|
-
12,
|
|
15226
|
-
17,
|
|
15227
|
-
22,
|
|
15228
|
-
7,
|
|
15229
|
-
12,
|
|
15230
|
-
17,
|
|
15231
|
-
22,
|
|
15232
|
-
7,
|
|
15233
|
-
12,
|
|
15234
|
-
17,
|
|
15235
|
-
22,
|
|
15236
|
-
5,
|
|
15237
|
-
9,
|
|
15238
|
-
14,
|
|
15239
|
-
20,
|
|
15240
|
-
5,
|
|
15241
|
-
9,
|
|
15242
|
-
14,
|
|
15243
|
-
20,
|
|
15244
|
-
5,
|
|
15245
|
-
9,
|
|
15246
|
-
14,
|
|
15247
|
-
20,
|
|
15248
|
-
5,
|
|
15249
|
-
9,
|
|
15250
|
-
14,
|
|
15251
|
-
20,
|
|
15252
|
-
4,
|
|
15253
|
-
11,
|
|
15254
|
-
16,
|
|
15255
|
-
23,
|
|
15256
|
-
4,
|
|
15257
|
-
11,
|
|
15258
|
-
16,
|
|
15259
|
-
23,
|
|
15260
|
-
4,
|
|
15261
|
-
11,
|
|
15262
|
-
16,
|
|
15263
|
-
23,
|
|
15264
|
-
4,
|
|
15265
|
-
11,
|
|
15266
|
-
16,
|
|
15267
|
-
23,
|
|
15268
|
-
6,
|
|
15269
|
-
10,
|
|
15270
|
-
15,
|
|
15271
|
-
21,
|
|
15272
|
-
6,
|
|
15273
|
-
10,
|
|
15274
|
-
15,
|
|
15275
|
-
21,
|
|
15276
|
-
6,
|
|
15277
|
-
10,
|
|
15278
|
-
15,
|
|
15279
|
-
21,
|
|
15280
|
-
6,
|
|
15281
|
-
10,
|
|
15282
|
-
15,
|
|
15283
|
-
21
|
|
15284
|
-
];
|
|
15285
|
-
const K = new Uint32Array(64);
|
|
15286
|
-
for (let i = 0; i < 64; i++) K[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 2 ** 32);
|
|
15287
|
-
const bitLength = input.length * 8;
|
|
15288
|
-
const padded = new Uint8Array(((input.length + 8 >> 6) + 1) * 64);
|
|
15289
|
-
padded.set(input);
|
|
15290
|
-
padded[input.length] = 128;
|
|
15291
|
-
const view = new DataView(padded.buffer);
|
|
15292
|
-
view.setUint32(padded.length - 8, bitLength >>> 0, true);
|
|
15293
|
-
view.setUint32(padded.length - 4, Math.floor(bitLength / 2 ** 32), true);
|
|
15294
|
-
let a0 = 1732584193;
|
|
15295
|
-
let b0 = 4023233417;
|
|
15296
|
-
let c0 = 2562383102;
|
|
15297
|
-
let d0 = 271733878;
|
|
15298
|
-
for (let chunk = 0; chunk < padded.length; chunk += 64) {
|
|
15299
|
-
const M = new Uint32Array(16);
|
|
15300
|
-
for (let i = 0; i < 16; i++) M[i] = view.getUint32(chunk + i * 4, true);
|
|
15301
|
-
let [a, b, c, d] = [a0, b0, c0, d0];
|
|
15302
|
-
for (let i = 0; i < 64; i++) {
|
|
15303
|
-
let f;
|
|
15304
|
-
let g;
|
|
15305
|
-
if (i < 16) {
|
|
15306
|
-
f = b & c | ~b & d;
|
|
15307
|
-
g = i;
|
|
15308
|
-
} else if (i < 32) {
|
|
15309
|
-
f = d & b | ~d & c;
|
|
15310
|
-
g = (5 * i + 1) % 16;
|
|
15311
|
-
} else if (i < 48) {
|
|
15312
|
-
f = b ^ c ^ d;
|
|
15313
|
-
g = (3 * i + 5) % 16;
|
|
15314
|
-
} else {
|
|
15315
|
-
f = c ^ (b | ~d);
|
|
15316
|
-
g = 7 * i % 16;
|
|
15317
|
-
}
|
|
15318
|
-
const tmp = d;
|
|
15319
|
-
d = c;
|
|
15320
|
-
c = b;
|
|
15321
|
-
const sum = a + f + K[i] + M[g] >>> 0;
|
|
15322
|
-
b = b + (sum << S[i] | sum >>> 32 - S[i]) >>> 0;
|
|
15323
|
-
a = tmp;
|
|
15324
|
-
}
|
|
15325
|
-
a0 = a0 + a >>> 0;
|
|
15326
|
-
b0 = b0 + b >>> 0;
|
|
15327
|
-
c0 = c0 + c >>> 0;
|
|
15328
|
-
d0 = d0 + d >>> 0;
|
|
15329
|
-
}
|
|
15330
|
-
const out = new Uint8Array(16);
|
|
15331
|
-
new DataView(out.buffer).setUint32(0, a0, true);
|
|
15332
|
-
new DataView(out.buffer).setUint32(4, b0, true);
|
|
15333
|
-
new DataView(out.buffer).setUint32(8, c0, true);
|
|
15334
|
-
new DataView(out.buffer).setUint32(12, d0, true);
|
|
15335
|
-
return toHex(out);
|
|
15336
|
-
}
|
|
15337
|
-
|
|
15338
|
-
// src/bin/archive.ts
|
|
15339
15427
|
var BLOCK = 512;
|
|
15340
15428
|
var encoder4 = new TextEncoder();
|
|
15341
15429
|
var decoder6 = new TextDecoder();
|
|
@@ -16643,7 +16731,7 @@ var watch = defineCommand({
|
|
|
16643
16731
|
return 0;
|
|
16644
16732
|
}
|
|
16645
16733
|
});
|
|
16646
|
-
var
|
|
16734
|
+
var install2 = defineCommand({
|
|
16647
16735
|
name: "install",
|
|
16648
16736
|
path: "/usr/bin/install",
|
|
16649
16737
|
summary: "copy files and set attributes",
|
|
@@ -16762,7 +16850,7 @@ var commands9 = [
|
|
|
16762
16850
|
timeoutCmd,
|
|
16763
16851
|
nohup,
|
|
16764
16852
|
watch,
|
|
16765
|
-
|
|
16853
|
+
install2,
|
|
16766
16854
|
niceCmd,
|
|
16767
16855
|
timeCmd
|
|
16768
16856
|
];
|
|
@@ -18588,12 +18676,12 @@ unless the container was created with network: { allowOutbound: true }.`,
|
|
|
18588
18676
|
}
|
|
18589
18677
|
ctx.stderr.write(`npx: installing ${packageSpec}...
|
|
18590
18678
|
`);
|
|
18591
|
-
const
|
|
18679
|
+
const installed2 = await installPackages(ctx, [packageSpec], {
|
|
18592
18680
|
cwd: root,
|
|
18593
18681
|
save: false,
|
|
18594
18682
|
quiet: true
|
|
18595
18683
|
});
|
|
18596
|
-
if (
|
|
18684
|
+
if (installed2 !== 0) return installed2;
|
|
18597
18685
|
if (!findLocalBin(ctx, command)) {
|
|
18598
18686
|
const binaries = packageBinaries(ctx, root, packageName);
|
|
18599
18687
|
const chosen = binaries.includes(command) ? command : binaries[0];
|
|
@@ -19022,6 +19110,7 @@ var Container = class _Container {
|
|
|
19022
19110
|
}
|
|
19023
19111
|
// ── boot ──────────────────────────────────────────────────────────────────
|
|
19024
19112
|
static async create(opts = {}) {
|
|
19113
|
+
if (!opts.pod) await installEsbuildRuntime();
|
|
19025
19114
|
const pod = opts.pod ?? await headless.Nodepod.boot({
|
|
19026
19115
|
headless: true,
|
|
19027
19116
|
serviceWorker: false,
|