dispersa 0.4.2 → 1.0.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 +73 -39
- package/dist/android-CRDfSB3_.d.cts +126 -0
- package/dist/android-DANJjjPO.d.ts +126 -0
- package/dist/builders.cjs +220 -64
- package/dist/builders.cjs.map +1 -1
- package/dist/builders.d.cts +15 -13
- package/dist/builders.d.ts +15 -13
- package/dist/builders.js +220 -64
- package/dist/builders.js.map +1 -1
- package/dist/cli/cli.js +120 -7
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/config.d.ts +321 -0
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/index.js +119 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/dispersa-BC1kDF5u.d.ts +118 -0
- package/dist/dispersa-DL3J_Pmz.d.cts +118 -0
- package/dist/errors-qT4sJgSA.d.cts +104 -0
- package/dist/errors-qT4sJgSA.d.ts +104 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +1 -83
- package/dist/errors.d.ts +1 -83
- package/dist/errors.js.map +1 -1
- package/dist/filters.cjs.map +1 -1
- package/dist/filters.d.cts +2 -2
- package/dist/filters.d.ts +2 -2
- package/dist/filters.js.map +1 -1
- package/dist/{index-CNT2Meyf.d.cts → index-Dajm5rvM.d.ts} +311 -132
- package/dist/{index-CqdaN3X0.d.ts → index-De6SjZYH.d.cts} +311 -132
- package/dist/index.cjs +813 -355
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -329
- package/dist/index.d.ts +8 -329
- package/dist/index.js +807 -355
- package/dist/index.js.map +1 -1
- package/dist/lint.cjs +1017 -0
- package/dist/lint.cjs.map +1 -0
- package/dist/lint.d.cts +463 -0
- package/dist/lint.d.ts +463 -0
- package/dist/lint.js +997 -0
- package/dist/lint.js.map +1 -0
- package/dist/preprocessors.d.cts +2 -2
- package/dist/preprocessors.d.ts +2 -2
- package/dist/renderers.cjs.map +1 -1
- package/dist/renderers.d.cts +7 -6
- package/dist/renderers.d.ts +7 -6
- package/dist/renderers.js.map +1 -1
- package/dist/transforms.cjs +0 -12
- package/dist/transforms.cjs.map +1 -1
- package/dist/transforms.d.cts +3 -7
- package/dist/transforms.d.ts +3 -7
- package/dist/transforms.js +1 -12
- package/dist/transforms.js.map +1 -1
- package/dist/{types-CZb19kiq.d.ts → types-8MLtztK3.d.ts} +56 -1
- package/dist/{types-CussyWwe.d.cts → types-BHBHRm0a.d.cts} +56 -1
- package/dist/{types-BAv39mum.d.cts → types-BltzwVYK.d.cts} +1 -1
- package/dist/{types-DWKq-eJj.d.cts → types-CAdUV-fa.d.cts} +1 -1
- package/dist/{types-CzHa7YkW.d.ts → types-DztXKlka.d.ts} +1 -1
- package/dist/{types-Bc0kA7De.d.ts → types-TQHV1MrY.d.cts} +19 -1
- package/dist/{types-Bc0kA7De.d.cts → types-TQHV1MrY.d.ts} +19 -1
- package/dist/{types-BzNcG-rI.d.ts → types-ebxDimRz.d.ts} +1 -1
- package/package.json +11 -1
|
@@ -1,7 +1,305 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { c as TokenType, L as InternalResolvedTokens, R as ResolvedToken, a as ResolvedTokens } from './types-TQHV1MrY.js';
|
|
2
|
+
import { F as Filter } from './types-ebxDimRz.js';
|
|
3
|
+
import { B as BuildConfigBase, O as OutputConfigBase, P as Preprocessor, D as DispersaOptionsBase } from './types-8MLtztK3.js';
|
|
4
|
+
import { T as Transform } from './types-DztXKlka.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @license MIT
|
|
8
|
+
* Copyright (c) 2025-present Dispersa
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @fileoverview Core type definitions for the Dispersa linting system
|
|
15
|
+
*
|
|
16
|
+
* Inspired by ESLint and Terrazzo, this system provides a plugin-based
|
|
17
|
+
* architecture for validating design tokens against semantic rules.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Lint rule severity levels
|
|
22
|
+
*
|
|
23
|
+
* - `'off'` - Rule is disabled
|
|
24
|
+
* - `'warn'` - Rule issues warnings but doesn't fail the build
|
|
25
|
+
* - `'error'` - Rule issues errors and fails the build (if failOnError is true)
|
|
26
|
+
*/
|
|
27
|
+
type Severity = 'off' | 'warn' | 'error';
|
|
28
|
+
/**
|
|
29
|
+
* Metadata describing a lint rule
|
|
30
|
+
*
|
|
31
|
+
* @template MessageIds - Union type of message IDs this rule can produce
|
|
32
|
+
*/
|
|
33
|
+
type LintRuleMeta<MessageIds extends string = string> = {
|
|
34
|
+
/** Short name of the rule (e.g., 'require-description') */
|
|
35
|
+
name: string;
|
|
36
|
+
/** Human-readable description of what the rule checks */
|
|
37
|
+
description: string;
|
|
38
|
+
/** Optional URL to documentation for this rule */
|
|
39
|
+
url?: string;
|
|
40
|
+
/** Map of message IDs to message templates (supports {{placeholder}} interpolation) */
|
|
41
|
+
messages: Record<MessageIds, string>;
|
|
42
|
+
/** Token types this rule applies to. Default: 'all' */
|
|
43
|
+
appliesTo?: TokenType[] | 'all';
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Context object passed to rule's create() function
|
|
47
|
+
*
|
|
48
|
+
* Provides access to tokens, configuration, and the report function.
|
|
49
|
+
*
|
|
50
|
+
* @template MessageIds - Union type of message IDs this rule can produce
|
|
51
|
+
* @template Options - Rule-specific options type
|
|
52
|
+
*/
|
|
53
|
+
type LintRuleContext<MessageIds extends string = string, Options extends Record<string, unknown> = Record<string, never>> = {
|
|
54
|
+
/** Fully qualified rule ID (e.g., 'dispersa/require-description') */
|
|
55
|
+
id: string;
|
|
56
|
+
/** Merged options (defaultOptions + user config) */
|
|
57
|
+
options: Options;
|
|
58
|
+
/** All resolved tokens to validate */
|
|
59
|
+
tokens: InternalResolvedTokens;
|
|
60
|
+
/**
|
|
61
|
+
* Report a lint issue
|
|
62
|
+
*
|
|
63
|
+
* @param descriptor - Issue descriptor with token, message ID, and optional data
|
|
64
|
+
*/
|
|
65
|
+
report(descriptor: LintReportDescriptor<MessageIds>): void;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Descriptor for reporting a lint issue
|
|
69
|
+
*
|
|
70
|
+
* @template MessageIds - Union type of message IDs this rule can produce
|
|
71
|
+
*/
|
|
72
|
+
type LintReportDescriptor<MessageIds extends string = string> = {
|
|
73
|
+
/** The token that has the issue */
|
|
74
|
+
token: ResolvedToken;
|
|
75
|
+
/** ID of the message to use from rule's meta.messages */
|
|
76
|
+
messageId: MessageIds;
|
|
77
|
+
/** Data to interpolate into the message (replaces {{key}} placeholders) */
|
|
78
|
+
data?: Record<string, string | number>;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* A lint rule definition
|
|
82
|
+
*
|
|
83
|
+
* Rules are created using the `createRule()` factory function for type safety.
|
|
84
|
+
*
|
|
85
|
+
* @template MessageIds - Union type of message IDs this rule can produce
|
|
86
|
+
* @template Options - Rule-specific options type
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const myRule: LintRule<'MISSING_VALUE', { required: boolean }> = {
|
|
91
|
+
* meta: {
|
|
92
|
+
* name: 'require-value',
|
|
93
|
+
* description: 'Require tokens to have values',
|
|
94
|
+
* messages: {
|
|
95
|
+
* MISSING_VALUE: "Token '{{name}}' is missing a value",
|
|
96
|
+
* },
|
|
97
|
+
* },
|
|
98
|
+
* defaultOptions: { required: true },
|
|
99
|
+
* create({ tokens, report, options }) {
|
|
100
|
+
* for (const token of Object.values(tokens)) {
|
|
101
|
+
* if (options.required && !token.$value) {
|
|
102
|
+
* report({ token, messageId: 'MISSING_VALUE', data: { name: token.name } })
|
|
103
|
+
* }
|
|
104
|
+
* }
|
|
105
|
+
* },
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
type LintRule<MessageIds extends string = string, Options extends Record<string, unknown> = Record<string, never>> = {
|
|
110
|
+
/** Rule metadata */
|
|
111
|
+
meta: LintRuleMeta<MessageIds>;
|
|
112
|
+
/** Default options merged with user config */
|
|
113
|
+
defaultOptions?: Options;
|
|
114
|
+
/**
|
|
115
|
+
* Factory function that creates the rule's validation logic
|
|
116
|
+
*
|
|
117
|
+
* Called once per lint run with the context object.
|
|
118
|
+
*
|
|
119
|
+
* @param context - Rule context with tokens, options, and report function
|
|
120
|
+
*/
|
|
121
|
+
create(context: LintRuleContext<MessageIds, Options>): void | Promise<void>;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Base rule type without generic parameters for use in plugin definitions
|
|
125
|
+
*/
|
|
126
|
+
type AnyLintRule = LintRule<string, Record<string, unknown>>;
|
|
127
|
+
/**
|
|
128
|
+
* A lint plugin that provides rules and configurations
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const myPlugin: LintPlugin = {
|
|
133
|
+
* meta: {
|
|
134
|
+
* name: 'my-lint-plugin',
|
|
135
|
+
* version: '1.0.0',
|
|
136
|
+
* },
|
|
137
|
+
* rules: {
|
|
138
|
+
* 'my-rule': myRule,
|
|
139
|
+
* },
|
|
140
|
+
* configs: {
|
|
141
|
+
* recommended: {
|
|
142
|
+
* plugins: { my: myPlugin },
|
|
143
|
+
* rules: {
|
|
144
|
+
* 'my/my-rule': 'warn',
|
|
145
|
+
* },
|
|
146
|
+
* },
|
|
147
|
+
* },
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
type LintPlugin = {
|
|
152
|
+
/** Plugin metadata */
|
|
153
|
+
meta: {
|
|
154
|
+
/** Package name (e.g., '@dispersa/lint-plugin-a11y') */
|
|
155
|
+
name: string;
|
|
156
|
+
/** Semantic version (optional, for debugging/metadata) */
|
|
157
|
+
version?: string;
|
|
158
|
+
};
|
|
159
|
+
/** Rules provided by this plugin */
|
|
160
|
+
rules: Record<string, AnyLintRule>;
|
|
161
|
+
/** Predefined configurations */
|
|
162
|
+
configs?: Record<string, LintConfig>;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Rule configuration - either severity only or severity with options
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* // Severity only
|
|
170
|
+
* 'error'
|
|
171
|
+
*
|
|
172
|
+
* // Severity with options
|
|
173
|
+
* ['error', { format: 'kebab-case' }]
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
type RuleConfig = Severity | [Severity, Record<string, unknown>];
|
|
177
|
+
/**
|
|
178
|
+
* Resolved rule configuration with parsed severity and options
|
|
179
|
+
*/
|
|
180
|
+
type ResolvedRuleConfig = {
|
|
181
|
+
severity: Exclude<Severity, 'off'>;
|
|
182
|
+
options: Record<string, unknown>;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Registry for lint rule options types.
|
|
186
|
+
*
|
|
187
|
+
* Built-in dispersa rules are registered via declaration merging in `./rules/index.ts`.
|
|
188
|
+
* Plugin authors can augment this interface to add their own rule types:
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* // In your plugin file
|
|
193
|
+
* declare module 'dispersa/lint' {
|
|
194
|
+
* interface RulesRegistry {
|
|
195
|
+
* 'my-plugin/my-rule': MyRuleOptions
|
|
196
|
+
* }
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
interface RulesRegistry {
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Type-safe configuration for a single rule from the registry.
|
|
204
|
+
*
|
|
205
|
+
* @template K - The rule ID key from RulesRegistry
|
|
206
|
+
*/
|
|
207
|
+
type RuleConfigFor<K extends keyof RulesRegistry> = Severity | [Severity, RulesRegistry[K]];
|
|
208
|
+
/**
|
|
209
|
+
* Typed rules configuration with intellisense for all registered rules.
|
|
210
|
+
*
|
|
211
|
+
* Provides autocomplete for rule IDs and their option types.
|
|
212
|
+
* Also allows arbitrary string keys for unregistered rules.
|
|
213
|
+
*/
|
|
214
|
+
type TypedRulesConfig = {
|
|
215
|
+
[K in keyof RulesRegistry]?: RuleConfigFor<K>;
|
|
216
|
+
} & Record<string, RuleConfig>;
|
|
217
|
+
/**
|
|
218
|
+
* Lint configuration
|
|
219
|
+
*
|
|
220
|
+
* @template Rules - Rules configuration type (defaults to TypedRulesConfig for intellisense)
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const config: LintConfig = {
|
|
225
|
+
* plugins: {
|
|
226
|
+
* dispersa: dispersaPlugin,
|
|
227
|
+
* a11y: '@dispersa/lint-plugin-a11y', // Load by string
|
|
228
|
+
* },
|
|
229
|
+
* rules: {
|
|
230
|
+
* 'dispersa/require-description': 'warn',
|
|
231
|
+
* 'dispersa/naming-convention': ['error', { format: 'kebab-case' }],
|
|
232
|
+
* 'a11y/min-contrast': ['error', { level: 'AA' }],
|
|
233
|
+
* },
|
|
234
|
+
* }
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
type LintConfig<Rules extends Record<string, RuleConfig> = TypedRulesConfig> = {
|
|
238
|
+
/** Plugins to load (by object or module path string) */
|
|
239
|
+
plugins?: Record<string, LintPlugin | string>;
|
|
240
|
+
/** Rule configurations */
|
|
241
|
+
rules?: Rules;
|
|
242
|
+
/** Fail build on lint errors (default: true) */
|
|
243
|
+
failOnError?: boolean;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Configuration for lint within BuildConfig
|
|
247
|
+
*
|
|
248
|
+
* Extends {@link LintConfig} with an `enabled` toggle for opt-in build integration.
|
|
249
|
+
*
|
|
250
|
+
* @template Rules - Rules configuration type (defaults to TypedRulesConfig for intellisense)
|
|
251
|
+
*/
|
|
252
|
+
type LintBuildConfig<Rules extends Record<string, RuleConfig> = TypedRulesConfig> = LintConfig<Rules> & {
|
|
253
|
+
/** Enable linting (default: false, opt-in) */
|
|
254
|
+
enabled?: boolean;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Resolved lint configuration with all plugins loaded
|
|
258
|
+
*/
|
|
259
|
+
type ResolvedLintConfig = {
|
|
260
|
+
/** Whether linting is enabled */
|
|
261
|
+
enabled: boolean;
|
|
262
|
+
/** Fail build on errors */
|
|
263
|
+
failOnError: boolean;
|
|
264
|
+
/** Loaded plugins indexed by namespace */
|
|
265
|
+
plugins: Record<string, LintPlugin>;
|
|
266
|
+
/** Resolved rule configurations */
|
|
267
|
+
rules: Record<string, ResolvedRuleConfig>;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* A single lint issue
|
|
271
|
+
*/
|
|
272
|
+
type LintIssue = {
|
|
273
|
+
/** Fully qualified rule ID (e.g., 'dispersa/require-description') */
|
|
274
|
+
ruleId: string;
|
|
275
|
+
/** Issue severity */
|
|
276
|
+
severity: Exclude<Severity, 'off'>;
|
|
277
|
+
/** Human-readable message */
|
|
278
|
+
message: string;
|
|
279
|
+
/** Token name (e.g., 'color.brand.primary') */
|
|
280
|
+
tokenName: string;
|
|
281
|
+
/** Token path segments (e.g., ['color', 'brand', 'primary']) */
|
|
282
|
+
tokenPath: string[];
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Result of a lint run
|
|
286
|
+
*/
|
|
287
|
+
type LintResult = {
|
|
288
|
+
/** All issues found */
|
|
289
|
+
issues: LintIssue[];
|
|
290
|
+
/** Count of error-severity issues */
|
|
291
|
+
errorCount: number;
|
|
292
|
+
/** Count of warning-severity issues */
|
|
293
|
+
warningCount: number;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Output format for lint results
|
|
297
|
+
*/
|
|
298
|
+
type LintOutputFormat = 'json' | 'stylish' | 'compact';
|
|
299
|
+
/**
|
|
300
|
+
* Formatter function that converts lint result to output string
|
|
301
|
+
*/
|
|
302
|
+
type LintFormatter = (result: LintResult) => string;
|
|
5
303
|
|
|
6
304
|
/**
|
|
7
305
|
* @fileoverview DTCG Resolver types (2025.10 specification)
|
|
@@ -70,129 +368,6 @@ type ResolverDocument = {
|
|
|
70
368
|
*/
|
|
71
369
|
type ModifierInputs<T extends Record<string, string> = Record<string, string>> = T;
|
|
72
370
|
|
|
73
|
-
/**
|
|
74
|
-
* @license MIT
|
|
75
|
-
* Copyright (c) 2025-present Dispersa Contributors
|
|
76
|
-
*
|
|
77
|
-
* This source code is licensed under the MIT license found in the
|
|
78
|
-
* LICENSE file in the root directory of this source tree.
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Options for Tailwind CSS v4 renderer
|
|
83
|
-
*
|
|
84
|
-
* Controls how tokens are converted to Tailwind v4 @theme CSS variables.
|
|
85
|
-
*
|
|
86
|
-
* @example Bundle with dark mode overrides
|
|
87
|
-
* ```typescript
|
|
88
|
-
* tailwind({
|
|
89
|
-
* name: 'tailwind',
|
|
90
|
-
* file: 'theme.css',
|
|
91
|
-
* preset: 'bundle',
|
|
92
|
-
* selector: (modifier, context, isBase) => {
|
|
93
|
-
* if (isBase) return ':root'
|
|
94
|
-
* return `[data-${modifier}="${context}"]`
|
|
95
|
-
* },
|
|
96
|
-
* })
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
type TailwindRendererOptions = {
|
|
100
|
-
preset?: 'bundle' | 'standalone';
|
|
101
|
-
includeImport?: boolean;
|
|
102
|
-
namespace?: string;
|
|
103
|
-
minify?: boolean;
|
|
104
|
-
selector?: string | SelectorFunction;
|
|
105
|
-
mediaQuery?: string | MediaQueryFunction;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @license MIT
|
|
110
|
-
* Copyright (c) 2025-present Dispersa Contributors
|
|
111
|
-
*
|
|
112
|
-
* This source code is licensed under the MIT license found in the
|
|
113
|
-
* LICENSE file in the root directory of this source tree.
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Options for iOS/SwiftUI renderer
|
|
118
|
-
*/
|
|
119
|
-
type IosRendererOptions = {
|
|
120
|
-
preset?: 'standalone';
|
|
121
|
-
accessLevel?: 'public' | 'internal';
|
|
122
|
-
/**
|
|
123
|
-
* Output structure:
|
|
124
|
-
* - `'enum'` — nested enums inside a single root enum
|
|
125
|
-
* - `'grouped'` — namespace enum with separate extensions per token group
|
|
126
|
-
*/
|
|
127
|
-
structure?: 'enum' | 'grouped';
|
|
128
|
-
enumName?: string;
|
|
129
|
-
/** Namespace enum name used in grouped mode (default: 'DesignTokens') */
|
|
130
|
-
extensionNamespace?: string;
|
|
131
|
-
colorSpace?: 'sRGB' | 'displayP3';
|
|
132
|
-
/**
|
|
133
|
-
* Target Swift language version.
|
|
134
|
-
* - `'5.9'` (default) — standard static let declarations
|
|
135
|
-
* - `'6.0'` — adds `nonisolated(unsafe)` to static properties for
|
|
136
|
-
* Swift 6 strict concurrency compliance
|
|
137
|
-
*/
|
|
138
|
-
swiftVersion?: '5.9' | '6.0';
|
|
139
|
-
/** Number of spaces per indentation level (default 4) */
|
|
140
|
-
indent?: number;
|
|
141
|
-
/** Add @frozen annotation to enums and structs for ABI stability (default false) */
|
|
142
|
-
frozen?: boolean;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @license MIT
|
|
147
|
-
* Copyright (c) 2025-present Dispersa Contributors
|
|
148
|
-
*
|
|
149
|
-
* This source code is licensed under the MIT license found in the
|
|
150
|
-
* LICENSE file in the root directory of this source tree.
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Options for Android/Jetpack Compose renderer
|
|
155
|
-
*
|
|
156
|
-
* Note: `packageName` is marked optional for type compatibility with the Renderer
|
|
157
|
-
* generic, but is validated as required at runtime in the renderer's format() method.
|
|
158
|
-
*
|
|
159
|
-
* @experimental This type is experimental. Properties and behavior may change.
|
|
160
|
-
*/
|
|
161
|
-
type AndroidRendererOptions = {
|
|
162
|
-
preset?: 'standalone' | 'bundle';
|
|
163
|
-
packageName?: string;
|
|
164
|
-
objectName?: string;
|
|
165
|
-
/**
|
|
166
|
-
* Color output format for Kotlin Color initializers.
|
|
167
|
-
* - `'argb_hex'` (default) — `Color(0xAARRGGBB)` hex literal
|
|
168
|
-
* - `'argb_float'` — `Color(r, g, b, a)` float components
|
|
169
|
-
*
|
|
170
|
-
* Legacy aliases: `'argb8'` maps to `'argb_hex'`, `'argb_floats'` maps to `'argb_float'`.
|
|
171
|
-
*/
|
|
172
|
-
colorFormat?: 'argb_hex' | 'argb_float' | 'argb8' | 'argb_floats';
|
|
173
|
-
/**
|
|
174
|
-
* Color space for generated Color values.
|
|
175
|
-
* - `'sRGB'` (default) — standard sRGB color space
|
|
176
|
-
* - `'displayP3'` — Display P3 wide gamut via `ColorSpaces.DisplayP3`
|
|
177
|
-
*/
|
|
178
|
-
colorSpace?: 'sRGB' | 'displayP3';
|
|
179
|
-
/**
|
|
180
|
-
* Structure mode for token organization.
|
|
181
|
-
* - `'nested'` (default) — mirror token path hierarchy as nested objects
|
|
182
|
-
* - `'flat'` — group tokens by $type into semantic sub-objects (Colors, Spacing, etc.)
|
|
183
|
-
*/
|
|
184
|
-
structure?: 'nested' | 'flat';
|
|
185
|
-
/**
|
|
186
|
-
* Kotlin visibility modifier for the generated object and its members.
|
|
187
|
-
* - `undefined` (default) — no explicit modifier, which means `public` in Kotlin
|
|
188
|
-
* - `'public'` — explicit `public object` / `public val`
|
|
189
|
-
* - `'internal'` — `internal object` / `internal val` (useful for KMP / multi-module)
|
|
190
|
-
*/
|
|
191
|
-
visibility?: 'public' | 'internal';
|
|
192
|
-
/** Number of spaces per indentation level (default 4) */
|
|
193
|
-
indent?: number;
|
|
194
|
-
};
|
|
195
|
-
|
|
196
371
|
/**
|
|
197
372
|
* @fileoverview Renderer system types for token output generation
|
|
198
373
|
*
|
|
@@ -384,7 +559,7 @@ type CssRendererOptions = {
|
|
|
384
559
|
*
|
|
385
560
|
* @example
|
|
386
561
|
* ```typescript
|
|
387
|
-
* const result = await
|
|
562
|
+
* const result = await build(config)
|
|
388
563
|
* if (result.success) {
|
|
389
564
|
* result.outputs.forEach(output => {
|
|
390
565
|
* console.log(`Generated ${output.name}: ${output.path}`)
|
|
@@ -644,11 +819,11 @@ type OutputConfig<TOptions extends FormatOptions = FormatOptions> = Omit<OutputC
|
|
|
644
819
|
*
|
|
645
820
|
* @example Basic usage with global filters and transforms
|
|
646
821
|
* ```typescript
|
|
647
|
-
* import {
|
|
822
|
+
* import { build, css, json } from 'dispersa'
|
|
648
823
|
* import { byType } from 'dispersa/filters'
|
|
649
824
|
* import { colorToHex, nameKebabCase } from 'dispersa/transforms'
|
|
650
825
|
*
|
|
651
|
-
* await
|
|
826
|
+
* await build({
|
|
652
827
|
* outputs: [
|
|
653
828
|
* css({ name: 'css', preset: 'bundle', selector: ':root' }),
|
|
654
829
|
* json({ name: 'json', preset: 'standalone', structure: 'flat' }),
|
|
@@ -664,7 +839,7 @@ type OutputConfig<TOptions extends FormatOptions = FormatOptions> = Omit<OutputC
|
|
|
664
839
|
* import { byType } from 'dispersa/filters'
|
|
665
840
|
* import { nameKebabCase } from 'dispersa/transforms'
|
|
666
841
|
*
|
|
667
|
-
* await
|
|
842
|
+
* await build({
|
|
668
843
|
* outputs: [
|
|
669
844
|
* css({
|
|
670
845
|
* name: 'css',
|
|
@@ -687,6 +862,8 @@ type BuildConfig = Omit<BuildConfigBase, 'outputs' | 'filters' | 'transforms' |
|
|
|
687
862
|
resolver?: string | ResolverDocument;
|
|
688
863
|
/** Output directory for generated files */
|
|
689
864
|
buildPath?: string;
|
|
865
|
+
/** Validation mode for token resolution */
|
|
866
|
+
validation?: ValidationOptions;
|
|
690
867
|
/** Array of output configurations defining target formats */
|
|
691
868
|
outputs: OutputConfig[];
|
|
692
869
|
/** Global filters to apply to all outputs before output-specific filters */
|
|
@@ -697,6 +874,8 @@ type BuildConfig = Omit<BuildConfigBase, 'outputs' | 'filters' | 'transforms' |
|
|
|
697
874
|
preprocessors?: Preprocessor[];
|
|
698
875
|
/** Explicit permutations to build (modifier inputs) */
|
|
699
876
|
permutations?: ModifierInputs[];
|
|
877
|
+
/** Linting configuration */
|
|
878
|
+
lint?: LintBuildConfig;
|
|
700
879
|
/** Global lifecycle hooks for the build process */
|
|
701
880
|
hooks?: LifecycleHooks;
|
|
702
881
|
};
|
|
@@ -713,4 +892,4 @@ type DispersaOptions = Omit<DispersaOptionsBase, 'validation'> & {
|
|
|
713
892
|
validation?: ValidationOptions;
|
|
714
893
|
};
|
|
715
894
|
|
|
716
|
-
export { type
|
|
895
|
+
export { type AnyLintRule as A, type BuildConfig as B, type CssRendererOptions as C, type DispersaOptions as D, type ErrorCode as E, type FileFunction as F, type LintOutputFormat as G, type RulesRegistry as H, type RuleConfigFor as I, type LifecycleHooks as L, type MediaQueryFunction as M, type OutputConfig as O, type PermutationData as P, type Renderer as R, type SelectorFunction as S, type TypedRulesConfig as T, type ValidationMode as V, type ValidationOptions as a, type BuildError as b, type BuildOutput as c, type BuildResult as d, type FormatOptions as e, type OutputTree as f, type RenderContext as g, type RenderMeta as h, type RenderOutput as i, type ModifierInputs as j, type ResolverDocument as k, defineRenderer as l, type LintConfig as m, type LintResult as n, type LintRule as o, type LintPlugin as p, type LintFormatter as q, type Severity as r, type LintRuleMeta as s, type LintRuleContext as t, type LintReportDescriptor as u, type RuleConfig as v, type ResolvedRuleConfig as w, type LintBuildConfig as x, type ResolvedLintConfig as y, type LintIssue as z };
|