@ignix-social/editor 0.1.0
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/LICENSE +190 -0
- package/NOTICE +54 -0
- package/README.md +23 -0
- package/bin/ignix-editor.mjs +8 -0
- package/package.json +53 -0
- package/patches/index.mjs +53 -0
- package/scripts/build-ffmpeg-macos.sh +35 -0
- package/scripts/build-whisper-macos.sh +21 -0
- package/scripts/vendor.mjs +41 -0
- package/skills/ignix-editor/SKILL.md +132 -0
- package/src/audio.mjs +31 -0
- package/src/binaries.json +46 -0
- package/src/binaries.mjs +83 -0
- package/src/cli.mjs +254 -0
- package/src/prepare.mjs +74 -0
- package/src/runtime/ignix-frame.js +92 -0
- package/src/transcribe.mjs +71 -0
- package/src/validate.mjs +71 -0
- package/templates/blank/index.html +41 -0
- package/vendor/hyperframes/README.md +181 -0
- package/vendor/hyperframes/UPSTREAM.json +12 -0
- package/vendor/hyperframes/bin/hyperframes-localize-fonts.mjs +12 -0
- package/vendor/hyperframes/bin/hyperframes.mjs +11 -0
- package/vendor/hyperframes/dist/add-LR3ZR2A5.js +79 -0
- package/vendor/hyperframes/dist/agentPromptGenerator-VIIPZCJ3.js +143 -0
- package/vendor/hyperframes/dist/animatedGifPrep-P2T6YM7Z.js +34 -0
- package/vendor/hyperframes/dist/asset-BE2DOV72.js +26 -0
- package/vendor/hyperframes/dist/assetCataloger-VBLPHX24.js +340 -0
- package/vendor/hyperframes/dist/auth-RCQB2ZT7.js +60 -0
- package/vendor/hyperframes/dist/autoUpdate-RJAX3DAZ.js +268 -0
- package/vendor/hyperframes/dist/backgroundChecks-H2LCUIMJ.js +61 -0
- package/vendor/hyperframes/dist/backgroundChecksWorker.js +26 -0
- package/vendor/hyperframes/dist/batchRender-FT7AP7XH.js +355 -0
- package/vendor/hyperframes/dist/beat-analyzer.global.js +338 -0
- package/vendor/hyperframes/dist/beats-Y2EOP72P.js +309 -0
- package/vendor/hyperframes/dist/benchmark-MZ7GY3JW.js +231 -0
- package/vendor/hyperframes/dist/browser-HUTAMRQE.js +237 -0
- package/vendor/hyperframes/dist/bundleWithLocalizedFonts-5QOPOB5D.js +52 -0
- package/vendor/hyperframes/dist/capture-RLZA6EMR.js +4079 -0
- package/vendor/hyperframes/dist/capture-SZZ4IYJK.js +290 -0
- package/vendor/hyperframes/dist/captureFile-LYOJOUIE.js +15 -0
- package/vendor/hyperframes/dist/captureTimeout-PA4FYWT5.js +27 -0
- package/vendor/hyperframes/dist/catalog-KYU55EWR.js +1001 -0
- package/vendor/hyperframes/dist/check-TCG4PXLR.js +1697 -0
- package/vendor/hyperframes/dist/checkBrowser-RPMO4OW5.js +1032 -0
- package/vendor/hyperframes/dist/chunk-2EAXUCCE.js +88 -0
- package/vendor/hyperframes/dist/chunk-2EGFTPWD.js +1077 -0
- package/vendor/hyperframes/dist/chunk-2PSPARWP.js +6058 -0
- package/vendor/hyperframes/dist/chunk-2YN64IN5.js +5747 -0
- package/vendor/hyperframes/dist/chunk-3GXQPCJC.js +682 -0
- package/vendor/hyperframes/dist/chunk-3ZP5DXE7.js +15 -0
- package/vendor/hyperframes/dist/chunk-4NWOGZZS.js +1990 -0
- package/vendor/hyperframes/dist/chunk-4PFZPP2N.js +587 -0
- package/vendor/hyperframes/dist/chunk-4THIAPBL.js +128 -0
- package/vendor/hyperframes/dist/chunk-4YYJOFKS.js +28 -0
- package/vendor/hyperframes/dist/chunk-54HJ63Q2.js +29 -0
- package/vendor/hyperframes/dist/chunk-5ETJX6WM.js +89 -0
- package/vendor/hyperframes/dist/chunk-5IAKAQA7.js +389 -0
- package/vendor/hyperframes/dist/chunk-5Z63TBTX.js +37 -0
- package/vendor/hyperframes/dist/chunk-6BEFEWFB.js +25 -0
- package/vendor/hyperframes/dist/chunk-6CSYCFQV.js +68 -0
- package/vendor/hyperframes/dist/chunk-6CTIGJY7.js +154 -0
- package/vendor/hyperframes/dist/chunk-7HG4BFIN.js +93 -0
- package/vendor/hyperframes/dist/chunk-7JZ4FXP2.js +118 -0
- package/vendor/hyperframes/dist/chunk-A2Z4Z4VL.js +2961 -0
- package/vendor/hyperframes/dist/chunk-AMKC3AXA.js +25 -0
- package/vendor/hyperframes/dist/chunk-AVUUN2XD.js +4847 -0
- package/vendor/hyperframes/dist/chunk-AWDFDFI3.js +46 -0
- package/vendor/hyperframes/dist/chunk-AWNBM3MZ.js +94 -0
- package/vendor/hyperframes/dist/chunk-BXCMXMJQ.js +73 -0
- package/vendor/hyperframes/dist/chunk-BZ56MTDX.js +6 -0
- package/vendor/hyperframes/dist/chunk-CFKU7HTK.js +171 -0
- package/vendor/hyperframes/dist/chunk-CWPVM2QV.js +308 -0
- package/vendor/hyperframes/dist/chunk-DPVXBVLL.js +31292 -0
- package/vendor/hyperframes/dist/chunk-DQBY7FRR.js +397 -0
- package/vendor/hyperframes/dist/chunk-E6RPWJVC.js +213 -0
- package/vendor/hyperframes/dist/chunk-EISRN4E6.js +294 -0
- package/vendor/hyperframes/dist/chunk-EOVYQ3IG.js +143 -0
- package/vendor/hyperframes/dist/chunk-F3WZGU7C.js +479 -0
- package/vendor/hyperframes/dist/chunk-FCSIGXXP.js +366 -0
- package/vendor/hyperframes/dist/chunk-FI4I7CME.js +56 -0
- package/vendor/hyperframes/dist/chunk-FLWXXDNS.js +15 -0
- package/vendor/hyperframes/dist/chunk-GK4AIFIH.js +11171 -0
- package/vendor/hyperframes/dist/chunk-GMECXFAN.js +57 -0
- package/vendor/hyperframes/dist/chunk-GULOKZLI.js +155 -0
- package/vendor/hyperframes/dist/chunk-H4YZZ2VQ.js +68 -0
- package/vendor/hyperframes/dist/chunk-H6QMKUYA.js +477 -0
- package/vendor/hyperframes/dist/chunk-HBBJFK6I.js +273 -0
- package/vendor/hyperframes/dist/chunk-HRUGC23L.js +212 -0
- package/vendor/hyperframes/dist/chunk-HVW7ABXD.js +19 -0
- package/vendor/hyperframes/dist/chunk-HW6OYASV.js +344 -0
- package/vendor/hyperframes/dist/chunk-HWKCIWQT.js +3578 -0
- package/vendor/hyperframes/dist/chunk-I465DBM6.js +1214 -0
- package/vendor/hyperframes/dist/chunk-IGLEPPTN.js +24 -0
- package/vendor/hyperframes/dist/chunk-IGNAAHS3.js +433 -0
- package/vendor/hyperframes/dist/chunk-IHFUKJOR.js +85 -0
- package/vendor/hyperframes/dist/chunk-IQ3OUQ5Z.js +213 -0
- package/vendor/hyperframes/dist/chunk-ISN5GRYI.js +20 -0
- package/vendor/hyperframes/dist/chunk-IUZFXWSV.js +446 -0
- package/vendor/hyperframes/dist/chunk-JH556Q42.js +647 -0
- package/vendor/hyperframes/dist/chunk-JTHMTOMQ.js +601 -0
- package/vendor/hyperframes/dist/chunk-K2EQN4VU.js +405 -0
- package/vendor/hyperframes/dist/chunk-K2FTXJYH.js +16044 -0
- package/vendor/hyperframes/dist/chunk-K4WIOZFP.js +32 -0
- package/vendor/hyperframes/dist/chunk-K4WKGXRC.js +18 -0
- package/vendor/hyperframes/dist/chunk-KBJUXVOJ.js +172 -0
- package/vendor/hyperframes/dist/chunk-KC5XXX3X.js +590 -0
- package/vendor/hyperframes/dist/chunk-KNU5COPB.js +29 -0
- package/vendor/hyperframes/dist/chunk-KZI44OPA.js +185 -0
- package/vendor/hyperframes/dist/chunk-L3YOGIPG.js +48 -0
- package/vendor/hyperframes/dist/chunk-LAOCA3MQ.js +189 -0
- package/vendor/hyperframes/dist/chunk-LCSMOLGX.js +312 -0
- package/vendor/hyperframes/dist/chunk-LFGJWOVA.js +61 -0
- package/vendor/hyperframes/dist/chunk-LHSR3M4M.js +498 -0
- package/vendor/hyperframes/dist/chunk-LYNI3FOL.js +123 -0
- package/vendor/hyperframes/dist/chunk-M2WBOQ2Q.js +54 -0
- package/vendor/hyperframes/dist/chunk-MRF4AMKD.js +104 -0
- package/vendor/hyperframes/dist/chunk-MWB3ZIFM.js +852 -0
- package/vendor/hyperframes/dist/chunk-NGKM64BP.js +39 -0
- package/vendor/hyperframes/dist/chunk-NXMYHJAL.js +43 -0
- package/vendor/hyperframes/dist/chunk-OAF4XJOW.js +192 -0
- package/vendor/hyperframes/dist/chunk-OFQWTKPW.js +117 -0
- package/vendor/hyperframes/dist/chunk-P6LJ4Y32.js +4662 -0
- package/vendor/hyperframes/dist/chunk-PBN6GBJE.js +108 -0
- package/vendor/hyperframes/dist/chunk-PDAMK4Q5.js +28 -0
- package/vendor/hyperframes/dist/chunk-PFCFR3KZ.js +20 -0
- package/vendor/hyperframes/dist/chunk-PJ3HDUCY.js +108 -0
- package/vendor/hyperframes/dist/chunk-PMRBLBUP.js +152 -0
- package/vendor/hyperframes/dist/chunk-PPQUYWTW.js +240 -0
- package/vendor/hyperframes/dist/chunk-Q5X2B5WT.js +29 -0
- package/vendor/hyperframes/dist/chunk-Q7IU7MOR.js +351 -0
- package/vendor/hyperframes/dist/chunk-QC4FJVLM.js +371 -0
- package/vendor/hyperframes/dist/chunk-QNYYOUU3.js +1318 -0
- package/vendor/hyperframes/dist/chunk-RDNNAKEP.js +161 -0
- package/vendor/hyperframes/dist/chunk-RMHUQGRK.js +657 -0
- package/vendor/hyperframes/dist/chunk-RQVDTPGD.js +6 -0
- package/vendor/hyperframes/dist/chunk-RVCWIIZ7.js +68 -0
- package/vendor/hyperframes/dist/chunk-S3D6GE5W.js +72 -0
- package/vendor/hyperframes/dist/chunk-S3S4TGEH.js +424 -0
- package/vendor/hyperframes/dist/chunk-S7NPLFWV.js +11395 -0
- package/vendor/hyperframes/dist/chunk-SHB5VDMH.js +51 -0
- package/vendor/hyperframes/dist/chunk-TCLGPL65.js +860 -0
- package/vendor/hyperframes/dist/chunk-THXFSPLV.js +40 -0
- package/vendor/hyperframes/dist/chunk-TJSTGSAW.js +354 -0
- package/vendor/hyperframes/dist/chunk-TQFG7HTI.js +1024 -0
- package/vendor/hyperframes/dist/chunk-TVCRUG2S.js +265 -0
- package/vendor/hyperframes/dist/chunk-TWWSYAKJ.js +24 -0
- package/vendor/hyperframes/dist/chunk-U7CZBDMV.js +27 -0
- package/vendor/hyperframes/dist/chunk-UEZXMWG3.js +139 -0
- package/vendor/hyperframes/dist/chunk-UYEZTK4U.js +61 -0
- package/vendor/hyperframes/dist/chunk-VC76R6W2.js +27 -0
- package/vendor/hyperframes/dist/chunk-VFCKXTBB.js +159 -0
- package/vendor/hyperframes/dist/chunk-VWG7OQKU.js +22 -0
- package/vendor/hyperframes/dist/chunk-VXVRPIJA.js +105 -0
- package/vendor/hyperframes/dist/chunk-WBLXWOYK.js +15 -0
- package/vendor/hyperframes/dist/chunk-WERLJGIC.js +20 -0
- package/vendor/hyperframes/dist/chunk-WMQNIQDJ.js +2057 -0
- package/vendor/hyperframes/dist/chunk-WPHMNO44.js +4528 -0
- package/vendor/hyperframes/dist/chunk-X5HWXQPU.js +113 -0
- package/vendor/hyperframes/dist/chunk-X7MTZ4T2.js +6 -0
- package/vendor/hyperframes/dist/chunk-XH4DSOS5.js +59 -0
- package/vendor/hyperframes/dist/chunk-XS4EJSKU.js +23 -0
- package/vendor/hyperframes/dist/chunk-XT5P4QMO.js +181 -0
- package/vendor/hyperframes/dist/chunk-XT7X6QCP.js +6 -0
- package/vendor/hyperframes/dist/chunk-XUHOIDKG.js +6 -0
- package/vendor/hyperframes/dist/chunk-XUXGIA7H.js +485 -0
- package/vendor/hyperframes/dist/chunk-XZABUQTX.js +113 -0
- package/vendor/hyperframes/dist/chunk-Y6W4DVPS.js +356 -0
- package/vendor/hyperframes/dist/chunk-YEIFI443.js +44 -0
- package/vendor/hyperframes/dist/chunk-YQZNILVH.js +375 -0
- package/vendor/hyperframes/dist/chunk-Z27A7NUB.js +65 -0
- package/vendor/hyperframes/dist/chunk-Z6B37SNM.js +3081 -0
- package/vendor/hyperframes/dist/chunk-ZJUKFZ2P.js +10954 -0
- package/vendor/hyperframes/dist/chunk-ZKDMAOFU.js +32 -0
- package/vendor/hyperframes/dist/chunk-ZMXUQLI2.js +17219 -0
- package/vendor/hyperframes/dist/chunk-ZTZ7NCJT.js +58 -0
- package/vendor/hyperframes/dist/chunk-ZTZA4UWZ.js +108 -0
- package/vendor/hyperframes/dist/clean-W57E5YQ3.js +293 -0
- package/vendor/hyperframes/dist/cli.js +495 -0
- package/vendor/hyperframes/dist/cloud-FFTJGZ24.js +70 -0
- package/vendor/hyperframes/dist/cloudrun-AJUTHUEA.js +763 -0
- package/vendor/hyperframes/dist/colors-HKWSZCGK.js +15 -0
- package/vendor/hyperframes/dist/commands/contrast-audit.browser.js +459 -0
- package/vendor/hyperframes/dist/commands/layout-audit.browser.js +2102 -0
- package/vendor/hyperframes/dist/commands/motion-sample.browser.js +74 -0
- package/vendor/hyperframes/dist/commands/motion-signature.browser.js +374 -0
- package/vendor/hyperframes/dist/compare-AYCTT55F.js +421 -0
- package/vendor/hyperframes/dist/compiler-QO36EXLS.js +121 -0
- package/vendor/hyperframes/dist/component-VFFR2O7T.js +176 -0
- package/vendor/hyperframes/dist/compositions-QTVN3U2A.js +228 -0
- package/vendor/hyperframes/dist/contactSheet-27SRU7A4.js +22 -0
- package/vendor/hyperframes/dist/delete-ZAKYCB7I.js +114 -0
- package/vendor/hyperframes/dist/deploy-MX76RZ36.js +101 -0
- package/vendor/hyperframes/dist/destroy-H2TZBYHH.js +42 -0
- package/vendor/hyperframes/dist/deterministicFonts-HAEMV4TM.js +50 -0
- package/vendor/hyperframes/dist/dist-EWXJGN63.js +129 -0
- package/vendor/hyperframes/dist/dist-FNNGCKFS.js +29 -0
- package/vendor/hyperframes/dist/dist-S3PJNPXQ.js +392 -0
- package/vendor/hyperframes/dist/docker/Dockerfile.render +65 -0
- package/vendor/hyperframes/dist/docs/compositions.md +67 -0
- package/vendor/hyperframes/dist/docs/data-attributes.md +27 -0
- package/vendor/hyperframes/dist/docs/examples.md +19 -0
- package/vendor/hyperframes/dist/docs/gsap.md +26 -0
- package/vendor/hyperframes/dist/docs/rendering.md +35 -0
- package/vendor/hyperframes/dist/docs/troubleshooting.md +29 -0
- package/vendor/hyperframes/dist/docs-QAPJEGLS.js +131 -0
- package/vendor/hyperframes/dist/doctor-AI7C3FON.js +67 -0
- package/vendor/hyperframes/dist/dom-IROKGVJI.js +14 -0
- package/vendor/hyperframes/dist/dotEnv-AECLXQSO.js +14 -0
- package/vendor/hyperframes/dist/events-7LALYNKZ.js +92 -0
- package/vendor/hyperframes/dist/events-FQY3HGKZ.js +88 -0
- package/vendor/hyperframes/dist/feedback-WCMDMSTK.js +472 -0
- package/vendor/hyperframes/dist/ffmpeg-QIUFEFTY.js +35 -0
- package/vendor/hyperframes/dist/figma-64WY462P.js +63 -0
- package/vendor/hyperframes/dist/fontData.generated-NXAOI4GH.js +13 -0
- package/vendor/hyperframes/dist/fontLocalizeCli.js +132 -0
- package/vendor/hyperframes/dist/get-FPOMJMZB.js +103 -0
- package/vendor/hyperframes/dist/gpuPolicy-2ZUZE5D6.js +38 -0
- package/vendor/hyperframes/dist/grade-compare-E2CKPST4.js +647 -0
- package/vendor/hyperframes/dist/gsapParser-DIYYX6JT.js +2846 -0
- package/vendor/hyperframes/dist/gsapParserAcorn-E3GEIRZB.js +28 -0
- package/vendor/hyperframes/dist/help-YRQIDDML.js +197 -0
- package/vendor/hyperframes/dist/history-PP5NDRV3.js +571 -0
- package/vendor/hyperframes/dist/hyperframe-runtime.js +1081 -0
- package/vendor/hyperframes/dist/hyperframe.manifest.json +22 -0
- package/vendor/hyperframes/dist/hyperframe.runtime.iife.js +1081 -0
- package/vendor/hyperframes/dist/hyperframes-player.global.js +474 -0
- package/vendor/hyperframes/dist/hyperframes-slideshow.global.js +149 -0
- package/vendor/hyperframes/dist/info-SEX3B7JL.js +153 -0
- package/vendor/hyperframes/dist/init-U3AKHO5B.js +1147 -0
- package/vendor/hyperframes/dist/inspect-Q3K6EDEK.js +97 -0
- package/vendor/hyperframes/dist/installer-K6O5WF44.js +37 -0
- package/vendor/hyperframes/dist/keyframes-DC64JCI3.js +2602 -0
- package/vendor/hyperframes/dist/lambda-D7UMN4DJ.js +451 -0
- package/vendor/hyperframes/dist/layout-XSPPDHOO.js +86 -0
- package/vendor/hyperframes/dist/lib-TPG2ZMAX.js +128 -0
- package/vendor/hyperframes/dist/lint-7DQZE7L3.js +164 -0
- package/vendor/hyperframes/dist/lintProject-OHBBM3DJ.js +27 -0
- package/vendor/hyperframes/dist/list-4K5MVDQX.js +162 -0
- package/vendor/hyperframes/dist/login-NTX4OWXL.js +377 -0
- package/vendor/hyperframes/dist/logout-Q654A3SI.js +100 -0
- package/vendor/hyperframes/dist/manager-67P2XFXQ.js +34 -0
- package/vendor/hyperframes/dist/manager-CT3D67CG.js +38 -0
- package/vendor/hyperframes/dist/manager-GFN75DM4.js +30 -0
- package/vendor/hyperframes/dist/media-treatment-5FYAOPNL.js +972 -0
- package/vendor/hyperframes/dist/media-use-4XXGABIL.js +113 -0
- package/vendor/hyperframes/dist/models-C4E4IWJD.js +137 -0
- package/vendor/hyperframes/dist/motionShot-S4MIGMT5.js +614 -0
- package/vendor/hyperframes/dist/normalize-O76AC4HE.js +333 -0
- package/vendor/hyperframes/dist/normalize-audio-CSFTXLXD.js +276 -0
- package/vendor/hyperframes/dist/open-2ZD6BHZG.js +115 -0
- package/vendor/hyperframes/dist/pipeline-TNGWUZQC.js +54 -0
- package/vendor/hyperframes/dist/play-CTMUXX6E.js +349 -0
- package/vendor/hyperframes/dist/policies-FSDZVS2E.js +292 -0
- package/vendor/hyperframes/dist/preflight-SMNV6RW2.js +45 -0
- package/vendor/hyperframes/dist/present-WQVHV5CR.js +350 -0
- package/vendor/hyperframes/dist/preview-JOJXTH75.js +1820 -0
- package/vendor/hyperframes/dist/producer-ECLEN5RP.js +13 -0
- package/vendor/hyperframes/dist/progress-FBIEEB7Y.js +73 -0
- package/vendor/hyperframes/dist/projectConfig-HYJMJ5BY.js +56 -0
- package/vendor/hyperframes/dist/publication-HQ5Y3KBM.js +29 -0
- package/vendor/hyperframes/dist/publish-VHDYQASC.js +430 -0
- package/vendor/hyperframes/dist/refresh-K24ETHMA.js +53 -0
- package/vendor/hyperframes/dist/remove-background-W2YX2NVH.js +253 -0
- package/vendor/hyperframes/dist/render-AO5VX3YI.js +177 -0
- package/vendor/hyperframes/dist/render-LNO62LEL.js +2367 -0
- package/vendor/hyperframes/dist/render-TTQI7TGN.js +796 -0
- package/vendor/hyperframes/dist/render-batch-YH7CTWNY.js +284 -0
- package/vendor/hyperframes/dist/renderCancellation-JPIHE47X.js +35 -0
- package/vendor/hyperframes/dist/renderSetupWorker.js +79 -0
- package/vendor/hyperframes/dist/resolver-IZ647GBZ.js +38 -0
- package/vendor/hyperframes/dist/runtimeVersion.js +18 -0
- package/vendor/hyperframes/dist/screenshotCapture-ECBTLCU6.js +179 -0
- package/vendor/hyperframes/dist/shaderTransitionWorker.js +44 -0
- package/vendor/hyperframes/dist/sherpa-KKLNW6U2.js +314 -0
- package/vendor/hyperframes/dist/sherpaWorker.js +77 -0
- package/vendor/hyperframes/dist/sites-TNVKZS73.js +52 -0
- package/vendor/hyperframes/dist/skill-ZHVLH7KX.js +15 -0
- package/vendor/hyperframes/dist/skills/hyperframes/SKILL.md +152 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/brief-contract.md +108 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/brief-format.md +72 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/capability-menu.md +47 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/frame-worker-core.md +80 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/intent-interview.md +73 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/pitch-round.md +40 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/plugin-installation.md +43 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/production-loop.md +26 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/review-loop.md +37 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/route-briefs.md +11 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/routes/embedded-captions.md +11 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/routes/faceless-explainer.md +12 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/routes/general-video.md +12 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/routes/motion-graphics.md +11 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/routes/music-to-video.md +12 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/routes/pr-to-video.md +28 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/routes/product-launch-video.md +13 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/routes/remotion-to-hyperframes.md +9 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/routes/slideshow.md +11 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/routes/talking-head-recut.md +11 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/script-format.md +52 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/skill-lifecycle.md +35 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/storyboard-format.md +99 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/subagent-dispatch.md +35 -0
- package/vendor/hyperframes/dist/skills/hyperframes/references/workflow-catalog.md +10 -0
- package/vendor/hyperframes/dist/skills/hyperframes/scripts/lib/frame-packets-core.mjs +194 -0
- package/vendor/hyperframes/dist/skills/hyperframes/scripts/plugin-cli.mjs +88 -0
- package/vendor/hyperframes/dist/skills/hyperframes/scripts/plugin-cli.test.mjs +117 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/SKILL.md +189 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/references/beats.md +19 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/references/cloud.md +163 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/references/cloudrun.md +62 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/references/compare-and-batch.md +105 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/references/doctor-browser.md +57 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/references/init-and-scaffold.md +74 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/references/lambda.md +185 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/references/lint-validate-inspect.md +132 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/references/preview-render.md +193 -0
- package/vendor/hyperframes/dist/skills/hyperframes-cli/references/upgrade-info-misc.md +134 -0
- package/vendor/hyperframes/dist/skills/media-use/SKILL.md +100 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/CREDITS.md +35 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/chime.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/click-soft.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/click.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/error.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/glitch-1.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/glitch-2.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/glitch-3.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/impact-bass-1.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/impact-bass-2.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/key-press.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/manifest.json +97 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/notification.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/ping.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/pop.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/riser.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/sparkle.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/typing.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/whoosh-cinematic.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/whoosh-short.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/assets/sfx/whoosh.mp3 +0 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/references/bgm.md +76 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/references/captions/authoring.md +163 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/references/captions/motion.md +87 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/references/captions/transcript-handling.md +97 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/references/remove-background.md +143 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/references/requirements.md +29 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/references/sfx.md +42 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/references/transcribe.md +52 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/references/tts-to-captions.md +35 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/references/tts.md +260 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/audio.mjs +311 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/audio.test.mjs +159 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/gemini-pipeline.test.mjs +131 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/heygen-tts.mjs +122 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/heygen-tts.test.mjs +38 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/heygen-voice.mjs +98 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/heygen-voice.test.mjs +233 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/audio-meta.mjs +39 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/audio-meta.test.mjs +136 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/bgm-volume.mjs +4 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/bgm.mjs +257 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/bgm.test.mjs +74 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/concurrency.mjs +14 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/concurrency.test.mjs +41 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/gemini-auth.mjs +43 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/gemini-auth.py +52 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/gemini-auth.test.mjs +86 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/gemini-auth_test.py +90 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/gemini-tts.mjs +122 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/gemini-tts.test.mjs +243 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/heygen.mjs +197 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/heygen.test.mjs +185 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/media-record.mjs +114 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/media-record.test.mjs +205 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/python.mjs +77 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/python.test.mjs +136 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/sfx.mjs +165 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/sfx.test.mjs +121 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/tts.mjs +389 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/tts.spawn.test.mjs +158 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lib/tts.test.mjs +230 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/lyria-recipe.py +136 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/wait-bgm.mjs +175 -0
- package/vendor/hyperframes/dist/skills/media-use/audio/scripts/wait-bgm.test.mjs +108 -0
- package/vendor/hyperframes/dist/skills/media-use/luts/README.md +28 -0
- package/vendor/hyperframes/dist/skills/media-use/luts/index.json +57 -0
- package/vendor/hyperframes/dist/skills/media-use/references/audio.md +20 -0
- package/vendor/hyperframes/dist/skills/media-use/references/grading.md +160 -0
- package/vendor/hyperframes/dist/skills/media-use/references/media-treatment-recipes.md +929 -0
- package/vendor/hyperframes/dist/skills/media-use/references/media-treatments.md +202 -0
- package/vendor/hyperframes/dist/skills/media-use/references/memory.md +37 -0
- package/vendor/hyperframes/dist/skills/media-use/references/meta.md +61 -0
- package/vendor/hyperframes/dist/skills/media-use/references/operations.md +327 -0
- package/vendor/hyperframes/dist/skills/media-use/references/resolve.md +150 -0
- package/vendor/hyperframes/dist/skills/media-use/references/setup-providers.md +80 -0
- package/vendor/hyperframes/dist/skills/media-use/references/telemetry-dashboard.md +49 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/audio-duck.mjs +113 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/compatibility.test.mjs +96 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/dither.mjs +328 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/dither.test.mjs +176 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/eval.mjs +369 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/adopt.mjs +128 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/adopt.test.mjs +95 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/bgm-provider.mjs +20 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/brand-provider.mjs +59 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/bundled-sfx-provider.mjs +119 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/bundled-sfx-provider.test.mjs +139 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/cache.mjs +148 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/candidates.mjs +91 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/candidates.test.mjs +155 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/codex-provider.mjs +161 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/codex-provider.test.mjs +34 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/config-lock.d.mts +3 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/config-lock.mjs +45 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/config-lock.test.mjs +79 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/coverage.test.mjs +136 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/cube-build.mjs +181 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/cube-build.test.mjs +80 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/cube-validate.mjs +198 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/cube-validate.test.mjs +125 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/cutlist.mjs +184 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/cutlist.test.mjs +162 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/duck.mjs +95 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/duck.test.mjs +153 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/error-diffusion.mjs +230 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/error-diffusion.test.mjs +102 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/ff-binaries.mjs +37 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/freeze.mjs +72 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/freeze.test.mjs +138 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/grade-analyzer.mjs +265 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/grade-analyzer.test.mjs +285 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/heygen-cli.mjs +191 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/heygen-cli.test.mjs +301 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/heygen-search.mjs +45 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/heygen-search.test.mjs +49 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/heygen-video-provider.mjs +138 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/heygen-video-provider.test.mjs +435 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/image-provider.mjs +44 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/index-gen.mjs +63 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/local-media-search.mjs +32 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/local-models.mjs +318 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/local-models.test.mjs +220 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/local-run.mjs +78 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/local-run.test.mjs +121 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/logo-provider.mjs +244 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/logo-provider.test.mjs +298 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/ltx-video-provider.mjs +94 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/ltx-video-provider.test.mjs +316 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/lut-preset-provider.mjs +271 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/lut-preset-provider.test.mjs +199 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/manifest.d.mts +19 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/manifest.mjs +279 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/manifest.test.mjs +397 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/match.mjs +47 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/media-fetch.mjs +85 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/media-fetch.test.mjs +197 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/media-home.mjs +20 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/media-home.test.mjs +61 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/media-search.d.mts +9 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/media-search.mjs +107 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/mflux-provider.mjs +128 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/mflux-provider.test.mjs +174 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/misses.mjs +49 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/misses.test.mjs +89 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/npx-sync.mjs +31 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/npx-sync.test.mjs +50 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/parakeet-words.mjs +27 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/parakeet-words.test.mjs +44 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/prefs-store.mjs +180 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/prefs-store.test.mjs +189 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/probe.mjs +41 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/probe.test.mjs +148 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/providers.mjs +5 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/recipe-store.mjs +367 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/recipe-store.test.mjs +367 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/registry.mjs +212 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/registry.test.mjs +262 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/search.mjs +24 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/search.test.mjs +32 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/sfx-provider.mjs +23 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/specs.mjs +132 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/specs.test.mjs +157 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/stats.mjs +117 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/stats.test.mjs +165 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/svg-sanitize.mjs +21 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/telemetry.mjs +210 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/telemetry.test.mjs +437 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/test-home.test.mjs +10 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/transcriptCutFade.mjs +21 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/transcriptCutFade.test.mjs +33 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/tts-local-provider.mjs +94 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/tts-local-provider.test.mjs +72 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/usage.mjs +57 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/usage.test.mjs +54 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/voice-provider.mjs +57 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/voice-provider.test.mjs +46 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/lib/words.mjs +18 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/prefs.mjs +70 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/recipe.mjs +103 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/resolve-plugin.test.mjs +62 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/resolve.mjs +1369 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/transcribe.mjs +194 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/transcribe.test.mjs +112 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/transcript-cut.mjs +270 -0
- package/vendor/hyperframes/dist/skills/media-use/scripts/transcript-cut.test.mjs +117 -0
- package/vendor/hyperframes/dist/skills-MJ2J4GEM.js +808 -0
- package/vendor/hyperframes/dist/skillsUpdateCheck-TKTYQN5R.js +26 -0
- package/vendor/hyperframes/dist/slideshow-EJ4IMY6P.js +24 -0
- package/vendor/hyperframes/dist/snapshot-KIVDUUMN.js +875 -0
- package/vendor/hyperframes/dist/src-6YQBJGWR.js +202 -0
- package/vendor/hyperframes/dist/src-PVYUYV3M.js +471 -0
- package/vendor/hyperframes/dist/state-KAXGHF77.js +26 -0
- package/vendor/hyperframes/dist/staticProjectServer-7EU666GS.js +49 -0
- package/vendor/hyperframes/dist/status-YM52BQ6S.js +311 -0
- package/vendor/hyperframes/dist/studio/assets/hyperframes-player-Cp8e_Zst.js +473 -0
- package/vendor/hyperframes/dist/studio/assets/index-BX3KHhGX.js +71 -0
- package/vendor/hyperframes/dist/studio/assets/index-CASEBNy2.js +1 -0
- package/vendor/hyperframes/dist/studio/assets/index-D11atkBt.css +1 -0
- package/vendor/hyperframes/dist/studio/assets/index-DMTt9nTf.js +531 -0
- package/vendor/hyperframes/dist/studio/assets/index-oE1pOdAy.js +399 -0
- package/vendor/hyperframes/dist/studio/chunk-5VSXRGIX.js +948 -0
- package/vendor/hyperframes/dist/studio/chunk-5VSXRGIX.js.map +1 -0
- package/vendor/hyperframes/dist/studio/chunk-7UQWVN52.js +938 -0
- package/vendor/hyperframes/dist/studio/chunk-7UQWVN52.js.map +1 -0
- package/vendor/hyperframes/dist/studio/chunk-EEXSYY5F.js +190 -0
- package/vendor/hyperframes/dist/studio/chunk-EEXSYY5F.js.map +1 -0
- package/vendor/hyperframes/dist/studio/chunk-FOEID72M.js +1441 -0
- package/vendor/hyperframes/dist/studio/chunk-FOEID72M.js.map +1 -0
- package/vendor/hyperframes/dist/studio/chunk-PZ5AY32C.js +10 -0
- package/vendor/hyperframes/dist/studio/chunk-PZ5AY32C.js.map +1 -0
- package/vendor/hyperframes/dist/studio/chunk-TDWGXBUT.js +1103 -0
- package/vendor/hyperframes/dist/studio/chunk-TDWGXBUT.js.map +1 -0
- package/vendor/hyperframes/dist/studio/domEditingLayers-IEVLO54Z.js +47 -0
- package/vendor/hyperframes/dist/studio/domEditingLayers-IEVLO54Z.js.map +1 -0
- package/vendor/hyperframes/dist/studio/favicon.svg +14 -0
- package/vendor/hyperframes/dist/studio/icons/timeline/audio.svg +7 -0
- package/vendor/hyperframes/dist/studio/icons/timeline/captions.svg +5 -0
- package/vendor/hyperframes/dist/studio/icons/timeline/composition.svg +12 -0
- package/vendor/hyperframes/dist/studio/icons/timeline/image.svg +18 -0
- package/vendor/hyperframes/dist/studio/icons/timeline/music.svg +10 -0
- package/vendor/hyperframes/dist/studio/icons/timeline/text.svg +3 -0
- package/vendor/hyperframes/dist/studio/index.css +165 -0
- package/vendor/hyperframes/dist/studio/index.css.map +1 -0
- package/vendor/hyperframes/dist/studio/index.d.ts +4296 -0
- package/vendor/hyperframes/dist/studio/index.html +23 -0
- package/vendor/hyperframes/dist/studio/index.js +99693 -0
- package/vendor/hyperframes/dist/studio/index.js.map +1 -0
- package/vendor/hyperframes/dist/studio/player.d.ts +30 -0
- package/vendor/hyperframes/dist/studio/player.js +10 -0
- package/vendor/hyperframes/dist/studio/player.js.map +1 -0
- package/vendor/hyperframes/dist/studio/styles/tailwind-preset.d.ts +39 -0
- package/vendor/hyperframes/dist/studio/styles/tailwind-preset.js +50 -0
- package/vendor/hyperframes/dist/studio/styles/tailwind-preset.js.map +1 -0
- package/vendor/hyperframes/dist/studio/styles.css +1 -0
- package/vendor/hyperframes/dist/studio/ui.d.ts +296 -0
- package/vendor/hyperframes/dist/studio/ui.js +66 -0
- package/vendor/hyperframes/dist/studio/ui.js.map +1 -0
- package/vendor/hyperframes/dist/studio-api-PNQZRPX5.js +136 -0
- package/vendor/hyperframes/dist/studioSelectionClient-IUUPKUHZ.js +25 -0
- package/vendor/hyperframes/dist/studioServer-UWRBPIOJ.js +1457 -0
- package/vendor/hyperframes/dist/synthesize-K62TIZWI.js +182 -0
- package/vendor/hyperframes/dist/system-EZYZNUFD.js +44 -0
- package/vendor/hyperframes/dist/telemetry-2YC4SGQU.js +144 -0
- package/vendor/hyperframes/dist/telemetry-QMYM4WME.js +95 -0
- package/vendor/hyperframes/dist/templates/_shared/AGENTS.md +107 -0
- package/vendor/hyperframes/dist/templates/_shared/CLAUDE.md +107 -0
- package/vendor/hyperframes/dist/templates/blank/index.html +55 -0
- package/vendor/hyperframes/dist/templates/from-file/index.html +75 -0
- package/vendor/hyperframes/dist/templates/warm-grain/compositions/captions.html +154 -0
- package/vendor/hyperframes/dist/templates/warm-grain/compositions/graphics.html +162 -0
- package/vendor/hyperframes/dist/templates/warm-grain/compositions/intro.html +87 -0
- package/vendor/hyperframes/dist/templates/warm-grain/index.html +264 -0
- package/vendor/hyperframes/dist/templates/warm-grain/registry-item.json +34 -0
- package/vendor/hyperframes/dist/timeline-77Z3BBQM.js +1377 -0
- package/vendor/hyperframes/dist/tokens-OBGTYE4Z.js +92 -0
- package/vendor/hyperframes/dist/transcribe-7NVFHCGA.js +387 -0
- package/vendor/hyperframes/dist/transcribe-BNSJRR4M.js +62 -0
- package/vendor/hyperframes/dist/tts-P3LIPIL5.js +234 -0
- package/vendor/hyperframes/dist/updateCheck-UDWIJ4ZQ.js +39 -0
- package/vendor/hyperframes/dist/upgrade-CT3CPO3E.js +231 -0
- package/vendor/hyperframes/dist/urlDownloader-H6WRI2UE.js +39 -0
- package/vendor/hyperframes/dist/usage-EC3KFUIJ.js +2139 -0
- package/vendor/hyperframes/dist/validate-65QDZJWZ.js +70 -0
- package/vendor/hyperframes/dist/video-FGSGKRSV.js +261 -0
- package/vendor/hyperframes/dist/workspaceBuildCheck-TOLGAI4T.js +133 -0
- package/vendor/hyperframes/package.json +80 -0
|
@@ -0,0 +1,4847 @@
|
|
|
1
|
+
import { createRequire as __hf_createRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath as __hf_fileURLToPath } from "node:url";
|
|
3
|
+
import { dirname as __hf_dirname } from "node:path";
|
|
4
|
+
var require = __hf_createRequire(import.meta.url);
|
|
5
|
+
var __filename = __hf_fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __hf_dirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
require_lib,
|
|
9
|
+
require_main
|
|
10
|
+
} from "./chunk-DPVXBVLL.js";
|
|
11
|
+
import {
|
|
12
|
+
ancestor,
|
|
13
|
+
full,
|
|
14
|
+
parse,
|
|
15
|
+
simple
|
|
16
|
+
} from "./chunk-2PSPARWP.js";
|
|
17
|
+
import {
|
|
18
|
+
__toESM
|
|
19
|
+
} from "./chunk-M2WBOQ2Q.js";
|
|
20
|
+
|
|
21
|
+
// ../parsers/dist/index.js
|
|
22
|
+
var recast = __toESM(require_main(), 1);
|
|
23
|
+
var import_parser = __toESM(require_lib(), 1);
|
|
24
|
+
|
|
25
|
+
// ../../node_modules/.bun/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
26
|
+
var comma = ",".charCodeAt(0);
|
|
27
|
+
var semicolon = ";".charCodeAt(0);
|
|
28
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
29
|
+
var intToChar = new Uint8Array(64);
|
|
30
|
+
var charToInt = new Uint8Array(128);
|
|
31
|
+
for (let i = 0; i < chars.length; i++) {
|
|
32
|
+
const c = chars.charCodeAt(i);
|
|
33
|
+
intToChar[i] = c;
|
|
34
|
+
charToInt[c] = i;
|
|
35
|
+
}
|
|
36
|
+
function encodeInteger(builder, num, relative) {
|
|
37
|
+
let delta = num - relative;
|
|
38
|
+
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
39
|
+
do {
|
|
40
|
+
let clamped = delta & 31;
|
|
41
|
+
delta >>>= 5;
|
|
42
|
+
if (delta > 0) clamped |= 32;
|
|
43
|
+
builder.write(intToChar[clamped]);
|
|
44
|
+
} while (delta > 0);
|
|
45
|
+
return num;
|
|
46
|
+
}
|
|
47
|
+
var bufLength = 1024 * 16;
|
|
48
|
+
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
|
|
49
|
+
decode(buf) {
|
|
50
|
+
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
51
|
+
return out.toString();
|
|
52
|
+
}
|
|
53
|
+
} : {
|
|
54
|
+
decode(buf) {
|
|
55
|
+
let out = "";
|
|
56
|
+
for (let i = 0; i < buf.length; i++) {
|
|
57
|
+
out += String.fromCharCode(buf[i]);
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var StringWriter = class {
|
|
63
|
+
constructor() {
|
|
64
|
+
this.pos = 0;
|
|
65
|
+
this.out = "";
|
|
66
|
+
this.buffer = new Uint8Array(bufLength);
|
|
67
|
+
}
|
|
68
|
+
write(v) {
|
|
69
|
+
const { buffer } = this;
|
|
70
|
+
buffer[this.pos++] = v;
|
|
71
|
+
if (this.pos === bufLength) {
|
|
72
|
+
this.out += td.decode(buffer);
|
|
73
|
+
this.pos = 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
flush() {
|
|
77
|
+
const { buffer, out, pos } = this;
|
|
78
|
+
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
function encode(decoded) {
|
|
82
|
+
const writer = new StringWriter();
|
|
83
|
+
let sourcesIndex = 0;
|
|
84
|
+
let sourceLine = 0;
|
|
85
|
+
let sourceColumn = 0;
|
|
86
|
+
let namesIndex = 0;
|
|
87
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
88
|
+
const line = decoded[i];
|
|
89
|
+
if (i > 0) writer.write(semicolon);
|
|
90
|
+
if (line.length === 0) continue;
|
|
91
|
+
let genColumn = 0;
|
|
92
|
+
for (let j = 0; j < line.length; j++) {
|
|
93
|
+
const segment = line[j];
|
|
94
|
+
if (j > 0) writer.write(comma);
|
|
95
|
+
genColumn = encodeInteger(writer, segment[0], genColumn);
|
|
96
|
+
if (segment.length === 1) continue;
|
|
97
|
+
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
|
98
|
+
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
|
99
|
+
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
|
100
|
+
if (segment.length === 4) continue;
|
|
101
|
+
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return writer.flush();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ../../node_modules/.bun/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs
|
|
108
|
+
var BitSet = class _BitSet {
|
|
109
|
+
constructor(arg) {
|
|
110
|
+
this.bits = arg instanceof _BitSet ? arg.bits.slice() : [];
|
|
111
|
+
}
|
|
112
|
+
add(n2) {
|
|
113
|
+
this.bits[n2 >> 5] |= 1 << (n2 & 31);
|
|
114
|
+
}
|
|
115
|
+
has(n2) {
|
|
116
|
+
return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var Chunk = class _Chunk {
|
|
120
|
+
constructor(start, end, content) {
|
|
121
|
+
this.start = start;
|
|
122
|
+
this.end = end;
|
|
123
|
+
this.original = content;
|
|
124
|
+
this.intro = "";
|
|
125
|
+
this.outro = "";
|
|
126
|
+
this.content = content;
|
|
127
|
+
this.storeName = false;
|
|
128
|
+
this.edited = false;
|
|
129
|
+
{
|
|
130
|
+
this.previous = null;
|
|
131
|
+
this.next = null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
appendLeft(content) {
|
|
135
|
+
this.outro += content;
|
|
136
|
+
}
|
|
137
|
+
appendRight(content) {
|
|
138
|
+
this.intro = this.intro + content;
|
|
139
|
+
}
|
|
140
|
+
clone() {
|
|
141
|
+
const chunk = new _Chunk(this.start, this.end, this.original);
|
|
142
|
+
chunk.intro = this.intro;
|
|
143
|
+
chunk.outro = this.outro;
|
|
144
|
+
chunk.content = this.content;
|
|
145
|
+
chunk.storeName = this.storeName;
|
|
146
|
+
chunk.edited = this.edited;
|
|
147
|
+
return chunk;
|
|
148
|
+
}
|
|
149
|
+
contains(index) {
|
|
150
|
+
return this.start < index && index < this.end;
|
|
151
|
+
}
|
|
152
|
+
eachNext(fn) {
|
|
153
|
+
let chunk = this;
|
|
154
|
+
while (chunk) {
|
|
155
|
+
fn(chunk);
|
|
156
|
+
chunk = chunk.next;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
eachPrevious(fn) {
|
|
160
|
+
let chunk = this;
|
|
161
|
+
while (chunk) {
|
|
162
|
+
fn(chunk);
|
|
163
|
+
chunk = chunk.previous;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
edit(content, storeName, contentOnly) {
|
|
167
|
+
this.content = content;
|
|
168
|
+
if (!contentOnly) {
|
|
169
|
+
this.intro = "";
|
|
170
|
+
this.outro = "";
|
|
171
|
+
}
|
|
172
|
+
this.storeName = storeName;
|
|
173
|
+
this.edited = true;
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
prependLeft(content) {
|
|
177
|
+
this.outro = content + this.outro;
|
|
178
|
+
}
|
|
179
|
+
prependRight(content) {
|
|
180
|
+
this.intro = content + this.intro;
|
|
181
|
+
}
|
|
182
|
+
reset() {
|
|
183
|
+
this.intro = "";
|
|
184
|
+
this.outro = "";
|
|
185
|
+
if (this.edited) {
|
|
186
|
+
this.content = this.original;
|
|
187
|
+
this.storeName = false;
|
|
188
|
+
this.edited = false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
split(index) {
|
|
192
|
+
const sliceIndex = index - this.start;
|
|
193
|
+
const originalBefore = this.original.slice(0, sliceIndex);
|
|
194
|
+
const originalAfter = this.original.slice(sliceIndex);
|
|
195
|
+
this.original = originalBefore;
|
|
196
|
+
const newChunk = new _Chunk(index, this.end, originalAfter);
|
|
197
|
+
newChunk.outro = this.outro;
|
|
198
|
+
this.outro = "";
|
|
199
|
+
this.end = index;
|
|
200
|
+
if (this.edited) {
|
|
201
|
+
newChunk.edit("", false);
|
|
202
|
+
this.content = "";
|
|
203
|
+
} else {
|
|
204
|
+
this.content = originalBefore;
|
|
205
|
+
}
|
|
206
|
+
newChunk.next = this.next;
|
|
207
|
+
if (newChunk.next) newChunk.next.previous = newChunk;
|
|
208
|
+
newChunk.previous = this;
|
|
209
|
+
this.next = newChunk;
|
|
210
|
+
return newChunk;
|
|
211
|
+
}
|
|
212
|
+
toString() {
|
|
213
|
+
return this.intro + this.content + this.outro;
|
|
214
|
+
}
|
|
215
|
+
trimEnd(rx) {
|
|
216
|
+
this.outro = this.outro.replace(rx, "");
|
|
217
|
+
if (this.outro.length) return true;
|
|
218
|
+
const trimmed = this.content.replace(rx, "");
|
|
219
|
+
if (trimmed.length) {
|
|
220
|
+
if (trimmed !== this.content) {
|
|
221
|
+
this.split(this.start + trimmed.length).edit("", void 0, true);
|
|
222
|
+
if (this.edited) {
|
|
223
|
+
this.edit(trimmed, this.storeName, true);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
} else {
|
|
228
|
+
this.edit("", void 0, true);
|
|
229
|
+
this.intro = this.intro.replace(rx, "");
|
|
230
|
+
if (this.intro.length) return true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
trimStart(rx) {
|
|
234
|
+
this.intro = this.intro.replace(rx, "");
|
|
235
|
+
if (this.intro.length) return true;
|
|
236
|
+
const trimmed = this.content.replace(rx, "");
|
|
237
|
+
if (trimmed.length) {
|
|
238
|
+
if (trimmed !== this.content) {
|
|
239
|
+
const newChunk = this.split(this.end - trimmed.length);
|
|
240
|
+
if (this.edited) {
|
|
241
|
+
newChunk.edit(trimmed, this.storeName, true);
|
|
242
|
+
}
|
|
243
|
+
this.edit("", void 0, true);
|
|
244
|
+
}
|
|
245
|
+
return true;
|
|
246
|
+
} else {
|
|
247
|
+
this.edit("", void 0, true);
|
|
248
|
+
this.outro = this.outro.replace(rx, "");
|
|
249
|
+
if (this.outro.length) return true;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
function getBtoa() {
|
|
254
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
|
|
255
|
+
return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
256
|
+
} else if (typeof Buffer === "function") {
|
|
257
|
+
return (str) => Buffer.from(str, "utf-8").toString("base64");
|
|
258
|
+
} else {
|
|
259
|
+
return () => {
|
|
260
|
+
throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
var btoa = /* @__PURE__ */ getBtoa();
|
|
265
|
+
var SourceMap = class {
|
|
266
|
+
constructor(properties) {
|
|
267
|
+
this.version = 3;
|
|
268
|
+
this.file = properties.file;
|
|
269
|
+
this.sources = properties.sources;
|
|
270
|
+
this.sourcesContent = properties.sourcesContent;
|
|
271
|
+
this.names = properties.names;
|
|
272
|
+
this.mappings = encode(properties.mappings);
|
|
273
|
+
if (typeof properties.x_google_ignoreList !== "undefined") {
|
|
274
|
+
this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
275
|
+
}
|
|
276
|
+
if (typeof properties.debugId !== "undefined") {
|
|
277
|
+
this.debugId = properties.debugId;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
toString() {
|
|
281
|
+
return JSON.stringify(this);
|
|
282
|
+
}
|
|
283
|
+
toUrl() {
|
|
284
|
+
return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
function guessIndent(code) {
|
|
288
|
+
const lines = code.split("\n");
|
|
289
|
+
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
290
|
+
const spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
291
|
+
if (tabbed.length === 0 && spaced.length === 0) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
if (tabbed.length >= spaced.length) {
|
|
295
|
+
return " ";
|
|
296
|
+
}
|
|
297
|
+
const min = spaced.reduce((previous, current) => {
|
|
298
|
+
const numSpaces = /^ +/.exec(current)[0].length;
|
|
299
|
+
return Math.min(numSpaces, previous);
|
|
300
|
+
}, Infinity);
|
|
301
|
+
return new Array(min + 1).join(" ");
|
|
302
|
+
}
|
|
303
|
+
function getRelativePath(from, to) {
|
|
304
|
+
const fromParts = from.split(/[/\\]/);
|
|
305
|
+
const toParts = to.split(/[/\\]/);
|
|
306
|
+
fromParts.pop();
|
|
307
|
+
while (fromParts[0] === toParts[0]) {
|
|
308
|
+
fromParts.shift();
|
|
309
|
+
toParts.shift();
|
|
310
|
+
}
|
|
311
|
+
if (fromParts.length) {
|
|
312
|
+
let i = fromParts.length;
|
|
313
|
+
while (i--) fromParts[i] = "..";
|
|
314
|
+
}
|
|
315
|
+
return fromParts.concat(toParts).join("/");
|
|
316
|
+
}
|
|
317
|
+
var toString = Object.prototype.toString;
|
|
318
|
+
function isObject(thing) {
|
|
319
|
+
return toString.call(thing) === "[object Object]";
|
|
320
|
+
}
|
|
321
|
+
function getLocator(source) {
|
|
322
|
+
const originalLines = source.split("\n");
|
|
323
|
+
const lineOffsets = [];
|
|
324
|
+
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
325
|
+
lineOffsets.push(pos);
|
|
326
|
+
pos += originalLines[i].length + 1;
|
|
327
|
+
}
|
|
328
|
+
return function locate(index) {
|
|
329
|
+
let i = 0;
|
|
330
|
+
let j = lineOffsets.length;
|
|
331
|
+
while (i < j) {
|
|
332
|
+
const m = i + j >> 1;
|
|
333
|
+
if (index < lineOffsets[m]) {
|
|
334
|
+
j = m;
|
|
335
|
+
} else {
|
|
336
|
+
i = m + 1;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
const line = i - 1;
|
|
340
|
+
const column = index - lineOffsets[line];
|
|
341
|
+
return { line, column };
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
var wordRegex = /\w/;
|
|
345
|
+
var Mappings = class {
|
|
346
|
+
constructor(hires) {
|
|
347
|
+
this.hires = hires;
|
|
348
|
+
this.generatedCodeLine = 0;
|
|
349
|
+
this.generatedCodeColumn = 0;
|
|
350
|
+
this.raw = [];
|
|
351
|
+
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
352
|
+
this.pending = null;
|
|
353
|
+
}
|
|
354
|
+
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
355
|
+
if (content.length) {
|
|
356
|
+
const contentLengthMinusOne = content.length - 1;
|
|
357
|
+
let contentLineEnd = content.indexOf("\n", 0);
|
|
358
|
+
let previousContentLineEnd = -1;
|
|
359
|
+
while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
|
|
360
|
+
const segment2 = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
361
|
+
if (nameIndex >= 0) {
|
|
362
|
+
segment2.push(nameIndex);
|
|
363
|
+
}
|
|
364
|
+
this.rawSegments.push(segment2);
|
|
365
|
+
this.generatedCodeLine += 1;
|
|
366
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
367
|
+
this.generatedCodeColumn = 0;
|
|
368
|
+
previousContentLineEnd = contentLineEnd;
|
|
369
|
+
contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
|
|
370
|
+
}
|
|
371
|
+
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
372
|
+
if (nameIndex >= 0) {
|
|
373
|
+
segment.push(nameIndex);
|
|
374
|
+
}
|
|
375
|
+
this.rawSegments.push(segment);
|
|
376
|
+
this.advance(content.slice(previousContentLineEnd + 1));
|
|
377
|
+
} else if (this.pending) {
|
|
378
|
+
this.rawSegments.push(this.pending);
|
|
379
|
+
this.advance(content);
|
|
380
|
+
}
|
|
381
|
+
this.pending = null;
|
|
382
|
+
}
|
|
383
|
+
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
384
|
+
let originalCharIndex = chunk.start;
|
|
385
|
+
let first = true;
|
|
386
|
+
let charInHiresBoundary = false;
|
|
387
|
+
while (originalCharIndex < chunk.end) {
|
|
388
|
+
if (original[originalCharIndex] === "\n") {
|
|
389
|
+
loc.line += 1;
|
|
390
|
+
loc.column = 0;
|
|
391
|
+
this.generatedCodeLine += 1;
|
|
392
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
393
|
+
this.generatedCodeColumn = 0;
|
|
394
|
+
first = true;
|
|
395
|
+
charInHiresBoundary = false;
|
|
396
|
+
} else {
|
|
397
|
+
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
398
|
+
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
399
|
+
if (this.hires === "boundary") {
|
|
400
|
+
if (wordRegex.test(original[originalCharIndex])) {
|
|
401
|
+
if (!charInHiresBoundary) {
|
|
402
|
+
this.rawSegments.push(segment);
|
|
403
|
+
charInHiresBoundary = true;
|
|
404
|
+
}
|
|
405
|
+
} else {
|
|
406
|
+
this.rawSegments.push(segment);
|
|
407
|
+
charInHiresBoundary = false;
|
|
408
|
+
}
|
|
409
|
+
} else {
|
|
410
|
+
this.rawSegments.push(segment);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
loc.column += 1;
|
|
414
|
+
this.generatedCodeColumn += 1;
|
|
415
|
+
first = false;
|
|
416
|
+
}
|
|
417
|
+
originalCharIndex += 1;
|
|
418
|
+
}
|
|
419
|
+
this.pending = null;
|
|
420
|
+
}
|
|
421
|
+
advance(str) {
|
|
422
|
+
if (!str) return;
|
|
423
|
+
const lines = str.split("\n");
|
|
424
|
+
if (lines.length > 1) {
|
|
425
|
+
for (let i = 0; i < lines.length - 1; i++) {
|
|
426
|
+
this.generatedCodeLine++;
|
|
427
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
428
|
+
}
|
|
429
|
+
this.generatedCodeColumn = 0;
|
|
430
|
+
}
|
|
431
|
+
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
var n = "\n";
|
|
435
|
+
var warned = {
|
|
436
|
+
insertLeft: false,
|
|
437
|
+
insertRight: false,
|
|
438
|
+
storeName: false
|
|
439
|
+
};
|
|
440
|
+
var MagicString = class _MagicString {
|
|
441
|
+
constructor(string, options = {}) {
|
|
442
|
+
const chunk = new Chunk(0, string.length, string);
|
|
443
|
+
Object.defineProperties(this, {
|
|
444
|
+
original: { writable: true, value: string },
|
|
445
|
+
outro: { writable: true, value: "" },
|
|
446
|
+
intro: { writable: true, value: "" },
|
|
447
|
+
firstChunk: { writable: true, value: chunk },
|
|
448
|
+
lastChunk: { writable: true, value: chunk },
|
|
449
|
+
lastSearchedChunk: { writable: true, value: chunk },
|
|
450
|
+
byStart: { writable: true, value: {} },
|
|
451
|
+
byEnd: { writable: true, value: {} },
|
|
452
|
+
filename: { writable: true, value: options.filename },
|
|
453
|
+
indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
|
|
454
|
+
sourcemapLocations: { writable: true, value: new BitSet() },
|
|
455
|
+
storedNames: { writable: true, value: {} },
|
|
456
|
+
indentStr: { writable: true, value: void 0 },
|
|
457
|
+
ignoreList: { writable: true, value: options.ignoreList },
|
|
458
|
+
offset: { writable: true, value: options.offset || 0 }
|
|
459
|
+
});
|
|
460
|
+
this.byStart[0] = chunk;
|
|
461
|
+
this.byEnd[string.length] = chunk;
|
|
462
|
+
}
|
|
463
|
+
addSourcemapLocation(char) {
|
|
464
|
+
this.sourcemapLocations.add(char);
|
|
465
|
+
}
|
|
466
|
+
append(content) {
|
|
467
|
+
if (typeof content !== "string") throw new TypeError("outro content must be a string");
|
|
468
|
+
this.outro += content;
|
|
469
|
+
return this;
|
|
470
|
+
}
|
|
471
|
+
appendLeft(index, content) {
|
|
472
|
+
index = index + this.offset;
|
|
473
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
474
|
+
this._split(index);
|
|
475
|
+
const chunk = this.byEnd[index];
|
|
476
|
+
if (chunk) {
|
|
477
|
+
chunk.appendLeft(content);
|
|
478
|
+
} else {
|
|
479
|
+
this.intro += content;
|
|
480
|
+
}
|
|
481
|
+
return this;
|
|
482
|
+
}
|
|
483
|
+
appendRight(index, content) {
|
|
484
|
+
index = index + this.offset;
|
|
485
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
486
|
+
this._split(index);
|
|
487
|
+
const chunk = this.byStart[index];
|
|
488
|
+
if (chunk) {
|
|
489
|
+
chunk.appendRight(content);
|
|
490
|
+
} else {
|
|
491
|
+
this.outro += content;
|
|
492
|
+
}
|
|
493
|
+
return this;
|
|
494
|
+
}
|
|
495
|
+
clone() {
|
|
496
|
+
const cloned = new _MagicString(this.original, { filename: this.filename, offset: this.offset });
|
|
497
|
+
let originalChunk = this.firstChunk;
|
|
498
|
+
let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
|
|
499
|
+
while (originalChunk) {
|
|
500
|
+
cloned.byStart[clonedChunk.start] = clonedChunk;
|
|
501
|
+
cloned.byEnd[clonedChunk.end] = clonedChunk;
|
|
502
|
+
const nextOriginalChunk = originalChunk.next;
|
|
503
|
+
const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
|
|
504
|
+
if (nextClonedChunk) {
|
|
505
|
+
clonedChunk.next = nextClonedChunk;
|
|
506
|
+
nextClonedChunk.previous = clonedChunk;
|
|
507
|
+
clonedChunk = nextClonedChunk;
|
|
508
|
+
}
|
|
509
|
+
originalChunk = nextOriginalChunk;
|
|
510
|
+
}
|
|
511
|
+
cloned.lastChunk = clonedChunk;
|
|
512
|
+
if (this.indentExclusionRanges) {
|
|
513
|
+
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
514
|
+
}
|
|
515
|
+
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
516
|
+
cloned.intro = this.intro;
|
|
517
|
+
cloned.outro = this.outro;
|
|
518
|
+
return cloned;
|
|
519
|
+
}
|
|
520
|
+
generateDecodedMap(options) {
|
|
521
|
+
options = options || {};
|
|
522
|
+
const sourceIndex = 0;
|
|
523
|
+
const names = Object.keys(this.storedNames);
|
|
524
|
+
const mappings = new Mappings(options.hires);
|
|
525
|
+
const locate = getLocator(this.original);
|
|
526
|
+
if (this.intro) {
|
|
527
|
+
mappings.advance(this.intro);
|
|
528
|
+
}
|
|
529
|
+
this.firstChunk.eachNext((chunk) => {
|
|
530
|
+
const loc = locate(chunk.start);
|
|
531
|
+
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
532
|
+
if (chunk.edited) {
|
|
533
|
+
mappings.addEdit(
|
|
534
|
+
sourceIndex,
|
|
535
|
+
chunk.content,
|
|
536
|
+
loc,
|
|
537
|
+
chunk.storeName ? names.indexOf(chunk.original) : -1
|
|
538
|
+
);
|
|
539
|
+
} else {
|
|
540
|
+
mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
541
|
+
}
|
|
542
|
+
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
543
|
+
});
|
|
544
|
+
if (this.outro) {
|
|
545
|
+
mappings.advance(this.outro);
|
|
546
|
+
}
|
|
547
|
+
return {
|
|
548
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
549
|
+
sources: [
|
|
550
|
+
options.source ? getRelativePath(options.file || "", options.source) : options.file || ""
|
|
551
|
+
],
|
|
552
|
+
sourcesContent: options.includeContent ? [this.original] : void 0,
|
|
553
|
+
names,
|
|
554
|
+
mappings: mappings.raw,
|
|
555
|
+
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
generateMap(options) {
|
|
559
|
+
return new SourceMap(this.generateDecodedMap(options));
|
|
560
|
+
}
|
|
561
|
+
_ensureindentStr() {
|
|
562
|
+
if (this.indentStr === void 0) {
|
|
563
|
+
this.indentStr = guessIndent(this.original);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
_getRawIndentString() {
|
|
567
|
+
this._ensureindentStr();
|
|
568
|
+
return this.indentStr;
|
|
569
|
+
}
|
|
570
|
+
getIndentString() {
|
|
571
|
+
this._ensureindentStr();
|
|
572
|
+
return this.indentStr === null ? " " : this.indentStr;
|
|
573
|
+
}
|
|
574
|
+
indent(indentStr, options) {
|
|
575
|
+
const pattern = /^[^\r\n]/gm;
|
|
576
|
+
if (isObject(indentStr)) {
|
|
577
|
+
options = indentStr;
|
|
578
|
+
indentStr = void 0;
|
|
579
|
+
}
|
|
580
|
+
if (indentStr === void 0) {
|
|
581
|
+
this._ensureindentStr();
|
|
582
|
+
indentStr = this.indentStr || " ";
|
|
583
|
+
}
|
|
584
|
+
if (indentStr === "") return this;
|
|
585
|
+
options = options || {};
|
|
586
|
+
const isExcluded = {};
|
|
587
|
+
if (options.exclude) {
|
|
588
|
+
const exclusions = typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude;
|
|
589
|
+
exclusions.forEach((exclusion) => {
|
|
590
|
+
for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
|
|
591
|
+
isExcluded[i] = true;
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
596
|
+
const replacer = (match) => {
|
|
597
|
+
if (shouldIndentNextCharacter) return `${indentStr}${match}`;
|
|
598
|
+
shouldIndentNextCharacter = true;
|
|
599
|
+
return match;
|
|
600
|
+
};
|
|
601
|
+
this.intro = this.intro.replace(pattern, replacer);
|
|
602
|
+
let charIndex = 0;
|
|
603
|
+
let chunk = this.firstChunk;
|
|
604
|
+
while (chunk) {
|
|
605
|
+
const end = chunk.end;
|
|
606
|
+
if (chunk.edited) {
|
|
607
|
+
if (!isExcluded[charIndex]) {
|
|
608
|
+
chunk.content = chunk.content.replace(pattern, replacer);
|
|
609
|
+
if (chunk.content.length) {
|
|
610
|
+
shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
} else {
|
|
614
|
+
charIndex = chunk.start;
|
|
615
|
+
while (charIndex < end) {
|
|
616
|
+
if (!isExcluded[charIndex]) {
|
|
617
|
+
const char = this.original[charIndex];
|
|
618
|
+
if (char === "\n") {
|
|
619
|
+
shouldIndentNextCharacter = true;
|
|
620
|
+
} else if (char !== "\r" && shouldIndentNextCharacter) {
|
|
621
|
+
shouldIndentNextCharacter = false;
|
|
622
|
+
if (charIndex === chunk.start) {
|
|
623
|
+
chunk.prependRight(indentStr);
|
|
624
|
+
} else {
|
|
625
|
+
this._splitChunk(chunk, charIndex);
|
|
626
|
+
chunk = chunk.next;
|
|
627
|
+
chunk.prependRight(indentStr);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
charIndex += 1;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
charIndex = chunk.end;
|
|
635
|
+
chunk = chunk.next;
|
|
636
|
+
}
|
|
637
|
+
this.outro = this.outro.replace(pattern, replacer);
|
|
638
|
+
return this;
|
|
639
|
+
}
|
|
640
|
+
insert() {
|
|
641
|
+
throw new Error(
|
|
642
|
+
"magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
insertLeft(index, content) {
|
|
646
|
+
if (!warned.insertLeft) {
|
|
647
|
+
console.warn(
|
|
648
|
+
"magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
|
|
649
|
+
);
|
|
650
|
+
warned.insertLeft = true;
|
|
651
|
+
}
|
|
652
|
+
return this.appendLeft(index, content);
|
|
653
|
+
}
|
|
654
|
+
insertRight(index, content) {
|
|
655
|
+
if (!warned.insertRight) {
|
|
656
|
+
console.warn(
|
|
657
|
+
"magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
|
|
658
|
+
);
|
|
659
|
+
warned.insertRight = true;
|
|
660
|
+
}
|
|
661
|
+
return this.prependRight(index, content);
|
|
662
|
+
}
|
|
663
|
+
move(start, end, index) {
|
|
664
|
+
start = start + this.offset;
|
|
665
|
+
end = end + this.offset;
|
|
666
|
+
index = index + this.offset;
|
|
667
|
+
if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
|
|
668
|
+
this._split(start);
|
|
669
|
+
this._split(end);
|
|
670
|
+
this._split(index);
|
|
671
|
+
const first = this.byStart[start];
|
|
672
|
+
const last = this.byEnd[end];
|
|
673
|
+
const oldLeft = first.previous;
|
|
674
|
+
const oldRight = last.next;
|
|
675
|
+
const newRight = this.byStart[index];
|
|
676
|
+
if (!newRight && last === this.lastChunk) return this;
|
|
677
|
+
const newLeft = newRight ? newRight.previous : this.lastChunk;
|
|
678
|
+
if (oldLeft) oldLeft.next = oldRight;
|
|
679
|
+
if (oldRight) oldRight.previous = oldLeft;
|
|
680
|
+
if (newLeft) newLeft.next = first;
|
|
681
|
+
if (newRight) newRight.previous = last;
|
|
682
|
+
if (!first.previous) this.firstChunk = last.next;
|
|
683
|
+
if (!last.next) {
|
|
684
|
+
this.lastChunk = first.previous;
|
|
685
|
+
this.lastChunk.next = null;
|
|
686
|
+
}
|
|
687
|
+
first.previous = newLeft;
|
|
688
|
+
last.next = newRight || null;
|
|
689
|
+
if (!newLeft) this.firstChunk = first;
|
|
690
|
+
if (!newRight) this.lastChunk = last;
|
|
691
|
+
return this;
|
|
692
|
+
}
|
|
693
|
+
overwrite(start, end, content, options) {
|
|
694
|
+
options = options || {};
|
|
695
|
+
return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
|
|
696
|
+
}
|
|
697
|
+
update(start, end, content, options) {
|
|
698
|
+
start = start + this.offset;
|
|
699
|
+
end = end + this.offset;
|
|
700
|
+
if (typeof content !== "string") throw new TypeError("replacement content must be a string");
|
|
701
|
+
if (this.original.length !== 0) {
|
|
702
|
+
while (start < 0) start += this.original.length;
|
|
703
|
+
while (end < 0) end += this.original.length;
|
|
704
|
+
}
|
|
705
|
+
if (end > this.original.length) throw new Error("end is out of bounds");
|
|
706
|
+
if (start === end)
|
|
707
|
+
throw new Error(
|
|
708
|
+
"Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
|
|
709
|
+
);
|
|
710
|
+
this._split(start);
|
|
711
|
+
this._split(end);
|
|
712
|
+
if (options === true) {
|
|
713
|
+
if (!warned.storeName) {
|
|
714
|
+
console.warn(
|
|
715
|
+
"The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
|
|
716
|
+
);
|
|
717
|
+
warned.storeName = true;
|
|
718
|
+
}
|
|
719
|
+
options = { storeName: true };
|
|
720
|
+
}
|
|
721
|
+
const storeName = options !== void 0 ? options.storeName : false;
|
|
722
|
+
const overwrite = options !== void 0 ? options.overwrite : false;
|
|
723
|
+
if (storeName) {
|
|
724
|
+
const original = this.original.slice(start, end);
|
|
725
|
+
Object.defineProperty(this.storedNames, original, {
|
|
726
|
+
writable: true,
|
|
727
|
+
value: true,
|
|
728
|
+
enumerable: true
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
const first = this.byStart[start];
|
|
732
|
+
const last = this.byEnd[end];
|
|
733
|
+
if (first) {
|
|
734
|
+
let chunk = first;
|
|
735
|
+
while (chunk !== last) {
|
|
736
|
+
if (chunk.next !== this.byStart[chunk.end]) {
|
|
737
|
+
throw new Error("Cannot overwrite across a split point");
|
|
738
|
+
}
|
|
739
|
+
chunk = chunk.next;
|
|
740
|
+
chunk.edit("", false);
|
|
741
|
+
}
|
|
742
|
+
first.edit(content, storeName, !overwrite);
|
|
743
|
+
} else {
|
|
744
|
+
const newChunk = new Chunk(start, end, "").edit(content, storeName);
|
|
745
|
+
last.next = newChunk;
|
|
746
|
+
newChunk.previous = last;
|
|
747
|
+
}
|
|
748
|
+
return this;
|
|
749
|
+
}
|
|
750
|
+
prepend(content) {
|
|
751
|
+
if (typeof content !== "string") throw new TypeError("outro content must be a string");
|
|
752
|
+
this.intro = content + this.intro;
|
|
753
|
+
return this;
|
|
754
|
+
}
|
|
755
|
+
prependLeft(index, content) {
|
|
756
|
+
index = index + this.offset;
|
|
757
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
758
|
+
this._split(index);
|
|
759
|
+
const chunk = this.byEnd[index];
|
|
760
|
+
if (chunk) {
|
|
761
|
+
chunk.prependLeft(content);
|
|
762
|
+
} else {
|
|
763
|
+
this.intro = content + this.intro;
|
|
764
|
+
}
|
|
765
|
+
return this;
|
|
766
|
+
}
|
|
767
|
+
prependRight(index, content) {
|
|
768
|
+
index = index + this.offset;
|
|
769
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
770
|
+
this._split(index);
|
|
771
|
+
const chunk = this.byStart[index];
|
|
772
|
+
if (chunk) {
|
|
773
|
+
chunk.prependRight(content);
|
|
774
|
+
} else {
|
|
775
|
+
this.outro = content + this.outro;
|
|
776
|
+
}
|
|
777
|
+
return this;
|
|
778
|
+
}
|
|
779
|
+
remove(start, end) {
|
|
780
|
+
start = start + this.offset;
|
|
781
|
+
end = end + this.offset;
|
|
782
|
+
if (this.original.length !== 0) {
|
|
783
|
+
while (start < 0) start += this.original.length;
|
|
784
|
+
while (end < 0) end += this.original.length;
|
|
785
|
+
}
|
|
786
|
+
if (start === end) return this;
|
|
787
|
+
if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
|
|
788
|
+
if (start > end) throw new Error("end must be greater than start");
|
|
789
|
+
this._split(start);
|
|
790
|
+
this._split(end);
|
|
791
|
+
let chunk = this.byStart[start];
|
|
792
|
+
while (chunk) {
|
|
793
|
+
chunk.intro = "";
|
|
794
|
+
chunk.outro = "";
|
|
795
|
+
chunk.edit("");
|
|
796
|
+
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
797
|
+
}
|
|
798
|
+
return this;
|
|
799
|
+
}
|
|
800
|
+
reset(start, end) {
|
|
801
|
+
start = start + this.offset;
|
|
802
|
+
end = end + this.offset;
|
|
803
|
+
if (this.original.length !== 0) {
|
|
804
|
+
while (start < 0) start += this.original.length;
|
|
805
|
+
while (end < 0) end += this.original.length;
|
|
806
|
+
}
|
|
807
|
+
if (start === end) return this;
|
|
808
|
+
if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
|
|
809
|
+
if (start > end) throw new Error("end must be greater than start");
|
|
810
|
+
this._split(start);
|
|
811
|
+
this._split(end);
|
|
812
|
+
let chunk = this.byStart[start];
|
|
813
|
+
while (chunk) {
|
|
814
|
+
chunk.reset();
|
|
815
|
+
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
816
|
+
}
|
|
817
|
+
return this;
|
|
818
|
+
}
|
|
819
|
+
lastChar() {
|
|
820
|
+
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
821
|
+
let chunk = this.lastChunk;
|
|
822
|
+
do {
|
|
823
|
+
if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
|
|
824
|
+
if (chunk.content.length) return chunk.content[chunk.content.length - 1];
|
|
825
|
+
if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
|
|
826
|
+
} while (chunk = chunk.previous);
|
|
827
|
+
if (this.intro.length) return this.intro[this.intro.length - 1];
|
|
828
|
+
return "";
|
|
829
|
+
}
|
|
830
|
+
lastLine() {
|
|
831
|
+
let lineIndex = this.outro.lastIndexOf(n);
|
|
832
|
+
if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
|
|
833
|
+
let lineStr = this.outro;
|
|
834
|
+
let chunk = this.lastChunk;
|
|
835
|
+
do {
|
|
836
|
+
if (chunk.outro.length > 0) {
|
|
837
|
+
lineIndex = chunk.outro.lastIndexOf(n);
|
|
838
|
+
if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
839
|
+
lineStr = chunk.outro + lineStr;
|
|
840
|
+
}
|
|
841
|
+
if (chunk.content.length > 0) {
|
|
842
|
+
lineIndex = chunk.content.lastIndexOf(n);
|
|
843
|
+
if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
|
|
844
|
+
lineStr = chunk.content + lineStr;
|
|
845
|
+
}
|
|
846
|
+
if (chunk.intro.length > 0) {
|
|
847
|
+
lineIndex = chunk.intro.lastIndexOf(n);
|
|
848
|
+
if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
849
|
+
lineStr = chunk.intro + lineStr;
|
|
850
|
+
}
|
|
851
|
+
} while (chunk = chunk.previous);
|
|
852
|
+
lineIndex = this.intro.lastIndexOf(n);
|
|
853
|
+
if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
|
|
854
|
+
return this.intro + lineStr;
|
|
855
|
+
}
|
|
856
|
+
slice(start = 0, end = this.original.length - this.offset) {
|
|
857
|
+
start = start + this.offset;
|
|
858
|
+
end = end + this.offset;
|
|
859
|
+
if (this.original.length !== 0) {
|
|
860
|
+
while (start < 0) start += this.original.length;
|
|
861
|
+
while (end < 0) end += this.original.length;
|
|
862
|
+
}
|
|
863
|
+
let result = "";
|
|
864
|
+
let chunk = this.firstChunk;
|
|
865
|
+
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
866
|
+
if (chunk.start < end && chunk.end >= end) {
|
|
867
|
+
return result;
|
|
868
|
+
}
|
|
869
|
+
chunk = chunk.next;
|
|
870
|
+
}
|
|
871
|
+
if (chunk && chunk.edited && chunk.start !== start)
|
|
872
|
+
throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
873
|
+
const startChunk = chunk;
|
|
874
|
+
while (chunk) {
|
|
875
|
+
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
|
|
876
|
+
result += chunk.intro;
|
|
877
|
+
}
|
|
878
|
+
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
879
|
+
if (containsEnd && chunk.edited && chunk.end !== end)
|
|
880
|
+
throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
881
|
+
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
882
|
+
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
883
|
+
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
884
|
+
if (chunk.outro && (!containsEnd || chunk.end === end)) {
|
|
885
|
+
result += chunk.outro;
|
|
886
|
+
}
|
|
887
|
+
if (containsEnd) {
|
|
888
|
+
break;
|
|
889
|
+
}
|
|
890
|
+
chunk = chunk.next;
|
|
891
|
+
}
|
|
892
|
+
return result;
|
|
893
|
+
}
|
|
894
|
+
// TODO deprecate this? not really very useful
|
|
895
|
+
snip(start, end) {
|
|
896
|
+
const clone = this.clone();
|
|
897
|
+
clone.remove(0, start);
|
|
898
|
+
clone.remove(end, clone.original.length);
|
|
899
|
+
return clone;
|
|
900
|
+
}
|
|
901
|
+
_split(index) {
|
|
902
|
+
if (this.byStart[index] || this.byEnd[index]) return;
|
|
903
|
+
let chunk = this.lastSearchedChunk;
|
|
904
|
+
let previousChunk = chunk;
|
|
905
|
+
const searchForward = index > chunk.end;
|
|
906
|
+
while (chunk) {
|
|
907
|
+
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
908
|
+
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
909
|
+
if (chunk === previousChunk) return;
|
|
910
|
+
previousChunk = chunk;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
_splitChunk(chunk, index) {
|
|
914
|
+
if (chunk.edited && chunk.content.length) {
|
|
915
|
+
const loc = getLocator(this.original)(index);
|
|
916
|
+
throw new Error(
|
|
917
|
+
`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
const newChunk = chunk.split(index);
|
|
921
|
+
this.byEnd[index] = chunk;
|
|
922
|
+
this.byStart[index] = newChunk;
|
|
923
|
+
this.byEnd[newChunk.end] = newChunk;
|
|
924
|
+
if (chunk === this.lastChunk) this.lastChunk = newChunk;
|
|
925
|
+
this.lastSearchedChunk = chunk;
|
|
926
|
+
return true;
|
|
927
|
+
}
|
|
928
|
+
toString() {
|
|
929
|
+
let str = this.intro;
|
|
930
|
+
let chunk = this.firstChunk;
|
|
931
|
+
while (chunk) {
|
|
932
|
+
str += chunk.toString();
|
|
933
|
+
chunk = chunk.next;
|
|
934
|
+
}
|
|
935
|
+
return str + this.outro;
|
|
936
|
+
}
|
|
937
|
+
isEmpty() {
|
|
938
|
+
let chunk = this.firstChunk;
|
|
939
|
+
do {
|
|
940
|
+
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim())
|
|
941
|
+
return false;
|
|
942
|
+
} while (chunk = chunk.next);
|
|
943
|
+
return true;
|
|
944
|
+
}
|
|
945
|
+
length() {
|
|
946
|
+
let chunk = this.firstChunk;
|
|
947
|
+
let length = 0;
|
|
948
|
+
do {
|
|
949
|
+
length += chunk.intro.length + chunk.content.length + chunk.outro.length;
|
|
950
|
+
} while (chunk = chunk.next);
|
|
951
|
+
return length;
|
|
952
|
+
}
|
|
953
|
+
trimLines() {
|
|
954
|
+
return this.trim("[\\r\\n]");
|
|
955
|
+
}
|
|
956
|
+
trim(charType) {
|
|
957
|
+
return this.trimStart(charType).trimEnd(charType);
|
|
958
|
+
}
|
|
959
|
+
trimEndAborted(charType) {
|
|
960
|
+
const rx = new RegExp((charType || "\\s") + "+$");
|
|
961
|
+
this.outro = this.outro.replace(rx, "");
|
|
962
|
+
if (this.outro.length) return true;
|
|
963
|
+
let chunk = this.lastChunk;
|
|
964
|
+
do {
|
|
965
|
+
const end = chunk.end;
|
|
966
|
+
const aborted = chunk.trimEnd(rx);
|
|
967
|
+
if (chunk.end !== end) {
|
|
968
|
+
if (this.lastChunk === chunk) {
|
|
969
|
+
this.lastChunk = chunk.next;
|
|
970
|
+
}
|
|
971
|
+
this.byEnd[chunk.end] = chunk;
|
|
972
|
+
this.byStart[chunk.next.start] = chunk.next;
|
|
973
|
+
this.byEnd[chunk.next.end] = chunk.next;
|
|
974
|
+
}
|
|
975
|
+
if (aborted) return true;
|
|
976
|
+
chunk = chunk.previous;
|
|
977
|
+
} while (chunk);
|
|
978
|
+
return false;
|
|
979
|
+
}
|
|
980
|
+
trimEnd(charType) {
|
|
981
|
+
this.trimEndAborted(charType);
|
|
982
|
+
return this;
|
|
983
|
+
}
|
|
984
|
+
trimStartAborted(charType) {
|
|
985
|
+
const rx = new RegExp("^" + (charType || "\\s") + "+");
|
|
986
|
+
this.intro = this.intro.replace(rx, "");
|
|
987
|
+
if (this.intro.length) return true;
|
|
988
|
+
let chunk = this.firstChunk;
|
|
989
|
+
do {
|
|
990
|
+
const end = chunk.end;
|
|
991
|
+
const aborted = chunk.trimStart(rx);
|
|
992
|
+
if (chunk.end !== end) {
|
|
993
|
+
if (chunk === this.lastChunk) this.lastChunk = chunk.next;
|
|
994
|
+
this.byEnd[chunk.end] = chunk;
|
|
995
|
+
this.byStart[chunk.next.start] = chunk.next;
|
|
996
|
+
this.byEnd[chunk.next.end] = chunk.next;
|
|
997
|
+
}
|
|
998
|
+
if (aborted) return true;
|
|
999
|
+
chunk = chunk.next;
|
|
1000
|
+
} while (chunk);
|
|
1001
|
+
return false;
|
|
1002
|
+
}
|
|
1003
|
+
trimStart(charType) {
|
|
1004
|
+
this.trimStartAborted(charType);
|
|
1005
|
+
return this;
|
|
1006
|
+
}
|
|
1007
|
+
hasChanged() {
|
|
1008
|
+
return this.original !== this.toString();
|
|
1009
|
+
}
|
|
1010
|
+
_replaceRegexp(searchValue, replacement) {
|
|
1011
|
+
function getReplacement(match, str) {
|
|
1012
|
+
if (typeof replacement === "string") {
|
|
1013
|
+
return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
1014
|
+
if (i === "$") return "$";
|
|
1015
|
+
if (i === "&") return match[0];
|
|
1016
|
+
const num = +i;
|
|
1017
|
+
if (num < match.length) return match[+i];
|
|
1018
|
+
return `$${i}`;
|
|
1019
|
+
});
|
|
1020
|
+
} else {
|
|
1021
|
+
return replacement(...match, match.index, str, match.groups);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
function matchAll(re, str) {
|
|
1025
|
+
let match;
|
|
1026
|
+
const matches = [];
|
|
1027
|
+
while (match = re.exec(str)) {
|
|
1028
|
+
matches.push(match);
|
|
1029
|
+
}
|
|
1030
|
+
return matches;
|
|
1031
|
+
}
|
|
1032
|
+
if (searchValue.global) {
|
|
1033
|
+
const matches = matchAll(searchValue, this.original);
|
|
1034
|
+
matches.forEach((match) => {
|
|
1035
|
+
if (match.index != null) {
|
|
1036
|
+
const replacement2 = getReplacement(match, this.original);
|
|
1037
|
+
if (replacement2 !== match[0]) {
|
|
1038
|
+
this.overwrite(match.index, match.index + match[0].length, replacement2);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
} else {
|
|
1043
|
+
const match = this.original.match(searchValue);
|
|
1044
|
+
if (match && match.index != null) {
|
|
1045
|
+
const replacement2 = getReplacement(match, this.original);
|
|
1046
|
+
if (replacement2 !== match[0]) {
|
|
1047
|
+
this.overwrite(match.index, match.index + match[0].length, replacement2);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
return this;
|
|
1052
|
+
}
|
|
1053
|
+
_replaceString(string, replacement) {
|
|
1054
|
+
const { original } = this;
|
|
1055
|
+
const index = original.indexOf(string);
|
|
1056
|
+
if (index !== -1) {
|
|
1057
|
+
if (typeof replacement === "function") {
|
|
1058
|
+
replacement = replacement(string, index, original);
|
|
1059
|
+
}
|
|
1060
|
+
if (string !== replacement) {
|
|
1061
|
+
this.overwrite(index, index + string.length, replacement);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
return this;
|
|
1065
|
+
}
|
|
1066
|
+
replace(searchValue, replacement) {
|
|
1067
|
+
if (typeof searchValue === "string") {
|
|
1068
|
+
return this._replaceString(searchValue, replacement);
|
|
1069
|
+
}
|
|
1070
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
1071
|
+
}
|
|
1072
|
+
_replaceAllString(string, replacement) {
|
|
1073
|
+
const { original } = this;
|
|
1074
|
+
const stringLength = string.length;
|
|
1075
|
+
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
1076
|
+
const previous = original.slice(index, index + stringLength);
|
|
1077
|
+
let _replacement = replacement;
|
|
1078
|
+
if (typeof replacement === "function") {
|
|
1079
|
+
_replacement = replacement(previous, index, original);
|
|
1080
|
+
}
|
|
1081
|
+
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
1082
|
+
}
|
|
1083
|
+
return this;
|
|
1084
|
+
}
|
|
1085
|
+
replaceAll(searchValue, replacement) {
|
|
1086
|
+
if (typeof searchValue === "string") {
|
|
1087
|
+
return this._replaceAllString(searchValue, replacement);
|
|
1088
|
+
}
|
|
1089
|
+
if (!searchValue.global) {
|
|
1090
|
+
throw new TypeError(
|
|
1091
|
+
"MagicString.prototype.replaceAll called with a non-global RegExp argument"
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1098
|
+
// ../parsers/dist/index.js
|
|
1099
|
+
var CANVAS_DIMENSIONS = {
|
|
1100
|
+
landscape: { width: 1920, height: 1080 },
|
|
1101
|
+
portrait: { width: 1080, height: 1920 },
|
|
1102
|
+
"landscape-4k": { width: 3840, height: 2160 },
|
|
1103
|
+
"portrait-4k": { width: 2160, height: 3840 },
|
|
1104
|
+
square: { width: 1080, height: 1080 },
|
|
1105
|
+
"square-4k": { width: 2160, height: 2160 }
|
|
1106
|
+
};
|
|
1107
|
+
var VALID_CANVAS_RESOLUTIONS = Object.keys(
|
|
1108
|
+
CANVAS_DIMENSIONS
|
|
1109
|
+
);
|
|
1110
|
+
var RESOLUTION_ALIASES = {
|
|
1111
|
+
"1080p": "landscape",
|
|
1112
|
+
hd: "landscape",
|
|
1113
|
+
"1080p-portrait": "portrait",
|
|
1114
|
+
"portrait-1080p": "portrait",
|
|
1115
|
+
"4k": "landscape-4k",
|
|
1116
|
+
uhd: "landscape-4k",
|
|
1117
|
+
"4k-portrait": "portrait-4k",
|
|
1118
|
+
"1080p-square": "square",
|
|
1119
|
+
"square-1080p": "square",
|
|
1120
|
+
"4k-square": "square-4k"
|
|
1121
|
+
};
|
|
1122
|
+
var ASPECT_AGNOSTIC_RESOLUTION_ALIASES = /* @__PURE__ */ new Set([
|
|
1123
|
+
"1080p",
|
|
1124
|
+
"hd",
|
|
1125
|
+
"4k",
|
|
1126
|
+
"uhd"
|
|
1127
|
+
]);
|
|
1128
|
+
function normalizeResolutionFlag(input) {
|
|
1129
|
+
if (!input) return void 0;
|
|
1130
|
+
const lowered = input.toLowerCase();
|
|
1131
|
+
if (VALID_CANVAS_RESOLUTIONS.includes(lowered)) {
|
|
1132
|
+
return lowered;
|
|
1133
|
+
}
|
|
1134
|
+
return RESOLUTION_ALIASES[lowered];
|
|
1135
|
+
}
|
|
1136
|
+
function isAspectAgnosticResolutionAlias(input) {
|
|
1137
|
+
if (!input) return false;
|
|
1138
|
+
return ASPECT_AGNOSTIC_RESOLUTION_ALIASES.has(input.toLowerCase());
|
|
1139
|
+
}
|
|
1140
|
+
function resolveResolutionFlagPair(input) {
|
|
1141
|
+
return {
|
|
1142
|
+
outputResolution: normalizeResolutionFlag(input),
|
|
1143
|
+
outputResolutionAspectAgnostic: isAspectAgnosticResolutionAlias(input)
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
var COMPOSITION_VARIABLE_TYPES = [
|
|
1147
|
+
"string",
|
|
1148
|
+
"number",
|
|
1149
|
+
"color",
|
|
1150
|
+
"boolean",
|
|
1151
|
+
"enum",
|
|
1152
|
+
"font",
|
|
1153
|
+
"image"
|
|
1154
|
+
];
|
|
1155
|
+
function isTextElement(el) {
|
|
1156
|
+
return el.type === "text";
|
|
1157
|
+
}
|
|
1158
|
+
function isMediaElement(el) {
|
|
1159
|
+
return el.type === "video" || el.type === "image" || el.type === "audio";
|
|
1160
|
+
}
|
|
1161
|
+
function isCompositionElement(el) {
|
|
1162
|
+
return el.type === "composition";
|
|
1163
|
+
}
|
|
1164
|
+
var TIMELINE_COLORS = {
|
|
1165
|
+
video: "#ec4899",
|
|
1166
|
+
image: "#3b82f6",
|
|
1167
|
+
text: "#06b6d4",
|
|
1168
|
+
audio: "#10b981",
|
|
1169
|
+
composition: "#f97316"
|
|
1170
|
+
};
|
|
1171
|
+
var DEFAULT_DURATIONS = {
|
|
1172
|
+
video: 5,
|
|
1173
|
+
image: 5,
|
|
1174
|
+
text: 2,
|
|
1175
|
+
audio: 5,
|
|
1176
|
+
composition: 5
|
|
1177
|
+
};
|
|
1178
|
+
function getDefaultStageZoom(resolution) {
|
|
1179
|
+
const { width, height } = CANVAS_DIMENSIONS[resolution];
|
|
1180
|
+
return {
|
|
1181
|
+
scale: 1,
|
|
1182
|
+
focusX: width / 2,
|
|
1183
|
+
focusY: height / 2
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
var GSAP_DEFAULT_DURATION = 0.5;
|
|
1187
|
+
var BUILTIN_VAR_KEYS = /* @__PURE__ */ new Set(["duration", "ease", "delay"]);
|
|
1188
|
+
var DROPPED_VAR_KEYS = /* @__PURE__ */ new Set([
|
|
1189
|
+
"onComplete",
|
|
1190
|
+
"onStart",
|
|
1191
|
+
"onUpdate",
|
|
1192
|
+
"onRepeat"
|
|
1193
|
+
]);
|
|
1194
|
+
var EXTRAS_KEYS = /* @__PURE__ */ new Set([
|
|
1195
|
+
"stagger",
|
|
1196
|
+
"yoyo",
|
|
1197
|
+
"repeat",
|
|
1198
|
+
"repeatDelay",
|
|
1199
|
+
"snap",
|
|
1200
|
+
"overwrite",
|
|
1201
|
+
"immediateRender"
|
|
1202
|
+
]);
|
|
1203
|
+
var PROPERTY_GROUPS = {
|
|
1204
|
+
position: /* @__PURE__ */ new Set(["x", "y", "xPercent", "yPercent"]),
|
|
1205
|
+
scale: /* @__PURE__ */ new Set(["scale", "scaleX", "scaleY"]),
|
|
1206
|
+
size: /* @__PURE__ */ new Set(["width", "height"]),
|
|
1207
|
+
rotation: /* @__PURE__ */ new Set(["rotation", "skewX", "skewY"]),
|
|
1208
|
+
visual: /* @__PURE__ */ new Set(["opacity", "autoAlpha"]),
|
|
1209
|
+
other: /* @__PURE__ */ new Set()
|
|
1210
|
+
};
|
|
1211
|
+
var PROP_TO_GROUP = /* @__PURE__ */ new Map();
|
|
1212
|
+
for (const [group, props] of Object.entries(PROPERTY_GROUPS)) {
|
|
1213
|
+
for (const p of props) PROP_TO_GROUP.set(p, group);
|
|
1214
|
+
}
|
|
1215
|
+
function classifyPropertyGroup(prop) {
|
|
1216
|
+
return PROP_TO_GROUP.get(prop) ?? "other";
|
|
1217
|
+
}
|
|
1218
|
+
function classifyTweenPropertyGroup(properties) {
|
|
1219
|
+
const groups = /* @__PURE__ */ new Set();
|
|
1220
|
+
for (const key of Object.keys(properties)) {
|
|
1221
|
+
if (key === "transformOrigin" || key === "_auto" || key === "data") continue;
|
|
1222
|
+
const g = classifyPropertyGroup(key);
|
|
1223
|
+
groups.add(g);
|
|
1224
|
+
}
|
|
1225
|
+
if (groups.size === 1) return groups.values().next().value;
|
|
1226
|
+
return void 0;
|
|
1227
|
+
}
|
|
1228
|
+
function buildArcPath(coords, curviness, autoRotate, isCubic) {
|
|
1229
|
+
const first = coords[0];
|
|
1230
|
+
if (coords.length < 2 || !first) return void 0;
|
|
1231
|
+
const segments = [];
|
|
1232
|
+
let waypoints;
|
|
1233
|
+
if (isCubic && coords.length >= 4) {
|
|
1234
|
+
waypoints = [first];
|
|
1235
|
+
for (let i = 1; i + 2 < coords.length; i += 3) {
|
|
1236
|
+
const cp1 = coords[i];
|
|
1237
|
+
const cp2 = coords[i + 1];
|
|
1238
|
+
const anchor = coords[i + 2];
|
|
1239
|
+
if (!cp1 || !cp2 || !anchor) continue;
|
|
1240
|
+
waypoints.push(anchor);
|
|
1241
|
+
segments.push({ curviness, cp1, cp2 });
|
|
1242
|
+
}
|
|
1243
|
+
} else {
|
|
1244
|
+
waypoints = coords;
|
|
1245
|
+
for (let i = 0; i < waypoints.length - 1; i++) segments.push({ curviness });
|
|
1246
|
+
}
|
|
1247
|
+
return { arcPath: { enabled: true, autoRotate, segments }, waypoints };
|
|
1248
|
+
}
|
|
1249
|
+
function serializeGsapAnimations(animations, timelineVar = "tl", options) {
|
|
1250
|
+
const sorted = [...animations].sort((a, b) => {
|
|
1251
|
+
const aNum = a.resolvedStart ?? (typeof a.position === "number" ? a.position : Number.MAX_SAFE_INTEGER);
|
|
1252
|
+
const bNum = b.resolvedStart ?? (typeof b.position === "number" ? b.position : Number.MAX_SAFE_INTEGER);
|
|
1253
|
+
return aNum - bNum;
|
|
1254
|
+
});
|
|
1255
|
+
const lines = sorted.map((anim) => {
|
|
1256
|
+
const selector = JSON.stringify(anim.targetSelector);
|
|
1257
|
+
const props = { ...anim.properties };
|
|
1258
|
+
if (anim.duration !== void 0) props.duration = anim.duration;
|
|
1259
|
+
if (anim.ease) props.ease = anim.ease;
|
|
1260
|
+
let propsStr = serializeObject(props);
|
|
1261
|
+
if (anim.extras && Object.keys(anim.extras).length > 0) {
|
|
1262
|
+
const extrasStr = serializeExtras(anim.extras);
|
|
1263
|
+
if (Object.keys(props).length === 0) {
|
|
1264
|
+
propsStr = `{ ${extrasStr} }`;
|
|
1265
|
+
} else {
|
|
1266
|
+
propsStr = propsStr.slice(0, -2) + `, ${extrasStr} }`;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
const posStr = JSON.stringify(anim.position);
|
|
1270
|
+
switch (anim.method) {
|
|
1271
|
+
case "set":
|
|
1272
|
+
return anim.global ? ` gsap.set(${selector}, ${propsStr});` : ` ${timelineVar}.set(${selector}, ${propsStr}, ${posStr});`;
|
|
1273
|
+
case "to":
|
|
1274
|
+
return ` ${timelineVar}.to(${selector}, ${propsStr}, ${posStr});`;
|
|
1275
|
+
case "from":
|
|
1276
|
+
return ` ${timelineVar}.from(${selector}, ${propsStr}, ${posStr});`;
|
|
1277
|
+
case "fromTo": {
|
|
1278
|
+
const fromStr = serializeObject(anim.fromProperties || {});
|
|
1279
|
+
return ` ${timelineVar}.fromTo(${selector}, ${fromStr}, ${propsStr}, ${posStr});`;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
let mediaSync = "";
|
|
1284
|
+
if (options?.includeMediaSync) {
|
|
1285
|
+
mediaSync = `
|
|
1286
|
+
${timelineVar}.eventCallback("onUpdate", function() {
|
|
1287
|
+
const time = ${timelineVar}.time();
|
|
1288
|
+
document.querySelectorAll("video[data-start], audio[data-start]").forEach(function(media) {
|
|
1289
|
+
const start = parseFloat(media.dataset.start);
|
|
1290
|
+
const end = parseFloat(media.dataset.end) || Infinity;
|
|
1291
|
+
const mediaTime = time - start;
|
|
1292
|
+
if (time >= start && time < end) {
|
|
1293
|
+
if (Math.abs(media.currentTime - mediaTime) > 0.1) {
|
|
1294
|
+
media.currentTime = mediaTime;
|
|
1295
|
+
}
|
|
1296
|
+
if (media.paused && !${timelineVar}.paused()) {
|
|
1297
|
+
media.play().catch(function() {});
|
|
1298
|
+
}
|
|
1299
|
+
} else if (!media.paused) {
|
|
1300
|
+
media.pause();
|
|
1301
|
+
}
|
|
1302
|
+
});
|
|
1303
|
+
});`;
|
|
1304
|
+
}
|
|
1305
|
+
const preamble = options?.preamble || `const ${timelineVar} = gsap.timeline({ paused: true });`;
|
|
1306
|
+
const postamble = options?.postamble ? `
|
|
1307
|
+
${options.postamble}` : "";
|
|
1308
|
+
return `
|
|
1309
|
+
${preamble}
|
|
1310
|
+
${lines.join("\n")}${mediaSync}${postamble}
|
|
1311
|
+
`;
|
|
1312
|
+
}
|
|
1313
|
+
function serializeValue(value) {
|
|
1314
|
+
if (typeof value === "string" && value.startsWith("__raw:")) {
|
|
1315
|
+
return value.slice(6);
|
|
1316
|
+
}
|
|
1317
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
1318
|
+
return String(value);
|
|
1319
|
+
}
|
|
1320
|
+
function safeJsKey(key) {
|
|
1321
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
|
|
1322
|
+
}
|
|
1323
|
+
function serializeObject(obj) {
|
|
1324
|
+
const entries = Object.entries(obj).map(([key, value]) => {
|
|
1325
|
+
return `${safeJsKey(key)}: ${serializeValue(value)}`;
|
|
1326
|
+
});
|
|
1327
|
+
return `{ ${entries.join(", ")} }`;
|
|
1328
|
+
}
|
|
1329
|
+
function serializeExtras(extras) {
|
|
1330
|
+
return Object.entries(extras).map(([key, value]) => {
|
|
1331
|
+
return `${safeJsKey(key)}: ${serializeValue(value)}`;
|
|
1332
|
+
}).join(", ");
|
|
1333
|
+
}
|
|
1334
|
+
function getAnimationsForElementId(animations, elementId) {
|
|
1335
|
+
const selector = `#${elementId}`;
|
|
1336
|
+
return animations.filter((a) => a.targetSelector === selector);
|
|
1337
|
+
}
|
|
1338
|
+
var FORBIDDEN_GSAP_PATTERNS = [
|
|
1339
|
+
{ pattern: /\.call\s*\(/, message: "call() method not allowed" },
|
|
1340
|
+
{ pattern: /\.add\s*\(/, message: "add() method not allowed" },
|
|
1341
|
+
{ pattern: /\.addPause\s*\(/, message: "addPause() method not allowed" },
|
|
1342
|
+
{ pattern: /gsap\.registerEffect\s*\(/, message: "registerEffect() not allowed" },
|
|
1343
|
+
{ pattern: /ScrollTrigger/, message: "ScrollTrigger not allowed" },
|
|
1344
|
+
{ pattern: /onComplete\s*:/, message: "onComplete callback not allowed" },
|
|
1345
|
+
{ pattern: /onUpdate\s*:/, message: "onUpdate callback not allowed" },
|
|
1346
|
+
{ pattern: /onStart\s*:/, message: "onStart callback not allowed" },
|
|
1347
|
+
{ pattern: /onRepeat\s*:/, message: "onRepeat callback not allowed" },
|
|
1348
|
+
{ pattern: /onReverseComplete\s*:/, message: "onReverseComplete callback not allowed" },
|
|
1349
|
+
{ pattern: /repeat\s*:\s*-1/, message: "Infinite repeat (repeat: -1) not allowed" },
|
|
1350
|
+
{ pattern: /Math\.random\s*\(/, message: "Random values (Math.random) not allowed" },
|
|
1351
|
+
{ pattern: /Date\.now\s*\(/, message: "Date-dependent values (Date.now) not allowed" },
|
|
1352
|
+
{ pattern: /new\s+Date\s*\(/, message: "Date constructor not allowed" },
|
|
1353
|
+
{ pattern: /setTimeout\s*\(/, message: "setTimeout not allowed" },
|
|
1354
|
+
{ pattern: /setInterval\s*\(/, message: "setInterval not allowed" },
|
|
1355
|
+
{ pattern: /requestAnimationFrame\s*\(/, message: "requestAnimationFrame not allowed" }
|
|
1356
|
+
];
|
|
1357
|
+
function validateCompositionGsap(script) {
|
|
1358
|
+
const errors = [];
|
|
1359
|
+
const warnings = [];
|
|
1360
|
+
for (const { pattern, message } of FORBIDDEN_GSAP_PATTERNS) {
|
|
1361
|
+
if (pattern.test(script)) errors.push(message);
|
|
1362
|
+
}
|
|
1363
|
+
if (/yoyo\s*:\s*true/.test(script)) {
|
|
1364
|
+
warnings.push("yoyo animations may behave unexpectedly when scrubbing");
|
|
1365
|
+
}
|
|
1366
|
+
if (/stagger\s*:/.test(script)) {
|
|
1367
|
+
warnings.push("stagger animations may not serialize correctly");
|
|
1368
|
+
}
|
|
1369
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
1370
|
+
}
|
|
1371
|
+
function keyframesToGsapAnimations(elementId, keyframes, elementStartTime, base) {
|
|
1372
|
+
const sorted = [...keyframes].sort((a, b) => a.time - b.time);
|
|
1373
|
+
const animations = [];
|
|
1374
|
+
const baseX = base?.x ?? 0;
|
|
1375
|
+
const baseY = base?.y ?? 0;
|
|
1376
|
+
const baseScale = base?.scale ?? 1;
|
|
1377
|
+
sorted.forEach((kf, i) => {
|
|
1378
|
+
const absoluteTime = elementStartTime + kf.time;
|
|
1379
|
+
const isFirst = i === 0;
|
|
1380
|
+
const prevKf = i > 0 ? sorted[i - 1] : null;
|
|
1381
|
+
const duration = prevKf ? kf.time - prevKf.time : void 0;
|
|
1382
|
+
const position = prevKf ? elementStartTime + prevKf.time : absoluteTime;
|
|
1383
|
+
const properties = {};
|
|
1384
|
+
for (const [key, value] of Object.entries(kf.properties)) {
|
|
1385
|
+
if (typeof value !== "number") continue;
|
|
1386
|
+
if (key === "x") properties.x = baseX + value;
|
|
1387
|
+
else if (key === "y") properties.y = baseY + value;
|
|
1388
|
+
else if (key === "scale") properties.scale = baseScale * value;
|
|
1389
|
+
else properties[key] = value;
|
|
1390
|
+
}
|
|
1391
|
+
animations.push({
|
|
1392
|
+
id: `${elementId}-kf-${kf.id}`,
|
|
1393
|
+
targetSelector: `#${elementId}`,
|
|
1394
|
+
method: isFirst ? "set" : "to",
|
|
1395
|
+
position,
|
|
1396
|
+
properties,
|
|
1397
|
+
duration: isFirst ? void 0 : duration,
|
|
1398
|
+
ease: kf.ease
|
|
1399
|
+
});
|
|
1400
|
+
});
|
|
1401
|
+
return animations;
|
|
1402
|
+
}
|
|
1403
|
+
function gsapAnimationsToKeyframes(animations, elementStartTime, options) {
|
|
1404
|
+
const validMethods = ["set", "to", "from", "fromTo"];
|
|
1405
|
+
const baseX = options?.baseX ?? 0;
|
|
1406
|
+
const baseY = options?.baseY ?? 0;
|
|
1407
|
+
const baseScale = options?.baseScale ?? 1;
|
|
1408
|
+
const clampTimeToZero = options?.clampTimeToZero ?? true;
|
|
1409
|
+
const skipBaseSet = options?.skipBaseSet ?? false;
|
|
1410
|
+
const baseTimeEpsilon = 1e-3;
|
|
1411
|
+
const baseValueEpsilon = 1e-5;
|
|
1412
|
+
return animations.filter(
|
|
1413
|
+
(a) => validMethods.includes(a.method) && typeof a.position === "number"
|
|
1414
|
+
).map((a) => {
|
|
1415
|
+
const relativeTimeRaw = a.position - elementStartTime;
|
|
1416
|
+
const time = clampTimeToZero ? Math.max(0, relativeTimeRaw) : relativeTimeRaw;
|
|
1417
|
+
const properties = {};
|
|
1418
|
+
for (const [key, value] of Object.entries(a.properties)) {
|
|
1419
|
+
if (typeof value !== "number") continue;
|
|
1420
|
+
if (key === "x") properties.x = value - baseX;
|
|
1421
|
+
else if (key === "y") properties.y = value - baseY;
|
|
1422
|
+
else if (key === "scale") {
|
|
1423
|
+
properties.scale = baseScale !== 0 ? value / baseScale : value;
|
|
1424
|
+
} else {
|
|
1425
|
+
properties[key] = value;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
if (skipBaseSet && a.method === "set" && time < baseTimeEpsilon && Object.values(properties).every(
|
|
1429
|
+
(v) => typeof v === "number" && Math.abs(v) < baseValueEpsilon
|
|
1430
|
+
)) {
|
|
1431
|
+
return null;
|
|
1432
|
+
}
|
|
1433
|
+
return {
|
|
1434
|
+
id: a.id.replace(/^.*-kf-/, ""),
|
|
1435
|
+
time,
|
|
1436
|
+
properties,
|
|
1437
|
+
ease: a.ease
|
|
1438
|
+
};
|
|
1439
|
+
}).filter((kf) => kf !== null);
|
|
1440
|
+
}
|
|
1441
|
+
var roundPercentage = (percentage) => Math.round(percentage * 10) / 10;
|
|
1442
|
+
function getObjectArrayKeyframeTiming(durations) {
|
|
1443
|
+
const steps = durations.map((duration) => duration ?? GSAP_DEFAULT_DURATION);
|
|
1444
|
+
if (!steps.every(
|
|
1445
|
+
(duration) => typeof duration === "number" && Number.isFinite(duration) && duration > 0
|
|
1446
|
+
)) {
|
|
1447
|
+
return null;
|
|
1448
|
+
}
|
|
1449
|
+
const totalDuration = steps.reduce((sum, duration) => sum + duration, 0);
|
|
1450
|
+
let cumulative = 0;
|
|
1451
|
+
return {
|
|
1452
|
+
percentages: steps.map((duration) => {
|
|
1453
|
+
cumulative += duration;
|
|
1454
|
+
return roundPercentage(cumulative / totalDuration * 100);
|
|
1455
|
+
}),
|
|
1456
|
+
totalDuration
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
var SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
1460
|
+
"type",
|
|
1461
|
+
"start",
|
|
1462
|
+
"end",
|
|
1463
|
+
"loc",
|
|
1464
|
+
"range",
|
|
1465
|
+
"__hfProvenance",
|
|
1466
|
+
"__hfOrder",
|
|
1467
|
+
"__hfSiteStart"
|
|
1468
|
+
]);
|
|
1469
|
+
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
1470
|
+
"ArrowFunctionExpression",
|
|
1471
|
+
"FunctionExpression",
|
|
1472
|
+
"FunctionDeclaration"
|
|
1473
|
+
]);
|
|
1474
|
+
var GSAP_METHODS = /* @__PURE__ */ new Set(["set", "to", "from", "fromTo"]);
|
|
1475
|
+
var MAX_DEPTH = 8;
|
|
1476
|
+
var MAX_ITERS = 512;
|
|
1477
|
+
function isFunctionNode(node) {
|
|
1478
|
+
return !!node && FUNCTION_TYPES.has(node.type);
|
|
1479
|
+
}
|
|
1480
|
+
function isNode(x) {
|
|
1481
|
+
return !!x && typeof x === "object" && typeof x.type === "string";
|
|
1482
|
+
}
|
|
1483
|
+
function transformChildren(node, fn) {
|
|
1484
|
+
for (const key of Object.keys(node)) {
|
|
1485
|
+
if (SKIP_KEYS.has(key) || isNonValueIdentifierSlot(node, key)) continue;
|
|
1486
|
+
const child = node[key];
|
|
1487
|
+
if (Array.isArray(child)) {
|
|
1488
|
+
for (let i = 0; i < child.length; i++) child[i] = fn(child[i]);
|
|
1489
|
+
} else {
|
|
1490
|
+
node[key] = fn(child);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
function cloneNode(node) {
|
|
1495
|
+
return structuredClone(node);
|
|
1496
|
+
}
|
|
1497
|
+
function collectPatternNames(pattern, out) {
|
|
1498
|
+
if (pattern?.type === "Identifier") out.add(pattern.name);
|
|
1499
|
+
else if (pattern?.type === "AssignmentPattern") collectPatternNames(pattern.left, out);
|
|
1500
|
+
else if (pattern?.type === "RestElement") collectPatternNames(pattern.argument, out);
|
|
1501
|
+
}
|
|
1502
|
+
function boundPatterns(node) {
|
|
1503
|
+
if (isFunctionNode(node)) return node.params ?? [];
|
|
1504
|
+
if (node.type === "VariableDeclarator") return [node.id];
|
|
1505
|
+
if (node.type === "CatchClause") return [node.param];
|
|
1506
|
+
if (node.type === "AssignmentExpression" && node.left?.type === "Identifier") return [node.left];
|
|
1507
|
+
return [];
|
|
1508
|
+
}
|
|
1509
|
+
function collectBoundNames(root) {
|
|
1510
|
+
const names = /* @__PURE__ */ new Set();
|
|
1511
|
+
const visit = (node) => {
|
|
1512
|
+
if (!isNode(node)) return node;
|
|
1513
|
+
for (const pattern of boundPatterns(node)) collectPatternNames(pattern, names);
|
|
1514
|
+
transformChildren(node, visit);
|
|
1515
|
+
return node;
|
|
1516
|
+
};
|
|
1517
|
+
visit(root);
|
|
1518
|
+
return names;
|
|
1519
|
+
}
|
|
1520
|
+
function isNonValueIdentifierSlot(node, key) {
|
|
1521
|
+
if (node.computed) return false;
|
|
1522
|
+
return node.type === "MemberExpression" && key === "property" || node.type === "Property" && key === "key";
|
|
1523
|
+
}
|
|
1524
|
+
function substituteParams(node, bindings) {
|
|
1525
|
+
const shadowed = collectBoundNames(node);
|
|
1526
|
+
let effective = bindings;
|
|
1527
|
+
if (shadowed.size > 0) {
|
|
1528
|
+
effective = new Map(bindings);
|
|
1529
|
+
for (const name of shadowed) effective.delete(name);
|
|
1530
|
+
}
|
|
1531
|
+
if (effective.size === 0) return node;
|
|
1532
|
+
return replace(node, effective);
|
|
1533
|
+
}
|
|
1534
|
+
function replace(node, bindings) {
|
|
1535
|
+
if (!isNode(node)) return node;
|
|
1536
|
+
if (node.type === "Identifier" && bindings.has(node.name)) {
|
|
1537
|
+
return cloneNode(bindings.get(node.name));
|
|
1538
|
+
}
|
|
1539
|
+
transformChildren(node, (child) => replace(child, bindings));
|
|
1540
|
+
return node;
|
|
1541
|
+
}
|
|
1542
|
+
function tagProvenance(node, provenance) {
|
|
1543
|
+
if (node && typeof node === "object") node.__hfProvenance = provenance;
|
|
1544
|
+
return node;
|
|
1545
|
+
}
|
|
1546
|
+
function readProvenance(node) {
|
|
1547
|
+
return node?.__hfProvenance;
|
|
1548
|
+
}
|
|
1549
|
+
function numericLiteral(value) {
|
|
1550
|
+
return { type: "Literal", value, raw: String(value) };
|
|
1551
|
+
}
|
|
1552
|
+
function walkNodes(node, fn) {
|
|
1553
|
+
if (!isNode(node)) return;
|
|
1554
|
+
fn(node);
|
|
1555
|
+
for (const key of Object.keys(node)) {
|
|
1556
|
+
if (SKIP_KEYS.has(key)) continue;
|
|
1557
|
+
const child = node[key];
|
|
1558
|
+
if (Array.isArray(child)) for (const c of child) walkNodes(c, fn);
|
|
1559
|
+
else walkNodes(child, fn);
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
function timelineRootName(call) {
|
|
1563
|
+
let obj = call.callee?.object;
|
|
1564
|
+
while (obj?.type === "CallExpression") obj = obj.callee?.object;
|
|
1565
|
+
return obj?.type === "Identifier" ? obj.name : null;
|
|
1566
|
+
}
|
|
1567
|
+
function isTimelineRooted(call, timelineVar) {
|
|
1568
|
+
if (timelineRootName(call) !== timelineVar) return false;
|
|
1569
|
+
return call.callee?.property?.type === "Identifier" && GSAP_METHODS.has(call.callee.property.name);
|
|
1570
|
+
}
|
|
1571
|
+
function isAddLabelCall(call, timelineVar) {
|
|
1572
|
+
return timelineRootName(call) === timelineVar && call.callee?.property?.name === "addLabel";
|
|
1573
|
+
}
|
|
1574
|
+
function containsTimelineCall(node, timelineVar) {
|
|
1575
|
+
let found = false;
|
|
1576
|
+
walkNodes(node, (n2) => {
|
|
1577
|
+
if (n2.type === "CallExpression" && isTimelineRooted(n2, timelineVar)) found = true;
|
|
1578
|
+
});
|
|
1579
|
+
return found;
|
|
1580
|
+
}
|
|
1581
|
+
function rangeOf(node) {
|
|
1582
|
+
return typeof node.start === "number" && typeof node.end === "number" ? [node.start, node.end] : void 0;
|
|
1583
|
+
}
|
|
1584
|
+
var SAFE_DEFAULT_NODES = /* @__PURE__ */ new Set([
|
|
1585
|
+
"ArrayExpression",
|
|
1586
|
+
"BinaryExpression",
|
|
1587
|
+
"ChainExpression",
|
|
1588
|
+
"ConditionalExpression",
|
|
1589
|
+
"Identifier",
|
|
1590
|
+
"Literal",
|
|
1591
|
+
"LogicalExpression",
|
|
1592
|
+
"MemberExpression",
|
|
1593
|
+
"ObjectExpression",
|
|
1594
|
+
"Property",
|
|
1595
|
+
"SpreadElement",
|
|
1596
|
+
"TemplateElement",
|
|
1597
|
+
"TemplateLiteral",
|
|
1598
|
+
"UnaryExpression"
|
|
1599
|
+
]);
|
|
1600
|
+
function isSafeDefaultExpression(node, earlierParams) {
|
|
1601
|
+
let safe = true;
|
|
1602
|
+
const visit = (current, parent, key) => {
|
|
1603
|
+
if (!isNode(current) || !safe) return;
|
|
1604
|
+
if (!SAFE_DEFAULT_NODES.has(current.type)) {
|
|
1605
|
+
safe = false;
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
if (current.type === "UnaryExpression" && current.operator === "delete") {
|
|
1609
|
+
safe = false;
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
if (current.type === "Identifier") {
|
|
1613
|
+
const nonValue = parent && key ? isNonValueIdentifierSlot(parent, key) : false;
|
|
1614
|
+
if (!nonValue && current.name !== "undefined" && !earlierParams.has(current.name)) {
|
|
1615
|
+
safe = false;
|
|
1616
|
+
}
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
for (const childKey of Object.keys(current)) {
|
|
1620
|
+
if (SKIP_KEYS.has(childKey)) continue;
|
|
1621
|
+
const child = current[childKey];
|
|
1622
|
+
if (Array.isArray(child)) {
|
|
1623
|
+
for (const item of child) visit(item, current, childKey);
|
|
1624
|
+
} else {
|
|
1625
|
+
visit(child, current, childKey);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
visit(node);
|
|
1630
|
+
return safe;
|
|
1631
|
+
}
|
|
1632
|
+
var SUPPORTED_PARAMS_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1633
|
+
function supportedParam(param, earlier) {
|
|
1634
|
+
if (param.type === "Identifier") return { name: param.name };
|
|
1635
|
+
if (param.type !== "AssignmentPattern" || param.left?.type !== "Identifier") return null;
|
|
1636
|
+
if (!isSafeDefaultExpression(param.right, earlier)) return null;
|
|
1637
|
+
return { name: param.left.name, defaultExpression: param.right };
|
|
1638
|
+
}
|
|
1639
|
+
function supportedParams(fn) {
|
|
1640
|
+
if (SUPPORTED_PARAMS_CACHE.has(fn)) return SUPPORTED_PARAMS_CACHE.get(fn) ?? null;
|
|
1641
|
+
const params = [];
|
|
1642
|
+
const earlier = /* @__PURE__ */ new Set();
|
|
1643
|
+
for (const param of fn.params ?? []) {
|
|
1644
|
+
const parsed = supportedParam(param, earlier);
|
|
1645
|
+
if (!parsed) {
|
|
1646
|
+
SUPPORTED_PARAMS_CACHE.set(fn, null);
|
|
1647
|
+
return null;
|
|
1648
|
+
}
|
|
1649
|
+
params.push(parsed);
|
|
1650
|
+
earlier.add(parsed.name);
|
|
1651
|
+
}
|
|
1652
|
+
SUPPORTED_PARAMS_CACHE.set(fn, params);
|
|
1653
|
+
return params;
|
|
1654
|
+
}
|
|
1655
|
+
function isShapeEligible(fn) {
|
|
1656
|
+
return isFunctionNode(fn) && fn.body?.type === "BlockStatement" && supportedParams(fn) !== null;
|
|
1657
|
+
}
|
|
1658
|
+
function callsAny(node, names) {
|
|
1659
|
+
let hit = false;
|
|
1660
|
+
walkNodes(node, (n2) => {
|
|
1661
|
+
if (n2.type === "CallExpression" && n2.callee?.type === "Identifier" && names.has(n2.callee.name)) {
|
|
1662
|
+
hit = true;
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
return hit;
|
|
1666
|
+
}
|
|
1667
|
+
function varDeclHelper(stmt) {
|
|
1668
|
+
if (stmt.declarations?.length !== 1) return null;
|
|
1669
|
+
const d = stmt.declarations[0];
|
|
1670
|
+
return d.id?.type === "Identifier" && isShapeEligible(d.init) ? [d.id.name, d.init] : null;
|
|
1671
|
+
}
|
|
1672
|
+
function helperFromStatement(stmt) {
|
|
1673
|
+
if (stmt.type === "FunctionDeclaration") {
|
|
1674
|
+
return stmt.id && isShapeEligible(stmt) ? [stmt.id.name, stmt] : null;
|
|
1675
|
+
}
|
|
1676
|
+
if (stmt.type === "VariableDeclaration") return varDeclHelper(stmt);
|
|
1677
|
+
return null;
|
|
1678
|
+
}
|
|
1679
|
+
function gatherHelperCandidates(program) {
|
|
1680
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
1681
|
+
for (const stmt of program.body ?? []) {
|
|
1682
|
+
const helper = helperFromStatement(stmt);
|
|
1683
|
+
if (helper) candidates.set(helper[0], helper[1]);
|
|
1684
|
+
}
|
|
1685
|
+
return candidates;
|
|
1686
|
+
}
|
|
1687
|
+
function timelineBuildingNames(candidates, timelineVar) {
|
|
1688
|
+
const building = /* @__PURE__ */ new Set();
|
|
1689
|
+
for (const [name, fn] of candidates) {
|
|
1690
|
+
if (containsTimelineCall(fn.body, timelineVar)) building.add(name);
|
|
1691
|
+
}
|
|
1692
|
+
for (let changed = true; changed; ) {
|
|
1693
|
+
changed = false;
|
|
1694
|
+
for (const [name, fn] of candidates) {
|
|
1695
|
+
if (!building.has(name) && callsAny(fn.body, building)) {
|
|
1696
|
+
building.add(name);
|
|
1697
|
+
changed = true;
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
return building;
|
|
1702
|
+
}
|
|
1703
|
+
function bump(counts, key) {
|
|
1704
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
1705
|
+
}
|
|
1706
|
+
function undefinedIdentifier() {
|
|
1707
|
+
return { type: "Identifier", name: "undefined" };
|
|
1708
|
+
}
|
|
1709
|
+
function isExplicitUndefined(node) {
|
|
1710
|
+
return node?.type === "Identifier" && node.name === "undefined" || node?.type === "UnaryExpression" && node.operator === "void" && node.argument?.type === "Literal" && node.argument.value === 0;
|
|
1711
|
+
}
|
|
1712
|
+
function resolveHelperBindings(call, params) {
|
|
1713
|
+
if (call.arguments?.some((arg) => arg?.type === "SpreadElement")) return null;
|
|
1714
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
1715
|
+
for (let i = 0; i < params.length; i++) {
|
|
1716
|
+
const param = params[i];
|
|
1717
|
+
const arg = call.arguments?.[i];
|
|
1718
|
+
if (arg && !isExplicitUndefined(arg)) {
|
|
1719
|
+
bindings.set(param.name, arg);
|
|
1720
|
+
} else if (param.defaultExpression) {
|
|
1721
|
+
bindings.set(param.name, substituteParams(cloneNode(param.defaultExpression), bindings));
|
|
1722
|
+
} else {
|
|
1723
|
+
bindings.set(param.name, undefinedIdentifier());
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
return bindings;
|
|
1727
|
+
}
|
|
1728
|
+
function statementHelperCall(node, names) {
|
|
1729
|
+
if (node.type !== "ExpressionStatement") return void 0;
|
|
1730
|
+
const expression = node.expression;
|
|
1731
|
+
if (expression?.type !== "CallExpression" || expression.callee?.type !== "Identifier") {
|
|
1732
|
+
return void 0;
|
|
1733
|
+
}
|
|
1734
|
+
return names.has(expression.callee.name) ? expression : void 0;
|
|
1735
|
+
}
|
|
1736
|
+
function safelyDroppable(program, candidates) {
|
|
1737
|
+
const names = new Set(candidates.keys());
|
|
1738
|
+
const totalIds = /* @__PURE__ */ new Map();
|
|
1739
|
+
const stmtCalls = /* @__PURE__ */ new Map();
|
|
1740
|
+
const unbindable = /* @__PURE__ */ new Set();
|
|
1741
|
+
walkNodes(program, (n2) => {
|
|
1742
|
+
if (n2.type === "Identifier" && names.has(n2.name)) bump(totalIds, n2.name);
|
|
1743
|
+
const call = statementHelperCall(n2, names);
|
|
1744
|
+
if (!call) return;
|
|
1745
|
+
bump(stmtCalls, call.callee.name);
|
|
1746
|
+
const fn = candidates.get(call.callee.name);
|
|
1747
|
+
const params = fn && supportedParams(fn);
|
|
1748
|
+
if (!params || !resolveHelperBindings(call, params)) unbindable.add(call.callee.name);
|
|
1749
|
+
});
|
|
1750
|
+
const safe = /* @__PURE__ */ new Map();
|
|
1751
|
+
for (const [name, fn] of candidates) {
|
|
1752
|
+
if (!unbindable.has(name) && (totalIds.get(name) ?? 0) === 1 + (stmtCalls.get(name) ?? 0)) {
|
|
1753
|
+
safe.set(name, fn);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
return safe;
|
|
1757
|
+
}
|
|
1758
|
+
function collectInlinableHelpers(program, timelineVar) {
|
|
1759
|
+
const candidates = gatherHelperCandidates(program);
|
|
1760
|
+
if (candidates.size === 0) return candidates;
|
|
1761
|
+
const building = timelineBuildingNames(candidates, timelineVar);
|
|
1762
|
+
for (const name of [...candidates.keys()]) if (!building.has(name)) candidates.delete(name);
|
|
1763
|
+
if (candidates.size === 0) return candidates;
|
|
1764
|
+
return safelyDroppable(program, candidates);
|
|
1765
|
+
}
|
|
1766
|
+
function isHelperDecl(stmt, helpers) {
|
|
1767
|
+
if (stmt.type === "FunctionDeclaration") return !!stmt.id && helpers.get(stmt.id.name) === stmt;
|
|
1768
|
+
if (stmt.type === "VariableDeclaration" && stmt.declarations?.length === 1) {
|
|
1769
|
+
const d = stmt.declarations[0];
|
|
1770
|
+
return d.id?.type === "Identifier" && helpers.get(d.id.name) === d.init;
|
|
1771
|
+
}
|
|
1772
|
+
return false;
|
|
1773
|
+
}
|
|
1774
|
+
function bodyStatements(node) {
|
|
1775
|
+
if (node?.type === "BlockStatement") return node.body ?? [];
|
|
1776
|
+
return node ? [{ type: "ExpressionStatement", expression: node }] : [];
|
|
1777
|
+
}
|
|
1778
|
+
function tagTimelineCalls(stmts, prov, ctx) {
|
|
1779
|
+
for (const stmt of stmts) {
|
|
1780
|
+
const calls = [];
|
|
1781
|
+
walkNodes(stmt, (n2) => {
|
|
1782
|
+
if (n2.type === "CallExpression" && (isTimelineRooted(n2, ctx.timelineVar) || isAddLabelCall(n2, ctx.timelineVar)))
|
|
1783
|
+
calls.push(n2);
|
|
1784
|
+
});
|
|
1785
|
+
calls.sort((a, b) => a.callee.property.start - b.callee.property.start);
|
|
1786
|
+
for (const n2 of calls) {
|
|
1787
|
+
tagProvenance(n2, { ...prov });
|
|
1788
|
+
n2.__hfOrder = ctx.order.n++;
|
|
1789
|
+
n2.__hfSiteStart = ctx.rootStart;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
function expandBody(bodyStmts, bindings, prov, ctx) {
|
|
1794
|
+
const block = substituteParams(cloneNode({ type: "BlockStatement", body: bodyStmts }), bindings);
|
|
1795
|
+
tagProvenance(block, prov);
|
|
1796
|
+
tagTimelineCalls(block.body, prov, ctx);
|
|
1797
|
+
block.body = expandStatements(block.body, { ...ctx, depth: ctx.depth + 1 });
|
|
1798
|
+
return [block];
|
|
1799
|
+
}
|
|
1800
|
+
function inlineHelper(call, ctx) {
|
|
1801
|
+
const fn = ctx.helpers.get(call.callee.name);
|
|
1802
|
+
if (!fn) return null;
|
|
1803
|
+
const params = supportedParams(fn);
|
|
1804
|
+
if (!params) return null;
|
|
1805
|
+
const bindings = resolveHelperBindings(call, params);
|
|
1806
|
+
if (!bindings) return null;
|
|
1807
|
+
const prov = {
|
|
1808
|
+
kind: "helper",
|
|
1809
|
+
fn: call.callee.name,
|
|
1810
|
+
callSite: ++ctx.site.n,
|
|
1811
|
+
sourceRange: rangeOf(call)
|
|
1812
|
+
};
|
|
1813
|
+
return expandBody(fn.body.body, bindings, prov, ctx);
|
|
1814
|
+
}
|
|
1815
|
+
function assignStep(update, resolve) {
|
|
1816
|
+
if (update.operator === "+=") return asNum(resolve(update.right));
|
|
1817
|
+
if (update.operator === "-=") {
|
|
1818
|
+
const s = asNum(resolve(update.right));
|
|
1819
|
+
return s === void 0 ? void 0 : -s;
|
|
1820
|
+
}
|
|
1821
|
+
if (update.operator === "=" && update.right?.type === "BinaryExpression") {
|
|
1822
|
+
return asNum(resolve(update.right.right));
|
|
1823
|
+
}
|
|
1824
|
+
return void 0;
|
|
1825
|
+
}
|
|
1826
|
+
function updatedVarName(update) {
|
|
1827
|
+
if (update?.type === "UpdateExpression") return update.argument?.name ?? null;
|
|
1828
|
+
if (update?.type === "AssignmentExpression") return update.left?.name ?? null;
|
|
1829
|
+
return null;
|
|
1830
|
+
}
|
|
1831
|
+
function loopStep(update, varName, resolve) {
|
|
1832
|
+
if (updatedVarName(update) !== varName) return void 0;
|
|
1833
|
+
if (update.type === "UpdateExpression") return update.operator === "++" ? 1 : -1;
|
|
1834
|
+
return assignStep(update, resolve);
|
|
1835
|
+
}
|
|
1836
|
+
function asNum(v) {
|
|
1837
|
+
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
1838
|
+
}
|
|
1839
|
+
function loopSatisfied(op, x, end) {
|
|
1840
|
+
if (op === "<") return x < end;
|
|
1841
|
+
if (op === "<=") return x <= end;
|
|
1842
|
+
if (op === ">") return x > end;
|
|
1843
|
+
if (op === ">=") return x >= end;
|
|
1844
|
+
return false;
|
|
1845
|
+
}
|
|
1846
|
+
function forInitVar(init) {
|
|
1847
|
+
if (init?.type !== "VariableDeclaration" || init.declarations?.length !== 1) return null;
|
|
1848
|
+
const d = init.declarations[0];
|
|
1849
|
+
return d.id?.type === "Identifier" ? { name: d.id.name, initExpr: d.init } : null;
|
|
1850
|
+
}
|
|
1851
|
+
function parseForHeader(stmt, resolve) {
|
|
1852
|
+
const iv = forInitVar(stmt.init);
|
|
1853
|
+
const test = stmt.test;
|
|
1854
|
+
if (!iv || test?.type !== "BinaryExpression" || test.left?.name !== iv.name) return null;
|
|
1855
|
+
const start = asNum(resolve(iv.initExpr));
|
|
1856
|
+
const end = asNum(resolve(test.right));
|
|
1857
|
+
const step = loopStep(stmt.update, iv.name, resolve);
|
|
1858
|
+
if (start === void 0 || end === void 0 || !step) return null;
|
|
1859
|
+
return { v: iv.name, start, end, op: test.operator, step };
|
|
1860
|
+
}
|
|
1861
|
+
function unrollFor(stmt, ctx) {
|
|
1862
|
+
const h = parseForHeader(stmt, ctx.resolve);
|
|
1863
|
+
if (!h) return null;
|
|
1864
|
+
const body = bodyStatements(stmt.body);
|
|
1865
|
+
const out = [];
|
|
1866
|
+
const site = ++ctx.site.n;
|
|
1867
|
+
let iteration = 0;
|
|
1868
|
+
for (let x = h.start; loopSatisfied(h.op, x, h.end); x += h.step) {
|
|
1869
|
+
if (iteration >= MAX_ITERS) return null;
|
|
1870
|
+
const prov = {
|
|
1871
|
+
kind: "loop",
|
|
1872
|
+
callSite: site,
|
|
1873
|
+
iteration,
|
|
1874
|
+
sourceRange: rangeOf(stmt)
|
|
1875
|
+
};
|
|
1876
|
+
out.push(...expandBody(body, /* @__PURE__ */ new Map([[h.v, numericLiteral(x)]]), prov, ctx));
|
|
1877
|
+
iteration++;
|
|
1878
|
+
}
|
|
1879
|
+
return out;
|
|
1880
|
+
}
|
|
1881
|
+
function forOfVarName(left) {
|
|
1882
|
+
if (left?.type === "VariableDeclaration") {
|
|
1883
|
+
const id = left.declarations?.[0]?.id;
|
|
1884
|
+
return id?.type === "Identifier" ? id.name : null;
|
|
1885
|
+
}
|
|
1886
|
+
return left?.type === "Identifier" ? left.name : null;
|
|
1887
|
+
}
|
|
1888
|
+
function unrollOverArray(elements, body, elName, idxName, range, ctx) {
|
|
1889
|
+
const out = [];
|
|
1890
|
+
const site = ++ctx.site.n;
|
|
1891
|
+
elements.forEach((el, i) => {
|
|
1892
|
+
if (!el) return;
|
|
1893
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
1894
|
+
if (elName) bindings.set(elName, el);
|
|
1895
|
+
if (idxName) bindings.set(idxName, numericLiteral(i));
|
|
1896
|
+
const prov = { kind: "loop", callSite: site, iteration: i, sourceRange: range };
|
|
1897
|
+
out.push(...expandBody(body, bindings, prov, ctx));
|
|
1898
|
+
});
|
|
1899
|
+
return out;
|
|
1900
|
+
}
|
|
1901
|
+
function unrollForOf(stmt, ctx) {
|
|
1902
|
+
if (stmt.right?.type !== "ArrayExpression") return null;
|
|
1903
|
+
const elName = forOfVarName(stmt.left);
|
|
1904
|
+
if (!elName) return null;
|
|
1905
|
+
return unrollOverArray(
|
|
1906
|
+
stmt.right.elements ?? [],
|
|
1907
|
+
bodyStatements(stmt.body),
|
|
1908
|
+
elName,
|
|
1909
|
+
null,
|
|
1910
|
+
rangeOf(stmt),
|
|
1911
|
+
ctx
|
|
1912
|
+
);
|
|
1913
|
+
}
|
|
1914
|
+
function callbackParamNames(cb) {
|
|
1915
|
+
const names = [];
|
|
1916
|
+
for (const p of [cb.params?.[0], cb.params?.[1]]) {
|
|
1917
|
+
if (!p) names.push(null);
|
|
1918
|
+
else if (p.type !== "Identifier") return null;
|
|
1919
|
+
else names.push(p.name);
|
|
1920
|
+
}
|
|
1921
|
+
return { el: names[0], idx: names[1] };
|
|
1922
|
+
}
|
|
1923
|
+
function isForEachCall(callee) {
|
|
1924
|
+
return callee?.type === "MemberExpression" && callee.property?.name === "forEach" && callee.object?.type === "ArrayExpression";
|
|
1925
|
+
}
|
|
1926
|
+
function forEachTarget(call) {
|
|
1927
|
+
if (!isForEachCall(call.callee)) return null;
|
|
1928
|
+
const cb = call.arguments?.[0];
|
|
1929
|
+
return isFunctionNode(cb) ? { elements: call.callee.object.elements ?? [], cb } : null;
|
|
1930
|
+
}
|
|
1931
|
+
function unrollForEach(call, ctx) {
|
|
1932
|
+
const target = forEachTarget(call);
|
|
1933
|
+
if (!target) return null;
|
|
1934
|
+
const params = callbackParamNames(target.cb);
|
|
1935
|
+
if (!params) return null;
|
|
1936
|
+
return unrollOverArray(
|
|
1937
|
+
target.elements,
|
|
1938
|
+
bodyStatements(target.cb.body),
|
|
1939
|
+
params.el,
|
|
1940
|
+
params.idx,
|
|
1941
|
+
rangeOf(call),
|
|
1942
|
+
ctx
|
|
1943
|
+
);
|
|
1944
|
+
}
|
|
1945
|
+
function expandCall(call, ctx) {
|
|
1946
|
+
if (call.callee?.type === "Identifier" && ctx.helpers.has(call.callee.name)) {
|
|
1947
|
+
return inlineHelper(call, ctx);
|
|
1948
|
+
}
|
|
1949
|
+
return unrollForEach(call, ctx);
|
|
1950
|
+
}
|
|
1951
|
+
function expandStatement(stmt, ctx) {
|
|
1952
|
+
if (ctx.depth >= MAX_DEPTH) return null;
|
|
1953
|
+
if (stmt.type === "ForStatement") return unrollFor(stmt, ctx);
|
|
1954
|
+
if (stmt.type === "ForOfStatement") return unrollForOf(stmt, ctx);
|
|
1955
|
+
if (stmt.type === "ExpressionStatement" && stmt.expression?.type === "CallExpression") {
|
|
1956
|
+
return expandCall(stmt.expression, ctx);
|
|
1957
|
+
}
|
|
1958
|
+
return null;
|
|
1959
|
+
}
|
|
1960
|
+
function expandStatements(stmts, ctx) {
|
|
1961
|
+
const out = [];
|
|
1962
|
+
for (const stmt of stmts) {
|
|
1963
|
+
const expanded = expandStatement(stmt, ctx);
|
|
1964
|
+
if (expanded) out.push(...expanded);
|
|
1965
|
+
else out.push(stmt);
|
|
1966
|
+
}
|
|
1967
|
+
return out;
|
|
1968
|
+
}
|
|
1969
|
+
function inlineComputedTimelines(ast, timelineVar, resolve) {
|
|
1970
|
+
const helpers = collectInlinableHelpers(ast, timelineVar);
|
|
1971
|
+
const ctx = {
|
|
1972
|
+
helpers,
|
|
1973
|
+
timelineVar,
|
|
1974
|
+
resolve,
|
|
1975
|
+
depth: 0,
|
|
1976
|
+
site: { n: 0 },
|
|
1977
|
+
order: { n: 0 },
|
|
1978
|
+
rootStart: 0
|
|
1979
|
+
};
|
|
1980
|
+
const body = (ast.body ?? []).filter((stmt) => !isHelperDecl(stmt, helpers));
|
|
1981
|
+
ast.body = body.flatMap((stmt) => {
|
|
1982
|
+
ctx.rootStart = stmt.start;
|
|
1983
|
+
return expandStatements([stmt], ctx);
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
var GSAP_METHODS2 = /* @__PURE__ */ new Set(["set", "to", "from", "fromTo"]);
|
|
1987
|
+
var QUERY_METHODS = /* @__PURE__ */ new Set(["querySelector", "querySelectorAll"]);
|
|
1988
|
+
var ITERATION_METHODS = /* @__PURE__ */ new Set(["forEach", "map"]);
|
|
1989
|
+
var SCOPE_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
1990
|
+
"Program",
|
|
1991
|
+
"BlockStatement",
|
|
1992
|
+
"FunctionDeclaration",
|
|
1993
|
+
"FunctionExpression",
|
|
1994
|
+
"ArrowFunctionExpression"
|
|
1995
|
+
]);
|
|
1996
|
+
function parseProgram(script) {
|
|
1997
|
+
try {
|
|
1998
|
+
return parse(script, {
|
|
1999
|
+
ecmaVersion: "latest",
|
|
2000
|
+
sourceType: "script",
|
|
2001
|
+
locations: true
|
|
2002
|
+
});
|
|
2003
|
+
} catch {
|
|
2004
|
+
return parse(script, {
|
|
2005
|
+
ecmaVersion: "latest",
|
|
2006
|
+
sourceType: "module",
|
|
2007
|
+
locations: true
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
var CONST_NODES = /* @__PURE__ */ Symbol("hf.constNodes");
|
|
2012
|
+
function constNodesOf(scope) {
|
|
2013
|
+
return scope[CONST_NODES];
|
|
2014
|
+
}
|
|
2015
|
+
var MATH_FNS = /* @__PURE__ */ new Set(["min", "max", "round", "floor", "ceil", "abs", "sqrt", "sign", "trunc"]);
|
|
2016
|
+
var MATH_CONSTS = { PI: Math.PI, E: Math.E, SQRT2: Math.SQRT2 };
|
|
2017
|
+
function resolveMemberNode(node, scope) {
|
|
2018
|
+
if (node.object?.type === "Identifier" && node.object.name === "Math") {
|
|
2019
|
+
const key = node.property?.name;
|
|
2020
|
+
return typeof key === "string" ? MATH_CONSTS[key] : void 0;
|
|
2021
|
+
}
|
|
2022
|
+
const objNode = resolveConstNode(node.object, scope);
|
|
2023
|
+
if (!objNode) return void 0;
|
|
2024
|
+
let valueNode;
|
|
2025
|
+
if (node.computed) {
|
|
2026
|
+
const idx = resolveNode(node.property, scope);
|
|
2027
|
+
if (objNode.type === "ArrayExpression" && typeof idx === "number") {
|
|
2028
|
+
valueNode = objNode.elements?.[idx];
|
|
2029
|
+
} else if (objNode.type === "ObjectExpression" && (typeof idx === "string" || typeof idx === "number")) {
|
|
2030
|
+
valueNode = findPropertyNode(objNode, String(idx));
|
|
2031
|
+
}
|
|
2032
|
+
} else if (objNode.type === "ObjectExpression") {
|
|
2033
|
+
valueNode = findPropertyNode(objNode, node.property?.name ?? node.property?.value);
|
|
2034
|
+
}
|
|
2035
|
+
return valueNode ? resolveNode(valueNode, scope) : void 0;
|
|
2036
|
+
}
|
|
2037
|
+
function resolveConstMember(objNode, node, scope) {
|
|
2038
|
+
if (!node.computed) {
|
|
2039
|
+
return objNode.type === "ObjectExpression" ? findPropertyNode(objNode, node.property?.name ?? node.property?.value) : void 0;
|
|
2040
|
+
}
|
|
2041
|
+
const idx = resolveNode(node.property, scope);
|
|
2042
|
+
if (objNode.type === "ArrayExpression" && typeof idx === "number") return objNode.elements?.[idx];
|
|
2043
|
+
if (objNode.type === "ObjectExpression") return findPropertyNode(objNode, String(idx));
|
|
2044
|
+
return void 0;
|
|
2045
|
+
}
|
|
2046
|
+
function resolveConstNode(node, scope) {
|
|
2047
|
+
if (!node) return void 0;
|
|
2048
|
+
if (node.type === "ArrayExpression" || node.type === "ObjectExpression") return node;
|
|
2049
|
+
if (node.type === "Identifier") return constNodesOf(scope)?.get(node.name);
|
|
2050
|
+
if (node.type !== "MemberExpression") return void 0;
|
|
2051
|
+
const objNode = resolveConstNode(node.object, scope);
|
|
2052
|
+
return objNode ? resolveConstMember(objNode, node, scope) : void 0;
|
|
2053
|
+
}
|
|
2054
|
+
function resolveNode(node, scope) {
|
|
2055
|
+
if (!node) return void 0;
|
|
2056
|
+
if (node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number")
|
|
2057
|
+
return node.value;
|
|
2058
|
+
if (node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string")
|
|
2059
|
+
return node.value;
|
|
2060
|
+
if (node.type === "BooleanLiteral" || node.type === "Literal" && typeof node.value === "boolean")
|
|
2061
|
+
return node.value;
|
|
2062
|
+
if (node.type === "UnaryExpression" && node.operator === "-" && node.argument) {
|
|
2063
|
+
const val = resolveNode(node.argument, scope);
|
|
2064
|
+
return typeof val === "number" ? -val : void 0;
|
|
2065
|
+
}
|
|
2066
|
+
if (node.type === "BinaryExpression") {
|
|
2067
|
+
const left = resolveNode(node.left, scope);
|
|
2068
|
+
const right = resolveNode(node.right, scope);
|
|
2069
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
2070
|
+
switch (node.operator) {
|
|
2071
|
+
case "+":
|
|
2072
|
+
return left + right;
|
|
2073
|
+
case "-":
|
|
2074
|
+
return left - right;
|
|
2075
|
+
case "*":
|
|
2076
|
+
return left * right;
|
|
2077
|
+
case "/":
|
|
2078
|
+
return right !== 0 ? left / right : void 0;
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
if (typeof left === "string" && node.operator === "+") return left + String(right ?? "");
|
|
2082
|
+
if (typeof right === "string" && node.operator === "+") return String(left ?? "") + right;
|
|
2083
|
+
}
|
|
2084
|
+
if (node.type === "Identifier" && scope.has(node.name)) {
|
|
2085
|
+
return scope.get(node.name);
|
|
2086
|
+
}
|
|
2087
|
+
if (node.type === "TemplateLiteral" && node.expressions?.length === 0) {
|
|
2088
|
+
return node.quasis?.[0]?.value?.cooked ?? void 0;
|
|
2089
|
+
}
|
|
2090
|
+
if (node.type === "MemberExpression") {
|
|
2091
|
+
return resolveMemberNode(node, scope);
|
|
2092
|
+
}
|
|
2093
|
+
if (node.type === "CallExpression" && node.callee?.type === "MemberExpression" && node.callee.object?.type === "Identifier" && node.callee.object.name === "Math" && MATH_FNS.has(node.callee.property?.name)) {
|
|
2094
|
+
const args = (node.arguments ?? []).map((a) => resolveNode(a, scope));
|
|
2095
|
+
if (args.every((a) => typeof a === "number")) {
|
|
2096
|
+
return Math[node.callee.property.name](...args);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
return void 0;
|
|
2100
|
+
}
|
|
2101
|
+
function extractLiteralValue(node, scope) {
|
|
2102
|
+
return resolveNode(node, scope);
|
|
2103
|
+
}
|
|
2104
|
+
function selectorFromQueryCall(node, scope) {
|
|
2105
|
+
if (node?.type !== "CallExpression") return null;
|
|
2106
|
+
const callee = node.callee;
|
|
2107
|
+
if (callee?.type !== "MemberExpression" || callee.property?.type !== "Identifier") return null;
|
|
2108
|
+
const method = callee.property.name;
|
|
2109
|
+
const argValue = resolveNode(node.arguments?.[0], scope);
|
|
2110
|
+
if (typeof argValue !== "string" || argValue.length === 0) return null;
|
|
2111
|
+
if (QUERY_METHODS.has(method) || method === "toArray") return argValue;
|
|
2112
|
+
if (method === "getElementById") return `#${argValue}`;
|
|
2113
|
+
return null;
|
|
2114
|
+
}
|
|
2115
|
+
function enclosingScopeNodeFromAncestors(ancestors, includeBlocks = true) {
|
|
2116
|
+
for (let i = ancestors.length - 2; i >= 0; i--) {
|
|
2117
|
+
const node = ancestors[i];
|
|
2118
|
+
if (node && SCOPE_NODE_TYPES.has(node.type) && (includeBlocks || node.type !== "BlockStatement")) {
|
|
2119
|
+
return node;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
return null;
|
|
2123
|
+
}
|
|
2124
|
+
function scopeChainFromAncestors(ancestors) {
|
|
2125
|
+
const chain = [];
|
|
2126
|
+
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
2127
|
+
const node = ancestors[i];
|
|
2128
|
+
if (node && SCOPE_NODE_TYPES.has(node.type)) chain.push(node);
|
|
2129
|
+
}
|
|
2130
|
+
return chain;
|
|
2131
|
+
}
|
|
2132
|
+
function nearestExpandedScopeFromAncestors(ancestors) {
|
|
2133
|
+
for (let index = ancestors.length - 2; index >= 0; index--) {
|
|
2134
|
+
const candidate = ancestors[index];
|
|
2135
|
+
if (candidate?.type === "BlockStatement" && readProvenance(candidate)) return candidate;
|
|
2136
|
+
}
|
|
2137
|
+
return void 0;
|
|
2138
|
+
}
|
|
2139
|
+
function findVisibleIdentifierDeclaration(name, ancestors, index, usageStart = Number.POSITIVE_INFINITY) {
|
|
2140
|
+
const declarations = index.declarationsByName.get(name) ?? [];
|
|
2141
|
+
const expandedScopeNode = nearestExpandedScopeFromAncestors(ancestors);
|
|
2142
|
+
for (const scopeNode of scopeChainFromAncestors(ancestors)) {
|
|
2143
|
+
const candidates = declarations.filter(
|
|
2144
|
+
(declaration) => declaration.scopeNode === scopeNode && (!declaration.expandedScopeNode || declaration.expandedScopeNode === expandedScopeNode) && (declaration.kind === "var" || declaration.kind === "param" || declaration.node.start < usageStart)
|
|
2145
|
+
).sort((left, right) => right.node.start - left.node.start);
|
|
2146
|
+
if (candidates[0]) return candidates[0];
|
|
2147
|
+
}
|
|
2148
|
+
return void 0;
|
|
2149
|
+
}
|
|
2150
|
+
function collectIdentifierBindingIndex(ast) {
|
|
2151
|
+
const declarationsByName = /* @__PURE__ */ new Map();
|
|
2152
|
+
const reassignedDeclarations = /* @__PURE__ */ new Set();
|
|
2153
|
+
ancestor(ast, {
|
|
2154
|
+
VariableDeclarator(node, _, ancestors) {
|
|
2155
|
+
const name = node.id?.name;
|
|
2156
|
+
if (!name) return;
|
|
2157
|
+
const declaration = ancestors.at(-2);
|
|
2158
|
+
const kind = declaration?.kind;
|
|
2159
|
+
if (!kind) return;
|
|
2160
|
+
const includeBlocks = declaration?.type !== "VariableDeclaration" || kind !== "var";
|
|
2161
|
+
const scopeNode = enclosingScopeNodeFromAncestors(ancestors, includeBlocks);
|
|
2162
|
+
const expandedScopeNode = nearestExpandedScopeFromAncestors(ancestors);
|
|
2163
|
+
const entries = declarationsByName.get(name) ?? [];
|
|
2164
|
+
entries.push({ node, scopeNode, expandedScopeNode, name, kind });
|
|
2165
|
+
declarationsByName.set(name, entries);
|
|
2166
|
+
},
|
|
2167
|
+
FunctionDeclaration: indexFunctionParameters,
|
|
2168
|
+
FunctionExpression: indexFunctionParameters,
|
|
2169
|
+
ArrowFunctionExpression: indexFunctionParameters
|
|
2170
|
+
});
|
|
2171
|
+
const index = { declarationsByName, reassignedDeclarations };
|
|
2172
|
+
ancestor(ast, {
|
|
2173
|
+
AssignmentExpression(node, _, ancestors) {
|
|
2174
|
+
const name = node.left?.type === "Identifier" ? node.left.name : void 0;
|
|
2175
|
+
if (!name) return;
|
|
2176
|
+
const declaration = findVisibleIdentifierDeclaration(name, ancestors, index, node.start);
|
|
2177
|
+
if (declaration) reassignedDeclarations.add(declaration.node);
|
|
2178
|
+
}
|
|
2179
|
+
});
|
|
2180
|
+
return index;
|
|
2181
|
+
function indexFunctionParameters(node) {
|
|
2182
|
+
for (const parameter of node.params ?? []) {
|
|
2183
|
+
if (parameter?.type !== "Identifier") continue;
|
|
2184
|
+
const entries = declarationsByName.get(parameter.name) ?? [];
|
|
2185
|
+
entries.push({ node: parameter, scopeNode: node, name: parameter.name, kind: "param" });
|
|
2186
|
+
declarationsByName.set(parameter.name, entries);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
function addBinding(bindings, scopeNode, name, selector) {
|
|
2191
|
+
let scoped = bindings.get(scopeNode);
|
|
2192
|
+
if (!scoped) {
|
|
2193
|
+
scoped = /* @__PURE__ */ new Map();
|
|
2194
|
+
bindings.set(scopeNode, scoped);
|
|
2195
|
+
}
|
|
2196
|
+
if (!scoped.has(name)) scoped.set(name, selector);
|
|
2197
|
+
}
|
|
2198
|
+
function lookupBindingFromAncestors(name, ancestors, bindings) {
|
|
2199
|
+
for (const scopeNode of scopeChainFromAncestors(ancestors)) {
|
|
2200
|
+
const selector = bindings.get(scopeNode)?.get(name);
|
|
2201
|
+
if (selector !== void 0) return selector;
|
|
2202
|
+
}
|
|
2203
|
+
return bindings.get(null)?.get(name) ?? null;
|
|
2204
|
+
}
|
|
2205
|
+
function isFunctionNode2(node) {
|
|
2206
|
+
return node?.type === "ArrowFunctionExpression" || node?.type === "FunctionExpression" || node?.type === "FunctionDeclaration";
|
|
2207
|
+
}
|
|
2208
|
+
function resolveCollectionSelector(node, ancestors, scope, bindings) {
|
|
2209
|
+
if (node?.type === "Identifier")
|
|
2210
|
+
return lookupBindingFromAncestors(node.name, ancestors, bindings);
|
|
2211
|
+
if (node?.type === "CallExpression") return selectorFromQueryCall(node, scope);
|
|
2212
|
+
return null;
|
|
2213
|
+
}
|
|
2214
|
+
function collectScopeBindings(ast) {
|
|
2215
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
2216
|
+
const ambiguousBindings = /* @__PURE__ */ new Set();
|
|
2217
|
+
const constNodes = /* @__PURE__ */ new Map();
|
|
2218
|
+
Object.defineProperty(bindings, CONST_NODES, { value: constNodes, enumerable: false });
|
|
2219
|
+
simple(ast, {
|
|
2220
|
+
VariableDeclarator(node) {
|
|
2221
|
+
const name = node.id?.name;
|
|
2222
|
+
const init = node.init;
|
|
2223
|
+
if (!name || !init) return;
|
|
2224
|
+
if (init.type === "ArrayExpression" || init.type === "ObjectExpression") {
|
|
2225
|
+
constNodes.set(name, init);
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2228
|
+
const val = resolveNode(init, bindings);
|
|
2229
|
+
if (val === void 0 || ambiguousBindings.has(name)) return;
|
|
2230
|
+
const existing = bindings.get(name);
|
|
2231
|
+
if (existing !== void 0 && existing !== val) {
|
|
2232
|
+
bindings.delete(name);
|
|
2233
|
+
ambiguousBindings.add(name);
|
|
2234
|
+
} else if (existing === void 0) {
|
|
2235
|
+
bindings.set(name, val);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
});
|
|
2239
|
+
return bindings;
|
|
2240
|
+
}
|
|
2241
|
+
function collectTargetBindings(ast, scope, identifierBindings) {
|
|
2242
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
2243
|
+
ancestor(ast, {
|
|
2244
|
+
VariableDeclarator(node, _, ancestors) {
|
|
2245
|
+
const name = node.id?.name;
|
|
2246
|
+
const selector = selectorFromQueryCall(node.init, scope);
|
|
2247
|
+
if (name && selector !== null) {
|
|
2248
|
+
const declaration = ancestors.at(-2);
|
|
2249
|
+
const includeBlocks = declaration?.type !== "VariableDeclaration" || declaration.kind !== "var";
|
|
2250
|
+
addBinding(
|
|
2251
|
+
bindings,
|
|
2252
|
+
enclosingScopeNodeFromAncestors(ancestors, includeBlocks),
|
|
2253
|
+
name,
|
|
2254
|
+
selector
|
|
2255
|
+
);
|
|
2256
|
+
}
|
|
2257
|
+
},
|
|
2258
|
+
AssignmentExpression(node, _, ancestors) {
|
|
2259
|
+
const left = node.left;
|
|
2260
|
+
const selector = selectorFromQueryCall(node.right, scope);
|
|
2261
|
+
if (left?.type === "Identifier" && selector !== null) {
|
|
2262
|
+
const declaration = findVisibleIdentifierDeclaration(
|
|
2263
|
+
left.name,
|
|
2264
|
+
ancestors,
|
|
2265
|
+
identifierBindings,
|
|
2266
|
+
node.start
|
|
2267
|
+
);
|
|
2268
|
+
addBinding(
|
|
2269
|
+
bindings,
|
|
2270
|
+
declaration?.scopeNode ?? nearestExpandedScopeFromAncestors(ancestors) ?? enclosingScopeNodeFromAncestors(ancestors),
|
|
2271
|
+
left.name,
|
|
2272
|
+
selector
|
|
2273
|
+
);
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2277
|
+
ancestor(ast, {
|
|
2278
|
+
// fallow-ignore-next-line complexity
|
|
2279
|
+
CallExpression(node, _, ancestors) {
|
|
2280
|
+
const callee = node.callee;
|
|
2281
|
+
if (callee?.type === "MemberExpression" && callee.property?.type === "Identifier" && ITERATION_METHODS.has(callee.property.name)) {
|
|
2282
|
+
const collectionSelector = resolveCollectionSelector(
|
|
2283
|
+
callee.object,
|
|
2284
|
+
ancestors,
|
|
2285
|
+
scope,
|
|
2286
|
+
bindings
|
|
2287
|
+
);
|
|
2288
|
+
const fn = node.arguments?.[0];
|
|
2289
|
+
const param = fn?.params?.[0];
|
|
2290
|
+
if (collectionSelector && param?.type === "Identifier" && isFunctionNode2(fn)) {
|
|
2291
|
+
addBinding(bindings, fn, param.name, collectionSelector);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
});
|
|
2296
|
+
const COLLECTION_ALIAS_METHODS = /* @__PURE__ */ new Set(["slice", "filter", "concat", "reverse"]);
|
|
2297
|
+
ancestor(ast, {
|
|
2298
|
+
// fallow-ignore-next-line complexity
|
|
2299
|
+
VariableDeclarator(node, _, ancestors) {
|
|
2300
|
+
const name = node.id?.name;
|
|
2301
|
+
const init = node.init;
|
|
2302
|
+
if (!name || !init) return;
|
|
2303
|
+
let sourceVar;
|
|
2304
|
+
if (init.type === "MemberExpression" && init.object?.type === "Identifier") {
|
|
2305
|
+
sourceVar = init.object.name;
|
|
2306
|
+
} else if (init.type === "CallExpression" && init.callee?.type === "MemberExpression" && init.callee.object?.type === "Identifier" && init.callee.property?.type === "Identifier" && COLLECTION_ALIAS_METHODS.has(init.callee.property.name)) {
|
|
2307
|
+
sourceVar = init.callee.object.name;
|
|
2308
|
+
}
|
|
2309
|
+
if (!sourceVar) return;
|
|
2310
|
+
const selector = lookupBindingFromAncestors(sourceVar, ancestors, bindings);
|
|
2311
|
+
if (selector)
|
|
2312
|
+
addBinding(bindings, enclosingScopeNodeFromAncestors(ancestors), name, selector);
|
|
2313
|
+
}
|
|
2314
|
+
});
|
|
2315
|
+
return bindings;
|
|
2316
|
+
}
|
|
2317
|
+
function resolveTargetSelector(node, ancestors, scope, bindings) {
|
|
2318
|
+
if (!node) return null;
|
|
2319
|
+
if (node.type === "StringLiteral" || node.type === "Literal") {
|
|
2320
|
+
return typeof node.value === "string" ? node.value : null;
|
|
2321
|
+
}
|
|
2322
|
+
if (node.type === "Identifier") {
|
|
2323
|
+
return lookupBindingFromAncestors(node.name, ancestors, bindings);
|
|
2324
|
+
}
|
|
2325
|
+
if (node.type === "CallExpression") {
|
|
2326
|
+
return selectorFromQueryCall(node, scope);
|
|
2327
|
+
}
|
|
2328
|
+
if (node.type === "ArrayExpression") {
|
|
2329
|
+
const parts = node.elements.map((el) => resolveTargetSelector(el, ancestors, scope, bindings)).filter((s) => typeof s === "string" && s.length > 0);
|
|
2330
|
+
return parts.length > 0 ? parts.join(", ") : null;
|
|
2331
|
+
}
|
|
2332
|
+
if (node.type === "MemberExpression" && node.object?.type === "Identifier") {
|
|
2333
|
+
return lookupBindingFromAncestors(node.object.name, ancestors, bindings);
|
|
2334
|
+
}
|
|
2335
|
+
return null;
|
|
2336
|
+
}
|
|
2337
|
+
function hasUnresolvedArrayPart(node, ancestors, scope, bindings) {
|
|
2338
|
+
return node?.type === "ArrayExpression" && node.elements.some(
|
|
2339
|
+
(el) => !resolveTargetSelector(el, ancestors, scope, bindings) || hasUnresolvedArrayPart(el, ancestors, scope, bindings)
|
|
2340
|
+
);
|
|
2341
|
+
}
|
|
2342
|
+
function describeProxyTarget(targetNode, varsNode, scope) {
|
|
2343
|
+
const objNode = targetNode?.type === "ObjectExpression" ? targetNode : targetNode?.type === "Identifier" ? resolveConstNode(targetNode, scope) : void 0;
|
|
2344
|
+
if (objNode?.type !== "ObjectExpression") return null;
|
|
2345
|
+
const onUpdate = findPropertyNode(varsNode, "onUpdate");
|
|
2346
|
+
const driven = onUpdate ? drivenDomChannel(onUpdate) : void 0;
|
|
2347
|
+
if (driven) return `proxy \u2192 ${driven}`;
|
|
2348
|
+
return "dwell/hold";
|
|
2349
|
+
}
|
|
2350
|
+
function isStyleAssignmentTarget(left) {
|
|
2351
|
+
return left?.type === "MemberExpression" && left.object?.type === "MemberExpression" && left.object.property?.name === "style" && !!left.property?.name;
|
|
2352
|
+
}
|
|
2353
|
+
function drivenDomChannel(fnNode) {
|
|
2354
|
+
let found;
|
|
2355
|
+
simple(fnNode, {
|
|
2356
|
+
CallExpression(node) {
|
|
2357
|
+
if (node.callee?.type === "MemberExpression" && node.callee.property?.name === "setAttribute" && typeof node.arguments?.[0]?.value === "string") {
|
|
2358
|
+
found ??= node.arguments[0].value;
|
|
2359
|
+
}
|
|
2360
|
+
},
|
|
2361
|
+
AssignmentExpression(node) {
|
|
2362
|
+
const left = node.left;
|
|
2363
|
+
if (isStyleAssignmentTarget(left)) found ??= `style.${left.property.name}`;
|
|
2364
|
+
}
|
|
2365
|
+
});
|
|
2366
|
+
return found;
|
|
2367
|
+
}
|
|
2368
|
+
function isObjectProperty(prop) {
|
|
2369
|
+
return prop?.type === "ObjectProperty" || prop?.type === "Property";
|
|
2370
|
+
}
|
|
2371
|
+
function propKeyName(prop) {
|
|
2372
|
+
return prop?.key?.name ?? prop?.key?.value;
|
|
2373
|
+
}
|
|
2374
|
+
function findPropertyNode(varsArgNode, key) {
|
|
2375
|
+
if (varsArgNode?.type !== "ObjectExpression") return void 0;
|
|
2376
|
+
for (const prop of varsArgNode.properties ?? []) {
|
|
2377
|
+
if (!isObjectProperty(prop)) continue;
|
|
2378
|
+
if (propKeyName(prop) === key) return prop.value;
|
|
2379
|
+
}
|
|
2380
|
+
return void 0;
|
|
2381
|
+
}
|
|
2382
|
+
function extractRawPropertySource(varsArgNode, key, source) {
|
|
2383
|
+
const node = findPropertyNode(varsArgNode, key);
|
|
2384
|
+
return node ? source.slice(node.start, node.end) : void 0;
|
|
2385
|
+
}
|
|
2386
|
+
function objectExpressionToRecord(node, scope, source) {
|
|
2387
|
+
const result = {};
|
|
2388
|
+
if (node?.type !== "ObjectExpression") return result;
|
|
2389
|
+
for (const prop of node.properties ?? []) {
|
|
2390
|
+
if (!isObjectProperty(prop)) continue;
|
|
2391
|
+
const key = prop.key?.name ?? prop.key?.value;
|
|
2392
|
+
if (!key) continue;
|
|
2393
|
+
const resolved = resolveNode(prop.value, scope);
|
|
2394
|
+
if (resolved !== void 0) {
|
|
2395
|
+
result[key] = resolved;
|
|
2396
|
+
} else {
|
|
2397
|
+
result[key] = `__raw:${source.slice(prop.value.start, prop.value.end)}`;
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
return result;
|
|
2401
|
+
}
|
|
2402
|
+
function isGsapTimelineCall(node) {
|
|
2403
|
+
return node?.type === "CallExpression" && node.callee?.type === "MemberExpression" && node.callee.object?.name === "gsap" && node.callee.property?.name === "timeline";
|
|
2404
|
+
}
|
|
2405
|
+
function hasUnknownDuration(varsNode, scope) {
|
|
2406
|
+
if (!varsNode) return false;
|
|
2407
|
+
if (varsNode.type !== "ObjectExpression") return true;
|
|
2408
|
+
const props = varsNode.properties ?? [];
|
|
2409
|
+
if (props.some((p) => p.type === "SpreadElement")) return true;
|
|
2410
|
+
const prop = props.find((p) => isObjectProperty(p) && propKeyName(p) === "duration");
|
|
2411
|
+
return prop !== void 0 && typeof resolveNode(prop.value, scope) !== "number";
|
|
2412
|
+
}
|
|
2413
|
+
function staticMemberKey(node) {
|
|
2414
|
+
if (!node || node.type !== "MemberExpression") return null;
|
|
2415
|
+
if (node.computed) {
|
|
2416
|
+
const p = node.property;
|
|
2417
|
+
if (p?.type === "Literal" && typeof p.value === "string") return p.value;
|
|
2418
|
+
return null;
|
|
2419
|
+
}
|
|
2420
|
+
return node.property?.type === "Identifier" ? node.property.name : null;
|
|
2421
|
+
}
|
|
2422
|
+
function isStaticMemberRef(node) {
|
|
2423
|
+
return node?.type === "MemberExpression" && staticMemberKey(node) !== null;
|
|
2424
|
+
}
|
|
2425
|
+
function sameMemberAccess(a, b) {
|
|
2426
|
+
if (a?.type !== "MemberExpression" || b?.type !== "MemberExpression") return false;
|
|
2427
|
+
if (staticMemberKey(a) !== staticMemberKey(b) || staticMemberKey(a) === null) return false;
|
|
2428
|
+
const ao = a.object;
|
|
2429
|
+
const bo = b.object;
|
|
2430
|
+
if (ao?.type === "Identifier" && bo?.type === "Identifier") return ao.name === bo.name;
|
|
2431
|
+
if (ao?.type === "MemberExpression" && bo?.type === "MemberExpression")
|
|
2432
|
+
return sameMemberAccess(ao, bo);
|
|
2433
|
+
return false;
|
|
2434
|
+
}
|
|
2435
|
+
function timelineRootSource(ref, script) {
|
|
2436
|
+
return ref.kind === "identifier" ? ref.name : script.slice(ref.node.start, ref.node.end);
|
|
2437
|
+
}
|
|
2438
|
+
function escapeRegExp(s) {
|
|
2439
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2440
|
+
}
|
|
2441
|
+
function extractTimelineDefaults(callNode, scope) {
|
|
2442
|
+
const arg = callNode.arguments?.[0];
|
|
2443
|
+
if (!arg || arg.type !== "ObjectExpression") return void 0;
|
|
2444
|
+
const defaultsProp = arg.properties?.find(
|
|
2445
|
+
(p) => isObjectProperty(p) && propKeyName(p) === "defaults"
|
|
2446
|
+
);
|
|
2447
|
+
if (!defaultsProp?.value || defaultsProp.value.type !== "ObjectExpression") return void 0;
|
|
2448
|
+
const result = {};
|
|
2449
|
+
for (const prop of defaultsProp.value.properties ?? []) {
|
|
2450
|
+
if (!isObjectProperty(prop)) continue;
|
|
2451
|
+
const key = propKeyName(prop);
|
|
2452
|
+
const val = resolveNode(prop.value, scope);
|
|
2453
|
+
if (key === "ease" && typeof val === "string") result.ease = val;
|
|
2454
|
+
if (key === "duration") {
|
|
2455
|
+
if (typeof val === "number") result.duration = val;
|
|
2456
|
+
else result.durationUnresolved = true;
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
2460
|
+
}
|
|
2461
|
+
function findTimelineVar(ast, scope) {
|
|
2462
|
+
let timelineVar = null;
|
|
2463
|
+
let ref = null;
|
|
2464
|
+
let timelineCount = 0;
|
|
2465
|
+
let defaults;
|
|
2466
|
+
const emptyScope = scope ?? /* @__PURE__ */ new Map();
|
|
2467
|
+
simple(ast, {
|
|
2468
|
+
VariableDeclarator(node) {
|
|
2469
|
+
if (isGsapTimelineCall(node.init)) {
|
|
2470
|
+
timelineCount += 1;
|
|
2471
|
+
if (!ref && node.id?.type === "Identifier") {
|
|
2472
|
+
timelineVar = node.id.name;
|
|
2473
|
+
ref = { kind: "identifier", name: node.id.name };
|
|
2474
|
+
defaults = extractTimelineDefaults(node.init, emptyScope);
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
},
|
|
2478
|
+
AssignmentExpression(node) {
|
|
2479
|
+
if (isGsapTimelineCall(node.right)) {
|
|
2480
|
+
timelineCount += 1;
|
|
2481
|
+
if (!ref) {
|
|
2482
|
+
const left = node.left;
|
|
2483
|
+
if (left?.type === "Identifier") {
|
|
2484
|
+
timelineVar = left.name;
|
|
2485
|
+
ref = { kind: "identifier", name: left.name };
|
|
2486
|
+
defaults = extractTimelineDefaults(node.right, emptyScope);
|
|
2487
|
+
} else if (isStaticMemberRef(left)) {
|
|
2488
|
+
ref = { kind: "member", node: left };
|
|
2489
|
+
defaults = extractTimelineDefaults(node.right, emptyScope);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
});
|
|
2495
|
+
return { timelineVar, ref, timelineCount, defaults };
|
|
2496
|
+
}
|
|
2497
|
+
function isTimelineRootedCall(callNode, ref) {
|
|
2498
|
+
let obj = callNode.callee?.object;
|
|
2499
|
+
while (obj?.type === "CallExpression") {
|
|
2500
|
+
obj = obj.callee?.object;
|
|
2501
|
+
}
|
|
2502
|
+
if (ref.kind === "identifier") return obj?.type === "Identifier" && obj.name === ref.name;
|
|
2503
|
+
return sameMemberAccess(obj, ref.node);
|
|
2504
|
+
}
|
|
2505
|
+
function findAllTweenCalls(ast, ref, scope, targetBindings) {
|
|
2506
|
+
const results = [];
|
|
2507
|
+
function visit(node, ancestors) {
|
|
2508
|
+
if (!node || typeof node !== "object") return;
|
|
2509
|
+
const nodeAncestors = [...ancestors, node];
|
|
2510
|
+
if (node.type === "CallExpression") {
|
|
2511
|
+
const callee = node.callee;
|
|
2512
|
+
const gsapSetArg = node.arguments?.[0];
|
|
2513
|
+
const isGlobalSet = callee?.type === "MemberExpression" && callee.object?.type === "Identifier" && callee.object.name === "gsap" && callee.property?.type === "Identifier" && callee.property.name === "set" && (gsapSetArg?.type === "StringLiteral" || gsapSetArg?.type === "Literal" && typeof gsapSetArg.value === "string");
|
|
2514
|
+
if (callee?.type === "MemberExpression" && callee.property?.type === "Identifier" && (isTimelineRootedCall(node, ref) || isGlobalSet) && GSAP_METHODS2.has(callee.property.name)) {
|
|
2515
|
+
const method = callee.property.name;
|
|
2516
|
+
const args = node.arguments;
|
|
2517
|
+
const selectorValue = args.length >= 1 ? resolveTargetSelector(args[0], nodeAncestors, scope, targetBindings) ?? "__unresolved__" : "__unresolved__";
|
|
2518
|
+
const partial = hasUnresolvedArrayPart(args[0], nodeAncestors, scope, targetBindings) ? { selectorPartial: true } : {};
|
|
2519
|
+
if (method === "fromTo" && args.length >= 3) {
|
|
2520
|
+
results.push({
|
|
2521
|
+
node,
|
|
2522
|
+
ancestors: nodeAncestors,
|
|
2523
|
+
method: "fromTo",
|
|
2524
|
+
selector: selectorValue,
|
|
2525
|
+
...partial,
|
|
2526
|
+
fromArg: args[1],
|
|
2527
|
+
varsArg: args[2],
|
|
2528
|
+
positionArg: args[3]
|
|
2529
|
+
});
|
|
2530
|
+
} else if (method !== "fromTo" && args.length >= 2) {
|
|
2531
|
+
results.push({
|
|
2532
|
+
node,
|
|
2533
|
+
ancestors: nodeAncestors,
|
|
2534
|
+
method,
|
|
2535
|
+
selector: selectorValue,
|
|
2536
|
+
...partial,
|
|
2537
|
+
varsArg: args[1],
|
|
2538
|
+
positionArg: args[2],
|
|
2539
|
+
...isGlobalSet ? { global: true } : {}
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
for (const key of Object.keys(node)) {
|
|
2545
|
+
if (key === "type" || key === "start" || key === "end" || key === "loc") continue;
|
|
2546
|
+
const child = node[key];
|
|
2547
|
+
if (Array.isArray(child)) {
|
|
2548
|
+
for (const item of child) {
|
|
2549
|
+
if (item && typeof item === "object" && item.type) visit(item, nodeAncestors);
|
|
2550
|
+
}
|
|
2551
|
+
} else if (child && typeof child === "object" && child.type) {
|
|
2552
|
+
visit(child, nodeAncestors);
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
visit(ast, []);
|
|
2557
|
+
return results;
|
|
2558
|
+
}
|
|
2559
|
+
var PERCENTAGE_KEY_RE = /^(\d+(?:\.\d+)?)%$/;
|
|
2560
|
+
function tryResolveStringProp(propValue, scope, source) {
|
|
2561
|
+
const val = resolveNode(propValue, scope);
|
|
2562
|
+
if (typeof val === "string") return val;
|
|
2563
|
+
return source === void 0 ? void 0 : `__raw:${source.slice(propValue.start, propValue.end)}`;
|
|
2564
|
+
}
|
|
2565
|
+
function parsePercentageKeyframes(node, scope, source) {
|
|
2566
|
+
const keyframes = [];
|
|
2567
|
+
let ease;
|
|
2568
|
+
let easeEach;
|
|
2569
|
+
for (const prop of node.properties ?? []) {
|
|
2570
|
+
if (prop.type !== "ObjectProperty" && prop.type !== "Property") continue;
|
|
2571
|
+
const key = prop.key?.value ?? prop.key?.name;
|
|
2572
|
+
if (typeof key !== "string") continue;
|
|
2573
|
+
const pctMatch = PERCENTAGE_KEY_RE.exec(key);
|
|
2574
|
+
if (pctMatch) {
|
|
2575
|
+
if (!isPlainStep(prop.value)) return void 0;
|
|
2576
|
+
const percentage = Number.parseFloat(pctMatch[1] ?? "0");
|
|
2577
|
+
const record = objectExpressionToRecord(prop.value, scope, source);
|
|
2578
|
+
const properties = {};
|
|
2579
|
+
let kfEase;
|
|
2580
|
+
for (const [k, v] of Object.entries(record)) {
|
|
2581
|
+
if (k === "ease" && typeof v === "string") {
|
|
2582
|
+
kfEase = v;
|
|
2583
|
+
} else if (k === "duration") {
|
|
2584
|
+
continue;
|
|
2585
|
+
} else if (typeof v === "number" || typeof v === "string") {
|
|
2586
|
+
properties[k] = v;
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
keyframes.push({ percentage, properties, ...kfEase ? { ease: kfEase } : {} });
|
|
2590
|
+
} else if (key === "ease") {
|
|
2591
|
+
ease = tryResolveStringProp(prop.value, scope, source) ?? ease;
|
|
2592
|
+
} else if (key === "easeEach") {
|
|
2593
|
+
easeEach = tryResolveStringProp(prop.value, scope, source) ?? easeEach;
|
|
2594
|
+
} else {
|
|
2595
|
+
return void 0;
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
keyframes.sort((a, b) => a.percentage - b.percentage);
|
|
2599
|
+
return {
|
|
2600
|
+
format: "percentage",
|
|
2601
|
+
keyframes,
|
|
2602
|
+
...ease ? { ease } : {},
|
|
2603
|
+
...easeEach ? { easeEach } : {}
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
function computeKeyframesTotalDuration(varsNode, scope, source) {
|
|
2607
|
+
const kfNode = (varsNode.properties ?? []).find(
|
|
2608
|
+
(p) => (p.key?.name ?? p.key?.value) === "keyframes"
|
|
2609
|
+
)?.value;
|
|
2610
|
+
if (!kfNode || kfNode.type !== "ArrayExpression") return void 0;
|
|
2611
|
+
const durations = [];
|
|
2612
|
+
for (const el of kfNode.elements ?? []) {
|
|
2613
|
+
if (!el || el.type !== "ObjectExpression") continue;
|
|
2614
|
+
const r = objectExpressionToRecord(el, scope, source);
|
|
2615
|
+
durations.push(r.duration);
|
|
2616
|
+
}
|
|
2617
|
+
return getObjectArrayKeyframeTiming(durations)?.totalDuration;
|
|
2618
|
+
}
|
|
2619
|
+
function staticKeyName(prop) {
|
|
2620
|
+
if (prop.type !== "ObjectProperty" && prop.type !== "Property") return void 0;
|
|
2621
|
+
if (prop.method || prop.kind && prop.kind !== "init") return void 0;
|
|
2622
|
+
const key = prop.computed ? prop.key?.type === "Literal" && prop.key.value : prop.key?.name ?? prop.key?.value;
|
|
2623
|
+
return typeof key === "string" ? key : void 0;
|
|
2624
|
+
}
|
|
2625
|
+
var isPlainObject = (node) => node?.type === "ObjectExpression" && (node.properties ?? []).every((p) => staticKeyName(p) !== void 0);
|
|
2626
|
+
var isPlainStep = (node) => node?.type === "Literal" || isPlainObject(node);
|
|
2627
|
+
function parseObjectArrayKeyframes(node, scope, source) {
|
|
2628
|
+
const elements = node.elements ?? [];
|
|
2629
|
+
const raw = [];
|
|
2630
|
+
for (const el of elements) {
|
|
2631
|
+
if (!isPlainObject(el)) return void 0;
|
|
2632
|
+
const record = objectExpressionToRecord(el, scope, source);
|
|
2633
|
+
const properties = {};
|
|
2634
|
+
let duration;
|
|
2635
|
+
let ease;
|
|
2636
|
+
for (const [k, v] of Object.entries(record)) {
|
|
2637
|
+
if (k === "duration") {
|
|
2638
|
+
duration = v;
|
|
2639
|
+
} else if (k === "ease" && typeof v === "string") {
|
|
2640
|
+
ease = v;
|
|
2641
|
+
} else if (typeof v === "number" || typeof v === "string") {
|
|
2642
|
+
properties[k] = v;
|
|
2643
|
+
} else {
|
|
2644
|
+
return void 0;
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
raw.push({ properties, duration, ease });
|
|
2648
|
+
}
|
|
2649
|
+
const timing = getObjectArrayKeyframeTiming(raw.map((entry) => entry.duration));
|
|
2650
|
+
if (!timing) return void 0;
|
|
2651
|
+
const keyframes = raw.map((entry, index) => ({
|
|
2652
|
+
percentage: timing.percentages[index],
|
|
2653
|
+
properties: entry.properties,
|
|
2654
|
+
...entry.ease ? { ease: entry.ease } : {}
|
|
2655
|
+
}));
|
|
2656
|
+
return { format: "object-array", keyframes };
|
|
2657
|
+
}
|
|
2658
|
+
function parseSimpleArrayKeyframes(node, scope) {
|
|
2659
|
+
const arrayProps = /* @__PURE__ */ new Map();
|
|
2660
|
+
let ease;
|
|
2661
|
+
let easeEach;
|
|
2662
|
+
for (const prop of node.properties ?? []) {
|
|
2663
|
+
if (prop.type !== "ObjectProperty" && prop.type !== "Property") continue;
|
|
2664
|
+
const key = prop.key?.name ?? prop.key?.value;
|
|
2665
|
+
if (typeof key !== "string") continue;
|
|
2666
|
+
if (prop.value?.type === "ArrayExpression") {
|
|
2667
|
+
const values = [];
|
|
2668
|
+
for (const el of prop.value.elements ?? []) {
|
|
2669
|
+
const val = resolveNode(el, scope);
|
|
2670
|
+
if (typeof val !== "number" && typeof val !== "string") return void 0;
|
|
2671
|
+
values.push(val);
|
|
2672
|
+
}
|
|
2673
|
+
if (values.length > 0) arrayProps.set(key, values);
|
|
2674
|
+
} else if (key === "ease") {
|
|
2675
|
+
ease = tryResolveStringProp(prop.value, scope) ?? ease;
|
|
2676
|
+
} else if (key === "easeEach") {
|
|
2677
|
+
easeEach = tryResolveStringProp(prop.value, scope) ?? easeEach;
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
const maxLen = Math.max(...[...arrayProps.values()].map((a) => a.length), 0);
|
|
2681
|
+
const keyframes = [];
|
|
2682
|
+
for (let i = 0; i < maxLen; i++) {
|
|
2683
|
+
const percentage = maxLen > 1 ? Math.round(i / (maxLen - 1) * 100) : 0;
|
|
2684
|
+
const properties = {};
|
|
2685
|
+
for (const [key, values] of arrayProps) {
|
|
2686
|
+
if (i < values.length) properties[key] = values[i];
|
|
2687
|
+
}
|
|
2688
|
+
keyframes.push({ percentage, properties });
|
|
2689
|
+
}
|
|
2690
|
+
return {
|
|
2691
|
+
format: "simple-array",
|
|
2692
|
+
keyframes,
|
|
2693
|
+
...ease ? { ease } : {},
|
|
2694
|
+
...easeEach ? { easeEach } : {}
|
|
2695
|
+
};
|
|
2696
|
+
}
|
|
2697
|
+
function parseKeyframesNode(node, scope, source) {
|
|
2698
|
+
if (!node) return void 0;
|
|
2699
|
+
if (node.type === "ArrayExpression") {
|
|
2700
|
+
return parseObjectArrayKeyframes(node, scope, source);
|
|
2701
|
+
}
|
|
2702
|
+
if (node.type !== "ObjectExpression") return void 0;
|
|
2703
|
+
const props = node.properties ?? [];
|
|
2704
|
+
if (!props.every((p) => staticKeyName(p) !== void 0)) return void 0;
|
|
2705
|
+
let hasPercentageKey = false;
|
|
2706
|
+
let hasArrayValue = false;
|
|
2707
|
+
for (const prop of props) {
|
|
2708
|
+
if (prop.type !== "ObjectProperty" && prop.type !== "Property") continue;
|
|
2709
|
+
const key = prop.key?.value ?? prop.key?.name;
|
|
2710
|
+
if (typeof key === "string" && PERCENTAGE_KEY_RE.test(key)) {
|
|
2711
|
+
hasPercentageKey = true;
|
|
2712
|
+
break;
|
|
2713
|
+
}
|
|
2714
|
+
if (prop.value?.type === "ArrayExpression") {
|
|
2715
|
+
hasArrayValue = true;
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
if (hasPercentageKey) return parsePercentageKeyframes(node, scope, source);
|
|
2719
|
+
if (hasArrayValue) return parseSimpleArrayKeyframes(node, scope);
|
|
2720
|
+
return void 0;
|
|
2721
|
+
}
|
|
2722
|
+
function parseMotionPathNode(node, scope, source) {
|
|
2723
|
+
if (!node) return void 0;
|
|
2724
|
+
let pathNode;
|
|
2725
|
+
let autoRotate = false;
|
|
2726
|
+
let curviness = 1;
|
|
2727
|
+
let isCubic = false;
|
|
2728
|
+
if (node.type === "ObjectExpression") {
|
|
2729
|
+
for (const prop of node.properties ?? []) {
|
|
2730
|
+
if (!isObjectProperty(prop)) continue;
|
|
2731
|
+
const key = propKeyName(prop);
|
|
2732
|
+
if (key === "path") pathNode = prop.value;
|
|
2733
|
+
else if (key === "autoRotate") {
|
|
2734
|
+
const val = resolveNode(prop.value, scope);
|
|
2735
|
+
autoRotate = typeof val === "number" ? val : val === true;
|
|
2736
|
+
} else if (key === "curviness") {
|
|
2737
|
+
const val = resolveNode(prop.value, scope);
|
|
2738
|
+
if (typeof val === "number") curviness = val;
|
|
2739
|
+
} else if (key === "type") {
|
|
2740
|
+
const val = resolveNode(prop.value, scope);
|
|
2741
|
+
if (val === "cubic") isCubic = true;
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
} else if (node.type === "ArrayExpression") {
|
|
2745
|
+
pathNode = node;
|
|
2746
|
+
}
|
|
2747
|
+
if (!pathNode || pathNode.type !== "ArrayExpression") return void 0;
|
|
2748
|
+
const elements = pathNode.elements ?? [];
|
|
2749
|
+
const coords = [];
|
|
2750
|
+
for (const elem of elements) {
|
|
2751
|
+
if (!elem || elem.type !== "ObjectExpression") continue;
|
|
2752
|
+
const rec = objectExpressionToRecord(elem, scope, source);
|
|
2753
|
+
const x = typeof rec.x === "number" ? rec.x : void 0;
|
|
2754
|
+
const y = typeof rec.y === "number" ? rec.y : void 0;
|
|
2755
|
+
if (x !== void 0 && y !== void 0) coords.push({ x, y });
|
|
2756
|
+
}
|
|
2757
|
+
return buildArcPath(coords, curviness, autoRotate, isCubic);
|
|
2758
|
+
}
|
|
2759
|
+
function tweenCallToAnimation(call, scope, source, identifierBindings) {
|
|
2760
|
+
const provenance = readProvenance(call.node);
|
|
2761
|
+
const vars = objectExpressionToRecord(call.varsArg, scope, source);
|
|
2762
|
+
const properties = {};
|
|
2763
|
+
const extras = {};
|
|
2764
|
+
let keyframesData;
|
|
2765
|
+
let hasUnresolvedKeyframes = false;
|
|
2766
|
+
let motionPathResult;
|
|
2767
|
+
for (const [key, val] of Object.entries(vars)) {
|
|
2768
|
+
if (BUILTIN_VAR_KEYS.has(key)) continue;
|
|
2769
|
+
if (DROPPED_VAR_KEYS.has(key)) continue;
|
|
2770
|
+
if (key === "keyframes") {
|
|
2771
|
+
const kfNode = findPropertyNode(call.varsArg, "keyframes");
|
|
2772
|
+
keyframesData = parseKeyframesNode(kfNode, scope, source);
|
|
2773
|
+
if (!keyframesData && kfNode) hasUnresolvedKeyframes = true;
|
|
2774
|
+
continue;
|
|
2775
|
+
}
|
|
2776
|
+
if (key === "motionPath") {
|
|
2777
|
+
const mpNode = findPropertyNode(call.varsArg, "motionPath");
|
|
2778
|
+
motionPathResult = parseMotionPathNode(mpNode, scope, source);
|
|
2779
|
+
continue;
|
|
2780
|
+
}
|
|
2781
|
+
if (key === "easeEach") continue;
|
|
2782
|
+
if (EXTRAS_KEYS.has(key)) {
|
|
2783
|
+
const rawSource = extractRawPropertySource(call.varsArg, key, source);
|
|
2784
|
+
if (rawSource !== void 0) {
|
|
2785
|
+
extras[key] = `__raw:${rawSource}`;
|
|
2786
|
+
} else if (val !== void 0) {
|
|
2787
|
+
extras[key] = val;
|
|
2788
|
+
}
|
|
2789
|
+
continue;
|
|
2790
|
+
}
|
|
2791
|
+
if (typeof val === "number" || typeof val === "string") {
|
|
2792
|
+
properties[key] = val;
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
if (keyframesData && typeof vars.easeEach === "string") {
|
|
2796
|
+
keyframesData.easeEach = vars.easeEach;
|
|
2797
|
+
}
|
|
2798
|
+
if (motionPathResult) {
|
|
2799
|
+
const { waypoints } = motionPathResult;
|
|
2800
|
+
if (!keyframesData) {
|
|
2801
|
+
const kf = waypoints.map((wp, i) => ({
|
|
2802
|
+
percentage: waypoints.length > 1 ? Math.round(i / (waypoints.length - 1) * 100) : 0,
|
|
2803
|
+
properties: { x: wp.x, y: wp.y }
|
|
2804
|
+
}));
|
|
2805
|
+
keyframesData = { format: "percentage", keyframes: kf, fromMotionPath: true };
|
|
2806
|
+
} else {
|
|
2807
|
+
const kfs = keyframesData.keyframes;
|
|
2808
|
+
if (kfs.length === waypoints.length) {
|
|
2809
|
+
for (let i = 0; i < kfs.length; i++) {
|
|
2810
|
+
const kf = kfs[i];
|
|
2811
|
+
const wp = waypoints[i];
|
|
2812
|
+
if (kf && wp) {
|
|
2813
|
+
kf.properties.x = wp.x;
|
|
2814
|
+
kf.properties.y = wp.y;
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
let fromProperties;
|
|
2821
|
+
if (call.method === "fromTo" && call.fromArg) {
|
|
2822
|
+
fromProperties = {};
|
|
2823
|
+
const fromVars = objectExpressionToRecord(call.fromArg, scope, source);
|
|
2824
|
+
for (const [key, val] of Object.entries(fromVars)) {
|
|
2825
|
+
if (typeof val === "number" || typeof val === "string") {
|
|
2826
|
+
fromProperties[key] = val;
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
const hasPositionArg = !!call.positionArg;
|
|
2831
|
+
const posVal = hasPositionArg ? extractLiteralValue(call.positionArg, scope) : 0;
|
|
2832
|
+
const position = typeof posVal === "number" ? posVal : typeof posVal === "string" ? posVal : hasPositionArg ? `__raw:${source.slice(call.positionArg.start, call.positionArg.end)}` : 0;
|
|
2833
|
+
let duration = typeof vars.duration === "number" ? vars.duration : void 0;
|
|
2834
|
+
const ease = typeof vars.ease === "string" ? vars.ease : void 0;
|
|
2835
|
+
const durationUnresolved = call.method !== "set" && duration === void 0 && hasUnknownDuration(call.varsArg, scope);
|
|
2836
|
+
if (duration === void 0 && keyframesData && !durationUnresolved) {
|
|
2837
|
+
duration = computeKeyframesTotalDuration(call.varsArg, scope, source);
|
|
2838
|
+
}
|
|
2839
|
+
let selector = call.selector;
|
|
2840
|
+
let targetIdentity;
|
|
2841
|
+
if (selector === "__unresolved__") {
|
|
2842
|
+
const targetNode = call.node.arguments?.[0];
|
|
2843
|
+
const proxyLabel = describeProxyTarget(targetNode, call.varsArg, scope);
|
|
2844
|
+
if (proxyLabel) {
|
|
2845
|
+
selector = proxyLabel;
|
|
2846
|
+
if (targetNode?.type === "Identifier") {
|
|
2847
|
+
const declaration = findVisibleIdentifierDeclaration(
|
|
2848
|
+
targetNode.name,
|
|
2849
|
+
call.ancestors,
|
|
2850
|
+
identifierBindings,
|
|
2851
|
+
call.node.start
|
|
2852
|
+
);
|
|
2853
|
+
if (declaration?.node.init?.type === "ObjectExpression" && !identifierBindings.reassignedDeclarations.has(declaration.node)) {
|
|
2854
|
+
const declarationProvenance = readProvenance(declaration.scopeNode) ?? readProvenance(declaration.expandedScopeNode);
|
|
2855
|
+
const instanceIdentity = declarationProvenance && (declarationProvenance.kind === "helper" || declarationProvenance.kind === "loop") ? `:${declarationProvenance.kind}:${declarationProvenance.callSite ?? ""}:${declarationProvenance.iteration ?? ""}` : "";
|
|
2856
|
+
targetIdentity = `proxy:${targetNode.name}@${declaration.node.start}${instanceIdentity}`;
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
const anim = {
|
|
2862
|
+
targetSelector: selector,
|
|
2863
|
+
method: call.method,
|
|
2864
|
+
position,
|
|
2865
|
+
properties,
|
|
2866
|
+
fromProperties,
|
|
2867
|
+
duration,
|
|
2868
|
+
ease
|
|
2869
|
+
};
|
|
2870
|
+
if (targetIdentity) anim.targetIdentity = targetIdentity;
|
|
2871
|
+
if (!hasPositionArg) anim.implicitPosition = true;
|
|
2872
|
+
let group = classifyTweenPropertyGroup(properties);
|
|
2873
|
+
if (!group && keyframesData) {
|
|
2874
|
+
const kfProps = {};
|
|
2875
|
+
for (const kf of keyframesData.keyframes) {
|
|
2876
|
+
for (const k of Object.keys(kf.properties)) kfProps[k] = true;
|
|
2877
|
+
}
|
|
2878
|
+
group = classifyTweenPropertyGroup(kfProps);
|
|
2879
|
+
}
|
|
2880
|
+
if (group) anim.propertyGroup = group;
|
|
2881
|
+
if (call.global) anim.global = true;
|
|
2882
|
+
if (Object.keys(extras).length > 0) anim.extras = extras;
|
|
2883
|
+
if (keyframesData) anim.keyframes = keyframesData;
|
|
2884
|
+
if (motionPathResult) anim.arcPath = motionPathResult.arcPath;
|
|
2885
|
+
if (hasUnresolvedKeyframes) anim.hasUnresolvedKeyframes = true;
|
|
2886
|
+
if (durationUnresolved) anim.durationUnresolved = true;
|
|
2887
|
+
if (selector === "__unresolved__") anim.hasUnresolvedSelector = true;
|
|
2888
|
+
if (call.selectorPartial) anim.hasPartialSelector = true;
|
|
2889
|
+
if (provenance) anim.provenance = provenance;
|
|
2890
|
+
return anim;
|
|
2891
|
+
}
|
|
2892
|
+
function staggerAmount(raw) {
|
|
2893
|
+
if (typeof raw === "number") return raw;
|
|
2894
|
+
if (typeof raw !== "string") return void 0;
|
|
2895
|
+
const src = raw.startsWith("__raw:") ? raw.slice(6) : raw;
|
|
2896
|
+
const m = /(?:each\s*:\s*)?(-?\d+(?:\.\d+)?)/.exec(src);
|
|
2897
|
+
if (!m) return void 0;
|
|
2898
|
+
const n2 = Number.parseFloat(m[1]);
|
|
2899
|
+
return Number.isFinite(n2) ? n2 : void 0;
|
|
2900
|
+
}
|
|
2901
|
+
function restValue(prop) {
|
|
2902
|
+
return prop === "opacity" || prop.startsWith("scale") ? 1 : 0;
|
|
2903
|
+
}
|
|
2904
|
+
function staggeredKeyframes(anim, each) {
|
|
2905
|
+
const vars = { ...anim.properties };
|
|
2906
|
+
let from;
|
|
2907
|
+
let to;
|
|
2908
|
+
if (anim.method === "fromTo") {
|
|
2909
|
+
from = { ...anim.fromProperties ?? {} };
|
|
2910
|
+
to = vars;
|
|
2911
|
+
} else if (anim.method === "from") {
|
|
2912
|
+
from = vars;
|
|
2913
|
+
to = {};
|
|
2914
|
+
for (const k of Object.keys(vars)) to[k] = restValue(k);
|
|
2915
|
+
} else {
|
|
2916
|
+
from = { ...anim.fromProperties ?? {} };
|
|
2917
|
+
for (const k of Object.keys(vars)) if (from[k] === void 0) from[k] = restValue(k);
|
|
2918
|
+
to = vars;
|
|
2919
|
+
}
|
|
2920
|
+
return [
|
|
2921
|
+
{ percentage: 0, properties: { ...from, stagger: each } },
|
|
2922
|
+
{ percentage: 100, properties: { ...to, stagger: each } }
|
|
2923
|
+
];
|
|
2924
|
+
}
|
|
2925
|
+
function annotateStaggeredCollections(anims) {
|
|
2926
|
+
for (const anim of anims) {
|
|
2927
|
+
if (anim.keyframes || anim.arcPath) continue;
|
|
2928
|
+
const each = staggerAmount(anim.extras?.stagger);
|
|
2929
|
+
if (each === void 0) continue;
|
|
2930
|
+
anim.keyframes = { format: "percentage", keyframes: staggeredKeyframes(anim, each) };
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
function resolvePositionString(pos, cursor, prevStart) {
|
|
2934
|
+
const trimmed = pos.trim();
|
|
2935
|
+
if (trimmed === "") return cursor;
|
|
2936
|
+
if (trimmed.startsWith("+=")) {
|
|
2937
|
+
const n22 = Number.parseFloat(trimmed.slice(2));
|
|
2938
|
+
return Number.isFinite(n22) ? cursor + n22 : null;
|
|
2939
|
+
}
|
|
2940
|
+
if (trimmed.startsWith("-=")) {
|
|
2941
|
+
const n22 = Number.parseFloat(trimmed.slice(2));
|
|
2942
|
+
return Number.isFinite(n22) ? cursor - n22 : null;
|
|
2943
|
+
}
|
|
2944
|
+
if (trimmed === "<") return prevStart;
|
|
2945
|
+
if (trimmed === ">") return cursor;
|
|
2946
|
+
if (trimmed.startsWith("<")) {
|
|
2947
|
+
const n22 = Number.parseFloat(trimmed.slice(1));
|
|
2948
|
+
return Number.isFinite(n22) ? prevStart + n22 : null;
|
|
2949
|
+
}
|
|
2950
|
+
if (trimmed.startsWith(">")) {
|
|
2951
|
+
const n22 = Number.parseFloat(trimmed.slice(1));
|
|
2952
|
+
return Number.isFinite(n22) ? cursor + n22 : null;
|
|
2953
|
+
}
|
|
2954
|
+
const n2 = Number.parseFloat(trimmed);
|
|
2955
|
+
return Number.isFinite(n2) ? n2 : null;
|
|
2956
|
+
}
|
|
2957
|
+
function collectGsapSetStates(ast, scope, bindings, source) {
|
|
2958
|
+
const states = /* @__PURE__ */ new Map();
|
|
2959
|
+
ancestor(ast, {
|
|
2960
|
+
// fallow-ignore-next-line complexity
|
|
2961
|
+
CallExpression(node, _, ancestors) {
|
|
2962
|
+
const callee = node.callee;
|
|
2963
|
+
if (callee?.type !== "MemberExpression" || callee.object?.name !== "gsap" || callee.property?.name !== "set")
|
|
2964
|
+
return;
|
|
2965
|
+
const selector = resolveTargetSelector(node.arguments?.[0], ancestors, scope, bindings);
|
|
2966
|
+
if (!selector) return;
|
|
2967
|
+
const rec = objectExpressionToRecord(node.arguments?.[1], scope, source);
|
|
2968
|
+
const props = states.get(selector) ?? {};
|
|
2969
|
+
for (const [k, v] of Object.entries(rec)) {
|
|
2970
|
+
if (typeof v === "number" || typeof v === "string") props[k] = v;
|
|
2971
|
+
}
|
|
2972
|
+
states.set(selector, props);
|
|
2973
|
+
}
|
|
2974
|
+
});
|
|
2975
|
+
return states;
|
|
2976
|
+
}
|
|
2977
|
+
function mergeProps(target, props) {
|
|
2978
|
+
for (const [k, v] of Object.entries(props)) target[k] = v;
|
|
2979
|
+
return target;
|
|
2980
|
+
}
|
|
2981
|
+
function seedFromPreState(anim, cur) {
|
|
2982
|
+
const from = { ...anim.fromProperties ?? {} };
|
|
2983
|
+
let seeded = false;
|
|
2984
|
+
for (const prop of Object.keys(anim.properties)) {
|
|
2985
|
+
if (from[prop] === void 0 && cur[prop] !== void 0) {
|
|
2986
|
+
from[prop] = cur[prop];
|
|
2987
|
+
seeded = true;
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
if (seeded) anim.fromProperties = from;
|
|
2991
|
+
}
|
|
2992
|
+
function seedSetStates(anims, initial) {
|
|
2993
|
+
const state = /* @__PURE__ */ new Map();
|
|
2994
|
+
for (const [sel, props] of initial) state.set(sel, { ...props });
|
|
2995
|
+
for (const anim of anims) {
|
|
2996
|
+
const sel = anim.targetSelector;
|
|
2997
|
+
if (anim.method === "set") {
|
|
2998
|
+
state.set(sel, mergeProps(state.get(sel) ?? {}, anim.properties));
|
|
2999
|
+
continue;
|
|
3000
|
+
}
|
|
3001
|
+
const cur = state.get(sel);
|
|
3002
|
+
if (anim.method === "to" && cur) seedFromPreState(anim, cur);
|
|
3003
|
+
state.set(sel, mergeProps(state.get(sel) ?? {}, anim.properties));
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
function applyTimelineDefaults(anims, defaults) {
|
|
3007
|
+
if (!defaults) return;
|
|
3008
|
+
for (const anim of anims) {
|
|
3009
|
+
if (anim.method === "set") continue;
|
|
3010
|
+
if (anim.duration === void 0 && !anim.durationUnresolved) {
|
|
3011
|
+
if (defaults.duration !== void 0) anim.duration = defaults.duration;
|
|
3012
|
+
else if (defaults.durationUnresolved) anim.durationUnresolved = true;
|
|
3013
|
+
}
|
|
3014
|
+
if (anim.ease === void 0 && defaults.ease !== void 0 && (!anim.keyframes || anim.keyframes.fromMotionPath)) {
|
|
3015
|
+
anim.ease = defaults.ease;
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
function resolveLabelPosition(pos, labels, cursor) {
|
|
3020
|
+
const m = /^([A-Za-z_$][\w$]*)\s*(?:([+-])=\s*([\d.]+))?$/.exec(pos.trim());
|
|
3021
|
+
if (!m) return null;
|
|
3022
|
+
const name = m[1];
|
|
3023
|
+
let base = labels.get(name);
|
|
3024
|
+
if (base === void 0) {
|
|
3025
|
+
base = cursor;
|
|
3026
|
+
labels.set(name, base);
|
|
3027
|
+
}
|
|
3028
|
+
if (m[2] && m[3]) {
|
|
3029
|
+
const n2 = Number.parseFloat(m[3]);
|
|
3030
|
+
if (Number.isFinite(n2)) return m[2] === "+" ? base + n2 : base - n2;
|
|
3031
|
+
}
|
|
3032
|
+
return base;
|
|
3033
|
+
}
|
|
3034
|
+
function resolveAnimStart(anim, cursor, prevStart, labels) {
|
|
3035
|
+
if (anim.implicitPosition) return cursor;
|
|
3036
|
+
if (typeof anim.position === "number") return anim.position;
|
|
3037
|
+
if (typeof anim.position === "string") {
|
|
3038
|
+
return resolveLabelPosition(anim.position, labels, cursor) ?? resolvePositionString(anim.position, cursor, prevStart);
|
|
3039
|
+
}
|
|
3040
|
+
return cursor;
|
|
3041
|
+
}
|
|
3042
|
+
function resolveTimelinePositions(anims, labelDefs = []) {
|
|
3043
|
+
let cursor = 0;
|
|
3044
|
+
let prevStart = 0;
|
|
3045
|
+
let cursorKnown = true;
|
|
3046
|
+
const labels = /* @__PURE__ */ new Map();
|
|
3047
|
+
let labelIdx = 0;
|
|
3048
|
+
const sortedLabels = [...labelDefs].sort((a, b) => a.order - b.order);
|
|
3049
|
+
const defineLabel = (def) => {
|
|
3050
|
+
let value;
|
|
3051
|
+
if (typeof def.position === "number") value = def.position;
|
|
3052
|
+
else if (!cursorKnown) return;
|
|
3053
|
+
else if (typeof def.position === "string") {
|
|
3054
|
+
value = resolveLabelPosition(def.position, labels, cursor) ?? cursor;
|
|
3055
|
+
} else value = cursor;
|
|
3056
|
+
labels.set(def.name, Math.max(0, value));
|
|
3057
|
+
};
|
|
3058
|
+
anims.forEach((anim, i) => {
|
|
3059
|
+
while (labelIdx < sortedLabels.length && sortedLabels[labelIdx].order <= i) {
|
|
3060
|
+
defineLabel(sortedLabels[labelIdx]);
|
|
3061
|
+
labelIdx++;
|
|
3062
|
+
}
|
|
3063
|
+
if (anim.method === "set" && anim.global) {
|
|
3064
|
+
anim.resolvedStart = 0;
|
|
3065
|
+
return;
|
|
3066
|
+
}
|
|
3067
|
+
const duration = anim.method === "set" ? 0 : anim.duration ?? GSAP_DEFAULT_DURATION;
|
|
3068
|
+
const readsCursor = anim.implicitPosition || typeof anim.position !== "number";
|
|
3069
|
+
const start = cursorKnown || !readsCursor ? resolveAnimStart(anim, cursor, prevStart, labels) : null;
|
|
3070
|
+
if (start == null || anim.durationUnresolved) cursorKnown = false;
|
|
3071
|
+
if (start != null) {
|
|
3072
|
+
anim.resolvedStart = Math.max(0, start);
|
|
3073
|
+
prevStart = anim.resolvedStart;
|
|
3074
|
+
cursor = Math.max(cursor, anim.resolvedStart + duration);
|
|
3075
|
+
}
|
|
3076
|
+
});
|
|
3077
|
+
while (labelIdx < sortedLabels.length) defineLabel(sortedLabels[labelIdx++]);
|
|
3078
|
+
}
|
|
3079
|
+
function collectAddLabelDefs(ast, ref, scope, sortedCalls) {
|
|
3080
|
+
const callKeys = sortedCalls.map((c) => ({
|
|
3081
|
+
site: callSiteStart(c),
|
|
3082
|
+
order: c.node.__hfOrder
|
|
3083
|
+
}));
|
|
3084
|
+
const comesAfter = (site, order, labelSite, labelOrder) => {
|
|
3085
|
+
if (site === void 0) return false;
|
|
3086
|
+
if (site !== labelSite) return site > labelSite;
|
|
3087
|
+
return (order ?? -Infinity) > (labelOrder ?? -Infinity);
|
|
3088
|
+
};
|
|
3089
|
+
const defs = [];
|
|
3090
|
+
simple(ast, {
|
|
3091
|
+
// fallow-ignore-next-line complexity
|
|
3092
|
+
CallExpression(node) {
|
|
3093
|
+
const callee = node.callee;
|
|
3094
|
+
const objMatches = ref.kind === "identifier" ? callee.object?.type === "Identifier" && callee.object.name === ref.name : sameMemberAccess(callee.object, ref.node);
|
|
3095
|
+
if (callee?.type !== "MemberExpression" || !objMatches || callee.property?.name !== "addLabel")
|
|
3096
|
+
return;
|
|
3097
|
+
const nameNode = node.arguments?.[0];
|
|
3098
|
+
const name = typeof nameNode?.value === "string" ? nameNode.value : void 0;
|
|
3099
|
+
if (!name) return;
|
|
3100
|
+
const posVal = resolveNode(node.arguments?.[1], scope);
|
|
3101
|
+
const position = typeof posVal === "number" || typeof posVal === "string" ? posVal : void 0;
|
|
3102
|
+
const labelStart = node.__hfSiteStart ?? callee.property?.start;
|
|
3103
|
+
const labelOrder = node.__hfOrder;
|
|
3104
|
+
let order = sortedCalls.length;
|
|
3105
|
+
if (labelStart !== void 0) {
|
|
3106
|
+
order = callKeys.findIndex((k) => comesAfter(k.site, k.order, labelStart, labelOrder));
|
|
3107
|
+
if (order === -1) order = sortedCalls.length;
|
|
3108
|
+
}
|
|
3109
|
+
defs.push({ name, position, order });
|
|
3110
|
+
}
|
|
3111
|
+
});
|
|
3112
|
+
return defs;
|
|
3113
|
+
}
|
|
3114
|
+
function compareByLoc(a, b) {
|
|
3115
|
+
const aLoc = a.node.callee?.property?.loc?.start;
|
|
3116
|
+
const bLoc = b.node.callee?.property?.loc?.start;
|
|
3117
|
+
if (!aLoc || !bLoc) return 0;
|
|
3118
|
+
return aLoc.line - bLoc.line || aLoc.column - bLoc.column;
|
|
3119
|
+
}
|
|
3120
|
+
function callSiteStart(call) {
|
|
3121
|
+
return call.node.__hfSiteStart ?? call.node.callee?.property?.start;
|
|
3122
|
+
}
|
|
3123
|
+
function compareCallOrder(a, b) {
|
|
3124
|
+
const aSite = callSiteStart(a);
|
|
3125
|
+
const bSite = callSiteStart(b);
|
|
3126
|
+
if (aSite !== void 0 && bSite !== void 0 && aSite !== bSite) return aSite - bSite;
|
|
3127
|
+
const ao = a.node.__hfOrder;
|
|
3128
|
+
const bo = b.node.__hfOrder;
|
|
3129
|
+
if (ao !== void 0 && bo !== void 0) return ao - bo;
|
|
3130
|
+
return compareByLoc(a, b);
|
|
3131
|
+
}
|
|
3132
|
+
function sortBySourcePosition(calls) {
|
|
3133
|
+
calls.sort(compareCallOrder);
|
|
3134
|
+
}
|
|
3135
|
+
function assignStableIds(anims) {
|
|
3136
|
+
const counts = /* @__PURE__ */ new Map();
|
|
3137
|
+
return anims.map((anim) => {
|
|
3138
|
+
const posKey = typeof anim.position === "number" ? String(Math.round(anim.position * 1e3)) : String(anim.position);
|
|
3139
|
+
const groupSuffix = anim.propertyGroup ? `-${anim.propertyGroup}` : "";
|
|
3140
|
+
const base = `${anim.targetSelector}-${anim.method}-${posKey}${groupSuffix}`;
|
|
3141
|
+
const count = (counts.get(base) ?? 0) + 1;
|
|
3142
|
+
counts.set(base, count);
|
|
3143
|
+
const id = count === 1 ? base : `${base}-${count}`;
|
|
3144
|
+
return { ...anim, id };
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
3147
|
+
function parseGsapScriptAcornForWrite(script) {
|
|
3148
|
+
try {
|
|
3149
|
+
const ast = parse(script, {
|
|
3150
|
+
ecmaVersion: "latest",
|
|
3151
|
+
sourceType: "script",
|
|
3152
|
+
locations: true
|
|
3153
|
+
});
|
|
3154
|
+
const scope = collectScopeBindings(ast);
|
|
3155
|
+
const identifierBindings = collectIdentifierBindingIndex(ast);
|
|
3156
|
+
const targetBindings = collectTargetBindings(ast, scope, identifierBindings);
|
|
3157
|
+
const detection = findTimelineVar(ast, scope);
|
|
3158
|
+
const ref = detection.ref ?? { kind: "identifier", name: "tl" };
|
|
3159
|
+
const timelineVar = timelineRootSource(ref, script);
|
|
3160
|
+
const calls = findAllTweenCalls(ast, ref, scope, targetBindings);
|
|
3161
|
+
sortBySourcePosition(calls);
|
|
3162
|
+
const rawAnims = calls.map(
|
|
3163
|
+
(call) => tweenCallToAnimation(call, scope, script, identifierBindings)
|
|
3164
|
+
);
|
|
3165
|
+
applyTimelineDefaults(rawAnims, detection.defaults);
|
|
3166
|
+
resolveTimelinePositions(rawAnims, collectAddLabelDefs(ast, ref, scope, calls));
|
|
3167
|
+
const animations = assignStableIds(rawAnims);
|
|
3168
|
+
const located = calls.map((call, i) => ({
|
|
3169
|
+
id: animations[i].id,
|
|
3170
|
+
call,
|
|
3171
|
+
animation: animations[i]
|
|
3172
|
+
}));
|
|
3173
|
+
return { ast, timelineVar, hasTimeline: detection.ref !== null, located };
|
|
3174
|
+
} catch {
|
|
3175
|
+
return null;
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
var PARSE_MEMO_ENTRIES = 4;
|
|
3179
|
+
var parseMemo = /* @__PURE__ */ new Map();
|
|
3180
|
+
function parseGsapScriptAcorn(script) {
|
|
3181
|
+
const parsed = parseMemo.get(script) ?? parseGsapScriptAcornUncached(script);
|
|
3182
|
+
parseMemo.delete(script);
|
|
3183
|
+
parseMemo.set(script, parsed);
|
|
3184
|
+
if (parseMemo.size > PARSE_MEMO_ENTRIES) parseMemo.delete(parseMemo.keys().next().value);
|
|
3185
|
+
return structuredClone(parsed);
|
|
3186
|
+
}
|
|
3187
|
+
function parseGsapScriptAcornUncached(script) {
|
|
3188
|
+
try {
|
|
3189
|
+
const ast = parseProgram(script);
|
|
3190
|
+
const scope = collectScopeBindings(ast);
|
|
3191
|
+
const detection = findTimelineVar(ast, scope);
|
|
3192
|
+
const ref = detection.ref ?? { kind: "identifier", name: "tl" };
|
|
3193
|
+
const timelineVar = timelineRootSource(ref, script);
|
|
3194
|
+
if (ref.kind === "identifier") {
|
|
3195
|
+
try {
|
|
3196
|
+
inlineComputedTimelines(ast, timelineVar, (node) => resolveNode(node, scope));
|
|
3197
|
+
} catch {
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
const identifierBindings = collectIdentifierBindingIndex(ast);
|
|
3201
|
+
const targetBindings = collectTargetBindings(ast, scope, identifierBindings);
|
|
3202
|
+
const calls = findAllTweenCalls(ast, ref, scope, targetBindings);
|
|
3203
|
+
sortBySourcePosition(calls);
|
|
3204
|
+
const rawAnims = calls.map(
|
|
3205
|
+
(call) => tweenCallToAnimation(call, scope, script, identifierBindings)
|
|
3206
|
+
);
|
|
3207
|
+
applyTimelineDefaults(rawAnims, detection.defaults);
|
|
3208
|
+
seedSetStates(rawAnims, collectGsapSetStates(ast, scope, targetBindings, script));
|
|
3209
|
+
const labelDefs = collectAddLabelDefs(ast, ref, scope, calls);
|
|
3210
|
+
resolveTimelinePositions(rawAnims, labelDefs);
|
|
3211
|
+
annotateStaggeredCollections(rawAnims);
|
|
3212
|
+
const animations = assignStableIds(rawAnims);
|
|
3213
|
+
const declPattern = ref.kind === "identifier" ? `(?:const|let|var)\\s+${timelineVar}\\s*=\\s*gsap\\.timeline\\s*\\([^)]*\\)\\s*;?` : `${escapeRegExp(timelineVar)}\\s*=\\s*gsap\\.timeline\\s*\\([^)]*\\)\\s*;?`;
|
|
3214
|
+
const timelineMatch = script.match(new RegExp(`^[\\s\\S]*?${declPattern}`));
|
|
3215
|
+
const fallbackPreamble = ref.kind === "identifier" ? `const ${timelineVar} = gsap.timeline({ paused: true });` : `${timelineVar} = gsap.timeline({ paused: true });`;
|
|
3216
|
+
const preamble = timelineMatch?.[0] ?? fallbackPreamble;
|
|
3217
|
+
const lastCallIdx = script.lastIndexOf(`${timelineVar}.`);
|
|
3218
|
+
let postamble = "";
|
|
3219
|
+
if (lastCallIdx !== -1) {
|
|
3220
|
+
const afterLast = script.slice(lastCallIdx);
|
|
3221
|
+
const endOfCall = afterLast.indexOf(";");
|
|
3222
|
+
if (endOfCall !== -1) {
|
|
3223
|
+
postamble = script.slice(lastCallIdx + endOfCall + 1).trim();
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
const result = { animations, timelineVar, preamble, postamble };
|
|
3227
|
+
if (detection.timelineCount > 1) result.multipleTimelines = true;
|
|
3228
|
+
if (detection.timelineCount > 0 && detection.ref === null)
|
|
3229
|
+
result.unsupportedTimelinePattern = true;
|
|
3230
|
+
return result;
|
|
3231
|
+
} catch {
|
|
3232
|
+
return { animations: [], timelineVar: "tl", preamble: "", postamble: "" };
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
var DEFAULT_TYPEOF = {
|
|
3236
|
+
string: "string",
|
|
3237
|
+
number: "number",
|
|
3238
|
+
color: "string",
|
|
3239
|
+
boolean: "boolean",
|
|
3240
|
+
enum: "string",
|
|
3241
|
+
font: "string",
|
|
3242
|
+
image: "string"
|
|
3243
|
+
};
|
|
3244
|
+
function isRecord(v) {
|
|
3245
|
+
return typeof v === "object" && v !== null;
|
|
3246
|
+
}
|
|
3247
|
+
function isVariableType(t) {
|
|
3248
|
+
return typeof t === "string" && t in DEFAULT_TYPEOF;
|
|
3249
|
+
}
|
|
3250
|
+
function isCompositionVariable(v) {
|
|
3251
|
+
if (!isRecord(v)) return false;
|
|
3252
|
+
if (typeof v.id !== "string" || typeof v.label !== "string") return false;
|
|
3253
|
+
if (!isVariableType(v.type)) return false;
|
|
3254
|
+
if (typeof v.default !== DEFAULT_TYPEOF[v.type]) return false;
|
|
3255
|
+
if (v.type === "enum" && !Array.isArray(v.options)) return false;
|
|
3256
|
+
return true;
|
|
3257
|
+
}
|
|
3258
|
+
function parseCompositionVariables(htmlEl) {
|
|
3259
|
+
const variablesAttr = htmlEl.getAttribute("data-composition-variables");
|
|
3260
|
+
if (!variablesAttr) {
|
|
3261
|
+
return [];
|
|
3262
|
+
}
|
|
3263
|
+
try {
|
|
3264
|
+
const parsed = JSON.parse(variablesAttr);
|
|
3265
|
+
if (!Array.isArray(parsed)) {
|
|
3266
|
+
return [];
|
|
3267
|
+
}
|
|
3268
|
+
return parsed.filter(isCompositionVariable);
|
|
3269
|
+
} catch {
|
|
3270
|
+
return [];
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
var EXCLUDED_TAGS = /* @__PURE__ */ new Set([
|
|
3274
|
+
"script",
|
|
3275
|
+
"style",
|
|
3276
|
+
"template",
|
|
3277
|
+
"meta",
|
|
3278
|
+
"link",
|
|
3279
|
+
"noscript",
|
|
3280
|
+
"base"
|
|
3281
|
+
]);
|
|
3282
|
+
function fnv1a(str) {
|
|
3283
|
+
let h = 2166136261;
|
|
3284
|
+
for (let i = 0; i < str.length; i++) {
|
|
3285
|
+
h ^= str.charCodeAt(i);
|
|
3286
|
+
h = Math.imul(h, 16777619);
|
|
3287
|
+
}
|
|
3288
|
+
return h >>> 0;
|
|
3289
|
+
}
|
|
3290
|
+
function toHfId(hash) {
|
|
3291
|
+
const s = (hash >>> 0).toString(36);
|
|
3292
|
+
const four = s.length >= 4 ? s.slice(-4) : s.padStart(4, "0");
|
|
3293
|
+
return `hf-${four}`;
|
|
3294
|
+
}
|
|
3295
|
+
function ownText(el) {
|
|
3296
|
+
let text = "";
|
|
3297
|
+
el.childNodes.forEach((n2) => {
|
|
3298
|
+
if (n2.nodeType === 3) text += n2.nodeValue ?? "";
|
|
3299
|
+
});
|
|
3300
|
+
return text.trim();
|
|
3301
|
+
}
|
|
3302
|
+
function getContractAttribute(el, name) {
|
|
3303
|
+
return Array.from(el.attributes).find((attr) => attr.name.toLowerCase() === name)?.value ?? null;
|
|
3304
|
+
}
|
|
3305
|
+
function contentKey(el) {
|
|
3306
|
+
const attrs = Array.from(el.attributes).filter((a) => !a.name.toLowerCase().startsWith("data-hf-")).map((a) => `${a.name.toLowerCase()}\0${a.value}`).sort().join("");
|
|
3307
|
+
return `${el.tagName.toLowerCase()}|${attrs}|${ownText(el)}`;
|
|
3308
|
+
}
|
|
3309
|
+
function mintHfId(el, assigned) {
|
|
3310
|
+
const key = contentKey(el);
|
|
3311
|
+
let id = toHfId(fnv1a(key));
|
|
3312
|
+
let dup = 0;
|
|
3313
|
+
while (assigned.has(id)) {
|
|
3314
|
+
dup += 1;
|
|
3315
|
+
if (dup > 1e4) {
|
|
3316
|
+
id = `hf-${(fnv1a(key) >>> 0).toString(36)}-${dup}`;
|
|
3317
|
+
break;
|
|
3318
|
+
}
|
|
3319
|
+
id = toHfId(fnv1a(`${key}#${dup}`));
|
|
3320
|
+
}
|
|
3321
|
+
assigned.add(id);
|
|
3322
|
+
return id;
|
|
3323
|
+
}
|
|
3324
|
+
function getChildElements(parent) {
|
|
3325
|
+
const directChildren = Array.from(parent.children);
|
|
3326
|
+
if (directChildren.length || parent.tagName.toLowerCase() !== "template") return directChildren;
|
|
3327
|
+
const content = parent.content;
|
|
3328
|
+
if (content?.children.length) return Array.from(content.children);
|
|
3329
|
+
return directChildren;
|
|
3330
|
+
}
|
|
3331
|
+
function isCompositionTemplate(el) {
|
|
3332
|
+
if (el.tagName.toLowerCase() !== "template") return false;
|
|
3333
|
+
if (getContractAttribute(el, "data-composition-id") !== null) return true;
|
|
3334
|
+
for (const child of getChildElements(el)) {
|
|
3335
|
+
if (getContractAttribute(child, "data-composition-id") !== null) return true;
|
|
3336
|
+
}
|
|
3337
|
+
return false;
|
|
3338
|
+
}
|
|
3339
|
+
function walkCompositionDescendants(root, visit) {
|
|
3340
|
+
const rootElement = root.nodeType === 9 ? root.documentElement : root;
|
|
3341
|
+
if (!rootElement) return;
|
|
3342
|
+
const walk = (parent) => {
|
|
3343
|
+
for (const child of getChildElements(parent)) {
|
|
3344
|
+
const isTemplate = child.tagName.toLowerCase() === "template";
|
|
3345
|
+
if (isTemplate && !isCompositionTemplate(child)) continue;
|
|
3346
|
+
visit(child);
|
|
3347
|
+
walk(child);
|
|
3348
|
+
}
|
|
3349
|
+
};
|
|
3350
|
+
walk(rootElement);
|
|
3351
|
+
}
|
|
3352
|
+
function assignHfIds(body) {
|
|
3353
|
+
const assigned = /* @__PURE__ */ new Set();
|
|
3354
|
+
walkCompositionDescendants(body, (el) => {
|
|
3355
|
+
const existing = getContractAttribute(el, "data-hf-id");
|
|
3356
|
+
if (existing) assigned.add(existing);
|
|
3357
|
+
});
|
|
3358
|
+
walkCompositionDescendants(body, (el) => {
|
|
3359
|
+
if (EXCLUDED_TAGS.has(el.tagName.toLowerCase())) return;
|
|
3360
|
+
if (getContractAttribute(el, "data-hf-id")) return;
|
|
3361
|
+
el.setAttribute("data-hf-id", mintHfId(el, assigned));
|
|
3362
|
+
});
|
|
3363
|
+
}
|
|
3364
|
+
function queryByAttr(root, attr, value, tag) {
|
|
3365
|
+
const selector = tag ? `${tag}[${attr}]` : `[${attr}]`;
|
|
3366
|
+
for (const el of root.querySelectorAll(selector)) {
|
|
3367
|
+
if (el.getAttribute(attr) === value) return el;
|
|
3368
|
+
}
|
|
3369
|
+
return null;
|
|
3370
|
+
}
|
|
3371
|
+
function findEnclosingExpressionStatement(ancestors) {
|
|
3372
|
+
for (let i = ancestors.length - 2; i >= 0; i--) {
|
|
3373
|
+
if (ancestors[i]?.type === "ExpressionStatement") return ancestors[i];
|
|
3374
|
+
}
|
|
3375
|
+
return null;
|
|
3376
|
+
}
|
|
3377
|
+
function removeCallFromMagicString(ms, call, script) {
|
|
3378
|
+
const N = call.node;
|
|
3379
|
+
const exprStmt = findEnclosingExpressionStatement(call.ancestors);
|
|
3380
|
+
if (N.callee?.object?.type !== "CallExpression" && exprStmt?.expression === N) {
|
|
3381
|
+
const end = exprStmt.end < script.length && script[exprStmt.end] === "\n" ? exprStmt.end + 1 : exprStmt.end;
|
|
3382
|
+
ms.remove(exprStmt.start, end);
|
|
3383
|
+
} else {
|
|
3384
|
+
ms.remove(N.callee.object.end, N.end);
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
function removeAnimationFromScript(script, animationId) {
|
|
3388
|
+
const parsed = parseGsapScriptAcornForWrite(script);
|
|
3389
|
+
if (!parsed) return script;
|
|
3390
|
+
const target = parsed.located.find((l) => l.id === animationId);
|
|
3391
|
+
if (!target) return script;
|
|
3392
|
+
const ms = new MagicString(script);
|
|
3393
|
+
removeCallFromMagicString(ms, target.call, script);
|
|
3394
|
+
return ms.toString();
|
|
3395
|
+
}
|
|
3396
|
+
var COMPOSITION_ATTRIBUTES = Object.freeze({
|
|
3397
|
+
start: "data-start",
|
|
3398
|
+
duration: "data-duration",
|
|
3399
|
+
trackIndex: "data-track-index",
|
|
3400
|
+
derivedEnd: "data-end",
|
|
3401
|
+
legacyTrack: "data-layer"
|
|
3402
|
+
});
|
|
3403
|
+
var CANONICAL_AUTHORED_TIMING_ATTRIBUTES = Object.freeze([
|
|
3404
|
+
COMPOSITION_ATTRIBUTES.start,
|
|
3405
|
+
COMPOSITION_ATTRIBUTES.duration,
|
|
3406
|
+
COMPOSITION_ATTRIBUTES.trackIndex
|
|
3407
|
+
]);
|
|
3408
|
+
var DERIVED_TIMING_ATTRIBUTES = Object.freeze([
|
|
3409
|
+
COMPOSITION_ATTRIBUTES.derivedEnd
|
|
3410
|
+
]);
|
|
3411
|
+
var LEGACY_TIMING_ATTRIBUTES = Object.freeze([
|
|
3412
|
+
COMPOSITION_ATTRIBUTES.derivedEnd,
|
|
3413
|
+
COMPOSITION_ATTRIBUTES.legacyTrack
|
|
3414
|
+
]);
|
|
3415
|
+
var ClipTimingWriteError = class extends Error {
|
|
3416
|
+
code;
|
|
3417
|
+
constructor(code, message) {
|
|
3418
|
+
super(message);
|
|
3419
|
+
this.name = "ClipTimingWriteError";
|
|
3420
|
+
this.code = code;
|
|
3421
|
+
}
|
|
3422
|
+
};
|
|
3423
|
+
function parseNumeric(value) {
|
|
3424
|
+
if (value == null || value.trim() === "") return null;
|
|
3425
|
+
const parsed = Number(value);
|
|
3426
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
3427
|
+
}
|
|
3428
|
+
var REFERENCE_ID_PATTERN = /^[A-Za-z0-9_.:-]+$/;
|
|
3429
|
+
function isAsciiDigitAt(value, index) {
|
|
3430
|
+
const code = value.charCodeAt(index);
|
|
3431
|
+
return code >= 48 && code <= 57;
|
|
3432
|
+
}
|
|
3433
|
+
function skipDigitsLeft(value, start) {
|
|
3434
|
+
let cursor = start;
|
|
3435
|
+
while (cursor >= 0 && isAsciiDigitAt(value, cursor)) cursor--;
|
|
3436
|
+
return cursor;
|
|
3437
|
+
}
|
|
3438
|
+
function skipWhitespaceLeft(value, start) {
|
|
3439
|
+
let cursor = start;
|
|
3440
|
+
while (cursor >= 0 && (value[cursor] ?? "").trim() === "") cursor--;
|
|
3441
|
+
return cursor;
|
|
3442
|
+
}
|
|
3443
|
+
function findMagnitudeStart(value) {
|
|
3444
|
+
const last = value.length - 1;
|
|
3445
|
+
if (!isAsciiDigitAt(value, last)) return null;
|
|
3446
|
+
let cursor = skipDigitsLeft(value, last);
|
|
3447
|
+
if (value[cursor] === ".") cursor = skipDigitsLeft(value, cursor - 1);
|
|
3448
|
+
return cursor + 1;
|
|
3449
|
+
}
|
|
3450
|
+
function parseReferenceOffset(value) {
|
|
3451
|
+
const magnitudeStart = findMagnitudeStart(value);
|
|
3452
|
+
if (magnitudeStart == null) return null;
|
|
3453
|
+
const operatorIndex = skipWhitespaceLeft(value, magnitudeStart - 1);
|
|
3454
|
+
const operator = value[operatorIndex];
|
|
3455
|
+
if (operator !== "+" && operator !== "-") return null;
|
|
3456
|
+
const refId = value.slice(0, operatorIndex).trim();
|
|
3457
|
+
if (!REFERENCE_ID_PATTERN.test(refId)) return null;
|
|
3458
|
+
const magnitude = Number(value.slice(magnitudeStart));
|
|
3459
|
+
if (!Number.isFinite(magnitude)) return null;
|
|
3460
|
+
return { refId, operator, magnitude };
|
|
3461
|
+
}
|
|
3462
|
+
function parseStartExpression(raw) {
|
|
3463
|
+
const normalized = (raw ?? "").trim();
|
|
3464
|
+
if (!normalized) return null;
|
|
3465
|
+
const absolute = parseNumeric(normalized);
|
|
3466
|
+
if (absolute != null) return { kind: "absolute", value: absolute };
|
|
3467
|
+
if (REFERENCE_ID_PATTERN.test(normalized)) {
|
|
3468
|
+
return { kind: "reference", refId: normalized, offset: 0 };
|
|
3469
|
+
}
|
|
3470
|
+
const reference = parseReferenceOffset(normalized);
|
|
3471
|
+
if (!reference) return null;
|
|
3472
|
+
return {
|
|
3473
|
+
kind: "reference",
|
|
3474
|
+
refId: reference.refId,
|
|
3475
|
+
offset: reference.operator === "-" ? -reference.magnitude : reference.magnitude
|
|
3476
|
+
};
|
|
3477
|
+
}
|
|
3478
|
+
function pushDiagnostic(diagnostics, code, attribute, value) {
|
|
3479
|
+
diagnostics.push({ code, attribute, value });
|
|
3480
|
+
}
|
|
3481
|
+
function resolveStart(expression, rawStart, options, diagnostics) {
|
|
3482
|
+
if (rawStart == null || rawStart.trim() === "") {
|
|
3483
|
+
return options.defaultStart === void 0 ? 0 : options.defaultStart;
|
|
3484
|
+
}
|
|
3485
|
+
if (!expression) {
|
|
3486
|
+
pushDiagnostic(diagnostics, "invalid-start", COMPOSITION_ATTRIBUTES.start, rawStart);
|
|
3487
|
+
return null;
|
|
3488
|
+
}
|
|
3489
|
+
if (expression.kind === "absolute") return Math.max(0, expression.value);
|
|
3490
|
+
const referencedEnd = options.resolveReferenceEnd?.(expression.refId);
|
|
3491
|
+
if (referencedEnd == null || !Number.isFinite(referencedEnd)) {
|
|
3492
|
+
pushDiagnostic(
|
|
3493
|
+
diagnostics,
|
|
3494
|
+
"unresolved-start-reference",
|
|
3495
|
+
COMPOSITION_ATTRIBUTES.start,
|
|
3496
|
+
rawStart
|
|
3497
|
+
);
|
|
3498
|
+
return null;
|
|
3499
|
+
}
|
|
3500
|
+
return Math.max(0, referencedEnd + expression.offset);
|
|
3501
|
+
}
|
|
3502
|
+
var DERIVED_END_EQUALITY_EPSILON_SECONDS = 1e-9;
|
|
3503
|
+
function derivedEndsAreConsistent(parsedEnd, canonicalEnd) {
|
|
3504
|
+
return Math.abs(parsedEnd - canonicalEnd) <= DERIVED_END_EQUALITY_EPSILON_SECONDS;
|
|
3505
|
+
}
|
|
3506
|
+
function diagnoseDerivedEnd(rawEnd, canonicalEnd, diagnostics) {
|
|
3507
|
+
const parsedEnd = parseNumeric(rawEnd);
|
|
3508
|
+
if (parsedEnd == null) {
|
|
3509
|
+
pushDiagnostic(diagnostics, "deprecated-end", COMPOSITION_ATTRIBUTES.derivedEnd, rawEnd);
|
|
3510
|
+
pushDiagnostic(diagnostics, "invalid-end", COMPOSITION_ATTRIBUTES.derivedEnd, rawEnd);
|
|
3511
|
+
return;
|
|
3512
|
+
}
|
|
3513
|
+
if (canonicalEnd == null) {
|
|
3514
|
+
pushDiagnostic(diagnostics, "deprecated-end", COMPOSITION_ATTRIBUTES.derivedEnd, rawEnd);
|
|
3515
|
+
return;
|
|
3516
|
+
}
|
|
3517
|
+
if (derivedEndsAreConsistent(parsedEnd, canonicalEnd)) {
|
|
3518
|
+
return;
|
|
3519
|
+
}
|
|
3520
|
+
pushDiagnostic(diagnostics, "deprecated-end", COMPOSITION_ATTRIBUTES.derivedEnd, rawEnd);
|
|
3521
|
+
pushDiagnostic(diagnostics, "conflicting-end", COMPOSITION_ATTRIBUTES.derivedEnd, rawEnd);
|
|
3522
|
+
}
|
|
3523
|
+
function readCanonicalDuration(rawDuration, start, diagnostics) {
|
|
3524
|
+
const duration = parseNumeric(rawDuration);
|
|
3525
|
+
if (duration == null || duration < 0) {
|
|
3526
|
+
pushDiagnostic(diagnostics, "invalid-duration", COMPOSITION_ATTRIBUTES.duration, rawDuration);
|
|
3527
|
+
return { duration: null, end: null, durationSource: "invalid" };
|
|
3528
|
+
}
|
|
3529
|
+
return {
|
|
3530
|
+
duration,
|
|
3531
|
+
end: start == null ? null : start + duration,
|
|
3532
|
+
durationSource: "duration"
|
|
3533
|
+
};
|
|
3534
|
+
}
|
|
3535
|
+
function readLegacyEnd(rawEnd, start, diagnostics) {
|
|
3536
|
+
pushDiagnostic(diagnostics, "deprecated-end", COMPOSITION_ATTRIBUTES.derivedEnd, rawEnd);
|
|
3537
|
+
const end = parseNumeric(rawEnd);
|
|
3538
|
+
if (end == null) {
|
|
3539
|
+
pushDiagnostic(diagnostics, "invalid-end", COMPOSITION_ATTRIBUTES.derivedEnd, rawEnd);
|
|
3540
|
+
return { duration: null, end: null, durationSource: "invalid" };
|
|
3541
|
+
}
|
|
3542
|
+
if (start == null) return { duration: null, end, durationSource: "legacy-end" };
|
|
3543
|
+
if (end < start) {
|
|
3544
|
+
pushDiagnostic(diagnostics, "end-before-start", COMPOSITION_ATTRIBUTES.derivedEnd, rawEnd);
|
|
3545
|
+
return { duration: null, end: null, durationSource: "invalid" };
|
|
3546
|
+
}
|
|
3547
|
+
return { duration: end - start, end, durationSource: "legacy-end" };
|
|
3548
|
+
}
|
|
3549
|
+
function readDuration(attributes, start, diagnostics) {
|
|
3550
|
+
const rawDuration = attributes.getAttribute(COMPOSITION_ATTRIBUTES.duration);
|
|
3551
|
+
const rawEnd = attributes.getAttribute(COMPOSITION_ATTRIBUTES.derivedEnd);
|
|
3552
|
+
if (rawDuration == null) {
|
|
3553
|
+
return rawEnd == null ? { duration: null, end: null, durationSource: "missing" } : readLegacyEnd(rawEnd, start, diagnostics);
|
|
3554
|
+
}
|
|
3555
|
+
const canonical = readCanonicalDuration(rawDuration, start, diagnostics);
|
|
3556
|
+
if (rawEnd != null) diagnoseDerivedEnd(rawEnd, canonical.end, diagnostics);
|
|
3557
|
+
return canonical;
|
|
3558
|
+
}
|
|
3559
|
+
function readTrackValue(rawValue, attribute, source, diagnostics) {
|
|
3560
|
+
const trackIndex = parseNumeric(rawValue);
|
|
3561
|
+
if (trackIndex == null || !Number.isInteger(trackIndex)) {
|
|
3562
|
+
pushDiagnostic(diagnostics, "invalid-track-index", attribute, rawValue);
|
|
3563
|
+
return { trackIndex: 0, trackSource: "invalid" };
|
|
3564
|
+
}
|
|
3565
|
+
return { trackIndex, trackSource: source };
|
|
3566
|
+
}
|
|
3567
|
+
function readTrack(attributes, diagnostics) {
|
|
3568
|
+
const rawTrack = attributes.getAttribute(COMPOSITION_ATTRIBUTES.trackIndex);
|
|
3569
|
+
const rawLayer = attributes.getAttribute(COMPOSITION_ATTRIBUTES.legacyTrack);
|
|
3570
|
+
if (rawTrack == null && rawLayer == null) return { trackIndex: 0, trackSource: "default" };
|
|
3571
|
+
if (rawTrack == null && rawLayer != null) {
|
|
3572
|
+
pushDiagnostic(diagnostics, "deprecated-layer", COMPOSITION_ATTRIBUTES.legacyTrack, rawLayer);
|
|
3573
|
+
return readTrackValue(
|
|
3574
|
+
rawLayer,
|
|
3575
|
+
COMPOSITION_ATTRIBUTES.legacyTrack,
|
|
3576
|
+
"legacy-layer",
|
|
3577
|
+
diagnostics
|
|
3578
|
+
);
|
|
3579
|
+
}
|
|
3580
|
+
const canonical = readTrackValue(
|
|
3581
|
+
rawTrack ?? "",
|
|
3582
|
+
COMPOSITION_ATTRIBUTES.trackIndex,
|
|
3583
|
+
"track-index",
|
|
3584
|
+
diagnostics
|
|
3585
|
+
);
|
|
3586
|
+
if (rawLayer == null) return canonical;
|
|
3587
|
+
pushDiagnostic(diagnostics, "deprecated-layer", COMPOSITION_ATTRIBUTES.legacyTrack, rawLayer);
|
|
3588
|
+
const parsedLayer = parseNumeric(rawLayer);
|
|
3589
|
+
if (parsedLayer != null && parsedLayer !== canonical.trackIndex) {
|
|
3590
|
+
pushDiagnostic(diagnostics, "conflicting-layer", COMPOSITION_ATTRIBUTES.legacyTrack, rawLayer);
|
|
3591
|
+
}
|
|
3592
|
+
return canonical;
|
|
3593
|
+
}
|
|
3594
|
+
function readClipTiming(attributes, options = {}) {
|
|
3595
|
+
const diagnostics = [];
|
|
3596
|
+
const rawStart = attributes.getAttribute(COMPOSITION_ATTRIBUTES.start);
|
|
3597
|
+
const startExpression = parseStartExpression(rawStart);
|
|
3598
|
+
const start = resolveStart(startExpression, rawStart, options, diagnostics);
|
|
3599
|
+
const duration = readDuration(attributes, start, diagnostics);
|
|
3600
|
+
const track = readTrack(attributes, diagnostics);
|
|
3601
|
+
return { startExpression, start, ...duration, ...track, diagnostics };
|
|
3602
|
+
}
|
|
3603
|
+
function serializeStartNumber(start) {
|
|
3604
|
+
if (!Number.isFinite(start)) {
|
|
3605
|
+
throw new ClipTimingWriteError("invalid-start", "start must be finite");
|
|
3606
|
+
}
|
|
3607
|
+
return String(start);
|
|
3608
|
+
}
|
|
3609
|
+
function serializeStartReference(start) {
|
|
3610
|
+
if (start.kind === "absolute") return serializeStartNumber(start.value);
|
|
3611
|
+
if (!start.refId || !Number.isFinite(start.offset)) {
|
|
3612
|
+
throw new ClipTimingWriteError(
|
|
3613
|
+
"invalid-start",
|
|
3614
|
+
"reference start must have an id and finite offset"
|
|
3615
|
+
);
|
|
3616
|
+
}
|
|
3617
|
+
if (start.offset === 0) return start.refId;
|
|
3618
|
+
return `${start.refId} ${start.offset < 0 ? "-" : "+"} ${Math.abs(start.offset)}`;
|
|
3619
|
+
}
|
|
3620
|
+
function serializeStart(start) {
|
|
3621
|
+
if (typeof start === "number") return serializeStartNumber(start);
|
|
3622
|
+
if (typeof start === "object" && start != null) return serializeStartReference(start);
|
|
3623
|
+
if (typeof start === "string" && parseStartExpression(start)) return start.trim();
|
|
3624
|
+
throw new ClipTimingWriteError("invalid-start", `invalid start expression: ${start ?? ""}`);
|
|
3625
|
+
}
|
|
3626
|
+
function writeDuration(attributes, duration, current) {
|
|
3627
|
+
if (duration === null) {
|
|
3628
|
+
attributes.removeAttribute(COMPOSITION_ATTRIBUTES.duration);
|
|
3629
|
+
return;
|
|
3630
|
+
}
|
|
3631
|
+
if (duration === void 0) {
|
|
3632
|
+
if (attributes.getAttribute(COMPOSITION_ATTRIBUTES.duration) == null && current.duration != null) {
|
|
3633
|
+
attributes.setAttribute(COMPOSITION_ATTRIBUTES.duration, String(current.duration));
|
|
3634
|
+
}
|
|
3635
|
+
return;
|
|
3636
|
+
}
|
|
3637
|
+
if (!Number.isFinite(duration) || duration < 0) {
|
|
3638
|
+
throw new ClipTimingWriteError(
|
|
3639
|
+
"invalid-duration",
|
|
3640
|
+
"duration must be a finite, non-negative number"
|
|
3641
|
+
);
|
|
3642
|
+
}
|
|
3643
|
+
attributes.setAttribute(COMPOSITION_ATTRIBUTES.duration, String(duration));
|
|
3644
|
+
}
|
|
3645
|
+
function writeTrack(attributes, trackIndex, current) {
|
|
3646
|
+
if (trackIndex === null) {
|
|
3647
|
+
attributes.removeAttribute(COMPOSITION_ATTRIBUTES.trackIndex);
|
|
3648
|
+
return;
|
|
3649
|
+
}
|
|
3650
|
+
if (trackIndex === void 0) {
|
|
3651
|
+
if (attributes.getAttribute(COMPOSITION_ATTRIBUTES.trackIndex) == null && current.trackSource === "legacy-layer") {
|
|
3652
|
+
attributes.setAttribute(COMPOSITION_ATTRIBUTES.trackIndex, String(current.trackIndex));
|
|
3653
|
+
}
|
|
3654
|
+
return;
|
|
3655
|
+
}
|
|
3656
|
+
if (!Number.isFinite(trackIndex) || !Number.isInteger(trackIndex)) {
|
|
3657
|
+
throw new ClipTimingWriteError("invalid-track-index", "trackIndex must be a finite integer");
|
|
3658
|
+
}
|
|
3659
|
+
attributes.setAttribute(COMPOSITION_ATTRIBUTES.trackIndex, String(trackIndex));
|
|
3660
|
+
}
|
|
3661
|
+
function writeClipTiming(attributes, update) {
|
|
3662
|
+
const current = readClipTiming(attributes);
|
|
3663
|
+
if (update.start !== void 0) {
|
|
3664
|
+
attributes.setAttribute(COMPOSITION_ATTRIBUTES.start, serializeStart(update.start));
|
|
3665
|
+
}
|
|
3666
|
+
writeDuration(attributes, update.duration, current);
|
|
3667
|
+
writeTrack(attributes, update.trackIndex, current);
|
|
3668
|
+
const preserveUnresolvedLegacyEnd = update.duration === void 0 && attributes.getAttribute(COMPOSITION_ATTRIBUTES.duration) == null && attributes.getAttribute(COMPOSITION_ATTRIBUTES.derivedEnd) != null && current.duration == null;
|
|
3669
|
+
if (!preserveUnresolvedLegacyEnd) {
|
|
3670
|
+
attributes.removeAttribute(COMPOSITION_ATTRIBUTES.derivedEnd);
|
|
3671
|
+
}
|
|
3672
|
+
attributes.removeAttribute(COMPOSITION_ATTRIBUTES.legacyTrack);
|
|
3673
|
+
return readClipTiming(attributes);
|
|
3674
|
+
}
|
|
3675
|
+
var MEDIA_TYPES = /* @__PURE__ */ new Set(["video", "image", "audio"]);
|
|
3676
|
+
var CompositionHtmlParseError = class extends Error {
|
|
3677
|
+
constructor(message) {
|
|
3678
|
+
super(message);
|
|
3679
|
+
this.name = "CompositionHtmlParseError";
|
|
3680
|
+
}
|
|
3681
|
+
};
|
|
3682
|
+
function getElementType(el) {
|
|
3683
|
+
const tag = el.tagName.toLowerCase();
|
|
3684
|
+
if (tag === "video") return "video";
|
|
3685
|
+
if (tag === "img") return "image";
|
|
3686
|
+
if (tag === "audio") return "audio";
|
|
3687
|
+
const dataType = el.getAttribute("data-type");
|
|
3688
|
+
if (dataType === "composition") return "composition";
|
|
3689
|
+
if (dataType === "text") return "text";
|
|
3690
|
+
if (tag === "div" || tag === "p" || tag === "h1" || tag === "h2" || tag === "h3" || tag === "span") {
|
|
3691
|
+
return "text";
|
|
3692
|
+
}
|
|
3693
|
+
return null;
|
|
3694
|
+
}
|
|
3695
|
+
function getElementName(el) {
|
|
3696
|
+
const dataName = el.getAttribute("data-name");
|
|
3697
|
+
if (dataName) return dataName;
|
|
3698
|
+
const type = getElementType(el);
|
|
3699
|
+
if (type === "text") {
|
|
3700
|
+
const text = el.textContent?.trim().slice(0, 30) || "Text";
|
|
3701
|
+
return text.length === 30 ? text + "..." : text;
|
|
3702
|
+
}
|
|
3703
|
+
const src = el.getAttribute("src");
|
|
3704
|
+
if (src) {
|
|
3705
|
+
const filename = src.split("/").pop() || src;
|
|
3706
|
+
return filename.split("?")[0] ?? filename;
|
|
3707
|
+
}
|
|
3708
|
+
return el.id || el.className?.toString().split(" ")[0] || "Element";
|
|
3709
|
+
}
|
|
3710
|
+
function getZIndex(el) {
|
|
3711
|
+
const timing = readClipTiming(el);
|
|
3712
|
+
if (timing.trackSource !== "default" && timing.trackSource !== "invalid") {
|
|
3713
|
+
return timing.trackIndex;
|
|
3714
|
+
}
|
|
3715
|
+
const style = el.style?.zIndex;
|
|
3716
|
+
if (style) return parseInt(style, 10) || 0;
|
|
3717
|
+
return 0;
|
|
3718
|
+
}
|
|
3719
|
+
function parseResolutionFromCss(doc, cssText) {
|
|
3720
|
+
const stage = doc.getElementById("stage") || doc.querySelector("#stage");
|
|
3721
|
+
if (stage) {
|
|
3722
|
+
const inlineStyle = stage.style;
|
|
3723
|
+
if (inlineStyle?.width && inlineStyle?.height) {
|
|
3724
|
+
const w = parseInt(inlineStyle.width, 10);
|
|
3725
|
+
const h = parseInt(inlineStyle.height, 10);
|
|
3726
|
+
if (w && h) {
|
|
3727
|
+
return resolveResolutionFromDimensions(w, h);
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
if (cssText) {
|
|
3732
|
+
const stageMatch = cssText.match(
|
|
3733
|
+
/#stage\s*\{[^}]*width:\s*(\d+)px[^}]*height:\s*(\d+)px[^}]*\}/
|
|
3734
|
+
);
|
|
3735
|
+
if (stageMatch) {
|
|
3736
|
+
const w = parseInt(stageMatch[1] ?? "", 10);
|
|
3737
|
+
const h = parseInt(stageMatch[2] ?? "", 10);
|
|
3738
|
+
return resolveResolutionFromDimensions(w, h);
|
|
3739
|
+
}
|
|
3740
|
+
const stageMatchReverse = cssText.match(
|
|
3741
|
+
/#stage\s*\{[^}]*height:\s*(\d+)px[^}]*width:\s*(\d+)px[^}]*\}/
|
|
3742
|
+
);
|
|
3743
|
+
if (stageMatchReverse) {
|
|
3744
|
+
const h = parseInt(stageMatchReverse[1] ?? "", 10);
|
|
3745
|
+
const w = parseInt(stageMatchReverse[2] ?? "", 10);
|
|
3746
|
+
return resolveResolutionFromDimensions(w, h);
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
return "portrait";
|
|
3750
|
+
}
|
|
3751
|
+
function parseResolutionFromHtml(doc) {
|
|
3752
|
+
const htmlEl = doc.documentElement;
|
|
3753
|
+
if (!htmlEl) return null;
|
|
3754
|
+
const resolutionAttr = htmlEl.getAttribute("data-resolution");
|
|
3755
|
+
if (resolutionAttr === "landscape" || resolutionAttr === "portrait" || resolutionAttr === "landscape-4k" || resolutionAttr === "portrait-4k" || resolutionAttr === "square" || resolutionAttr === "square-4k") {
|
|
3756
|
+
return resolutionAttr;
|
|
3757
|
+
}
|
|
3758
|
+
const widthAttr = htmlEl.getAttribute("data-composition-width");
|
|
3759
|
+
const heightAttr = htmlEl.getAttribute("data-composition-height");
|
|
3760
|
+
if (widthAttr && heightAttr) {
|
|
3761
|
+
const width = parseInt(widthAttr, 10);
|
|
3762
|
+
const height = parseInt(heightAttr, 10);
|
|
3763
|
+
if (width && height) {
|
|
3764
|
+
return resolveResolutionFromDimensions(width, height);
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
return null;
|
|
3768
|
+
}
|
|
3769
|
+
var UHD_SQUARE_MIN = 2160;
|
|
3770
|
+
var UHD_RECT_MIN = 3840;
|
|
3771
|
+
function resolveResolutionFromDimensions(width, height) {
|
|
3772
|
+
const longSide = Math.max(width, height);
|
|
3773
|
+
if (width === height) {
|
|
3774
|
+
return longSide >= UHD_SQUARE_MIN ? "square-4k" : "square";
|
|
3775
|
+
}
|
|
3776
|
+
const isLandscape = width > height;
|
|
3777
|
+
const isUhd = longSide >= UHD_RECT_MIN;
|
|
3778
|
+
if (isLandscape) return isUhd ? "landscape-4k" : "landscape";
|
|
3779
|
+
return isUhd ? "portrait-4k" : "portrait";
|
|
3780
|
+
}
|
|
3781
|
+
function parseHtml(html) {
|
|
3782
|
+
const parser = new DOMParser();
|
|
3783
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
3784
|
+
const elements = [];
|
|
3785
|
+
const keyframes = {};
|
|
3786
|
+
let idCounter = 0;
|
|
3787
|
+
const htmlEl = doc.documentElement;
|
|
3788
|
+
if (!htmlEl) {
|
|
3789
|
+
throw new CompositionHtmlParseError("parseHtml: input HTML is empty or could not be parsed");
|
|
3790
|
+
}
|
|
3791
|
+
if (doc.body) assignHfIds(doc.body);
|
|
3792
|
+
const customStylesAttr = htmlEl.getAttribute("data-custom-styles");
|
|
3793
|
+
let customStyles = null;
|
|
3794
|
+
if (customStylesAttr) {
|
|
3795
|
+
try {
|
|
3796
|
+
customStyles = JSON.parse(customStylesAttr);
|
|
3797
|
+
} catch {
|
|
3798
|
+
customStyles = customStylesAttr;
|
|
3799
|
+
}
|
|
3800
|
+
}
|
|
3801
|
+
const timedElements = Array.from(doc.querySelectorAll("[data-start]"));
|
|
3802
|
+
const timedById = /* @__PURE__ */ new Map();
|
|
3803
|
+
for (const element of timedElements) {
|
|
3804
|
+
for (const id of [element.id, element.getAttribute("data-hf-id")]) {
|
|
3805
|
+
if (id) timedById.set(id, element);
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
const resolveEnd = (refId, visiting) => {
|
|
3809
|
+
if (visiting.has(refId)) return null;
|
|
3810
|
+
const referenced = timedById.get(refId);
|
|
3811
|
+
if (!referenced) return null;
|
|
3812
|
+
const next = new Set(visiting);
|
|
3813
|
+
next.add(refId);
|
|
3814
|
+
return readClipTiming(referenced, {
|
|
3815
|
+
resolveReferenceEnd: (nestedId) => resolveEnd(nestedId, next)
|
|
3816
|
+
}).end;
|
|
3817
|
+
};
|
|
3818
|
+
timedElements.forEach((el) => {
|
|
3819
|
+
const type = getElementType(el);
|
|
3820
|
+
if (!type) return;
|
|
3821
|
+
const ownId = el.id || el.getAttribute("data-hf-id");
|
|
3822
|
+
const timing = readClipTiming(el, {
|
|
3823
|
+
resolveReferenceEnd: (refId) => resolveEnd(refId, new Set(ownId ? [ownId] : []))
|
|
3824
|
+
});
|
|
3825
|
+
const start = timing.start ?? 0;
|
|
3826
|
+
const duration = timing.duration ?? 5;
|
|
3827
|
+
const id = el.getAttribute("data-hf-id") || el.id || `element-${++idCounter}`;
|
|
3828
|
+
const name = getElementName(el);
|
|
3829
|
+
const zIndex = getZIndex(el);
|
|
3830
|
+
const keyframesAttr = el.getAttribute("data-keyframes");
|
|
3831
|
+
if (keyframesAttr) {
|
|
3832
|
+
try {
|
|
3833
|
+
const parsedKeyframes = JSON.parse(keyframesAttr);
|
|
3834
|
+
if (Array.isArray(parsedKeyframes) && parsedKeyframes.length > 0) {
|
|
3835
|
+
keyframes[id] = parsedKeyframes;
|
|
3836
|
+
}
|
|
3837
|
+
} catch {
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3840
|
+
const xAttr = el.getAttribute("data-x");
|
|
3841
|
+
const yAttr = el.getAttribute("data-y");
|
|
3842
|
+
const scaleAttr = el.getAttribute("data-scale");
|
|
3843
|
+
const opacityAttr = el.getAttribute("data-opacity");
|
|
3844
|
+
const x = xAttr ? parseFloat(xAttr) : void 0;
|
|
3845
|
+
const y = yAttr ? parseFloat(yAttr) : void 0;
|
|
3846
|
+
const scale = scaleAttr ? parseFloat(scaleAttr) : void 0;
|
|
3847
|
+
const opacity = opacityAttr ? parseFloat(opacityAttr) : void 0;
|
|
3848
|
+
if (type === "text") {
|
|
3849
|
+
const textEl = el.firstElementChild;
|
|
3850
|
+
const content = textEl?.textContent ?? name;
|
|
3851
|
+
const color = el.getAttribute("data-color") || void 0;
|
|
3852
|
+
const fontSizeAttr = el.getAttribute("data-font-size");
|
|
3853
|
+
const fontSize = fontSizeAttr ? parseInt(fontSizeAttr, 10) : void 0;
|
|
3854
|
+
const fontWeightAttr = el.getAttribute("data-font-weight");
|
|
3855
|
+
const fontWeight = fontWeightAttr ? parseInt(fontWeightAttr, 10) : void 0;
|
|
3856
|
+
const fontFamily = el.getAttribute("data-font-family") || void 0;
|
|
3857
|
+
const textShadowAttr = el.getAttribute("data-text-shadow");
|
|
3858
|
+
const textShadow = textShadowAttr === "false" ? false : void 0;
|
|
3859
|
+
const textOutlineAttr = el.getAttribute("data-text-outline");
|
|
3860
|
+
const textOutline = textOutlineAttr === "true" ? true : void 0;
|
|
3861
|
+
const textOutlineColor = el.getAttribute("data-text-outline-color") || void 0;
|
|
3862
|
+
const textOutlineWidthAttr = el.getAttribute("data-text-outline-width");
|
|
3863
|
+
const textOutlineWidth = textOutlineWidthAttr ? parseInt(textOutlineWidthAttr, 10) : void 0;
|
|
3864
|
+
const textHighlightAttr = el.getAttribute("data-text-highlight");
|
|
3865
|
+
const textHighlight = textHighlightAttr === "true" ? true : void 0;
|
|
3866
|
+
const textHighlightColor = el.getAttribute("data-text-highlight-color") || void 0;
|
|
3867
|
+
const textHighlightPaddingAttr = el.getAttribute("data-text-highlight-padding");
|
|
3868
|
+
const textHighlightPadding = textHighlightPaddingAttr ? parseInt(textHighlightPaddingAttr, 10) : void 0;
|
|
3869
|
+
const textHighlightRadiusAttr = el.getAttribute("data-text-highlight-radius");
|
|
3870
|
+
const textHighlightRadius = textHighlightRadiusAttr ? parseInt(textHighlightRadiusAttr, 10) : void 0;
|
|
3871
|
+
const textElement = {
|
|
3872
|
+
id,
|
|
3873
|
+
type: "text",
|
|
3874
|
+
name,
|
|
3875
|
+
content,
|
|
3876
|
+
startTime: start,
|
|
3877
|
+
duration,
|
|
3878
|
+
zIndex,
|
|
3879
|
+
x,
|
|
3880
|
+
y,
|
|
3881
|
+
scale,
|
|
3882
|
+
opacity,
|
|
3883
|
+
color,
|
|
3884
|
+
fontSize,
|
|
3885
|
+
fontWeight,
|
|
3886
|
+
fontFamily,
|
|
3887
|
+
textShadow,
|
|
3888
|
+
textOutline,
|
|
3889
|
+
textOutlineColor,
|
|
3890
|
+
textOutlineWidth,
|
|
3891
|
+
textHighlight,
|
|
3892
|
+
textHighlightColor,
|
|
3893
|
+
textHighlightPadding,
|
|
3894
|
+
textHighlightRadius
|
|
3895
|
+
};
|
|
3896
|
+
elements.push(textElement);
|
|
3897
|
+
} else if (type === "composition") {
|
|
3898
|
+
const iframe = el.querySelector("iframe");
|
|
3899
|
+
const src = iframe?.getAttribute("src") || el.getAttribute("src") || "";
|
|
3900
|
+
const compositionId = el.getAttribute("data-composition-id") || "";
|
|
3901
|
+
const sourceDurationAttr = el.getAttribute("data-source-duration");
|
|
3902
|
+
const sourceDuration = sourceDurationAttr ? parseFloat(sourceDurationAttr) : void 0;
|
|
3903
|
+
const sourceWidthAttr = el.getAttribute("data-source-width");
|
|
3904
|
+
const sourceWidth = sourceWidthAttr ? parseInt(sourceWidthAttr, 10) : void 0;
|
|
3905
|
+
const sourceHeightAttr = el.getAttribute("data-source-height");
|
|
3906
|
+
const sourceHeight = sourceHeightAttr ? parseInt(sourceHeightAttr, 10) : void 0;
|
|
3907
|
+
const variableValuesAttr = el.getAttribute("data-variable-values");
|
|
3908
|
+
let variableValues;
|
|
3909
|
+
if (variableValuesAttr) {
|
|
3910
|
+
try {
|
|
3911
|
+
variableValues = JSON.parse(variableValuesAttr);
|
|
3912
|
+
} catch {
|
|
3913
|
+
}
|
|
3914
|
+
}
|
|
3915
|
+
const compositionElement = {
|
|
3916
|
+
id,
|
|
3917
|
+
type: "composition",
|
|
3918
|
+
name,
|
|
3919
|
+
src,
|
|
3920
|
+
compositionId,
|
|
3921
|
+
startTime: start,
|
|
3922
|
+
duration,
|
|
3923
|
+
zIndex,
|
|
3924
|
+
x,
|
|
3925
|
+
y,
|
|
3926
|
+
scale,
|
|
3927
|
+
opacity,
|
|
3928
|
+
sourceDuration,
|
|
3929
|
+
sourceWidth,
|
|
3930
|
+
sourceHeight,
|
|
3931
|
+
variableValues
|
|
3932
|
+
};
|
|
3933
|
+
elements.push(compositionElement);
|
|
3934
|
+
} else {
|
|
3935
|
+
if (!MEDIA_TYPES.has(type)) return;
|
|
3936
|
+
const src = el.getAttribute("src") || "";
|
|
3937
|
+
const mediaStartTimeAttr = el.getAttribute("data-media-start");
|
|
3938
|
+
const mediaStartTime = mediaStartTimeAttr ? parseFloat(mediaStartTimeAttr) : void 0;
|
|
3939
|
+
const sourceDurationAttr = el.getAttribute("data-source-duration");
|
|
3940
|
+
const sourceDuration = sourceDurationAttr ? parseFloat(sourceDurationAttr) : void 0;
|
|
3941
|
+
const isArollAttr = el.getAttribute("data-aroll");
|
|
3942
|
+
const isAroll = isArollAttr === "true" ? true : void 0;
|
|
3943
|
+
const volumeAttr = el.getAttribute("data-volume");
|
|
3944
|
+
const volume = volumeAttr ? parseFloat(volumeAttr) : void 0;
|
|
3945
|
+
const hasAudioAttr = el.getAttribute("data-has-audio");
|
|
3946
|
+
const hasAudio = hasAudioAttr === "true" ? true : void 0;
|
|
3947
|
+
const mediaElement = {
|
|
3948
|
+
id,
|
|
3949
|
+
type,
|
|
3950
|
+
name,
|
|
3951
|
+
src,
|
|
3952
|
+
startTime: start,
|
|
3953
|
+
duration,
|
|
3954
|
+
zIndex,
|
|
3955
|
+
x,
|
|
3956
|
+
y,
|
|
3957
|
+
scale,
|
|
3958
|
+
opacity,
|
|
3959
|
+
mediaStartTime,
|
|
3960
|
+
sourceDuration,
|
|
3961
|
+
isAroll,
|
|
3962
|
+
volume,
|
|
3963
|
+
hasAudio
|
|
3964
|
+
};
|
|
3965
|
+
elements.push(mediaElement);
|
|
3966
|
+
}
|
|
3967
|
+
});
|
|
3968
|
+
const scriptTags = findScriptElementsDeep(doc);
|
|
3969
|
+
let gsapScript = null;
|
|
3970
|
+
for (const script of scriptTags) {
|
|
3971
|
+
const src = script.getAttribute("src");
|
|
3972
|
+
if (src && src.includes("gsap")) continue;
|
|
3973
|
+
const content = script.textContent?.trim();
|
|
3974
|
+
if (content && (content.includes("gsap") || content.includes("timeline"))) {
|
|
3975
|
+
gsapScript = content;
|
|
3976
|
+
break;
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
for (const element of elements) {
|
|
3980
|
+
const elementKeyframes = keyframes[element.id];
|
|
3981
|
+
if (!elementKeyframes || elementKeyframes.length === 0) continue;
|
|
3982
|
+
const baseX = element.x ?? 0;
|
|
3983
|
+
const baseY = element.y ?? 0;
|
|
3984
|
+
const baseScale = element.type === "video" || element.type === "image" || element.type === "composition" ? element.scale ?? 1 : 1;
|
|
3985
|
+
keyframes[element.id] = normalizeKeyframes(elementKeyframes, baseX, baseY, baseScale);
|
|
3986
|
+
}
|
|
3987
|
+
const styleTags = doc.querySelectorAll("style");
|
|
3988
|
+
const allStyles = Array.from(styleTags).map((s) => s.textContent?.trim()).filter(Boolean).join("\n\n") || null;
|
|
3989
|
+
const customStyleTags = Array.from(styleTags).filter(
|
|
3990
|
+
(s) => s.getAttribute("data-hf-custom") === "true"
|
|
3991
|
+
);
|
|
3992
|
+
const customStylesFromTags = customStyleTags.map((s) => s.textContent?.trim()).filter(Boolean).join("\n\n") || null;
|
|
3993
|
+
const styles = customStyles ?? customStylesFromTags ?? null;
|
|
3994
|
+
const resolution = parseResolutionFromHtml(doc) ?? parseResolutionFromCss(doc, allStyles);
|
|
3995
|
+
const stageZoomKeyframes = parseStageZoomKeyframes(doc);
|
|
3996
|
+
return {
|
|
3997
|
+
elements,
|
|
3998
|
+
gsapScript,
|
|
3999
|
+
styles,
|
|
4000
|
+
resolution,
|
|
4001
|
+
keyframes,
|
|
4002
|
+
stageZoomKeyframes
|
|
4003
|
+
};
|
|
4004
|
+
}
|
|
4005
|
+
function parseStageZoomKeyframes(doc) {
|
|
4006
|
+
const zoomContainer = doc.getElementById("stage-zoom-container");
|
|
4007
|
+
if (!zoomContainer) {
|
|
4008
|
+
return [];
|
|
4009
|
+
}
|
|
4010
|
+
const zoomKeyframesAttr = zoomContainer.getAttribute("data-zoom-keyframes");
|
|
4011
|
+
if (!zoomKeyframesAttr) {
|
|
4012
|
+
return [];
|
|
4013
|
+
}
|
|
4014
|
+
try {
|
|
4015
|
+
const parsed = JSON.parse(zoomKeyframesAttr);
|
|
4016
|
+
if (Array.isArray(parsed)) {
|
|
4017
|
+
return parsed.filter(
|
|
4018
|
+
(kf) => typeof kf === "object" && kf !== null && typeof kf.id === "string" && typeof kf.time === "number" && typeof kf.zoom === "object" && kf.zoom !== null && typeof kf.zoom.scale === "number" && typeof kf.zoom.focusX === "number" && typeof kf.zoom.focusY === "number"
|
|
4019
|
+
);
|
|
4020
|
+
}
|
|
4021
|
+
} catch {
|
|
4022
|
+
}
|
|
4023
|
+
return [];
|
|
4024
|
+
}
|
|
4025
|
+
function normalizeKeyframes(keyframes, baseX, baseY, baseScale) {
|
|
4026
|
+
const timeEpsilon = 1e-3;
|
|
4027
|
+
const valueEpsilon = 1e-5;
|
|
4028
|
+
const hasBaseCheck = (value, base) => value !== void 0 && Math.abs(value - base) <= valueEpsilon && Math.abs(base) > valueEpsilon;
|
|
4029
|
+
const timeZeroKeyframes = keyframes.filter((kf) => Math.abs(kf.time) <= timeEpsilon);
|
|
4030
|
+
const treatAsAbsolute = timeZeroKeyframes.some((kf) => {
|
|
4031
|
+
const props = kf.properties || {};
|
|
4032
|
+
if (hasBaseCheck(props.x, baseX) || hasBaseCheck(props.y, baseY) || baseScale !== 1 && hasBaseCheck(props.scale, baseScale)) {
|
|
4033
|
+
return true;
|
|
4034
|
+
}
|
|
4035
|
+
return false;
|
|
4036
|
+
});
|
|
4037
|
+
return keyframes.map((kf) => {
|
|
4038
|
+
const normalizedProps = {};
|
|
4039
|
+
for (const [key, value] of Object.entries(kf.properties || {})) {
|
|
4040
|
+
if (typeof value !== "number") continue;
|
|
4041
|
+
if (treatAsAbsolute && key === "x") {
|
|
4042
|
+
normalizedProps.x = value - baseX;
|
|
4043
|
+
} else if (treatAsAbsolute && key === "y") {
|
|
4044
|
+
normalizedProps.y = value - baseY;
|
|
4045
|
+
} else if (treatAsAbsolute && key === "scale") {
|
|
4046
|
+
normalizedProps.scale = baseScale !== 0 ? value / baseScale : value;
|
|
4047
|
+
} else {
|
|
4048
|
+
normalizedProps[key] = value;
|
|
4049
|
+
}
|
|
4050
|
+
}
|
|
4051
|
+
return {
|
|
4052
|
+
...kf,
|
|
4053
|
+
time: Math.max(0, kf.time),
|
|
4054
|
+
properties: normalizedProps
|
|
4055
|
+
};
|
|
4056
|
+
});
|
|
4057
|
+
}
|
|
4058
|
+
function updateElementInHtml(html, elementId, updates) {
|
|
4059
|
+
const parser = new DOMParser();
|
|
4060
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
4061
|
+
const el = doc.getElementById(elementId) || queryByAttr(doc, "data-name", elementId);
|
|
4062
|
+
if (!el) return html;
|
|
4063
|
+
if (updates.startTime !== void 0 || updates.duration !== void 0 || updates.zIndex !== void 0) {
|
|
4064
|
+
writeClipTiming(el, {
|
|
4065
|
+
start: updates.startTime,
|
|
4066
|
+
duration: updates.duration,
|
|
4067
|
+
trackIndex: updates.zIndex
|
|
4068
|
+
});
|
|
4069
|
+
}
|
|
4070
|
+
if (updates.name !== void 0) {
|
|
4071
|
+
el.setAttribute("data-name", updates.name);
|
|
4072
|
+
}
|
|
4073
|
+
if ("src" in updates && updates.src !== void 0) {
|
|
4074
|
+
el.setAttribute("src", updates.src);
|
|
4075
|
+
}
|
|
4076
|
+
if ("content" in updates && updates.content !== void 0) {
|
|
4077
|
+
const textEl = el.firstElementChild;
|
|
4078
|
+
if (textEl) {
|
|
4079
|
+
textEl.textContent = updates.content;
|
|
4080
|
+
}
|
|
4081
|
+
}
|
|
4082
|
+
if ("color" in updates && updates.color !== void 0) {
|
|
4083
|
+
el.setAttribute("data-color", updates.color);
|
|
4084
|
+
}
|
|
4085
|
+
if ("fontSize" in updates && updates.fontSize !== void 0) {
|
|
4086
|
+
el.setAttribute("data-font-size", String(updates.fontSize));
|
|
4087
|
+
}
|
|
4088
|
+
if ("textShadow" in updates) {
|
|
4089
|
+
if (updates.textShadow === false) {
|
|
4090
|
+
el.setAttribute("data-text-shadow", "false");
|
|
4091
|
+
} else {
|
|
4092
|
+
el.removeAttribute("data-text-shadow");
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
if ("volume" in updates) {
|
|
4096
|
+
if (updates.volume !== void 0 && updates.volume !== 1) {
|
|
4097
|
+
el.setAttribute("data-volume", String(updates.volume));
|
|
4098
|
+
} else {
|
|
4099
|
+
el.removeAttribute("data-volume");
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
if (el.tagName.toLowerCase() === "video" && "hasAudio" in updates) {
|
|
4103
|
+
if (updates.hasAudio === true) {
|
|
4104
|
+
el.setAttribute("data-has-audio", "true");
|
|
4105
|
+
el.removeAttribute("muted");
|
|
4106
|
+
} else if (updates.hasAudio === false) {
|
|
4107
|
+
el.removeAttribute("data-has-audio");
|
|
4108
|
+
el.setAttribute("muted", "");
|
|
4109
|
+
}
|
|
4110
|
+
}
|
|
4111
|
+
if (!doc.documentElement) {
|
|
4112
|
+
throw new CompositionHtmlParseError(
|
|
4113
|
+
"updateElementInHtml: input HTML is empty or could not be parsed"
|
|
4114
|
+
);
|
|
4115
|
+
}
|
|
4116
|
+
return "<!DOCTYPE html>\n" + doc.documentElement.outerHTML;
|
|
4117
|
+
}
|
|
4118
|
+
function addElementToHtml(html, element) {
|
|
4119
|
+
const parser = new DOMParser();
|
|
4120
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
4121
|
+
if (!doc.documentElement) {
|
|
4122
|
+
throw new CompositionHtmlParseError(
|
|
4123
|
+
"addElementToHtml: input HTML is empty or could not be parsed"
|
|
4124
|
+
);
|
|
4125
|
+
}
|
|
4126
|
+
const container = doc.querySelector("#stage-zoom-container") || doc.querySelector(".container") || doc.querySelector("#stage") || doc.body;
|
|
4127
|
+
if (!container) {
|
|
4128
|
+
throw new CompositionHtmlParseError("addElementToHtml: input HTML has no <body>");
|
|
4129
|
+
}
|
|
4130
|
+
const id = element.id || `element-${Date.now()}`;
|
|
4131
|
+
let newEl;
|
|
4132
|
+
function applyMediaAttrs(el, mediaEl) {
|
|
4133
|
+
if (mediaEl.src) el.setAttribute("src", mediaEl.src);
|
|
4134
|
+
if (mediaEl.volume !== void 0 && mediaEl.volume !== 1) {
|
|
4135
|
+
el.setAttribute("data-volume", String(mediaEl.volume));
|
|
4136
|
+
}
|
|
4137
|
+
}
|
|
4138
|
+
switch (element.type) {
|
|
4139
|
+
case "video": {
|
|
4140
|
+
const mediaEl = element;
|
|
4141
|
+
newEl = doc.createElement("video");
|
|
4142
|
+
newEl.setAttribute("playsinline", "");
|
|
4143
|
+
applyMediaAttrs(newEl, mediaEl);
|
|
4144
|
+
if (mediaEl.hasAudio) newEl.setAttribute("data-has-audio", "true");
|
|
4145
|
+
else newEl.setAttribute("muted", "");
|
|
4146
|
+
break;
|
|
4147
|
+
}
|
|
4148
|
+
case "image": {
|
|
4149
|
+
const mediaEl = element;
|
|
4150
|
+
newEl = doc.createElement("img");
|
|
4151
|
+
if (mediaEl.src) newEl.setAttribute("src", mediaEl.src);
|
|
4152
|
+
newEl.setAttribute("alt", element.name);
|
|
4153
|
+
break;
|
|
4154
|
+
}
|
|
4155
|
+
case "audio": {
|
|
4156
|
+
const mediaEl = element;
|
|
4157
|
+
newEl = doc.createElement("audio");
|
|
4158
|
+
applyMediaAttrs(newEl, mediaEl);
|
|
4159
|
+
break;
|
|
4160
|
+
}
|
|
4161
|
+
case "text":
|
|
4162
|
+
default: {
|
|
4163
|
+
const textEl = element;
|
|
4164
|
+
newEl = doc.createElement("div");
|
|
4165
|
+
const textContent = doc.createElement("div");
|
|
4166
|
+
textContent.textContent = textEl.content || element.name;
|
|
4167
|
+
newEl.appendChild(textContent);
|
|
4168
|
+
if (textEl.color) {
|
|
4169
|
+
newEl.setAttribute("data-color", textEl.color);
|
|
4170
|
+
}
|
|
4171
|
+
if (textEl.fontSize) {
|
|
4172
|
+
newEl.setAttribute("data-font-size", String(textEl.fontSize));
|
|
4173
|
+
}
|
|
4174
|
+
break;
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4177
|
+
newEl.id = id;
|
|
4178
|
+
writeClipTiming(newEl, {
|
|
4179
|
+
start: element.startTime,
|
|
4180
|
+
duration: element.duration,
|
|
4181
|
+
trackIndex: element.zIndex
|
|
4182
|
+
});
|
|
4183
|
+
newEl.setAttribute("data-name", element.name);
|
|
4184
|
+
container.appendChild(newEl);
|
|
4185
|
+
return {
|
|
4186
|
+
html: "<!DOCTYPE html>\n" + doc.documentElement.outerHTML,
|
|
4187
|
+
id
|
|
4188
|
+
};
|
|
4189
|
+
}
|
|
4190
|
+
function elementSelectors(element) {
|
|
4191
|
+
const selectors = [];
|
|
4192
|
+
const id = element.getAttribute("id");
|
|
4193
|
+
const hfId = element.getAttribute("data-hf-id");
|
|
4194
|
+
if (id) selectors.push(`#${id}`);
|
|
4195
|
+
if (hfId) selectors.push(`[data-hf-id="${hfId}"]`, `[data-hf-id='${hfId}']`);
|
|
4196
|
+
return selectors;
|
|
4197
|
+
}
|
|
4198
|
+
function removeElementWithGsapCascade(doc, element) {
|
|
4199
|
+
const removedSelectors = new Set(elementSelectors(element));
|
|
4200
|
+
walkCompositionDescendants(element, (child) => {
|
|
4201
|
+
for (const selector of elementSelectors(child)) removedSelectors.add(selector);
|
|
4202
|
+
});
|
|
4203
|
+
element.remove();
|
|
4204
|
+
walkCompositionDescendants(doc, (survivor) => {
|
|
4205
|
+
for (const selector of elementSelectors(survivor)) removedSelectors.delete(selector);
|
|
4206
|
+
});
|
|
4207
|
+
if (removedSelectors.size === 0) return;
|
|
4208
|
+
for (const script of findScriptElementsDeep(doc)) {
|
|
4209
|
+
let current = script.textContent ?? "";
|
|
4210
|
+
if (!current.includes("gsap") && !current.includes("ScrollTrigger")) continue;
|
|
4211
|
+
for (; ; ) {
|
|
4212
|
+
const parsed = parseGsapScriptAcornForWrite(current);
|
|
4213
|
+
const match = parsed?.located.find(
|
|
4214
|
+
(located) => removedSelectors.has(located.animation.targetSelector)
|
|
4215
|
+
);
|
|
4216
|
+
if (!match) break;
|
|
4217
|
+
const updated = removeAnimationFromScript(current, match.id);
|
|
4218
|
+
if (updated === current) break;
|
|
4219
|
+
current = updated;
|
|
4220
|
+
}
|
|
4221
|
+
if (current !== script.textContent) script.textContent = current;
|
|
4222
|
+
}
|
|
4223
|
+
}
|
|
4224
|
+
function removeElementFromHtml(html, elementId) {
|
|
4225
|
+
const parser = new DOMParser();
|
|
4226
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
4227
|
+
if (!doc.documentElement) {
|
|
4228
|
+
throw new CompositionHtmlParseError(
|
|
4229
|
+
"removeElementFromHtml: input HTML is empty or could not be parsed"
|
|
4230
|
+
);
|
|
4231
|
+
}
|
|
4232
|
+
const element = doc.getElementById(elementId);
|
|
4233
|
+
if (element) removeElementWithGsapCascade(doc, element);
|
|
4234
|
+
return "<!DOCTYPE html>\n" + doc.documentElement.outerHTML;
|
|
4235
|
+
}
|
|
4236
|
+
function extractCompositionMetadata(html) {
|
|
4237
|
+
const parser = new DOMParser();
|
|
4238
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
4239
|
+
const htmlEl = doc.documentElement;
|
|
4240
|
+
if (!htmlEl) {
|
|
4241
|
+
throw new CompositionHtmlParseError(
|
|
4242
|
+
"extractCompositionMetadata: input HTML is empty or could not be parsed"
|
|
4243
|
+
);
|
|
4244
|
+
}
|
|
4245
|
+
const compositionId = htmlEl.getAttribute("data-composition-id");
|
|
4246
|
+
const durationStr = htmlEl.getAttribute("data-composition-duration");
|
|
4247
|
+
const compositionDuration = durationStr ? parseFloat(durationStr) : null;
|
|
4248
|
+
const root = (doc.querySelector("template")?.content ?? doc).querySelector(
|
|
4249
|
+
"[data-composition-id]"
|
|
4250
|
+
);
|
|
4251
|
+
const variables = [
|
|
4252
|
+
...new Map(
|
|
4253
|
+
[
|
|
4254
|
+
...parseCompositionVariables(htmlEl),
|
|
4255
|
+
...root && root !== htmlEl ? parseCompositionVariables(root) : []
|
|
4256
|
+
].map((v) => [v.id, v])
|
|
4257
|
+
).values()
|
|
4258
|
+
];
|
|
4259
|
+
return {
|
|
4260
|
+
compositionId,
|
|
4261
|
+
compositionDuration: compositionDuration && isFinite(compositionDuration) ? compositionDuration : null,
|
|
4262
|
+
variables
|
|
4263
|
+
};
|
|
4264
|
+
}
|
|
4265
|
+
function validateCompositionHtml(html) {
|
|
4266
|
+
const errors = [];
|
|
4267
|
+
const warnings = [];
|
|
4268
|
+
const parser = new DOMParser();
|
|
4269
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
4270
|
+
const htmlEl = doc.documentElement;
|
|
4271
|
+
if (!htmlEl) {
|
|
4272
|
+
return {
|
|
4273
|
+
valid: false,
|
|
4274
|
+
errors: ["Composition HTML is empty or could not be parsed"],
|
|
4275
|
+
warnings: []
|
|
4276
|
+
};
|
|
4277
|
+
}
|
|
4278
|
+
const compositionId = htmlEl.getAttribute("data-composition-id");
|
|
4279
|
+
if (!compositionId) {
|
|
4280
|
+
errors.push("Missing data-composition-id attribute on <html> element");
|
|
4281
|
+
}
|
|
4282
|
+
const durationStr = htmlEl.getAttribute("data-composition-duration");
|
|
4283
|
+
if (!durationStr) {
|
|
4284
|
+
errors.push("Missing data-composition-duration attribute on <html> element");
|
|
4285
|
+
} else {
|
|
4286
|
+
const duration = parseFloat(durationStr);
|
|
4287
|
+
if (!isFinite(duration) || duration <= 0) {
|
|
4288
|
+
errors.push("data-composition-duration must be a positive finite number");
|
|
4289
|
+
}
|
|
4290
|
+
}
|
|
4291
|
+
const stage = doc.getElementById("stage");
|
|
4292
|
+
if (!stage) {
|
|
4293
|
+
errors.push("Missing #stage element");
|
|
4294
|
+
}
|
|
4295
|
+
if (/\son\w+\s*=/i.test(html)) {
|
|
4296
|
+
errors.push("Inline event handlers (onclick, onload, etc.) not allowed");
|
|
4297
|
+
}
|
|
4298
|
+
if (/javascript\s*:/i.test(html)) {
|
|
4299
|
+
errors.push("javascript: URLs not allowed");
|
|
4300
|
+
}
|
|
4301
|
+
const scripts = findScriptElementsDeep(doc);
|
|
4302
|
+
if (scripts.length > 2) {
|
|
4303
|
+
warnings.push("Multiple script tags detected - only GSAP CDN and main script expected");
|
|
4304
|
+
}
|
|
4305
|
+
for (const gsapScript of extractGsapScripts(doc)) {
|
|
4306
|
+
const gsapValidation = validateCompositionGsap(gsapScript);
|
|
4307
|
+
errors.push(...gsapValidation.errors);
|
|
4308
|
+
warnings.push(...gsapValidation.warnings);
|
|
4309
|
+
}
|
|
4310
|
+
return {
|
|
4311
|
+
valid: errors.length === 0,
|
|
4312
|
+
errors,
|
|
4313
|
+
warnings
|
|
4314
|
+
};
|
|
4315
|
+
}
|
|
4316
|
+
function findScriptElementsDeep(doc) {
|
|
4317
|
+
const scripts = [];
|
|
4318
|
+
walkCompositionDescendants(doc, (el) => {
|
|
4319
|
+
if (el.tagName.toLowerCase() === "script") scripts.push(el);
|
|
4320
|
+
});
|
|
4321
|
+
return scripts;
|
|
4322
|
+
}
|
|
4323
|
+
function extractGsapScripts(doc) {
|
|
4324
|
+
const scripts = findScriptElementsDeep(doc);
|
|
4325
|
+
const gsapScripts = [];
|
|
4326
|
+
for (const script of scripts) {
|
|
4327
|
+
const content = script.textContent || "";
|
|
4328
|
+
if (content.includes("gsap.timeline") || content.includes(".set(") || content.includes(".to(")) {
|
|
4329
|
+
gsapScripts.push(content);
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
return gsapScripts;
|
|
4333
|
+
}
|
|
4334
|
+
var OK = { ok: true };
|
|
4335
|
+
function suggestMatchingPreset(compositionWidth, compositionHeight, chosen) {
|
|
4336
|
+
const aspectMatches = VALID_CANVAS_RESOLUTIONS.filter((preset) => {
|
|
4337
|
+
const { width, height } = CANVAS_DIMENSIONS[preset];
|
|
4338
|
+
return width * compositionHeight === height * compositionWidth;
|
|
4339
|
+
});
|
|
4340
|
+
if (aspectMatches.length === 0) return void 0;
|
|
4341
|
+
const chosenIs4k = chosen.endsWith("-4k");
|
|
4342
|
+
const sameTier = aspectMatches.find((preset) => preset.endsWith("-4k") === chosenIs4k);
|
|
4343
|
+
return sameTier ?? aspectMatches[0];
|
|
4344
|
+
}
|
|
4345
|
+
function describeOrientation(width, height) {
|
|
4346
|
+
if (width > height) return "landscape";
|
|
4347
|
+
if (width < height) return "portrait";
|
|
4348
|
+
return "square";
|
|
4349
|
+
}
|
|
4350
|
+
function buildAspectMismatch(compositionWidth, compositionHeight, outputResolution, target) {
|
|
4351
|
+
const suggestedResolution = suggestMatchingPreset(
|
|
4352
|
+
compositionWidth,
|
|
4353
|
+
compositionHeight,
|
|
4354
|
+
outputResolution
|
|
4355
|
+
);
|
|
4356
|
+
const suggestion = suggestedResolution ? ` The composition is ${describeOrientation(compositionWidth, compositionHeight)} \u2014 use --resolution ${suggestedResolution} instead.` : ` Pick a preset whose orientation matches, or omit --resolution to render at the composition's native dimensions.`;
|
|
4357
|
+
return {
|
|
4358
|
+
ok: false,
|
|
4359
|
+
kind: "aspect-mismatch",
|
|
4360
|
+
suggestedResolution,
|
|
4361
|
+
message: `outputResolution ${outputResolution} (${target.width}\xD7${target.height}) does not match the aspect ratio of the composition (${compositionWidth}\xD7${compositionHeight}).` + suggestion
|
|
4362
|
+
};
|
|
4363
|
+
}
|
|
4364
|
+
function checkOutputResolutionCompatibility(input) {
|
|
4365
|
+
const { compositionWidth, compositionHeight, outputResolution } = input;
|
|
4366
|
+
if (!outputResolution) return OK;
|
|
4367
|
+
if (input.hdrRequested) {
|
|
4368
|
+
return {
|
|
4369
|
+
ok: false,
|
|
4370
|
+
kind: "hdr-incompatible",
|
|
4371
|
+
message: `outputResolution cannot be combined with hdrMode='force-hdr'. HDR rendering composites at composition dimensions and does not yet support supersampling. Pick one or render in two passes.`
|
|
4372
|
+
};
|
|
4373
|
+
}
|
|
4374
|
+
const target = CANVAS_DIMENSIONS[outputResolution];
|
|
4375
|
+
if (target.width * compositionHeight !== target.height * compositionWidth) {
|
|
4376
|
+
return buildAspectMismatch(compositionWidth, compositionHeight, outputResolution, target);
|
|
4377
|
+
}
|
|
4378
|
+
const widthRatio = target.width / compositionWidth;
|
|
4379
|
+
if (widthRatio < 1) {
|
|
4380
|
+
return {
|
|
4381
|
+
ok: false,
|
|
4382
|
+
kind: "downsampling",
|
|
4383
|
+
message: `outputResolution ${outputResolution} (${target.width}\xD7${target.height}) is smaller than the composition (${compositionWidth}\xD7${compositionHeight}). Downsampling via --resolution is not supported.`
|
|
4384
|
+
};
|
|
4385
|
+
}
|
|
4386
|
+
if (!Number.isInteger(widthRatio)) {
|
|
4387
|
+
return {
|
|
4388
|
+
ok: false,
|
|
4389
|
+
kind: "non-integer-scale",
|
|
4390
|
+
message: `outputResolution ${outputResolution} requires a non-integer device scale factor (${widthRatio}\xD7) to upsample from ${compositionWidth}\xD7${compositionHeight}. Pick a preset that's an integer multiple, or rescale the composition.`
|
|
4391
|
+
};
|
|
4392
|
+
}
|
|
4393
|
+
return OK;
|
|
4394
|
+
}
|
|
4395
|
+
function propEntries(props) {
|
|
4396
|
+
return Object.entries(props).map(([k, v]) => `${safeJsKey(k)}: ${serializeValue(v)}`);
|
|
4397
|
+
}
|
|
4398
|
+
function motionPathEntry(anim) {
|
|
4399
|
+
const waypoints = (anim.keyframes?.keyframes ?? []).filter((k) => typeof k.properties.x === "number" && typeof k.properties.y === "number").map((k) => `{ x: ${serializeValue(k.properties.x)}, y: ${serializeValue(k.properties.y)} }`);
|
|
4400
|
+
const curviness = anim.arcPath?.segments[0]?.curviness ?? 1;
|
|
4401
|
+
const autoRotate = anim.arcPath?.autoRotate;
|
|
4402
|
+
const extra = autoRotate ? `, autoRotate: ${serializeValue(autoRotate)}` : "";
|
|
4403
|
+
return `motionPath: { path: [${waypoints.join(", ")}], curviness: ${curviness}${extra} }`;
|
|
4404
|
+
}
|
|
4405
|
+
function keyframesEntry(anim) {
|
|
4406
|
+
const kfs = (anim.keyframes?.keyframes ?? []).map((k) => {
|
|
4407
|
+
const body = propEntries(k.properties);
|
|
4408
|
+
if (k.ease) body.push(`ease: ${serializeValue(k.ease)}`);
|
|
4409
|
+
return `"${k.percentage}%": { ${body.join(", ")} }`;
|
|
4410
|
+
});
|
|
4411
|
+
if (anim.keyframes?.easeEach) kfs.push(`easeEach: ${serializeValue(anim.keyframes.easeEach)}`);
|
|
4412
|
+
return `keyframes: { ${kfs.join(", ")} }`;
|
|
4413
|
+
}
|
|
4414
|
+
function buildVarsParts(anim) {
|
|
4415
|
+
const parts = [];
|
|
4416
|
+
if (anim.arcPath?.enabled) parts.push(motionPathEntry(anim));
|
|
4417
|
+
else if (anim.keyframes) parts.push(keyframesEntry(anim));
|
|
4418
|
+
parts.push(...propEntries(anim.properties));
|
|
4419
|
+
if (anim.method !== "set" && anim.duration !== void 0) {
|
|
4420
|
+
parts.push(`duration: ${serializeValue(anim.duration)}`);
|
|
4421
|
+
}
|
|
4422
|
+
if (anim.ease) parts.push(`ease: ${serializeValue(anim.ease)}`);
|
|
4423
|
+
for (const [k, v] of Object.entries(anim.extras ?? {})) {
|
|
4424
|
+
parts.push(`${safeJsKey(k)}: ${serializeValue(v)}`);
|
|
4425
|
+
}
|
|
4426
|
+
return parts;
|
|
4427
|
+
}
|
|
4428
|
+
function serializeTweenStatement(timelineVar, anim) {
|
|
4429
|
+
const obj = `{ ${buildVarsParts(anim).join(", ")} }`;
|
|
4430
|
+
const pos = serializeValue(
|
|
4431
|
+
anim.resolvedStart ?? (typeof anim.position === "number" ? anim.position : 0)
|
|
4432
|
+
);
|
|
4433
|
+
const sel = serializeValue(anim.targetSelector);
|
|
4434
|
+
if (anim.method === "fromTo") {
|
|
4435
|
+
const from = `{ ${propEntries(anim.fromProperties ?? {}).join(", ")} }`;
|
|
4436
|
+
return `${timelineVar}.fromTo(${sel}, ${from}, ${obj}, ${pos});`;
|
|
4437
|
+
}
|
|
4438
|
+
return `${timelineVar}.${anim.method}(${sel}, ${obj}, ${pos});`;
|
|
4439
|
+
}
|
|
4440
|
+
function isComputed(anim) {
|
|
4441
|
+
return anim.provenance?.kind === "helper" || anim.provenance?.kind === "loop";
|
|
4442
|
+
}
|
|
4443
|
+
function topLevelStatements(script) {
|
|
4444
|
+
return parse(script, { ecmaVersion: "latest", sourceType: "script" }).body ?? [];
|
|
4445
|
+
}
|
|
4446
|
+
function enclosingTopLevel(statements, start, end) {
|
|
4447
|
+
for (const stmt of statements) {
|
|
4448
|
+
if (stmt.start <= start && stmt.end >= end) return stmt;
|
|
4449
|
+
}
|
|
4450
|
+
return null;
|
|
4451
|
+
}
|
|
4452
|
+
function declaresFunction(stmt) {
|
|
4453
|
+
if (stmt.type === "FunctionDeclaration") return true;
|
|
4454
|
+
return stmt.type === "VariableDeclaration" && (stmt.declarations ?? []).some((d) => isFunctionNode(d.init));
|
|
4455
|
+
}
|
|
4456
|
+
function declaredNames(stmt) {
|
|
4457
|
+
if (stmt.type === "FunctionDeclaration") return stmt.id?.name ? [stmt.id.name] : [];
|
|
4458
|
+
if (stmt.type !== "VariableDeclaration") return [];
|
|
4459
|
+
return (stmt.declarations ?? []).flatMap((d) => d.id?.name ? [d.id.name] : []);
|
|
4460
|
+
}
|
|
4461
|
+
function mentionsIdentifier(text, name) {
|
|
4462
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4463
|
+
return new RegExp(`(?<![\\p{ID_Continue}$])${escaped}(?![\\p{ID_Continue}$])`, "u").test(text);
|
|
4464
|
+
}
|
|
4465
|
+
function unreferencedHelperDecls(statements, script, unrolled, helperNames) {
|
|
4466
|
+
let live = statements.filter((stmt) => !unrolled.has(stmt));
|
|
4467
|
+
const dead = [];
|
|
4468
|
+
for (let changed = true; changed; ) {
|
|
4469
|
+
changed = false;
|
|
4470
|
+
for (const decl of live) {
|
|
4471
|
+
const names = declaredNames(decl);
|
|
4472
|
+
if (names.length === 0 || !names.every((n2) => helperNames.has(n2))) continue;
|
|
4473
|
+
const others = live.filter((s) => s !== decl).map((s) => script.slice(s.start, s.end));
|
|
4474
|
+
if (names.some((n2) => others.some((text) => mentionsIdentifier(text, n2)))) continue;
|
|
4475
|
+
dead.push(decl);
|
|
4476
|
+
live = live.filter((s) => s !== decl);
|
|
4477
|
+
changed = true;
|
|
4478
|
+
}
|
|
4479
|
+
}
|
|
4480
|
+
return dead;
|
|
4481
|
+
}
|
|
4482
|
+
var EFFECT_NODES = /* @__PURE__ */ new Set([
|
|
4483
|
+
"CallExpression",
|
|
4484
|
+
"NewExpression",
|
|
4485
|
+
"UpdateExpression",
|
|
4486
|
+
"AssignmentExpression"
|
|
4487
|
+
]);
|
|
4488
|
+
function containsEffect(node) {
|
|
4489
|
+
let hit = false;
|
|
4490
|
+
full(node, (n2) => {
|
|
4491
|
+
if (EFFECT_NODES.has(n2.type)) hit = true;
|
|
4492
|
+
});
|
|
4493
|
+
return hit;
|
|
4494
|
+
}
|
|
4495
|
+
function isPureTweenChain(expr, timelineVar) {
|
|
4496
|
+
let node = expr;
|
|
4497
|
+
while (node?.type === "CallExpression") {
|
|
4498
|
+
if (!isTimelineRooted(node, timelineVar) || node.arguments.some(containsEffect)) return false;
|
|
4499
|
+
node = node.callee?.object;
|
|
4500
|
+
}
|
|
4501
|
+
return node?.type === "Identifier";
|
|
4502
|
+
}
|
|
4503
|
+
var blockStatements = (block) => block?.type === "BlockStatement" ? block.body : block ? [block] : [];
|
|
4504
|
+
function forEachBody(call) {
|
|
4505
|
+
const callback = call.callee?.property?.name === "forEach" ? call.arguments[0] : null;
|
|
4506
|
+
return callback?.body ? blockStatements(callback.body) : null;
|
|
4507
|
+
}
|
|
4508
|
+
function calledBody(call, helpers) {
|
|
4509
|
+
if (call?.type !== "CallExpression") return null;
|
|
4510
|
+
if (call.callee?.type !== "Identifier") return forEachBody(call);
|
|
4511
|
+
return helpers.get(call.callee.name) ?? null;
|
|
4512
|
+
}
|
|
4513
|
+
function bodyOf(stmt, helpers) {
|
|
4514
|
+
if (stmt.type === "ExpressionStatement") return calledBody(stmt.expression, helpers);
|
|
4515
|
+
return stmt.body ? blockStatements(stmt.body) : null;
|
|
4516
|
+
}
|
|
4517
|
+
function onlyAddsTweens(stmts, ctx, seen = /* @__PURE__ */ new Set()) {
|
|
4518
|
+
if (seen.has(stmts)) return false;
|
|
4519
|
+
seen.add(stmts);
|
|
4520
|
+
return stmts.every((stmt) => {
|
|
4521
|
+
if (stmt.type === "VariableDeclaration") return !containsEffect(stmt);
|
|
4522
|
+
if (stmt.type === "ExpressionStatement" && isPureTweenChain(stmt.expression, ctx.timelineVar)) {
|
|
4523
|
+
return true;
|
|
4524
|
+
}
|
|
4525
|
+
const nested = bodyOf(stmt, ctx.helpers);
|
|
4526
|
+
return nested !== null && onlyAddsTweens(nested, ctx, seen);
|
|
4527
|
+
});
|
|
4528
|
+
}
|
|
4529
|
+
function declaredFunctions(stmt) {
|
|
4530
|
+
if (stmt.type === "FunctionDeclaration") {
|
|
4531
|
+
return stmt.id?.name ? [[stmt.id.name, blockStatements(stmt.body)]] : [];
|
|
4532
|
+
}
|
|
4533
|
+
if (stmt.type !== "VariableDeclaration") return [];
|
|
4534
|
+
return stmt.declarations.filter((d) => d.id?.name && isFunctionNode(d.init)).map((d) => [d.id.name, blockStatements(d.init.body)]);
|
|
4535
|
+
}
|
|
4536
|
+
var collectHelperBodies = (statements) => new Map(statements.flatMap(declaredFunctions));
|
|
4537
|
+
function dropStatementsUnsafeToUnroll(byStatement, ctx) {
|
|
4538
|
+
for (const [stmt, anims] of byStatement) {
|
|
4539
|
+
const unknownTiming = anims.some(
|
|
4540
|
+
(a) => a.durationUnresolved || a.resolvedStart === void 0 || a.hasUnresolvedSelector || a.hasUnresolvedKeyframes
|
|
4541
|
+
);
|
|
4542
|
+
const bodyStmts = unknownTiming ? null : bodyOf(stmt, ctx.helpers);
|
|
4543
|
+
if (bodyStmts === null || !onlyAddsTweens(bodyStmts, ctx)) byStatement.delete(stmt);
|
|
4544
|
+
}
|
|
4545
|
+
}
|
|
4546
|
+
function groupByTopLevelStatement(computed, statements) {
|
|
4547
|
+
const byStatement = /* @__PURE__ */ new Map();
|
|
4548
|
+
const helperNames = /* @__PURE__ */ new Set();
|
|
4549
|
+
for (const anim of computed) {
|
|
4550
|
+
const [s, e] = anim.provenance.sourceRange;
|
|
4551
|
+
const stmt = enclosingTopLevel(statements, s, e);
|
|
4552
|
+
if (stmt && declaresFunction(stmt)) return null;
|
|
4553
|
+
if (!stmt) continue;
|
|
4554
|
+
if (anim.provenance?.fn) helperNames.add(anim.provenance.fn);
|
|
4555
|
+
const list = byStatement.get(stmt) ?? [];
|
|
4556
|
+
list.push(anim);
|
|
4557
|
+
byStatement.set(stmt, list);
|
|
4558
|
+
}
|
|
4559
|
+
return { byStatement, helperNames };
|
|
4560
|
+
}
|
|
4561
|
+
function unrollComputedTimeline(script) {
|
|
4562
|
+
const parsed = parseGsapScriptAcorn(script);
|
|
4563
|
+
const computed = parsed.animations.filter((a) => isComputed(a) && a.provenance?.sourceRange);
|
|
4564
|
+
if (computed.length === 0) return script;
|
|
4565
|
+
const statements = topLevelStatements(script);
|
|
4566
|
+
const grouped = groupByTopLevelStatement(computed, statements);
|
|
4567
|
+
if (!grouped) return script;
|
|
4568
|
+
const { byStatement, helperNames } = grouped;
|
|
4569
|
+
dropStatementsUnsafeToUnroll(byStatement, {
|
|
4570
|
+
timelineVar: parsed.timelineVar,
|
|
4571
|
+
helpers: collectHelperBodies(statements)
|
|
4572
|
+
});
|
|
4573
|
+
if (byStatement.size === 0) return script;
|
|
4574
|
+
const ms = new MagicString(script);
|
|
4575
|
+
for (const [stmt, anims] of byStatement) {
|
|
4576
|
+
const literals = anims.map((a) => serializeTweenStatement(parsed.timelineVar, a)).join("\n");
|
|
4577
|
+
ms.overwrite(stmt.start, stmt.end, literals);
|
|
4578
|
+
}
|
|
4579
|
+
for (const decl of unreferencedHelperDecls(
|
|
4580
|
+
statements,
|
|
4581
|
+
script,
|
|
4582
|
+
new Set(byStatement.keys()),
|
|
4583
|
+
helperNames
|
|
4584
|
+
)) {
|
|
4585
|
+
ms.remove(decl.start, decl.end);
|
|
4586
|
+
}
|
|
4587
|
+
return ms.toString();
|
|
4588
|
+
}
|
|
4589
|
+
var HTML_BODY_CSS_WIDTH_FIRST_RE = /(html\s*,\s*body\s*\{[^}]*?width:\s*)(\d+)px([^}]*?height:\s*)(\d+)px/i;
|
|
4590
|
+
var HTML_BODY_CSS_HEIGHT_FIRST_RE = /(html\s*,\s*body\s*\{[^}]*?height:\s*)(\d+)px([^}]*?width:\s*)(\d+)px/i;
|
|
4591
|
+
var VIEWPORT_META_SIZE_RE = /(<meta[^>]*name=["']viewport["'][^>]*content=["']width=)(\d+)(,\s*height=)(\d+)/i;
|
|
4592
|
+
var NON_RENDERED_TAGS = /* @__PURE__ */ new Set(["script", "style", "template", "noscript", "link", "meta"]);
|
|
4593
|
+
var MEDIA_TAGS = /* @__PURE__ */ new Set(["video", "audio", "img"]);
|
|
4594
|
+
var TRACK_KINDS = ["video", "audio", "captions", "graphics"];
|
|
4595
|
+
function isSubCompositionHost(node) {
|
|
4596
|
+
return node.attrs["data-composition-src"] !== void 0 || node.attrs["data-composition-id"] !== void 0;
|
|
4597
|
+
}
|
|
4598
|
+
function isTimedElement(node) {
|
|
4599
|
+
const { attrs } = node;
|
|
4600
|
+
return attrs["data-start"] !== void 0 || attrs["data-track-index"] !== void 0 && attrs["data-duration"] !== void 0 || MEDIA_TAGS.has(node.tag.toLowerCase());
|
|
4601
|
+
}
|
|
4602
|
+
function topLevelElements(root) {
|
|
4603
|
+
const rows = [];
|
|
4604
|
+
const visit = (node) => {
|
|
4605
|
+
if (NON_RENDERED_TAGS.has(node.tag.toLowerCase())) return;
|
|
4606
|
+
if (isSubCompositionHost(node) || isTimedElement(node)) rows.push(node);
|
|
4607
|
+
else node.children.forEach(visit);
|
|
4608
|
+
};
|
|
4609
|
+
root.children.forEach(visit);
|
|
4610
|
+
return rows;
|
|
4611
|
+
}
|
|
4612
|
+
function trackKindOf(node) {
|
|
4613
|
+
const explicit = node.attrs["data-track-kind"]?.trim().toLowerCase();
|
|
4614
|
+
if (explicit && TRACK_KINDS.includes(explicit))
|
|
4615
|
+
return { kind: explicit, source: "attribute" };
|
|
4616
|
+
const tag = node.tag.toLowerCase();
|
|
4617
|
+
if (tag === "video" || tag === "audio") return { kind: tag, source: "tag" };
|
|
4618
|
+
if (isSubCompositionHost(node)) {
|
|
4619
|
+
const legacy = node.attrs["data-composition-id"] === "captions" || /(?:^|\s)caption[-_]/.test(node.attrs.class ?? "");
|
|
4620
|
+
return legacy ? { kind: "captions", source: "legacy-captions" } : { kind: "graphics", source: "sub-composition" };
|
|
4621
|
+
}
|
|
4622
|
+
return { kind: "graphics", source: "tag" };
|
|
4623
|
+
}
|
|
4624
|
+
function decodeUrlPathVariants(path) {
|
|
4625
|
+
const variants = [path];
|
|
4626
|
+
try {
|
|
4627
|
+
const decoded = decodeURIComponent(path);
|
|
4628
|
+
if (decoded !== path) variants.unshift(decoded);
|
|
4629
|
+
} catch {
|
|
4630
|
+
}
|
|
4631
|
+
return variants;
|
|
4632
|
+
}
|
|
4633
|
+
function parseProgram2(script) {
|
|
4634
|
+
try {
|
|
4635
|
+
return parse(script, { ecmaVersion: "latest", sourceType: "script" });
|
|
4636
|
+
} catch {
|
|
4637
|
+
return parse(script, { ecmaVersion: "latest", sourceType: "module" });
|
|
4638
|
+
}
|
|
4639
|
+
}
|
|
4640
|
+
function literalString(node) {
|
|
4641
|
+
if (node?.type === "Literal" && typeof node.value === "string") return node.value;
|
|
4642
|
+
if (node?.type === "TemplateLiteral" && node.expressions?.length === 0) {
|
|
4643
|
+
return node.quasis?.[0]?.value?.cooked;
|
|
4644
|
+
}
|
|
4645
|
+
return void 0;
|
|
4646
|
+
}
|
|
4647
|
+
function memberName(node) {
|
|
4648
|
+
if (node?.type !== "MemberExpression") return void 0;
|
|
4649
|
+
if (!node.computed && node.property?.type === "Identifier") return node.property.name;
|
|
4650
|
+
return literalString(node.property);
|
|
4651
|
+
}
|
|
4652
|
+
function lookupSelector(node, bindings) {
|
|
4653
|
+
if (node?.type === "Identifier") return bindings.get(node.name);
|
|
4654
|
+
if (node?.type !== "CallExpression" || node.callee?.type !== "MemberExpression") {
|
|
4655
|
+
return void 0;
|
|
4656
|
+
}
|
|
4657
|
+
const method = memberName(node.callee);
|
|
4658
|
+
if (method !== "getElementById" && method !== "querySelector") return void 0;
|
|
4659
|
+
const value = literalString(node.arguments?.[0]);
|
|
4660
|
+
if (!value) return void 0;
|
|
4661
|
+
return method === "getElementById" ? `#${value}` : value;
|
|
4662
|
+
}
|
|
4663
|
+
function extractMediaSrcMutations(script) {
|
|
4664
|
+
try {
|
|
4665
|
+
const ast = parseProgram2(script);
|
|
4666
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
4667
|
+
simple(ast, {
|
|
4668
|
+
VariableDeclarator(node) {
|
|
4669
|
+
if (node.id?.type !== "Identifier") return;
|
|
4670
|
+
const selector = lookupSelector(node.init, bindings);
|
|
4671
|
+
if (selector) bindings.set(node.id.name, selector);
|
|
4672
|
+
}
|
|
4673
|
+
});
|
|
4674
|
+
const mutations = [];
|
|
4675
|
+
simple(ast, {
|
|
4676
|
+
AssignmentExpression(node) {
|
|
4677
|
+
if (node.operator !== "=" || memberName(node.left) !== "src") return;
|
|
4678
|
+
const selector = lookupSelector(node.left.object, bindings);
|
|
4679
|
+
if (!selector) return;
|
|
4680
|
+
mutations.push({
|
|
4681
|
+
selector,
|
|
4682
|
+
operation: "src_assignment",
|
|
4683
|
+
raw: script.slice(node.start, node.end)
|
|
4684
|
+
});
|
|
4685
|
+
},
|
|
4686
|
+
CallExpression(node) {
|
|
4687
|
+
if (memberName(node.callee) !== "setAttribute") return;
|
|
4688
|
+
if (literalString(node.arguments?.[0])?.toLowerCase() !== "src") return;
|
|
4689
|
+
const selector = lookupSelector(node.callee.object, bindings);
|
|
4690
|
+
if (!selector) return;
|
|
4691
|
+
mutations.push({
|
|
4692
|
+
selector,
|
|
4693
|
+
operation: "set_attribute",
|
|
4694
|
+
raw: script.slice(node.start, node.end)
|
|
4695
|
+
});
|
|
4696
|
+
}
|
|
4697
|
+
});
|
|
4698
|
+
return mutations;
|
|
4699
|
+
} catch {
|
|
4700
|
+
return [];
|
|
4701
|
+
}
|
|
4702
|
+
}
|
|
4703
|
+
var FONT_ALIAS_MAP = {
|
|
4704
|
+
// ── Canonical bundled fonts (self-referencing) ────────────────────────
|
|
4705
|
+
inter: "inter",
|
|
4706
|
+
montserrat: "montserrat",
|
|
4707
|
+
outfit: "outfit",
|
|
4708
|
+
nunito: "nunito",
|
|
4709
|
+
oswald: "oswald",
|
|
4710
|
+
"league gothic": "league-gothic",
|
|
4711
|
+
"archivo black": "archivo-black",
|
|
4712
|
+
"space mono": "space-mono",
|
|
4713
|
+
"ibm plex mono": "ibm-plex-mono",
|
|
4714
|
+
"jetbrains mono": "jetbrains-mono",
|
|
4715
|
+
"eb garamond": "eb-garamond",
|
|
4716
|
+
"playfair display": "playfair-display",
|
|
4717
|
+
"source code pro": "source-code-pro",
|
|
4718
|
+
"noto sans jp": "noto-sans-jp",
|
|
4719
|
+
roboto: "roboto",
|
|
4720
|
+
"open sans": "open-sans",
|
|
4721
|
+
lato: "lato",
|
|
4722
|
+
poppins: "poppins",
|
|
4723
|
+
// ── Common aliases → nearest canonical ────────────────────────────────
|
|
4724
|
+
"helvetica neue": "inter",
|
|
4725
|
+
helvetica: "inter",
|
|
4726
|
+
arial: "inter",
|
|
4727
|
+
"helvetica bold": "inter",
|
|
4728
|
+
futura: "montserrat",
|
|
4729
|
+
"din alternate": "montserrat",
|
|
4730
|
+
"arial black": "montserrat",
|
|
4731
|
+
"bebas neue": "league-gothic",
|
|
4732
|
+
"courier new": "jetbrains-mono",
|
|
4733
|
+
courier: "jetbrains-mono",
|
|
4734
|
+
garamond: "eb-garamond",
|
|
4735
|
+
"noto sans japanese": "noto-sans-jp",
|
|
4736
|
+
"segoe ui": "roboto",
|
|
4737
|
+
// ── macOS sans-serif system fonts → inter ─────────────────────────────
|
|
4738
|
+
"sf pro": "inter",
|
|
4739
|
+
"sf pro display": "inter",
|
|
4740
|
+
"sf pro text": "inter",
|
|
4741
|
+
"sf pro rounded": "inter",
|
|
4742
|
+
avenir: "inter",
|
|
4743
|
+
"avenir next": "inter",
|
|
4744
|
+
"lucida grande": "inter",
|
|
4745
|
+
geneva: "inter",
|
|
4746
|
+
optima: "inter",
|
|
4747
|
+
// ── Windows sans-serif system fonts → inter ───────────────────────────
|
|
4748
|
+
verdana: "inter",
|
|
4749
|
+
tahoma: "inter",
|
|
4750
|
+
"trebuchet ms": "inter",
|
|
4751
|
+
calibri: "inter",
|
|
4752
|
+
candara: "inter",
|
|
4753
|
+
corbel: "inter",
|
|
4754
|
+
"lucida sans": "inter",
|
|
4755
|
+
"lucida sans unicode": "inter",
|
|
4756
|
+
// ── Linux sans-serif system fonts → inter ─────────────────────────────
|
|
4757
|
+
"noto sans": "inter",
|
|
4758
|
+
"dejavu sans": "inter",
|
|
4759
|
+
"liberation sans": "inter",
|
|
4760
|
+
// ── Monospace system fonts → jetbrains-mono ───────────────────────────
|
|
4761
|
+
"sf mono": "jetbrains-mono",
|
|
4762
|
+
menlo: "jetbrains-mono",
|
|
4763
|
+
monaco: "jetbrains-mono",
|
|
4764
|
+
consolas: "jetbrains-mono",
|
|
4765
|
+
"lucida console": "jetbrains-mono",
|
|
4766
|
+
"lucida sans typewriter": "jetbrains-mono",
|
|
4767
|
+
"andale mono": "jetbrains-mono",
|
|
4768
|
+
"dejavu sans mono": "jetbrains-mono",
|
|
4769
|
+
"liberation mono": "jetbrains-mono",
|
|
4770
|
+
// ── Serif system fonts → eb-garamond ──────────────────────────────────
|
|
4771
|
+
georgia: "eb-garamond",
|
|
4772
|
+
palatino: "eb-garamond",
|
|
4773
|
+
"palatino linotype": "eb-garamond",
|
|
4774
|
+
"book antiqua": "eb-garamond",
|
|
4775
|
+
cambria: "eb-garamond",
|
|
4776
|
+
times: "eb-garamond",
|
|
4777
|
+
"times new roman": "eb-garamond",
|
|
4778
|
+
"dejavu serif": "eb-garamond",
|
|
4779
|
+
"liberation serif": "eb-garamond"
|
|
4780
|
+
};
|
|
4781
|
+
var FONT_ALIAS_KEYS = new Set(Object.keys(FONT_ALIAS_MAP));
|
|
4782
|
+
var CANONICAL_FONT_DISPLAY_NAMES = {
|
|
4783
|
+
inter: "Inter",
|
|
4784
|
+
montserrat: "Montserrat",
|
|
4785
|
+
outfit: "Outfit",
|
|
4786
|
+
nunito: "Nunito",
|
|
4787
|
+
oswald: "Oswald",
|
|
4788
|
+
"league-gothic": "League Gothic",
|
|
4789
|
+
"archivo-black": "Archivo Black",
|
|
4790
|
+
"space-mono": "Space Mono",
|
|
4791
|
+
"ibm-plex-mono": "IBM Plex Mono",
|
|
4792
|
+
"jetbrains-mono": "JetBrains Mono",
|
|
4793
|
+
"eb-garamond": "EB Garamond",
|
|
4794
|
+
"playfair-display": "Playfair Display",
|
|
4795
|
+
"source-code-pro": "Source Code Pro",
|
|
4796
|
+
"noto-sans-jp": "Noto Sans JP",
|
|
4797
|
+
roboto: "Roboto",
|
|
4798
|
+
"open-sans": "Open Sans",
|
|
4799
|
+
lato: "Lato",
|
|
4800
|
+
poppins: "Poppins"
|
|
4801
|
+
};
|
|
4802
|
+
function resolveAliasDisplayName(alias) {
|
|
4803
|
+
const slug = FONT_ALIAS_MAP[alias.toLowerCase()];
|
|
4804
|
+
if (!slug) return void 0;
|
|
4805
|
+
return CANONICAL_FONT_DISPLAY_NAMES[slug];
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4808
|
+
export {
|
|
4809
|
+
MagicString,
|
|
4810
|
+
CANVAS_DIMENSIONS,
|
|
4811
|
+
VALID_CANVAS_RESOLUTIONS,
|
|
4812
|
+
normalizeResolutionFlag,
|
|
4813
|
+
isAspectAgnosticResolutionAlias,
|
|
4814
|
+
resolveResolutionFlagPair,
|
|
4815
|
+
COMPOSITION_VARIABLE_TYPES,
|
|
4816
|
+
isTextElement,
|
|
4817
|
+
isMediaElement,
|
|
4818
|
+
isCompositionElement,
|
|
4819
|
+
TIMELINE_COLORS,
|
|
4820
|
+
DEFAULT_DURATIONS,
|
|
4821
|
+
getDefaultStageZoom,
|
|
4822
|
+
serializeGsapAnimations,
|
|
4823
|
+
getAnimationsForElementId,
|
|
4824
|
+
validateCompositionGsap,
|
|
4825
|
+
keyframesToGsapAnimations,
|
|
4826
|
+
gsapAnimationsToKeyframes,
|
|
4827
|
+
parseHtml,
|
|
4828
|
+
updateElementInHtml,
|
|
4829
|
+
addElementToHtml,
|
|
4830
|
+
removeElementWithGsapCascade,
|
|
4831
|
+
removeElementFromHtml,
|
|
4832
|
+
extractCompositionMetadata,
|
|
4833
|
+
validateCompositionHtml,
|
|
4834
|
+
suggestMatchingPreset,
|
|
4835
|
+
checkOutputResolutionCompatibility,
|
|
4836
|
+
unrollComputedTimeline,
|
|
4837
|
+
HTML_BODY_CSS_WIDTH_FIRST_RE,
|
|
4838
|
+
HTML_BODY_CSS_HEIGHT_FIRST_RE,
|
|
4839
|
+
VIEWPORT_META_SIZE_RE,
|
|
4840
|
+
topLevelElements,
|
|
4841
|
+
trackKindOf,
|
|
4842
|
+
decodeUrlPathVariants,
|
|
4843
|
+
extractMediaSrcMutations,
|
|
4844
|
+
FONT_ALIAS_MAP,
|
|
4845
|
+
FONT_ALIAS_KEYS,
|
|
4846
|
+
resolveAliasDisplayName
|
|
4847
|
+
};
|