@gesslar/sassy 2.0.1 → 3.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 +79 -49
- package/package.json +3 -3
- package/src/Compiler.js +12 -0
- package/src/Evaluator.js +35 -0
- package/types/BuildCommand.d.ts +65 -0
- package/types/BuildCommand.d.ts.map +1 -0
- package/types/Colour.d.ts +126 -0
- package/types/Colour.d.ts.map +1 -0
- package/types/Command.d.ts +139 -0
- package/types/Command.d.ts.map +1 -0
- package/types/Compiler.d.ts +19 -0
- package/types/Compiler.d.ts.map +1 -0
- package/types/Evaluator.d.ts +106 -0
- package/types/Evaluator.d.ts.map +1 -0
- package/types/LintCommand.d.ts +62 -0
- package/types/LintCommand.d.ts.map +1 -0
- package/types/ResolveCommand.d.ts +66 -0
- package/types/ResolveCommand.d.ts.map +1 -0
- package/types/Session.d.ts +140 -0
- package/types/Session.d.ts.map +1 -0
- package/types/Theme.d.ts +339 -0
- package/types/Theme.d.ts.map +1 -0
- package/types/ThemePool.d.ts +82 -0
- package/types/ThemePool.d.ts.map +1 -0
- package/types/ThemeToken.d.ts +165 -0
- package/types/ThemeToken.d.ts.map +1 -0
- package/types/index.d.ts +10 -0
- package/types/index.d.ts.map +1 -0
package/types/Theme.d.ts
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme class: manages the lifecycle of a theme compilation unit.
|
|
3
|
+
* See file-level docstring for responsibilities.
|
|
4
|
+
*/
|
|
5
|
+
export default class Theme {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new Theme instance.
|
|
8
|
+
*
|
|
9
|
+
* @param {FileObject} themeFile - The source theme file object
|
|
10
|
+
* @param {DirectoryObject} cwd - The project's directory.
|
|
11
|
+
* @param {object} options - Compilation options
|
|
12
|
+
*/
|
|
13
|
+
constructor(themeFile: FileObject, cwd: DirectoryObject, options: object);
|
|
14
|
+
/**
|
|
15
|
+
* Resets the theme's compilation state, clearing output and lookup data.
|
|
16
|
+
* Used when recompiling in watch mode or clearing previous state.
|
|
17
|
+
*/
|
|
18
|
+
reset(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the current working directory.
|
|
21
|
+
*
|
|
22
|
+
* @returns {DirectoryObject} The current working directory
|
|
23
|
+
*/
|
|
24
|
+
getCwd(): DirectoryObject;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the compilation options.
|
|
27
|
+
*
|
|
28
|
+
* @returns {object} The compilation options object
|
|
29
|
+
*/
|
|
30
|
+
getOptions(): object;
|
|
31
|
+
/**
|
|
32
|
+
* Gets a specific compilation option.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} option - The option name to retrieve
|
|
35
|
+
* @returns {unknown} The option value or undefined if not set
|
|
36
|
+
*/
|
|
37
|
+
getOption(option: string): unknown;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the cache instance for theme compilation.
|
|
40
|
+
*
|
|
41
|
+
* @param {Cache} cache - The cache instance to use for file operations
|
|
42
|
+
* @returns {this} Returns this instance for method chaining
|
|
43
|
+
*/
|
|
44
|
+
setCache(cache: Cache): this;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the cache instance.
|
|
47
|
+
*
|
|
48
|
+
* @returns {Cache|null} The cache instance or null if not set
|
|
49
|
+
*/
|
|
50
|
+
getCache(): Cache | null;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the theme name.
|
|
53
|
+
*
|
|
54
|
+
* @returns {string} The theme name derived from the source file
|
|
55
|
+
*/
|
|
56
|
+
getName(): string;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the output file name for the compiled theme.
|
|
59
|
+
*
|
|
60
|
+
* @returns {string} The output file name with extension
|
|
61
|
+
*/
|
|
62
|
+
getOutputFileName(): string;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the source file object.
|
|
65
|
+
*
|
|
66
|
+
* @returns {FileObject} The source theme file
|
|
67
|
+
*/
|
|
68
|
+
getSourceFile(): FileObject;
|
|
69
|
+
/**
|
|
70
|
+
* Sets the compiled theme output object and updates derived JSON and hash.
|
|
71
|
+
*
|
|
72
|
+
* @param {object} data - The compiled theme output object
|
|
73
|
+
* @returns {this} Returns this instance for method chaining
|
|
74
|
+
*/
|
|
75
|
+
setOutput(data: object): this;
|
|
76
|
+
/**
|
|
77
|
+
* Gets the compiled theme output object.
|
|
78
|
+
*
|
|
79
|
+
* @returns {object|null} The compiled theme output
|
|
80
|
+
*/
|
|
81
|
+
getOutput(): object | null;
|
|
82
|
+
/**
|
|
83
|
+
* Checks if the source has colors defined.
|
|
84
|
+
*
|
|
85
|
+
* @returns {boolean} True if source has theme colors
|
|
86
|
+
*/
|
|
87
|
+
sourceHasColors(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Checks if the source has token colors defined.
|
|
90
|
+
*
|
|
91
|
+
* @returns {boolean} True if source has theme token colors
|
|
92
|
+
*/
|
|
93
|
+
sourceHasTokenColors(): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Checks if the source has semantic token colors defined.
|
|
96
|
+
*
|
|
97
|
+
* @returns {boolean} True if source has theme semantic token colors
|
|
98
|
+
*/
|
|
99
|
+
sourceHasSemanticTokenColors(): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Checks if the source has theme configuration.
|
|
102
|
+
*
|
|
103
|
+
* @returns {boolean} True if source has theme data
|
|
104
|
+
*/
|
|
105
|
+
sourceHasTheme(): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Checks if the source has variables.
|
|
108
|
+
*
|
|
109
|
+
* @returns {boolean} True if source has vars section
|
|
110
|
+
*/
|
|
111
|
+
sourceHasVars(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Checks if the source has config section.
|
|
114
|
+
*
|
|
115
|
+
* @returns {boolean} True if source has config
|
|
116
|
+
*/
|
|
117
|
+
sourceHasConfig(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Gets the source colors data.
|
|
120
|
+
*
|
|
121
|
+
* @returns {object|null} The colors object or null if not defined
|
|
122
|
+
*/
|
|
123
|
+
getSourceColors(): object | null;
|
|
124
|
+
/**
|
|
125
|
+
* Gets the source token colors data.
|
|
126
|
+
*
|
|
127
|
+
* @returns {Array|null} The token colors array or null if not defined
|
|
128
|
+
*/
|
|
129
|
+
getSourceTokenColors(): any[] | null;
|
|
130
|
+
/**
|
|
131
|
+
* Gets the source semantic token colors data.
|
|
132
|
+
*
|
|
133
|
+
* @returns {object|null} The semantic token colors object or null if not defined
|
|
134
|
+
*/
|
|
135
|
+
getSourceSemanticTokenColors(): object | null;
|
|
136
|
+
/**
|
|
137
|
+
* Gets the set of file dependencies.
|
|
138
|
+
*
|
|
139
|
+
* @returns {Set<Dependency>} Set of dependency files
|
|
140
|
+
*/
|
|
141
|
+
getDependencies(): Set<Dependency>;
|
|
142
|
+
/**
|
|
143
|
+
* Adds a dependency to the theme with its source data.
|
|
144
|
+
*
|
|
145
|
+
* @param {FileObject} file - The dependency file object
|
|
146
|
+
* @param {object} source - The parsed source data from the file
|
|
147
|
+
* @returns {this} Returns this instance for method chaining
|
|
148
|
+
*/
|
|
149
|
+
addDependency(file: FileObject, source: object): this;
|
|
150
|
+
/**
|
|
151
|
+
* Checks if the theme has any dependencies.
|
|
152
|
+
*
|
|
153
|
+
* @returns {boolean} True if theme has dependencies
|
|
154
|
+
*/
|
|
155
|
+
hasDependencies(): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Gets the parsed source data from the theme file.
|
|
158
|
+
*
|
|
159
|
+
* @returns {object|null} The parsed source data
|
|
160
|
+
*/
|
|
161
|
+
getSource(): object | null;
|
|
162
|
+
/**
|
|
163
|
+
* Gets the variable lookup data for theme compilation.
|
|
164
|
+
*
|
|
165
|
+
* @returns {object|null} The lookup data object
|
|
166
|
+
*/
|
|
167
|
+
getLookup(): object | null;
|
|
168
|
+
/**
|
|
169
|
+
* Sets the variable lookup data for theme compilation.
|
|
170
|
+
*
|
|
171
|
+
* @param {object} data - The lookup data object
|
|
172
|
+
* @returns {this} Returns this instance for method chaining
|
|
173
|
+
*/
|
|
174
|
+
setLookup(data: object): this;
|
|
175
|
+
/**
|
|
176
|
+
* Gets the pool data for variable resolution tracking or null if one has
|
|
177
|
+
* not been set.
|
|
178
|
+
*
|
|
179
|
+
* @returns {ThemePool|null} The pool for this theme.
|
|
180
|
+
*/
|
|
181
|
+
getPool(): ThemePool | null;
|
|
182
|
+
/**
|
|
183
|
+
* Sets the pool data for variable resolution tracking. May not be over-
|
|
184
|
+
* written publicly. May only be reset
|
|
185
|
+
*
|
|
186
|
+
* @see reset
|
|
187
|
+
*
|
|
188
|
+
* @param {ThemePool} pool - The pool to assign to this theme
|
|
189
|
+
* @throws {Error} If there is already a pool.
|
|
190
|
+
* @returns {this} Returns this instance for method chaining
|
|
191
|
+
*/
|
|
192
|
+
setPool(pool: ThemePool): this;
|
|
193
|
+
/**
|
|
194
|
+
* Method to return true or false if this theme has a pool.
|
|
195
|
+
*
|
|
196
|
+
* @returns {boolean} True if a pool has been set, false otherwise.
|
|
197
|
+
*/
|
|
198
|
+
hasPool(): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Checks if the theme has compiled output.
|
|
201
|
+
*
|
|
202
|
+
* @returns {boolean} True if theme has been compiled
|
|
203
|
+
*/
|
|
204
|
+
hasOutput(): boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Checks if the theme has loaded source data.
|
|
207
|
+
*
|
|
208
|
+
* @returns {boolean} True if source data is available
|
|
209
|
+
*/
|
|
210
|
+
hasSource(): boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Checks if the theme has a cache instance.
|
|
213
|
+
*
|
|
214
|
+
* @returns {boolean} True if cache is available
|
|
215
|
+
*/
|
|
216
|
+
hasCache(): boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Checks if the theme has lookup data.
|
|
219
|
+
*
|
|
220
|
+
* @returns {boolean} True if lookup data exists
|
|
221
|
+
*/
|
|
222
|
+
hasLookup(): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Checks if the theme is ready to be compiled.
|
|
225
|
+
* Requires source data and cache to be available.
|
|
226
|
+
*
|
|
227
|
+
* @returns {boolean} True if theme can be compiled
|
|
228
|
+
*/
|
|
229
|
+
isReady(): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Checks if the theme has been fully compiled.
|
|
232
|
+
* Requires output, pool, and lookup data to be present.
|
|
233
|
+
*
|
|
234
|
+
* @returns {boolean} True if theme is fully compiled
|
|
235
|
+
*/
|
|
236
|
+
isCompiled(): boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Checks if the theme can be built/compiled.
|
|
239
|
+
* Same as isReady() but with more semantic naming.
|
|
240
|
+
*
|
|
241
|
+
* @returns {boolean} True if build can proceed
|
|
242
|
+
*/
|
|
243
|
+
canBuild(): boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Checks if the theme can be written to output.
|
|
246
|
+
* Requires the theme to be compiled.
|
|
247
|
+
*
|
|
248
|
+
* @returns {boolean} True if write can proceed
|
|
249
|
+
*/
|
|
250
|
+
canWrite(): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Checks if the theme is in a valid state for operation.
|
|
253
|
+
* Basic validation that core properties are set.
|
|
254
|
+
*
|
|
255
|
+
* @returns {boolean} True if theme state is valid
|
|
256
|
+
*/
|
|
257
|
+
isValid(): boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Loads and parses the theme source file.
|
|
260
|
+
* Validates that the source contains required configuration.
|
|
261
|
+
* Skips loading if no cache is available (extension use case).
|
|
262
|
+
*
|
|
263
|
+
* @returns {Promise<this>} Returns this instance for method chaining
|
|
264
|
+
* @throws {Sass} If source file lacks required 'config' property
|
|
265
|
+
*/
|
|
266
|
+
load(): Promise<this>;
|
|
267
|
+
/**
|
|
268
|
+
* Builds the theme by compiling source data into final output.
|
|
269
|
+
* Main entry point for theme compilation process.
|
|
270
|
+
*
|
|
271
|
+
* @returns {Promise<this>} Returns this instance for method chaining
|
|
272
|
+
*/
|
|
273
|
+
build(): Promise<this>;
|
|
274
|
+
/**
|
|
275
|
+
* Writes the compiled theme output to a file or stdout.
|
|
276
|
+
* Handles dry-run mode, output directory creation, and duplicate write prevention.
|
|
277
|
+
*
|
|
278
|
+
* @param {boolean} [force] - Force a write. Used by the rebuild CLI option.
|
|
279
|
+
* @returns {Promise<void>} Resolves when write operation is complete
|
|
280
|
+
*/
|
|
281
|
+
write(force?: boolean): Promise<void>;
|
|
282
|
+
#private;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Dependency class represents a theme file dependency.
|
|
286
|
+
* Manages the relationship between a file reference and its parsed source data.
|
|
287
|
+
*/
|
|
288
|
+
export class Dependency {
|
|
289
|
+
/**
|
|
290
|
+
* Sets the file object for this dependency.
|
|
291
|
+
*
|
|
292
|
+
* @param {FileObject} file - The file object of this dependency.
|
|
293
|
+
* @returns {this} This.
|
|
294
|
+
*/
|
|
295
|
+
setSourceFile(file: FileObject): this;
|
|
296
|
+
/**
|
|
297
|
+
* Get the file object for this depenency.
|
|
298
|
+
*
|
|
299
|
+
* @returns {FileObject} The file object of this dependency.
|
|
300
|
+
*/
|
|
301
|
+
getSourceFile(): FileObject;
|
|
302
|
+
/**
|
|
303
|
+
* Sets the source object for this dependency.
|
|
304
|
+
*
|
|
305
|
+
* @param {object} source - The parsed JSON from the file after loading.
|
|
306
|
+
* @returns {this} This.
|
|
307
|
+
*/
|
|
308
|
+
setSource(source: object): this;
|
|
309
|
+
/**
|
|
310
|
+
* Gets the parsed source data for this dependency.
|
|
311
|
+
*
|
|
312
|
+
* @returns {object|null} The parsed source data
|
|
313
|
+
*/
|
|
314
|
+
getSource(): object | null;
|
|
315
|
+
/**
|
|
316
|
+
* Checks if the dependency has a source file.
|
|
317
|
+
*
|
|
318
|
+
* @returns {boolean} True if source file is set
|
|
319
|
+
*/
|
|
320
|
+
hasSourceFile(): boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Checks if the dependency has parsed source data.
|
|
323
|
+
*
|
|
324
|
+
* @returns {boolean} True if source data is available
|
|
325
|
+
*/
|
|
326
|
+
hasSource(): boolean;
|
|
327
|
+
/**
|
|
328
|
+
* Checks if the dependency is fully initialized.
|
|
329
|
+
*
|
|
330
|
+
* @returns {boolean} True if both file and source are set
|
|
331
|
+
*/
|
|
332
|
+
isComplete(): boolean;
|
|
333
|
+
#private;
|
|
334
|
+
}
|
|
335
|
+
import type { DirectoryObject } from "@gesslar/toolkit";
|
|
336
|
+
import type { Cache } from "@gesslar/toolkit";
|
|
337
|
+
import type { FileObject } from "@gesslar/toolkit";
|
|
338
|
+
import ThemePool from "./ThemePool.js";
|
|
339
|
+
//# sourceMappingURL=Theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../src/Theme.js"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThemePool represents a collection of ThemeTokens serving both as a
|
|
3
|
+
* lookup of string>ThemeToken and dependencies.
|
|
4
|
+
*
|
|
5
|
+
* @class ThemePool
|
|
6
|
+
*/
|
|
7
|
+
export default class ThemePool {
|
|
8
|
+
/**
|
|
9
|
+
* Returns the map of encoded theme token ids to their token object.
|
|
10
|
+
*
|
|
11
|
+
* @returns {Map<string, ThemeToken>} Map of tokens to their children.
|
|
12
|
+
*/
|
|
13
|
+
getTokens(): Map<string, ThemeToken>;
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves a resolved token by its name.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} name - The token to look up.
|
|
18
|
+
* @returns {string|undefined} The resolved token string or undefined.
|
|
19
|
+
*/
|
|
20
|
+
lookup(name: string): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Sets a resolved value for a token key.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} key - The token key.
|
|
25
|
+
* @param {string} value - The resolved value.
|
|
26
|
+
*/
|
|
27
|
+
resolve(key: string, value: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Sets a raw resolved value for a token key.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} key - The token key.
|
|
32
|
+
* @param {string} value - The raw resolved value.
|
|
33
|
+
*/
|
|
34
|
+
rawResolve(key: string, value: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if a token name exists in resolved map.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} name - The token name to check.
|
|
39
|
+
* @returns {boolean} True if the token exists.
|
|
40
|
+
*/
|
|
41
|
+
has(name: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Checks if a token exists by its name.
|
|
44
|
+
*
|
|
45
|
+
* @param {ThemeToken} token - The token to check.
|
|
46
|
+
* @returns {boolean} True if the token exists.
|
|
47
|
+
*/
|
|
48
|
+
hasToken(token: ThemeToken): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves a token's dependency.
|
|
51
|
+
*
|
|
52
|
+
* @param {ThemeToken} token - The token to look up.
|
|
53
|
+
* @returns {ThemeToken?} The dependent token with the given token, or undefined.
|
|
54
|
+
*/
|
|
55
|
+
reverseLookup(token: ThemeToken): ThemeToken | null;
|
|
56
|
+
/**
|
|
57
|
+
* Adds a token to the pool, optionally setting up dependencies if required.
|
|
58
|
+
*
|
|
59
|
+
* @param {ThemeToken} token - The token to add.
|
|
60
|
+
* @param {ThemeToken} [dependency] - The dependent token.
|
|
61
|
+
* @returns {ThemeToken} The token that was added.
|
|
62
|
+
*/
|
|
63
|
+
addToken(token: ThemeToken, dependency?: ThemeToken): ThemeToken;
|
|
64
|
+
/**
|
|
65
|
+
* Finds a token by its value.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} value - The value to search for.
|
|
68
|
+
* @returns {ThemeToken|undefined} The found token or undefined.
|
|
69
|
+
*/
|
|
70
|
+
findToken(value: string): ThemeToken | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Checks if one token is an ancestor of another using reverse lookup.
|
|
73
|
+
*
|
|
74
|
+
* @param {ThemeToken} candidate - Potential ancestor token.
|
|
75
|
+
* @param {ThemeToken} token - Potential descendant token.
|
|
76
|
+
* @returns {boolean} True if candidate is an ancestor of token.
|
|
77
|
+
*/
|
|
78
|
+
isAncestorOf(candidate: ThemeToken, token: ThemeToken): boolean;
|
|
79
|
+
#private;
|
|
80
|
+
}
|
|
81
|
+
import ThemeToken from "./ThemeToken.js";
|
|
82
|
+
//# sourceMappingURL=ThemePool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemePool.d.ts","sourceRoot":"","sources":["../src/ThemePool.js"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH;IAKE;;;;OAIG;IACH,aAFa,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAInC;IAED;;;;;OAKG;IACH,aAHW,MAAM,GACJ,MAAM,GAAC,SAAS,CAI5B;IAED;;;;;OAKG;IACH,aAHW,MAAM,SACN,MAAM,QAIhB;IAED;;;;;OAKG;IACH,gBAHW,MAAM,SACN,MAAM,QAIhB;IAED;;;;;OAKG;IACH,UAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;OAKG;IACH,gBAHW,UAAU,GACR,OAAO,CAInB;IAED;;;;;OAKG;IACH,qBAHW,UAAU,GACR,UAAU,OAAC,CAIvB;IAED;;;;;;OAMG;IACH,gBAJW,UAAU,eACV,UAAU,GACR,UAAU,CAYtB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,UAAU,GAAC,SAAS,CAIhC;IAED;;;;;;OAMG;IACH,wBAJW,UAAU,SACV,UAAU,GACR,OAAO,CAYnB;;CACF;uBAjIsB,iBAAiB"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThemeToken represents a single token in a theme tree, encapsulating theme
|
|
3
|
+
* token data and relationships.
|
|
4
|
+
*
|
|
5
|
+
* Provides property management, factory methods, tree integration, and
|
|
6
|
+
* serialization.
|
|
7
|
+
*
|
|
8
|
+
* @class ThemeToken
|
|
9
|
+
*/
|
|
10
|
+
export default class ThemeToken {
|
|
11
|
+
/**
|
|
12
|
+
* Constructs a ThemeToken with a given token name.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} name - The token name for this token.
|
|
15
|
+
*/
|
|
16
|
+
constructor(name: string);
|
|
17
|
+
/**
|
|
18
|
+
* Adds this token to a ThemePool with optional dependency.
|
|
19
|
+
*
|
|
20
|
+
* @param {ThemePool} pool - The pool to add to.
|
|
21
|
+
* @param {ThemeToken} [dependency] - Optional dependency token.
|
|
22
|
+
* @returns {ThemeToken} This token instance.
|
|
23
|
+
*/
|
|
24
|
+
addToPool(pool?: ThemePool, dependency?: ThemeToken): ThemeToken;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the name of this token (only if not already set).
|
|
27
|
+
*
|
|
28
|
+
* @param {string} name - The token name.
|
|
29
|
+
* @returns {ThemeToken} This token instance.
|
|
30
|
+
*/
|
|
31
|
+
setName(name: string): ThemeToken;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the name of this token.
|
|
34
|
+
*
|
|
35
|
+
* @returns {string} The token name.
|
|
36
|
+
*/
|
|
37
|
+
getName(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the kind of this token (only if not already set).
|
|
40
|
+
*
|
|
41
|
+
* @param {string} kind - The token kind.
|
|
42
|
+
* @returns {ThemeToken} This token instance.
|
|
43
|
+
*/
|
|
44
|
+
setKind(kind: string): ThemeToken;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the kind of this token.
|
|
47
|
+
*
|
|
48
|
+
* @returns {string} The token kind.
|
|
49
|
+
*/
|
|
50
|
+
getKind(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Sets the value of this token.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} value - The token value.
|
|
55
|
+
* @returns {ThemeToken} This token instance.
|
|
56
|
+
*/
|
|
57
|
+
setValue(value: string): ThemeToken;
|
|
58
|
+
/**
|
|
59
|
+
* Gets the value of this token.
|
|
60
|
+
*
|
|
61
|
+
* @returns {string} The token value.
|
|
62
|
+
*/
|
|
63
|
+
getValue(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the raw value of this token (only if not already set).
|
|
66
|
+
*
|
|
67
|
+
* @param {string} raw - The raw token value.
|
|
68
|
+
* @returns {ThemeToken} This token instance.
|
|
69
|
+
*/
|
|
70
|
+
setRawValue(raw: string): ThemeToken;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the raw value of this token.
|
|
73
|
+
*
|
|
74
|
+
* @returns {string} The raw token value.
|
|
75
|
+
*/
|
|
76
|
+
getRawValue(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Sets the dependency of this token (only if not already set).
|
|
79
|
+
*
|
|
80
|
+
* @param {ThemeToken} dependency - The dependency token.
|
|
81
|
+
* @returns {ThemeToken} This token instance.
|
|
82
|
+
*/
|
|
83
|
+
setDependency(dependency: ThemeToken): ThemeToken;
|
|
84
|
+
/**
|
|
85
|
+
* Gets the dependency of this token.
|
|
86
|
+
*
|
|
87
|
+
* @returns {ThemeToken|null} The dependency token or null.
|
|
88
|
+
*/
|
|
89
|
+
getDependency(): ThemeToken | null;
|
|
90
|
+
/**
|
|
91
|
+
* Sets the parent token key.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} tokenKey - The parent token key.
|
|
94
|
+
* @returns {ThemeToken} This token instance.
|
|
95
|
+
*/
|
|
96
|
+
setParentTokenKey(tokenKey: string): ThemeToken;
|
|
97
|
+
/**
|
|
98
|
+
* Gets the parent token key.
|
|
99
|
+
*
|
|
100
|
+
* @returns {string|null} The parent token key or null.
|
|
101
|
+
*/
|
|
102
|
+
getParentTokenKey(): string | null;
|
|
103
|
+
/**
|
|
104
|
+
* Adds a trail of tokens to this token's trail array.
|
|
105
|
+
*
|
|
106
|
+
* @param {Array<ThemeToken>} trail - Array of tokens to add.
|
|
107
|
+
* @returns {ThemeToken} This token instance.
|
|
108
|
+
*/
|
|
109
|
+
addTrail(trail: Array<ThemeToken>): ThemeToken;
|
|
110
|
+
/**
|
|
111
|
+
* Gets the trail array of this token.
|
|
112
|
+
*
|
|
113
|
+
* @returns {Array<ThemeToken>} The trail array.
|
|
114
|
+
*/
|
|
115
|
+
getTrail(): Array<ThemeToken>;
|
|
116
|
+
/**
|
|
117
|
+
* Sets the parsed color object for this token.
|
|
118
|
+
*
|
|
119
|
+
* @param {object} parsedColor - The parsed Culori color object
|
|
120
|
+
* @returns {ThemeToken} This token instance.
|
|
121
|
+
*/
|
|
122
|
+
setParsedColor(parsedColor: object): ThemeToken;
|
|
123
|
+
/**
|
|
124
|
+
* Gets the parsed color object of this token.
|
|
125
|
+
*
|
|
126
|
+
* @returns {object|null} The parsed Culori color object or null.
|
|
127
|
+
*/
|
|
128
|
+
getParsedColor(): object | null;
|
|
129
|
+
/**
|
|
130
|
+
* Sets the direct result of a colour function evaluation, before
|
|
131
|
+
* substitution back into the enclosing expression.
|
|
132
|
+
*
|
|
133
|
+
* @param {string} result - The direct function output.
|
|
134
|
+
* @returns {ThemeToken} This token instance.
|
|
135
|
+
*/
|
|
136
|
+
setFunctionResult(result: string): ThemeToken;
|
|
137
|
+
/**
|
|
138
|
+
* Gets the direct result of a colour function evaluation.
|
|
139
|
+
*
|
|
140
|
+
* @returns {string|null} The direct function output or null.
|
|
141
|
+
*/
|
|
142
|
+
getFunctionResult(): string | null;
|
|
143
|
+
/**
|
|
144
|
+
* Checks if this token has an ancestor with the given token name.
|
|
145
|
+
*
|
|
146
|
+
* @param {string} name - The name of the ancestor token to check for.
|
|
147
|
+
* @returns {boolean} True if ancestor exists.
|
|
148
|
+
*/
|
|
149
|
+
hasDependency(name: string): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Gets the ThemePool associated with this token.
|
|
152
|
+
*
|
|
153
|
+
* @returns {ThemePool} The associated pool.
|
|
154
|
+
*/
|
|
155
|
+
getPool(): ThemePool;
|
|
156
|
+
/**
|
|
157
|
+
* Returns a JSON representation of the ThemeToken.
|
|
158
|
+
*
|
|
159
|
+
* @returns {object} JSON representation of the ThemeToken
|
|
160
|
+
*/
|
|
161
|
+
toJSON(): object;
|
|
162
|
+
#private;
|
|
163
|
+
}
|
|
164
|
+
import ThemePool from "./ThemePool.js";
|
|
165
|
+
//# sourceMappingURL=ThemeToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeToken.d.ts","sourceRoot":"","sources":["../src/ThemeToken.js"],"names":[],"mappings":"AAYA;;;;;;;;GAQG;AACH;IAaE;;;;OAIG;IACH,kBAFW,MAAM,EAOhB;IAED;;;;;;OAMG;IACH,iBAJW,SAAS,eACT,UAAU,GACR,UAAU,CAetB;IAED;;;;;OAKG;IACH,cAHW,MAAM,GACJ,UAAU,CAOtB;IAED;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,cAHW,MAAM,GACJ,UAAU,CAOtB;IAED;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,UAAU,CAMtB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,UAAU,CAOtB;IAED;;;;OAIG;IACH,eAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,0BAHW,UAAU,GACR,UAAU,CAOtB;IAED;;;;OAIG;IACH,iBAFa,UAAU,GAAC,IAAI,CAI3B;IAED;;;;;OAKG;IACH,4BAHW,MAAM,GACJ,UAAU,CAMtB;IAED;;;;OAIG;IACH,qBAFa,MAAM,GAAC,IAAI,CAIvB;IAED;;;;;OAKG;IACH,gBAHW,KAAK,CAAC,UAAU,CAAC,GACf,UAAU,CAWtB;IAED;;;;OAIG;IACH,YAFa,KAAK,CAAC,UAAU,CAAC,CAI7B;IAED;;;;;OAKG;IACH,4BAHW,MAAM,GACJ,UAAU,CAMtB;IAED;;;;OAIG;IACH,kBAFa,MAAM,GAAC,IAAI,CAIvB;IAED;;;;;;OAMG;IACH,0BAHW,MAAM,GACJ,UAAU,CAMtB;IAED;;;;OAIG;IACH,qBAFa,MAAM,GAAC,IAAI,CAIvB;IAED;;;;;OAKG;IACH,oBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;OAIG;IACH,WAFa,SAAS,CAIrB;IAED;;;;OAIG;IACH,UAFa,MAAM,CAalB;;CACF;sBArSqB,gBAAgB"}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as Theme } from "./Theme.js";
|
|
2
|
+
export { default as Compiler } from "./Compiler.js";
|
|
3
|
+
export { default as Evaluator } from "./Evaluator.js";
|
|
4
|
+
export { default as Command } from "./Command.js";
|
|
5
|
+
export { default as BuildCommand } from "./BuildCommand.js";
|
|
6
|
+
export { default as LintCommand } from "./LintCommand.js";
|
|
7
|
+
export { default as ResolveCommand } from "./ResolveCommand.js";
|
|
8
|
+
export { default as Session } from "./Session.js";
|
|
9
|
+
export { default as Colour } from "./Colour.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|