@socketsecurity/lib 2.10.3 → 3.0.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 +38 -0
- package/README.md +231 -40
- package/dist/constants/platform.js +1 -1
- package/dist/constants/platform.js.map +3 -3
- package/dist/cover/code.js +1 -1
- package/dist/cover/code.js.map +3 -3
- package/dist/debug.js +2 -2
- package/dist/debug.js.map +3 -3
- package/dist/dlx-binary.d.ts +29 -6
- package/dist/dlx-binary.js +7 -7
- package/dist/dlx-binary.js.map +3 -3
- package/dist/dlx-package.d.ts +16 -1
- package/dist/dlx-package.js +7 -7
- package/dist/dlx-package.js.map +3 -3
- package/dist/dlx.js +4 -4
- package/dist/dlx.js.map +3 -3
- package/dist/env/rewire.js +1 -1
- package/dist/env/rewire.js.map +3 -3
- package/dist/env/socket-cli.d.ts +7 -0
- package/dist/env/socket-cli.js +1 -1
- package/dist/env/socket-cli.js.map +2 -2
- package/dist/external/yoctocolors-cjs.d.ts +14 -0
- package/dist/fs.d.ts +82 -27
- package/dist/fs.js +7 -7
- package/dist/fs.js.map +3 -3
- package/dist/git.js +1 -1
- package/dist/git.js.map +3 -3
- package/dist/http-request.js +1 -1
- package/dist/http-request.js.map +3 -3
- package/dist/ipc.js +1 -1
- package/dist/ipc.js.map +3 -3
- package/dist/links/index.d.ts +65 -0
- package/dist/links/index.js +3 -0
- package/dist/links/index.js.map +7 -0
- package/dist/logger.d.ts +21 -18
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +3 -3
- package/dist/packages/isolation.js +1 -1
- package/dist/packages/isolation.js.map +3 -3
- package/dist/paths.js +1 -1
- package/dist/paths.js.map +2 -2
- package/dist/process-lock.js +2 -2
- package/dist/process-lock.js.map +3 -3
- package/dist/promises.d.ts +6 -21
- package/dist/promises.js +1 -1
- package/dist/promises.js.map +2 -2
- package/dist/prompts/index.d.ts +115 -0
- package/dist/prompts/index.js +3 -0
- package/dist/prompts/index.js.map +7 -0
- package/dist/spinner.d.ts +33 -23
- package/dist/spinner.js +1 -1
- package/dist/spinner.js.map +3 -3
- package/dist/stdio/mask.d.ts +2 -2
- package/dist/stdio/mask.js +4 -4
- package/dist/stdio/mask.js.map +3 -3
- package/dist/stdio/stdout.js +1 -1
- package/dist/stdio/stdout.js.map +3 -3
- package/dist/themes/context.d.ts +80 -0
- package/dist/themes/context.js +3 -0
- package/dist/themes/context.js.map +7 -0
- package/dist/themes/index.d.ts +53 -0
- package/dist/themes/index.js +3 -0
- package/dist/themes/index.js.map +7 -0
- package/dist/themes/themes.d.ts +49 -0
- package/dist/themes/themes.js +3 -0
- package/dist/themes/themes.js.map +7 -0
- package/dist/themes/types.d.ts +92 -0
- package/dist/themes/types.js +3 -0
- package/dist/themes/types.js.map +7 -0
- package/dist/themes/utils.d.ts +78 -0
- package/dist/themes/utils.js +3 -0
- package/dist/themes/utils.js.map +7 -0
- package/package.json +40 -8
- package/dist/download-lock.d.ts +0 -49
- package/dist/download-lock.js +0 -10
- package/dist/download-lock.js.map +0 -7
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Theme } from './types';
|
|
2
|
+
import { type ThemeName } from './themes';
|
|
3
|
+
/**
|
|
4
|
+
* Theme change event listener signature.
|
|
5
|
+
*/
|
|
6
|
+
export type ThemeChangeListener = (theme: Theme) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Set the global fallback theme.
|
|
9
|
+
*
|
|
10
|
+
* @param theme - Theme name or object
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* setTheme('socket-firewall')
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function setTheme(theme: Theme | ThemeName): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get the active theme from context.
|
|
20
|
+
*
|
|
21
|
+
* @returns Current theme
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const theme = getTheme()
|
|
26
|
+
* console.log(theme.displayName)
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function getTheme(): Theme;
|
|
30
|
+
/**
|
|
31
|
+
* Execute async operation with scoped theme.
|
|
32
|
+
* Theme automatically restored on completion.
|
|
33
|
+
*
|
|
34
|
+
* @template T - Return type
|
|
35
|
+
* @param theme - Scoped theme
|
|
36
|
+
* @param fn - Async operation
|
|
37
|
+
* @returns Operation result
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* await withTheme('ultra', async () => {
|
|
42
|
+
* // Operations use Ultra theme
|
|
43
|
+
* })
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function withTheme<T>(theme: Theme | ThemeName, fn: () => Promise<T>): Promise<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Execute sync operation with scoped theme.
|
|
49
|
+
* Theme automatically restored on completion.
|
|
50
|
+
*
|
|
51
|
+
* @template T - Return type
|
|
52
|
+
* @param theme - Scoped theme
|
|
53
|
+
* @param fn - Sync operation
|
|
54
|
+
* @returns Operation result
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const result = withThemeSync('coana', () => {
|
|
59
|
+
* return processData()
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
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;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var m=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},y=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!u.call(e,r)&&r!==n&&m(e,r,{get:()=>t[r],enumerable:!(a=p(t,r))||a.enumerable});return e};var d=e=>y(m({},"__esModule",{value:!0}),e);var C={};g(C,{getTheme:()=>S,onThemeChange:()=>x,setTheme:()=>l,withTheme:()=>v,withThemeSync:()=>w});module.exports=d(C);var c=require("node:async_hooks"),o=require("./themes");const i=new c.AsyncLocalStorage;let T=o.SOCKET_THEME;const h=new Set;function l(e){T=typeof e=="string"?o.THEMES[e]:e,s(T)}function S(){return i.getStore()??T}async function v(e,t){const n=typeof e=="string"?o.THEMES[e]:e;return await i.run(n,async()=>(s(n),await t()))}function w(e,t){const n=typeof e=="string"?o.THEMES[e]:e;return i.run(n,()=>(s(n),t()))}function x(e){return h.add(e),()=>{h.delete(e)}}function s(e){for(const t of h)t(e)}0&&(module.exports={getTheme,onThemeChange,setTheme,withTheme,withThemeSync});
|
|
3
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/themes/context.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Elegant theme context management.\n * Async-aware theming with automatic context isolation via AsyncLocalStorage.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks'\n\nimport type { Theme } from './types'\nimport { SOCKET_THEME, THEMES, type ThemeName } from './themes'\n\n/**\n * Theme change event listener signature.\n */\nexport type ThemeChangeListener = (theme: Theme) => void\n\n/**\n * AsyncLocalStorage for theme context isolation.\n */\nconst themeStorage = new AsyncLocalStorage<Theme>()\n\n/**\n * Fallback theme for global context.\n */\nlet fallbackTheme: Theme = SOCKET_THEME\n\n/**\n * Registered theme change listeners.\n */\nconst listeners: Set<ThemeChangeListener> = new Set()\n\n/**\n * Set the global fallback theme.\n *\n * @param theme - Theme name or object\n *\n * @example\n * ```ts\n * setTheme('socket-firewall')\n * ```\n */\nexport function setTheme(theme: Theme | ThemeName): void {\n fallbackTheme = typeof theme === 'string' ? THEMES[theme] : theme\n emitThemeChange(fallbackTheme)\n}\n\n/**\n * Get the active theme from context.\n *\n * @returns Current theme\n *\n * @example\n * ```ts\n * const theme = getTheme()\n * console.log(theme.displayName)\n * ```\n */\nexport function getTheme(): Theme {\n return themeStorage.getStore() ?? fallbackTheme\n}\n\n/**\n * Execute async operation with scoped theme.\n * Theme automatically restored on completion.\n *\n * @template T - Return type\n * @param theme - Scoped theme\n * @param fn - Async operation\n * @returns Operation result\n *\n * @example\n * ```ts\n * await withTheme('ultra', async () => {\n * // Operations use Ultra theme\n * })\n * ```\n */\nexport async function withTheme<T>(\n theme: Theme | ThemeName,\n fn: () => Promise<T>,\n): Promise<T> {\n const resolvedTheme = typeof theme === 'string' ? THEMES[theme] : theme\n return await themeStorage.run(resolvedTheme, async () => {\n emitThemeChange(resolvedTheme)\n return await fn()\n })\n}\n\n/**\n * Execute sync operation with scoped theme.\n * Theme automatically restored on completion.\n *\n * @template T - Return type\n * @param theme - Scoped theme\n * @param fn - Sync operation\n * @returns Operation result\n *\n * @example\n * ```ts\n * const result = withThemeSync('coana', () => {\n * return processData()\n * })\n * ```\n */\nexport function withThemeSync<T>(theme: Theme | ThemeName, fn: () => T): T {\n const resolvedTheme = typeof theme === 'string' ? THEMES[theme] : theme\n return themeStorage.run(resolvedTheme, () => {\n emitThemeChange(resolvedTheme)\n return fn()\n })\n}\n\n/**\n * Subscribe to theme change events.\n *\n * @param listener - Change handler\n * @returns Unsubscribe function\n *\n * @example\n * ```ts\n * const unsubscribe = onThemeChange((theme) => {\n * console.log('Theme:', theme.displayName)\n * })\n *\n * // Cleanup\n * unsubscribe()\n * ```\n */\nexport function onThemeChange(listener: ThemeChangeListener): () => void {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n}\n\n/**\n * Emit theme change event to listeners.\n * @private\n */\nfunction emitThemeChange(theme: Theme): void {\n for (const listener of listeners) {\n listener(theme)\n }\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,kBAAAC,EAAA,aAAAC,EAAA,cAAAC,EAAA,kBAAAC,IAAA,eAAAC,EAAAP,GAKA,IAAAQ,EAAkC,4BAGlCC,EAAqD,oBAUrD,MAAMC,EAAe,IAAI,oBAKzB,IAAIC,EAAuB,eAK3B,MAAMC,EAAsC,IAAI,IAYzC,SAASR,EAASS,EAAgC,CACvDF,EAAgB,OAAOE,GAAU,SAAW,SAAOA,CAAK,EAAIA,EAC5DC,EAAgBH,CAAa,CAC/B,CAaO,SAAST,GAAkB,CAChC,OAAOQ,EAAa,SAAS,GAAKC,CACpC,CAkBA,eAAsBN,EACpBQ,EACAE,EACY,CACZ,MAAMC,EAAgB,OAAOH,GAAU,SAAW,SAAOA,CAAK,EAAIA,EAClE,OAAO,MAAMH,EAAa,IAAIM,EAAe,UAC3CF,EAAgBE,CAAa,EACtB,MAAMD,EAAG,EACjB,CACH,CAkBO,SAAST,EAAiBO,EAA0BE,EAAgB,CACzE,MAAMC,EAAgB,OAAOH,GAAU,SAAW,SAAOA,CAAK,EAAIA,EAClE,OAAOH,EAAa,IAAIM,EAAe,KACrCF,EAAgBE,CAAa,EACtBD,EAAG,EACX,CACH,CAkBO,SAASZ,EAAcc,EAA2C,CACvE,OAAAL,EAAU,IAAIK,CAAQ,EACf,IAAM,CACXL,EAAU,OAAOK,CAAQ,CAC3B,CACF,CAMA,SAASH,EAAgBD,EAAoB,CAC3C,UAAWI,KAAYL,EACrBK,EAASJ,CAAK,CAElB",
|
|
6
|
+
"names": ["context_exports", "__export", "getTheme", "onThemeChange", "setTheme", "withTheme", "withThemeSync", "__toCommonJS", "import_node_async_hooks", "import_themes", "themeStorage", "fallbackTheme", "listeners", "theme", "emitThemeChange", "fn", "resolvedTheme", "listener"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Elegant theming system for Socket libraries.
|
|
3
|
+
* Unified visual language across spinners, loggers, prompts, and links.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { setTheme, THEMES } from '@socketsecurity/lib/themes'
|
|
8
|
+
*
|
|
9
|
+
* // Set global theme
|
|
10
|
+
* setTheme('brick')
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { withTheme } from '@socketsecurity/lib/themes'
|
|
16
|
+
*
|
|
17
|
+
* // Scoped theme context
|
|
18
|
+
* await withTheme('ultra', async () => {
|
|
19
|
+
* // All operations inherit Ultra theme
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { createTheme } from '@socketsecurity/lib/themes'
|
|
26
|
+
*
|
|
27
|
+
* // Custom theme creation
|
|
28
|
+
* const myTheme = createTheme({
|
|
29
|
+
* name: 'custom',
|
|
30
|
+
* displayName: 'Custom Theme',
|
|
31
|
+
* colors: {
|
|
32
|
+
* primary: [255, 100, 200],
|
|
33
|
+
* success: 'greenBright',
|
|
34
|
+
* error: 'redBright',
|
|
35
|
+
* warning: 'yellowBright',
|
|
36
|
+
* info: 'blueBright',
|
|
37
|
+
* step: 'cyanBright',
|
|
38
|
+
* text: 'white',
|
|
39
|
+
* textDim: 'gray',
|
|
40
|
+
* link: 'cyanBright',
|
|
41
|
+
* prompt: 'primary'
|
|
42
|
+
* }
|
|
43
|
+
* })
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
// Type system
|
|
47
|
+
export type { ColorReference, Theme, ThemeColors, ThemeEffects, ThemeMeta, } from './types';
|
|
48
|
+
// Curated themes
|
|
49
|
+
export { BRICK_THEME, LUSH_THEME, SOCKET_THEME, SUNSET_THEME, THEMES, ULTRA_THEME, type ThemeName, } from './themes';
|
|
50
|
+
// Context management
|
|
51
|
+
export { getTheme, onThemeChange, setTheme, withTheme, withThemeSync, type ThemeChangeListener, } from './context';
|
|
52
|
+
// Composition utilities
|
|
53
|
+
export { createTheme, extendTheme, resolveColor, resolveShimmerColor, } from './utils';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var E=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var s=(h,m)=>{for(var t in m)E(h,t,{get:m[t],enumerable:!0})},H=(h,m,t,p)=>{if(m&&typeof m=="object"||typeof m=="function")for(let r of f(m))!n.call(h,r)&&r!==t&&E(h,r,{get:()=>m[r],enumerable:!(p=C(m,r))||p.enumerable});return h};var M=h=>H(E({},"__esModule",{value:!0}),h);var S={};s(S,{BRICK_THEME:()=>e.BRICK_THEME,LUSH_THEME:()=>e.LUSH_THEME,SOCKET_THEME:()=>e.SOCKET_THEME,SUNSET_THEME:()=>e.SUNSET_THEME,THEMES:()=>e.THEMES,ULTRA_THEME:()=>e.ULTRA_THEME,createTheme:()=>o.createTheme,extendTheme:()=>o.extendTheme,getTheme:()=>T.getTheme,onThemeChange:()=>T.onThemeChange,resolveColor:()=>o.resolveColor,resolveShimmerColor:()=>o.resolveShimmerColor,setTheme:()=>T.setTheme,withTheme:()=>T.withTheme,withThemeSync:()=>T.withThemeSync});module.exports=M(S);var e=require("./themes"),T=require("./context"),o=require("./utils");0&&(module.exports={BRICK_THEME,LUSH_THEME,SOCKET_THEME,SUNSET_THEME,THEMES,ULTRA_THEME,createTheme,extendTheme,getTheme,onThemeChange,resolveColor,resolveShimmerColor,setTheme,withTheme,withThemeSync});
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/themes/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Elegant theming system for Socket libraries.\n * Unified visual language across spinners, loggers, prompts, and links.\n *\n * @example\n * ```ts\n * import { setTheme, THEMES } from '@socketsecurity/lib/themes'\n *\n * // Set global theme\n * setTheme('brick')\n * ```\n *\n * @example\n * ```ts\n * import { withTheme } from '@socketsecurity/lib/themes'\n *\n * // Scoped theme context\n * await withTheme('ultra', async () => {\n * // All operations inherit Ultra theme\n * })\n * ```\n *\n * @example\n * ```ts\n * import { createTheme } from '@socketsecurity/lib/themes'\n *\n * // Custom theme creation\n * const myTheme = createTheme({\n * name: 'custom',\n * displayName: 'Custom Theme',\n * colors: {\n * primary: [255, 100, 200],\n * success: 'greenBright',\n * error: 'redBright',\n * warning: 'yellowBright',\n * info: 'blueBright',\n * step: 'cyanBright',\n * text: 'white',\n * textDim: 'gray',\n * link: 'cyanBright',\n * prompt: 'primary'\n * }\n * })\n * ```\n */\n\n// Type system\nexport type {\n ColorReference,\n Theme,\n ThemeColors,\n ThemeEffects,\n ThemeMeta,\n} from './types'\n\n// Curated themes\nexport {\n BRICK_THEME,\n LUSH_THEME,\n SOCKET_THEME,\n SUNSET_THEME,\n THEMES,\n ULTRA_THEME,\n type ThemeName,\n} from './themes'\n\n// Context management\nexport {\n getTheme,\n onThemeChange,\n setTheme,\n withTheme,\n withThemeSync,\n type ThemeChangeListener,\n} from './context'\n\n// Composition utilities\nexport {\n createTheme,\n extendTheme,\n resolveColor,\n resolveShimmerColor,\n} from './utils'\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sdAAAE,EAAAF,GAwDA,IAAAG,EAQO,oBAGPC,EAOO,qBAGPC,EAKO",
|
|
6
|
+
"names": ["themes_exports", "__export", "__toCommonJS", "import_themes", "import_context", "import_utils"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Elegant theme definitions for Socket libraries.
|
|
3
|
+
* Sophisticated color palettes crafted for clarity and visual harmony.
|
|
4
|
+
*
|
|
5
|
+
* Philosophy: Every color choice serves a purpose. Bright variants ensure
|
|
6
|
+
* terminal legibility without compromising sophistication. Minimal emoji use,
|
|
7
|
+
* refined symbols with color—elegance in restraint.
|
|
8
|
+
*/
|
|
9
|
+
import type { Theme } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Socket Security — The signature theme.
|
|
12
|
+
* Refined violet with subtle shimmer, designed for focus and elegance.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SOCKET_THEME: Theme;
|
|
15
|
+
/**
|
|
16
|
+
* Sunset — Crisp azure.
|
|
17
|
+
* Clean analytical theme with precise blue tones.
|
|
18
|
+
*/
|
|
19
|
+
export declare const SUNSET_THEME: Theme;
|
|
20
|
+
/**
|
|
21
|
+
* Brick — Solid warmth.
|
|
22
|
+
* Rich terracotta and ember tones for grounded confidence.
|
|
23
|
+
*/
|
|
24
|
+
export declare const BRICK_THEME: Theme;
|
|
25
|
+
/**
|
|
26
|
+
* Lush — Steel elegance.
|
|
27
|
+
* Python-inspired steel blue with golden accents.
|
|
28
|
+
*/
|
|
29
|
+
export declare const LUSH_THEME: Theme;
|
|
30
|
+
/**
|
|
31
|
+
* Ultra — Premium intensity.
|
|
32
|
+
* Prismatic shimmer for deep analysis, where complexity meets elegance.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ULTRA_THEME: Theme;
|
|
35
|
+
/**
|
|
36
|
+
* Theme registry — Curated palette collection.
|
|
37
|
+
*/
|
|
38
|
+
export declare const THEMES: {
|
|
39
|
+
readonly __proto__: any;
|
|
40
|
+
readonly socket: Theme;
|
|
41
|
+
readonly sunset: Theme;
|
|
42
|
+
readonly brick: Theme;
|
|
43
|
+
readonly lush: Theme;
|
|
44
|
+
readonly ultra: Theme;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Available theme identifiers.
|
|
48
|
+
*/
|
|
49
|
+
export type ThemeName = keyof typeof THEMES;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var g=(r,e)=>{for(var i in e)o(r,i,{get:e[i],enumerable:!0})},d=(r,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of l(e))!y.call(r,t)&&t!==i&&o(r,t,{get:()=>e[t],enumerable:!(s=p(e,t))||s.enumerable});return r};var B=r=>d(o({},"__esModule",{value:!0}),r);var f={};g(f,{BRICK_THEME:()=>c,LUSH_THEME:()=>m,SOCKET_THEME:()=>n,SUNSET_THEME:()=>a,THEMES:()=>u,ULTRA_THEME:()=>h});module.exports=B(f);const n={name:"socket",displayName:"Socket Security",colors:{primary:[140,82,255],success:"greenBright",error:"redBright",warning:"yellowBright",info:"blueBright",step:"cyanBright",text:"white",textDim:"gray",link:"cyanBright",prompt:"primary"},effects:{spinner:{color:"primary",style:"socket"},shimmer:{enabled:!0,color:"inherit",direction:"ltr",speed:.33}},meta:{description:"Signature theme with refined violet and subtle shimmer",version:"1.0.0"}},a={name:"sunset",displayName:"Sunset",colors:{primary:[100,200,255],secondary:[50,150,200],success:"greenBright",error:"redBright",warning:"yellowBright",info:"blueBright",step:"cyanBright",text:"white",textDim:"gray",link:"cyanBright",prompt:"primary"},effects:{spinner:{color:"primary",style:"dots"}},meta:{description:"Crisp azure theme for precision and clarity",version:"1.0.0"}},c={name:"brick",displayName:"Brick",colors:{primary:[255,100,50],secondary:[255,150,100],success:"greenBright",error:"redBright",warning:"yellowBright",info:"blueBright",step:"cyanBright",text:"white",textDim:"gray",link:"secondary",prompt:"primary"},effects:{spinner:{color:"primary",style:"socket"},shimmer:{enabled:!0,color:"inherit",direction:"ltr",speed:.5}},meta:{description:"Solid theme with rich terracotta and ember warmth",version:"1.0.0"}},m={name:"lush",displayName:"Lush",colors:{primary:[70,130,180],secondary:[255,215,0],success:"greenBright",error:"redBright",warning:"yellowBright",info:"blueBright",step:"cyanBright",text:"white",textDim:"gray",link:"cyanBright",prompt:"primary"},effects:{spinner:{color:"primary",style:"dots"}},meta:{description:"Elegant theme with steel blue and golden harmony",version:"1.0.0"}},h={name:"ultra",displayName:"Ultra",colors:{primary:[140,82,255],success:"greenBright",error:"redBright",warning:"yellowBright",info:"cyanBright",step:"magentaBright",text:"whiteBright",textDim:"gray",link:"cyanBright",prompt:"primary"},effects:{spinner:{color:"inherit",style:"socket"},shimmer:{enabled:!0,color:"rainbow",direction:"bi",speed:.5}},meta:{description:"Premium theme with prismatic shimmer for deep analysis",version:"1.0.0"}},u={__proto__:null,socket:n,sunset:a,brick:c,lush:m,ultra:h};0&&(module.exports={BRICK_THEME,LUSH_THEME,SOCKET_THEME,SUNSET_THEME,THEMES,ULTRA_THEME});
|
|
3
|
+
//# sourceMappingURL=themes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/themes/themes.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Elegant theme definitions for Socket libraries.\n * Sophisticated color palettes crafted for clarity and visual harmony.\n *\n * Philosophy: Every color choice serves a purpose. Bright variants ensure\n * terminal legibility without compromising sophistication. Minimal emoji use,\n * refined symbols with color\u2014elegance in restraint.\n */\n\nimport type { Theme } from './types'\n\n/**\n * Socket Security \u2014 The signature theme.\n * Refined violet with subtle shimmer, designed for focus and elegance.\n */\nexport const SOCKET_THEME: Theme = {\n name: 'socket',\n displayName: 'Socket Security',\n colors: {\n primary: [140, 82, 255],\n success: 'greenBright',\n error: 'redBright',\n warning: 'yellowBright',\n info: 'blueBright',\n step: 'cyanBright',\n text: 'white',\n textDim: 'gray',\n link: 'cyanBright',\n prompt: 'primary',\n },\n effects: {\n spinner: {\n color: 'primary',\n style: 'socket',\n },\n shimmer: {\n enabled: true,\n color: 'inherit',\n direction: 'ltr',\n speed: 0.33,\n },\n },\n meta: {\n description: 'Signature theme with refined violet and subtle shimmer',\n version: '1.0.0',\n },\n}\n\n/**\n * Sunset \u2014 Crisp azure.\n * Clean analytical theme with precise blue tones.\n */\nexport const SUNSET_THEME: Theme = {\n name: 'sunset',\n displayName: 'Sunset',\n colors: {\n primary: [100, 200, 255],\n secondary: [50, 150, 200],\n success: 'greenBright',\n error: 'redBright',\n warning: 'yellowBright',\n info: 'blueBright',\n step: 'cyanBright',\n text: 'white',\n textDim: 'gray',\n link: 'cyanBright',\n prompt: 'primary',\n },\n effects: {\n spinner: {\n color: 'primary',\n style: 'dots',\n },\n },\n meta: {\n description: 'Crisp azure theme for precision and clarity',\n version: '1.0.0',\n },\n}\n\n/**\n * Brick \u2014 Solid warmth.\n * Rich terracotta and ember tones for grounded confidence.\n */\nexport const BRICK_THEME: Theme = {\n name: 'brick',\n displayName: 'Brick',\n colors: {\n primary: [255, 100, 50],\n secondary: [255, 150, 100],\n success: 'greenBright',\n error: 'redBright',\n warning: 'yellowBright',\n info: 'blueBright',\n step: 'cyanBright',\n text: 'white',\n textDim: 'gray',\n link: 'secondary',\n prompt: 'primary',\n },\n effects: {\n spinner: {\n color: 'primary',\n style: 'socket',\n },\n shimmer: {\n enabled: true,\n color: 'inherit',\n direction: 'ltr',\n speed: 0.5,\n },\n },\n meta: {\n description: 'Solid theme with rich terracotta and ember warmth',\n version: '1.0.0',\n },\n}\n\n/**\n * Lush \u2014 Steel elegance.\n * Python-inspired steel blue with golden accents.\n */\nexport const LUSH_THEME: Theme = {\n name: 'lush',\n displayName: 'Lush',\n colors: {\n primary: [70, 130, 180],\n secondary: [255, 215, 0],\n success: 'greenBright',\n error: 'redBright',\n warning: 'yellowBright',\n info: 'blueBright',\n step: 'cyanBright',\n text: 'white',\n textDim: 'gray',\n link: 'cyanBright',\n prompt: 'primary',\n },\n effects: {\n spinner: {\n color: 'primary',\n style: 'dots',\n },\n },\n meta: {\n description: 'Elegant theme with steel blue and golden harmony',\n version: '1.0.0',\n },\n}\n\n/**\n * Ultra \u2014 Premium intensity.\n * Prismatic shimmer for deep analysis, where complexity meets elegance.\n */\nexport const ULTRA_THEME: Theme = {\n name: 'ultra',\n displayName: 'Ultra',\n colors: {\n primary: [140, 82, 255],\n success: 'greenBright',\n error: 'redBright',\n warning: 'yellowBright',\n info: 'cyanBright',\n step: 'magentaBright',\n text: 'whiteBright',\n textDim: 'gray',\n link: 'cyanBright',\n prompt: 'primary',\n },\n effects: {\n spinner: {\n color: 'inherit',\n style: 'socket',\n },\n shimmer: {\n enabled: true,\n color: 'rainbow',\n direction: 'bi',\n speed: 0.5,\n },\n },\n meta: {\n description: 'Premium theme with prismatic shimmer for deep analysis',\n version: '1.0.0',\n },\n}\n\n/**\n * Theme registry \u2014 Curated palette collection.\n */\nexport const THEMES = {\n __proto__: null,\n socket: SOCKET_THEME,\n sunset: SUNSET_THEME,\n brick: BRICK_THEME,\n lush: LUSH_THEME,\n ultra: ULTRA_THEME,\n} as const\n\n/**\n * Available theme identifiers.\n */\nexport type ThemeName = keyof typeof THEMES\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,eAAAC,EAAA,iBAAAC,EAAA,iBAAAC,EAAA,WAAAC,EAAA,gBAAAC,IAAA,eAAAC,EAAAR,GAeO,MAAMI,EAAsB,CACjC,KAAM,SACN,YAAa,kBACb,OAAQ,CACN,QAAS,CAAC,IAAK,GAAI,GAAG,EACtB,QAAS,cACT,MAAO,YACP,QAAS,eACT,KAAM,aACN,KAAM,aACN,KAAM,QACN,QAAS,OACT,KAAM,aACN,OAAQ,SACV,EACA,QAAS,CACP,QAAS,CACP,MAAO,UACP,MAAO,QACT,EACA,QAAS,CACP,QAAS,GACT,MAAO,UACP,UAAW,MACX,MAAO,GACT,CACF,EACA,KAAM,CACJ,YAAa,yDACb,QAAS,OACX,CACF,EAMaC,EAAsB,CACjC,KAAM,SACN,YAAa,SACb,OAAQ,CACN,QAAS,CAAC,IAAK,IAAK,GAAG,EACvB,UAAW,CAAC,GAAI,IAAK,GAAG,EACxB,QAAS,cACT,MAAO,YACP,QAAS,eACT,KAAM,aACN,KAAM,aACN,KAAM,QACN,QAAS,OACT,KAAM,aACN,OAAQ,SACV,EACA,QAAS,CACP,QAAS,CACP,MAAO,UACP,MAAO,MACT,CACF,EACA,KAAM,CACJ,YAAa,8CACb,QAAS,OACX,CACF,EAMaH,EAAqB,CAChC,KAAM,QACN,YAAa,QACb,OAAQ,CACN,QAAS,CAAC,IAAK,IAAK,EAAE,EACtB,UAAW,CAAC,IAAK,IAAK,GAAG,EACzB,QAAS,cACT,MAAO,YACP,QAAS,eACT,KAAM,aACN,KAAM,aACN,KAAM,QACN,QAAS,OACT,KAAM,YACN,OAAQ,SACV,EACA,QAAS,CACP,QAAS,CACP,MAAO,UACP,MAAO,QACT,EACA,QAAS,CACP,QAAS,GACT,MAAO,UACP,UAAW,MACX,MAAO,EACT,CACF,EACA,KAAM,CACJ,YAAa,oDACb,QAAS,OACX,CACF,EAMaC,EAAoB,CAC/B,KAAM,OACN,YAAa,OACb,OAAQ,CACN,QAAS,CAAC,GAAI,IAAK,GAAG,EACtB,UAAW,CAAC,IAAK,IAAK,CAAC,EACvB,QAAS,cACT,MAAO,YACP,QAAS,eACT,KAAM,aACN,KAAM,aACN,KAAM,QACN,QAAS,OACT,KAAM,aACN,OAAQ,SACV,EACA,QAAS,CACP,QAAS,CACP,MAAO,UACP,MAAO,MACT,CACF,EACA,KAAM,CACJ,YAAa,mDACb,QAAS,OACX,CACF,EAMaI,EAAqB,CAChC,KAAM,QACN,YAAa,QACb,OAAQ,CACN,QAAS,CAAC,IAAK,GAAI,GAAG,EACtB,QAAS,cACT,MAAO,YACP,QAAS,eACT,KAAM,aACN,KAAM,gBACN,KAAM,cACN,QAAS,OACT,KAAM,aACN,OAAQ,SACV,EACA,QAAS,CACP,QAAS,CACP,MAAO,UACP,MAAO,QACT,EACA,QAAS,CACP,QAAS,GACT,MAAO,UACP,UAAW,KACX,MAAO,EACT,CACF,EACA,KAAM,CACJ,YAAa,yDACb,QAAS,OACX,CACF,EAKaD,EAAS,CACpB,UAAW,KACX,OAAQF,EACR,OAAQC,EACR,MAAOH,EACP,KAAMC,EACN,MAAOI,CACT",
|
|
6
|
+
"names": ["themes_exports", "__export", "BRICK_THEME", "LUSH_THEME", "SOCKET_THEME", "SUNSET_THEME", "THEMES", "ULTRA_THEME", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Elegant theme type system.
|
|
3
|
+
* Type-safe theming for spinners, loggers, prompts, and links.
|
|
4
|
+
*/
|
|
5
|
+
import type { ColorValue, SpinnerStyle } from '../spinner';
|
|
6
|
+
import type { ShimmerDirection } from '../effects/text-shimmer';
|
|
7
|
+
/**
|
|
8
|
+
* Color reference — direct value or semantic keyword.
|
|
9
|
+
* Keywords: 'primary', 'secondary', 'inherit', 'rainbow'
|
|
10
|
+
*/
|
|
11
|
+
export type ColorReference = ColorValue | 'primary' | 'secondary' | 'inherit' | 'rainbow';
|
|
12
|
+
/**
|
|
13
|
+
* Theme color palette — semantic colors for visual harmony.
|
|
14
|
+
*/
|
|
15
|
+
export type ThemeColors = {
|
|
16
|
+
/** Primary brand identity */
|
|
17
|
+
primary: ColorValue;
|
|
18
|
+
/** Secondary accent (optional) */
|
|
19
|
+
secondary?: ColorValue | undefined;
|
|
20
|
+
/** Success indicator ✓ */
|
|
21
|
+
success: ColorValue;
|
|
22
|
+
/** Error indicator ✗ */
|
|
23
|
+
error: ColorValue;
|
|
24
|
+
/** Warning indicator ⚠ */
|
|
25
|
+
warning: ColorValue;
|
|
26
|
+
/** Information indicator ℹ */
|
|
27
|
+
info: ColorValue;
|
|
28
|
+
/** Progress indicator → */
|
|
29
|
+
step: ColorValue;
|
|
30
|
+
/** Primary text */
|
|
31
|
+
text: ColorValue;
|
|
32
|
+
/** Dimmed text */
|
|
33
|
+
textDim: ColorValue;
|
|
34
|
+
/** Hyperlinks */
|
|
35
|
+
link: ColorReference;
|
|
36
|
+
/** Interactive prompts */
|
|
37
|
+
prompt: ColorReference;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Theme effects — animations and visual enhancements.
|
|
41
|
+
*/
|
|
42
|
+
export type ThemeEffects = {
|
|
43
|
+
/** Spinner configuration */
|
|
44
|
+
spinner?: {
|
|
45
|
+
/** Color (supports theme references) */
|
|
46
|
+
color?: ColorReference | undefined;
|
|
47
|
+
/** Animation style */
|
|
48
|
+
style?: SpinnerStyle | string | undefined;
|
|
49
|
+
};
|
|
50
|
+
/** Shimmer configuration */
|
|
51
|
+
shimmer?: {
|
|
52
|
+
/** Enable shimmer */
|
|
53
|
+
enabled?: boolean | undefined;
|
|
54
|
+
/** Color (single, gradient, or keyword) */
|
|
55
|
+
color?: ColorReference | ColorValue[] | undefined;
|
|
56
|
+
/** Direction */
|
|
57
|
+
direction?: ShimmerDirection | undefined;
|
|
58
|
+
/** Speed (steps per frame) */
|
|
59
|
+
speed?: number | undefined;
|
|
60
|
+
};
|
|
61
|
+
/** Pulse configuration */
|
|
62
|
+
pulse?: {
|
|
63
|
+
/** Speed (milliseconds) */
|
|
64
|
+
speed?: number | undefined;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Theme metadata — descriptive information.
|
|
69
|
+
*/
|
|
70
|
+
export type ThemeMeta = {
|
|
71
|
+
/** Description */
|
|
72
|
+
description?: string | undefined;
|
|
73
|
+
/** Author */
|
|
74
|
+
author?: string | undefined;
|
|
75
|
+
/** Version */
|
|
76
|
+
version?: string | undefined;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Theme definition — complete visual identity.
|
|
80
|
+
*/
|
|
81
|
+
export type Theme = {
|
|
82
|
+
/** Unique identifier (kebab-case) */
|
|
83
|
+
name: string;
|
|
84
|
+
/** Display name */
|
|
85
|
+
displayName: string;
|
|
86
|
+
/** Color palette */
|
|
87
|
+
colors: ThemeColors;
|
|
88
|
+
/** Visual effects (optional) */
|
|
89
|
+
effects?: ThemeEffects | undefined;
|
|
90
|
+
/** Metadata (optional) */
|
|
91
|
+
meta?: ThemeMeta | undefined;
|
|
92
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var u=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of d(e))!s.call(r,o)&&o!==t&&i(r,o,{get:()=>e[o],enumerable:!(n=l(e,o))||n.enumerable});return r};var f=r=>u(i({},"__esModule",{value:!0}),r);var m={};module.exports=f(m);
|
|
3
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/themes/types.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Elegant theme type system.\n * Type-safe theming for spinners, loggers, prompts, and links.\n */\n\nimport type { ColorValue, SpinnerStyle } from '../spinner'\nimport type { ShimmerDirection } from '../effects/text-shimmer'\n\n/**\n * Color reference \u2014 direct value or semantic keyword.\n * Keywords: 'primary', 'secondary', 'inherit', 'rainbow'\n */\nexport type ColorReference =\n | ColorValue\n | 'primary'\n | 'secondary'\n | 'inherit'\n | 'rainbow'\n\n/**\n * Theme color palette \u2014 semantic colors for visual harmony.\n */\nexport type ThemeColors = {\n /** Primary brand identity */\n primary: ColorValue\n /** Secondary accent (optional) */\n secondary?: ColorValue | undefined\n\n /** Success indicator \u2713 */\n success: ColorValue\n /** Error indicator \u2717 */\n error: ColorValue\n /** Warning indicator \u26A0 */\n warning: ColorValue\n /** Information indicator \u2139 */\n info: ColorValue\n /** Progress indicator \u2192 */\n step: ColorValue\n\n /** Primary text */\n text: ColorValue\n /** Dimmed text */\n textDim: ColorValue\n /** Hyperlinks */\n link: ColorReference\n /** Interactive prompts */\n prompt: ColorReference\n}\n\n/**\n * Theme effects \u2014 animations and visual enhancements.\n */\nexport type ThemeEffects = {\n /** Spinner configuration */\n spinner?: {\n /** Color (supports theme references) */\n color?: ColorReference | undefined\n /** Animation style */\n style?: SpinnerStyle | string | undefined\n }\n\n /** Shimmer configuration */\n shimmer?: {\n /** Enable shimmer */\n enabled?: boolean | undefined\n /** Color (single, gradient, or keyword) */\n color?: ColorReference | ColorValue[] | undefined\n /** Direction */\n direction?: ShimmerDirection | undefined\n /** Speed (steps per frame) */\n speed?: number | undefined\n }\n\n /** Pulse configuration */\n pulse?: {\n /** Speed (milliseconds) */\n speed?: number | undefined\n }\n}\n\n/**\n * Theme metadata \u2014 descriptive information.\n */\nexport type ThemeMeta = {\n /** Description */\n description?: string | undefined\n /** Author */\n author?: string | undefined\n /** Version */\n version?: string | undefined\n}\n\n/**\n * Theme definition \u2014 complete visual identity.\n */\nexport type Theme = {\n /** Unique identifier (kebab-case) */\n name: string\n /** Display name */\n displayName: string\n\n /** Color palette */\n colors: ThemeColors\n\n /** Visual effects (optional) */\n effects?: ThemeEffects | undefined\n\n /** Metadata (optional) */\n meta?: ThemeMeta | undefined\n}\n"],
|
|
5
|
+
"mappings": ";kWAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["types_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ColorValue } from '../spinner';
|
|
2
|
+
import type { ShimmerColorGradient } from '../effects/text-shimmer';
|
|
3
|
+
import type { Theme, ThemeColors, ColorReference } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve color reference to concrete value.
|
|
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
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveColor(value: ColorReference | ColorValue, colors: ThemeColors): ColorValue | 'inherit' | ShimmerColorGradient;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve shimmer color with gradient support.
|
|
21
|
+
*
|
|
22
|
+
* @param value - Shimmer color
|
|
23
|
+
* @param theme - Theme context
|
|
24
|
+
* @returns Resolved color
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* resolveShimmerColor('rainbow', theme)
|
|
29
|
+
* resolveShimmerColor('primary', theme)
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveShimmerColor(value: ColorReference | ColorValue[] | undefined, theme: Theme): ColorValue | ShimmerColorGradient | 'inherit';
|
|
33
|
+
/**
|
|
34
|
+
* Extend existing theme with custom overrides.
|
|
35
|
+
* Deep merge of colors and effects.
|
|
36
|
+
*
|
|
37
|
+
* @param base - Base theme
|
|
38
|
+
* @param overrides - Custom overrides
|
|
39
|
+
* @returns Extended theme
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const custom = extendTheme(SOCKET_THEME, {
|
|
44
|
+
* name: 'custom',
|
|
45
|
+
* colors: { primary: [255, 100, 200] }
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function extendTheme(base: Theme, overrides: Partial<Omit<Theme, 'colors'>> & {
|
|
50
|
+
colors?: Partial<ThemeColors> | undefined;
|
|
51
|
+
}): Theme;
|
|
52
|
+
/**
|
|
53
|
+
* Create new theme from complete specification.
|
|
54
|
+
*
|
|
55
|
+
* @param config - Theme configuration
|
|
56
|
+
* @returns Theme object
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const theme = createTheme({
|
|
61
|
+
* name: 'custom',
|
|
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
|
+
* })
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function createTheme(config: Pick<Theme, 'name' | 'displayName' | 'colors'> & Partial<Omit<Theme, 'name' | 'displayName' | 'colors'>>): Theme;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var p=(e,r)=>{for(var o in r)n(e,o,{get:r[o],enumerable:!0})},h=(e,r,o,f)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of s(r))!_.call(e,t)&&t!==o&&n(e,t,{get:()=>r[t],enumerable:!(f=i(r,t))||f.enumerable});return e};var u=e=>h(n({},"__esModule",{value:!0}),e);var y={};p(y,{createTheme:()=>C,extendTheme:()=>c,resolveColor:()=>l,resolveShimmerColor:()=>a});module.exports=u(y);var m=require("../effects/ultra");function l(e,r){return typeof e=="string"?e==="primary"?r.primary:e==="secondary"?r.secondary??r.primary:e==="inherit"?"inherit":e==="rainbow"?m.RAINBOW_GRADIENT:e:e}function a(e,r){return e?e==="rainbow"?m.RAINBOW_GRADIENT:e==="inherit"?"inherit":Array.isArray(e)?(e.length>0&&Array.isArray(e[0]),e):l(e,r.colors):"inherit"}function c(e,r){return{__proto__:null,...e,...r,colors:{__proto__:null,...e.colors,...r.colors},effects:r.effects?{__proto__:null,...e.effects,...r.effects,spinner:r.effects.spinner!==void 0?{__proto__:null,...e.effects?.spinner,...r.effects.spinner}:e.effects?.spinner,shimmer:r.effects.shimmer!==void 0?{__proto__:null,...e.effects?.shimmer,...r.effects.shimmer}:e.effects?.shimmer,pulse:r.effects.pulse!==void 0?{__proto__:null,...e.effects?.pulse,...r.effects.pulse}:e.effects?.pulse}:e.effects,meta:r.meta?{__proto__:null,...e.meta,...r.meta}:e.meta}}function C(e){return{__proto__:null,name:e.name,displayName:e.displayName,colors:{__proto__:null,...e.colors},effects:e.effects?{__proto__:null,...e.effects}:void 0,meta:e.meta?{__proto__:null,...e.meta}:void 0}}0&&(module.exports={createTheme,extendTheme,resolveColor,resolveShimmerColor});
|
|
3
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/themes/utils.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Theme utilities \u2014 color resolution and composition.\n */\n\nimport { RAINBOW_GRADIENT } from '../effects/ultra'\nimport type { ColorValue } from '../spinner'\nimport type { ShimmerColorGradient } from '../effects/text-shimmer'\nimport type { Theme, ThemeColors, ColorReference } from './types'\n\n/**\n * Resolve color reference to concrete value.\n * Handles semantic keywords: 'primary', 'secondary', 'rainbow', 'inherit'\n *\n * @param value - Color reference\n * @param colors - Theme palette\n * @returns Resolved color\n *\n * @example\n * ```ts\n * resolveColor('primary', theme.colors)\n * resolveColor([255, 0, 0], theme.colors)\n * ```\n */\nexport function resolveColor(\n value: ColorReference | ColorValue,\n colors: ThemeColors,\n): ColorValue | 'inherit' | ShimmerColorGradient {\n if (typeof value === 'string') {\n if (value === 'primary') {\n return colors.primary\n }\n if (value === 'secondary') {\n return colors.secondary ?? colors.primary\n }\n if (value === 'inherit') {\n return 'inherit'\n }\n if (value === 'rainbow') {\n return RAINBOW_GRADIENT\n }\n return value as ColorValue\n }\n return value as ColorValue\n}\n\n/**\n * Resolve shimmer color with gradient support.\n *\n * @param value - Shimmer color\n * @param theme - Theme context\n * @returns Resolved color\n *\n * @example\n * ```ts\n * resolveShimmerColor('rainbow', theme)\n * resolveShimmerColor('primary', theme)\n * ```\n */\nexport function resolveShimmerColor(\n value: ColorReference | ColorValue[] | undefined,\n theme: Theme,\n): ColorValue | ShimmerColorGradient | 'inherit' {\n if (!value) {\n return 'inherit'\n }\n if (value === 'rainbow') {\n return RAINBOW_GRADIENT\n }\n if (value === 'inherit') {\n return 'inherit'\n }\n if (Array.isArray(value)) {\n if (value.length > 0 && Array.isArray(value[0])) {\n // Gradient\n return value as ShimmerColorGradient\n }\n // Single RGB\n return value as unknown as ColorValue\n }\n return resolveColor(value as ColorReference, theme.colors)\n}\n\n/**\n * Extend existing theme with custom overrides.\n * Deep merge of colors and effects.\n *\n * @param base - Base theme\n * @param overrides - Custom overrides\n * @returns Extended theme\n *\n * @example\n * ```ts\n * const custom = extendTheme(SOCKET_THEME, {\n * name: 'custom',\n * colors: { primary: [255, 100, 200] }\n * })\n * ```\n */\nexport function extendTheme(\n base: Theme,\n overrides: Partial<Omit<Theme, 'colors'>> & {\n colors?: Partial<ThemeColors> | undefined\n },\n): Theme {\n return {\n __proto__: null,\n ...base,\n ...overrides,\n colors: {\n __proto__: null,\n ...base.colors,\n ...overrides.colors,\n } as ThemeColors,\n effects: overrides.effects\n ? {\n __proto__: null,\n ...base.effects,\n ...overrides.effects,\n spinner:\n overrides.effects.spinner !== undefined\n ? {\n __proto__: null,\n ...base.effects?.spinner,\n ...overrides.effects.spinner,\n }\n : base.effects?.spinner,\n shimmer:\n overrides.effects.shimmer !== undefined\n ? {\n __proto__: null,\n ...base.effects?.shimmer,\n ...overrides.effects.shimmer,\n }\n : base.effects?.shimmer,\n pulse:\n overrides.effects.pulse !== undefined\n ? {\n __proto__: null,\n ...base.effects?.pulse,\n ...overrides.effects.pulse,\n }\n : base.effects?.pulse,\n }\n : base.effects,\n meta: overrides.meta\n ? {\n __proto__: null,\n ...base.meta,\n ...overrides.meta,\n }\n : base.meta,\n } as Theme\n}\n\n/**\n * Create new theme from complete specification.\n *\n * @param config - Theme configuration\n * @returns Theme object\n *\n * @example\n * ```ts\n * const theme = createTheme({\n * name: 'custom',\n * displayName: 'Custom',\n * colors: {\n * primary: [255, 100, 200],\n * success: 'greenBright',\n * error: 'redBright',\n * warning: 'yellowBright',\n * info: 'blueBright',\n * step: 'cyanBright',\n * text: 'white',\n * textDim: 'gray',\n * link: 'cyanBright',\n * prompt: 'primary'\n * }\n * })\n * ```\n */\nexport function createTheme(\n config: Pick<Theme, 'name' | 'displayName' | 'colors'> &\n Partial<Omit<Theme, 'name' | 'displayName' | 'colors'>>,\n): Theme {\n return {\n __proto__: null,\n name: config.name,\n displayName: config.displayName,\n colors: { __proto__: null, ...config.colors } as ThemeColors,\n effects: config.effects\n ? { __proto__: null, ...config.effects }\n : undefined,\n meta: config.meta ? { __proto__: null, ...config.meta } : undefined,\n } as Theme\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,gBAAAC,EAAA,iBAAAC,EAAA,wBAAAC,IAAA,eAAAC,EAAAN,GAIA,IAAAO,EAAiC,4BAmB1B,SAASH,EACdI,EACAC,EAC+C,CAC/C,OAAI,OAAOD,GAAU,SACfA,IAAU,UACLC,EAAO,QAEZD,IAAU,YACLC,EAAO,WAAaA,EAAO,QAEhCD,IAAU,UACL,UAELA,IAAU,UACL,mBAEFA,EAEFA,CACT,CAeO,SAASH,EACdG,EACAE,EAC+C,CAC/C,OAAKF,EAGDA,IAAU,UACL,mBAELA,IAAU,UACL,UAEL,MAAM,QAAQA,CAAK,GACjBA,EAAM,OAAS,GAAK,MAAM,QAAQA,EAAM,CAAC,CAAC,EAErCA,GAKJJ,EAAaI,EAAyBE,EAAM,MAAM,EAhBhD,SAiBX,CAkBO,SAASP,EACdQ,EACAC,EAGO,CACP,MAAO,CACL,UAAW,KACX,GAAGD,EACH,GAAGC,EACH,OAAQ,CACN,UAAW,KACX,GAAGD,EAAK,OACR,GAAGC,EAAU,MACf,EACA,QAASA,EAAU,QACf,CACE,UAAW,KACX,GAAGD,EAAK,QACR,GAAGC,EAAU,QACb,QACEA,EAAU,QAAQ,UAAY,OAC1B,CACE,UAAW,KACX,GAAGD,EAAK,SAAS,QACjB,GAAGC,EAAU,QAAQ,OACvB,EACAD,EAAK,SAAS,QACpB,QACEC,EAAU,QAAQ,UAAY,OAC1B,CACE,UAAW,KACX,GAAGD,EAAK,SAAS,QACjB,GAAGC,EAAU,QAAQ,OACvB,EACAD,EAAK,SAAS,QACpB,MACEC,EAAU,QAAQ,QAAU,OACxB,CACE,UAAW,KACX,GAAGD,EAAK,SAAS,MACjB,GAAGC,EAAU,QAAQ,KACvB,EACAD,EAAK,SAAS,KACtB,EACAA,EAAK,QACT,KAAMC,EAAU,KACZ,CACE,UAAW,KACX,GAAGD,EAAK,KACR,GAAGC,EAAU,IACf,EACAD,EAAK,IACX,CACF,CA4BO,SAAST,EACdW,EAEO,CACP,MAAO,CACL,UAAW,KACX,KAAMA,EAAO,KACb,YAAaA,EAAO,YACpB,OAAQ,CAAE,UAAW,KAAM,GAAGA,EAAO,MAAO,EAC5C,QAASA,EAAO,QACZ,CAAE,UAAW,KAAM,GAAGA,EAAO,OAAQ,EACrC,OACJ,KAAMA,EAAO,KAAO,CAAE,UAAW,KAAM,GAAGA,EAAO,IAAK,EAAI,MAC5D,CACF",
|
|
6
|
+
"names": ["utils_exports", "__export", "createTheme", "extendTheme", "resolveColor", "resolveShimmerColor", "__toCommonJS", "import_ultra", "value", "colors", "theme", "base", "overrides", "config"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/lib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Core utilities and infrastructure for Socket.dev security tools",
|
|
6
6
|
"keywords": [
|
|
@@ -152,10 +152,6 @@
|
|
|
152
152
|
"types": "./dist/dlx-package.d.ts",
|
|
153
153
|
"default": "./dist/dlx-package.js"
|
|
154
154
|
},
|
|
155
|
-
"./download-lock": {
|
|
156
|
-
"types": "./dist/download-lock.d.ts",
|
|
157
|
-
"default": "./dist/download-lock.js"
|
|
158
|
-
},
|
|
159
155
|
"./effects/pulse-frames": {
|
|
160
156
|
"types": "./dist/effects/pulse-frames.d.ts",
|
|
161
157
|
"default": "./dist/effects/pulse-frames.js"
|
|
@@ -296,6 +292,14 @@
|
|
|
296
292
|
"types": "./dist/json.d.ts",
|
|
297
293
|
"default": "./dist/json.js"
|
|
298
294
|
},
|
|
295
|
+
"./links": {
|
|
296
|
+
"types": "./dist/links/index.d.ts",
|
|
297
|
+
"default": "./dist/links/index.js"
|
|
298
|
+
},
|
|
299
|
+
"./links/index": {
|
|
300
|
+
"types": "./dist/links/index.d.ts",
|
|
301
|
+
"default": "./dist/links/index.js"
|
|
302
|
+
},
|
|
299
303
|
"./logger": {
|
|
300
304
|
"types": "./dist/logger.d.ts",
|
|
301
305
|
"default": "./dist/logger.js"
|
|
@@ -397,8 +401,12 @@
|
|
|
397
401
|
"default": "./dist/promises.js"
|
|
398
402
|
},
|
|
399
403
|
"./prompts": {
|
|
400
|
-
"types": "./dist/prompts.d.ts",
|
|
401
|
-
"default": "./dist/prompts.js"
|
|
404
|
+
"types": "./dist/prompts/index.d.ts",
|
|
405
|
+
"default": "./dist/prompts/index.js"
|
|
406
|
+
},
|
|
407
|
+
"./prompts/index": {
|
|
408
|
+
"types": "./dist/prompts/index.d.ts",
|
|
409
|
+
"default": "./dist/prompts/index.js"
|
|
402
410
|
},
|
|
403
411
|
"./regexps": {
|
|
404
412
|
"types": "./dist/regexps.d.ts",
|
|
@@ -488,6 +496,30 @@
|
|
|
488
496
|
"types": "./dist/temporary-executor.d.ts",
|
|
489
497
|
"default": "./dist/temporary-executor.js"
|
|
490
498
|
},
|
|
499
|
+
"./themes": {
|
|
500
|
+
"types": "./dist/themes/index.d.ts",
|
|
501
|
+
"default": "./dist/themes/index.js"
|
|
502
|
+
},
|
|
503
|
+
"./themes/context": {
|
|
504
|
+
"types": "./dist/themes/context.d.ts",
|
|
505
|
+
"default": "./dist/themes/context.js"
|
|
506
|
+
},
|
|
507
|
+
"./themes/index": {
|
|
508
|
+
"types": "./dist/themes/index.d.ts",
|
|
509
|
+
"default": "./dist/themes/index.js"
|
|
510
|
+
},
|
|
511
|
+
"./themes/themes": {
|
|
512
|
+
"types": "./dist/themes/themes.d.ts",
|
|
513
|
+
"default": "./dist/themes/themes.js"
|
|
514
|
+
},
|
|
515
|
+
"./themes/types": {
|
|
516
|
+
"types": "./dist/themes/types.d.ts",
|
|
517
|
+
"default": "./dist/themes/types.js"
|
|
518
|
+
},
|
|
519
|
+
"./themes/utils": {
|
|
520
|
+
"types": "./dist/themes/utils.d.ts",
|
|
521
|
+
"default": "./dist/themes/utils.js"
|
|
522
|
+
},
|
|
491
523
|
"./types": {
|
|
492
524
|
"types": "./dist/types.d.ts",
|
|
493
525
|
"default": "./dist/types.js"
|
|
@@ -579,7 +611,7 @@
|
|
|
579
611
|
"@socketregistry/is-unicode-supported": "1.0.5",
|
|
580
612
|
"@socketregistry/packageurl-js": "1.3.1",
|
|
581
613
|
"@socketregistry/yocto-spinner": "1.0.19",
|
|
582
|
-
"@types/node": "24.
|
|
614
|
+
"@types/node": "24.9.2",
|
|
583
615
|
"@typescript/native-preview": "7.0.0-dev.20250920.1",
|
|
584
616
|
"@vitest/coverage-v8": "4.0.3",
|
|
585
617
|
"@vitest/ui": "4.0.3",
|
package/dist/download-lock.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { HttpDownloadOptions, HttpDownloadResult } from './http-request';
|
|
2
|
-
export interface DownloadLockInfo {
|
|
3
|
-
pid: number;
|
|
4
|
-
startTime: number;
|
|
5
|
-
url: string;
|
|
6
|
-
}
|
|
7
|
-
export interface DownloadWithLockOptions extends HttpDownloadOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Maximum time to wait for lock acquisition in milliseconds.
|
|
10
|
-
* @default 60000 (1 minute)
|
|
11
|
-
*/
|
|
12
|
-
lockTimeout?: number | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Directory where lock files are stored.
|
|
15
|
-
* @default '<destPath>.locks'
|
|
16
|
-
*/
|
|
17
|
-
locksDir?: string | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* Interval for checking stale locks in milliseconds.
|
|
20
|
-
* @default 1000 (1 second)
|
|
21
|
-
*/
|
|
22
|
-
pollInterval?: number | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Maximum age of a lock before it's considered stale in milliseconds.
|
|
25
|
-
* Aligned with npm's npx locking strategy (5-10 seconds).
|
|
26
|
-
* @default 10000 (10 seconds)
|
|
27
|
-
*/
|
|
28
|
-
staleTimeout?: number | undefined;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Download a file with locking to prevent concurrent downloads of the same resource.
|
|
32
|
-
* If another process is already downloading to the same destination, this will wait
|
|
33
|
-
* for the download to complete (up to lockTimeout) before proceeding.
|
|
34
|
-
*
|
|
35
|
-
* @throws {Error} When download fails or lock cannot be acquired.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const result = await downloadWithLock(
|
|
40
|
-
* 'https://example.com/file.tar.gz',
|
|
41
|
-
* '/tmp/downloads/file.tar.gz',
|
|
42
|
-
* {
|
|
43
|
-
* retries: 3,
|
|
44
|
-
* lockTimeout: 60000, // Wait up to 1 minute for other downloads
|
|
45
|
-
* }
|
|
46
|
-
* )
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export declare function downloadWithLock(url: string, destPath: string, options?: DownloadWithLockOptions | undefined): Promise<HttpDownloadResult>;
|
package/dist/download-lock.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var D=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var y=(o,t)=>{for(var n in t)D(o,n,{get:t[n],enumerable:!0})},I=(o,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of h(t))!L.call(o,r)&&r!==n&&D(o,r,{get:()=>t[r],enumerable:!(i=T(t,r))||i.enumerable});return o};var b=o=>I(D({},"__esModule",{value:!0}),o);var z={};y(z,{downloadWithLock:()=>x});module.exports=b(z);var f=require("node:fs"),e=require("node:fs/promises"),u=require("node:path"),g=require("./http-request");function O(o,t){const n=o.replace(/[^\w.-]/g,"_"),i=t||(0,u.join)((0,u.dirname)(o),".locks",n);return(0,u.join)(i,"concurrency.lock")}function S(o,t){if(Date.now()-o.startTime>t)return!0;try{return process.kill(o.pid,0),!1}catch{return!0}}async function $(o,t,n){const{lockTimeout:i,locksDir:r,pollInterval:m,staleTimeout:p}=n,s=O(o,r),w=(0,u.dirname)(s);await(0,e.mkdir)(w,{recursive:!0});const c=Date.now();for(;;)try{if((0,f.existsSync)(s)){const d=await(0,e.readFile)(s,"utf8"),l=JSON.parse(d);if(S(l,p))await(0,e.rm)(s,{force:!0});else{if(Date.now()-c>i){const k=Date.now()-l.startTime;throw new Error(`Download lock timed out after ${i}ms
|
|
3
|
-
Lock held by process ${l.pid} for ${k}ms
|
|
4
|
-
Resource: ${l.url}
|
|
5
|
-
Started: ${new Date(l.startTime).toISOString()}
|
|
6
|
-
To resolve:
|
|
7
|
-
1. Check if process ${l.pid} is still running: ps -p ${l.pid}
|
|
8
|
-
2. If stale, remove lock file: rm "${s}"
|
|
9
|
-
3. Or increase lockTimeout option`)}await new Promise(k=>setTimeout(k,m));continue}}const a={pid:process.pid,startTime:Date.now(),url:t};return await(0,e.writeFile)(s,JSON.stringify(a,null,2),{flag:"wx"}),s}catch(a){if(a.code==="EEXIST"){if(Date.now()-c>i)throw new Error(`Lock acquisition timed out after ${i}ms`);await new Promise(d=>setTimeout(d,m));continue}throw a}}async function v(o){try{await(0,e.rm)(o,{force:!0})}catch{}}async function x(o,t,n){const{lockTimeout:i=6e4,locksDir:r,pollInterval:m=1e3,staleTimeout:p=1e4,...s}={__proto__:null,...n};if((0,f.existsSync)(t)){const c=await(0,e.stat)(t).catch(()=>null);if(c&&c.size>0)return{path:t,size:c.size}}const w=await $(t,o,{lockTimeout:i,locksDir:r,pollInterval:m,staleTimeout:p});try{if((0,f.existsSync)(t)){const a=await(0,e.stat)(t).catch(()=>null);if(a&&a.size>0)return{path:t,size:a.size}}return await(0,g.httpDownload)(o,t,s)}finally{await v(w)}}0&&(module.exports={downloadWithLock});
|
|
10
|
-
//# sourceMappingURL=download-lock.js.map
|