@socketsecurity/lib 5.26.0 → 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.
Files changed (147) hide show
  1. package/CHANGELOG.md +345 -1185
  2. package/README.md +1 -1
  3. package/dist/abort.js +7 -6
  4. package/dist/agent.js +16 -15
  5. package/dist/ansi.js +3 -2
  6. package/dist/archives.js +18 -17
  7. package/dist/argv/flags.js +29 -28
  8. package/dist/argv/parse.js +4 -3
  9. package/dist/arrays.js +3 -2
  10. package/dist/bin.js +12 -11
  11. package/dist/cacache.js +16 -11
  12. package/dist/cache-with-ttl.js +26 -21
  13. package/dist/colors.js +2 -1
  14. package/dist/constants/licenses.js +2 -1
  15. package/dist/constants/lifecycle-script-names.js +2 -1
  16. package/dist/constants/maintained-node-versions.js +2 -1
  17. package/dist/constants/node.js +4 -3
  18. package/dist/constants/package-default-socket-categories.js +2 -1
  19. package/dist/constants/packages.js +4 -3
  20. package/dist/constants/socket.js +1 -1
  21. package/dist/cover/code.js +9 -8
  22. package/dist/cover/formatters.js +12 -11
  23. package/dist/cover/type.js +5 -4
  24. package/dist/crypto.d.ts +36 -0
  25. package/dist/{effects/ultra.js → crypto.js} +33 -37
  26. package/dist/debug.js +12 -15
  27. package/dist/dlx/arborist.js +10 -9
  28. package/dist/dlx/binary.js +27 -24
  29. package/dist/dlx/cache.js +2 -10
  30. package/dist/dlx/detect.js +6 -5
  31. package/dist/dlx/integrity.js +13 -11
  32. package/dist/dlx/lockfile.js +7 -6
  33. package/dist/dlx/manifest.js +6 -5
  34. package/dist/dlx/package.js +17 -16
  35. package/dist/dlx/packages.js +6 -5
  36. package/dist/dlx/paths.d.ts +1 -1
  37. package/dist/dlx/paths.js +2 -1
  38. package/dist/effects/pulse-frames.js +4 -3
  39. package/dist/effects/shimmer-keyframes.d.ts +62 -0
  40. package/dist/effects/shimmer-keyframes.js +55 -0
  41. package/dist/effects/shimmer-terminal.d.ts +66 -0
  42. package/dist/effects/shimmer-terminal.js +57 -0
  43. package/dist/effects/shimmer.d.ts +293 -0
  44. package/dist/effects/shimmer.js +180 -0
  45. package/dist/env/rewire.js +4 -3
  46. package/dist/env.js +5 -4
  47. package/dist/errors.js +1 -1
  48. package/dist/external/@npmcli/package-json/lib/read-package.js +10 -10
  49. package/dist/external/@npmcli/package-json.js +372 -372
  50. package/dist/external/@npmcli/promise-spawn.js +24 -24
  51. package/dist/external/@socketregistry/packageurl-js.js +19 -18
  52. package/dist/external/@socketregistry/yocto-spinner.js +4 -3
  53. package/dist/external/@yarnpkg/extensions.js +2 -1
  54. package/dist/external/adm-zip.js +70 -70
  55. package/dist/external/debug.js +22 -22
  56. package/dist/external/external-pack.js +45 -45
  57. package/dist/external/fast-sort.js +5 -5
  58. package/dist/external/libnpmexec.js +4 -3
  59. package/dist/external/npm-pack.js +369 -369
  60. package/dist/external/p-map.js +9 -9
  61. package/dist/external/pico-pack.js +190 -190
  62. package/dist/external/pony-cause.js +2 -1
  63. package/dist/external/spdx-pack.js +11 -10
  64. package/dist/external/tar-fs.js +58 -58
  65. package/dist/external/which.js +13 -13
  66. package/dist/external/yargs-parser.js +71 -71
  67. package/dist/fs.js +19 -23
  68. package/dist/git.js +14 -13
  69. package/dist/github.d.ts +34 -0
  70. package/dist/github.js +248 -23
  71. package/dist/globs.d.ts +20 -0
  72. package/dist/globs.js +134 -25
  73. package/dist/http-request.d.ts +4 -3
  74. package/dist/http-request.js +39 -32
  75. package/dist/ipc-cli.js +2 -1
  76. package/dist/ipc.js +5 -4
  77. package/dist/json/edit.js +4 -3
  78. package/dist/json/format.js +3 -2
  79. package/dist/json/parse.js +7 -6
  80. package/dist/links.js +2 -1
  81. package/dist/logger.js +21 -14
  82. package/dist/memoization.js +16 -15
  83. package/dist/objects.js +2 -2
  84. package/dist/packages/edit.js +8 -7
  85. package/dist/packages/exports.js +17 -16
  86. package/dist/packages/isolation.js +20 -13
  87. package/dist/packages/licenses.js +6 -3
  88. package/dist/packages/manifest.js +2 -1
  89. package/dist/packages/normalize.js +8 -4
  90. package/dist/packages/operations.js +5 -4
  91. package/dist/packages/provenance.js +7 -6
  92. package/dist/packages/specs.js +2 -1
  93. package/dist/packages/validation.js +2 -1
  94. package/dist/paths/normalize.js +32 -40
  95. package/dist/paths/packages.js +2 -1
  96. package/dist/paths/rewire.js +3 -2
  97. package/dist/performance.js +19 -18
  98. package/dist/primordials.d.ts +9 -0
  99. package/dist/primordials.js +17 -0
  100. package/dist/process-lock.js +14 -13
  101. package/dist/promise-queue.js +17 -9
  102. package/dist/promises.d.ts +29 -6
  103. package/dist/promises.js +19 -15
  104. package/dist/regexps.js +9 -8
  105. package/dist/releases/github-api.d.ts +56 -0
  106. package/dist/releases/github-api.js +275 -0
  107. package/dist/releases/github-archives.d.ts +60 -0
  108. package/dist/releases/github-archives.js +136 -0
  109. package/dist/releases/github-assets.d.ts +21 -0
  110. package/dist/releases/github-assets.js +52 -0
  111. package/dist/releases/github-auth.d.ts +16 -0
  112. package/dist/releases/github-auth.js +51 -0
  113. package/dist/releases/github-downloads.d.ts +42 -0
  114. package/dist/releases/github-downloads.js +155 -0
  115. package/dist/releases/github-types.d.ts +66 -0
  116. package/dist/{effects/types.js → releases/github-types.js} +2 -2
  117. package/dist/releases/socket-btm.d.ts +1 -1
  118. package/dist/releases/socket-btm.js +17 -17
  119. package/dist/schema/parse.js +2 -1
  120. package/dist/schema/validate.js +6 -5
  121. package/dist/shadow.js +2 -1
  122. package/dist/signal-exit.js +2 -2
  123. package/dist/spawn.js +45 -35
  124. package/dist/spinner.d.ts +13 -6
  125. package/dist/spinner.js +75 -57
  126. package/dist/ssri.js +8 -7
  127. package/dist/stdio/footer.js +13 -12
  128. package/dist/stdio/header.js +5 -4
  129. package/dist/stdio/progress.js +13 -12
  130. package/dist/strings.js +19 -18
  131. package/dist/suppress-warnings.js +2 -2
  132. package/dist/tables.js +16 -13
  133. package/dist/temporary-executor.js +2 -1
  134. package/dist/themes/context.js +2 -1
  135. package/dist/themes/types.d.ts +1 -1
  136. package/dist/themes/utils.d.ts +8 -3
  137. package/dist/themes/utils.js +29 -5
  138. package/dist/url.js +4 -3
  139. package/package.json +44 -20
  140. package/dist/effects/text-shimmer.d.ts +0 -58
  141. package/dist/effects/text-shimmer.js +0 -192
  142. package/dist/effects/types.d.ts +0 -47
  143. package/dist/effects/ultra.d.ts +0 -22
  144. package/dist/releases/github.d.ts +0 -234
  145. package/dist/releases/github.js +0 -417
  146. package/dist/themes/index.d.ts +0 -49
  147. package/dist/themes/index.js +0 -60
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Socket Badge](https://socket.dev/api/badge/npm/package/@socketsecurity/lib)](https://socket.dev/npm/package/@socketsecurity/lib)
4
4
  [![CI](https://github.com/SocketDev/socket-lib/actions/workflows/ci.yml/badge.svg)](https://github.com/SocketDev/socket-lib/actions/workflows/ci.yml)
5
- ![Coverage](https://img.shields.io/badge/coverage-81%25-brightgreen)
5
+ ![Coverage](https://img.shields.io/badge/coverage-84%25-brightgreen)
6
6
 
7
7
  [![Follow @SocketSecurity](https://img.shields.io/twitter/follow/SocketSecurity?style=social)](https://twitter.com/SocketSecurity)
8
8
  [![Follow @socket.dev on Bluesky](https://img.shields.io/badge/Follow-@socket.dev-1DA1F2?style=social&logo=bluesky)](https://bsky.app/profile/socket.dev)
package/dist/abort.js CHANGED
@@ -24,6 +24,7 @@ __export(abort_exports, {
24
24
  createTimeoutSignal: () => createTimeoutSignal
25
25
  });
26
26
  module.exports = __toCommonJS(abort_exports);
27
+ var import_primordials = require("./primordials");
27
28
  function createCompositeAbortSignal(...signals) {
28
29
  const validSignals = signals.filter((s) => s != null);
29
30
  if (validSignals.length === 0) {
@@ -43,16 +44,16 @@ function createCompositeAbortSignal(...signals) {
43
44
  return controller.signal;
44
45
  }
45
46
  function createTimeoutSignal(ms) {
46
- if (typeof ms !== "number" || Number.isNaN(ms)) {
47
- throw new TypeError("timeout must be a number");
47
+ if (typeof ms !== "number" || (0, import_primordials.NumberIsNaN)(ms)) {
48
+ throw new import_primordials.TypeErrorCtor("timeout must be a number");
48
49
  }
49
- if (!Number.isFinite(ms)) {
50
- throw new TypeError("timeout must be a finite number");
50
+ if (!(0, import_primordials.NumberIsFinite)(ms)) {
51
+ throw new import_primordials.TypeErrorCtor("timeout must be a finite number");
51
52
  }
52
53
  if (ms <= 0) {
53
- throw new TypeError("timeout must be a positive number");
54
+ throw new import_primordials.TypeErrorCtor("timeout must be a positive number");
54
55
  }
55
- return AbortSignal.timeout(Math.ceil(ms));
56
+ return AbortSignal.timeout((0, import_primordials.MathCeil)(ms));
56
57
  }
57
58
  // Annotate the CommonJS export names for ESM import in node:
58
59
  0 && (module.exports = {
package/dist/agent.js CHANGED
@@ -55,16 +55,17 @@ var import_ci = require("./env/ci");
55
55
  var import_fs = require("./fs");
56
56
  var import_objects = require("./objects");
57
57
  var import_spawn = require("./spawn");
58
- const pnpmIgnoreScriptsFlags = /* @__PURE__ */ new Set([
58
+ var import_primordials = require("./primordials");
59
+ const pnpmIgnoreScriptsFlags = new import_primordials.SetCtor([
59
60
  "--ignore-scripts",
60
61
  "--no-ignore-scripts"
61
62
  ]);
62
- const pnpmFrozenLockfileFlags = /* @__PURE__ */ new Set([
63
+ const pnpmFrozenLockfileFlags = new import_primordials.SetCtor([
63
64
  "--frozen-lockfile",
64
65
  "--no-frozen-lockfile"
65
66
  ]);
66
- const pnpmInstallCommands = /* @__PURE__ */ new Set(["install", "i"]);
67
- const pnpmInstallLikeCommands = /* @__PURE__ */ new Set([
67
+ const pnpmInstallCommands = new import_primordials.SetCtor(["install", "i"]);
68
+ const pnpmInstallLikeCommands = new import_primordials.SetCtor([
68
69
  "install",
69
70
  "i",
70
71
  "add",
@@ -79,7 +80,7 @@ const pnpmInstallLikeCommands = /* @__PURE__ */ new Set([
79
80
  "rebuild",
80
81
  "rb"
81
82
  ]);
82
- const yarnInstallLikeCommands = /* @__PURE__ */ new Set([
83
+ const yarnInstallLikeCommands = new import_primordials.SetCtor([
83
84
  "install",
84
85
  "add",
85
86
  "upgrade",
@@ -90,11 +91,11 @@ const yarnInstallLikeCommands = /* @__PURE__ */ new Set([
90
91
  ]);
91
92
  function execNpm(args, options) {
92
93
  const useDebug = (0, import_debug.isDebug)();
93
- const terminatorPos = args.indexOf("--");
94
- const npmArgs = (terminatorPos === -1 ? args : args.slice(0, terminatorPos)).filter(
94
+ const terminatorPos = (0, import_primordials.ArrayPrototypeIndexOf)(args, "--");
95
+ const npmArgs = (terminatorPos === -1 ? args : (0, import_primordials.ArrayPrototypeSlice)(args, 0, terminatorPos)).filter(
95
96
  (a) => !/* @__PURE__ */ isNpmAuditFlag(a) && !/* @__PURE__ */ isNpmFundFlag(a) && !/* @__PURE__ */ isNpmProgressFlag(a)
96
97
  );
97
- const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos);
98
+ const otherArgs = terminatorPos === -1 ? [] : (0, import_primordials.ArrayPrototypeSlice)(args, terminatorPos);
98
99
  const logLevelArgs = (
99
100
  // The default value of loglevel is "notice". We default to "warn" which is
100
101
  // one level quieter.
@@ -132,9 +133,9 @@ function execPnpm(args, options) {
132
133
  ...options
133
134
  };
134
135
  const useDebug = (0, import_debug.isDebug)();
135
- const terminatorPos = args.indexOf("--");
136
- const pnpmArgs = (terminatorPos === -1 ? args : args.slice(0, terminatorPos)).filter((a) => !/* @__PURE__ */ isNpmProgressFlag(a));
137
- const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos);
136
+ const terminatorPos = (0, import_primordials.ArrayPrototypeIndexOf)(args, "--");
137
+ const pnpmArgs = (terminatorPos === -1 ? args : (0, import_primordials.ArrayPrototypeSlice)(args, 0, terminatorPos)).filter((a) => !/* @__PURE__ */ isNpmProgressFlag(a));
138
+ const otherArgs = terminatorPos === -1 ? [] : (0, import_primordials.ArrayPrototypeSlice)(args, terminatorPos);
138
139
  const firstArg = pnpmArgs[0];
139
140
  const supportsIgnoreScripts = firstArg ? pnpmInstallLikeCommands.has(firstArg) : false;
140
141
  const logLevelArgs = useDebug || pnpmArgs.some(isPnpmLoglevelFlag) ? [] : ["--loglevel", "warn"];
@@ -162,7 +163,7 @@ function execPnpm(args, options) {
162
163
  function execScript(scriptName, args, options) {
163
164
  let resolvedOptions;
164
165
  let resolvedArgs;
165
- if (!Array.isArray(args) && args !== null && typeof args === "object") {
166
+ if (!(0, import_primordials.ArrayIsArray)(args) && args !== null && typeof args === "object") {
166
167
  resolvedOptions = args;
167
168
  resolvedArgs = [];
168
169
  } else {
@@ -205,9 +206,9 @@ function execScript(scriptName, args, options) {
205
206
  }
206
207
  function execYarn(args, options) {
207
208
  const useDebug = (0, import_debug.isDebug)();
208
- const terminatorPos = args.indexOf("--");
209
- const yarnArgs = (terminatorPos === -1 ? args : args.slice(0, terminatorPos)).filter((a) => !/* @__PURE__ */ isNpmProgressFlag(a));
210
- const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos);
209
+ const terminatorPos = (0, import_primordials.ArrayPrototypeIndexOf)(args, "--");
210
+ const yarnArgs = (terminatorPos === -1 ? args : (0, import_primordials.ArrayPrototypeSlice)(args, 0, terminatorPos)).filter((a) => !/* @__PURE__ */ isNpmProgressFlag(a));
211
+ const otherArgs = terminatorPos === -1 ? [] : (0, import_primordials.ArrayPrototypeSlice)(args, terminatorPos);
211
212
  const firstArg = yarnArgs[0];
212
213
  const supportsIgnoreScripts = firstArg ? yarnInstallLikeCommands.has(firstArg) : false;
213
214
  const logLevelArgs = useDebug || yarnArgs.some(isNpmLoglevelFlag) ? [] : ["--silent"];
package/dist/ansi.js CHANGED
@@ -30,6 +30,7 @@ __export(ansi_exports, {
30
30
  stripAnsi: () => stripAnsi
31
31
  });
32
32
  module.exports = __toCommonJS(ansi_exports);
33
+ var import_primordials = require("./primordials");
33
34
  const ANSI_BOLD = "\x1B[1m";
34
35
  const ANSI_DIM = "\x1B[2m";
35
36
  const ANSI_ITALIC = "\x1B[3m";
@@ -44,11 +45,11 @@ function ansiRegex(options) {
44
45
  const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
45
46
  const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
46
47
  const pattern = `${osc}|${csi}`;
47
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
48
+ return new import_primordials.RegExpCtor(pattern, onlyFirst ? void 0 : "g");
48
49
  }
49
50
  // @__NO_SIDE_EFFECTS__
50
51
  function stripAnsi(text) {
51
- return text.replace(ANSI_REGEX, "");
52
+ return (0, import_primordials.StringPrototypeReplace)(text, ANSI_REGEX, "");
52
53
  }
53
54
  // Annotate the CommonJS export names for ESM import in node:
54
55
  0 && (module.exports = {
package/dist/archives.js CHANGED
@@ -43,6 +43,7 @@ var import_promises = require("node:stream/promises");
43
43
  var import_node_zlib = require("node:zlib");
44
44
  var import_fs = require("./fs");
45
45
  var import_normalize = require("./paths/normalize");
46
+ var import_primordials = require("./primordials");
46
47
  const DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024;
47
48
  const DEFAULT_MAX_TOTAL_SIZE = 1024 * 1024 * 1024;
48
49
  const DEFAULT_MAX_ENTRIES = 1e5;
@@ -74,15 +75,15 @@ function validatePathWithinBase(targetPath, baseDir, entryName) {
74
75
  const path = /* @__PURE__ */ getPath();
75
76
  const resolvedTarget = path.resolve(targetPath);
76
77
  const resolvedBase = path.resolve(baseDir);
77
- if (!resolvedTarget.startsWith(resolvedBase + path.sep) && resolvedTarget !== resolvedBase) {
78
- throw new Error(
78
+ if (!(0, import_primordials.StringPrototypeStartsWith)(resolvedTarget, resolvedBase + path.sep) && resolvedTarget !== resolvedBase) {
79
+ throw new import_primordials.ErrorCtor(
79
80
  `Path traversal attempt detected: entry "${entryName}" would extract to "${resolvedTarget}" outside target directory "${resolvedBase}"`
80
81
  );
81
82
  }
82
83
  }
83
84
  function assertArchiveExists(archivePath) {
84
85
  if (!(0, import_node_fs.existsSync)(archivePath)) {
85
- const err = new Error(
86
+ const err = new import_primordials.ErrorCtor(
86
87
  `ENOENT: no such file or directory, open '${archivePath}'`
87
88
  );
88
89
  err.code = "ENOENT";
@@ -92,16 +93,16 @@ function assertArchiveExists(archivePath) {
92
93
  }
93
94
  function detectArchiveFormat(filePath) {
94
95
  const lower = filePath.toLowerCase();
95
- if (lower.endsWith(".tar.gz")) {
96
+ if ((0, import_primordials.StringPrototypeEndsWith)(lower, ".tar.gz")) {
96
97
  return "tar.gz";
97
98
  }
98
- if (lower.endsWith(".tgz")) {
99
+ if ((0, import_primordials.StringPrototypeEndsWith)(lower, ".tgz")) {
99
100
  return "tgz";
100
101
  }
101
- if (lower.endsWith(".tar")) {
102
+ if ((0, import_primordials.StringPrototypeEndsWith)(lower, ".tar")) {
102
103
  return "tar";
103
104
  }
104
- if (lower.endsWith(".zip")) {
105
+ if ((0, import_primordials.StringPrototypeEndsWith)(lower, ".zip")) {
105
106
  return "zip";
106
107
  }
107
108
  return null;
@@ -111,7 +112,7 @@ async function extractArchive(archivePath, outputDir, options = {}) {
111
112
  if (!format) {
112
113
  const path = /* @__PURE__ */ getPath();
113
114
  const ext = path.extname(archivePath).toLowerCase();
114
- throw new Error(
115
+ throw new import_primordials.ErrorCtor(
115
116
  `Unsupported archive format${ext ? ` (extension: ${ext})` : ""}: ${archivePath}. Supported formats: .zip, .tar, .tar.gz, .tgz`
116
117
  );
117
118
  }
@@ -324,7 +325,7 @@ async function extractZip(archivePath, outputDir, options = {}) {
324
325
  const path = /* @__PURE__ */ getPath();
325
326
  const entries = zip.getEntries();
326
327
  if (entries.length > maxEntries) {
327
- throw new Error(
328
+ throw new import_primordials.ErrorCtor(
328
329
  `Archive has too many entries: ${entries.length} (limit: ${maxEntries})`
329
330
  );
330
331
  }
@@ -334,19 +335,19 @@ async function extractZip(archivePath, outputDir, options = {}) {
334
335
  continue;
335
336
  }
336
337
  if (entry.entryName.includes("\0")) {
337
- throw new Error(
338
+ throw new import_primordials.ErrorCtor(
338
339
  `Invalid null byte in archive entry name: ${entry.entryName}`
339
340
  );
340
341
  }
341
342
  const uncompressedSize = entry.header.size;
342
343
  if (uncompressedSize > maxFileSize) {
343
- throw new Error(
344
+ throw new import_primordials.ErrorCtor(
344
345
  `File size exceeds limit: ${entry.entryName} (${uncompressedSize} bytes > ${maxFileSize} bytes)`
345
346
  );
346
347
  }
347
348
  totalExtractedSize += uncompressedSize;
348
349
  if (totalExtractedSize > maxTotalSize) {
349
- throw new Error(
350
+ throw new import_primordials.ErrorCtor(
350
351
  `Total extracted size exceeds limit: ${totalExtractedSize} bytes > ${maxTotalSize} bytes`
351
352
  );
352
353
  }
@@ -354,7 +355,7 @@ async function extractZip(archivePath, outputDir, options = {}) {
354
355
  if (parts.length <= strip) {
355
356
  continue;
356
357
  }
357
- const strippedPath = parts.slice(strip).join("/");
358
+ const strippedPath = (0, import_primordials.ArrayPrototypeSlice)(parts, strip).join("/");
358
359
  const targetPath = path.join(normalizedOutputDir, strippedPath);
359
360
  validatePathWithinBase(targetPath, normalizedOutputDir, entry.entryName);
360
361
  }
@@ -369,7 +370,7 @@ async function extractZip(archivePath, outputDir, options = {}) {
369
370
  } else {
370
371
  const path2 = /* @__PURE__ */ getPath();
371
372
  const entries2 = zip.getEntries();
372
- const dirsToCreate = /* @__PURE__ */ new Set();
373
+ const dirsToCreate = new import_primordials.SetCtor();
373
374
  for (const entry of entries2) {
374
375
  if (entry.isDirectory) {
375
376
  continue;
@@ -378,11 +379,11 @@ async function extractZip(archivePath, outputDir, options = {}) {
378
379
  if (parts.length <= strip) {
379
380
  continue;
380
381
  }
381
- const strippedPath = parts.slice(strip).join("/");
382
+ const strippedPath = (0, import_primordials.ArrayPrototypeSlice)(parts, strip).join("/");
382
383
  const targetPath = path2.join(normalizedOutputDir, strippedPath);
383
384
  dirsToCreate.add(path2.dirname(targetPath));
384
385
  }
385
- await Promise.all(Array.from(dirsToCreate).map((dir) => (0, import_fs.safeMkdir)(dir)));
386
+ await (0, import_primordials.PromiseAll)((0, import_primordials.ArrayFrom)(dirsToCreate).map((dir) => (0, import_fs.safeMkdir)(dir)));
386
387
  for (const entry of entries2) {
387
388
  if (entry.isDirectory) {
388
389
  continue;
@@ -391,7 +392,7 @@ async function extractZip(archivePath, outputDir, options = {}) {
391
392
  if (parts.length <= strip) {
392
393
  continue;
393
394
  }
394
- const strippedPath = parts.slice(strip).join("/");
395
+ const strippedPath = (0, import_primordials.ArrayPrototypeSlice)(parts, strip).join("/");
395
396
  const targetPath = path2.join(normalizedOutputDir, strippedPath);
396
397
  zip.extractEntryTo(entry, path2.dirname(targetPath), false, true);
397
398
  }
@@ -49,6 +49,7 @@ __export(flags_exports, {
49
49
  });
50
50
  module.exports = __toCommonJS(flags_exports);
51
51
  var import_node_process = __toESM(require("node:process"));
52
+ var import_primordials = require("../primordials");
52
53
  const processArg = [...import_node_process.default.argv];
53
54
  const COMMON_FLAGS = {
54
55
  all: {
@@ -153,8 +154,8 @@ function isAll(input) {
153
154
  if (!input) {
154
155
  return processArg.includes("--all");
155
156
  }
156
- if (Array.isArray(input)) {
157
- return input.includes("--all");
157
+ if ((0, import_primordials.ArrayIsArray)(input)) {
158
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--all");
158
159
  }
159
160
  return !!input.all;
160
161
  }
@@ -162,8 +163,8 @@ function isChanged(input) {
162
163
  if (!input) {
163
164
  return processArg.includes("--changed");
164
165
  }
165
- if (Array.isArray(input)) {
166
- return input.includes("--changed");
166
+ if ((0, import_primordials.ArrayIsArray)(input)) {
167
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--changed");
167
168
  }
168
169
  return !!input.changed;
169
170
  }
@@ -171,8 +172,8 @@ function isCoverage(input) {
171
172
  if (!input) {
172
173
  return processArg.includes("--coverage") || processArg.includes("--cover");
173
174
  }
174
- if (Array.isArray(input)) {
175
- return input.includes("--coverage") || input.includes("--cover");
175
+ if ((0, import_primordials.ArrayIsArray)(input)) {
176
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--coverage") || (0, import_primordials.StringPrototypeIncludes)(input, "--cover");
176
177
  }
177
178
  return !!(input.coverage || input.cover);
178
179
  }
@@ -180,8 +181,8 @@ function isDebug(input) {
180
181
  if (!input) {
181
182
  return processArg.includes("--debug");
182
183
  }
183
- if (Array.isArray(input)) {
184
- return input.includes("--debug");
184
+ if ((0, import_primordials.ArrayIsArray)(input)) {
185
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--debug");
185
186
  }
186
187
  return !!input.debug;
187
188
  }
@@ -189,8 +190,8 @@ function isDryRun(input) {
189
190
  if (!input) {
190
191
  return processArg.includes("--dry-run");
191
192
  }
192
- if (Array.isArray(input)) {
193
- return input.includes("--dry-run");
193
+ if ((0, import_primordials.ArrayIsArray)(input)) {
194
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--dry-run");
194
195
  }
195
196
  return !!input["dry-run"];
196
197
  }
@@ -198,8 +199,8 @@ function isFix(input) {
198
199
  if (!input) {
199
200
  return processArg.includes("--fix");
200
201
  }
201
- if (Array.isArray(input)) {
202
- return input.includes("--fix");
202
+ if ((0, import_primordials.ArrayIsArray)(input)) {
203
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--fix");
203
204
  }
204
205
  return !!input.fix;
205
206
  }
@@ -207,8 +208,8 @@ function isForce(input) {
207
208
  if (!input) {
208
209
  return processArg.includes("--force");
209
210
  }
210
- if (Array.isArray(input)) {
211
- return input.includes("--force");
211
+ if ((0, import_primordials.ArrayIsArray)(input)) {
212
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--force");
212
213
  }
213
214
  return !!input.force;
214
215
  }
@@ -216,8 +217,8 @@ function isHelp(input) {
216
217
  if (!input) {
217
218
  return processArg.includes("--help") || processArg.includes("-h");
218
219
  }
219
- if (Array.isArray(input)) {
220
- return input.includes("--help") || input.includes("-h");
220
+ if ((0, import_primordials.ArrayIsArray)(input)) {
221
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--help") || (0, import_primordials.StringPrototypeIncludes)(input, "-h");
221
222
  }
222
223
  return !!input.help;
223
224
  }
@@ -225,8 +226,8 @@ function isJson(input) {
225
226
  if (!input) {
226
227
  return processArg.includes("--json");
227
228
  }
228
- if (Array.isArray(input)) {
229
- return input.includes("--json");
229
+ if ((0, import_primordials.ArrayIsArray)(input)) {
230
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--json");
230
231
  }
231
232
  return !!input.json;
232
233
  }
@@ -234,8 +235,8 @@ function isQuiet(input) {
234
235
  if (!input) {
235
236
  return processArg.includes("--quiet") || processArg.includes("--silent");
236
237
  }
237
- if (Array.isArray(input)) {
238
- return input.includes("--quiet") || input.includes("--silent");
238
+ if ((0, import_primordials.ArrayIsArray)(input)) {
239
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--quiet") || (0, import_primordials.StringPrototypeIncludes)(input, "--silent");
239
240
  }
240
241
  return !!(input.quiet || input.silent);
241
242
  }
@@ -243,8 +244,8 @@ function isStaged(input) {
243
244
  if (!input) {
244
245
  return processArg.includes("--staged");
245
246
  }
246
- if (Array.isArray(input)) {
247
- return input.includes("--staged");
247
+ if ((0, import_primordials.ArrayIsArray)(input)) {
248
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--staged");
248
249
  }
249
250
  return !!input.staged;
250
251
  }
@@ -252,8 +253,8 @@ function isUpdate(input) {
252
253
  if (!input) {
253
254
  return processArg.includes("--update") || processArg.includes("-u");
254
255
  }
255
- if (Array.isArray(input)) {
256
- return input.includes("--update") || input.includes("-u");
256
+ if ((0, import_primordials.ArrayIsArray)(input)) {
257
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--update") || (0, import_primordials.StringPrototypeIncludes)(input, "-u");
257
258
  }
258
259
  return !!input.update;
259
260
  }
@@ -261,8 +262,8 @@ function isVerbose(input) {
261
262
  if (!input) {
262
263
  return processArg.includes("--verbose");
263
264
  }
264
- if (Array.isArray(input)) {
265
- return input.includes("--verbose");
265
+ if ((0, import_primordials.ArrayIsArray)(input)) {
266
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--verbose");
266
267
  }
267
268
  return !!input.verbose;
268
269
  }
@@ -270,8 +271,8 @@ function isWatch(input) {
270
271
  if (!input) {
271
272
  return processArg.includes("--watch") || processArg.includes("-w");
272
273
  }
273
- if (Array.isArray(input)) {
274
- return input.includes("--watch") || input.includes("-w");
274
+ if ((0, import_primordials.ArrayIsArray)(input)) {
275
+ return (0, import_primordials.StringPrototypeIncludes)(input, "--watch") || (0, import_primordials.StringPrototypeIncludes)(input, "-w");
275
276
  }
276
277
  return !!input.watch;
277
278
  }
@@ -39,6 +39,7 @@ __export(parse_exports, {
39
39
  module.exports = __toCommonJS(parse_exports);
40
40
  var import_node_process = __toESM(require("node:process"));
41
41
  var import_yargs_parser = __toESM(require("../external/yargs-parser"));
42
+ var import_primordials = require("../primordials");
42
43
  const commonParseArgsConfig = {
43
44
  options: {
44
45
  force: {
@@ -60,7 +61,7 @@ function getPositionalArgs(startIndex = 2) {
60
61
  let i = 0;
61
62
  while (i < args.length) {
62
63
  const arg = args[i];
63
- if (arg.startsWith("-")) {
64
+ if ((0, import_primordials.StringPrototypeStartsWith)(arg, "-")) {
64
65
  break;
65
66
  }
66
67
  positionals.push(arg);
@@ -69,7 +70,7 @@ function getPositionalArgs(startIndex = 2) {
69
70
  return positionals;
70
71
  }
71
72
  function hasFlag(flag, argv = import_node_process.default.argv) {
72
- return argv.includes(`--${flag}`);
73
+ return (0, import_primordials.ArrayPrototypeIncludes)(argv, `--${flag}`);
73
74
  }
74
75
  function parseArgs(config = {}) {
75
76
  const {
@@ -114,7 +115,7 @@ function parseArgs(config = {}) {
114
115
  ...configuration
115
116
  }
116
117
  };
117
- for (const { 0: key, 1: optionConfig } of Object.entries(options)) {
118
+ for (const { 0: key, 1: optionConfig } of (0, import_primordials.ObjectEntries)(options)) {
118
119
  const {
119
120
  coerce,
120
121
  default: defaultValue,
package/dist/arrays.js CHANGED
@@ -27,6 +27,7 @@ __export(arrays_exports, {
27
27
  joinOr: () => joinOr
28
28
  });
29
29
  module.exports = __toCommonJS(arrays_exports);
30
+ var import_primordials = require("./primordials");
30
31
  let _conjunctionFormatter;
31
32
  // @__NO_SIDE_EFFECTS__
32
33
  function getConjunctionFormatter() {
@@ -55,7 +56,7 @@ function getDisjunctionFormatter() {
55
56
  function arrayChunk(arr, size) {
56
57
  const chunkSize = size ?? 2;
57
58
  if (chunkSize <= 0) {
58
- throw new Error("Chunk size must be greater than 0");
59
+ throw new import_primordials.ErrorCtor("Chunk size must be greater than 0");
59
60
  }
60
61
  const { length } = arr;
61
62
  const chunks = [];
@@ -66,7 +67,7 @@ function arrayChunk(arr, size) {
66
67
  }
67
68
  // @__NO_SIDE_EFFECTS__
68
69
  function arrayUnique(arr) {
69
- return [...new Set(arr)];
70
+ return [...new import_primordials.SetCtor(arr)];
70
71
  }
71
72
  const isArray = Array.isArray;
72
73
  // @__NO_SIDE_EFFECTS__
package/dist/bin.js CHANGED
@@ -52,9 +52,10 @@ var import_which = __toESM(require("./external/which"));
52
52
  var import_fs = require("./fs");
53
53
  var import_normalize = require("./paths/normalize");
54
54
  var import_spawn = require("./spawn");
55
- const binPathCache = /* @__PURE__ */ new Map();
56
- const binPathAllCache = /* @__PURE__ */ new Map();
57
- const voltaBinCache = /* @__PURE__ */ new Map();
55
+ var import_primordials = require("./primordials");
56
+ const binPathCache = new import_primordials.MapCtor();
57
+ const binPathAllCache = new import_primordials.MapCtor();
58
+ const voltaBinCache = new import_primordials.MapCtor();
58
59
  let _fs;
59
60
  // @__NO_SIDE_EFFECTS__
60
61
  function getFs() {
@@ -93,7 +94,7 @@ async function execBin(binPath, args, options) {
93
94
  }
94
95
  }
95
96
  if (!resolvedPath) {
96
- const error = new Error(
97
+ const error = new import_primordials.ErrorCtor(
97
98
  `Binary not found: ${binPath}
98
99
  Possible causes:
99
100
  - Binary "${binPath}" is not installed or not in PATH
@@ -107,7 +108,7 @@ To resolve:
107
108
  error.code = "ENOENT";
108
109
  throw error;
109
110
  }
110
- const binCommand = Array.isArray(resolvedPath) ? resolvedPath[0] : resolvedPath;
111
+ const binCommand = (0, import_primordials.ArrayIsArray)(resolvedPath) ? resolvedPath[0] : resolvedPath;
111
112
  return await (0, import_spawn.spawn)(binCommand, args ?? [], {
112
113
  shell: import_platform.WIN32,
113
114
  ...options
@@ -122,7 +123,7 @@ function findRealBin(binName, commonPaths = []) {
122
123
  }
123
124
  }
124
125
  const allPaths = import_which.default.sync(binName, { all: true, nothrow: true }) || [];
125
- const pathsArray = Array.isArray(allPaths) ? allPaths : typeof allPaths === "string" ? [allPaths] : [];
126
+ const pathsArray = (0, import_primordials.ArrayIsArray)(allPaths) ? allPaths : typeof allPaths === "string" ? [allPaths] : [];
126
127
  if (pathsArray.length === 0) {
127
128
  return void 0;
128
129
  }
@@ -404,7 +405,7 @@ function resolveRealBinSync(binPath) {
404
405
  relPath = match[1] || "";
405
406
  }
406
407
  }
407
- if (relPath && basename === "pnpm" && relPath.startsWith("pnpm/")) {
408
+ if (relPath && basename === "pnpm" && (0, import_primordials.StringPrototypeStartsWith)(relPath, "pnpm/")) {
408
409
  relPath = `../${relPath}`;
409
410
  }
410
411
  } else if (isNpmOrNpx) {
@@ -461,9 +462,9 @@ async function whichReal(binName, options) {
461
462
  opts
462
463
  );
463
464
  if (opts?.all) {
464
- const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
465
+ const paths = (0, import_primordials.ArrayIsArray)(result) ? result : typeof result === "string" ? [result] : void 0;
465
466
  if (paths?.length) {
466
- const resolved2 = paths.map((p) => /* @__PURE__ */ resolveRealBinSync(p));
467
+ const resolved2 = (0, import_primordials.ArrayPrototypeMap)(paths, (p) => /* @__PURE__ */ resolveRealBinSync(p));
467
468
  binPathAllCache.set(binName, resolved2);
468
469
  return resolved2;
469
470
  }
@@ -498,9 +499,9 @@ function whichRealSync(binName, options) {
498
499
  }
499
500
  const result = whichSync(binName, opts);
500
501
  if (opts.all) {
501
- const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
502
+ const paths = (0, import_primordials.ArrayIsArray)(result) ? result : typeof result === "string" ? [result] : void 0;
502
503
  if (paths?.length) {
503
- const resolved2 = paths.map((p) => /* @__PURE__ */ resolveRealBinSync(p));
504
+ const resolved2 = (0, import_primordials.ArrayPrototypeMap)(paths, (p) => /* @__PURE__ */ resolveRealBinSync(p));
504
505
  binPathAllCache.set(binName, resolved2);
505
506
  return resolved2;
506
507
  }
package/dist/cacache.js CHANGED
@@ -41,14 +41,19 @@ __export(cacache_exports, {
41
41
  module.exports = __toCommonJS(cacache_exports);
42
42
  var import_cacache = __toESM(require("./external/cacache"));
43
43
  var import_socket = require("./paths/socket");
44
+ var import_primordials = require("./primordials");
44
45
  function createPatternMatcher(pattern) {
45
46
  if (!pattern.includes("*")) {
46
- return (key) => key.startsWith(pattern);
47
+ return (key) => (0, import_primordials.StringPrototypeStartsWith)(key, pattern);
47
48
  }
48
- const escaped = pattern.replaceAll(/[.+?^${}()|[\]\\]/g, "\\$&");
49
- const regexPattern = escaped.replaceAll("*", ".*");
50
- const regex = new RegExp(`^${regexPattern}$`);
51
- return (key) => regex.test(key);
49
+ const escaped = (0, import_primordials.StringPrototypeReplaceAll)(
50
+ pattern,
51
+ /[.+?^${}()|[\]\\]/g,
52
+ "\\$&"
53
+ );
54
+ const regexPattern = (0, import_primordials.StringPrototypeReplaceAll)(escaped, "*", ".*");
55
+ const regex = new import_primordials.RegExpCtor(`^${regexPattern}$`);
56
+ return (key) => (0, import_primordials.RegExpPrototypeTest)(regex, key);
52
57
  }
53
58
  async function clear(options) {
54
59
  const opts = { __proto__: null, ...options };
@@ -95,8 +100,8 @@ async function clear(options) {
95
100
  return removed;
96
101
  }
97
102
  async function get(key, options) {
98
- if (key.includes("*")) {
99
- throw new TypeError(
103
+ if ((0, import_primordials.StringPrototypeIncludes)(key, "*")) {
104
+ throw new import_primordials.TypeErrorCtor(
100
105
  'Cache key cannot contain wildcards (*). Wildcards are only supported in clear({ prefix: "pattern*" }).'
101
106
  );
102
107
  }
@@ -107,8 +112,8 @@ function getCacache() {
107
112
  return import_cacache.default;
108
113
  }
109
114
  async function put(key, data, options) {
110
- if (key.includes("*")) {
111
- throw new TypeError(
115
+ if ((0, import_primordials.StringPrototypeIncludes)(key, "*")) {
116
+ throw new import_primordials.TypeErrorCtor(
112
117
  'Cache key cannot contain wildcards (*). Wildcards are only supported in clear({ prefix: "pattern*" }).'
113
118
  );
114
119
  }
@@ -116,8 +121,8 @@ async function put(key, data, options) {
116
121
  return await cacache2.put((0, import_socket.getSocketCacacheDir)(), key, data, options);
117
122
  }
118
123
  async function remove(key) {
119
- if (key.includes("*")) {
120
- throw new TypeError(
124
+ if ((0, import_primordials.StringPrototypeIncludes)(key, "*")) {
125
+ throw new import_primordials.TypeErrorCtor(
121
126
  'Cache key cannot contain wildcards (*). Use clear({ prefix: "pattern*" }) to remove multiple entries.'
122
127
  );
123
128
  }