@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,80 @@
|
|
|
1
|
+
# Real-time 3D performance
|
|
2
|
+
|
|
3
|
+
Set budgets during planning and measure on representative devices. A fixed FPS target is meaningless without device, refresh rate, viewport, scene, and throttling context.
|
|
4
|
+
|
|
5
|
+
## Control the cost
|
|
6
|
+
|
|
7
|
+
- Cap device pixel ratio; full-resolution rendering at high-DPI can multiply fragment work.
|
|
8
|
+
- Bound triangles, draw calls, textures, render targets, lights, shadows, physics steps, and postprocessing passes.
|
|
9
|
+
- Prefer instancing for repeated meshes and LOD/culling for wide scenes.
|
|
10
|
+
- Use static environment maps or baked lighting where realtime lighting has no user-facing value.
|
|
11
|
+
- Lazy-load scene code and assets; show a poster before initialization.
|
|
12
|
+
- Pause when document hidden or scene offscreen; avoid idle animation on operational pages.
|
|
13
|
+
- Use lower quality presets for mobile/thermal pressure and expose a non-3D fallback.
|
|
14
|
+
- Dispose resources and test memory after route changes or repeated open/close.
|
|
15
|
+
- Avoid blanket `will-change: transform` on large lists; apply compositor promotion only to actively animating elements to prevent VRAM exhaustion.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// Cap DPR, pause when offscreen or hidden, and handle WebGL context loss + restoration
|
|
19
|
+
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
20
|
+
renderer.setPixelRatio(dpr);
|
|
21
|
+
|
|
22
|
+
let visible = true;
|
|
23
|
+
let rafId = 0;
|
|
24
|
+
|
|
25
|
+
function tick(now: number) {
|
|
26
|
+
if (!visible || document.hidden) {
|
|
27
|
+
rafId = 0;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
renderFrame(now);
|
|
31
|
+
rafId = requestAnimationFrame(tick);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function startLoop() {
|
|
35
|
+
if (!rafId && visible && !document.hidden) rafId = requestAnimationFrame(tick);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const io = new IntersectionObserver(
|
|
39
|
+
([entry]) => {
|
|
40
|
+
visible = entry.isIntersecting;
|
|
41
|
+
if (visible) startLoop();
|
|
42
|
+
},
|
|
43
|
+
{ threshold: 0.01 },
|
|
44
|
+
);
|
|
45
|
+
io.observe(canvas);
|
|
46
|
+
|
|
47
|
+
const onVisibility = () => { if (!document.hidden) startLoop(); };
|
|
48
|
+
document.addEventListener('visibilitychange', onVisibility);
|
|
49
|
+
|
|
50
|
+
const onContextLost = (e: Event) => {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
cancelAnimationFrame(rafId);
|
|
53
|
+
rafId = 0;
|
|
54
|
+
};
|
|
55
|
+
const onContextRestored = () => {
|
|
56
|
+
rebuildGpuResources();
|
|
57
|
+
startLoop();
|
|
58
|
+
};
|
|
59
|
+
canvas.addEventListener('webglcontextlost', onContextLost);
|
|
60
|
+
canvas.addEventListener('webglcontextrestored', onContextRestored);
|
|
61
|
+
|
|
62
|
+
// On teardown:
|
|
63
|
+
// cancelAnimationFrame(rafId); io.disconnect();
|
|
64
|
+
// document.removeEventListener('visibilitychange', onVisibility);
|
|
65
|
+
// canvas.removeEventListener('webglcontextlost', onContextLost);
|
|
66
|
+
// canvas.removeEventListener('webglcontextrestored', onContextRestored);
|
|
67
|
+
// geometry.dispose(); material.dispose(); renderer.dispose();
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Evidence
|
|
71
|
+
|
|
72
|
+
Record device/GPU/browser, viewport, DPR, refresh rate, scene state, warm/cold cache, frame-time distribution or FPS sample, long tasks, GPU memory (`renderer.info.memory`), draw calls (`renderer.info.render.calls`), and whether capture was actual device or emulation (`rendered`). Do not compare numbers from unlike devices as if they were equivalent.
|
|
73
|
+
|
|
74
|
+
The visual-qa performance budget is the shared project-level floor; this guide adds scene-specific measurements. If device profiling is unavailable, label GPU/frame checks `not-checked` rather than inferring from a screenshot.
|
|
75
|
+
|
|
76
|
+
## Official references
|
|
77
|
+
|
|
78
|
+
- WebGL best practices: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices
|
|
79
|
+
- Three.js manual: https://threejs.org/manual/
|
|
80
|
+
- R3F performance: https://r3f.docs.pmnd.rs/advanced/scaling-performance
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Rich text, code editors, playgrounds, and visual page builders
|
|
2
|
+
|
|
3
|
+
Never build a rich-text or code editor on raw `contenteditable` with `document.execCommand` (deprecated and inconsistent across browsers). Choose an engine with an explicit document model, predictable undo/redo, IME composition support, and keyboard/screen-reader accessibility.
|
|
4
|
+
|
|
5
|
+
## Engine decision matrix
|
|
6
|
+
|
|
7
|
+
| Category | Tools | Document model | Best fit | Primary trade-off |
|
|
8
|
+
|---|---|---|---|---|
|
|
9
|
+
| **Rich-text core** | **ProseMirror**, **Tiptap** (v3), **BlockNote** | Immutable schema-validated node tree (ProseMirror) | Custom block/inline docs, Notion-like editors (**BlockNote** ships slash menus, drag handles, and Yjs blocks out of the box) | Bundle size & schema design discipline; SSR requires `immediatelyRender: false` |
|
|
10
|
+
| **React-first rich text** | **Lexical**, **Slate**, **Plate** | Double-buffered node tree (Lexical) or JSON AST (Slate/Plate) | React apps needing fine-grained custom nodes, mentions, slash commands, or shadcn-style blocks (Plate) | Lexical requires registering custom nodes upfront; Slate needs careful normalization & IME testing |
|
|
11
|
+
| **Full-featured turnkey** | **CKEditor 5**, **TinyMCE** | Proprietary rich model | CMS/enterprise forms needing turnkey tables, track changes, Word paste cleanup | Commercial licensing for advanced plugins; harder to restyle deeply |
|
|
12
|
+
| **Markdown / MDX** | **Milkdown** (ProseMirror-based), **MDXEditor** (Lexical-based) | Markdown AST + live WYSIWYG | Developer docs, Git-backed CMS, technical writing | Round-trip Markdown serialization edge cases with custom JSX/MDX |
|
|
13
|
+
| **Read-only syntax highlighting** | **Shiki** (`shiki`) | TextMate grammars → static HTML / CSS variables | Docs, changelogs, diff viewers, AI code blocks (0 KB client JS when rendered at build/SSR time) | Not an editable code editor—pair with CodeMirror 6 when editing is required |
|
|
14
|
+
| **Code editors** | **CodeMirror 6**, **Monaco Editor**, **Ace** | Line/rope immutable state (CM6) or VS Code text model (Monaco) | **CodeMirror 6**: lightweight, mobile-friendly, modular web apps; **Monaco**: desktop IDE features (TypeScript IntelliSense, diff editor, LSP) | Monaco is heavy (~2–4 MB + Web Workers) and weak on mobile touch; never bundle Monaco for a small JSON input or read-only snippet |
|
|
15
|
+
| **In-browser playgrounds** | **Sandpack**, **WebContainers** | Client bundler iframe (Sandpack) or WASM Node.js runtime (WebContainers) | **Sandpack**: live React/Vue/HTML sandboxes in docs; **WebContainers**: full Node CLI/dev-server in browser | WebContainers require `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp` headers |
|
|
16
|
+
| **Visual page builders** | **Puck**, **Craft.js**, **GrapesJS** | JSON component tree (Puck/Craft.js) or HTML/CSS canvas (GrapesJS) | **Puck**: React/Next.js apps rendering your own design-system components; **GrapesJS**: standalone HTML/email template builders | GrapesJS outputs arbitrary HTML/CSS that can drift from design tokens |
|
|
17
|
+
|
|
18
|
+
## Rich-text implementation idioms
|
|
19
|
+
|
|
20
|
+
### Standalone ProseMirror (`Schema` → `EditorState` → `Transaction` → `EditorView`)
|
|
21
|
+
|
|
22
|
+
Choose standalone **ProseMirror** (`prosemirror-model`, `prosemirror-state`, `prosemirror-view`, `prosemirror-history`, `prosemirror-keymap`) over wrapper frameworks when you need tight bundle control, framework-agnostic state ownership, or strict custom document invariants:
|
|
23
|
+
|
|
24
|
+
- Define a closed `Schema` (allowed nodes, marks, and content expressions) so invalid DOM structures cannot enter editor state.
|
|
25
|
+
- Route every mutation through an immutable `Transaction` (`state.tr`) inside `dispatchTransaction(tr)`, apply it via `view.state.apply(tr)`, update the view with `view.updateState(nextState)`, and call `view.destroy()` on unmount.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { Schema } from 'prosemirror-model';
|
|
29
|
+
import { EditorState, Transaction } from 'prosemirror-state';
|
|
30
|
+
import { EditorView } from 'prosemirror-view';
|
|
31
|
+
import { history, undo, redo } from 'prosemirror-history';
|
|
32
|
+
import { keymap } from 'prosemirror-keymap';
|
|
33
|
+
import { baseKeymap } from 'prosemirror-commands';
|
|
34
|
+
|
|
35
|
+
const schema = new Schema({
|
|
36
|
+
nodes: {
|
|
37
|
+
doc: { content: 'paragraph+' },
|
|
38
|
+
paragraph: { content: 'text*', toDOM: () => ['p', 0], parseDOM: [{ tag: 'p' }] },
|
|
39
|
+
text: { group: 'inline' },
|
|
40
|
+
},
|
|
41
|
+
marks: {
|
|
42
|
+
strong: { toDOM: () => ['strong', 0], parseDOM: [{ tag: 'strong' }] },
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export function mountProseMirror(parent: HTMLElement, onDocChange: (json: unknown) => void) {
|
|
47
|
+
const state = EditorState.create({
|
|
48
|
+
schema,
|
|
49
|
+
plugins: [history(), keymap({ 'Mod-z': undo, 'Mod-Shift-z': redo }), keymap(baseKeymap)],
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const view = new EditorView(parent, {
|
|
53
|
+
state,
|
|
54
|
+
attributes: { role: 'textbox', 'aria-multiline': 'true', 'aria-label': 'Document body' },
|
|
55
|
+
dispatchTransaction(tr: Transaction) {
|
|
56
|
+
const next = view.state.apply(tr);
|
|
57
|
+
view.updateState(next);
|
|
58
|
+
if (tr.docChanged) onDocChange(next.doc.toJSON());
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return () => view.destroy();
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Tiptap v3 (ProseMirror) & BlockNote
|
|
67
|
+
|
|
68
|
+
- **SSR safety**: always set `immediatelyRender: false` in `useEditor()` inside Next.js/Remix/SSR apps so server and client HTML do not mismatch.
|
|
69
|
+
- **Undo/Redo footgun**: keep `StarterKit`'s built-in undo/redo **enabled** for single-user editors! Disable it (`undoRedo: false` in Tiptap v3) **only** when `@tiptap/extension-collaboration` (Yjs) owns history—copying `undoRedo: false` into a standalone editor silently breaks `Ctrl+Z` / `Cmd+Z`.
|
|
70
|
+
- **BlockNote**: use `@blocknote/react` (`useCreateBlockNote` + `<BlockNoteView>`) when a Notion-style block editor with slash menus, block drag handles, and optional Yjs sync is desired without assembling 15 Tiptap extensions by hand.
|
|
71
|
+
- **Persistence & XSS**: store canonical JSON (or sanitize HTML server-side with DOMPurify/allowlist before rendering read-only views).
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
'use client';
|
|
75
|
+
|
|
76
|
+
import { useEditor, EditorContent } from '@tiptap/react';
|
|
77
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
78
|
+
import Collaboration from '@tiptap/extension-collaboration';
|
|
79
|
+
import type * as Y from 'yjs';
|
|
80
|
+
|
|
81
|
+
export function DocumentEditor({ initialHtml, ydoc }: { initialHtml: string; ydoc?: Y.Doc }) {
|
|
82
|
+
const isCollaborative = Boolean(ydoc);
|
|
83
|
+
const editor = useEditor({
|
|
84
|
+
extensions: [
|
|
85
|
+
// ONLY disable built-in undoRedo when Yjs Collaboration provides history!
|
|
86
|
+
StarterKit.configure(isCollaborative ? { undoRedo: false } : {}),
|
|
87
|
+
...(ydoc ? [Collaboration.configure({ document: ydoc })] : []),
|
|
88
|
+
],
|
|
89
|
+
content: isCollaborative ? undefined : initialHtml,
|
|
90
|
+
immediatelyRender: false,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (!editor) return null;
|
|
94
|
+
return <EditorContent editor={editor} />;
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Lexical
|
|
99
|
+
|
|
100
|
+
- Register every custom node class in `initialConfig.nodes` up front—unregistered nodes throw at runtime when parsed.
|
|
101
|
+
- Always pass `ErrorBoundary={LexicalErrorBoundary}` to `<RichTextPlugin>` and wrap every programmatic state mutation inside `editor.update(() => { ... })`.
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
105
|
+
import { RichTextPlugin } from '@lexical/react/RichTextPlugin';
|
|
106
|
+
import { ContentEditable } from '@lexical/react/ContentEditable';
|
|
107
|
+
import { HistoryPlugin } from '@lexical/react/HistoryPlugin';
|
|
108
|
+
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
109
|
+
|
|
110
|
+
const initialConfig = {
|
|
111
|
+
namespace: 'NotesEditor',
|
|
112
|
+
onError(error: Error) {
|
|
113
|
+
throw error;
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export function NotesEditor() {
|
|
118
|
+
return (
|
|
119
|
+
<LexicalComposer initialConfig={initialConfig}>
|
|
120
|
+
<RichTextPlugin
|
|
121
|
+
contentEditable={<ContentEditable aria-label="Document body" className="editor-input" />}
|
|
122
|
+
placeholder={<div className="editor-placeholder">Write a note…</div>}
|
|
123
|
+
ErrorBoundary={LexicalErrorBoundary}
|
|
124
|
+
/>
|
|
125
|
+
<HistoryPlugin />
|
|
126
|
+
</LexicalComposer>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Code editors and read-only highlighting
|
|
132
|
+
|
|
133
|
+
### Shiki (read-only code blocks)
|
|
134
|
+
|
|
135
|
+
- Never ship CodeMirror or Monaco just to display read-only code snippets. Use **`shiki`** (`codeToHtml(code, { lang, themes: { light, dark } })`) at build time or inside Server Components / `.server.vue` / Astro for VS Code-accurate syntax highlighting with zero client JavaScript, using dual light/dark CSS variables so themes switch without re-highlighting.
|
|
136
|
+
|
|
137
|
+
### CodeMirror 6
|
|
138
|
+
|
|
139
|
+
- Use `Compartment` to reconfigure dynamic settings (theme, language, `readOnly`, `tabSize`) via `view.dispatch({ effects: compartment.reconfigure(...) })` instead of destroying and recreating `EditorView` on every prop change (which loses undo history, scroll, and cursor selection).
|
|
140
|
+
- Always call `view.destroy()` on component unmount.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { Compartment, EditorState } from '@codemirror/state';
|
|
144
|
+
import { EditorView } from '@codemirror/view';
|
|
145
|
+
|
|
146
|
+
const tabSize = new Compartment();
|
|
147
|
+
|
|
148
|
+
const view = new EditorView({
|
|
149
|
+
state: EditorState.create({
|
|
150
|
+
doc: 'const x = 1;\n',
|
|
151
|
+
extensions: [tabSize.of(EditorState.tabSize.of(2))],
|
|
152
|
+
}),
|
|
153
|
+
parent: containerEl,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export function setTabSize(size: number) {
|
|
157
|
+
view.dispatch({ effects: tabSize.reconfigure(EditorState.tabSize.of(size)) });
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Monaco Editor
|
|
162
|
+
|
|
163
|
+
- Always lazy-load Monaco (`React.lazy` / dynamic `import()`) and configure its Web Workers (`MonacoEnvironment.getWorker`) so TypeScript/JSON language services do not run on the main thread.
|
|
164
|
+
- Dispose both the editor instance and created `ITextModel` instances on unmount to avoid multi-megabyte memory leaks.
|
|
165
|
+
|
|
166
|
+
## Visual page builders & client-proof CMS authoring guardrails
|
|
167
|
+
|
|
168
|
+
- **Puck**: define a typed `Config` mapping component names to `fields` and `render`, author via `<Puck config={config} data={data} onPublish={save} />`, and render the published page cleanly on the server with `<Render config={config} data={data} />` without shipping editor chrome to end users.
|
|
169
|
+
- **Raw camera upload auto-transcode & focal-point crop**: non-technical editors routinely upload raw `10–15 MB` camera/phone photos (`4000×3000+` JPEG/PNG/HEIC). Enforce an upload/CDN pipeline (Sharp, Cloudflare Images, Sanity, Payload, Strapi, Imgix) that auto-rotates EXIF, strips sensitive GPS metadata, transcodes into responsive `AVIF`/`WebP` `srcset` widths, and honors **hotspot / focal-point coordinates** (`object-position: calc(var(--fp-x, 0.5) * 100%) calc(var(--fp-y, 0.5) * 100%)` or CDN `fp-x`/`fp-y` crop params) so portraits and product shots never get decapitated across card aspect ratios.
|
|
170
|
+
- **Word / Google Docs / Notion paste sanitization**: configure ProseMirror `editorProps.transformPastedHTML` (or Lexical `PASTE_COMMAND` + server allowlist) to strip inline `style="font-family: Calibri; color: #000000; font-size: 11pt"`, `<font>`, `MsoNormal` classes, arbitrary `<span>` soup, and accidental `<h1>` tags—converting pasted content cleanly into semantic `<h2>`–`<h4>`, `<p>`, `<ul>`/`<ol>`, `<blockquote>`, `<strong>`/`<em>`, and safe `<a>` nodes styled exclusively by design tokens.
|
|
171
|
+
- **Schema guardrails, alt-text enforcement & Draft Live Preview**: configure CMS field schemas (Sanity, Payload, Strapi, Contentful, Directus, Tina, Keystatic, Wagtail, Gutenberg) with soft/hard character limits and live counters on titles, card teasers, and SEO descriptions so long copy cannot shatter layouts; require explicit `alt` text (or an intentional `"Decorative"` checkbox emitting `alt=""`) before publishing media; and wire **Draft Mode / Live Preview** so editors inspect unpublished responsive pages in real templates prior to publish.
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
// ProseMirror / Tiptap: strip Word & Google Docs inline style/font soup on paste
|
|
175
|
+
const cleanWordPaste = (html: string): string => {
|
|
176
|
+
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
177
|
+
doc.querySelectorAll('style, meta, link, script, xml, o\\:p').forEach((el) => el.remove());
|
|
178
|
+
doc.querySelectorAll('*').forEach((el) => {
|
|
179
|
+
el.removeAttribute('style');
|
|
180
|
+
el.removeAttribute('class');
|
|
181
|
+
el.removeAttribute('face');
|
|
182
|
+
el.removeAttribute('color');
|
|
183
|
+
el.removeAttribute('size');
|
|
184
|
+
if (el.tagName === 'H1') {
|
|
185
|
+
const h2 = doc.createElement('h2');
|
|
186
|
+
h2.innerHTML = el.innerHTML;
|
|
187
|
+
el.replaceWith(h2);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return doc.body.innerHTML;
|
|
191
|
+
};
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Accessibility, IME, and collaborative CRDT rules for editors
|
|
195
|
+
|
|
196
|
+
- Every editor must have an accessible name (`aria-label` or `aria-labelledby`) and a documented keyboard escape hatch from `Tab` indentation (for example, `Esc` then `Tab` or a visible toggle) so keyboard users are never trapped (WCAG 2.1.2).
|
|
197
|
+
- Toolbars must use roving `tabindex` (`role="toolbar"`) with `aria-pressed` on formatting toggles (`Bold`, `Italic`, `Code`).
|
|
198
|
+
- Never break IME composition (CJK/Vietnamese/accented input) by rewriting editor content synchronously on `keydown`/`input` during `isComposing`. For custom canvas or virtualized code editors in Chromium 121+, feature-detect the W3C **EditContext API** (`'EditContext' in window`) to decouple OS/IME composition (`textupdate`, `updateControlBounds`) from hidden DOM hacks, with a fallback for Safari/Firefox.
|
|
199
|
+
- **Collaborative rich text**: never roll ad-hoc string diffing or last-write-wins patches for concurrent document editing—use proven CRDT/OT engines (Yjs/YATA, Peritext-style rich-text mark CRDTs, or Fugue non-interleaving sequence CRDTs) so concurrent insertions at the same cursor do not corrupt or interleave characters.
|
|
200
|
+
|
|
201
|
+
## Do/don't pairs
|
|
202
|
+
|
|
203
|
+
| Do | Don't |
|
|
204
|
+
|---|---|
|
|
205
|
+
| Set `immediatelyRender: false` in Tiptap `useEditor()` for SSR apps | Mount Tiptap immediately on the server and ship hydration mismatches |
|
|
206
|
+
| Disable `StarterKit` `undoRedo` **only** when Yjs Collaboration is attached | Copy `undoRedo: false` into a standalone single-user editor (silently breaks Undo/Redo) |
|
|
207
|
+
| Use **Shiki** (build/SSR) for read-only code blocks and CodeMirror 6 (`Compartment`) for editable inputs | Ship Monaco or CodeMirror just to highlight static code examples, or recreate `EditorView` on prop change |
|
|
208
|
+
| Lazy-load Monaco and configure Web Workers for desktop IDE surfaces | Bundle full Monaco synchronously into a mobile form or settings modal |
|
|
209
|
+
| Auto-transcode `10–15 MB` CMS uploads to AVIF/WebP `srcset` with focal-point crop, sanitize Word/Docs paste, and wire Draft Live Preview | Serve raw camera uploads directly, allow pasted `style="font-family: Calibri"` soup into production HTML, or publish blind without preview |
|
|
210
|
+
| Provide a `Tab` escape hatch and `role="toolbar"` roving focus | Trap keyboard focus inside `Tab`-indented editors |
|
|
211
|
+
| Sanitize persisted rich-text HTML or store structured JSON AST | Render unsanitized `dangerouslySetInnerHTML` from editor output |
|
|
212
|
+
|
|
213
|
+
## Verification commands
|
|
214
|
+
|
|
215
|
+
```sh
|
|
216
|
+
npm run build
|
|
217
|
+
npx playwright test
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Verify bundle chunk splitting (editor chunks lazy-loaded, `static`), and test typing, IME composition, undo/redo, Word/Google Docs paste cleanup, CMS focal-point crop, Draft Live Preview, and keyboard escape from `Tab` in a real browser (`rendered`).
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Rive and Lottie / dotLottie selection
|
|
2
|
+
|
|
3
|
+
## Choose by behavior
|
|
4
|
+
|
|
5
|
+
| Need | Choose | Packages | Why |
|
|
6
|
+
|---|---|---|---|
|
|
7
|
+
| Interactive state machine, pointer-tracking rig, or data-bound vector animation | **Rive** | `@rive-app/react-canvas`, `@rive-app/canvas` (vanilla/Vue/Svelte), `@rive-app/webgl2` / `@rive-app/react-webgl2` (feathering / dense vector GPU scenes) | State machines and ViewModel Data Binding run in a compact WASM runtime without rebuilding timelines in JS |
|
|
8
|
+
| One-shot or looped vector illustration / empty-state graphic | **dotLottie** (`.lottie` archive) | `@lottiefiles/dotlottie-react`, `@lottiefiles/dotlottie-web` (WASM) | Compressed `.lottie` bundles with built-in theming/state support replace bloated legacy `lottie-web` JSON payloads |
|
|
9
|
+
| UI state, selection, validation, focus, or form feedback | Native DOM/CSS | N/A | Assistive tech and application state require semantic controls, not canvas pixels |
|
|
10
|
+
| Complex scroll choreography or path movement | GSAP / native CSS scroll timelines | `gsap` (`gsap.md`) | Timeline/scroll ownership is easier to inspect and synchronize with DOM |
|
|
11
|
+
|
|
12
|
+
## Rive Data Binding (ViewModels) & dotLottie idioms
|
|
13
|
+
|
|
14
|
+
- **Rive Data Binding / ViewModels**: prefer Rive's **Data Binding (`autoBind: true` + `useViewModelInstanceString` / `Number` / `Boolean` / `Trigger`)** over brittle manual `useStateMachineInput` string lookups whenever the `.riv` asset defines a ViewModel. Keep application state authoritative; drive Rive properties from app state.
|
|
15
|
+
- **Rive cleanup & offscreen pause**: call `rive.cleanup()` on unmount in vanilla integrations (`useRive` handles disposal in React) and pause playback when hidden via `IntersectionObserver` or `prefers-reduced-motion`.
|
|
16
|
+
- **dotLottie reduced-motion & disposal**: pass `autoplay={!prefersReduced}` and call `dotLottie.pause(); dotLottie.setFrame(0);` (or render a static SVG/image fallback) under `prefers-reduced-motion: reduce`; call `dotLottie.destroy()` on unmount.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
// Rive React: state machine + Data Binding (autoBind) + reduced-motion pause
|
|
20
|
+
import { useEffect } from 'react';
|
|
21
|
+
import { useRive, useViewModelInstanceNumber } from '@rive-app/react-canvas';
|
|
22
|
+
|
|
23
|
+
export function SyncGauge({ progress, reducedMotion }: { progress: number; reducedMotion: boolean }) {
|
|
24
|
+
const { rive, RiveComponent } = useRive({
|
|
25
|
+
src: '/animations/sync-gauge.riv',
|
|
26
|
+
artboard: 'Gauge',
|
|
27
|
+
stateMachines: 'State Machine 1',
|
|
28
|
+
autoBind: true,
|
|
29
|
+
autoplay: !reducedMotion,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const { setValue } = useViewModelInstanceNumber('progress', rive?.viewModelInstance);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
setValue(progress);
|
|
36
|
+
}, [progress, setValue]);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div role="img" aria-label={`Sync progress ${progress}%`}>
|
|
40
|
+
<RiveComponent />
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
// dotLottie React: compressed .lottie archive with reduced-motion guard
|
|
48
|
+
import { DotLottieReact } from '@lottiefiles/dotlottie-react';
|
|
49
|
+
|
|
50
|
+
export function EmptyArchiveGraphic({ reducedMotion }: { reducedMotion: boolean }) {
|
|
51
|
+
return (
|
|
52
|
+
<DotLottieReact
|
|
53
|
+
src="/animations/empty-archive.lottie"
|
|
54
|
+
loop={!reducedMotion}
|
|
55
|
+
autoplay={!reducedMotion}
|
|
56
|
+
aria-hidden="true"
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Integration checklist
|
|
63
|
+
|
|
64
|
+
- Keep application state authoritative; the animation reflects state and never replaces DOM controls or status text.
|
|
65
|
+
- Provide `aria-label` (for meaningful graphics) or `aria-hidden="true"` (for pure decoration alongside real DOM copy).
|
|
66
|
+
- Lazy-load WASM runtimes and `.riv`/`.lottie` files on routes/regions that need them, cache cleanly, and supply a static SVG/poster fallback if WASM or asset fetch fails.
|
|
67
|
+
- Pause offscreen loops (`IntersectionObserver` + `document.hidden`) and check asset provenance, embedded fonts/images, and licenses.
|
|
68
|
+
|
|
69
|
+
## Official references
|
|
70
|
+
|
|
71
|
+
- Rive docs & Data Binding: https://rive.app/docs/
|
|
72
|
+
- Rive web runtimes: https://rive.app/docs/runtimes/web
|
|
73
|
+
- dotLottie web/React SDK: https://developers.lottiefiles.com/docs/dotlottie-player/dotlottie-web/
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Scala.js Laminar
|
|
2
|
+
|
|
3
|
+
## Token mapping
|
|
4
|
+
|
|
5
|
+
Use generated CSS variables/semantic classes in Laminar/Scala DOM Types. Reactive theme state can be a `Var`/signal controlling a root class, but visual constants belong in CSS/design-token assets rather than repeated inline styles.
|
|
6
|
+
|
|
7
|
+
## Layout and responsive idioms
|
|
8
|
+
|
|
9
|
+
Laminar has no virtual DOM; elements are real DOM with fine-grained Airstream updates. Use semantic HTML/CSS responsive layout and explicit ownership of dynamic nodes. Router state/deep links belong in URL-aware application state.
|
|
10
|
+
|
|
11
|
+
## Typography/custom fonts
|
|
12
|
+
|
|
13
|
+
Configure fonts in static HTML/CSS; verify fallback/subsets/scaling/localization. Use semantic type classes rather than inline font sizes in every element.
|
|
14
|
+
|
|
15
|
+
## Motion/reduced motion
|
|
16
|
+
|
|
17
|
+
Use CSS transitions/keyframes and `@media (prefers-reduced-motion: reduce)` first. Browser media query state can be read through scala-js-dom when reactive behavior depends on it. Do not use stream timing as decoration that masks state errors.
|
|
18
|
+
|
|
19
|
+
## Accessibility specifics
|
|
20
|
+
|
|
21
|
+
Scala DOM Types exposes HTML attributes/props/ARIA-like browser behavior, but type safety does not enforce semantics. Use labels, real buttons/links/forms, focus restoration after dynamic insertion/removal, keyboard paths, and visible focus. Validate the actual DOM/accessibility tree.
|
|
22
|
+
|
|
23
|
+
## States idiom
|
|
24
|
+
|
|
25
|
+
Airstream signals/events should model loading/empty/error/offline/stale/permission/optimistic states explicitly. Avoid sample/combine patterns that drop errors or leave stale data indistinguishable from current data. Preserve input across validation/server failure.
|
|
26
|
+
|
|
27
|
+
## Forms idiom
|
|
28
|
+
|
|
29
|
+
Use native forms/labels/types/autocomplete/inputmode. Controlled inputs need careful cursor/focus behavior because fine-grained updates may replace nodes. Validate at blur/submit and map server errors without clearing values.
|
|
30
|
+
|
|
31
|
+
## Do/don't pairs
|
|
32
|
+
|
|
33
|
+
| Do | Don't |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `label(forId := "email", "Email")` | placeholder-only input |
|
|
36
|
+
| real `button`/`form` elements | clickable divs driven by event streams |
|
|
37
|
+
| explicit async state ADT | unlabeled stale data after failed refresh |
|
|
38
|
+
| semantic class tokens | repeated inline color/style literals |
|
|
39
|
+
|
|
40
|
+
## Known traps
|
|
41
|
+
|
|
42
|
+
Unexpected element replacement causing focus loss, stream lifecycle leaks, missing keys in dynamic lists, Scala.js bundle size/compile-time hiding UX failure, exception paths that never surface in UI, imperative DOM interop divergence.
|
|
43
|
+
|
|
44
|
+
## Verification commands
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
sbt test
|
|
48
|
+
sbt fastLinkJS
|
|
49
|
+
sbt fullLinkJS
|
|
50
|
+
npx playwright test
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Inspect production/fast output differences, DOM/focus/accessibility behavior, offline/server failure, reduced motion, browser zoom/text scaling, localization expansion.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# 3D scene architecture
|
|
2
|
+
|
|
3
|
+
## Renderer and engine decision
|
|
4
|
+
|
|
5
|
+
- **Three.js**: direct control of scene, renderer, camera, asset loading, and disposal across any web stack.
|
|
6
|
+
- **React Three Fiber (R3F v9)**: declarative React composition over Three.js (read [r3f-integration.md](r3f-integration.md)). Use `@react-three/drei` selectively for helpers/controls/loaders—never pull the whole barrel blindly.
|
|
7
|
+
- **Alternative browser 3D engines**: for zero-code product GLB/AR previews (`<model-viewer>`), Babylon.js, PlayCanvas, Svelte **Threlte v8**, Vue **TresJS v5**, **luma.gl v9**, or `regl`, read [web-3d-engines.md](web-3d-engines.md). For designer-authored hosted scenes, Spline is an option when payload and accessibility trade-offs are explicitly accepted.
|
|
8
|
+
- **Embodied XR / headset UX**: for WebXR/visionOS/Quest comfort, depth ergonomics, and spatial interaction, use `pixelcraft-spatial`.
|
|
9
|
+
|
|
10
|
+
## Three.js `WebGPURenderer` (`three/webgpu`) + TSL (`three/tsl`)
|
|
11
|
+
|
|
12
|
+
Modern Three.js ships **`WebGPURenderer`** from `'three/webgpu'` (which runs on WebGPU when supported and **automatically falls back to a WebGL 2 backend** when WebGPU is unavailable) alongside **TSL (`'three/tsl'` — Three.js Shading Language)**, a composable JavaScript node-material graph that compiles to both WGSL and GLSL without duplicating shader files:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import * as THREE from 'three/webgpu';
|
|
16
|
+
import { color, mix, positionLocal, time, uniform } from 'three/tsl';
|
|
17
|
+
|
|
18
|
+
const renderer = new THREE.WebGPURenderer({ antialias: true, powerPreference: 'high-performance' });
|
|
19
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
|
|
20
|
+
renderer.setSize(container.clientWidth, container.clientHeight);
|
|
21
|
+
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
22
|
+
await renderer.init(); // Required async init before first render
|
|
23
|
+
container.appendChild(renderer.domElement);
|
|
24
|
+
|
|
25
|
+
// Node material compiles to WGSL on WebGPU and GLSL on WebGL2 fallback
|
|
26
|
+
const uMotion = uniform(window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 1);
|
|
27
|
+
const mat = new THREE.MeshStandardNodeMaterial();
|
|
28
|
+
mat.colorNode = mix(
|
|
29
|
+
color(0x1f2937),
|
|
30
|
+
color(0x38bdf8),
|
|
31
|
+
positionLocal.y.add(time.mul(0.4).mul(uMotion)).sin().mul(0.5).add(0.5),
|
|
32
|
+
);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Always call `renderer.setAnimationLoop(null)`, dispose geometries/materials/textures, and call `renderer.dispose()` on unmount.
|
|
36
|
+
|
|
37
|
+
## Scene contract
|
|
38
|
+
|
|
39
|
+
Record before building:
|
|
40
|
+
- world units and object scale (standardize 1 unit = 1 meter for PBR lighting and physics);
|
|
41
|
+
- coordinate orientation and origin;
|
|
42
|
+
- camera type, FOV/frustum, near/far planes, and reset behavior;
|
|
43
|
+
- user controls, damping, polar/zoom limits, and keyboard/DOM reset mapping;
|
|
44
|
+
- lighting/environment (`PMREMGenerator` / HDRI envMap) and linear-to-sRGB tone mapping (`ACESFilmicToneMapping` or `AgXToneMapping`);
|
|
45
|
+
- asset loading, missing asset, WebGL/WebGPU context loss, resize, and reduced-motion behavior.
|
|
46
|
+
|
|
47
|
+
Keep high-value text, pricing, forms, and primary controls in the DOM. Treat the canvas as a visual/manipulation surface, not a replacement for product semantics.
|
|
48
|
+
|
|
49
|
+
## Composition
|
|
50
|
+
|
|
51
|
+
- Establish silhouette and camera framing before adding detail.
|
|
52
|
+
- Use one main light strategy plus an environment map; avoid stacking multiple real-time shadow-casting lights without profiling.
|
|
53
|
+
- Keep postprocessing selective: a single restrained pass can be meaningful; multiple full-screen passes multiply fill-rate and VRAM cost.
|
|
54
|
+
- Make object manipulation bounded, resettable, and understandable. Avoid involuntary idle camera spin.
|
|
55
|
+
|
|
56
|
+
## Choreography & designer-authored WebGL scenes
|
|
57
|
+
|
|
58
|
+
### Theatre.js (keyframe & sequence choreography)
|
|
59
|
+
|
|
60
|
+
Use **Theatre.js** (`@theatre/core`, `@theatre/studio`, `@theatre/r3f`) when camera rails, lighting transitions, or DOM + Three.js/R3F properties require timeline curves authored visually instead of brittle nested `setTimeout` or hand-tuned easing arrays:
|
|
61
|
+
|
|
62
|
+
- **Strip Studio from production builds**: import `@theatre/studio` dynamically behind a build-time dev guard (`if (import.meta.env.DEV)`) and load the exported static `state.json` into `getProject('Hero', { state })` in production—never bundle Studio UI into end-user JavaScript.
|
|
63
|
+
- **Reduced motion**: when `prefers-reduced-motion: reduce` matches, seek directly to the resting keyframe (`sheet.sequence.position = REST_TIME`) instead of playing camera sweeps.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { getProject, types } from '@theatre/core';
|
|
67
|
+
import bakedState from './hero-sequence.theatre-project-state.json';
|
|
68
|
+
|
|
69
|
+
if (import.meta.env.DEV) {
|
|
70
|
+
const studio = (await import('@theatre/studio')).default;
|
|
71
|
+
studio.initialize();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const project = getProject('ProductShowcase', { state: bakedState });
|
|
75
|
+
const sheet = project.sheet('Intro');
|
|
76
|
+
const cameraRig = sheet.object('Camera', {
|
|
77
|
+
fov: types.number(40, { range: [25, 75] }),
|
|
78
|
+
orbitY: types.number(0, { range: [-Math.PI, Math.PI] }),
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Spline (`@splinetool/react-spline` / `@splinetool/runtime`)
|
|
83
|
+
|
|
84
|
+
Use **Spline** only when a designer-authored interactive 3D scene justifies its runtime payload and the following budget rules are enforced:
|
|
85
|
+
|
|
86
|
+
- **Lazy-load**: wrap `@splinetool/react-spline` in `React.lazy` (or load `@splinetool/runtime` on `IntersectionObserver` entry) so the Spline runtime never blocks hydration or first paint.
|
|
87
|
+
- **Scene weight budget**: audit `.splinecode` transfer size and embedded texture resolution before shipping (compress textures, cull hidden meshes, keep total scene transfer bounded rather than shipping 15 MB hero downloads).
|
|
88
|
+
- **Static poster & reduced-motion fallback**: render a high-craft static WebP/AVIF poster image immediately for LCP, keep the static poster when `prefers-reduced-motion: reduce` or Save-Data is active (with an explicit opt-in play toggle if interactive inspection matters), and keep all copy, buttons, and forms in semantic DOM above the canvas.
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
'use client';
|
|
92
|
+
|
|
93
|
+
import { lazy, Suspense, useEffect, useState } from 'react';
|
|
94
|
+
|
|
95
|
+
const Spline = lazy(() => import('@splinetool/react-spline'));
|
|
96
|
+
|
|
97
|
+
export function ProductSpline({ sceneUrl, posterUrl, alt }: { sceneUrl: string; posterUrl: string; alt: string }) {
|
|
98
|
+
const [reducedMotion, setReducedMotion] = useState(true);
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
setReducedMotion(window.matchMedia('(prefers-reduced-motion: reduce)').matches);
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
if (reducedMotion) {
|
|
105
|
+
return <img src={posterUrl} alt={alt} className="scene-poster" />;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<Suspense fallback={<img src={posterUrl} alt={alt} className="scene-poster" />}>
|
|
110
|
+
<Spline scene={sceneUrl} aria-label={alt} />
|
|
111
|
+
</Suspense>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Unicorn Studio (interactive WebGL scene embeds)
|
|
117
|
+
|
|
118
|
+
Use **Unicorn Studio** when embedding designer-authored shader/WebGL motion backdrops with explicit performance and accessibility guardrails:
|
|
119
|
+
|
|
120
|
+
- Lazy-initialize (`UnicornStudio.init()`) only when the section approaches the viewport, cap DPR (`data-us-dpi="1.5"`), and destroy/pause instances when scrolled offscreen or unmounted (`UnicornStudio.destroy()`).
|
|
121
|
+
- Always render a lightweight CSS/static poster fallback beneath the canvas for `prefers-reduced-motion: reduce`, low-power/Save-Data devices, or WebGL context failure.
|
|
122
|
+
- Treat Unicorn Studio strictly as an atmospheric layer—never lock readable headlines, navigation, or conversion forms inside the WebGL canvas.
|
|
123
|
+
|
|
124
|
+
## Official references
|
|
125
|
+
|
|
126
|
+
- Three.js docs: https://threejs.org/docs/
|
|
127
|
+
- Three.js WebGPU & TSL wiki/examples: https://threejs.org/examples/?q=webgpu
|
|
128
|
+
- React Three Fiber docs: https://r3f.docs.pmnd.rs/
|
|
129
|
+
- Drei docs: https://drei.docs.pmnd.rs/
|
|
130
|
+
- Theatre.js docs: https://www.theatrejs.com/docs/latest
|
|
131
|
+
- Spline docs: https://docs.spline.design/
|
|
132
|
+
- WebGPU API: https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API
|