@gesslar/sassy 1.1.0 → 1.3.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 CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "gesslar",
6
6
  "url": "https://gesslar.dev"
7
7
  },
8
- "version": "1.1.0",
8
+ "version": "1.3.0",
9
9
  "license": "Unlicense",
10
10
  "homepage": "https://github.com/gesslar/sassy#readme",
11
11
  "repository": {
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@gesslar/colours": "^0.8.0",
47
- "@gesslar/toolkit": "^3.29.0",
47
+ "@gesslar/toolkit": "^3.30.0",
48
48
  "chokidar": "^5.0.0",
49
49
  "color-support": "^1.1.3",
50
50
  "commander": "^14.0.2",
@@ -48,39 +48,33 @@ export default class BuildCommand extends Command {
48
48
  return await Util.asyncEmit(this.emitter, event, ...args)
49
49
  }
50
50
 
51
+ /**
52
+ * @typedef {object} BuildCommandOptions
53
+ * @property {boolean} [watch] - Enable watch mode for file changes
54
+ * @property {string} [outputDir] - Custom output directory path
55
+ * @property {boolean} [dryRun] - Print JSON to stdout without writing files
56
+ * @property {boolean} [silent] - Silent mode, only show errors or dry-run output
57
+ */
58
+
51
59
  /**
52
60
  * Executes the build command for the provided theme files.
53
61
  * Processes each file in parallel, optionally watching for changes.
54
62
  *
55
- * @param {string[]} fileNames - Array of theme file paths to process
56
- * @param {object} options - Build options
57
- * @param {boolean} [options.watch] - Enable watch mode for file changes
58
- * @param {string} [options.outputDir] - Custom output directory path
59
- * @param {boolean} [options.dryRun] - Print JSON to stdout without writing files
60
- * @param {boolean} [options.silent] - Silent mode, only show errors or dry-run output
63
+ * @param {Array<string>} fileNames - Array of theme file paths to process
64
+ * @param {BuildCommandOptions} options - {@link BuildCommandOptions}
61
65
  * @returns {Promise<void>} Resolves when all files are processed
62
66
  * @throws {Error} When theme compilation fails
63
67
  */
64
68
  async execute(fileNames, options) {
65
-
66
- /**
67
- * @typedef {object} BuildCommandOptions
68
- * @property {boolean} [watch] Enable watch mode for file changes
69
- * @property {string} [outputDir] Custom output directory path
70
- * @property {boolean} [dryRun] Print JSON to stdout without writing files
71
- * @property {boolean} [silent] Silent mode, only show errors or dry-run output
72
- */
73
69
  const cwd = this.getCwd()
74
70
 
75
71
  if(options.watch) {
76
72
  options.watch && this.#initialiseInputHandler()
77
73
 
78
- this.emitter.on("quit", async() =>
79
- await this.#handleQuit())
80
-
81
- this.emitter.on("building", async() => await this.#startBuilding())
74
+ this.emitter.on("quit", async() => await this.#handleQuit())
75
+ this.emitter.on("building", () => this.#startBuilding())
82
76
  this.emitter.on("finishedBuilding", () => this.#finishBuilding())
83
- this.emitter.on("erasePrompt", async() => await this.#erasePrompt())
77
+ this.emitter.on("erasePrompt", () => this.#erasePrompt())
84
78
  this.emitter.on("printPrompt", () => this.#printPrompt())
85
79
  }
86
80
 
@@ -97,16 +91,6 @@ export default class BuildCommand extends Command {
97
91
  if(Promised.hasRejected(sessionResults))
98
92
  Promised.throw("Creating sessions.", sessionResults)
99
93
 
100
- // if(sessionResults.some(theme => theme.status === "rejected")) {
101
- // const rejected = sessionResults.filter(result => result.status === "rejected")
102
-
103
- // rejected.forEach(item => {
104
- // const sassError = Sass.new("Creating session for theme file.", item.reason)
105
- // sassError.report(options.nerd)
106
- // })
107
- // process.exit(1)
108
- // }
109
-
110
94
  const sessions = Promised.values(sessionResults)
111
95
  const firstRun = await Promised.settle(sessions.map(
112
96
  async session => await session.run()))
@@ -123,7 +107,7 @@ export default class BuildCommand extends Command {
123
107
  async #handleQuit() {
124
108
  await this.asyncEmit("closeSession")
125
109
 
126
- await Term.directWrite("\x1b[?25h")
110
+ Term.write("\x1b[?25h")
127
111
 
128
112
  Term.info()
129
113
  Term.info("Exiting.")
@@ -160,16 +144,16 @@ export default class BuildCommand extends Command {
160
144
  }
161
145
  })
162
146
 
163
- await Term.directWrite("\x1b[?25l")
147
+ Term.write("\x1b[?25l")
164
148
  }
165
149
 
166
- async #printPrompt() {
150
+ #printPrompt() {
167
151
  if(this.#hasPrompt && this.#building > 0)
168
152
  return
169
153
 
170
- await Term.directWrite("\n")
154
+ Term.write("\n")
171
155
 
172
- await Term.directWrite(Term.terminalMessage([
156
+ Term.write(Term.terminalMessage([
173
157
  ["info", "F5", ["<",">"]],
174
158
  "rebuild all,",
175
159
  ["info", "Ctrl-C", ["<",">"]],
@@ -179,17 +163,18 @@ export default class BuildCommand extends Command {
179
163
  this.#hasPrompt = true
180
164
  }
181
165
 
182
- async #erasePrompt() {
166
+ #erasePrompt() {
183
167
  if(!this.#hasPrompt)
184
168
  return
185
169
 
186
170
  this.#hasPrompt = false
187
171
 
188
- await Term.clearLines(1)
172
+ Term.clearLine().moveStart()
189
173
  }
190
174
 
191
- async #startBuilding() {
192
- await this.#erasePrompt()
175
+ #startBuilding() {
176
+ this.#erasePrompt()
177
+
193
178
  this.#building++
194
179
  }
195
180
 
package/src/Command.js CHANGED
@@ -115,7 +115,7 @@ export default class Command {
115
115
  /**
116
116
  * Gets the array of CLI option names.
117
117
  *
118
- * @returns {string[]} Array of option names
118
+ * @returns {Array<string>} Array of option names
119
119
  */
120
120
  getCliOptionNames() {
121
121
  return this.#optionNames
@@ -192,7 +192,7 @@ export default class Command {
192
192
  * Adds a single CLI option to the command.
193
193
  *
194
194
  * @param {string} name - The option name
195
- * @param {string[]} options - Array containing option flag and description
195
+ * @param {Array<string>} options - Array containing option flag and description
196
196
  * @param {boolean} preserve - Whether to preserve this option name in the list
197
197
  * @returns {Promise<this>} Returns this instance for method chaining
198
198
  */
package/src/Compiler.js CHANGED
@@ -222,7 +222,7 @@ export default class Compiler {
222
222
  * evaluation.
223
223
  *
224
224
  * @param {object} work - The object to decompose
225
- * @param {string[]} path - Current path array for nested properties
225
+ * @param {Array<string>} path - Current path array for nested properties
226
226
  * @returns {Array<object>} Array of decomposed object entries with path information
227
227
  */
228
228
  #decomposeObject(work, path = []) {
package/src/Session.js CHANGED
@@ -6,6 +6,7 @@ import {Promised, Sass, Term, Util} from "@gesslar/toolkit"
6
6
  /**
7
7
  * @import {Command} from "./Command.js"
8
8
  * @import {Theme} from "./Theme.js"
9
+ * @import {FSWatcher} from "chokidar"
9
10
  */
10
11
 
11
12
  /**
@@ -58,7 +59,7 @@ export default class Session {
58
59
  /**
59
60
  * Active file system watcher for theme dependencies.
60
61
  *
61
- * @type {import("chokidar").FSWatcher|null}
62
+ * @type {FSWatcher}
62
63
  * @private
63
64
  */
64
65
  #watcher = null
@@ -383,7 +384,7 @@ export default class Session {
383
384
 
384
385
  const changedFile = Array.from(this.#theme.getDependencies()).find(
385
386
  dep => {
386
- const depPath = dep.getSourceFile().real.path
387
+ const depPath = dep.getSourceFile().path
387
388
  const normalizedDepPath = path.resolve(depPath)
388
389
 
389
390
  return normalizedDepPath === normalizedChanged
@@ -500,7 +501,7 @@ export default class Session {
500
501
  const dependencies = Array.from(this.#theme
501
502
  .getDependencies())
502
503
  .map(d => {
503
- const filePath = d.getSourceFile().real.path
504
+ const filePath = d.getSourceFile().path
504
505
 
505
506
  // Normalize to absolute path for chokidar
506
507
  return path.resolve(filePath)
package/src/cli.js CHANGED
@@ -16,7 +16,7 @@
16
16
  * sourceFile: FileObject // entry theme file
17
17
  * source: object // raw parsed data (must contain `config`)
18
18
  * output: object // final theme JSON object
19
- * dependencies: FileObject[] // secondary sources discovered during compile
19
+ * dependencies: Array<FileObject> // secondary sources discovered during compile
20
20
  * lookup: object // variable lookup data for compilation
21
21
  * breadcrumbs: Map // variable resolution tracking
22
22
  * }