pattern-dump 0.1.0-alpha.0 → 0.1.0-alpha.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.
@@ -1,7 +1,9 @@
1
1
  import type { ShellBrandConfig, SwatchSlots, ThemeSwitch } from "../contracts/index.js";
2
2
  export type { ShellBrandConfig, SwatchSlots, ThemeSwitch };
3
+ export { ConfigError, configProblems, validateConfig } from "./validate.js";
3
4
  export interface AssetsConfig {
4
- /** 'central' (default) serves the central assets dir; 'component-relative' resolves from component folder. */
5
+ /** Where assets live. Only 'central' (the default: one assets dir, served at /assets/) is supported
6
+ * so far; 'component-relative' is reserved, and the config check rejects it as not supported yet. */
5
7
  strategy?: "central" | "component-relative";
6
8
  /**
7
9
  * Asset directory (relative to project root), served at /assets/. Accepts an ARRAY of roots —
@@ -11,12 +13,14 @@ export interface AssetsConfig {
11
13
  * normalized to `/assets/…` by matching a root basename — depth-independent.
12
14
  */
13
15
  dir?: string | string[];
14
- /** CSS files (relative to assets dir) to link in every preview document, before component CSS. */
16
+ /** Stylesheets to link in every preview document, before component CSS: a path relative to the
17
+ * assets dir, or a full URL (e.g. a web-font stylesheet), which is linked as it is. */
15
18
  css?: string[];
16
19
  }
17
20
  export interface StylesConfig {
18
- /** 'parallel' (default, hTWOo-native) or 'co-located' (framework-oriented). */
19
- strategy: "parallel" | "co-located";
21
+ /** Where styles live. Only 'parallel' (the default: a separate tree mirroring the patterns) is
22
+ * supported so far; 'co-located' is reserved, and the config check rejects it as not supported yet. */
23
+ strategy?: "parallel" | "co-located";
20
24
  /** Source tree root; also the home for global/base/theme styles. */
21
25
  dir: string;
22
26
  /**
@@ -102,15 +106,18 @@ export interface PatternDumpConfig {
102
106
  helpers?: string;
103
107
  /**
104
108
  * The always-injected document-base layer (M5-CSS-EXTERNAL §2.2: a preview links
105
- * closure + base + active theme). Names the base-origin path(s) — e.g.
106
- * ['base/reset', 'base/root', 'base/font.base'] — relative to `styles.dir`.
109
+ * closure + base + active theme). Names file or folder paths — e.g.
110
+ * ['base/reset', 'base/root', 'base/font.base'] — relative to `styles.dir`; `"."` is the whole tree.
107
111
  *
108
- * When present and non-empty, PD links the compiled base layer (`/_pd/base.css`, the
109
- * origin-unattributed shared rules — resets, `:root`, `@font-face`, and family-level classes
110
- * with no single owning component) into every preview, BENEATH the component closure so it
111
- * never overrides it. Absent → not linked (current behaviour; a project whose classes all
112
- * attribute to components needs no shared layer). The `__base__` layer must still carry no
113
- * MIS-attributed rules — anything with a genuine owner attributes to that owner.
112
+ * When present and non-empty, PD links the compiled base layer (`/_pd/base.css`) into every
113
+ * preview, BENEATH the component closure so it never overrides it. The layer holds:
114
+ * - every rule from a LISTED path, even one whose file belongs to a component (a component's
115
+ * `body` rule needed on every page, or a whole PatternLab stylesheet with `"."`);
116
+ * - the origin-unattributed rules — `:root`, `@font-face`, family-level classes with no single
117
+ * owning component — listed or not, so shared partials stay available.
118
+ * Entries that match no file are reported at startup. Absent → not linked (a project whose classes
119
+ * all attribute to components needs no shared layer). Class ownership is unchanged by listing: a
120
+ * class still belongs to the component whose file authored it.
114
121
  */
115
122
  documentBase?: string[];
116
123
  /**
@@ -0,0 +1,10 @@
1
+ import type { PatternDumpConfig } from "./index.js";
2
+ /** A config that cannot be used, with a message written for the person editing it. The CLI prints
3
+ * its message alone, without a stack trace. */
4
+ export declare class ConfigError extends Error {
5
+ name: string;
6
+ }
7
+ /** The problems with a loaded config, one line each; empty when it is valid. */
8
+ export declare function configProblems(raw: unknown): string[];
9
+ /** Check a loaded config and return it typed, or throw one error listing every problem. */
10
+ export declare function validateConfig(raw: unknown, source: string): PatternDumpConfig;
@@ -4,12 +4,13 @@ export type ComponentId = string;
4
4
  export type Category = string;
5
5
  export type ComponentStatus = "draft" | "stable" | "deprecated";
6
6
  /**
7
- * Preview layout mode (M4.2). How the component sits in the stage:
8
- * - "centered": inner <main> hugs content, height-fits, stage centers it (atoms/molecules/organisms)
9
- * - "full": inner <main> fills the stage width AND height, top-aligned (pages/templates)
7
+ * Preview layout mode (M4.2). How the component sits in the stage. The preview document is the same
8
+ * in both — the markup directly in <body>, no wrapper — only the frame around it differs:
9
+ * - "centered": the frame is sized to what the content needs (pd-width, measured at the full width
10
+ * available) and to its height (pd-height), and the stage centres it (atoms/molecules/organisms)
11
+ * - "full": the frame fills the stage width AND height, top-aligned (pages/templates)
10
12
  * This is the RESOLVED mode (category default ← category index.md frontmatter ← component override),
11
- * so the shell renders directly without re-deriving precedence. Width is pure CSS; height is measured
12
- * for centered mode only (full mode fills).
13
+ * so the shell renders directly without re-deriving precedence.
13
14
  */
14
15
  export type LayoutMode = "centered" | "full";
15
16
  /** A named data set applied over defaults — a state or a documentation example. */
@@ -164,10 +165,22 @@ export interface DiagnosticsGraph {
164
165
  /** The subject's commit SHA when it has one (pinned in the report). */
165
166
  subjectSha?: string;
166
167
  }
167
- /** The §0 scope boundary — embedded verbatim in every report/view so the artifact states its own
168
- * limits. Corrected for the sweep's real coverage: the rendered-contrast (needsRendering) axe tier
169
- * is a named exclusion (it needs browser layout the static jsdom sweep cannot produce). */
170
- export declare const SCOPE_BOUNDARY = "## Scope \u2014 the boundary is part of the artifact\n\n**Covers** \u2014 machine-detectable, static, single-render (no browser layout):\n- **HTML content-model** (html-validate) \u2014 nesting/permitted-content violations.\n- **Structural a11y** (axe, alwaysOn tier) \u2014 labels, names, ARIA, roles, image-alt.\n- **Schema** \u2014 required/shape violations against `component.schema.json`.\n- **Render outcome** \u2014 blank / error / ok (metadata, never itself a defect).\n\n**Deliberately NOT covered \u2014 named boundaries, not misses:**\n- **Rendered-contrast (axe needsRendering tier)** \u2014 contrast, aria-hidden-focus, duplicate-id-aria.\n These require real browser layout/paint; the static jsdom sweep cannot produce them. The\n per-component panel shows them (live iframe); this aggregate does not. Fewer rule types here is a\n scope boundary, not a gap.\n- **Structural/graph findings** \u2014 dead subtrees, a shared-base \"component\", flattened variant families.\n Those are the style graph's lens, not this one.\n- **PD reporting gaps** \u2014 PD under-claiming (e.g. missing provenance) is not a subject defect.\n- **Interactive / behavioural** \u2014 focus traps, keyboard flow, escape handling. Single static render only.\n- **Data-masked** \u2014 a component that renders empty for want of data won't throw the violations it would\n when populated; findings are annotated with render outcome wherever it is blank.\n\nA component with zero findings is **not \"clean\" \u2014 it is \"clean of static machine-detectable defects.\"**\nThat is the honest claim; never \"clean\".";
168
+ /** One line of the audit scope: a named area and what it means. */
169
+ export interface AuditScopeItem {
170
+ name: string;
171
+ detail: string;
172
+ }
173
+ /** What the corpus audit checks and what it deliberately leaves out. Carried with every audit result
174
+ * (every `pd audit` format and the workbench's Audit tab), because a defect count is only meaningful
175
+ * next to its limits. Data, not formatted text: each renderer (Markdown, plain text, JSON, the
176
+ * workbench's DOM) formats it for its own medium. */
177
+ export interface AuditScope {
178
+ covered: AuditScopeItem[];
179
+ notCovered: AuditScopeItem[];
180
+ /** The closing statement on what zero findings means. */
181
+ note: string;
182
+ }
183
+ export declare const AUDIT_SCOPE: AuditScope;
171
184
  /** Per-rule roll-up: blast radius (distinct components) primary, occurrences secondary. */
172
185
  export interface AuditRuleRollup {
173
186
  engine: string;
@@ -190,8 +203,8 @@ export interface AuditComponentRollup {
190
203
  /** The `pd audit` report as structured data — the single rollup every output format serializes.
191
204
  * All roll-ups (headline numbers, rule blast-radius table, per-component list) are computed ONCE in
192
205
  * `buildAuditRollup`; `md`/`text`/`json` (and the workbench facet) are renderers over this object,
193
- * never independent string builders. A CI consumer reading the `json` gets `scope` (the §0 boundary)
194
- * + `headline` alongside the count, never a bare number. */
206
+ * never independent string builders. A CI consumer reading the `json` gets `scope` (what the audit covers)
207
+ * and `headline` alongside the count, never a bare number. */
195
208
  export interface AuditRollup {
196
209
  subjectSha?: string;
197
210
  /** The headline sentence, plain (no markdown emphasis); renderers wrap/position it. */
@@ -209,8 +222,8 @@ export interface AuditRollup {
209
222
  };
210
223
  rulesByBlast: AuditRuleRollup[];
211
224
  perComponent: AuditComponentRollup[];
212
- /** The §0 scope boundary, verbatim (SCOPE_BOUNDARY). Carried in every format. */
213
- scope: string;
225
+ /** What the audit covers and leaves out (AUDIT_SCOPE). Carried in every format. */
226
+ scope: AuditScope;
214
227
  }
215
228
  /** Build the structured rollup from the graph — the numbers exist as data here, not only as strings.
216
229
  * PURE: same graph → same rollup, no I/O or clock. The one builder both the CLI report renderers and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pattern-dump",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.2",
4
4
  "description": "A workbench for HTML and CSS design systems: live component previews, docs, checks and static publishing.",
5
5
  "keywords": [
6
6
  "design-system",
@@ -50,7 +50,8 @@
50
50
  "dist",
51
51
  "templates",
52
52
  "README.md",
53
- "LICENSE"
53
+ "LICENSE",
54
+ "CHANGELOG.md"
54
55
  ],
55
56
  "engines": {
56
57
  "node": ">=20.10"