@gesslar/toolkit 3.14.2 → 3.16.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": "3.14.2",
8
+ "version": "3.16.0",
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",
@@ -107,36 +107,77 @@ class Glog {
107
107
 
108
108
  // === STATIC CONFIGURATION (for global usage) ===
109
109
 
110
+ /**
111
+ * Set the log prefix for global usage
112
+ *
113
+ * @param {string} prefix - Prefix to prepend to all log messages
114
+ * @returns {typeof Glog} The Glog class for chaining
115
+ */
110
116
  static setLogPrefix(prefix) {
111
117
  this.logPrefix = prefix
112
118
 
113
119
  return this
114
120
  }
115
121
 
122
+ /**
123
+ * Set the log level for global usage (0-5)
124
+ *
125
+ * @param {number} level - Log level (0 = off, 1-5 = increasing verbosity)
126
+ * @returns {typeof Glog} The Glog class for chaining
127
+ */
116
128
  static setLogLevel(level) {
117
129
  this.logLevel = Data.clamp(level, 0, 5)
118
130
 
119
131
  return this
120
132
  }
121
133
 
134
+ /**
135
+ * Set the logger name for global usage
136
+ *
137
+ * @param {string} name - Logger name to display in output
138
+ * @returns {typeof Glog} The Glog class for chaining
139
+ */
122
140
  static withName(name) {
123
141
  this.name = name
124
142
 
125
143
  return this
126
144
  }
127
145
 
146
+ /**
147
+ * Enable colors for global usage
148
+ * Merges with existing color configuration (can pass partial config)
149
+ * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
150
+ * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
151
+ * - info, warn, error, reset: Single color code strings
152
+ * Uses @gesslar/colours format like "{F196}"
153
+ *
154
+ * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
155
+ * @returns {typeof Glog} The Glog class for chaining
156
+ */
128
157
  static withColors(colors = loggerColours) {
129
- this.colors = colors
158
+ this.colors = Object.assign({}, this.colors ?? loggerColours, colors)
130
159
 
131
160
  return this
132
161
  }
133
162
 
163
+ /**
164
+ * Enable stack trace extraction for global usage
165
+ *
166
+ * @param {boolean} [enabled=true] - Whether to enable stack traces
167
+ * @returns {typeof Glog} The Glog class for chaining
168
+ */
134
169
  static withStackTrace(enabled = true) {
135
170
  this.stackTrace = enabled
136
171
 
137
172
  return this
138
173
  }
139
174
 
175
+ /**
176
+ * Use tag names as strings instead of symbols for global usage
177
+ *
178
+ * @param {boolean} [enabled=false] - Whether to use string tags
179
+ * @returns {typeof Glog} The Glog class for chaining
180
+ */
140
181
  static withTagsAsStrings(enabled = false) {
141
182
  this.tagsAsStrings = enabled
142
183
 
@@ -145,6 +186,12 @@ class Glog {
145
186
 
146
187
  // === FLUENT INSTANCE CREATION ===
147
188
 
189
+ /**
190
+ * Create a new Glog instance with fluent configuration
191
+ *
192
+ * @param {object} [options={}] - Initial options
193
+ * @returns {Glog} New Glog instance
194
+ */
148
195
  static create(options = {}) {
149
196
  return new this(options)
150
197
  }
@@ -167,8 +214,19 @@ class Glog {
167
214
  return this
168
215
  }
169
216
 
217
+ /**
218
+ * Enable colors for this logger instance
219
+ * Merges with existing color configuration (can pass partial config)
220
+ * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
221
+ * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
222
+ * - info, warn, error, reset: Single color code strings
223
+ * Uses @gesslar/colours format like "{F196}"
224
+ *
225
+ * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
226
+ * @returns {Glog} This Glog instance for chaining
227
+ */
170
228
  withColors(colors = loggerColours) {
171
- this.#colors = colors
229
+ this.#colors = Object.assign({}, this.#colors ?? loggerColours, colors)
172
230
 
173
231
  return this
174
232
  }
@@ -319,7 +377,12 @@ class Glog {
319
377
  this.#vscodeError?.(JSON.stringify(message))
320
378
  }
321
379
 
322
- // Core execute method for simple usage
380
+ /**
381
+ * Core execute method for simple static usage
382
+ * Can be called as: Glog(data) or Glog(level, data)
383
+ *
384
+ * @param {...unknown} args - Arguments (optional level number, then data)
385
+ */
323
386
  static execute(...args) {
324
387
  // Use static properties for global calls
325
388
  let level, rest
@@ -662,7 +725,7 @@ class Glog {
662
725
 
663
726
  // Wrap in proxy for dual usage
664
727
  export default new Proxy(Glog, {
665
- apply(target, thisArg, argumentsList) {
728
+ apply(target, _thisArg, argumentsList) {
666
729
  return target.execute(...argumentsList)
667
730
  },
668
731
  construct(target, argumentsList) {
@@ -25,20 +25,67 @@ declare class Glog {
25
25
  static stackTrace: boolean;
26
26
  static name: string;
27
27
  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;
28
+ /**
29
+ * Set the log prefix for global usage
30
+ *
31
+ * @param {string} prefix - Prefix to prepend to all log messages
32
+ * @returns {typeof Glog} The Glog class for chaining
33
+ */
34
+ static setLogPrefix(prefix: string): typeof Glog;
35
+ /**
36
+ * Set the log level for global usage (0-5)
37
+ *
38
+ * @param {number} level - Log level (0 = off, 1-5 = increasing verbosity)
39
+ * @returns {typeof Glog} The Glog class for chaining
40
+ */
41
+ static setLogLevel(level: number): typeof Glog;
42
+ /**
43
+ * Set the logger name for global usage
44
+ *
45
+ * @param {string} name - Logger name to display in output
46
+ * @returns {typeof Glog} The Glog class for chaining
47
+ */
48
+ static withName(name: string): typeof Glog;
49
+ /**
50
+ * Enable colors for global usage
51
+ * Merges with existing color configuration (can pass partial config)
52
+ * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
53
+ * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
54
+ * - info, warn, error, reset: Single color code strings
55
+ * Uses @gesslar/colours format like "{F196}"
56
+ *
57
+ * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
58
+ * @returns {typeof Glog} The Glog class for chaining
59
+ */
60
+ static withColors(colors?: object): typeof Glog;
61
+ /**
62
+ * Enable stack trace extraction for global usage
63
+ *
64
+ * @param {boolean} [enabled=true] - Whether to enable stack traces
65
+ * @returns {typeof Glog} The Glog class for chaining
66
+ */
38
67
  static withStackTrace(enabled?: boolean): typeof Glog;
68
+ /**
69
+ * Use tag names as strings instead of symbols for global usage
70
+ *
71
+ * @param {boolean} [enabled=false] - Whether to use string tags
72
+ * @returns {typeof Glog} The Glog class for chaining
73
+ */
39
74
  static withTagsAsStrings(enabled?: boolean): typeof Glog;
40
- static create(options?: {}): Glog;
41
- static execute(...args: any[]): void;
75
+ /**
76
+ * Create a new Glog instance with fluent configuration
77
+ *
78
+ * @param {object} [options={}] - Initial options
79
+ * @returns {Glog} New Glog instance
80
+ */
81
+ static create(options?: object): Glog;
82
+ /**
83
+ * Core execute method for simple static usage
84
+ * Can be called as: Glog(data) or Glog(level, data)
85
+ *
86
+ * @param {...unknown} args - Arguments (optional level number, then data)
87
+ */
88
+ static execute(...args: unknown[]): void;
42
89
  /**
43
90
  * Static version of colorize for global usage
44
91
  *
@@ -116,13 +163,18 @@ declare class Glog {
116
163
  withName(name: any): this;
117
164
  withLogLevel(level: any): this;
118
165
  withPrefix(prefix: any): this;
119
- withColors(colors?: {
120
- debug: string[];
121
- info: string;
122
- warn: string;
123
- error: string;
124
- reset: string;
125
- }): this;
166
+ /**
167
+ * Enable colors for this logger instance
168
+ * Merges with existing color configuration (can pass partial config)
169
+ * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
170
+ * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
171
+ * - info, warn, error, reset: Single color code strings
172
+ * Uses @gesslar/colours format like "{F196}"
173
+ *
174
+ * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
175
+ * @returns {Glog} This Glog instance for chaining
176
+ */
177
+ withColors(colors?: object): Glog;
126
178
  withStackTrace(enabled?: boolean): this;
127
179
  withTagsAsStrings(enabled?: boolean): this;
128
180
  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;;;;OAIG;IACH,0BAFW,MAAM,QAYhB;IAED;;;;OAIG;IACH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