sandboxedjs 0.1.69 → 0.1.70
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 +33 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -18
- package/dist/index.js.map +1 -1
- package/dist/python/python.data +148 -135
- package/dist/python/python.js +1 -1
- package/dist/python/python.wasm +0 -0
- package/dist/python/runtime.json +3 -3
- package/dist/python-abi.cjs +4 -0
- package/dist/python-abi.cjs.map +1 -1
- package/dist/python-abi.d.cts +2 -0
- package/dist/python-abi.d.ts +2 -0
- package/dist/python-abi.js +4 -0
- package/dist/python-abi.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17953,7 +17953,7 @@ var wheels_default = {
|
|
|
17953
17953
|
|
|
17954
17954
|
// package.json
|
|
17955
17955
|
var package_default = {
|
|
17956
|
-
version: "0.1.
|
|
17956
|
+
version: "0.1.70"};
|
|
17957
17957
|
|
|
17958
17958
|
// src/runtime/python/config.ts
|
|
17959
17959
|
var bundledManifest = {
|
|
@@ -18498,9 +18498,6 @@ function toPosixError(error) {
|
|
|
18498
18498
|
};
|
|
18499
18499
|
return new PosixError(code && mapped[code] ? mapped[code] : Errno.EIO, message);
|
|
18500
18500
|
}
|
|
18501
|
-
|
|
18502
|
-
// src/runtime/python/backend.ts
|
|
18503
|
-
init_signals();
|
|
18504
18501
|
var DescriptorTable = class _DescriptorTable {
|
|
18505
18502
|
slots = /* @__PURE__ */ new Map();
|
|
18506
18503
|
/** Descriptions this table shares with others, so close counts correctly. */
|
|
@@ -18571,6 +18568,10 @@ var DescriptorTable = class _DescriptorTable {
|
|
|
18571
18568
|
}
|
|
18572
18569
|
}
|
|
18573
18570
|
}
|
|
18571
|
+
/** The numbers this table currently holds, in ascending order. */
|
|
18572
|
+
fds() {
|
|
18573
|
+
return [...this.slots.keys()].sort((a, b) => a - b);
|
|
18574
|
+
}
|
|
18574
18575
|
get openCount() {
|
|
18575
18576
|
return this.slots.size;
|
|
18576
18577
|
}
|
|
@@ -18672,6 +18673,9 @@ var FileService = class {
|
|
|
18672
18673
|
}
|
|
18673
18674
|
};
|
|
18674
18675
|
|
|
18676
|
+
// src/runtime/python/backend.ts
|
|
18677
|
+
init_signals();
|
|
18678
|
+
|
|
18675
18679
|
// src/runtime/python/protocol.ts
|
|
18676
18680
|
var ProtocolError = class extends Error {
|
|
18677
18681
|
code = "ERR_SBX_ABI_PROTOCOL";
|
|
@@ -19787,7 +19791,9 @@ async function startPythonProcess(options) {
|
|
|
19787
19791
|
table.set(0, stdin);
|
|
19788
19792
|
table.set(1, stdout);
|
|
19789
19793
|
table.set(2, stderr);
|
|
19790
|
-
|
|
19794
|
+
const inheritedFds = options.inherit?.fds() ?? [];
|
|
19795
|
+
for (const fd of inheritedFds) table.set(fd, options.inherit.get(fd));
|
|
19796
|
+
options.inherit?.closeAll();
|
|
19791
19797
|
const controller = new AbortController();
|
|
19792
19798
|
const abort = () => controller.abort();
|
|
19793
19799
|
options.signal.addEventListener("abort", abort, { once: true });
|
|
@@ -19871,7 +19877,7 @@ async function startPythonProcess(options) {
|
|
|
19871
19877
|
/* Only beyond the standard three: 0, 1 and 2 are bound as the process's
|
|
19872
19878
|
* terminal-or-pipe streams by the worker itself, and installing a second
|
|
19873
19879
|
* stream over one of them would leave two objects claiming the number. */
|
|
19874
|
-
inheritFds:
|
|
19880
|
+
inheritFds: inheritedFds.filter((fd) => fd > 2)
|
|
19875
19881
|
});
|
|
19876
19882
|
return {
|
|
19877
19883
|
write: (data) => stdin.push(data),
|
|
@@ -20350,11 +20356,18 @@ function consoleLauncher(target) {
|
|
|
20350
20356
|
return `#!/usr/bin/python3
|
|
20351
20357
|
import sys
|
|
20352
20358
|
from importlib import import_module
|
|
20353
|
-
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
|
|
20357
|
-
|
|
20359
|
+
|
|
20360
|
+
|
|
20361
|
+
def _entry():
|
|
20362
|
+
entry = import_module(${JSON.stringify(module)})
|
|
20363
|
+
for part in ${JSON.stringify(attribute)}.split('.'):
|
|
20364
|
+
if part:
|
|
20365
|
+
entry = getattr(entry, part)
|
|
20366
|
+
return entry
|
|
20367
|
+
|
|
20368
|
+
|
|
20369
|
+
if __name__ == '__main__':
|
|
20370
|
+
sys.exit(_entry()())
|
|
20358
20371
|
`;
|
|
20359
20372
|
}
|
|
20360
20373
|
|
|
@@ -20365,10 +20378,10 @@ var WNOHANG = 1;
|
|
|
20365
20378
|
function claimInheritance(env2) {
|
|
20366
20379
|
const token = env2[INHERIT_TOKEN];
|
|
20367
20380
|
if (!token) return void 0;
|
|
20368
|
-
const
|
|
20381
|
+
const held = PENDING_INHERITANCE.get(token);
|
|
20369
20382
|
PENDING_INHERITANCE.delete(token);
|
|
20370
20383
|
delete env2[INHERIT_TOKEN];
|
|
20371
|
-
return
|
|
20384
|
+
return held;
|
|
20372
20385
|
}
|
|
20373
20386
|
function waitStatus(proc) {
|
|
20374
20387
|
if (proc.termSignal) return signalNumber(proc.termSignal) & 127;
|
|
@@ -20395,10 +20408,10 @@ function createProcessService(ctx) {
|
|
|
20395
20408
|
async spawn(request) {
|
|
20396
20409
|
const token = `${ctx.proc.pid}:${Math.random().toString(36).slice(2)}`;
|
|
20397
20410
|
const env2 = { ...request.env };
|
|
20398
|
-
|
|
20399
|
-
|
|
20400
|
-
|
|
20401
|
-
|
|
20411
|
+
const held = new DescriptorTable();
|
|
20412
|
+
for (const [fd, description] of request.files) held.set(fd, description);
|
|
20413
|
+
PENDING_INHERITANCE.set(token, held);
|
|
20414
|
+
env2[INHERIT_TOKEN] = token;
|
|
20402
20415
|
const stdin = request.files.get(0);
|
|
20403
20416
|
const argv = [containerProgram(ctx, request.argv[0] ?? ""), ...request.argv.slice(1)];
|
|
20404
20417
|
const proc = ctx.kernel.spawn(argv, {
|
|
@@ -20411,7 +20424,9 @@ function createProcessService(ctx) {
|
|
|
20411
20424
|
stderr: outputFor(request.files.get(2), ctx.stderr)
|
|
20412
20425
|
});
|
|
20413
20426
|
children.set(proc.pid, proc);
|
|
20414
|
-
void proc.wait().finally(() =>
|
|
20427
|
+
void proc.wait().finally(() => {
|
|
20428
|
+
if (PENDING_INHERITANCE.delete(token)) held.closeAll();
|
|
20429
|
+
});
|
|
20415
20430
|
return proc.pid;
|
|
20416
20431
|
},
|
|
20417
20432
|
async wait(pid, options) {
|