@poe-platform/safe-bash 0.1.756 → 0.1.758

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 (161) hide show
  1. package/dist/image-ast/index.browser.js +76 -23
  2. package/dist/image-ast/index.js +76 -23
  3. package/dist/pdf-ast/ast.d.ts +3 -0
  4. package/dist/pdf-ast/index.js +88 -36
  5. package/dist/safe-bash/chunks/{chunk-LESPJ3OG.js → chunk-WNWIBBJZ.js} +15 -2
  6. package/dist/safe-bash/command-chunks/{chunk-S4J6MSLY.js → chunk-444OTXM7.js} +3 -3
  7. package/dist/safe-bash/command-chunks/{chunk-F3J5ZLKF.js → chunk-522TDVLS.js} +1 -1
  8. package/dist/safe-bash/command-chunks/{chunk-VFS2MDAB.js → chunk-6YLD37NH.js} +2 -2
  9. package/dist/safe-bash/command-chunks/{chunk-YI3GKJ7Q.js → chunk-766IWMTB.js} +2 -2
  10. package/dist/safe-bash/command-chunks/{chunk-6AIOGLZO.js → chunk-CE6Z2ULX.js} +2 -2
  11. package/dist/safe-bash/command-chunks/{chunk-KSH2F6RG.js → chunk-CUFCNL6G.js} +1 -1
  12. package/dist/safe-bash/command-chunks/{chunk-5VSGEE6J.js → chunk-F4IQCXZG.js} +5 -5
  13. package/dist/safe-bash/command-chunks/{chunk-F5MORDSU.js → chunk-FDNCPZQS.js} +32 -1
  14. package/dist/safe-bash/command-chunks/{chunk-SG3ZDZCX.js → chunk-FLMLM7Y4.js} +2 -2
  15. package/dist/safe-bash/command-chunks/{chunk-DVZCHNB5.js → chunk-J2NPH7DO.js} +11 -7
  16. package/dist/safe-bash/command-chunks/{chunk-CT3FB722.js → chunk-J7UMKBRK.js} +1 -1
  17. package/dist/safe-bash/command-chunks/{chunk-QQOAK7JQ.js → chunk-KKJCKPTA.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-7KS6PX4U.js → chunk-KSIGF4AG.js} +3 -3
  19. package/dist/safe-bash/command-chunks/{chunk-KBBI4CSU.js → chunk-L2C5TIII.js} +2 -2
  20. package/dist/safe-bash/command-chunks/{chunk-4HQ7WYSI.js → chunk-MED2BOOW.js} +30 -5
  21. package/dist/safe-bash/command-chunks/{chunk-JRNLDPLI.js → chunk-OZSWW23M.js} +1 -1
  22. package/dist/safe-bash/command-chunks/{chunk-DKQ5REXF.js → chunk-QDPRSPHQ.js} +1 -1
  23. package/dist/safe-bash/command-chunks/{chunk-WOPU2VWF.js → chunk-RID3B5RE.js} +1 -1
  24. package/dist/safe-bash/command-chunks/{chunk-H2FQA4OU.js → chunk-TCAGGM44.js} +72 -19
  25. package/dist/safe-bash/command-chunks/{chunk-REYTQLLB.js → chunk-TT2DMDBY.js} +1 -1
  26. package/dist/safe-bash/command-chunks/{chunk-UGX6MXDD.js → chunk-UIIT4ULR.js} +3 -3
  27. package/dist/safe-bash/command-chunks/{chunk-A6NFLWZI.js → chunk-WKPOGTZY.js} +22 -6
  28. package/dist/safe-bash/command-chunks/{chunk-WI35236J.js → chunk-XYCWDGOG.js} +1 -1
  29. package/dist/safe-bash/command-chunks/{chunk-3DOHQQJR.js → chunk-Y64PA6IA.js} +8 -8
  30. package/dist/safe-bash/command-chunks/{chunk-4F6PG2OT.js → chunk-YJWWRCIG.js} +8 -8
  31. package/dist/safe-bash/command-chunks/{chunk-6Z7OS3TZ.js → chunk-ZP5KDHB4.js} +7 -7
  32. package/dist/safe-bash/commands/pandoc/index.d.ts +1 -1
  33. package/dist/safe-bash/commands/pandoc/index.js +5 -3
  34. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  35. package/dist/safe-bash/commands/python/index.js +6 -0
  36. package/dist/safe-bash/commands/python/jspi.js +11 -2
  37. package/dist/safe-bash/core.browser.js +6 -4
  38. package/dist/safe-bash-command-column/column.js +3 -3
  39. package/dist/safe-bash-command-column/index.js +3 -3
  40. package/dist/safe-bash-command-column/layout.js +2 -2
  41. package/dist/safe-bash-command-csvkit/index.js +8 -8
  42. package/dist/safe-bash-command-factor/command.js +2 -2
  43. package/dist/safe-bash-command-factor/index.js +2 -2
  44. package/dist/safe-bash-command-ffmpeg/index.js +5923 -5893
  45. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  46. package/dist/safe-bash-command-pandoc/command.js +3 -3
  47. package/dist/safe-bash-command-pandoc/index.js +3 -3
  48. package/dist/safe-bash-command-pdfimages/index.js +72 -19
  49. package/dist/safe-bash-command-pdfinfo/index.js +88 -36
  50. package/dist/safe-bash-command-pdftk/index.js +72 -19
  51. package/dist/safe-bash-command-pdftoppm/index.js +88 -36
  52. package/dist/safe-bash-command-pdftotext/index.js +72 -19
  53. package/dist/safe-bash-command-qpdf/index.js +72 -19
  54. package/dist/safe-bash-command-sips/index.js +2 -2
  55. package/dist/safe-bash-command-soffice/index.js +17 -17
  56. package/dist/safe-bash-command-ssconvert/command-bindings.d.ts +18 -0
  57. package/dist/safe-bash-command-ssconvert/command.d.ts +5 -14
  58. package/dist/safe-bash-command-ssconvert/commands.d.ts +6 -0
  59. package/dist/safe-bash-command-ssconvert/commands.js +871 -0
  60. package/dist/safe-bash-command-ssconvert/core.js +8 -8
  61. package/dist/safe-bash-command-ssconvert/formats/csv.js +9 -9
  62. package/dist/safe-bash-command-ssconvert/formats/ods.js +8 -8
  63. package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +1 -1
  64. package/dist/safe-bash-command-ssconvert/formats/xls.js +9 -8
  65. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +8 -8
  66. package/dist/safe-bash-command-ssconvert/index.js +376 -236
  67. package/dist/safe-bash-command-wkhtmltopdf/index.js +72 -19
  68. package/dist/safe-bash-command-yq/index.js +4 -4
  69. package/dist/safe-bash-compression-engine/files.js +2 -2
  70. package/dist/safe-bash-compression-engine/operand.js +4 -4
  71. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  72. package/dist/safe-bash-contracts/filesystem-output.js +1 -1
  73. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  74. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  75. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  76. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  77. package/dist/safe-bash-markdown-engine/index.js +7 -7
  78. package/dist/safe-bash-mcp/index.js +4 -4
  79. package/dist/safe-bash-query-engine/index.js +5 -5
  80. package/dist/safe-bash-query-engine/interpreter.js +4 -4
  81. package/dist/safe-bash-query-engine/query-core.js +5 -5
  82. package/dist/spreadsheet-engine/formulas/ast.d.ts +13 -0
  83. package/dist/spreadsheet-engine/formulas/conventions.js +1 -1
  84. package/dist/spreadsheet-engine/formulas/dependencies.js +2 -2
  85. package/dist/spreadsheet-engine/formulas/evaluator.js +2 -2
  86. package/dist/spreadsheet-engine/formulas/named-expressions.d.ts +2 -2
  87. package/dist/spreadsheet-engine/formulas/named-expressions.js +31 -5
  88. package/dist/spreadsheet-engine/formulas/parser.js +34 -0
  89. package/dist/spreadsheet-engine/formulas/rewriting.js +19 -1
  90. package/dist/spreadsheet-engine/formulas/serialization.js +6 -0
  91. package/dist/spreadsheet-format-xls/biff-write-formulas.js +2 -0
  92. package/dist/xlsx-ast/formula-semantics.js +2 -0
  93. package/package.json +6 -2
  94. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +16 -0
  95. package/dist/safe-bash/chunks/browser-ECQX6GMK.js +0 -6766
  96. package/dist/safe-bash/chunks/bz2-4OP3OWW3.js +0 -8
  97. package/dist/safe-bash/chunks/chunk-22XPAAOI.js +0 -173
  98. package/dist/safe-bash/chunks/chunk-44WUNUPV.js +0 -649
  99. package/dist/safe-bash/chunks/chunk-4E3SGG37.js +0 -876
  100. package/dist/safe-bash/chunks/chunk-4QTSSQKP.js +0 -898
  101. package/dist/safe-bash/chunks/chunk-5UVGPVXP.js +0 -410
  102. package/dist/safe-bash/chunks/chunk-64OE6Q6X.js +0 -3487
  103. package/dist/safe-bash/chunks/chunk-6IIFUPN2.js +0 -1526
  104. package/dist/safe-bash/chunks/chunk-BENDLTQD.js +0 -7065
  105. package/dist/safe-bash/chunks/chunk-BMO5LWEX.js +0 -534
  106. package/dist/safe-bash/chunks/chunk-BPMCPTNP.js +0 -1920
  107. package/dist/safe-bash/chunks/chunk-BRJTAWP5.js +0 -2955
  108. package/dist/safe-bash/chunks/chunk-C3GEIN7Q.js +0 -20054
  109. package/dist/safe-bash/chunks/chunk-CBVANNKK.js +0 -174814
  110. package/dist/safe-bash/chunks/chunk-CEWCRI6H.js +0 -2813
  111. package/dist/safe-bash/chunks/chunk-CGL53DQQ.js +0 -37
  112. package/dist/safe-bash/chunks/chunk-CTYJJD4O.js +0 -869
  113. package/dist/safe-bash/chunks/chunk-CWSS4MQA.js +0 -7
  114. package/dist/safe-bash/chunks/chunk-DLIGMTCP.js +0 -3266
  115. package/dist/safe-bash/chunks/chunk-EMAJ7WUW.js +0 -1031
  116. package/dist/safe-bash/chunks/chunk-FDKIZ2IJ.js +0 -1950
  117. package/dist/safe-bash/chunks/chunk-FZWJ2A7V.js +0 -3093
  118. package/dist/safe-bash/chunks/chunk-G2VCIF2J.js +0 -22
  119. package/dist/safe-bash/chunks/chunk-GVKBUQDX.js +0 -2649
  120. package/dist/safe-bash/chunks/chunk-IO2OGW3E.js +0 -28051
  121. package/dist/safe-bash/chunks/chunk-ISCZG7WA.js +0 -2648
  122. package/dist/safe-bash/chunks/chunk-JCN3FXLP.js +0 -38983
  123. package/dist/safe-bash/chunks/chunk-KJHDD4A2.js +0 -759
  124. package/dist/safe-bash/chunks/chunk-LB6HVRXS.js +0 -857
  125. package/dist/safe-bash/chunks/chunk-LLWAJOZH.js +0 -15
  126. package/dist/safe-bash/chunks/chunk-LMUKYZIJ.js +0 -708
  127. package/dist/safe-bash/chunks/chunk-M5SCNKIK.js +0 -2012
  128. package/dist/safe-bash/chunks/chunk-MJPFHANT.js +0 -3350
  129. package/dist/safe-bash/chunks/chunk-MZQW2DOL.js +0 -82
  130. package/dist/safe-bash/chunks/chunk-NB2V7EOY.js +0 -1348
  131. package/dist/safe-bash/chunks/chunk-NJVGOIYN.js +0 -17
  132. package/dist/safe-bash/chunks/chunk-OLNZHDIQ.js +0 -5141
  133. package/dist/safe-bash/chunks/chunk-OSUXMC43.js +0 -2317
  134. package/dist/safe-bash/chunks/chunk-OUUVROTM.js +0 -38
  135. package/dist/safe-bash/chunks/chunk-PA6GYKBQ.js +0 -151
  136. package/dist/safe-bash/chunks/chunk-PEFHZ226.js +0 -6957
  137. package/dist/safe-bash/chunks/chunk-QBB5P5KW.js +0 -4839
  138. package/dist/safe-bash/chunks/chunk-RSAWYAEH.js +0 -973
  139. package/dist/safe-bash/chunks/chunk-UWLYRWT4.js +0 -739
  140. package/dist/safe-bash/chunks/chunk-V463NBQH.js +0 -13
  141. package/dist/safe-bash/chunks/chunk-WPUALYUS.js +0 -843
  142. package/dist/safe-bash/chunks/chunk-XHKFSRGU.js +0 -5747
  143. package/dist/safe-bash/chunks/chunk-XHRCLZ3N.js +0 -13391
  144. package/dist/safe-bash/chunks/chunk-XPF5XHLY.js +0 -15
  145. package/dist/safe-bash/chunks/chunk-ZBFOWARG.js +0 -305
  146. package/dist/safe-bash/chunks/chunk-ZG7GWQ5P.js +0 -1859
  147. package/dist/safe-bash/chunks/model-store-EIY3ZQLZ.js +0 -10
  148. package/dist/safe-bash/chunks/pdf-renderer-CMF3CSVU.js +0 -22
  149. package/dist/safe-bash/chunks/pptx-ZL6L7KP2-O425BFIU.js +0 -30658
  150. package/dist/safe-bash/chunks/src-HHEPGR7U.js +0 -18969
  151. package/dist/safe-bash/chunks/src-MXIKQCIC.js +0 -187
  152. package/dist/safe-bash/chunks/usage-6TGVA2OM.js +0 -35
  153. package/dist/safe-bash/chunks/xz-EGQGQUEI.js +0 -8
  154. package/dist/safe-bash/chunks/xz-K2E2WLM6.js +0 -9
  155. package/dist/safe-bash/chunks/zstd-6JBLP5EF.js +0 -8
  156. package/dist/safe-bash/git_rust-C3QYOAZL.wasm +0 -0
  157. package/dist/safe-bash/command-chunks/{chunk-OQVIJMBY.js → chunk-7HINP7ZK.js} +4 -4
  158. package/dist/safe-bash/command-chunks/{chunk-XAYEDOV5.js → chunk-CG4JSOK2.js} +3 -3
  159. package/dist/safe-bash/command-chunks/{chunk-YIK4ZYQ4.js → chunk-DC52GWRK.js} +9 -9
  160. package/dist/safe-bash/command-chunks/{chunk-TOTZFBDT.js → chunk-TKACIO4X.js} +4 -4
  161. package/dist/safe-bash/command-chunks/{chunk-VTWKS4RM.js → chunk-WF2LSKMI.js} +3 -3
@@ -1,15 +0,0 @@
1
- import {
2
- __reExport,
3
- init_platform
4
- } from "./chunk-ZG7GWQ5P.js";
5
-
6
- // packages/safe-bash/src/contracts/yield.ts
7
- var yield_exports = {};
8
- init_platform();
9
- __reExport(yield_exports, yield_star);
10
- import * as yield_star from "../../safe-bash-contracts/yield.js";
11
-
12
- export {
13
- yield_exports
14
- };
15
- //# sourceMappingURL=chunk-XPF5XHLY.js.map
@@ -1,305 +0,0 @@
1
- import {
2
- init_platform
3
- } from "./chunk-ZG7GWQ5P.js";
4
-
5
- // packages/safe-bash-command-file/src/classify.ts
6
- init_platform();
7
- var binary = { description: "data", mime: "application/octet-stream", encoding: "binary" };
8
- function result(description, mime, encoding = "binary") {
9
- return { description, mime, encoding };
10
- }
11
- function matches(bytes, signature, offset = 0) {
12
- return bytes.length >= offset + signature.length && signature.every((value, index) => bytes[offset + index] === value);
13
- }
14
- function ascii(bytes, start, length) {
15
- return String.fromCharCode(...bytes.subarray(start, start + length));
16
- }
17
- function magic(bytes) {
18
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
19
- if (bytes.length >= 33 && matches(bytes, [137, 80, 78, 71, 13, 10, 26, 10]) && view.getUint32(8) === 13 && ascii(bytes, 12, 4) === "IHDR" && view.getUint32(16) > 0 && view.getUint32(20) > 0 && bytes[26] === 0 && bytes[27] === 0 && bytes[28] <= 1) {
20
- const allowed = { 0: [1, 2, 4, 8, 16], 2: [8, 16], 3: [1, 2, 4, 8], 4: [8, 16], 6: [8, 16] };
21
- if (allowed[bytes[25]]?.includes(bytes[24])) return result("PNG image data", "image/png");
22
- }
23
- if (bytes.length >= 13 && ["GIF87a", "GIF89a"].includes(ascii(bytes, 0, 6)) && view.getUint16(6, true) > 0 && view.getUint16(8, true) > 0) return result("GIF image data", "image/gif");
24
- if (bytes.length >= 4 && matches(bytes, [255, 216, 255]) && bytes[3] >= 192 && bytes[3] <= 254) return result("JPEG image data", "image/jpeg");
25
- if (bytes.length >= 20 && ascii(bytes, 0, 4) === "RIFF" && ascii(bytes, 8, 4) === "WEBP" && ["VP8 ", "VP8L", "VP8X"].includes(ascii(bytes, 12, 4)) && view.getUint32(4, true) >= 12) return result("WebP image data", "image/webp");
26
- if (bytes.length >= 8 && (matches(bytes, [73, 73, 42, 0]) || matches(bytes, [77, 77, 0, 42]))) return result("TIFF image data", "image/tiff");
27
- if (bytes.length >= 26 && ascii(bytes, 0, 2) === "BM" && [12, 40, 52, 56, 108, 124].includes(view.getUint32(14, true))) return result("PC bitmap image data", "image/bmp");
28
- if (bytes.length >= 22 && matches(bytes, [0, 0, 1, 0]) && view.getUint16(4, true) > 0) return result("MS Windows icon resource", "image/vnd.microsoft.icon");
29
- if (/^%PDF-[12]\.[0-9](?:\r|\n|\s)/u.test(ascii(bytes, 0, 16))) return result("PDF document", "application/pdf");
30
- if (bytes.length >= 10 && matches(bytes, [31, 139, 8]) && (bytes[3] & 224) === 0) return result("gzip compressed data", "application/gzip");
31
- if (bytes.length >= 10 && ascii(bytes, 0, 3) === "BZh" && bytes[3] >= 49 && bytes[3] <= 57 && (ascii(bytes, 4, 6) === "1AY&SY" || matches(bytes, [23, 114, 69, 56, 80, 144], 4))) return result("bzip2 compressed data", "application/x-bzip2");
32
- if (bytes.length >= 12 && matches(bytes, [253, 55, 122, 88, 90, 0]) && bytes[6] === 0 && bytes[7] <= 15) return result("XZ compressed data", "application/x-xz");
33
- if (bytes.length >= 6 && matches(bytes, [40, 181, 47, 253]) && (bytes[4] & 24) === 0) return result("Zstandard compressed data", "application/zstd");
34
- if (bytes.length >= 30 && matches(bytes, [80, 75, 3, 4]) || bytes.length >= 22 && matches(bytes, [80, 75, 5, 6])) return result("Zip archive data", "application/zip");
35
- if (bytes.length >= 32 && matches(bytes, [55, 122, 188, 175, 39, 28])) return result("7-zip archive data", "application/x-7z-compressed");
36
- if (bytes.length >= 14 && matches(bytes, [82, 97, 114, 33, 26, 7, 0]) || bytes.length >= 16 && matches(bytes, [82, 97, 114, 33, 26, 7, 1, 0])) return result("RAR archive data", "application/x-rar");
37
- if (bytes.length >= 512 && ascii(bytes, 257, 5) === "ustar") {
38
- const checksum = ascii(bytes, 148, 8).replace(/\0.*$/u, "").trim();
39
- if (/^[0-7]+$/u.test(checksum)) {
40
- let total = 0;
41
- for (let index = 0; index < 512; index++) total += index >= 148 && index < 156 ? 32 : bytes[index];
42
- if (parseInt(checksum, 8) === total) return result("POSIX tar archive", "application/x-tar");
43
- }
44
- }
45
- if (bytes.length >= 52 && matches(bytes, [127, 69, 76, 70]) && [1, 2].includes(bytes[4]) && [1, 2].includes(bytes[5]) && bytes[6] === 1 && (bytes[4] === 1 || bytes.length >= 64)) {
46
- const type = view.getUint16(16, bytes[5] === 1);
47
- const mime = type === 1 ? "application/x-object" : type === 2 ? "application/x-executable" : type === 3 ? "application/x-sharedlib" : "application/octet-stream";
48
- return result(`ELF ${bytes[4] === 1 ? "32" : "64"}-bit ${type === 2 ? "executable" : type === 3 ? "shared object" : "object"}`, mime);
49
- }
50
- if (bytes.length >= 64 && ascii(bytes, 0, 2) === "MZ") {
51
- const offset = view.getUint32(60, true);
52
- if (offset >= 64 && offset <= bytes.length - 24 && matches(bytes, [80, 69, 0, 0], offset)) return result("PE executable", "application/vnd.microsoft.portable-executable");
53
- return result("DOS executable", "application/x-dosexec");
54
- }
55
- if (bytes.length >= 8 && matches(bytes, [0, 97, 115, 109, 1, 0, 0, 0])) return result("WebAssembly binary module", "application/wasm");
56
- if (bytes.length >= 100 && ascii(bytes, 0, 16) === "SQLite format 3\0") {
57
- const size = view.getUint16(16);
58
- if ((size === 1 || size >= 512 && size <= 32768 && (size & size - 1) === 0) && [1, 2].includes(bytes[18]) && [1, 2].includes(bytes[19]) && matches(bytes, [64, 32, 32], 21)) return result("SQLite 3.x database", "application/vnd.sqlite3");
59
- }
60
- if (bytes.length >= 512 && matches(bytes, [208, 207, 17, 224, 161, 177, 26, 225]) && matches(bytes, [254, 255], 28)) return result("OLE Compound Document", "application/x-ole-storage");
61
- return void 0;
62
- }
63
- function csv(text, complete) {
64
- let records = 0, columns = 0, fields = 1, recordStart = 0;
65
- let state = "start";
66
- const endRecord = () => {
67
- if (fields < 2 || records > 0 && fields !== columns) return false;
68
- records++;
69
- columns = fields;
70
- fields = 1;
71
- state = "start";
72
- return true;
73
- };
74
- for (let index = 0; index < text.length; index++) {
75
- const character = text[index];
76
- if (state === "quoted") {
77
- if (character === '"') {
78
- if (text[index + 1] === '"') index++;
79
- else state = "closed";
80
- }
81
- continue;
82
- }
83
- if (character === ",") {
84
- fields++;
85
- state = "start";
86
- } else if (character === "\n") {
87
- if (!endRecord()) return false;
88
- recordStart = index + 1;
89
- } else if (character === "\r" && (text[index + 1] === "\n" || !complete && index + 1 === text.length)) continue;
90
- else if (character === '"' && state === "start") state = "quoted";
91
- else {
92
- if (character === '"' || character === "\r" || state === "closed") return false;
93
- state = "unquoted";
94
- }
95
- }
96
- if (complete && recordStart < text.length && (state === "quoted" || !endRecord())) return false;
97
- return records >= 2;
98
- }
99
- function textFormat(text, complete) {
100
- const lineEnd = text.indexOf("\n");
101
- if (text.startsWith("#!") && lineEnd >= 0) {
102
- const words = text.slice(2, lineEnd).trim().replaceAll(" ", " ").split(" ").filter(Boolean);
103
- const path = words[0] ?? "";
104
- const name = path.slice(path.lastIndexOf("/") + 1);
105
- const interpreter = name === "env" ? words[1] ?? "" : name;
106
- if (["sh", "bash", "ash", "ksh", "zsh", "csh", "tcsh"].includes(interpreter)) return ["shell script", "text/x-shellscript"];
107
- if (interpreter === "python" || interpreter.startsWith("python") && interpreter.length > 6 && "0123456789".includes(interpreter[6]) && [...interpreter.slice(6)].every((character) => "0123456789.".includes(character))) {
108
- return ["Python script", "text/x-script.python"];
109
- }
110
- }
111
- const lower = text.toLowerCase();
112
- if (lower.startsWith("<?xml") && " \r\n".includes(lower[5] ?? "\0")) return ["XML document", "text/xml"];
113
- for (const marker of ["<!doctype html", "<html", "<head", "<title"]) {
114
- let offset = lower.indexOf(marker);
115
- while (offset >= 0) {
116
- if (" \r\n\f>".includes(lower[offset + marker.length] ?? "\0")) return ["HTML document", "text/html"];
117
- offset = lower.indexOf(marker, offset + marker.length);
118
- }
119
- }
120
- if (csv(text, complete)) return ["CSV text", "text/csv"];
121
- return void 0;
122
- }
123
- function classify(bytes, complete) {
124
- if (!bytes.length) return complete ? result("empty", "inode/x-empty") : binary;
125
- const recognized = magic(bytes);
126
- if (recognized) return recognized;
127
- if (matches(bytes, [255, 254, 0, 0]) || matches(bytes, [0, 0, 254, 255])) return binary;
128
- let encoding = "utf-8";
129
- let bom = 0;
130
- if (matches(bytes, [239, 187, 191])) bom = 3;
131
- else if (matches(bytes, [255, 254])) {
132
- encoding = "utf-16le";
133
- bom = 2;
134
- } else if (matches(bytes, [254, 255])) {
135
- encoding = "utf-16be";
136
- bom = 2;
137
- }
138
- let text;
139
- try {
140
- text = new TextDecoder(encoding, { fatal: true }).decode(bytes, { stream: !complete });
141
- } catch {
142
- if (bom) return binary;
143
- encoding = "iso-8859-1";
144
- text = Array.from(bytes, (value) => String.fromCharCode(value)).join("");
145
- }
146
- if (!text.length && bytes.length > bom) return binary;
147
- for (const character of text) {
148
- const code = character.codePointAt(0);
149
- if (code < 32 && ![8, 9, 10, 12, 13, 27].includes(code) || code >= 127 && code <= 159) return binary;
150
- }
151
- if (!bom && encoding === "utf-8" && bytes.every((value) => value < 128)) encoding = "us-ascii";
152
- if (complete && /^[\x20\t\r\n]*(?:\{|\[)/u.test(text)) {
153
- try {
154
- JSON.parse(text);
155
- return result("JSON text data", "application/json", encoding);
156
- } catch {
157
- }
158
- }
159
- const description = encoding === "us-ascii" ? "ASCII text" : encoding === "iso-8859-1" ? "ISO-8859 text" : encoding === "utf-8" ? "Unicode text, UTF-8" : `Unicode text, ${encoding === "utf-16le" ? "UTF-16, little-endian" : "UTF-16, big-endian"}`;
160
- const format = textFormat(text, complete);
161
- return result(format ? `${format[0]}, ${description}` : description, format?.[1] ?? "text/plain", encoding);
162
- }
163
-
164
- // packages/safe-bash/src/commands/llm/mime.ts
165
- init_platform();
166
- var extensions = {
167
- png: "image/png",
168
- jpg: "image/jpeg",
169
- jpeg: "image/jpeg",
170
- gif: "image/gif",
171
- webp: "image/webp",
172
- avif: "image/avif",
173
- heic: "image/heic",
174
- heif: "image/heif",
175
- bmp: "image/bmp",
176
- tif: "image/tiff",
177
- tiff: "image/tiff",
178
- svg: "image/svg+xml",
179
- mp3: "audio/mpeg",
180
- wav: "audio/wav",
181
- ogg: "audio/ogg",
182
- oga: "audio/ogg",
183
- opus: "audio/ogg",
184
- flac: "audio/flac",
185
- aac: "audio/aac",
186
- m4a: "audio/mp4",
187
- aiff: "audio/aiff",
188
- mp4: "video/mp4",
189
- m4v: "video/mp4",
190
- mov: "video/quicktime",
191
- webm: "video/webm",
192
- mkv: "video/x-matroska",
193
- avi: "video/x-msvideo",
194
- ogv: "video/ogg",
195
- mpeg: "video/mpeg",
196
- mpg: "video/mpeg",
197
- pdf: "application/pdf",
198
- json: "application/json",
199
- zip: "application/zip",
200
- gz: "application/gzip",
201
- txt: "text/plain",
202
- md: "text/markdown",
203
- csv: "text/csv",
204
- html: "text/html",
205
- xml: "application/xml"
206
- };
207
- function ebmlInteger(bytes, offset, retainMarker = false) {
208
- const first = bytes[offset];
209
- if (!first) return void 0;
210
- let marker = 128, width = 1;
211
- while (!(first & marker)) {
212
- marker >>= 1;
213
- width++;
214
- }
215
- if (offset + width > bytes.length) return void 0;
216
- let value = retainMarker ? first : first & marker - 1;
217
- for (let index = 1; index < width; index++) value = value * 256 + bytes[offset + index];
218
- if (!Number.isSafeInteger(value) || !retainMarker && value === 2 ** (7 * width) - 1) return void 0;
219
- return { value, width };
220
- }
221
- function ebmlMimeType(bytes) {
222
- const header = ebmlInteger(bytes, 4);
223
- if (!header) return void 0;
224
- let offset = 4 + header.width;
225
- const end = Math.min(bytes.length, offset + header.value, 4096);
226
- while (offset < end) {
227
- const identifier = ebmlInteger(bytes, offset, true);
228
- if (!identifier) return void 0;
229
- offset += identifier.width;
230
- const size = ebmlInteger(bytes, offset);
231
- if (!size) return void 0;
232
- offset += size.width;
233
- if (size.value > end - offset) return void 0;
234
- if (identifier.value === 17026) {
235
- const docType = new TextDecoder().decode(bytes.subarray(offset, offset + size.value)).split("\0", 1)[0];
236
- if (docType === "webm") return "video/webm";
237
- if (docType === "matroska") return "video/x-matroska";
238
- return void 0;
239
- }
240
- offset += size.value;
241
- }
242
- return void 0;
243
- }
244
- function sniffMimeType(path, bytes) {
245
- const matches2 = (signature, offset = 0) => bytes.length >= offset + signature.length && signature.every((byte, index) => bytes[offset + index] === byte);
246
- const ascii2 = (offset, text) => bytes.length >= offset + text.length && [...text].every((character, index) => bytes[offset + index] === character.charCodeAt(0));
247
- if (matches2([137, 80, 78, 71, 13, 10, 26, 10])) return "image/png";
248
- if (matches2([255, 216, 255])) return "image/jpeg";
249
- if (ascii2(0, "GIF87a") || ascii2(0, "GIF89a")) return "image/gif";
250
- if (ascii2(0, "RIFF")) {
251
- if (ascii2(8, "WEBP")) return "image/webp";
252
- if (ascii2(8, "WAVE")) return "audio/wav";
253
- if (ascii2(8, "AVI ")) return "video/x-msvideo";
254
- }
255
- if (ascii2(0, "fLaC")) return "audio/flac";
256
- if (ascii2(0, "OggS")) {
257
- const packet = 27 + (bytes[26] ?? 0);
258
- if (bytes[26] && bytes[packet] === 128 && ascii2(packet + 1, "theora")) return "video/ogg";
259
- return "audio/ogg";
260
- }
261
- if (ascii2(0, "ID3") || bytes.length >= 2 && bytes[0] === 255 && (bytes[1] & 224) === 224 && (bytes[1] & 6) !== 0) return "audio/mpeg";
262
- if (bytes.length >= 2 && bytes[0] === 255 && (bytes[1] & 246) === 240) return "audio/aac";
263
- if (ascii2(0, "FORM") && (ascii2(8, "AIFF") || ascii2(8, "AIFC"))) return "audio/aiff";
264
- if (ascii2(4, "ftyp")) {
265
- if (ascii2(8, "avif") || ascii2(8, "avis")) return "image/avif";
266
- if (ascii2(8, "heic") || ascii2(8, "heix")) return "image/heic";
267
- if (ascii2(8, "mif1") || ascii2(8, "msf1")) return "image/heif";
268
- if (ascii2(8, "M4A ") || ascii2(8, "M4B ")) return "audio/mp4";
269
- if (ascii2(8, "qt ")) return "video/quicktime";
270
- return "video/mp4";
271
- }
272
- if (matches2([26, 69, 223, 163])) {
273
- const mimeType = ebmlMimeType(bytes);
274
- if (mimeType) return mimeType;
275
- }
276
- if (ascii2(0, "%PDF-")) return "application/pdf";
277
- if (matches2([80, 75, 3, 4]) || matches2([80, 75, 5, 6])) return "application/zip";
278
- if (matches2([31, 139])) return "application/gzip";
279
- if (matches2([73, 73, 42, 0]) || matches2([77, 77, 0, 42])) return "image/tiff";
280
- if (ascii2(0, "BM")) return "image/bmp";
281
- const prefix = bytes.subarray(0, 512);
282
- const classified = classify(prefix, bytes.length <= prefix.length).mime;
283
- if (!["application/octet-stream", "text/plain", "inode/x-empty"].includes(classified)) return classified;
284
- const filename = path.slice(path.lastIndexOf("/") + 1);
285
- const dot = filename.lastIndexOf(".");
286
- const extension = dot < 0 ? "" : filename.slice(dot + 1).toLowerCase();
287
- return Object.hasOwn(extensions, extension) ? extensions[extension] : classified === "inode/x-empty" ? "application/octet-stream" : classified;
288
- }
289
- function acceptsMimeType(types, mimeType) {
290
- if ([...mimeType].some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127)) return false;
291
- const mime = mimeType.split(";", 1)[0].trim().toLowerCase();
292
- const parts = mime.split("/");
293
- if (parts.length !== 2 || parts.some((part) => !part || [...part].some((character) => !(character >= "a" && character <= "z" || character >= "0" && character <= "9" || "!#$%&'+-.^_`|~".includes(character))))) return false;
294
- return types.some((type) => {
295
- const accepted = type.toLowerCase();
296
- return accepted === mime || accepted.endsWith("/*") && accepted.slice(0, -2) === parts[0];
297
- });
298
- }
299
-
300
- export {
301
- classify,
302
- sniffMimeType,
303
- acceptsMimeType
304
- };
305
- //# sourceMappingURL=chunk-ZBFOWARG.js.map