@takazudo/zudo-sg 0.2.0 → 0.2.2
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/CHANGELOG.md +34 -0
- package/README.md +70 -8
- package/dist/cli/config.d.ts +2 -2
- package/dist/cli/registry/build-registry-source.d.ts +1 -1
- package/dist/cli/registry/build-registry-source.js +4 -4
- package/dist/cli/registry/gen-registry.js +22 -9
- package/dist/cli/scaffold/component-scaffold.d.ts +1 -1
- package/dist/cli/scaffold/component-scaffold.js +2 -1
- package/dist/cli/token-manifest/gen-token-manifest.js +2 -2
- package/dist/cli/token-manifest/ui-token-manifest.d.ts +7 -1
- package/dist/cli/token-manifest/ui-token-manifest.js +18 -12
- package/dist/config/index.d.ts +7 -1
- package/dist/config/index.js +38 -1
- package/dist/safelist.css +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,40 @@ All notable changes to `@takazudo/zudo-sg` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on Keep a Changelog, and release notes are generated from the changelog MDX pages.
|
|
6
6
|
|
|
7
|
+
## [0.2.2] - 2026-09-20
|
|
8
|
+
|
|
9
|
+
Minimal hosts now expose the engine's routes in their header without requiring
|
|
10
|
+
additional navigation configuration.
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- `withZudoSg` fills an empty host header with Components and Design Tokens
|
|
15
|
+
links and a search control. Existing non-empty navigation remains unchanged,
|
|
16
|
+
and `chromeDefaults: false` preserves an intentionally empty header.
|
|
17
|
+
- Default engine links honor custom route paths and deployment bases while
|
|
18
|
+
remaining global on translated and versioned documentation pages.
|
|
19
|
+
|
|
20
|
+
## [0.2.1] - 2026-09-20
|
|
21
|
+
|
|
22
|
+
This release removes host-specific assumptions from generated registries and
|
|
23
|
+
token manifests, while making first-time registry generation self-starting.
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
- Generated registries now import the engine-owned `StoryModule` type instead
|
|
28
|
+
of depending on the repository's demo UI package.
|
|
29
|
+
- Token manifests preserve each CSS input's configured import specifier, so
|
|
30
|
+
generated output remains valid when a host uses relative or package paths.
|
|
31
|
+
- `gen-registry` now creates a missing or whitespace-only output file and its
|
|
32
|
+
parent directories. Existing non-empty files without generated markers are
|
|
33
|
+
still protected from overwrite.
|
|
34
|
+
|
|
35
|
+
### Other Changes
|
|
36
|
+
|
|
37
|
+
- Raised the engine peer floors to `@takazudo/zfb ^2.20.0` and
|
|
38
|
+
`@takazudo/zudo-doc ^5.26.2`.
|
|
39
|
+
- Expanded foreign-host and initializer verification around generated output.
|
|
40
|
+
|
|
7
41
|
## [0.2.0] - 2026-09-20
|
|
8
42
|
|
|
9
43
|
A requirements release. The engine's code is unchanged, but its published peer
|
package/README.md
CHANGED
|
@@ -51,18 +51,23 @@ pnpm gen-token-manifest
|
|
|
51
51
|
pnpm dev
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
It copies a private starter with three example Preact components, stories,
|
|
55
|
+
token CSS, a preview entry, and the zfb/zudo-doc composition already wired.
|
|
56
|
+
The CLI prints the same next steps after scaffolding.
|
|
57
|
+
|
|
58
|
+
`gen-registry` bootstraps a missing or whitespace-only `registryOut` and its
|
|
59
|
+
parent directories, so a new host does not need to create a marker-only seed
|
|
60
|
+
file by hand. A non-empty registry without generated markers is rejected to
|
|
61
|
+
protect hand-authored content. `gen-registry --check` reports missing or empty
|
|
62
|
+
output as drift and never writes it.
|
|
58
63
|
|
|
59
64
|
## Installation
|
|
60
65
|
|
|
61
66
|
```sh
|
|
62
|
-
pnpm add @takazudo/zudo-sg@latest @takazudo/zfb@^2.
|
|
67
|
+
pnpm add @takazudo/zudo-sg@latest @takazudo/zfb@^2.20.0 @takazudo/zfb-md-wasm@^2.20.0 @takazudo/zfb-runtime@^2.20.0 @takazudo/zudo-doc@^5.26.2 @takazudo/zdtp@^0.8.0 diff@^8.0.4 katex@^0.16.38 preact@^10.29.8 preact-render-to-string@^6.6.6 tailwindcss@^4.2.0 zod@^4.3.6
|
|
63
68
|
```
|
|
64
69
|
|
|
65
|
-
The engine peers are `@takazudo/zfb ^2.
|
|
70
|
+
The engine peers are `@takazudo/zfb ^2.20.0`, `@takazudo/zudo-doc ^5.26.2`,
|
|
66
71
|
`@takazudo/zdtp ^0.8.0`, and `preact ^10.29.8`. `@takazudo/zdtp` is required:
|
|
67
72
|
the injected `/tokens` route imports its dashboard at build time. The
|
|
68
73
|
`@takazudo/zfb-md-wasm`, `@takazudo/zfb-runtime`, `diff`, `katex`, and `zod`
|
|
@@ -95,7 +100,7 @@ export default defineConfig(
|
|
|
95
100
|
{
|
|
96
101
|
componentsRoots: [{ dir: "./src/components", importBase: "@/components" }],
|
|
97
102
|
registryOut: "./src/styleguide/sg-registry.ts",
|
|
98
|
-
uiPackageName: "@your-scope/ui",
|
|
103
|
+
uiPackageName: "@your-scope/ui", // optional: usage snippets and catalog labels
|
|
99
104
|
previewStyles: "./src/styles/preview-entry.css",
|
|
100
105
|
},
|
|
101
106
|
),
|
|
@@ -103,7 +108,11 @@ export default defineConfig(
|
|
|
103
108
|
```
|
|
104
109
|
|
|
105
110
|
`withZudoSg` merges the engine's plugins and collections after the zudo-doc
|
|
106
|
-
preset's own.
|
|
111
|
+
preset's own. When the zudo-doc preset has an empty `headerNav`, it also adds
|
|
112
|
+
the engine-owned Components and Design Tokens links and the standard search
|
|
113
|
+
control. Any non-empty host navigation stays authoritative; set
|
|
114
|
+
`chromeDefaults: false` in the second argument to keep an intentionally empty
|
|
115
|
+
header. The engine requires `packageOwnedRoutes: true` on the host (its
|
|
107
116
|
routes import zudo-doc's route-context virtual modules). On the engine's zfb
|
|
108
117
|
peer floor (≥ 2.18.0) nothing else is needed: `zfb dev` seeds its island
|
|
109
118
|
scanner from the injected routes. `@takazudo/zudo-sg/islands` remains
|
|
@@ -111,9 +120,62 @@ exported as a side-effect module that statically imports every engine
|
|
|
111
120
|
island — importing it once from a host `pages/` file is optional and
|
|
112
121
|
harmless (it was required on zfb < 2.18.0).
|
|
113
122
|
|
|
123
|
+
`uiPackageName` is optional. When set, it names the package used in generated
|
|
124
|
+
usage snippets and catalog labels; when omitted, scaffolded usage snippets
|
|
125
|
+
import the component from its own relative module. The generated registry's
|
|
126
|
+
`StoryModule` type always comes from `@takazudo/zudo-sg/stories`.
|
|
127
|
+
|
|
114
128
|
Full option shape, virtual modules, and every locked constant:
|
|
115
129
|
`docs/adr/styleguide-engine.md` in this repository.
|
|
116
130
|
|
|
131
|
+
### Host styles
|
|
132
|
+
|
|
133
|
+
Add `src/styles/global.css` to the host; zfb discovers it automatically
|
|
134
|
+
(`styles/global.css` takes precedence if both exist). The initializer ships
|
|
135
|
+
this entry already. Use this import order, replacing `ui-tokens.css` with
|
|
136
|
+
your own token stylesheet as needed:
|
|
137
|
+
|
|
138
|
+
```css
|
|
139
|
+
@layer zd-preflight, zd-flow;
|
|
140
|
+
/* One element reset: theme.css resets color tokens, not elements. */
|
|
141
|
+
@import "tailwindcss/preflight" layer(zd-preflight);
|
|
142
|
+
@import "tailwindcss/utilities";
|
|
143
|
+
@import "@takazudo/zudo-doc/theme.css";
|
|
144
|
+
@import "./ui-tokens.css";
|
|
145
|
+
/* Add your component package stylesheet here. */
|
|
146
|
+
@import "@takazudo/zudo-doc/safelist.css";
|
|
147
|
+
@import "@takazudo/zudo-doc/content.css";
|
|
148
|
+
@import "@takazudo/zudo-doc/features.css";
|
|
149
|
+
@import "@takazudo/zudo-doc/page-loading.css";
|
|
150
|
+
@import "@takazudo/zdtp/dashboard/styles.css";
|
|
151
|
+
@import "@takazudo/zudo-sg/styles.css";
|
|
152
|
+
@import "@takazudo/zudo-sg/safelist.css";
|
|
153
|
+
|
|
154
|
+
/* zfb global-entry paths are project-root-relative; add your UI package here. */
|
|
155
|
+
@source "pages/**/*.{tsx,ts,jsx,js}";
|
|
156
|
+
@source "ui/**/*.{tsx,ts,jsx,js,mdx,md}";
|
|
157
|
+
@source "src/content/**/*.{mdx,md}";
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The zudo-doc theme supplies framework defaults, including the breakpoints
|
|
161
|
+
needed by responsive sidebar utilities. Its color-token reset precedes your
|
|
162
|
+
tokens so they survive. Use `theme-no-reset.css` instead to preserve
|
|
163
|
+
consumer-only color tokens imported earlier; tokens defined by both
|
|
164
|
+
stylesheets still follow source order. Do not import both variants or add
|
|
165
|
+
another preflight/full `tailwindcss` import. A host that already defines the
|
|
166
|
+
full zudo-doc token contract can keep its own theme.
|
|
167
|
+
|
|
168
|
+
Keep utilities and engine styles unlayered. The `zd-flow` layer must beat
|
|
169
|
+
preflight's margin reset while allowing utility margins to win, and catalog
|
|
170
|
+
chrome overrides must compete with utilities. The zdtp dashboard stylesheet
|
|
171
|
+
belongs after zudo-doc content CSS so dashboard rules win ties with prose.
|
|
172
|
+
Safelists cover package chrome; your `@source` globs cover consumer code.
|
|
173
|
+
|
|
174
|
+
Add the component package's CSS and source scan to your `previewStyles` entry
|
|
175
|
+
as well; that standalone entry compiles separately and resolves `@source`
|
|
176
|
+
paths relative to its stylesheet. Dashboard and catalog CSS stay in the
|
|
177
|
+
host entry.
|
|
178
|
+
|
|
117
179
|
## Release scheme
|
|
118
180
|
|
|
119
181
|
Stable only. `v*.*.*` tags publish to the npm `latest` dist-tag — there is no
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ export interface ZudoSgConfig {
|
|
|
25
25
|
* `computeCategoryOrder`).
|
|
26
26
|
*/
|
|
27
27
|
categoryOrder: string[];
|
|
28
|
-
/** npm package name components
|
|
29
|
-
uiPackageName
|
|
28
|
+
/** npm package name components are imported from in generated usage snippets and catalog labels. */
|
|
29
|
+
uiPackageName?: string;
|
|
30
30
|
/**
|
|
31
31
|
* Project-root-relative path to the barrel file `new-component` inserts an
|
|
32
32
|
* export into, or `null` for a project with no barrel-file convention.
|
|
@@ -13,7 +13,7 @@ export interface RegistryEntry extends DiscoveredStory {
|
|
|
13
13
|
* `StoryModule` import, one `import * as <name>` per story, and the
|
|
14
14
|
* `storyModules` + `storyExportOrder` maps.
|
|
15
15
|
*/
|
|
16
|
-
export declare function buildRegistryBlock(entries: RegistryEntry[]
|
|
16
|
+
export declare function buildRegistryBlock(entries: RegistryEntry[]): string;
|
|
17
17
|
/**
|
|
18
18
|
* Build the generated block for a components root's secondary
|
|
19
19
|
* `story-modules.ts` fixture: one `import * as <name>` per story (relative,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const BEGIN_MARKER = "GENERATED:SG_REGISTRY_BEGIN";
|
|
2
2
|
const END_MARKER = "GENERATED:SG_REGISTRY_END";
|
|
3
|
-
function buildRegistryBlock(entries
|
|
3
|
+
function buildRegistryBlock(entries) {
|
|
4
4
|
const lines = [];
|
|
5
|
-
lines.push(`// ${BEGIN_MARKER} \u2014 do not hand-edit; run \`
|
|
6
|
-
lines.push(`import type { StoryModule } from "
|
|
5
|
+
lines.push(`// ${BEGIN_MARKER} \u2014 do not hand-edit; run \`zudo-sg gen-registry\`.`);
|
|
6
|
+
lines.push(`import type { StoryModule } from "@takazudo/zudo-sg/stories";`);
|
|
7
7
|
lines.push(``);
|
|
8
8
|
for (const e of entries) {
|
|
9
9
|
lines.push(`import * as ${e.importName} from "${e.importSpecifier}";`);
|
|
@@ -41,7 +41,7 @@ function buildRegistryBlock(entries, uiPackageName) {
|
|
|
41
41
|
}
|
|
42
42
|
function buildStoryModulesBlock(entries, relativeImportPrefix) {
|
|
43
43
|
const lines = [];
|
|
44
|
-
lines.push(`// ${BEGIN_MARKER} \u2014 do not hand-edit; run \`
|
|
44
|
+
lines.push(`// ${BEGIN_MARKER} \u2014 do not hand-edit; run \`zudo-sg gen-registry\`.`);
|
|
45
45
|
for (const e of entries) {
|
|
46
46
|
lines.push(`import * as ${e.importName} from "${relativeImportPrefix}/${e.relDirStem}.stories";`);
|
|
47
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, relative, resolve } from "node:path";
|
|
3
3
|
import {
|
|
4
4
|
buildRegistryBlock,
|
|
@@ -25,12 +25,17 @@ function runGenRegistry(projectRoot, config, options = {}) {
|
|
|
25
25
|
const allEntries = perRootEntries.flatMap((r) => r.entries).sort((a, b) => a.mapKey.localeCompare(b.mapKey));
|
|
26
26
|
assertUniqueImportNames(allEntries);
|
|
27
27
|
const registryPath = resolve(projectRoot, config.registryOut);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
)
|
|
28
|
+
let registrySrc = "";
|
|
29
|
+
let bootstrapRegistry = false;
|
|
30
|
+
try {
|
|
31
|
+
registrySrc = readFileSync(registryPath, "utf8");
|
|
32
|
+
bootstrapRegistry = registrySrc.trim().length === 0;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (!isErrorCode(error, "ENOENT")) throw error;
|
|
35
|
+
bootstrapRegistry = true;
|
|
36
|
+
}
|
|
37
|
+
const registryBlock = buildRegistryBlock(allEntries);
|
|
38
|
+
const nextRegistry = bootstrapRegistry ? registryBlock : replaceBlock(registrySrc, registryBlock, registryPath);
|
|
34
39
|
const targets = [
|
|
35
40
|
{ path: registryPath, before: registrySrc, after: nextRegistry }
|
|
36
41
|
];
|
|
@@ -54,14 +59,22 @@ function runGenRegistry(projectRoot, config, options = {}) {
|
|
|
54
59
|
}
|
|
55
60
|
return { entryCount: allEntries.length, changed: [] };
|
|
56
61
|
}
|
|
57
|
-
for (const t of changed)
|
|
62
|
+
for (const t of changed) {
|
|
63
|
+
if (t.path === registryPath && bootstrapRegistry) {
|
|
64
|
+
mkdirSync(dirname(t.path), { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
writeFileSync(t.path, t.after);
|
|
67
|
+
}
|
|
58
68
|
return { entryCount: allEntries.length, changed: changed.map((t) => t.path) };
|
|
59
69
|
}
|
|
70
|
+
function isErrorCode(error, code) {
|
|
71
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
72
|
+
}
|
|
60
73
|
class SgRegistryDriftError extends Error {
|
|
61
74
|
constructor(driftedPaths) {
|
|
62
75
|
super(`sg-registry codegen drift detected:
|
|
63
76
|
${driftedPaths.map((p) => ` - ${p}`).join("\n")}
|
|
64
|
-
Run \`
|
|
77
|
+
Run \`zudo-sg gen-registry\` and commit the result.`);
|
|
65
78
|
this.driftedPaths = driftedPaths;
|
|
66
79
|
this.name = "SgRegistryDriftError";
|
|
67
80
|
}
|
|
@@ -67,6 +67,7 @@ function storiesTemplate({
|
|
|
67
67
|
uiPackageName,
|
|
68
68
|
nested = false
|
|
69
69
|
}) {
|
|
70
|
+
const usageImport = uiPackageName ?? `./${kebabName}`;
|
|
70
71
|
const lines = [
|
|
71
72
|
`import type { StoryMeta, Story } from "${nested ? "../../stories/types" : "../stories/types"}";`,
|
|
72
73
|
`import { ${pascalName}, type ${pascalName}Props } from "./${kebabName}";`,
|
|
@@ -75,7 +76,7 @@ function storiesTemplate({
|
|
|
75
76
|
` title: "${pascalName}", // TODO: human-friendly display name, if different`,
|
|
76
77
|
` category: "${category}",`,
|
|
77
78
|
` description: "TODO: one-sentence description of ${pascalName}.",`,
|
|
78
|
-
` usage: \`import { ${pascalName} } from "${
|
|
79
|
+
` usage: \`import { ${pascalName} } from "${usageImport}";`,
|
|
79
80
|
``,
|
|
80
81
|
`<${pascalName}>Content</${pascalName}>\`,`,
|
|
81
82
|
`};`,
|
|
@@ -5,7 +5,7 @@ class TokenManifestDriftError extends Error {
|
|
|
5
5
|
constructor(manifestOut) {
|
|
6
6
|
super(
|
|
7
7
|
`Token manifest drift detected: ${manifestOut} is out of date.
|
|
8
|
-
Run \`
|
|
8
|
+
Run \`zudo-sg gen-token-manifest\` and commit the result.`
|
|
9
9
|
);
|
|
10
10
|
this.name = "TokenManifestDriftError";
|
|
11
11
|
}
|
|
@@ -25,7 +25,7 @@ function runGenTokenManifest(projectRoot, config, options = {}) {
|
|
|
25
25
|
const tokensCss = readFileSync(resolve(projectRoot, tokensCssPath), "utf8");
|
|
26
26
|
const colorsCss = readFileSync(resolve(projectRoot, colorsCssPath), "utf8");
|
|
27
27
|
const manifest = buildUiTokenManifest({ tokensCss, colorsCss });
|
|
28
|
-
const next = renderUiTokenManifestFile(manifest);
|
|
28
|
+
const next = renderUiTokenManifestFile(manifest, { tokensCssPath, colorsCssPath });
|
|
29
29
|
const tokenCount = manifest.paletteColors.length + manifest.colorTokens.length + manifest.spacingTokens.length + manifest.fontTokens.length + manifest.sizeTokens.length;
|
|
30
30
|
const manifestPath = resolve(projectRoot, tokens.manifestOut);
|
|
31
31
|
let current;
|
|
@@ -64,6 +64,12 @@ export interface UiTokenManifest {
|
|
|
64
64
|
fontTokens: BuiltToken[];
|
|
65
65
|
sizeTokens: BuiltToken[];
|
|
66
66
|
}
|
|
67
|
+
export interface TokenManifestProvenance {
|
|
68
|
+
/** Project-root-relative path configured for spacing/font/size tokens. */
|
|
69
|
+
tokensCssPath: string;
|
|
70
|
+
/** Project-root-relative path configured for palette/semantic color tokens. */
|
|
71
|
+
colorsCssPath: string;
|
|
72
|
+
}
|
|
67
73
|
/**
|
|
68
74
|
* Parse `tokensCss` (the components root's main tokens file) and
|
|
69
75
|
* `colorsCss` (its colors file) and build the full manifest data — the same
|
|
@@ -75,4 +81,4 @@ export declare function buildUiTokenManifest({ tokensCss, colorsCss }: {
|
|
|
75
81
|
colorsCss: string;
|
|
76
82
|
}): UiTokenManifest;
|
|
77
83
|
/** Render the full generated manifest `.ts` source. */
|
|
78
|
-
export declare function renderUiTokenManifestFile(manifest: UiTokenManifest): string;
|
|
84
|
+
export declare function renderUiTokenManifestFile(manifest: UiTokenManifest, provenance: TokenManifestProvenance): string;
|
|
@@ -195,6 +195,9 @@ function buildUiTokenManifest({ tokensCss, colorsCss }) {
|
|
|
195
195
|
function jsStringLiteral(value) {
|
|
196
196
|
return JSON.stringify(value);
|
|
197
197
|
}
|
|
198
|
+
function normalizeProvenancePath(path) {
|
|
199
|
+
return path.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
200
|
+
}
|
|
198
201
|
function renderTokenDefObject(token, indent) {
|
|
199
202
|
const pad = " ".repeat(indent);
|
|
200
203
|
const fields = [
|
|
@@ -225,20 +228,23 @@ ${pad}},`;
|
|
|
225
228
|
function renderPaletteEntry(entry) {
|
|
226
229
|
return ` { name: ${jsStringLiteral(entry.name)}, value: ${jsStringLiteral(entry.value)} },`;
|
|
227
230
|
}
|
|
228
|
-
function renderUiTokenManifestFile(manifest) {
|
|
231
|
+
function renderUiTokenManifestFile(manifest, provenance) {
|
|
232
|
+
const tokensCssPath = normalizeProvenancePath(provenance.tokensCssPath);
|
|
233
|
+
const colorsCssPath = normalizeProvenancePath(provenance.colorsCssPath);
|
|
234
|
+
const sourceOfTruth = tokensCssPath === colorsCssPath ? `\`${tokensCssPath}\`` : `\`${tokensCssPath}\` and \`${colorsCssPath}\``;
|
|
229
235
|
const paletteLines = manifest.paletteColors.map(renderPaletteEntry).join("\n");
|
|
230
236
|
const colorLines = manifest.colorTokens.map((t) => renderTokenDefObject(t, 2)).join("\n");
|
|
231
237
|
const spacingLines = manifest.spacingTokens.map((t) => renderTokenDefObject(t, 2)).join("\n");
|
|
232
238
|
const fontLines = manifest.fontTokens.map((t) => renderTokenDefObject(t, 2)).join("\n");
|
|
233
239
|
const sizeLines = manifest.sizeTokens.map((t) => renderTokenDefObject(t, 2)).join("\n");
|
|
234
240
|
return `/**
|
|
235
|
-
* Design-token manifest for
|
|
241
|
+
* Design-token manifest for configured UI tokens.
|
|
236
242
|
*
|
|
237
|
-
* GENERATED \u2014 do not hand-edit. Run \`
|
|
238
|
-
*
|
|
239
|
-
*
|
|
243
|
+
* GENERATED \u2014 do not hand-edit. Run \`zudo-sg gen-token-manifest\` after changing
|
|
244
|
+
* either configured source file, then commit the regenerated output.
|
|
245
|
+
* \`zudo-sg gen-token-manifest --check\` fails on drift.
|
|
240
246
|
*
|
|
241
|
-
* Source of truth:
|
|
247
|
+
* Source of truth: ${sourceOfTruth},
|
|
242
248
|
* parsed by the \`zudo-sg gen-token-manifest\` CLI command
|
|
243
249
|
* (@takazudo/zudo-sg's src/cli/token-manifest/ui-token-manifest.ts). Only
|
|
244
250
|
* \`default\` values are derived from the CSS; \`group\`/\`step\`/\`unit\`/
|
|
@@ -256,7 +262,7 @@ const FONT_WEIGHT_OPTIONS = [
|
|
|
256
262
|
] as const;
|
|
257
263
|
|
|
258
264
|
/**
|
|
259
|
-
* Tier-1 raw palette colors from \`
|
|
265
|
+
* Tier-1 raw palette colors from \`${colorsCssPath}\` (the \`:root\`
|
|
260
266
|
* \`--palette-{group}-{step-or-role}\` block). This is the raw material beneath the
|
|
261
267
|
* semantic \`--color-*\` tokens in UI_COLOR_TOKENS below \u2014 same three-tier
|
|
262
268
|
* model the doc-chrome panel exposes via \`--palette-*\` ramps and \`--zd-*\`
|
|
@@ -274,7 +280,7 @@ const FONT_WEIGHT_OPTIONS = [
|
|
|
274
280
|
export interface UiPaletteColor {
|
|
275
281
|
/** Palette key without the \`--palette-\` prefix, e.g. "neutral-2". */
|
|
276
282
|
name: string;
|
|
277
|
-
/** Raw oklch value, from
|
|
283
|
+
/** Raw oklch value, from \`${colorsCssPath}\`. */
|
|
278
284
|
value: string;
|
|
279
285
|
}
|
|
280
286
|
|
|
@@ -283,7 +289,7 @@ ${paletteLines}
|
|
|
283
289
|
];
|
|
284
290
|
|
|
285
291
|
/**
|
|
286
|
-
* Color tokens from
|
|
292
|
+
* Color tokens from \`${colorsCssPath}\`.
|
|
287
293
|
*
|
|
288
294
|
* All values use light-dark() for dual-scheme support. Defaults here are
|
|
289
295
|
* the full CSS declarations including both light and dark sides.
|
|
@@ -297,7 +303,7 @@ ${colorLines}
|
|
|
297
303
|
];
|
|
298
304
|
|
|
299
305
|
/**
|
|
300
|
-
* Spacing tokens from
|
|
306
|
+
* Spacing tokens from \`${tokensCssPath}\`.
|
|
301
307
|
*
|
|
302
308
|
* Coverage: ${manifest.spacingTokens.length} tokens total.
|
|
303
309
|
*/
|
|
@@ -306,7 +312,7 @@ ${spacingLines}
|
|
|
306
312
|
];
|
|
307
313
|
|
|
308
314
|
/**
|
|
309
|
-
* Font tokens from
|
|
315
|
+
* Font tokens from \`${tokensCssPath}\`.
|
|
310
316
|
*
|
|
311
317
|
* Coverage: ${manifest.fontTokens.length} tokens total.
|
|
312
318
|
*/
|
|
@@ -315,7 +321,7 @@ ${fontLines}
|
|
|
315
321
|
];
|
|
316
322
|
|
|
317
323
|
/**
|
|
318
|
-
* Size tokens from
|
|
324
|
+
* Size tokens from \`${tokensCssPath}\`.
|
|
319
325
|
*
|
|
320
326
|
* Coverage: ${manifest.sizeTokens.length} tokens total.
|
|
321
327
|
* \`--radius-full\` carries a pill toggle (sentinel 9999px).
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { componentDocsCollectionName } from "../registry/component-docs.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type SgRoutes } from "../sg-routes.js";
|
|
3
3
|
export declare const ROUTES_PLUGIN_NAME = "@takazudo/zudo-sg/plugins/routes";
|
|
4
4
|
export declare const PREVIEW_CSS_PLUGIN_NAME = "@takazudo/zudo-sg/plugins/preview-css";
|
|
5
5
|
export declare const ZDTP_APPLY_PROXY_PLUGIN_NAME = "@takazudo/zudo-sg/plugins/zdtp-apply-proxy";
|
|
@@ -34,6 +34,12 @@ export interface ZudoSgComposeOptions {
|
|
|
34
34
|
title?: string;
|
|
35
35
|
intro?: string;
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Populate an otherwise empty zudo-doc header with links to the engine-owned
|
|
39
|
+
* Components and Design Tokens routes, plus search. Defaults to true.
|
|
40
|
+
* Existing host navigation remains authoritative and is never replaced.
|
|
41
|
+
*/
|
|
42
|
+
chromeDefaults?: boolean;
|
|
37
43
|
/** `tokens.manifestOut` feeds the `/tokens` route's dashboards (routes plugin `tokensManifestModule`). */
|
|
38
44
|
tokens?: {
|
|
39
45
|
manifestOut?: string;
|
package/dist/config/index.js
CHANGED
|
@@ -4,13 +4,48 @@ import {
|
|
|
4
4
|
componentDocsRoots
|
|
5
5
|
} from "../registry/component-docs.js";
|
|
6
6
|
import { DEFAULT_PREVIEW_CSS_URL } from "../sg-context.js";
|
|
7
|
+
import { resolveSgRoutes } from "../sg-routes.js";
|
|
7
8
|
const ROUTES_PLUGIN_NAME = "@takazudo/zudo-sg/plugins/routes";
|
|
8
9
|
const PREVIEW_CSS_PLUGIN_NAME = "@takazudo/zudo-sg/plugins/preview-css";
|
|
9
10
|
const ZDTP_APPLY_PROXY_PLUGIN_NAME = "@takazudo/zudo-sg/plugins/zdtp-apply-proxy";
|
|
11
|
+
const ZUDO_DOC_ROUTES_PLUGIN_NAME = "@takazudo/zudo-doc/plugins/routes";
|
|
10
12
|
const COMPONENT_DOCS_COLLECTION_BASE = COMPONENT_DOCS_COLLECTION;
|
|
11
13
|
function definedOnly(record) {
|
|
12
14
|
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0));
|
|
13
15
|
}
|
|
16
|
+
function isRecord(value) {
|
|
17
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18
|
+
}
|
|
19
|
+
function withStyleguideChromeDefaults(plugin, routes) {
|
|
20
|
+
if (!isRecord(plugin) || plugin.name !== ZUDO_DOC_ROUTES_PLUGIN_NAME) return plugin;
|
|
21
|
+
const options = isRecord(plugin.options) ? plugin.options : {};
|
|
22
|
+
const settings = isRecord(options.settings) ? options.settings : {};
|
|
23
|
+
const headerNav = Array.isArray(settings.headerNav) ? settings.headerNav : [];
|
|
24
|
+
if (headerNav.length > 0) return plugin;
|
|
25
|
+
const headerRightItems = Array.isArray(settings.headerRightItems) ? settings.headerRightItems : [];
|
|
26
|
+
const hasSearch = headerRightItems.some(
|
|
27
|
+
(item) => isRecord(item) && item.type === "component" && item.component === "search"
|
|
28
|
+
);
|
|
29
|
+
return {
|
|
30
|
+
...plugin,
|
|
31
|
+
options: {
|
|
32
|
+
...options,
|
|
33
|
+
settings: {
|
|
34
|
+
...settings,
|
|
35
|
+
headerNav: [
|
|
36
|
+
{ label: "Components", path: routes.componentsIndex, categoryMatch: "components", versioned: false },
|
|
37
|
+
{ label: "Design Tokens", path: routes.tokens, versioned: false }
|
|
38
|
+
],
|
|
39
|
+
// Engine navigation targets global routes, including from translated docs.
|
|
40
|
+
defaultLocaleOnlyPrefixes: [.../* @__PURE__ */ new Set([
|
|
41
|
+
...Array.isArray(settings.defaultLocaleOnlyPrefixes) ? settings.defaultLocaleOnlyPrefixes : [],
|
|
42
|
+
...[routes.componentsIndex, routes.tokens].map((path) => `${path.replace(/\/+$/, "")}/`)
|
|
43
|
+
])],
|
|
44
|
+
headerRightItems: hasSearch ? headerRightItems : [...headerRightItems, { type: "component", component: "search" }]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
14
49
|
function zudoSg(options) {
|
|
15
50
|
if (!options || typeof options !== "object") {
|
|
16
51
|
throw new Error("[zudo-sg] zudoSg(options) requires an options object (the zudo-sg.config.mjs shape)");
|
|
@@ -51,9 +86,11 @@ function zudoSg(options) {
|
|
|
51
86
|
}
|
|
52
87
|
function withZudoSg(presetFragment, options) {
|
|
53
88
|
const sg = zudoSg(options);
|
|
89
|
+
const presetPlugins = [...presetFragment.plugins ?? []];
|
|
90
|
+
const pluginsWithChrome = options.chromeDefaults === false ? presetPlugins : presetPlugins.map((plugin) => withStyleguideChromeDefaults(plugin, resolveSgRoutes(options.routes)));
|
|
54
91
|
return {
|
|
55
92
|
...presetFragment,
|
|
56
|
-
plugins: [...
|
|
93
|
+
plugins: [...pluginsWithChrome, ...sg.plugins],
|
|
57
94
|
collections: [...presetFragment.collections ?? [], ...sg.collections]
|
|
58
95
|
};
|
|
59
96
|
}
|
package/dist/safelist.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* generated by gen-safelist.mjs — do not edit by hand */
|
|
2
|
-
@source inline("-components [--check] [--nested] [--skip-barrel] [data-sg-card] [data-sg-catalog] [data-sg-empty] [data-sg-section] [data-sg-tile] [options] [slug] [zudo-sg] a accent accent-0 accent-1 accent-2 accent-3 accent/state across add adjusted after alias allow-forms allow-same-origin allow-scripts alphabetical alphabetically already always among an and any anything appear application/json apply-css-vars are aria-activedescendant aria-controls aria-describedby aria-details aria-expanded aria-hidden aria-label aria-labelledby aria-live aria-orientation aria-owns aria-pressed aria-selected array as aside assumes at authored back bar barrel barrel-export base be because before below beneath bg bg-accent bg-bg bg-surface bg-surface-2 block body bogus boolean border border-accent border-b border-border border-border-strong border-t border-transparent both build builds but button by cache-control cannot canvas carries cascading catalog categories category caution change changing
|
|
2
|
+
@source inline("-components [--check] [--nested] [--skip-barrel] [data-sg-card] [data-sg-catalog] [data-sg-empty] [data-sg-section] [data-sg-tile] [options] [slug] [zudo-sg] a accent accent-0 accent-1 accent-2 accent-3 accent/state across add adjusted after alias allow-forms allow-same-origin allow-scripts alphabetical alphabetically already always among an and any anything appear application/json apply-css-vars are aria-activedescendant aria-controls aria-describedby aria-details aria-expanded aria-hidden aria-label aria-labelledby aria-live aria-orientation aria-owns aria-pressed aria-selected array as aside assumes at authored back bar barrel barrel-export base be because before below beneath bg bg-accent bg-bg bg-surface bg-surface-2 block body bogus boolean border border-accent border-b border-border border-border-strong border-t border-transparent both build builds but button by cache-control cannot canvas carries cascading catalog categories category caution change changing checkbox children circle clamp classes clear-css-vars clickable client code codegen collapsing collection color colors command commit compact compare compile compiled component components components2026 config configured confirm const contain content-type copy count counts css cursor-pointer custom-property cx danger dark dashboard dashboards data-category data-copied data-keywords data-name data-sg-card data-sg-catalog data-sg-catalog-intro data-sg-code-panel-hidden data-sg-code-panel-resizer data-sg-empty data-sg-injected-css data-sg-preview-css data-sg-preview-doc data-sg-preview-loading data-sg-preview-scope data-sg-section data-sg-stage-grid data-sg-tile data-sg-tile-size data-sg-variant-root data-theme data-zudo-sg-tokens-empty date declaration declarations declared default defaults demo derive derived describe description descriptors design design-token desktop detail dev different differs digit directories directory disabled discovered display div do doc doc-chrome drift driven dual-scheme each edit editing edits either el element else empty en endpoint engine entry entrypoint equivalent every exists expected export exported exports exposes expressions failed fails family fg file files filled find first first-authored fixed flag flex flex-1 flex-col flex-wrap focus-visible:-outline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus focus-visible:outline-offset-2 follow follows font font-bold font-family font-medium font-semibold font-size font-size-lh font-weight for form found frame frames free-form from frost full function g gap-hsp-2xs gap-hsp-3xs gap-hsp-md gap-hsp-sm gap-hsp-xs gap-vsp-2xs gap-vsp-lg gap-vsp-md gap-x-hsp-xl gap-y-vsp-xl gate gen-registry gen-token-manifest gen:sg-registry generated give glob-relative grid grid-cols-1 grid-cols-[repeat(auto-fit,minmax(min(18rem,100%),1fr))] group guards h-[1.5rem] h-full h1 h2 h3 hand handle hands has have head header headers height here hex hidden hold host hover:text-fg hsp html human-friendly identifier identifiers if iframe iframes import important in include including inert info init inject inline-block inline-flex input inserting inserts inside installed instead interface into intro inventory is isolated it items-center items-start its itself justify-between kebab-case keeps key key-enumeration keyboard keydown keyed known label large layout lazy leading leading-normal left length lh light like line line-beauty-accent line-beauty-accent-dark line-beauty-hover line-beauty-hover-dark line-height line-laser-accent line-laser-accent-dark line-laser-hover line-laser-hover-dark line-meeting-accent line-meeting-accent-dark line-meeting-hover line-meeting-hover-dark line-process-accent line-process-accent-dark line-process-hover line-process-hover-dark line-vacuum-accent line-vacuum-accent-dark line-vacuum-hover line-vacuum-hover-dark link lint:tokens list listed lists live load loading m-0 m21 makes manifest marker markers match matching material max-w-[56rem] may mb-vsp-2xs mb-vsp-lg mb-vsp-sm mb-vsp-xl message meta metadata min-h-0 mirroring missing mobile mode mode-dependent mode-independent model module ms-auto mt-vsp-2xs mt-vsp-3xs mt-vsp-xl mt-vsp-xs must mx-auto name name/value named named-export namespace navigation needs neutral-0 neutral-1 neutral-2 neutral-3 never new new-component new:component no no-store node:crypto node:fs node:fs/promises node:module node:path node:url noindex non-empty none not note nowhere number object of off oklch on once one one-sentence only option options opts or order other out outline-none overflow-auto overflow-hidden overflow-x-auto overriding p p-hsp-2xs p-hsp-md p-hsp-sm pages pairs palette palette- panel panels parse parsed parser pass passes path per-element per-variant pick pill placeholders plain plugin plugins pnpm polite polyline postcss pre preact-render-to-string preact/hooks preact/jsx-runtime presentation preview previews primary property pt-vsp-xl pushes px px-hsp-2xs px-hsp-md px-hsp-sm px-hsp-xs py-vsp-2xs py-vsp-3xs py-vsp-xs radius rail ramp ramps range raw re-executed re-run read-only readonly ready real recover rect reference references regenerated region registration relative rem rem-aware rem-based rename renamed/removed render rendered renders replace required requires resolve resolved return returns rhythm robots root-absolute round rounded rounded-full rounded-md rounded-sm route router routes routes-src rows run runtime s same saved scaffold scaffolds screen scrim script search secondary section segment segments select semantic separator settings sg-catalog-tile-size sg-chip sg-chip-row sg-code-panel sg-code-panel-hidden sg-code-panel-resizer sg-code-panel-width sg-copy-btn sg-filter sg-filter-row sg-gallery-section sg-grid sg-injected- sg-preview-design-token-panel-modal sg-preview-design-tokens sg-preview-design-tokens/v1 sg-preview-tweak sg-registry sg-search-clear sg-search-field sg-search-input sg-seg sg-seg-btn sg-thumb sg-thumb-inner sg-thumb-note sg-tile sg-tile-count sg-tile-desc sg-tile-meta sg-tile-title sg-workbench-toolbar sg:height sg:ready sgt- shadow shape shared show shown shrink-0 sidebar sidebar- single-axis site size skipped skips slug so solid sorts source spacing span spec specimen stacked starting state state-danger state-danger-dark state-info state-info-dark state-success state-success-dark state-warning state-warning-dark stay step still story string strings stroke-linecap stroke-linejoin stroke-width style stylesheet supported surface surfaces svg swaps swatch tab tablet tablist tabs tabular-nums text text-2xl text-accent text-caption text-fg text-heading text-muted text-on-accent text-right text-sm text-small text-xl text-xs text/icons textarea that the their them theme then these this three-tier tier tile time tip title to toggle toggle-design-token-panel toggle-preview-token-panel token tokens total tracking-wide transition-colors true tsx tweaks twice two type typechecks ui- ui-color ui-defaults-dark ui-defaults-light ui-defaults-shared undefined under underline underline-offset-2 unknown unwired up uppercase us use used uses utf-8 utf8 valid value values var variant variants vertical via viewport views virtual:zudo-doc-chrome-bindings virtual:zudo-doc-route-context virtual:zudo-sg-context virtual:zudo-sg-preview-token-panel virtual:zudo-sg-registry virtual:zudo-sg-tokens visible visit vs vsp w-[2.5rem] w-[5rem] warning was weight were what when which while whole whose will window with without would written yield you your zd-content zdtp-preview-prehydrate zfb zudo-doc zudo-doc-sidebar-width zudo-sg zudo-sg-token-tweak-bridge");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takazudo/zudo-sg",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "zudo-sg styleguide engine — story registry, catalog routes and preview machinery for zfb + zudo-doc hosts.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -138,15 +138,15 @@
|
|
|
138
138
|
"@tailwindcss/oxide": "^4.2.0"
|
|
139
139
|
},
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@takazudo/zfb": "^2.
|
|
141
|
+
"@takazudo/zfb": "^2.20.0",
|
|
142
142
|
"@takazudo/zdtp": "^0.8.0",
|
|
143
|
-
"@takazudo/zudo-doc": "^5.26.
|
|
143
|
+
"@takazudo/zudo-doc": "^5.26.2",
|
|
144
144
|
"preact": "^10.29.8"
|
|
145
145
|
},
|
|
146
146
|
"devDependencies": {
|
|
147
147
|
"@takazudo/zdtp": "0.8.0",
|
|
148
|
-
"@takazudo/zfb": "2.
|
|
149
|
-
"@takazudo/zudo-doc": "5.26.
|
|
148
|
+
"@takazudo/zfb": "2.20.0",
|
|
149
|
+
"@takazudo/zudo-doc": "5.26.2",
|
|
150
150
|
"@testing-library/jest-dom": "^6.9.1",
|
|
151
151
|
"@testing-library/preact": "^3.2.4",
|
|
152
152
|
"@types/culori": "^4.0.1",
|