@poe-platform/safe-bash 0.1.744 → 0.1.746

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 (70) hide show
  1. package/README.md +10 -1
  2. package/dist/image-ast/browser/sharp.d.ts +1 -1
  3. package/dist/image-ast/index.js +133 -35
  4. package/dist/image-ast/sharp.d.ts +1 -1
  5. package/dist/safe-bash/chunks/{chunk-2CO4WCMK.js → chunk-3ZNXN3XO.js} +434 -245
  6. package/dist/safe-bash/chunks/{chunk-2F7Q532M.js → chunk-4GK4FAT6.js} +3 -3
  7. package/dist/safe-bash/chunks/{chunk-WCNFCN2G.js → chunk-BS6QFRNX.js} +2 -2
  8. package/dist/safe-bash/chunks/{chunk-IZZ7KX4E.js → chunk-JCXAGOEK.js} +40 -3
  9. package/dist/safe-bash/chunks/{chunk-WN7FYUWU.js → chunk-MC2KZY3D.js} +26 -13
  10. package/dist/safe-bash/chunks/{chunk-I3DOFJSJ.js → chunk-MUWJPSGN.js} +2 -2
  11. package/dist/safe-bash/chunks/{chunk-7RP6WOWK.js → chunk-OF2PDE3W.js} +2 -2
  12. package/dist/safe-bash/chunks/{pdf-renderer-3TVUXNBT.js → pdf-renderer-4APIM7F7.js} +2 -2
  13. package/dist/safe-bash/chunks/{src-5VZS2ZKB.js → src-T2WAWJXF.js} +2 -2
  14. package/dist/safe-bash/command-chunks/{chunk-DRCPJVZF.js → chunk-44N2IRVP.js} +17 -5
  15. package/dist/safe-bash/command-chunks/{chunk-LYKC7WJB.js → chunk-6742OVAC.js} +37 -3
  16. package/dist/safe-bash/command-chunks/{chunk-BMBXSLVX.js → chunk-6QU5OLPJ.js} +2 -2
  17. package/dist/safe-bash/command-chunks/{chunk-YHANNN7I.js → chunk-S3BO2NJT.js} +7 -0
  18. package/dist/safe-bash/commands/basic.d.ts +2 -0
  19. package/dist/safe-bash/commands/basic.js +236 -9
  20. package/dist/safe-bash/commands/pr/index.browser.js +1 -1
  21. package/dist/safe-bash/commands/streams.js +9 -56
  22. package/dist/safe-bash/commands/table-text/index.js +5 -1
  23. package/dist/safe-bash/commands/text.js +13 -2
  24. package/dist/safe-bash/commands/time-env/shared.js +2 -2
  25. package/dist/safe-bash/commands/time-env/sleep.js +6 -4
  26. package/dist/safe-bash/commands/timeout/index.d.ts +7 -0
  27. package/dist/safe-bash/commands/timeout/index.js +52 -32
  28. package/dist/safe-bash/commands/timeout/scheduler.js +7 -6
  29. package/dist/safe-bash/core.browser.js +3475 -883
  30. package/dist/safe-bash/opt-in/commands/shuf/random.js +2 -3
  31. package/dist/safe-bash/opt-in/shell/extensions/read/index.js +1 -2
  32. package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +1 -2
  33. package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +1 -8
  34. package/dist/safe-bash/playwright/adapter.d.ts +2 -0
  35. package/dist/safe-bash/playwright/capability-events.d.ts +7 -0
  36. package/dist/safe-bash/playwright/capability-events.js +11 -3
  37. package/dist/safe-bash/playwright/controller.d.ts +14 -0
  38. package/dist/safe-bash/playwright/controller.js +36 -8
  39. package/dist/safe-bash/playwright/index.d.ts +1 -0
  40. package/dist/safe-bash/playwright/index.js +1 -0
  41. package/dist/safe-bash/playwright/private-target-transport.d.ts +1 -0
  42. package/dist/safe-bash/playwright/private-target-transport.js +21 -21
  43. package/dist/safe-bash/shell/runtime.d.ts +34 -2
  44. package/dist/safe-bash/shell/runtime.js +4107 -947
  45. package/dist/safe-bash/shell/sync-jq-expression.d.ts +6 -0
  46. package/dist/safe-bash/shell/sync-jq-expression.js +46 -0
  47. package/dist/safe-bash-command-cal/index.js +32 -12
  48. package/dist/safe-bash-command-hostname/index.js +22 -7
  49. package/dist/safe-bash-command-id/index.js +28 -9
  50. package/dist/safe-bash-command-pandoc/command.js +1 -1
  51. package/dist/safe-bash-command-pandoc/index.js +1 -1
  52. package/dist/safe-bash-command-ssconvert/command.d.ts +2 -2
  53. package/dist/safe-bash-command-ssconvert/contracts.d.ts +4 -0
  54. package/dist/safe-bash-command-ssconvert/engine.d.ts +2 -2
  55. package/dist/safe-bash-command-ssconvert/index.js +421 -237
  56. package/dist/safe-bash-command-whoami/index.js +26 -12
  57. package/dist/safe-bash-command-wkhtmltopdf/index.js +24 -11
  58. package/dist/safe-bash-command-wkhtmltopdf/limits.d.ts +1 -1
  59. package/dist/safe-bash-command-wkhtmltopdf/resources.d.ts +1 -1
  60. package/dist/safe-bash-query-engine/index.js +3 -3
  61. package/dist/safe-bash-query-engine/interpreter.js +1 -1
  62. package/dist/safe-bash-query-engine/parser.js +1 -1
  63. package/dist/safe-bash-query-engine/query-core.js +3 -3
  64. package/dist/safe-playwright-cloudflare/browser-private-transport.js +8 -13
  65. package/dist/safe-playwright-cloudflare/browser-storage-control.js +13 -4
  66. package/dist/safe-playwright-cloudflare/browser-trace-archive.js +1 -1
  67. package/package.json +18 -14
  68. package/dist/image-ast/streams/node.d.ts +0 -10
  69. package/dist/image-ast/streams/node.js +0 -5
  70. package/dist/image-ast/streams/web.js +0 -94
@@ -1438,8 +1438,8 @@ function settings2(options) {
1438
1438
  if (value !== Infinity && (!Number.isSafeInteger(value) || value < 1)) throw new RangeError(`Invalid time-env limit: ${name}`);
1439
1439
  }
1440
1440
  const maxTimerMilliseconds = options.maxTimerMilliseconds ?? 2147483647;
1441
- if (!Number.isInteger(maxTimerMilliseconds) || maxTimerMilliseconds < 1 || maxTimerMilliseconds > 2147483647) {
1442
- throw new RangeError("maxTimerMilliseconds must be between1 and2147483647");
1441
+ if (maxTimerMilliseconds !== Infinity && (!Number.isInteger(maxTimerMilliseconds) || maxTimerMilliseconds < 1 || maxTimerMilliseconds > 2147483647)) {
1442
+ throw new RangeError("maxTimerMilliseconds must be between 1 and 2147483647 or Infinity");
1443
1443
  }
1444
1444
  const scheduler = options.scheduler ?? {
1445
1445
  now: () => performance.now(),
@@ -2079,4 +2079,4 @@ export {
2079
2079
  createPrCommands,
2080
2080
  prCommands
2081
2081
  };
2082
- //# sourceMappingURL=chunk-2F7Q532M.js.map
2082
+ //# sourceMappingURL=chunk-4GK4FAT6.js.map
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  Interpreter,
14
14
  parse
15
- } from "./chunk-IZZ7KX4E.js";
15
+ } from "./chunk-JCXAGOEK.js";
16
16
  import {
17
17
  Budget,
18
18
  Decimal,
@@ -2879,4 +2879,4 @@ export {
2879
2879
  createYqCommands,
2880
2880
  yqCommands
2881
2881
  };
2882
- //# sourceMappingURL=chunk-WCNFCN2G.js.map
2882
+ //# sourceMappingURL=chunk-BS6QFRNX.js.map
@@ -3849,8 +3849,38 @@ var Interpreter = class _Interpreter {
3849
3849
  }
3850
3850
  return;
3851
3851
  }
3852
- if (name === "indices") {
3853
- for await (const value of this.run(args[0], input)) yield await indices(input, value, budget);
3852
+ if (name === "indices" || name === "index" || name === "rindex") {
3853
+ for await (const value of this.run(args[0], input)) {
3854
+ const found = await indices(input, value, budget);
3855
+ if (name === "indices") yield found;
3856
+ else yield indexValue(found, name === "index" ? 0 : -1);
3857
+ }
3858
+ return;
3859
+ }
3860
+ if (name === "floor" || name === "ceil" || name === "round" || name === "abs") {
3861
+ if (!isNumber(input)) throw new JqError(`${describe(input, budget)} cannot be ${name}ed`);
3862
+ budget.step();
3863
+ const n = numberValue(input);
3864
+ yield name === "floor" ? Math.floor(n) : name === "ceil" ? Math.ceil(n) : name === "round" ? Math.round(n) : Math.abs(n);
3865
+ return;
3866
+ }
3867
+ if (name === "implode") {
3868
+ if (!Array.isArray(input)) throw new JqError("implode input must be an array");
3869
+ let out = "";
3870
+ for (let i = 0; i < input.length; i++) {
3871
+ {
3872
+ const _p = budget.tickSync();
3873
+ if (_p) await _p;
3874
+ }
3875
+ const el = input[i];
3876
+ const cp = isNumber(el) ? numberValue(el) : NaN;
3877
+ if (!Number.isInteger(cp) || cp < 0 || cp > 1114111) {
3878
+ throw new JqError("implode elements must be Unicode codepoints");
3879
+ }
3880
+ out += String.fromCodePoint(cp);
3881
+ }
3882
+ budget.value(out);
3883
+ yield out;
3854
3884
  return;
3855
3885
  }
3856
3886
  if (["startswith", "endswith", "ltrimstr", "rtrimstr"].includes(name)) {
@@ -4459,7 +4489,14 @@ var precedence = Object.freeze({
4459
4489
  var functions = Object.freeze({
4460
4490
  walk: [1],
4461
4491
  explode: [0],
4492
+ implode: [0],
4462
4493
  utf8bytelength: [0],
4494
+ floor: [0],
4495
+ ceil: [0],
4496
+ round: [0],
4497
+ abs: [0],
4498
+ index: [1],
4499
+ rindex: [1],
4463
4500
  while: [2],
4464
4501
  until: [2],
4465
4502
  fromdateiso8601: [0],
@@ -5107,4 +5144,4 @@ export {
5107
5144
  moduleProgram,
5108
5145
  parse
5109
5146
  };
5110
- //# sourceMappingURL=chunk-IZZ7KX4E.js.map
5147
+ //# sourceMappingURL=chunk-JCXAGOEK.js.map
@@ -8,6 +8,7 @@ import {
8
8
 
9
9
  // packages/safe-bash-command-wkhtmltopdf/src/pdf-renderer.ts
10
10
  init_platform();
11
+ import { yieldTurn } from "../../safe-bash-contracts/yield.js";
11
12
 
12
13
  // packages/pdf-ast/src/index.ts
13
14
  init_platform();
@@ -14369,10 +14370,10 @@ var ParseBudget = class {
14369
14370
  this.options = options;
14370
14371
  this.checkCancellation();
14371
14372
  this.limits = {
14372
- maxArguments: options.limits?.maxArguments,
14373
- maxTextBytes: options.limits?.maxTextBytes,
14374
- maxObjects: options.limits?.maxObjects,
14375
- maxWork: options.limits?.maxWork
14373
+ maxArguments: options.limits?.maxArguments ?? Infinity,
14374
+ maxTextBytes: options.limits?.maxTextBytes ?? Infinity,
14375
+ maxObjects: options.limits?.maxObjects ?? Infinity,
14376
+ maxWork: options.limits?.maxWork ?? Infinity
14376
14377
  };
14377
14378
  for (const value of Object.values(this.limits)) {
14378
14379
  if (value !== Infinity && (!Number.isSafeInteger(value) || value < 1)) {
@@ -15039,7 +15040,13 @@ var byteLengthGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byt
15039
15040
  var byteTypeGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, Symbol.toStringTag).get;
15040
15041
  var copyBytes = Uint8Array.prototype.set;
15041
15042
  async function withResources(options, run) {
15042
- const limits = { ...options.limits };
15043
+ const limits = {
15044
+ maxInputBytes: options.limits?.maxInputBytes ?? Infinity,
15045
+ maxDecodedBytes: options.limits?.maxDecodedBytes ?? Infinity,
15046
+ maxRetainedBytes: options.limits?.maxRetainedBytes ?? Infinity,
15047
+ maxWork: options.limits?.maxWork ?? Infinity,
15048
+ maxResources: options.limits?.maxResources ?? Infinity
15049
+ };
15043
15050
  for (const key of ["maxInputBytes", "maxDecodedBytes", "maxRetainedBytes", "maxWork", "maxResources"]) {
15044
15051
  if (limits[key] !== Infinity && (!Number.isSafeInteger(limits[key]) || limits[key] < 1)) {
15045
15052
  throw new WkhtmltopdfError("INVALID_VALUE", "Resource limits must be positive safe integers");
@@ -15468,7 +15475,7 @@ async function runWkhtmltopdf(context, options = {}) {
15468
15475
  await writeBytes(stdout.output, encoder.encode(text), signal);
15469
15476
  result = { kind: "information", exitCode: 0 };
15470
15477
  } else {
15471
- const renderer = options.renderer ?? (await import("./pdf-renderer-3TVUXNBT.js")).pdfAstRenderer;
15478
+ const renderer = options.renderer ?? (await import("./pdf-renderer-4APIM7F7.js")).pdfAstRenderer;
15472
15479
  requireRendererFeatures(renderer.profile, []);
15473
15480
  let outputBytes = 0;
15474
15481
  let outputChunks = 0;
@@ -15826,7 +15833,7 @@ function extractLinks(html) {
15826
15833
  }
15827
15834
  return links;
15828
15835
  }
15829
- function parseHtmlDocument(rawHtml, replacements) {
15836
+ async function parseHtmlDocument(rawHtml, replacements, signal) {
15830
15837
  let html = rawHtml;
15831
15838
  for (const [key, value] of replacements) {
15832
15839
  if (key) html = html.split(key).join(value);
@@ -15838,7 +15845,10 @@ function parseHtmlDocument(rawHtml, replacements) {
15838
15845
  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;
15839
15846
  let lastIndex = 0;
15840
15847
  let match;
15848
+ let work = 0;
15841
15849
  while ((match = tokenRegex.exec(bodyHtml)) !== null) {
15850
+ signal.throwIfAborted();
15851
+ if (++work % 64 === 0) await yieldTurn(signal);
15842
15852
  const leadingText = stripTags(bodyHtml.slice(lastIndex, match.index));
15843
15853
  if (leadingText) {
15844
15854
  blocks.push({ kind: "paragraph", text: leadingText, links: extractLinks(bodyHtml.slice(lastIndex, match.index)) });
@@ -15968,7 +15978,7 @@ function parseHtmlDocument(rawHtml, replacements) {
15968
15978
  }
15969
15979
  } else {
15970
15980
  if (/<(h[1-6]|p|pre|ul|ol|dl|table|svg|hr|img|blockquote|div|section|article)\b/i.test(inner)) {
15971
- const nested = parseHtmlDocument(inner, []);
15981
+ const nested = await parseHtmlDocument(inner, [], signal);
15972
15982
  blocks.push(...nested.blocks);
15973
15983
  } else {
15974
15984
  const text = stripTags(inner);
@@ -16015,7 +16025,7 @@ function rgbColor(r, g, b, grayscale) {
16015
16025
  const lum = Math.round((0.299 * r + 0.587 * g + 0.114 * b) * 1e3) / 1e3;
16016
16026
  return { r: lum, g: lum, b: lum };
16017
16027
  }
16018
- function layoutObjectPages(blocks, box, settings) {
16028
+ async function layoutObjectPages(blocks, box, settings, signal) {
16019
16029
  const pages = [];
16020
16030
  let currentActions = [];
16021
16031
  const headerReserve = settings.header.left || settings.header.center || settings.header.right ? 24 : 0;
@@ -16034,7 +16044,10 @@ function layoutObjectPages(blocks, box, settings) {
16034
16044
  flushPage();
16035
16045
  }
16036
16046
  };
16047
+ let work = 0;
16037
16048
  for (const block of blocks) {
16049
+ signal.throwIfAborted();
16050
+ if (++work % 64 === 0) await yieldTurn(signal);
16038
16051
  if (block.kind === "pagebreak") {
16039
16052
  flushPage();
16040
16053
  continue;
@@ -16353,11 +16366,11 @@ function createPdfAstRenderer() {
16353
16366
  const obj = job.objects[i];
16354
16367
  const htmlBytes = inputs[i] ?? new Uint8Array(0);
16355
16368
  const htmlText = decoder3.decode(htmlBytes);
16356
- const parsed = parseHtmlDocument(htmlText, obj.settings.replacements);
16369
+ const parsed = await parseHtmlDocument(htmlText, obj.settings.replacements, signal);
16357
16370
  if (!inferredDocumentTitle && parsed.title) {
16358
16371
  inferredDocumentTitle = parsed.title;
16359
16372
  }
16360
- const pages = layoutObjectPages(parsed.blocks, box, obj.settings);
16373
+ const pages = await layoutObjectPages(parsed.blocks, box, obj.settings, signal);
16361
16374
  laidOutPerObject.push(pages);
16362
16375
  objectMeta.push({
16363
16376
  title: parsed.title || inferredDocumentTitle || "Document",
@@ -16389,7 +16402,7 @@ function createPdfAstRenderer() {
16389
16402
  producer: "@poe-code/pdf-ast"
16390
16403
  });
16391
16404
  for (const outPage of sequence.pages) {
16392
- signal.throwIfAborted();
16405
+ await yieldTurn(signal);
16393
16406
  const spec = laidOutPerObject[outPage.objectIndex][outPage.pageIndex];
16394
16407
  const meta = objectMeta[outPage.objectIndex];
16395
16408
  const page = doc.addPage({ width: box.width, height: box.height });
@@ -16560,4 +16573,4 @@ export {
16560
16573
  wkhtmltopdfCommands,
16561
16574
  createWkhtmltopdfCommands
16562
16575
  };
16563
- //# sourceMappingURL=chunk-WN7FYUWU.js.map
16576
+ //# sourceMappingURL=chunk-MC2KZY3D.js.map
@@ -1438,8 +1438,8 @@ function settings2(options) {
1438
1438
  if (value !== Infinity && (!Number.isSafeInteger(value) || value < 1)) throw new RangeError(`Invalid time-env limit: ${name}`);
1439
1439
  }
1440
1440
  const maxTimerMilliseconds = options.maxTimerMilliseconds ?? 2147483647;
1441
- if (!Number.isInteger(maxTimerMilliseconds) || maxTimerMilliseconds < 1 || maxTimerMilliseconds > 2147483647) {
1442
- throw new RangeError("maxTimerMilliseconds must be between1 and2147483647");
1441
+ if (maxTimerMilliseconds !== Infinity && (!Number.isInteger(maxTimerMilliseconds) || maxTimerMilliseconds < 1 || maxTimerMilliseconds > 2147483647)) {
1442
+ throw new RangeError("maxTimerMilliseconds must be between 1 and 2147483647 or Infinity");
1443
1443
  }
1444
1444
  const scheduler = options.scheduler ?? {
1445
1445
  now: () => performance.now(),
@@ -11,7 +11,7 @@ import {
11
11
  tryProcessFlatJsonChunkSync,
12
12
  tryProcessFlatSelectProjectChunkSync,
13
13
  tryWriteCompactSync
14
- } from "./chunk-IZZ7KX4E.js";
14
+ } from "./chunk-JCXAGOEK.js";
15
15
  import {
16
16
  Budget,
17
17
  JqError,
@@ -2530,4 +2530,4 @@ export {
2530
2530
  createXmlCommands,
2531
2531
  xmlCommands
2532
2532
  };
2533
- //# sourceMappingURL=chunk-7RP6WOWK.js.map
2533
+ //# sourceMappingURL=chunk-OF2PDE3W.js.map
@@ -5,7 +5,7 @@ import {
5
5
  pdfAstRendererProfile,
6
6
  pdfAstWkhtmltopdfCommand,
7
7
  pdfAstWkhtmltopdfCommands
8
- } from "./chunk-WN7FYUWU.js";
8
+ } from "./chunk-MC2KZY3D.js";
9
9
  import "./chunk-LSRHLNCR.js";
10
10
  import "./chunk-ZG7GWQ5P.js";
11
11
  export {
@@ -16,4 +16,4 @@ export {
16
16
  pdfAstWkhtmltopdfCommand,
17
17
  pdfAstWkhtmltopdfCommands
18
18
  };
19
- //# sourceMappingURL=pdf-renderer-3TVUXNBT.js.map
19
+ //# sourceMappingURL=pdf-renderer-4APIM7F7.js.map
@@ -81,7 +81,7 @@ import {
81
81
  updateWorkbook,
82
82
  validSheetSize,
83
83
  visitFormula
84
- } from "./chunk-2CO4WCMK.js";
84
+ } from "./chunk-3ZNXN3XO.js";
85
85
  import "./chunk-CVAVQZSF.js";
86
86
  import "./chunk-RCM5PZBN.js";
87
87
  import "./chunk-LSRHLNCR.js";
@@ -171,4 +171,4 @@ export {
171
171
  validSheetSize,
172
172
  visitFormula
173
173
  };
174
- //# sourceMappingURL=src-5VZS2ZKB.js.map
174
+ //# sourceMappingURL=src-T2WAWJXF.js.map
@@ -31,7 +31,7 @@ import {
31
31
  init_buffer
32
32
  } from "./chunk-OWQEVNXV.js";
33
33
 
34
- // packages/safe-bash-command-pandoc/dist/chunks/chunk-AUKRN2ZN.js
34
+ // packages/safe-bash-command-pandoc/dist/chunks/chunk-IGDCQRP5.js
35
35
  init_buffer();
36
36
  import * as gfm_syntax_star from "../../safe-bash-markdown-engine/gfm-syntax.js";
37
37
  import * as commonmark_blocks_star from "../../safe-bash-markdown-engine/commonmark-blocks.js";
@@ -919,7 +919,7 @@ async function renderPdf(document, context = {}) {
919
919
  return bytes;
920
920
  }
921
921
 
922
- // packages/safe-bash-command-pandoc/dist/chunks/chunk-AUKRN2ZN.js
922
+ // packages/safe-bash-command-pandoc/dist/chunks/chunk-IGDCQRP5.js
923
923
  import { hasYieldCheckpoint, runYieldCheckpoint, yieldTurn } from "../../safe-bash-contracts/yield.js";
924
924
  import { dirname } from "@poe-platform/safe-fs/core";
925
925
  import { createOutputOperation, getCommandArguments, readBytes, FsError } from "../../safe-bash-contracts/index.js";
@@ -22874,10 +22874,22 @@ function createPandocCommand(options = {}, hasCommand) {
22874
22874
  if (matchedExt) return matchedExt;
22875
22875
  if (!["python3", "python", "node", "sh", "bash"].some((candidate) => hasCommand(candidate))) return void 0;
22876
22876
  try {
22877
- const head2 = await context.fs.readFile(pathOf(context, filterPath), { signal: readSignal, maxBytes: 256 });
22878
- const shebangCmd = parseShebangCommand(head2);
22877
+ const bound = Math.min(limits.resourceBytes ?? defaultLimits.resourceBytes, maxBytes);
22878
+ const head2 = await (stdout ?? invocation).acquire(() => context.fs.readFile(
22879
+ pathOf(context, filterPath),
22880
+ Number.isFinite(bound) ? { signal: readSignal, maxBytes: bound } : { signal: readSignal }
22881
+ ), () => {
22882
+ });
22883
+ total += head2.byteLength;
22884
+ context.inputBudget?.check(total);
22885
+ const shebangCmd = parseShebangCommand(head2.subarray(0, 256));
22879
22886
  if (shebangCmd && hasCommand(shebangCmd)) return shebangCmd;
22880
- } catch {
22887
+ } catch (error) {
22888
+ readSignal.throwIfAborted();
22889
+ if (error instanceof Error && error.name === "AbortError") {
22890
+ await (stdout ?? invocation).abort(error);
22891
+ throw error;
22892
+ }
22881
22893
  return void 0;
22882
22894
  }
22883
22895
  return void 0;
@@ -1511,9 +1511,43 @@ var Interpreter = class _Interpreter {
1511
1511
  }
1512
1512
  return;
1513
1513
  }
1514
- if (name === "indices") {
1515
- for await (const value of this.run(args[0], input))
1516
- yield await indices(input, value, budget);
1514
+ if (name === "indices" || name === "index" || name === "rindex") {
1515
+ for await (const value of this.run(args[0], input)) {
1516
+ const found = await indices(input, value, budget);
1517
+ if (name === "indices")
1518
+ yield found;
1519
+ else
1520
+ yield indexValue(found, name === "index" ? 0 : -1);
1521
+ }
1522
+ return;
1523
+ }
1524
+ if (name === "floor" || name === "ceil" || name === "round" || name === "abs") {
1525
+ if (!isNumber(input))
1526
+ throw new JqError(`${describe(input, budget)} cannot be ${name}ed`);
1527
+ budget.step();
1528
+ const n = numberValue(input);
1529
+ yield name === "floor" ? Math.floor(n) : name === "ceil" ? Math.ceil(n) : name === "round" ? Math.round(n) : Math.abs(n);
1530
+ return;
1531
+ }
1532
+ if (name === "implode") {
1533
+ if (!Array.isArray(input))
1534
+ throw new JqError("implode input must be an array");
1535
+ let out = "";
1536
+ for (let i = 0; i < input.length; i++) {
1537
+ {
1538
+ const _p = budget.tickSync();
1539
+ if (_p)
1540
+ await _p;
1541
+ }
1542
+ const el = input[i];
1543
+ const cp = isNumber(el) ? numberValue(el) : NaN;
1544
+ if (!Number.isInteger(cp) || cp < 0 || cp > 1114111) {
1545
+ throw new JqError("implode elements must be Unicode codepoints");
1546
+ }
1547
+ out += String.fromCodePoint(cp);
1548
+ }
1549
+ budget.value(out);
1550
+ yield out;
1517
1551
  return;
1518
1552
  }
1519
1553
  if (["startswith", "endswith", "ltrimstr", "rtrimstr"].includes(name)) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  parse
3
- } from "./chunk-YHANNN7I.js";
3
+ } from "./chunk-S3BO2NJT.js";
4
4
  import {
5
5
  Interpreter
6
- } from "./chunk-LYKC7WJB.js";
6
+ } from "./chunk-6742OVAC.js";
7
7
  import {
8
8
  Budget,
9
9
  JqLimitError,
@@ -44,7 +44,14 @@ var precedence = Object.freeze({
44
44
  var functions = Object.freeze({
45
45
  walk: [1],
46
46
  explode: [0],
47
+ implode: [0],
47
48
  utf8bytelength: [0],
49
+ floor: [0],
50
+ ceil: [0],
51
+ round: [0],
52
+ abs: [0],
53
+ index: [1],
54
+ rindex: [1],
48
55
  while: [2],
49
56
  until: [2],
50
57
  fromdateiso8601: [0],
@@ -3,5 +3,7 @@ export declare const defaultEchoExecutors: WeakSet<CommandHandler>;
3
3
  export declare function basicCommands(): CommandDefinition[];
4
4
  export declare function formatPrintf(context: CommandContext): Promise<CommandResult>;
5
5
  export declare function tryFastPrintf(args: readonly string[]): string | undefined;
6
+ export type FastPrintfSpecKind = "s" | "s_prec" | "c" | "d" | "u";
7
+ export declare function extractFastPrintfSpecifiers(format: string): readonly FastPrintfSpecKind[] | undefined;
6
8
  export declare const printfCommand: CommandDefinition;
7
9
  //# sourceMappingURL=basic.d.ts.map