sera-code 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/bin/sera.mjs +31 -0
- package/dist/bundle/chunks/{chunk-OXMPCU7P.js → chunk-DFRGGJWV.js} +1 -1
- package/dist/bundle/chunks/{chunk-KO3Z5BTR.js → chunk-EMXTNOOJ.js} +5 -5
- package/dist/bundle/chunks/{chunk-KXU77PUU.js → chunk-ET2ARYK4.js} +1 -1
- package/dist/bundle/chunks/{chunk-ZNCN2NGY.js → chunk-G5BGS7HZ.js} +2 -2
- package/dist/bundle/chunks/{chunk-HODJBMOY.js → chunk-GSGPISRE.js} +3 -4
- package/dist/bundle/chunks/{chunk-46WGNYIE.js → chunk-NMUS7OCP.js} +1 -1
- package/dist/bundle/chunks/{chunk-HQBQWHLD.js → chunk-RCQXVPCE.js} +1 -1
- package/dist/bundle/chunks/{cli-MML2DU4A.js → cli-NOCFT7AL.js} +1 -1
- package/dist/bundle/chunks/{execute-HXDNZ26B.js → execute-S2O3RL6V.js} +1 -1
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/{runtime-JAH75CB5.js → runtime-BRT7AUXY.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-OE2CSJ4W.js → virtual-modules-QR2XYBMY.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/lib/postinstall.js +16 -0
- package/lib/update.js +85 -0
- package/lib/win-setup.js +96 -0
- package/package.json +4 -1
- package/sera-core/skills/ambalaj-tasarim/NOTICE +1 -0
- package/sera-core/skills/ambalaj-tasarim/SKILL.md +34 -0
- package/sera-core/skills/ambalaj-tasarim/dieline.mjs +17 -0
- package/sera-core/skills/ambalaj-tasarim/sera-pack.js +535 -0
- package/sera-core/skills/animasyonlu-site/NOTICE +1 -0
- package/sera-core/skills/animasyonlu-site/SKILL.md +26 -0
- package/sera-core/skills/animasyonlu-site/sera-motion.js +310 -0
- package/sera-core/skills/animate/LICENSE +21 -0
- package/sera-core/skills/animate/NOTICE +2 -0
- package/sera-core/skills/animate/RECIPES.md +324 -0
- package/sera-core/skills/animate/SKILL.md +209 -0
- package/sera-core/skills/astryx-ui/SKILL.md +37 -0
- package/sera-core/skills/awwwards/LICENSE +21 -0
- package/sera-core/skills/awwwards/NOTICE +5 -0
- package/sera-core/skills/awwwards/SKILL.md +357 -0
- package/sera-core/skills/awwwards/references/anatomy.md +103 -0
- package/sera-core/skills/awwwards/references/art-direction.md +114 -0
- package/sera-core/skills/awwwards/references/astro.md +235 -0
- package/sera-core/skills/awwwards/references/concepts.md +110 -0
- package/sera-core/skills/awwwards/references/content.md +88 -0
- package/sera-core/skills/awwwards/references/engine.md +751 -0
- package/sera-core/skills/awwwards/references/layout.md +81 -0
- package/sera-core/skills/awwwards/references/motion.md +463 -0
- package/sera-core/skills/awwwards/references/nextjs.md +386 -0
- package/sera-core/skills/awwwards/references/patterns.md +123 -0
- package/sera-core/skills/awwwards/references/quality-bar.md +151 -0
- package/sera-core/skills/awwwards/references/quality.md +91 -0
- package/sera-core/skills/awwwards/references/ship.md +36 -0
- package/sera-core/skills/awwwards/references/typography.md +135 -0
- package/sera-core/skills/awwwards/references/webgl.md +430 -0
- package/sera-core/skills/awwwards/scripts/audit.mjs +243 -0
- package/sera-core/skills/awwwards/scripts/browser.mjs +54 -0
- package/sera-core/skills/awwwards/scripts/font.mjs +87 -0
- package/sera-core/skills/awwwards/scripts/og.mjs +20 -0
- package/sera-core/skills/awwwards/scripts/photos.mjs +65 -0
- package/sera-core/skills/awwwards/scripts/serve.mjs +48 -0
- package/sera-core/skills/awwwards/scripts/shoot.mjs +675 -0
- package/sera-core/skills/beceri-yaz/SKILL.md +39 -0
- package/sera-core/skills/brag-slim/LICENSE +21 -0
- package/sera-core/skills/brag-slim/NOTICE +2 -0
- package/sera-core/skills/brag-slim/SKILL.md +108 -0
- package/sera-core/skills/brainstorming/LICENSE +21 -0
- package/sera-core/skills/brainstorming/NOTICE +5 -0
- package/sera-core/skills/brainstorming/SKILL.md +298 -0
- package/sera-core/skills/brainstorming/builder-check-prompt.md +23 -0
- package/sera-core/skills/copywriting/LICENSE +21 -0
- package/sera-core/skills/copywriting/NOTICE +5 -0
- package/sera-core/skills/copywriting/SKILL.md +343 -0
- package/sera-core/skills/copywriting/references/ai-tells.md +309 -0
- package/sera-core/skills/copywriting/references/copy-frameworks.md +432 -0
- package/sera-core/skills/copywriting/references/natural-transitions.md +256 -0
- package/sera-core/skills/cro/LICENSE +21 -0
- package/sera-core/skills/cro/NOTICE +5 -0
- package/sera-core/skills/cro/SKILL.md +198 -0
- package/sera-core/skills/cro/references/experiments.md +248 -0
- package/sera-core/skills/cro/references/form.md +422 -0
- package/sera-core/skills/derin-arastirma/referanslar/arastirma-yontem.md +11 -0
- package/sera-core/skills/emil-design-eng/LICENSE +21 -0
- package/sera-core/skills/emil-design-eng/NOTICE +2 -0
- package/sera-core/skills/emil-design-eng/SKILL.md +684 -0
- package/sera-core/skills/frontend-design/LICENSE.txt +177 -0
- package/sera-core/skills/frontend-design/NOTICE +2 -0
- package/sera-core/skills/frontend-design/SKILL.md +71 -0
- package/sera-core/skills/gorsel-denetim/SKILL.md +30 -0
- package/sera-core/skills/hallmark/LICENSE +21 -0
- package/sera-core/skills/hallmark/NOTICE +5 -0
- package/sera-core/skills/hallmark/SKILL.md +154 -0
- package/sera-core/skills/hallmark/references/anatomy.md +71 -0
- package/sera-core/skills/hallmark/references/brand-truth.md +40 -0
- package/sera-core/skills/hallmark/references/comp.md +104 -0
- package/sera-core/skills/hallmark/references/craft.md +116 -0
- package/sera-core/skills/hallmark/references/dark-mode.md +49 -0
- package/sera-core/skills/hallmark/references/data-viz.md +48 -0
- package/sera-core/skills/hallmark/references/design-md.md +53 -0
- package/sera-core/skills/hallmark/references/direction.md +52 -0
- package/sera-core/skills/hallmark/references/export-formats.md +80 -0
- package/sera-core/skills/hallmark/references/flow.md +131 -0
- package/sera-core/skills/hallmark/references/fonts.md +58 -0
- package/sera-core/skills/hallmark/references/gates.md +243 -0
- package/sera-core/skills/hallmark/references/genres/atmospheric.md +24 -0
- package/sera-core/skills/hallmark/references/genres/editorial.md +24 -0
- package/sera-core/skills/hallmark/references/genres/modern-minimal.md +24 -0
- package/sera-core/skills/hallmark/references/genres/playful.md +24 -0
- package/sera-core/skills/hallmark/references/imagery.md +99 -0
- package/sera-core/skills/hallmark/references/interaction-and-states.md +89 -0
- package/sera-core/skills/hallmark/references/layout.md +104 -0
- package/sera-core/skills/hallmark/references/macrostructures/01-bento-grid.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/02-long-document.md +35 -0
- package/sera-core/skills/hallmark/references/macrostructures/03-marquee-hero.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/04-stat-led.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/05-workbench.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/06-conversational-faq.md +28 -0
- package/sera-core/skills/hallmark/references/macrostructures/07-manifesto.md +28 -0
- package/sera-core/skills/hallmark/references/macrostructures/08-photographic.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/09-quote-led.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/10-specimen.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/11-catalogue.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/12-letter.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/13-index-first.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/14-narrative-workflow.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/15-split-studio.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/16-feature-stack.md +23 -0
- package/sera-core/skills/hallmark/references/macrostructures/17-type-specimen.md +19 -0
- package/sera-core/skills/hallmark/references/macrostructures/18-portfolio-grid.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/19-map-diagram.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures/20-ecosystem-index.md +19 -0
- package/sera-core/skills/hallmark/references/macrostructures/21-component-playground.md +21 -0
- package/sera-core/skills/hallmark/references/macrostructures.md +119 -0
- package/sera-core/skills/hallmark/references/microinteractions.md +80 -0
- package/sera-core/skills/hallmark/references/patterns.md +202 -0
- package/sera-core/skills/hallmark/references/redesign.md +88 -0
- package/sera-core/skills/hallmark/references/responsive.md +46 -0
- package/sera-core/skills/hallmark/references/review-finish.md +19 -0
- package/sera-core/skills/hallmark/references/review-hero.md +20 -0
- package/sera-core/skills/hallmark/references/scroll-choreography.md +110 -0
- package/sera-core/skills/hallmark/references/texture.md +90 -0
- package/sera-core/skills/hallmark/references/themes/README.md +58 -0
- package/sera-core/skills/hallmark/references/themes/almanac.md +103 -0
- package/sera-core/skills/hallmark/references/themes/arcade.md +102 -0
- package/sera-core/skills/hallmark/references/themes/atelier.md +98 -0
- package/sera-core/skills/hallmark/references/themes/bloom.md +102 -0
- package/sera-core/skills/hallmark/references/themes/blueprint.md +103 -0
- package/sera-core/skills/hallmark/references/themes/broadside.md +108 -0
- package/sera-core/skills/hallmark/references/themes/brutal.md +95 -0
- package/sera-core/skills/hallmark/references/themes/carnival.md +104 -0
- package/sera-core/skills/hallmark/references/themes/cobalt.md +101 -0
- package/sera-core/skills/hallmark/references/themes/console.md +99 -0
- package/sera-core/skills/hallmark/references/themes/coral.md +102 -0
- package/sera-core/skills/hallmark/references/themes/darkroom.md +99 -0
- package/sera-core/skills/hallmark/references/themes/dose.md +98 -0
- package/sera-core/skills/hallmark/references/themes/dusk.md +105 -0
- package/sera-core/skills/hallmark/references/themes/editorial.md +97 -0
- package/sera-core/skills/hallmark/references/themes/formwork.md +107 -0
- package/sera-core/skills/hallmark/references/themes/furrow.md +98 -0
- package/sera-core/skills/hallmark/references/themes/garden.md +97 -0
- package/sera-core/skills/hallmark/references/themes/grid.md +101 -0
- package/sera-core/skills/hallmark/references/themes/halftone.md +106 -0
- package/sera-core/skills/hallmark/references/themes/hedgerow.md +104 -0
- package/sera-core/skills/hallmark/references/themes/hum.md +99 -0
- package/sera-core/skills/hallmark/references/themes/ink.md +106 -0
- package/sera-core/skills/hallmark/references/themes/kiln.md +108 -0
- package/sera-core/skills/hallmark/references/themes/loom.md +106 -0
- package/sera-core/skills/hallmark/references/themes/lumen.md +103 -0
- package/sera-core/skills/hallmark/references/themes/manifesto.md +101 -0
- package/sera-core/skills/hallmark/references/themes/midnight.md +97 -0
- package/sera-core/skills/hallmark/references/themes/newsprint.md +102 -0
- package/sera-core/skills/hallmark/references/themes/overprint.md +101 -0
- package/sera-core/skills/hallmark/references/themes/pasteup.md +100 -0
- package/sera-core/skills/hallmark/references/themes/piste.md +99 -0
- package/sera-core/skills/hallmark/references/themes/refract.md +101 -0
- package/sera-core/skills/hallmark/references/themes/ribbon.md +106 -0
- package/sera-core/skills/hallmark/references/themes/rim.md +96 -0
- package/sera-core/skills/hallmark/references/themes/riso.md +98 -0
- package/sera-core/skills/hallmark/references/themes/solstice.md +104 -0
- package/sera-core/skills/hallmark/references/themes/specimen.md +100 -0
- package/sera-core/skills/hallmark/references/themes/spore.md +104 -0
- package/sera-core/skills/hallmark/references/themes/sport.md +101 -0
- package/sera-core/skills/hallmark/references/themes/squeeze.md +99 -0
- package/sera-core/skills/hallmark/references/themes/sticker.md +106 -0
- package/sera-core/skills/hallmark/references/themes/studio.md +99 -0
- package/sera-core/skills/hallmark/references/themes/terminal.md +96 -0
- package/sera-core/skills/hallmark/references/themes/terrazzo.md +106 -0
- package/sera-core/skills/hallmark/references/themes/ultraviolet.md +106 -0
- package/sera-core/skills/hallmark/references/themes/vantage.md +99 -0
- package/sera-core/skills/hallmark/references/themes/vellum.md +105 -0
- package/sera-core/skills/hallmark/references/themes/wayfind.md +105 -0
- package/sera-core/skills/hallmark/references/themes/werkstatt.md +105 -0
- package/sera-core/skills/hallmark/scripts/capture.mjs +132 -0
- package/sera-core/skills/hallmark/scripts/refcheck.mjs +405 -0
- package/sera-core/skills/hallmark/scripts/sloplint-render.mjs +1283 -0
- package/sera-core/skills/hallmark/scripts/sloplint.mjs +4426 -0
- package/sera-core/skills/hallmark/scripts/theme.mjs +660 -0
- package/sera-core/skills/kurum-ici-iletisim/SKILL.md +40 -0
- package/sera-core/skills/launch/LICENSE +21 -0
- package/sera-core/skills/launch/NOTICE +5 -0
- package/sera-core/skills/launch/SKILL.md +385 -0
- package/sera-core/skills/launch/references/shipped-changes.md +84 -0
- package/sera-core/skills/launch/references/site-launch-qa.md +57 -0
- package/sera-core/skills/marka-kimligi/SKILL.md +30 -0
- package/sera-core/skills/mcp-yaz/SKILL.md +41 -0
- package/sera-core/skills/mobil-arayuz/SKILL.md +12 -0
- package/sera-core/skills/mvp-scoping/LICENSE +21 -0
- package/sera-core/skills/mvp-scoping/NOTICE +5 -0
- package/sera-core/skills/mvp-scoping/SKILL.md +95 -0
- package/sera-core/skills/ortak-yazarlik/SKILL.md +32 -0
- package/sera-core/skills/oyun-turleri/SKILL.md +176 -0
- package/sera-core/skills/paralel-sadelestirme/SKILL.md +33 -0
- package/sera-core/skills/phaser-core/LICENSE +201 -0
- package/sera-core/skills/phaser-core/NOTICE +5 -0
- package/sera-core/skills/phaser-core/NOTICE-UPSTREAM +15 -0
- package/sera-core/skills/phaser-core/SKILL.md +245 -0
- package/sera-core/skills/phaser-core/references/scene-flow.md +177 -0
- package/sera-core/skills/pitch-deck/LICENSE +21 -0
- package/sera-core/skills/pitch-deck/NOTICE +5 -0
- package/sera-core/skills/pitch-deck/SKILL.md +103 -0
- package/sera-core/skills/sera-3d-oyun/NOTICE +1 -0
- package/sera-core/skills/sera-3d-oyun/SKILL.md +12 -0
- package/sera-core/skills/sera-3d-oyun/sera-3d.js +3697 -0
- package/sera-core/skills/sera-diyagram/SKILL.md +43 -0
- package/sera-core/skills/sera-ofis-dosya/SKILL.md +3 -0
- package/sera-core/skills/sera-ofis-dosya/referanslar/ofis-ileri.md +46 -0
- package/sera-core/skills/sera-ui-site/NOTICE +1 -0
- package/sera-core/skills/sera-ui-site/SKILL.md +10 -0
- package/sera-core/skills/sera-ui-site/sera-ui.js +83 -0
- package/sera-core/skills/sera-veri-gorsel/SKILL.md +3 -0
- package/sera-core/skills/sera-veri-gorsel/referanslar/palet-dogrula.mjs +80 -0
- package/sera-core/skills/sistem-tarama/SKILL.md +49 -0
- package/sera-core/skills/sistem-tarama/referanslar/komutlar.md +78 -0
- package/sera-core/skills/tasarim-stilleri/SKILL.md +113 -0
- package/sera-core/skills/teardown/LICENSE +22 -0
- package/sera-core/skills/teardown/NOTICE +3 -0
- package/sera-core/skills/teardown/SKILL.md +144 -0
- package/sera-core/skills/teardown/package-lock.json +545 -0
- package/sera-core/skills/teardown/package.json +18 -0
- package/sera-core/skills/teardown/paths.mjs +30 -0
- package/sera-core/skills/teardown/run_sfx.py +10 -0
- package/sera-core/skills/teardown/sfx/__init__.py +10 -0
- package/sera-core/skills/teardown/sfx/__main__.py +64 -0
- package/sera-core/skills/teardown/sfx/dsp.py +453 -0
- package/sera-core/skills/teardown/sfx/loudness.py +72 -0
- package/sera-core/skills/teardown/sfx/mix.py +111 -0
- package/sera-core/skills/teardown/sfx/samples/SOURCES.md +23 -0
- package/sera-core/skills/teardown/sfx/samples/fs-258269-mouth-pop.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-323432-typing.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-329533-room-tone-in-an-apartment-livi.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-329569-roomtone-bedroom-yew.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-339521-vhs-rewind-forward-and-eject.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-349504-triangle-open-04.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-416777-digital-typing-wav.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-426767-apartment-room-tone-wav.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-447909-keyboard-typing.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-447910-plop.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-79388-keyboard-typing-wav.ogg +0 -0
- package/sera-core/skills/teardown/sfx/samples/fs-824189-pop-in-sfx.ogg +0 -0
- package/sera-core/skills/teardown/sfx/score_kit.py +206 -0
- package/sera-core/skills/teardown/sfx/synth.py +294 -0
- package/sera-core/skills/teardown/sheet.mjs +127 -0
- package/sera-core/skills/teardown/sims/beats.py +212 -0
- package/sera-core/skills/teardown/sims/build.mjs +141 -0
- package/sera-core/skills/teardown/sims/capture.mjs +211 -0
- package/sera-core/skills/teardown/sims/cessna-film/main.js +4 -0
- package/sera-core/skills/teardown/sims/cessna-film/timeline.json +1 -0
- package/sera-core/skills/teardown/sims/cessna-live/main.js +5 -0
- package/sera-core/skills/teardown/sims/cessna-shared/console.js +288 -0
- package/sera-core/skills/teardown/sims/cessna-shared/film.js +254 -0
- package/sera-core/skills/teardown/sims/cessna-shared/flight.js +53 -0
- package/sera-core/skills/teardown/sims/cessna-shared/gear.js +364 -0
- package/sera-core/skills/teardown/sims/cessna-shared/live.js +351 -0
- package/sera-core/skills/teardown/sims/cessna-shared/score.py +41 -0
- package/sera-core/skills/teardown/sims/cessna-shared/stage.js +248 -0
- package/sera-core/skills/teardown/sims/kit/director.js +300 -0
- package/sera-core/skills/teardown/sims/kit/hud.js +194 -0
- package/sera-core/skills/teardown/sims/kit/runtime.js +168 -0
- package/sera-core/skills/teardown/sims/kit/stage3d.js +114 -0
- package/sera-core/skills/teardown/sims/kit/style.css +137 -0
- package/sera-core/skills/teardown/sims/kit/util.js +79 -0
- package/sera-core/skills/teardown/sims/kit/warm.js +66 -0
- package/sera-core/skills/teardown/sims/strandbeest-film/main.js +4 -0
- package/sera-core/skills/teardown/sims/strandbeest-film/timeline.json +1 -0
- package/sera-core/skills/teardown/sims/strandbeest-live/main.js +5 -0
- package/sera-core/skills/teardown/sims/strandbeest-shared/beast.js +419 -0
- package/sera-core/skills/teardown/sims/strandbeest-shared/console.js +375 -0
- package/sera-core/skills/teardown/sims/strandbeest-shared/film.js +352 -0
- package/sera-core/skills/teardown/sims/strandbeest-shared/jansen.js +67 -0
- package/sera-core/skills/teardown/sims/strandbeest-shared/live.js +420 -0
- package/sera-core/skills/teardown/sims/strandbeest-shared/score.py +85 -0
- package/sera-core/skills/teardown/sims/strandbeest-shared/stage.js +463 -0
- package/sera-core/skills/teardown/sims/v8-film/main.js +4 -0
- package/sera-core/skills/teardown/sims/v8-film/timeline.json +1 -0
- package/sera-core/skills/teardown/sims/v8-live/main.js +5 -0
- package/sera-core/skills/teardown/sims/v8-shared/console.js +339 -0
- package/sera-core/skills/teardown/sims/v8-shared/engine.js +624 -0
- package/sera-core/skills/teardown/sims/v8-shared/film.js +239 -0
- package/sera-core/skills/teardown/sims/v8-shared/kin.js +86 -0
- package/sera-core/skills/teardown/sims/v8-shared/live.js +374 -0
- package/sera-core/skills/teardown/sims/v8-shared/score.py +60 -0
- package/sera-core/skills/teardown/sims/v8-shared/stage.js +173 -0
- package/sera-core/skills/teardown/wave.mjs +67 -0
- package/sera-core/skills/toplu-degisiklik/SKILL.md +39 -0
- package/sera-core/skills/ui-ux-pro-max/LICENSE +21 -0
- package/sera-core/skills/ui-ux-pro-max/NOTICE +5 -0
- package/sera-core/skills/ui-ux-pro-max/SKILL.md +13 -0
- package/sera-core/skills/ui-ux-pro-max/references/pro-rules.md +117 -0
- package/sera-core/skills/ui-ux-pro-max/references/quick-reference.md +266 -0
- package/sera-core/skills/unslop/LICENSE.md +410 -0
- package/sera-core/skills/unslop/SKILL.md +217 -0
- package/sera-core/skills/unslop/references/effects.md +113 -0
- package/sera-core/skills/unslop/references/refs/unslop-dashboard-after.webp +0 -0
- package/sera-core/skills/unslop/references/refs/unslop-hero-after.webp +0 -0
- package/sera-core/skills/unslop/references/refs.md +16 -0
- package/sera-core/skills/unslop/references/rtl.md +72 -0
- package/sera-core/skills/unslop/references/signs.md +125 -0
- package/sera-core/skills/unslop/references/tokens.md +137 -0
- package/sera-core/skills/unslop/references/visuals.md +84 -0
- package/sera-core/skills/unslop/scripts/snapshot.mjs +197 -0
- package/sera-core/skills/uretken-sanat/SKILL.md +42 -0
- package/sera-core/skills/verification-before-completion/LICENSE +21 -0
- package/sera-core/skills/verification-before-completion/NOTICE +5 -0
- package/sera-core/skills/verification-before-completion/SKILL.md +120 -0
- package/sera-core/skills/web-yayin-listesi/SKILL.md +3 -0
- package/sera-core/src/app-master.ts +2 -2
- package/sera-core/src/app-verify.ts +33 -0
- package/sera-core/src/extension.ts +16 -2
- package/sera-core/src/generated/build-rules.ts +81 -17
- package/sera-core/src/generated/quality-probe.ts +2 -0
- package/sera-core/src/generated/zero-knowledge.ts +36 -9
- package/sera-core/src/image-tool.ts +12 -2
- package/sera-core/src/link-data-tools.ts +411 -0
- package/sera-core/src/skills.ts +54 -18
- package/sera-core/src/video-tool.ts +51 -0
- package/sera-core/src/zk.ts +7 -3
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
<!-- Generated from tests/nexttest by tests/_gen/build.py; edit there, not here. -->
|
|
2
|
+
# WebGL
|
|
3
|
+
|
|
4
|
+
WebGL is standard on award-winning sites (6 of 7 recent Site of the Day portfolios). It is
|
|
5
|
+
worth adding only when it expresses the concept and holds 60 fps on a mid-range phone. The
|
|
6
|
+
engine's optional GL module (code at the end of this file, in `src/engine/gl/`) gives you one
|
|
7
|
+
shared OGL canvas with two primitives. Extend them rather than adding a second renderer.
|
|
8
|
+
Install: `npm i ogl`.
|
|
9
|
+
|
|
10
|
+
## Primitives
|
|
11
|
+
|
|
12
|
+
1. **DOM-synced planes** (`data-gl`): every `<figure data-gl>` gets a plane drawn exactly over
|
|
13
|
+
its rect each frame. The `<img>` stays in the DOM (SEO, a11y, LCP, fallback) at opacity 0.
|
|
14
|
+
Built-in look: in-shader object-fit cover, hover zoom and pointer push, chromatic split from
|
|
15
|
+
scroll velocity, organic bottom-up reveal, bend with scroll velocity.
|
|
16
|
+
Procedural variant (`data-gl="procedural"`): seeded fbm field in three palette colors with grain.
|
|
17
|
+
|
|
18
|
+
| Attribute | Effect |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `data-gl` | Image plane for the `<img>` inside. Remote images need `crossorigin="anonymous"` |
|
|
21
|
+
| `data-gl="procedural" data-seed="2.4" data-colors="#a,#b,#c"` | Generative cover in the palette (for projects without imagery). Put a `.gl-fallback` div with `role="img"` + `aria-label` inside |
|
|
22
|
+
| `data-gl-instant` | Visible immediately (hero media, the target of a shared-element transition) |
|
|
23
|
+
| `data-gl-scrub` | Reveal follows scroll position (0 as it enters, 1 at 25% from the top) |
|
|
24
|
+
| `data-gl-duration="2.4"` | Length of the timed reveal in seconds (default 1.6) |
|
|
25
|
+
|
|
26
|
+
2. **Fullscreen layer** (`setBackground(fragment, uniforms)`): a shader under the planes for skies,
|
|
27
|
+
fields, gradients, noise, light. Built-in uniforms: `uTime, uResolution, uScroll (0..1),
|
|
28
|
+
uScrollY, uVelocity, uMouse (smoothed 0..1)`; varying `vUv`.
|
|
29
|
+
|
|
30
|
+
Customize the plane shaders in `src/engine/gl/shaders.ts` per concept (that is expected):
|
|
31
|
+
change the hover, the reveal shape and the velocity response. Keep the uniform names so the
|
|
32
|
+
engine can drive them.
|
|
33
|
+
Tested example: a photographer's "darkroom" replaced `imageFragment` so prints develop out of
|
|
34
|
+
paper white (dark tones first, uneven like tray agitation) under a red safelight cast, and hover
|
|
35
|
+
turns the room lights on (true color); `data-gl-scrub` tied development to scroll position.
|
|
36
|
+
|
|
37
|
+
**Layering rules (the canvas is UNDER the content):**
|
|
38
|
+
- No background on a `[data-gl]` element or its ancestors inside `<main>` (the engine forces
|
|
39
|
+
`background: none` on GL elements; `shoot.mjs` reports `glHidden` for covered planes).
|
|
40
|
+
- Text over a GL image: put a gradient scrim as a pseudo-element on the container in the DOM.
|
|
41
|
+
- Fixed UI over GL imagery: `mix-blend-mode: difference` or a scrim.
|
|
42
|
+
|
|
43
|
+
## Recipes
|
|
44
|
+
|
|
45
|
+
### Scroll-driven sky / time of day (fullscreen)
|
|
46
|
+
```ts
|
|
47
|
+
import { onPage, setBackground } from '../engine';
|
|
48
|
+
const frag = /* glsl */ `
|
|
49
|
+
precision highp float;
|
|
50
|
+
varying vec2 vUv;
|
|
51
|
+
uniform float uTime, uScroll;
|
|
52
|
+
uniform vec2 uMouse, uResolution;
|
|
53
|
+
uniform vec3 uA, uB, uC; // palette stops (dawn, noon, dusk)
|
|
54
|
+
float hash(vec2 p){ return fract(sin(dot(p, vec2(12.9898,78.233))) * 43758.5453); }
|
|
55
|
+
void main() {
|
|
56
|
+
float t = uScroll;
|
|
57
|
+
vec3 top = mix(mix(uA, uB, smoothstep(0.0, 0.5, t)), uC, smoothstep(0.5, 1.0, t));
|
|
58
|
+
vec3 bottom = mix(top, vec3(1.0), 0.35 - 0.25 * t);
|
|
59
|
+
vec2 sun = vec2(0.2 + 0.6 * t, 0.85 - 0.6 * abs(t - 0.5) * 2.0) + (uMouse - 0.5) * 0.03;
|
|
60
|
+
float glow = smoothstep(0.35, 0.0, distance(vUv * vec2(uResolution.x / uResolution.y, 1.0), sun * vec2(uResolution.x / uResolution.y, 1.0)));
|
|
61
|
+
vec3 col = mix(bottom, top, vUv.y) + glow * 0.25;
|
|
62
|
+
col += (hash(vUv * uResolution + fract(uTime)) - 0.5) * 0.03; // grain
|
|
63
|
+
gl_FragColor = vec4(col, 1.0);
|
|
64
|
+
}`;
|
|
65
|
+
// Register once, in setupMotion (src/motion/setup.ts); it persists across pages:
|
|
66
|
+
setBackground(frag, { uA: { value: [0.62, 0.72, 0.86] }, uB: { value: [0.97, 0.96, 0.92] }, uC: { value: [0.93, 0.47, 0.25] } });
|
|
67
|
+
```
|
|
68
|
+
Text over a moving background must keep AA contrast at every scroll position: pick ink colors
|
|
69
|
+
that work on all stops, or tween the ink color with the same progress.
|
|
70
|
+
`setBackground` returns `null` when GL is off (reduced motion, no WebGL): style `html` with a
|
|
71
|
+
static gradient as the fallback.
|
|
72
|
+
|
|
73
|
+
### Image hover variants (edit `imageFragment`)
|
|
74
|
+
- **Liquid:** offset `uv` by `fbm(uv * 3.0 + uTime * 0.2) * 0.03 * uHover`.
|
|
75
|
+
- **Pixel sort / mosaic:** `uv = floor(uv * mix(400.0, 24.0, uHover)) / mix(400.0, 24.0, uHover)`.
|
|
76
|
+
- **Lens:** inside `distance(vUv, uMouse) < 0.2`, scale uv toward uMouse by `1.0 - 0.3 * uHover`.
|
|
77
|
+
- **Duotone to color:** mix luminance-mapped duotone (palette) with the true color by `uHover`.
|
|
78
|
+
|
|
79
|
+
### Reveal variants (edit `revealMask`)
|
|
80
|
+
- Horizontal wipe: use `uv.x`. Circle from center: `distance(uv, vec2(0.5))`.
|
|
81
|
+
- Blinds: `fract(uv.y * 8.0)` compared to `uReveal`.
|
|
82
|
+
|
|
83
|
+
### Text in WebGL
|
|
84
|
+
Prefer real DOM text. If a concept truly needs GL text (displacing a giant word), render the word
|
|
85
|
+
into a 2D canvas (`ctx.font` with the loaded webfont after `document.fonts.ready`), use it as a
|
|
86
|
+
texture on a `data-gl`-like plane, and keep the DOM word visually hidden but present.
|
|
87
|
+
|
|
88
|
+
### 3D models
|
|
89
|
+
Only when the concept is spatial. Use Three.js + `GLTFLoader` with Draco/Meshopt-compressed GLB
|
|
90
|
+
under 1.5 MB, lazy-import it (`await import('three')`) after the hero paints, and render in its
|
|
91
|
+
own canvas only while visible. Never block the loader on a model.
|
|
92
|
+
|
|
93
|
+
## Performance rules
|
|
94
|
+
|
|
95
|
+
- One canvas, DPR capped at 2 (engine), `antialias: false`, geometry segments ≤ 32.
|
|
96
|
+
- Fragment work: ≤ 5 fbm octaves per fullscreen pixel; avoid loops over textures; no
|
|
97
|
+
`discard`-heavy shaders on large areas.
|
|
98
|
+
- Pause when the tab is hidden (engine) and skip planes off-screen (engine).
|
|
99
|
+
- Textures: images ≤ 2000 px on the long edge, compressed (AVIF/WebP for DOM, the GL reads the
|
|
100
|
+
decoded `<img>`). Remote images need CORS (`crossorigin="anonymous"`).
|
|
101
|
+
- Test: the `shoot.mjs` FPS sample must stay at 55 or above on desktop. For heavy scenes,
|
|
102
|
+
throttle the CPU 4x in DevTools and reduce octaves or DPR when it drops.
|
|
103
|
+
- Reduced motion, Save-Data, or no WebGL: the engine never starts GL; DOM images and the static
|
|
104
|
+
fallback must look finished, not broken.
|
|
105
|
+
|
|
106
|
+
## Module code
|
|
107
|
+
|
|
108
|
+
Add these two files only when the site uses GL. The core (`engine.md`) imports `./gl`; without
|
|
109
|
+
GL, delete the lines marked `// GL` there instead.
|
|
110
|
+
|
|
111
|
+
### `src/engine/gl/index.ts`
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
// DOM-synced WebGL planes on ONE shared canvas (the standard award-site technique).
|
|
115
|
+
// <figure data-gl> image plane: uses the <img> inside (keep the img: SEO, a11y, fallback)
|
|
116
|
+
// <figure data-gl="procedural" data-seed="3" data-colors="#0d0d0d,#e9e4da,#ff4d00"> generative cover
|
|
117
|
+
// data-gl-scrub (reveal tied to scroll position) data-gl-duration="2.4" (timed reveal length) data-gl-instant
|
|
118
|
+
// The DOM element stays in layout; the canvas draws on top of its rect each frame.
|
|
119
|
+
// Disabled under reduced motion, without WebGL, or with Save-Data; DOM images then show as-is.
|
|
120
|
+
import { Renderer, Camera, Transform, Plane, Program, Mesh, Texture, Vec2, Triangle } from 'ogl';
|
|
121
|
+
import { gsap } from 'gsap';
|
|
122
|
+
import { vertex, imageFragment, proceduralFragment } from './shaders';
|
|
123
|
+
import { scrollState } from '../scroll';
|
|
124
|
+
import { prefersReducedMotion } from '../env';
|
|
125
|
+
|
|
126
|
+
type Item = { el: HTMLElement; mesh: Mesh; program: Program; hover: { v: number }; revealed: boolean; scrub: boolean; io?: IntersectionObserver; off: () => void };
|
|
127
|
+
|
|
128
|
+
let renderer: Renderer | null = null;
|
|
129
|
+
let camera: Camera;
|
|
130
|
+
let scene: Transform;
|
|
131
|
+
let geometry: Plane;
|
|
132
|
+
const items: Item[] = [];
|
|
133
|
+
const textures = new Map<string, Texture>();
|
|
134
|
+
let vw = 0, vh = 0, time = 0, velocity = 0;
|
|
135
|
+
let bg: { scene: Transform; program: Program } | null = null;
|
|
136
|
+
const mouse = { x: 0.5, y: 0.5, tx: 0.5, ty: 0.5 };
|
|
137
|
+
|
|
138
|
+
const hex = (h: string) => {
|
|
139
|
+
const n = parseInt(h.replace('#', ''), 16);
|
|
140
|
+
return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export function glSupported() {
|
|
144
|
+
if (prefersReducedMotion()) return false;
|
|
145
|
+
if ((navigator as Navigator & { connection?: { saveData?: boolean } }).connection?.saveData) return false;
|
|
146
|
+
try { return !!document.createElement('canvas').getContext('webgl'); } catch { return false; }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function initGL() {
|
|
150
|
+
if (renderer || !glSupported()) return;
|
|
151
|
+
renderer = new Renderer({ dpr: Math.min(devicePixelRatio, 2), alpha: true, antialias: false, premultipliedAlpha: true });
|
|
152
|
+
const gl = renderer.gl;
|
|
153
|
+
gl.canvas.classList.add('gl-canvas');
|
|
154
|
+
gl.canvas.setAttribute('aria-hidden', 'true');
|
|
155
|
+
// Lives in a host element that persists across navigations (#gl in the layout).
|
|
156
|
+
(document.getElementById('gl') || document.body).appendChild(gl.canvas);
|
|
157
|
+
camera = new Camera(gl, { near: -10, far: 10 });
|
|
158
|
+
camera.position.z = 1;
|
|
159
|
+
scene = new Transform();
|
|
160
|
+
geometry = new Plane(gl, { widthSegments: 24, heightSegments: 24 });
|
|
161
|
+
document.documentElement.classList.add('gl-on');
|
|
162
|
+
resize();
|
|
163
|
+
addEventListener('resize', resize);
|
|
164
|
+
addEventListener('pointermove', (e) => { mouse.tx = e.clientX / vw; mouse.ty = 1 - e.clientY / vh; }, { passive: true });
|
|
165
|
+
gsap.ticker.add(render);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Fullscreen shader layer drawn under the DOM planes (skies, fields, gradients, noise).
|
|
170
|
+
* Built-in uniforms: uTime (s), uResolution (px), uScroll (0..1 page progress), uScrollY (px),
|
|
171
|
+
* uVelocity (smoothed scroll velocity), uMouse (0..1, smoothed). Varying: vUv.
|
|
172
|
+
* Persists across navigations until clearBackground(). Returns the Program (tween its uniforms).
|
|
173
|
+
*/
|
|
174
|
+
export function setBackground(fragment: string, uniforms: Record<string, { value: unknown }> = {}) {
|
|
175
|
+
if (!renderer) return null;
|
|
176
|
+
clearBackground();
|
|
177
|
+
const gl = renderer.gl;
|
|
178
|
+
const program = new Program(gl, {
|
|
179
|
+
vertex: `attribute vec2 uv; attribute vec2 position; varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position, 0.0, 1.0); }`,
|
|
180
|
+
fragment,
|
|
181
|
+
uniforms: {
|
|
182
|
+
uTime: { value: 0 }, uResolution: { value: new Vec2(vw, vh) }, uScroll: { value: 0 }, uScrollY: { value: 0 },
|
|
183
|
+
uVelocity: { value: 0 }, uMouse: { value: new Vec2(0.5, 0.5) }, ...uniforms,
|
|
184
|
+
},
|
|
185
|
+
depthTest: false,
|
|
186
|
+
depthWrite: false,
|
|
187
|
+
});
|
|
188
|
+
const scene = new Transform();
|
|
189
|
+
new Mesh(gl, { geometry: new Triangle(gl), program }).setParent(scene);
|
|
190
|
+
bg = { scene, program };
|
|
191
|
+
return program;
|
|
192
|
+
}
|
|
193
|
+
export function clearBackground() { bg = null; }
|
|
194
|
+
|
|
195
|
+
function resize() {
|
|
196
|
+
if (!renderer) return;
|
|
197
|
+
vw = innerWidth; vh = innerHeight;
|
|
198
|
+
renderer.setSize(vw, vh);
|
|
199
|
+
camera.orthographic({ left: -vw / 2, right: vw / 2, top: vh / 2, bottom: -vh / 2, near: -10, far: 10 });
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function loadTexture(img: HTMLImageElement, program: Program) {
|
|
203
|
+
const src = img.currentSrc || img.src;
|
|
204
|
+
const gl = renderer!.gl;
|
|
205
|
+
let tex = textures.get(src);
|
|
206
|
+
const apply = (t: Texture) => {
|
|
207
|
+
program.uniforms.tMap.value = t;
|
|
208
|
+
const im = t.image as HTMLImageElement;
|
|
209
|
+
program.uniforms.uImage.value.set(im.naturalWidth || 1, im.naturalHeight || 1);
|
|
210
|
+
};
|
|
211
|
+
if (tex) return apply(tex);
|
|
212
|
+
tex = new Texture(gl, { generateMipmaps: false, minFilter: gl.LINEAR });
|
|
213
|
+
textures.set(src, tex);
|
|
214
|
+
const im = new Image();
|
|
215
|
+
im.crossOrigin = 'anonymous';
|
|
216
|
+
im.decoding = 'async';
|
|
217
|
+
im.onload = () => { tex!.image = im; apply(tex!); };
|
|
218
|
+
im.src = src;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function add(el: HTMLElement) {
|
|
222
|
+
if (!renderer) return;
|
|
223
|
+
const gl = renderer.gl;
|
|
224
|
+
const procedural = el.dataset.gl === 'procedural';
|
|
225
|
+
const uniforms: Record<string, { value: unknown }> = {
|
|
226
|
+
uPlane: { value: new Vec2(1, 1) },
|
|
227
|
+
uTime: { value: 0 },
|
|
228
|
+
uHover: { value: 0 },
|
|
229
|
+
uVelocity: { value: 0 },
|
|
230
|
+
uReveal: { value: el.hasAttribute('data-gl-instant') ? 1 : 0 },
|
|
231
|
+
uMouse: { value: new Vec2(0.5, 0.5) },
|
|
232
|
+
};
|
|
233
|
+
if (procedural) {
|
|
234
|
+
const [c1, c2, c3] = (el.dataset.colors || '#111111,#888888,#eeeeee').split(',').map(hex);
|
|
235
|
+
Object.assign(uniforms, { uC1: { value: c1 }, uC2: { value: c2 }, uC3: { value: c3 }, uSeed: { value: parseFloat(el.dataset.seed || '1') } });
|
|
236
|
+
} else {
|
|
237
|
+
const blank = new Texture(gl, { image: new Uint8Array([0, 0, 0, 0]), width: 1, height: 1 });
|
|
238
|
+
Object.assign(uniforms, { tMap: { value: blank }, uImage: { value: new Vec2(1, 1) } });
|
|
239
|
+
}
|
|
240
|
+
const program = new Program(gl, { vertex, fragment: procedural ? proceduralFragment : imageFragment, uniforms, transparent: true });
|
|
241
|
+
const mesh = new Mesh(gl, { geometry, program });
|
|
242
|
+
mesh.setParent(scene);
|
|
243
|
+
const img = el.querySelector('img');
|
|
244
|
+
if (img && !procedural) {
|
|
245
|
+
if (img.complete && img.naturalWidth) loadTexture(img, program);
|
|
246
|
+
else img.addEventListener('load', () => loadTexture(img, program), { once: true });
|
|
247
|
+
}
|
|
248
|
+
const hover = { v: 0 };
|
|
249
|
+
const enter = () => gsap.to(hover, { v: 1, duration: 0.9, ease: 'expo.out' });
|
|
250
|
+
const leave = () => gsap.to(hover, { v: 0, duration: 0.9, ease: 'expo.out' });
|
|
251
|
+
const move = (e: PointerEvent) => {
|
|
252
|
+
const r = el.getBoundingClientRect();
|
|
253
|
+
program.uniforms.uMouse.value.set((e.clientX - r.left) / r.width, 1 - (e.clientY - r.top) / r.height);
|
|
254
|
+
};
|
|
255
|
+
el.addEventListener('pointerenter', enter);
|
|
256
|
+
el.addEventListener('pointerleave', leave);
|
|
257
|
+
el.addEventListener('pointermove', move);
|
|
258
|
+
const scrub = el.hasAttribute('data-gl-scrub');
|
|
259
|
+
const item: Item = {
|
|
260
|
+
el, mesh, program, hover, revealed: false, scrub,
|
|
261
|
+
off: () => {
|
|
262
|
+
el.removeEventListener('pointerenter', enter);
|
|
263
|
+
el.removeEventListener('pointerleave', leave);
|
|
264
|
+
el.removeEventListener('pointermove', move);
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
if (!el.hasAttribute('data-gl-instant') && !scrub) {
|
|
268
|
+
item.io = new IntersectionObserver(([e]) => {
|
|
269
|
+
if (e.isIntersecting && !item.revealed) {
|
|
270
|
+
item.revealed = true;
|
|
271
|
+
gsap.to(program.uniforms.uReveal, { value: 1, duration: parseFloat(el.dataset.glDuration || '1.6'), ease: 'expo.out', delay: parseFloat(el.dataset.delay || '0') });
|
|
272
|
+
item.io?.disconnect();
|
|
273
|
+
}
|
|
274
|
+
}, { rootMargin: '0px 0px -10% 0px' });
|
|
275
|
+
item.io.observe(el);
|
|
276
|
+
}
|
|
277
|
+
items.push(item);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Scan a page for [data-gl] elements. Call on every page load. */
|
|
281
|
+
export function mountGL(root: ParentNode = document) {
|
|
282
|
+
if (!renderer) return;
|
|
283
|
+
root.querySelectorAll<HTMLElement>('[data-gl]').forEach(add);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Remove all planes (before a page swap). Textures stay cached for back-navigation. */
|
|
287
|
+
export function unmountGL() {
|
|
288
|
+
while (items.length) {
|
|
289
|
+
const it = items.pop()!;
|
|
290
|
+
it.off();
|
|
291
|
+
it.io?.disconnect();
|
|
292
|
+
it.mesh.setParent(null);
|
|
293
|
+
it.program.remove?.();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** Fade every plane out, e.g. as part of a page-leave animation. */
|
|
298
|
+
export function hideGL(duration = 0.6) {
|
|
299
|
+
return gsap.to(items.map((i) => i.program.uniforms.uReveal), { value: 0, duration, ease: 'expo.in' });
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function render(t: number) {
|
|
303
|
+
if (!renderer || document.hidden) return;
|
|
304
|
+
time = t;
|
|
305
|
+
const target = Math.max(-40, Math.min(40, scrollState().velocity));
|
|
306
|
+
velocity += (target - velocity) * 0.12;
|
|
307
|
+
let visible = 0;
|
|
308
|
+
for (const it of items) {
|
|
309
|
+
const r = it.el.getBoundingClientRect();
|
|
310
|
+
const onScreen = r.bottom > -100 && r.top < vh + 100 && r.width > 0;
|
|
311
|
+
it.mesh.visible = onScreen;
|
|
312
|
+
if (!onScreen) continue;
|
|
313
|
+
visible++;
|
|
314
|
+
it.mesh.scale.set(r.width, r.height, 1);
|
|
315
|
+
it.mesh.position.set(r.left + r.width / 2 - vw / 2, vh / 2 - (r.top + r.height / 2), 0);
|
|
316
|
+
const u = it.program.uniforms;
|
|
317
|
+
u.uPlane.value.set(r.width, r.height);
|
|
318
|
+
u.uTime.value = time;
|
|
319
|
+
u.uHover.value = it.hover.v;
|
|
320
|
+
u.uVelocity.value = velocity * 0.05;
|
|
321
|
+
// data-gl-scrub: reveal follows position: 0 when the top enters the viewport, 1 at 25% from the top.
|
|
322
|
+
if (it.scrub) u.uReveal.value = Math.min(1, Math.max(0, (vh - r.top) / (vh * 0.75)));
|
|
323
|
+
}
|
|
324
|
+
mouse.x += (mouse.tx - mouse.x) * 0.08;
|
|
325
|
+
mouse.y += (mouse.ty - mouse.y) * 0.08;
|
|
326
|
+
if (bg) {
|
|
327
|
+
const u = bg.program.uniforms;
|
|
328
|
+
const s = scrollState();
|
|
329
|
+
u.uTime.value = time; u.uResolution.value.set(vw, vh); u.uScroll.value = s.progress; u.uScrollY.value = s.y;
|
|
330
|
+
u.uVelocity.value = velocity; u.uMouse.value.set(mouse.x, mouse.y);
|
|
331
|
+
renderer.render({ scene: bg.scene, camera });
|
|
332
|
+
renderer.render({ scene, camera, clear: false });
|
|
333
|
+
} else if (visible || renderer.gl.canvas.dataset.dirty !== '0') {
|
|
334
|
+
renderer.render({ scene, camera });
|
|
335
|
+
renderer.gl.canvas.dataset.dirty = visible ? '1' : '0';
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### `src/engine/gl/shaders.ts`
|
|
341
|
+
|
|
342
|
+
```ts
|
|
343
|
+
// Shared vertex: bends the plane with scroll velocity, swells on hover.
|
|
344
|
+
export const vertex = /* glsl */ `
|
|
345
|
+
attribute vec3 position;
|
|
346
|
+
attribute vec2 uv;
|
|
347
|
+
uniform mat4 modelViewMatrix;
|
|
348
|
+
uniform mat4 projectionMatrix;
|
|
349
|
+
uniform float uVelocity;
|
|
350
|
+
uniform float uHover;
|
|
351
|
+
varying vec2 vUv;
|
|
352
|
+
void main() {
|
|
353
|
+
vUv = uv;
|
|
354
|
+
vec3 p = position;
|
|
355
|
+
float bend = sin(uv.x * 3.14159265);
|
|
356
|
+
p.y += bend * uVelocity * 0.06;
|
|
357
|
+
p.z += bend * uHover * 0.05;
|
|
358
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
|
|
359
|
+
}`;
|
|
360
|
+
|
|
361
|
+
const common = /* glsl */ `
|
|
362
|
+
precision highp float;
|
|
363
|
+
varying vec2 vUv;
|
|
364
|
+
uniform vec2 uPlane;
|
|
365
|
+
uniform float uTime;
|
|
366
|
+
uniform float uHover;
|
|
367
|
+
uniform float uVelocity;
|
|
368
|
+
uniform float uReveal;
|
|
369
|
+
uniform vec2 uMouse;
|
|
370
|
+
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
|
|
371
|
+
float noise(vec2 p) {
|
|
372
|
+
vec2 i = floor(p), f = fract(p);
|
|
373
|
+
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
374
|
+
return mix(mix(hash(i), hash(i + vec2(1, 0)), u.x), mix(hash(i + vec2(0, 1)), hash(i + vec2(1, 1)), u.x), u.y);
|
|
375
|
+
}
|
|
376
|
+
float fbm(vec2 p) {
|
|
377
|
+
float v = 0.0, a = 0.5;
|
|
378
|
+
for (int i = 0; i < 5; i++) { v += a * noise(p); p *= 2.02; a *= 0.5; }
|
|
379
|
+
return v;
|
|
380
|
+
}
|
|
381
|
+
// Reveal mask: rises from the bottom with an organic edge. uReveal 0 → hidden, 1 → shown.
|
|
382
|
+
float revealMask(vec2 uv) {
|
|
383
|
+
float edge = uReveal * 1.25 - 0.12 + (noise(uv * vec2(6.0, 2.0) + uTime * 0.2) - 0.5) * 0.12;
|
|
384
|
+
return smoothstep(edge, edge - 0.08, uv.y);
|
|
385
|
+
}`;
|
|
386
|
+
|
|
387
|
+
// Image plane: object-fit: cover in-shader, hover zoom + chromatic split driven by velocity.
|
|
388
|
+
export const imageFragment = /* glsl */ `
|
|
389
|
+
${common}
|
|
390
|
+
uniform sampler2D tMap;
|
|
391
|
+
uniform vec2 uImage;
|
|
392
|
+
vec2 cover(vec2 uv) {
|
|
393
|
+
vec2 r = vec2(min((uPlane.x / uPlane.y) / (uImage.x / uImage.y), 1.0), min((uPlane.y / uPlane.x) / (uImage.y / uImage.x), 1.0));
|
|
394
|
+
return uv * r + (1.0 - r) * 0.5;
|
|
395
|
+
}
|
|
396
|
+
void main() {
|
|
397
|
+
vec2 uv = vUv;
|
|
398
|
+
vec2 c = uv - 0.5;
|
|
399
|
+
uv = 0.5 + c * (1.0 - uHover * 0.06);
|
|
400
|
+
vec2 dir = (uv - uMouse) * uHover;
|
|
401
|
+
uv += dir * 0.04 * smoothstep(0.6, 0.0, length(vUv - uMouse));
|
|
402
|
+
float shift = (abs(uVelocity) * 0.004 + uHover * 0.004);
|
|
403
|
+
vec2 t = cover(uv);
|
|
404
|
+
float r = texture2D(tMap, t + vec2(shift, 0.0)).r;
|
|
405
|
+
float g = texture2D(tMap, t).g;
|
|
406
|
+
float b = texture2D(tMap, t - vec2(shift, 0.0)).b;
|
|
407
|
+
gl_FragColor = vec4(r, g, b, 1.0) * revealMask(vUv);
|
|
408
|
+
}`;
|
|
409
|
+
|
|
410
|
+
// Procedural plane: seeded flowing field in the palette. Honest generative cover art for
|
|
411
|
+
// projects that do not have imagery yet (never a fake screenshot).
|
|
412
|
+
export const proceduralFragment = /* glsl */ `
|
|
413
|
+
${common}
|
|
414
|
+
uniform vec3 uC1;
|
|
415
|
+
uniform vec3 uC2;
|
|
416
|
+
uniform vec3 uC3;
|
|
417
|
+
uniform float uSeed;
|
|
418
|
+
void main() {
|
|
419
|
+
vec2 uv = vUv;
|
|
420
|
+
vec2 p = uv * vec2(uPlane.x / uPlane.y, 1.0) * 1.6 + uSeed * 7.0;
|
|
421
|
+
float t = uTime * 0.05;
|
|
422
|
+
vec2 q = vec2(fbm(p + t), fbm(p + vec2(5.2, 1.3) - t));
|
|
423
|
+
vec2 m = (uMouse - 0.5) * uHover * 0.8;
|
|
424
|
+
float f = fbm(p + 2.5 * q + m + vec2(uVelocity * 0.02, 0.0));
|
|
425
|
+
vec3 col = mix(uC1, uC2, smoothstep(0.2, 0.75, f));
|
|
426
|
+
col = mix(col, uC3, smoothstep(0.55, 0.95, length(q) * f * 1.4));
|
|
427
|
+
col += (hash(uv * uPlane + fract(uTime)) - 0.5) * 0.045; // film grain
|
|
428
|
+
gl_FragColor = vec4(col, 1.0) * revealMask(vUv);
|
|
429
|
+
}`;
|
|
430
|
+
```
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Generated from jury/scripts/audit.mjs by tests/_gen/build.py; edit there, not here.
|
|
3
|
+
// Static audit of a production build: semantics/SEO, metadata, accessibility basics, page weight,
|
|
4
|
+
// leftover placeholders and AI-copy tells. Crawls same-origin links from the start page.
|
|
5
|
+
// node audit.mjs <url | build-dir> [--max 40]
|
|
6
|
+
// url: a running production server, e.g. `next start` → http://127.0.0.1:4400/
|
|
7
|
+
// build-dir: a static output folder (dist/, out/); served internally
|
|
8
|
+
// exit code 1 if any FAIL
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import zlib from 'node:zlib';
|
|
12
|
+
import { serve } from './serve.mjs';
|
|
13
|
+
|
|
14
|
+
const args = process.argv.slice(2);
|
|
15
|
+
const target = args.find((a, i) => !a.startsWith('--') && args[i - 1] !== '--max') || 'dist';
|
|
16
|
+
const maxPages = +(args[args.indexOf('--max') + 1] || 40) || 40;
|
|
17
|
+
let server = null;
|
|
18
|
+
let base = target;
|
|
19
|
+
if (!/^https?:\/\//.test(target)) {
|
|
20
|
+
if (!fs.existsSync(target)) { console.error(`No build at ${path.resolve(target)} and not a URL. Build first, or pass the server URL.`); process.exit(1); }
|
|
21
|
+
server = await serve(target, 0);
|
|
22
|
+
base = `http://127.0.0.1:${server.address().port}/`;
|
|
23
|
+
}
|
|
24
|
+
const origin = new URL(base).origin;
|
|
25
|
+
|
|
26
|
+
const results = [];
|
|
27
|
+
const add = (level, where, msg) => results.push({ level, where, msg });
|
|
28
|
+
const strip = (html) => html
|
|
29
|
+
.replace(/<script[\s\S]*?<\/script>/gi, ' ')
|
|
30
|
+
.replace(/<style[\s\S]*?<\/style>/gi, ' ')
|
|
31
|
+
.replace(/<[^>]+>/g, ' ')
|
|
32
|
+
.replace(/ | /g, ' ')
|
|
33
|
+
.replace(/&/g, '&')
|
|
34
|
+
.replace(/'|'|’/g, "'")
|
|
35
|
+
.replace(/\s+/g, ' ');
|
|
36
|
+
// Attributes as HTML parses them: double-quoted, single-quoted, unquoted (minifiers drop quotes:
|
|
37
|
+
// <html lang=en>) or bare (<img alt>, an empty value).
|
|
38
|
+
const ATTR = /\s([^\s"'>\/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
|
|
39
|
+
const attrs = (tag) => {
|
|
40
|
+
const out = {};
|
|
41
|
+
for (const m of tag.replace(/^<[^\s>]+/, '').matchAll(ATTR)) out[m[1].toLowerCase()] ??= m[2] ?? m[3] ?? m[4] ?? '';
|
|
42
|
+
return out;
|
|
43
|
+
};
|
|
44
|
+
const attr = (tag, name) => attrs(tag)[name] ?? null;
|
|
45
|
+
const TAG_BODY = `(?:"[^"]*"|'[^']*'|[^'">])*`; // a '>' inside a quoted value does not end the tag
|
|
46
|
+
const tags = (html, name) => html.match(new RegExp(`<${name}\\b${TAG_BODY}>`, 'gi')) || [];
|
|
47
|
+
const rels = (tag) => (attr(tag, 'rel') || '').toLowerCase().split(/\s+/);
|
|
48
|
+
const meta = (html, key) => {
|
|
49
|
+
const tag = tags(html, 'meta').find((t) => [attr(t, 'name'), attr(t, 'property')].some((v) => v?.toLowerCase() === key));
|
|
50
|
+
return tag ? attr(tag, 'content') : null;
|
|
51
|
+
};
|
|
52
|
+
const onSite = (u) => { const x = new URL(u); return new URL(x.pathname + x.search, origin).href; }; // production URLs → local server
|
|
53
|
+
const get = async (u) => {
|
|
54
|
+
try {
|
|
55
|
+
const r = await fetch(u, { redirect: 'follow' });
|
|
56
|
+
return { status: r.status, type: r.headers.get('content-type') || '', body: Buffer.from(await r.arrayBuffer()), url: r.url };
|
|
57
|
+
} catch (e) { return { status: 0, type: '', body: Buffer.alloc(0), url: u, error: e.message }; }
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const PLACEHOLDERS = [/lorem ipsum/i, /\bName Surname\b/, /example\.com/, /Replace with/i, /\bTODO\b/, /\bAcme\b/, /\bJohn Doe\b/i, /\bJane Doe\b/i, /One plain sentence about/i];
|
|
61
|
+
const TELLS = [
|
|
62
|
+
[/\b(elevate|seamless(ly)?|unleash|revolutioni[sz]e|cutting-edge|next-gen|synergy|game-chang)/i, 'filler marketing verb'],
|
|
63
|
+
[/\b(crafting digital experiences|pixel[- ]perfect|passionate about)\b/i, 'portfolio cliche'],
|
|
64
|
+
[/scroll to explore/i, 'generic scroll cue copy'],
|
|
65
|
+
// Page text is one line, so both phrases stop at sentence ends to avoid matching across sentences.
|
|
66
|
+
[/\bwhere\s+(?:[^\s.!?]+\s+){1,3}meets?\s+[^\s.!?,;:]+/i, 'portfolio cliche'],
|
|
67
|
+
[/\b(?:not|\w+n['’]t)\s+just\b[^.!?]{1,80}?\bbut\b/i, 'portfolio cliche'],
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
// Crawl
|
|
71
|
+
const pages = new Map(); // url → html
|
|
72
|
+
const queue = [new URL(base).href];
|
|
73
|
+
const seen = new Set(queue);
|
|
74
|
+
while (queue.length && pages.size < maxPages) {
|
|
75
|
+
const u = queue.shift();
|
|
76
|
+
const r = await get(u);
|
|
77
|
+
if (r.status >= 400 || r.status === 0) { add('FAIL', new URL(u).pathname, `HTTP ${r.status || r.error} for an internal link`); continue; }
|
|
78
|
+
if (!r.type.includes('html')) continue;
|
|
79
|
+
const html = r.body.toString('utf8');
|
|
80
|
+
pages.set(u, html);
|
|
81
|
+
for (const a of tags(html, 'a')) {
|
|
82
|
+
const href = attr(a, 'href');
|
|
83
|
+
if (!href || href.startsWith('#')) continue;
|
|
84
|
+
let next;
|
|
85
|
+
try { next = new URL(href.replace(/&/g, '&'), u); } catch { continue; }
|
|
86
|
+
next.hash = ''; next.search = '';
|
|
87
|
+
if (next.origin !== origin || seen.has(next.href) || /\.(?!html?$)[a-z0-9]{2,5}$/i.test(next.pathname)) continue;
|
|
88
|
+
seen.add(next.href);
|
|
89
|
+
queue.push(next.href);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!pages.size) { console.error(`Could not load ${base}`); add('FAIL', 'site', `start page ${base} did not load as HTML`); }
|
|
93
|
+
|
|
94
|
+
for (const [u, html] of pages) {
|
|
95
|
+
const where = new URL(u).pathname;
|
|
96
|
+
const head = html.match(/<head[\s\S]*?<\/head>/i)?.[0] || '';
|
|
97
|
+
const text = strip(html.replace(/<head[\s\S]*?<\/head>/i, ''));
|
|
98
|
+
if (!attr(tags(html, 'html')[0] || '', 'lang')?.trim()) add('FAIL', where, '<html> has no lang');
|
|
99
|
+
const title = (html.match(/<title[^>]*>([\s\S]*?)<\/title>/i) || [])[1]?.trim();
|
|
100
|
+
if (!title) add('FAIL', where, 'missing <title>');
|
|
101
|
+
else if (title.length > 70) add('WARN', where, `title is ${title.length} chars (keep <= 70)`);
|
|
102
|
+
const desc = meta(html, 'description');
|
|
103
|
+
if (!desc) add('FAIL', where, 'missing meta description');
|
|
104
|
+
else if (desc.length < 50 || desc.length > 170) add('WARN', where, `meta description is ${desc.length} chars (aim 50-160)`);
|
|
105
|
+
const links = tags(html, 'link');
|
|
106
|
+
if (!links.some((t) => rels(t).includes('canonical'))) add('WARN', where, 'no canonical link');
|
|
107
|
+
for (const k of ['og:title', 'og:description', 'og:image', 'twitter:card']) if (!meta(html, k)) add('WARN', where, `missing ${k}`);
|
|
108
|
+
if (!tags(html, 'meta').some((t) => attr(t, 'name')?.toLowerCase() === 'viewport')) add('FAIL', where, 'missing viewport meta');
|
|
109
|
+
if (!links.some((t) => rels(t).includes('icon'))) add('WARN', where, 'no favicon link');
|
|
110
|
+
|
|
111
|
+
const h1s = html.match(/<h1[\s>]/gi) || [];
|
|
112
|
+
if (h1s.length !== 1) add('FAIL', where, `${h1s.length} <h1> elements (want exactly 1)`);
|
|
113
|
+
const levels = [...html.matchAll(/<h([1-6])[\s>]/gi)].map((m) => +m[1]);
|
|
114
|
+
for (let i = 1; i < levels.length; i++) if (levels[i] > levels[i - 1] + 1) { add('WARN', where, `heading level skips h${levels[i - 1]} -> h${levels[i]}`); break; }
|
|
115
|
+
if (!/<main[\s>]/i.test(html)) add('FAIL', where, 'no <main> landmark');
|
|
116
|
+
|
|
117
|
+
for (const tag of tags(html, 'img')) {
|
|
118
|
+
const src = attr(tag, 'src') || '';
|
|
119
|
+
if (attr(tag, 'alt') === null) add('FAIL', where, `img without alt: ${src.slice(0, 60)}`);
|
|
120
|
+
if (!attr(tag, 'width') && !/\bfill\b|position:\s*absolute/.test(tag)) add('WARN', where, `img without width/height (layout shift): ${src.slice(0, 60)}`);
|
|
121
|
+
}
|
|
122
|
+
for (const m of html.matchAll(new RegExp(`<a\\b(${TAG_BODY})>([\\s\\S]*?)</a>`, 'gi'))) {
|
|
123
|
+
const a = `<a ${m[1]}>`;
|
|
124
|
+
if (!strip(m[2]).trim() && attr(a, 'aria-label') === null && !tags(m[2], 'img').some((t) => attr(t, 'alt')?.trim())) add('FAIL', where, `link with no accessible name: ${attr(a, 'href')}`);
|
|
125
|
+
if (attr(a, 'target')?.toLowerCase() === '_blank' && !rels(a).includes('noopener')) add('WARN', where, 'target=_blank without rel=noopener');
|
|
126
|
+
}
|
|
127
|
+
for (const m of html.matchAll(new RegExp(`<button\\b(${TAG_BODY})>([\\s\\S]*?)</button>`, 'gi'))) {
|
|
128
|
+
if (!strip(m[2]).trim() && attr(`<button ${m[1]}>`, 'aria-label') === null) add('FAIL', where, 'button with no accessible name');
|
|
129
|
+
}
|
|
130
|
+
if (/<div[^>]+onclick=/i.test(html)) add('FAIL', where, 'clickable <div> (use <button> or <a>)');
|
|
131
|
+
|
|
132
|
+
const dashes = (text.match(/[—–]/g) || []).length;
|
|
133
|
+
if (dashes) add('WARN', where, `${dashes} em/en dash(es) in visible text (read as AI tell; rewrite)`);
|
|
134
|
+
for (const re of PLACEHOLDERS) if (re.test(text) || re.test(head)) add('FAIL', where, `placeholder content: ${re}`);
|
|
135
|
+
for (const [re, why] of TELLS) { const m = text.match(re); if (m) add('WARN', where, `${why}: "${m[0]}"`); }
|
|
136
|
+
// The same sentence twice on one page reads as filler (e.g. hero line repeated in about).
|
|
137
|
+
const body = html.replace(/<head[\s\S]*?<\/head>/i, '').replace(/<script[\s\S]*?<\/script>/gi, '');
|
|
138
|
+
const sentences = [...body.matchAll(/<(p|h[1-6]|li|blockquote|figcaption|dd)\b[^>]*>([\s\S]*?)<\/\1>/gi)]
|
|
139
|
+
.flatMap((m) => strip(m[2]).split(/(?<=[.!?])\s+/))
|
|
140
|
+
.map((s) => s.trim())
|
|
141
|
+
.filter((s) => s.split(' ').length >= 6);
|
|
142
|
+
const counts = new Map();
|
|
143
|
+
for (const s of sentences) counts.set(s, (counts.get(s) || 0) + 1);
|
|
144
|
+
for (const [s, n] of counts) if (n > 1) add('WARN', where, `sentence repeated ${n}x: "${s.slice(0, 70)}"`);
|
|
145
|
+
// Headings must read cleanly: visual duplicates (shadows, outlines) belong outside them.
|
|
146
|
+
for (const m of html.matchAll(/<h([1-3])[^>]*>([\s\S]*?)<\/h\1>/gi)) {
|
|
147
|
+
const t = strip(m[2]).trim().split(' ').filter(Boolean);
|
|
148
|
+
const half = t.length / 2;
|
|
149
|
+
if (t.length >= 2 && t.length % 2 === 0 && t.slice(0, half).join(' ').toLowerCase() === t.slice(half).join(' ').toLowerCase()) add('FAIL', where, `<h${m[1]}> text is duplicated ("${t.join(' ')}"): move decorative copies out of the heading`);
|
|
150
|
+
}
|
|
151
|
+
const words = text.split(' ').filter(Boolean).length;
|
|
152
|
+
if (words < 60) add('WARN', where, `only ${words} words of visible text (thin content)`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Site level (skipped when the start page did not load: every check would fail with it)
|
|
156
|
+
if (pages.size) {
|
|
157
|
+
const missing = await get(new URL(`/__audit-missing-${Date.now()}`, origin).href);
|
|
158
|
+
if (missing.status !== 404) add('FAIL', 'site', `a missing URL returned HTTP ${missing.status}, not 404`);
|
|
159
|
+
else if (!/<h1[\s>]/i.test(missing.body.toString('utf8'))) add('WARN', 'site', '404 page has no <h1> (design it: a way back, in the site voice)');
|
|
160
|
+
const robots = await get(new URL('/robots.txt', origin).href);
|
|
161
|
+
if (robots.status !== 200) add('WARN', 'site', 'no robots.txt');
|
|
162
|
+
else if (/example\.com/.test(robots.body.toString())) add('WARN', 'site', 'robots.txt still points at example.com');
|
|
163
|
+
const maps = [...robots.body.toString().matchAll(/^sitemap:\s*(\S+)/gim)].map((m) => onSite(m[1]));
|
|
164
|
+
let sitemapOk = false;
|
|
165
|
+
for (const u of [...maps, new URL('/sitemap.xml', origin).href, new URL('/sitemap-index.xml', origin).href]) if ((await get(u)).status === 200) { sitemapOk = true; break; }
|
|
166
|
+
if (!sitemapOk) add('WARN', 'site', 'no sitemap');
|
|
167
|
+
const ogs = new Set([...pages.values()].map((h) => meta(h, 'og:image')).filter(Boolean));
|
|
168
|
+
// As written (a live site, or a CDN), else mapped onto this server (a local build whose tags
|
|
169
|
+
// already point at the production domain).
|
|
170
|
+
const isImage = (r) => r.status === 200 && r.type.startsWith('image/');
|
|
171
|
+
for (const og of ogs) {
|
|
172
|
+
const abs = new URL(og, origin).href;
|
|
173
|
+
if (!isImage(await get(abs)) && !isImage(await get(onSite(abs)))) add('FAIL', 'site', `og:image ${abs} does not load (create a 1200x630 image)`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Weight: what each page actually downloads (gzip size for text assets).
|
|
178
|
+
const sizes = new Map();
|
|
179
|
+
const kb = (b) => Math.round(b / 1024);
|
|
180
|
+
async function size(u) {
|
|
181
|
+
if (sizes.has(u)) return sizes.get(u);
|
|
182
|
+
const r = await get(u);
|
|
183
|
+
const text = /javascript|css|html|json|svg/.test(r.type);
|
|
184
|
+
const entry = { bytes: r.status === 200 ? (text ? zlib.gzipSync(r.body).length : r.body.length) : 0, type: r.type, body: r.body, url: u };
|
|
185
|
+
sizes.set(u, entry);
|
|
186
|
+
return entry;
|
|
187
|
+
}
|
|
188
|
+
const pick = (tag) => {
|
|
189
|
+
const set = attr(tag, 'srcset');
|
|
190
|
+
if (set) {
|
|
191
|
+
const c = set.split(',').map((s) => s.trim().split(/\s+/)).map(([u, d]) => ({ u, w: parseFloat(d) || 0 })).filter((c) => c.u).sort((a, b) => a.w - b.w);
|
|
192
|
+
return (c.find((x) => x.w >= 1440) || c[c.length - 1])?.u;
|
|
193
|
+
}
|
|
194
|
+
return attr(tag, 'src');
|
|
195
|
+
};
|
|
196
|
+
let worst = null;
|
|
197
|
+
for (const [u, html] of pages) {
|
|
198
|
+
const where = new URL(u).pathname;
|
|
199
|
+
const res = (list) => list.filter(Boolean).map((x) => new URL(x.replace(/&/g, '&'), u).href);
|
|
200
|
+
const links = tags(html, 'link');
|
|
201
|
+
const js = res(tags(html, 'script').map((t) => attr(t, 'src')));
|
|
202
|
+
const css = res(links.filter((t) => rels(t).includes('stylesheet')).map((t) => attr(t, 'href')));
|
|
203
|
+
const preFonts = res(links.map((t) => attr(t, 'href')).filter((h) => /\.(?:woff2?|ttf|otf)$/i.test(h || '')));
|
|
204
|
+
const imgs = res(tags(html, 'img').map(pick));
|
|
205
|
+
const tally = { html: (await size(u)).bytes, js: 0, css: 0, fonts: 0, img: 0 };
|
|
206
|
+
for (const x of new Set(js)) tally.js += (await size(x)).bytes;
|
|
207
|
+
const fonts = new Set(preFonts);
|
|
208
|
+
for (const x of new Set(css)) {
|
|
209
|
+
const c = await size(x);
|
|
210
|
+
tally.css += c.bytes;
|
|
211
|
+
// Fonts the latin page will fetch: @font-face without unicode-range or covering basic latin.
|
|
212
|
+
for (const face of c.body.toString().match(/@font-face\s*{[^}]+}/g) || []) {
|
|
213
|
+
const range = face.match(/unicode-range:\s*([^;}]+)/)?.[1];
|
|
214
|
+
if (range && !/U\+0000|U\+0020|U\+00?20-/i.test(range)) continue;
|
|
215
|
+
const f = face.match(/url\(["']?([^"')]+\.(?:woff2?|ttf|otf))/)?.[1];
|
|
216
|
+
if (f) fonts.add(new URL(f, x).href);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
for (const f of fonts) { tally.fonts += (await size(f)).bytes; if (/\.(ttf|otf)$/.test(f)) add('WARN', where, `ttf/otf font shipped: ${path.basename(f)} (use woff2)`); }
|
|
220
|
+
for (const x of new Set(imgs)) {
|
|
221
|
+
const s = (await size(x)).bytes;
|
|
222
|
+
tally.img += s;
|
|
223
|
+
if (s > 500 * 1024) add('WARN', where, `image ${kb(s)} KB: ${x.replace(origin, '').slice(0, 70)} (compress, AVIF/WebP, smaller variant)`);
|
|
224
|
+
}
|
|
225
|
+
const total = tally.html + tally.js + tally.css + tally.fonts + tally.img;
|
|
226
|
+
if (kb(tally.js) > 300) add('WARN', where, `JS ${kb(tally.js)} KB gzipped (aim < 300 KB; lazy-load heavy libraries)`);
|
|
227
|
+
if (kb(tally.fonts) > 300) add('WARN', where, `fonts ${kb(tally.fonts)} KB (fewer weights, variable font, subset)`);
|
|
228
|
+
if (kb(total) > 3000) add('WARN', where, `page weight ~${kb(total)} KB (aim < 3 MB)`);
|
|
229
|
+
if (!worst || total > worst.total) worst = { where, total, ...tally };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const order = { FAIL: 0, WARN: 1 };
|
|
233
|
+
results.sort((a, b) => order[a.level] - order[b.level]);
|
|
234
|
+
for (const r of results) console.log(`${r.level.padEnd(4)} ${r.where.padEnd(28)} ${r.msg}`);
|
|
235
|
+
const fails = results.filter((r) => r.level === 'FAIL').length;
|
|
236
|
+
console.log(`\n${pages.size} pages crawled from ${base}`);
|
|
237
|
+
if (worst) console.log(`heaviest page ${worst.where}: ~${kb(worst.total)} KB | html ${kb(worst.html)} | JS ${kb(worst.js)} (gz) | CSS ${kb(worst.css)} (gz) | fonts ${kb(worst.fonts)} | images ${kb(worst.img)}`);
|
|
238
|
+
console.log(`${fails} FAIL, ${results.length - fails} WARN`);
|
|
239
|
+
// Let Node exit on its own: process.exit() right after fetch() aborts Node on Windows (libuv
|
|
240
|
+
// UV_HANDLE_CLOSING assertion, exit code 127) instead of returning this code.
|
|
241
|
+
server?.closeAllConnections();
|
|
242
|
+
server?.close();
|
|
243
|
+
process.exitCode = fails ? 1 : 0;
|