@dioramajs/diorama 0.0.0-stage → 0.1.2
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 +21 -0
- package/README.md +65 -2
- package/bin/diorama.mjs +7 -0
- package/dist/assets.d.ts +1 -0
- package/dist/assets.js +1 -0
- package/dist/astro-client.d.ts +51 -0
- package/dist/astro-client.d.ts.map +1 -0
- package/dist/astro-client.js +255 -0
- package/dist/astro-client.js.map +1 -0
- package/dist/astro.d.ts +108 -0
- package/dist/astro.d.ts.map +1 -0
- package/dist/astro.js +66 -0
- package/dist/astro.js.map +1 -0
- package/dist/attach-CrYQw3kS.js +120 -0
- package/dist/attach-CrYQw3kS.js.map +1 -0
- package/dist/audio-graph.d.ts +1 -0
- package/dist/audio-graph.js +1 -0
- package/dist/audio.d.ts +1 -0
- package/dist/audio.js +1 -0
- package/dist/backgrounds.d.ts +1 -0
- package/dist/backgrounds.js +1 -0
- package/dist/blocks.d.ts +1 -0
- package/dist/blocks.js +1 -0
- package/dist/cdn/DRACOLoader-CLIkZhHm.js +2 -0
- package/dist/cdn/GLTFLoader-B6YCnVYD.js +1 -0
- package/dist/cdn/KTX2Loader-T0eS_4c7.js +2 -0
- package/dist/cdn/RoomEnvironment-DFh6TGKE.js +1 -0
- package/dist/cdn/SkeletonUtils-C0RbSNS1.js +1 -0
- package/dist/cdn/ambient-DIZGYvSi.js +1 -0
- package/dist/cdn/assemble-MJ_EvuR8.js +1 -0
- package/dist/cdn/auto.js +3 -0
- package/dist/cdn/beam-CRy7xI4S.js +1 -0
- package/dist/cdn/beat-DLeilsFn.js +1 -0
- package/dist/cdn/bend-D8TNkUYH.js +1 -0
- package/dist/cdn/bitmap-B-zWPVnC-u-0Jd8aY.js +1 -0
- package/dist/cdn/blinds-DTbiwlQc.js +1 -0
- package/dist/cdn/blobs-CtJwaqgN.js +1 -0
- package/dist/cdn/book-Ce25Qhm7.js +1 -0
- package/dist/cdn/box-BRuNrJbg.js +1 -0
- package/dist/cdn/carousel-Du9hL4Hj.js +1 -0
- package/dist/cdn/chart-BJBhQqS9.js +1 -0
- package/dist/cdn/chroma-BIq-O9IL.js +1 -0
- package/dist/cdn/click-vRJzpDy5-rjDL10Io.js +1 -0
- package/dist/cdn/clock-DsSGeylm-B-eNqNgy.js +1 -0
- package/dist/cdn/clouds-DtluDSlt.js +1 -0
- package/dist/cdn/coin-B5K_aStV.js +1 -0
- package/dist/cdn/compare-BfUVwqGR.js +1 -0
- package/dist/cdn/confetti-W7jfbR94.js +1 -0
- package/dist/cdn/contain-DZQSiTDn-QEMwSsdy.js +1 -0
- package/dist/cdn/counter-CSEioZKX.js +1 -0
- package/dist/cdn/cover-5obZq-u-.js +2 -0
- package/dist/cdn/coverflow-DO-FebEb.js +1 -0
- package/dist/cdn/curtain-CbAuf4ZU.js +1 -0
- package/dist/cdn/curtain-DNk0Au1K-D9d80d17.js +1 -0
- package/dist/cdn/deck-C1kqdqrs-Cdh9s95v.js +1 -0
- package/dist/cdn/define-BwEwaSnA-xcf1zhk4.js +4 -0
- package/dist/cdn/dev-CoKR705i.js +1 -0
- package/dist/cdn/device-DOPGKWbR.js +1 -0
- package/dist/cdn/dist-7b15V3X3.js +1 -0
- package/dist/cdn/dist-BMV8xl5-.js +1 -0
- package/dist/cdn/dist-BeaOPyWn.js +1 -0
- package/dist/cdn/dist-BzvtjGBm.js +1 -0
- package/dist/cdn/dist-CQQi9P-c.js +1 -0
- package/dist/cdn/dist-CvtbpzPe.js +1 -0
- package/dist/cdn/dist-DFFVgRA4.js +1 -0
- package/dist/cdn/dist-DX6TxChi.js +1 -0
- package/dist/cdn/dist-DjdCf6RM.js +1 -0
- package/dist/cdn/dist-DkCpGHmT.js +1 -0
- package/dist/cdn/dist-lpY6kHhX.js +1 -0
- package/dist/cdn/dist-oIIwBspx.js +1 -0
- package/dist/cdn/dots-D8yyE7C5.js +1 -0
- package/dist/cdn/drops-SReNSu4T.js +1 -0
- package/dist/cdn/dust-Ba53-2Od.js +1 -0
- package/dist/cdn/effect-DJHvQTKy.js +4 -0
- package/dist/cdn/emboss-B3zm-CQg.js +1 -0
- package/dist/cdn/emoji-CUFvppuC.js +1 -0
- package/dist/cdn/errors-DgHytoOg-CkvGnlFR.js +1 -0
- package/dist/cdn/expand-Ct4bDkE7.js +1 -0
- package/dist/cdn/explode-DmvDuRJM.js +1 -0
- package/dist/cdn/extrude-BMoYqE6D.js +1 -0
- package/dist/cdn/fire-BmydGRu2.js +1 -0
- package/dist/cdn/flare-BmSONTgn.js +1 -0
- package/dist/cdn/flipbook-CH_3YZxX.js +1 -0
- package/dist/cdn/focus-B2oqkeBA-DWlH1Yp4.js +1 -0
- package/dist/cdn/frames-DM0t1Yk5-BoLGWKJF.js +1 -0
- package/dist/cdn/frost-Bm6r2w_2.js +1 -0
- package/dist/cdn/gallery-BToSExwQ.js +1 -0
- package/dist/cdn/glitch-Bed4mvJx.js +1 -0
- package/dist/cdn/globe-CQ2eHYhM.js +1 -0
- package/dist/cdn/glow-C7zdbiI9.js +1 -0
- package/dist/cdn/glyphs-D7LK1Gmd-C2MJqO2r.js +1 -0
- package/dist/cdn/gradient-D3DqQqOq.js +1 -0
- package/dist/cdn/graph-D3H2eUVr.js +1 -0
- package/dist/cdn/graph-LkZb-s8X.js +1 -0
- package/dist/cdn/grid-CCgUhAtC.js +1 -0
- package/dist/cdn/heatmap-CIbRSzEq.js +1 -0
- package/dist/cdn/hologram-B5Y_wKDp.js +1 -0
- package/dist/cdn/horizontal-B_WSeATL.js +1 -0
- package/dist/cdn/hotspots-CEzJsuww.js +1 -0
- package/dist/cdn/hover-preview-_UiH86w9.js +1 -0
- package/dist/cdn/image-DrrHgBDZ.js +1 -0
- package/dist/cdn/inflate-D0hUrvfE.js +1 -0
- package/dist/cdn/ink-BuIqWW1a-LH0T-7Ym.js +1 -0
- package/dist/cdn/inspect-CMJ44mep-CH0YStPl.js +1 -0
- package/dist/cdn/instances-DqmbgxOT-DvtH0UQa.js +1 -0
- package/dist/cdn/intro-BdismCiL.js +1 -0
- package/dist/cdn/intro-Du94izRI.js +1 -0
- package/dist/cdn/keycaps-BUe3ZHtn.js +1 -0
- package/dist/cdn/kit-B5sROK9w.js +1 -0
- package/dist/cdn/label-x3oJGzxx.js +1 -0
- package/dist/cdn/land-CAz4UHLd.js +1 -0
- package/dist/cdn/lens-D2SHCO1D.js +1 -0
- package/dist/cdn/letters-DNd5TZRC-DAmAx05M.js +1 -0
- package/dist/cdn/lightbox-BByhvkFX.js +1 -0
- package/dist/cdn/liquid-DexApgs4.js +1 -0
- package/dist/cdn/magnet-CWdE24zq.js +1 -0
- package/dist/cdn/map-DpSGvJy-.js +1 -0
- package/dist/cdn/marquee-BoFUSKyN.js +1 -0
- package/dist/cdn/melt-CsHl_9i4.js +1 -0
- package/dist/cdn/meshopt_decoder.module-DXTYc6wn.js +1 -0
- package/dist/cdn/model-Zaxb6O_P.js +1 -0
- package/dist/cdn/neon-DZTPn2d8.js +1 -0
- package/dist/cdn/offaxis-pl12jVWD-CrocNlQs.js +1 -0
- package/dist/cdn/orbit-DprDlH5X.js +1 -0
- package/dist/cdn/paint-XpIPgN9_-DVLxr5Rf.js +1 -0
- package/dist/cdn/panorama-fjmwKUBz.js +1 -0
- package/dist/cdn/parallax-BS4cjREz.js +1 -0
- package/dist/cdn/physics-B0gmpVWd.js +1 -0
- package/dist/cdn/pins-toALcmW2.js +1 -0
- package/dist/cdn/pixel-Cd_KYBN0-BmuGvvt0.js +1 -0
- package/dist/cdn/pixelate-CdU_1Wix.js +1 -0
- package/dist/cdn/points-3Fg6fQYz-Dp_GTrYY.js +1 -0
- package/dist/cdn/polaroids-DzIsNq6h.js +1 -0
- package/dist/cdn/prism-DB99ig6Q.js +1 -0
- package/dist/cdn/progress-DXTLwl6b-Ca6pzfih.js +1 -0
- package/dist/cdn/raster-Bf0CGQIc-CYX6ZFTt.js +1 -0
- package/dist/cdn/reflection-Ch4MkBnW.js +1 -0
- package/dist/cdn/relief-CRucXb4K-D2c8eU4w.js +1 -0
- package/dist/cdn/reveal-BoaWK4H7.js +1 -0
- package/dist/cdn/ribbon-DMJb7Ubo.js +1 -0
- package/dist/cdn/rig-B3C7cuex.js +1 -0
- package/dist/cdn/ripple-C133L4Vf.js +1 -0
- package/dist/cdn/rolldown-runtime-DK3Fl9T5.js +1 -0
- package/dist/cdn/rotator-C0nKwxBs.js +1 -0
- package/dist/cdn/runtime-DRryYdMT.js +1 -0
- package/dist/cdn/scramble-PJ4TsmNP.js +1 -0
- package/dist/cdn/screen-r73hNnjl-DTGJZ1XT.js +1 -0
- package/dist/cdn/scrub-Br_seUEa.js +1 -0
- package/dist/cdn/sdf-CQr4aUMC-C64-EhF4.js +1 -0
- package/dist/cdn/sequence-BKFTjdum.js +1 -0
- package/dist/cdn/shapes-Dijwus5M-JtBN9JiC.js +1 -0
- package/dist/cdn/shatter-B0PpiG19.js +1 -0
- package/dist/cdn/sheen-DMBey4pL-Bn9uDVqP.js +1 -0
- package/dist/cdn/shimmer-BqiIpO8g.js +1 -0
- package/dist/cdn/shine-BTuQduW0.js +1 -0
- package/dist/cdn/slots-BchTTkEV-CpV0wiOK.js +1 -0
- package/dist/cdn/smoke-BdTuN_-F.js +1 -0
- package/dist/cdn/snow-BXvR3N6h.js +1 -0
- package/dist/cdn/sparkles-CMx-Vm41.js +1 -0
- package/dist/cdn/spin-TtDxqifD.js +1 -0
- package/dist/cdn/split-flap-CWCOtV__.js +1 -0
- package/dist/cdn/spotlight-CxHjttPn.js +1 -0
- package/dist/cdn/stack-CRmnKC3h.js +1 -0
- package/dist/cdn/stars-p9oqxjUv.js +1 -0
- package/dist/cdn/studio-BuaMR-l8-xmE25_P-.js +1 -0
- package/dist/cdn/table-BrsKqA1S-CsxYd9lw.js +1 -0
- package/dist/cdn/target-CVFjw9e--rWdFTtdC.js +1 -0
- package/dist/cdn/text-glitch-33ElrOXQ.js +1 -0
- package/dist/cdn/text-reveal-BpAgAVSr.js +1 -0
- package/dist/cdn/three-B-jdjO-m.js +1 -0
- package/dist/cdn/three.core-B13DgFZS.js +6 -0
- package/dist/cdn/three.tsl-CmShpHGs.js +30 -0
- package/dist/cdn/three.webgpu-CChnXdxT.js +525 -0
- package/dist/cdn/tilt-f5MU5kjL.js +1 -0
- package/dist/cdn/tone-BbRDyAyH.js +1 -0
- package/dist/cdn/track-BeG2aIt_-D6vBB6gj.js +1 -0
- package/dist/cdn/tunnel-B8vCM_7f.js +1 -0
- package/dist/cdn/turn-BIjT-ygb-BJjv3T5r.js +1 -0
- package/dist/cdn/unfold-B3kDqhA7.js +1 -0
- package/dist/cdn/video-hover-B1Xqv_6U.js +1 -0
- package/dist/cdn/video-text-ClDbMvvD.js +1 -0
- package/dist/cdn/vinyl-DN3u2keG.js +1 -0
- package/dist/cdn/visualizer-ByIbDQP9.js +1 -0
- package/dist/cdn/voxel-BGEgV3Fl.js +1 -0
- package/dist/cdn/water-eWtyzNOa.js +1 -0
- package/dist/cdn/wave-BVs3mtr4.js +1 -0
- package/dist/cdn/waves-DS01PfgC.js +1 -0
- package/dist/cdn/zoom-BQVIAvF6.js +1 -0
- package/dist/cdn/zoom-scroll-DypyL1NE.js +1 -0
- package/dist/cli.d.ts +22 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +488 -0
- package/dist/cli.js.map +1 -0
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -0
- package/dist/data.d.ts +1 -0
- package/dist/data.js +1 -0
- package/dist/effects.d.ts +1 -0
- package/dist/effects.js +1 -0
- package/dist/esm/ambient-Cdp45mcb.js +1 -0
- package/dist/esm/assemble-Cfoe1gvx.js +1 -0
- package/dist/esm/beam-B_LDOqXC.js +1 -0
- package/dist/esm/beat-BBrKft7_.js +1 -0
- package/dist/esm/bend-QXWstuRn.js +1 -0
- package/dist/esm/bitmap-B-zWPVnC-Dw5c6dU_.js +1 -0
- package/dist/esm/blinds-C8EzA7Fo.js +1 -0
- package/dist/esm/blobs-DnqdqyVF.js +1 -0
- package/dist/esm/book-Dmje1Q11.js +1 -0
- package/dist/esm/box-BRKfJU1u.js +1 -0
- package/dist/esm/carousel-DKX_0Ck4.js +1 -0
- package/dist/esm/chart-BA6rHoJH.js +1 -0
- package/dist/esm/chroma-CTMwDMM-.js +1 -0
- package/dist/esm/click-vRJzpDy5-rjDL10Io.js +1 -0
- package/dist/esm/clock-DsSGeylm-B-eNqNgy.js +1 -0
- package/dist/esm/clouds-Dz2UCaSS.js +1 -0
- package/dist/esm/coin-DYSGv31E.js +1 -0
- package/dist/esm/compare-CoZmY9ad.js +1 -0
- package/dist/esm/confetti-DZCMbuTg.js +1 -0
- package/dist/esm/contain-DZQSiTDn-9K_cwcJL.js +1 -0
- package/dist/esm/counter-D-zoMmRl.js +1 -0
- package/dist/esm/cover-D7LZA48a.js +2 -0
- package/dist/esm/coverflow-BBpN2X8R.js +1 -0
- package/dist/esm/curtain-C4v6A2DZ.js +1 -0
- package/dist/esm/curtain-DNk0Au1K-D3QNVqhM.js +1 -0
- package/dist/esm/deck-C1kqdqrs-9fGcRmUv.js +1 -0
- package/dist/esm/define-BwEwaSnA-xcf1zhk4.js +4 -0
- package/dist/esm/dev-CoKR705i.js +1 -0
- package/dist/esm/device-D7K0JgZp.js +1 -0
- package/dist/esm/dist-BC2BEMZt.js +1 -0
- package/dist/esm/dist-BxTri4p8.js +1 -0
- package/dist/esm/dist-BzHg0BTN.js +1 -0
- package/dist/esm/dist-C8-H8Ydv.js +1 -0
- package/dist/esm/dist-C8ZH4c0R.js +1 -0
- package/dist/esm/dist-CQQi9P-c.js +1 -0
- package/dist/esm/dist-CvE4MVle.js +1 -0
- package/dist/esm/dist-D4qgVKLZ.js +1 -0
- package/dist/esm/dist-DX6TxChi.js +1 -0
- package/dist/esm/dist-DiiSTwcx.js +1 -0
- package/dist/esm/dist-XTXHnsNv.js +1 -0
- package/dist/esm/dist-dVSMGzky.js +1 -0
- package/dist/esm/dots-g96d3JFh.js +1 -0
- package/dist/esm/drops-BkwM693o.js +1 -0
- package/dist/esm/dust-Tes1owoS.js +1 -0
- package/dist/esm/effect-DJHvQTKy.js +4 -0
- package/dist/esm/emboss-bRL0GIl1.js +1 -0
- package/dist/esm/emoji-BFxwyyMp.js +1 -0
- package/dist/esm/errors-DgHytoOg-CkvGnlFR.js +1 -0
- package/dist/esm/expand-_AdA72hX.js +1 -0
- package/dist/esm/explode-DaBP5A_l.js +1 -0
- package/dist/esm/extrude-BQ4Po06y.js +1 -0
- package/dist/esm/fire-DnYo6Fcp.js +1 -0
- package/dist/esm/flare-W-sFp2YW.js +1 -0
- package/dist/esm/flipbook-BDAUFEay.js +1 -0
- package/dist/esm/focus-B2oqkeBA-BAeaC3SB.js +1 -0
- package/dist/esm/frames-DM0t1Yk5-DxC5bJrF.js +1 -0
- package/dist/esm/frost-W_lJJSu8.js +1 -0
- package/dist/esm/gallery-BPBvhrwM.js +1 -0
- package/dist/esm/glitch-C0xIbw2H.js +1 -0
- package/dist/esm/globe-hGhuLOSR.js +1 -0
- package/dist/esm/glow-kJ_lXSXR.js +1 -0
- package/dist/esm/glyphs-D7LK1Gmd-DIrg9OD4.js +1 -0
- package/dist/esm/gradient-DbJT2qkK.js +1 -0
- package/dist/esm/graph-BzBZEppr.js +1 -0
- package/dist/esm/graph-LkZb-s8X.js +1 -0
- package/dist/esm/grid-PWVOZHt-.js +1 -0
- package/dist/esm/heatmap-BDwfwXxL.js +1 -0
- package/dist/esm/hologram-eqg1NhbS.js +1 -0
- package/dist/esm/horizontal-D0e4U4dk.js +1 -0
- package/dist/esm/hotspots-sKynFCvK.js +1 -0
- package/dist/esm/hover-preview-CtrrxyxG.js +1 -0
- package/dist/esm/image-C8BD6F7U.js +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/inflate-CImx9Sck.js +1 -0
- package/dist/esm/ink-BuIqWW1a-DOMnJX6K.js +1 -0
- package/dist/esm/inspect-CMJ44mep-Bl3l1Jr0.js +1 -0
- package/dist/esm/instances-DqmbgxOT-DvtH0UQa.js +1 -0
- package/dist/esm/intro-BdismCiL.js +1 -0
- package/dist/esm/intro-Du94izRI.js +1 -0
- package/dist/esm/keycaps-Bk24JPlr.js +1 -0
- package/dist/esm/kit-DIwHK01X.js +1 -0
- package/dist/esm/label-DbI2sN7Z.js +1 -0
- package/dist/esm/land-CAz4UHLd.js +1 -0
- package/dist/esm/lens-BowwSOrJ.js +1 -0
- package/dist/esm/letters-DNd5TZRC-DAmAx05M.js +1 -0
- package/dist/esm/lightbox-CVK9lgJw.js +1 -0
- package/dist/esm/liquid-BLxDbMEa.js +1 -0
- package/dist/esm/magnet-On56lP34.js +1 -0
- package/dist/esm/map-DYLP1gqu.js +1 -0
- package/dist/esm/marquee-C816jR-L.js +1 -0
- package/dist/esm/melt-C2Xly1pz.js +1 -0
- package/dist/esm/model-nEAs_rn0.js +1 -0
- package/dist/esm/neon-95PrphVe.js +1 -0
- package/dist/esm/offaxis-pl12jVWD-uMkIFFGS.js +1 -0
- package/dist/esm/orbit-DWRtVcyn.js +1 -0
- package/dist/esm/paint-XpIPgN9_-CgDq0G_v.js +1 -0
- package/dist/esm/panorama-C9AS8BJp.js +1 -0
- package/dist/esm/parallax-DqIE_Nlk.js +1 -0
- package/dist/esm/physics-CwPt2zLb.js +1 -0
- package/dist/esm/pins-D5g4pnPT.js +1 -0
- package/dist/esm/pixel-Cd_KYBN0-CNrCJvLg.js +1 -0
- package/dist/esm/pixelate-Cay2eriT.js +1 -0
- package/dist/esm/points-3Fg6fQYz-Dp8jGvN3.js +1 -0
- package/dist/esm/polaroids-Cc4VmT6G.js +1 -0
- package/dist/esm/prism-BtL99l7t.js +1 -0
- package/dist/esm/progress-DXTLwl6b-Ca6pzfih.js +1 -0
- package/dist/esm/raster-Bf0CGQIc-CYX6ZFTt.js +1 -0
- package/dist/esm/reflection-BQ1Sm8o2.js +1 -0
- package/dist/esm/relief-CRucXb4K-jn9rPiDm.js +1 -0
- package/dist/esm/reveal-Bw7G-jLH.js +1 -0
- package/dist/esm/ribbon-BcZjjvuQ.js +1 -0
- package/dist/esm/rig-DqcDPLdU.js +1 -0
- package/dist/esm/ripple-BGPIAJw1.js +1 -0
- package/dist/esm/rotator-C-eNN93L.js +1 -0
- package/dist/esm/runtime-DO6qioXd.js +1 -0
- package/dist/esm/scramble-DAte1H39.js +1 -0
- package/dist/esm/screen-r73hNnjl-KlPgPjv-.js +1 -0
- package/dist/esm/scrub-DX83LFFV.js +1 -0
- package/dist/esm/sdf-CQr4aUMC-C64-EhF4.js +1 -0
- package/dist/esm/sequence-DdNQe7PM.js +1 -0
- package/dist/esm/shapes-Dijwus5M-BR_XNd9s.js +1 -0
- package/dist/esm/shatter-Dm-k3NCA.js +1 -0
- package/dist/esm/sheen-DMBey4pL-NgpTOTed.js +1 -0
- package/dist/esm/shimmer-BA6fH-ee.js +1 -0
- package/dist/esm/shine-BUGxnUAK.js +1 -0
- package/dist/esm/slots-BchTTkEV-CVvHj59t.js +1 -0
- package/dist/esm/smoke-DjoGr7fo.js +1 -0
- package/dist/esm/snow-JCiQsGHf.js +1 -0
- package/dist/esm/sparkles-C8MjHp2r.js +1 -0
- package/dist/esm/spin-DJ-YoiST.js +1 -0
- package/dist/esm/split-flap-dRmSO-lh.js +1 -0
- package/dist/esm/spotlight-DVA7Azih.js +1 -0
- package/dist/esm/stack-Bqzc2OQQ.js +1 -0
- package/dist/esm/stars-CWTNzDKU.js +1 -0
- package/dist/esm/studio-BuaMR-l8-DaL_nHEk.js +1 -0
- package/dist/esm/table-BrsKqA1S-CsxYd9lw.js +1 -0
- package/dist/esm/target-CVFjw9e--rWdFTtdC.js +1 -0
- package/dist/esm/text-glitch-D2sNzZ6I.js +1 -0
- package/dist/esm/text-reveal-AThQMONY.js +1 -0
- package/dist/esm/three-Es4Vpj1x.js +1 -0
- package/dist/esm/tilt-CgKbQn8v.js +1 -0
- package/dist/esm/tone-DHD2i4LU.js +1 -0
- package/dist/esm/track-BeG2aIt_-mu8DgKlm.js +1 -0
- package/dist/esm/tunnel-Djd-6KgJ.js +1 -0
- package/dist/esm/turn-BIjT-ygb-Dldj4HIv.js +1 -0
- package/dist/esm/unfold-X5OAOaXY.js +1 -0
- package/dist/esm/video-hover-CyMqU7sF.js +1 -0
- package/dist/esm/video-text-BQ7wkZec.js +1 -0
- package/dist/esm/vinyl-C2kuMJqU.js +1 -0
- package/dist/esm/visualizer-BLXSUJfy.js +1 -0
- package/dist/esm/voxel-DwWFnTEj.js +1 -0
- package/dist/esm/water-DeAwMJwO.js +1 -0
- package/dist/esm/wave-BlEpZGm9.js +1 -0
- package/dist/esm/waves-moqzvDQn.js +1 -0
- package/dist/esm/zoom-BsqNVzZz.js +1 -0
- package/dist/esm/zoom-scroll-ZXDHlq4h.js +1 -0
- package/dist/generated.d.ts +4 -0
- package/dist/generated.d.ts.map +1 -0
- package/dist/generated.js +6 -0
- package/dist/generated.js.map +1 -0
- package/dist/globe.d.ts +1 -0
- package/dist/globe.js +1 -0
- package/dist/glsl.d.ts +1 -0
- package/dist/glsl.js +1 -0
- package/dist/gsap.d.ts +1 -0
- package/dist/gsap.js +1 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +258 -0
- package/dist/index.js.map +1 -0
- package/dist/kit.d.ts +3 -0
- package/dist/kit.js +2 -0
- package/dist/lenis.d.ts +1 -0
- package/dist/lenis.js +1 -0
- package/dist/media.d.ts +1 -0
- package/dist/media.js +1 -0
- package/dist/model-rig.d.ts +1 -0
- package/dist/model-rig.js +1 -0
- package/dist/model.d.ts +1 -0
- package/dist/model.js +1 -0
- package/dist/next.d.ts +36 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +99 -0
- package/dist/next.js.map +1 -0
- package/dist/nuxt.d.ts +15 -0
- package/dist/nuxt.d.ts.map +1 -0
- package/dist/nuxt.js +18 -0
- package/dist/nuxt.js.map +1 -0
- package/dist/particles.d.ts +1 -0
- package/dist/particles.js +1 -0
- package/dist/quality.d.ts +1 -0
- package/dist/quality.js +1 -0
- package/dist/render.d.ts +1 -0
- package/dist/render.js +1 -0
- package/dist/text.d.ts +1 -0
- package/dist/text.js +1 -0
- package/dist/transitions.d.ts +2 -0
- package/dist/transitions.js +2 -0
- package/dist/vite-CsSD-__s.js +617 -0
- package/dist/vite-CsSD-__s.js.map +1 -0
- package/dist/vite-DOADLT7L.d.ts +68 -0
- package/dist/vite-DOADLT7L.d.ts.map +1 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.js +1 -0
- package/package.json +221 -3
- package/src/add.ts +442 -0
- package/src/assets.ts +2 -0
- package/src/astro-client.ts +334 -0
- package/src/astro.ts +171 -0
- package/src/attach.ts +145 -0
- package/src/audio-graph.ts +3 -0
- package/src/audio.ts +2 -0
- package/src/auto.ts +22 -0
- package/src/backgrounds.ts +2 -0
- package/src/blocks.ts +2 -0
- package/src/catalog.ts +136 -0
- package/src/cli.ts +151 -0
- package/src/core.ts +2 -0
- package/src/data.ts +2 -0
- package/src/effects.ts +2 -0
- package/src/generated.ts +6 -0
- package/src/globe.ts +2 -0
- package/src/glsl.ts +2 -0
- package/src/gsap.ts +2 -0
- package/src/index.ts +234 -0
- package/src/kit.ts +5 -0
- package/src/lenis.ts +2 -0
- package/src/media.ts +2 -0
- package/src/meta.ts +483 -0
- package/src/model-rig.ts +3 -0
- package/src/model.ts +2 -0
- package/src/names.ts +10 -0
- package/src/next.ts +143 -0
- package/src/nuxt.ts +26 -0
- package/src/particles.ts +2 -0
- package/src/paths.ts +21 -0
- package/src/quality.ts +2 -0
- package/src/render.ts +2 -0
- package/src/text.ts +2 -0
- package/src/transitions.ts +3 -0
- package/src/vite.ts +217 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Diorama contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dioramajs/diorama
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
three.js effects for plain HTML. One attribute on any element.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<img src="/harbour.jpg" alt="The harbour at dusk" data-dio="ripple" />
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The image becomes a WebGL plane that keeps its place in the layout while the page scrolls and reflows. three.js loads after the first paint, each effect loads when its element nears the viewport, and frames are drawn only while something on screen changes. Rendering uses WebGPU with a WebGL 2 fallback.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @dioramajs/diorama three
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// vite.config.ts
|
|
19
|
+
import { diorama } from '@dioramajs/diorama/vite'
|
|
20
|
+
|
|
21
|
+
export default { plugins: [diorama()] }
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// src/main.ts
|
|
26
|
+
import { start } from '@dioramajs/diorama'
|
|
27
|
+
|
|
28
|
+
export const app = start()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Astro, Nuxt and Next.js have their own integrations (`@dioramajs/diorama/astro`, `@dioramajs/diorama/nuxt`, `@dioramajs/diorama/next`), and a page without a build step needs one script tag:
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@dioramajs/diorama/dist/cdn/auto.js"></script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Your own effects
|
|
38
|
+
|
|
39
|
+
Every file in `src/effects/` is an effect named after the file:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// src/effects/brighten.ts
|
|
43
|
+
import { effect } from '@dioramajs/diorama'
|
|
44
|
+
|
|
45
|
+
export default effect({ strength: 1 }, ({ surface, u }) => {
|
|
46
|
+
surface.color((color) => color.mul(u.strength.add(1)))
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<img src="/cover.jpg" alt="" data-dio="brighten" data-dio-strength="2" />
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Copy a built-in into your folder to start from it: `npx dioramajs add spotlight`.
|
|
55
|
+
|
|
56
|
+
## Docs
|
|
57
|
+
|
|
58
|
+
- [Get started](https://dioramajs.dev/docs/start)
|
|
59
|
+
- [100 effects](https://dioramajs.dev/docs/effects)
|
|
60
|
+
- [Your own effect in 10 minutes](https://dioramajs.dev/docs/learn/effect-in-10-minutes)
|
|
61
|
+
- [API reference](https://dioramajs.dev/docs/api/diorama)
|
|
62
|
+
- [Diorama on GitHub](https://github.com/MasterKurosava/diorama)
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|
package/bin/diorama.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { run } from '../dist/cli.js'
|
|
3
|
+
|
|
4
|
+
const result = run(process.argv.slice(2))
|
|
5
|
+
// A watcher keeps the process alive. --check never watches.
|
|
6
|
+
if (!process.argv.includes('--watch') || process.argv.includes('--check'))
|
|
7
|
+
process.exitCode = result.code
|
package/dist/assets.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@dioramajs/assets";
|
package/dist/assets.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@dioramajs/assets";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { LenisLike } from "@dioramajs/lenis";
|
|
2
|
+
/** The part of Lenis 1.3 the page side uses on top of what the adapter needs. */
|
|
3
|
+
export interface SmoothScroll extends LenisLike {
|
|
4
|
+
/** Lenis' classes for <html>, e.g. 'lenis lenis-stopped'. */
|
|
5
|
+
readonly className: string;
|
|
6
|
+
/** Where a smooth scroll in flight ends, px. */
|
|
7
|
+
targetScroll: number;
|
|
8
|
+
/** Measures the page again and takes the native scroll position. */
|
|
9
|
+
resize(): void;
|
|
10
|
+
/** Scrolls to a position. `immediate` ends a smooth scroll in flight, `force` works while stopped. */
|
|
11
|
+
scrollTo: (target: number, options: {
|
|
12
|
+
immediate: boolean;
|
|
13
|
+
force: boolean;
|
|
14
|
+
}) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Smooth scroll on an Astro page. The first call makes the page's Lenis, later calls return it,
|
|
18
|
+
* so a script that needs the instance calls it too. Lenis runs on its own frames until the app
|
|
19
|
+
* of `start()` runs and drives it. On a ClientRouter swap it keeps the scroll Astro sets (the
|
|
20
|
+
* top, the hash, the position Back restores) and its classes on <html>.
|
|
21
|
+
*
|
|
22
|
+
* import Lenis from 'lenis'
|
|
23
|
+
* import { smoothScroll } from '@dioramajs/diorama/astro/client'
|
|
24
|
+
*
|
|
25
|
+
* const lenis = smoothScroll(Lenis, { easing: (t) => 1 - (1 - t) ** 3, duration: 1.2 })
|
|
26
|
+
*/
|
|
27
|
+
export declare function smoothScroll<O extends object, L extends SmoothScroll>(Lenis: new (options?: O) => L, options?: O): L;
|
|
28
|
+
/**
|
|
29
|
+
* Which ClientRouter links land where the reader left the page, as Back does, instead of at the
|
|
30
|
+
* top. 'parents': links up the address, to `/` from anywhere or to `/work` from `/work/aurora`,
|
|
31
|
+
* so a list opens where the reader left it while a project opened from it starts at its cover.
|
|
32
|
+
* 'visited': links to any page seen earlier in this tab.
|
|
33
|
+
*/
|
|
34
|
+
export type ScrollRestore = "parents" | "visited";
|
|
35
|
+
/**
|
|
36
|
+
* Links back to a page land where the reader left it, as Back does; browsers open every link at
|
|
37
|
+
* the top. A link with a #hash still goes to its anchor, and a link to the page on screen or a
|
|
38
|
+
* form's answer to the top. Positions live in sessionStorage by path and query, kept against the
|
|
39
|
+
* content at the top of the screen, so blocks that scripts fill above it after the swap do not
|
|
40
|
+
* move the page. Runs before other `astro:after-swap` listeners, so Lenis, page transitions and
|
|
41
|
+
* the site's own scripts start from the restored position, and puts the page back on that content
|
|
42
|
+
* at `astro:page-load` and on the frame after it. Back and Forward get the same correction when
|
|
43
|
+
* Astro restores the position the page was left at. The first call decides; it returns a
|
|
44
|
+
* function that turns it off.
|
|
45
|
+
*
|
|
46
|
+
* import { restoreScroll } from '@dioramajs/diorama/astro/client'
|
|
47
|
+
*
|
|
48
|
+
* restoreScroll('parents')
|
|
49
|
+
*/
|
|
50
|
+
export declare function restoreScroll(mode: ScrollRestore): () => void;
|
|
51
|
+
//# sourceMappingURL=astro-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-client.d.ts","names":[],"sources":["../src/astro-client.ts"],"mappings":";;iBAOiB,qBAAqB;;WAE3B;;EAET;;EAEA;;EAEA,WAAW,gBAAgB;IAAW;IAAoB;;;;;;;;;;;;;;wBAmC5C,aAAa,kBAAkB,UAAU,cACvD,YAAY,UAAU,MAAM,GAC5B,UAAU,IACT;;;;;;;YA8KS;;;;;;;;;;;;;;;;wBAoBI,cAAc,MAAM"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { i as ready } from "./attach-CrYQw3kS.js";
|
|
2
|
+
import { lenisPlugin } from "@dioramajs/lenis";
|
|
3
|
+
// src/astro-client.ts
|
|
4
|
+
const KEY = Symbol.for("diorama.astro.lenis");
|
|
5
|
+
const RESTORE = Symbol.for("diorama.astro.restore");
|
|
6
|
+
/** ms between saves of the scroll into history: Safari allows 100 replaceState per 30 s. */
|
|
7
|
+
const SAVE_EVERY = 400;
|
|
8
|
+
/** sessionStorage key of the last scroll of each page left in this tab. */
|
|
9
|
+
const VISITED = "diorama:scroll";
|
|
10
|
+
const holder = globalThis;
|
|
11
|
+
const lenisClass = (name) => name === "lenis" || name.startsWith("lenis-");
|
|
12
|
+
/**
|
|
13
|
+
* Smooth scroll on an Astro page. The first call makes the page's Lenis, later calls return it,
|
|
14
|
+
* so a script that needs the instance calls it too. Lenis runs on its own frames until the app
|
|
15
|
+
* of `start()` runs and drives it. On a ClientRouter swap it keeps the scroll Astro sets (the
|
|
16
|
+
* top, the hash, the position Back restores) and its classes on <html>.
|
|
17
|
+
*
|
|
18
|
+
* import Lenis from 'lenis'
|
|
19
|
+
* import { smoothScroll } from '@dioramajs/diorama/astro/client'
|
|
20
|
+
*
|
|
21
|
+
* const lenis = smoothScroll(Lenis, { easing: (t) => 1 - (1 - t) ** 3, duration: 1.2 })
|
|
22
|
+
*/
|
|
23
|
+
function smoothScroll(Lenis, options) {
|
|
24
|
+
const made = holder[KEY];
|
|
25
|
+
if (made) return made;
|
|
26
|
+
const lenis = new Lenis({
|
|
27
|
+
...options,
|
|
28
|
+
autoRaf: true
|
|
29
|
+
});
|
|
30
|
+
holder[KEY] = lenis;
|
|
31
|
+
const root = document.documentElement;
|
|
32
|
+
const controller = new AbortController();
|
|
33
|
+
const { signal } = controller;
|
|
34
|
+
const destroy = lenis.destroy.bind(lenis);
|
|
35
|
+
lenis.destroy = () => {
|
|
36
|
+
controller.abort();
|
|
37
|
+
if (holder[KEY] === lenis) delete holder[KEY];
|
|
38
|
+
destroy();
|
|
39
|
+
};
|
|
40
|
+
let moving = false;
|
|
41
|
+
let saving;
|
|
42
|
+
const save = () => {
|
|
43
|
+
clearTimeout(saving);
|
|
44
|
+
saving = void 0;
|
|
45
|
+
const state = history.state;
|
|
46
|
+
if (moving || !state || state.scrollX === scrollX && state.scrollY === scrollY) return;
|
|
47
|
+
history.replaceState({
|
|
48
|
+
...state,
|
|
49
|
+
scrollX,
|
|
50
|
+
scrollY
|
|
51
|
+
}, "");
|
|
52
|
+
};
|
|
53
|
+
lenis.on("scroll", () => {
|
|
54
|
+
saving ??= setTimeout(save, SAVE_EVERY);
|
|
55
|
+
});
|
|
56
|
+
signal.addEventListener("abort", () => clearTimeout(saving));
|
|
57
|
+
document.addEventListener("astro:before-preparation", (event) => {
|
|
58
|
+
if (event.navigationType === "traverse") moving = true;
|
|
59
|
+
}, { signal });
|
|
60
|
+
document.addEventListener("astro:before-swap", (event) => {
|
|
61
|
+
save();
|
|
62
|
+
moving = true;
|
|
63
|
+
event.newDocument.documentElement.classList.add(...lenis.className.split(" "));
|
|
64
|
+
}, { signal });
|
|
65
|
+
document.addEventListener("astro:after-swap", () => {
|
|
66
|
+
moving = false;
|
|
67
|
+
lenis.resize();
|
|
68
|
+
if (lenis.isScrolling === "smooth") {
|
|
69
|
+
lenis.targetScroll = NaN;
|
|
70
|
+
lenis.scrollTo(lenis.actualScroll, {
|
|
71
|
+
immediate: true,
|
|
72
|
+
force: true
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
for (const name of [...root.classList]) if (lenisClass(name)) root.classList.remove(name);
|
|
76
|
+
root.classList.add(...lenis.className.split(" "));
|
|
77
|
+
}, { signal });
|
|
78
|
+
const connect = () => {
|
|
79
|
+
ready().then((app) => {
|
|
80
|
+
if (signal.aborted) return;
|
|
81
|
+
const service = app.find("lenis");
|
|
82
|
+
if (service?.lenis && service.lenis !== lenis) {
|
|
83
|
+
console.warn("[diorama] diorama({ lenis }) in astro.config makes Lenis, and start({ lenis }) got another: the one from start() stays. Remove one of them");
|
|
84
|
+
lenis.destroy();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (service) service.use(lenis);
|
|
88
|
+
else app.use(lenisPlugin({ lenis })).catch((error) => app.report(error, "lenis"));
|
|
89
|
+
const off = app.state.subscribe((state) => {
|
|
90
|
+
if (state !== "destroyed") return;
|
|
91
|
+
queueMicrotask(() => off());
|
|
92
|
+
connect();
|
|
93
|
+
});
|
|
94
|
+
}, () => {});
|
|
95
|
+
};
|
|
96
|
+
connect();
|
|
97
|
+
return lenis;
|
|
98
|
+
}
|
|
99
|
+
/** The positions saved in this tab, by page. */
|
|
100
|
+
const visited = () => {
|
|
101
|
+
try {
|
|
102
|
+
const seen = JSON.parse(sessionStorage.getItem(VISITED) ?? "{}");
|
|
103
|
+
return seen && typeof seen === "object" ? seen : {};
|
|
104
|
+
} catch {
|
|
105
|
+
return {};
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/** The element whose children anchor a position: main, else body. */
|
|
109
|
+
const shell = () => {
|
|
110
|
+
const main = document.querySelector("main");
|
|
111
|
+
return main ? ["main", main] : ["body", document.body];
|
|
112
|
+
};
|
|
113
|
+
const pinned = (el) => /fixed|sticky/.test(getComputedStyle(el).position);
|
|
114
|
+
/**
|
|
115
|
+
* Anchors on what is at the top of the screen: the deepest element with an id there, then the
|
|
116
|
+
* child of main (or body) there. A raw scroll misses once scripts fill blocks above it.
|
|
117
|
+
*/
|
|
118
|
+
function anchors() {
|
|
119
|
+
const [name, root] = shell();
|
|
120
|
+
const children = [...root.children];
|
|
121
|
+
let top;
|
|
122
|
+
for (const child of children) {
|
|
123
|
+
const rect = child.getBoundingClientRect();
|
|
124
|
+
if (rect.top <= 0 && rect.height > 0 && !pinned(child)) top = child;
|
|
125
|
+
}
|
|
126
|
+
if (!top) return [];
|
|
127
|
+
let named = top.id ? top : void 0;
|
|
128
|
+
for (let el = top; el;) {
|
|
129
|
+
el = [...el.children].find((child) => {
|
|
130
|
+
const rect = child.getBoundingClientRect();
|
|
131
|
+
return rect.top <= 0 && rect.bottom > 0 && !pinned(child);
|
|
132
|
+
});
|
|
133
|
+
if (el?.id) named = el;
|
|
134
|
+
}
|
|
135
|
+
const past = (el) => -el.getBoundingClientRect().top;
|
|
136
|
+
const found = [];
|
|
137
|
+
if (named) found.push([`#${named.id}`, past(named)]);
|
|
138
|
+
if (named !== top) found.push([`${name}>${children.indexOf(top)}`, past(top)]);
|
|
139
|
+
return found;
|
|
140
|
+
}
|
|
141
|
+
/** The scroll that puts the first anchor still on the page where it was, else the raw one. */
|
|
142
|
+
function place([x, y, list = []]) {
|
|
143
|
+
const [name, root] = shell();
|
|
144
|
+
for (const [key, past] of list) {
|
|
145
|
+
const [where, at] = key.split(">");
|
|
146
|
+
const el = key.startsWith("#") ? document.getElementById(key.slice(1)) : where === name ? root.children[Number(at)] : void 0;
|
|
147
|
+
if (el) return [x, el.getBoundingClientRect().top + scrollY + past];
|
|
148
|
+
}
|
|
149
|
+
return [x, y];
|
|
150
|
+
}
|
|
151
|
+
/** The reader's own scrolling ends the corrections after a restore. */
|
|
152
|
+
const GESTURES = [
|
|
153
|
+
"wheel",
|
|
154
|
+
"touchstart",
|
|
155
|
+
"pointerdown",
|
|
156
|
+
"keydown"
|
|
157
|
+
];
|
|
158
|
+
/**
|
|
159
|
+
* Links back to a page land where the reader left it, as Back does; browsers open every link at
|
|
160
|
+
* the top. A link with a #hash still goes to its anchor, and a link to the page on screen or a
|
|
161
|
+
* form's answer to the top. Positions live in sessionStorage by path and query, kept against the
|
|
162
|
+
* content at the top of the screen, so blocks that scripts fill above it after the swap do not
|
|
163
|
+
* move the page. Runs before other `astro:after-swap` listeners, so Lenis, page transitions and
|
|
164
|
+
* the site's own scripts start from the restored position, and puts the page back on that content
|
|
165
|
+
* at `astro:page-load` and on the frame after it. Back and Forward get the same correction when
|
|
166
|
+
* Astro restores the position the page was left at. The first call decides; it returns a
|
|
167
|
+
* function that turns it off.
|
|
168
|
+
*
|
|
169
|
+
* import { restoreScroll } from '@dioramajs/diorama/astro/client'
|
|
170
|
+
*
|
|
171
|
+
* restoreScroll('parents')
|
|
172
|
+
*/
|
|
173
|
+
function restoreScroll(mode) {
|
|
174
|
+
const made = holder[RESTORE];
|
|
175
|
+
if (made) return made;
|
|
176
|
+
const controller = new AbortController();
|
|
177
|
+
const options = {
|
|
178
|
+
capture: true,
|
|
179
|
+
signal: controller.signal
|
|
180
|
+
};
|
|
181
|
+
const path = (url) => url.pathname.replace(/(.)\/$/, "$1");
|
|
182
|
+
const dir = (url) => path(url).replace(/([^/])$/, "$1/");
|
|
183
|
+
const page = (url) => path(url) + url.search;
|
|
184
|
+
let form = false;
|
|
185
|
+
let to;
|
|
186
|
+
let frame = 0;
|
|
187
|
+
const settle = () => {
|
|
188
|
+
if (!to) return;
|
|
189
|
+
const [x, y] = place(to);
|
|
190
|
+
if (Math.abs(x - scrollX) >= 1 || Math.abs(y - scrollY) >= 1) {
|
|
191
|
+
scrollTo(x, y);
|
|
192
|
+
const lenis = holder[KEY];
|
|
193
|
+
if (lenis && !lenis.isScrolling) lenis.resize();
|
|
194
|
+
}
|
|
195
|
+
const state = history.state;
|
|
196
|
+
if (state) history.replaceState({
|
|
197
|
+
...state,
|
|
198
|
+
scrollX,
|
|
199
|
+
scrollY
|
|
200
|
+
}, "");
|
|
201
|
+
};
|
|
202
|
+
const stop = () => {
|
|
203
|
+
to = void 0;
|
|
204
|
+
cancelAnimationFrame(frame);
|
|
205
|
+
};
|
|
206
|
+
for (const gesture of GESTURES) addEventListener(gesture, stop, {
|
|
207
|
+
...options,
|
|
208
|
+
passive: true
|
|
209
|
+
});
|
|
210
|
+
addEventListener("astro:before-preparation", (event) => {
|
|
211
|
+
stop();
|
|
212
|
+
form = !!event.formData;
|
|
213
|
+
}, options);
|
|
214
|
+
addEventListener("astro:before-swap", (event) => {
|
|
215
|
+
const { from, to: next, navigationType } = event;
|
|
216
|
+
const left = page(from);
|
|
217
|
+
const seen = visited();
|
|
218
|
+
delete seen[left];
|
|
219
|
+
const found = anchors();
|
|
220
|
+
seen[left] = found.length ? [
|
|
221
|
+
scrollX,
|
|
222
|
+
scrollY,
|
|
223
|
+
found
|
|
224
|
+
] : [scrollX, scrollY];
|
|
225
|
+
for (const key of Object.keys(seen).slice(0, -100)) delete seen[key];
|
|
226
|
+
try {
|
|
227
|
+
sessionStorage.setItem(VISITED, JSON.stringify(seen));
|
|
228
|
+
} catch {}
|
|
229
|
+
const spot = page(next) === left ? void 0 : seen[page(next)];
|
|
230
|
+
if (navigationType === "traverse") {
|
|
231
|
+
const y = history.state?.scrollY;
|
|
232
|
+
to = spot && typeof y === "number" && Math.abs(spot[1] - y) < 1 ? spot : void 0;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
to = (mode === "visited" || path(next) !== path(from) && dir(from).startsWith(dir(next))) && !form && !next.hash ? spot : void 0;
|
|
236
|
+
}, options);
|
|
237
|
+
addEventListener("astro:after-swap", settle, options);
|
|
238
|
+
addEventListener("astro:page-load", () => {
|
|
239
|
+
settle();
|
|
240
|
+
frame = requestAnimationFrame(() => {
|
|
241
|
+
settle();
|
|
242
|
+
to = void 0;
|
|
243
|
+
});
|
|
244
|
+
}, options);
|
|
245
|
+
const off = () => {
|
|
246
|
+
stop();
|
|
247
|
+
controller.abort();
|
|
248
|
+
if (holder[RESTORE] === off) delete holder[RESTORE];
|
|
249
|
+
};
|
|
250
|
+
holder[RESTORE] = off;
|
|
251
|
+
return off;
|
|
252
|
+
}
|
|
253
|
+
export { restoreScroll, smoothScroll };
|
|
254
|
+
|
|
255
|
+
//# sourceMappingURL=astro-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-client.js","names":[],"sources":["../src/astro-client.ts"],"sourcesContent":["// diorama/astro/client, the page side of `diorama({ lenis, restoreScroll })` in astro.config: the\n// integration puts `smoothScroll(Lenis, options)` and `restoreScroll()` on every page. One Lenis\n// for the site that lives across ClientRouter swaps; the app of `start()` takes it over once it runs.\nimport { type LenisLike, lenisPlugin } from '@dioramajs/lenis'\nimport { ready } from './attach'\n\n/** The part of Lenis 1.3 the page side uses on top of what the adapter needs. */\nexport interface SmoothScroll extends LenisLike {\n /** Lenis' classes for <html>, e.g. 'lenis lenis-stopped'. */\n readonly className: string\n /** Where a smooth scroll in flight ends, px. */\n targetScroll: number\n /** Measures the page again and takes the native scroll position. */\n resize(): void\n /** Scrolls to a position. `immediate` ends a smooth scroll in flight, `force` works while stopped. */\n scrollTo: (target: number, options: { immediate: boolean; force: boolean }) => void\n}\n\ninterface NavigationEvent extends Event {\n readonly navigationType: 'push' | 'replace' | 'traverse'\n}\ninterface SwapEvent extends NavigationEvent {\n readonly newDocument: Document\n readonly from: URL\n readonly to: URL\n}\n\nconst KEY = Symbol.for('diorama.astro.lenis')\nconst RESTORE = Symbol.for('diorama.astro.restore')\n/** ms between saves of the scroll into history: Safari allows 100 replaceState per 30 s. */\nconst SAVE_EVERY = 400\n/** sessionStorage key of the last scroll of each page left in this tab. */\nconst VISITED = 'diorama:scroll'\n/** Pages remembered; the one left longest ago goes first. */\nconst KEEP = 100\nconst holder = globalThis as { [KEY]?: SmoothScroll; [RESTORE]?: () => void }\n\nconst lenisClass = (name: string): boolean => name === 'lenis' || name.startsWith('lenis-')\n\n/**\n * Smooth scroll on an Astro page. The first call makes the page's Lenis, later calls return it,\n * so a script that needs the instance calls it too. Lenis runs on its own frames until the app\n * of `start()` runs and drives it. On a ClientRouter swap it keeps the scroll Astro sets (the\n * top, the hash, the position Back restores) and its classes on <html>.\n *\n * import Lenis from 'lenis'\n * import { smoothScroll } from '@dioramajs/diorama/astro/client'\n *\n * const lenis = smoothScroll(Lenis, { easing: (t) => 1 - (1 - t) ** 3, duration: 1.2 })\n */\nexport function smoothScroll<O extends object, L extends SmoothScroll>(\n Lenis: new (options?: O) => L,\n options?: O,\n): L {\n const made = holder[KEY]\n if (made) return made as L\n const lenis = new Lenis({ ...options, autoRaf: true } as O)\n holder[KEY] = lenis\n const root = document.documentElement\n const controller = new AbortController()\n const { signal } = controller\n\n const destroy = lenis.destroy.bind(lenis)\n lenis.destroy = () => {\n controller.abort()\n if (holder[KEY] === lenis) delete holder[KEY]\n destroy()\n }\n\n // Astro saves the scroll that Back and Forward restore on `scrollend`, which Lenis sends only\n // when a smooth scroll comes to rest, a second or more after the wheel stops: a quick Back\n // would lose the position. Save it into the page's history entry as Lenis moves, and once more as\n // a link swaps the page. A popstate has already made the next page's entry current, so from\n // there to the swap nothing is saved.\n let moving = false\n let saving: ReturnType<typeof setTimeout> | undefined\n const save = (): void => {\n clearTimeout(saving)\n saving = undefined\n const state = history.state as { scrollX?: number; scrollY?: number } | null\n if (moving || !state || (state.scrollX === scrollX && state.scrollY === scrollY)) return\n history.replaceState({ ...state, scrollX, scrollY }, '')\n }\n lenis.on('scroll', () => {\n saving ??= setTimeout(save, SAVE_EVERY)\n })\n signal.addEventListener('abort', () => clearTimeout(saving))\n document.addEventListener(\n 'astro:before-preparation',\n (event) => {\n if ((event as NavigationEvent).navigationType === 'traverse') moving = true\n },\n { signal },\n )\n\n document.addEventListener(\n 'astro:before-swap',\n (event) => {\n // A link: the page may have scrolled on while the next one loaded.\n save()\n moving = true\n // Astro gives <html> the next page's attributes. Without Lenis' classes lenis.css lets go\n // (height: auto, overflow: clip while stopped) until Lenis changes state again.\n const next = (event as SwapEvent).newDocument.documentElement\n next.classList.add(...lenis.className.split(' '))\n },\n { signal },\n )\n document.addEventListener(\n 'astro:after-swap',\n () => {\n // Astro has scrolled: the top, the hash, or the position Back restores. Lenis measures the\n // new page and takes it from there; it never scrolls to 0 itself, which would undo Back.\n moving = false\n lenis.resize()\n if (lenis.isScrolling === 'smooth') {\n // A smooth scroll of the page that left would go on to its old target. A jump to where\n // Astro put the page ends it; NaN keeps Lenis from skipping a jump onto its target.\n lenis.targetScroll = Number.NaN\n lenis.scrollTo(lenis.actualScroll, { immediate: true, force: true })\n }\n for (const name of [...root.classList]) if (lenisClass(name)) root.classList.remove(name)\n root.classList.add(...lenis.className.split(' '))\n },\n { signal },\n )\n\n const connect = (): void => {\n ready().then(\n (app) => {\n if (signal.aborted) return\n const service = app.find('lenis')\n if (service?.lenis && service.lenis !== lenis) {\n console.warn(\n '[diorama] diorama({ lenis }) in astro.config makes Lenis, and start({ lenis }) got another: the one from start() stays. Remove one of them',\n )\n lenis.destroy()\n return\n }\n if (service) service.use(lenis)\n else app.use(lenisPlugin({ lenis })).catch((error: unknown) => app.report(error, 'lenis'))\n // The next start() after a destroy takes Lenis over again.\n const off = app.state.subscribe((state) => {\n if (state !== 'destroyed') return\n queueMicrotask(() => off())\n connect()\n })\n },\n () => {},\n )\n }\n connect()\n return lenis\n}\n\n/** `#id`, or `main>3` for the 4th child of main (or of body), and the scroll past its top. */\ntype Anchor = [key: string, past: number]\n/** A position left: the scroll, and anchors on the content at the top of the screen. */\ntype Spot = [x: number, y: number, anchors?: Anchor[]]\ntype Visited = Record<string, Spot>\n\n/** The positions saved in this tab, by page. */\nconst visited = (): Visited => {\n try {\n const seen: unknown = JSON.parse(sessionStorage.getItem(VISITED) ?? '{}')\n return seen && typeof seen === 'object' ? (seen as Visited) : {}\n } catch {\n return {}\n }\n}\n\n/** The element whose children anchor a position: main, else body. */\nconst shell = (): [name: string, el: Element] => {\n const main = document.querySelector('main')\n return main ? ['main', main] : ['body', document.body]\n}\nconst pinned = (el: Element): boolean => /fixed|sticky/.test(getComputedStyle(el).position)\n\n/**\n * Anchors on what is at the top of the screen: the deepest element with an id there, then the\n * child of main (or body) there. A raw scroll misses once scripts fill blocks above it.\n */\nfunction anchors(): Anchor[] {\n const [name, root] = shell()\n const children = [...root.children]\n let top: Element | undefined\n for (const child of children) {\n const rect = child.getBoundingClientRect()\n if (rect.top <= 0 && rect.height > 0 && !pinned(child)) top = child\n }\n if (!top) return []\n let named: Element | undefined = top.id ? top : undefined\n for (let el: Element | undefined = top; el; ) {\n el = [...el.children].find((child) => {\n const rect = child.getBoundingClientRect()\n return rect.top <= 0 && rect.bottom > 0 && !pinned(child)\n })\n if (el?.id) named = el\n }\n const past = (el: Element): number => -el.getBoundingClientRect().top\n const found: Anchor[] = []\n if (named) found.push([`#${named.id}`, past(named)])\n if (named !== top) found.push([`${name}>${children.indexOf(top)}`, past(top)])\n return found\n}\n\n/** The scroll that puts the first anchor still on the page where it was, else the raw one. */\nfunction place([x, y, list = []]: Spot): [x: number, y: number] {\n const [name, root] = shell()\n for (const [key, past] of list) {\n const [where, at] = key.split('>')\n const el = key.startsWith('#')\n ? document.getElementById(key.slice(1))\n : where === name\n ? root.children[Number(at)]\n : undefined\n if (el) return [x, el.getBoundingClientRect().top + scrollY + past]\n }\n return [x, y]\n}\n\n/**\n * Which ClientRouter links land where the reader left the page, as Back does, instead of at the\n * top. 'parents': links up the address, to `/` from anywhere or to `/work` from `/work/aurora`,\n * so a list opens where the reader left it while a project opened from it starts at its cover.\n * 'visited': links to any page seen earlier in this tab.\n */\nexport type ScrollRestore = 'parents' | 'visited'\n\n/** The reader's own scrolling ends the corrections after a restore. */\nconst GESTURES = ['wheel', 'touchstart', 'pointerdown', 'keydown'] as const\n\n/**\n * Links back to a page land where the reader left it, as Back does; browsers open every link at\n * the top. A link with a #hash still goes to its anchor, and a link to the page on screen or a\n * form's answer to the top. Positions live in sessionStorage by path and query, kept against the\n * content at the top of the screen, so blocks that scripts fill above it after the swap do not\n * move the page. Runs before other `astro:after-swap` listeners, so Lenis, page transitions and\n * the site's own scripts start from the restored position, and puts the page back on that content\n * at `astro:page-load` and on the frame after it. Back and Forward get the same correction when\n * Astro restores the position the page was left at. The first call decides; it returns a\n * function that turns it off.\n *\n * import { restoreScroll } from '@dioramajs/diorama/astro/client'\n *\n * restoreScroll('parents')\n */\nexport function restoreScroll(mode: ScrollRestore): () => void {\n const made = holder[RESTORE]\n if (made) return made\n const controller = new AbortController()\n // Capture on window: Astro dispatches on document, so these run before its listeners.\n const options = { capture: true, signal: controller.signal }\n // `/work/` and `/work` are one page; `/work/` is the folder of `/work/aurora`, not of `/workshop`.\n const path = (url: URL): string => url.pathname.replace(/(.)\\/$/, '$1')\n const dir = (url: URL): string => path(url).replace(/([^/])$/, '$1/')\n const page = (url: URL): string => path(url) + url.search\n let form = false\n let to: Spot | undefined\n let frame = 0\n const settle = (): void => {\n if (!to) return\n const [x, y] = place(to)\n if (Math.abs(x - scrollX) >= 1 || Math.abs(y - scrollY) >= 1) {\n scrollTo(x, y)\n // Lenis made here takes the position at once; another one follows the native scroll.\n const lenis = holder[KEY]\n if (lenis && !lenis.isScrolling) lenis.resize()\n }\n const state = history.state as object | null\n if (state) history.replaceState({ ...state, scrollX, scrollY }, '')\n }\n const stop = (): void => {\n to = undefined\n cancelAnimationFrame(frame)\n }\n for (const gesture of GESTURES) addEventListener(gesture, stop, { ...options, passive: true })\n addEventListener(\n 'astro:before-preparation',\n (event) => {\n stop()\n form = !!(event as Event & { formData?: FormData }).formData\n },\n options,\n )\n addEventListener(\n 'astro:before-swap',\n (event) => {\n const { from, to: next, navigationType } = event as SwapEvent\n const left = page(from)\n const seen = visited()\n delete seen[left]\n const found = anchors()\n seen[left] = found.length ? [scrollX, scrollY, found] : [scrollX, scrollY]\n for (const key of Object.keys(seen).slice(0, -KEEP)) delete seen[key]\n try {\n sessionStorage.setItem(VISITED, JSON.stringify(seen))\n } catch {}\n const spot = page(next) === left ? undefined : seen[page(next)]\n if (navigationType === 'traverse') {\n // Astro restores the entry's own scroll: corrected only when the page was left there.\n const y = (history.state as { scrollY?: number } | null)?.scrollY\n to = spot && typeof y === 'number' && Math.abs(spot[1] - y) < 1 ? spot : undefined\n return\n }\n const back =\n mode === 'visited' || (path(next) !== path(from) && dir(from).startsWith(dir(next)))\n to = back && !form && !next.hash ? spot : undefined\n },\n options,\n )\n // Astro has put the page at the top or at the entry's scroll: move it onto the content left and\n // into the entry Back comes to. The new page's scripts run before page-load, some fill a frame\n // later.\n addEventListener('astro:after-swap', settle, options)\n addEventListener(\n 'astro:page-load',\n () => {\n settle()\n frame = requestAnimationFrame(() => {\n settle()\n to = undefined\n })\n },\n options,\n )\n const off = (): void => {\n stop()\n controller.abort()\n if (holder[RESTORE] === off) delete holder[RESTORE]\n }\n holder[RESTORE] = off\n return off\n}\n"],"mappings":";;;AA2BA,MAAM,MAAM,OAAO,IAAI,qBAAqB;AAC5C,MAAM,UAAU,OAAO,IAAI,uBAAuB;;AAElD,MAAM,aAAa;;AAEnB,MAAM,UAAU;AAGhB,MAAM,SAAS;AAEf,MAAM,cAAc,SAA0B,SAAS,WAAW,KAAK,WAAW,QAAQ;;;;;;;;;;;;AAa1F,SAAgB,aACd,OACA,SACG;CACH,MAAM,OAAO,OAAO;CACpB,IAAI,MAAM,OAAO;CACjB,MAAM,QAAQ,IAAI,MAAM;EAAE,GAAG;EAAS,SAAS;CAAK,CAAM;CAC1D,OAAO,OAAO;CACd,MAAM,OAAO,SAAS;CACtB,MAAM,aAAa,IAAI,gBAAgB;CACvC,MAAM,EAAE,WAAW;CAEnB,MAAM,UAAU,MAAM,QAAQ,KAAK,KAAK;CACxC,MAAM,gBAAgB;EACpB,WAAW,MAAM;EACjB,IAAI,OAAO,SAAS,OAAO,OAAO,OAAO;EACzC,QAAQ;CACV;CAOA,IAAI,SAAS;CACb,IAAI;CACJ,MAAM,aAAmB;EACvB,aAAa,MAAM;EACnB,SAAS,KAAA;EACT,MAAM,QAAQ,QAAQ;EACtB,IAAI,UAAU,CAAC,SAAU,MAAM,YAAY,WAAW,MAAM,YAAY,SAAU;EAClF,QAAQ,aAAa;GAAE,GAAG;GAAO;GAAS;EAAQ,GAAG,EAAE;CACzD;CACA,MAAM,GAAG,gBAAgB;EACvB,WAAW,WAAW,MAAM,UAAU;CACxC,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ACA,OACF;CACA,MAAM,YAAkB;EACtB,KAAK;EACL,WAAW,MAAM;EACjB,IAAI,OAAO,aAAa,KAAK,OAAO,OAAO;CAC7C;CACA,OAAO,WAAW;CAClB,OAAO;AACT"}
|
package/dist/astro.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { n as DioramaPluginOptions } from "./vite-DOADLT7L.js";
|
|
2
|
+
import "@dioramajs/lenis";
|
|
3
|
+
/**
|
|
4
|
+
* Which ClientRouter links land where the reader left the page, as Back does, instead of at the
|
|
5
|
+
* top. 'parents': links up the address, to `/` from anywhere or to `/work` from `/work/aurora`,
|
|
6
|
+
* so a list opens where the reader left it while a project opened from it starts at its cover.
|
|
7
|
+
* 'visited': links to any page seen earlier in this tab.
|
|
8
|
+
*/
|
|
9
|
+
type ScrollRestore = "parents" | "visited";
|
|
10
|
+
/**
|
|
11
|
+
* Lenis options that can be written into the page. Functions (`easing`, `prevent`,
|
|
12
|
+
* `virtualScroll`) cannot: pass those to `smoothScroll` from diorama/astro/client in a script.
|
|
13
|
+
*/
|
|
14
|
+
export interface AstroLenisOptions {
|
|
15
|
+
/** Smoothing per frame, 0 to 1. Lenis' default 0.1. */
|
|
16
|
+
readonly lerp?: number;
|
|
17
|
+
/** Duration of a smooth scroll, s, used instead of `lerp`. */
|
|
18
|
+
readonly duration?: number;
|
|
19
|
+
/** Smooth the wheel. Default true. */
|
|
20
|
+
readonly smoothWheel?: boolean;
|
|
21
|
+
/** Smooth touch too, with inertia. Default false. */
|
|
22
|
+
readonly syncTouch?: boolean;
|
|
23
|
+
/** `lerp` while `syncTouch` follows a finger. Default 0.075. */
|
|
24
|
+
readonly syncTouchLerp?: number;
|
|
25
|
+
/** Strength of the `syncTouch` inertia. Default 1.7. */
|
|
26
|
+
readonly touchInertiaExponent?: number;
|
|
27
|
+
/** Multiplier of wheel steps. Default 1. */
|
|
28
|
+
readonly wheelMultiplier?: number;
|
|
29
|
+
/** Multiplier of touch moves. Default 1. */
|
|
30
|
+
readonly touchMultiplier?: number;
|
|
31
|
+
/** The scroll axis. Default 'vertical'. */
|
|
32
|
+
readonly orientation?: "vertical" | "horizontal";
|
|
33
|
+
/** The gestures that scroll. Default the `orientation`, 'both' for horizontal. */
|
|
34
|
+
readonly gestureOrientation?: "vertical" | "horizontal" | "both";
|
|
35
|
+
/** Endless scroll. Default false. */
|
|
36
|
+
readonly infinite?: boolean;
|
|
37
|
+
/** Let a nested Lenis hand the scroll over at its end. Default true. */
|
|
38
|
+
readonly overscroll?: boolean;
|
|
39
|
+
/** Measure the page again when it resizes. Default true. */
|
|
40
|
+
readonly autoResize?: boolean;
|
|
41
|
+
/** Smooth scroll to `#hash` links of the same page, with scroll options if an object. */
|
|
42
|
+
readonly anchors?: boolean | {
|
|
43
|
+
/** Offset from the target, px. */
|
|
44
|
+
readonly offset?: number;
|
|
45
|
+
/** Duration, s. */
|
|
46
|
+
readonly duration?: number;
|
|
47
|
+
/** Smoothing per frame, 0 to 1. */
|
|
48
|
+
readonly lerp?: number;
|
|
49
|
+
/** Jump instead of a smooth scroll. */
|
|
50
|
+
readonly immediate?: boolean;
|
|
51
|
+
/** Ignore input until it arrives. */
|
|
52
|
+
readonly lock?: boolean;
|
|
53
|
+
};
|
|
54
|
+
/** Stop while <html> has `overflow: hidden` or `clip`, start when it scrolls again. */
|
|
55
|
+
readonly autoToggle?: boolean;
|
|
56
|
+
/** Let nested scroll areas scroll natively. Default false. */
|
|
57
|
+
readonly allowNestedScroll?: boolean;
|
|
58
|
+
/** Measure with scrollHeight on every read. Default false. */
|
|
59
|
+
readonly naiveDimensions?: boolean;
|
|
60
|
+
/** Stop the inertia when a link to another page is clicked. Default false. */
|
|
61
|
+
readonly stopInertiaOnNavigate?: boolean;
|
|
62
|
+
/** Under reduced motion follow the input 1:1. Default true. */
|
|
63
|
+
readonly respectReducedMotion?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** Options of the Astro integration. */
|
|
66
|
+
export interface DioramaAstroOptions extends DioramaPluginOptions {
|
|
67
|
+
/**
|
|
68
|
+
* Smooth scroll with Lenis on every page: `true` or Lenis options. The site installs `lenis`.
|
|
69
|
+
* The app of `start()` drives it, and it keeps the scroll ClientRouter sets on a page change.
|
|
70
|
+
*/
|
|
71
|
+
readonly lenis?: boolean | AstroLenisOptions;
|
|
72
|
+
/**
|
|
73
|
+
* Which ClientRouter links land where the reader left the page instead of at the top.
|
|
74
|
+
* 'history' (default), as browsers do: only Back and Forward. 'parents': also links up the
|
|
75
|
+
* address, to `/` from anywhere or to `/work` from `/work/aurora`, so a list opens where it was
|
|
76
|
+
* left while a project opened from it starts at the top. 'visited': links to any page seen
|
|
77
|
+
* earlier in the tab. A link with a #hash still goes to its anchor.
|
|
78
|
+
*/
|
|
79
|
+
readonly restoreScroll?: "history" | ScrollRestore;
|
|
80
|
+
}
|
|
81
|
+
/** What `astro:config:setup` gives the integration. */
|
|
82
|
+
export interface AstroSetupParams {
|
|
83
|
+
/** The site's config; `root` is where `lenis` is looked up. */
|
|
84
|
+
readonly config: {
|
|
85
|
+
readonly root: URL;
|
|
86
|
+
};
|
|
87
|
+
/** Adds the Vite plugin. */
|
|
88
|
+
updateConfig(config: {
|
|
89
|
+
vite: {
|
|
90
|
+
plugins: unknown[];
|
|
91
|
+
};
|
|
92
|
+
}): unknown;
|
|
93
|
+
/** Puts the page script (Lenis, scroll restoring) and lenis.css on every page. */
|
|
94
|
+
injectScript(stage: "page" | "page-ssr", content: string): void;
|
|
95
|
+
}
|
|
96
|
+
/** The part of an Astro integration the plugin returns. */
|
|
97
|
+
export interface AstroIntegrationLike {
|
|
98
|
+
/** Integration name, 'diorama'. */
|
|
99
|
+
readonly name: string;
|
|
100
|
+
/** Adds the Vite plugin in `astro:config:setup`, and the page script with `lenis` or `restoreScroll`. */
|
|
101
|
+
readonly hooks: {
|
|
102
|
+
readonly "astro:config:setup": (params: AstroSetupParams) => void;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** The Astro integration: the Vite plugin for the effects folder, Lenis and scroll on request. */
|
|
106
|
+
export declare function diorama(options?: DioramaAstroOptions): AstroIntegrationLike;
|
|
107
|
+
export { diorama as default };
|
|
108
|
+
//# sourceMappingURL=astro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro.d.ts","names":[],"sources":["../src/astro-client.ts","../src/astro.ts"],"mappings":";;;;;;;;KAmOY;;;;;iBCrNK;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;aAIM;;aAEA;;aAEA;;aAEA;;aAEA;;;WAGN;;WAEA;;WAEA;;WAEA;;WAEA;;;iBAIM,4BAA4B;;;;;WAKlC,kBAAkB;;;;;;;;WAQlB,4BAA4B;;;iBAItB;;WAEN;aAAmB,MAAM;;;EAElC,aAAa;IAAU;MAAQ;;;;EAE/B,aAAa,4BAA4B;;;iBAI1B;;WAEN;;WAEA;aACE,uBAAuB,QAAQ;;;;wBAiC5B,QAAQ,UAAS,sBAA2B"}
|
package/dist/astro.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { a as diorama$1 } from "./vite-CsSD-__s.js";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
// src/astro.ts
|
|
6
|
+
const fail = (message, option = "lenis") => {
|
|
7
|
+
throw new Error(`[diorama] diorama({ ${option} }) in astro.config: ${message}`);
|
|
8
|
+
};
|
|
9
|
+
/** Options go into the page as JSON, which would drop functions and elements without a word. */
|
|
10
|
+
function plain(value, path) {
|
|
11
|
+
if (value === null || [
|
|
12
|
+
"string",
|
|
13
|
+
"number",
|
|
14
|
+
"boolean",
|
|
15
|
+
"undefined"
|
|
16
|
+
].includes(typeof value)) return;
|
|
17
|
+
if (typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
|
|
18
|
+
for (const [key, item] of Object.entries(value)) plain(item, `${path}.${key}`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
fail(`${path} cannot be written into the page. Pass functions to smoothScroll() from diorama/astro/client in a layout script instead`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The script with Lenis is bundled into the site, so the site must have it. Looked up the way
|
|
25
|
+
* Vite does, in node_modules up from the root: `require` would also take NODE_PATH, which pnpm
|
|
26
|
+
* bin shims point at packages the site never installed.
|
|
27
|
+
*/
|
|
28
|
+
function requireLenis(root) {
|
|
29
|
+
for (let dir = fileURLToPath(root), up = ""; dir !== up; up = dir, dir = dirname(dir)) if (existsSync(join(dir, "node_modules/lenis/package.json"))) return;
|
|
30
|
+
fail("the lenis package is not installed. Run `npm install lenis`");
|
|
31
|
+
}
|
|
32
|
+
/** The Astro integration: the Vite plugin for the effects folder, Lenis and scroll on request. */
|
|
33
|
+
function diorama(options = {}) {
|
|
34
|
+
const { lenis, restoreScroll = "history", ...plugin } = options;
|
|
35
|
+
const lenisOptions = lenis === true ? {} : lenis || void 0;
|
|
36
|
+
if (lenisOptions) plain(lenisOptions, "lenis");
|
|
37
|
+
if (![
|
|
38
|
+
"history",
|
|
39
|
+
"parents",
|
|
40
|
+
"visited"
|
|
41
|
+
].includes(restoreScroll)) {
|
|
42
|
+
const value = JSON.stringify(restoreScroll);
|
|
43
|
+
fail(`use 'history', 'parents' or 'visited', not ${value}`, "restoreScroll");
|
|
44
|
+
}
|
|
45
|
+
const restore = restoreScroll !== "history";
|
|
46
|
+
return {
|
|
47
|
+
name: "diorama",
|
|
48
|
+
hooks: { "astro:config:setup": ({ config, updateConfig, injectScript }) => {
|
|
49
|
+
updateConfig({ vite: { plugins: [diorama$1(plugin)] } });
|
|
50
|
+
if (lenisOptions) {
|
|
51
|
+
requireLenis(config.root);
|
|
52
|
+
injectScript("page-ssr", "import 'lenis/dist/lenis.css'");
|
|
53
|
+
}
|
|
54
|
+
if (!lenisOptions && !restore) return;
|
|
55
|
+
injectScript("page", [
|
|
56
|
+
lenisOptions && "import Lenis from 'lenis'",
|
|
57
|
+
`import { ${[restore && "restoreScroll", lenisOptions && "smoothScroll"].filter(Boolean).join(", ")} } from '@dioramajs/diorama/astro/client'`,
|
|
58
|
+
restore && `restoreScroll('${restoreScroll}')`,
|
|
59
|
+
lenisOptions && `smoothScroll(Lenis, ${JSON.stringify(lenisOptions)})`
|
|
60
|
+
].filter(Boolean).join("\n"));
|
|
61
|
+
} }
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export { diorama as default, diorama };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=astro.js.map
|