@socketsecurity/lib 5.26.1 → 5.27.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 (46) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/constants/socket.js +1 -1
  3. package/dist/crypto.js +3 -10
  4. package/dist/external/adm-zip.js +2 -2
  5. package/dist/external/tar-fs.js +2 -2
  6. package/dist/fs.js +31 -45
  7. package/dist/node/async-hooks.d.ts +6 -0
  8. package/dist/node/async-hooks.js +34 -0
  9. package/dist/node/child-process.d.ts +11 -0
  10. package/dist/node/child-process.js +34 -0
  11. package/dist/node/crypto.d.ts +6 -0
  12. package/dist/node/crypto.js +34 -0
  13. package/dist/node/events.d.ts +6 -0
  14. package/dist/node/events.js +34 -0
  15. package/dist/node/fs-promises.d.ts +6 -0
  16. package/dist/node/fs-promises.js +34 -0
  17. package/dist/node/fs.d.ts +14 -0
  18. package/dist/node/fs.js +34 -0
  19. package/dist/node/http.d.ts +6 -0
  20. package/dist/node/http.js +34 -0
  21. package/dist/node/https.d.ts +6 -0
  22. package/dist/node/https.js +34 -0
  23. package/dist/node/os.d.ts +6 -0
  24. package/dist/node/os.js +34 -0
  25. package/dist/node/path.d.ts +6 -0
  26. package/dist/node/path.js +34 -0
  27. package/dist/node/timers-promises.d.ts +6 -0
  28. package/dist/node/timers-promises.js +34 -0
  29. package/dist/node/url.d.ts +6 -0
  30. package/dist/node/url.js +34 -0
  31. package/dist/node/util.d.ts +6 -0
  32. package/dist/node/util.js +34 -0
  33. package/dist/primordials.d.ts +76 -2
  34. package/dist/primordials.js +294 -23
  35. package/dist/sea/util.d.ts +43 -0
  36. package/dist/{sea.js → sea/util.js} +7 -7
  37. package/dist/smol/primordial.d.ts +80 -0
  38. package/dist/smol/primordial.js +46 -0
  39. package/dist/smol/util.d.ts +87 -0
  40. package/dist/smol/util.js +59 -0
  41. package/dist/smol/versions.d.ts +46 -0
  42. package/dist/smol/versions.js +46 -0
  43. package/dist/spawn.js +13 -28
  44. package/dist/versions.js +27 -22
  45. package/package.json +79 -9
  46. package/dist/sea.d.ts +0 -30
package/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.27.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.27.0) - 2026-05-04
9
+
10
+ ### Added
11
+
12
+ - **45 new `primordials` exports** rounding out the surface to 296 total:
13
+ - `BigIntCtor`
14
+ - Math: 24 methods (Acos, Atan2, Hypot, Pow, etc.) + 8 constants (E, PI, SQRT2, etc.); `MathF16round` typed `| undefined` for ES2025
15
+ - Number constants: `EPSILON`, `MAX_SAFE_INTEGER`, `MAX_VALUE`, `MIN_SAFE_INTEGER`, `MIN_VALUE`, `NEGATIVE_INFINITY`, `POSITIVE_INFINITY`
16
+ - Symbol: 10 well-knowns (`HasInstance`, `KeyFor`, `Match`, `Species`, etc.); `SymbolAsyncDispose` / `SymbolDispose` typed `| undefined` for ES2024; prototype helpers (`Description`, `ToString`, `ValueOf`)
17
+ - Function: `FunctionPrototypeToString`
18
+ - Array (ES2023 Change Array By Copy): `ArrayPrototypeToSpliced`, `ArrayPrototypeWith`
19
+ - Globals: `InfinityValue`, `NaNValue`, `globalThisRef`
20
+ - Object (annex B): `ObjectPrototype{Define,Lookup}{Getter,Setter}`
21
+ - Error (V8 stack-trace API, `| undefined`): `ErrorCaptureStackTrace`, `ErrorPrepareStackTrace`, `ErrorStackTraceLimit` (function-shaped, reads live value)
22
+
23
+ - **`smol/*` (new exports)** — feature-detect + lazy-loaders for socket-btm's smol Node binary:
24
+ - `smol/detect` — `isSmol()`: memoized boolean, mirrors `isSeaBinary()`
25
+ - `smol/util` — `getSmolUtil()`: native `uncurryThis` / `applyBind` (~2x faster), or `undefined`
26
+ - `smol/primordial` — `getSmolPrimordial()`: V8 Fast API typed `Math.*` / `Number.is*` (~30-50% faster on hot loops), or `undefined`
27
+ - `primordials` transparently routes through these on smol; **zero call-site changes**, identical behavior on stock Node, smol, browsers, Deno, Bun
28
+
29
+ - **`node/*` (new exports)** — per-builtin lazy-loaders for `node:*` modules. Each is `/*@__NO_SIDE_EFFECTS__*/`-marked so bundlers tree-shake the `require()` when unused:
30
+ - `node/fs` (`getNodeFs`), `node/path` (`getNodePath`), `node/crypto` (`getNodeCrypto`), `node/http` (`getNodeHttp`), `node/https` (`getNodeHttps`), `node/os` (`getNodeOs`), `node/util` (`getNodeUtil`), `node/url` (`getNodeUrl`), `node/events` (`getNodeEvents`)
31
+ - `node/child-process` (`getNodeChildProcess`), `node/async-hooks` (`getNodeAsyncHooks`), `node/fs-promises` (`getNodeFsPromises`), `node/timers-promises` (`getNodeTimersPromises`)
32
+ - Replaces ~30 ad-hoc copies of the same lazy-loader boilerplate previously scattered across `http-request.ts`, `spawn.ts`, `fs.ts`, `crypto.ts`, etc.
33
+
8
34
  ## [5.26.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.26.1) - 2026-05-01
9
35
 
10
36
  ### Added
@@ -77,7 +77,7 @@ const SOCKET_FIREWALL_APP_NAME = "sfw";
77
77
  const SOCKET_REGISTRY_APP_NAME = "registry";
78
78
  const SOCKET_APP_PREFIX = "_";
79
79
  const SOCKET_LIB_NAME = "@socketsecurity/lib";
80
- const SOCKET_LIB_VERSION = "5.26.1";
80
+ const SOCKET_LIB_VERSION = "5.27.0";
81
81
  const SOCKET_LIB_URL = "https://github.com/SocketDev/socket-lib";
82
82
  const SOCKET_LIB_USER_AGENT = `socketsecurity-lib/${SOCKET_LIB_VERSION} (${SOCKET_LIB_URL})`;
83
83
  const SOCKET_IPC_HANDSHAKE = "SOCKET_IPC_HANDSHAKE";
package/dist/crypto.js CHANGED
@@ -24,20 +24,13 @@ __export(crypto_exports, {
24
24
  hash: () => hash
25
25
  });
26
26
  module.exports = __toCommonJS(crypto_exports);
27
- let _crypto;
27
+ var import_crypto = require("./node/crypto");
28
28
  let _hash;
29
29
  let _hashProbed = false;
30
30
  // @__NO_SIDE_EFFECTS__
31
- function getCrypto() {
32
- if (_crypto === void 0) {
33
- _crypto = require("node:crypto");
34
- }
35
- return _crypto;
36
- }
37
- // @__NO_SIDE_EFFECTS__
38
31
  function getNativeHash() {
39
32
  if (!_hashProbed) {
40
- const fn = (/* @__PURE__ */ getCrypto()).hash;
33
+ const fn = (0, import_crypto.getNodeCrypto)().hash;
41
34
  if (typeof fn === "function") {
42
35
  _hash = fn;
43
36
  }
@@ -51,7 +44,7 @@ function hash(algorithm, data, outputEncoding) {
51
44
  if (native !== void 0) {
52
45
  return native(algorithm, data, outputEncoding);
53
46
  }
54
- return (/* @__PURE__ */ getCrypto()).createHash(algorithm).update(data).digest(outputEncoding);
47
+ return (0, import_crypto.getNodeCrypto)().createHash(algorithm).update(data).digest(outputEncoding);
55
48
  }
56
49
  // Annotate the CommonJS export names for ESM import in node:
57
50
  0 && (module.exports = {
@@ -1,4 +1,4 @@
1
- const { ArrayCtor: _p_ArrayCtor, ArrayFrom: _p_ArrayFrom, ArrayIsArray: _p_ArrayIsArray, ArrayPrototypeFindLast: _p_ArrayPrototypeFindLast, BufferAlloc: _p_BufferAlloc, BufferFrom: _p_BufferFrom, BufferIsBuffer: _p_BufferIsBuffer, DateCtor: _p_DateCtor, ErrorCtor: _p_ErrorCtor, JSONStringify: _p_JSONStringify, MathMax: _p_MathMax, MathRandom: _p_MathRandom, ObjectAssign: _p_ObjectAssign, ObjectCreate: _p_ObjectCreate, ObjectKeys: _p_ObjectKeys, PromiseCtor: _p_PromiseCtor, SetCtor: _p_SetCtor, TypeErrorCtor: _p_TypeErrorCtor, Uint32ArrayCtor: _p_Uint32ArrayCtor } = require('../primordials.js')
1
+ const { ArrayCtor: _p_ArrayCtor, ArrayFrom: _p_ArrayFrom, ArrayIsArray: _p_ArrayIsArray, ArrayPrototypeFindLast: _p_ArrayPrototypeFindLast, BufferAlloc: _p_BufferAlloc, BufferFrom: _p_BufferFrom, BufferIsBuffer: _p_BufferIsBuffer, DateCtor: _p_DateCtor, ErrorCtor: _p_ErrorCtor, JSONStringify: _p_JSONStringify, MathImul: _p_MathImul, MathMax: _p_MathMax, MathRandom: _p_MathRandom, ObjectAssign: _p_ObjectAssign, ObjectCreate: _p_ObjectCreate, ObjectKeys: _p_ObjectKeys, PromiseCtor: _p_PromiseCtor, SetCtor: _p_SetCtor, TypeErrorCtor: _p_TypeErrorCtor, Uint32ArrayCtor: _p_Uint32ArrayCtor } = require('../primordials.js')
2
2
  "use strict";
3
3
  /**
4
4
  * Bundled from adm-zip
@@ -1097,7 +1097,7 @@ var require_zipcrypto = __commonJS({
1097
1097
  }
1098
1098
  return crc >>> 0;
1099
1099
  });
1100
- var uMul = /* @__PURE__ */ __name((a, b) => Math.imul(a, b) >>> 0, "uMul");
1100
+ var uMul = /* @__PURE__ */ __name((a, b) => _p_MathImul(a, b) >>> 0, "uMul");
1101
1101
  var crc32update = /* @__PURE__ */ __name((pCrc32, bval) => {
1102
1102
  return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
1103
1103
  }, "crc32update");
@@ -1,4 +1,4 @@
1
- const { ArrayCtor: _p_ArrayCtor, ArrayIsArray: _p_ArrayIsArray, BufferAlloc: _p_BufferAlloc, BufferAllocUnsafe: _p_BufferAllocUnsafe, BufferAllocUnsafeSlow: _p_BufferAllocUnsafeSlow, BufferByteLength: _p_BufferByteLength, BufferConcat: _p_BufferConcat, BufferFrom: _p_BufferFrom, BufferIsBuffer: _p_BufferIsBuffer, BufferIsEncoding: _p_BufferIsEncoding, DateCtor: _p_DateCtor, ErrorCtor: _p_ErrorCtor, MathFloor: _p_MathFloor, MathMax: _p_MathMax, MathMin: _p_MathMin, MathPow: _p_MathPow, ObjectDefineProperty: _p_ObjectDefineProperty, ObjectKeys: _p_ObjectKeys, PromiseCtor: _p_PromiseCtor, PromiseResolve: _p_PromiseResolve, StringFromCharCode: _p_StringFromCharCode, StringFromCodePoint: _p_StringFromCodePoint, StringPrototypeStartsWith: _p_StringPrototypeStartsWith, TypeErrorCtor: _p_TypeErrorCtor } = require('../primordials.js')
1
+ const { ArrayCtor: _p_ArrayCtor, ArrayIsArray: _p_ArrayIsArray, BufferAlloc: _p_BufferAlloc, BufferAllocUnsafe: _p_BufferAllocUnsafe, BufferAllocUnsafeSlow: _p_BufferAllocUnsafeSlow, BufferByteLength: _p_BufferByteLength, BufferConcat: _p_BufferConcat, BufferFrom: _p_BufferFrom, BufferIsBuffer: _p_BufferIsBuffer, BufferIsEncoding: _p_BufferIsEncoding, DateCtor: _p_DateCtor, ErrorCtor: _p_ErrorCtor, MathFloor: _p_MathFloor, MathLog: _p_MathLog, MathMax: _p_MathMax, MathMin: _p_MathMin, MathPow: _p_MathPow, ObjectDefineProperty: _p_ObjectDefineProperty, ObjectKeys: _p_ObjectKeys, PromiseCtor: _p_PromiseCtor, PromiseResolve: _p_PromiseResolve, StringFromCharCode: _p_StringFromCharCode, StringFromCodePoint: _p_StringFromCodePoint, StringPrototypeStartsWith: _p_StringPrototypeStartsWith, TypeErrorCtor: _p_TypeErrorCtor } = require('../primordials.js')
2
2
  "use strict";
3
3
  /**
4
4
  * Bundled from tar-fs
@@ -1860,7 +1860,7 @@ var require_headers = __commonJS({
1860
1860
  __name(decodeStr, "decodeStr");
1861
1861
  function addLength(str) {
1862
1862
  const len = b4a.byteLength(str);
1863
- let digits = _p_MathFloor(Math.log(len) / Math.log(10)) + 1;
1863
+ let digits = _p_MathFloor(_p_MathLog(len) / _p_MathLog(10)) + 1;
1864
1864
  if (len + digits >= _p_MathPow(10, digits)) digits++;
1865
1865
  return len + digits + str;
1866
1866
  }
package/dist/fs.js CHANGED
@@ -67,6 +67,8 @@ var import_process = require("./constants/process");
67
67
  var import_errors = require("./errors");
68
68
  var import_globs = require("./globs");
69
69
  var import_parse = require("./json/parse");
70
+ var import_fs = require("./node/fs");
71
+ var import_path = require("./node/path");
70
72
  var import_objects = require("./objects");
71
73
  var import_normalize = require("./paths/normalize");
72
74
  var import_rewire = require("./paths/rewire");
@@ -85,11 +87,9 @@ const defaultRemoveOptions = (0, import_objects.objectFreeze)({
85
87
  });
86
88
  let _del;
87
89
  let _cachedAllowedDirs;
88
- let _fs;
89
- let _path;
90
90
  function getAllowedDirectories() {
91
91
  if (_cachedAllowedDirs === void 0) {
92
- const path = /* @__PURE__ */ getPath();
92
+ const path = (0, import_path.getNodePath)();
93
93
  _cachedAllowedDirs = [
94
94
  path.resolve((0, import_socket.getOsTmpDir)()),
95
95
  path.resolve((0, import_socket.getSocketCacacheDir)()),
@@ -106,27 +106,13 @@ function getDel() {
106
106
  return _del;
107
107
  }
108
108
  // @__NO_SIDE_EFFECTS__
109
- function getFs() {
110
- if (_fs === void 0) {
111
- _fs = require("node:fs");
112
- }
113
- return _fs;
114
- }
115
- // @__NO_SIDE_EFFECTS__
116
- function getPath() {
117
- if (_path === void 0) {
118
- _path = require("node:path");
119
- }
120
- return _path;
121
- }
122
- // @__NO_SIDE_EFFECTS__
123
109
  function innerReadDirNames(dirents, dirname, options) {
124
110
  const {
125
111
  ignore,
126
112
  includeEmpty = true,
127
113
  sort = true
128
114
  } = { __proto__: null, ...options };
129
- const path = /* @__PURE__ */ getPath();
115
+ const path = (0, import_path.getNodePath)();
130
116
  const names = dirents.filter(
131
117
  (d) => d.isDirectory() && (includeEmpty || !/* @__PURE__ */ isDirEmptySync(path.join(dirname || d.parentPath, d.name), {
132
118
  ignore
@@ -156,8 +142,8 @@ async function findUp(name, options) {
156
142
  if (onlyFiles) {
157
143
  onlyDirectories = false;
158
144
  }
159
- const fs = /* @__PURE__ */ getFs();
160
- const path = /* @__PURE__ */ getPath();
145
+ const fs = (0, import_fs.getNodeFs)();
146
+ const path = (0, import_path.getNodePath)();
161
147
  let dir = path.resolve(cwd);
162
148
  const { root } = path.parse(dir);
163
149
  const names = (0, import_arrays.isArray)(name) ? name : [name];
@@ -201,8 +187,8 @@ function findUpSync(name, options) {
201
187
  if (onlyFiles) {
202
188
  onlyDirectories = false;
203
189
  }
204
- const fs = /* @__PURE__ */ getFs();
205
- const path = /* @__PURE__ */ getPath();
190
+ const fs = (0, import_fs.getNodeFs)();
191
+ const path = (0, import_path.getNodePath)();
206
192
  let dir = path.resolve(cwd);
207
193
  const { root } = path.parse(dir);
208
194
  const stopDir = stopAt ? path.resolve(stopAt) : void 0;
@@ -257,7 +243,7 @@ function isDirEmptySync(dirname, options) {
257
243
  __proto__: null,
258
244
  ...options
259
245
  };
260
- const fs = /* @__PURE__ */ getFs();
246
+ const fs = (0, import_fs.getNodeFs)();
261
247
  try {
262
248
  const files = fs.readdirSync(dirname);
263
249
  const { length } = files;
@@ -288,7 +274,7 @@ function isDirSync(filepath) {
288
274
  }
289
275
  // @__NO_SIDE_EFFECTS__
290
276
  function isSymLinkSync(filepath) {
291
- const fs = /* @__PURE__ */ getFs();
277
+ const fs = (0, import_fs.getNodeFs)();
292
278
  try {
293
279
  return fs.lstatSync(filepath).isSymbolicLink();
294
280
  } catch {
@@ -368,7 +354,7 @@ function normalizeEncodingSlow(enc) {
368
354
  }
369
355
  // @__NO_SIDE_EFFECTS__
370
356
  async function readDirNames(dirname, options) {
371
- const fs = /* @__PURE__ */ getFs();
357
+ const fs = (0, import_fs.getNodeFs)();
372
358
  try {
373
359
  return /* @__PURE__ */ innerReadDirNames(
374
360
  await fs.promises.readdir(dirname, {
@@ -385,7 +371,7 @@ async function readDirNames(dirname, options) {
385
371
  }
386
372
  // @__NO_SIDE_EFFECTS__
387
373
  function readDirNamesSync(dirname, options) {
388
- const fs = /* @__PURE__ */ getFs();
374
+ const fs = (0, import_fs.getNodeFs)();
389
375
  try {
390
376
  return /* @__PURE__ */ innerReadDirNames(
391
377
  fs.readdirSync(dirname, {
@@ -403,7 +389,7 @@ function readDirNamesSync(dirname, options) {
403
389
  // @__NO_SIDE_EFFECTS__
404
390
  async function readFileBinary(filepath, options) {
405
391
  const opts = typeof options === "string" ? { encoding: options } : options;
406
- const fs = /* @__PURE__ */ getFs();
392
+ const fs = (0, import_fs.getNodeFs)();
407
393
  return await fs.promises.readFile(filepath, {
408
394
  signal: abortSignal,
409
395
  ...opts,
@@ -413,7 +399,7 @@ async function readFileBinary(filepath, options) {
413
399
  // @__NO_SIDE_EFFECTS__
414
400
  function readFileBinarySync(filepath, options) {
415
401
  const opts = typeof options === "string" ? { encoding: options } : options;
416
- const fs = /* @__PURE__ */ getFs();
402
+ const fs = (0, import_fs.getNodeFs)();
417
403
  return fs.readFileSync(filepath, {
418
404
  ...opts,
419
405
  encoding: null
@@ -422,7 +408,7 @@ function readFileBinarySync(filepath, options) {
422
408
  // @__NO_SIDE_EFFECTS__
423
409
  async function readFileUtf8(filepath, options) {
424
410
  const opts = typeof options === "string" ? { encoding: options } : options;
425
- const fs = /* @__PURE__ */ getFs();
411
+ const fs = (0, import_fs.getNodeFs)();
426
412
  return await fs.promises.readFile(filepath, {
427
413
  signal: abortSignal,
428
414
  ...opts,
@@ -432,7 +418,7 @@ async function readFileUtf8(filepath, options) {
432
418
  // @__NO_SIDE_EFFECTS__
433
419
  function readFileUtf8Sync(filepath, options) {
434
420
  const opts = typeof options === "string" ? { encoding: options } : options;
435
- const fs = /* @__PURE__ */ getFs();
421
+ const fs = (0, import_fs.getNodeFs)();
436
422
  return fs.readFileSync(filepath, {
437
423
  ...opts,
438
424
  encoding: "utf8"
@@ -446,7 +432,7 @@ async function readJson(filepath, options) {
446
432
  ...opts
447
433
  };
448
434
  const shouldThrow = throws === void 0 || !!throws;
449
- const fs = /* @__PURE__ */ getFs();
435
+ const fs = (0, import_fs.getNodeFs)();
450
436
  let content = "";
451
437
  try {
452
438
  content = await fs.promises.readFile(filepath, {
@@ -489,7 +475,7 @@ function readJsonSync(filepath, options) {
489
475
  ...opts
490
476
  };
491
477
  const shouldThrow = throws === void 0 || !!throws;
492
- const fs = /* @__PURE__ */ getFs();
478
+ const fs = (0, import_fs.getNodeFs)();
493
479
  let content = "";
494
480
  try {
495
481
  content = fs.readFileSync(filepath, {
@@ -529,7 +515,7 @@ async function safeDelete(filepath, options) {
529
515
  const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_normalize.pathLikeToString) : [(0, import_normalize.pathLikeToString)(filepath)];
530
516
  let shouldForce = opts.force !== false;
531
517
  if (!shouldForce && patterns.length > 0) {
532
- const path = /* @__PURE__ */ getPath();
518
+ const path = (0, import_path.getNodePath)();
533
519
  const allowedDirs = getAllowedDirectories();
534
520
  const allInAllowedDirs = patterns.every((pattern) => {
535
521
  const resolvedPath = path.resolve(pattern);
@@ -571,7 +557,7 @@ function safeDeleteSync(filepath, options) {
571
557
  const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_normalize.pathLikeToString) : [(0, import_normalize.pathLikeToString)(filepath)];
572
558
  let shouldForce = opts.force !== false;
573
559
  if (!shouldForce && patterns.length > 0) {
574
- const path = /* @__PURE__ */ getPath();
560
+ const path = (0, import_path.getNodePath)();
575
561
  const allowedDirs = getAllowedDirectories();
576
562
  const allInAllowedDirs = patterns.every((pattern) => {
577
563
  const resolvedPath = path.resolve(pattern);
@@ -621,7 +607,7 @@ function safeDeleteSync(filepath, options) {
621
607
  }
622
608
  }
623
609
  async function safeMkdir(path, options) {
624
- const fs = /* @__PURE__ */ getFs();
610
+ const fs = (0, import_fs.getNodeFs)();
625
611
  const opts = { __proto__: null, recursive: true, ...options };
626
612
  try {
627
613
  await fs.promises.mkdir(path, opts);
@@ -632,7 +618,7 @@ async function safeMkdir(path, options) {
632
618
  }
633
619
  }
634
620
  function safeMkdirSync(path, options) {
635
- const fs = /* @__PURE__ */ getFs();
621
+ const fs = (0, import_fs.getNodeFs)();
636
622
  const opts = { __proto__: null, recursive: true, ...options };
637
623
  try {
638
624
  fs.mkdirSync(path, opts);
@@ -649,7 +635,7 @@ async function safeReadFile(filepath, options) {
649
635
  const readOpts = { __proto__: null, ...rawReadOpts };
650
636
  const shouldReturnBuffer = readOpts.encoding === null;
651
637
  const encoding = shouldReturnBuffer ? null : /* @__PURE__ */ normalizeEncoding(readOpts.encoding);
652
- const fs = /* @__PURE__ */ getFs();
638
+ const fs = (0, import_fs.getNodeFs)();
653
639
  try {
654
640
  return await fs.promises.readFile(filepath, {
655
641
  __proto__: null,
@@ -674,7 +660,7 @@ function safeReadFileSync(filepath, options) {
674
660
  const readOpts = { __proto__: null, ...rawReadOpts };
675
661
  const shouldReturnBuffer = readOpts.encoding === null;
676
662
  const encoding = shouldReturnBuffer ? null : /* @__PURE__ */ normalizeEncoding(readOpts.encoding);
677
- const fs = /* @__PURE__ */ getFs();
663
+ const fs = (0, import_fs.getNodeFs)();
678
664
  try {
679
665
  return fs.readFileSync(filepath, {
680
666
  __proto__: null,
@@ -693,7 +679,7 @@ function safeReadFileSync(filepath, options) {
693
679
  }
694
680
  // @__NO_SIDE_EFFECTS__
695
681
  async function safeStats(filepath) {
696
- const fs = /* @__PURE__ */ getFs();
682
+ const fs = (0, import_fs.getNodeFs)();
697
683
  try {
698
684
  return await fs.promises.stat(filepath);
699
685
  } catch {
@@ -702,7 +688,7 @@ async function safeStats(filepath) {
702
688
  }
703
689
  // @__NO_SIDE_EFFECTS__
704
690
  function safeStatsSync(filepath) {
705
- const fs = /* @__PURE__ */ getFs();
691
+ const fs = (0, import_fs.getNodeFs)();
706
692
  try {
707
693
  return fs.statSync(filepath, {
708
694
  __proto__: null,
@@ -714,8 +700,8 @@ function safeStatsSync(filepath) {
714
700
  }
715
701
  // @__NO_SIDE_EFFECTS__
716
702
  function uniqueSync(filepath) {
717
- const fs = /* @__PURE__ */ getFs();
718
- const path = /* @__PURE__ */ getPath();
703
+ const fs = (0, import_fs.getNodeFs)();
704
+ const path = (0, import_path.getNodePath)();
719
705
  const filepathStr = String(filepath);
720
706
  if (!fs.existsSync(filepathStr)) {
721
707
  return (0, import_normalize.normalizePath)(filepathStr);
@@ -733,7 +719,7 @@ function uniqueSync(filepath) {
733
719
  }
734
720
  // @__NO_SIDE_EFFECTS__
735
721
  function validateFiles(filepaths) {
736
- const fs = /* @__PURE__ */ getFs();
722
+ const fs = (0, import_fs.getNodeFs)();
737
723
  const validPaths = [];
738
724
  const invalidPaths = [];
739
725
  const { R_OK } = fs.constants;
@@ -753,7 +739,7 @@ async function writeJson(filepath, jsonContent, options) {
753
739
  __proto__: null,
754
740
  ...opts
755
741
  };
756
- const fs = /* @__PURE__ */ getFs();
742
+ const fs = (0, import_fs.getNodeFs)();
757
743
  const jsonString = /* @__PURE__ */ stringify(
758
744
  jsonContent,
759
745
  EOL || "\n",
@@ -773,7 +759,7 @@ function writeJsonSync(filepath, jsonContent, options) {
773
759
  __proto__: null,
774
760
  ...opts
775
761
  };
776
- const fs = /* @__PURE__ */ getFs();
762
+ const fs = (0, import_fs.getNodeFs)();
777
763
  const jsonString = /* @__PURE__ */ stringify(
778
764
  jsonContent,
779
765
  EOL || "\n",
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @fileoverview Lazy-loader for `node:async_hooks`. See `node/fs.ts`
3
+ * for the design rationale shared across all `node/*.ts` lazy-loaders.
4
+ */
5
+ import type * as NodeAsyncHooks from 'node:async_hooks';
6
+ export declare function getNodeAsyncHooks(): typeof NodeAsyncHooks;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var async_hooks_exports = {};
22
+ __export(async_hooks_exports, {
23
+ getNodeAsyncHooks: () => getNodeAsyncHooks
24
+ });
25
+ module.exports = __toCommonJS(async_hooks_exports);
26
+ let _asyncHooks;
27
+ // @__NO_SIDE_EFFECTS__
28
+ function getNodeAsyncHooks() {
29
+ return _asyncHooks ??= require("node:async_hooks");
30
+ }
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ getNodeAsyncHooks
34
+ });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @fileoverview Lazy-loader for `node:child_process`. See `node/fs.ts`
3
+ * for the design rationale shared across all `node/*.ts` lazy-loaders.
4
+ *
5
+ * Filename uses `child-process` (kebab-case) to match the rest of
6
+ * socket-lib's filename convention. The exported getter name is
7
+ * `getNodeChildProcess` (camelCase, prefixed with `Node` to match
8
+ * every other `node/*` lazy-loader).
9
+ */
10
+ import type * as NodeChildProcess from 'node:child_process';
11
+ export declare function getNodeChildProcess(): typeof NodeChildProcess;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var child_process_exports = {};
22
+ __export(child_process_exports, {
23
+ getNodeChildProcess: () => getNodeChildProcess
24
+ });
25
+ module.exports = __toCommonJS(child_process_exports);
26
+ let _childProcess;
27
+ // @__NO_SIDE_EFFECTS__
28
+ function getNodeChildProcess() {
29
+ return _childProcess ??= require("node:child_process");
30
+ }
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ getNodeChildProcess
34
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @fileoverview Lazy-loader for `node:crypto`. See `node/fs.ts` for
3
+ * the design rationale shared across all `node/*.ts` lazy-loaders.
4
+ */
5
+ import type * as NodeCrypto from 'node:crypto';
6
+ export declare function getNodeCrypto(): typeof NodeCrypto;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var crypto_exports = {};
22
+ __export(crypto_exports, {
23
+ getNodeCrypto: () => getNodeCrypto
24
+ });
25
+ module.exports = __toCommonJS(crypto_exports);
26
+ let _crypto;
27
+ // @__NO_SIDE_EFFECTS__
28
+ function getNodeCrypto() {
29
+ return _crypto ??= require("node:crypto");
30
+ }
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ getNodeCrypto
34
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @fileoverview Lazy-loader for `node:events`. See `node/fs.ts` for
3
+ * the design rationale shared across all `node/*.ts` lazy-loaders.
4
+ */
5
+ import type * as NodeEvents from 'node:events';
6
+ export declare function getNodeEvents(): typeof NodeEvents;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var events_exports = {};
22
+ __export(events_exports, {
23
+ getNodeEvents: () => getNodeEvents
24
+ });
25
+ module.exports = __toCommonJS(events_exports);
26
+ let _events;
27
+ // @__NO_SIDE_EFFECTS__
28
+ function getNodeEvents() {
29
+ return _events ??= require("node:events");
30
+ }
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ getNodeEvents
34
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @fileoverview Lazy-loader for `node:fs/promises`. See `node/fs.ts`
3
+ * for the design rationale shared across all `node/*.ts` lazy-loaders.
4
+ */
5
+ import type * as NodeFsPromises from 'node:fs/promises';
6
+ export declare function getNodeFsPromises(): typeof NodeFsPromises;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var fs_promises_exports = {};
22
+ __export(fs_promises_exports, {
23
+ getNodeFsPromises: () => getNodeFsPromises
24
+ });
25
+ module.exports = __toCommonJS(fs_promises_exports);
26
+ let _fsPromises;
27
+ // @__NO_SIDE_EFFECTS__
28
+ function getNodeFsPromises() {
29
+ return _fsPromises ??= require("node:fs/promises");
30
+ }
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ getNodeFsPromises
34
+ });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @fileoverview Lazy-loader for `node:fs`.
3
+ *
4
+ * Bundlers (Webpack/Rollup/esbuild) targeting browsers can't statically
5
+ * resolve `require('node:fs')` — but they CAN drop the call entirely
6
+ * if it's wrapped in a `/*@__NO_SIDE_EFFECTS__*\/`-marked function and
7
+ * never called. So we always go through `getFs()` instead of importing
8
+ * top-level.
9
+ *
10
+ * Cache slot is module-local: first call resolves the require, every
11
+ * subsequent call returns the cached reference.
12
+ */
13
+ import type * as NodeFs from 'node:fs';
14
+ export declare function getNodeFs(): typeof NodeFs;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var fs_exports = {};
22
+ __export(fs_exports, {
23
+ getNodeFs: () => getNodeFs
24
+ });
25
+ module.exports = __toCommonJS(fs_exports);
26
+ let _fs;
27
+ // @__NO_SIDE_EFFECTS__
28
+ function getNodeFs() {
29
+ return _fs ??= require("node:fs");
30
+ }
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ getNodeFs
34
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @fileoverview Lazy-loader for `node:http`. See `node/fs.ts` for
3
+ * the design rationale shared across all `node/*.ts` lazy-loaders.
4
+ */
5
+ import type * as NodeHttp from 'node:http';
6
+ export declare function getNodeHttp(): typeof NodeHttp;