@poe-platform/safe-bash 0.1.755 → 0.1.756

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 (28) hide show
  1. package/dist/image-ast/index.browser.js +26 -2
  2. package/dist/image-ast/index.js +26 -2
  3. package/dist/pdf-ast/canvas.d.ts +1 -0
  4. package/dist/pdf-ast/index.js +26 -2
  5. package/dist/safe-bash/chunks/{chunk-JEFBTRY7.js → chunk-CBVANNKK.js} +2 -2
  6. package/dist/safe-bash/chunks/{chunk-6XDKK63A.js → chunk-JCN3FXLP.js} +27 -3
  7. package/dist/safe-bash/chunks/{chunk-QHB7HBLA.js → chunk-OSUXMC43.js} +3 -3
  8. package/dist/safe-bash/chunks/{pdf-renderer-XIFUTX34.js → pdf-renderer-CMF3CSVU.js} +3 -3
  9. package/dist/safe-bash/chunks/{src-V4VCM5OX.js → src-MXIKQCIC.js} +3 -3
  10. package/dist/safe-bash/command-chunks/{chunk-XRVNFK7Z.js → chunk-H2FQA4OU.js} +26 -2
  11. package/dist/safe-bash/command-chunks/{chunk-KB2LQ4HG.js → chunk-KBBI4CSU.js} +2 -2
  12. package/dist/safe-bash/command-chunks/{chunk-MENC7RPR.js → chunk-WI35236J.js} +1 -1
  13. package/dist/safe-bash-command-ffmpeg/index.js +20 -2
  14. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  15. package/dist/safe-bash-command-pandoc/command.js +3 -3
  16. package/dist/safe-bash-command-pandoc/index.js +3 -3
  17. package/dist/safe-bash-command-pdfimages/index.js +26 -2
  18. package/dist/safe-bash-command-pdfinfo/index.js +26 -2
  19. package/dist/safe-bash-command-pdftk/index.js +26 -2
  20. package/dist/safe-bash-command-pdftoppm/index.js +26 -2
  21. package/dist/safe-bash-command-pdftotext/index.js +26 -2
  22. package/dist/safe-bash-command-qpdf/index.js +26 -2
  23. package/dist/safe-bash-command-sips/index.js +2 -2
  24. package/dist/safe-bash-command-soffice/index.js +1 -1
  25. package/dist/safe-bash-command-ssconvert/index.js +26 -2
  26. package/dist/safe-bash-command-wkhtmltopdf/index.js +26 -2
  27. package/package.json +2 -2
  28. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +1 -1
@@ -46136,7 +46136,7 @@ var PdfPage = class {
46136
46136
  this.cachedContentAst = parseContentStream(bytes);
46137
46137
  this.isolatedInitialStream = false;
46138
46138
  const stm = cosStream(bytes, { compress });
46139
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
46139
+ this.replaceContentStream(stm);
46140
46140
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46141
46141
  }
46142
46142
  getIsolatedContentAst() {
@@ -46153,9 +46153,33 @@ var PdfPage = class {
46153
46153
  this.cachedContentAst = [...nodes];
46154
46154
  const bytes = serializeContentAst(this.cachedContentAst);
46155
46155
  const streamObj = cosStream(bytes, { compress });
46156
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
46156
+ this.replaceContentStream(streamObj);
46157
46157
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46158
46158
  }
46159
+ replaceContentStream(stream) {
46160
+ const contents = dictGet(this.pageDict, "Contents");
46161
+ if (contents?.kind === "ref") {
46162
+ let references = 0;
46163
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
46164
+ const visited = /* @__PURE__ */ new Set();
46165
+ while (pending.length > 0 && references < 2) {
46166
+ const node = pending.pop();
46167
+ if (node.kind === "ref") {
46168
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
46169
+ } else if (!visited.has(node)) {
46170
+ visited.add(node);
46171
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
46172
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
46173
+ else if (node.kind === "stream") pending.push(node.dict);
46174
+ }
46175
+ }
46176
+ if (references === 1) {
46177
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
46178
+ return;
46179
+ }
46180
+ }
46181
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
46182
+ }
46159
46183
  drawText(text, options) {
46160
46184
  const size = options.size ?? options.fontSize ?? 12;
46161
46185
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -46136,7 +46136,7 @@ var PdfPage = class {
46136
46136
  this.cachedContentAst = parseContentStream(bytes);
46137
46137
  this.isolatedInitialStream = false;
46138
46138
  const stm = cosStream(bytes, { compress });
46139
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
46139
+ this.replaceContentStream(stm);
46140
46140
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46141
46141
  }
46142
46142
  getIsolatedContentAst() {
@@ -46153,9 +46153,33 @@ var PdfPage = class {
46153
46153
  this.cachedContentAst = [...nodes];
46154
46154
  const bytes = serializeContentAst(this.cachedContentAst);
46155
46155
  const streamObj = cosStream(bytes, { compress });
46156
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
46156
+ this.replaceContentStream(streamObj);
46157
46157
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46158
46158
  }
46159
+ replaceContentStream(stream) {
46160
+ const contents = dictGet(this.pageDict, "Contents");
46161
+ if (contents?.kind === "ref") {
46162
+ let references = 0;
46163
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
46164
+ const visited = /* @__PURE__ */ new Set();
46165
+ while (pending.length > 0 && references < 2) {
46166
+ const node = pending.pop();
46167
+ if (node.kind === "ref") {
46168
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
46169
+ } else if (!visited.has(node)) {
46170
+ visited.add(node);
46171
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
46172
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
46173
+ else if (node.kind === "stream") pending.push(node.dict);
46174
+ }
46175
+ }
46176
+ if (references === 1) {
46177
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
46178
+ return;
46179
+ }
46180
+ }
46181
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
46182
+ }
46159
46183
  drawText(text, options) {
46160
46184
  const size = options.size ?? options.fontSize ?? 12;
46161
46185
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -103,6 +103,7 @@ export declare class PdfPage {
103
103
  setRawContentStream(bytesOrText: Uint8Array | string, compress?: boolean): void;
104
104
  private getIsolatedContentAst;
105
105
  setContentAst(nodes: PdfContentNode[], compress?: boolean): void;
106
+ private replaceContentStream;
106
107
  drawText(text: string, options: DrawTextOptions): void;
107
108
  drawRect(options: DrawRectOptions): void;
108
109
  drawLine(options: DrawLineOptions): void;
@@ -39539,7 +39539,7 @@ var PdfPage = class {
39539
39539
  this.cachedContentAst = parseContentStream(bytes);
39540
39540
  this.isolatedInitialStream = false;
39541
39541
  const stm = cosStream(bytes, { compress });
39542
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
39542
+ this.replaceContentStream(stm);
39543
39543
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
39544
39544
  }
39545
39545
  getIsolatedContentAst() {
@@ -39556,9 +39556,33 @@ var PdfPage = class {
39556
39556
  this.cachedContentAst = [...nodes];
39557
39557
  const bytes = serializeContentAst(this.cachedContentAst);
39558
39558
  const streamObj = cosStream(bytes, { compress });
39559
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
39559
+ this.replaceContentStream(streamObj);
39560
39560
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
39561
39561
  }
39562
+ replaceContentStream(stream) {
39563
+ const contents = dictGet(this.pageDict, "Contents");
39564
+ if (contents?.kind === "ref") {
39565
+ let references = 0;
39566
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
39567
+ const visited = /* @__PURE__ */ new Set();
39568
+ while (pending.length > 0 && references < 2) {
39569
+ const node = pending.pop();
39570
+ if (node.kind === "ref") {
39571
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
39572
+ } else if (!visited.has(node)) {
39573
+ visited.add(node);
39574
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
39575
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
39576
+ else if (node.kind === "stream") pending.push(node.dict);
39577
+ }
39578
+ }
39579
+ if (references === 1) {
39580
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
39581
+ return;
39582
+ }
39583
+ }
39584
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
39585
+ }
39562
39586
  drawText(text, options) {
39563
39587
  const size = options.size ?? options.fontSize ?? 12;
39564
39588
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  PdfDocument,
7
7
  renderPdfPageToPng
8
- } from "./chunk-6XDKK63A.js";
8
+ } from "./chunk-JCN3FXLP.js";
9
9
  import {
10
10
  CodecError,
11
11
  createCompressionCodec,
@@ -174811,4 +174811,4 @@ tslib/tslib.js:
174811
174811
  @noble/ciphers/utils.js:
174812
174812
  (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
174813
174813
  */
174814
- //# sourceMappingURL=chunk-JEFBTRY7.js.map
174814
+ //# sourceMappingURL=chunk-CBVANNKK.js.map
@@ -34768,7 +34768,7 @@ var PdfPage = class {
34768
34768
  this.cachedContentAst = parseContentStream(bytes);
34769
34769
  this.isolatedInitialStream = false;
34770
34770
  const stm = cosStream(bytes, { compress });
34771
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
34771
+ this.replaceContentStream(stm);
34772
34772
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
34773
34773
  }
34774
34774
  getIsolatedContentAst() {
@@ -34785,9 +34785,33 @@ var PdfPage = class {
34785
34785
  this.cachedContentAst = [...nodes];
34786
34786
  const bytes = serializeContentAst(this.cachedContentAst);
34787
34787
  const streamObj = cosStream(bytes, { compress });
34788
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
34788
+ this.replaceContentStream(streamObj);
34789
34789
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
34790
34790
  }
34791
+ replaceContentStream(stream) {
34792
+ const contents = dictGet(this.pageDict, "Contents");
34793
+ if (contents?.kind === "ref") {
34794
+ let references = 0;
34795
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
34796
+ const visited = /* @__PURE__ */ new Set();
34797
+ while (pending.length > 0 && references < 2) {
34798
+ const node = pending.pop();
34799
+ if (node.kind === "ref") {
34800
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
34801
+ } else if (!visited.has(node)) {
34802
+ visited.add(node);
34803
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
34804
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
34805
+ else if (node.kind === "stream") pending.push(node.dict);
34806
+ }
34807
+ }
34808
+ if (references === 1) {
34809
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
34810
+ return;
34811
+ }
34812
+ }
34813
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
34814
+ }
34791
34815
  drawText(text, options) {
34792
34816
  const size = options.size ?? options.fontSize ?? 12;
34793
34817
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -38956,4 +38980,4 @@ export {
38956
38980
  * Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
38957
38981
  * See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
38958
38982
  */
38959
- //# sourceMappingURL=chunk-6XDKK63A.js.map
38983
+ //# sourceMappingURL=chunk-JCN3FXLP.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PdfDocument,
3
3
  decodePng
4
- } from "./chunk-6XDKK63A.js";
4
+ } from "./chunk-JCN3FXLP.js";
5
5
  import {
6
6
  init_platform
7
7
  } from "./chunk-ZG7GWQ5P.js";
@@ -1250,7 +1250,7 @@ async function runWkhtmltopdf(context, options = {}) {
1250
1250
  await writeBytes(stdout.output, encoder.encode(text), signal);
1251
1251
  result = { kind: "information", exitCode: 0 };
1252
1252
  } else {
1253
- const renderer = options.renderer ?? (await import("./pdf-renderer-XIFUTX34.js")).pdfAstRenderer;
1253
+ const renderer = options.renderer ?? (await import("./pdf-renderer-CMF3CSVU.js")).pdfAstRenderer;
1254
1254
  requireRendererFeatures(renderer.profile, []);
1255
1255
  let outputBytes = 0;
1256
1256
  let outputChunks = 0;
@@ -2314,4 +2314,4 @@ export {
2314
2314
  pdfAstWkhtmltopdfCommands,
2315
2315
  wkhtmltopdfLimits
2316
2316
  };
2317
- //# sourceMappingURL=chunk-QHB7HBLA.js.map
2317
+ //# sourceMappingURL=chunk-OSUXMC43.js.map
@@ -6,8 +6,8 @@ import {
6
6
  pdfAstWkhtmltopdfCommand,
7
7
  pdfAstWkhtmltopdfCommands,
8
8
  renderPdfAstSync
9
- } from "./chunk-QHB7HBLA.js";
10
- import "./chunk-6XDKK63A.js";
9
+ } from "./chunk-OSUXMC43.js";
10
+ import "./chunk-JCN3FXLP.js";
11
11
  import "./chunk-64OE6Q6X.js";
12
12
  import "./chunk-ZG7GWQ5P.js";
13
13
  export {
@@ -19,4 +19,4 @@ export {
19
19
  pdfAstWkhtmltopdfCommands,
20
20
  renderPdfAstSync
21
21
  };
22
- //# sourceMappingURL=pdf-renderer-XIFUTX34.js.map
22
+ //# sourceMappingURL=pdf-renderer-CMF3CSVU.js.map
@@ -87,9 +87,9 @@ import {
87
87
  visitFormula,
88
88
  xlsFormat,
89
89
  xlsxFormat
90
- } from "./chunk-JEFBTRY7.js";
90
+ } from "./chunk-CBVANNKK.js";
91
91
  import "./chunk-22XPAAOI.js";
92
- import "./chunk-6XDKK63A.js";
92
+ import "./chunk-JCN3FXLP.js";
93
93
  import "./chunk-EMAJ7WUW.js";
94
94
  import "./chunk-64OE6Q6X.js";
95
95
  import "./chunk-CTYJJD4O.js";
@@ -184,4 +184,4 @@ export {
184
184
  xlsFormat,
185
185
  xlsxFormat
186
186
  };
187
- //# sourceMappingURL=src-V4VCM5OX.js.map
187
+ //# sourceMappingURL=src-MXIKQCIC.js.map
@@ -35390,7 +35390,7 @@ var PdfPage = class {
35390
35390
  this.cachedContentAst = parseContentStream(bytes);
35391
35391
  this.isolatedInitialStream = false;
35392
35392
  const stm = cosStream(bytes, { compress });
35393
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
35393
+ this.replaceContentStream(stm);
35394
35394
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
35395
35395
  }
35396
35396
  getIsolatedContentAst() {
@@ -35407,9 +35407,33 @@ var PdfPage = class {
35407
35407
  this.cachedContentAst = [...nodes];
35408
35408
  const bytes = serializeContentAst(this.cachedContentAst);
35409
35409
  const streamObj = cosStream(bytes, { compress });
35410
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
35410
+ this.replaceContentStream(streamObj);
35411
35411
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
35412
35412
  }
35413
+ replaceContentStream(stream) {
35414
+ const contents = dictGet(this.pageDict, "Contents");
35415
+ if (contents?.kind === "ref") {
35416
+ let references = 0;
35417
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
35418
+ const visited = /* @__PURE__ */ new Set();
35419
+ while (pending.length > 0 && references < 2) {
35420
+ const node = pending.pop();
35421
+ if (node.kind === "ref") {
35422
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
35423
+ } else if (!visited.has(node)) {
35424
+ visited.add(node);
35425
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
35426
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
35427
+ else if (node.kind === "stream") pending.push(node.dict);
35428
+ }
35429
+ }
35430
+ if (references === 1) {
35431
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
35432
+ return;
35433
+ }
35434
+ }
35435
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
35436
+ }
35413
35437
  drawText(text, options) {
35414
35438
  const size = options.size ?? options.fontSize ?? 12;
35415
35439
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -48,11 +48,11 @@ import {
48
48
  trimImage,
49
49
  unflattenImage,
50
50
  unpremultiplyRgbaImage
51
- } from "./chunk-MENC7RPR.js";
51
+ } from "./chunk-WI35236J.js";
52
52
  import {
53
53
  PdfDocument,
54
54
  encodePng
55
- } from "./chunk-XRVNFK7Z.js";
55
+ } from "./chunk-H2FQA4OU.js";
56
56
  import {
57
57
  createLuaFilterCapability
58
58
  } from "./chunk-Y2KHC6TZ.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PdfDocument,
3
3
  renderPdfPageToPng
4
- } from "./chunk-XRVNFK7Z.js";
4
+ } from "./chunk-H2FQA4OU.js";
5
5
  import {
6
6
  init_buffer
7
7
  } from "./chunk-HX3SHTCE.js";
@@ -14675,7 +14675,7 @@ var is = class {
14675
14675
  let n = typeof e == "string" ? new TextEncoder().encode(e) : e;
14676
14676
  this.cachedContentAst = Ba(n), this.isolatedInitialStream = false;
14677
14677
  let a = Mt(n, { compress: t });
14678
- ke(this.pageDict, "Contents", this.cosDoc.allocateObject(a)), this.cachedContentsNode = K(this.pageDict, "Contents");
14678
+ this.replaceContentStream(a), this.cachedContentsNode = K(this.pageDict, "Contents");
14679
14679
  }
14680
14680
  getIsolatedContentAst() {
14681
14681
  let e = this.getContentAst();
@@ -14684,7 +14684,25 @@ var is = class {
14684
14684
  setContentAst(e, t = true) {
14685
14685
  this.cachedContentAst = [...e];
14686
14686
  let n = qd(this.cachedContentAst), a = Mt(n, { compress: t });
14687
- ke(this.pageDict, "Contents", this.cosDoc.allocateObject(a)), this.cachedContentsNode = K(this.pageDict, "Contents");
14687
+ this.replaceContentStream(a), this.cachedContentsNode = K(this.pageDict, "Contents");
14688
+ }
14689
+ replaceContentStream(e) {
14690
+ let t = K(this.pageDict, "Contents");
14691
+ if (t?.kind === "ref") {
14692
+ let n = 0, a = [...this.cosDoc.objects.values()].map((r) => r.value), i = /* @__PURE__ */ new Set();
14693
+ for (; a.length > 0 && n < 2; ) {
14694
+ let r = a.pop();
14695
+ if (r.kind === "ref") r.objectNumber === t.objectNumber && r.generationNumber === t.generationNumber && n++;
14696
+ else if (!i.has(r)) if (i.add(r), r.kind === "array") for (let o of r.items) a.push(o);
14697
+ else if (r.kind === "dict") for (let o of r.entries) a.push(o.value);
14698
+ else r.kind === "stream" && a.push(r.dict);
14699
+ }
14700
+ if (n === 1) {
14701
+ this.cosDoc.setObject(t.objectNumber, e, t.generationNumber);
14702
+ return;
14703
+ }
14704
+ }
14705
+ ke(this.pageDict, "Contents", this.cosDoc.allocateObject(e));
14688
14706
  }
14689
14707
  drawText(e, t) {
14690
14708
  let n = t.size ?? t.fontSize ?? 12, a = t.color ?? { r: 0, g: 0, b: 0 }, i = this.getIsolatedContentAst(), r, o;
@@ -28,8 +28,8 @@ import {
28
28
  thresholdImage,
29
29
  tintImage,
30
30
  trimImage
31
- } from "../safe-bash/command-chunks/chunk-MENC7RPR.js";
32
- import "../safe-bash/command-chunks/chunk-XRVNFK7Z.js";
31
+ } from "../safe-bash/command-chunks/chunk-WI35236J.js";
32
+ import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
33
33
  import {
34
34
  init_buffer
35
35
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -2,11 +2,11 @@ import {
2
2
  createPandocCommand,
3
3
  createPandocCommands,
4
4
  pandocCommands
5
- } from "../safe-bash/command-chunks/chunk-KB2LQ4HG.js";
5
+ } from "../safe-bash/command-chunks/chunk-KBBI4CSU.js";
6
6
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
7
7
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
8
- import "../safe-bash/command-chunks/chunk-MENC7RPR.js";
9
- import "../safe-bash/command-chunks/chunk-XRVNFK7Z.js";
8
+ import "../safe-bash/command-chunks/chunk-WI35236J.js";
9
+ import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
10
10
  import "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
11
11
  import "../safe-bash/command-chunks/chunk-YGYOVXTO.js";
12
12
  import "../safe-bash/command-chunks/chunk-I5GLTNVH.js";
@@ -21,11 +21,11 @@ import {
21
21
  readDocument,
22
22
  resolveConversionArgs,
23
23
  writeDocument
24
- } from "../safe-bash/command-chunks/chunk-KB2LQ4HG.js";
24
+ } from "../safe-bash/command-chunks/chunk-KBBI4CSU.js";
25
25
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
26
26
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
27
- import "../safe-bash/command-chunks/chunk-MENC7RPR.js";
28
- import "../safe-bash/command-chunks/chunk-XRVNFK7Z.js";
27
+ import "../safe-bash/command-chunks/chunk-WI35236J.js";
28
+ import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
29
29
  import {
30
30
  createLuaFilterCapability
31
31
  } from "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
@@ -38482,7 +38482,7 @@ var PdfPage = class {
38482
38482
  this.cachedContentAst = parseContentStream(bytes);
38483
38483
  this.isolatedInitialStream = false;
38484
38484
  const stm = cosStream(bytes, { compress });
38485
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38485
+ this.replaceContentStream(stm);
38486
38486
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38487
38487
  }
38488
38488
  getIsolatedContentAst() {
@@ -38499,9 +38499,33 @@ var PdfPage = class {
38499
38499
  this.cachedContentAst = [...nodes];
38500
38500
  const bytes = serializeContentAst(this.cachedContentAst);
38501
38501
  const streamObj = cosStream(bytes, { compress });
38502
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38502
+ this.replaceContentStream(streamObj);
38503
38503
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38504
38504
  }
38505
+ replaceContentStream(stream) {
38506
+ const contents = dictGet(this.pageDict, "Contents");
38507
+ if (contents?.kind === "ref") {
38508
+ let references = 0;
38509
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38510
+ const visited = /* @__PURE__ */ new Set();
38511
+ while (pending.length > 0 && references < 2) {
38512
+ const node = pending.pop();
38513
+ if (node.kind === "ref") {
38514
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38515
+ } else if (!visited.has(node)) {
38516
+ visited.add(node);
38517
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38518
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38519
+ else if (node.kind === "stream") pending.push(node.dict);
38520
+ }
38521
+ }
38522
+ if (references === 1) {
38523
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38524
+ return;
38525
+ }
38526
+ }
38527
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38528
+ }
38505
38529
  drawText(text, options) {
38506
38530
  const size = options.size ?? options.fontSize ?? 12;
38507
38531
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -38676,7 +38676,7 @@ var PdfPage = class {
38676
38676
  this.cachedContentAst = parseContentStream(bytes);
38677
38677
  this.isolatedInitialStream = false;
38678
38678
  const stm = cosStream(bytes, { compress });
38679
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38679
+ this.replaceContentStream(stm);
38680
38680
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38681
38681
  }
38682
38682
  getIsolatedContentAst() {
@@ -38693,9 +38693,33 @@ var PdfPage = class {
38693
38693
  this.cachedContentAst = [...nodes];
38694
38694
  const bytes = serializeContentAst(this.cachedContentAst);
38695
38695
  const streamObj = cosStream(bytes, { compress });
38696
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38696
+ this.replaceContentStream(streamObj);
38697
38697
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38698
38698
  }
38699
+ replaceContentStream(stream) {
38700
+ const contents = dictGet(this.pageDict, "Contents");
38701
+ if (contents?.kind === "ref") {
38702
+ let references = 0;
38703
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38704
+ const visited = /* @__PURE__ */ new Set();
38705
+ while (pending.length > 0 && references < 2) {
38706
+ const node = pending.pop();
38707
+ if (node.kind === "ref") {
38708
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38709
+ } else if (!visited.has(node)) {
38710
+ visited.add(node);
38711
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38712
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38713
+ else if (node.kind === "stream") pending.push(node.dict);
38714
+ }
38715
+ }
38716
+ if (references === 1) {
38717
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38718
+ return;
38719
+ }
38720
+ }
38721
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38722
+ }
38699
38723
  drawText(text, options) {
38700
38724
  const size = options.size ?? options.fontSize ?? 12;
38701
38725
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -38701,7 +38701,7 @@ var PdfPage = class {
38701
38701
  this.cachedContentAst = parseContentStream(bytes);
38702
38702
  this.isolatedInitialStream = false;
38703
38703
  const stm = cosStream(bytes, { compress });
38704
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38704
+ this.replaceContentStream(stm);
38705
38705
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38706
38706
  }
38707
38707
  getIsolatedContentAst() {
@@ -38718,9 +38718,33 @@ var PdfPage = class {
38718
38718
  this.cachedContentAst = [...nodes];
38719
38719
  const bytes = serializeContentAst(this.cachedContentAst);
38720
38720
  const streamObj = cosStream(bytes, { compress });
38721
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38721
+ this.replaceContentStream(streamObj);
38722
38722
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38723
38723
  }
38724
+ replaceContentStream(stream) {
38725
+ const contents = dictGet(this.pageDict, "Contents");
38726
+ if (contents?.kind === "ref") {
38727
+ let references = 0;
38728
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38729
+ const visited = /* @__PURE__ */ new Set();
38730
+ while (pending.length > 0 && references < 2) {
38731
+ const node = pending.pop();
38732
+ if (node.kind === "ref") {
38733
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38734
+ } else if (!visited.has(node)) {
38735
+ visited.add(node);
38736
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38737
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38738
+ else if (node.kind === "stream") pending.push(node.dict);
38739
+ }
38740
+ }
38741
+ if (references === 1) {
38742
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38743
+ return;
38744
+ }
38745
+ }
38746
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38747
+ }
38724
38748
  drawText(text, options) {
38725
38749
  const size = options.size ?? options.fontSize ?? 12;
38726
38750
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -38331,7 +38331,7 @@ var PdfPage = class {
38331
38331
  this.cachedContentAst = parseContentStream(bytes);
38332
38332
  this.isolatedInitialStream = false;
38333
38333
  const stm = cosStream(bytes, { compress });
38334
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38334
+ this.replaceContentStream(stm);
38335
38335
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38336
38336
  }
38337
38337
  getIsolatedContentAst() {
@@ -38348,9 +38348,33 @@ var PdfPage = class {
38348
38348
  this.cachedContentAst = [...nodes];
38349
38349
  const bytes = serializeContentAst(this.cachedContentAst);
38350
38350
  const streamObj = cosStream(bytes, { compress });
38351
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38351
+ this.replaceContentStream(streamObj);
38352
38352
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38353
38353
  }
38354
+ replaceContentStream(stream) {
38355
+ const contents = dictGet(this.pageDict, "Contents");
38356
+ if (contents?.kind === "ref") {
38357
+ let references = 0;
38358
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38359
+ const visited = /* @__PURE__ */ new Set();
38360
+ while (pending.length > 0 && references < 2) {
38361
+ const node = pending.pop();
38362
+ if (node.kind === "ref") {
38363
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38364
+ } else if (!visited.has(node)) {
38365
+ visited.add(node);
38366
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38367
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38368
+ else if (node.kind === "stream") pending.push(node.dict);
38369
+ }
38370
+ }
38371
+ if (references === 1) {
38372
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38373
+ return;
38374
+ }
38375
+ }
38376
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38377
+ }
38354
38378
  drawText(text, options) {
38355
38379
  const size = options.size ?? options.fontSize ?? 12;
38356
38380
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -38482,7 +38482,7 @@ var PdfPage = class {
38482
38482
  this.cachedContentAst = parseContentStream(bytes);
38483
38483
  this.isolatedInitialStream = false;
38484
38484
  const stm = cosStream(bytes, { compress });
38485
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38485
+ this.replaceContentStream(stm);
38486
38486
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38487
38487
  }
38488
38488
  getIsolatedContentAst() {
@@ -38499,9 +38499,33 @@ var PdfPage = class {
38499
38499
  this.cachedContentAst = [...nodes];
38500
38500
  const bytes = serializeContentAst(this.cachedContentAst);
38501
38501
  const streamObj = cosStream(bytes, { compress });
38502
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38502
+ this.replaceContentStream(streamObj);
38503
38503
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38504
38504
  }
38505
+ replaceContentStream(stream) {
38506
+ const contents = dictGet(this.pageDict, "Contents");
38507
+ if (contents?.kind === "ref") {
38508
+ let references = 0;
38509
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38510
+ const visited = /* @__PURE__ */ new Set();
38511
+ while (pending.length > 0 && references < 2) {
38512
+ const node = pending.pop();
38513
+ if (node.kind === "ref") {
38514
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38515
+ } else if (!visited.has(node)) {
38516
+ visited.add(node);
38517
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38518
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38519
+ else if (node.kind === "stream") pending.push(node.dict);
38520
+ }
38521
+ }
38522
+ if (references === 1) {
38523
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38524
+ return;
38525
+ }
38526
+ }
38527
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38528
+ }
38505
38529
  drawText(text, options) {
38506
38530
  const size = options.size ?? options.fontSize ?? 12;
38507
38531
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -38247,7 +38247,7 @@ var PdfPage = class {
38247
38247
  this.cachedContentAst = parseContentStream(bytes);
38248
38248
  this.isolatedInitialStream = false;
38249
38249
  const stm = cosStream(bytes, { compress });
38250
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38250
+ this.replaceContentStream(stm);
38251
38251
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38252
38252
  }
38253
38253
  getIsolatedContentAst() {
@@ -38264,9 +38264,33 @@ var PdfPage = class {
38264
38264
  this.cachedContentAst = [...nodes];
38265
38265
  const bytes = serializeContentAst(this.cachedContentAst);
38266
38266
  const streamObj = cosStream(bytes, { compress });
38267
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38267
+ this.replaceContentStream(streamObj);
38268
38268
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38269
38269
  }
38270
+ replaceContentStream(stream) {
38271
+ const contents = dictGet(this.pageDict, "Contents");
38272
+ if (contents?.kind === "ref") {
38273
+ let references = 0;
38274
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38275
+ const visited = /* @__PURE__ */ new Set();
38276
+ while (pending.length > 0 && references < 2) {
38277
+ const node = pending.pop();
38278
+ if (node.kind === "ref") {
38279
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38280
+ } else if (!visited.has(node)) {
38281
+ visited.add(node);
38282
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38283
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38284
+ else if (node.kind === "stream") pending.push(node.dict);
38285
+ }
38286
+ }
38287
+ if (references === 1) {
38288
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38289
+ return;
38290
+ }
38291
+ }
38292
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38293
+ }
38270
38294
  drawText(text, options) {
38271
38295
  const size = options.size ?? options.fontSize ?? 12;
38272
38296
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -11,8 +11,8 @@ import {
11
11
  readImageMetadata,
12
12
  resizeImage,
13
13
  rotateImage
14
- } from "../safe-bash/command-chunks/chunk-MENC7RPR.js";
15
- import "../safe-bash/command-chunks/chunk-XRVNFK7Z.js";
14
+ } from "../safe-bash/command-chunks/chunk-WI35236J.js";
15
+ import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
16
16
  import {
17
17
  init_buffer
18
18
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -31,7 +31,7 @@ import {
31
31
  PdfDocument,
32
32
  decodeFlate,
33
33
  rgb
34
- } from "../safe-bash/command-chunks/chunk-XRVNFK7Z.js";
34
+ } from "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
35
35
  import {
36
36
  init_buffer
37
37
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -211564,7 +211564,7 @@ var PdfPage = class {
211564
211564
  this.cachedContentAst = parseContentStream(bytes);
211565
211565
  this.isolatedInitialStream = false;
211566
211566
  const stm = cosStream(bytes, { compress });
211567
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
211567
+ this.replaceContentStream(stm);
211568
211568
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
211569
211569
  }
211570
211570
  getIsolatedContentAst() {
@@ -211581,9 +211581,33 @@ var PdfPage = class {
211581
211581
  this.cachedContentAst = [...nodes];
211582
211582
  const bytes = serializeContentAst(this.cachedContentAst);
211583
211583
  const streamObj = cosStream(bytes, { compress });
211584
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
211584
+ this.replaceContentStream(streamObj);
211585
211585
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
211586
211586
  }
211587
+ replaceContentStream(stream) {
211588
+ const contents = dictGet(this.pageDict, "Contents");
211589
+ if (contents?.kind === "ref") {
211590
+ let references = 0;
211591
+ const pending = [...this.cosDoc.objects.values()].map((object5) => object5.value);
211592
+ const visited = /* @__PURE__ */ new Set();
211593
+ while (pending.length > 0 && references < 2) {
211594
+ const node3 = pending.pop();
211595
+ if (node3.kind === "ref") {
211596
+ if (node3.objectNumber === contents.objectNumber && node3.generationNumber === contents.generationNumber) references++;
211597
+ } else if (!visited.has(node3)) {
211598
+ visited.add(node3);
211599
+ if (node3.kind === "array") for (const item of node3.items) pending.push(item);
211600
+ else if (node3.kind === "dict") for (const entry2 of node3.entries) pending.push(entry2.value);
211601
+ else if (node3.kind === "stream") pending.push(node3.dict);
211602
+ }
211603
+ }
211604
+ if (references === 1) {
211605
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
211606
+ return;
211607
+ }
211608
+ }
211609
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
211610
+ }
211587
211611
  drawText(text2, options) {
211588
211612
  const size = options.size ?? options.fontSize ?? 12;
211589
211613
  const color5 = options.color ?? { r: 0, g: 0, b: 0 };
@@ -40688,7 +40688,7 @@ var init_dist = __esm({
40688
40688
  this.cachedContentAst = parseContentStream(bytes);
40689
40689
  this.isolatedInitialStream = false;
40690
40690
  const stm = cosStream(bytes, { compress });
40691
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
40691
+ this.replaceContentStream(stm);
40692
40692
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
40693
40693
  }
40694
40694
  getIsolatedContentAst() {
@@ -40705,9 +40705,33 @@ var init_dist = __esm({
40705
40705
  this.cachedContentAst = [...nodes];
40706
40706
  const bytes = serializeContentAst(this.cachedContentAst);
40707
40707
  const streamObj = cosStream(bytes, { compress });
40708
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
40708
+ this.replaceContentStream(streamObj);
40709
40709
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
40710
40710
  }
40711
+ replaceContentStream(stream) {
40712
+ const contents = dictGet(this.pageDict, "Contents");
40713
+ if (contents?.kind === "ref") {
40714
+ let references = 0;
40715
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
40716
+ const visited = /* @__PURE__ */ new Set();
40717
+ while (pending.length > 0 && references < 2) {
40718
+ const node = pending.pop();
40719
+ if (node.kind === "ref") {
40720
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
40721
+ } else if (!visited.has(node)) {
40722
+ visited.add(node);
40723
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
40724
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
40725
+ else if (node.kind === "stream") pending.push(node.dict);
40726
+ }
40727
+ }
40728
+ if (references === 1) {
40729
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
40730
+ return;
40731
+ }
40732
+ }
40733
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
40734
+ }
40711
40735
  drawText(text, options) {
40712
40736
  const size = options.size ?? options.fontSize ?? 12;
40713
40737
  const color = options.color ?? { r: 0, g: 0, b: 0 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-bash",
3
- "version": "0.1.755",
3
+ "version": "0.1.756",
4
4
  "description": "Extensible virtual shell with pluggable filesystems and streaming commands",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -837,7 +837,7 @@
837
837
  "access": "public"
838
838
  },
839
839
  "dependencies": {
840
- "@poe-platform/safe-fs": "0.1.755",
840
+ "@poe-platform/safe-fs": "0.1.756",
841
841
  "pdf-lib": "1.17.1",
842
842
  "@noble/hashes": "2.4.0",
843
843
  "pako": "3.0.1",
@@ -286,7 +286,7 @@ cases exercise direct and chained references to the shading stream.
286
286
  `tests/test_writer.py`, replacing its downloaded PDF with an in-memory page
287
287
  and checking every copy and save/reopen. Page copying follows `_writer.py`
288
288
  `_add_page`: each occurrence gets a distinct page dictionary while resources
289
- can remain shared. Content edits replace the page's Contents reference so
289
+ can remain shared. Edits to shared content replace the page's Contents reference so
290
290
  other pages retain their original stream. pypdf attribution/license is above.
291
291
 
292
292
  Windows Symbol cmap selection in `src/content/evaluator.ts` follows PDF.js