dispersa 0.1.3 → 0.3.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 (53) hide show
  1. package/README.md +65 -23
  2. package/dist/builders.cjs +1923 -47
  3. package/dist/builders.cjs.map +1 -1
  4. package/dist/builders.d.cts +155 -6
  5. package/dist/builders.d.ts +155 -6
  6. package/dist/builders.js +1922 -49
  7. package/dist/builders.js.map +1 -1
  8. package/dist/cli/cli.d.ts +11 -0
  9. package/dist/cli/cli.js +201 -0
  10. package/dist/cli/cli.js.map +1 -0
  11. package/dist/cli/config.d.ts +8 -0
  12. package/dist/cli/config.js +8 -0
  13. package/dist/cli/config.js.map +1 -0
  14. package/dist/cli/index.d.ts +1 -0
  15. package/dist/cli/index.js +203 -0
  16. package/dist/cli/index.js.map +1 -0
  17. package/dist/filters.cjs +8 -7
  18. package/dist/filters.cjs.map +1 -1
  19. package/dist/filters.d.cts +13 -16
  20. package/dist/filters.d.ts +13 -16
  21. package/dist/filters.js +8 -7
  22. package/dist/filters.js.map +1 -1
  23. package/dist/{index-CPB9Ea9U.d.ts → index-BkvV7Z54.d.cts} +183 -60
  24. package/dist/{index-DKf9WMQG.d.cts → index-DJ_UHSQG.d.ts} +183 -60
  25. package/dist/index.cjs +2121 -226
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +8 -8
  28. package/dist/index.d.ts +8 -8
  29. package/dist/index.js +2120 -228
  30. package/dist/index.js.map +1 -1
  31. package/dist/preprocessors.cjs.map +1 -1
  32. package/dist/preprocessors.d.cts +2 -2
  33. package/dist/preprocessors.d.ts +2 -2
  34. package/dist/preprocessors.js.map +1 -1
  35. package/dist/renderers.cjs.map +1 -1
  36. package/dist/renderers.d.cts +6 -6
  37. package/dist/renderers.d.ts +6 -6
  38. package/dist/renderers.js.map +1 -1
  39. package/dist/transforms.cjs +5 -5
  40. package/dist/transforms.cjs.map +1 -1
  41. package/dist/transforms.d.cts +2 -2
  42. package/dist/transforms.d.ts +2 -2
  43. package/dist/transforms.js +5 -5
  44. package/dist/transforms.js.map +1 -1
  45. package/dist/{types-DM5faYUn.d.cts → types-BAv39mum.d.cts} +1 -1
  46. package/dist/{types-C1GpiJ6q.d.ts → types-Bc0kA7De.d.cts} +10 -10
  47. package/dist/{types-C1GpiJ6q.d.cts → types-Bc0kA7De.d.ts} +10 -10
  48. package/dist/{types-Cl-1UYGD.d.ts → types-BzNcG-rI.d.ts} +1 -1
  49. package/dist/{types-DJH6_4U9.d.ts → types-CZb19kiq.d.ts} +1 -1
  50. package/dist/{types-DbufGPrb.d.cts → types-CussyWwe.d.cts} +1 -1
  51. package/dist/{types-DdPWYkgh.d.ts → types-CzHa7YkW.d.ts} +1 -1
  52. package/dist/{types-BDY1xBmD.d.cts → types-DWKq-eJj.d.cts} +1 -1
  53. package/package.json +18 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Dispersa
2
2
 
3
- A TypeScript build system for processing [DTCG 2025.10](https://www.designtokens.org/) design tokens. Dispersa loads resolver documents, resolves references and modifiers, applies filters and transforms, then renders output to CSS, JSON, and JS/TS modules.
3
+ A TypeScript build system for processing [DTCG 2025.10](https://www.designtokens.org/) design tokens. Dispersa loads resolver documents, resolves references and modifiers, applies filters and transforms, then renders output to CSS, JSON, JS/TS or custom modules.
4
4
 
5
5
  ## Features
6
6
 
@@ -17,7 +17,17 @@ A TypeScript build system for processing [DTCG 2025.10](https://www.designtokens
17
17
 
18
18
  **Composite types:** `shadow`, `typography`, `border`, `strokeStyle`, `transition`, `gradient`
19
19
 
20
- ## Installation
20
+ ## Getting started
21
+
22
+ ### New project
23
+
24
+ ```bash
25
+ pnpm create dispersa
26
+ ```
27
+
28
+ The scaffold prompts for a project directory, lets you pick a template (programmatic or CLI-based), and optionally installs dependencies.
29
+
30
+ ### Add to an existing project
21
31
 
22
32
  ```bash
23
33
  pnpm add dispersa
@@ -108,11 +118,11 @@ for (const output of result.outputs) {
108
118
  }
109
119
  ```
110
120
 
111
- > For file-based tokens, define JSON files and reference them with `$ref` in your resolver document. See the [`basic` example](./examples/basic/) for a complete setup.
121
+ > For file-based tokens, define JSON files and reference them with `$ref` in your resolver document. See the [`typescript-starter` example](./examples/typescript-starter/) for a complete setup.
112
122
 
113
123
  ## Output formats
114
124
 
115
- Dispersa ships four builder functions. Each returns an `OutputConfig` that can be passed to `build()`.
125
+ Dispersa ships five builder functions. Each returns an `OutputConfig` that can be passed to `build()`.
116
126
 
117
127
  ### `css(config)`
118
128
 
@@ -129,6 +139,7 @@ Renders CSS custom properties.
129
139
  | `minify` | `boolean` | `false` | Minify output |
130
140
  | `transforms` | `Transform[]` | -- | Per-output transforms |
131
141
  | `filters` | `Filter[]` | -- | Per-output filters |
142
+ | `hooks` | `LifecycleHooks` | -- | Per-output lifecycle hooks |
132
143
 
133
144
  ### `json(config)`
134
145
 
@@ -144,6 +155,7 @@ Renders JSON output.
144
155
  | `minify` | `boolean` | -- | Minify output |
145
156
  | `transforms` | `Transform[]` | -- | Per-output transforms |
146
157
  | `filters` | `Filter[]` | -- | Per-output filters |
158
+ | `hooks` | `LifecycleHooks` | -- | Per-output lifecycle hooks |
147
159
 
148
160
  ### `js(config)`
149
161
 
@@ -160,6 +172,31 @@ Renders JavaScript/TypeScript modules.
160
172
  | `minify` | `boolean` | -- | Minify output |
161
173
  | `transforms` | `Transform[]` | -- | Per-output transforms |
162
174
  | `filters` | `Filter[]` | -- | Per-output filters |
175
+ | `hooks` | `LifecycleHooks` | -- | Per-output lifecycle hooks |
176
+
177
+ ### `tailwind(config)`
178
+
179
+ Renders Tailwind CSS v4 `@theme` blocks.
180
+
181
+ | Option | Type | Default | Description |
182
+ | --------------- | ------------------------------ | ---------- | -------------------------------------------- |
183
+ | `name` | `string` | -- | Unique output identifier |
184
+ | `file` | `string \| function` | -- | Output path (supports `{modifier}` patterns) |
185
+ | `preset` | `'bundle' \| 'standalone'` | `'bundle'` | Output preset |
186
+ | `includeImport` | `boolean` | -- | Include `@import "tailwindcss"` directive |
187
+ | `namespace` | `string` | -- | Prefix for CSS variable names |
188
+ | `selector` | `string \| SelectorFunction` | `':root'` | CSS selector |
189
+ | `mediaQuery` | `string \| MediaQueryFunction` | -- | Media query wrapper |
190
+ | `minify` | `boolean` | `false` | Minify output |
191
+ | `transforms` | `Transform[]` | -- | Per-output transforms |
192
+ | `filters` | `Filter[]` | -- | Per-output filters |
193
+ | `hooks` | `LifecycleHooks` | -- | Per-output lifecycle hooks |
194
+
195
+ ### Experimental: native platform outputs
196
+
197
+ Dispersa also ships `ios()` and `android()` builders for Swift/SwiftUI and Kotlin/Jetpack Compose. These are **experimental** -- APIs and generated code may change.
198
+
199
+ See the [multi-platform example](./examples/multi-platform/) for a complete setup.
163
200
 
164
201
  ## Output presets
165
202
 
@@ -658,10 +695,10 @@ All hooks support both sync and async functions.
658
695
 
659
696
  ## CLI
660
697
 
661
- Dispersa ships a CLI package (`dispersa-cli`) with a config-first workflow.
698
+ Dispersa includes a CLI for a config-first workflow.
662
699
 
663
700
  ```bash
664
- pnpm add dispersa-cli
701
+ pnpm add dispersa
665
702
  ```
666
703
 
667
704
  ```bash
@@ -673,7 +710,7 @@ The CLI auto-discovers config files named `dispersa.config.(ts|js|mts|mjs|cts|cj
673
710
 
674
711
  ```typescript
675
712
  // dispersa.config.ts
676
- import { defineConfig } from 'dispersa-cli'
713
+ import { defineConfig } from 'dispersa/config'
677
714
  import { css, json } from 'dispersa'
678
715
  import { colorToHex, nameKebabCase } from 'dispersa/transforms'
679
716
 
@@ -727,15 +764,16 @@ const dispersa = new Dispersa(options?: DispersaOptions)
727
764
 
728
765
  ### Subpath exports
729
766
 
730
- | Export | Description |
731
- | ------------------------ | ---------------------------------------------------------------- |
732
- | `dispersa` | `Dispersa` class, builder functions (`css`, `json`, `js`), types |
733
- | `dispersa/transforms` | Built-in transform factories |
734
- | `dispersa/filters` | Built-in filter factories |
735
- | `dispersa/builders` | Output builder functions |
736
- | `dispersa/renderers` | Renderer types, `defineRenderer`, and `outputTree` helper |
737
- | `dispersa/preprocessors` | Preprocessor type |
738
- | `dispersa/errors` | Error classes (`DispersaError`, `TokenReferenceError`, etc.) |
767
+ | Export | Description |
768
+ | ------------------------ | ---------------------------------------------------------------------------- |
769
+ | `dispersa` | `Dispersa` class, builder functions (`css`, `json`, `js`, `tailwind`), types |
770
+ | `dispersa/transforms` | Built-in transform factories |
771
+ | `dispersa/filters` | Built-in filter factories |
772
+ | `dispersa/builders` | Output builder functions |
773
+ | `dispersa/renderers` | Renderer types, `defineRenderer`, and `outputTree` helper |
774
+ | `dispersa/preprocessors` | Preprocessor type |
775
+ | `dispersa/errors` | Error classes (`DispersaError`, `TokenReferenceError`, etc.) |
776
+ | `dispersa/config` | `defineConfig` helper for CLI config files |
739
777
 
740
778
  Everything outside these entry points is internal and not a stable API contract.
741
779
 
@@ -758,13 +796,17 @@ Resolver -> Preprocessors -> $ref resolution -> Parse/flatten -> Alias resolutio
758
796
 
759
797
  See [`examples/`](./examples/) for complete working projects. Suggested learning path:
760
798
 
761
- | Example | Focus |
762
- | ---------------------------------------------- | --------------------------------------------- |
763
- | [`basic`](./examples/basic/) | Minimal setup with light/dark themes |
764
- | [`no-filesystem`](./examples/no-filesystem/) | In-memory mode with inline tokens |
765
- | [`custom-plugins`](./examples/custom-plugins/) | Custom transforms, filters, and renderers |
766
- | [`advanced`](./examples/advanced/) | Multi-modifier system with all output formats |
767
- | [`enterprise`](./examples/enterprise/) | Multi-brand, multi-platform at scale |
799
+ | Example | Focus |
800
+ | ------------------------------------------------------ | --------------------------------------------------------- |
801
+ | [`typescript-starter`](./examples/typescript-starter/) | Programmatic build script with themed CSS |
802
+ | [`cli-starter`](./examples/cli-starter/) | Config-file workflow using the dispersa CLI |
803
+ | [`in-memory`](./examples/in-memory/) | In-memory mode with inline tokens |
804
+ | [`custom-plugins`](./examples/custom-plugins/) | Custom transforms, filters, and renderers |
805
+ | [`multi-format`](./examples/multi-format/) | Multi-modifier system with all output formats |
806
+ | [`multi-brand`](./examples/multi-brand/) | Multi-brand, multi-platform at scale |
807
+ | [`multi-platform`](./examples/multi-platform/) | CSS, Tailwind, iOS, and Android from one set |
808
+ | [`split-by-type`](./examples/split-by-type/) | Filtered outputs split by token category |
809
+ | [`atlassian-semantic`](./examples/atlassian-semantic/) | Semantic tokens with density, motion, and theme modifiers |
768
810
 
769
811
  ## License
770
812