@socketsecurity/lib 6.0.7 → 6.0.9

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 (323) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +1 -1
  3. package/dist/ai/agent-context.d.mts +103 -0
  4. package/dist/ai/agent-context.js +157 -0
  5. package/dist/ai/backends.d.mts +83 -0
  6. package/dist/ai/backends.js +173 -0
  7. package/dist/ai/credentials.d.mts +49 -0
  8. package/dist/ai/credentials.js +82 -0
  9. package/dist/ai/discover.d.mts +4 -0
  10. package/dist/ai/discover.js +1 -1
  11. package/dist/ai/exec.d.mts +52 -0
  12. package/dist/ai/exec.js +92 -0
  13. package/dist/ai/http.d.mts +132 -0
  14. package/dist/ai/http.js +130 -0
  15. package/dist/ai/profiles.d.mts +41 -6
  16. package/dist/ai/profiles.js +52 -10
  17. package/dist/ai/route.d.mts +82 -0
  18. package/dist/ai/route.js +171 -0
  19. package/dist/ai/spawn.d.mts +42 -2
  20. package/dist/ai/spawn.js +146 -33
  21. package/dist/ai/subagent-status.d.mts +48 -0
  22. package/dist/ai/subagent-status.js +57 -0
  23. package/dist/ai/tier.d.mts +60 -0
  24. package/dist/ai/tier.js +53 -0
  25. package/dist/ai/types.d.mts +25 -2
  26. package/dist/ai/worktree.js +4 -0
  27. package/dist/archives/tar.js +1 -1
  28. package/dist/archives/zip.js +2 -2
  29. package/dist/argv/parse.d.ts +19 -2
  30. package/dist/argv/parse.js +1 -1
  31. package/dist/arrays/join.js +4 -0
  32. package/dist/bin/find.js +4 -4
  33. package/dist/bin/prim.cjs +23322 -18018
  34. package/dist/bin/resolve.js +2 -2
  35. package/dist/cache/ttl/store.js +2 -2
  36. package/dist/cli/check-primordials.d.ts +8 -3
  37. package/dist/cli/check-primordials.js +4 -4
  38. package/dist/compression/_internal.js +1 -1
  39. package/dist/compression/brotli.d.ts +1 -2
  40. package/dist/compression/brotli.js +5 -1
  41. package/dist/compression/gzip.js +5 -1
  42. package/dist/config/layers.d.ts +53 -0
  43. package/dist/config/layers.js +83 -0
  44. package/dist/constants/packages.d.ts +3 -0
  45. package/dist/constants/packages.js +2 -1
  46. package/dist/constants/socket.d.ts +2 -6
  47. package/dist/constants/socket.js +12 -14
  48. package/dist/cover/code.js +2 -2
  49. package/dist/crypto/hash.d.ts +4 -1
  50. package/dist/crypto/hash.js +4 -1
  51. package/dist/dlx/arborist.js +13 -3
  52. package/dist/dlx/binary-cache.js +1 -1
  53. package/dist/dlx/binary-resolution.js +1 -1
  54. package/dist/dlx/detect.d.ts +8 -0
  55. package/dist/dlx/firewall.d.ts +8 -0
  56. package/dist/dlx/lockfile.js +5 -2
  57. package/dist/dlx/manifest.js +1 -1
  58. package/dist/dlx/package.js +4 -0
  59. package/dist/eco/cargo/parse-lockfile.d.ts +1 -2
  60. package/dist/eco/cargo/parse-lockfile.js +3 -3
  61. package/dist/eco/manifest/detect-format.js +1 -1
  62. package/dist/eco/npm/npm/parse-lockfile.d.ts +3 -4
  63. package/dist/eco/npm/npm/parse-lockfile.js +2 -2
  64. package/dist/eco/npm/parse-package-json.d.ts +11 -0
  65. package/dist/eco/npm/parse-package-json.js +1 -1
  66. package/dist/eco/npm/pnpm/parse-lockfile.d.ts +5 -3
  67. package/dist/eco/npm/pnpm/parse-lockfile.js +3 -3
  68. package/dist/eco/npm/yarnpkg/yarn/exec.js +1 -1
  69. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.d.ts +1 -2
  70. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +2 -2
  71. package/dist/env/proxy.js +1 -1
  72. package/dist/env/rewire.d.ts +6 -3
  73. package/dist/env/rewire.js +7 -8
  74. package/dist/env/socket.d.ts +7 -0
  75. package/dist/env/socket.js +10 -0
  76. package/dist/env/xdg.d.ts +17 -0
  77. package/dist/env/xdg.js +21 -1
  78. package/dist/errors/predicates.js +1 -1
  79. package/dist/errors/stack.js +1 -2
  80. package/dist/external/@npmcli/package-json.js +3455 -4881
  81. package/dist/external/@npmcli/promise-spawn.js +3 -1
  82. package/dist/external/@yarnpkg/extensions.js +1 -1
  83. package/dist/external/external-pack.js +1 -1
  84. package/dist/external/npm-pack.js +29164 -31799
  85. package/dist/external/pico-pack.js +4 -2
  86. package/dist/external/tar-fs.js +63 -16
  87. package/dist/external/which.js +3 -1
  88. package/dist/external-tools/bazel/asset-names.d.ts +1 -1
  89. package/dist/external-tools/bazel/asset-names.js +5 -2
  90. package/dist/external-tools/bazel/from-download.d.ts +1 -1
  91. package/dist/external-tools/bazel/from-download.js +5 -2
  92. package/dist/external-tools/bazel/resolve-bazel-version.js +4 -0
  93. package/dist/external-tools/bazel/resolve.d.ts +3 -3
  94. package/dist/external-tools/bazel/resolve.js +16 -8
  95. package/dist/external-tools/cdxgen/asset-names.d.ts +1 -1
  96. package/dist/external-tools/cdxgen/asset-names.js +5 -2
  97. package/dist/external-tools/cdxgen/from-download.d.ts +1 -1
  98. package/dist/external-tools/cdxgen/from-download.js +7 -4
  99. package/dist/external-tools/cdxgen/resolve.d.ts +3 -3
  100. package/dist/external-tools/cdxgen/resolve.js +16 -8
  101. package/dist/external-tools/from-download.d.ts +2 -2
  102. package/dist/external-tools/from-download.js +11 -5
  103. package/dist/external-tools/from-pip-venv.d.ts +1 -1
  104. package/dist/external-tools/from-pip-venv.js +12 -5
  105. package/dist/external-tools/janus/asset-names.d.ts +1 -1
  106. package/dist/external-tools/janus/asset-names.js +5 -2
  107. package/dist/external-tools/janus/from-download.d.ts +1 -1
  108. package/dist/external-tools/janus/from-download.js +5 -2
  109. package/dist/external-tools/janus/resolve.d.ts +3 -3
  110. package/dist/external-tools/janus/resolve.js +16 -8
  111. package/dist/external-tools/jre/asset-names.d.ts +1 -1
  112. package/dist/external-tools/jre/asset-names.js +5 -2
  113. package/dist/external-tools/jre/detect-platform-arch.js +1 -1
  114. package/dist/external-tools/jre/from-download.d.ts +1 -1
  115. package/dist/external-tools/jre/from-download.js +7 -4
  116. package/dist/external-tools/jre/from-java-home.js +2 -2
  117. package/dist/external-tools/jre/from-vfs.js +2 -2
  118. package/dist/external-tools/jre/resolve.d.ts +3 -3
  119. package/dist/external-tools/jre/resolve.js +16 -8
  120. package/dist/external-tools/manifest.d.ts +18 -0
  121. package/dist/external-tools/manifest.js +2 -2
  122. package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
  123. package/dist/external-tools/opengrep/asset-names.js +5 -2
  124. package/dist/external-tools/opengrep/from-download.d.ts +1 -1
  125. package/dist/external-tools/opengrep/from-download.js +5 -2
  126. package/dist/external-tools/opengrep/resolve.d.ts +3 -3
  127. package/dist/external-tools/opengrep/resolve.js +16 -8
  128. package/dist/external-tools/python/asset-names.d.ts +1 -1
  129. package/dist/external-tools/python/asset-names.js +11 -4
  130. package/dist/external-tools/python/dlx.d.ts +3 -3
  131. package/dist/external-tools/python/dlx.js +20 -9
  132. package/dist/external-tools/python/from-download.d.ts +1 -1
  133. package/dist/external-tools/python/from-download.js +12 -5
  134. package/dist/external-tools/python/pin.js +6 -3
  135. package/dist/external-tools/python/pip-install.js +6 -3
  136. package/dist/external-tools/python/resolve.d.ts +3 -3
  137. package/dist/external-tools/python/resolve.js +19 -11
  138. package/dist/external-tools/python/uv-install.d.ts +89 -0
  139. package/dist/external-tools/python/uv-install.js +165 -0
  140. package/dist/external-tools/sbt/asset-names.d.ts +1 -1
  141. package/dist/external-tools/sbt/asset-names.js +5 -2
  142. package/dist/external-tools/sbt/from-download.d.ts +1 -1
  143. package/dist/external-tools/sbt/from-download.js +5 -2
  144. package/dist/external-tools/sbt/resolve.d.ts +3 -3
  145. package/dist/external-tools/sbt/resolve.js +16 -8
  146. package/dist/external-tools/skillspector/from-dlx.d.ts +1 -1
  147. package/dist/external-tools/skillspector/from-dlx.js +10 -3
  148. package/dist/external-tools/skillspector/from-uv.d.ts +30 -0
  149. package/dist/external-tools/skillspector/from-uv.js +56 -0
  150. package/dist/external-tools/skillspector/resolve.d.ts +20 -5
  151. package/dist/external-tools/skillspector/resolve.js +27 -6
  152. package/dist/external-tools/skillspector/types.d.ts +3 -1
  153. package/dist/external-tools/synp/asset-names.d.ts +1 -1
  154. package/dist/external-tools/synp/asset-names.js +6 -2
  155. package/dist/external-tools/synp/from-download.d.ts +1 -1
  156. package/dist/external-tools/synp/from-download.js +5 -2
  157. package/dist/external-tools/synp/resolve.d.ts +3 -3
  158. package/dist/external-tools/synp/resolve.js +16 -8
  159. package/dist/external-tools/trivy/asset-names.d.ts +1 -1
  160. package/dist/external-tools/trivy/asset-names.js +5 -2
  161. package/dist/external-tools/trivy/from-download.d.ts +1 -1
  162. package/dist/external-tools/trivy/from-download.js +7 -4
  163. package/dist/external-tools/trivy/resolve.d.ts +3 -3
  164. package/dist/external-tools/trivy/resolve.js +16 -8
  165. package/dist/external-tools/trufflehog/asset-names.d.ts +1 -1
  166. package/dist/external-tools/trufflehog/asset-names.js +5 -2
  167. package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
  168. package/dist/external-tools/trufflehog/from-download.js +7 -4
  169. package/dist/external-tools/trufflehog/resolve.d.ts +3 -3
  170. package/dist/external-tools/trufflehog/resolve.js +16 -8
  171. package/dist/external-tools/uv/asset-names.d.ts +36 -0
  172. package/dist/external-tools/uv/asset-names.js +73 -0
  173. package/dist/external-tools/uv/from-download.d.ts +17 -0
  174. package/dist/external-tools/uv/from-download.js +50 -0
  175. package/dist/external-tools/uv/from-path.d.ts +5 -0
  176. package/dist/external-tools/uv/from-path.js +22 -0
  177. package/dist/external-tools/uv/from-vfs.d.ts +7 -0
  178. package/dist/external-tools/uv/from-vfs.js +26 -0
  179. package/dist/external-tools/uv/resolve.d.ts +25 -0
  180. package/dist/external-tools/uv/resolve.js +61 -0
  181. package/dist/external-tools/uv/types.d.ts +24 -0
  182. package/dist/external-tools/uv/types.js +2 -0
  183. package/dist/fleet/repo-config.d.ts +53 -0
  184. package/dist/fleet/repo-config.js +79 -0
  185. package/dist/fs/allowed-dirs-cache.d.ts +27 -1
  186. package/dist/fs/allowed-dirs-cache.js +39 -6
  187. package/dist/fs/copy.d.ts +88 -0
  188. package/dist/fs/copy.js +89 -0
  189. package/dist/fs/find.js +1 -1
  190. package/dist/fs/read-json-cache.d.ts +7 -0
  191. package/dist/fs/resolve-module.js +6 -2
  192. package/dist/fs/safe.js +1 -1
  193. package/dist/git/_internal.js +3 -3
  194. package/dist/git/repo.js +2 -4
  195. package/dist/git/staged.js +8 -0
  196. package/dist/git/tracked.d.ts +84 -0
  197. package/dist/git/tracked.js +163 -0
  198. package/dist/git/unstaged.js +8 -0
  199. package/dist/github/refs-graphql.js +4 -0
  200. package/dist/github/refs-rest.js +4 -0
  201. package/dist/globs/_internal.js +1 -1
  202. package/dist/globs/match.js +9 -1
  203. package/dist/globs/matcher.js +5 -1
  204. package/dist/http-request/browser.js +7 -3
  205. package/dist/http-request/checksum-file.js +1 -1
  206. package/dist/http-request/{browser-fetch.d.ts → fetch/browser.d.ts} +2 -2
  207. package/dist/http-request/{browser-fetch.js → fetch/browser.js} +4 -4
  208. package/dist/http-request/headers.js +1 -1
  209. package/dist/http-request/request-attempt.js +2 -2
  210. package/dist/http-request/user-agent.js +1 -1
  211. package/dist/integrity.d.ts +124 -71
  212. package/dist/integrity.js +168 -78
  213. package/dist/json/edit.js +38 -30
  214. package/dist/json/format.js +1 -1
  215. package/dist/logger/colors.d.ts +1 -2
  216. package/dist/logger/colors.js +2 -2
  217. package/dist/logger/symbols-builder.js +7 -8
  218. package/dist/logger/symbols.js +8 -8
  219. package/dist/native-messaging/install.d.ts +1 -1
  220. package/dist/native-messaging/install.js +7 -4
  221. package/dist/native-messaging/rate-limit.d.ts +7 -0
  222. package/dist/native-messaging/rate-limit.js +4 -0
  223. package/dist/node/async-hooks.js +1 -1
  224. package/dist/node/child-process.js +1 -1
  225. package/dist/node/crypto.js +1 -1
  226. package/dist/node/events.js +1 -1
  227. package/dist/node/fs-promises.js +1 -1
  228. package/dist/node/fs.d.ts +22 -6
  229. package/dist/node/fs.js +16 -3
  230. package/dist/node/http.js +1 -1
  231. package/dist/node/https.js +1 -1
  232. package/dist/node/module.d.ts +73 -2
  233. package/dist/node/module.js +97 -12
  234. package/dist/node/os.d.ts +10 -2
  235. package/dist/node/os.js +11 -4
  236. package/dist/node/path.d.ts +11 -2
  237. package/dist/node/path.js +17 -4
  238. package/dist/node/timers-promises.js +1 -1
  239. package/dist/node/url.js +1 -1
  240. package/dist/node/util.js +1 -1
  241. package/dist/objects/getters.js +1 -1
  242. package/dist/objects/mutate.js +2 -2
  243. package/dist/packages/edit-class.d.ts +2 -3
  244. package/dist/packages/edit-class.js +41 -35
  245. package/dist/packages/exports.js +4 -4
  246. package/dist/packages/fetch.js +1 -1
  247. package/dist/packages/isolation.js +2 -2
  248. package/dist/packages/licenses.js +2 -2
  249. package/dist/packages/manifest.d.ts +29 -0
  250. package/dist/packages/manifest.js +40 -4
  251. package/dist/packages/normalize.js +2 -2
  252. package/dist/packages/provenance.js +3 -3
  253. package/dist/packages/specs.js +1 -1
  254. package/dist/packages/tarball.js +4 -2
  255. package/dist/packages/types.d.ts +1 -2
  256. package/dist/paths/_internal.d.ts +1 -7
  257. package/dist/paths/_internal.js +9 -15
  258. package/dist/paths/conversion.js +1 -1
  259. package/dist/paths/dirnames.d.ts +1 -0
  260. package/dist/paths/dirnames.js +2 -0
  261. package/dist/paths/normalize.js +1 -1
  262. package/dist/paths/predicates.js +2 -1
  263. package/dist/paths/resolve.js +14 -19
  264. package/dist/paths/rewire.d.ts +5 -0
  265. package/dist/paths/socket.d.ts +137 -123
  266. package/dist/paths/socket.js +172 -131
  267. package/dist/perf/metrics.js +1 -1
  268. package/dist/perf/report.js +1 -1
  269. package/dist/primordials/process.d.ts +88 -0
  270. package/dist/primordials/process.js +132 -0
  271. package/dist/primordials/uncurry.d.ts +1 -2
  272. package/dist/process/spawn/child.js +8 -2
  273. package/dist/process/spawn/errors.js +1 -1
  274. package/dist/releases/github-archives.js +1 -1
  275. package/dist/releases/github-listing.d.ts +1 -2
  276. package/dist/schema/types.d.ts +3 -4
  277. package/dist/schema/validate.js +1 -1
  278. package/dist/secrets/broker.d.ts +35 -0
  279. package/dist/secrets/broker.js +72 -0
  280. package/dist/secrets/find.d.ts +8 -6
  281. package/dist/secrets/find.js +25 -5
  282. package/dist/secrets/keychain.d.ts +1 -1
  283. package/dist/secrets/linux.js +32 -44
  284. package/dist/secrets/macos.d.ts +1 -2
  285. package/dist/secrets/macos.js +20 -29
  286. package/dist/secrets/rc.d.ts +2 -2
  287. package/dist/secrets/rc.js +21 -13
  288. package/dist/secrets/socket-api-token.js +8 -0
  289. package/dist/secrets/windows.js +27 -33
  290. package/dist/shell/parse.d.ts +32 -0
  291. package/dist/shell/parse.js +60 -0
  292. package/dist/smol/detect.js +1 -1
  293. package/dist/smol/http.js +1 -1
  294. package/dist/smol/https.js +1 -1
  295. package/dist/smol/manifest.js +1 -1
  296. package/dist/smol/path.js +1 -1
  297. package/dist/smol/primordial.js +1 -1
  298. package/dist/smol/purl.js +1 -1
  299. package/dist/smol/versions.js +1 -1
  300. package/dist/smol/vfs.js +1 -1
  301. package/dist/sorts/_internal.d.ts +1 -2
  302. package/dist/sorts/_internal.js +2 -6
  303. package/dist/sorts/semver.js +2 -2
  304. package/dist/spinner/create-spinner-class.js +2 -2
  305. package/dist/spinner/spinner-internals.d.ts +1 -1
  306. package/dist/spinner/spinner-internals.js +9 -5
  307. package/dist/spinner/spinner.d.ts +4 -0
  308. package/dist/spinner/spinner.js +1 -1
  309. package/dist/stdio/progress.js +6 -2
  310. package/dist/stdio/prompts.d.ts +2 -10
  311. package/dist/stdio/prompts.js +11 -24
  312. package/dist/strings/format.js +1 -1
  313. package/dist/strings/search.js +1 -1
  314. package/dist/temporal/instant.js +2 -2
  315. package/dist/themes/context.d.ts +5 -3
  316. package/dist/themes/context.js +5 -6
  317. package/dist/url/assert-safe.d.ts +29 -0
  318. package/dist/url/assert-safe.js +54 -0
  319. package/dist/url/predicates.d.ts +31 -1
  320. package/dist/url/predicates.js +42 -1
  321. package/dist/url/types.d.ts +4 -0
  322. package/llms.txt +750 -0
  323. package/package.json +253 -125
package/dist/json/edit.js CHANGED
@@ -33,21 +33,21 @@ let editableJsonClass;
33
33
  */
34
34
  function getEditableJsonClass() {
35
35
  if (editableJsonClass === void 0) editableJsonClass = class EditableJson {
36
- _canSave = true;
37
- _content = {};
38
- _path = void 0;
39
- _readFileContent = "";
40
- _readFileJson = void 0;
36
+ canSave = true;
37
+ contentData = {};
38
+ pathValue = void 0;
39
+ readFileContent = "";
40
+ readFileJson = void 0;
41
41
  get content() {
42
- return this._content;
42
+ return this.contentData;
43
43
  }
44
44
  get filename() {
45
- const path = this._path;
45
+ const path = this.pathValue;
46
46
  if (!path) return "";
47
47
  return path;
48
48
  }
49
49
  get path() {
50
- return this._path;
50
+ return this.pathValue;
51
51
  }
52
52
  static async create(path, opts = { __proto__: null }) {
53
53
  const instance = new EditableJson();
@@ -66,14 +66,14 @@ function getEditableJsonClass() {
66
66
  /* c8 ignore stop */
67
67
  }
68
68
  create(path) {
69
- this._path = path;
70
- this._content = {};
71
- this._canSave = true;
69
+ this.pathValue = path;
70
+ this.contentData = {};
71
+ this.canSave = true;
72
72
  return this;
73
73
  }
74
74
  fromContent(data) {
75
- this._content = data;
76
- this._canSave = false;
75
+ this.contentData = data;
76
+ this.canSave = false;
77
77
  return this;
78
78
  }
79
79
  fromJSON(data) {
@@ -82,46 +82,54 @@ function getEditableJsonClass() {
82
82
  const newline = require_json_format.detectNewline(data);
83
83
  parsed[identSymbol] = indent;
84
84
  parsed[newlineSymbol] = newline;
85
- this._content = parsed;
85
+ this.contentData = parsed;
86
86
  return this;
87
87
  }
88
88
  async load(path) {
89
- this._path = path;
90
- this._readFileContent = await readFile(this.filename);
91
- this.fromJSON(this._readFileContent);
92
- this._readFileJson = require_primordials_json.JSONParse(this._readFileContent);
89
+ this.pathValue = path;
90
+ this.readFileContent = await readFile(this.filename);
91
+ this.fromJSON(this.readFileContent);
92
+ this.readFileJson = require_primordials_json.JSONParse(this.readFileContent);
93
93
  return this;
94
94
  }
95
95
  async save(options) {
96
- if (!this._canSave || this.content === void 0) throw new require_primordials_error.ErrorCtor("No file path to save to");
97
- if (!require_json_format.shouldSave(this.content, this._readFileJson, this._readFileContent, options)) return false;
96
+ options = {
97
+ __proto__: null,
98
+ ...options
99
+ };
100
+ if (!this.canSave || this.content === void 0) throw new require_primordials_error.ErrorCtor("No file path to save to");
101
+ if (!require_json_format.shouldSave(this.content, this.readFileJson, this.readFileContent, options)) return false;
98
102
  const content = require_json_format.stripFormattingSymbols(this.content);
99
103
  const fileContent = require_json_format.stringifyWithFormatting(options?.sort ? require_json_format.sortKeys(content) : content, require_json_format.getFormattingFromContent(this.content));
100
104
  await retryWrite(this.filename, fileContent);
101
- this._readFileContent = fileContent;
102
- this._readFileJson = require_primordials_json.JSONParse(fileContent);
105
+ this.readFileContent = fileContent;
106
+ this.readFileJson = require_primordials_json.JSONParse(fileContent);
103
107
  return true;
104
108
  }
105
109
  saveSync(options) {
106
- if (!this._canSave || this.content === void 0) throw new require_primordials_error.ErrorCtor("No file path to save to");
107
- if (!require_json_format.shouldSave(this.content, this._readFileJson, this._readFileContent, options)) return false;
110
+ options = {
111
+ __proto__: null,
112
+ ...options
113
+ };
114
+ if (!this.canSave || this.content === void 0) throw new require_primordials_error.ErrorCtor("No file path to save to");
115
+ if (!require_json_format.shouldSave(this.content, this.readFileJson, this.readFileContent, options)) return false;
108
116
  const content = require_json_format.stripFormattingSymbols(this.content);
109
117
  const fileContent = require_json_format.stringifyWithFormatting(options?.sort ? require_json_format.sortKeys(content) : content, require_json_format.getFormattingFromContent(this.content));
110
118
  require_node_fs.getNodeFs().writeFileSync(this.filename, fileContent);
111
- this._readFileContent = fileContent;
112
- this._readFileJson = require_primordials_json.JSONParse(fileContent);
119
+ this.readFileContent = fileContent;
120
+ this.readFileJson = require_primordials_json.JSONParse(fileContent);
113
121
  return true;
114
122
  }
115
123
  update(content) {
116
- this._content = {
117
- ...this._content,
124
+ this.contentData = {
125
+ ...this.contentData,
118
126
  ...content
119
127
  };
120
128
  return this;
121
129
  }
122
130
  willSave(options) {
123
- if (!this._canSave || this.content === void 0) return false;
124
- return require_json_format.shouldSave(this.content, this._readFileJson, this._readFileContent, options);
131
+ if (!this.canSave || this.content === void 0) return false;
132
+ return require_json_format.shouldSave(this.content, this.readFileJson, this.readFileContent, options);
125
133
  }
126
134
  };
127
135
  return editableJsonClass;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_primordials_json = require('../primordials/json.js');
5
4
  const require_primordials_object = require('../primordials/object.js');
5
+ const require_primordials_json = require('../primordials/json.js');
6
6
 
7
7
  //#region src/json/format.ts
8
8
  /**
@@ -5,13 +5,12 @@
5
5
  * emitted via the 24-bit `[38;2;...m` escape because `yoctocolors-cjs`
6
6
  * doesn't ship an `rgb()` helper.
7
7
  */
8
- import yoctocolorsCjs from '../external/yoctocolors-cjs';
9
8
  import type { ColorValue } from '../colors/types';
10
9
  /**
11
10
  * Apply a color to text using yoctocolors. Handles both named colors and RGB
12
11
  * tuples.
13
12
  */
14
- export declare function applyColor(text: string, color: ColorValue, colors: typeof yoctocolorsCjs): string;
13
+ export declare function applyColor(text: string, color: ColorValue): string;
15
14
  /**
16
15
  * Get the yoctocolors module for terminal colors.
17
16
  */
@@ -17,9 +17,9 @@ src_external_yoctocolors_cjs = require_runtime.__toESM(src_external_yoctocolors_
17
17
  * Apply a color to text using yoctocolors. Handles both named colors and RGB
18
18
  * tuples.
19
19
  */
20
- function applyColor(text, color, colors) {
20
+ function applyColor(text, color) {
21
21
  if (typeof color === "string") {
22
- const formatter = colors[color];
22
+ const formatter = src_external_yoctocolors_cjs.default[color];
23
23
  return formatter ? formatter(text) : text;
24
24
  }
25
25
  const { 0: r, 1: g, 2: b } = color;
@@ -26,18 +26,17 @@ src_external__socketregistry_is_unicode_supported = require_runtime.__toESM(src_
26
26
  */
27
27
  function buildLoggerSymbols(theme) {
28
28
  const supported = (0, src_external__socketregistry_is_unicode_supported.default)();
29
- const colors = require_logger_colors.getYoctocolors();
30
29
  /* c8 ignore start - ASCII-fallback symbol arms only fire on
31
30
  terminals without unicode support; tests run on unicode TTYs. */
32
31
  return {
33
32
  __proto__: null,
34
- fail: require_logger_colors.applyColor(supported ? "✖" : "×", theme.colors.error, colors),
35
- info: require_logger_colors.applyColor(supported ? "ℹ" : "i", theme.colors.info, colors),
36
- progress: require_logger_colors.applyColor(supported ? "∴" : ":.", theme.colors.step, colors),
37
- skip: require_logger_colors.applyColor(supported ? "↻" : "@", theme.colors.step, colors),
38
- step: require_logger_colors.applyColor(supported ? "→" : ">", theme.colors.step, colors),
39
- success: require_logger_colors.applyColor(supported ? "✔" : "√", theme.colors.success, colors),
40
- warn: require_logger_colors.applyColor(supported ? "⚠" : "‼", theme.colors.warning, colors)
33
+ fail: require_logger_colors.applyColor(supported ? "✖" : "×", theme.colors.error),
34
+ info: require_logger_colors.applyColor(supported ? "ℹ" : "i", theme.colors.info),
35
+ progress: require_logger_colors.applyColor(supported ? "∴" : ":.", theme.colors.step),
36
+ skip: require_logger_colors.applyColor(supported ? "↻" : "@", theme.colors.step),
37
+ step: require_logger_colors.applyColor(supported ? "→" : ">", theme.colors.step),
38
+ success: require_logger_colors.applyColor(supported ? "✔" : "√", theme.colors.success),
39
+ warn: require_logger_colors.applyColor(supported ? "⚠" : "‼", theme.colors.warning)
41
40
  };
42
41
  /* c8 ignore stop */
43
42
  }
@@ -39,14 +39,14 @@ function createLogSymbols() {
39
39
  const stepColor = theme.colors.step;
40
40
  /* c8 ignore start - ASCII-fallback symbol arms only fire on
41
41
  terminals without unicode support; tests run on unicode TTYs. */
42
- target["fail"] = require_logger_colors.applyColor(supported ? "✖" : "×", errorColor, colors);
43
- target["info"] = require_logger_colors.applyColor(supported ? "ℹ" : "i", infoColor, colors);
44
- target["progress"] = require_logger_colors.applyColor(supported ? "∴" : ":.", stepColor, colors);
45
- target["reason"] = colors.dim(require_logger_colors.applyColor(supported ? "∴" : ":.", warningColor, colors));
46
- target["skip"] = require_logger_colors.applyColor(supported ? "↻" : "@", stepColor, colors);
47
- target["step"] = require_logger_colors.applyColor(supported ? "→" : ">", stepColor, colors);
48
- target["success"] = require_logger_colors.applyColor(supported ? "✔" : "√", successColor, colors);
49
- target["warn"] = require_logger_colors.applyColor(supported ? "⚠" : "‼", warningColor, colors);
42
+ target["fail"] = require_logger_colors.applyColor(supported ? "✖" : "×", errorColor);
43
+ target["info"] = require_logger_colors.applyColor(supported ? "ℹ" : "i", infoColor);
44
+ target["progress"] = require_logger_colors.applyColor(supported ? "∴" : ":.", stepColor);
45
+ target["reason"] = colors.dim(require_logger_colors.applyColor(supported ? "∴" : ":.", warningColor));
46
+ target["skip"] = require_logger_colors.applyColor(supported ? "↻" : "@", stepColor);
47
+ target["step"] = require_logger_colors.applyColor(supported ? "→" : ">", stepColor);
48
+ target["success"] = require_logger_colors.applyColor(supported ? "✔" : "√", successColor);
49
+ target["warn"] = require_logger_colors.applyColor(supported ? "⚠" : "‼", warningColor);
50
50
  /* c8 ignore stop */
51
51
  };
52
52
  const init = () => {
@@ -53,7 +53,7 @@ export interface InstallResult {
53
53
  export declare function assertNodeStripTypesSupported(): void;
54
54
  export declare function buildManifest(wrapperPath: string, allowedOrigins: string[]): object;
55
55
  export declare function chromeManifestDirs(): string[];
56
- export declare function installNativeHost(opts: InstallOptions): InstallResult;
56
+ export declare function installNativeHost(options: InstallOptions): InstallResult;
57
57
  export declare function registerWindows(manifestPath: string): void;
58
58
  export declare function stripTypesFlag(): string;
59
59
  export declare function writeWrapperPosix(wrapperPath: string): void;
@@ -9,11 +9,11 @@ const require_env_windows = require('../env/windows.js');
9
9
  const require_constants_node = require('../constants/node.js');
10
10
  const require_env_node_version_managers = require('../env/node-version-managers.js');
11
11
  let node_fs = require("node:fs");
12
+ let node_process = require("node:process");
13
+ node_process = require_runtime.__toESM(node_process);
12
14
  let node_path = require("node:path");
13
15
  node_path = require_runtime.__toESM(node_path);
14
16
  let node_url = require("node:url");
15
- let node_process = require("node:process");
16
- node_process = require_runtime.__toESM(node_process);
17
17
  let _socketsecurity_lib_stable_process_spawn_child = require("@socketsecurity/lib-stable/process/spawn/child");
18
18
 
19
19
  //#region src/native-messaging/install.ts
@@ -78,9 +78,12 @@ function chromeManifestDirs() {
78
78
  const config = node_process.default.env["XDG_CONFIG_HOME"] ?? node_path.default.join(home, ".config");
79
79
  return [node_path.default.join(config, "google-chrome", "NativeMessagingHosts"), node_path.default.join(config, "chromium", "NativeMessagingHosts")];
80
80
  }
81
- function installNativeHost(opts) {
81
+ function installNativeHost(options) {
82
82
  assertNodeStripTypesSupported();
83
- const { allowedOrigins, production = false, wrapperDir = __dirname$1 } = opts;
83
+ const { allowedOrigins, production = false, wrapperDir = __dirname$1 } = {
84
+ __proto__: null,
85
+ ...options
86
+ };
84
87
  if (production && allowedOrigins.includes("*")) throw new require_primordials_error.ErrorCtor("production mode rejects allowedOrigins '*' — pin to specific chrome-extension://<id>/ origins");
85
88
  if (allowedOrigins.length === 0) throw new require_primordials_error.ErrorCtor("allowedOrigins must contain at least one origin; pass ['*'] for development");
86
89
  const wrapperName = require_constants_platform.WIN32 ? `${HOST_NAME}.cmd` : `${HOST_NAME}.sh`;
@@ -38,6 +38,13 @@ export interface TokenBucketOptions {
38
38
  */
39
39
  maxKeys: number;
40
40
  }
41
+ export interface BucketEntry {
42
+ tokens: number;
43
+ lastRefillAt: number;
44
+ newer: BucketEntry | undefined;
45
+ older: BucketEntry | undefined;
46
+ key: string;
47
+ }
41
48
  export declare class TokenBucketLimiter {
42
49
  #private;
43
50
  constructor(options: TokenBucketOptions);
@@ -31,6 +31,10 @@ var TokenBucketLimiter = class {
31
31
  #newest = void 0;
32
32
  #oldest = void 0;
33
33
  constructor(options) {
34
+ options = {
35
+ __proto__: null,
36
+ ...options
37
+ };
34
38
  if (options.capacity < 1) throw new require_primordials_error.ErrorCtor("capacity must be >= 1");
35
39
  if (options.refillIntervalMs <= 0) throw new require_primordials_error.ErrorCtor("refillIntervalMs must be > 0");
36
40
  if (options.maxKeys < 1) throw new require_primordials_error.ErrorCtor("maxKeys must be >= 1");
@@ -7,7 +7,7 @@ const require_constants_runtime = require('../constants/runtime.js');
7
7
  let asyncHooks;
8
8
  function getNodeAsyncHooks() {
9
9
  if (!require_constants_runtime.IS_NODE) return;
10
- return asyncHooks ??= /*@__PURE__*/ require("node:async_hooks");
10
+ return asyncHooks ??= /*@__PURE__*/ require("async_hooks");
11
11
  }
12
12
 
13
13
  //#endregion
@@ -7,7 +7,7 @@ const require_constants_runtime = require('../constants/runtime.js');
7
7
  let childProcess;
8
8
  function getNodeChildProcess() {
9
9
  if (!require_constants_runtime.IS_NODE) return;
10
- return childProcess ??= /*@__PURE__*/ require("node:child_process");
10
+ return childProcess ??= /*@__PURE__*/ require("child_process");
11
11
  }
12
12
 
13
13
  //#endregion
@@ -7,7 +7,7 @@ const require_constants_runtime = require('../constants/runtime.js');
7
7
  let crypto;
8
8
  function getNodeCrypto() {
9
9
  if (!require_constants_runtime.IS_NODE) return;
10
- return crypto ??= /*@__PURE__*/ require("node:crypto");
10
+ return crypto ??= /*@__PURE__*/ require("crypto");
11
11
  }
12
12
 
13
13
  //#endregion
@@ -7,7 +7,7 @@ const require_constants_runtime = require('../constants/runtime.js');
7
7
  let events;
8
8
  function getNodeEvents() {
9
9
  if (!require_constants_runtime.IS_NODE) return;
10
- return events ??= /*@__PURE__*/ require("node:events");
10
+ return events ??= /*@__PURE__*/ require("events");
11
11
  }
12
12
 
13
13
  //#endregion
@@ -7,7 +7,7 @@ const require_constants_runtime = require('../constants/runtime.js');
7
7
  let fsPromises;
8
8
  function getNodeFsPromises() {
9
9
  if (!require_constants_runtime.IS_NODE) return;
10
- return fsPromises ??= /*@__PURE__*/ require("node:fs/promises");
10
+ return fsPromises ??= /*@__PURE__*/ require("fs/promises");
11
11
  }
12
12
 
13
13
  //#endregion
package/dist/node/fs.d.ts CHANGED
@@ -1,10 +1,26 @@
1
1
  /**
2
- * @file Lazy-loader for `node:fs`. Bundlers (Webpack/Rollup/esbuild) targeting
3
- * browsers can't statically resolve `require('node:fs')` — but they CAN drop
4
- * the call entirely if it's wrapped in a `/*@__NO_SIDE_EFFECTS__*\/`-marked
5
- * function and never called. So we always go through `getFs()` instead of
6
- * importing top-level. Cache slot is module-local: first call resolves the
7
- * require, every subsequent call returns the cached reference.
2
+ * @file Early-snapshot accessor for `node:fs`. The `require('fs')` runs at
3
+ * module load, but ONLY inside the `IS_NODE` runtime guard in a browser
4
+ * `IS_NODE` is `false`, so the require branch never executes (bundlers mark
5
+ * `node:` builtins external, so the call survives in the output but is
6
+ * unreachable at runtime). In Node the module is captured at load: a
7
+ * primordial-style snapshot, so a later tamper of the `node:fs` cache entry
8
+ * can't redirect what we already hold. `getNodeFs()` returns the captured
9
+ * reference; the `/*@__PURE__*\/` lets a Node-targeted minifier strip the
10
+ * capture when `getNodeFs` is unused. Was a lazy first-call loader; the
11
+ * eager-but-guarded form keeps the browser-safe behavior while gaining the
12
+ * load-time snapshot. Two surfaces: `getNodeFs()` returns the module object
13
+ * with LATE method lookup (spy-able — the test seam); the `fs<Method>` consts
14
+ * (`fsExistsSync`, `fsReadFileSync`, …) are method references FROZEN at load
15
+ * (tamper-proof against a method swap, not spy-able), for the fleet's hot fs
16
+ * calls. Both stay browser-safe behind IS_NODE + `/*@__PURE__*\/`.
8
17
  */
9
18
  import type * as NodeFs from 'node:fs';
10
19
  export declare function getNodeFs(): typeof NodeFs;
20
+ export declare const fsAccessSync: any;
21
+ export declare const fsExistsSync: any;
22
+ export declare const fsMkdirSync: any;
23
+ export declare const fsReadFileSync: any;
24
+ export declare const fsRealpathSync: any;
25
+ export declare const fsStatSync: any;
26
+ export declare const fsWriteFileSync: any;
package/dist/node/fs.js CHANGED
@@ -4,11 +4,24 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_constants_runtime = require('../constants/runtime.js');
5
5
 
6
6
  //#region src/node/fs.ts
7
- let cachedFs;
7
+ const nodeFs = require_constants_runtime.IS_NODE ? /*@__PURE__*/ require("fs") : void 0;
8
8
  function getNodeFs() {
9
- if (!require_constants_runtime.IS_NODE) return;
10
- return cachedFs ??= /*@__PURE__*/ require("node:fs");
9
+ return nodeFs;
11
10
  }
11
+ const fsAccessSync = nodeFs?.accessSync;
12
+ const fsExistsSync = nodeFs?.existsSync;
13
+ const fsMkdirSync = nodeFs?.mkdirSync;
14
+ const fsReadFileSync = nodeFs?.readFileSync;
15
+ const fsRealpathSync = nodeFs?.realpathSync;
16
+ const fsStatSync = nodeFs?.statSync;
17
+ const fsWriteFileSync = nodeFs?.writeFileSync;
12
18
 
13
19
  //#endregion
20
+ exports.fsAccessSync = fsAccessSync;
21
+ exports.fsExistsSync = fsExistsSync;
22
+ exports.fsMkdirSync = fsMkdirSync;
23
+ exports.fsReadFileSync = fsReadFileSync;
24
+ exports.fsRealpathSync = fsRealpathSync;
25
+ exports.fsStatSync = fsStatSync;
26
+ exports.fsWriteFileSync = fsWriteFileSync;
14
27
  exports.getNodeFs = getNodeFs;
package/dist/node/http.js CHANGED
@@ -7,7 +7,7 @@ const require_constants_runtime = require('../constants/runtime.js');
7
7
  let cachedHttp;
8
8
  function getNodeHttp() {
9
9
  if (!require_constants_runtime.IS_NODE) return;
10
- return cachedHttp ??= /*@__PURE__*/ require("node:http");
10
+ return cachedHttp ??= /*@__PURE__*/ require("http");
11
11
  }
12
12
 
13
13
  //#endregion
@@ -7,7 +7,7 @@ const require_constants_runtime = require('../constants/runtime.js');
7
7
  let cachedHttps;
8
8
  function getNodeHttps() {
9
9
  if (!require_constants_runtime.IS_NODE) return;
10
- return cachedHttps ??= /*@__PURE__*/ require("node:https");
10
+ return cachedHttps ??= /*@__PURE__*/ require("https");
11
11
  }
12
12
 
13
13
  //#endregion
@@ -1,7 +1,78 @@
1
1
  /**
2
- * @file Lazy-loader for `node:module`. See `node/fs.ts` for the design
3
- * rationale shared across all `node/*.ts` lazy-loaders.
2
+ * @file Accessors for `node:module` that work across runtimes. Ambient
3
+ * `require` is bound in CommonJS but unbound in ESM and inside
4
+ * ahead-of-time-compiled package modules (e.g. Perry), where reading it
5
+ * throws. And Perry's `require('module')` value omits `isBuiltin`. So instead
6
+ * of the ambient `require('module')` lazy-loader, `isBuiltin`/`createRequire`
7
+ * are imported as named values from the bare `module` specifier — which
8
+ * resolves on Node and Perry, and which browser bundlers can stub via
9
+ * resolve.fallback (a `node:` prefix would throw UnhandledSchemeError
10
+ * there).
11
+ * `require` is DIRECTORY-SPECIFIC: `createRequire(base)` resolves relative
12
+ * specifiers (`./x`, `../y`) from `base`'s directory. For builtins and bare
13
+ * packages that's irrelevant (they resolve the same anywhere), so the cached
14
+ * `getRequire` / `requireBuiltin` bind to THIS file. A RELATIVE specifier
15
+ * must resolve from the CALLER's directory, so use `requireFrom` with the
16
+ * caller's `import.meta.url` — binding such a load to this file would resolve
17
+ * it against `src/node/` instead. Bundled, every module collapses to one base
18
+ * and either works; unbundled (e.g. AOT-compiled from source), each module
19
+ * sits at its own nested path and the base matters.
4
20
  */
5
21
  import type * as NodeModule from 'node:module';
22
+ /**
23
+ * Bind a working `require`. Ambient `require` exists in CommonJS; in ESM and
24
+ * ahead-of-time-compiled package modules it is unbound (reading it throws or
25
+ * yields undefined), so fall back to `createRequire`. Returns undefined off
26
+ * Node and in browsers, where neither is available.
27
+ *
28
+ * `fromUrl` sets the resolution base — pass a caller's `import.meta.url` to
29
+ * resolve that caller's RELATIVE specifiers. When omitted, the base is this
30
+ * file, which is correct only for builtins / bare packages (dir-independent).
31
+ * With `fromUrl` the ambient `require` is skipped: it is bound to THIS file, so
32
+ * it would resolve a relative specifier from the wrong directory.
33
+ */
34
+ export declare function bindRequire(fromUrl?: string | undefined): ((id: string) => unknown) | undefined;
35
+ /**
36
+ * Returns `node:module` (or undefined off Node), loaded through the bound
37
+ * `require`. Cached across calls.
38
+ */
6
39
  export declare function getNodeModule(): typeof NodeModule;
40
+ /**
41
+ * Returns a working `require` bound to THIS file, binding one on first call
42
+ * (see bindRequire). Cached across calls; undefined off Node / in browsers.
43
+ *
44
+ * For builtins and bare packages only — the resolution base is this file, so a
45
+ * relative specifier would resolve from `src/node/`. Use `requireFrom` for
46
+ * relative loads.
47
+ */
48
+ export declare function getRequire(): ((id: string) => unknown) | undefined;
49
+ /**
50
+ * Is `name` a Node built-in module? Resolved from the statically-imported
51
+ * `isBuiltin`, so it works on Node and on ahead-of-time-compiled binaries
52
+ * (Perry), where ambient `require('module')` would lack `isBuiltin`. Returns
53
+ * false in browsers, where the bare `module` import is stubbed away.
54
+ *
55
+ * Single source of truth for "is this a Node builtin?" probes across socket-lib
56
+ * (used by the smol-binding loaders to gate their `node:smol-*` loads).
57
+ */
7
58
  export declare function isNodeBuiltin(name: string): boolean;
59
+ /**
60
+ * Load a built-in module by *computed* specifier through the bound `require`
61
+ * (see getRequire). The specifier is a parameter — never a literal at the call
62
+ * site — so browser bundlers neither walk nor bundle it. Returns undefined
63
+ * where no `require` can be bound.
64
+ *
65
+ * Builtins / bare packages only (dir-independent); for a relative specifier use
66
+ * `requireFrom`. Used by `getNodeModule` for `node:module`, and by the
67
+ * smol-binding loaders for the optional `node:smol-*` native bindings (gated
68
+ * behind `isNodeBuiltin`, true only on socket-btm's smol Node binary).
69
+ */
70
+ export declare function requireBuiltin(specifier: string): unknown;
71
+ /**
72
+ * Load a module by specifier from a CALLER-supplied base (its
73
+ * `import.meta.url`). Use this for RELATIVE specifiers (`./x`, `../y`), whose
74
+ * resolution depends on the caller's directory — `requireBuiltin` binds to this
75
+ * file and would resolve them from `src/node/`. Not cached: the binding is
76
+ * per-caller. Returns undefined where no `require` can be bound.
77
+ */
78
+ export declare function requireFrom(fromUrl: string, specifier: string): unknown;
@@ -2,30 +2,115 @@
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_constants_runtime = require('../constants/runtime.js');
5
+ let module$1 = require("module");
5
6
 
6
7
  //#region src/node/module.ts
8
+ /**
9
+ * @file Accessors for `node:module` that work across runtimes. Ambient
10
+ * `require` is bound in CommonJS but unbound in ESM and inside
11
+ * ahead-of-time-compiled package modules (e.g. Perry), where reading it
12
+ * throws. And Perry's `require('module')` value omits `isBuiltin`. So instead
13
+ * of the ambient `require('module')` lazy-loader, `isBuiltin`/`createRequire`
14
+ * are imported as named values from the bare `module` specifier — which
15
+ * resolves on Node and Perry, and which browser bundlers can stub via
16
+ * resolve.fallback (a `node:` prefix would throw UnhandledSchemeError
17
+ * there).
18
+ * `require` is DIRECTORY-SPECIFIC: `createRequire(base)` resolves relative
19
+ * specifiers (`./x`, `../y`) from `base`'s directory. For builtins and bare
20
+ * packages that's irrelevant (they resolve the same anywhere), so the cached
21
+ * `getRequire` / `requireBuiltin` bind to THIS file. A RELATIVE specifier
22
+ * must resolve from the CALLER's directory, so use `requireFrom` with the
23
+ * caller's `import.meta.url` — binding such a load to this file would resolve
24
+ * it against `src/node/` instead. Bundled, every module collapses to one base
25
+ * and either works; unbundled (e.g. AOT-compiled from source), each module
26
+ * sits at its own nested path and the base matters.
27
+ */
7
28
  let cachedModule;
8
- function getNodeModule() {
29
+ let cachedRequire;
30
+ /**
31
+ * Bind a working `require`. Ambient `require` exists in CommonJS; in ESM and
32
+ * ahead-of-time-compiled package modules it is unbound (reading it throws or
33
+ * yields undefined), so fall back to `createRequire`. Returns undefined off
34
+ * Node and in browsers, where neither is available.
35
+ *
36
+ * `fromUrl` sets the resolution base — pass a caller's `import.meta.url` to
37
+ * resolve that caller's RELATIVE specifiers. When omitted, the base is this
38
+ * file, which is correct only for builtins / bare packages (dir-independent).
39
+ * With `fromUrl` the ambient `require` is skipped: it is bound to THIS file, so
40
+ * it would resolve a relative specifier from the wrong directory.
41
+ */
42
+ function bindRequire(fromUrl) {
9
43
  if (!require_constants_runtime.IS_NODE) return;
10
- return cachedModule ??= /*@__PURE__*/ require("node:module");
44
+ if (!fromUrl && typeof require === "function") return require;
45
+ if (typeof module$1.createRequire === "function") try {
46
+ return (0, module$1.createRequire)(fromUrl ?? require("url").pathToFileURL(__filename).href);
47
+ } catch {
48
+ return;
49
+ }
50
+ }
51
+ /**
52
+ * Returns `node:module` (or undefined off Node), loaded through the bound
53
+ * `require`. Cached across calls.
54
+ */
55
+ function getNodeModule() {
56
+ return cachedModule ??= requireBuiltin("module");
11
57
  }
12
58
  /**
13
- * Lazy + cached reference to `node:module`'s `isBuiltin(name)`. First call
14
- * resolves the binding; subsequent calls dispatch through the cached function
15
- * reference. Safe to detach — `isBuiltin` is `this`-free.
59
+ * Returns a working `require` bound to THIS file, binding one on first call
60
+ * (see bindRequire). Cached across calls; undefined off Node / in browsers.
16
61
  *
17
- * Returns `false` in browser / non-CJS environments where `require` is
18
- * undefined no `node:` modules are built-in there.
62
+ * For builtins and bare packages only the resolution base is this file, so a
63
+ * relative specifier would resolve from `src/node/`. Use `requireFrom` for
64
+ * relative loads.
65
+ */
66
+ function getRequire() {
67
+ if (cachedRequire === void 0) cachedRequire = bindRequire();
68
+ return cachedRequire;
69
+ }
70
+ /**
71
+ * Is `name` a Node built-in module? Resolved from the statically-imported
72
+ * `isBuiltin`, so it works on Node and on ahead-of-time-compiled binaries
73
+ * (Perry), where ambient `require('module')` would lack `isBuiltin`. Returns
74
+ * false in browsers, where the bare `module` import is stubbed away.
19
75
  *
20
76
  * Single source of truth for "is this a Node builtin?" probes across socket-lib
21
- * (used by the smol-binding loaders to gate `require('node:smol-*')`).
77
+ * (used by the smol-binding loaders to gate their `node:smol-*` loads).
22
78
  */
23
- let cachedIsBuiltin;
24
79
  function isNodeBuiltin(name) {
25
- if (!require_constants_runtime.IS_NODE) return false;
26
- return (cachedIsBuiltin ??= getNodeModule().isBuiltin)(name);
80
+ if (!require_constants_runtime.IS_NODE || typeof module$1.isBuiltin !== "function") return false;
81
+ return (0, module$1.isBuiltin)(name);
82
+ }
83
+ /**
84
+ * Load a built-in module by *computed* specifier through the bound `require`
85
+ * (see getRequire). The specifier is a parameter — never a literal at the call
86
+ * site — so browser bundlers neither walk nor bundle it. Returns undefined
87
+ * where no `require` can be bound.
88
+ *
89
+ * Builtins / bare packages only (dir-independent); for a relative specifier use
90
+ * `requireFrom`. Used by `getNodeModule` for `node:module`, and by the
91
+ * smol-binding loaders for the optional `node:smol-*` native bindings (gated
92
+ * behind `isNodeBuiltin`, true only on socket-btm's smol Node binary).
93
+ */
94
+ function requireBuiltin(specifier) {
95
+ const req = getRequire();
96
+ if (req) return req(specifier);
97
+ }
98
+ /**
99
+ * Load a module by specifier from a CALLER-supplied base (its
100
+ * `import.meta.url`). Use this for RELATIVE specifiers (`./x`, `../y`), whose
101
+ * resolution depends on the caller's directory — `requireBuiltin` binds to this
102
+ * file and would resolve them from `src/node/`. Not cached: the binding is
103
+ * per-caller. Returns undefined where no `require` can be bound.
104
+ */
105
+ function requireFrom(fromUrl, specifier) {
106
+ const req = bindRequire(fromUrl);
107
+ if (req) return req(specifier);
27
108
  }
28
109
 
29
110
  //#endregion
111
+ exports.bindRequire = bindRequire;
30
112
  exports.getNodeModule = getNodeModule;
31
- exports.isNodeBuiltin = isNodeBuiltin;
113
+ exports.getRequire = getRequire;
114
+ exports.isNodeBuiltin = isNodeBuiltin;
115
+ exports.requireBuiltin = requireBuiltin;
116
+ exports.requireFrom = requireFrom;
package/dist/node/os.d.ts CHANGED
@@ -1,6 +1,14 @@
1
1
  /**
2
- * @file Lazy-loader for `node:os`. See `node/fs.ts` for the design rationale
3
- * shared across all `node/*.ts` lazy-loaders.
2
+ * @file Early-snapshot accessor for `node:os`. See `node/fs.ts` for the shared
3
+ * rationale: the `require` runs at module load behind the runtime `IS_NODE`
4
+ * guard (false in browsers → never executes there), giving a load-time
5
+ * snapshot in Node while staying browser-safe. `getNodeOs()` returns the
6
+ * module object (late method lookup, spy-able); the frozen `os<Method>`
7
+ * snapshots below are the tamper-proof hot-path twin.
4
8
  */
5
9
  import type * as NodeOs from 'node:os';
6
10
  export declare function getNodeOs(): typeof NodeOs;
11
+ export declare const osArch: any;
12
+ export declare const osHomedir: any;
13
+ export declare const osPlatform: any;
14
+ export declare const osTmpdir: any;