@poe-platform/safe-bash 0.1.754 → 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 (52) hide show
  1. package/dist/image-ast/index.browser.js +39 -3
  2. package/dist/image-ast/index.js +39 -3
  3. package/dist/pdf-ast/canvas.d.ts +1 -0
  4. package/dist/pdf-ast/fonts/truetype.d.ts +1 -0
  5. package/dist/pdf-ast/index.js +39 -3
  6. package/dist/safe-bash/chunks/{chunk-3W6CRM25.js → chunk-CBVANNKK.js} +553 -289
  7. package/dist/safe-bash/chunks/{chunk-R2WG64VB.js → chunk-JCN3FXLP.js} +40 -4
  8. package/dist/safe-bash/chunks/{chunk-WNB4XH45.js → chunk-OSUXMC43.js} +3 -3
  9. package/dist/safe-bash/chunks/{chunk-37Y7GZTK.js → chunk-RSAWYAEH.js} +2 -2
  10. package/dist/safe-bash/chunks/{pdf-renderer-DHQDZC6N.js → pdf-renderer-CMF3CSVU.js} +3 -3
  11. package/dist/safe-bash/chunks/{src-S52LORVD.js → src-MXIKQCIC.js} +5 -3
  12. package/dist/safe-bash/command-chunks/{chunk-IJHV6I6X.js → chunk-3DOHQQJR.js} +8 -6
  13. package/dist/safe-bash/command-chunks/{chunk-PUOJAS3O.js → chunk-H2FQA4OU.js} +39 -3
  14. package/dist/safe-bash/command-chunks/chunk-IDR3WWKI.js +46 -0
  15. package/dist/safe-bash/command-chunks/{chunk-XAZ3NTJ4.js → chunk-KBBI4CSU.js} +2 -2
  16. package/dist/safe-bash/command-chunks/{chunk-YY7HJMBG.js → chunk-KOM3FNCE.js} +1 -37
  17. package/dist/safe-bash/command-chunks/chunk-QQOAK7JQ.js +888 -0
  18. package/dist/safe-bash/command-chunks/{chunk-BE4AM2JW.js → chunk-UGX6MXDD.js} +5 -3
  19. package/dist/safe-bash/command-chunks/{chunk-CM4SVTIA.js → chunk-WI35236J.js} +1 -1
  20. package/dist/safe-bash/commands/ssconvert/index.d.ts +1 -2
  21. package/dist/safe-bash/commands/ssconvert/index.js +6 -260
  22. package/dist/safe-bash/core.browser.js +5 -207
  23. package/dist/safe-bash-command-csvkit/index.js +277 -49
  24. package/dist/safe-bash-command-ffmpeg/index.js +1741 -1717
  25. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  26. package/dist/safe-bash-command-pandoc/command.js +3 -3
  27. package/dist/safe-bash-command-pandoc/index.js +3 -3
  28. package/dist/safe-bash-command-pdfimages/index.js +39 -3
  29. package/dist/safe-bash-command-pdfinfo/index.js +39 -3
  30. package/dist/safe-bash-command-pdftk/index.js +39 -3
  31. package/dist/safe-bash-command-pdftoppm/index.js +39 -3
  32. package/dist/safe-bash-command-pdftotext/index.js +39 -3
  33. package/dist/safe-bash-command-qpdf/index.js +39 -3
  34. package/dist/safe-bash-command-sips/index.js +2 -2
  35. package/dist/safe-bash-command-soffice/index.js +5 -4
  36. package/dist/safe-bash-command-ssconvert/formats/csv.js +4 -3
  37. package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +4 -2
  38. package/dist/safe-bash-command-ssconvert/formats/xls.js +10 -666
  39. package/dist/safe-bash-command-ssconvert/index.d.ts +1 -0
  40. package/dist/safe-bash-command-ssconvert/index.js +706 -392
  41. package/dist/safe-bash-command-ssconvert/sync.d.ts +7 -0
  42. package/dist/safe-bash-command-timeout/index.js +1 -1
  43. package/dist/safe-bash-command-wkhtmltopdf/index.js +39 -3
  44. package/dist/spreadsheet-format-csv/text-export.d.ts +14 -0
  45. package/dist/spreadsheet-format-csv/text-export.js +2 -2
  46. package/dist/spreadsheet-format-xls/biff-binary.d.ts +7 -2
  47. package/dist/spreadsheet-format-xls/biff-binary.js +10 -1
  48. package/dist/spreadsheet-format-xls/biff-strings.d.ts +2 -3
  49. package/dist/spreadsheet-format-xls/biff-strings.js +14 -2
  50. package/package.json +2 -3
  51. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +8 -1
  52. package/dist/safe-bash/command-chunks/chunk-MPUNHXWI.js +0 -205
@@ -34663,17 +34663,22 @@ function parseTrueTypeFont(bytes) {
34663
34663
  const cmapNumTables = cmap ? readU16(view, cmapOffset + 2) : 0;
34664
34664
  let format4Offset = 0;
34665
34665
  let format12Offset = 0;
34666
+ let format4IsSymbolic = false;
34667
+ let format12IsSymbolic = false;
34666
34668
  for (let i = 0; i < cmapNumTables; i++) {
34667
34669
  const rec = cmapOffset + 4 + i * 8;
34668
34670
  if (rec + 8 > bytes.byteLength) break;
34669
34671
  const platformID = readU16(view, rec);
34672
+ const encodingID = readU16(view, rec + 2);
34670
34673
  const subOffset = cmapOffset + readU32(view, rec + 4);
34671
34674
  if (subOffset + 4 > bytes.byteLength) continue;
34672
34675
  const fmt = readU16(view, subOffset);
34673
34676
  if (fmt === 12 && (platformID === 3 || platformID === 0)) {
34674
34677
  format12Offset = subOffset;
34678
+ format12IsSymbolic = platformID === 3 && encodingID === 0;
34675
34679
  } else if (fmt === 4 && (platformID === 3 || platformID === 0)) {
34676
34680
  format4Offset = subOffset;
34681
+ format4IsSymbolic = platformID === 3 && encodingID === 0;
34677
34682
  }
34678
34683
  }
34679
34684
  if (format12Offset > 0) {
@@ -34962,6 +34967,7 @@ function parseTrueTypeFont(bytes) {
34962
34967
  numGlyphs,
34963
34968
  isCff: renderCffGlyph !== void 0,
34964
34969
  hasCmap: cmap !== void 0,
34970
+ isSymbolicCmap: format12Offset > 0 ? format12IsSymbolic : format4IsSymbolic,
34965
34971
  glyphNames,
34966
34972
  getGlyphId(codePoint) {
34967
34973
  return codePointToGlyph.get(codePoint) ?? 0;
@@ -42547,7 +42553,13 @@ function resolvePageFonts(doc, resourcesDict) {
42547
42553
  embeddedCff = parseEmbeddedCffFont(doc.decodeStream(program), baseEncoding?.kind === "name" ? baseEncoding.decoded : void 0, glyphNames);
42548
42554
  } else {
42549
42555
  embeddedTrueType = parseTrueTypeFont(doc.decodeStream(program));
42550
- if (subtype !== "Type0" && !embeddedTrueType.hasCmap) {
42556
+ if (subtype !== "Type0" && embeddedTrueType.isSymbolicCmap) {
42557
+ simpleToGid = /* @__PURE__ */ new Map();
42558
+ for (let code = 0; code < 256; code++) {
42559
+ const gid = embeddedTrueType.getGlyphId(61440 + code) || embeddedTrueType.getGlyphId(code);
42560
+ if (gid > 0) simpleToGid.set(code, gid);
42561
+ }
42562
+ } else if (subtype !== "Type0" && !embeddedTrueType.hasCmap) {
42551
42563
  simpleToGid = /* @__PURE__ */ new Map();
42552
42564
  const encoding = baseEncoding?.kind === "name" ? getEncoding(baseEncoding.decoded) : void 0;
42553
42565
  for (let code = 0; code < 256; code++) {
@@ -46124,7 +46136,7 @@ var PdfPage = class {
46124
46136
  this.cachedContentAst = parseContentStream(bytes);
46125
46137
  this.isolatedInitialStream = false;
46126
46138
  const stm = cosStream(bytes, { compress });
46127
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
46139
+ this.replaceContentStream(stm);
46128
46140
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46129
46141
  }
46130
46142
  getIsolatedContentAst() {
@@ -46141,9 +46153,33 @@ var PdfPage = class {
46141
46153
  this.cachedContentAst = [...nodes];
46142
46154
  const bytes = serializeContentAst(this.cachedContentAst);
46143
46155
  const streamObj = cosStream(bytes, { compress });
46144
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
46156
+ this.replaceContentStream(streamObj);
46145
46157
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46146
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
+ }
46147
46183
  drawText(text, options) {
46148
46184
  const size = options.size ?? options.fontSize ?? 12;
46149
46185
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -34663,17 +34663,22 @@ function parseTrueTypeFont(bytes) {
34663
34663
  const cmapNumTables = cmap ? readU16(view, cmapOffset + 2) : 0;
34664
34664
  let format4Offset = 0;
34665
34665
  let format12Offset = 0;
34666
+ let format4IsSymbolic = false;
34667
+ let format12IsSymbolic = false;
34666
34668
  for (let i = 0; i < cmapNumTables; i++) {
34667
34669
  const rec = cmapOffset + 4 + i * 8;
34668
34670
  if (rec + 8 > bytes.byteLength) break;
34669
34671
  const platformID = readU16(view, rec);
34672
+ const encodingID = readU16(view, rec + 2);
34670
34673
  const subOffset = cmapOffset + readU32(view, rec + 4);
34671
34674
  if (subOffset + 4 > bytes.byteLength) continue;
34672
34675
  const fmt = readU16(view, subOffset);
34673
34676
  if (fmt === 12 && (platformID === 3 || platformID === 0)) {
34674
34677
  format12Offset = subOffset;
34678
+ format12IsSymbolic = platformID === 3 && encodingID === 0;
34675
34679
  } else if (fmt === 4 && (platformID === 3 || platformID === 0)) {
34676
34680
  format4Offset = subOffset;
34681
+ format4IsSymbolic = platformID === 3 && encodingID === 0;
34677
34682
  }
34678
34683
  }
34679
34684
  if (format12Offset > 0) {
@@ -34962,6 +34967,7 @@ function parseTrueTypeFont(bytes) {
34962
34967
  numGlyphs,
34963
34968
  isCff: renderCffGlyph !== void 0,
34964
34969
  hasCmap: cmap !== void 0,
34970
+ isSymbolicCmap: format12Offset > 0 ? format12IsSymbolic : format4IsSymbolic,
34965
34971
  glyphNames,
34966
34972
  getGlyphId(codePoint) {
34967
34973
  return codePointToGlyph.get(codePoint) ?? 0;
@@ -42547,7 +42553,13 @@ function resolvePageFonts(doc, resourcesDict) {
42547
42553
  embeddedCff = parseEmbeddedCffFont(doc.decodeStream(program), baseEncoding?.kind === "name" ? baseEncoding.decoded : void 0, glyphNames);
42548
42554
  } else {
42549
42555
  embeddedTrueType = parseTrueTypeFont(doc.decodeStream(program));
42550
- if (subtype !== "Type0" && !embeddedTrueType.hasCmap) {
42556
+ if (subtype !== "Type0" && embeddedTrueType.isSymbolicCmap) {
42557
+ simpleToGid = /* @__PURE__ */ new Map();
42558
+ for (let code = 0; code < 256; code++) {
42559
+ const gid = embeddedTrueType.getGlyphId(61440 + code) || embeddedTrueType.getGlyphId(code);
42560
+ if (gid > 0) simpleToGid.set(code, gid);
42561
+ }
42562
+ } else if (subtype !== "Type0" && !embeddedTrueType.hasCmap) {
42551
42563
  simpleToGid = /* @__PURE__ */ new Map();
42552
42564
  const encoding = baseEncoding?.kind === "name" ? getEncoding(baseEncoding.decoded) : void 0;
42553
42565
  for (let code = 0; code < 256; code++) {
@@ -46124,7 +46136,7 @@ var PdfPage = class {
46124
46136
  this.cachedContentAst = parseContentStream(bytes);
46125
46137
  this.isolatedInitialStream = false;
46126
46138
  const stm = cosStream(bytes, { compress });
46127
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
46139
+ this.replaceContentStream(stm);
46128
46140
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46129
46141
  }
46130
46142
  getIsolatedContentAst() {
@@ -46141,9 +46153,33 @@ var PdfPage = class {
46141
46153
  this.cachedContentAst = [...nodes];
46142
46154
  const bytes = serializeContentAst(this.cachedContentAst);
46143
46155
  const streamObj = cosStream(bytes, { compress });
46144
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
46156
+ this.replaceContentStream(streamObj);
46145
46157
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46146
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
+ }
46147
46183
  drawText(text, options) {
46148
46184
  const size = options.size ?? options.fontSize ?? 12;
46149
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;
@@ -13,6 +13,7 @@ export interface ParsedTrueTypeFont {
13
13
  readonly numGlyphs: number;
14
14
  readonly isCff: boolean;
15
15
  readonly hasCmap: boolean;
16
+ readonly isSymbolicCmap: boolean;
16
17
  readonly glyphNames: readonly (string | undefined)[];
17
18
  getGlyphId(codePoint: number): number;
18
19
  getAdvanceWidthUnits(glyphId: number): number;
@@ -27006,17 +27006,22 @@ function parseTrueTypeFont(bytes) {
27006
27006
  const cmapNumTables = cmap ? readU16(view, cmapOffset + 2) : 0;
27007
27007
  let format4Offset = 0;
27008
27008
  let format12Offset = 0;
27009
+ let format4IsSymbolic = false;
27010
+ let format12IsSymbolic = false;
27009
27011
  for (let i = 0; i < cmapNumTables; i++) {
27010
27012
  const rec = cmapOffset + 4 + i * 8;
27011
27013
  if (rec + 8 > bytes.byteLength) break;
27012
27014
  const platformID = readU16(view, rec);
27015
+ const encodingID = readU16(view, rec + 2);
27013
27016
  const subOffset = cmapOffset + readU32(view, rec + 4);
27014
27017
  if (subOffset + 4 > bytes.byteLength) continue;
27015
27018
  const fmt = readU16(view, subOffset);
27016
27019
  if (fmt === 12 && (platformID === 3 || platformID === 0)) {
27017
27020
  format12Offset = subOffset;
27021
+ format12IsSymbolic = platformID === 3 && encodingID === 0;
27018
27022
  } else if (fmt === 4 && (platformID === 3 || platformID === 0)) {
27019
27023
  format4Offset = subOffset;
27024
+ format4IsSymbolic = platformID === 3 && encodingID === 0;
27020
27025
  }
27021
27026
  }
27022
27027
  if (format12Offset > 0) {
@@ -27305,6 +27310,7 @@ function parseTrueTypeFont(bytes) {
27305
27310
  numGlyphs,
27306
27311
  isCff: renderCffGlyph !== void 0,
27307
27312
  hasCmap: cmap !== void 0,
27313
+ isSymbolicCmap: format12Offset > 0 ? format12IsSymbolic : format4IsSymbolic,
27308
27314
  glyphNames,
27309
27315
  getGlyphId(codePoint) {
27310
27316
  return codePointToGlyph.get(codePoint) ?? 0;
@@ -35261,7 +35267,13 @@ function resolvePageFonts(doc, resourcesDict) {
35261
35267
  embeddedCff = parseEmbeddedCffFont(doc.decodeStream(program), baseEncoding?.kind === "name" ? baseEncoding.decoded : void 0, glyphNames);
35262
35268
  } else {
35263
35269
  embeddedTrueType = parseTrueTypeFont(doc.decodeStream(program));
35264
- if (subtype !== "Type0" && !embeddedTrueType.hasCmap) {
35270
+ if (subtype !== "Type0" && embeddedTrueType.isSymbolicCmap) {
35271
+ simpleToGid = /* @__PURE__ */ new Map();
35272
+ for (let code = 0; code < 256; code++) {
35273
+ const gid = embeddedTrueType.getGlyphId(61440 + code) || embeddedTrueType.getGlyphId(code);
35274
+ if (gid > 0) simpleToGid.set(code, gid);
35275
+ }
35276
+ } else if (subtype !== "Type0" && !embeddedTrueType.hasCmap) {
35265
35277
  simpleToGid = /* @__PURE__ */ new Map();
35266
35278
  const encoding = baseEncoding?.kind === "name" ? getEncoding(baseEncoding.decoded) : void 0;
35267
35279
  for (let code = 0; code < 256; code++) {
@@ -39527,7 +39539,7 @@ var PdfPage = class {
39527
39539
  this.cachedContentAst = parseContentStream(bytes);
39528
39540
  this.isolatedInitialStream = false;
39529
39541
  const stm = cosStream(bytes, { compress });
39530
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
39542
+ this.replaceContentStream(stm);
39531
39543
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
39532
39544
  }
39533
39545
  getIsolatedContentAst() {
@@ -39544,9 +39556,33 @@ var PdfPage = class {
39544
39556
  this.cachedContentAst = [...nodes];
39545
39557
  const bytes = serializeContentAst(this.cachedContentAst);
39546
39558
  const streamObj = cosStream(bytes, { compress });
39547
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
39559
+ this.replaceContentStream(streamObj);
39548
39560
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
39549
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
+ }
39550
39586
  drawText(text, options) {
39551
39587
  const size = options.size ?? options.fontSize ?? 12;
39552
39588
  const color = options.color ?? { r: 0, g: 0, b: 0 };