@socketsecurity/cli-with-sentry 1.1.14 → 1.1.17
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/CHANGELOG.md +19 -0
- package/dist/cli.js +114 -32
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +35 -37
- package/dist/constants.js.map +1 -1
- package/dist/shadow-npm-bin.js +6 -6
- package/dist/shadow-npm-bin.js.map +1 -1
- package/dist/shadow-pnpm-bin.js +3 -5
- package/dist/shadow-pnpm-bin.js.map +1 -1
- package/dist/shadow-yarn-bin.js +2 -2
- package/dist/shadow-yarn-bin.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/env-helpers.d.mts +13 -0
- package/dist/types/commands/fix/env-helpers.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +1 -1
- package/dist/types/commands/manifest/run-cdxgen.d.mts.map +1 -1
- package/dist/types/commands/optimize/apply-optimization.d.mts.map +1 -1
- package/dist/types/commands/optimize/update-lockfile.d.mts.map +1 -1
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +1 -1
- package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
- package/dist/types/commands/patch/handle-patch.d.mts.map +1 -1
- package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts.map +1 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts +1 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts.map +1 -1
- package/dist/types/constants.d.mts +15 -19
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/shadow/pnpm/bin.d.mts.map +1 -1
- package/dist/types/utils/agent.d.mts.map +1 -1
- package/dist/types/utils/api.d.mts.map +1 -1
- package/dist/types/utils/dlx.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/types/utils/path-resolve.d.mts.map +1 -1
- package/dist/utils.js +70 -29
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +514 -517
- package/external/@socketsecurity/registry/external/@inquirer/confirm.js +45 -205
- package/external/@socketsecurity/registry/external/@inquirer/input.js +45 -205
- package/external/@socketsecurity/registry/external/@inquirer/password.js +181 -205
- package/external/@socketsecurity/registry/external/@inquirer/search.js +47 -207
- package/external/@socketsecurity/registry/external/@inquirer/select.js +183 -207
- package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +388 -2280
- package/external/@socketsecurity/registry/external/browserslist.js +11534 -567
- package/external/@socketsecurity/registry/external/cacache.js +2575 -4914
- package/external/@socketsecurity/registry/external/libnpmpack.js +64667 -166061
- package/external/@socketsecurity/registry/external/make-fetch-happen.js +384 -4044
- package/external/@socketsecurity/registry/external/normalize-package-data.js +30 -278
- package/external/@socketsecurity/registry/external/npm-package-arg.js +28 -9
- package/external/@socketsecurity/registry/external/pacote.js +46680 -66482
- package/external/@socketsecurity/registry/external/spdx-correct.js +19 -0
- package/external/@socketsecurity/registry/external/spdx-expression-parse.js +19 -0
- package/external/@socketsecurity/registry/lib/agent.js +390 -0
- package/external/@socketsecurity/registry/lib/arrays.js +31 -0
- package/external/@socketsecurity/registry/lib/bin.js +650 -0
- package/external/@socketsecurity/registry/lib/constants/bun-lock.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/bun-lockb.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/bun.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/dot-git-dir.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/dot-socket-dir.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/empty-value.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/env.js +17 -3
- package/external/@socketsecurity/registry/lib/constants/ext-yaml.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-yml.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/index.js +20 -11
- package/external/@socketsecurity/registry/lib/constants/npm-exec-path.js +2 -2
- package/external/@socketsecurity/registry/lib/constants/npm-real-exec-path.js +1 -1
- package/external/@socketsecurity/registry/lib/constants/npm-shrinkwrap-json.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/pnpm-exec-path.js +5 -0
- package/external/@socketsecurity/registry/lib/constants/pnpm-lock-yaml.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/unknown-error.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/unknown-value.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/vlt-lock-json.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/vlt.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/yarn-berry.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/yarn-classic.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/yarn-exec-path.js +5 -0
- package/external/@socketsecurity/registry/lib/constants/yarn.js +3 -0
- package/external/@socketsecurity/registry/lib/debug.js +53 -0
- package/external/@socketsecurity/registry/lib/env.js +18 -0
- package/external/@socketsecurity/registry/lib/fs.js +218 -2
- package/external/@socketsecurity/registry/lib/functions.js +5 -0
- package/external/@socketsecurity/registry/lib/globs.js +22 -1
- package/external/@socketsecurity/registry/lib/json.js +16 -0
- package/external/@socketsecurity/registry/lib/logger.js +157 -0
- package/external/@socketsecurity/registry/lib/objects.js +103 -0
- package/external/@socketsecurity/registry/lib/packages.js +88 -0
- package/external/@socketsecurity/registry/lib/path.js +51 -1
- package/external/@socketsecurity/registry/lib/promises.js +55 -0
- package/external/@socketsecurity/registry/lib/regexps.js +5 -0
- package/external/@socketsecurity/registry/lib/sorts.js +17 -0
- package/external/@socketsecurity/registry/lib/spawn.js +105 -7
- package/external/@socketsecurity/registry/lib/streams.js +26 -0
- package/external/@socketsecurity/registry/lib/strings.js +123 -9
- package/external/@socketsecurity/registry/lib/url.js +21 -0
- package/external/@socketsecurity/registry/lib/words.js +16 -0
- package/external/@socketsecurity/registry/manifest.json +5 -4
- package/package.json +5 -4
- package/external/@socketsecurity/registry/external/ansi-regex.js +0 -13
- package/external/@socketsecurity/registry/lib/constants/node-workspaces.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/parse-args-config.js +0 -14
- package/external/@socketsecurity/registry/lib/constants/skip-tests-by-ecosystem.js +0 -43
- package/external/@socketsecurity/registry/lib/constants/template-cjs-browser.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-cjs-esm.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-cjs.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-es-shim-constructor.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-es-shim-prototype-method.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-es-shim-static-method.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/win32-ensure-tests-by-ecosystem.js +0 -3
- package/external/@socketsecurity/registry/lib/npm.js +0 -404
- /package/external/@socketsecurity/registry/lib/constants/{hidden-package-lock-json.js → dot-package-lock-json.js} +0 -0
|
@@ -7,6 +7,12 @@ const { apply: ReflectApply, construct: ReflectConstruct } = Reflect
|
|
|
7
7
|
const { applyLinePrefix, isBlankString } = /*@__PURE__*/ require('./strings')
|
|
8
8
|
|
|
9
9
|
let _Console
|
|
10
|
+
/**
|
|
11
|
+
* Construct a new Console instance.
|
|
12
|
+
* @param {...any} args - Arguments to pass to the Console constructor.
|
|
13
|
+
* @returns {Console} A new Console instance.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
10
16
|
/*@__NO_SIDE_EFFECTS__*/
|
|
11
17
|
function constructConsole(...args) {
|
|
12
18
|
if (_Console === undefined) {
|
|
@@ -19,6 +25,11 @@ function constructConsole(...args) {
|
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
let _yoctocolors
|
|
28
|
+
/**
|
|
29
|
+
* Get the yoctocolors module for terminal colors.
|
|
30
|
+
* @returns {Object} The yoctocolors module.
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
22
33
|
/*@__NO_SIDE_EFFECTS__*/
|
|
23
34
|
function getYoctocolors() {
|
|
24
35
|
if (_yoctocolors === undefined) {
|
|
@@ -109,6 +120,10 @@ const kGroupIndentationWidthSymbol =
|
|
|
109
120
|
Symbol('kGroupIndentWidth')
|
|
110
121
|
const lastWasBlankSymbol = Symbol.for('logger.lastWasBlank')
|
|
111
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Custom Logger class that wraps console with additional features.
|
|
125
|
+
* Supports indentation, symbols, and blank line tracking.
|
|
126
|
+
*/
|
|
112
127
|
/*@__PURE__*/
|
|
113
128
|
class Logger {
|
|
114
129
|
static LOG_SYMBOLS = LOG_SYMBOLS
|
|
@@ -134,6 +149,13 @@ class Logger {
|
|
|
134
149
|
}
|
|
135
150
|
}
|
|
136
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Apply a console method with indentation.
|
|
154
|
+
* @param {string} methodName - Name of the console method to call.
|
|
155
|
+
* @param {any[]} args - Arguments to pass to the method.
|
|
156
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
137
159
|
#apply(methodName, args) {
|
|
138
160
|
const con = privateConsole.get(this)
|
|
139
161
|
const text = args.at(0)
|
|
@@ -147,6 +169,13 @@ class Logger {
|
|
|
147
169
|
return this
|
|
148
170
|
}
|
|
149
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Apply a method with a symbol prefix.
|
|
174
|
+
* @param {string} symbolType - Type of symbol to use (fail, info, success, warn).
|
|
175
|
+
* @param {any[]} args - Arguments to pass to the method.
|
|
176
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
177
|
+
* @private
|
|
178
|
+
*/
|
|
150
179
|
#symbolApply(symbolType, args) {
|
|
151
180
|
const con = privateConsole.get(this)
|
|
152
181
|
let text = args.at(0)
|
|
@@ -167,20 +196,39 @@ class Logger {
|
|
|
167
196
|
return this
|
|
168
197
|
}
|
|
169
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Get the current log call count.
|
|
201
|
+
* @returns {number} The number of log calls made.
|
|
202
|
+
*/
|
|
170
203
|
get logCallCount() {
|
|
171
204
|
return this.#logCallCount
|
|
172
205
|
}
|
|
173
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Increment the log call count.
|
|
209
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
210
|
+
*/
|
|
174
211
|
[incLogCallCountSymbol]() {
|
|
175
212
|
this.#logCallCount += 1
|
|
176
213
|
return this
|
|
177
214
|
}
|
|
178
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Set whether the last logged line was blank.
|
|
218
|
+
* @param {boolean} value - Whether the last line was blank.
|
|
219
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
220
|
+
*/
|
|
179
221
|
[lastWasBlankSymbol](value) {
|
|
180
222
|
this.#lastWasBlank = !!value
|
|
181
223
|
return this
|
|
182
224
|
}
|
|
183
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Log an assertion.
|
|
228
|
+
* @param {any} value - Value to assert.
|
|
229
|
+
* @param {...any} message - Message to log if assertion fails.
|
|
230
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
231
|
+
*/
|
|
184
232
|
assert(value, ...message) {
|
|
185
233
|
const con = privateConsole.get(this)
|
|
186
234
|
con.assert(value, ...message)
|
|
@@ -188,6 +236,10 @@ class Logger {
|
|
|
188
236
|
return value ? this : this[incLogCallCountSymbol]()
|
|
189
237
|
}
|
|
190
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Clear the console.
|
|
241
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
242
|
+
*/
|
|
191
243
|
clear() {
|
|
192
244
|
const con = privateConsole.get(this)
|
|
193
245
|
con.clear()
|
|
@@ -198,6 +250,11 @@ class Logger {
|
|
|
198
250
|
return this
|
|
199
251
|
}
|
|
200
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Log a count for the given label.
|
|
255
|
+
* @param {string} label - Label to count.
|
|
256
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
257
|
+
*/
|
|
201
258
|
count(label) {
|
|
202
259
|
const con = privateConsole.get(this)
|
|
203
260
|
con.count(label)
|
|
@@ -205,11 +262,22 @@ class Logger {
|
|
|
205
262
|
return this[incLogCallCountSymbol]()
|
|
206
263
|
}
|
|
207
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Decrease indentation level.
|
|
267
|
+
* @param {number} [spaces=2] - Number of spaces to dedent.
|
|
268
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
269
|
+
*/
|
|
208
270
|
dedent(spaces = 2) {
|
|
209
271
|
this.#indention = this.#indention.slice(0, -spaces)
|
|
210
272
|
return this
|
|
211
273
|
}
|
|
212
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Display an object's properties.
|
|
277
|
+
* @param {any} obj - Object to display.
|
|
278
|
+
* @param {Object} [options] - Display options.
|
|
279
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
280
|
+
*/
|
|
213
281
|
dir(obj, options) {
|
|
214
282
|
const con = privateConsole.get(this)
|
|
215
283
|
con.dir(obj, options)
|
|
@@ -217,6 +285,11 @@ class Logger {
|
|
|
217
285
|
return this[incLogCallCountSymbol]()
|
|
218
286
|
}
|
|
219
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Display data as XML.
|
|
290
|
+
* @param {...any} data - Data to display.
|
|
291
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
292
|
+
*/
|
|
220
293
|
dirxml(...data) {
|
|
221
294
|
const con = privateConsole.get(this)
|
|
222
295
|
con.dirxml(data)
|
|
@@ -224,18 +297,37 @@ class Logger {
|
|
|
224
297
|
return this[incLogCallCountSymbol]()
|
|
225
298
|
}
|
|
226
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Log an error message.
|
|
302
|
+
* @param {...any} args - Arguments to log.
|
|
303
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
304
|
+
*/
|
|
227
305
|
error(...args) {
|
|
228
306
|
return this.#apply('error', args)
|
|
229
307
|
}
|
|
230
308
|
|
|
309
|
+
/**
|
|
310
|
+
* Log a newline to stderr if last line wasn't blank.
|
|
311
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
312
|
+
*/
|
|
231
313
|
errorNewline() {
|
|
232
314
|
return this.#lastWasBlank ? this : this.error('')
|
|
233
315
|
}
|
|
234
316
|
|
|
317
|
+
/**
|
|
318
|
+
* Log a failure message with symbol.
|
|
319
|
+
* @param {...any} args - Arguments to log.
|
|
320
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
321
|
+
*/
|
|
235
322
|
fail(...args) {
|
|
236
323
|
return this.#symbolApply('fail', args)
|
|
237
324
|
}
|
|
238
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Start a new log group.
|
|
328
|
+
* @param {...any} label - Label for the group.
|
|
329
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
330
|
+
*/
|
|
239
331
|
group(...label) {
|
|
240
332
|
const { length } = label
|
|
241
333
|
if (length) {
|
|
@@ -249,43 +341,86 @@ class Logger {
|
|
|
249
341
|
return this
|
|
250
342
|
}
|
|
251
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Start a new collapsed log group (alias for group).
|
|
346
|
+
* @param {...any} label - Label for the group.
|
|
347
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
348
|
+
*/
|
|
252
349
|
// groupCollapsed is an alias of group.
|
|
253
350
|
// https://nodejs.org/api/console.html#consolegroupcollapsed
|
|
254
351
|
groupCollapsed(...label) {
|
|
255
352
|
return ReflectApply(this.group, this, label)
|
|
256
353
|
}
|
|
257
354
|
|
|
355
|
+
/**
|
|
356
|
+
* End the current log group.
|
|
357
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
358
|
+
*/
|
|
258
359
|
groupEnd() {
|
|
259
360
|
this.dedent(this[kGroupIndentationWidthSymbol])
|
|
260
361
|
return this
|
|
261
362
|
}
|
|
262
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Increase indentation level.
|
|
366
|
+
* @param {number} [spaces=2] - Number of spaces to indent.
|
|
367
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
368
|
+
*/
|
|
263
369
|
indent(spaces = 2) {
|
|
264
370
|
this.#indention += ' '.repeat(Math.min(spaces, maxIndentation))
|
|
265
371
|
return this
|
|
266
372
|
}
|
|
267
373
|
|
|
374
|
+
/**
|
|
375
|
+
* Log an info message with symbol.
|
|
376
|
+
* @param {...any} args - Arguments to log.
|
|
377
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
378
|
+
*/
|
|
268
379
|
info(...args) {
|
|
269
380
|
return this.#symbolApply('info', args)
|
|
270
381
|
}
|
|
271
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Log a message.
|
|
385
|
+
* @param {...any} args - Arguments to log.
|
|
386
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
387
|
+
*/
|
|
272
388
|
log(...args) {
|
|
273
389
|
return this.#apply('log', args)
|
|
274
390
|
}
|
|
275
391
|
|
|
392
|
+
/**
|
|
393
|
+
* Log a newline to stdout if last line wasn't blank.
|
|
394
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
395
|
+
*/
|
|
276
396
|
logNewline() {
|
|
277
397
|
return this.#lastWasBlank ? this : this.log('')
|
|
278
398
|
}
|
|
279
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Reset indentation to zero.
|
|
402
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
403
|
+
*/
|
|
280
404
|
resetIndent() {
|
|
281
405
|
this.#indention = ''
|
|
282
406
|
return this
|
|
283
407
|
}
|
|
284
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Log a success message with symbol.
|
|
411
|
+
* @param {...any} args - Arguments to log.
|
|
412
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
413
|
+
*/
|
|
285
414
|
success(...args) {
|
|
286
415
|
return this.#symbolApply('success', args)
|
|
287
416
|
}
|
|
288
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Display data in a table format.
|
|
420
|
+
* @param {any} tabularData - Data to display.
|
|
421
|
+
* @param {string[]} [properties] - Properties to display.
|
|
422
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
423
|
+
*/
|
|
289
424
|
table(tabularData, properties) {
|
|
290
425
|
const con = privateConsole.get(this)
|
|
291
426
|
con.table(tabularData, properties)
|
|
@@ -293,6 +428,11 @@ class Logger {
|
|
|
293
428
|
return this[incLogCallCountSymbol]()
|
|
294
429
|
}
|
|
295
430
|
|
|
431
|
+
/**
|
|
432
|
+
* End a timer and log the elapsed time.
|
|
433
|
+
* @param {string} label - Timer label.
|
|
434
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
435
|
+
*/
|
|
296
436
|
timeEnd(label) {
|
|
297
437
|
const con = privateConsole.get(this)
|
|
298
438
|
con.timeEnd(label)
|
|
@@ -300,6 +440,12 @@ class Logger {
|
|
|
300
440
|
return this[incLogCallCountSymbol]()
|
|
301
441
|
}
|
|
302
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Log the current timer value.
|
|
445
|
+
* @param {string} label - Timer label.
|
|
446
|
+
* @param {...any} data - Additional data to log.
|
|
447
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
448
|
+
*/
|
|
303
449
|
timeLog(label, ...data) {
|
|
304
450
|
const con = privateConsole.get(this)
|
|
305
451
|
con.timeLog(label, ...data)
|
|
@@ -307,6 +453,12 @@ class Logger {
|
|
|
307
453
|
return this[incLogCallCountSymbol]()
|
|
308
454
|
}
|
|
309
455
|
|
|
456
|
+
/**
|
|
457
|
+
* Log a stack trace.
|
|
458
|
+
* @param {string} message - Message to log with trace.
|
|
459
|
+
* @param {...any} args - Additional arguments.
|
|
460
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
461
|
+
*/
|
|
310
462
|
trace(message, ...args) {
|
|
311
463
|
const con = privateConsole.get(this)
|
|
312
464
|
con.trace(message, ...args)
|
|
@@ -314,6 +466,11 @@ class Logger {
|
|
|
314
466
|
return this[incLogCallCountSymbol]()
|
|
315
467
|
}
|
|
316
468
|
|
|
469
|
+
/**
|
|
470
|
+
* Log a warning message with symbol.
|
|
471
|
+
* @param {...any} args - Arguments to log.
|
|
472
|
+
* @returns {Logger} This Logger instance for chaining.
|
|
473
|
+
*/
|
|
317
474
|
warn(...args) {
|
|
318
475
|
return this.#symbolApply('warn', args)
|
|
319
476
|
}
|
|
@@ -14,6 +14,13 @@ const {
|
|
|
14
14
|
const { __defineGetter__ } = Object.prototype
|
|
15
15
|
const { ownKeys: ReflectOwnKeys } = Reflect
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Create a lazy getter function that memoizes its result.
|
|
19
|
+
* @param {string | symbol} name - The property name for the getter.
|
|
20
|
+
* @param {Function} getter - The function to compute the value.
|
|
21
|
+
* @param {{initialized?: Set<string | symbol>}} [stats] - Statistics tracking object.
|
|
22
|
+
* @returns {Function} The lazy getter function.
|
|
23
|
+
*/
|
|
17
24
|
/*@__NO_SIDE_EFFECTS__*/
|
|
18
25
|
function createLazyGetter(name, getter, stats) {
|
|
19
26
|
const UNDEFINED_TOKEN = /*@__PURE__*/ require('./constants/undefined-token')
|
|
@@ -31,6 +38,15 @@ function createLazyGetter(name, getter, stats) {
|
|
|
31
38
|
return lazyGetter
|
|
32
39
|
}
|
|
33
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Create a frozen constants object with lazy getters and internal properties.
|
|
43
|
+
* @param {Object} props - Properties to include in the constants object.
|
|
44
|
+
* @param {Object} [options_] - Configuration options.
|
|
45
|
+
* @param {Object} [options_.getters] - Lazy getter definitions.
|
|
46
|
+
* @param {Object} [options_.internals] - Internal properties.
|
|
47
|
+
* @param {Object} [options_.mixin] - Properties to mix in.
|
|
48
|
+
* @returns {Object} The frozen constants object.
|
|
49
|
+
*/
|
|
34
50
|
/*@__NO_SIDE_EFFECTS__*/
|
|
35
51
|
function createConstantsObject(props, options_) {
|
|
36
52
|
const options = { __proto__: null, ...options_ }
|
|
@@ -95,17 +111,39 @@ function createConstantsObject(props, options_) {
|
|
|
95
111
|
return ObjectFreeze(object)
|
|
96
112
|
}
|
|
97
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Define a getter property on an object.
|
|
116
|
+
* @param {Object} object - The object to define the getter on.
|
|
117
|
+
* @param {string | symbol} propKey - The property key.
|
|
118
|
+
* @param {Function} getter - The getter function.
|
|
119
|
+
* @returns {Object} The object with the getter defined.
|
|
120
|
+
*/
|
|
98
121
|
/*@__NO_SIDE_EFFECTS__*/
|
|
99
122
|
function defineGetter(object, propKey, getter) {
|
|
100
123
|
__defineGetter__.call(object, propKey, getter)
|
|
101
124
|
return object
|
|
102
125
|
}
|
|
103
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Define a lazy getter property on an object.
|
|
129
|
+
* @param {Object} object - The object to define the lazy getter on.
|
|
130
|
+
* @param {string | symbol} propKey - The property key.
|
|
131
|
+
* @param {Function} getter - The getter function.
|
|
132
|
+
* @param {{initialized?: Set<string | symbol>}} [stats] - Statistics tracking object.
|
|
133
|
+
* @returns {Object} The object with the lazy getter defined.
|
|
134
|
+
*/
|
|
104
135
|
/*@__NO_SIDE_EFFECTS__*/
|
|
105
136
|
function defineLazyGetter(object, propKey, getter, stats) {
|
|
106
137
|
return defineGetter(object, propKey, createLazyGetter(propKey, getter, stats))
|
|
107
138
|
}
|
|
108
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Define multiple lazy getter properties on an object.
|
|
142
|
+
* @param {Object} object - The object to define the lazy getters on.
|
|
143
|
+
* @param {Object | null} getterDefObj - Object mapping property keys to getter functions.
|
|
144
|
+
* @param {{initialized?: Set<string | symbol>}} [stats] - Statistics tracking object.
|
|
145
|
+
* @returns {Object} The object with the lazy getters defined.
|
|
146
|
+
*/
|
|
109
147
|
/*@__NO_SIDE_EFFECTS__*/
|
|
110
148
|
function defineLazyGetters(object, getterDefObj, stats) {
|
|
111
149
|
if (getterDefObj !== null && typeof getterDefObj === 'object') {
|
|
@@ -123,6 +161,13 @@ function defineLazyGetters(object, getterDefObj, stats) {
|
|
|
123
161
|
}
|
|
124
162
|
|
|
125
163
|
let _localeCompare
|
|
164
|
+
/**
|
|
165
|
+
* Compare two entry arrays by their keys for sorting.
|
|
166
|
+
* @param {[any, any]} a - First entry tuple.
|
|
167
|
+
* @param {[any, any]} b - Second entry tuple.
|
|
168
|
+
* @returns {number} Comparison result for sorting.
|
|
169
|
+
* @private
|
|
170
|
+
*/
|
|
126
171
|
/*@__NO_SIDE_EFFECTS__*/
|
|
127
172
|
function entryKeyComparator(a, b) {
|
|
128
173
|
if (_localeCompare === undefined) {
|
|
@@ -136,11 +181,22 @@ function entryKeyComparator(a, b) {
|
|
|
136
181
|
return _localeCompare(strKeyA, strKeyB)
|
|
137
182
|
}
|
|
138
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Get the enumerable own property keys of an object.
|
|
186
|
+
* @param {any} obj - The object to get keys from.
|
|
187
|
+
* @returns {string[]} Array of property keys, or empty array if not an object.
|
|
188
|
+
*/
|
|
139
189
|
/*@__NO_SIDE_EFFECTS__*/
|
|
140
190
|
function getKeys(obj) {
|
|
141
191
|
return isObject(obj) ? ObjectKeys(obj) : []
|
|
142
192
|
}
|
|
143
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Get an own property value from an object safely.
|
|
196
|
+
* @param {any} obj - The object to get the property from.
|
|
197
|
+
* @param {string | symbol} propKey - The property key.
|
|
198
|
+
* @returns {any} The property value or undefined.
|
|
199
|
+
*/
|
|
144
200
|
/*@__NO_SIDE_EFFECTS__*/
|
|
145
201
|
function getOwn(obj, propKey) {
|
|
146
202
|
if (obj === null || obj === undefined) {
|
|
@@ -149,6 +205,11 @@ function getOwn(obj, propKey) {
|
|
|
149
205
|
return ObjectHasOwn(obj, propKey) ? obj[propKey] : undefined
|
|
150
206
|
}
|
|
151
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Get all own property values from an object.
|
|
210
|
+
* @param {any} obj - The object to get values from.
|
|
211
|
+
* @returns {any[]} Array of property values.
|
|
212
|
+
*/
|
|
152
213
|
/*@__NO_SIDE_EFFECTS__*/
|
|
153
214
|
function getOwnPropertyValues(obj) {
|
|
154
215
|
if (obj === null || obj === undefined) {
|
|
@@ -163,6 +224,11 @@ function getOwnPropertyValues(obj) {
|
|
|
163
224
|
return values
|
|
164
225
|
}
|
|
165
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Check if an object has any enumerable own properties.
|
|
229
|
+
* @param {any} obj - The object to check.
|
|
230
|
+
* @returns {boolean} True if the object has at least one own property.
|
|
231
|
+
*/
|
|
166
232
|
/*@__NO_SIDE_EFFECTS__*/
|
|
167
233
|
function hasKeys(obj) {
|
|
168
234
|
if (obj === null || obj === undefined) {
|
|
@@ -176,6 +242,12 @@ function hasKeys(obj) {
|
|
|
176
242
|
return false
|
|
177
243
|
}
|
|
178
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Check if an object has an own property.
|
|
247
|
+
* @param {any} obj - The object to check.
|
|
248
|
+
* @param {string | symbol} propKey - The property key.
|
|
249
|
+
* @returns {boolean} True if the object has the own property.
|
|
250
|
+
*/
|
|
179
251
|
/*@__NO_SIDE_EFFECTS__*/
|
|
180
252
|
function hasOwn(obj, propKey) {
|
|
181
253
|
if (obj === null || obj === undefined) {
|
|
@@ -184,16 +256,31 @@ function hasOwn(obj, propKey) {
|
|
|
184
256
|
return ObjectHasOwn(obj, propKey)
|
|
185
257
|
}
|
|
186
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Check if a value is an object (including arrays).
|
|
261
|
+
* @param {any} value - The value to check.
|
|
262
|
+
* @returns {boolean} True if the value is an object.
|
|
263
|
+
*/
|
|
187
264
|
/*@__NO_SIDE_EFFECTS__*/
|
|
188
265
|
function isObject(value) {
|
|
189
266
|
return value !== null && typeof value === 'object'
|
|
190
267
|
}
|
|
191
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Check if a value is a plain object (not an array).
|
|
271
|
+
* @param {any} value - The value to check.
|
|
272
|
+
* @returns {boolean} True if the value is a plain object.
|
|
273
|
+
*/
|
|
192
274
|
/*@__NO_SIDE_EFFECTS__*/
|
|
193
275
|
function isObjectObject(value) {
|
|
194
276
|
return value !== null && typeof value === 'object' && !ArrayIsArray(value)
|
|
195
277
|
}
|
|
196
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Get all own property entries (key-value pairs) from an object.
|
|
281
|
+
* @param {any} obj - The object to get entries from.
|
|
282
|
+
* @returns {Array<[string | symbol, any]>} Array of [key, value] tuples.
|
|
283
|
+
*/
|
|
197
284
|
/*@__NO_SIDE_EFFECTS__*/
|
|
198
285
|
function objectEntries(obj) {
|
|
199
286
|
if (obj === null || obj === undefined) {
|
|
@@ -209,6 +296,12 @@ function objectEntries(obj) {
|
|
|
209
296
|
return entries
|
|
210
297
|
}
|
|
211
298
|
|
|
299
|
+
/**
|
|
300
|
+
* Deep merge source object into target object.
|
|
301
|
+
* @param {any} target - The target object to merge into.
|
|
302
|
+
* @param {any} source - The source object to merge from.
|
|
303
|
+
* @returns {any} The modified target object.
|
|
304
|
+
*/
|
|
212
305
|
/*@__NO_SIDE_EFFECTS__*/
|
|
213
306
|
function merge(target, source) {
|
|
214
307
|
if (!isObject(target) || !isObject(source)) {
|
|
@@ -272,11 +365,21 @@ function merge(target, source) {
|
|
|
272
365
|
return target
|
|
273
366
|
}
|
|
274
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Convert an object to a new object with sorted keys.
|
|
370
|
+
* @param {Object} obj - The object to sort.
|
|
371
|
+
* @returns {Object} A new object with keys in sorted order.
|
|
372
|
+
*/
|
|
275
373
|
/*@__NO_SIDE_EFFECTS__*/
|
|
276
374
|
function toSortedObject(obj) {
|
|
277
375
|
return toSortedObjectFromEntries(objectEntries(obj))
|
|
278
376
|
}
|
|
279
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Create an object from entries with sorted keys.
|
|
380
|
+
* @param {Iterable<[string | symbol, any]>} entries - The entries to create an object from.
|
|
381
|
+
* @returns {Object} A new object with keys in sorted order.
|
|
382
|
+
*/
|
|
280
383
|
/*@__NO_SIDE_EFFECTS__*/
|
|
281
384
|
function toSortedObjectFromEntries(entries) {
|
|
282
385
|
const otherEntries = []
|