@poe-platform/safe-bash 0.1.812 → 0.1.814
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.
- package/dist/audio-ast/id3-source.d.ts +27 -0
- package/dist/audio-ast/index.d.ts +4 -0
- package/dist/audio-ast/index.js +996 -596
- package/dist/audio-ast/mp3-source.d.ts +18 -0
- package/dist/audio-ast/ogg-source.d.ts +25 -0
- package/dist/audio-ast/ogg-stream-source.d.ts +22 -0
- package/dist/image-ast/index.js +139 -9
- package/dist/mp4-ast/containers/adapters.d.ts +7 -0
- package/dist/mp4-ast/index.d.ts +2 -0
- package/dist/mp4-ast/mp4-sample-source.d.ts +52 -0
- package/dist/mp4-ast/mp4-source.d.ts +32 -0
- package/dist/office-xml/retained-xml-document.d.ts +14 -0
- package/dist/pdf-ast/ast.d.ts +2 -0
- package/dist/pdf-ast/content/dictionary-cursor.d.ts +15 -0
- package/dist/pdf-ast/content/evaluator.d.ts +4 -0
- package/dist/pdf-ast/content/range-operator-parser.d.ts +4 -0
- package/dist/pdf-ast/content/stored-dictionary.d.ts +10 -0
- package/dist/pdf-ast/cos/lexer.d.ts +8 -5
- package/dist/pdf-ast/cos/object-reader.d.ts +11 -3
- package/dist/pdf-ast/cos/range-parser.d.ts +4 -0
- package/dist/pdf-ast/cos/retained-objects.d.ts +1 -0
- package/dist/pdf-ast/cos/retained-writer.d.ts +1 -0
- package/dist/pdf-ast/cos/value-parser.d.ts +10 -0
- package/dist/pdf-ast/edit/retained-append-attachments.d.ts +13 -0
- package/dist/pdf-ast/edit/retained-bookmarks.d.ts +13 -0
- package/dist/pdf-ast/edit/retained-form-appearances.d.ts +10 -0
- package/dist/pdf-ast/edit/retained-graph.d.ts +12 -0
- package/dist/pdf-ast/edit/retained-info-updates.d.ts +33 -0
- package/dist/pdf-ast/edit/retained-save.d.ts +2 -0
- package/dist/pdf-ast/edit/retained-stamps.d.ts +9 -0
- package/dist/pdf-ast/fonts/resolve.d.ts +3 -1
- package/dist/pdf-ast/index.d.ts +3 -1
- package/dist/pdf-ast/index.js +1966 -844
- package/dist/pdf-ast/retained-document.d.ts +5 -0
- package/dist/safe-bash/audio-ast.browser.js +6 -1
- package/dist/safe-bash/chunks/{chunk-HHSOUC3Z.js → chunk-HPQE675Q.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-BUYRKFW2.js → chunk-I6ECNJMR.js} +1 -1
- package/dist/safe-bash/chunks/{pdftk-WRYEP3CA.js → pdftk-Y2TX74LY.js} +2 -1
- package/dist/safe-bash/command-chunks/biff-KRHJ63K3-VQPJCVIL.js +5309 -0
- package/dist/safe-bash/command-chunks/{chunk-34G2SQX2.js → chunk-2BLTUQNK.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-LLU2IQEJ.js → chunk-2BNGPR6Z.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-HWQ2UHMT.js → chunk-2ETEJOYX.js} +18 -18
- package/dist/safe-bash/command-chunks/{chunk-NQDIT667.js → chunk-2PKBXGXD.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-MMBZTYXO.js → chunk-2PQRZDNR.js} +221 -0
- package/dist/safe-bash/command-chunks/{chunk-6QBMND4A.js → chunk-2VVJRVYM.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-G5QVZQCO.js → chunk-3EASXF5D.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-U3SBHEKH.js → chunk-3EB2FSAN.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-VB2TUPO2.js → chunk-3EW7GYHM.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-RNSKXOG3.js → chunk-3GRMU7TM.js} +6 -6
- package/dist/safe-bash/command-chunks/chunk-3JM7E42I.js +197 -0
- package/dist/safe-bash/command-chunks/{chunk-6L4IYQAT.js → chunk-3MG5EAMX.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-RASQPOSV.js → chunk-3SPLP2DB.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-K5COUQAQ.js → chunk-3VGQTLO6.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-K7CV55K5.js → chunk-3YEQI5B7.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-ZXR6LXV5.js → chunk-3ZRCL756.js} +48 -4
- package/dist/safe-bash/command-chunks/{chunk-SOFM3GPG.js → chunk-42MEXZBJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-GQ2ZSPZ3.js → chunk-46AMTJPE.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-MTWZEPAR.js → chunk-47IAU25U.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-6GI3NTCW.js → chunk-4B2ZUGLT.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-L5MCW6CM.js → chunk-4EHY6J2Z.js} +9 -155
- package/dist/safe-bash/command-chunks/{chunk-QQVACHZA.js → chunk-4EZJV4FZ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-SSKMPDN4.js → chunk-4GQKCUS5.js} +15 -15
- package/dist/safe-bash/command-chunks/{chunk-UOBW5K3M.js → chunk-4RRYWHED.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-PINR7QET.js → chunk-4UPKVQWH.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-M7QE2MN7.js → chunk-4YLACJHE.js} +6 -6
- package/dist/safe-bash/command-chunks/chunk-5BIQWWLB.js +175 -0
- package/dist/safe-bash/command-chunks/{chunk-P3WU3PSL.js → chunk-5L4YGRQU.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-HKATEVAP.js → chunk-5LFGXN3D.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-SPLOIABU.js → chunk-5OM3UIK3.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-TVH4JORU.js → chunk-6LPSKLLD.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-CV7M2QJU.js → chunk-6QYSF7I2.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-XVP6V5K3.js → chunk-6VBDJC6V.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-6N5GHM72.js → chunk-6WNVGCXD.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-6CCQI6XZ.js → chunk-6XES7Z4G.js} +12 -12
- package/dist/safe-bash/command-chunks/{chunk-AFROLW6S.js → chunk-6XGDWFNQ.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-WTE23QXN.js → chunk-6ZGCKUAM.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-6ZHQB453.js +35 -0
- package/dist/safe-bash/command-chunks/{chunk-RIV6XN7K.js → chunk-7DOLY7IV.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-QD7ZRDUN.js → chunk-7KZ5LWV2.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-NGR5KOPQ.js → chunk-A347DLRB.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-ZM2Y4Z3C.js → chunk-A45UG4KT.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-56NYSX65.js → chunk-ADHFF2IM.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-ATI464W3.js → chunk-AG2SNMP5.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-FDCIPJBQ.js → chunk-AM5LANIE.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-3Q247UDJ.js → chunk-AVGXFWEB.js} +278 -135
- package/dist/safe-bash/command-chunks/{chunk-RBTC7OFT.js → chunk-AVOGFREX.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-QC5RMGSA.js → chunk-AWPI4DZR.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-FYMNHG7R.js → chunk-AXXZNB7U.js} +13 -13
- package/dist/safe-bash/command-chunks/{chunk-Q6S57NOQ.js → chunk-AY3KQ4EN.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-456PHA3L.js → chunk-BLGGAHQW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-CU4DLVME.js → chunk-BLIFGBIO.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-NARD63DY.js → chunk-BS3ZEQGT.js} +22 -66
- package/dist/safe-bash/command-chunks/{chunk-WFVSUXJL.js → chunk-BS5JEUEW.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-UYWSIIUX.js → chunk-BZMNC7Q5.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-RHYJVTJO.js → chunk-CCMAHM3I.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-N4R2SHSS.js → chunk-CCZZVCHX.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-WGG6G2KG.js → chunk-CIRDVCAZ.js} +7 -7
- package/dist/safe-bash/command-chunks/chunk-CK2WFJZN.js +178 -0
- package/dist/safe-bash/command-chunks/{chunk-UZL7G57V.js → chunk-CKEMZUE3.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-B5LDP7AA.js → chunk-CQBACD2V.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-JYUJAF4L.js → chunk-CSE4VQKG.js} +16 -1
- package/dist/safe-bash/command-chunks/{chunk-Q73EMLLZ.js → chunk-CXME4YHU.js} +107 -5
- package/dist/safe-bash/command-chunks/{chunk-FTLDRH47.js → chunk-CZ5K2YPU.js} +16 -16
- package/dist/safe-bash/command-chunks/{chunk-554Z6IKP.js → chunk-DBLQUZGN.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-6M6TM5Z5.js → chunk-DBNJEXHK.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-SPW4GW4Z.js → chunk-DFI7QF3M.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-ZO5WBWLL.js → chunk-DN6MSXY7.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-GXLXWZWH.js → chunk-DZH54L3F.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-XRVKWGVQ.js → chunk-EBHOZIBS.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-3Y5EME26.js → chunk-ENEIE44W.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-ATTWQVR2.js → chunk-EQWFKNHJ.js} +17 -17
- package/dist/safe-bash/command-chunks/{chunk-YV72XQKL.js → chunk-ETXPMVR6.js} +13 -13
- package/dist/safe-bash/command-chunks/{chunk-JFYWVQ4V.js → chunk-EV5G535P.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-PZMU3Z4L.js → chunk-EVYKV3QI.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-D6UMSC45.js → chunk-F4YFTO2K.js} +11 -11
- package/dist/safe-bash/command-chunks/{chunk-MPUHH2KR.js → chunk-F762XDNG.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-D2ASPM7R.js → chunk-FF7UGJWS.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-OA75SGN2.js → chunk-FOONI6BD.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-DYLNU57U.js → chunk-FSVJ67G5.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-CLKOGAR3.js → chunk-FSYMSWJU.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-22MOB45U.js → chunk-FUQMEUAT.js} +6 -6
- package/dist/safe-bash/command-chunks/chunk-FWKLBDMK.js +0 -0
- package/dist/safe-bash/command-chunks/{chunk-KXPCSVAT.js → chunk-FXCSPPYE.js} +20 -20
- package/dist/safe-bash/command-chunks/{chunk-XZ2FWFNV.js → chunk-FYYFV6PW.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-3OETVNJA.js → chunk-G2COZLXX.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-ZEX53S5I.js → chunk-G3TAX3CV.js} +7369 -7221
- package/dist/safe-bash/command-chunks/{chunk-LXLLA4PM.js → chunk-GCHB7VNX.js} +17 -17
- package/dist/safe-bash/command-chunks/{chunk-4Y6O2K35.js → chunk-GLAF45M7.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-OEJM666F.js → chunk-GQGMQMIM.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-RRL3Y562.js → chunk-GXMPXMDP.js} +11 -11
- package/dist/safe-bash/command-chunks/{chunk-GEM47B2P.js → chunk-GYM5ICK4.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-A5FZBR7X.js → chunk-H33D4R26.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-AGLK7OJR.js → chunk-HDSIIQBS.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3ZDANXIC.js → chunk-HELAVGZH.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-S4QH5BXZ.js → chunk-HGIMFVI2.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-35IPOBWL.js → chunk-HI6ZYH3W.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-KB7DUBVL.js → chunk-HK6MSB7Z.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-7ZE3VIAN.js → chunk-IB5QP4LF.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-UCR5YDV3.js → chunk-IBYMPAUW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-LABOWPFB.js → chunk-IHXZMAMY.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-XPD636C4.js → chunk-IWHNRYER.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-PPO7YUZF.js → chunk-JGKSWDGP.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-KCOJA7EM.js → chunk-JR3Q6QNL.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-S6R3IB36.js → chunk-JUHOL5KB.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3O2YEI47.js → chunk-JVKE7YZN.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-6NATRKUJ.js → chunk-JW6WVNTM.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IK6K2HCG.js → chunk-JWORWL72.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-JOCFI7TG.js → chunk-K2WOMJOQ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XVLWZTPY.js → chunk-K4XNUJVJ.js} +543 -144
- package/dist/safe-bash/command-chunks/{chunk-DM2CPMB4.js → chunk-KBAQHE5Y.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-KCLJGRU7.js +737 -0
- package/dist/safe-bash/command-chunks/{chunk-TUDFMNPP.js → chunk-KINIV2SV.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-43TRBJ2N.js → chunk-KPHLESD4.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-47NEG4UO.js → chunk-KRRG4MGH.js} +222 -46
- package/dist/safe-bash/command-chunks/{chunk-33YCKZZX.js → chunk-KSBNZTAZ.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-4Y34ZG4T.js → chunk-KUOCGGEU.js} +11 -11
- package/dist/safe-bash/command-chunks/{chunk-ML5R5JML.js → chunk-KY4LCHUF.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2JSDKQ4J.js → chunk-LAPOMHGY.js} +251 -239
- package/dist/safe-bash/command-chunks/{chunk-ENT3IV2G.js → chunk-LDW3RF7Y.js} +12 -12
- package/dist/safe-bash/command-chunks/{chunk-U27XPNLP.js → chunk-LEO4VRIN.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-GZ3VIWNN.js → chunk-LKGTH2Q7.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-ZMHEGDU2.js → chunk-LNTEV56A.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-DVGXLBUW.js → chunk-LZ2JFMKT.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-6D2BMAF4.js → chunk-MEM2ZPMI.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-HTVIYLVB.js → chunk-MGMTRGKM.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-B3NLITWP.js → chunk-MKK6FM5H.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-Z2JW6M2D.js → chunk-MKOIPOXX.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-MLOYUXUV.js +244 -0
- package/dist/safe-bash/command-chunks/{chunk-CBNKHBLD.js → chunk-MNK3DDH6.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-JVGUVHWI.js → chunk-MPXMRTMY.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-TW73OXPR.js → chunk-MVLVIMJ6.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-TY4WDAHM.js → chunk-MYZ46FQL.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-TBAIMDGL.js → chunk-N4MUBJCT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-NPLVFAD6.js → chunk-N6G3345Q.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-ZIIO6GRY.js → chunk-NEMUPUUB.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-K5GB2YMN.js → chunk-NEVQWOU6.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-FIIAYCWS.js → chunk-NFGCBQN3.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-PNGDJA6M.js → chunk-NFII726L.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-JQPNA77Y.js → chunk-NHNZYWPW.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-NQINS4XY.js +156 -0
- package/dist/safe-bash/command-chunks/{chunk-APEWTWCC.js → chunk-NRFTYZ2R.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-THMZLJQD.js → chunk-NYFYTL5G.js} +18 -18
- package/dist/safe-bash/command-chunks/{chunk-SMSGLRIH.js → chunk-OTF2AJ5M.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-QZZ73J2O.js → chunk-OVQP6KH5.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-HDJVJTCK.js → chunk-P2LT6TGR.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-YS25EI54.js → chunk-PCCFLPUQ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-26VCZHLJ.js → chunk-PIOQBOEK.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-D2KZ66W4.js → chunk-PIVH35EQ.js} +190 -42
- package/dist/safe-bash/command-chunks/{chunk-QYMEASQ6.js → chunk-PLMF35XK.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-JQVHUSDD.js → chunk-PLR5IULU.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-2CORNDGF.js → chunk-PS5GDFIP.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-R6EGGK5M.js → chunk-Q5PWYPQV.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-COKYZUBW.js → chunk-Q7TVCBU2.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-EHTOHOTR.js → chunk-QB72X7FF.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-F3GP3EXE.js → chunk-RGDOYWOD.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-RQIQ75W5.js → chunk-RHDERFMR.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-3KMOXEGH.js → chunk-RHU44OMN.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-7PVHO47B.js → chunk-RIVKF77R.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-UOR6PXZZ.js → chunk-ROL5AEX6.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-AHA6IWAJ.js → chunk-RQYPFLZJ.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-YSMNXMAO.js → chunk-RTNI47C5.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-W5LLKV5H.js → chunk-RV5AGXOV.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-PMAM4N33.js → chunk-RXQ2G2YK.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-EVU7FLDA.js → chunk-S2QNBAN6.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-YE6OAKK7.js → chunk-S43QRKDC.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-774GLJAO.js → chunk-S7HIOT7Z.js} +4 -4
- package/dist/safe-bash/command-chunks/chunk-SEPUP6TZ.js +63 -0
- package/dist/safe-bash/command-chunks/{chunk-JPMYPOYZ.js → chunk-SUTHGUD3.js} +28 -28
- package/dist/safe-bash/command-chunks/chunk-SW37YCBW.js +286 -0
- package/dist/safe-bash/command-chunks/{chunk-Y4EYCZFT.js → chunk-SWAKALDJ.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-QUM3SYAJ.js → chunk-SYSX46IV.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-WGH3RLJY.js → chunk-T5S4SJGO.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-7JEIWA3A.js → chunk-TID5TSQW.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-CRV2Q3PB.js → chunk-TJLXSENN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IT7TAC3F.js → chunk-TKCUGMRZ.js} +24 -20
- package/dist/safe-bash/command-chunks/{chunk-7GKKMNL6.js → chunk-TXPDKEGY.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-A2CLZMQZ.js → chunk-UJERQEJB.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-6VPQ3CDZ.js → chunk-USGZN2KE.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-LCZDBW55.js → chunk-UYGQEQIP.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-MPORWUTU.js → chunk-V5XC43BX.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-AIMSZBWP.js → chunk-V7E3PZOK.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-CNHRVUHA.js → chunk-VDTFVRYX.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-KJ4XXZIL.js → chunk-VT2PHQ63.js} +582 -59
- package/dist/safe-bash/command-chunks/{chunk-MOZD7RUY.js → chunk-VT7UBPAE.js} +38 -15
- package/dist/safe-bash/command-chunks/{chunk-QDVI2YB6.js → chunk-VUWXLH3E.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-X7FA7ZD5.js → chunk-W3ZSWK76.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-JPA2PUYI.js → chunk-WBKB7HBZ.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-MIRL7HTF.js → chunk-WJ2ERUCQ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-36XGIPOG.js → chunk-WTVJLHMG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-SLQWQKXP.js → chunk-WWHMI4S3.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-2UBZALAK.js → chunk-WYZG3DRR.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-YORJDX4V.js → chunk-WZRFS5OY.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-EHSM5ZQS.js → chunk-X6OHFKBL.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-S6ZTBXYO.js → chunk-XKAUKLF7.js} +13 -13
- package/dist/safe-bash/command-chunks/{chunk-EUT24Y5Z.js → chunk-XM5QJCPD.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-WXRYDALR.js → chunk-XMTR7QGL.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-4CKFNXRN.js → chunk-XNGM3W5R.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2ZFLMWOX.js → chunk-XTEIT5CI.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4DLIUTQV.js → chunk-XU6S3XUZ.js} +11 -11
- package/dist/safe-bash/command-chunks/{chunk-CJQSAATC.js → chunk-XUJAQA3S.js} +30 -30
- package/dist/safe-bash/command-chunks/{chunk-W5YSINXC.js → chunk-Y42KSX63.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-UAXSE3XE.js → chunk-Y54L4P4J.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-6WQD7LRA.js → chunk-YAD7EV4N.js} +14 -14
- package/dist/safe-bash/command-chunks/{chunk-WVMHRNXZ.js → chunk-YRPXBGRX.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-5HPU7D36.js → chunk-Z2WNYEPD.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-SDTPO2VV.js → chunk-Z7QOSXQC.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-WJCN2IXI.js → chunk-ZQM37BGE.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-W3HV45CI.js → chunk-ZSQZHFWS.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-IDJQP3A6.js → chunk-ZTMZO4IT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RID6VYS3.js → chunk-ZU2KJMXO.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-YXKNJ6EM.js → chunk-ZXELXF2H.js} +5 -5
- package/dist/safe-bash/command-chunks/{clipboard-BBDK33GP-VB22F7GI.js → clipboard-BBDK33GP-QZ4ERNQX.js} +2 -2
- package/dist/safe-bash/command-chunks/{command-engine-BCUQGJJ4.js → command-engine-7V6PZR7G.js} +1012 -678
- package/dist/safe-bash/command-chunks/{engine-LAUEWYSQ-DQCEI5HE.js → engine-UYJENSWK-VSCGKSQV.js} +1 -1
- package/dist/safe-bash/command-chunks/{gnumeric-UJPXWBVR-YPXTNEDZ.js → gnumeric-UJPXWBVR-7VOHQAPM.js} +2 -2
- package/dist/safe-bash/command-chunks/{model-store-E7BHBFJC.js → model-store-UB5DWMAP.js} +24 -24
- package/dist/safe-bash/command-chunks/paradox-4FCZE53D-LQPGVMEL.js +365 -0
- package/dist/safe-bash/commands/pandoc/index.browser.js +1 -1
- package/dist/safe-bash/full-core.browser.js +2 -2
- package/dist/safe-bash/plugins/index.browser.js +2 -2
- package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
- package/dist/safe-bash-command-awk/awk.js +4 -4
- package/dist/safe-bash-command-awk/index.js +4 -4
- package/dist/safe-bash-command-diff/diff.js +2 -2
- package/dist/safe-bash-command-diff/index.js +3 -3
- package/dist/safe-bash-command-diff/sync.js +2 -2
- package/dist/safe-bash-command-du/du.js +2 -2
- package/dist/safe-bash-command-du/index.js +2 -2
- package/dist/safe-bash-command-ffmpeg/index.js +1 -1
- package/dist/safe-bash-command-ffprobe/index.js +2 -2
- package/dist/safe-bash-command-ffprobe/media.d.ts +3 -1
- package/dist/safe-bash-command-ffprobe/media.js +2 -2
- package/dist/safe-bash-command-html-to-markdown/budget.js +2 -1
- package/dist/safe-bash-command-html-to-markdown/entities.js +4 -3
- package/dist/safe-bash-command-html-to-markdown/index.js +533 -310
- package/dist/safe-bash-command-html-to-markdown/input.js +6 -5
- package/dist/safe-bash-command-html-to-markdown/options.js +2 -1
- package/dist/safe-bash-command-html-to-markdown/parser.js +5 -4
- package/dist/safe-bash-command-html-to-markdown/render.js +6 -5
- package/dist/safe-bash-command-html-to-markdown/stored-text.d.ts +50 -0
- package/dist/safe-bash-command-html-to-markdown/stored-text.js +12 -0
- package/dist/safe-bash-command-html-to-markdown/text.js +3 -2
- package/dist/safe-bash-command-htmlq/contracts.d.ts +5 -0
- package/dist/safe-bash-command-htmlq/index.js +2006 -259
- package/dist/safe-bash-command-htmlq/selectors.d.ts +38 -1
- package/dist/safe-bash-command-htmlq/serializer.d.ts +1 -0
- package/dist/safe-bash-command-htmlq/tree.d.ts +4 -2
- package/dist/safe-bash-command-iconv/command.js +2 -2
- package/dist/safe-bash-command-iconv/index.js +2 -2
- package/dist/safe-bash-command-llm/command.js +3 -3
- package/dist/safe-bash-command-llm/index.js +9 -9
- package/dist/safe-bash-command-llm/openai.js +2 -2
- package/dist/safe-bash-command-llm/providers/index.js +2 -2
- package/dist/safe-bash-command-llm/providers/openai.js +2 -2
- package/dist/safe-bash-command-node/commands/node/browser.js +2 -2
- package/dist/safe-bash-command-node/commands/node/default-runtime.js +2 -2
- package/dist/safe-bash-command-node/commands/node/safejs.js +2 -2
- package/dist/safe-bash-command-pandoc/command.js +7 -7
- package/dist/safe-bash-command-pandoc/index.js +46 -46
- package/dist/safe-bash-command-patch/index.js +6 -6
- package/dist/safe-bash-command-patch/patch-envelope.js +53 -3
- package/dist/safe-bash-command-patch/patch-formats.d.ts +7 -2
- package/dist/safe-bash-command-patch/patch-formats.js +6 -4
- package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +7 -7
- package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +3 -2
- package/dist/safe-bash-command-patch/patch-gnu-reject.js +4 -3
- package/dist/safe-bash-command-patch/patch-publication.js +2 -1
- package/dist/safe-bash-command-patch/patch.js +6 -6
- package/dist/safe-bash-command-patch/stored-patch.d.ts +26 -0
- package/dist/safe-bash-command-patch/stored-target.d.ts +40 -0
- package/dist/safe-bash-command-patch/unified.d.ts +23 -10
- package/dist/safe-bash-command-patch/unified.js +3 -1
- package/dist/safe-bash-command-pdftk/index.d.ts +6 -2
- package/dist/safe-bash-command-pdftk/index.js +1247 -373
- package/dist/safe-bash-command-playwright-cli/index.js +26 -26
- package/dist/safe-bash-command-playwright-cli/playwright/abilities.js +10 -10
- package/dist/safe-bash-command-playwright-cli/playwright/controller.js +14 -14
- package/dist/safe-bash-command-playwright-cli/playwright/index.js +23 -23
- package/dist/safe-bash-command-playwright-cli/playwright/snapshot.js +2 -2
- package/dist/safe-bash-command-playwright-cli/playwright/standard-capabilities.js +6 -6
- package/dist/safe-bash-command-playwright-cli/playwright/storage-capabilities.js +4 -4
- package/dist/safe-bash-command-pptx/command-engine.d.ts +5 -1
- package/dist/safe-bash-command-pptx/engine.js +1 -1
- package/dist/safe-bash-command-pptx/index.d.ts +1 -1
- package/dist/safe-bash-command-pptx/index.js +172 -19
- package/dist/safe-bash-command-pptx/streaming-inputs.d.ts +7 -2
- package/dist/safe-bash-command-python/executor.js +5 -5
- package/dist/safe-bash-command-python/index.js +5 -5
- package/dist/safe-bash-command-python/jspi.js +2 -2
- package/dist/safe-bash-command-soffice/index.js +1 -1
- package/dist/safe-bash-command-sort/index.js +3 -3
- package/dist/safe-bash-command-ssconvert/index.js +2 -2
- package/dist/safe-bash-command-tar/create.js +2 -2
- package/dist/safe-bash-command-tar/extract.js +2 -2
- package/dist/safe-bash-command-tar/index.js +8 -8
- package/dist/safe-bash-command-tar/modes.js +4 -4
- package/dist/safe-bash-command-timeout/index.js +3 -3
- package/dist/safe-bash-command-tree/index.js +2 -2
- package/dist/safe-bash-command-tree/tree.js +2 -2
- package/dist/safe-bash-command-xmllint/index.js +22 -31
- package/dist/safe-bash-command-xz/index.js +5 -5
- package/dist/safe-bash-compression-engine/files.js +2 -2
- package/dist/safe-bash-compression-engine/operand.js +4 -4
- package/dist/safe-bash-contracts/diagnostics.js +3 -3
- package/dist/safe-bash-contracts/escaping.js +10 -10
- package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
- package/dist/safe-bash-contracts/filesystem-output.js +6 -6
- package/dist/safe-bash-contracts/index.js +33 -33
- package/dist/safe-bash-contracts/io.js +2 -2
- package/dist/safe-bash-contracts/output.js +3 -3
- package/dist/safe-bash-docx-engine/ancillary-resources.js +5 -5
- package/dist/safe-bash-docx-engine/batch-operations.js +63 -63
- package/dist/safe-bash-docx-engine/batch-result-schema.js +74 -74
- package/dist/safe-bash-docx-engine/batch.js +74 -74
- package/dist/safe-bash-docx-engine/bookmarks.js +13 -13
- package/dist/safe-bash-docx-engine/charts.js +6 -6
- package/dist/safe-bash-docx-engine/command-option-rules.js +3 -3
- package/dist/safe-bash-docx-engine/comments.js +21 -21
- package/dist/safe-bash-docx-engine/control-bindings.js +16 -16
- package/dist/safe-bash-docx-engine/control-repeat.js +16 -16
- package/dist/safe-bash-docx-engine/controls.js +14 -14
- package/dist/safe-bash-docx-engine/create.js +8 -8
- package/dist/safe-bash-docx-engine/diagrams.js +6 -6
- package/dist/safe-bash-docx-engine/diff.js +8 -8
- package/dist/safe-bash-docx-engine/document-properties.js +12 -12
- package/dist/safe-bash-docx-engine/equations.js +12 -12
- package/dist/safe-bash-docx-engine/extract.js +9 -9
- package/dist/safe-bash-docx-engine/fields.js +18 -18
- package/dist/safe-bash-docx-engine/font-inventory.js +13 -13
- package/dist/safe-bash-docx-engine/font-resources.js +3 -3
- package/dist/safe-bash-docx-engine/image-batch-operations.js +11 -11
- package/dist/safe-bash-docx-engine/image-insertion.js +17 -17
- package/dist/safe-bash-docx-engine/image-layout.js +14 -14
- package/dist/safe-bash-docx-engine/image-replacement.js +19 -19
- package/dist/safe-bash-docx-engine/images.js +14 -14
- package/dist/safe-bash-docx-engine/index.js +102 -102
- package/dist/safe-bash-docx-engine/inspection.js +15 -15
- package/dist/safe-bash-docx-engine/invocation.js +4 -4
- package/dist/safe-bash-docx-engine/io.js +6 -6
- package/dist/safe-bash-docx-engine/links.js +17 -17
- package/dist/safe-bash-docx-engine/lists.js +16 -16
- package/dist/safe-bash-docx-engine/locations.js +10 -10
- package/dist/safe-bash-docx-engine/notes.js +18 -18
- package/dist/safe-bash-docx-engine/objects.js +14 -14
- package/dist/safe-bash-docx-engine/pack.js +9 -9
- package/dist/safe-bash-docx-engine/package-view-batch-operations.js +19 -19
- package/dist/safe-bash-docx-engine/pandoc-adapter.js +25 -25
- package/dist/safe-bash-docx-engine/paragraph-edit.js +21 -21
- package/dist/safe-bash-docx-engine/publication.js +6 -6
- package/dist/safe-bash-docx-engine/removal.js +16 -16
- package/dist/safe-bash-docx-engine/revision-decisions.js +16 -16
- package/dist/safe-bash-docx-engine/revision-edit.js +15 -15
- package/dist/safe-bash-docx-engine/revisions.js +12 -12
- package/dist/safe-bash-docx-engine/run-format.js +15 -15
- package/dist/safe-bash-docx-engine/sanitize.js +29 -29
- package/dist/safe-bash-docx-engine/sections.js +15 -15
- package/dist/safe-bash-docx-engine/settings.js +6 -6
- package/dist/safe-bash-docx-engine/shape-edit.js +16 -16
- package/dist/safe-bash-docx-engine/signatures.js +11 -11
- package/dist/safe-bash-docx-engine/stories.js +18 -18
- package/dist/safe-bash-docx-engine/structure-model-batch-operations.js +34 -34
- package/dist/safe-bash-docx-engine/style-model-batch-operations.js +24 -24
- package/dist/safe-bash-docx-engine/style-model-result-schema.js +39 -39
- package/dist/safe-bash-docx-engine/styles.js +14 -14
- package/dist/safe-bash-docx-engine/table-edit.js +23 -23
- package/dist/safe-bash-docx-engine/table-read.js +11 -11
- package/dist/safe-bash-docx-engine/template.js +17 -17
- package/dist/safe-bash-docx-engine/text-replace.js +15 -15
- package/dist/safe-bash-docx-engine/text-resource-read.js +11 -11
- package/dist/safe-bash-docx-engine/text.js +11 -11
- package/dist/safe-bash-docx-engine/validation.js +4 -4
- package/dist/safe-bash-docx-engine/xml-parts.js +17 -17
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +4 -4
- package/dist/safe-bash-line-ending-engine/command.js +3 -3
- package/dist/safe-bash-line-ending-engine/convert.js +2 -2
- package/dist/safe-bash-line-ending-engine/index.js +6 -6
- package/dist/safe-bash-line-ending-engine/info.js +2 -2
- package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
- package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
- package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
- package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
- package/dist/safe-bash-markdown-engine/index.js +5 -5
- package/dist/safe-bash-network-engine/transfer.js +3 -3
- package/dist/safe-bash-presentation-engine/accessibility.js +31 -30
- package/dist/safe-bash-presentation-engine/animation-editing.js +16 -15
- package/dist/safe-bash-presentation-engine/animations.js +16 -15
- package/dist/safe-bash-presentation-engine/backgrounds.js +17 -16
- package/dist/safe-bash-presentation-engine/bytes.js +3 -3
- package/dist/safe-bash-presentation-engine/chart-editing.js +34 -33
- package/dist/safe-bash-presentation-engine/chart-object-operations.js +25 -24
- package/dist/safe-bash-presentation-engine/charts.js +31 -30
- package/dist/safe-bash-presentation-engine/command-placeholder.js +59 -56
- package/dist/safe-bash-presentation-engine/comments.js +17 -16
- package/dist/safe-bash-presentation-engine/connector-operations.js +32 -31
- package/dist/safe-bash-presentation-engine/connectors.js +29 -28
- package/dist/safe-bash-presentation-engine/content-types.js +4 -4
- package/dist/safe-bash-presentation-engine/creation.js +6 -6
- package/dist/safe-bash-presentation-engine/diff.js +32 -31
- package/dist/safe-bash-presentation-engine/drawing-enums.d.ts +10 -10
- package/dist/safe-bash-presentation-engine/drawing-format.js +20 -19
- package/dist/safe-bash-presentation-engine/drawing-operations.js +31 -30
- package/dist/safe-bash-presentation-engine/drawing-schema.js +21 -20
- package/dist/safe-bash-presentation-engine/equations.js +17 -16
- package/dist/safe-bash-presentation-engine/errors.js +2 -2
- package/dist/safe-bash-presentation-engine/fields.js +17 -16
- package/dist/safe-bash-presentation-engine/font-metrics.js +3 -3
- package/dist/safe-bash-presentation-engine/image-extraction.js +20 -19
- package/dist/safe-bash-presentation-engine/image-formatting.js +32 -31
- package/dist/safe-bash-presentation-engine/image-insertion.js +18 -17
- package/dist/safe-bash-presentation-engine/image-replacement.js +21 -20
- package/dist/safe-bash-presentation-engine/image-value.js +4 -4
- package/dist/safe-bash-presentation-engine/images.js +19 -18
- package/dist/safe-bash-presentation-engine/index.d.ts +5 -1
- package/dist/safe-bash-presentation-engine/index.js +121 -108
- package/dist/safe-bash-presentation-engine/layouts.js +16 -15
- package/dist/safe-bash-presentation-engine/length.js +3 -3
- package/dist/safe-bash-presentation-engine/links.js +16 -15
- package/dist/safe-bash-presentation-engine/masters.js +15 -14
- package/dist/safe-bash-presentation-engine/media-editing.js +24 -23
- package/dist/safe-bash-presentation-engine/media-extraction.js +17 -16
- package/dist/safe-bash-presentation-engine/media.js +16 -15
- package/dist/safe-bash-presentation-engine/memberships.js +15 -14
- package/dist/safe-bash-presentation-engine/notes.js +16 -15
- package/dist/safe-bash-presentation-engine/ole-enum.js +4 -4
- package/dist/safe-bash-presentation-engine/ole-insertion.js +20 -19
- package/dist/safe-bash-presentation-engine/opaque-objects.js +9 -9
- package/dist/safe-bash-presentation-engine/package-reader.js +5 -5
- package/dist/safe-bash-presentation-engine/package-tools.d.ts +3 -0
- package/dist/safe-bash-presentation-engine/package-tools.js +27 -17
- package/dist/safe-bash-presentation-engine/package-uri.js +3 -3
- package/dist/safe-bash-presentation-engine/package-writer.js +4 -4
- package/dist/safe-bash-presentation-engine/presentation-model.js +58 -55
- package/dist/safe-bash-presentation-engine/presentation-settings.js +14 -13
- package/dist/safe-bash-presentation-engine/properties.js +16 -15
- package/dist/safe-bash-presentation-engine/relationships.js +4 -4
- package/dist/safe-bash-presentation-engine/resource-limits.js +1 -1
- package/dist/safe-bash-presentation-engine/retained-archive-staging.d.ts +19 -0
- package/dist/safe-bash-presentation-engine/retained-extraction-output.d.ts +18 -0
- package/dist/safe-bash-presentation-engine/retained-frame-formatting.d.ts +14 -0
- package/dist/safe-bash-presentation-engine/retained-inspection.js +14 -12
- package/dist/safe-bash-presentation-engine/retained-package-extraction.d.ts +22 -0
- package/dist/safe-bash-presentation-engine/retained-package-packing.d.ts +19 -0
- package/dist/safe-bash-presentation-engine/retained-package.d.ts +2 -0
- package/dist/safe-bash-presentation-engine/retained-package.js +6 -4
- package/dist/safe-bash-presentation-engine/retained-text.d.ts +9 -2
- package/dist/safe-bash-presentation-engine/retained-text.js +131 -30
- package/dist/safe-bash-presentation-engine/retained-xml-document.d.ts +1 -0
- package/dist/safe-bash-presentation-engine/retained-xml-parts.d.ts +5 -1
- package/dist/safe-bash-presentation-engine/retained-xml-publication.d.ts +18 -0
- package/dist/safe-bash-presentation-engine/retained-xml-replacement.d.ts +13 -0
- package/dist/safe-bash-presentation-engine/sanitize.js +17 -16
- package/dist/safe-bash-presentation-engine/selectors.js +10 -10
- package/dist/safe-bash-presentation-engine/shape-groups.js +31 -30
- package/dist/safe-bash-presentation-engine/shape-operations.js +30 -29
- package/dist/safe-bash-presentation-engine/shape-path-operations.js +32 -31
- package/dist/safe-bash-presentation-engine/shape-paths.js +16 -15
- package/dist/safe-bash-presentation-engine/shape-presets.js +3 -3
- package/dist/safe-bash-presentation-engine/shape-selection.js +31 -30
- package/dist/safe-bash-presentation-engine/shape-transforms.js +18 -17
- package/dist/safe-bash-presentation-engine/shapes.d.ts +1 -1
- package/dist/safe-bash-presentation-engine/shapes.js +27 -26
- package/dist/safe-bash-presentation-engine/slide-copy.js +17 -16
- package/dist/safe-bash-presentation-engine/slide-import.js +18 -17
- package/dist/safe-bash-presentation-engine/slide-merge-split.js +20 -19
- package/dist/safe-bash-presentation-engine/slide-model.js +43 -42
- package/dist/safe-bash-presentation-engine/slide-removal.js +18 -17
- package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +9 -9
- package/dist/safe-bash-presentation-engine/slides.js +19 -16
- package/dist/safe-bash-presentation-engine/table-operations.js +33 -32
- package/dist/safe-bash-presentation-engine/table-spans.js +32 -31
- package/dist/safe-bash-presentation-engine/tables.js +31 -30
- package/dist/safe-bash-presentation-engine/tags.js +16 -15
- package/dist/safe-bash-presentation-engine/template-bindings.js +33 -32
- package/dist/safe-bash-presentation-engine/template-repeat.js +40 -39
- package/dist/safe-bash-presentation-engine/text-fitting.js +27 -26
- package/dist/safe-bash-presentation-engine/text-frames.d.ts +13 -0
- package/dist/safe-bash-presentation-engine/text-frames.js +29 -26
- package/dist/safe-bash-presentation-engine/text-paragraphs.js +27 -26
- package/dist/safe-bash-presentation-engine/text-reading.js +11 -11
- package/dist/safe-bash-presentation-engine/text-replacement.js +17 -16
- package/dist/safe-bash-presentation-engine/text-runs.js +20 -19
- package/dist/safe-bash-presentation-engine/themes.js +16 -15
- package/dist/safe-bash-presentation-engine/transitions.js +16 -15
- package/dist/safe-bash-presentation-engine/validation.js +10 -9
- package/dist/safe-bash-presentation-engine/xml-parts.d.ts +2 -0
- package/dist/safe-bash-presentation-engine/xml-parts.js +23 -15
- package/dist/safe-bash-presentation-engine/xml-view.js +3 -3
- package/dist/safe-bash-presentation-engine/xml.js +3 -3
- package/dist/safe-bash-query-engine/index.js +4 -4
- package/dist/safe-bash-query-engine/interpreter.js +2 -2
- package/dist/safe-bash-query-engine/query-core.js +4 -4
- package/dist/safe-bash-regex-engine/index.js +1 -1
- package/dist/safe-bash-regex-engine/python-glob.js +1 -1
- package/dist/safe-bash-regex-engine/text/regex.d.ts +19 -0
- package/dist/safe-bash-regex-engine/text/regex.js +1 -1
- package/dist/safe-bash-xml-engine/document.js +3 -3
- package/dist/safe-bash-xml-engine/evaluate.js +1 -1
- package/dist/safe-bash-xml-engine/index.d.ts +1 -0
- package/dist/safe-bash-xml-engine/index.js +9 -5
- package/dist/safe-bash-xml-engine/query.js +2 -2
- package/dist/safe-bash-xml-engine/recovery.d.ts +10 -0
- package/dist/safe-bash-xml-engine/stored-document.d.ts +3 -3
- package/dist/safe-bash-xml-engine/stored-document.js +1 -1
- package/dist/safe-bash-xml-engine/stored-evaluate.js +1 -1
- package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
- package/dist/safe-bash-zip-engine/zip/volumes.js +3 -3
- package/dist/spreadsheet-engine/datasource.js +16 -2
- package/dist/spreadsheet-engine/formulas/diagnostics.d.ts +2 -1
- package/dist/spreadsheet-engine/formulas/diagnostics.js +2 -2
- package/dist/spreadsheet-engine/formulas/evaluator.d.ts +1 -1
- package/dist/spreadsheet-engine/formulas/evaluator.js +2 -1
- package/dist/spreadsheet-engine/formulas/functions/python-printf.js +56 -33
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +1 -1
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +54 -24
- package/dist/spreadsheet-format-xls/biff-properties-merge.d.ts +6 -2
- package/dist/spreadsheet-format-xls/biff-properties-merge.js +413 -296
- package/dist/spreadsheet-format-xls/biff-properties-write.js +40 -23
- package/dist/spreadsheet-format-xls/biff-properties.js +95 -175
- package/dist/spreadsheet-format-xls/biff-property-dictionary.d.ts +5 -0
- package/dist/spreadsheet-format-xls/biff-property-dictionary.js +75 -0
- package/dist/spreadsheet-format-xls/biff-property-index.d.ts +23 -0
- package/dist/spreadsheet-format-xls/biff-property-index.js +93 -0
- package/dist/spreadsheet-format-xls/biff-property-name.d.ts +4 -0
- package/dist/spreadsheet-format-xls/biff-property-name.js +114 -0
- package/dist/spreadsheet-format-xls/biff-property-range.d.ts +17 -3
- package/dist/spreadsheet-format-xls/biff-property-range.js +178 -37
- package/dist/spreadsheet-format-xls/biff-property-text.d.ts +6 -0
- package/dist/spreadsheet-format-xls/biff-property-text.js +68 -0
- package/dist/spreadsheet-format-xls/biff-property-transcode.d.ts +5 -0
- package/dist/spreadsheet-format-xls/biff-property-transcode.js +45 -0
- package/package.json +8 -3
- package/dist/safe-bash/command-chunks/biff-YKPDH35C-MVQIWNKV.js +0 -4974
- package/dist/safe-bash/command-chunks/chunk-2VLAXKTS.js +0 -245
- package/dist/safe-bash/command-chunks/chunk-5Q22ZLNC.js +0 -127
- package/dist/safe-bash/command-chunks/chunk-JKLOBSMP.js +0 -56
- package/dist/safe-bash/command-chunks/chunk-JYTESTBS.js +0 -99
- package/dist/safe-bash/command-chunks/chunk-ZEGNRZV2.js +0 -333
- package/dist/safe-bash/command-chunks/paradox-ZWWXYY4J-JYOSWSBL.js +0 -362
- package/dist/spreadsheet-format-xls/biff-properties-layout.js +0 -56
- package/dist/safe-bash/command-chunks/{chunk-X2HVVMTW.js → chunk-AW4Q3GZW.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-JC2EV66U.js → chunk-BJXADHRT.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-XI2LETBJ.js → chunk-BXU5Y7I5.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-PVLPWVRH.js → chunk-D3HW7R2N.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-OLK3DCJD.js → chunk-DYERIXPU.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-WYBCSJFG.js → chunk-FWCUEZ3K.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-FF2SQ2GP.js → chunk-GGH376XQ.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-D66Q7QJ3.js → chunk-JRSZ5IGD.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-Z3YB4EVE.js → chunk-KSM5CCHT.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-NJ4NTTCR.js → chunk-LNLACEAN.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-NBTG6NF6.js → chunk-LTJRUMK6.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-XCYTG7CR.js → chunk-NJGL5JQ6.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-SZ66JC25.js → chunk-Q7J2NTH2.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-MDV7W5AS.js → chunk-SKNI2XQA.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-7ZWACKCG.js → chunk-T6OXG7QQ.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-ECDEPKKW.js → chunk-W25EIKDJ.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-4YSBUQPV.js → chunk-W2FKFEVY.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-2CIDPOUV.js → chunk-WSNHJZQ5.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-4H3TYOVC.js → chunk-Y7AXMCFV.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-U6IEK2CI.js → chunk-YPG55QTP.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-252L5YC5.js → chunk-Z37OM247.js} +6 -6
- package/dist/safe-bash/command-chunks/{pln-DFS7VLVS-JATX6FS7.js → pln-DFS7VLVS-OVOBS4QX.js} +3 -3
- package/dist/safe-bash/command-chunks/{psion-YBI6JEQI-6OMC2PGC.js → psion-YBI6JEQI-GY4S6ZLC.js} +3 -3
|
@@ -26,6 +26,13 @@ var HtmlError = class extends Error {
|
|
|
26
26
|
offset;
|
|
27
27
|
resource;
|
|
28
28
|
};
|
|
29
|
+
var HtmlCancellationError = class extends HtmlError {
|
|
30
|
+
constructor(signal) {
|
|
31
|
+
super("E_CANCELLED", "HTML invocation cancelled");
|
|
32
|
+
this.signal = signal;
|
|
33
|
+
}
|
|
34
|
+
signal;
|
|
35
|
+
};
|
|
29
36
|
var htmlqBaseline = Object.freeze({
|
|
30
37
|
commit: "bfcb1d1d11a80fdd92c0dace1e7e559fbdb225cb",
|
|
31
38
|
version: "0.5.0",
|
|
@@ -80,7 +87,7 @@ var HtmlBudget = class {
|
|
|
80
87
|
ledger;
|
|
81
88
|
check() {
|
|
82
89
|
if (this.options.signal.aborted)
|
|
83
|
-
throw new
|
|
90
|
+
throw new HtmlCancellationError(this.options.signal);
|
|
84
91
|
}
|
|
85
92
|
bound(resource, amount) {
|
|
86
93
|
this.check();
|
|
@@ -108,6 +115,9 @@ var HtmlBudget = class {
|
|
|
108
115
|
}
|
|
109
116
|
};
|
|
110
117
|
|
|
118
|
+
// packages/safe-bash-command-htmlq/src/tree.ts
|
|
119
|
+
import { yieldTurn } from "../safe-bash-contracts/yield.js";
|
|
120
|
+
|
|
111
121
|
// packages/safe-bash-command-htmlq/src/entities.ts
|
|
112
122
|
var entities_exports = {};
|
|
113
123
|
__reExport(entities_exports, entities_star);
|
|
@@ -392,179 +402,187 @@ var HtmlTokenizer = class {
|
|
|
392
402
|
}
|
|
393
403
|
};
|
|
394
404
|
|
|
395
|
-
// packages/safe-bash-command-htmlq/src/
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
var kNode = /* @__PURE__ */ Symbol("node");
|
|
401
|
-
var kOwner = /* @__PURE__ */ Symbol("owner");
|
|
402
|
-
var owners = {
|
|
403
|
-
get(node) {
|
|
404
|
-
return node[kOwner] ?? node._owner;
|
|
405
|
-
},
|
|
406
|
-
set(node, owner) {
|
|
407
|
-
node._owner = owner;
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
var internals = {
|
|
411
|
-
has(node) {
|
|
412
|
-
return Boolean(node[kNode]);
|
|
413
|
-
},
|
|
414
|
-
get(node) {
|
|
415
|
-
return node[kNode];
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
function getInternalHtmlNode(node) {
|
|
419
|
-
if (!node || typeof node !== "object") throw new HtmlError("E_OWNERSHIP", "Unowned HTML node");
|
|
420
|
-
return internals.get(node);
|
|
421
|
-
}
|
|
422
|
-
function getPublicHtmlView(node) {
|
|
423
|
-
let view = node._view;
|
|
424
|
-
if (!view) {
|
|
425
|
-
const v = Object.create(publicViewProto);
|
|
426
|
-
v[kNode] = node;
|
|
427
|
-
v[kOwner] = node._owner;
|
|
428
|
-
Object.freeze(v);
|
|
429
|
-
view = v;
|
|
430
|
-
node._view = view;
|
|
431
|
-
}
|
|
432
|
-
return view;
|
|
433
|
-
}
|
|
434
|
-
var views = {
|
|
435
|
-
get(node) {
|
|
436
|
-
return getPublicHtmlView(node);
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
var childViews = {
|
|
440
|
-
get(node) {
|
|
441
|
-
return node._childViews;
|
|
442
|
-
},
|
|
443
|
-
set(node, cv) {
|
|
444
|
-
node._childViews = cv;
|
|
405
|
+
// packages/safe-bash-command-htmlq/src/streaming-tokenizer.ts
|
|
406
|
+
var StreamingHtmlTokenizer = class {
|
|
407
|
+
constructor(source, budget) {
|
|
408
|
+
this.budget = budget;
|
|
409
|
+
this.input = source[Symbol.asyncIterator]();
|
|
445
410
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
Object.defineProperty(publicViewProto, "attributes", {
|
|
457
|
-
enumerable: true,
|
|
458
|
-
get() {
|
|
459
|
-
const n = this[kNode];
|
|
460
|
-
if (!n._attrsFrozen) {
|
|
461
|
-
for (const attribute2 of n.attributes) Object.freeze(attribute2);
|
|
462
|
-
Object.freeze(n.attributes);
|
|
463
|
-
n._attrsFrozen = true;
|
|
411
|
+
budget;
|
|
412
|
+
buffer = "";
|
|
413
|
+
ended = false;
|
|
414
|
+
input;
|
|
415
|
+
async peek(length = 1) {
|
|
416
|
+
while (!this.ended && this.buffer.length < length) {
|
|
417
|
+
const next = await this.input.next();
|
|
418
|
+
this.budget.check();
|
|
419
|
+
if (next.done) this.ended = true;
|
|
420
|
+
else this.buffer += next.value;
|
|
464
421
|
}
|
|
465
|
-
return
|
|
422
|
+
return this.buffer.slice(0, length);
|
|
466
423
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
enumerable: true,
|
|
470
|
-
get() {
|
|
471
|
-
const n = this[kNode];
|
|
472
|
-
let cv = n._childViews;
|
|
473
|
-
if (!cv) {
|
|
474
|
-
cv = Object.freeze(n.children.map((child) => getPublicHtmlView(child)));
|
|
475
|
-
n._childViews = cv;
|
|
476
|
-
}
|
|
477
|
-
return cv;
|
|
424
|
+
async close() {
|
|
425
|
+
if (!this.ended) await this.input.return?.();
|
|
478
426
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
427
|
+
async next(raw, foreign = false) {
|
|
428
|
+
if (!await this.peek()) return void 0;
|
|
429
|
+
let frame = "";
|
|
430
|
+
const take = async (length = 1) => {
|
|
431
|
+
const value = await this.peek(length);
|
|
432
|
+
this.budget.bound("tokenBytes", (frame.length + value.length) * 2);
|
|
433
|
+
frame += value;
|
|
434
|
+
this.buffer = this.buffer.slice(value.length);
|
|
435
|
+
};
|
|
436
|
+
const until = async (delimiter2) => {
|
|
437
|
+
while (await this.peek()) {
|
|
438
|
+
if (await this.peek(delimiter2.length) === delimiter2) {
|
|
439
|
+
await take(delimiter2.length);
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
await take();
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
if (raw) {
|
|
446
|
+
let scriptState = "data";
|
|
447
|
+
while (await this.peek()) {
|
|
448
|
+
let end = raw === "plaintext" ? this.buffer.length : this.buffer.indexOf("<");
|
|
449
|
+
if (end < 0) end = this.buffer.length;
|
|
450
|
+
if (raw === "script" && scriptState !== "data") {
|
|
451
|
+
const dash = this.buffer.indexOf("-");
|
|
452
|
+
if (dash >= 0) end = Math.min(end, dash);
|
|
453
|
+
}
|
|
454
|
+
if (end > 0) {
|
|
455
|
+
await take(end);
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
if (raw !== "plaintext") {
|
|
459
|
+
if (raw === "script") {
|
|
460
|
+
if (scriptState === "data" && await this.peek(4) === "<!--") {
|
|
461
|
+
scriptState = "escaped";
|
|
462
|
+
await take(4);
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
if (scriptState !== "data" && await this.peek(3) === "-->") {
|
|
466
|
+
scriptState = "data";
|
|
467
|
+
await take(3);
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
const opening = (0, entities_exports.asciiLower)(await this.peek(8));
|
|
471
|
+
if (scriptState === "escaped" && opening.startsWith("<script") && delimiter(opening[7])) {
|
|
472
|
+
scriptState = "double";
|
|
473
|
+
await take(7);
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
const closing = (0, entities_exports.asciiLower)(await this.peek(9));
|
|
477
|
+
if (scriptState === "double" && closing.startsWith("<\/script") && delimiter(closing[8])) {
|
|
478
|
+
scriptState = "escaped";
|
|
479
|
+
await take(8);
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (scriptState !== "double" && await this.peek(2) === "</") {
|
|
484
|
+
const closing = (0, entities_exports.asciiLower)(await this.peek(raw.length + 3));
|
|
485
|
+
if (closing.slice(2, 2 + raw.length) === raw && delimiter(closing[2 + raw.length])) break;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
await take();
|
|
489
|
+
}
|
|
490
|
+
if (frame) return new HtmlTokenizer(frame, this.budget).next(raw, foreign);
|
|
486
491
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
492
|
+
if (await this.peek() !== "<") {
|
|
493
|
+
while (await this.peek() && this.buffer[0] !== "<") {
|
|
494
|
+
const end = this.buffer.indexOf("<");
|
|
495
|
+
await take(end < 0 ? this.buffer.length : end);
|
|
496
|
+
}
|
|
497
|
+
} else if (foreign && await this.peek(9) === "<![CDATA[") {
|
|
498
|
+
await take(9);
|
|
499
|
+
await until("]]>");
|
|
500
|
+
} else if (await this.peek(4) === "<!--") {
|
|
501
|
+
await take(4);
|
|
502
|
+
let state = "start";
|
|
503
|
+
while (await this.peek()) {
|
|
504
|
+
const c = await this.peek();
|
|
505
|
+
await take();
|
|
506
|
+
if (state === "start" || state === "startDash") {
|
|
507
|
+
if (c === ">") break;
|
|
508
|
+
state = c === "-" ? state === "start" ? "startDash" : "end" : "data";
|
|
509
|
+
} else if (state === "data") {
|
|
510
|
+
if (c === "-") state = "dash";
|
|
511
|
+
} else if (state === "dash") state = c === "-" ? "end" : "data";
|
|
512
|
+
else if (state === "end") {
|
|
513
|
+
if (c === ">") break;
|
|
514
|
+
if (c !== "-") state = c === "!" ? "bang" : "data";
|
|
515
|
+
} else {
|
|
516
|
+
if (c === ">") break;
|
|
517
|
+
state = c === "-" ? "dash" : "data";
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
} else if ((0, entities_exports.asciiLower)(await this.peek(9)) === "<!doctype") {
|
|
521
|
+
await take(9);
|
|
522
|
+
await until(">");
|
|
523
|
+
} else {
|
|
524
|
+
await take();
|
|
525
|
+
const closing = await this.peek() === "/";
|
|
526
|
+
if (closing) await take();
|
|
527
|
+
const first = await this.peek();
|
|
528
|
+
if (!asciiLetter(first)) {
|
|
529
|
+
if (closing || first === "!" || first === "?") await until(">");
|
|
530
|
+
} else {
|
|
531
|
+
while (await this.peek() && !delimiter(await this.peek())) await take();
|
|
532
|
+
let state = "before";
|
|
533
|
+
let quote = "";
|
|
534
|
+
while (await this.peek()) {
|
|
535
|
+
const c = await this.peek();
|
|
536
|
+
if (state === "quoted") {
|
|
537
|
+
await take();
|
|
538
|
+
if (c === quote) state = "before";
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
if (c === ">") {
|
|
542
|
+
await take();
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
if (state === "before") {
|
|
546
|
+
await take();
|
|
547
|
+
if (!(0, entities_exports.htmlSpace)(c) && c !== "/") state = "name";
|
|
548
|
+
} else if (state === "name") {
|
|
549
|
+
if (c === "=") {
|
|
550
|
+
await take();
|
|
551
|
+
state = "value";
|
|
552
|
+
} else if ((0, entities_exports.htmlSpace)(c) || c === "/") state = "after";
|
|
553
|
+
else await take();
|
|
554
|
+
} else if (state === "after") {
|
|
555
|
+
if ((0, entities_exports.htmlSpace)(c)) await take();
|
|
556
|
+
else if (c === "=") {
|
|
557
|
+
await take();
|
|
558
|
+
state = "value";
|
|
559
|
+
} else state = "before";
|
|
560
|
+
} else if (state === "value") {
|
|
561
|
+
await take();
|
|
562
|
+
if (!(0, entities_exports.htmlSpace)(c)) {
|
|
563
|
+
if (c === '"' || c === "'") {
|
|
564
|
+
quote = c;
|
|
565
|
+
state = "quoted";
|
|
566
|
+
} else state = "unquoted";
|
|
567
|
+
}
|
|
568
|
+
} else {
|
|
569
|
+
await take();
|
|
570
|
+
if ((0, entities_exports.htmlSpace)(c)) state = "before";
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return new HtmlTokenizer(frame, this.budget).next(void 0, foreign);
|
|
501
576
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
return internals.has(node);
|
|
506
|
-
}
|
|
507
|
-
function originalSource(node) {
|
|
508
|
-
const owner = owners.get(node);
|
|
509
|
-
if (!owner) throw new HtmlError("E_OWNERSHIP", "Node is not owned by this HTML engine");
|
|
510
|
-
if (node.kind !== "document")
|
|
511
|
-
throw new HtmlError(
|
|
512
|
-
"E_UNSUPPORTED",
|
|
513
|
-
"Original serialization is defined only for a complete document"
|
|
514
|
-
);
|
|
515
|
-
if (owner.mutated)
|
|
516
|
-
throw new HtmlError("E_MUTATED", "Original source does not represent the mutated tree");
|
|
517
|
-
return owner.source;
|
|
518
|
-
}
|
|
519
|
-
function unlink(node) {
|
|
520
|
-
const parent = node.parent;
|
|
521
|
-
if (!parent) return;
|
|
522
|
-
const index = parent.children.indexOf(node);
|
|
523
|
-
if (index < 0) throw new HtmlError("E_OWNERSHIP", "Inconsistent parent link");
|
|
524
|
-
if (node.previousSibling) node.previousSibling.nextSibling = node.nextSibling;
|
|
525
|
-
if (node.nextSibling) node.nextSibling.previousSibling = node.previousSibling;
|
|
526
|
-
parent.children.splice(index, 1);
|
|
527
|
-
node.parent = null;
|
|
528
|
-
node.previousSibling = null;
|
|
529
|
-
node.nextSibling = null;
|
|
530
|
-
}
|
|
531
|
-
function detachHtmlNode(node, options) {
|
|
532
|
-
const budget = new HtmlBudget(options);
|
|
533
|
-
const owner = owners.get(node);
|
|
534
|
-
if (!owner) throw new HtmlError("E_OWNERSHIP", "Unowned node");
|
|
535
|
-
const internal = internals.get(node);
|
|
536
|
-
if (!internal) throw new HtmlError("E_OWNERSHIP", "Unowned node");
|
|
537
|
-
const parent = internal.parent;
|
|
538
|
-
budget.charge("work", parent?.children.length ?? 1);
|
|
539
|
-
budget.charge("retainedBytes", (parent?.children.length ?? 0) * 8);
|
|
540
|
-
unlink(internal);
|
|
541
|
-
if (parent)
|
|
542
|
-
childViews.set(parent, Object.freeze(parent.children.map((child) => views.get(child))));
|
|
543
|
-
owner.mutated = true;
|
|
544
|
-
}
|
|
545
|
-
function replaceHtmlAttribute(node, name, value, options) {
|
|
546
|
-
const budget = new HtmlBudget(options);
|
|
547
|
-
const internal = internals.get(node), owner = owners.get(node);
|
|
548
|
-
if (!internal || !owner) throw new HtmlError("E_OWNERSHIP", "Unowned node");
|
|
549
|
-
budget.charge("work", internal.attributes.length + value.length);
|
|
550
|
-
budget.charge("retainedBytes", internal.attributes.length * 64 + value.length * 2);
|
|
551
|
-
if (!internal.attributes.some((a) => a.namespace === "none" && a.name === name)) return;
|
|
552
|
-
internal.attributes = Object.freeze(internal.attributes.map((a) => a.namespace === "none" && a.name === name ? Object.freeze({ ...a, value }) : a));
|
|
553
|
-
owner.mutated = true;
|
|
577
|
+
};
|
|
578
|
+
function delimiter(c) {
|
|
579
|
+
return c !== void 0 && ((0, entities_exports.htmlSpace)(c) || c === "/" || c === ">");
|
|
554
580
|
}
|
|
555
|
-
function
|
|
556
|
-
|
|
557
|
-
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
558
|
-
if (index < 0) throw new HtmlError("E_OWNERSHIP", "Insertion reference has another parent");
|
|
559
|
-
const previous2 = parent.children[index - 1] ?? null;
|
|
560
|
-
const next = parent.children[index] ?? null;
|
|
561
|
-
node.parent = parent;
|
|
562
|
-
node.previousSibling = previous2;
|
|
563
|
-
node.nextSibling = next;
|
|
564
|
-
if (previous2) previous2.nextSibling = node;
|
|
565
|
-
if (next) next.previousSibling = node;
|
|
566
|
-
parent.children.splice(index, 0, node);
|
|
581
|
+
function asciiLetter(c) {
|
|
582
|
+
return c >= "A" && c <= "Z" || c >= "a" && c <= "z";
|
|
567
583
|
}
|
|
584
|
+
|
|
585
|
+
// packages/safe-bash-command-htmlq/src/tree-rules.ts
|
|
568
586
|
var formatting = /* @__PURE__ */ new Set([
|
|
569
587
|
"a",
|
|
570
588
|
"b",
|
|
@@ -751,69 +769,303 @@ var svgAttributes = Object.fromEntries(
|
|
|
751
769
|
"zoomAndPan"
|
|
752
770
|
].map((name) => [name.toLowerCase(), name])
|
|
753
771
|
);
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
772
|
+
|
|
773
|
+
// packages/safe-bash-command-htmlq/src/tree.ts
|
|
774
|
+
function allSpace(data) {
|
|
775
|
+
for (const c of data) if (!(0, entities_exports.htmlSpace)(c)) return false;
|
|
776
|
+
return true;
|
|
777
|
+
}
|
|
778
|
+
var kNode = /* @__PURE__ */ Symbol("node");
|
|
779
|
+
var kOwner = /* @__PURE__ */ Symbol("owner");
|
|
780
|
+
var owners = {
|
|
781
|
+
get(node) {
|
|
782
|
+
return node[kOwner] ?? node._owner;
|
|
783
|
+
},
|
|
784
|
+
set(node, owner) {
|
|
785
|
+
node._owner = owner;
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
var internals = {
|
|
789
|
+
has(node) {
|
|
790
|
+
return Boolean(node[kNode]);
|
|
791
|
+
},
|
|
792
|
+
get(node) {
|
|
793
|
+
return node[kNode];
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
function getInternalHtmlNode(node) {
|
|
797
|
+
if (!node || typeof node !== "object") throw new HtmlError("E_OWNERSHIP", "Unowned HTML node");
|
|
798
|
+
return internals.get(node);
|
|
799
|
+
}
|
|
800
|
+
function getPublicHtmlView(node) {
|
|
801
|
+
let view = node._view;
|
|
802
|
+
if (!view) {
|
|
803
|
+
const v = Object.create(publicViewProto);
|
|
804
|
+
v[kNode] = node;
|
|
805
|
+
v[kOwner] = node._owner;
|
|
806
|
+
Object.freeze(v);
|
|
807
|
+
view = v;
|
|
808
|
+
node._view = view;
|
|
809
|
+
}
|
|
810
|
+
return view;
|
|
811
|
+
}
|
|
812
|
+
var views = {
|
|
813
|
+
get(node) {
|
|
814
|
+
return getPublicHtmlView(node);
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
var childViews = {
|
|
818
|
+
get(node) {
|
|
819
|
+
return node._childViews;
|
|
820
|
+
},
|
|
821
|
+
set(node, cv) {
|
|
822
|
+
node._childViews = cv;
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
var publicViewProto = {};
|
|
826
|
+
for (const key of ["kind", "name", "data", "namespace"]) {
|
|
827
|
+
Object.defineProperty(publicViewProto, key, {
|
|
828
|
+
enumerable: true,
|
|
829
|
+
get() {
|
|
830
|
+
return this[kNode][key];
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
Object.defineProperty(publicViewProto, "attributes", {
|
|
835
|
+
enumerable: true,
|
|
836
|
+
get() {
|
|
837
|
+
const n = this[kNode];
|
|
838
|
+
if (!n._attrsFrozen) {
|
|
839
|
+
for (const attribute2 of n.attributes) Object.freeze(attribute2);
|
|
840
|
+
Object.freeze(n.attributes);
|
|
841
|
+
n._attrsFrozen = true;
|
|
842
|
+
}
|
|
843
|
+
return n.attributes;
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
Object.defineProperty(publicViewProto, "children", {
|
|
847
|
+
enumerable: true,
|
|
848
|
+
get() {
|
|
849
|
+
const n = this[kNode];
|
|
850
|
+
let cv = n._childViews;
|
|
851
|
+
if (!cv) {
|
|
852
|
+
cv = Object.freeze(n.children.map((child) => getPublicHtmlView(child)));
|
|
853
|
+
n._childViews = cv;
|
|
854
|
+
}
|
|
855
|
+
return cv;
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
for (const key of ["parent", "previousSibling", "nextSibling", "templateContents"]) {
|
|
859
|
+
Object.defineProperty(publicViewProto, key, {
|
|
860
|
+
enumerable: true,
|
|
861
|
+
get() {
|
|
862
|
+
const n = this[kNode][key];
|
|
863
|
+
return n ? getPublicHtmlView(n) : n;
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
Object.freeze(publicViewProto);
|
|
868
|
+
function expose(document, budget) {
|
|
869
|
+
const pending = [{ node: document, depth: 0 }];
|
|
870
|
+
const docOwner = owners.get(document);
|
|
871
|
+
while (pending.length) {
|
|
872
|
+
const { node, depth } = pending.pop();
|
|
873
|
+
budget.bound("depth", depth);
|
|
874
|
+
budget.charge("work", 1);
|
|
875
|
+
budget.charge("retainedBytes", 128 + node.children.length * 8);
|
|
876
|
+
node._owner = docOwner;
|
|
877
|
+
for (const child of node.children) pending.push({ node: child, depth: depth + 1 });
|
|
878
|
+
if (node.templateContents) pending.push({ node: node.templateContents, depth: depth + 1 });
|
|
879
|
+
}
|
|
880
|
+
return getPublicHtmlView(document);
|
|
881
|
+
}
|
|
882
|
+
function ownsHtmlNode(node) {
|
|
883
|
+
return internals.has(node);
|
|
884
|
+
}
|
|
885
|
+
function originalSource(node) {
|
|
886
|
+
const owner = owners.get(node);
|
|
887
|
+
if (!owner) throw new HtmlError("E_OWNERSHIP", "Node is not owned by this HTML engine");
|
|
888
|
+
if (node.kind !== "document")
|
|
889
|
+
throw new HtmlError(
|
|
890
|
+
"E_UNSUPPORTED",
|
|
891
|
+
"Original serialization is defined only for a complete document"
|
|
892
|
+
);
|
|
893
|
+
if (owner.mutated)
|
|
894
|
+
throw new HtmlError("E_MUTATED", "Original source does not represent the mutated tree");
|
|
895
|
+
if (owner.source === void 0) throw new HtmlError("E_UNSUPPORTED", "Original source was not retained");
|
|
896
|
+
return owner.source;
|
|
897
|
+
}
|
|
898
|
+
function unlink(node) {
|
|
899
|
+
const parent = node.parent;
|
|
900
|
+
if (!parent) return;
|
|
901
|
+
const index = parent.children.indexOf(node);
|
|
902
|
+
if (index < 0) throw new HtmlError("E_OWNERSHIP", "Inconsistent parent link");
|
|
903
|
+
if (node.previousSibling) node.previousSibling.nextSibling = node.nextSibling;
|
|
904
|
+
if (node.nextSibling) node.nextSibling.previousSibling = node.previousSibling;
|
|
905
|
+
parent.children.splice(index, 1);
|
|
906
|
+
node.parent = null;
|
|
907
|
+
node.previousSibling = null;
|
|
908
|
+
node.nextSibling = null;
|
|
909
|
+
}
|
|
910
|
+
function detachHtmlNode(node, options) {
|
|
911
|
+
const budget = new HtmlBudget(options);
|
|
912
|
+
const owner = owners.get(node);
|
|
913
|
+
if (!owner) throw new HtmlError("E_OWNERSHIP", "Unowned node");
|
|
914
|
+
const internal = internals.get(node);
|
|
915
|
+
if (!internal) throw new HtmlError("E_OWNERSHIP", "Unowned node");
|
|
916
|
+
const parent = internal.parent;
|
|
917
|
+
budget.charge("work", parent?.children.length ?? 1);
|
|
918
|
+
budget.charge("retainedBytes", (parent?.children.length ?? 0) * 8);
|
|
919
|
+
unlink(internal);
|
|
920
|
+
if (parent)
|
|
921
|
+
childViews.set(parent, Object.freeze(parent.children.map((child) => views.get(child))));
|
|
922
|
+
owner.mutated = true;
|
|
923
|
+
}
|
|
924
|
+
function replaceHtmlAttribute(node, name, value, options) {
|
|
925
|
+
const budget = new HtmlBudget(options);
|
|
926
|
+
const internal = internals.get(node), owner = owners.get(node);
|
|
927
|
+
if (!internal || !owner) throw new HtmlError("E_OWNERSHIP", "Unowned node");
|
|
928
|
+
budget.charge("work", internal.attributes.length + value.length);
|
|
929
|
+
budget.charge("retainedBytes", internal.attributes.length * 64 + value.length * 2);
|
|
930
|
+
if (!internal.attributes.some((a) => a.namespace === "none" && a.name === name)) return;
|
|
931
|
+
internal.attributes = Object.freeze(internal.attributes.map((a) => a.namespace === "none" && a.name === name ? Object.freeze({ ...a, value }) : a));
|
|
932
|
+
owner.mutated = true;
|
|
933
|
+
}
|
|
934
|
+
function attach(parent, node, before) {
|
|
935
|
+
unlink(node);
|
|
936
|
+
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
937
|
+
if (index < 0) throw new HtmlError("E_OWNERSHIP", "Insertion reference has another parent");
|
|
938
|
+
const previous2 = parent.children[index - 1] ?? null;
|
|
939
|
+
const next = parent.children[index] ?? null;
|
|
940
|
+
node.parent = parent;
|
|
941
|
+
node.previousSibling = previous2;
|
|
942
|
+
node.nextSibling = next;
|
|
943
|
+
if (previous2) previous2.nextSibling = node;
|
|
944
|
+
if (next) next.previousSibling = node;
|
|
945
|
+
parent.children.splice(index, 0, node);
|
|
946
|
+
}
|
|
947
|
+
async function parseHtml(source, options, originalSource2 = "retain") {
|
|
948
|
+
const budget = new HtmlBudget(options);
|
|
949
|
+
const owner = { source: originalSource2 === "retain" ? "" : void 0, mutated: false };
|
|
950
|
+
async function* normalized() {
|
|
951
|
+
let first = true, carriage = false;
|
|
952
|
+
for await (const original of decodedHtml(source, options)) {
|
|
953
|
+
if (owner.source !== void 0) {
|
|
954
|
+
budget.charge("retainedBytes", original.length * 2);
|
|
955
|
+
owner.source += original;
|
|
956
|
+
}
|
|
957
|
+
let text = "";
|
|
958
|
+
for (const character of original) {
|
|
959
|
+
budget.charge("work", 1);
|
|
960
|
+
if (first) {
|
|
961
|
+
first = false;
|
|
962
|
+
if (character === "\uFEFF") continue;
|
|
963
|
+
}
|
|
964
|
+
if (carriage && character === "\n") {
|
|
965
|
+
carriage = false;
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
carriage = character === "\r";
|
|
969
|
+
text += carriage ? "\n" : character;
|
|
970
|
+
}
|
|
971
|
+
yield text;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
const tokenizer = new StreamingHtmlTokenizer(normalized(), budget);
|
|
975
|
+
const tree = buildTree(owner, budget);
|
|
976
|
+
let step = tree.next();
|
|
977
|
+
let failure;
|
|
978
|
+
try {
|
|
979
|
+
while (!step.done) step = tree.next(await tokenizer.next(step.value.raw, step.value.foreign));
|
|
980
|
+
} catch (error) {
|
|
981
|
+
failure = { error };
|
|
982
|
+
}
|
|
983
|
+
try {
|
|
984
|
+
await tokenizer.close();
|
|
985
|
+
} catch (error) {
|
|
986
|
+
if (failure) throw new AggregateError([failure.error, error], "HTML input and cleanup failed");
|
|
987
|
+
throw error;
|
|
988
|
+
}
|
|
989
|
+
if (failure) throw failure.error;
|
|
990
|
+
return step.value;
|
|
991
|
+
}
|
|
992
|
+
async function* decodedHtml(source, options) {
|
|
993
|
+
const budget = new HtmlBudget(options);
|
|
994
|
+
const decoder = new TextDecoder("utf-8", { fatal: false, ignoreBOM: true });
|
|
995
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
996
|
+
let complete = false, sinceYield = 0;
|
|
997
|
+
let failed = false;
|
|
998
|
+
let failure;
|
|
999
|
+
const closeInput = async () => {
|
|
1000
|
+
if (!complete && iterator.return) {
|
|
1001
|
+
try {
|
|
1002
|
+
await iterator.return();
|
|
1003
|
+
} catch (cleanup) {
|
|
1004
|
+
if (failed) throw new AggregateError([failure, cleanup], "HTML input and cleanup failed");
|
|
1005
|
+
throw cleanup;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
const abort = () => {
|
|
1010
|
+
throw new HtmlCancellationError(options.signal);
|
|
1011
|
+
};
|
|
1012
|
+
try {
|
|
1013
|
+
while (true) {
|
|
1014
|
+
budget.charge("work", 1);
|
|
1015
|
+
if (++sinceYield >= 4096) {
|
|
1016
|
+
await yieldTurn();
|
|
1017
|
+
budget.check();
|
|
1018
|
+
sinceYield = 0;
|
|
1019
|
+
}
|
|
1020
|
+
let listener = () => {
|
|
1021
|
+
};
|
|
1022
|
+
const cancellation = new Promise((_, reject) => {
|
|
1023
|
+
listener = () => reject(new HtmlCancellationError(options.signal));
|
|
1024
|
+
options.signal.addEventListener("abort", listener, { once: true });
|
|
1025
|
+
});
|
|
1026
|
+
let result;
|
|
1027
|
+
try {
|
|
1028
|
+
result = await Promise.race([iterator.next(), cancellation]);
|
|
1029
|
+
} finally {
|
|
1030
|
+
options.signal.removeEventListener("abort", listener);
|
|
1031
|
+
}
|
|
1032
|
+
if (options.signal.aborted) abort();
|
|
1033
|
+
if (result.done) {
|
|
1034
|
+
complete = true;
|
|
1035
|
+
break;
|
|
1036
|
+
}
|
|
1037
|
+
const chunk = result.value;
|
|
1038
|
+
budget.check();
|
|
1039
|
+
const typedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
|
|
1040
|
+
if (!ArrayBuffer.isView(chunk) || Object.getOwnPropertyDescriptor(typedArrayPrototype, Symbol.toStringTag).get.call(chunk) !== "Uint8Array")
|
|
1041
|
+
throw new HtmlError("E_UNSUPPORTED", "HTML input requires byte chunks");
|
|
1042
|
+
const byteLength2 = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteLength").get.call(chunk);
|
|
1043
|
+
budget.charge("inputBytes", byteLength2);
|
|
792
1044
|
budget.charge("retainedBytes", byteLength2 * 2);
|
|
793
1045
|
budget.charge("work", byteLength2);
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
1046
|
+
for (let offset = 0; offset < byteLength2; offset += 4096) {
|
|
1047
|
+
if (sinceYield >= 4096) {
|
|
1048
|
+
await yieldTurn();
|
|
1049
|
+
budget.check();
|
|
1050
|
+
sinceYield = 0;
|
|
1051
|
+
}
|
|
1052
|
+
sinceYield += Math.min(4096, byteLength2 - offset);
|
|
1053
|
+
const text = decoder.decode(Uint8Array.prototype.subarray.call(chunk, offset, Math.min(byteLength2, offset + 4096)), { stream: true });
|
|
1054
|
+
budget.charge("decodedBytes", text.length * 2);
|
|
1055
|
+
yield text;
|
|
1056
|
+
}
|
|
797
1057
|
}
|
|
798
1058
|
} catch (error) {
|
|
799
1059
|
failed = true;
|
|
800
1060
|
failure = error;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
try {
|
|
804
|
-
await iterator.return();
|
|
805
|
-
} catch (cleanup) {
|
|
806
|
-
if (failed)
|
|
807
|
-
throw new AggregateError([failure, cleanup], "HTML input and cleanup failed");
|
|
808
|
-
throw cleanup;
|
|
809
|
-
}
|
|
1061
|
+
} finally {
|
|
1062
|
+
await closeInput();
|
|
810
1063
|
}
|
|
811
1064
|
if (failed) throw failure;
|
|
812
1065
|
const tail = decoder.decode();
|
|
813
1066
|
budget.charge("decodedBytes", tail.length * 2);
|
|
814
1067
|
budget.charge("retainedBytes", tail.length * 2);
|
|
815
|
-
|
|
816
|
-
return parseHtmlSync(original, options, budget);
|
|
1068
|
+
yield tail;
|
|
817
1069
|
}
|
|
818
1070
|
function parseHtmlSync(original, options, existingBudget) {
|
|
819
1071
|
const budget = existingBudget ?? new HtmlBudget(options);
|
|
@@ -832,7 +1084,13 @@ function parseHtmlSync(original, options, existingBudget) {
|
|
|
832
1084
|
} else normalized += original[i];
|
|
833
1085
|
}
|
|
834
1086
|
}
|
|
835
|
-
const
|
|
1087
|
+
const tree = buildTree({ source: original, mutated: false }, budget);
|
|
1088
|
+
const tokenizer = new HtmlTokenizer(normalized, budget);
|
|
1089
|
+
let step = tree.next();
|
|
1090
|
+
while (!step.done) step = tree.next(tokenizer.next(step.value.raw, step.value.foreign));
|
|
1091
|
+
return step.value;
|
|
1092
|
+
}
|
|
1093
|
+
function* buildTree(owner, budget) {
|
|
836
1094
|
const make = (kind, name = "", data = "", namespace = "html") => {
|
|
837
1095
|
budget.charge("nodes", 1);
|
|
838
1096
|
budget.charge("retainedBytes", 128 + (name.length + data.length) * 2);
|
|
@@ -1035,12 +1293,11 @@ function parseHtmlSync(original, options, existingBudget) {
|
|
|
1035
1293
|
last.data += data;
|
|
1036
1294
|
} else append(parent, make("text", "", data), before);
|
|
1037
1295
|
};
|
|
1038
|
-
const tokenizer = new HtmlTokenizer(normalized, budget);
|
|
1039
1296
|
let token;
|
|
1040
|
-
while (token =
|
|
1041
|
-
current().namespace === "html" && (rawElements.has(current().name) || current().name === "title" || current().name === "textarea") ? current().name : void 0,
|
|
1042
|
-
current().namespace !== "html"
|
|
1043
|
-
)
|
|
1297
|
+
while (token = yield {
|
|
1298
|
+
raw: current().namespace === "html" && (rawElements.has(current().name) || current().name === "title" || current().name === "textarea") ? current().name : void 0,
|
|
1299
|
+
foreign: current().namespace !== "html"
|
|
1300
|
+
}) {
|
|
1044
1301
|
budget.charge("work", stack.length + active.length + 1);
|
|
1045
1302
|
if (token.kind === "doctype") {
|
|
1046
1303
|
if (mode === "beforeHead") append(document, make("doctype", "", token.data), html);
|
|
@@ -1553,7 +1810,7 @@ function* inclusiveHtmlDescendants(root, options) {
|
|
|
1553
1810
|
|
|
1554
1811
|
// packages/safe-bash-command-htmlq/src/selectors.ts
|
|
1555
1812
|
var cssSpace = (c) => c === " " || c === " " || c === "\n" || c === "\r" || c === "\f";
|
|
1556
|
-
function
|
|
1813
|
+
function asciiLower3(s) {
|
|
1557
1814
|
let out = "", changed = false;
|
|
1558
1815
|
for (let i = 0; i < s.length; i++) {
|
|
1559
1816
|
const n = s.charCodeAt(i);
|
|
@@ -1565,7 +1822,7 @@ function asciiLower2(s) {
|
|
|
1565
1822
|
}
|
|
1566
1823
|
return changed ? out : s;
|
|
1567
1824
|
}
|
|
1568
|
-
var
|
|
1825
|
+
var SelectorParser = class {
|
|
1569
1826
|
constructor(source, budget) {
|
|
1570
1827
|
this.source = source;
|
|
1571
1828
|
this.budget = budget;
|
|
@@ -1615,8 +1872,8 @@ var Parser = class {
|
|
|
1615
1872
|
} else {
|
|
1616
1873
|
if (!this.peek() || this.peek() === "\n" || this.peek() === "\r" || this.peek() === "\f")
|
|
1617
1874
|
this.fail();
|
|
1618
|
-
const
|
|
1619
|
-
out +=
|
|
1875
|
+
const escaped3 = this.take();
|
|
1876
|
+
out += escaped3 === "\0" ? "\uFFFD" : escaped3;
|
|
1620
1877
|
}
|
|
1621
1878
|
} else if (c === "-" || c === "_" || c === "\0" || c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" || c.charCodeAt(0) >= 128)
|
|
1622
1879
|
out += this.take() === "\0" ? "\uFFFD" : c;
|
|
@@ -1644,8 +1901,8 @@ var Parser = class {
|
|
|
1644
1901
|
} else if (this.peek() === "\n" || this.peek() === "\r" || this.peek() === "\f")
|
|
1645
1902
|
this.escapeWhitespace();
|
|
1646
1903
|
else if (this.peek()) {
|
|
1647
|
-
const
|
|
1648
|
-
out +=
|
|
1904
|
+
const escaped3 = this.take();
|
|
1905
|
+
out += escaped3 === "\0" ? "\uFFFD" : escaped3;
|
|
1649
1906
|
} else this.fail();
|
|
1650
1907
|
} else {
|
|
1651
1908
|
if (this.peek() === "\n" || this.peek() === "\r" || this.peek() === "\f") this.fail();
|
|
@@ -1696,7 +1953,7 @@ var Parser = class {
|
|
|
1696
1953
|
expected = this.peek() === '"' || this.peek() === "'" ? this.quoted() : this.identifier();
|
|
1697
1954
|
this.spaces();
|
|
1698
1955
|
if (this.peek() !== "]") {
|
|
1699
|
-
const flag =
|
|
1956
|
+
const flag = asciiLower3(this.identifier());
|
|
1700
1957
|
if (flag !== "i" && flag !== "s") this.fail();
|
|
1701
1958
|
insensitive = flag === "i";
|
|
1702
1959
|
this.spaces();
|
|
@@ -1705,7 +1962,7 @@ var Parser = class {
|
|
|
1705
1962
|
if (this.take() !== "]") this.fail();
|
|
1706
1963
|
tests.push({ kind: "attribute", value, operator, expected, insensitive });
|
|
1707
1964
|
} else {
|
|
1708
|
-
const value =
|
|
1965
|
+
const value = asciiLower3(this.identifier());
|
|
1709
1966
|
if (value === "not") {
|
|
1710
1967
|
if (inNot || this.take() !== "(") this.fail();
|
|
1711
1968
|
const negated = this.list(true);
|
|
@@ -1787,13 +2044,13 @@ var Parser = class {
|
|
|
1787
2044
|
spaces();
|
|
1788
2045
|
let end = source.length;
|
|
1789
2046
|
while (end > at && cssSpace(source[end - 1])) end--;
|
|
1790
|
-
const word =
|
|
2047
|
+
const word = asciiLower3(source.slice(at, end));
|
|
1791
2048
|
if (word === "odd") return [2, 1];
|
|
1792
2049
|
if (word === "even") return [2, 0];
|
|
1793
2050
|
let sign = "";
|
|
1794
2051
|
if (source[at] === "+" || source[at] === "-") sign = source[at++];
|
|
1795
2052
|
const number = digits();
|
|
1796
|
-
if (
|
|
2053
|
+
if (asciiLower3(source[at] ?? "") !== "n") {
|
|
1797
2054
|
spaces();
|
|
1798
2055
|
if (!number || at !== source.length) this.fail();
|
|
1799
2056
|
return [0, integer(sign + number)];
|
|
@@ -1814,7 +2071,7 @@ var Parser = class {
|
|
|
1814
2071
|
function attribute(node, name, budget) {
|
|
1815
2072
|
budget.charge("work", name.length);
|
|
1816
2073
|
budget.charge("retainedBytes", name.length * 2);
|
|
1817
|
-
const expected = node.namespace === "html" ?
|
|
2074
|
+
const expected = node.namespace === "html" ? asciiLower3(name) : name;
|
|
1818
2075
|
for (const a of node.attributes) {
|
|
1819
2076
|
budget.charge("work", a.name.length + expected.length + 1);
|
|
1820
2077
|
if (a.namespace === "none" && a.name === expected) return a.value;
|
|
@@ -1847,7 +2104,7 @@ function matchesTest(node, test, budget) {
|
|
|
1847
2104
|
if (test.kind === "type") {
|
|
1848
2105
|
budget.charge("work", node.name.length + test.value.length);
|
|
1849
2106
|
budget.charge("retainedBytes", test.value.length * 2);
|
|
1850
|
-
return test.namespace !== "none" && (test.value === "*" || node.name === (node.namespace === "html" ?
|
|
2107
|
+
return test.namespace !== "none" && (test.value === "*" || node.name === (node.namespace === "html" ? asciiLower3(test.value) : test.value));
|
|
1851
2108
|
}
|
|
1852
2109
|
if (test.kind === "id") {
|
|
1853
2110
|
const value = attribute(node, "id", budget);
|
|
@@ -1863,8 +2120,8 @@ function matchesTest(node, test, budget) {
|
|
|
1863
2120
|
budget.charge("work", value.length + expected.length);
|
|
1864
2121
|
if (test.insensitive) {
|
|
1865
2122
|
budget.charge("retainedBytes", (value.length + expected.length) * 4);
|
|
1866
|
-
value =
|
|
1867
|
-
expected =
|
|
2123
|
+
value = asciiLower3(value);
|
|
2124
|
+
expected = asciiLower3(expected);
|
|
1868
2125
|
}
|
|
1869
2126
|
switch (test.operator) {
|
|
1870
2127
|
case "":
|
|
@@ -1953,7 +2210,7 @@ function matchesProgram(node, program, budget) {
|
|
|
1953
2210
|
}
|
|
1954
2211
|
function selectHtml(root, selector, options) {
|
|
1955
2212
|
const budget = new HtmlBudget(options);
|
|
1956
|
-
const program = new
|
|
2213
|
+
const program = new SelectorParser(selector, budget).list();
|
|
1957
2214
|
const internalRoot = getInternalHtmlNode(root);
|
|
1958
2215
|
if (!internalRoot) throw new HtmlError("E_OWNERSHIP", "Unowned HTML node");
|
|
1959
2216
|
return (function* () {
|
|
@@ -2222,7 +2479,7 @@ function evalSyncHtmlq(inBytes, opArgs, readFileSync, writeFileSync) {
|
|
|
2222
2479
|
}
|
|
2223
2480
|
|
|
2224
2481
|
// packages/safe-bash-command-htmlq/src/behavior.ts
|
|
2225
|
-
import { yieldTurn } from "../safe-bash-contracts/yield.js";
|
|
2482
|
+
import { yieldTurn as yieldTurn2 } from "../safe-bash-contracts/yield.js";
|
|
2226
2483
|
|
|
2227
2484
|
// packages/safe-bash-command-htmlq/src/information.ts
|
|
2228
2485
|
var help = `Like jq, but for HTML.
|
|
@@ -2284,7 +2541,7 @@ async function* projectHtmlq(source, args, invocation) {
|
|
|
2284
2541
|
budget.check();
|
|
2285
2542
|
return;
|
|
2286
2543
|
}
|
|
2287
|
-
const document = await parseHtml(source, invocation);
|
|
2544
|
+
const document = await parseHtml(source, invocation, "discard");
|
|
2288
2545
|
let base = baseUrl(args.base);
|
|
2289
2546
|
if (args.detectBase) {
|
|
2290
2547
|
const first = selectHtml(document, "base", invocation).next().value;
|
|
@@ -2360,7 +2617,7 @@ async function* projectHtmlq(source, args, invocation) {
|
|
|
2360
2617
|
let selectedIndex = 0;
|
|
2361
2618
|
for (const node of nodes) {
|
|
2362
2619
|
if (selectedIndex % 64 === 0) {
|
|
2363
|
-
await
|
|
2620
|
+
await yieldTurn2(invocation.signal);
|
|
2364
2621
|
invocation.signal.throwIfAborted();
|
|
2365
2622
|
}
|
|
2366
2623
|
const isFirstNode = selectedIndex++ === 0;
|
|
@@ -2443,19 +2700,1504 @@ import { FsError } from "../safe-bash-contracts/errors.js";
|
|
|
2443
2700
|
import { writeBytes } from "../safe-bash-contracts/io.js";
|
|
2444
2701
|
import { createOutputOperation } from "../safe-bash-contracts/output.js";
|
|
2445
2702
|
import { shellValueByteLength } from "../safe-bash-contracts/value.js";
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2703
|
+
import { PagedStorage } from "@poe-platform/safe-fs/storage";
|
|
2704
|
+
|
|
2705
|
+
// packages/safe-bash-command-htmlq/src/stored-project.ts
|
|
2706
|
+
import { TextStore } from "../safe-bash-command-html-to-markdown/stored-text.js";
|
|
2707
|
+
import { yieldTurn as yieldTurn3 } from "../safe-bash-contracts/yield.js";
|
|
2708
|
+
|
|
2709
|
+
// packages/safe-bash-command-htmlq/src/document-store.ts
|
|
2710
|
+
var kinds = ["document", "fragment", "element", "text", "comment", "doctype"];
|
|
2711
|
+
var namespaces = ["html", "svg", "mathml"];
|
|
2712
|
+
var attributeNamespaces = ["none", "xml", "xmlns", "xlink"];
|
|
2713
|
+
var fields = ["name", "data", "parent", "first", "last", "previous", "next", "templateContents", "firstAttribute", "lastAttribute", "childCount", "attributeCount"];
|
|
2714
|
+
var DocumentStore = class {
|
|
2715
|
+
constructor(storage, cooperate) {
|
|
2716
|
+
this.storage = storage;
|
|
2717
|
+
this.cooperate = cooperate;
|
|
2453
2718
|
}
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2719
|
+
storage;
|
|
2720
|
+
cooperate;
|
|
2721
|
+
nodes = /* @__PURE__ */ new Map();
|
|
2722
|
+
get residentNodes() {
|
|
2723
|
+
return this.nodes.size;
|
|
2724
|
+
}
|
|
2725
|
+
retain(node) {
|
|
2726
|
+
this.nodes.delete(node.id);
|
|
2727
|
+
if (this.nodes.size === 512) this.nodes.delete(this.nodes.keys().next().value);
|
|
2728
|
+
this.nodes.set(node.id, node);
|
|
2729
|
+
}
|
|
2730
|
+
async create(kind, values = {}) {
|
|
2731
|
+
const bytes = new Uint8Array(112), view = new DataView(bytes.buffer);
|
|
2732
|
+
view.setFloat64(0, kinds.indexOf(kind), true);
|
|
2733
|
+
view.setFloat64(8, namespaces.indexOf(values.namespace ?? "html"), true);
|
|
2734
|
+
for (const [index, field] of fields.entries()) view.setFloat64(16 + index * 8, values[field] ?? 0, true);
|
|
2735
|
+
return this.storage.append(bytes);
|
|
2736
|
+
}
|
|
2737
|
+
async read(id) {
|
|
2738
|
+
const checkpoint = this.cooperate?.();
|
|
2739
|
+
if (checkpoint) await checkpoint;
|
|
2740
|
+
if (!id) throw new HtmlError("E_OWNERSHIP", "Absent stored HTML node");
|
|
2741
|
+
const cached = this.nodes.get(id);
|
|
2742
|
+
if (cached) {
|
|
2743
|
+
this.retain(cached);
|
|
2744
|
+
return { ...cached };
|
|
2745
|
+
}
|
|
2746
|
+
const bytes = await this.storage.read(id, 112), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2747
|
+
const node = { id, kind: kinds[view.getFloat64(0, true)], namespace: namespaces[view.getFloat64(8, true)] };
|
|
2748
|
+
for (const [index, field] of fields.entries()) node[field] = view.getFloat64(16 + index * 8, true);
|
|
2749
|
+
this.retain(node);
|
|
2750
|
+
return { ...node };
|
|
2751
|
+
}
|
|
2752
|
+
async patch(id, values) {
|
|
2753
|
+
const node = { ...await this.read(id), ...values };
|
|
2754
|
+
const bytes = new Uint8Array(112), view = new DataView(bytes.buffer);
|
|
2755
|
+
view.setFloat64(0, kinds.indexOf(node.kind), true);
|
|
2756
|
+
view.setFloat64(8, namespaces.indexOf(node.namespace), true);
|
|
2757
|
+
for (const [index, field] of fields.entries()) view.setFloat64(16 + index * 8, node[field], true);
|
|
2758
|
+
this.nodes.delete(id);
|
|
2759
|
+
await this.storage.write(id, bytes);
|
|
2760
|
+
this.retain(node);
|
|
2761
|
+
}
|
|
2762
|
+
async detach(id) {
|
|
2763
|
+
const node = await this.read(id);
|
|
2764
|
+
if (!node.parent) return;
|
|
2765
|
+
const parent = await this.read(node.parent);
|
|
2766
|
+
if (node.previous) await this.patch(node.previous, { next: node.next });
|
|
2767
|
+
if (node.next) await this.patch(node.next, { previous: node.previous });
|
|
2768
|
+
await this.patch(parent.id, {
|
|
2769
|
+
first: parent.first === id ? node.next : parent.first,
|
|
2770
|
+
last: parent.last === id ? node.previous : parent.last,
|
|
2771
|
+
childCount: parent.childCount - 1
|
|
2772
|
+
});
|
|
2773
|
+
await this.patch(id, { parent: 0, previous: 0, next: 0 });
|
|
2774
|
+
}
|
|
2775
|
+
async attach(parentId, id, before = 0) {
|
|
2776
|
+
if (before === id) return;
|
|
2777
|
+
if (before && (await this.read(before)).parent !== parentId)
|
|
2778
|
+
throw new HtmlError("E_OWNERSHIP", "Stored insertion reference has a different parent");
|
|
2779
|
+
await this.detach(id);
|
|
2780
|
+
const parent = await this.read(parentId);
|
|
2781
|
+
const previous2 = before ? (await this.read(before)).previous : parent.last;
|
|
2782
|
+
await this.patch(id, { parent: parentId, previous: previous2, next: before });
|
|
2783
|
+
if (previous2) await this.patch(previous2, { next: id });
|
|
2784
|
+
if (before) await this.patch(before, { previous: id });
|
|
2785
|
+
await this.patch(parentId, {
|
|
2786
|
+
first: previous2 ? parent.first : id,
|
|
2787
|
+
last: before ? parent.last : id,
|
|
2788
|
+
childCount: parent.childCount + 1
|
|
2789
|
+
});
|
|
2790
|
+
}
|
|
2791
|
+
async *children(parent) {
|
|
2792
|
+
let id = (await this.read(parent)).first;
|
|
2793
|
+
while (id) {
|
|
2794
|
+
const next = (await this.read(id)).next;
|
|
2795
|
+
yield id;
|
|
2796
|
+
id = next;
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
async attribute(nodeId, name, value, namespace) {
|
|
2800
|
+
const node = await this.read(nodeId), bytes = new Uint8Array(32), view = new DataView(bytes.buffer);
|
|
2801
|
+
view.setFloat64(8, name, true);
|
|
2802
|
+
view.setFloat64(16, value, true);
|
|
2803
|
+
view.setFloat64(24, attributeNamespaces.indexOf(namespace), true);
|
|
2804
|
+
const id = await this.storage.append(bytes);
|
|
2805
|
+
if (node.lastAttribute) {
|
|
2806
|
+
view.setFloat64(0, id, true);
|
|
2807
|
+
await this.storage.write(node.lastAttribute, bytes.subarray(0, 8));
|
|
2808
|
+
}
|
|
2809
|
+
await this.patch(nodeId, { firstAttribute: node.firstAttribute || id, lastAttribute: id, attributeCount: node.attributeCount + 1 });
|
|
2810
|
+
return id;
|
|
2811
|
+
}
|
|
2812
|
+
async *attributes(node) {
|
|
2813
|
+
let id = (await this.read(node)).firstAttribute;
|
|
2814
|
+
while (id) {
|
|
2815
|
+
const bytes = await this.storage.read(id, 32), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2816
|
+
const next = view.getFloat64(0, true);
|
|
2817
|
+
yield { id, next, name: view.getFloat64(8, true), value: view.getFloat64(16, true), namespace: attributeNamespaces[view.getFloat64(24, true)] };
|
|
2818
|
+
id = next;
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
async replaceAttribute(id, value) {
|
|
2822
|
+
const bytes = new Uint8Array(8);
|
|
2823
|
+
new DataView(bytes.buffer).setFloat64(0, value, true);
|
|
2824
|
+
await this.storage.write(id + 16, bytes);
|
|
2825
|
+
}
|
|
2826
|
+
async clone(id) {
|
|
2827
|
+
const node = await this.read(id);
|
|
2828
|
+
const clone = await this.create(node.kind, { name: node.name, namespace: node.namespace });
|
|
2829
|
+
for await (const attribute2 of this.attributes(id))
|
|
2830
|
+
await this.attribute(clone, attribute2.name, attribute2.value, attribute2.namespace);
|
|
2831
|
+
return clone;
|
|
2832
|
+
}
|
|
2833
|
+
};
|
|
2834
|
+
var StoredSequence = class {
|
|
2835
|
+
constructor(storage) {
|
|
2836
|
+
this.storage = storage;
|
|
2837
|
+
}
|
|
2838
|
+
storage;
|
|
2839
|
+
start = 0;
|
|
2840
|
+
capacity = 0;
|
|
2841
|
+
count = 0;
|
|
2842
|
+
window;
|
|
2843
|
+
get residentBytes() {
|
|
2844
|
+
return this.window?.bytes.byteLength ?? 0;
|
|
2845
|
+
}
|
|
2846
|
+
get length() {
|
|
2847
|
+
return this.count;
|
|
2848
|
+
}
|
|
2849
|
+
async reserve(count) {
|
|
2850
|
+
if (count <= this.capacity) return;
|
|
2851
|
+
const capacity = Math.max(256, this.capacity * 2, count);
|
|
2852
|
+
const start = this.storage.allocate(capacity * 8);
|
|
2853
|
+
for (let offset = 0; offset < this.count * 8; offset += 16384)
|
|
2854
|
+
await this.storage.write(start + offset, await this.storage.read(this.start + offset, Math.min(16384, this.count * 8 - offset)));
|
|
2855
|
+
this.start = start;
|
|
2856
|
+
this.capacity = capacity;
|
|
2857
|
+
this.window = void 0;
|
|
2858
|
+
}
|
|
2859
|
+
async get(index) {
|
|
2860
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= this.count) return void 0;
|
|
2861
|
+
const offset = Math.floor(index / 2048) * 16384;
|
|
2862
|
+
if (this.window?.offset !== offset) this.window = { offset, bytes: await this.storage.read(this.start + offset, Math.min(16384, this.capacity * 8 - offset)) };
|
|
2863
|
+
const { bytes } = this.window;
|
|
2864
|
+
return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getFloat64(index * 8 - offset, true);
|
|
2865
|
+
}
|
|
2866
|
+
async set(index, value) {
|
|
2867
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= this.count) throw new RangeError("Invalid stored sequence index");
|
|
2868
|
+
const bytes = new Uint8Array(8);
|
|
2869
|
+
new DataView(bytes.buffer).setFloat64(0, value, true);
|
|
2870
|
+
await this.storage.write(this.start + index * 8, bytes);
|
|
2871
|
+
if (this.window && index * 8 >= this.window.offset && index * 8 < this.window.offset + this.window.bytes.length)
|
|
2872
|
+
this.window.bytes.set(bytes, index * 8 - this.window.offset);
|
|
2873
|
+
}
|
|
2874
|
+
async push(value) {
|
|
2875
|
+
await this.reserve(this.count + 1);
|
|
2876
|
+
this.count++;
|
|
2877
|
+
await this.set(this.count - 1, value);
|
|
2878
|
+
}
|
|
2879
|
+
async pop() {
|
|
2880
|
+
if (!this.count) return void 0;
|
|
2881
|
+
const value = await this.get(this.count - 1);
|
|
2882
|
+
this.count--;
|
|
2883
|
+
return value;
|
|
2884
|
+
}
|
|
2885
|
+
async truncate(length) {
|
|
2886
|
+
if (!Number.isSafeInteger(length) || length < 0 || length > this.count) throw new RangeError("Invalid stored sequence length");
|
|
2887
|
+
this.count = length;
|
|
2888
|
+
}
|
|
2889
|
+
async indexOf(value, reverse = false) {
|
|
2890
|
+
for (let index = reverse ? this.count - 1 : 0; index >= 0 && index < this.count; index += reverse ? -1 : 1)
|
|
2891
|
+
if (await this.get(index) === value) return index;
|
|
2892
|
+
return -1;
|
|
2893
|
+
}
|
|
2894
|
+
async splice(index, remove, insert) {
|
|
2895
|
+
if (!Number.isSafeInteger(index) || !Number.isSafeInteger(remove) || index < 0 || index > this.count || remove < 0)
|
|
2896
|
+
throw new RangeError("Invalid stored sequence splice");
|
|
2897
|
+
remove = Math.min(remove, this.count - index);
|
|
2898
|
+
const added = insert === void 0 ? 0 : 1;
|
|
2899
|
+
const count = this.count - remove + added;
|
|
2900
|
+
await this.reserve(count);
|
|
2901
|
+
this.window = void 0;
|
|
2902
|
+
const source = (index + remove) * 8, destination = (index + added) * 8;
|
|
2903
|
+
const length = (this.count - index - remove) * 8;
|
|
2904
|
+
if (destination > source) {
|
|
2905
|
+
for (let remaining = length; remaining > 0; ) {
|
|
2906
|
+
const size = Math.min(16384, remaining);
|
|
2907
|
+
remaining -= size;
|
|
2908
|
+
await this.storage.write(this.start + destination + remaining, await this.storage.read(this.start + source + remaining, size));
|
|
2909
|
+
}
|
|
2910
|
+
} else if (destination < source) {
|
|
2911
|
+
for (let offset = 0; offset < length; offset += 16384)
|
|
2912
|
+
await this.storage.write(this.start + destination + offset, await this.storage.read(this.start + source + offset, Math.min(16384, length - offset)));
|
|
2913
|
+
}
|
|
2914
|
+
this.count = count;
|
|
2915
|
+
if (insert !== void 0) await this.set(index, insert);
|
|
2916
|
+
}
|
|
2917
|
+
};
|
|
2918
|
+
|
|
2919
|
+
// packages/safe-bash-command-htmlq/src/stored-parser.ts
|
|
2920
|
+
function allSpace2(value) {
|
|
2921
|
+
for (const c of value)
|
|
2922
|
+
if (!(0, entities_exports.htmlSpace)(c))
|
|
2923
|
+
return false;
|
|
2924
|
+
return true;
|
|
2925
|
+
}
|
|
2926
|
+
async function parseStoredHtml(source, tree, strings, storage, options) {
|
|
2927
|
+
const budget = new HtmlBudget(options);
|
|
2928
|
+
async function* normalized() {
|
|
2929
|
+
let first = true, carriage = false;
|
|
2930
|
+
for await (const original of decodedHtml(source, options)) {
|
|
2931
|
+
let result2 = "";
|
|
2932
|
+
for (const c of original) {
|
|
2933
|
+
budget.charge("work", 1);
|
|
2934
|
+
if (first) {
|
|
2935
|
+
first = false;
|
|
2936
|
+
if (c === "\uFEFF")
|
|
2937
|
+
continue;
|
|
2938
|
+
}
|
|
2939
|
+
if (carriage && c === "\n") {
|
|
2940
|
+
carriage = false;
|
|
2941
|
+
continue;
|
|
2942
|
+
}
|
|
2943
|
+
carriage = c === "\r";
|
|
2944
|
+
result2 += carriage ? "\n" : c;
|
|
2945
|
+
}
|
|
2946
|
+
yield result2;
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
const tokenizer = new StreamingHtmlTokenizer(normalized(), budget);
|
|
2950
|
+
let result = 0, failure;
|
|
2951
|
+
try {
|
|
2952
|
+
result = await buildStoredTree(tree, strings, storage, tokenizer, budget);
|
|
2953
|
+
} catch (error) {
|
|
2954
|
+
failure = { error };
|
|
2955
|
+
}
|
|
2956
|
+
try {
|
|
2957
|
+
await tokenizer.close();
|
|
2958
|
+
} catch (error) {
|
|
2959
|
+
if (failure)
|
|
2960
|
+
throw new AggregateError([failure.error, error], "HTML parsing and input cleanup failed");
|
|
2961
|
+
throw error;
|
|
2962
|
+
}
|
|
2963
|
+
if (failure)
|
|
2964
|
+
throw failure.error;
|
|
2965
|
+
return result;
|
|
2966
|
+
}
|
|
2967
|
+
async function buildStoredTree(tree, strings, storage, tokenizer, budget) {
|
|
2968
|
+
const labels = /* @__PURE__ */ new Map();
|
|
2969
|
+
const names = /* @__PURE__ */ new Map();
|
|
2970
|
+
const value = async (id) => {
|
|
2971
|
+
const cached = labels.get(id);
|
|
2972
|
+
if (cached !== void 0) return cached;
|
|
2973
|
+
let value2 = "";
|
|
2974
|
+
for await (const chunk of strings.chunks(id)) value2 += chunk;
|
|
2975
|
+
if (value2.length <= 64) {
|
|
2976
|
+
if (labels.size === 256) labels.delete(labels.keys().next().value);
|
|
2977
|
+
labels.set(id, value2);
|
|
2978
|
+
}
|
|
2979
|
+
return value2;
|
|
2980
|
+
};
|
|
2981
|
+
const nameRef = async (name) => {
|
|
2982
|
+
const cached = names.get(name);
|
|
2983
|
+
if (cached !== void 0) return cached;
|
|
2984
|
+
const id = await strings.from(name);
|
|
2985
|
+
if (name.length <= 64) {
|
|
2986
|
+
if (names.size === 256) names.delete(names.keys().next().value);
|
|
2987
|
+
names.set(name, id);
|
|
2988
|
+
if (labels.size === 256) labels.delete(labels.keys().next().value);
|
|
2989
|
+
labels.set(id, name);
|
|
2990
|
+
}
|
|
2991
|
+
return id;
|
|
2992
|
+
};
|
|
2993
|
+
const meta = async (id) => {
|
|
2994
|
+
const node = await tree.read(id);
|
|
2995
|
+
return { ...node, name: await value(node.name) };
|
|
2996
|
+
};
|
|
2997
|
+
const make = async (kind, name = "", data = "", namespace = "html") => {
|
|
2998
|
+
budget.charge("nodes", 1);
|
|
2999
|
+
budget.charge("retainedBytes", 128 + (name.length + data.length) * 2);
|
|
3000
|
+
return tree.create(kind, { name: await nameRef(name), data: await strings.from(data), namespace });
|
|
3001
|
+
};
|
|
3002
|
+
const append = async (parent, node, before = 0) => {
|
|
3003
|
+
const previous2 = (await tree.read(node)).parent;
|
|
3004
|
+
budget.charge("work", (previous2 ? (await tree.read(previous2)).childCount : 0) + (before ? (await tree.read(parent)).childCount : 1));
|
|
3005
|
+
await tree.attach(parent, node, before);
|
|
3006
|
+
};
|
|
3007
|
+
const document = await make("document"), html = await make("element", "html"), head = await make("element", "head"), body = await make("element", "body");
|
|
3008
|
+
await append(document, html);
|
|
3009
|
+
await append(html, head);
|
|
3010
|
+
await append(html, body);
|
|
3011
|
+
const stack = new StoredSequence(storage), active = new StoredSequence(storage);
|
|
3012
|
+
await stack.push(html);
|
|
3013
|
+
let form = 0;
|
|
3014
|
+
let mode = "beforeHead";
|
|
3015
|
+
const current = async () => await stack.get(stack.length - 1);
|
|
3016
|
+
const target = async (node) => {
|
|
3017
|
+
node ??= await current();
|
|
3018
|
+
return (await tree.read(node)).templateContents || node;
|
|
3019
|
+
};
|
|
3020
|
+
const push = async (node) => {
|
|
3021
|
+
budget.bound("depth", stack.length + 1);
|
|
3022
|
+
await stack.push(node);
|
|
3023
|
+
};
|
|
3024
|
+
const find = async (name) => {
|
|
3025
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
3026
|
+
budget.charge("work", 1);
|
|
3027
|
+
if ((await meta(await stack.get(i))).name.toLowerCase() === name)
|
|
3028
|
+
return i;
|
|
3029
|
+
}
|
|
3030
|
+
return -1;
|
|
3031
|
+
};
|
|
3032
|
+
const pop = async (name) => {
|
|
3033
|
+
const i = await find(name);
|
|
3034
|
+
if (i > 0)
|
|
3035
|
+
await stack.truncate(i);
|
|
3036
|
+
};
|
|
3037
|
+
const inScope = async (names2, extra = []) => {
|
|
3038
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
3039
|
+
budget.charge("work", 1);
|
|
3040
|
+
const node = await meta(await stack.get(i));
|
|
3041
|
+
if (node.namespace === "html" && names2.includes(node.name))
|
|
3042
|
+
return i;
|
|
3043
|
+
if (node.namespace === "html" && (htmlScopeBarriers.has(node.name) || extra.includes(node.name)) || node.namespace === "mathml" && mathmlScopeBarriers.has(node.name) || node.namespace === "svg" && svgScopeBarriers.has(node.name))
|
|
3044
|
+
return -1;
|
|
3045
|
+
}
|
|
3046
|
+
return -1;
|
|
3047
|
+
};
|
|
3048
|
+
const headings = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
3049
|
+
const clearFormatting = async () => {
|
|
3050
|
+
while (active.length) {
|
|
3051
|
+
budget.charge("work", 1);
|
|
3052
|
+
if (await active.pop() === 0)
|
|
3053
|
+
break;
|
|
3054
|
+
}
|
|
3055
|
+
};
|
|
3056
|
+
const closeCell = async () => {
|
|
3057
|
+
const index = await inScope(["td", "th"]);
|
|
3058
|
+
if (index > 0) {
|
|
3059
|
+
await stack.truncate(index);
|
|
3060
|
+
await clearFormatting();
|
|
3061
|
+
}
|
|
3062
|
+
};
|
|
3063
|
+
const setAttributes = async (node, attributes) => {
|
|
3064
|
+
for (const a of attributes)
|
|
3065
|
+
await tree.attribute(node, await strings.from(a.name), await strings.from(a.value), a.namespace);
|
|
3066
|
+
};
|
|
3067
|
+
const mergeAttributes = async (node, attributes) => {
|
|
3068
|
+
budget.charge("work", (await tree.read(node)).attributeCount + attributes.length);
|
|
3069
|
+
for (const a of attributes) {
|
|
3070
|
+
let exists = false;
|
|
3071
|
+
for await (const old of tree.attributes(node))
|
|
3072
|
+
if (await value(old.name) === a.name) {
|
|
3073
|
+
exists = true;
|
|
3074
|
+
break;
|
|
3075
|
+
}
|
|
3076
|
+
if (!exists) {
|
|
3077
|
+
budget.charge("retainedBytes", 64 + (a.name.length + a.value.length) * 2);
|
|
3078
|
+
await setAttributes(node, [a]);
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
const clone = async (node) => {
|
|
3083
|
+
const original = await tree.read(node);
|
|
3084
|
+
budget.charge("nodes", 1);
|
|
3085
|
+
budget.charge("retainedBytes", 128 + (await strings.info(original.name)).length * 2);
|
|
3086
|
+
budget.charge("attributes", original.attributeCount);
|
|
3087
|
+
for await (const a of tree.attributes(node))
|
|
3088
|
+
budget.charge("retainedBytes", 64 + ((await strings.info(a.name)).length + (await strings.info(a.value)).length) * 2);
|
|
3089
|
+
return tree.clone(node);
|
|
3090
|
+
};
|
|
3091
|
+
const reconstruct = async () => {
|
|
3092
|
+
for (let i = await active.indexOf(0, true) + 1; i < active.length; i++) {
|
|
3093
|
+
budget.charge("work", stack.length + 1);
|
|
3094
|
+
const a = await active.get(i);
|
|
3095
|
+
if (await stack.indexOf(a) < 0) {
|
|
3096
|
+
const n = await clone(a);
|
|
3097
|
+
await append(await target(), n);
|
|
3098
|
+
await push(n);
|
|
3099
|
+
await active.set(i, n);
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
};
|
|
3103
|
+
const location = async () => {
|
|
3104
|
+
const name = (await meta(await current())).name;
|
|
3105
|
+
if (["table", "tbody", "thead", "tfoot", "tr"].includes(name)) {
|
|
3106
|
+
const table = await stack.get(await find("table"));
|
|
3107
|
+
if (table) {
|
|
3108
|
+
const parent = (await tree.read(table)).parent;
|
|
3109
|
+
if (parent)
|
|
3110
|
+
return [parent, table];
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
return [await target()];
|
|
3114
|
+
};
|
|
3115
|
+
const special = async (id) => {
|
|
3116
|
+
const node = await meta(id);
|
|
3117
|
+
return node.namespace !== "html" || blocks.has(node.name) || specialHtmlElements.has(node.name);
|
|
3118
|
+
};
|
|
3119
|
+
const adopt = async (name) => {
|
|
3120
|
+
for (let outer = 0; outer < 8; outer++) {
|
|
3121
|
+
budget.charge("work", stack.length + active.length);
|
|
3122
|
+
let at = -1;
|
|
3123
|
+
for (let i = active.length - 1; i >= 0; i--) {
|
|
3124
|
+
const node = await active.get(i);
|
|
3125
|
+
if (!node)
|
|
3126
|
+
break;
|
|
3127
|
+
if ((await meta(node)).name === name) {
|
|
3128
|
+
at = i;
|
|
3129
|
+
break;
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
if (at < 0) {
|
|
3133
|
+
await pop(name);
|
|
3134
|
+
return;
|
|
3135
|
+
}
|
|
3136
|
+
const fmt = await active.get(at), index = await stack.indexOf(fmt);
|
|
3137
|
+
if (index < 0) {
|
|
3138
|
+
await active.splice(at, 1);
|
|
3139
|
+
return;
|
|
3140
|
+
}
|
|
3141
|
+
let blockIndex = -1;
|
|
3142
|
+
for (let i = index + 1; i < stack.length; i++)
|
|
3143
|
+
if (await special(await stack.get(i))) {
|
|
3144
|
+
blockIndex = i;
|
|
3145
|
+
break;
|
|
3146
|
+
}
|
|
3147
|
+
if (blockIndex < 0) {
|
|
3148
|
+
await stack.truncate(index);
|
|
3149
|
+
await active.splice(at, 1);
|
|
3150
|
+
return;
|
|
3151
|
+
}
|
|
3152
|
+
const block = await stack.get(blockIndex), ancestor = await stack.get(index - 1);
|
|
3153
|
+
let bookmark = at, last = block, cursor = blockIndex;
|
|
3154
|
+
for (let inner = 1; cursor > index; inner++) {
|
|
3155
|
+
budget.charge("work", stack.length + active.length);
|
|
3156
|
+
cursor--;
|
|
3157
|
+
const node = await stack.get(cursor);
|
|
3158
|
+
if (node === fmt)
|
|
3159
|
+
break;
|
|
3160
|
+
let activeIndex = await active.indexOf(node);
|
|
3161
|
+
if (inner > 3 && activeIndex >= 0) {
|
|
3162
|
+
await active.splice(activeIndex, 1);
|
|
3163
|
+
if (activeIndex < bookmark)
|
|
3164
|
+
bookmark--;
|
|
3165
|
+
activeIndex = -1;
|
|
3166
|
+
}
|
|
3167
|
+
if (activeIndex < 0) {
|
|
3168
|
+
await stack.splice(cursor, 1);
|
|
3169
|
+
continue;
|
|
3170
|
+
}
|
|
3171
|
+
const replacement2 = await clone(node);
|
|
3172
|
+
await stack.set(cursor, replacement2);
|
|
3173
|
+
await active.set(activeIndex, replacement2);
|
|
3174
|
+
if (last === block)
|
|
3175
|
+
bookmark = activeIndex + 1;
|
|
3176
|
+
await append(replacement2, last);
|
|
3177
|
+
last = replacement2;
|
|
3178
|
+
}
|
|
3179
|
+
if (["table", "tbody", "tfoot", "thead", "tr"].includes((await meta(ancestor)).name)) {
|
|
3180
|
+
const table = await stack.get(await find("table")), parent = table ? (await tree.read(table)).parent : 0;
|
|
3181
|
+
if (table && parent)
|
|
3182
|
+
await append(parent, last, table);
|
|
3183
|
+
else
|
|
3184
|
+
await append(await target(ancestor), last);
|
|
3185
|
+
} else
|
|
3186
|
+
await append(await target(ancestor), last);
|
|
3187
|
+
const replacement = await clone(fmt);
|
|
3188
|
+
while ((await tree.read(block)).first)
|
|
3189
|
+
await append(replacement, (await tree.read(block)).first);
|
|
3190
|
+
await append(block, replacement);
|
|
3191
|
+
const old = await active.indexOf(fmt);
|
|
3192
|
+
await active.splice(old, 1);
|
|
3193
|
+
if (old < bookmark)
|
|
3194
|
+
bookmark--;
|
|
3195
|
+
await active.splice(bookmark, 0, replacement);
|
|
3196
|
+
await stack.splice(await stack.indexOf(fmt), 1);
|
|
3197
|
+
await stack.splice(await stack.indexOf(block) + 1, 0, replacement);
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
const text = async (data) => {
|
|
3201
|
+
if (!data)
|
|
3202
|
+
return;
|
|
3203
|
+
await reconstruct();
|
|
3204
|
+
const [parent, before] = allSpace2(data) ? [await target(), void 0] : await location();
|
|
3205
|
+
const last = before ? (await tree.read(before)).previous : (await tree.read(parent)).last;
|
|
3206
|
+
if (last && (await tree.read(last)).kind === "text") {
|
|
3207
|
+
budget.charge("retainedBytes", data.length * 2);
|
|
3208
|
+
await tree.patch(last, { data: await strings.concat((await tree.read(last)).data, await strings.from(data)) });
|
|
3209
|
+
} else
|
|
3210
|
+
await append(parent, await make("text", "", data), before);
|
|
3211
|
+
};
|
|
3212
|
+
const integration = async (node) => {
|
|
3213
|
+
for await (const a of tree.attributes(node))
|
|
3214
|
+
if (await value(a.name) === "encoding" && ["text/html", "application/xhtml+xml"].includes((await value(a.value)).toLowerCase()))
|
|
3215
|
+
return true;
|
|
3216
|
+
return false;
|
|
3217
|
+
};
|
|
3218
|
+
const activeAnchor = async () => {
|
|
3219
|
+
for (let i = await active.indexOf(0, true) + 1; i < active.length; i++)
|
|
3220
|
+
if ((await meta(await active.get(i))).name === "a")
|
|
3221
|
+
return true;
|
|
3222
|
+
return false;
|
|
3223
|
+
};
|
|
3224
|
+
for (; ; ) {
|
|
3225
|
+
const top = await meta(await current());
|
|
3226
|
+
const raw = top.namespace === "html" && (rawElements.has(top.name) || top.name === "title" || top.name === "textarea") ? top.name : void 0;
|
|
3227
|
+
const token = await tokenizer.next(raw, top.namespace !== "html");
|
|
3228
|
+
if (!token)
|
|
3229
|
+
break;
|
|
3230
|
+
budget.charge("work", stack.length + active.length + 1);
|
|
3231
|
+
if (token.kind === "doctype") {
|
|
3232
|
+
if (mode === "beforeHead")
|
|
3233
|
+
await append(document, await make("doctype", "", token.data), html);
|
|
3234
|
+
continue;
|
|
3235
|
+
}
|
|
3236
|
+
if (token.kind === "comment") {
|
|
3237
|
+
await append(mode === "beforeHead" ? document : await target(), await make("comment", "", token.data), mode === "beforeHead" ? html : void 0);
|
|
3238
|
+
continue;
|
|
3239
|
+
}
|
|
3240
|
+
if (token.kind === "text") {
|
|
3241
|
+
if (mode === "beforeHead") {
|
|
3242
|
+
if (allSpace2(token.data))
|
|
3243
|
+
continue;
|
|
3244
|
+
mode = "body";
|
|
3245
|
+
await stack.push(body);
|
|
3246
|
+
}
|
|
3247
|
+
if (mode === "head" && await current() === head && !allSpace2(token.data)) {
|
|
3248
|
+
mode = "body";
|
|
3249
|
+
await stack.truncate(1);
|
|
3250
|
+
await stack.push(body);
|
|
3251
|
+
}
|
|
3252
|
+
let data = token.data;
|
|
3253
|
+
if ((await meta(await current())).name === "colgroup" && !allSpace2(data)) {
|
|
3254
|
+
let prefix = 0;
|
|
3255
|
+
while ((0, entities_exports.htmlSpace)(data[prefix] ?? "")) {
|
|
3256
|
+
budget.charge("work", 1);
|
|
3257
|
+
prefix++;
|
|
3258
|
+
}
|
|
3259
|
+
if (prefix)
|
|
3260
|
+
await text(data.slice(0, prefix));
|
|
3261
|
+
data = data.slice(prefix);
|
|
3262
|
+
await stack.pop();
|
|
3263
|
+
}
|
|
3264
|
+
if (((await meta(await current())).name === "pre" || (await meta(await current())).name === "textarea" || (await meta(await current())).name === "listing") && (await tree.read(await current())).childCount === 0 && data.startsWith("\n"))
|
|
3265
|
+
data = data.slice(1);
|
|
3266
|
+
if ((await meta(await current())).namespace === "html" && !rawElements.has((await meta(await current())).name))
|
|
3267
|
+
data = data.includes("\0") ? data.replaceAll("\0", "") : data;
|
|
3268
|
+
await text(data);
|
|
3269
|
+
continue;
|
|
3270
|
+
}
|
|
3271
|
+
let t = token;
|
|
3272
|
+
const name = t.name;
|
|
3273
|
+
if ((await meta(await current())).namespace === "html" && (await meta(await current())).name === "colgroup" && name !== "col" && name !== "template" && name !== "colgroup")
|
|
3274
|
+
await stack.pop();
|
|
3275
|
+
if (t.kind === "start" && captionBreakingElements.has(name)) {
|
|
3276
|
+
const caption = await inScope(["caption"]);
|
|
3277
|
+
if (caption > 0) {
|
|
3278
|
+
await stack.truncate(caption);
|
|
3279
|
+
await clearFormatting();
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
if (await find("select") >= 0 && !["option", "optgroup", "select", "script", "template"].includes(name)) {
|
|
3283
|
+
if (["input", "keygen", "textarea"].includes(name) && t.kind === "start")
|
|
3284
|
+
await pop("select");
|
|
3285
|
+
else
|
|
3286
|
+
continue;
|
|
3287
|
+
}
|
|
3288
|
+
if (t.kind === "start" && name === "select" && await find("select") >= 0) {
|
|
3289
|
+
await pop("select");
|
|
3290
|
+
continue;
|
|
3291
|
+
}
|
|
3292
|
+
if (t.kind === "start" && name === "html") {
|
|
3293
|
+
await mergeAttributes(html, t.attributes);
|
|
3294
|
+
continue;
|
|
3295
|
+
}
|
|
3296
|
+
if (t.kind === "start" && name === "head" && mode === "beforeHead") {
|
|
3297
|
+
mode = "head";
|
|
3298
|
+
await stack.push(head);
|
|
3299
|
+
await setAttributes(head, t.attributes);
|
|
3300
|
+
continue;
|
|
3301
|
+
}
|
|
3302
|
+
if (name === "head" && mode !== "beforeHead" && !(t.kind === "end" && mode === "head"))
|
|
3303
|
+
continue;
|
|
3304
|
+
if (t.kind === "end" && name === "head") {
|
|
3305
|
+
await stack.truncate(1);
|
|
3306
|
+
mode = "body";
|
|
3307
|
+
await stack.push(body);
|
|
3308
|
+
continue;
|
|
3309
|
+
}
|
|
3310
|
+
if (mode === "beforeHead") {
|
|
3311
|
+
if (t.kind === "start" && headElements.has(name)) {
|
|
3312
|
+
mode = "head";
|
|
3313
|
+
await stack.push(head);
|
|
3314
|
+
} else {
|
|
3315
|
+
mode = "body";
|
|
3316
|
+
await stack.push(body);
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
if (mode === "head" && await current() === head && t.kind === "start" && !headElements.has(name)) {
|
|
3320
|
+
await stack.truncate(1);
|
|
3321
|
+
await stack.push(body);
|
|
3322
|
+
mode = "body";
|
|
3323
|
+
}
|
|
3324
|
+
if (t.kind === "start" && name === "body") {
|
|
3325
|
+
await mergeAttributes(body, t.attributes);
|
|
3326
|
+
continue;
|
|
3327
|
+
}
|
|
3328
|
+
if (t.kind === "end" && name === "br" && (await meta(await current())).namespace === "html")
|
|
3329
|
+
t = { ...t, kind: "start" };
|
|
3330
|
+
if (t.kind === "end") {
|
|
3331
|
+
if (name === "body" || name === "html")
|
|
3332
|
+
continue;
|
|
3333
|
+
if (tableCloseElements.has(name)) {
|
|
3334
|
+
if (await find(name) >= 0) {
|
|
3335
|
+
await closeCell();
|
|
3336
|
+
if (name !== "td" && name !== "th")
|
|
3337
|
+
await pop(name);
|
|
3338
|
+
}
|
|
3339
|
+
continue;
|
|
3340
|
+
}
|
|
3341
|
+
if (name === "form" && await find("template") < 0) {
|
|
3342
|
+
const node2 = form;
|
|
3343
|
+
form = 0;
|
|
3344
|
+
const index = node2 ? await inScope(["form"]) : -1;
|
|
3345
|
+
if (index > 0 && await stack.get(index) === node2)
|
|
3346
|
+
await stack.splice(index, 1);
|
|
3347
|
+
continue;
|
|
3348
|
+
}
|
|
3349
|
+
if (name === "caption") {
|
|
3350
|
+
const index = await inScope(["caption"]);
|
|
3351
|
+
if (index > 0) {
|
|
3352
|
+
await stack.truncate(index);
|
|
3353
|
+
await clearFormatting();
|
|
3354
|
+
}
|
|
3355
|
+
continue;
|
|
3356
|
+
}
|
|
3357
|
+
if (formatting.has(name)) {
|
|
3358
|
+
await adopt(name);
|
|
3359
|
+
continue;
|
|
3360
|
+
}
|
|
3361
|
+
if (name === "template") {
|
|
3362
|
+
await pop(name);
|
|
3363
|
+
await clearFormatting();
|
|
3364
|
+
continue;
|
|
3365
|
+
}
|
|
3366
|
+
if (name === "p" && await inScope(["p"], ["button"]) < 0) {
|
|
3367
|
+
const p = await make("element", "p");
|
|
3368
|
+
await append(await target(), p);
|
|
3369
|
+
continue;
|
|
3370
|
+
}
|
|
3371
|
+
if (headingElements.has(name)) {
|
|
3372
|
+
const index = await inScope(headings);
|
|
3373
|
+
if (index > 0)
|
|
3374
|
+
await stack.truncate(index);
|
|
3375
|
+
continue;
|
|
3376
|
+
}
|
|
3377
|
+
if (blocks.has(name) || endScopeExtraElements.has(name)) {
|
|
3378
|
+
const index = await inScope([name], name === "li" ? ["ol", "ul"] : name === "p" ? ["button"] : []);
|
|
3379
|
+
if (index > 0)
|
|
3380
|
+
await stack.truncate(index);
|
|
3381
|
+
} else {
|
|
3382
|
+
for (let i = stack.length - 1; i > 0; i--) {
|
|
3383
|
+
budget.charge("work", 1);
|
|
3384
|
+
if ((await meta(await stack.get(i))).name.toLowerCase() === name) {
|
|
3385
|
+
await stack.truncate(i);
|
|
3386
|
+
break;
|
|
3387
|
+
}
|
|
3388
|
+
if (await special(await stack.get(i)))
|
|
3389
|
+
break;
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
continue;
|
|
3393
|
+
}
|
|
3394
|
+
let ns = (await meta(await current())).namespace;
|
|
3395
|
+
if (ns === "svg" && ["foreignObject", "desc", "title"].includes((await meta(await current())).name) || ns === "mathml" && ["mi", "mo", "mn", "ms", "mtext"].includes((await meta(await current())).name) && name !== "mglyph" && name !== "malignmark" || ns === "mathml" && (await meta(await current())).name === "annotation-xml" && await integration(await current()))
|
|
3396
|
+
ns = "html";
|
|
3397
|
+
if (ns !== "html" && [
|
|
3398
|
+
"b",
|
|
3399
|
+
"big",
|
|
3400
|
+
"blockquote",
|
|
3401
|
+
"body",
|
|
3402
|
+
"br",
|
|
3403
|
+
"center",
|
|
3404
|
+
"code",
|
|
3405
|
+
"dd",
|
|
3406
|
+
"div",
|
|
3407
|
+
"dl",
|
|
3408
|
+
"dt",
|
|
3409
|
+
"em",
|
|
3410
|
+
"embed",
|
|
3411
|
+
"h1",
|
|
3412
|
+
"h2",
|
|
3413
|
+
"h3",
|
|
3414
|
+
"h4",
|
|
3415
|
+
"h5",
|
|
3416
|
+
"h6",
|
|
3417
|
+
"head",
|
|
3418
|
+
"hr",
|
|
3419
|
+
"i",
|
|
3420
|
+
"img",
|
|
3421
|
+
"li",
|
|
3422
|
+
"listing",
|
|
3423
|
+
"menu",
|
|
3424
|
+
"meta",
|
|
3425
|
+
"nobr",
|
|
3426
|
+
"ol",
|
|
3427
|
+
"p",
|
|
3428
|
+
"pre",
|
|
3429
|
+
"ruby",
|
|
3430
|
+
"s",
|
|
3431
|
+
"small",
|
|
3432
|
+
"span",
|
|
3433
|
+
"strong",
|
|
3434
|
+
"strike",
|
|
3435
|
+
"sub",
|
|
3436
|
+
"sup",
|
|
3437
|
+
"table",
|
|
3438
|
+
"tt",
|
|
3439
|
+
"u",
|
|
3440
|
+
"ul",
|
|
3441
|
+
"var"
|
|
3442
|
+
].includes(name)) {
|
|
3443
|
+
while ((await meta(await current())).namespace !== "html")
|
|
3444
|
+
await stack.pop();
|
|
3445
|
+
ns = "html";
|
|
3446
|
+
}
|
|
3447
|
+
if (name === "svg")
|
|
3448
|
+
ns = "svg";
|
|
3449
|
+
if (name === "math")
|
|
3450
|
+
ns = "mathml";
|
|
3451
|
+
if (ns === "html") {
|
|
3452
|
+
if (["caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"].includes(name) && await find("table") < 0 && await find("template") < 0)
|
|
3453
|
+
continue;
|
|
3454
|
+
if (name === "form" && form && await find("template") < 0)
|
|
3455
|
+
continue;
|
|
3456
|
+
if (blocks.has(name) || name === "table" || name === "hr") {
|
|
3457
|
+
const index = await inScope(["p"], ["button"]);
|
|
3458
|
+
if (index > 0)
|
|
3459
|
+
await stack.truncate(index);
|
|
3460
|
+
}
|
|
3461
|
+
if (name === "li") {
|
|
3462
|
+
const index = await inScope(["li"], ["ol", "ul"]);
|
|
3463
|
+
if (index > 0)
|
|
3464
|
+
await stack.truncate(index);
|
|
3465
|
+
}
|
|
3466
|
+
if (headingElements.has(name) && headingElements.has((await meta(await current())).name))
|
|
3467
|
+
await stack.pop();
|
|
3468
|
+
if (name === "button") {
|
|
3469
|
+
const index = await inScope(["button"]);
|
|
3470
|
+
if (index > 0)
|
|
3471
|
+
await stack.truncate(index);
|
|
3472
|
+
await reconstruct();
|
|
3473
|
+
}
|
|
3474
|
+
if (name === "dt" || name === "dd") {
|
|
3475
|
+
await pop("dt");
|
|
3476
|
+
await pop("dd");
|
|
3477
|
+
}
|
|
3478
|
+
if (name === "option")
|
|
3479
|
+
await pop("option");
|
|
3480
|
+
if (name === "optgroup") {
|
|
3481
|
+
if ((await meta(await current())).name === "option")
|
|
3482
|
+
await stack.pop();
|
|
3483
|
+
if ((await meta(await current())).name === "optgroup")
|
|
3484
|
+
await stack.pop();
|
|
3485
|
+
}
|
|
3486
|
+
if (name === "tr") {
|
|
3487
|
+
await closeCell();
|
|
3488
|
+
await pop("tr");
|
|
3489
|
+
if ((await meta(await current())).name === "table") {
|
|
3490
|
+
const section = await make("element", "tbody");
|
|
3491
|
+
await append(await target(), section);
|
|
3492
|
+
await push(section);
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
if (name === "td" || name === "th") {
|
|
3496
|
+
await closeCell();
|
|
3497
|
+
if ((await meta(await current())).name === "table") {
|
|
3498
|
+
const section = await make("element", "tbody");
|
|
3499
|
+
await append(await target(), section);
|
|
3500
|
+
await push(section);
|
|
3501
|
+
}
|
|
3502
|
+
if (["tbody", "thead", "tfoot"].includes((await meta(await current())).name)) {
|
|
3503
|
+
const row = await make("element", "tr");
|
|
3504
|
+
await append(await target(), row);
|
|
3505
|
+
await push(row);
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
if (name === "tbody" || name === "thead" || name === "tfoot") {
|
|
3509
|
+
await closeCell();
|
|
3510
|
+
await pop("tr");
|
|
3511
|
+
if (["tbody", "thead", "tfoot"].includes((await meta(await current())).name))
|
|
3512
|
+
await stack.pop();
|
|
3513
|
+
}
|
|
3514
|
+
if (name === "col" && (await meta(await current())).name === "table") {
|
|
3515
|
+
const group = await make("element", "colgroup");
|
|
3516
|
+
await append(await target(), group);
|
|
3517
|
+
await push(group);
|
|
3518
|
+
}
|
|
3519
|
+
if (name === "a" && await activeAnchor())
|
|
3520
|
+
await adopt("a");
|
|
3521
|
+
if (formatting.has(name))
|
|
3522
|
+
await reconstruct();
|
|
3523
|
+
}
|
|
3524
|
+
const node = await make("element", ns === "svg" ? svgNames[name] ?? name : name, "", ns);
|
|
3525
|
+
const attributes = t.attributes;
|
|
3526
|
+
budget.charge("retainedBytes", attributes.reduce((sum, a) => sum + 64 + (a.name.length + a.value.length) * 2, 0));
|
|
3527
|
+
if (ns !== "html")
|
|
3528
|
+
for (const a of attributes) {
|
|
3529
|
+
if (ns === "svg")
|
|
3530
|
+
a.name = svgAttributes[a.name] ?? a.name;
|
|
3531
|
+
if (ns === "mathml" && a.name === "definitionurl")
|
|
3532
|
+
a.name = "definitionURL";
|
|
3533
|
+
const colon = a.name.indexOf(":");
|
|
3534
|
+
const prefix = a.name.slice(0, colon);
|
|
3535
|
+
if (colon > 0 && ["xml", "xmlns", "xlink"].includes(prefix))
|
|
3536
|
+
a.namespace = prefix;
|
|
3537
|
+
else if (a.name === "xmlns")
|
|
3538
|
+
a.namespace = "xmlns";
|
|
3539
|
+
}
|
|
3540
|
+
await setAttributes(node, attributes);
|
|
3541
|
+
const [parent, before] = ns === "html" && !tableAllowedElements.has(name) ? await location() : [await target(), void 0];
|
|
3542
|
+
await append(parent, node, before);
|
|
3543
|
+
if (name === "form" && ns === "html" && await find("template") < 0)
|
|
3544
|
+
form = node;
|
|
3545
|
+
if (["caption", "td", "th"].includes(name) && ns === "html")
|
|
3546
|
+
await active.push(0);
|
|
3547
|
+
if (name === "template" && ns === "html") {
|
|
3548
|
+
await tree.patch(node, { templateContents: await make("fragment") });
|
|
3549
|
+
await active.push(0);
|
|
3550
|
+
}
|
|
3551
|
+
if (ns === "html" && voidElements.has(name) || ns !== "html" && t.selfClosing)
|
|
3552
|
+
continue;
|
|
3553
|
+
await push(node);
|
|
3554
|
+
if (ns === "html" && formatting.has(name))
|
|
3555
|
+
await active.push(node);
|
|
3556
|
+
}
|
|
3557
|
+
return document;
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3560
|
+
// packages/safe-bash-command-htmlq/src/stored-selectors.ts
|
|
3561
|
+
function lower(value) {
|
|
3562
|
+
let result = "";
|
|
3563
|
+
for (const c of value) result += c >= "A" && c <= "Z" ? String.fromCharCode(c.charCodeAt(0) + 32) : c;
|
|
3564
|
+
return result;
|
|
3565
|
+
}
|
|
3566
|
+
var StoredQueries = class {
|
|
3567
|
+
constructor(tree, text, storage, budget) {
|
|
3568
|
+
this.tree = tree;
|
|
3569
|
+
this.text = text;
|
|
3570
|
+
this.budget = budget;
|
|
3571
|
+
this.pending = new StoredSequence(storage);
|
|
3572
|
+
}
|
|
3573
|
+
tree;
|
|
3574
|
+
text;
|
|
3575
|
+
budget;
|
|
3576
|
+
pending;
|
|
3577
|
+
async literal(root, expected, insensitive = false, prefix = false) {
|
|
3578
|
+
const length = (await this.text.info(root)).length;
|
|
3579
|
+
this.budget.charge("work", length + expected.length);
|
|
3580
|
+
if (prefix ? length < expected.length : length !== expected.length) return false;
|
|
3581
|
+
let at = 0;
|
|
3582
|
+
if (insensitive) expected = lower(expected);
|
|
3583
|
+
for await (const original of this.text.chunks(root)) {
|
|
3584
|
+
const chunk = insensitive ? lower(original) : original;
|
|
3585
|
+
for (let i = 0; i < chunk.length && at < expected.length; i++, at++) if (chunk[i] !== expected[at]) return false;
|
|
3586
|
+
if (at === expected.length) return true;
|
|
3587
|
+
}
|
|
3588
|
+
return at === expected.length;
|
|
3589
|
+
}
|
|
3590
|
+
async equal(left, right) {
|
|
3591
|
+
if (left === right) return true;
|
|
3592
|
+
if ((await this.text.info(left)).length !== (await this.text.info(right)).length) return false;
|
|
3593
|
+
const a = this.text.chunks(left), b = this.text.chunks(right);
|
|
3594
|
+
let x = "", y = "", ax = 0, by = 0;
|
|
3595
|
+
try {
|
|
3596
|
+
for (; ; ) {
|
|
3597
|
+
if (ax === x.length) {
|
|
3598
|
+
x = (await a.next()).value ?? "";
|
|
3599
|
+
ax = 0;
|
|
3600
|
+
}
|
|
3601
|
+
if (by === y.length) {
|
|
3602
|
+
y = (await b.next()).value ?? "";
|
|
3603
|
+
by = 0;
|
|
3604
|
+
}
|
|
3605
|
+
if (!x || !y) return x === y;
|
|
3606
|
+
const length = Math.min(x.length - ax, y.length - by);
|
|
3607
|
+
this.budget.charge("work", length);
|
|
3608
|
+
if (x.slice(ax, ax + length) !== y.slice(by, by + length)) return false;
|
|
3609
|
+
ax += length;
|
|
3610
|
+
by += length;
|
|
3611
|
+
}
|
|
3612
|
+
} finally {
|
|
3613
|
+
await a.return(void 0);
|
|
3614
|
+
await b.return(void 0);
|
|
3615
|
+
}
|
|
3616
|
+
}
|
|
3617
|
+
async attribute(node, name) {
|
|
3618
|
+
this.budget.charge("work", name.length);
|
|
3619
|
+
this.budget.charge("retainedBytes", name.length * 2);
|
|
3620
|
+
const expected = node.namespace === "html" ? lower(name) : name;
|
|
3621
|
+
for await (const a of this.tree.attributes(node.id)) {
|
|
3622
|
+
this.budget.charge("work", 1);
|
|
3623
|
+
if (a.namespace === "none" && await this.literal(a.name, expected)) return a.value;
|
|
3624
|
+
}
|
|
3625
|
+
return void 0;
|
|
3626
|
+
}
|
|
3627
|
+
async word(root, expected, insensitive = false) {
|
|
3628
|
+
if (!expected) return false;
|
|
3629
|
+
for (const c of expected) if (cssSpace(c)) return false;
|
|
3630
|
+
if (insensitive) expected = lower(expected);
|
|
3631
|
+
let at = 0, matching = true;
|
|
3632
|
+
for await (const original of this.text.chunks(root)) {
|
|
3633
|
+
const chunk = insensitive ? lower(original) : original;
|
|
3634
|
+
this.budget.charge("work", chunk.length);
|
|
3635
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
3636
|
+
const c = chunk[i];
|
|
3637
|
+
if (cssSpace(c)) {
|
|
3638
|
+
if (matching && at === expected.length) return true;
|
|
3639
|
+
at = 0;
|
|
3640
|
+
matching = true;
|
|
3641
|
+
} else {
|
|
3642
|
+
if (c !== expected[at]) matching = false;
|
|
3643
|
+
at++;
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
return matching && at === expected.length;
|
|
3648
|
+
}
|
|
3649
|
+
async contains(root, expected, insensitive) {
|
|
3650
|
+
if (!expected) return false;
|
|
3651
|
+
if (insensitive) expected = lower(expected);
|
|
3652
|
+
let tail = "";
|
|
3653
|
+
for await (const original of this.text.chunks(root)) {
|
|
3654
|
+
const chunk = tail + (insensitive ? lower(original) : original);
|
|
3655
|
+
this.budget.charge("work", chunk.length);
|
|
3656
|
+
if (chunk.includes(expected)) return true;
|
|
3657
|
+
tail = expected.length === 1 ? "" : chunk.slice(-(expected.length - 1));
|
|
3658
|
+
}
|
|
3659
|
+
return false;
|
|
3660
|
+
}
|
|
3661
|
+
async previous(id) {
|
|
3662
|
+
let n = (await this.tree.read(id)).previous;
|
|
3663
|
+
while (n) {
|
|
3664
|
+
const node = await this.tree.read(n);
|
|
3665
|
+
if (node.kind === "element") return n;
|
|
3666
|
+
this.budget.charge("work", 1);
|
|
3667
|
+
n = node.previous;
|
|
3668
|
+
}
|
|
3669
|
+
return 0;
|
|
3670
|
+
}
|
|
3671
|
+
async test(node, test) {
|
|
3672
|
+
const budget = this.budget;
|
|
3673
|
+
budget.charge("work", 1);
|
|
3674
|
+
if (test.kind === "type") {
|
|
3675
|
+
budget.charge("retainedBytes", test.value.length * 2);
|
|
3676
|
+
return test.namespace !== "none" && (test.value === "*" || await this.literal(node.name, node.namespace === "html" ? lower(test.value) : test.value));
|
|
3677
|
+
}
|
|
3678
|
+
if (test.kind === "id") {
|
|
3679
|
+
const value = await this.attribute(node, "id");
|
|
3680
|
+
return value !== void 0 && this.literal(value, test.value);
|
|
3681
|
+
}
|
|
3682
|
+
if (test.kind === "class") return this.word(await this.attribute(node, "class") ?? 0, test.value);
|
|
3683
|
+
if (test.kind === "attribute") {
|
|
3684
|
+
const value = await this.attribute(node, test.value), expected = test.expected;
|
|
3685
|
+
if (value === void 0) return false;
|
|
3686
|
+
switch (test.operator) {
|
|
3687
|
+
case "":
|
|
3688
|
+
return true;
|
|
3689
|
+
case "=":
|
|
3690
|
+
return this.literal(value, expected, test.insensitive);
|
|
3691
|
+
case "^=":
|
|
3692
|
+
return !!expected && this.literal(value, expected, test.insensitive, true);
|
|
3693
|
+
case "$=": {
|
|
3694
|
+
const length = (await this.text.info(value)).length;
|
|
3695
|
+
return !!expected && length >= expected.length && this.literal(await this.text.slice(value, length - expected.length), expected, test.insensitive);
|
|
3696
|
+
}
|
|
3697
|
+
case "*=":
|
|
3698
|
+
return this.contains(value, expected, test.insensitive);
|
|
3699
|
+
case "|=":
|
|
3700
|
+
return await this.literal(value, expected, test.insensitive) || this.literal(value, expected + "-", test.insensitive, true);
|
|
3701
|
+
case "~=":
|
|
3702
|
+
return this.word(value, expected, test.insensitive);
|
|
3703
|
+
default:
|
|
3704
|
+
return false;
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
if (test.kind !== "pseudo") return false;
|
|
3708
|
+
const p = test.value;
|
|
3709
|
+
if (p === "not") return !await this.matches(node.id, test.negated);
|
|
3710
|
+
if (p === "root" || p === "scope") return !!node.parent && (await this.tree.read(node.parent)).kind === "document";
|
|
3711
|
+
if (p === "any-link" || p === "link") return node.namespace === "html" && (await this.literal(node.name, "a") || await this.literal(node.name, "area") || await this.literal(node.name, "link")) && await this.attribute(node, "href") !== void 0;
|
|
3712
|
+
if (p === "empty") {
|
|
3713
|
+
for await (const child of this.tree.children(node.id)) {
|
|
3714
|
+
budget.charge("work", 1);
|
|
3715
|
+
const n = await this.tree.read(child);
|
|
3716
|
+
if (n.kind === "element" || n.kind === "text" && (await this.text.info(n.data)).length > 0) return false;
|
|
3717
|
+
}
|
|
3718
|
+
return true;
|
|
3719
|
+
}
|
|
3720
|
+
if (["visited", "active", "focus", "hover", "enabled", "disabled", "checked", "indeterminate"].includes(p)) return false;
|
|
3721
|
+
let index = 0, count = 0;
|
|
3722
|
+
if (node.parent) for await (const child of this.tree.children(node.parent)) {
|
|
3723
|
+
budget.charge("work", 1);
|
|
3724
|
+
const n = await this.tree.read(child);
|
|
3725
|
+
if (n.kind !== "element" || p.includes("of-type") && (n.namespace !== node.namespace || !await this.equal(n.name, node.name))) continue;
|
|
3726
|
+
count++;
|
|
3727
|
+
if (child === node.id) index = count;
|
|
3728
|
+
}
|
|
3729
|
+
if (!index) return false;
|
|
3730
|
+
if (p.startsWith("first-")) return index === 1;
|
|
3731
|
+
if (p.startsWith("last-")) return index === count;
|
|
3732
|
+
if (p.startsWith("only-")) return count === 1;
|
|
3733
|
+
if (p.includes("last")) index = count - index + 1;
|
|
3734
|
+
const delta = index - test.b;
|
|
3735
|
+
return test.a === 0 ? delta === 0 : delta / test.a >= 0 && delta % test.a === 0;
|
|
3736
|
+
}
|
|
3737
|
+
async matches(id, program) {
|
|
3738
|
+
const marker = this.pending.length;
|
|
3739
|
+
const push = async (node, at, depth, axis) => {
|
|
3740
|
+
await this.pending.push(node);
|
|
3741
|
+
await this.pending.push(at);
|
|
3742
|
+
await this.pending.push(depth);
|
|
3743
|
+
await this.pending.push(axis);
|
|
3744
|
+
};
|
|
3745
|
+
try {
|
|
3746
|
+
for (const parts of program) {
|
|
3747
|
+
await push(id, parts.length - 1, 0, 0);
|
|
3748
|
+
while (this.pending.length > marker) {
|
|
3749
|
+
const axis = await this.pending.pop(), depth = await this.pending.pop(), at = await this.pending.pop();
|
|
3750
|
+
const node = await this.tree.read(await this.pending.pop());
|
|
3751
|
+
if (axis < 0) {
|
|
3752
|
+
const next2 = axis === -2 ? await this.previous(node.id) : node.parent;
|
|
3753
|
+
if (next2) await push(next2, at, depth, -axis);
|
|
3754
|
+
continue;
|
|
3755
|
+
}
|
|
3756
|
+
if (axis > 0) await push(node.id, at, depth, -axis);
|
|
3757
|
+
if (axis === 1) this.budget.charge("work", 1);
|
|
3758
|
+
this.budget.bound("depth", depth);
|
|
3759
|
+
this.budget.charge("work", 1);
|
|
3760
|
+
if (node.kind !== "element") continue;
|
|
3761
|
+
let matches = true;
|
|
3762
|
+
for (const test of parts[at].tests) if (!await this.test(node, test)) {
|
|
3763
|
+
matches = false;
|
|
3764
|
+
break;
|
|
3765
|
+
}
|
|
3766
|
+
if (!matches) continue;
|
|
3767
|
+
if (!at) return true;
|
|
3768
|
+
const relation = parts[at].relation;
|
|
3769
|
+
const next = relation === "+" || relation === "~" ? await this.previous(node.id) : node.parent;
|
|
3770
|
+
if (next) await push(next, at - 1, depth + 1, relation === "~" ? 2 : relation === ">" || relation === "+" ? 0 : 1);
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
return false;
|
|
3774
|
+
} finally {
|
|
3775
|
+
await this.pending.truncate(marker);
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
};
|
|
3779
|
+
function selectStoredHtml(root, selector, tree, text, storage, options) {
|
|
3780
|
+
const budget = new HtmlBudget(options), program = new SelectorParser(selector, budget).list();
|
|
3781
|
+
const query = new StoredQueries(tree, text, storage, budget);
|
|
3782
|
+
return (async function* () {
|
|
3783
|
+
let id = root, start = true, depth = 0;
|
|
3784
|
+
while (id) {
|
|
3785
|
+
budget.charge("work", 1);
|
|
3786
|
+
budget.bound("depth", depth);
|
|
3787
|
+
const node = await tree.read(id), entering = start;
|
|
3788
|
+
if (start) {
|
|
3789
|
+
if (node.first) {
|
|
3790
|
+
id = node.first;
|
|
3791
|
+
depth++;
|
|
3792
|
+
} else start = false;
|
|
3793
|
+
} else {
|
|
3794
|
+
if (id === root) return;
|
|
3795
|
+
if (node.next) {
|
|
3796
|
+
id = node.next;
|
|
3797
|
+
start = true;
|
|
3798
|
+
} else {
|
|
3799
|
+
id = node.parent;
|
|
3800
|
+
depth = Math.max(0, depth - 1);
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3803
|
+
if (entering) {
|
|
3804
|
+
budget.charge("work", 1);
|
|
3805
|
+
if (node.kind === "element" && await query.matches(node.id, program)) yield node.id;
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
})();
|
|
3809
|
+
}
|
|
3810
|
+
|
|
3811
|
+
// packages/safe-bash-command-htmlq/src/stored-serializer.ts
|
|
3812
|
+
async function knownName(text, name) {
|
|
3813
|
+
if ((await text.info(name)).length > 32) return "";
|
|
3814
|
+
let value = "";
|
|
3815
|
+
for await (const chunk of text.chunks(name)) value += chunk;
|
|
3816
|
+
return value;
|
|
3817
|
+
}
|
|
3818
|
+
async function storedWhitespace(text, root) {
|
|
3819
|
+
for await (const chunk of text.chunks(root)) if (!rustWhitespaceOnly(chunk)) return false;
|
|
3820
|
+
return true;
|
|
3821
|
+
}
|
|
3822
|
+
async function* escaped2(text, root, attribute2) {
|
|
3823
|
+
for await (const chunk of text.chunks(root)) {
|
|
3824
|
+
let result = "";
|
|
3825
|
+
for (const c of chunk) result += c === "&" ? "&" : c === "\xA0" ? " " : attribute2 && c === '"' ? """ : !attribute2 && c === "<" ? "<" : !attribute2 && c === ">" ? ">" : c;
|
|
3826
|
+
yield result;
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
async function* serializeStoredHtml(root, tree, text, options, mode = "normalized") {
|
|
3830
|
+
const budget = new HtmlBudget(options);
|
|
3831
|
+
let id = root, entering = true, depth = 0, indent = 0, previousWasBlock = false;
|
|
3832
|
+
function* newline() {
|
|
3833
|
+
yield "\n";
|
|
3834
|
+
for (let remaining = indent; remaining > 0; remaining -= 2048) yield " ".repeat(Math.min(2048, remaining));
|
|
3835
|
+
}
|
|
3836
|
+
while (id) {
|
|
3837
|
+
budget.charge("work", 1);
|
|
3838
|
+
budget.bound("depth", depth);
|
|
3839
|
+
budget.bound("retainedBytes", (depth + 1) * 32);
|
|
3840
|
+
const node = await tree.read(id), name = await knownName(text, node.name);
|
|
3841
|
+
let close = node.kind === "element";
|
|
3842
|
+
if (entering) {
|
|
3843
|
+
if (node.kind === "text") {
|
|
3844
|
+
let emit = true;
|
|
3845
|
+
if (mode === "pretty") {
|
|
3846
|
+
budget.charge("work", (await text.info(node.data)).length);
|
|
3847
|
+
emit = !await storedWhitespace(text, node.data);
|
|
3848
|
+
if (emit) {
|
|
3849
|
+
if (previousWasBlock) yield* newline();
|
|
3850
|
+
previousWasBlock = false;
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
if (emit) {
|
|
3854
|
+
const parent = node.parent ? await tree.read(node.parent) : void 0;
|
|
3855
|
+
if (parent?.namespace === "html" && rawElements.has(await knownName(text, parent.name))) yield* text.chunks(node.data);
|
|
3856
|
+
else yield* escaped2(text, node.data, false);
|
|
3857
|
+
}
|
|
3858
|
+
} else if (node.kind === "comment") {
|
|
3859
|
+
yield "<!--";
|
|
3860
|
+
yield* text.chunks(node.data);
|
|
3861
|
+
yield "-->";
|
|
3862
|
+
} else if (node.kind === "doctype") {
|
|
3863
|
+
yield "<!DOCTYPE ";
|
|
3864
|
+
yield* text.chunks(node.data);
|
|
3865
|
+
yield ">";
|
|
3866
|
+
} else {
|
|
3867
|
+
if (node.kind === "element") {
|
|
3868
|
+
if (mode === "pretty") {
|
|
3869
|
+
if (!inlineElements.has(name) || previousWasBlock) yield* newline();
|
|
3870
|
+
indent += 2;
|
|
3871
|
+
}
|
|
3872
|
+
yield "<";
|
|
3873
|
+
yield* text.chunks(node.name);
|
|
3874
|
+
for await (const a of tree.attributes(id)) {
|
|
3875
|
+
yield " ";
|
|
3876
|
+
yield* text.chunks(a.name);
|
|
3877
|
+
yield '="';
|
|
3878
|
+
yield* escaped2(text, a.value, true);
|
|
3879
|
+
yield '"';
|
|
3880
|
+
}
|
|
3881
|
+
yield ">";
|
|
3882
|
+
if (node.namespace === "html" && voidElements.has(name)) {
|
|
3883
|
+
close = false;
|
|
3884
|
+
if (mode === "pretty") {
|
|
3885
|
+
indent -= 2;
|
|
3886
|
+
previousWasBlock = !inlineElements.has(name);
|
|
3887
|
+
if (previousWasBlock) yield* newline();
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
if ((close || node.kind !== "element") && node.first) {
|
|
3892
|
+
id = node.first;
|
|
3893
|
+
depth++;
|
|
3894
|
+
entering = true;
|
|
3895
|
+
continue;
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
if (close) {
|
|
3900
|
+
if (mode === "pretty") {
|
|
3901
|
+
indent -= 2;
|
|
3902
|
+
previousWasBlock = !inlineElements.has(name);
|
|
3903
|
+
if (previousWasBlock) yield* newline();
|
|
3904
|
+
}
|
|
3905
|
+
yield "</";
|
|
3906
|
+
yield* text.chunks(node.name);
|
|
3907
|
+
yield ">";
|
|
3908
|
+
}
|
|
3909
|
+
if (id === root) return;
|
|
3910
|
+
if (node.next) {
|
|
3911
|
+
id = node.next;
|
|
3912
|
+
entering = true;
|
|
3913
|
+
} else {
|
|
3914
|
+
id = node.parent;
|
|
3915
|
+
depth--;
|
|
3916
|
+
entering = false;
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3921
|
+
// packages/safe-bash-command-htmlq/src/stored-project.ts
|
|
3922
|
+
function baseUrl2(value) {
|
|
3923
|
+
try {
|
|
3924
|
+
return new URL(value);
|
|
3925
|
+
} catch {
|
|
3926
|
+
return void 0;
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3929
|
+
async function* projectStoredHtmlq(source, args, options, storage) {
|
|
3930
|
+
const budget = new HtmlBudget(options);
|
|
3931
|
+
let operations = 0, characters = 0;
|
|
3932
|
+
const tree = new DocumentStore(storage, () => {
|
|
3933
|
+
budget.check();
|
|
3934
|
+
if (++operations % 2048 === 0) return yieldTurn3(options.signal);
|
|
3935
|
+
});
|
|
3936
|
+
const text = new TextStore(storage, async (count) => {
|
|
3937
|
+
characters += count;
|
|
3938
|
+
if (characters >= 4096) {
|
|
3939
|
+
characters = 0;
|
|
3940
|
+
await yieldTurn3(options.signal);
|
|
3941
|
+
}
|
|
3942
|
+
budget.check();
|
|
3943
|
+
});
|
|
3944
|
+
const document = await parseStoredHtml(source, tree, text, storage, options);
|
|
3945
|
+
const query = new StoredQueries(tree, text, storage, budget);
|
|
3946
|
+
const string = async (id) => {
|
|
3947
|
+
let result = "";
|
|
3948
|
+
for await (const chunk of text.chunks(id)) result += chunk;
|
|
3949
|
+
return result;
|
|
3950
|
+
};
|
|
3951
|
+
let base = baseUrl2(args.base);
|
|
3952
|
+
if (args.detectBase) {
|
|
3953
|
+
for await (const first of selectStoredHtml(document, "base", tree, text, storage, options)) {
|
|
3954
|
+
base = baseUrl2(await string(await query.attribute(await tree.read(first), "href") ?? 0)) ?? base;
|
|
3955
|
+
break;
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
const selected = selectStoredHtml(document, args.selector, tree, text, storage, options);
|
|
3959
|
+
let removal = "";
|
|
3960
|
+
if (args.removeNodes.length) {
|
|
3961
|
+
removal = args.removeNodes.join(",");
|
|
3962
|
+
budget.charge("retainedBytes", removal.length * 2);
|
|
3963
|
+
try {
|
|
3964
|
+
selectStoredHtml(document, removal, tree, text, storage, options);
|
|
3965
|
+
} catch (error) {
|
|
3966
|
+
if (!(error instanceof HtmlError) || error.code !== "E_SELECTOR") throw error;
|
|
3967
|
+
removal = "";
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3970
|
+
const snapshot = new StoredSequence(storage), matches = new StoredSequence(storage);
|
|
3971
|
+
if (removal) for await (const node of selected) {
|
|
3972
|
+
budget.charge("retainedBytes", 8);
|
|
3973
|
+
await snapshot.push(node);
|
|
3974
|
+
}
|
|
3975
|
+
async function* nodes() {
|
|
3976
|
+
if (!removal) {
|
|
3977
|
+
yield* selected;
|
|
3978
|
+
return;
|
|
3979
|
+
}
|
|
3980
|
+
for (let i = 0; i < snapshot.length; i++) yield await snapshot.get(i);
|
|
3981
|
+
}
|
|
3982
|
+
async function* descendants(root) {
|
|
3983
|
+
let id = root, depth = 0;
|
|
3984
|
+
while (id) {
|
|
3985
|
+
const node = await tree.read(id);
|
|
3986
|
+
budget.charge("work", 1);
|
|
3987
|
+
budget.bound("depth", depth);
|
|
3988
|
+
yield id;
|
|
3989
|
+
if (node.first) {
|
|
3990
|
+
id = node.first;
|
|
3991
|
+
depth++;
|
|
3992
|
+
continue;
|
|
3993
|
+
}
|
|
3994
|
+
while (id !== root && !(await tree.read(id)).next) {
|
|
3995
|
+
id = (await tree.read(id)).parent;
|
|
3996
|
+
depth--;
|
|
3997
|
+
}
|
|
3998
|
+
if (id === root) return;
|
|
3999
|
+
id = (await tree.read(id)).next;
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
const encoder = new TextEncoder();
|
|
4003
|
+
async function* output(value) {
|
|
4004
|
+
let pending = "";
|
|
4005
|
+
for (const c of value) {
|
|
4006
|
+
budget.charge("work", 1);
|
|
4007
|
+
if (pending.length + c.length > 2048) {
|
|
4008
|
+
budget.charge("retainedBytes", pending.length * 3);
|
|
4009
|
+
const bytes = encoder.encode(pending);
|
|
4010
|
+
budget.charge("outputBytes", bytes.length);
|
|
4011
|
+
yield bytes;
|
|
4012
|
+
budget.check();
|
|
4013
|
+
pending = "";
|
|
4014
|
+
}
|
|
4015
|
+
budget.charge("retainedBytes", c.length * 2);
|
|
4016
|
+
pending += c;
|
|
4017
|
+
}
|
|
4018
|
+
if (pending) {
|
|
4019
|
+
budget.charge("retainedBytes", pending.length * 3);
|
|
4020
|
+
const bytes = encoder.encode(pending);
|
|
4021
|
+
budget.charge("outputBytes", bytes.length);
|
|
4022
|
+
yield bytes;
|
|
4023
|
+
budget.check();
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
let index = 0;
|
|
4027
|
+
for await (const id of nodes()) {
|
|
4028
|
+
if (index++ % 64 === 0) {
|
|
4029
|
+
await yieldTurn3(options.signal);
|
|
4030
|
+
budget.check();
|
|
4031
|
+
}
|
|
4032
|
+
if (removal) {
|
|
4033
|
+
let ancestor = id;
|
|
4034
|
+
for (; ; ) {
|
|
4035
|
+
const parent = (await tree.read(ancestor)).parent;
|
|
4036
|
+
if (!parent) break;
|
|
4037
|
+
budget.charge("work", 1);
|
|
4038
|
+
ancestor = parent;
|
|
4039
|
+
}
|
|
4040
|
+
if (ancestor !== document) continue;
|
|
4041
|
+
await matches.truncate(0);
|
|
4042
|
+
let removedRoot = false;
|
|
4043
|
+
for await (const match of selectStoredHtml(id, removal, tree, text, storage, options)) {
|
|
4044
|
+
budget.charge("retainedBytes", 8);
|
|
4045
|
+
await matches.push(match);
|
|
4046
|
+
if (match === id) removedRoot = true;
|
|
4047
|
+
}
|
|
4048
|
+
for (let i = 0; i < matches.length; i++) {
|
|
4049
|
+
const match = await matches.get(i), parent = (await tree.read(match)).parent;
|
|
4050
|
+
const count = parent ? (await tree.read(parent)).childCount : 0;
|
|
4051
|
+
budget.charge("work", parent ? count : 1);
|
|
4052
|
+
budget.charge("retainedBytes", count * 8);
|
|
4053
|
+
await tree.detach(match);
|
|
4054
|
+
}
|
|
4055
|
+
if (removedRoot) continue;
|
|
4056
|
+
}
|
|
4057
|
+
const node = await tree.read(id);
|
|
4058
|
+
if (base && node.namespace === "html" && ["a", "area", "link"].includes(await knownName(text, node.name))) {
|
|
4059
|
+
for await (const a of tree.attributes(id)) {
|
|
4060
|
+
if (a.namespace !== "none" || !await query.literal(a.name, "href")) continue;
|
|
4061
|
+
const href = await string(a.value);
|
|
4062
|
+
budget.charge("work", href.length + base.href.length);
|
|
4063
|
+
let value;
|
|
4064
|
+
if (href.startsWith("////")) {
|
|
4065
|
+
let i = 0;
|
|
4066
|
+
while (href[i] === "/") i++;
|
|
4067
|
+
value = href.slice(i);
|
|
4068
|
+
} else {
|
|
4069
|
+
try {
|
|
4070
|
+
value = new URL(href, base).href;
|
|
4071
|
+
} catch {
|
|
4072
|
+
value = base.href;
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4075
|
+
budget.charge("work", node.attributeCount + value.length);
|
|
4076
|
+
budget.charge("retainedBytes", node.attributeCount * 64 + value.length * 2);
|
|
4077
|
+
await tree.replaceAttribute(a.id, await text.from(value));
|
|
4078
|
+
break;
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
if (args.attributes.length) {
|
|
4082
|
+
for (const name of args.attributes) {
|
|
4083
|
+
budget.charge("work", node.attributeCount + name.length);
|
|
4084
|
+
for await (const a of tree.attributes(id)) {
|
|
4085
|
+
if (a.namespace !== "none" || !await query.literal(a.name, name)) continue;
|
|
4086
|
+
for await (const chunk of text.chunks(a.value)) yield* output(chunk);
|
|
4087
|
+
yield* output("\n");
|
|
4088
|
+
break;
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
} else if (args.text) {
|
|
4092
|
+
for await (const descendant of descendants(id)) {
|
|
4093
|
+
const n = await tree.read(descendant);
|
|
4094
|
+
if (n.kind !== "text") continue;
|
|
4095
|
+
budget.charge("work", (await text.info(n.data)).length);
|
|
4096
|
+
if (args.ignoreWhitespace && await storedWhitespace(text, n.data)) continue;
|
|
4097
|
+
for await (const chunk of text.chunks(n.data)) yield* output(chunk);
|
|
4098
|
+
if (args.ignoreWhitespace) yield* output("\n");
|
|
4099
|
+
}
|
|
4100
|
+
yield* output("\n");
|
|
4101
|
+
} else {
|
|
4102
|
+
for await (const piece of serializeStoredHtml(id, tree, text, options, args.pretty ? "pretty" : "normalized")) yield* output(piece);
|
|
4103
|
+
yield* output("\n");
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
}
|
|
4107
|
+
|
|
4108
|
+
// packages/safe-bash-command-htmlq/src/staged-output.ts
|
|
4109
|
+
import { normalizePath } from "@poe-platform/safe-fs/core";
|
|
4110
|
+
async function publishStagedHtmlq(fs, path, source, signal) {
|
|
4111
|
+
const target = await fs.prepareStagingResolution(normalizePath(path), { signal });
|
|
4112
|
+
target.validate();
|
|
4113
|
+
if (target.destination && target.destination.type !== "file")
|
|
4114
|
+
throw new HtmlError("E_UNSUPPORTED", "Output must be a regular VFS file");
|
|
4115
|
+
let stage;
|
|
4116
|
+
let failure;
|
|
4117
|
+
try {
|
|
4118
|
+
const parentPath = target.path.slice(0, target.path.lastIndexOf("/"));
|
|
4119
|
+
stage = await fs.createStagedFile(
|
|
4120
|
+
`${parentPath}/.htmlq-${crypto.randomUUID()}`,
|
|
4121
|
+
"output",
|
|
4122
|
+
{ type: "file", data: new Uint8Array() },
|
|
4123
|
+
{
|
|
4124
|
+
parent: target.parent,
|
|
4125
|
+
retainCleanup: true,
|
|
4126
|
+
signal,
|
|
4127
|
+
mode: target.destination ? target.destination.mode & 4095 : 438
|
|
4128
|
+
}
|
|
4129
|
+
);
|
|
4130
|
+
if (!stage.writer || !stage.cleanup)
|
|
4131
|
+
throw new HtmlError("E_UNSUPPORTED", "Output requires retained staging handles");
|
|
4132
|
+
signal.throwIfAborted();
|
|
4133
|
+
for await (const bytes of source) {
|
|
4134
|
+
for (let offset = 0; offset < bytes.length; offset += 16384) {
|
|
4135
|
+
signal.throwIfAborted();
|
|
4136
|
+
await stage.writer.write(bytes.slice(offset, offset + 16384), { signal });
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4139
|
+
const stat = await stage.writer.finish({ signal });
|
|
4140
|
+
signal.throwIfAborted();
|
|
4141
|
+
target.validate();
|
|
4142
|
+
await fs.publishStagedFile({ ...stage, file: { ...stage.file, stat } }, target.path, {
|
|
4143
|
+
parent: target.parent,
|
|
4144
|
+
destination: target.destination,
|
|
4145
|
+
ancestors: target.ancestors,
|
|
4146
|
+
commitGuard: target.validate,
|
|
4147
|
+
preserveIdentity: target.destination !== null,
|
|
4148
|
+
signal
|
|
4149
|
+
});
|
|
4150
|
+
} catch (error) {
|
|
4151
|
+
failure = { error };
|
|
4152
|
+
}
|
|
4153
|
+
const cleanupErrors = [];
|
|
4154
|
+
if (stage?.cleanup) {
|
|
4155
|
+
try {
|
|
4156
|
+
await stage.cleanup.remove();
|
|
4157
|
+
} catch (error) {
|
|
4158
|
+
cleanupErrors.push(error);
|
|
4159
|
+
}
|
|
4160
|
+
try {
|
|
4161
|
+
await stage.cleanup.close();
|
|
4162
|
+
} catch (error) {
|
|
4163
|
+
cleanupErrors.push(error);
|
|
4164
|
+
}
|
|
4165
|
+
} else if (stage) {
|
|
4166
|
+
try {
|
|
4167
|
+
await fs.removeStagedFile(stage);
|
|
4168
|
+
} catch (error) {
|
|
4169
|
+
cleanupErrors.push(error);
|
|
4170
|
+
}
|
|
4171
|
+
}
|
|
4172
|
+
if (cleanupErrors.length) {
|
|
4173
|
+
if (failure) cleanupErrors.unshift(failure.error);
|
|
4174
|
+
throw new AggregateError(cleanupErrors, "htmlq staged output cleanup failed");
|
|
4175
|
+
}
|
|
4176
|
+
if (failure) throw failure.error;
|
|
4177
|
+
}
|
|
4178
|
+
|
|
4179
|
+
// packages/safe-bash-command-htmlq/src/command.ts
|
|
4180
|
+
function admittedLimits(overrides = {}) {
|
|
4181
|
+
const limits = { ...defaultHtmlLimits, ...overrides };
|
|
4182
|
+
for (const name of Object.keys(defaultHtmlLimits)) {
|
|
4183
|
+
if (limits[name] === void 0) limits[name] = defaultHtmlLimits[name];
|
|
4184
|
+
const value = limits[name];
|
|
4185
|
+
if (value !== Infinity && (!Number.isSafeInteger(value) || value < 0))
|
|
4186
|
+
throw new HtmlError("E_LIMIT", "Limits must be nonnegative safe integers or Infinity", 0, name);
|
|
4187
|
+
}
|
|
4188
|
+
return Object.freeze(limits);
|
|
4189
|
+
}
|
|
4190
|
+
function cancellationReason(error, signal, seen = /* @__PURE__ */ new Set()) {
|
|
4191
|
+
if (error instanceof HtmlCancellationError && error.signal === signal) return signal.reason;
|
|
4192
|
+
if (!(error instanceof AggregateError) || seen.has(error)) return error;
|
|
4193
|
+
seen.add(error);
|
|
4194
|
+
const errors = error.errors.map((failure) => cancellationReason(failure, signal, seen));
|
|
4195
|
+
seen.delete(error);
|
|
4196
|
+
return errors.some((failure, index) => !Object.is(failure, error.errors[index])) ? new AggregateError(errors, error.message, { cause: error }) : error;
|
|
4197
|
+
}
|
|
4198
|
+
async function htmlq(context, configuration = {}) {
|
|
4199
|
+
const sdkArgv = configuration.argv;
|
|
4200
|
+
const controller = new AbortController();
|
|
2459
4201
|
const abort = () => controller.abort(context.signal.reason);
|
|
2460
4202
|
const consumerAbort = () => controller.abort(stdout?.signal.reason);
|
|
2461
4203
|
const options = invocationOptions({
|
|
@@ -2464,6 +4206,7 @@ async function htmlq(context, configuration = {}) {
|
|
|
2464
4206
|
});
|
|
2465
4207
|
const budget = new HtmlBudget(options);
|
|
2466
4208
|
let stdout, stderr;
|
|
4209
|
+
let storage;
|
|
2467
4210
|
let task = Promise.resolve(void 0), closing;
|
|
2468
4211
|
let accepting = true;
|
|
2469
4212
|
const cleanup = () => {
|
|
@@ -2473,7 +4216,7 @@ async function htmlq(context, configuration = {}) {
|
|
|
2473
4216
|
await Promise.allSettled([task]);
|
|
2474
4217
|
context.signal.removeEventListener("abort", abort);
|
|
2475
4218
|
stdout?.signal.removeEventListener("abort", consumerAbort);
|
|
2476
|
-
const results = await Promise.allSettled([stdout?.close(), stderr?.close()]);
|
|
4219
|
+
const results = await Promise.allSettled([stdout?.close(), stderr?.close(), storage?.close()]);
|
|
2477
4220
|
const failures = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
2478
4221
|
if (failures.length) throw new AggregateError(failures, "htmlq output cleanup failed");
|
|
2479
4222
|
});
|
|
@@ -2619,7 +4362,8 @@ async function htmlq(context, configuration = {}) {
|
|
|
2619
4362
|
};
|
|
2620
4363
|
}
|
|
2621
4364
|
};
|
|
2622
|
-
|
|
4365
|
+
storage = new PagedStorage({ ...context, signal: options.signal }, 16);
|
|
4366
|
+
const rendered = projectStoredHtmlq(admittedInput, args, options, storage);
|
|
2623
4367
|
if (args.output === "-") {
|
|
2624
4368
|
if (options.limits.outputBytes === Infinity && options.limits.retainedBytes === Infinity) {
|
|
2625
4369
|
const batch = new Uint8Array(16384);
|
|
@@ -2654,10 +4398,11 @@ async function htmlq(context, configuration = {}) {
|
|
|
2654
4398
|
}
|
|
2655
4399
|
} else {
|
|
2656
4400
|
const path = args.output.startsWith("/") ? args.output : `${context.cwd}/${args.output}`;
|
|
2657
|
-
const caps = await context.fs.capabilitiesFor?.(path, { signal: options.signal }) ?? context.fs.capabilities;
|
|
4401
|
+
const caps = await context.fs.capabilitiesFor?.(path, { signal: options.signal, stagingResolution: true }) ?? context.fs.capabilities;
|
|
2658
4402
|
const streaming = caps.atomicFilePublication ? context.fs.publishFileConditional : void 0;
|
|
4403
|
+
const staged = caps.atomicFileStaging && caps.atomicStagedFileMutation && caps.atomicStagingAncestry && caps.retainedStagingWrite && caps.retainedStagingCleanup && caps.synchronousStagingResolution && caps.guardedStagingPublication && context.fs.prepareStagingResolution && context.fs.createStagedFile && context.fs.publishStagedFile && context.fs.removeStagedFile;
|
|
2659
4404
|
const buffered = caps.atomicFileMutation || caps.trustedOwnedStaging ? context.fs.writeFileConditional : void 0;
|
|
2660
|
-
if (caps.write === false || caps.readOnly || !streaming && !buffered)
|
|
4405
|
+
if (caps.write === false || caps.readOnly || !streaming && !staged && !buffered)
|
|
2661
4406
|
throw new HtmlError(
|
|
2662
4407
|
"E_UNSUPPORTED",
|
|
2663
4408
|
"Output requires atomic conditional VFS publication"
|
|
@@ -2680,6 +4425,8 @@ async function htmlq(context, configuration = {}) {
|
|
|
2680
4425
|
signal: options.signal,
|
|
2681
4426
|
maxBytes: options.limits.outputBytes
|
|
2682
4427
|
});
|
|
4428
|
+
} else if (staged) {
|
|
4429
|
+
await publishStagedHtmlq(context.fs, path, rendered, options.signal);
|
|
2683
4430
|
} else {
|
|
2684
4431
|
const chunks = [];
|
|
2685
4432
|
let size = 0;
|
|
@@ -2732,7 +4479,7 @@ async function htmlq(context, configuration = {}) {
|
|
|
2732
4479
|
try {
|
|
2733
4480
|
result = await task;
|
|
2734
4481
|
} catch (error) {
|
|
2735
|
-
failure = { error };
|
|
4482
|
+
failure = { error: cancellationReason(error, options.signal) };
|
|
2736
4483
|
}
|
|
2737
4484
|
try {
|
|
2738
4485
|
await cleanup();
|