@gesslar/sassy 0.21.1 → 0.21.3
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 +10 -5
- package/src/BuildCommand.js +1 -2
- package/src/Colour.js +1 -3
- package/src/Command.js +1 -4
- 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/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,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gesslar/sassy",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.3",
|
|
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
10
|
"bin": "src/cli.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./src/index.js",
|
|
13
|
+
"./cli": "./src/cli.js"
|
|
14
|
+
},
|
|
11
15
|
"files": [
|
|
12
16
|
"src/",
|
|
13
17
|
"UNLICENSE.txt"
|
|
@@ -43,6 +47,7 @@
|
|
|
43
47
|
],
|
|
44
48
|
"dependencies": {
|
|
45
49
|
"@gesslar/colours": "^0.0.1",
|
|
50
|
+
"@gesslar/toolkit": "^0.0.3",
|
|
46
51
|
"chokidar": "^4.0.3",
|
|
47
52
|
"color-support": "^1.1.3",
|
|
48
53
|
"commander": "^14.0.1",
|
|
@@ -52,13 +57,13 @@
|
|
|
52
57
|
"yaml": "^2.8.1"
|
|
53
58
|
},
|
|
54
59
|
"devDependencies": {
|
|
55
|
-
"@stylistic/eslint-plugin": "^5.
|
|
60
|
+
"@stylistic/eslint-plugin": "^5.4.0",
|
|
56
61
|
"@types/vscode": "^1.104.0",
|
|
57
62
|
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
58
63
|
"@typescript-eslint/parser": "^8.44.0",
|
|
59
64
|
"esbuild": "^0.25.10",
|
|
60
|
-
"eslint": "^9.
|
|
61
|
-
"eslint-plugin-jsdoc": "^
|
|
65
|
+
"eslint": "^9.36.0",
|
|
66
|
+
"eslint-plugin-jsdoc": "^60.1.0",
|
|
62
67
|
"typescript": "^5.9.2"
|
|
63
68
|
}
|
|
64
69
|
}
|
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.
|
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
|
package/src/Cache.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import Sass from "./Sass.js"
|
|
2
|
-
import File from "./File.js"
|
|
3
|
-
import FileObject from "./FileObject.js"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* File system cache for theme compilation data with automatic invalidation.
|
|
7
|
-
* Provides intelligent caching of parsed JSON5/YAML files with mtime-based
|
|
8
|
-
* cache invalidation to optimize parallel theme compilation performance.
|
|
9
|
-
*
|
|
10
|
-
* The cache eliminates redundant file reads and parsing when multiple themes
|
|
11
|
-
* import the same dependency files, while ensuring data freshness through
|
|
12
|
-
* modification time checking.
|
|
13
|
-
*/
|
|
14
|
-
export default class Cache {
|
|
15
|
-
/** @type {Map<string, Date>} Map of file paths to last modification times */
|
|
16
|
-
#modifiedTimes = new Map()
|
|
17
|
-
/** @type {Map<string, object>} Map of file paths to parsed file data */
|
|
18
|
-
#dataCache = new Map()
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Removes cached data for a specific file from both time and data maps.
|
|
22
|
-
* Used when files are modified or when cache consistency needs to be
|
|
23
|
-
* maintained.
|
|
24
|
-
*
|
|
25
|
-
* @private
|
|
26
|
-
* @param {FileObject} file - The file object to remove from cache
|
|
27
|
-
* @returns {void}
|
|
28
|
-
*/
|
|
29
|
-
#cleanup(file) {
|
|
30
|
-
this.#modifiedTimes.delete(file.path)
|
|
31
|
-
this.#dataCache.delete(file.path)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Loads and caches parsed file data with automatic invalidation based on
|
|
36
|
-
* modification time.
|
|
37
|
-
*
|
|
38
|
-
* Implements a sophisticated caching strategy that checks file modification
|
|
39
|
-
* times to determine whether cached data is still valid, ensuring data
|
|
40
|
-
* freshness while optimizing performance for repeated file access during
|
|
41
|
-
* parallel theme compilation.
|
|
42
|
-
*
|
|
43
|
-
* @param {FileObject} fileObject - The file object to load and cache
|
|
44
|
-
* @returns {Promise<object>} The parsed file data (JSON5 or YAML)
|
|
45
|
-
* @throws {Sass} If the file cannot be found or accessed
|
|
46
|
-
*/
|
|
47
|
-
async loadCachedData(fileObject) {
|
|
48
|
-
const lastModified = await File.fileModified(fileObject)
|
|
49
|
-
|
|
50
|
-
if(lastModified === null)
|
|
51
|
-
throw Sass.new(`Unable to find file '${fileObject.path}'`)
|
|
52
|
-
|
|
53
|
-
if(this.#modifiedTimes.has(fileObject.path)) {
|
|
54
|
-
const lastCached = this.#modifiedTimes.get(fileObject.path)
|
|
55
|
-
|
|
56
|
-
if(lastModified > lastCached) {
|
|
57
|
-
this.#cleanup(fileObject)
|
|
58
|
-
} else {
|
|
59
|
-
if(!(this.#dataCache.has(fileObject.path)))
|
|
60
|
-
this.#cleanup(fileObject)
|
|
61
|
-
else {
|
|
62
|
-
return this.#dataCache.get(fileObject.path)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const data = await File.loadDataFile(fileObject)
|
|
68
|
-
|
|
69
|
-
this.#modifiedTimes.set(fileObject.path, lastModified)
|
|
70
|
-
this.#dataCache.set(fileObject.path, data)
|
|
71
|
-
|
|
72
|
-
return data
|
|
73
|
-
}
|
|
74
|
-
}
|