kss-modern 1.6.2 → 1.7.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -59
- package/dist/node/lib/index.d.mts +1 -309
- package/dist/node/lib/index.d.ts +1 -309
- package/dist/node/lib/index.mjs +1954 -1081
- package/dist/node/lib/pug/worker.d.mts +35 -3
- package/dist/node/lib/pug/worker.d.ts +35 -3
- package/dist/node/lib/pug/worker.mjs +19 -6
- package/dist/node/shared/kss-modern.Blhbay-v.d.mts +430 -0
- package/dist/node/shared/kss-modern.Blhbay-v.d.ts +430 -0
- package/dist/node/shared/kss-modern.N3ElcapL.mjs +483 -0
- package/dist/styleguide-assets/.vite/manifest.json +59 -8
- package/dist/styleguide-assets/alerts-DIQ8TeZB.js +100 -0
- package/dist/styleguide-assets/clipboard-CkCI4gyF.js +12 -0
- package/dist/styleguide-assets/controller-BLn-0hDZ.js +592 -0
- package/dist/styleguide-assets/explorer-ADHDxFj8.js +187 -0
- package/dist/styleguide-assets/{fullpage-DSD6-0qF.js → fullpage-aWqc0gjm.js} +185 -166
- package/dist/styleguide-assets/kss-modern--f8H_kmd.css +3 -0
- package/dist/styleguide-assets/pausable-interval-CqQkAlJa.js +35 -0
- package/dist/styleguide-assets/playground-D9faUdLy.js +185 -0
- package/dist/styleguide-assets/{preview-DOMYJTpi.js → preview-CsX9psV8.js} +5 -3
- package/dist/styleguide-assets/{preview-inline-ByTkw_pt.js → preview-inline-DSosVng3.js} +25 -19
- package/dist/styleguide-assets/zod-ZRXEfO_L.js +15470 -0
- package/package.json +15 -2
- package/dist/node/shared/kss-modern.DeAy2QDg.mjs +0 -255
- package/dist/styleguide-assets/clipboard-CHYspHPs.js +0 -140
- package/dist/styleguide-assets/kss-modern-4xCd1hgR.css +0 -3
package/README.md
CHANGED
|
@@ -1,91 +1,106 @@
|
|
|
1
1
|
# kss-modern
|
|
2
2
|
|
|
3
|
-
A modern, KSS-compatible styleguide generator.
|
|
4
|
-
|
|
5
|
-
**[
|
|
3
|
+
A modern, KSS-compatible styleguide generator. Write KSS comments in your CSS or SCSS, and kss-modern turns them into a fast, accessible styleguide with live component previews, dark mode, themes and a built-in accessibility audit.
|
|
4
|
+
|
|
5
|
+
**[Open the live demo →](https://felixranesberger.github.io/kss-modern/)**
|
|
6
|
+
|
|
7
|
+
<picture>
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/welcome-dark.png">
|
|
9
|
+
<img src="docs/screenshots/welcome.png" alt="A kss-modern styleguide showing the welcome page of the Verdant demo design system">
|
|
10
|
+
</picture>
|
|
11
|
+
|
|
12
|
+
The demo documents Verdant, a small fictional design system. Its source in [`demo/content/`](demo/content/) is plain CSS, Pug and Markdown, so it doubles as a reference for writing your own styleguide.
|
|
13
|
+
|
|
14
|
+
<table>
|
|
15
|
+
<tr>
|
|
16
|
+
<td width="50%"><img src="docs/screenshots/dashboard.png" alt="A dashboard screen assembled from other sections with insert-markup"></td>
|
|
17
|
+
<td width="50%"><img src="docs/screenshots/components-dark.png" alt="The project card component in dark mode with a section theme dropdown"></td>
|
|
18
|
+
</tr>
|
|
19
|
+
<tr>
|
|
20
|
+
<td><b>Whole screens from reusable parts.</b> Pull other sections into a page with <code><insert-markup></code> and Pug <code>extends</code>.</td>
|
|
21
|
+
<td><b>Dark mode everywhere.</b> Previews follow the System, Light and Dark toggle through <code>light-dark()</code> tokens.</td>
|
|
22
|
+
</tr>
|
|
23
|
+
<tr>
|
|
24
|
+
<td><img src="docs/screenshots/theme-ocean.png" alt="The pricing pattern rendered in the Ocean preview theme"></td>
|
|
25
|
+
<td><img src="docs/screenshots/search.png" alt="The global search dialog with fuzzy matches"></td>
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<td><b>Preview themes.</b> Restyle every preview from the header, with an optional stylesheet per theme.</td>
|
|
29
|
+
<td><b>Instant search.</b> <kbd>Cmd</kbd>/<kbd>Ctrl</kbd> + <kbd>K</kbd> searches titles and descriptions across the whole styleguide.</td>
|
|
30
|
+
</tr>
|
|
31
|
+
</table>
|
|
6
32
|
|
|
7
33
|
## Features
|
|
8
34
|
|
|
9
35
|
- KSS-compatible comment parsing from CSS/SCSS files
|
|
10
36
|
- Live component previews with modifier variants
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
- Markup from inline HTML, static `.html` files or Pug templates (compiled in a worker thread pool)
|
|
38
|
+
- Reuse markup across sections with `<insert-markup>`
|
|
39
|
+
- Theme dropdowns in the header (`previewThemes` option) and per section (`Themes:`), optionally loading a stylesheet per theme
|
|
40
|
+
- Color palette and searchable icon gallery
|
|
41
|
+
- Markdown descriptions with alerts, accordions, tables and highlighted code
|
|
42
|
+
- Status indicators in the sidebar
|
|
43
|
+
- Figma embeds with light/dark sync
|
|
44
|
+
- Accessibility audit (axe-core) and HTML validation per component, or page-wide via `window.kssAudit()` for CI and AI agents
|
|
45
|
+
- Dark mode with a System/Light/Dark toggle
|
|
46
|
+
- Global search, keyboard navigation and "Open in Editor" links
|
|
47
|
+
- Watch mode that rebuilds only when KSS comments change
|
|
48
|
+
|
|
49
|
+
## Quick start
|
|
22
50
|
|
|
23
51
|
```bash
|
|
24
|
-
npm install kss-modern
|
|
52
|
+
npm install --save-dev kss-modern
|
|
25
53
|
```
|
|
26
54
|
|
|
27
|
-
|
|
55
|
+
Document a component next to its CSS:
|
|
56
|
+
|
|
57
|
+
```css
|
|
58
|
+
/*
|
|
59
|
+
Button
|
|
60
|
+
|
|
61
|
+
The main call to action.
|
|
62
|
+
|
|
63
|
+
.btn--secondary - Secondary action
|
|
64
|
+
.btn--danger - Destructive action
|
|
28
65
|
|
|
29
|
-
|
|
66
|
+
Markup: <button class="btn {{modifier_class}}">Save changes</button>
|
|
67
|
+
|
|
68
|
+
Styleguide 2.1
|
|
69
|
+
*/
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Build the styleguide from a small script:
|
|
73
|
+
|
|
74
|
+
```js
|
|
30
75
|
import { buildStyleguide } from 'kss-modern'
|
|
31
76
|
|
|
32
77
|
await buildStyleguide({
|
|
33
78
|
mode: 'production',
|
|
34
79
|
outDir: './styleguide',
|
|
35
|
-
contentDir: './src/
|
|
80
|
+
contentDir: './src/css/',
|
|
36
81
|
projectTitle: 'My Design System',
|
|
37
|
-
|
|
82
|
+
brandColor: '#005075',
|
|
38
83
|
html: {
|
|
39
84
|
lang: 'en',
|
|
40
85
|
assets: {
|
|
41
|
-
css: [{ src: '
|
|
86
|
+
css: [{ src: 'css/styles.css' }],
|
|
42
87
|
js: [],
|
|
43
88
|
},
|
|
44
89
|
},
|
|
45
90
|
})
|
|
46
91
|
```
|
|
47
92
|
|
|
48
|
-
|
|
93
|
+
kss-modern scans every `.css` and `.scss` file in `contentDir` and writes a static styleguide to `outDir`.
|
|
49
94
|
|
|
50
95
|
## Documentation
|
|
51
96
|
|
|
52
|
-
- **[
|
|
53
|
-
- **[
|
|
54
|
-
- **[
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/*
|
|
60
|
-
Button
|
|
61
|
-
|
|
62
|
-
A basic button component.
|
|
63
|
-
|
|
64
|
-
.btn--primary - Primary action button
|
|
65
|
-
.btn--outline - Outlined variant
|
|
66
|
-
|
|
67
|
-
Markup: <button class="btn {{modifier_class}}">Click me</button>
|
|
68
|
-
|
|
69
|
-
Styleguide 2.1
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
.btn { /* styles */ }
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Markup Includes
|
|
76
|
-
|
|
77
|
-
The `Markup:` field accepts three formats. File paths are resolved relative to `contentDir`.
|
|
78
|
-
|
|
79
|
-
```scss
|
|
80
|
-
/* Inline HTML */
|
|
81
|
-
Markup: <button class="btn {{modifier_class}}">Click me</button>
|
|
82
|
-
|
|
83
|
-
/* Static .html file — contents are inlined as-is */
|
|
84
|
-
Markup: templates/components/badge.html
|
|
85
|
-
|
|
86
|
-
/* Static .pug file — compiled to HTML at build time */
|
|
87
|
-
Markup: templates/components/card.pug
|
|
88
|
-
```
|
|
97
|
+
- **[Getting started](docs/getting-started.md)** covers installation, watch mode and deployment.
|
|
98
|
+
- **[Writing sections](docs/writing-sections.md)** explains the KSS format and every property.
|
|
99
|
+
- **[Markup and templates](docs/markup.md)** covers inline HTML, Pug templates and `<insert-markup>`.
|
|
100
|
+
- **[Configuration](docs/configuration.md)** lists every option and the JavaScript API.
|
|
101
|
+
- **[The styleguide UI](docs/styleguide-ui.md)** describes search, themes, dark mode and the other visitor features.
|
|
102
|
+
- **[Accessibility audit](docs/accessibility-audit.md)** covers the Audit button and `window.kssAudit()`.
|
|
103
|
+
- **[Changelog](CHANGELOG.md)** lists every release.
|
|
89
104
|
|
|
90
105
|
## Development
|
|
91
106
|
|
|
@@ -93,7 +108,8 @@ Markup: templates/components/card.pug
|
|
|
93
108
|
bun install
|
|
94
109
|
bun run build # Build: Vite (client assets) then Unbuild (Node.js library)
|
|
95
110
|
bun run dev # Build + run dev server with Deno (watches test-styleguide/ content)
|
|
96
|
-
bun run demo # Build the public demo into demo-dist/
|
|
111
|
+
bun run demo # Build the public demo into demo-dist/
|
|
112
|
+
bun run demo:screenshots # Rebuild the demo and refresh the README screenshots in docs/screenshots/
|
|
97
113
|
bun run lint # ESLint
|
|
98
114
|
bun run test # Vitest unit + integration tests
|
|
99
115
|
bun run release # Lint + version bump via bumpp
|
|
@@ -1,309 +1 @@
|
|
|
1
|
-
|
|
2
|
-
modifiers: {
|
|
3
|
-
name: string;
|
|
4
|
-
}[];
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* One entry of a section's `Themes:` block — a theme class (or class list, e.g. `.theme-a.compact`)
|
|
9
|
-
* written as in the KSS comment, plus the label shown in the theme dropdown.
|
|
10
|
-
*/
|
|
11
|
-
interface ThemeOption {
|
|
12
|
-
value: string;
|
|
13
|
-
description: string;
|
|
14
|
-
}
|
|
15
|
-
interface ColorObject {
|
|
16
|
-
name?: string;
|
|
17
|
-
color: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
}
|
|
20
|
-
interface IconObject {
|
|
21
|
-
name: string;
|
|
22
|
-
svg: string;
|
|
23
|
-
}
|
|
24
|
-
interface in2Section {
|
|
25
|
-
id: string;
|
|
26
|
-
sectionLevel: 'first' | 'second' | 'third';
|
|
27
|
-
header: string;
|
|
28
|
-
description: string;
|
|
29
|
-
hasMarkdownDescription: boolean;
|
|
30
|
-
/** Compiled markup, rendered in previews and fullpages exactly as it is. */
|
|
31
|
-
markup: string;
|
|
32
|
-
/** `markup` formatted for the code views. Set once the markup is compiled. */
|
|
33
|
-
sourceCode?: string;
|
|
34
|
-
modifiers: {
|
|
35
|
-
value: string;
|
|
36
|
-
description: string;
|
|
37
|
-
}[];
|
|
38
|
-
colors?: ColorObject[];
|
|
39
|
-
icons?: IconObject[];
|
|
40
|
-
figma?: string;
|
|
41
|
-
status?: string;
|
|
42
|
-
wrapper?: string;
|
|
43
|
-
htmlclass?: string;
|
|
44
|
-
bodyclass?: string;
|
|
45
|
-
/** Theme contexts offered by the section's theme dropdown; classes are applied to the preview's <html>. */
|
|
46
|
-
themes?: ThemeOption[];
|
|
47
|
-
source: {
|
|
48
|
-
css: {
|
|
49
|
-
file: string;
|
|
50
|
-
line: number;
|
|
51
|
-
};
|
|
52
|
-
markup?: {
|
|
53
|
-
file: string;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
previewFileName: string;
|
|
57
|
-
fullpageFileName: string;
|
|
58
|
-
}
|
|
59
|
-
interface in2FirstLevelSection extends in2Section {
|
|
60
|
-
sections: in2SecondLevelSection[];
|
|
61
|
-
}
|
|
62
|
-
interface in2SecondLevelSection extends in2Section {
|
|
63
|
-
sections: in2Section[];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Title + message for a boxed log entry. */
|
|
67
|
-
interface LogBox {
|
|
68
|
-
title: string;
|
|
69
|
-
message: string;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Styleguide logger. Intentionally a small, fixed surface so the underlying
|
|
73
|
-
* logging library (currently consola) stays an implementation detail and can
|
|
74
|
-
* be swapped without touching call sites.
|
|
75
|
-
*
|
|
76
|
-
* The message methods are variadic pass-throughs, so a leading message can be
|
|
77
|
-
* paired with an Error/unknown value — `logger.error('Build failed', err)` —
|
|
78
|
-
* and consola renders the error (and its stack) below the message.
|
|
79
|
-
*/
|
|
80
|
-
interface Logger {
|
|
81
|
-
/** Informational message. */
|
|
82
|
-
info: (message: unknown, ...args: unknown[]) => void;
|
|
83
|
-
/** Successful operation. */
|
|
84
|
-
success: (message: unknown, ...args: unknown[]) => void;
|
|
85
|
-
/** Non-fatal warning. */
|
|
86
|
-
warn: (message: unknown, ...args: unknown[]) => void;
|
|
87
|
-
/** Error — a message, an Error/unknown value, or a message followed by one. */
|
|
88
|
-
error: (message: unknown, ...args: unknown[]) => void;
|
|
89
|
-
/** Boxed, highlighted message used for grouped summaries. */
|
|
90
|
-
box: (box: LogBox) => void;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Create a {@link Logger} backed by consola. consola is wrapped rather than
|
|
94
|
-
* exposed directly so consumers depend only on the {@link Logger} contract.
|
|
95
|
-
*
|
|
96
|
-
* Every entry leads with a blue `tag` badge — styled like consola's own
|
|
97
|
-
* WARN/ERROR badges — passed as part of the message so it always sits at the
|
|
98
|
-
* start of the line. (consola's built-in `tag` option is right-aligned by the
|
|
99
|
-
* fancy reporter and scrolls off a wide terminal.)
|
|
100
|
-
*/
|
|
101
|
-
declare function createLogger(tag?: string): Logger;
|
|
102
|
-
/** Shared styleguide logger instance. */
|
|
103
|
-
declare const logger: Logger;
|
|
104
|
-
|
|
105
|
-
/** The styleguide's accent colour: one value, or one per color scheme. */
|
|
106
|
-
type StyleguideBrandColor = string | {
|
|
107
|
-
light: string;
|
|
108
|
-
dark: string;
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* One entry of the header's **Theme** dropdown — an alternative theme context the previews can be
|
|
112
|
-
* shown in, not a color scheme (that is the separate System/Light/Dark toggle).
|
|
113
|
-
*/
|
|
114
|
-
interface PreviewTheme {
|
|
115
|
-
/**
|
|
116
|
-
* The theme's class or class list — `'theme-midnight'`, `'.theme-midnight.compact'` — added to
|
|
117
|
-
* the `<html>` of every preview iframe while the theme is selected.
|
|
118
|
-
*/
|
|
119
|
-
value: string;
|
|
120
|
-
/** The label shown in the dropdown. */
|
|
121
|
-
label: string;
|
|
122
|
-
/**
|
|
123
|
-
* Stylesheets loaded into a preview while this theme is selected, layered on top of
|
|
124
|
-
* `html.assets.css` (they are never replaced). Every preview document carries a `<link>` for
|
|
125
|
-
* each of these from the start — inert until the theme is selected — so switching costs no
|
|
126
|
-
* request and shows no flash.
|
|
127
|
-
*
|
|
128
|
-
* The CSS is keyed on the theme's class list, so a section's `Themes:` entry gets the same
|
|
129
|
-
* stylesheets as soon as it resolves to the same classes (`.theme-midnight` here and in the
|
|
130
|
-
* KSS comment); a section theme that matches no configured entry simply loads no extra CSS.
|
|
131
|
-
*/
|
|
132
|
-
css?: string[];
|
|
133
|
-
}
|
|
134
|
-
/** Every styleguide option except the accent colour, which carries the deprecated `theme` alias. */
|
|
135
|
-
interface StyleguideOptions {
|
|
136
|
-
mode: 'development' | 'production';
|
|
137
|
-
outDir: string;
|
|
138
|
-
contentDir: `${string}/`;
|
|
139
|
-
projectTitle: string;
|
|
140
|
-
deactivateDarkMode?: boolean;
|
|
141
|
-
launchInEditor?: boolean | {
|
|
142
|
-
rootDir: string;
|
|
143
|
-
};
|
|
144
|
-
/** The themes offered by the header's **Theme** dropdown. */
|
|
145
|
-
previewThemes?: PreviewTheme[];
|
|
146
|
-
/** @deprecated Renamed to `previewThemes`, to tell it apart from `brandColor`. */
|
|
147
|
-
themes?: PreviewTheme[];
|
|
148
|
-
/**
|
|
149
|
-
* Reload a preview iframe when its theme changes, instead of swapping the theme's classes and
|
|
150
|
-
* stylesheets into the loaded document.
|
|
151
|
-
*
|
|
152
|
-
* Off by default: the in-place swap is instant and keeps the preview's state. Turn it on when a
|
|
153
|
-
* preview's own JavaScript reads styling at startup — components that measure, canvas/chart
|
|
154
|
-
* rendering, web components that snapshot tokens on connect — and so needs to run again against
|
|
155
|
-
* the new theme. A preview is reloaded only when the visitor actually changes a theme, never on
|
|
156
|
-
* the initial page load.
|
|
157
|
-
*/
|
|
158
|
-
reloadPreviewsOnThemeChange?: boolean;
|
|
159
|
-
/**
|
|
160
|
-
* Let search engines index the generated styleguide.
|
|
161
|
-
*
|
|
162
|
-
* Off by default: a styleguide is internal documentation, and its output directory is usually
|
|
163
|
-
* served from a host that is reachable without being meant for the public. Every build writes a
|
|
164
|
-
* `robots.txt` into the output root, and every page carries a matching `<meta name="robots">` —
|
|
165
|
-
* `noindex, nofollow` while this is off, `index, follow` once it is on.
|
|
166
|
-
*/
|
|
167
|
-
allowSearchEngineIndexing?: boolean;
|
|
168
|
-
logoSignet?: {
|
|
169
|
-
href: string;
|
|
170
|
-
} | {
|
|
171
|
-
svgContent: string;
|
|
172
|
-
};
|
|
173
|
-
html: {
|
|
174
|
-
lang: string;
|
|
175
|
-
assets: {
|
|
176
|
-
css: {
|
|
177
|
-
type?: 'regular' | 'overwriteStyleguide';
|
|
178
|
-
src: string;
|
|
179
|
-
}[];
|
|
180
|
-
js: {
|
|
181
|
-
type?: 'regular' | 'overwriteStyleguide';
|
|
182
|
-
src: string;
|
|
183
|
-
additionalAttributes?: Record<string, string>;
|
|
184
|
-
}[];
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
plugins?: {
|
|
188
|
-
ogImage?: (section: in2Section) => string;
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* The styleguide configuration. The accent colour is required under one of its two names:
|
|
193
|
-
* `brandColor`, or the deprecated `theme`.
|
|
194
|
-
*
|
|
195
|
-
* `theme` never had anything to do with the preview themes; it is the colour behind
|
|
196
|
-
* `<meta name="theme-color">`, the generated favicons and the styleguide UI's highlight — hence
|
|
197
|
-
* the rename, which also ends its collision with `themes` / `previewThemes`.
|
|
198
|
-
*/
|
|
199
|
-
type StyleguideConfiguration = (StyleguideOptions & {
|
|
200
|
-
brandColor: StyleguideBrandColor;
|
|
201
|
-
theme?: never;
|
|
202
|
-
}) | (StyleguideOptions & {
|
|
203
|
-
/** @deprecated Renamed to `brandColor` — this is the accent colour, not a preview theme. */
|
|
204
|
-
theme: StyleguideBrandColor;
|
|
205
|
-
brandColor?: never;
|
|
206
|
-
});
|
|
207
|
-
/**
|
|
208
|
-
* A configuration with the deprecated aliases resolved away. Everything past
|
|
209
|
-
* {@link resolveConfiguration} works with this, so no internal code has to know about the old names.
|
|
210
|
-
*/
|
|
211
|
-
interface ResolvedStyleguideConfiguration extends StyleguideOptions {
|
|
212
|
-
brandColor: StyleguideBrandColor;
|
|
213
|
-
previewThemes: PreviewTheme[];
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Resolve the deprecated `theme` / `themes` aliases into `brandColor` / `previewThemes`, warning
|
|
217
|
-
* once per option. Idempotent, so the public entry points can each call it without re-warning.
|
|
218
|
-
*/
|
|
219
|
-
declare function resolveConfiguration(config: StyleguideConfiguration | ResolvedStyleguideConfiguration): ResolvedStyleguideConfiguration;
|
|
220
|
-
interface StyleguideBuildOutput {
|
|
221
|
-
errors?: {
|
|
222
|
-
overwrittenSectionsIds?: string[];
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
interface MenuSectionMapping {
|
|
226
|
-
title: string;
|
|
227
|
-
items: {
|
|
228
|
-
label: string;
|
|
229
|
-
href: string;
|
|
230
|
-
status?: string;
|
|
231
|
-
}[];
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Expensive, parse-derived state computed once and reused across incremental rebuilds.
|
|
235
|
-
* A markup-only edit never changes section structure, so the parsed tree, navigation mappings,
|
|
236
|
-
* and lookups stay valid; only affected sections are recompiled and rewritten.
|
|
237
|
-
*/
|
|
238
|
-
interface StyleguideContext {
|
|
239
|
-
baseDirectory: string;
|
|
240
|
-
parsedContent: in2FirstLevelSection[];
|
|
241
|
-
overwrittenSectionsIds: string[];
|
|
242
|
-
sectionsById: Map<string, SectionMeta>;
|
|
243
|
-
/** section id -> original (pre-compile) markup, i.e. the compile input */
|
|
244
|
-
rawMarkupBySection: Map<string, string>;
|
|
245
|
-
/** section id -> compiled markup that is NOT yet <insert-markup>-resolved (persistent) */
|
|
246
|
-
compiledRepository: Map<string, {
|
|
247
|
-
markup: string;
|
|
248
|
-
}>;
|
|
249
|
-
/** refId -> ids whose compiled markup embeds <insert-markup>refId</insert-markup> */
|
|
250
|
-
insertMarkupConsumers: Map<string, Set<string>>;
|
|
251
|
-
headerHtml: string;
|
|
252
|
-
searchHtml: string;
|
|
253
|
-
menuSectionMapping: MenuSectionMapping[];
|
|
254
|
-
/** section id (second & third level) -> its parsed node */
|
|
255
|
-
nodeById: Map<string, in2Section>;
|
|
256
|
-
/** any section id -> the location of its owning second-level section (for preview regen) */
|
|
257
|
-
ownerLocationById: Map<string, {
|
|
258
|
-
firstLevelIndex: number;
|
|
259
|
-
secondLevelIndex: number;
|
|
260
|
-
}>;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Parse given contentDir and get structured data for further processing
|
|
264
|
-
*/
|
|
265
|
-
declare function parseStyleguide(contentDir: StyleguideConfiguration['contentDir']): Promise<{
|
|
266
|
-
content: in2FirstLevelSection[];
|
|
267
|
-
overwrittenSectionsIds: string[];
|
|
268
|
-
}>;
|
|
269
|
-
/**
|
|
270
|
-
* Full build: parse, compile every section, and write all fullpage + preview files. Returns the
|
|
271
|
-
* reusable context so the watcher can perform targeted incremental rebuilds afterwards.
|
|
272
|
-
*/
|
|
273
|
-
declare function buildAll(input: StyleguideConfiguration | ResolvedStyleguideConfiguration): Promise<{
|
|
274
|
-
errors: StyleguideBuildOutput['errors'];
|
|
275
|
-
context: StyleguideContext;
|
|
276
|
-
}>;
|
|
277
|
-
/**
|
|
278
|
-
* Builds the styleguide
|
|
279
|
-
* @param config - The configuration for the styleguide
|
|
280
|
-
*/
|
|
281
|
-
declare function buildStyleguide(config: StyleguideConfiguration): Promise<StyleguideBuildOutput>;
|
|
282
|
-
/**
|
|
283
|
-
* Incrementally rebuild only the sections affected by a markup change: recompile their pug
|
|
284
|
-
* (cache-aware), re-resolve <insert-markup>, and rewrite just their fullpage + owning preview files.
|
|
285
|
-
* `changedSectionIds` are the sections whose pug (or a dependency) changed.
|
|
286
|
-
*/
|
|
287
|
-
declare function rebuildSections(config: ResolvedStyleguideConfiguration, context: StyleguideContext, changedSectionIds: Iterable<string>): Promise<void>;
|
|
288
|
-
/**
|
|
289
|
-
* What triggered a {@link watchStyleguide} rebuild:
|
|
290
|
-
* - `structural` — a CSS/SCSS/Markdown edit that can change section structure; the whole styleguide is rebuilt.
|
|
291
|
-
* - `markup` — a Pug/HTML edit; only `sections` (those depending on `file`) are rebuilt.
|
|
292
|
-
*/
|
|
293
|
-
type StyleguideChange = {
|
|
294
|
-
type: 'structural';
|
|
295
|
-
} | {
|
|
296
|
-
type: 'markup';
|
|
297
|
-
files: string[];
|
|
298
|
-
sections: string[];
|
|
299
|
-
};
|
|
300
|
-
/**
|
|
301
|
-
* Builds the styleguide and watches for changes
|
|
302
|
-
* @param input - The configuration for the styleguide
|
|
303
|
-
* @param onChange - Optional callback invoked after each rebuild, with the change that triggered it
|
|
304
|
-
* @param onError - Optional callback function to call when an error occurs while building the styleguide
|
|
305
|
-
*/
|
|
306
|
-
declare function watchStyleguide(input: StyleguideConfiguration | ResolvedStyleguideConfiguration, onChange?: (change: StyleguideChange) => void, onError?: (errorData: StyleguideBuildOutput['errors']) => void): Promise<void>;
|
|
307
|
-
|
|
308
|
-
export { buildAll, buildStyleguide, createLogger, logger, parseStyleguide, rebuildSections, resolveConfiguration, watchStyleguide };
|
|
309
|
-
export type { LogBox, Logger, PreviewTheme, ResolvedStyleguideConfiguration, StyleguideBrandColor, StyleguideChange, StyleguideConfiguration, StyleguideContext };
|
|
1
|
+
export { B as BuildAllOptions, L as LogBox, a as Logger, P as PreviewTheme, R as ResolvedStyleguideConfiguration, b as StyleguideBrandColor, c as StyleguideChange, S as StyleguideConfiguration, d as StyleguideContext, e as buildAll, f as buildStyleguide, g as createLogger, l as logger, p as parseStyleguide, r as rebuildSections, h as resolveConfiguration, w as watchStyleguide } from '../shared/kss-modern.Blhbay-v.mjs';
|