anyfile-cli 0.0.0-stage → 0.2.1

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 (354) hide show
  1. package/LICENSE +177 -0
  2. package/README.md +55 -2
  3. package/SKILL.md +101 -0
  4. package/chunks/browser-probe-5STDX455.mjs +17 -0
  5. package/chunks/browser-probe-F5RX44T3.mjs +24 -0
  6. package/chunks/chunk-2C34VMNV.mjs +108 -0
  7. package/chunks/chunk-3OZ56PUH.mjs +97 -0
  8. package/chunks/chunk-3YRWCQGV.mjs +38 -0
  9. package/chunks/chunk-53MJMIN4.mjs +23 -0
  10. package/chunks/chunk-5LOC7IST.mjs +372 -0
  11. package/chunks/chunk-5XTYLZF3.mjs +559 -0
  12. package/chunks/chunk-5ZHDYRGV.mjs +64 -0
  13. package/chunks/chunk-6CQL4K2K.mjs +21 -0
  14. package/chunks/chunk-6EVJJFOH.mjs +243 -0
  15. package/chunks/chunk-6NWSQGYE.mjs +68 -0
  16. package/chunks/chunk-7O5JLQE7.mjs +1 -0
  17. package/chunks/chunk-A6AQI6DF.mjs +321 -0
  18. package/chunks/chunk-AYF63UBE.mjs +79 -0
  19. package/chunks/chunk-B27PR6Q4.mjs +17 -0
  20. package/chunks/chunk-BP7LORL4.mjs +13 -0
  21. package/chunks/chunk-BVCRJLCD.mjs +109 -0
  22. package/chunks/chunk-CLSEE3VA.mjs +28 -0
  23. package/chunks/chunk-CO2ZAQIK.mjs +52 -0
  24. package/chunks/chunk-CQWM5GMU.mjs +167 -0
  25. package/chunks/chunk-CZFFYCMJ.mjs +136 -0
  26. package/chunks/chunk-D3CS6TIK.mjs +419 -0
  27. package/chunks/chunk-DJLFVMDJ.mjs +807 -0
  28. package/chunks/chunk-DJXVCKIO.mjs +30 -0
  29. package/chunks/chunk-EMXODK3K.mjs +94 -0
  30. package/chunks/chunk-EOJ7ZCDK.mjs +227 -0
  31. package/chunks/chunk-H4TBN22D.mjs +100 -0
  32. package/chunks/chunk-HI7TURZM.mjs +2256 -0
  33. package/chunks/chunk-HUSX3ZU3.mjs +58 -0
  34. package/chunks/chunk-IC3G2XE2.mjs +436 -0
  35. package/chunks/chunk-IGEGIF35.mjs +2034 -0
  36. package/chunks/chunk-IZGTVZHE.mjs +90 -0
  37. package/chunks/chunk-J4G7LUPA.mjs +117 -0
  38. package/chunks/chunk-JBAJW66L.mjs +4220 -0
  39. package/chunks/chunk-JKQUF2MM.mjs +438 -0
  40. package/chunks/chunk-KAMPC5TK.mjs +131 -0
  41. package/chunks/chunk-KSKEMJVC.mjs +145 -0
  42. package/chunks/chunk-LRHHRZLE.mjs +29 -0
  43. package/chunks/chunk-M37ZOAUG.mjs +93 -0
  44. package/chunks/chunk-MG7LUDXO.mjs +187 -0
  45. package/chunks/chunk-NGVHHTQD.mjs +125 -0
  46. package/chunks/chunk-NQ7J2NH6.mjs +50 -0
  47. package/chunks/chunk-NUMNHVSI.mjs +60 -0
  48. package/chunks/chunk-ORJ3DN65.mjs +58 -0
  49. package/chunks/chunk-QOUEBPPL.mjs +15 -0
  50. package/chunks/chunk-QR3Y3UKM.mjs +194 -0
  51. package/chunks/chunk-RFKYE7SE.mjs +50 -0
  52. package/chunks/chunk-SH57XOAV.mjs +33 -0
  53. package/chunks/chunk-TB5ISPA4.mjs +1 -0
  54. package/chunks/chunk-UGAU3V4V.mjs +206 -0
  55. package/chunks/chunk-WDN6NMVU.mjs +36 -0
  56. package/chunks/chunk-WWTLSPEG.mjs +3999 -0
  57. package/chunks/chunk-XDW56XVX.mjs +69 -0
  58. package/chunks/chunk-XRT7TAAY.mjs +27 -0
  59. package/chunks/chunk-XTW4HNIJ.mjs +418 -0
  60. package/chunks/chunk-YPLWNGCC.mjs +17 -0
  61. package/chunks/chunk-ZBR7RQQE.mjs +64 -0
  62. package/chunks/chunk-ZUHJIGHP.mjs +300 -0
  63. package/chunks/deflate-IINN6MRE.mjs +19 -0
  64. package/chunks/jpeg-N3DSYEAQ.mjs +964 -0
  65. package/chunks/jxl_oxide_wasm-3UN6G3YN.mjs +589 -0
  66. package/chunks/lerc-5LP7Q554.mjs +2086 -0
  67. package/chunks/lzw-Z2ZZBEWD.mjs +137 -0
  68. package/chunks/packbits-3S2JASDB.mjs +34 -0
  69. package/chunks/pdf.worker-PUGU2NS2.mjs +67416 -0
  70. package/chunks/probe-22WNVZ3I.mjs +17 -0
  71. package/chunks/probe-2P4CTFCY.mjs +14 -0
  72. package/chunks/probe-2QBNDPYK.mjs +18 -0
  73. package/chunks/probe-34TOVXUI.mjs +11 -0
  74. package/chunks/probe-3W2HOWBM.mjs +20 -0
  75. package/chunks/probe-42OBMD35.mjs +23 -0
  76. package/chunks/probe-43RVHUBG.mjs +17 -0
  77. package/chunks/probe-4O362IEX.mjs +18 -0
  78. package/chunks/probe-4WF34ZXS.mjs +11 -0
  79. package/chunks/probe-5ZITS3T5.mjs +40 -0
  80. package/chunks/probe-5ZS5DHFP.mjs +21 -0
  81. package/chunks/probe-62RFYKCP.mjs +14 -0
  82. package/chunks/probe-64JTFRH4.mjs +41 -0
  83. package/chunks/probe-6YJQJJ3R.mjs +518 -0
  84. package/chunks/probe-6YMOOV53.mjs +39 -0
  85. package/chunks/probe-BYBD2WAK.mjs +239 -0
  86. package/chunks/probe-CZZNJOHV.mjs +20 -0
  87. package/chunks/probe-DJMPK6HU.mjs +11 -0
  88. package/chunks/probe-FMWIF4LX.mjs +33 -0
  89. package/chunks/probe-FYPH6CYY.mjs +206 -0
  90. package/chunks/probe-G6PPXKBE.mjs +15 -0
  91. package/chunks/probe-GJ5OUOQ3.mjs +32 -0
  92. package/chunks/probe-H6J7TUY2.mjs +95 -0
  93. package/chunks/probe-IGZ47OE3.mjs +68 -0
  94. package/chunks/probe-IL5HO3OK.mjs +46 -0
  95. package/chunks/probe-INYCDZHO.mjs +27 -0
  96. package/chunks/probe-JFH545GO.mjs +11 -0
  97. package/chunks/probe-JZYDRITV.mjs +18 -0
  98. package/chunks/probe-K3WW5O5K.mjs +26 -0
  99. package/chunks/probe-KB4T466L.mjs +70 -0
  100. package/chunks/probe-KY7SIIXD.mjs +13 -0
  101. package/chunks/probe-L2P263WT.mjs +16 -0
  102. package/chunks/probe-LEP3RQPD.mjs +11 -0
  103. package/chunks/probe-M2QWULOI.mjs +119 -0
  104. package/chunks/probe-M7AYZBD3.mjs +35 -0
  105. package/chunks/probe-MEN3BMBB.mjs +22 -0
  106. package/chunks/probe-MNIGKDWT.mjs +163 -0
  107. package/chunks/probe-NFVFWB4M.mjs +56 -0
  108. package/chunks/probe-NJGSTL6R.mjs +161 -0
  109. package/chunks/probe-O73EHWT3.mjs +14 -0
  110. package/chunks/probe-OG2XYCG2.mjs +25 -0
  111. package/chunks/probe-OTKJKTNS.mjs +10 -0
  112. package/chunks/probe-OZKO3C2V.mjs +27 -0
  113. package/chunks/probe-PBL4KITG.mjs +12 -0
  114. package/chunks/probe-PEFZNH2T.mjs +21 -0
  115. package/chunks/probe-R4SSEXES.mjs +27 -0
  116. package/chunks/probe-RCAUVV27.mjs +29 -0
  117. package/chunks/probe-RPGBKGPI.mjs +20 -0
  118. package/chunks/probe-S2I46SEO.mjs +10 -0
  119. package/chunks/probe-SGDD4U4Q.mjs +165 -0
  120. package/chunks/probe-SPQO5LHI.mjs +9 -0
  121. package/chunks/probe-TBR6UGRZ.mjs +19 -0
  122. package/chunks/probe-TNKNILAW.mjs +21 -0
  123. package/chunks/probe-TVRJBPXH.mjs +48 -0
  124. package/chunks/probe-UESMTUQ5.mjs +33 -0
  125. package/chunks/probe-VDXFEZ5Q.mjs +16 -0
  126. package/chunks/probe-VX7JCDW6.mjs +39 -0
  127. package/chunks/probe-W7M55OPE.mjs +64 -0
  128. package/chunks/probe-XUBTIWGE.mjs +13 -0
  129. package/chunks/probe-ZF7KIRHO.mjs +36 -0
  130. package/chunks/raw-JJRPYAXO.mjs +16 -0
  131. package/chunks/tiff-metadata-7MWLNVW2.mjs +2990 -0
  132. package/chunks/webimage-D6XSCCTJ.mjs +56 -0
  133. package/chunks/zip-reader-YUGANW4Z.mjs +92 -0
  134. package/chunks/zstd-AH2S24PU.mjs +121 -0
  135. package/cli-main.mjs +297 -0
  136. package/cli.mjs +3 -0
  137. package/extractors/apple-plist.mjs +145 -0
  138. package/extractors/archive-metadata-viewer.mjs +1401 -0
  139. package/extractors/bittorrent-metadata.mjs +369 -0
  140. package/extractors/calendar-contacts.mjs +328 -0
  141. package/extractors/camera-raw.mjs +201 -0
  142. package/extractors/chm-reader.mjs +1842 -0
  143. package/extractors/comic-book-reader.mjs +307 -0
  144. package/extractors/design-source.mjs +1801 -0
  145. package/extractors/dev-array-viewer.mjs +825 -0
  146. package/extractors/dev-native-binary-viewer.mjs +1661 -0
  147. package/extractors/dev-source-map-viewer.mjs +416 -0
  148. package/extractors/dev-wasm-viewer.mjs +506 -0
  149. package/extractors/dicom.mjs +383 -0
  150. package/extractors/djvu-reader.mjs +337 -0
  151. package/extractors/duckdb-data.mjs +49174 -0
  152. package/extractors/epub-reader.mjs +222 -0
  153. package/extractors/excel-workbook.mjs +27057 -0
  154. package/extractors/fictionbook-reader.mjs +362 -0
  155. package/extractors/font-viewer.mjs +441 -0
  156. package/extractors/general-raster.mjs +444 -0
  157. package/extractors/hdr-image.mjs +1685 -0
  158. package/extractors/http-archive.mjs +306 -0
  159. package/extractors/ifc.mjs +341 -0
  160. package/extractors/iwork.mjs +640 -0
  161. package/extractors/microsoft-project.mjs +174 -0
  162. package/extractors/mind-map.mjs +607 -0
  163. package/extractors/ml-weights.mjs +649 -0
  164. package/extractors/modern-raster.mjs +620 -0
  165. package/extractors/ofd-reader.mjs +973 -0
  166. package/extractors/outlook-pst.mjs +997 -0
  167. package/extractors/pdfjs-pdf.mjs +32056 -0
  168. package/extractors/photoshop-document.mjs +17448 -0
  169. package/extractors/safe-svg.mjs +163 -0
  170. package/extractors/scientific-data.mjs +2041 -0
  171. package/extractors/sqlite-database.mjs +333 -0
  172. package/extractors/statistical-data.mjs +297 -0
  173. package/extractors/visio.mjs +141 -0
  174. package/extractors/x509-certificate.mjs +588 -0
  175. package/extractors/xps-reader.mjs +896 -0
  176. package/index.mjs +83 -0
  177. package/licenses/dicom-parser/1.8.21/LICENSE +21 -0
  178. package/licenses/libraw-wasm/1.6.0/COPYRIGHT.LibRaw +27 -0
  179. package/licenses/libraw-wasm/1.6.0/LICENSE.Emscripten +102 -0
  180. package/licenses/libraw-wasm/1.6.0/LICENSE.LibRaw-CDDL-1.0 +340 -0
  181. package/licenses/libraw-wasm/1.6.0/LICENSE.Little-CMS-MIT +22 -0
  182. package/licenses/libraw-wasm/1.6.0/LICENSE.libpng +134 -0
  183. package/licenses/libraw-wasm/1.6.0/LICENSE.libraw-wasm-ISC +15 -0
  184. package/licenses/libraw-wasm/1.6.0/LICENSE.zlib +22 -0
  185. package/licenses/libraw-wasm/1.6.0/NOTICE.IJG-libjpeg +49 -0
  186. package/licenses/libraw-wasm/1.6.0/SOURCE.md +25 -0
  187. package/licenses/libraw-wasm/1.6.0/THIRD_PARTY_NOTICES.md +14 -0
  188. package/licenses/mediabunny/1.55.3/MPL-2.0.txt +373 -0
  189. package/licenses/mediabunny/1.55.3/SOURCE.md +16 -0
  190. package/licenses/openskp/1.3.0/LICENSE +21 -0
  191. package/package.json +34 -4
  192. package/renderer-host/assets/ColladaComposer-TCm9fgZa.js +1 -0
  193. package/renderer-host/assets/ColladaParser-BHTzbhBz.js +3 -0
  194. package/renderer-host/assets/FBXLoader-D1vDnL3o.js +8 -0
  195. package/renderer-host/assets/agent-CKvDbj87.js +1 -0
  196. package/renderer-host/assets/amf-BkE--DNX.js +1 -0
  197. package/renderer-host/assets/animation-Dt0WW2cB.js +1 -0
  198. package/renderer-host/assets/archive-client-CL5yOgwH.js +1 -0
  199. package/renderer-host/assets/archive.worker-CcLnJ9FC.js +1 -0
  200. package/renderer-host/assets/audio-visualizer-CiyGNhY2.js +1 -0
  201. package/renderer-host/assets/basedecoder-BuG7fe0q.js +1 -0
  202. package/renderer-host/assets/book-source-28BQcBKR.js +1 -0
  203. package/renderer-host/assets/book-worker-DUt14LJO.js +1 -0
  204. package/renderer-host/assets/browser-C0pGRq_c.js +1 -0
  205. package/renderer-host/assets/client-CU2ERPtk.js +1 -0
  206. package/renderer-host/assets/container-inspection-ekEPWWcy.js +1 -0
  207. package/renderer-host/assets/data-table-OJQe3aN5.js +1 -0
  208. package/renderer-host/assets/decode-hBroL8C1.js +1 -0
  209. package/renderer-host/assets/decode-tiff-CP1xdrF_.js +5 -0
  210. package/renderer-host/assets/decoder-worker-B0sdTVlF.js +1 -0
  211. package/renderer-host/assets/decoder-worker-CBiHE971.js +3 -0
  212. package/renderer-host/assets/decoder-worker-Cr5oP97p.js +5 -0
  213. package/renderer-host/assets/decoder-worker-DIdLFebY.js +11 -0
  214. package/renderer-host/assets/decoder-worker-DLeuEYxq.js +1 -0
  215. package/renderer-host/assets/decoder.worker-BXAaF0Qj.js +1 -0
  216. package/renderer-host/assets/decoder.worker-yaM6uups.js +1 -0
  217. package/renderer-host/assets/deflate-DPjr4M2G.js +1 -0
  218. package/renderer-host/assets/deflate-S3QmZI-f.js +1 -0
  219. package/renderer-host/assets/dual-track-playback-CxjGms-W.js +1 -0
  220. package/renderer-host/assets/ext-searchbox-BIdon51Z.js +164 -0
  221. package/renderer-host/assets/ffmpeg-playback-DzCJz9Ny.js +1 -0
  222. package/renderer-host/assets/gltf-PozNLKNg.js +1 -0
  223. package/renderer-host/assets/hdf5.worker-BO3TrRup.js +1 -0
  224. package/renderer-host/assets/heif-worker-CC9DI3ZR.js +1 -0
  225. package/renderer-host/assets/id3-uzaDmDwy.js +1 -0
  226. package/renderer-host/assets/ifc.worker-KIbgAIsy.js +1 -0
  227. package/renderer-host/assets/image-load-SK3ULGWm.js +1 -0
  228. package/renderer-host/assets/index-DtiyOy_J.js +2 -0
  229. package/renderer-host/assets/jpeg-AGQ46WDa.js +1 -0
  230. package/renderer-host/assets/jpeg-Dm0yBuYB.js +1 -0
  231. package/renderer-host/assets/jszip.min-DCdQ6XWv.js +2 -0
  232. package/renderer-host/assets/jxl_oxide_wasm-BJKDqoXP.js +1 -0
  233. package/renderer-host/assets/jxl_oxide_wasm_bg-C5JqlrFv.wasm +0 -0
  234. package/renderer-host/assets/kernel.worker-B58X9XWu.js +1 -0
  235. package/renderer-host/assets/kernel.worker-BcQYKb39.js +8 -0
  236. package/renderer-host/assets/kernel.worker-BdWmPdqg.js +1 -0
  237. package/renderer-host/assets/kernel.worker-C7qxomuK.js +1 -0
  238. package/renderer-host/assets/kernel.worker-D88TbQnz.js +1 -0
  239. package/renderer-host/assets/laz-Lt10LsWd.js +1 -0
  240. package/renderer-host/assets/lerc-BxVqCKaH.js +3 -0
  241. package/renderer-host/assets/lerc-Cuor-Zm2.js +1 -0
  242. package/renderer-host/assets/lzw-D2FslT4L.js +1 -0
  243. package/renderer-host/assets/lzw-DODNa9l5.js +1 -0
  244. package/renderer-host/assets/mediabunny-viewer-BniHVEWJ.js +16 -0
  245. package/renderer-host/assets/model-Drd3vqcF.js +1 -0
  246. package/renderer-host/assets/obj-B3p81LL2.js +9 -0
  247. package/renderer-host/assets/off-QQbiKPTX.js +1 -0
  248. package/renderer-host/assets/ogg-probe-C2TT74FL.js +1 -0
  249. package/renderer-host/assets/ogg-viewer-Dc8K-tas.js +9 -0
  250. package/renderer-host/assets/packbits-DCimUQ1T.js +1 -0
  251. package/renderer-host/assets/paged-C8AQD7sX.js +319 -0
  252. package/renderer-host/assets/pako.esm-0UYEm1Jg.js +2 -0
  253. package/renderer-host/assets/pako.esm-CtVA0R7W.js +1 -0
  254. package/renderer-host/assets/pdf.worker.min-CHFwMXne.mjs +29 -0
  255. package/renderer-host/assets/ply-C3_RRA7n.js +2 -0
  256. package/renderer-host/assets/points.worker-CA8v75dl.js +2 -0
  257. package/renderer-host/assets/probe-asf-C_UpCBly.js +14 -0
  258. package/renderer-host/assets/range-reader-BMfLhWcp.js +1 -0
  259. package/renderer-host/assets/raw-A-vJRPpa.js +1 -0
  260. package/renderer-host/assets/resource-cache-CHocY8K3.js +1 -0
  261. package/renderer-host/assets/resources-6AmS6O5e.js +1 -0
  262. package/renderer-host/assets/rolldown-runtime-Dd_uD5pT.js +1 -0
  263. package/renderer-host/assets/safe-content-CWHf8jex.js +1 -0
  264. package/renderer-host/assets/sanitize-D56ODnaM.js +1 -0
  265. package/renderer-host/assets/scene-adapter-CaCLr1am.js +1 -0
  266. package/renderer-host/assets/scene.worker-CJViWLYo.js +24 -0
  267. package/renderer-host/assets/scene.worker-D7koFZY8.js +2 -0
  268. package/renderer-host/assets/skp-adapter-jl6q24fW.js +1 -0
  269. package/renderer-host/assets/skp.worker-D9ujTXFV.js +1 -0
  270. package/renderer-host/assets/src-1Won7FxU.js +88 -0
  271. package/renderer-host/assets/src-3RoHqOkA.js +7 -0
  272. package/renderer-host/assets/src-4zBOL6Jt.js +1 -0
  273. package/renderer-host/assets/src-6v8-hoR3.js +24 -0
  274. package/renderer-host/assets/src-8Jx9gbII.js +1 -0
  275. package/renderer-host/assets/src-B1WA0dRu.js +64 -0
  276. package/renderer-host/assets/src-B5ijbemo.js +9 -0
  277. package/renderer-host/assets/src-B8DH2GJe.js +17 -0
  278. package/renderer-host/assets/src-B9t_iEO3.js +58 -0
  279. package/renderer-host/assets/src-BCC58C0X.js +1 -0
  280. package/renderer-host/assets/src-BCwENs26.js +1 -0
  281. package/renderer-host/assets/src-BEirBh4c.js +27 -0
  282. package/renderer-host/assets/src-BHR6n7Fj.js +1 -0
  283. package/renderer-host/assets/src-BIlLq0QT.js +169 -0
  284. package/renderer-host/assets/src-BKlK1jcN.js +1 -0
  285. package/renderer-host/assets/src-BN0FUJhs.js +8 -0
  286. package/renderer-host/assets/src-BWElAdlq.js +52 -0
  287. package/renderer-host/assets/src-BXg11IjY.js +4 -0
  288. package/renderer-host/assets/src-BbBdnTjJ.js +2 -0
  289. package/renderer-host/assets/src-BbFZbZsL.js +2 -0
  290. package/renderer-host/assets/src-BdPbFRd-.js +24 -0
  291. package/renderer-host/assets/src-BpbGaBrT.js +182 -0
  292. package/renderer-host/assets/src-BwIl76_H.js +7 -0
  293. package/renderer-host/assets/src-C2e6QJIj.js +10 -0
  294. package/renderer-host/assets/src-C2gNidHF.js +989 -0
  295. package/renderer-host/assets/src-C9Uz3C-q.js +432 -0
  296. package/renderer-host/assets/src-CBUhG6W5.js +7 -0
  297. package/renderer-host/assets/src-CQDGi3Qa.js +10 -0
  298. package/renderer-host/assets/src-CRLCRg0N.js +21 -0
  299. package/renderer-host/assets/src-CS5rqxBy.js +10 -0
  300. package/renderer-host/assets/src-CWZdSJQw.js +7 -0
  301. package/renderer-host/assets/src-CXnpsVpU.js +27 -0
  302. package/renderer-host/assets/src-CnhXvqQY.js +8 -0
  303. package/renderer-host/assets/src-CpExg0ZA.js +9 -0
  304. package/renderer-host/assets/src-CrLmL3wU.js +5 -0
  305. package/renderer-host/assets/src-CrYEJ5uz.js +2 -0
  306. package/renderer-host/assets/src-D-iIkSqZ.js +222 -0
  307. package/renderer-host/assets/src-D6sH9uTT.js +23 -0
  308. package/renderer-host/assets/src-D8zHDJh_.js +10 -0
  309. package/renderer-host/assets/src-D9OFaPNV.js +1 -0
  310. package/renderer-host/assets/src-DCI_ff7c.js +1 -0
  311. package/renderer-host/assets/src-DCrbiTpH.js +18 -0
  312. package/renderer-host/assets/src-DK8DvtMd.js +115 -0
  313. package/renderer-host/assets/src-DWGlOVjt.js +17 -0
  314. package/renderer-host/assets/src-DbvEX_Ct.js +6 -0
  315. package/renderer-host/assets/src-Dezc2dj1.js +1 -0
  316. package/renderer-host/assets/src-Dh5VD1lL.js +11 -0
  317. package/renderer-host/assets/src-DlwABqw5.js +1 -0
  318. package/renderer-host/assets/src-DlxETlTh.js +44 -0
  319. package/renderer-host/assets/src-Dmd6BvBh.js +387 -0
  320. package/renderer-host/assets/src-DpgvaJNJ.js +24 -0
  321. package/renderer-host/assets/src-DpjRB2sv.js +1 -0
  322. package/renderer-host/assets/src-Dvn41FR7.js +90 -0
  323. package/renderer-host/assets/src-DwcPYp7X.js +1 -0
  324. package/renderer-host/assets/src-HUxhcDlO.js +2 -0
  325. package/renderer-host/assets/src-Jhqg3J8L.js +2 -0
  326. package/renderer-host/assets/src-MO5bLsLj.js +4126 -0
  327. package/renderer-host/assets/src-N8XBQaK4.js +20 -0
  328. package/renderer-host/assets/src-XZ_0U972.js +1 -0
  329. package/renderer-host/assets/src-Y6mXl4vh.js +29 -0
  330. package/renderer-host/assets/src-b9aXVJde.js +100 -0
  331. package/renderer-host/assets/src-d2U6neq8.js +37 -0
  332. package/renderer-host/assets/src-hCrza_Lf.js +1 -0
  333. package/renderer-host/assets/src-jUGjKzOV.js +1 -0
  334. package/renderer-host/assets/src-rJN_jaC5.js +1 -0
  335. package/renderer-host/assets/src-vOBd-1zk.js +5 -0
  336. package/renderer-host/assets/src-wrrVkfrK.js +1 -0
  337. package/renderer-host/assets/src-yCrAObB-.js +1 -0
  338. package/renderer-host/assets/src-zrBiCtay.js +7 -0
  339. package/renderer-host/assets/stl-adapter-CLkWHoOn.js +1 -0
  340. package/renderer-host/assets/stl.worker-C-anHijM.js +1 -0
  341. package/renderer-host/assets/three-mf-BSrcsdQD.js +2 -0
  342. package/renderer-host/assets/webimage-zQMH-_zR.js +1 -0
  343. package/renderer-host/assets/webm-14HHwfWy.js +1 -0
  344. package/renderer-host/assets/worker-QK2gViTu.js +1 -0
  345. package/renderer-host/assets/x6-dng-worker-CNf3zUP-.js +1 -0
  346. package/renderer-host/assets/xml.browser-CC8-XAyN.js +1 -0
  347. package/renderer-host/assets/zip-core-base-DD8akpjq.js +1 -0
  348. package/renderer-host/assets/zip-core-custom-CfPFs1lw.js +1 -0
  349. package/renderer-host/assets/zip-source-CLF3Hfcg.js +1 -0
  350. package/renderer-host/assets/zstd-CmwSLjHB.js +1 -0
  351. package/renderer-host/assets/zstd-i4Jwubnx.js +1 -0
  352. package/renderer-host/index.html +65 -0
  353. package/vendor-manifest.json +1433 -0
  354. package/worker.mjs +262 -0
@@ -0,0 +1,640 @@
1
+ import { createRequire as __anyfileCreateRequire } from "node:module"; import { dirname as __anyfileDirname } from "node:path"; import { fileURLToPath as __anyfileFileURLToPath } from "node:url"; const require = __anyfileCreateRequire(import.meta.url); const __filename = __anyfileFileURLToPath(import.meta.url); const __dirname = __anyfileDirname(__filename);
2
+ import {
3
+ detectIworkLayout,
4
+ iworkAppFromName,
5
+ previewPath
6
+ } from "../chunks/chunk-3YRWCQGV.mjs";
7
+ import "../chunks/chunk-D3CS6TIK.mjs";
8
+ import {
9
+ BlobReader,
10
+ BlobWriter,
11
+ Uint8ArrayWriter,
12
+ ZipReader
13
+ } from "../chunks/chunk-WWTLSPEG.mjs";
14
+ import {
15
+ parseXmlDocument
16
+ } from "../chunks/chunk-53MJMIN4.mjs";
17
+ import {
18
+ AgentError,
19
+ HARD_READ_MAX_BYTES,
20
+ abortError,
21
+ isViewerAbortError,
22
+ paginateLines,
23
+ paginateText
24
+ } from "../chunks/chunk-IC3G2XE2.mjs";
25
+ import "../chunks/chunk-ORJ3DN65.mjs";
26
+
27
+ // ../plugins/iwork/src/iwa.ts
28
+ var IwaFormatError = class extends Error {
29
+ };
30
+ var IwaLimitError = class extends Error {
31
+ };
32
+ function fail(message) {
33
+ throw new IwaFormatError(message);
34
+ }
35
+ function readVarint(bytes, position) {
36
+ let value = 0;
37
+ let scale = 1;
38
+ for (let index = 0; index < 10; index += 1) {
39
+ if (position.offset >= bytes.length) fail("Truncated varint.");
40
+ const byte = bytes[position.offset++];
41
+ value += (byte & 127) * scale;
42
+ if (byte < 128) return value;
43
+ scale *= 128;
44
+ }
45
+ return fail("Varint is too long.");
46
+ }
47
+ function decompressSnappy(input, maxBytes) {
48
+ const position = { offset: 0 };
49
+ const length = readVarint(input, position);
50
+ if (length > maxBytes) throw new IwaLimitError("Snappy block exceeds the output limit.");
51
+ const output = new Uint8Array(length);
52
+ let written = 0;
53
+ let offset = position.offset;
54
+ while (offset < input.length) {
55
+ const tag = input[offset++];
56
+ const kind = tag & 3;
57
+ if (kind === 0) {
58
+ let size2 = tag >>> 2;
59
+ if (size2 >= 60) {
60
+ const extra = size2 - 59;
61
+ if (offset + extra > input.length) fail("Truncated Snappy literal.");
62
+ size2 = 0;
63
+ for (let index = 0; index < extra; index += 1) size2 += input[offset + index] * 2 ** (8 * index);
64
+ offset += extra;
65
+ }
66
+ size2 += 1;
67
+ if (offset + size2 > input.length || written + size2 > length) fail("Invalid Snappy literal.");
68
+ output.set(input.subarray(offset, offset + size2), written);
69
+ offset += size2;
70
+ written += size2;
71
+ continue;
72
+ }
73
+ let size;
74
+ let distance;
75
+ if (kind === 1) {
76
+ if (offset >= input.length) fail("Truncated Snappy copy.");
77
+ size = (tag >>> 2 & 7) + 4;
78
+ distance = tag >>> 5 << 8 | input[offset++];
79
+ } else {
80
+ const width = kind === 2 ? 2 : 4;
81
+ if (offset + width > input.length) fail("Truncated Snappy copy.");
82
+ size = (tag >>> 2) + 1;
83
+ distance = 0;
84
+ for (let index = 0; index < width; index += 1) distance += input[offset + index] * 2 ** (8 * index);
85
+ offset += width;
86
+ }
87
+ if (distance === 0 || distance > written || written + size > length) fail("Invalid Snappy copy.");
88
+ for (let index = 0; index < size; index += 1, written += 1) output[written] = output[written - distance];
89
+ }
90
+ if (written !== length) fail("Snappy block length mismatch.");
91
+ return output;
92
+ }
93
+ function decodeIwaStream(bytes, maxBytes) {
94
+ const blocks = [];
95
+ let total = 0;
96
+ let offset = 0;
97
+ while (offset < bytes.length) {
98
+ if (offset + 4 > bytes.length || bytes[offset] !== 0) fail("Invalid IWA chunk header.");
99
+ const size = bytes[offset + 1] | bytes[offset + 2] << 8 | bytes[offset + 3] << 16;
100
+ offset += 4;
101
+ if (offset + size > bytes.length) fail("Truncated IWA chunk.");
102
+ const block = decompressSnappy(bytes.subarray(offset, offset + size), maxBytes - total);
103
+ blocks.push(block);
104
+ total += block.length;
105
+ offset += size;
106
+ }
107
+ if (blocks.length === 1) return blocks[0];
108
+ const output = new Uint8Array(total);
109
+ let written = 0;
110
+ for (const block of blocks) {
111
+ output.set(block, written);
112
+ written += block.length;
113
+ }
114
+ return output;
115
+ }
116
+ function readProto(bytes) {
117
+ const fields = /* @__PURE__ */ new Map();
118
+ const position = { offset: 0 };
119
+ while (position.offset < bytes.length) {
120
+ const key = readVarint(bytes, position);
121
+ const field = Math.floor(key / 8);
122
+ const wire = key % 8;
123
+ if (field === 0) fail("Invalid protobuf field.");
124
+ let value;
125
+ if (wire === 0) value = readVarint(bytes, position);
126
+ else if (wire === 2) {
127
+ const size = readVarint(bytes, position);
128
+ if (position.offset + size > bytes.length) fail("Truncated protobuf field.");
129
+ value = bytes.subarray(position.offset, position.offset + size);
130
+ position.offset += size;
131
+ } else if (wire === 1 || wire === 5) {
132
+ position.offset += wire === 1 ? 8 : 4;
133
+ if (position.offset > bytes.length) fail("Truncated protobuf field.");
134
+ } else fail("Unsupported protobuf wire type.");
135
+ if (value === void 0) continue;
136
+ const values = fields.get(field);
137
+ if (values) values.push(value);
138
+ else fields.set(field, [value]);
139
+ }
140
+ return fields;
141
+ }
142
+ function protoNumber(fields, field) {
143
+ const value = fields.get(field)?.[0];
144
+ return typeof value === "number" ? value : void 0;
145
+ }
146
+ function protoMessages(fields, field) {
147
+ return (fields.get(field) ?? []).filter((value) => value instanceof Uint8Array);
148
+ }
149
+ function readIwaObjects(stream) {
150
+ const objects = [];
151
+ const position = { offset: 0 };
152
+ while (position.offset < stream.length) {
153
+ const infoLength = readVarint(stream, position);
154
+ if (position.offset + infoLength > stream.length) fail("Truncated IWA archive info.");
155
+ const info = readProto(stream.subarray(position.offset, position.offset + infoLength));
156
+ position.offset += infoLength;
157
+ const id = protoNumber(info, 1);
158
+ if (id === void 0) fail("IWA archive has no identifier.");
159
+ const messages = [];
160
+ for (const raw of protoMessages(info, 2)) {
161
+ const messageInfo = readProto(raw);
162
+ const type = protoNumber(messageInfo, 1) ?? 0;
163
+ const length = protoNumber(messageInfo, 3) ?? 0;
164
+ if (position.offset + length > stream.length) fail("Truncated IWA message.");
165
+ messages.push({ type, data: stream.subarray(position.offset, position.offset + length) });
166
+ position.offset += length;
167
+ }
168
+ objects.push({ id, messages });
169
+ }
170
+ return objects;
171
+ }
172
+
173
+ // ../plugins/iwork/src/model.ts
174
+ var STORAGE_TYPE = 2001;
175
+ var STORAGE_KIND_BODY = 0;
176
+ var STORAGE_KIND_NOTE = 4;
177
+ var PAGES_DOCUMENT_TYPE = 1e4;
178
+ var KEYNOTE_DOCUMENT_TYPE = 1;
179
+ var KEYNOTE_SHOW_TYPE = 2;
180
+ var KEYNOTE_SLIDE_NODE_TYPE = 4;
181
+ var KEYNOTE_SLIDE_TYPE = 5;
182
+ var PACKAGE_METADATA_TYPE = 11006;
183
+ var MAX_SLIDE_DEPTH = 32;
184
+ var decoder = new TextDecoder();
185
+ function splitParagraphs(text) {
186
+ return text.replace(/\uFFFC/g, "").split(/[\n\r\u2029\u000c\u000e\u0004\u0005]/).map((paragraph) => paragraph.replace(/\u2028/g, "\n").replace(/[\u0000-\u0009\u000b\u000f-\u001f]/g, "").trim()).filter(Boolean);
187
+ }
188
+ function indexObjects(files) {
189
+ const objects = /* @__PURE__ */ new Map();
190
+ for (const [file, list] of files) {
191
+ for (const object of list) {
192
+ const message = object.messages[0];
193
+ if (!message || objects.has(object.id)) continue;
194
+ objects.set(object.id, { file, type: message.type, get fields() {
195
+ return readProto(message.data);
196
+ } });
197
+ }
198
+ }
199
+ return objects;
200
+ }
201
+ function referenceId(fields, field) {
202
+ const raw = protoMessages(fields, field)[0];
203
+ return raw ? protoNumber(readProto(raw), 1) : void 0;
204
+ }
205
+ function storageText(fields) {
206
+ return protoMessages(fields, 3).map((chunk) => decoder.decode(chunk)).join("");
207
+ }
208
+ function storages(list) {
209
+ const result = [];
210
+ for (const object of list) {
211
+ for (const message of object.messages) {
212
+ if (message.type !== STORAGE_TYPE) continue;
213
+ const fields = readProto(message.data);
214
+ result.push({ id: object.id, kind: protoNumber(fields, 1), text: storageText(fields) });
215
+ }
216
+ }
217
+ return result;
218
+ }
219
+ function buildPages(files) {
220
+ const documentFile = files.get("Document.iwa");
221
+ const root = documentFile?.find((object) => object.id === 1)?.messages[0];
222
+ if (!documentFile || root?.type !== PAGES_DOCUMENT_TYPE) throw new IwaFormatError("Missing Pages document archive.");
223
+ const bodyId = referenceId(readProto(root.data), 4);
224
+ const all = storages(documentFile);
225
+ const body = all.find((storage) => storage.id === bodyId && storage.kind === STORAGE_KIND_BODY);
226
+ const sections = [];
227
+ const bodyParagraphs = body ? splitParagraphs(body.text) : [];
228
+ if (bodyParagraphs.length) sections.push({ role: "body", paragraphs: bodyParagraphs, notes: [] });
229
+ const boxes = all.filter((storage) => storage !== body && (storage.kind === void 0 || storage.kind === 3)).flatMap((storage) => splitParagraphs(storage.text));
230
+ if (boxes.length) sections.push({ role: "text-boxes", paragraphs: boxes, notes: [] });
231
+ return { app: "pages", generation: "iwa", sections };
232
+ }
233
+ function dataFileNames(files) {
234
+ const names = /* @__PURE__ */ new Map();
235
+ for (const object of files.get("Metadata.iwa") ?? []) {
236
+ for (const message of object.messages) {
237
+ if (message.type !== PACKAGE_METADATA_TYPE) continue;
238
+ for (const raw of protoMessages(readProto(message.data), 4)) {
239
+ const info = readProto(raw);
240
+ const id = protoNumber(info, 1);
241
+ const name = protoMessages(info, 4)[0] ?? protoMessages(info, 3)[0];
242
+ if (id !== void 0 && name) names.set(id, decoder.decode(name));
243
+ }
244
+ }
245
+ }
246
+ return names;
247
+ }
248
+ function orderSlideText(objects, slide, texts) {
249
+ const rank = /* @__PURE__ */ new Map();
250
+ const drawables = [5, 6, 7].flatMap((field) => protoMessages(slide, field).map((raw) => protoNumber(readProto(raw), 1)));
251
+ for (const drawableId of drawables) {
252
+ const drawable = objects.get(drawableId ?? -1);
253
+ const shape = drawable && protoMessages(drawable.fields, 1)[0];
254
+ const storageId = shape ? referenceId(readProto(shape), 2) : void 0;
255
+ if (storageId !== void 0 && !rank.has(storageId)) rank.set(storageId, rank.size);
256
+ }
257
+ return texts.map((text, index) => ({ text, order: rank.get(text.id) ?? rank.size + index })).sort((a, b) => a.order - b.order).map(({ text }) => text);
258
+ }
259
+ function buildKeynote(files, resolveData) {
260
+ const objects = indexObjects(files);
261
+ const root = objects.get(1);
262
+ if (root?.type !== KEYNOTE_DOCUMENT_TYPE) throw new IwaFormatError("Missing Keynote document archive.");
263
+ const show = objects.get(referenceId(root.fields, 2) ?? -1);
264
+ if (show?.type !== KEYNOTE_SHOW_TYPE) throw new IwaFormatError("Missing Keynote show archive.");
265
+ const treeRaw = protoMessages(show.fields, 3)[0];
266
+ const tree = treeRaw ? readProto(treeRaw) : /* @__PURE__ */ new Map();
267
+ const dataNames = dataFileNames(files);
268
+ const sections = [];
269
+ const visited = /* @__PURE__ */ new Set();
270
+ const visit = (nodeId, depth) => {
271
+ if (depth > MAX_SLIDE_DEPTH || visited.has(nodeId)) return;
272
+ visited.add(nodeId);
273
+ const node = objects.get(nodeId);
274
+ if (node?.type !== KEYNOTE_SLIDE_NODE_TYPE) return;
275
+ const slide = objects.get(referenceId(node.fields, 2) ?? -1);
276
+ if (slide?.type === KEYNOTE_SLIDE_TYPE) {
277
+ const own = files.get(slide.file) ?? [];
278
+ const slideCount = own.filter((object) => object.messages[0]?.type === KEYNOTE_SLIDE_TYPE).length;
279
+ const texts = slideCount === 1 ? orderSlideText(objects, slide.fields, storages(own)) : [];
280
+ const thumbnailRaw = protoMessages(node.fields, 16)[0];
281
+ const thumbnailId = thumbnailRaw ? protoNumber(readProto(thumbnailRaw), 1) : void 0;
282
+ sections.push({
283
+ role: "slide",
284
+ paragraphs: texts.filter((text) => text.kind !== STORAGE_KIND_NOTE).flatMap((text) => splitParagraphs(text.text)),
285
+ notes: texts.filter((text) => text.kind === STORAGE_KIND_NOTE).flatMap((text) => splitParagraphs(text.text)),
286
+ image: thumbnailId === void 0 ? void 0 : resolveData(thumbnailId, dataNames.get(thumbnailId))
287
+ });
288
+ }
289
+ for (const raw of protoMessages(node.fields, 1)) {
290
+ const child = protoNumber(readProto(raw), 1);
291
+ if (child !== void 0) visit(child, depth + 1);
292
+ }
293
+ };
294
+ for (const raw of protoMessages(tree, 2)) {
295
+ const nodeId = protoNumber(readProto(raw), 1);
296
+ if (nodeId !== void 0) visit(nodeId, 0);
297
+ }
298
+ return { app: "keynote", generation: "iwa", sections };
299
+ }
300
+ function buildIwaModel(app, files, resolveData) {
301
+ return app === "pages" ? buildPages(files) : buildKeynote(files, resolveData);
302
+ }
303
+
304
+ // ../plugins/iwork/src/legacy.ts
305
+ var SF = "http://developer.apple.com/namespaces/sf";
306
+ var KEY = "http://developer.apple.com/namespaces/keynote2";
307
+ var LegacyFormatError = class extends Error {
308
+ };
309
+ function descendants(scope, namespace, localName) {
310
+ return Array.from(scope.getElementsByTagName("*")).filter(
311
+ (element) => element.namespaceURI === namespace && element.localName === localName
312
+ );
313
+ }
314
+ function sfAttribute(element, name) {
315
+ return element?.getAttribute(`sf:${name}`) ?? void 0;
316
+ }
317
+ function paragraphText(paragraph) {
318
+ let text = "";
319
+ const walk = (node) => {
320
+ for (const child of Array.from(node.childNodes)) {
321
+ if (child.nodeType === 3) text += child.nodeValue ?? "";
322
+ else if (child.nodeType === 1) {
323
+ const element = child;
324
+ if (element.namespaceURI === SF && element.localName === "ghost-text") continue;
325
+ if (element.namespaceURI === SF && (element.localName === "br" || element.localName === "lnbr")) text += "\n";
326
+ else if (element.namespaceURI === SF && element.localName === "tab") text += " ";
327
+ else walk(element);
328
+ }
329
+ }
330
+ };
331
+ walk(paragraph);
332
+ return text;
333
+ }
334
+ function paragraphsIn(scope, exclude) {
335
+ return descendants(scope, SF, "p").filter((paragraph) => !exclude?.(paragraph)).flatMap((paragraph) => splitParagraphs(paragraphText(paragraph)));
336
+ }
337
+ function insideNotes(element, slide) {
338
+ for (let node = element.parentElement; node && node !== slide; node = node.parentElement) {
339
+ if (node.namespaceURI === KEY && node.localName === "notes") return true;
340
+ }
341
+ return false;
342
+ }
343
+ function parse(xml) {
344
+ const document = parseXmlDocument(xml, "application/xml");
345
+ if (document.getElementsByTagName("parsererror").length) throw new LegacyFormatError("Malformed iWork XML.");
346
+ return document;
347
+ }
348
+ function buildPages2(document) {
349
+ if (document.documentElement.localName !== "document") throw new LegacyFormatError("Not a Pages document.");
350
+ const storage = Array.from(document.documentElement.children).find(
351
+ (child) => child.namespaceURI === SF && child.localName === "text-storage" && sfAttribute(child, "kind") === "body"
352
+ );
353
+ const body = storage && descendants(storage, SF, "text-body")[0];
354
+ const paragraphs = body ? paragraphsIn(body) : [];
355
+ const sections = paragraphs.length ? [{ role: "body", paragraphs, notes: [] }] : [];
356
+ return { app: "pages", generation: "xml", sections };
357
+ }
358
+ function buildKeynote2(document) {
359
+ if (document.documentElement.namespaceURI !== KEY || document.documentElement.localName !== "presentation") {
360
+ throw new LegacyFormatError("Not a Keynote presentation.");
361
+ }
362
+ const list = descendants(document, KEY, "slide-list")[0];
363
+ const slides = list ? descendants(list, KEY, "slide") : [];
364
+ const sections = slides.map((slide) => {
365
+ const thumbnails = descendants(slide, KEY, "thumbnails")[0];
366
+ const path = sfAttribute(thumbnails && descendants(thumbnails, SF, "data")[0], "path");
367
+ const notes = descendants(slide, KEY, "notes")[0];
368
+ return {
369
+ role: "slide",
370
+ paragraphs: paragraphsIn(slide, (paragraph) => insideNotes(paragraph, slide)),
371
+ notes: notes ? paragraphsIn(notes) : [],
372
+ image: path || void 0
373
+ };
374
+ });
375
+ return { app: "keynote", generation: "xml", sections };
376
+ }
377
+ function buildLegacyModel(app, xml) {
378
+ const document = parse(xml);
379
+ return app === "pages" ? buildPages2(document) : buildKeynote2(document);
380
+ }
381
+
382
+ // ../plugins/iwork/src/package.ts
383
+ var IWORK_LIMITS = {
384
+ entries: 2e4,
385
+ /** One compressed IWA stream, legacy XML file or nested Index.zip. */
386
+ entryBytes: 128 * 1024 * 1024,
387
+ /** Sum of decompressed IWA streams / legacy XML text. */
388
+ expandedBytes: 256 * 1024 * 1024,
389
+ /** Sum of thumbnails and previews turned into object URLs. */
390
+ imageBytes: 64 * 1024 * 1024,
391
+ slides: 5e3
392
+ };
393
+ var PackageLimitError = class extends Error {
394
+ };
395
+ var PackageEncryptedError = class extends Error {
396
+ };
397
+ var SUPPORTED_METHODS = /* @__PURE__ */ new Set([0, 8]);
398
+ var IworkPackage = class _IworkPackage {
399
+ constructor(signal) {
400
+ this.signal = signal;
401
+ this.readers = [];
402
+ this.entries = /* @__PURE__ */ new Map();
403
+ }
404
+ static async open(file, signal) {
405
+ const pkg = new _IworkPackage(signal);
406
+ try {
407
+ await pkg.mount(file, "");
408
+ return pkg;
409
+ } catch (error) {
410
+ await pkg.close();
411
+ throw error;
412
+ }
413
+ }
414
+ get names() {
415
+ return new Set(this.entries.keys());
416
+ }
417
+ /** Mounts a nested ZIP (the `Index.zip` of a package bundle) under `prefix`. */
418
+ async mountNested(path, prefix) {
419
+ await this.mount(await this.blob(path, IWORK_LIMITS.entryBytes), prefix);
420
+ }
421
+ async bytes(path, limit) {
422
+ const entry = this.entry(path, limit);
423
+ return entry.getData(new Uint8ArrayWriter(), { signal: this.signal });
424
+ }
425
+ async blob(path, limit, type = "application/octet-stream") {
426
+ const entry = this.entry(path, limit);
427
+ return entry.getData(new BlobWriter(type), { signal: this.signal });
428
+ }
429
+ size(path) {
430
+ return this.entries.get(path)?.uncompressedSize;
431
+ }
432
+ async close() {
433
+ await Promise.all(this.readers.splice(0).map((reader) => reader.close().catch(() => void 0)));
434
+ }
435
+ entry(path, limit) {
436
+ const entry = this.entries.get(path);
437
+ if (!entry) throw new Error(`Missing package entry ${path}.`);
438
+ if (entry.encrypted || !SUPPORTED_METHODS.has(entry.compressionMethod)) throw new PackageEncryptedError("Encrypted entry.");
439
+ if (entry.uncompressedSize > limit) throw new PackageLimitError("Package entry exceeds the limit.");
440
+ return entry;
441
+ }
442
+ async mount(blob, prefix) {
443
+ const reader = new ZipReader(new BlobReader(blob), { useWebWorkers: false, useCompressionStream: true });
444
+ this.readers.push(reader);
445
+ for await (const entry of reader.getEntriesGenerator()) {
446
+ if (this.signal.aborted) throw new DOMException("Viewer operation aborted.", "AbortError");
447
+ if (this.entries.size >= IWORK_LIMITS.entries) throw new PackageLimitError("Too many package entries.");
448
+ if (isFile(entry)) this.entries.set((prefix + entry.filename).normalize("NFC"), entry);
449
+ }
450
+ }
451
+ };
452
+ function isFile(entry) {
453
+ return !entry.directory;
454
+ }
455
+
456
+ // ../plugins/iwork/src/load.ts
457
+ async function readIwaFiles(pkg, prefix, app, signal) {
458
+ const index = `${prefix}Index/`;
459
+ const wanted = [...pkg.names].filter((name) => {
460
+ if (!name.startsWith(index)) return false;
461
+ const local = name.slice(index.length);
462
+ if (local === "Document.iwa" || local === "Metadata.iwa") return true;
463
+ return app === "keynote" && /^Slide(-[^/]*)?\.iwa$/.test(local);
464
+ });
465
+ if (app === "keynote" && wanted.length > IWORK_LIMITS.slides + 2) throw new PackageLimitError("Too many slides.");
466
+ const files = /* @__PURE__ */ new Map();
467
+ let budget = IWORK_LIMITS.expandedBytes;
468
+ for (const name of wanted) {
469
+ if (signal.aborted) throw abortError();
470
+ const stream = decodeIwaStream(await pkg.bytes(name, IWORK_LIMITS.entryBytes), budget);
471
+ budget -= stream.length;
472
+ files.set(name.slice(index.length), readIwaObjects(stream));
473
+ }
474
+ return files;
475
+ }
476
+ async function readLegacyXml(pkg, path) {
477
+ const blob = await pkg.blob(path, IWORK_LIMITS.entryBytes);
478
+ if (!path.endsWith(".gz")) return blob.text();
479
+ const chunks = [];
480
+ let size = 0;
481
+ const reader = blob.stream().pipeThrough(new DecompressionStream("gzip")).getReader();
482
+ try {
483
+ for (let read = await reader.read(); !read.done; read = await reader.read()) {
484
+ size += read.value.length;
485
+ if (size > IWORK_LIMITS.expandedBytes) throw new PackageLimitError("Expanded XML exceeds the limit.");
486
+ chunks.push(read.value);
487
+ }
488
+ } finally {
489
+ await reader.cancel().catch(() => void 0);
490
+ }
491
+ return new Blob(chunks).text();
492
+ }
493
+ function dataResolver(names, prefix) {
494
+ const data = `${prefix}Data/`;
495
+ const entries = [...names].filter((name) => name.startsWith(data));
496
+ return (id, name) => {
497
+ const exact = name ? `${data}${name.normalize("NFC")}` : void 0;
498
+ if (exact && names.has(exact)) return exact;
499
+ const suffix = `-${id}.`;
500
+ return entries.find((entry) => entry.slice(data.length).includes(suffix));
501
+ };
502
+ }
503
+ async function buildIworkModel(pkg, layout, app, signal) {
504
+ if (layout.kind === "xml") {
505
+ const model = buildLegacyModel(app, await readLegacyXml(pkg, layout.index));
506
+ const sections = model.sections.map((section) => ({ ...section, image: section.image ? layout.prefix + section.image : void 0 }));
507
+ return { ...model, sections };
508
+ }
509
+ if (layout.kind === "iwa-zip") await pkg.mountNested(`${layout.prefix}Index.zip`, layout.prefix);
510
+ const files = await readIwaFiles(pkg, layout.prefix, app, signal);
511
+ return buildIwaModel(app, files, dataResolver(pkg.names, layout.prefix));
512
+ }
513
+
514
+ // ../plugins/iwork/src/extract.ts
515
+ var PLUGIN_ID = "iwork";
516
+ var TITLE_CHARS = 80;
517
+ function mapError(error) {
518
+ if (error instanceof AgentError || isViewerAbortError(error)) throw error;
519
+ if (error instanceof PackageEncryptedError) {
520
+ throw new AgentError("encrypted-file", "Password-protected iWork documents are not supported.", { pluginId: PLUGIN_ID, cause: error });
521
+ }
522
+ if (error instanceof PackageLimitError || error instanceof IwaLimitError) {
523
+ throw new AgentError("resource-limit", "The iWork document exceeds safety limits.", { pluginId: PLUGIN_ID, cause: error });
524
+ }
525
+ throw new AgentError("invalid-file", "The file is not a readable Pages or Keynote document.", { pluginId: PLUGIN_ID, cause: error });
526
+ }
527
+ async function isZipHeader(context) {
528
+ const head = await context.source.read(0, 4, context.signal);
529
+ return head.length >= 4 && head[0] === 80 && head[1] === 75 && head[2] === 3 && head[3] === 4;
530
+ }
531
+ async function resolveModel(pkg, namedApp, signal) {
532
+ if (namedApp) {
533
+ const layout2 = detectIworkLayout(pkg.names, namedApp);
534
+ if (!layout2) throw new AgentError("invalid-file", "The file is not a readable Pages or Keynote document.", { pluginId: PLUGIN_ID });
535
+ if (layout2.kind === "encrypted") throw new PackageEncryptedError("Password-protected package.");
536
+ return { model: await buildIworkModel(pkg, layout2, namedApp, signal), layout: layout2 };
537
+ }
538
+ const pagesLayout = detectIworkLayout(pkg.names, "pages");
539
+ const keynoteLayout = detectIworkLayout(pkg.names, "keynote");
540
+ if (pagesLayout?.kind === "encrypted" || keynoteLayout?.kind === "encrypted") {
541
+ throw new PackageEncryptedError("Password-protected package.");
542
+ }
543
+ if (pagesLayout?.kind === "xml") {
544
+ return { model: await buildIworkModel(pkg, pagesLayout, "pages", signal), layout: pagesLayout };
545
+ }
546
+ if (keynoteLayout?.kind === "xml") {
547
+ return { model: await buildIworkModel(pkg, keynoteLayout, "keynote", signal), layout: keynoteLayout };
548
+ }
549
+ const layout = pagesLayout ?? keynoteLayout;
550
+ if (!layout) throw new AgentError("invalid-file", "The file is not a readable Pages or Keynote document.", { pluginId: PLUGIN_ID });
551
+ try {
552
+ return { model: await buildIworkModel(pkg, layout, "pages", signal), layout };
553
+ } catch (error) {
554
+ if (!(error instanceof IwaFormatError)) throw error;
555
+ const iwaLayout = { kind: "iwa", prefix: layout.prefix };
556
+ return { model: await buildIworkModel(pkg, iwaLayout, "keynote", signal), layout: iwaLayout };
557
+ }
558
+ }
559
+ async function loadModel(context) {
560
+ if (context.signal.aborted) throw abortError();
561
+ if (!await isZipHeader(context)) {
562
+ throw new AgentError("invalid-file", "The file is not a readable Pages or Keynote document.", { pluginId: PLUGIN_ID });
563
+ }
564
+ const namedApp = iworkAppFromName(context.file.name);
565
+ let pkg;
566
+ try {
567
+ pkg = await IworkPackage.open(context.file, context.signal);
568
+ const { model, layout } = await resolveModel(pkg, namedApp, context.signal);
569
+ return { model, hasPreview: previewPath(pkg.names, layout.prefix) !== void 0 };
570
+ } catch (error) {
571
+ return mapError(error);
572
+ } finally {
573
+ await pkg?.close();
574
+ }
575
+ }
576
+ function sectionMarkdown(title, section) {
577
+ const parts = [`## ${title}`, ...section.paragraphs];
578
+ if (section.notes.length) parts.push("### Presenter notes", ...section.notes);
579
+ return parts.join("\n\n");
580
+ }
581
+ function textSections(model) {
582
+ let slide = 0;
583
+ return model.sections.map((section) => {
584
+ if (section.role === "slide") {
585
+ slide += 1;
586
+ const heading = section.paragraphs[0]?.replace(/\s+/g, " ").slice(0, TITLE_CHARS);
587
+ const title2 = heading ? `Slide ${slide}: ${heading}` : `Slide ${slide}`;
588
+ return {
589
+ target: { id: `slide:${slide}`, title: title2, kind: "slide", size: section.paragraphs.length + section.notes.length },
590
+ markdown: sectionMarkdown(`Slide ${slide}`, section)
591
+ };
592
+ }
593
+ const title = section.role === "body" ? "Document text" : "Text boxes";
594
+ return {
595
+ target: { id: section.role, title, kind: "section", size: section.paragraphs.length },
596
+ markdown: sectionMarkdown(title, section)
597
+ };
598
+ });
599
+ }
600
+ function pageText(text, params) {
601
+ const maxBytes = Math.min(params.maxBytes, HARD_READ_MAX_BYTES);
602
+ const needle = params.filter?.trim().toLowerCase();
603
+ if (!needle) return paginateText(text, params.cursor, maxBytes, "markdown", PLUGIN_ID);
604
+ const lines = text.split("\n").filter((line) => line.toLowerCase().includes(needle));
605
+ const page = paginateLines(lines, params.cursor, maxBytes, PLUGIN_ID);
606
+ return { contentType: "markdown", ...page, filterApplied: true };
607
+ }
608
+ var iworkExtractor = {
609
+ async inspect(context) {
610
+ const { model, hasPreview } = await loadModel(context);
611
+ const sections = textSections(model);
612
+ return {
613
+ metadata: {
614
+ app: model.app,
615
+ generation: model.generation === "iwa" ? "iWork 2013+" : "iWork '09",
616
+ ...model.app === "keynote" ? { slideCount: sections.length } : {},
617
+ paragraphCount: model.sections.reduce((sum, section) => sum + section.paragraphs.length, 0),
618
+ noteCount: model.sections.reduce((sum, section) => sum + section.notes.length, 0),
619
+ hasSavedPreview: hasPreview,
620
+ sizeBytes: context.source.size
621
+ },
622
+ targets: sections.map((section) => section.target)
623
+ };
624
+ },
625
+ async read(context, params) {
626
+ const { model } = await loadModel(context);
627
+ const sections = textSections(model);
628
+ let selected = sections;
629
+ if (params.target !== void 0) {
630
+ selected = sections.filter((section) => section.target.id === params.target);
631
+ if (!selected.length) throw new AgentError("target-not-found", `iWork target not found: "${params.target}".`, { pluginId: PLUGIN_ID });
632
+ }
633
+ const text = selected.map((section) => section.markdown).join("\n\n") || "(no text found)";
634
+ return pageText(text, params);
635
+ }
636
+ };
637
+ var extract_default = iworkExtractor;
638
+ export {
639
+ extract_default as default
640
+ };