@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,3081 @@
|
|
|
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
|
+
HF_COLOR_GRADING_ATTR,
|
|
9
|
+
RUNTIME_BOOTSTRAP_ATTR,
|
|
10
|
+
clampDurations,
|
|
11
|
+
compileTimingAttrs,
|
|
12
|
+
escapeInlineScriptSource,
|
|
13
|
+
extractResolvedMedia,
|
|
14
|
+
getHyperframeRuntimeScript,
|
|
15
|
+
injectDurations,
|
|
16
|
+
injectTagsAtHeadStart,
|
|
17
|
+
insertRuntimeTag,
|
|
18
|
+
parseHTMLContent,
|
|
19
|
+
parseHostVariableValues,
|
|
20
|
+
queryByAttr,
|
|
21
|
+
readDeclaredDefaults,
|
|
22
|
+
shouldClampResolvedMediaDuration,
|
|
23
|
+
stripEmbeddedRuntimeScripts,
|
|
24
|
+
warnUnknownEnumValues
|
|
25
|
+
} from "./chunk-HWKCIWQT.js";
|
|
26
|
+
import {
|
|
27
|
+
cssVariableName
|
|
28
|
+
} from "./chunk-VC76R6W2.js";
|
|
29
|
+
import {
|
|
30
|
+
isSafePath,
|
|
31
|
+
resolveWithinProject
|
|
32
|
+
} from "./chunk-OFQWTKPW.js";
|
|
33
|
+
import {
|
|
34
|
+
lintHyperframeHtml
|
|
35
|
+
} from "./chunk-ZJUKFZ2P.js";
|
|
36
|
+
import {
|
|
37
|
+
CSS_URL_RE,
|
|
38
|
+
checkSubCompositionUsability,
|
|
39
|
+
isNonRelativeUrl,
|
|
40
|
+
resolveSubCompositionContent,
|
|
41
|
+
rewriteAssetPath,
|
|
42
|
+
rewriteAssetPaths,
|
|
43
|
+
rewriteCssAssetUrls,
|
|
44
|
+
rewriteInlineStyleAssetUrls
|
|
45
|
+
} from "./chunk-TQFG7HTI.js";
|
|
46
|
+
import {
|
|
47
|
+
parseHTML
|
|
48
|
+
} from "./chunk-GK4AIFIH.js";
|
|
49
|
+
|
|
50
|
+
// ../core/dist/compiler/htmlCompiler.js
|
|
51
|
+
import { resolve } from "path";
|
|
52
|
+
function resolveMediaSrc(src, projectDir) {
|
|
53
|
+
return src.startsWith("http://") || src.startsWith("https://") ? src : resolve(projectDir, src);
|
|
54
|
+
}
|
|
55
|
+
async function compileHtml(rawHtml, projectDir, probeMediaDuration) {
|
|
56
|
+
const { html: staticCompiled, unresolved } = compileTimingAttrs(rawHtml);
|
|
57
|
+
let html = staticCompiled;
|
|
58
|
+
if (!probeMediaDuration)
|
|
59
|
+
return html;
|
|
60
|
+
const mediaUnresolved = unresolved.filter((el) => el.tagName === "video" || el.tagName === "audio");
|
|
61
|
+
if (mediaUnresolved.length > 0) {
|
|
62
|
+
const resolutions = [];
|
|
63
|
+
for (const el of mediaUnresolved) {
|
|
64
|
+
if (!el.src)
|
|
65
|
+
continue;
|
|
66
|
+
const src = resolveMediaSrc(el.src, projectDir);
|
|
67
|
+
const fileDuration = await probeMediaDuration(src);
|
|
68
|
+
if (fileDuration <= 0)
|
|
69
|
+
continue;
|
|
70
|
+
const effectiveDuration = fileDuration - el.mediaStart;
|
|
71
|
+
const sourceDuration = effectiveDuration > 0 ? effectiveDuration : fileDuration;
|
|
72
|
+
resolutions.push({ id: el.id, duration: sourceDuration });
|
|
73
|
+
}
|
|
74
|
+
if (resolutions.length > 0) {
|
|
75
|
+
html = injectDurations(html, resolutions);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const preResolved = extractResolvedMedia(html);
|
|
79
|
+
const clampList = [];
|
|
80
|
+
for (const el of preResolved) {
|
|
81
|
+
if (!el.src)
|
|
82
|
+
continue;
|
|
83
|
+
if (el.loop)
|
|
84
|
+
continue;
|
|
85
|
+
const src = resolveMediaSrc(el.src, projectDir);
|
|
86
|
+
const fileDuration = await probeMediaDuration(src);
|
|
87
|
+
if (fileDuration <= 0)
|
|
88
|
+
continue;
|
|
89
|
+
const maxDuration = fileDuration - el.mediaStart;
|
|
90
|
+
if (maxDuration > 0 && shouldClampResolvedMediaDuration(el.tagName, el.duration, maxDuration)) {
|
|
91
|
+
clampList.push({ id: el.id, duration: maxDuration });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (clampList.length > 0) {
|
|
95
|
+
html = clampDurations(html, clampList);
|
|
96
|
+
}
|
|
97
|
+
return html;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ../core/dist/compiler/scriptRuns.js
|
|
101
|
+
var JAVASCRIPT_TYPES = /* @__PURE__ */ new Set([
|
|
102
|
+
"",
|
|
103
|
+
"application/ecmascript",
|
|
104
|
+
"application/javascript",
|
|
105
|
+
"application/x-ecmascript",
|
|
106
|
+
"application/x-javascript",
|
|
107
|
+
"text/ecmascript",
|
|
108
|
+
"text/javascript",
|
|
109
|
+
"text/javascript1.0",
|
|
110
|
+
"text/javascript1.1",
|
|
111
|
+
"text/javascript1.2",
|
|
112
|
+
"text/javascript1.3",
|
|
113
|
+
"text/javascript1.4",
|
|
114
|
+
"text/javascript1.5",
|
|
115
|
+
"text/jscript",
|
|
116
|
+
"text/livescript",
|
|
117
|
+
"text/x-ecmascript",
|
|
118
|
+
"text/x-javascript"
|
|
119
|
+
]);
|
|
120
|
+
function isJavaScriptType(el) {
|
|
121
|
+
return JAVASCRIPT_TYPES.has((el.getAttribute("type") || "").trim().toLowerCase());
|
|
122
|
+
}
|
|
123
|
+
function isClassicInline(el) {
|
|
124
|
+
return !el.hasAttribute("nomodule") && isJavaScriptType(el);
|
|
125
|
+
}
|
|
126
|
+
function isSeparateExecution(el, isPinned) {
|
|
127
|
+
return el.hasAttribute("src") || el.hasAttribute("defer") || el.hasAttribute("async") || isPinned(el) || (el.getAttribute("type") || "").trim().toLowerCase() === "module";
|
|
128
|
+
}
|
|
129
|
+
function inlineScriptRuns(scripts, isPinned = () => false) {
|
|
130
|
+
const runs = [];
|
|
131
|
+
let members = [];
|
|
132
|
+
for (const el of scripts) {
|
|
133
|
+
if (isSeparateExecution(el, isPinned)) {
|
|
134
|
+
if (members.length === 0)
|
|
135
|
+
continue;
|
|
136
|
+
runs.push({ members, anchor: el });
|
|
137
|
+
members = [];
|
|
138
|
+
} else if (isClassicInline(el)) {
|
|
139
|
+
members.push(el);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (members.length > 0)
|
|
143
|
+
runs.push({ members, anchor: null });
|
|
144
|
+
return runs;
|
|
145
|
+
}
|
|
146
|
+
var AFTER_FONTS_SCRIPT_TYPE = "text/hf-after-fonts";
|
|
147
|
+
var AFTER_FONTS_MODULE_TYPE = `${AFTER_FONTS_SCRIPT_TYPE}+module`;
|
|
148
|
+
var AFTER_FONTS_SCRIPTS = `script[type="${AFTER_FONTS_SCRIPT_TYPE}"], script[type="${AFTER_FONTS_MODULE_TYPE}"]`;
|
|
149
|
+
var AFTER_FONTS_CLAIM = "__hfAfterFontsClaimed";
|
|
150
|
+
var INLINED_FILE_ATTR = "data-hf-inlined-src";
|
|
151
|
+
var DEFERRED_FILE = `[defer][src], [defer][${INLINED_FILE_ATTR}]`;
|
|
152
|
+
var AFTER_FONTS_FALLBACK_ATTR = "data-hf-after-fonts-fallback";
|
|
153
|
+
var afterFontsFallback = () => `document.addEventListener("DOMContentLoaded", function () {
|
|
154
|
+
if (window.${AFTER_FONTS_CLAIM}) return;
|
|
155
|
+
var T = "${AFTER_FONTS_SCRIPT_TYPE}";
|
|
156
|
+
var all = [].slice.call(document.querySelectorAll('${AFTER_FONTS_SCRIPTS}'));
|
|
157
|
+
if (!all.length) return;
|
|
158
|
+
console.warn("[hyperframes] the runtime has no web-font gate; composition scripts run without waiting for fonts");
|
|
159
|
+
var late = function (el) { return el.type !== T || el.matches('${DEFERRED_FILE}'); };
|
|
160
|
+
var queue = all.filter(function (el) { return !late(el); }).concat(all.filter(late));
|
|
161
|
+
(function next() {
|
|
162
|
+
var el = queue.shift();
|
|
163
|
+
if (!el) return;
|
|
164
|
+
var s = document.createElement("script");
|
|
165
|
+
for (var i = 0; i < el.attributes.length; i++) s.setAttribute(el.attributes[i].name, el.attributes[i].value);
|
|
166
|
+
if (el.type === T) s.removeAttribute("type"); else s.type = "module";
|
|
167
|
+
s.async = el.hasAttribute("async");
|
|
168
|
+
s.text = el.text;
|
|
169
|
+
var waits = s.type !== "module" && s.hasAttribute("src") && !s.async && !s.noModule;
|
|
170
|
+
if (waits) { s.addEventListener("load", next); s.addEventListener("error", next); }
|
|
171
|
+
el.replaceWith(s);
|
|
172
|
+
if (!waits) next();
|
|
173
|
+
})();
|
|
174
|
+
});`;
|
|
175
|
+
function deferScriptsUntilFonts(document, isFramework = () => false) {
|
|
176
|
+
let deferred = false;
|
|
177
|
+
for (const el of document.querySelectorAll("body script")) {
|
|
178
|
+
if (isFramework(el) || el.closest("noscript, svg"))
|
|
179
|
+
continue;
|
|
180
|
+
if (isClassicInline(el))
|
|
181
|
+
el.setAttribute("type", AFTER_FONTS_SCRIPT_TYPE);
|
|
182
|
+
else if ((el.getAttribute("type") || "").trim().toLowerCase() === "module") {
|
|
183
|
+
el.setAttribute("type", AFTER_FONTS_MODULE_TYPE);
|
|
184
|
+
} else
|
|
185
|
+
continue;
|
|
186
|
+
deferred = true;
|
|
187
|
+
}
|
|
188
|
+
if (!deferred || !document.head || document.querySelector(`script[${AFTER_FONTS_FALLBACK_ATTR}]`)) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const fallback = document.createElement("script");
|
|
192
|
+
fallback.setAttribute(AFTER_FONTS_FALLBACK_ATTR, "");
|
|
193
|
+
fallback.textContent = afterFontsFallback();
|
|
194
|
+
document.head.insertBefore(fallback, document.head.firstChild);
|
|
195
|
+
}
|
|
196
|
+
function cssStyleMergeKey(el) {
|
|
197
|
+
const rawType = el.getAttribute("type") ?? "";
|
|
198
|
+
const type = el.tagName.toLowerCase() === "link" ? rawType.split(";")[0].trim() : rawType;
|
|
199
|
+
if (type !== "" && type.toLowerCase() !== "text/css")
|
|
200
|
+
return void 0;
|
|
201
|
+
const media = (el.getAttribute("media") ?? "").trim().toLowerCase();
|
|
202
|
+
return JSON.stringify([media === "all" ? "" : media, el.getAttribute("title") ?? ""]);
|
|
203
|
+
}
|
|
204
|
+
var UNCONDITIONAL_CSS_KEY = JSON.stringify(["", ""]);
|
|
205
|
+
function linkDedupeKey(el) {
|
|
206
|
+
return JSON.stringify([
|
|
207
|
+
el.getAttribute("href"),
|
|
208
|
+
(el.getAttribute("rel") ?? "").trim().toLowerCase(),
|
|
209
|
+
cssStyleMergeKey(el) ?? el.getAttribute("type"),
|
|
210
|
+
el.hasAttribute("disabled")
|
|
211
|
+
]);
|
|
212
|
+
}
|
|
213
|
+
function hasSameLink(scope, link) {
|
|
214
|
+
const key = linkDedupeKey(link);
|
|
215
|
+
return [...scope.querySelectorAll("link[href]")].some((other) => !other.closest("noscript") && linkDedupeKey(other) === key);
|
|
216
|
+
}
|
|
217
|
+
function headStyleRuns(styles, isPinned = () => false) {
|
|
218
|
+
const runs = [];
|
|
219
|
+
let previousKey;
|
|
220
|
+
for (const el of styles) {
|
|
221
|
+
const key = isPinned(el) ? void 0 : cssStyleMergeKey(el);
|
|
222
|
+
if (key !== void 0 && key === previousKey)
|
|
223
|
+
runs.at(-1).push(el);
|
|
224
|
+
else if (key !== void 0)
|
|
225
|
+
runs.push([el]);
|
|
226
|
+
previousKey = key;
|
|
227
|
+
}
|
|
228
|
+
return runs;
|
|
229
|
+
}
|
|
230
|
+
function compositionStyle(el, css) {
|
|
231
|
+
return { css, media: el.getAttribute("media"), title: el.getAttribute("title") };
|
|
232
|
+
}
|
|
233
|
+
function styleElementsFor(document, sheets, join) {
|
|
234
|
+
const elements = sheets.map(({ css, media, title }) => {
|
|
235
|
+
const el = document.createElement("style");
|
|
236
|
+
if (media !== null)
|
|
237
|
+
el.setAttribute("media", media);
|
|
238
|
+
if (title !== null)
|
|
239
|
+
el.setAttribute("title", title);
|
|
240
|
+
el.textContent = css;
|
|
241
|
+
return el;
|
|
242
|
+
});
|
|
243
|
+
return headStyleRuns(elements).map((run) => {
|
|
244
|
+
run[0].textContent = join(run.map((el) => el.textContent || ""));
|
|
245
|
+
return run[0];
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// ../core/dist/sceneParts.js
|
|
250
|
+
var SCENE_PART_ATTR = "data-hf-scene";
|
|
251
|
+
var SCENE_PARTS_META = "hf-scene-parts";
|
|
252
|
+
var SCENE_NO_SWAP_ATTR = "data-hf-scene-no-swap";
|
|
253
|
+
|
|
254
|
+
// ../core/dist/compiler/externalScripts.js
|
|
255
|
+
function readExternalScriptAttributes(el) {
|
|
256
|
+
const attributes = {};
|
|
257
|
+
if (el.hasAttribute("integrity"))
|
|
258
|
+
attributes.integrity = el.getAttribute("integrity") || "";
|
|
259
|
+
if (el.hasAttribute("crossorigin"))
|
|
260
|
+
attributes.crossorigin = el.getAttribute("crossorigin") || "";
|
|
261
|
+
if ((el.getAttribute("type") || "").trim().toLowerCase() === "module")
|
|
262
|
+
attributes.type = "module";
|
|
263
|
+
return attributes;
|
|
264
|
+
}
|
|
265
|
+
function ensureExternalScriptTag(doc, src, attributes = {}) {
|
|
266
|
+
const existing = [...doc.querySelectorAll("script[src]")].filter((el) => el.getAttribute("src")?.trim() === src);
|
|
267
|
+
const requirements = new Set([attributes.integrity, ...existing.map((el) => el.getAttribute("integrity"))].map((value) => value?.trim().replace(/(^|[\t\n\f\r ])(sha256|sha384|sha512)-/gi, (_match, space, algorithm) => `${space}${algorithm.toLowerCase()}-`)).filter((value) => Boolean(value)));
|
|
268
|
+
if (requirements.size > 1) {
|
|
269
|
+
throw new Error(`Conflicting script integrity requirements for ${src}`);
|
|
270
|
+
}
|
|
271
|
+
const integrity = [...requirements][0];
|
|
272
|
+
const elements = existing.length ? existing : [doc.createElement("script")];
|
|
273
|
+
for (const el of elements) {
|
|
274
|
+
if (integrity)
|
|
275
|
+
el.setAttribute("integrity", integrity);
|
|
276
|
+
if (attributes.crossorigin !== void 0)
|
|
277
|
+
el.setAttribute("crossorigin", attributes.crossorigin);
|
|
278
|
+
if (attributes.type)
|
|
279
|
+
el.setAttribute("type", attributes.type);
|
|
280
|
+
}
|
|
281
|
+
if (!existing.length) {
|
|
282
|
+
const el = elements[0];
|
|
283
|
+
el.setAttribute("src", src);
|
|
284
|
+
doc.body.appendChild(el);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// ../core/dist/compiler/importMaps.js
|
|
289
|
+
var rebaseEntries = (entries, rebase) => entries && Object.fromEntries(Object.entries(entries).map(([specifier, url]) => [specifier, rebase(url)]));
|
|
290
|
+
function parseImportMap(json, rebase) {
|
|
291
|
+
let parsed;
|
|
292
|
+
try {
|
|
293
|
+
parsed = JSON.parse(json);
|
|
294
|
+
} catch {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
if (!parsed || typeof parsed !== "object")
|
|
298
|
+
return null;
|
|
299
|
+
const { imports, scopes } = parsed;
|
|
300
|
+
return {
|
|
301
|
+
imports: rebaseEntries(imports, rebase),
|
|
302
|
+
scopes: scopes && Object.fromEntries(Object.entries(scopes).map(([prefix, entries]) => [
|
|
303
|
+
rebase(prefix),
|
|
304
|
+
rebaseEntries(entries, rebase) ?? {}
|
|
305
|
+
]))
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function mergeEntries(into, from, where) {
|
|
309
|
+
for (const [specifier, url] of Object.entries(from ?? {})) {
|
|
310
|
+
if (!(specifier in into))
|
|
311
|
+
into[specifier] = url;
|
|
312
|
+
else if (into[specifier] !== url) {
|
|
313
|
+
console.warn(`[HyperFrames] import map conflict for "${specifier}"${where}: keeping ${into[specifier]}, ignoring ${url}.`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function mergeImportMapsIntoDocument(doc, maps) {
|
|
318
|
+
if (maps.length === 0)
|
|
319
|
+
return;
|
|
320
|
+
let el = doc.querySelector('script[type="importmap"]');
|
|
321
|
+
let page = {};
|
|
322
|
+
try {
|
|
323
|
+
page = el ? JSON.parse(el.textContent || "{}") : {};
|
|
324
|
+
} catch {
|
|
325
|
+
console.warn("[HyperFrames] the page's import map is not valid JSON; replacing it.");
|
|
326
|
+
}
|
|
327
|
+
const imports = { ...page.imports };
|
|
328
|
+
const scopes = { ...page.scopes };
|
|
329
|
+
for (const map of maps) {
|
|
330
|
+
mergeEntries(imports, map.imports, "");
|
|
331
|
+
for (const [prefix, entries] of Object.entries(map.scopes ?? {})) {
|
|
332
|
+
mergeEntries(scopes[prefix] ??= {}, entries, ` in scope ${prefix}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (!el) {
|
|
336
|
+
el = doc.createElement("script");
|
|
337
|
+
el.setAttribute("type", "importmap");
|
|
338
|
+
doc.head.prepend(el);
|
|
339
|
+
}
|
|
340
|
+
el.textContent = JSON.stringify({
|
|
341
|
+
...page,
|
|
342
|
+
imports,
|
|
343
|
+
...Object.keys(scopes).length ? { scopes } : {}
|
|
344
|
+
}).replace(/</g, "\\u003c");
|
|
345
|
+
}
|
|
346
|
+
function emitMountedModuleScripts(doc, importMaps, moduleScripts) {
|
|
347
|
+
mergeImportMapsIntoDocument(doc, importMaps);
|
|
348
|
+
for (const content of moduleScripts) {
|
|
349
|
+
const el = doc.createElement("script");
|
|
350
|
+
el.setAttribute("type", "module");
|
|
351
|
+
el.textContent = content;
|
|
352
|
+
doc.body.appendChild(el);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// ../core/dist/runtime/flattenedRoot.js
|
|
357
|
+
var FLATTENED_INNER_ROOT_STRIP_ATTRS = [
|
|
358
|
+
"data-composition-id",
|
|
359
|
+
"data-composition-file",
|
|
360
|
+
"data-start",
|
|
361
|
+
"data-duration",
|
|
362
|
+
"data-end",
|
|
363
|
+
"data-track-index",
|
|
364
|
+
"data-track",
|
|
365
|
+
"data-composition-src",
|
|
366
|
+
"data-hf-authored-duration",
|
|
367
|
+
"data-hf-authored-end"
|
|
368
|
+
];
|
|
369
|
+
function markFlattenedInnerRoot(prepared) {
|
|
370
|
+
const authoredRootId = prepared.getAttribute("id")?.trim();
|
|
371
|
+
for (const attrName of FLATTENED_INNER_ROOT_STRIP_ATTRS) {
|
|
372
|
+
prepared.removeAttribute(attrName);
|
|
373
|
+
}
|
|
374
|
+
if (authoredRootId) {
|
|
375
|
+
prepared.removeAttribute("id");
|
|
376
|
+
prepared.setAttribute("data-hf-authored-id", authoredRootId);
|
|
377
|
+
}
|
|
378
|
+
prepared.setAttribute("data-hf-inner-root", "true");
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// ../core/dist/runtime/applyVariableBindings.js
|
|
382
|
+
function sanitizeCssValue(value) {
|
|
383
|
+
return value.replace(/[;{}<>\r\n]/g, "");
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// ../core/dist/compiler/htmlBundler.js
|
|
387
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
388
|
+
import { readFileSync, existsSync, statSync } from "fs";
|
|
389
|
+
import { resolve as resolve2, relative, dirname, isAbsolute, sep } from "path";
|
|
390
|
+
import { transformSync } from "esbuild";
|
|
391
|
+
|
|
392
|
+
// ../core/dist/compiler/compositionScoping.js
|
|
393
|
+
import postcss from "postcss";
|
|
394
|
+
|
|
395
|
+
// ../core/dist/compiler/selectorIdTokens.js
|
|
396
|
+
function isNameChar(char) {
|
|
397
|
+
if (!char)
|
|
398
|
+
return false;
|
|
399
|
+
return /[\w-]/.test(char) || char.charCodeAt(0) >= 128;
|
|
400
|
+
}
|
|
401
|
+
function isCssWhitespace(char) {
|
|
402
|
+
return char === " " || char === " " || char === "\n" || char === "\r" || char === "\f";
|
|
403
|
+
}
|
|
404
|
+
var HEX_ESCAPE_RE = /^[0-9a-fA-F]{1,6}/;
|
|
405
|
+
function sanitizeCodePoint(codePoint) {
|
|
406
|
+
const isSurrogate = codePoint >= 55296 && codePoint <= 57343;
|
|
407
|
+
return codePoint === 0 || codePoint > 1114111 || isSurrogate ? 65533 : codePoint;
|
|
408
|
+
}
|
|
409
|
+
function skipEscapeWhitespace(text, index) {
|
|
410
|
+
if (text[index] === "\r" && text[index + 1] === "\n")
|
|
411
|
+
return index + 2;
|
|
412
|
+
return isCssWhitespace(text[index]) ? index + 1 : index;
|
|
413
|
+
}
|
|
414
|
+
function consumeCssEscape(text, index) {
|
|
415
|
+
const next = text[index + 1];
|
|
416
|
+
if (next === void 0 || next === "\n")
|
|
417
|
+
return null;
|
|
418
|
+
const hex = HEX_ESCAPE_RE.exec(text.slice(index + 1, index + 7));
|
|
419
|
+
if (!hex)
|
|
420
|
+
return { value: next, end: index + 2 };
|
|
421
|
+
const codePoint = sanitizeCodePoint(Number.parseInt(hex[0], 16));
|
|
422
|
+
return {
|
|
423
|
+
value: String.fromCodePoint(codePoint),
|
|
424
|
+
end: skipEscapeWhitespace(text, index + 1 + hex[0].length)
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
function decodeCssIdentifierAt(text, start) {
|
|
428
|
+
let index = start;
|
|
429
|
+
let value = "";
|
|
430
|
+
while (index < text.length) {
|
|
431
|
+
const char = text[index];
|
|
432
|
+
if (char === "\\") {
|
|
433
|
+
const escape = consumeCssEscape(text, index);
|
|
434
|
+
if (!escape)
|
|
435
|
+
break;
|
|
436
|
+
value += escape.value;
|
|
437
|
+
index = escape.end;
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
if (!isNameChar(char))
|
|
441
|
+
break;
|
|
442
|
+
value += char;
|
|
443
|
+
index += 1;
|
|
444
|
+
}
|
|
445
|
+
return index === start ? null : { value, end: index };
|
|
446
|
+
}
|
|
447
|
+
var CODE_UNIT_HYPHEN = 45;
|
|
448
|
+
function isDigitCodeUnit(codeUnit) {
|
|
449
|
+
return codeUnit >= 48 && codeUnit <= 57;
|
|
450
|
+
}
|
|
451
|
+
function isPlainNameCodeUnit(codeUnit) {
|
|
452
|
+
return codeUnit >= 128 || codeUnit === CODE_UNIT_HYPHEN || codeUnit === 95 || isDigitCodeUnit(codeUnit) || codeUnit >= 65 && codeUnit <= 90 || codeUnit >= 97 && codeUnit <= 122;
|
|
453
|
+
}
|
|
454
|
+
function needsHexEscape(value, index) {
|
|
455
|
+
const codeUnit = value.charCodeAt(index);
|
|
456
|
+
if (codeUnit >= 1 && codeUnit <= 31 || codeUnit === 127)
|
|
457
|
+
return true;
|
|
458
|
+
if (!isDigitCodeUnit(codeUnit))
|
|
459
|
+
return false;
|
|
460
|
+
return index === 0 || index === 1 && value.charCodeAt(0) === CODE_UNIT_HYPHEN;
|
|
461
|
+
}
|
|
462
|
+
function escapeCssIdentifier(value) {
|
|
463
|
+
let result = "";
|
|
464
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
465
|
+
const codeUnit = value.charCodeAt(index);
|
|
466
|
+
const char = value[index];
|
|
467
|
+
if (codeUnit === 0)
|
|
468
|
+
result += "\uFFFD";
|
|
469
|
+
else if (needsHexEscape(value, index))
|
|
470
|
+
result += `\\${codeUnit.toString(16)} `;
|
|
471
|
+
else if (index === 0 && value.length === 1 && codeUnit === CODE_UNIT_HYPHEN)
|
|
472
|
+
result += `\\${char}`;
|
|
473
|
+
else if (isPlainNameCodeUnit(codeUnit))
|
|
474
|
+
result += char;
|
|
475
|
+
else
|
|
476
|
+
result += `\\${char}`;
|
|
477
|
+
}
|
|
478
|
+
return result;
|
|
479
|
+
}
|
|
480
|
+
var GUARDED_SELECTOR_SEGMENT_RE = /\\(?:[0-9a-fA-F]{1,6}(?:\r\n|[ \t\r\n\f])?|[\s\S])|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\[(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^\]"'])*\]/g;
|
|
481
|
+
function markUnguardedOffsets(selector) {
|
|
482
|
+
const mask = new Array(selector.length).fill(true);
|
|
483
|
+
for (const match of selector.matchAll(GUARDED_SELECTOR_SEGMENT_RE)) {
|
|
484
|
+
const start = match.index;
|
|
485
|
+
mask.fill(false, start, start + match[0].length);
|
|
486
|
+
}
|
|
487
|
+
return mask;
|
|
488
|
+
}
|
|
489
|
+
function replaceSelectorIdTokens(selector, candidateIds, resolveReplacement) {
|
|
490
|
+
if (candidateIds.length === 0 || !selector.includes("#"))
|
|
491
|
+
return selector;
|
|
492
|
+
const candidates = new Set(candidateIds);
|
|
493
|
+
const unguarded = markUnguardedOffsets(selector);
|
|
494
|
+
let result = "";
|
|
495
|
+
let index = 0;
|
|
496
|
+
while (index < selector.length) {
|
|
497
|
+
const token = unguarded[index] && selector[index] === "#" ? decodeCssIdentifierAt(selector, index + 1) : null;
|
|
498
|
+
if (token && candidates.has(token.value)) {
|
|
499
|
+
result += resolveReplacement(token.value);
|
|
500
|
+
index = token.end;
|
|
501
|
+
} else {
|
|
502
|
+
result += selector[index];
|
|
503
|
+
index += 1;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return result;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// ../core/dist/compiler/compositionScoping.js
|
|
510
|
+
var AUTHORED_ROOT_ID_ATTR = "data-hf-authored-id";
|
|
511
|
+
var INNER_ROOT_ATTR = "data-hf-inner-root";
|
|
512
|
+
function escapeRegExp(value) {
|
|
513
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
514
|
+
}
|
|
515
|
+
function escapeCssAttributeValue(value) {
|
|
516
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
517
|
+
}
|
|
518
|
+
function getAuthoredRootIdSelectorForms(authoredRootId) {
|
|
519
|
+
const trimmed = authoredRootId.trim();
|
|
520
|
+
if (!trimmed)
|
|
521
|
+
return [];
|
|
522
|
+
return Array.from(/* @__PURE__ */ new Set([trimmed, escapeCssIdentifier(trimmed)])).filter(Boolean);
|
|
523
|
+
}
|
|
524
|
+
function replaceAuthoredRootIdSelectors(selector, authoredRootId, replacement) {
|
|
525
|
+
const forms = getAuthoredRootIdSelectorForms(authoredRootId);
|
|
526
|
+
return replaceSelectorIdTokens(selector, forms, () => replacement);
|
|
527
|
+
}
|
|
528
|
+
function normalizeAuthoredRootIdSelector(selector, authoredRootId) {
|
|
529
|
+
const trimmed = authoredRootId?.trim();
|
|
530
|
+
if (!trimmed)
|
|
531
|
+
return selector;
|
|
532
|
+
return replaceAuthoredRootIdSelectors(selector, trimmed, `[${AUTHORED_ROOT_ID_ATTR}="${escapeCssAttributeValue(trimmed)}"]`);
|
|
533
|
+
}
|
|
534
|
+
function compositionBoxSelector(scope) {
|
|
535
|
+
return `${scope}:not(:has([${INNER_ROOT_ATTR}])), ${scope} > [${INNER_ROOT_ATTR}]`;
|
|
536
|
+
}
|
|
537
|
+
function scopeSelector(selector, scope, compositionId, authoredRootId, compoundAuthoredRoot, scopeRootSelectors) {
|
|
538
|
+
const selectorWithoutAuthoredRootId = normalizeAuthoredRootIdSelector(selector, authoredRootId);
|
|
539
|
+
const selectorWithoutRootTiming = normalizeCompositionRootSelector(selectorWithoutAuthoredRootId, scope, compositionId);
|
|
540
|
+
const trimmed = selectorWithoutRootTiming.trim();
|
|
541
|
+
if (!trimmed)
|
|
542
|
+
return selector;
|
|
543
|
+
if (trimmed === "*")
|
|
544
|
+
return selector;
|
|
545
|
+
if (/^(html|body|:root)$/i.test(trimmed)) {
|
|
546
|
+
return scopeRootSelectors ? compositionBoxSelector(scope) : selector;
|
|
547
|
+
}
|
|
548
|
+
const compositionIdPattern = new RegExp(`\\[\\s*data-composition-id\\s*[\\^\\*\\$]?=\\s*(["'])${escapeRegExp(compositionId)}\\1\\s*\\]`, "g");
|
|
549
|
+
if (compositionIdPattern.test(trimmed)) {
|
|
550
|
+
const isRootBoxSelector = trimmed.replace(compositionIdPattern, "").trim() === "";
|
|
551
|
+
if (isRootBoxSelector) {
|
|
552
|
+
return compositionBoxSelector(scope);
|
|
553
|
+
}
|
|
554
|
+
return selectorWithoutRootTiming.replace(compositionIdPattern, scope);
|
|
555
|
+
}
|
|
556
|
+
const leading = selectorWithoutRootTiming.match(/^\s*/)?.[0] ?? "";
|
|
557
|
+
const trailing = selectorWithoutRootTiming.match(/\s*$/)?.[0] ?? "";
|
|
558
|
+
if (compoundAuthoredRoot) {
|
|
559
|
+
const authoredRootAttr = authoredRootId ? `[${AUTHORED_ROOT_ID_ATTR}="${escapeCssAttributeValue(authoredRootId)}"]` : null;
|
|
560
|
+
if (authoredRootAttr && trimmed.startsWith(authoredRootAttr)) {
|
|
561
|
+
const rest = trimmed.slice(authoredRootAttr.length);
|
|
562
|
+
return `${leading}${scope}${authoredRootAttr}${rest}${trailing}`;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return `${leading}${scope} ${trimmed}${trailing}`;
|
|
566
|
+
}
|
|
567
|
+
function normalizeCompositionRootSelector(selector, scope, compositionId) {
|
|
568
|
+
const quotedCompId = escapeRegExp(compositionId);
|
|
569
|
+
const compAttr = String.raw`\[\s*data-composition-id\s*=\s*(?:"${quotedCompId}"|'${quotedCompId}')\s*\]`;
|
|
570
|
+
const timingAttr = String.raw`\s*\[\s*data-(?:start|duration)\s*=\s*(?:"[^"]*"|'[^']*')\s*\]`;
|
|
571
|
+
return selector.replace(new RegExp(`${compAttr}(?:${timingAttr})+`, "g"), scope).replace(new RegExp(`(?:${timingAttr})+${compAttr}`, "g"), scope);
|
|
572
|
+
}
|
|
573
|
+
var GLOBAL_AT_RULES = /* @__PURE__ */ new Set(["keyframes", "-webkit-keyframes", "font-face"]);
|
|
574
|
+
function isAtRuleNode(node) {
|
|
575
|
+
return node?.type === "atrule";
|
|
576
|
+
}
|
|
577
|
+
function isInsideGlobalAtRule(rule) {
|
|
578
|
+
let current = rule.parent;
|
|
579
|
+
while (current) {
|
|
580
|
+
if (isAtRuleNode(current) && GLOBAL_AT_RULES.has(current.name.toLowerCase())) {
|
|
581
|
+
return true;
|
|
582
|
+
}
|
|
583
|
+
current = current.parent;
|
|
584
|
+
}
|
|
585
|
+
return false;
|
|
586
|
+
}
|
|
587
|
+
function isNestedInsideAnotherRule(rule) {
|
|
588
|
+
let current = rule.parent;
|
|
589
|
+
while (current) {
|
|
590
|
+
if (current.type === "rule")
|
|
591
|
+
return true;
|
|
592
|
+
current = current.parent;
|
|
593
|
+
}
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
function scopeCssToComposition(css, compositionId, scopeSelectorOverride, authoredRootId, options) {
|
|
597
|
+
const trimmedCompositionId = compositionId.trim();
|
|
598
|
+
if (!css || !trimmedCompositionId)
|
|
599
|
+
return css;
|
|
600
|
+
const scope = scopeSelectorOverride || `[data-composition-id="${escapeCssAttributeValue(trimmedCompositionId)}"]`;
|
|
601
|
+
let root;
|
|
602
|
+
try {
|
|
603
|
+
root = postcss.parse(css);
|
|
604
|
+
} catch {
|
|
605
|
+
return "";
|
|
606
|
+
}
|
|
607
|
+
root.walkRules((rule) => {
|
|
608
|
+
if (isInsideGlobalAtRule(rule))
|
|
609
|
+
return;
|
|
610
|
+
if (isNestedInsideAnotherRule(rule))
|
|
611
|
+
return;
|
|
612
|
+
rule.selectors = rule.selectors.map((selector) => scopeSelector(selector, scope, trimmedCompositionId, authoredRootId, options?.compoundAuthoredRoot, options?.scopeRootSelectors));
|
|
613
|
+
});
|
|
614
|
+
return root.toResult({ map: false }).css;
|
|
615
|
+
}
|
|
616
|
+
function isFontFaceAtRule(node) {
|
|
617
|
+
return node.type === "atrule" && node.name.toLowerCase() === "font-face";
|
|
618
|
+
}
|
|
619
|
+
function fontFaceKey(atRule) {
|
|
620
|
+
const decls = [];
|
|
621
|
+
atRule.walkDecls((decl) => {
|
|
622
|
+
const value = decl.value.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\s+/g, (_m, str) => str ?? " ");
|
|
623
|
+
decls.push(`${decl.prop.trim().toLowerCase()}:${value.trim()}${decl.important ? "!important" : ""}`);
|
|
624
|
+
});
|
|
625
|
+
return decls.join(";");
|
|
626
|
+
}
|
|
627
|
+
function dedupeFontFaceRules(styleTexts) {
|
|
628
|
+
const seen = /* @__PURE__ */ new Set();
|
|
629
|
+
return [...styleTexts].reverse().map((css) => {
|
|
630
|
+
if (!css || !/@font-face/i.test(css))
|
|
631
|
+
return css;
|
|
632
|
+
let root;
|
|
633
|
+
try {
|
|
634
|
+
root = postcss.parse(css);
|
|
635
|
+
} catch {
|
|
636
|
+
return css;
|
|
637
|
+
}
|
|
638
|
+
let changed = false;
|
|
639
|
+
for (const node of [...root.nodes ?? []].reverse()) {
|
|
640
|
+
if (!isFontFaceAtRule(node))
|
|
641
|
+
continue;
|
|
642
|
+
const key = fontFaceKey(node);
|
|
643
|
+
if (seen.has(key)) {
|
|
644
|
+
node.remove();
|
|
645
|
+
changed = true;
|
|
646
|
+
} else {
|
|
647
|
+
seen.add(key);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return changed ? root.toResult({ map: false }).css : css;
|
|
651
|
+
}).reverse();
|
|
652
|
+
}
|
|
653
|
+
function jsonScriptLiteral(value) {
|
|
654
|
+
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
655
|
+
}
|
|
656
|
+
var SCOPED_HYPERFRAMES_EXPRESSION = `!__hfBaseHyperframes
|
|
657
|
+
? __hfBaseHyperframes
|
|
658
|
+
: Object.assign({}, __hfBaseHyperframes, {
|
|
659
|
+
assetUrl: function(path) {
|
|
660
|
+
var page = window.document.baseURI;
|
|
661
|
+
return new URL(path, __hfCompositionSrc ? new URL(__hfCompositionSrc, page) : page).href;
|
|
662
|
+
},
|
|
663
|
+
getVariables: function() {
|
|
664
|
+
var byComp = window.__hfVariablesByComp;
|
|
665
|
+
var scoped = byComp && __hfTimelineCompId ? byComp[__hfTimelineCompId] : null;
|
|
666
|
+
return scoped ? Object.assign({}, scoped) : {};
|
|
667
|
+
},
|
|
668
|
+
})`;
|
|
669
|
+
function scopedModulePrelude(timelineCompositionId, compositionSrc) {
|
|
670
|
+
return `const __hyperframes = (function(__hfBaseHyperframes, __hfTimelineCompId, __hfCompositionSrc) {
|
|
671
|
+
return ${SCOPED_HYPERFRAMES_EXPRESSION};
|
|
672
|
+
})(window.__hyperframes, ${jsonScriptLiteral(timelineCompositionId)}, ${jsonScriptLiteral(compositionSrc?.trim() || null)});
|
|
673
|
+
${wrapScopedCompositionScript("", timelineCompositionId)}
|
|
674
|
+
`;
|
|
675
|
+
}
|
|
676
|
+
function wrapScopedCompositionScript(source, compositionId, errorLabel = "[HyperFrames] composition script error:", scopeSelectorOverride, timelineCompositionId = compositionId, authoredRootId, compositionSrc) {
|
|
677
|
+
const compositionIdLiteral = jsonScriptLiteral(compositionId);
|
|
678
|
+
const timelineCompositionIdLiteral = jsonScriptLiteral(timelineCompositionId);
|
|
679
|
+
const errorLabelLiteral = jsonScriptLiteral(errorLabel);
|
|
680
|
+
const escapedCompositionId = escapeRegExp(compositionId);
|
|
681
|
+
const authoredRootIdLiteral = jsonScriptLiteral(authoredRootId?.trim() || null);
|
|
682
|
+
const scopeSelectorLiteral = jsonScriptLiteral(scopeSelectorOverride ?? null);
|
|
683
|
+
const rootSelectorPatternLiteral = jsonScriptLiteral(String.raw`\[\s*data-composition-id\s*=\s*(?:"${escapedCompositionId}"|'${escapedCompositionId}')\s*\]`);
|
|
684
|
+
const timingSelectorPatternLiteral = jsonScriptLiteral(String.raw`\s*\[\s*data-(?:start|duration)\s*=\s*(?:"[^"]*"|'[^']*')\s*\]`);
|
|
685
|
+
return `(function(){
|
|
686
|
+
var __hfCompId = ${compositionIdLiteral};
|
|
687
|
+
var __hfTimelineCompId = ${timelineCompositionIdLiteral};
|
|
688
|
+
var __hfErrorLabel = ${errorLabelLiteral};
|
|
689
|
+
var __hfAuthoredRootId = ${authoredRootIdLiteral};
|
|
690
|
+
var __hfCompositionSrc = ${jsonScriptLiteral(compositionSrc?.trim() || null)};
|
|
691
|
+
var __hfAuthoredRootAttr = ${jsonScriptLiteral(AUTHORED_ROOT_ID_ATTR)};
|
|
692
|
+
var __hfEscapeAttr = function(value) {
|
|
693
|
+
return (value + "").replace(/\\\\/g, "\\\\\\\\").replace(/"/g, "\\\\\\"");
|
|
694
|
+
};
|
|
695
|
+
var __hfRootSelector = ${scopeSelectorLiteral} || (__hfCompId
|
|
696
|
+
? '[data-composition-id="' + __hfEscapeAttr(__hfCompId) + '"]'
|
|
697
|
+
: "");
|
|
698
|
+
var __hfRoot = null;
|
|
699
|
+
var __hfRootSelectorPattern = ${rootSelectorPatternLiteral};
|
|
700
|
+
var __hfTimingSelectorPattern = ${timingSelectorPatternLiteral};
|
|
701
|
+
var __hfAuthoredRootSelector = __hfAuthoredRootId
|
|
702
|
+
? "[" + __hfAuthoredRootAttr + '="' + __hfEscapeAttr(__hfAuthoredRootId) + '"]'
|
|
703
|
+
: "";
|
|
704
|
+
var __hfCssEscape = function(value) {
|
|
705
|
+
var text = value + "";
|
|
706
|
+
if (typeof CSS !== "undefined" && CSS && typeof CSS.escape === "function") {
|
|
707
|
+
try { return CSS.escape(text); } catch {}
|
|
708
|
+
}
|
|
709
|
+
return text.replace(/[^a-zA-Z0-9_-]/g, function(char) { return "\\\\" + char; });
|
|
710
|
+
};
|
|
711
|
+
// Decode complete CSS identifiers before comparing authored ids.
|
|
712
|
+
var __hfRewriteIdSelectors = function(selector, entries) {
|
|
713
|
+
if (!entries || !entries.length || typeof selector !== "string" || selector.indexOf("#") === -1) {
|
|
714
|
+
return selector;
|
|
715
|
+
}
|
|
716
|
+
var result = "";
|
|
717
|
+
var bracketDepth = 0;
|
|
718
|
+
var quote = null;
|
|
719
|
+
for (var index = 0; index < selector.length; index += 1) {
|
|
720
|
+
var char = selector[index];
|
|
721
|
+
if (char === "\\\\") {
|
|
722
|
+
var escape = selector.slice(index).match(/^\\\\(?:[0-9a-fA-F]{1,6}(?:\\r\\n|[ \\t\\r\\n\\f])?|[\\s\\S])/);
|
|
723
|
+
if (escape) {
|
|
724
|
+
result += escape[0];
|
|
725
|
+
index += escape[0].length - 1;
|
|
726
|
+
continue;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
if (quote) {
|
|
730
|
+
result += char;
|
|
731
|
+
if (char === quote) {
|
|
732
|
+
quote = null;
|
|
733
|
+
}
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
if (char === '"' || char === "'") {
|
|
737
|
+
quote = char;
|
|
738
|
+
result += char;
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
if (char === "[") {
|
|
742
|
+
bracketDepth += 1;
|
|
743
|
+
result += char;
|
|
744
|
+
continue;
|
|
745
|
+
}
|
|
746
|
+
if (char === "]") {
|
|
747
|
+
bracketDepth = Math.max(0, bracketDepth - 1);
|
|
748
|
+
result += char;
|
|
749
|
+
continue;
|
|
750
|
+
}
|
|
751
|
+
if (char === "#" && bracketDepth === 0) {
|
|
752
|
+
var token = selector.slice(index + 1).match(/^(?:[\\w\\u0080-\\uffff-]|\\\\(?:[0-9a-fA-F]{1,6}(?:\\r\\n|[ \\t\\r\\n\\f])?|[^\\r\\n\\f]))+/);
|
|
753
|
+
if (token) {
|
|
754
|
+
var decoded = token[0].replace(/\\\\([0-9a-fA-F]{1,6})(?:\\r\\n|[ \\t\\r\\n\\f])?|\\\\([^\\r\\n\\f])/g, function(_, hex, escaped) {
|
|
755
|
+
if (!hex) return escaped;
|
|
756
|
+
var code = parseInt(hex, 16);
|
|
757
|
+
return String.fromCodePoint(!code || code > 0x10ffff || (code >= 0xd800 && code <= 0xdfff) ? 0xfffd : code);
|
|
758
|
+
});
|
|
759
|
+
var matched = entries.find(function(entry) { return entry.id === decoded; });
|
|
760
|
+
result += matched ? matched.replacement : "#" + token[0];
|
|
761
|
+
index += token[0].length;
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
result += char;
|
|
766
|
+
}
|
|
767
|
+
return result;
|
|
768
|
+
};
|
|
769
|
+
var __hfAuthoredRootEntries = __hfAuthoredRootSelector
|
|
770
|
+
? [{ id: __hfAuthoredRootId, replacement: __hfAuthoredRootSelector }]
|
|
771
|
+
: [];
|
|
772
|
+
// Include both renamed and untouched instances. Each wrapper refreshes this
|
|
773
|
+
// document-wide cache because preview scene swaps can introduce new ids.
|
|
774
|
+
var __hfRenamedIdEntries = function() {
|
|
775
|
+
if (window.__hfRenamedIdSelectorEntries) return window.__hfRenamedIdSelectorEntries;
|
|
776
|
+
var entries = [];
|
|
777
|
+
var seen = Object.create(null);
|
|
778
|
+
var nodes;
|
|
779
|
+
try {
|
|
780
|
+
nodes = window.document.querySelectorAll("[" + __hfAuthoredRootAttr + "][id]");
|
|
781
|
+
} catch {
|
|
782
|
+
nodes = [];
|
|
783
|
+
}
|
|
784
|
+
for (var i = 0; i < nodes.length; i += 1) {
|
|
785
|
+
var authored = nodes[i].getAttribute(__hfAuthoredRootAttr);
|
|
786
|
+
if (!authored || seen[authored] || authored === nodes[i].id) continue;
|
|
787
|
+
seen[authored] = true;
|
|
788
|
+
var escaped = __hfCssEscape(authored);
|
|
789
|
+
entries.push({
|
|
790
|
+
id: authored,
|
|
791
|
+
replacement: ":is(#" + escaped + ", [" + __hfAuthoredRootAttr + '="' + __hfEscapeAttr(authored) + '"])',
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
window.__hfRenamedIdSelectorEntries = entries;
|
|
795
|
+
return window.__hfRenamedIdSelectorEntries;
|
|
796
|
+
};
|
|
797
|
+
// element.querySelector("#authored") on an arbitrary Element never passes
|
|
798
|
+
// through the scoped document proxy, so the same rewrite is installed once
|
|
799
|
+
// per document on Element.prototype \u2014 only when at least one id was
|
|
800
|
+
// actually renamed, so a document without collisions runs untouched
|
|
801
|
+
// natives. Document.prototype is deliberately NOT patched: an unscoped
|
|
802
|
+
// document-wide lookup cannot know which instance it means, and rewriting
|
|
803
|
+
// it would only widen the ambiguity.
|
|
804
|
+
var __hfInstallRenamedIdSelectorShim = function() {
|
|
805
|
+
if (window.__hfRenamedIdSelectorShim) return;
|
|
806
|
+
var entries = __hfRenamedIdEntries();
|
|
807
|
+
if (!entries.length) return;
|
|
808
|
+
var proto = window.Element && window.Element.prototype;
|
|
809
|
+
if (!proto || typeof proto.querySelector !== "function" || typeof proto.querySelectorAll !== "function") {
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
var nativeQuerySelector = proto.querySelector;
|
|
813
|
+
var nativeQuerySelectorAll = proto.querySelectorAll;
|
|
814
|
+
proto.querySelector = function(selector) {
|
|
815
|
+
return nativeQuerySelector.call(this, __hfRewriteIdSelectors(selector, __hfRenamedIdEntries()));
|
|
816
|
+
};
|
|
817
|
+
proto.querySelectorAll = function(selector) {
|
|
818
|
+
return nativeQuerySelectorAll.call(this, __hfRewriteIdSelectors(selector, __hfRenamedIdEntries()));
|
|
819
|
+
};
|
|
820
|
+
window.__hfRenamedIdSelectorShim = true;
|
|
821
|
+
};
|
|
822
|
+
var __hfNormalizeSelector = function(selector) {
|
|
823
|
+
if (!__hfCompId || typeof selector !== "string") return selector;
|
|
824
|
+
var normalized = selector
|
|
825
|
+
.replace(new RegExp(__hfRootSelectorPattern + '(?:' + __hfTimingSelectorPattern + ')+', 'g'), __hfRootSelector)
|
|
826
|
+
.replace(new RegExp('(?:' + __hfTimingSelectorPattern + ')+' + __hfRootSelectorPattern, 'g'), __hfRootSelector);
|
|
827
|
+
normalized = __hfRewriteIdSelectors(normalized, __hfAuthoredRootEntries);
|
|
828
|
+
return __hfRewriteIdSelectors(normalized, __hfRenamedIdEntries());
|
|
829
|
+
};
|
|
830
|
+
var __hfFindRoot = function() {
|
|
831
|
+
if (!__hfRoot && __hfRootSelector) {
|
|
832
|
+
__hfRoot = window.document.querySelector(__hfRootSelector);
|
|
833
|
+
}
|
|
834
|
+
return __hfRoot;
|
|
835
|
+
};
|
|
836
|
+
var __hfContains = function(node) {
|
|
837
|
+
var root = __hfFindRoot();
|
|
838
|
+
return !root || node === root || root.contains(node);
|
|
839
|
+
};
|
|
840
|
+
var __hfQueryAll = function(selector) {
|
|
841
|
+
var root = __hfFindRoot();
|
|
842
|
+
if (!root || typeof selector !== "string") {
|
|
843
|
+
return window.document.querySelectorAll(selector);
|
|
844
|
+
}
|
|
845
|
+
return Array.prototype.filter.call(window.document.querySelectorAll(__hfNormalizeSelector(selector)), function(node) {
|
|
846
|
+
return __hfContains(node);
|
|
847
|
+
});
|
|
848
|
+
};
|
|
849
|
+
var __hfQueryOne = function(selector) {
|
|
850
|
+
var matches = __hfQueryAll(selector);
|
|
851
|
+
return matches[0] || null;
|
|
852
|
+
};
|
|
853
|
+
var __hfGetElementById = function(id) {
|
|
854
|
+
var found = window.document.getElementById(id);
|
|
855
|
+
if (found && __hfContains(found)) return found;
|
|
856
|
+
var root = __hfFindRoot();
|
|
857
|
+
if (!root) return found || null;
|
|
858
|
+
var idValue = id + "";
|
|
859
|
+
if (__hfAuthoredRootId && __hfAuthoredRootId === idValue && root.getAttribute && root.getAttribute(__hfAuthoredRootAttr) === idValue) {
|
|
860
|
+
return root;
|
|
861
|
+
}
|
|
862
|
+
if (root.id === idValue) return root;
|
|
863
|
+
if (typeof root.querySelector !== "function") return null;
|
|
864
|
+
try {
|
|
865
|
+
var authoredRootMatch = root.querySelector('[' + __hfAuthoredRootAttr + '="' + __hfEscapeAttr(idValue) + '"]');
|
|
866
|
+
if (authoredRootMatch) return authoredRootMatch;
|
|
867
|
+
} catch {}
|
|
868
|
+
if (typeof CSS !== "undefined" && CSS && typeof CSS.escape === "function") {
|
|
869
|
+
try {
|
|
870
|
+
return root.querySelector("#" + CSS.escape(idValue)) || null;
|
|
871
|
+
} catch {}
|
|
872
|
+
}
|
|
873
|
+
try {
|
|
874
|
+
return root.querySelector('[id="' + __hfEscapeAttr(idValue) + '"]') || null;
|
|
875
|
+
} catch {}
|
|
876
|
+
return null;
|
|
877
|
+
};
|
|
878
|
+
var __hfScopedDocument = typeof Proxy === "function"
|
|
879
|
+
? new Proxy(window.document, {
|
|
880
|
+
get: function(target, prop, receiver) {
|
|
881
|
+
if (prop === "querySelector") return __hfQueryOne;
|
|
882
|
+
if (prop === "querySelectorAll") return __hfQueryAll;
|
|
883
|
+
if (prop === "getElementById") return __hfGetElementById;
|
|
884
|
+
var value = Reflect.get(target, prop, target);
|
|
885
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
886
|
+
},
|
|
887
|
+
})
|
|
888
|
+
: window.document;
|
|
889
|
+
var __hfTimelineRegistryProxy = null;
|
|
890
|
+
var __hfGetTimelineRegistry = function() {
|
|
891
|
+
window.__timelines = window.__timelines || {};
|
|
892
|
+
if (!__hfCompId || __hfCompId === __hfTimelineCompId || typeof Proxy !== "function") {
|
|
893
|
+
return window.__timelines;
|
|
894
|
+
}
|
|
895
|
+
if (!__hfTimelineRegistryProxy) {
|
|
896
|
+
__hfTimelineRegistryProxy = new Proxy(window.__timelines, {
|
|
897
|
+
get: function(target, prop, receiver) {
|
|
898
|
+
if (prop !== __hfCompId) {
|
|
899
|
+
return Reflect.get(target, prop, target);
|
|
900
|
+
}
|
|
901
|
+
var authoredValue = Reflect.get(target, prop, target);
|
|
902
|
+
return authoredValue === undefined
|
|
903
|
+
? Reflect.get(target, __hfTimelineCompId, target)
|
|
904
|
+
: authoredValue;
|
|
905
|
+
},
|
|
906
|
+
set: function(target, prop, value, receiver) {
|
|
907
|
+
if (prop !== __hfCompId) {
|
|
908
|
+
return Reflect.set(target, prop, value, target);
|
|
909
|
+
}
|
|
910
|
+
// The authored node remains in the compiled DOM when its local id
|
|
911
|
+
// differs from the runtime mount id, so readiness legitimately sees
|
|
912
|
+
// both compositions. Publish the same timeline under both identities
|
|
913
|
+
// instead of replacing one with the other.
|
|
914
|
+
var authoredSet = Reflect.set(target, __hfCompId, value, target);
|
|
915
|
+
var runtimeSet = Reflect.set(target, __hfTimelineCompId, value, target);
|
|
916
|
+
return authoredSet && runtimeSet;
|
|
917
|
+
},
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
return __hfTimelineRegistryProxy;
|
|
921
|
+
};
|
|
922
|
+
var __hfScopedWindow = typeof Proxy === "function"
|
|
923
|
+
? new Proxy(window, {
|
|
924
|
+
get: function(target, prop, receiver) {
|
|
925
|
+
if (prop === "__timelines") return __hfGetTimelineRegistry();
|
|
926
|
+
// Inside a sub-composition, __hyperframes is passed as a bare script
|
|
927
|
+
// param bound to the SCOPED variant (per-comp getVariables). But
|
|
928
|
+
// authors routinely write the documented window.__hyperframes.
|
|
929
|
+
// getVariables() form, which would otherwise fall through to the host
|
|
930
|
+
// page's base __hyperframes and return the WRONG (or empty) variables
|
|
931
|
+
// for this instance. Route it to the scoped variant too so both
|
|
932
|
+
// spellings resolve to this composition's own variables.
|
|
933
|
+
// (__hfScopedHyperframes is a hoisted var assigned below, before any
|
|
934
|
+
// sub-comp script -- the only code that reads this -- runs.)
|
|
935
|
+
if (prop === "__hyperframes") return __hfScopedHyperframes;
|
|
936
|
+
// Native window methods must stay bound to the real window. Handed
|
|
937
|
+
// back unbound, "this" at call time is this Proxy and Chrome rejects
|
|
938
|
+
// it with "Illegal invocation", which broke window.addEventListener,
|
|
939
|
+
// setTimeout, matchMedia and getComputedStyle inside every
|
|
940
|
+
// sub-composition -- including the window.addEventListener("hf-seek",
|
|
941
|
+
// ...) form the Three.js and TypeGPU adapters document. The sibling
|
|
942
|
+
// document and gsap proxies here already bind.
|
|
943
|
+
//
|
|
944
|
+
// Only bind non-constructors. Function.prototype.bind drops static
|
|
945
|
+
// members, so binding a class exposed on window (window.Texts and
|
|
946
|
+
// friends) would silently strip its statics. Built-in methods have
|
|
947
|
+
// no .prototype; classes and constructor functions do.
|
|
948
|
+
var value = Reflect.get(target, prop, target);
|
|
949
|
+
return typeof value === "function" && value.prototype === undefined
|
|
950
|
+
? value.bind(target)
|
|
951
|
+
: value;
|
|
952
|
+
},
|
|
953
|
+
set: function(target, prop, value, receiver) {
|
|
954
|
+
if (prop === "__timelines") {
|
|
955
|
+
// Common authoring boilerplate assigns the registry back to
|
|
956
|
+
// itself (window.__timelines = window.__timelines || {}). The
|
|
957
|
+
// getter above returns our proxy; do not replace the canonical
|
|
958
|
+
// registry with that proxy or later wrappers will stack proxies.
|
|
959
|
+
if (value === __hfTimelineRegistryProxy) return true;
|
|
960
|
+
target.__timelines = value || {};
|
|
961
|
+
__hfTimelineRegistryProxy = null;
|
|
962
|
+
return true;
|
|
963
|
+
}
|
|
964
|
+
return Reflect.set(target, prop, value, target);
|
|
965
|
+
},
|
|
966
|
+
})
|
|
967
|
+
: window;
|
|
968
|
+
var __hfResolveGsapTarget = function(target) {
|
|
969
|
+
if (typeof target === "string") return __hfQueryAll(target);
|
|
970
|
+
if (!Array.isArray(target)) return target;
|
|
971
|
+
return target.reduce(function(resolved, item) {
|
|
972
|
+
if (typeof item === "string") {
|
|
973
|
+
return resolved.concat(Array.prototype.slice.call(__hfQueryAll(item)));
|
|
974
|
+
}
|
|
975
|
+
resolved.push(item);
|
|
976
|
+
return resolved;
|
|
977
|
+
}, []);
|
|
978
|
+
|
|
979
|
+
};
|
|
980
|
+
var __hfScopeTimeline = function(timeline) {
|
|
981
|
+
if (!timeline || timeline.__hfScopedCompositionRoot === __hfFindRoot()) return timeline;
|
|
982
|
+
["to", "from", "fromTo", "set"].forEach(function(method) {
|
|
983
|
+
var original = timeline[method];
|
|
984
|
+
if (typeof original !== "function") return;
|
|
985
|
+
timeline[method] = function(target) {
|
|
986
|
+
var args = Array.prototype.slice.call(arguments);
|
|
987
|
+
args[0] = __hfResolveGsapTarget(target);
|
|
988
|
+
return original.apply(timeline, args);
|
|
989
|
+
};
|
|
990
|
+
});
|
|
991
|
+
try {
|
|
992
|
+
Object.defineProperty(timeline, "__hfScopedCompositionRoot", {
|
|
993
|
+
value: __hfFindRoot(),
|
|
994
|
+
configurable: true,
|
|
995
|
+
});
|
|
996
|
+
} catch {
|
|
997
|
+
// Best-effort: timelines coming from user code may have a frozen target
|
|
998
|
+
// or a non-extensible defineProperty path. Swallow \u2014 the scoped root
|
|
999
|
+
// is an enrichment, not a correctness invariant for playback.
|
|
1000
|
+
}
|
|
1001
|
+
return timeline;
|
|
1002
|
+
};
|
|
1003
|
+
var __hfBaseGsap = typeof gsap === "undefined" ? window.gsap : gsap;
|
|
1004
|
+
var __hfScopedGsap = !__hfBaseGsap || typeof Proxy !== "function"
|
|
1005
|
+
? __hfBaseGsap
|
|
1006
|
+
: new Proxy(__hfBaseGsap, {
|
|
1007
|
+
get: function(target, prop, receiver) {
|
|
1008
|
+
if (prop === "timeline") {
|
|
1009
|
+
return function() {
|
|
1010
|
+
return __hfScopeTimeline(target.timeline.apply(target, arguments));
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
if (prop === "to" || prop === "from" || prop === "fromTo" || prop === "set") {
|
|
1014
|
+
return function(firstArg) {
|
|
1015
|
+
var args = Array.prototype.slice.call(arguments);
|
|
1016
|
+
args[0] = __hfResolveGsapTarget(firstArg);
|
|
1017
|
+
return target[prop].apply(target, args);
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
if (prop === "utils" && target.utils && typeof Proxy === "function") {
|
|
1021
|
+
return new Proxy(target.utils, {
|
|
1022
|
+
get: function(utilsTarget, utilsProp, utilsReceiver) {
|
|
1023
|
+
if (utilsProp === "toArray") {
|
|
1024
|
+
return function(firstArg) {
|
|
1025
|
+
var args = Array.prototype.slice.call(arguments);
|
|
1026
|
+
args[0] = __hfResolveGsapTarget(firstArg);
|
|
1027
|
+
return utilsTarget.toArray.apply(utilsTarget, args);
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
if (utilsProp === "selector") {
|
|
1031
|
+
return function(base) {
|
|
1032
|
+
var baseEl = typeof base === "string" ? __hfQueryOne(base) : base;
|
|
1033
|
+
var root = baseEl || __hfFindRoot();
|
|
1034
|
+
return function(selector) {
|
|
1035
|
+
if (!root || typeof selector !== "string") return [];
|
|
1036
|
+
return Array.prototype.filter.call(
|
|
1037
|
+
window.document.querySelectorAll(__hfNormalizeSelector(selector)),
|
|
1038
|
+
function(node) {
|
|
1039
|
+
return node === root || (typeof root.contains === "function" && root.contains(node));
|
|
1040
|
+
},
|
|
1041
|
+
);
|
|
1042
|
+
};
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
var value = Reflect.get(utilsTarget, utilsProp, utilsTarget);
|
|
1046
|
+
return typeof value === "function" ? value.bind(utilsTarget) : value;
|
|
1047
|
+
},
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
var value = Reflect.get(target, prop, target);
|
|
1051
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
1052
|
+
},
|
|
1053
|
+
});
|
|
1054
|
+
var __hfBaseHyperframes = window.__hyperframes;
|
|
1055
|
+
var __hfScopedHyperframes = ${SCOPED_HYPERFRAMES_EXPRESSION};
|
|
1056
|
+
var __hfRun = function() {
|
|
1057
|
+
try {
|
|
1058
|
+
(function(document, gsap, window, __hyperframes) {
|
|
1059
|
+
${source.replace(/<\/(script)/gi, "<\\/$1")}
|
|
1060
|
+
}).call(window, __hfScopedDocument, __hfScopedGsap, __hfScopedWindow, __hfScopedHyperframes);
|
|
1061
|
+
} catch (_err) {
|
|
1062
|
+
console.error(__hfErrorLabel, __hfCompId, _err);
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
// What the script started on the global gsap timeline, by any route, for a scene swap to revert.
|
|
1066
|
+
// Only a page with a scene manifest can swap; elsewhere the first script stores null and none records.
|
|
1067
|
+
var __hfRecordAnimations = function(run) {
|
|
1068
|
+
if (window.__hfSceneAnimations === undefined) {
|
|
1069
|
+
window.__hfSceneAnimations = window.document.querySelector(${jsonScriptLiteral(`meta[name="${SCENE_PARTS_META}"]`)})
|
|
1070
|
+
? {}
|
|
1071
|
+
: null;
|
|
1072
|
+
}
|
|
1073
|
+
var byComp = window.__hfSceneAnimations;
|
|
1074
|
+
var globalTimeline = __hfBaseGsap && __hfBaseGsap.globalTimeline;
|
|
1075
|
+
if (!byComp || !globalTimeline || !__hfTimelineCompId) return run();
|
|
1076
|
+
var before = globalTimeline.getChildren(false);
|
|
1077
|
+
// A set completes as it is made and would leave the timeline before the diff below.
|
|
1078
|
+
var autoRemove = globalTimeline.autoRemoveChildren;
|
|
1079
|
+
globalTimeline.autoRemoveChildren = false;
|
|
1080
|
+
run();
|
|
1081
|
+
globalTimeline.autoRemoveChildren = autoRemove;
|
|
1082
|
+
var recorded = (byComp[__hfTimelineCompId] = byComp[__hfTimelineCompId] || []);
|
|
1083
|
+
globalTimeline.getChildren(false).forEach(function(animation) {
|
|
1084
|
+
if (before.indexOf(animation) >= 0) return;
|
|
1085
|
+
recorded.push(animation);
|
|
1086
|
+
// Dropped as the timeline drops a finished tween (it keeps a paused one); moved back, a tween re-adds itself.
|
|
1087
|
+
if (autoRemove && !animation.getChildren && animation.totalProgress() === 1) globalTimeline.remove(animation);
|
|
1088
|
+
});
|
|
1089
|
+
};
|
|
1090
|
+
__hfFindRoot();
|
|
1091
|
+
window.__hfRenamedIdSelectorEntries = null;
|
|
1092
|
+
__hfInstallRenamedIdSelectorShim();
|
|
1093
|
+
__hfRecordAnimations(__hfRun);
|
|
1094
|
+
})();`;
|
|
1095
|
+
}
|
|
1096
|
+
function wrapInlineScriptWithErrorBoundary(source, errorLabel) {
|
|
1097
|
+
return `(function(){ try { Function(${jsonScriptLiteral(source)}).call(window); } catch (_err) { console.error(${jsonScriptLiteral(errorLabel)}, _err); } })();`;
|
|
1098
|
+
}
|
|
1099
|
+
function buildVariablesByCompScript(variablesByComp) {
|
|
1100
|
+
if (!variablesByComp || Object.keys(variablesByComp).length === 0)
|
|
1101
|
+
return null;
|
|
1102
|
+
const json = jsonScriptLiteral(variablesByComp);
|
|
1103
|
+
return `window.__hfVariablesByComp = Object.assign({}, window.__hfVariablesByComp || {}, ${json});`;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
// ../core/dist/compiler/staticGuard.js
|
|
1107
|
+
async function validateHyperframeHtmlContract(html) {
|
|
1108
|
+
const result = await lintHyperframeHtml(html);
|
|
1109
|
+
const missingKeys = result.findings.filter((finding) => finding.severity === "error").map((finding) => finding.message);
|
|
1110
|
+
if (missingKeys.length === 0) {
|
|
1111
|
+
return { isValid: true, missingKeys: [], failureReason: null };
|
|
1112
|
+
}
|
|
1113
|
+
const joined = missingKeys.join(" ").toLowerCase();
|
|
1114
|
+
let failureReason = "invalid_static_hyperframe_contract";
|
|
1115
|
+
if (joined.includes("data-composition-id")) {
|
|
1116
|
+
failureReason = "missing_composition_id";
|
|
1117
|
+
} else if (joined.includes("data-width") || joined.includes("data-height")) {
|
|
1118
|
+
failureReason = "missing_composition_dimensions";
|
|
1119
|
+
} else if (joined.includes("window.__timelines")) {
|
|
1120
|
+
failureReason = "missing_timeline_registry";
|
|
1121
|
+
} else if (joined.includes("script syntax")) {
|
|
1122
|
+
failureReason = "invalid_script_syntax";
|
|
1123
|
+
}
|
|
1124
|
+
return { isValid: false, missingKeys, failureReason };
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// ../core/dist/compiler/svgIdNamespacing.js
|
|
1128
|
+
import postcss2 from "postcss";
|
|
1129
|
+
var ID_ATTR = "id";
|
|
1130
|
+
var SVG_AUTHORED_ID_ATTR = "data-hf-authored-id";
|
|
1131
|
+
var URL_HASH_REF_RE = /(url\(\s*)(["']?)#([^"')\s]+)\2(\s*\))/gi;
|
|
1132
|
+
function isHrefAttrName(name) {
|
|
1133
|
+
return name === "href" || name.endsWith(":href");
|
|
1134
|
+
}
|
|
1135
|
+
function sanitizeNamespaceSegment(value) {
|
|
1136
|
+
return value.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
1137
|
+
}
|
|
1138
|
+
function rewriteUrlHashRefs(value, idMap) {
|
|
1139
|
+
if (!value || !value.toLowerCase().includes("url("))
|
|
1140
|
+
return value;
|
|
1141
|
+
return value.replace(URL_HASH_REF_RE, (full, pre, quote, id, post) => {
|
|
1142
|
+
const mapped = idMap.get(id);
|
|
1143
|
+
return mapped ? `${pre}${quote}#${mapped}${quote}${post}` : full;
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
function rewriteHrefValue(value, idMap) {
|
|
1147
|
+
if (!value.startsWith("#"))
|
|
1148
|
+
return null;
|
|
1149
|
+
const mapped = idMap.get(value.slice(1));
|
|
1150
|
+
return mapped ? `#${mapped}` : null;
|
|
1151
|
+
}
|
|
1152
|
+
function rewriteElementIdReferences(el, idMap) {
|
|
1153
|
+
const attrs = el.attributes ? Array.from(el.attributes) : [];
|
|
1154
|
+
for (const attr of attrs) {
|
|
1155
|
+
const { name, value } = attr;
|
|
1156
|
+
if (!value)
|
|
1157
|
+
continue;
|
|
1158
|
+
if (isHrefAttrName(name)) {
|
|
1159
|
+
const rewritten = rewriteHrefValue(value, idMap);
|
|
1160
|
+
if (rewritten) {
|
|
1161
|
+
el.setAttribute(name, rewritten);
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
if (value.toLowerCase().includes("url(")) {
|
|
1166
|
+
const rewritten = rewriteUrlHashRefs(value, idMap);
|
|
1167
|
+
if (rewritten !== value)
|
|
1168
|
+
el.setAttribute(name, rewritten);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
function collectUrlHashRefsFromText(text, filter, out) {
|
|
1173
|
+
let m;
|
|
1174
|
+
URL_HASH_REF_RE.lastIndex = 0;
|
|
1175
|
+
while (m = URL_HASH_REF_RE.exec(text)) {
|
|
1176
|
+
const refId = m[3];
|
|
1177
|
+
if (filter.has(refId))
|
|
1178
|
+
out.add(refId);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
function collectHrefFragmentRef(attr, filter, out) {
|
|
1182
|
+
if (isHrefAttrName(attr.name) && attr.value.startsWith("#")) {
|
|
1183
|
+
const id = attr.value.slice(1);
|
|
1184
|
+
if (filter.has(id))
|
|
1185
|
+
out.add(id);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
function collectNativelyReferencedIds(elements, cssTexts, svgIds) {
|
|
1189
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
1190
|
+
for (const el of elements) {
|
|
1191
|
+
for (const attr of el.attributes ? Array.from(el.attributes) : []) {
|
|
1192
|
+
if (!attr.value)
|
|
1193
|
+
continue;
|
|
1194
|
+
collectHrefFragmentRef(attr, svgIds, referenced);
|
|
1195
|
+
if (attr.value.toLowerCase().includes("url("))
|
|
1196
|
+
collectUrlHashRefsFromText(attr.value, svgIds, referenced);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
for (const text of cssTexts) {
|
|
1200
|
+
if (text.toLowerCase().includes("url("))
|
|
1201
|
+
collectUrlHashRefsFromText(text, svgIds, referenced);
|
|
1202
|
+
}
|
|
1203
|
+
return referenced;
|
|
1204
|
+
}
|
|
1205
|
+
function isExcluded(el, exclude) {
|
|
1206
|
+
return exclude.some((excluded) => excluded === el || excluded.contains(el));
|
|
1207
|
+
}
|
|
1208
|
+
function collectScopeElements(scope) {
|
|
1209
|
+
const exclude = scope.exclude ?? [];
|
|
1210
|
+
const descendants = [...scope.root.querySelectorAll("*")];
|
|
1211
|
+
const own = exclude.length ? descendants.filter((el) => !isExcluded(el, exclude)) : descendants;
|
|
1212
|
+
return [scope.root, ...own];
|
|
1213
|
+
}
|
|
1214
|
+
function collectSvgIdElements(scope) {
|
|
1215
|
+
const exclude = scope.exclude ?? [];
|
|
1216
|
+
const matches = [...scope.root.querySelectorAll("svg [id], svg[id]")];
|
|
1217
|
+
return exclude.length ? matches.filter((el) => !isExcluded(el, exclude)) : matches;
|
|
1218
|
+
}
|
|
1219
|
+
function resolveScope(scope) {
|
|
1220
|
+
const elements = collectScopeElements(scope);
|
|
1221
|
+
const renamable = /* @__PURE__ */ new Set();
|
|
1222
|
+
if (!scope.namespace)
|
|
1223
|
+
return { elements, renamable };
|
|
1224
|
+
const svgIdElements = collectSvgIdElements(scope);
|
|
1225
|
+
const svgIds = /* @__PURE__ */ new Set();
|
|
1226
|
+
for (const el of svgIdElements) {
|
|
1227
|
+
const id = el.getAttribute(ID_ATTR);
|
|
1228
|
+
if (id)
|
|
1229
|
+
svgIds.add(id);
|
|
1230
|
+
}
|
|
1231
|
+
if (svgIds.size === 0)
|
|
1232
|
+
return { elements, renamable };
|
|
1233
|
+
const nativelyReferenced = collectNativelyReferencedIds(elements, scope.cssTexts ?? [], svgIds);
|
|
1234
|
+
for (const el of svgIdElements) {
|
|
1235
|
+
const id = el.getAttribute(ID_ATTR);
|
|
1236
|
+
if (id && nativelyReferenced.has(id))
|
|
1237
|
+
renamable.add(el);
|
|
1238
|
+
}
|
|
1239
|
+
return { elements, renamable };
|
|
1240
|
+
}
|
|
1241
|
+
function buildIdCensus(document) {
|
|
1242
|
+
const elementsById = /* @__PURE__ */ new Map();
|
|
1243
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
1244
|
+
for (const el of document.querySelectorAll("[id]")) {
|
|
1245
|
+
const id = el.getAttribute(ID_ATTR);
|
|
1246
|
+
if (!id)
|
|
1247
|
+
continue;
|
|
1248
|
+
usedIds.add(id);
|
|
1249
|
+
const list = elementsById.get(id);
|
|
1250
|
+
if (list)
|
|
1251
|
+
list.push(el);
|
|
1252
|
+
else
|
|
1253
|
+
elementsById.set(id, [el]);
|
|
1254
|
+
}
|
|
1255
|
+
return { elementsById, usedIds };
|
|
1256
|
+
}
|
|
1257
|
+
function hasAnyCollision(census) {
|
|
1258
|
+
for (const elements of census.elementsById.values()) {
|
|
1259
|
+
if (elements.length > 1)
|
|
1260
|
+
return true;
|
|
1261
|
+
}
|
|
1262
|
+
return false;
|
|
1263
|
+
}
|
|
1264
|
+
function mintNamespacedId(namespace, originalId, usedIds) {
|
|
1265
|
+
const base = `${sanitizeNamespaceSegment(namespace)}--${originalId}`;
|
|
1266
|
+
let candidate = base;
|
|
1267
|
+
for (let n = 2; usedIds.has(candidate); n += 1)
|
|
1268
|
+
candidate = `${base}-${n}`;
|
|
1269
|
+
usedIds.add(candidate);
|
|
1270
|
+
return candidate;
|
|
1271
|
+
}
|
|
1272
|
+
function planRenames(census, scopes, scopeIndexByRenamable) {
|
|
1273
|
+
const idMaps = scopes.map(() => /* @__PURE__ */ new Map());
|
|
1274
|
+
for (const [id, elements] of census.elementsById) {
|
|
1275
|
+
if (elements.length < 2)
|
|
1276
|
+
continue;
|
|
1277
|
+
const keeper = elements.find((el) => !scopeIndexByRenamable.has(el)) ?? elements[0];
|
|
1278
|
+
for (const el of elements) {
|
|
1279
|
+
if (el === keeper)
|
|
1280
|
+
continue;
|
|
1281
|
+
const scopeIndex = scopeIndexByRenamable.get(el);
|
|
1282
|
+
if (scopeIndex === void 0)
|
|
1283
|
+
continue;
|
|
1284
|
+
const idMap = idMaps[scopeIndex];
|
|
1285
|
+
if (!idMap.has(id)) {
|
|
1286
|
+
idMap.set(id, mintNamespacedId(scopes[scopeIndex].namespace, id, census.usedIds));
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
return idMaps;
|
|
1291
|
+
}
|
|
1292
|
+
function applyRenames(resolved, idMap) {
|
|
1293
|
+
for (const el of resolved.elements) {
|
|
1294
|
+
const currentId = el.getAttribute(ID_ATTR);
|
|
1295
|
+
if (currentId && resolved.renamable.has(el) && idMap.has(currentId)) {
|
|
1296
|
+
if (!el.hasAttribute(SVG_AUTHORED_ID_ATTR))
|
|
1297
|
+
el.setAttribute(SVG_AUTHORED_ID_ATTR, currentId);
|
|
1298
|
+
el.setAttribute(ID_ATTR, idMap.get(currentId));
|
|
1299
|
+
}
|
|
1300
|
+
rewriteElementIdReferences(el, idMap);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
function namespaceCollidingSvgIds(document, scopes) {
|
|
1304
|
+
const untouched = scopes.map(() => /* @__PURE__ */ new Map());
|
|
1305
|
+
if (scopes.length === 0)
|
|
1306
|
+
return untouched;
|
|
1307
|
+
const census = buildIdCensus(document);
|
|
1308
|
+
if (!hasAnyCollision(census))
|
|
1309
|
+
return untouched;
|
|
1310
|
+
const resolved = scopes.map(resolveScope);
|
|
1311
|
+
const scopeIndexByRenamable = /* @__PURE__ */ new Map();
|
|
1312
|
+
resolved.forEach(({ renamable }, index) => {
|
|
1313
|
+
for (const el of renamable)
|
|
1314
|
+
scopeIndexByRenamable.set(el, index);
|
|
1315
|
+
});
|
|
1316
|
+
if (scopeIndexByRenamable.size === 0)
|
|
1317
|
+
return untouched;
|
|
1318
|
+
const idMaps = planRenames(census, scopes, scopeIndexByRenamable);
|
|
1319
|
+
const referenceMaps = resolved.map((scope, index) => {
|
|
1320
|
+
const references = new Map(idMaps[index]);
|
|
1321
|
+
const localIds = new Set(scope.elements.map((el) => el.getAttribute(ID_ATTR)));
|
|
1322
|
+
for (const [id, elements] of census.elementsById) {
|
|
1323
|
+
if (localIds.has(id))
|
|
1324
|
+
continue;
|
|
1325
|
+
const targetScope = scopeIndexByRenamable.get(elements[0]);
|
|
1326
|
+
if (targetScope === void 0)
|
|
1327
|
+
continue;
|
|
1328
|
+
const mapped = idMaps[targetScope].get(id);
|
|
1329
|
+
if (mapped)
|
|
1330
|
+
references.set(id, mapped);
|
|
1331
|
+
}
|
|
1332
|
+
return references;
|
|
1333
|
+
});
|
|
1334
|
+
referenceMaps.forEach((idMap, index) => {
|
|
1335
|
+
if (idMap.size > 0)
|
|
1336
|
+
applyRenames(resolved[index], idMap);
|
|
1337
|
+
});
|
|
1338
|
+
return referenceMaps;
|
|
1339
|
+
}
|
|
1340
|
+
function renameIdTokensInSelector(selector, idMap) {
|
|
1341
|
+
return replaceSelectorIdTokens(selector, [...idMap.keys()], (matchedId) => `#${escapeCssIdentifier(idMap.get(matchedId))}`);
|
|
1342
|
+
}
|
|
1343
|
+
function rewriteSvgIdReferencesInCss(css, idMap) {
|
|
1344
|
+
if (!css || idMap.size === 0)
|
|
1345
|
+
return css;
|
|
1346
|
+
if (!css.includes("#") && !css.toLowerCase().includes("url("))
|
|
1347
|
+
return css;
|
|
1348
|
+
let root;
|
|
1349
|
+
try {
|
|
1350
|
+
root = postcss2.parse(css);
|
|
1351
|
+
} catch {
|
|
1352
|
+
return css;
|
|
1353
|
+
}
|
|
1354
|
+
let mutated = false;
|
|
1355
|
+
root.walkRules((rule) => {
|
|
1356
|
+
const rewritten = rule.selectors.map((selector) => renameIdTokensInSelector(selector, idMap));
|
|
1357
|
+
if (rewritten.some((selector, index) => selector !== rule.selectors[index])) {
|
|
1358
|
+
rule.selectors = rewritten;
|
|
1359
|
+
mutated = true;
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
root.walkDecls((decl) => {
|
|
1363
|
+
const rewritten = rewriteUrlHashRefs(decl.value, idMap);
|
|
1364
|
+
if (rewritten !== decl.value) {
|
|
1365
|
+
decl.value = rewritten;
|
|
1366
|
+
mutated = true;
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
root.walkAtRules((atRule) => {
|
|
1370
|
+
if (!atRule.params)
|
|
1371
|
+
return;
|
|
1372
|
+
const rewritten = rewriteUrlHashRefs(atRule.params, idMap);
|
|
1373
|
+
if (rewritten !== atRule.params) {
|
|
1374
|
+
atRule.params = rewritten;
|
|
1375
|
+
mutated = true;
|
|
1376
|
+
}
|
|
1377
|
+
});
|
|
1378
|
+
return mutated ? root.toResult({ map: false }).css : css;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
// ../core/dist/compiler/compositionAssembly.js
|
|
1382
|
+
var COMPOSITION_ID_ATTR = "data-composition-id";
|
|
1383
|
+
var COMPOSITION_SRC_ATTR = "data-composition-src";
|
|
1384
|
+
var COMPOSITION_ROOT_SELECTOR = `[${COMPOSITION_ID_ATTR}]`;
|
|
1385
|
+
var COMPOSITION_HOST_SELECTOR = `[${COMPOSITION_SRC_ATTR}]`;
|
|
1386
|
+
var STYLE_SELECTOR = "style";
|
|
1387
|
+
var SCRIPT_SELECTOR = "script";
|
|
1388
|
+
var HOISTED_LINK_SELECTOR = 'link[rel="stylesheet"], link[rel="preconnect"]';
|
|
1389
|
+
var EXTRACTED_COMPOSITION_ASSET_SELECTOR = `${STYLE_SELECTOR}, ${SCRIPT_SELECTOR}, ${HOISTED_LINK_SELECTOR}`;
|
|
1390
|
+
var MAX_SUB_COMPOSITION_DEPTH = 20;
|
|
1391
|
+
function toArray(items) {
|
|
1392
|
+
return items ? Array.from(items) : [];
|
|
1393
|
+
}
|
|
1394
|
+
function planCompositionAssembly(input) {
|
|
1395
|
+
const { contentNode, head, documentElement, hasTemplate, compositionId } = input;
|
|
1396
|
+
const compositionRoots = toArray(contentNode.querySelectorAll(COMPOSITION_ROOT_SELECTOR));
|
|
1397
|
+
const innerRoot = compositionId ? compositionRoots.find((root) => root.getAttribute(COMPOSITION_ID_ATTR) === compositionId) ?? null : compositionRoots[0] ?? null;
|
|
1398
|
+
const declaredCompositionId = (innerRoot ?? compositionRoots[0])?.getAttribute(COMPOSITION_ID_ATTR)?.trim() || "";
|
|
1399
|
+
const assetHead = hasTemplate ? null : head ?? null;
|
|
1400
|
+
return {
|
|
1401
|
+
innerRoot,
|
|
1402
|
+
authoredCompositionId: compositionId || declaredCompositionId || null,
|
|
1403
|
+
scriptCompositionId: declaredCompositionId || compositionId || null,
|
|
1404
|
+
authoredRootId: innerRoot?.getAttribute("id")?.trim() || null,
|
|
1405
|
+
styleSources: [
|
|
1406
|
+
...toArray(assetHead?.querySelectorAll(STYLE_SELECTOR)),
|
|
1407
|
+
...toArray(contentNode.querySelectorAll(STYLE_SELECTOR))
|
|
1408
|
+
],
|
|
1409
|
+
scriptSources: [
|
|
1410
|
+
...toArray(assetHead?.querySelectorAll(SCRIPT_SELECTOR)),
|
|
1411
|
+
...toArray(contentNode.querySelectorAll(SCRIPT_SELECTOR))
|
|
1412
|
+
],
|
|
1413
|
+
linkSources: [
|
|
1414
|
+
...toArray(head?.querySelectorAll(HOISTED_LINK_SELECTOR)),
|
|
1415
|
+
...toArray(contentNode.querySelectorAll(HOISTED_LINK_SELECTOR))
|
|
1416
|
+
],
|
|
1417
|
+
variableDefaultCarriers: [documentElement, innerRoot].filter((carrier) => carrier != null)
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
function enumerateNestedCompositionHosts(assembledHost, ancestry) {
|
|
1421
|
+
const hosts = [];
|
|
1422
|
+
const skipped = [];
|
|
1423
|
+
for (const nestedHost of assembledHost.querySelectorAll(COMPOSITION_HOST_SELECTOR)) {
|
|
1424
|
+
const src = nestedHost.getAttribute(COMPOSITION_SRC_ATTR);
|
|
1425
|
+
if (!src)
|
|
1426
|
+
continue;
|
|
1427
|
+
if (ancestry.includes(src)) {
|
|
1428
|
+
skipped.push({ src, reason: "circular composition reference" });
|
|
1429
|
+
continue;
|
|
1430
|
+
}
|
|
1431
|
+
if (ancestry.length >= MAX_SUB_COMPOSITION_DEPTH) {
|
|
1432
|
+
skipped.push({ src, reason: "nesting depth exceeded" });
|
|
1433
|
+
continue;
|
|
1434
|
+
}
|
|
1435
|
+
hosts.push({ host: nestedHost, src });
|
|
1436
|
+
}
|
|
1437
|
+
return { hosts, skipped };
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
// ../core/dist/compiler/inlineSubCompositions.js
|
|
1441
|
+
var SIDE_EFFECT_RE = /\b(addEventListener|requestAnimationFrame|requestIdleCallback|setTimeout|setInterval|queueMicrotask|getContext|WebGL\w*|WebGPU\w*|gpu|Worker|WebSocket|EventSource|Audio\w*|\w*Observer|fetch|import|eval|Function|Promise|async|await|delayedCall|ScrollTrigger|Draggable|anime|customElements|registerProperty|addListener|BroadcastChannel|pushState|replaceState|adoptedStyleSheets|documentElement|getElementsByTagName|lottie|THREE|__hf[A-Z]\w*)\b|\.then\s*\(|\.animate\s*\(|\.ticker\b|repeat\s*:\s*-1|\.repeat\s*\(\s*-1|defineProperty\s*\(\s*(window|globalThis|self|document)\b|\bfonts\s*\.\s*add\b|\.on[a-z]+\s*=(?!=)|\bon(resize|scroll|message|key\w+|click|pointer\w+|mouse\w+|wheel|visibilitychange|hashchange|popstate|error|load)\s*=(?!=)|\[\s*["']on[a-z]+["']\s*\]|document\s*\.\s*(head|body)\b|querySelector(All)?\(\s*["'](head|body)["']|\bgsap\s*\.\s*(?:to|from|fromTo)\s*\(|\bgsap\s*\.\s*timeline\s*\((?:[^()]|\([^()]*\))*\)\s*\.\s*(?:to|from|fromTo|set|add|call)\s*\(/;
|
|
1442
|
+
var SWAP_SAFE_LIBRARY_URL = /^https:\/\/(cdn\.jsdelivr\.net\/npm|unpkg\.com)\/(gsap|three|d3|d3-[a-z-]+|topojson-client|clipper-lib)(@[^/]+)?\//;
|
|
1443
|
+
var isSwapSafeLibrary = (src) => URL.canParse(src) && SWAP_SAFE_LIBRARY_URL.test(new URL(src).href);
|
|
1444
|
+
function sceneScriptSwapRefusal(script) {
|
|
1445
|
+
const match = SIDE_EFFECT_RE.exec(script);
|
|
1446
|
+
return match ? `its script uses ${match[0].trim()}` : null;
|
|
1447
|
+
}
|
|
1448
|
+
var STRING_LITERAL_RE = /(["'`])((?:\\.|(?!\1)[^\\\n])*?)\1/g;
|
|
1449
|
+
var CREATES_ELEMENT_RE = /createElement\s*\(\s*$|createElementNS\s*\([^()]*,\s*$/;
|
|
1450
|
+
var isNotASelector = (script, at, literal) => CREATES_ELEMENT_RE.test(script.slice(Math.max(0, at - 60), at)) || literal.trim() === "*" && /,\s*$/.test(script.slice(Math.max(0, at - 20), at));
|
|
1451
|
+
function refuseSwapsReachedByRootScripts(document, rootScripts) {
|
|
1452
|
+
const hosts = [...document.querySelectorAll(`[${SCENE_PART_ATTR}]`)];
|
|
1453
|
+
const byName = /* @__PURE__ */ new Map();
|
|
1454
|
+
for (const host of hosts) {
|
|
1455
|
+
for (const el of [host, ...host.querySelectorAll("*")]) {
|
|
1456
|
+
for (const name of [
|
|
1457
|
+
el.localName,
|
|
1458
|
+
el.id && `#${el.id}`,
|
|
1459
|
+
...[...el.classList].map((c) => `.${c}`)
|
|
1460
|
+
]) {
|
|
1461
|
+
if (name)
|
|
1462
|
+
byName.set(name, (byName.get(name) ?? /* @__PURE__ */ new Set()).add(host));
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
const namesKnown = (selector) => selector.split(",").some((alt) => alt.split(/[\s>+~]+/).every((part) => !/^[a-z][\w-]*$/i.test(part) || byName.has(part.toLowerCase()) || document.querySelector(part) !== null));
|
|
1467
|
+
const literals = new Set(rootScripts.flatMap((s) => [...s.matchAll(STRING_LITERAL_RE)].filter((m) => !isNotASelector(s, m.index, m[2] ?? "")).map((m) => m[2] ?? "")));
|
|
1468
|
+
for (const literal of literals) {
|
|
1469
|
+
const open = hosts.filter((host) => !host.hasAttribute(SCENE_NO_SWAP_ATTR));
|
|
1470
|
+
if (open.length === 0)
|
|
1471
|
+
return;
|
|
1472
|
+
const reached = literal.trim() === "*" ? open : /^[A-Za-z_][\w-]*$/.test(literal) ? [literal.toLowerCase(), `#${literal}`, `.${literal}`].flatMap((name) => [
|
|
1473
|
+
...byName.get(name) ?? []
|
|
1474
|
+
]) : /[#.[:>]|[\w\]*] *[\s,]+ *[\w*]/.test(literal) && literal.length <= 120 && namesKnown(literal) ? open.filter((host) => reaches(host, literal)) : [];
|
|
1475
|
+
for (const host of reached)
|
|
1476
|
+
if (!host.hasAttribute(SCENE_NO_SWAP_ATTR))
|
|
1477
|
+
host.setAttribute(SCENE_NO_SWAP_ATTR, `a script outside the scene selects ${literal}`);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
var reaches = (host, selector) => {
|
|
1481
|
+
try {
|
|
1482
|
+
return host.matches(selector) || host.querySelector(selector) !== null;
|
|
1483
|
+
} catch {
|
|
1484
|
+
return false;
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
function ensureExternalLinkTag(doc, link) {
|
|
1488
|
+
const el = doc.createElement("link");
|
|
1489
|
+
el.setAttribute("rel", link.rel);
|
|
1490
|
+
el.setAttribute("href", link.href);
|
|
1491
|
+
for (const name of ["crossorigin", "media", "title", "type"]) {
|
|
1492
|
+
const value = link[name];
|
|
1493
|
+
if (value != null)
|
|
1494
|
+
el.setAttribute(name, value);
|
|
1495
|
+
}
|
|
1496
|
+
if (link.disabled)
|
|
1497
|
+
el.setAttribute("disabled", "");
|
|
1498
|
+
if (!hasSameLink(doc, el))
|
|
1499
|
+
doc.head.appendChild(el);
|
|
1500
|
+
}
|
|
1501
|
+
function defaultBuildScopeSelector(compId) {
|
|
1502
|
+
const escaped = compId.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
1503
|
+
return `[data-composition-id="${escaped}"]`;
|
|
1504
|
+
}
|
|
1505
|
+
function inlineSubCompositions(document, hosts, options) {
|
|
1506
|
+
const { resolveHtml, parseHtml, hostIdentityMap, rewriteInlineStyles = false, flattenInnerRoot, compoundAuthoredRoot, readVariableDefaults, parseHostVariables, buildScopeSelector = defaultBuildScopeSelector, scriptErrorLabel = "[HyperFrames] composition script error:", onMissingComposition, assetExists, tagScenes = false } = options;
|
|
1507
|
+
const styles = [];
|
|
1508
|
+
const styleScenes = [];
|
|
1509
|
+
const scripts = [];
|
|
1510
|
+
const externalScriptSrcs = [];
|
|
1511
|
+
const scriptItems = [];
|
|
1512
|
+
const importMaps = [];
|
|
1513
|
+
const moduleScripts = [];
|
|
1514
|
+
const externalLinks = [];
|
|
1515
|
+
const variablesByComp = {};
|
|
1516
|
+
const svgIdScopes = [];
|
|
1517
|
+
const sceneHosts = /* @__PURE__ */ new Map();
|
|
1518
|
+
const queue = hosts.map((element) => ({
|
|
1519
|
+
element,
|
|
1520
|
+
ancestry: [],
|
|
1521
|
+
scene: void 0
|
|
1522
|
+
}));
|
|
1523
|
+
for (let queueIndex = 0; queueIndex < queue.length; queueIndex += 1) {
|
|
1524
|
+
const { element: hostEl, ancestry, scene: parentScene } = queue[queueIndex];
|
|
1525
|
+
const src = hostEl.getAttribute("data-composition-src");
|
|
1526
|
+
if (!src)
|
|
1527
|
+
continue;
|
|
1528
|
+
const compHtml = resolveHtml(src);
|
|
1529
|
+
const validity = checkSubCompositionUsability(compHtml, parseHtml);
|
|
1530
|
+
if (!validity.ok) {
|
|
1531
|
+
onMissingComposition?.(src, validity.detail);
|
|
1532
|
+
continue;
|
|
1533
|
+
}
|
|
1534
|
+
if (compHtml == null) {
|
|
1535
|
+
onMissingComposition?.(src);
|
|
1536
|
+
continue;
|
|
1537
|
+
}
|
|
1538
|
+
const compDoc = parseHtml(compHtml);
|
|
1539
|
+
let compId;
|
|
1540
|
+
let runtimeCompId;
|
|
1541
|
+
if (hostIdentityMap) {
|
|
1542
|
+
const identity = hostIdentityMap.get(hostEl);
|
|
1543
|
+
compId = identity?.authoredCompositionId || null;
|
|
1544
|
+
runtimeCompId = identity?.runtimeCompositionId || compId || "";
|
|
1545
|
+
} else {
|
|
1546
|
+
compId = hostEl.getAttribute("data-composition-id") || null;
|
|
1547
|
+
runtimeCompId = compId || "";
|
|
1548
|
+
}
|
|
1549
|
+
const { contentHtml, hasTemplate } = resolveSubCompositionContent(compHtml, compDoc);
|
|
1550
|
+
if (!contentHtml.trim()) {
|
|
1551
|
+
onMissingComposition?.(src);
|
|
1552
|
+
continue;
|
|
1553
|
+
}
|
|
1554
|
+
const contentDoc = parseHtml(contentHtml);
|
|
1555
|
+
if (!contentDoc.documentElement) {
|
|
1556
|
+
onMissingComposition?.(src);
|
|
1557
|
+
continue;
|
|
1558
|
+
}
|
|
1559
|
+
const plan = planCompositionAssembly({
|
|
1560
|
+
contentNode: contentDoc,
|
|
1561
|
+
head: compDoc.head,
|
|
1562
|
+
documentElement: compDoc.documentElement,
|
|
1563
|
+
hasTemplate,
|
|
1564
|
+
compositionId: compId
|
|
1565
|
+
});
|
|
1566
|
+
const innerRoot = plan.innerRoot;
|
|
1567
|
+
const authoredRootId = plan.authoredRootId;
|
|
1568
|
+
const scopeCompId = plan.authoredCompositionId || "";
|
|
1569
|
+
const scriptCompositionId = plan.scriptCompositionId || "";
|
|
1570
|
+
const runtimeScope = runtimeCompId ? buildScopeSelector(runtimeCompId) : "";
|
|
1571
|
+
const scene = tagScenes ? parentScene ?? (runtimeCompId || src) : void 0;
|
|
1572
|
+
if (scene && !parentScene) {
|
|
1573
|
+
hostEl.setAttribute(SCENE_PART_ATTR, scene);
|
|
1574
|
+
sceneHosts.set(scene, hostEl);
|
|
1575
|
+
}
|
|
1576
|
+
const refuseSwap = (why) => {
|
|
1577
|
+
const host = scene ? sceneHosts.get(scene) : void 0;
|
|
1578
|
+
if (!host || host.hasAttribute(SCENE_NO_SWAP_ATTR))
|
|
1579
|
+
return;
|
|
1580
|
+
const reason = why();
|
|
1581
|
+
if (reason)
|
|
1582
|
+
host.setAttribute(SCENE_NO_SWAP_ATTR, reason);
|
|
1583
|
+
};
|
|
1584
|
+
if (readVariableDefaults && parseHostVariables && runtimeCompId) {
|
|
1585
|
+
const mergedVariables = {};
|
|
1586
|
+
for (const carrier of plan.variableDefaultCarriers) {
|
|
1587
|
+
Object.assign(mergedVariables, readVariableDefaults(carrier));
|
|
1588
|
+
}
|
|
1589
|
+
Object.assign(mergedVariables, parseHostVariables(hostEl));
|
|
1590
|
+
if (Object.keys(mergedVariables).length > 0) {
|
|
1591
|
+
variablesByComp[runtimeCompId] = mergedVariables;
|
|
1592
|
+
}
|
|
1593
|
+
warnUnknownEnumValues(compDoc.documentElement, mergedVariables, runtimeCompId);
|
|
1594
|
+
warnUnknownEnumValues(innerRoot, mergedVariables, runtimeCompId);
|
|
1595
|
+
}
|
|
1596
|
+
const resolveSubAssetPath = (raw) => rewriteAssetPath(src, (raw || "").trim(), assetExists);
|
|
1597
|
+
const scopeSubStyle = (raw) => {
|
|
1598
|
+
const css = rewriteCssAssetUrls(raw, src, assetExists);
|
|
1599
|
+
return scopeCompId ? scopeCssToComposition(css, scopeCompId, runtimeScope || void 0, authoredRootId, {
|
|
1600
|
+
compoundAuthoredRoot: compoundAuthoredRoot === true,
|
|
1601
|
+
scopeRootSelectors: true
|
|
1602
|
+
}) : css;
|
|
1603
|
+
};
|
|
1604
|
+
for (const link of plan.linkSources) {
|
|
1605
|
+
const href = resolveSubAssetPath(link.getAttribute("href"));
|
|
1606
|
+
if (href) {
|
|
1607
|
+
const rel = (link.getAttribute("rel") || "").trim();
|
|
1608
|
+
const crossorigin = link.hasAttribute("crossorigin") ? link.getAttribute("crossorigin") || "" : void 0;
|
|
1609
|
+
const media = link.getAttribute("media") ?? void 0;
|
|
1610
|
+
const title = link.getAttribute("title") ?? void 0;
|
|
1611
|
+
const type = link.getAttribute("type") ?? void 0;
|
|
1612
|
+
const disabled = link.hasAttribute("disabled") ? true : void 0;
|
|
1613
|
+
externalLinks.push({ href, rel, crossorigin, media, title, type, disabled });
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
const styleStart = styles.length;
|
|
1617
|
+
for (const styleEl of plan.styleSources) {
|
|
1618
|
+
if (cssStyleMergeKey(styleEl) === void 0)
|
|
1619
|
+
continue;
|
|
1620
|
+
styles.push(compositionStyle(styleEl, scopeSubStyle(styleEl.textContent || "")));
|
|
1621
|
+
if (scene)
|
|
1622
|
+
styleScenes.push(scene);
|
|
1623
|
+
styleEl.remove();
|
|
1624
|
+
}
|
|
1625
|
+
const styleEnd = styles.length;
|
|
1626
|
+
for (const scriptEl of plan.scriptSources) {
|
|
1627
|
+
const externalSrc = resolveSubAssetPath(scriptEl.getAttribute("src"));
|
|
1628
|
+
const type = (scriptEl.getAttribute("type") || "").trim().toLowerCase();
|
|
1629
|
+
refuseSwap(() => type === "importmap" || type === "module" ? "it runs a module script or import map" : !externalSrc ? sceneScriptSwapRefusal(scriptEl.textContent || "") : isSwapSafeLibrary(externalSrc) ? null : "it runs a script that is not a known library");
|
|
1630
|
+
if (type === "importmap") {
|
|
1631
|
+
const map = parseImportMap(scriptEl.textContent || "", (url) => {
|
|
1632
|
+
const authored = url.trim();
|
|
1633
|
+
const rebased = resolveSubAssetPath(authored);
|
|
1634
|
+
if (rebased === authored)
|
|
1635
|
+
return rebased;
|
|
1636
|
+
const urlLike = /^(\/|\.\.?\/|[a-z][a-z\d+.-]*:)/i.test(rebased) ? rebased : `./${rebased}`;
|
|
1637
|
+
return authored.endsWith("/") && !urlLike.endsWith("/") ? `${urlLike}/` : urlLike;
|
|
1638
|
+
});
|
|
1639
|
+
if (map)
|
|
1640
|
+
importMaps.push(map);
|
|
1641
|
+
else
|
|
1642
|
+
console.warn(`[HyperFrames] ${src}: import map is not valid JSON, so it is skipped.`);
|
|
1643
|
+
} else if (type === "module" && !externalSrc) {
|
|
1644
|
+
const prelude = scriptCompositionId ? scopedModulePrelude(runtimeCompId || scopeCompId || scriptCompositionId, src) : "";
|
|
1645
|
+
moduleScripts.push(prelude + (scriptEl.textContent || ""));
|
|
1646
|
+
} else if (externalSrc) {
|
|
1647
|
+
if (!externalScriptSrcs.includes(externalSrc)) {
|
|
1648
|
+
externalScriptSrcs.push(externalSrc);
|
|
1649
|
+
}
|
|
1650
|
+
scriptItems.push({
|
|
1651
|
+
kind: "external",
|
|
1652
|
+
src: externalSrc,
|
|
1653
|
+
...readExternalScriptAttributes(scriptEl),
|
|
1654
|
+
...scene ? { scene } : {}
|
|
1655
|
+
});
|
|
1656
|
+
} else {
|
|
1657
|
+
const wrappedScript = scriptCompositionId ? wrapScopedCompositionScript(scriptEl.textContent || "", scriptCompositionId, scriptErrorLabel, runtimeScope || void 0, runtimeCompId || scopeCompId || scriptCompositionId, authoredRootId, src) : wrapInlineScriptWithErrorBoundary(scriptEl.textContent || "", scriptErrorLabel);
|
|
1658
|
+
scripts.push(wrappedScript);
|
|
1659
|
+
scriptItems.push({ kind: "inline", content: wrappedScript, ...scene ? { scene } : {} });
|
|
1660
|
+
}
|
|
1661
|
+
scriptEl.remove();
|
|
1662
|
+
}
|
|
1663
|
+
const assetEls = innerRoot ? innerRoot.querySelectorAll("[src], [href]") : contentDoc.querySelectorAll("[src], [href]");
|
|
1664
|
+
rewriteAssetPaths(assetEls, src, (el, attr) => el.getAttribute(attr), (el, attr, val) => {
|
|
1665
|
+
el.setAttribute(attr, val);
|
|
1666
|
+
}, assetExists);
|
|
1667
|
+
if (rewriteInlineStyles) {
|
|
1668
|
+
const styledEls = innerRoot ? innerRoot.querySelectorAll("[style]") : contentDoc.querySelectorAll("[style]");
|
|
1669
|
+
rewriteInlineStyleAssetUrls(styledEls, src, (el) => el.getAttribute("style"), (el, val) => {
|
|
1670
|
+
el.setAttribute("style", val);
|
|
1671
|
+
}, assetExists);
|
|
1672
|
+
}
|
|
1673
|
+
if (innerRoot?.hasAttribute("data-timeline-locked")) {
|
|
1674
|
+
hostEl.setAttribute("data-timeline-locked", "");
|
|
1675
|
+
}
|
|
1676
|
+
if (innerRoot) {
|
|
1677
|
+
const innerW = innerRoot.getAttribute("data-width");
|
|
1678
|
+
const innerH = innerRoot.getAttribute("data-height");
|
|
1679
|
+
if (innerW && !hostEl.getAttribute("data-width"))
|
|
1680
|
+
hostEl.setAttribute("data-width", innerW);
|
|
1681
|
+
if (innerH && !hostEl.getAttribute("data-height")) {
|
|
1682
|
+
hostEl.setAttribute("data-height", innerH);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
if (innerRoot) {
|
|
1686
|
+
innerRoot.setAttribute("data-composition-file", src);
|
|
1687
|
+
for (const child of [...innerRoot.querySelectorAll(EXTRACTED_COMPOSITION_ASSET_SELECTOR)])
|
|
1688
|
+
child.remove();
|
|
1689
|
+
if (flattenInnerRoot) {
|
|
1690
|
+
const prepared = flattenInnerRoot(innerRoot);
|
|
1691
|
+
if (!compId && scopeCompId) {
|
|
1692
|
+
prepared.setAttribute("data-composition-id", scopeCompId);
|
|
1693
|
+
}
|
|
1694
|
+
hostEl.innerHTML = prepared.outerHTML || "";
|
|
1695
|
+
} else {
|
|
1696
|
+
hostEl.innerHTML = compId ? innerRoot.innerHTML || "" : innerRoot.outerHTML || "";
|
|
1697
|
+
if (compId && authoredRootId) {
|
|
1698
|
+
hostEl.setAttribute("data-hf-authored-id", authoredRootId);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
} else {
|
|
1702
|
+
for (const child of [...contentDoc.querySelectorAll(EXTRACTED_COMPOSITION_ASSET_SELECTOR)])
|
|
1703
|
+
child.remove();
|
|
1704
|
+
const bodyHtml = contentDoc.body?.innerHTML || "";
|
|
1705
|
+
hostEl.innerHTML = bodyHtml || contentDoc.documentElement?.outerHTML || "";
|
|
1706
|
+
}
|
|
1707
|
+
hostEl.setAttribute("data-composition-file", src);
|
|
1708
|
+
hostEl.removeAttribute("data-composition-src");
|
|
1709
|
+
const nestedAncestry = [...ancestry, src];
|
|
1710
|
+
const nested = enumerateNestedCompositionHosts(hostEl, nestedAncestry);
|
|
1711
|
+
for (const skipped of nested.skipped) {
|
|
1712
|
+
onMissingComposition?.(skipped.src, skipped.reason);
|
|
1713
|
+
}
|
|
1714
|
+
for (const nestedHost of nested.hosts) {
|
|
1715
|
+
queue.push({ element: nestedHost.host, ancestry: nestedAncestry, scene });
|
|
1716
|
+
}
|
|
1717
|
+
svgIdScopes.push({
|
|
1718
|
+
root: hostEl,
|
|
1719
|
+
namespace: runtimeCompId || scopeCompId,
|
|
1720
|
+
exclude: nested.hosts.map((nestedHost) => nestedHost.host),
|
|
1721
|
+
styleStart,
|
|
1722
|
+
styleEnd
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
const svgIdMaps = namespaceCollidingSvgIds(document, svgIdScopes.map(({ root, namespace, exclude, styleStart, styleEnd }) => ({
|
|
1726
|
+
root,
|
|
1727
|
+
namespace,
|
|
1728
|
+
exclude,
|
|
1729
|
+
cssTexts: styles.slice(styleStart, styleEnd).map((style) => style.css)
|
|
1730
|
+
})));
|
|
1731
|
+
svgIdMaps.forEach((idMap, index) => {
|
|
1732
|
+
if (idMap.size === 0)
|
|
1733
|
+
return;
|
|
1734
|
+
const { styleStart, styleEnd } = svgIdScopes[index];
|
|
1735
|
+
for (let i = styleStart; i < styleEnd; i += 1) {
|
|
1736
|
+
styles[i].css = rewriteSvgIdReferencesInCss(styles[i].css, idMap);
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
return {
|
|
1740
|
+
styles,
|
|
1741
|
+
styleScenes,
|
|
1742
|
+
scripts,
|
|
1743
|
+
externalScriptSrcs,
|
|
1744
|
+
scriptItems,
|
|
1745
|
+
externalLinks,
|
|
1746
|
+
variablesByComp,
|
|
1747
|
+
importMaps,
|
|
1748
|
+
moduleScripts
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
// ../parsers/dist/hfIds.js
|
|
1753
|
+
var EXCLUDED_TAGS = /* @__PURE__ */ new Set([
|
|
1754
|
+
"script",
|
|
1755
|
+
"style",
|
|
1756
|
+
"template",
|
|
1757
|
+
"meta",
|
|
1758
|
+
"link",
|
|
1759
|
+
"noscript",
|
|
1760
|
+
"base"
|
|
1761
|
+
]);
|
|
1762
|
+
function fnv1a(str) {
|
|
1763
|
+
let h = 2166136261;
|
|
1764
|
+
for (let i = 0; i < str.length; i++) {
|
|
1765
|
+
h ^= str.charCodeAt(i);
|
|
1766
|
+
h = Math.imul(h, 16777619);
|
|
1767
|
+
}
|
|
1768
|
+
return h >>> 0;
|
|
1769
|
+
}
|
|
1770
|
+
function toHfId(hash2) {
|
|
1771
|
+
const s = (hash2 >>> 0).toString(36);
|
|
1772
|
+
const four = s.length >= 4 ? s.slice(-4) : s.padStart(4, "0");
|
|
1773
|
+
return `hf-${four}`;
|
|
1774
|
+
}
|
|
1775
|
+
function ownText(el) {
|
|
1776
|
+
let text = "";
|
|
1777
|
+
el.childNodes.forEach((n) => {
|
|
1778
|
+
if (n.nodeType === 3) text += n.nodeValue ?? "";
|
|
1779
|
+
});
|
|
1780
|
+
return text.trim();
|
|
1781
|
+
}
|
|
1782
|
+
function getContractAttribute(el, name) {
|
|
1783
|
+
return Array.from(el.attributes).find((attr) => attr.name.toLowerCase() === name)?.value ?? null;
|
|
1784
|
+
}
|
|
1785
|
+
function contentKey(el) {
|
|
1786
|
+
const attrs = Array.from(el.attributes).filter((a) => !a.name.toLowerCase().startsWith("data-hf-")).map((a) => `${a.name.toLowerCase()}\0${a.value}`).sort().join("");
|
|
1787
|
+
return `${el.tagName.toLowerCase()}|${attrs}|${ownText(el)}`;
|
|
1788
|
+
}
|
|
1789
|
+
function mintHfId(el, assigned) {
|
|
1790
|
+
const key = contentKey(el);
|
|
1791
|
+
let id = toHfId(fnv1a(key));
|
|
1792
|
+
let dup = 0;
|
|
1793
|
+
while (assigned.has(id)) {
|
|
1794
|
+
dup += 1;
|
|
1795
|
+
if (dup > 1e4) {
|
|
1796
|
+
id = `hf-${(fnv1a(key) >>> 0).toString(36)}-${dup}`;
|
|
1797
|
+
break;
|
|
1798
|
+
}
|
|
1799
|
+
id = toHfId(fnv1a(`${key}#${dup}`));
|
|
1800
|
+
}
|
|
1801
|
+
assigned.add(id);
|
|
1802
|
+
return id;
|
|
1803
|
+
}
|
|
1804
|
+
function getChildElements(parent) {
|
|
1805
|
+
const directChildren = Array.from(parent.children);
|
|
1806
|
+
if (directChildren.length || parent.tagName.toLowerCase() !== "template") return directChildren;
|
|
1807
|
+
const content = parent.content;
|
|
1808
|
+
if (content?.children.length) return Array.from(content.children);
|
|
1809
|
+
return directChildren;
|
|
1810
|
+
}
|
|
1811
|
+
function isCompositionTemplate(el) {
|
|
1812
|
+
if (el.tagName.toLowerCase() !== "template") return false;
|
|
1813
|
+
if (getContractAttribute(el, "data-composition-id") !== null) return true;
|
|
1814
|
+
for (const child of getChildElements(el)) {
|
|
1815
|
+
if (getContractAttribute(child, "data-composition-id") !== null) return true;
|
|
1816
|
+
}
|
|
1817
|
+
return false;
|
|
1818
|
+
}
|
|
1819
|
+
function walkCompositionDescendants(root, visit) {
|
|
1820
|
+
const rootElement = root.nodeType === 9 ? root.documentElement : root;
|
|
1821
|
+
if (!rootElement) return;
|
|
1822
|
+
const walk = (parent) => {
|
|
1823
|
+
for (const child of getChildElements(parent)) {
|
|
1824
|
+
const isTemplate = child.tagName.toLowerCase() === "template";
|
|
1825
|
+
if (isTemplate && !isCompositionTemplate(child)) continue;
|
|
1826
|
+
visit(child);
|
|
1827
|
+
walk(child);
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
walk(rootElement);
|
|
1831
|
+
}
|
|
1832
|
+
function assignHfIds(body) {
|
|
1833
|
+
const assigned = /* @__PURE__ */ new Set();
|
|
1834
|
+
walkCompositionDescendants(body, (el) => {
|
|
1835
|
+
const existing = getContractAttribute(el, "data-hf-id");
|
|
1836
|
+
if (existing) assigned.add(existing);
|
|
1837
|
+
});
|
|
1838
|
+
walkCompositionDescendants(body, (el) => {
|
|
1839
|
+
if (EXCLUDED_TAGS.has(el.tagName.toLowerCase())) return;
|
|
1840
|
+
if (getContractAttribute(el, "data-hf-id")) return;
|
|
1841
|
+
el.setAttribute("data-hf-id", mintHfId(el, assigned));
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
function ensureHfIds(html) {
|
|
1845
|
+
const wrapped = !/<!doctype|<html[\s>]/i.test(html);
|
|
1846
|
+
const { document } = wrapped ? parseHTML(`<!DOCTYPE html><html><head></head><body>${html}</body></html>`) : parseHTML(html);
|
|
1847
|
+
if (!document.body) return html;
|
|
1848
|
+
assignHfIds(document.body);
|
|
1849
|
+
return wrapped ? document.body.innerHTML || "" : document.toString();
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
// ../core/dist/compiler/htmlBundler.js
|
|
1853
|
+
var DEFAULT_RUNTIME_SCRIPT_URL = "";
|
|
1854
|
+
function getRuntimeScriptUrl() {
|
|
1855
|
+
const configured = (process.env.HYPERFRAME_RUNTIME_URL || "").trim();
|
|
1856
|
+
return configured || DEFAULT_RUNTIME_SCRIPT_URL;
|
|
1857
|
+
}
|
|
1858
|
+
function injectInterceptor(html, runtimeMode = "inline") {
|
|
1859
|
+
const sanitized = stripEmbeddedRuntimeScripts(html);
|
|
1860
|
+
const runtimeScriptUrl = getRuntimeScriptUrl();
|
|
1861
|
+
let tag;
|
|
1862
|
+
if (runtimeScriptUrl) {
|
|
1863
|
+
const escaped = runtimeScriptUrl.replace(/"/g, """);
|
|
1864
|
+
tag = `<script ${RUNTIME_BOOTSTRAP_ATTR}="1" src="${escaped}"></script>`;
|
|
1865
|
+
} else if (runtimeMode === "placeholder") {
|
|
1866
|
+
tag = `<script ${RUNTIME_BOOTSTRAP_ATTR}="1" src=""></script>`;
|
|
1867
|
+
} else {
|
|
1868
|
+
const inlinedRuntime = getHyperframeRuntimeScript();
|
|
1869
|
+
tag = `<script ${RUNTIME_BOOTSTRAP_ATTR}="1">${inlinedRuntime}</script>`;
|
|
1870
|
+
}
|
|
1871
|
+
return insertRuntimeTag(sanitized, tag);
|
|
1872
|
+
}
|
|
1873
|
+
function isRelativeUrl(url) {
|
|
1874
|
+
return !isNonRelativeUrl(url) && !isAbsolute(url);
|
|
1875
|
+
}
|
|
1876
|
+
var bundleReads = new AsyncLocalStorage();
|
|
1877
|
+
function noteRead(filePath) {
|
|
1878
|
+
bundleReads.getStore()?.(filePath);
|
|
1879
|
+
}
|
|
1880
|
+
function safeReadFile(filePath) {
|
|
1881
|
+
noteRead(filePath);
|
|
1882
|
+
if (!existsSync(filePath))
|
|
1883
|
+
return null;
|
|
1884
|
+
try {
|
|
1885
|
+
return readFileSync(filePath, "utf-8");
|
|
1886
|
+
} catch {
|
|
1887
|
+
return null;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
var CSS_IMPORT_RE = /@import\s+(?:url\(\s*(["']?)([^)"']+)\1\s*\)|(["'])([^"']+)\3)\s*([^;]*);\s*/g;
|
|
1891
|
+
var CSS_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
|
|
1892
|
+
function withCommentsStripped(css, fn) {
|
|
1893
|
+
const comments = [];
|
|
1894
|
+
const stripped = css.replace(CSS_COMMENT_RE, (m) => {
|
|
1895
|
+
const idx = comments.length;
|
|
1896
|
+
comments.push(m);
|
|
1897
|
+
return `/*__hf_c${idx}__*/`;
|
|
1898
|
+
});
|
|
1899
|
+
const result = fn(stripped);
|
|
1900
|
+
const restore = (s) => {
|
|
1901
|
+
let out = s;
|
|
1902
|
+
for (let i = 0; i < comments.length; i++) {
|
|
1903
|
+
out = out.replace(`/*__hf_c${i}__*/`, comments[i]);
|
|
1904
|
+
}
|
|
1905
|
+
return out;
|
|
1906
|
+
};
|
|
1907
|
+
return { result, restore };
|
|
1908
|
+
}
|
|
1909
|
+
function rebaseCssUrls(css, cssFileDir, projectDir) {
|
|
1910
|
+
const resolvedRoot = resolve2(projectDir);
|
|
1911
|
+
const resolvedDir = resolve2(cssFileDir);
|
|
1912
|
+
if (resolvedDir === resolvedRoot)
|
|
1913
|
+
return css;
|
|
1914
|
+
return css.replace(CSS_URL_RE, (full, quote, urlValue) => {
|
|
1915
|
+
if (!urlValue || !isRelativeUrl(urlValue))
|
|
1916
|
+
return full;
|
|
1917
|
+
const { basePath, suffix } = splitUrlSuffix(urlValue.trim());
|
|
1918
|
+
if (!basePath)
|
|
1919
|
+
return full;
|
|
1920
|
+
const absolutePath = resolve2(resolvedDir, basePath);
|
|
1921
|
+
const rebased = relative(resolvedRoot, absolutePath).split(sep).join("/");
|
|
1922
|
+
if (rebased === basePath)
|
|
1923
|
+
return full;
|
|
1924
|
+
return `url(${quote || ""}${rebased}${suffix}${quote || ""})`;
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
function rebaseRelativePath(urlValue, fromDir, toDir) {
|
|
1928
|
+
const { basePath, suffix } = splitUrlSuffix(urlValue.trim());
|
|
1929
|
+
if (!basePath)
|
|
1930
|
+
return urlValue;
|
|
1931
|
+
const absolutePath = resolve2(fromDir, basePath);
|
|
1932
|
+
const rebased = relative(resolve2(toDir), absolutePath).split(sep).join("/");
|
|
1933
|
+
return appendSuffixToUrl(rebased, suffix);
|
|
1934
|
+
}
|
|
1935
|
+
function rebaseSrcsetPaths(srcsetValue, fromDir, toDir) {
|
|
1936
|
+
if (!srcsetValue)
|
|
1937
|
+
return srcsetValue;
|
|
1938
|
+
return srcsetValue.split(",").map((rawCandidate) => {
|
|
1939
|
+
const candidate = rawCandidate.trim();
|
|
1940
|
+
if (!candidate)
|
|
1941
|
+
return candidate;
|
|
1942
|
+
const parts = candidate.split(/\s+/);
|
|
1943
|
+
const first = parts[0] ?? "";
|
|
1944
|
+
if (parts.length === 0 || !isRelativeUrl(first))
|
|
1945
|
+
return candidate;
|
|
1946
|
+
parts[0] = rebaseRelativePath(first, fromDir, toDir);
|
|
1947
|
+
return parts.join(" ");
|
|
1948
|
+
}).join(", ");
|
|
1949
|
+
}
|
|
1950
|
+
function rebaseColorGradingLutPath(value, fromDir, toDir) {
|
|
1951
|
+
if (!value.trim().startsWith("{"))
|
|
1952
|
+
return value;
|
|
1953
|
+
let parsed;
|
|
1954
|
+
try {
|
|
1955
|
+
parsed = JSON.parse(value);
|
|
1956
|
+
} catch {
|
|
1957
|
+
return value;
|
|
1958
|
+
}
|
|
1959
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
1960
|
+
return value;
|
|
1961
|
+
const lut = Reflect.get(parsed, "lut");
|
|
1962
|
+
if (typeof lut === "string") {
|
|
1963
|
+
if (!isRelativeUrl(lut))
|
|
1964
|
+
return value;
|
|
1965
|
+
Reflect.set(parsed, "lut", rebaseRelativePath(lut, fromDir, toDir));
|
|
1966
|
+
return JSON.stringify(parsed);
|
|
1967
|
+
}
|
|
1968
|
+
if (typeof lut !== "object" || lut === null || Array.isArray(lut))
|
|
1969
|
+
return value;
|
|
1970
|
+
const lutSrc = Reflect.get(lut, "src");
|
|
1971
|
+
if (typeof lutSrc !== "string" || !isRelativeUrl(lutSrc))
|
|
1972
|
+
return value;
|
|
1973
|
+
Reflect.set(lut, "src", rebaseRelativePath(lutSrc, fromDir, toDir));
|
|
1974
|
+
return JSON.stringify(parsed);
|
|
1975
|
+
}
|
|
1976
|
+
function rebaseEntryAuthoredAssetPaths(document, sourceDir, projectDir) {
|
|
1977
|
+
for (const styleEl of [...document.querySelectorAll("style")]) {
|
|
1978
|
+
styleEl.textContent = rebaseCssUrls(styleEl.textContent || "", sourceDir, projectDir);
|
|
1979
|
+
}
|
|
1980
|
+
for (const el of [...document.querySelectorAll("[style]")]) {
|
|
1981
|
+
const styleAttr = el.getAttribute("style");
|
|
1982
|
+
if (styleAttr)
|
|
1983
|
+
el.setAttribute("style", rebaseCssUrls(styleAttr, sourceDir, projectDir));
|
|
1984
|
+
}
|
|
1985
|
+
for (const el of [...document.querySelectorAll("[src], [href], [poster], [xlink\\:href]")]) {
|
|
1986
|
+
if (el.tagName === "LINK" && (el.getAttribute("rel") || "").toLowerCase() === "stylesheet")
|
|
1987
|
+
continue;
|
|
1988
|
+
if (el.tagName === "SCRIPT" && el.hasAttribute("src"))
|
|
1989
|
+
continue;
|
|
1990
|
+
for (const attr of ["src", "href", "poster", "xlink:href"]) {
|
|
1991
|
+
const value = el.getAttribute(attr);
|
|
1992
|
+
if (!value || !isRelativeUrl(value))
|
|
1993
|
+
continue;
|
|
1994
|
+
el.setAttribute(attr, rebaseRelativePath(value, sourceDir, projectDir));
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
for (const el of [...document.querySelectorAll("[srcset]")]) {
|
|
1998
|
+
const srcset = el.getAttribute("srcset");
|
|
1999
|
+
if (srcset)
|
|
2000
|
+
el.setAttribute("srcset", rebaseSrcsetPaths(srcset, sourceDir, projectDir));
|
|
2001
|
+
}
|
|
2002
|
+
for (const el of [...document.querySelectorAll(`[${HF_COLOR_GRADING_ATTR}]`)]) {
|
|
2003
|
+
const value = el.getAttribute(HF_COLOR_GRADING_ATTR);
|
|
2004
|
+
if (value)
|
|
2005
|
+
el.setAttribute(HF_COLOR_GRADING_ATTR, rebaseColorGradingLutPath(value, sourceDir, projectDir));
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
function inlineCssFile(css, cssFileDir, projectDir, visited = /* @__PURE__ */ new Set()) {
|
|
2009
|
+
const { result: strippedCss, restore: restoreComments } = withCommentsStripped(css, (s) => s);
|
|
2010
|
+
const importPlaceholders = [];
|
|
2011
|
+
const withPlaceholders = strippedCss.replace(CSS_IMPORT_RE, (full, _q1, urlPath, _q2, barePath, mediaQuery) => {
|
|
2012
|
+
const importPath = urlPath ?? barePath;
|
|
2013
|
+
if (!importPath || !isRelativeUrl(importPath))
|
|
2014
|
+
return full;
|
|
2015
|
+
const resolved = resolve2(cssFileDir, importPath);
|
|
2016
|
+
if (!isSafePath(projectDir, resolved))
|
|
2017
|
+
return full;
|
|
2018
|
+
if (visited.has(resolved))
|
|
2019
|
+
return "";
|
|
2020
|
+
const content = safeReadFile(resolved);
|
|
2021
|
+
if (content == null)
|
|
2022
|
+
return full;
|
|
2023
|
+
visited.add(resolved);
|
|
2024
|
+
const inlined = inlineCssFile(content, dirname(resolved), projectDir, visited);
|
|
2025
|
+
const trimmedMedia = (mediaQuery || "").trim();
|
|
2026
|
+
const block = trimmedMedia ? `@media ${trimmedMedia} {
|
|
2027
|
+
${inlined}
|
|
2028
|
+
}
|
|
2029
|
+
` : inlined + "\n";
|
|
2030
|
+
const idx = importPlaceholders.length;
|
|
2031
|
+
importPlaceholders.push(block);
|
|
2032
|
+
return `/*__hf_import_${idx}__*/`;
|
|
2033
|
+
});
|
|
2034
|
+
let rebased = rebaseCssUrls(withPlaceholders, cssFileDir, projectDir);
|
|
2035
|
+
rebased = restoreComments(rebased);
|
|
2036
|
+
for (let i = 0; i < importPlaceholders.length; i++) {
|
|
2037
|
+
rebased = rebased.replace(`/*__hf_import_${i}__*/`, importPlaceholders[i]);
|
|
2038
|
+
}
|
|
2039
|
+
return rebased;
|
|
2040
|
+
}
|
|
2041
|
+
function safeReadFileBuffer(filePath) {
|
|
2042
|
+
noteRead(filePath);
|
|
2043
|
+
if (!existsSync(filePath))
|
|
2044
|
+
return null;
|
|
2045
|
+
try {
|
|
2046
|
+
return readFileSync(filePath);
|
|
2047
|
+
} catch {
|
|
2048
|
+
return null;
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
function splitUrlSuffix(urlValue) {
|
|
2052
|
+
const queryIdx = urlValue.indexOf("?");
|
|
2053
|
+
const hashIdx = urlValue.indexOf("#");
|
|
2054
|
+
if (queryIdx < 0 && hashIdx < 0)
|
|
2055
|
+
return { basePath: urlValue, suffix: "" };
|
|
2056
|
+
const cutIdx = queryIdx < 0 ? hashIdx : hashIdx < 0 ? queryIdx : Math.min(queryIdx, hashIdx);
|
|
2057
|
+
return { basePath: urlValue.slice(0, cutIdx), suffix: urlValue.slice(cutIdx) };
|
|
2058
|
+
}
|
|
2059
|
+
function appendSuffixToUrl(baseUrl, suffix) {
|
|
2060
|
+
if (!suffix)
|
|
2061
|
+
return baseUrl;
|
|
2062
|
+
if (suffix.startsWith("#"))
|
|
2063
|
+
return `${baseUrl}${suffix}`;
|
|
2064
|
+
if (suffix.startsWith("?")) {
|
|
2065
|
+
const queryWithOptionalHash = suffix.slice(1);
|
|
2066
|
+
if (!queryWithOptionalHash)
|
|
2067
|
+
return baseUrl;
|
|
2068
|
+
const hashIdx = queryWithOptionalHash.indexOf("#");
|
|
2069
|
+
const queryPart = hashIdx >= 0 ? queryWithOptionalHash.slice(0, hashIdx) : queryWithOptionalHash;
|
|
2070
|
+
const hashPart = hashIdx >= 0 ? queryWithOptionalHash.slice(hashIdx) : "";
|
|
2071
|
+
if (!queryPart)
|
|
2072
|
+
return `${baseUrl}${hashPart}`;
|
|
2073
|
+
const joiner = baseUrl.includes("?") ? "&" : "?";
|
|
2074
|
+
return `${baseUrl}${joiner}${queryPart}${hashPart}`;
|
|
2075
|
+
}
|
|
2076
|
+
return baseUrl;
|
|
2077
|
+
}
|
|
2078
|
+
var INLINE_MIME = {
|
|
2079
|
+
".svg": "image/svg+xml",
|
|
2080
|
+
".json": "application/json",
|
|
2081
|
+
".txt": "text/plain",
|
|
2082
|
+
".cube": "text/plain",
|
|
2083
|
+
".xml": "application/xml",
|
|
2084
|
+
// Fonts and raster images. A bundle handed to a consumer that stores it as a
|
|
2085
|
+
// lone object — no sibling `assets/` directory — 404s on every surviving
|
|
2086
|
+
// relative reference, and a missing font silently reflows the whole frame
|
|
2087
|
+
// rather than failing loudly. Media (mp4/webm/mp3/wav) is deliberately absent:
|
|
2088
|
+
// it is large, streamed rather than laid out, and its absence is obvious.
|
|
2089
|
+
".woff2": "font/woff2",
|
|
2090
|
+
".woff": "font/woff",
|
|
2091
|
+
".ttf": "font/ttf",
|
|
2092
|
+
".otf": "font/otf",
|
|
2093
|
+
".png": "image/png",
|
|
2094
|
+
".jpg": "image/jpeg",
|
|
2095
|
+
".jpeg": "image/jpeg",
|
|
2096
|
+
".gif": "image/gif",
|
|
2097
|
+
".webp": "image/webp",
|
|
2098
|
+
".avif": "image/avif"
|
|
2099
|
+
};
|
|
2100
|
+
var MAX_INLINE_ASSET_BYTES = 2 * 1024 * 1024;
|
|
2101
|
+
function safeStatSize(filePath) {
|
|
2102
|
+
try {
|
|
2103
|
+
return statSync(filePath).size;
|
|
2104
|
+
} catch {
|
|
2105
|
+
return null;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
function warnAssetTooLargeToInline(assetPath, byteLength) {
|
|
2109
|
+
const mb = (byteLength / (1024 * 1024)).toFixed(1);
|
|
2110
|
+
console.warn(`[HyperFrames] Not inlining "${assetPath}" (${mb} MB exceeds the ${MAX_INLINE_ASSET_BYTES / (1024 * 1024)} MB inline limit). The bundle may not be self-contained.`);
|
|
2111
|
+
}
|
|
2112
|
+
function maybeInlineRelativeAssetUrl(urlValue, projectDir, inlineAssets) {
|
|
2113
|
+
if (!inlineAssets)
|
|
2114
|
+
return null;
|
|
2115
|
+
if (!urlValue || !isRelativeUrl(urlValue))
|
|
2116
|
+
return null;
|
|
2117
|
+
const { basePath, suffix } = splitUrlSuffix(urlValue.trim());
|
|
2118
|
+
if (!basePath)
|
|
2119
|
+
return null;
|
|
2120
|
+
const filePath = resolveWithinProject(projectDir, basePath);
|
|
2121
|
+
if (!filePath)
|
|
2122
|
+
return null;
|
|
2123
|
+
const ext = filePath.toLowerCase().match(/\.[^.]+$/)?.[0] ?? "";
|
|
2124
|
+
const mimeType = INLINE_MIME[ext];
|
|
2125
|
+
if (!mimeType)
|
|
2126
|
+
return null;
|
|
2127
|
+
const byteLength = safeStatSize(filePath);
|
|
2128
|
+
if (byteLength !== null && byteLength > MAX_INLINE_ASSET_BYTES) {
|
|
2129
|
+
warnAssetTooLargeToInline(basePath, byteLength);
|
|
2130
|
+
return null;
|
|
2131
|
+
}
|
|
2132
|
+
const content = safeReadFileBuffer(filePath);
|
|
2133
|
+
if (content == null)
|
|
2134
|
+
return null;
|
|
2135
|
+
const dataUrl = `data:${mimeType};base64,${content.toString("base64")}`;
|
|
2136
|
+
return appendSuffixToUrl(dataUrl, suffix);
|
|
2137
|
+
}
|
|
2138
|
+
function isExternalSvgFragmentUse(el, attr, urlValue) {
|
|
2139
|
+
if (el.tagName.toLowerCase() !== "use")
|
|
2140
|
+
return false;
|
|
2141
|
+
if (attr !== "href" && attr !== "xlink:href")
|
|
2142
|
+
return false;
|
|
2143
|
+
if (!isRelativeUrl(urlValue))
|
|
2144
|
+
return false;
|
|
2145
|
+
const hashIdx = urlValue.indexOf("#");
|
|
2146
|
+
if (hashIdx <= 0)
|
|
2147
|
+
return false;
|
|
2148
|
+
const pathBeforeFragment = urlValue.slice(0, hashIdx).split("?", 1)[0] ?? "";
|
|
2149
|
+
return pathBeforeFragment.toLowerCase().endsWith(".svg");
|
|
2150
|
+
}
|
|
2151
|
+
function warnColorGradingLutNotInlined(lutSrc) {
|
|
2152
|
+
const trimmed = lutSrc.trim();
|
|
2153
|
+
if (!isRelativeUrl(trimmed))
|
|
2154
|
+
return;
|
|
2155
|
+
console.warn(`[HyperFrames] Could not inline color grading LUT "${trimmed}". The rendered bundle may not be self-contained.`);
|
|
2156
|
+
}
|
|
2157
|
+
function rewriteColorGradingLutWithInlinedAssets(value, projectDir) {
|
|
2158
|
+
if (!value.trim().startsWith("{"))
|
|
2159
|
+
return value;
|
|
2160
|
+
let parsed;
|
|
2161
|
+
try {
|
|
2162
|
+
parsed = JSON.parse(value);
|
|
2163
|
+
} catch {
|
|
2164
|
+
return value;
|
|
2165
|
+
}
|
|
2166
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
2167
|
+
return value;
|
|
2168
|
+
const lut = Reflect.get(parsed, "lut");
|
|
2169
|
+
if (typeof lut === "string") {
|
|
2170
|
+
const inlined2 = maybeInlineRelativeAssetUrl(lut, projectDir, true);
|
|
2171
|
+
if (!inlined2) {
|
|
2172
|
+
warnColorGradingLutNotInlined(lut);
|
|
2173
|
+
return value;
|
|
2174
|
+
}
|
|
2175
|
+
Reflect.set(parsed, "lut", inlined2);
|
|
2176
|
+
return JSON.stringify(parsed);
|
|
2177
|
+
}
|
|
2178
|
+
if (typeof lut !== "object" || lut === null || Array.isArray(lut))
|
|
2179
|
+
return value;
|
|
2180
|
+
const lutSrc = Reflect.get(lut, "src");
|
|
2181
|
+
if (typeof lutSrc !== "string")
|
|
2182
|
+
return value;
|
|
2183
|
+
const inlined = maybeInlineRelativeAssetUrl(lutSrc, projectDir, true);
|
|
2184
|
+
if (!inlined) {
|
|
2185
|
+
warnColorGradingLutNotInlined(lutSrc);
|
|
2186
|
+
return value;
|
|
2187
|
+
}
|
|
2188
|
+
Reflect.set(lut, "src", inlined);
|
|
2189
|
+
return JSON.stringify(parsed);
|
|
2190
|
+
}
|
|
2191
|
+
function rewriteSrcsetWithInlinedAssets(srcsetValue, projectDir, inlineAssets) {
|
|
2192
|
+
if (!srcsetValue)
|
|
2193
|
+
return srcsetValue;
|
|
2194
|
+
return srcsetValue.split(",").map((rawCandidate) => {
|
|
2195
|
+
const candidate = rawCandidate.trim();
|
|
2196
|
+
if (!candidate)
|
|
2197
|
+
return candidate;
|
|
2198
|
+
const parts = candidate.split(/\s+/);
|
|
2199
|
+
if (parts.length === 0)
|
|
2200
|
+
return candidate;
|
|
2201
|
+
const maybeInlined = maybeInlineRelativeAssetUrl(parts[0] ?? "", projectDir, inlineAssets);
|
|
2202
|
+
if (maybeInlined)
|
|
2203
|
+
parts[0] = maybeInlined;
|
|
2204
|
+
return parts.join(" ");
|
|
2205
|
+
}).join(", ");
|
|
2206
|
+
}
|
|
2207
|
+
function rewriteCssUrlsWithInlinedAssets(cssText, projectDir, inlineAssets) {
|
|
2208
|
+
if (!cssText)
|
|
2209
|
+
return cssText;
|
|
2210
|
+
return cssText.replace(/\burl\(\s*(["']?)([^)"']+)\1\s*\)/g, (_full, quote, rawUrl) => {
|
|
2211
|
+
const maybeInlined = maybeInlineRelativeAssetUrl((rawUrl || "").trim(), projectDir, inlineAssets);
|
|
2212
|
+
if (!maybeInlined)
|
|
2213
|
+
return _full;
|
|
2214
|
+
return `url(${quote || ""}${maybeInlined}${quote || ""})`;
|
|
2215
|
+
});
|
|
2216
|
+
}
|
|
2217
|
+
function cssAttributeSelector(attr, value) {
|
|
2218
|
+
const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/</g, "\\3c ");
|
|
2219
|
+
return `[${attr}="${escaped}"]`;
|
|
2220
|
+
}
|
|
2221
|
+
function uniqueCompositionId(baseId, index) {
|
|
2222
|
+
return `${baseId}__hf${index}`;
|
|
2223
|
+
}
|
|
2224
|
+
function getBundledHostCompositionIdentity(host) {
|
|
2225
|
+
const currentCompositionId = (host.getAttribute("data-composition-id") || "").trim() || null;
|
|
2226
|
+
const authoredCompositionId = (host.getAttribute("data-hf-original-composition-id") || currentCompositionId || "").trim() || null;
|
|
2227
|
+
return {
|
|
2228
|
+
authoredCompositionId,
|
|
2229
|
+
runtimeCompositionId: currentCompositionId
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
function getBundledTrackedCompositionHosts(document) {
|
|
2233
|
+
const hosts = Array.from(document.querySelectorAll("[data-composition-src], [data-composition-id]"));
|
|
2234
|
+
return hosts.filter((host) => {
|
|
2235
|
+
if (host.hasAttribute("data-composition-src"))
|
|
2236
|
+
return true;
|
|
2237
|
+
const authoredCompositionId = getBundledHostCompositionIdentity(host).authoredCompositionId;
|
|
2238
|
+
if (!authoredCompositionId)
|
|
2239
|
+
return false;
|
|
2240
|
+
return !!document.getElementById(`${authoredCompositionId}-template`);
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
function shouldAssignBundledRuntimeCompositionId(host, document) {
|
|
2244
|
+
if (host.hasAttribute("data-composition-src"))
|
|
2245
|
+
return true;
|
|
2246
|
+
const authoredCompositionId = getBundledHostCompositionIdentity(host).authoredCompositionId;
|
|
2247
|
+
if (!authoredCompositionId)
|
|
2248
|
+
return false;
|
|
2249
|
+
if (!document.getElementById(`${authoredCompositionId}-template`))
|
|
2250
|
+
return false;
|
|
2251
|
+
return host.children.length === 0;
|
|
2252
|
+
}
|
|
2253
|
+
function countBundledAuthoredCompositionIds(hosts) {
|
|
2254
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2255
|
+
for (const host of hosts) {
|
|
2256
|
+
const authoredCompositionId = getBundledHostCompositionIdentity(host).authoredCompositionId;
|
|
2257
|
+
if (!authoredCompositionId)
|
|
2258
|
+
continue;
|
|
2259
|
+
counts.set(authoredCompositionId, (counts.get(authoredCompositionId) || 0) + 1);
|
|
2260
|
+
}
|
|
2261
|
+
return counts;
|
|
2262
|
+
}
|
|
2263
|
+
function assignBundledRuntimeCompositionIds(hosts, counts = countBundledAuthoredCompositionIds(hosts)) {
|
|
2264
|
+
const instanceByCompositionId = /* @__PURE__ */ new Map();
|
|
2265
|
+
const identities = /* @__PURE__ */ new Map();
|
|
2266
|
+
for (const host of hosts) {
|
|
2267
|
+
const { authoredCompositionId, runtimeCompositionId: previousRuntimeCompositionId } = getBundledHostCompositionIdentity(host);
|
|
2268
|
+
const shouldAssign = shouldAssignBundledRuntimeCompositionId(host, host.ownerDocument);
|
|
2269
|
+
if (!authoredCompositionId) {
|
|
2270
|
+
identities.set(host, {
|
|
2271
|
+
authoredCompositionId: null,
|
|
2272
|
+
runtimeCompositionId: previousRuntimeCompositionId
|
|
2273
|
+
});
|
|
2274
|
+
continue;
|
|
2275
|
+
}
|
|
2276
|
+
const duplicateInstance = (counts.get(authoredCompositionId) || 0) > 1;
|
|
2277
|
+
let runtimeCompositionId = previousRuntimeCompositionId || authoredCompositionId;
|
|
2278
|
+
if (shouldAssign) {
|
|
2279
|
+
const instanceIndex = duplicateInstance ? (instanceByCompositionId.get(authoredCompositionId) || 0) + 1 : 0;
|
|
2280
|
+
if (duplicateInstance) {
|
|
2281
|
+
instanceByCompositionId.set(authoredCompositionId, instanceIndex);
|
|
2282
|
+
host.setAttribute("data-hf-original-composition-id", authoredCompositionId);
|
|
2283
|
+
} else {
|
|
2284
|
+
host.removeAttribute("data-hf-original-composition-id");
|
|
2285
|
+
}
|
|
2286
|
+
runtimeCompositionId = duplicateInstance ? uniqueCompositionId(authoredCompositionId, instanceIndex) : authoredCompositionId;
|
|
2287
|
+
host.setAttribute("data-composition-id", runtimeCompositionId);
|
|
2288
|
+
}
|
|
2289
|
+
identities.set(host, {
|
|
2290
|
+
authoredCompositionId,
|
|
2291
|
+
runtimeCompositionId
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
return identities;
|
|
2295
|
+
}
|
|
2296
|
+
function prepareFlattenedInnerRoot(innerRoot) {
|
|
2297
|
+
const prepared = innerRoot.cloneNode(true);
|
|
2298
|
+
markFlattenedInnerRoot(prepared);
|
|
2299
|
+
const w = prepared.getAttribute("data-width");
|
|
2300
|
+
const h = prepared.getAttribute("data-height");
|
|
2301
|
+
const widthVal = w ? `${w}px` : "100%";
|
|
2302
|
+
const heightVal = h ? `${h}px` : "100%";
|
|
2303
|
+
const existingStyle = (prepared.getAttribute("style") || "").trim();
|
|
2304
|
+
const fill = `width:${widthVal};height:${heightVal}`;
|
|
2305
|
+
prepared.setAttribute("style", existingStyle ? `${existingStyle};${fill}` : fill);
|
|
2306
|
+
return prepared;
|
|
2307
|
+
}
|
|
2308
|
+
function enforceCompositionPixelSizing(document) {
|
|
2309
|
+
const compositionEls = [
|
|
2310
|
+
...document.querySelectorAll("[data-composition-id][data-width][data-height]")
|
|
2311
|
+
];
|
|
2312
|
+
if (compositionEls.length === 0)
|
|
2313
|
+
return;
|
|
2314
|
+
const sizeMap = /* @__PURE__ */ new Map();
|
|
2315
|
+
for (const el of compositionEls) {
|
|
2316
|
+
const compId = el.getAttribute("data-composition-id");
|
|
2317
|
+
const w = Number(el.getAttribute("data-width"));
|
|
2318
|
+
const h = Number(el.getAttribute("data-height"));
|
|
2319
|
+
if (compId && Number.isFinite(w) && Number.isFinite(h) && w > 0 && h > 0) {
|
|
2320
|
+
sizeMap.set(compId, { w, h });
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
if (sizeMap.size === 0)
|
|
2324
|
+
return;
|
|
2325
|
+
for (const styleEl of document.querySelectorAll("style")) {
|
|
2326
|
+
let css = styleEl.textContent || "";
|
|
2327
|
+
let modified = false;
|
|
2328
|
+
for (const [compId, { w, h }] of sizeMap) {
|
|
2329
|
+
const escaped = compId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2330
|
+
const blockRe = new RegExp(`(\\[data-composition-id=["']${escaped}["']\\]\\s*\\{)([^}]*)(})`, "g");
|
|
2331
|
+
css = css.replace(blockRe, (_, open, body, close) => {
|
|
2332
|
+
const newBody = body.replace(/(\bwidth\s*:\s*)100%/g, `$1${w}px`).replace(/(\bheight\s*:\s*)100%/g, `$1${h}px`);
|
|
2333
|
+
if (newBody !== body)
|
|
2334
|
+
modified = true;
|
|
2335
|
+
return open + newBody + close;
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
if (modified)
|
|
2339
|
+
styleEl.textContent = css;
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
function autoHealMissingCompositionIds(document) {
|
|
2343
|
+
const compositionIdRe = /data-composition-id=["']([^"']+)["']/gi;
|
|
2344
|
+
const referencedIds = /* @__PURE__ */ new Set();
|
|
2345
|
+
for (const el of document.querySelectorAll("style, script")) {
|
|
2346
|
+
const text = (el.textContent || "").trim();
|
|
2347
|
+
if (!text)
|
|
2348
|
+
continue;
|
|
2349
|
+
let match;
|
|
2350
|
+
while ((match = compositionIdRe.exec(text)) !== null) {
|
|
2351
|
+
const compId = (match[1] || "").trim();
|
|
2352
|
+
if (compId)
|
|
2353
|
+
referencedIds.add(compId);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
if (referencedIds.size === 0)
|
|
2357
|
+
return;
|
|
2358
|
+
const existingIds = /* @__PURE__ */ new Set();
|
|
2359
|
+
for (const el of document.querySelectorAll("[data-composition-id]")) {
|
|
2360
|
+
const id = (el.getAttribute("data-composition-id") || "").trim();
|
|
2361
|
+
if (id)
|
|
2362
|
+
existingIds.add(id);
|
|
2363
|
+
}
|
|
2364
|
+
for (const compId of referencedIds) {
|
|
2365
|
+
if (compId === "root" || existingIds.has(compId))
|
|
2366
|
+
continue;
|
|
2367
|
+
const candidates = [`${compId}-layer`, `${compId}-comp`, compId];
|
|
2368
|
+
for (const targetId of candidates) {
|
|
2369
|
+
const found = document.getElementById(targetId);
|
|
2370
|
+
if (found && !found.getAttribute("data-composition-id")) {
|
|
2371
|
+
found.setAttribute("data-composition-id", compId);
|
|
2372
|
+
break;
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
function joinCssHoistingImports(sheets) {
|
|
2378
|
+
const imports = /* @__PURE__ */ new Set();
|
|
2379
|
+
const cssParts = [];
|
|
2380
|
+
for (const sheet of sheets) {
|
|
2381
|
+
const rest = sheet.trim().replace(CSS_IMPORT_RE, (match) => {
|
|
2382
|
+
imports.add(match.trim());
|
|
2383
|
+
return "";
|
|
2384
|
+
});
|
|
2385
|
+
if (rest.trim())
|
|
2386
|
+
cssParts.push(rest.trim());
|
|
2387
|
+
}
|
|
2388
|
+
return [...imports, ...cssParts].join("\n\n").trim();
|
|
2389
|
+
}
|
|
2390
|
+
function placeSceneStylesLikeRender(document) {
|
|
2391
|
+
const styles = [...document.querySelectorAll("head style")];
|
|
2392
|
+
const imports = /* @__PURE__ */ new Set();
|
|
2393
|
+
for (const el of styles) {
|
|
2394
|
+
el.textContent = (el.textContent || "").replace(CSS_IMPORT_RE, (match) => (imports.add(match.trim()), "")).trim();
|
|
2395
|
+
}
|
|
2396
|
+
styles.slice(1).reduce((previous, el) => (previous.after(el), el), styles[0]);
|
|
2397
|
+
if (imports.size === 0)
|
|
2398
|
+
return;
|
|
2399
|
+
const hoisted = [...imports].join("\n\n");
|
|
2400
|
+
const first = styles[0];
|
|
2401
|
+
if (!first.hasAttribute(SCENE_PART_ATTR)) {
|
|
2402
|
+
first.textContent = [hoisted, first.textContent].filter(Boolean).join("\n\n");
|
|
2403
|
+
return;
|
|
2404
|
+
}
|
|
2405
|
+
const holder = document.createElement("style");
|
|
2406
|
+
holder.textContent = hoisted;
|
|
2407
|
+
first.before(holder);
|
|
2408
|
+
}
|
|
2409
|
+
function isAlwaysAppliedStyle(el) {
|
|
2410
|
+
return cssStyleMergeKey(el) === UNCONDITIONAL_CSS_KEY && !el.closest("template, noscript, svg");
|
|
2411
|
+
}
|
|
2412
|
+
function pushRun(runs, scene, chunk) {
|
|
2413
|
+
const last = runs.at(-1);
|
|
2414
|
+
if (last && last.scene === scene)
|
|
2415
|
+
last.chunks.push(chunk);
|
|
2416
|
+
else
|
|
2417
|
+
runs.push({ scene, chunks: [chunk] });
|
|
2418
|
+
}
|
|
2419
|
+
function coalesceHeadStylesAndBodyScripts(document) {
|
|
2420
|
+
const allHeadStyles = [...document.querySelectorAll("head style")];
|
|
2421
|
+
const isScenePart = (el) => el.hasAttribute(SCENE_PART_ATTR);
|
|
2422
|
+
for (const run of allHeadStyles.length > 1 ? headStyleRuns(allHeadStyles, isScenePart) : []) {
|
|
2423
|
+
const merged = joinCssHoistingImports(run.map((el) => el.textContent || ""));
|
|
2424
|
+
if (!merged)
|
|
2425
|
+
continue;
|
|
2426
|
+
run[0].textContent = merged;
|
|
2427
|
+
for (const el of run.slice(1))
|
|
2428
|
+
el.remove();
|
|
2429
|
+
}
|
|
2430
|
+
if (allHeadStyles.some(isScenePart))
|
|
2431
|
+
placeSceneStylesLikeRender(document);
|
|
2432
|
+
const isPinned = (el) => el.hasAttribute(RUNTIME_BOOTSTRAP_ATTR) || el.hasAttribute(SCENE_PART_ATTR);
|
|
2433
|
+
for (const { members, anchor } of inlineScriptRuns([...document.querySelectorAll("body script")], isPinned)) {
|
|
2434
|
+
const mergedJs = joinJsChunks(members.map((el) => el.textContent || ""));
|
|
2435
|
+
for (const el of members)
|
|
2436
|
+
el.remove();
|
|
2437
|
+
if (!mergedJs)
|
|
2438
|
+
continue;
|
|
2439
|
+
const inlineScript = document.createElement("script");
|
|
2440
|
+
inlineScript.textContent = escapeInlineScriptSource(stripJsCommentsParserSafe(mergedJs));
|
|
2441
|
+
if (anchor)
|
|
2442
|
+
anchor.before(inlineScript);
|
|
2443
|
+
else
|
|
2444
|
+
document.body.appendChild(inlineScript);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
function injectTextRenderingRule(document) {
|
|
2448
|
+
const head = document.head;
|
|
2449
|
+
if (!head)
|
|
2450
|
+
return;
|
|
2451
|
+
if (document.querySelector("style[data-hyperframes-text-rendering]"))
|
|
2452
|
+
return;
|
|
2453
|
+
const styleEl = document.createElement("style");
|
|
2454
|
+
styleEl.setAttribute("data-hyperframes-text-rendering", "true");
|
|
2455
|
+
styleEl.textContent = "html,body,*{text-rendering:geometricPrecision}";
|
|
2456
|
+
head.insertBefore(styleEl, head.firstChild);
|
|
2457
|
+
}
|
|
2458
|
+
function joinJsChunks(chunks) {
|
|
2459
|
+
return chunks.map((chunk) => chunk.trim()).filter((chunk) => chunk.length > 0).map((chunk) => chunk.endsWith(";") ? chunk : chunk + "\n;").join("\n");
|
|
2460
|
+
}
|
|
2461
|
+
function stripJsCommentsParserSafe(source) {
|
|
2462
|
+
if (!source)
|
|
2463
|
+
return source;
|
|
2464
|
+
try {
|
|
2465
|
+
const result = transformSync(source, { loader: "js", minify: false, legalComments: "none" });
|
|
2466
|
+
return result.code.trim();
|
|
2467
|
+
} catch {
|
|
2468
|
+
return source;
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
function preserveLocalScriptIntegrity(doc, src, resolvePath) {
|
|
2472
|
+
const path = resolvePath(src);
|
|
2473
|
+
if (!path)
|
|
2474
|
+
return false;
|
|
2475
|
+
const pinned = [...doc.querySelectorAll("script[src][integrity]")].filter((el) => {
|
|
2476
|
+
const candidate = el.getAttribute("src") || "";
|
|
2477
|
+
return isRelativeUrl(candidate) && resolvePath(candidate) === path && el.getAttribute("integrity")?.trim();
|
|
2478
|
+
});
|
|
2479
|
+
for (const el of pinned)
|
|
2480
|
+
ensureExternalScriptTag(doc, src, readExternalScriptAttributes(el));
|
|
2481
|
+
return pinned.length > 0;
|
|
2482
|
+
}
|
|
2483
|
+
function hoistExternalScript(src, projectDir, doc, seenSrcs, chunks, attributes) {
|
|
2484
|
+
if (attributes.integrity?.trim()) {
|
|
2485
|
+
ensureExternalScriptTag(doc, src, attributes);
|
|
2486
|
+
seenSrcs.add(src);
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
if (seenSrcs.has(src))
|
|
2490
|
+
return;
|
|
2491
|
+
seenSrcs.add(src);
|
|
2492
|
+
if (!isNonRelativeUrl(src) && !isAbsolute(src) && attributes.type !== "module") {
|
|
2493
|
+
const jsPath = resolveWithinProject(projectDir, src);
|
|
2494
|
+
const js = jsPath ? safeReadFile(jsPath) : null;
|
|
2495
|
+
if (js != null) {
|
|
2496
|
+
chunks.push(() => preserveLocalScriptIntegrity(doc, src, (value) => resolveWithinProject(projectDir, value)) ? "" : js);
|
|
2497
|
+
return;
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
ensureExternalScriptTag(doc, src, attributes);
|
|
2501
|
+
}
|
|
2502
|
+
function hoistCompositionScripts(container, opts) {
|
|
2503
|
+
for (const scriptEl of [...container.querySelectorAll("script")]) {
|
|
2504
|
+
const externalSrc = (scriptEl.getAttribute("src") || "").trim();
|
|
2505
|
+
if (externalSrc) {
|
|
2506
|
+
hoistExternalScript(externalSrc, opts.projectDir, opts.document, opts.seenCompScriptSrcs, opts.compScriptChunks, readExternalScriptAttributes(scriptEl));
|
|
2507
|
+
} else {
|
|
2508
|
+
opts.compScriptChunks.push(opts.compId ? wrapScopedCompositionScript(scriptEl.textContent || "", opts.compId, "[HyperFrames] composition script error:", opts.runtimeScope, opts.runtimeCompId || opts.compId, opts.authoredRootId) : wrapInlineScriptWithErrorBoundary(scriptEl.textContent || "", "[HyperFrames] composition script error:"));
|
|
2509
|
+
}
|
|
2510
|
+
scriptEl.remove();
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
function bundleToSingleHtml(projectDir, options) {
|
|
2514
|
+
const bundle = () => bundleProject(projectDir, options);
|
|
2515
|
+
return options?.onRead ? bundleReads.run(options.onRead, bundle) : bundle();
|
|
2516
|
+
}
|
|
2517
|
+
async function bundleProject(projectDir, options) {
|
|
2518
|
+
const entryFile = options?.entryFile ?? "index.html";
|
|
2519
|
+
const indexPath = resolveWithinProject(projectDir, entryFile);
|
|
2520
|
+
if (!indexPath || !existsSync(indexPath)) {
|
|
2521
|
+
throw new Error(`${entryFile} not found in project directory`);
|
|
2522
|
+
}
|
|
2523
|
+
const sourceDir = dirname(indexPath);
|
|
2524
|
+
const resolveEntryPath = (relativePath) => {
|
|
2525
|
+
const resolved = resolve2(sourceDir, relativePath);
|
|
2526
|
+
return isSafePath(projectDir, resolved) ? resolved : null;
|
|
2527
|
+
};
|
|
2528
|
+
const readSource = options?.stampHfIds ? ensureHfIds : (html) => html;
|
|
2529
|
+
noteRead(indexPath);
|
|
2530
|
+
const rawHtml = readSource(readFileSync(indexPath, "utf-8"));
|
|
2531
|
+
const compiled = await compileHtml(rawHtml, sourceDir, options?.probeMediaDuration);
|
|
2532
|
+
if (options?.staticGuard !== false) {
|
|
2533
|
+
const staticGuard = await validateHyperframeHtmlContract(compiled);
|
|
2534
|
+
if (!staticGuard.isValid) {
|
|
2535
|
+
console.warn(`[StaticGuard] Invalid HyperFrame contract: ${staticGuard.missingKeys.join("; ")}`);
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
const withInterceptor = injectInterceptor(compiled, options?.runtime ?? "inline");
|
|
2539
|
+
const document = parseHTMLContent(withInterceptor);
|
|
2540
|
+
if (resolve2(sourceDir) !== resolve2(projectDir)) {
|
|
2541
|
+
rebaseEntryAuthoredAssetPaths(document, sourceDir, projectDir);
|
|
2542
|
+
}
|
|
2543
|
+
for (const el of [...document.querySelectorAll('link[rel="stylesheet"]')]) {
|
|
2544
|
+
const href = el.getAttribute("href");
|
|
2545
|
+
if (!href || !isRelativeUrl(href) || cssStyleMergeKey(el) === void 0)
|
|
2546
|
+
continue;
|
|
2547
|
+
if (el.hasAttribute("disabled"))
|
|
2548
|
+
continue;
|
|
2549
|
+
const cssPath = resolveEntryPath(href);
|
|
2550
|
+
if (!cssPath)
|
|
2551
|
+
continue;
|
|
2552
|
+
const css = safeReadFile(cssPath);
|
|
2553
|
+
if (css == null)
|
|
2554
|
+
continue;
|
|
2555
|
+
const style = document.createElement("style");
|
|
2556
|
+
for (const name of ["media", "title"]) {
|
|
2557
|
+
const value = el.getAttribute(name);
|
|
2558
|
+
if (value !== null)
|
|
2559
|
+
style.setAttribute(name, value);
|
|
2560
|
+
}
|
|
2561
|
+
style.textContent = inlineCssFile(css, dirname(cssPath), projectDir);
|
|
2562
|
+
el.replaceWith(style);
|
|
2563
|
+
}
|
|
2564
|
+
const rootScripts = options?.sceneParts ? [
|
|
2565
|
+
...document.querySelectorAll(`script:not([${RUNTIME_BOOTSTRAP_ATTR}])`),
|
|
2566
|
+
...[...document.querySelectorAll("template")].flatMap((t) => [
|
|
2567
|
+
...t.content.querySelectorAll("script")
|
|
2568
|
+
])
|
|
2569
|
+
].map((el) => {
|
|
2570
|
+
const src = el.getAttribute("src");
|
|
2571
|
+
const path = src && isRelativeUrl(src) ? resolveEntryPath(src) : null;
|
|
2572
|
+
return src ? path && safeReadFile(path) || "" : el.textContent || "";
|
|
2573
|
+
}) : [];
|
|
2574
|
+
const trackedCompositionHosts = getBundledTrackedCompositionHosts(document);
|
|
2575
|
+
const hostIdentityByElement = assignBundledRuntimeCompositionIds(trackedCompositionHosts);
|
|
2576
|
+
const subCompositionHosts = trackedCompositionHosts.filter((host) => host.hasAttribute("data-composition-src"));
|
|
2577
|
+
const subCompResult = inlineSubCompositions(document, subCompositionHosts, {
|
|
2578
|
+
resolveHtml: (srcPath) => {
|
|
2579
|
+
if (!isRelativeUrl(srcPath))
|
|
2580
|
+
return null;
|
|
2581
|
+
const compPath = resolveEntryPath(srcPath);
|
|
2582
|
+
const html = compPath ? safeReadFile(compPath) : null;
|
|
2583
|
+
return html === null ? null : readSource(html);
|
|
2584
|
+
},
|
|
2585
|
+
parseHtml: parseHTMLContent,
|
|
2586
|
+
hostIdentityMap: hostIdentityByElement,
|
|
2587
|
+
rewriteInlineStyles: true,
|
|
2588
|
+
// A sub-composition's SIBLING assets (a stylesheet next to it) must be
|
|
2589
|
+
// re-pointed at its own directory when its content moves to the root
|
|
2590
|
+
// document; project-root refs with no such sibling stay as authored.
|
|
2591
|
+
assetExists: (path) => {
|
|
2592
|
+
const resolved = resolveEntryPath(path);
|
|
2593
|
+
if (resolved)
|
|
2594
|
+
noteRead(resolved);
|
|
2595
|
+
return resolved !== null && existsSync(resolved);
|
|
2596
|
+
},
|
|
2597
|
+
flattenInnerRoot: prepareFlattenedInnerRoot,
|
|
2598
|
+
tagScenes: options?.sceneParts === true,
|
|
2599
|
+
readVariableDefaults: readDeclaredDefaults,
|
|
2600
|
+
parseHostVariables: parseHostVariableValues,
|
|
2601
|
+
buildScopeSelector: (compId) => cssAttributeSelector("data-composition-id", compId),
|
|
2602
|
+
scriptErrorLabel: "[HyperFrames] composition script error:",
|
|
2603
|
+
onMissingComposition: (srcPath, reason) => {
|
|
2604
|
+
console.warn(`[Bundler] Skipping sub-composition "${srcPath}": ${reason ?? "the file could not be found"}.`);
|
|
2605
|
+
}
|
|
2606
|
+
});
|
|
2607
|
+
refuseSwapsReachedByRootScripts(document, rootScripts);
|
|
2608
|
+
const styleRuns = [];
|
|
2609
|
+
subCompResult.styles.forEach((style, i) => pushRun(styleRuns, subCompResult.styleScenes[i], style));
|
|
2610
|
+
const scriptRuns = [];
|
|
2611
|
+
const compStyleChunks = [];
|
|
2612
|
+
const compScriptChunks = [];
|
|
2613
|
+
const compExternalLinks = [...subCompResult.externalLinks];
|
|
2614
|
+
const compVariablesByComp = {
|
|
2615
|
+
...subCompResult.variablesByComp
|
|
2616
|
+
};
|
|
2617
|
+
const seenCompScriptSrcs = /* @__PURE__ */ new Set();
|
|
2618
|
+
for (const scriptItem of subCompResult.scriptItems) {
|
|
2619
|
+
if (scriptItem.kind === "inline") {
|
|
2620
|
+
pushRun(scriptRuns, scriptItem.scene, scriptItem.content);
|
|
2621
|
+
continue;
|
|
2622
|
+
}
|
|
2623
|
+
const extSrc = scriptItem.src;
|
|
2624
|
+
if (scriptItem.integrity?.trim()) {
|
|
2625
|
+
ensureExternalScriptTag(document, extSrc, scriptItem);
|
|
2626
|
+
seenCompScriptSrcs.add(extSrc);
|
|
2627
|
+
continue;
|
|
2628
|
+
}
|
|
2629
|
+
if (seenCompScriptSrcs.has(extSrc))
|
|
2630
|
+
continue;
|
|
2631
|
+
seenCompScriptSrcs.add(extSrc);
|
|
2632
|
+
if (isRelativeUrl(extSrc) && scriptItem.type !== "module") {
|
|
2633
|
+
const jsPath = resolveEntryPath(extSrc);
|
|
2634
|
+
const js = jsPath ? safeReadFile(jsPath) : null;
|
|
2635
|
+
if (js != null) {
|
|
2636
|
+
const chunk = () => preserveLocalScriptIntegrity(document, extSrc, resolveEntryPath) ? "" : js;
|
|
2637
|
+
pushRun(scriptRuns, scriptItem.scene, chunk);
|
|
2638
|
+
continue;
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
ensureExternalScriptTag(document, extSrc, scriptItem);
|
|
2642
|
+
}
|
|
2643
|
+
const candidateInlineHosts = trackedCompositionHosts.filter((host) => !host.hasAttribute("data-composition-src"));
|
|
2644
|
+
for (const templateEl of [...document.querySelectorAll("template[id]")]) {
|
|
2645
|
+
const templateId = templateEl.getAttribute("id") || "";
|
|
2646
|
+
const match = templateId.match(/^(.+)-template$/);
|
|
2647
|
+
if (!match)
|
|
2648
|
+
continue;
|
|
2649
|
+
const compId = match[1];
|
|
2650
|
+
if (!compId)
|
|
2651
|
+
continue;
|
|
2652
|
+
const hosts = candidateInlineHosts.filter((host) => hostIdentityByElement.get(host)?.authoredCompositionId === compId && host.children.length === 0);
|
|
2653
|
+
if (hosts.length === 0)
|
|
2654
|
+
continue;
|
|
2655
|
+
const templateHtml = templateEl.innerHTML || "";
|
|
2656
|
+
for (const host of hosts) {
|
|
2657
|
+
const hostIdentity = hostIdentityByElement.get(host);
|
|
2658
|
+
const runtimeCompId = hostIdentity?.runtimeCompositionId || compId;
|
|
2659
|
+
const innerDoc = parseHTMLContent(templateHtml);
|
|
2660
|
+
const innerRoot = queryByAttr(innerDoc, "data-composition-id", compId);
|
|
2661
|
+
const authoredRootId = innerRoot?.getAttribute("id")?.trim() || null;
|
|
2662
|
+
const runtimeScope = runtimeCompId ? cssAttributeSelector("data-composition-id", runtimeCompId) : "";
|
|
2663
|
+
const mergedVariables = runtimeCompId ? parseHostVariableValues(host) : {};
|
|
2664
|
+
if (runtimeCompId && Object.keys(mergedVariables).length > 0) {
|
|
2665
|
+
compVariablesByComp[runtimeCompId] = mergedVariables;
|
|
2666
|
+
}
|
|
2667
|
+
if (runtimeCompId) {
|
|
2668
|
+
warnUnknownEnumValues(innerDoc.documentElement, mergedVariables, runtimeCompId);
|
|
2669
|
+
warnUnknownEnumValues(innerRoot, mergedVariables, runtimeCompId);
|
|
2670
|
+
}
|
|
2671
|
+
pushSubCompVariableStyles(innerDoc, innerRoot, mergedVariables, runtimeScope, compStyleChunks);
|
|
2672
|
+
if (innerRoot) {
|
|
2673
|
+
for (const styleEl of [...innerRoot.querySelectorAll("style")]) {
|
|
2674
|
+
if (cssStyleMergeKey(styleEl) === void 0)
|
|
2675
|
+
continue;
|
|
2676
|
+
const css = styleEl.textContent || "";
|
|
2677
|
+
compStyleChunks.push(compositionStyle(styleEl, compId ? scopeCssToComposition(css, compId, runtimeScope, authoredRootId, {
|
|
2678
|
+
scopeRootSelectors: true
|
|
2679
|
+
}) : css));
|
|
2680
|
+
styleEl.remove();
|
|
2681
|
+
}
|
|
2682
|
+
hoistCompositionScripts(innerRoot, {
|
|
2683
|
+
projectDir,
|
|
2684
|
+
document,
|
|
2685
|
+
compId,
|
|
2686
|
+
runtimeScope,
|
|
2687
|
+
runtimeCompId,
|
|
2688
|
+
authoredRootId: authoredRootId ?? void 0,
|
|
2689
|
+
seenCompScriptSrcs,
|
|
2690
|
+
compScriptChunks
|
|
2691
|
+
});
|
|
2692
|
+
const innerW = innerRoot.getAttribute("data-width");
|
|
2693
|
+
const innerH = innerRoot.getAttribute("data-height");
|
|
2694
|
+
if (innerW && !host.getAttribute("data-width"))
|
|
2695
|
+
host.setAttribute("data-width", innerW);
|
|
2696
|
+
if (innerH && !host.getAttribute("data-height"))
|
|
2697
|
+
host.setAttribute("data-height", innerH);
|
|
2698
|
+
const preparedInnerRoot = prepareFlattenedInnerRoot(innerRoot);
|
|
2699
|
+
host.innerHTML = preparedInnerRoot.outerHTML || "";
|
|
2700
|
+
} else {
|
|
2701
|
+
for (const styleEl of [...innerDoc.querySelectorAll("style")]) {
|
|
2702
|
+
if (cssStyleMergeKey(styleEl) === void 0)
|
|
2703
|
+
continue;
|
|
2704
|
+
const css = styleEl.textContent || "";
|
|
2705
|
+
compStyleChunks.push(compositionStyle(styleEl, compId ? scopeCssToComposition(css, compId, runtimeScope, void 0, {
|
|
2706
|
+
scopeRootSelectors: true
|
|
2707
|
+
}) : css));
|
|
2708
|
+
styleEl.remove();
|
|
2709
|
+
}
|
|
2710
|
+
hoistCompositionScripts(innerDoc, {
|
|
2711
|
+
projectDir,
|
|
2712
|
+
document,
|
|
2713
|
+
compId,
|
|
2714
|
+
runtimeScope,
|
|
2715
|
+
runtimeCompId,
|
|
2716
|
+
authoredRootId: void 0,
|
|
2717
|
+
seenCompScriptSrcs,
|
|
2718
|
+
compScriptChunks
|
|
2719
|
+
});
|
|
2720
|
+
host.innerHTML = innerDoc.body.innerHTML || "";
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
templateEl.remove();
|
|
2724
|
+
}
|
|
2725
|
+
for (const el of [...document.querySelectorAll("script[src]")]) {
|
|
2726
|
+
const src = el.getAttribute("src");
|
|
2727
|
+
if (!src || !isRelativeUrl(src))
|
|
2728
|
+
continue;
|
|
2729
|
+
if (preserveLocalScriptIntegrity(document, src, resolveEntryPath))
|
|
2730
|
+
continue;
|
|
2731
|
+
if ((el.getAttribute("type") || "").trim().toLowerCase() === "module")
|
|
2732
|
+
continue;
|
|
2733
|
+
const jsPath = resolveEntryPath(src);
|
|
2734
|
+
const js = jsPath ? safeReadFile(jsPath) : null;
|
|
2735
|
+
if (js == null)
|
|
2736
|
+
continue;
|
|
2737
|
+
el.setAttribute(INLINED_FILE_ATTR, src);
|
|
2738
|
+
el.removeAttribute("src");
|
|
2739
|
+
el.textContent = js;
|
|
2740
|
+
}
|
|
2741
|
+
for (const link of compExternalLinks)
|
|
2742
|
+
ensureExternalLinkTag(document, link);
|
|
2743
|
+
for (const css of compStyleChunks)
|
|
2744
|
+
pushRun(styleRuns, void 0, css);
|
|
2745
|
+
for (const chunk of compScriptChunks)
|
|
2746
|
+
pushRun(scriptRuns, void 0, chunk);
|
|
2747
|
+
const variablesByCompScript = buildVariablesByCompScript(compVariablesByComp);
|
|
2748
|
+
if (variablesByCompScript) {
|
|
2749
|
+
if (scriptRuns[0] && !scriptRuns[0].scene)
|
|
2750
|
+
scriptRuns[0].chunks.unshift(variablesByCompScript);
|
|
2751
|
+
else
|
|
2752
|
+
scriptRuns.unshift({ chunks: [variablesByCompScript] });
|
|
2753
|
+
}
|
|
2754
|
+
for (const { scene, chunks } of styleRuns) {
|
|
2755
|
+
const join = scene ? joinCssHoistingImports : (css) => css.join("\n\n");
|
|
2756
|
+
for (const style of styleElementsFor(document, chunks, join)) {
|
|
2757
|
+
if (scene)
|
|
2758
|
+
style.setAttribute(SCENE_PART_ATTR, scene);
|
|
2759
|
+
document.head.appendChild(style);
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
for (const { scene, chunks } of scriptRuns) {
|
|
2763
|
+
const script = document.createElement("script");
|
|
2764
|
+
if (scene)
|
|
2765
|
+
script.setAttribute(SCENE_PART_ATTR, scene);
|
|
2766
|
+
script.textContent = joinJsChunks(chunks.map((chunk) => typeof chunk === "string" ? chunk : chunk()));
|
|
2767
|
+
document.body.appendChild(script);
|
|
2768
|
+
}
|
|
2769
|
+
emitMountedModuleScripts(document, subCompResult.importMaps, subCompResult.moduleScripts);
|
|
2770
|
+
emitRootCompositionVariableStyles(document, compVariablesByComp);
|
|
2771
|
+
enforceCompositionPixelSizing(document);
|
|
2772
|
+
autoHealMissingCompositionIds(document);
|
|
2773
|
+
coalesceHeadStylesAndBodyScripts(document);
|
|
2774
|
+
for (const el of document.querySelectorAll(`script[${INLINED_FILE_ATTR}]`)) {
|
|
2775
|
+
const js = el.textContent ?? "";
|
|
2776
|
+
el.textContent = escapeInlineScriptSource(isJavaScriptType(el) ? stripJsCommentsParserSafe(js) : js);
|
|
2777
|
+
}
|
|
2778
|
+
deferScriptsUntilFonts(document, (el) => el.hasAttribute(RUNTIME_BOOTSTRAP_ATTR));
|
|
2779
|
+
injectTextRenderingRule(document);
|
|
2780
|
+
const inlineAssets = options?.inlineAssets !== false;
|
|
2781
|
+
for (const el of [...document.querySelectorAll("[src], [href], [poster], [xlink\\:href]")]) {
|
|
2782
|
+
for (const attr of ["src", "href", "poster", "xlink:href"]) {
|
|
2783
|
+
const value = el.getAttribute(attr);
|
|
2784
|
+
if (!value)
|
|
2785
|
+
continue;
|
|
2786
|
+
if (isExternalSvgFragmentUse(el, attr, value))
|
|
2787
|
+
continue;
|
|
2788
|
+
const inlined = maybeInlineRelativeAssetUrl(value, projectDir, inlineAssets);
|
|
2789
|
+
if (inlined)
|
|
2790
|
+
el.setAttribute(attr, inlined);
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
for (const el of [...document.querySelectorAll("[srcset]")]) {
|
|
2794
|
+
const srcset = el.getAttribute("srcset");
|
|
2795
|
+
if (srcset)
|
|
2796
|
+
el.setAttribute("srcset", rewriteSrcsetWithInlinedAssets(srcset, projectDir, inlineAssets));
|
|
2797
|
+
}
|
|
2798
|
+
if (!options?.sceneParts) {
|
|
2799
|
+
const liveStyles = [...document.querySelectorAll("style")].filter(isAlwaysAppliedStyle);
|
|
2800
|
+
const dedupedStyles = dedupeFontFaceRules(liveStyles.map((el) => el.textContent || ""));
|
|
2801
|
+
liveStyles.forEach((el, i) => {
|
|
2802
|
+
el.textContent = dedupedStyles[i] ?? "";
|
|
2803
|
+
});
|
|
2804
|
+
}
|
|
2805
|
+
for (const styleEl of document.querySelectorAll("style")) {
|
|
2806
|
+
styleEl.textContent = rewriteCssUrlsWithInlinedAssets(styleEl.textContent || "", projectDir, inlineAssets);
|
|
2807
|
+
}
|
|
2808
|
+
for (const el of [...document.querySelectorAll("[style]")]) {
|
|
2809
|
+
el.setAttribute("style", rewriteCssUrlsWithInlinedAssets(el.getAttribute("style") || "", projectDir, inlineAssets));
|
|
2810
|
+
}
|
|
2811
|
+
if (inlineAssets && options?.inlineColorGradingLuts !== false) {
|
|
2812
|
+
for (const el of [...document.querySelectorAll(`[${HF_COLOR_GRADING_ATTR}]`)]) {
|
|
2813
|
+
const value = el.getAttribute(HF_COLOR_GRADING_ATTR);
|
|
2814
|
+
if (value) {
|
|
2815
|
+
el.setAttribute(HF_COLOR_GRADING_ATTR, rewriteColorGradingLutWithInlinedAssets(value, projectDir));
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
return document.toString();
|
|
2820
|
+
}
|
|
2821
|
+
function cssSafeVariableValue(value) {
|
|
2822
|
+
return sanitizeCssValue(String(value)).replace(/</g, "\\3c ");
|
|
2823
|
+
}
|
|
2824
|
+
function compositionVariablesCssBlock(variables, selector) {
|
|
2825
|
+
const lines = [];
|
|
2826
|
+
for (const [id, value] of Object.entries(variables)) {
|
|
2827
|
+
if (typeof value === "string" && value !== "" || typeof value === "number") {
|
|
2828
|
+
lines.push(` ${cssVariableName(id)}: ${cssSafeVariableValue(value)};`);
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
if (lines.length === 0)
|
|
2832
|
+
return null;
|
|
2833
|
+
return `${selector} {
|
|
2834
|
+
${lines.join("\n")}
|
|
2835
|
+
}`;
|
|
2836
|
+
}
|
|
2837
|
+
function emitRootCompositionVariableStyles(document, variablesByComp = {}, overrides = {}) {
|
|
2838
|
+
const authoredDefines = authoredDefinesPredicate(document);
|
|
2839
|
+
const layerFor = makeVariableLayer(authoredDefines, overrides);
|
|
2840
|
+
const rules = [
|
|
2841
|
+
...hostScopedVariableRules(variablesByComp, overrides, authoredDefines),
|
|
2842
|
+
...rootDeclaredVariableRules(document, layerFor),
|
|
2843
|
+
...declarerVariableRules(document, layerFor)
|
|
2844
|
+
];
|
|
2845
|
+
if (rules.length === 0)
|
|
2846
|
+
return false;
|
|
2847
|
+
const style = document.createElement("style");
|
|
2848
|
+
style.setAttribute("data-hf-composition-variables", "");
|
|
2849
|
+
style.textContent = rules.join("\n\n");
|
|
2850
|
+
document.head.appendChild(style);
|
|
2851
|
+
return true;
|
|
2852
|
+
}
|
|
2853
|
+
function authoredDefinesPredicate(document) {
|
|
2854
|
+
const authoredCss = [...document.querySelectorAll("style:not([data-hf-composition-variables])")].map((s) => s.textContent || "").join("\n");
|
|
2855
|
+
return (id) => new RegExp(`${cssVariableName(id)}\\s*:`).test(authoredCss);
|
|
2856
|
+
}
|
|
2857
|
+
function makeVariableLayer(authoredDefines, overrides) {
|
|
2858
|
+
return (declared, hostValues) => {
|
|
2859
|
+
const out = {};
|
|
2860
|
+
for (const [id, value] of Object.entries(declared)) {
|
|
2861
|
+
if (!authoredDefines(id))
|
|
2862
|
+
out[id] = value;
|
|
2863
|
+
}
|
|
2864
|
+
for (const [id, value] of Object.entries(hostValues)) {
|
|
2865
|
+
if (id in declared)
|
|
2866
|
+
out[id] = value;
|
|
2867
|
+
}
|
|
2868
|
+
for (const [id, value] of Object.entries(overrides)) {
|
|
2869
|
+
if (id in declared || id in hostValues)
|
|
2870
|
+
out[id] = value;
|
|
2871
|
+
}
|
|
2872
|
+
return out;
|
|
2873
|
+
};
|
|
2874
|
+
}
|
|
2875
|
+
function hostScopedVariableRules(variablesByComp, overrides, authoredDefines) {
|
|
2876
|
+
const rules = [];
|
|
2877
|
+
for (const [compId, vars] of Object.entries(variablesByComp)) {
|
|
2878
|
+
const withOverrides = {};
|
|
2879
|
+
for (const [id, value] of Object.entries(vars)) {
|
|
2880
|
+
if (!authoredDefines(id))
|
|
2881
|
+
withOverrides[id] = value;
|
|
2882
|
+
}
|
|
2883
|
+
for (const [id, value] of Object.entries(overrides)) {
|
|
2884
|
+
if (id in vars)
|
|
2885
|
+
withOverrides[id] = value;
|
|
2886
|
+
}
|
|
2887
|
+
const rule = compositionVariablesCssBlock(withOverrides, cssAttributeSelector("data-composition-id", compId));
|
|
2888
|
+
if (rule)
|
|
2889
|
+
rules.push(rule);
|
|
2890
|
+
}
|
|
2891
|
+
return rules;
|
|
2892
|
+
}
|
|
2893
|
+
function rootDeclaredVariableRules(document, layerFor) {
|
|
2894
|
+
const htmlDeclared = readDeclaredDefaults(document.documentElement);
|
|
2895
|
+
const htmlRule = compositionVariablesCssBlock(layerFor(htmlDeclared, {}), ":root");
|
|
2896
|
+
return htmlRule ? [htmlRule] : [];
|
|
2897
|
+
}
|
|
2898
|
+
function declarerVariableRules(document, layerFor) {
|
|
2899
|
+
const rules = [];
|
|
2900
|
+
let markerSeq = 0;
|
|
2901
|
+
for (const el of [...document.querySelectorAll("[data-composition-variables]")]) {
|
|
2902
|
+
const declared = readDeclaredDefaults(el);
|
|
2903
|
+
const hostEl = typeof el.closest === "function" ? el.parentElement?.closest("[data-variable-values]") : null;
|
|
2904
|
+
const hostValues = hostEl ? parseHostVariableValues(hostEl) : {};
|
|
2905
|
+
const vars = layerFor(declared, hostValues);
|
|
2906
|
+
if (Object.keys(vars).length === 0)
|
|
2907
|
+
continue;
|
|
2908
|
+
markerSeq += 1;
|
|
2909
|
+
el.setAttribute("data-hf-var-scope", String(markerSeq));
|
|
2910
|
+
const rule = compositionVariablesCssBlock(vars, `[data-hf-var-scope="${markerSeq}"]`);
|
|
2911
|
+
if (rule)
|
|
2912
|
+
rules.push(rule);
|
|
2913
|
+
}
|
|
2914
|
+
return rules;
|
|
2915
|
+
}
|
|
2916
|
+
function pushSubCompVariableStyles(innerDoc, innerRoot, mergedVariables, runtimeScope, compStyleChunks) {
|
|
2917
|
+
if (!runtimeScope)
|
|
2918
|
+
return;
|
|
2919
|
+
const declaredForCss = readDeclaredDefaults(innerDoc.documentElement);
|
|
2920
|
+
const innerRootForVars = innerRoot ?? innerDoc.querySelector("[data-composition-variables]");
|
|
2921
|
+
if (innerRootForVars)
|
|
2922
|
+
Object.assign(declaredForCss, readDeclaredDefaults(innerRootForVars));
|
|
2923
|
+
const cssVars = compositionVariablesCssBlock({ ...declaredForCss, ...mergedVariables }, runtimeScope);
|
|
2924
|
+
if (cssVars)
|
|
2925
|
+
compStyleChunks.push({ css: cssVars, media: null, title: null });
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
// ../core/dist/compiler/htmlParityContract.js
|
|
2929
|
+
function finiteAttribute(element, name) {
|
|
2930
|
+
const raw = element.getAttribute(name);
|
|
2931
|
+
if (raw === null || raw.trim() === "")
|
|
2932
|
+
return null;
|
|
2933
|
+
const value = Number(raw);
|
|
2934
|
+
return Number.isFinite(value) ? value : null;
|
|
2935
|
+
}
|
|
2936
|
+
function timing(element) {
|
|
2937
|
+
const start = finiteAttribute(element, "data-start") ?? 0;
|
|
2938
|
+
const duration = finiteAttribute(element, "data-duration") ?? (() => {
|
|
2939
|
+
const end = finiteAttribute(element, "data-end");
|
|
2940
|
+
return end === null ? null : Math.max(0, end - start);
|
|
2941
|
+
})();
|
|
2942
|
+
return {
|
|
2943
|
+
start,
|
|
2944
|
+
duration,
|
|
2945
|
+
trackIndex: finiteAttribute(element, "data-track-index") ?? finiteAttribute(element, "data-layer")
|
|
2946
|
+
};
|
|
2947
|
+
}
|
|
2948
|
+
function normalizeJson(value) {
|
|
2949
|
+
if (value === null)
|
|
2950
|
+
return null;
|
|
2951
|
+
try {
|
|
2952
|
+
return JSON.stringify(canonicalizeJson(JSON.parse(value)));
|
|
2953
|
+
} catch {
|
|
2954
|
+
return value.trim();
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
function canonicalizeJson(value) {
|
|
2958
|
+
if (Array.isArray(value))
|
|
2959
|
+
return value.map(canonicalizeJson);
|
|
2960
|
+
if (value === null || typeof value !== "object")
|
|
2961
|
+
return value;
|
|
2962
|
+
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, canonicalizeJson(nested)]));
|
|
2963
|
+
}
|
|
2964
|
+
function styleSignatures(document) {
|
|
2965
|
+
return [...document.querySelectorAll("style")].map((style) => style.textContent ?? "").flatMap((css) => css.match(/[^{}]+\{[^{}]*--parity-contract\s*:[^{}]+\}/g) ?? []).map((rule) => rule.replace(/\s+/g, " ").replace(/\s*([:;{},])\s*/g, "$1").trim()).sort();
|
|
2966
|
+
}
|
|
2967
|
+
function parityFontFamilies(html) {
|
|
2968
|
+
const families = /* @__PURE__ */ new Set();
|
|
2969
|
+
for (const match of html.matchAll(/font-family\s*:\s*([^;}]+)/gi)) {
|
|
2970
|
+
for (const family of match[1].split(",")) {
|
|
2971
|
+
const normalized = family.trim().replace(/^['"]|['"]$/g, "");
|
|
2972
|
+
if (normalized.startsWith("Parity"))
|
|
2973
|
+
families.add(normalized);
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
return [...families].sort();
|
|
2977
|
+
}
|
|
2978
|
+
function resources(document) {
|
|
2979
|
+
const resources2 = [];
|
|
2980
|
+
for (const [index, element] of [
|
|
2981
|
+
...document.querySelectorAll("[src], [href], [poster]")
|
|
2982
|
+
].entries()) {
|
|
2983
|
+
for (const attribute of ["src", "href", "poster"]) {
|
|
2984
|
+
const value = element.getAttribute(attribute)?.trim();
|
|
2985
|
+
if (!value)
|
|
2986
|
+
continue;
|
|
2987
|
+
if (element.tagName.toLowerCase() === "script" && /hyperframes|runtime/i.test(value))
|
|
2988
|
+
continue;
|
|
2989
|
+
resources2.push({
|
|
2990
|
+
identity: element.getAttribute("data-hf-id") ?? element.getAttribute("id") ?? `${element.tagName.toLowerCase()}[${index}]`,
|
|
2991
|
+
attribute,
|
|
2992
|
+
locality: /^https?:\/\//i.test(value) ? "remote" : "local"
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
return resources2.sort((left, right) => `${left.identity}:${left.attribute}`.localeCompare(`${right.identity}:${right.attribute}`));
|
|
2997
|
+
}
|
|
2998
|
+
function extractCompiledHtmlParityContract(html) {
|
|
2999
|
+
const { document } = parseHTML(html);
|
|
3000
|
+
const compositions = [...document.querySelectorAll("[data-composition-id]")].map((element) => {
|
|
3001
|
+
const resolved = timing(element);
|
|
3002
|
+
return {
|
|
3003
|
+
id: element.getAttribute("data-composition-id") ?? "",
|
|
3004
|
+
originalId: element.getAttribute("data-hf-original-composition-id"),
|
|
3005
|
+
...resolved,
|
|
3006
|
+
width: finiteAttribute(element, "data-width"),
|
|
3007
|
+
height: finiteAttribute(element, "data-height"),
|
|
3008
|
+
variableValues: normalizeJson(element.getAttribute("data-variable-values"))
|
|
3009
|
+
};
|
|
3010
|
+
});
|
|
3011
|
+
const timedElements = [
|
|
3012
|
+
...document.querySelectorAll("[data-start], [data-duration], [data-end], [data-track-index], [data-layer]")
|
|
3013
|
+
].filter((element) => !element.hasAttribute("data-composition-id")).map((element, index) => ({
|
|
3014
|
+
identity: element.getAttribute("data-hf-id") ?? element.getAttribute("id") ?? `${element.tagName.toLowerCase()}[${index}]`,
|
|
3015
|
+
...timing(element)
|
|
3016
|
+
}));
|
|
3017
|
+
return {
|
|
3018
|
+
compositions,
|
|
3019
|
+
timedElements,
|
|
3020
|
+
authoredStyleSignatures: styleSignatures(document),
|
|
3021
|
+
parityFontFamilies: parityFontFamilies(html),
|
|
3022
|
+
resources: resources(document),
|
|
3023
|
+
runtimeBootstrap: /__hyperframes|data-hyperframes-(?:preview-)?runtime/i.test(html),
|
|
3024
|
+
variableBootstrap: /__hfVariables(?:ByComp)?/.test(html)
|
|
3025
|
+
};
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3028
|
+
// ../core/dist/compiler/scenePartsManifest.js
|
|
3029
|
+
import { createHash } from "crypto";
|
|
3030
|
+
var hash = (text) => createHash("sha1").update(text).digest("hex").slice(0, 16);
|
|
3031
|
+
function addScenePartsManifest(html, ignore = []) {
|
|
3032
|
+
const doc = parseHTMLContent(html);
|
|
3033
|
+
const parts = [...doc.querySelectorAll(`[${SCENE_PART_ATTR}]`)];
|
|
3034
|
+
if (parts.length === 0)
|
|
3035
|
+
return html;
|
|
3036
|
+
const byScene = /* @__PURE__ */ new Map();
|
|
3037
|
+
for (const el of parts) {
|
|
3038
|
+
const scene = el.getAttribute(SCENE_PART_ATTR) ?? "";
|
|
3039
|
+
byScene.set(scene, [...byScene.get(scene) ?? [], el.outerHTML]);
|
|
3040
|
+
}
|
|
3041
|
+
for (const el of parts)
|
|
3042
|
+
el.replaceWith(doc.createComment(`hf-scene:${el.getAttribute(SCENE_PART_ATTR)}`));
|
|
3043
|
+
for (const el of ignore.flatMap((sel) => [...doc.querySelectorAll(sel)]))
|
|
3044
|
+
el.remove();
|
|
3045
|
+
const manifest = {
|
|
3046
|
+
shared: hash(doc.toString()),
|
|
3047
|
+
scenes: Object.fromEntries([...byScene].map(([scene, html2]) => [scene, hash(html2.join("\n"))]))
|
|
3048
|
+
};
|
|
3049
|
+
const content = JSON.stringify(manifest).replace(/&/g, "&").replace(/"/g, """);
|
|
3050
|
+
return injectTagsAtHeadStart(html, `<meta name="${SCENE_PARTS_META}" content="${content}">`);
|
|
3051
|
+
}
|
|
3052
|
+
|
|
3053
|
+
export {
|
|
3054
|
+
compileHtml,
|
|
3055
|
+
inlineScriptRuns,
|
|
3056
|
+
AFTER_FONTS_SCRIPT_TYPE,
|
|
3057
|
+
deferScriptsUntilFonts,
|
|
3058
|
+
cssStyleMergeKey,
|
|
3059
|
+
headStyleRuns,
|
|
3060
|
+
compositionStyle,
|
|
3061
|
+
styleElementsFor,
|
|
3062
|
+
ensureExternalScriptTag,
|
|
3063
|
+
emitMountedModuleScripts,
|
|
3064
|
+
FLATTENED_INNER_ROOT_STRIP_ATTRS,
|
|
3065
|
+
scopeCssToComposition,
|
|
3066
|
+
wrapScopedCompositionScript,
|
|
3067
|
+
buildVariablesByCompScript,
|
|
3068
|
+
validateHyperframeHtmlContract,
|
|
3069
|
+
ensureExternalLinkTag,
|
|
3070
|
+
inlineSubCompositions,
|
|
3071
|
+
EXCLUDED_TAGS,
|
|
3072
|
+
mintHfId,
|
|
3073
|
+
walkCompositionDescendants,
|
|
3074
|
+
ensureHfIds,
|
|
3075
|
+
assignBundledRuntimeCompositionIds,
|
|
3076
|
+
prepareFlattenedInnerRoot,
|
|
3077
|
+
bundleToSingleHtml,
|
|
3078
|
+
emitRootCompositionVariableStyles,
|
|
3079
|
+
extractCompiledHtmlParityContract,
|
|
3080
|
+
addScenePartsManifest
|
|
3081
|
+
};
|