@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.
- package/CHANGELOG.md +42 -0
- package/README.md +1 -1
- package/dist/ai/agent-context.d.mts +103 -0
- package/dist/ai/agent-context.js +157 -0
- package/dist/ai/backends.d.mts +83 -0
- package/dist/ai/backends.js +173 -0
- package/dist/ai/credentials.d.mts +49 -0
- package/dist/ai/credentials.js +82 -0
- package/dist/ai/discover.d.mts +4 -0
- package/dist/ai/discover.js +1 -1
- package/dist/ai/exec.d.mts +52 -0
- package/dist/ai/exec.js +92 -0
- package/dist/ai/http.d.mts +132 -0
- package/dist/ai/http.js +130 -0
- package/dist/ai/profiles.d.mts +41 -6
- package/dist/ai/profiles.js +52 -10
- package/dist/ai/route.d.mts +82 -0
- package/dist/ai/route.js +171 -0
- package/dist/ai/spawn.d.mts +42 -2
- package/dist/ai/spawn.js +146 -33
- package/dist/ai/subagent-status.d.mts +48 -0
- package/dist/ai/subagent-status.js +57 -0
- package/dist/ai/tier.d.mts +60 -0
- package/dist/ai/tier.js +53 -0
- package/dist/ai/types.d.mts +25 -2
- package/dist/ai/worktree.js +4 -0
- package/dist/archives/tar.js +1 -1
- package/dist/archives/zip.js +2 -2
- package/dist/argv/parse.d.ts +19 -2
- package/dist/argv/parse.js +1 -1
- package/dist/arrays/join.js +4 -0
- package/dist/bin/find.js +4 -4
- package/dist/bin/prim.cjs +23322 -18018
- package/dist/bin/resolve.js +2 -2
- package/dist/cache/ttl/store.js +2 -2
- package/dist/cli/check-primordials.d.ts +8 -3
- package/dist/cli/check-primordials.js +4 -4
- package/dist/compression/_internal.js +1 -1
- package/dist/compression/brotli.d.ts +1 -2
- package/dist/compression/brotli.js +5 -1
- package/dist/compression/gzip.js +5 -1
- package/dist/config/layers.d.ts +53 -0
- package/dist/config/layers.js +83 -0
- package/dist/constants/packages.d.ts +3 -0
- package/dist/constants/packages.js +2 -1
- package/dist/constants/socket.d.ts +2 -6
- package/dist/constants/socket.js +12 -14
- package/dist/cover/code.js +2 -2
- package/dist/crypto/hash.d.ts +4 -1
- package/dist/crypto/hash.js +4 -1
- package/dist/dlx/arborist.js +13 -3
- package/dist/dlx/binary-cache.js +1 -1
- package/dist/dlx/binary-resolution.js +1 -1
- package/dist/dlx/detect.d.ts +8 -0
- package/dist/dlx/firewall.d.ts +8 -0
- package/dist/dlx/lockfile.js +5 -2
- package/dist/dlx/manifest.js +1 -1
- package/dist/dlx/package.js +4 -0
- package/dist/eco/cargo/parse-lockfile.d.ts +1 -2
- package/dist/eco/cargo/parse-lockfile.js +3 -3
- package/dist/eco/manifest/detect-format.js +1 -1
- package/dist/eco/npm/npm/parse-lockfile.d.ts +3 -4
- package/dist/eco/npm/npm/parse-lockfile.js +2 -2
- package/dist/eco/npm/parse-package-json.d.ts +11 -0
- package/dist/eco/npm/parse-package-json.js +1 -1
- package/dist/eco/npm/pnpm/parse-lockfile.d.ts +5 -3
- package/dist/eco/npm/pnpm/parse-lockfile.js +3 -3
- package/dist/eco/npm/yarnpkg/yarn/exec.js +1 -1
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.d.ts +1 -2
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +2 -2
- package/dist/env/proxy.js +1 -1
- package/dist/env/rewire.d.ts +6 -3
- package/dist/env/rewire.js +7 -8
- package/dist/env/socket.d.ts +7 -0
- package/dist/env/socket.js +10 -0
- package/dist/env/xdg.d.ts +17 -0
- package/dist/env/xdg.js +21 -1
- package/dist/errors/predicates.js +1 -1
- package/dist/errors/stack.js +1 -2
- package/dist/external/@npmcli/package-json.js +3455 -4881
- package/dist/external/@npmcli/promise-spawn.js +3 -1
- package/dist/external/@yarnpkg/extensions.js +1 -1
- package/dist/external/external-pack.js +1 -1
- package/dist/external/npm-pack.js +29164 -31799
- package/dist/external/pico-pack.js +4 -2
- package/dist/external/tar-fs.js +63 -16
- package/dist/external/which.js +3 -1
- package/dist/external-tools/bazel/asset-names.d.ts +1 -1
- package/dist/external-tools/bazel/asset-names.js +5 -2
- package/dist/external-tools/bazel/from-download.d.ts +1 -1
- package/dist/external-tools/bazel/from-download.js +5 -2
- package/dist/external-tools/bazel/resolve-bazel-version.js +4 -0
- package/dist/external-tools/bazel/resolve.d.ts +3 -3
- package/dist/external-tools/bazel/resolve.js +16 -8
- package/dist/external-tools/cdxgen/asset-names.d.ts +1 -1
- package/dist/external-tools/cdxgen/asset-names.js +5 -2
- package/dist/external-tools/cdxgen/from-download.d.ts +1 -1
- package/dist/external-tools/cdxgen/from-download.js +7 -4
- package/dist/external-tools/cdxgen/resolve.d.ts +3 -3
- package/dist/external-tools/cdxgen/resolve.js +16 -8
- package/dist/external-tools/from-download.d.ts +2 -2
- package/dist/external-tools/from-download.js +11 -5
- package/dist/external-tools/from-pip-venv.d.ts +1 -1
- package/dist/external-tools/from-pip-venv.js +12 -5
- package/dist/external-tools/janus/asset-names.d.ts +1 -1
- package/dist/external-tools/janus/asset-names.js +5 -2
- package/dist/external-tools/janus/from-download.d.ts +1 -1
- package/dist/external-tools/janus/from-download.js +5 -2
- package/dist/external-tools/janus/resolve.d.ts +3 -3
- package/dist/external-tools/janus/resolve.js +16 -8
- package/dist/external-tools/jre/asset-names.d.ts +1 -1
- package/dist/external-tools/jre/asset-names.js +5 -2
- package/dist/external-tools/jre/detect-platform-arch.js +1 -1
- package/dist/external-tools/jre/from-download.d.ts +1 -1
- package/dist/external-tools/jre/from-download.js +7 -4
- package/dist/external-tools/jre/from-java-home.js +2 -2
- package/dist/external-tools/jre/from-vfs.js +2 -2
- package/dist/external-tools/jre/resolve.d.ts +3 -3
- package/dist/external-tools/jre/resolve.js +16 -8
- package/dist/external-tools/manifest.d.ts +18 -0
- package/dist/external-tools/manifest.js +2 -2
- package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
- package/dist/external-tools/opengrep/asset-names.js +5 -2
- package/dist/external-tools/opengrep/from-download.d.ts +1 -1
- package/dist/external-tools/opengrep/from-download.js +5 -2
- package/dist/external-tools/opengrep/resolve.d.ts +3 -3
- package/dist/external-tools/opengrep/resolve.js +16 -8
- package/dist/external-tools/python/asset-names.d.ts +1 -1
- package/dist/external-tools/python/asset-names.js +11 -4
- package/dist/external-tools/python/dlx.d.ts +3 -3
- package/dist/external-tools/python/dlx.js +20 -9
- package/dist/external-tools/python/from-download.d.ts +1 -1
- package/dist/external-tools/python/from-download.js +12 -5
- package/dist/external-tools/python/pin.js +6 -3
- package/dist/external-tools/python/pip-install.js +6 -3
- package/dist/external-tools/python/resolve.d.ts +3 -3
- package/dist/external-tools/python/resolve.js +19 -11
- package/dist/external-tools/python/uv-install.d.ts +89 -0
- package/dist/external-tools/python/uv-install.js +165 -0
- package/dist/external-tools/sbt/asset-names.d.ts +1 -1
- package/dist/external-tools/sbt/asset-names.js +5 -2
- package/dist/external-tools/sbt/from-download.d.ts +1 -1
- package/dist/external-tools/sbt/from-download.js +5 -2
- package/dist/external-tools/sbt/resolve.d.ts +3 -3
- package/dist/external-tools/sbt/resolve.js +16 -8
- package/dist/external-tools/skillspector/from-dlx.d.ts +1 -1
- package/dist/external-tools/skillspector/from-dlx.js +10 -3
- package/dist/external-tools/skillspector/from-uv.d.ts +30 -0
- package/dist/external-tools/skillspector/from-uv.js +56 -0
- package/dist/external-tools/skillspector/resolve.d.ts +20 -5
- package/dist/external-tools/skillspector/resolve.js +27 -6
- package/dist/external-tools/skillspector/types.d.ts +3 -1
- package/dist/external-tools/synp/asset-names.d.ts +1 -1
- package/dist/external-tools/synp/asset-names.js +6 -2
- package/dist/external-tools/synp/from-download.d.ts +1 -1
- package/dist/external-tools/synp/from-download.js +5 -2
- package/dist/external-tools/synp/resolve.d.ts +3 -3
- package/dist/external-tools/synp/resolve.js +16 -8
- package/dist/external-tools/trivy/asset-names.d.ts +1 -1
- package/dist/external-tools/trivy/asset-names.js +5 -2
- package/dist/external-tools/trivy/from-download.d.ts +1 -1
- package/dist/external-tools/trivy/from-download.js +7 -4
- package/dist/external-tools/trivy/resolve.d.ts +3 -3
- package/dist/external-tools/trivy/resolve.js +16 -8
- package/dist/external-tools/trufflehog/asset-names.d.ts +1 -1
- package/dist/external-tools/trufflehog/asset-names.js +5 -2
- package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
- package/dist/external-tools/trufflehog/from-download.js +7 -4
- package/dist/external-tools/trufflehog/resolve.d.ts +3 -3
- package/dist/external-tools/trufflehog/resolve.js +16 -8
- package/dist/external-tools/uv/asset-names.d.ts +36 -0
- package/dist/external-tools/uv/asset-names.js +73 -0
- package/dist/external-tools/uv/from-download.d.ts +17 -0
- package/dist/external-tools/uv/from-download.js +50 -0
- package/dist/external-tools/uv/from-path.d.ts +5 -0
- package/dist/external-tools/uv/from-path.js +22 -0
- package/dist/external-tools/uv/from-vfs.d.ts +7 -0
- package/dist/external-tools/uv/from-vfs.js +26 -0
- package/dist/external-tools/uv/resolve.d.ts +25 -0
- package/dist/external-tools/uv/resolve.js +61 -0
- package/dist/external-tools/uv/types.d.ts +24 -0
- package/dist/external-tools/uv/types.js +2 -0
- package/dist/fleet/repo-config.d.ts +53 -0
- package/dist/fleet/repo-config.js +79 -0
- package/dist/fs/allowed-dirs-cache.d.ts +27 -1
- package/dist/fs/allowed-dirs-cache.js +39 -6
- package/dist/fs/copy.d.ts +88 -0
- package/dist/fs/copy.js +89 -0
- package/dist/fs/find.js +1 -1
- package/dist/fs/read-json-cache.d.ts +7 -0
- package/dist/fs/resolve-module.js +6 -2
- package/dist/fs/safe.js +1 -1
- package/dist/git/_internal.js +3 -3
- package/dist/git/repo.js +2 -4
- package/dist/git/staged.js +8 -0
- package/dist/git/tracked.d.ts +84 -0
- package/dist/git/tracked.js +163 -0
- package/dist/git/unstaged.js +8 -0
- package/dist/github/refs-graphql.js +4 -0
- package/dist/github/refs-rest.js +4 -0
- package/dist/globs/_internal.js +1 -1
- package/dist/globs/match.js +9 -1
- package/dist/globs/matcher.js +5 -1
- package/dist/http-request/browser.js +7 -3
- package/dist/http-request/checksum-file.js +1 -1
- package/dist/http-request/{browser-fetch.d.ts → fetch/browser.d.ts} +2 -2
- package/dist/http-request/{browser-fetch.js → fetch/browser.js} +4 -4
- package/dist/http-request/headers.js +1 -1
- package/dist/http-request/request-attempt.js +2 -2
- package/dist/http-request/user-agent.js +1 -1
- package/dist/integrity.d.ts +124 -71
- package/dist/integrity.js +168 -78
- package/dist/json/edit.js +38 -30
- package/dist/json/format.js +1 -1
- package/dist/logger/colors.d.ts +1 -2
- package/dist/logger/colors.js +2 -2
- package/dist/logger/symbols-builder.js +7 -8
- package/dist/logger/symbols.js +8 -8
- package/dist/native-messaging/install.d.ts +1 -1
- package/dist/native-messaging/install.js +7 -4
- package/dist/native-messaging/rate-limit.d.ts +7 -0
- package/dist/native-messaging/rate-limit.js +4 -0
- package/dist/node/async-hooks.js +1 -1
- package/dist/node/child-process.js +1 -1
- package/dist/node/crypto.js +1 -1
- package/dist/node/events.js +1 -1
- package/dist/node/fs-promises.js +1 -1
- package/dist/node/fs.d.ts +22 -6
- package/dist/node/fs.js +16 -3
- package/dist/node/http.js +1 -1
- package/dist/node/https.js +1 -1
- package/dist/node/module.d.ts +73 -2
- package/dist/node/module.js +97 -12
- package/dist/node/os.d.ts +10 -2
- package/dist/node/os.js +11 -4
- package/dist/node/path.d.ts +11 -2
- package/dist/node/path.js +17 -4
- package/dist/node/timers-promises.js +1 -1
- package/dist/node/url.js +1 -1
- package/dist/node/util.js +1 -1
- package/dist/objects/getters.js +1 -1
- package/dist/objects/mutate.js +2 -2
- package/dist/packages/edit-class.d.ts +2 -3
- package/dist/packages/edit-class.js +41 -35
- package/dist/packages/exports.js +4 -4
- package/dist/packages/fetch.js +1 -1
- package/dist/packages/isolation.js +2 -2
- package/dist/packages/licenses.js +2 -2
- package/dist/packages/manifest.d.ts +29 -0
- package/dist/packages/manifest.js +40 -4
- package/dist/packages/normalize.js +2 -2
- package/dist/packages/provenance.js +3 -3
- package/dist/packages/specs.js +1 -1
- package/dist/packages/tarball.js +4 -2
- package/dist/packages/types.d.ts +1 -2
- package/dist/paths/_internal.d.ts +1 -7
- package/dist/paths/_internal.js +9 -15
- package/dist/paths/conversion.js +1 -1
- package/dist/paths/dirnames.d.ts +1 -0
- package/dist/paths/dirnames.js +2 -0
- package/dist/paths/normalize.js +1 -1
- package/dist/paths/predicates.js +2 -1
- package/dist/paths/resolve.js +14 -19
- package/dist/paths/rewire.d.ts +5 -0
- package/dist/paths/socket.d.ts +137 -123
- package/dist/paths/socket.js +172 -131
- package/dist/perf/metrics.js +1 -1
- package/dist/perf/report.js +1 -1
- package/dist/primordials/process.d.ts +88 -0
- package/dist/primordials/process.js +132 -0
- package/dist/primordials/uncurry.d.ts +1 -2
- package/dist/process/spawn/child.js +8 -2
- package/dist/process/spawn/errors.js +1 -1
- package/dist/releases/github-archives.js +1 -1
- package/dist/releases/github-listing.d.ts +1 -2
- package/dist/schema/types.d.ts +3 -4
- package/dist/schema/validate.js +1 -1
- package/dist/secrets/broker.d.ts +35 -0
- package/dist/secrets/broker.js +72 -0
- package/dist/secrets/find.d.ts +8 -6
- package/dist/secrets/find.js +25 -5
- package/dist/secrets/keychain.d.ts +1 -1
- package/dist/secrets/linux.js +32 -44
- package/dist/secrets/macos.d.ts +1 -2
- package/dist/secrets/macos.js +20 -29
- package/dist/secrets/rc.d.ts +2 -2
- package/dist/secrets/rc.js +21 -13
- package/dist/secrets/socket-api-token.js +8 -0
- package/dist/secrets/windows.js +27 -33
- package/dist/shell/parse.d.ts +32 -0
- package/dist/shell/parse.js +60 -0
- package/dist/smol/detect.js +1 -1
- package/dist/smol/http.js +1 -1
- package/dist/smol/https.js +1 -1
- package/dist/smol/manifest.js +1 -1
- package/dist/smol/path.js +1 -1
- package/dist/smol/primordial.js +1 -1
- package/dist/smol/purl.js +1 -1
- package/dist/smol/versions.js +1 -1
- package/dist/smol/vfs.js +1 -1
- package/dist/sorts/_internal.d.ts +1 -2
- package/dist/sorts/_internal.js +2 -6
- package/dist/sorts/semver.js +2 -2
- package/dist/spinner/create-spinner-class.js +2 -2
- package/dist/spinner/spinner-internals.d.ts +1 -1
- package/dist/spinner/spinner-internals.js +9 -5
- package/dist/spinner/spinner.d.ts +4 -0
- package/dist/spinner/spinner.js +1 -1
- package/dist/stdio/progress.js +6 -2
- package/dist/stdio/prompts.d.ts +2 -10
- package/dist/stdio/prompts.js +11 -24
- package/dist/strings/format.js +1 -1
- package/dist/strings/search.js +1 -1
- package/dist/temporal/instant.js +2 -2
- package/dist/themes/context.d.ts +5 -3
- package/dist/themes/context.js +5 -6
- package/dist/url/assert-safe.d.ts +29 -0
- package/dist/url/assert-safe.js +54 -0
- package/dist/url/predicates.d.ts +31 -1
- package/dist/url/predicates.js +42 -1
- package/dist/url/types.d.ts +4 -0
- package/llms.txt +750 -0
- 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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
canSave = true;
|
|
37
|
+
contentData = {};
|
|
38
|
+
pathValue = void 0;
|
|
39
|
+
readFileContent = "";
|
|
40
|
+
readFileJson = void 0;
|
|
41
41
|
get content() {
|
|
42
|
-
return this.
|
|
42
|
+
return this.contentData;
|
|
43
43
|
}
|
|
44
44
|
get filename() {
|
|
45
|
-
const path = this.
|
|
45
|
+
const path = this.pathValue;
|
|
46
46
|
if (!path) return "";
|
|
47
47
|
return path;
|
|
48
48
|
}
|
|
49
49
|
get path() {
|
|
50
|
-
return this.
|
|
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.
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
69
|
+
this.pathValue = path;
|
|
70
|
+
this.contentData = {};
|
|
71
|
+
this.canSave = true;
|
|
72
72
|
return this;
|
|
73
73
|
}
|
|
74
74
|
fromContent(data) {
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
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.
|
|
85
|
+
this.contentData = parsed;
|
|
86
86
|
return this;
|
|
87
87
|
}
|
|
88
88
|
async load(path) {
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
91
|
-
this.fromJSON(this.
|
|
92
|
-
this.
|
|
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
|
-
|
|
97
|
-
|
|
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.
|
|
102
|
-
this.
|
|
105
|
+
this.readFileContent = fileContent;
|
|
106
|
+
this.readFileJson = require_primordials_json.JSONParse(fileContent);
|
|
103
107
|
return true;
|
|
104
108
|
}
|
|
105
109
|
saveSync(options) {
|
|
106
|
-
|
|
107
|
-
|
|
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.
|
|
112
|
-
this.
|
|
119
|
+
this.readFileContent = fileContent;
|
|
120
|
+
this.readFileJson = require_primordials_json.JSONParse(fileContent);
|
|
113
121
|
return true;
|
|
114
122
|
}
|
|
115
123
|
update(content) {
|
|
116
|
-
this.
|
|
117
|
-
...this.
|
|
124
|
+
this.contentData = {
|
|
125
|
+
...this.contentData,
|
|
118
126
|
...content
|
|
119
127
|
};
|
|
120
128
|
return this;
|
|
121
129
|
}
|
|
122
130
|
willSave(options) {
|
|
123
|
-
if (!this.
|
|
124
|
-
return require_json_format.shouldSave(this.content, this.
|
|
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;
|
package/dist/json/format.js
CHANGED
|
@@ -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
|
/**
|
package/dist/logger/colors.d.ts
CHANGED
|
@@ -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
|
|
13
|
+
export declare function applyColor(text: string, color: ColorValue): string;
|
|
15
14
|
/**
|
|
16
15
|
* Get the yoctocolors module for terminal colors.
|
|
17
16
|
*/
|
package/dist/logger/colors.js
CHANGED
|
@@ -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
|
|
20
|
+
function applyColor(text, color) {
|
|
21
21
|
if (typeof color === "string") {
|
|
22
|
-
const formatter =
|
|
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
|
|
35
|
-
info: require_logger_colors.applyColor(supported ? "ℹ" : "i", theme.colors.info
|
|
36
|
-
progress: require_logger_colors.applyColor(supported ? "∴" : ":.", theme.colors.step
|
|
37
|
-
skip: require_logger_colors.applyColor(supported ? "↻" : "@", theme.colors.step
|
|
38
|
-
step: require_logger_colors.applyColor(supported ? "→" : ">", theme.colors.step
|
|
39
|
-
success: require_logger_colors.applyColor(supported ? "✔" : "√", theme.colors.success
|
|
40
|
-
warn: require_logger_colors.applyColor(supported ? "⚠" : "‼", theme.colors.warning
|
|
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
|
}
|
package/dist/logger/symbols.js
CHANGED
|
@@ -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
|
|
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
|
|
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(
|
|
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(
|
|
81
|
+
function installNativeHost(options) {
|
|
82
82
|
assertNodeStripTypesSupported();
|
|
83
|
-
const { allowedOrigins, production = false, wrapperDir = __dirname$1 } =
|
|
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");
|
package/dist/node/async-hooks.js
CHANGED
|
@@ -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("
|
|
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("
|
|
10
|
+
return childProcess ??= /*@__PURE__*/ require("child_process");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
//#endregion
|
package/dist/node/crypto.js
CHANGED
|
@@ -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("
|
|
10
|
+
return crypto ??= /*@__PURE__*/ require("crypto");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
//#endregion
|
package/dist/node/events.js
CHANGED
|
@@ -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("
|
|
10
|
+
return events ??= /*@__PURE__*/ require("events");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
//#endregion
|
package/dist/node/fs-promises.js
CHANGED
|
@@ -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("
|
|
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
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
-
|
|
7
|
+
const nodeFs = require_constants_runtime.IS_NODE ? /*@__PURE__*/ require("fs") : void 0;
|
|
8
8
|
function getNodeFs() {
|
|
9
|
-
|
|
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("
|
|
10
|
+
return cachedHttp ??= /*@__PURE__*/ require("http");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
//#endregion
|
package/dist/node/https.js
CHANGED
|
@@ -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("
|
|
10
|
+
return cachedHttps ??= /*@__PURE__*/ require("https");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
//#endregion
|
package/dist/node/module.d.ts
CHANGED
|
@@ -1,7 +1,78 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
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;
|
package/dist/node/module.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
14
|
-
*
|
|
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
|
-
*
|
|
18
|
-
*
|
|
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 `
|
|
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 (
|
|
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.
|
|
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
|
|
3
|
-
*
|
|
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;
|