@poe-platform/safe-bash 0.1.806 → 0.1.807
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/README.md +4 -0
- package/dist/image-ast/portable.d.ts +8 -0
- package/dist/image-ast/portable.js +2 -0
- package/dist/safe-bash/chunks/{chunk-KRA6WK4Z.js → chunk-3Y54SR4R.js} +6 -6
- package/dist/safe-bash/chunks/{chunk-OYJI4L4J.js → chunk-PPAA3LJS.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-SCROOJV7.js → chunk-XZ2Y4RWC.js} +2 -2
- package/dist/safe-bash/command-chunks/{biff-AU4VGVMD-6EQ64QPG.js → biff-YBHP7ZES-M7TU7NA5.js} +1211 -1205
- package/dist/safe-bash/command-chunks/chunk-2A6TBB4F.js +14 -0
- package/dist/safe-bash/command-chunks/chunk-2AF7J6FE.js +372 -0
- package/dist/safe-bash/command-chunks/{chunk-AITNVBXO.js → chunk-2ANW3FXH.js} +4 -4
- package/dist/safe-bash/command-chunks/chunk-2B6XWO6A.js +730 -0
- package/dist/safe-bash/command-chunks/chunk-2BKOSQD3.js +11 -0
- package/dist/safe-bash/command-chunks/chunk-2EUH5B6A.js +127 -0
- package/dist/safe-bash/command-chunks/chunk-2FOLUJLI.js +400 -0
- package/dist/safe-bash/command-chunks/{chunk-CZLX3KVF.js → chunk-2GILUQJY.js} +4 -6
- package/dist/safe-bash/command-chunks/chunk-2HHGDJ7J.js +280 -0
- package/dist/safe-bash/command-chunks/chunk-2NE2GPSF.js +546 -0
- package/dist/safe-bash/command-chunks/chunk-2P7BLWWI.js +272 -0
- package/dist/safe-bash/command-chunks/chunk-2PSVE7I5.js +101 -0
- package/dist/safe-bash/command-chunks/chunk-2UUFZMOH.js +503 -0
- package/dist/safe-bash/command-chunks/chunk-2VGAC6S6.js +393 -0
- package/dist/safe-bash/command-chunks/chunk-2W54TAGI.js +162 -0
- package/dist/safe-bash/command-chunks/chunk-326A5G42.js +328 -0
- package/dist/safe-bash/command-chunks/chunk-36KIT4DU.js +218 -0
- package/dist/safe-bash/command-chunks/chunk-3CHQG25N.js +455 -0
- package/dist/safe-bash/command-chunks/chunk-3JQ3RF2O.js +72 -0
- package/dist/safe-bash/command-chunks/chunk-3MLJWSYL.js +92 -0
- package/dist/safe-bash/command-chunks/{chunk-ASYR2LU7.js → chunk-3RQCLLQA.js} +5 -5
- package/dist/safe-bash/command-chunks/chunk-3SEQG5JH.js +521 -0
- package/dist/safe-bash/command-chunks/chunk-3SWT2KYH.js +78 -0
- package/dist/safe-bash/command-chunks/chunk-3VETFXYR.js +170 -0
- package/dist/safe-bash/command-chunks/chunk-3W6PTHHB.js +65 -0
- package/dist/safe-bash/command-chunks/chunk-457CU3IC.js +8 -0
- package/dist/safe-bash/command-chunks/chunk-45BW6MGM.js +250 -0
- package/dist/safe-bash/command-chunks/chunk-47MFDPH4.js +419 -0
- package/dist/safe-bash/command-chunks/chunk-4ATHODCG.js +444 -0
- package/dist/safe-bash/command-chunks/chunk-4DJICIFV.js +227 -0
- package/dist/safe-bash/command-chunks/chunk-4FNQPK7C.js +385 -0
- package/dist/safe-bash/command-chunks/chunk-4LXDJES2.js +65 -0
- package/dist/safe-bash/command-chunks/chunk-4QRXKUD2.js +662 -0
- package/dist/safe-bash/command-chunks/chunk-4QYNOBWZ.js +455 -0
- package/dist/safe-bash/command-chunks/{chunk-MWNWT6HG.js → chunk-4XFFIKA3.js} +5 -5
- package/dist/safe-bash/command-chunks/chunk-5AU5ENL5.js +180 -0
- package/dist/safe-bash/command-chunks/chunk-5DFZAJHL.js +324 -0
- package/dist/safe-bash/command-chunks/chunk-5GEFJROP.js +270 -0
- package/dist/safe-bash/command-chunks/chunk-5HWX4XYW.js +263 -0
- package/dist/safe-bash/command-chunks/chunk-5LKNP4IF.js +872 -0
- package/dist/safe-bash/command-chunks/chunk-5OEHUIVE.js +240 -0
- package/dist/safe-bash/command-chunks/chunk-6EHVFKM7.js +171 -0
- package/dist/safe-bash/command-chunks/chunk-6JTPLJ3B.js +155 -0
- package/dist/safe-bash/command-chunks/chunk-6KLUPQ65.js +496 -0
- package/dist/safe-bash/command-chunks/chunk-6NS5RXQ7.js +285 -0
- package/dist/safe-bash/command-chunks/chunk-6PJIQEH4.js +3472 -0
- package/dist/safe-bash/command-chunks/chunk-763ECQWB.js +566 -0
- package/dist/safe-bash/command-chunks/chunk-7DADVPKN.js +23 -0
- package/dist/safe-bash/command-chunks/chunk-7LEADSSA.js +164 -0
- package/dist/safe-bash/command-chunks/chunk-7MMSBVUP.js +732 -0
- package/dist/safe-bash/command-chunks/chunk-7OXNWLSL.js +35 -0
- package/dist/safe-bash/command-chunks/chunk-7PZASWL6.js +354 -0
- package/dist/safe-bash/command-chunks/{chunk-ZBR3UH4P.js → chunk-7QH3WAMQ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-CB3HTIDK.js → chunk-7SOE7XIS.js} +11 -11
- package/dist/safe-bash/command-chunks/chunk-7Y3ZQ6FE.js +56 -0
- package/dist/safe-bash/command-chunks/chunk-A2YEQYCC.js +289 -0
- package/dist/safe-bash/command-chunks/chunk-A3XE767Q.js +502 -0
- package/dist/safe-bash/command-chunks/{chunk-MWY75E3F.js → chunk-A6LCBGE6.js} +187 -187
- package/dist/safe-bash/command-chunks/{chunk-HFUL6E5I.js → chunk-A7CE4EIU.js} +33 -151
- package/dist/safe-bash/command-chunks/chunk-A7EMM3SB.js +297 -0
- package/dist/safe-bash/command-chunks/{chunk-G3YO3JIN.js → chunk-ABH5FMMA.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-AEJZEGW7.js +1376 -0
- package/dist/safe-bash/command-chunks/chunk-AELXRNM6.js +207 -0
- package/dist/safe-bash/command-chunks/chunk-AEZIPWRI.js +260 -0
- package/dist/safe-bash/command-chunks/{chunk-AHD3CGAY.js → chunk-AFPXADZG.js} +4 -4
- package/dist/safe-bash/command-chunks/chunk-AIOB34IX.js +201 -0
- package/dist/safe-bash/command-chunks/chunk-AJEYCC4X.js +262 -0
- package/dist/safe-bash/command-chunks/chunk-ALMHXDKZ.js +321 -0
- package/dist/safe-bash/command-chunks/chunk-AQ6RTM2M.js +309 -0
- package/dist/safe-bash/command-chunks/chunk-AQNFEGMZ.js +481 -0
- package/dist/safe-bash/command-chunks/{chunk-2AKKYY5G.js → chunk-ASZ4EMKE.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-AYJGINE5.js +144 -0
- package/dist/safe-bash/command-chunks/{chunk-MRFW2E6B.js → chunk-B4UWZCQR.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-BDYKJTBQ.js +43 -0
- package/dist/safe-bash/command-chunks/chunk-BERVTMQB.js +41 -0
- package/dist/safe-bash/command-chunks/chunk-BZOY2UMP.js +275 -0
- package/dist/safe-bash/command-chunks/{chunk-W47KIMSP.js → chunk-C2EYJT4S.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-CK5Q6RDE.js +342 -0
- package/dist/safe-bash/command-chunks/chunk-CKEODJVT.js +992 -0
- package/dist/safe-bash/command-chunks/{chunk-Z7UIOPHJ.js → chunk-DCMSPMMD.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-DE66JRWJ.js +352 -0
- package/dist/safe-bash/command-chunks/chunk-DKNNYPOI.js +409 -0
- package/dist/safe-bash/command-chunks/chunk-DV745GFU.js +294 -0
- package/dist/safe-bash/command-chunks/chunk-DXX2Z2QA.js +33 -0
- package/dist/safe-bash/command-chunks/chunk-E7AYF54A.js +473 -0
- package/dist/safe-bash/command-chunks/chunk-EDSFQJAU.js +159 -0
- package/dist/safe-bash/command-chunks/{chunk-UQ3KEUCF.js → chunk-ESD5ZD74.js} +7 -1
- package/dist/safe-bash/command-chunks/chunk-EUXUCRCI.js +1739 -0
- package/dist/safe-bash/command-chunks/chunk-F2ORFLCH.js +3669 -0
- package/dist/safe-bash/command-chunks/chunk-FANIWOBM.js +311 -0
- package/dist/safe-bash/command-chunks/chunk-FOO3AXFK.js +47 -0
- package/dist/safe-bash/command-chunks/chunk-FRZ5P5AB.js +131 -0
- package/dist/safe-bash/command-chunks/chunk-FZSQMMYV.js +276 -0
- package/dist/safe-bash/command-chunks/{chunk-P6NUIMMX.js → chunk-G5F2VSQ7.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-GGOZXIGH.js +299 -0
- package/dist/safe-bash/command-chunks/chunk-GIESJLR2.js +241 -0
- package/dist/safe-bash/command-chunks/chunk-GLPIFP7N.js +385 -0
- package/dist/safe-bash/command-chunks/chunk-GZ2N24A2.js +342 -0
- package/dist/safe-bash/command-chunks/chunk-H2NWPMNW.js +216 -0
- package/dist/safe-bash/command-chunks/chunk-HHLVI2CB.js +3949 -0
- package/dist/safe-bash/command-chunks/chunk-HJDE7ZNV.js +82 -0
- package/dist/safe-bash/command-chunks/chunk-HOAM3F5I.js +124 -0
- package/dist/safe-bash/command-chunks/chunk-HPKUFWHW.js +482 -0
- package/dist/safe-bash/command-chunks/chunk-HPMVMOD2.js +109 -0
- package/dist/safe-bash/command-chunks/chunk-HQAHDJPX.js +8 -0
- package/dist/safe-bash/command-chunks/chunk-HR2Y6YEP.js +12 -0
- package/dist/safe-bash/command-chunks/chunk-HUNXIAOL.js +62 -0
- package/dist/safe-bash/command-chunks/chunk-I4JWZOSP.js +244 -0
- package/dist/safe-bash/command-chunks/chunk-I6AMDG2T.js +85 -0
- package/dist/safe-bash/command-chunks/chunk-IB2Q5CL3.js +288 -0
- package/dist/safe-bash/command-chunks/chunk-IFNLDOJ4.js +316 -0
- package/dist/safe-bash/command-chunks/chunk-IKHBXETN.js +174 -0
- package/dist/safe-bash/command-chunks/chunk-IOSWG5JS.js +228 -0
- package/dist/safe-bash/command-chunks/chunk-IQFRPIXH.js +317 -0
- package/dist/safe-bash/command-chunks/chunk-IR6ZKAUH.js +582 -0
- package/dist/safe-bash/command-chunks/chunk-IW7PEB4I.js +297 -0
- package/dist/safe-bash/command-chunks/chunk-JGGRMERW.js +36 -0
- package/dist/safe-bash/command-chunks/chunk-JHAY3KYC.js +520 -0
- package/dist/safe-bash/command-chunks/{chunk-UO25D4WG.js → chunk-JITDS55R.js} +22 -22
- package/dist/safe-bash/command-chunks/chunk-JJK3CU7Z.js +6 -0
- package/dist/safe-bash/command-chunks/{chunk-XKZWUMH4.js → chunk-JN7GNI2C.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-JQ3EJKHF.js +160 -0
- package/dist/safe-bash/command-chunks/chunk-JQE256UO.js +292 -0
- package/dist/safe-bash/command-chunks/chunk-JQZ3BXWY.js +382 -0
- package/dist/safe-bash/command-chunks/{chunk-7DLR4HCC.js → chunk-JWSOFSGI.js} +22 -22
- package/dist/safe-bash/command-chunks/chunk-K3CDZMUN.js +168 -0
- package/dist/safe-bash/command-chunks/{chunk-SUYSZJI3.js → chunk-K5COUQAQ.js} +4 -4
- package/dist/safe-bash/command-chunks/chunk-K7HUXUN2.js +489 -0
- package/dist/safe-bash/command-chunks/chunk-KB3CY3QO.js +62 -0
- package/dist/safe-bash/command-chunks/chunk-KCBVOYAY.js +92 -0
- package/dist/safe-bash/command-chunks/chunk-KD25ICP4.js +366 -0
- package/dist/safe-bash/command-chunks/chunk-KDKQ5D55.js +180 -0
- package/dist/safe-bash/command-chunks/chunk-KNKDUEDW.js +521 -0
- package/dist/safe-bash/command-chunks/chunk-KR2PQ7GD.js +174 -0
- package/dist/safe-bash/command-chunks/chunk-KS6WUDPM.js +153 -0
- package/dist/safe-bash/command-chunks/{chunk-XFHUSZBM.js → chunk-KUGV3SSL.js} +5 -5
- package/dist/safe-bash/command-chunks/chunk-L2JAP5KO.js +249 -0
- package/dist/safe-bash/command-chunks/chunk-L2KEA6SN.js +271 -0
- package/dist/safe-bash/command-chunks/chunk-L3WY5ASN.js +526 -0
- package/dist/safe-bash/command-chunks/chunk-L4XEXXVQ.js +399 -0
- package/dist/safe-bash/command-chunks/chunk-LDTUZIJK.js +90 -0
- package/dist/safe-bash/command-chunks/chunk-LHDB4QO5.js +479 -0
- package/dist/safe-bash/command-chunks/chunk-LHL6RWGJ.js +548 -0
- package/dist/safe-bash/command-chunks/chunk-LHRXDH45.js +164 -0
- package/dist/safe-bash/command-chunks/chunk-LQOKYG3O.js +153 -0
- package/dist/safe-bash/command-chunks/chunk-LRDME6WV.js +12 -0
- package/dist/safe-bash/command-chunks/chunk-LWVDJB5S.js +305 -0
- package/dist/safe-bash/command-chunks/chunk-M57GLLK4.js +27 -0
- package/dist/safe-bash/command-chunks/chunk-MAHX3IW3.js +108 -0
- package/dist/safe-bash/command-chunks/{chunk-LQZSR6DT.js → chunk-MDV7W5AS.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-MG7AJD5E.js +168 -0
- package/dist/safe-bash/command-chunks/chunk-MHJ3DQUE.js +213 -0
- package/dist/safe-bash/command-chunks/chunk-MLGNBD7V.js +552 -0
- package/dist/safe-bash/command-chunks/chunk-MN2M33JK.js +237 -0
- package/dist/safe-bash/command-chunks/chunk-MOL3TRBT.js +32 -0
- package/dist/safe-bash/command-chunks/chunk-MQFXMBGD.js +75 -0
- package/dist/safe-bash/command-chunks/chunk-MQPWE22J.js +171 -0
- package/dist/safe-bash/command-chunks/chunk-MQU6Q75R.js +523 -0
- package/dist/safe-bash/command-chunks/chunk-MWAAMNAM.js +353 -0
- package/dist/safe-bash/command-chunks/chunk-MZ4BTMTI.js +240 -0
- package/dist/safe-bash/command-chunks/chunk-N4DY4FPA.js +679 -0
- package/dist/safe-bash/command-chunks/chunk-N74TJL6X.js +183 -0
- package/dist/safe-bash/command-chunks/chunk-NA5Q4V2H.js +304 -0
- package/dist/safe-bash/command-chunks/chunk-NSM366N6.js +22 -0
- package/dist/safe-bash/command-chunks/chunk-NY4ZPV3N.js +523 -0
- package/dist/safe-bash/command-chunks/chunk-NYBF2BVE.js +17 -0
- package/dist/safe-bash/command-chunks/chunk-OBK24KGM.js +24 -0
- package/dist/safe-bash/command-chunks/{chunk-GDAS4LY7.js → chunk-OEKLEUUW.js} +4 -4
- package/dist/safe-bash/command-chunks/chunk-OGWJD5QP.js +404 -0
- package/dist/safe-bash/command-chunks/chunk-OIPATOZW.js +154 -0
- package/dist/safe-bash/command-chunks/chunk-OP6J3OLL.js +243 -0
- package/dist/safe-bash/command-chunks/chunk-OTTMIB3C.js +266 -0
- package/dist/safe-bash/command-chunks/{chunk-OZHPB4KD.js → chunk-OU4VE5CR.js} +12 -12
- package/dist/safe-bash/command-chunks/chunk-P42REFYL.js +228 -0
- package/dist/safe-bash/command-chunks/{chunk-YJ3TFZB2.js → chunk-PQOAM5SC.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-PQOIOVF2.js +444 -0
- package/dist/safe-bash/command-chunks/chunk-PRQEVUNE.js +205 -0
- package/dist/safe-bash/command-chunks/{chunk-W5OR7COJ.js → chunk-PVLPWVRH.js} +21 -21
- package/dist/safe-bash/command-chunks/{chunk-BNG4ZMZ3.js → chunk-PXL4NBYP.js} +1 -78
- package/dist/safe-bash/command-chunks/chunk-Q6W5FRZG.js +41 -0
- package/dist/safe-bash/command-chunks/{chunk-KLCHCSIV.js → chunk-QGD64UHJ.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-QHS7PDG3.js +188 -0
- package/dist/safe-bash/command-chunks/chunk-QXCSASIE.js +151 -0
- package/dist/safe-bash/command-chunks/chunk-QYCBVKFT.js +255 -0
- package/dist/safe-bash/command-chunks/chunk-R4TYL2G6.js +1529 -0
- package/dist/safe-bash/command-chunks/chunk-RAXJVM4U.js +625 -0
- package/dist/safe-bash/command-chunks/chunk-RBFZYSZZ.js +207 -0
- package/dist/safe-bash/command-chunks/chunk-RJHVJZ4H.js +185 -0
- package/dist/safe-bash/command-chunks/chunk-RKPPUYZE.js +213 -0
- package/dist/safe-bash/command-chunks/chunk-RMJNV6Q7.js +23 -0
- package/dist/safe-bash/command-chunks/{chunk-MR2RLUPV.js → chunk-RQHQCJMV.js} +11 -9
- package/dist/safe-bash/command-chunks/chunk-RR6QQ25D.js +71 -0
- package/dist/safe-bash/command-chunks/{chunk-JW3KIZU6.js → chunk-RUXY7GN5.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-RZC7QHL6.js +112 -0
- package/dist/safe-bash/command-chunks/chunk-RZJRR4UJ.js +1677 -0
- package/dist/safe-bash/command-chunks/chunk-S4OBYRNI.js +639 -0
- package/dist/safe-bash/command-chunks/{chunk-DQNDEWCI.js → chunk-S65T5JJO.js} +12 -12
- package/dist/safe-bash/command-chunks/chunk-S6PPBBXX.js +77 -0
- package/dist/safe-bash/command-chunks/chunk-SCG4LK5U.js +265 -0
- package/dist/safe-bash/command-chunks/chunk-SDTC2BLK.js +143 -0
- package/dist/safe-bash/command-chunks/chunk-SEK43FRN.js +357 -0
- package/dist/safe-bash/command-chunks/chunk-SH45NZ2P.js +194 -0
- package/dist/safe-bash/command-chunks/chunk-SM733XRT.js +250 -0
- package/dist/safe-bash/command-chunks/chunk-SSRGI476.js +116 -0
- package/dist/safe-bash/command-chunks/chunk-SUUD352U.js +127 -0
- package/dist/safe-bash/command-chunks/{chunk-B5F2KQYA.js → chunk-SWUVHT7G.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-TBAH4XGI.js +38 -0
- package/dist/safe-bash/command-chunks/chunk-TBVWTZTR.js +469 -0
- package/dist/safe-bash/command-chunks/chunk-TGHQGJNR.js +144 -0
- package/dist/safe-bash/command-chunks/{chunk-Q6JLT2EY.js → chunk-TL3KDYEM.js} +8 -110
- package/dist/safe-bash/command-chunks/chunk-TVAEX4WQ.js +473 -0
- package/dist/safe-bash/command-chunks/chunk-TZ2J6LGM.js +163 -0
- package/dist/safe-bash/command-chunks/chunk-UICO7H6S.js +186 -0
- package/dist/safe-bash/command-chunks/chunk-UJTJFMIN.js +501 -0
- package/dist/safe-bash/command-chunks/chunk-UMWWCLBG.js +109 -0
- package/dist/safe-bash/command-chunks/chunk-UPXFSGQG.js +134 -0
- package/dist/safe-bash/command-chunks/chunk-UWUYSXYT.js +272 -0
- package/dist/safe-bash/command-chunks/{chunk-5FMXQUDY.js → chunk-UZOGSYJP.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-V3RGA5PS.js +125 -0
- package/dist/safe-bash/command-chunks/chunk-VEUQWV2V.js +287 -0
- package/dist/safe-bash/command-chunks/chunk-VGKYTZT5.js +161 -0
- package/dist/safe-bash/command-chunks/chunk-VQUEIEVP.js +410 -0
- package/dist/safe-bash/command-chunks/chunk-VU3YUC3U.js +169 -0
- package/dist/safe-bash/command-chunks/chunk-W32KW66B.js +27 -0
- package/dist/safe-bash/command-chunks/chunk-W543LSYH.js +899 -0
- package/dist/safe-bash/command-chunks/chunk-W5YFDYHO.js +387 -0
- package/dist/safe-bash/command-chunks/chunk-W6DV2CLS.js +267 -0
- package/dist/safe-bash/command-chunks/chunk-WAKYUXVQ.js +215 -0
- package/dist/safe-bash/command-chunks/chunk-WGOL3MM6.js +125 -0
- package/dist/safe-bash/command-chunks/{chunk-N2A7V3WY.js → chunk-WHNYT34N.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-WOZCIRJ5.js +169 -0
- package/dist/safe-bash/command-chunks/chunk-WVB6ONZS.js +232 -0
- package/dist/safe-bash/command-chunks/chunk-WVESNAND.js +25 -0
- package/dist/safe-bash/command-chunks/chunk-XDEA3TL5.js +322 -0
- package/dist/safe-bash/command-chunks/chunk-XFEUWSYG.js +357 -0
- package/dist/safe-bash/command-chunks/chunk-XFMJ4RMS.js +2849 -0
- package/dist/safe-bash/command-chunks/chunk-XH6DXJHX.js +196 -0
- package/dist/safe-bash/command-chunks/chunk-XNJ67APB.js +6 -0
- package/dist/safe-bash/command-chunks/chunk-XP6BHGZ6.js +227 -0
- package/dist/safe-bash/command-chunks/chunk-XXFHTGV2.js +142 -0
- package/dist/safe-bash/command-chunks/chunk-Y5GI5PVT.js +139 -0
- package/dist/safe-bash/command-chunks/chunk-Y6KHC3JB.js +177 -0
- package/dist/safe-bash/command-chunks/{chunk-2UWPMSME.js → chunk-Y72LPXST.js} +8 -8
- package/dist/safe-bash/command-chunks/chunk-YDRWQZNB.js +69 -0
- package/dist/safe-bash/command-chunks/{chunk-P4OJBL2B.js → chunk-YFZ6FPIC.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-YH4DC4RP.js +171 -0
- package/dist/safe-bash/command-chunks/chunk-YH7KKMMN.js +463 -0
- package/dist/safe-bash/command-chunks/{chunk-MN3BB4WW.js → chunk-YP3WWV5N.js} +4 -4
- package/dist/safe-bash/command-chunks/chunk-YPVBU7QF.js +2817 -0
- package/dist/safe-bash/command-chunks/chunk-YQYVEVUE.js +1621 -0
- package/dist/safe-bash/command-chunks/chunk-YRNBIU5U.js +175 -0
- package/dist/safe-bash/command-chunks/chunk-Z7ESJVFP.js +10 -0
- package/dist/safe-bash/command-chunks/chunk-ZTAFAHY3.js +653 -0
- package/dist/safe-bash/command-chunks/chunk-ZXKOMB24.js +85 -0
- package/dist/safe-bash/command-chunks/{clipboard-XCSQACOK-SHFXT53F.js → clipboard-6SDGQGC3-TVJ3CG7A.js} +4 -4
- package/dist/safe-bash/command-chunks/{command-engine-4TEGTXCQ.js → command-engine-KMLHVFMA.js} +356 -316
- package/dist/safe-bash/command-chunks/{engine-QDC5VCGO-LYAAFESF.js → engine-EOYR2WTY-KUFLFTDE.js} +2 -4
- package/dist/safe-bash/command-chunks/{gnumeric-OCFH63UT-YI7SG7TN.js → gnumeric-ABKSRBZJ-MPIIPXKP.js} +3 -3
- package/dist/safe-bash/command-chunks/inspection-command-ULEU7ZVV.js +7 -0
- package/dist/safe-bash/command-chunks/model-store-JUFU3RSW.js +54 -0
- package/dist/safe-bash/command-chunks/pdf-22JDKKAR-UDWNSWYB.js +338 -0
- package/dist/safe-bash/command-chunks/{pptx-XG3YSXWZ-XAG36NAB.js → pptx-YDKHIGCD-H7FU4VMJ.js} +2 -2
- package/dist/safe-bash/commands/bc/index.browser.js +2 -2
- package/dist/safe-bash/commands/diffpdf/index.d.ts +2 -0
- package/dist/safe-bash/commands/diffpdf/index.js +2 -0
- package/dist/safe-bash/commands/dot/index.d.ts +2 -0
- package/dist/safe-bash/commands/dot/index.js +2 -0
- package/dist/safe-bash/commands/llm/collections.browser.js +6 -0
- package/dist/safe-bash/commands/llm/collections.d.ts +2 -0
- package/dist/safe-bash/commands/llm/collections.js +2 -0
- package/dist/safe-bash/commands/pandoc/index.browser.js +1 -1
- package/dist/safe-bash/commands/rsvg-convert/index.d.ts +2 -0
- package/dist/safe-bash/commands/rsvg-convert/index.js +2 -0
- package/dist/safe-bash/commands/safejs/io.d.ts +1 -1
- package/dist/safe-bash/commands/safejs/io.js +1 -1
- package/dist/safe-bash/commands/safejs/options.d.ts +1 -1
- package/dist/safe-bash/commands/safejs/options.js +1 -1
- package/dist/safe-bash/commands/safejs/render.d.ts +1 -1
- package/dist/safe-bash/commands/safejs/render.js +1 -1
- package/dist/safe-bash/commands/safejs/runtime.d.ts +1 -1
- package/dist/safe-bash/commands/safejs/runtime.js +1 -1
- package/dist/safe-bash/commands/safejs/types.d.ts +1 -1
- package/dist/safe-bash/commands/safejs/types.js +1 -1
- package/dist/safe-bash/commands/wdiff/index.d.ts +2 -0
- package/dist/safe-bash/commands/wdiff/index.js +2 -0
- package/dist/safe-bash/core.d.ts +4 -0
- package/dist/safe-bash/core.js +4 -0
- package/dist/safe-bash/full-core.browser.js +59 -35
- package/dist/safe-bash/optional-host.browser.js +7 -7
- package/dist/safe-bash/plugins/index.browser.js +7 -7
- package/dist/safe-bash/registry-entry.browser.js +6 -6
- package/dist/safe-bash/search.browser.js +2 -2
- package/dist/safe-bash/shell-entry.browser.js +3 -3
- package/dist/safe-bash-checksum-engine/index.js +83 -40
- package/dist/safe-bash-checksum-engine/md5.d.ts +2 -0
- package/dist/safe-bash-checksum-engine/md5.js +7 -0
- package/dist/safe-bash-command-awk/awk-inspection.js +2 -2
- package/dist/safe-bash-command-awk/awk-runtime.js +2 -2
- package/dist/safe-bash-command-awk/awk.js +7 -7
- package/dist/safe-bash-command-awk/index.js +7 -7
- package/dist/safe-bash-command-chmod/command.js +1 -1
- package/dist/safe-bash-command-chmod/index.js +1 -1
- package/dist/safe-bash-command-csvkit/index.js +6 -6
- package/dist/safe-bash-command-diff/index.js +3 -3
- package/dist/safe-bash-command-diffpdf/LICENSE +21 -0
- package/dist/safe-bash-command-diffpdf/index.d.ts +12 -0
- package/dist/safe-bash-command-diffpdf/index.js +107 -0
- package/dist/safe-bash-command-docx/command.d.ts +36 -0
- package/dist/{safe-bash-docx-engine → safe-bash-command-docx}/discovery.d.ts +4 -4
- package/dist/safe-bash-command-docx/index.js +1 -1
- package/dist/{safe-bash-docx-engine → safe-bash-command-docx}/inspection-command.d.ts +6 -6
- package/dist/safe-bash-command-docx/sdk.d.ts +4 -0
- package/dist/safe-bash-command-docx/sdk.js +24 -0
- package/dist/safe-bash-command-dot/LICENSE +21 -0
- package/dist/safe-bash-command-dot/index.d.ts +14 -0
- package/dist/safe-bash-command-dot/index.js +1298 -0
- package/dist/safe-bash-command-du/arguments.d.ts +1 -1
- package/dist/safe-bash-command-du/arguments.js +1 -1
- 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-factor/command.js +2 -2
- package/dist/safe-bash-command-factor/index.js +2 -2
- package/dist/safe-bash-command-ffmpeg/index.js +16 -16
- package/dist/safe-bash-command-imagemagick/index.js +21 -53
- package/dist/safe-bash-command-llm/collections-embed.d.ts +23 -0
- package/dist/safe-bash-command-llm/collections.d.ts +38 -0
- package/dist/safe-bash-command-llm/collections.js +423 -0
- package/dist/safe-bash-command-llm/command.js +4 -2
- package/dist/safe-bash-command-llm/index.js +12 -8
- package/dist/safe-bash-command-llm/openai.js +4 -3
- package/dist/safe-bash-command-llm/providers/index.js +6 -4
- package/dist/safe-bash-command-llm/providers/openai.js +4 -3
- package/dist/safe-bash-command-node/commands/node/browser.js +9 -12
- package/dist/safe-bash-command-node/commands/node/buffer.js +2 -2
- package/dist/safe-bash-command-node/commands/node/default-runtime.js +9 -12
- package/dist/safe-bash-command-node/commands/node/filesystem.js +3 -3
- package/dist/safe-bash-command-node/commands/node/safejs.js +9 -12
- package/dist/safe-bash-command-node/commands/node/source-maps.js +2 -2
- package/dist/safe-bash-command-node/commands/node/timers.js +3 -3
- package/dist/safe-bash-command-node/commands/safejs/io.d.ts +1 -35
- package/dist/safe-bash-command-node/commands/safejs/io.js +3 -7
- package/dist/safe-bash-command-node/commands/safejs/options.d.ts +2 -22
- package/dist/safe-bash-command-node/commands/safejs/options.js +1 -1
- package/dist/safe-bash-command-node/commands/safejs/render.d.ts +1 -1
- package/dist/safe-bash-command-node/commands/safejs/render.js +3 -5
- package/dist/safe-bash-command-node/commands/safejs/runtime.d.ts +2 -25
- package/dist/safe-bash-command-node/commands/safejs/runtime.js +1 -7
- package/dist/safe-bash-command-node/commands/safejs/types.d.ts +2 -85
- package/dist/safe-bash-command-node/commands/safejs/types.js +1 -1
- package/dist/safe-bash-command-node/integrations/safejs/filesystem.d.ts +2 -5
- package/dist/safe-bash-command-node/integrations/safejs/filesystem.js +3 -3
- package/dist/safe-bash-command-node/integrations/safejs/shell.js +1 -1
- package/dist/safe-bash-command-node/integrations/safejs/values.d.ts +1 -7
- package/dist/safe-bash-command-node/integrations/safejs/values.js +1 -1
- package/dist/safe-bash-command-openssl/index.js +15452 -420
- package/dist/safe-bash-command-pandoc/command.js +1 -1
- package/dist/safe-bash-command-pandoc/index.js +1 -1
- package/dist/safe-bash-command-patch/index.js +5 -5
- package/dist/safe-bash-command-patch/patch.js +4 -4
- package/dist/safe-bash-command-playwright-cli/index.js +25 -25
- package/dist/safe-bash-command-playwright-cli/playwright/abilities.js +8 -8
- package/dist/safe-bash-command-playwright-cli/playwright/controller.js +16 -16
- package/dist/safe-bash-command-playwright-cli/playwright/index.js +25 -25
- package/dist/safe-bash-command-playwright-cli/playwright/standard-capabilities.js +4 -4
- package/dist/{safe-bash-pptx-engine → safe-bash-command-pptx}/command-engine.d.ts +5 -13
- package/dist/safe-bash-command-pptx/engine.d.ts +4 -0
- package/dist/safe-bash-command-pptx/engine.js +37 -0
- package/dist/safe-bash-command-pptx/index.js +1 -1
- package/dist/safe-bash-command-python/executor.js +15 -15
- package/dist/safe-bash-command-python/index.js +15 -15
- package/dist/safe-bash-command-python/jspi.js +4 -4
- package/dist/safe-bash-command-qrencode/index.js +1 -4
- package/dist/safe-bash-command-rsvg-convert/LICENSE +21 -0
- package/dist/safe-bash-command-rsvg-convert/index.d.ts +13 -0
- package/dist/safe-bash-command-rsvg-convert/index.js +84 -0
- package/dist/safe-bash-command-safejs/LICENSE +21 -0
- package/dist/safe-bash-command-safejs/filesystem.d.ts +5 -0
- package/dist/safe-bash-command-safejs/filesystem.js +7 -0
- package/dist/safe-bash-command-safejs/index.d.ts +4 -0
- package/dist/safe-bash-command-safejs/index.js +19 -0
- package/dist/safe-bash-command-safejs/io.d.ts +35 -0
- package/dist/safe-bash-command-safejs/io.js +12 -0
- package/dist/safe-bash-command-safejs/options.d.ts +22 -0
- package/dist/safe-bash-command-safejs/options.js +11 -0
- package/dist/safe-bash-command-safejs/render.d.ts +1 -0
- package/dist/safe-bash-command-safejs/render.js +9 -0
- package/dist/safe-bash-command-safejs/runtime.d.ts +25 -0
- package/dist/safe-bash-command-safejs/runtime.js +13 -0
- package/dist/safe-bash-command-safejs/types.d.ts +85 -0
- package/dist/safe-bash-command-safejs/types.js +7 -0
- package/dist/safe-bash-command-safejs/values.d.ts +7 -0
- package/dist/safe-bash-command-safejs/values.js +19 -0
- package/dist/safe-bash-command-sips/index.js +1 -14
- package/dist/safe-bash-command-ssconvert/index.js +413 -546
- package/dist/safe-bash-command-ssconvert/rendering/chart/axis.d.ts +1 -26
- package/dist/safe-bash-command-ssconvert/rendering/chart/error-bar.d.ts +1 -39
- package/dist/safe-bash-command-ssconvert/rendering/chart/layout.d.ts +1 -24
- package/dist/safe-bash-command-ssconvert/rendering/chart/line.d.ts +1 -23
- package/dist/safe-bash-command-ssconvert/rendering/chart/marker.d.ts +1 -35
- package/dist/safe-bash-command-ssconvert/rendering/chart/pie.d.ts +1 -32
- package/dist/safe-bash-command-ssconvert/rendering/images/index.d.ts +1 -26
- package/dist/safe-bash-command-ssconvert/rendering/print/header-footer.d.ts +1 -16
- package/dist/safe-bash-command-ssconvert/rendering/print/layout.d.ts +1 -65
- package/dist/safe-bash-command-ssconvert/rendering/print/pagination.d.ts +1 -34
- package/dist/safe-bash-command-tar/create.js +4 -4
- package/dist/safe-bash-command-tar/extract.js +4 -4
- package/dist/safe-bash-command-tar/index.js +16 -14
- package/dist/safe-bash-command-tar/modes.js +6 -6
- package/dist/safe-bash-command-tar/options.d.ts +3 -1
- package/dist/safe-bash-command-tar/options.js +1 -1
- package/dist/safe-bash-command-unzip/index.js +4 -4
- package/dist/safe-bash-command-wdiff/LICENSE +21 -0
- package/dist/safe-bash-command-wdiff/index.d.ts +12 -0
- package/dist/safe-bash-command-wdiff/index.js +123 -0
- package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
- package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
- package/dist/safe-bash-compression-engine/files.js +5 -5
- package/dist/safe-bash-compression-engine/index.js +4 -4
- package/dist/safe-bash-compression-engine/operand.js +5 -5
- package/dist/safe-bash-compression-engine/stream.js +4 -4
- package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
- package/dist/safe-bash-contracts/escaping.js +2 -2
- package/dist/safe-bash-contracts/index.js +15 -15
- package/dist/safe-bash-docx-engine/admission.js +31 -0
- package/dist/safe-bash-docx-engine/ancillary-resources.js +38 -0
- package/dist/safe-bash-docx-engine/archive.js +24 -0
- package/dist/safe-bash-docx-engine/argument-json.js +25 -0
- package/dist/safe-bash-docx-engine/batch-operations.d.ts +7 -0
- package/dist/safe-bash-docx-engine/batch-operations.js +95 -0
- package/dist/safe-bash-docx-engine/batch-result-schema.d.ts +2 -0
- package/dist/safe-bash-docx-engine/batch-result-schema.js +145 -0
- package/dist/safe-bash-docx-engine/batch.js +106 -0
- package/dist/safe-bash-docx-engine/bookmarks.js +43 -0
- package/dist/safe-bash-docx-engine/budget.js +18 -0
- package/dist/safe-bash-docx-engine/charts.js +35 -0
- package/dist/safe-bash-docx-engine/command-option-rules.d.ts +1 -0
- package/dist/safe-bash-docx-engine/command-option-rules.js +24 -0
- package/dist/safe-bash-docx-engine/command-properties.d.ts +1 -0
- package/dist/safe-bash-docx-engine/command-properties.js +18 -0
- package/dist/safe-bash-docx-engine/command-selection.d.ts +1 -0
- package/dist/safe-bash-docx-engine/command-selection.js +15 -0
- package/dist/safe-bash-docx-engine/comments.js +53 -0
- package/dist/safe-bash-docx-engine/control-bindings.js +45 -0
- package/dist/safe-bash-docx-engine/control-repeat.js +46 -0
- package/dist/safe-bash-docx-engine/controls.js +52 -0
- package/dist/safe-bash-docx-engine/create.js +36 -0
- package/dist/safe-bash-docx-engine/diagrams.js +43 -0
- package/dist/safe-bash-docx-engine/diff.js +33 -0
- package/dist/safe-bash-docx-engine/discovery-result-schema.d.ts +72 -0
- package/dist/safe-bash-docx-engine/discovery-result-schema.js +36 -0
- package/dist/safe-bash-docx-engine/document-properties.js +43 -0
- package/dist/safe-bash-docx-engine/equations.js +53 -0
- package/dist/safe-bash-docx-engine/extract.js +40 -0
- package/dist/safe-bash-docx-engine/fields.js +48 -0
- package/dist/safe-bash-docx-engine/font-inventory.js +40 -0
- package/dist/safe-bash-docx-engine/font-resources.js +33 -0
- package/dist/safe-bash-docx-engine/image-batch-operations.d.ts +4 -0
- package/dist/safe-bash-docx-engine/image-batch-operations.js +35 -0
- package/dist/safe-bash-docx-engine/image-insertion.js +46 -0
- package/dist/safe-bash-docx-engine/image-layout.js +43 -0
- package/dist/safe-bash-docx-engine/image-replacement.js +48 -0
- package/dist/safe-bash-docx-engine/images.js +49 -0
- package/dist/safe-bash-docx-engine/index.d.ts +1 -3
- package/dist/safe-bash-docx-engine/index.js +369 -19350
- package/dist/safe-bash-docx-engine/inspection.js +49 -0
- package/dist/safe-bash-docx-engine/invocation.d.ts +50 -0
- package/dist/safe-bash-docx-engine/invocation.js +66 -0
- package/dist/safe-bash-docx-engine/io-errors.js +11 -0
- package/dist/safe-bash-docx-engine/io.js +29 -0
- package/dist/safe-bash-docx-engine/links.js +47 -0
- package/dist/safe-bash-docx-engine/lists.js +46 -0
- package/dist/safe-bash-docx-engine/location-token.js +27 -0
- package/dist/safe-bash-docx-engine/locations.js +39 -0
- package/dist/safe-bash-docx-engine/model-context.js +15 -0
- package/dist/safe-bash-docx-engine/model-errors.js +13 -0
- package/dist/safe-bash-docx-engine/notes.js +48 -0
- package/dist/safe-bash-docx-engine/objects.js +49 -0
- package/dist/safe-bash-docx-engine/operation-json-schema.js +21 -0
- package/dist/safe-bash-docx-engine/operation-schema.js +29 -0
- package/dist/safe-bash-docx-engine/pack-uri-batch-operations.d.ts +3 -0
- package/dist/safe-bash-docx-engine/pack-uri-batch-operations.js +15 -0
- package/dist/safe-bash-docx-engine/pack.js +38 -0
- package/dist/safe-bash-docx-engine/package-view-batch-operations.d.ts +4 -0
- package/dist/safe-bash-docx-engine/package-view-batch-operations.js +47 -0
- package/dist/safe-bash-docx-engine/package-xml.js +25 -0
- package/dist/safe-bash-docx-engine/pandoc-adapter.js +55 -6
- package/dist/safe-bash-docx-engine/paragraph-edit.js +52 -0
- package/dist/safe-bash-docx-engine/part-provider.js +18 -0
- package/dist/safe-bash-docx-engine/property-values.js +46 -0
- package/dist/safe-bash-docx-engine/publication.js +40 -0
- package/dist/safe-bash-docx-engine/removal.js +44 -0
- package/dist/safe-bash-docx-engine/revision-decisions.js +46 -0
- package/dist/safe-bash-docx-engine/revision-edit.js +43 -0
- package/dist/safe-bash-docx-engine/revisions.js +42 -0
- package/dist/safe-bash-docx-engine/run-format.js +43 -0
- package/dist/safe-bash-docx-engine/sanitize.js +59 -0
- package/dist/safe-bash-docx-engine/sections.js +47 -0
- package/dist/safe-bash-docx-engine/settings.js +36 -0
- package/dist/safe-bash-docx-engine/shape-edit.js +47 -0
- package/dist/safe-bash-docx-engine/signatures.js +42 -0
- package/dist/safe-bash-docx-engine/simple-selection.d.ts +1 -1
- package/dist/safe-bash-docx-engine/stories.js +48 -0
- package/dist/safe-bash-docx-engine/structure-model-batch-operations.d.ts +3 -0
- package/dist/safe-bash-docx-engine/structure-model-batch-operations.js +64 -0
- package/dist/safe-bash-docx-engine/style-model-batch-operations.js +57 -0
- package/dist/safe-bash-docx-engine/style-model-result-schema.d.ts +4 -0
- package/dist/safe-bash-docx-engine/style-model-result-schema.js +76 -0
- package/dist/safe-bash-docx-engine/styles.js +44 -0
- package/dist/safe-bash-docx-engine/table-edit.js +52 -0
- package/dist/safe-bash-docx-engine/table-read.js +38 -0
- package/dist/safe-bash-docx-engine/template.js +45 -0
- package/dist/safe-bash-docx-engine/text-replace.js +47 -0
- package/dist/safe-bash-docx-engine/text-resource-read.js +42 -0
- package/dist/safe-bash-docx-engine/text.js +36 -0
- package/dist/safe-bash-docx-engine/validation.js +30 -0
- package/dist/safe-bash-docx-engine/xml-parts.js +48 -0
- package/dist/safe-bash-markdown-engine/index.js +3 -3
- package/dist/safe-bash-network-engine/aggregate.js +3 -3
- package/dist/safe-bash-network-engine/args.js +3 -3
- package/dist/safe-bash-network-engine/body.js +4 -4
- package/dist/safe-bash-network-engine/decode.js +3 -3
- package/dist/safe-bash-network-engine/fetch-transport.js +3 -3
- package/dist/safe-bash-network-engine/index.js +3 -3
- package/dist/safe-bash-network-engine/output.js +3 -3
- package/dist/safe-bash-network-engine/platform-portable.js +3 -3
- package/dist/safe-bash-network-engine/shared.js +2 -2
- package/dist/safe-bash-network-engine/transfer.js +20 -20
- package/dist/safe-bash-pptx-engine/bytes.d.ts +1 -4
- package/dist/safe-bash-pptx-engine/bytes.js +2 -11
- package/dist/safe-bash-pptx-engine/index.d.ts +1 -103
- package/dist/safe-bash-pptx-engine/index.js +1 -662
- package/dist/safe-bash-presentation-engine/LICENSE +21 -0
- package/dist/safe-bash-presentation-engine/accessibility.js +43 -0
- package/dist/safe-bash-presentation-engine/animation-editing.js +29 -0
- package/dist/safe-bash-presentation-engine/animations.js +23 -0
- package/dist/safe-bash-presentation-engine/backgrounds.js +26 -0
- package/dist/safe-bash-presentation-engine/bytes.d.ts +4 -0
- package/dist/safe-bash-presentation-engine/bytes.js +13 -0
- package/dist/safe-bash-presentation-engine/chart-editing.js +60 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-enums.d.ts +2 -2
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-object-operations.d.ts +1 -1
- package/dist/safe-bash-presentation-engine/chart-object-operations.js +35 -0
- package/dist/safe-bash-presentation-engine/charts.js +41 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/color-enums.d.ts +5 -5
- package/dist/safe-bash-presentation-engine/command-placeholder.js +64 -0
- package/dist/safe-bash-presentation-engine/comments.js +32 -0
- package/dist/safe-bash-presentation-engine/connector-operations.js +50 -0
- package/dist/safe-bash-presentation-engine/connectors.js +49 -0
- package/dist/safe-bash-presentation-engine/content-types.js +9 -0
- package/dist/safe-bash-presentation-engine/contracts.js +0 -0
- package/dist/safe-bash-presentation-engine/creation.js +15 -0
- package/dist/safe-bash-presentation-engine/diff.js +40 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/drawing-enums.d.ts +20 -20
- package/dist/safe-bash-presentation-engine/drawing-format.js +44 -0
- package/dist/safe-bash-presentation-engine/drawing-operations.js +41 -0
- package/dist/safe-bash-presentation-engine/drawing-schema.d.ts +1549 -0
- package/dist/safe-bash-presentation-engine/drawing-schema.js +33 -0
- package/dist/safe-bash-presentation-engine/equations.js +30 -0
- package/dist/safe-bash-presentation-engine/errors.js +23 -0
- package/dist/safe-bash-presentation-engine/fields.js +32 -0
- package/dist/safe-bash-presentation-engine/font-metrics.js +12 -0
- package/dist/safe-bash-presentation-engine/image-extraction.js +29 -0
- package/dist/safe-bash-presentation-engine/image-formatting.js +43 -0
- package/dist/safe-bash-presentation-engine/image-insertion.js +26 -0
- package/dist/safe-bash-presentation-engine/image-metadata.d.ts +9 -0
- package/dist/safe-bash-presentation-engine/image-metadata.js +9 -0
- package/dist/safe-bash-presentation-engine/image-replacement.js +30 -0
- package/dist/safe-bash-presentation-engine/image-value.js +15 -0
- package/dist/safe-bash-presentation-engine/images.js +30 -0
- package/dist/safe-bash-presentation-engine/index.d.ts +100 -0
- package/dist/safe-bash-presentation-engine/index.js +791 -0
- package/dist/safe-bash-presentation-engine/layouts.js +31 -0
- package/dist/safe-bash-presentation-engine/length.js +21 -0
- package/dist/safe-bash-presentation-engine/links.js +33 -0
- package/dist/safe-bash-presentation-engine/masters.js +54 -0
- package/dist/safe-bash-presentation-engine/media-editing.js +35 -0
- package/dist/safe-bash-presentation-engine/media-extraction.js +24 -0
- package/dist/safe-bash-presentation-engine/media.js +23 -0
- package/dist/safe-bash-presentation-engine/memberships.js +24 -0
- package/dist/safe-bash-presentation-engine/notes.js +27 -0
- package/dist/safe-bash-presentation-engine/ole-enum.js +10 -0
- package/dist/safe-bash-presentation-engine/ole-insertion.js +29 -0
- package/dist/safe-bash-presentation-engine/opaque-objects.js +21 -0
- package/dist/safe-bash-presentation-engine/package-reader.js +13 -0
- package/dist/safe-bash-presentation-engine/package-tools.js +25 -0
- package/dist/safe-bash-presentation-engine/package-uri.d.ts +13 -0
- package/dist/safe-bash-presentation-engine/package-uri.js +16 -0
- package/dist/safe-bash-presentation-engine/package-writer.js +13 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/presentation-model.d.ts +1 -1
- package/dist/safe-bash-presentation-engine/presentation-model.js +63 -0
- package/dist/safe-bash-presentation-engine/presentation-settings.js +25 -0
- package/dist/safe-bash-presentation-engine/properties.js +37 -0
- package/dist/safe-bash-presentation-engine/publication.d.ts +10 -0
- package/dist/safe-bash-presentation-engine/publication.js +0 -0
- package/dist/safe-bash-presentation-engine/relationships.js +16 -0
- package/dist/safe-bash-presentation-engine/resource-limits.js +8 -0
- package/dist/safe-bash-presentation-engine/sanitize.js +24 -0
- package/dist/safe-bash-presentation-engine/selector-schema.js +7 -0
- package/dist/safe-bash-presentation-engine/selectors.js +26 -0
- package/dist/safe-bash-presentation-engine/shape-groups.js +47 -0
- package/dist/safe-bash-presentation-engine/shape-operations.js +48 -0
- package/dist/safe-bash-presentation-engine/shape-path-operations.js +44 -0
- package/dist/safe-bash-presentation-engine/shape-paths.js +31 -0
- package/dist/safe-bash-presentation-engine/shape-presets.js +11 -0
- package/dist/safe-bash-presentation-engine/shape-selection.js +43 -0
- package/dist/safe-bash-presentation-engine/shape-transforms.js +28 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-types.d.ts +1 -1
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shapes.d.ts +1 -1
- package/dist/safe-bash-presentation-engine/shapes.js +66 -0
- package/dist/safe-bash-presentation-engine/slide-copy.js +24 -0
- package/dist/safe-bash-presentation-engine/slide-import.js +27 -0
- package/dist/safe-bash-presentation-engine/slide-merge-split.js +33 -0
- package/dist/safe-bash-presentation-engine/slide-model.js +74 -0
- package/dist/safe-bash-presentation-engine/slide-removal.js +25 -0
- package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +17 -0
- package/dist/safe-bash-presentation-engine/slides.js +26 -0
- package/dist/safe-bash-presentation-engine/table-operations.js +51 -0
- package/dist/safe-bash-presentation-engine/table-spans.js +42 -0
- package/dist/safe-bash-presentation-engine/tables.js +45 -0
- package/dist/safe-bash-presentation-engine/tags.js +25 -0
- package/dist/safe-bash-presentation-engine/template-bindings.js +44 -0
- package/dist/safe-bash-presentation-engine/template-repeat.js +51 -0
- package/dist/safe-bash-presentation-engine/text-fitting.js +39 -0
- package/dist/safe-bash-presentation-engine/text-frames.js +52 -0
- package/dist/safe-bash-presentation-engine/text-paragraphs.js +58 -0
- package/dist/safe-bash-presentation-engine/text-reading.js +23 -0
- package/dist/safe-bash-presentation-engine/text-replacement.js +24 -0
- package/dist/safe-bash-presentation-engine/text-runs.js +45 -0
- package/dist/safe-bash-presentation-engine/themes.js +31 -0
- package/dist/safe-bash-presentation-engine/transitions.js +27 -0
- package/dist/safe-bash-presentation-engine/validation.js +14 -0
- package/dist/safe-bash-presentation-engine/xml-parts.js +25 -0
- package/dist/safe-bash-presentation-engine/xml-view.js +8 -0
- package/dist/safe-bash-presentation-engine/xml.js +8 -0
- package/dist/safe-bash-sqlite-engine/sqlite-edit-snapshot.d.ts +15 -0
- package/dist/safe-bash-sqlite-engine/sqlite-finalization.d.ts +7 -0
- package/dist/safe-bash-sqlite-engine/sqlite-pages.d.ts +18 -0
- package/dist/safe-bash-sqlite-engine/sqlite-record-read.d.ts +8 -0
- package/dist/safe-bash-sqlite-engine/sqlite-record-write.d.ts +20 -0
- package/dist/safe-bash-sqlite-engine/storage.d.ts +2 -0
- package/dist/safe-bash-sqlite-engine/storage.js +236 -55
- package/dist/safe-bash-svg-engine/LICENSE +21 -0
- package/dist/safe-bash-svg-engine/index.d.ts +8 -0
- package/dist/safe-bash-svg-engine/index.js +477 -0
- package/dist/safe-bash-zip-engine/index.js +3 -3
- package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
- package/dist/safe-bash-zip-engine/zip/sfx.js +3 -3
- package/dist/safe-bash-zip-engine/zip-format.js +3 -3
- package/dist/safe-playwright-cloudflare/browser-provider.generated.js +55 -18
- package/dist/safe-playwright-cloudflare/browser-run-code-guest.generated.js +1 -1
- package/dist/spreadsheet-engine/datasource.js +4 -1
- package/dist/spreadsheet-engine/formulas/functions/math.js +3 -1
- package/dist/spreadsheet-engine/rendering/chart/axis.d.ts +26 -0
- package/dist/spreadsheet-engine/rendering/chart/axis.js +61 -0
- package/dist/spreadsheet-engine/rendering/chart/error-bar.d.ts +39 -0
- package/dist/spreadsheet-engine/rendering/chart/error-bar.js +59 -0
- package/dist/spreadsheet-engine/rendering/chart/layout.d.ts +24 -0
- package/dist/spreadsheet-engine/rendering/chart/layout.js +54 -0
- package/dist/spreadsheet-engine/rendering/chart/line.d.ts +23 -0
- package/dist/spreadsheet-engine/rendering/chart/line.js +56 -0
- package/dist/spreadsheet-engine/rendering/chart/marker.d.ts +35 -0
- package/dist/spreadsheet-engine/rendering/chart/marker.js +52 -0
- package/dist/spreadsheet-engine/rendering/chart/pie.d.ts +32 -0
- package/dist/spreadsheet-engine/rendering/chart/pie.js +47 -0
- package/dist/{safe-bash-command-ssconvert → spreadsheet-engine}/rendering/images/codecs.d.ts +0 -1
- package/dist/spreadsheet-engine/rendering/images/codecs.js +253 -0
- package/dist/spreadsheet-engine/rendering/images/index.d.ts +26 -0
- package/dist/spreadsheet-engine/rendering/images/index.js +144 -0
- package/dist/spreadsheet-engine/rendering/images/profile-raster.d.ts +4 -0
- package/dist/spreadsheet-engine/rendering/images/profile-raster.js +72 -0
- package/dist/spreadsheet-engine/rendering/images/scene.d.ts +3 -0
- package/dist/spreadsheet-engine/rendering/images/scene.js +34 -0
- package/dist/spreadsheet-engine/rendering/print/cell-style.d.ts +10 -0
- package/dist/spreadsheet-engine/rendering/print/cell-style.js +52 -0
- package/dist/spreadsheet-engine/rendering/print/font-normalization-data.d.ts +43 -0
- package/dist/spreadsheet-engine/rendering/print/font-normalization-data.js +1558 -0
- package/dist/spreadsheet-engine/rendering/print/font-normalization.d.ts +3 -0
- package/dist/spreadsheet-engine/rendering/print/font-normalization.js +113 -0
- package/dist/spreadsheet-engine/rendering/print/font-shaping.d.ts +18 -0
- package/dist/spreadsheet-engine/rendering/print/font-shaping.js +271 -0
- package/dist/spreadsheet-engine/rendering/print/harfbuzz/data.d.ts +1 -0
- package/dist/spreadsheet-engine/rendering/print/harfbuzz/data.js +2 -0
- package/dist/spreadsheet-engine/rendering/print/header-footer.d.ts +16 -0
- package/dist/spreadsheet-engine/rendering/print/header-footer.js +92 -0
- package/dist/spreadsheet-engine/rendering/print/layout.d.ts +65 -0
- package/dist/spreadsheet-engine/rendering/print/layout.js +75 -0
- package/dist/spreadsheet-engine/rendering/print/pagination.d.ts +34 -0
- package/dist/spreadsheet-engine/rendering/print/pagination.js +126 -0
- package/dist/spreadsheet-engine/rendering/print/settings.d.ts +42 -0
- package/dist/spreadsheet-engine/rendering/print/settings.js +159 -0
- package/dist/spreadsheet-format-xls/biff-metadata.js +3 -3
- package/dist/spreadsheet-format-xls/biff-write-metadata.d.ts +1 -1
- package/dist/spreadsheet-format-xls/biff-write-metadata.js +20 -3
- package/dist/spreadsheet-format-xls/biff-write.js +1 -1
- package/package.json +239 -12
- package/third-party/spreadsheet-engine/scripts/harfbuzz/README.md +39 -0
- package/third-party/spreadsheet-engine/scripts/harfbuzz/allocator.cc +18 -0
- package/third-party/spreadsheet-engine/scripts/harfbuzz/build.mjs +94 -0
- package/third-party/spreadsheet-engine/scripts/harfbuzz/completion.patch +98 -0
- package/third-party/spreadsheet-engine/scripts/harfbuzz/config-override.h +19 -0
- package/third-party/spreadsheet-engine/scripts/harfbuzz/exports.json +29 -0
- package/third-party/spreadsheet-engine/scripts/harfbuzz/sources.json +274 -0
- package/third-party/spreadsheet-engine/scripts/harfbuzz/verify.d.mts +10 -0
- package/third-party/spreadsheet-engine/scripts/harfbuzz/verify.mjs +96 -0
- package/third-party/spreadsheet-engine/scripts/harfbuzz/verify.test.mjs +60 -0
- package/third-party/spreadsheet-engine/src/rendering/images/NOTICE.md +22 -0
- package/third-party/spreadsheet-engine/src/rendering/print/NOTICE.md +30 -0
- package/third-party/spreadsheet-engine/src/rendering/print/font-normalization-NOTICE.md +64 -0
- package/third-party/spreadsheet-engine/src/rendering/print/font-normalization-data.ts +1558 -0
- package/third-party/spreadsheet-engine/src/rendering/print/font-normalization.ts +91 -0
- package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/EMSCRIPTEN-LICENSE.txt +102 -0
- package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/HARFBUZZ-LICENSE.txt +42 -0
- package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/LIBCXX-LICENSE.txt +311 -0
- package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/LIBCXXABI-LICENSE.txt +311 -0
- package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/MUSL-LICENSE.txt +193 -0
- package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/NOTICE.md +41 -0
- package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/data.ts +2 -0
- package/dist/safe-bash/command-chunks/chunk-C5TUE2FE.js +0 -169
- package/dist/safe-bash/command-chunks/chunk-CVKW2YIC.js +0 -13631
- package/dist/safe-bash/command-chunks/chunk-JBGGUHQY.js +0 -17617
- package/dist/safe-bash/command-chunks/chunk-S4R2JDPL.js +0 -35
- package/dist/safe-bash/command-chunks/chunk-TU5IFVCX.js +0 -33708
- package/dist/safe-bash/command-chunks/chunk-TUWGIF22.js +0 -328
- package/dist/safe-bash/command-chunks/data-2FJOPYXA-PDKMLCGR.js +0 -8
- package/dist/safe-bash/command-chunks/index.browser-2NLML6H4.js +0 -269
- package/dist/safe-bash/command-chunks/model-store-EEI3QS4G.js +0 -10
- package/dist/safe-bash/command-chunks/pdf-M2GFAR2A-FCJMJCAP.js +0 -683
- package/dist/safe-bash-command-ssconvert/rendering/images/formats.d.ts +0 -2
- package/dist/safe-bash-docx-engine/command.d.ts +0 -65
- package/dist/safe-bash/chunks/{chunk-4T4RQYRI.js → chunk-5HRGBHZH.js} +10 -10
- package/dist/safe-bash/chunks/{chunk-QUS6X4MS.js → chunk-EOQMDRTY.js} +0 -0
- package/dist/safe-bash/command-chunks/{chunk-2L3JKGUH.js → chunk-4LYZBDZF.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-EMMSXKEJ.js → chunk-4Q4R3VZU.js} +0 -0
- package/dist/safe-bash/command-chunks/{chunk-5RLK2QSY.js → chunk-7JEIWA3A.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-AV6N7DDA.js → chunk-DDYPQAXN.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-OOB7YCFQ.js → chunk-FMJKCVSQ.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-FUL2C4EX.js → chunk-HFKS6AET.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-2M3WUEDX.js → chunk-J6K5Q53O.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-ATWMLV75.js → chunk-RJXZYDSN.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-JD3NSHFT.js → chunk-TVGIJ56E.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-3I33KPQH.js → chunk-X2HVVMTW.js} +6 -6
- package/dist/safe-bash/command-chunks/{odf-UKSXPNOZ-NCL5P7YL.js → odf-UKSXPNOZ-BV2LCKTB.js} +0 -0
- package/dist/{safe-bash/command-chunks/chunk-3SVT5VB7.js → safe-bash-docx-engine/operation-types.js} +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/accessibility.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/animation-editing.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/animations.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/backgrounds.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-data-model.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-editing.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-font-operations.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-model-axes.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-model-core.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-model-series.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-model.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-objects.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-workbook.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/charts.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/command-placeholder.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/comments.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/connector-operations.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/connectors-model.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/connectors.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/content-types.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/contracts.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/creation.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/diagram-resources.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/diff.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/drawing-format.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/drawing-operations.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/equations.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/errors.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/fields.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/font-metrics.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/freeform-builder.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/group-model.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/image-extraction.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/image-formatting.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/image-insertion.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/image-replacement.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/image-value.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/images.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/inventory.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/language-enum.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/layouts.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/length.d.ts +0 -0
- package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/links-model.d.ts +4 -4
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/links.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/masters.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/media-editing.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/media-enum.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/media-extraction.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/media.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/memberships.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/modern-comments.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/notes.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/ole-enum.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/ole-insertion.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/opaque-objects.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/package-reader.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/package-tools.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/package-view.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/package-writer.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/paragraph-alignment.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/presentation-settings.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/properties.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/relationships.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/resource-limits.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/sanitize.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/selector-schema.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/selectors.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-adjustments.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-groups.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-operations.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-path-operations.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-paths.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-placeholder-types.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-presets.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-selection.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-transforms.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-copy.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-import.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-layout-model.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-merge-split.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-model.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-removal.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-transfer-budget.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slides.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/table-operations.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/table-spans.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/tables-model.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/tables.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/tags.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/template-bindings.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/template-repeat.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-fitting.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-frame-enums.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-frames.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-paragraphs.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-reading.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-replacement.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-run-color.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-runs.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-style-resolution.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/themes.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/transitions.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/validation.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/xml-parts.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/xml-view.d.ts +0 -0
- /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/xml.d.ts +0 -0
|
@@ -0,0 +1,3949 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MSO_AUTO_SHAPE_TYPE,
|
|
3
|
+
shapePresets
|
|
4
|
+
} from "./chunk-2FOLUJLI.js";
|
|
5
|
+
import {
|
|
6
|
+
createXmlElementView
|
|
7
|
+
} from "./chunk-QXCSASIE.js";
|
|
8
|
+
import {
|
|
9
|
+
MSO_LANGUAGE_ID
|
|
10
|
+
} from "./chunk-4ATHODCG.js";
|
|
11
|
+
import {
|
|
12
|
+
bestFitText
|
|
13
|
+
} from "./chunk-5HWX4XYW.js";
|
|
14
|
+
import {
|
|
15
|
+
readRunFormatting,
|
|
16
|
+
runPropertiesMerge,
|
|
17
|
+
textUnderlineStyles,
|
|
18
|
+
validateTextRunOptions
|
|
19
|
+
} from "./chunk-JHAY3KYC.js";
|
|
20
|
+
import {
|
|
21
|
+
readTextBodies,
|
|
22
|
+
validateTextReadingOptions
|
|
23
|
+
} from "./chunk-XP6BHGZ6.js";
|
|
24
|
+
import {
|
|
25
|
+
applyDrawingFill,
|
|
26
|
+
applyDrawingUpdate,
|
|
27
|
+
readDrawingColor,
|
|
28
|
+
readDrawingFormat
|
|
29
|
+
} from "./chunk-A3XE767Q.js";
|
|
30
|
+
import {
|
|
31
|
+
ColorFormat,
|
|
32
|
+
MSO_COLOR_TYPE,
|
|
33
|
+
MSO_THEME_COLOR_INDEX,
|
|
34
|
+
RGBColor,
|
|
35
|
+
colorBrightnessMerge,
|
|
36
|
+
colorMerge,
|
|
37
|
+
defineEnum,
|
|
38
|
+
defineXmlEnum,
|
|
39
|
+
readRunColor
|
|
40
|
+
} from "./chunk-SEK43FRN.js";
|
|
41
|
+
import {
|
|
42
|
+
readXmlCoordinate,
|
|
43
|
+
readXmlInteger
|
|
44
|
+
} from "./chunk-3W6PTHHB.js";
|
|
45
|
+
import {
|
|
46
|
+
Length,
|
|
47
|
+
Pt
|
|
48
|
+
} from "./chunk-I6AMDG2T.js";
|
|
49
|
+
import {
|
|
50
|
+
attr,
|
|
51
|
+
child,
|
|
52
|
+
loadShared
|
|
53
|
+
} from "./chunk-RAXJVM4U.js";
|
|
54
|
+
import {
|
|
55
|
+
SelectionError
|
|
56
|
+
} from "./chunk-CKEODJVT.js";
|
|
57
|
+
import {
|
|
58
|
+
protectedEquationNodes
|
|
59
|
+
} from "./chunk-5DFZAJHL.js";
|
|
60
|
+
import {
|
|
61
|
+
parseXmlPart
|
|
62
|
+
} from "./chunk-L3WY5ASN.js";
|
|
63
|
+
import {
|
|
64
|
+
IndexError,
|
|
65
|
+
InvalidHandleError,
|
|
66
|
+
OfficeError,
|
|
67
|
+
PropertyAccessError,
|
|
68
|
+
TypeError,
|
|
69
|
+
ValueError
|
|
70
|
+
} from "./chunk-RR6QQ25D.js";
|
|
71
|
+
|
|
72
|
+
// packages/safe-bash-presentation-engine/src/text-link-capability.ts
|
|
73
|
+
var textLinkCapabilities = /* @__PURE__ */ new WeakMap();
|
|
74
|
+
|
|
75
|
+
// packages/safe-bash-presentation-engine/src/shape-adjustment-defaults.ts
|
|
76
|
+
var shapeAdjustmentDefaults = {
|
|
77
|
+
ARC: [
|
|
78
|
+
["adj1", 162e5],
|
|
79
|
+
["adj2", 0]
|
|
80
|
+
],
|
|
81
|
+
BALLOON: [
|
|
82
|
+
["adj1", -20833],
|
|
83
|
+
["adj2", 62500],
|
|
84
|
+
["adj3", 16667]
|
|
85
|
+
],
|
|
86
|
+
BENT_ARROW: [
|
|
87
|
+
["adj1", 25e3],
|
|
88
|
+
["adj2", 25e3],
|
|
89
|
+
["adj3", 25e3],
|
|
90
|
+
["adj4", 43750]
|
|
91
|
+
],
|
|
92
|
+
BENT_UP_ARROW: [
|
|
93
|
+
["adj1", 25e3],
|
|
94
|
+
["adj2", 25e3],
|
|
95
|
+
["adj3", 25e3]
|
|
96
|
+
],
|
|
97
|
+
BEVEL: [["adj", 12500]],
|
|
98
|
+
BLOCK_ARC: [
|
|
99
|
+
["adj1", 108e5],
|
|
100
|
+
["adj2", 0],
|
|
101
|
+
["adj3", 25e3]
|
|
102
|
+
],
|
|
103
|
+
CAN: [["adj", 25e3]],
|
|
104
|
+
CHEVRON: [["adj", 5e4]],
|
|
105
|
+
CHORD: [
|
|
106
|
+
["adj1", 27e5],
|
|
107
|
+
["adj2", 162e5]
|
|
108
|
+
],
|
|
109
|
+
CIRCULAR_ARROW: [
|
|
110
|
+
["adj1", 12500],
|
|
111
|
+
["adj2", 1142319],
|
|
112
|
+
["adj3", 20457681],
|
|
113
|
+
["adj4", 108e5],
|
|
114
|
+
["adj5", 12500]
|
|
115
|
+
],
|
|
116
|
+
CLOUD_CALLOUT: [
|
|
117
|
+
["adj1", -20833],
|
|
118
|
+
["adj2", 62500]
|
|
119
|
+
],
|
|
120
|
+
CORNER: [
|
|
121
|
+
["adj1", 5e4],
|
|
122
|
+
["adj2", 5e4]
|
|
123
|
+
],
|
|
124
|
+
CROSS: [["adj", 25e3]],
|
|
125
|
+
CUBE: [["adj", 25e3]],
|
|
126
|
+
CURVED_DOWN_ARROW: [
|
|
127
|
+
["adj1", 25e3],
|
|
128
|
+
["adj2", 5e4],
|
|
129
|
+
["adj3", 25e3]
|
|
130
|
+
],
|
|
131
|
+
CURVED_DOWN_RIBBON: [
|
|
132
|
+
["adj1", 25e3],
|
|
133
|
+
["adj2", 5e4],
|
|
134
|
+
["adj3", 12500]
|
|
135
|
+
],
|
|
136
|
+
CURVED_LEFT_ARROW: [
|
|
137
|
+
["adj1", 25e3],
|
|
138
|
+
["adj2", 5e4],
|
|
139
|
+
["adj3", 25e3]
|
|
140
|
+
],
|
|
141
|
+
CURVED_RIGHT_ARROW: [
|
|
142
|
+
["adj1", 25e3],
|
|
143
|
+
["adj2", 5e4],
|
|
144
|
+
["adj3", 25e3]
|
|
145
|
+
],
|
|
146
|
+
CURVED_UP_ARROW: [
|
|
147
|
+
["adj1", 25e3],
|
|
148
|
+
["adj2", 5e4],
|
|
149
|
+
["adj3", 25e3]
|
|
150
|
+
],
|
|
151
|
+
CURVED_UP_RIBBON: [
|
|
152
|
+
["adj1", 25e3],
|
|
153
|
+
["adj2", 5e4],
|
|
154
|
+
["adj3", 12500]
|
|
155
|
+
],
|
|
156
|
+
DECAGON: [["vf", 105146]],
|
|
157
|
+
DIAGONAL_STRIPE: [["adj", 5e4]],
|
|
158
|
+
DONUT: [["adj", 25e3]],
|
|
159
|
+
DOUBLE_BRACE: [["adj", 8333]],
|
|
160
|
+
DOUBLE_BRACKET: [["adj", 16667]],
|
|
161
|
+
DOUBLE_WAVE: [
|
|
162
|
+
["adj1", 6250],
|
|
163
|
+
["adj2", 0]
|
|
164
|
+
],
|
|
165
|
+
DOWN_ARROW: [
|
|
166
|
+
["adj1", 5e4],
|
|
167
|
+
["adj2", 5e4]
|
|
168
|
+
],
|
|
169
|
+
DOWN_ARROW_CALLOUT: [
|
|
170
|
+
["adj1", 25e3],
|
|
171
|
+
["adj2", 25e3],
|
|
172
|
+
["adj3", 25e3],
|
|
173
|
+
["adj4", 64977]
|
|
174
|
+
],
|
|
175
|
+
DOWN_RIBBON: [
|
|
176
|
+
["adj1", 16667],
|
|
177
|
+
["adj2", 5e4]
|
|
178
|
+
],
|
|
179
|
+
FRAME: [["adj1", 12500]],
|
|
180
|
+
GEAR_6: [
|
|
181
|
+
["adj1", 15e3],
|
|
182
|
+
["adj2", 3526]
|
|
183
|
+
],
|
|
184
|
+
GEAR_9: [
|
|
185
|
+
["adj1", 1e4],
|
|
186
|
+
["adj2", 1763]
|
|
187
|
+
],
|
|
188
|
+
HALF_FRAME: [
|
|
189
|
+
["adj1", 33333],
|
|
190
|
+
["adj2", 33333]
|
|
191
|
+
],
|
|
192
|
+
HEPTAGON: [
|
|
193
|
+
["hf", 102572],
|
|
194
|
+
["vf", 105210]
|
|
195
|
+
],
|
|
196
|
+
HEXAGON: [
|
|
197
|
+
["adj", 25e3],
|
|
198
|
+
["vf", 115470]
|
|
199
|
+
],
|
|
200
|
+
HORIZONTAL_SCROLL: [["adj", 12500]],
|
|
201
|
+
ISOSCELES_TRIANGLE: [["adj", 5e4]],
|
|
202
|
+
LEFT_ARROW: [
|
|
203
|
+
["adj1", 5e4],
|
|
204
|
+
["adj2", 5e4]
|
|
205
|
+
],
|
|
206
|
+
LEFT_ARROW_CALLOUT: [
|
|
207
|
+
["adj1", 25e3],
|
|
208
|
+
["adj2", 25e3],
|
|
209
|
+
["adj3", 25e3],
|
|
210
|
+
["adj4", 64977]
|
|
211
|
+
],
|
|
212
|
+
LEFT_BRACE: [
|
|
213
|
+
["adj1", 8333],
|
|
214
|
+
["adj2", 5e4]
|
|
215
|
+
],
|
|
216
|
+
LEFT_BRACKET: [["adj", 8333]],
|
|
217
|
+
LEFT_CIRCULAR_ARROW: [
|
|
218
|
+
["adj1", 12500],
|
|
219
|
+
["adj2", -1142319],
|
|
220
|
+
["adj3", 1142319],
|
|
221
|
+
["adj4", 108e5],
|
|
222
|
+
["adj5", 12500]
|
|
223
|
+
],
|
|
224
|
+
LEFT_RIGHT_ARROW: [
|
|
225
|
+
["adj1", 5e4],
|
|
226
|
+
["adj2", 5e4]
|
|
227
|
+
],
|
|
228
|
+
LEFT_RIGHT_ARROW_CALLOUT: [
|
|
229
|
+
["adj1", 25e3],
|
|
230
|
+
["adj2", 25e3],
|
|
231
|
+
["adj3", 25e3],
|
|
232
|
+
["adj4", 48123]
|
|
233
|
+
],
|
|
234
|
+
LEFT_RIGHT_CIRCULAR_ARROW: [
|
|
235
|
+
["adj1", 12500],
|
|
236
|
+
["adj2", 1142319],
|
|
237
|
+
["adj3", 20457681],
|
|
238
|
+
["adj4", 11942319],
|
|
239
|
+
["adj5", 12500]
|
|
240
|
+
],
|
|
241
|
+
LEFT_RIGHT_RIBBON: [
|
|
242
|
+
["adj1", 5e4],
|
|
243
|
+
["adj2", 5e4],
|
|
244
|
+
["adj3", 16667]
|
|
245
|
+
],
|
|
246
|
+
LEFT_RIGHT_UP_ARROW: [
|
|
247
|
+
["adj1", 25e3],
|
|
248
|
+
["adj2", 25e3],
|
|
249
|
+
["adj3", 25e3]
|
|
250
|
+
],
|
|
251
|
+
LEFT_UP_ARROW: [
|
|
252
|
+
["adj1", 25e3],
|
|
253
|
+
["adj2", 25e3],
|
|
254
|
+
["adj3", 25e3]
|
|
255
|
+
],
|
|
256
|
+
LINE_CALLOUT_1: [
|
|
257
|
+
["adj1", 18750],
|
|
258
|
+
["adj2", -8333],
|
|
259
|
+
["adj3", 112500],
|
|
260
|
+
["adj4", -38333]
|
|
261
|
+
],
|
|
262
|
+
LINE_CALLOUT_1_ACCENT_BAR: [
|
|
263
|
+
["adj1", 18750],
|
|
264
|
+
["adj2", -8333],
|
|
265
|
+
["adj3", 112500],
|
|
266
|
+
["adj4", -38333]
|
|
267
|
+
],
|
|
268
|
+
LINE_CALLOUT_1_BORDER_AND_ACCENT_BAR: [
|
|
269
|
+
["adj1", 18750],
|
|
270
|
+
["adj2", -8333],
|
|
271
|
+
["adj3", 112500],
|
|
272
|
+
["adj4", -38333]
|
|
273
|
+
],
|
|
274
|
+
LINE_CALLOUT_1_NO_BORDER: [
|
|
275
|
+
["adj1", 18750],
|
|
276
|
+
["adj2", -8333],
|
|
277
|
+
["adj3", 112500],
|
|
278
|
+
["adj4", -38333]
|
|
279
|
+
],
|
|
280
|
+
LINE_CALLOUT_2: [
|
|
281
|
+
["adj1", 18750],
|
|
282
|
+
["adj2", -8333],
|
|
283
|
+
["adj3", 18750],
|
|
284
|
+
["adj4", -16667],
|
|
285
|
+
["adj5", 112500],
|
|
286
|
+
["adj6", -46667]
|
|
287
|
+
],
|
|
288
|
+
LINE_CALLOUT_2_ACCENT_BAR: [
|
|
289
|
+
["adj1", 18750],
|
|
290
|
+
["adj2", -8333],
|
|
291
|
+
["adj3", 18750],
|
|
292
|
+
["adj4", -16667],
|
|
293
|
+
["adj5", 112500],
|
|
294
|
+
["adj6", -46667]
|
|
295
|
+
],
|
|
296
|
+
LINE_CALLOUT_2_BORDER_AND_ACCENT_BAR: [
|
|
297
|
+
["adj1", 18750],
|
|
298
|
+
["adj2", -8333],
|
|
299
|
+
["adj3", 18750],
|
|
300
|
+
["adj4", -16667],
|
|
301
|
+
["adj5", 112500],
|
|
302
|
+
["adj6", -46667]
|
|
303
|
+
],
|
|
304
|
+
LINE_CALLOUT_2_NO_BORDER: [
|
|
305
|
+
["adj1", 18750],
|
|
306
|
+
["adj2", -8333],
|
|
307
|
+
["adj3", 18750],
|
|
308
|
+
["adj4", -16667],
|
|
309
|
+
["adj5", 112500],
|
|
310
|
+
["adj6", -46667]
|
|
311
|
+
],
|
|
312
|
+
LINE_CALLOUT_3: [
|
|
313
|
+
["adj1", 18750],
|
|
314
|
+
["adj2", -8333],
|
|
315
|
+
["adj3", 18750],
|
|
316
|
+
["adj4", -16667],
|
|
317
|
+
["adj5", 1e5],
|
|
318
|
+
["adj6", -16667],
|
|
319
|
+
["adj7", 112963],
|
|
320
|
+
["adj8", -8333]
|
|
321
|
+
],
|
|
322
|
+
LINE_CALLOUT_3_ACCENT_BAR: [
|
|
323
|
+
["adj1", 18750],
|
|
324
|
+
["adj2", -8333],
|
|
325
|
+
["adj3", 18750],
|
|
326
|
+
["adj4", -16667],
|
|
327
|
+
["adj5", 1e5],
|
|
328
|
+
["adj6", -16667],
|
|
329
|
+
["adj7", 112963],
|
|
330
|
+
["adj8", -8333]
|
|
331
|
+
],
|
|
332
|
+
LINE_CALLOUT_3_BORDER_AND_ACCENT_BAR: [
|
|
333
|
+
["adj1", 18750],
|
|
334
|
+
["adj2", -8333],
|
|
335
|
+
["adj3", 18750],
|
|
336
|
+
["adj4", -16667],
|
|
337
|
+
["adj5", 1e5],
|
|
338
|
+
["adj6", -16667],
|
|
339
|
+
["adj7", 112963],
|
|
340
|
+
["adj8", -8333]
|
|
341
|
+
],
|
|
342
|
+
LINE_CALLOUT_3_NO_BORDER: [
|
|
343
|
+
["adj1", 18750],
|
|
344
|
+
["adj2", -8333],
|
|
345
|
+
["adj3", 18750],
|
|
346
|
+
["adj4", -16667],
|
|
347
|
+
["adj5", 1e5],
|
|
348
|
+
["adj6", -16667],
|
|
349
|
+
["adj7", 112963],
|
|
350
|
+
["adj8", -8333]
|
|
351
|
+
],
|
|
352
|
+
LINE_CALLOUT_4: [
|
|
353
|
+
["adj1", 18750],
|
|
354
|
+
["adj2", -8333],
|
|
355
|
+
["adj3", 18750],
|
|
356
|
+
["adj4", -16667],
|
|
357
|
+
["adj5", 1e5],
|
|
358
|
+
["adj6", -16667],
|
|
359
|
+
["adj7", 112963],
|
|
360
|
+
["adj8", -8333]
|
|
361
|
+
],
|
|
362
|
+
LINE_CALLOUT_4_ACCENT_BAR: [
|
|
363
|
+
["adj1", 18750],
|
|
364
|
+
["adj2", -8333],
|
|
365
|
+
["adj3", 18750],
|
|
366
|
+
["adj4", -16667],
|
|
367
|
+
["adj5", 1e5],
|
|
368
|
+
["adj6", -16667],
|
|
369
|
+
["adj7", 112963],
|
|
370
|
+
["adj8", -8333]
|
|
371
|
+
],
|
|
372
|
+
LINE_CALLOUT_4_BORDER_AND_ACCENT_BAR: [
|
|
373
|
+
["adj1", 18750],
|
|
374
|
+
["adj2", -8333],
|
|
375
|
+
["adj3", 18750],
|
|
376
|
+
["adj4", -16667],
|
|
377
|
+
["adj5", 1e5],
|
|
378
|
+
["adj6", -16667],
|
|
379
|
+
["adj7", 112963],
|
|
380
|
+
["adj8", -8333]
|
|
381
|
+
],
|
|
382
|
+
LINE_CALLOUT_4_NO_BORDER: [
|
|
383
|
+
["adj1", 18750],
|
|
384
|
+
["adj2", -8333],
|
|
385
|
+
["adj3", 18750],
|
|
386
|
+
["adj4", -16667],
|
|
387
|
+
["adj5", 1e5],
|
|
388
|
+
["adj6", -16667],
|
|
389
|
+
["adj7", 112963],
|
|
390
|
+
["adj8", -8333]
|
|
391
|
+
],
|
|
392
|
+
MATH_DIVIDE: [
|
|
393
|
+
["adj1", 23520],
|
|
394
|
+
["adj2", 5880],
|
|
395
|
+
["adj3", 11760]
|
|
396
|
+
],
|
|
397
|
+
MATH_EQUAL: [
|
|
398
|
+
["adj1", 23520],
|
|
399
|
+
["adj2", 11760]
|
|
400
|
+
],
|
|
401
|
+
MATH_MINUS: [["adj1", 23520]],
|
|
402
|
+
MATH_MULTIPLY: [["adj1", 23520]],
|
|
403
|
+
MATH_NOT_EQUAL: [
|
|
404
|
+
["adj1", 23520],
|
|
405
|
+
["adj2", 66e5],
|
|
406
|
+
["adj3", 11760]
|
|
407
|
+
],
|
|
408
|
+
MATH_PLUS: [["adj1", 23520]],
|
|
409
|
+
MOON: [["adj", 5e4]],
|
|
410
|
+
NON_ISOSCELES_TRAPEZOID: [
|
|
411
|
+
["adj1", 25e3],
|
|
412
|
+
["adj2", 25e3]
|
|
413
|
+
],
|
|
414
|
+
NOTCHED_RIGHT_ARROW: [
|
|
415
|
+
["adj1", 5e4],
|
|
416
|
+
["adj2", 5e4]
|
|
417
|
+
],
|
|
418
|
+
NO_SYMBOL: [["adj", 18750]],
|
|
419
|
+
OCTAGON: [["adj", 29289]],
|
|
420
|
+
OVAL_CALLOUT: [
|
|
421
|
+
["adj1", -20833],
|
|
422
|
+
["adj2", 62500]
|
|
423
|
+
],
|
|
424
|
+
PARALLELOGRAM: [["adj", 25e3]],
|
|
425
|
+
PENTAGON: [["adj", 5e4]],
|
|
426
|
+
PIE: [
|
|
427
|
+
["adj1", 0],
|
|
428
|
+
["adj2", 162e5]
|
|
429
|
+
],
|
|
430
|
+
PLAQUE: [["adj", 16667]],
|
|
431
|
+
QUAD_ARROW: [
|
|
432
|
+
["adj1", 22500],
|
|
433
|
+
["adj2", 22500],
|
|
434
|
+
["adj3", 22500]
|
|
435
|
+
],
|
|
436
|
+
QUAD_ARROW_CALLOUT: [
|
|
437
|
+
["adj1", 18515],
|
|
438
|
+
["adj2", 18515],
|
|
439
|
+
["adj3", 18515],
|
|
440
|
+
["adj4", 48123]
|
|
441
|
+
],
|
|
442
|
+
RECTANGULAR_CALLOUT: [
|
|
443
|
+
["adj1", -20833],
|
|
444
|
+
["adj2", 62500]
|
|
445
|
+
],
|
|
446
|
+
REGULAR_PENTAGON: [
|
|
447
|
+
["hf", 105146],
|
|
448
|
+
["vf", 110557]
|
|
449
|
+
],
|
|
450
|
+
RIGHT_ARROW: [
|
|
451
|
+
["adj1", 5e4],
|
|
452
|
+
["adj2", 5e4]
|
|
453
|
+
],
|
|
454
|
+
RIGHT_ARROW_CALLOUT: [
|
|
455
|
+
["adj1", 25e3],
|
|
456
|
+
["adj2", 25e3],
|
|
457
|
+
["adj3", 25e3],
|
|
458
|
+
["adj4", 64977]
|
|
459
|
+
],
|
|
460
|
+
RIGHT_BRACE: [
|
|
461
|
+
["adj1", 8333],
|
|
462
|
+
["adj2", 5e4]
|
|
463
|
+
],
|
|
464
|
+
RIGHT_BRACKET: [["adj", 8333]],
|
|
465
|
+
ROUNDED_RECTANGLE: [["adj", 16667]],
|
|
466
|
+
ROUNDED_RECTANGULAR_CALLOUT: [
|
|
467
|
+
["adj1", -20833],
|
|
468
|
+
["adj2", 62500],
|
|
469
|
+
["adj3", 16667]
|
|
470
|
+
],
|
|
471
|
+
ROUND_1_RECTANGLE: [["adj", 16667]],
|
|
472
|
+
ROUND_2_DIAG_RECTANGLE: [
|
|
473
|
+
["adj1", 16667],
|
|
474
|
+
["adj2", 0]
|
|
475
|
+
],
|
|
476
|
+
ROUND_2_SAME_RECTANGLE: [
|
|
477
|
+
["adj1", 16667],
|
|
478
|
+
["adj2", 0]
|
|
479
|
+
],
|
|
480
|
+
SMILEY_FACE: [["adj", 4653]],
|
|
481
|
+
SNIP_1_RECTANGLE: [["adj", 16667]],
|
|
482
|
+
SNIP_2_DIAG_RECTANGLE: [
|
|
483
|
+
["adj1", 0],
|
|
484
|
+
["adj2", 16667]
|
|
485
|
+
],
|
|
486
|
+
SNIP_2_SAME_RECTANGLE: [
|
|
487
|
+
["adj1", 16667],
|
|
488
|
+
["adj2", 0]
|
|
489
|
+
],
|
|
490
|
+
SNIP_ROUND_RECTANGLE: [
|
|
491
|
+
["adj1", 16667],
|
|
492
|
+
["adj2", 16667]
|
|
493
|
+
],
|
|
494
|
+
STAR_10_POINT: [
|
|
495
|
+
["adj", 42533],
|
|
496
|
+
["hf", 105146]
|
|
497
|
+
],
|
|
498
|
+
STAR_12_POINT: [["adj", 37500]],
|
|
499
|
+
STAR_16_POINT: [["adj", 37500]],
|
|
500
|
+
STAR_24_POINT: [["adj", 37500]],
|
|
501
|
+
STAR_32_POINT: [["adj", 37500]],
|
|
502
|
+
STAR_4_POINT: [["adj", 12500]],
|
|
503
|
+
STAR_5_POINT: [
|
|
504
|
+
["adj", 19098],
|
|
505
|
+
["hf", 105146],
|
|
506
|
+
["vf", 110557]
|
|
507
|
+
],
|
|
508
|
+
STAR_6_POINT: [
|
|
509
|
+
["adj", 28868],
|
|
510
|
+
["hf", 115470]
|
|
511
|
+
],
|
|
512
|
+
STAR_7_POINT: [
|
|
513
|
+
["adj", 34601],
|
|
514
|
+
["hf", 102572],
|
|
515
|
+
["vf", 105210]
|
|
516
|
+
],
|
|
517
|
+
STAR_8_POINT: [["adj", 37500]],
|
|
518
|
+
STRIPED_RIGHT_ARROW: [
|
|
519
|
+
["adj1", 5e4],
|
|
520
|
+
["adj2", 5e4]
|
|
521
|
+
],
|
|
522
|
+
SUN: [["adj", 25e3]],
|
|
523
|
+
SWOOSH_ARROW: [
|
|
524
|
+
["adj1", 25e3],
|
|
525
|
+
["adj2", 16667]
|
|
526
|
+
],
|
|
527
|
+
TEAR: [["adj", 1e5]],
|
|
528
|
+
TRAPEZOID: [["adj", 25e3]],
|
|
529
|
+
UP_ARROW: [
|
|
530
|
+
["adj1", 5e4],
|
|
531
|
+
["adj2", 5e4]
|
|
532
|
+
],
|
|
533
|
+
UP_ARROW_CALLOUT: [
|
|
534
|
+
["adj1", 25e3],
|
|
535
|
+
["adj2", 25e3],
|
|
536
|
+
["adj3", 25e3],
|
|
537
|
+
["adj4", 64977]
|
|
538
|
+
],
|
|
539
|
+
UP_DOWN_ARROW: [
|
|
540
|
+
["adj1", 5e4],
|
|
541
|
+
["adj1", 5e4],
|
|
542
|
+
["adj2", 5e4],
|
|
543
|
+
["adj2", 5e4]
|
|
544
|
+
],
|
|
545
|
+
UP_DOWN_ARROW_CALLOUT: [
|
|
546
|
+
["adj1", 25e3],
|
|
547
|
+
["adj2", 25e3],
|
|
548
|
+
["adj3", 25e3],
|
|
549
|
+
["adj4", 48123]
|
|
550
|
+
],
|
|
551
|
+
UP_RIBBON: [
|
|
552
|
+
["adj1", 16667],
|
|
553
|
+
["adj2", 5e4]
|
|
554
|
+
],
|
|
555
|
+
U_TURN_ARROW: [
|
|
556
|
+
["adj1", 25e3],
|
|
557
|
+
["adj2", 25e3],
|
|
558
|
+
["adj3", 25e3],
|
|
559
|
+
["adj4", 43750],
|
|
560
|
+
["adj5", 75e3]
|
|
561
|
+
],
|
|
562
|
+
VERTICAL_SCROLL: [["adj", 12500]],
|
|
563
|
+
WAVE: [
|
|
564
|
+
["adj1", 12500],
|
|
565
|
+
["adj2", 0]
|
|
566
|
+
]
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
// packages/safe-bash-presentation-engine/src/shape-adjustments.ts
|
|
570
|
+
function raw(value) {
|
|
571
|
+
if (typeof value !== "number") throw new TypeError("Adjustment value must be numeric.");
|
|
572
|
+
const result = Math.trunc(value * 1e5);
|
|
573
|
+
if (!Number.isSafeInteger(result))
|
|
574
|
+
throw new ValueError("Adjustment value exceeds the safe numeric range.");
|
|
575
|
+
return result;
|
|
576
|
+
}
|
|
577
|
+
function validateAdjustmentValues(values3) {
|
|
578
|
+
if (!Array.isArray(values3)) throw new TypeError("Adjustment values require an array.");
|
|
579
|
+
if (values3.length > 4096)
|
|
580
|
+
throw new OfficeError("resource-limit", "Adjustment value limit exceeded.", "usage");
|
|
581
|
+
for (let index = 0; index < values3.length; index++) {
|
|
582
|
+
if (!Object.hasOwn(values3, index))
|
|
583
|
+
throw new ValueError("Adjustment arrays must contain every position.");
|
|
584
|
+
raw(values3[index]);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
var Adjustment = class {
|
|
588
|
+
constructor(name, defaultValue, actual = null) {
|
|
589
|
+
this.name = name;
|
|
590
|
+
this.defaultValue = defaultValue;
|
|
591
|
+
if (typeof name !== "string") throw new TypeError();
|
|
592
|
+
if (!Number.isSafeInteger(defaultValue) || actual !== null && !Number.isSafeInteger(actual))
|
|
593
|
+
throw new ValueError();
|
|
594
|
+
this.#actual = actual;
|
|
595
|
+
}
|
|
596
|
+
name;
|
|
597
|
+
defaultValue;
|
|
598
|
+
#actual;
|
|
599
|
+
get effective_value() {
|
|
600
|
+
return this.val / 1e5;
|
|
601
|
+
}
|
|
602
|
+
set effective_value(value) {
|
|
603
|
+
this.#actual = raw(value);
|
|
604
|
+
}
|
|
605
|
+
get val() {
|
|
606
|
+
return this.#actual ?? this.defaultValue;
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
function geometry(xml) {
|
|
610
|
+
const props2 = child(xml.root, "spPr");
|
|
611
|
+
const preset2 = props2?.children.find(
|
|
612
|
+
(n) => n.name.localName === "prstGeom" && [
|
|
613
|
+
"http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
614
|
+
"http://purl.oclc.org/ooxml/drawingml/main"
|
|
615
|
+
].includes(n.name.namespace)
|
|
616
|
+
);
|
|
617
|
+
return preset2;
|
|
618
|
+
}
|
|
619
|
+
var AdjustmentCollection = class {
|
|
620
|
+
#preset;
|
|
621
|
+
#read;
|
|
622
|
+
#writeXml;
|
|
623
|
+
constructor(read, write) {
|
|
624
|
+
this.#read = read;
|
|
625
|
+
this.#writeXml = write;
|
|
626
|
+
const node = geometry(read());
|
|
627
|
+
this.#preset = node && attr(node, "prst");
|
|
628
|
+
return new Proxy(this, {
|
|
629
|
+
get(target, key) {
|
|
630
|
+
if (typeof key === "string" && key !== "" && String(Number(key)) === key)
|
|
631
|
+
return target.#value(Number(key));
|
|
632
|
+
const value = Reflect.get(target, key, target);
|
|
633
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
634
|
+
},
|
|
635
|
+
set(target, key, value) {
|
|
636
|
+
if (typeof key === "string" && key !== "" && String(Number(key)) === key) {
|
|
637
|
+
target.#set(Number(key), value);
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
640
|
+
throw new ValueError("Adjustment collection members are read-only.");
|
|
641
|
+
},
|
|
642
|
+
defineProperty() {
|
|
643
|
+
throw new ValueError("Adjustment collection properties cannot be redefined.");
|
|
644
|
+
},
|
|
645
|
+
deleteProperty() {
|
|
646
|
+
throw new ValueError("Adjustment collection entries cannot be deleted.");
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
#values() {
|
|
651
|
+
const xml = this.#read(), node = geometry(xml);
|
|
652
|
+
if ((node && attr(node, "prst")) !== this.#preset) throw new InvalidHandleError();
|
|
653
|
+
if (!node) return [];
|
|
654
|
+
const key = Object.keys(shapePresets).find(
|
|
655
|
+
(key2) => shapePresets[key2] === this.#preset
|
|
656
|
+
);
|
|
657
|
+
if (!key)
|
|
658
|
+
throw new OfficeError(
|
|
659
|
+
"unsupported-edit",
|
|
660
|
+
"Unknown preset adjustment defaults.",
|
|
661
|
+
"validate-intent"
|
|
662
|
+
);
|
|
663
|
+
const values3 = (shapeAdjustmentDefaults[key] ?? []).map(([name, value]) => [
|
|
664
|
+
name,
|
|
665
|
+
value
|
|
666
|
+
]);
|
|
667
|
+
const guides = child(node, "avLst", node.name.namespace);
|
|
668
|
+
for (const guide of guides?.children ?? []) {
|
|
669
|
+
if (guide.name.localName !== "gd" || guide.name.namespace !== node.name.namespace) continue;
|
|
670
|
+
const target = values3.find(([name]) => name === attr(guide, "name"));
|
|
671
|
+
if (!target) continue;
|
|
672
|
+
const formula = attr(guide, "fmla");
|
|
673
|
+
const token = formula?.startsWith("val ") ? formula.slice(4) : "";
|
|
674
|
+
if (!token.length || [...token].some((c, i) => !"0123456789".includes(c) && !(i === 0 && c === "-")) || !Number.isSafeInteger(Number(token)))
|
|
675
|
+
throw new OfficeError(
|
|
676
|
+
"unsupported-edit",
|
|
677
|
+
"Adjustment requires a literal integer guide.",
|
|
678
|
+
"validate-intent"
|
|
679
|
+
);
|
|
680
|
+
target[1] = Number(token);
|
|
681
|
+
}
|
|
682
|
+
return values3;
|
|
683
|
+
}
|
|
684
|
+
#value(index) {
|
|
685
|
+
const values3 = this.#values();
|
|
686
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= values3.length) throw new IndexError();
|
|
687
|
+
return values3[index][1] / 1e5;
|
|
688
|
+
}
|
|
689
|
+
#set(index, value) {
|
|
690
|
+
const values3 = this.#values();
|
|
691
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= values3.length) throw new IndexError();
|
|
692
|
+
const actual = raw(value);
|
|
693
|
+
this.#write(
|
|
694
|
+
values3.map(([name, current], position) => [name, position === index ? actual : current])
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
get length() {
|
|
698
|
+
return this.#values().length;
|
|
699
|
+
}
|
|
700
|
+
at(index) {
|
|
701
|
+
if (!Number.isSafeInteger(index)) throw new IndexError();
|
|
702
|
+
return this.#value(index < 0 ? this.length + index : index);
|
|
703
|
+
}
|
|
704
|
+
*[Symbol.iterator]() {
|
|
705
|
+
for (const [, value] of this.#values()) yield value / 1e5;
|
|
706
|
+
}
|
|
707
|
+
replace(values3) {
|
|
708
|
+
validateAdjustmentValues(values3);
|
|
709
|
+
const current = this.#values();
|
|
710
|
+
if (values3.length !== current.length)
|
|
711
|
+
throw new ValueError("Adjustment count must match the preset.");
|
|
712
|
+
const actuals = values3.map(raw);
|
|
713
|
+
this.#write(current.map(([name], index) => [name, actuals[index]]));
|
|
714
|
+
}
|
|
715
|
+
#write(current) {
|
|
716
|
+
const xml = this.#read(), node = geometry(xml);
|
|
717
|
+
if (!node) {
|
|
718
|
+
if (current.length) throw new ValueError();
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
const namespace = node.name.namespace;
|
|
722
|
+
const guides = `<a:avLst xmlns:a="${namespace}">${current.map(([name, value]) => `<a:gd name="${name}" fmla="val ${value}"/>`).join("")}</a:avLst>`;
|
|
723
|
+
const existing = child(node, "avLst", namespace);
|
|
724
|
+
this.#writeXml(
|
|
725
|
+
xml.spliceChildren(node, existing ? node.children.indexOf(existing) : 0, existing ? 1 : 0, [
|
|
726
|
+
guides
|
|
727
|
+
])
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
// packages/safe-bash-presentation-engine/src/text-fitting.ts
|
|
733
|
+
function unsupported() {
|
|
734
|
+
throw new OfficeError(
|
|
735
|
+
"unsupported-edit",
|
|
736
|
+
"Text fitting requires supplied matching metrics and a supported horizontal single-column frame.",
|
|
737
|
+
"validate-intent"
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
function validateTextFitOptions(options) {
|
|
741
|
+
if (!options || typeof options !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(options)))
|
|
742
|
+
throw new OfficeError("invalid-value", "Invalid text fit options.", "usage");
|
|
743
|
+
const allowed = [
|
|
744
|
+
"metrics",
|
|
745
|
+
"fontFamily",
|
|
746
|
+
"maxSize",
|
|
747
|
+
"minSize",
|
|
748
|
+
"bold",
|
|
749
|
+
"italic",
|
|
750
|
+
"marginLeft",
|
|
751
|
+
"marginRight",
|
|
752
|
+
"marginTop",
|
|
753
|
+
"marginBottom",
|
|
754
|
+
"wrap",
|
|
755
|
+
"lineSpacing",
|
|
756
|
+
"scope",
|
|
757
|
+
"select",
|
|
758
|
+
"shape",
|
|
759
|
+
"all",
|
|
760
|
+
"allowEmpty"
|
|
761
|
+
];
|
|
762
|
+
if (Reflect.ownKeys(options).some(
|
|
763
|
+
(k) => typeof k !== "string" || !allowed.includes(k) || !Object.hasOwn(Object.getOwnPropertyDescriptor(options, k), "value")
|
|
764
|
+
))
|
|
765
|
+
throw new OfficeError("invalid-value", "Invalid text fit options.", "usage");
|
|
766
|
+
if (!options.metrics) unsupported();
|
|
767
|
+
for (const key of ["fontFamily", "maxSize", "minSize", "bold", "italic", "lineSpacing"])
|
|
768
|
+
if (options[key] === null)
|
|
769
|
+
throw new OfficeError("invalid-value", "Invalid text fit options.", "usage");
|
|
770
|
+
if ((options.maxSize ?? 18) > 4e3)
|
|
771
|
+
throw new OfficeError("invalid-value", "Text fit sizes must not exceed 4000 points.", "usage");
|
|
772
|
+
for (const key of ["all", "allowEmpty", "wrap"])
|
|
773
|
+
if (options[key] !== void 0 && typeof options[key] !== "boolean")
|
|
774
|
+
throw new OfficeError("invalid-value", "Invalid text fit options.", "usage");
|
|
775
|
+
for (const key of ["marginLeft", "marginRight", "marginTop", "marginBottom"])
|
|
776
|
+
if (options[key] !== void 0 && (typeof options[key] !== "number" || !Number.isFinite(options[key]) || options[key] < 0 || options[key] > 2147483647 / 12700))
|
|
777
|
+
throw new OfficeError("invalid-value", "Invalid text fit margins.", "usage");
|
|
778
|
+
validateTextReadingOptions({
|
|
779
|
+
...options.scope === void 0 ? {} : { scope: options.scope },
|
|
780
|
+
...options.select === void 0 ? {} : { select: options.select },
|
|
781
|
+
...options.shape === void 0 ? {} : { shape: options.shape }
|
|
782
|
+
});
|
|
783
|
+
bestFitText(options.metrics, "", {
|
|
784
|
+
family: options.fontFamily ?? "Calibri",
|
|
785
|
+
bold: options.bold ?? false,
|
|
786
|
+
italic: options.italic ?? false,
|
|
787
|
+
maxSize: options.maxSize ?? 18,
|
|
788
|
+
minSize: options.minSize ?? 1,
|
|
789
|
+
width: 0,
|
|
790
|
+
height: 0,
|
|
791
|
+
wrap: options.wrap ?? true,
|
|
792
|
+
lineSpacing: options.lineSpacing ?? 1
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
function fitFrameXml(xml, options, width, height) {
|
|
796
|
+
validateTextFitOptions(options);
|
|
797
|
+
if (![width, height].every(
|
|
798
|
+
(v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1e9
|
|
799
|
+
))
|
|
800
|
+
throw new OfficeError("invalid-value", "Invalid text frame extents.", "usage");
|
|
801
|
+
const formatting = readFrameFormatting(xml.root);
|
|
802
|
+
if ((formatting.columns ?? 1) !== 1 || ![null, "horz"].includes(formatting.verticalText) || (formatting.rotation ?? 0) !== 0)
|
|
803
|
+
unsupported();
|
|
804
|
+
const ns = xml.root.name.namespace.includes("purl.oclc.org") ? "http://purl.oclc.org/ooxml/drawingml/main" : "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
805
|
+
const name = (localName) => ({ namespace: ns, localName });
|
|
806
|
+
const check = (node) => {
|
|
807
|
+
if (node.name.namespace !== ns) return;
|
|
808
|
+
if (["buChar", "buAutoNum", "buBlip", "tabLst"].includes(node.name.localName)) unsupported();
|
|
809
|
+
if (node.attributes.some(
|
|
810
|
+
(a) => !a.name.namespace && ["marL", "marR", "indent", "lvl", "spc", "baseline"].includes(a.name.localName) && Number(a.value) !== 0
|
|
811
|
+
))
|
|
812
|
+
unsupported();
|
|
813
|
+
if (node.attributes.some(
|
|
814
|
+
(a) => !a.name.namespace && a.name.localName === "cap" && a.value !== "none"
|
|
815
|
+
))
|
|
816
|
+
unsupported();
|
|
817
|
+
node.children.forEach(check);
|
|
818
|
+
};
|
|
819
|
+
xml.root.children.forEach(check);
|
|
820
|
+
const margins = {
|
|
821
|
+
marginLeft: options.marginLeft ?? formatting.marginLeft ?? 7.2,
|
|
822
|
+
marginRight: options.marginRight ?? formatting.marginRight ?? 7.2,
|
|
823
|
+
marginTop: options.marginTop ?? formatting.marginTop ?? 3.6,
|
|
824
|
+
marginBottom: options.marginBottom ?? formatting.marginBottom ?? 3.6
|
|
825
|
+
};
|
|
826
|
+
for (const key of Object.keys(margins))
|
|
827
|
+
margins[key] = Math.round(margins[key] * 12700) / 12700;
|
|
828
|
+
if (Object.values(margins).some((v) => v < 0)) unsupported();
|
|
829
|
+
const family = options.fontFamily ?? "Calibri", bold = options.bold ?? false, italic = options.italic ?? false;
|
|
830
|
+
const lineSpacing = Math.round((options.lineSpacing ?? 1) * 1e5) / 1e5;
|
|
831
|
+
if (width < margins.marginLeft + margins.marginRight || height < margins.marginTop + margins.marginBottom)
|
|
832
|
+
unsupported();
|
|
833
|
+
const size = bestFitText(options.metrics, new TextFrame(xml).text, {
|
|
834
|
+
family,
|
|
835
|
+
bold,
|
|
836
|
+
italic,
|
|
837
|
+
width: width - margins.marginLeft - margins.marginRight,
|
|
838
|
+
height: height - margins.marginTop - margins.marginBottom,
|
|
839
|
+
minSize: options.minSize ?? 1,
|
|
840
|
+
maxSize: options.maxSize ?? 18,
|
|
841
|
+
wrap: options.wrap ?? true,
|
|
842
|
+
lineSpacing,
|
|
843
|
+
preserveBreaks: true,
|
|
844
|
+
preserveSpaces: true
|
|
845
|
+
});
|
|
846
|
+
if (size === null)
|
|
847
|
+
throw new OfficeError(
|
|
848
|
+
"unsupported-edit",
|
|
849
|
+
"Text does not fit within the supplied size bounds.",
|
|
850
|
+
"validate-intent"
|
|
851
|
+
);
|
|
852
|
+
let result = applyFrameFormatting(xml, xml.root, {
|
|
853
|
+
...margins,
|
|
854
|
+
wrap: options.wrap ?? true,
|
|
855
|
+
autofit: "none"
|
|
856
|
+
});
|
|
857
|
+
const paragraphIndexes = result.root.children.flatMap(
|
|
858
|
+
(p, i) => p.name.namespace === ns && p.name.localName === "p" ? [i] : []
|
|
859
|
+
);
|
|
860
|
+
for (const index of paragraphIndexes) {
|
|
861
|
+
if (!result.root.children[index].children.some(
|
|
862
|
+
(n) => n.name.namespace === ns && n.name.localName === "pPr"
|
|
863
|
+
))
|
|
864
|
+
result = result.spliceChildren(result.root.children[index], 0, 0, [`<pPr xmlns="${ns}"/>`]);
|
|
865
|
+
if (!result.root.children[index].children.some(
|
|
866
|
+
(n) => n.name.namespace === ns && n.name.localName === "endParaRPr"
|
|
867
|
+
))
|
|
868
|
+
result = result.spliceChildren(
|
|
869
|
+
result.root.children[index],
|
|
870
|
+
result.root.children[index].children.length,
|
|
871
|
+
0,
|
|
872
|
+
[`<endParaRPr xmlns="${ns}"/>`]
|
|
873
|
+
);
|
|
874
|
+
result = result.merge(result.root.children[index], {
|
|
875
|
+
children: {
|
|
876
|
+
sequence: ["pPr", "endParaRPr"].map(name),
|
|
877
|
+
remove: [],
|
|
878
|
+
upsert: [
|
|
879
|
+
{
|
|
880
|
+
name: name("pPr"),
|
|
881
|
+
merge: paragraphPropertiesMerge(
|
|
882
|
+
{
|
|
883
|
+
lineSpacing: { unit: "multiple", value: lineSpacing },
|
|
884
|
+
spaceBefore: 0,
|
|
885
|
+
spaceAfter: 0
|
|
886
|
+
},
|
|
887
|
+
ns
|
|
888
|
+
)
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
name: name("endParaRPr"),
|
|
892
|
+
merge: runPropertiesMerge({ font: family, size, bold, italic }, ns)
|
|
893
|
+
}
|
|
894
|
+
]
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
const paragraph = result.root.children[index];
|
|
898
|
+
for (const [childIndex, child2] of paragraph.children.entries()) {
|
|
899
|
+
if (child2.name.namespace !== ns || !["r", "fld", "br"].includes(child2.name.localName))
|
|
900
|
+
continue;
|
|
901
|
+
result = result.merge(result.root.children[index].children[childIndex], {
|
|
902
|
+
children: {
|
|
903
|
+
sequence: ["rPr", "pPr", "t"].map(name),
|
|
904
|
+
remove: [],
|
|
905
|
+
upsert: [
|
|
906
|
+
{
|
|
907
|
+
name: name("rPr"),
|
|
908
|
+
merge: runPropertiesMerge({ font: family, size, bold, italic }, ns)
|
|
909
|
+
}
|
|
910
|
+
]
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
return { xml: result, size };
|
|
916
|
+
}
|
|
917
|
+
async function fitTextFrames(input, options, context) {
|
|
918
|
+
validateTextFitOptions(options);
|
|
919
|
+
if (!options.all && options.select === void 0 && options.shape === void 0)
|
|
920
|
+
throw new SelectionError("missing-selection");
|
|
921
|
+
const state = await loadShared(input, context);
|
|
922
|
+
const bodies = (await readTextBodies(
|
|
923
|
+
state.source,
|
|
924
|
+
{
|
|
925
|
+
...options.scope === void 0 ? {} : { scope: options.scope },
|
|
926
|
+
...options.select === void 0 ? {} : { select: options.select },
|
|
927
|
+
...options.shape === void 0 ? {} : { shape: options.shape }
|
|
928
|
+
},
|
|
929
|
+
context
|
|
930
|
+
).catch((error) => {
|
|
931
|
+
if (error instanceof SelectionError && error.code === "missing-selection") return [];
|
|
932
|
+
throw error;
|
|
933
|
+
})).filter((b) => b.segment.cell === void 0);
|
|
934
|
+
if (!bodies.length && !options.allowEmpty) throw new SelectionError("missing-selection");
|
|
935
|
+
if (bodies.length > 1 && !options.all) throw new SelectionError("ambiguous-selection");
|
|
936
|
+
const documents = /* @__PURE__ */ new Map();
|
|
937
|
+
const sizes2 = [];
|
|
938
|
+
for (const body of bodies) {
|
|
939
|
+
let locate2 = function(node2) {
|
|
940
|
+
if (node2 === body.node) return true;
|
|
941
|
+
for (const [i, child2] of node2.children.entries()) {
|
|
942
|
+
path.push(i);
|
|
943
|
+
if (locate2(child2)) return true;
|
|
944
|
+
path.pop();
|
|
945
|
+
}
|
|
946
|
+
return false;
|
|
947
|
+
};
|
|
948
|
+
var locate = locate2;
|
|
949
|
+
context.signal?.throwIfAborted();
|
|
950
|
+
const path = [];
|
|
951
|
+
if (!locate2(body.document.root)) unsupported();
|
|
952
|
+
const parentPath = path.slice(0, -1);
|
|
953
|
+
const parent = parentPath.reduce((n, i) => n.children[i], body.document.root);
|
|
954
|
+
const shapeNs = parent.name.namespace;
|
|
955
|
+
const props2 = parent.children.find(
|
|
956
|
+
(n) => n.name.namespace === shapeNs && n.name.localName === "spPr"
|
|
957
|
+
);
|
|
958
|
+
const transform = props2?.children.find(
|
|
959
|
+
(n) => n.name.localName === "xfrm" && n.name.namespace === (shapeNs.includes("purl.oclc.org") ? "http://purl.oclc.org/ooxml/drawingml/main" : "http://schemas.openxmlformats.org/drawingml/2006/main")
|
|
960
|
+
);
|
|
961
|
+
const extent = transform?.children.find(
|
|
962
|
+
(n) => n.name.namespace === transform.name.namespace && n.name.localName === "ext"
|
|
963
|
+
);
|
|
964
|
+
if (!extent) unsupported();
|
|
965
|
+
const dimension = (key) => {
|
|
966
|
+
const raw2 = extent.attributes.find(
|
|
967
|
+
(a) => !a.name.namespace && a.name.localName === key
|
|
968
|
+
)?.value;
|
|
969
|
+
if (!raw2 || [...raw2].some((c) => c < "0" || c > "9") || !Number.isSafeInteger(Number(raw2)))
|
|
970
|
+
unsupported();
|
|
971
|
+
return Number(raw2) / 12700;
|
|
972
|
+
};
|
|
973
|
+
let document = documents.get(body.part) ?? body.document;
|
|
974
|
+
const node = path.reduce((n, i) => n.children[i], document.root);
|
|
975
|
+
const standalone = parseXmlPart(
|
|
976
|
+
new TextEncoder().encode(document.markup(node, true)),
|
|
977
|
+
context.xmlLimits
|
|
978
|
+
);
|
|
979
|
+
const fitted = fitFrameXml(standalone, options, dimension("cx"), dimension("cy"));
|
|
980
|
+
document = document.spliceChildren(
|
|
981
|
+
parentPath.reduce((n, i) => n.children[i], document.root),
|
|
982
|
+
path.at(-1),
|
|
983
|
+
1,
|
|
984
|
+
[new TextDecoder().decode(fitted.xml.bytes())]
|
|
985
|
+
);
|
|
986
|
+
documents.set(body.part, document);
|
|
987
|
+
sizes2.push(fitted.size);
|
|
988
|
+
}
|
|
989
|
+
for (const [part, document] of documents) state.save(part, document);
|
|
990
|
+
return {
|
|
991
|
+
bytes: bodies.length ? (await state.finish(state.main, [])).bytes : state.source,
|
|
992
|
+
affected: bodies.length,
|
|
993
|
+
locations: bodies.map((b) => b.segment.location),
|
|
994
|
+
sizes: sizes2
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// packages/safe-bash-presentation-engine/src/text-frames.ts
|
|
999
|
+
import { SaxesParser } from "saxes";
|
|
1000
|
+
|
|
1001
|
+
// packages/safe-bash-presentation-engine/src/text-frame-enums.ts
|
|
1002
|
+
var AutoSizeValue = /* @__PURE__ */ ((AutoSizeValue2) => {
|
|
1003
|
+
AutoSizeValue2[AutoSizeValue2["NONE"] = 0] = "NONE";
|
|
1004
|
+
AutoSizeValue2[AutoSizeValue2["SHAPE_TO_FIT_TEXT"] = 1] = "SHAPE_TO_FIT_TEXT";
|
|
1005
|
+
AutoSizeValue2[AutoSizeValue2["TEXT_TO_FIT_SHAPE"] = 2] = "TEXT_TO_FIT_SHAPE";
|
|
1006
|
+
AutoSizeValue2[AutoSizeValue2["MIXED"] = -2] = "MIXED";
|
|
1007
|
+
return AutoSizeValue2;
|
|
1008
|
+
})(AutoSizeValue || {});
|
|
1009
|
+
var VerticalAnchorValue = /* @__PURE__ */ ((VerticalAnchorValue2) => {
|
|
1010
|
+
VerticalAnchorValue2[VerticalAnchorValue2["TOP"] = 1] = "TOP";
|
|
1011
|
+
VerticalAnchorValue2[VerticalAnchorValue2["MIDDLE"] = 3] = "MIDDLE";
|
|
1012
|
+
VerticalAnchorValue2[VerticalAnchorValue2["BOTTOM"] = 4] = "BOTTOM";
|
|
1013
|
+
VerticalAnchorValue2[VerticalAnchorValue2["MIXED"] = -2] = "MIXED";
|
|
1014
|
+
return VerticalAnchorValue2;
|
|
1015
|
+
})(VerticalAnchorValue || {});
|
|
1016
|
+
var sizes = [
|
|
1017
|
+
{ name: "NONE", value: 0 },
|
|
1018
|
+
{ name: "SHAPE_TO_FIT_TEXT", value: 1 },
|
|
1019
|
+
{ name: "TEXT_TO_FIT_SHAPE", value: 2 },
|
|
1020
|
+
{ name: "MIXED", value: -2 }
|
|
1021
|
+
].map((value) => Object.freeze(value));
|
|
1022
|
+
var anchors = [
|
|
1023
|
+
{ name: "TOP", value: 1, xml_value: "t" },
|
|
1024
|
+
{ name: "MIDDLE", value: 3, xml_value: "ctr" },
|
|
1025
|
+
{ name: "BOTTOM", value: 4, xml_value: "b" },
|
|
1026
|
+
{ name: "MIXED", value: -2, xml_value: null }
|
|
1027
|
+
].map((value) => Object.freeze(value));
|
|
1028
|
+
function invalid() {
|
|
1029
|
+
throw new ValueError("Invalid text frame enumeration value.");
|
|
1030
|
+
}
|
|
1031
|
+
var MSO_AUTO_SIZE = Object.freeze(
|
|
1032
|
+
Object.assign(AutoSizeValue, {
|
|
1033
|
+
metadata(value) {
|
|
1034
|
+
return sizes.find((item) => item.value === value) ?? invalid();
|
|
1035
|
+
}
|
|
1036
|
+
})
|
|
1037
|
+
);
|
|
1038
|
+
var MSO_VERTICAL_ANCHOR = Object.freeze(
|
|
1039
|
+
Object.assign(VerticalAnchorValue, {
|
|
1040
|
+
metadata(value) {
|
|
1041
|
+
return anchors.find((item) => item.value === value) ?? invalid();
|
|
1042
|
+
},
|
|
1043
|
+
from_xml(xml_value) {
|
|
1044
|
+
return anchors.find((item) => item.xml_value !== null && item.xml_value === xml_value)?.value ?? invalid();
|
|
1045
|
+
},
|
|
1046
|
+
to_xml(value) {
|
|
1047
|
+
return anchors.find((item) => item.value === value)?.xml_value ?? invalid();
|
|
1048
|
+
},
|
|
1049
|
+
validate(value) {
|
|
1050
|
+
if (!anchors.some((item) => item.value === value && item.xml_value !== null)) invalid();
|
|
1051
|
+
}
|
|
1052
|
+
})
|
|
1053
|
+
);
|
|
1054
|
+
|
|
1055
|
+
// packages/safe-bash-presentation-engine/src/text-frames.ts
|
|
1056
|
+
var textVerticalModes = [
|
|
1057
|
+
"horz",
|
|
1058
|
+
"vert",
|
|
1059
|
+
"vert270",
|
|
1060
|
+
"wordArtVert",
|
|
1061
|
+
"eaVert",
|
|
1062
|
+
"mongolianVert",
|
|
1063
|
+
"wordArtVertRtl"
|
|
1064
|
+
];
|
|
1065
|
+
var drawingNamespaces = [
|
|
1066
|
+
"http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
1067
|
+
"http://purl.oclc.org/ooxml/drawingml/main"
|
|
1068
|
+
];
|
|
1069
|
+
var keys = [
|
|
1070
|
+
"marginLeft",
|
|
1071
|
+
"marginRight",
|
|
1072
|
+
"marginTop",
|
|
1073
|
+
"marginBottom",
|
|
1074
|
+
"verticalAnchor",
|
|
1075
|
+
"columns",
|
|
1076
|
+
"wrap",
|
|
1077
|
+
"verticalText",
|
|
1078
|
+
"rotation",
|
|
1079
|
+
"autofit",
|
|
1080
|
+
"text"
|
|
1081
|
+
];
|
|
1082
|
+
var insetAttributes = {
|
|
1083
|
+
marginLeft: "lIns",
|
|
1084
|
+
marginRight: "rIns",
|
|
1085
|
+
marginTop: "tIns",
|
|
1086
|
+
marginBottom: "bIns"
|
|
1087
|
+
};
|
|
1088
|
+
var anchorValues = { top: "t", middle: "ctr", bottom: "b", 1: "t", 3: "ctr", 4: "b" };
|
|
1089
|
+
var fitValues = {
|
|
1090
|
+
none: "noAutofit",
|
|
1091
|
+
shape: "spAutoFit",
|
|
1092
|
+
text: "normAutofit",
|
|
1093
|
+
0: "noAutofit",
|
|
1094
|
+
1: "spAutoFit",
|
|
1095
|
+
2: "normAutofit"
|
|
1096
|
+
};
|
|
1097
|
+
function invalid2() {
|
|
1098
|
+
throw new OfficeError("invalid-value", "Invalid text frame options.", "usage");
|
|
1099
|
+
}
|
|
1100
|
+
function malformed() {
|
|
1101
|
+
throw new OfficeError("invalid-xml", "Invalid text frame properties.", "parse");
|
|
1102
|
+
}
|
|
1103
|
+
function validateTextFrameOptions(options) {
|
|
1104
|
+
if (!options || typeof options !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(options)) || Object.keys(options).some(
|
|
1105
|
+
(k) => ![...keys, "scope", "select", "shape", "all", "allowEmpty"].includes(k)
|
|
1106
|
+
) || !keys.some((k) => options[k] !== void 0))
|
|
1107
|
+
invalid2();
|
|
1108
|
+
const { scope, select, shape } = options;
|
|
1109
|
+
validateTextReadingOptions({
|
|
1110
|
+
...scope === void 0 ? {} : { scope },
|
|
1111
|
+
...select === void 0 ? {} : { select },
|
|
1112
|
+
...shape === void 0 ? {} : { shape }
|
|
1113
|
+
});
|
|
1114
|
+
for (const key of ["all", "allowEmpty"])
|
|
1115
|
+
if (options[key] !== void 0 && typeof options[key] !== "boolean") invalid2();
|
|
1116
|
+
for (const key of Object.keys(insetAttributes)) {
|
|
1117
|
+
const v = options[key];
|
|
1118
|
+
if (v != null && (typeof v !== "number" || !Number.isFinite(v) || v < -2147483648 / 12700 || v > 2147483647 / 12700))
|
|
1119
|
+
invalid2();
|
|
1120
|
+
}
|
|
1121
|
+
if (options.wrap != null && typeof options.wrap !== "boolean") invalid2();
|
|
1122
|
+
if (options.columns != null && (!Number.isInteger(options.columns) || options.columns < 1 || options.columns > 16))
|
|
1123
|
+
invalid2();
|
|
1124
|
+
if (options.rotation != null && (typeof options.rotation !== "number" || !Number.isFinite(options.rotation) || options.rotation < -2147483648 / 6e4 || options.rotation > 2147483647 / 6e4))
|
|
1125
|
+
invalid2();
|
|
1126
|
+
if (options.verticalText != null && !textVerticalModes.includes(options.verticalText)) invalid2();
|
|
1127
|
+
if (options.verticalAnchor != null && !(typeof options.verticalAnchor === "number" ? [1, 3, 4].includes(options.verticalAnchor) : ["top", "middle", "bottom"].includes(options.verticalAnchor)))
|
|
1128
|
+
invalid2();
|
|
1129
|
+
if (options.autofit != null && !(typeof options.autofit === "number" ? [0, 1, 2].includes(options.autofit) : ["none", "shape", "text"].includes(options.autofit)))
|
|
1130
|
+
invalid2();
|
|
1131
|
+
if (options.text !== void 0 && typeof options.text !== "string") invalid2();
|
|
1132
|
+
}
|
|
1133
|
+
function bodyProperties(body) {
|
|
1134
|
+
if (!(body.name.localName === "txBody" && [
|
|
1135
|
+
...drawingNamespaces,
|
|
1136
|
+
"http://schemas.openxmlformats.org/presentationml/2006/main",
|
|
1137
|
+
"http://purl.oclc.org/ooxml/presentationml/main"
|
|
1138
|
+
].includes(body.name.namespace)) && !(["rich", "txPr"].includes(body.name.localName) && [
|
|
1139
|
+
"http://schemas.openxmlformats.org/drawingml/2006/chart",
|
|
1140
|
+
"http://purl.oclc.org/ooxml/drawingml/chart"
|
|
1141
|
+
].includes(body.name.namespace)))
|
|
1142
|
+
malformed();
|
|
1143
|
+
const children = body.children.filter(
|
|
1144
|
+
(n) => drawingNamespaces.includes(n.name.namespace) && n.name.localName === "bodyPr"
|
|
1145
|
+
);
|
|
1146
|
+
if (children.length > 1) malformed();
|
|
1147
|
+
return children[0];
|
|
1148
|
+
}
|
|
1149
|
+
function readFrameFormatting(body) {
|
|
1150
|
+
const p = bodyProperties(body);
|
|
1151
|
+
const attr2 = (key) => p?.attributes.find((a) => !a.name.namespace && a.name.localName === key)?.value ?? null;
|
|
1152
|
+
const number2 = (key, scale) => {
|
|
1153
|
+
const raw2 = attr2(key);
|
|
1154
|
+
if (raw2 === null) return null;
|
|
1155
|
+
const token = raw2.trim();
|
|
1156
|
+
const digits = token.startsWith("+") || token.startsWith("-") ? token.slice(1) : token;
|
|
1157
|
+
if (!digits.length || Array.from(digits).some((c) => c < "0" || c > "9") || !Number.isSafeInteger(Number(raw2)))
|
|
1158
|
+
malformed();
|
|
1159
|
+
return Number(raw2) / scale;
|
|
1160
|
+
};
|
|
1161
|
+
const wrap = attr2("wrap"), anchor = attr2("anchor"), vertical = attr2("vert");
|
|
1162
|
+
if (wrap !== null && !["square", "none"].includes(wrap)) malformed();
|
|
1163
|
+
const fits = p?.children.filter(
|
|
1164
|
+
(n) => n.name.namespace === p.name.namespace && ["noAutofit", "normAutofit", "spAutoFit"].includes(n.name.localName)
|
|
1165
|
+
) ?? [];
|
|
1166
|
+
if (fits.length > 1) malformed();
|
|
1167
|
+
const result = {
|
|
1168
|
+
marginLeft: number2("lIns", 12700),
|
|
1169
|
+
marginRight: number2("rIns", 12700),
|
|
1170
|
+
marginTop: number2("tIns", 12700),
|
|
1171
|
+
marginBottom: number2("bIns", 12700),
|
|
1172
|
+
verticalAnchor: anchor === null ? null : { t: "top", ctr: "middle", b: "bottom" }[anchor] ?? anchor,
|
|
1173
|
+
columns: number2("numCol", 1),
|
|
1174
|
+
wrap: wrap === null ? null : wrap === "square",
|
|
1175
|
+
verticalText: vertical,
|
|
1176
|
+
rotation: number2("rot", 6e4),
|
|
1177
|
+
autofit: fits.length ? { noAutofit: "none", spAutoFit: "shape", normAutofit: "text" }[fits[0].name.localName] : null
|
|
1178
|
+
};
|
|
1179
|
+
try {
|
|
1180
|
+
if (anchor !== null && !["t", "ctr", "b", "just", "dist"].includes(anchor)) malformed();
|
|
1181
|
+
validateTextFrameOptions({ ...result, verticalAnchor: null });
|
|
1182
|
+
} catch {
|
|
1183
|
+
malformed();
|
|
1184
|
+
}
|
|
1185
|
+
return result;
|
|
1186
|
+
}
|
|
1187
|
+
function applyFrameFormatting(document, node, options) {
|
|
1188
|
+
validateTextFrameOptions(options);
|
|
1189
|
+
readFrameFormatting(node);
|
|
1190
|
+
if (options.text !== void 0 && (protectedEquationNodes(node).size > 0 || protectedEquationNodes(document.root).has(node)))
|
|
1191
|
+
throw new OfficeError(
|
|
1192
|
+
"unsupported-edit",
|
|
1193
|
+
"Whole text replacement cannot remove equations or their fallbacks.",
|
|
1194
|
+
"validate-intent"
|
|
1195
|
+
);
|
|
1196
|
+
const path = [];
|
|
1197
|
+
function locate(current2) {
|
|
1198
|
+
if (current2 === node) return true;
|
|
1199
|
+
for (const [i, c] of current2.children.entries()) {
|
|
1200
|
+
path.push(i);
|
|
1201
|
+
if (locate(c)) return true;
|
|
1202
|
+
path.pop();
|
|
1203
|
+
}
|
|
1204
|
+
return false;
|
|
1205
|
+
}
|
|
1206
|
+
if (!locate(document.root)) invalid2();
|
|
1207
|
+
let result = document;
|
|
1208
|
+
const current = () => path.reduce((n, i) => n.children[i], result.root);
|
|
1209
|
+
let p = bodyProperties(node);
|
|
1210
|
+
const ns = p?.name.namespace ?? (node.name.namespace.includes("purl.oclc.org") ? drawingNamespaces[1] : drawingNamespaces[0]);
|
|
1211
|
+
if (!p) {
|
|
1212
|
+
result = result.spliceChildren(current(), 0, 0, [`<bodyPr xmlns="${ns}"/>`]);
|
|
1213
|
+
p = bodyProperties(current());
|
|
1214
|
+
}
|
|
1215
|
+
const attributes = [];
|
|
1216
|
+
for (const [key, localName] of Object.entries(insetAttributes)) {
|
|
1217
|
+
const value = options[key];
|
|
1218
|
+
if (value !== void 0)
|
|
1219
|
+
attributes.push({
|
|
1220
|
+
namespace: "",
|
|
1221
|
+
localName,
|
|
1222
|
+
value: value === null ? null : String(Math.sign(value) * Math.round(Math.abs(value) * 12700))
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
for (const [key, localName] of [
|
|
1226
|
+
["columns", "numCol"],
|
|
1227
|
+
["wrap", "wrap"],
|
|
1228
|
+
["verticalText", "vert"],
|
|
1229
|
+
["rotation", "rot"],
|
|
1230
|
+
["verticalAnchor", "anchor"]
|
|
1231
|
+
]) {
|
|
1232
|
+
const value = options[key];
|
|
1233
|
+
if (value === void 0) continue;
|
|
1234
|
+
attributes.push({
|
|
1235
|
+
namespace: "",
|
|
1236
|
+
localName,
|
|
1237
|
+
value: value === null ? null : key === "wrap" ? value ? "square" : "none" : key === "rotation" ? String(Math.sign(Number(value)) * Math.round(Math.abs(Number(value)) * 6e4)) : key === "verticalAnchor" ? anchorValues[value] : String(value)
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
const name = (localName) => ({ namespace: ns, localName });
|
|
1241
|
+
const fit = options.autofit == null ? null : fitValues[options.autofit];
|
|
1242
|
+
result = result.merge(p, {
|
|
1243
|
+
attributes,
|
|
1244
|
+
...options.autofit === void 0 ? {} : {
|
|
1245
|
+
children: {
|
|
1246
|
+
sequence: [
|
|
1247
|
+
"prstTxWarp",
|
|
1248
|
+
"noAutofit",
|
|
1249
|
+
"normAutofit",
|
|
1250
|
+
"spAutoFit",
|
|
1251
|
+
"scene3d",
|
|
1252
|
+
"sp3d",
|
|
1253
|
+
"flatTx",
|
|
1254
|
+
"extLst"
|
|
1255
|
+
].map(name),
|
|
1256
|
+
remove: ["noAutofit", "normAutofit", "spAutoFit"].filter((n) => n !== fit).map(name),
|
|
1257
|
+
upsert: fit ? [{ name: name(fit), merge: {} }] : []
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
if (options.text !== void 0) {
|
|
1262
|
+
const paragraphs = current().children.flatMap(
|
|
1263
|
+
(n, i) => n.name.namespace === ns && n.name.localName === "p" ? [i] : []
|
|
1264
|
+
);
|
|
1265
|
+
const position = paragraphs[0] ?? current().children.length;
|
|
1266
|
+
for (const index of paragraphs.reverse())
|
|
1267
|
+
result = result.spliceChildren(current(), index, 1, []);
|
|
1268
|
+
const escape = (text) => Array.from(text).map((c) => {
|
|
1269
|
+
const point = c.codePointAt(0);
|
|
1270
|
+
return point < 32 && ![9, 10, 13].includes(point) || point >= 55296 && point <= 57343 || [65534, 65535].includes(point) ? `_x${point.toString(16).toUpperCase().padStart(4, "0")}_` : c === "&" ? "&" : c === "<" ? "<" : c === "\r" ? " " : c;
|
|
1271
|
+
}).join("");
|
|
1272
|
+
const fragments = options.text.split("\n").map(
|
|
1273
|
+
(text) => `<p xmlns="${ns}">${text.split("\v").map((piece) => piece ? `<r><t>${escape(piece)}</t></r>` : "").join("<br/>")}</p>`
|
|
1274
|
+
);
|
|
1275
|
+
result = result.spliceChildren(current(), position, 0, fragments);
|
|
1276
|
+
}
|
|
1277
|
+
return result;
|
|
1278
|
+
}
|
|
1279
|
+
async function readTextFrames(input, options, context) {
|
|
1280
|
+
const bodies = await readTextBodies(input, options, context).catch((error) => {
|
|
1281
|
+
if (error instanceof SelectionError && error.code === "missing-selection") return [];
|
|
1282
|
+
throw error;
|
|
1283
|
+
});
|
|
1284
|
+
return bodies.filter((body) => body.segment.cell === void 0).map((body) => ({
|
|
1285
|
+
location: body.segment.location,
|
|
1286
|
+
formatting: readFrameFormatting(body.node)
|
|
1287
|
+
}));
|
|
1288
|
+
}
|
|
1289
|
+
async function mutateTextFrames(input, options, context) {
|
|
1290
|
+
validateTextFrameOptions(options);
|
|
1291
|
+
if (!options.all && options.select === void 0 && options.shape === void 0)
|
|
1292
|
+
throw new SelectionError("missing-selection");
|
|
1293
|
+
const state = await loadShared(input, context);
|
|
1294
|
+
const { scope, select, shape } = options;
|
|
1295
|
+
const bodies = await readTextBodies(
|
|
1296
|
+
state.source,
|
|
1297
|
+
{
|
|
1298
|
+
...scope === void 0 ? {} : { scope },
|
|
1299
|
+
...select === void 0 ? {} : { select },
|
|
1300
|
+
...shape === void 0 ? {} : { shape }
|
|
1301
|
+
},
|
|
1302
|
+
context
|
|
1303
|
+
).catch((error) => {
|
|
1304
|
+
if (error instanceof SelectionError && error.code === "missing-selection") return [];
|
|
1305
|
+
throw error;
|
|
1306
|
+
}).then((bodies2) => bodies2.filter((body) => body.segment.cell === void 0));
|
|
1307
|
+
if (!bodies.length && !options.allowEmpty) throw new SelectionError("missing-selection");
|
|
1308
|
+
if (bodies.length > 1 && !options.all) throw new SelectionError("ambiguous-selection");
|
|
1309
|
+
const edits = /* @__PURE__ */ new Map();
|
|
1310
|
+
for (const body of bodies) {
|
|
1311
|
+
const edit = edits.get(body.part) ?? { document: body.document, nodes: /* @__PURE__ */ new Set() };
|
|
1312
|
+
edit.nodes.add(body.node);
|
|
1313
|
+
edits.set(body.part, edit);
|
|
1314
|
+
}
|
|
1315
|
+
for (const [part, edit] of edits) {
|
|
1316
|
+
const paths = [];
|
|
1317
|
+
const visit = (node, path) => {
|
|
1318
|
+
if (edit.nodes.has(node)) paths.push(path);
|
|
1319
|
+
node.children.forEach((n, i) => visit(n, [...path, i]));
|
|
1320
|
+
};
|
|
1321
|
+
visit(edit.document.root, []);
|
|
1322
|
+
let document = edit.document;
|
|
1323
|
+
for (const path of paths.reverse()) {
|
|
1324
|
+
context.signal?.throwIfAborted();
|
|
1325
|
+
document = applyFrameFormatting(
|
|
1326
|
+
document,
|
|
1327
|
+
path.reduce((n, i) => n.children[i], document.root),
|
|
1328
|
+
options
|
|
1329
|
+
);
|
|
1330
|
+
}
|
|
1331
|
+
state.save(part, document);
|
|
1332
|
+
}
|
|
1333
|
+
return {
|
|
1334
|
+
bytes: bodies.length ? (await state.finish(state.main, [])).bytes : state.source,
|
|
1335
|
+
affected: bodies.length,
|
|
1336
|
+
locations: bodies.map((b) => b.segment.location)
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
var TextFrame = class {
|
|
1340
|
+
#paragraphs = [];
|
|
1341
|
+
#storedXml;
|
|
1342
|
+
#binding;
|
|
1343
|
+
get #xml() {
|
|
1344
|
+
return this.#binding?.read() ?? this.#storedXml;
|
|
1345
|
+
}
|
|
1346
|
+
set #xml(xml) {
|
|
1347
|
+
if (this.#binding) this.#binding.write(xml);
|
|
1348
|
+
else this.#storedXml = xml;
|
|
1349
|
+
}
|
|
1350
|
+
#extents;
|
|
1351
|
+
constructor(xml, extents, binding) {
|
|
1352
|
+
readFrameFormatting(xml.root);
|
|
1353
|
+
this.#storedXml = xml;
|
|
1354
|
+
this.#binding = binding;
|
|
1355
|
+
this.#extents = extents === void 0 ? void 0 : { ...extents };
|
|
1356
|
+
}
|
|
1357
|
+
fit_text(font_family = "Calibri", max_size = 18, bold = false, italic = false, font_file, options = {}) {
|
|
1358
|
+
if (typeof font_family !== "string" || typeof max_size !== "number" || typeof bold !== "boolean" || typeof italic !== "boolean")
|
|
1359
|
+
throw new TypeError("Text fitting requires a font family, numeric size and boolean styles.");
|
|
1360
|
+
if (!options || typeof options !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(options)) || Reflect.ownKeys(options).some(
|
|
1361
|
+
(key) => typeof key !== "string" || ![
|
|
1362
|
+
"minSize",
|
|
1363
|
+
"marginLeft",
|
|
1364
|
+
"marginRight",
|
|
1365
|
+
"marginTop",
|
|
1366
|
+
"marginBottom",
|
|
1367
|
+
"wrap",
|
|
1368
|
+
"lineSpacing"
|
|
1369
|
+
].includes(key) || !Object.hasOwn(Object.getOwnPropertyDescriptor(options, key), "value")
|
|
1370
|
+
))
|
|
1371
|
+
throw new OfficeError("invalid-value", "Text fit options require stored data.", "usage");
|
|
1372
|
+
const extents = this.#binding?.extents ? this.#binding.extents() : this.#extents;
|
|
1373
|
+
const result = fitFrameXml(
|
|
1374
|
+
this.#xml,
|
|
1375
|
+
{ ...options, fontFamily: font_family, maxSize: max_size, bold, italic, metrics: font_file },
|
|
1376
|
+
extents?.width ?? NaN,
|
|
1377
|
+
extents?.height ?? NaN
|
|
1378
|
+
);
|
|
1379
|
+
this.#xml = result.xml;
|
|
1380
|
+
}
|
|
1381
|
+
get xml() {
|
|
1382
|
+
return this.#xml;
|
|
1383
|
+
}
|
|
1384
|
+
get parent() {
|
|
1385
|
+
return this.#binding?.parent;
|
|
1386
|
+
}
|
|
1387
|
+
get paragraphs() {
|
|
1388
|
+
const nodes = this.#xml.root.children.filter(
|
|
1389
|
+
(node) => node.name.localName === "p" && drawingNamespaces.includes(node.name.namespace)
|
|
1390
|
+
);
|
|
1391
|
+
return Object.freeze(
|
|
1392
|
+
nodes.map((_, index) => {
|
|
1393
|
+
if (this.#paragraphs[index]) return this.#paragraphs[index];
|
|
1394
|
+
let owner;
|
|
1395
|
+
let cached;
|
|
1396
|
+
const locate = () => {
|
|
1397
|
+
if (this.#paragraphs[index] !== handle) throw new InvalidHandleError();
|
|
1398
|
+
const xml = this.#xml;
|
|
1399
|
+
const node = xml.root.children.filter(
|
|
1400
|
+
(child2) => child2.name.localName === "p" && drawingNamespaces.includes(child2.name.namespace)
|
|
1401
|
+
)[index];
|
|
1402
|
+
if (!node) throw new InvalidHandleError();
|
|
1403
|
+
return { xml, node };
|
|
1404
|
+
};
|
|
1405
|
+
const read = () => {
|
|
1406
|
+
const { xml, node } = locate();
|
|
1407
|
+
if (owner !== xml) {
|
|
1408
|
+
cached = xml.subtree(node);
|
|
1409
|
+
owner = xml;
|
|
1410
|
+
}
|
|
1411
|
+
return cached;
|
|
1412
|
+
};
|
|
1413
|
+
const initial = this.#xml.subtree(nodes[index]);
|
|
1414
|
+
const handle = new Paragraph(initial, {
|
|
1415
|
+
parent: this,
|
|
1416
|
+
read,
|
|
1417
|
+
write: (value) => {
|
|
1418
|
+
const { xml, node } = locate();
|
|
1419
|
+
this.#xml = xml.spliceChildren(xml.root, xml.root.children.indexOf(node), 1, [
|
|
1420
|
+
value.markup(value.root, true)
|
|
1421
|
+
]);
|
|
1422
|
+
}
|
|
1423
|
+
});
|
|
1424
|
+
const hyperlink = textLinkCapabilities.get(this);
|
|
1425
|
+
if (hyperlink)
|
|
1426
|
+
textLinkCapabilities.set(
|
|
1427
|
+
handle,
|
|
1428
|
+
(path) => hyperlink(() => {
|
|
1429
|
+
const { xml, node } = locate();
|
|
1430
|
+
return [xml.root.children.indexOf(node), ...path()];
|
|
1431
|
+
})
|
|
1432
|
+
);
|
|
1433
|
+
this.#paragraphs[index] = handle;
|
|
1434
|
+
return handle;
|
|
1435
|
+
})
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
add_paragraph() {
|
|
1439
|
+
const xml = this.#xml;
|
|
1440
|
+
const ns = xml.root.name.namespace.includes("purl.oclc.org") ? drawingNamespaces[1] : drawingNamespaces[0];
|
|
1441
|
+
const extension = xml.root.children.findIndex((node) => node.name.localName === "extLst");
|
|
1442
|
+
this.#xml = xml.spliceChildren(
|
|
1443
|
+
xml.root,
|
|
1444
|
+
extension < 0 ? xml.root.children.length : extension,
|
|
1445
|
+
0,
|
|
1446
|
+
[`<p xmlns="${ns}"/>`]
|
|
1447
|
+
);
|
|
1448
|
+
return this.paragraphs.at(-1);
|
|
1449
|
+
}
|
|
1450
|
+
clear() {
|
|
1451
|
+
const xml = this.#xml;
|
|
1452
|
+
if (protectedEquationNodes(xml.root).size > 0)
|
|
1453
|
+
throw new OfficeError(
|
|
1454
|
+
"unsupported-edit",
|
|
1455
|
+
"Whole text replacement cannot remove equations or their fallbacks.",
|
|
1456
|
+
"validate-intent"
|
|
1457
|
+
);
|
|
1458
|
+
const first = this.paragraphs[0];
|
|
1459
|
+
if (!first) {
|
|
1460
|
+
this.add_paragraph();
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
first.clear();
|
|
1464
|
+
let current = this.#xml;
|
|
1465
|
+
const indexes = current.root.children.flatMap(
|
|
1466
|
+
(node, index) => node.name.localName === "p" && drawingNamespaces.includes(node.name.namespace) ? [index] : []
|
|
1467
|
+
);
|
|
1468
|
+
for (const index of indexes.slice(1).reverse())
|
|
1469
|
+
current = current.spliceChildren(current.root, index, 1, []);
|
|
1470
|
+
this.#xml = current;
|
|
1471
|
+
this.#paragraphs = [first];
|
|
1472
|
+
}
|
|
1473
|
+
get margin_left() {
|
|
1474
|
+
return new Pt(readFrameFormatting(this.#xml.root).marginLeft ?? 7.2);
|
|
1475
|
+
}
|
|
1476
|
+
set margin_left(value) {
|
|
1477
|
+
if (!(value instanceof Length)) invalid2();
|
|
1478
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, {
|
|
1479
|
+
marginLeft: value.emu === 91440 ? null : value.pt
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1482
|
+
get margin_right() {
|
|
1483
|
+
return new Pt(readFrameFormatting(this.#xml.root).marginRight ?? 7.2);
|
|
1484
|
+
}
|
|
1485
|
+
set margin_right(value) {
|
|
1486
|
+
if (!(value instanceof Length)) invalid2();
|
|
1487
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, {
|
|
1488
|
+
marginRight: value.emu === 91440 ? null : value.pt
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
get margin_top() {
|
|
1492
|
+
return new Pt(readFrameFormatting(this.#xml.root).marginTop ?? 3.6);
|
|
1493
|
+
}
|
|
1494
|
+
set margin_top(value) {
|
|
1495
|
+
if (!(value instanceof Length)) invalid2();
|
|
1496
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, {
|
|
1497
|
+
marginTop: value.emu === 45720 ? null : value.pt
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
get margin_bottom() {
|
|
1501
|
+
return new Pt(readFrameFormatting(this.#xml.root).marginBottom ?? 3.6);
|
|
1502
|
+
}
|
|
1503
|
+
set margin_bottom(value) {
|
|
1504
|
+
if (!(value instanceof Length)) invalid2();
|
|
1505
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, {
|
|
1506
|
+
marginBottom: value.emu === 45720 ? null : value.pt
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
get word_wrap() {
|
|
1510
|
+
return readFrameFormatting(this.#xml.root).wrap;
|
|
1511
|
+
}
|
|
1512
|
+
set word_wrap(value) {
|
|
1513
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, { wrap: value });
|
|
1514
|
+
}
|
|
1515
|
+
get auto_size() {
|
|
1516
|
+
const v = readFrameFormatting(this.#xml.root).autofit;
|
|
1517
|
+
return v === null ? null : { none: 0, shape: 1, text: 2 }[v];
|
|
1518
|
+
}
|
|
1519
|
+
set auto_size(value) {
|
|
1520
|
+
if (value !== null && (typeof value !== "number" || ![0, 1, 2].includes(value))) invalid2();
|
|
1521
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, { autofit: value });
|
|
1522
|
+
}
|
|
1523
|
+
get vertical_anchor() {
|
|
1524
|
+
const v = readFrameFormatting(this.#xml.root).verticalAnchor;
|
|
1525
|
+
if (v === "just" || v === "dist")
|
|
1526
|
+
throw new OfficeError(
|
|
1527
|
+
"unsupported-profile",
|
|
1528
|
+
"Extended frame anchor has no model enum value.",
|
|
1529
|
+
"parse"
|
|
1530
|
+
);
|
|
1531
|
+
return v === null ? null : { top: 1, middle: 3, bottom: 4 }[v];
|
|
1532
|
+
}
|
|
1533
|
+
set vertical_anchor(value) {
|
|
1534
|
+
if (value !== null && (typeof value !== "number" || ![1, 3, 4].includes(value))) invalid2();
|
|
1535
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, { verticalAnchor: value });
|
|
1536
|
+
}
|
|
1537
|
+
get columns() {
|
|
1538
|
+
return readFrameFormatting(this.#xml.root).columns ?? 1;
|
|
1539
|
+
}
|
|
1540
|
+
set columns(value) {
|
|
1541
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, { columns: value });
|
|
1542
|
+
}
|
|
1543
|
+
get vertical_text() {
|
|
1544
|
+
return readFrameFormatting(this.#xml.root).verticalText;
|
|
1545
|
+
}
|
|
1546
|
+
set vertical_text(value) {
|
|
1547
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, { verticalText: value });
|
|
1548
|
+
}
|
|
1549
|
+
get rotation() {
|
|
1550
|
+
return readFrameFormatting(this.#xml.root).rotation ?? 0;
|
|
1551
|
+
}
|
|
1552
|
+
set rotation(value) {
|
|
1553
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, { rotation: value });
|
|
1554
|
+
}
|
|
1555
|
+
get text() {
|
|
1556
|
+
const body = this.#xml.root;
|
|
1557
|
+
const texts = (node) => {
|
|
1558
|
+
if (node.name.localName === "br" && drawingNamespaces.includes(node.name.namespace))
|
|
1559
|
+
return "\v";
|
|
1560
|
+
if (node.name.localName === "t" && drawingNamespaces.includes(node.name.namespace)) {
|
|
1561
|
+
const raw2 = this.#xml.markup(node);
|
|
1562
|
+
return decodeText(raw2);
|
|
1563
|
+
}
|
|
1564
|
+
return node.children.map(texts).join("");
|
|
1565
|
+
};
|
|
1566
|
+
return body.children.filter((n) => n.name.localName === "p" && drawingNamespaces.includes(n.name.namespace)).map(texts).join("\n");
|
|
1567
|
+
}
|
|
1568
|
+
set text(value) {
|
|
1569
|
+
this.#xml = applyFrameFormatting(this.#xml, this.#xml.root, { text: value });
|
|
1570
|
+
this.#paragraphs = [];
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
function decodeText(markup) {
|
|
1574
|
+
let result = "";
|
|
1575
|
+
const parser = new SaxesParser({ xmlns: false });
|
|
1576
|
+
parser.on("text", (value) => {
|
|
1577
|
+
result += value;
|
|
1578
|
+
});
|
|
1579
|
+
parser.on("cdata", (value) => {
|
|
1580
|
+
result += value;
|
|
1581
|
+
});
|
|
1582
|
+
parser.write(markup).close();
|
|
1583
|
+
return result;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
// packages/safe-bash-presentation-engine/src/shape-types.ts
|
|
1587
|
+
var values = {
|
|
1588
|
+
AUTO_SHAPE: 1,
|
|
1589
|
+
CALLOUT: 2,
|
|
1590
|
+
CANVAS: 20,
|
|
1591
|
+
CHART: 3,
|
|
1592
|
+
COMMENT: 4,
|
|
1593
|
+
DIAGRAM: 21,
|
|
1594
|
+
EMBEDDED_OLE_OBJECT: 7,
|
|
1595
|
+
FORM_CONTROL: 8,
|
|
1596
|
+
FREEFORM: 5,
|
|
1597
|
+
GROUP: 6,
|
|
1598
|
+
IGX_GRAPHIC: 24,
|
|
1599
|
+
INK: 22,
|
|
1600
|
+
INK_COMMENT: 23,
|
|
1601
|
+
LINE: 9,
|
|
1602
|
+
LINKED_OLE_OBJECT: 10,
|
|
1603
|
+
LINKED_PICTURE: 11,
|
|
1604
|
+
MEDIA: 16,
|
|
1605
|
+
OLE_CONTROL_OBJECT: 12,
|
|
1606
|
+
PICTURE: 13,
|
|
1607
|
+
PLACEHOLDER: 14,
|
|
1608
|
+
SCRIPT_ANCHOR: 18,
|
|
1609
|
+
TABLE: 19,
|
|
1610
|
+
TEXT_BOX: 17,
|
|
1611
|
+
TEXT_EFFECT: 15,
|
|
1612
|
+
WEB_VIDEO: 26,
|
|
1613
|
+
MIXED: -2
|
|
1614
|
+
};
|
|
1615
|
+
var entries = Object.keys(values).map(
|
|
1616
|
+
(name) => Object.freeze({ name, value: values[name] })
|
|
1617
|
+
);
|
|
1618
|
+
var MSO_SHAPE_TYPE = Object.freeze(
|
|
1619
|
+
Object.assign(values, {
|
|
1620
|
+
metadata(value) {
|
|
1621
|
+
const item = entries.find((e) => e.value === value);
|
|
1622
|
+
if (!item) throw new ValueError("Unknown shape category.");
|
|
1623
|
+
return item;
|
|
1624
|
+
}
|
|
1625
|
+
})
|
|
1626
|
+
);
|
|
1627
|
+
|
|
1628
|
+
// packages/safe-bash-presentation-engine/src/shape-placeholder-types.ts
|
|
1629
|
+
var values2 = {
|
|
1630
|
+
BITMAP: 9,
|
|
1631
|
+
BODY: 2,
|
|
1632
|
+
CENTER_TITLE: 3,
|
|
1633
|
+
CHART: 8,
|
|
1634
|
+
DATE: 16,
|
|
1635
|
+
FOOTER: 15,
|
|
1636
|
+
HEADER: 14,
|
|
1637
|
+
MEDIA_CLIP: 10,
|
|
1638
|
+
OBJECT: 7,
|
|
1639
|
+
ORG_CHART: 11,
|
|
1640
|
+
PICTURE: 18,
|
|
1641
|
+
SLIDE_IMAGE: 101,
|
|
1642
|
+
SLIDE_NUMBER: 13,
|
|
1643
|
+
SUBTITLE: 4,
|
|
1644
|
+
TABLE: 12,
|
|
1645
|
+
TITLE: 1,
|
|
1646
|
+
VERTICAL_BODY: 6,
|
|
1647
|
+
VERTICAL_OBJECT: 17,
|
|
1648
|
+
VERTICAL_TITLE: 5,
|
|
1649
|
+
MIXED: -2
|
|
1650
|
+
};
|
|
1651
|
+
var entries2 = [
|
|
1652
|
+
{ name: "BITMAP", value: 9, xml_value: "clipArt" },
|
|
1653
|
+
{ name: "BODY", value: 2, xml_value: "body" },
|
|
1654
|
+
{ name: "CENTER_TITLE", value: 3, xml_value: "ctrTitle" },
|
|
1655
|
+
{ name: "CHART", value: 8, xml_value: "chart" },
|
|
1656
|
+
{ name: "DATE", value: 16, xml_value: "dt" },
|
|
1657
|
+
{ name: "FOOTER", value: 15, xml_value: "ftr" },
|
|
1658
|
+
{ name: "HEADER", value: 14, xml_value: "hdr" },
|
|
1659
|
+
{ name: "MEDIA_CLIP", value: 10, xml_value: "media" },
|
|
1660
|
+
{ name: "OBJECT", value: 7, xml_value: "obj" },
|
|
1661
|
+
{ name: "ORG_CHART", value: 11, xml_value: "dgm" },
|
|
1662
|
+
{ name: "PICTURE", value: 18, xml_value: "pic" },
|
|
1663
|
+
{ name: "SLIDE_IMAGE", value: 101, xml_value: "sldImg" },
|
|
1664
|
+
{ name: "SLIDE_NUMBER", value: 13, xml_value: "sldNum" },
|
|
1665
|
+
{ name: "SUBTITLE", value: 4, xml_value: "subTitle" },
|
|
1666
|
+
{ name: "TABLE", value: 12, xml_value: "tbl" },
|
|
1667
|
+
{ name: "TITLE", value: 1, xml_value: "title" },
|
|
1668
|
+
{ name: "VERTICAL_BODY", value: 6, xml_value: null },
|
|
1669
|
+
{ name: "VERTICAL_OBJECT", value: 17, xml_value: null },
|
|
1670
|
+
{ name: "VERTICAL_TITLE", value: 5, xml_value: null },
|
|
1671
|
+
{ name: "MIXED", value: -2, xml_value: null }
|
|
1672
|
+
];
|
|
1673
|
+
function invalid3() {
|
|
1674
|
+
throw new ValueError("Unsupported placeholder type.");
|
|
1675
|
+
}
|
|
1676
|
+
var PP_PLACEHOLDER_TYPE = Object.freeze(
|
|
1677
|
+
Object.assign(values2, {
|
|
1678
|
+
metadata(value) {
|
|
1679
|
+
const item = entries2.find((e) => e.value === value);
|
|
1680
|
+
return item ? Object.freeze({ ...item }) : invalid3();
|
|
1681
|
+
},
|
|
1682
|
+
from_xml(value) {
|
|
1683
|
+
return entries2.find((e) => e.xml_value !== null && e.xml_value === value)?.value ?? invalid3();
|
|
1684
|
+
},
|
|
1685
|
+
to_xml(value) {
|
|
1686
|
+
return entries2.find((e) => e.value === value)?.xml_value ?? invalid3();
|
|
1687
|
+
},
|
|
1688
|
+
validate(value) {
|
|
1689
|
+
if (!entries2.some((e) => e.value === value && e.xml_value !== null)) invalid3();
|
|
1690
|
+
}
|
|
1691
|
+
})
|
|
1692
|
+
);
|
|
1693
|
+
|
|
1694
|
+
// packages/safe-bash-presentation-engine/src/drawing-enums.ts
|
|
1695
|
+
var MSO_FILL_TYPE = defineEnum({
|
|
1696
|
+
SOLID: 1,
|
|
1697
|
+
PATTERNED: 2,
|
|
1698
|
+
GRADIENT: 3,
|
|
1699
|
+
TEXTURED: 4,
|
|
1700
|
+
BACKGROUND: 5,
|
|
1701
|
+
PICTURE: 6,
|
|
1702
|
+
GROUP: 101
|
|
1703
|
+
});
|
|
1704
|
+
var MSO_FILL = MSO_FILL_TYPE;
|
|
1705
|
+
var lineValues = {
|
|
1706
|
+
SOLID: 1,
|
|
1707
|
+
SQUARE_DOT: 2,
|
|
1708
|
+
ROUND_DOT: 3,
|
|
1709
|
+
DASH: 4,
|
|
1710
|
+
DASH_DOT: 5,
|
|
1711
|
+
DASH_DOT_DOT: 6,
|
|
1712
|
+
LONG_DASH: 7,
|
|
1713
|
+
LONG_DASH_DOT: 8,
|
|
1714
|
+
DASH_STYLE_MIXED: -2
|
|
1715
|
+
};
|
|
1716
|
+
var dashTokens = Object.freeze({
|
|
1717
|
+
1: "solid",
|
|
1718
|
+
2: "sysDash",
|
|
1719
|
+
3: "sysDot",
|
|
1720
|
+
4: "dash",
|
|
1721
|
+
5: "dashDot",
|
|
1722
|
+
6: "lgDashDotDot",
|
|
1723
|
+
7: "lgDash",
|
|
1724
|
+
8: "lgDashDot"
|
|
1725
|
+
});
|
|
1726
|
+
var patternValues = {
|
|
1727
|
+
PERCENT_5: 1,
|
|
1728
|
+
PERCENT_10: 2,
|
|
1729
|
+
PERCENT_20: 3,
|
|
1730
|
+
PERCENT_25: 4,
|
|
1731
|
+
PERCENT_30: 5,
|
|
1732
|
+
PERCENT_40: 6,
|
|
1733
|
+
PERCENT_50: 7,
|
|
1734
|
+
PERCENT_60: 8,
|
|
1735
|
+
PERCENT_70: 9,
|
|
1736
|
+
PERCENT_75: 10,
|
|
1737
|
+
PERCENT_80: 11,
|
|
1738
|
+
PERCENT_90: 12,
|
|
1739
|
+
DARK_HORIZONTAL: 13,
|
|
1740
|
+
DARK_VERTICAL: 14,
|
|
1741
|
+
DARK_DOWNWARD_DIAGONAL: 15,
|
|
1742
|
+
DARK_UPWARD_DIAGONAL: 16,
|
|
1743
|
+
SMALL_CHECKER_BOARD: 17,
|
|
1744
|
+
TRELLIS: 18,
|
|
1745
|
+
LIGHT_HORIZONTAL: 19,
|
|
1746
|
+
LIGHT_VERTICAL: 20,
|
|
1747
|
+
LIGHT_DOWNWARD_DIAGONAL: 21,
|
|
1748
|
+
LIGHT_UPWARD_DIAGONAL: 22,
|
|
1749
|
+
SMALL_GRID: 23,
|
|
1750
|
+
DOTTED_DIAMOND: 24,
|
|
1751
|
+
WIDE_DOWNWARD_DIAGONAL: 25,
|
|
1752
|
+
WIDE_UPWARD_DIAGONAL: 26,
|
|
1753
|
+
DASHED_UPWARD_DIAGONAL: 27,
|
|
1754
|
+
DASHED_DOWNWARD_DIAGONAL: 28,
|
|
1755
|
+
NARROW_VERTICAL: 29,
|
|
1756
|
+
NARROW_HORIZONTAL: 30,
|
|
1757
|
+
DASHED_VERTICAL: 31,
|
|
1758
|
+
DASHED_HORIZONTAL: 32,
|
|
1759
|
+
LARGE_CONFETTI: 33,
|
|
1760
|
+
LARGE_GRID: 34,
|
|
1761
|
+
HORIZONTAL_BRICK: 35,
|
|
1762
|
+
LARGE_CHECKER_BOARD: 36,
|
|
1763
|
+
SMALL_CONFETTI: 37,
|
|
1764
|
+
ZIG_ZAG: 38,
|
|
1765
|
+
SOLID_DIAMOND: 39,
|
|
1766
|
+
DIAGONAL_BRICK: 40,
|
|
1767
|
+
OUTLINED_DIAMOND: 41,
|
|
1768
|
+
PLAID: 42,
|
|
1769
|
+
SPHERE: 43,
|
|
1770
|
+
WEAVE: 44,
|
|
1771
|
+
DOTTED_GRID: 45,
|
|
1772
|
+
DIVOT: 46,
|
|
1773
|
+
SHINGLE: 47,
|
|
1774
|
+
WAVE: 48,
|
|
1775
|
+
HORIZONTAL: 49,
|
|
1776
|
+
VERTICAL: 50,
|
|
1777
|
+
CROSS: 51,
|
|
1778
|
+
DOWNWARD_DIAGONAL: 52,
|
|
1779
|
+
UPWARD_DIAGONAL: 53,
|
|
1780
|
+
DIAGONAL_CROSS: 54,
|
|
1781
|
+
MIXED: -2
|
|
1782
|
+
};
|
|
1783
|
+
var patternTokens = Object.freeze({
|
|
1784
|
+
1: "pct5",
|
|
1785
|
+
2: "pct10",
|
|
1786
|
+
3: "pct20",
|
|
1787
|
+
4: "pct25",
|
|
1788
|
+
5: "pct30",
|
|
1789
|
+
6: "pct40",
|
|
1790
|
+
7: "pct50",
|
|
1791
|
+
8: "pct60",
|
|
1792
|
+
9: "pct70",
|
|
1793
|
+
10: "pct75",
|
|
1794
|
+
11: "pct80",
|
|
1795
|
+
12: "pct90",
|
|
1796
|
+
13: "dkHorz",
|
|
1797
|
+
14: "dkVert",
|
|
1798
|
+
15: "dkDnDiag",
|
|
1799
|
+
16: "dkUpDiag",
|
|
1800
|
+
17: "smCheck",
|
|
1801
|
+
18: "trellis",
|
|
1802
|
+
19: "ltHorz",
|
|
1803
|
+
20: "ltVert",
|
|
1804
|
+
21: "ltDnDiag",
|
|
1805
|
+
22: "ltUpDiag",
|
|
1806
|
+
23: "smGrid",
|
|
1807
|
+
24: "dotDmnd",
|
|
1808
|
+
25: "wdDnDiag",
|
|
1809
|
+
26: "wdUpDiag",
|
|
1810
|
+
27: "dashUpDiag",
|
|
1811
|
+
28: "dashDnDiag",
|
|
1812
|
+
29: "narVert",
|
|
1813
|
+
30: "narHorz",
|
|
1814
|
+
31: "dashVert",
|
|
1815
|
+
32: "dashHorz",
|
|
1816
|
+
33: "lgConfetti",
|
|
1817
|
+
34: "lgGrid",
|
|
1818
|
+
35: "horzBrick",
|
|
1819
|
+
36: "lgCheck",
|
|
1820
|
+
37: "smConfetti",
|
|
1821
|
+
38: "zigZag",
|
|
1822
|
+
39: "solidDmnd",
|
|
1823
|
+
40: "diagBrick",
|
|
1824
|
+
41: "openDmnd",
|
|
1825
|
+
42: "plaid",
|
|
1826
|
+
43: "sphere",
|
|
1827
|
+
44: "weave",
|
|
1828
|
+
45: "dotGrid",
|
|
1829
|
+
46: "divot",
|
|
1830
|
+
47: "shingle",
|
|
1831
|
+
48: "wave",
|
|
1832
|
+
49: "horz",
|
|
1833
|
+
50: "vert",
|
|
1834
|
+
51: "cross",
|
|
1835
|
+
52: "dnDiag",
|
|
1836
|
+
53: "upDiag",
|
|
1837
|
+
54: "diagCross"
|
|
1838
|
+
});
|
|
1839
|
+
var MSO_LINE_DASH_STYLE = defineXmlEnum(lineValues, dashTokens);
|
|
1840
|
+
var MSO_LINE = MSO_LINE_DASH_STYLE;
|
|
1841
|
+
var MSO_PATTERN_TYPE = defineXmlEnum(patternValues, patternTokens);
|
|
1842
|
+
var MSO_PATTERN = MSO_PATTERN_TYPE;
|
|
1843
|
+
|
|
1844
|
+
// packages/safe-bash-presentation-engine/src/shapes.ts
|
|
1845
|
+
var pns = "http://schemas.openxmlformats.org/presentationml/2006/main";
|
|
1846
|
+
var ans = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
1847
|
+
function drawing(node) {
|
|
1848
|
+
if ([ans, "http://purl.oclc.org/ooxml/drawingml/main"].includes(node.name.namespace))
|
|
1849
|
+
return node.name.namespace;
|
|
1850
|
+
if (![
|
|
1851
|
+
pns,
|
|
1852
|
+
"http://purl.oclc.org/ooxml/presentationml/main",
|
|
1853
|
+
"http://schemas.openxmlformats.org/drawingml/2006/chart",
|
|
1854
|
+
"http://purl.oclc.org/ooxml/drawingml/chart"
|
|
1855
|
+
].includes(node.name.namespace))
|
|
1856
|
+
invalid4("Unsupported shape namespace.");
|
|
1857
|
+
return [
|
|
1858
|
+
"http://purl.oclc.org/ooxml/presentationml/main",
|
|
1859
|
+
"http://purl.oclc.org/ooxml/drawingml/chart"
|
|
1860
|
+
].includes(node.name.namespace) ? "http://purl.oclc.org/ooxml/drawingml/main" : ans;
|
|
1861
|
+
}
|
|
1862
|
+
function invalid4(message = "Invalid shape properties.") {
|
|
1863
|
+
throw new OfficeError("invalid-value", message, "usage");
|
|
1864
|
+
}
|
|
1865
|
+
function unsupported2(message) {
|
|
1866
|
+
throw new OfficeError("unsupported-edit", message, "validate-intent");
|
|
1867
|
+
}
|
|
1868
|
+
function preset(kind) {
|
|
1869
|
+
if (kind === "text-box") return null;
|
|
1870
|
+
const name = typeof kind === "number" ? Object.keys(shapePresets).find(
|
|
1871
|
+
(k) => MSO_AUTO_SHAPE_TYPE[k] === kind
|
|
1872
|
+
) : kind;
|
|
1873
|
+
if (!name || !Object.hasOwn(shapePresets, name)) invalid4("Unknown preset shape.");
|
|
1874
|
+
return name;
|
|
1875
|
+
}
|
|
1876
|
+
function emu(value) {
|
|
1877
|
+
if (value instanceof Length) return value.emu;
|
|
1878
|
+
if (!value || typeof value !== "object" || Object.keys(value).some((k) => !["value", "unit"].includes(k)) || typeof value.value !== "number")
|
|
1879
|
+
invalid4();
|
|
1880
|
+
const factors = { emu: 1, in: 914400, cm: 36e4, mm: 36e3, pt: 12700 };
|
|
1881
|
+
if (!Object.hasOwn(factors, value.unit)) invalid4();
|
|
1882
|
+
const result = new Length(value.value * factors[value.unit]).emu;
|
|
1883
|
+
return result;
|
|
1884
|
+
}
|
|
1885
|
+
function escaped(value) {
|
|
1886
|
+
let text = "";
|
|
1887
|
+
for (const c of value) {
|
|
1888
|
+
const cp = c.codePointAt(0);
|
|
1889
|
+
if (cp < 32 && ![9, 10, 13].includes(cp) || cp >= 55296 && cp <= 57343 || cp === 65534 || cp === 65535)
|
|
1890
|
+
invalid4();
|
|
1891
|
+
text += c === "&" ? "&" : c === "<" ? "<" : c === '"' ? """ : c === "\r" ? " " : c === "\n" ? " " : c === " " ? "	" : c;
|
|
1892
|
+
}
|
|
1893
|
+
return text;
|
|
1894
|
+
}
|
|
1895
|
+
function validateShapeOptions(options, adding = false) {
|
|
1896
|
+
if (!options || typeof options !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(options)) || Object.keys(options).some(
|
|
1897
|
+
(k) => ![
|
|
1898
|
+
"kind",
|
|
1899
|
+
"name",
|
|
1900
|
+
"title",
|
|
1901
|
+
"description",
|
|
1902
|
+
"altText",
|
|
1903
|
+
"locked",
|
|
1904
|
+
"left",
|
|
1905
|
+
"top",
|
|
1906
|
+
"width",
|
|
1907
|
+
"height",
|
|
1908
|
+
"rotation",
|
|
1909
|
+
"flipHorizontal",
|
|
1910
|
+
"flipVertical",
|
|
1911
|
+
"fill",
|
|
1912
|
+
"lineColor",
|
|
1913
|
+
"lineWidth",
|
|
1914
|
+
"text",
|
|
1915
|
+
"adjustments"
|
|
1916
|
+
].includes(k)
|
|
1917
|
+
))
|
|
1918
|
+
invalid4();
|
|
1919
|
+
if (options.adjustments !== void 0) validateAdjustmentValues(options.adjustments);
|
|
1920
|
+
if (options.kind !== void 0) preset(options.kind);
|
|
1921
|
+
for (const key of ["flipHorizontal", "flipVertical"])
|
|
1922
|
+
if (options[key] !== void 0 && typeof options[key] !== "boolean") invalid4();
|
|
1923
|
+
if (adding && options.kind === void 0) invalid4("Shape creation requires a kind.");
|
|
1924
|
+
if (adding && ["left", "top", "width", "height"].some((k) => options[k] === void 0))
|
|
1925
|
+
invalid4("Shape creation requires explicit geometry.");
|
|
1926
|
+
for (const k of ["left", "top", "width", "height", "lineWidth"]) {
|
|
1927
|
+
if (options[k] === null && k !== "lineWidth") invalid4();
|
|
1928
|
+
if (options[k] !== void 0 && options[k] !== null) {
|
|
1929
|
+
const n = emu(options[k]);
|
|
1930
|
+
if (Math.abs(n) > 27273042316900) invalid4("Shape geometry exceeds DrawingML bounds.");
|
|
1931
|
+
if ((k === "width" || k === "height") && n <= 0 || k === "lineWidth" && n < 0) invalid4();
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
for (const k of ["name", "text", "title", "description", "altText"]) {
|
|
1935
|
+
const v = options[k];
|
|
1936
|
+
if (v !== void 0 && v !== null) {
|
|
1937
|
+
if (typeof v !== "string") invalid4();
|
|
1938
|
+
if (k !== "text") escaped(v);
|
|
1939
|
+
} else if (v === null && (k === "name" || k === "text")) invalid4();
|
|
1940
|
+
}
|
|
1941
|
+
if (options.description !== void 0 && options.altText !== void 0)
|
|
1942
|
+
invalid4("Use description or altText, not both.");
|
|
1943
|
+
if (options.locked !== void 0 && options.locked !== null && typeof options.locked !== "boolean")
|
|
1944
|
+
invalid4();
|
|
1945
|
+
if (options.rotation !== void 0 && (typeof options.rotation !== "number" || !Number.isFinite(options.rotation) || Math.abs(options.rotation) > 36e4))
|
|
1946
|
+
invalid4();
|
|
1947
|
+
for (const k of ["fill", "lineColor"]) {
|
|
1948
|
+
const v = options[k];
|
|
1949
|
+
if (v !== void 0 && v !== null && v !== "solid" && (typeof v !== "string" || v.length !== 6 || Array.from(v).some((c) => !"0123456789abcdefABCDEF".includes(c))))
|
|
1950
|
+
invalid4();
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
function nv(node) {
|
|
1954
|
+
return node.children.find(
|
|
1955
|
+
(n) => n.name.namespace === node.name.namespace && ["nvSpPr", "nvPicPr", "nvGraphicFramePr", "nvGrpSpPr", "nvCxnSpPr"].includes(n.name.localName)
|
|
1956
|
+
);
|
|
1957
|
+
}
|
|
1958
|
+
function props(node) {
|
|
1959
|
+
return child(node, node.name.localName === "grpSp" ? "grpSpPr" : "spPr");
|
|
1960
|
+
}
|
|
1961
|
+
function num(node, key) {
|
|
1962
|
+
const v = node && attr(node, key);
|
|
1963
|
+
if (v === void 0) return null;
|
|
1964
|
+
return ["x", "y"].includes(key) ? readXmlCoordinate(v) : readXmlInteger(v);
|
|
1965
|
+
}
|
|
1966
|
+
function readShape(node) {
|
|
1967
|
+
const a = drawing(node), n = nv(node), cn = n && child(n, "cNvPr"), pr = props(node), x = node.name.localName === "graphicFrame" ? child(node, "xfrm") : pr && child(pr, "xfrm", a), off = x && child(x, "off", a), ext = x && child(x, "ext", a), geom = pr && child(pr, "prstGeom", a), raw2 = geom && attr(geom, "prst"), cp = n && child(n, "cNvSpPr"), ph = n && child(n, "nvPr") && child(child(n, "nvPr"), "ph"), locks = cp && child(cp, "spLocks", a), line = pr && child(pr, "ln", a);
|
|
1968
|
+
const readColor = (v) => {
|
|
1969
|
+
const sf = v && child(v, "solidFill", a), rgb = sf && child(sf, "srgbClr", a);
|
|
1970
|
+
return rgb ? attr(rgb, "val") ?? null : null;
|
|
1971
|
+
};
|
|
1972
|
+
const found = raw2 ? Object.keys(shapePresets).find(
|
|
1973
|
+
(k) => shapePresets[k] === raw2
|
|
1974
|
+
) : void 0;
|
|
1975
|
+
const unknown = [];
|
|
1976
|
+
for (const [label, owner] of [
|
|
1977
|
+
["fill", pr],
|
|
1978
|
+
["line", line]
|
|
1979
|
+
]) {
|
|
1980
|
+
const fill = owner && child(owner, "solidFill", a);
|
|
1981
|
+
for (const color of fill?.children ?? [])
|
|
1982
|
+
if (color.name.namespace === a && color.name.localName !== "srgbClr")
|
|
1983
|
+
unknown.push(`${label}:${color.name.localName}`);
|
|
1984
|
+
}
|
|
1985
|
+
if (raw2 && !found) unknown.push(`preset:${raw2}`);
|
|
1986
|
+
for (const v of pr?.children ?? [])
|
|
1987
|
+
if (v.name.namespace === a && ["gradFill", "pattFill", "blipFill", "grpFill", "custGeom"].includes(v.name.localName))
|
|
1988
|
+
unknown.push(v.name.localName);
|
|
1989
|
+
const lock = locks && attr(locks, "noSelect");
|
|
1990
|
+
return {
|
|
1991
|
+
shapeId: cn ? num(cn, "id") ?? 0 : 0,
|
|
1992
|
+
name: cn ? attr(cn, "name") ?? "" : "",
|
|
1993
|
+
title: cn ? attr(cn, "title") ?? null : null,
|
|
1994
|
+
description: cn ? attr(cn, "descr") ?? null : null,
|
|
1995
|
+
kind: cp && ["1", "true"].includes(attr(cp, "txBox") ?? "") ? "text-box" : found ?? null,
|
|
1996
|
+
left: num(off, "x"),
|
|
1997
|
+
top: num(off, "y"),
|
|
1998
|
+
width: num(ext, "cx"),
|
|
1999
|
+
height: num(ext, "cy"),
|
|
2000
|
+
rotation: ((num(x, "rot") ?? 0) % 216e5 + 216e5) % 216e5 / 6e4,
|
|
2001
|
+
flipHorizontal: x ? ["true", "1"].includes(attr(x, "flipH") ?? "0") : false,
|
|
2002
|
+
flipVertical: x ? ["true", "1"].includes(attr(x, "flipV") ?? "0") : false,
|
|
2003
|
+
locked: lock === void 0 ? null : ["1", "true"].includes(lock),
|
|
2004
|
+
fill: readColor(pr),
|
|
2005
|
+
fillType: pr?.children.find(
|
|
2006
|
+
(n2) => n2.name.namespace === a && ["noFill", "solidFill", "gradFill", "pattFill", "blipFill", "grpFill"].includes(
|
|
2007
|
+
n2.name.localName
|
|
2008
|
+
)
|
|
2009
|
+
)?.name.localName ?? null,
|
|
2010
|
+
lineColor: readColor(line),
|
|
2011
|
+
lineFillType: line?.children.find(
|
|
2012
|
+
(n2) => n2.name.namespace === a && ["noFill", "solidFill", "gradFill", "pattFill"].includes(n2.name.localName)
|
|
2013
|
+
)?.name.localName ?? null,
|
|
2014
|
+
lineWidth: num(line, "w"),
|
|
2015
|
+
unsupported: unknown,
|
|
2016
|
+
placeholder: ph ? {
|
|
2017
|
+
idx: num(ph, "idx") ?? 0,
|
|
2018
|
+
type: attr(ph, "type") ?? "obj",
|
|
2019
|
+
orient: attr(ph, "orient") ?? "horz",
|
|
2020
|
+
sz: attr(ph, "sz") ?? "full"
|
|
2021
|
+
} : null
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
2024
|
+
var propertyOrder = [
|
|
2025
|
+
"xfrm",
|
|
2026
|
+
"prstGeom",
|
|
2027
|
+
"custGeom",
|
|
2028
|
+
"noFill",
|
|
2029
|
+
"solidFill",
|
|
2030
|
+
"gradFill",
|
|
2031
|
+
"blipFill",
|
|
2032
|
+
"pattFill",
|
|
2033
|
+
"grpFill",
|
|
2034
|
+
"ln",
|
|
2035
|
+
"effectLst",
|
|
2036
|
+
"effectDag",
|
|
2037
|
+
"scene3d",
|
|
2038
|
+
"sp3d",
|
|
2039
|
+
"extLst"
|
|
2040
|
+
];
|
|
2041
|
+
function applyShapeUpdate(document, node, options) {
|
|
2042
|
+
validateShapeOptions(options);
|
|
2043
|
+
if (node.name.localName !== "sp" && Object.keys(options).length && Object.keys(options).every((key) => ["name", "title", "description", "altText"].includes(key))) {
|
|
2044
|
+
const identity = nv(node);
|
|
2045
|
+
const properties = identity && child(identity, "cNvPr");
|
|
2046
|
+
if (!properties) unsupported2("Shape identity is required for metadata edits.");
|
|
2047
|
+
return document.merge(properties, {
|
|
2048
|
+
attributes: Object.entries(options).map(([key, value]) => ({
|
|
2049
|
+
namespace: "",
|
|
2050
|
+
localName: key === "description" || key === "altText" ? "descr" : key,
|
|
2051
|
+
value
|
|
2052
|
+
}))
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
if (node.name.localName !== "sp" && (!["pic", "cxnSp", "graphicFrame", "grpSp"].includes(node.name.localName) || Object.keys(options).some(
|
|
2056
|
+
(key) => ![
|
|
2057
|
+
"left",
|
|
2058
|
+
"top",
|
|
2059
|
+
"width",
|
|
2060
|
+
"height",
|
|
2061
|
+
"rotation",
|
|
2062
|
+
"flipHorizontal",
|
|
2063
|
+
"flipVertical"
|
|
2064
|
+
].includes(key)
|
|
2065
|
+
)))
|
|
2066
|
+
unsupported2("This object supports only position, size, rotation and flip edits.");
|
|
2067
|
+
const p = node.name.namespace, a = drawing(node);
|
|
2068
|
+
const at = (name, value) => ({ namespace: "", localName: name, value });
|
|
2069
|
+
const ch = (namespace, order, upsert, remove = []) => ({
|
|
2070
|
+
children: {
|
|
2071
|
+
sequence: order.map((localName) => ({ namespace, localName })),
|
|
2072
|
+
remove: remove.filter((localName) => !upsert.some((item) => item.name.localName === localName)).map((localName) => ({ namespace, localName })),
|
|
2073
|
+
upsert
|
|
2074
|
+
}
|
|
2075
|
+
});
|
|
2076
|
+
const u = (namespace, localName, merge) => ({
|
|
2077
|
+
name: { namespace, localName },
|
|
2078
|
+
merge
|
|
2079
|
+
});
|
|
2080
|
+
const nvEdits = [];
|
|
2081
|
+
const attrs = [];
|
|
2082
|
+
for (const [key, xmlKey] of [
|
|
2083
|
+
["name", "name"],
|
|
2084
|
+
["title", "title"],
|
|
2085
|
+
["description", "descr"],
|
|
2086
|
+
["altText", "descr"]
|
|
2087
|
+
])
|
|
2088
|
+
if (options[key] !== void 0) attrs.push(at(xmlKey, options[key]));
|
|
2089
|
+
if (attrs.length) nvEdits.push(u(p, "cNvPr", { attributes: attrs }));
|
|
2090
|
+
if (options.locked !== void 0 || options.kind !== void 0) {
|
|
2091
|
+
const lock = options.locked === void 0 ? {} : ch(
|
|
2092
|
+
a,
|
|
2093
|
+
["spLocks", "extLst"],
|
|
2094
|
+
[
|
|
2095
|
+
u(a, "spLocks", {
|
|
2096
|
+
attributes: [
|
|
2097
|
+
at("noSelect", options.locked === null ? null : options.locked ? "1" : "0")
|
|
2098
|
+
]
|
|
2099
|
+
})
|
|
2100
|
+
]
|
|
2101
|
+
);
|
|
2102
|
+
nvEdits.push(
|
|
2103
|
+
u(p, "cNvSpPr", {
|
|
2104
|
+
...lock,
|
|
2105
|
+
...options.kind === void 0 ? {} : { attributes: [at("txBox", options.kind === "text-box" ? "1" : null)] }
|
|
2106
|
+
})
|
|
2107
|
+
);
|
|
2108
|
+
}
|
|
2109
|
+
const propEdits = [];
|
|
2110
|
+
const removes = [];
|
|
2111
|
+
const coords = [];
|
|
2112
|
+
for (const [name, keys2] of [
|
|
2113
|
+
[
|
|
2114
|
+
"off",
|
|
2115
|
+
[
|
|
2116
|
+
["left", "x"],
|
|
2117
|
+
["top", "y"]
|
|
2118
|
+
]
|
|
2119
|
+
],
|
|
2120
|
+
[
|
|
2121
|
+
"ext",
|
|
2122
|
+
[
|
|
2123
|
+
["width", "cx"],
|
|
2124
|
+
["height", "cy"]
|
|
2125
|
+
]
|
|
2126
|
+
]
|
|
2127
|
+
]) {
|
|
2128
|
+
const values3 = keys2.filter(([k]) => options[k] !== void 0).map(([k, v]) => at(v, String(emu(options[k]))));
|
|
2129
|
+
if (values3.length) {
|
|
2130
|
+
const existingProperties = props(node);
|
|
2131
|
+
const existingTransform = node.name.localName === "graphicFrame" ? child(node, "xfrm") : existingProperties && child(existingProperties, "xfrm", a);
|
|
2132
|
+
const existingPair = existingTransform && child(existingTransform, name, a);
|
|
2133
|
+
for (const [key, attribute] of keys2) {
|
|
2134
|
+
if (options[key] === void 0 && (!existingPair || attr(existingPair, attribute) === void 0)) {
|
|
2135
|
+
if (name === "ext") invalid4("Creating dimensions requires both width and height.");
|
|
2136
|
+
values3.push(at(attribute, "0"));
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
if (values3.length) coords.push(u(a, name, { attributes: values3 }));
|
|
2141
|
+
}
|
|
2142
|
+
const transformAttributes = [];
|
|
2143
|
+
if (options.rotation !== void 0) {
|
|
2144
|
+
const angle = Math.sign(options.rotation) * Math.round(Math.abs(options.rotation) * 6e4);
|
|
2145
|
+
transformAttributes.push(at("rot", String((angle % 216e5 + 216e5) % 216e5)));
|
|
2146
|
+
}
|
|
2147
|
+
for (const [key, name] of [
|
|
2148
|
+
["flipHorizontal", "flipH"],
|
|
2149
|
+
["flipVertical", "flipV"]
|
|
2150
|
+
])
|
|
2151
|
+
if (options[key] !== void 0) transformAttributes.push(at(name, options[key] ? "1" : "0"));
|
|
2152
|
+
if (coords.length || transformAttributes.length)
|
|
2153
|
+
propEdits.push(
|
|
2154
|
+
u(a, "xfrm", {
|
|
2155
|
+
...ch(a, ["off", "ext", "chOff", "chExt"], coords),
|
|
2156
|
+
attributes: transformAttributes
|
|
2157
|
+
})
|
|
2158
|
+
);
|
|
2159
|
+
if (options.kind !== void 0) {
|
|
2160
|
+
const key = preset(options.kind);
|
|
2161
|
+
propEdits.push(
|
|
2162
|
+
u(a, "prstGeom", {
|
|
2163
|
+
attributes: [at("prst", key ? shapePresets[key] : "rect")],
|
|
2164
|
+
...ch(a, ["avLst"], [u(a, "avLst", {})])
|
|
2165
|
+
})
|
|
2166
|
+
);
|
|
2167
|
+
removes.push("custGeom");
|
|
2168
|
+
}
|
|
2169
|
+
const fill = (color) => color === null || color === "solid" ? {} : ch(
|
|
2170
|
+
a,
|
|
2171
|
+
["srgbClr", "schemeClr", "scrgbClr", "hslClr", "sysClr", "prstClr"],
|
|
2172
|
+
[u(a, "srgbClr", { attributes: [at("val", color.toUpperCase())] })],
|
|
2173
|
+
["schemeClr", "scrgbClr", "hslClr", "sysClr", "prstClr"]
|
|
2174
|
+
);
|
|
2175
|
+
if (options.fill !== void 0) {
|
|
2176
|
+
removes.push("noFill", "solidFill", "gradFill", "blipFill", "pattFill", "grpFill");
|
|
2177
|
+
propEdits.push(u(a, options.fill === null ? "noFill" : "solidFill", fill(options.fill)));
|
|
2178
|
+
}
|
|
2179
|
+
if (options.lineColor !== void 0 || options.lineWidth !== void 0) {
|
|
2180
|
+
const lineChildren = options.lineColor === void 0 ? {} : ch(
|
|
2181
|
+
a,
|
|
2182
|
+
[
|
|
2183
|
+
"noFill",
|
|
2184
|
+
"solidFill",
|
|
2185
|
+
"gradFill",
|
|
2186
|
+
"pattFill",
|
|
2187
|
+
"prstDash",
|
|
2188
|
+
"custDash",
|
|
2189
|
+
"round",
|
|
2190
|
+
"bevel",
|
|
2191
|
+
"miter",
|
|
2192
|
+
"headEnd",
|
|
2193
|
+
"tailEnd",
|
|
2194
|
+
"extLst"
|
|
2195
|
+
],
|
|
2196
|
+
[u(a, options.lineColor === null ? "noFill" : "solidFill", fill(options.lineColor))],
|
|
2197
|
+
["noFill", "solidFill", "gradFill", "pattFill"]
|
|
2198
|
+
);
|
|
2199
|
+
propEdits.push(
|
|
2200
|
+
u(a, "ln", {
|
|
2201
|
+
...lineChildren,
|
|
2202
|
+
...options.lineWidth === void 0 ? {} : {
|
|
2203
|
+
attributes: [
|
|
2204
|
+
at("w", options.lineWidth === null ? null : String(emu(options.lineWidth)))
|
|
2205
|
+
]
|
|
2206
|
+
}
|
|
2207
|
+
})
|
|
2208
|
+
);
|
|
2209
|
+
}
|
|
2210
|
+
const top = [];
|
|
2211
|
+
if (node.name.localName === "graphicFrame")
|
|
2212
|
+
return document.merge(node, {
|
|
2213
|
+
children: {
|
|
2214
|
+
sequence: ["nvGraphicFramePr", "xfrm", "graphic", "extLst"].map((localName) => ({
|
|
2215
|
+
namespace: localName === "graphic" ? a : p,
|
|
2216
|
+
localName
|
|
2217
|
+
})),
|
|
2218
|
+
upsert: propEdits.map((edit) => u(p, "xfrm", edit.merge))
|
|
2219
|
+
}
|
|
2220
|
+
});
|
|
2221
|
+
if (node.name.localName !== "sp") {
|
|
2222
|
+
const existing = props(node);
|
|
2223
|
+
if (!existing) unsupported2("Transform edits require existing shape properties.");
|
|
2224
|
+
return document.merge(existing, ch(a, propertyOrder, propEdits));
|
|
2225
|
+
}
|
|
2226
|
+
if (nvEdits.length) top.push(u(p, "nvSpPr", ch(p, ["cNvPr", "cNvSpPr", "nvPr"], nvEdits)));
|
|
2227
|
+
if (propEdits.length) top.push(u(p, "spPr", ch(a, propertyOrder, propEdits, removes)));
|
|
2228
|
+
let updated = document.merge(node, ch(p, ["nvSpPr", "spPr", "style", "txBody", "extLst"], top));
|
|
2229
|
+
if (options.text !== void 0) {
|
|
2230
|
+
let locate2 = function(n) {
|
|
2231
|
+
if (n === node) return true;
|
|
2232
|
+
for (let i = 0; i < n.children.length; i++) {
|
|
2233
|
+
path.push(i);
|
|
2234
|
+
if (locate2(n.children[i])) return true;
|
|
2235
|
+
path.pop();
|
|
2236
|
+
}
|
|
2237
|
+
return false;
|
|
2238
|
+
};
|
|
2239
|
+
var locate = locate2;
|
|
2240
|
+
const path = [];
|
|
2241
|
+
locate2(document.root);
|
|
2242
|
+
const target = path.reduce((n, i) => n.children[i], updated.root);
|
|
2243
|
+
let body = child(target, "txBody");
|
|
2244
|
+
if (!body) {
|
|
2245
|
+
const extensionIndex = target.children.findIndex(
|
|
2246
|
+
(n) => n.name.namespace === p && n.name.localName === "extLst"
|
|
2247
|
+
);
|
|
2248
|
+
updated = updated.spliceChildren(
|
|
2249
|
+
target,
|
|
2250
|
+
extensionIndex < 0 ? target.children.length : extensionIndex,
|
|
2251
|
+
0,
|
|
2252
|
+
[`<p:txBody xmlns:p="${p}" xmlns:a="${a}"><a:bodyPr/><a:lstStyle/><a:p/></p:txBody>`]
|
|
2253
|
+
);
|
|
2254
|
+
body = child(
|
|
2255
|
+
path.reduce((n, i) => n.children[i], updated.root),
|
|
2256
|
+
"txBody"
|
|
2257
|
+
);
|
|
2258
|
+
}
|
|
2259
|
+
updated = applyFrameFormatting(updated, body, { text: options.text });
|
|
2260
|
+
}
|
|
2261
|
+
if (options.adjustments !== void 0) {
|
|
2262
|
+
const path = [];
|
|
2263
|
+
const locate2 = (current) => {
|
|
2264
|
+
if (current === node) return true;
|
|
2265
|
+
for (let i = 0; i < current.children.length; i++) {
|
|
2266
|
+
path.push(i);
|
|
2267
|
+
if (locate2(current.children[i])) return true;
|
|
2268
|
+
path.pop();
|
|
2269
|
+
}
|
|
2270
|
+
return false;
|
|
2271
|
+
};
|
|
2272
|
+
if (!locate2(document.root)) invalid4("Shape does not belong to its document.");
|
|
2273
|
+
const target = path.reduce((current, i) => current.children[i], updated.root);
|
|
2274
|
+
const adjustments = new AdjustmentCollection(
|
|
2275
|
+
() => updated.subtree(target),
|
|
2276
|
+
(xml) => {
|
|
2277
|
+
if (!path.length) updated = xml;
|
|
2278
|
+
else {
|
|
2279
|
+
const parent = path.slice(0, -1).reduce((current, i) => current.children[i], updated.root);
|
|
2280
|
+
updated = updated.spliceChildren(parent, path.at(-1), 1, [xml.markup(xml.root, true)]);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
);
|
|
2284
|
+
adjustments.replace(options.adjustments);
|
|
2285
|
+
}
|
|
2286
|
+
return updated;
|
|
2287
|
+
}
|
|
2288
|
+
function createShapeXml(kind, id, options, presentationNamespace = pns, limits = {}) {
|
|
2289
|
+
validateShapeOptions({ ...options, kind }, true);
|
|
2290
|
+
if (!Number.isInteger(id) || id < 1 || id > 4294967295)
|
|
2291
|
+
invalid4("Shape identity must be a positive unsigned 32-bit integer.");
|
|
2292
|
+
if (![pns, "http://purl.oclc.org/ooxml/presentationml/main"].includes(presentationNamespace))
|
|
2293
|
+
invalid4();
|
|
2294
|
+
const a = presentationNamespace === pns ? ans : "http://purl.oclc.org/ooxml/drawingml/main";
|
|
2295
|
+
let doc = parseXmlPart(
|
|
2296
|
+
new TextEncoder().encode(
|
|
2297
|
+
`<p:sp xmlns:p="${presentationNamespace}" xmlns:a="${a}"><p:nvSpPr><p:cNvPr id="${id}" name="Shape ${id}"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr><p:spPr/></p:sp>`
|
|
2298
|
+
),
|
|
2299
|
+
limits
|
|
2300
|
+
);
|
|
2301
|
+
doc = applyShapeUpdate(doc, doc.root, { ...options, kind, text: options.text ?? "" });
|
|
2302
|
+
return doc.markup(doc.root, true);
|
|
2303
|
+
}
|
|
2304
|
+
var Shape = class _Shape {
|
|
2305
|
+
#snapshot;
|
|
2306
|
+
#owner;
|
|
2307
|
+
get #xml() {
|
|
2308
|
+
return this.#owner?.read() ?? this.#snapshot;
|
|
2309
|
+
}
|
|
2310
|
+
set #xml(xml) {
|
|
2311
|
+
if (this.#owner) this.#owner.write(xml);
|
|
2312
|
+
else this.#snapshot = xml;
|
|
2313
|
+
}
|
|
2314
|
+
#textFrame;
|
|
2315
|
+
#adjustments;
|
|
2316
|
+
constructor(xml, owner) {
|
|
2317
|
+
if (!["sp", "grpSp"].includes(xml.root.name.localName) && (new.target === _Shape || !["pic", "graphicFrame"].includes(xml.root.name.localName)))
|
|
2318
|
+
invalid4();
|
|
2319
|
+
drawing(xml.root);
|
|
2320
|
+
this.#snapshot = xml;
|
|
2321
|
+
this.#owner = owner;
|
|
2322
|
+
}
|
|
2323
|
+
get xml() {
|
|
2324
|
+
return this.#xml;
|
|
2325
|
+
}
|
|
2326
|
+
get element() {
|
|
2327
|
+
return this.#xml.root;
|
|
2328
|
+
}
|
|
2329
|
+
get part() {
|
|
2330
|
+
void this.element;
|
|
2331
|
+
if (!this.#owner?.part) throw new PropertyAccessError("Shape has no package part.");
|
|
2332
|
+
return this.#owner.part;
|
|
2333
|
+
}
|
|
2334
|
+
get shape_id() {
|
|
2335
|
+
return readShape(this.element).shapeId;
|
|
2336
|
+
}
|
|
2337
|
+
get name() {
|
|
2338
|
+
return readShape(this.element).name;
|
|
2339
|
+
}
|
|
2340
|
+
set name(v) {
|
|
2341
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { name: v });
|
|
2342
|
+
}
|
|
2343
|
+
get title() {
|
|
2344
|
+
return readShape(this.element).title;
|
|
2345
|
+
}
|
|
2346
|
+
set title(v) {
|
|
2347
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { title: v });
|
|
2348
|
+
}
|
|
2349
|
+
get description() {
|
|
2350
|
+
return readShape(this.element).description;
|
|
2351
|
+
}
|
|
2352
|
+
set description(v) {
|
|
2353
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { description: v });
|
|
2354
|
+
}
|
|
2355
|
+
get locked() {
|
|
2356
|
+
return readShape(this.element).locked;
|
|
2357
|
+
}
|
|
2358
|
+
set locked(v) {
|
|
2359
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { locked: v });
|
|
2360
|
+
}
|
|
2361
|
+
get left() {
|
|
2362
|
+
const v = readShape(this.element).left;
|
|
2363
|
+
return v === null ? null : new Length(v);
|
|
2364
|
+
}
|
|
2365
|
+
set left(v) {
|
|
2366
|
+
if (!(v instanceof Length)) invalid4();
|
|
2367
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { left: v });
|
|
2368
|
+
}
|
|
2369
|
+
get top() {
|
|
2370
|
+
const v = readShape(this.element).top;
|
|
2371
|
+
return v === null ? null : new Length(v);
|
|
2372
|
+
}
|
|
2373
|
+
set top(v) {
|
|
2374
|
+
if (!(v instanceof Length)) invalid4();
|
|
2375
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { top: v });
|
|
2376
|
+
}
|
|
2377
|
+
get width() {
|
|
2378
|
+
const v = readShape(this.element).width;
|
|
2379
|
+
return v === null ? null : new Length(v);
|
|
2380
|
+
}
|
|
2381
|
+
set width(v) {
|
|
2382
|
+
if (!(v instanceof Length)) invalid4();
|
|
2383
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { width: v });
|
|
2384
|
+
}
|
|
2385
|
+
get height() {
|
|
2386
|
+
const v = readShape(this.element).height;
|
|
2387
|
+
return v === null ? null : new Length(v);
|
|
2388
|
+
}
|
|
2389
|
+
set height(v) {
|
|
2390
|
+
if (!(v instanceof Length)) invalid4();
|
|
2391
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { height: v });
|
|
2392
|
+
}
|
|
2393
|
+
get rotation() {
|
|
2394
|
+
return readShape(this.element).rotation;
|
|
2395
|
+
}
|
|
2396
|
+
set rotation(v) {
|
|
2397
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { rotation: v });
|
|
2398
|
+
}
|
|
2399
|
+
get flip_horizontal() {
|
|
2400
|
+
return readShape(this.element).flipHorizontal;
|
|
2401
|
+
}
|
|
2402
|
+
set flip_horizontal(v) {
|
|
2403
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { flipHorizontal: v });
|
|
2404
|
+
}
|
|
2405
|
+
get flip_vertical() {
|
|
2406
|
+
return readShape(this.element).flipVertical;
|
|
2407
|
+
}
|
|
2408
|
+
set flip_vertical(v) {
|
|
2409
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { flipVertical: v });
|
|
2410
|
+
}
|
|
2411
|
+
get is_placeholder() {
|
|
2412
|
+
return readShape(this.element).placeholder !== null;
|
|
2413
|
+
}
|
|
2414
|
+
get placeholder_format() {
|
|
2415
|
+
const ph = readShape(this.element).placeholder;
|
|
2416
|
+
if (!ph) invalid4("Shape is not a placeholder.");
|
|
2417
|
+
return { ...ph, type: PP_PLACEHOLDER_TYPE.from_xml(ph.type) };
|
|
2418
|
+
}
|
|
2419
|
+
get adjustments() {
|
|
2420
|
+
return this.#adjustments ??= new AdjustmentCollection(
|
|
2421
|
+
() => this.#xml,
|
|
2422
|
+
(xml) => {
|
|
2423
|
+
this.#xml = xml;
|
|
2424
|
+
}
|
|
2425
|
+
);
|
|
2426
|
+
}
|
|
2427
|
+
get auto_shape_type() {
|
|
2428
|
+
const kind = readShape(this.element).kind;
|
|
2429
|
+
if (!kind || kind === "text-box") invalid4("Shape has no supported preset type.");
|
|
2430
|
+
return MSO_AUTO_SHAPE_TYPE[kind];
|
|
2431
|
+
}
|
|
2432
|
+
get has_text_frame() {
|
|
2433
|
+
return this.element.name.localName === "sp";
|
|
2434
|
+
}
|
|
2435
|
+
get text_frame() {
|
|
2436
|
+
if (!this.has_text_frame) unsupported2("This shape has no text frame.");
|
|
2437
|
+
if (this.#textFrame) return this.#textFrame;
|
|
2438
|
+
if (!child(this.element, "txBody"))
|
|
2439
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, { text: "" });
|
|
2440
|
+
let owner;
|
|
2441
|
+
let cached;
|
|
2442
|
+
const read = () => {
|
|
2443
|
+
if (owner === this.#xml && cached) return cached;
|
|
2444
|
+
const body = child(this.element, "txBody");
|
|
2445
|
+
if (!body) unsupported2("Text frame no longer exists.");
|
|
2446
|
+
cached = this.#xml.subtree(body);
|
|
2447
|
+
owner = this.#xml;
|
|
2448
|
+
return cached;
|
|
2449
|
+
};
|
|
2450
|
+
const write = (xml) => {
|
|
2451
|
+
const body = child(this.element, "txBody");
|
|
2452
|
+
if (!body) unsupported2("Text frame no longer exists.");
|
|
2453
|
+
this.#xml = this.#xml.spliceChildren(this.element, this.element.children.indexOf(body), 1, [
|
|
2454
|
+
xml.markup(xml.root, true)
|
|
2455
|
+
]);
|
|
2456
|
+
};
|
|
2457
|
+
const extents = () => {
|
|
2458
|
+
const shape = readShape(this.element);
|
|
2459
|
+
return shape.width === null || shape.height === null ? void 0 : { width: shape.width / 12700, height: shape.height / 12700 };
|
|
2460
|
+
};
|
|
2461
|
+
this.#textFrame = new TextFrame(read(), extents(), { read, write, extents, parent: this });
|
|
2462
|
+
if (this.#owner?.hyperlink) {
|
|
2463
|
+
const hyperlink = this.#owner.hyperlink;
|
|
2464
|
+
textLinkCapabilities.set(
|
|
2465
|
+
this.#textFrame,
|
|
2466
|
+
(path) => hyperlink(() => {
|
|
2467
|
+
const body = child(this.element, "txBody");
|
|
2468
|
+
if (!body) throw new InvalidHandleError();
|
|
2469
|
+
return [this.element.children.indexOf(body), ...path()];
|
|
2470
|
+
})
|
|
2471
|
+
);
|
|
2472
|
+
}
|
|
2473
|
+
return this.#textFrame;
|
|
2474
|
+
}
|
|
2475
|
+
get fill() {
|
|
2476
|
+
return new FillFormat(
|
|
2477
|
+
() => this.#xml,
|
|
2478
|
+
(update) => {
|
|
2479
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, update);
|
|
2480
|
+
},
|
|
2481
|
+
false,
|
|
2482
|
+
(transform) => {
|
|
2483
|
+
this.#xml = transform(this.#xml, this.element);
|
|
2484
|
+
}
|
|
2485
|
+
);
|
|
2486
|
+
}
|
|
2487
|
+
get shadow() {
|
|
2488
|
+
return new ShadowFormat(
|
|
2489
|
+
() => this.#xml,
|
|
2490
|
+
(transform) => {
|
|
2491
|
+
this.#xml = transform(this.#xml, this.element);
|
|
2492
|
+
}
|
|
2493
|
+
);
|
|
2494
|
+
}
|
|
2495
|
+
get line() {
|
|
2496
|
+
return new LineFormat(
|
|
2497
|
+
() => this.#xml,
|
|
2498
|
+
(update) => {
|
|
2499
|
+
this.#xml = applyShapeUpdate(this.#xml, this.element, update);
|
|
2500
|
+
},
|
|
2501
|
+
(transform) => {
|
|
2502
|
+
this.#xml = transform(this.#xml, this.element);
|
|
2503
|
+
}
|
|
2504
|
+
);
|
|
2505
|
+
}
|
|
2506
|
+
get shape_type() {
|
|
2507
|
+
const record = readShape(this.element);
|
|
2508
|
+
if (record.placeholder) return MSO_SHAPE_TYPE.PLACEHOLDER;
|
|
2509
|
+
if (record.kind === "text-box") return MSO_SHAPE_TYPE.TEXT_BOX;
|
|
2510
|
+
const pr = props(this.element);
|
|
2511
|
+
if (pr && child(pr, "custGeom", drawing(this.element))) return MSO_SHAPE_TYPE.FREEFORM;
|
|
2512
|
+
if (record.kind) return MSO_SHAPE_TYPE.AUTO_SHAPE;
|
|
2513
|
+
unsupported2("Shape category is unsupported.");
|
|
2514
|
+
}
|
|
2515
|
+
get has_chart() {
|
|
2516
|
+
readShape(this.element);
|
|
2517
|
+
return false;
|
|
2518
|
+
}
|
|
2519
|
+
get has_table() {
|
|
2520
|
+
readShape(this.element);
|
|
2521
|
+
return false;
|
|
2522
|
+
}
|
|
2523
|
+
get text() {
|
|
2524
|
+
return this.text_frame.text;
|
|
2525
|
+
}
|
|
2526
|
+
set text(v) {
|
|
2527
|
+
this.text_frame.text = v;
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
var ShapeColorFormat = class {
|
|
2531
|
+
constructor(read, edit, owner) {
|
|
2532
|
+
this.read = read;
|
|
2533
|
+
this.edit = edit;
|
|
2534
|
+
this.owner = owner;
|
|
2535
|
+
}
|
|
2536
|
+
read;
|
|
2537
|
+
edit;
|
|
2538
|
+
owner;
|
|
2539
|
+
get type() {
|
|
2540
|
+
const type = readRunColor(this.owner(this.read().root))?.type;
|
|
2541
|
+
return type === void 0 ? null : MSO_COLOR_TYPE[type];
|
|
2542
|
+
}
|
|
2543
|
+
get rgb() {
|
|
2544
|
+
const v = readRunColor(this.owner(this.read().root))?.rgb;
|
|
2545
|
+
if (!v) throw new PropertyAccessError("RGB color is unavailable.");
|
|
2546
|
+
return RGBColor.from_string(v);
|
|
2547
|
+
}
|
|
2548
|
+
set rgb(v) {
|
|
2549
|
+
if (!(v instanceof RGBColor)) invalid4();
|
|
2550
|
+
this.edit((doc, node) => {
|
|
2551
|
+
const owner = this.owner(node);
|
|
2552
|
+
return doc.merge(owner, colorMerge(v.toString(), owner.name.namespace));
|
|
2553
|
+
});
|
|
2554
|
+
}
|
|
2555
|
+
get theme_color() {
|
|
2556
|
+
const c = readRunColor(this.owner(this.read().root));
|
|
2557
|
+
if (!c) throw new PropertyAccessError("Theme color is unavailable.");
|
|
2558
|
+
return c.theme === null ? MSO_THEME_COLOR_INDEX.NOT_THEME_COLOR : MSO_THEME_COLOR_INDEX.from_xml(c.theme);
|
|
2559
|
+
}
|
|
2560
|
+
set theme_color(v) {
|
|
2561
|
+
const theme = MSO_THEME_COLOR_INDEX.to_xml(v);
|
|
2562
|
+
this.edit((doc, node) => {
|
|
2563
|
+
const owner = this.owner(node);
|
|
2564
|
+
return doc.merge(owner, colorMerge({ theme }, owner.name.namespace));
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
get brightness() {
|
|
2568
|
+
return readRunColor(this.owner(this.read().root))?.brightness ?? 0;
|
|
2569
|
+
}
|
|
2570
|
+
set brightness(v) {
|
|
2571
|
+
this.edit((doc, node) => {
|
|
2572
|
+
const owner = this.owner(node), color = owner.children.find(
|
|
2573
|
+
(n) => n.name.namespace === owner.name.namespace && ["srgbClr", "schemeClr", "scrgbClr", "hslClr", "sysClr", "prstClr"].includes(
|
|
2574
|
+
n.name.localName
|
|
2575
|
+
)
|
|
2576
|
+
);
|
|
2577
|
+
if (!color) invalid4("Brightness requires a color.");
|
|
2578
|
+
return doc.merge(color, colorBrightnessMerge(v, color.name.namespace));
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
get opacity() {
|
|
2582
|
+
return readDrawingColor(this.owner(this.read().root))?.opacity ?? null;
|
|
2583
|
+
}
|
|
2584
|
+
set opacity(v) {
|
|
2585
|
+
if (v !== null && (!Number.isFinite(v) || v < 0 || v > 1)) invalid4();
|
|
2586
|
+
this.edit((doc, node) => {
|
|
2587
|
+
const owner = this.owner(node), color = owner.children.find(
|
|
2588
|
+
(n) => n.name.namespace === owner.name.namespace && ["srgbClr", "schemeClr", "scrgbClr", "hslClr", "sysClr", "prstClr"].includes(
|
|
2589
|
+
n.name.localName
|
|
2590
|
+
)
|
|
2591
|
+
);
|
|
2592
|
+
if (!color) invalid4("Alpha requires a color.");
|
|
2593
|
+
return doc.merge(color, {
|
|
2594
|
+
children: {
|
|
2595
|
+
sequence: [{ namespace: color.name.namespace, localName: "alpha" }],
|
|
2596
|
+
remove: v === null ? [{ namespace: color.name.namespace, localName: "alpha" }] : [],
|
|
2597
|
+
upsert: v === null ? [] : [
|
|
2598
|
+
{
|
|
2599
|
+
name: { namespace: color.name.namespace, localName: "alpha" },
|
|
2600
|
+
merge: {
|
|
2601
|
+
attributes: [
|
|
2602
|
+
{ namespace: "", localName: "val", value: String(Math.round(v * 1e5)) }
|
|
2603
|
+
]
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
]
|
|
2607
|
+
}
|
|
2608
|
+
});
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
};
|
|
2612
|
+
function fillPosition(owner, fill, namespace) {
|
|
2613
|
+
if (fill) return owner.children.indexOf(fill);
|
|
2614
|
+
const after = owner.children.findIndex(
|
|
2615
|
+
(node) => node.name.namespace === namespace && [
|
|
2616
|
+
"ln",
|
|
2617
|
+
"prstDash",
|
|
2618
|
+
"custDash",
|
|
2619
|
+
"round",
|
|
2620
|
+
"bevel",
|
|
2621
|
+
"miter",
|
|
2622
|
+
"headEnd",
|
|
2623
|
+
"tailEnd",
|
|
2624
|
+
"effectLst",
|
|
2625
|
+
"effectDag",
|
|
2626
|
+
"scene3d",
|
|
2627
|
+
"sp3d",
|
|
2628
|
+
"extLst"
|
|
2629
|
+
].includes(node.name.localName)
|
|
2630
|
+
);
|
|
2631
|
+
return after < 0 ? owner.children.length : after;
|
|
2632
|
+
}
|
|
2633
|
+
function gradientNodes(owner) {
|
|
2634
|
+
return owner.children.filter(
|
|
2635
|
+
(node) => node.name.namespace === owner.name.namespace && node.name.localName === "gs"
|
|
2636
|
+
);
|
|
2637
|
+
}
|
|
2638
|
+
var FillFormat = class {
|
|
2639
|
+
constructor(read, update, line, edit, fillOwner) {
|
|
2640
|
+
this.read = read;
|
|
2641
|
+
this.update = update;
|
|
2642
|
+
this.line = line;
|
|
2643
|
+
this.edit = edit;
|
|
2644
|
+
this.fillOwner = fillOwner;
|
|
2645
|
+
}
|
|
2646
|
+
read;
|
|
2647
|
+
update;
|
|
2648
|
+
line;
|
|
2649
|
+
edit;
|
|
2650
|
+
fillOwner;
|
|
2651
|
+
owner(node) {
|
|
2652
|
+
if (this.fillOwner) return this.fillOwner(node);
|
|
2653
|
+
const pr = props(node);
|
|
2654
|
+
const result = this.line ? pr && child(pr, "ln", drawing(node)) : pr;
|
|
2655
|
+
return result;
|
|
2656
|
+
}
|
|
2657
|
+
fill(node) {
|
|
2658
|
+
const owner = this.owner(node);
|
|
2659
|
+
return owner?.children.find(
|
|
2660
|
+
(n) => n.name.namespace === drawing(node) && ["solidFill", "gradFill", "pattFill", "blipFill", "noFill", "grpFill"].includes(
|
|
2661
|
+
n.name.localName
|
|
2662
|
+
)
|
|
2663
|
+
);
|
|
2664
|
+
}
|
|
2665
|
+
change(transform) {
|
|
2666
|
+
if (!this.edit) unsupported2("This view does not support extended drawing edits.");
|
|
2667
|
+
this.edit(transform);
|
|
2668
|
+
}
|
|
2669
|
+
apply(value) {
|
|
2670
|
+
this.change((document, node) => {
|
|
2671
|
+
const owner = this.owner(node);
|
|
2672
|
+
if (!owner) invalid4("Fill owner is unavailable.");
|
|
2673
|
+
return applyDrawingFill(document, owner, value);
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
get type() {
|
|
2677
|
+
const f = this.fill(this.read().root);
|
|
2678
|
+
return f ? { solidFill: 1, pattFill: 2, gradFill: 3, blipFill: 6, noFill: 5, grpFill: 101 }[f.name.localName] ?? null : null;
|
|
2679
|
+
}
|
|
2680
|
+
solid() {
|
|
2681
|
+
if (this.fillOwner) {
|
|
2682
|
+
if (this.type !== 1)
|
|
2683
|
+
this.change((doc, node) => {
|
|
2684
|
+
const owner = this.owner(node), fill = this.fill(node);
|
|
2685
|
+
return doc.spliceChildren(owner, fillPosition(owner, fill, drawing(node)), fill ? 1 : 0, [
|
|
2686
|
+
`<a:solidFill xmlns="${escaped(doc.resolveNamespace(owner, "") ?? "")}" xmlns:a="${drawing(node)}"/>`
|
|
2687
|
+
]);
|
|
2688
|
+
});
|
|
2689
|
+
return;
|
|
2690
|
+
}
|
|
2691
|
+
if (this.type !== 1) {
|
|
2692
|
+
if (!this.update) unsupported2("This view does not support drawing edits.");
|
|
2693
|
+
this.update(this.line ? { lineColor: "solid" } : { fill: "solid" });
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
background() {
|
|
2697
|
+
if (this.fillOwner) {
|
|
2698
|
+
this.change((doc, node) => {
|
|
2699
|
+
const owner = this.owner(node), fill = this.fill(node);
|
|
2700
|
+
return doc.spliceChildren(owner, fillPosition(owner, fill, drawing(node)), fill ? 1 : 0, [
|
|
2701
|
+
`<a:noFill xmlns="${escaped(doc.resolveNamespace(owner, "") ?? "")}" xmlns:a="${drawing(node)}"/>`
|
|
2702
|
+
]);
|
|
2703
|
+
});
|
|
2704
|
+
return;
|
|
2705
|
+
}
|
|
2706
|
+
if (!this.update) unsupported2("This view does not support drawing edits.");
|
|
2707
|
+
this.update(this.line ? { lineColor: null } : { fill: null });
|
|
2708
|
+
}
|
|
2709
|
+
gradient() {
|
|
2710
|
+
if (this.type === 3) return;
|
|
2711
|
+
if (!this.owner(this.read().root)) this.solid();
|
|
2712
|
+
this.change((doc, node) => {
|
|
2713
|
+
const owner = this.owner(node), fill = this.fill(node), a = drawing(node);
|
|
2714
|
+
return doc.spliceChildren(owner, fillPosition(owner, fill, drawing(node)), fill ? 1 : 0, [
|
|
2715
|
+
`<a:gradFill xmlns="${escaped(doc.resolveNamespace(owner, "") ?? "")}" xmlns:a="${a}" rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="accent1"><a:tint val="100000"/><a:shade val="100000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="accent1"><a:tint val="50000"/><a:shade val="100000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill>`
|
|
2716
|
+
]);
|
|
2717
|
+
});
|
|
2718
|
+
}
|
|
2719
|
+
patterned() {
|
|
2720
|
+
if (this.type === 2) return;
|
|
2721
|
+
if (!this.owner(this.read().root)) this.solid();
|
|
2722
|
+
this.change((doc, node) => {
|
|
2723
|
+
const owner = this.owner(node), fill = this.fill(node);
|
|
2724
|
+
return doc.spliceChildren(owner, fillPosition(owner, fill, drawing(node)), fill ? 1 : 0, [
|
|
2725
|
+
`<a:pattFill xmlns="${escaped(doc.resolveNamespace(owner, "") ?? "")}" xmlns:a="${drawing(node)}"/>`
|
|
2726
|
+
]);
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2729
|
+
get gradient_angle() {
|
|
2730
|
+
const fill = this.fill(this.read().root);
|
|
2731
|
+
if (fill?.name.localName !== "gradFill" || child(fill, "path"))
|
|
2732
|
+
throw new PropertyAccessError("Linear gradient angle is unavailable.");
|
|
2733
|
+
const lin = child(fill, "lin");
|
|
2734
|
+
return lin ? ((360 - Number(attr(lin, "ang")) / 6e4) % 360 + 360) % 360 : null;
|
|
2735
|
+
}
|
|
2736
|
+
set gradient_angle(v) {
|
|
2737
|
+
void this.gradient_angle;
|
|
2738
|
+
if (!Number.isFinite(v) || Math.abs(v) > 36e4) invalid4();
|
|
2739
|
+
this.change((doc, node) => {
|
|
2740
|
+
const fill = this.fill(node);
|
|
2741
|
+
return doc.merge(fill, {
|
|
2742
|
+
children: {
|
|
2743
|
+
sequence: ["gsLst", "lin", "path", "tileRect"].map((localName) => ({
|
|
2744
|
+
namespace: fill.name.namespace,
|
|
2745
|
+
localName
|
|
2746
|
+
})),
|
|
2747
|
+
upsert: [
|
|
2748
|
+
{
|
|
2749
|
+
name: { namespace: fill.name.namespace, localName: "lin" },
|
|
2750
|
+
merge: {
|
|
2751
|
+
attributes: [
|
|
2752
|
+
{
|
|
2753
|
+
namespace: "",
|
|
2754
|
+
localName: "ang",
|
|
2755
|
+
value: String(
|
|
2756
|
+
Math.round(((360 - v % 360) % 360 + 360) % 360 * 6e4) % 216e5
|
|
2757
|
+
)
|
|
2758
|
+
}
|
|
2759
|
+
]
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
]
|
|
2763
|
+
}
|
|
2764
|
+
});
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
get gradient_stops() {
|
|
2768
|
+
if (this.type !== 3) throw new PropertyAccessError("Gradient stops are unavailable.");
|
|
2769
|
+
if (!child(this.fill(this.read().root), "gsLst"))
|
|
2770
|
+
this.change((doc, node) => {
|
|
2771
|
+
const fill = this.fill(node);
|
|
2772
|
+
return doc.spliceChildren(fill, 0, 0, [
|
|
2773
|
+
`<a:gsLst xmlns:a="${fill.name.namespace}"><a:gs pos="0"><a:schemeClr val="accent1"><a:tint val="100000"/><a:shade val="100000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="accent1"><a:tint val="50000"/><a:shade val="100000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst>`
|
|
2774
|
+
]);
|
|
2775
|
+
});
|
|
2776
|
+
return new GradientStops(
|
|
2777
|
+
this.read,
|
|
2778
|
+
(t) => this.change(t),
|
|
2779
|
+
(node) => child(this.fill(node), "gsLst")
|
|
2780
|
+
);
|
|
2781
|
+
}
|
|
2782
|
+
get pattern() {
|
|
2783
|
+
if (this.type !== 2) throw new PropertyAccessError("Pattern is unavailable.");
|
|
2784
|
+
const token = attr(this.fill(this.read().root), "prst");
|
|
2785
|
+
const key = Object.keys(patternTokens).find((k) => patternTokens[Number(k)] === token);
|
|
2786
|
+
return key === void 0 ? null : Number(key);
|
|
2787
|
+
}
|
|
2788
|
+
set pattern(v) {
|
|
2789
|
+
if (this.type !== 2) throw new PropertyAccessError("Pattern is unavailable.");
|
|
2790
|
+
if (v !== null && (typeof v !== "number" || !Object.hasOwn(patternTokens, v))) invalid4();
|
|
2791
|
+
this.change(
|
|
2792
|
+
(doc, node) => doc.merge(this.fill(node), {
|
|
2793
|
+
attributes: [
|
|
2794
|
+
{ namespace: "", localName: "prst", value: v === null ? null : patternTokens[v] }
|
|
2795
|
+
]
|
|
2796
|
+
})
|
|
2797
|
+
);
|
|
2798
|
+
}
|
|
2799
|
+
color(back) {
|
|
2800
|
+
if (this.type !== 1 && this.type !== 2 || back && this.type !== 2)
|
|
2801
|
+
throw new PropertyAccessError("Fill color is unavailable.");
|
|
2802
|
+
if (this.type === 2) {
|
|
2803
|
+
const tag = back ? "bgClr" : "fgClr";
|
|
2804
|
+
if (!child(this.fill(this.read().root), tag))
|
|
2805
|
+
this.change((doc, node) => {
|
|
2806
|
+
const fill = this.fill(node);
|
|
2807
|
+
const afterForeground = fill.children.findIndex(
|
|
2808
|
+
(n) => n.name.namespace !== fill.name.namespace || n.name.localName !== "fgClr"
|
|
2809
|
+
);
|
|
2810
|
+
return doc.spliceChildren(
|
|
2811
|
+
fill,
|
|
2812
|
+
back ? afterForeground < 0 ? fill.children.length : afterForeground : 0,
|
|
2813
|
+
0,
|
|
2814
|
+
[
|
|
2815
|
+
`<a:${tag} xmlns:a="${fill.name.namespace}"><a:srgbClr val="${back ? "FFFFFF" : "000000"}"/></a:${tag}>`
|
|
2816
|
+
]
|
|
2817
|
+
);
|
|
2818
|
+
});
|
|
2819
|
+
}
|
|
2820
|
+
return new ShapeColorFormat(
|
|
2821
|
+
this.read,
|
|
2822
|
+
(t) => this.change(t),
|
|
2823
|
+
(node) => {
|
|
2824
|
+
const f = this.fill(node);
|
|
2825
|
+
return f.name.localName === "pattFill" ? child(f, back ? "bgClr" : "fgClr") : f;
|
|
2826
|
+
}
|
|
2827
|
+
);
|
|
2828
|
+
}
|
|
2829
|
+
get fore_color() {
|
|
2830
|
+
return this.color(false);
|
|
2831
|
+
}
|
|
2832
|
+
get back_color() {
|
|
2833
|
+
return this.color(true);
|
|
2834
|
+
}
|
|
2835
|
+
};
|
|
2836
|
+
var GradientStop = class _GradientStop {
|
|
2837
|
+
constructor(read, edit, owner, index) {
|
|
2838
|
+
this.read = read;
|
|
2839
|
+
this.edit = edit;
|
|
2840
|
+
this.owner = owner;
|
|
2841
|
+
this.index = index;
|
|
2842
|
+
}
|
|
2843
|
+
read;
|
|
2844
|
+
edit;
|
|
2845
|
+
owner;
|
|
2846
|
+
index;
|
|
2847
|
+
node(shape) {
|
|
2848
|
+
const n = gradientNodes(this.owner(shape))[this.index];
|
|
2849
|
+
if (!n) invalid4("Gradient stop is unavailable.");
|
|
2850
|
+
return n;
|
|
2851
|
+
}
|
|
2852
|
+
get element() {
|
|
2853
|
+
return createXmlElementView(
|
|
2854
|
+
{
|
|
2855
|
+
read: this.read,
|
|
2856
|
+
commit: (expected, next) => this.edit((document) => {
|
|
2857
|
+
if (document !== expected) throw new InvalidHandleError();
|
|
2858
|
+
return next;
|
|
2859
|
+
})
|
|
2860
|
+
},
|
|
2861
|
+
this.node(this.read().root)
|
|
2862
|
+
);
|
|
2863
|
+
}
|
|
2864
|
+
equals(other) {
|
|
2865
|
+
return other instanceof _GradientStop && this.node(this.read().root) === other.node(other.read().root);
|
|
2866
|
+
}
|
|
2867
|
+
get position() {
|
|
2868
|
+
return Number(attr(this.node(this.read().root), "pos")) / 1e5;
|
|
2869
|
+
}
|
|
2870
|
+
set position(v) {
|
|
2871
|
+
if (!Number.isFinite(v) || v < 0 || v > 1) invalid4();
|
|
2872
|
+
this.edit(
|
|
2873
|
+
(doc, node) => doc.merge(this.node(node), {
|
|
2874
|
+
attributes: [{ namespace: "", localName: "pos", value: String(Math.round(v * 1e5)) }]
|
|
2875
|
+
})
|
|
2876
|
+
);
|
|
2877
|
+
}
|
|
2878
|
+
get color() {
|
|
2879
|
+
return new ShapeColorFormat(this.read, this.edit, (node) => this.node(node));
|
|
2880
|
+
}
|
|
2881
|
+
};
|
|
2882
|
+
var GradientStops = class {
|
|
2883
|
+
constructor(read, edit, owner) {
|
|
2884
|
+
this.read = read;
|
|
2885
|
+
this.edit = edit;
|
|
2886
|
+
this.owner = owner;
|
|
2887
|
+
return new Proxy(this, {
|
|
2888
|
+
get(target, key) {
|
|
2889
|
+
if (typeof key === "string" && key !== "" && String(Number(key)) === key) {
|
|
2890
|
+
if (Number(key) < 0) throw new IndexError("Gradient stop index is out of range.");
|
|
2891
|
+
return target.at(Number(key));
|
|
2892
|
+
}
|
|
2893
|
+
const value = Reflect.get(target, key, target);
|
|
2894
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
2895
|
+
},
|
|
2896
|
+
set(target, key, value, receiver) {
|
|
2897
|
+
if (typeof key === "string" && key !== "" && String(Number(key)) === key)
|
|
2898
|
+
invalid4("Gradient stops cannot replace entries.");
|
|
2899
|
+
return Reflect.set(target, key, value, receiver);
|
|
2900
|
+
},
|
|
2901
|
+
defineProperty(target, key, descriptor) {
|
|
2902
|
+
if (typeof key === "string" && key !== "" && String(Number(key)) === key)
|
|
2903
|
+
invalid4("Gradient stops cannot replace entries.");
|
|
2904
|
+
return Reflect.defineProperty(target, key, descriptor);
|
|
2905
|
+
},
|
|
2906
|
+
deleteProperty(target, key) {
|
|
2907
|
+
if (typeof key === "string" && key !== "" && String(Number(key)) === key)
|
|
2908
|
+
invalid4("Gradient stops cannot remove entries.");
|
|
2909
|
+
return Reflect.deleteProperty(target, key);
|
|
2910
|
+
}
|
|
2911
|
+
});
|
|
2912
|
+
}
|
|
2913
|
+
read;
|
|
2914
|
+
edit;
|
|
2915
|
+
owner;
|
|
2916
|
+
cache = /* @__PURE__ */ new Map();
|
|
2917
|
+
get length() {
|
|
2918
|
+
return gradientNodes(this.owner(this.read().root)).length;
|
|
2919
|
+
}
|
|
2920
|
+
at(index) {
|
|
2921
|
+
if (!Number.isInteger(index) || index < -this.length || index >= this.length)
|
|
2922
|
+
throw new IndexError("Gradient stop index is out of range.");
|
|
2923
|
+
const i = index < 0 ? index + this.length : index;
|
|
2924
|
+
let stop = this.cache.get(i);
|
|
2925
|
+
if (!stop) {
|
|
2926
|
+
stop = new GradientStop(this.read, this.edit, this.owner, i);
|
|
2927
|
+
this.cache.set(i, stop);
|
|
2928
|
+
}
|
|
2929
|
+
return stop;
|
|
2930
|
+
}
|
|
2931
|
+
*[Symbol.iterator]() {
|
|
2932
|
+
for (let i = 0; i < this.length; i++) yield this.at(i);
|
|
2933
|
+
}
|
|
2934
|
+
includes(value) {
|
|
2935
|
+
return Array.from(this).some((stop) => stop.equals(value));
|
|
2936
|
+
}
|
|
2937
|
+
count(value) {
|
|
2938
|
+
return this.includes(value) ? 1 : 0;
|
|
2939
|
+
}
|
|
2940
|
+
index(value, start = 0, stop = this.length) {
|
|
2941
|
+
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(stop))
|
|
2942
|
+
throw new ValueError("Gradient stop search bounds must be integers.");
|
|
2943
|
+
const lower = Math.max(0, start < 0 ? this.length + start : start);
|
|
2944
|
+
const upper = Math.min(this.length, stop < 0 ? this.length + stop : stop);
|
|
2945
|
+
for (let i = lower; i < upper; i++) if (this.at(i).equals(value)) return i;
|
|
2946
|
+
throw new ValueError("Gradient stop is not in this collection.");
|
|
2947
|
+
}
|
|
2948
|
+
reversed() {
|
|
2949
|
+
return Array.from(this).reverse();
|
|
2950
|
+
}
|
|
2951
|
+
};
|
|
2952
|
+
var ShadowFormat = class {
|
|
2953
|
+
constructor(read, edit) {
|
|
2954
|
+
this.read = read;
|
|
2955
|
+
this.edit = edit;
|
|
2956
|
+
}
|
|
2957
|
+
read;
|
|
2958
|
+
edit;
|
|
2959
|
+
get inherit() {
|
|
2960
|
+
return readDrawingFormat(this.read().root).shadowInherit;
|
|
2961
|
+
}
|
|
2962
|
+
set inherit(value) {
|
|
2963
|
+
this.edit((doc, node) => applyDrawingUpdate(doc, node, { shadowInherit: value }));
|
|
2964
|
+
}
|
|
2965
|
+
};
|
|
2966
|
+
var LineFormat = class {
|
|
2967
|
+
constructor(read, update, edit) {
|
|
2968
|
+
this.read = read;
|
|
2969
|
+
this.update = update;
|
|
2970
|
+
this.edit = edit;
|
|
2971
|
+
}
|
|
2972
|
+
read;
|
|
2973
|
+
update;
|
|
2974
|
+
edit;
|
|
2975
|
+
get width() {
|
|
2976
|
+
return new Length(readDrawingFormat(this.read().root).line.width ?? 0);
|
|
2977
|
+
}
|
|
2978
|
+
set width(value) {
|
|
2979
|
+
if (value !== null && !(value instanceof Length)) invalid4();
|
|
2980
|
+
this.update({ lineWidth: value });
|
|
2981
|
+
}
|
|
2982
|
+
get fill() {
|
|
2983
|
+
return new FillFormat(this.read, this.update, true, this.edit);
|
|
2984
|
+
}
|
|
2985
|
+
get color() {
|
|
2986
|
+
if (this.fill.type !== 1) this.fill.solid();
|
|
2987
|
+
return this.fill.fore_color;
|
|
2988
|
+
}
|
|
2989
|
+
get dash_style() {
|
|
2990
|
+
const token = readDrawingFormat(this.read().root).line.dash;
|
|
2991
|
+
const key = Object.keys(dashTokens).find((k) => dashTokens[Number(k)] === token);
|
|
2992
|
+
return key === void 0 ? null : Number(key);
|
|
2993
|
+
}
|
|
2994
|
+
set dash_style(v) {
|
|
2995
|
+
if (v !== null && (typeof v !== "number" || !Object.hasOwn(dashTokens, v))) invalid4();
|
|
2996
|
+
if (!this.edit) unsupported2("Extended line editing is unavailable.");
|
|
2997
|
+
this.edit(
|
|
2998
|
+
(doc, node) => applyDrawingUpdate(doc, node, { line: { dash: v === null ? null : dashTokens[v] } })
|
|
2999
|
+
);
|
|
3000
|
+
}
|
|
3001
|
+
};
|
|
3002
|
+
|
|
3003
|
+
// packages/safe-bash-presentation-engine/src/text-paragraphs.ts
|
|
3004
|
+
import { SaxesParser as SaxesParser2 } from "saxes";
|
|
3005
|
+
|
|
3006
|
+
// packages/safe-bash-presentation-engine/src/paragraph-alignment.ts
|
|
3007
|
+
var AlignmentValue = /* @__PURE__ */ ((AlignmentValue2) => {
|
|
3008
|
+
AlignmentValue2[AlignmentValue2["LEFT"] = 1] = "LEFT";
|
|
3009
|
+
AlignmentValue2[AlignmentValue2["CENTER"] = 2] = "CENTER";
|
|
3010
|
+
AlignmentValue2[AlignmentValue2["RIGHT"] = 3] = "RIGHT";
|
|
3011
|
+
AlignmentValue2[AlignmentValue2["JUSTIFY"] = 4] = "JUSTIFY";
|
|
3012
|
+
AlignmentValue2[AlignmentValue2["DISTRIBUTE"] = 5] = "DISTRIBUTE";
|
|
3013
|
+
AlignmentValue2[AlignmentValue2["THAI_DISTRIBUTE"] = 6] = "THAI_DISTRIBUTE";
|
|
3014
|
+
AlignmentValue2[AlignmentValue2["JUSTIFY_LOW"] = 7] = "JUSTIFY_LOW";
|
|
3015
|
+
AlignmentValue2[AlignmentValue2["MIXED"] = -2] = "MIXED";
|
|
3016
|
+
return AlignmentValue2;
|
|
3017
|
+
})(AlignmentValue || {});
|
|
3018
|
+
var alignmentMetadata = [
|
|
3019
|
+
{ name: "LEFT", value: 1, xml_value: "l" },
|
|
3020
|
+
{ name: "CENTER", value: 2, xml_value: "ctr" },
|
|
3021
|
+
{ name: "RIGHT", value: 3, xml_value: "r" },
|
|
3022
|
+
{ name: "JUSTIFY", value: 4, xml_value: "just" },
|
|
3023
|
+
{ name: "DISTRIBUTE", value: 5, xml_value: "dist" },
|
|
3024
|
+
{ name: "THAI_DISTRIBUTE", value: 6, xml_value: "thaiDist" },
|
|
3025
|
+
{ name: "JUSTIFY_LOW", value: 7, xml_value: "justLow" },
|
|
3026
|
+
{ name: "MIXED", value: -2, xml_value: null }
|
|
3027
|
+
].map((value) => Object.freeze(value));
|
|
3028
|
+
function invalid5() {
|
|
3029
|
+
throw new ValueError("Invalid paragraph alignment value.");
|
|
3030
|
+
}
|
|
3031
|
+
var PP_PARAGRAPH_ALIGNMENT = Object.freeze(
|
|
3032
|
+
Object.assign(AlignmentValue, {
|
|
3033
|
+
metadata(value) {
|
|
3034
|
+
const found = alignmentMetadata.find((item) => item.value === value);
|
|
3035
|
+
return found ?? invalid5();
|
|
3036
|
+
},
|
|
3037
|
+
from_xml(xml_value) {
|
|
3038
|
+
const found = alignmentMetadata.find(
|
|
3039
|
+
(item) => item.xml_value !== null && item.xml_value === xml_value
|
|
3040
|
+
);
|
|
3041
|
+
return found?.value ?? invalid5();
|
|
3042
|
+
},
|
|
3043
|
+
to_xml(value) {
|
|
3044
|
+
const found = alignmentMetadata.find((item) => item.value === value);
|
|
3045
|
+
return found?.xml_value ?? invalid5();
|
|
3046
|
+
},
|
|
3047
|
+
validate(value) {
|
|
3048
|
+
if (!alignmentMetadata.some((item) => item.value === value && item.xml_value !== null))
|
|
3049
|
+
invalid5();
|
|
3050
|
+
}
|
|
3051
|
+
})
|
|
3052
|
+
);
|
|
3053
|
+
|
|
3054
|
+
// packages/safe-bash-presentation-engine/src/text-paragraphs.ts
|
|
3055
|
+
var paragraphAlignments = [
|
|
3056
|
+
"left",
|
|
3057
|
+
"center",
|
|
3058
|
+
"right",
|
|
3059
|
+
"justify",
|
|
3060
|
+
"distributed",
|
|
3061
|
+
"thaiDistributed",
|
|
3062
|
+
"justifyLow"
|
|
3063
|
+
];
|
|
3064
|
+
var paragraphNumberingSchemes = [
|
|
3065
|
+
"alphaLcParenBoth",
|
|
3066
|
+
"alphaUcParenBoth",
|
|
3067
|
+
"alphaLcParenR",
|
|
3068
|
+
"alphaUcParenR",
|
|
3069
|
+
"alphaLcPeriod",
|
|
3070
|
+
"alphaUcPeriod",
|
|
3071
|
+
"arabicParenBoth",
|
|
3072
|
+
"arabicParenR",
|
|
3073
|
+
"arabicPeriod",
|
|
3074
|
+
"arabicPlain",
|
|
3075
|
+
"romanLcParenBoth",
|
|
3076
|
+
"romanUcParenBoth",
|
|
3077
|
+
"romanLcParenR",
|
|
3078
|
+
"romanUcParenR",
|
|
3079
|
+
"romanLcPeriod",
|
|
3080
|
+
"romanUcPeriod",
|
|
3081
|
+
"circleNumDbPlain",
|
|
3082
|
+
"circleNumWdBlackPlain",
|
|
3083
|
+
"circleNumWdWhitePlain",
|
|
3084
|
+
"arabicDbPeriod",
|
|
3085
|
+
"arabicDbPlain",
|
|
3086
|
+
"ea1ChsPeriod",
|
|
3087
|
+
"ea1ChsPlain",
|
|
3088
|
+
"ea1ChtPeriod",
|
|
3089
|
+
"ea1ChtPlain",
|
|
3090
|
+
"ea1JpnChsDbPeriod",
|
|
3091
|
+
"ea1JpnKorPlain",
|
|
3092
|
+
"ea1JpnKorPeriod",
|
|
3093
|
+
"arabic1Minus",
|
|
3094
|
+
"arabic2Minus",
|
|
3095
|
+
"hebrew2Minus",
|
|
3096
|
+
"thaiAlphaPeriod",
|
|
3097
|
+
"thaiAlphaParenR",
|
|
3098
|
+
"thaiAlphaParenBoth",
|
|
3099
|
+
"thaiNumPeriod",
|
|
3100
|
+
"thaiNumParenR",
|
|
3101
|
+
"thaiNumParenBoth",
|
|
3102
|
+
"hindiAlphaPeriod",
|
|
3103
|
+
"hindiNumPeriod",
|
|
3104
|
+
"hindiNumParenR",
|
|
3105
|
+
"hindiAlpha1Period"
|
|
3106
|
+
];
|
|
3107
|
+
var formatKeys = [
|
|
3108
|
+
"alignment",
|
|
3109
|
+
"marginLeft",
|
|
3110
|
+
"marginRight",
|
|
3111
|
+
"indent",
|
|
3112
|
+
"defaultTabSize",
|
|
3113
|
+
"lineSpacing",
|
|
3114
|
+
"spaceBefore",
|
|
3115
|
+
"spaceAfter",
|
|
3116
|
+
"level",
|
|
3117
|
+
"rtl",
|
|
3118
|
+
"bullet",
|
|
3119
|
+
"tabs"
|
|
3120
|
+
];
|
|
3121
|
+
var alignmentTokens = ["l", "ctr", "r", "just", "dist", "thaiDist", "justLow"];
|
|
3122
|
+
function alignmentIndex(value) {
|
|
3123
|
+
return typeof value === "number" ? value - 1 : paragraphAlignments.includes(value) ? paragraphAlignments.indexOf(value) : Number(PP_PARAGRAPH_ALIGNMENT[value]) - 1;
|
|
3124
|
+
}
|
|
3125
|
+
function invalid6() {
|
|
3126
|
+
throw new OfficeError("invalid-value", "Invalid paragraph formatting options.", "usage");
|
|
3127
|
+
}
|
|
3128
|
+
function object(value, keys2) {
|
|
3129
|
+
return !!value && typeof value === "object" && [Object.prototype, null].includes(Object.getPrototypeOf(value)) && Object.keys(value).every((k) => keys2.includes(k));
|
|
3130
|
+
}
|
|
3131
|
+
function number(value, min, max) {
|
|
3132
|
+
return typeof value === "number" && Number.isFinite(value) && value >= min && value <= max;
|
|
3133
|
+
}
|
|
3134
|
+
function validateTextParagraphOptions(options) {
|
|
3135
|
+
if (!object(options, [...formatKeys, "paragraph", "all", "allowEmpty", "scope", "select", "shape"]))
|
|
3136
|
+
invalid6();
|
|
3137
|
+
const { scope, select, shape } = options;
|
|
3138
|
+
validateTextReadingOptions({
|
|
3139
|
+
...scope === void 0 ? {} : { scope },
|
|
3140
|
+
...select === void 0 ? {} : { select },
|
|
3141
|
+
...shape === void 0 ? {} : { shape }
|
|
3142
|
+
});
|
|
3143
|
+
if (!formatKeys.some((k) => options[k] !== void 0)) invalid6();
|
|
3144
|
+
if (options.paragraph !== void 0 && (!Number.isSafeInteger(options.paragraph) || options.paragraph < 0))
|
|
3145
|
+
invalid6();
|
|
3146
|
+
for (const key of ["all", "allowEmpty"])
|
|
3147
|
+
if (options[key] !== void 0 && typeof options[key] !== "boolean") invalid6();
|
|
3148
|
+
for (const key of ["rtl"])
|
|
3149
|
+
if (options[key] != null && typeof options[key] !== "boolean") invalid6();
|
|
3150
|
+
if (options.alignment != null && !alignmentTokens[alignmentIndex(options.alignment)]) invalid6();
|
|
3151
|
+
for (const key of ["marginLeft", "marginRight", "indent", "defaultTabSize"])
|
|
3152
|
+
if (options[key] != null && !number(options[key], key === "indent" ? -51206400 / 12700 : 0, 51206400 / 12700))
|
|
3153
|
+
invalid6();
|
|
3154
|
+
for (const key of ["spaceBefore", "spaceAfter"])
|
|
3155
|
+
if (options[key] != null && !number(options[key], 0, 20116800 / 100)) invalid6();
|
|
3156
|
+
if (options.level != null && (!Number.isInteger(options.level) || !number(options.level, 0, 8)))
|
|
3157
|
+
invalid6();
|
|
3158
|
+
if (options.lineSpacing != null) {
|
|
3159
|
+
const s = options.lineSpacing;
|
|
3160
|
+
if (!object(s, ["unit", "value"]) || !["pt", "multiple"].includes(s.unit) || !number(s.value, 0, s.unit === "pt" ? 201168 : 132))
|
|
3161
|
+
invalid6();
|
|
3162
|
+
}
|
|
3163
|
+
if (options.bullet != null) {
|
|
3164
|
+
const b = options.bullet;
|
|
3165
|
+
if (!object(b, ["kind", "character", "scheme", "startAt"])) invalid6();
|
|
3166
|
+
if (b.kind === "none") {
|
|
3167
|
+
if (Object.keys(b).length !== 1) invalid6();
|
|
3168
|
+
} else if (b.kind === "character") {
|
|
3169
|
+
if (Object.keys(b).some((k) => !["kind", "character"].includes(k)) || typeof b.character !== "string" || Array.from(b.character).length !== 1 || b.character.codePointAt(0) < 32 || b.character.codePointAt(0) >= 55296 && b.character.codePointAt(0) <= 57343 || [65534, 65535].includes(b.character.codePointAt(0)))
|
|
3170
|
+
invalid6();
|
|
3171
|
+
} else if (b.kind === "numbered") {
|
|
3172
|
+
if (Object.keys(b).some((k) => !["kind", "scheme", "startAt"].includes(k)) || !paragraphNumberingSchemes.includes(b.scheme) || b.startAt !== void 0 && (!Number.isInteger(b.startAt) || !number(b.startAt, 1, 32767)))
|
|
3173
|
+
invalid6();
|
|
3174
|
+
} else invalid6();
|
|
3175
|
+
}
|
|
3176
|
+
if (options.tabs != null) {
|
|
3177
|
+
if (!Array.isArray(options.tabs) || options.tabs.length > 1e4) invalid6();
|
|
3178
|
+
let previous = -1;
|
|
3179
|
+
for (const tab of options.tabs) {
|
|
3180
|
+
if (!object(tab, ["position", "alignment"]) || !number(tab.position, 0, 51206400 / 12700) || !["left", "center", "right", "decimal"].includes(tab.alignment) || Math.round(tab.position * 12700) <= previous)
|
|
3181
|
+
invalid6();
|
|
3182
|
+
previous = Math.round(tab.position * 12700);
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
var sequence = [
|
|
3187
|
+
"lnSpc",
|
|
3188
|
+
"spcBef",
|
|
3189
|
+
"spcAft",
|
|
3190
|
+
"buClrTx",
|
|
3191
|
+
"buClr",
|
|
3192
|
+
"buSzTx",
|
|
3193
|
+
"buSzPct",
|
|
3194
|
+
"buSzPts",
|
|
3195
|
+
"buFontTx",
|
|
3196
|
+
"buFont",
|
|
3197
|
+
"buNone",
|
|
3198
|
+
"buAutoNum",
|
|
3199
|
+
"buChar",
|
|
3200
|
+
"buBlip",
|
|
3201
|
+
"tabLst",
|
|
3202
|
+
"defRPr",
|
|
3203
|
+
"extLst"
|
|
3204
|
+
];
|
|
3205
|
+
function paragraphPropertiesMerge(options, namespace) {
|
|
3206
|
+
const name = (localName) => ({ namespace, localName });
|
|
3207
|
+
const attributes = [];
|
|
3208
|
+
for (const [key, localName] of Object.entries({
|
|
3209
|
+
alignment: "algn",
|
|
3210
|
+
marginLeft: "marL",
|
|
3211
|
+
marginRight: "marR",
|
|
3212
|
+
indent: "indent",
|
|
3213
|
+
defaultTabSize: "defTabSz",
|
|
3214
|
+
level: "lvl",
|
|
3215
|
+
rtl: "rtl"
|
|
3216
|
+
})) {
|
|
3217
|
+
const value = options[key];
|
|
3218
|
+
if (value === void 0) continue;
|
|
3219
|
+
attributes.push({
|
|
3220
|
+
namespace: "",
|
|
3221
|
+
localName,
|
|
3222
|
+
value: value === null ? null : key === "alignment" ? alignmentTokens[alignmentIndex(value)] : key === "rtl" ? value ? "1" : "0" : String(
|
|
3223
|
+
["marginLeft", "marginRight", "indent", "defaultTabSize"].includes(key) ? Math.sign(Number(value)) * Math.round(Math.abs(Number(value)) * 12700) : value
|
|
3224
|
+
)
|
|
3225
|
+
});
|
|
3226
|
+
}
|
|
3227
|
+
const remove = [];
|
|
3228
|
+
const upsert = [];
|
|
3229
|
+
for (const [key, local] of [
|
|
3230
|
+
["lineSpacing", "lnSpc"],
|
|
3231
|
+
["spaceBefore", "spcBef"],
|
|
3232
|
+
["spaceAfter", "spcAft"]
|
|
3233
|
+
]) {
|
|
3234
|
+
const value = options[key];
|
|
3235
|
+
if (value === void 0) continue;
|
|
3236
|
+
if (value === null) {
|
|
3237
|
+
remove.push(name(local));
|
|
3238
|
+
continue;
|
|
3239
|
+
}
|
|
3240
|
+
const spacing = typeof value === "number" ? { unit: "pt", value } : value;
|
|
3241
|
+
const child2 = spacing.unit === "pt" ? "spcPts" : "spcPct";
|
|
3242
|
+
upsert.push({
|
|
3243
|
+
name: name(local),
|
|
3244
|
+
merge: {
|
|
3245
|
+
children: {
|
|
3246
|
+
sequence: [name("spcPct"), name("spcPts")],
|
|
3247
|
+
remove: [name(child2 === "spcPts" ? "spcPct" : "spcPts")],
|
|
3248
|
+
upsert: [
|
|
3249
|
+
{
|
|
3250
|
+
name: name(child2),
|
|
3251
|
+
merge: {
|
|
3252
|
+
attributes: [
|
|
3253
|
+
{
|
|
3254
|
+
namespace: "",
|
|
3255
|
+
localName: "val",
|
|
3256
|
+
value: String(
|
|
3257
|
+
Math.round(spacing.value * (spacing.unit === "pt" ? 100 : 1e5))
|
|
3258
|
+
)
|
|
3259
|
+
}
|
|
3260
|
+
]
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
]
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
});
|
|
3267
|
+
}
|
|
3268
|
+
if (options.bullet !== void 0) {
|
|
3269
|
+
const b = options.bullet;
|
|
3270
|
+
const selected = b?.kind === "none" ? "buNone" : b?.kind === "character" ? "buChar" : b?.kind === "numbered" ? "buAutoNum" : null;
|
|
3271
|
+
remove.push(
|
|
3272
|
+
...["buNone", "buAutoNum", "buChar", "buBlip"].filter((n) => n !== selected).map(name)
|
|
3273
|
+
);
|
|
3274
|
+
if (b) {
|
|
3275
|
+
const local = b.kind === "none" ? "buNone" : b.kind === "character" ? "buChar" : "buAutoNum";
|
|
3276
|
+
const values3 = b.kind === "none" ? {} : b.kind === "character" ? { char: b.character } : {
|
|
3277
|
+
type: b.scheme,
|
|
3278
|
+
...b.startAt === void 0 ? {} : { startAt: String(b.startAt) }
|
|
3279
|
+
};
|
|
3280
|
+
upsert.push({
|
|
3281
|
+
name: name(local),
|
|
3282
|
+
merge: {
|
|
3283
|
+
attributes: Object.entries(values3).map(([localName, value]) => ({
|
|
3284
|
+
namespace: "",
|
|
3285
|
+
localName,
|
|
3286
|
+
value
|
|
3287
|
+
}))
|
|
3288
|
+
}
|
|
3289
|
+
});
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
if (options.tabs !== void 0) {
|
|
3293
|
+
if (options.tabs === null) remove.push(name("tabLst"));
|
|
3294
|
+
else upsert.push({ name: name("tabLst"), merge: {} });
|
|
3295
|
+
}
|
|
3296
|
+
return { attributes, children: { sequence: sequence.map(name), remove, upsert } };
|
|
3297
|
+
}
|
|
3298
|
+
function applyParagraphFormatting(document, node, options) {
|
|
3299
|
+
validateTextParagraphOptions(options);
|
|
3300
|
+
if (node.name.localName !== "p" || ![
|
|
3301
|
+
"http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
3302
|
+
"http://purl.oclc.org/ooxml/drawingml/main"
|
|
3303
|
+
].includes(node.name.namespace))
|
|
3304
|
+
invalid6();
|
|
3305
|
+
const path = [];
|
|
3306
|
+
function locate(current) {
|
|
3307
|
+
if (current === node) return true;
|
|
3308
|
+
for (const [i, c] of current.children.entries()) {
|
|
3309
|
+
path.push(i);
|
|
3310
|
+
if (locate(c)) return true;
|
|
3311
|
+
path.pop();
|
|
3312
|
+
}
|
|
3313
|
+
return false;
|
|
3314
|
+
}
|
|
3315
|
+
if (!locate(document.root)) invalid6();
|
|
3316
|
+
const ns = node.name.namespace;
|
|
3317
|
+
let result = document;
|
|
3318
|
+
if (!node.children.some((n) => n.name.namespace === ns && n.name.localName === "pPr")) {
|
|
3319
|
+
result = result.spliceChildren(node, 0, 0, [`<pPr xmlns="${ns}"/>`]);
|
|
3320
|
+
node = path.reduce((n, i) => n.children[i], result.root);
|
|
3321
|
+
}
|
|
3322
|
+
result = result.merge(
|
|
3323
|
+
node.children.find((n) => n.name.namespace === ns && n.name.localName === "pPr"),
|
|
3324
|
+
paragraphPropertiesMerge(options, ns)
|
|
3325
|
+
);
|
|
3326
|
+
if (options.tabs != null) {
|
|
3327
|
+
const p = path.reduce((n, i) => n.children[i], result.root);
|
|
3328
|
+
let list = p.children.find((n) => n.name.namespace === ns && n.name.localName === "pPr").children.find((n) => n.name.namespace === ns && n.name.localName === "tabLst");
|
|
3329
|
+
const tokens = { left: "l", center: "ctr", right: "r", decimal: "dec" };
|
|
3330
|
+
const removed = list.children.flatMap(
|
|
3331
|
+
(child2, index) => child2.name.namespace === ns && child2.name.localName === "tab" ? [index] : []
|
|
3332
|
+
);
|
|
3333
|
+
for (const index of removed.reverse()) {
|
|
3334
|
+
result = result.spliceChildren(list, index, 1, []);
|
|
3335
|
+
list = path.reduce((n, i) => n.children[i], result.root).children.find((n) => n.name.namespace === ns && n.name.localName === "pPr").children.find((n) => n.name.namespace === ns && n.name.localName === "tabLst");
|
|
3336
|
+
}
|
|
3337
|
+
result = result.spliceChildren(
|
|
3338
|
+
list,
|
|
3339
|
+
0,
|
|
3340
|
+
0,
|
|
3341
|
+
options.tabs.map(
|
|
3342
|
+
(t) => `<tab xmlns="${ns}" pos="${Math.round(t.position * 12700)}" algn="${tokens[t.alignment]}"/>`
|
|
3343
|
+
)
|
|
3344
|
+
);
|
|
3345
|
+
}
|
|
3346
|
+
return result;
|
|
3347
|
+
}
|
|
3348
|
+
function readParagraphFormatting(paragraph) {
|
|
3349
|
+
const ns = paragraph.name.namespace;
|
|
3350
|
+
const candidates = paragraph.children.filter(
|
|
3351
|
+
(n) => n.name.namespace === ns && n.name.localName === "pPr"
|
|
3352
|
+
);
|
|
3353
|
+
if (candidates.length > 1)
|
|
3354
|
+
throw new OfficeError("invalid-xml", "Ambiguous paragraph properties.", "parse");
|
|
3355
|
+
const p = candidates[0];
|
|
3356
|
+
const attr2 = (n, key) => n?.attributes.find((a) => !a.name.namespace && a.name.localName === key)?.value ?? null;
|
|
3357
|
+
const child2 = (key) => p?.children.find((n) => n.name.namespace === ns && n.name.localName === key);
|
|
3358
|
+
const numeric = (value, scale) => {
|
|
3359
|
+
if (value === null) return null;
|
|
3360
|
+
if (!value.trim() || !Number.isFinite(Number(value)))
|
|
3361
|
+
throw new OfficeError("invalid-xml", "Invalid paragraph number.", "parse");
|
|
3362
|
+
return Number(value) / scale;
|
|
3363
|
+
};
|
|
3364
|
+
const spacing = (key) => {
|
|
3365
|
+
const n = child2(key)?.children.find(
|
|
3366
|
+
(n2) => n2.name.namespace === ns && ["spcPts", "spcPct"].includes(n2.name.localName)
|
|
3367
|
+
);
|
|
3368
|
+
if (!n) return null;
|
|
3369
|
+
const value = attr2(n, "val");
|
|
3370
|
+
if (value === null) return null;
|
|
3371
|
+
return {
|
|
3372
|
+
unit: n.name.localName === "spcPts" ? "pt" : "multiple",
|
|
3373
|
+
value: n.name.localName === "spcPts" ? numeric(value, 100) : value.endsWith("%") ? numeric(value.slice(0, -1), 100) : numeric(value, 1e5)
|
|
3374
|
+
};
|
|
3375
|
+
};
|
|
3376
|
+
const bulletNode = p?.children.find(
|
|
3377
|
+
(n) => n.name.namespace === ns && ["buNone", "buAutoNum", "buChar", "buBlip"].includes(n.name.localName)
|
|
3378
|
+
);
|
|
3379
|
+
const bullet = bulletNode?.name.localName === "buNone" ? { kind: "none" } : bulletNode?.name.localName === "buChar" ? { kind: "character", character: attr2(bulletNode, "char") } : bulletNode?.name.localName === "buAutoNum" ? {
|
|
3380
|
+
kind: "numbered",
|
|
3381
|
+
scheme: attr2(bulletNode, "type"),
|
|
3382
|
+
...attr2(bulletNode, "startAt") === null ? {} : { startAt: Number(attr2(bulletNode, "startAt")) }
|
|
3383
|
+
} : bulletNode ? { kind: "picture" } : null;
|
|
3384
|
+
const before = spacing("spcBef"), after = spacing("spcAft");
|
|
3385
|
+
const align = attr2(p, "algn");
|
|
3386
|
+
const rtl = attr2(p, "rtl");
|
|
3387
|
+
if (rtl !== null && !["0", "1", "false", "true"].includes(rtl))
|
|
3388
|
+
throw new OfficeError("invalid-xml", "Invalid paragraph direction.", "parse");
|
|
3389
|
+
return {
|
|
3390
|
+
alignment: align === null ? null : paragraphAlignments[alignmentTokens.indexOf(align)] ?? align,
|
|
3391
|
+
marginLeft: numeric(attr2(p, "marL"), 12700),
|
|
3392
|
+
marginRight: numeric(attr2(p, "marR"), 12700),
|
|
3393
|
+
indent: numeric(attr2(p, "indent"), 12700),
|
|
3394
|
+
defaultTabSize: numeric(attr2(p, "defTabSz"), 12700),
|
|
3395
|
+
level: numeric(attr2(p, "lvl"), 1),
|
|
3396
|
+
rtl: rtl === null ? null : ["1", "true"].includes(rtl),
|
|
3397
|
+
lineSpacing: spacing("lnSpc"),
|
|
3398
|
+
spaceBefore: before?.unit === "pt" ? before.value : null,
|
|
3399
|
+
spaceAfter: after?.unit === "pt" ? after.value : null,
|
|
3400
|
+
bullet,
|
|
3401
|
+
tabs: child2("tabLst")?.children.filter((n) => n.name.namespace === ns && n.name.localName === "tab").map((n) => ({
|
|
3402
|
+
position: numeric(attr2(n, "pos"), 12700),
|
|
3403
|
+
alignment: { l: "left", ctr: "center", r: "right", dec: "decimal" }[attr2(n, "algn") ?? "l"] ?? attr2(n, "algn")
|
|
3404
|
+
})) ?? null
|
|
3405
|
+
};
|
|
3406
|
+
}
|
|
3407
|
+
async function readTextParagraphs(input, options, context) {
|
|
3408
|
+
const { paragraph, ...reading } = options;
|
|
3409
|
+
if (paragraph !== void 0 && (!Number.isSafeInteger(paragraph) || paragraph < 0)) invalid6();
|
|
3410
|
+
const bodies = await readTextBodies(input, reading, context);
|
|
3411
|
+
return bodies.flatMap(
|
|
3412
|
+
(body) => body.paragraphs.flatMap(
|
|
3413
|
+
(p, i) => paragraph !== void 0 && paragraph !== i ? [] : [
|
|
3414
|
+
{
|
|
3415
|
+
location: body.segment.location,
|
|
3416
|
+
paragraph: i,
|
|
3417
|
+
coordinateSystem: "zero-based",
|
|
3418
|
+
formatting: readParagraphFormatting(p.node)
|
|
3419
|
+
}
|
|
3420
|
+
]
|
|
3421
|
+
)
|
|
3422
|
+
);
|
|
3423
|
+
}
|
|
3424
|
+
async function mutateTextParagraphs(input, options, context) {
|
|
3425
|
+
validateTextParagraphOptions(options);
|
|
3426
|
+
if (!options.all && options.select === void 0 && options.shape === void 0 && options.paragraph === void 0)
|
|
3427
|
+
throw new SelectionError("missing-selection");
|
|
3428
|
+
const state = await loadShared(input, context);
|
|
3429
|
+
const { scope, select, shape } = options;
|
|
3430
|
+
const bodies = await readTextBodies(
|
|
3431
|
+
state.source,
|
|
3432
|
+
{
|
|
3433
|
+
...scope === void 0 ? {} : { scope },
|
|
3434
|
+
...select === void 0 ? {} : { select },
|
|
3435
|
+
...shape === void 0 ? {} : { shape }
|
|
3436
|
+
},
|
|
3437
|
+
context
|
|
3438
|
+
);
|
|
3439
|
+
const edits = /* @__PURE__ */ new Map();
|
|
3440
|
+
const locations = [];
|
|
3441
|
+
let affected = 0;
|
|
3442
|
+
for (const body of bodies)
|
|
3443
|
+
for (const [i, p] of body.paragraphs.entries()) {
|
|
3444
|
+
if (options.paragraph !== void 0 && options.paragraph !== i) continue;
|
|
3445
|
+
const edit = edits.get(body.part) ?? {
|
|
3446
|
+
document: body.document,
|
|
3447
|
+
nodes: /* @__PURE__ */ new Set()
|
|
3448
|
+
};
|
|
3449
|
+
if (!edit.nodes.has(p.node)) {
|
|
3450
|
+
edit.nodes.add(p.node);
|
|
3451
|
+
affected++;
|
|
3452
|
+
}
|
|
3453
|
+
edits.set(body.part, edit);
|
|
3454
|
+
if (!locations.includes(body.segment.location)) locations.push(body.segment.location);
|
|
3455
|
+
}
|
|
3456
|
+
if (!affected && !options.allowEmpty) throw new SelectionError("missing-selection");
|
|
3457
|
+
const singleShapeFormatting = options.shape !== void 0 && options.paragraph === void 0 && bodies.length === 1;
|
|
3458
|
+
if (affected > 1 && !options.all && !singleShapeFormatting) throw new SelectionError("ambiguous-selection");
|
|
3459
|
+
for (const [part, edit] of edits) {
|
|
3460
|
+
const paths = [];
|
|
3461
|
+
const visit = (node, path) => {
|
|
3462
|
+
if (edit.nodes.has(node)) paths.push(path);
|
|
3463
|
+
node.children.forEach((n, i) => visit(n, [...path, i]));
|
|
3464
|
+
};
|
|
3465
|
+
visit(edit.document.root, []);
|
|
3466
|
+
let document = edit.document;
|
|
3467
|
+
for (const path of paths.reverse()) {
|
|
3468
|
+
context.signal?.throwIfAborted();
|
|
3469
|
+
document = applyParagraphFormatting(
|
|
3470
|
+
document,
|
|
3471
|
+
path.reduce((n, i) => n.children[i], document.root),
|
|
3472
|
+
options
|
|
3473
|
+
);
|
|
3474
|
+
}
|
|
3475
|
+
state.save(part, document);
|
|
3476
|
+
}
|
|
3477
|
+
if (!affected) return { bytes: state.source, affected, locations };
|
|
3478
|
+
return { bytes: (await state.finish(state.main, [])).bytes, affected, locations };
|
|
3479
|
+
}
|
|
3480
|
+
var Paragraph = class {
|
|
3481
|
+
#storedXml;
|
|
3482
|
+
#binding;
|
|
3483
|
+
#generation = 0;
|
|
3484
|
+
#runs = [];
|
|
3485
|
+
#font;
|
|
3486
|
+
get #xml() {
|
|
3487
|
+
return this.#binding?.read() ?? this.#storedXml;
|
|
3488
|
+
}
|
|
3489
|
+
set #xml(xml) {
|
|
3490
|
+
if (this.#binding) this.#binding.write(xml);
|
|
3491
|
+
else this.#storedXml = xml;
|
|
3492
|
+
}
|
|
3493
|
+
constructor(xml, binding) {
|
|
3494
|
+
if (xml.root.name.localName !== "p" || ![
|
|
3495
|
+
"http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
3496
|
+
"http://purl.oclc.org/ooxml/drawingml/main"
|
|
3497
|
+
].includes(xml.root.name.namespace))
|
|
3498
|
+
invalid6();
|
|
3499
|
+
readParagraphFormatting(xml.root);
|
|
3500
|
+
this.#storedXml = xml;
|
|
3501
|
+
this.#binding = binding;
|
|
3502
|
+
}
|
|
3503
|
+
get xml() {
|
|
3504
|
+
return this.#xml;
|
|
3505
|
+
}
|
|
3506
|
+
get parent() {
|
|
3507
|
+
this.#binding?.read();
|
|
3508
|
+
return this.#binding?.parent;
|
|
3509
|
+
}
|
|
3510
|
+
get runs() {
|
|
3511
|
+
const xml = this.#xml;
|
|
3512
|
+
const count = xml.root.children.filter(
|
|
3513
|
+
(n) => n.name.namespace === xml.root.name.namespace && n.name.localName === "r"
|
|
3514
|
+
).length;
|
|
3515
|
+
const generation = this.#generation;
|
|
3516
|
+
for (let i = this.#runs.length; i < count; i++) {
|
|
3517
|
+
this.#runs.push(
|
|
3518
|
+
new Run({
|
|
3519
|
+
parent: this,
|
|
3520
|
+
read: () => {
|
|
3521
|
+
if (generation !== this.#generation) throw new InvalidHandleError();
|
|
3522
|
+
const document = this.#xml;
|
|
3523
|
+
const node = document.root.children.filter(
|
|
3524
|
+
(n) => n.name.namespace === document.root.name.namespace && n.name.localName === "r"
|
|
3525
|
+
)[i];
|
|
3526
|
+
if (!node) throw new InvalidHandleError();
|
|
3527
|
+
return { document, node };
|
|
3528
|
+
},
|
|
3529
|
+
write: (xml2) => {
|
|
3530
|
+
this.#xml = xml2;
|
|
3531
|
+
}
|
|
3532
|
+
})
|
|
3533
|
+
);
|
|
3534
|
+
}
|
|
3535
|
+
return Object.freeze(this.#runs.slice(0, count));
|
|
3536
|
+
}
|
|
3537
|
+
add_run() {
|
|
3538
|
+
const xml = this.#xml;
|
|
3539
|
+
const end = xml.root.children.findIndex(
|
|
3540
|
+
(n) => n.name.namespace === xml.root.name.namespace && n.name.localName === "endParaRPr"
|
|
3541
|
+
);
|
|
3542
|
+
this.#xml = xml.spliceChildren(xml.root, end < 0 ? xml.root.children.length : end, 0, [
|
|
3543
|
+
`<r xmlns="${xml.root.name.namespace}"><t/></r>`
|
|
3544
|
+
]);
|
|
3545
|
+
return this.runs.at(-1);
|
|
3546
|
+
}
|
|
3547
|
+
add_line_break() {
|
|
3548
|
+
const xml = this.#xml;
|
|
3549
|
+
const end = xml.root.children.findIndex(
|
|
3550
|
+
(n) => n.name.namespace === xml.root.name.namespace && n.name.localName === "endParaRPr"
|
|
3551
|
+
);
|
|
3552
|
+
this.#xml = xml.spliceChildren(xml.root, end < 0 ? xml.root.children.length : end, 0, [
|
|
3553
|
+
`<br xmlns="${xml.root.name.namespace}"/>`
|
|
3554
|
+
]);
|
|
3555
|
+
}
|
|
3556
|
+
clear() {
|
|
3557
|
+
this.#xml = replaceParagraphContent(this.#xml, []);
|
|
3558
|
+
this.#generation++;
|
|
3559
|
+
this.#runs = [];
|
|
3560
|
+
return this;
|
|
3561
|
+
}
|
|
3562
|
+
get text() {
|
|
3563
|
+
const xml = this.#xml;
|
|
3564
|
+
return xml.root.children.filter(
|
|
3565
|
+
(n) => n.name.namespace === xml.root.name.namespace && ["r", "br", "fld"].includes(n.name.localName)
|
|
3566
|
+
).map((n) => n.name.localName === "br" ? "\v" : nodeText(xml, n)).join("");
|
|
3567
|
+
}
|
|
3568
|
+
set text(value) {
|
|
3569
|
+
if (typeof value !== "string") invalid6();
|
|
3570
|
+
const ns = this.#xml.root.name.namespace;
|
|
3571
|
+
const fragments = value.split("\n").join("\v").split("\v").flatMap((piece, index) => [
|
|
3572
|
+
...index ? [`<br xmlns="${ns}"/>`] : [],
|
|
3573
|
+
...piece ? [`<r xmlns="${ns}"><t>${escapeModelText(piece)}</t></r>`] : []
|
|
3574
|
+
]);
|
|
3575
|
+
this.#xml = replaceParagraphContent(this.#xml, fragments);
|
|
3576
|
+
this.#generation++;
|
|
3577
|
+
this.#runs = [];
|
|
3578
|
+
}
|
|
3579
|
+
get font() {
|
|
3580
|
+
let xml = this.#xml;
|
|
3581
|
+
const ns = xml.root.name.namespace;
|
|
3582
|
+
let properties = xml.root.children.find(
|
|
3583
|
+
(n) => n.name.namespace === ns && n.name.localName === "pPr"
|
|
3584
|
+
);
|
|
3585
|
+
if (!properties) {
|
|
3586
|
+
xml = xml.spliceChildren(xml.root, 0, 0, [`<pPr xmlns="${ns}"/>`]);
|
|
3587
|
+
properties = xml.root.children[0];
|
|
3588
|
+
}
|
|
3589
|
+
if (!properties.children.some((n) => n.name.namespace === ns && n.name.localName === "defRPr")) {
|
|
3590
|
+
xml = xml.merge(properties, {
|
|
3591
|
+
children: {
|
|
3592
|
+
sequence: sequence.map((localName) => ({ namespace: ns, localName })),
|
|
3593
|
+
upsert: [{ name: { namespace: ns, localName: "defRPr" }, merge: {} }]
|
|
3594
|
+
}
|
|
3595
|
+
});
|
|
3596
|
+
}
|
|
3597
|
+
this.#xml = xml;
|
|
3598
|
+
return this.#font ??= new Font({
|
|
3599
|
+
read: () => {
|
|
3600
|
+
const document = this.#xml;
|
|
3601
|
+
const node = document.root.children.find(
|
|
3602
|
+
(n) => n.name.namespace === document.root.name.namespace && n.name.localName === "pPr"
|
|
3603
|
+
)?.children.find(
|
|
3604
|
+
(n) => n.name.namespace === document.root.name.namespace && n.name.localName === "defRPr"
|
|
3605
|
+
);
|
|
3606
|
+
if (!node) throw new InvalidHandleError();
|
|
3607
|
+
return { document, node };
|
|
3608
|
+
},
|
|
3609
|
+
write: (xml2) => {
|
|
3610
|
+
this.#xml = xml2;
|
|
3611
|
+
}
|
|
3612
|
+
});
|
|
3613
|
+
}
|
|
3614
|
+
get alignment() {
|
|
3615
|
+
const value = readParagraphFormatting(this.#xml.root).alignment;
|
|
3616
|
+
if (value === null) return null;
|
|
3617
|
+
const index = paragraphAlignments.indexOf(value);
|
|
3618
|
+
if (index < 0) throw new OfficeError("invalid-xml", "Unknown paragraph alignment.", "parse");
|
|
3619
|
+
return index + 1;
|
|
3620
|
+
}
|
|
3621
|
+
set alignment(value) {
|
|
3622
|
+
this.#xml = applyParagraphFormatting(this.#xml, this.#xml.root, { alignment: value });
|
|
3623
|
+
}
|
|
3624
|
+
get level() {
|
|
3625
|
+
return readParagraphFormatting(this.#xml.root).level ?? 0;
|
|
3626
|
+
}
|
|
3627
|
+
set level(value) {
|
|
3628
|
+
this.#xml = applyParagraphFormatting(this.#xml, this.#xml.root, { level: value });
|
|
3629
|
+
}
|
|
3630
|
+
get line_spacing() {
|
|
3631
|
+
const value = readParagraphFormatting(this.#xml.root).lineSpacing;
|
|
3632
|
+
return value === null ? null : value.unit === "multiple" ? value.value : new Pt(value.value);
|
|
3633
|
+
}
|
|
3634
|
+
set line_spacing(value) {
|
|
3635
|
+
if (value !== null && typeof value !== "number" && !(value instanceof Length)) invalid6();
|
|
3636
|
+
this.#xml = applyParagraphFormatting(this.#xml, this.#xml.root, {
|
|
3637
|
+
lineSpacing: value === null ? null : typeof value === "number" ? { unit: "multiple", value } : { unit: "pt", value: value.pt }
|
|
3638
|
+
});
|
|
3639
|
+
}
|
|
3640
|
+
get space_before() {
|
|
3641
|
+
const value = readParagraphFormatting(this.#xml.root).spaceBefore;
|
|
3642
|
+
return value === null ? null : new Pt(value);
|
|
3643
|
+
}
|
|
3644
|
+
set space_before(value) {
|
|
3645
|
+
if (value !== null && !(value instanceof Length)) invalid6();
|
|
3646
|
+
this.#xml = applyParagraphFormatting(this.#xml, this.#xml.root, {
|
|
3647
|
+
spaceBefore: value === null ? null : value.pt
|
|
3648
|
+
});
|
|
3649
|
+
}
|
|
3650
|
+
get space_after() {
|
|
3651
|
+
const value = readParagraphFormatting(this.#xml.root).spaceAfter;
|
|
3652
|
+
return value === null ? null : new Pt(value);
|
|
3653
|
+
}
|
|
3654
|
+
set space_after(value) {
|
|
3655
|
+
if (value !== null && !(value instanceof Length)) invalid6();
|
|
3656
|
+
this.#xml = applyParagraphFormatting(this.#xml, this.#xml.root, {
|
|
3657
|
+
spaceAfter: value === null ? null : value.pt
|
|
3658
|
+
});
|
|
3659
|
+
}
|
|
3660
|
+
};
|
|
3661
|
+
function nodeText(document, node) {
|
|
3662
|
+
let text = "";
|
|
3663
|
+
for (const child2 of node.children.filter(
|
|
3664
|
+
(n) => n.name.namespace === node.name.namespace && n.name.localName === "t"
|
|
3665
|
+
)) {
|
|
3666
|
+
const parser = new SaxesParser2({ xmlns: false });
|
|
3667
|
+
parser.on("text", (value) => {
|
|
3668
|
+
text += value;
|
|
3669
|
+
});
|
|
3670
|
+
parser.on("cdata", (value) => {
|
|
3671
|
+
text += value;
|
|
3672
|
+
});
|
|
3673
|
+
parser.write(document.markup(child2)).close();
|
|
3674
|
+
}
|
|
3675
|
+
return text;
|
|
3676
|
+
}
|
|
3677
|
+
function escapeModelText(value) {
|
|
3678
|
+
return Array.from(value).map((c) => {
|
|
3679
|
+
const code = c.codePointAt(0);
|
|
3680
|
+
if (code < 32 && ![9, 10, 13].includes(code) || code >= 55296 && code <= 57343 || [65534, 65535].includes(code))
|
|
3681
|
+
return `_x${code.toString(16).toUpperCase().padStart(4, "0")}_`;
|
|
3682
|
+
return c === "&" ? "&" : c === "<" ? "<" : c === ">" ? ">" : c === "\r" ? " " : c;
|
|
3683
|
+
}).join("");
|
|
3684
|
+
}
|
|
3685
|
+
function replaceParagraphContent(xml, fragments) {
|
|
3686
|
+
if (protectedEquationNodes(xml.root).size)
|
|
3687
|
+
throw new OfficeError(
|
|
3688
|
+
"unsupported-edit",
|
|
3689
|
+
"Whole text replacement cannot remove equations or their fallbacks.",
|
|
3690
|
+
"validate-intent"
|
|
3691
|
+
);
|
|
3692
|
+
const ns = xml.root.name.namespace;
|
|
3693
|
+
const indexes = xml.root.children.flatMap(
|
|
3694
|
+
(n, i) => n.name.namespace === ns && ["r", "br", "fld"].includes(n.name.localName) ? [i] : []
|
|
3695
|
+
);
|
|
3696
|
+
let result = xml;
|
|
3697
|
+
for (const i of indexes.reverse()) result = result.spliceChildren(result.root, i, 1, []);
|
|
3698
|
+
if (fragments.length) {
|
|
3699
|
+
const end = result.root.children.findIndex(
|
|
3700
|
+
(n) => n.name.namespace === ns && n.name.localName === "endParaRPr"
|
|
3701
|
+
);
|
|
3702
|
+
result = result.spliceChildren(
|
|
3703
|
+
result.root,
|
|
3704
|
+
end < 0 ? result.root.children.length : end,
|
|
3705
|
+
0,
|
|
3706
|
+
fragments
|
|
3707
|
+
);
|
|
3708
|
+
}
|
|
3709
|
+
return result;
|
|
3710
|
+
}
|
|
3711
|
+
var Run = class {
|
|
3712
|
+
#binding;
|
|
3713
|
+
#font;
|
|
3714
|
+
#hyperlink;
|
|
3715
|
+
constructor(binding) {
|
|
3716
|
+
this.#binding = binding;
|
|
3717
|
+
}
|
|
3718
|
+
get parent() {
|
|
3719
|
+
this.#binding.read();
|
|
3720
|
+
return this.#binding.parent;
|
|
3721
|
+
}
|
|
3722
|
+
get text() {
|
|
3723
|
+
const { document, node } = this.#binding.read();
|
|
3724
|
+
return nodeText(document, node);
|
|
3725
|
+
}
|
|
3726
|
+
set text(value) {
|
|
3727
|
+
if (typeof value !== "string") invalid6();
|
|
3728
|
+
const { document, node } = this.#binding.read();
|
|
3729
|
+
if (protectedEquationNodes(node).size)
|
|
3730
|
+
throw new OfficeError(
|
|
3731
|
+
"unsupported-edit",
|
|
3732
|
+
"Text replacement cannot remove equations.",
|
|
3733
|
+
"validate-intent"
|
|
3734
|
+
);
|
|
3735
|
+
const texts = node.children.flatMap(
|
|
3736
|
+
(n, i) => n.name.namespace === node.name.namespace && n.name.localName === "t" ? [i] : []
|
|
3737
|
+
);
|
|
3738
|
+
if (texts.length !== 1)
|
|
3739
|
+
throw new OfficeError("invalid-xml", "A text run requires one text element.", "parse");
|
|
3740
|
+
this.#binding.write(
|
|
3741
|
+
document.spliceChildren(node, texts[0], 1, [
|
|
3742
|
+
`<t xmlns="${node.name.namespace}">${escapeModelText(value)}</t>`
|
|
3743
|
+
])
|
|
3744
|
+
);
|
|
3745
|
+
}
|
|
3746
|
+
get hyperlink() {
|
|
3747
|
+
this.#binding.read();
|
|
3748
|
+
const capability = textLinkCapabilities.get(this.#binding.parent);
|
|
3749
|
+
if (!capability) throw new PropertyAccessError("Run has no package hyperlink owner.");
|
|
3750
|
+
void this.font;
|
|
3751
|
+
return this.#hyperlink ??= capability(() => {
|
|
3752
|
+
const { document, node } = this.#binding.read();
|
|
3753
|
+
const properties = node.children.findIndex(
|
|
3754
|
+
(child2) => child2.name.namespace === node.name.namespace && child2.name.localName === "rPr"
|
|
3755
|
+
);
|
|
3756
|
+
if (properties < 0) throw new InvalidHandleError();
|
|
3757
|
+
return [document.root.children.indexOf(node), properties];
|
|
3758
|
+
});
|
|
3759
|
+
}
|
|
3760
|
+
get font() {
|
|
3761
|
+
const { document, node } = this.#binding.read();
|
|
3762
|
+
if (!node.children.some(
|
|
3763
|
+
(n) => n.name.namespace === node.name.namespace && n.name.localName === "rPr"
|
|
3764
|
+
))
|
|
3765
|
+
this.#binding.write(
|
|
3766
|
+
document.spliceChildren(node, 0, 0, [`<rPr xmlns="${node.name.namespace}"/>`])
|
|
3767
|
+
);
|
|
3768
|
+
return this.#font ??= new Font({
|
|
3769
|
+
read: () => {
|
|
3770
|
+
const { document: document2, node: node2 } = this.#binding.read();
|
|
3771
|
+
const properties = node2.children.find(
|
|
3772
|
+
(n) => n.name.namespace === node2.name.namespace && n.name.localName === "rPr"
|
|
3773
|
+
);
|
|
3774
|
+
if (!properties) throw new InvalidHandleError();
|
|
3775
|
+
return { document: document2, node: properties };
|
|
3776
|
+
},
|
|
3777
|
+
write: this.#binding.write
|
|
3778
|
+
});
|
|
3779
|
+
}
|
|
3780
|
+
};
|
|
3781
|
+
var Font = class {
|
|
3782
|
+
#binding;
|
|
3783
|
+
#color;
|
|
3784
|
+
#fill;
|
|
3785
|
+
constructor(binding) {
|
|
3786
|
+
this.#binding = binding;
|
|
3787
|
+
}
|
|
3788
|
+
get #format() {
|
|
3789
|
+
const { node } = this.#binding.read();
|
|
3790
|
+
return readRunFormatting({
|
|
3791
|
+
name: { namespace: node.name.namespace, localName: "r" },
|
|
3792
|
+
attributes: [],
|
|
3793
|
+
children: [{ ...node, name: { namespace: node.name.namespace, localName: "rPr" } }]
|
|
3794
|
+
});
|
|
3795
|
+
}
|
|
3796
|
+
#set(options) {
|
|
3797
|
+
validateTextRunOptions(options);
|
|
3798
|
+
const { document, node } = this.#binding.read();
|
|
3799
|
+
this.#binding.write(document.merge(node, runPropertiesMerge(options, node.name.namespace)));
|
|
3800
|
+
}
|
|
3801
|
+
get fill() {
|
|
3802
|
+
this.#binding.read();
|
|
3803
|
+
return this.#fill ??= new FillFormat(
|
|
3804
|
+
() => {
|
|
3805
|
+
const { document, node } = this.#binding.read();
|
|
3806
|
+
return document.subtree(node);
|
|
3807
|
+
},
|
|
3808
|
+
void 0,
|
|
3809
|
+
false,
|
|
3810
|
+
(transform) => {
|
|
3811
|
+
const { document, node } = this.#binding.read();
|
|
3812
|
+
this.#binding.write(transform(document, node));
|
|
3813
|
+
},
|
|
3814
|
+
(node) => node
|
|
3815
|
+
);
|
|
3816
|
+
}
|
|
3817
|
+
get color() {
|
|
3818
|
+
this.fill.solid();
|
|
3819
|
+
const read = () => {
|
|
3820
|
+
const { document, node } = this.#binding.read();
|
|
3821
|
+
const selected = node.children.find(
|
|
3822
|
+
(n) => n.name.namespace === node.name.namespace && n.name.localName === "solidFill"
|
|
3823
|
+
);
|
|
3824
|
+
if (!selected) throw new InvalidHandleError();
|
|
3825
|
+
return document.subtree(selected);
|
|
3826
|
+
};
|
|
3827
|
+
return this.#color ??= new ColorFormat(read(), {
|
|
3828
|
+
read,
|
|
3829
|
+
write: (xml) => {
|
|
3830
|
+
const { document, node } = this.#binding.read();
|
|
3831
|
+
const index = node.children.findIndex(
|
|
3832
|
+
(n) => n.name.namespace === node.name.namespace && n.name.localName === "solidFill"
|
|
3833
|
+
);
|
|
3834
|
+
if (index < 0) throw new InvalidHandleError();
|
|
3835
|
+
this.#binding.write(document.spliceChildren(node, index, 1, [xml.markup(xml.root, true)]));
|
|
3836
|
+
}
|
|
3837
|
+
});
|
|
3838
|
+
}
|
|
3839
|
+
get bold() {
|
|
3840
|
+
return this.#format.bold;
|
|
3841
|
+
}
|
|
3842
|
+
set bold(value) {
|
|
3843
|
+
this.#set({ bold: value });
|
|
3844
|
+
}
|
|
3845
|
+
get language_id() {
|
|
3846
|
+
const value = this.#format.language;
|
|
3847
|
+
return value === null ? MSO_LANGUAGE_ID.NONE : MSO_LANGUAGE_ID.from_xml(value);
|
|
3848
|
+
}
|
|
3849
|
+
set language_id(value) {
|
|
3850
|
+
this.#set({
|
|
3851
|
+
language: value === null || value === MSO_LANGUAGE_ID.NONE ? null : MSO_LANGUAGE_ID.to_xml(value)
|
|
3852
|
+
});
|
|
3853
|
+
}
|
|
3854
|
+
get italic() {
|
|
3855
|
+
return this.#format.italic;
|
|
3856
|
+
}
|
|
3857
|
+
set italic(value) {
|
|
3858
|
+
this.#set({ italic: value });
|
|
3859
|
+
}
|
|
3860
|
+
get strike() {
|
|
3861
|
+
const value = this.#format.strike;
|
|
3862
|
+
if (value === null || value === "none" || value === "single" || value === "double") return value;
|
|
3863
|
+
throw new OfficeError("invalid-xml", "Unknown text strikeout.", "parse");
|
|
3864
|
+
}
|
|
3865
|
+
set strike(value) {
|
|
3866
|
+
this.#set({ strike: value });
|
|
3867
|
+
}
|
|
3868
|
+
get baseline() {
|
|
3869
|
+
return this.#format.baseline;
|
|
3870
|
+
}
|
|
3871
|
+
set baseline(value) {
|
|
3872
|
+
this.#set({ baseline: value });
|
|
3873
|
+
}
|
|
3874
|
+
get name() {
|
|
3875
|
+
return this.#format.font;
|
|
3876
|
+
}
|
|
3877
|
+
set name(value) {
|
|
3878
|
+
this.#set({ font: value });
|
|
3879
|
+
}
|
|
3880
|
+
get size() {
|
|
3881
|
+
const value = this.#format.size;
|
|
3882
|
+
return value === null ? null : new Pt(value);
|
|
3883
|
+
}
|
|
3884
|
+
set size(value) {
|
|
3885
|
+
if (value !== null && !(value instanceof Length)) invalid6();
|
|
3886
|
+
this.#set({ size: value === null ? null : value.pt });
|
|
3887
|
+
}
|
|
3888
|
+
get underline() {
|
|
3889
|
+
const value = this.#format.underline;
|
|
3890
|
+
if (value === null) return null;
|
|
3891
|
+
if (value === "none") return false;
|
|
3892
|
+
if (value === "sng") return true;
|
|
3893
|
+
const index = textUnderlineStyles.indexOf(value);
|
|
3894
|
+
if (index < 0) throw new OfficeError("invalid-xml", "Unknown text underline.", "parse");
|
|
3895
|
+
return index;
|
|
3896
|
+
}
|
|
3897
|
+
set underline(value) {
|
|
3898
|
+
this.#set({ underline: value });
|
|
3899
|
+
}
|
|
3900
|
+
};
|
|
3901
|
+
|
|
3902
|
+
export {
|
|
3903
|
+
textLinkCapabilities,
|
|
3904
|
+
Adjustment,
|
|
3905
|
+
AdjustmentCollection,
|
|
3906
|
+
PP_PARAGRAPH_ALIGNMENT,
|
|
3907
|
+
paragraphAlignments,
|
|
3908
|
+
paragraphNumberingSchemes,
|
|
3909
|
+
validateTextParagraphOptions,
|
|
3910
|
+
paragraphPropertiesMerge,
|
|
3911
|
+
applyParagraphFormatting,
|
|
3912
|
+
readParagraphFormatting,
|
|
3913
|
+
readTextParagraphs,
|
|
3914
|
+
mutateTextParagraphs,
|
|
3915
|
+
Paragraph,
|
|
3916
|
+
Run,
|
|
3917
|
+
Font,
|
|
3918
|
+
validateTextFitOptions,
|
|
3919
|
+
fitFrameXml,
|
|
3920
|
+
fitTextFrames,
|
|
3921
|
+
MSO_AUTO_SIZE,
|
|
3922
|
+
MSO_VERTICAL_ANCHOR,
|
|
3923
|
+
textVerticalModes,
|
|
3924
|
+
validateTextFrameOptions,
|
|
3925
|
+
readFrameFormatting,
|
|
3926
|
+
applyFrameFormatting,
|
|
3927
|
+
readTextFrames,
|
|
3928
|
+
mutateTextFrames,
|
|
3929
|
+
TextFrame,
|
|
3930
|
+
MSO_SHAPE_TYPE,
|
|
3931
|
+
PP_PLACEHOLDER_TYPE,
|
|
3932
|
+
MSO_FILL_TYPE,
|
|
3933
|
+
MSO_FILL,
|
|
3934
|
+
MSO_LINE_DASH_STYLE,
|
|
3935
|
+
MSO_LINE,
|
|
3936
|
+
MSO_PATTERN_TYPE,
|
|
3937
|
+
MSO_PATTERN,
|
|
3938
|
+
validateShapeOptions,
|
|
3939
|
+
readShape,
|
|
3940
|
+
applyShapeUpdate,
|
|
3941
|
+
createShapeXml,
|
|
3942
|
+
Shape,
|
|
3943
|
+
ShapeColorFormat,
|
|
3944
|
+
FillFormat,
|
|
3945
|
+
GradientStop,
|
|
3946
|
+
GradientStops,
|
|
3947
|
+
ShadowFormat,
|
|
3948
|
+
LineFormat
|
|
3949
|
+
};
|