@socketsecurity/lib 5.25.1 → 5.26.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/CHANGELOG.md +344 -1184
- package/README.md +1 -1
- package/dist/abort.js +7 -6
- package/dist/agent.js +16 -15
- package/dist/ansi.js +3 -2
- package/dist/archives.js +18 -17
- package/dist/argv/flags.js +29 -28
- package/dist/argv/parse.js +4 -3
- package/dist/arrays.js +3 -2
- package/dist/bin.js +12 -11
- package/dist/cacache.js +16 -11
- package/dist/cache-with-ttl.js +26 -21
- package/dist/colors.js +2 -1
- package/dist/constants/licenses.js +2 -1
- package/dist/constants/lifecycle-script-names.js +2 -1
- package/dist/constants/maintained-node-versions.js +2 -1
- package/dist/constants/node.js +4 -3
- package/dist/constants/package-default-socket-categories.js +2 -1
- package/dist/constants/packages.js +4 -3
- package/dist/constants/socket.js +1 -1
- package/dist/cover/code.js +9 -8
- package/dist/cover/formatters.js +12 -11
- package/dist/cover/type.js +5 -4
- package/dist/crypto.d.ts +36 -0
- package/dist/{effects/ultra.js → crypto.js} +33 -37
- package/dist/debug.js +12 -15
- package/dist/dlx/arborist.js +10 -9
- package/dist/dlx/binary.js +27 -24
- package/dist/dlx/cache.js +2 -10
- package/dist/dlx/detect.js +6 -5
- package/dist/dlx/integrity.js +13 -11
- package/dist/dlx/lockfile.js +7 -6
- package/dist/dlx/manifest.js +6 -5
- package/dist/dlx/package.js +17 -16
- package/dist/dlx/packages.js +6 -5
- package/dist/dlx/paths.d.ts +1 -1
- package/dist/dlx/paths.js +2 -1
- package/dist/effects/pulse-frames.js +4 -3
- package/dist/effects/shimmer-keyframes.d.ts +62 -0
- package/dist/effects/shimmer-keyframes.js +55 -0
- package/dist/effects/shimmer-terminal.d.ts +66 -0
- package/dist/effects/shimmer-terminal.js +57 -0
- package/dist/effects/shimmer.d.ts +293 -0
- package/dist/effects/shimmer.js +180 -0
- package/dist/env/rewire.js +4 -3
- package/dist/env.js +5 -4
- package/dist/errors.js +1 -1
- package/dist/external/@npmcli/package-json/lib/read-package.js +10 -10
- package/dist/external/@npmcli/package-json.js +372 -372
- package/dist/external/@npmcli/promise-spawn.js +24 -24
- package/dist/external/@socketregistry/packageurl-js.js +19 -18
- package/dist/external/@socketregistry/yocto-spinner.js +4 -3
- package/dist/external/@yarnpkg/extensions.js +2 -1
- package/dist/external/adm-zip.js +70 -70
- package/dist/external/debug.js +22 -22
- package/dist/external/external-pack.js +45 -45
- package/dist/external/fast-sort.js +5 -5
- package/dist/external/libnpmexec.js +4 -3
- package/dist/external/npm-pack.js +369 -369
- package/dist/external/p-map.js +9 -9
- package/dist/external/pico-pack.js +190 -190
- package/dist/external/pony-cause.js +2 -1
- package/dist/external/spdx-pack.js +11 -10
- package/dist/external/tar-fs.js +58 -58
- package/dist/external/which.js +13 -13
- package/dist/external/yargs-parser.js +71 -71
- package/dist/fs.js +19 -23
- package/dist/git.js +14 -13
- package/dist/github.d.ts +34 -0
- package/dist/github.js +248 -23
- package/dist/globs.d.ts +20 -0
- package/dist/globs.js +134 -25
- package/dist/http-request.d.ts +4 -3
- package/dist/http-request.js +39 -32
- package/dist/ipc-cli.js +2 -1
- package/dist/ipc.js +5 -4
- package/dist/json/edit.js +4 -3
- package/dist/json/format.js +3 -2
- package/dist/json/parse.js +7 -6
- package/dist/links.js +2 -1
- package/dist/logger.js +21 -14
- package/dist/memoization.js +16 -15
- package/dist/objects.js +2 -2
- package/dist/packages/edit.js +8 -7
- package/dist/packages/exports.js +17 -16
- package/dist/packages/isolation.js +20 -13
- package/dist/packages/licenses.js +6 -3
- package/dist/packages/manifest.js +2 -1
- package/dist/packages/normalize.js +8 -4
- package/dist/packages/operations.js +5 -4
- package/dist/packages/provenance.js +7 -6
- package/dist/packages/specs.js +2 -1
- package/dist/packages/validation.js +2 -1
- package/dist/paths/normalize.js +32 -40
- package/dist/paths/packages.js +2 -1
- package/dist/paths/rewire.js +3 -2
- package/dist/performance.js +19 -18
- package/dist/primordials.d.ts +9 -0
- package/dist/primordials.js +17 -0
- package/dist/process-lock.js +14 -13
- package/dist/promise-queue.js +17 -9
- package/dist/promises.d.ts +29 -6
- package/dist/promises.js +19 -15
- package/dist/regexps.js +9 -8
- package/dist/releases/github-api.d.ts +56 -0
- package/dist/releases/github-api.js +275 -0
- package/dist/releases/github-archives.d.ts +60 -0
- package/dist/releases/github-archives.js +136 -0
- package/dist/releases/github-assets.d.ts +21 -0
- package/dist/releases/github-assets.js +52 -0
- package/dist/releases/github-auth.d.ts +16 -0
- package/dist/releases/github-auth.js +51 -0
- package/dist/releases/github-downloads.d.ts +42 -0
- package/dist/releases/github-downloads.js +155 -0
- package/dist/releases/github-types.d.ts +66 -0
- package/dist/{effects/types.js → releases/github-types.js} +2 -2
- package/dist/releases/socket-btm.d.ts +1 -1
- package/dist/releases/socket-btm.js +17 -17
- package/dist/schema/parse.js +2 -1
- package/dist/schema/validate.js +6 -5
- package/dist/shadow.js +2 -1
- package/dist/signal-exit.js +2 -2
- package/dist/spawn.js +45 -35
- package/dist/spinner.d.ts +13 -6
- package/dist/spinner.js +75 -57
- package/dist/ssri.js +8 -7
- package/dist/stdio/footer.js +13 -12
- package/dist/stdio/header.js +5 -4
- package/dist/stdio/progress.js +13 -12
- package/dist/strings.js +19 -18
- package/dist/suppress-warnings.js +2 -2
- package/dist/tables.js +16 -13
- package/dist/temporary-executor.js +2 -1
- package/dist/themes/context.js +2 -1
- package/dist/themes/types.d.ts +1 -1
- package/dist/themes/utils.d.ts +8 -3
- package/dist/themes/utils.js +29 -5
- package/dist/url.js +4 -3
- package/package.json +44 -20
- package/dist/effects/text-shimmer.d.ts +0 -58
- package/dist/effects/text-shimmer.js +0 -192
- package/dist/effects/types.d.ts +0 -47
- package/dist/effects/ultra.d.ts +0 -22
- package/dist/releases/github.d.ts +0 -234
- package/dist/releases/github.js +0 -417
- package/dist/themes/index.d.ts +0 -49
- package/dist/themes/index.js +0 -60
package/dist/spinner.js
CHANGED
|
@@ -46,7 +46,8 @@ var import_process = require("./constants/process");
|
|
|
46
46
|
var import_ci = require("./env/ci");
|
|
47
47
|
var import_debug = require("./debug");
|
|
48
48
|
var import_pulse_frames = require("./effects/pulse-frames");
|
|
49
|
-
var
|
|
49
|
+
var import_shimmer = require("./effects/shimmer");
|
|
50
|
+
var import_shimmer_terminal = require("./effects/shimmer-terminal");
|
|
50
51
|
var import_yocto_spinner = __toESM(require("./external/@socketregistry/yocto-spinner"));
|
|
51
52
|
var import_logger = require("./logger");
|
|
52
53
|
var import_objects = require("./objects");
|
|
@@ -54,6 +55,8 @@ var import_strings = require("./strings");
|
|
|
54
55
|
var import_context = require("./themes/context");
|
|
55
56
|
var import_themes = require("./themes/themes");
|
|
56
57
|
var import_utils = require("./themes/utils");
|
|
58
|
+
var import_primordials = require("./primordials");
|
|
59
|
+
const COLOR_INHERIT = "inherit";
|
|
57
60
|
const ciSpinner = {
|
|
58
61
|
frames: [""],
|
|
59
62
|
interval: 2147483647
|
|
@@ -68,7 +71,7 @@ function desc(value) {
|
|
|
68
71
|
}
|
|
69
72
|
function formatProgress(progress) {
|
|
70
73
|
const { current, total, unit } = progress;
|
|
71
|
-
const percentage = total === 0 ? 0 :
|
|
74
|
+
const percentage = total === 0 ? 0 : (0, import_primordials.MathRound)(current / total * 100);
|
|
72
75
|
const bar = renderProgressBar(percentage);
|
|
73
76
|
const count = unit ? `${current}/${total} ${unit}` : `${current}/${total}`;
|
|
74
77
|
return `${bar} ${percentage}% (${count})`;
|
|
@@ -77,11 +80,11 @@ function normalizeText(value) {
|
|
|
77
80
|
return typeof value === "string" ? value.trimStart() : "";
|
|
78
81
|
}
|
|
79
82
|
function renderProgressBar(percentage, width = 20) {
|
|
80
|
-
const filled =
|
|
83
|
+
const filled = (0, import_primordials.MathMax)(
|
|
81
84
|
0,
|
|
82
85
|
Math.min(width, Math.round(percentage / 100 * width))
|
|
83
86
|
);
|
|
84
|
-
const empty =
|
|
87
|
+
const empty = (0, import_primordials.MathMax)(0, width - filled);
|
|
85
88
|
const bar = "\u2588".repeat(filled) + "\u2591".repeat(empty);
|
|
86
89
|
return import_yoctocolors_cjs.default.cyan(bar);
|
|
87
90
|
}
|
|
@@ -141,7 +144,7 @@ function Spinner(options) {
|
|
|
141
144
|
theme.effects.spinner.color,
|
|
142
145
|
theme.colors
|
|
143
146
|
);
|
|
144
|
-
if (resolved === "inherit" ||
|
|
147
|
+
if (resolved === "inherit" || (0, import_primordials.ArrayIsArray)(resolved[0])) {
|
|
145
148
|
defaultColor = theme.colors.primary;
|
|
146
149
|
} else {
|
|
147
150
|
defaultColor = resolved;
|
|
@@ -151,7 +154,7 @@ function Spinner(options) {
|
|
|
151
154
|
if ((0, import_colors.isRgbTuple)(spinnerColor) && (spinnerColor.length !== 3 || !spinnerColor.every(
|
|
152
155
|
(n) => typeof n === "number" && n >= 0 && n <= 255
|
|
153
156
|
))) {
|
|
154
|
-
throw new
|
|
157
|
+
throw new import_primordials.TypeErrorCtor(
|
|
155
158
|
"RGB color must be an array of 3 numbers between 0 and 255"
|
|
156
159
|
);
|
|
157
160
|
}
|
|
@@ -163,22 +166,22 @@ function Spinner(options) {
|
|
|
163
166
|
let shimmerSpeed = 1 / 3;
|
|
164
167
|
if (typeof opts.shimmer === "string") {
|
|
165
168
|
shimmerDir = opts.shimmer;
|
|
169
|
+
shimmerColor = COLOR_INHERIT;
|
|
166
170
|
} else {
|
|
167
171
|
const shimmerConfig = {
|
|
168
172
|
__proto__: null,
|
|
169
173
|
...opts.shimmer
|
|
170
174
|
};
|
|
171
|
-
shimmerDir = shimmerConfig.dir ??
|
|
172
|
-
shimmerColor = shimmerConfig.color ??
|
|
175
|
+
shimmerDir = shimmerConfig.dir ?? "ltr";
|
|
176
|
+
shimmerColor = shimmerConfig.color ?? COLOR_INHERIT;
|
|
173
177
|
shimmerSpeed = shimmerConfig.speed ?? 1 / 3;
|
|
174
178
|
}
|
|
175
179
|
shimmerInfo = {
|
|
176
180
|
__proto__: null,
|
|
177
|
-
color: shimmerColor
|
|
178
|
-
|
|
179
|
-
mode: shimmerDir,
|
|
181
|
+
color: shimmerColor,
|
|
182
|
+
direction: shimmerDir,
|
|
180
183
|
speed: shimmerSpeed,
|
|
181
|
-
|
|
184
|
+
frame: 0
|
|
182
185
|
};
|
|
183
186
|
}
|
|
184
187
|
super({
|
|
@@ -219,11 +222,11 @@ function Spinner(options) {
|
|
|
219
222
|
return void 0;
|
|
220
223
|
}
|
|
221
224
|
return {
|
|
225
|
+
__proto__: null,
|
|
222
226
|
color: this.#shimmer.color,
|
|
223
|
-
|
|
224
|
-
mode: this.#shimmer.mode,
|
|
227
|
+
direction: this.#shimmer.direction,
|
|
225
228
|
speed: this.#shimmer.speed,
|
|
226
|
-
|
|
229
|
+
frame: this.#shimmer.frame
|
|
227
230
|
};
|
|
228
231
|
}
|
|
229
232
|
/**
|
|
@@ -233,9 +236,9 @@ function Spinner(options) {
|
|
|
233
236
|
*/
|
|
234
237
|
#apply(methodName, args) {
|
|
235
238
|
let extras;
|
|
236
|
-
let text =
|
|
239
|
+
let text = (0, import_primordials.ArrayPrototypeAt)(args, 0);
|
|
237
240
|
if (typeof text === "string") {
|
|
238
|
-
extras =
|
|
241
|
+
extras = (0, import_primordials.ArrayPrototypeSlice)(args, 1);
|
|
239
242
|
} else {
|
|
240
243
|
extras = args;
|
|
241
244
|
text = "";
|
|
@@ -275,17 +278,27 @@ function Spinner(options) {
|
|
|
275
278
|
}
|
|
276
279
|
if (displayText && this.#shimmer) {
|
|
277
280
|
let shimmerColor;
|
|
278
|
-
if (this.#shimmer.color ===
|
|
281
|
+
if (this.#shimmer.color === COLOR_INHERIT) {
|
|
279
282
|
shimmerColor = this.color;
|
|
280
|
-
} else if (
|
|
283
|
+
} else if ((0, import_primordials.ArrayIsArray)(this.#shimmer.color[0])) {
|
|
281
284
|
shimmerColor = this.#shimmer.color;
|
|
282
285
|
} else {
|
|
283
286
|
shimmerColor = (0, import_colors.toRgb)(this.#shimmer.color);
|
|
284
287
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
288
|
+
if (!(0, import_ci.getCI)() && this.#shimmer.direction !== "none") {
|
|
289
|
+
const chars = [...displayText];
|
|
290
|
+
const spec = (0, import_shimmer.configToSpec)(
|
|
291
|
+
{
|
|
292
|
+
color: shimmerColor,
|
|
293
|
+
dir: this.#shimmer.direction,
|
|
294
|
+
speed: this.#shimmer.speed
|
|
295
|
+
},
|
|
296
|
+
chars.length
|
|
297
|
+
);
|
|
298
|
+
const colors2 = (0, import_shimmer.frameColors)(spec, chars.length, this.#shimmer.frame);
|
|
299
|
+
displayText = (0, import_shimmer_terminal.colorsToAnsi)(displayText, colors2);
|
|
300
|
+
this.#shimmer.frame++;
|
|
301
|
+
}
|
|
289
302
|
}
|
|
290
303
|
if (this.#indentation && displayText) {
|
|
291
304
|
displayText = this.#indentation + displayText;
|
|
@@ -298,10 +311,10 @@ function Spinner(options) {
|
|
|
298
311
|
* @private
|
|
299
312
|
*/
|
|
300
313
|
#showStatusAndKeepSpinning(symbolType, args) {
|
|
301
|
-
let text =
|
|
314
|
+
let text = (0, import_primordials.ArrayPrototypeAt)(args, 0);
|
|
302
315
|
let extras;
|
|
303
316
|
if (typeof text === "string") {
|
|
304
|
-
extras =
|
|
317
|
+
extras = (0, import_primordials.ArrayPrototypeSlice)(args, 1);
|
|
305
318
|
} else {
|
|
306
319
|
extras = args;
|
|
307
320
|
text = "";
|
|
@@ -367,7 +380,7 @@ function Spinner(options) {
|
|
|
367
380
|
this.#indentation = "";
|
|
368
381
|
} else {
|
|
369
382
|
const amount = spaces ?? 2;
|
|
370
|
-
const newLength =
|
|
383
|
+
const newLength = (0, import_primordials.MathMax)(0, this.#indentation.length - amount);
|
|
371
384
|
this.#indentation = this.#indentation.slice(0, newLength);
|
|
372
385
|
}
|
|
373
386
|
this.#updateSpinnerText();
|
|
@@ -423,14 +436,14 @@ function Spinner(options) {
|
|
|
423
436
|
*/
|
|
424
437
|
enableShimmer() {
|
|
425
438
|
if (this.#shimmerSavedConfig) {
|
|
426
|
-
this.#shimmer = { ...this.#shimmerSavedConfig };
|
|
439
|
+
this.#shimmer = { ...this.#shimmerSavedConfig, frame: 0 };
|
|
427
440
|
} else {
|
|
428
441
|
this.#shimmer = {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
442
|
+
__proto__: null,
|
|
443
|
+
color: COLOR_INHERIT,
|
|
444
|
+
direction: "ltr",
|
|
432
445
|
speed: 1 / 3,
|
|
433
|
-
|
|
446
|
+
frame: 0
|
|
434
447
|
};
|
|
435
448
|
this.#shimmerSavedConfig = this.#shimmer;
|
|
436
449
|
}
|
|
@@ -576,7 +589,7 @@ function Spinner(options) {
|
|
|
576
589
|
const newCurrent = this.#progress.current + amount;
|
|
577
590
|
this.#progress = {
|
|
578
591
|
__proto__: null,
|
|
579
|
-
current:
|
|
592
|
+
current: (0, import_primordials.MathMax)(0, Math.min(newCurrent, this.#progress.total)),
|
|
580
593
|
total: this.#progress.total,
|
|
581
594
|
...this.#progress.unit ? { unit: this.#progress.unit } : {}
|
|
582
595
|
};
|
|
@@ -633,11 +646,11 @@ function Spinner(options) {
|
|
|
633
646
|
*/
|
|
634
647
|
setShimmer(config) {
|
|
635
648
|
this.#shimmer = {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
649
|
+
__proto__: null,
|
|
650
|
+
color: config.color ?? COLOR_INHERIT,
|
|
651
|
+
direction: config.dir ?? "ltr",
|
|
639
652
|
speed: config.speed ?? 1 / 3,
|
|
640
|
-
|
|
653
|
+
frame: 0
|
|
641
654
|
};
|
|
642
655
|
this.#shimmerSavedConfig = this.#shimmer;
|
|
643
656
|
this.#updateSpinnerText();
|
|
@@ -659,7 +672,7 @@ function Spinner(options) {
|
|
|
659
672
|
*/
|
|
660
673
|
start(...args) {
|
|
661
674
|
if (args.length) {
|
|
662
|
-
const text =
|
|
675
|
+
const text = (0, import_primordials.ArrayPrototypeAt)(args, 0);
|
|
663
676
|
const normalized = normalizeText(text);
|
|
664
677
|
if (!normalized) {
|
|
665
678
|
this.#baseText = "";
|
|
@@ -794,32 +807,37 @@ function Spinner(options) {
|
|
|
794
807
|
__proto__: null,
|
|
795
808
|
...config
|
|
796
809
|
};
|
|
810
|
+
const update = {
|
|
811
|
+
__proto__: null
|
|
812
|
+
};
|
|
813
|
+
if (partialConfig.color !== void 0) {
|
|
814
|
+
update.color = partialConfig.color;
|
|
815
|
+
}
|
|
816
|
+
if (partialConfig.dir !== void 0) {
|
|
817
|
+
update.direction = partialConfig.dir;
|
|
818
|
+
}
|
|
819
|
+
if (partialConfig.speed !== void 0) {
|
|
820
|
+
update.speed = partialConfig.speed;
|
|
821
|
+
}
|
|
797
822
|
if (this.#shimmer) {
|
|
798
|
-
this.#shimmer = {
|
|
799
|
-
...this.#shimmer,
|
|
800
|
-
...partialConfig.color !== void 0 ? { color: partialConfig.color } : {},
|
|
801
|
-
...partialConfig.dir !== void 0 ? { mode: partialConfig.dir } : {},
|
|
802
|
-
...partialConfig.speed !== void 0 ? { speed: partialConfig.speed } : {}
|
|
803
|
-
};
|
|
804
|
-
this.#shimmerSavedConfig = this.#shimmer;
|
|
823
|
+
this.#shimmer = { ...this.#shimmer, ...update };
|
|
805
824
|
} else if (this.#shimmerSavedConfig) {
|
|
806
825
|
this.#shimmer = {
|
|
807
826
|
...this.#shimmerSavedConfig,
|
|
808
|
-
...
|
|
809
|
-
|
|
810
|
-
...partialConfig.speed !== void 0 ? { speed: partialConfig.speed } : {}
|
|
827
|
+
...update,
|
|
828
|
+
frame: 0
|
|
811
829
|
};
|
|
812
|
-
this.#shimmerSavedConfig = this.#shimmer;
|
|
813
830
|
} else {
|
|
814
831
|
this.#shimmer = {
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
speed:
|
|
819
|
-
|
|
832
|
+
__proto__: null,
|
|
833
|
+
color: COLOR_INHERIT,
|
|
834
|
+
direction: "ltr",
|
|
835
|
+
speed: 1 / 3,
|
|
836
|
+
frame: 0,
|
|
837
|
+
...update
|
|
820
838
|
};
|
|
821
|
-
this.#shimmerSavedConfig = this.#shimmer;
|
|
822
839
|
}
|
|
840
|
+
this.#shimmerSavedConfig = this.#shimmer;
|
|
823
841
|
this.#updateSpinnerText();
|
|
824
842
|
return this;
|
|
825
843
|
}
|
|
@@ -846,7 +864,7 @@ function Spinner(options) {
|
|
|
846
864
|
return this.#apply("warning", [text, ...extras]);
|
|
847
865
|
}
|
|
848
866
|
};
|
|
849
|
-
|
|
867
|
+
(0, import_primordials.ObjectDefineProperties)(_Spinner.prototype, {
|
|
850
868
|
error: desc(_Spinner.prototype.fail),
|
|
851
869
|
errorAndStop: desc(_Spinner.prototype.failAndStop),
|
|
852
870
|
warning: desc(_Spinner.prototype.warn),
|
|
@@ -895,7 +913,7 @@ async function withSpinner(options) {
|
|
|
895
913
|
if (savedShimmerState) {
|
|
896
914
|
spinner.setShimmer({
|
|
897
915
|
color: savedShimmerState.color,
|
|
898
|
-
dir: savedShimmerState.
|
|
916
|
+
dir: savedShimmerState.direction,
|
|
899
917
|
speed: savedShimmerState.speed
|
|
900
918
|
});
|
|
901
919
|
} else {
|
|
@@ -949,7 +967,7 @@ function withSpinnerSync(options) {
|
|
|
949
967
|
if (savedShimmerState) {
|
|
950
968
|
spinner.setShimmer({
|
|
951
969
|
color: savedShimmerState.color,
|
|
952
|
-
dir: savedShimmerState.
|
|
970
|
+
dir: savedShimmerState.direction,
|
|
953
971
|
speed: savedShimmerState.speed
|
|
954
972
|
});
|
|
955
973
|
} else {
|
package/dist/ssri.js
CHANGED
|
@@ -27,13 +27,14 @@ __export(ssri_exports, {
|
|
|
27
27
|
ssriToHex: () => ssriToHex
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(ssri_exports);
|
|
30
|
+
var import_primordials = require("./primordials");
|
|
30
31
|
// @__NO_SIDE_EFFECTS__
|
|
31
32
|
function hexToSsri(hex, algorithm = "sha256") {
|
|
32
33
|
if (!/^[a-f0-9]+$/i.test(hex)) {
|
|
33
|
-
throw new
|
|
34
|
+
throw new import_primordials.ErrorCtor(`Invalid hex format: ${hex}`);
|
|
34
35
|
}
|
|
35
|
-
const buffer =
|
|
36
|
-
const base64Hash =
|
|
36
|
+
const buffer = (0, import_primordials.BufferFrom)(hex, "hex");
|
|
37
|
+
const base64Hash = (0, import_primordials.BufferPrototypeToString)(buffer, "base64");
|
|
37
38
|
return `${algorithm}-${base64Hash}`;
|
|
38
39
|
}
|
|
39
40
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -48,7 +49,7 @@ function isValidSsri(value) {
|
|
|
48
49
|
function parseSsri(ssri) {
|
|
49
50
|
const match = /^([a-z0-9]+)-([A-Za-z0-9+/]+=*)$/i.exec(ssri);
|
|
50
51
|
if (!match || !match[1] || !match[2] || match[2].length < 2) {
|
|
51
|
-
throw new
|
|
52
|
+
throw new import_primordials.ErrorCtor(`Invalid SSRI format: ${ssri}`);
|
|
52
53
|
}
|
|
53
54
|
const algorithm = match[1];
|
|
54
55
|
const base64Hash = match[2];
|
|
@@ -58,11 +59,11 @@ function parseSsri(ssri) {
|
|
|
58
59
|
function ssriToHex(ssri) {
|
|
59
60
|
const match = /^([a-z0-9]+)-([A-Za-z0-9+/]+=*)$/i.exec(ssri);
|
|
60
61
|
if (!match || !match[2] || match[2].length < 2) {
|
|
61
|
-
throw new
|
|
62
|
+
throw new import_primordials.ErrorCtor(`Invalid SSRI format: ${ssri}`);
|
|
62
63
|
}
|
|
63
64
|
const base64Hash = match[2];
|
|
64
|
-
const buffer =
|
|
65
|
-
return
|
|
65
|
+
const buffer = (0, import_primordials.BufferFrom)(base64Hash, "base64");
|
|
66
|
+
return (0, import_primordials.BufferPrototypeToString)(buffer, "hex");
|
|
66
67
|
}
|
|
67
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
68
69
|
0 && (module.exports = {
|
package/dist/stdio/footer.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(footer_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(footer_exports);
|
|
38
38
|
var import_yoctocolors_cjs = __toESM(require("../external/yoctocolors-cjs"));
|
|
39
39
|
var import_strings = require("../strings");
|
|
40
|
+
var import_primordials = require("../primordials");
|
|
40
41
|
function createFooter(message, options) {
|
|
41
42
|
const {
|
|
42
43
|
borderChar = "=",
|
|
@@ -50,39 +51,39 @@ function createFooter(message, options) {
|
|
|
50
51
|
const lines = [];
|
|
51
52
|
if (message) {
|
|
52
53
|
const colorFn = color && import_yoctocolors_cjs.default[color] ? import_yoctocolors_cjs.default[color] : (s) => s;
|
|
53
|
-
|
|
54
|
+
(0, import_primordials.ArrayPrototypePush)(lines, colorFn(message));
|
|
54
55
|
}
|
|
55
56
|
if (showTimestamp) {
|
|
56
|
-
const timestamp =
|
|
57
|
-
|
|
57
|
+
const timestamp = new import_primordials.DateCtor().toISOString();
|
|
58
|
+
(0, import_primordials.ArrayPrototypePush)(lines, import_yoctocolors_cjs.default.gray(`Completed at: ${timestamp}`));
|
|
58
59
|
}
|
|
59
60
|
if (showDuration && startTime) {
|
|
60
|
-
const duration =
|
|
61
|
+
const duration = (0, import_primordials.DateNow)() - startTime;
|
|
61
62
|
const seconds = (duration / 1e3).toFixed(2);
|
|
62
|
-
|
|
63
|
+
(0, import_primordials.ArrayPrototypePush)(lines, import_yoctocolors_cjs.default.gray(`Duration: ${seconds}s`));
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
+
(0, import_primordials.ArrayPrototypePush)(lines, border);
|
|
65
66
|
return lines.join("\n");
|
|
66
67
|
}
|
|
67
68
|
function createSummaryFooter(stats, options) {
|
|
68
69
|
const parts = [];
|
|
69
70
|
if (stats.total !== void 0) {
|
|
70
|
-
|
|
71
|
+
(0, import_primordials.ArrayPrototypePush)(parts, `Total: ${stats.total}`);
|
|
71
72
|
}
|
|
72
73
|
if (stats.success !== void 0) {
|
|
73
|
-
|
|
74
|
+
(0, import_primordials.ArrayPrototypePush)(parts, import_yoctocolors_cjs.default.green(`\u2713 ${stats.success} passed`));
|
|
74
75
|
}
|
|
75
76
|
if (stats.failed !== void 0 && stats.failed > 0) {
|
|
76
|
-
|
|
77
|
+
(0, import_primordials.ArrayPrototypePush)(parts, import_yoctocolors_cjs.default.red(`\u2717 ${stats.failed} failed`));
|
|
77
78
|
}
|
|
78
79
|
if (stats.skipped !== void 0 && stats.skipped > 0) {
|
|
79
|
-
|
|
80
|
+
(0, import_primordials.ArrayPrototypePush)(parts, import_yoctocolors_cjs.default.yellow(`\u25CB ${stats.skipped} skipped`));
|
|
80
81
|
}
|
|
81
82
|
if (stats.warnings !== void 0 && stats.warnings > 0) {
|
|
82
|
-
|
|
83
|
+
(0, import_primordials.ArrayPrototypePush)(parts, import_yoctocolors_cjs.default.yellow(`\u26A0 ${stats.warnings} warnings`));
|
|
83
84
|
}
|
|
84
85
|
if (stats.errors !== void 0 && stats.errors > 0) {
|
|
85
|
-
|
|
86
|
+
(0, import_primordials.ArrayPrototypePush)(parts, import_yoctocolors_cjs.default.red(`\u2717 ${stats.errors} errors`));
|
|
86
87
|
}
|
|
87
88
|
const message = parts.join(" | ");
|
|
88
89
|
return createFooter(message, {
|
package/dist/stdio/header.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(header_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(header_exports);
|
|
38
38
|
var import_yoctocolors_cjs = __toESM(require("../external/yoctocolors-cjs"));
|
|
39
39
|
var import_strings = require("../strings");
|
|
40
|
+
var import_primordials = require("../primordials");
|
|
40
41
|
function createHeader(title, options) {
|
|
41
42
|
const {
|
|
42
43
|
bold = true,
|
|
@@ -57,13 +58,13 @@ function createHeader(title, options) {
|
|
|
57
58
|
const paddingLine = (0, import_strings.repeatString)(" ", width);
|
|
58
59
|
const lines = [border];
|
|
59
60
|
for (let i = 0; i < padding; i++) {
|
|
60
|
-
|
|
61
|
+
(0, import_primordials.ArrayPrototypePush)(lines, paddingLine);
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
(0, import_primordials.ArrayPrototypePush)(lines, centeredTitle);
|
|
63
64
|
for (let i = 0; i < padding; i++) {
|
|
64
|
-
|
|
65
|
+
(0, import_primordials.ArrayPrototypePush)(lines, paddingLine);
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
+
(0, import_primordials.ArrayPrototypePush)(lines, border);
|
|
67
68
|
return lines.join("\n");
|
|
68
69
|
}
|
|
69
70
|
function createSectionHeader(title, options) {
|
package/dist/stdio/progress.js
CHANGED
|
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(progress_exports);
|
|
|
37
37
|
var import_node_process = __toESM(require("node:process"));
|
|
38
38
|
var import_yoctocolors_cjs = __toESM(require("../external/yoctocolors-cjs"));
|
|
39
39
|
var import_strings = require("../strings");
|
|
40
|
+
var import_primordials = require("../primordials");
|
|
40
41
|
class ProgressBar {
|
|
41
42
|
current = 0;
|
|
42
43
|
total;
|
|
@@ -63,7 +64,7 @@ class ProgressBar {
|
|
|
63
64
|
*/
|
|
64
65
|
constructor(total, options) {
|
|
65
66
|
this.total = total;
|
|
66
|
-
this.startTime =
|
|
67
|
+
this.startTime = (0, import_primordials.DateNow)();
|
|
67
68
|
this.stream = options?.stream || import_node_process.default.stderr;
|
|
68
69
|
this.options = {
|
|
69
70
|
width: 40,
|
|
@@ -96,8 +97,8 @@ class ProgressBar {
|
|
|
96
97
|
if (this.terminated) {
|
|
97
98
|
return;
|
|
98
99
|
}
|
|
99
|
-
this.current =
|
|
100
|
-
const now =
|
|
100
|
+
this.current = (0, import_primordials.MathMin)(current, this.total);
|
|
101
|
+
const now = (0, import_primordials.DateNow)();
|
|
101
102
|
if (now - this.lastRender < (this.options.renderThrottle ?? 16) && this.current < this.total) {
|
|
102
103
|
return;
|
|
103
104
|
}
|
|
@@ -131,27 +132,27 @@ class ProgressBar {
|
|
|
131
132
|
render(tokens) {
|
|
132
133
|
const colorName = this.options.color ?? "cyan";
|
|
133
134
|
const colorFn = import_yoctocolors_cjs.default[colorName] || ((s) => s);
|
|
134
|
-
const percent = this.total === 0 ? 0 :
|
|
135
|
-
const elapsed =
|
|
135
|
+
const percent = this.total === 0 ? 0 : (0, import_primordials.MathFloor)(this.current / this.total * 100);
|
|
136
|
+
const elapsed = (0, import_primordials.DateNow)() - this.startTime;
|
|
136
137
|
const eta = this.current === 0 ? 0 : elapsed / this.current * (this.total - this.current);
|
|
137
138
|
const availableWidth = this.options.width ?? 40;
|
|
138
|
-
const filledWidth = this.total === 0 ? 0 :
|
|
139
|
+
const filledWidth = this.total === 0 ? 0 : (0, import_primordials.MathMin)(
|
|
139
140
|
availableWidth,
|
|
140
141
|
Math.floor(this.current / this.total * availableWidth)
|
|
141
142
|
);
|
|
142
|
-
const emptyWidth =
|
|
143
|
+
const emptyWidth = (0, import_primordials.MathMax)(0, availableWidth - filledWidth);
|
|
143
144
|
const filled = (0, import_strings.repeatString)(this.options.complete ?? "\u2588", filledWidth);
|
|
144
145
|
const empty = (0, import_strings.repeatString)(this.options.incomplete ?? "\u2591", emptyWidth);
|
|
145
146
|
const bar = colorFn(filled) + empty;
|
|
146
147
|
let output = this.options.format ?? ":bar :percent :current/:total";
|
|
147
|
-
output =
|
|
148
|
+
output = (0, import_primordials.StringPrototypeReplace)(output, ":bar", bar);
|
|
148
149
|
output = output.replace(":percent", `${percent}%`);
|
|
149
150
|
output = output.replace(":current", String(this.current));
|
|
150
151
|
output = output.replace(":total", String(this.total));
|
|
151
152
|
output = output.replace(":elapsed", this.formatTime(elapsed));
|
|
152
153
|
output = output.replace(":eta", this.formatTime(eta));
|
|
153
154
|
if (tokens) {
|
|
154
|
-
for (const [key, value] of
|
|
155
|
+
for (const [key, value] of (0, import_primordials.ObjectEntries)(tokens)) {
|
|
155
156
|
output = output.replace(`:${key}`, String(value));
|
|
156
157
|
}
|
|
157
158
|
}
|
|
@@ -174,11 +175,11 @@ class ProgressBar {
|
|
|
174
175
|
* Format time in seconds to human readable.
|
|
175
176
|
*/
|
|
176
177
|
formatTime(ms) {
|
|
177
|
-
const seconds =
|
|
178
|
+
const seconds = (0, import_primordials.MathMax)(0, Math.round(ms / 1e3));
|
|
178
179
|
if (seconds < 60) {
|
|
179
180
|
return `${seconds}s`;
|
|
180
181
|
}
|
|
181
|
-
const minutes =
|
|
182
|
+
const minutes = (0, import_primordials.MathFloor)(seconds / 60);
|
|
182
183
|
const remainingSeconds = seconds % 60;
|
|
183
184
|
return `${minutes}m${remainingSeconds}s`;
|
|
184
185
|
}
|
|
@@ -201,7 +202,7 @@ class ProgressBar {
|
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
204
|
function createProgressIndicator(current, total, label) {
|
|
204
|
-
const percent = total === 0 ? 0 :
|
|
205
|
+
const percent = total === 0 ? 0 : (0, import_primordials.MathFloor)(current / total * 100);
|
|
205
206
|
const progress = `${current}/${total}`;
|
|
206
207
|
let output = "";
|
|
207
208
|
if (label) {
|
package/dist/strings.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(strings_exports, {
|
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(strings_exports);
|
|
39
39
|
var import_ansi = require("./ansi");
|
|
40
|
+
var import_primordials = require("./primordials");
|
|
40
41
|
let _eastAsianWidth;
|
|
41
42
|
// @__NO_SIDE_EFFECTS__
|
|
42
43
|
function getEastAsianWidth() {
|
|
@@ -52,7 +53,7 @@ function applyLinePrefix(str, options) {
|
|
|
52
53
|
__proto__: null,
|
|
53
54
|
...options
|
|
54
55
|
};
|
|
55
|
-
return prefix.length ? `${prefix}${
|
|
56
|
+
return prefix.length ? `${prefix}${(0, import_primordials.StringPrototypeIncludes)(str, "\n") ? str.replace(/\n/g, `
|
|
56
57
|
${prefix}`) : str}` : str;
|
|
57
58
|
}
|
|
58
59
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -62,7 +63,7 @@ function centerText(text, width) {
|
|
|
62
63
|
return text;
|
|
63
64
|
}
|
|
64
65
|
const padding = width - textLength;
|
|
65
|
-
const leftPad =
|
|
66
|
+
const leftPad = (0, import_primordials.MathFloor)(padding / 2);
|
|
66
67
|
const rightPad = padding - leftPad;
|
|
67
68
|
return " ".repeat(leftPad) + text + " ".repeat(rightPad);
|
|
68
69
|
}
|
|
@@ -84,7 +85,7 @@ function repeatString(str, count) {
|
|
|
84
85
|
if (count <= 0) {
|
|
85
86
|
return "";
|
|
86
87
|
}
|
|
87
|
-
return
|
|
88
|
+
return (0, import_primordials.StringPrototypeRepeat)(str, count);
|
|
88
89
|
}
|
|
89
90
|
// @__NO_SIDE_EFFECTS__
|
|
90
91
|
function search(str, regexp, options) {
|
|
@@ -94,10 +95,10 @@ function search(str, regexp, options) {
|
|
|
94
95
|
return -1;
|
|
95
96
|
}
|
|
96
97
|
if (fromIndex === 0) {
|
|
97
|
-
return
|
|
98
|
+
return (0, import_primordials.StringPrototypeSearch)(str, regexp);
|
|
98
99
|
}
|
|
99
|
-
const offset = fromIndex < 0 ?
|
|
100
|
-
const result =
|
|
100
|
+
const offset = fromIndex < 0 ? (0, import_primordials.MathMax)(length + fromIndex, 0) : fromIndex;
|
|
101
|
+
const result = (0, import_primordials.StringPrototypeSlice)(str, offset).search(regexp);
|
|
101
102
|
return result === -1 ? -1 : result + offset;
|
|
102
103
|
}
|
|
103
104
|
const segmenter = new Intl.Segmenter();
|
|
@@ -126,24 +127,24 @@ function stringWidth(text) {
|
|
|
126
127
|
const eastAsianWidthOptions = { ambiguousAsWide: false };
|
|
127
128
|
const eastAsianWidth = /* @__PURE__ */ getEastAsianWidth();
|
|
128
129
|
for (const { segment } of segmenter.segment(plainText)) {
|
|
129
|
-
if (
|
|
130
|
+
if ((0, import_primordials.RegExpPrototypeTest)(zeroWidthClusterRegex, segment)) {
|
|
130
131
|
continue;
|
|
131
132
|
}
|
|
132
|
-
if (
|
|
133
|
+
if ((0, import_primordials.RegExpPrototypeTest)(emojiRegex, segment)) {
|
|
133
134
|
width += 2;
|
|
134
135
|
continue;
|
|
135
136
|
}
|
|
136
137
|
const baseSegment = segment.replace(leadingNonPrintingRegex, "");
|
|
137
|
-
const codePoint =
|
|
138
|
+
const codePoint = (0, import_primordials.StringPrototypeCodePointAt)(baseSegment, 0);
|
|
138
139
|
if (codePoint === void 0) {
|
|
139
140
|
continue;
|
|
140
141
|
}
|
|
141
142
|
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
142
143
|
if (segment.length > 1) {
|
|
143
144
|
for (const char of segment.slice(1)) {
|
|
144
|
-
const charCode =
|
|
145
|
+
const charCode = (0, import_primordials.StringPrototypeCharCodeAt)(char, 0);
|
|
145
146
|
if (charCode >= 65280 && charCode <= 65519) {
|
|
146
|
-
const trailingCodePoint =
|
|
147
|
+
const trailingCodePoint = (0, import_primordials.StringPrototypeCodePointAt)(char, 0);
|
|
147
148
|
if (trailingCodePoint !== void 0) {
|
|
148
149
|
width += eastAsianWidth(trailingCodePoint, eastAsianWidthOptions);
|
|
149
150
|
}
|
|
@@ -155,14 +156,14 @@ function stringWidth(text) {
|
|
|
155
156
|
}
|
|
156
157
|
// @__NO_SIDE_EFFECTS__
|
|
157
158
|
function stripBom(str) {
|
|
158
|
-
return str.length > 0 &&
|
|
159
|
+
return str.length > 0 && (0, import_primordials.StringPrototypeCharCodeAt)(str, 0) === 65279 ? (0, import_primordials.StringPrototypeSlice)(str, 1) : str;
|
|
159
160
|
}
|
|
160
161
|
// @__NO_SIDE_EFFECTS__
|
|
161
162
|
function toKebabCase(str) {
|
|
162
163
|
if (!str.length) {
|
|
163
164
|
return str;
|
|
164
165
|
}
|
|
165
|
-
return
|
|
166
|
+
return (0, import_primordials.StringPrototypeReplace)(str, /([a-z]+[0-9]*)([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
|
|
166
167
|
}
|
|
167
168
|
// @__NO_SIDE_EFFECTS__
|
|
168
169
|
function trimNewlines(str) {
|
|
@@ -170,12 +171,12 @@ function trimNewlines(str) {
|
|
|
170
171
|
if (length === 0) {
|
|
171
172
|
return str;
|
|
172
173
|
}
|
|
173
|
-
const first =
|
|
174
|
+
const first = (0, import_primordials.StringPrototypeCharCodeAt)(str, 0);
|
|
174
175
|
const noFirstNewline = first !== 13 && first !== 10;
|
|
175
176
|
if (length === 1) {
|
|
176
177
|
return noFirstNewline ? str : "";
|
|
177
178
|
}
|
|
178
|
-
const last =
|
|
179
|
+
const last = (0, import_primordials.StringPrototypeCharCodeAt)(str, length - 1);
|
|
179
180
|
const noLastNewline = last !== 13 && last !== 10;
|
|
180
181
|
if (noFirstNewline && noLastNewline) {
|
|
181
182
|
return str;
|
|
@@ -183,20 +184,20 @@ function trimNewlines(str) {
|
|
|
183
184
|
let start = 0;
|
|
184
185
|
let end = length;
|
|
185
186
|
while (start < end) {
|
|
186
|
-
const code =
|
|
187
|
+
const code = (0, import_primordials.StringPrototypeCharCodeAt)(str, start);
|
|
187
188
|
if (code !== 13 && code !== 10) {
|
|
188
189
|
break;
|
|
189
190
|
}
|
|
190
191
|
start += 1;
|
|
191
192
|
}
|
|
192
193
|
while (end > start) {
|
|
193
|
-
const code =
|
|
194
|
+
const code = (0, import_primordials.StringPrototypeCharCodeAt)(str, end - 1);
|
|
194
195
|
if (code !== 13 && code !== 10) {
|
|
195
196
|
break;
|
|
196
197
|
}
|
|
197
198
|
end -= 1;
|
|
198
199
|
}
|
|
199
|
-
return start === 0 && end === length ? str :
|
|
200
|
+
return start === 0 && end === length ? str : (0, import_primordials.StringPrototypeSlice)(str, start, end);
|
|
200
201
|
}
|
|
201
202
|
// Annotate the CommonJS export names for ESM import in node:
|
|
202
203
|
0 && (module.exports = {
|
|
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(suppress_warnings_exports);
|
|
|
40
40
|
var import_node_process = __toESM(require("node:process"));
|
|
41
41
|
var import_primordials = require("./primordials");
|
|
42
42
|
let originalEmitWarning;
|
|
43
|
-
const suppressedWarnings =
|
|
43
|
+
const suppressedWarnings = new import_primordials.SetCtor();
|
|
44
44
|
function setupSuppression() {
|
|
45
45
|
if (!originalEmitWarning) {
|
|
46
46
|
originalEmitWarning = import_node_process.default.emitWarning;
|
|
@@ -76,7 +76,7 @@ function setMaxEventTargetListeners(target, maxListeners = 10) {
|
|
|
76
76
|
if (!target) {
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
const symbols =
|
|
79
|
+
const symbols = (0, import_primordials.ObjectGetOwnPropertySymbols)(target);
|
|
80
80
|
const kMaxEventTargetListeners = symbols.find(
|
|
81
81
|
(s) => s.description === "events.maxEventTargetListeners"
|
|
82
82
|
);
|