@gesslar/toolkit 0.8.0 → 1.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.
Files changed (49) hide show
  1. package/README.md +35 -0
  2. package/package.json +20 -8
  3. package/src/browser/index.js +10 -0
  4. package/src/browser/lib/Sass.js +168 -0
  5. package/src/browser/lib/Tantrum.js +115 -0
  6. package/src/browser/lib/Util.js +257 -0
  7. package/src/browser/lib/Valid.js +76 -0
  8. package/src/index.js +14 -12
  9. package/src/lib/Cache.js +2 -3
  10. package/src/lib/Contract.js +3 -4
  11. package/src/lib/FS.js +15 -20
  12. package/src/lib/FileObject.js +1 -1
  13. package/src/lib/Glog.js +2 -2
  14. package/src/lib/Sass.js +2 -91
  15. package/src/lib/Schemer.js +2 -2
  16. package/src/lib/Tantrum.js +3 -70
  17. package/src/lib/Terms.js +2 -3
  18. package/src/lib/Util.js +2 -252
  19. package/src/lib/Valid.js +17 -20
  20. package/src/types/browser/index.d.ts +8 -0
  21. package/src/types/browser/index.d.ts.map +1 -0
  22. package/src/types/browser/lib/Collection.d.ts +246 -0
  23. package/src/types/browser/lib/Collection.d.ts.map +1 -0
  24. package/src/types/browser/lib/Data.d.ts +206 -0
  25. package/src/types/browser/lib/Data.d.ts.map +1 -0
  26. package/src/types/browser/lib/Sass.d.ts +62 -0
  27. package/src/types/browser/lib/Sass.d.ts.map +1 -0
  28. package/src/types/browser/lib/Tantrum.d.ts +51 -0
  29. package/src/types/browser/lib/Tantrum.d.ts.map +1 -0
  30. package/src/types/browser/lib/TypeSpec.d.ts +92 -0
  31. package/src/types/browser/lib/TypeSpec.d.ts.map +1 -0
  32. package/src/types/browser/lib/Util.d.ts +129 -0
  33. package/src/types/browser/lib/Util.d.ts.map +1 -0
  34. package/src/types/browser/lib/Valid.d.ts +33 -0
  35. package/src/types/browser/lib/Valid.d.ts.map +1 -0
  36. package/src/types/index.d.ts +10 -10
  37. package/src/types/lib/FS.d.ts +2 -2
  38. package/src/types/lib/FS.d.ts.map +1 -1
  39. package/src/types/lib/Sass.d.ts +2 -55
  40. package/src/types/lib/Sass.d.ts.map +1 -1
  41. package/src/types/lib/Tantrum.d.ts +3 -44
  42. package/src/types/lib/Tantrum.d.ts.map +1 -1
  43. package/src/types/lib/Util.d.ts +2 -123
  44. package/src/types/lib/Util.d.ts.map +1 -1
  45. package/src/types/lib/Valid.d.ts +1 -1
  46. package/src/types/lib/Valid.d.ts.map +1 -1
  47. /package/src/{lib → browser/lib}/Collection.js +0 -0
  48. /package/src/{lib → browser/lib}/Data.js +0 -0
  49. /package/src/{lib → browser/lib}/TypeSpec.js +0 -0
@@ -2,61 +2,8 @@
2
2
  * Custom error class for toolkit errors.
3
3
  * Provides error chaining, trace management, and formatted error reporting.
4
4
  */
5
- export default class Sass extends Error {
6
- /**
7
- * Creates an Sass from an existing Error object with additional
8
- * trace message.
9
- *
10
- * @param {Error} error - The original error object
11
- * @param {string} message - Additional trace message to add
12
- * @returns {Sass} New Sass instance with trace from the original error
13
- * @throws {Sass} If the first parameter is not an Error instance
14
- */
15
- static from(error: Error, message: string): Sass;
16
- /**
17
- * Factory method to create or enhance Sass instances.
18
- * If error parameter is provided, enhances existing Sass or wraps
19
- * other errors. Otherwise creates a new Sass instance.
20
- *
21
- * @param {string} message - The error message
22
- * @param {Error|Sass|Tantrum} [error] - Optional existing error to wrap or enhance
23
- * @returns {Sass} New or enhanced Sass instance
24
- */
25
- static "new"(message: string, error?: Error | Sass | Tantrum): Sass;
26
- /**
27
- * Creates a new Sass instance.
28
- *
29
- * @param {string} message - The error message
30
- * @param {...unknown} [arg] - Additional arguments passed to parent Error constructor
31
- */
32
- constructor(message: string, ...arg?: unknown[]);
33
- /**
34
- * Adds a message to the beginning of the trace array.
35
- *
36
- * @param {string} message - The trace message to add
37
- */
38
- set trace(message: string);
39
- /**
40
- * Gets the error trace array.
41
- *
42
- * @returns {Array<string>} Array of trace messages
43
- */
44
- get trace(): Array<string>;
45
- /**
46
- * Adds a trace message and returns this instance for chaining.
47
- *
48
- * @param {string} message - The trace message to add
49
- * @returns {this} This Sass instance for method chaining
50
- */
51
- addTrace(message: string): this;
52
- /**
53
- * Reports the error to the terminal with formatted output.
54
- * Optionally includes detailed stack trace information.
55
- *
56
- * @param {boolean} [nerdMode] - Whether to include detailed stack trace
57
- */
58
- report(nerdMode?: boolean): void;
5
+ export default class Sass extends BrowserSass {
59
6
  #private;
60
7
  }
61
- import Tantrum from "./Tantrum.js";
8
+ import { Sass as BrowserSass } from "../browser/index.js";
62
9
  //# sourceMappingURL=Sass.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Sass.d.ts","sourceRoot":"","sources":["../../lib/Sass.js"],"names":[],"mappings":"AAgBA;;;GAGG;AACH;IA2GE;;;;;;;;OAQG;IACH,mBALW,KAAK,WACL,MAAM,GACJ,IAAI,CAWhB;IAED;;;;;;;;OAQG;IACH,sBAJW,MAAM,UACN,KAAK,GAAC,IAAI,GAAC,OAAO,GAChB,IAAI,CAchB;IAhJD;;;;;OAKG;IACH,qBAHW,MAAM,WACH,OAAO,EAAA,EAMpB;IAWD;;;;OAIG;IACH,mBAFW,MAAM,EAIhB;IAhBD;;;;OAIG;IACH,aAFa,KAAK,CAAC,MAAM,CAAC,CAIzB;IAWD;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,IAAI,CAShB;IAED;;;;;OAKG;IACH,kBAFW,OAAO,QAqBjB;;CA2EF;oBA1JmB,cAAc"}
1
+ {"version":3,"file":"Sass.d.ts","sourceRoot":"","sources":["../../lib/Sass.js"],"names":[],"mappings":"AAgBA;;;GAGG;AACH;;CA2DC;oCAlEiC,qBAAqB"}
@@ -2,49 +2,8 @@
2
2
  * Custom aggregate error class that extends AggregateError.
3
3
  * Automatically wraps plain errors in Sass instances for consistent reporting.
4
4
  */
5
- export default class Tantrum extends AggregateError {
6
- /**
7
- * Factory method to create a Tantrum instance.
8
- *
9
- * @param {string} message - The aggregate error message
10
- * @param {Array<Error|Sass>} errors - Array of errors to aggregate
11
- * @returns {Tantrum} New Tantrum instance
12
- */
13
- static "new"(message: string, errors?: Array<Error | Sass>): Tantrum;
14
- /**
15
- * Creates a new Tantrum instance.
16
- *
17
- * @param {string} message - The aggregate error message
18
- * @param {Array<Error|Sass>} errors - Array of errors to aggregate
19
- */
20
- constructor(message: string, errors?: Array<Error | Sass>);
21
- /**
22
- * Adds a trace message and returns this instance for chaining.
23
- *
24
- * @param {string} message - The trace message to add
25
- * @param {Error|Sass} [_error] - Optional error (currently unused, reserved for future use)
26
- * @returns {this} This Tantrum instance for method chaining
27
- */
28
- addTrace(message: string, _error?: Error | Sass): this;
29
- /**
30
- * Adds a message to the beginning of the trace array.
31
- *
32
- * @param {string} message - The trace message to add
33
- */
34
- set trace(message: string);
35
- /**
36
- * Gets the error trace array.
37
- *
38
- * @returns {Array<string>} Array of trace messages
39
- */
40
- get trace(): Array<string>;
41
- /**
42
- * Reports all aggregated errors to the terminal with formatted output.
43
- *
44
- * @param {boolean} [nerdMode] - Whether to include detailed stack traces
45
- */
46
- report(nerdMode?: boolean): void;
47
- #private;
5
+ export default class Tantrum extends BrowserTantrum {
6
+ constructor(message: any, errors?: any[]);
48
7
  }
49
- import Sass from "./Sass.js";
8
+ import { Tantrum as BrowserTantrum } from "../browser/index.js";
50
9
  //# sourceMappingURL=Tantrum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tantrum.d.ts","sourceRoot":"","sources":["../../lib/Tantrum.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IAgFE;;;;;;OAMG;IACH,sBAJW,MAAM,WACN,KAAK,CAAC,KAAK,GAAC,IAAI,CAAC,GACf,OAAO,CAOnB;IAzFD;;;;;OAKG;IACH,qBAHW,MAAM,WACN,KAAK,CAAC,KAAK,GAAC,IAAI,CAAC,EAgB3B;IAED;;;;;;OAMG;IACH,kBAJW,MAAM,WACN,KAAK,GAAC,IAAI,GACR,IAAI,CAShB;IAWD;;;;OAIG;IACH,mBAFW,MAAM,EAIhB;IAhBD;;;;OAIG;IACH,aAFa,KAAK,CAAC,MAAM,CAAC,CAIzB;IAWD;;;;OAIG;IACH,kBAFW,OAAO,QAgBjB;;CAeF;iBApGgB,WAAW"}
1
+ {"version":3,"file":"Tantrum.d.ts","sourceRoot":"","sources":["../../lib/Tantrum.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH;IACE,0CAEC;CAsBF;0CAjCuC,qBAAqB"}
@@ -2,43 +2,7 @@
2
2
  * Utility class providing common helper functions for string manipulation,
3
3
  * timing, hashing, and option parsing.
4
4
  */
5
- export default class Util {
6
- /**
7
- * Capitalizes the first letter of a string.
8
- *
9
- * @param {string} text - The text to capitalize
10
- * @returns {string} Text with first letter capitalized
11
- */
12
- static capitalize(text: string): string;
13
- /**
14
- * Measure wall-clock time for an async function.
15
- *
16
- * @template T
17
- * @param {() => Promise<T>} fn - Thunk returning a promise.
18
- * @returns {Promise<{result: T, cost: number}>} Object containing result and elapsed ms (number, 1 decimal).
19
- */
20
- static time<T>(fn: () => Promise<T>): Promise<{
21
- result: T;
22
- cost: number;
23
- }>;
24
- /**
25
- * Right-align a string inside a fixed width (left pad with spaces).
26
- * If the string exceeds width it is returned unchanged.
27
- *
28
- * @param {string|number} text - Text to align.
29
- * @param {number} width - Target field width (default 80).
30
- * @returns {string} Padded string.
31
- */
32
- static rightAlignText(text: string | number, width?: number): string;
33
- /**
34
- * Centre-align a string inside a fixed width (pad with spaces on left).
35
- * If the string exceeds width it is returned unchanged.
36
- *
37
- * @param {string|number} text - Text to align.
38
- * @param {number} width - Target field width (default 80).
39
- * @returns {string} Padded string with text centred.
40
- */
41
- static centreAlignText(text: string | number, width?: number): string;
5
+ export default class Util extends BrowserUtil {
42
6
  /**
43
7
  * Compute sha256 hash (hex) of the provided string.
44
8
  *
@@ -71,73 +35,6 @@ export default class Util {
71
35
  * @returns {Array<string>} Array of canonical option names (long preferred, short if no long present).
72
36
  */
73
37
  static generateOptionNames(object: object): Array<string>;
74
- /**
75
- * Asynchronously awaits all promises in parallel.
76
- * Wrapper around Promise.all for consistency with other utility methods.
77
- *
78
- * @param {Array<Promise<unknown>>} promises - Array of promises to await
79
- * @returns {Promise<Array<unknown>>} Results of all promises
80
- */
81
- static awaitAll(promises: Array<Promise<unknown>>): Promise<Array<unknown>>;
82
- /**
83
- * Settles all promises (both fulfilled and rejected) in parallel.
84
- * Wrapper around Promise.allSettled for consistency with other utility methods.
85
- *
86
- * @param {Array<Promise<unknown>>} promises - Array of promises to settle
87
- * @returns {Promise<Array<object>>} Results of all settled promises with status and value/reason
88
- */
89
- static settleAll(promises: Array<Promise<unknown>>): Promise<Array<object>>;
90
- /**
91
- * Checks if any result in the settled promise array is rejected.
92
- *
93
- * @param {Array<object>} result - Array of settled promise results.
94
- * @returns {boolean} True if any result is rejected, false otherwise.
95
- */
96
- static anyRejected(result: Array<object>): boolean;
97
- /**
98
- * Filters and returns all rejected results from a settled promise array.
99
- *
100
- * @param {Array<object>} result - Array of settled promise results.
101
- * @returns {Array<object>} Array of rejected results.
102
- */
103
- static settledAndRejected(result: Array<object>): Array<object>;
104
- /**
105
- * Extracts the rejection reasons from an array of rejected promise results.
106
- *
107
- * @param {Array<object>} rejected - Array of rejected results.
108
- * @returns {Array<unknown>} Array of rejection reasons.
109
- */
110
- static rejectedReasons(rejected: Array<object>): Array<unknown>;
111
- /**
112
- * Throws a Sass error containing all rejection reasons from settled promises.
113
- *
114
- * @param {string} [_message] - Optional error message. Defaults to "GIGO"
115
- * @param {Array<object>} rejected - Array of rejected results.
116
- * @throws {Error} Throws a Sass error with rejection reasons.
117
- */
118
- static throwRejected(_message?: string, rejected: Array<object>): void;
119
- /**
120
- * Filters and returns all fulfilled results from a settled promise array.
121
- *
122
- * @param {Array<object>} result - Array of settled promise results.
123
- * @returns {Array<object>} Array of fulfilled results.
124
- */
125
- static settledAndFulfilled(result: Array<object>): Array<object>;
126
- /**
127
- * Extracts the values from all fulfilled results in a settled promise array.
128
- *
129
- * @param {Array<object>} result - Array of settled promise results.
130
- * @returns {Array<unknown>} Array of fulfilled values.
131
- */
132
- static fulfilledValues(result: Array<object>): Array<unknown>;
133
- /**
134
- * Returns the first promise to resolve or reject from an array of promises.
135
- * Wrapper around Promise.race for consistency with other utility methods.
136
- *
137
- * @param {Array<Promise<unknown>>} promises - Array of promises to race
138
- * @returns {Promise<unknown>} Result of the first settled promise
139
- */
140
- static race(promises: Array<Promise<unknown>>): Promise<unknown>;
141
38
  /**
142
39
  * Private method that performs the actual async emission logic.
143
40
  * Handles listener execution, error aggregation, and result processing.
@@ -174,25 +71,7 @@ export default class Util {
174
71
  * @returns {Promise<void>} Resolves when all listeners have completed, but no grapes.
175
72
  */
176
73
  static asyncEmitQuack(emitter: object, event: string, ...args: unknown[]): Promise<void>;
177
- /**
178
- * Determine the Levenshtein distance between two string values
179
- *
180
- * @param {string} a The first value for comparison.
181
- * @param {string} b The second value for comparison.
182
- * @returns {number} The Levenshtein distance
183
- */
184
- static levenshteinDistance(a: string, b: string): number;
185
- /**
186
- * Determine the closest match between a string and allowed values
187
- * from the Levenshtein distance.
188
- *
189
- * @param {string} input The input string to resolve
190
- * @param {Array<string>} allowedValues The values which are permitted
191
- * @param {number} [threshold] Max edit distance for a "close match"
192
- * @returns {string} Suggested, probable match.
193
- */
194
- static findClosestMatch(input: string, allowedValues: Array<string>, threshold?: number): string;
195
- static regexify(input: any, trim?: boolean, flags?: any[]): RegExp;
196
74
  }
75
+ import { Util as BrowserUtil } from "../browser/index.js";
197
76
  import { EventEmitter } from "node:events";
198
77
  //# sourceMappingURL=Util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../lib/Util.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACE;;;;;OAKG;IACH,wBAHW,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;;OAMG;IACH,YAJa,CAAC,MACH,MAAM,OAAO,CAAC,CAAC,CAAC,GACd,OAAO,CAAC;QAAC,MAAM,EAA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QG;IACH,+CALW,MAAM,SACN,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAmBzB;IAED;;;;;;;;;;;;OAYG;IACH,0BALW,YAAY,SACZ,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAqBzB;IAED;;;;;;;;;;OAUG;IACH,+BALW,MAAM,SACN,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAyBzB;IAED;;;;;;OAMG;IACH,8BAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAsBlB;IAED;;;;;;;;OAQG;IACH,+BALW,MAAM,iBACN,KAAK,CAAC,MAAM,CAAC,cACb,MAAM,GACJ,MAAM,CAwBlB;IAED,mEAiBC;CACF;6BAlZ0B,aAAa"}
1
+ {"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../lib/Util.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IACE;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,mCAHW,MAAM,GACJ,KAAK,CAAC,MAAM,CAAC,CAazB;IAED;;;;;;;;OAQG;IACH,+CALW,MAAM,SACN,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAmBzB;IAED;;;;;;;;;;;;OAYG;IACH,0BALW,YAAY,SACZ,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAqBzB;IAED;;;;;;;;;;OAUG;IACH,+BALW,MAAM,SACN,MAAM,WACH,OAAO,EAAA,GACR,OAAO,CAAC,IAAI,CAAC,CAyBzB;CACF;oCAvJiC,qBAAqB;6BAF5B,aAAa"}
@@ -2,6 +2,7 @@
2
2
  * Validation utility class providing type checking and assertion methods.
3
3
  */
4
4
  export default class Valid {
5
+ static "__#private@#restrictedProto": string[];
5
6
  /**
6
7
  * Validates a value against a type. Uses Data.isType.
7
8
  *
@@ -20,7 +21,6 @@ export default class Valid {
20
21
  * met (optional)
21
22
  */
22
23
  static assert(condition: boolean, message: string, arg?: number): void;
23
- static "__#private@#restrictedProto": string[];
24
24
  /**
25
25
  * Protects against prototype pollution by checking keys for dangerous property names.
26
26
  * Throws if any restricted prototype properties are found in the keys array.
@@ -1 +1 @@
1
- {"version":3,"file":"Valid.d.ts","sourceRoot":"","sources":["../../lib/Valid.js"],"names":[],"mappings":"AAaA;;GAEG;AACH;IACE;;;;;;OAMG;IACH,mBAJW,OAAO,QACP,MAAM,YACN,MAAM,QAQhB;IAED;;;;;;;;OAQG;IACH,yBANW,OAAO,WACP,MAAM,QAEN,MAAM,QAmBhB;IAED,+CAAmE;IAEnE;;;;;;OAMG;IACH,0CAHW,KAAK,CAAC,MAAM,CAAC,QAYvB;CACF"}
1
+ {"version":3,"file":"Valid.d.ts","sourceRoot":"","sources":["../../lib/Valid.js"],"names":[],"mappings":"AAWA;;GAEG;AACH;IACE,+CAAmE;IAEnE;;;;;;OAMG;IACH,mBAJW,OAAO,QACP,MAAM,YACN,MAAM,QAQhB;IAED;;;;;;;;OAQG;IACH,yBANW,OAAO,WACP,MAAM,QAEN,MAAM,QAkBhB;IAED;;;;;;OAMG;IACH,0CAHW,KAAK,CAAC,MAAM,CAAC,QAYvB;CACF"}
File without changes
File without changes
File without changes