@socketsecurity/lib 5.18.1 → 5.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +6 -5
  3. package/dist/abort.d.ts +3 -0
  4. package/dist/abort.js +1 -0
  5. package/dist/agent.d.ts +66 -49
  6. package/dist/agent.js +51 -50
  7. package/dist/ansi.d.ts +2 -5
  8. package/dist/ansi.js +3 -2
  9. package/dist/archives.d.ts +25 -21
  10. package/dist/archives.js +35 -34
  11. package/dist/argv/flags.d.ts +100 -91
  12. package/dist/argv/flags.js +88 -87
  13. package/dist/argv/parse.d.ts +30 -40
  14. package/dist/argv/parse.js +33 -32
  15. package/dist/arrays.d.ts +4 -8
  16. package/dist/arrays.js +1 -0
  17. package/dist/bin.d.ts +7 -5
  18. package/dist/bin.js +52 -29
  19. package/dist/cacache.d.ts +13 -12
  20. package/dist/cacache.js +9 -8
  21. package/dist/cache-with-ttl.d.ts +53 -35
  22. package/dist/cache-with-ttl.js +1 -0
  23. package/dist/colors.d.ts +5 -5
  24. package/dist/colors.js +1 -0
  25. package/dist/constants/agents.d.ts +5 -9
  26. package/dist/constants/agents.js +3 -2
  27. package/dist/constants/core.d.ts +5 -10
  28. package/dist/constants/core.js +2 -1
  29. package/dist/constants/encoding.d.ts +3 -3
  30. package/dist/constants/encoding.js +1 -0
  31. package/dist/constants/github.d.ts +3 -3
  32. package/dist/constants/github.js +1 -0
  33. package/dist/constants/licenses.d.ts +9 -2
  34. package/dist/constants/licenses.js +1 -0
  35. package/dist/constants/lifecycle-script-names.js +1 -0
  36. package/dist/constants/maintained-node-versions.d.ts +3 -0
  37. package/dist/constants/maintained-node-versions.js +1 -0
  38. package/dist/constants/node.d.ts +125 -16
  39. package/dist/constants/node.js +74 -73
  40. package/dist/constants/package-default-node-range.d.ts +3 -1
  41. package/dist/constants/package-default-node-range.js +2 -1
  42. package/dist/constants/package-default-socket-categories.d.ts +0 -1
  43. package/dist/constants/package-default-socket-categories.js +1 -0
  44. package/dist/constants/packages.d.ts +12 -17
  45. package/dist/constants/packages.js +31 -16
  46. package/dist/constants/platform.d.ts +1 -2
  47. package/dist/constants/platform.js +2 -1
  48. package/dist/constants/process.d.ts +18 -0
  49. package/dist/constants/process.js +1 -0
  50. package/dist/constants/socket.d.ts +4 -10
  51. package/dist/constants/socket.js +2 -1
  52. package/dist/constants/testing.d.ts +3 -3
  53. package/dist/constants/testing.js +1 -0
  54. package/dist/constants/time.d.ts +3 -4
  55. package/dist/constants/time.js +1 -0
  56. package/dist/constants/typescript.d.ts +10 -3
  57. package/dist/constants/typescript.js +5 -4
  58. package/dist/cover/code.d.ts +3 -0
  59. package/dist/cover/code.js +12 -12
  60. package/dist/cover/formatters.d.ts +12 -9
  61. package/dist/cover/formatters.js +19 -18
  62. package/dist/cover/type.d.ts +3 -0
  63. package/dist/cover/type.js +1 -0
  64. package/dist/cover/types.js +1 -0
  65. package/dist/debug.d.ts +32 -47
  66. package/dist/debug.js +97 -96
  67. package/dist/dlx/arborist.d.ts +134 -0
  68. package/dist/dlx/arborist.js +177 -0
  69. package/dist/dlx/binary.d.ts +25 -9
  70. package/dist/dlx/binary.js +34 -12
  71. package/dist/dlx/cache.d.ts +1 -0
  72. package/dist/dlx/cache.js +2 -1
  73. package/dist/dlx/detect.d.ts +15 -0
  74. package/dist/dlx/detect.js +28 -20
  75. package/dist/dlx/dir.d.ts +1 -11
  76. package/dist/dlx/dir.js +2 -12
  77. package/dist/dlx/integrity.d.ts +86 -0
  78. package/dist/dlx/integrity.js +112 -0
  79. package/dist/dlx/lockfile.d.ts +115 -0
  80. package/dist/dlx/lockfile.js +139 -0
  81. package/dist/dlx/manifest.d.ts +26 -1
  82. package/dist/dlx/manifest.js +9 -6
  83. package/dist/dlx/package.d.ts +58 -3
  84. package/dist/dlx/package.js +101 -74
  85. package/dist/dlx/packages.d.ts +1 -11
  86. package/dist/dlx/packages.js +3 -14
  87. package/dist/dlx/paths.d.ts +1 -0
  88. package/dist/dlx/paths.js +2 -1
  89. package/dist/effects/pulse-frames.js +1 -0
  90. package/dist/effects/text-shimmer.d.ts +13 -2
  91. package/dist/effects/text-shimmer.js +50 -46
  92. package/dist/effects/types.js +1 -0
  93. package/dist/effects/ultra.js +1 -0
  94. package/dist/env/ci.d.ts +6 -1
  95. package/dist/env/ci.js +1 -0
  96. package/dist/env/debug.d.ts +5 -1
  97. package/dist/env/debug.js +1 -0
  98. package/dist/env/github.d.ts +19 -23
  99. package/dist/env/github.js +5 -4
  100. package/dist/env/helpers.d.ts +21 -9
  101. package/dist/env/helpers.js +5 -11
  102. package/dist/env/home.d.ts +17 -4
  103. package/dist/env/home.js +2 -1
  104. package/dist/env/locale.d.ts +4 -3
  105. package/dist/env/locale.js +1 -0
  106. package/dist/env/node-auth-token.d.ts +5 -1
  107. package/dist/env/node-auth-token.js +1 -0
  108. package/dist/env/node-env.d.ts +5 -1
  109. package/dist/env/node-env.js +1 -0
  110. package/dist/env/npm.d.ts +4 -5
  111. package/dist/env/npm.js +1 -0
  112. package/dist/env/package-manager.d.ts +4 -3
  113. package/dist/env/package-manager.js +2 -1
  114. package/dist/env/path.d.ts +5 -1
  115. package/dist/env/path.js +1 -0
  116. package/dist/env/pre-commit.d.ts +5 -1
  117. package/dist/env/pre-commit.js +1 -0
  118. package/dist/env/rewire.d.ts +10 -0
  119. package/dist/env/rewire.js +7 -5
  120. package/dist/env/shell.d.ts +5 -1
  121. package/dist/env/shell.js +1 -0
  122. package/dist/env/socket-cli-shadow.d.ts +4 -5
  123. package/dist/env/socket-cli-shadow.js +1 -0
  124. package/dist/env/socket-cli.d.ts +4 -14
  125. package/dist/env/socket-cli.js +1 -0
  126. package/dist/env/socket.d.ts +6 -18
  127. package/dist/env/socket.js +4 -3
  128. package/dist/env/temp-dir.d.ts +4 -3
  129. package/dist/env/temp-dir.js +1 -0
  130. package/dist/env/term.d.ts +5 -1
  131. package/dist/env/term.js +1 -0
  132. package/dist/env/test.d.ts +4 -3
  133. package/dist/env/test.js +1 -0
  134. package/dist/env/windows.d.ts +4 -4
  135. package/dist/env/windows.js +1 -0
  136. package/dist/env/xdg.d.ts +4 -3
  137. package/dist/env/xdg.js +1 -0
  138. package/dist/env.d.ts +83 -23
  139. package/dist/env.js +112 -80
  140. package/dist/errors.js +1 -0
  141. package/dist/external/@npmcli/package-json.js +9 -3968
  142. package/dist/external/@socketregistry/packageurl-js.js +2 -2
  143. package/dist/external/debug.js +162 -328
  144. package/dist/external/external-pack.js +3 -2835
  145. package/dist/external/npm-pack.js +13939 -33342
  146. package/dist/external/zod.js +160 -7558
  147. package/dist/fs.d.ts +92 -113
  148. package/dist/fs.js +35 -35
  149. package/dist/git.d.ts +170 -164
  150. package/dist/git.js +113 -87
  151. package/dist/github.d.ts +249 -227
  152. package/dist/github.js +82 -81
  153. package/dist/globs.d.ts +31 -17
  154. package/dist/globs.js +51 -58
  155. package/dist/http-request.d.ts +99 -99
  156. package/dist/http-request.js +182 -156
  157. package/dist/ipc-cli.d.ts +28 -0
  158. package/dist/{utils/get-ipc.js → ipc-cli.js} +4 -3
  159. package/dist/ipc.d.ts +9 -299
  160. package/dist/ipc.js +18 -204
  161. package/dist/json/edit.d.ts +3 -1
  162. package/dist/json/edit.js +30 -30
  163. package/dist/json/format.d.ts +36 -36
  164. package/dist/json/format.js +22 -21
  165. package/dist/json/parse.d.ts +4 -2
  166. package/dist/json/parse.js +1 -0
  167. package/dist/json/types.js +1 -0
  168. package/dist/{links/index.d.ts → links.d.ts} +6 -2
  169. package/dist/{links/index.js → links.js} +5 -4
  170. package/dist/logger.d.ts +4 -6
  171. package/dist/logger.js +61 -53
  172. package/dist/memoization.d.ts +52 -49
  173. package/dist/memoization.js +55 -33
  174. package/dist/objects.d.ts +25 -44
  175. package/dist/objects.js +2 -1
  176. package/dist/package-extensions.d.ts +6 -0
  177. package/dist/package-extensions.js +2 -1
  178. package/dist/packages/edit.d.ts +3 -5
  179. package/dist/packages/edit.js +4 -3
  180. package/dist/packages/exports.d.ts +11 -14
  181. package/dist/packages/exports.js +11 -10
  182. package/dist/packages/isolation.d.ts +4 -0
  183. package/dist/packages/isolation.js +20 -19
  184. package/dist/packages/licenses.d.ts +3 -10
  185. package/dist/packages/licenses.js +2 -1
  186. package/dist/packages/manifest.d.ts +3 -3
  187. package/dist/packages/manifest.js +1 -0
  188. package/dist/packages/normalize.d.ts +3 -4
  189. package/dist/packages/normalize.js +1 -0
  190. package/dist/packages/operations.d.ts +3 -10
  191. package/dist/packages/operations.js +1 -0
  192. package/dist/packages/provenance.d.ts +10 -8
  193. package/dist/packages/provenance.js +55 -54
  194. package/dist/packages/specs.d.ts +3 -5
  195. package/dist/packages/specs.js +1 -0
  196. package/dist/packages/validation.d.ts +3 -3
  197. package/dist/packages/validation.js +1 -0
  198. package/dist/packages.d.ts +2 -17
  199. package/dist/packages.js +2 -1
  200. package/dist/paths/dirnames.d.ts +0 -2
  201. package/dist/paths/dirnames.js +1 -0
  202. package/dist/paths/exts.d.ts +0 -1
  203. package/dist/paths/exts.js +1 -0
  204. package/dist/paths/filenames.d.ts +0 -1
  205. package/dist/paths/filenames.js +1 -0
  206. package/dist/paths/globs.d.ts +0 -1
  207. package/dist/paths/globs.js +1 -0
  208. package/dist/paths/normalize.d.ts +115 -123
  209. package/dist/paths/normalize.js +128 -127
  210. package/dist/paths/packages.d.ts +3 -2
  211. package/dist/paths/packages.js +2 -1
  212. package/dist/paths/rewire.d.ts +9 -0
  213. package/dist/paths/rewire.js +5 -3
  214. package/dist/paths/socket.d.ts +37 -23
  215. package/dist/paths/socket.js +26 -25
  216. package/dist/performance.d.ts +87 -84
  217. package/dist/performance.js +97 -96
  218. package/dist/process-lock.d.ts +41 -1
  219. package/dist/process-lock.js +24 -17
  220. package/dist/promise-queue.d.ts +6 -0
  221. package/dist/promise-queue.js +1 -0
  222. package/dist/promises.d.ts +40 -55
  223. package/dist/promises.js +12 -11
  224. package/dist/regexps.d.ts +0 -5
  225. package/dist/regexps.js +1 -0
  226. package/dist/releases/github.d.ts +59 -63
  227. package/dist/releases/github.js +95 -100
  228. package/dist/releases/socket-btm.d.ts +9 -2
  229. package/dist/releases/socket-btm.js +32 -25
  230. package/dist/sea.d.ts +5 -0
  231. package/dist/sea.js +1 -0
  232. package/dist/shadow.d.ts +4 -0
  233. package/dist/shadow.js +1 -0
  234. package/dist/signal-exit.d.ts +7 -7
  235. package/dist/signal-exit.js +46 -45
  236. package/dist/sorts.d.ts +5 -7
  237. package/dist/sorts.js +11 -10
  238. package/dist/spawn.d.ts +96 -77
  239. package/dist/spawn.js +39 -38
  240. package/dist/spinner.d.ts +21 -22
  241. package/dist/spinner.js +15 -11
  242. package/dist/ssri.d.ts +31 -36
  243. package/dist/ssri.js +15 -14
  244. package/dist/stdio/_stream.d.ts +31 -0
  245. package/dist/stdio/_stream.js +57 -0
  246. package/dist/stdio/divider.d.ts +40 -36
  247. package/dist/stdio/divider.js +10 -9
  248. package/dist/stdio/footer.d.ts +20 -0
  249. package/dist/stdio/footer.js +12 -2
  250. package/dist/stdio/header.d.ts +4 -16
  251. package/dist/stdio/header.js +1 -9
  252. package/dist/stdio/stderr.d.ts +51 -39
  253. package/dist/stdio/stderr.js +19 -22
  254. package/dist/stdio/stdout.d.ts +54 -52
  255. package/dist/stdio/stdout.js +35 -33
  256. package/dist/streams.d.ts +4 -3
  257. package/dist/streams.js +1 -0
  258. package/dist/strings.d.ts +31 -85
  259. package/dist/strings.js +5 -49
  260. package/dist/suppress-warnings.d.ts +32 -15
  261. package/dist/suppress-warnings.js +14 -13
  262. package/dist/tables.d.ts +30 -26
  263. package/dist/tables.js +24 -23
  264. package/dist/temporary-executor.d.ts +4 -0
  265. package/dist/temporary-executor.js +1 -0
  266. package/dist/themes/context.d.ts +30 -26
  267. package/dist/themes/context.js +19 -18
  268. package/dist/themes/index.d.ts +0 -4
  269. package/dist/themes/index.js +1 -0
  270. package/dist/themes/themes.d.ts +1 -1
  271. package/dist/themes/themes.js +1 -0
  272. package/dist/themes/types.js +1 -0
  273. package/dist/themes/utils.d.ts +46 -43
  274. package/dist/themes/utils.js +45 -44
  275. package/dist/types.d.ts +48 -52
  276. package/dist/types.js +35 -35
  277. package/dist/url.d.ts +48 -53
  278. package/dist/url.js +38 -37
  279. package/dist/validation/json-parser.d.ts +19 -190
  280. package/dist/validation/json-parser.js +5 -69
  281. package/dist/validation/types.d.ts +9 -33
  282. package/dist/validation/types.js +1 -0
  283. package/dist/versions.d.ts +1 -0
  284. package/dist/versions.js +2 -1
  285. package/dist/words.d.ts +3 -6
  286. package/dist/words.js +1 -0
  287. package/dist/zod.js +1 -0
  288. package/package.json +34 -70
  289. package/dist/external/@inquirer/checkbox.js +0 -5
  290. package/dist/external/@inquirer/confirm.js +0 -5
  291. package/dist/external/@inquirer/input.js +0 -5
  292. package/dist/external/@inquirer/password.js +0 -5
  293. package/dist/external/@inquirer/search.js +0 -5
  294. package/dist/external/@inquirer/select.js +0 -5
  295. package/dist/functions.d.ts +0 -57
  296. package/dist/functions.js +0 -70
  297. package/dist/stdio/clear.d.ts +0 -140
  298. package/dist/stdio/clear.js +0 -95
  299. package/dist/stdio/mask.d.ts +0 -151
  300. package/dist/stdio/mask.js +0 -224
  301. package/dist/stdio/progress.d.ts +0 -148
  302. package/dist/stdio/progress.js +0 -212
  303. package/dist/stdio/prompts.d.ts +0 -195
  304. package/dist/stdio/prompts.js +0 -176
  305. package/dist/utils/get-ipc.d.ts +0 -15
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Testing framework constants and CI environment detection.
2
+ * @fileoverview Testing framework and CI-related string constants.
3
+ * Exports the canonical `TEST`, `VITEST`, `CI`, and `PRE_COMMIT` name
4
+ * strings referenced by env checks and configuration.
3
5
  */
4
- // Testing frameworks.
5
6
  export declare const TEST = "test";
6
7
  export declare const VITEST = "VITEST";
7
- // CI environment.
8
8
  export declare const CI = "CI";
9
9
  export declare const PRE_COMMIT = "PRE_COMMIT";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,11 +1,10 @@
1
1
  /**
2
- * Time-related constants including cache TTLs and timeouts.
2
+ * @fileoverview Time-related numeric constants.
3
+ * Provides millisecond-per-unit multipliers (second/minute/hour/day) and
4
+ * derived cache TTLs such as the DLX binary cache expiration.
3
5
  */
4
- // Time unit multipliers (milliseconds).
5
6
  export declare const MILLISECONDS_PER_SECOND = 1000;
6
7
  export declare const MILLISECONDS_PER_MINUTE: number;
7
8
  export declare const MILLISECONDS_PER_HOUR: number;
8
9
  export declare const MILLISECONDS_PER_DAY: number;
9
- // Cache TTL values.
10
- // DLX binary cache expires after 7 days.
11
10
  export declare const DLX_BINARY_CACHE_TTL: number;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,6 +1,13 @@
1
1
  /**
2
- * TypeScript availability and type system checks.
2
+ * @fileoverview TypeScript availability detection.
3
+ * Exports small getters that probe whether the `typescript` package's type
4
+ * definitions and lib files are resolvable from the current project.
5
+ */
6
+ /**
7
+ * Check whether TypeScript's `lib/` directory is resolvable from the current
8
+ * project by probing `typescript/lib`.
9
+ *
10
+ * @returns `true` when the `typescript` package's libs can be resolved.
3
11
  */
4
- // TypeScript types/libs availability.
5
- export declare function getTsTypesAvailable(): boolean;
6
12
  export declare function getTsLibsAvailable(): boolean;
13
+ export declare function getTsTypesAvailable(): boolean;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -33,17 +34,17 @@ __export(typescript_exports, {
33
34
  getTsTypesAvailable: () => getTsTypesAvailable
34
35
  });
35
36
  module.exports = __toCommonJS(typescript_exports);
36
- function getTsTypesAvailable() {
37
+ function getTsLibsAvailable() {
37
38
  try {
38
- require.resolve("typescript/lib/lib.d.ts");
39
+ require.resolve("typescript/lib");
39
40
  return true;
40
41
  } catch {
41
42
  return false;
42
43
  }
43
44
  }
44
- function getTsLibsAvailable() {
45
+ function getTsTypesAvailable() {
45
46
  try {
46
- require.resolve("typescript/lib");
47
+ require.resolve("typescript/lib/lib.d.ts");
47
48
  return true;
48
49
  } catch {
49
50
  return false;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @fileoverview Code coverage utilities for parsing v8 coverage data.
3
+ */
1
4
  import type { CodeCoverageResult, GetCodeCoverageOptions } from './types';
2
5
  /**
3
6
  * Get code coverage metrics from v8 coverage-final.json.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -38,17 +39,25 @@ var import_objects = require("../objects");
38
39
  var import_spawn = require("../spawn");
39
40
  let _fs;
40
41
  let _path;
42
+ function calculateMetric(data) {
43
+ const percent = data.total === 0 ? "0.00" : (data.covered / data.total * 100).toFixed(2);
44
+ return {
45
+ covered: data.covered,
46
+ percent,
47
+ total: data.total
48
+ };
49
+ }
41
50
  // @__NO_SIDE_EFFECTS__
42
51
  function getFs() {
43
52
  if (_fs === void 0) {
44
- _fs = require("fs");
53
+ _fs = require("node:fs");
45
54
  }
46
55
  return _fs;
47
56
  }
48
57
  // @__NO_SIDE_EFFECTS__
49
58
  function getPath() {
50
59
  if (_path === void 0) {
51
- _path = require("path");
60
+ _path = require("node:path");
52
61
  }
53
62
  return _path;
54
63
  }
@@ -65,8 +74,7 @@ async function getCodeCoverage(options) {
65
74
  throw new Error("Coverage path is required");
66
75
  }
67
76
  const fs = /* @__PURE__ */ getFs();
68
- const coverageExists = await fs.promises.access(coveragePath).then(() => true).catch(() => false);
69
- if (!coverageExists) {
77
+ if (!fs.existsSync(coveragePath)) {
70
78
  if (generateIfMissing) {
71
79
  await (0, import_spawn.spawn)("vitest", ["run", "--coverage"], {
72
80
  cwd: import_node_process.default.cwd(),
@@ -142,14 +150,6 @@ async function getCodeCoverage(options) {
142
150
  statements: calculateMetric(totals.statements)
143
151
  };
144
152
  }
145
- function calculateMetric(data) {
146
- const percent = data.total === 0 ? "0.00" : (data.covered / data.total * 100).toFixed(2);
147
- return {
148
- covered: data.covered,
149
- percent,
150
- total: data.total
151
- };
152
- }
153
153
  // Annotate the CommonJS export names for ESM import in node:
154
154
  0 && (module.exports = {
155
155
  getCodeCoverage
@@ -1,14 +1,7 @@
1
- import type { FormatCoverageOptions } from './types';
2
1
  /**
3
- * Get emoji for coverage percentage.
4
- *
5
- * @example
6
- * ```typescript
7
- * getCoverageEmoji(95) // ' \u{1F3AF}'
8
- * getCoverageEmoji(50) // ' \u{1F528}'
9
- * ```
2
+ * @fileoverview Coverage output formatters.
10
3
  */
11
- export declare function getCoverageEmoji(percent: number): string;
4
+ import type { FormatCoverageOptions } from './types';
12
5
  /**
13
6
  * Format coverage data for console output.
14
7
  *
@@ -25,3 +18,13 @@ export declare function getCoverageEmoji(percent: number): string;
25
18
  * ```
26
19
  */
27
20
  export declare function formatCoverage(options: FormatCoverageOptions): string;
21
+ /**
22
+ * Get emoji for coverage percentage.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * getCoverageEmoji(95) // ' \u{1F3AF}'
27
+ * getCoverageEmoji(50) // ' \u{1F528}'
28
+ * ```
29
+ */
30
+ export declare function getCoverageEmoji(percent: number): string;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -35,11 +36,19 @@ const COVERAGE_EMOJI_THRESHOLDS = [
35
36
  { emoji: " \u{1F528}", threshold: 50 },
36
37
  { emoji: " \u26A0\uFE0F", threshold: 0 }
37
38
  ];
38
- function getCoverageEmoji(percent) {
39
- const entry = COVERAGE_EMOJI_THRESHOLDS.find(
40
- ({ threshold }) => percent >= threshold
41
- );
42
- return entry?.emoji || "";
39
+ function calculateOverall(code, type) {
40
+ const metrics = [
41
+ Number.parseFloat(code.statements.percent),
42
+ Number.parseFloat(code.branches.percent),
43
+ Number.parseFloat(code.functions.percent),
44
+ Number.parseFloat(code.lines.percent)
45
+ ].map((val) => Number.isNaN(val) ? 0 : val);
46
+ if (type) {
47
+ const typePercent = Number.parseFloat(type.percent);
48
+ metrics.push(Number.isNaN(typePercent) ? 0 : typePercent);
49
+ }
50
+ const average = metrics.reduce((sum, val) => sum + val, 0) / metrics.length;
51
+ return average.toFixed(2);
43
52
  }
44
53
  function formatCoverage(options) {
45
54
  const opts = {
@@ -84,19 +93,11 @@ Overall: ${overall}%${emoji}
84
93
  `;
85
94
  return output;
86
95
  }
87
- function calculateOverall(code, type) {
88
- const metrics = [
89
- Number.parseFloat(code.statements.percent),
90
- Number.parseFloat(code.branches.percent),
91
- Number.parseFloat(code.functions.percent),
92
- Number.parseFloat(code.lines.percent)
93
- ].map((val) => Number.isNaN(val) ? 0 : val);
94
- if (type) {
95
- const typePercent = Number.parseFloat(type.percent);
96
- metrics.push(Number.isNaN(typePercent) ? 0 : typePercent);
97
- }
98
- const average = metrics.reduce((sum, val) => sum + val, 0) / metrics.length;
99
- return average.toFixed(2);
96
+ function getCoverageEmoji(percent) {
97
+ const entry = COVERAGE_EMOJI_THRESHOLDS.find(
98
+ ({ threshold }) => percent >= threshold
99
+ );
100
+ return entry?.emoji || "";
100
101
  }
101
102
  // Annotate the CommonJS export names for ESM import in node:
102
103
  0 && (module.exports = {
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @fileoverview TypeScript type coverage utilities.
3
+ */
1
4
  import type { GetTypeCoverageOptions, TypeCoverageResult } from './types';
2
5
  /**
3
6
  * Get TypeScript type coverage metrics.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
package/dist/debug.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- // Type definitions
1
+ /**
2
+ * @fileoverview Debug logging utilities with lazy loading and environment-based control.
3
+ * Provides Socket CLI specific debug functionality and logging formatters.
4
+ */
2
5
  interface DebugOptions {
3
6
  namespaces?: string;
4
7
  spinner?: {
@@ -16,24 +19,9 @@ interface InspectOptions {
16
19
  }
17
20
  export type { DebugOptions, NamespacesOrOptions, InspectOptions };
18
21
  /**
19
- * Debug output for object inspection with caller info.
20
- */
21
- declare function debugDirNs(namespacesOrOpts: NamespacesOrOptions, obj: unknown, inspectOpts?: InspectOptions | undefined): void;
22
- /**
23
- * Debug output with caller info.
24
- */
25
- declare function debugNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]): void;
26
- /**
27
- * Debug logging function with caller info.
28
- */
29
- declare function debugLogNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]): void;
30
- /**
31
- * Debug output for cache operations with caller info.
32
- * First argument is the operation type (hit/miss/set/clear).
33
- * Second argument is the cache key or message.
34
- * Optional third argument is metadata object.
22
+ * Debug output with caller info (wrapper for debugNs with default namespace).
35
23
  */
36
- declare function debugCacheNs(namespacesOrOpts: NamespacesOrOptions, operation: string, key: string, meta?: unknown | undefined): void;
24
+ export declare function debug(...args: unknown[]): void;
37
25
  /**
38
26
  * Cache debug function with caller info.
39
27
  *
@@ -43,56 +31,53 @@ declare function debugCacheNs(namespacesOrOpts: NamespacesOrOptions, operation:
43
31
  * debugCache('miss', 'socket-sdk:scans:xyz', { ttl: 60000 })
44
32
  * ```
45
33
  */
46
- /*@__NO_SIDE_EFFECTS__*/
47
34
  export declare function debugCache(operation: string, key: string, meta?: unknown | undefined): void;
48
35
  /**
49
- * Check if debug mode is enabled.
36
+ * Debug output for cache operations with caller info.
37
+ * First argument is the operation type (hit/miss/set/clear).
38
+ * Second argument is the cache key or message.
39
+ * Optional third argument is metadata object.
50
40
  */
51
- /*@__NO_SIDE_EFFECTS__*/
52
- declare function isDebugNs(namespaces: string | undefined): boolean;
41
+ export declare function debugCacheNs(namespacesOrOpts: NamespacesOrOptions, operation: string, key: string, meta?: unknown | undefined): void;
53
42
  /**
54
- * Debug output with caller info (wrapper for debugNs with default namespace).
43
+ * Debug output for object inspection (wrapper for debugDirNs with default namespace).
55
44
  */
56
- declare function debug(...args: unknown[]): void;
45
+ export declare function debugDir(obj: unknown, inspectOpts?: InspectOptions | undefined): void;
57
46
  /**
58
- * Debug output for object inspection (wrapper for debugDirNs with default namespace).
47
+ * Debug output for object inspection with caller info.
59
48
  */
60
- declare function debugDir(obj: unknown, inspectOpts?: InspectOptions | undefined): void;
49
+ export declare function debugDirNs(namespacesOrOpts: NamespacesOrOptions, obj: unknown, inspectOpts?: InspectOptions | undefined): void;
61
50
  /**
62
51
  * Debug logging function (wrapper for debugLogNs with default namespace).
63
52
  */
64
- declare function debugLog(...args: unknown[]): void;
53
+ export declare function debugLog(...args: unknown[]): void;
65
54
  /**
66
- * Check if debug mode is enabled.
55
+ * Debug logging function with caller info.
67
56
  */
68
- /*@__NO_SIDE_EFFECTS__*/
69
- declare function isDebug(): boolean;
57
+ export declare function debugLogNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]): void;
70
58
  /**
71
59
  * Create a Node.js util.debuglog compatible function.
72
60
  * Returns a function that conditionally writes debug messages to stderr.
73
61
  */
74
- /*@__NO_SIDE_EFFECTS__*/
75
- declare function debuglog(section: string): import("util").DebugLogger;
62
+ export declare function debuglog(section: string): import("util").DebugLogger;
63
+ /**
64
+ * Debug output with caller info.
65
+ */
66
+ export declare function debugNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]): void;
76
67
  /**
77
68
  * Create timing functions for measuring code execution time.
78
69
  * Returns an object with start() and end() methods, plus a callable function.
79
70
  */
80
- /*@__NO_SIDE_EFFECTS__*/
81
- declare function debugtime(label: string): {
71
+ export declare function debugtime(label: string): {
82
72
  (): void;
83
73
  start: () => void;
84
74
  end: () => void;
85
75
  };
86
- // Export main debug functions with caller info.
87
- export { debug };
88
- // debugCache is already exported directly above
89
- export { debugCacheNs };
90
- export { debugDir };
91
- export { debugDirNs };
92
- export { debugLog };
93
- export { debuglog };
94
- export { debugLogNs };
95
- export { debugNs };
96
- export { debugtime };
97
- export { isDebug };
98
- export { isDebugNs };
76
+ /**
77
+ * Check if debug mode is enabled.
78
+ */
79
+ export declare function isDebug(): boolean;
80
+ /**
81
+ * Check if debug mode is enabled.
82
+ */
83
+ export declare function isDebugNs(namespaces: string | undefined): boolean;
package/dist/debug.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -54,27 +55,23 @@ var import_strings = require("./strings");
54
55
  const ReflectApply = Reflect.apply;
55
56
  const logger = (0, import_logger.getDefaultLogger)();
56
57
  const debugByNamespace = /* @__PURE__ */ new Map();
58
+ let _util;
59
+ let pointingTriangle;
57
60
  // @__NO_SIDE_EFFECTS__
58
- function getDebugJsInstance(namespace) {
59
- let inst = debugByNamespace.get(namespace);
60
- if (inst) {
61
- return inst;
62
- }
63
- if (!(0, import_debug.getDebug)() && (0, import_socket.getSocketDebug)() && (namespace === "error" || namespace === "notice")) {
64
- import_debug2.default.enable(namespace);
65
- }
66
- inst = (0, import_debug2.default)(namespace);
67
- inst.log = customLog;
68
- debugByNamespace.set(namespace, inst);
69
- return inst;
61
+ function customLog(...args) {
62
+ const util = /* @__PURE__ */ getUtil();
63
+ const inspectOpts = import_debug2.default.inspectOpts ? {
64
+ ...import_debug2.default.inspectOpts,
65
+ showHidden: import_debug2.default.inspectOpts.showHidden === null ? void 0 : import_debug2.default.inspectOpts.showHidden,
66
+ depth: import_debug2.default.inspectOpts.depth === null || typeof import_debug2.default.inspectOpts.depth === "boolean" ? void 0 : import_debug2.default.inspectOpts.depth
67
+ } : {};
68
+ ReflectApply(logger.info, logger, [
69
+ util.formatWithOptions(inspectOpts, ...args)
70
+ ]);
70
71
  }
71
- let _util;
72
72
  // @__NO_SIDE_EFFECTS__
73
- function getUtil() {
74
- if (_util === void 0) {
75
- _util = require("util");
76
- }
77
- return _util;
73
+ function extractOptions(namespaces) {
74
+ return namespaces !== null && typeof namespaces === "object" ? { __proto__: null, ...namespaces } : { __proto__: null, namespaces };
78
75
  }
79
76
  // @__NO_SIDE_EFFECTS__
80
77
  function getCallerInfo(stackOffset = 3) {
@@ -116,20 +113,25 @@ function getCallerInfo(stackOffset = 3) {
116
113
  return name;
117
114
  }
118
115
  // @__NO_SIDE_EFFECTS__
119
- function customLog(...args) {
120
- const util = /* @__PURE__ */ getUtil();
121
- const inspectOpts = import_debug2.default.inspectOpts ? {
122
- ...import_debug2.default.inspectOpts,
123
- showHidden: import_debug2.default.inspectOpts.showHidden === null ? void 0 : import_debug2.default.inspectOpts.showHidden,
124
- depth: import_debug2.default.inspectOpts.depth === null || typeof import_debug2.default.inspectOpts.depth === "boolean" ? void 0 : import_debug2.default.inspectOpts.depth
125
- } : {};
126
- ReflectApply(logger.info, logger, [
127
- util.formatWithOptions(inspectOpts, ...args)
128
- ]);
116
+ function getDebugJsInstance(namespace) {
117
+ let inst = debugByNamespace.get(namespace);
118
+ if (inst) {
119
+ return inst;
120
+ }
121
+ if (!(0, import_debug.getDebug)() && (0, import_socket.getSocketDebug)() && (namespace === "error" || namespace === "notice")) {
122
+ import_debug2.default.enable(namespace);
123
+ }
124
+ inst = (0, import_debug2.default)(namespace);
125
+ inst.log = customLog;
126
+ debugByNamespace.set(namespace, inst);
127
+ return inst;
129
128
  }
130
129
  // @__NO_SIDE_EFFECTS__
131
- function extractOptions(namespaces) {
132
- return namespaces !== null && typeof namespaces === "object" ? { __proto__: null, ...namespaces } : { __proto__: null, namespaces };
130
+ function getUtil() {
131
+ if (_util === void 0) {
132
+ _util = require("node:util");
133
+ }
134
+ return _util;
133
135
  }
134
136
  // @__NO_SIDE_EFFECTS__
135
137
  function isEnabled(namespaces) {
@@ -154,6 +156,47 @@ function isEnabled(namespaces) {
154
156
  }
155
157
  return skips.every((ns) => !(/* @__PURE__ */ getDebugJsInstance(ns)).enabled);
156
158
  }
159
+ function debug(...args) {
160
+ debugNs("*", ...args);
161
+ }
162
+ // @__NO_SIDE_EFFECTS__
163
+ function debugCache(operation, key, meta) {
164
+ if (!(0, import_socket.getSocketDebug)()) {
165
+ return;
166
+ }
167
+ const callerName = /* @__PURE__ */ getCallerInfo(3) || "cache";
168
+ if (pointingTriangle === void 0) {
169
+ const supported = (0, import_is_unicode_supported.default)();
170
+ pointingTriangle = supported ? "\u25B8" : ">";
171
+ }
172
+ const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`;
173
+ const args = meta !== void 0 ? [prefix, meta] : [prefix];
174
+ console.log(...args);
175
+ }
176
+ function debugCacheNs(namespacesOrOpts, operation, key, meta) {
177
+ const options = /* @__PURE__ */ extractOptions(namespacesOrOpts);
178
+ const { namespaces } = options;
179
+ if (!/* @__PURE__ */ isEnabled(namespaces)) {
180
+ return;
181
+ }
182
+ const callerName = /* @__PURE__ */ getCallerInfo(4) || "cache";
183
+ if (pointingTriangle === void 0) {
184
+ const supported = (0, import_is_unicode_supported.default)();
185
+ pointingTriangle = supported ? "\u25B8" : ">";
186
+ }
187
+ const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`;
188
+ const logArgs = meta !== void 0 ? [prefix, meta] : [prefix];
189
+ const spinnerInstance = options.spinner || (0, import_spinner.getDefaultSpinner)();
190
+ const wasSpinning = spinnerInstance?.isSpinning;
191
+ spinnerInstance?.stop();
192
+ ReflectApply(logger.info, logger, logArgs);
193
+ if (wasSpinning) {
194
+ spinnerInstance?.start();
195
+ }
196
+ }
197
+ function debugDir(obj, inspectOpts) {
198
+ debugDirNs("*", obj, inspectOpts);
199
+ }
157
200
  function debugDirNs(namespacesOrOpts, obj, inspectOpts) {
158
201
  const options = /* @__PURE__ */ extractOptions(namespacesOrOpts);
159
202
  const { namespaces } = options;
@@ -185,14 +228,16 @@ function debugDirNs(namespacesOrOpts, obj, inspectOpts) {
185
228
  spinnerInstance?.start();
186
229
  }
187
230
  }
188
- let pointingTriangle;
189
- function debugNs(namespacesOrOpts, ...args) {
231
+ function debugLog(...args) {
232
+ debugLogNs("*", ...args);
233
+ }
234
+ function debugLogNs(namespacesOrOpts, ...args) {
190
235
  const options = /* @__PURE__ */ extractOptions(namespacesOrOpts);
191
236
  const { namespaces } = options;
192
237
  if (!/* @__PURE__ */ isEnabled(namespaces)) {
193
238
  return;
194
239
  }
195
- const name = /* @__PURE__ */ getCallerInfo(4) || "anonymous";
240
+ const callerName = /* @__PURE__ */ getCallerInfo(4) || "anonymous";
196
241
  if (pointingTriangle === void 0) {
197
242
  const supported = (0, import_is_unicode_supported.default)();
198
243
  pointingTriangle = supported ? "\u25B8" : ">";
@@ -200,11 +245,11 @@ function debugNs(namespacesOrOpts, ...args) {
200
245
  const text = args.at(0);
201
246
  const logArgs = typeof text === "string" ? [
202
247
  (0, import_strings.applyLinePrefix)(
203
- `${name ? `${name} ${pointingTriangle} ` : ""}${text}`,
248
+ `${callerName ? `${callerName} ${pointingTriangle} ` : ""}${text}`,
204
249
  { prefix: "[DEBUG] " }
205
250
  ),
206
251
  ...args.slice(1)
207
- ] : args;
252
+ ] : [`[DEBUG] ${callerName} ${pointingTriangle}`, ...args];
208
253
  const spinnerInstance = options.spinner || (0, import_spinner.getDefaultSpinner)();
209
254
  const wasSpinning = spinnerInstance?.isSpinning;
210
255
  spinnerInstance?.stop();
@@ -213,13 +258,18 @@ function debugNs(namespacesOrOpts, ...args) {
213
258
  spinnerInstance?.start();
214
259
  }
215
260
  }
216
- function debugLogNs(namespacesOrOpts, ...args) {
261
+ // @__NO_SIDE_EFFECTS__
262
+ function debuglog(section) {
263
+ const util = /* @__PURE__ */ getUtil();
264
+ return util.debuglog(section);
265
+ }
266
+ function debugNs(namespacesOrOpts, ...args) {
217
267
  const options = /* @__PURE__ */ extractOptions(namespacesOrOpts);
218
268
  const { namespaces } = options;
219
269
  if (!/* @__PURE__ */ isEnabled(namespaces)) {
220
270
  return;
221
271
  }
222
- const callerName = /* @__PURE__ */ getCallerInfo(4) || "anonymous";
272
+ const name = /* @__PURE__ */ getCallerInfo(4) || "anonymous";
223
273
  if (pointingTriangle === void 0) {
224
274
  const supported = (0, import_is_unicode_supported.default)();
225
275
  pointingTriangle = supported ? "\u25B8" : ">";
@@ -227,32 +277,11 @@ function debugLogNs(namespacesOrOpts, ...args) {
227
277
  const text = args.at(0);
228
278
  const logArgs = typeof text === "string" ? [
229
279
  (0, import_strings.applyLinePrefix)(
230
- `${callerName ? `${callerName} ${pointingTriangle} ` : ""}${text}`,
280
+ `${name ? `${name} ${pointingTriangle} ` : ""}${text}`,
231
281
  { prefix: "[DEBUG] " }
232
282
  ),
233
283
  ...args.slice(1)
234
- ] : [`[DEBUG] ${callerName} ${pointingTriangle}`, ...args];
235
- const spinnerInstance = options.spinner || (0, import_spinner.getDefaultSpinner)();
236
- const wasSpinning = spinnerInstance?.isSpinning;
237
- spinnerInstance?.stop();
238
- ReflectApply(logger.info, logger, logArgs);
239
- if (wasSpinning) {
240
- spinnerInstance?.start();
241
- }
242
- }
243
- function debugCacheNs(namespacesOrOpts, operation, key, meta) {
244
- const options = /* @__PURE__ */ extractOptions(namespacesOrOpts);
245
- const { namespaces } = options;
246
- if (!/* @__PURE__ */ isEnabled(namespaces)) {
247
- return;
248
- }
249
- const callerName = /* @__PURE__ */ getCallerInfo(4) || "cache";
250
- if (pointingTriangle === void 0) {
251
- const supported = (0, import_is_unicode_supported.default)();
252
- pointingTriangle = supported ? "\u25B8" : ">";
253
- }
254
- const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`;
255
- const logArgs = meta !== void 0 ? [prefix, meta] : [prefix];
284
+ ] : args;
256
285
  const spinnerInstance = options.spinner || (0, import_spinner.getDefaultSpinner)();
257
286
  const wasSpinning = spinnerInstance?.isSpinning;
258
287
  spinnerInstance?.stop();
@@ -262,42 +291,6 @@ function debugCacheNs(namespacesOrOpts, operation, key, meta) {
262
291
  }
263
292
  }
264
293
  // @__NO_SIDE_EFFECTS__
265
- function debugCache(operation, key, meta) {
266
- if (!(0, import_socket.getSocketDebug)()) {
267
- return;
268
- }
269
- const callerName = /* @__PURE__ */ getCallerInfo(3) || "cache";
270
- if (pointingTriangle === void 0) {
271
- const supported = (0, import_is_unicode_supported.default)();
272
- pointingTriangle = supported ? "\u25B8" : ">";
273
- }
274
- const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`;
275
- const args = meta !== void 0 ? [prefix, meta] : [prefix];
276
- console.log(...args);
277
- }
278
- // @__NO_SIDE_EFFECTS__
279
- function isDebugNs(namespaces) {
280
- return !!(0, import_socket.getSocketDebug)() && /* @__PURE__ */ isEnabled(namespaces);
281
- }
282
- function debug(...args) {
283
- debugNs("*", ...args);
284
- }
285
- function debugDir(obj, inspectOpts) {
286
- debugDirNs("*", obj, inspectOpts);
287
- }
288
- function debugLog(...args) {
289
- debugLogNs("*", ...args);
290
- }
291
- // @__NO_SIDE_EFFECTS__
292
- function isDebug() {
293
- return !!(0, import_socket.getSocketDebug)();
294
- }
295
- // @__NO_SIDE_EFFECTS__
296
- function debuglog(section) {
297
- const util = /* @__PURE__ */ getUtil();
298
- return util.debuglog(section);
299
- }
300
- // @__NO_SIDE_EFFECTS__
301
294
  function debugtime(label) {
302
295
  const util = /* @__PURE__ */ getUtil();
303
296
  let startTime;
@@ -322,6 +315,14 @@ function debugtime(label) {
322
315
  };
323
316
  return impl;
324
317
  }
318
+ // @__NO_SIDE_EFFECTS__
319
+ function isDebug() {
320
+ return !!(0, import_socket.getSocketDebug)();
321
+ }
322
+ // @__NO_SIDE_EFFECTS__
323
+ function isDebugNs(namespaces) {
324
+ return !!(0, import_socket.getSocketDebug)() && /* @__PURE__ */ isEnabled(namespaces);
325
+ }
325
326
  // Annotate the CommonJS export names for ESM import in node:
326
327
  0 && (module.exports = {
327
328
  debug,