@thanhnguyxn/pixelcraft 0.1.0 → 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 +1 -1
- package/.antigravity-plugin/plugin.json +32 -0
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +15 -4
- 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/README.md +185 -328
- package/SECURITY.md +28 -0
- package/assets/pixelcraft-logo-128.png +0 -0
- package/assets/pixelcraft-logo-256.png +0 -0
- package/bin/pixelcraft.mjs +431 -23
- package/docs/ARCHITECTURE.md +40 -37
- package/docs/DESIGN-RATIONALE.md +51 -3
- package/docs/INSTALL.md +221 -0
- package/evals/README.md +16 -6
- package/evals/fixtures/3d-web-engineering.json +69 -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/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/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/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-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/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/pixelcraft-accessibility.md +17 -0
- package/evals/pixelcraft-craft.md +16 -0
- package/evals/pixelcraft-dataviz.md +3 -3
- package/evals/pixelcraft-direction.md +17 -0
- package/evals/pixelcraft-game-ui.md +3 -3
- package/evals/pixelcraft-mobile.md +3 -3
- package/evals/pixelcraft-patterns.md +16 -0
- package/evals/pixelcraft-plan.md +65 -3
- package/evals/pixelcraft-review.md +3 -3
- package/evals/pixelcraft-visual-qa.md +11 -5
- package/evals/pixelcraft-web.md +21 -3
- package/evals/pixelcraft.md +4 -4
- package/gemini-extension.json +3 -2
- package/install.ps1 +57 -11
- package/install.sh +82 -7
- package/package.json +32 -4
- package/plugin.json +6 -1
- package/scripts/build-adapters.mjs +11 -13
- package/scripts/run-evals.mjs +397 -0
- package/scripts/sync-docs.mjs +381 -0
- package/scripts/test-build-adapters.mjs +14 -1
- package/scripts/test-cross-platform-qa.mjs +359 -0
- package/scripts/test-distribution.mjs +86 -7
- package/scripts/test-export-tokens.mjs +259 -3
- package/scripts/test-finish-gate.mjs +133 -10
- package/scripts/test-installers.mjs +155 -6
- package/scripts/test-shoot.mjs +23 -1
- package/scripts/test-slop-scan.mjs +390 -3
- package/scripts/test-style-inventory.mjs +23 -0
- package/scripts/test-sync-docs.mjs +140 -0
- package/scripts/test-validate-skills.mjs +82 -4
- package/scripts/validate-skills.mjs +149 -3
- package/skills/pixelcraft/SKILL.md +67 -47
- package/skills/pixelcraft/references/design-brief.md +2 -2
- package/skills/pixelcraft/references/floor.md +36 -19
- package/skills/pixelcraft/references/report-template.md +25 -11
- package/skills/pixelcraft/references/stack-detection.md +138 -67
- package/skills/pixelcraft/references/surface-acceptance.md +33 -21
- package/skills/pixelcraft/references/workflow-checkpoints.md +49 -7
- package/skills/pixelcraft-accessibility/SKILL.md +34 -13
- package/skills/pixelcraft-accessibility/references/apg-patterns.md +13 -0
- package/skills/pixelcraft-accessibility/references/motion-canvas.md +57 -0
- package/skills/pixelcraft-accessibility/references/platforms.md +34 -6
- package/skills/pixelcraft-accessibility/references/verification.md +15 -10
- package/skills/pixelcraft-accessibility/references/wcag22-checks.md +38 -5
- package/skills/pixelcraft-brandkit/SKILL.md +42 -30
- package/skills/pixelcraft-brandkit/references/asset-pipeline.md +90 -50
- package/skills/pixelcraft-brandkit/references/brand-governance.md +29 -27
- package/skills/pixelcraft-brandkit/references/logo-methods.md +33 -34
- package/skills/pixelcraft-brandkit/references/prompt-template.md +53 -51
- package/skills/pixelcraft-brandkit/references/qa-checklist.md +7 -2
- package/skills/pixelcraft-brandkit/references/visual-modes.md +16 -16
- package/skills/pixelcraft-chat-ui/SKILL.md +31 -27
- 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 +12 -6
- package/skills/pixelcraft-chat-ui/references/mobile-business-platforms.md +58 -68
- package/skills/pixelcraft-chat-ui/references/slack-discord.md +60 -76
- package/skills/pixelcraft-constrained/SKILL.md +21 -20
- package/skills/pixelcraft-constrained/references/specialized-hardware.md +69 -45
- package/skills/pixelcraft-constrained/references/tv-wearables.md +123 -73
- package/skills/pixelcraft-constrained/references/voice-ui.md +86 -45
- package/skills/pixelcraft-craft/SKILL.md +29 -15
- package/skills/pixelcraft-craft/references/color.md +62 -6
- package/skills/pixelcraft-craft/references/layout.md +32 -0
- package/skills/pixelcraft-craft/references/motion.md +99 -12
- package/skills/pixelcraft-craft/references/typography.md +48 -9
- package/skills/pixelcraft-data-apps/SKILL.md +50 -31
- package/skills/pixelcraft-data-apps/references/ai-and-internal-data-apps.md +147 -0
- package/skills/pixelcraft-data-apps/references/dash.md +87 -31
- package/skills/pixelcraft-data-apps/references/evidence.md +41 -26
- package/skills/pixelcraft-data-apps/references/gradio.md +65 -27
- package/skills/pixelcraft-data-apps/references/julia-genie.md +64 -29
- package/skills/pixelcraft-data-apps/references/jupyter-widgets.md +65 -27
- package/skills/pixelcraft-data-apps/references/nicegui.md +73 -34
- package/skills/pixelcraft-data-apps/references/observable-framework.md +65 -27
- package/skills/pixelcraft-data-apps/references/panel.md +69 -23
- package/skills/pixelcraft-data-apps/references/r-shiny.md +104 -34
- package/skills/pixelcraft-data-apps/references/reactive-data-apps.md +186 -0
- package/skills/pixelcraft-data-apps/references/reflex.md +85 -31
- package/skills/pixelcraft-data-apps/references/shiny.md +84 -27
- package/skills/pixelcraft-data-apps/references/streamlit.md +73 -25
- package/skills/pixelcraft-dataviz/SKILL.md +21 -24
- package/skills/pixelcraft-dataviz/references/color-accessibility.md +2 -2
- package/skills/pixelcraft-dataviz/references/encoding-tables-dashboards.md +35 -25
- package/skills/pixelcraft-dataviz/references/libraries.md +165 -46
- package/skills/pixelcraft-dataviz/references/maps-geospatial.md +159 -0
- package/skills/pixelcraft-dataviz/references/realtime-graphs-maps-scale.md +58 -65
- package/skills/pixelcraft-desktop/SKILL.md +61 -39
- package/skills/pixelcraft-desktop/references/appkit.md +60 -26
- package/skills/pixelcraft-desktop/references/avalonia.md +65 -29
- package/skills/pixelcraft-desktop/references/cpp-gui.md +104 -27
- package/skills/pixelcraft-desktop/references/electron.md +68 -26
- package/skills/pixelcraft-desktop/references/go-gui.md +59 -30
- package/skills/pixelcraft-desktop/references/gtk.md +74 -31
- package/skills/pixelcraft-desktop/references/javafx-swing.md +54 -25
- package/skills/pixelcraft-desktop/references/qt-pyside-qml.md +57 -30
- package/skills/pixelcraft-desktop/references/rust-gui.md +59 -41
- package/skills/pixelcraft-desktop/references/tauri.md +80 -24
- package/skills/pixelcraft-desktop/references/uno-platform.md +42 -23
- package/skills/pixelcraft-desktop/references/winui-wpf.md +66 -26
- package/skills/pixelcraft-desktop/references/working-context.md +82 -3
- package/skills/pixelcraft-direction/SKILL.md +48 -82
- package/skills/pixelcraft-direction/references/creative-brainstorming.md +72 -0
- package/skills/pixelcraft-direction/references/direction-card.md +11 -1
- package/skills/pixelcraft-direction/references/direction-scoring.md +5 -1
- package/skills/pixelcraft-direction/references/motion-identity.md +67 -0
- package/skills/pixelcraft-direction/references/movements.md +3 -0
- package/skills/pixelcraft-direction/references/reference-analysis.md +37 -0
- package/skills/pixelcraft-direction/references/slop-fingerprints.md +32 -7
- package/skills/pixelcraft-document/SKILL.md +27 -23
- package/skills/pixelcraft-document/references/archetypes.md +27 -4
- package/skills/pixelcraft-document/references/pdf-tools.md +241 -81
- package/skills/pixelcraft-document/references/pdfjs-and-pptx.md +114 -0
- package/skills/pixelcraft-document/references/print-css.md +96 -43
- package/skills/pixelcraft-document/references/slides.md +123 -27
- package/skills/pixelcraft-email/SKILL.md +42 -20
- package/skills/pixelcraft-email/references/client-quirks.md +101 -33
- package/skills/pixelcraft-email/references/html-tables.md +83 -22
- package/skills/pixelcraft-email/references/maizzle.md +54 -0
- package/skills/pixelcraft-email/references/mjml.md +13 -11
- package/skills/pixelcraft-email/references/react-email.md +76 -34
- package/skills/pixelcraft-extensions/SKILL.md +32 -27
- package/skills/pixelcraft-extensions/references/browser-extensions.md +91 -17
- package/skills/pixelcraft-extensions/references/figma-office.md +97 -14
- package/skills/pixelcraft-extensions/references/ide-and-saas-plugins.md +125 -0
- package/skills/pixelcraft-extensions/references/raycast.md +90 -11
- package/skills/pixelcraft-extensions/references/vscode-webviews.md +91 -17
- package/skills/pixelcraft-game-ui/SKILL.md +45 -26
- package/skills/pixelcraft-game-ui/references/bevy.md +69 -31
- package/skills/pixelcraft-game-ui/references/godot.md +100 -27
- package/skills/pixelcraft-game-ui/references/hud-principles.md +50 -21
- package/skills/pixelcraft-game-ui/references/love2d.md +53 -27
- package/skills/pixelcraft-game-ui/references/monogame.md +45 -29
- package/skills/pixelcraft-game-ui/references/unity-ugui.md +109 -0
- package/skills/pixelcraft-game-ui/references/unity-ui-toolkit.md +69 -27
- package/skills/pixelcraft-game-ui/references/unreal-umg.md +53 -26
- package/skills/pixelcraft-game-ui/references/web-and-middleware-game-ui.md +122 -0
- package/skills/pixelcraft-handoff/SKILL.md +14 -13
- package/skills/pixelcraft-handoff/references/design-translation.md +40 -10
- package/skills/pixelcraft-handoff/references/motion-handoff.md +54 -0
- package/skills/pixelcraft-media/SKILL.md +20 -23
- package/skills/pixelcraft-media/references/banners-video.md +83 -65
- package/skills/pixelcraft-media/references/og-generation.md +110 -63
- package/skills/pixelcraft-media/references/social-cards.md +57 -58
- package/skills/pixelcraft-mobile/SKILL.md +53 -36
- package/skills/pixelcraft-mobile/references/dotnet-maui.md +62 -34
- package/skills/pixelcraft-mobile/references/flet.md +53 -26
- package/skills/pixelcraft-mobile/references/flutter.md +76 -32
- package/skills/pixelcraft-mobile/references/harmonyos-and-emerging-mobile.md +121 -0
- package/skills/pixelcraft-mobile/references/ionic-capacitor.md +48 -26
- package/skills/pixelcraft-mobile/references/jetpack-compose.md +92 -24
- package/skills/pixelcraft-mobile/references/kivy.md +54 -31
- package/skills/pixelcraft-mobile/references/kotlin-multiplatform.md +53 -27
- 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 +66 -31
- package/skills/pixelcraft-mobile/references/swiftui.md +158 -28
- package/skills/pixelcraft-mobile/references/tactile-interactions.md +55 -0
- package/skills/pixelcraft-mobile/references/task-state-composition.md +82 -2
- package/skills/pixelcraft-mobile/references/uikit.md +57 -23
- package/skills/pixelcraft-patterns/SKILL.md +30 -13
- 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 +32 -13
- 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 +35 -16
- package/skills/pixelcraft-patterns/references/communication.md +34 -15
- package/skills/pixelcraft-patterns/references/creative-tools.md +30 -17
- package/skills/pixelcraft-patterns/references/creative-web-composition.md +38 -0
- package/skills/pixelcraft-patterns/references/dashboard-admin.md +22 -18
- package/skills/pixelcraft-patterns/references/history-diff-undo.md +50 -0
- package/skills/pixelcraft-patterns/references/marketing.md +31 -19
- 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 +8 -2
- 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/settings.md +40 -12
- package/skills/pixelcraft-plan/SKILL.md +54 -18
- 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 +44 -9
- package/skills/pixelcraft-plan/references/repo-discovery.md +16 -9
- package/skills/pixelcraft-plan/references/stack-freshness.md +22 -5
- package/skills/pixelcraft-plan/references/stack-selection.md +65 -9
- package/skills/pixelcraft-review/SKILL.md +41 -19
- package/skills/pixelcraft-review/references/audit-report.md +20 -1
- package/skills/pixelcraft-review/references/heuristics.md +63 -18
- package/skills/pixelcraft-review/references/personas.md +41 -14
- package/skills/pixelcraft-review/references/polish.md +66 -26
- package/skills/pixelcraft-review/scripts/check-acceptance.mjs +619 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-longhand-removal.css +34 -0
- package/skills/pixelcraft-review/scripts/slop-scan.mjs +679 -32
- package/skills/pixelcraft-spatial/SKILL.md +16 -17
- package/skills/pixelcraft-spatial/references/comfort-accessibility.md +25 -84
- package/skills/pixelcraft-spatial/references/platforms.md +123 -53
- package/skills/pixelcraft-tokens/SKILL.md +18 -14
- package/skills/pixelcraft-tokens/assets/tokens.example.json +1 -1
- package/skills/pixelcraft-tokens/assets/tokens.modes.example.json +1 -1
- package/skills/pixelcraft-tokens/references/format.md +39 -9
- package/skills/pixelcraft-tokens/references/governance.md +1 -1
- package/skills/pixelcraft-tokens/references/theme-presets.md +36 -8
- package/skills/pixelcraft-tokens/references/token-tooling.md +119 -0
- package/skills/pixelcraft-tokens/scripts/export-tokens.mjs +637 -75
- package/skills/pixelcraft-tui/SKILL.md +41 -25
- package/skills/pixelcraft-tui/references/bubbletea-lipgloss.md +49 -30
- package/skills/pixelcraft-tui/references/extended-tui-toolkits.md +127 -0
- package/skills/pixelcraft-tui/references/ink.md +77 -28
- package/skills/pixelcraft-tui/references/ratatui.md +70 -30
- package/skills/pixelcraft-tui/references/rich.md +53 -33
- package/skills/pixelcraft-tui/references/terminal-protocols.md +80 -0
- package/skills/pixelcraft-tui/references/textual.md +75 -34
- package/skills/pixelcraft-ux/SKILL.md +22 -12
- package/skills/pixelcraft-ux/references/feedback-performance.md +39 -19
- package/skills/pixelcraft-ux/references/forms.md +57 -3
- package/skills/pixelcraft-ux/references/i18n.md +50 -12
- package/skills/pixelcraft-ux/references/laws.md +35 -14
- package/skills/pixelcraft-ux/references/state-matrix.md +15 -1
- package/skills/pixelcraft-ux/references/ux-writing.md +1 -0
- package/skills/pixelcraft-visual-qa/SKILL.md +21 -7
- package/skills/pixelcraft-visual-qa/references/capture-desktop-game.md +28 -7
- package/skills/pixelcraft-visual-qa/references/capture-document.md +70 -0
- package/skills/pixelcraft-visual-qa/references/capture-email.md +13 -9
- package/skills/pixelcraft-visual-qa/references/capture-mobile.md +20 -5
- package/skills/pixelcraft-visual-qa/references/capture-terminal.md +6 -2
- package/skills/pixelcraft-visual-qa/references/motion-capture.md +63 -0
- package/skills/pixelcraft-visual-qa/references/performance-budgets.md +25 -12
- package/skills/pixelcraft-visual-qa/references/realtime-graphics.md +55 -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 +50 -11
- package/skills/pixelcraft-visual-qa/scripts/shoot.mjs +214 -59
- package/skills/pixelcraft-visual-qa/scripts/style-inventory.mjs +121 -49
- package/skills/pixelcraft-web/SKILL.md +105 -49
- package/skills/pixelcraft-web/references/accessibility-performance.md +42 -0
- package/skills/pixelcraft-web/references/adaptive-layout.md +52 -8
- package/skills/pixelcraft-web/references/angular.md +63 -16
- package/skills/pixelcraft-web/references/assets-pipeline.md +67 -0
- package/skills/pixelcraft-web/references/astro.md +64 -13
- 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 +52 -17
- 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/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 +3 -2
- package/skills/pixelcraft-web/references/gsap.md +102 -0
- package/skills/pixelcraft-web/references/html-css.md +144 -12
- package/skills/pixelcraft-web/references/htmx-alpine.md +68 -18
- 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 +27 -18
- package/skills/pixelcraft-web/references/kotlin-web.md +6 -2
- package/skills/pixelcraft-web/references/leptos-yew.md +62 -19
- package/skills/pixelcraft-web/references/lit-web-components.md +4 -2
- 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 +6 -1
- package/skills/pixelcraft-web/references/qwik.md +51 -11
- package/skills/pixelcraft-web/references/r3f-integration.md +69 -0
- package/skills/pixelcraft-web/references/react-next.md +112 -13
- 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/scene-architecture.md +132 -0
- package/skills/pixelcraft-web/references/server-rendered.md +106 -63
- 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 +67 -16
- 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 +61 -11
- package/skills/pixelcraft-web/references/tailwind.md +40 -14
- package/skills/pixelcraft-web/references/video-media.md +69 -0
- package/skills/pixelcraft-web/references/vue-nuxt.md +37 -13
- package/skills/pixelcraft-web/references/web-3d-engines.md +97 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Audiovisual accessibility and performance
|
|
2
|
+
|
|
3
|
+
Pair these concrete browser media rules with [media-players.md](media-players.md) and `pixelcraft-accessibility` (`motion-canvas.md`).
|
|
4
|
+
|
|
5
|
+
## `<track>` & alternative media contract (WCAG 1.2.x)
|
|
6
|
+
|
|
7
|
+
| Track `kind` | Purpose | Required when |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `kind="captions"` | Spoken dialogue **plus** meaningful non-speech sound cues (`[alarm beeps]`, `[music fades]`) | All prerecorded informative video with audio (WCAG 1.2.2); include `srclang`, `label`, and `default` where appropriate |
|
|
10
|
+
| `kind="descriptions"` | Text audio-description cues describing critical visual-only actions/charts | Informative video containing visual information not spoken in the audio track (WCAG 1.2.3 / 1.2.5) |
|
|
11
|
+
| `kind="subtitles"` | Translated dialogue for viewers who can hear the audio | Multilingual releases (does **not** replace `captions` for deaf/hard-of-hearing users) |
|
|
12
|
+
| `kind="chapters"` | Navigable WebVTT chapter markers | Long tutorials, talks, and podcasts for keyboard/scrubber navigation |
|
|
13
|
+
|
|
14
|
+
- Supply a readable text transcript adjacent to audio-only podcasts/clips (WCAG 1.2.1) and long-form videos so users can search, copy, and translate content.
|
|
15
|
+
|
|
16
|
+
## User control & WCAG 2.2.2 / 2.3.1 safety rules
|
|
17
|
+
|
|
18
|
+
- **No unmuted autoplay (WCAG 1.4.2)**: never autoplay audible media (>3s without an immediate pause/stop/mute control).
|
|
19
|
+
- **WCAG 2.2.2 (Pause, Stop, Hide)**: any moving, blinking, scrolling, or auto-updating content (ambient background video, marquees, canvas loops, carousels) that starts automatically, lasts **more than 5 seconds**, and appears alongside other content **must** expose a visible, keyboard-focusable Pause/Stop/Hide button—honoring `prefers-reduced-motion` is necessary but not sufficient for users who have not enabled OS reduced motion.
|
|
20
|
+
- **WCAG 2.3.1 (Three Flashes or Below Threshold)**: never render content that flashes **more than 3 times in any 1-second period** above general or saturated-red flash thresholds. Clamp audio-reactive luminance/opacity modulation (`audio-reactive.md`) and shader noise frequencies accordingly.
|
|
21
|
+
- **Keyboard & assistive tech parity**: Play/Pause, Seek, Mute/Volume, Captions toggle, and Fullscreen must be reachable by `Tab`, operable with `Space`/`Enter`/arrows, expose `aria-pressed` or live state labels, and keep visible focus rings.
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<!-- Ambient loop satisfying WCAG 2.2.2 (Pause control) + reduced motion -->
|
|
25
|
+
<figure class="ambient-stage">
|
|
26
|
+
<video id="hero-loop" muted loop playsinline poster="/media/loop-poster.webp" aria-hidden="true">
|
|
27
|
+
<source src="/media/loop.mp4" type='video/mp4; codecs="avc1.42E01E"' />
|
|
28
|
+
</video>
|
|
29
|
+
<button type="button" id="toggle-loop" aria-pressed="false" aria-controls="hero-loop">
|
|
30
|
+
Pause background motion
|
|
31
|
+
</button>
|
|
32
|
+
</figure>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Performance & verification
|
|
36
|
+
|
|
37
|
+
- Record media transfer size, codec/decode cost, analyser/visualizer update rate, GPU frame time, memory, and device tier separately (`rendered`).
|
|
38
|
+
- Lazy-load below-fold media (`preload="none"` / `IntersectionObserver`), pause playback when offscreen or `document.hidden`, avoid per-frame allocations in audio visualizers, and test on mid-tier mobile or throttled network profiles (or mark device profiling `not-checked`).
|
|
39
|
+
|
|
40
|
+
Official guidance:
|
|
41
|
+
- WCAG 2.2: https://www.w3.org/TR/WCAG22/
|
|
42
|
+
- W3C Making Audio and Video Media Accessible: https://www.w3.org/WAI/media/av/
|
|
@@ -8,18 +8,62 @@ Use these as starting CSS viewport sizes, not prescribed breakpoints. Check just
|
|
|
8
8
|
|
|
9
9
|
| Class | Example width × height | Task constraint to check |
|
|
10
10
|
|---|---|---|
|
|
11
|
-
| Small /
|
|
12
|
-
| Phone landscape | 844×390 | Safe insets, short dialogs, keyboard/scroll recovery, primary action
|
|
11
|
+
| Small / standard phone portrait | 360×800 / 390×844 / 430×932 (plus 320px WCAG reflow) | One-handed reach, `>= 44×44px` touch targets, no hover dependency, long labels and soft keyboard. |
|
|
12
|
+
| Phone landscape | 844×390 | Safe insets (`env(safe-area-inset-*)`), short dialogs, keyboard/scroll recovery, primary action reachable. |
|
|
13
13
|
| Tablet portrait / landscape | 768×1024 / 1024×768 | Touch and attached keyboard/pointer; panes that adapt without losing current selection. |
|
|
14
14
|
| Foldable / split pane | Host pane sizes before and after change | Avoid a hinge or constrained pane when relevant; retain progress when resized or folded. |
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
15
|
+
| **Scaled 13–14" laptop (short fold)** | **`1280×620` / `1366×650`** (Windows `125%–150%` OS scale + browser chrome) | **Above-the-fold headline, value anchor, and primary CTA must remain visible and unclipped without blind scrolling.** |
|
|
16
|
+
| Desktop / large monitor | 1280×800 / 1440×900 / 1920×1080 | Keep scan efficiency, pointer actions, and keyboard/focus paths; never hide critical actions behind hover alone. |
|
|
17
|
+
| Ultrawide | 2560×1080+ | Constrain reading measure (`65–75ch`) and max shell width without stretching unrelated controls across the screen. |
|
|
18
|
+
| Shallow split / docked window | 1280×480 | Reachable focused fields and scrollable modal bodies despite sticky bars and reduced vertical space. |
|
|
18
19
|
|
|
19
20
|
## Implementation
|
|
20
21
|
|
|
21
|
-
-
|
|
22
|
+
- Verify across the standard width progression (`360`, `390`, `768`, `1024`, `1280`, `1440`, `1920+` CSS px) **and** short-height laptop folds (`1280×620` / `1366×650`). Never set hero sections to rigid `min-height: 900px` or excessive vertical padding that pushes the primary CTA below the fold on a `125%–150%` scaled Windows laptop—use `clamp()` vertical spacing and `@media (max-height: 700px)` tightening rules.
|
|
23
|
+
- Use fluid Grid/Flex, intrinsic sizing, `clamp()`, and logical properties. Use container queries for components reused in panels of different widths; reserve viewport queries for shell changes, including height and aspect-ratio constraints where needed.
|
|
22
24
|
- Consider a wide sidebar versus a compact tab bar or sheet, a table versus a summary list with details, and denser desktop controls versus touch targets. Choose only patterns that fit the task. Preserve actual table semantics or a usable comparison view when the task requires comparing rows/columns; do not remove fields to avoid reflow.
|
|
23
25
|
- Match affordances to keyboard, pointer and touch; use hover as enhancement, not the sole way to reveal an action. Test mixed-input devices and preserve Tab order and focus across presentation changes.
|
|
24
|
-
- Handle mobile browser chrome with
|
|
25
|
-
|
|
26
|
+
- Handle mobile browser chrome with dynamic/small viewport units (`100svh` for stable above-the-fold hero bounds without address-bar resize jumps; `100dvh`/`100dvb` with `100vh` fallback for full-height app shells) and safe-area insets (`env(safe-area-inset-*)`); treat on-screen keyboard occlusion as a separate runtime check. Make constrained regions scroll rather than clipping or locking the whole page, and verify focused controls stay visible.
|
|
27
|
+
|
|
28
|
+
```css
|
|
29
|
+
/* Logical-property adaptive shell + container-query panel adaptation */
|
|
30
|
+
.app-shell {
|
|
31
|
+
display: grid;
|
|
32
|
+
min-block-size: 100vh;
|
|
33
|
+
min-block-size: 100dvb;
|
|
34
|
+
grid-template-rows: auto minmax(0, 1fr);
|
|
35
|
+
padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.app-main {
|
|
39
|
+
container-type: inline-size;
|
|
40
|
+
container-name: workspace;
|
|
41
|
+
padding-inline: clamp(1rem, 3vw, 2rem);
|
|
42
|
+
padding-block: 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@media (inline-size >= 64rem) {
|
|
46
|
+
.app-shell {
|
|
47
|
+
grid-template-rows: none;
|
|
48
|
+
grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Re-compose detail cards based on workspace slot width, not only viewport */
|
|
53
|
+
@container workspace (inline-size >= 44rem) {
|
|
54
|
+
.detail-grid {
|
|
55
|
+
display: grid;
|
|
56
|
+
grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
|
|
57
|
+
gap: var(--space-4, 1rem);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Preserve touch target floor on coarse pointers without inflating mouse density */
|
|
62
|
+
@media (pointer: coarse) {
|
|
63
|
+
.action-btn { min-block-size: 2.75rem; min-inline-size: 2.75rem; }
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Verification
|
|
68
|
+
|
|
69
|
+
Test the actual primary task in each distinct layout. Check touch, mouse and keyboard where relevant; include long content/text scaling, keyboard-open state for forms, and orientation/resize mid-task. Label an emulated browser viewport (`rendered` via emulation) separately from physical touch hardware, hinge, or mobile browser-chrome evidence (`rendered` on device or `not-checked`).
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Token mapping
|
|
4
4
|
|
|
5
|
-
Import generated CSS variables in global styles and expose semantic roles through design-system components rather than copying values into decorators:
|
|
5
|
+
Import generated CSS variables in the global stylesheet configured in `angular.json` (`styles` array) or via SCSS `@use`—never legacy SCSS `@import`—and expose semantic roles through design-system components rather than copying values into component decorators:
|
|
6
6
|
|
|
7
7
|
```scss
|
|
8
|
-
|
|
8
|
+
// styles.scss
|
|
9
|
+
@use './tokens';
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
Angular component encapsulation is useful for state variants, not a substitute for global semantic token ownership.
|
|
12
|
+
(Plain CSS files can still use standard CSS `@import './tokens.css';`.) Angular component encapsulation is useful for state variants, not a substitute for global semantic token ownership.
|
|
12
13
|
|
|
13
14
|
## Layout and responsive idioms
|
|
14
15
|
|
|
15
|
-
Use route-level layouts/components plus CSS grid/flex/container queries. Angular CDK layout utilities can help but should not hide simple CSS. Standalone components
|
|
16
|
+
Use route-level layouts/components plus CSS grid/flex/container queries. Angular CDK layout utilities can help but should not hide simple CSS. Standalone components are the default in Angular 19+; avoid deep wrapper hierarchies that exist only for styling.
|
|
16
17
|
|
|
17
18
|
## Typography/custom fonts
|
|
18
19
|
|
|
@@ -20,42 +21,88 @@ Load fonts globally with preload/fallback policy. Use typographic classes/compon
|
|
|
20
21
|
|
|
21
22
|
## Motion/reduced motion
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
Do not add new dependencies on the deprecated `@angular/animations` DSL. Use native CSS transitions/animations (with `@starting-style` where supported) paired with Angular 20.2+ **`animate.enter`** and **`animate.leave`** bindings to animate mounting/unmounting nodes cleanly while letting CSS `@media (prefers-reduced-motion: no-preference)` govern motion:
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
@if (panelOpen()) {
|
|
28
|
+
<aside class="drawer" animate.enter="drawer-enter" animate.leave="drawer-leave">
|
|
29
|
+
...
|
|
30
|
+
</aside>
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Keep animations interruptible and honor `prefers-reduced-motion` in both CSS and any imperative Web Animations API calls.
|
|
24
35
|
|
|
25
36
|
## Accessibility specifics
|
|
26
37
|
|
|
27
|
-
Prefer native HTML controls or Angular CDK/Material components with correct configuration. CDK a11y tools (
|
|
38
|
+
Prefer native HTML controls or Angular CDK/Material components with correct configuration. CDK a11y tools (`FocusTrap`, `LiveAnnouncer`, `FocusKeyManager`) must be wired and tested; importing them is not evidence. Route focus/heading management is application responsibility. Reactive forms still require visible persistent labels and accessible error association.
|
|
28
39
|
|
|
29
40
|
## States idiom
|
|
30
41
|
|
|
31
|
-
Model async state explicitly with signals
|
|
42
|
+
Model async state explicitly with signals and resources: loading, refreshing, loaded-empty, loaded-partial, error, offline/stale, mutation pending, rollback. Do not unwrap async values into blank undefined states. HTTP interceptors must not swallow user-facing error context.
|
|
32
43
|
|
|
33
44
|
## Forms idiom
|
|
34
45
|
|
|
35
|
-
Reactive forms provide validation timing/control state (`touched`, `dirty`, `invalid`, async pending)
|
|
46
|
+
Reactive forms provide validation timing/control state (`touched`, `dirty`, `invalid`, async pending) while UX copy/recovery still must be designed. Use correct native input attributes (`autocomplete`, `inputmode`), preserve form model/input after submit failure, and expose a validation summary for complex flows.
|
|
47
|
+
|
|
48
|
+
## Angular 19–21 Signals, Zoneless, Resources, and Hydration idioms
|
|
49
|
+
|
|
50
|
+
- **Signals & two-way binding**: prefer `signal()`, `computed()`, `linkedSignal()` (writable derived state that resets when its source changes), `input()`, `output()`, and **`model()`** (for two-way `[(value)]` signal bindings) over manual RxJS `BehaviorSubject` boilerplate for synchronous UI state.
|
|
51
|
+
- **Async resources**: use **`httpResource()`** (reactive signal-backed `HttpClient` GET requests with `.value()`, `.isLoading()`, `.error()`, `.reload()` and automatic cancellation on param change) and **`rxResource()`** (when bridging existing RxJS streams) rather than manual `subscribe()` effects.
|
|
52
|
+
- **NgRx SignalStore (`@ngrx/signals`)**: for multi-feature shared state, prefer `signalStore(withState(...), withComputed(...), withMethods(...))` over heavy action/reducer boilerplate unless strict event-sourced DevTools auditing is required.
|
|
53
|
+
- **Control flow, `@let`, and Incremental Hydration**: use `@if`, `@for (item of items(); track item.id)`, `@switch`, template-local **`@let total = subtotal() + tax();`**, and **`@defer (on viewport; hydrate on interaction)`** (with `withIncrementalHydration()` in `provideClientHydration(...)`) so non-critical islands stay SSR HTML until needed.
|
|
54
|
+
- **Zoneless change detection**: enable `provideZonelessChangeDetection()` in `bootstrapApplication` for new apps (default in Angular 21+); never mutate plain non-signal fields and expect templates to update.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { Component, httpResource, model, signal } from '@angular/core';
|
|
58
|
+
|
|
59
|
+
@Component({
|
|
60
|
+
selector: 'app-invoice-list',
|
|
61
|
+
template: `
|
|
62
|
+
@let res = invoices;
|
|
63
|
+
@if (res.isLoading()) {
|
|
64
|
+
<p role="status" aria-busy="true">Loading invoices…</p>
|
|
65
|
+
} @else if (res.error()) {
|
|
66
|
+
<p role="alert">Could not load invoices. <button type="button" (click)="res.reload()">Retry</button></p>
|
|
67
|
+
} @else {
|
|
68
|
+
@for (inv of res.value() ?? []; track inv.id) {
|
|
69
|
+
<a [routerLink]="['/invoice', inv.id]">{{ inv.number }}</a>
|
|
70
|
+
} @empty {
|
|
71
|
+
<p>No invoices match "{{ query() }}".</p>
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`,
|
|
75
|
+
})
|
|
76
|
+
export class InvoiceListComponent {
|
|
77
|
+
readonly query = model('');
|
|
78
|
+
readonly invoices = httpResource<Invoice[]>(() => `/api/invoices?q=${encodeURIComponent(this.query())}`);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
36
81
|
|
|
37
82
|
## Do/don't pairs
|
|
38
83
|
|
|
39
84
|
| Do | Don't |
|
|
40
85
|
|---|---|
|
|
41
86
|
| `<a [routerLink]="['/invoice', id]">View invoice</a>` | `<div (click)="router.navigate(['/invoice', id])">View invoice</div>` |
|
|
42
|
-
| `
|
|
43
|
-
| semantic
|
|
44
|
-
|
|
|
45
|
-
|
|
|
87
|
+
| CSS transitions + `animate.enter` / `animate.leave` gated by `prefers-reduced-motion` | Introducing deprecated `@angular/animations` triggers in new components |
|
|
88
|
+
| `@use './tokens';` in SCSS and semantic CSS custom properties | Legacy SCSS `@import` or copying hex constants into component styles |
|
|
89
|
+
| `httpResource` / `rxResource` + `@for (...; track item.id)` + `@empty` | Manual `subscribe()` in `ngOnInit` without teardown or missing empty/error branches |
|
|
90
|
+
| `@defer (on viewport; hydrate on interaction)` for heavy secondary widgets | Eagerly hydrating every below-the-fold chart/widget on initial load |
|
|
91
|
+
| Validation after blur/submit using control state (`touched`) | Marking untouched fields red on initial render |
|
|
46
92
|
|
|
47
93
|
## Known traps
|
|
48
94
|
|
|
49
|
-
|
|
95
|
+
Mutating plain properties under zoneless change detection, introducing deprecated `@angular/animations` or Karma in new Angular 20/21 apps, subscription leaks, missing `track` keys in `@for`, focus traps that never release, enterprise fixed-density clipping, Angular Material defaults mistaken for project direction.
|
|
50
96
|
|
|
51
97
|
## Verification commands
|
|
52
98
|
|
|
99
|
+
Use the project's configured test runner (Vitest via `@angular/build:unit-test` in Angular 20/21+; check `angular.json` before assuming Karma):
|
|
100
|
+
|
|
53
101
|
```sh
|
|
54
102
|
npm run lint
|
|
55
|
-
|
|
103
|
+
npx ng test --watch=false
|
|
56
104
|
npm run build
|
|
57
105
|
npx playwright test
|
|
58
|
-
npx ng test --watch=false 2>/dev/null || true
|
|
59
106
|
```
|
|
60
107
|
|
|
61
|
-
Use browser/device inspection for actual rendering and interaction evidence.
|
|
108
|
+
Use browser/device inspection for actual rendering and interaction evidence (`rendered`); unit tests and builds are `static` or DOM-harness evidence.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# 3D asset pipeline
|
|
2
|
+
|
|
3
|
+
## Preferred delivery path
|
|
4
|
+
|
|
5
|
+
1. Author or obtain assets with clear provenance and license.
|
|
6
|
+
2. Export GLB/glTF containing only required meshes, materials, animations, and texture sets.
|
|
7
|
+
3. Strip hidden/unused nodes, duplicate materials, unused animation clips, and excess geometry.
|
|
8
|
+
4. Compress geometry with **Meshopt** (fast decode, preserves animation/morph targets cleanly) or **Draco** (smallest static meshes) via `gltf-transform`.
|
|
9
|
+
5. Transcode textures to **KTX2 / Basis Universal** (ETC1S for diffuse/albedo, UASTC for normal/ORM maps) so textures stay compressed in GPU VRAM instead of expanding into 4×–8× RGBA buffers.
|
|
10
|
+
6. Generate sensible LODs and cap texture dimensions (`1024px` mobile / `2048px` hero) before shipping.
|
|
11
|
+
7. Load lazily, cache by versioned URL, and show a poster/loading/error state until ready.
|
|
12
|
+
|
|
13
|
+
## Concrete `gltf-transform` & loader pipeline
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
# Optimize GLB: prune/dedup, resize textures <= 1024px, KTX2/WebP textures, Meshopt geometry
|
|
17
|
+
npx @gltf-transform/cli optimize raw-chair.glb chair.opt.glb \
|
|
18
|
+
--compress meshopt \
|
|
19
|
+
--texture-compress ktx2 \
|
|
20
|
+
--texture-size 1024
|
|
21
|
+
|
|
22
|
+
# Inspect geometry, draw calls, texture sizes, and extensions
|
|
23
|
+
npx @gltf-transform/cli inspect chair.opt.glb
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
// Three.js GLTFLoader wired with self-hosted Draco/KTX2/Meshopt decoders + cleanup
|
|
28
|
+
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
|
29
|
+
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
|
|
30
|
+
import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
|
|
31
|
+
import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';
|
|
32
|
+
|
|
33
|
+
export function createAssetLoader(renderer: THREE.WebGLRenderer) {
|
|
34
|
+
const draco = new DRACOLoader().setDecoderPath('/decoders/draco/');
|
|
35
|
+
const ktx2 = new KTX2Loader().setTranscoderPath('/decoders/basis/').detectSupport(renderer);
|
|
36
|
+
|
|
37
|
+
const loader = new GLTFLoader();
|
|
38
|
+
loader.setDRACOLoader(draco);
|
|
39
|
+
loader.setKTX2Loader(ktx2);
|
|
40
|
+
loader.setMeshoptDecoder(MeshoptDecoder);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
loader,
|
|
44
|
+
dispose: () => {
|
|
45
|
+
draco.dispose();
|
|
46
|
+
ktx2.dispose();
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Host `/decoders/draco/` and `/decoders/basis/` from your own static assets (rather than unpinned third-party CDNs) so CSP and offline caching remain deterministic.
|
|
53
|
+
|
|
54
|
+
## Validation
|
|
55
|
+
|
|
56
|
+
- Check visual parity after compression: normals (keep UASTC or linear encoding on normal maps), tangents, sRGB vs linear color space, alpha cutoff, animation tracks, and material roughness.
|
|
57
|
+
- Measure compressed transfer size, decode/parse time, GPU VRAM (`renderer.info.memory`), draw calls (`renderer.info.render.calls`), and time-to-interactive (`rendered`).
|
|
58
|
+
- Prefer `InstancedMesh` for repeated geometry and fetch only the active variant rather than preloading every color/model upfront.
|
|
59
|
+
|
|
60
|
+
## Useful tooling and references
|
|
61
|
+
|
|
62
|
+
- glTF 2.0 specification: https://www.khronos.org/gltf/
|
|
63
|
+
- glTF-Transform CLI & SDK: https://gltf-transform.dev/
|
|
64
|
+
- Three.js GLTFLoader: https://threejs.org/docs/#examples/en/loaders/GLTFLoader
|
|
65
|
+
- Draco: https://google.github.io/draco/
|
|
66
|
+
- Meshoptimizer: https://meshoptimizer.org/
|
|
67
|
+
- KTX-Software: https://github.com/KhronosGroup/KTX-Software
|
|
@@ -18,45 +18,96 @@ Astro's strength is content-first static rendering with selective islands. Keep
|
|
|
18
18
|
|
|
19
19
|
## Typography/custom fonts
|
|
20
20
|
|
|
21
|
-
Static rendering makes font loading visible immediately
|
|
21
|
+
Static rendering makes font loading visible immediately. Use the **Astro Fonts API** (`fonts` in `astro.config.mjs` with `fontProviders` + `<Font cssVariable="--font-display" preload />` in `<head>`) when on Astro 5.7+ for automatic self-hosting, metric-adjusted fallbacks, and subsetting; otherwise configure explicit `@font-face` + preload/fallback policy. Do not load display fonts needed only on one route globally unless reuse justifies cost.
|
|
22
22
|
|
|
23
23
|
## Motion/reduced motion
|
|
24
24
|
|
|
25
|
-
Use CSS motion for static/semantic transitions.
|
|
25
|
+
Use CSS motion for static/semantic transitions. For client-side view transitions in Astro 5, import **`<ClientRouter />`** from `'astro:transitions'` (replacing the deprecated `<ViewTransitions />`), honor `prefers-reduced-motion`, and re-initialize any non-island listeners on `astro:page-load`. In framework islands (`client:load`, `client:visible`, `client:idle`), honor `prefers-reduced-motion` and prefer `client:visible`/`client:idle` for nonessential animated islands.
|
|
26
26
|
|
|
27
27
|
## Accessibility specifics
|
|
28
28
|
|
|
29
|
-
Static HTML must be correct before hydration. Islands need real controls, labels, focus behavior, and route/navigation semantics.
|
|
29
|
+
Static HTML must be correct before hydration. Islands need real controls, labels, focus behavior, and route/navigation semantics. `<ClientRouter />` transitions must preserve focus, route announcements, and reduced-motion expectations. Do not use client directives to delay critical semantic content unnecessarily.
|
|
30
30
|
|
|
31
31
|
## States idiom
|
|
32
32
|
|
|
33
|
-
Static content has fewer runtime states by design; dynamic data
|
|
33
|
+
Static content has fewer runtime states by design; dynamic user/live data belongs in **Server Islands** (`server:defer`) or client islands. Always provide a sized `slot="fallback"` on `server:defer` components so streaming personalized regions (cart badge, user greeting, live price) do not cause CLS. Render empty/error/loading explicitly inside islands and server-island error paths.
|
|
34
34
|
|
|
35
35
|
## Forms idiom
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Use **Astro Actions** (`src/actions/index.ts`, `defineAction` + Zod validation) paired with standard HTML `<form method="POST" action={actions.subscribe}>` for progressively enhanced submissions that work without client JS, then enhance optionally on the client with `actions.subscribe(formData)` and `isInputError(error)`. Always preserve entered values on validation failure and associate errors next to fields.
|
|
38
|
+
|
|
39
|
+
## Astro 5 architecture idioms
|
|
40
|
+
|
|
41
|
+
- **Content Layer API (`src/content.config.ts`)**: define collections at `src/content.config.ts` (moved from legacy `src/content/config.ts`) using `loader: glob({ pattern: '**/*.md', base: './src/content/docs' })` or `file(...)` plus `z.object(...)` schemas. Load entries with `getCollection()` and render Markdown/MDX with standalone `render(entry)` from `'astro:content'`.
|
|
42
|
+
- **Server Islands (`server:defer`)**: keep the outer page statically cached at the CDN while deferring small dynamic `.astro` components to render on demand with a fixed-height `slot="fallback"`.
|
|
43
|
+
- **Typed environment variables (`astro:env`)**: declare public/secret schema in `astro.config.mjs` (`env.schema`) and import from `astro:env/client` or `astro:env/server` instead of raw `import.meta.env` casts.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// src/content.config.ts (Astro 5 Content Layer)
|
|
47
|
+
import { defineCollection, z } from 'astro:content';
|
|
48
|
+
import { glob } from 'astro/loaders';
|
|
49
|
+
|
|
50
|
+
const guides = defineCollection({
|
|
51
|
+
loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/guides' }),
|
|
52
|
+
schema: z.object({ title: z.string(), publishedAt: z.coerce.date(), draft: z.boolean().default(false) }),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const collections = { guides };
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
// src/actions/index.ts (Astro Actions)
|
|
60
|
+
import { defineAction } from 'astro:actions';
|
|
61
|
+
import { z } from 'astro:schema';
|
|
62
|
+
|
|
63
|
+
export const server = {
|
|
64
|
+
contact: defineAction({
|
|
65
|
+
accept: 'form',
|
|
66
|
+
input: z.object({ email: z.string().email(), message: z.string().min(10) }),
|
|
67
|
+
handler: async ({ email, message }) => ({ ok: true, email, length: message.length }),
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```astro
|
|
73
|
+
---
|
|
74
|
+
import { ClientRouter } from 'astro:transitions';
|
|
75
|
+
import { actions } from 'astro:actions';
|
|
76
|
+
import CartCount from '../components/CartCount.astro';
|
|
77
|
+
---
|
|
78
|
+
<head>
|
|
79
|
+
<ClientRouter />
|
|
80
|
+
</head>
|
|
81
|
+
<header>
|
|
82
|
+
<CartCount server:defer>
|
|
83
|
+
<span slot="fallback" class="badge-placeholder" aria-busy="true">—</span>
|
|
84
|
+
</CartCount>
|
|
85
|
+
</header>
|
|
86
|
+
<form method="POST" action={actions.contact}>...</form>
|
|
87
|
+
```
|
|
38
88
|
|
|
39
89
|
## Do/don't pairs
|
|
40
90
|
|
|
41
91
|
| Do | Don't |
|
|
42
92
|
|---|---|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
93
|
+
| Static article/navigation markup plus `<Search client:visible />` or `<CartCount server:defer>` | Hydrating the entire marketing/docs page or disabling static caching for one dynamic badge |
|
|
94
|
+
| `src/content.config.ts` with `loader: glob(...)` and `render(entry)` | Legacy `src/content/config.ts` with `type: 'content'` and `entry.render()` in Astro 5 |
|
|
95
|
+
| `<ClientRouter />` from `'astro:transitions'` | Deprecated `<ViewTransitions />` |
|
|
96
|
+
| `defineAction` + `<form method="POST" action={actions.x}>` for forms | Hand-rolled untyped `/api/*.ts` endpoints without progressive fallback |
|
|
97
|
+
| `astro:env/server` for secrets and `astro:env/client` for public config | Reading unvalidated `import.meta.env` keys across client/server boundaries |
|
|
98
|
+
| Stable `slot="fallback"` sized like the resolved island | Blank layout-shifting fallback on `server:defer` or `client:visible` |
|
|
48
99
|
|
|
49
100
|
## Known traps
|
|
50
101
|
|
|
51
|
-
|
|
102
|
+
Putting Content Layer config in legacy `src/content/config.ts`, forgetting `slot="fallback"` sizing on `server:defer` islands, attaching DOM scripts on `DOMContentLoaded` instead of `astro:page-load` when `<ClientRouter />` is active, too many `client:load` directives, duplicated framework renderers, leaking server env vars into client islands.
|
|
52
103
|
|
|
53
104
|
## Verification commands
|
|
54
105
|
|
|
55
106
|
```sh
|
|
56
|
-
|
|
107
|
+
npx astro check
|
|
57
108
|
npm run build
|
|
58
109
|
npm run test -- --run
|
|
59
110
|
npx playwright test
|
|
60
111
|
```
|
|
61
112
|
|
|
62
|
-
Inspect generated HTML as static evidence and
|
|
113
|
+
Inspect generated HTML and `astro check` as `static` evidence, and verify hydration, Server Island fallback stability, and `<ClientRouter />` focus behavior in a real browser (`rendered`).
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Audio-reactive graphics
|
|
2
|
+
|
|
3
|
+
For player UIs, waveform scrubbers (`wavesurfer.js`), game SFX (`Howler.js`), and interactive synthesis (`Tone.js`), read [media-players.md](media-players.md).
|
|
4
|
+
|
|
5
|
+
## Audio pipeline
|
|
6
|
+
|
|
7
|
+
Use Web Audio when audio analysis genuinely improves a visual interaction. Separate media playback from analysis:
|
|
8
|
+
1. Obtain a user gesture (`click` / `keydown`) before starting or resuming an `AudioContext` (`await ctx.resume()`).
|
|
9
|
+
2. Connect the media source to an `AnalyserNode` or `AudioWorklet` **and** route playback to `ctx.destination`—creating a `MediaElementAudioSourceNode` detaches the element from default speakers, so terminating at the analyser silences audio.
|
|
10
|
+
3. **Single-call `createMediaElementSource` guard**: the Web Audio spec allows calling `ctx.createMediaElementSource(el)` **only once per `HTMLMediaElement` lifetime**. Calling it again (for example during React Strict Mode double-effects or re-mounts) throws `InvalidStateError`. Cache `{ ctx, source }` in a `WeakMap<HTMLMediaElement, ...>` and reconnect/disconnect the `AnalyserNode` on remount rather than re-creating the source node.
|
|
11
|
+
4. Smooth amplitude/frequency values, map a few bands to bounded visual parameters, and pause analysis when playback stops or `document.hidden` is true.
|
|
12
|
+
5. Disconnect analyser nodes and cancel `requestAnimationFrame` on teardown (only close a cached `AudioContext` when the `<audio>`/`<video>` element itself is permanently discarded).
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
// StrictMode-safe MediaElement analysis graph (never calls createMediaElementSource twice)
|
|
16
|
+
type Graph = { ctx: AudioContext; source: MediaElementAudioSourceNode; analyser: AnalyserNode };
|
|
17
|
+
const elementGraphs = new WeakMap<HTMLMediaElement, Graph>();
|
|
18
|
+
|
|
19
|
+
export function attachAudioAnalyser(mediaEl: HTMLMediaElement): { analyser: AnalyserNode; detach: () => void } {
|
|
20
|
+
let graph = elementGraphs.get(mediaEl);
|
|
21
|
+
if (!graph) {
|
|
22
|
+
const ctx = new AudioContext();
|
|
23
|
+
const source = ctx.createMediaElementSource(mediaEl);
|
|
24
|
+
const analyser = ctx.createAnalyser();
|
|
25
|
+
analyser.fftSize = 2048;
|
|
26
|
+
analyser.smoothingTimeConstant = 0.8;
|
|
27
|
+
source.connect(analyser);
|
|
28
|
+
analyser.connect(ctx.destination); // Required so audible playback is not silenced
|
|
29
|
+
graph = { ctx, source, analyser };
|
|
30
|
+
elementGraphs.set(mediaEl, graph);
|
|
31
|
+
}
|
|
32
|
+
if (graph.ctx.state === 'suspended') void graph.ctx.resume();
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
analyser: graph.analyser,
|
|
36
|
+
detach: () => {
|
|
37
|
+
// Suspend analysis work without destroying the single-use MediaElementAudioSourceNode
|
|
38
|
+
if (graph!.ctx.state === 'running' && mediaEl.paused) void graph!.ctx.suspend();
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Do not ask for microphone permission when analysing an already playing media element. Treat microphone capture as a separate, explicit, purpose-limited permission.
|
|
45
|
+
|
|
46
|
+
## Mapping rules
|
|
47
|
+
|
|
48
|
+
- Smooth and normalize low/mid/high frequency values; avoid raw-bin jitter.
|
|
49
|
+
- Change a small number of meaningful visual properties rather than every particle independently.
|
|
50
|
+
- Clamp amplitude, hue, speed, scale, and displacement ranges.
|
|
51
|
+
- Never map audio peaks to high-contrast flashing or strobing (>3 flashes/second violates WCAG 2.3.1; see [accessibility-performance.md](accessibility-performance.md)).
|
|
52
|
+
- Support fixed seed/frozen time for visual regression tests and expose a reduced-motion / opt-out toggle.
|
|
53
|
+
|
|
54
|
+
## AudioWorklet
|
|
55
|
+
|
|
56
|
+
Use `AudioWorklet` only when custom DSP or low-latency audio processing needs a dedicated audio rendering thread. Verify browser support, module loading, sample-rate assumptions, and fallback.
|
|
57
|
+
|
|
58
|
+
Official docs:
|
|
59
|
+
- Web Audio API: https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API
|
|
60
|
+
- AnalyserNode: https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode
|
|
61
|
+
- AudioWorklet: https://developer.mozilla.org/en-US/docs/Web/API/AudioWorklet
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Auth, Passkeys (WebAuthn), OTP, and checkout UI patterns
|
|
2
|
+
|
|
3
|
+
This reference covers **frontend UI/UX engineering** for authentication and payment flows—never backend cryptography or PCI storage. Broken autofill, blocked password managers, missing passkey conditional UI, and confusing checkout error recovery are among the highest-impact conversion and accessibility failures in web products.
|
|
4
|
+
|
|
5
|
+
## Auth & billing UI integration matrix
|
|
6
|
+
|
|
7
|
+
| Category | Platforms / SDKs | Frontend UI integration rule |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| **Auth SDKs & hosted UI** | **Better Auth** (self-hosted TS, passkey/2FA/org plugins), **Clerk** (embeddable `<SignIn>`/`<UserButton>`), **Auth.js (NextAuth v5)**, **Supabase Auth** (`@supabase/ssr`) | Map semantic design tokens into hosted component appearance props (e.g., Clerk `appearance.variables`); for custom forms (Better Auth / Auth.js / Supabase), preserve input on error, enforce `autocomplete` tokens, and keep OAuth/PKCE redirect errors recoverable with a clear retry link |
|
|
10
|
+
| **Direct payment gateways** | **Stripe Payment Element**, **Stripe Embedded Checkout**, Adyen Drop-in, Braintree | Use **Stripe Embedded Checkout** (`<EmbeddedCheckoutProvider>` / `stripe.initEmbeddedCheckout`) for full turnkey hosted checkout inside your route, or **Payment Element** (`appearance.variables`) for custom checkout layouts—never render raw card `<input>`s in app code |
|
|
11
|
+
| **Merchant of Record (MoR)** | **Polar**, **Paddle** (`Paddle.Checkout.open`), **Lemon Squeezy** | Prefer MoR overlay/inline checkouts + customer portals when global VAT/GST/sales-tax compliance and invoicing are out of scope; always show clear post-checkout confirmation/polling states while webhooks settle |
|
|
12
|
+
|
|
13
|
+
## Passkeys & WebAuthn Level 3 Conditional UI
|
|
14
|
+
|
|
15
|
+
- **Feature detection**: prefer WebAuthn Level 3 **`await PublicKeyCredential.getClientCapabilities()`** (checking `caps.conditionalGet`, `caps.userVerifyingPlatformAuthenticator`, `caps.hybridTransport`) with fallback to `PublicKeyCredential.isConditionalMediationAvailable()`.
|
|
16
|
+
- **JSON parsing without manual Base64URL glue**: use **`PublicKeyCredential.parseRequestOptionsFromJSON(serverJson)`** (and `parseCreationOptionsFromJSON` for registration + `credential.toJSON()` for submission) instead of hand-rolled `Uint8Array` / Base64URL converters where supported (feature-detect or use `@simplewebauthn/browser` for older browsers).
|
|
17
|
+
- **Conditional UI (`autocomplete="username webauthn"`)**: start `navigator.credentials.get({ publicKey, mediation: 'conditional', signal: controller.signal })` on page load and always abort via `AbortController` if the user picks password/OAuth/magic link instead.
|
|
18
|
+
- **Password manager compatibility (WCAG 3.3.8 Accessible Authentication)**: never block paste (`onPaste={e => e.preventDefault()}`) on password or OTP inputs, and always use standard HTML `autocomplete` tokens (`username`, `current-password`, `new-password`, `one-time-code`).
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<label for="email">Work email</label>
|
|
22
|
+
<input id="email" name="email" type="email" autocomplete="username webauthn" required />
|
|
23
|
+
|
|
24
|
+
<label for="pw">Password</label>
|
|
25
|
+
<input id="pw" name="pw" type="password" autocomplete="current-password" required />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
const controller = new AbortController();
|
|
30
|
+
|
|
31
|
+
async function supportsConditionalPasskeys(): Promise<boolean> {
|
|
32
|
+
if (!window.PublicKeyCredential) return false;
|
|
33
|
+
if ('getClientCapabilities' in PublicKeyCredential) {
|
|
34
|
+
const caps = await PublicKeyCredential.getClientCapabilities();
|
|
35
|
+
return Boolean(caps.conditionalGet);
|
|
36
|
+
}
|
|
37
|
+
return Boolean(await PublicKeyCredential.isConditionalMediationAvailable?.());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (await supportsConditionalPasskeys()) {
|
|
41
|
+
try {
|
|
42
|
+
const publicKey = PublicKeyCredential.parseRequestOptionsFromJSON(serverChallengeJson);
|
|
43
|
+
const cred = (await navigator.credentials.get({
|
|
44
|
+
publicKey,
|
|
45
|
+
mediation: 'conditional',
|
|
46
|
+
signal: controller.signal,
|
|
47
|
+
})) as PublicKeyCredential | null;
|
|
48
|
+
if (cred) await verifyAssertion(cred.toJSON());
|
|
49
|
+
} catch (err) {
|
|
50
|
+
if ((err as Error).name !== 'AbortError') showAuthRecoveryMessage(err);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## OTP, magic links, and MFA UI
|
|
56
|
+
|
|
57
|
+
- **One-time code (`one-time-code`)**: support pasting the full 6-digit code into either a single `inputmode="numeric" autocomplete="one-time-code"` field (preferred for screen readers and mobile SMS autofill) or segmented boxes that distribute pasted characters cleanly and allow `Backspace` across boxes.
|
|
58
|
+
- **Resend & expiry**: show an explicit countdown before re-enabling "Resend code", preserve the entered email address on error, and allow editing the email without restarting the entire flow.
|
|
59
|
+
|
|
60
|
+
## Checkout, double-charge prevention & `401` session-expiry recovery
|
|
61
|
+
|
|
62
|
+
- **PCI isolation**: never mount raw `<input>` card-number fields inside your own app bundle; use Stripe Embedded Checkout / Payment Element, Polar/Paddle/Lemon Squeezy checkout, or Adyen Drop-in, passing semantic CSS custom properties into the provider's appearance config so visual craft stays coherent without touching raw PANs.
|
|
63
|
+
- **Express wallets & Payment Request**: surface Apple Pay / Google Pay / Link only when capability-detected on the current device/browser; never render broken wallet buttons on unsupported platforms.
|
|
64
|
+
- **Double-charge prevention (`Idempotency-Key` + synchronous submit lock)**: guard every payment, order creation, subscription change, or invite mutation with **both** a synchronous in-memory ref lock (`if (submittingRef.current) return; submittingRef.current = true;` before the first `await`, paired with `aria-busy="true"` / `disabled` and exact charge copy like `"Pay $49.00"`) **and** an `Idempotency-Key: <uuid>` header tied to that logical checkout attempt. Reuse the same `Idempotency-Key` across transient network retries; rotate a fresh UUID only when cart line items/amounts change or after a terminal `4xx` validation/decline error.
|
|
65
|
+
- **Decline & webhook recovery**: keep all billing/shipping fields intact if a card declines, move focus to the decline alert with actionable recovery (`"Try another card"` / `"Check postal code"`), and poll/stream webhook settlement (`"Confirming payment…"`) rather than assuming a client redirect guarantees entitlement.
|
|
66
|
+
- **`401` session-expiry draft preservation**: when an authenticated save/checkout/comment request returns `401 Unauthorized` mid-work, **never** redirect immediately and destroy unsaved user input. Snapshot dirty form/editor state (excluding raw secrets/PANs) into `IndexedDB` or `sessionStorage` keyed by route + user hint, open an inline re-auth modal (or pass a validated relative `returnTo` path), and automatically hydrate the saved draft with a confirmation banner once re-authenticated.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
// Synchronous lock + stable Idempotency-Key per checkout payload fingerprint
|
|
70
|
+
let inflight = false;
|
|
71
|
+
let attemptKey = crypto.randomUUID();
|
|
72
|
+
|
|
73
|
+
export async function submitOrder(payload: OrderPayload) {
|
|
74
|
+
if (inflight) return;
|
|
75
|
+
inflight = true;
|
|
76
|
+
try {
|
|
77
|
+
const res = await fetch('/api/orders', {
|
|
78
|
+
method: 'POST',
|
|
79
|
+
headers: { 'Content-Type': 'application/json', 'Idempotency-Key': attemptKey },
|
|
80
|
+
body: JSON.stringify(payload),
|
|
81
|
+
});
|
|
82
|
+
if (res.status === 401) {
|
|
83
|
+
sessionStorage.setItem('draft:checkout', JSON.stringify(payload));
|
|
84
|
+
window.location.assign(`/sign-in?returnTo=${encodeURIComponent(location.pathname + location.search)}`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (res.status >= 400 && res.status < 500 && res.status !== 409 && res.status !== 429) {
|
|
88
|
+
attemptKey = crypto.randomUUID(); // rotate only on non-retryable 4xx validation/decline
|
|
89
|
+
}
|
|
90
|
+
return await res.json();
|
|
91
|
+
} finally {
|
|
92
|
+
inflight = false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Do/don't pairs
|
|
98
|
+
|
|
99
|
+
| Do | Don't |
|
|
100
|
+
|---|---|
|
|
101
|
+
| Use `getClientCapabilities()` + `parseRequestOptionsFromJSON()` + `mediation: "conditional"` + `AbortController` | Force a disruptive modal WebAuthn prompt on page load or hand-roll buggy Base64URL byte loops |
|
|
102
|
+
| Allow paste and password managers on password & OTP fields (WCAG 3.3.8) | Disable paste on password/confirm-password/OTP inputs |
|
|
103
|
+
| Use Stripe Embedded Checkout / Payment Element or Polar / Paddle / Lemon Squeezy themed with semantic tokens | Collect raw credit card numbers in custom React/Vue inputs |
|
|
104
|
+
| Lock submit synchronously before `await` and send a stable `Idempotency-Key` across network retries | Rely only on async `useState` `disabled` (vulnerable to fast double-click) or generate a new UUID per retry |
|
|
105
|
+
| Snapshot dirty drafts before `401` re-auth and preserve checkout fields on card decline | Redirect on `401` and wipe 10 minutes of form/editor work or assume redirect return equals settled entitlement |
|
|
106
|
+
| Enforce server-side session & authz checks with Better Auth / Clerk / Auth.js / Supabase SSR | Trust client-only auth state or unvalidated open-redirect `returnTo` URLs |
|
|
107
|
+
|
|
108
|
+
## Verification commands
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
npm run build
|
|
112
|
+
npx playwright test
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Verify password-manager autofill attributes and `Idempotency-Key` wiring (`static`), and test virtual authenticator WebAuthn conditional UI, OTP paste, rapid double-click submit lock, `401` session-expiry draft restoration, and card-decline input preservation in a real browser (`rendered`).
|