@gesslar/sassy 0.21.1 → 0.22.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/package.json +18 -7
- package/src/BuildCommand.js +1 -2
- package/src/Colour.js +1 -3
- package/src/Command.js +1 -37
- package/src/Compiler.js +1 -6
- package/src/Evaluator.js +1 -1
- package/src/LintCommand.js +1 -2
- package/src/ResolveCommand.js +3 -6
- package/src/Session.js +1 -4
- package/src/Theme.js +1 -7
- package/src/ThemePool.js +1 -1
- package/src/ThemeToken.js +1 -1
- package/src/cli.js +1 -5
- package/src/index.js +40 -0
- package/types/BuildCommand.d.ts +40 -0
- package/types/Colour.d.ts +126 -0
- package/types/Command.d.ts +135 -0
- package/types/Compiler.d.ts +16 -0
- package/types/Evaluator.d.ts +86 -0
- package/types/LintCommand.d.ts +58 -0
- package/types/ResolveCommand.d.ts +58 -0
- package/types/Session.d.ts +132 -0
- package/types/Theme.d.ts +336 -0
- package/types/ThemePool.d.ts +81 -0
- package/types/ThemeToken.d.ts +150 -0
- package/types/cli.d.ts +2 -0
- package/types/index.d.ts +9 -0
- package/src/Cache.js +0 -74
- package/src/Data.js +0 -533
- package/src/DirectoryObject.js +0 -188
- package/src/File.js +0 -346
- package/src/FileObject.js +0 -226
- package/src/Sass.js +0 -166
- package/src/Term.js +0 -175
- package/src/Type.js +0 -207
- package/src/Util.js +0 -132
- package/src/Valid.js +0 -50
package/package.json
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gesslar/sassy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"displayName": "Sassy",
|
|
5
5
|
"description": "Make gorgeous themes that speak as boldly as you do.",
|
|
6
6
|
"publisher": "gesslar",
|
|
7
7
|
"license": "Unlicense",
|
|
8
8
|
"type": "module",
|
|
9
|
-
"main": "src/
|
|
9
|
+
"main": "src/index.js",
|
|
10
|
+
"types": "types/index.d.ts",
|
|
10
11
|
"bin": "src/cli.js",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./types/index.d.ts",
|
|
15
|
+
"import": "./src/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
11
18
|
"files": [
|
|
12
19
|
"src/",
|
|
20
|
+
"types/",
|
|
13
21
|
"UNLICENSE.txt"
|
|
14
22
|
],
|
|
15
23
|
"scripts": {
|
|
16
24
|
"clean": "rm -rfv ./dist",
|
|
17
|
-
"
|
|
25
|
+
"clean-types": "rm -rfv ./types",
|
|
26
|
+
"types": "npx tsc src/*.js types-helper.d.ts --allowJs --declaration --emitDeclarationOnly --outDir types --target ES2022 --module ESNext --moduleResolution Node --esModuleInterop --skipLibCheck --resolveJsonModule && node fix-types.js",
|
|
27
|
+
"build": "npm run clean && npm run types && mkdir -pv ./dist && npm pack --pack-destination ./dist/",
|
|
18
28
|
"exec": "node ./src/cli.js",
|
|
19
29
|
"lint": "eslint src/",
|
|
20
|
-
"submit": "npm publish --access public",
|
|
30
|
+
"submit": "npm run build && npm publish --access public",
|
|
21
31
|
"examples": "node ./examples/validator.js",
|
|
22
32
|
"test": "node -p \"require('fs').readFileSync('TESTING.txt', 'utf8')\"",
|
|
23
33
|
"update": "npx npm-check-updates -u && npm install"
|
|
@@ -43,6 +53,7 @@
|
|
|
43
53
|
],
|
|
44
54
|
"dependencies": {
|
|
45
55
|
"@gesslar/colours": "^0.0.1",
|
|
56
|
+
"@gesslar/toolkit": "^0.0.3",
|
|
46
57
|
"chokidar": "^4.0.3",
|
|
47
58
|
"color-support": "^1.1.3",
|
|
48
59
|
"commander": "^14.0.1",
|
|
@@ -52,13 +63,13 @@
|
|
|
52
63
|
"yaml": "^2.8.1"
|
|
53
64
|
},
|
|
54
65
|
"devDependencies": {
|
|
55
|
-
"@stylistic/eslint-plugin": "^5.
|
|
66
|
+
"@stylistic/eslint-plugin": "^5.4.0",
|
|
56
67
|
"@types/vscode": "^1.104.0",
|
|
57
68
|
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
58
69
|
"@typescript-eslint/parser": "^8.44.0",
|
|
59
70
|
"esbuild": "^0.25.10",
|
|
60
|
-
"eslint": "^9.
|
|
61
|
-
"eslint-plugin-jsdoc": "^
|
|
71
|
+
"eslint": "^9.36.0",
|
|
72
|
+
"eslint-plugin-jsdoc": "^60.1.0",
|
|
62
73
|
"typescript": "^5.9.2"
|
|
63
74
|
}
|
|
64
75
|
}
|
package/src/BuildCommand.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {EventEmitter} from "node:events"
|
|
2
2
|
import process from "node:process"
|
|
3
3
|
|
|
4
|
+
import {Sass, Term} from "@gesslar/toolkit"
|
|
4
5
|
import Command from "./Command.js"
|
|
5
|
-
import Sass from "./Sass.js"
|
|
6
6
|
import Session from "./Session.js"
|
|
7
|
-
import Term from "./Term.js"
|
|
8
7
|
import Theme from "./Theme.js"
|
|
9
8
|
|
|
10
9
|
/**
|
package/src/Colour.js
CHANGED
|
@@ -13,10 +13,8 @@ import {
|
|
|
13
13
|
parse
|
|
14
14
|
} from "culori"
|
|
15
15
|
|
|
16
|
-
import Sass from "
|
|
16
|
+
import {Util, Sass} from "@gesslar/toolkit"
|
|
17
17
|
import ThemeToken from "./ThemeToken.js"
|
|
18
|
-
import Util from "./Util.js"
|
|
19
|
-
|
|
20
18
|
// Cache for parsed colours to improve performance
|
|
21
19
|
const _colourCache = new Map()
|
|
22
20
|
|
package/src/Command.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import Sass from "
|
|
2
|
-
import FileObject from "./FileObject.js"
|
|
3
|
-
import DirectoryObject from "./DirectoryObject.js"
|
|
4
|
-
import Cache from "./Cache.js"
|
|
1
|
+
import {Sass, FileObject, DirectoryObject, Cache} from "@gesslar/toolkit"
|
|
5
2
|
|
|
6
3
|
/**
|
|
7
4
|
* Base class for command-line interface commands.
|
|
@@ -237,37 +234,4 @@ export default class Command {
|
|
|
237
234
|
return fileObject
|
|
238
235
|
}
|
|
239
236
|
|
|
240
|
-
/**
|
|
241
|
-
* Emits an event asynchronously and waits for all listeners to complete.
|
|
242
|
-
* Unlike the standard EventEmitter.emit() which is synchronous, this method
|
|
243
|
-
* properly handles async event listeners by waiting for all of them to
|
|
244
|
-
* resolve or reject using Promise.allSettled().
|
|
245
|
-
*
|
|
246
|
-
* @param {string} event - The event name to emit
|
|
247
|
-
* @param {...unknown} [arg] - Arguments to pass to event listeners
|
|
248
|
-
* @returns {Promise<void>} Resolves when all listeners have completed
|
|
249
|
-
*/
|
|
250
|
-
async asyncEmit(event, arg) {
|
|
251
|
-
try {
|
|
252
|
-
arg = arg || new Array()
|
|
253
|
-
const listeners = this.emitter.listeners(event)
|
|
254
|
-
|
|
255
|
-
const settled =
|
|
256
|
-
await Promise.allSettled(listeners.map(listener => listener(arg)))
|
|
257
|
-
|
|
258
|
-
const rejected = settled.filter(reject => reject.status === "rejected")
|
|
259
|
-
|
|
260
|
-
if(rejected.length > 0) {
|
|
261
|
-
if(rejected[0].reason instanceof Error)
|
|
262
|
-
throw rejected[0].reason
|
|
263
|
-
else
|
|
264
|
-
throw Sass.new(rejected[0].reason)
|
|
265
|
-
}
|
|
266
|
-
} catch(error) {
|
|
267
|
-
throw Sass.new(
|
|
268
|
-
`Processing '${event}' event with ${arg&&arg.length?`'${arg}'`:"no arguments"}.`,
|
|
269
|
-
error
|
|
270
|
-
)
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
237
|
}
|
package/src/Compiler.js
CHANGED
|
@@ -11,14 +11,9 @@
|
|
|
11
11
|
* Supports extension points for custom phases and output formats.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import Sass from "
|
|
15
|
-
import Data from "./Data.js"
|
|
14
|
+
import {Sass, Data, File, FileObject, Term, Util} from "@gesslar/toolkit"
|
|
16
15
|
import Evaluator from "./Evaluator.js"
|
|
17
|
-
import File from "./File.js"
|
|
18
|
-
import FileObject from "./FileObject.js"
|
|
19
|
-
import Term from "./Term.js"
|
|
20
16
|
import Theme from "./Theme.js"
|
|
21
|
-
import Util from "./Util.js"
|
|
22
17
|
|
|
23
18
|
/**
|
|
24
19
|
* Main compiler class for processing theme source files.
|
package/src/Evaluator.js
CHANGED
package/src/LintCommand.js
CHANGED
|
@@ -20,9 +20,8 @@ import c from "@gesslar/colours"
|
|
|
20
20
|
|
|
21
21
|
import Command from "./Command.js"
|
|
22
22
|
import Evaluator from "./Evaluator.js"
|
|
23
|
-
import File from "./File.js"
|
|
24
|
-
import Term from "./Term.js"
|
|
25
23
|
import Theme from "./Theme.js"
|
|
24
|
+
import {Term} from "@gesslar/toolkit"
|
|
26
25
|
import ThemePool from "./ThemePool.js"
|
|
27
26
|
|
|
28
27
|
// oops, need to have @gesslar/colours support this, too!
|
package/src/ResolveCommand.js
CHANGED
|
@@ -2,13 +2,10 @@ import c from "@gesslar/colours"
|
|
|
2
2
|
// import colorSupport from "color-support"
|
|
3
3
|
|
|
4
4
|
import Command from "./Command.js"
|
|
5
|
-
import Sass from "
|
|
5
|
+
import {Sass, Term, Util, Data} from "@gesslar/toolkit"
|
|
6
6
|
import Colour from "./Colour.js"
|
|
7
7
|
import Evaluator from "./Evaluator.js"
|
|
8
|
-
import Term from "./Term.js"
|
|
9
8
|
import Theme from "./Theme.js"
|
|
10
|
-
import Util from "./Util.js"
|
|
11
|
-
import Data from "./Data.js"
|
|
12
9
|
|
|
13
10
|
// ansiColors.enabled = colorSupport.hasBasic
|
|
14
11
|
|
|
@@ -436,10 +433,10 @@ export default class ResolveCommand extends Command {
|
|
|
436
433
|
|
|
437
434
|
if(this.#func.test(value)) {
|
|
438
435
|
const result = Evaluator.extractFunctionCall(value)
|
|
439
|
-
|
|
436
|
+
|
|
440
437
|
if(!result)
|
|
441
438
|
return [c`{leaf}${value}{/}`, "literal"]
|
|
442
|
-
|
|
439
|
+
|
|
443
440
|
const {func, args} = result
|
|
444
441
|
|
|
445
442
|
return [
|
package/src/Session.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import chokidar from "chokidar"
|
|
2
2
|
|
|
3
3
|
import Command from "./Command.js"
|
|
4
|
-
import Sass from "
|
|
5
|
-
import File from "./File.js"
|
|
6
|
-
import Term from "./Term.js"
|
|
4
|
+
import {Sass, File, Term, Util} from "@gesslar/toolkit"
|
|
7
5
|
import Theme from "./Theme.js"
|
|
8
|
-
import Util from "./Util.js"
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* @typedef {object} SessionOptions
|
package/src/Theme.js
CHANGED
|
@@ -13,15 +13,9 @@
|
|
|
13
13
|
* - Write output files, supporting dry-run and hash-based skip
|
|
14
14
|
* - Support watch mode for live theme development
|
|
15
15
|
*/
|
|
16
|
-
import Sass from "
|
|
16
|
+
import {Sass, DirectoryObject, File, FileObject, Term, Util, Cache} from "@gesslar/toolkit"
|
|
17
17
|
import Compiler from "./Compiler.js"
|
|
18
|
-
import DirectoryObject from "./DirectoryObject.js"
|
|
19
|
-
import File from "./File.js"
|
|
20
|
-
import FileObject from "./FileObject.js"
|
|
21
|
-
import Term from "./Term.js"
|
|
22
18
|
import ThemePool from "./ThemePool.js"
|
|
23
|
-
import Util from "./Util.js"
|
|
24
|
-
import Cache from "./Cache.js"
|
|
25
19
|
|
|
26
20
|
const outputFileExtension = "color-theme.json"
|
|
27
21
|
const obviouslyASentinelYouCantMissSoShutUpAboutIt = "kakadoodoo"
|
package/src/ThemePool.js
CHANGED
package/src/ThemeToken.js
CHANGED
package/src/cli.js
CHANGED
|
@@ -36,14 +36,10 @@ import process from "node:process"
|
|
|
36
36
|
import url from "node:url"
|
|
37
37
|
import c from "@gesslar/colours"
|
|
38
38
|
|
|
39
|
-
import Cache from "
|
|
40
|
-
import Sass from "./Sass.js"
|
|
39
|
+
import {Cache, Sass, DirectoryObject, FileObject, Term} from "@gesslar/toolkit"
|
|
41
40
|
import BuildCommand from "./BuildCommand.js"
|
|
42
|
-
import DirectoryObject from "./DirectoryObject.js"
|
|
43
|
-
import FileObject from "./FileObject.js"
|
|
44
41
|
import LintCommand from "./LintCommand.js"
|
|
45
42
|
import ResolveCommand from "./ResolveCommand.js"
|
|
46
|
-
import Term from "./Term.js"
|
|
47
43
|
|
|
48
44
|
/**
|
|
49
45
|
* Main application entry point.
|
package/src/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file API entry point for @gesslar/sassy
|
|
3
|
+
*
|
|
4
|
+
* Exports classes and utilities for programmatic use by other npm packages.
|
|
5
|
+
*
|
|
6
|
+
* This allows other projects to import and use Sassy's functionality
|
|
7
|
+
* programmatically.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Import specific classes
|
|
11
|
+
* import { Theme, LintCommand, Compiler } from '@gesslar/sassy'
|
|
12
|
+
*
|
|
13
|
+
* // Import everything
|
|
14
|
+
* import * as Sassy from '@gesslar/sassy'
|
|
15
|
+
*
|
|
16
|
+
* // Create and use a Theme programmatically
|
|
17
|
+
* const theme = new Theme(fileObject)
|
|
18
|
+
* await theme.load('./my-theme.json5')
|
|
19
|
+
* await theme.build()
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// Core theme functionality
|
|
23
|
+
export {default as Theme} from "./Theme.js"
|
|
24
|
+
export {default as Compiler} from "./Compiler.js"
|
|
25
|
+
export {default as Evaluator} from "./Evaluator.js"
|
|
26
|
+
|
|
27
|
+
// Command classes for programmatic access
|
|
28
|
+
export {default as Command} from "./Command.js"
|
|
29
|
+
export {default as BuildCommand} from "./BuildCommand.js"
|
|
30
|
+
export {default as LintCommand} from "./LintCommand.js"
|
|
31
|
+
export {default as ResolveCommand} from "./ResolveCommand.js"
|
|
32
|
+
|
|
33
|
+
// Data handling and utilities
|
|
34
|
+
export {default as Session} from "./Session.js"
|
|
35
|
+
|
|
36
|
+
// Color utilities
|
|
37
|
+
export {default as Colour} from "./Colour.js"
|
|
38
|
+
|
|
39
|
+
// Note: CLI functionality remains in cli.js and is accessible via the 'sassy'
|
|
40
|
+
// command when installed globally or via npx
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command handler for building VS Code themes from source files.
|
|
3
|
+
* Handles compilation, watching for changes, and output generation.
|
|
4
|
+
*/
|
|
5
|
+
export default class BuildCommand extends Command {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new BuildCommand instance.
|
|
8
|
+
*
|
|
9
|
+
* @param {object} base - Base configuration object
|
|
10
|
+
* @param {string} base.cwd - Current working directory path
|
|
11
|
+
* @param {object} base.packageJson - Package.json configuration data
|
|
12
|
+
*/
|
|
13
|
+
constructor(base: {
|
|
14
|
+
cwd: string;
|
|
15
|
+
packageJson: object;
|
|
16
|
+
});
|
|
17
|
+
/** @type {EventEmitter} Internal event emitter for watch mode coordination */
|
|
18
|
+
emitter: EventEmitter;
|
|
19
|
+
/**
|
|
20
|
+
* Executes the build command for the provided theme files.
|
|
21
|
+
* Processes each file in parallel, optionally watching for changes.
|
|
22
|
+
*
|
|
23
|
+
* @param {string[]} fileNames - Array of theme file paths to process
|
|
24
|
+
* @param {object} options - Build options
|
|
25
|
+
* @param {boolean} [options.watch] - Enable watch mode for file changes
|
|
26
|
+
* @param {string} [options.output-dir] - Custom output directory path
|
|
27
|
+
* @param {boolean} [options.dry-run] - Print JSON to stdout without writing files
|
|
28
|
+
* @param {boolean} [options.silent] - Silent mode, only show errors or dry-run output
|
|
29
|
+
* @returns {Promise<void>} Resolves when all files are processed
|
|
30
|
+
* @throws {Error} When theme compilation fails
|
|
31
|
+
*/
|
|
32
|
+
execute(fileNames: string[], options: {
|
|
33
|
+
watch?: boolean;
|
|
34
|
+
output?: string;
|
|
35
|
+
dry?: boolean;
|
|
36
|
+
silent?: boolean;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
#private;
|
|
39
|
+
}
|
|
40
|
+
import Command from "./Command.js";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colour manipulation utility class providing static methods for colour operations.
|
|
3
|
+
* Handles hex colour parsing, alpha manipulation, mixing, and format conversions.
|
|
4
|
+
*/
|
|
5
|
+
export default class Colour {
|
|
6
|
+
/**
|
|
7
|
+
* Regular expression for matching long hex colour codes with optional alpha.
|
|
8
|
+
* Matches patterns like #ff0000 or #ff0000ff
|
|
9
|
+
*
|
|
10
|
+
* @type {RegExp}
|
|
11
|
+
*/
|
|
12
|
+
static longHex: RegExp;
|
|
13
|
+
/**
|
|
14
|
+
* Regular expression for matching short hex colour codes with optional alpha.
|
|
15
|
+
* Matches patterns like #f00 or #f00f
|
|
16
|
+
*
|
|
17
|
+
* @type {RegExp}
|
|
18
|
+
*/
|
|
19
|
+
static shortHex: RegExp;
|
|
20
|
+
/**
|
|
21
|
+
* Lightens or darkens a hex colour by a specified amount.
|
|
22
|
+
* Always uses OKLCH as the working color space for consistent perceptual results.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} hex - The hex colour code (e.g., "#ff0000" or "#f00")
|
|
25
|
+
* @param {number} amount - The amount to lighten (+) or darken (-) as a percentage
|
|
26
|
+
* @returns {string} The modified hex colour with preserved alpha
|
|
27
|
+
*/
|
|
28
|
+
static lightenOrDarken(hex: string, amount?: number): string;
|
|
29
|
+
/**
|
|
30
|
+
* Lightens or darkens a color using OKLCH as working space for consistent results.
|
|
31
|
+
* Preserves original color information from tokens when available.
|
|
32
|
+
*
|
|
33
|
+
* @param {ThemeToken|object|string} tokenOrColor - ThemeToken, Culori color object, or hex string
|
|
34
|
+
* @param {number} amount - The amount to lighten (+) or darken (-) as a percentage
|
|
35
|
+
* @returns {string} The modified hex colour
|
|
36
|
+
*/
|
|
37
|
+
static lightenOrDarkenWithToken(tokenOrColor: ThemeToken | object | string, amount?: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* Inverts a hex colour by flipping its lightness value.
|
|
40
|
+
* Preserves hue and saturation while inverting the lightness component.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} hex - The hex colour code to invert
|
|
43
|
+
* @returns {string} The inverted hex colour with preserved alpha
|
|
44
|
+
*/
|
|
45
|
+
static invert(hex: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Converts a hex alpha value to a decimal percentage.
|
|
48
|
+
* Takes a 2-digit hex alpha value and converts it to a percentage (0-100).
|
|
49
|
+
*
|
|
50
|
+
* @param {string} hex - The hex alpha value (e.g., "ff", "80")
|
|
51
|
+
* @returns {number} The alpha as a percentage rounded to 2 decimal places
|
|
52
|
+
*/
|
|
53
|
+
static hexAlphaToDecimal(hex: string): number;
|
|
54
|
+
/**
|
|
55
|
+
* Converts a decimal percentage to a hex alpha value.
|
|
56
|
+
* Takes a percentage (0-100) and converts it to a 2-digit hex alpha value.
|
|
57
|
+
*
|
|
58
|
+
* @param {number} dec - The alpha percentage (0-100)
|
|
59
|
+
* @returns {string} The hex alpha value (e.g., "ff", "80")
|
|
60
|
+
*/
|
|
61
|
+
static decimalAlphaToHex(dec: number): string;
|
|
62
|
+
static isHex(value: any): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Normalises a short hex colour code to a full 6-character format.
|
|
65
|
+
* Converts 3-character hex codes like "#f00" to "#ff0000".
|
|
66
|
+
*
|
|
67
|
+
* @param {string} code - The short hex colour code
|
|
68
|
+
* @returns {string} The normalized 6-character hex colour code
|
|
69
|
+
*/
|
|
70
|
+
static normaliseHex(code: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Parses a hex colour string and extracts colour and alpha components.
|
|
73
|
+
* Supports both short (#f00) and long (#ff0000) formats with optional alpha.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} hex - The hex colour string to parse
|
|
76
|
+
* @returns {object} Object containing colour and optional alpha information
|
|
77
|
+
* @throws {Sass} If the hex value is invalid or missing
|
|
78
|
+
*/
|
|
79
|
+
static parseHexColour(hex: string): object;
|
|
80
|
+
/**
|
|
81
|
+
* Sets the alpha transparency of a hex colour to a specific value.
|
|
82
|
+
* Replaces any existing alpha with the new value.
|
|
83
|
+
*
|
|
84
|
+
* @param {string} hex - The hex colour code
|
|
85
|
+
* @param {number} amount - The alpha value (0-1, where 0 is transparent and 1 is opaque)
|
|
86
|
+
* @returns {string} The hex colour with the new alpha value
|
|
87
|
+
*/
|
|
88
|
+
static setAlpha(hex: string, amount: number): string;
|
|
89
|
+
/**
|
|
90
|
+
* Adjusts the alpha transparency of a hex colour by a relative amount.
|
|
91
|
+
* Multiplies the current alpha by (1 + amount) and clamps the result.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} hex - The hex colour code
|
|
94
|
+
* @param {number} amount - The relative amount to adjust alpha (-1 to make transparent, positive to increase)
|
|
95
|
+
* @returns {string} The hex colour with adjusted alpha
|
|
96
|
+
*/
|
|
97
|
+
static addAlpha(hex: string, amount: number): string;
|
|
98
|
+
/**
|
|
99
|
+
* Removes alpha channel from a hex colour, returning only the solid colour.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} hex - The hex colour code with or without alpha
|
|
102
|
+
* @returns {string} The solid hex colour without alpha
|
|
103
|
+
*/
|
|
104
|
+
static solid(hex: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Mixes two hex colours together in a specified ratio.
|
|
107
|
+
* Blends both the colours and their alpha channels if present.
|
|
108
|
+
*
|
|
109
|
+
* @param {string} colourA - The first hex colour
|
|
110
|
+
* @param {string} colourB - The second hex colour
|
|
111
|
+
* @param {number} ratio - The mixing ratio as percentage (0-100, where 50 is equal mix)
|
|
112
|
+
* @returns {string} The mixed hex colour with blended alpha
|
|
113
|
+
*/
|
|
114
|
+
static mix(colourA: string, colourB: string, ratio?: number): string;
|
|
115
|
+
static getColourParser(name: any): Promise<any>;
|
|
116
|
+
/**
|
|
117
|
+
* Converts colour values from various formats to hex.
|
|
118
|
+
* Supports RGB, RGBA, HSL, HSLA, OKLCH, and OKLCHA colour modes, and MORE!
|
|
119
|
+
*
|
|
120
|
+
* @param {string} input - The colour expression
|
|
121
|
+
* @returns {string} The resulting hex colour
|
|
122
|
+
* @throws {Sass} If the wrong function or value is provided
|
|
123
|
+
*/
|
|
124
|
+
static toHex(input: string): string;
|
|
125
|
+
}
|
|
126
|
+
import ThemeToken from "./ThemeToken.js";
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { FileObject, DirectoryObject, Cache } from '@gesslar/toolkit';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for command-line interface commands.
|
|
4
|
+
* Provides common functionality for CLI option handling and file resolution.
|
|
5
|
+
*/
|
|
6
|
+
export default class Command {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new Command instance.
|
|
9
|
+
*
|
|
10
|
+
* @param {object} config - Configuration object
|
|
11
|
+
* @param {DirectoryObject} config.cwd - Current working directory object
|
|
12
|
+
* @param {object} config.packageJson - Package.json data
|
|
13
|
+
*/
|
|
14
|
+
constructor({ cwd, packageJson }: {
|
|
15
|
+
cwd: DirectoryObject;
|
|
16
|
+
packageJson: object;
|
|
17
|
+
});
|
|
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 {string[]} Array of option names
|
|
73
|
+
*/
|
|
74
|
+
getCliOptionNames(): 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 {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: 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 {object} 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: object): Promise<FileObject>;
|
|
134
|
+
#private;
|
|
135
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main compiler class for processing theme source files.
|
|
3
|
+
* Handles the complete compilation pipeline from source to VS Code theme output.
|
|
4
|
+
*/
|
|
5
|
+
export default class Compiler {
|
|
6
|
+
/**
|
|
7
|
+
* Compiles a theme source file into a VS Code colour theme.
|
|
8
|
+
* Processes configuration, variables, imports, and theme definitions.
|
|
9
|
+
*
|
|
10
|
+
* @param {Theme} theme - The file object containing source data and metadata
|
|
11
|
+
* @returns {Promise<void>} Resolves when compilation is complete
|
|
12
|
+
*/
|
|
13
|
+
compile(theme: Theme): Promise<void>;
|
|
14
|
+
#private;
|
|
15
|
+
}
|
|
16
|
+
import Theme from "./Theme.js";
|