@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,668 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
6
|
+
|
|
7
|
+
function help() {
|
|
8
|
+
return `Usage: node shoot.mjs <url-file-or-directory> [options]
|
|
9
|
+
|
|
10
|
+
Capture optional dependency-free browser visual QA evidence. Playwright is used
|
|
11
|
+
only when already installed; otherwise install guidance is printed and nothing
|
|
12
|
+
is captured.
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--out DIR Artifact directory (default: visual-qa)
|
|
16
|
+
--breakpoints LIST Width x height list (default: 390x844,768x1024,1440x900)
|
|
17
|
+
--project DIR Dependency resolution root (default: current directory)
|
|
18
|
+
--root DIR Static server root for local targets (default: the
|
|
19
|
+
file/directory itself; exposes everything beneath it)
|
|
20
|
+
--executable-path FILE Use a specific Chromium/Chrome executable
|
|
21
|
+
--timeout MS Navigation timeout in milliseconds (default: 30000)
|
|
22
|
+
--wait-for SELECTOR Wait for a selector after page load
|
|
23
|
+
--wait-ms MS Maximum post-load selector/network/font settle time
|
|
24
|
+
(default: 5000)
|
|
25
|
+
--forced-colors MODE Emulate forced-colors media feature: none or active
|
|
26
|
+
--locale TAG Emulate browser locale (e.g. de-DE, ar-EG, ja-JP)
|
|
27
|
+
--allow-http-error Capture HTTP 4xx/5xx pages without failing the run
|
|
28
|
+
--keyboard Probe the first eight real Tab stops on a safe fixture
|
|
29
|
+
(including WCAG 2.4.11 focus-not-obscured checks)
|
|
30
|
+
--light-only Skip dark-mode captures
|
|
31
|
+
--no-reduced-motion Skip reduced-motion captures
|
|
32
|
+
--help Show this help
|
|
33
|
+
|
|
34
|
+
Outputs PNG captures plus report.json. Audits are heuristic leads for human
|
|
35
|
+
inspection: overflow, clipping, low contrast, broken images, hidden essential
|
|
36
|
+
content, text occlusion, target size (<24x24 CSS px), and optional keyboard
|
|
37
|
+
focus. They are not proof of accessibility or visual quality.
|
|
38
|
+
|
|
39
|
+
Install Playwright in the target project when capture is desired, for example:
|
|
40
|
+
npm install --save-dev playwright
|
|
41
|
+
npx playwright install chromium
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function optionValue(args, index, name) {
|
|
46
|
+
const value = args[index + 1];
|
|
47
|
+
if (value === undefined || value === '') throw new Error(`${name} requires a value`);
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function inlineValue(arg, prefix, name) {
|
|
52
|
+
const value = arg.slice(prefix.length);
|
|
53
|
+
if (value === '') throw new Error(`${name} requires a value`);
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function parse(args) {
|
|
58
|
+
const options = {
|
|
59
|
+
out: 'visual-qa',
|
|
60
|
+
breakpoints: '390x844,768x1024,1440x900',
|
|
61
|
+
timeout: 30000,
|
|
62
|
+
waitFor: null,
|
|
63
|
+
waitMs: 5000,
|
|
64
|
+
allowHttpError: false,
|
|
65
|
+
project: process.cwd(),
|
|
66
|
+
root: null,
|
|
67
|
+
executablePath: null,
|
|
68
|
+
forcedColors: null,
|
|
69
|
+
locale: null,
|
|
70
|
+
lightOnly: false,
|
|
71
|
+
reducedMotion: true,
|
|
72
|
+
keyboard: false,
|
|
73
|
+
help: false,
|
|
74
|
+
};
|
|
75
|
+
const positional = [];
|
|
76
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
77
|
+
const arg = args[index];
|
|
78
|
+
if (arg === '--help' || arg === '-h') options.help = true;
|
|
79
|
+
else if (arg === '--light-only') options.lightOnly = true;
|
|
80
|
+
else if (arg === '--no-reduced-motion') options.reducedMotion = false;
|
|
81
|
+
else if (arg === '--allow-http-error') options.allowHttpError = true;
|
|
82
|
+
else if (arg === '--keyboard') options.keyboard = true;
|
|
83
|
+
else if (arg === '--out') { options.out = optionValue(args, index, '--out'); index += 1; }
|
|
84
|
+
else if (arg.startsWith('--out=')) options.out = inlineValue(arg, '--out=', '--out');
|
|
85
|
+
else if (arg === '--breakpoints') { options.breakpoints = optionValue(args, index, '--breakpoints'); index += 1; }
|
|
86
|
+
else if (arg.startsWith('--breakpoints=')) options.breakpoints = inlineValue(arg, '--breakpoints=', '--breakpoints');
|
|
87
|
+
else if (arg === '--project') { options.project = optionValue(args, index, '--project'); index += 1; }
|
|
88
|
+
else if (arg.startsWith('--project=')) options.project = inlineValue(arg, '--project=', '--project');
|
|
89
|
+
else if (arg === '--root') { options.root = optionValue(args, index, '--root'); index += 1; }
|
|
90
|
+
else if (arg.startsWith('--root=')) options.root = inlineValue(arg, '--root=', '--root');
|
|
91
|
+
else if (arg === '--executable-path') { options.executablePath = optionValue(args, index, '--executable-path'); index += 1; }
|
|
92
|
+
else if (arg.startsWith('--executable-path=')) options.executablePath = inlineValue(arg, '--executable-path=', '--executable-path');
|
|
93
|
+
else if (arg === '--forced-colors') { options.forcedColors = optionValue(args, index, '--forced-colors'); index += 1; }
|
|
94
|
+
else if (arg.startsWith('--forced-colors=')) options.forcedColors = inlineValue(arg, '--forced-colors=', '--forced-colors');
|
|
95
|
+
else if (arg === '--locale') { options.locale = optionValue(args, index, '--locale'); index += 1; }
|
|
96
|
+
else if (arg.startsWith('--locale=')) options.locale = inlineValue(arg, '--locale=', '--locale');
|
|
97
|
+
else if (arg === '--timeout') { options.timeout = Number(optionValue(args, index, '--timeout')); index += 1; }
|
|
98
|
+
else if (arg.startsWith('--timeout=')) options.timeout = Number(inlineValue(arg, '--timeout=', '--timeout'));
|
|
99
|
+
else if (arg === '--wait-for') { options.waitFor = optionValue(args, index, '--wait-for'); index += 1; }
|
|
100
|
+
else if (arg.startsWith('--wait-for=')) options.waitFor = inlineValue(arg, '--wait-for=', '--wait-for');
|
|
101
|
+
else if (arg === '--wait-ms') { options.waitMs = Number(optionValue(args, index, '--wait-ms')); index += 1; }
|
|
102
|
+
else if (arg.startsWith('--wait-ms=')) options.waitMs = Number(inlineValue(arg, '--wait-ms=', '--wait-ms'));
|
|
103
|
+
else if (arg.startsWith('-')) throw new Error(`unknown option: ${arg}`);
|
|
104
|
+
else positional.push(arg);
|
|
105
|
+
}
|
|
106
|
+
if (!Number.isFinite(options.timeout) || options.timeout <= 0) throw new Error('--timeout must be a positive number');
|
|
107
|
+
if (!Number.isFinite(options.waitMs) || options.waitMs < 0) throw new Error('--wait-ms must be a non-negative number');
|
|
108
|
+
if (options.forcedColors !== null && options.forcedColors !== 'none' && options.forcedColors !== 'active') {
|
|
109
|
+
throw new Error(`--forced-colors must be 'none' or 'active', got '${options.forcedColors}'`);
|
|
110
|
+
}
|
|
111
|
+
return { positional, options };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function parseBreakpoints(value) {
|
|
115
|
+
return value.split(',').map((part) => {
|
|
116
|
+
const match = /^(\d{3,5})x(\d{3,5})$/.exec(part.trim());
|
|
117
|
+
if (!match) throw new Error(`invalid breakpoint '${part}'; expected WIDTHxHEIGHT`);
|
|
118
|
+
return { width: Number(match[1]), height: Number(match[2]) };
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const mimeTypes = new Map(Object.entries({
|
|
123
|
+
'.html': 'text/html; charset=utf-8', '.htm': 'text/html; charset=utf-8', '.css': 'text/css; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.mjs': 'text/javascript; charset=utf-8', '.json': 'application/json; charset=utf-8', '.svg': 'image/svg+xml', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif', '.webp': 'image/webp', '.avif': 'image/avif', '.ico': 'image/x-icon', '.woff': 'font/woff', '.woff2': 'font/woff2', '.txt': 'text/plain; charset=utf-8', '.wasm': 'application/wasm',
|
|
124
|
+
}));
|
|
125
|
+
|
|
126
|
+
async function createStaticTarget(target, options) {
|
|
127
|
+
if (/^https?:\/\//i.test(target)) return { url: target, local: false, async close() {} };
|
|
128
|
+
const resolved = path.resolve(target);
|
|
129
|
+
if (!fs.existsSync(resolved)) throw new Error(`target is neither an http(s) URL nor an existing file/directory: ${target}`);
|
|
130
|
+
const stat = fs.statSync(resolved);
|
|
131
|
+
const fallbackRoot = stat.isDirectory() ? resolved : path.dirname(resolved);
|
|
132
|
+
const configuredRoot = path.resolve(options.root || fallbackRoot);
|
|
133
|
+
if (!fs.existsSync(configuredRoot) || !fs.statSync(configuredRoot).isDirectory()) throw new Error(`static server root is not a directory: ${configuredRoot}`);
|
|
134
|
+
const lexicalRoot = configuredRoot;
|
|
135
|
+
const root = fs.realpathSync(configuredRoot);
|
|
136
|
+
const rootPrefix = root.endsWith(path.sep) ? root : `${root}${path.sep}`;
|
|
137
|
+
const lexicalTarget = path.relative(lexicalRoot, resolved);
|
|
138
|
+
if (lexicalTarget.startsWith('..') || path.isAbsolute(lexicalTarget)) throw new Error(`local target is outside the static server root: target=${resolved}; root=${lexicalRoot}`);
|
|
139
|
+
const realTarget = fs.realpathSync(resolved);
|
|
140
|
+
const realRelativeTarget = path.relative(root, realTarget);
|
|
141
|
+
if (realRelativeTarget.startsWith('..') || path.isAbsolute(realRelativeTarget)) throw new Error(`local target resolves outside the static server root: target=${realTarget}; root=${root}`);
|
|
142
|
+
const encodedTarget = lexicalTarget.split(path.sep).map(encodeURIComponent).join('/');
|
|
143
|
+
let initialPath = encodedTarget ? `/${encodedTarget}` : '/';
|
|
144
|
+
if (stat.isDirectory() && !initialPath.endsWith('/')) initialPath += '/';
|
|
145
|
+
const server = http.createServer((request, response) => {
|
|
146
|
+
let pathname;
|
|
147
|
+
try {
|
|
148
|
+
pathname = decodeURIComponent(new URL(request.url, 'http://127.0.0.1').pathname);
|
|
149
|
+
} catch {
|
|
150
|
+
response.writeHead(400).end('bad request');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (pathname.endsWith('/')) pathname += 'index.html';
|
|
154
|
+
if (pathname.split('/').some((part) => part.startsWith('.'))) {
|
|
155
|
+
response.writeHead(404).end('not found');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const file = path.resolve(root, `.${pathname}`);
|
|
159
|
+
if (file !== root && !file.startsWith(`${root}${path.sep}`)) {
|
|
160
|
+
response.writeHead(403).end('forbidden');
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
let fileStat;
|
|
164
|
+
let realFile;
|
|
165
|
+
try {
|
|
166
|
+
realFile = fs.realpathSync(file);
|
|
167
|
+
fileStat = fs.statSync(realFile);
|
|
168
|
+
} catch {
|
|
169
|
+
response.writeHead(404).end('not found');
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (realFile !== root && !realFile.startsWith(rootPrefix)) {
|
|
173
|
+
response.writeHead(403).end('forbidden');
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!fileStat.isFile()) {
|
|
177
|
+
response.writeHead(404).end('not found');
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
response.writeHead(200, { 'content-type': mimeTypes.get(path.extname(file).toLowerCase()) || 'application/octet-stream', 'cache-control': 'no-store' });
|
|
181
|
+
fs.createReadStream(realFile).pipe(response);
|
|
182
|
+
});
|
|
183
|
+
await new Promise((resolve, reject) => {
|
|
184
|
+
server.once('error', reject);
|
|
185
|
+
server.listen(0, '127.0.0.1', resolve);
|
|
186
|
+
});
|
|
187
|
+
const { port } = server.address();
|
|
188
|
+
return {
|
|
189
|
+
url: `http://127.0.0.1:${port}${initialPath}`,
|
|
190
|
+
local: true,
|
|
191
|
+
close: () => new Promise((resolve) => server.close(resolve)),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const auditSource = `(auditOptions = {}) => {
|
|
196
|
+
const findings = [];
|
|
197
|
+
const vw = document.documentElement.clientWidth;
|
|
198
|
+
const add = (type, severity, message, element) => {
|
|
199
|
+
if (findings.length < 200) findings.push({ type, severity, message, element: element ? describe(element) : undefined });
|
|
200
|
+
};
|
|
201
|
+
const describe = (element) => {
|
|
202
|
+
const id = element.id ? '#' + element.id : '';
|
|
203
|
+
const cls = typeof element.className === 'string' && element.className.trim() ? '.' + element.className.trim().split(/\\s+/).slice(0, 2).join('.') : '';
|
|
204
|
+
return (element.tagName || 'element').toLowerCase() + id + cls;
|
|
205
|
+
};
|
|
206
|
+
if (document.documentElement.scrollWidth > vw + 1) add('horizontal-overflow', 'high', 'document scrollWidth exceeds viewport: ' + document.documentElement.scrollWidth + ' > ' + vw);
|
|
207
|
+
const elements = Array.from(document.querySelectorAll('body *')).slice(0, 5000);
|
|
208
|
+
const colorContext = document.createElement('canvas').getContext('2d');
|
|
209
|
+
const parseSerializedColor = (value) => {
|
|
210
|
+
const text = (value || '').trim().toLowerCase();
|
|
211
|
+
if (text === 'transparent') return { r: 0, g: 0, b: 0, a: 0 };
|
|
212
|
+
const hex = /^#([0-9a-f]{6}|[0-9a-f]{8})$/.exec(text);
|
|
213
|
+
if (hex) {
|
|
214
|
+
const digits = hex[1];
|
|
215
|
+
return { r: parseInt(digits.slice(0, 2), 16), g: parseInt(digits.slice(2, 4), 16), b: parseInt(digits.slice(4, 6), 16), a: digits.length === 8 ? parseInt(digits.slice(6, 8), 16) / 255 : 1 };
|
|
216
|
+
}
|
|
217
|
+
const rgb = /^rgba?\\(([^)]+)\\)$/.exec(text);
|
|
218
|
+
if (!rgb) return null;
|
|
219
|
+
const parts = rgb[1].split(',').map((part) => Number.parseFloat(part));
|
|
220
|
+
if (parts.length < 3 || parts.slice(0, 3).some(Number.isNaN)) return null;
|
|
221
|
+
return { r: parts[0], g: parts[1], b: parts[2], a: parts.length > 3 && !Number.isNaN(parts[3]) ? parts[3] : 1 };
|
|
222
|
+
};
|
|
223
|
+
const parseColor = (value) => {
|
|
224
|
+
if (!value) return null;
|
|
225
|
+
let serialized = null;
|
|
226
|
+
for (const sentinel of ['#010203', '#040506']) {
|
|
227
|
+
colorContext.fillStyle = sentinel;
|
|
228
|
+
const before = colorContext.fillStyle;
|
|
229
|
+
colorContext.fillStyle = value;
|
|
230
|
+
if (colorContext.fillStyle !== before) {
|
|
231
|
+
serialized = colorContext.fillStyle;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return serialized ? parseSerializedColor(serialized) : null;
|
|
236
|
+
};
|
|
237
|
+
const luminance = (color) => {
|
|
238
|
+
const convert = (channel) => {
|
|
239
|
+
const c = channel / 255;
|
|
240
|
+
return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
241
|
+
};
|
|
242
|
+
return 0.2126 * convert(color.r) + 0.7152 * convert(color.g) + 0.0722 * convert(color.b);
|
|
243
|
+
};
|
|
244
|
+
const contrast = (a, b) => {
|
|
245
|
+
const la = luminance(a), lb = luminance(b);
|
|
246
|
+
return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
|
|
247
|
+
};
|
|
248
|
+
const alphaBlend = (source, destination) => {
|
|
249
|
+
const alpha = source.a + destination.a * (1 - source.a);
|
|
250
|
+
if (alpha === 0) return { r: 0, g: 0, b: 0, a: 0 };
|
|
251
|
+
return {
|
|
252
|
+
r: (source.r * source.a + destination.r * destination.a * (1 - source.a)) / alpha,
|
|
253
|
+
g: (source.g * source.a + destination.g * destination.a * (1 - source.a)) / alpha,
|
|
254
|
+
b: (source.b * source.a + destination.b * destination.a * (1 - source.a)) / alpha,
|
|
255
|
+
a: alpha,
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
const canvasBackdrop = auditOptions.colorScheme === 'dark'
|
|
259
|
+
? { r: 18, g: 18, b: 18, a: 1 }
|
|
260
|
+
: { r: 255, g: 255, b: 255, a: 1 };
|
|
261
|
+
const effectiveContrastColors = (element, foregroundColor) => {
|
|
262
|
+
const chain = [];
|
|
263
|
+
let node = element;
|
|
264
|
+
while (node && node.nodeType === 1) {
|
|
265
|
+
chain.push(node);
|
|
266
|
+
node = node.parentElement;
|
|
267
|
+
}
|
|
268
|
+
let bg = { r: 0, g: 0, b: 0, a: 0 };
|
|
269
|
+
let fg = foregroundColor;
|
|
270
|
+
let unparsedLogged = false;
|
|
271
|
+
for (const current of chain) {
|
|
272
|
+
const nodeStyle = getComputedStyle(current);
|
|
273
|
+
const parsedBg = parseColor(nodeStyle.backgroundColor);
|
|
274
|
+
if (!parsedBg && !unparsedLogged) {
|
|
275
|
+
add('unchecked-contrast', 'medium', 'background color could not be parsed while compositing: ' + nodeStyle.backgroundColor, element);
|
|
276
|
+
unparsedLogged = true;
|
|
277
|
+
}
|
|
278
|
+
const layerBg = parsedBg || { r: 0, g: 0, b: 0, a: 0 };
|
|
279
|
+
const parsedOpacity = Number.parseFloat(nodeStyle.opacity);
|
|
280
|
+
const opacity = Number.isFinite(parsedOpacity) ? Math.max(0, Math.min(1, parsedOpacity)) : 1;
|
|
281
|
+
const innerBg = layerBg.a > 0 ? alphaBlend(bg, layerBg) : bg;
|
|
282
|
+
const innerFg = layerBg.a > 0 ? alphaBlend(fg, layerBg) : fg;
|
|
283
|
+
bg = opacity < 1 ? { ...innerBg, a: innerBg.a * opacity } : innerBg;
|
|
284
|
+
fg = opacity < 1 ? { ...innerFg, a: innerFg.a * opacity } : innerFg;
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
background: alphaBlend(bg, canvasBackdrop),
|
|
288
|
+
foreground: alphaBlend(fg, canvasBackdrop),
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
const documentBounds = {
|
|
292
|
+
right: Math.max(document.documentElement.scrollWidth, vw),
|
|
293
|
+
bottom: Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight),
|
|
294
|
+
};
|
|
295
|
+
const clippedByAncestor = (parent, rect) => {
|
|
296
|
+
let node = parent;
|
|
297
|
+
while (node && node.nodeType === 1) {
|
|
298
|
+
const nodeStyle = getComputedStyle(node);
|
|
299
|
+
if (nodeStyle.display !== 'contents') {
|
|
300
|
+
const clip = node.getBoundingClientRect();
|
|
301
|
+
const clippedHorizontally = /hidden|clip/.test(nodeStyle.overflowX) && (rect.right <= clip.left || rect.left >= clip.right);
|
|
302
|
+
const clippedVertically = /hidden|clip/.test(nodeStyle.overflowY) && (rect.bottom <= clip.top || rect.top >= clip.bottom);
|
|
303
|
+
if (clippedHorizontally || clippedVertically) return true;
|
|
304
|
+
}
|
|
305
|
+
node = node.parentElement;
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
308
|
+
};
|
|
309
|
+
const insideHorizontalScroller = (element) => {
|
|
310
|
+
let node = element.parentElement;
|
|
311
|
+
while (node && node.nodeType === 1 && node !== document.documentElement && node !== document.body) {
|
|
312
|
+
const nodeStyle = getComputedStyle(node);
|
|
313
|
+
if (/^(?:auto|scroll)$/.test(nodeStyle.overflowX)) {
|
|
314
|
+
const scrollerRect = node.getBoundingClientRect();
|
|
315
|
+
if (scrollerRect.left >= -2 && scrollerRect.right <= vw + 2) return true;
|
|
316
|
+
}
|
|
317
|
+
node = node.parentElement;
|
|
318
|
+
}
|
|
319
|
+
return false;
|
|
320
|
+
};
|
|
321
|
+
const renderedTextRects = (node) => {
|
|
322
|
+
const parent = node.parentElement;
|
|
323
|
+
if (!parent) return [];
|
|
324
|
+
if (typeof parent.checkVisibility === 'function') {
|
|
325
|
+
if (!parent.checkVisibility({ opacityProperty: true, visibilityProperty: true })) return [];
|
|
326
|
+
} else {
|
|
327
|
+
let ancestor = parent;
|
|
328
|
+
while (ancestor && ancestor.nodeType === 1) {
|
|
329
|
+
const ancestorStyle = getComputedStyle(ancestor);
|
|
330
|
+
if (ancestorStyle.display === 'none' || ancestorStyle.visibility === 'hidden' || ancestorStyle.visibility === 'collapse' || Number.parseFloat(ancestorStyle.opacity) === 0) return [];
|
|
331
|
+
ancestor = ancestor.parentElement;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const range = document.createRange();
|
|
335
|
+
range.selectNodeContents(node);
|
|
336
|
+
const rects = Array.from(range.getClientRects()).filter((rect) => rect.width > 0 && rect.height > 0);
|
|
337
|
+
if (range.detach) range.detach();
|
|
338
|
+
return rects.filter((rect) => {
|
|
339
|
+
const documentRect = { left: rect.left + window.scrollX, right: rect.right + window.scrollX, top: rect.top + window.scrollY, bottom: rect.bottom + window.scrollY };
|
|
340
|
+
const withinDocument = documentRect.right > 0 && documentRect.bottom > 0 && documentRect.left < documentBounds.right && documentRect.top < documentBounds.bottom;
|
|
341
|
+
return withinDocument && !clippedByAncestor(parent, rect);
|
|
342
|
+
});
|
|
343
|
+
};
|
|
344
|
+
const isModalBackdrop = (overlay, owner, style) => {
|
|
345
|
+
if (style.position !== 'fixed' || !overlay.parentElement) return false;
|
|
346
|
+
const bounds = overlay.getBoundingClientRect();
|
|
347
|
+
if (bounds.left > 0 || bounds.top > 0 || bounds.right < vw || bounds.bottom < innerHeight) return false;
|
|
348
|
+
return Array.from(overlay.parentElement.children).some((dialog) => {
|
|
349
|
+
if (dialog === overlay || !dialog.matches('[aria-modal="true"]') || dialog.contains(owner)
|
|
350
|
+
|| dialog.closest('[hidden], [aria-hidden="true"], [inert]')
|
|
351
|
+
|| !dialog.checkVisibility({ opacityProperty: true, visibilityProperty: true })) return false;
|
|
352
|
+
const rect = dialog.getBoundingClientRect();
|
|
353
|
+
const left = Math.max(0, rect.left), right = Math.min(vw, rect.right);
|
|
354
|
+
const top = Math.max(0, rect.top), bottom = Math.min(innerHeight, rect.bottom);
|
|
355
|
+
if (left >= right || top >= bottom) return false;
|
|
356
|
+
const stack = document.elementsFromPoint((left + right) / 2, (top + bottom) / 2);
|
|
357
|
+
const dialogIndex = stack.findIndex((hit) => dialog.contains(hit));
|
|
358
|
+
return dialogIndex !== -1 && stack.indexOf(overlay) > dialogIndex;
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
const coveringElement = (owner, rect) => {
|
|
362
|
+
if (rect.left < 0 || rect.right > vw || rect.top < 0 || rect.bottom > innerHeight
|
|
363
|
+
|| rect.width < 8 || rect.height < 8) return null;
|
|
364
|
+
const y = rect.top + rect.height / 2;
|
|
365
|
+
const hits = [0.25, 0.5, 0.75].map((frac) => document.elementFromPoint(rect.left + rect.width * frac, y));
|
|
366
|
+
const cover = hits[0];
|
|
367
|
+
if (!cover || !hits.every((hit) => hit === cover) || cover.contains(owner) || owner.contains(cover)) return null;
|
|
368
|
+
const modal = cover.closest('dialog:modal, [aria-modal="true"]');
|
|
369
|
+
if (modal && !modal.contains(owner)) return null;
|
|
370
|
+
let current = cover;
|
|
371
|
+
while (current && !current.contains(owner)) {
|
|
372
|
+
const style = getComputedStyle(current);
|
|
373
|
+
if (Number.parseFloat(style.opacity) !== 1) return null;
|
|
374
|
+
if ((parseColor(style.backgroundColor)?.a ?? 0) >= 0.99) {
|
|
375
|
+
for (let ancestor = current.parentElement; ancestor; ancestor = ancestor.parentElement) {
|
|
376
|
+
if (Number.parseFloat(getComputedStyle(ancestor).opacity) !== 1) return null;
|
|
377
|
+
}
|
|
378
|
+
return isModalBackdrop(current, owner, style) ? null : current;
|
|
379
|
+
}
|
|
380
|
+
current = current.parentElement;
|
|
381
|
+
}
|
|
382
|
+
return null;
|
|
383
|
+
};
|
|
384
|
+
const closedDisclosures = Array.from(document.querySelectorAll('details:not([open])'));
|
|
385
|
+
const inClosedPopover = (element) => {
|
|
386
|
+
try {
|
|
387
|
+
return Boolean(element.closest('[popover]:not(:popover-open)'));
|
|
388
|
+
} catch {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
const intentionallyHidden = (element) => element.closest('[hidden], [aria-hidden="true"], [inert], dialog:not([open])')
|
|
393
|
+
|| inClosedPopover(element)
|
|
394
|
+
|| closedDisclosures.some((details) =>
|
|
395
|
+
details.contains(element) && !Array.from(details.children).find((child) => child.tagName === 'SUMMARY')?.contains(element));
|
|
396
|
+
const interactiveSelector = 'button, a[href], input:not([type="hidden"]), select, textarea, summary, [role="button"], [role="link"], [role="checkbox"], [role="radio"], [role="switch"], [role="tab"], [role="menuitem"]';
|
|
397
|
+
for (const element of elements) {
|
|
398
|
+
const rect = element.getBoundingClientRect();
|
|
399
|
+
const style = getComputedStyle(element);
|
|
400
|
+
const essential = element.matches('main, h1, [data-pixelcraft-essential]');
|
|
401
|
+
if (essential && !intentionallyHidden(element)
|
|
402
|
+
&& element.checkVisibility?.({ opacityProperty: true, visibilityProperty: true }) === false
|
|
403
|
+
&& style.display !== 'contents') {
|
|
404
|
+
add('content-hidden-at-rest', 'medium', 'landmark, heading or marked essential content was not visible after settling', element);
|
|
405
|
+
}
|
|
406
|
+
if (element.tagName === 'IMG' && (element.currentSrc || element.getAttribute('src')?.trim() || element.getAttribute('srcset')?.trim())
|
|
407
|
+
&& element.complete && element.naturalWidth === 0 && !intentionallyHidden(element) && rect.width > 0 && rect.height > 0
|
|
408
|
+
&& element.checkVisibility?.({ opacityProperty: true, visibilityProperty: true }) !== false) {
|
|
409
|
+
add('broken-image', 'high', 'visible image finished loading with no intrinsic width', element);
|
|
410
|
+
}
|
|
411
|
+
if (rect.width > 2 && rect.height > 2 && style.visibility !== 'hidden' && style.display !== 'none') {
|
|
412
|
+
if ((rect.left < -2 || rect.right > vw + 2) && !insideHorizontalScroller(element)) {
|
|
413
|
+
add('outside-viewport', 'medium', 'rendered box extends outside horizontal viewport: ' + JSON.stringify({ left: Math.round(rect.left), right: Math.round(rect.right), viewport: vw }), element);
|
|
414
|
+
}
|
|
415
|
+
const clippedX = element.scrollWidth > element.clientWidth + 2 && /hidden|clip/.test(style.overflowX);
|
|
416
|
+
const clippedY = element.scrollHeight > element.clientHeight + 2 && /hidden|clip/.test(style.overflowY);
|
|
417
|
+
if ((clippedX || clippedY) && element.textContent.trim()) add('clipped-text', 'medium', 'text content may be clipped by hidden overflow', element);
|
|
418
|
+
if (element.matches(interactiveSelector) && !intentionallyHidden(element)
|
|
419
|
+
&& element.checkVisibility?.({ opacityProperty: true, visibilityProperty: true }) !== false) {
|
|
420
|
+
const inlineProseLink = element.tagName === 'A' && style.display === 'inline' && Boolean(element.closest('p, li, dd, dt, blockquote, td, th'));
|
|
421
|
+
if (!inlineProseLink && (rect.width < 24 || rect.height < 24)) {
|
|
422
|
+
add('small-touch-target', 'low', 'interactive target is ' + Math.round(rect.width) + 'x' + Math.round(rect.height) + ' CSS px (< 24x24 WCAG 2.5.8 heuristic)', element);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
const textRects = Array.from(element.childNodes).flatMap((node) => node.nodeType === 3 && node.textContent.trim() ? renderedTextRects(node) : []);
|
|
427
|
+
if (textRects.length) {
|
|
428
|
+
const cover = textRects.slice(0, 8).map((line) => coveringElement(element, line)).find(Boolean);
|
|
429
|
+
if (cover) add('text-occlusion', 'medium', 'visible text range is covered at three sample points by ' + describe(cover), element);
|
|
430
|
+
const fg = parseColor(style.color);
|
|
431
|
+
if (fg) {
|
|
432
|
+
const { foreground, background } = effectiveContrastColors(element, fg);
|
|
433
|
+
const ratio = contrast(foreground, background);
|
|
434
|
+
const size = Number.parseFloat(style.fontSize) || 16;
|
|
435
|
+
const weight = Number.parseInt(style.fontWeight, 10) || 400;
|
|
436
|
+
const large = size >= 24 || (size >= 18.66 && weight >= 700);
|
|
437
|
+
const required = large ? 3 : 4.5;
|
|
438
|
+
if (ratio + 0.05 < required) add('low-contrast-text', 'high', 'approximate contrast ' + ratio.toFixed(2) + ':1 below ' + required + ':1', element);
|
|
439
|
+
} else {
|
|
440
|
+
add('unchecked-contrast', 'medium', 'text color could not be parsed by the browser canvas normalization path: ' + style.color, element);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return { viewportWidth: vw, documentWidth: document.documentElement.scrollWidth, findings };
|
|
445
|
+
}`;
|
|
446
|
+
|
|
447
|
+
async function auditKeyboard(page) {
|
|
448
|
+
const initial = await page.evaluateHandle(() => {
|
|
449
|
+
const properties = ['outlineColor', 'outlineStyle', 'outlineWidth', 'outlineOffset', 'boxShadow',
|
|
450
|
+
'borderColor', 'borderWidth', 'backgroundColor', 'color', 'textDecorationLine', 'textDecorationColor',
|
|
451
|
+
'opacity', 'visibility', 'content', 'transform'];
|
|
452
|
+
const signature = (element) => {
|
|
453
|
+
const styles = [getComputedStyle(element), getComputedStyle(element, '::before'), getComputedStyle(element, '::after')];
|
|
454
|
+
return styles.map((style) => properties.map((key) => style[key]).join('|')).join(':');
|
|
455
|
+
};
|
|
456
|
+
const baseline = new WeakMap();
|
|
457
|
+
for (const element of document.querySelectorAll('html, body, body *')) baseline.set(element, signature(element));
|
|
458
|
+
return { baseline, signature };
|
|
459
|
+
});
|
|
460
|
+
const stops = [];
|
|
461
|
+
const findings = [];
|
|
462
|
+
try {
|
|
463
|
+
for (let index = 0; index < 8; index += 1) {
|
|
464
|
+
await page.keyboard.press('Tab');
|
|
465
|
+
const stop = await page.evaluate(({ baseline, signature }) => {
|
|
466
|
+
const element = document.activeElement;
|
|
467
|
+
if (!element || element === document.body || element === document.documentElement) return null;
|
|
468
|
+
const name = element.localName + (element.id ? '#' + element.id : '');
|
|
469
|
+
const fixedOrStickyOwner = (node) => {
|
|
470
|
+
let cur = node;
|
|
471
|
+
while (cur && cur.nodeType === 1 && cur !== document.documentElement && cur !== document.body) {
|
|
472
|
+
const st = getComputedStyle(cur);
|
|
473
|
+
if (st.position === 'fixed' || st.position === 'sticky') return cur;
|
|
474
|
+
cur = cur.parentElement;
|
|
475
|
+
}
|
|
476
|
+
return null;
|
|
477
|
+
};
|
|
478
|
+
const checkObscured = () => {
|
|
479
|
+
const rect = element.getBoundingClientRect();
|
|
480
|
+
if (rect.width <= 0 || rect.height <= 0) return null;
|
|
481
|
+
const points = [
|
|
482
|
+
[rect.left + rect.width * 0.5, rect.top + rect.height * 0.5],
|
|
483
|
+
[rect.left + Math.min(rect.width * 0.25, rect.width - 1), rect.top + Math.min(rect.height * 0.25, rect.height - 1)],
|
|
484
|
+
[rect.left + Math.max(rect.width * 0.75, 1), rect.top + Math.max(rect.height * 0.75, 1)],
|
|
485
|
+
].filter(([x, y]) => x >= 0 && x < innerWidth && y >= 0 && y < innerHeight);
|
|
486
|
+
if (!points.length) return null;
|
|
487
|
+
let overlay = null;
|
|
488
|
+
let coveredCount = 0;
|
|
489
|
+
for (const [x, y] of points) {
|
|
490
|
+
const hit = document.elementFromPoint(x, y);
|
|
491
|
+
if (!hit || hit === element || element.contains(hit) || hit.contains(element)) continue;
|
|
492
|
+
const pinned = fixedOrStickyOwner(hit);
|
|
493
|
+
if (pinned && !pinned.contains(element)) {
|
|
494
|
+
coveredCount += 1;
|
|
495
|
+
overlay = pinned;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if (!overlay || coveredCount === 0) return null;
|
|
499
|
+
const id = overlay.id ? '#' + overlay.id : '';
|
|
500
|
+
const cls = typeof overlay.className === 'string' && overlay.className.trim()
|
|
501
|
+
? '.' + overlay.className.trim().split(/\s+/).slice(0, 2).join('.')
|
|
502
|
+
: '';
|
|
503
|
+
return { by: (overlay.tagName || 'element').toLowerCase() + id + cls, fully: coveredCount === points.length };
|
|
504
|
+
};
|
|
505
|
+
const obscured = checkObscured();
|
|
506
|
+
if (!baseline.has(element) || element.shadowRoot || element.matches('iframe, :read-write')) {
|
|
507
|
+
return { element: name, indicator: 'not-checked', obscured };
|
|
508
|
+
}
|
|
509
|
+
for (let node = element; node; node = node.parentElement) {
|
|
510
|
+
if (!baseline.has(node)) return { element: name, indicator: 'not-checked', obscured };
|
|
511
|
+
if (signature(node) !== baseline.get(node)) return { element: name, indicator: 'style-change', obscured };
|
|
512
|
+
}
|
|
513
|
+
const style = getComputedStyle(element);
|
|
514
|
+
return {
|
|
515
|
+
element: name,
|
|
516
|
+
indicator: style.outlineStyle === 'none' || parseFloat(style.outlineWidth) === 0 ? 'not-detected' : 'not-checked',
|
|
517
|
+
obscured,
|
|
518
|
+
};
|
|
519
|
+
}, initial);
|
|
520
|
+
if (!stop) break;
|
|
521
|
+
stops.push({ element: stop.element, indicator: stop.indicator });
|
|
522
|
+
if (stop.indicator === 'not-detected') {
|
|
523
|
+
findings.push({
|
|
524
|
+
type: 'keyboard-focus-not-detected',
|
|
525
|
+
severity: 'medium',
|
|
526
|
+
element: stop.element,
|
|
527
|
+
message: 'Tab reached this element but no focus style change was detected; inspect the focused state manually',
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
if (stop.obscured) {
|
|
531
|
+
findings.push({
|
|
532
|
+
type: 'focus-obscured',
|
|
533
|
+
severity: stop.obscured.fully ? 'high' : 'medium',
|
|
534
|
+
element: stop.element,
|
|
535
|
+
message: `focused element is ${stop.obscured.fully ? 'fully' : 'partially'} obscured by fixed/sticky overlay ${stop.obscured.by} (WCAG 2.4.11)`,
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
} finally {
|
|
540
|
+
await initial.dispose();
|
|
541
|
+
}
|
|
542
|
+
return { stops, findings };
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function trackDataRequests(page) {
|
|
546
|
+
let pending = 0;
|
|
547
|
+
const isDataRequest = (request) => ['fetch', 'xhr'].includes(request.resourceType());
|
|
548
|
+
page.on('request', (request) => {
|
|
549
|
+
if (isDataRequest(request)) pending += 1;
|
|
550
|
+
});
|
|
551
|
+
const finish = (request) => {
|
|
552
|
+
if (isDataRequest(request) && pending > 0) pending -= 1;
|
|
553
|
+
};
|
|
554
|
+
page.on('requestfinished', finish);
|
|
555
|
+
page.on('requestfailed', finish);
|
|
556
|
+
return () => pending;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
async function settlePage(page, options, pendingRequests, allowMissingSelector = false) {
|
|
560
|
+
const deadline = Date.now() + options.waitMs;
|
|
561
|
+
const remaining = () => Math.max(0, deadline - Date.now());
|
|
562
|
+
let waitForTimedOut = false;
|
|
563
|
+
if (options.waitFor) {
|
|
564
|
+
try {
|
|
565
|
+
await page.waitForSelector(options.waitFor, { timeout: Math.max(1, remaining()) });
|
|
566
|
+
} catch (error) {
|
|
567
|
+
if (error?.name !== 'TimeoutError') throw error;
|
|
568
|
+
if (!allowMissingSelector) throw new Error(`--wait-for selector did not appear within ${options.waitMs}ms: ${options.waitFor}`);
|
|
569
|
+
waitForTimedOut = true;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
while (pendingRequests() > 0 && remaining() > 0) await page.waitForTimeout(Math.min(100, remaining()));
|
|
573
|
+
const fontBudget = Math.min(1000, remaining());
|
|
574
|
+
if (fontBudget > 0) {
|
|
575
|
+
await Promise.race([
|
|
576
|
+
page.evaluate(() => (document.fonts ? document.fonts.ready : Promise.resolve())).catch(() => {}),
|
|
577
|
+
new Promise((resolve) => setTimeout(resolve, fontBudget)),
|
|
578
|
+
]);
|
|
579
|
+
}
|
|
580
|
+
const paintSettle = Math.min(300, remaining());
|
|
581
|
+
if (paintSettle > 0) await page.waitForTimeout(paintSettle);
|
|
582
|
+
return { waitForTimedOut };
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
async function main() {
|
|
586
|
+
const { positional, options } = parse(process.argv.slice(2));
|
|
587
|
+
if (options.help) {
|
|
588
|
+
console.log(help());
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
const target = positional[0];
|
|
592
|
+
if (!target) throw new Error('missing URL or file; run with --help');
|
|
593
|
+
const breakpoints = parseBreakpoints(options.breakpoints);
|
|
594
|
+
|
|
595
|
+
let chromium;
|
|
596
|
+
try {
|
|
597
|
+
const projectRequire = createRequire(path.join(path.resolve(options.project), 'pixelcraft-shoot-require.cjs'));
|
|
598
|
+
({ chromium } = projectRequire('playwright'));
|
|
599
|
+
} catch {
|
|
600
|
+
try {
|
|
601
|
+
({ chromium } = await import('playwright'));
|
|
602
|
+
} catch {
|
|
603
|
+
console.error('Playwright is not installed in this dependency context. Install it explicitly in the target project, for example: npm install --save-dev playwright && npx playwright install chromium');
|
|
604
|
+
process.exitCode = 2;
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const out = path.resolve(options.out);
|
|
610
|
+
fs.mkdirSync(out, { recursive: true });
|
|
611
|
+
const browser = await chromium.launch({ headless: true, ...(options.executablePath ? { executablePath: options.executablePath } : {}) });
|
|
612
|
+
const staticTarget = await createStaticTarget(target, options);
|
|
613
|
+
const report = {
|
|
614
|
+
target,
|
|
615
|
+
generatedAt: new Date().toISOString(),
|
|
616
|
+
captures: [],
|
|
617
|
+
heuristic: true,
|
|
618
|
+
...(options.forcedColors ? { forcedColors: options.forcedColors } : {}),
|
|
619
|
+
...(options.locale ? { locale: options.locale } : {}),
|
|
620
|
+
};
|
|
621
|
+
let sawHttpError = false;
|
|
622
|
+
try {
|
|
623
|
+
for (const viewport of breakpoints) {
|
|
624
|
+
for (const colorScheme of options.lightOnly ? ['light'] : ['light', 'dark']) {
|
|
625
|
+
for (const reducedMotion of options.reducedMotion ? ['no-preference', 'reduce'] : ['no-preference']) {
|
|
626
|
+
const page = await browser.newPage({
|
|
627
|
+
viewport,
|
|
628
|
+
colorScheme,
|
|
629
|
+
reducedMotion,
|
|
630
|
+
...(options.forcedColors ? { forcedColors: options.forcedColors } : {}),
|
|
631
|
+
...(options.locale ? { locale: options.locale } : {}),
|
|
632
|
+
});
|
|
633
|
+
const pendingRequests = trackDataRequests(page);
|
|
634
|
+
const response = await page.goto(staticTarget.url, { waitUntil: 'load', timeout: options.timeout });
|
|
635
|
+
const status = response ? response.status() : null;
|
|
636
|
+
if (status !== null && status >= 400) sawHttpError = true;
|
|
637
|
+
const settle = await settlePage(page, options, pendingRequests, status !== null && status >= 400);
|
|
638
|
+
const name = `${viewport.width}x${viewport.height}-${colorScheme}-${reducedMotion === 'reduce' ? 'reduced-motion' : 'motion'}.png`;
|
|
639
|
+
const file = path.join(out, name);
|
|
640
|
+
await page.screenshot({ path: file, fullPage: true });
|
|
641
|
+
const audit = await page.evaluate(`(${auditSource})(${JSON.stringify({ colorScheme })})`);
|
|
642
|
+
if (options.keyboard) {
|
|
643
|
+
const keyboard = await auditKeyboard(page);
|
|
644
|
+
audit.keyboard = keyboard.stops;
|
|
645
|
+
audit.findings.push(...keyboard.findings);
|
|
646
|
+
}
|
|
647
|
+
report.captures.push({ file: name, viewport, colorScheme, reducedMotion: reducedMotion === 'reduce', status, ...(settle.waitForTimedOut ? { waitFor: options.waitFor, waitForTimedOut: true } : {}), ...audit });
|
|
648
|
+
console.log(`captured: ${name}; findings=${audit.findings.length}`);
|
|
649
|
+
await page.close();
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
} finally {
|
|
654
|
+
await browser.close();
|
|
655
|
+
await staticTarget.close();
|
|
656
|
+
}
|
|
657
|
+
fs.writeFileSync(path.join(out, 'report.json'), `${JSON.stringify(report, null, 2)}\n`);
|
|
658
|
+
console.log(`report: ${path.join(out, 'report.json')}`);
|
|
659
|
+
if (sawHttpError && !options.allowHttpError) {
|
|
660
|
+
console.error('capture target returned HTTP 4xx/5xx; use --allow-http-error only when intentionally capturing error-page designs');
|
|
661
|
+
process.exitCode = 1;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
main().catch((error) => {
|
|
666
|
+
console.error(`shoot: ${error.message}`);
|
|
667
|
+
process.exit(1);
|
|
668
|
+
});
|