@poe-platform/safe-bash 0.1.809 → 0.1.810

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 (109) hide show
  1. package/dist/audio-ast/index.d.ts +1 -1
  2. package/dist/audio-ast/index.js +6 -0
  3. package/dist/audio-ast/wav-source.d.ts +7 -1
  4. package/dist/image-ast/index.js +1 -1
  5. package/dist/pdf-ast/cos/mutable-object-store.d.ts +3 -0
  6. package/dist/pdf-ast/cos/qpdf-json-document.d.ts +42 -0
  7. package/dist/pdf-ast/cos/qpdf-json-values.d.ts +7 -0
  8. package/dist/pdf-ast/index.d.ts +1 -0
  9. package/dist/pdf-ast/index.js +508 -37
  10. package/dist/pdf-ast/retained-document.d.ts +3 -1
  11. package/dist/safe-bash/chunks/{chunk-RQCK77SC.js → chunk-65TFMAZU.js} +2 -2
  12. package/dist/safe-bash/chunks/{chunk-SOFBGDXG.js → chunk-HHSOUC3Z.js} +32 -0
  13. package/dist/safe-bash/chunks/{chunk-WAZEELYB.js → chunk-ZA5FQ34E.js} +10 -5
  14. package/dist/safe-bash/command-chunks/biff-ORSHM4YX-QYPGRDAZ.js +4937 -0
  15. package/dist/safe-bash/command-chunks/{chunk-62ZAHKFS.js → chunk-2VCKUNDZ.js} +130 -14
  16. package/dist/safe-bash/command-chunks/{chunk-GLVD3JJG.js → chunk-BYZUOF6X.js} +2858 -2816
  17. package/dist/safe-bash/command-chunks/{chunk-6OKH4X67.js → chunk-CAXJ4RLF.js} +264 -1
  18. package/dist/safe-bash/command-chunks/{chunk-YJJBGN7U.js → chunk-CHR2OD2U.js} +9 -9
  19. package/dist/safe-bash/command-chunks/{chunk-D7XBUF76.js → chunk-D2ASPM7R.js} +109 -23
  20. package/dist/safe-bash/command-chunks/chunk-D5AYP2UM.js +816 -0
  21. package/dist/safe-bash/command-chunks/{chunk-WFDG3N5R.js → chunk-ECDEPKKW.js} +1 -1
  22. package/dist/safe-bash/command-chunks/{chunk-OQCJGUI6.js → chunk-HARUYHH7.js} +10 -10
  23. package/dist/safe-bash/command-chunks/{chunk-NVBUC644.js → chunk-HKGNBH7Z.js} +2 -2
  24. package/dist/safe-bash/command-chunks/chunk-MGBHGZEX.js +12 -0
  25. package/dist/safe-bash/command-chunks/{chunk-4557HE3J.js → chunk-PMWW7KSB.js} +161 -42
  26. package/dist/safe-bash/command-chunks/{chunk-JW3KIZU6.js → chunk-RUXY7GN5.js} +1 -1
  27. package/dist/safe-bash/command-chunks/{chunk-KELMIFVV.js → chunk-TI52LKLL.js} +1 -1
  28. package/dist/safe-bash/command-chunks/{chunk-JJQ72P3V.js → chunk-VCML4T5D.js} +1 -1
  29. package/dist/safe-bash/command-chunks/{chunk-5HGEXQVD.js → chunk-WC2OCF4H.js} +1 -1
  30. package/dist/safe-bash/command-chunks/chunk-WH3TIOTS.js +326 -0
  31. package/dist/safe-bash/command-chunks/{chunk-45FI2IPY.js → chunk-WQ6ABTJU.js} +3 -6
  32. package/dist/safe-bash/command-chunks/{chunk-NB7JO7FE.js → chunk-YTFWPJ3F.js} +1 -1
  33. package/dist/safe-bash/command-chunks/{chunk-GKYCV6BU.js → chunk-ZEPDT6I5.js} +482 -168
  34. package/dist/safe-bash/command-chunks/{command-engine-P5DFM4OU.js → command-engine-BEWABZ75.js} +10 -3
  35. package/dist/safe-bash/command-chunks/{engine-RU4OFLPO-CPLFYD67.js → engine-MEPOXIXT-WZMRHACG.js} +1 -1
  36. package/dist/safe-bash/command-chunks/pdf-LOZAXXS6-ERI57IAV.js +557 -0
  37. package/dist/safe-bash/commands/audio/index.browser.js +2 -14
  38. package/dist/safe-bash/commands/diff-patch/index.js +0 -2
  39. package/dist/safe-bash/commands/ffprobe/index.browser.js +2 -5
  40. package/dist/safe-bash/commands/pandoc/index.browser.js +3 -1
  41. package/dist/safe-bash/commands/text.js +10 -1
  42. package/dist/safe-bash/core.d.ts +2 -2
  43. package/dist/safe-bash/core.js +2 -2
  44. package/dist/safe-bash/full-core.browser.js +18 -22
  45. package/dist/safe-bash/lazy-optional.d.ts +9 -0
  46. package/dist/safe-bash/lazy-optional.js +24 -0
  47. package/dist/safe-bash/plugins/index.browser.js +5 -3
  48. package/dist/safe-bash/registry-entry.browser.js +1 -1
  49. package/dist/safe-bash-command-apply-patch/apply.js +2 -2
  50. package/dist/safe-bash-command-apply-patch/index.js +2 -2
  51. package/dist/safe-bash-command-apply-patch/parser.d.ts +20 -1
  52. package/dist/safe-bash-command-apply-patch/parser.js +1 -1
  53. package/dist/safe-bash-command-ffprobe/index.js +2 -1
  54. package/dist/safe-bash-command-ffprobe/media.js +2 -1
  55. package/dist/safe-bash-command-ffprobe/options.d.ts +15 -0
  56. package/dist/safe-bash-command-ffprobe/options.js +7 -0
  57. package/dist/safe-bash-command-media/index.js +2 -2
  58. package/dist/safe-bash-command-media/plugin.js +1 -1
  59. package/dist/safe-bash-command-media/remote.js +2 -2
  60. package/dist/safe-bash-command-pandoc/command.js +6 -6
  61. package/dist/safe-bash-command-pandoc/index.js +31 -31
  62. package/dist/safe-bash-command-patch/index.js +2 -2
  63. package/dist/safe-bash-command-patch/patch-publication.d.ts +2 -2
  64. package/dist/safe-bash-command-patch/patch-publication.js +1 -1
  65. package/dist/safe-bash-command-patch/patch.js +2 -2
  66. package/dist/safe-bash-command-pptx/engine.js +1 -1
  67. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  68. package/dist/safe-bash-command-xmllint/index.js +137 -30
  69. package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
  70. package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
  71. package/dist/safe-bash-compression-engine/files.js +5 -5
  72. package/dist/safe-bash-compression-engine/index.js +4 -4
  73. package/dist/safe-bash-compression-engine/operand.js +5 -5
  74. package/dist/safe-bash-compression-engine/stream.js +4 -4
  75. package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
  76. package/dist/safe-bash-media-engine/imagemagick.d.ts +2 -0
  77. package/dist/safe-bash-media-engine/index.js +162 -72
  78. package/dist/safe-bash-network-engine/body.d.ts +1 -0
  79. package/dist/safe-bash-network-engine/body.js +1 -1
  80. package/dist/safe-bash-network-engine/transfer.js +11 -3
  81. package/dist/safe-bash-presentation-engine/command-placeholder.js +4 -3
  82. package/dist/safe-bash-presentation-engine/index.d.ts +1 -1
  83. package/dist/safe-bash-presentation-engine/index.js +9 -4
  84. package/dist/safe-bash-presentation-engine/presentation-model.js +3 -2
  85. package/dist/safe-bash-presentation-engine/retained-text.js +3 -3
  86. package/dist/safe-bash-presentation-engine/retained-xml-parts.d.ts +26 -0
  87. package/dist/safe-bash-presentation-engine/xml-parts.d.ts +1 -0
  88. package/dist/safe-bash-presentation-engine/xml-parts.js +7 -1
  89. package/dist/safe-bash-xml-engine/document.js +1 -1
  90. package/dist/safe-bash-xml-engine/index.js +1 -1
  91. package/dist/spreadsheet-engine/rendering/print/tab-layout.d.ts +11 -0
  92. package/dist/spreadsheet-engine/rendering/print/tab-layout.js +15 -0
  93. package/dist/spreadsheet-engine/rendering/print/text-lines.d.ts +2 -2
  94. package/dist/spreadsheet-engine/rendering/print/text-lines.js +3 -3
  95. package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +4 -0
  96. package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +137 -56
  97. package/dist/spreadsheet-format-xls/biff-encryption.d.ts +1 -1
  98. package/dist/spreadsheet-format-xls/biff-encryption.js +8 -3
  99. package/dist/spreadsheet-format-xls/biff-property-bytes.d.ts +1 -1
  100. package/dist/spreadsheet-format-xls/biff-property-bytes.js +2 -2
  101. package/dist/spreadsheet-format-xls/biff.js +11 -3
  102. package/package.json +3 -2
  103. package/dist/safe-bash/chunks/chunk-I2A5ZCPD.js +0 -17
  104. package/dist/safe-bash/chunks/chunk-PQTT2EZP.js +0 -8
  105. package/dist/safe-bash/command-chunks/biff-DS263V2K-2GP4GZT7.js +0 -4868
  106. package/dist/safe-bash/command-chunks/chunk-6ZFYWT3U.js +0 -581
  107. package/dist/safe-bash/command-chunks/chunk-S244SWDH.js +0 -153
  108. package/dist/safe-bash/command-chunks/pdf-T7AWYZGQ-KNAYJ7YF.js +0 -552
  109. /package/dist/safe-bash/command-chunks/{chunk-EMMSXKEJ.js → chunk-4Q4R3VZU.js} +0 -0
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  createBody,
20
20
  queryData
21
- } from "../safe-bash/command-chunks/chunk-4557HE3J.js";
21
+ } from "../safe-bash/command-chunks/chunk-PMWW7KSB.js";
22
22
  import "../safe-bash/command-chunks/chunk-CYIHFBEH.js";
23
23
  import "../safe-bash/command-chunks/chunk-ZGXSETAX.js";
24
24
  import {
@@ -293,6 +293,7 @@ function createTransferCommand(options, profile) {
293
293
  return def;
294
294
  }
295
295
  async function transfer(context, args, input, limits, transport, authorize, started, status, headerState) {
296
+ let retainedBody;
296
297
  const start = performance.now();
297
298
  const remaining = () => Math.min(args.maxTimeMs - (performance.now() - start), limits.maxTotalTimeMs - (performance.now() - started));
298
299
  const hasFileOutput = args.etagSave !== void 0 && args.etagSave !== "-" || args.remoteName || args.output !== void 0 && args.output !== "-" || args.dumpHeader !== void 0 && args.dumpHeader !== "-";
@@ -304,6 +305,13 @@ async function transfer(context, args, input, limits, transport, authorize, star
304
305
  } } : context.stdin;
305
306
  let response;
306
307
  let failure;
308
+ operation.registerCleanup(async () => {
309
+ try {
310
+ await retainedBody?.close();
311
+ } catch {
312
+ failure ??= new CurlError(65, "Failed cleaning upload replay storage");
313
+ }
314
+ });
307
315
  const values = { ...writeOutDefaults };
308
316
  let format = args.writeOut;
309
317
  let formatReady = false;
@@ -373,7 +381,7 @@ async function transfer(context, args, input, limits, transport, authorize, star
373
381
  if (args.query?.length) {
374
382
  const queryArgs = { ...args, data: args.query };
375
383
  delete queryArgs.upload;
376
- const queryBody = createBody({ ...context, stdin: borrowed }, queryArgs, limits);
384
+ const queryBody = retainedBody = createBody({ ...context, stdin: borrowed }, queryArgs, limits);
377
385
  const encoded = await queryData(queryBody, signal, limits);
378
386
  let query = "";
379
387
  for (let index = 0; index < encoded.length; index++) {
@@ -386,7 +394,7 @@ async function transfer(context, args, input, limits, transport, authorize, star
386
394
  }
387
395
  initial.search += `${initial.search ? "&" : "?"}${query}`;
388
396
  }
389
- let body = createBody({ ...context, stdin: borrowed }, args, limits);
397
+ let body = retainedBody = createBody({ ...context, stdin: borrowed }, args, limits);
390
398
  if (args.get && body) {
391
399
  const query = await queryData(body, signal, limits);
392
400
  if (/[^\x21-\x7e]/.test(query)) throw new CurlError(3, "GET data must be URL encoded");
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  insertPlaceholder
3
- } from "../safe-bash/command-chunks/chunk-5HGEXQVD.js";
4
- import "../safe-bash/command-chunks/chunk-NB7JO7FE.js";
5
- import "../safe-bash/command-chunks/chunk-6OKH4X67.js";
3
+ } from "../safe-bash/command-chunks/chunk-WC2OCF4H.js";
4
+ import "../safe-bash/command-chunks/chunk-YTFWPJ3F.js";
5
+ import "../safe-bash/command-chunks/chunk-CAXJ4RLF.js";
6
+ import "../safe-bash/command-chunks/chunk-U6QHTC5J.js";
6
7
  import "../safe-bash/command-chunks/chunk-YUVH6CE4.js";
7
8
  import "../safe-bash/command-chunks/chunk-DJVRDUCA.js";
8
9
  import "../safe-bash/command-chunks/chunk-XBZ4ZWGL.js";
@@ -22,7 +22,7 @@ export { addChart, setCharts, chartTypes, type CreatableChartType, type ChartInp
22
22
  export { selectionQuerySchema } from "./selector-schema.js";
23
23
  export type { PresentationInventory, SlideInventory, PartInventory } from "./inventory.js";
24
24
  export { readSelectionIndex, decodeSelectionToken, createBatchHandles, SelectionError, type SelectionContext, type SelectionQuery, type SelectionRecord, type SelectionIndex } from "./selectors.js";
25
- export { getXmlPart, replaceXmlPart, type XmlPartContext, type XmlPartData } from "./xml-parts.js";
25
+ export { getXmlPart, openRetainedXmlPart, stageRetainedXmlPart, replaceXmlPart, type RetainedXmlPart, type RetainedXmlPartContext, type XmlPartContext, type XmlPartData } from "./xml-parts.js";
26
26
  export type { PartView, PackageView, PartRelationship } from "./package-view.js";
27
27
  export type { XmlElementView } from "./xml-view.js";
28
28
  export { Presentation, type PresentationModel, type PresentationContext, type PresentationPublication } from "./presentation-model.js";
@@ -95,7 +95,7 @@ import {
95
95
  } from "../safe-bash/command-chunks/chunk-EWS4KYJE.js";
96
96
  import {
97
97
  insertPlaceholder
98
- } from "../safe-bash/command-chunks/chunk-5HGEXQVD.js";
98
+ } from "../safe-bash/command-chunks/chunk-WC2OCF4H.js";
99
99
  import {
100
100
  sanitize
101
101
  } from "../safe-bash/command-chunks/chunk-K7AGAS3K.js";
@@ -149,11 +149,14 @@ import {
149
149
  Presentation,
150
150
  SlideLayout,
151
151
  SlideLayouts
152
- } from "../safe-bash/command-chunks/chunk-NB7JO7FE.js";
152
+ } from "../safe-bash/command-chunks/chunk-YTFWPJ3F.js";
153
153
  import {
154
154
  getXmlPart,
155
- replaceXmlPart
156
- } from "../safe-bash/command-chunks/chunk-6OKH4X67.js";
155
+ openRetainedXmlPart,
156
+ replaceXmlPart,
157
+ stageRetainedXmlPart
158
+ } from "../safe-bash/command-chunks/chunk-CAXJ4RLF.js";
159
+ import "../safe-bash/command-chunks/chunk-U6QHTC5J.js";
157
160
  import {
158
161
  Connector,
159
162
  DrawingOperation,
@@ -710,6 +713,7 @@ export {
710
713
  openLinkSession,
711
714
  openPackageArchive,
712
715
  openPropertySession,
716
+ openRetainedXmlPart,
713
717
  packPackage,
714
718
  paragraphAlignments,
715
719
  paragraphNumberingSchemes,
@@ -774,6 +778,7 @@ export {
774
778
  shapePathXml,
775
779
  shapePresets,
776
780
  splitSlides,
781
+ stageRetainedXmlPart,
777
782
  textCapitalizationStyles,
778
783
  textStrikeStyles,
779
784
  textUnderlineStyles,
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  Presentation
3
- } from "../safe-bash/command-chunks/chunk-NB7JO7FE.js";
4
- import "../safe-bash/command-chunks/chunk-6OKH4X67.js";
3
+ } from "../safe-bash/command-chunks/chunk-YTFWPJ3F.js";
4
+ import "../safe-bash/command-chunks/chunk-CAXJ4RLF.js";
5
+ import "../safe-bash/command-chunks/chunk-U6QHTC5J.js";
5
6
  import "../safe-bash/command-chunks/chunk-YUVH6CE4.js";
6
7
  import "../safe-bash/command-chunks/chunk-DJVRDUCA.js";
7
8
  import "../safe-bash/command-chunks/chunk-XBZ4ZWGL.js";
@@ -1,11 +1,11 @@
1
+ import {
2
+ fieldTypeKinds
3
+ } from "../safe-bash/command-chunks/chunk-GTWVMFBK.js";
1
4
  import {
2
5
  openRetainedPresentationIndex,
3
6
  stageRetainedOutput,
4
7
  streamJson
5
8
  } from "../safe-bash/command-chunks/chunk-U6QHTC5J.js";
6
- import {
7
- fieldTypeKinds
8
- } from "../safe-bash/command-chunks/chunk-GTWVMFBK.js";
9
9
  import {
10
10
  validateTextReadingOptions
11
11
  } from "../safe-bash/command-chunks/chunk-HONWGFDA.js";
@@ -0,0 +1,26 @@
1
+ import type { ValidationLimits } from './validation.js';
2
+ import type { ByteSource } from './contracts.js';
3
+ import type { RetainedPackageArchive, RetainedPackageContext } from './retained-package.js';
4
+ import { type StagedOutput } from './retained-output.js';
5
+ import { type RetainedInspectionSelection } from './retained-inspection.js';
6
+ export interface RetainedXmlPartContext extends RetainedPackageContext {
7
+ readonly validationLimits?: ValidationLimits;
8
+ }
9
+ type Archive = Pick<RetainedPackageArchive, 'parts' | 'has' | 'read' | 'byteLength'>;
10
+ export interface RetainedXmlPart {
11
+ readonly part: string;
12
+ readonly format: 'original' | 'pretty';
13
+ bytes(): ByteSource;
14
+ xml(): ByteSource;
15
+ close(): Promise<void>;
16
+ }
17
+ /** Borrow an admitted archive; all decoded XML and pretty state use caller storage. */
18
+ export declare function openRetainedXmlPart(archive: Archive, requested: string, settings: RetainedXmlPartContext, options?: {
19
+ readonly pretty?: boolean;
20
+ }): Promise<RetainedXmlPart>;
21
+ export declare function stageRetainedXmlPart(archive: Archive, fingerprint: string, selection: RetainedInspectionSelection, settings: RetainedXmlPartContext, output: {
22
+ readonly json: boolean;
23
+ readonly pretty?: boolean;
24
+ readonly maxOutputBytes: number;
25
+ }): Promise<StagedOutput>;
26
+ export {};
@@ -15,3 +15,4 @@ export declare function getXmlPart(input: BinaryInput, part: string, context: Xm
15
15
  }): Promise<XmlPartData>;
16
16
  export declare function replaceXmlPart(input: BinaryInput, part: string, replacement: BinaryInput, context: XmlPartContext): Promise<Uint8Array>;
17
17
  export declare function validateXmlPartReplacement(reader: PackageReader, part: string, bytes: Uint8Array, context: XmlPartContext): PackageReader;
18
+ export { openRetainedXmlPart, stageRetainedXmlPart, type RetainedXmlPart, type RetainedXmlPartContext } from './retained-xml-parts.js';
@@ -1,9 +1,13 @@
1
1
  import {
2
2
  getXmlPart,
3
+ openRetainedXmlPart,
3
4
  replaceXmlPart,
5
+ stageRetainedXmlPart,
4
6
  validateXmlPartReplacement
5
- } from "../safe-bash/command-chunks/chunk-6OKH4X67.js";
7
+ } from "../safe-bash/command-chunks/chunk-CAXJ4RLF.js";
8
+ import "../safe-bash/command-chunks/chunk-U6QHTC5J.js";
6
9
  import "../safe-bash/command-chunks/chunk-VPDSQPSN.js";
10
+ import "../safe-bash/command-chunks/chunk-S4IIOSRA.js";
7
11
  import "../safe-bash/command-chunks/chunk-SFCERNHU.js";
8
12
  import "../safe-bash/command-chunks/chunk-KMMAJ6H6.js";
9
13
  import "../safe-bash/command-chunks/chunk-MMBRBANA.js";
@@ -22,6 +26,8 @@ import "../safe-bash/command-chunks/chunk-E6SK3OU2.js";
22
26
  import "../safe-bash/command-chunks/chunk-65DS4IOB.js";
23
27
  export {
24
28
  getXmlPart,
29
+ openRetainedXmlPart,
25
30
  replaceXmlPart,
31
+ stageRetainedXmlPart,
26
32
  validateXmlPartReplacement
27
33
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serializeDocument
3
- } from "../safe-bash/command-chunks/chunk-D7XBUF76.js";
3
+ } from "../safe-bash/command-chunks/chunk-D2ASPM7R.js";
4
4
  import "../safe-bash/command-chunks/chunk-D2KZ66W4.js";
5
5
  import "../safe-bash/command-chunks/chunk-JYUJAF4L.js";
6
6
  import "../safe-bash/command-chunks/chunk-3I5WTVWZ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serializeDocument
3
- } from "../safe-bash/command-chunks/chunk-D7XBUF76.js";
3
+ } from "../safe-bash/command-chunks/chunk-D2ASPM7R.js";
4
4
  import "../safe-bash/command-chunks/chunk-D2KZ66W4.js";
5
5
  import {
6
6
  parseQuery
@@ -0,0 +1,11 @@
1
+ /** Pango default tabs leave at least one space before the next eight-space stop. */
2
+ export declare function nextPrintTabStop(width: number, tabWidth: number): number;
3
+ /** Mirror tab-run boxes without reversing the already-shaped glyphs inside each run. */
4
+ export declare function mirrorPrintTabRuns(glyphs: {
5
+ x: number;
6
+ }[], runs: readonly {
7
+ start: number;
8
+ end: number;
9
+ first: number;
10
+ last: number;
11
+ }[], width: number, tick: () => void): void;
@@ -0,0 +1,15 @@
1
+ /** Pango default tabs leave at least one space before the next eight-space stop. */
2
+ export function nextPrintTabStop(width, tabWidth) {
3
+ return Math.ceil((width + tabWidth / 8) / tabWidth) * tabWidth;
4
+ }
5
+ /** Mirror tab-run boxes without reversing the already-shaped glyphs inside each run. */
6
+ export function mirrorPrintTabRuns(glyphs, runs, width, tick) {
7
+ for (const run of runs) {
8
+ tick();
9
+ const offset = width - run.end - run.start;
10
+ for (let index = run.first; index < run.last; index++) {
11
+ tick();
12
+ glyphs[index].x += offset;
13
+ }
14
+ }
15
+ }
@@ -5,5 +5,5 @@ export declare function splitPrintLines(value: string, tick: (amount?: number) =
5
5
  }[];
6
6
  /** Gnumeric displays LF inside Fill strings as a direction-aware return arrow. */
7
7
  export declare function fillPrintNewlines(value: string, rtl: boolean, tick: (amount?: number) => void): string;
8
- /** Keep shaping boundaries while painting single-direction Fill paragraphs in visual order. */
9
- export declare function fillPrintParagraphs(value: string, rtl: boolean, tick: (amount?: number) => void): string[];
8
+ /** Keep shaping boundaries and control markers in single-direction Fill visual order. */
9
+ export declare function fillPrintItems(value: string, rtl: boolean, tick: (amount?: number) => void): string[];
@@ -30,9 +30,9 @@ export function fillPrintNewlines(value, rtl, tick) {
30
30
  tick(value.length);
31
31
  return value.split("\n").join(rtl ? "↪" : "↩");
32
32
  }
33
- /** Keep shaping boundaries while painting single-direction Fill paragraphs in visual order. */
34
- export function fillPrintParagraphs(value, rtl, tick) {
33
+ /** Keep shaping boundaries and control markers in single-direction Fill visual order. */
34
+ export function fillPrintItems(value, rtl, tick) {
35
35
  tick(value.length);
36
- const parts = value.split("\u2029");
36
+ const parts = value.split("\u2029").flatMap(part => ["\u2028", "\r"].reduce((parts, separator) => parts.flatMap(part => part.split(separator).flatMap((piece, index) => index ? [separator, piece] : [piece])), [part]));
37
37
  return rtl ? parts.reverse() : parts;
38
38
  }
@@ -1,4 +1,5 @@
1
1
  import { type CapabilityContext, type RangeSource } from "../spreadsheet-engine/contracts.js";
2
+ import type { BiffPropertySource } from "./biff-encrypted-properties-write.js";
2
3
  import type { BiffRc4Cipher } from "./biff-encryption.js";
3
4
  /** Admit the outer container and reject hidden plaintext property collisions
4
5
  * before asking for a password. POI emits an empty document-summary placeholder. */
@@ -6,3 +7,6 @@ export declare function encryptedBiffPropertyStream(streams: ReadonlyMap<string,
6
7
  /** MS-OFFCRYPTO 2.3.5.4: header/table restart block 0; each payload restarts its
7
8
  * descriptor block. These are not Workbook's absolute-position 1024-byte chunks. */
8
9
  export declare function decryptBiffPropertyContainer(encrypted: Uint8Array, keyStream: (block: number, length: number) => Uint8Array, context: CapabilityContext, charge: (amount: number) => void, createCipher?: (block: number) => BiffRc4Cipher): ReadonlyMap<string, Uint8Array>;
10
+ /** Decrypt payloads directly into caller storage. Container bytes and the validated
11
+ * descriptor table are still buffered; payload plaintext never accumulates in RAM. */
12
+ export declare function decryptBiffPropertySources(encrypted: Uint8Array, createCipher: (block: number) => BiffRc4Cipher, context: CapabilityContext, charge: (amount: number) => void): Promise<ReadonlyMap<string, BiffPropertySource>>;
@@ -1,4 +1,5 @@
1
1
  import { SsconvertError } from "../spreadsheet-engine/contracts.js";
2
+ import { stagePropertyBytes } from "./biff-property-bytes.js";
2
3
  import { Binary, invalidBiff } from "./biff-binary.js";
3
4
  import { biffPropertyFormats } from "./biff-properties.js";
4
5
  import { propertyRange, readPropertySectionRanges, readPropertyValueRanges } from "./biff-property-range.js";
@@ -98,62 +99,7 @@ export function decryptBiffPropertyContainer(encrypted, keyStream, context, char
98
99
  };
99
100
  try {
100
101
  check();
101
- if (encrypted.length > context.limits.inputBytes)
102
- throw new SsconvertError("resource-limit", "ssconvert encrypted BIFF property input limit exceeded");
103
- const source = new Binary(encrypted), header = new Binary(decrypt(source.slice(0, 8), 0));
104
- const offset = header.u32(0), size = header.u32(4);
105
- header.bytes.fill(0);
106
- if (offset < 8 || size < 4)
107
- invalidBiff("invalid encrypted property descriptor range");
108
- source.check(offset, size);
109
- const table = new Binary(decrypt(source.slice(offset, size), 0)), count = table.u32(0);
110
- if (count > Math.floor((size - 4) / 18))
111
- invalidBiff("invalid encrypted property descriptor count");
112
- if (count > (context.limits.workbookNodes ?? context.limits.inputBytes))
113
- throw new SsconvertError("resource-limit", "ssconvert encrypted BIFF property node limit exceeded");
114
- charge(count);
115
- let at = 4, textBytes = 0;
116
- const descriptors = [], names = new Set();
117
- for (let i = 0; i < count; i++) {
118
- context.signal.throwIfAborted();
119
- table.check(at, 18);
120
- const start = table.u32(at), length = table.u32(at + 4), block = table.u16(at + 8), nameLength = table.u8(at + 10), flags = table.u8(at + 11);
121
- if (flags !== 1 || table.u32(at + 12) !== 0)
122
- invalidBiff("invalid encrypted property descriptor flags");
123
- at += 16;
124
- if (!nameLength || nameLength > 31)
125
- invalidBiff("invalid encrypted property stream name");
126
- table.check(at, (nameLength + 1) * 2);
127
- charge(nameLength);
128
- if (table.u16(at + nameLength * 2) !== 0)
129
- invalidBiff("unterminated encrypted property stream name");
130
- textBytes += nameLength * 3;
131
- if (textBytes > (context.limits.workbookTextBytes ?? context.limits.inputBytes))
132
- throw new SsconvertError("resource-limit", "ssconvert encrypted BIFF property text limit exceeded");
133
- let name;
134
- try {
135
- name = new TextDecoder("utf-16le", { fatal: true, ignoreBOM: true }).decode(table.slice(at, nameLength * 2));
136
- }
137
- catch {
138
- invalidBiff("invalid encrypted property stream name");
139
- }
140
- if (name.includes("\0") || names.has(name.toUpperCase()))
141
- invalidBiff("duplicate or invalid encrypted property stream name");
142
- names.add(name.toUpperCase());
143
- at += (nameLength + 1) * 2;
144
- source.check(start, length);
145
- if (start < 8 || start < offset + size && start + length > offset)
146
- invalidBiff("overlapping encrypted property ranges");
147
- descriptors.push({ offset: start, size: length, block, name });
148
- }
149
- if (at !== size)
150
- invalidBiff("invalid encrypted property descriptor size");
151
- table.bytes.fill(0);
152
- charge(count * Math.ceil(Math.log2(count + 1)));
153
- const ordered = [...descriptors].sort((a, b) => a.offset - b.offset);
154
- for (let i = 1; i < ordered.length; i++)
155
- if (ordered[i].offset < ordered[i - 1].offset + ordered[i - 1].size)
156
- invalidBiff("overlapping encrypted property payloads");
102
+ const descriptors = readEncryptedPropertyDescriptors(encrypted, decrypt, context, charge), source = new Binary(encrypted);
157
103
  for (const entry of descriptors)
158
104
  result.set(entry.name, decrypt(source.slice(entry.offset, entry.size), entry.block));
159
105
  return result;
@@ -163,3 +109,138 @@ export function decryptBiffPropertyContainer(encrypted, keyStream, context, char
163
109
  throw error;
164
110
  }
165
111
  }
112
+ function readEncryptedPropertyDescriptors(encrypted, decrypt, context, charge) {
113
+ if (encrypted.length > context.limits.inputBytes)
114
+ throw new SsconvertError("resource-limit", "ssconvert encrypted BIFF property input limit exceeded");
115
+ const source = new Binary(encrypted), header = new Binary(decrypt(source.slice(0, 8), 0));
116
+ const offset = header.u32(0), size = header.u32(4);
117
+ header.bytes.fill(0);
118
+ if (offset < 8 || size < 4)
119
+ invalidBiff("invalid encrypted property descriptor range");
120
+ source.check(offset, size);
121
+ const table = new Binary(decrypt(source.slice(offset, size), 0)), count = table.u32(0);
122
+ if (count > Math.floor((size - 4) / 18))
123
+ invalidBiff("invalid encrypted property descriptor count");
124
+ if (count > (context.limits.workbookNodes ?? context.limits.inputBytes))
125
+ throw new SsconvertError("resource-limit", "ssconvert encrypted BIFF property node limit exceeded");
126
+ charge(count);
127
+ let at = 4, textBytes = 0;
128
+ const descriptors = [], names = new Set();
129
+ for (let i = 0; i < count; i++) {
130
+ context.signal.throwIfAborted();
131
+ table.check(at, 18);
132
+ const start = table.u32(at), length = table.u32(at + 4), block = table.u16(at + 8), nameLength = table.u8(at + 10), flags = table.u8(at + 11);
133
+ if (flags !== 1 || table.u32(at + 12) !== 0)
134
+ invalidBiff("invalid encrypted property descriptor flags");
135
+ at += 16;
136
+ if (!nameLength || nameLength > 31)
137
+ invalidBiff("invalid encrypted property stream name");
138
+ table.check(at, (nameLength + 1) * 2);
139
+ charge(nameLength);
140
+ if (table.u16(at + nameLength * 2) !== 0)
141
+ invalidBiff("unterminated encrypted property stream name");
142
+ textBytes += nameLength * 3;
143
+ if (textBytes > (context.limits.workbookTextBytes ?? context.limits.inputBytes))
144
+ throw new SsconvertError("resource-limit", "ssconvert encrypted BIFF property text limit exceeded");
145
+ let name;
146
+ try {
147
+ name = new TextDecoder("utf-16le", { fatal: true, ignoreBOM: true }).decode(table.slice(at, nameLength * 2));
148
+ }
149
+ catch {
150
+ invalidBiff("invalid encrypted property stream name");
151
+ }
152
+ if (name.includes("\0") || names.has(name.toUpperCase()))
153
+ invalidBiff("duplicate or invalid encrypted property stream name");
154
+ names.add(name.toUpperCase());
155
+ at += (nameLength + 1) * 2;
156
+ source.check(start, length);
157
+ if (start < 8 || start < offset + size && start + length > offset)
158
+ invalidBiff("overlapping encrypted property ranges");
159
+ descriptors.push({ offset: start, size: length, block, name });
160
+ }
161
+ if (at !== size)
162
+ invalidBiff("invalid encrypted property descriptor size");
163
+ table.bytes.fill(0);
164
+ charge(count * Math.ceil(Math.log2(count + 1)));
165
+ const ordered = [...descriptors].sort((a, b) => a.offset - b.offset);
166
+ for (let i = 1; i < ordered.length; i++)
167
+ if (ordered[i].offset < ordered[i - 1].offset + ordered[i - 1].size)
168
+ invalidBiff("overlapping encrypted property payloads");
169
+ return descriptors;
170
+ }
171
+ /** Decrypt payloads directly into caller storage. Container bytes and the validated
172
+ * descriptor table are still buffered; payload plaintext never accumulates in RAM. */
173
+ export async function decryptBiffPropertySources(encrypted, createCipher, context, charge) {
174
+ const result = new Map(), owned = [];
175
+ let closed = false;
176
+ const check = () => { context.signal.throwIfAborted(); if (closed)
177
+ throw new SsconvertError("invalid-request", "Encrypted BIFF property reader disposed"); };
178
+ const close = async () => {
179
+ closed = true;
180
+ for (const bytes of owned)
181
+ bytes.fill(0);
182
+ const outcomes = await Promise.allSettled([...result.values()].map(source => source.close()));
183
+ result.clear();
184
+ const errors = outcomes.filter((value) => value.status === "rejected").map(value => value.reason);
185
+ if (errors.length)
186
+ throw new AggregateError(errors, "Encrypted BIFF property cleanup failed");
187
+ };
188
+ context.own(close);
189
+ function* chunks(bytes, block) {
190
+ check();
191
+ charge(bytes.length * 2 + 320);
192
+ const cipher = createCipher(block);
193
+ try {
194
+ check();
195
+ for (let at = 0; at < bytes.length; at += 16384) {
196
+ const output = bytes.slice(at, at + 16384);
197
+ try {
198
+ cipher.xor(output);
199
+ check();
200
+ yield output;
201
+ check();
202
+ }
203
+ finally {
204
+ output.fill(0);
205
+ }
206
+ }
207
+ }
208
+ finally {
209
+ cipher.close();
210
+ }
211
+ }
212
+ try {
213
+ check();
214
+ const descriptors = readEncryptedPropertyDescriptors(encrypted, (bytes, block) => {
215
+ const output = new Uint8Array(bytes.length);
216
+ owned.push(output);
217
+ let at = 0;
218
+ for (const part of chunks(bytes, block)) {
219
+ output.set(part, at);
220
+ at += part.length;
221
+ }
222
+ return output;
223
+ }, context, charge);
224
+ for (const entry of descriptors) {
225
+ const bytes = encrypted.subarray(entry.offset, entry.offset + entry.size);
226
+ const source = await stagePropertyBytes({ length: entry.size, chunks: () => chunks(bytes, entry.block) }, context, context.limits.inputBytes);
227
+ result.set(entry.name, source);
228
+ check();
229
+ }
230
+ return result;
231
+ }
232
+ catch (error) {
233
+ try {
234
+ await close();
235
+ }
236
+ catch (cleanup) {
237
+ throw new AggregateError([error, cleanup], "Encrypted BIFF property read and cleanup failed");
238
+ }
239
+ throw error;
240
+ }
241
+ finally {
242
+ for (const bytes of owned)
243
+ bytes.fill(0);
244
+ owned.length = 0;
245
+ }
246
+ }
@@ -12,4 +12,4 @@ export declare function createRc4Cipher(key: Uint8Array, context: CapabilityCont
12
12
  /** Buffering convenience for the bounded record blocks and legacy readers. */
13
13
  export declare function rc4Stream(key: Uint8Array, length: number, context: CapabilityContext): Uint8Array;
14
14
  /** Decode admitted XOR/RC4 profiles; optional secret acquisition is explicit host authority. */
15
- export declare function decryptBiffRecords(records: BiffRecords, revision: number, context: CapabilityContext, streams?: ReadonlyMap<string, Uint8Array>, propertySources?: ReadonlyMap<string, RangeSource>): Promise<ReadonlyMap<string, Uint8Array> | undefined>;
15
+ export declare function decryptBiffRecords(records: BiffRecords, revision: number, context: CapabilityContext, streams?: ReadonlyMap<string, Uint8Array>, propertySources?: ReadonlyMap<string, RangeSource>): Promise<ReadonlyMap<string, Uint8Array | RangeSource> | undefined>;
@@ -1,7 +1,7 @@
1
1
  import { biffRecord } from "./biff-record-storage.js";
2
2
  import { SsconvertError } from "../spreadsheet-engine/contracts.js";
3
3
  import { Binary, invalidBiff } from "./biff-binary.js";
4
- import { decryptBiffPropertyContainer, encryptedBiffPropertyStream } from "./biff-encrypted-properties.js";
4
+ import { decryptBiffPropertyContainer, decryptBiffPropertySources, encryptedBiffPropertyStream } from "./biff-encrypted-properties.js";
5
5
  import { md5, sha1 } from "@noble/hashes/legacy.js";
6
6
  /** MS-OFFCRYPTO legacy interoperability only; RC4 provides no authentication.
7
7
  * The caller closes each stream before releasing its key lifetime. Only the
@@ -327,7 +327,9 @@ export async function decryptBiffRecords(records, revision, context, streams, pr
327
327
  decoded.fill(0);
328
328
  }
329
329
  }
330
- return properties ? decryptBiffPropertyContainer(properties, keyStream, context, admit, number => {
330
+ if (!properties)
331
+ return undefined;
332
+ const createCipher = (number) => {
331
333
  const key = blockKey(number);
332
334
  try {
333
335
  return createRc4Cipher(key, context);
@@ -335,7 +337,10 @@ export async function decryptBiffRecords(records, revision, context, streams, pr
335
337
  finally {
336
338
  key.fill(0);
337
339
  }
338
- }) : undefined;
340
+ };
341
+ // Staging must finish while the block-key base still exists.
342
+ return context.createWorkingStorage ? await decryptBiffPropertySources(properties, createCipher, context, admit) :
343
+ decryptBiffPropertyContainer(properties, keyStream, context, admit, createCipher);
339
344
  }
340
345
  catch (error) {
341
346
  for (const bytes of decodedBuffers)
@@ -6,4 +6,4 @@ export type BiffPropertyBytes = Uint8Array | {
6
6
  };
7
7
  export declare function propertyChunks(value: BiffPropertyBytes): Iterable<Uint8Array>;
8
8
  /** Consume lazy serialization once into caller storage; never retain emitted chunks. */
9
- export declare function stagePropertyBytes(value: BiffPropertyBytes, context: CapabilityContext): Promise<BiffPropertySource>;
9
+ export declare function stagePropertyBytes(value: BiffPropertyBytes, context: CapabilityContext, maximumBytes?: number): Promise<BiffPropertySource>;
@@ -8,9 +8,9 @@ export function* propertyChunks(value) {
8
8
  yield* value.chunks();
9
9
  }
10
10
  /** Consume lazy serialization once into caller storage; never retain emitted chunks. */
11
- export async function stagePropertyBytes(value, context) {
11
+ export async function stagePropertyBytes(value, context, maximumBytes = context.limits.outputBytes) {
12
12
  context.signal.throwIfAborted();
13
- if (!Number.isSafeInteger(value.length) || value.length < 0 || value.length > context.limits.outputBytes)
13
+ if (!Number.isSafeInteger(value.length) || value.length < 0 || value.length > maximumBytes)
14
14
  throw new SsconvertError('resource-limit', 'Invalid BIFF property serialization size');
15
15
  const acquire = context.createWorkingStorage?.bind(context);
16
16
  if (!acquire)
@@ -1,3 +1,4 @@
1
+ import { propertyRange } from "./biff-property-range.js";
1
2
  import { BiffStagedOutput } from "./biff-staged-output.js";
2
3
  import { createBiffCatalogs } from "./biff-catalogs.js";
3
4
  import { biffFillPatterns } from "./biff-fill-patterns.js";
@@ -1348,12 +1349,19 @@ async function readBiffContents(records, streamSize, streams, context, encoding,
1348
1349
  for (const [name, bytes] of decryptedProperties ?? []) {
1349
1350
  if (["\u0005SUMMARYINFORMATION", "\u0005DOCUMENTSUMMARYINFORMATION"].includes(name.toUpperCase()))
1350
1351
  continue;
1351
- accountFormulaWork(bytes.length * 2);
1352
- metadataBytes += bytes.length * 2;
1352
+ const range = propertyRange(bytes, context);
1353
+ accountFormulaWork(range.size * 2);
1354
+ metadataBytes += range.size * 2;
1353
1355
  if (metadataBytes > (context.limits.workbookTextBytes ?? context.limits.inputBytes * 2))
1354
1356
  throw new SsconvertError("resource-limit", "ssconvert BIFF metadata byte limit exceeded");
1357
+ let hex = "";
1358
+ for (let at = 0; at < range.size;) {
1359
+ const chunk = await range.read(at, 16384);
1360
+ at += chunk.length;
1361
+ hex += Array.from(chunk, byte => byte.toString(16).padStart(2, "0")).join("");
1362
+ }
1355
1363
  unsupported.push({ source: "biff", kind: "encrypted-ancillary", disposition: "retained",
1356
- data: { stream: accountText(name), bytes: accountText(Array.from(bytes, byte => byte.toString(16).padStart(2, "0")).join("")) } });
1364
+ data: { stream: accountText(name), bytes: accountText(hex) } });
1357
1365
  await context.diagnostic?.({ code: "biff-loss-warning", severity: "warning", message: `BIFF encrypted ancillary stream ${name} retained without interpretation` });
1358
1366
  }
1359
1367
  const properties = propertyStreams ? await readBiffProperties(propertyStreams, context, accountText, accountFormulaWork, unsupported) : {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-bash",
3
- "version": "0.1.809",
3
+ "version": "0.1.810",
4
4
  "description": "Extensible virtual shell with pluggable filesystems and streaming commands",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1407,7 +1407,7 @@
1407
1407
  "access": "public"
1408
1408
  },
1409
1409
  "dependencies": {
1410
- "@poe-platform/safe-fs": "0.1.809",
1410
+ "@poe-platform/safe-fs": "0.1.810",
1411
1411
  "pdf-lib": "1.17.1",
1412
1412
  "@types/node": "^25.2.2",
1413
1413
  "@formatjs/intl-numberformat": "9.4.0",
@@ -2748,6 +2748,7 @@
2748
2748
  "./dist/spreadsheet-engine/rendering/print/rotated-text.js",
2749
2749
  "./dist/spreadsheet-engine/rendering/print/settings.js",
2750
2750
  "./dist/spreadsheet-engine/rendering/print/shared-borders.js",
2751
+ "./dist/spreadsheet-engine/rendering/print/tab-layout.js",
2751
2752
  "./dist/spreadsheet-engine/rendering/print/text-lines.js",
2752
2753
  "./dist/spreadsheet-engine/rendering/print/text-span.js",
2753
2754
  "./dist/spreadsheet-engine/rendering/print/wrap-lines.js",
@@ -1,17 +0,0 @@
1
- // packages/safe-bash/src/commands/audio/index.ts
2
- import { audioCommands, createAudioCommand, createAudioCommands, createFfprobeCommand, createFfprobeCommands, createSoxCommand, createSoxCommands, createSoxiCommand, createSoxiCommands, ffprobeCommands, soxCommands, soxiCommands } from "../../safe-bash-command-audio/index.js";
3
-
4
- export {
5
- audioCommands,
6
- createAudioCommand,
7
- createAudioCommands,
8
- createFfprobeCommand,
9
- createFfprobeCommands,
10
- createSoxCommand,
11
- createSoxCommands,
12
- createSoxiCommand,
13
- createSoxiCommands,
14
- ffprobeCommands,
15
- soxCommands,
16
- soxiCommands
17
- };
@@ -1,8 +0,0 @@
1
- // packages/safe-bash/src/commands/ffprobe/index.ts
2
- import { createFfprobeCommand, createFfprobeCommands, ffprobeCommands } from "../../safe-bash-command-ffprobe/index.js";
3
-
4
- export {
5
- createFfprobeCommand,
6
- createFfprobeCommands,
7
- ffprobeCommands
8
- };