@reqvire-org/ads 0.3.44 → 0.3.46
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/README.md +29 -9
- package/dist/a11y.mjs +100 -0
- package/dist/assets.mjs +29 -5
- package/dist/brand-assets.mjs +41 -7
- package/dist/capture/worker.mjs +1 -1
- package/dist/capture-store.mjs +2 -1
- package/dist/capture.mjs +5 -2
- package/dist/check.mjs +2 -1
- package/dist/cli.mjs +33 -9
- package/dist/config.mjs +22 -10
- package/dist/contracts/tokens.json +1 -1
- package/dist/create.mjs +48 -0
- package/dist/design-values.mjs +8 -2
- package/dist/foundation.mjs +3 -0
- package/dist/image-size.mjs +28 -0
- package/dist/index.mjs +1 -0
- package/dist/init.mjs +4 -5
- package/dist/mcp/apps.mjs +1 -1
- package/dist/mcp/preview-widget.bundle.js +19 -13
- package/dist/mcp/project-widget.bundle.js +26 -26
- package/dist/mcp/server.mjs +6 -5
- package/dist/mcp/skills.mjs +1 -1
- package/dist/mcp/widget.bundle.js +15 -15
- package/dist/preview-resources.mjs +2 -2
- package/dist/scenario-groups.mjs +2 -2
- package/dist/scenario-registry.mjs +3 -3
- package/dist/scenarios-compiler.mjs +1 -1
- package/dist/scenarios.mjs +6 -11
- package/dist/showcase/client.bundle.js +27 -27
- package/dist/showcase/draft-navigation.js +1 -1
- package/dist/showcase/index.html +2 -1
- package/dist/skills/ads-break-ui/SKILL.md +1 -1
- package/dist/skills/ads-break-ui/references/captures.md +3 -2
- package/dist/skills/ads-break-ui/references/design-data.md +89 -0
- package/dist/skills/ads-designer/README.md +2 -2
- package/dist/skills/ads-designer/SKILL.md +47 -56
- package/dist/skills/ads-designer/references/accessibility.md +43 -0
- package/dist/skills/ads-designer/references/branding.md +52 -9
- package/dist/skills/ads-designer/references/captures.md +3 -2
- package/dist/skills/ads-designer/references/cli.md +5 -4
- package/dist/skills/ads-designer/references/design-data.md +89 -0
- package/dist/skills/ads-import/SKILL.md +1 -1
- package/dist/skills/ads-import/references/branding.md +4 -3
- package/dist/skills/ads-import/references/captures.md +3 -2
- package/dist/skills/ads-import/references/cli.md +5 -4
- package/dist/skills/ads-import/references/design-data.md +89 -0
- package/dist/skills/ads-motion/SKILL.md +1 -1
- package/dist/skills/ads-motion/references/build.md +33 -0
- package/dist/skills/ads-motion/references/captures.md +3 -2
- package/dist/skills/ads-motion/references/design-data.md +89 -0
- package/dist/skills/ads-motion/references/motion-review.md +2 -2
- package/dist/skills/ads-port/SKILL.md +1 -1
- package/dist/skills/ads-port/references/captures.md +3 -2
- package/dist/skills/ads-port/references/cli.md +5 -4
- package/dist/skills/ads-port/references/design-data.md +89 -0
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +76 -0
- package/dist/{skills/ads-designer/assets/bootstrap-ds-preact → starters/preact}/design-system/review/token-preview/TokenPreview.tsx +10 -1
- package/dist/starters/preact/ds.config.json +32 -0
- package/dist/{bootstrap-ds → starters/react}/README.md +65 -24
- package/dist/{skills/ads-designer/assets/bootstrap-ds → starters/react}/design-system/assets/brand/README.md +1 -1
- package/dist/starters/react/design-system/assets/glyphs/README.md +12 -0
- package/dist/starters/react/design-system/assets/glyphs/aliases.json +1 -0
- package/dist/starters/react/design-system/assets/glyphs/check.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/chevron-down.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/chevron-right.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/close.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/external-link.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/info.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/menu.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/plus.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/search.svg +1 -0
- package/dist/starters/react/design-system/assets/glyphs/warning.svg +1 -0
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +7 -0
- package/dist/{bootstrap-ds/design-system/tokens/Brand.ads.scenario.tsx → starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx} +2 -2
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +7 -0
- package/dist/{skills/ads-designer/assets/bootstrap-ds/design-system/tokens/Brand.ads.scenario.tsx → starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx} +2 -2
- package/dist/{skills/ads-designer/assets/bootstrap-ds → starters/react}/design-system/components/Actions/Button/Button.tsx +11 -4
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.fixture.ts +9 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.scenario.tsx +16 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +44 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/README.md +14 -0
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +15 -0
- package/dist/starters/react/design-system/components/Content/Icon/Icon.tsx +42 -0
- package/dist/starters/react/design-system/components/Content/Icon/README.md +16 -0
- package/dist/starters/react/design-system/components/Content/Icon/glyphs.ts +17 -0
- package/dist/{bootstrap-ds → starters/react}/design-system/components/Forms/TextField/TextField.tsx +9 -5
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +12 -0
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +17 -0
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +75 -0
- package/dist/starters/react/design-system/components/Layout/Grid/README.md +21 -0
- package/dist/{bootstrap-ds → starters/react}/design-system/index.ts +3 -0
- package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +18 -0
- package/dist/{bootstrap-ds → starters/react}/design-system/review/index.ts +1 -0
- package/dist/{skills/ads-designer/assets/bootstrap-ds → starters/react}/design-system/review/token-preview/TokenPreview.tsx +10 -1
- package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +124 -0
- package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +23 -0
- package/dist/{bootstrap-ds/design-system/tokens/SpaceTypeMotion.ads.scenario.tsx → starters/react/design-system/tokens/Layout.ads.scenario.tsx} +1 -1
- package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +18 -0
- package/dist/{skills/ads-designer/assets/bootstrap-ds/design-system/tokens/SpaceTypeMotion.ads.scenario.tsx → starters/react/design-system/tokens/Motion.ads.scenario.tsx} +1 -1
- package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +30 -0
- package/dist/{skills/ads-designer/assets/bootstrap-ds/design-system/tokens/Color.ads.scenario.tsx → starters/react/design-system/tokens/Shape.ads.scenario.tsx} +1 -1
- package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +37 -0
- package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +4 -0
- package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +29 -0
- package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +4 -0
- package/dist/{bootstrap-ds → starters/react}/design-system/tokens/base.css +6 -3
- package/dist/starters/react/design-system/tokens/colors.css +223 -0
- package/dist/starters/react/design-system/tokens/elevation.css +60 -0
- package/dist/starters/react/design-system/tokens/spacing.css +79 -0
- package/dist/starters/react/design-system/tokens/typography.css +31 -0
- package/dist/starters/react/ds.config.json +32 -0
- package/dist/{skills/ads-designer/assets/bootstrap-ds → starters/react}/tsconfig.build.json +2 -1
- package/dist/task-cache.mjs +1 -1
- package/dist/themes.mjs +106 -0
- package/dist/token-export.mjs +58 -0
- package/dist/token-fixtures.mjs +1 -1
- package/dist/token-quality.mjs +109 -0
- package/dist/tokens.mjs +9 -2
- package/dist/units.mjs +6 -6
- package/dist/validation.mjs +1 -1
- package/docs/ADS.md +38 -9
- package/docs/ARCHITECTURE.md +50 -5
- package/docs/CHANGELOG.md +88 -12
- package/docs/GUIDE.md +56 -25
- package/docs/MCP.md +13 -4
- package/package.json +3 -5
- package/dist/bootstrap-ds/design-system/assets/brand/README.md +0 -36
- package/dist/bootstrap-ds/design-system/components/Actions/Button/Button.tsx +0 -49
- package/dist/bootstrap-ds/design-system/review/token-preview/TokenPreview.tsx +0 -119
- package/dist/bootstrap-ds/design-system/tokens/Brand.ads.fixture.ts +0 -12
- package/dist/bootstrap-ds/design-system/tokens/Color.ads.fixture.ts +0 -18
- package/dist/bootstrap-ds/design-system/tokens/SpaceTypeMotion.ads.fixture.ts +0 -36
- package/dist/bootstrap-ds/design-system/tokens/colors.css +0 -29
- package/dist/bootstrap-ds/design-system/tokens/elevation.css +0 -15
- package/dist/bootstrap-ds/design-system/tokens/spacing.css +0 -15
- package/dist/bootstrap-ds/design-system/tokens/typography.css +0 -13
- package/dist/bootstrap-ds/ds.config.json +0 -20
- package/dist/bootstrap-ds/tsconfig.build.json +0 -19
- package/dist/bootstrap-ds-preact/design-system/review/token-preview/TokenPreview.tsx +0 -119
- package/dist/bootstrap-ds-preact/ds.config.json +0 -20
- package/dist/skills/ads-designer/assets/bootstrap-ds/ADS.md +0 -258
- package/dist/skills/ads-designer/assets/bootstrap-ds/README.md +0 -122
- package/dist/skills/ads-designer/assets/bootstrap-ds/biome.css.json +0 -21
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/brand/app-icon.svg +0 -4
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/brand/logo.dark.svg +0 -6
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/brand/logo.svg +0 -6
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/fonts/.gitkeep +0 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Actions/Button/Button.ads.fixture.ts +0 -1
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Actions/Button/Button.ads.scenario.tsx +0 -13
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Actions/Button/README.md +0 -12
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Content/Logo/Logo.ads.fixture.ts +0 -1
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Content/Logo/Logo.ads.scenario.tsx +0 -12
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Content/Logo/Logo.tsx +0 -41
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Content/Logo/README.md +0 -10
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Forms/TextField/README.md +0 -14
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Forms/TextField/TextField.ads.fixture.ts +0 -6
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Forms/TextField/TextField.ads.scenario.tsx +0 -13
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Forms/TextField/TextField.tsx +0 -57
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/composition/Search/SearchPage/README.md +0 -4
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/composition/Search/SearchPage/SearchPage.ads.fixture.ts +0 -7
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/composition/Search/SearchPage/SearchPage.ads.scenario.tsx +0 -16
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/controllers/.gitkeep +0 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/index.ts +0 -8
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/patterns/Search/SearchBar/README.md +0 -12
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/patterns/Search/SearchBar/SearchBar.ads.fixture.ts +0 -1
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/patterns/Search/SearchBar/SearchBar.ads.scenario.tsx +0 -11
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/patterns/Search/SearchBar/SearchBar.tsx +0 -41
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/review/brand-preview/BrandPreview.tsx +0 -115
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/review/index.ts +0 -4
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/showcase/mcp/index.html +0 -1
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/showcase/mcp/main.tsx +0 -8
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/styles.css +0 -5
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/Brand.ads.fixture.ts +0 -12
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/Color.ads.fixture.ts +0 -18
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/SpaceTypeMotion.ads.fixture.ts +0 -36
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/base.css +0 -30
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/colors.css +0 -29
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/elevation.css +0 -15
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/spacing.css +0 -15
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/typography.css +0 -13
- package/dist/skills/ads-designer/assets/bootstrap-ds/ds.config.json +0 -20
- package/dist/skills/ads-designer/assets/bootstrap-ds/gitignore.template +0 -8
- package/dist/skills/ads-designer/assets/bootstrap-ds/package-lock.json +0 -4660
- package/dist/skills/ads-designer/assets/bootstrap-ds/package.json +0 -42
- package/dist/skills/ads-designer/assets/bootstrap-ds/scripts/build-mcp-previews.mjs +0 -3
- package/dist/skills/ads-designer/assets/bootstrap-ds/src/vite-env.d.ts +0 -7
- package/dist/skills/ads-designer/assets/bootstrap-ds/tsconfig.json +0 -35
- package/dist/skills/ads-designer/assets/bootstrap-ds/vite.config.ts +0 -23
- package/dist/skills/ads-designer/assets/bootstrap-ds-preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/skills/ads-designer/assets/bootstrap-ds-preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/skills/ads-designer/assets/bootstrap-ds-preact/design-system/showcase/mcp/main.tsx +0 -6
- package/dist/skills/ads-designer/assets/bootstrap-ds-preact/ds.config.json +0 -20
- package/dist/skills/ads-designer/assets/bootstrap-ds-preact/package.json +0 -38
- package/dist/skills/ads-designer/assets/bootstrap-ds-preact/src/vite-env.d.ts +0 -7
- package/dist/skills/ads-designer/assets/bootstrap-ds-preact/tsconfig.json +0 -36
- package/dist/skills/ads-designer/assets/bootstrap-ds-preact/vite.config.ts +0 -23
- /package/dist/{bootstrap-ds-preact → starters/preact}/design-system/review/demo-frame/DemoFrame.tsx +0 -0
- /package/dist/{bootstrap-ds-preact → starters/preact}/design-system/review/screen-frame/ScreenFrame.tsx +0 -0
- /package/dist/{bootstrap-ds-preact → starters/preact}/design-system/showcase/mcp/main.tsx +0 -0
- /package/dist/{bootstrap-ds-preact → starters/preact}/package.json +0 -0
- /package/dist/{bootstrap-ds-preact → starters/preact}/src/vite-env.d.ts +0 -0
- /package/dist/{bootstrap-ds-preact → starters/preact}/tsconfig.json +0 -0
- /package/dist/{bootstrap-ds-preact → starters/preact}/vite.config.ts +0 -0
- /package/dist/{bootstrap-ds → starters/react}/ADS.md +0 -0
- /package/dist/{bootstrap-ds → starters/react}/biome.css.json +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/assets/brand/app-icon.svg +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/assets/brand/logo.dark.svg +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/assets/brand/logo.svg +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/assets/fonts/.gitkeep +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/components/Actions/Button/Button.ads.fixture.ts +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/components/Actions/Button/Button.ads.scenario.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/components/Actions/Button/README.md +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/components/Content/Logo/Logo.ads.fixture.ts +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/components/Content/Logo/Logo.ads.scenario.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/components/Content/Logo/Logo.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/components/Content/Logo/README.md +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/components/Forms/TextField/README.md +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/components/Forms/TextField/TextField.ads.fixture.ts +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/components/Forms/TextField/TextField.ads.scenario.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/composition/Search/SearchPage/README.md +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/composition/Search/SearchPage/SearchPage.ads.fixture.ts +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/composition/Search/SearchPage/SearchPage.ads.scenario.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/controllers/.gitkeep +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/patterns/Search/SearchBar/README.md +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/patterns/Search/SearchBar/SearchBar.ads.fixture.ts +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/patterns/Search/SearchBar/SearchBar.ads.scenario.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/patterns/Search/SearchBar/SearchBar.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/review/brand-preview/BrandPreview.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/review/demo-frame/DemoFrame.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/review/screen-frame/ScreenFrame.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/showcase/mcp/index.html +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/showcase/mcp/main.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/styles.css +0 -0
- /package/dist/{bootstrap-ds → starters/react}/design-system/tokens/Color.ads.scenario.tsx +0 -0
- /package/dist/{bootstrap-ds → starters/react}/gitignore.template +0 -0
- /package/dist/{bootstrap-ds → starters/react}/package-lock.json +0 -0
- /package/dist/{bootstrap-ds → starters/react}/package.json +0 -0
- /package/dist/{bootstrap-ds → starters/react}/scripts/build-mcp-previews.mjs +0 -0
- /package/dist/{bootstrap-ds → starters/react}/src/vite-env.d.ts +0 -0
- /package/dist/{bootstrap-ds → starters/react}/tsconfig.json +0 -0
- /package/dist/{bootstrap-ds → starters/react}/vite.config.ts +0 -0
package/README.md
CHANGED
|
@@ -64,7 +64,24 @@ and composition previews can use dependency drafts through normal `@ds` imports;
|
|
|
64
64
|
accepting a dependency automatically switches dependent drafts to accepted source.
|
|
65
65
|
Drafts survive restart and Git clone, but cannot enter production imports.
|
|
66
66
|
|
|
67
|
-
##
|
|
67
|
+
## Create a new design system
|
|
68
|
+
|
|
69
|
+
`create` copies the starter shipped in this ADS version into a new folder and sets
|
|
70
|
+
it up, so the project always matches the tool that checks it:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
npx @reqvire-org/ads create my-design-system --framework react # or preact
|
|
74
|
+
cd my-design-system
|
|
75
|
+
npm install
|
|
76
|
+
npm run build
|
|
77
|
+
npm run dev:showcase
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
With Bun: `bunx @reqvire-org/ads create my-design-system --framework preact
|
|
81
|
+
--package-manager bun`, then `bun install` and `bun --bun run build`. `--name` sets
|
|
82
|
+
the package name (default: the folder name).
|
|
83
|
+
|
|
84
|
+
## Set up an existing project
|
|
68
85
|
|
|
69
86
|
Run **inside your project**, where `package.json` lives. Install Bun 1.4.1+ for
|
|
70
87
|
ADS tooling and previews. Your application can continue using Node/npm or Bun.
|
|
@@ -76,8 +93,7 @@ npm run build
|
|
|
76
93
|
```
|
|
77
94
|
|
|
78
95
|
Use `--framework preact` for native Preact. Init saves the choice in
|
|
79
|
-
`ds.config.json`; later runs can use plain `ads init`.
|
|
80
|
-
already declares its framework can also omit the flag.
|
|
96
|
+
`ds.config.json`; later runs can use plain `ads init`.
|
|
81
97
|
|
|
82
98
|
For a Bun project, Node is unnecessary:
|
|
83
99
|
|
|
@@ -233,7 +249,7 @@ happens automatically; no separate project showcase rebuild is needed.
|
|
|
233
249
|
|
|
234
250
|
For an existing app, `init` adds the showcase launch script; it does not install
|
|
235
251
|
a preview compiler. Integrate the [starter compiler and mount adapter](docs/GUIDE.md#showcase)
|
|
236
|
-
with your build.
|
|
252
|
+
with your build. Projects from `ads create` already include that setup.
|
|
237
253
|
|
|
238
254
|
There are no required showcase page files. Add a colocated scenario and fixture
|
|
239
255
|
for tokens and each public UI owner; larger entries live under `composition/`.
|
|
@@ -340,11 +356,15 @@ The [dummy project](tests/fixtures/guard-project/README.md) tests the generic gu
|
|
|
340
356
|
|
|
341
357
|
There are two different starting points in this checkout:
|
|
342
358
|
|
|
343
|
-
- [
|
|
344
|
-
[
|
|
345
|
-
token
|
|
346
|
-
|
|
347
|
-
|
|
359
|
+
- [starters/react/](starters/react/README.md) is the React application starter, and
|
|
360
|
+
[starters/preact/](starters/preact/) the files that replace it for Preact:
|
|
361
|
+
a token foundation in six groups (AA contrast in both themes, a 2 px
|
|
362
|
+
rhythm), light and dark themes declared in `ds.config.json` that apply to the page or one
|
|
363
|
+
section, a column grid, an icon set, a brand preview with placeholder artwork, build
|
|
364
|
+
setup, example components, a pattern and a composition, development-only review
|
|
365
|
+
renderers, and a project preview compiler adapter. They ship in the npm package;
|
|
366
|
+
`ads create` copies them into a new project, and `ads init` uses their foundation
|
|
367
|
+
files when a project has no ADS.
|
|
348
368
|
- [design-system/](design-system/README.md) is this repository's working example,
|
|
349
369
|
with real components, patterns, and scenarios inspected through the built-in showcase. It demonstrates the architecture
|
|
350
370
|
and helps us develop the tooling. Its UI source is excluded from the npm package
|
package/dist/a11y.mjs
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { isDevelopmentFile, isInside, sourceFiles } from "./config.mjs";
|
|
5
|
+
import { parseColor } from "./token-quality.mjs";
|
|
6
|
+
import { baseDefinition } from "./themes.mjs";
|
|
7
|
+
|
|
8
|
+
// Accessibility guards ADS can check without a browser: token values (WCAG target size,
|
|
9
|
+
// focus, text resize, reduced motion, text spacing) and runtime component source (text
|
|
10
|
+
// alternatives, keyboard reach, autoplaying motion). All are advisories with WCAG references.
|
|
11
|
+
|
|
12
|
+
const advisory = (rule, { file, line = 1, column = 1 }, message, tokens) => ({ rule, severity: "warning", file, line, column, ...(tokens ? { tokens } : {}), guidanceUri: "ads://guides/accessibility", message });
|
|
13
|
+
/** Pixels of a px/rem length, or null. */
|
|
14
|
+
const pixels = value => {
|
|
15
|
+
const match = value.trim().match(/^(\d*\.?\d+)(px|rem)$/);
|
|
16
|
+
return match ? Number(match[1]) * (match[2] === "rem" ? 16 : 1) : null;
|
|
17
|
+
};
|
|
18
|
+
const isAlias = value => value.trim().startsWith("var(");
|
|
19
|
+
|
|
20
|
+
/** Token-level guards over the inventory's definitions and the foundation sheet. */
|
|
21
|
+
export function a11yTokenAdvisories(tokens, { foundationFile, root } = {}) {
|
|
22
|
+
const advisories = [];
|
|
23
|
+
const base = baseDefinition;
|
|
24
|
+
for (const token of tokens) {
|
|
25
|
+
const root = base(token);
|
|
26
|
+
if (!root || isAlias(root.value)) continue;
|
|
27
|
+
if (token.name.startsWith("--control-height-")) {
|
|
28
|
+
const size = pixels(root.value);
|
|
29
|
+
if (size !== null && size < 24) advisories.push(advisory("a11y-target-size", root, `${token.name} is ${size}px; pointer targets need at least 24×24 px (WCAG 2.5.8), 44 px where touch is common.`, [token.name]));
|
|
30
|
+
}
|
|
31
|
+
if (token.name === "--focus-w") {
|
|
32
|
+
const size = pixels(root.value);
|
|
33
|
+
if (size !== null && size < 2) advisories.push(advisory("a11y-focus", root, `--focus-w is ${size}px; focus indicators need at least 2 px to stay visible (WCAG 2.4.7, 2.4.13).`, [token.name]));
|
|
34
|
+
}
|
|
35
|
+
// Font sizes, not text colors: a px size ignores the reader's browser font size.
|
|
36
|
+
if (token.name.startsWith("--text-") && !parseColor(root.value) && /\d(?:\.\d+)?px\b/.test(root.value) && !/\d(?:\.\d+)?r?em\b/.test(root.value)) {
|
|
37
|
+
advisories.push(advisory("a11y-text-resize", root, `${token.name} is ${root.value.trim()}; use rem so text follows the reader's font size (WCAG 1.4.4).`, [token.name]));
|
|
38
|
+
}
|
|
39
|
+
if (token.name.startsWith("--dur-") && !/^0(?:m?s)?$/.test(root.value.trim()) && !token.definitions.some(definition => /prefers-reduced-motion/.test(definition.scope))) {
|
|
40
|
+
advisories.push(advisory("a11y-reduced-motion", root, `${token.name} has no value under @media (prefers-reduced-motion: reduce); set it to 0ms there (WCAG 2.3.3).`, [token.name]));
|
|
41
|
+
}
|
|
42
|
+
if (token.name === "--leading-normal") {
|
|
43
|
+
const value = Number(root.value.trim());
|
|
44
|
+
if (Number.isFinite(value) && value < 1.5) advisories.push(advisory("a11y-text-spacing", root, `--leading-normal is ${value}; body text needs a line height of at least 1.5 (WCAG 1.4.8, 1.4.12).`, [token.name]));
|
|
45
|
+
}
|
|
46
|
+
if (token.name === "--content-max") {
|
|
47
|
+
const match = root.value.trim().match(/^(\d*\.?\d+)ch$/);
|
|
48
|
+
if (match && Number(match[1]) > 80) advisories.push(advisory("a11y-text-spacing", root, `--content-max is ${match[1]}ch; keep text lines under 80 characters (WCAG 1.4.8).`, [token.name]));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (foundationFile && existsSync(foundationFile) && !/:focus-visible\b/.test(readFileSync(foundationFile, "utf8"))) {
|
|
52
|
+
advisories.push(advisory("a11y-focus", { file: path.relative(root, foundationFile).replaceAll("\\", "/") }, "The foundation styles no :focus-visible indicator; keyboard users must see where focus is (WCAG 2.4.7)."));
|
|
53
|
+
}
|
|
54
|
+
return advisories;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const nonInteractive = new Set(["div", "span", "p", "li", "section", "article", "td", "img", "header", "footer", "main", "aside"]);
|
|
58
|
+
// Children of composite widgets: the container owns focus (aria-activedescendant or roving).
|
|
59
|
+
const managedRoles = new Set(["option", "menuitem", "menuitemcheckbox", "menuitemradio", "tab", "treeitem", "row", "gridcell"]);
|
|
60
|
+
/** Source guards over runtime components and patterns (not previews, fixtures or tests). */
|
|
61
|
+
export function a11ySourceAdvisories({ root, dsRoot }) {
|
|
62
|
+
const advisories = [];
|
|
63
|
+
const options = { root, dsRoot };
|
|
64
|
+
const files = sourceFiles(dsRoot).filter(file => /\.[jt]sx$/.test(file) && ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file)) && !isDevelopmentFile(file, options) && !/\.test\.|\.spec\./.test(file));
|
|
65
|
+
for (const file of files) {
|
|
66
|
+
const text = readFileSync(file, "utf8"), relative = path.relative(root, file).replaceAll("\\", "/");
|
|
67
|
+
const source = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
68
|
+
const at = node => { const { line, character } = source.getLineAndCharacterOfPosition(node.getStart(source)); return { file: relative, line: line + 1, column: character + 1 }; };
|
|
69
|
+
const visit = node => {
|
|
70
|
+
if (ts.isJsxSelfClosingElement(node) || ts.isJsxOpeningElement(node)) {
|
|
71
|
+
const tag = node.tagName.getText(source);
|
|
72
|
+
const attributes = node.attributes.properties;
|
|
73
|
+
const spread = attributes.some(ts.isJsxSpreadAttribute);
|
|
74
|
+
const names = new Set(attributes.filter(ts.isJsxAttribute).map(attribute => attribute.name.getText(source)));
|
|
75
|
+
if (tag === "img" && !spread && !names.has("alt")) advisories.push(advisory("a11y-image-alt", at(node), `<img> needs alt text, or alt="" when it is decorative (WCAG 1.1.1).`));
|
|
76
|
+
// A button or link whose only content is an icon, SVG or image has no accessible name.
|
|
77
|
+
if (ts.isJsxOpeningElement(node) && ["button", "a"].includes(tag) && !spread && !["aria-label", "aria-labelledby", "title"].some(name => names.has(name))) {
|
|
78
|
+
const children = node.parent.children.filter(child => !(ts.isJsxText(child) && !child.text.trim()));
|
|
79
|
+
const graphic = child => ts.isJsxSelfClosingElement(child) && (/Icon|Glyph|Svg/i.test(child.tagName.getText(source)) || ["svg", "img"].includes(child.tagName.getText(source)));
|
|
80
|
+
if (children.length && children.every(graphic)) advisories.push(advisory("a11y-icon-label", at(node), `<${tag}> shows only an icon and has no accessible name; add aria-label (or use IconButton with a label) (WCAG 4.1.2).`));
|
|
81
|
+
}
|
|
82
|
+
const attribute = name => attributes.find(item => ts.isJsxAttribute(item) && item.name.getText(source) === name);
|
|
83
|
+
const role = attribute("role")?.initializer?.getText(source).replace(/^["'{]+|["'}]+$/g, "");
|
|
84
|
+
// A backdrop that closes on its own click repeats Escape; it is not the keyboard path.
|
|
85
|
+
const backdrop = /currentTarget/.test(attribute("onClick")?.getText(source) ?? "");
|
|
86
|
+
if (nonInteractive.has(tag) && !spread && names.has("onClick") && !backdrop && !managedRoles.has(role) && !(role && names.has("tabIndex"))) {
|
|
87
|
+
advisories.push(advisory("a11y-keyboard", at(node), `<${tag} onClick> cannot be reached or used from the keyboard; use a <button>, or add role, tabIndex and a key handler (WCAG 2.1.1).`));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
ts.forEachChild(node, visit);
|
|
91
|
+
};
|
|
92
|
+
visit(source);
|
|
93
|
+
// Motion that never stops must yield to the reader's reduced-motion setting.
|
|
94
|
+
if (/animation(?:-iteration-count)?\s*:[^;`]*\binfinite\b/.test(text) && !/prefers-reduced-motion/.test(text)) {
|
|
95
|
+
const index = text.search(/\binfinite\b/), line = text.slice(0, index).split("\n").length;
|
|
96
|
+
advisories.push(advisory("a11y-reduced-motion", { file: relative, line }, "An infinite animation runs without a prefers-reduced-motion guard; stop it under @media (prefers-reduced-motion: reduce), or let the user pause it (WCAG 2.2.2, 2.3.3)."));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return advisories;
|
|
100
|
+
}
|
package/dist/assets.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { isInside } from "./config.mjs";
|
|
4
|
+
import { brandFormats, isInside } from "./config.mjs";
|
|
5
5
|
import { brandFiles, brandSourceDiagnostic, staleBrandOutputs } from "./brand-assets.mjs";
|
|
6
6
|
|
|
7
7
|
function assetFiles(directory, prefix = "") {
|
|
@@ -35,13 +35,37 @@ function sourceTexts(directories, skipped) {
|
|
|
35
35
|
return texts;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/** A glyph set draws in currentColor on one shared viewBox, so icons follow text color and size. */
|
|
39
|
+
function inspectGlyphs({ root, dsRoot, config }) {
|
|
40
|
+
const glyphs = config.assets.glyphs;
|
|
41
|
+
if (!glyphs) return [];
|
|
42
|
+
const directory = path.join(dsRoot, glyphs.source);
|
|
43
|
+
const files = assetFiles(directory).filter(file => file.toLowerCase().endsWith(".svg"));
|
|
44
|
+
const read = files.map(file => ({ file: path.join(directory, file), text: readFileSync(path.join(directory, file), "utf8") }));
|
|
45
|
+
const warn = (rule, file, message) => ({ rule, severity: "warning", file: path.relative(root, file).replaceAll("\\", "/"), line: 1, column: 1, guidanceUri: "ads://guides/branding", message });
|
|
46
|
+
const viewBox = text => text.match(/<svg\b[^>]*\bviewBox\s*=\s*["']([^"']+)["']/)?.[1]?.trim().replace(/\s+/g, " ") ?? null;
|
|
47
|
+
const counts = new Map();
|
|
48
|
+
for (const { text } of read) { const box = viewBox(text); if (box) counts.set(box, (counts.get(box) ?? 0) + 1); }
|
|
49
|
+
const shared = [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
50
|
+
const findings = [];
|
|
51
|
+
for (const { file, text } of read) {
|
|
52
|
+
const base = path.basename(file), box = viewBox(text);
|
|
53
|
+
if (!box) findings.push(warn("glyph-viewbox", file, `${base} has no viewBox; glyphs need one shared viewBox to draw at the same size.`));
|
|
54
|
+
else if (shared && box !== shared) findings.push(warn("glyph-viewbox", file, `${base} uses viewBox "${box}"; the set uses "${shared}", so it would draw at a different size.`));
|
|
55
|
+
// Any fill or stroke other than none or currentColor fixes the icon's color.
|
|
56
|
+
const colors = [...text.matchAll(/\b(fill|stroke)\s*[=:]\s*["']?\s*([^"';\s>]+)/g)].map(match => match[2]).filter(value => !/^(?:none|currentcolor|inherit)$/i.test(value) && !/^url\(/i.test(value));
|
|
57
|
+
if (colors.length) findings.push(warn("glyph-color", file, `${base} sets ${[...new Set(colors)].join(", ")}; draw glyphs in currentColor so they follow the text color and theme. A logo that must keep its colors (another product's mark) belongs in assets/brand/, shown as an image.`));
|
|
58
|
+
}
|
|
59
|
+
return findings;
|
|
60
|
+
}
|
|
61
|
+
|
|
38
62
|
/** Brand artwork is documented, licensed, previewed and used. Generated outputs match their masters. */
|
|
39
63
|
function inspectBrand({ root, dsRoot, config }) {
|
|
40
64
|
const diagnostics = [];
|
|
41
65
|
const relative = file => path.relative(root, file).replaceAll("\\", "/") || ".";
|
|
42
66
|
for (const { file, message } of staleBrandOutputs({ root, dsRoot, config })) diagnostics.push({ rule: "brand-output-stale", file, line: 1, column: 1, message });
|
|
43
67
|
const brand = path.join(dsRoot, "assets/brand");
|
|
44
|
-
const artwork = assetFiles(brand).filter(file =>
|
|
68
|
+
const artwork = assetFiles(brand).filter(file => brandFormats.includes(path.extname(file).toLowerCase()));
|
|
45
69
|
if (!artwork.length) return diagnostics;
|
|
46
70
|
const warn = (rule, file, message) => diagnostics.push({ rule, severity: "warning", file: relative(file), line: 1, column: 1, guidanceUri: "ads://guides/branding", message });
|
|
47
71
|
const readmeFile = path.join(brand, "README.md");
|
|
@@ -51,12 +75,12 @@ function inspectBrand({ root, dsRoot, config }) {
|
|
|
51
75
|
const generated = [...config.assets.generatedPaths.map(entry => path.resolve(root, entry)), path.join(root, ".ds")];
|
|
52
76
|
const sources = sourceTexts([dsRoot, path.join(root, config.sourceDir ?? "src")], [path.join(dsRoot, "assets"), ...generated]);
|
|
53
77
|
const configured = new Set([config.assets.iconSource, ...config.assets.targets.map(target => target.from)].filter(Boolean).map(file => path.join(dsRoot, file)));
|
|
54
|
-
const previews = path.join(dsRoot,
|
|
78
|
+
const previews = path.join(dsRoot, "brand");
|
|
55
79
|
for (const name of artwork) {
|
|
56
80
|
const file = path.join(brand, name), base = path.basename(name);
|
|
57
81
|
if (readme !== null && !readme.includes(base)) warn("brand-readme", file, `Describe ${base} in assets/brand/README.md: its use, suitable backgrounds, credits and license.`);
|
|
58
82
|
const referencing = sources.filter(source => source.text.includes(base));
|
|
59
|
-
if (!referencing.some(source => isInside(previews, source.file) && previewFile.test(source.file))) warn("brand-preview", file, `Show ${base} in a
|
|
83
|
+
if (!referencing.some(source => isInside(previews, source.file) && previewFile.test(source.file))) warn("brand-preview", file, `Show ${base} in a brand/ scenario, so it can be reviewed in the showcase's Brand section.`);
|
|
60
84
|
if (!configured.has(file) && !referencing.some(source => !previewFile.test(source.file))) warn("brand-unused", file, `${base} is not used by any component, assets.iconSource or assets.targets. Use it or remove it.`);
|
|
61
85
|
}
|
|
62
86
|
return diagnostics;
|
|
@@ -66,7 +90,7 @@ export function inspectAssets({ root, dsRoot, config, trackingRoot = root }) {
|
|
|
66
90
|
const diagnostics = [];
|
|
67
91
|
const sourceDiagnostic = brandSourceDiagnostic({ root, dsRoot, config });
|
|
68
92
|
if (sourceDiagnostic) diagnostics.push(sourceDiagnostic);
|
|
69
|
-
diagnostics.push(...inspectBrand({ root, dsRoot, config }));
|
|
93
|
+
diagnostics.push(...inspectBrand({ root, dsRoot, config }), ...inspectGlyphs({ root, dsRoot, config }));
|
|
70
94
|
function report(rule, file, message) { diagnostics.push({ rule, file: path.relative(root, file).replaceAll("\\", "/") || ".", line: 1, column: 1, message }); }
|
|
71
95
|
const assetRoot = path.join(dsRoot, "assets");
|
|
72
96
|
// Every mount is compared with the canonical ADS assets. Public mounts are
|
package/dist/brand-assets.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { isInside, loadConfig } from "./config.mjs";
|
|
5
|
+
import { imageSize } from "./image-size.mjs";
|
|
5
6
|
|
|
6
7
|
export const brandFiles = ["favicon.svg", "favicon.ico", "apple-touch-icon.png", "icon-192.png", "icon-512.png"];
|
|
7
8
|
|
|
@@ -14,8 +15,15 @@ export function brandSourceDiagnostic({ root, dsRoot, config }) {
|
|
|
14
15
|
if (!stat || stat.isSymbolicLink() || (current === file ? !stat.isFile() : !stat.isDirectory())) valid = false;
|
|
15
16
|
if (current === root) break;
|
|
16
17
|
}
|
|
18
|
+
const relative = path.relative(root, file).replaceAll("\\", "/");
|
|
19
|
+
if (valid && !file.toLowerCase().endsWith(".svg")) {
|
|
20
|
+
// A finished image is a master only when it is square and big enough for the largest icon.
|
|
21
|
+
const size = imageSize(readFileSync(file));
|
|
22
|
+
if (size && size.width === size.height && size.width >= 512) return null;
|
|
23
|
+
return { rule: "asset-source", file: relative, line: 1, column: 1, message: `assets.iconSource ${size ? `is ${size.width}×${size.height}; it` : "is not a readable PNG, JPEG or WebP; it"} must be a square image of at least 512×512, or an SVG.` };
|
|
24
|
+
}
|
|
17
25
|
if (valid && /<svg\b[\s\S]*<\/svg\s*>|<svg\b[^>]*\/>/i.test(readFileSync(file, "utf8"))) return null;
|
|
18
|
-
return { rule: "asset-source", file:
|
|
26
|
+
return { rule: "asset-source", file: relative, line: 1, column: 1, message: "assets.iconSource must be an existing SVG master inside assets/brand/, without symlinked paths." };
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
function assertOutput(root, file, { directory = false } = {}) {
|
|
@@ -78,12 +86,29 @@ function icns(entries) {
|
|
|
78
86
|
return Buffer.concat([header, ...chunks]);
|
|
79
87
|
}
|
|
80
88
|
|
|
89
|
+
const sized = target => ["size", "width", "height", "sizes", "background"].some(key => key in target);
|
|
90
|
+
/** A copy of the supplied file: the same format, no sizes. */
|
|
91
|
+
export const copiesTarget = target => !sized(target) && path.extname(target.to).toLowerCase() === path.extname(target.from).toLowerCase();
|
|
92
|
+
|
|
93
|
+
/** Why a raster master cannot make this target: ADS never enlarges a finished image. */
|
|
94
|
+
export function targetUpscale(source, target) {
|
|
95
|
+
if (copiesTarget(target) || target.from.toLowerCase().endsWith(".svg")) return null;
|
|
96
|
+
const size = imageSize(source);
|
|
97
|
+
if (!size) return `${target.from} is not a readable PNG, JPEG or WebP.`;
|
|
98
|
+
const sizes = target.sizes ?? [];
|
|
99
|
+
const width = target.width ?? target.size ?? Math.max(...sizes), height = target.height ?? target.size ?? Math.max(...sizes);
|
|
100
|
+
return Math.min(width / size.width, height / size.height) > 1 ? `${target.to} would enlarge ${target.from} (${size.width}×${size.height}) to ${width}×${height}. Supply a larger image or an SVG master.` : null;
|
|
101
|
+
}
|
|
102
|
+
|
|
81
103
|
async function renderTarget(sharp, source, target) {
|
|
82
104
|
const format = path.extname(target.to).toLowerCase();
|
|
83
|
-
if (
|
|
105
|
+
if (copiesTarget(target)) return source;
|
|
106
|
+
const upscale = targetUpscale(source, target);
|
|
107
|
+
if (upscale) throw new Error(upscale);
|
|
108
|
+
const vector = target.from.toLowerCase().endsWith(".svg");
|
|
84
109
|
const background = target.background;
|
|
85
110
|
const png = async (width, height) => {
|
|
86
|
-
let image = sharp(source, { density: Math.max(72, Math.ceil(Math.max(width, height) * 1.5)) })
|
|
111
|
+
let image = sharp(source, vector ? { density: Math.max(72, Math.ceil(Math.max(width, height) * 1.5)) } : {})
|
|
87
112
|
.resize(width, height, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 } });
|
|
88
113
|
if (background) image = image.flatten({ background });
|
|
89
114
|
return image.png().toBuffer();
|
|
@@ -129,6 +154,9 @@ export function staleBrandOutputs(options) {
|
|
|
129
154
|
const file = path.join(root, target.to);
|
|
130
155
|
const entry = recorded[target.to];
|
|
131
156
|
let reason = null;
|
|
157
|
+
if (!existsSync(path.join(dsRoot, target.from))) { stale.push({ file: target.to, message: `${target.to} names a missing master ${target.from}.` }); continue; }
|
|
158
|
+
const upscale = targetUpscale(readFileSync(path.join(dsRoot, target.from)), target);
|
|
159
|
+
if (upscale) { stale.push({ file: target.to, message: upscale }); continue; }
|
|
132
160
|
if (!existsSync(file)) reason = "is missing";
|
|
133
161
|
else if (!entry || entry.fingerprint !== fingerprint(dsRoot, target)) reason = `no longer matches ${target.from} or its settings`;
|
|
134
162
|
else if (entry.sha256 !== sha256(readFileSync(file))) reason = "was changed by hand";
|
|
@@ -152,6 +180,7 @@ async function generateCommitted(options) {
|
|
|
152
180
|
let sharp;
|
|
153
181
|
for (const target of config.assets.targets) {
|
|
154
182
|
const file = path.join(root, target.to);
|
|
183
|
+
if (!existsSync(path.join(dsRoot, target.from))) throw new Error(`${target.to} names a missing master ${target.from}.`);
|
|
155
184
|
const print = fingerprint(dsRoot, target);
|
|
156
185
|
const entry = recorded[target.to];
|
|
157
186
|
if (entry?.fingerprint === print && existsSync(file) && entry.sha256 === sha256(readFileSync(file))) { next[target.to] = entry; continue; }
|
|
@@ -196,10 +225,12 @@ export async function generateBrandAssets(directory = process.cwd()) {
|
|
|
196
225
|
// before writing, so invalid SVG cannot replace the last successful outputs.
|
|
197
226
|
const { default: sharp } = await import("sharp");
|
|
198
227
|
const source = readFileSync(path.join(dsRoot, config.assets.iconSource));
|
|
199
|
-
const
|
|
228
|
+
const vector = config.assets.iconSource.toLowerCase().endsWith(".svg");
|
|
229
|
+
// Only an SVG master is also the SVG favicon; a finished image makes the rest.
|
|
230
|
+
const outputs = new Map(vector ? [["favicon.svg", source]] : []);
|
|
200
231
|
const sizes = [16, 32, 48, 180, 192, 512];
|
|
201
232
|
const rendered = new Map();
|
|
202
|
-
for (const size of sizes) rendered.set(size, await sharp(source, { density: 512 }).resize(size, size, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 } }).png().toBuffer());
|
|
233
|
+
for (const size of sizes) rendered.set(size, await sharp(source, vector ? { density: 512 } : {}).resize(size, size, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 } }).png().toBuffer());
|
|
203
234
|
outputs.set("favicon.ico", ico([16, 32, 48].map((size) => ({ size, buffer: rendered.get(size) }))));
|
|
204
235
|
outputs.set("apple-touch-icon.png", rendered.get(180));
|
|
205
236
|
outputs.set("icon-192.png", rendered.get(192));
|
|
@@ -209,7 +240,10 @@ export async function generateBrandAssets(directory = process.cwd()) {
|
|
|
209
240
|
try {
|
|
210
241
|
for (const [name, buffer] of outputs) writeFileSync(path.join(staging, name), buffer);
|
|
211
242
|
mkdirSync(output, { recursive: true });
|
|
212
|
-
for (const name of brandFiles)
|
|
243
|
+
for (const name of brandFiles) {
|
|
244
|
+
if (outputs.has(name)) renameSync(path.join(staging, name), path.join(output, name));
|
|
245
|
+
else rmSync(path.join(output, name), { force: true });
|
|
246
|
+
}
|
|
213
247
|
} finally { rmSync(staging, { recursive: true, force: true }); }
|
|
214
|
-
return { directory: output, files:
|
|
248
|
+
return { directory: output, files: [...outputs.keys()].map((name) => path.join(output, name)), committed, skipped: false };
|
|
215
249
|
}
|
package/dist/capture/worker.mjs
CHANGED
|
@@ -11,7 +11,7 @@ try {
|
|
|
11
11
|
browser = await playwright[request.settings.browser].launch({ headless: true, ...(request.settings.channel ? { channel: request.settings.channel } : {}) });
|
|
12
12
|
const images = [];
|
|
13
13
|
for (const [index, app] of request.apps.entries()) {
|
|
14
|
-
const context = await browser.newContext({ viewport: app.viewport, deviceScaleFactor: 1, colorScheme: app.
|
|
14
|
+
const context = await browser.newContext({ viewport: app.viewport, deviceScaleFactor: 1, colorScheme: app.scheme });
|
|
15
15
|
try {
|
|
16
16
|
const page = await context.newPage(), timeout = request.settings.timeoutMs;
|
|
17
17
|
const frame = await openPreviewScenario(page, app.url, app.scenario, { timeout });
|
package/dist/capture-store.mjs
CHANGED
|
@@ -7,7 +7,8 @@ export const CAPTURES_URI = "ads://project/captures";
|
|
|
7
7
|
export const captureLimits = { selections: 8, imageBytes: 4 * 1024 * 1024, pixels: 8 * 1024 * 1024, storeBytes: 256 * 1024 * 1024, pairBytes: 12 * 1024 * 1024 };
|
|
8
8
|
export const captureSpec = z.object({
|
|
9
9
|
scenario: z.string().min(1).max(256), target: z.string().regex(/^[a-zA-Z0-9][\w.-]{0,79}$/).optional(),
|
|
10
|
-
theme
|
|
10
|
+
// A declared theme's name; the project's default theme when omitted.
|
|
11
|
+
theme: z.string().regex(/^[a-z][a-z0-9-]{0,31}$/).optional(),
|
|
11
12
|
viewport: z.object({ width: z.number().int().min(100).max(4096), height: z.number().int().min(100).max(4096) }).strict().default({ width: 1280, height: 800 }),
|
|
12
13
|
animations: z.enum(["disabled", "allow"]).default("disabled"),
|
|
13
14
|
}).strict().refine(value => value.viewport.width * value.viewport.height <= captureLimits.pixels, "Capture viewport exceeds 8 megapixels.");
|
package/dist/capture.mjs
CHANGED
|
@@ -80,9 +80,12 @@ export function createCaptureController(root) {
|
|
|
80
80
|
const host = previewHosts[projectIndex] ?? await startAdsMcp(project.options.root, { stdio: false, showcase: true });
|
|
81
81
|
if(!previewHosts[projectIndex])ownedHosts.push(host);
|
|
82
82
|
hosts.push(host);
|
|
83
|
+
const themes = project.options.config.themes;
|
|
83
84
|
for (const selection of project.apps) {
|
|
84
|
-
const
|
|
85
|
-
|
|
85
|
+
const theme = themes.find(item => item.name === (selection.theme ?? themes[0].name));
|
|
86
|
+
if (!theme) throw new Error(`Unknown theme "${selection.theme}"; the project declares ${themes.map(item => item.name).join(", ")}.`);
|
|
87
|
+
const url = new URL(host.url); url.searchParams.set("scenario", selection.scenario); url.searchParams.set("capture", "1"); url.searchParams.set("theme", theme.name);
|
|
88
|
+
apps.push({ ...selection, theme: theme.name, scheme: theme.scheme, projectIndex, url: url.href });
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
const request = path.join(temporary, "request.json"), report = path.join(temporary, "report.json"), runId = randomUUID();
|
package/dist/check.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { importViolation, isInside, loadConfig, sourceFiles, isDevelopmentFile,
|
|
|
7
7
|
import { inspectTokens, references } from "./tokens.mjs";
|
|
8
8
|
import { foundationFiles, foundationImportTarget, isSharedToken } from "./token-policy.mjs";
|
|
9
9
|
import { inspectAssets } from "./assets.mjs";
|
|
10
|
+
import { a11ySourceAdvisories } from "./a11y.mjs";
|
|
10
11
|
import { appImportViolation, showcaseImportViolation, checkComponentVariable, importResolver, projectCompilerOptions, isUiCssProperties, styleWriteViolation } from "./boundaries.mjs";
|
|
11
12
|
import { inspectPublicProps } from "./public-props.mjs";
|
|
12
13
|
import { adsFileRole } from "./config.mjs";
|
|
@@ -338,7 +339,7 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
338
339
|
inspectDesignAliases(layerStyles,options,report);
|
|
339
340
|
// Bounded clients should see actionable warnings before source-analysis limits.
|
|
340
341
|
for (const { file, css, offset } of layerStyles) layers.inspectStyles(file, css, offset);
|
|
341
|
-
advisories.push(...(tokenInventory.advisories??[]), ...assetAdvisories);
|
|
342
|
+
advisories.push(...(tokenInventory.advisories??[]), ...assetAdvisories, ...a11ySourceAdvisories(options));
|
|
342
343
|
advisories.sort((first, second) => Number(first.severity === "info") - Number(second.severity === "info"));
|
|
343
344
|
const uniqueDiagnostics=[...new Map(diagnostics.map(diagnostic=>[JSON.stringify([diagnostic.file,diagnostic.rule,diagnostic.line,diagnostic.column,diagnostic.message]),diagnostic])).values()];
|
|
344
345
|
return architectureEvidence({ ok: uniqueDiagnostics.length === 0, diagnostics:uniqueDiagnostics, ...(advisories.length ? { advisories } : {}) });
|
package/dist/cli.mjs
CHANGED
|
@@ -8,9 +8,11 @@ import { assertBunRuntime } from "./runtime-requirements.mjs";
|
|
|
8
8
|
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
9
9
|
const help = `ADS ${pkg.version} — tooling for a project's local design system
|
|
10
10
|
|
|
11
|
-
Usage: ads
|
|
11
|
+
Usage: ads create <directory> --framework react|preact New design-system project
|
|
12
|
+
ads init [options] Run inside your project
|
|
12
13
|
ads <command> [directory] [--json]
|
|
13
14
|
|
|
15
|
+
create <directory> Create a project from this version's starter, then init it
|
|
14
16
|
init Set up ADS in the current project (requires package.json)
|
|
15
17
|
check [directory] Check tokens, ownership, imports, and showcase coverage
|
|
16
18
|
compile [directory] Build ADS previews with Bun (--watch for incremental previews)
|
|
@@ -19,6 +21,8 @@ Usage: ads init [options] Run inside your project
|
|
|
19
21
|
behaviors [dir] Inspect behavior contracts and current verification evidence
|
|
20
22
|
verify [directory] Run registered behavior checks (--unit and --check select)
|
|
21
23
|
tokens [directory] Inspect local token values and theme definitions
|
|
24
|
+
--format dtcg prints them as W3C Design Tokens JSON;
|
|
25
|
+
--theme <name> exports that theme's values (default: the first)
|
|
22
26
|
assets [directory] Generate standard web icons in .ds/assets from assets.iconSource
|
|
23
27
|
lint-config [dir] Generate .ds/oxlintrc.json with core and project plugins
|
|
24
28
|
mcp [directory] Serve stdio MCP tools/Apps and the local showcase website
|
|
@@ -26,9 +30,10 @@ Usage: ads init [options] Run inside your project
|
|
|
26
30
|
|
|
27
31
|
--help Show this help
|
|
28
32
|
--version Show the tool version
|
|
29
|
-
--framework name
|
|
30
|
-
--
|
|
31
|
-
--package
|
|
33
|
+
--framework name Create/init: react or preact (required until saved in config)
|
|
34
|
+
--name name Create only: package name (default: the folder name)
|
|
35
|
+
--tool-package spec Create/init: tool version or local tarball for devDependency
|
|
36
|
+
--package-manager pm Create/init: npm or bun (create default npm; init detects it)
|
|
32
37
|
--port number MCP/showcase only: loopback website port (default: automatic)
|
|
33
38
|
--no-showcase MCP only: disable the local website
|
|
34
39
|
--mutations MCP only: enable guarded ADS source editing
|
|
@@ -49,6 +54,8 @@ async function main(args) {
|
|
|
49
54
|
let toolPackage;
|
|
50
55
|
let packageManager;
|
|
51
56
|
let framework;
|
|
57
|
+
let name;
|
|
58
|
+
let format, theme;
|
|
52
59
|
let port;
|
|
53
60
|
let unit;
|
|
54
61
|
const selectedChecks = [];
|
|
@@ -82,6 +89,15 @@ async function main(args) {
|
|
|
82
89
|
} else if (argument === "--package-manager") {
|
|
83
90
|
if (packageManager !== undefined || !args[index + 1] || args[index + 1].startsWith("-")) throw new Error("Specify one package manager after --package-manager: npm or bun.");
|
|
84
91
|
packageManager = args[++index];
|
|
92
|
+
} else if (argument === "--theme") {
|
|
93
|
+
if (theme !== undefined || !args[index + 1] || args[index + 1].startsWith("--")) throw new Error("Specify --theme <name>.");
|
|
94
|
+
theme = args[++index];
|
|
95
|
+
} else if (argument === "--format") {
|
|
96
|
+
if (format !== undefined || args[index + 1] !== "dtcg") throw new Error("Specify --format dtcg (the W3C Design Tokens format).");
|
|
97
|
+
format = args[++index];
|
|
98
|
+
} else if (argument === "--name") {
|
|
99
|
+
if (name !== undefined || !args[index + 1] || args[index + 1].startsWith("-")) throw new Error("Specify one package name after --name.");
|
|
100
|
+
name = args[++index];
|
|
85
101
|
} else if (argument === "--framework") {
|
|
86
102
|
if (framework !== undefined || !args[index + 1] || args[index + 1].startsWith("-")) throw new Error("Specify one framework after --framework: react or preact.");
|
|
87
103
|
framework = args[++index];
|
|
@@ -90,7 +106,7 @@ async function main(args) {
|
|
|
90
106
|
}
|
|
91
107
|
if (positional.length > 2) throw new Error("Extra argument. Run ads --help.");
|
|
92
108
|
const [command, directory] = positional;
|
|
93
|
-
if(command!=="init"){
|
|
109
|
+
if(command!=="init"&&command!=="create"){
|
|
94
110
|
const exitCode=await enterMemoryBudget(loadConfig(path.resolve(directory??process.cwd())).config,args);
|
|
95
111
|
if(exitCode!==null){process.exitCode=exitCode;return;}
|
|
96
112
|
}
|
|
@@ -103,9 +119,14 @@ async function main(args) {
|
|
|
103
119
|
if ((port !== undefined || !showcase) && !["mcp", "showcase"].includes(command)) throw new Error("Website options are supported only by mcp/showcase.");
|
|
104
120
|
if (!showcase && command !== "mcp") throw new Error("--no-showcase is supported only by mcp.");
|
|
105
121
|
if (mutations && command !== "mcp") throw new Error("--mutations is supported only by mcp.");
|
|
106
|
-
|
|
107
|
-
if (
|
|
108
|
-
if (
|
|
122
|
+
const setup = command === "init" || command === "create";
|
|
123
|
+
if (toolPackage !== undefined && !setup) throw new Error("--tool-package is supported only by create and init.");
|
|
124
|
+
if (packageManager !== undefined && !setup) throw new Error("--package-manager is supported only by create and init.");
|
|
125
|
+
if (framework !== undefined && !setup) throw new Error("--framework is supported only by create and init.");
|
|
126
|
+
if (name !== undefined && command !== "create") throw new Error("--name is supported only by create.");
|
|
127
|
+
if (format !== undefined && command !== "tokens") throw new Error("--format is supported only by tokens.");
|
|
128
|
+
if (theme !== undefined && format !== "dtcg") throw new Error("--theme is supported only by tokens --format dtcg.");
|
|
129
|
+
if (command === "create" && !directory) throw new Error("Name the new project's folder: ads create <directory> --framework react|preact.");
|
|
109
130
|
if (command === "init" && directory) throw new Error("Run ads init inside the project, without a directory argument.");
|
|
110
131
|
if ((unit || selectedChecks.length) && command !== "verify") throw new Error("--unit and --check are supported only by verify.");
|
|
111
132
|
const target = path.resolve(directory ?? process.cwd());
|
|
@@ -116,7 +137,8 @@ async function main(args) {
|
|
|
116
137
|
return;
|
|
117
138
|
}
|
|
118
139
|
let result;
|
|
119
|
-
if (command === "
|
|
140
|
+
if (command === "create") { const { createProject } = await import("./create.mjs"); result = createProject(target, { framework, packageManager, name, toolPackage }); }
|
|
141
|
+
else if (command === "init") result = initProject(target, { toolPackage, packageManager, framework });
|
|
120
142
|
else if (command === "check") {const {checkCandidate}=await import("./validation-checks.mjs");result=await checkCandidate(target,undefined,target,{fresh});}
|
|
121
143
|
else if (command === "validate") {
|
|
122
144
|
const {createValidationController}=await import("./validation.mjs");
|
|
@@ -127,11 +149,13 @@ async function main(args) {
|
|
|
127
149
|
}
|
|
128
150
|
else if (command === "behaviors") { const {behaviorStatus}=await import("./verification.mjs"); const {loadConfig}=await import("./config.mjs"); result=behaviorStatus(loadConfig(target)); }
|
|
129
151
|
else if (command === "verify") { const {createVerificationController}=await import("./verification.mjs"); const verification=createVerificationController(target); try {result=await verification.run({...(unit?{unit}:{}),...(selectedChecks.length?{checks:selectedChecks}:{})});} finally {await verification.close();} }
|
|
152
|
+
else if (command === "tokens" && format === "dtcg") { const { exportTokensDtcg } = await import("./token-export.mjs"); console.log(JSON.stringify(exportTokensDtcg(target, { theme }), null, 2)); return; }
|
|
130
153
|
else if (command === "tokens") result = inspectTokens(target);
|
|
131
154
|
else if (command === "assets") result = await generateBrandAssets(target);
|
|
132
155
|
else if (command === "lint-config") result = generateLintConfig(target);
|
|
133
156
|
else throw new Error(`Unknown command: ${command}. Run ads --help.`);
|
|
134
157
|
if (json) console.log(JSON.stringify(result, null, 2));
|
|
158
|
+
else if (command === "create") console.log(`Created ${result.name} in ${target}\nFramework: ${result.framework}\nNext: cd ${((folder) => /[\s'"$`\\]/.test(folder) ? JSON.stringify(folder) : folder)(path.relative(process.cwd(), target) || ".")} && ${result.packageManager} install && ${result.packageManager} run build && ${result.packageManager} run dev:showcase`);
|
|
135
159
|
else if (command === "init") console.log(`Initialized ${target}\nFramework: ${result.framework}\nAdded ${result.toolDependency.name} (${result.toolDependency.spec}) as a development dependency.\nRun ${result.packageManager} install and ${result.packageManager} run build; the build runs ADS checks and generates configured brand assets automatically.`);
|
|
136
160
|
else if (command === "assets") console.log(result.skipped ? "No assets.iconSource configured; brand generation skipped." : `Generated ${result.files.length} brand assets in ${result.directory}.`);
|
|
137
161
|
else if (command === "lint-config") console.log(`Generated ${result.file}\nUse this optional configuration only in the project linter you choose to run.`);
|
package/dist/config.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { isDraftFile, draftImportViolation } from "./draft-boundary.mjs";
|
|
5
5
|
import { isSharedToken } from "./token-policy.mjs";
|
|
6
|
+
import { defaultThemes, validateThemes } from "./themes.mjs";
|
|
6
7
|
|
|
7
8
|
export const supportedFrameworks = ["react", "preact"];
|
|
8
9
|
|
|
@@ -18,6 +19,7 @@ export const defaultConfig = {
|
|
|
18
19
|
reviewEntry: "review/index.ts",
|
|
19
20
|
stylesEntry: "styles.css",
|
|
20
21
|
tokenDir: "tokens",
|
|
22
|
+
themes: defaultThemes,
|
|
21
23
|
inlineStyleFiles: [],
|
|
22
24
|
boundaries: { styleWrites: [], componentVariables: [] },
|
|
23
25
|
assets: { publicDirs: ["public/assets"], generatedPaths: ["dist", "dist-showcase", ".vite", ".ds"], generatedFiles: [], iconSource: null, targets: [], glyphs: null },
|
|
@@ -34,33 +36,42 @@ export function isInside(parent, file) {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
const iconSizes = [16, 32, 64, 128, 256, 512, 1024];
|
|
37
|
-
/**
|
|
39
|
+
/** Brand artwork formats: SVG masters, finished images, and finished icon files. */
|
|
40
|
+
export const brandFormats = [".svg", ".png", ".jpg", ".jpeg", ".webp", ".ico", ".icns"];
|
|
41
|
+
/** Formats a target can render from; finished .ico/.icns files are only copied. */
|
|
42
|
+
export const renderableFormats = [".svg", ".png", ".jpg", ".jpeg", ".webp"];
|
|
43
|
+
const sizeKeys = ["size", "width", "height", "sizes", "background"];
|
|
44
|
+
/** Committed brand outputs: each copies or renders one master in assets/brand/ to a project path. */
|
|
38
45
|
function validateBrandTargets(targets, { root, dsRoot }) {
|
|
39
46
|
if (!Array.isArray(targets)) throw new Error("assets.targets must be an array.");
|
|
40
47
|
const outputs = new Set();
|
|
41
48
|
for (const [index, target] of targets.entries()) {
|
|
42
49
|
const field = `assets.targets[${index}]`;
|
|
43
50
|
if (!target || typeof target !== "object" || Array.isArray(target)) throw new Error(`${field} must be an object.`);
|
|
44
|
-
const unknown = Object.keys(target).filter(key => !["from", "to",
|
|
51
|
+
const unknown = Object.keys(target).filter(key => !["from", "to", ...sizeKeys].includes(key));
|
|
45
52
|
if (unknown.length) throw new Error(`${field} has unknown keys: ${unknown.join(", ")}.`);
|
|
46
53
|
const source = projectPath(dsRoot, target.from, `${field}.from`);
|
|
47
|
-
|
|
54
|
+
const sourceFormat = path.extname(source).toLowerCase();
|
|
55
|
+
if (!isInside(path.join(dsRoot, "assets/brand"), source) || !brandFormats.includes(sourceFormat)) throw new Error(`${field}.from must name brand artwork inside the ADS's assets/brand/ folder (${brandFormats.join(", ")}).`);
|
|
48
56
|
const output = projectPath(root, target.to, `${field}.to`);
|
|
49
57
|
if (isInside(path.join(dsRoot, "assets"), output) || isInside(path.join(root, ".ds"), output)) throw new Error(`${field}.to must be outside the ADS assets/ folder and .ds/.`);
|
|
50
58
|
if (outputs.has(output)) throw new Error(`${field}.to repeats an earlier target's output.`);
|
|
51
59
|
outputs.add(output);
|
|
52
60
|
const format = path.extname(output).toLowerCase();
|
|
61
|
+
const sized = sizeKeys.some(key => key in target);
|
|
62
|
+
// The same format without sizes is a copy of the supplied file.
|
|
63
|
+
if (!sized && format === sourceFormat) continue;
|
|
64
|
+
if (format === ".svg") throw new Error(`${field} copies an SVG master to .svg; it takes no sizes.`);
|
|
65
|
+
if (!renderableFormats.includes(sourceFormat)) throw new Error(`${field} copies the finished ${sourceFormat} file; give it the same extension and no sizes.`);
|
|
53
66
|
const pixels = value => Number.isInteger(value) && value >= 1 && value <= 4096;
|
|
54
|
-
if (target.background !== undefined && (
|
|
55
|
-
if (format === ".
|
|
56
|
-
if (["size", "width", "height", "sizes"].some(key => key in target)) throw new Error(`${field} copies its SVG; it takes no sizes.`);
|
|
57
|
-
} else if (format === ".png") {
|
|
67
|
+
if (target.background !== undefined && (typeof target.background !== "string" || !/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(target.background))) throw new Error(`${field}.background must be a #RGB, #RRGGBB or #RRGGBBAA colour on a PNG, ICO or ICNS target.`);
|
|
68
|
+
if (format === ".png") {
|
|
58
69
|
const square = target.size !== undefined, rectangle = target.width !== undefined || target.height !== undefined;
|
|
59
70
|
if (square === rectangle || target.sizes !== undefined || (square ? !pixels(target.size) : !pixels(target.width) || !pixels(target.height))) throw new Error(`${field} renders a PNG at one size (1–4096) or one width and height.`);
|
|
60
71
|
} else if (format === ".ico" || format === ".icns") {
|
|
61
72
|
const allowed = format === ".ico" ? [16, 24, 32, 48, 64, 128, 256] : iconSizes;
|
|
62
73
|
if (["size", "width", "height"].some(key => key in target) || !Array.isArray(target.sizes) || !target.sizes.length || new Set(target.sizes).size !== target.sizes.length || target.sizes.some(size => !allowed.includes(size))) throw new Error(`${field}.sizes must list distinct ${format.slice(1).toUpperCase()} sizes from ${allowed.join(", ")}.`);
|
|
63
|
-
} else throw new Error(`${field}.to must end in .svg, .png, .ico or .icns.`);
|
|
74
|
+
} else throw new Error(`${field}.to must end in .svg, .png, .ico or .icns, or keep the supplied file's extension.`);
|
|
64
75
|
}
|
|
65
76
|
}
|
|
66
77
|
/** A glyph set: SVGs in one assets/ folder become one generated TypeScript map. */
|
|
@@ -101,6 +112,7 @@ export function loadConfig(directory = process.cwd()) {
|
|
|
101
112
|
for (const key of Object.keys(user[field] ?? {})) if (!(key in defaultConfig[field])) throw new Error(`Unknown ${field} configuration field: ${key}`);
|
|
102
113
|
}
|
|
103
114
|
const config = { ...defaultConfig, ...user, boundaries: { ...defaultConfig.boundaries, ...user.boundaries }, assets: { ...defaultConfig.assets, ...user.assets }, oxlint: { ...defaultConfig.oxlint, ...user.oxlint }, acceptance: { ...defaultConfig.acceptance, ...user.acceptance }, validation: { ...defaultConfig.validation, ...user.validation }, mcp: { ...defaultConfig.mcp, ...user.mcp }, usage: { ...defaultConfig.usage, ...user.usage }, resources: { ...defaultConfig.resources, ...user.resources } };
|
|
115
|
+
validateThemes(config.themes);
|
|
104
116
|
if(config.resources.memoryLimitMb!==null&&(!Number.isInteger(config.resources.memoryLimitMb)||config.resources.memoryLimitMb<64||config.resources.memoryLimitMb>1048576))throw new Error("resources.memoryLimitMb must be null (automatic) or an integer from 64 to 1048576 MiB.");
|
|
105
117
|
if (!Array.isArray(config.usage.notifications) || config.usage.notifications.length > 100) throw new Error("usage.notifications must be an array of notification API registrations.");
|
|
106
118
|
const notificationNames = new Set();
|
|
@@ -166,7 +178,7 @@ export function loadConfig(directory = process.cwd()) {
|
|
|
166
178
|
}
|
|
167
179
|
if (config.assets.iconSource !== null) {
|
|
168
180
|
const source = projectPath(dsRoot, config.assets.iconSource, "assets.iconSource");
|
|
169
|
-
if (!isInside(path.join(dsRoot, "assets/brand"), source) || path.extname(source).toLowerCase()
|
|
181
|
+
if (!isInside(path.join(dsRoot, "assets/brand"), source) || !renderableFormats.includes(path.extname(source).toLowerCase())) throw new Error("assets.iconSource must name an SVG, or a square PNG, JPEG or WebP of at least 512 px, inside the ADS's assets/brand/ folder.");
|
|
170
182
|
}
|
|
171
183
|
validateBrandTargets(config.assets.targets, { root, dsRoot });
|
|
172
184
|
validateGlyphs(config.assets.glyphs, { dsRoot });
|
|
@@ -268,7 +280,7 @@ export function isDevelopmentFile(file, { dsRoot }) {
|
|
|
268
280
|
if (!isInside(dsRoot, file)) return isTestFile(file) || adsFileRole(file) !== null;
|
|
269
281
|
const relative = path.relative(dsRoot, file).replaceAll("\\", "/");
|
|
270
282
|
return adsFileRole(file) !== null || isTestFile(file) || isScenarioFile(file) || isFixtureFile(file) || isBehaviorFile(file)
|
|
271
|
-
|| /^(?:showcase|composition|review)\//.test(relative)
|
|
283
|
+
|| /^(?:showcase|composition|review|brand)\//.test(relative)
|
|
272
284
|
|| /(?:^|\/)(?:scenario|fixtures)(?:\/|$)/.test(relative)
|
|
273
285
|
|| /\.scenario(?:-adapter)?\.[cm]?[jt]sx?$/.test(relative);
|
|
274
286
|
}
|