@socketsecurity/lib 5.18.2 → 5.19.1
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 +57 -0
- package/README.md +6 -5
- package/dist/abort.d.ts +3 -0
- package/dist/abort.js +1 -0
- package/dist/agent.d.ts +66 -49
- package/dist/agent.js +51 -50
- package/dist/ansi.d.ts +2 -5
- package/dist/ansi.js +3 -2
- package/dist/archives.d.ts +25 -21
- package/dist/archives.js +35 -34
- package/dist/argv/flags.d.ts +100 -91
- package/dist/argv/flags.js +88 -87
- package/dist/argv/parse.d.ts +30 -40
- package/dist/argv/parse.js +33 -32
- package/dist/arrays.d.ts +4 -8
- package/dist/arrays.js +1 -0
- package/dist/bin.d.ts +7 -5
- package/dist/bin.js +52 -29
- package/dist/cacache.d.ts +13 -12
- package/dist/cacache.js +9 -8
- package/dist/cache-with-ttl.d.ts +53 -35
- package/dist/cache-with-ttl.js +1 -0
- package/dist/colors.d.ts +5 -5
- package/dist/colors.js +1 -0
- package/dist/constants/agents.d.ts +5 -9
- package/dist/constants/agents.js +3 -2
- package/dist/constants/core.d.ts +5 -10
- package/dist/constants/core.js +2 -1
- package/dist/constants/encoding.d.ts +3 -3
- package/dist/constants/encoding.js +1 -0
- package/dist/constants/github.d.ts +3 -3
- package/dist/constants/github.js +1 -0
- package/dist/constants/licenses.d.ts +9 -2
- package/dist/constants/licenses.js +1 -0
- package/dist/constants/lifecycle-script-names.js +1 -0
- package/dist/constants/maintained-node-versions.d.ts +3 -0
- package/dist/constants/maintained-node-versions.js +1 -0
- package/dist/constants/node.d.ts +125 -16
- package/dist/constants/node.js +74 -73
- package/dist/constants/package-default-node-range.d.ts +3 -1
- package/dist/constants/package-default-node-range.js +2 -1
- package/dist/constants/package-default-socket-categories.d.ts +0 -1
- package/dist/constants/package-default-socket-categories.js +1 -0
- package/dist/constants/packages.d.ts +12 -17
- package/dist/constants/packages.js +31 -16
- package/dist/constants/platform.d.ts +1 -2
- package/dist/constants/platform.js +2 -1
- package/dist/constants/process.d.ts +18 -0
- package/dist/constants/process.js +1 -0
- package/dist/constants/socket.d.ts +4 -10
- package/dist/constants/socket.js +2 -1
- package/dist/constants/testing.d.ts +3 -3
- package/dist/constants/testing.js +1 -0
- package/dist/constants/time.d.ts +3 -4
- package/dist/constants/time.js +1 -0
- package/dist/constants/typescript.d.ts +10 -3
- package/dist/constants/typescript.js +5 -4
- package/dist/cover/code.d.ts +3 -0
- package/dist/cover/code.js +12 -12
- package/dist/cover/formatters.d.ts +12 -9
- package/dist/cover/formatters.js +19 -18
- package/dist/cover/type.d.ts +3 -0
- package/dist/cover/type.js +1 -0
- package/dist/cover/types.js +1 -0
- package/dist/debug.d.ts +32 -47
- package/dist/debug.js +97 -96
- package/dist/dlx/arborist.d.ts +134 -0
- package/dist/dlx/arborist.js +177 -0
- package/dist/dlx/binary.d.ts +25 -9
- package/dist/dlx/binary.js +34 -12
- package/dist/dlx/cache.d.ts +1 -0
- package/dist/dlx/cache.js +2 -1
- package/dist/dlx/detect.d.ts +15 -0
- package/dist/dlx/detect.js +28 -20
- package/dist/dlx/dir.d.ts +1 -11
- package/dist/dlx/dir.js +2 -12
- package/dist/dlx/integrity.d.ts +86 -0
- package/dist/dlx/integrity.js +112 -0
- package/dist/dlx/lockfile.d.ts +115 -0
- package/dist/dlx/lockfile.js +139 -0
- package/dist/dlx/manifest.d.ts +26 -1
- package/dist/dlx/manifest.js +9 -6
- package/dist/dlx/package.d.ts +58 -3
- package/dist/dlx/package.js +101 -74
- package/dist/dlx/packages.d.ts +1 -11
- package/dist/dlx/packages.js +3 -14
- package/dist/dlx/paths.d.ts +1 -0
- package/dist/dlx/paths.js +2 -1
- package/dist/effects/pulse-frames.js +1 -0
- package/dist/effects/text-shimmer.d.ts +13 -2
- package/dist/effects/text-shimmer.js +50 -46
- package/dist/effects/types.js +1 -0
- package/dist/effects/ultra.js +1 -0
- package/dist/env/ci.d.ts +6 -1
- package/dist/env/ci.js +1 -0
- package/dist/env/debug.d.ts +5 -1
- package/dist/env/debug.js +1 -0
- package/dist/env/github.d.ts +19 -23
- package/dist/env/github.js +5 -4
- package/dist/env/helpers.d.ts +21 -9
- package/dist/env/helpers.js +5 -11
- package/dist/env/home.d.ts +17 -4
- package/dist/env/home.js +2 -1
- package/dist/env/locale.d.ts +4 -3
- package/dist/env/locale.js +1 -0
- package/dist/env/node-auth-token.d.ts +5 -1
- package/dist/env/node-auth-token.js +1 -0
- package/dist/env/node-env.d.ts +5 -1
- package/dist/env/node-env.js +1 -0
- package/dist/env/npm.d.ts +4 -5
- package/dist/env/npm.js +1 -0
- package/dist/env/package-manager.d.ts +4 -3
- package/dist/env/package-manager.js +2 -1
- package/dist/env/path.d.ts +5 -1
- package/dist/env/path.js +1 -0
- package/dist/env/pre-commit.d.ts +5 -1
- package/dist/env/pre-commit.js +1 -0
- package/dist/env/rewire.d.ts +10 -0
- package/dist/env/rewire.js +7 -5
- package/dist/env/shell.d.ts +5 -1
- package/dist/env/shell.js +1 -0
- package/dist/env/socket-cli-shadow.d.ts +4 -5
- package/dist/env/socket-cli-shadow.js +1 -0
- package/dist/env/socket-cli.d.ts +4 -14
- package/dist/env/socket-cli.js +1 -0
- package/dist/env/socket.d.ts +6 -18
- package/dist/env/socket.js +4 -3
- package/dist/env/temp-dir.d.ts +4 -3
- package/dist/env/temp-dir.js +1 -0
- package/dist/env/term.d.ts +5 -1
- package/dist/env/term.js +1 -0
- package/dist/env/test.d.ts +4 -3
- package/dist/env/test.js +1 -0
- package/dist/env/windows.d.ts +4 -4
- package/dist/env/windows.js +1 -0
- package/dist/env/xdg.d.ts +4 -3
- package/dist/env/xdg.js +1 -0
- package/dist/env.d.ts +83 -23
- package/dist/env.js +112 -80
- package/dist/errors.js +1 -0
- package/dist/external/@socketregistry/packageurl-js.js +2 -2
- package/dist/external/external-pack.js +1562 -1673
- package/dist/external/npm-pack.js +5 -1
- package/dist/fs.d.ts +92 -113
- package/dist/fs.js +35 -35
- package/dist/git.d.ts +170 -164
- package/dist/git.js +113 -87
- package/dist/github.d.ts +249 -227
- package/dist/github.js +82 -81
- package/dist/globs.d.ts +31 -17
- package/dist/globs.js +51 -58
- package/dist/http-request.d.ts +99 -99
- package/dist/http-request.js +182 -156
- package/dist/ipc-cli.d.ts +28 -0
- package/dist/{utils/get-ipc.js → ipc-cli.js} +4 -3
- package/dist/ipc.d.ts +9 -299
- package/dist/ipc.js +18 -204
- package/dist/json/edit.d.ts +3 -1
- package/dist/json/edit.js +30 -30
- package/dist/json/format.d.ts +36 -36
- package/dist/json/format.js +22 -21
- package/dist/json/parse.d.ts +4 -2
- package/dist/json/parse.js +1 -0
- package/dist/json/types.js +1 -0
- package/dist/{links/index.d.ts → links.d.ts} +6 -2
- package/dist/{links/index.js → links.js} +5 -4
- package/dist/logger.d.ts +4 -6
- package/dist/logger.js +61 -53
- package/dist/memoization.d.ts +52 -49
- package/dist/memoization.js +55 -33
- package/dist/objects.d.ts +25 -44
- package/dist/objects.js +2 -1
- package/dist/package-extensions.d.ts +6 -0
- package/dist/package-extensions.js +2 -1
- package/dist/packages/edit.d.ts +3 -5
- package/dist/packages/edit.js +4 -3
- package/dist/packages/exports.d.ts +11 -14
- package/dist/packages/exports.js +11 -10
- package/dist/packages/isolation.d.ts +4 -0
- package/dist/packages/isolation.js +20 -19
- package/dist/packages/licenses.d.ts +3 -10
- package/dist/packages/licenses.js +2 -1
- package/dist/packages/manifest.d.ts +3 -3
- package/dist/packages/manifest.js +1 -0
- package/dist/packages/normalize.d.ts +3 -4
- package/dist/packages/normalize.js +1 -0
- package/dist/packages/operations.d.ts +3 -10
- package/dist/packages/operations.js +1 -0
- package/dist/packages/provenance.d.ts +10 -8
- package/dist/packages/provenance.js +55 -54
- package/dist/packages/specs.d.ts +3 -5
- package/dist/packages/specs.js +1 -0
- package/dist/packages/validation.d.ts +3 -3
- package/dist/packages/validation.js +1 -0
- package/dist/packages.d.ts +2 -17
- package/dist/packages.js +2 -1
- package/dist/paths/dirnames.d.ts +0 -2
- package/dist/paths/dirnames.js +1 -0
- package/dist/paths/exts.d.ts +0 -1
- package/dist/paths/exts.js +1 -0
- package/dist/paths/filenames.d.ts +0 -1
- package/dist/paths/filenames.js +1 -0
- package/dist/paths/globs.d.ts +0 -1
- package/dist/paths/globs.js +1 -0
- package/dist/paths/normalize.d.ts +115 -123
- package/dist/paths/normalize.js +128 -127
- package/dist/paths/packages.d.ts +3 -2
- package/dist/paths/packages.js +2 -1
- package/dist/paths/rewire.d.ts +9 -0
- package/dist/paths/rewire.js +5 -3
- package/dist/paths/socket.d.ts +37 -23
- package/dist/paths/socket.js +26 -25
- package/dist/performance.d.ts +87 -84
- package/dist/performance.js +97 -96
- package/dist/process-lock.d.ts +41 -1
- package/dist/process-lock.js +24 -17
- package/dist/promise-queue.d.ts +6 -0
- package/dist/promise-queue.js +1 -0
- package/dist/promises.d.ts +40 -55
- package/dist/promises.js +12 -11
- package/dist/regexps.d.ts +0 -5
- package/dist/regexps.js +1 -0
- package/dist/releases/github.d.ts +59 -63
- package/dist/releases/github.js +95 -100
- package/dist/releases/socket-btm.d.ts +9 -2
- package/dist/releases/socket-btm.js +32 -25
- package/dist/sea.d.ts +5 -0
- package/dist/sea.js +1 -0
- package/dist/shadow.d.ts +4 -0
- package/dist/shadow.js +1 -0
- package/dist/signal-exit.d.ts +7 -7
- package/dist/signal-exit.js +46 -45
- package/dist/sorts.d.ts +5 -7
- package/dist/sorts.js +11 -10
- package/dist/spawn.d.ts +96 -77
- package/dist/spawn.js +39 -38
- package/dist/spinner.d.ts +21 -22
- package/dist/spinner.js +15 -11
- package/dist/ssri.d.ts +31 -36
- package/dist/ssri.js +15 -14
- package/dist/stdio/_stream.d.ts +31 -0
- package/dist/stdio/_stream.js +57 -0
- package/dist/stdio/clear.d.ts +38 -15
- package/dist/stdio/clear.js +5 -4
- package/dist/stdio/divider.d.ts +40 -36
- package/dist/stdio/divider.js +10 -9
- package/dist/stdio/footer.d.ts +20 -0
- package/dist/stdio/footer.js +12 -2
- package/dist/stdio/header.d.ts +4 -16
- package/dist/stdio/header.js +1 -9
- package/dist/stdio/progress.d.ts +4 -0
- package/dist/stdio/progress.js +13 -8
- package/dist/stdio/prompts.d.ts +24 -23
- package/dist/stdio/prompts.js +10 -9
- package/dist/stdio/stderr.d.ts +51 -39
- package/dist/stdio/stderr.js +19 -22
- package/dist/stdio/stdout.d.ts +54 -52
- package/dist/stdio/stdout.js +35 -33
- package/dist/streams.d.ts +4 -3
- package/dist/streams.js +1 -0
- package/dist/strings.d.ts +31 -85
- package/dist/strings.js +5 -49
- package/dist/suppress-warnings.d.ts +32 -15
- package/dist/suppress-warnings.js +14 -13
- package/dist/tables.d.ts +30 -26
- package/dist/tables.js +24 -23
- package/dist/temporary-executor.d.ts +4 -0
- package/dist/temporary-executor.js +1 -0
- package/dist/themes/context.d.ts +30 -26
- package/dist/themes/context.js +19 -18
- package/dist/themes/index.d.ts +0 -4
- package/dist/themes/index.js +1 -0
- package/dist/themes/themes.d.ts +1 -1
- package/dist/themes/themes.js +1 -0
- package/dist/themes/types.js +1 -0
- package/dist/themes/utils.d.ts +46 -43
- package/dist/themes/utils.js +45 -44
- package/dist/types.d.ts +48 -52
- package/dist/types.js +35 -35
- package/dist/url.d.ts +48 -53
- package/dist/url.js +38 -37
- package/dist/validation/json-parser.d.ts +19 -190
- package/dist/validation/json-parser.js +5 -69
- package/dist/validation/types.d.ts +9 -33
- package/dist/validation/types.js +1 -0
- package/dist/versions.d.ts +1 -0
- package/dist/versions.js +2 -1
- package/dist/words.d.ts +3 -6
- package/dist/words.js +1 -0
- package/dist/zod.js +1 -0
- package/package.json +40 -54
- package/dist/functions.d.ts +0 -57
- package/dist/functions.js +0 -70
- package/dist/stdio/mask.d.ts +0 -151
- package/dist/stdio/mask.js +0 -224
- package/dist/utils/get-ipc.d.ts +0 -15
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -64,13 +65,12 @@ function setupSuppression() {
|
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
setupSuppression();
|
|
68
|
+
function restoreWarnings() {
|
|
69
|
+
if (originalEmitWarning) {
|
|
70
|
+
import_node_process.default.emitWarning = originalEmitWarning;
|
|
71
|
+
originalEmitWarning = void 0;
|
|
72
|
+
suppressedWarnings.clear();
|
|
73
|
+
}
|
|
74
74
|
}
|
|
75
75
|
function setMaxEventTargetListeners(target, maxListeners = 10) {
|
|
76
76
|
if (!target) {
|
|
@@ -85,12 +85,13 @@ function setMaxEventTargetListeners(target, maxListeners = 10) {
|
|
|
85
85
|
target[kMaxEventTargetListeners] = maxListeners;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
function suppressMaxListenersWarning() {
|
|
89
|
+
suppressedWarnings.add("MaxListenersExceededWarning");
|
|
90
|
+
setupSuppression();
|
|
91
|
+
}
|
|
92
|
+
function suppressWarningType(warningType) {
|
|
93
|
+
suppressedWarnings.add(warningType);
|
|
94
|
+
setupSuppression();
|
|
94
95
|
}
|
|
95
96
|
async function withSuppressedWarnings(warningType, callback) {
|
|
96
97
|
const wasAlreadySuppressed = suppressedWarnings.has(warningType);
|
package/dist/tables.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Table formatting utilities for CLI applications.
|
|
3
|
+
* Provides ASCII table rendering with borders, alignment, and colors.
|
|
4
|
+
*/
|
|
1
5
|
export type ColumnAlignment = 'left' | 'right' | 'center';
|
|
2
6
|
/**
|
|
3
7
|
* Table column configuration.
|
|
@@ -10,60 +14,60 @@ export type TableColumn = {
|
|
|
10
14
|
color?: ((value: string) => string) | undefined;
|
|
11
15
|
};
|
|
12
16
|
/**
|
|
13
|
-
* Format data as
|
|
17
|
+
* Format data as a simple table without borders.
|
|
18
|
+
* Lighter weight alternative to formatTable().
|
|
14
19
|
*
|
|
15
20
|
* @param data - Array of data objects
|
|
16
21
|
* @param columns - Column configuration
|
|
17
22
|
* @returns Formatted table string
|
|
18
23
|
*
|
|
19
24
|
* @example
|
|
20
|
-
* import {
|
|
25
|
+
* import { formatSimpleTable } from '@socketsecurity/lib/tables'
|
|
21
26
|
* import colors from 'yoctocolors-cjs'
|
|
22
27
|
*
|
|
23
28
|
* const data = [
|
|
24
|
-
* { name: 'lodash', version: '4.17.21'
|
|
25
|
-
* { name: 'react', version: '18.2.0'
|
|
29
|
+
* { name: 'lodash', version: '4.17.21' },
|
|
30
|
+
* { name: 'react', version: '18.2.0' },
|
|
26
31
|
* ]
|
|
27
32
|
* const columns = [
|
|
28
33
|
* { key: 'name', header: 'Package' },
|
|
29
|
-
* { key: 'version', header: 'Version'
|
|
30
|
-
* { key: 'issues', header: 'Issues', align: 'right', color: (v) => v === '0' ? colors.green(v) : colors.red(v) },
|
|
34
|
+
* { key: 'version', header: 'Version' },
|
|
31
35
|
* ]
|
|
32
|
-
* console.log(
|
|
36
|
+
* console.log(formatSimpleTable(data, columns))
|
|
33
37
|
* // Output:
|
|
34
|
-
* //
|
|
35
|
-
* //
|
|
36
|
-
* //
|
|
37
|
-
* //
|
|
38
|
-
* // │ react │ 18.2.0 │ 2 │
|
|
39
|
-
* // └─────────┴─────────┴────────┘
|
|
38
|
+
* // Package Version
|
|
39
|
+
* // ─────── ───────
|
|
40
|
+
* // lodash 4.17.21
|
|
41
|
+
* // react 18.2.0
|
|
40
42
|
*/
|
|
41
|
-
export declare function
|
|
43
|
+
export declare function formatSimpleTable(data: Array<Record<string, unknown>>, columns: TableColumn[]): string;
|
|
42
44
|
/**
|
|
43
|
-
* Format data as
|
|
44
|
-
* Lighter weight alternative to formatTable().
|
|
45
|
+
* Format data as an ASCII table with borders.
|
|
45
46
|
*
|
|
46
47
|
* @param data - Array of data objects
|
|
47
48
|
* @param columns - Column configuration
|
|
48
49
|
* @returns Formatted table string
|
|
49
50
|
*
|
|
50
51
|
* @example
|
|
51
|
-
* import {
|
|
52
|
+
* import { formatTable } from '@socketsecurity/lib/tables'
|
|
52
53
|
* import colors from 'yoctocolors-cjs'
|
|
53
54
|
*
|
|
54
55
|
* const data = [
|
|
55
|
-
* { name: 'lodash', version: '4.17.21' },
|
|
56
|
-
* { name: 'react', version: '18.2.0' },
|
|
56
|
+
* { name: 'lodash', version: '4.17.21', issues: 0 },
|
|
57
|
+
* { name: 'react', version: '18.2.0', issues: 2 },
|
|
57
58
|
* ]
|
|
58
59
|
* const columns = [
|
|
59
60
|
* { key: 'name', header: 'Package' },
|
|
60
|
-
* { key: 'version', header: 'Version' },
|
|
61
|
+
* { key: 'version', header: 'Version', align: 'center' },
|
|
62
|
+
* { key: 'issues', header: 'Issues', align: 'right', color: (v) => v === '0' ? colors.green(v) : colors.red(v) },
|
|
61
63
|
* ]
|
|
62
|
-
* console.log(
|
|
64
|
+
* console.log(formatTable(data, columns))
|
|
63
65
|
* // Output:
|
|
64
|
-
* //
|
|
65
|
-
* //
|
|
66
|
-
* //
|
|
67
|
-
* //
|
|
66
|
+
* // ┌─────────┬─────────┬────────┐
|
|
67
|
+
* // │ Package │ Version │ Issues │
|
|
68
|
+
* // ├─────────┼─────────┼────────┤
|
|
69
|
+
* // │ lodash │ 4.17.21 │ 0 │
|
|
70
|
+
* // │ react │ 18.2.0 │ 2 │
|
|
71
|
+
* // └─────────┴─────────┴────────┘
|
|
68
72
|
*/
|
|
69
|
-
export declare function
|
|
73
|
+
export declare function formatTable(data: Array<Record<string, unknown>>, columns: TableColumn[]): string;
|
package/dist/tables.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -54,7 +55,7 @@ function padText(text, width, align = "left") {
|
|
|
54
55
|
return text + " ".repeat(padding);
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
+
function formatSimpleTable(data, columns) {
|
|
58
59
|
if (data.length === 0) {
|
|
59
60
|
return "(no data)";
|
|
60
61
|
}
|
|
@@ -66,17 +67,12 @@ function formatTable(data, columns) {
|
|
|
66
67
|
return col.width ?? Math.max(headerWidth, maxDataWidth);
|
|
67
68
|
});
|
|
68
69
|
const lines = [];
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const headerCells = columns.map((col, i) => {
|
|
72
|
-
const text = import_yoctocolors_cjs.default.bold(col.header);
|
|
73
|
-
return padText(text, widths[i], col.align);
|
|
74
|
-
});
|
|
75
|
-
lines.push(
|
|
76
|
-
import_yoctocolors_cjs.default.dim("\u2502 ") + headerCells.join(import_yoctocolors_cjs.default.dim(" \u2502 ")) + import_yoctocolors_cjs.default.dim(" \u2502")
|
|
70
|
+
const headerCells = columns.map(
|
|
71
|
+
(col, i) => padText(import_yoctocolors_cjs.default.bold(col.header), widths[i], col.align)
|
|
77
72
|
);
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
lines.push(headerCells.join(" "));
|
|
74
|
+
const separators = widths.map((w) => import_yoctocolors_cjs.default.dim("\u2500".repeat(w)));
|
|
75
|
+
lines.push(separators.join(" "));
|
|
80
76
|
for (const row of data) {
|
|
81
77
|
const cells = columns.map((col, i) => {
|
|
82
78
|
let value = String(row[col.key] ?? "");
|
|
@@ -85,15 +81,11 @@ function formatTable(data, columns) {
|
|
|
85
81
|
}
|
|
86
82
|
return padText(value, widths[i], col.align);
|
|
87
83
|
});
|
|
88
|
-
lines.push(
|
|
89
|
-
import_yoctocolors_cjs.default.dim("\u2502 ") + cells.join(import_yoctocolors_cjs.default.dim(" \u2502 ")) + import_yoctocolors_cjs.default.dim(" \u2502")
|
|
90
|
-
);
|
|
84
|
+
lines.push(cells.join(" "));
|
|
91
85
|
}
|
|
92
|
-
const bottomBorder = `\u2514\u2500${widths.map((w) => "\u2500".repeat(w)).join("\u2500\u2534\u2500")}\u2500\u2518`;
|
|
93
|
-
lines.push(import_yoctocolors_cjs.default.dim(bottomBorder));
|
|
94
86
|
return lines.join("\n");
|
|
95
87
|
}
|
|
96
|
-
function
|
|
88
|
+
function formatTable(data, columns) {
|
|
97
89
|
if (data.length === 0) {
|
|
98
90
|
return "(no data)";
|
|
99
91
|
}
|
|
@@ -105,12 +97,17 @@ function formatSimpleTable(data, columns) {
|
|
|
105
97
|
return col.width ?? Math.max(headerWidth, maxDataWidth);
|
|
106
98
|
});
|
|
107
99
|
const lines = [];
|
|
108
|
-
const
|
|
109
|
-
|
|
100
|
+
const topBorder = `\u250C\u2500${widths.map((w) => "\u2500".repeat(w)).join("\u2500\u252C\u2500")}\u2500\u2510`;
|
|
101
|
+
lines.push(import_yoctocolors_cjs.default.dim(topBorder));
|
|
102
|
+
const headerCells = columns.map((col, i) => {
|
|
103
|
+
const text = import_yoctocolors_cjs.default.bold(col.header);
|
|
104
|
+
return padText(text, widths[i], col.align);
|
|
105
|
+
});
|
|
106
|
+
lines.push(
|
|
107
|
+
import_yoctocolors_cjs.default.dim("\u2502 ") + headerCells.join(import_yoctocolors_cjs.default.dim(" \u2502 ")) + import_yoctocolors_cjs.default.dim(" \u2502")
|
|
110
108
|
);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
lines.push(separators.join(" "));
|
|
109
|
+
const headerSep = `\u251C\u2500${widths.map((w) => "\u2500".repeat(w)).join("\u2500\u253C\u2500")}\u2500\u2524`;
|
|
110
|
+
lines.push(import_yoctocolors_cjs.default.dim(headerSep));
|
|
114
111
|
for (const row of data) {
|
|
115
112
|
const cells = columns.map((col, i) => {
|
|
116
113
|
let value = String(row[col.key] ?? "");
|
|
@@ -119,8 +116,12 @@ function formatSimpleTable(data, columns) {
|
|
|
119
116
|
}
|
|
120
117
|
return padText(value, widths[i], col.align);
|
|
121
118
|
});
|
|
122
|
-
lines.push(
|
|
119
|
+
lines.push(
|
|
120
|
+
import_yoctocolors_cjs.default.dim("\u2502 ") + cells.join(import_yoctocolors_cjs.default.dim(" \u2502 ")) + import_yoctocolors_cjs.default.dim(" \u2502")
|
|
121
|
+
);
|
|
123
122
|
}
|
|
123
|
+
const bottomBorder = `\u2514\u2500${widths.map((w) => "\u2500".repeat(w)).join("\u2500\u2534\u2500")}\u2500\u2518`;
|
|
124
|
+
lines.push(import_yoctocolors_cjs.default.dim(bottomBorder));
|
|
124
125
|
return lines.join("\n");
|
|
125
126
|
}
|
|
126
127
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Temporary package executor detection utilities for Socket ecosystem.
|
|
3
|
+
* Identifies and handles temporary execution contexts such as npx, pnpm dlx, and yarn dlx.
|
|
4
|
+
*/
|
|
1
5
|
/**
|
|
2
6
|
* Detects if the current process is running in a temporary package execution context
|
|
3
7
|
* such as npm exec, npx, pnpm dlx, or yarn dlx.
|
package/dist/themes/context.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Elegant theme context management.
|
|
3
|
+
* Async-aware theming with automatic context isolation via AsyncLocalStorage.
|
|
4
|
+
*/
|
|
1
5
|
import type { Theme } from './types';
|
|
2
6
|
import { type ThemeName } from './themes';
|
|
3
7
|
/**
|
|
@@ -5,28 +9,45 @@ import { type ThemeName } from './themes';
|
|
|
5
9
|
*/
|
|
6
10
|
export type ThemeChangeListener = (theme: Theme) => void;
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
12
|
+
* Get the active theme from context.
|
|
9
13
|
*
|
|
10
|
-
* @
|
|
14
|
+
* @returns Current theme
|
|
11
15
|
*
|
|
12
16
|
* @example
|
|
13
17
|
* ```ts
|
|
14
|
-
*
|
|
18
|
+
* const theme = getTheme()
|
|
19
|
+
* console.log(theme.displayName)
|
|
15
20
|
* ```
|
|
16
21
|
*/
|
|
17
|
-
export declare function
|
|
22
|
+
export declare function getTheme(): Theme;
|
|
18
23
|
/**
|
|
19
|
-
*
|
|
24
|
+
* Subscribe to theme change events.
|
|
20
25
|
*
|
|
21
|
-
* @
|
|
26
|
+
* @param listener - Change handler
|
|
27
|
+
* @returns Unsubscribe function
|
|
22
28
|
*
|
|
23
29
|
* @example
|
|
24
30
|
* ```ts
|
|
25
|
-
* const
|
|
26
|
-
*
|
|
31
|
+
* const unsubscribe = onThemeChange((theme) => {
|
|
32
|
+
* console.log('Theme:', theme.displayName)
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* // Cleanup
|
|
36
|
+
* unsubscribe()
|
|
27
37
|
* ```
|
|
28
38
|
*/
|
|
29
|
-
export declare function
|
|
39
|
+
export declare function onThemeChange(listener: ThemeChangeListener): () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Set the global fallback theme.
|
|
42
|
+
*
|
|
43
|
+
* @param theme - Theme name or object
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* setTheme('socket-firewall')
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function setTheme(theme: Theme | ThemeName): void;
|
|
30
51
|
/**
|
|
31
52
|
* Execute async operation with scoped theme.
|
|
32
53
|
* Theme automatically restored on completion.
|
|
@@ -61,20 +82,3 @@ export declare function withTheme<T>(theme: Theme | ThemeName, fn: () => Promise
|
|
|
61
82
|
* ```
|
|
62
83
|
*/
|
|
63
84
|
export declare function withThemeSync<T>(theme: Theme | ThemeName, fn: () => T): T;
|
|
64
|
-
/**
|
|
65
|
-
* Subscribe to theme change events.
|
|
66
|
-
*
|
|
67
|
-
* @param listener - Change handler
|
|
68
|
-
* @returns Unsubscribe function
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```ts
|
|
72
|
-
* const unsubscribe = onThemeChange((theme) => {
|
|
73
|
-
* console.log('Theme:', theme.displayName)
|
|
74
|
-
* })
|
|
75
|
-
*
|
|
76
|
-
* // Cleanup
|
|
77
|
-
* unsubscribe()
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
export declare function onThemeChange(listener: ThemeChangeListener): () => void;
|
package/dist/themes/context.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -28,10 +29,15 @@ __export(context_exports, {
|
|
|
28
29
|
module.exports = __toCommonJS(context_exports);
|
|
29
30
|
var import_themes = require("./themes");
|
|
30
31
|
let _async_hooks;
|
|
32
|
+
function emitThemeChange(theme) {
|
|
33
|
+
for (const listener of listeners) {
|
|
34
|
+
listener(theme);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
31
37
|
// @__NO_SIDE_EFFECTS__
|
|
32
38
|
function getAsyncHooks() {
|
|
33
39
|
if (_async_hooks === void 0) {
|
|
34
|
-
_async_hooks = require("async_hooks");
|
|
40
|
+
_async_hooks = require("node:async_hooks");
|
|
35
41
|
}
|
|
36
42
|
return _async_hooks;
|
|
37
43
|
}
|
|
@@ -39,38 +45,33 @@ const { AsyncLocalStorage } = /* @__PURE__ */ getAsyncHooks();
|
|
|
39
45
|
const themeStorage = new AsyncLocalStorage();
|
|
40
46
|
let fallbackTheme = import_themes.SOCKET_THEME;
|
|
41
47
|
const listeners = /* @__PURE__ */ new Set();
|
|
42
|
-
function setTheme(theme) {
|
|
43
|
-
fallbackTheme = typeof theme === "string" ? import_themes.THEMES[theme] : theme;
|
|
44
|
-
emitThemeChange(fallbackTheme);
|
|
45
|
-
}
|
|
46
48
|
function getTheme() {
|
|
47
49
|
return themeStorage.getStore() ?? fallbackTheme;
|
|
48
50
|
}
|
|
51
|
+
function onThemeChange(listener) {
|
|
52
|
+
listeners.add(listener);
|
|
53
|
+
return () => {
|
|
54
|
+
listeners.delete(listener);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function setTheme(theme) {
|
|
58
|
+
fallbackTheme = typeof theme === "string" ? import_themes.THEMES[theme] ?? fallbackTheme : theme;
|
|
59
|
+
emitThemeChange(fallbackTheme);
|
|
60
|
+
}
|
|
49
61
|
async function withTheme(theme, fn) {
|
|
50
|
-
const resolvedTheme = typeof theme === "string" ? import_themes.THEMES[theme] : theme;
|
|
62
|
+
const resolvedTheme = typeof theme === "string" ? import_themes.THEMES[theme] ?? fallbackTheme : theme;
|
|
51
63
|
return await themeStorage.run(resolvedTheme, async () => {
|
|
52
64
|
emitThemeChange(resolvedTheme);
|
|
53
65
|
return await fn();
|
|
54
66
|
});
|
|
55
67
|
}
|
|
56
68
|
function withThemeSync(theme, fn) {
|
|
57
|
-
const resolvedTheme = typeof theme === "string" ? import_themes.THEMES[theme] : theme;
|
|
69
|
+
const resolvedTheme = typeof theme === "string" ? import_themes.THEMES[theme] ?? fallbackTheme : theme;
|
|
58
70
|
return themeStorage.run(resolvedTheme, () => {
|
|
59
71
|
emitThemeChange(resolvedTheme);
|
|
60
72
|
return fn();
|
|
61
73
|
});
|
|
62
74
|
}
|
|
63
|
-
function onThemeChange(listener) {
|
|
64
|
-
listeners.add(listener);
|
|
65
|
-
return () => {
|
|
66
|
-
listeners.delete(listener);
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function emitThemeChange(theme) {
|
|
70
|
-
for (const listener of listeners) {
|
|
71
|
-
listener(theme);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
75
|
// Annotate the CommonJS export names for ESM import in node:
|
|
75
76
|
0 && (module.exports = {
|
|
76
77
|
getTheme,
|
package/dist/themes/index.d.ts
CHANGED
|
@@ -43,11 +43,7 @@
|
|
|
43
43
|
* })
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
// Type system
|
|
47
46
|
export type { ColorReference, Theme, ThemeColors, ThemeEffects, ThemeMeta, } from './types';
|
|
48
|
-
// Curated themes
|
|
49
47
|
export { LUSH_THEME, SOCKET_THEME, SUNSET_THEME, TERRACOTTA_THEME, THEMES, ULTRA_THEME, type ThemeName, } from './themes';
|
|
50
|
-
// Context management
|
|
51
48
|
export { getTheme, onThemeChange, setTheme, withTheme, withThemeSync, type ThemeChangeListener, } from './context';
|
|
52
|
-
// Composition utilities
|
|
53
49
|
export { createTheme, extendTheme, resolveColor, resolveShimmerColor, } from './utils';
|
package/dist/themes/index.js
CHANGED
package/dist/themes/themes.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare const ULTRA_THEME: Theme;
|
|
|
36
36
|
* Theme registry — Curated palette collection.
|
|
37
37
|
*/
|
|
38
38
|
export declare const THEMES: {
|
|
39
|
-
readonly __proto__:
|
|
39
|
+
readonly __proto__: null;
|
|
40
40
|
readonly socket: Theme;
|
|
41
41
|
readonly sunset: Theme;
|
|
42
42
|
readonly terracotta: Theme;
|
package/dist/themes/themes.js
CHANGED
package/dist/themes/types.js
CHANGED
package/dist/themes/utils.d.ts
CHANGED
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import type { ColorValue } from '../colors';
|
|
2
|
-
import type { ShimmerColorGradient } from '../effects/text-shimmer';
|
|
3
|
-
import type { Theme, ThemeColors, ColorReference } from './types';
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Handles semantic keywords: 'primary', 'secondary', 'rainbow', 'inherit'
|
|
7
|
-
*
|
|
8
|
-
* @param value - Color reference
|
|
9
|
-
* @param colors - Theme palette
|
|
10
|
-
* @returns Resolved color
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* resolveColor('primary', theme.colors)
|
|
15
|
-
* resolveColor([255, 0, 0], theme.colors)
|
|
16
|
-
* ```
|
|
2
|
+
* @fileoverview Theme utilities — color resolution and composition.
|
|
17
3
|
*/
|
|
18
|
-
|
|
4
|
+
import type { ColorValue } from '../colors';
|
|
5
|
+
import type { ShimmerColorGradient } from '../effects/text-shimmer';
|
|
6
|
+
import type { ColorReference, Theme, ThemeColors } from './types';
|
|
19
7
|
/**
|
|
20
|
-
*
|
|
8
|
+
* Create new theme from complete specification.
|
|
21
9
|
*
|
|
22
|
-
* @param
|
|
23
|
-
* @
|
|
24
|
-
* @returns Resolved color
|
|
10
|
+
* @param config - Theme configuration
|
|
11
|
+
* @returns Theme object
|
|
25
12
|
*
|
|
26
13
|
* @example
|
|
27
14
|
* ```ts
|
|
28
|
-
*
|
|
29
|
-
*
|
|
15
|
+
* const theme = createTheme({
|
|
16
|
+
* name: 'custom',
|
|
17
|
+
* displayName: 'Custom',
|
|
18
|
+
* colors: {
|
|
19
|
+
* primary: [255, 100, 200],
|
|
20
|
+
* success: 'greenBright',
|
|
21
|
+
* error: 'redBright',
|
|
22
|
+
* warning: 'yellowBright',
|
|
23
|
+
* info: 'blueBright',
|
|
24
|
+
* step: 'cyanBright',
|
|
25
|
+
* text: 'white',
|
|
26
|
+
* textDim: 'gray',
|
|
27
|
+
* link: 'cyanBright',
|
|
28
|
+
* prompt: 'primary'
|
|
29
|
+
* }
|
|
30
|
+
* })
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
export declare function
|
|
33
|
+
export declare function createTheme(config: Pick<Theme, 'name' | 'displayName' | 'colors'> & Partial<Omit<Theme, 'name' | 'displayName' | 'colors'>>): Theme;
|
|
33
34
|
/**
|
|
34
35
|
* Extend existing theme with custom overrides.
|
|
35
36
|
* Deep merge of colors and effects.
|
|
@@ -50,29 +51,31 @@ export declare function extendTheme(base: Theme, overrides: Partial<Omit<Theme,
|
|
|
50
51
|
colors?: Partial<ThemeColors> | undefined;
|
|
51
52
|
}): Theme;
|
|
52
53
|
/**
|
|
53
|
-
*
|
|
54
|
+
* Resolve color reference to concrete value.
|
|
55
|
+
* Handles semantic keywords: 'primary', 'secondary', 'rainbow', 'inherit'
|
|
54
56
|
*
|
|
55
|
-
* @param
|
|
56
|
-
* @
|
|
57
|
+
* @param value - Color reference
|
|
58
|
+
* @param colors - Theme palette
|
|
59
|
+
* @returns Resolved color
|
|
57
60
|
*
|
|
58
61
|
* @example
|
|
59
62
|
* ```ts
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* displayName: 'Custom',
|
|
63
|
-
* colors: {
|
|
64
|
-
* primary: [255, 100, 200],
|
|
65
|
-
* success: 'greenBright',
|
|
66
|
-
* error: 'redBright',
|
|
67
|
-
* warning: 'yellowBright',
|
|
68
|
-
* info: 'blueBright',
|
|
69
|
-
* step: 'cyanBright',
|
|
70
|
-
* text: 'white',
|
|
71
|
-
* textDim: 'gray',
|
|
72
|
-
* link: 'cyanBright',
|
|
73
|
-
* prompt: 'primary'
|
|
74
|
-
* }
|
|
75
|
-
* })
|
|
63
|
+
* resolveColor('primary', theme.colors)
|
|
64
|
+
* resolveColor([255, 0, 0], theme.colors)
|
|
76
65
|
* ```
|
|
77
66
|
*/
|
|
78
|
-
export declare function
|
|
67
|
+
export declare function resolveColor(value: ColorReference | ColorValue, colors: ThemeColors): ColorValue | 'inherit' | ShimmerColorGradient;
|
|
68
|
+
/**
|
|
69
|
+
* Resolve shimmer color with gradient support.
|
|
70
|
+
*
|
|
71
|
+
* @param value - Shimmer color
|
|
72
|
+
* @param theme - Theme context
|
|
73
|
+
* @returns Resolved color
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* resolveShimmerColor('rainbow', theme)
|
|
78
|
+
* resolveShimmerColor('primary', theme)
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolveShimmerColor(value: ColorReference | ColorValue[] | undefined, theme: Theme): ColorValue | ShimmerColorGradient | 'inherit';
|