sandboxedjs 0.1.71 → 0.1.73

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.js CHANGED
@@ -4060,6 +4060,214 @@ var init_builtins = __esm({
4060
4060
  }
4061
4061
  });
4062
4062
 
4063
+ // src/util/binary.ts
4064
+ async function nodeBuiltin(name) {
4065
+ const specifier = `node:${name}`;
4066
+ return await import(
4067
+ /* @vite-ignore */
4068
+ /* webpackIgnore: true */
4069
+ specifier
4070
+ );
4071
+ }
4072
+ async function nodeOnlyModule(specifier) {
4073
+ const parts = specifier.split("/");
4074
+ const runtimeSpecifier = parts.join("/");
4075
+ return await import(
4076
+ /* @vite-ignore */
4077
+ /* webpackIgnore: true */
4078
+ runtimeSpecifier
4079
+ );
4080
+ }
4081
+ function nodeZlib() {
4082
+ zlibPromise ??= nodeBuiltin("zlib");
4083
+ return zlibPromise;
4084
+ }
4085
+ async function throughStream(data, stream) {
4086
+ const source = new Blob([data]).stream();
4087
+ const piped = source.pipeThrough(stream);
4088
+ return new Uint8Array(await new Response(piped).arrayBuffer());
4089
+ }
4090
+ async function gzip(data) {
4091
+ if (isNode) return new Uint8Array((await nodeZlib()).gzipSync(data));
4092
+ return throughStream(data, new CompressionStream("gzip"));
4093
+ }
4094
+ async function gunzip(data) {
4095
+ if (isNode) return new Uint8Array((await nodeZlib()).gunzipSync(data));
4096
+ return throughStream(data, new DecompressionStream("gzip"));
4097
+ }
4098
+ async function deflate(data) {
4099
+ if (isNode) return new Uint8Array((await nodeZlib()).deflateSync(data));
4100
+ return throughStream(data, new CompressionStream("deflate"));
4101
+ }
4102
+ async function inflate(data) {
4103
+ if (isNode) return new Uint8Array((await nodeZlib()).inflateSync(data));
4104
+ return throughStream(data, new DecompressionStream("deflate"));
4105
+ }
4106
+ function nodeCrypto() {
4107
+ cryptoPromise ??= nodeBuiltin("crypto");
4108
+ return cryptoPromise;
4109
+ }
4110
+ async function digestHex(algorithm, data) {
4111
+ if (isNode) {
4112
+ const { createHash } = await nodeCrypto();
4113
+ return createHash(algorithm).update(data).digest("hex");
4114
+ }
4115
+ if (algorithm === "md5") return md5Hex(data);
4116
+ const name = SUBTLE_NAMES[algorithm];
4117
+ if (!name) throw new UnsupportedAlgorithmError(algorithm);
4118
+ const buffer = await crypto.subtle.digest(name, data);
4119
+ return toHex(new Uint8Array(buffer));
4120
+ }
4121
+ async function randomUuid() {
4122
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
4123
+ const { randomUUID } = await nodeCrypto();
4124
+ return randomUUID();
4125
+ }
4126
+ function toHex(bytes2) {
4127
+ let out = "";
4128
+ for (const byte of bytes2) out += byte.toString(16).padStart(2, "0");
4129
+ return out;
4130
+ }
4131
+ function md5Hex(input) {
4132
+ const S = [
4133
+ 7,
4134
+ 12,
4135
+ 17,
4136
+ 22,
4137
+ 7,
4138
+ 12,
4139
+ 17,
4140
+ 22,
4141
+ 7,
4142
+ 12,
4143
+ 17,
4144
+ 22,
4145
+ 7,
4146
+ 12,
4147
+ 17,
4148
+ 22,
4149
+ 5,
4150
+ 9,
4151
+ 14,
4152
+ 20,
4153
+ 5,
4154
+ 9,
4155
+ 14,
4156
+ 20,
4157
+ 5,
4158
+ 9,
4159
+ 14,
4160
+ 20,
4161
+ 5,
4162
+ 9,
4163
+ 14,
4164
+ 20,
4165
+ 4,
4166
+ 11,
4167
+ 16,
4168
+ 23,
4169
+ 4,
4170
+ 11,
4171
+ 16,
4172
+ 23,
4173
+ 4,
4174
+ 11,
4175
+ 16,
4176
+ 23,
4177
+ 4,
4178
+ 11,
4179
+ 16,
4180
+ 23,
4181
+ 6,
4182
+ 10,
4183
+ 15,
4184
+ 21,
4185
+ 6,
4186
+ 10,
4187
+ 15,
4188
+ 21,
4189
+ 6,
4190
+ 10,
4191
+ 15,
4192
+ 21,
4193
+ 6,
4194
+ 10,
4195
+ 15,
4196
+ 21
4197
+ ];
4198
+ const K = new Uint32Array(64);
4199
+ for (let i = 0; i < 64; i++) K[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 2 ** 32);
4200
+ const bitLength = input.length * 8;
4201
+ const padded = new Uint8Array(((input.length + 8 >> 6) + 1) * 64);
4202
+ padded.set(input);
4203
+ padded[input.length] = 128;
4204
+ const view = new DataView(padded.buffer);
4205
+ view.setUint32(padded.length - 8, bitLength >>> 0, true);
4206
+ view.setUint32(padded.length - 4, Math.floor(bitLength / 2 ** 32), true);
4207
+ let a0 = 1732584193;
4208
+ let b0 = 4023233417;
4209
+ let c0 = 2562383102;
4210
+ let d0 = 271733878;
4211
+ for (let chunk = 0; chunk < padded.length; chunk += 64) {
4212
+ const M = new Uint32Array(16);
4213
+ for (let i = 0; i < 16; i++) M[i] = view.getUint32(chunk + i * 4, true);
4214
+ let [a, b, c, d] = [a0, b0, c0, d0];
4215
+ for (let i = 0; i < 64; i++) {
4216
+ let f;
4217
+ let g;
4218
+ if (i < 16) {
4219
+ f = b & c | ~b & d;
4220
+ g = i;
4221
+ } else if (i < 32) {
4222
+ f = d & b | ~d & c;
4223
+ g = (5 * i + 1) % 16;
4224
+ } else if (i < 48) {
4225
+ f = b ^ c ^ d;
4226
+ g = (3 * i + 5) % 16;
4227
+ } else {
4228
+ f = c ^ (b | ~d);
4229
+ g = 7 * i % 16;
4230
+ }
4231
+ const tmp = d;
4232
+ d = c;
4233
+ c = b;
4234
+ const sum = a + f + K[i] + M[g] >>> 0;
4235
+ b = b + (sum << S[i] | sum >>> 32 - S[i]) >>> 0;
4236
+ a = tmp;
4237
+ }
4238
+ a0 = a0 + a >>> 0;
4239
+ b0 = b0 + b >>> 0;
4240
+ c0 = c0 + c >>> 0;
4241
+ d0 = d0 + d >>> 0;
4242
+ }
4243
+ const out = new Uint8Array(16);
4244
+ new DataView(out.buffer).setUint32(0, a0, true);
4245
+ new DataView(out.buffer).setUint32(4, b0, true);
4246
+ new DataView(out.buffer).setUint32(8, c0, true);
4247
+ new DataView(out.buffer).setUint32(12, d0, true);
4248
+ return toHex(out);
4249
+ }
4250
+ var isNode, zlibPromise, cryptoPromise, SUBTLE_NAMES, UnsupportedAlgorithmError;
4251
+ var init_binary = __esm({
4252
+ "src/util/binary.ts"() {
4253
+ isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
4254
+ zlibPromise = null;
4255
+ cryptoPromise = null;
4256
+ SUBTLE_NAMES = {
4257
+ sha1: "SHA-1",
4258
+ sha256: "SHA-256",
4259
+ sha384: "SHA-384",
4260
+ sha512: "SHA-512"
4261
+ };
4262
+ UnsupportedAlgorithmError = class extends Error {
4263
+ constructor(algorithm) {
4264
+ super(`${algorithm} is not available in this environment`);
4265
+ this.name = "UnsupportedAlgorithmError";
4266
+ }
4267
+ };
4268
+ }
4269
+ });
4270
+
4063
4271
  // src/pkg/zip.ts
4064
4272
  var zip_exports = {};
4065
4273
  __export(zip_exports, {
@@ -4148,6 +4356,122 @@ var init_zip = __esm({
4148
4356
  }
4149
4357
  });
4150
4358
 
4359
+ // src/python/local-builder.ts
4360
+ var local_builder_exports = {};
4361
+ __export(local_builder_exports, {
4362
+ buildFromSource: () => buildFromSource
4363
+ });
4364
+ async function pipelineRoot() {
4365
+ const [{ existsSync }, { fileURLToPath: fileURLToPath2 }, { dirname: dirname3, resolve: resolve3 }] = await Promise.all([
4366
+ nodeBuiltin("fs"),
4367
+ nodeBuiltin("url"),
4368
+ nodeBuiltin("path")
4369
+ ]);
4370
+ const here = dirname3(fileURLToPath2(import.meta.url));
4371
+ for (const candidate of [
4372
+ resolve3(here, "../python-runtime"),
4373
+ resolve3(here, "../../python-runtime"),
4374
+ resolve3(here, "../../../python-runtime")
4375
+ ]) {
4376
+ if (existsSync(resolve3(candidate, "scripts/build_extension.py"))) return candidate;
4377
+ }
4378
+ return null;
4379
+ }
4380
+ async function run(command, args, cwd) {
4381
+ const { spawn } = await nodeBuiltin("child_process");
4382
+ return await new Promise((resolveRun) => {
4383
+ const child = spawn(command, args, { cwd });
4384
+ let stdout = "";
4385
+ let stderr = "";
4386
+ child.stdout.on("data", (chunk) => {
4387
+ stdout += String(chunk);
4388
+ });
4389
+ child.stderr.on("data", (chunk) => {
4390
+ stderr += String(chunk);
4391
+ });
4392
+ child.on("error", (error) => resolveRun({ code: -1, stdout, stderr: String(error) }));
4393
+ child.on("close", (code) => resolveRun({ code: code ?? -1, stdout, stderr }));
4394
+ });
4395
+ }
4396
+ async function readIndex(root) {
4397
+ const [{ readFileSync, existsSync }, { pathToFileURL: pathToFileURL2 }, { resolve: resolve3 }] = await Promise.all([
4398
+ nodeBuiltin("fs"),
4399
+ nodeBuiltin("url"),
4400
+ nodeBuiltin("path")
4401
+ ]);
4402
+ const directory2 = resolve3(root, "out/wheels");
4403
+ const file3 = resolve3(directory2, "index.json");
4404
+ if (!existsSync(file3)) return null;
4405
+ const parsed = JSON.parse(readFileSync(file3, "utf8"));
4406
+ return {
4407
+ ...parsed,
4408
+ baseUrl: pathToFileURL2(directory2).href
4409
+ };
4410
+ }
4411
+ async function buildFromSource(requirement, log = () => {
4412
+ }) {
4413
+ const root = await pipelineRoot();
4414
+ if (root === null) {
4415
+ return {
4416
+ built: false,
4417
+ index: null,
4418
+ classification: "blocked-toolchain",
4419
+ reason: "the build pipeline is not present; wheels can only be built from a checkout"
4420
+ };
4421
+ }
4422
+ log(`Building ${requirement} from source (no wheel for this runtime yet)`);
4423
+ const recipe = await run("python3", ["scripts/auto_recipe.py", requirement], root);
4424
+ if (recipe.code !== 0) {
4425
+ try {
4426
+ const reported = JSON.parse(recipe.stdout.trim().split("\n").at(-1) ?? "{}");
4427
+ if (reported.reason) {
4428
+ return {
4429
+ built: false,
4430
+ index: null,
4431
+ classification: reported.classification ?? "blocked-toolchain",
4432
+ reason: reported.reason
4433
+ };
4434
+ }
4435
+ } catch {
4436
+ }
4437
+ return {
4438
+ built: false,
4439
+ index: null,
4440
+ classification: "blocked-toolchain",
4441
+ reason: `could not describe ${requirement}: ${recipe.stderr.trim().slice(-400)}`
4442
+ };
4443
+ }
4444
+ const recipePath = recipe.stdout.trim().split("\n").at(-1);
4445
+ const build = await run("python3", ["scripts/build_extension.py", recipePath], root);
4446
+ if (build.code !== 0) {
4447
+ const tail2 = `${build.stdout}
4448
+ ${build.stderr}`.trim().split("\n").slice(-12).join("\n");
4449
+ return {
4450
+ built: false,
4451
+ index: null,
4452
+ classification: "blocked-toolchain",
4453
+ reason: `building ${requirement} failed:
4454
+ ${tail2}`
4455
+ };
4456
+ }
4457
+ const indexed = await run("python3", ["scripts/build_index.py"], root);
4458
+ if (indexed.code !== 0) {
4459
+ return {
4460
+ built: false,
4461
+ index: null,
4462
+ classification: "blocked-toolchain",
4463
+ reason: `built ${requirement} but could not index it: ${indexed.stderr.trim().slice(-300)}`
4464
+ };
4465
+ }
4466
+ log(`Built ${requirement}`);
4467
+ return { built: true, index: await readIndex(root) };
4468
+ }
4469
+ var init_local_builder = __esm({
4470
+ "src/python/local-builder.ts"() {
4471
+ init_binary();
4472
+ }
4473
+ });
4474
+
4151
4475
  // src/fs/vfs.ts
4152
4476
  init_errno();
4153
4477
  init_path();
@@ -15410,211 +15734,7 @@ var commands5 = [grep, find, xargs, diff, cmp];
15410
15734
  // src/bin/archive.ts
15411
15735
  init_mode();
15412
15736
  init_path();
15413
-
15414
- // src/util/binary.ts
15415
- var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
15416
- async function nodeBuiltin(name) {
15417
- const specifier = `node:${name}`;
15418
- return await import(
15419
- /* @vite-ignore */
15420
- /* webpackIgnore: true */
15421
- specifier
15422
- );
15423
- }
15424
- async function nodeOnlyModule(specifier) {
15425
- const parts = specifier.split("/");
15426
- const runtimeSpecifier = parts.join("/");
15427
- return await import(
15428
- /* @vite-ignore */
15429
- /* webpackIgnore: true */
15430
- runtimeSpecifier
15431
- );
15432
- }
15433
- var zlibPromise = null;
15434
- function nodeZlib() {
15435
- zlibPromise ??= nodeBuiltin("zlib");
15436
- return zlibPromise;
15437
- }
15438
- async function throughStream(data, stream) {
15439
- const source = new Blob([data]).stream();
15440
- const piped = source.pipeThrough(stream);
15441
- return new Uint8Array(await new Response(piped).arrayBuffer());
15442
- }
15443
- async function gzip(data) {
15444
- if (isNode) return new Uint8Array((await nodeZlib()).gzipSync(data));
15445
- return throughStream(data, new CompressionStream("gzip"));
15446
- }
15447
- async function gunzip(data) {
15448
- if (isNode) return new Uint8Array((await nodeZlib()).gunzipSync(data));
15449
- return throughStream(data, new DecompressionStream("gzip"));
15450
- }
15451
- async function deflate(data) {
15452
- if (isNode) return new Uint8Array((await nodeZlib()).deflateSync(data));
15453
- return throughStream(data, new CompressionStream("deflate"));
15454
- }
15455
- async function inflate(data) {
15456
- if (isNode) return new Uint8Array((await nodeZlib()).inflateSync(data));
15457
- return throughStream(data, new DecompressionStream("deflate"));
15458
- }
15459
- var cryptoPromise = null;
15460
- function nodeCrypto() {
15461
- cryptoPromise ??= nodeBuiltin("crypto");
15462
- return cryptoPromise;
15463
- }
15464
- var SUBTLE_NAMES = {
15465
- sha1: "SHA-1",
15466
- sha256: "SHA-256",
15467
- sha384: "SHA-384",
15468
- sha512: "SHA-512"
15469
- };
15470
- var UnsupportedAlgorithmError = class extends Error {
15471
- constructor(algorithm) {
15472
- super(`${algorithm} is not available in this environment`);
15473
- this.name = "UnsupportedAlgorithmError";
15474
- }
15475
- };
15476
- async function digestHex(algorithm, data) {
15477
- if (isNode) {
15478
- const { createHash } = await nodeCrypto();
15479
- return createHash(algorithm).update(data).digest("hex");
15480
- }
15481
- if (algorithm === "md5") return md5Hex(data);
15482
- const name = SUBTLE_NAMES[algorithm];
15483
- if (!name) throw new UnsupportedAlgorithmError(algorithm);
15484
- const buffer = await crypto.subtle.digest(name, data);
15485
- return toHex(new Uint8Array(buffer));
15486
- }
15487
- async function randomUuid() {
15488
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
15489
- const { randomUUID } = await nodeCrypto();
15490
- return randomUUID();
15491
- }
15492
- function toHex(bytes2) {
15493
- let out = "";
15494
- for (const byte of bytes2) out += byte.toString(16).padStart(2, "0");
15495
- return out;
15496
- }
15497
- function md5Hex(input) {
15498
- const S = [
15499
- 7,
15500
- 12,
15501
- 17,
15502
- 22,
15503
- 7,
15504
- 12,
15505
- 17,
15506
- 22,
15507
- 7,
15508
- 12,
15509
- 17,
15510
- 22,
15511
- 7,
15512
- 12,
15513
- 17,
15514
- 22,
15515
- 5,
15516
- 9,
15517
- 14,
15518
- 20,
15519
- 5,
15520
- 9,
15521
- 14,
15522
- 20,
15523
- 5,
15524
- 9,
15525
- 14,
15526
- 20,
15527
- 5,
15528
- 9,
15529
- 14,
15530
- 20,
15531
- 4,
15532
- 11,
15533
- 16,
15534
- 23,
15535
- 4,
15536
- 11,
15537
- 16,
15538
- 23,
15539
- 4,
15540
- 11,
15541
- 16,
15542
- 23,
15543
- 4,
15544
- 11,
15545
- 16,
15546
- 23,
15547
- 6,
15548
- 10,
15549
- 15,
15550
- 21,
15551
- 6,
15552
- 10,
15553
- 15,
15554
- 21,
15555
- 6,
15556
- 10,
15557
- 15,
15558
- 21,
15559
- 6,
15560
- 10,
15561
- 15,
15562
- 21
15563
- ];
15564
- const K = new Uint32Array(64);
15565
- for (let i = 0; i < 64; i++) K[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 2 ** 32);
15566
- const bitLength = input.length * 8;
15567
- const padded = new Uint8Array(((input.length + 8 >> 6) + 1) * 64);
15568
- padded.set(input);
15569
- padded[input.length] = 128;
15570
- const view = new DataView(padded.buffer);
15571
- view.setUint32(padded.length - 8, bitLength >>> 0, true);
15572
- view.setUint32(padded.length - 4, Math.floor(bitLength / 2 ** 32), true);
15573
- let a0 = 1732584193;
15574
- let b0 = 4023233417;
15575
- let c0 = 2562383102;
15576
- let d0 = 271733878;
15577
- for (let chunk = 0; chunk < padded.length; chunk += 64) {
15578
- const M = new Uint32Array(16);
15579
- for (let i = 0; i < 16; i++) M[i] = view.getUint32(chunk + i * 4, true);
15580
- let [a, b, c, d] = [a0, b0, c0, d0];
15581
- for (let i = 0; i < 64; i++) {
15582
- let f;
15583
- let g;
15584
- if (i < 16) {
15585
- f = b & c | ~b & d;
15586
- g = i;
15587
- } else if (i < 32) {
15588
- f = d & b | ~d & c;
15589
- g = (5 * i + 1) % 16;
15590
- } else if (i < 48) {
15591
- f = b ^ c ^ d;
15592
- g = (3 * i + 5) % 16;
15593
- } else {
15594
- f = c ^ (b | ~d);
15595
- g = 7 * i % 16;
15596
- }
15597
- const tmp = d;
15598
- d = c;
15599
- c = b;
15600
- const sum = a + f + K[i] + M[g] >>> 0;
15601
- b = b + (sum << S[i] | sum >>> 32 - S[i]) >>> 0;
15602
- a = tmp;
15603
- }
15604
- a0 = a0 + a >>> 0;
15605
- b0 = b0 + b >>> 0;
15606
- c0 = c0 + c >>> 0;
15607
- d0 = d0 + d >>> 0;
15608
- }
15609
- const out = new Uint8Array(16);
15610
- new DataView(out.buffer).setUint32(0, a0, true);
15611
- new DataView(out.buffer).setUint32(4, b0, true);
15612
- new DataView(out.buffer).setUint32(8, c0, true);
15613
- new DataView(out.buffer).setUint32(12, d0, true);
15614
- return toHex(out);
15615
- }
15616
-
15617
- // src/bin/archive.ts
15737
+ init_binary();
15618
15738
  var BLOCK = 512;
15619
15739
  var encoder4 = new TextEncoder();
15620
15740
  var decoder6 = new TextDecoder();
@@ -15927,6 +16047,7 @@ var zlibCompress = defineCommand({
15927
16047
  var commands6 = [tar, gzip2, gunzip2, zcat, zlibCompress];
15928
16048
 
15929
16049
  // src/bin/hash.ts
16050
+ init_binary();
15930
16051
  function makeSum(name, algorithm, path) {
15931
16052
  return defineCommand({
15932
16053
  name,
@@ -17355,7 +17476,7 @@ var wlPaste = defineCommand({
17355
17476
  });
17356
17477
  var commands11 = [xsel, xclip, pbcopy, pbpaste, wlCopy, wlPaste];
17357
17478
 
17358
- // src/runtime/node.ts
17479
+ // src/node/node.ts
17359
17480
  init_path();
17360
17481
  var NODE_VERSION = "v22.12.0";
17361
17482
  new TextEncoder();
@@ -17752,10 +17873,10 @@ function nodeCommands() {
17752
17873
  return [node, nodeVersionFile];
17753
17874
  }
17754
17875
 
17755
- // src/runtime/python.ts
17876
+ // src/python/python.ts
17756
17877
  init_path();
17757
17878
 
17758
- // src/runtime/python/host-abi.ts
17879
+ // src/python/host-abi.ts
17759
17880
  var SBX_HOST_ABI_VERSION = 1;
17760
17881
  var SBX_REQUEST_HEADER_BYTES = 16;
17761
17882
  var SBX_RESPONSE_HEADER_BYTES = 20;
@@ -17868,7 +17989,7 @@ Object.fromEntries(
17868
17989
  Object.entries(Errno).map(([name, code]) => [code, name])
17869
17990
  );
17870
17991
 
17871
- // src/runtime/python/manifest.ts
17992
+ // src/python/manifest.ts
17872
17993
  var MANIFEST_FORMAT = "sandboxedjs-python-runtime";
17873
17994
  var MANIFEST_SCHEMA_VERSION = 1;
17874
17995
  var ManifestError = class extends Error {
@@ -17967,6 +18088,27 @@ var wheels_default = {
17967
18088
  patches: []
17968
18089
  }
17969
18090
  },
18091
+ {
18092
+ name: "numpy",
18093
+ version: "2.2.6",
18094
+ filename: "numpy-2.2.6-cp313-cp313-emscripten_5_0_6_wasm32.whl",
18095
+ sha256: "93ae7230479566b45f715733e92caaeadb1e6fd7b6bfe244e907c2c4eea910bf",
18096
+ abiId: "sbxabi1-c2637d04695ad927",
18097
+ requires: [],
18098
+ provenance: {
18099
+ sourceTreeDigest: "71c23901e3de9adcf52c9e9965279e73f98f45ed7ab9847d7f5f9f1433d4452e",
18100
+ recipeSha256: "b5cde263ce9932472b1c17ee74d80ac194f938ca8e4c3415faedd0abe69c3e09",
18101
+ buildTools: [
18102
+ "setuptools==84.0.0",
18103
+ "meson-python==0.21.0",
18104
+ "meson==1.12.0",
18105
+ "ninja==1.13.2",
18106
+ "Cython==3.1.4"
18107
+ ],
18108
+ nativeDependencies: [],
18109
+ patches: []
18110
+ }
18111
+ },
17970
18112
  {
17971
18113
  name: "pydantic-core",
17972
18114
  version: "2.23.2",
@@ -18044,7 +18186,7 @@ var wheels_default = {
18044
18186
  name: "sbx-meson-probe",
18045
18187
  version: "1.0.0",
18046
18188
  filename: "sbx_meson_probe-1.0.0-cp313-cp313-emscripten_5_0_6_wasm32.whl",
18047
- sha256: "f3efc427caa9ab45c85af554b19c06f0d227852682972894484f9b024a6cb586",
18189
+ sha256: "3ad378e05668ec190f76605e312a47a12009879a13cc083574b03c8cdbbf5ed5",
18048
18190
  abiId: "sbxabi1-c2637d04695ad927",
18049
18191
  requires: [
18050
18192
  "typing-extensions>=4.0"
@@ -18180,7 +18322,7 @@ var wheels_default = {
18180
18322
  name: "siphash24",
18181
18323
  version: "1.9",
18182
18324
  filename: "siphash24-1.9-cp313-cp313-emscripten_5_0_6_wasm32.whl",
18183
- sha256: "cf672c37b0f8e4cd198e5fdd4c6c84036d1d4da36f889564385c1eacfb7c3295",
18325
+ sha256: "41e76fde2f7ed45f801e73c7ed65b7f0ea0465966915e5415c96e782f8cbfc48",
18184
18326
  abiId: "sbxabi1-c2637d04695ad927",
18185
18327
  requires: [],
18186
18328
  provenance: {
@@ -18204,9 +18346,17 @@ var wheels_default = {
18204
18346
 
18205
18347
  // package.json
18206
18348
  var package_default = {
18207
- version: "0.1.71"};
18349
+ version: "0.1.73"};
18208
18350
 
18209
- // src/runtime/python/config.ts
18351
+ // src/python/config.ts
18352
+ function runtimeModuleUrl() {
18353
+ const url = new URL(
18354
+ import.meta.url.includes("/src/python/") ? "../../dist/python/python.js" : "./python/python.js",
18355
+ import.meta.url
18356
+ );
18357
+ if (url.protocol !== "file:") url.searchParams.set("sbx-runtime", package_default.version);
18358
+ return url;
18359
+ }
18210
18360
  var bundledManifest = {
18211
18361
  format: "sandboxedjs-python-runtime",
18212
18362
  schemaVersion: 1,
@@ -18215,16 +18365,7 @@ var bundledManifest = {
18215
18365
  pythonVersion: "3.13.5",
18216
18366
  profile: "dynamic",
18217
18367
  hostAbi: { name: "sbx_host_v1", version: 1 },
18218
- artifacts: {
18219
- moduleUrl: (() => {
18220
- const url = new URL(
18221
- import.meta.url.includes("/src/runtime/python/") ? "../../../dist/python/python.js" : "./python/python.js",
18222
- import.meta.url
18223
- );
18224
- if (url.protocol !== "file:") url.searchParams.set("sbx-runtime", package_default.version);
18225
- return url.href;
18226
- })()
18227
- },
18368
+ artifacts: { moduleUrl: runtimeModuleUrl().href },
18228
18369
  capabilities: {
18229
18370
  threads: true,
18230
18371
  nativeExtensions: "dynamic",
@@ -18233,24 +18374,31 @@ var bundledManifest = {
18233
18374
  persistence: "memory"
18234
18375
  }
18235
18376
  };
18236
- var bundledWheelNames = {
18377
+ var embeddedWheels = {
18237
18378
  "pydantic_core-2.23.2-cp313-cp313-emscripten_5_0_6_wasm32.whl": pydantic_core_2_23_2_cp313_cp313_emscripten_5_0_6_wasm32_default,
18238
18379
  "pydantic_core-2.46.5-cp313-cp313-emscripten_5_0_6_wasm32.whl": pydantic_core_2_46_5_cp313_cp313_emscripten_5_0_6_wasm32_default
18239
18380
  };
18240
18381
  var bundledWheelIndex = {
18241
- baseUrl: "sbx-wheel:",
18242
- wheels: wheels_default.wheels.filter(
18243
- (wheel) => wheel.filename in bundledWheelNames
18244
- ),
18245
- files: bundledWheelNames
18382
+ baseUrl: new URL("./wheels", runtimeModuleUrl()).href,
18383
+ wheels: wheels_default.wheels,
18384
+ files: embeddedWheels
18246
18385
  };
18247
18386
  var config = {
18248
18387
  backend: "sbx-cpython-wasm",
18249
18388
  manifest: bundledManifest,
18250
- wheelIndex: bundledWheelIndex
18389
+ wheelIndex: bundledWheelIndex,
18390
+ /* On by default only where it can possibly work: a Node process, running
18391
+ * from a checkout that has the build pipeline. A browser has no compiler and
18392
+ * never will, and a published package has no pipeline -- in both, building
18393
+ * would replace a clear "no wheel for this package" with a hang or a
18394
+ * confusing failure, so both keep reporting instead. `local-builder` checks
18395
+ * for the pipeline again before it runs, so this is a cheap hint rather than
18396
+ * a promise. */
18397
+ buildFromSource: typeof process !== "undefined" && Boolean(process.versions?.node) && import.meta.url.startsWith("file:")
18251
18398
  };
18252
18399
  function setPythonBackend(options) {
18253
18400
  if (options.wheelIndex !== void 0) config.wheelIndex = options.wheelIndex;
18401
+ if (options.buildFromSource !== void 0) config.buildFromSource = options.buildFromSource;
18254
18402
  if (options.manifest !== void 0) config.manifest = validateManifest(options.manifest);
18255
18403
  if (options.workerUrl !== void 0) config.workerUrl = options.workerUrl;
18256
18404
  if (options.backend !== void 0) {
@@ -18924,10 +19072,11 @@ var FileService = class {
18924
19072
  }
18925
19073
  };
18926
19074
 
18927
- // src/runtime/python/backend.ts
19075
+ // src/python/backend.ts
18928
19076
  init_signals();
19077
+ init_binary();
18929
19078
 
18930
- // src/runtime/python/protocol.ts
19079
+ // src/python/protocol.ts
18931
19080
  var ProtocolError = class extends Error {
18932
19081
  code = "ERR_SBX_ABI_PROTOCOL";
18933
19082
  };
@@ -19404,7 +19553,7 @@ var VirtualTcpNetwork = class {
19404
19553
  }
19405
19554
  };
19406
19555
 
19407
- // src/runtime/python/syscall-server.ts
19556
+ // src/python/syscall-server.ts
19408
19557
  var MAX_TRANSFER = 8 * 1024 * 1024;
19409
19558
  var POLLIN = 1;
19410
19559
  var POLLOUT = 4;
@@ -19853,7 +20002,7 @@ function encodeStat(st) {
19853
20002
  return new Writer().u64(st.ino).u32(st.mode).u64(st.size).u32(st.uid).u32(st.gid).u32(st.nlink).i64(Math.round(st.atimeMs * 1e6)).i64(Math.round(st.mtimeMs * 1e6)).i64(Math.round(st.ctimeMs * 1e6)).finish();
19854
20003
  }
19855
20004
 
19856
- // src/runtime/python/sync-transport.ts
20005
+ // src/python/sync-transport.ts
19857
20006
  var STATE = 0;
19858
20007
  var LENGTH = 1;
19859
20008
  var MORE = 2;
@@ -19956,7 +20105,7 @@ function concat3(parts) {
19956
20105
  return joined;
19957
20106
  }
19958
20107
 
19959
- // src/runtime/worker-host.ts
20108
+ // src/worker/worker-host.ts
19960
20109
  function defaultWorkerUrl() {
19961
20110
  return new URL("./worker-entry.js", import.meta.url);
19962
20111
  }
@@ -20027,7 +20176,7 @@ async function startNodeWorker(url, workerData) {
20027
20176
  };
20028
20177
  }
20029
20178
 
20030
- // src/runtime/python/supervisor.ts
20179
+ // src/python/supervisor.ts
20031
20180
  var nextGeneration = 1;
20032
20181
  async function startPythonProcess(options) {
20033
20182
  const unavailable2 = syncTransportUnavailableReason();
@@ -20142,10 +20291,10 @@ async function startPythonProcess(options) {
20142
20291
  };
20143
20292
  }
20144
20293
 
20145
- // src/runtime/python/install.ts
20294
+ // src/python/install.ts
20146
20295
  init_zip();
20147
20296
 
20148
- // src/runtime/python/pypi.ts
20297
+ // src/python/pypi.ts
20149
20298
  function parseRequirement(text2) {
20150
20299
  const cleaned = text2.replace(/#.*$/, "").trim();
20151
20300
  if (!cleaned) return null;
@@ -20224,7 +20373,7 @@ function splitOnce(text2, separator) {
20224
20373
  return at < 0 ? [text2] : [text2.slice(0, at), text2.slice(at + 1)];
20225
20374
  }
20226
20375
 
20227
- // src/runtime/python/extension-abi.ts
20376
+ // src/python/extension-abi.ts
20228
20377
  var EXTENSION_ABI = {
20229
20378
  "abiId": "sbxabi1-c2637d04695ad927",
20230
20379
  "wheelTag": "cp313-cp313-emscripten_5_0_6_wasm32",
@@ -20238,7 +20387,7 @@ var EXTENSION_ABI = {
20238
20387
  var WHEEL_TAG = EXTENSION_ABI.wheelTag;
20239
20388
  var PURE_PYTHON_TAGS = EXTENSION_ABI.wheel.acceptedPurePythonTags;
20240
20389
 
20241
- // src/runtime/python/resolver.ts
20390
+ // src/python/resolver.ts
20242
20391
  var WHEEL_INDEX_SCHEMA_VERSION = 1;
20243
20392
  function assertIndexUsable(index) {
20244
20393
  const declared = index.schemaVersion;
@@ -20548,7 +20697,7 @@ function requiresFromMetadata(text2) {
20548
20697
  return result;
20549
20698
  }
20550
20699
 
20551
- // src/runtime/python/install.ts
20700
+ // src/python/install.ts
20552
20701
  var SITE_PACKAGES = "/usr/lib/python3.13/site-packages";
20553
20702
  var SCRIPTS = "/usr/local/bin";
20554
20703
  function markerEnvironment(pythonVersion) {
@@ -20675,7 +20824,7 @@ if __name__ == '__main__':
20675
20824
  `;
20676
20825
  }
20677
20826
 
20678
- // src/runtime/python/backend.ts
20827
+ // src/python/backend.ts
20679
20828
  var PENDING_INHERITANCE = /* @__PURE__ */ new Map();
20680
20829
  var INHERIT_TOKEN = "SBX_PYTHON_INHERIT";
20681
20830
  var WNOHANG = 1;
@@ -20828,7 +20977,7 @@ async function resolveWorkerUrl(explicit) {
20828
20977
  nodeBuiltin("url")
20829
20978
  ]);
20830
20979
  if (existsSync(fileURLToPath2(beside))) return beside;
20831
- const built = new URL("../../../dist/python-worker.js", import.meta.url);
20980
+ const built = new URL("../../dist/python-worker.js", import.meta.url);
20832
20981
  if (existsSync(fileURLToPath2(built))) return pathToFileURL2(fileURLToPath2(built));
20833
20982
  throw new Error(
20834
20983
  "the SandboxedJs Python process worker has not been built; run `npm run build` in the package, or pass configurePython({ workerUrl })."
@@ -20913,7 +21062,76 @@ function containerMounts(ctx) {
20913
21062
  return mounts;
20914
21063
  }
20915
21064
 
20916
- // src/runtime/python/pip-command.ts
21065
+ // src/python/pip-command.ts
21066
+ init_binary();
21067
+ async function requestRemoteBuild(service, requirement, line) {
21068
+ line(`Asking ${new URL(service).host} to build ${requirement}`);
21069
+ try {
21070
+ const deadline = Date.now() + 20 * 6e4;
21071
+ let verdict = {};
21072
+ for (; ; ) {
21073
+ const response = await fetch(service, {
21074
+ method: "POST",
21075
+ headers: { "content-type": "application/json" },
21076
+ body: JSON.stringify({ requirement })
21077
+ });
21078
+ if (!response.ok) {
21079
+ return {
21080
+ built: false,
21081
+ index: null,
21082
+ classification: "blocked-toolchain",
21083
+ reason: `${service} answered ${response.status}`
21084
+ };
21085
+ }
21086
+ verdict = await response.json();
21087
+ if (verdict.state !== "building-wheel" && verdict.state !== "queued") break;
21088
+ if (Date.now() > deadline) {
21089
+ return {
21090
+ built: false,
21091
+ index: null,
21092
+ classification: "blocked-toolchain",
21093
+ reason: `${service} is still building ${requirement} after 20 minutes`
21094
+ };
21095
+ }
21096
+ await new Promise((wait) => setTimeout(wait, 3e3));
21097
+ }
21098
+ if (!verdict.built) {
21099
+ return {
21100
+ built: false,
21101
+ index: null,
21102
+ classification: verdict.classification ?? "blocked-toolchain",
21103
+ reason: verdict.reason ?? "the build service reported no wheel"
21104
+ };
21105
+ }
21106
+ const base2 = (verdict.indexUrl ?? service.replace(/\/build\/?$/, "")).replace(/\/$/, "");
21107
+ const fresh = await fetch(`${base2}/index.json`, { cache: "no-store" });
21108
+ if (!fresh.ok) {
21109
+ return {
21110
+ built: false,
21111
+ index: null,
21112
+ classification: "blocked-toolchain",
21113
+ reason: `${base2}/index.json answered ${fresh.status} after the build`
21114
+ };
21115
+ }
21116
+ const loaded = await fresh.json();
21117
+ line(`Built ${requirement}`);
21118
+ return {
21119
+ built: true,
21120
+ index: {
21121
+ baseUrl: base2,
21122
+ wheels: loaded.wheels ?? [],
21123
+ ...loaded.schemaVersion === void 0 ? {} : { schemaVersion: loaded.schemaVersion }
21124
+ }
21125
+ };
21126
+ } catch (error) {
21127
+ return {
21128
+ built: false,
21129
+ index: null,
21130
+ classification: "blocked-toolchain",
21131
+ reason: `could not reach the build service at ${service}: ${error.message}`
21132
+ };
21133
+ }
21134
+ }
20917
21135
  var pipCommand = defineCommand({
20918
21136
  name: "pip",
20919
21137
  path: "/usr/bin/pip",
@@ -20966,15 +21184,19 @@ environments. A package with no usable wheel is an error, never a silent skip.`,
20966
21184
  const cache = /* @__PURE__ */ new Map();
20967
21185
  let embeddedFiles = {};
20968
21186
  const request = async (url, timeoutMs, read) => {
20969
- if (url.startsWith("sbx-wheel:")) {
20970
- const filename = decodeURIComponent(url.slice("sbx-wheel:".length).replace(/^\/+/, ""));
20971
- const encoded = embeddedFiles[filename];
20972
- if (!encoded) throw new Error(`bundled wheel ${filename} is missing`);
20973
- const binary = atob(encoded);
21187
+ const embedded = embeddedFiles[decodeURIComponent(
21188
+ url.replace(/[?#].*$/, "").split("/").pop() ?? ""
21189
+ )];
21190
+ if (embedded) {
21191
+ const binary = atob(embedded);
20974
21192
  const bytes2 = new Uint8Array(binary.length);
20975
21193
  for (let i = 0; i < binary.length; i += 1) bytes2[i] = binary.charCodeAt(i);
20976
21194
  return await read(new Response(bytes2));
20977
21195
  }
21196
+ if (url.startsWith("sbx-wheel:")) {
21197
+ const filename = decodeURIComponent(url.slice("sbx-wheel:".length).replace(/^\/+/, ""));
21198
+ throw new Error(`bundled wheel ${filename} is missing`);
21199
+ }
20978
21200
  if (url.startsWith("file:")) {
20979
21201
  try {
20980
21202
  const [{ readFile }, { fileURLToPath: fileURLToPath2 }] = await Promise.all([
@@ -21035,29 +21257,48 @@ environments. A package with no usable wheel is an error, never a silent skip.`,
21035
21257
  index = configured;
21036
21258
  embeddedFiles = configured.files ?? {};
21037
21259
  }
21038
- try {
21039
- const report = await installRequirements({
21040
- index,
21041
- client,
21042
- vfs: ctx.vfs,
21043
- cred: ctx.cred,
21044
- requirements,
21045
- pythonVersion: pythonBackend().manifest?.pythonVersion ?? "3.13.5",
21046
- progress: {
21047
- collecting: (name) => ctx.line(`Collecting ${name}`),
21048
- downloading: () => {
21260
+ let attemptsLeft = 12;
21261
+ for (; ; ) {
21262
+ try {
21263
+ const report = await installRequirements({
21264
+ index,
21265
+ client,
21266
+ vfs: ctx.vfs,
21267
+ cred: ctx.cred,
21268
+ requirements,
21269
+ pythonVersion: pythonBackend().manifest?.pythonVersion ?? "3.13.5",
21270
+ progress: {
21271
+ collecting: (name) => ctx.line(`Collecting ${name}`),
21272
+ downloading: () => {
21273
+ }
21049
21274
  }
21275
+ });
21276
+ for (const skipped of report.skipped) {
21277
+ ctx.line(` Skipping ${skipped.name} (marker: ${skipped.marker})`);
21050
21278
  }
21051
- });
21052
- for (const skipped of report.skipped) {
21053
- ctx.line(` Skipping ${skipped.name} (marker: ${skipped.marker})`);
21279
+ ctx.line(
21280
+ `Successfully installed ${report.installed.map((p) => `${p.name}-${p.version}`).join(" ")}`
21281
+ );
21282
+ return 0;
21283
+ } catch (error) {
21284
+ const failure2 = error.failure;
21285
+ const buildable = failure2?.reason === "no-compatible-distribution" && Boolean(failure2.package) && failure2.sourceAvailable === true;
21286
+ if (!buildable || !pythonBackend().buildFromSource || attemptsLeft <= 0) {
21287
+ return ctx.fail(error.message ?? String(error));
21288
+ }
21289
+ attemptsLeft -= 1;
21290
+ const builder = pythonBackend().buildFromSource;
21291
+ const outcome = typeof builder === "string" ? await requestRemoteBuild(builder, failure2.package, (l) => ctx.line(l)) : await (await Promise.resolve().then(() => (init_local_builder(), local_builder_exports))).buildFromSource(failure2.package, (line) => ctx.line(line));
21292
+ if (!outcome.built) {
21293
+ return ctx.fail(
21294
+ `${error.message}
21295
+ ${outcome.classification}: ${outcome.reason}`
21296
+ );
21297
+ }
21298
+ if (outcome.index) index = outcome.index;
21299
+ embeddedFiles = { ...embeddedFiles, ...outcome.index?.files ?? {} };
21300
+ cache.clear();
21054
21301
  }
21055
- ctx.line(
21056
- `Successfully installed ${report.installed.map((p) => `${p.name}-${p.version}`).join(" ")}`
21057
- );
21058
- return 0;
21059
- } catch (error) {
21060
- return ctx.fail(error.message ?? String(error));
21061
21302
  }
21062
21303
  }
21063
21304
  });
@@ -21075,7 +21316,7 @@ function listInstalled(ctx) {
21075
21316
  return 0;
21076
21317
  }
21077
21318
 
21078
- // src/runtime/emscripten-fs.ts
21319
+ // src/fs/emscripten-fs.ts
21079
21320
  init_errno();
21080
21321
  init_path();
21081
21322
  var EM_ERRNO = {
@@ -21330,7 +21571,10 @@ function mountContainerFs(FS, opts) {
21330
21571
  }
21331
21572
  }
21332
21573
 
21333
- // src/runtime/python-syscalls.ts
21574
+ // src/python/cpython.ts
21575
+ init_binary();
21576
+
21577
+ // src/python/python-syscalls.ts
21334
21578
  var EMPTY = new Uint8Array(0);
21335
21579
  function createStdinHost(ctx) {
21336
21580
  let pending = EMPTY;
@@ -22067,7 +22311,7 @@ function bindProgram(py, binding) {
22067
22311
  });
22068
22312
  }
22069
22313
 
22070
- // src/runtime/cpython.ts
22314
+ // src/python/cpython.ts
22071
22315
  var RESERVED_FOR_INTERPRETER = /* @__PURE__ */ new Set(["lib", "dev", "proc"]);
22072
22316
  var pyodideModule = null;
22073
22317
  var indexUrl;
@@ -22475,7 +22719,7 @@ var micropip = defineCommand({
22475
22719
  }
22476
22720
  });
22477
22721
 
22478
- // src/runtime/python.ts
22722
+ // src/python/python.ts
22479
22723
  var PYTHON_VERSION = "3.13";
22480
22724
  function configurePython(options = {}) {
22481
22725
  configureCPython({ indexURL: options.indexURL, moduleURL: options.pyodideURL });
@@ -22483,7 +22727,8 @@ function configurePython(options = {}) {
22483
22727
  ...options.backend !== void 0 ? { backend: options.backend } : {},
22484
22728
  ...options.manifest !== void 0 ? { manifest: options.manifest } : {},
22485
22729
  ...options.workerUrl !== void 0 ? { workerUrl: options.workerUrl } : {},
22486
- ...options.wheelIndex !== void 0 ? { wheelIndex: options.wheelIndex } : {}
22730
+ ...options.wheelIndex !== void 0 ? { wheelIndex: options.wheelIndex } : {},
22731
+ ...options.buildFromSource !== void 0 ? { buildFromSource: options.buildFromSource } : {}
22487
22732
  });
22488
22733
  }
22489
22734
  var isPythonAvailable = isCPythonAvailable;
@@ -22587,7 +22832,8 @@ function pythonCommands() {
22587
22832
  return usingOwnedPython() ? [python, pipCommand] : [python, micropip];
22588
22833
  }
22589
22834
 
22590
- // src/runtime/ffmpeg.ts
22835
+ // src/tools/ffmpeg.ts
22836
+ init_binary();
22591
22837
  var INSTALL_HINT = "ffmpeg is not installed in this container.\nThe FFmpeg runtime ships separately because it is a ~31MB WebAssembly build:\n npm install @ffmpeg/core";
22592
22838
  var compiled = null;
22593
22839
  async function loadFactory() {
@@ -24662,7 +24908,7 @@ unless the container was created with network: { allowOutbound: true }.`,
24662
24908
  const packageSpec = packages[0] ?? spec;
24663
24909
  const packageName = packages[0] ? splitPackageSpec(packages[0]).name : specName;
24664
24910
  let command = packages.length > 0 ? spec : basename(specName);
24665
- const run = async (binary) => {
24911
+ const run2 = async (binary) => {
24666
24912
  const env2 = {
24667
24913
  ...ctx.env,
24668
24914
  PATH: `${binDir}:${ctx.env.PATH ?? ""}`,
@@ -24679,8 +24925,8 @@ unless the container was created with network: { allowOutbound: true }.`,
24679
24925
  }).wait();
24680
24926
  };
24681
24927
  if (!version) {
24682
- if (findLocalBin(ctx, command)) return run(command);
24683
- if (ctx.kernel.which(command, ctx.cwd, ctx.env, ctx.cred)) return run(command);
24928
+ if (findLocalBin(ctx, command)) return run2(command);
24929
+ if (ctx.kernel.which(command, ctx.cwd, ctx.env, ctx.cred)) return run2(command);
24684
24930
  }
24685
24931
  if (args.has("no-install")) {
24686
24932
  ctx.warn(`command not found: ${command}`);
@@ -24718,7 +24964,7 @@ unless the container was created with network: { allowOutbound: true }.`,
24718
24964
  }
24719
24965
  command = chosen;
24720
24966
  }
24721
- return run(command);
24967
+ return run2(command);
24722
24968
  }
24723
24969
  });
24724
24970
  function makeNpmAlias(name, path) {
@@ -24912,6 +25158,9 @@ function installUserland(kernel) {
24912
25158
  }
24913
25159
  }
24914
25160
 
25161
+ // src/container/container.ts
25162
+ init_binary();
25163
+
24915
25164
  // src/container/fs.ts
24916
25165
  init_path();
24917
25166
  async function bytesFor(data) {
@@ -25109,7 +25358,7 @@ var Session = class {
25109
25358
  }
25110
25359
  };
25111
25360
 
25112
- // src/runtime/node-child-process-bridge.ts
25361
+ // src/node/node-child-process-bridge.ts
25113
25362
  var KernelChildProcess = class {
25114
25363
  pid;
25115
25364
  command;
@@ -25260,7 +25509,7 @@ function installNodeChildProcessBridge(pod, kernel, cred) {
25260
25509
  };
25261
25510
  }
25262
25511
 
25263
- // src/runtime/host-module-tracker.ts
25512
+ // src/node/host-module-tracker.ts
25264
25513
  var HostModuleTracker = class {
25265
25514
  active = 0;
25266
25515
  disposed = false;
@@ -25322,7 +25571,7 @@ var HostModuleTracker = class {
25322
25571
  }
25323
25572
  };
25324
25573
 
25325
- // src/runtime/commonjs-engine.ts
25574
+ // src/node/commonjs-engine.ts
25326
25575
  init_path();
25327
25576
  var HELPERS = {
25328
25577
  /** Import a specifier and return an ES-module-shaped namespace. */
@@ -26181,7 +26430,7 @@ function splitSpecifier(specifier) {
26181
26430
  return { name: parts.slice(0, size).join("/"), subpath: parts.slice(size).join("/") };
26182
26431
  }
26183
26432
 
26184
- // src/runtime/readable-from.ts
26433
+ // src/node/readable-from.ts
26185
26434
  function createReadableFrom(Readable) {
26186
26435
  return function from(source, options = {}) {
26187
26436
  if (source && typeof source.pipe === "function") return source;
@@ -26230,7 +26479,7 @@ function installReadableFrom(streamModule5) {
26230
26479
  streamModule5.Readable.from = createReadableFrom(streamModule5.Readable);
26231
26480
  }
26232
26481
 
26233
- // src/runtime/util-module.ts
26482
+ // src/node/util-module.ts
26234
26483
  var customInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
26235
26484
  var promisifyCustom = /* @__PURE__ */ Symbol.for("nodejs.util.promisify.custom");
26236
26485
  var BREAK_LENGTH = 72;
@@ -26604,7 +26853,7 @@ var utilModule = {
26604
26853
  };
26605
26854
  var util_module_default = utilModule;
26606
26855
 
26607
- // src/runtime/assert-module.ts
26856
+ // src/node/assert-module.ts
26608
26857
  var AssertionError = class extends Error {
26609
26858
  actual;
26610
26859
  expected;
@@ -26773,8 +27022,8 @@ var bytes = (data) => {
26773
27022
  if (data instanceof ArrayBuffer) return new Uint8Array(data);
26774
27023
  return data;
26775
27024
  };
26776
- function codec(name, run) {
26777
- const sync2 = (data, options) => Buffer2.from(run(bytes(data), options));
27025
+ function codec(name, run2) {
27026
+ const sync2 = (data, options) => Buffer2.from(run2(bytes(data), options));
26778
27027
  const async_ = (data, options, callback) => {
26779
27028
  const done = typeof options === "function" ? options : callback;
26780
27029
  const settings = typeof options === "function" ? void 0 : options;
@@ -26938,7 +27187,7 @@ var urlModule = {
26938
27187
  };
26939
27188
  var url_module_default = urlModule;
26940
27189
 
26941
- // src/runtime/core-modules.ts
27190
+ // src/node/core-modules.ts
26942
27191
  init_path();
26943
27192
  var VirtualIncomingMessage = class extends streamModule4.Readable {
26944
27193
  method;
@@ -27662,7 +27911,7 @@ function toBytes2(data, encoding) {
27662
27911
  return typeof data === "string" ? Buffer2.from(data, encoding) : data;
27663
27912
  }
27664
27913
 
27665
- // src/runtime/sync-channel.ts
27914
+ // src/worker/sync-channel.ts
27666
27915
  var STATE2 = 0;
27667
27916
  var LENGTH2 = 1;
27668
27917
  var MORE2 = 2;
@@ -27911,7 +28160,7 @@ function buildSyncFamily(syncSpawn, throughShell, defaultCwd, environmentFor) {
27911
28160
  spawnSync: unavailable("spawnSync")
27912
28161
  };
27913
28162
  }
27914
- const run = (file3, args, options) => {
28163
+ const run2 = (file3, args, options) => {
27915
28164
  const resolved = options.shell ? throughShell([file3, ...args].join(" "), options) : { file: file3, args };
27916
28165
  const input = options.input === void 0 ? void 0 : typeof options.input === "string" ? options.input : new TextDecoder().decode(options.input);
27917
28166
  const inherit = options.stdio === "inherit" || Array.isArray(options.stdio) && options.stdio[0] === "inherit";
@@ -27945,7 +28194,7 @@ ${result.stderr}`), {
27945
28194
  };
27946
28195
  const spawnSync = (file3, args = [], options = {}) => {
27947
28196
  const [list, opts] = Array.isArray(args) ? [args, options] : [[], args];
27948
- const result = run(file3, list, opts);
28197
+ const result = run2(file3, list, opts);
27949
28198
  return {
27950
28199
  pid: 0,
27951
28200
  status: result.status,
@@ -27958,9 +28207,9 @@ ${result.stderr}`), {
27958
28207
  };
27959
28208
  const execFileSync = (file3, args = [], options = {}) => {
27960
28209
  const [list, opts] = Array.isArray(args) ? [args, options] : [[], args];
27961
- return orThrow(run(file3, list, opts), [file3, ...list].join(" "), opts);
28210
+ return orThrow(run2(file3, list, opts), [file3, ...list].join(" "), opts);
27962
28211
  };
27963
- const execSync = (command, options = {}) => orThrow(run(command, [], { ...options, shell: options.shell ?? true }), command, options);
28212
+ const execSync = (command, options = {}) => orThrow(run2(command, [], { ...options, shell: options.shell ?? true }), command, options);
27964
28213
  return { spawnSync, execFileSync, execSync };
27965
28214
  }
27966
28215
  function normalize3(options, callback) {
@@ -27980,7 +28229,7 @@ function unavailable(name) {
27980
28229
  };
27981
28230
  }
27982
28231
 
27983
- // src/runtime/core-modules.ts
28232
+ // src/node/core-modules.ts
27984
28233
  init_signals();
27985
28234
  var CSI_KEYS = {
27986
28235
  "[A": "up",
@@ -28387,7 +28636,7 @@ function createReadlineModule(defaultInput, defaultOutput = () => void 0) {
28387
28636
  return { ...base2, promises: { ...base2, Interface, createInterface } };
28388
28637
  }
28389
28638
 
28390
- // src/runtime/core-modules.ts
28639
+ // src/node/core-modules.ts
28391
28640
  installReadableFrom(streamModule4);
28392
28641
  var Dirent = class {
28393
28642
  /** Node 20+ exposes the containing directory, and `fs.glob` consumers read it. */
@@ -29555,7 +29804,7 @@ var builtinNames2 = [
29555
29804
  ...stubNames
29556
29805
  ];
29557
29806
 
29558
- // src/runtime/memory-volume.ts
29807
+ // src/fs/memory-volume.ts
29559
29808
  init_path();
29560
29809
  var VolumeError = class extends Error {
29561
29810
  constructor(code, operation, path) {
@@ -29865,7 +30114,7 @@ var MemoryVolume = class {
29865
30114
  }
29866
30115
  };
29867
30116
 
29868
- // src/runtime/mirroring-volume.ts
30117
+ // src/fs/mirroring-volume.ts
29869
30118
  init_path();
29870
30119
  var MirroringVolume = class {
29871
30120
  constructor(inner = new MemoryVolume()) {
@@ -30271,7 +30520,8 @@ function sameBytes(a, b) {
30271
30520
  return true;
30272
30521
  }
30273
30522
 
30274
- // src/runtime/host-esbuild.ts
30523
+ // src/tools/host-esbuild.ts
30524
+ init_binary();
30275
30525
  var ASYNC_API = ["transform", "build", "context", "formatMessages", "analyzeMetafile"];
30276
30526
  function createHostEsbuild() {
30277
30527
  let loading = null;
@@ -30339,7 +30589,8 @@ function ensureProcessGlobal() {
30339
30589
  });
30340
30590
  }
30341
30591
 
30342
- // src/runtime/rolldown-node-binding.ts
30592
+ // src/tools/rolldown-node-binding.ts
30593
+ init_binary();
30343
30594
  async function loadNodeApi() {
30344
30595
  const [moduleApi, fsApi, pathApi, urlApi] = await Promise.all([
30345
30596
  nodeBuiltin("module"),
@@ -30457,7 +30708,7 @@ function resolveWorkerPath(node2) {
30457
30708
  const here = dirname3(fileURLToPath2(import.meta.url));
30458
30709
  const candidates = [
30459
30710
  join3(here, WORKER_FILE),
30460
- /* src/runtime → dist, for a checkout that has been built. */
30711
+ /* src/tools → dist, for a checkout that has been built. */
30461
30712
  join3(here, "..", "..", "dist", WORKER_FILE)
30462
30713
  ];
30463
30714
  return candidates.find((candidate) => existsSync(candidate)) ?? null;
@@ -30491,7 +30742,7 @@ function unreferenceWorker(worker) {
30491
30742
  worker.unref();
30492
30743
  }
30493
30744
 
30494
- // src/runtime/host-rolldown.ts
30745
+ // src/tools/host-rolldown.ts
30495
30746
  var BUNDLER_HINT = "If this is a bundler pre-bundling the worker away, exclude the binding from dependency optimisation \u2014 in Vite:\n\n optimizeDeps: { exclude: ['@rolldown/binding-wasm32-wasi'] }";
30496
30747
  var isNodeHost = typeof process !== "undefined" && Boolean(process.versions?.node);
30497
30748
  async function loadHostRolldownBinding() {
@@ -30518,7 +30769,7 @@ ${BUNDLER_HINT}`),
30518
30769
  }
30519
30770
  }
30520
30771
 
30521
- // src/runtime/local-runtime-pod.ts
30772
+ // src/worker/local-runtime-pod.ts
30522
30773
  init_path();
30523
30774
  var WASM_ALIASES = {
30524
30775
  esbuild: "esbuild-wasm",
@@ -31157,7 +31408,7 @@ function attachRolldownMirror(binding, volume, root) {
31157
31408
  volume.attach(fs, root);
31158
31409
  }
31159
31410
 
31160
- // src/runtime/remote-volume.ts
31411
+ // src/fs/remote-volume.ts
31161
31412
  var encoder8 = new TextEncoder();
31162
31413
  var decoder8 = new TextDecoder();
31163
31414
  function encodeFrame(header, body) {
@@ -31220,7 +31471,7 @@ function serveVolume(volume) {
31220
31471
  };
31221
31472
  }
31222
31473
 
31223
- // src/runtime/sync-syscalls.ts
31474
+ // src/worker/sync-syscalls.ts
31224
31475
  var SPAWN_OP = "spawnSync";
31225
31476
  function serveSyncSyscalls(options) {
31226
31477
  const volumeHandler = serveVolume(options.volume);