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.cjs
CHANGED
|
@@ -17970,7 +17970,7 @@ var wheels_default = {
|
|
|
17970
17970
|
|
|
17971
17971
|
// package.json
|
|
17972
17972
|
var package_default = {
|
|
17973
|
-
version: "0.1.
|
|
17973
|
+
version: "0.1.70"};
|
|
17974
17974
|
|
|
17975
17975
|
// src/runtime/python/config.ts
|
|
17976
17976
|
var bundledManifest = {
|
|
@@ -18515,9 +18515,6 @@ function toPosixError(error) {
|
|
|
18515
18515
|
};
|
|
18516
18516
|
return new PosixError(code && mapped[code] ? mapped[code] : Errno.EIO, message);
|
|
18517
18517
|
}
|
|
18518
|
-
|
|
18519
|
-
// src/runtime/python/backend.ts
|
|
18520
|
-
init_signals();
|
|
18521
18518
|
var DescriptorTable = class _DescriptorTable {
|
|
18522
18519
|
slots = /* @__PURE__ */ new Map();
|
|
18523
18520
|
/** Descriptions this table shares with others, so close counts correctly. */
|
|
@@ -18588,6 +18585,10 @@ var DescriptorTable = class _DescriptorTable {
|
|
|
18588
18585
|
}
|
|
18589
18586
|
}
|
|
18590
18587
|
}
|
|
18588
|
+
/** The numbers this table currently holds, in ascending order. */
|
|
18589
|
+
fds() {
|
|
18590
|
+
return [...this.slots.keys()].sort((a, b) => a - b);
|
|
18591
|
+
}
|
|
18591
18592
|
get openCount() {
|
|
18592
18593
|
return this.slots.size;
|
|
18593
18594
|
}
|
|
@@ -18689,6 +18690,9 @@ var FileService = class {
|
|
|
18689
18690
|
}
|
|
18690
18691
|
};
|
|
18691
18692
|
|
|
18693
|
+
// src/runtime/python/backend.ts
|
|
18694
|
+
init_signals();
|
|
18695
|
+
|
|
18692
18696
|
// src/runtime/python/protocol.ts
|
|
18693
18697
|
var ProtocolError = class extends Error {
|
|
18694
18698
|
code = "ERR_SBX_ABI_PROTOCOL";
|
|
@@ -19804,7 +19808,9 @@ async function startPythonProcess(options) {
|
|
|
19804
19808
|
table.set(0, stdin);
|
|
19805
19809
|
table.set(1, stdout);
|
|
19806
19810
|
table.set(2, stderr);
|
|
19807
|
-
|
|
19811
|
+
const inheritedFds = options.inherit?.fds() ?? [];
|
|
19812
|
+
for (const fd of inheritedFds) table.set(fd, options.inherit.get(fd));
|
|
19813
|
+
options.inherit?.closeAll();
|
|
19808
19814
|
const controller = new AbortController();
|
|
19809
19815
|
const abort = () => controller.abort();
|
|
19810
19816
|
options.signal.addEventListener("abort", abort, { once: true });
|
|
@@ -19888,7 +19894,7 @@ async function startPythonProcess(options) {
|
|
|
19888
19894
|
/* Only beyond the standard three: 0, 1 and 2 are bound as the process's
|
|
19889
19895
|
* terminal-or-pipe streams by the worker itself, and installing a second
|
|
19890
19896
|
* stream over one of them would leave two objects claiming the number. */
|
|
19891
|
-
inheritFds:
|
|
19897
|
+
inheritFds: inheritedFds.filter((fd) => fd > 2)
|
|
19892
19898
|
});
|
|
19893
19899
|
return {
|
|
19894
19900
|
write: (data) => stdin.push(data),
|
|
@@ -20367,11 +20373,18 @@ function consoleLauncher(target) {
|
|
|
20367
20373
|
return `#!/usr/bin/python3
|
|
20368
20374
|
import sys
|
|
20369
20375
|
from importlib import import_module
|
|
20370
|
-
|
|
20371
|
-
|
|
20372
|
-
|
|
20373
|
-
|
|
20374
|
-
|
|
20376
|
+
|
|
20377
|
+
|
|
20378
|
+
def _entry():
|
|
20379
|
+
entry = import_module(${JSON.stringify(module)})
|
|
20380
|
+
for part in ${JSON.stringify(attribute)}.split('.'):
|
|
20381
|
+
if part:
|
|
20382
|
+
entry = getattr(entry, part)
|
|
20383
|
+
return entry
|
|
20384
|
+
|
|
20385
|
+
|
|
20386
|
+
if __name__ == '__main__':
|
|
20387
|
+
sys.exit(_entry()())
|
|
20375
20388
|
`;
|
|
20376
20389
|
}
|
|
20377
20390
|
|
|
@@ -20382,10 +20395,10 @@ var WNOHANG = 1;
|
|
|
20382
20395
|
function claimInheritance(env2) {
|
|
20383
20396
|
const token = env2[INHERIT_TOKEN];
|
|
20384
20397
|
if (!token) return void 0;
|
|
20385
|
-
const
|
|
20398
|
+
const held = PENDING_INHERITANCE.get(token);
|
|
20386
20399
|
PENDING_INHERITANCE.delete(token);
|
|
20387
20400
|
delete env2[INHERIT_TOKEN];
|
|
20388
|
-
return
|
|
20401
|
+
return held;
|
|
20389
20402
|
}
|
|
20390
20403
|
function waitStatus(proc) {
|
|
20391
20404
|
if (proc.termSignal) return signalNumber(proc.termSignal) & 127;
|
|
@@ -20412,10 +20425,10 @@ function createProcessService(ctx) {
|
|
|
20412
20425
|
async spawn(request) {
|
|
20413
20426
|
const token = `${ctx.proc.pid}:${Math.random().toString(36).slice(2)}`;
|
|
20414
20427
|
const env2 = { ...request.env };
|
|
20415
|
-
|
|
20416
|
-
|
|
20417
|
-
|
|
20418
|
-
|
|
20428
|
+
const held = new DescriptorTable();
|
|
20429
|
+
for (const [fd, description] of request.files) held.set(fd, description);
|
|
20430
|
+
PENDING_INHERITANCE.set(token, held);
|
|
20431
|
+
env2[INHERIT_TOKEN] = token;
|
|
20419
20432
|
const stdin = request.files.get(0);
|
|
20420
20433
|
const argv = [containerProgram(ctx, request.argv[0] ?? ""), ...request.argv.slice(1)];
|
|
20421
20434
|
const proc = ctx.kernel.spawn(argv, {
|
|
@@ -20428,7 +20441,9 @@ function createProcessService(ctx) {
|
|
|
20428
20441
|
stderr: outputFor(request.files.get(2), ctx.stderr)
|
|
20429
20442
|
});
|
|
20430
20443
|
children.set(proc.pid, proc);
|
|
20431
|
-
void proc.wait().finally(() =>
|
|
20444
|
+
void proc.wait().finally(() => {
|
|
20445
|
+
if (PENDING_INHERITANCE.delete(token)) held.closeAll();
|
|
20446
|
+
});
|
|
20432
20447
|
return proc.pid;
|
|
20433
20448
|
},
|
|
20434
20449
|
async wait(pid, options) {
|