@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.
- package/CHANGELOG.md +26 -0
- package/dist/constants/socket.js +1 -1
- package/dist/crypto.js +3 -10
- package/dist/external/adm-zip.js +2 -2
- package/dist/external/tar-fs.js +2 -2
- package/dist/fs.js +31 -45
- package/dist/node/async-hooks.d.ts +6 -0
- package/dist/node/async-hooks.js +34 -0
- package/dist/node/child-process.d.ts +11 -0
- package/dist/node/child-process.js +34 -0
- package/dist/node/crypto.d.ts +6 -0
- package/dist/node/crypto.js +34 -0
- package/dist/node/events.d.ts +6 -0
- package/dist/node/events.js +34 -0
- package/dist/node/fs-promises.d.ts +6 -0
- package/dist/node/fs-promises.js +34 -0
- package/dist/node/fs.d.ts +14 -0
- package/dist/node/fs.js +34 -0
- package/dist/node/http.d.ts +6 -0
- package/dist/node/http.js +34 -0
- package/dist/node/https.d.ts +6 -0
- package/dist/node/https.js +34 -0
- package/dist/node/os.d.ts +6 -0
- package/dist/node/os.js +34 -0
- package/dist/node/path.d.ts +6 -0
- package/dist/node/path.js +34 -0
- package/dist/node/timers-promises.d.ts +6 -0
- package/dist/node/timers-promises.js +34 -0
- package/dist/node/url.d.ts +6 -0
- package/dist/node/url.js +34 -0
- package/dist/node/util.d.ts +6 -0
- package/dist/node/util.js +34 -0
- package/dist/primordials.d.ts +76 -2
- package/dist/primordials.js +294 -23
- package/dist/sea/util.d.ts +43 -0
- package/dist/{sea.js → sea/util.js} +7 -7
- package/dist/smol/primordial.d.ts +80 -0
- package/dist/smol/primordial.js +46 -0
- package/dist/smol/util.d.ts +87 -0
- package/dist/smol/util.js +59 -0
- package/dist/smol/versions.d.ts +46 -0
- package/dist/smol/versions.js +46 -0
- package/dist/spawn.js +13 -28
- package/dist/versions.js +27 -22
- package/package.json +79 -9
- package/dist/sea.d.ts +0 -30
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Lazy-loader for socket-btm's `node:smol-primordial`
|
|
3
|
+
* binding.
|
|
4
|
+
*
|
|
5
|
+
* `node:smol-primordial` provides V8 Fast API typed implementations
|
|
6
|
+
* of Math.* and Number.is* primordials, registered with
|
|
7
|
+
* `CFunction::Make()` so TurboFan inlines them directly into JIT-
|
|
8
|
+
* compiled JS callers. Bypasses the FunctionCallbackInfo trampoline
|
|
9
|
+
* entirely — ~30-50% gain on hot loops where V8 doesn't already
|
|
10
|
+
* auto-inline.
|
|
11
|
+
*
|
|
12
|
+
* Returns `undefined` on stock Node + non-Node runtimes. Result is
|
|
13
|
+
* cached across calls.
|
|
14
|
+
*
|
|
15
|
+
* @internal — used by `src/primordials.ts` to resolve smol-aware
|
|
16
|
+
* Math.* / Number.is* fast paths. Most callers should use the
|
|
17
|
+
* standard `primordials` exports, which already route through this
|
|
18
|
+
* when smol is present.
|
|
19
|
+
*
|
|
20
|
+
* @see https://v8.dev/blog/v8-release-99 — V8 Fast API Calls overview
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Surface of `node:smol-primordial`. See socket-btm's
|
|
24
|
+
* additions/source-patched/lib/smol-primordial.js for the canonical
|
|
25
|
+
* shape.
|
|
26
|
+
*
|
|
27
|
+
* Each entry is registered as a `v8::CFunction` so V8 can inline the
|
|
28
|
+
* C++ implementation directly into JIT-compiled callers — eliminating
|
|
29
|
+
* the FunctionCallbackInfo allocation, the HandleScope, and the call-
|
|
30
|
+
* site trampoline. See the C++ binding file for which signatures
|
|
31
|
+
* get real wins (and which don't).
|
|
32
|
+
*/
|
|
33
|
+
export interface SmolPrimordialBinding {
|
|
34
|
+
arrayIsArray(v: unknown): v is unknown[];
|
|
35
|
+
dateNow(): number;
|
|
36
|
+
mathAbs(x: number): number;
|
|
37
|
+
mathAcos(x: number): number;
|
|
38
|
+
mathAcosh(x: number): number;
|
|
39
|
+
mathAsin(x: number): number;
|
|
40
|
+
mathAsinh(x: number): number;
|
|
41
|
+
mathAtan(x: number): number;
|
|
42
|
+
mathAtan2(a: number, b: number): number;
|
|
43
|
+
mathAtanh(x: number): number;
|
|
44
|
+
mathCbrt(x: number): number;
|
|
45
|
+
mathCeil(x: number): number;
|
|
46
|
+
mathClz32(v: number): number;
|
|
47
|
+
mathCos(x: number): number;
|
|
48
|
+
mathCosh(x: number): number;
|
|
49
|
+
mathExp(x: number): number;
|
|
50
|
+
mathExpm1(x: number): number;
|
|
51
|
+
mathFloor(x: number): number;
|
|
52
|
+
mathFround(x: number): number;
|
|
53
|
+
mathHypot(a: number, b: number): number;
|
|
54
|
+
mathImul(a: number, b: number): number;
|
|
55
|
+
mathLog(x: number): number;
|
|
56
|
+
mathLog1p(x: number): number;
|
|
57
|
+
mathLog2(x: number): number;
|
|
58
|
+
mathLog10(x: number): number;
|
|
59
|
+
mathPow(a: number, b: number): number;
|
|
60
|
+
mathRound(x: number): number;
|
|
61
|
+
mathSign(x: number): number;
|
|
62
|
+
mathSin(x: number): number;
|
|
63
|
+
mathSinh(x: number): number;
|
|
64
|
+
mathSqrt(x: number): number;
|
|
65
|
+
mathTan(x: number): number;
|
|
66
|
+
mathTanh(x: number): number;
|
|
67
|
+
mathTrunc(x: number): number;
|
|
68
|
+
numberIsFinite(v: unknown): boolean;
|
|
69
|
+
numberIsInteger(v: unknown): boolean;
|
|
70
|
+
numberIsNaN(v: unknown): boolean;
|
|
71
|
+
numberIsSafeInteger(v: unknown): boolean;
|
|
72
|
+
numberParseFloat(s: string): number;
|
|
73
|
+
numberParseInt10(s: string): number;
|
|
74
|
+
stringCharCodeAt(s: string, i: number): number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns `node:smol-primordial` when running on the smol Node
|
|
78
|
+
* binary, otherwise `undefined`. Result is cached across calls.
|
|
79
|
+
*/
|
|
80
|
+
export declare function getSmolPrimordial(): SmolPrimordialBinding | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 primordial_exports = {};
|
|
22
|
+
__export(primordial_exports, {
|
|
23
|
+
getSmolPrimordial: () => getSmolPrimordial
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(primordial_exports);
|
|
26
|
+
var import_util = require("./util");
|
|
27
|
+
let _smolPrimordial;
|
|
28
|
+
// @__NO_SIDE_EFFECTS__
|
|
29
|
+
function getSmolPrimordial() {
|
|
30
|
+
if (_smolPrimordial === void 0) {
|
|
31
|
+
if ((0, import_util.isSmol)()) {
|
|
32
|
+
try {
|
|
33
|
+
_smolPrimordial = require("node:smol-primordial");
|
|
34
|
+
} catch {
|
|
35
|
+
_smolPrimordial = null;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
_smolPrimordial = null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return _smolPrimordial ?? void 0;
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
getSmolPrimordial
|
|
46
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Smol detection + lazy-loader for `node:smol-util`.
|
|
3
|
+
*
|
|
4
|
+
* Two responsibilities:
|
|
5
|
+
*
|
|
6
|
+
* 1. `isSmol()` — memoized boolean detector for socket-btm's smol
|
|
7
|
+
* Node binary. Mirrors `isSeaBinary()` from `src/sea.ts`. Probes
|
|
8
|
+
* via `node:module.isBuiltin('node:smol-util')` since only the
|
|
9
|
+
* smol binary registers any `node:smol-*` builtins.
|
|
10
|
+
*
|
|
11
|
+
* 2. `getSmolUtil()` — lazy-loader for the `node:smol-util` binding,
|
|
12
|
+
* which provides native `uncurryThis` and `applyBind` (single
|
|
13
|
+
* V8 dispatch via `args.Data()` + `v8::Function::Call`, skipping
|
|
14
|
+
* the BoundFunction adapter + `Function.prototype.call` trampoline
|
|
15
|
+
* that the JS form `bind.bind(call)(fn)` hits twice per invocation).
|
|
16
|
+
* ~2x faster on hot uncurried-call sites.
|
|
17
|
+
*
|
|
18
|
+
* `getSmolUtil()` returns `undefined` on stock Node + non-Node
|
|
19
|
+
* runtimes. Result is cached across calls; the lazy-loader follows
|
|
20
|
+
* the same shape as `src/node/fs.ts` etc.
|
|
21
|
+
*
|
|
22
|
+
* @see https://github.com/SocketDev/socket-btm — socket-btm builds
|
|
23
|
+
* the smol binary that exposes the `node:smol-util` binding.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Detect if the current process is running on socket-btm's smol Node
|
|
27
|
+
* binary. Memoized on first call.
|
|
28
|
+
*
|
|
29
|
+
* Defensive across runtimes: returns `false` on stock Node, browsers
|
|
30
|
+
* (no `node:module`), Deno / Bun (different module resolution), and
|
|
31
|
+
* worker threads (each has its own builtin table).
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { isSmol } from '@socketsecurity/lib/smol/util'
|
|
36
|
+
*
|
|
37
|
+
* if (isSmol()) {
|
|
38
|
+
* // running on the smol binary; native fast paths available
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function isSmol(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Surface of `node:smol-util`. See socket-btm's
|
|
45
|
+
* additions/source-patched/lib/smol-util.js for the canonical shape.
|
|
46
|
+
*/
|
|
47
|
+
export interface SmolUtilBinding {
|
|
48
|
+
/**
|
|
49
|
+
* Native equivalent of `Function.prototype.bind.bind(apply)(fn)`.
|
|
50
|
+
*/
|
|
51
|
+
applyBind: <T, A extends readonly unknown[], R>(fn: (this: T, ...args: A) => R) => (self: T, args: A) => R;
|
|
52
|
+
/**
|
|
53
|
+
* Native equivalent of:
|
|
54
|
+
* `(self, args) => { try { return fn.apply(self, args) } catch {} }`.
|
|
55
|
+
* Returns a function that swallows synchronous throws and returns
|
|
56
|
+
* `undefined`. Avoids JS-level throw construction on the swallow
|
|
57
|
+
* path — useful for logger sinks, debug hooks, abort handlers, etc.
|
|
58
|
+
*/
|
|
59
|
+
applySafe: <T, A extends readonly unknown[], R>(fn: (this: T, ...args: A) => R) => (self: T, args: A) => R | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Native equivalent of:
|
|
62
|
+
* `(...newArgs) => fn.call(thisArg, ...presetArgs, ...newArgs)`.
|
|
63
|
+
* Same shape as `Function.prototype.bind` but with a single C++
|
|
64
|
+
* dispatch instead of going through V8's BoundFunction adapter.
|
|
65
|
+
* Useful where `bind` would be hot — captured callbacks fed to
|
|
66
|
+
* `setImmediate`/`setTimeout`/promise continuations.
|
|
67
|
+
*/
|
|
68
|
+
bindCall: <T, P extends readonly unknown[], A extends readonly unknown[], R>(fn: (this: T, ...args: [...P, ...A]) => R, thisArg: T, ...presetArgs: P) => (...newArgs: A) => R;
|
|
69
|
+
/**
|
|
70
|
+
* Native equivalent of `Function.prototype.bind.bind(call)(fn)`.
|
|
71
|
+
* Single C++ dispatch via `args.Data()` + `v8::Function::Call`.
|
|
72
|
+
*/
|
|
73
|
+
uncurryThis: <T, A extends readonly unknown[], R>(fn: (this: T, ...args: A) => R) => (self: T, ...args: A) => R;
|
|
74
|
+
/**
|
|
75
|
+
* Native equivalent of:
|
|
76
|
+
* `try { return new WeakRef(target) } catch { return undefined }`.
|
|
77
|
+
* Returns `undefined` for non-Object, non-Symbol inputs that would
|
|
78
|
+
* make the constructor throw. The Safe suffix follows the project's
|
|
79
|
+
* non-throwing-wrapper convention.
|
|
80
|
+
*/
|
|
81
|
+
weakRefSafe: <T extends object | symbol>(target: T) => WeakRef<T> | undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns `node:smol-util` when running on the smol Node binary,
|
|
85
|
+
* otherwise `undefined`. Result is cached across calls.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getSmolUtil(): SmolUtilBinding | undefined;
|
|
@@ -0,0 +1,59 @@
|
|
|
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 util_exports = {};
|
|
22
|
+
__export(util_exports, {
|
|
23
|
+
getSmolUtil: () => getSmolUtil,
|
|
24
|
+
isSmol: () => isSmol
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(util_exports);
|
|
27
|
+
let _isSmol;
|
|
28
|
+
function isSmol() {
|
|
29
|
+
if (_isSmol === void 0) {
|
|
30
|
+
try {
|
|
31
|
+
const mod = require("node:module");
|
|
32
|
+
_isSmol = typeof mod.isBuiltin === "function" && mod.isBuiltin("node:smol-util");
|
|
33
|
+
} catch {
|
|
34
|
+
_isSmol = false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return _isSmol ?? false;
|
|
38
|
+
}
|
|
39
|
+
let _smolUtil;
|
|
40
|
+
// @__NO_SIDE_EFFECTS__
|
|
41
|
+
function getSmolUtil() {
|
|
42
|
+
if (_smolUtil === void 0) {
|
|
43
|
+
if (isSmol()) {
|
|
44
|
+
try {
|
|
45
|
+
_smolUtil = require("node:smol-util");
|
|
46
|
+
} catch {
|
|
47
|
+
_smolUtil = null;
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
_smolUtil = null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return _smolUtil ?? void 0;
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
getSmolUtil,
|
|
58
|
+
isSmol
|
|
59
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Lazy-loader for socket-btm's `node:smol-versions`.
|
|
3
|
+
*
|
|
4
|
+
* `node:smol-versions` is the multi-ecosystem version helper exposed
|
|
5
|
+
* by socket-btm's smol Node binary. It supports npm/maven/pypi/nuget/
|
|
6
|
+
* gem version comparison + range satisfies with internal C++
|
|
7
|
+
* acceleration on the npm hot path.
|
|
8
|
+
*
|
|
9
|
+
* Returns `undefined` on stock Node + non-Node runtimes. Result is
|
|
10
|
+
* cached across calls.
|
|
11
|
+
*
|
|
12
|
+
* @internal — used by `src/versions.ts` to resolve smol-aware version
|
|
13
|
+
* ops. Most callers should use the standard `versions` exports,
|
|
14
|
+
* which already route through this when smol is present.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Surface of `node:smol-versions`. See socket-btm's
|
|
18
|
+
* additions/source-patched/lib/smol-versions.js for the canonical
|
|
19
|
+
* shape. Each entry takes an optional `ecosystem` (default `'npm'`)
|
|
20
|
+
* — pass it for non-npm versions; npm callers can omit.
|
|
21
|
+
*/
|
|
22
|
+
export interface SmolVersionsBinding {
|
|
23
|
+
compare(a: string, b: string, ecosystem?: string): -1 | 0 | 1;
|
|
24
|
+
eq(a: string, b: string, ecosystem?: string): boolean;
|
|
25
|
+
gt(a: string, b: string, ecosystem?: string): boolean;
|
|
26
|
+
gte(a: string, b: string, ecosystem?: string): boolean;
|
|
27
|
+
inc(version: string, release: 'major' | 'minor' | 'patch' | 'prerelease', ecosystem?: string, identifier?: string): string | undefined;
|
|
28
|
+
lt(a: string, b: string, ecosystem?: string): boolean;
|
|
29
|
+
lte(a: string, b: string, ecosystem?: string): boolean;
|
|
30
|
+
max(versions: readonly string[], ecosystem?: string): string | undefined;
|
|
31
|
+
maxSatisfying(versions: readonly string[], range: string, ecosystem?: string): string | undefined;
|
|
32
|
+
min(versions: readonly string[], ecosystem?: string): string | undefined;
|
|
33
|
+
minSatisfying(versions: readonly string[], range: string, ecosystem?: string): string | undefined;
|
|
34
|
+
neq(a: string, b: string, ecosystem?: string): boolean;
|
|
35
|
+
rsort(versions: readonly string[], ecosystem?: string): string[];
|
|
36
|
+
satisfies(version: string, range: string, ecosystem?: string): boolean;
|
|
37
|
+
sort(versions: readonly string[], ecosystem?: string): string[];
|
|
38
|
+
valid(version: string, ecosystem?: string): string | undefined;
|
|
39
|
+
filter(versions: readonly string[], range: string, ecosystem?: string): string[];
|
|
40
|
+
coerce(version: string, ecosystem?: string): string | undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns `node:smol-versions` when running on the smol Node binary,
|
|
44
|
+
* otherwise `undefined`. Result is cached across calls.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getSmolVersions(): SmolVersionsBinding | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 versions_exports = {};
|
|
22
|
+
__export(versions_exports, {
|
|
23
|
+
getSmolVersions: () => getSmolVersions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(versions_exports);
|
|
26
|
+
var import_util = require("./util");
|
|
27
|
+
let _smolVersions;
|
|
28
|
+
// @__NO_SIDE_EFFECTS__
|
|
29
|
+
function getSmolVersions() {
|
|
30
|
+
if (_smolVersions === void 0) {
|
|
31
|
+
if ((0, import_util.isSmol)()) {
|
|
32
|
+
try {
|
|
33
|
+
_smolVersions = require("node:smol-versions");
|
|
34
|
+
} catch {
|
|
35
|
+
_smolVersions = null;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
_smolVersions = null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return _smolVersions ?? void 0;
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
getSmolVersions
|
|
46
|
+
});
|
package/dist/spawn.js
CHANGED
|
@@ -42,6 +42,9 @@ var import_arrays = require("./arrays");
|
|
|
42
42
|
var import_bin = require("./bin");
|
|
43
43
|
var import_process = require("./constants/process");
|
|
44
44
|
var import_errors = require("./errors");
|
|
45
|
+
var import_child_process = require("./node/child-process");
|
|
46
|
+
var import_fs = require("./node/fs");
|
|
47
|
+
var import_path = require("./node/path");
|
|
45
48
|
var import_objects = require("./objects");
|
|
46
49
|
var import_normalize = require("./paths/normalize");
|
|
47
50
|
var import_spinner = require("./spinner");
|
|
@@ -53,23 +56,6 @@ const stackCache = new import_primordials.WeakMapCtor();
|
|
|
53
56
|
const spawnBinPathCache = new import_primordials.MapCtor();
|
|
54
57
|
const windowsScriptExtRegExp = /\.(?:cmd|bat|ps1)$/i;
|
|
55
58
|
let _npmCliPromiseSpawn;
|
|
56
|
-
let _path;
|
|
57
|
-
let _fs;
|
|
58
|
-
let _child_process;
|
|
59
|
-
// @__NO_SIDE_EFFECTS__
|
|
60
|
-
function getChildProcess() {
|
|
61
|
-
if (_child_process === void 0) {
|
|
62
|
-
_child_process = require("node:child_process");
|
|
63
|
-
}
|
|
64
|
-
return _child_process;
|
|
65
|
-
}
|
|
66
|
-
// @__NO_SIDE_EFFECTS__
|
|
67
|
-
function getFs() {
|
|
68
|
-
if (_fs === void 0) {
|
|
69
|
-
_fs = require("node:fs");
|
|
70
|
-
}
|
|
71
|
-
return _fs;
|
|
72
|
-
}
|
|
73
59
|
// @__NO_SIDE_EFFECTS__
|
|
74
60
|
function getNpmCliPromiseSpawn() {
|
|
75
61
|
if (_npmCliPromiseSpawn === void 0) {
|
|
@@ -78,13 +64,6 @@ function getNpmCliPromiseSpawn() {
|
|
|
78
64
|
return _npmCliPromiseSpawn;
|
|
79
65
|
}
|
|
80
66
|
// @__NO_SIDE_EFFECTS__
|
|
81
|
-
function getPath() {
|
|
82
|
-
if (_path === void 0) {
|
|
83
|
-
_path = require("node:path");
|
|
84
|
-
}
|
|
85
|
-
return _path;
|
|
86
|
-
}
|
|
87
|
-
// @__NO_SIDE_EFFECTS__
|
|
88
67
|
function stripAnsiFromSpawnResult(result) {
|
|
89
68
|
const res = result;
|
|
90
69
|
const { stderr, stdout } = res;
|
|
@@ -197,7 +176,7 @@ function spawn(cmd, args, options, extra) {
|
|
|
197
176
|
const cwd = spawnOptions.cwd ? String(spawnOptions.cwd) : void 0;
|
|
198
177
|
let actualCmd = cmd;
|
|
199
178
|
if (!(0, import_normalize.isPath)(cmd)) {
|
|
200
|
-
const fs =
|
|
179
|
+
const fs = (0, import_fs.getNodeFs)();
|
|
201
180
|
const cached = spawnBinPathCache.get(cmd);
|
|
202
181
|
if (cached) {
|
|
203
182
|
if (fs.existsSync(cached)) {
|
|
@@ -217,7 +196,10 @@ function spawn(cmd, args, options, extra) {
|
|
|
217
196
|
const WIN32 = import_node_process.default.platform === "win32";
|
|
218
197
|
if (WIN32 && shell && (0, import_primordials.RegExpPrototypeTest)(windowsScriptExtRegExp, actualCmd)) {
|
|
219
198
|
if (!(0, import_normalize.isPath)(actualCmd)) {
|
|
220
|
-
actualCmd = (
|
|
199
|
+
actualCmd = (0, import_path.getNodePath)().basename(
|
|
200
|
+
actualCmd,
|
|
201
|
+
(0, import_path.getNodePath)().extname(actualCmd)
|
|
202
|
+
);
|
|
221
203
|
}
|
|
222
204
|
}
|
|
223
205
|
const wasSpinning = !!spinnerInstance?.isSpinning;
|
|
@@ -313,7 +295,10 @@ function spawnSync(cmd, args, options) {
|
|
|
313
295
|
const WIN32 = import_node_process.default.platform === "win32";
|
|
314
296
|
if (WIN32 && shell && (0, import_primordials.RegExpPrototypeTest)(windowsScriptExtRegExp, actualCmd)) {
|
|
315
297
|
if (!(0, import_normalize.isPath)(actualCmd)) {
|
|
316
|
-
actualCmd = (
|
|
298
|
+
actualCmd = (0, import_path.getNodePath)().basename(
|
|
299
|
+
actualCmd,
|
|
300
|
+
(0, import_path.getNodePath)().extname(actualCmd)
|
|
301
|
+
);
|
|
317
302
|
}
|
|
318
303
|
}
|
|
319
304
|
const { stripAnsi: shouldStripAnsi = true, ...rawSpawnOptions } = {
|
|
@@ -327,7 +312,7 @@ function spawnSync(cmd, args, options) {
|
|
|
327
312
|
...rawSpawnOptions
|
|
328
313
|
};
|
|
329
314
|
const stdioString = spawnOptions.encoding !== "buffer";
|
|
330
|
-
const result = (
|
|
315
|
+
const result = (0, import_child_process.getNodeChildProcess)().spawnSync(actualCmd, args, spawnOptions);
|
|
331
316
|
if (stdioString) {
|
|
332
317
|
const { stderr, stdout } = result;
|
|
333
318
|
if (stdout) {
|
package/dist/versions.js
CHANGED
|
@@ -42,6 +42,8 @@ __export(versions_exports, {
|
|
|
42
42
|
versionDiff: () => versionDiff
|
|
43
43
|
});
|
|
44
44
|
module.exports = __toCommonJS(versions_exports);
|
|
45
|
+
var import_versions = require("./smol/versions");
|
|
46
|
+
const _smolVersions = (0, import_versions.getSmolVersions)();
|
|
45
47
|
let _semver;
|
|
46
48
|
function getSemver() {
|
|
47
49
|
if (_semver === void 0) {
|
|
@@ -49,6 +51,9 @@ function getSemver() {
|
|
|
49
51
|
}
|
|
50
52
|
return _semver;
|
|
51
53
|
}
|
|
54
|
+
function getVersionsImpl() {
|
|
55
|
+
return _smolVersions ?? getSemver();
|
|
56
|
+
}
|
|
52
57
|
function coerceVersion(version) {
|
|
53
58
|
const semver = getSemver();
|
|
54
59
|
const coerced = semver.coerce(version);
|
|
@@ -56,15 +61,15 @@ function coerceVersion(version) {
|
|
|
56
61
|
}
|
|
57
62
|
function compareVersions(v1, v2) {
|
|
58
63
|
try {
|
|
59
|
-
const
|
|
60
|
-
return
|
|
64
|
+
const impl = getVersionsImpl();
|
|
65
|
+
return impl.compare(v1, v2);
|
|
61
66
|
} catch {
|
|
62
67
|
return void 0;
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
function filterVersions(versions, range) {
|
|
66
|
-
const
|
|
67
|
-
return versions.filter((v) =>
|
|
71
|
+
const impl = getVersionsImpl();
|
|
72
|
+
return versions.filter((v) => impl.satisfies(v, range));
|
|
68
73
|
}
|
|
69
74
|
function getMajorVersion(version) {
|
|
70
75
|
const semver = getSemver();
|
|
@@ -86,28 +91,28 @@ function incrementVersion(version, release, identifier) {
|
|
|
86
91
|
return semver.inc(version, release, identifier) || void 0;
|
|
87
92
|
}
|
|
88
93
|
function isEqual(version1, version2) {
|
|
89
|
-
const
|
|
90
|
-
return
|
|
94
|
+
const impl = getVersionsImpl();
|
|
95
|
+
return impl.eq(version1, version2);
|
|
91
96
|
}
|
|
92
97
|
function isGreaterThan(version1, version2) {
|
|
93
|
-
const
|
|
94
|
-
return
|
|
98
|
+
const impl = getVersionsImpl();
|
|
99
|
+
return impl.gt(version1, version2);
|
|
95
100
|
}
|
|
96
101
|
function isGreaterThanOrEqual(version1, version2) {
|
|
97
|
-
const
|
|
98
|
-
return
|
|
102
|
+
const impl = getVersionsImpl();
|
|
103
|
+
return impl.gte(version1, version2);
|
|
99
104
|
}
|
|
100
105
|
function isLessThan(version1, version2) {
|
|
101
|
-
const
|
|
102
|
-
return
|
|
106
|
+
const impl = getVersionsImpl();
|
|
107
|
+
return impl.lt(version1, version2);
|
|
103
108
|
}
|
|
104
109
|
function isLessThanOrEqual(version1, version2) {
|
|
105
|
-
const
|
|
106
|
-
return
|
|
110
|
+
const impl = getVersionsImpl();
|
|
111
|
+
return impl.lte(version1, version2);
|
|
107
112
|
}
|
|
108
113
|
function isValidVersion(version) {
|
|
109
|
-
const
|
|
110
|
-
return
|
|
114
|
+
const impl = getVersionsImpl();
|
|
115
|
+
return impl.valid(version) != null;
|
|
111
116
|
}
|
|
112
117
|
function maxVersion(versions) {
|
|
113
118
|
const semver = getSemver();
|
|
@@ -132,16 +137,16 @@ function parseVersion(version) {
|
|
|
132
137
|
};
|
|
133
138
|
}
|
|
134
139
|
function satisfiesVersion(version, range) {
|
|
135
|
-
const
|
|
136
|
-
return
|
|
140
|
+
const impl = getVersionsImpl();
|
|
141
|
+
return impl.satisfies(version, range);
|
|
137
142
|
}
|
|
138
143
|
function sortVersions(versions) {
|
|
139
|
-
const
|
|
140
|
-
return
|
|
144
|
+
const impl = getVersionsImpl();
|
|
145
|
+
return impl.sort([...versions]);
|
|
141
146
|
}
|
|
142
147
|
function sortVersionsDesc(versions) {
|
|
143
|
-
const
|
|
144
|
-
return
|
|
148
|
+
const impl = getVersionsImpl();
|
|
149
|
+
return impl.rsort([...versions]);
|
|
145
150
|
}
|
|
146
151
|
function versionDiff(version1, version2) {
|
|
147
152
|
try {
|