@poe-platform/safe-bash 0.1.744 → 0.1.745

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.
@@ -139993,6 +139993,16 @@ async function readLotus(bytes, context) {
139993
139993
  active = -1;
139994
139994
  continue;
139995
139995
  }
139996
+ if (version >= 4099 && version <= 4101 && id === 35) {
139997
+ consumeOperation();
139998
+ if (length < 5) await warn(`Record with type 0x23 has wrong length ${length}.`);
139999
+ else {
140000
+ const nameBytes = data3.bytes.subarray(4), zero2 = nameBytes.indexOf(0);
140001
+ const name = new TextDecoder("windows-1252").decode(zero2 < 0 ? nameBytes : nameBytes.subarray(0, zero2));
140002
+ if (name) sheet(data3.u16(2)).name = name;
140003
+ }
140004
+ continue;
140005
+ }
139996
140006
  if (id === (modern ? 9 : 11)) {
139997
140007
  consumeOperation();
139998
140008
  if (length < (modern ? 26 : 24)) {
@@ -140187,11 +140197,12 @@ async function readLotus(bytes, context) {
140187
140197
  else {
140188
140198
  const subtype = data3.u16(0);
140189
140199
  if (subtype === 14e3) {
140190
- if (length <= 5) await warn(`Record with type 0x1b has wrong length ${length}.`);
140200
+ consumeOperation();
140201
+ if (length < 5) await warn(`Record with type 0x1b has wrong length ${length}.`);
140191
140202
  else {
140192
- consumeOperation();
140193
- const nameBytes = data3.bytes.subarray(4, length - 1), zero2 = nameBytes.indexOf(0);
140194
- sheet(data3.u8(2)).name = new TextDecoder().decode(zero2 < 0 ? nameBytes : nameBytes.subarray(0, zero2));
140203
+ const nameBytes = data3.bytes.subarray(4), zero2 = nameBytes.indexOf(0);
140204
+ const name = new TextDecoder("windows-1252").decode(zero2 < 0 ? nameBytes : nameBytes.subarray(0, zero2));
140205
+ if (name) sheet(data3.u16(2)).name = name;
140195
140206
  }
140196
140207
  } else if (subtype === 4001) {
140197
140208
  if (length < 24) await warn(`Record with type 0x1b has wrong length ${length}.`);
@@ -4,6 +4,7 @@ import {
4
4
 
5
5
  // packages/safe-bash-command-wkhtmltopdf/dist/index.js
6
6
  init_buffer();
7
+ import { yieldTurn } from "../safe-bash-contracts/yield.js";
7
8
  import { commandRuntimeIdentity, getCommandArguments } from "../safe-bash-contracts/command.js";
8
9
  import { readBytes, writeBytes } from "../safe-bash-contracts/io.js";
9
10
  import { shellValueByteLength } from "../safe-bash-contracts/value.js";
@@ -51,10 +52,10 @@ var init_limits = __esm({
51
52
  this.options = options;
52
53
  this.checkCancellation();
53
54
  this.limits = {
54
- maxArguments: options.limits?.maxArguments,
55
- maxTextBytes: options.limits?.maxTextBytes,
56
- maxObjects: options.limits?.maxObjects,
57
- maxWork: options.limits?.maxWork
55
+ maxArguments: options.limits?.maxArguments ?? Infinity,
56
+ maxTextBytes: options.limits?.maxTextBytes ?? Infinity,
57
+ maxObjects: options.limits?.maxObjects ?? Infinity,
58
+ maxWork: options.limits?.maxWork ?? Infinity
58
59
  };
59
60
  for (const value of Object.values(this.limits)) {
60
61
  if (value !== Infinity && (!Number.isSafeInteger(value) || value < 1)) {
@@ -842,7 +843,13 @@ var init_outcome = __esm({
842
843
  }
843
844
  });
844
845
  async function withResources(options, run) {
845
- const limits = { ...options.limits };
846
+ const limits = {
847
+ maxInputBytes: options.limits?.maxInputBytes ?? Infinity,
848
+ maxDecodedBytes: options.limits?.maxDecodedBytes ?? Infinity,
849
+ maxRetainedBytes: options.limits?.maxRetainedBytes ?? Infinity,
850
+ maxWork: options.limits?.maxWork ?? Infinity,
851
+ maxResources: options.limits?.maxResources ?? Infinity
852
+ };
846
853
  for (const key of ["maxInputBytes", "maxDecodedBytes", "maxRetainedBytes", "maxWork", "maxResources"]) {
847
854
  if (limits[key] !== Infinity && (!Number.isSafeInteger(limits[key]) || limits[key] < 1)) {
848
855
  throw new WkhtmltopdfError("INVALID_VALUE", "Resource limits must be positive safe integers");
@@ -17290,7 +17297,7 @@ function extractLinks(html) {
17290
17297
  }
17291
17298
  return links;
17292
17299
  }
17293
- function parseHtmlDocument(rawHtml, replacements) {
17300
+ async function parseHtmlDocument(rawHtml, replacements, signal) {
17294
17301
  let html = rawHtml;
17295
17302
  for (const [key, value] of replacements) {
17296
17303
  if (key) html = html.split(key).join(value);
@@ -17302,7 +17309,10 @@ function parseHtmlDocument(rawHtml, replacements) {
17302
17309
  const tokenRegex = /<(h[1-6]|p|pre|ul|ol|dl|table|svg|hr|img|blockquote|div|section|article)\b([^>]*)>([\s\S]*?)<\/\1>|<(hr|img)\b([^>]*?)\/?>/gi;
17303
17310
  let lastIndex = 0;
17304
17311
  let match;
17312
+ let work = 0;
17305
17313
  while ((match = tokenRegex.exec(bodyHtml)) !== null) {
17314
+ signal.throwIfAborted();
17315
+ if (++work % 64 === 0) await yieldTurn(signal);
17306
17316
  const leadingText = stripTags(bodyHtml.slice(lastIndex, match.index));
17307
17317
  if (leadingText) {
17308
17318
  blocks.push({ kind: "paragraph", text: leadingText, links: extractLinks(bodyHtml.slice(lastIndex, match.index)) });
@@ -17432,7 +17442,7 @@ function parseHtmlDocument(rawHtml, replacements) {
17432
17442
  }
17433
17443
  } else {
17434
17444
  if (/<(h[1-6]|p|pre|ul|ol|dl|table|svg|hr|img|blockquote|div|section|article)\b/i.test(inner)) {
17435
- const nested = parseHtmlDocument(inner, []);
17445
+ const nested = await parseHtmlDocument(inner, [], signal);
17436
17446
  blocks.push(...nested.blocks);
17437
17447
  } else {
17438
17448
  const text = stripTags(inner);
@@ -17479,7 +17489,7 @@ function rgbColor(r, g, b, grayscale) {
17479
17489
  const lum = Math.round((0.299 * r + 0.587 * g + 0.114 * b) * 1e3) / 1e3;
17480
17490
  return { r: lum, g: lum, b: lum };
17481
17491
  }
17482
- function layoutObjectPages(blocks, box, settings) {
17492
+ async function layoutObjectPages(blocks, box, settings, signal) {
17483
17493
  const pages = [];
17484
17494
  let currentActions = [];
17485
17495
  const headerReserve = settings.header.left || settings.header.center || settings.header.right ? 24 : 0;
@@ -17498,7 +17508,10 @@ function layoutObjectPages(blocks, box, settings) {
17498
17508
  flushPage();
17499
17509
  }
17500
17510
  };
17511
+ let work = 0;
17501
17512
  for (const block of blocks) {
17513
+ signal.throwIfAborted();
17514
+ if (++work % 64 === 0) await yieldTurn(signal);
17502
17515
  if (block.kind === "pagebreak") {
17503
17516
  flushPage();
17504
17517
  continue;
@@ -17817,11 +17830,11 @@ function createPdfAstRenderer() {
17817
17830
  const obj = job.objects[i];
17818
17831
  const htmlBytes = inputs[i] ?? new Uint8Array(0);
17819
17832
  const htmlText = decoder3.decode(htmlBytes);
17820
- const parsed = parseHtmlDocument(htmlText, obj.settings.replacements);
17833
+ const parsed = await parseHtmlDocument(htmlText, obj.settings.replacements, signal);
17821
17834
  if (!inferredDocumentTitle && parsed.title) {
17822
17835
  inferredDocumentTitle = parsed.title;
17823
17836
  }
17824
- const pages = layoutObjectPages(parsed.blocks, box, obj.settings);
17837
+ const pages = await layoutObjectPages(parsed.blocks, box, obj.settings, signal);
17825
17838
  laidOutPerObject.push(pages);
17826
17839
  objectMeta.push({
17827
17840
  title: parsed.title || inferredDocumentTitle || "Document",
@@ -17853,7 +17866,7 @@ function createPdfAstRenderer() {
17853
17866
  producer: "@poe-code/pdf-ast"
17854
17867
  });
17855
17868
  for (const outPage of sequence.pages) {
17856
- signal.throwIfAborted();
17869
+ await yieldTurn(signal);
17857
17870
  const spec = laidOutPerObject[outPage.objectIndex][outPage.pageIndex];
17858
17871
  const meta = objectMeta[outPage.objectIndex];
17859
17872
  const page = doc.addPage({ width: box.width, height: box.height });
@@ -5,7 +5,7 @@ export interface ParseLimits {
5
5
  readonly maxWork: number;
6
6
  }
7
7
  export interface ParseOptions {
8
- readonly limits: ParseLimits;
8
+ readonly limits?: Partial<ParseLimits>;
9
9
  readonly signal?: AbortSignal;
10
10
  /** Deliberate safe CLI deviation from the unqualified ASCII-zero sentinel. */
11
11
  readonly endOfOptions?: boolean;
@@ -24,7 +24,7 @@ export interface ResourceLease {
24
24
  */
25
25
  export type ResourceOpen = (reference: string, signal: AbortSignal) => Promise<ResourceLease>;
26
26
  export interface ResourceOptions {
27
- readonly limits: ResourceLimits;
27
+ readonly limits?: Partial<ResourceLimits>;
28
28
  readonly signal: AbortSignal;
29
29
  readonly vfs?: ResourceOpen;
30
30
  readonly fonts?: ResourceOpen;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-bash",
3
- "version": "0.1.744",
3
+ "version": "0.1.745",
4
4
  "description": "Extensible virtual shell with pluggable filesystems and streaming commands",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -631,7 +631,7 @@
631
631
  "access": "public"
632
632
  },
633
633
  "dependencies": {
634
- "@poe-platform/safe-fs": "0.1.744",
634
+ "@poe-platform/safe-fs": "0.1.745",
635
635
  "pdf-lib": "1.17.1",
636
636
  "@types/node": "^25.2.2",
637
637
  "pako": "3.0.1",