@socketsecurity/lib 5.18.2 → 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 +43 -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 -66
  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/json/edit.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;
@@ -32,8 +33,8 @@ __export(edit_exports, {
32
33
  getEditableJsonClass: () => getEditableJsonClass
33
34
  });
34
35
  module.exports = __toCommonJS(edit_exports);
35
- var import_promises = require("node:timers/promises");
36
36
  var import_node_process = __toESM(require("node:process"));
37
+ var import_promises = require("node:timers/promises");
37
38
  var import_format = require("./format");
38
39
  const identSymbol = import_format.INDENT_SYMBOL;
39
40
  const newlineSymbol = import_format.NEWLINE_SYMBOL;
@@ -43,12 +44,34 @@ let _fs;
43
44
  // @__NO_SIDE_EFFECTS__
44
45
  function getFs() {
45
46
  if (_fs === void 0) {
46
- _fs = require("fs");
47
+ _fs = require("node:fs");
47
48
  }
48
49
  return _fs;
49
50
  }
50
- async function retryWrite(filepath, content, retries = 3, baseDelay = 10) {
51
+ function parseJson(content) {
52
+ return JSONParse(content);
53
+ }
54
+ async function readFile(filepath) {
51
55
  const { promises: fsPromises } = /* @__PURE__ */ getFs();
56
+ const maxRetries = import_node_process.default.platform === "win32" ? 5 : 1;
57
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
58
+ try {
59
+ return await fsPromises.readFile(filepath, "utf8");
60
+ } catch (err) {
61
+ const isLastAttempt = attempt === maxRetries;
62
+ const isEnoent = err instanceof Error && "code" in err && err.code === "ENOENT";
63
+ if (!isEnoent || isLastAttempt) {
64
+ throw err;
65
+ }
66
+ const delay = import_node_process.default.platform === "win32" ? 50 * (attempt + 1) : 20;
67
+ await (0, import_promises.setTimeout)(delay);
68
+ }
69
+ }
70
+ throw new Error("Unreachable code");
71
+ }
72
+ async function retryWrite(filepath, content, retries = 3, baseDelay = 10) {
73
+ const fs = /* @__PURE__ */ getFs();
74
+ const { promises: fsPromises } = fs;
52
75
  for (let attempt = 0; attempt <= retries; attempt++) {
53
76
  try {
54
77
  await fsPromises.writeFile(filepath, content);
@@ -57,15 +80,13 @@ async function retryWrite(filepath, content, retries = 3, baseDelay = 10) {
57
80
  let accessRetries = 0;
58
81
  const maxAccessRetries = 5;
59
82
  while (accessRetries < maxAccessRetries) {
60
- try {
61
- await fsPromises.access(filepath);
83
+ if (fs.existsSync(filepath)) {
62
84
  await (0, import_promises.setTimeout)(10);
63
85
  break;
64
- } catch {
65
- const delay = 20 * (accessRetries + 1);
66
- await (0, import_promises.setTimeout)(delay);
67
- accessRetries++;
68
86
  }
87
+ const delay = 20 * (accessRetries + 1);
88
+ await (0, import_promises.setTimeout)(delay);
89
+ accessRetries++;
69
90
  }
70
91
  }
71
92
  return;
@@ -80,27 +101,6 @@ async function retryWrite(filepath, content, retries = 3, baseDelay = 10) {
80
101
  }
81
102
  }
82
103
  }
83
- function parseJson(content) {
84
- return JSONParse(content);
85
- }
86
- async function readFile(filepath) {
87
- const { promises: fsPromises } = /* @__PURE__ */ getFs();
88
- const maxRetries = import_node_process.default.platform === "win32" ? 5 : 1;
89
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
90
- try {
91
- return await fsPromises.readFile(filepath, "utf8");
92
- } catch (err) {
93
- const isLastAttempt = attempt === maxRetries;
94
- const isEnoent = err instanceof Error && "code" in err && err.code === "ENOENT";
95
- if (!isEnoent || isLastAttempt) {
96
- throw err;
97
- }
98
- const delay = import_node_process.default.platform === "win32" ? 50 * (attempt + 1) : 20;
99
- await (0, import_promises.setTimeout)(delay);
100
- }
101
- }
102
- throw new Error("Unreachable code");
103
- }
104
104
  // @__NO_SIDE_EFFECTS__
105
105
  function getEditableJsonClass() {
106
106
  if (_EditableJsonClass === void 0) {
@@ -19,9 +19,9 @@ export interface JsonFormatting {
19
19
  * Options for determining if a save should occur.
20
20
  */
21
21
  export interface ShouldSaveOptions {
22
- ignoreWhitespace?: boolean;
23
- sort?: boolean;
24
- sortFn?: (obj: Record<string, unknown>) => Record<string, unknown>;
22
+ ignoreWhitespace?: boolean | undefined;
23
+ sort?: boolean | undefined;
24
+ sortFn?: ((obj: Record<string, unknown>) => Record<string, unknown>) | undefined;
25
25
  }
26
26
  /**
27
27
  * Detect indentation from a JSON string.
@@ -77,6 +77,39 @@ export declare function extractFormatting(json: string): JsonFormatting;
77
77
  * ```
78
78
  */
79
79
  export declare function getDefaultFormatting(): JsonFormatting;
80
+ /**
81
+ * Extract formatting from content object that has symbol-based metadata.
82
+ *
83
+ * @param content - Content object with Symbol.for('indent') and Symbol.for('newline')
84
+ * @returns Formatting metadata, or defaults if symbols not present
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const content = { [Symbol.for("indent")]: 4, [Symbol.for("newline")]: "\r\n" }
89
+ * getFormattingFromContent(content) // { indent: 4, newline: "\r\n" }
90
+ * ```
91
+ */
92
+ export declare function getFormattingFromContent(content: Record<string | symbol, unknown>): JsonFormatting;
93
+ /**
94
+ * Determine if content should be saved based on changes and options.
95
+ * Compares current content with original content and respects options like
96
+ * ignoreWhitespace and sort.
97
+ *
98
+ * @param currentContent - Current content object (may include formatting symbols)
99
+ * @param originalContent - Original content for comparison (may include formatting symbols)
100
+ * @param originalFileContent - Original file content as string (for whitespace comparison)
101
+ * @param options - Options controlling save behavior
102
+ * @returns true if content should be saved, false otherwise
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * const current = { key: 'new-value', [Symbol.for('indent')]: 2 }
107
+ * const original = { key: 'old-value', [Symbol.for('indent')]: 2 }
108
+ * shouldSave(current, original, '{\n "key": "old-value"\n}\n')
109
+ * // => true
110
+ * ```
111
+ */
112
+ export declare function shouldSave(currentContent: Record<string | symbol, unknown>, originalContent: Record<string | symbol, unknown> | undefined, originalFileContent: string, options?: ShouldSaveOptions): boolean;
80
113
  /**
81
114
  * Sort object keys alphabetically.
82
115
  * Creates a new object with sorted keys (does not mutate input).
@@ -123,36 +156,3 @@ export declare function stringifyWithFormatting(content: Record<string, unknown>
123
156
  * ```
124
157
  */
125
158
  export declare function stripFormattingSymbols(content: Record<string | symbol, unknown>): Record<string, unknown>;
126
- /**
127
- * Extract formatting from content object that has symbol-based metadata.
128
- *
129
- * @param content - Content object with Symbol.for('indent') and Symbol.for('newline')
130
- * @returns Formatting metadata, or defaults if symbols not present
131
- *
132
- * @example
133
- * ```typescript
134
- * const content = { [Symbol.for("indent")]: 4, [Symbol.for("newline")]: "\r\n" }
135
- * getFormattingFromContent(content) // { indent: 4, newline: "\r\n" }
136
- * ```
137
- */
138
- export declare function getFormattingFromContent(content: Record<string | symbol, unknown>): JsonFormatting;
139
- /**
140
- * Determine if content should be saved based on changes and options.
141
- * Compares current content with original content and respects options like
142
- * ignoreWhitespace and sort.
143
- *
144
- * @param currentContent - Current content object (may include formatting symbols)
145
- * @param originalContent - Original content for comparison (may include formatting symbols)
146
- * @param originalFileContent - Original file content as string (for whitespace comparison)
147
- * @param options - Options controlling save behavior
148
- * @returns true if content should be saved, false otherwise
149
- *
150
- * @example
151
- * ```ts
152
- * const current = { key: 'new-value', [Symbol.for('indent')]: 2 }
153
- * const original = { key: 'old-value', [Symbol.for('indent')]: 2 }
154
- * shouldSave(current, original, '{\n "key": "old-value"\n}\n')
155
- * // => true
156
- * ```
157
- */
158
- export declare function shouldSave(currentContent: Record<string | symbol, unknown>, originalContent: Record<string | symbol, unknown> | undefined, originalFileContent: string, options?: ShouldSaveOptions): boolean;
@@ -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;
@@ -61,6 +62,27 @@ function getDefaultFormatting() {
61
62
  newline: "\n"
62
63
  };
63
64
  }
65
+ function getFormattingFromContent(content) {
66
+ const indent = content[INDENT_SYMBOL];
67
+ const newline = content[NEWLINE_SYMBOL];
68
+ return {
69
+ indent: indent === void 0 || indent === null ? 2 : indent,
70
+ newline: newline === void 0 || newline === null ? "\n" : newline
71
+ };
72
+ }
73
+ function shouldSave(currentContent, originalContent, originalFileContent, options = {}) {
74
+ const { ignoreWhitespace = false, sort = false, sortFn } = options;
75
+ const content = stripFormattingSymbols(currentContent);
76
+ const sortedContent = sortFn ? sortFn(content) : sort ? sortKeys(content) : content;
77
+ const origContent = originalContent ? stripFormattingSymbols(originalContent) : {};
78
+ if (ignoreWhitespace) {
79
+ const util = require("node:util");
80
+ return !util.isDeepStrictEqual(sortedContent, origContent);
81
+ }
82
+ const formatting = getFormattingFromContent(currentContent);
83
+ const newFileContent = stringifyWithFormatting(sortedContent, formatting);
84
+ return newFileContent.trim() !== originalFileContent.trim();
85
+ }
64
86
  function sortKeys(obj) {
65
87
  const sorted = { __proto__: null };
66
88
  const keys = Object.keys(obj).sort();
@@ -84,27 +106,6 @@ function stripFormattingSymbols(content) {
84
106
  } = content;
85
107
  return rest;
86
108
  }
87
- function getFormattingFromContent(content) {
88
- const indent = content[INDENT_SYMBOL];
89
- const newline = content[NEWLINE_SYMBOL];
90
- return {
91
- indent: indent === void 0 || indent === null ? 2 : indent,
92
- newline: newline === void 0 || newline === null ? "\n" : newline
93
- };
94
- }
95
- function shouldSave(currentContent, originalContent, originalFileContent, options = {}) {
96
- const { ignoreWhitespace = false, sort = false, sortFn } = options;
97
- const content = stripFormattingSymbols(currentContent);
98
- const sortedContent = sortFn ? sortFn(content) : sort ? sortKeys(content) : content;
99
- const origContent = originalContent ? stripFormattingSymbols(originalContent) : {};
100
- if (ignoreWhitespace) {
101
- const util = require("util");
102
- return !util.isDeepStrictEqual(sortedContent, origContent);
103
- }
104
- const formatting = getFormattingFromContent(currentContent);
105
- const newFileContent = stringifyWithFormatting(sortedContent, formatting);
106
- return newFileContent.trim() !== originalFileContent.trim();
107
- }
108
109
  // Annotate the CommonJS export names for ESM import in node:
109
110
  0 && (module.exports = {
110
111
  INDENT_SYMBOL,
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview JSON parsing utilities with Buffer detection and BOM stripping.
3
+ * Provides safe JSON parsing with automatic encoding handling.
4
+ */
1
5
  import type { JsonParseOptions, JsonPrimitive, JsonValue } from './types';
2
6
  /**
3
7
  * Check if a value is a JSON primitive type.
@@ -17,7 +21,6 @@ import type { JsonParseOptions, JsonPrimitive, JsonValue } from './types';
17
21
  * isJsonPrimitive(undefined) // => false
18
22
  * ```
19
23
  */
20
- /*@__NO_SIDE_EFFECTS__*/
21
24
  export declare function isJsonPrimitive(value: unknown): value is JsonPrimitive;
22
25
  /**
23
26
  * Parse JSON content with automatic Buffer handling and BOM stripping.
@@ -72,5 +75,4 @@ export declare function isJsonPrimitive(value: unknown): value is JsonPrimitive;
72
75
  * console.log(data.created instanceof Date) // => true
73
76
  * ```
74
77
  */
75
- /*@__NO_SIDE_EFFECTS__*/
76
78
  export declare function jsonParse(content: string | Buffer, options?: JsonParseOptions | undefined): JsonValue | undefined;
@@ -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,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,5 +1,9 @@
1
- import type { Theme } from '../themes/types';
2
- import type { ThemeName } from '../themes/themes';
1
+ /**
2
+ * @fileoverview Themed hyperlink utilities for terminal output.
3
+ * Provides colored hyperlinks using theme configuration.
4
+ */
5
+ import type { ThemeName } from './themes/themes';
6
+ import type { Theme } from './themes/types';
3
7
  /**
4
8
  * Options for creating themed links.
5
9
  */
@@ -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,10 +34,10 @@ __export(links_exports, {
33
34
  links: () => links
34
35
  });
35
36
  module.exports = __toCommonJS(links_exports);
36
- var import_yoctocolors_cjs = __toESM(require("../external/yoctocolors-cjs"));
37
- var import_context = require("../themes/context");
38
- var import_themes = require("../themes/themes");
39
- var import_utils = require("../themes/utils");
37
+ var import_yoctocolors_cjs = __toESM(require("./external/yoctocolors-cjs"));
38
+ var import_context = require("./themes/context");
39
+ var import_themes = require("./themes/themes");
40
+ var import_utils = require("./themes/utils");
40
41
  function link(text, url, options) {
41
42
  const opts = { __proto__: null, fallback: false, ...options };
42
43
  const theme = typeof opts.theme === "string" ? import_themes.THEMES[opts.theme] : opts.theme ?? (0, import_context.getTheme)();
package/dist/logger.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Console logging utilities with line prefix support.
3
+ * Provides enhanced console methods with formatted output capabilities.
4
+ */
1
5
  /**
2
6
  * Log symbols for terminal output with colored indicators.
3
7
  *
@@ -161,7 +165,6 @@ export declare const lastWasBlankSymbol: unique symbol;
161
165
  * })
162
166
  * ```
163
167
  */
164
- /*@__PURE__*/
165
168
  export declare class Logger {
166
169
  #private;
167
170
  /**
@@ -564,8 +567,6 @@ export declare class Logger {
564
567
  * logger.groupEnd()
565
568
  * ```
566
569
  */
567
- // groupCollapsed is an alias of group.
568
- // https://nodejs.org/api/console.html#consolegroupcollapsed
569
570
  groupCollapsed(...label: unknown[]): this;
570
571
  /**
571
572
  * Ends the current log group and decreases indentation.
@@ -990,6 +991,3 @@ export declare class Logger {
990
991
  * ```
991
992
  */
992
993
  export declare function getDefaultLogger(): Logger;
993
- // REMOVED: Deprecated `logger` export
994
- // Migration: Use getDefaultLogger() instead
995
- // See: getDefaultLogger() function above
package/dist/logger.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;
@@ -46,30 +47,10 @@ const globalConsole = console;
46
47
  const ReflectApply = Reflect.apply;
47
48
  const ReflectConstruct = Reflect.construct;
48
49
  let _Console;
49
- // @__NO_SIDE_EFFECTS__
50
- function constructConsole(...args) {
51
- if (_Console === void 0) {
52
- const nodeConsole = require("console");
53
- _Console = nodeConsole.Console;
54
- }
55
- return ReflectConstruct(
56
- _Console,
57
- // eslint-disable-line no-undef
58
- args
59
- );
60
- }
61
- // @__NO_SIDE_EFFECTS__
62
- function getYoctocolors() {
63
- return import_yoctocolors_cjs.default;
64
- }
65
- // @__NO_SIDE_EFFECTS__
66
- function applyColor(text, color, colors) {
67
- if (typeof color === "string") {
68
- return colors[color](text);
69
- }
70
- const { 0: r, 1: g, 2: b } = color;
71
- return `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
72
- }
50
+ let _consoleSymbols;
51
+ let _kGroupIndentationWidthSymbol;
52
+ let _prototypeInitialized = false;
53
+ let _logger;
73
54
  const LOG_SYMBOLS = /* @__PURE__ */ (() => {
74
55
  const target = {
75
56
  __proto__: null
@@ -87,16 +68,16 @@ const LOG_SYMBOLS = /* @__PURE__ */ (() => {
87
68
  const warningColor = theme.colors.warning;
88
69
  const infoColor = theme.colors.info;
89
70
  const stepColor = theme.colors.step;
90
- target.fail = /* @__PURE__ */ applyColor(supported ? "\u2716" : "\xD7", errorColor, colors);
91
- target.info = /* @__PURE__ */ applyColor(supported ? "\u2139" : "i", infoColor, colors);
92
- target.progress = /* @__PURE__ */ applyColor(supported ? "\u2234" : ":.", stepColor, colors);
93
- target.reason = colors.dim(
71
+ target["fail"] = /* @__PURE__ */ applyColor(supported ? "\u2716" : "\xD7", errorColor, colors);
72
+ target["info"] = /* @__PURE__ */ applyColor(supported ? "\u2139" : "i", infoColor, colors);
73
+ target["progress"] = /* @__PURE__ */ applyColor(supported ? "\u2234" : ":.", stepColor, colors);
74
+ target["reason"] = colors.dim(
94
75
  /* @__PURE__ */ applyColor(supported ? "\u2234" : ":.", warningColor, colors)
95
76
  );
96
- target.skip = /* @__PURE__ */ applyColor(supported ? "\u21BB" : "@", stepColor, colors);
97
- target.step = /* @__PURE__ */ applyColor(supported ? "\u2192" : ">", stepColor, colors);
98
- target.success = /* @__PURE__ */ applyColor(supported ? "\u2714" : "\u221A", successColor, colors);
99
- target.warn = /* @__PURE__ */ applyColor(supported ? "\u26A0" : "\u203C", warningColor, colors);
77
+ target["skip"] = /* @__PURE__ */ applyColor(supported ? "\u21BB" : "@", stepColor, colors);
78
+ target["step"] = /* @__PURE__ */ applyColor(supported ? "\u2192" : ">", stepColor, colors);
79
+ target["success"] = /* @__PURE__ */ applyColor(supported ? "\u2714" : "\u221A", successColor, colors);
80
+ target["warn"] = /* @__PURE__ */ applyColor(supported ? "\u26A0" : "\u203C", warningColor, colors);
100
81
  };
101
82
  const init = () => {
102
83
  if (initialized) {
@@ -168,21 +149,7 @@ const consolePropAttributes = {
168
149
  const maxIndentation = 1e3;
169
150
  const privateConsole = /* @__PURE__ */ new WeakMap();
170
151
  const privateConstructorArgs = /* @__PURE__ */ new WeakMap();
171
- let _consoleSymbols;
172
- function getConsoleSymbols() {
173
- if (_consoleSymbols === void 0) {
174
- _consoleSymbols = Object.getOwnPropertySymbols(globalConsole);
175
- }
176
- return _consoleSymbols;
177
- }
178
152
  const incLogCallCountSymbol = Symbol.for("logger.logCallCount++");
179
- let _kGroupIndentationWidthSymbol;
180
- function getKGroupIndentationWidthSymbol() {
181
- if (_kGroupIndentationWidthSymbol === void 0) {
182
- _kGroupIndentationWidthSymbol = getConsoleSymbols().find((s) => s.label === "kGroupIndentWidth") ?? Symbol("kGroupIndentWidth");
183
- }
184
- return _kGroupIndentationWidthSymbol;
185
- }
186
153
  const lastWasBlankSymbol = Symbol.for("logger.lastWasBlank");
187
154
  class Logger {
188
155
  /**
@@ -236,7 +203,10 @@ class Logger {
236
203
  const themeOption = options.theme;
237
204
  if (themeOption) {
238
205
  if (typeof themeOption === "string") {
239
- this.#theme = import_themes.THEMES[themeOption];
206
+ const resolved = import_themes.THEMES[themeOption];
207
+ if (resolved) {
208
+ this.#theme = resolved;
209
+ }
240
210
  } else {
241
211
  this.#theme = themeOption;
242
212
  }
@@ -438,7 +408,9 @@ class Logger {
438
408
  instance.#parent = this;
439
409
  instance.#boundStream = "stderr";
440
410
  instance.#options = { __proto__: null, ...this.#options };
441
- instance.#theme = this.#theme;
411
+ if (this.#theme) {
412
+ instance.#theme = this.#theme;
413
+ }
442
414
  this.#stderrLogger = instance;
443
415
  }
444
416
  return this.#stderrLogger;
@@ -471,7 +443,9 @@ class Logger {
471
443
  instance.#parent = this;
472
444
  instance.#boundStream = "stdout";
473
445
  instance.#options = { __proto__: null, ...this.#options };
474
- instance.#theme = this.#theme;
446
+ if (this.#theme) {
447
+ instance.#theme = this.#theme;
448
+ }
475
449
  this.#stdoutLogger = instance;
476
450
  }
477
451
  return this.#stdoutLogger;
@@ -584,7 +558,7 @@ class Logger {
584
558
  clearLine() {
585
559
  const con = this.#getConsole();
586
560
  const stream = this.#getTargetStream();
587
- const streamObj = stream === "stderr" ? con._stderr : con._stdout;
561
+ const streamObj = stream === "stderr" ? con["_stderr"] : con["_stdout"];
588
562
  if (streamObj.isTTY) {
589
563
  streamObj.cursorTo(0);
590
564
  streamObj.clearLine(0);
@@ -1061,7 +1035,7 @@ class Logger {
1061
1035
  progress(text) {
1062
1036
  const con = this.#getConsole();
1063
1037
  const stream = this.#getTargetStream();
1064
- const streamObj = stream === "stderr" ? con._stderr : con._stdout;
1038
+ const streamObj = stream === "stderr" ? con["_stderr"] : con["_stdout"];
1065
1039
  const symbols = this.#getSymbols();
1066
1040
  streamObj.write(`${symbols.progress} ${text}`);
1067
1041
  this[lastWasBlankSymbol](false);
@@ -1408,7 +1382,26 @@ class Logger {
1408
1382
  return this;
1409
1383
  }
1410
1384
  }
1411
- let _prototypeInitialized = false;
1385
+ // @__NO_SIDE_EFFECTS__
1386
+ function applyColor(text, color, colors) {
1387
+ if (typeof color === "string") {
1388
+ return colors[color](text);
1389
+ }
1390
+ const { 0: r, 1: g, 2: b } = color;
1391
+ return `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
1392
+ }
1393
+ // @__NO_SIDE_EFFECTS__
1394
+ function constructConsole(...args) {
1395
+ if (_Console === void 0) {
1396
+ const nodeConsole = require("node:console");
1397
+ _Console = nodeConsole.Console;
1398
+ }
1399
+ return ReflectConstruct(
1400
+ _Console,
1401
+ // eslint-disable-line no-undef
1402
+ args
1403
+ );
1404
+ }
1412
1405
  function ensurePrototypeInitialized() {
1413
1406
  if (_prototypeInitialized) {
1414
1407
  return;
@@ -1467,7 +1460,22 @@ function ensurePrototypeInitialized() {
1467
1460
  }
1468
1461
  Object.defineProperties(Logger.prototype, Object.fromEntries(entries));
1469
1462
  }
1470
- let _logger;
1463
+ function getConsoleSymbols() {
1464
+ if (_consoleSymbols === void 0) {
1465
+ _consoleSymbols = Object.getOwnPropertySymbols(globalConsole);
1466
+ }
1467
+ return _consoleSymbols;
1468
+ }
1469
+ function getKGroupIndentationWidthSymbol() {
1470
+ if (_kGroupIndentationWidthSymbol === void 0) {
1471
+ _kGroupIndentationWidthSymbol = getConsoleSymbols().find((s) => s.label === "kGroupIndentWidth") ?? Symbol("kGroupIndentWidth");
1472
+ }
1473
+ return _kGroupIndentationWidthSymbol;
1474
+ }
1475
+ // @__NO_SIDE_EFFECTS__
1476
+ function getYoctocolors() {
1477
+ return import_yoctocolors_cjs.default;
1478
+ }
1471
1479
  function getDefaultLogger() {
1472
1480
  if (_logger === void 0) {
1473
1481
  _logger = new Logger();