@poe-platform/safe-bash 0.1.814 → 0.1.815

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 (59) hide show
  1. package/dist/mp4-ast/index.d.ts +1 -0
  2. package/dist/mp4-ast/mp4-fragment-source.d.ts +35 -0
  3. package/dist/mp4-ast/mp4-sample-source.d.ts +5 -2
  4. package/dist/mp4-ast/types.d.ts +11 -0
  5. package/dist/pdf-ast/cos/object-reader.d.ts +3 -2
  6. package/dist/pdf-ast/edit/forms.d.ts +1 -0
  7. package/dist/pdf-ast/edit/retained-form-data.d.ts +9 -0
  8. package/dist/pdf-ast/index.d.ts +1 -0
  9. package/dist/pdf-ast/index.js +476 -55
  10. package/dist/safe-bash/command-chunks/{biff-KRHJ63K3-VQPJCVIL.js → biff-A7XPBWAK-DCLG5QKF.js} +1775 -1667
  11. package/dist/safe-bash/command-chunks/{chunk-AVGXFWEB.js → chunk-44F5TOHZ.js} +179 -58
  12. package/dist/safe-bash/command-chunks/{chunk-PIVH35EQ.js → chunk-6CDDKNNA.js} +1 -0
  13. package/dist/safe-bash/command-chunks/{chunk-K4XNUJVJ.js → chunk-6EINUY5G.js} +149 -165
  14. package/dist/safe-bash/command-chunks/{chunk-5BIQWWLB.js → chunk-CFMJXJS5.js} +1 -1
  15. package/dist/safe-bash/command-chunks/{chunk-3JM7E42I.js → chunk-GPGLTWNR.js} +106 -32
  16. package/dist/safe-bash/command-chunks/{chunk-2ETEJOYX.js → chunk-HQ2UN2L2.js} +8 -8
  17. package/dist/safe-bash/command-chunks/{chunk-CK2WFJZN.js → chunk-KASXIRKD.js} +12 -14
  18. package/dist/safe-bash/command-chunks/chunk-KHUT7BB5.js +65 -0
  19. package/dist/safe-bash/command-chunks/{chunk-LAPOMHGY.js → chunk-NEYITAAO.js} +114 -97
  20. package/dist/safe-bash/command-chunks/{chunk-FF7UGJWS.js → chunk-QDVDBN2N.js} +1 -1
  21. package/dist/safe-bash/command-chunks/{chunk-SW37YCBW.js → chunk-U3C6IT2C.js} +44 -30
  22. package/dist/safe-bash/command-chunks/{chunk-G3TAX3CV.js → chunk-WAT2562G.js} +610 -539
  23. package/dist/safe-bash/command-chunks/{chunk-VT7UBPAE.js → chunk-YW2VYN4V.js} +23 -11
  24. package/dist/safe-bash/command-chunks/{chunk-GQGMQMIM.js → chunk-ZIGENXGC.js} +243 -1
  25. package/dist/safe-bash/command-chunks/{command-engine-7V6PZR7G.js → command-engine-M7S4QIXV.js} +12 -4
  26. package/dist/safe-bash/command-chunks/{engine-UYJENSWK-VSCGKSQV.js → engine-YUYZJIB4-NZUDFEHL.js} +1 -1
  27. package/dist/safe-bash-command-ffmpeg/index.js +1 -1
  28. package/dist/safe-bash-command-ffprobe/index.js +2 -2
  29. package/dist/safe-bash-command-ffprobe/media.d.ts +8 -2
  30. package/dist/safe-bash-command-ffprobe/media.js +4 -2
  31. package/dist/safe-bash-command-pandoc/command.js +3 -3
  32. package/dist/safe-bash-command-pandoc/index.js +8 -8
  33. package/dist/safe-bash-command-patch/index.js +7 -6
  34. package/dist/safe-bash-command-patch/patch-formats.d.ts +6 -5
  35. package/dist/safe-bash-command-patch/patch-formats.js +3 -2
  36. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +7 -7
  37. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +1 -1
  38. package/dist/safe-bash-command-patch/patch-gnu-reject.js +3 -2
  39. package/dist/safe-bash-command-patch/patch-publication.js +3 -2
  40. package/dist/safe-bash-command-patch/patch-text.d.ts +13 -0
  41. package/dist/safe-bash-command-patch/patch.js +7 -6
  42. package/dist/safe-bash-command-patch/stored-patch.d.ts +29 -4
  43. package/dist/safe-bash-command-patch/stored-target.d.ts +2 -1
  44. package/dist/safe-bash-command-patch/unified.d.ts +18 -4
  45. package/dist/safe-bash-command-patch/unified.js +2 -1
  46. package/dist/safe-bash-command-pdftk/index.js +30 -20
  47. package/dist/safe-bash-command-pptx/engine.js +1 -1
  48. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  49. package/dist/safe-bash-presentation-engine/index.js +1 -1
  50. package/dist/safe-bash-presentation-engine/notes.d.ts +1 -0
  51. package/dist/safe-bash-presentation-engine/notes.js +7 -1
  52. package/dist/safe-bash-presentation-engine/retained-notes.d.ts +27 -0
  53. package/dist/safe-bash-xml-engine/document.js +2 -2
  54. package/dist/safe-bash-xml-engine/index.js +2 -2
  55. package/dist/safe-bash-xml-engine/stored-document.js +1 -1
  56. package/dist/spreadsheet-format-xls/biff-properties-merge.js +40 -21
  57. package/dist/spreadsheet-format-xls/biff-property-values.d.ts +31 -0
  58. package/dist/spreadsheet-format-xls/biff-property-values.js +158 -0
  59. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
1
  import { type ReplayPatch, type ReplayOutcome } from "./stored-patch.js";
2
2
  import type { Budget } from "../safe-bash-diff-engine/shared.js";
3
3
  import type { ByteSource } from "../safe-bash-contracts/index.js";
4
- export declare function rejectBytes(patch: ReplayPatch, outcomes: readonly ReplayOutcome[], oldName: string | undefined, newName: string | undefined, indexName: string | undefined, reverse: boolean, budget: Budget, format?: "unified" | "context"): ByteSource;
4
+ export declare function rejectBytes(patch: ReplayPatch, outcomes: Iterable<ReplayOutcome> | AsyncIterable<ReplayOutcome>, oldName: string | undefined, newName: string | undefined, indexName: string | undefined, reverse: boolean, budget: Budget, format?: "unified" | "context"): ByteSource;
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  rejectBytes
3
- } from "../safe-bash/command-chunks/chunk-3JM7E42I.js";
4
- import "../safe-bash/command-chunks/chunk-CK2WFJZN.js";
3
+ } from "../safe-bash/command-chunks/chunk-GPGLTWNR.js";
4
+ import "../safe-bash/command-chunks/chunk-KASXIRKD.js";
5
+ import "../safe-bash/command-chunks/chunk-KHUT7BB5.js";
5
6
  import "../safe-bash/command-chunks/chunk-65DS4IOB.js";
6
7
  export {
7
8
  rejectBytes
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  PatchPublication
3
- } from "../safe-bash/command-chunks/chunk-5BIQWWLB.js";
4
- import "../safe-bash/command-chunks/chunk-CK2WFJZN.js";
3
+ } from "../safe-bash/command-chunks/chunk-CFMJXJS5.js";
4
+ import "../safe-bash/command-chunks/chunk-KASXIRKD.js";
5
+ import "../safe-bash/command-chunks/chunk-KHUT7BB5.js";
5
6
  import "../safe-bash/command-chunks/chunk-65DS4IOB.js";
6
7
  export {
7
8
  PatchPublication
@@ -0,0 +1,13 @@
1
+ import type { ByteSource } from "../safe-bash-contracts/index.js";
2
+ import type { Budget } from "../safe-bash-diff-engine/shared.js";
3
+ /** Replayable UTF-8 text; the owner retains the source until parsing finishes. */
4
+ export type PatchText = string | {
5
+ readonly bytes: ByteSource;
6
+ readonly size: number;
7
+ readonly terminated: boolean;
8
+ };
9
+ export declare function textSize(text: PatchText): number;
10
+ export declare function terminated(text: PatchText): boolean;
11
+ export declare function patchTextBytes(text: PatchText): ByteSource;
12
+ export declare function materializeText(text: PatchText): Promise<string>;
13
+ export declare function equalPatchText(left: PatchText, right: PatchText, budget: Budget): Promise<boolean>;
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  patchCommand
3
- } from "../safe-bash/command-chunks/chunk-AVGXFWEB.js";
4
- import "../safe-bash/command-chunks/chunk-3JM7E42I.js";
5
- import "../safe-bash/command-chunks/chunk-5BIQWWLB.js";
6
- import "../safe-bash/command-chunks/chunk-CK2WFJZN.js";
7
- import "../safe-bash/command-chunks/chunk-SW37YCBW.js";
8
- import "../safe-bash/command-chunks/chunk-VT7UBPAE.js";
3
+ } from "../safe-bash/command-chunks/chunk-44F5TOHZ.js";
4
+ import "../safe-bash/command-chunks/chunk-GPGLTWNR.js";
5
+ import "../safe-bash/command-chunks/chunk-CFMJXJS5.js";
6
+ import "../safe-bash/command-chunks/chunk-KASXIRKD.js";
7
+ import "../safe-bash/command-chunks/chunk-U3C6IT2C.js";
8
+ import "../safe-bash/command-chunks/chunk-YW2VYN4V.js";
9
+ import "../safe-bash/command-chunks/chunk-KHUT7BB5.js";
9
10
  import "../safe-bash/command-chunks/chunk-OQNX2OOS.js";
10
11
  import "../safe-bash/command-chunks/chunk-AJEQUVDN.js";
11
12
  import "../safe-bash/command-chunks/chunk-65DS4IOB.js";
@@ -1,5 +1,6 @@
1
+ import { PagedStorage } from "@poe-platform/safe-fs/storage";
1
2
  import { type TargetDocuments, type TargetLine } from "./stored-target.js";
2
- import type { FilePatch, Hunk, HunkApplication, HunkLineBuilder, HunkOutcome, PatchLine } from "./unified.js";
3
+ import type { FilePatch, Hunk, HunkApplication, HunkBuilder, HunkLineBuilder, HunkOutcome, PatchLine } from "./unified.js";
3
4
  export interface StoredPatchLine {
4
5
  readonly kind: PatchLine["kind"];
5
6
  readonly text: TargetLine;
@@ -9,18 +10,42 @@ export interface StoredPatchLines {
9
10
  read(index: number): Promise<StoredPatchLine>;
10
11
  }
11
12
  export type PatchLines = PatchLine[] | StoredPatchLines;
12
- export type ReplayPatch = FilePatch<PatchLines>;
13
+ export interface StoredPatchHunks {
14
+ readonly length: number;
15
+ read(index: number): Promise<Hunk<PatchLines>>;
16
+ }
17
+ export type ReplayPatch = FilePatch<PatchLines, Hunk<PatchLines>[] | StoredPatchHunks>;
13
18
  export type ReplayOutcome = HunkOutcome<PatchLines>;
14
- export type ReplayApplication = HunkApplication<PatchLines>;
19
+ export interface OutcomeSink {
20
+ push(outcome: ReplayOutcome): number | Promise<void>;
21
+ pop(): ReplayOutcome | undefined | Promise<ReplayOutcome | undefined>;
22
+ }
23
+ export type ReplayApplication = Omit<HunkApplication<PatchLines>, "outcomes"> & {
24
+ readonly outcomes?: OutcomeSink;
25
+ };
15
26
  export declare function patchLine(hunk: Hunk<PatchLines>, index: number): Promise<StoredPatchLine>;
27
+ export declare function patchHunk(patch: ReplayPatch, index: number): Promise<Hunk<PatchLines>>;
28
+ export declare function patchHunks(patch: ReplayPatch): AsyncGenerator<readonly [number, Hunk<PatchLines>]>;
29
+ declare class BodyLines implements StoredPatchLines {
30
+ readonly start: number;
31
+ private readonly records;
32
+ private readonly data;
33
+ length: number;
34
+ constructor(start: number, records: PagedStorage, data: PagedStorage);
35
+ read(index: number): Promise<StoredPatchLine>;
36
+ }
16
37
  /** Hunk payloads and fixed-width records share the invocation's caller-backed cache. */
17
38
  export declare class PatchBodyStore {
18
39
  private readonly data;
19
40
  private readonly records;
41
+ private readonly hunks;
20
42
  private dataEnd;
21
43
  private recordEnd;
44
+ private hunkEnd;
22
45
  constructor(documents: TargetDocuments);
23
- begin(): HunkLineBuilder<StoredPatchLines>;
46
+ begin(): HunkLineBuilder<BodyLines>;
47
+ beginHunks(): HunkBuilder<BodyLines, StoredPatchHunks>;
24
48
  close(): Promise<void>;
25
49
  }
26
50
  export declare function reverseStoredPatch(patch: ReplayPatch): ReplayPatch;
51
+ export {};
@@ -2,7 +2,8 @@ import { PagedStorage, PagedStorageCache } from "@poe-platform/safe-fs/storage";
2
2
  import { IndexedDocument } from "../safe-bash-diff-engine/document.js";
3
3
  import { Budget } from "../safe-bash-diff-engine/shared.js";
4
4
  import type { ByteSource } from "../safe-bash-contracts/index.js";
5
- export type TargetLine = string | {
5
+ import { type PatchText } from "./patch-text.js";
6
+ export type TargetLine = PatchText | {
6
7
  document: IndexedDocument;
7
8
  index: number;
8
9
  } | {
@@ -1,8 +1,13 @@
1
1
  import { Budget } from "../safe-bash-diff-engine/shared.js";
2
+ import { type PatchText } from "./patch-text.js";
2
3
  export interface PatchLine {
3
4
  readonly kind: " " | "+" | "-";
4
5
  text: string;
5
6
  }
7
+ export interface ParsedPatchLine {
8
+ readonly kind: PatchLine["kind"];
9
+ readonly text: PatchText;
10
+ }
6
11
  export interface Hunk<Lines = PatchLine[]> {
7
12
  readonly oldStart: number;
8
13
  readonly oldCount: number;
@@ -11,12 +16,12 @@ export interface Hunk<Lines = PatchLine[]> {
11
16
  readonly lines: Lines;
12
17
  readonly section?: string;
13
18
  }
14
- export interface FilePatch<Lines = PatchLine[]> {
19
+ export interface FilePatch<Lines = PatchLine[], Hunks = Hunk<Lines>[]> {
15
20
  readonly oldPath: string;
16
21
  readonly newPath: string;
17
22
  readonly oldEpoch: boolean;
18
23
  readonly newEpoch: boolean;
19
- readonly hunks: Hunk<Lines>[];
24
+ readonly hunks: Hunks;
20
25
  readonly oldHeader?: string;
21
26
  readonly newHeader?: string;
22
27
  readonly indexPath?: string;
@@ -26,7 +31,9 @@ export interface FilePatch<Lines = PatchLine[]> {
26
31
  export declare function startIndex(start: number, count: number): number;
27
32
  export interface PatchInput {
28
33
  readonly length: number;
29
- read(index: number): Promise<string | undefined>;
34
+ read(index: number, prefix?: number): Promise<string | undefined>;
35
+ matches?(index: number, text: string): Promise<boolean>;
36
+ body?(index: number, skip: number, incomplete: boolean): Promise<PatchText>;
30
37
  }
31
38
  export interface UnifiedCursor {
32
39
  readonly lines: readonly string[];
@@ -40,9 +47,16 @@ export declare function parseUnified(text: string | PatchInput, budget: Budget):
40
47
  export declare function parseUnifiedSection(cursor: IndexedUnifiedCursor | UnifiedCursor, budget: Budget): Promise<FilePatch[]>;
41
48
  export interface HunkLineBuilder<Lines> {
42
49
  readonly lines: Lines;
43
- append(line: PatchLine): void | Promise<void>;
50
+ append(line: ParsedPatchLine): void | Promise<void>;
51
+ }
52
+ export interface HunkBuilder<Lines, Hunks> {
53
+ readonly hunks: Hunks;
54
+ append(hunk: Hunk<Lines>): void | Promise<void>;
44
55
  }
45
56
  export declare function parseUnifiedReader<Lines>(cursor: IndexedUnifiedCursor, budget: Budget, single: boolean, createLines: () => HunkLineBuilder<Lines>): Promise<FilePatch<Lines>[]>;
57
+ export declare function parseUnifiedReader<Lines, Hunks extends {
58
+ readonly length: number;
59
+ }>(cursor: IndexedUnifiedCursor, budget: Budget, single: boolean, createLines: () => HunkLineBuilder<Lines>, createHunks: () => HunkBuilder<Lines, Hunks>): Promise<FilePatch<Lines, Hunks>[]>;
46
60
  export declare function reversePatch(patch: FilePatch): FilePatch;
47
61
  export interface HunkOutcome<Lines = PatchLine[]> {
48
62
  readonly hunk: Hunk<Lines>;
@@ -5,7 +5,8 @@ import {
5
5
  parseUnifiedSection,
6
6
  reversePatch,
7
7
  startIndex
8
- } from "../safe-bash/command-chunks/chunk-VT7UBPAE.js";
8
+ } from "../safe-bash/command-chunks/chunk-YW2VYN4V.js";
9
+ import "../safe-bash/command-chunks/chunk-KHUT7BB5.js";
9
10
  import "../safe-bash/command-chunks/chunk-AJEQUVDN.js";
10
11
  import "../safe-bash/command-chunks/chunk-65DS4IOB.js";
11
12
  export {
@@ -876,22 +876,28 @@ async function* retainedRotations(args, handles, primaryHandle, pageCount, stora
876
876
  }
877
877
 
878
878
  // packages/safe-bash-command-pdftk/src/retained-output.ts
879
- import { editRetainedDocument as editRetainedDocument2, PdfFileSource as PdfFileSource3, PdfMutableObjectStore as PdfMutableObjectStore4, PdfRetainedDocument, cosBool, dictDelete, dictGet as dictGet4, dictSet as dictSet2, encryptRetainedPdfChunks, retainedCosObjects, saveRetainedDocumentChunks as saveRetainedDocumentChunks2 } from "../pdf-ast/index.js";
880
- async function* retainedOutput(source, storage, options, selectedId, signal, handles, pageCount, attachments, attachmentPage, stamps, info) {
879
+ import { parseRetainedFormData, editRetainedDocument as editRetainedDocument2, PdfFileSource as PdfFileSource3, PdfMutableObjectStore as PdfMutableObjectStore4, PdfRetainedDocument, cosBool, cosName, dictDelete, dictGet as dictGet4, dictSet as dictSet2, encryptRetainedPdfChunks, retainedCosObjects, saveRetainedDocumentChunks as saveRetainedDocumentChunks2 } from "../pdf-ast/index.js";
880
+ async function* retainedOutput(source, storage, options, selectedId, signal, handles, pageCount, attachments, attachmentPage, stamps, info, formData) {
881
881
  const infoUpdates = info?.updates;
882
882
  const store = new PdfMutableObjectStore4(storage, { signal });
883
883
  let edited;
884
884
  let document, plaintext, failed = false;
885
885
  try {
886
- if (options.operation === "attach_files" || stamps || infoUpdates) {
886
+ if (options.operation === "attach_files" || stamps || infoUpdates || formData) {
887
887
  const pageIndex = attachmentPage !== void 0 && pageCount > 0 ? attachmentPage.toLowerCase() === "end" ? pageCount - 1 : Math.max(0, Math.min(pageCount - 1, (Number.parseInt(attachmentPage, 10) || 1) - 1)) : void 0;
888
- edited = await editRetainedDocument2(source, storage, { signal, ...infoUpdates ? { infoUpdates } : {}, ...options.operation === "attach_files" ? { appendAttachments: attachments } : {}, ...stamps ? { stamps } : {}, ...pageIndex !== void 0 ? { attachmentPageIndex: pageIndex } : {} });
888
+ edited = await editRetainedDocument2(source, storage, { signal, ...formData ? { formUpdates: parseRetainedFormData(formData, storage, { signal }) } : {}, ...infoUpdates ? { infoUpdates } : {}, ...options.operation === "attach_files" ? { appendAttachments: attachments } : {}, ...stamps ? { stamps } : {}, ...pageIndex !== void 0 ? { attachmentPageIndex: pageIndex } : {} });
889
889
  }
890
890
  const input = edited?.document ?? source;
891
891
  const pageReferences = edited ? { pageReferences: async function* () {
892
892
  for await (const page of input.pages()) if (page.reference) yield page.reference;
893
893
  } } : {};
894
- for await (const object of retainedCosObjects(input, storage, { signal })) await store.set(object);
894
+ for await (const object of retainedCosObjects(input, storage, { signal })) {
895
+ if (formData && options.replacementFont && object.value.kind === "dict") {
896
+ const subtype = dictGet4(object.value, "Subtype"), font = dictGet4(object.value, "BaseFont");
897
+ if (subtype?.kind === "name" && subtype.decoded === "Type1" && font?.kind === "name" && font.decoded === "Helvetica") dictSet2(object.value, "BaseFont", cosName(options.replacementFont.startsWith("/") ? options.replacementFont.slice(1) : options.replacementFont));
898
+ }
899
+ await store.set(object);
900
+ }
895
901
  const reference = input.crossReference;
896
902
  const chosenId = info?.useUpdatedId ? reference.idArray : selectedId;
897
903
  const idArray = options.keepFinalId || options.keepFirstId ? chosenId ?? reference.idArray : reference.idArray ?? chosenId;
@@ -901,7 +907,7 @@ async function* retainedOutput(source, storage, options, selectedId, signal, han
901
907
  const form = await document.lookup(dictGet4(root.value, "AcroForm"));
902
908
  if (form?.value.kind === "dict" && !form.stream) {
903
909
  if (options.dropXfa) dictDelete(form.value, "XFA");
904
- if (options.needAppearances) dictSet2(form.value, "NeedAppearances", cosBool(true));
910
+ if (formData || options.needAppearances) dictSet2(form.value, "NeedAppearances", cosBool(options.needAppearances));
905
911
  if (form.reference) await store.set({ objectNumber: form.reference.objectNumber, generationNumber: form.reference.generationNumber, value: form.value });
906
912
  else dictSet2(root.value, "AcroForm", form.value);
907
913
  }
@@ -1159,6 +1165,7 @@ async function executeRetainedPdftk(context, options) {
1159
1165
  let selectedId;
1160
1166
  const counts = /* @__PURE__ */ new Map();
1161
1167
  const inputs = /* @__PURE__ */ new Map();
1168
+ const formPath = options.operation === "fill_form" ? options.opArgs[0] ?? "-" : void 0;
1162
1169
  const infoPath = options.operation === "update_info" || options.operation === "update_info_utf8" ? options.opArgs[0] ?? "-" : void 0;
1163
1170
  const overlayPath = ["stamp", "multistamp", "background", "multibackground"].includes(options.operation) ? options.opArgs[0] ?? "-" : void 0;
1164
1171
  const attachmentPaths = [];
@@ -1183,13 +1190,13 @@ async function executeRetainedPdftk(context, options) {
1183
1190
  try {
1184
1191
  await context.fs.mkdir(storage.directory, { recursive: true, signal });
1185
1192
  const maximum = context.inputBudget?.maxBytes ?? Infinity;
1186
- if (options.inputs.some((input) => input.file === "-") || attachmentPaths.includes("-") || overlayPath === "-" || infoPath === "-") {
1193
+ if (options.inputs.some((input) => input.file === "-") || attachmentPaths.includes("-") || overlayPath === "-" || infoPath === "-" || formPath === "-") {
1187
1194
  const source = await PdfFileSource5.fromStream(context.fs, storage.directory, context.stdin, { signal, maxInputBytes: maximum });
1188
1195
  inputs.set("-", source);
1189
1196
  total += source.size;
1190
1197
  context.inputBudget?.check(total);
1191
1198
  }
1192
- for (const input of [...options.inputs, ...attachmentPaths.map((file) => ({ file })), ...overlayPath !== void 0 ? [{ file: overlayPath }] : [], ...infoPath !== void 0 ? [{ file: infoPath }] : []]) {
1199
+ for (const input of [...options.inputs, ...attachmentPaths.map((file) => ({ file })), ...overlayPath !== void 0 ? [{ file: overlayPath }] : [], ...infoPath !== void 0 ? [{ file: infoPath }] : [], ...formPath !== void 0 ? [{ file: formPath }] : []]) {
1193
1200
  if (inputs.has(input.file)) continue;
1194
1201
  let source;
1195
1202
  try {
@@ -1231,6 +1238,9 @@ async function executeRetainedPdftk(context, options) {
1231
1238
  await source.releaseCache();
1232
1239
  }
1233
1240
  document = await PdfRetainedDocument2.open(inputs.get(primary.file), storage, { signal, recovery: "strict", ...primary.password ? { password: primary.password } : {} });
1241
+ const formSource = formPath === void 0 ? void 0 : inputs.get(formPath);
1242
+ if (formPath !== void 0 && !formSource) return await diagnostic(`Error: Unable to open form data file '${formPath}'
1243
+ `);
1234
1244
  const infoSource = infoPath === void 0 ? void 0 : inputs.get(infoPath);
1235
1245
  if (infoPath !== void 0 && !infoSource) return await diagnostic(`Error: Unable to open info file '${infoPath}'
1236
1246
  `);
@@ -1266,7 +1276,7 @@ async function executeRetainedPdftk(context, options) {
1266
1276
  if (options.operation === "cat" || options.operation === "shuffle") {
1267
1277
  assembled = await assembleRetainedPdftk(document, storage, options, counts, handles, async (input) => PdfRetainedDocument2.open(inputs.get(input.file), storage, { signal, recovery: "strict", ...input.password ? { password: input.password } : {} }), signal);
1268
1278
  }
1269
- output = await PdfFileSource5.fromStream(context.fs, storage.directory, ["output", "rotate", "attach_files", "stamp", "multistamp", "background", "multibackground", "update_info", "update_info_utf8", "cat", "shuffle"].includes(options.operation) ? retainedOutput(assembled?.document ?? document, storage, options, selectedId, signal, new Map([...handles].map(([handle, input]) => [handle, { pageCount: counts.get(input) }])), counts.get(primary), attachments(), attachmentPage, overlayDocument ? [{ source: overlayDocument, mode: options.operation.includes("background") ? "underlay" : "overlay", preserveStreams: true, pages: stampPages() }] : void 0, infoSource ? { updates: retainedInfoUpdates(infoSource.stream(0, infoSource.size, signal), signal), useUpdatedId: idInput === primary } : void 0) : options.operation === "generate_fdf" ? retainedFdf(document, storage, signal) : options.operation === "dump_data_fields" || options.operation === "dump_data_fields_utf8" ? retainedFieldReport(document, options.operation.endsWith("_utf8"), signal) : retainedInspectionReport(document, storage, options.operation.endsWith("_utf8"), signal, options.operation === "dump_data" || options.operation === "dump_data_utf8" ? "document" : "annotations"), { signal });
1279
+ output = await PdfFileSource5.fromStream(context.fs, storage.directory, ["output", "rotate", "attach_files", "stamp", "multistamp", "background", "multibackground", "update_info", "update_info_utf8", "cat", "shuffle", "fill_form"].includes(options.operation) ? retainedOutput(assembled?.document ?? document, storage, options, selectedId, signal, new Map([...handles].map(([handle, input]) => [handle, { pageCount: counts.get(input) }])), counts.get(primary), attachments(), attachmentPage, overlayDocument ? [{ source: overlayDocument, mode: options.operation.includes("background") ? "underlay" : "overlay", preserveStreams: true, pages: stampPages() }] : void 0, infoSource ? { updates: retainedInfoUpdates(infoSource.stream(0, infoSource.size, signal), signal), useUpdatedId: idInput === primary } : void 0, formSource) : options.operation === "generate_fdf" ? retainedFdf(document, storage, signal) : options.operation === "dump_data_fields" || options.operation === "dump_data_fields_utf8" ? retainedFieldReport(document, options.operation.endsWith("_utf8"), signal) : retainedInspectionReport(document, storage, options.operation.endsWith("_utf8"), signal, options.operation === "dump_data" || options.operation === "dump_data_utf8" ? "document" : "annotations"), { signal });
1270
1280
  const destination = options.outputTarget;
1271
1281
  if (!destination || destination === "-") for await (const bytes of output.stream(0, output.size, signal)) await writeBytes(context.stdout, bytes, signal);
1272
1282
  else {
@@ -1500,7 +1510,7 @@ import {
1500
1510
  cosArray as cosArray4,
1501
1511
  cosDict as cosDict4,
1502
1512
  cosHexString,
1503
- cosName,
1513
+ cosName as cosName2,
1504
1514
  cosNumber as cosNumber4,
1505
1515
  cosStream,
1506
1516
  cosString as cosString4,
@@ -2124,7 +2134,7 @@ function setDocumentBookmarks(doc, bookmarks) {
2124
2134
  if (bookmarks.length === 0 || doc.pageCount === 0) return;
2125
2135
  const catalog = doc.cos.resolveDict(doc.cos.rootRef);
2126
2136
  if (!catalog) return;
2127
- const outlinesDict = cosDict4({ Type: cosName("Outlines") });
2137
+ const outlinesDict = cosDict4({ Type: cosName2("Outlines") });
2128
2138
  const outlinesRef = doc.cos.allocateObject(outlinesDict);
2129
2139
  dictSet3(catalog, "Outlines", outlinesRef);
2130
2140
  const stack = [{ ref: outlinesRef, dict: outlinesDict, children: [] }];
@@ -2148,7 +2158,7 @@ function setDocumentBookmarks(doc, bookmarks) {
2148
2158
  const itemDict = cosDict4({
2149
2159
  Title: cosString4(bm.title),
2150
2160
  Parent: parentState.ref,
2151
- Dest: cosArray4([pageRef, cosName("XYZ"), { kind: "null" }, { kind: "null" }, { kind: "null" }])
2161
+ Dest: cosArray4([pageRef, cosName2("XYZ"), { kind: "null" }, { kind: "null" }, { kind: "null" }])
2152
2162
  });
2153
2163
  const itemRef = doc.cos.allocateObject(itemDict);
2154
2164
  const prevSibling = parentState.children[parentState.children.length - 1];
@@ -2346,7 +2356,7 @@ function applyUpdateInfoText(doc, text) {
2346
2356
  }
2347
2357
  const pdfStyle = PAGE_LABEL_STYLE_TO_PDF[pl.style];
2348
2358
  if (pdfStyle) {
2349
- lblEntries.S = cosName(pdfStyle);
2359
+ lblEntries.S = cosName2(pdfStyle);
2350
2360
  }
2351
2361
  numsItems.push(cosDict4(lblEntries));
2352
2362
  }
@@ -2381,13 +2391,13 @@ function attachFilesToDocument(doc, filePaths, files, toPageSpec) {
2381
2391
  const baseName = fp.slice(fp.lastIndexOf("/") + 1);
2382
2392
  const efStreamRef = doc.cos.allocateObject(
2383
2393
  cosStream(bytes, {
2384
- dict: cosDict4({ Type: cosName("EmbeddedFile") }),
2394
+ dict: cosDict4({ Type: cosName2("EmbeddedFile") }),
2385
2395
  compress: true
2386
2396
  })
2387
2397
  );
2388
2398
  const filespecRef = doc.cos.allocateObject(
2389
2399
  cosDict4({
2390
- Type: cosName("Filespec"),
2400
+ Type: cosName2("Filespec"),
2391
2401
  F: cosString4(baseName),
2392
2402
  UF: cosString4(baseName),
2393
2403
  EF: cosDict4({ F: efStreamRef })
@@ -2403,9 +2413,9 @@ function attachFilesToDocument(doc, filePaths, files, toPageSpec) {
2403
2413
  }
2404
2414
  const annotRef = doc.cos.allocateObject(
2405
2415
  cosDict4({
2406
- Type: cosName("Annot"),
2407
- Subtype: cosName("FileAttachment"),
2408
- Name: cosName("PushPin"),
2416
+ Type: cosName2("Annot"),
2417
+ Subtype: cosName2("FileAttachment"),
2418
+ Name: cosName2("PushPin"),
2409
2419
  Contents: cosString4(baseName),
2410
2420
  FS: filespecRef,
2411
2421
  Rect: cosArray4([cosNumber4(20), cosNumber4(20), cosNumber4(40), cosNumber4(40)])
@@ -2965,7 +2975,7 @@ function* runPdftkCliSteps(argv, files, signal) {
2965
2975
  const subtype = stNode?.kind === "name" ? stNode.decoded : void 0;
2966
2976
  const baseFont = bfNode?.kind === "name" ? bfNode.decoded : void 0;
2967
2977
  if (subtype === "Type1" && baseFont === "Helvetica") {
2968
- dictSet3(obj.value, "BaseFont", cosName(cleanFontName));
2978
+ dictSet3(obj.value, "BaseFont", cosName2(cleanFontName));
2969
2979
  }
2970
2980
  }
2971
2981
  }
@@ -3061,7 +3071,7 @@ async function executePdftk(context, retainedContext = context) {
3061
3071
  const carrier = getCommandArguments(context);
3062
3072
  const argv = [...carrier.args];
3063
3073
  const parsed = await drainSteps(parsePdftkArgumentsSteps(argv), invocation.signal);
3064
- if (parsed.options && (["output", "rotate", "attach_files", "stamp", "multistamp", "background", "multibackground", "burst", "update_info", "update_info_utf8", "cat", "shuffle"].includes(parsed.options.operation) && !parsed.options.shouldFlatten || ["dump_data", "dump_data_utf8", "dump_data_annots", "dump_data_annots_utf8", "dump_data_fields", "dump_data_fields_utf8", "generate_fdf", "unpack_files"].includes(parsed.options.operation))) {
3074
+ if (parsed.options && (["output", "rotate", "attach_files", "stamp", "multistamp", "background", "multibackground", "burst", "update_info", "update_info_utf8", "cat", "shuffle", "fill_form"].includes(parsed.options.operation) && !parsed.options.shouldFlatten || ["dump_data", "dump_data_utf8", "dump_data_annots", "dump_data_annots_utf8", "dump_data_fields", "dump_data_fields_utf8", "generate_fdf", "unpack_files"].includes(parsed.options.operation))) {
3065
3075
  return await executeRetainedPdftk({ ...retainedContext, signal: invocation.signal, stdout: invocation.child(context.stdout).output }, parsed.options);
3066
3076
  }
3067
3077
  const vfsFiles = /* @__PURE__ */ new Map();
@@ -27,7 +27,7 @@ function createPptxCommandEngine(settings = {}) {
27
27
  };
28
28
  return Object.freeze({
29
29
  async execute(request) {
30
- const mod = await (cachedPptxEngineMod ??= import("../safe-bash/command-chunks/command-engine-7V6PZR7G.js"));
30
+ const mod = await (cachedPptxEngineMod ??= import("../safe-bash/command-chunks/command-engine-M7S4QIXV.js"));
31
31
  return mod.createPptxCommandEngine(ownedSettings).execute(request);
32
32
  }
33
33
  });
@@ -10,7 +10,7 @@ import {
10
10
  gt,
11
11
  j,
12
12
  oe
13
- } from "../safe-bash/command-chunks/chunk-2ETEJOYX.js";
13
+ } from "../safe-bash/command-chunks/chunk-HQ2UN2L2.js";
14
14
  import {
15
15
  a,
16
16
  g,
@@ -719,7 +719,7 @@ var le;
719
719
  function wr(...u) {
720
720
  return le ??= V({ read: readZipArchiveEntries, write: createStoredZipArchive }), le(...u);
721
721
  }
722
- var H = de(async (u) => (await import("../safe-bash/command-chunks/engine-UYJENSWK-VSCGKSQV.js")).createEngine(u), true, wr);
722
+ var H = de(async (u) => (await import("../safe-bash/command-chunks/engine-YUYZJIB4-NZUDFEHL.js")).createEngine(u), true, wr);
723
723
  var Do = H.createSsconvertCommand;
724
724
  var To = H.createSsconvertCommands;
725
725
  var Uo = H.ssconvertCommands;
@@ -69,7 +69,7 @@ import {
69
69
  mutateNotes,
70
70
  readNotes,
71
71
  validateNotesOptions
72
- } from "../safe-bash/command-chunks/chunk-GQGMQMIM.js";
72
+ } from "../safe-bash/command-chunks/chunk-ZIGENXGC.js";
73
73
  import {
74
74
  insertPlaceholder
75
75
  } from "../safe-bash/command-chunks/chunk-AM5LANIE.js";
@@ -23,3 +23,4 @@ export declare function mutateNotes(input: BinaryInput, action: "add" | "set" |
23
23
  affected: number;
24
24
  locations: readonly Location[];
25
25
  }>;
26
+ export { openRetainedNotes, stageRetainedNotes, type RetainedNotes, type RetainedNotesRecord } from './retained-notes.js';
@@ -1,8 +1,12 @@
1
1
  import {
2
2
  mutateNotes,
3
+ openRetainedNotes,
3
4
  readNotes,
5
+ stageRetainedNotes,
4
6
  validateNotesOptions
5
- } from "../safe-bash/command-chunks/chunk-GQGMQMIM.js";
7
+ } from "../safe-bash/command-chunks/chunk-ZIGENXGC.js";
8
+ import "../safe-bash/command-chunks/chunk-4EHY6J2Z.js";
9
+ import "../safe-bash/command-chunks/chunk-NQINS4XY.js";
6
10
  import "../safe-bash/command-chunks/chunk-ADHFF2IM.js";
7
11
  import "../safe-bash/command-chunks/chunk-KBAQHE5Y.js";
8
12
  import "../safe-bash/command-chunks/chunk-W3ZSWK76.js";
@@ -25,6 +29,8 @@ import "../safe-bash/command-chunks/chunk-E6SK3OU2.js";
25
29
  import "../safe-bash/command-chunks/chunk-65DS4IOB.js";
26
30
  export {
27
31
  mutateNotes,
32
+ openRetainedNotes,
28
33
  readNotes,
34
+ stageRetainedNotes,
29
35
  validateNotesOptions
30
36
  };
@@ -0,0 +1,27 @@
1
+ import type { ByteSource } from './contracts.js';
2
+ import type { NotesRecord } from './notes.js';
3
+ import { type SelectionQuery } from './selectors.js';
4
+ import type { RetainedPackageArchive, RetainedPackageContext } from './retained-package.js';
5
+ import { type StagedOutput } from './retained-output.js';
6
+ export interface RetainedNotesRecord extends Omit<NotesRecord, 'part' | 'master' | 'text' | 'bodyShapeId'> {
7
+ part(): ByteSource;
8
+ master(): ByteSource;
9
+ readonly text: (() => ByteSource) | null;
10
+ readonly bodyShapeId: (() => ByteSource) | null;
11
+ }
12
+ export interface RetainedNotes {
13
+ readonly count: number;
14
+ records(): AsyncGenerator<RetainedNotesRecord>;
15
+ close(): Promise<void>;
16
+ }
17
+ /** Borrow the archive; retain every selected note in caller storage before exposing records. */
18
+ export declare function openRetainedNotes(archive: Pick<RetainedPackageArchive, 'parts' | 'has' | 'read' | 'byteLength'>, fingerprint: string, options: {
19
+ readonly selection?: SelectionQuery;
20
+ }, settings: RetainedPackageContext, selectBeforeValidation?: boolean): Promise<RetainedNotes>;
21
+ export declare function stageRetainedNotes(archive: Pick<RetainedPackageArchive, 'parts' | 'has' | 'read' | 'byteLength'>, fingerprint: string, options: {
22
+ readonly selection?: SelectionQuery;
23
+ }, settings: RetainedPackageContext, output: {
24
+ readonly operation: 'notes.list' | 'notes.get';
25
+ readonly json: boolean;
26
+ readonly maxOutputBytes: number;
27
+ }): Promise<StagedOutput>;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  serializeDocument
3
- } from "../safe-bash/command-chunks/chunk-FF7UGJWS.js";
4
- import "../safe-bash/command-chunks/chunk-PIVH35EQ.js";
3
+ } from "../safe-bash/command-chunks/chunk-QDVDBN2N.js";
4
+ import "../safe-bash/command-chunks/chunk-6CDDKNNA.js";
5
5
  import "../safe-bash/command-chunks/chunk-CSE4VQKG.js";
6
6
  import "../safe-bash/command-chunks/chunk-3I5WTVWZ.js";
7
7
  import "../safe-bash/command-chunks/chunk-65DS4IOB.js";
@@ -3,10 +3,10 @@ import {
3
3
  } from "../safe-bash/command-chunks/chunk-WJ2ERUCQ.js";
4
4
  import {
5
5
  serializeDocument
6
- } from "../safe-bash/command-chunks/chunk-FF7UGJWS.js";
6
+ } from "../safe-bash/command-chunks/chunk-QDVDBN2N.js";
7
7
  import {
8
8
  parseStoredXml
9
- } from "../safe-bash/command-chunks/chunk-PIVH35EQ.js";
9
+ } from "../safe-bash/command-chunks/chunk-6CDDKNNA.js";
10
10
  import {
11
11
  escape,
12
12
  evaluate,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  StoredXmlDocument
3
- } from "../safe-bash/command-chunks/chunk-PIVH35EQ.js";
3
+ } from "../safe-bash/command-chunks/chunk-6CDDKNNA.js";
4
4
  import "../safe-bash/command-chunks/chunk-65DS4IOB.js";
5
5
  export {
6
6
  StoredXmlDocument