@luci-dev/skills 0.0.0-stage → 0.5.1
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/dist/benchmark.d.ts +48 -0
- package/dist/benchmark.d.ts.map +1 -0
- package/dist/benchmark.js +84 -0
- package/dist/benchmark.js.map +1 -0
- package/dist/discovery.d.ts +105 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +271 -0
- package/dist/discovery.js.map +1 -0
- package/dist/drafts.d.ts +20 -0
- package/dist/drafts.d.ts.map +1 -0
- package/dist/drafts.js +57 -0
- package/dist/drafts.js.map +1 -0
- package/dist/github.d.ts +49 -0
- package/dist/github.d.ts.map +1 -0
- package/dist/github.js +93 -0
- package/dist/github.js.map +1 -0
- package/dist/import.d.ts +80 -0
- package/dist/import.d.ts.map +1 -0
- package/dist/import.js +286 -0
- package/dist/import.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/licenses.d.ts +30 -0
- package/dist/licenses.d.ts.map +1 -0
- package/dist/licenses.js +116 -0
- package/dist/licenses.js.map +1 -0
- package/dist/linter.d.ts +35 -0
- package/dist/linter.d.ts.map +1 -0
- package/dist/linter.js +262 -0
- package/dist/linter.js.map +1 -0
- package/dist/lss.d.ts +74 -0
- package/dist/lss.d.ts.map +1 -0
- package/dist/lss.js +273 -0
- package/dist/lss.js.map +1 -0
- package/dist/orchestrator.d.ts +164 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +370 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/packs.d.ts +50 -0
- package/dist/packs.d.ts.map +1 -0
- package/dist/packs.js +166 -0
- package/dist/packs.js.map +1 -0
- package/dist/preferences.d.ts +18 -0
- package/dist/preferences.d.ts.map +1 -0
- package/dist/preferences.js +57 -0
- package/dist/preferences.js.map +1 -0
- package/dist/project.d.ts +45 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +183 -0
- package/dist/project.js.map +1 -0
- package/dist/rankability.d.ts +51 -0
- package/dist/rankability.d.ts.map +1 -0
- package/dist/rankability.js +217 -0
- package/dist/rankability.js.map +1 -0
- package/dist/registry.d.ts +82 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +300 -0
- package/dist/registry.js.map +1 -0
- package/dist/trust.d.ts +13 -0
- package/dist/trust.d.ts.map +1 -0
- package/dist/trust.js +41 -0
- package/dist/trust.js.map +1 -0
- package/dist/types.d.ts +44 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/library/3d/threejs/LICENSE.txt +21 -0
- package/library/3d/threejs/NOTICE.md +7 -0
- package/library/3d/threejs/SKILL.md +102 -0
- package/library/3d/threejs/luci.json +39 -0
- package/library/accessibility/accessibility-baseline/SKILL.md +51 -0
- package/library/accessibility/accessibility-baseline/luci.json +33 -0
- package/library/accessibility/fixing-accessibility/NOTICE.md +6 -0
- package/library/accessibility/fixing-accessibility/SKILL.md +141 -0
- package/library/accessibility/fixing-accessibility/luci.json +36 -0
- package/library/animation-motion/animation-systems/LICENSE.txt +21 -0
- package/library/animation-motion/animation-systems/NOTICE.md +7 -0
- package/library/animation-motion/animation-systems/SKILL.md +192 -0
- package/library/animation-motion/animation-systems/luci.json +32 -0
- package/library/animation-motion/animejs/SKILL.md +64 -0
- package/library/animation-motion/animejs/luci.json +12 -0
- package/library/animation-motion/motion-dev/SKILL.md +69 -0
- package/library/animation-motion/motion-dev/luci.json +13 -0
- package/library/animation-motion/react-view-transitions/AGENTS.md +1380 -0
- package/library/animation-motion/react-view-transitions/NOTICE.md +6 -0
- package/library/animation-motion/react-view-transitions/README.md +44 -0
- package/library/animation-motion/react-view-transitions/SKILL.md +334 -0
- package/library/animation-motion/react-view-transitions/luci.json +40 -0
- package/library/animation-motion/react-view-transitions/metadata.json +12 -0
- package/library/animation-motion/react-view-transitions/references/css-recipes.md +312 -0
- package/library/animation-motion/react-view-transitions/references/implementation.md +170 -0
- package/library/animation-motion/react-view-transitions/references/nextjs.md +233 -0
- package/library/animation-motion/react-view-transitions/references/patterns.md +274 -0
- package/library/animation-motion/react-view-transitions/references/troubleshooting.md +47 -0
- package/library/code-quality/code-review/NOTICE.md +6 -0
- package/library/code-quality/code-review/SKILL.md +94 -0
- package/library/code-quality/code-review/agents/openai.yaml +3 -0
- package/library/code-quality/code-review/luci.json +33 -0
- package/library/components/company-logos/LICENSE.txt +21 -0
- package/library/components/company-logos/NOTICE.md +7 -0
- package/library/components/company-logos/SKILL.md +27 -0
- package/library/components/company-logos/luci.json +38 -0
- package/library/components/container-lines/LICENSE.txt +21 -0
- package/library/components/container-lines/NOTICE.md +7 -0
- package/library/components/container-lines/SKILL.md +124 -0
- package/library/components/container-lines/luci.json +48 -0
- package/library/design-systems/build-design-system/NOTICE.md +6 -0
- package/library/design-systems/build-design-system/SKILL.md +78 -0
- package/library/design-systems/build-design-system/luci.json +29 -0
- package/library/design-systems/build-design-system/references/components.md +46 -0
- package/library/design-systems/build-design-system/references/glossary.md +77 -0
- package/library/design-systems/build-design-system/references/taste.md +37 -0
- package/library/design-systems/build-design-system/references/tokens.md +59 -0
- package/library/design-systems/build-design-system/references/traps.md +128 -0
- package/library/design-systems/build-design-system/scripts/capture-guard.mjs +470 -0
- package/library/design-systems/build-design-system/scripts/capture.mjs +355 -0
- package/library/design-systems/build-design-system/scripts/check-system.mjs +1883 -0
- package/library/design-systems/build-design-system/scripts/find-chromium.mjs +137 -0
- package/library/design-systems/build-design-system/scripts/oklch.mjs +221 -0
- package/library/design-systems/build-design-system/scripts/pixdiff.mjs +186 -0
- package/library/design-systems/component-docs/NOTICE.md +6 -0
- package/library/design-systems/component-docs/SKILL.md +50 -0
- package/library/design-systems/component-docs/luci.json +30 -0
- package/library/design-systems/component-docs/references/doc-format.md +85 -0
- package/library/design-systems/create-design-md/NOTICE.md +6 -0
- package/library/design-systems/create-design-md/SKILL.md +259 -0
- package/library/design-systems/create-design-md/luci.json +38 -0
- package/library/design-systems/design-system-boss/NOTICE.md +6 -0
- package/library/design-systems/design-system-boss/SKILL.md +58 -0
- package/library/design-systems/design-system-boss/luci.json +29 -0
- package/library/design-systems/design-system-boss/playbooks/build.md +10 -0
- package/library/design-systems/design-system-boss/playbooks/component.md +9 -0
- package/library/design-systems/design-system-boss/playbooks/migrate.md +11 -0
- package/library/design-systems/design-system-boss/playbooks/review.md +9 -0
- package/library/design-systems/migrate-design-system/NOTICE.md +6 -0
- package/library/design-systems/migrate-design-system/SKILL.md +62 -0
- package/library/design-systems/migrate-design-system/luci.json +33 -0
- package/library/design-systems/migrate-design-system/references/correct.md +37 -0
- package/library/design-systems/migrate-design-system/references/lessons.md +69 -0
- package/library/design-systems/migrate-design-system/references/parity.md +44 -0
- package/library/design-systems/migrate-design-system/references/running-many-agents.md +52 -0
- package/library/design-systems/migrate-design-system/scripts/bodies-check.mjs +215 -0
- package/library/design-systems/migrate-design-system/scripts/land.mjs +433 -0
- package/library/design-systems/migrate-design-system/scripts/legacy.mjs +283 -0
- package/library/design-systems/migrate-design-system/scripts/parity.mjs +173 -0
- package/library/design-systems/token-mapping/NOTICE.md +6 -0
- package/library/design-systems/token-mapping/SKILL.md +46 -0
- package/library/design-systems/token-mapping/luci.json +25 -0
- package/library/design-systems/token-mapping/references/mapping-rules.md +54 -0
- package/library/design-systems/ui-review/NOTICE.md +6 -0
- package/library/design-systems/ui-review/SKILL.md +53 -0
- package/library/design-systems/ui-review/luci.json +29 -0
- package/library/design-systems/ui-review/references/criteria.md +49 -0
- package/library/frontend/composition-patterns/AGENTS.md +946 -0
- package/library/frontend/composition-patterns/NOTICE.md +6 -0
- package/library/frontend/composition-patterns/README.md +60 -0
- package/library/frontend/composition-patterns/SKILL.md +86 -0
- package/library/frontend/composition-patterns/luci.json +33 -0
- package/library/frontend/composition-patterns/metadata.json +11 -0
- package/library/frontend/composition-patterns/rules/_sections.md +29 -0
- package/library/frontend/composition-patterns/rules/_template.md +24 -0
- package/library/frontend/composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
- package/library/frontend/composition-patterns/rules/architecture-compound-components.md +112 -0
- package/library/frontend/composition-patterns/rules/patterns-children-over-render-props.md +87 -0
- package/library/frontend/composition-patterns/rules/patterns-explicit-variants.md +100 -0
- package/library/frontend/composition-patterns/rules/react19-no-forwardref.md +42 -0
- package/library/frontend/composition-patterns/rules/state-context-interface.md +191 -0
- package/library/frontend/composition-patterns/rules/state-decouple-implementation.md +113 -0
- package/library/frontend/composition-patterns/rules/state-lift-state.md +125 -0
- package/library/frontend/design-mobile-apps/NOTICE.md +6 -0
- package/library/frontend/design-mobile-apps/SKILL.md +121 -0
- package/library/frontend/design-mobile-apps/designing.md +56 -0
- package/library/frontend/design-mobile-apps/endpoints.md +362 -0
- package/library/frontend/design-mobile-apps/implementing.md +213 -0
- package/library/frontend/design-mobile-apps/luci.json +31 -0
- package/library/frontend/design-mobile-apps/styling/nativewind.md +57 -0
- package/library/frontend/design-mobile-apps/styling/stylesheet.md +28 -0
- package/library/frontend/design-mobile-apps/styling/uniwind.md +38 -0
- package/library/frontend/frontend-design/LICENSE.txt +202 -0
- package/library/frontend/frontend-design/NOTICE.md +6 -0
- package/library/frontend/frontend-design/SKILL.md +81 -0
- package/library/frontend/frontend-design/luci.json +43 -0
- package/library/frontend/react-native-skills/AGENTS.md +2897 -0
- package/library/frontend/react-native-skills/NOTICE.md +6 -0
- package/library/frontend/react-native-skills/README.md +165 -0
- package/library/frontend/react-native-skills/SKILL.md +119 -0
- package/library/frontend/react-native-skills/luci.json +33 -0
- package/library/frontend/react-native-skills/metadata.json +16 -0
- package/library/frontend/react-native-skills/rules/_sections.md +86 -0
- package/library/frontend/react-native-skills/rules/_template.md +28 -0
- package/library/frontend/react-native-skills/rules/animation-derived-value.md +53 -0
- package/library/frontend/react-native-skills/rules/animation-gesture-detector-press.md +95 -0
- package/library/frontend/react-native-skills/rules/animation-gpu-properties.md +65 -0
- package/library/frontend/react-native-skills/rules/design-system-compound-components.md +66 -0
- package/library/frontend/react-native-skills/rules/fonts-config-plugin.md +71 -0
- package/library/frontend/react-native-skills/rules/imports-design-system-folder.md +68 -0
- package/library/frontend/react-native-skills/rules/js-hoist-intl.md +61 -0
- package/library/frontend/react-native-skills/rules/list-performance-callbacks.md +44 -0
- package/library/frontend/react-native-skills/rules/list-performance-function-references.md +132 -0
- package/library/frontend/react-native-skills/rules/list-performance-images.md +53 -0
- package/library/frontend/react-native-skills/rules/list-performance-inline-objects.md +97 -0
- package/library/frontend/react-native-skills/rules/list-performance-item-expensive.md +94 -0
- package/library/frontend/react-native-skills/rules/list-performance-item-memo.md +82 -0
- package/library/frontend/react-native-skills/rules/list-performance-item-types.md +104 -0
- package/library/frontend/react-native-skills/rules/list-performance-virtualize.md +67 -0
- package/library/frontend/react-native-skills/rules/monorepo-native-deps-in-app.md +46 -0
- package/library/frontend/react-native-skills/rules/monorepo-single-dependency-versions.md +63 -0
- package/library/frontend/react-native-skills/rules/navigation-native-navigators.md +188 -0
- package/library/frontend/react-native-skills/rules/react-compiler-destructure-functions.md +50 -0
- package/library/frontend/react-native-skills/rules/react-compiler-reanimated-shared-values.md +48 -0
- package/library/frontend/react-native-skills/rules/react-state-dispatcher.md +91 -0
- package/library/frontend/react-native-skills/rules/react-state-fallback.md +56 -0
- package/library/frontend/react-native-skills/rules/react-state-minimize.md +65 -0
- package/library/frontend/react-native-skills/rules/rendering-no-falsy-and.md +74 -0
- package/library/frontend/react-native-skills/rules/rendering-text-in-text-component.md +36 -0
- package/library/frontend/react-native-skills/rules/scroll-position-no-state.md +82 -0
- package/library/frontend/react-native-skills/rules/state-ground-truth.md +80 -0
- package/library/frontend/react-native-skills/rules/ui-expo-image.md +66 -0
- package/library/frontend/react-native-skills/rules/ui-image-gallery.md +104 -0
- package/library/frontend/react-native-skills/rules/ui-measure-views.md +78 -0
- package/library/frontend/react-native-skills/rules/ui-menus.md +174 -0
- package/library/frontend/react-native-skills/rules/ui-native-modals.md +77 -0
- package/library/frontend/react-native-skills/rules/ui-pressable.md +61 -0
- package/library/frontend/react-native-skills/rules/ui-safe-area-scroll.md +65 -0
- package/library/frontend/react-native-skills/rules/ui-scrollview-content-inset.md +45 -0
- package/library/frontend/react-native-skills/rules/ui-styling.md +87 -0
- package/library/frontend/tailwindcss/LICENSE.txt +21 -0
- package/library/frontend/tailwindcss/NOTICE.md +7 -0
- package/library/frontend/tailwindcss/SKILL.md +83 -0
- package/library/frontend/tailwindcss/luci.json +39 -0
- package/library/frontend-frameworks/react-best-practices/NOTICE.md +6 -0
- package/library/frontend-frameworks/react-best-practices/SKILL.md +151 -0
- package/library/frontend-frameworks/react-best-practices/luci.json +39 -0
- package/library/general/algorithmic-art/LICENSE.txt +202 -0
- package/library/general/algorithmic-art/NOTICE.md +6 -0
- package/library/general/algorithmic-art/SKILL.md +409 -0
- package/library/general/algorithmic-art/luci.json +27 -0
- package/library/general/algorithmic-art/templates/generator_template.js +223 -0
- package/library/general/algorithmic-art/templates/viewer.html +599 -0
- package/library/general/canvas-design/LICENSE.txt +202 -0
- package/library/general/canvas-design/NOTICE.md +6 -0
- package/library/general/canvas-design/SKILL.md +134 -0
- package/library/general/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/BigShoulders-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/Boldonse-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/DMMono-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/EricaOne-OFL.txt +94 -0
- package/library/general/canvas-design/canvas-fonts/GeistMono-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/Gloock-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/Italiana-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/Jura-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/Lora-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/NationalPark-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/Outfit-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/PixelifySans-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/PoiretOne-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/RedHatMono-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/Silkscreen-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/SmoochSans-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/Tektur-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/WorkSans-OFL.txt +93 -0
- package/library/general/canvas-design/canvas-fonts/YoungSerif-OFL.txt +93 -0
- package/library/general/canvas-design/luci.json +29 -0
- package/library/index.json +2507 -0
- package/library/interaction/animation-on-scroll/LICENSE.txt +21 -0
- package/library/interaction/animation-on-scroll/NOTICE.md +7 -0
- package/library/interaction/animation-on-scroll/SKILL.md +115 -0
- package/library/interaction/animation-on-scroll/luci.json +38 -0
- package/library/micro-interactions/masked-reveal/LICENSE.txt +21 -0
- package/library/micro-interactions/masked-reveal/NOTICE.md +7 -0
- package/library/micro-interactions/masked-reveal/SKILL.md +187 -0
- package/library/micro-interactions/masked-reveal/luci.json +63 -0
- package/library/micro-interactions/micro-interaction/NOTICE.md +6 -0
- package/library/micro-interactions/micro-interaction/SKILL.md +177 -0
- package/library/micro-interactions/micro-interaction/luci.json +52 -0
- package/library/micro-interactions/micro-interaction/references/css-recipes.md +142 -0
- package/library/micro-interactions/micro-interaction/references/framer-motion-recipes.md +187 -0
- package/library/micro-interactions/micro-interaction/scripts/README.md +42 -0
- package/library/micro-interactions/micro-interaction/scripts/contact-sheet.sh +17 -0
- package/library/micro-interactions/micro-interaction/scripts/seek-shot.sh +21 -0
- package/library/performance/fixing-motion-performance/NOTICE.md +6 -0
- package/library/performance/fixing-motion-performance/SKILL.md +156 -0
- package/library/performance/fixing-motion-performance/luci.json +30 -0
- package/library/seo/fixing-metadata/NOTICE.md +6 -0
- package/library/seo/fixing-metadata/SKILL.md +111 -0
- package/library/seo/fixing-metadata/luci.json +36 -0
- package/library/shadcn-ui/migrate-radix-to-base/NOTICE.md +6 -0
- package/library/shadcn-ui/migrate-radix-to-base/SKILL.md +178 -0
- package/library/shadcn-ui/migrate-radix-to-base/class-mapping.md +62 -0
- package/library/shadcn-ui/migrate-radix-to-base/consumer-props.md +58 -0
- package/library/shadcn-ui/migrate-radix-to-base/disclosure.md +353 -0
- package/library/shadcn-ui/migrate-radix-to-base/display-misc.md +410 -0
- package/library/shadcn-ui/migrate-radix-to-base/form-controls.md +390 -0
- package/library/shadcn-ui/migrate-radix-to-base/luci.json +33 -0
- package/library/shadcn-ui/migrate-radix-to-base/menus.md +409 -0
- package/library/shadcn-ui/migrate-radix-to-base/overlays.md +459 -0
- package/library/shadcn-ui/migrate-radix-to-base/universal-patterns.md +286 -0
- package/library/shadcn-ui/migrate-radix-to-base/wrapper-shapes.md +110 -0
- package/library/shadcn-ui/shadcn/NOTICE.md +6 -0
- package/library/shadcn-ui/shadcn/SKILL.md +187 -0
- package/library/shadcn-ui/shadcn/agents/openai.yml +5 -0
- package/library/shadcn-ui/shadcn/assets/shadcn-small.png +0 -0
- package/library/shadcn-ui/shadcn/assets/shadcn.png +0 -0
- package/library/shadcn-ui/shadcn/assets/showcase/color-pair.tsx +126 -0
- package/library/shadcn-ui/shadcn/assets/showcase/preview-states.css +14 -0
- package/library/shadcn-ui/shadcn/assets/showcase/state-matrix.tsx +72 -0
- package/library/shadcn-ui/shadcn/cli.md +290 -0
- package/library/shadcn-ui/shadcn/customization.md +211 -0
- package/library/shadcn-ui/shadcn/design-system-page.md +268 -0
- package/library/shadcn-ui/shadcn/design-system.md +386 -0
- package/library/shadcn-ui/shadcn/evals/evals.json +126 -0
- package/library/shadcn-ui/shadcn/luci.json +34 -0
- package/library/shadcn-ui/shadcn/mcp.md +105 -0
- package/library/shadcn-ui/shadcn/references/updating-components.md +91 -0
- package/library/shadcn-ui/shadcn/references/workflow.md +31 -0
- package/library/shadcn-ui/shadcn/registry.md +277 -0
- package/library/shadcn-ui/shadcn/rules/base-vs-radix.md +306 -0
- package/library/shadcn-ui/shadcn/rules/chat.md +507 -0
- package/library/shadcn-ui/shadcn/rules/composition.md +213 -0
- package/library/shadcn-ui/shadcn/rules/forms.md +192 -0
- package/library/shadcn-ui/shadcn/rules/icons.md +101 -0
- package/library/shadcn-ui/shadcn/rules/styling.md +185 -0
- package/library/shadcn-ui/shadcn/scripts/showcase-coverage.mjs +53 -0
- package/library/systems/baseline-ui/NOTICE.md +6 -0
- package/library/systems/baseline-ui/SKILL.md +90 -0
- package/library/systems/baseline-ui/luci.json +35 -0
- package/library/testing/tdd/NOTICE.md +6 -0
- package/library/testing/tdd/SKILL.md +43 -0
- package/library/testing/tdd/agents/openai.yaml +3 -0
- package/library/testing/tdd/luci.json +29 -0
- package/library/testing/tdd/mocking.md +59 -0
- package/library/testing/tdd/tests.md +77 -0
- package/library/testing/webapp-testing/LICENSE.txt +202 -0
- package/library/testing/webapp-testing/NOTICE.md +6 -0
- package/library/testing/webapp-testing/SKILL.md +100 -0
- package/library/testing/webapp-testing/examples/console_logging.py +35 -0
- package/library/testing/webapp-testing/examples/element_discovery.py +40 -0
- package/library/testing/webapp-testing/examples/static_html_automation.py +33 -0
- package/library/testing/webapp-testing/luci.json +33 -0
- package/library/testing/webapp-testing/scripts/with_server.py +106 -0
- package/library/ui-ux/improve-ui/NOTICE.md +6 -0
- package/library/ui-ux/improve-ui/SKILL.md +127 -0
- package/library/ui-ux/improve-ui/agents/openai.yaml +13 -0
- package/library/ui-ux/improve-ui/luci.json +47 -0
- package/library/ui-ux/improve-ui/references/plan-template.md +55 -0
- package/library/ui-ux/landing-page/LICENSE.txt +21 -0
- package/library/ui-ux/landing-page/NOTICE.md +7 -0
- package/library/ui-ux/landing-page/SKILL.md +213 -0
- package/library/ui-ux/landing-page/luci.json +47 -0
- package/library/ui-ux/pricing-page/LICENSE.txt +21 -0
- package/library/ui-ux/pricing-page/NOTICE.md +7 -0
- package/library/ui-ux/pricing-page/SKILL.md +217 -0
- package/library/ui-ux/pricing-page/luci.json +47 -0
- package/library/ui-ux/prototype/LOGIC.md +67 -0
- package/library/ui-ux/prototype/NOTICE.md +6 -0
- package/library/ui-ux/prototype/SKILL.md +31 -0
- package/library/ui-ux/prototype/UI.md +112 -0
- package/library/ui-ux/prototype/agents/openai.yaml +3 -0
- package/library/ui-ux/prototype/luci.json +33 -0
- package/library/ui-ux/theme-factory/LICENSE.txt +202 -0
- package/library/ui-ux/theme-factory/NOTICE.md +6 -0
- package/library/ui-ux/theme-factory/SKILL.md +62 -0
- package/library/ui-ux/theme-factory/luci.json +35 -0
- package/library/ui-ux/theme-factory/themes/arctic-frost.md +19 -0
- package/library/ui-ux/theme-factory/themes/botanical-garden.md +19 -0
- package/library/ui-ux/theme-factory/themes/desert-rose.md +19 -0
- package/library/ui-ux/theme-factory/themes/forest-canopy.md +19 -0
- package/library/ui-ux/theme-factory/themes/golden-hour.md +19 -0
- package/library/ui-ux/theme-factory/themes/midnight-galaxy.md +19 -0
- package/library/ui-ux/theme-factory/themes/modern-minimalist.md +19 -0
- package/library/ui-ux/theme-factory/themes/ocean-depths.md +19 -0
- package/library/ui-ux/theme-factory/themes/sunset-boulevard.md +19 -0
- package/library/ui-ux/theme-factory/themes/tech-innovation.md +19 -0
- package/package.json +21 -3
- package/packs/design-system-build.json +10 -0
- package/packs/design-system.json +16 -0
- package/packs/marketing.json +11 -0
- package/packs/motion.json +12 -0
- package/packs/ui.json +13 -0
- package/README.md +0 -3
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// find-chromium.mjs: find Playwright and a Chromium it can launch. Used by capture.mjs and pixdiff.mjs.
|
|
2
|
+
// Node 18+, no dependencies of its own.
|
|
3
|
+
//
|
|
4
|
+
// node find-chromium.mjs [--root <dir>] [--self-test] prints where Playwright and the browser come from. Exit 0, or 2 on none
|
|
5
|
+
//
|
|
6
|
+
// The root is --root, else the git root of the script's first path argument, else of the current folder, else the
|
|
7
|
+
// current folder (repoRoot below). Playwright (`playwright` or `playwright-core`) is looked for in that root and its
|
|
8
|
+
// parents first, then the current folder and its parents, the repo root of this script, then the global install
|
|
9
|
+
// (`npm root -g`). So a command run from outside the app still finds the app's own Playwright.
|
|
10
|
+
//
|
|
11
|
+
// The browser is tried in this order, and the first that launches wins:
|
|
12
|
+
// 1. PW_CHROMIUM, when set: a path to any Chrome or Chromium executable
|
|
13
|
+
// 2. Playwright's own download for its version
|
|
14
|
+
// 3. any other Playwright download in the browser cache (PLAYWRIGHT_BROWSERS_PATH, ~/Library/Caches/ms-playwright,
|
|
15
|
+
// ~/.cache/ms-playwright, %LOCALAPPDATA%\ms-playwright), newest first. playwright-core never ships a browser,
|
|
16
|
+
// and a version bump leaves the old download in place, so this is the common fix
|
|
17
|
+
// 4. the system Chrome (Playwright's "chrome" channel, then the usual install paths)
|
|
18
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
19
|
+
import { dirname, join, resolve } from "node:path";
|
|
20
|
+
import { createRequire } from "node:module";
|
|
21
|
+
import { execSync } from "node:child_process";
|
|
22
|
+
import { homedir } from "node:os";
|
|
23
|
+
import { fileURLToPath } from "node:url";
|
|
24
|
+
|
|
25
|
+
const sh = (cmd, cwd) => { try { return execSync(cmd, { cwd, stdio: ["ignore", "pipe", "ignore"] }).toString().trim(); } catch { return ""; } };
|
|
26
|
+
|
|
27
|
+
// The repo root every script uses: --root, else the git root of the first path argument, else of the current
|
|
28
|
+
// folder, else the current folder. A path that does not exist yet (an --out folder) uses its nearest parent.
|
|
29
|
+
export function repoRoot(rootFlag, firstPath) {
|
|
30
|
+
if (rootFlag) return resolve(rootFlag);
|
|
31
|
+
if (firstPath) {
|
|
32
|
+
let d = resolve(firstPath);
|
|
33
|
+
while (!existsSync(d) && dirname(d) !== d) d = dirname(d);
|
|
34
|
+
if (!statSync(d).isDirectory()) d = dirname(d);
|
|
35
|
+
const g = sh("git rev-parse --show-toplevel", d); if (g) return g;
|
|
36
|
+
}
|
|
37
|
+
return sh("git rev-parse --show-toplevel", process.cwd()) || process.cwd();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function findPlaywright(root = repoRoot()) {
|
|
41
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
42
|
+
const scriptRoot = sh("git rev-parse --show-toplevel", here);
|
|
43
|
+
const globalRoot = sh("npm root -g", process.cwd());
|
|
44
|
+
// The root and the current folder walk up like any require. The script's repo root and the global folder are
|
|
45
|
+
// checked exactly, so an unrelated node_modules higher up never stands in for them.
|
|
46
|
+
const places = [
|
|
47
|
+
["repo root", root, true],
|
|
48
|
+
["current folder", process.cwd(), true],
|
|
49
|
+
["script's repo root", scriptRoot, false],
|
|
50
|
+
["global", globalRoot && dirname(globalRoot), false],
|
|
51
|
+
];
|
|
52
|
+
for (const [label, dir, up] of places) {
|
|
53
|
+
if (!dir) continue;
|
|
54
|
+
for (const name of ["playwright", "playwright-core"]) {
|
|
55
|
+
const exact = label === "global" ? join(globalRoot, name) : join(dir, "node_modules", name);
|
|
56
|
+
if (!up && !existsSync(join(exact, "package.json"))) continue;
|
|
57
|
+
try { const pw = createRequire(join(dir, "noop.js"))(up ? name : exact); if (pw.chromium) return { chromium: pw.chromium, from: `${name} (${label})` }; } catch {}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const lines = [
|
|
61
|
+
"Playwright not found. Looked in:",
|
|
62
|
+
` ${root} and its parents (the repo root; pass --root <app> when that is wrong)`,
|
|
63
|
+
` ${process.cwd()} and its parents`,
|
|
64
|
+
` ${scriptRoot ? join(scriptRoot, "node_modules") : "(script is not in a git repo)"}`,
|
|
65
|
+
` ${globalRoot || "(npm root -g failed)"}`,
|
|
66
|
+
"Install it in the repo root: npm i -D playwright && npx playwright install chromium",
|
|
67
|
+
"or globally: npm i -g playwright && playwright install chromium",
|
|
68
|
+
];
|
|
69
|
+
return { error: lines.join("\n") };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const EXE = new Set(["chrome-headless-shell", "headless_shell", "chrome-headless-shell.exe", "headless_shell.exe", "chrome", "chrome.exe", "Chromium", "Google Chrome for Testing"]);
|
|
73
|
+
function cachedBrowsers() {
|
|
74
|
+
const roots = [process.env.PLAYWRIGHT_BROWSERS_PATH, join(homedir(), "Library/Caches/ms-playwright"), join(homedir(), ".cache/ms-playwright"), process.env.LOCALAPPDATA && join(process.env.LOCALAPPDATA, "ms-playwright")].filter((r) => r && r !== "0" && existsSync(r));
|
|
75
|
+
const found = [];
|
|
76
|
+
for (const r of roots) {
|
|
77
|
+
const builds = readdirSync(r).map((d) => /^(chromium_headless_shell|chromium)-(\d+)$/.exec(d)).filter(Boolean)
|
|
78
|
+
.sort((a, b) => Number(b[2]) - Number(a[2]) || (a[1] === "chromium_headless_shell" ? -1 : 1));
|
|
79
|
+
for (const b of builds) {
|
|
80
|
+
const walk = (d, depth) => {
|
|
81
|
+
if (depth > 5) return null;
|
|
82
|
+
let entries = [];
|
|
83
|
+
try { entries = readdirSync(d); } catch { return null; }
|
|
84
|
+
for (const e of entries) {
|
|
85
|
+
const p = join(d, e);
|
|
86
|
+
let st; try { st = statSync(p); } catch { continue; }
|
|
87
|
+
if (st.isFile() && EXE.has(e) && (st.mode & 0o111 || e.endsWith(".exe"))) return p;
|
|
88
|
+
}
|
|
89
|
+
for (const e of entries) { const p = join(d, e); try { if (statSync(p).isDirectory()) { const x = walk(p, depth + 1); if (x) return x; } } catch {} }
|
|
90
|
+
return null;
|
|
91
|
+
};
|
|
92
|
+
const exe = walk(join(r, b[0]), 0);
|
|
93
|
+
if (exe) found.push(exe);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return found;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const SYSTEM = [
|
|
100
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
101
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
102
|
+
"/usr/bin/google-chrome", "/usr/bin/google-chrome-stable", "/usr/bin/chromium", "/usr/bin/chromium-browser",
|
|
103
|
+
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
// Returns { browser, from, how } or { error }.
|
|
107
|
+
export async function launchChromium(options = {}, { root } = {}) {
|
|
108
|
+
const pw = findPlaywright(root || repoRoot());
|
|
109
|
+
if (pw.error) return { error: pw.error };
|
|
110
|
+
const tried = [];
|
|
111
|
+
const attempt = async (how, opts) => {
|
|
112
|
+
try { return { browser: await pw.chromium.launch({ ...options, ...opts }), from: pw.from, how }; }
|
|
113
|
+
catch (e) { tried.push(`${how}: ${String(e.message).split("\n")[0].slice(0, 140)}`); return null; }
|
|
114
|
+
};
|
|
115
|
+
let r = null;
|
|
116
|
+
if (process.env.PW_CHROMIUM) r = await attempt(`PW_CHROMIUM ${process.env.PW_CHROMIUM}`, { executablePath: process.env.PW_CHROMIUM });
|
|
117
|
+
if (!r) r = await attempt("Playwright's own download", {});
|
|
118
|
+
if (!r) for (const exe of cachedBrowsers()) { r = await attempt(`cached Playwright build ${exe}`, { executablePath: exe }); if (r) break; }
|
|
119
|
+
if (!r) r = await attempt("system Chrome (channel chrome)", { channel: "chrome" });
|
|
120
|
+
if (!r) for (const exe of SYSTEM.filter((p) => existsSync(p))) { r = await attempt(`system browser ${exe}`, { executablePath: exe }); if (r) break; }
|
|
121
|
+
if (r) return r;
|
|
122
|
+
return { error: [`found ${pw.from} but no Chromium would launch. Tried:`, ...tried.map((t) => ` ${t}`), "Run `npx playwright install chromium` in the repo root, or set PW_CHROMIUM to a Chrome or Chromium executable."].join("\n") };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
126
|
+
const argv = process.argv.slice(2);
|
|
127
|
+
if (argv.includes("--help") || argv.includes("-h") || argv.some((a) => a.startsWith("--") && a !== "--root" && a !== "--self-test")) {
|
|
128
|
+
console.log("usage: node find-chromium.mjs [--root <dir>] [--self-test]\nPrints where Playwright and a launchable Chromium come from, after launching and closing it. Exit 0 when one launches, 2 when none does.\n--self-test is the same run: it passes only when a browser really launched.");
|
|
129
|
+
process.exit(argv.includes("--help") || argv.includes("-h") ? 0 : 2);
|
|
130
|
+
}
|
|
131
|
+
const i = argv.indexOf("--root");
|
|
132
|
+
const root = repoRoot(i >= 0 ? argv[i + 1] : null);
|
|
133
|
+
const r = await launchChromium({}, { root });
|
|
134
|
+
if (r.error) { console.error(r.error); process.exit(2); }
|
|
135
|
+
console.log(`root ${root}\nplaywright ${r.from}\nbrowser ${r.how}`);
|
|
136
|
+
await r.browser.close();
|
|
137
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// oklch.mjs: read a CSS color, print it as OKLCH, and measure the OK distance (deltaE OK, x100 scale) between two.
|
|
3
|
+
// Node 18+, no dependencies. Run `node scripts/oklch.mjs --help`.
|
|
4
|
+
|
|
5
|
+
const HELP = `oklch.mjs: a CSS color to OKLCH, and deltaE OK between two colors
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
node scripts/oklch.mjs <color>... one line per color: input, oklch(L C H / alpha), L in 0 to 1
|
|
9
|
+
node scripts/oklch.mjs --delta <a> <b> the deltaE OK between two colors, 0 to about 100, and their alphas
|
|
10
|
+
node scripts/oklch.mjs --self-test known values
|
|
11
|
+
|
|
12
|
+
A color is hex (#rgb, #rgba, #rrggbb, #rrggbbaa), rgb() or rgba(), hsl() or hsla(), hwb(), oklch(), oklab(),
|
|
13
|
+
a named color (the CSS list, transparent included). Commas or spaces both work, alpha after a slash or a fourth
|
|
14
|
+
comma, as a number or a percent. Angles take deg, grad, rad or turn. Quote functions in the shell.
|
|
15
|
+
Alpha is part of the color: it prints after the slash, and --delta prints both alphas and says "alpha differs"
|
|
16
|
+
when they are more than 0.02 apart (the opacity tolerance), which makes the pair two colors whatever the
|
|
17
|
+
distance. Hue prints as "none" when chroma is under 0.0001, as it is for grays. deltaE OK is the straight-line
|
|
18
|
+
distance in OKLab times 100, the scale token-mapping's rules use: under 0.5 counts as identical, the color
|
|
19
|
+
tolerance is 2, and a near pair is under 5. Not read: color(), lab(), lch(), color-mix(), var(), currentColor,
|
|
20
|
+
relative colors and system colors.
|
|
21
|
+
|
|
22
|
+
Exit 0 on success, 1 when a self-test value is off, 2 on bad input.`;
|
|
23
|
+
|
|
24
|
+
// The CSS named colors, as name and hex.
|
|
25
|
+
const NAMED = Object.fromEntries(("aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4 black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887 cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9 darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00 darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493 deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0 forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080 green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082 ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3 lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0 lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23 orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6 purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513 salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32")
|
|
26
|
+
.split(" ").reduce((pairs, word, i, all) => (i % 2 ? pairs : [...pairs, [word, all[i + 1]]]), []));
|
|
27
|
+
export const NAMED_COLORS = NAMED;
|
|
28
|
+
|
|
29
|
+
const lin = (v) => (v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4));
|
|
30
|
+
|
|
31
|
+
// sRGB channels 0 to 255 to OKLab.
|
|
32
|
+
export function toOklab(rgb) {
|
|
33
|
+
const [r, g, b] = rgb.map((v) => lin(v / 255));
|
|
34
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
35
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
36
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
37
|
+
return [
|
|
38
|
+
0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
39
|
+
1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
40
|
+
0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// "none" is 0, a percent is a share of `full`, a bare number stays as it is.
|
|
45
|
+
const num = (p, full) => {
|
|
46
|
+
if (p === "none") return 0;
|
|
47
|
+
if (p.endsWith("%")) { const v = parseFloat(p); return /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?%$/.test(p) ? (v / 100) * full : NaN; }
|
|
48
|
+
return /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/.test(p) ? parseFloat(p) : NaN;
|
|
49
|
+
};
|
|
50
|
+
const angle = (p) => {
|
|
51
|
+
if (p === "none") return 0;
|
|
52
|
+
const m = /^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(deg|grad|rad|turn)?$/.exec(p);
|
|
53
|
+
if (!m) return NaN;
|
|
54
|
+
const v = parseFloat(m[1]);
|
|
55
|
+
return { deg: v, grad: v * 0.9, rad: (v * 180) / Math.PI, turn: v * 360 }[m[2] || "deg"];
|
|
56
|
+
};
|
|
57
|
+
const alphaOf = (p) => (p === undefined ? 1 : Math.min(1, Math.max(0, num(p, 1))));
|
|
58
|
+
|
|
59
|
+
function hslToRgb(h, s, l) {
|
|
60
|
+
h = ((h % 360) + 360) % 360;
|
|
61
|
+
const k = (n) => (n + h / 30) % 12;
|
|
62
|
+
const a = s * Math.min(l, 1 - l);
|
|
63
|
+
return [0, 8, 4].map((n) => 255 * (l - a * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1))));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function hwbToRgb(h, w, b) {
|
|
67
|
+
if (w + b >= 1) { const g = (255 * w) / (w + b); return [g, g, g]; }
|
|
68
|
+
return hslToRgb(h, 1, 0.5).map((v) => v * (1 - w - b) + 255 * w);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// A CSS color to {lab: [L, a, b], alpha}, or null when it cannot be read.
|
|
72
|
+
export function parseColor(input) {
|
|
73
|
+
const s = String(input).trim().toLowerCase();
|
|
74
|
+
if (s === "transparent") return { lab: toOklab([0, 0, 0]), alpha: 0 };
|
|
75
|
+
if (NAMED[s]) return parseColor(`#${NAMED[s]}`);
|
|
76
|
+
let m = s.match(/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/);
|
|
77
|
+
if (m) {
|
|
78
|
+
let h = m[1];
|
|
79
|
+
if (h.length <= 4) h = [...h].map((c) => c + c).join("");
|
|
80
|
+
const rgb = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
|
|
81
|
+
return { lab: toOklab(rgb), alpha: h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1 };
|
|
82
|
+
}
|
|
83
|
+
m = s.match(/^(rgba?|hsla?|hwb|oklch|oklab)\(\s*([^)]*)\)$/);
|
|
84
|
+
if (!m) return null;
|
|
85
|
+
const [fn, body] = [m[1], m[2]];
|
|
86
|
+
const slash = body.split("/");
|
|
87
|
+
if (slash.length > 2) return null;
|
|
88
|
+
let parts = slash[0].split(/[\s,]+/).filter(Boolean);
|
|
89
|
+
let a = slash[1]?.trim();
|
|
90
|
+
if (a === "") return null;
|
|
91
|
+
if (a === undefined && parts.length === 4) a = parts.pop();
|
|
92
|
+
if (parts.length !== 3) return null;
|
|
93
|
+
const alpha = alphaOf(a);
|
|
94
|
+
let lab;
|
|
95
|
+
if (fn.startsWith("rgb")) {
|
|
96
|
+
const rgb = parts.map((p) => num(p, 255));
|
|
97
|
+
if (rgb.some((v) => !Number.isFinite(v))) return null;
|
|
98
|
+
lab = toOklab(rgb.map((v) => Math.min(255, Math.max(0, v))));
|
|
99
|
+
} else if (fn.startsWith("hsl") || fn === "hwb") {
|
|
100
|
+
const [h, x, y] = [angle(parts[0]), num(parts[1], 100) / 100, num(parts[2], 100) / 100];
|
|
101
|
+
if (![h, x, y].every(Number.isFinite)) return null;
|
|
102
|
+
const clamp = (v) => Math.min(1, Math.max(0, v));
|
|
103
|
+
lab = toOklab(fn === "hwb" ? hwbToRgb(h, clamp(x), clamp(y)) : hslToRgb(h, clamp(x), clamp(y)));
|
|
104
|
+
} else if (fn === "oklch") {
|
|
105
|
+
const [L, C, H] = [num(parts[0], 1), num(parts[1], 0.4), angle(parts[2])];
|
|
106
|
+
if (![L, C, H].every(Number.isFinite)) return null;
|
|
107
|
+
const c = Math.max(0, C);
|
|
108
|
+
lab = [Math.min(1, Math.max(0, L)), c * Math.cos((H * Math.PI) / 180), c * Math.sin((H * Math.PI) / 180)];
|
|
109
|
+
} else {
|
|
110
|
+
const [L, A, B] = [num(parts[0], 1), num(parts[1], 0.4), num(parts[2], 0.4)];
|
|
111
|
+
if (![L, A, B].every(Number.isFinite)) return null;
|
|
112
|
+
lab = [Math.min(1, Math.max(0, L)), A, B];
|
|
113
|
+
}
|
|
114
|
+
if (a !== undefined && !Number.isFinite(alpha)) return null;
|
|
115
|
+
return { lab, alpha };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Kept for callers of the old API: sRGB channels for hex and rgb() only.
|
|
119
|
+
export function parse(input) {
|
|
120
|
+
const s = String(input).trim().toLowerCase();
|
|
121
|
+
if (!/^#|^rgba?\(/.test(s)) return null;
|
|
122
|
+
const c = parseColor(s);
|
|
123
|
+
if (!c) return null;
|
|
124
|
+
const m = s.match(/^#([0-9a-f]+)$/);
|
|
125
|
+
if (m) { let h = m[1]; if (h.length <= 4) h = [...h].map((x) => x + x).join(""); return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16)); }
|
|
126
|
+
const parts = s.replace(/^rgba?\(|\)$/g, "").split("/")[0].split(/[\s,]+/).filter(Boolean).slice(0, 3);
|
|
127
|
+
return parts.map((p) => num(p, 255));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const labToLch = ([L, a, b]) => {
|
|
131
|
+
const C = Math.hypot(a, b);
|
|
132
|
+
return [L, C, C < 0.0001 ? null : ((Math.atan2(b, a) * 180) / Math.PI + 360) % 360];
|
|
133
|
+
};
|
|
134
|
+
export const toOklch = (rgb) => labToLch(toOklab(rgb));
|
|
135
|
+
|
|
136
|
+
// deltaE OK between two colors: parsed colors, or sRGB channel arrays.
|
|
137
|
+
export function deltaEOK(x, y) {
|
|
138
|
+
const [p, q] = [x, y].map((c) => (Array.isArray(c) ? toOklab(c) : c.lab));
|
|
139
|
+
return 100 * Math.hypot(p[0] - q[0], p[1] - q[1], p[2] - q[2]);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export const format = ([L, C, H], alpha = 1) => `oklch(${L.toFixed(4)} ${C.toFixed(4)} ${H === null ? "none" : H.toFixed(2)}${alpha < 1 ? ` / ${+alpha.toFixed(4)}` : ""})`;
|
|
143
|
+
|
|
144
|
+
if (process.argv[1] && (await import("node:path")).resolve(process.argv[1]) === (await import("node:url")).fileURLToPath(import.meta.url)) {
|
|
145
|
+
const argv = process.argv.slice(2);
|
|
146
|
+
const bad = (msg) => { console.error(`oklch: ${msg}\n\n${HELP}`); process.exit(2); };
|
|
147
|
+
if (!argv.length) bad("give a color, --delta <a> <b>, or --self-test");
|
|
148
|
+
if (argv.includes("--help") || argv.includes("-h")) { console.log(HELP); process.exit(0); }
|
|
149
|
+
if (argv.includes("--self-test")) {
|
|
150
|
+
// [color, L, C, H, alpha] with H null for grays, then [a, b, deltaE OK on the x100 scale], then unreadable input.
|
|
151
|
+
const known = [
|
|
152
|
+
["#ffffff", 1, 0, null, 1],
|
|
153
|
+
["#000000", 0, 0, null, 1],
|
|
154
|
+
["#808080", 0.5999, 0, null, 1],
|
|
155
|
+
["#ff0000", 0.628, 0.2577, 29.23, 1],
|
|
156
|
+
["#00ff00", 0.8664, 0.2948, 142.5, 1],
|
|
157
|
+
["#0000ff", 0.452, 0.3132, 264.05, 1],
|
|
158
|
+
["rgb(255, 0, 0)", 0.628, 0.2577, 29.23, 1],
|
|
159
|
+
// The doc once promised these and the script read hex and rgb() only, with alpha dropped.
|
|
160
|
+
["rgb(255 0 0 / 50%)", 0.628, 0.2577, 29.23, 0.5],
|
|
161
|
+
["rgba(255, 0, 0, .25)", 0.628, 0.2577, 29.23, 0.25],
|
|
162
|
+
["#ff000080", 0.628, 0.2577, 29.23, 128 / 255],
|
|
163
|
+
["#f008", 0.628, 0.2577, 29.23, 136 / 255],
|
|
164
|
+
["hsl(0 100% 50%)", 0.628, 0.2577, 29.23, 1],
|
|
165
|
+
["hsla(120, 100%, 25%, 0.5)", 0.5183, 0.1764, 142.5, 0.5],
|
|
166
|
+
["hsl(0.5turn 100% 50%)", 0.9054, 0.1546, 194.77, 1],
|
|
167
|
+
["hwb(0 0% 0%)", 0.628, 0.2577, 29.23, 1],
|
|
168
|
+
["hwb(0 60% 60%)", 0.5982, 0, null, 1],
|
|
169
|
+
["oklch(0.628 0.2577 29.23)", 0.628, 0.2577, 29.23, 1],
|
|
170
|
+
["oklch(62.8% 64.425% 29.23deg / 0.8)", 0.628, 0.2577, 29.23, 0.8],
|
|
171
|
+
["oklab(0.628 0.2249 0.1258)", 0.628, 0.2577, 29.22, 1],
|
|
172
|
+
["red", 0.628, 0.2577, 29.23, 1],
|
|
173
|
+
["green", 0.5197, 0.1765, 142.5, 1],
|
|
174
|
+
["rebeccapurple", 0.4403, 0.1603, 303.37, 1],
|
|
175
|
+
["transparent", 0, 0, null, 0],
|
|
176
|
+
];
|
|
177
|
+
const deltas = [["#ffffff", "#000000", 100], ["#6b7280", "#6b7280", 0], ["#6b7280", "#737373", 2.38], ["hsl(0 100% 50%)", "red", 0], ["oklch(0.628 0.2577 29.23)", "#ff0000", 0]];
|
|
178
|
+
const unreadable = ["#12", "rgb(1 2)", "hsl(x 1% 1%)", "oklch(0.5 0.1 10 / )", "notacolor", "lab(50 10 10)"];
|
|
179
|
+
let ok = true;
|
|
180
|
+
for (const [c, L, C, H, A] of known) {
|
|
181
|
+
const p = parseColor(c);
|
|
182
|
+
const [l, ch, h] = p ? labToLch(p.lab) : [NaN, NaN, NaN];
|
|
183
|
+
const good = !!p && Math.abs(l - L) < 0.001 && Math.abs(ch - C) < 0.001 && (H === null ? h === null : Math.abs(h - H) < 0.05) && Math.abs(p.alpha - A) < 0.001;
|
|
184
|
+
if (!good) ok = false;
|
|
185
|
+
console.log(`self-test ${good ? "ok " : "FAIL"} ${c}: ${p ? format([l, ch, h], p.alpha) : "unread"}, want L ${L} C ${C} H ${H ?? "none"} alpha ${+A.toFixed(4)}`);
|
|
186
|
+
}
|
|
187
|
+
for (const [a, b, want] of deltas) {
|
|
188
|
+
const d = deltaEOK(parseColor(a), parseColor(b));
|
|
189
|
+
const good = Math.abs(d - want) < 0.02;
|
|
190
|
+
if (!good) ok = false;
|
|
191
|
+
console.log(`self-test ${good ? "ok " : "FAIL"} deltaE OK x100 ${a} ${b}: ${d.toFixed(2)}, want ${want}`);
|
|
192
|
+
}
|
|
193
|
+
for (const c of unreadable) {
|
|
194
|
+
const good = parseColor(c) === null;
|
|
195
|
+
if (!good) ok = false;
|
|
196
|
+
console.log(`self-test ${good ? "ok " : "FAIL"} ${c} is refused`);
|
|
197
|
+
}
|
|
198
|
+
const named = Object.keys(NAMED).length;
|
|
199
|
+
const goodNamed = named === 148;
|
|
200
|
+
if (!goodNamed) ok = false;
|
|
201
|
+
console.log(`self-test ${goodNamed ? "ok " : "FAIL"} ${named} named colors, want 148`);
|
|
202
|
+
console.log(`self-test: ${known.length + deltas.length + unreadable.length + 1} checks, ${ok ? "all as expected" : "FAILED"}`);
|
|
203
|
+
process.exit(ok ? 0 : 1);
|
|
204
|
+
}
|
|
205
|
+
if (argv[0] === "--delta") {
|
|
206
|
+
if (argv.length !== 3) bad("--delta takes exactly two colors");
|
|
207
|
+
const [a, b] = argv.slice(1).map((c) => parseColor(c) || bad(`cannot read the color ${c}`));
|
|
208
|
+
const differs = Math.abs(a.alpha - b.alpha) > 0.02;
|
|
209
|
+
console.log(`${argv[1]}\t${argv[2]}\tdeltaE OK x100 ${deltaEOK(a, b).toFixed(2)}\talpha ${+a.alpha.toFixed(4)} and ${+b.alpha.toFixed(4)}${differs ? "\talpha differs" : ""}`);
|
|
210
|
+
console.log("Coverage: 2 colors, alpha compared on its own. Not read: color spaces beyond sRGB, OKLab and OKLCH");
|
|
211
|
+
process.exit(0);
|
|
212
|
+
}
|
|
213
|
+
const unknown = argv.find((a) => a.startsWith("--"));
|
|
214
|
+
if (unknown) bad(`unknown ${unknown}`);
|
|
215
|
+
for (const c of argv) {
|
|
216
|
+
const p = parseColor(c);
|
|
217
|
+
if (!p) bad(`cannot read the color ${c}`);
|
|
218
|
+
console.log(`${c}\t${format(labToLch(p.lab), p.alpha)}`);
|
|
219
|
+
}
|
|
220
|
+
console.log(`Coverage: ${argv.length} color(s) with alpha. Not read: color spaces beyond sRGB, OKLab and OKLCH`);
|
|
221
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// pixdiff.mjs: compare two saved screenshots, or two folders of same-named PNGs.
|
|
3
|
+
//
|
|
4
|
+
// node pixdiff.mjs /abs/before.png /abs/after.png
|
|
5
|
+
// node pixdiff.mjs /abs/baseline/ /abs/after/ [--surface <name>,...] [--max <percent>] [--tolerance <n>] [--out <dir>] [--no-image] [--root <dir>]
|
|
6
|
+
//
|
|
7
|
+
// In folder mode, when the first folder holds capture.mjs names (<surface>-before-<width>.png),
|
|
8
|
+
// each before file pairs with its -after- name in the second folder, which may be the same
|
|
9
|
+
// folder. Otherwise files pair by the same relative path. Every width and theme is compared.
|
|
10
|
+
// --surface keeps only the named surfaces' files (every width, theme and state) and prints
|
|
11
|
+
// how many other before files it skipped, so one surface's swap is proven in a shared folder.
|
|
12
|
+
// Prints one line per file: path, size match, changed-pixel percentage, the bounding
|
|
13
|
+
// box of the changed pixels, the largest per-channel delta (printed even under the
|
|
14
|
+
// tolerance), the tolerance, and the diff image: the after capture faded, changed
|
|
15
|
+
// pixels red, written beside the after file as <name>.diff.png or into --out.
|
|
16
|
+
// A pixel counts as changed when any channel differs by more than --tolerance
|
|
17
|
+
// (0 to 255, default 0). A value-identical swap is proven at tolerance 0 only.
|
|
18
|
+
// Exits 1 when any pair differs in size, is missing, or changes more pixels than
|
|
19
|
+
// --max (percent, default 0).
|
|
20
|
+
//
|
|
21
|
+
// Needs Playwright (`playwright` or `playwright-core`) and a Chromium. find-chromium.mjs
|
|
22
|
+
// finds both: PW_CHROMIUM, Playwright's own download, any other Playwright download in
|
|
23
|
+
// the cache, then the system Chrome. Playwright is looked for first in --root, which defaults to the git root of the
|
|
24
|
+
// first image path, else of the current folder. Relative image paths resolve against the current folder.
|
|
25
|
+
import { readFileSync, readdirSync, statSync, existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
26
|
+
import { spawnSync } from "node:child_process";
|
|
27
|
+
import { tmpdir } from "node:os";
|
|
28
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
29
|
+
import { deflateSync } from "node:zlib";
|
|
30
|
+
import { fileURLToPath } from "node:url";
|
|
31
|
+
import { launchChromium, repoRoot } from "./find-chromium.mjs";
|
|
32
|
+
|
|
33
|
+
const USAGE = "usage: node pixdiff.mjs <before.png|dir> <after.png|dir> [--surface <name>,...] [--max <percent>] [--tolerance <n>] [--out <dir>] [--no-image] [--root <dir>]\n node pixdiff.mjs --self-test\nTwo folders pair capture.mjs -before- files with their -after- names (the folders may be the same), else files of the same name\n--surface keeps only those surfaces' capture.mjs files and counts the rest as skipped\n--tolerance is the per-channel delta, 0 to 255, a pixel may move and still count as unchanged. Default 0. Keep 0 to prove a value-identical swap\n--root is where Playwright is looked for first. Default: the git root of the first path, else of the current folder";
|
|
34
|
+
const args = process.argv.slice(2);
|
|
35
|
+
if (args.includes("--help") || args.includes("-h")) { console.log(USAGE); process.exit(0); }
|
|
36
|
+
if (args.includes("--self-test")) process.exit(selfTest());
|
|
37
|
+
|
|
38
|
+
// A w x h RGBA PNG, every pixel from px(x, y) -> [r, g, b, a]. Enough to test the diff without an image library.
|
|
39
|
+
function png(w, h, px) {
|
|
40
|
+
const crcTable = Array.from({ length: 256 }, (_, n) => { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; return c >>> 0; });
|
|
41
|
+
const crc = (buf) => { let c = 0xffffffff; for (const b of buf) c = crcTable[(c ^ b) & 0xff] ^ (c >>> 8); return (c ^ 0xffffffff) >>> 0; };
|
|
42
|
+
const chunk = (type, data) => { const len = Buffer.alloc(4); len.writeUInt32BE(data.length); const td = Buffer.concat([Buffer.from(type), data]); const c = Buffer.alloc(4); c.writeUInt32BE(crc(td)); return Buffer.concat([len, td, c]); };
|
|
43
|
+
const head = Buffer.alloc(13); head.writeUInt32BE(w, 0); head.writeUInt32BE(h, 4); head[8] = 8; head[9] = 6;
|
|
44
|
+
const raw = Buffer.alloc(h * (1 + w * 4));
|
|
45
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) Buffer.from(px(x, y)).copy(raw, y * (1 + w * 4) + 1 + x * 4);
|
|
46
|
+
return Buffer.concat([Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), chunk("IHDR", head), chunk("IDAT", deflateSync(raw)), chunk("IEND", Buffer.alloc(0))]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function selfTest() {
|
|
50
|
+
const dir = mkdtempSync(join(tmpdir(), "pixdiff-"));
|
|
51
|
+
let fails = 0;
|
|
52
|
+
const t = (name, ok, detail) => { console.log(`${ok ? "ok " : "FAIL"} ${name}${ok ? "" : `: ${detail}`}`); if (!ok) fails++; };
|
|
53
|
+
const run = (...a) => { const r = spawnSync(process.execPath, [fileURLToPath(import.meta.url), ...a], { encoding: "utf8" }); return { code: r.status, out: (r.stdout || "") + (r.stderr || "") }; };
|
|
54
|
+
try {
|
|
55
|
+
const grey = () => [200, 200, 200, 255];
|
|
56
|
+
mkdirSync(join(dir, "shots"));
|
|
57
|
+
writeFileSync(join(dir, "shots/home-before-390.png"), png(20, 10, grey));
|
|
58
|
+
writeFileSync(join(dir, "shots/home-after-390.png"), png(20, 10, grey));
|
|
59
|
+
writeFileSync(join(dir, "shots/card-before-390.png"), png(20, 10, grey));
|
|
60
|
+
writeFileSync(join(dir, "shots/card-after-390.png"), png(20, 10, (x, y) => (x === 3 && y === 4 ? [201, 200, 200, 255] : grey())));
|
|
61
|
+
writeFileSync(join(dir, "wide.png"), png(21, 10, grey));
|
|
62
|
+
let r = run(join(dir, "shots/home-before-390.png"), join(dir, "shots/home-after-390.png"), "--root", dir);
|
|
63
|
+
if (/no Chromium|Playwright not found/.test(r.out)) { console.log(`self-test: the comparison did not run, because no browser was found:
|
|
64
|
+
${r.out.trim()}`); return 2; }
|
|
65
|
+
t("identical images exit 0 at tolerance 0", r.code === 0 && /\t0%\tno change/.test(r.out), r.out);
|
|
66
|
+
r = run(join(dir, "shots/card-before-390.png"), join(dir, "shots/card-after-390.png"), "--no-image", "--root", dir);
|
|
67
|
+
t("one pixel off by one channel step fails at tolerance 0", r.code === 1 && /bbox 3,4 1x1/.test(r.out) && /max delta 1/.test(r.out), r.out);
|
|
68
|
+
r = run(join(dir, "shots/card-before-390.png"), join(dir, "shots/card-after-390.png"), "--no-image", "--tolerance", "1", "--root", dir);
|
|
69
|
+
t("the same pixel passes at tolerance 1", r.code === 0, r.out);
|
|
70
|
+
r = run(join(dir, "shots/card-before-390.png"), join(dir, "wide.png"), "--root", dir);
|
|
71
|
+
t("a size change fails", r.code === 1 && /20x10 vs 21x10/.test(r.out), r.out);
|
|
72
|
+
r = run(join(dir, "shots"), join(dir, "shots"), "--surface", "home", "--root", dir);
|
|
73
|
+
t("folder mode pairs before with after and keeps one surface", r.code === 0 && /1 compared/.test(r.out) && /1 of other surfaces skipped/.test(r.out), r.out);
|
|
74
|
+
r = run(join(dir, "shots"), join(dir, "shots"), "--no-image", "--root", dir);
|
|
75
|
+
t("folder mode fails when any surface changed", r.code === 1 && /2 compared, 1 over 0%/.test(r.out), r.out);
|
|
76
|
+
} finally { rmSync(dir, { recursive: true, force: true }); }
|
|
77
|
+
console.log(fails ? `${fails} failed` : "all as expected");
|
|
78
|
+
return fails ? 1 : 0;
|
|
79
|
+
}
|
|
80
|
+
if (args.some((a) => a.startsWith("-") && !["--max", "--out", "--no-image", "--root", "--tolerance", "--surface"].includes(a))) {
|
|
81
|
+
console.error(USAGE);
|
|
82
|
+
process.exit(2);
|
|
83
|
+
}
|
|
84
|
+
const take = (f) => { const i = args.indexOf(f); return i >= 0 ? args.splice(i, 2)[1] : undefined; };
|
|
85
|
+
const maxArg = take("--max");
|
|
86
|
+
const max = maxArg === undefined ? 0 : Number(maxArg);
|
|
87
|
+
const outDir = take("--out");
|
|
88
|
+
const rootArg = take("--root");
|
|
89
|
+
const tolArg = take("--tolerance");
|
|
90
|
+
const surfArg = take("--surface");
|
|
91
|
+
const only = surfArg ? new Set(surfArg.split(",").map((x) => x.trim()).filter(Boolean)) : null;
|
|
92
|
+
const tolerance = tolArg === undefined ? 0 : Number(tolArg);
|
|
93
|
+
if (!Number.isInteger(tolerance) || tolerance < 0 || tolerance > 255) { console.error(`pixdiff: --tolerance takes a whole number from 0 to 255, not ${tolArg}\n${USAGE}`); process.exit(2); }
|
|
94
|
+
const noImage = args.includes("--no-image");
|
|
95
|
+
if (noImage) args.splice(args.indexOf("--no-image"), 1);
|
|
96
|
+
const [A, B] = args.map((p) => resolve(p));
|
|
97
|
+
if (!A || !B || Number.isNaN(max)) {
|
|
98
|
+
console.error(USAGE);
|
|
99
|
+
process.exit(2);
|
|
100
|
+
}
|
|
101
|
+
for (const p of [A, B]) {
|
|
102
|
+
if (!existsSync(p)) { console.error(`pixdiff: ${p} does not exist (relative paths resolve against ${process.cwd()})`); process.exit(2); }
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const launched = await launchChromium({}, { root: repoRoot(rootArg, A) });
|
|
106
|
+
if (launched.error) { console.error(`pixdiff: ${launched.error}`); process.exit(2); }
|
|
107
|
+
const browser = launched.browser;
|
|
108
|
+
console.error(`pixdiff: using ${launched.from}, ${launched.how}`);
|
|
109
|
+
|
|
110
|
+
const walk = (d) => readdirSync(d).flatMap((e) => {
|
|
111
|
+
const p = join(d, e);
|
|
112
|
+
return statSync(p).isDirectory() ? walk(p) : p.endsWith(".png") && !p.includes(".diff.") ? [p] : [];
|
|
113
|
+
});
|
|
114
|
+
const dirMode = statSync(A).isDirectory();
|
|
115
|
+
// capture.mjs names files <surface>-before-<width>[-<theme>].png, so when the before
|
|
116
|
+
// folder holds such names, each pairs with the same name with -after- in the after folder.
|
|
117
|
+
const kinded = dirMode && walk(A).some((f) => basename(f).includes("-before-"));
|
|
118
|
+
if (only && !kinded) { console.error("pixdiff: --surface needs two folders of capture.mjs names (<surface>-before-<width>.png)"); process.exit(2); }
|
|
119
|
+
// A state capture is <surface>.<state>-before-..., so the surface is the name up to the first dot.
|
|
120
|
+
const surfaceOf = (f) => basename(f).split("-before-")[0].split(".")[0];
|
|
121
|
+
const befores = dirMode ? walk(A).filter((f) => !kinded || basename(f).includes("-before-")) : [];
|
|
122
|
+
const kept = only ? befores.filter((f) => only.has(surfaceOf(f))) : befores;
|
|
123
|
+
const skipped = befores.length - kept.length;
|
|
124
|
+
if (only && !kept.length) { console.error(`pixdiff: no before capture for ${[...only].join(", ")} in ${A}`); process.exit(2); }
|
|
125
|
+
const pairs = dirMode
|
|
126
|
+
? kept.sort().map((fa) => {
|
|
127
|
+
const rel = relative(A, fa);
|
|
128
|
+
return [rel, fa, join(B, kinded ? join(dirname(rel), basename(rel).replace("-before-", "-after-")) : rel)];
|
|
129
|
+
})
|
|
130
|
+
: [[relative(process.cwd(), B), A, B]];
|
|
131
|
+
|
|
132
|
+
const page = await browser.newPage();
|
|
133
|
+
let failed = 0;
|
|
134
|
+
for (const [name, fa, fb] of pairs) {
|
|
135
|
+
if (!existsSync(fb)) { console.log(`${name}\tmissing in ${B}\ttolerance ${tolerance}`); failed++; continue; }
|
|
136
|
+
const r = await page.evaluate(async ([a, b, wantImage, tol]) => {
|
|
137
|
+
const load = (s) => new Promise((ok, no) => { const i = new Image(); i.onload = () => ok(i); i.onerror = no; i.src = "data:image/png;base64," + s; });
|
|
138
|
+
const [ia, ib] = await Promise.all([load(a), load(b)]);
|
|
139
|
+
if (ia.width !== ib.width || ia.height !== ib.height) return { size: `${ia.width}x${ia.height} vs ${ib.width}x${ib.height}`, pct: null };
|
|
140
|
+
const w = ia.width, h = ia.height;
|
|
141
|
+
const px = (i) => { const c = document.createElement("canvas"); c.width = w; c.height = h; const x = c.getContext("2d"); x.drawImage(i, 0, 0); return x.getImageData(0, 0, w, h).data; };
|
|
142
|
+
const da = px(ia), db = px(ib);
|
|
143
|
+
let n = 0, x0 = w, y0 = h, x1 = -1, y1 = -1, maxDelta = 0;
|
|
144
|
+
const changed = new Uint8Array(w * h);
|
|
145
|
+
for (let k = 0, p = 0; k < da.length; k += 4, p++) {
|
|
146
|
+
const d = Math.max(Math.abs(da[k] - db[k]), Math.abs(da[k + 1] - db[k + 1]), Math.abs(da[k + 2] - db[k + 2]), Math.abs(da[k + 3] - db[k + 3]));
|
|
147
|
+
if (d > maxDelta) maxDelta = d;
|
|
148
|
+
if (d > tol) {
|
|
149
|
+
n++; changed[p] = 1;
|
|
150
|
+
const x = p % w, y = (p / w) | 0;
|
|
151
|
+
if (x < x0) x0 = x; if (x > x1) x1 = x; if (y < y0) y0 = y; if (y > y1) y1 = y;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// A changed pixel never rounds down to 0%: the percentage keeps enough digits to show it.
|
|
155
|
+
const raw = 100 * n / (w * h);
|
|
156
|
+
const pct = n && +raw.toFixed(3) === 0 ? +raw.toPrecision(2) : +raw.toFixed(3);
|
|
157
|
+
const out = { size: "same size", pct, bbox: n ? [x0, y0, x1 - x0 + 1, y1 - y0 + 1] : null, maxDelta };
|
|
158
|
+
if (n && wantImage) {
|
|
159
|
+
// the after capture faded to 25%, changed pixels in red, the box outlined
|
|
160
|
+
const c = document.createElement("canvas"); c.width = w; c.height = h;
|
|
161
|
+
const x = c.getContext("2d");
|
|
162
|
+
x.fillStyle = "#fff"; x.fillRect(0, 0, w, h); x.globalAlpha = 0.25; x.drawImage(ib, 0, 0); x.globalAlpha = 1;
|
|
163
|
+
const img = x.getImageData(0, 0, w, h);
|
|
164
|
+
for (let p = 0; p < changed.length; p++) if (changed[p]) { img.data[p * 4] = 255; img.data[p * 4 + 1] = 0; img.data[p * 4 + 2] = 0; img.data[p * 4 + 3] = 255; }
|
|
165
|
+
x.putImageData(img, 0, 0);
|
|
166
|
+
x.strokeStyle = "#f0f"; x.lineWidth = 2; x.strokeRect(x0 - 2, y0 - 2, x1 - x0 + 5, y1 - y0 + 5);
|
|
167
|
+
out.png = c.toDataURL("image/png").split(",")[1];
|
|
168
|
+
}
|
|
169
|
+
return out;
|
|
170
|
+
}, [readFileSync(fa).toString("base64"), readFileSync(fb).toString("base64"), !noImage, tolerance]);
|
|
171
|
+
if (r.pct === null || r.pct > max) failed++;
|
|
172
|
+
let img = "";
|
|
173
|
+
if (r.png) {
|
|
174
|
+
const dest = outDir ? join(resolve(outDir), (dirMode ? name : basename(fb)).replace(/\.png$/, ".diff.png")) : fb.replace(/\.png$/, ".diff.png");
|
|
175
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
176
|
+
writeFileSync(dest, Buffer.from(r.png, "base64"));
|
|
177
|
+
img = dest;
|
|
178
|
+
}
|
|
179
|
+
const box = r.bbox ? `bbox ${r.bbox[0]},${r.bbox[1]} ${r.bbox[2]}x${r.bbox[3]}` : r.pct === null ? "-" : "no change";
|
|
180
|
+
const delta = r.pct === null ? "max delta -" : `max delta ${r.maxDelta}`;
|
|
181
|
+
console.log(`${name}\t${r.size}\t${r.pct === null ? "-" : r.pct + "%"}\t${box}\t${delta}\ttolerance ${tolerance}${img ? `\t${relative(process.cwd(), img) || basename(img)}` : ""}`);
|
|
182
|
+
}
|
|
183
|
+
await browser.close();
|
|
184
|
+
console.log(`${pairs.length} compared, ${failed} over ${max}%, tolerance ${tolerance}${only ? `, ${skipped} of other surfaces skipped` : ""}`);
|
|
185
|
+
console.log(`Coverage: ${pairs.length} pair(s) compared pixel by pixel on every channel including alpha${dirMode ? `, every before file in ${A}${only ? ` for ${[...only].join(", ")}` : ""}` : ""}. Not compared: after files with no before file, accessibility trees, probe files, motion, and any state or width that was not captured`);
|
|
186
|
+
process.exit(failed ? 1 : 0);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Notice
|
|
2
|
+
|
|
3
|
+
This skill comes from https://github.com/arla6ka/design.how (`skills/component-docs/SKILL.md`).
|
|
4
|
+
Licence: MIT (evidence: repository license, https://github.com/arla6ka/design.how/blob/main/LICENSE, checked 2026-11-09).
|
|
5
|
+
|
|
6
|
+
Luci converted it to the Luci Skill Standard: SKILL.md metadata keys and luci.json. The instructions are unchanged.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "component-docs"
|
|
3
|
+
description: "Use to write one component's documentation entry from its code, stories and real call sites, such as \"document the button\", \"write docs for Select\", \"what states does Toast have\", or usage rules for a new or changed component. Not for foundations or pages that span components, which no skill here writes, nor for changing the component, which is build-design-system."
|
|
4
|
+
license: "MIT"
|
|
5
|
+
metadata:
|
|
6
|
+
luci-category: "design-systems"
|
|
7
|
+
luci-author: "unknown"
|
|
8
|
+
luci-version: "1.0.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Component docs
|
|
12
|
+
|
|
13
|
+
A draft entry for one component, built only from what its sources say. Gaps are marked, not filled. It does not judge the design and it publishes nothing. The heading order and a worked example are in `references/doc-format.md`.
|
|
14
|
+
|
|
15
|
+
## Steps
|
|
16
|
+
|
|
17
|
+
1. Paste the nine headings from `references/doc-format.md` into the draft, empty.
|
|
18
|
+
2. Find the component. Read its code, props type, styles and stories, and record each as a Sources line.
|
|
19
|
+
3. Find two real uses, by call-site search or from the ask. One real use or none changes the stop table below.
|
|
20
|
+
4. Trace which source gave each example, variant, prop, state and token. Every disagreement between sources is a line under Conflicts, with the quoted rule that settles it, or "no rule, not chosen".
|
|
21
|
+
5. Fill each section from sourced facts, copying token names and example code character for character.
|
|
22
|
+
6. Write Usage rules last. Each rule is `rule/<component>-<slug>`, a condition, an action, a reason, its evidence (two call sites, a measurement with its path, a named principle, or the person's words), and a `Don't:` line with real code that breaks it. A rule you cannot break with a snippet is cut.
|
|
23
|
+
7. Fill Guessed at, one line per judgement call. Reread the draft against the Done list below.
|
|
24
|
+
|
|
25
|
+
## Output
|
|
26
|
+
|
|
27
|
+
The entry, then Sources, Conflicts, Guessed at, and Gates (a question with its default) only where a rule adds one. Run on its own, it saves to `docs/system/<name>.md` with a draft comment on line 1 and writes each missing example file. The reply opens with the path, what the entry covers and its status, then up to three questions with defaults and one prompt the person can paste to take the next step.
|
|
28
|
+
|
|
29
|
+
## Stops
|
|
30
|
+
|
|
31
|
+
| Missing after searching | Why it stops |
|
|
32
|
+
|---|---|
|
|
33
|
+
| The code | Nothing else sources the variants, props or behaviour |
|
|
34
|
+
| The variant list (props type or stories) | A guessed list documents a different component |
|
|
35
|
+
| Any use, real or planned | Invented uses read like real ones and readers copy them first |
|
|
36
|
+
|
|
37
|
+
A props type with no variant prop is an empty list. Variants reads "None" and the run goes on. One real use, planned uses and a deprecated predecessor are marked as such, not stopped on. A stopped run returns the stop, the facts sourced so far by section, and the smallest reply that unblocks it ("one screen name, what put the component there, and which variant showed").
|
|
38
|
+
|
|
39
|
+
## Rules
|
|
40
|
+
|
|
41
|
+
- Never write a variant, prop, token name, example or use that has no listed source. A planned use says planned.
|
|
42
|
+
- Never invent a state or a precedence order to make a section look complete.
|
|
43
|
+
- A behaviour that looks like a bug is written as it is, followed by a `Defect:` line to the owner with what goes wrong for the user and the smallest fix.
|
|
44
|
+
- A part also used on its own gets a `### Parts` subsection under Description. A compound component (`Tabs` with `Tab`) is one entry.
|
|
45
|
+
- Do not edit the code, stories or spec being documented.
|
|
46
|
+
- Counts in the reply come from `grep -o` on the saved file, below the draft comment.
|
|
47
|
+
|
|
48
|
+
## Done
|
|
49
|
+
|
|
50
|
+
Every variant, prop, token and example has a Sources line. Every Usage rule has evidence and a `Don't:` line. Every conflict is shown. The nine headings are present in order, and a section with nothing sourced reads `Not applicable: <reason>`.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lss": 1,
|
|
3
|
+
"lastVerified": "2026-11-09",
|
|
4
|
+
"source": {
|
|
5
|
+
"repo": "arla6ka/design.how",
|
|
6
|
+
"path": "skills/component-docs/SKILL.md",
|
|
7
|
+
"licenseVerified": true,
|
|
8
|
+
"licenseStatus": "open",
|
|
9
|
+
"licenseEvidence": "repository license",
|
|
10
|
+
"licenseUrl": "https://github.com/arla6ka/design.how/blob/main/LICENSE",
|
|
11
|
+
"licenseCheckedAt": "2026-11-09"
|
|
12
|
+
},
|
|
13
|
+
"whenToUse": [
|
|
14
|
+
"Writing one component's documentation entry from its code, stories and real call sites, such as document"
|
|
15
|
+
],
|
|
16
|
+
"summary": "Use to write one component's documentation entry from its code, stories and real call sites, such as \"document the button\", \"write docs for Select\", \"what states does Toast have\", or usage rules for a new or changed component. Not for foundations or pages that span components, which no skill…",
|
|
17
|
+
"whenNotToUse": [
|
|
18
|
+
"Not for foundations or pages that span components, which no skill here writes, nor for changing the component, which is build-design-system."
|
|
19
|
+
],
|
|
20
|
+
"domains": [
|
|
21
|
+
"design",
|
|
22
|
+
"web",
|
|
23
|
+
"writing"
|
|
24
|
+
],
|
|
25
|
+
"derived": [
|
|
26
|
+
"domains",
|
|
27
|
+
"summary",
|
|
28
|
+
"whenNotToUse"
|
|
29
|
+
]
|
|
30
|
+
}
|