@gesslar/toolkit 3.14.2 → 3.16.1

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": "3.14.2",
8
+ "version": "3.16.1",
9
9
  "license": "Unlicense",
10
10
  "homepage": "https://github.com/gesslar/toolkit#readme",
11
11
  "repository": {
@@ -52,7 +52,7 @@
52
52
  "node": ">=22"
53
53
  },
54
54
  "dependencies": {
55
- "@gesslar/colours": "^0.7.1",
55
+ "@gesslar/colours": "^0.8.0",
56
56
  "ajv": "^8.17.1",
57
57
  "json5": "^2.2.3",
58
58
  "yaml": "^2.8.2"
@@ -68,7 +68,7 @@
68
68
  "lint": "eslint src/",
69
69
  "lint:fix": "eslint src/ --fix",
70
70
  "submit": "pnpm publish --access public --//registry.npmjs.org/:_authToken=\"${NPM_ACCESS_TOKEN}\"",
71
- "update": "pnpm up --latest --recursive",
71
+ "update": "pnpm self-update && pnpx npm-check-updates -u && pnpm install",
72
72
  "test": "node --test tests/**/*.test.js",
73
73
  "test:coverage": "node --experimental-config-file=node.config.json --experimental-test-coverage --test-timeout=3000 --test tests/**/*.test.js",
74
74
  "test:node": "node --test tests/node/*.test.js",
@@ -30,6 +30,7 @@ export const loggerColours = {
30
30
  info: "{F036}", // Medium Spring Green
31
31
  warn: "{F214}", // Orange1
32
32
  error: "{F196}", // Red1
33
+ success: "{F046}", // Green (Bright Green)
33
34
  reset: "{/}", // Reset
34
35
  }
35
36
 
@@ -107,36 +108,77 @@ class Glog {
107
108
 
108
109
  // === STATIC CONFIGURATION (for global usage) ===
109
110
 
111
+ /**
112
+ * Set the log prefix for global usage
113
+ *
114
+ * @param {string} prefix - Prefix to prepend to all log messages
115
+ * @returns {typeof Glog} The Glog class for chaining
116
+ */
110
117
  static setLogPrefix(prefix) {
111
118
  this.logPrefix = prefix
112
119
 
113
120
  return this
114
121
  }
115
122
 
123
+ /**
124
+ * Set the log level for global usage (0-5)
125
+ *
126
+ * @param {number} level - Log level (0 = off, 1-5 = increasing verbosity)
127
+ * @returns {typeof Glog} The Glog class for chaining
128
+ */
116
129
  static setLogLevel(level) {
117
130
  this.logLevel = Data.clamp(level, 0, 5)
118
131
 
119
132
  return this
120
133
  }
121
134
 
135
+ /**
136
+ * Set the logger name for global usage
137
+ *
138
+ * @param {string} name - Logger name to display in output
139
+ * @returns {typeof Glog} The Glog class for chaining
140
+ */
122
141
  static withName(name) {
123
142
  this.name = name
124
143
 
125
144
  return this
126
145
  }
127
146
 
147
+ /**
148
+ * Enable colors for global usage
149
+ * Merges with existing color configuration (can pass partial config)
150
+ * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
151
+ * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
152
+ * - info, warn, error, reset: Single color code strings
153
+ * Uses @gesslar/colours format like "{F196}"
154
+ *
155
+ * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
156
+ * @returns {typeof Glog} The Glog class for chaining
157
+ */
128
158
  static withColors(colors = loggerColours) {
129
- this.colors = colors
159
+ this.colors = Object.assign({}, this.colors ?? loggerColours, colors)
130
160
 
131
161
  return this
132
162
  }
133
163
 
164
+ /**
165
+ * Enable stack trace extraction for global usage
166
+ *
167
+ * @param {boolean} [enabled=true] - Whether to enable stack traces
168
+ * @returns {typeof Glog} The Glog class for chaining
169
+ */
134
170
  static withStackTrace(enabled = true) {
135
171
  this.stackTrace = enabled
136
172
 
137
173
  return this
138
174
  }
139
175
 
176
+ /**
177
+ * Use tag names as strings instead of symbols for global usage
178
+ *
179
+ * @param {boolean} [enabled=false] - Whether to use string tags
180
+ * @returns {typeof Glog} The Glog class for chaining
181
+ */
140
182
  static withTagsAsStrings(enabled = false) {
141
183
  this.tagsAsStrings = enabled
142
184
 
@@ -145,6 +187,12 @@ class Glog {
145
187
 
146
188
  // === FLUENT INSTANCE CREATION ===
147
189
 
190
+ /**
191
+ * Create a new Glog instance with fluent configuration
192
+ *
193
+ * @param {object} [options={}] - Initial options
194
+ * @returns {Glog} New Glog instance
195
+ */
148
196
  static create(options = {}) {
149
197
  return new this(options)
150
198
  }
@@ -167,8 +215,19 @@ class Glog {
167
215
  return this
168
216
  }
169
217
 
218
+ /**
219
+ * Enable colors for this logger instance
220
+ * Merges with existing color configuration (can pass partial config)
221
+ * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
222
+ * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
223
+ * - info, warn, error, reset: Single color code strings
224
+ * Uses @gesslar/colours format like "{F196}"
225
+ *
226
+ * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
227
+ * @returns {Glog} This Glog instance for chaining
228
+ */
170
229
  withColors(colors = loggerColours) {
171
- this.#colors = colors
230
+ this.#colors = Object.assign({}, this.#colors ?? loggerColours, colors)
172
231
 
173
232
  return this
174
233
  }
@@ -319,7 +378,12 @@ class Glog {
319
378
  this.#vscodeError?.(JSON.stringify(message))
320
379
  }
321
380
 
322
- // Core execute method for simple usage
381
+ /**
382
+ * Core execute method for simple static usage
383
+ * Can be called as: Glog(data) or Glog(level, data)
384
+ *
385
+ * @param {...unknown} args - Arguments (optional level number, then data)
386
+ */
323
387
  static execute(...args) {
324
388
  // Use static properties for global calls
325
389
  let level, rest
@@ -383,16 +447,7 @@ class Glog {
383
447
  * @param {...unknown} args - Additional arguments
384
448
  */
385
449
  success(message, ...args) {
386
- const name = this.#name || Glog.name || "Log"
387
- const useStrings = this.#tagsAsStrings || Glog.tagsAsStrings
388
- const showName = this.#displayName
389
- const tag = useStrings ? "Success" : logSymbols.success
390
- const namePrefix = showName ? `[${name}] ` : ""
391
- const formatted = useStrings
392
- ? c`${namePrefix}{success}${tag}{/}: ${message}`
393
- : c`${namePrefix}{success}${tag}{/} ${message}`
394
-
395
- Term.log(formatted, ...args)
450
+ Term.log(this.#compose("success", message), ...args)
396
451
  }
397
452
 
398
453
  /**
@@ -402,12 +457,14 @@ class Glog {
402
457
  * @param {...unknown} args - Additional arguments to log
403
458
  */
404
459
  static success(message, ...args) {
460
+ const colors = this.colors || loggerColours
405
461
  const name = this.name || "Log"
406
462
  const useStrings = this.tagsAsStrings
407
463
  const tag = useStrings ? "Success" : logSymbols.success
464
+ const colorCode = colors.success || "{F046}"
408
465
  const formatted = useStrings
409
- ? c`[${name}] {success}${tag}{/}: ${message}`
410
- : c`[${name}] {success}${tag}{/} ${message}`
466
+ ? c`[${name}] ${colorCode}${tag}{/}: ${message}`
467
+ : c`[${name}] ${colorCode}${tag}{/} ${message}`
411
468
 
412
469
  Term.log(formatted, ...args)
413
470
  }
@@ -662,7 +719,7 @@ class Glog {
662
719
 
663
720
  // Wrap in proxy for dual usage
664
721
  export default new Proxy(Glog, {
665
- apply(target, thisArg, argumentsList) {
722
+ apply(target, _thisArg, argumentsList) {
666
723
  return target.execute(...argumentsList)
667
724
  },
668
725
  construct(target, argumentsList) {
@@ -3,6 +3,7 @@ export namespace loggerColours {
3
3
  let info: string;
4
4
  let warn: string;
5
5
  let error: string;
6
+ let success: string;
6
7
  let reset: string;
7
8
  }
8
9
  export namespace logSymbols {
@@ -14,7 +15,8 @@ export namespace logSymbols {
14
15
  export { warn_1 as warn };
15
16
  let error_1: string;
16
17
  export { error_1 as error };
17
- export let success: string;
18
+ let success_1: string;
19
+ export { success_1 as success };
18
20
  }
19
21
  declare const _default: typeof Glog;
20
22
  export default _default;
@@ -25,20 +27,67 @@ declare class Glog {
25
27
  static stackTrace: boolean;
26
28
  static name: string;
27
29
  static tagsAsStrings: boolean;
28
- static setLogPrefix(prefix: any): typeof Glog;
29
- static setLogLevel(level: any): typeof Glog;
30
- static withName(name: any): typeof Glog;
31
- static withColors(colors?: {
32
- debug: string[];
33
- info: string;
34
- warn: string;
35
- error: string;
36
- reset: string;
37
- }): typeof Glog;
30
+ /**
31
+ * Set the log prefix for global usage
32
+ *
33
+ * @param {string} prefix - Prefix to prepend to all log messages
34
+ * @returns {typeof Glog} The Glog class for chaining
35
+ */
36
+ static setLogPrefix(prefix: string): typeof Glog;
37
+ /**
38
+ * Set the log level for global usage (0-5)
39
+ *
40
+ * @param {number} level - Log level (0 = off, 1-5 = increasing verbosity)
41
+ * @returns {typeof Glog} The Glog class for chaining
42
+ */
43
+ static setLogLevel(level: number): typeof Glog;
44
+ /**
45
+ * Set the logger name for global usage
46
+ *
47
+ * @param {string} name - Logger name to display in output
48
+ * @returns {typeof Glog} The Glog class for chaining
49
+ */
50
+ static withName(name: string): typeof Glog;
51
+ /**
52
+ * Enable colors for global usage
53
+ * Merges with existing color configuration (can pass partial config)
54
+ * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
55
+ * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
56
+ * - info, warn, error, reset: Single color code strings
57
+ * Uses @gesslar/colours format like "{F196}"
58
+ *
59
+ * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
60
+ * @returns {typeof Glog} The Glog class for chaining
61
+ */
62
+ static withColors(colors?: object): typeof Glog;
63
+ /**
64
+ * Enable stack trace extraction for global usage
65
+ *
66
+ * @param {boolean} [enabled=true] - Whether to enable stack traces
67
+ * @returns {typeof Glog} The Glog class for chaining
68
+ */
38
69
  static withStackTrace(enabled?: boolean): typeof Glog;
70
+ /**
71
+ * Use tag names as strings instead of symbols for global usage
72
+ *
73
+ * @param {boolean} [enabled=false] - Whether to use string tags
74
+ * @returns {typeof Glog} The Glog class for chaining
75
+ */
39
76
  static withTagsAsStrings(enabled?: boolean): typeof Glog;
40
- static create(options?: {}): Glog;
41
- static execute(...args: any[]): void;
77
+ /**
78
+ * Create a new Glog instance with fluent configuration
79
+ *
80
+ * @param {object} [options={}] - Initial options
81
+ * @returns {Glog} New Glog instance
82
+ */
83
+ static create(options?: object): Glog;
84
+ /**
85
+ * Core execute method for simple static usage
86
+ * Can be called as: Glog(data) or Glog(level, data)
87
+ *
88
+ * @param {...unknown} args - Arguments (optional level number, then data)
89
+ */
90
+ static execute(...args: unknown[]): void;
42
91
  /**
43
92
  * Static version of colorize for global usage
44
93
  *
@@ -116,13 +165,18 @@ declare class Glog {
116
165
  withName(name: any): this;
117
166
  withLogLevel(level: any): this;
118
167
  withPrefix(prefix: any): this;
119
- withColors(colors?: {
120
- debug: string[];
121
- info: string;
122
- warn: string;
123
- error: string;
124
- reset: string;
125
- }): this;
168
+ /**
169
+ * Enable colors for this logger instance
170
+ * Merges with existing color configuration (can pass partial config)
171
+ * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
172
+ * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
173
+ * - info, warn, error, reset: Single color code strings
174
+ * Uses @gesslar/colours format like "{F196}"
175
+ *
176
+ * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
177
+ * @returns {Glog} This Glog instance for chaining
178
+ */
179
+ withColors(colors?: object): Glog;
126
180
  withStackTrace(enabled?: boolean): this;
127
181
  withTagsAsStrings(enabled?: boolean): this;
128
182
  noDisplayName(): this;
@@ -1 +1 @@
1
- {"version":3,"file":"Glog.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Glog.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAsDA;IAEE,wBAAmB;IACnB,yBAAqB;IACrB,mBAAoB;IACpB,2BAAyB;IACzB,oBAAgB;IAChB,8BAA4B;IAgD5B,8CAIC;IAED,4CAIC;IAED,wCAIC;IAED;;;;;;oBAIC;IAED,sDAIC;IAED,yDAIC;IAID,kCAEC;IA6KD,qCAoBC;IAuBD;;;;;OAKG;IACH,yBAHW,KAAK,CAAC,MAAM,CAAC,aACV,OAAO,EAAA,QAOpB;IAqBD;;;;;OAKG;IACH,wBAHW,MAAM,WACH,OAAO,EAAA,QAWpB;IAED;;;;OAIG;IACH,sBAFc,OAAO,EAAA,QAOpB;IAED;;OAEG;IACH,wBAEC;IAED;;;;;OAKG;IACH,2BAHW,MAAM,UACN,MAAM,QAahB;IAED;;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ACH,WAFa,MAAM,CAclB;;CAoBF"}
1
+ {"version":3,"file":"Glog.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Glog.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuDA;IAEE,wBAAmB;IACnB,yBAAqB;IACrB,mBAAoB;IACpB,2BAAyB;IACzB,oBAAgB;IAChB,8BAA4B;IAgD5B;;;;;OAKG;IACH,4BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,0BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;;;;;;OAUG;IACH,2BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,gCAHW,OAAO,GACL,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,mCAHW,OAAO,GACL,OAAO,IAAI,CAMvB;IAID;;;;;OAKG;IACH,wBAHW,MAAM,GACJ,IAAI,CAIhB;IAuLD;;;;;OAKG;IACH,wBAFc,OAAO,EAAA,QAsBpB;IAuBD;;;;;OAKG;IACH,yBAHW,KAAK,CAAC,MAAM,CAAC,aACV,OAAO,EAAA,QAOpB;IAYD;;;;;OAKG;IACH,wBAHW,MAAM,WACH,OAAO,EAAA,QAapB;IAED;;;;OAIG;IACH,sBAFc,OAAO,EAAA,QAOpB;IAED;;OAEG;IACH,wBAEC;IAED;;;;;OAKG;IACH,2BAHW,MAAM,UACN,MAAM,QAahB;IAED;;;;OAIG;IACH,0BAFW,MAAM,QAYhB;IAED;;;;OAIG;IACH,6BAFW,MAAM,QAWhB;IAyFD;;;;;;;;;OASG;IACH,mBAPW,MAAM,QAAQ,mBACd,MAAM,GAAG,MAAM,YAEvB;QAAgC,UAAU,GAAlC,KAAK,CAAC,MAAM,CAAC;QACK,UAAU,GAA5B,OAAO;QACW,aAAa,GAA/B,OAAO;KACjB,QAkBA;IAED;;;;;;OAMG;IAC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