@thanhnguyxn/pixelcraft 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +20 -0
- package/.antigravity-plugin/plugin.json +32 -0
- package/.claude-plugin/marketplace.json +20 -0
- package/.claude-plugin/plugin.json +22 -0
- package/.codex-plugin/plugin.json +45 -0
- package/.cursor-plugin/marketplace.json +17 -0
- package/.cursor-plugin/plugin.json +27 -0
- package/.devin-plugin/plugin.json +21 -0
- package/.github/plugin/marketplace.json +34 -0
- package/CHANGELOG.md +159 -0
- package/GEMINI.md +1 -0
- package/LICENSE +21 -0
- package/README.md +264 -2
- package/SECURITY.md +28 -0
- package/assets/README.md +28 -0
- package/assets/pixelcraft-logo-128.png +0 -0
- package/assets/pixelcraft-logo-256.png +0 -0
- package/assets/pixelcraft-logo-512.png +0 -0
- package/bin/pixelcraft.mjs +852 -0
- package/docs/ARCHITECTURE.md +105 -0
- package/docs/DESIGN-RATIONALE.md +191 -0
- package/docs/INSTALL.md +221 -0
- package/evals/README.md +37 -0
- package/evals/fixtures/3d-web-engineering.json +69 -0
- package/evals/fixtures/README.md +36 -0
- package/evals/fixtures/acceptance-checklist-rule03-gate.json +43 -0
- package/evals/fixtures/ai-ui-libraries.json +53 -0
- package/evals/fixtures/audio-visual-accessibility.json +69 -0
- package/evals/fixtures/auth-and-checkout-ui.json +53 -0
- package/evals/fixtures/brandkit-identity-governance.json +48 -0
- package/evals/fixtures/build-and-architecture.json +53 -0
- package/evals/fixtures/canvas-and-node-editors.json +53 -0
- package/evals/fixtures/chat-ai-exfiltration-ime-hitl-gate.json +43 -0
- package/evals/fixtures/completion-gate-scan-until-clean.json +44 -0
- package/evals/fixtures/component-systems.json +53 -0
- package/evals/fixtures/component-testing.json +53 -0
- package/evals/fixtures/constrained-voice-and-tv.json +43 -0
- package/evals/fixtures/creative-code-rendering.json +69 -0
- package/evals/fixtures/creative-reference-evidence.json +67 -0
- package/evals/fixtures/data-app-python-marimo.json +49 -0
- package/evals/fixtures/desktop-cpp-juce-audio.json +49 -0
- package/evals/fixtures/desktop-csharp-avalonia.json +49 -0
- package/evals/fixtures/desktop-native-workspace.json +48 -0
- package/evals/fixtures/desktop-python-anti-tkinter.json +49 -0
- package/evals/fixtures/direction-prototype-complexity.json +29 -0
- package/evals/fixtures/document-prepress-pdfx4-tounicode.json +43 -0
- package/evals/fixtures/document-rust-typst-invoice.json +49 -0
- package/evals/fixtures/document-typst-and-print-css.json +43 -0
- package/evals/fixtures/email-mjml-dark-mode.json +49 -0
- package/evals/fixtures/email-outlook-and-plaintext.json +43 -0
- package/evals/fixtures/enterprise-data-ui.json +53 -0
- package/evals/fixtures/extended-tui-toolkits.json +53 -0
- package/evals/fixtures/extensions-mv3-and-vscode.json +43 -0
- package/evals/fixtures/file-upload-media-ui.json +53 -0
- package/evals/fixtures/finish-gate-anti-slop.json +30 -0
- package/evals/fixtures/forms-accessibility-negative.json +29 -0
- package/evals/fixtures/forms-validation.json +53 -0
- package/evals/fixtures/game-go-ebitengine.json +49 -0
- package/evals/fixtures/game-godot-gdscript.json +49 -0
- package/evals/fixtures/game-ui-hud-and-engines.json +43 -0
- package/evals/fixtures/handoff-fidelity-tolerance.json +29 -0
- package/evals/fixtures/i18n-engineering.json +53 -0
- package/evals/fixtures/local-first-sync.json +53 -0
- package/evals/fixtures/lynxjs.json +53 -0
- package/evals/fixtures/maizzle-email.json +53 -0
- package/evals/fixtures/maps-geospatial.json +53 -0
- package/evals/fixtures/media-og-and-video-export.json +43 -0
- package/evals/fixtures/media-players.json +53 -0
- package/evals/fixtures/mobile-compose-16kb-foldable-store-gate.json +44 -0
- package/evals/fixtures/mobile-elixir-liveview-native.json +49 -0
- package/evals/fixtures/mobile-flutter-dynamic-type.json +49 -0
- package/evals/fixtures/mobile-harmonyos-arkui.json +49 -0
- package/evals/fixtures/mobile-jetpack-compose.json +49 -0
- package/evals/fixtures/mobile-swiftui-ios.json +49 -0
- package/evals/fixtures/motion-engineering.json +69 -0
- package/evals/fixtures/pdfjs-and-pptx.json +53 -0
- package/evals/fixtures/plan-brownfield-evidence.json +28 -0
- package/evals/fixtures/plan-discovery-interview.json +31 -0
- package/evals/fixtures/plan-grill-me-brainstorm-gate.json +49 -0
- package/evals/fixtures/reactive-data-apps.json +53 -0
- package/evals/fixtures/review-evidence-audit.json +43 -0
- package/evals/fixtures/rich-text-and-code-editors.json +53 -0
- package/evals/fixtures/scrollytelling-resilience.json +70 -0
- package/evals/fixtures/spatial-xr-comfort-and-platforms.json +43 -0
- package/evals/fixtures/state-architecture.json +53 -0
- package/evals/fixtures/styling-ecosystem.json +53 -0
- package/evals/fixtures/token-tooling.json +53 -0
- package/evals/fixtures/tui-go-bubbletea.json +49 -0
- package/evals/fixtures/tui-rust-ratatui-grapheme-paste-teardown.json +44 -0
- package/evals/fixtures/tui-rust-ratatui.json +49 -0
- package/evals/fixtures/ux-state-matrix-and-i18n.json +43 -0
- package/evals/fixtures/visual-qa-task-evidence.json +29 -0
- package/evals/fixtures/web-3d-engines.json +53 -0
- package/evals/fixtures/web-php-laravel-filament.json +49 -0
- package/evals/fixtures/web-ruby-viewcomponent-phlex.json +49 -0
- package/evals/fixtures/workflow-checkpoints.json +30 -0
- package/evals/pixelcraft-accessibility.md +74 -0
- package/evals/pixelcraft-brandkit.md +58 -0
- package/evals/pixelcraft-chat-ui.md +55 -0
- package/evals/pixelcraft-constrained.md +55 -0
- package/evals/pixelcraft-craft.md +76 -0
- package/evals/pixelcraft-data-apps.md +55 -0
- package/evals/pixelcraft-dataviz.md +59 -0
- package/evals/pixelcraft-desktop.md +55 -0
- package/evals/pixelcraft-direction.md +77 -0
- package/evals/pixelcraft-document.md +55 -0
- package/evals/pixelcraft-email.md +55 -0
- package/evals/pixelcraft-extensions.md +55 -0
- package/evals/pixelcraft-game-ui.md +59 -0
- package/evals/pixelcraft-handoff.md +57 -0
- package/evals/pixelcraft-media.md +55 -0
- package/evals/pixelcraft-mobile.md +59 -0
- package/evals/pixelcraft-patterns.md +73 -0
- package/evals/pixelcraft-plan.md +127 -0
- package/evals/pixelcraft-review.md +63 -0
- package/evals/pixelcraft-spatial.md +55 -0
- package/evals/pixelcraft-tokens.md +57 -0
- package/evals/pixelcraft-tui.md +55 -0
- package/evals/pixelcraft-ux.md +59 -0
- package/evals/pixelcraft-visual-qa.md +86 -0
- package/evals/pixelcraft-web.md +89 -0
- package/evals/pixelcraft.md +70 -0
- package/gemini-extension.json +6 -0
- package/install.ps1 +341 -0
- package/install.sh +512 -0
- package/package.json +91 -4
- package/plugin.json +29 -0
- package/scripts/build-adapters.mjs +288 -0
- package/scripts/build-release-archives.mjs +61 -0
- package/scripts/build-skill-zips.mjs +94 -0
- package/scripts/run-evals.mjs +397 -0
- package/scripts/sync-docs.mjs +381 -0
- package/scripts/test-build-adapters.mjs +61 -0
- package/scripts/test-cross-platform-qa.mjs +359 -0
- package/scripts/test-distribution.mjs +203 -0
- package/scripts/test-export-tokens.mjs +361 -0
- package/scripts/test-finish-gate.mjs +271 -0
- package/scripts/test-installers.mjs +216 -0
- package/scripts/test-release-archives.mjs +42 -0
- package/scripts/test-shoot.mjs +87 -0
- package/scripts/test-slop-scan.mjs +416 -0
- package/scripts/test-style-inventory.mjs +234 -0
- package/scripts/test-sync-docs.mjs +140 -0
- package/scripts/test-validate-skills.mjs +195 -0
- package/scripts/validate-skills.mjs +658 -0
- package/skills/pixelcraft/SKILL.md +155 -0
- package/skills/pixelcraft/references/design-brief.md +75 -0
- package/skills/pixelcraft/references/floor.md +90 -0
- package/skills/pixelcraft/references/report-template.md +49 -0
- package/skills/pixelcraft/references/stack-detection.md +226 -0
- package/skills/pixelcraft/references/surface-acceptance.md +52 -0
- package/skills/pixelcraft/references/workflow-checkpoints.md +71 -0
- package/skills/pixelcraft-accessibility/SKILL.md +54 -0
- package/skills/pixelcraft-accessibility/references/apg-patterns.md +64 -0
- package/skills/pixelcraft-accessibility/references/motion-canvas.md +57 -0
- package/skills/pixelcraft-accessibility/references/platforms.md +86 -0
- package/skills/pixelcraft-accessibility/references/verification.md +64 -0
- package/skills/pixelcraft-accessibility/references/wcag22-checks.md +99 -0
- package/skills/pixelcraft-brandkit/SKILL.md +127 -0
- package/skills/pixelcraft-brandkit/references/asset-pipeline.md +165 -0
- package/skills/pixelcraft-brandkit/references/brand-governance.md +82 -0
- package/skills/pixelcraft-brandkit/references/layouts.md +88 -0
- package/skills/pixelcraft-brandkit/references/logo-concepting.md +83 -0
- package/skills/pixelcraft-brandkit/references/logo-methods.md +97 -0
- package/skills/pixelcraft-brandkit/references/pixel-art-logos.md +82 -0
- package/skills/pixelcraft-brandkit/references/prompt-template.md +87 -0
- package/skills/pixelcraft-brandkit/references/qa-checklist.md +93 -0
- package/skills/pixelcraft-brandkit/references/visual-modes.md +123 -0
- package/skills/pixelcraft-chat-ui/SKILL.md +57 -0
- package/skills/pixelcraft-chat-ui/references/agentic-workspace.md +66 -0
- package/skills/pixelcraft-chat-ui/references/ai-ui-libraries.md +259 -0
- package/skills/pixelcraft-chat-ui/references/conversation-design.md +84 -0
- package/skills/pixelcraft-chat-ui/references/mobile-business-platforms.md +77 -0
- package/skills/pixelcraft-chat-ui/references/slack-discord.md +80 -0
- package/skills/pixelcraft-constrained/SKILL.md +52 -0
- package/skills/pixelcraft-constrained/references/specialized-hardware.md +90 -0
- package/skills/pixelcraft-constrained/references/tv-wearables.md +134 -0
- package/skills/pixelcraft-constrained/references/voice-ui.md +104 -0
- package/skills/pixelcraft-craft/SKILL.md +58 -0
- package/skills/pixelcraft-craft/references/color.md +125 -0
- package/skills/pixelcraft-craft/references/imagery-icons.md +37 -0
- package/skills/pixelcraft-craft/references/layout-quality.md +65 -0
- package/skills/pixelcraft-craft/references/layout.md +73 -0
- package/skills/pixelcraft-craft/references/motion.md +163 -0
- package/skills/pixelcraft-craft/references/typography.md +110 -0
- package/skills/pixelcraft-data-apps/SKILL.md +86 -0
- package/skills/pixelcraft-data-apps/references/ai-and-internal-data-apps.md +147 -0
- package/skills/pixelcraft-data-apps/references/dash.md +109 -0
- package/skills/pixelcraft-data-apps/references/evidence.md +90 -0
- package/skills/pixelcraft-data-apps/references/gradio.md +103 -0
- package/skills/pixelcraft-data-apps/references/julia-genie.md +89 -0
- package/skills/pixelcraft-data-apps/references/jupyter-widgets.md +91 -0
- package/skills/pixelcraft-data-apps/references/nicegui.md +102 -0
- package/skills/pixelcraft-data-apps/references/observable-framework.md +105 -0
- package/skills/pixelcraft-data-apps/references/panel.md +99 -0
- package/skills/pixelcraft-data-apps/references/r-shiny.md +124 -0
- package/skills/pixelcraft-data-apps/references/reactive-data-apps.md +186 -0
- package/skills/pixelcraft-data-apps/references/reflex.md +116 -0
- package/skills/pixelcraft-data-apps/references/shiny.md +110 -0
- package/skills/pixelcraft-data-apps/references/streamlit.md +113 -0
- package/skills/pixelcraft-dataviz/SKILL.md +60 -0
- package/skills/pixelcraft-dataviz/references/chart-choice.md +55 -0
- package/skills/pixelcraft-dataviz/references/color-accessibility.md +112 -0
- package/skills/pixelcraft-dataviz/references/encoding-tables-dashboards.md +107 -0
- package/skills/pixelcraft-dataviz/references/libraries.md +176 -0
- package/skills/pixelcraft-dataviz/references/maps-geospatial.md +159 -0
- package/skills/pixelcraft-dataviz/references/realtime-graphs-maps-scale.md +92 -0
- package/skills/pixelcraft-desktop/SKILL.md +93 -0
- package/skills/pixelcraft-desktop/references/appkit.md +92 -0
- package/skills/pixelcraft-desktop/references/avalonia.md +95 -0
- package/skills/pixelcraft-desktop/references/cpp-gui.md +129 -0
- package/skills/pixelcraft-desktop/references/electron.md +96 -0
- package/skills/pixelcraft-desktop/references/go-gui.md +83 -0
- package/skills/pixelcraft-desktop/references/gtk.md +97 -0
- package/skills/pixelcraft-desktop/references/javafx-swing.md +81 -0
- package/skills/pixelcraft-desktop/references/qt-pyside-qml.md +88 -0
- package/skills/pixelcraft-desktop/references/rust-gui.md +83 -0
- package/skills/pixelcraft-desktop/references/tauri.md +110 -0
- package/skills/pixelcraft-desktop/references/uno-platform.md +71 -0
- package/skills/pixelcraft-desktop/references/winui-wpf.md +98 -0
- package/skills/pixelcraft-desktop/references/working-context.md +84 -0
- package/skills/pixelcraft-direction/SKILL.md +120 -0
- package/skills/pixelcraft-direction/references/composition-library.md +84 -0
- package/skills/pixelcraft-direction/references/creative-brainstorming.md +72 -0
- package/skills/pixelcraft-direction/references/direction-card.md +64 -0
- package/skills/pixelcraft-direction/references/direction-scoring.md +76 -0
- package/skills/pixelcraft-direction/references/motion-identity.md +67 -0
- package/skills/pixelcraft-direction/references/movements.md +71 -0
- package/skills/pixelcraft-direction/references/reference-analysis.md +37 -0
- package/skills/pixelcraft-direction/references/repetition-history.md +75 -0
- package/skills/pixelcraft-direction/references/slop-fingerprints.md +83 -0
- package/skills/pixelcraft-direction/references/wildcards.md +47 -0
- package/skills/pixelcraft-document/SKILL.md +58 -0
- package/skills/pixelcraft-document/references/archetypes.md +106 -0
- package/skills/pixelcraft-document/references/pdf-tools.md +314 -0
- package/skills/pixelcraft-document/references/pdfjs-and-pptx.md +114 -0
- package/skills/pixelcraft-document/references/print-css.md +187 -0
- package/skills/pixelcraft-document/references/slides.md +198 -0
- package/skills/pixelcraft-email/SKILL.md +80 -0
- package/skills/pixelcraft-email/references/client-quirks.md +113 -0
- package/skills/pixelcraft-email/references/html-tables.md +114 -0
- package/skills/pixelcraft-email/references/maizzle.md +54 -0
- package/skills/pixelcraft-email/references/mjml.md +54 -0
- package/skills/pixelcraft-email/references/react-email.md +95 -0
- package/skills/pixelcraft-extensions/SKILL.md +56 -0
- package/skills/pixelcraft-extensions/references/browser-extensions.md +105 -0
- package/skills/pixelcraft-extensions/references/figma-office.md +106 -0
- package/skills/pixelcraft-extensions/references/ide-and-saas-plugins.md +125 -0
- package/skills/pixelcraft-extensions/references/raycast.md +98 -0
- package/skills/pixelcraft-extensions/references/vscode-webviews.md +100 -0
- package/skills/pixelcraft-game-ui/SKILL.md +80 -0
- package/skills/pixelcraft-game-ui/references/bevy.md +90 -0
- package/skills/pixelcraft-game-ui/references/godot.md +130 -0
- package/skills/pixelcraft-game-ui/references/hud-principles.md +67 -0
- package/skills/pixelcraft-game-ui/references/love2d.md +77 -0
- package/skills/pixelcraft-game-ui/references/monogame.md +68 -0
- package/skills/pixelcraft-game-ui/references/unity-ugui.md +109 -0
- package/skills/pixelcraft-game-ui/references/unity-ui-toolkit.md +107 -0
- package/skills/pixelcraft-game-ui/references/unreal-umg.md +80 -0
- package/skills/pixelcraft-game-ui/references/web-and-middleware-game-ui.md +122 -0
- package/skills/pixelcraft-handoff/SKILL.md +50 -0
- package/skills/pixelcraft-handoff/references/design-translation.md +134 -0
- package/skills/pixelcraft-handoff/references/fidelity-tolerance.md +78 -0
- package/skills/pixelcraft-handoff/references/motion-handoff.md +54 -0
- package/skills/pixelcraft-media/SKILL.md +49 -0
- package/skills/pixelcraft-media/references/banners-video.md +130 -0
- package/skills/pixelcraft-media/references/og-generation.md +154 -0
- package/skills/pixelcraft-media/references/social-cards.md +71 -0
- package/skills/pixelcraft-mobile/SKILL.md +86 -0
- package/skills/pixelcraft-mobile/references/dotnet-maui.md +91 -0
- package/skills/pixelcraft-mobile/references/flet.md +80 -0
- package/skills/pixelcraft-mobile/references/flutter.md +113 -0
- package/skills/pixelcraft-mobile/references/harmonyos-and-emerging-mobile.md +121 -0
- package/skills/pixelcraft-mobile/references/ionic-capacitor.md +87 -0
- package/skills/pixelcraft-mobile/references/jetpack-compose.md +129 -0
- package/skills/pixelcraft-mobile/references/kivy.md +82 -0
- package/skills/pixelcraft-mobile/references/kotlin-multiplatform.md +86 -0
- package/skills/pixelcraft-mobile/references/lynxjs.md +110 -0
- package/skills/pixelcraft-mobile/references/nativescript-and-skip.md +91 -0
- package/skills/pixelcraft-mobile/references/react-native-expo.md +106 -0
- package/skills/pixelcraft-mobile/references/swiftui.md +200 -0
- package/skills/pixelcraft-mobile/references/tactile-interactions.md +55 -0
- package/skills/pixelcraft-mobile/references/task-state-composition.md +85 -0
- package/skills/pixelcraft-mobile/references/uikit.md +92 -0
- package/skills/pixelcraft-patterns/SKILL.md +75 -0
- package/skills/pixelcraft-patterns/references/accessibility-resilience.md +29 -0
- package/skills/pixelcraft-patterns/references/ai-and-offline-patterns.md +54 -0
- package/skills/pixelcraft-patterns/references/auth-onboarding.md +44 -0
- package/skills/pixelcraft-patterns/references/billing-paywalls.md +40 -0
- package/skills/pixelcraft-patterns/references/command-workspace.md +56 -0
- package/skills/pixelcraft-patterns/references/commerce.md +47 -0
- package/skills/pixelcraft-patterns/references/communication.md +45 -0
- package/skills/pixelcraft-patterns/references/creative-tools.md +42 -0
- package/skills/pixelcraft-patterns/references/creative-web-composition.md +38 -0
- package/skills/pixelcraft-patterns/references/dashboard-admin.md +35 -0
- package/skills/pixelcraft-patterns/references/history-diff-undo.md +50 -0
- package/skills/pixelcraft-patterns/references/marketing.md +44 -0
- package/skills/pixelcraft-patterns/references/multi-tenant-rbac.md +47 -0
- package/skills/pixelcraft-patterns/references/narrative-systems.md +42 -0
- package/skills/pixelcraft-patterns/references/notifications-activity.md +57 -0
- package/skills/pixelcraft-patterns/references/pattern-selection.md +80 -0
- package/skills/pixelcraft-patterns/references/scheduling-kanban.md +47 -0
- package/skills/pixelcraft-patterns/references/scroll-implementation.md +37 -0
- package/skills/pixelcraft-patterns/references/search-filtering.md +42 -0
- package/skills/pixelcraft-patterns/references/settings.md +51 -0
- package/skills/pixelcraft-patterns/references/tables-crud.md +43 -0
- package/skills/pixelcraft-plan/SKILL.md +103 -0
- package/skills/pixelcraft-plan/references/design-input.md +69 -0
- package/skills/pixelcraft-plan/references/discovery-interview.md +110 -0
- package/skills/pixelcraft-plan/references/grill-me-protocol.md +63 -0
- package/skills/pixelcraft-plan/references/plan-template.md +134 -0
- package/skills/pixelcraft-plan/references/repo-discovery.md +49 -0
- package/skills/pixelcraft-plan/references/stack-freshness.md +67 -0
- package/skills/pixelcraft-plan/references/stack-selection.md +98 -0
- package/skills/pixelcraft-review/SKILL.md +86 -0
- package/skills/pixelcraft-review/references/audit-report.md +69 -0
- package/skills/pixelcraft-review/references/critique-protocol.md +89 -0
- package/skills/pixelcraft-review/references/heuristics.md +63 -0
- package/skills/pixelcraft-review/references/personas.md +53 -0
- package/skills/pixelcraft-review/references/polish.md +78 -0
- package/skills/pixelcraft-review/scripts/check-acceptance.mjs +619 -0
- package/skills/pixelcraft-review/scripts/fixtures/brand-critique-waivers.json +14 -0
- package/skills/pixelcraft-review/scripts/fixtures/brand-critique.css +18 -0
- package/skills/pixelcraft-review/scripts/fixtures/clean.html +43 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-after-block.css +4 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-at-rules.css +17 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-comments.css +10 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-html-quote-leak.html +12 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-invalid-replacements.css +27 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-longhand-removal.css +34 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-nested-rules.css +19 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-not-visible-skip.css +8 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-outline-shorthands.css +11 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-unknown-and-border.css +15 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-unknown-last-wins.css +19 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-valid-replacements-extended.css +29 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-visible-no-replacement.css +3 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-visible-valid-replacements.css +9 -0
- package/skills/pixelcraft-review/scripts/fixtures/slop.html +28 -0
- package/skills/pixelcraft-review/scripts/slop-scan.mjs +1233 -0
- package/skills/pixelcraft-spatial/SKILL.md +51 -0
- package/skills/pixelcraft-spatial/references/comfort-accessibility.md +39 -0
- package/skills/pixelcraft-spatial/references/platforms.md +147 -0
- package/skills/pixelcraft-tokens/SKILL.md +60 -0
- package/skills/pixelcraft-tokens/assets/tokens.example.json +71 -0
- package/skills/pixelcraft-tokens/assets/tokens.modes.example.json +47 -0
- package/skills/pixelcraft-tokens/references/adoption.md +55 -0
- package/skills/pixelcraft-tokens/references/format.md +84 -0
- package/skills/pixelcraft-tokens/references/governance.md +80 -0
- package/skills/pixelcraft-tokens/references/state-tokens.md +62 -0
- package/skills/pixelcraft-tokens/references/theme-presets.md +122 -0
- package/skills/pixelcraft-tokens/references/token-tooling.md +119 -0
- package/skills/pixelcraft-tokens/scripts/export-tokens.mjs +847 -0
- package/skills/pixelcraft-tui/SKILL.md +76 -0
- package/skills/pixelcraft-tui/references/bubbletea-lipgloss.md +79 -0
- package/skills/pixelcraft-tui/references/extended-tui-toolkits.md +127 -0
- package/skills/pixelcraft-tui/references/ink.md +109 -0
- package/skills/pixelcraft-tui/references/ratatui.md +102 -0
- package/skills/pixelcraft-tui/references/rich.md +82 -0
- package/skills/pixelcraft-tui/references/terminal-protocols.md +80 -0
- package/skills/pixelcraft-tui/references/textual.md +108 -0
- package/skills/pixelcraft-ux/SKILL.md +56 -0
- package/skills/pixelcraft-ux/references/cognitive-walkthrough.md +70 -0
- package/skills/pixelcraft-ux/references/feedback-performance.md +50 -0
- package/skills/pixelcraft-ux/references/flows-ia.md +44 -0
- package/skills/pixelcraft-ux/references/forms.md +151 -0
- package/skills/pixelcraft-ux/references/i18n.md +221 -0
- package/skills/pixelcraft-ux/references/laws.md +39 -0
- package/skills/pixelcraft-ux/references/locale-test-matrix.md +60 -0
- package/skills/pixelcraft-ux/references/state-matrix.md +53 -0
- package/skills/pixelcraft-ux/references/usability-testing.md +84 -0
- package/skills/pixelcraft-ux/references/ux-writing.md +44 -0
- package/skills/pixelcraft-visual-qa/SKILL.md +96 -0
- package/skills/pixelcraft-visual-qa/references/baseline-governance.md +70 -0
- package/skills/pixelcraft-visual-qa/references/capture-desktop-game.md +59 -0
- package/skills/pixelcraft-visual-qa/references/capture-document.md +70 -0
- package/skills/pixelcraft-visual-qa/references/capture-email.md +38 -0
- package/skills/pixelcraft-visual-qa/references/capture-mobile.md +50 -0
- package/skills/pixelcraft-visual-qa/references/capture-terminal.md +35 -0
- package/skills/pixelcraft-visual-qa/references/critique-rubric.md +71 -0
- package/skills/pixelcraft-visual-qa/references/finish-gate.md +35 -0
- package/skills/pixelcraft-visual-qa/references/measured-craft.md +30 -0
- package/skills/pixelcraft-visual-qa/references/motion-capture.md +63 -0
- package/skills/pixelcraft-visual-qa/references/performance-budgets.md +78 -0
- package/skills/pixelcraft-visual-qa/references/realtime-graphics.md +55 -0
- package/skills/pixelcraft-visual-qa/references/task-verification.md +81 -0
- package/skills/pixelcraft-visual-qa/scripts/check-contrast.mjs +442 -0
- package/skills/pixelcraft-visual-qa/scripts/check-email.mjs +397 -0
- package/skills/pixelcraft-visual-qa/scripts/check-pdf.mjs +189 -0
- package/skills/pixelcraft-visual-qa/scripts/check-tui.mjs +321 -0
- package/skills/pixelcraft-visual-qa/scripts/finish-gate.mjs +174 -0
- package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-aria-modal.html +19 -0
- package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-audit.html +34 -0
- package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-modal.html +17 -0
- package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory-deferred.js +1 -0
- package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory-edge.html +52 -0
- package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory.html +80 -0
- package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory.js +8 -0
- package/skills/pixelcraft-visual-qa/scripts/shoot.mjs +668 -0
- package/skills/pixelcraft-visual-qa/scripts/style-inventory.mjs +1226 -0
- package/skills/pixelcraft-web/SKILL.md +132 -0
- package/skills/pixelcraft-web/references/accessibility-performance.md +42 -0
- package/skills/pixelcraft-web/references/adaptive-layout.md +69 -0
- package/skills/pixelcraft-web/references/angular.md +108 -0
- package/skills/pixelcraft-web/references/assets-pipeline.md +67 -0
- package/skills/pixelcraft-web/references/astro.md +113 -0
- package/skills/pixelcraft-web/references/audio-reactive.md +61 -0
- package/skills/pixelcraft-web/references/auth-and-checkout-ui.md +115 -0
- package/skills/pixelcraft-web/references/build-and-architecture.md +215 -0
- package/skills/pixelcraft-web/references/canvas-and-node-editors.md +157 -0
- package/skills/pixelcraft-web/references/clojurescript.md +88 -0
- package/skills/pixelcraft-web/references/component-systems.md +102 -0
- package/skills/pixelcraft-web/references/component-testing.md +170 -0
- package/skills/pixelcraft-web/references/creative-effects.md +59 -0
- package/skills/pixelcraft-web/references/creative-runtime.md +34 -0
- package/skills/pixelcraft-web/references/elm.md +53 -0
- package/skills/pixelcraft-web/references/enterprise-data-ui.md +138 -0
- package/skills/pixelcraft-web/references/file-upload-media-ui.md +82 -0
- package/skills/pixelcraft-web/references/forms-validation.md +123 -0
- package/skills/pixelcraft-web/references/fsharp-fable.md +54 -0
- package/skills/pixelcraft-web/references/gsap.md +102 -0
- package/skills/pixelcraft-web/references/html-css.md +220 -0
- package/skills/pixelcraft-web/references/htmx-alpine.md +103 -0
- package/skills/pixelcraft-web/references/i18n-engineering.md +106 -0
- package/skills/pixelcraft-web/references/interaction-and-search-primitives.md +196 -0
- package/skills/pixelcraft-web/references/java-web.md +61 -0
- package/skills/pixelcraft-web/references/kotlin-web.md +57 -0
- package/skills/pixelcraft-web/references/leptos-yew.md +97 -0
- package/skills/pixelcraft-web/references/lit-web-components.md +63 -0
- package/skills/pixelcraft-web/references/local-first-sync.md +105 -0
- package/skills/pixelcraft-web/references/media-players.md +104 -0
- package/skills/pixelcraft-web/references/motion-react.md +96 -0
- package/skills/pixelcraft-web/references/motion-recipes.md +82 -0
- package/skills/pixelcraft-web/references/preact-fresh-hono.md +111 -0
- package/skills/pixelcraft-web/references/pwa.md +230 -0
- package/skills/pixelcraft-web/references/qwik.md +94 -0
- package/skills/pixelcraft-web/references/r3f-integration.md +69 -0
- package/skills/pixelcraft-web/references/react-next.md +168 -0
- package/skills/pixelcraft-web/references/rendering-choice.md +63 -0
- package/skills/pixelcraft-web/references/rendering-performance.md +80 -0
- package/skills/pixelcraft-web/references/rich-text-and-code-editors.md +220 -0
- package/skills/pixelcraft-web/references/rive-lottie.md +73 -0
- package/skills/pixelcraft-web/references/scala-laminar.md +53 -0
- package/skills/pixelcraft-web/references/scene-architecture.md +132 -0
- package/skills/pixelcraft-web/references/server-rendered.md +114 -0
- package/skills/pixelcraft-web/references/shader-workflow.md +77 -0
- package/skills/pixelcraft-web/references/smooth-scroll.md +58 -0
- package/skills/pixelcraft-web/references/solid.md +111 -0
- package/skills/pixelcraft-web/references/state-architecture.md +107 -0
- package/skills/pixelcraft-web/references/styling-ecosystem.md +273 -0
- package/skills/pixelcraft-web/references/svelte.md +111 -0
- package/skills/pixelcraft-web/references/tailwind.md +99 -0
- package/skills/pixelcraft-web/references/video-media.md +69 -0
- package/skills/pixelcraft-web/references/vue-nuxt.md +86 -0
- package/skills/pixelcraft-web/references/web-3d-engines.md +97 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Lit / Web Components
|
|
2
|
+
|
|
3
|
+
## Token mapping
|
|
4
|
+
|
|
5
|
+
Import generated CSS variables globally and consume them inside shadow DOM:
|
|
6
|
+
|
|
7
|
+
```css
|
|
8
|
+
:host { color: var(--semantic-color-foreground); }
|
|
9
|
+
button { background: var(--semantic-color-action); }
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
CSS custom properties pierce shadow boundaries; raw global selectors do not. Use `::part()` deliberately for documented customization rather than leaking internals.
|
|
13
|
+
|
|
14
|
+
## Layout and responsive idioms
|
|
15
|
+
|
|
16
|
+
Treat components as interoperable leaf/regional primitives. The page owns broad layout; components own internal structure. Use shadow DOM slots intentionally for composition and document slot expectations. Container queries are useful where supported; otherwise expose size/density variants explicitly.
|
|
17
|
+
|
|
18
|
+
## Typography/custom fonts
|
|
19
|
+
|
|
20
|
+
Fonts may inherit into shadow DOM but font loading remains document responsibility. Define typography through inherited/custom properties and do not hard-code one app's font inside reusable components. Document required CSS variables/parts.
|
|
21
|
+
|
|
22
|
+
## Motion/reduced motion
|
|
23
|
+
|
|
24
|
+
Keep animation local and purpose-driven. Read `matchMedia` inside the component or inherit a semantic reduced-motion flag; never force consumers into motion they cannot control. Cleanup event listeners/timers/observers in `disconnectedCallback`.
|
|
25
|
+
|
|
26
|
+
## Accessibility specifics
|
|
27
|
+
|
|
28
|
+
Shadow DOM does not automatically connect labels/IDs across boundaries. Use native elements inside shadow DOM, delegate focus where appropriate (`delegatesFocus` only with care), expose states/roles/ARIA deliberately, and test accessibility tree/focus order in real browsers. Form-associated custom elements require ElementInternals/form participation when acting as inputs.
|
|
29
|
+
|
|
30
|
+
## States idiom
|
|
31
|
+
|
|
32
|
+
Reflect meaningful public state through attributes/properties only when styling/interop requires it. Render loading/empty/error/disabled/invalid internally with stable layout and expose events rather than expecting parents to inspect internals. Preserve user input internally and externally across failed submission.
|
|
33
|
+
|
|
34
|
+
## Forms idiom
|
|
35
|
+
|
|
36
|
+
Native form controls inside shadow DOM do not automatically participate exactly like normal page inputs in every scenario. Use form-associated custom element APIs where needed, implement validation/value/reset/disabled semantics, and document constraints. Never let shadow boundary hide missing labels.
|
|
37
|
+
|
|
38
|
+
## Do/don't pairs
|
|
39
|
+
|
|
40
|
+
| Do | Don't |
|
|
41
|
+
|---|---|
|
|
42
|
+
| `<button part="button">` or documented parts for customization | forcing consumers to reach into shadow internals |
|
|
43
|
+
| semantic custom property fallback `var(--pc-action, var(--semantic-color-action))` | hard-coding app-specific hex inside reusable component |
|
|
44
|
+
| `disconnectedCallback() { this.observer?.disconnect(); }` | leaking observers/listeners after removal |
|
|
45
|
+
| dispatch clear typed events such as `pc-change` | mutating parent/global state as hidden coupling |
|
|
46
|
+
| native `<input>`/ElementInternals when form behavior matters | div-based fake input with decorative shadow styling |
|
|
47
|
+
|
|
48
|
+
## Known traps
|
|
49
|
+
|
|
50
|
+
ARIA/label boundary issues, focus delegation confusion, duplicate IDs across shadow/light DOM, style encapsulation mistaken for token architecture, CSS part API sprawl, form participation gaps, SSR/declarative shadow DOM support differences, event composition/retargeting surprises.
|
|
51
|
+
|
|
52
|
+
## Verification commands
|
|
53
|
+
|
|
54
|
+
Run the project's configured browser test runner (`web-test-runner` or Playwright) without suppressing failures:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
npm run test -- --run
|
|
58
|
+
npm run build
|
|
59
|
+
npx web-test-runner
|
|
60
|
+
npx playwright test
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Test in real browsers (`rendered`) because shadow DOM behavior, `ElementInternals` form participation, and accessibility trees differ from shallow unit rendering.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Local-first, realtime sync, and CRDT engines
|
|
2
|
+
|
|
3
|
+
Choose a sync/CRDT architecture when the UI requires **instant local writes, offline resilience, cross-tab consistency, or live multiplayer editing**—not for ordinary request/response CRUD where TanStack Query suffices ([state-architecture.md](state-architecture.md)).
|
|
4
|
+
|
|
5
|
+
## Sync engine decision matrix
|
|
6
|
+
|
|
7
|
+
| Engine | Data model | Offline / persistence | Presence / realtime | Best fit |
|
|
8
|
+
|---|---|---|---|---|
|
|
9
|
+
| **Yjs** (`yjs`, `y-indexeddb`, `y-websocket`, Hocuspocus) | Sequence & map CRDTs (`Y.Doc`, `Y.Text`, `Y.XmlFragment`) | `IndexeddbPersistence` (`y-indexeddb`) | Built-in Awareness protocol | Collaborative rich text (Tiptap, Lexical, CodeMirror, Monaco) and whiteboards |
|
|
10
|
+
| **Automerge** (`@automerge/automerge-repo`) | JSON-like document CRDT (WASM Rust core) + binary sync | `IndexedDBStorageAdapter` + `BroadcastChannel` | Ephemeral messages | Local-first structured documents, offline multi-device apps, git-like history |
|
|
11
|
+
| **Zero (Rocicorp)** | Postgres-backed client cache + ZQL reactive queries + custom mutators | IndexedDB / local query cache | Live incremental Postgres sync | Instant-UI SaaS apps backed by existing Postgres needing sub-frame optimistic writes |
|
|
12
|
+
| **ElectricSQL** | Postgres logical-replication HTTP **Shapes** streamed to clients | Pairs with local stores / **TanStack DB** / PGlite | Live Shape SSE/long-poll stream | Read-heavy sync of Postgres subsets into existing web apps without replacing Postgres |
|
|
13
|
+
| **TanStack DB** | Reactive client collections + differential dataflow live joins + optimistic mutations | Pluggable (TanStack Query, ElectricSQL, Zero, custom) | Driven by backing collection sync | Frontend-first reactive relational cache and instant optimistic UX across frameworks |
|
|
14
|
+
| **PowerSync** | SQLite-in-browser (WASM/OPFS) synced bi-directionally with Postgres/Mongo/MySQL | Full local SQLite (OPFS/IndexedDB) | Streaming sync buckets + upload queue | Offline-first SQL apps needing full local SQL queries and conflict-controlled server writes |
|
|
15
|
+
| **Jazz** | End-to-end encrypted collaborative values (`CoMap`, `CoList`, `CoFeed`) | Built-in IndexedDB / local-first | Realtime peer/mesh sync + group RBAC | Collaborative local-first apps wanting built-in E2E encryption and permissions |
|
|
16
|
+
| **InstantDB** | Realtime client graph DB (`InstaQL`) with declarative CEL permissions | Local IndexedDB cache + optimistic writes | Live WebSocket subscriptions + presence rooms | Realtime collaborative SaaS & multiplayer apps wanting Firebase-like ergonomics with relational queries |
|
|
17
|
+
| **Convex** | Reactive TypeScript backend (`useQuery`/`useMutation`) + transactional DB | Optimistic updates (online-first reactive) | Automatic live WebSocket query invalidation | Full-stack TypeScript apps wanting end-to-end reactive queries without hand-building sync |
|
|
18
|
+
| **TinyBase** | Lightweight reactive tabular/key-value store + optional CRDT/synchronizer | IndexedDB / OPFS / SQLite / `localStorage` persisters | WebSocket / BroadcastChannel / Durable Objects synchronizers | Small-footprint reactive local stores, local-first tools, and custom sync topologies |
|
|
19
|
+
| **Liveblocks** (`@liveblocks/react`) | Managed realtime rooms (`LiveObject`/`LiveList`/Yjs) + comments | Managed cloud + Yjs integration | First-class `useMyPresence` / `useOthers` | Turnkey multiplayer SaaS (live cursors, threads, collaborative React Flow/tldraw/Tiptap) |
|
|
20
|
+
| **RxDB** (`rxdb`) | Local-first reactive NoSQL database + replication | `getRxStorageDexie()` / IndexedDB / OPFS | Via replication | Offline-first collection apps needing reactive RxJS queries (`.find().$`) and JSON schemas |
|
|
21
|
+
| **PartyKit / Cloudflare Durable Objects** | Stateful edge WebSocket rooms (per-document actor) | Hibernatable WebSockets + SQLite DO storage | Direct room broadcasts (`y-partyserver`, custom presence) | Hosting your own low-latency multiplayer rooms or Yjs sync servers at the edge |
|
|
22
|
+
|
|
23
|
+
## Verified implementation idioms
|
|
24
|
+
|
|
25
|
+
### Yjs + `y-indexeddb` lifecycle
|
|
26
|
+
|
|
27
|
+
- Always group related mutations inside `ydoc.transact(() => { ... })` so observers and network providers emit a single atomic update.
|
|
28
|
+
- Calling `ydoc.destroy()` automatically tears down attached `IndexeddbPersistence` providers (preserving stored IndexedDB data). If a provider may be destroyed before opening completes, guard `provider.whenSynced.catch(() => {})`.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import * as Y from 'yjs';
|
|
32
|
+
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
33
|
+
|
|
34
|
+
const doc = new Y.Doc();
|
|
35
|
+
const persistence = new IndexeddbPersistence('doc-123', doc);
|
|
36
|
+
|
|
37
|
+
await persistence.whenSynced;
|
|
38
|
+
doc.transact(() => {
|
|
39
|
+
doc.getMap('meta').set('title', 'Q4 Plan');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Cleanup on unmount (closes DB connection without deleting stored data)
|
|
43
|
+
doc.destroy();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Automerge Repo (`@automerge/automerge-repo`)
|
|
47
|
+
|
|
48
|
+
- Combine `BroadcastChannelNetworkAdapter` (instant cross-tab sync), `WebSocketClientAdapter` (remote sync), and `IndexedDBStorageAdapter` (offline persistence) in one `Repo`.
|
|
49
|
+
- **Mutation API**: in core `@automerge/automerge-repo`, mutate via **`handle.change((d) => { ... })`** on a `DocHandle` (never mutate `handle.docSync()` snapshots in place). When using `@automerge/automerge-repo-react-hooks`, `useDocument(docUrl)` returns `[doc, changeDoc]` which delegates to `handle.change(...)` under the hood.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { Repo } from '@automerge/automerge-repo';
|
|
53
|
+
import { BroadcastChannelNetworkAdapter } from '@automerge/automerge-repo-network-broadcastchannel';
|
|
54
|
+
import { WebSocketClientAdapter } from '@automerge/automerge-repo-network-websocket';
|
|
55
|
+
import { IndexedDBStorageAdapter } from '@automerge/automerge-repo-storage-indexeddb';
|
|
56
|
+
|
|
57
|
+
export const repo = new Repo({
|
|
58
|
+
network: [
|
|
59
|
+
new BroadcastChannelNetworkAdapter(),
|
|
60
|
+
new WebSocketClientAdapter('wss://sync.example.com'),
|
|
61
|
+
],
|
|
62
|
+
storage: new IndexedDBStorageAdapter(),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const handle = repo.create<{ title: string }>({ title: 'Draft' });
|
|
66
|
+
handle.change((d) => {
|
|
67
|
+
d.title = 'Q4 Plan';
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Database-backed sync (Zero / ElectricSQL + TanStack DB / PowerSync / Convex / InstantDB)
|
|
72
|
+
|
|
73
|
+
- **Authorization boundary**: client sync caches cannot enforce security—always enforce row-level permissions on the sync server (Zero permissions/custom mutators, Electric auth proxy + Shape filters, PowerSync sync rules, Convex server mutations, InstantDB permission rules).
|
|
74
|
+
- **Optimistic mutation reconciliation**: show immediate local updates, attach clear rollback/conflict recovery if the server rejects a custom mutator, and avoid syncing unbounded tables into browser storage (scope Shapes/queries to the active workspace or time window).
|
|
75
|
+
|
|
76
|
+
### Liveblocks, RxDB, TinyBase, and Durable Objects
|
|
77
|
+
|
|
78
|
+
- **Liveblocks**: use `authEndpoint="/api/liveblocks-auth"` (never expose a `publicApiKey` for private rooms) and wrap room consumers in `<ClientSideSuspense fallback={...}>` so SSR never crashes.
|
|
79
|
+
- **RxDB**: declare `indexes` on sorted/filtered fields in the collection JSON schema and unsubscribe from reactive `query.$` observables on unmount.
|
|
80
|
+
- **PartyKit / Cloudflare Durable Objects**: enable WebSocket Hibernation on room DOs and persist snapshots/WALs to DO storage so idle rooms scale to zero without losing edits.
|
|
81
|
+
|
|
82
|
+
## Multiplayer & offline UX contract
|
|
83
|
+
|
|
84
|
+
- **Explicit sync state**: surface `Saved locally (offline)`, `Syncing…`, `Synced`, and `Sync error (retry)` calmly—never hide offline unsynced edits behind a fake "Saved" checkmark.
|
|
85
|
+
- **Presence restraint**: throttle pointer/cursor broadcasts (`~30–60 ms`), fade idle cursors, and respect `prefers-reduced-motion` on remote cursor interpolation.
|
|
86
|
+
- **Per-user undo**: in collaborative docs, scope Undo/Redo to the local user's operations (`Y.UndoManager` / collaborative history), never rolling back a teammate's edits.
|
|
87
|
+
|
|
88
|
+
## Do/don't pairs
|
|
89
|
+
|
|
90
|
+
| Do | Don't |
|
|
91
|
+
|---|---|
|
|
92
|
+
| Batch multi-field Yjs edits inside `doc.transact()` and call `doc.destroy()` on unmount | Emit 50 individual network updates in a loop or leak IndexedDB/WebSocket providers |
|
|
93
|
+
| Mutate Automerge docs via `handle.change((d) => ...)` (or `changeDoc` from `useDocument`) | Mutate frozen Automerge `doc` snapshots in place |
|
|
94
|
+
| Scope Electric Shapes / Zero queries / PowerSync buckets to authorized workspace slices | Replicate an entire multi-tenant database into browser IndexedDB/OPFS |
|
|
95
|
+
| Use `authEndpoint` for private Liveblocks rooms + `<ClientSideSuspense>` | Ship `publicApiKey` on private collaborative documents |
|
|
96
|
+
| Scope Undo/Redo to the local user (`Y.UndoManager`) and show honest offline sync status | Let `Ctrl+Z` revert another collaborator's work or display "Saved" while offline |
|
|
97
|
+
|
|
98
|
+
## Verification commands
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
npm run build
|
|
102
|
+
npx playwright test
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Verify offline edit → reload → reconnect merge convergence and authorization rejection rollback across two browser contexts (simulating two collaborators + offline mode) in Playwright (`rendered`).
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Audio and video player engineering
|
|
2
|
+
|
|
3
|
+
Choose a media playback library by **streaming protocol (MP4/WebM vs HLS/DASH/MoQ), DRM requirement, custom UI ownership, and audio DSP/waveform needs**. Pair this reference with [video-media.md](video-media.md), [audio-reactive.md](audio-reactive.md), and [accessibility-performance.md](accessibility-performance.md). Never autoplay unmuted audio, and always include synchronized captions (`<track kind="captions">`) and keyboard-accessible controls (WCAG 1.2.2 & 2.1.1).
|
|
4
|
+
|
|
5
|
+
## Player & audio engine decision matrix
|
|
6
|
+
|
|
7
|
+
| Category | Tools | Protocols / model | Best fit | Primary trade-off |
|
|
8
|
+
|---|---|---|---|---|
|
|
9
|
+
| **Modern accessible player UI** | **Vidstack** (`@vidstack/react`, Web Components), **Media Chrome** (`media-chrome`), **Mux Player** (`@mux/mux-player`) | Composable `<media-player>` / Web Components wrapping native `<video>`, `hls.js`, DASH, captions, ARIA, and Media Session | Custom-branded or turnkey accessible video/audio players across React, Vue, Svelte, Astro, or vanilla HTML | **Mux Player** ties to Mux delivery; **Media Chrome** gives full chrome ownership while delegating streaming engine (`<hls-video>`) |
|
|
10
|
+
| **Adaptive streaming engines** | **`hls.js`** (v1.7+), **Shaka Player** (v5+), **`dash.js`** | `hls.js`: HLS via MSE / iOS 17.1+ `ManagedMediaSource`; **Shaka**: DASH + HLS + MoQ + DRM (Widevine/FairPlay/PlayReady); **`dash.js`**: MPEG-DASH reference | Production adaptive-bitrate video/live streaming; Shaka when DRM or multi-protocol DASH+HLS is required | Safari/iOS needs careful `ManagedMediaSource` vs native HLS handling (AirPlay/FairPlay/older iOS < 17.1) |
|
|
11
|
+
| **Classic plugin-based player** | **Video.js** | Skinned `<video>` + VHS adaptive engine + broad ad/analytics plugin ecosystem | Existing enterprise/media sites reliant on Video.js IMA/analytics plugins | Heavier CSS/plugin footprint than Vidstack or Media Chrome |
|
|
12
|
+
| **Waveform audio UI** | **`wavesurfer.js`** (v7+) | `<audio>` MediaElement (default) or WebAudio backend + Canvas waveform | Podcasts, voice notes, audio editors, music previews | Decoding multi-hour files client-side burns RAM/CPU unless you pass pre-computed `peaks` + `duration` |
|
|
13
|
+
| **Game / UI sound effects** | **`Howler.js`** | Web Audio API with HTML5 Audio fallback + audio sprites | UI sound effects, game SFX, pooled spatial/layered playback | Not an adaptive streaming video/podcast player |
|
|
14
|
+
| **Interactive synthesis & DSP** | **`Tone.js`** (v15+) | Web Audio API graph, `Tone.Transport` scheduler, synths & effects | Web synthesizers, DAWs, generative/interactive music tools | Requires `await Tone.start()` inside a user gesture (`click`/`keydown`) before scheduling audio |
|
|
15
|
+
|
|
16
|
+
## Verified implementation idioms
|
|
17
|
+
|
|
18
|
+
### Media Chrome & Vidstack (framework-agnostic accessible chrome)
|
|
19
|
+
|
|
20
|
+
- **Media Chrome**: compose semantic Web Component controls (`<media-controller>`, `<media-play-button>`, `<media-time-range>`, `<media-captions-button>`, `<media-fullscreen-button>`) around any `<video>` or `<hls-video>` element—works identically in React, Vue, Svelte, Astro, Rails, or plain HTML and styles via CSS custom properties (`--media-control-background`, `--media-accent-color`).
|
|
21
|
+
- **Vidstack**: use `<MediaPlayer>` + `<MediaProvider>` + `<DefaultVideoLayout>` (or headless `<Controls>`) for built-in HLS integration, keyboard shortcuts, caption styling, thumbnail scrubbers, and Media Session wiring.
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<!-- Media Chrome: custom-styled accessible player over semantic <video> -->
|
|
25
|
+
<media-controller style="--media-accent-color: var(--semantic-color-action);">
|
|
26
|
+
<video slot="media" src="/media/talk.mp4" poster="/media/talk-poster.webp" playsinline crossorigin>
|
|
27
|
+
<track kind="captions" src="/media/talk.en.vtt" srclang="en" label="English" default />
|
|
28
|
+
</video>
|
|
29
|
+
<media-control-bar>
|
|
30
|
+
<media-play-button></media-play-button>
|
|
31
|
+
<media-time-range></media-time-range>
|
|
32
|
+
<media-time-display showduration></media-time-display>
|
|
33
|
+
<media-mute-button></media-mute-button>
|
|
34
|
+
<media-captions-button></media-captions-button>
|
|
35
|
+
<media-fullscreen-button></media-fullscreen-button>
|
|
36
|
+
</media-control-bar>
|
|
37
|
+
</media-controller>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### `hls.js` + iOS 17.1+ `ManagedMediaSource` vs native HLS fallback
|
|
41
|
+
|
|
42
|
+
- Starting with **iOS/iPadOS 17.1**, Safari supports **`ManagedMediaSource` (MMS)**, so modern `hls.js` (`Hls.isSupported()`) can run MSE-style adaptive streaming on iPhone/iPad as well as desktop browsers!
|
|
43
|
+
- **Nuance**: keep the native `video.canPlayType('application/vnd.apple.mpegurl')` branch for **iOS < 17.1** and whenever **FairPlay DRM** or native **AirPlay** takes priority (note that `ManagedMediaSource` disables AirPlay unless you either prefer native HLS on Safari or attach a fallback `<source>`).
|
|
44
|
+
- Throttle `hls.recoverMediaError()` on fatal `MEDIA_ERROR` (e.g., 5-second cooldown) to avoid infinite reload loops, and always call `hls.destroy()` on unmount.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import Hls from 'hls.js';
|
|
48
|
+
|
|
49
|
+
export function attachHls(video: HTMLVideoElement, manifestUrl: string, preferNativeAppleHls = false) {
|
|
50
|
+
const canPlayNative = Boolean(video.canPlayType('application/vnd.apple.mpegurl'));
|
|
51
|
+
|
|
52
|
+
if (!preferNativeAppleHls && Hls.isSupported()) {
|
|
53
|
+
const hls = new Hls();
|
|
54
|
+
let lastRecoverAt = 0;
|
|
55
|
+
hls.on(Hls.Events.ERROR, (_evt, data) => {
|
|
56
|
+
if (data.fatal && data.type === Hls.ErrorTypes.MEDIA_ERROR && Date.now() - lastRecoverAt > 5000) {
|
|
57
|
+
lastRecoverAt = Date.now();
|
|
58
|
+
hls.recoverMediaError();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
hls.loadSource(manifestUrl);
|
|
62
|
+
hls.attachMedia(video);
|
|
63
|
+
return () => hls.destroy();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (canPlayNative) {
|
|
67
|
+
video.src = manifestUrl;
|
|
68
|
+
}
|
|
69
|
+
return () => {
|
|
70
|
+
video.removeAttribute('src');
|
|
71
|
+
video.load();
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Shaka Player (v5+), `wavesurfer.js` (v7+), and `Tone.js` (v15+)
|
|
77
|
+
|
|
78
|
+
- **Shaka Player**: call `shaka.polyfill.installAll()` once, check `shaka.Player.isBrowserSupported()` (and `await shaka.Player.probeSupport()` when DRM/codecs are mandatory), attach with `await player.attach(video)`, and call `await player.destroy()` on unmount.
|
|
79
|
+
- **`wavesurfer.js`**: for long podcasts or streaming audio, pass **both** pre-computed `peaks` and `duration` to `WaveSurfer.create({ container, url, peaks, duration })` so the waveform renders immediately without decoding a 90-minute file into RAM. Call `wavesurfer.destroy()` on unmount.
|
|
80
|
+
- **`Tone.js`**: never schedule or trigger audio on mount—call `await Tone.start()` inside a user `click` or `keydown` handler first, and call `.dispose()` on synths/effects when unmounting.
|
|
81
|
+
|
|
82
|
+
## Media accessibility & Media Session rules
|
|
83
|
+
|
|
84
|
+
- **Captions & transcripts**: attach `<track kind="captions" src="...vtt" srclang="en" label="English" default>` and follow WCAG 1.2.2 / 2.2.2 / 2.3.1 in [accessibility-performance.md](accessibility-performance.md).
|
|
85
|
+
- **Keyboard & OS controls**: verify Play/Pause, Seek (`ArrowLeft`/`ArrowRight`), Volume, Mute, Captions toggle, and Fullscreen are keyboard-operable with visible focus rings, and populate `navigator.mediaSession.metadata` + action handlers for lock-screen/hardware media keys where appropriate.
|
|
86
|
+
|
|
87
|
+
## Do/don't pairs
|
|
88
|
+
|
|
89
|
+
| Do | Don't |
|
|
90
|
+
|---|---|
|
|
91
|
+
| Choose **Vidstack**, **Media Chrome**, or **Mux Player** for modern accessible player UI | Reach for stale unmaintained player skins or build mouse-only custom scrubbers |
|
|
92
|
+
| Handle both `Hls.isSupported()` (MSE + iOS 17.1+ `ManagedMediaSource`) and native Apple HLS fallback | Assume iOS never supports `hls.js`, or omit native fallback for older iOS / AirPlay / FairPlay |
|
|
93
|
+
| Throttle `hls.recoverMediaError()` and call `hls.destroy()` / `player.destroy()` / `wavesurfer.destroy()` / `synth.dispose()` on unmount | Leak media buffers, MSE decoders, or Web Audio nodes across route changes |
|
|
94
|
+
| Supply pre-computed `peaks` + `duration` to `wavesurfer.js` for long audio files | Force the browser to download and decode a 90-minute audio file just to draw a waveform |
|
|
95
|
+
| Unlock Web Audio with `await Tone.start()` inside a `click`/`keydown` listener | Call `triggerAttackRelease()` on mount while `AudioContext` is suspended |
|
|
96
|
+
|
|
97
|
+
## Verification commands
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
npm run build
|
|
101
|
+
npx playwright test
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Verify player chunk lazy-loading (`static`), and test Safari/iOS/Chromium HLS fallback, caption toggle, keyboard scrubbing, user-gesture audio unlock, and unmount cleanup in real browsers (`rendered`).
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Motion (`motion/react` & vanilla `motion`)
|
|
2
|
+
|
|
3
|
+
Use Motion for component-level state transitions, gestures, layout animation, presence, spring physics, and lightweight WAAPI-accelerated scroll/view animations.
|
|
4
|
+
|
|
5
|
+
## Package & entry-point rules
|
|
6
|
+
|
|
7
|
+
- **Modern package**: install **`motion`** (replacing legacy `framer-motion`). Import React APIs from **`'motion/react'`** in `'use client'` modules, or **`'motion/react-client'`** when rendering simple motion elements inside Next.js / React Server Components without adding `'use client'` to a whole page. Confirm the installed package in `package.json` before editing an existing repo.
|
|
8
|
+
- **Bundle reduction (`LazyMotion` + `motion/react-m`)**: wrap your app or feature root in `<LazyMotion features={domAnimation} strict>` (or `domMax` when drag/layout projections are required) and import **`import * as m from 'motion/react-m'`** (`<m.div>`) instead of full `motion.div` to cut initial runtime size from ~34 KB to ~4.6 KB.
|
|
9
|
+
- **Non-React stacks (Vue, Svelte, Astro, Lit, server-rendered HTML)**: use vanilla **`motion`** (`animate`, `scroll`, `inView`, `spring`) built directly on Web Animations API / ScrollTimeline with minimal overhead.
|
|
10
|
+
|
|
11
|
+
## Good fit vs boundaries
|
|
12
|
+
|
|
13
|
+
- **Use Motion** when component state drives animation, items move between layouts (`layout` / `layoutId`), dialogs/drawers need exit presence (`AnimatePresence`), or drag/pan/tap spring physics carry meaning.
|
|
14
|
+
- **Use CSS** for simple hover/focus/opacity transitions and native `<dialog>`/`[popover]` `@starting-style` reveals.
|
|
15
|
+
- **Use GSAP** (`gsap.md`) for multi-beat choreographed timelines, complex pinned ScrollTrigger sequences, and SplitText/DrawSVG/MorphSVG work.
|
|
16
|
+
- Never animate the same `transform`/style property with Motion and GSAP concurrently. Keep semantic state and focus restoration in application/DOM logic, never tied to animation completion alone.
|
|
17
|
+
|
|
18
|
+
## Reduced-motion, layout, and presence rules
|
|
19
|
+
|
|
20
|
+
- **Critical `MotionConfig` trap**: `<MotionConfig reducedMotion="user">` disables declarative `animate`/`whileHover`/`whileInView` transform animations, **but it does NOT disable `MotionValue`-driven styles** (`useScroll`, `useTransform`, `useSpring`, `useMotionValue`). Always read **`useReducedMotion()`** explicitly to bypass springs, parallax, or transform `MotionValue`s when reduced motion is requested.
|
|
21
|
+
- **Layout animations without text distortion**: use **`layout="position"`** on cards/headers containing text so elements translate smoothly without non-uniform scale stretching; wrap sibling components that affect each other's layout (accordions, tab underlines with shared `layoutId`) inside **`<LayoutGroup>`**.
|
|
22
|
+
- **Presence & focus**: give direct children of **`<AnimatePresence mode="popLayout" | "wait">`** stable `key`s, and restore keyboard focus immediately on close rather than leaving focus trapped inside an exiting node.
|
|
23
|
+
- **Logical direction**: use logical origin (`transformOrigin: 'inline-start'` or directional CSS variables) instead of physical left/right so RTL progress indicators grow from the start edge.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
'use client';
|
|
27
|
+
import { LazyMotion, MotionConfig, domAnimation, useReducedMotion, useScroll, useSpring } from 'motion/react';
|
|
28
|
+
import * as m from 'motion/react-m';
|
|
29
|
+
|
|
30
|
+
export function ScrollMeter() {
|
|
31
|
+
const prefersReduced = useReducedMotion();
|
|
32
|
+
const { scrollYProgress } = useScroll();
|
|
33
|
+
const smoothScaleX = useSpring(scrollYProgress, { stiffness: 220, damping: 32 });
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<LazyMotion features={domAnimation} strict>
|
|
37
|
+
<MotionConfig reducedMotion="user">
|
|
38
|
+
<m.div
|
|
39
|
+
role="progressbar"
|
|
40
|
+
aria-label="Reading progress"
|
|
41
|
+
style={{
|
|
42
|
+
position: 'fixed',
|
|
43
|
+
insetBlockStart: 0,
|
|
44
|
+
insetInline: 0,
|
|
45
|
+
blockSize: '2px',
|
|
46
|
+
background: 'var(--semantic-color-action)',
|
|
47
|
+
transformOrigin: 'inline-start',
|
|
48
|
+
// Explicitly bypass spring/transform MotionValue when reduced motion is enabled
|
|
49
|
+
scaleX: prefersReduced ? scrollYProgress : smoothScaleX,
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
</MotionConfig>
|
|
53
|
+
</LazyMotion>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
// AnimatePresence + LayoutGroup + layout="position" (prevents text stretch)
|
|
60
|
+
import { AnimatePresence, LayoutGroup, motion } from 'motion/react';
|
|
61
|
+
|
|
62
|
+
<LayoutGroup>
|
|
63
|
+
<AnimatePresence mode="popLayout">
|
|
64
|
+
{items.map((item) => (
|
|
65
|
+
<motion.li
|
|
66
|
+
key={item.id}
|
|
67
|
+
layout="position"
|
|
68
|
+
initial={{ opacity: 0 }}
|
|
69
|
+
animate={{ opacity: 1 }}
|
|
70
|
+
exit={{ opacity: 0 }}
|
|
71
|
+
>
|
|
72
|
+
{item.label}
|
|
73
|
+
</motion.li>
|
|
74
|
+
))}
|
|
75
|
+
</AnimatePresence>
|
|
76
|
+
</LayoutGroup>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
// Non-React vanilla Motion (Astro / Svelte / Vue / HTML): WAAPI-backed with reduced-motion guard
|
|
81
|
+
import { animate, inView } from 'motion';
|
|
82
|
+
|
|
83
|
+
const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
84
|
+
const stop = inView('.feature-row', (el) => {
|
|
85
|
+
if (reduced) return;
|
|
86
|
+
animate(el, { opacity: [0, 1], y: [12, 0] }, { duration: 0.35 });
|
|
87
|
+
});
|
|
88
|
+
// Cleanup: stop();
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Official references
|
|
92
|
+
|
|
93
|
+
- Motion documentation: https://motion.dev/docs
|
|
94
|
+
- Motion for React: https://motion.dev/docs/react
|
|
95
|
+
- LazyMotion bundle reduction: https://motion.dev/docs/react-reduce-bundle-size
|
|
96
|
+
- Vanilla Motion (`animate`/`scroll`/`inView`): https://motion.dev/docs/quick-start
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Motion recipe library
|
|
2
|
+
|
|
3
|
+
These recipes describe reusable behavior, not a visual template. Choose only what supports the product/story.
|
|
4
|
+
|
|
5
|
+
| Recipe | Sequence | Required fallback/test |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| Loader | Small brand mark/indicator reveals, then exits promptly after critical content is ready | Never block navigation; timeout/failure path; skip on reduced motion |
|
|
8
|
+
| Kinetic headline | Split short headline by line/word, masked reveal, then settle | Semantic unsplit text, selectable content, instant reduced-motion path |
|
|
9
|
+
| SVG stroke reveal | Draw a meaningful path as progress or narrative is explained | Static completed path and readable labels |
|
|
10
|
+
| Magnetic CTA | Pointer-relative translation capped to a small travel distance, with inner parallax | Ordinary button position on touch/keyboard; hit area remains aligned |
|
|
11
|
+
| Pointer parallax | Small transform response to pointer position | No layout shift; stop on touch, keyboard, and reduced motion |
|
|
12
|
+
| FLIP card/modal | Capture origin geometry, move one semantic object to destination, then restore focus on close | Focus trap/restore, Escape, scroll lock only while dialog is open |
|
|
13
|
+
| Navigation overlay | Open/close panel with clear focus transfer and staggered items | Keyboard, touch, Escape, no hover dependence |
|
|
14
|
+
| Pinned chapter | Persistent media/artifact changes as linear chapters enter | Linear reading path, direct links, short-height and reverse-scroll tests |
|
|
15
|
+
| Horizontal narrative | Track advances through a deliberate sequence while vertical page access remains obvious | Native sequential list/swipe alternative; keyboard controls if custom |
|
|
16
|
+
| Velocity marquee | Continuous track changes speed/direction with scroll velocity | Pause control, reduced-motion static strip, duplicated decorative text hidden from AT |
|
|
17
|
+
| Image reveal | Clip/mask or crossfade as image becomes relevant | Stable dimensions, low-motion fade/static image |
|
|
18
|
+
| Route transition | Brief continuity transition around route change | History/back, focus announcement, no blocked navigation |
|
|
19
|
+
| Elastic footer | One bounded footer mark responds to entering/leaving viewport | No constant loop; avoid bounce on operational pages |
|
|
20
|
+
| Progress indicator | Chapter or task progress tracks real completed/current state | Text or numeric equivalent; no false precision |
|
|
21
|
+
| Stateful icon | Small icon/shape communicates a real state transition | Semantic label/state remains outside the animation |
|
|
22
|
+
|
|
23
|
+
## Choreography rules
|
|
24
|
+
|
|
25
|
+
- One primary signature movement plus at most two supporting movements at the same moment unless the story requires more.
|
|
26
|
+
- Put essential content and controls in the DOM and visible before nonessential choreography.
|
|
27
|
+
- Use stagger only where order carries meaning; arbitrary delays make interfaces feel slow.
|
|
28
|
+
- Do not randomize a motion on every render. Seed or stabilize randomized values for deterministic QA.
|
|
29
|
+
- Clamp pointer displacement and velocity; cancel stale tweens on repeated input.
|
|
30
|
+
- Use animation for cause/effect and state, not to conceal loading or fake activity.
|
|
31
|
+
|
|
32
|
+
## Native CSS motion before JS runtimes
|
|
33
|
+
|
|
34
|
+
Prefer native browser primitives when the effect does not need JS physics or timeline callbacks:
|
|
35
|
+
|
|
36
|
+
- **CSS Scroll-Driven Animations** (`animation-timeline: view()` / `scroll()`): gate with `@supports (animation-timeline: view())` and `@media (prefers-reduced-motion: no-preference)`.
|
|
37
|
+
- **View Transitions API + Types + `view-transition-class`**:
|
|
38
|
+
- Use `@view-transition { navigation: auto; }` for cross-document MPA transitions and `document.startViewTransition({ update, types: ['slide-forward'] })` for directional SPA transitions; target transition modes cleanly in CSS with **`:active-view-transition-type(slide-forward)`** instead of toggling temporary classes on `<html>`.
|
|
39
|
+
- Use **`view-transition-class: card-item`** alongside unique `view-transition-name: card-42` values so every card shares one `::view-transition-group(.card-item)` animation rule without generating per-ID CSS.
|
|
40
|
+
- Always feature-detect `document.startViewTransition` and bypass or simplify to instant crossfade/update when `prefers-reduced-motion: reduce` is active.
|
|
41
|
+
|
|
42
|
+
```css
|
|
43
|
+
@supports (animation-timeline: view()) {
|
|
44
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
45
|
+
.reveal-plate {
|
|
46
|
+
animation: plate-rise linear both;
|
|
47
|
+
animation-timeline: view();
|
|
48
|
+
animation-range: entry 10% cover 35%;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@keyframes plate-rise {
|
|
54
|
+
from { opacity: 0; translate: 0 24px; }
|
|
55
|
+
to { opacity: 1; translate: 0 0; }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* View Transition Types + shared view-transition-class */
|
|
59
|
+
.product-card { view-transition-class: product-card; }
|
|
60
|
+
|
|
61
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
62
|
+
::view-transition-group(.product-card) {
|
|
63
|
+
animation-duration: 240ms;
|
|
64
|
+
animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
|
|
65
|
+
}
|
|
66
|
+
html:active-view-transition-type(slide-forward)::view-transition-new(page-body) {
|
|
67
|
+
animation: slide-in-inline 220ms ease-out both;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
// Feature-detected SPA View Transition with semantic transition type
|
|
74
|
+
export function transitionView(update: () => void, direction: 'slide-forward' | 'slide-back') {
|
|
75
|
+
const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
76
|
+
if (!document.startViewTransition || reduced) {
|
|
77
|
+
update();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
document.startViewTransition({ update, types: [direction] });
|
|
81
|
+
}
|
|
82
|
+
```
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Lightweight & edge-first stacks: Preact, Deno Fresh 2, Hono JSX/RPC, RedwoodSDK, Waku
|
|
2
|
+
|
|
3
|
+
Choose a lightweight or edge-first web stack when bundle weight, cold-start latency, or Web Standards (`Request`/`Response`) portability outweigh the full Next.js/Nuxt ecosystem.
|
|
4
|
+
|
|
5
|
+
## Stack decision matrix
|
|
6
|
+
|
|
7
|
+
| Stack | Runtime / Model | Client JS footprint | Best fit | Primary watch-out |
|
|
8
|
+
|---|---|---|---|---|
|
|
9
|
+
| **Preact + `@preact/signals`** | ~4 KB React-like VDOM + fine-grained signals | Tiny (~4–6 KB gzipped) | Embedded widgets, low-bandwidth SPAs, islands inside Astro/Fresh | Importing full React libraries via `preact/compat` can silently bloat bundles |
|
|
10
|
+
| **Deno Fresh 2.0** | Zero-JS-by-default SSR + selective Preact `islands/` on Deno/Vite | 0 KB on static/SSR pages; island-only JS | Edge-rendered Deno apps needing standard HTTP handlers + isolated interactive islands | Only JSON-serializable props cross into `islands/`; avoid hydrating whole layouts |
|
|
11
|
+
| **Hono JSX + Hono RPC (`hc`)** | Ultra-fast Web Standards router + server JSX + optional `hono/jsx/dom` client islands | 0 KB (server JSX) or tiny client island | Cloudflare Workers / Bun / Deno / Node full-stack apps wanting end-to-end typed RPC | `hono/jsx` is not React—do not copy React-specific hooks/libraries blindly |
|
|
12
|
+
| **RedwoodSDK** | Cloudflare Workers-native React Server Components + explicit routing + Server Functions | RSC payload + client leaves only | Edge-first React 19 apps tightly integrated with Workers/D1/Durable Objects | Explicit request/response & RSC boundary ownership; no magic file-router defaults |
|
|
13
|
+
| **Waku** | Minimal Vite-based React Server Components framework | RSC payload + client leaves only | Teams wanting React 19 RSC + Vite without Next.js framework coupling | Smaller plugin ecosystem than Next.js; verify deployment adapter early |
|
|
14
|
+
|
|
15
|
+
## Token mapping
|
|
16
|
+
|
|
17
|
+
Import generated CSS variables once in the root HTML shell (`<link rel="stylesheet" href="/tokens.css" />` or Vite CSS entry). Keep semantic variables in CSS rather than passing raw hex strings across island or RSC serialization boundaries.
|
|
18
|
+
|
|
19
|
+
## Preact + `@preact/signals` idioms
|
|
20
|
+
|
|
21
|
+
- Use **`@preact/signals`** (`signal`, `computed`, `effect`, `useSignal`, `useComputed`) for fine-grained updates: binding a signal directly into JSX text (`<span>{count}</span>`) updates the DOM text node without re-rendering the enclosing component.
|
|
22
|
+
- Prefer standard HTML attribute names (`class`, `for`) in native Preact; use `className`/`htmlFor` only when sharing source code with `preact/compat`.
|
|
23
|
+
- Clean up `effect()` subscriptions by returning a disposal callback, and avoid mutating signals during render.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { computed, useSignal } from '@preact/signals';
|
|
27
|
+
|
|
28
|
+
export function QuantityControl({ unitPrice }: { unitPrice: number }) {
|
|
29
|
+
const qty = useSignal(1);
|
|
30
|
+
const total = computed(() => qty.value * unitPrice);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div class="qty-row">
|
|
34
|
+
<button type="button" onClick={() => { if (qty.value > 1) qty.value--; }} aria-label="Decrease quantity">−</button>
|
|
35
|
+
<output aria-live="polite">{qty}</output>
|
|
36
|
+
<button type="button" onClick={() => { qty.value++; }} aria-label="Increase quantity">+</button>
|
|
37
|
+
<span>Total: {total}</span>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Deno Fresh 2.0 idioms
|
|
44
|
+
|
|
45
|
+
- Fresh 2.0 uses a composable middleware/route `App` (`new App().use(...).fsRoutes()`) with Vite support and Preact islands under `islands/`.
|
|
46
|
+
- Keep page routes and forms server-rendered with standard `Request`/`Response` handlers (`GET`/`POST`) that preserve submitted values and return HTTP 422 HTML with adjacent field errors on validation failure.
|
|
47
|
+
- Isolate browser-only interactivity in small `islands/*.tsx` components; pass only serializable data props and keep island fallback markup identical to initial SSR output to avoid CLS.
|
|
48
|
+
|
|
49
|
+
## Hono JSX & Hono RPC (`hc`) idioms
|
|
50
|
+
|
|
51
|
+
- Render fast semantic HTML on the server using `hono/jsx` (`c.html(<Layout>...</Layout>)` or `renderToReadableStream` / `<Suspense>` streaming) and pair with htmx or tiny `hono/jsx/dom` client islands where interactivity is needed.
|
|
52
|
+
- Export the chained route type (`export type AppType = typeof routes`) and consume it on the client with **`hc<AppType>('/api')`** plus `@hono/zod-validator` (or Standard Schema validator) so API contracts stay end-to-end type-safe with zero codegen:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
// server.ts
|
|
56
|
+
import { Hono } from 'hono';
|
|
57
|
+
import { zValidator } from '@hono/zod-validator';
|
|
58
|
+
import { z } from 'zod';
|
|
59
|
+
|
|
60
|
+
const routes = new Hono().post(
|
|
61
|
+
'/api/invoices',
|
|
62
|
+
zValidator('json', z.object({ number: z.string().min(1) })),
|
|
63
|
+
(c) => c.json({ ok: true, number: c.req.valid('json').number }, 201)
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
export type AppType = typeof routes;
|
|
67
|
+
|
|
68
|
+
// client.ts
|
|
69
|
+
import { hc } from 'hono/client';
|
|
70
|
+
import type { AppType } from './server';
|
|
71
|
+
|
|
72
|
+
const client = hc<AppType>('/');
|
|
73
|
+
const res = await client.api.invoices.$post({ json: { number: 'INV-104' } });
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## RedwoodSDK & Waku (minimal RSC) idioms
|
|
77
|
+
|
|
78
|
+
- Follow the React 19 RSC rules in `react-next.md`: keep data fetching and auth/authz checks in Server Components and Server Functions, mark only interactive leaves `'use client'`, and never read `window` during SSR.
|
|
79
|
+
- In **RedwoodSDK**, colocate request middleware (session/auth/CSRF) explicitly on route definitions (`defineApp([render(Document, [route('/invoices', [requireAuth, InvoicesPage])])])`).
|
|
80
|
+
- In **Waku**, specify static vs dynamic rendering explicitly (`getConfig = async () => ({ render: 'static' | 'dynamic' })`) so CDN-cacheable routes do not incur unnecessary per-request compute.
|
|
81
|
+
|
|
82
|
+
## Do/don't pairs
|
|
83
|
+
|
|
84
|
+
| Do | Don't |
|
|
85
|
+
|---|---|
|
|
86
|
+
| Bind `@preact/signals` directly in JSX for high-frequency updates | Pull heavy React state libraries into Preact via `preact/compat` by habit |
|
|
87
|
+
| Keep Fresh 2 routes server-rendered and hydrate tiny `islands/` | Put entire page layouts inside `islands/` (negates zero-JS SSR) |
|
|
88
|
+
| Chain Hono routes (`const routes = app.get(...).post(...)`) so `typeof routes` preserves `hc<AppType>` inference | Register routes in separate unchained statements (`app.get(...)`) that erase `AppType` inference |
|
|
89
|
+
| Enforce auth/authz inside every Server Function / POST handler | Trust client-side route guards or unvalidated JSON payloads |
|
|
90
|
+
| Use semantic `<form>`, `<label>`, and `prefers-reduced-motion` CSS across all stacks | Assume minimal runtimes exempt the UI from WCAG 2.2 or full state coverage |
|
|
91
|
+
|
|
92
|
+
## Known traps
|
|
93
|
+
|
|
94
|
+
Breaking `hc<AppType>` type inference by not chaining Hono routes, importing heavyweight React UI kits through `preact/compat` and losing the bundle win, passing non-serializable functions/classes into Fresh islands, unguarded `window`/`document` access in edge SSR runtimes (Cloudflare Workers / Deno Deploy), missing CSRF checks on form POST routes.
|
|
95
|
+
|
|
96
|
+
## Verification commands
|
|
97
|
+
|
|
98
|
+
Use the stack's actual runtime/test runner:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
# Preact / Hono / Waku / RedwoodSDK (Node/Vite)
|
|
102
|
+
npm run typecheck && npm run test -- --run && npm run build
|
|
103
|
+
|
|
104
|
+
# Deno Fresh 2
|
|
105
|
+
deno check && deno test && deno task build
|
|
106
|
+
|
|
107
|
+
# Browser evidence (all stacks)
|
|
108
|
+
npx playwright test
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Typechecks and server handler tests provide `static`/HTTP evidence; verify hydration, islands, focus, and network error states in a real browser (`rendered`).
|