@gesslar/sassy 2.0.0 → 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/src/ResolveCommand.js +1 -1
- 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
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {DirectoryObject} from "@gesslar/toolkit"
|
|
3
|
+
* @import {FileObject} from "@gesslar/toolkit"
|
|
4
|
+
* @import {Cache} from "@gesslar/toolkit"
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base class for command-line interface commands.
|
|
8
|
+
* Provides common functionality for CLI option handling and file resolution.
|
|
9
|
+
*/
|
|
10
|
+
export default class Command {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Command instance.
|
|
13
|
+
*
|
|
14
|
+
* @param {DirectoryObject} config.cwd - Current working directory object
|
|
15
|
+
* @param {object} config.packageJson - Package.json data
|
|
16
|
+
*/
|
|
17
|
+
constructor({ cwd, packageJson }: DirectoryObject);
|
|
18
|
+
/**
|
|
19
|
+
* Gets the current working directory object.
|
|
20
|
+
*
|
|
21
|
+
* @returns {DirectoryObject} The current working directory
|
|
22
|
+
*/
|
|
23
|
+
getCwd(): DirectoryObject;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the package.json data.
|
|
26
|
+
*
|
|
27
|
+
* @returns {object} The package.json object
|
|
28
|
+
*/
|
|
29
|
+
getPackageJson(): object;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the cache instance for the command.
|
|
32
|
+
*
|
|
33
|
+
* @param {Cache} cache - The cache instance to set
|
|
34
|
+
* @returns {this} Returns this instance for method chaining
|
|
35
|
+
*/
|
|
36
|
+
setCache(cache: Cache): this;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the cache instance.
|
|
39
|
+
*
|
|
40
|
+
* @returns {Cache|null} The cache instance or null if not set
|
|
41
|
+
*/
|
|
42
|
+
getCache(): Cache | null;
|
|
43
|
+
/**
|
|
44
|
+
* Sets the CLI command string.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} data - The CLI command string
|
|
47
|
+
* @returns {this} Returns this instance for method chaining
|
|
48
|
+
*/
|
|
49
|
+
setCliCommand(data: string): this;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the CLI command string.
|
|
52
|
+
*
|
|
53
|
+
* @returns {string|null} The CLI command string
|
|
54
|
+
*/
|
|
55
|
+
getCliCommand(): string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the CLI options object.
|
|
58
|
+
*
|
|
59
|
+
* @param {object} data - The CLI options configuration
|
|
60
|
+
* @returns {this} Returns this instance for method chaining
|
|
61
|
+
*/
|
|
62
|
+
setCliOptions(data: object): this;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the CLI options object.
|
|
65
|
+
*
|
|
66
|
+
* @returns {object|null} The CLI options configuration
|
|
67
|
+
*/
|
|
68
|
+
getCliOptions(): object | null;
|
|
69
|
+
/**
|
|
70
|
+
* Gets the array of CLI option names.
|
|
71
|
+
*
|
|
72
|
+
* @returns {Array<string>} Array of option names
|
|
73
|
+
*/
|
|
74
|
+
getCliOptionNames(): Array<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if the command has a cache instance.
|
|
77
|
+
*
|
|
78
|
+
* @returns {boolean} True if cache is available
|
|
79
|
+
*/
|
|
80
|
+
hasCache(): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Checks if the command has a CLI command string configured.
|
|
83
|
+
*
|
|
84
|
+
* @returns {boolean} True if CLI command is set
|
|
85
|
+
*/
|
|
86
|
+
hasCliCommand(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Checks if the command has CLI options configured.
|
|
89
|
+
*
|
|
90
|
+
* @returns {boolean} True if CLI options are set
|
|
91
|
+
*/
|
|
92
|
+
hasCliOptions(): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Checks if the command is ready to be built.
|
|
95
|
+
* Requires both CLI command and options to be set.
|
|
96
|
+
*
|
|
97
|
+
* @returns {boolean} True if command can be built
|
|
98
|
+
*/
|
|
99
|
+
canBuild(): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Builds the CLI command interface using the commander.js program instance.
|
|
102
|
+
* Initializes the command with its options and action handler.
|
|
103
|
+
*
|
|
104
|
+
* @param {object} program - The commander.js program instance
|
|
105
|
+
* @returns {Promise<this>} Returns this instance for method chaining
|
|
106
|
+
*/
|
|
107
|
+
buildCli(program: object): Promise<this>;
|
|
108
|
+
/**
|
|
109
|
+
* Adds a single CLI option to the command.
|
|
110
|
+
*
|
|
111
|
+
* @param {string} name - The option name
|
|
112
|
+
* @param {Array<string>} options - Array containing option flag and description
|
|
113
|
+
* @param {boolean} preserve - Whether to preserve this option name in the list
|
|
114
|
+
* @returns {Promise<this>} Returns this instance for method chaining
|
|
115
|
+
*/
|
|
116
|
+
addCliOption(name: string, options: Array<string>, preserve: boolean): Promise<this>;
|
|
117
|
+
/**
|
|
118
|
+
* Adds multiple CLI options to the command.
|
|
119
|
+
*
|
|
120
|
+
* @param {object} options - Object mapping option names to [flag, description] arrays
|
|
121
|
+
* @param {boolean} preserve - Whether to preserve option names in the list
|
|
122
|
+
* @returns {this} Returns this instance for method chaining
|
|
123
|
+
*/
|
|
124
|
+
addCliOptions(options: object, preserve: boolean): this;
|
|
125
|
+
/**
|
|
126
|
+
* Resolves a theme file name to a FileObject and validates its existence.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} fileName - The theme file name or path
|
|
129
|
+
* @param {DirectoryObject} cwd - The current working directory object
|
|
130
|
+
* @returns {Promise<FileObject>} The resolved and validated FileObject
|
|
131
|
+
* @throws {Sass} If the file does not exist
|
|
132
|
+
*/
|
|
133
|
+
resolveThemeFileName(fileName: string, cwd: DirectoryObject): Promise<FileObject>;
|
|
134
|
+
#private;
|
|
135
|
+
}
|
|
136
|
+
import type { DirectoryObject } from "@gesslar/toolkit";
|
|
137
|
+
import type { Cache } from "@gesslar/toolkit";
|
|
138
|
+
import type { FileObject } from "@gesslar/toolkit";
|
|
139
|
+
//# sourceMappingURL=Command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../src/Command.js"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH;;;GAGG;AACH;IAUE;;;;;OAKG;IACH,kCAHW,eAAe,EAMzB;IAED;;;;OAIG;IACH,UAFa,eAAe,CAI3B;IAED;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,gBAHW,KAAK,GACH,IAAI,CAMhB;IAED;;;;OAIG;IACH,YAFa,KAAK,GAAC,IAAI,CAItB;IAED;;;;;OAKG;IACH,oBAHW,MAAM,GACJ,IAAI,CAMhB;IAED;;;;OAIG;IACH,iBAFa,MAAM,GAAC,IAAI,CAIvB;IAED;;;;;OAKG;IACH,oBAHW,MAAM,GACJ,IAAI,CAMhB;IAED;;;;OAIG;IACH,iBAFa,MAAM,GAAC,IAAI,CAIvB;IAED;;;;OAIG;IACH,qBAFa,KAAK,CAAC,MAAM,CAAC,CAIzB;IAED;;;;OAIG;IACH,YAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,iBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,iBAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,YAFa,OAAO,CAInB;IAED;;;;;;OAMG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAuBzB;IAED;;;;;;;OAOG;IACH,mBALW,MAAM,WACN,KAAK,CAAC,MAAM,CAAC,YACb,OAAO,GACL,OAAO,CAAC,IAAI,CAAC,CAYzB;IAED;;;;;;OAMG;IACH,uBAJW,MAAM,YACN,OAAO,GACL,IAAI,CAOhB;IAED;;;;;;;OAOG;IACH,+BALW,MAAM,OACN,eAAe,GACb,OAAO,CAAC,UAAU,CAAC,CAY/B;;CACF;qCA/OiC,kBAAkB;2BAE5B,kBAAkB;gCADb,kBAAkB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Theme} from "./Theme.js"
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Main compiler class for processing theme source files.
|
|
6
|
+
* Handles the complete compilation pipeline from source to VS Code theme output.
|
|
7
|
+
*/
|
|
8
|
+
export default class Compiler {
|
|
9
|
+
/**
|
|
10
|
+
* Compiles a theme source file into a VS Code colour theme.
|
|
11
|
+
* Processes configuration, variables, imports, and theme definitions.
|
|
12
|
+
*
|
|
13
|
+
* @param {Theme} theme - The file object containing source data and metadata
|
|
14
|
+
* @returns {Promise<void>} Resolves when compilation is complete
|
|
15
|
+
*/
|
|
16
|
+
compile(theme: Theme): Promise<void>;
|
|
17
|
+
#private;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=Compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Compiler.d.ts","sourceRoot":"","sources":["../src/Compiler.js"],"names":[],"mappings":"AAiBA;;GAEG;AAEH;;;GAGG;AACH;IACE;;;;;;OAMG;IACH,uBAFa,OAAO,CAAC,IAAI,CAAC,CA4GzB;;CA4NF"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluator class for resolving variables and colour tokens in theme objects.
|
|
3
|
+
* Handles recursive substitution of token references in arrays of objects
|
|
4
|
+
* with support for colour manipulation functions.
|
|
5
|
+
*/
|
|
6
|
+
export default class Evaluator {
|
|
7
|
+
/**
|
|
8
|
+
* Regular expression used to locate variable substitution tokens. Supports:
|
|
9
|
+
* - POSIX-ish: $(variable.path)
|
|
10
|
+
* - Legacy: $variable.path
|
|
11
|
+
* - Braced: ${variable.path}
|
|
12
|
+
*
|
|
13
|
+
* Capturing groups allow extraction of the inner path variant irrespective
|
|
14
|
+
* of wrapping style. The pattern captures (entireMatch, posix, legacy,
|
|
15
|
+
* braced).
|
|
16
|
+
*
|
|
17
|
+
* @type {RegExp}
|
|
18
|
+
*/
|
|
19
|
+
static sub: RegExp;
|
|
20
|
+
/**
|
|
21
|
+
* Regular expression for matching colour / transformation function calls
|
|
22
|
+
* within token strings, e.g. `darken($(std.accent), 10)`.
|
|
23
|
+
*
|
|
24
|
+
* @type {RegExp}
|
|
25
|
+
*/
|
|
26
|
+
static func: RegExp;
|
|
27
|
+
/**
|
|
28
|
+
* Extracts a variable name from a string containing variable syntax.
|
|
29
|
+
* Supports $(var), $var, and ${var} patterns.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} [str] - String that may contain a variable reference
|
|
32
|
+
* @returns {string|null} The variable name or null if none found
|
|
33
|
+
*/
|
|
34
|
+
static extractVariableName(str?: string): string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Extracts function name and arguments from a string containing function syntax.
|
|
37
|
+
* Supports functionName(args) patterns.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} [str] - String that may contain a function call
|
|
40
|
+
* @returns {{func:string, args:string}|null} Object with {func, args} or null if none found
|
|
41
|
+
*/
|
|
42
|
+
static extractFunctionCall(str?: string): {
|
|
43
|
+
func: string;
|
|
44
|
+
args: string;
|
|
45
|
+
} | null;
|
|
46
|
+
/**
|
|
47
|
+
* Regular expression for expanding palette alias syntax. The `$` prefix
|
|
48
|
+
* inside variable references is shorthand for `palette.`:
|
|
49
|
+
* - `$$name` → `$palette.name`
|
|
50
|
+
* - `$($name)` → `$(palette.name)`
|
|
51
|
+
* - `${$name}` → `${palette.name}`
|
|
52
|
+
*
|
|
53
|
+
* @type {RegExp}
|
|
54
|
+
*/
|
|
55
|
+
static paletteAlias: RegExp;
|
|
56
|
+
/**
|
|
57
|
+
* Expands palette alias references in a string value.
|
|
58
|
+
* Converts `$$name`, `$($name)`, and `${$name}` to their
|
|
59
|
+
* full `palette.` equivalents before variable resolution.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} value - The string potentially containing palette aliases
|
|
62
|
+
* @returns {string} The string with palette aliases expanded
|
|
63
|
+
*/
|
|
64
|
+
static expandPaletteAliases(value: string): string;
|
|
65
|
+
get pool(): ThemePool;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve variables and theme token entries in two distinct passes to ensure
|
|
68
|
+
* deterministic scoping and to prevent partially-resolved values from
|
|
69
|
+
* leaking between stages:
|
|
70
|
+
*
|
|
71
|
+
* 1. Variable pass: each variable is resolved only with access to the
|
|
72
|
+
* variable set itself (no theme values yet). This ensures variables are
|
|
73
|
+
* self-contained building blocks.
|
|
74
|
+
* 2. Theme pass: theme entries are then resolved against the union of the
|
|
75
|
+
* fully-resolved variables plus (progressively) the theme entries. This
|
|
76
|
+
* allows theme keys to reference variables and other theme keys.
|
|
77
|
+
*
|
|
78
|
+
* Implementation details:
|
|
79
|
+
* - The internal lookup map persists for the lifetime of this instance; new
|
|
80
|
+
* entries overwrite prior values (last write wins) so previously resolved
|
|
81
|
+
* data can seed later evaluations without a rebuild.
|
|
82
|
+
* - Input array is mutated in-place (`value` fields change).
|
|
83
|
+
* - No return value. Evident by the absence of a return statement.
|
|
84
|
+
*
|
|
85
|
+
* @param {Array<{flatPath:string,value:unknown}>} decomposed - Variable entries to resolve.
|
|
86
|
+
* @example
|
|
87
|
+
* // Example decomposed input with variables and theme references
|
|
88
|
+
* const evaluator = new Evaluator();
|
|
89
|
+
* const decomposed = [
|
|
90
|
+
* { flatPath: 'vars.primary', value: '#3366cc' },
|
|
91
|
+
* { flatPath: 'theme.colors.background', value: '$(vars.primary)' },
|
|
92
|
+
* { flatPath: 'theme.colors.accent', value: 'lighten($(vars.primary), 20)' }
|
|
93
|
+
* ];
|
|
94
|
+
* evaluator.evaluate(decomposed);
|
|
95
|
+
* // After evaluation, values are resolved:
|
|
96
|
+
* // decomposed[1].value === '#3366cc'
|
|
97
|
+
* // decomposed[2].value === '#5588dd' (lightened color)
|
|
98
|
+
*/
|
|
99
|
+
evaluate(decomposed: Array<{
|
|
100
|
+
flatPath: string;
|
|
101
|
+
value: unknown;
|
|
102
|
+
}>): void;
|
|
103
|
+
#private;
|
|
104
|
+
}
|
|
105
|
+
import ThemePool from "./ThemePool.js";
|
|
106
|
+
//# sourceMappingURL=Evaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Evaluator.d.ts","sourceRoot":"","sources":["../src/Evaluator.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH;IAWE;;;;;;;;;;;OAWG;IACH,YAFU,MAAM,CAEwF;IAExG;;;;;OAKG;IACH,aAFU,MAAM,CAE4C;IAE5D;;;;;;OAMG;IACH,iCAHW,MAAM,GACJ,MAAM,GAAC,IAAI,CAMvB;IAED;;;;;;OAMG;IACH,iCAHW,MAAM,GACJ;QAAC,IAAI,EAAC,MAAM,CAAC;QAAC,IAAI,EAAC,MAAM,CAAA;KAAC,GAAC,IAAI,CAW3C;IAOD;;;;;;;;OAQG;IACH,qBAFU,MAAM,CAEkE;IAElF;;;;;;;OAOG;IACH,mCAHW,MAAM,GACJ,MAAM,CAUlB;IA/BD,sBAEC;IA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,qBAdW,KAAK,CAAC;QAAC,QAAQ,EAAC,MAAM,CAAC;QAAA,KAAK,EAAC,OAAO,CAAA;KAAC,CAAC,QAmEhD;;CAuOF;sBAvaqB,gBAAgB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {ThemePool} from "./ThemePool.js"
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Command handler for linting theme files for potential issues.
|
|
6
|
+
* Validates tokenColors for duplicate scopes, undefined variables, unused
|
|
7
|
+
* variables, and precedence issues that could cause unexpected theme
|
|
8
|
+
* behaviour.
|
|
9
|
+
*/
|
|
10
|
+
export default class LintCommand extends Command {
|
|
11
|
+
static SECTIONS: {
|
|
12
|
+
VARS: string;
|
|
13
|
+
COLORS: string;
|
|
14
|
+
TOKEN_COLORS: string;
|
|
15
|
+
SEMANTIC_TOKEN_COLORS: string;
|
|
16
|
+
};
|
|
17
|
+
static SEVERITY: {
|
|
18
|
+
HIGH: string;
|
|
19
|
+
MEDIUM: string;
|
|
20
|
+
LOW: string;
|
|
21
|
+
};
|
|
22
|
+
static ISSUE_TYPES: {
|
|
23
|
+
DUPLICATE_SCOPE: string;
|
|
24
|
+
UNDEFINED_VARIABLE: string;
|
|
25
|
+
UNUSED_VARIABLE: string;
|
|
26
|
+
PRECEDENCE_ISSUE: string;
|
|
27
|
+
};
|
|
28
|
+
static TEMPLATES: {
|
|
29
|
+
ENTRY_NAME: (index: any) => string;
|
|
30
|
+
OBJECT_NAME: (index: any) => string;
|
|
31
|
+
VARIABLE_PREFIX: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new LintCommand instance.
|
|
35
|
+
*
|
|
36
|
+
* @param {object} base - Base configuration containing cwd and packageJson
|
|
37
|
+
*/
|
|
38
|
+
constructor(base: object);
|
|
39
|
+
/**
|
|
40
|
+
* Executes the lint command for a given theme file.
|
|
41
|
+
* Validates the theme and reports any issues found.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} inputArg - Path to the theme file to lint
|
|
44
|
+
* @param {object} options - Linting options
|
|
45
|
+
* @returns {Promise<void>} Resolves when linting is complete
|
|
46
|
+
*/
|
|
47
|
+
execute(inputArg: string, options?: object): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Public method to lint a theme and return structured results for external
|
|
50
|
+
* consumption.
|
|
51
|
+
*
|
|
52
|
+
* Returns categorized lint results for tokenColors, semanticTokenColors, and colors.
|
|
53
|
+
*
|
|
54
|
+
* @param {Theme} theme - The compiled theme object
|
|
55
|
+
* @returns {Promise<object>} Object containing categorized lint results
|
|
56
|
+
*/
|
|
57
|
+
lint(theme: Theme): Promise<object>;
|
|
58
|
+
#private;
|
|
59
|
+
}
|
|
60
|
+
import Command from "./Command.js";
|
|
61
|
+
import Theme from "./Theme.js";
|
|
62
|
+
//# sourceMappingURL=LintCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LintCommand.d.ts","sourceRoot":"","sources":["../src/LintCommand.js"],"names":[],"mappings":"AAyBA;;GAEG;AAKH;;;;;GAKG;AACH;IAGE;;;;;MAKC;IAGD;;;;MAIC;IAGD;;;;;MAKC;IAGD;;;;MAIC;IACD;;;;OAIG;IACH,kBAFW,MAAM,EAYhB;IAED;;;;;;;OAOG;IACH,kBAJW,MAAM,YACN,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAczB;IAED;;;;;;;;OAQG;IACH,YAHW,KAAK,GACH,OAAO,CAAC,MAAM,CAAC,CAyC3B;;CAykBF;oBAjtBmB,cAAc;kBAEhB,YAAY"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command handler for resolving theme tokens and variables to their final values.
|
|
3
|
+
* Provides introspection into the theme resolution process and variable dependencies.
|
|
4
|
+
*/
|
|
5
|
+
export default class ResolveCommand extends Command {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new ResolveCommand instance.
|
|
8
|
+
*
|
|
9
|
+
* @param {object} base - Base configuration containing cwd and packageJson
|
|
10
|
+
*/
|
|
11
|
+
constructor(base: object);
|
|
12
|
+
/**
|
|
13
|
+
* Builds the CLI command, adding extra options that are not mutually exclusive.
|
|
14
|
+
*
|
|
15
|
+
* @param {object} program - The commander.js program instance
|
|
16
|
+
* @returns {Promise<this>} Returns this instance for method chaining
|
|
17
|
+
*/
|
|
18
|
+
buildCli(program: object): Promise<this>;
|
|
19
|
+
/**
|
|
20
|
+
* Executes the resolve command for a given theme file and option.
|
|
21
|
+
* Validates mutual exclusivity of options and delegates to appropriate resolver.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} inputArg - Path to the theme file to resolve
|
|
24
|
+
* @param {object} options - Resolution options (token, etc.)
|
|
25
|
+
* @returns {Promise<void>} Resolves when resolution is complete
|
|
26
|
+
*/
|
|
27
|
+
execute(inputArg: string, options?: object): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Resolves a specific color to its final value and displays the resolution trail.
|
|
30
|
+
* Shows the complete dependency chain for the requested color.
|
|
31
|
+
*
|
|
32
|
+
* @param {object} theme - The compiled theme object with pool
|
|
33
|
+
* @param {string} colorName - The color key to resolve
|
|
34
|
+
* @returns {void}
|
|
35
|
+
* @example
|
|
36
|
+
* // Resolve a color variable from a compiled theme
|
|
37
|
+
* await resolveCommand.resolveColor(theme, 'colors.primary');
|
|
38
|
+
* // Output:
|
|
39
|
+
* // colors.primary:
|
|
40
|
+
* // $(vars.accent)
|
|
41
|
+
* // → #3366cc
|
|
42
|
+
* // Resolution: #3366cc
|
|
43
|
+
*/
|
|
44
|
+
resolveColor(theme: object, colorName: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Resolves a specific tokenColors scope to its final value and displays the resolution trail.
|
|
47
|
+
* Shows all matching scopes with disambiguation when multiple matches are found.
|
|
48
|
+
*
|
|
49
|
+
* @param {object} theme - The compiled theme object with output
|
|
50
|
+
* @param {string} scopeName - The scope to resolve (e.g., "entity.name.class" or "entity.name.class.1")
|
|
51
|
+
* @returns {void}
|
|
52
|
+
*/
|
|
53
|
+
resolveTokenColor(theme: object, scopeName: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Resolves a specific semanticTokenColors scope to its final value.
|
|
56
|
+
* Uses the same logic as tokenColors since they have identical structure.
|
|
57
|
+
*
|
|
58
|
+
* @param {object} theme - The compiled theme object with output
|
|
59
|
+
* @param {string} scopeName - The scope to resolve (e.g., "keyword" or "keyword.1")
|
|
60
|
+
* @returns {void}
|
|
61
|
+
*/
|
|
62
|
+
resolveSemanticTokenColor(theme: object, scopeName: string): void;
|
|
63
|
+
#private;
|
|
64
|
+
}
|
|
65
|
+
import Command from "./Command.js";
|
|
66
|
+
//# sourceMappingURL=ResolveCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolveCommand.d.ts","sourceRoot":"","sources":["../src/ResolveCommand.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAIE;;;;OAIG;IACH,kBAFW,MAAM,EAchB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAOzB;IAED;;;;;;;OAOG;IACH,kBAJW,MAAM,YACN,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAiDzB;IAED;;;;;;;;;;;;;;;OAeG;IACH,oBAZW,MAAM,aACN,MAAM,GACJ,IAAI,CA2BhB;IAED;;;;;;;OAOG;IACH,yBAJW,MAAM,aACN,MAAM,GACJ,IAAI,CA4ChB;IAuED;;;;;;;OAOG;IACH,iCAJW,MAAM,aACN,MAAM,GACJ,IAAI,CAoBhB;;CAwQF;oBAviBmB,cAAc"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Command} from "./Command.js"
|
|
3
|
+
* @import {Theme} from "./Theme.js"
|
|
4
|
+
* @import {FSWatcher} from "chokidar"
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {object} SessionOptions
|
|
8
|
+
* @property {boolean} [watch] - Whether to enable file watching
|
|
9
|
+
* @property {boolean} [nerd] - Whether to show verbose output
|
|
10
|
+
* @property {boolean} [dryRun] - Whether to skip file writes
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} BuildRecord
|
|
14
|
+
* @property {number} timestamp - Epoch ms when the build started
|
|
15
|
+
* @property {number} loadTime - Time (ms) spent loading theme sources
|
|
16
|
+
* @property {number} buildTime - Time (ms) spent compiling the theme
|
|
17
|
+
* @property {number} writeTime - Time (ms) spent writing the output file
|
|
18
|
+
* @property {boolean} success - Whether the build completed successfully
|
|
19
|
+
* @property {string} [error] - Error message when success is false
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @import {Theme} from "./Theme.js"
|
|
23
|
+
* @import {Command} from "./Command.js"
|
|
24
|
+
*/
|
|
25
|
+
export default class Session {
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new Session instance for managing theme compilation lifecycle.
|
|
28
|
+
* Sessions provide persistent state across rebuilds, error tracking, and
|
|
29
|
+
* individual theme management within the build system.
|
|
30
|
+
*
|
|
31
|
+
* @param {Command} command - The parent build command instance
|
|
32
|
+
* @param {Theme} theme - The theme instance to manage
|
|
33
|
+
* @param {SessionOptions} options - Build configuration options
|
|
34
|
+
*/
|
|
35
|
+
constructor(command: path, theme: path, options: SessionOptions);
|
|
36
|
+
get theme(): any;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the theme instance managed by this session.
|
|
39
|
+
*
|
|
40
|
+
* @returns {Theme} The theme instance
|
|
41
|
+
*/
|
|
42
|
+
getTheme(): path;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the command instance orchestrating this session.
|
|
45
|
+
*
|
|
46
|
+
* @returns {Command} The command instance
|
|
47
|
+
*/
|
|
48
|
+
getCommand(): path;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the session options.
|
|
51
|
+
*
|
|
52
|
+
* @returns {SessionOptions} The session options
|
|
53
|
+
*/
|
|
54
|
+
getOptions(): SessionOptions;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the build history for this session.
|
|
57
|
+
*
|
|
58
|
+
* @returns {Array<BuildRecord>} Array of build records
|
|
59
|
+
*/
|
|
60
|
+
getHistory(): Array<BuildRecord>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the build statistics for this session.
|
|
63
|
+
*
|
|
64
|
+
* @returns {{builds: number, failures: number}} Build statistics
|
|
65
|
+
*/
|
|
66
|
+
getStats(): {
|
|
67
|
+
builds: number;
|
|
68
|
+
failures: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Checks if a build is currently in progress.
|
|
72
|
+
*
|
|
73
|
+
* @returns {boolean} True if building
|
|
74
|
+
*/
|
|
75
|
+
isBuilding(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Checks if watch mode is enabled.
|
|
78
|
+
*
|
|
79
|
+
* @returns {boolean} True if watching
|
|
80
|
+
*/
|
|
81
|
+
isWatching(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Checks if there's an active file watcher.
|
|
84
|
+
*
|
|
85
|
+
* @returns {boolean} True if watcher exists
|
|
86
|
+
*/
|
|
87
|
+
hasWatcher(): boolean;
|
|
88
|
+
run(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Displays a formatted summary of the session's build statistics and
|
|
91
|
+
* performance. Shows total builds, success/failure counts, success rate
|
|
92
|
+
* percentage, and timing information from the most recent build. Used during
|
|
93
|
+
* session cleanup to provide final statistics to the user.
|
|
94
|
+
*
|
|
95
|
+
* @returns {void}
|
|
96
|
+
*/
|
|
97
|
+
showSummary(): void;
|
|
98
|
+
#private;
|
|
99
|
+
}
|
|
100
|
+
export type SessionOptions = {
|
|
101
|
+
/**
|
|
102
|
+
* - Whether to enable file watching
|
|
103
|
+
*/
|
|
104
|
+
watch?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* - Whether to show verbose output
|
|
107
|
+
*/
|
|
108
|
+
nerd?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* - Whether to skip file writes
|
|
111
|
+
*/
|
|
112
|
+
dryRun?: boolean;
|
|
113
|
+
};
|
|
114
|
+
export type BuildRecord = {
|
|
115
|
+
/**
|
|
116
|
+
* - Epoch ms when the build started
|
|
117
|
+
*/
|
|
118
|
+
timestamp: number;
|
|
119
|
+
/**
|
|
120
|
+
* - Time (ms) spent loading theme sources
|
|
121
|
+
*/
|
|
122
|
+
loadTime: number;
|
|
123
|
+
/**
|
|
124
|
+
* - Time (ms) spent compiling the theme
|
|
125
|
+
*/
|
|
126
|
+
buildTime: number;
|
|
127
|
+
/**
|
|
128
|
+
* - Time (ms) spent writing the output file
|
|
129
|
+
*/
|
|
130
|
+
writeTime: number;
|
|
131
|
+
/**
|
|
132
|
+
* - Whether the build completed successfully
|
|
133
|
+
*/
|
|
134
|
+
success: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* - Error message when success is false
|
|
137
|
+
*/
|
|
138
|
+
error?: string;
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=Session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Session.d.ts","sourceRoot":"","sources":["../src/Session.js"],"names":[],"mappings":"AAKA;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;;;GAQG;AAEH;;;GAGG;AAEH;IAqIE;;;;;;;;OAQG;IACH,qBAJW,IAAO,SACP,IAAK,WACL,cAAc,EAMxB;IAzFD,iBAEC;IAED;;;;OAIG;IACH,YAFa,IAAK,CAIjB;IAED;;;;OAIG;IACH,cAFa,IAAO,CAInB;IAED;;;;OAIG;IACH,cAFa,cAAc,CAI1B;IAED;;;;OAIG;IACH,cAFa,KAAK,CAAC,WAAW,CAAC,CAI9B;IAED;;;;OAIG;IACH,YAFa;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,CAI9C;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAiBD,qBA0BC;IAwND;;;;;;;OAOG;IACH,eAFa,IAAI,CAkChB;;CAyFF;;;;;YA3hBa,OAAO;;;;WACP,OAAO;;;;aACP,OAAO;;;;;;eAKP,MAAM;;;;cACN,MAAM;;;;eACN,MAAM;;;;eACN,MAAM;;;;aACN,OAAO;;;;YACP,MAAM"}
|