@poe-platform/safe-bash 0.1.652 → 0.1.654

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.
Files changed (50) hide show
  1. package/dist/pandoc/ast-types.d.ts +54 -0
  2. package/dist/pandoc/ast.d.ts +14 -0
  3. package/dist/pandoc/cli.d.ts +13 -0
  4. package/dist/pandoc/engine.d.ts +5 -0
  5. package/dist/pandoc/errors.d.ts +13 -0
  6. package/dist/pandoc/execution.d.ts +47 -0
  7. package/dist/pandoc/formats/index.d.ts +2 -0
  8. package/dist/pandoc/formats.d.ts +76 -0
  9. package/dist/pandoc/index.d.ts +14 -0
  10. package/dist/pandoc/inspection.d.ts +5 -0
  11. package/dist/pandoc/safe-bash.d.ts +38 -0
  12. package/dist/pandoc/types.d.ts +229 -0
  13. package/dist/pdf/default-font.d.ts +4 -0
  14. package/dist/pdf/errors.d.ts +4 -0
  15. package/dist/pdf/index.d.ts +32 -0
  16. package/dist/pdf/model.d.ts +92 -0
  17. package/dist/safe-bash/chunks/{chunk-IX6VL7KM.js → chunk-43HWIHXB.js} +122 -81
  18. package/dist/safe-bash/chunks/chunk-43HWIHXB.js.map +7 -0
  19. package/dist/safe-bash/chunks/{chunk-MQJRBELV.js → chunk-EYC5LGC7.js} +2 -2
  20. package/dist/safe-bash/chunks/chunk-EYC5LGC7.js.map +7 -0
  21. package/dist/safe-bash/chunks/chunk-Y7MAMRAF.js +143 -0
  22. package/dist/safe-bash/chunks/chunk-Y7MAMRAF.js.map +7 -0
  23. package/dist/safe-bash/commands/node/index.browser.js +1 -1
  24. package/dist/safe-bash/commands/pandoc/index.d.ts +11 -0
  25. package/dist/safe-bash/commands/pandoc/index.d.ts.map +1 -0
  26. package/dist/safe-bash/commands/pandoc/index.js +112084 -0
  27. package/dist/safe-bash/commands/pandoc/index.js.map +7 -0
  28. package/dist/safe-bash/commands/python/diagnostics.d.ts +42 -0
  29. package/dist/safe-bash/commands/python/diagnostics.d.ts.map +1 -0
  30. package/dist/safe-bash/commands/python/diagnostics.js +68 -0
  31. package/dist/safe-bash/commands/python/diagnostics.js.map +1 -0
  32. package/dist/safe-bash/commands/python/index.browser.js +7 -2
  33. package/dist/safe-bash/commands/python/index.d.ts +4 -0
  34. package/dist/safe-bash/commands/python/index.d.ts.map +1 -1
  35. package/dist/safe-bash/commands/python/index.js +120 -67
  36. package/dist/safe-bash/commands/python/index.js.map +1 -1
  37. package/dist/safe-bash/commands/python/node.js +2 -2
  38. package/dist/safe-bash/commands/python/node.js.map +1 -1
  39. package/dist/safe-bash/commands/python/worker.browser.js +41 -12
  40. package/dist/safe-bash/commands/python/worker.browser.js.map +2 -2
  41. package/dist/safe-bash/commands/python/worker.d.ts.map +1 -1
  42. package/dist/safe-bash/commands/python/worker.js +41 -12
  43. package/dist/safe-bash/commands/python/worker.js.map +1 -1
  44. package/dist/safe-bash/core.browser.js +8 -3
  45. package/dist/safe-bash/core.browser.js.map +1 -1
  46. package/package.json +9 -3
  47. package/dist/safe-bash/chunks/chunk-IX6VL7KM.js.map +0 -7
  48. package/dist/safe-bash/chunks/chunk-JZDO5MC3.js +0 -77
  49. package/dist/safe-bash/chunks/chunk-JZDO5MC3.js.map +0 -7
  50. 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
- parsePythonInvocation
7
- } from "./chunk-JZDO5MC3.js";
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 TypeError("Python requires an explicit interpreter worker factory");
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
- await writeBytes(context.stderr, new TextEncoder().encode("python: worker capacity exhausted\n"), context.signal);
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
- if (typeof SharedArrayBuffer !== "function") throw new Error("Python worker filesystem requires SharedArrayBuffer");
1321
- const shared = new SharedArrayBuffer(8 + maxTransferBytes * 6 + 65536);
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
- Atomics.store(control, 1, bytes.length);
1336
- Atomics.store(control, 0, status);
1337
- Atomics.notify(control, 0);
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
- endpoint = options.createWorker();
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
- unsubscribe = endpoint.subscribe((value) => {
1398
- if (closed || settled) return;
1399
- if (typeof value !== "object" || value === null) {
1400
- fail(new TypeError("Invalid Python worker message"));
1401
- return;
1402
- }
1403
- const message = value;
1404
- if (message.type === "ready") {
1405
- try {
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
- return;
1411
- }
1412
- if (message.type === "exit") {
1413
- if (pending.size) {
1414
- fail(new TypeError("Python worker exited with an outstanding request"));
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
- try {
1418
- const status = validateExitCode(message.exitCode);
1419
- settled = true;
1420
- resolve(status);
1421
- } catch (error) {
1422
- fail(error);
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
- return;
1425
- }
1426
- if (message.type === "error") {
1427
- settled = true;
1428
- const diagnostic = "python: " + (typeof message.message === "string" ? message.message : "Python worker failed") + "\n";
1429
- const work2 = writeBytes(stderrOperation.output, new TextEncoder().encode(diagnostic), signal).then(
1430
- () => {
1431
- pending.delete(work2);
1432
- resolve(1);
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
- pending.delete(work2);
1436
- reject(error);
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(work2);
1440
- return;
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
- if (signal.aborted) {
1454
- fail(signal.reason);
1455
- return;
1456
- }
1457
- if (typeof message.op === "string" && message.op.startsWith("package-")) {
1458
- reply({ code: "EPACKAGE", message: error instanceof Error ? error.message : String(error) }, 2);
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
- endpoint.postMessage(start);
1504
+ try {
1505
+ endpoint.postMessage(start);
1506
+ } catch (reason) {
1507
+ transportFailure(reason);
1508
+ }
1475
1509
  });
1476
1510
  } catch (reason) {
1477
- if (!signal.aborted && (reason instanceof PythonInputChunkError || reason instanceof Error && "code" in reason && reason.code === "EPACKAGE")) {
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) throw primary.reason;
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-IX6VL7KM.js.map
1569
+ //# sourceMappingURL=chunk-43HWIHXB.js.map