@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/dist/logger.js CHANGED
@@ -94,7 +94,7 @@ const LOG_SYMBOLS = /* @__PURE__ */ (() => {
94
94
  }
95
95
  updateSymbols();
96
96
  };
97
- for (const trapName of Reflect.ownKeys(Reflect)) {
97
+ for (const trapName of (0, import_primordials.ReflectOwnKeys)(Reflect)) {
98
98
  const fn = Reflect[trapName];
99
99
  if (typeof fn === "function") {
100
100
  ;
@@ -107,7 +107,7 @@ const LOG_SYMBOLS = /* @__PURE__ */ (() => {
107
107
  (0, import_context.onThemeChange)(() => {
108
108
  reset();
109
109
  });
110
- return new Proxy(target, handler);
110
+ return new import_primordials.ProxyCtor(target, handler);
111
111
  })();
112
112
  const boundConsoleEntries = [
113
113
  // Add bound properties from console[kBindProperties](ignoreErrors, colorMode, groupIndentation).
@@ -146,8 +146,8 @@ const consolePropAttributes = {
146
146
  configurable: true
147
147
  };
148
148
  const maxIndentation = 1e3;
149
- const privateConsole = /* @__PURE__ */ new WeakMap();
150
- const privateConstructorArgs = /* @__PURE__ */ new WeakMap();
149
+ const privateConsole = new import_primordials.WeakMapCtor();
150
+ const privateConstructorArgs = new import_primordials.WeakMapCtor();
151
151
  const incLogCallCountSymbol = Symbol.for("logger.logCallCount++");
152
152
  const lastWasBlankSymbol = Symbol.for("logger.lastWasBlank");
153
153
  class Logger {
@@ -220,11 +220,14 @@ class Logger {
220
220
  */
221
221
  #apply(methodName, args, stream) {
222
222
  const con = this.#getConsole();
223
- const text = args.at(0);
223
+ const text = (0, import_primordials.ArrayPrototypeAt)(args, 0);
224
224
  const hasText = typeof text === "string";
225
225
  const targetStream = stream || (methodName === "log" ? "stdout" : "stderr");
226
226
  const indent = this.#getIndent(targetStream);
227
- const logArgs = hasText ? [(0, import_strings.applyLinePrefix)(text, { prefix: indent }), ...args.slice(1)] : args;
227
+ const logArgs = hasText ? [
228
+ (0, import_strings.applyLinePrefix)(text, { prefix: indent }),
229
+ ...(0, import_primordials.ArrayPrototypeSlice)(args, 1)
230
+ ] : args;
228
231
  (0, import_primordials.ReflectApply)(
229
232
  con[methodName],
230
233
  con,
@@ -350,7 +353,11 @@ class Logger {
350
353
  * @private
351
354
  */
352
355
  #stripSymbols(text) {
353
- return text.replace(/^(?:[✖✗×⚠‼✔✓√ℹ→∴↻]|:.)[\uFE0F\s]*/u, "");
356
+ return (0, import_primordials.StringPrototypeReplace)(
357
+ text,
358
+ /^(?:[✖✗×⚠‼✔✓√ℹ→∴↻]|:.)[\uFE0F\s]*/u,
359
+ ""
360
+ );
354
361
  }
355
362
  /**
356
363
  * Apply a method with a symbol prefix.
@@ -358,11 +365,11 @@ class Logger {
358
365
  */
359
366
  #symbolApply(symbolType, args) {
360
367
  const con = this.#getConsole();
361
- let text = args.at(0);
368
+ let text = (0, import_primordials.ArrayPrototypeAt)(args, 0);
362
369
  let extras;
363
370
  if (typeof text === "string") {
364
371
  text = this.#stripSymbols(text);
365
- extras = args.slice(1);
372
+ extras = (0, import_primordials.ArrayPrototypeSlice)(args, 1);
366
373
  } else {
367
374
  extras = args;
368
375
  text = "";
@@ -587,7 +594,7 @@ class Logger {
587
594
  */
588
595
  clearVisible() {
589
596
  if (this.#boundStream) {
590
- throw new Error(
597
+ throw new import_primordials.ErrorCtor(
591
598
  "clearVisible() is only available on the main logger instance, not on stream-bound instances"
592
599
  );
593
600
  }
@@ -932,7 +939,7 @@ class Logger {
932
939
  * ```
933
940
  */
934
941
  indent(spaces = 2) {
935
- const spacesToAdd = " ".repeat(Math.min(spaces, maxIndentation));
942
+ const spacesToAdd = " ".repeat((0, import_primordials.MathMin)(spaces, maxIndentation));
936
943
  if (this.#boundStream) {
937
944
  const current = this.#getIndent(this.#boundStream);
938
945
  this.#setIndent(this.#boundStream, current + spacesToAdd);
@@ -1423,7 +1430,7 @@ function ensurePrototypeInitialized() {
1423
1430
  }
1424
1431
  ]
1425
1432
  ];
1426
- for (const { 0: key, 1: value } of Object.entries(globalConsole)) {
1433
+ for (const { 0: key, 1: value } of (0, import_primordials.ObjectEntries)(globalConsole)) {
1427
1434
  if (!Logger.prototype[key] && typeof value === "function") {
1428
1435
  const { [key]: func } = {
1429
1436
  [key](...args) {
@@ -1457,11 +1464,11 @@ function ensurePrototypeInitialized() {
1457
1464
  ]);
1458
1465
  }
1459
1466
  }
1460
- Object.defineProperties(Logger.prototype, Object.fromEntries(entries));
1467
+ (0, import_primordials.ObjectDefineProperties)(Logger.prototype, Object.fromEntries(entries));
1461
1468
  }
1462
1469
  function getConsoleSymbols() {
1463
1470
  if (_consoleSymbols === void 0) {
1464
- _consoleSymbols = Object.getOwnPropertySymbols(globalConsole);
1471
+ _consoleSymbols = (0, import_primordials.ObjectGetOwnPropertySymbols)(globalConsole);
1465
1472
  }
1466
1473
  return _consoleSymbols;
1467
1474
  }
@@ -29,9 +29,10 @@ __export(memoization_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(memoization_exports);
31
31
  var import_debug = require("./debug");
32
+ var import_primordials = require("./primordials");
32
33
  const cacheRegistry = [];
33
34
  function defaultKeyGen(args) {
34
- return JSON.stringify(args, (_key, value) => {
35
+ return (0, import_primordials.JSONStringify)(args, (_key, value) => {
35
36
  if (value === void 0) {
36
37
  return "\0undefined";
37
38
  }
@@ -74,9 +75,9 @@ function memoize(fn, options = {}) {
74
75
  ttl = Number.POSITIVE_INFINITY
75
76
  } = options;
76
77
  if (ttl < 0) {
77
- throw new TypeError("TTL must be non-negative");
78
+ throw new import_primordials.TypeErrorCtor("TTL must be non-negative");
78
79
  }
79
- const cache = /* @__PURE__ */ new Map();
80
+ const cache = new import_primordials.MapCtor();
80
81
  cacheRegistry.push(() => {
81
82
  cache.clear();
82
83
  });
@@ -96,7 +97,7 @@ function memoize(fn, options = {}) {
96
97
  if (ttl === Number.POSITIVE_INFINITY) {
97
98
  return false;
98
99
  }
99
- return Date.now() - entry.timestamp > ttl;
100
+ return (0, import_primordials.DateNow)() - entry.timestamp > ttl;
100
101
  }
101
102
  return function memoized(...args) {
102
103
  const key = keyGen(...args);
@@ -130,7 +131,7 @@ function memoizeAsync(fn, options = {}) {
130
131
  name = fn.name || "anonymous",
131
132
  ttl = Number.POSITIVE_INFINITY
132
133
  } = options;
133
- const cache = /* @__PURE__ */ new Map();
134
+ const cache = new import_primordials.MapCtor();
134
135
  cacheRegistry.push(() => {
135
136
  cache.clear();
136
137
  });
@@ -150,13 +151,13 @@ function memoizeAsync(fn, options = {}) {
150
151
  if (ttl === Number.POSITIVE_INFINITY) {
151
152
  return false;
152
153
  }
153
- return Date.now() - entry.timestamp > ttl;
154
+ return (0, import_primordials.DateNow)() - entry.timestamp > ttl;
154
155
  }
155
156
  function bumpRecency(key, entry) {
156
157
  cache.delete(key);
157
158
  cache.set(key, entry);
158
159
  }
159
- const refreshing = /* @__PURE__ */ new Map();
160
+ const refreshing = new import_primordials.MapCtor();
160
161
  return async function memoized(...args) {
161
162
  const key = keyGen(...args);
162
163
  const cached = cache.get(key);
@@ -176,23 +177,23 @@ function memoizeAsync(fn, options = {}) {
176
177
  cache.delete(key);
177
178
  }
178
179
  (0, import_debug.debugLog)(`[memoizeAsync:${name}] miss`, { key });
179
- const promise = fn(...args).then(
180
- (result) => {
180
+ const promise = (async () => {
181
+ try {
182
+ const result = await fn(...args);
181
183
  refreshing.delete(key);
182
184
  const entry = cache.get(key);
183
185
  if (entry) {
184
- entry.value = Promise.resolve(result);
185
- entry.timestamp = Date.now();
186
+ entry.value = (0, import_primordials.PromiseResolve)(result);
187
+ entry.timestamp = (0, import_primordials.DateNow)();
186
188
  }
187
189
  return result;
188
- },
189
- (error) => {
190
+ } catch (error) {
190
191
  refreshing.delete(key);
191
192
  cache.delete(key);
192
193
  (0, import_debug.debugLog)(`[memoizeAsync:${name}] error`, { key, error });
193
194
  throw error;
194
195
  }
195
- );
196
+ })();
196
197
  refreshing.set(key, promise);
197
198
  evictLRU();
198
199
  cache.set(key, {
@@ -205,7 +206,7 @@ function memoizeAsync(fn, options = {}) {
205
206
  };
206
207
  }
207
208
  function memoizeWeak(fn) {
208
- const cache = /* @__PURE__ */ new WeakMap();
209
+ const cache = new import_primordials.WeakMapCtor();
209
210
  return function memoized(key) {
210
211
  if (cache.has(key)) {
211
212
  (0, import_debug.debugLog)(`[memoizeWeak:${fn.name}] hit`);
package/dist/objects.js CHANGED
@@ -66,7 +66,7 @@ function createConstantsObject(props, options_) {
66
66
  });
67
67
  const lazyGetterStats = (0, import_primordials.ObjectFreeze)({
68
68
  __proto__: null,
69
- initialized: /* @__PURE__ */ new Set()
69
+ initialized: new import_primordials.SetCtor()
70
70
  });
71
71
  const object = defineLazyGetters(
72
72
  {
@@ -207,7 +207,7 @@ function merge(target, source) {
207
207
  let { length: queueLength } = queue;
208
208
  while (pos < queueLength) {
209
209
  if (pos === import_core.LOOP_SENTINEL) {
210
- throw new Error("Detected infinite loop in object crawl of merge");
210
+ throw new import_primordials.ErrorCtor("Detected infinite loop in object crawl of merge");
211
211
  }
212
212
  const { 0: currentTarget, 1: currentSource } = queue[pos++];
213
213
  if (!currentSource || !currentTarget) {
@@ -43,6 +43,7 @@ var import_format = require("../json/format");
43
43
  var import_normalize = require("../paths/normalize");
44
44
  var import_normalize2 = require("./normalize");
45
45
  var import_packages = require("../paths/packages");
46
+ var import_primordials = require("../primordials");
46
47
  let _EditablePackageJsonClass;
47
48
  let _fs;
48
49
  // @__NO_SIDE_EFFECTS__
@@ -87,7 +88,7 @@ function getEditablePackageJsonClass() {
87
88
  if (!path) {
88
89
  return "";
89
90
  }
90
- if (path.endsWith("package.json")) {
91
+ if ((0, import_primordials.StringPrototypeEndsWith)(path, "package.json")) {
91
92
  return path;
92
93
  }
93
94
  const nodePath = /* @__PURE__ */ getPath();
@@ -191,7 +192,7 @@ function getEditablePackageJsonClass() {
191
192
  }
192
193
  async save(options) {
193
194
  if (!this._canSave || this.content === void 0) {
194
- throw new Error("No package.json to save to");
195
+ throw new import_primordials.ErrorCtor("No package.json to save to");
195
196
  }
196
197
  if (!(0, import_format.shouldSave)(
197
198
  this.content,
@@ -217,7 +218,7 @@ function getEditablePackageJsonClass() {
217
218
  }
218
219
  saveSync(options) {
219
220
  if (!this._canSave || this.content === void 0) {
220
- throw new Error("No package.json to save to");
221
+ throw new import_primordials.ErrorCtor("No package.json to save to");
221
222
  }
222
223
  const { ignoreWhitespace = false, sort = false } = {
223
224
  __proto__: null,
@@ -234,7 +235,7 @@ function getEditablePackageJsonClass() {
234
235
  }
235
236
  const format = indent === void 0 || indent === null ? " " : indent;
236
237
  const eol = newline === void 0 || newline === null ? "\n" : newline;
237
- const fileContent = `${JSON.stringify(
238
+ const fileContent = `${(0, import_primordials.JSONStringify)(
238
239
  content,
239
240
  void 0,
240
241
  format
@@ -272,7 +273,7 @@ function getEditablePackageJsonClass() {
272
273
  }
273
274
  const format = indent === void 0 || indent === null ? " " : indent;
274
275
  const eol = newline === void 0 || newline === null ? "\n" : newline;
275
- const fileContent = `${JSON.stringify(
276
+ const fileContent = `${(0, import_primordials.JSONStringify)(
276
277
  content,
277
278
  void 0,
278
279
  format
@@ -311,7 +312,7 @@ async function toEditablePackageJson(pkgJson, options) {
311
312
  const EditablePackageJson = /* @__PURE__ */ getEditablePackageJsonClass();
312
313
  const pkgJsonPath = (0, import_packages.resolvePackageJsonDirname)(filepath);
313
314
  return (await EditablePackageJson.load(pkgJsonPath, { create: true })).fromJSON(
314
- `${JSON.stringify(
315
+ `${(0, import_primordials.JSONStringify)(
315
316
  normalize ? (0, import_normalize2.normalizePackageJson)(pkgJson, {
316
317
  ...(0, import_normalize.isNodeModules)(pkgJsonPath) ? {} : { preserve: ["repository"] },
317
318
  ...normalizeOptions
@@ -335,7 +336,7 @@ function toEditablePackageJsonSync(pkgJson, options) {
335
336
  const EditablePackageJson = /* @__PURE__ */ getEditablePackageJsonClass();
336
337
  const pkgJsonPath = (0, import_packages.resolvePackageJsonDirname)(filepath);
337
338
  return new EditablePackageJson().create(pkgJsonPath).fromJSON(
338
- `${JSON.stringify(
339
+ `${(0, import_primordials.JSONStringify)(
339
340
  normalize ? (0, import_normalize2.normalizePackageJson)(pkgJson, {
340
341
  ...(0, import_normalize.isNodeModules)(pkgJsonPath) ? {} : { preserve: ["repository"] },
341
342
  ...normalizeOptions
@@ -31,13 +31,14 @@ module.exports = __toCommonJS(exports_exports);
31
31
  var import_arrays = require("../arrays");
32
32
  var import_core = require("../constants/core");
33
33
  var import_objects = require("../objects");
34
+ var import_primordials = require("../primordials");
34
35
  // @__NO_SIDE_EFFECTS__
35
36
  function findTypesForSubpath(entryExports, subpath) {
36
37
  const queue = [entryExports];
37
38
  let pos = 0;
38
39
  while (pos < queue.length) {
39
40
  if (pos === import_core.LOOP_SENTINEL) {
40
- throw new Error(
41
+ throw new import_primordials.ErrorCtor(
41
42
  "Detected infinite loop in entry exports crawl of getTypesForSubpath"
42
43
  );
43
44
  }
@@ -53,7 +54,7 @@ function findTypesForSubpath(entryExports, subpath) {
53
54
  }
54
55
  }
55
56
  } else if ((0, import_objects.isObject)(value)) {
56
- const keys = Object.getOwnPropertyNames(value);
57
+ const keys = (0, import_primordials.ObjectGetOwnPropertyNames)(value);
57
58
  for (let i = 0, { length } = keys; i < length; i += 1) {
58
59
  const key = keys[i];
59
60
  const item = value[key];
@@ -74,27 +75,27 @@ function getExportFilePaths(entryExports) {
74
75
  return [];
75
76
  }
76
77
  const paths = [];
77
- for (const key of Object.getOwnPropertyNames(entryExports)) {
78
- if (!key.startsWith(".")) {
78
+ for (const key of (0, import_primordials.ObjectGetOwnPropertyNames)(entryExports)) {
79
+ if (!(0, import_primordials.StringPrototypeStartsWith)(key, ".")) {
79
80
  continue;
80
81
  }
81
82
  const value = entryExports[key];
82
83
  if (typeof value === "string") {
83
- paths.push(value);
84
+ (0, import_primordials.ArrayPrototypePush)(paths, value);
84
85
  } else if ((0, import_objects.isObject)(value)) {
85
- for (const subKey of Object.getOwnPropertyNames(value)) {
86
+ for (const subKey of (0, import_primordials.ObjectGetOwnPropertyNames)(value)) {
86
87
  const subValue = value[subKey];
87
88
  if (typeof subValue === "string") {
88
- paths.push(subValue);
89
+ (0, import_primordials.ArrayPrototypePush)(paths, subValue);
89
90
  } else if ((0, import_arrays.isArray)(subValue)) {
90
91
  for (const item of subValue) {
91
92
  if (typeof item === "string") {
92
- paths.push(item);
93
+ (0, import_primordials.ArrayPrototypePush)(paths, item);
93
94
  } else if ((0, import_objects.isObject)(item)) {
94
- for (const nestedKey of Object.getOwnPropertyNames(item)) {
95
+ for (const nestedKey of (0, import_primordials.ObjectGetOwnPropertyNames)(item)) {
95
96
  const nestedValue = item[nestedKey];
96
97
  if (typeof nestedValue === "string") {
97
- paths.push(nestedValue);
98
+ (0, import_primordials.ArrayPrototypePush)(paths, nestedValue);
98
99
  }
99
100
  }
100
101
  }
@@ -103,15 +104,15 @@ function getExportFilePaths(entryExports) {
103
104
  }
104
105
  }
105
106
  }
106
- return [...new Set(paths)].filter((p) => p.startsWith("./"));
107
+ return [...new import_primordials.SetCtor(paths)].filter((p) => (0, import_primordials.StringPrototypeStartsWith)(p, "./"));
107
108
  }
108
109
  // @__NO_SIDE_EFFECTS__
109
110
  function getSubpaths(entryExports) {
110
111
  if (!(0, import_objects.isObject)(entryExports)) {
111
112
  return [];
112
113
  }
113
- return Object.getOwnPropertyNames(entryExports).filter(
114
- (key) => key.startsWith(".")
114
+ return (0, import_primordials.ObjectGetOwnPropertyNames)(entryExports).filter(
115
+ (key) => (0, import_primordials.StringPrototypeStartsWith)(key, ".")
115
116
  );
116
117
  }
117
118
  // @__NO_SIDE_EFFECTS__
@@ -119,14 +120,14 @@ function isConditionalExports(entryExports) {
119
120
  if (!(0, import_objects.isObjectObject)(entryExports)) {
120
121
  return false;
121
122
  }
122
- const keys = Object.getOwnPropertyNames(entryExports);
123
+ const keys = (0, import_primordials.ObjectGetOwnPropertyNames)(entryExports);
123
124
  const { length } = keys;
124
125
  if (!length) {
125
126
  return false;
126
127
  }
127
128
  for (let i = 0; i < length; i += 1) {
128
129
  const key = keys[i];
129
- if (key.length > 0 && key.charCodeAt(0) === 46) {
130
+ if (key.length > 0 && (0, import_primordials.StringPrototypeCharCodeAt)(key, 0) === 46) {
130
131
  return false;
131
132
  }
132
133
  }
@@ -135,7 +136,7 @@ function isConditionalExports(entryExports) {
135
136
  // @__NO_SIDE_EFFECTS__
136
137
  function isSubpathExports(entryExports) {
137
138
  if ((0, import_objects.isObjectObject)(entryExports)) {
138
- const keys = Object.getOwnPropertyNames(entryExports);
139
+ const keys = (0, import_primordials.ObjectGetOwnPropertyNames)(entryExports);
139
140
  for (let i = 0, { length } = keys; i < length; i += 1) {
140
141
  if (keys[i]?.charCodeAt(0) === 46) {
141
142
  return true;
@@ -40,10 +40,11 @@ var import_normalize = require("../paths/normalize");
40
40
  var import_socket = require("../paths/socket");
41
41
  var import_spawn = require("../spawn");
42
42
  var import_operations = require("./operations");
43
+ var import_primordials = require("../primordials");
43
44
  const FS_CP_OPTIONS = {
44
45
  dereference: true,
45
46
  errorOnExist: false,
46
- filter: (src) => !src.includes("node_modules") && !src.endsWith(".DS_Store"),
47
+ filter: (src) => !src.includes("node_modules") && !(0, import_primordials.StringPrototypeEndsWith)(src, ".DS_Store"),
47
48
  force: true,
48
49
  recursive: true,
49
50
  ...import_platform.WIN32 ? { maxRetries: 3, retryDelay: 100 } : {}
@@ -68,9 +69,9 @@ async function mergePackageJson(pkgJsonPath, originalPkgJson) {
68
69
  const fs = /* @__PURE__ */ getFs();
69
70
  let pkgJson;
70
71
  try {
71
- pkgJson = JSON.parse(await fs.promises.readFile(pkgJsonPath, "utf8"));
72
+ pkgJson = (0, import_primordials.JSONParse)(await fs.promises.readFile(pkgJsonPath, "utf8"));
72
73
  } catch (e) {
73
- throw new Error(`Failed to parse ${pkgJsonPath}: ${(0, import_errors.errorMessage)(e)}`, {
74
+ throw new import_primordials.ErrorCtor(`Failed to parse ${pkgJsonPath}: ${(0, import_errors.errorMessage)(e)}`, {
74
75
  cause: e
75
76
  });
76
77
  }
@@ -80,7 +81,11 @@ async function mergePackageJson(pkgJsonPath, originalPkgJson) {
80
81
  async function resolveRealPath(pathStr) {
81
82
  const fs = /* @__PURE__ */ getFs();
82
83
  const path = /* @__PURE__ */ getPath();
83
- return await fs.promises.realpath(pathStr).catch(() => path.resolve(pathStr));
84
+ try {
85
+ return await fs.promises.realpath(pathStr);
86
+ } catch {
87
+ return path.resolve(pathStr);
88
+ }
84
89
  }
85
90
  async function isolatePackage(packageSpec, options) {
86
91
  const fs = /* @__PURE__ */ getFs();
@@ -95,11 +100,11 @@ async function isolatePackage(packageSpec, options) {
95
100
  const pathToResolve = (0, import_normalize.isAbsolute)(trimmedPath) ? trimmedPath : packageSpec;
96
101
  sourcePath = path.resolve(pathToResolve);
97
102
  if (!fs.existsSync(sourcePath)) {
98
- throw new Error(`Source path does not exist: ${sourcePath}`);
103
+ throw new import_primordials.ErrorCtor(`Source path does not exist: ${sourcePath}`);
99
104
  }
100
105
  const pkgJson = await (0, import_operations.readPackageJson)(sourcePath, { normalize: true });
101
106
  if (!pkgJson) {
102
- throw new Error(`Could not read package.json from: ${sourcePath}`);
107
+ throw new import_primordials.ErrorCtor(`Could not read package.json from: ${sourcePath}`);
103
108
  }
104
109
  packageName = pkgJson.name;
105
110
  } else {
@@ -108,12 +113,12 @@ async function isolatePackage(packageSpec, options) {
108
113
  if (parsed.type === "directory" || parsed.type === "file") {
109
114
  sourcePath = parsed.fetchSpec;
110
115
  if (!sourcePath || !fs.existsSync(sourcePath)) {
111
- throw new Error(`Source path does not exist: ${sourcePath}`);
116
+ throw new import_primordials.ErrorCtor(`Source path does not exist: ${sourcePath}`);
112
117
  }
113
118
  if (!packageName) {
114
119
  const pkgJson = await (0, import_operations.readPackageJson)(sourcePath, { normalize: true });
115
120
  if (!pkgJson) {
116
- throw new Error(`Could not read package.json from: ${sourcePath}`);
121
+ throw new import_primordials.ErrorCtor(`Could not read package.json from: ${sourcePath}`);
117
122
  }
118
123
  packageName = pkgJson.name;
119
124
  }
@@ -122,7 +127,7 @@ async function isolatePackage(packageSpec, options) {
122
127
  }
123
128
  }
124
129
  if (!packageName) {
125
- throw new Error(`Could not determine package name from: ${packageSpec}`);
130
+ throw new import_primordials.ErrorCtor(`Could not determine package name from: ${packageSpec}`);
126
131
  }
127
132
  const sanitizedName = packageName.replace(/[@/]/g, "-");
128
133
  const tempDir = await fs.promises.mkdtemp(
@@ -148,7 +153,7 @@ async function isolatePackage(packageSpec, options) {
148
153
  if (install) {
149
154
  await install(packageTempDir);
150
155
  } else {
151
- const packageInstallSpec = spec.startsWith("https://") ? spec : `${packageName}@${spec}`;
156
+ const packageInstallSpec = (0, import_primordials.StringPrototypeStartsWith)(spec, "https://") ? spec : `${packageName}@${spec}`;
152
157
  await (0, import_spawn.spawn)("pnpm", ["add", packageInstallSpec], {
153
158
  cwd: packageTempDir,
154
159
  shell: import_platform.WIN32,
@@ -168,9 +173,11 @@ async function isolatePackage(packageSpec, options) {
168
173
  }
169
174
  } else {
170
175
  if (!sourcePath) {
171
- throw new Error("sourcePath is required when no version spec provided");
176
+ throw new import_primordials.ErrorCtor(
177
+ "sourcePath is required when no version spec provided"
178
+ );
172
179
  }
173
- const scopedPath = packageName.startsWith("@") ? path.join(
180
+ const scopedPath = (0, import_primordials.StringPrototypeStartsWith)(packageName, "@") ? path.join(
174
181
  packageTempDir,
175
182
  "node_modules",
176
183
  packageName.split("/")[0] ?? ""
@@ -202,7 +209,7 @@ async function isolatePackage(packageSpec, options) {
202
209
  }
203
210
  const exports2 = imports ? { __proto__: null } : void 0;
204
211
  if (imports) {
205
- for (const { 0: key, 1: specifier } of Object.entries(imports)) {
212
+ for (const { 0: key, 1: specifier } of (0, import_primordials.ObjectEntries)(imports)) {
206
213
  const fullPath = path.join(installedPath, specifier);
207
214
  exports2[key] = require(fullPath);
208
215
  }
@@ -46,6 +46,7 @@ var import_spdx_correct = __toESM(require("../external/spdx-correct"));
46
46
  var import_spdx_expression_parse = __toESM(require("../external/spdx-expression-parse"));
47
47
  var import_objects = require("../objects");
48
48
  var import_normalize = require("../paths/normalize");
49
+ var import_primordials = require("../primordials");
49
50
  const copyLeftLicenses = (0, import_licenses.getCopyLeftLicenses)();
50
51
  let _path;
51
52
  // @__NO_SIDE_EFFECTS__
@@ -71,7 +72,7 @@ function collectIncompatibleLicenses(licenseNodes) {
71
72
  }
72
73
  // @__NO_SIDE_EFFECTS__
73
74
  function collectLicenseWarnings(licenseNodes) {
74
- const warnings = /* @__PURE__ */ new Map();
75
+ const warnings = new import_primordials.MapCtor();
75
76
  for (let i = 0, { length } = licenseNodes; i < length; i += 1) {
76
77
  const node = licenseNodes[i];
77
78
  if (!node) {
@@ -139,7 +140,7 @@ function resolvePackageLicenses(licenseFieldValue, where) {
139
140
  if (licenseFieldValue === "UNLICENSED" || licenseFieldValue === "UNLICENCED") {
140
141
  return [{ license: "UNLICENSED" }];
141
142
  }
142
- const match = fileReferenceRegExp.exec(licenseFieldValue);
143
+ const match = (0, import_primordials.RegExpPrototypeExec)(fileReferenceRegExp, licenseFieldValue);
143
144
  if (match) {
144
145
  const path = /* @__PURE__ */ getPath();
145
146
  return [
@@ -174,7 +175,9 @@ function visitLicenses(ast, visitor) {
174
175
  let { length: queueLength } = queue;
175
176
  while (pos < queueLength) {
176
177
  if (pos === import_core.LOOP_SENTINEL) {
177
- throw new Error("Detected infinite loop in ast crawl of visitLicenses");
178
+ throw new import_primordials.ErrorCtor(
179
+ "Detected infinite loop in ast crawl of visitLicenses"
180
+ );
178
181
  }
179
182
  const { 0: node, 1: parent } = queue[pos++];
180
183
  const { type } = node;
@@ -45,6 +45,7 @@ var import_arrays = require("../arrays");
45
45
  var import_objects = require("../objects");
46
46
  var import_exports = require("./exports");
47
47
  var import_validation = require("./validation");
48
+ var import_primordials = require("../primordials");
48
49
  const abortSignal = (0, import_process.getAbortSignal)();
49
50
  const packageDefaultNodeRange = (0, import_packages.getPackageDefaultNodeRange)();
50
51
  const PACKAGE_DEFAULT_SOCKET_CATEGORIES = (0, import_packages.getPackageDefaultSocketCategories)();
@@ -91,7 +92,7 @@ function createPackageJson(sockRegPkgName, directory, options) {
91
92
  ...(0, import_objects.isObjectObject)(overrides) ? { overrides: { ...overrides } } : {},
92
93
  ...(0, import_objects.isObjectObject)(resolutions) ? { resolutions: { ...resolutions } } : {},
93
94
  ...(0, import_objects.isObjectObject)(engines) ? {
94
- engines: Object.fromEntries(
95
+ engines: (0, import_primordials.ObjectFromEntries)(
95
96
  (0, import_objects.objectEntries)(engines).map((pair) => {
96
97
  const strKey = String(pair[0]);
97
98
  const result = [strKey, pair[1]];
@@ -41,11 +41,12 @@ var import_regexps = require("../regexps");
41
41
  var import_normalize_package_data = __toESM(require("../external/normalize-package-data"));
42
42
  var import_objects = require("../objects");
43
43
  var import_operations = require("./operations");
44
+ var import_primordials = require("../primordials");
44
45
  const ArrayIsArray = Array.isArray;
45
46
  const ObjectHasOwn = Object.hasOwn;
46
47
  function getEscapedScopeRegExp() {
47
48
  const firstChar = import_socket.REGISTRY_SCOPE_DELIMITER[0];
48
- return new RegExp(
49
+ return new import_primordials.RegExpCtor(
49
50
  `^[^${(0, import_regexps.escapeRegExp)(firstChar)}]+${(0, import_regexps.escapeRegExp)(import_socket.REGISTRY_SCOPE_DELIMITER)}(?!${(0, import_regexps.escapeRegExp)(firstChar)})`
50
51
  );
51
52
  }
@@ -81,14 +82,17 @@ function normalizePackageJson(pkgJson, options) {
81
82
  // @__NO_SIDE_EFFECTS__
82
83
  function resolveEscapedScope(sockRegPkgName) {
83
84
  const escapedScopeRegExp = getEscapedScopeRegExp();
84
- const match = escapedScopeRegExp.exec(sockRegPkgName)?.[0];
85
+ const match = (0, import_primordials.RegExpPrototypeExec)(escapedScopeRegExp, sockRegPkgName)?.[0];
85
86
  return match || void 0;
86
87
  }
87
88
  // @__NO_SIDE_EFFECTS__
88
89
  function resolveOriginalPackageName(sockRegPkgName) {
89
- const name = sockRegPkgName.startsWith(`${import_socket.SOCKET_REGISTRY_SCOPE}/`) ? sockRegPkgName.slice(import_socket.SOCKET_REGISTRY_SCOPE.length + 1) : sockRegPkgName;
90
+ const name = (0, import_primordials.StringPrototypeStartsWith)(
91
+ sockRegPkgName,
92
+ `${import_socket.SOCKET_REGISTRY_SCOPE}/`
93
+ ) ? sockRegPkgName.slice(import_socket.SOCKET_REGISTRY_SCOPE.length + 1) : sockRegPkgName;
90
94
  const escapedScope = /* @__PURE__ */ resolveEscapedScope(name);
91
- return escapedScope ? `${/* @__PURE__ */ unescapeScope(escapedScope)}/${name.slice(escapedScope.length)}` : name;
95
+ return escapedScope ? `${/* @__PURE__ */ unescapeScope(escapedScope)}/${(0, import_primordials.StringPrototypeSlice)(name, escapedScope.length)}` : name;
92
96
  }
93
97
  // @__NO_SIDE_EFFECTS__
94
98
  function unescapeScope(escapedScope) {
@@ -57,6 +57,7 @@ var import_normalize = require("./normalize");
57
57
  var import_packages2 = require("../paths/packages");
58
58
  var import_specs = require("./specs");
59
59
  var import_edit = require("./edit");
60
+ var import_primordials = require("../primordials");
60
61
  const abortSignal = (0, import_process.getAbortSignal)();
61
62
  const packageExtensions = (0, import_packages.getPackageExtensions)();
62
63
  const packumentCache = (0, import_packages.getPackumentCache)();
@@ -131,13 +132,13 @@ function getReleaseTag(spec) {
131
132
  return "";
132
133
  }
133
134
  let atIndex = -1;
134
- if (spec.startsWith("@")) {
135
- atIndex = spec.indexOf("@", 1);
135
+ if ((0, import_primordials.StringPrototypeStartsWith)(spec, "@")) {
136
+ atIndex = (0, import_primordials.StringPrototypeIndexOf)(spec, "@", 1);
136
137
  } else {
137
- atIndex = spec.indexOf("@");
138
+ atIndex = (0, import_primordials.StringPrototypeIndexOf)(spec, "@");
138
139
  }
139
140
  if (atIndex !== -1) {
140
- return spec.slice(atIndex + 1);
141
+ return (0, import_primordials.StringPrototypeSlice)(spec, atIndex + 1);
141
142
  }
142
143
  return "";
143
144
  }