@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
package/dist/strings.d.ts CHANGED
@@ -3,12 +3,7 @@
3
3
  * Provides string processing, prefix application, and terminal output utilities.
4
4
  */
5
5
  import { ansiRegex, stripAnsi } from './ansi';
6
- // Import get-east-asian-width from external wrapper.
7
- // This library implements Unicode Standard Annex #11 (East Asian Width).
8
- // https://www.unicode.org/reports/tr11/
9
- // Re-export ANSI utilities for backward compatibility.
10
6
  export { ansiRegex, stripAnsi };
11
- // Type definitions
12
7
  declare const BlankStringBrand: unique symbol;
13
8
  export type BlankString = string & {
14
9
  [BlankStringBrand]: true;
@@ -17,10 +12,6 @@ declare const EmptyStringBrand: unique symbol;
17
12
  export type EmptyString = string & {
18
13
  [EmptyStringBrand]: true;
19
14
  };
20
- // IMPORTANT: Do not use destructuring here - use direct assignment instead.
21
- // tsgo has a bug that incorrectly transpiles destructured exports, resulting in
22
- // `exports.SomeName = void 0;` which causes runtime errors.
23
- // See: https://github.com/SocketDev/socket-packageurl-js/issues/3
24
15
  export declare const fromCharCode: (...codes: number[]) => string;
25
16
  export interface ApplyLinePrefixOptions {
26
17
  /**
@@ -52,39 +43,7 @@ export interface ApplyLinePrefixOptions {
52
43
  * // Returns: 'no prefix'
53
44
  * ```
54
45
  */
55
- /*@__NO_SIDE_EFFECTS__*/
56
46
  export declare function applyLinePrefix(str: string, options?: ApplyLinePrefixOptions | undefined): string;
57
- /**
58
- * Convert a camelCase string to kebab-case.
59
- *
60
- * Transforms camelCase strings by converting uppercase letters to lowercase
61
- * and inserting hyphens before uppercase sequences. Handles consecutive
62
- * uppercase letters (like "XMLHttpRequest") by treating them as a single word.
63
- * Returns empty string for empty input.
64
- *
65
- * Note: This function only handles camelCase. For mixed formats including
66
- * snake_case, use `toKebabCase()` instead.
67
- *
68
- * @param str - The camelCase string to convert
69
- * @returns The kebab-case string
70
- *
71
- * @example
72
- * ```ts
73
- * camelToKebab('helloWorld')
74
- * // Returns: 'hello-world'
75
- *
76
- * camelToKebab('XMLHttpRequest')
77
- * // Returns: 'xmlhttprequest'
78
- *
79
- * camelToKebab('iOS')
80
- * // Returns: 'ios'
81
- *
82
- * camelToKebab('')
83
- * // Returns: ''
84
- * ```
85
- */
86
- /*@__NO_SIDE_EFFECTS__*/
87
- export declare function camelToKebab(str: string): string;
88
47
  /**
89
48
  * Center text within a given width.
90
49
  *
@@ -118,7 +77,6 @@ export declare function camelToKebab(str: string): string;
118
77
  * // Returns: 'too long text' (no truncation, returned as-is)
119
78
  * ```
120
79
  */
121
- /*@__NO_SIDE_EFFECTS__*/
122
80
  export declare function centerText(text: string, width: number): string;
123
81
  export interface IndentStringOptions {
124
82
  /**
@@ -150,7 +108,6 @@ export interface IndentStringOptions {
150
108
  * // Returns: ' single line' (default: 1 space)
151
109
  * ```
152
110
  */
153
- /*@__NO_SIDE_EFFECTS__*/
154
111
  export declare function indentString(str: string, options?: IndentStringOptions | undefined): string;
155
112
  /**
156
113
  * Check if a value is a blank string (empty or only whitespace).
@@ -183,7 +140,6 @@ export declare function indentString(str: string, options?: IndentStringOptions
183
140
  * // Returns: false
184
141
  * ```
185
142
  */
186
- /*@__NO_SIDE_EFFECTS__*/
187
143
  export declare function isBlankString(value: unknown): value is BlankString;
188
144
  /**
189
145
  * Check if a value is a non-empty string.
@@ -214,7 +170,6 @@ export declare function isBlankString(value: unknown): value is BlankString;
214
170
  * // Returns: false
215
171
  * ```
216
172
  */
217
- /*@__NO_SIDE_EFFECTS__*/
218
173
  export declare function isNonEmptyString(value: unknown): value is Exclude<string, EmptyString>;
219
174
  /**
220
175
  * Repeat a string a specified number of times.
@@ -241,7 +196,6 @@ export declare function isNonEmptyString(value: unknown): value is Exclude<strin
241
196
  * // Returns: ''
242
197
  * ```
243
198
  */
244
- /*@__NO_SIDE_EFFECTS__*/
245
199
  export declare function repeatString(str: string, count: number): string;
246
200
  export interface SearchOptions {
247
201
  /**
@@ -283,38 +237,7 @@ export interface SearchOptions {
283
237
  * // Returns: -1 (starts searching from 'world', no match)
284
238
  * ```
285
239
  */
286
- /*@__NO_SIDE_EFFECTS__*/
287
240
  export declare function search(str: string, regexp: RegExp, options?: SearchOptions | undefined): number;
288
- /**
289
- * Strip the Byte Order Mark (BOM) from the beginning of a string.
290
- *
291
- * The BOM (U+FEFF) is a Unicode character that can appear at the start of
292
- * a text file to indicate byte order and encoding. In UTF-16 (JavaScript's
293
- * internal string representation), it appears as 0xFEFF. This function
294
- * removes it if present, leaving the rest of the string unchanged.
295
- *
296
- * Most text processing doesn't need to handle the BOM explicitly, but it
297
- * can cause issues when parsing JSON, CSV, or other structured data formats
298
- * that don't expect a leading invisible character.
299
- *
300
- * @param str - The string to strip BOM from
301
- * @returns The string without BOM
302
- *
303
- * @example
304
- * ```ts
305
- * stripBom('\uFEFFhello world')
306
- * // Returns: 'hello world'
307
- *
308
- * stripBom('hello world')
309
- * // Returns: 'hello world' (no BOM to strip)
310
- *
311
- * stripBom('')
312
- * // Returns: ''
313
- * ```
314
- */
315
- /*@__NO_SIDE_EFFECTS__*/
316
- export declare function stripBom(str: string): string;
317
- /* c8 ignore stop */
318
241
  /**
319
242
  * Get the visual width of a string in terminal columns.
320
243
  *
@@ -392,11 +315,36 @@ export declare function stripBom(str: string): string;
392
315
  * stringWidth('')
393
316
  * // Returns: 0
394
317
  * ```
395
- *
396
- * @throws {TypeError} When input is not a string
397
318
  */
398
- /*@__NO_SIDE_EFFECTS__*/
399
319
  export declare function stringWidth(text: string): number;
320
+ /**
321
+ * Strip the Byte Order Mark (BOM) from the beginning of a string.
322
+ *
323
+ * The BOM (U+FEFF) is a Unicode character that can appear at the start of
324
+ * a text file to indicate byte order and encoding. In UTF-16 (JavaScript's
325
+ * internal string representation), it appears as 0xFEFF. This function
326
+ * removes it if present, leaving the rest of the string unchanged.
327
+ *
328
+ * Most text processing doesn't need to handle the BOM explicitly, but it
329
+ * can cause issues when parsing JSON, CSV, or other structured data formats
330
+ * that don't expect a leading invisible character.
331
+ *
332
+ * @param str - The string to strip BOM from
333
+ * @returns The string without BOM
334
+ *
335
+ * @example
336
+ * ```ts
337
+ * stripBom('\uFEFFhello world')
338
+ * // Returns: 'hello world'
339
+ *
340
+ * stripBom('hello world')
341
+ * // Returns: 'hello world' (no BOM to strip)
342
+ *
343
+ * stripBom('')
344
+ * // Returns: ''
345
+ * ```
346
+ */
347
+ export declare function stripBom(str: string): string;
400
348
  /**
401
349
  * Convert a string to kebab-case (handles camelCase and snake_case).
402
350
  *
@@ -405,8 +353,8 @@ export declare function stringWidth(text: string): number;
405
353
  * - Inserting hyphens before uppercase letters (for camelCase)
406
354
  * - Replacing underscores with hyphens (for snake_case)
407
355
  *
408
- * This is more comprehensive than `camelToKebab()` as it handles mixed
409
- * formats including snake_case. Returns empty string for empty input.
356
+ * Handles mixed formats (camelCase, snake_case, acronyms) in one pass.
357
+ * Returns empty string for empty input.
410
358
  *
411
359
  * @param str - The string to convert
412
360
  * @returns The kebab-case string
@@ -423,13 +371,12 @@ export declare function stringWidth(text: string): number;
423
371
  * // Returns: 'xmlhttp-request'
424
372
  *
425
373
  * toKebabCase('iOS_Version')
426
- * // Returns: 'io-s-version'
374
+ * // Returns: 'i-os-version'
427
375
  *
428
376
  * toKebabCase('')
429
377
  * // Returns: ''
430
378
  * ```
431
379
  */
432
- /*@__NO_SIDE_EFFECTS__*/
433
380
  export declare function toKebabCase(str: string): string;
434
381
  /**
435
382
  * Trim newlines from the beginning and end of a string.
@@ -464,5 +411,4 @@ export declare function toKebabCase(str: string): string;
464
411
  * // Returns: 'hello'
465
412
  * ```
466
413
  */
467
- /*@__NO_SIDE_EFFECTS__*/
468
414
  export declare function trimNewlines(str: string): string;
package/dist/strings.js CHANGED
@@ -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;
@@ -21,7 +22,6 @@ var strings_exports = {};
21
22
  __export(strings_exports, {
22
23
  ansiRegex: () => import_ansi.ansiRegex,
23
24
  applyLinePrefix: () => applyLinePrefix,
24
- camelToKebab: () => camelToKebab,
25
25
  centerText: () => centerText,
26
26
  fromCharCode: () => fromCharCode,
27
27
  indentString: () => indentString,
@@ -56,49 +56,6 @@ function applyLinePrefix(str, options) {
56
56
  ${prefix}`) : str}` : str;
57
57
  }
58
58
  // @__NO_SIDE_EFFECTS__
59
- function camelToKebab(str) {
60
- const { length } = str;
61
- if (!length) {
62
- return "";
63
- }
64
- let result = "";
65
- let i = 0;
66
- while (i < length) {
67
- const char = str[i];
68
- if (!char) {
69
- break;
70
- }
71
- const charCode = char.charCodeAt(0);
72
- const isUpperCase = charCode >= 65 && charCode <= 90;
73
- if (isUpperCase) {
74
- if (result.length > 0) {
75
- result += "-";
76
- }
77
- while (i < length) {
78
- const currChar = str[i];
79
- if (!currChar) {
80
- break;
81
- }
82
- const currCharCode = currChar.charCodeAt(0);
83
- const isCurrUpper = currCharCode >= 65 && currCharCode <= 90;
84
- if (isCurrUpper) {
85
- result += fromCharCode(
86
- currCharCode + 32
87
- /*'a'-'A'*/
88
- );
89
- i += 1;
90
- } else {
91
- break;
92
- }
93
- }
94
- } else {
95
- result += char;
96
- i += 1;
97
- }
98
- }
99
- return result;
100
- }
101
- // @__NO_SIDE_EFFECTS__
102
59
  function centerText(text, width) {
103
60
  const textLength = (0, import_ansi.stripAnsi)(text).length;
104
61
  if (textLength >= width) {
@@ -143,10 +100,6 @@ function search(str, regexp, options) {
143
100
  const result = str.slice(offset).search(regexp);
144
101
  return result === -1 ? -1 : result + offset;
145
102
  }
146
- // @__NO_SIDE_EFFECTS__
147
- function stripBom(str) {
148
- return str.length > 0 && str.charCodeAt(0) === 65279 ? str.slice(1) : str;
149
- }
150
103
  const segmenter = new Intl.Segmenter();
151
104
  let zeroWidthClusterRegex;
152
105
  let leadingNonPrintingRegex;
@@ -201,6 +154,10 @@ function stringWidth(text) {
201
154
  return width;
202
155
  }
203
156
  // @__NO_SIDE_EFFECTS__
157
+ function stripBom(str) {
158
+ return str.length > 0 && str.charCodeAt(0) === 65279 ? str.slice(1) : str;
159
+ }
160
+ // @__NO_SIDE_EFFECTS__
204
161
  function toKebabCase(str) {
205
162
  if (!str.length) {
206
163
  return str;
@@ -245,7 +202,6 @@ function trimNewlines(str) {
245
202
  0 && (module.exports = {
246
203
  ansiRegex,
247
204
  applyLinePrefix,
248
- camelToKebab,
249
205
  centerText,
250
206
  fromCharCode,
251
207
  indentString,
@@ -1,15 +1,18 @@
1
- export declare function suppressMaxListenersWarning(): void;
2
1
  /**
3
- * Suppress all process warnings of a specific type.
4
- *
5
- * @param warningType - The warning type to suppress (e.g., 'DeprecationWarning', 'ExperimentalWarning')
2
+ * @fileoverview Utilities to suppress specific process warnings.
3
+ */
4
+ /**
5
+ * Restore the original process.emitWarning function.
6
+ * Call this to re-enable all warnings after suppressing them.
6
7
  *
7
8
  * @example
8
- * import { suppressWarningType } from '@socketsecurity/lib/suppress-warnings'
9
- *
10
- * suppressWarningType('ExperimentalWarning')
9
+ * ```typescript
10
+ * suppressMaxListenersWarning()
11
+ * // ... do work ...
12
+ * restoreWarnings() // Re-enable all warnings
13
+ * ```
11
14
  */
12
- export declare function suppressWarningType(warningType: string): void;
15
+ export declare function restoreWarnings(): void;
13
16
  /**
14
17
  * Set max listeners on an EventTarget (like AbortSignal) to avoid TypeError.
15
18
  *
@@ -35,17 +38,31 @@ export declare function suppressWarningType(warningType: string): void;
35
38
  */
36
39
  export declare function setMaxEventTargetListeners(target: EventTarget | AbortSignal | undefined, maxListeners?: number): void;
37
40
  /**
38
- * Restore the original process.emitWarning function.
39
- * Call this to re-enable all warnings after suppressing them.
41
+ * Suppress MaxListenersExceededWarning messages.
42
+ * This is useful in tests or scripts where multiple listeners are expected.
40
43
  *
41
44
  * @example
42
- * ```typescript
45
+ * import { suppressMaxListenersWarning } from '@socketsecurity/lib/suppress-warnings'
46
+ *
43
47
  * suppressMaxListenersWarning()
44
- * // ... do work ...
45
- * restoreWarnings() // Re-enable all warnings
46
- * ```
47
48
  */
48
- export declare function restoreWarnings(): void;
49
+ /**
50
+ * Silence `MaxListenersExceededWarning` messages from `process.emitWarning`.
51
+ * Installs a single shared wrapper around `process.emitWarning` on first call
52
+ * so repeat invocations are cheap.
53
+ */
54
+ export declare function suppressMaxListenersWarning(): void;
55
+ /**
56
+ * Suppress all process warnings of a specific type.
57
+ *
58
+ * @param warningType - The warning type to suppress (e.g., 'DeprecationWarning', 'ExperimentalWarning')
59
+ *
60
+ * @example
61
+ * import { suppressWarningType } from '@socketsecurity/lib/suppress-warnings'
62
+ *
63
+ * suppressWarningType('ExperimentalWarning')
64
+ */
65
+ export declare function suppressWarningType(warningType: string): void;
49
66
  /**
50
67
  * Suppress warnings temporarily within a callback.
51
68
  *
@@ -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;
@@ -64,13 +65,12 @@ function setupSuppression() {
64
65
  };
65
66
  }
66
67
  }
67
- function suppressMaxListenersWarning() {
68
- suppressedWarnings.add("MaxListenersExceededWarning");
69
- setupSuppression();
70
- }
71
- function suppressWarningType(warningType) {
72
- suppressedWarnings.add(warningType);
73
- setupSuppression();
68
+ function restoreWarnings() {
69
+ if (originalEmitWarning) {
70
+ import_node_process.default.emitWarning = originalEmitWarning;
71
+ originalEmitWarning = void 0;
72
+ suppressedWarnings.clear();
73
+ }
74
74
  }
75
75
  function setMaxEventTargetListeners(target, maxListeners = 10) {
76
76
  if (!target) {
@@ -85,12 +85,13 @@ function setMaxEventTargetListeners(target, maxListeners = 10) {
85
85
  target[kMaxEventTargetListeners] = maxListeners;
86
86
  }
87
87
  }
88
- function restoreWarnings() {
89
- if (originalEmitWarning) {
90
- import_node_process.default.emitWarning = originalEmitWarning;
91
- originalEmitWarning = void 0;
92
- suppressedWarnings.clear();
93
- }
88
+ function suppressMaxListenersWarning() {
89
+ suppressedWarnings.add("MaxListenersExceededWarning");
90
+ setupSuppression();
91
+ }
92
+ function suppressWarningType(warningType) {
93
+ suppressedWarnings.add(warningType);
94
+ setupSuppression();
94
95
  }
95
96
  async function withSuppressedWarnings(warningType, callback) {
96
97
  const wasAlreadySuppressed = suppressedWarnings.has(warningType);
package/dist/tables.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Table formatting utilities for CLI applications.
3
+ * Provides ASCII table rendering with borders, alignment, and colors.
4
+ */
1
5
  export type ColumnAlignment = 'left' | 'right' | 'center';
2
6
  /**
3
7
  * Table column configuration.
@@ -10,60 +14,60 @@ export type TableColumn = {
10
14
  color?: ((value: string) => string) | undefined;
11
15
  };
12
16
  /**
13
- * Format data as an ASCII table with borders.
17
+ * Format data as a simple table without borders.
18
+ * Lighter weight alternative to formatTable().
14
19
  *
15
20
  * @param data - Array of data objects
16
21
  * @param columns - Column configuration
17
22
  * @returns Formatted table string
18
23
  *
19
24
  * @example
20
- * import { formatTable } from '@socketsecurity/lib/tables'
25
+ * import { formatSimpleTable } from '@socketsecurity/lib/tables'
21
26
  * import colors from 'yoctocolors-cjs'
22
27
  *
23
28
  * const data = [
24
- * { name: 'lodash', version: '4.17.21', issues: 0 },
25
- * { name: 'react', version: '18.2.0', issues: 2 },
29
+ * { name: 'lodash', version: '4.17.21' },
30
+ * { name: 'react', version: '18.2.0' },
26
31
  * ]
27
32
  * const columns = [
28
33
  * { key: 'name', header: 'Package' },
29
- * { key: 'version', header: 'Version', align: 'center' },
30
- * { key: 'issues', header: 'Issues', align: 'right', color: (v) => v === '0' ? colors.green(v) : colors.red(v) },
34
+ * { key: 'version', header: 'Version' },
31
35
  * ]
32
- * console.log(formatTable(data, columns))
36
+ * console.log(formatSimpleTable(data, columns))
33
37
  * // Output:
34
- * // ┌─────────┬─────────┬────────┐
35
- * // │ Package │ Version │ Issues │
36
- * // ├─────────┼─────────┼────────┤
37
- * // │ lodash │ 4.17.21 │ 0
38
- * // │ react │ 18.2.0 │ 2 │
39
- * // └─────────┴─────────┴────────┘
38
+ * // Package Version
39
+ * // ─────── ───────
40
+ * // lodash 4.17.21
41
+ * // react 18.2.0
40
42
  */
41
- export declare function formatTable(data: Array<Record<string, unknown>>, columns: TableColumn[]): string;
43
+ export declare function formatSimpleTable(data: Array<Record<string, unknown>>, columns: TableColumn[]): string;
42
44
  /**
43
- * Format data as a simple table without borders.
44
- * Lighter weight alternative to formatTable().
45
+ * Format data as an ASCII table with borders.
45
46
  *
46
47
  * @param data - Array of data objects
47
48
  * @param columns - Column configuration
48
49
  * @returns Formatted table string
49
50
  *
50
51
  * @example
51
- * import { formatSimpleTable } from '@socketsecurity/lib/tables'
52
+ * import { formatTable } from '@socketsecurity/lib/tables'
52
53
  * import colors from 'yoctocolors-cjs'
53
54
  *
54
55
  * const data = [
55
- * { name: 'lodash', version: '4.17.21' },
56
- * { name: 'react', version: '18.2.0' },
56
+ * { name: 'lodash', version: '4.17.21', issues: 0 },
57
+ * { name: 'react', version: '18.2.0', issues: 2 },
57
58
  * ]
58
59
  * const columns = [
59
60
  * { key: 'name', header: 'Package' },
60
- * { key: 'version', header: 'Version' },
61
+ * { key: 'version', header: 'Version', align: 'center' },
62
+ * { key: 'issues', header: 'Issues', align: 'right', color: (v) => v === '0' ? colors.green(v) : colors.red(v) },
61
63
  * ]
62
- * console.log(formatSimpleTable(data, columns))
64
+ * console.log(formatTable(data, columns))
63
65
  * // Output:
64
- * // Package Version
65
- * // ─────── ───────
66
- * // lodash 4.17.21
67
- * // react 18.2.0
66
+ * // ┌─────────┬─────────┬────────┐
67
+ * // │ Package │ Version │ Issues │
68
+ * // ├─────────┼─────────┼────────┤
69
+ * // │ lodash │ 4.17.21 │ 0
70
+ * // │ react │ 18.2.0 │ 2 │
71
+ * // └─────────┴─────────┴────────┘
68
72
  */
69
- export declare function formatSimpleTable(data: Array<Record<string, unknown>>, columns: TableColumn[]): string;
73
+ export declare function formatTable(data: Array<Record<string, unknown>>, columns: TableColumn[]): string;
package/dist/tables.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,7 +55,7 @@ function padText(text, width, align = "left") {
54
55
  return text + " ".repeat(padding);
55
56
  }
56
57
  }
57
- function formatTable(data, columns) {
58
+ function formatSimpleTable(data, columns) {
58
59
  if (data.length === 0) {
59
60
  return "(no data)";
60
61
  }
@@ -66,17 +67,12 @@ function formatTable(data, columns) {
66
67
  return col.width ?? Math.max(headerWidth, maxDataWidth);
67
68
  });
68
69
  const lines = [];
69
- const topBorder = `\u250C\u2500${widths.map((w) => "\u2500".repeat(w)).join("\u2500\u252C\u2500")}\u2500\u2510`;
70
- lines.push(import_yoctocolors_cjs.default.dim(topBorder));
71
- const headerCells = columns.map((col, i) => {
72
- const text = import_yoctocolors_cjs.default.bold(col.header);
73
- return padText(text, widths[i], col.align);
74
- });
75
- lines.push(
76
- import_yoctocolors_cjs.default.dim("\u2502 ") + headerCells.join(import_yoctocolors_cjs.default.dim(" \u2502 ")) + import_yoctocolors_cjs.default.dim(" \u2502")
70
+ const headerCells = columns.map(
71
+ (col, i) => padText(import_yoctocolors_cjs.default.bold(col.header), widths[i], col.align)
77
72
  );
78
- const headerSep = `\u251C\u2500${widths.map((w) => "\u2500".repeat(w)).join("\u2500\u253C\u2500")}\u2500\u2524`;
79
- lines.push(import_yoctocolors_cjs.default.dim(headerSep));
73
+ lines.push(headerCells.join(" "));
74
+ const separators = widths.map((w) => import_yoctocolors_cjs.default.dim("\u2500".repeat(w)));
75
+ lines.push(separators.join(" "));
80
76
  for (const row of data) {
81
77
  const cells = columns.map((col, i) => {
82
78
  let value = String(row[col.key] ?? "");
@@ -85,15 +81,11 @@ function formatTable(data, columns) {
85
81
  }
86
82
  return padText(value, widths[i], col.align);
87
83
  });
88
- lines.push(
89
- import_yoctocolors_cjs.default.dim("\u2502 ") + cells.join(import_yoctocolors_cjs.default.dim(" \u2502 ")) + import_yoctocolors_cjs.default.dim(" \u2502")
90
- );
84
+ lines.push(cells.join(" "));
91
85
  }
92
- const bottomBorder = `\u2514\u2500${widths.map((w) => "\u2500".repeat(w)).join("\u2500\u2534\u2500")}\u2500\u2518`;
93
- lines.push(import_yoctocolors_cjs.default.dim(bottomBorder));
94
86
  return lines.join("\n");
95
87
  }
96
- function formatSimpleTable(data, columns) {
88
+ function formatTable(data, columns) {
97
89
  if (data.length === 0) {
98
90
  return "(no data)";
99
91
  }
@@ -105,12 +97,17 @@ function formatSimpleTable(data, columns) {
105
97
  return col.width ?? Math.max(headerWidth, maxDataWidth);
106
98
  });
107
99
  const lines = [];
108
- const headerCells = columns.map(
109
- (col, i) => padText(import_yoctocolors_cjs.default.bold(col.header), widths[i], col.align)
100
+ const topBorder = `\u250C\u2500${widths.map((w) => "\u2500".repeat(w)).join("\u2500\u252C\u2500")}\u2500\u2510`;
101
+ lines.push(import_yoctocolors_cjs.default.dim(topBorder));
102
+ const headerCells = columns.map((col, i) => {
103
+ const text = import_yoctocolors_cjs.default.bold(col.header);
104
+ return padText(text, widths[i], col.align);
105
+ });
106
+ lines.push(
107
+ import_yoctocolors_cjs.default.dim("\u2502 ") + headerCells.join(import_yoctocolors_cjs.default.dim(" \u2502 ")) + import_yoctocolors_cjs.default.dim(" \u2502")
110
108
  );
111
- lines.push(headerCells.join(" "));
112
- const separators = widths.map((w) => import_yoctocolors_cjs.default.dim("\u2500".repeat(w)));
113
- lines.push(separators.join(" "));
109
+ const headerSep = `\u251C\u2500${widths.map((w) => "\u2500".repeat(w)).join("\u2500\u253C\u2500")}\u2500\u2524`;
110
+ lines.push(import_yoctocolors_cjs.default.dim(headerSep));
114
111
  for (const row of data) {
115
112
  const cells = columns.map((col, i) => {
116
113
  let value = String(row[col.key] ?? "");
@@ -119,8 +116,12 @@ function formatSimpleTable(data, columns) {
119
116
  }
120
117
  return padText(value, widths[i], col.align);
121
118
  });
122
- lines.push(cells.join(" "));
119
+ lines.push(
120
+ import_yoctocolors_cjs.default.dim("\u2502 ") + cells.join(import_yoctocolors_cjs.default.dim(" \u2502 ")) + import_yoctocolors_cjs.default.dim(" \u2502")
121
+ );
123
122
  }
123
+ const bottomBorder = `\u2514\u2500${widths.map((w) => "\u2500".repeat(w)).join("\u2500\u2534\u2500")}\u2500\u2518`;
124
+ lines.push(import_yoctocolors_cjs.default.dim(bottomBorder));
124
125
  return lines.join("\n");
125
126
  }
126
127
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Temporary package executor detection utilities for Socket ecosystem.
3
+ * Identifies and handles temporary execution contexts such as npx, pnpm dlx, and yarn dlx.
4
+ */
1
5
  /**
2
6
  * Detects if the current process is running in a temporary package execution context
3
7
  * such as npm exec, npx, pnpm dlx, or yarn dlx.
@@ -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;