pattern-dump 0.1.0-alpha.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.
Files changed (47) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +92 -0
  3. package/dist/dev-ui/main.css +1825 -0
  4. package/dist/dev-ui/main.js +3054 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +7 -0
  7. package/dist/pd.js +4759 -0
  8. package/dist/types/config/index.d.ts +145 -0
  9. package/dist/types/contracts/dev-protocol.d.ts +624 -0
  10. package/dist/types/contracts/index.d.ts +294 -0
  11. package/package.json +76 -0
  12. package/templates/base/README.md +77 -0
  13. package/templates/base/_gitignore +3 -0
  14. package/templates/base/pattern-dump.config.ts +36 -0
  15. package/templates/base/src/scripts/globals.d.ts +6 -0
  16. package/templates/base/src/styles/base/_tokens.scss +8 -0
  17. package/templates/base/src/styles/base/document.scss +18 -0
  18. package/templates/base/themes/dark.theme.scss +8 -0
  19. package/templates/base/themes/light.theme.scss +8 -0
  20. package/templates/base/tsconfig.json +19 -0
  21. package/templates/examples/src/patterns/atoms/button/button.hbs +1 -0
  22. package/templates/examples/src/patterns/atoms/button/button.json +1 -0
  23. package/templates/examples/src/patterns/atoms/button/button.md +21 -0
  24. package/templates/examples/src/patterns/atoms/button/button.schema.json +11 -0
  25. package/templates/examples/src/patterns/atoms/button/button~icon.hbs +5 -0
  26. package/templates/examples/src/patterns/atoms/button/button~secondary.json +1 -0
  27. package/templates/examples/src/patterns/atoms/index.md +6 -0
  28. package/templates/examples/src/patterns/index.md +3 -0
  29. package/templates/examples/src/patterns/molecules/index.md +6 -0
  30. package/templates/examples/src/patterns/molecules/search-field/input/input.hbs +4 -0
  31. package/templates/examples/src/patterns/molecules/search-field/input/input.json +1 -0
  32. package/templates/examples/src/patterns/molecules/search-field/input/input.md +8 -0
  33. package/templates/examples/src/patterns/molecules/search-field/input/input.schema.json +10 -0
  34. package/templates/examples/src/patterns/molecules/search-field/search-field.hbs +5 -0
  35. package/templates/examples/src/patterns/molecules/search-field/search-field.json +1 -0
  36. package/templates/examples/src/patterns/molecules/search-field/search-field.md +21 -0
  37. package/templates/examples/src/patterns/molecules/search-field/search-field.schema.json +11 -0
  38. package/templates/examples/src/patterns/pages/example/example.hbs +11 -0
  39. package/templates/examples/src/patterns/pages/example/example.json +8 -0
  40. package/templates/examples/src/patterns/pages/example/example.md +11 -0
  41. package/templates/examples/src/patterns/pages/example/example.schema.json +14 -0
  42. package/templates/examples/src/patterns/pages/index.md +6 -0
  43. package/templates/examples/src/scripts/search-field.ts +16 -0
  44. package/templates/examples/src/styles/atoms/button.scss +36 -0
  45. package/templates/examples/src/styles/molecules/search-field/input.scss +21 -0
  46. package/templates/examples/src/styles/molecules/search-field.scss +13 -0
  47. package/templates/examples/src/styles/pages/example.scss +28 -0
@@ -0,0 +1,145 @@
1
+ import type { ShellBrandConfig, SwatchSlots, ThemeSwitch } from "../contracts/index.js";
2
+ export type { ShellBrandConfig, SwatchSlots, ThemeSwitch };
3
+ export interface AssetsConfig {
4
+ /** 'central' (default) serves the central assets dir; 'component-relative' resolves from component folder. */
5
+ strategy?: "central" | "component-relative";
6
+ /**
7
+ * Asset directory (relative to project root), served at /assets/. Accepts an ARRAY of roots —
8
+ * hTWOo needs `src/images` AND `src/fonts`. Each root is addressable by its basename under
9
+ * /assets/ (`/assets/images/x` → `<src/images>/x`); a single root also mirrors 1:1
10
+ * (`/assets/y` → `<dir>/y`). Relative refs in rendered markup (`../../images/icons.svg`) are
11
+ * normalized to `/assets/…` by matching a root basename — depth-independent.
12
+ */
13
+ dir?: string | string[];
14
+ /** CSS files (relative to assets dir) to link in every preview document, before component CSS. */
15
+ css?: string[];
16
+ }
17
+ export interface StylesConfig {
18
+ /** 'parallel' (default, hTWOo-native) or 'co-located' (framework-oriented). */
19
+ strategy: "parallel" | "co-located";
20
+ /** Source tree root; also the home for global/base/theme styles. */
21
+ dir: string;
22
+ /**
23
+ * SCSS entry point(s) to compile for `classOwnerIndex` + CSS bucketing, relative to `dir`.
24
+ * When set, ONLY these are compiled (one map per entry, first-writer-wins across them).
25
+ * When absent, every non-underscore `.scss` under `dir` is compiled (the glob default).
26
+ *
27
+ * A single design-system bundle (e.g. `htwoo.scss`) is the intended shape: attribution is
28
+ * source-map-mediated, so one bundle compile attributes every rule to its authoring partial.
29
+ * Pointing at a tree with several overlapping bundles (e.g. `htwoo.scss` + `htwoo.min.scss` +
30
+ * `style.scss`) compiles the same partials into multiple bundles and yields ambiguous, not
31
+ * merely noisy, attribution — name the one design-system entry here.
32
+ */
33
+ entry?: string | string[];
34
+ }
35
+ export interface ThemesConfig {
36
+ /** Directory of theme files (custom-property value-sets). */
37
+ dir: string;
38
+ /** Default theme name applied via data-theme on the preview body. */
39
+ default: string;
40
+ /** Switch wiring: attribute toggle (default) or per-theme stylesheet swap. */
41
+ switch?: ThemeSwitch;
42
+ /** Swatch configuration for the left-rail theme picker. */
43
+ swatch?: {
44
+ /**
45
+ * Ordered CSS custom-property names sampled per theme for the swatch strip.
46
+ * Defaults to ['--bodyBackground', '--themePrimary', '--accent'].
47
+ * Per-theme swatchSlots override is deferred.
48
+ */
49
+ slots: SwatchSlots;
50
+ };
51
+ }
52
+ export interface ShellConfig {
53
+ /** Brand slot rendered at the top of the left rail. */
54
+ brand?: ShellBrandConfig;
55
+ }
56
+ /**
57
+ * A Pattern Dump project config.
58
+ *
59
+ * RESOLUTION BASE — the one rule: every directory path in this config (`patternsDir`,
60
+ * `styles.dir`, `themes.dir`, `assets.dir`, `scriptsDir`, `helpers`, …) resolves against the
61
+ * **project root** (the `--root` dir), NOT against this file's location and NOT against the
62
+ * invoking `cwd`. This holds even when the file is supplied via `--config` from outside the
63
+ * root — which is what lets PD open a read-only project it does not own.
64
+ */
65
+ /** A pattern package named in the config: the npm name, or the name plus extra excludes. */
66
+ export type PackageReference = string | {
67
+ name: string;
68
+ exclude?: string[];
69
+ };
70
+ export interface PatternDumpConfig {
71
+ sourceDir: string;
72
+ patternsDir: string;
73
+ outDir: string;
74
+ styles: StylesConfig;
75
+ themes?: ThemesConfig;
76
+ /** Asset directory configuration. Served at /assets/. */
77
+ assets?: AssetsConfig;
78
+ /** Path to the scripts directory (relative to project root). requireScript bare ids resolve here. */
79
+ scriptsDir?: string;
80
+ /**
81
+ * Project-level behaviour scripts loaded into EVERY preview (e.g. hTWOo's src/ts dialog, nav,
82
+ * pivot, …). requireScript is per-component and cannot express "load these for every preview".
83
+ * Each entry is a bare id resolved from `scriptsDir` (root-relative — the single resolution base)
84
+ * or an absolute URL. Injected after markup, before the component's own requireScripts. Absent →
85
+ * none (current behaviour).
86
+ */
87
+ globalScripts?: string[];
88
+ /**
89
+ * Path to a project-level data directory (relative to the project root, the single resolution
90
+ * base). Every `*.json` in it is deep-merged into one global context, applied BENEATH component
91
+ * data: global → component defaults → variant → live. Component data always wins. Absent → no
92
+ * global tier (current behaviour). Loaded once at startup — a config'd context merge, not a
93
+ * pipeline; a `_data` edit needs a restart.
94
+ */
95
+ dataDir?: string;
96
+ /**
97
+ * Path to project Handlebars helpers — a directory of helper modules or a single module file,
98
+ * relative to the project root (the single resolution base). Each module is either a registrar
99
+ * (`module.exports = (Handlebars) => {…}`, the PatternLab/hTWOo shape) or a map of named functions.
100
+ * Loaded once at startup; the renderer invokes them per render. Absent → core helpers only.
101
+ */
102
+ helpers?: string;
103
+ /**
104
+ * 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`.
107
+ *
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.
114
+ */
115
+ documentBase?: string[];
116
+ /**
117
+ * Global master switch for folder overview pages. Default: true.
118
+ * A folder's index.md can set `overview: false` to suppress just that one folder.
119
+ */
120
+ overviews?: boolean;
121
+ /** Shell chrome configuration (brand slot, future: shell tokens). */
122
+ shell?: ShellConfig;
123
+ /**
124
+ * Pattern packages installed in this project, used ALONGSIDE its own patterns. Each package
125
+ * describes itself with a `patternDump` field in its package.json (see PackageManifest); peer
126
+ * dependencies that have one are followed. The project's own component wins when both define the
127
+ * same handle. `{ name, exclude }` hides some of a package's templates (globs relative to its
128
+ * patterns folder).
129
+ */
130
+ packages?: PackageReference[];
131
+ /** Globs (relative to `patternsDir`) of the project's own templates to leave undiscovered. */
132
+ exclude?: string[];
133
+ /**
134
+ * `pd build` — the static snapshot. `outDir` (relative to the root) defaults to the top-level
135
+ * `outDir`; `basePath` is where the snapshot will be hosted ("/" at a domain root, "/docs/" under a
136
+ * subpath) and defaults to "/". `audit: false` leaves the corpus audit out — it is not run, and the
137
+ * static site has no Audit tab. All three can be overridden on the command line.
138
+ */
139
+ build?: {
140
+ outDir?: string;
141
+ basePath?: string;
142
+ audit?: boolean;
143
+ };
144
+ }
145
+ export declare function defineConfig(config: PatternDumpConfig): PatternDumpConfig;