@poe-platform/safe-bash 0.1.651 → 0.1.653
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/pandoc/ast-types.d.ts +54 -0
- package/dist/pandoc/ast.d.ts +14 -0
- package/dist/pandoc/cli.d.ts +13 -0
- package/dist/pandoc/engine.d.ts +5 -0
- package/dist/pandoc/errors.d.ts +13 -0
- package/dist/pandoc/execution.d.ts +47 -0
- package/dist/pandoc/formats/index.d.ts +2 -0
- package/dist/pandoc/formats.d.ts +76 -0
- package/dist/pandoc/index.d.ts +14 -0
- package/dist/pandoc/inspection.d.ts +5 -0
- package/dist/pandoc/safe-bash.d.ts +38 -0
- package/dist/pandoc/types.d.ts +229 -0
- package/dist/pdf/default-font.d.ts +4 -0
- package/dist/pdf/errors.d.ts +4 -0
- package/dist/pdf/index.d.ts +32 -0
- package/dist/pdf/model.d.ts +92 -0
- package/dist/safe-bash/chunks/{chunk-IX6VL7KM.js → chunk-43HWIHXB.js} +122 -81
- package/dist/safe-bash/chunks/chunk-43HWIHXB.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-MQJRBELV.js → chunk-EYC5LGC7.js} +2 -2
- package/dist/safe-bash/chunks/chunk-EYC5LGC7.js.map +7 -0
- package/dist/safe-bash/chunks/chunk-Y7MAMRAF.js +143 -0
- package/dist/safe-bash/chunks/chunk-Y7MAMRAF.js.map +7 -0
- package/dist/safe-bash/commands/node/index.browser.js +1 -1
- package/dist/safe-bash/commands/pandoc/index.d.ts +11 -0
- package/dist/safe-bash/commands/pandoc/index.d.ts.map +1 -0
- package/dist/safe-bash/commands/pandoc/index.js +112084 -0
- package/dist/safe-bash/commands/pandoc/index.js.map +7 -0
- package/dist/safe-bash/commands/python/diagnostics.d.ts +42 -0
- package/dist/safe-bash/commands/python/diagnostics.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/diagnostics.js +68 -0
- package/dist/safe-bash/commands/python/diagnostics.js.map +1 -0
- package/dist/safe-bash/commands/python/index.browser.js +7 -2
- package/dist/safe-bash/commands/python/index.d.ts +4 -0
- package/dist/safe-bash/commands/python/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/python/index.js +120 -67
- package/dist/safe-bash/commands/python/index.js.map +1 -1
- package/dist/safe-bash/commands/python/node.js +2 -2
- package/dist/safe-bash/commands/python/node.js.map +1 -1
- package/dist/safe-bash/commands/python/worker.browser.js +41 -12
- package/dist/safe-bash/commands/python/worker.browser.js.map +2 -2
- package/dist/safe-bash/commands/python/worker.d.ts.map +1 -1
- package/dist/safe-bash/commands/python/worker.js +41 -12
- package/dist/safe-bash/commands/python/worker.js.map +1 -1
- package/dist/safe-bash/core.browser.js +8 -3
- package/dist/safe-bash/core.browser.js.map +1 -1
- package/dist/safe-bash/playwright/adapter.d.ts +1 -0
- package/dist/safe-bash/playwright/adapter.d.ts.map +1 -1
- package/dist/safe-bash/playwright/adapter.js +2 -0
- package/dist/safe-bash/playwright/adapter.js.map +1 -1
- package/package.json +9 -3
- package/dist/safe-bash/chunks/chunk-IX6VL7KM.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-JZDO5MC3.js +0 -77
- package/dist/safe-bash/chunks/chunk-JZDO5MC3.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-MQJRBELV.js.map +0 -7
|
@@ -2,9 +2,12 @@ import {
|
|
|
2
2
|
openCommandFile
|
|
3
3
|
} from "./chunk-2E4KBFO6.js";
|
|
4
4
|
import {
|
|
5
|
+
PythonFailure,
|
|
5
6
|
PythonInvocationError,
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
isPythonFailureCategory,
|
|
8
|
+
parsePythonInvocation,
|
|
9
|
+
reportPythonFailure
|
|
10
|
+
} from "./chunk-Y7MAMRAF.js";
|
|
8
11
|
import {
|
|
9
12
|
createOutputOperation
|
|
10
13
|
} from "./chunk-CDBQXRWL.js";
|
|
@@ -1212,7 +1215,8 @@ function createPythonPackageEnvironment(options = {}) {
|
|
|
1212
1215
|
var PythonInputChunkError = class extends RangeError {
|
|
1213
1216
|
};
|
|
1214
1217
|
function createPythonCommands(options) {
|
|
1215
|
-
if (typeof options?.createWorker !== "function") throw new
|
|
1218
|
+
if (typeof options?.createWorker !== "function") throw new PythonFailure("executor-unavailable");
|
|
1219
|
+
if (options.onDiagnostic !== void 0 && typeof options.onDiagnostic !== "function") throw new TypeError("Python onDiagnostic must be a function");
|
|
1216
1220
|
const maxTransferBytes = options.maxTransferBytes ?? 65536;
|
|
1217
1221
|
const maxOpenFiles = options.maxOpenFiles ?? 256;
|
|
1218
1222
|
const maxConcurrentWorkers = options.maxConcurrentWorkers ?? 4;
|
|
@@ -1245,7 +1249,8 @@ function createPythonCommands(options) {
|
|
|
1245
1249
|
}
|
|
1246
1250
|
context.signal.throwIfAborted();
|
|
1247
1251
|
if (activeWorkers >= maxConcurrentWorkers) {
|
|
1248
|
-
|
|
1252
|
+
const failure2 = reportPythonFailure("capacity", void 0, options.onDiagnostic);
|
|
1253
|
+
await writeBytes(context.stderr, new TextEncoder().encode("python: " + failure2.message + "\n"), context.signal);
|
|
1249
1254
|
return { exitCode: 1 };
|
|
1250
1255
|
}
|
|
1251
1256
|
const controller = new AbortController();
|
|
@@ -1300,7 +1305,7 @@ function createPythonCommands(options) {
|
|
|
1300
1305
|
}
|
|
1301
1306
|
finish();
|
|
1302
1307
|
}, (reason) => {
|
|
1303
|
-
fail(reason);
|
|
1308
|
+
fail(reportPythonFailure("cleanup", reason, options.onDiagnostic));
|
|
1304
1309
|
});
|
|
1305
1310
|
return closing;
|
|
1306
1311
|
};
|
|
@@ -1309,6 +1314,8 @@ function createPythonCommands(options) {
|
|
|
1309
1314
|
};
|
|
1310
1315
|
context.registerCleanup?.(close);
|
|
1311
1316
|
let primary;
|
|
1317
|
+
let ready = false;
|
|
1318
|
+
const filesystemDiagnostics = /* @__PURE__ */ new Set();
|
|
1312
1319
|
let result = 1;
|
|
1313
1320
|
try {
|
|
1314
1321
|
signal.throwIfAborted();
|
|
@@ -1317,8 +1324,12 @@ function createPythonCommands(options) {
|
|
|
1317
1324
|
const outputContext = { signal, ...context.registerCleanup ? { registerCleanup: context.registerCleanup } : {} };
|
|
1318
1325
|
stdoutOperation = createOutputOperation(outputContext, context.stdout);
|
|
1319
1326
|
stderrOperation = createOutputOperation(outputContext, context.stderr);
|
|
1320
|
-
|
|
1321
|
-
|
|
1327
|
+
let shared;
|
|
1328
|
+
try {
|
|
1329
|
+
shared = new SharedArrayBuffer(8 + maxTransferBytes * 6 + 65536);
|
|
1330
|
+
} catch (reason) {
|
|
1331
|
+
throw reportPythonFailure("transport-unavailable", reason, options.onDiagnostic);
|
|
1332
|
+
}
|
|
1322
1333
|
const control = new Int32Array(shared, 0, 2);
|
|
1323
1334
|
const payload = new Uint8Array(shared, 8);
|
|
1324
1335
|
const reply = (value, status) => {
|
|
@@ -1332,9 +1343,13 @@ function createPythonCommands(options) {
|
|
|
1332
1343
|
status = 2;
|
|
1333
1344
|
}
|
|
1334
1345
|
payload.set(bytes);
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1346
|
+
try {
|
|
1347
|
+
Atomics.store(control, 1, bytes.length);
|
|
1348
|
+
Atomics.store(control, 0, status);
|
|
1349
|
+
Atomics.notify(control, 0);
|
|
1350
|
+
} catch (reason) {
|
|
1351
|
+
throw reportPythonFailure("transport-unavailable", reason, options.onDiagnostic);
|
|
1352
|
+
}
|
|
1338
1353
|
};
|
|
1339
1354
|
const dispatch = async (request) => {
|
|
1340
1355
|
signal.throwIfAborted();
|
|
@@ -1384,7 +1399,11 @@ function createPythonCommands(options) {
|
|
|
1384
1399
|
pending.delete(preparation);
|
|
1385
1400
|
}
|
|
1386
1401
|
signal.throwIfAborted();
|
|
1387
|
-
|
|
1402
|
+
try {
|
|
1403
|
+
endpoint = options.createWorker();
|
|
1404
|
+
} catch (reason) {
|
|
1405
|
+
throw reportPythonFailure(reason instanceof PythonFailure ? reason.category : "startup", reason, options.onDiagnostic);
|
|
1406
|
+
}
|
|
1388
1407
|
signal.throwIfAborted();
|
|
1389
1408
|
result = await new Promise((resolve, reject) => {
|
|
1390
1409
|
let settled = false;
|
|
@@ -1394,92 +1413,109 @@ function createPythonCommands(options) {
|
|
|
1394
1413
|
};
|
|
1395
1414
|
rejectRun = fail;
|
|
1396
1415
|
signal.addEventListener("abort", aborted, { once: true });
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
options.onProgress?.({ phase: "ready", command: context.command });
|
|
1407
|
-
} catch (error) {
|
|
1408
|
-
fail(error);
|
|
1416
|
+
const transportFailure = (reason) => {
|
|
1417
|
+
fail(reportPythonFailure("transport-unavailable", reason, options.onDiagnostic));
|
|
1418
|
+
};
|
|
1419
|
+
try {
|
|
1420
|
+
unsubscribe = endpoint.subscribe((value) => {
|
|
1421
|
+
if (closed || settled) return;
|
|
1422
|
+
if (typeof value !== "object" || value === null) {
|
|
1423
|
+
transportFailure(new TypeError("Invalid Python worker message"));
|
|
1424
|
+
return;
|
|
1409
1425
|
}
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1426
|
+
const message = value;
|
|
1427
|
+
if (message.type === "ready") {
|
|
1428
|
+
ready = true;
|
|
1429
|
+
try {
|
|
1430
|
+
options.onProgress?.({ phase: "ready", command: context.command });
|
|
1431
|
+
} catch (error) {
|
|
1432
|
+
fail(error);
|
|
1433
|
+
}
|
|
1415
1434
|
return;
|
|
1416
1435
|
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1436
|
+
if (message.type === "exit") {
|
|
1437
|
+
if (pending.size) {
|
|
1438
|
+
transportFailure(new TypeError("Python worker exited with an outstanding request"));
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
try {
|
|
1442
|
+
const status = validateExitCode(message.exitCode);
|
|
1443
|
+
settled = true;
|
|
1444
|
+
resolve(status);
|
|
1445
|
+
} catch (error) {
|
|
1446
|
+
transportFailure(error);
|
|
1447
|
+
}
|
|
1448
|
+
return;
|
|
1423
1449
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1450
|
+
if (message.type === "error") {
|
|
1451
|
+
fail(reportPythonFailure(isPythonFailureCategory(message.category) ? message.category : ready ? "runtime" : "startup", message.message, options.onDiagnostic));
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
if (typeof message.op !== "string" || !Array.isArray(message.args) || pending.size) {
|
|
1455
|
+
transportFailure(new TypeError("Invalid concurrent Python worker request"));
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
const work = dispatch({ op: message.op, args: message.args }).then(
|
|
1459
|
+
(value2) => {
|
|
1460
|
+
pending.delete(work);
|
|
1461
|
+
reply(value2, 1);
|
|
1433
1462
|
},
|
|
1434
|
-
(error) => {
|
|
1435
|
-
|
|
1436
|
-
|
|
1463
|
+
async (error) => {
|
|
1464
|
+
if (signal.aborted) {
|
|
1465
|
+
pending.delete(work);
|
|
1466
|
+
fail(signal.reason);
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1469
|
+
if (typeof message.op === "string" && message.op.startsWith("package-")) {
|
|
1470
|
+
const failure2 = reportPythonFailure("runtime-assets", error, options.onDiagnostic);
|
|
1471
|
+
pending.delete(work);
|
|
1472
|
+
reply({ code: "EPACKAGE", message: failure2.message }, 2);
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
if (typeof error !== "object" || error === null || !("code" in error) || typeof error.code !== "string") {
|
|
1476
|
+
pending.delete(work);
|
|
1477
|
+
fail(error);
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
if (error.code === "ENOTSUP") {
|
|
1481
|
+
const category = message.op === "open" ? "filesystem-open" : message.op === "read" ? "filesystem-read" : message.op === "write" || message.op === "ftruncate" ? "filesystem-write" : message.op === "readdir" ? "filesystem-directory" : "filesystem-operation";
|
|
1482
|
+
if (!filesystemDiagnostics.has(category)) {
|
|
1483
|
+
filesystemDiagnostics.add(category);
|
|
1484
|
+
const failure2 = reportPythonFailure(category, error, options.onDiagnostic);
|
|
1485
|
+
await writeBytes(stderrOperation.output, new TextEncoder().encode("python: " + failure2.message + "\n"), signal);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
pending.delete(work);
|
|
1489
|
+
reply({ code: error.code }, 2);
|
|
1437
1490
|
}
|
|
1438
1491
|
);
|
|
1439
|
-
pending.add(
|
|
1440
|
-
|
|
1441
|
-
}
|
|
1442
|
-
if (typeof message.op !== "string" || !Array.isArray(message.args) || pending.size) {
|
|
1443
|
-
fail(new TypeError("Invalid concurrent Python worker request"));
|
|
1444
|
-
return;
|
|
1445
|
-
}
|
|
1446
|
-
const work = dispatch({ op: message.op, args: message.args }).then(
|
|
1447
|
-
(value2) => {
|
|
1448
|
-
pending.delete(work);
|
|
1449
|
-
reply(value2, 1);
|
|
1450
|
-
},
|
|
1451
|
-
(error) => {
|
|
1492
|
+
pending.add(work);
|
|
1493
|
+
void work.catch((reason) => {
|
|
1452
1494
|
pending.delete(work);
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
return;
|
|
1460
|
-
}
|
|
1461
|
-
if (typeof error !== "object" || error === null || !("code" in error) || typeof error.code !== "string") {
|
|
1462
|
-
fail(error);
|
|
1463
|
-
return;
|
|
1464
|
-
}
|
|
1465
|
-
reply({ code: error.code }, 2);
|
|
1466
|
-
}
|
|
1467
|
-
);
|
|
1468
|
-
pending.add(work);
|
|
1469
|
-
void work.catch(fail);
|
|
1470
|
-
}, fail);
|
|
1495
|
+
fail(reason);
|
|
1496
|
+
});
|
|
1497
|
+
}, transportFailure);
|
|
1498
|
+
} catch (reason) {
|
|
1499
|
+
transportFailure(reason);
|
|
1500
|
+
}
|
|
1471
1501
|
if (settled) return;
|
|
1472
1502
|
const start = { type: "start", shared, invocation: { command: context.command, args: [...context.args], cwd: context.cwd, env: { ...context.env } }, runtimeMount, maxTransferBytes, ...packages ? { packages } : {}, installOnly: !!installation };
|
|
1473
1503
|
signal.throwIfAborted();
|
|
1474
|
-
|
|
1504
|
+
try {
|
|
1505
|
+
endpoint.postMessage(start);
|
|
1506
|
+
} catch (reason) {
|
|
1507
|
+
transportFailure(reason);
|
|
1508
|
+
}
|
|
1475
1509
|
});
|
|
1476
1510
|
} catch (reason) {
|
|
1477
|
-
if (!signal.aborted &&
|
|
1511
|
+
if (!signal.aborted && reason instanceof PythonInputChunkError) {
|
|
1478
1512
|
try {
|
|
1479
1513
|
await writeBytes(stderrOperation.output, new TextEncoder().encode("python: " + reason.message + "\n"), signal);
|
|
1480
1514
|
} catch (error) {
|
|
1481
1515
|
primary = { reason: error };
|
|
1482
1516
|
}
|
|
1517
|
+
} else if (!signal.aborted && typeof reason === "object" && reason !== null && "code" in reason && reason.code === "EPACKAGE") {
|
|
1518
|
+
primary = { reason: reportPythonFailure("runtime-assets", reason, options.onDiagnostic) };
|
|
1483
1519
|
} else primary = { reason };
|
|
1484
1520
|
}
|
|
1485
1521
|
try {
|
|
@@ -1493,7 +1529,12 @@ function createPythonCommands(options) {
|
|
|
1493
1529
|
primary ??= { reason };
|
|
1494
1530
|
}
|
|
1495
1531
|
context.signal.throwIfAborted();
|
|
1496
|
-
if (primary)
|
|
1532
|
+
if (primary) {
|
|
1533
|
+
if (!(primary.reason instanceof PythonFailure)) throw primary.reason;
|
|
1534
|
+
const failure2 = primary.reason;
|
|
1535
|
+
await writeBytes(context.stderr, new TextEncoder().encode("python: " + failure2.message + "\n"), context.signal);
|
|
1536
|
+
return { exitCode: 1 };
|
|
1537
|
+
}
|
|
1497
1538
|
return { exitCode: result };
|
|
1498
1539
|
};
|
|
1499
1540
|
return ["python", "python3"].map((name) => ({ name, description: "Python with an explicit synchronous interpreter worker and canonical filesystem", execute }));
|
|
@@ -1525,4 +1566,4 @@ export {
|
|
|
1525
1566
|
createPythonCommands,
|
|
1526
1567
|
pythonCommands
|
|
1527
1568
|
};
|
|
1528
|
-
//# sourceMappingURL=chunk-
|
|
1569
|
+
//# sourceMappingURL=chunk-43HWIHXB.js.map
|