@socketsecurity/lib 3.0.3 → 3.0.5
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 +47 -1
- package/dist/dlx.js +1 -1
- package/dist/dlx.js.map +2 -2
- package/dist/effects/pulse-frames.d.ts +7 -0
- package/dist/effects/pulse-frames.js.map +2 -2
- package/dist/effects/text-shimmer.d.ts +1 -0
- package/dist/effects/text-shimmer.js +13 -1
- package/dist/effects/text-shimmer.js.map +2 -2
- package/dist/effects/types.d.ts +6 -0
- package/dist/effects/types.js.map +1 -1
- package/dist/external/@socketregistry/packageurl-js.js +12 -2
- package/dist/links/index.js +2 -1
- package/dist/links/index.js.map +2 -2
- package/dist/logger.js +41 -2
- package/dist/logger.js.map +2 -2
- package/dist/objects.js.map +2 -2
- package/dist/packages/isolation.js +2 -4
- package/dist/packages/isolation.js.map +3 -3
- package/dist/spinner.d.ts +6 -0
- package/dist/spinner.js +14 -2
- package/dist/spinner.js.map +2 -2
- package/dist/stdio/prompts.d.ts +51 -8
- package/dist/stdio/prompts.js +82 -0
- package/dist/stdio/prompts.js.map +3 -3
- package/dist/themes/context.js.map +2 -2
- package/dist/themes/index.d.ts +2 -2
- package/dist/themes/index.js +2 -2
- package/dist/themes/index.js.map +1 -1
- package/dist/themes/themes.d.ts +5 -5
- package/dist/themes/themes.js +22 -13
- package/dist/themes/themes.js.map +2 -2
- package/package.json +2 -18
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -71
- package/dist/index.js.map +0 -7
- package/dist/prompts/index.d.ts +0 -115
- package/dist/prompts/index.js +0 -47
- package/dist/prompts/index.js.map +0 -7
- package/dist/prompts.d.ts +0 -27
- package/dist/prompts.js +0 -60
- package/dist/prompts.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,52 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.0.5](https://github.com/SocketDev/socket-lib/releases/tag/v3.0.5) - 2025-11-01
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Critical: Prompts API breaking changes**: Restored working prompts implementation that was accidentally replaced with non-functional stub in v3.0.0
|
|
13
|
+
- Consolidated all prompts functionality into `src/stdio/prompts.ts`
|
|
14
|
+
- Removed unimplemented stub from `src/prompts/` that was throwing "not yet implemented" errors
|
|
15
|
+
- Removed `./prompts` package export (use `@socketsecurity/lib/stdio/prompts` instead)
|
|
16
|
+
- Restored missing exports: `password`, `search`, `Separator`, and added `createSeparator()` helper
|
|
17
|
+
- Fixed `Choice` type to use correct `name` property (matching `@inquirer` API, not erroneous `label`)
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **Theme integration for prompts**: Prompts now automatically use the active theme colors
|
|
22
|
+
- Prompt messages styled with `colors.prompt`
|
|
23
|
+
- Descriptions and disabled items styled with `colors.textDim`
|
|
24
|
+
- Answers and highlights styled with `colors.primary`
|
|
25
|
+
- Error messages styled with `colors.error`
|
|
26
|
+
- Success indicators styled with `colors.success`
|
|
27
|
+
- Exported `createInquirerTheme()` function for converting Socket themes to @inquirer format
|
|
28
|
+
- Consistent visual experience with Logger and Spinner theme integration
|
|
29
|
+
|
|
30
|
+
- **Theme parameter support**: Logger, Prompts, and text effects now accept optional `theme` parameter
|
|
31
|
+
- Pass theme names (`'socket'`, `'sunset'`, `'terracotta'`, `'lush'`, `'ultra'`) or Theme objects
|
|
32
|
+
- **Logger**: `new Logger({ theme: 'sunset' })` - uses theme-specific symbol colors
|
|
33
|
+
- **Prompts**: `await input({ message: 'Name:', theme: 'ultra' })` - uses theme for prompt styling
|
|
34
|
+
- **Text effects**: `applyShimmer(text, state, { theme: 'terracotta' })` - uses theme for shimmer colors
|
|
35
|
+
- Instance-specific themes override global theme context when provided
|
|
36
|
+
- Falls back to global theme context when no instance theme specified
|
|
37
|
+
- **Note**: Spinner already had theme parameter support in v3.0.0
|
|
38
|
+
|
|
39
|
+
### Removed
|
|
40
|
+
|
|
41
|
+
- **Unused index entrypoint**: Removed `src/index.ts` and package exports for `"."` and `"./index"`
|
|
42
|
+
- This was a leftover from socket-registry and not needed for this library
|
|
43
|
+
- Users should import specific modules directly (e.g., `@socketsecurity/lib/logger`)
|
|
44
|
+
- Breaking: `import { getDefaultLogger } from '@socketsecurity/lib'` no longer works
|
|
45
|
+
- Use: `import { getDefaultLogger } from '@socketsecurity/lib/logger'` instead
|
|
46
|
+
|
|
47
|
+
## [3.0.4](https://github.com/SocketDev/socket-lib/releases/tag/v3.0.4) - 2025-11-01
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- **Sunset theme**: Updated colors from azure blue to warm orange/purple gradient matching Coana branding
|
|
52
|
+
- **Terracotta theme**: Renamed from `brick` to `terracotta` for better clarity
|
|
53
|
+
|
|
8
54
|
## [3.0.3](https://github.com/SocketDev/socket-lib/releases/tag/v3.0.3) - 2025-11-01
|
|
9
55
|
|
|
10
56
|
### Fixed
|
|
@@ -54,7 +100,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
54
100
|
|
|
55
101
|
### Added
|
|
56
102
|
|
|
57
|
-
- Theme system with 5 built-in themes: `socket`, `sunset`, `
|
|
103
|
+
- Theme system with 5 built-in themes: `socket`, `sunset`, `terracotta`, `lush`, `ultra`
|
|
58
104
|
- `setTheme()`, `getTheme()`, `withTheme()`, `withThemeSync()` for theme management
|
|
59
105
|
- `createTheme()`, `extendTheme()`, `resolveColor()` helper functions
|
|
60
106
|
- `onThemeChange()` event listener for theme reactivity
|
package/dist/dlx.js
CHANGED
|
@@ -118,7 +118,7 @@ function isInSocketDlx(filePath) {
|
|
|
118
118
|
const path = /* @__PURE__ */ getPath();
|
|
119
119
|
const dlxDir = (0, import_paths.getSocketDlxDir)();
|
|
120
120
|
const absolutePath = (0, import_path.normalizePath)(path.resolve(filePath));
|
|
121
|
-
return absolutePath.startsWith(dlxDir
|
|
121
|
+
return absolutePath.startsWith(`${dlxDir}/`);
|
|
122
122
|
}
|
|
123
123
|
function isDlxPackageInstalled(packageName) {
|
|
124
124
|
const fs = /* @__PURE__ */ getFs();
|
package/dist/dlx.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/dlx.ts"],
|
|
4
|
-
"sourcesContent": ["/** @fileoverview DLX (execute package) utilities for Socket ecosystem shared installations. */\n\nimport { createHash } from 'crypto'\n\nimport { readDirNamesSync, safeDelete, safeMkdir, safeMkdirSync } from './fs'\nimport { normalizePath } from './path'\nimport { getSocketDlxDir } from './paths'\nimport { pEach } from './promises'\n\nlet _fs: typeof import('fs') | undefined\n/**\n * Lazily load the fs module to avoid Webpack errors.\n * Uses non-'node:' prefixed require to prevent Webpack bundling issues.\n *\n * @returns The Node.js fs module\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFs() {\n if (_fs === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _fs = /*@__PURE__*/ require('node:fs')\n }\n return _fs as typeof import('fs')\n}\n\n/**\n * Generate a cache directory name using npm/npx approach.\n * Uses first 16 characters of SHA-512 hash (like npm/npx).\n *\n * Rationale for SHA-512 truncated (vs full SHA-256):\n * - Matches npm/npx ecosystem behavior\n * - Shorter paths for Windows MAX_PATH compatibility (260 chars)\n * - 16 hex chars = 64 bits = acceptable collision risk for local cache\n * - Collision probability ~1 in 18 quintillion with 1000 entries\n *\n * Input strategy (aligned with npx):\n * - npx uses package spec strings (e.g., '@scope/pkg@1.0.0', 'prettier@3.0.0')\n * - Caller provides complete spec string with version for accurate cache keying\n * - For package installs: Use PURL-style spec with version\n * Examples: 'npm:prettier@3.0.0', 'pypi:requests@2.31.0', 'gem:rails@7.0.0'\n * Note: Socket uses shorthand format without 'pkg:' prefix\n * (handled by @socketregistry/packageurl-js)\n * - For binary downloads: Use URL:name for uniqueness\n *\n * Reference: npm/cli v11.6.2 libnpmexec/lib/index.js#L233-L244\n * https://github.com/npm/cli/blob/v11.6.2/workspaces/libnpmexec/lib/index.js#L233-L244\n * Implementation: packages.map().sort().join('\\n') \u2192 SHA-512 \u2192 slice(0,16)\n * npx hashes the package spec (name@version), not just name\n */\nexport function generateCacheKey(spec: string): string {\n return createHash('sha512').update(spec).digest('hex').substring(0, 16)\n}\n\nlet _path: typeof import('path') | undefined\n/**\n * Lazily load the path module to avoid Webpack errors.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path!\n}\n\n/**\n * Clear all DLX package installations.\n */\nexport async function clearDlx(): Promise<void> {\n const packages = await listDlxPackagesAsync()\n await pEach(packages, pkg => removeDlxPackage(pkg))\n}\n\n/**\n * Clear all DLX package installations synchronously.\n */\nexport function clearDlxSync(): void {\n const packages = listDlxPackages()\n for (const pkg of packages) {\n removeDlxPackageSync(pkg)\n }\n}\n\n/**\n * Check if the DLX directory exists.\n */\nexport function dlxDirExists(): boolean {\n const fs = getFs()\n return fs.existsSync(getSocketDlxDir())\n}\n\n/**\n * Check if the DLX directory exists asynchronously.\n */\nexport async function dlxDirExistsAsync(): Promise<boolean> {\n const fs = getFs()\n try {\n await fs.promises.access(getSocketDlxDir())\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Ensure the DLX directory exists, creating it if necessary.\n */\nexport async function ensureDlxDir(): Promise<void> {\n await safeMkdir(getSocketDlxDir(), { recursive: true })\n}\n\n/**\n * Ensure the DLX directory exists synchronously, creating it if necessary.\n */\nexport function ensureDlxDirSync(): void {\n safeMkdirSync(getSocketDlxDir(), { recursive: true })\n}\n\n/**\n * Get the installed package directory within DLX node_modules.\n */\nexport function getDlxInstalledPackageDir(packageName: string): string {\n const path = getPath()\n return normalizePath(\n path.join(getDlxPackageNodeModulesDir(packageName), packageName),\n )\n}\n\n/**\n * Get the DLX installation directory for a specific package.\n */\nexport function getDlxPackageDir(packageName: string): string {\n const path = getPath()\n return normalizePath(path.join(getSocketDlxDir(), packageName))\n}\n\n/**\n * Get the package.json path for a DLX installed package.\n */\nexport function getDlxPackageJsonPath(packageName: string): string {\n const path = getPath()\n return normalizePath(\n path.join(getDlxInstalledPackageDir(packageName), 'package.json'),\n )\n}\n\n/**\n * Get the node_modules directory for a DLX package installation.\n */\nexport function getDlxPackageNodeModulesDir(packageName: string): string {\n const path = getPath()\n return normalizePath(path.join(getDlxPackageDir(packageName), 'node_modules'))\n}\n\n/**\n * Check if a file path is within the Socket DLX directory.\n * This is useful for determining if a binary or file is managed by Socket's DLX system.\n *\n * @param filePath - Absolute or relative path to check\n * @returns true if the path is within ~/.socket/_dlx/, false otherwise\n *\n * @example\n * ```typescript\n * isInSocketDlx('/home/user/.socket/_dlx/abc123/bin/socket') // true\n * isInSocketDlx('/usr/local/bin/socket') // false\n * isInSocketDlx(process.argv[0]) // Check if current binary is in DLX\n * ```\n */\nexport function isInSocketDlx(filePath: string): boolean {\n if (!filePath) {\n return false\n }\n\n const path = getPath()\n const dlxDir = getSocketDlxDir()\n const absolutePath = normalizePath(path.resolve(filePath))\n\n // Check if the absolute path starts with the DLX directory.\n // Both paths are normalized to use forward slashes for consistent comparison.\n return absolutePath.startsWith(dlxDir
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAE3B,gBAAuE;AACvE,kBAA8B;AAC9B,mBAAgC;AAChC,sBAAsB;AAEtB,IAAI;AAAA;AASJ,SAAS,QAAQ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6B;AACjE,QAAM,OAAO,wBAAQ;AACrB,aAAO;AAAA,IACL,KAAK,KAAK,0BAA0B,WAAW,GAAG,cAAc;AAAA,EAClE;AACF;AAKO,SAAS,4BAA4B,aAA6B;AACvE,QAAM,OAAO,wBAAQ;AACrB,aAAO,2BAAc,KAAK,KAAK,iBAAiB,WAAW,GAAG,cAAc,CAAC;AAC/E;AAgBO,SAAS,cAAc,UAA2B;AACvD,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,wBAAQ;AACrB,QAAM,aAAS,8BAAgB;AAC/B,QAAM,mBAAe,2BAAc,KAAK,QAAQ,QAAQ,CAAC;AAIzD,SAAO,aAAa,WAAW,
|
|
4
|
+
"sourcesContent": ["/** @fileoverview DLX (execute package) utilities for Socket ecosystem shared installations. */\n\nimport { createHash } from 'crypto'\n\nimport { readDirNamesSync, safeDelete, safeMkdir, safeMkdirSync } from './fs'\nimport { normalizePath } from './path'\nimport { getSocketDlxDir } from './paths'\nimport { pEach } from './promises'\n\nlet _fs: typeof import('fs') | undefined\n/**\n * Lazily load the fs module to avoid Webpack errors.\n * Uses non-'node:' prefixed require to prevent Webpack bundling issues.\n *\n * @returns The Node.js fs module\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFs() {\n if (_fs === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _fs = /*@__PURE__*/ require('node:fs')\n }\n return _fs as typeof import('fs')\n}\n\n/**\n * Generate a cache directory name using npm/npx approach.\n * Uses first 16 characters of SHA-512 hash (like npm/npx).\n *\n * Rationale for SHA-512 truncated (vs full SHA-256):\n * - Matches npm/npx ecosystem behavior\n * - Shorter paths for Windows MAX_PATH compatibility (260 chars)\n * - 16 hex chars = 64 bits = acceptable collision risk for local cache\n * - Collision probability ~1 in 18 quintillion with 1000 entries\n *\n * Input strategy (aligned with npx):\n * - npx uses package spec strings (e.g., '@scope/pkg@1.0.0', 'prettier@3.0.0')\n * - Caller provides complete spec string with version for accurate cache keying\n * - For package installs: Use PURL-style spec with version\n * Examples: 'npm:prettier@3.0.0', 'pypi:requests@2.31.0', 'gem:rails@7.0.0'\n * Note: Socket uses shorthand format without 'pkg:' prefix\n * (handled by @socketregistry/packageurl-js)\n * - For binary downloads: Use URL:name for uniqueness\n *\n * Reference: npm/cli v11.6.2 libnpmexec/lib/index.js#L233-L244\n * https://github.com/npm/cli/blob/v11.6.2/workspaces/libnpmexec/lib/index.js#L233-L244\n * Implementation: packages.map().sort().join('\\n') \u2192 SHA-512 \u2192 slice(0,16)\n * npx hashes the package spec (name@version), not just name\n */\nexport function generateCacheKey(spec: string): string {\n return createHash('sha512').update(spec).digest('hex').substring(0, 16)\n}\n\nlet _path: typeof import('path') | undefined\n/**\n * Lazily load the path module to avoid Webpack errors.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path!\n}\n\n/**\n * Clear all DLX package installations.\n */\nexport async function clearDlx(): Promise<void> {\n const packages = await listDlxPackagesAsync()\n await pEach(packages, pkg => removeDlxPackage(pkg))\n}\n\n/**\n * Clear all DLX package installations synchronously.\n */\nexport function clearDlxSync(): void {\n const packages = listDlxPackages()\n for (const pkg of packages) {\n removeDlxPackageSync(pkg)\n }\n}\n\n/**\n * Check if the DLX directory exists.\n */\nexport function dlxDirExists(): boolean {\n const fs = getFs()\n return fs.existsSync(getSocketDlxDir())\n}\n\n/**\n * Check if the DLX directory exists asynchronously.\n */\nexport async function dlxDirExistsAsync(): Promise<boolean> {\n const fs = getFs()\n try {\n await fs.promises.access(getSocketDlxDir())\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Ensure the DLX directory exists, creating it if necessary.\n */\nexport async function ensureDlxDir(): Promise<void> {\n await safeMkdir(getSocketDlxDir(), { recursive: true })\n}\n\n/**\n * Ensure the DLX directory exists synchronously, creating it if necessary.\n */\nexport function ensureDlxDirSync(): void {\n safeMkdirSync(getSocketDlxDir(), { recursive: true })\n}\n\n/**\n * Get the installed package directory within DLX node_modules.\n */\nexport function getDlxInstalledPackageDir(packageName: string): string {\n const path = getPath()\n return normalizePath(\n path.join(getDlxPackageNodeModulesDir(packageName), packageName),\n )\n}\n\n/**\n * Get the DLX installation directory for a specific package.\n */\nexport function getDlxPackageDir(packageName: string): string {\n const path = getPath()\n return normalizePath(path.join(getSocketDlxDir(), packageName))\n}\n\n/**\n * Get the package.json path for a DLX installed package.\n */\nexport function getDlxPackageJsonPath(packageName: string): string {\n const path = getPath()\n return normalizePath(\n path.join(getDlxInstalledPackageDir(packageName), 'package.json'),\n )\n}\n\n/**\n * Get the node_modules directory for a DLX package installation.\n */\nexport function getDlxPackageNodeModulesDir(packageName: string): string {\n const path = getPath()\n return normalizePath(path.join(getDlxPackageDir(packageName), 'node_modules'))\n}\n\n/**\n * Check if a file path is within the Socket DLX directory.\n * This is useful for determining if a binary or file is managed by Socket's DLX system.\n *\n * @param filePath - Absolute or relative path to check\n * @returns true if the path is within ~/.socket/_dlx/, false otherwise\n *\n * @example\n * ```typescript\n * isInSocketDlx('/home/user/.socket/_dlx/abc123/bin/socket') // true\n * isInSocketDlx('/usr/local/bin/socket') // false\n * isInSocketDlx(process.argv[0]) // Check if current binary is in DLX\n * ```\n */\nexport function isInSocketDlx(filePath: string): boolean {\n if (!filePath) {\n return false\n }\n\n const path = getPath()\n const dlxDir = getSocketDlxDir()\n const absolutePath = normalizePath(path.resolve(filePath))\n\n // Check if the absolute path starts with the DLX directory.\n // Both paths are normalized to use forward slashes for consistent comparison.\n return absolutePath.startsWith(`${dlxDir}/`)\n}\n\n/**\n * Check if a package is installed in DLX.\n */\nexport function isDlxPackageInstalled(packageName: string): boolean {\n const fs = getFs()\n return fs.existsSync(getDlxInstalledPackageDir(packageName))\n}\n\n/**\n * Check if a package is installed in DLX asynchronously.\n */\nexport async function isDlxPackageInstalledAsync(\n packageName: string,\n): Promise<boolean> {\n const fs = getFs()\n try {\n await fs.promises.access(getDlxInstalledPackageDir(packageName))\n return true\n } catch {\n return false\n }\n}\n\n/**\n * List all packages installed in DLX.\n */\nexport function listDlxPackages(): string[] {\n try {\n return readDirNamesSync(getSocketDlxDir(), { sort: true })\n } catch {\n return []\n }\n}\n\n/**\n * List all packages installed in DLX asynchronously.\n */\nexport async function listDlxPackagesAsync(): Promise<string[]> {\n const fs = getFs()\n try {\n const entries = await fs.promises.readdir(getSocketDlxDir(), {\n withFileTypes: true,\n })\n return entries\n .filter(e => e.isDirectory())\n .map(e => e.name)\n .sort()\n } catch {\n return []\n }\n}\n\n/**\n * Remove a DLX package installation.\n */\nexport async function removeDlxPackage(packageName: string): Promise<void> {\n const packageDir = getDlxPackageDir(packageName)\n try {\n await safeDelete(packageDir, { recursive: true, force: true })\n } catch (e) {\n throw new Error(`Failed to remove DLX package \"${packageName}\"`, {\n cause: e,\n })\n }\n}\n\n/**\n * Remove a DLX package installation synchronously.\n */\nexport function removeDlxPackageSync(packageName: string): void {\n const fs = getFs()\n const packageDir = getDlxPackageDir(packageName)\n try {\n fs.rmSync(packageDir, { recursive: true, force: true })\n } catch (e) {\n const code = (e as NodeJS.ErrnoException).code\n if (code === 'EACCES' || code === 'EPERM') {\n throw new Error(\n `Permission denied removing DLX package \"${packageName}\"\\n` +\n `Directory: ${packageDir}\\n` +\n 'To resolve:\\n' +\n ' 1. Check file/directory permissions\\n' +\n ' 2. Close any programs using files in this directory\\n' +\n ' 3. Try running with elevated privileges if necessary\\n' +\n ` 4. Manually remove: rm -rf \"${packageDir}\"`,\n { cause: e },\n )\n }\n if (code === 'EROFS') {\n throw new Error(\n `Cannot remove DLX package \"${packageName}\" from read-only filesystem\\n` +\n `Directory: ${packageDir}\\n` +\n 'The filesystem is mounted read-only.',\n { cause: e },\n )\n }\n throw new Error(\n `Failed to remove DLX package \"${packageName}\"\\n` +\n `Directory: ${packageDir}\\n` +\n 'Check permissions and ensure no programs are using this directory.',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6,13 @@
|
|
|
6
6
|
export type SocketFramesOptions = {
|
|
7
7
|
readonly baseColor?: readonly [number, number, number] | undefined;
|
|
8
8
|
readonly interval?: number | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Theme to use for pulse colors.
|
|
11
|
+
* Can be a theme name ('socket', 'sunset', etc.) or a Theme object.
|
|
12
|
+
* Note: Currently frames only contain brightness modifiers.
|
|
13
|
+
* Colors are applied by yocto-spinner based on spinner.color.
|
|
14
|
+
*/
|
|
15
|
+
readonly theme?: import('../themes/types').Theme | import('../themes/themes').ThemeName | undefined;
|
|
9
16
|
};
|
|
10
17
|
/**
|
|
11
18
|
* Generate Socket pulse animation frames.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/effects/pulse-frames.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Socket pulse animation frames generator.\n * Generates themeable pulsing animation frames using sparkles (\u2727 \u2726) and lightning (\u26A1).\n * Follows the cli-spinners format: https://github.com/sindresorhus/cli-spinners\n */\n\nexport type SocketFramesOptions = {\n readonly baseColor?: readonly [number, number, number] | undefined\n readonly interval?: number | undefined\n}\n\n/**\n * Generate Socket pulse animation frames.\n * Creates a pulsing throbber using Unicode sparkles and lightning symbols.\n * Frames use brightness modifiers (bold/dim) but no embedded colors.\n * Yocto-spinner applies the current spinner color to each frame.\n *\n * Returns a spinner definition compatible with cli-spinners format.\n *\n * @see https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json\n */\nexport function generateSocketSpinnerFrames(\n options?: SocketFramesOptions | undefined,\n): {\n frames: string[]\n interval: number\n} {\n const opts = { __proto__: null, ...options } as SocketFramesOptions\n const interval = opts.interval ?? 50\n\n // ANSI codes for brightness modifiers only (no colors).\n // Yocto-spinner will apply the spinner's current color to each frame.\n const bold = '\\x1b[1m'\n const dim = '\\x1b[2m'\n const reset = '\\x1b[0m'\n\n // Using VS15 (\\uFE0E) to force text-style rendering.\n // Lightning bolt (\u26A1) is wider than stars. To keep consistent spacing:\n // - All frames have NO internal padding\n // - Yocto-spinner adds 1 space after each frame\n // - Success/fail symbols also get 1 space (consistent)\n const lightning = '\u26A1\\uFE0E'\n const starFilled = '\u2726\\uFE0E'\n const starOutline = '\u2727\\uFE0E'\n const starTiny = '\u22C6\\uFE0E'\n\n // Pulse frames with brightness modifiers only.\n // Each frame gets colored by yocto-spinner based on current spinner.color.\n // Yocto-spinner adds 1 space after the frame automatically.\n const frames = [\n // Build up from dim to bright\n `${dim}${starOutline}${reset}`,\n `${dim}${starOutline}${reset}`,\n `${dim}${starTiny}${reset}`,\n `${starFilled}${reset}`,\n `${starFilled}${reset}`,\n `${bold}${starFilled}${reset}`,\n `${bold}${starFilled}${reset}`,\n `${bold}${lightning}${reset}`,\n `${bold}${lightning}${reset}`,\n `${bold}${lightning}${reset}`,\n // Fade down\n `${bold}${lightning}${reset}`,\n `${bold}${lightning}${reset}`,\n `${bold}${starFilled}${reset}`,\n `${bold}${starFilled}${reset}`,\n `${starFilled}${reset}`,\n `${starFilled}${reset}`,\n `${dim}${starTiny}${reset}`,\n `${dim}${starOutline}${reset}`,\n ]\n\n return {\n __proto__: null,\n frames,\n interval,\n } as { frames: string[]; interval: number }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Socket pulse animation frames generator.\n * Generates themeable pulsing animation frames using sparkles (\u2727 \u2726) and lightning (\u26A1).\n * Follows the cli-spinners format: https://github.com/sindresorhus/cli-spinners\n */\n\nexport type SocketFramesOptions = {\n readonly baseColor?: readonly [number, number, number] | undefined\n readonly interval?: number | undefined\n /**\n * Theme to use for pulse colors.\n * Can be a theme name ('socket', 'sunset', etc.) or a Theme object.\n * Note: Currently frames only contain brightness modifiers.\n * Colors are applied by yocto-spinner based on spinner.color.\n */\n readonly theme?:\n | import('../themes/types').Theme\n | import('../themes/themes').ThemeName\n | undefined\n}\n\n/**\n * Generate Socket pulse animation frames.\n * Creates a pulsing throbber using Unicode sparkles and lightning symbols.\n * Frames use brightness modifiers (bold/dim) but no embedded colors.\n * Yocto-spinner applies the current spinner color to each frame.\n *\n * Returns a spinner definition compatible with cli-spinners format.\n *\n * @see https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json\n */\nexport function generateSocketSpinnerFrames(\n options?: SocketFramesOptions | undefined,\n): {\n frames: string[]\n interval: number\n} {\n const opts = { __proto__: null, ...options } as SocketFramesOptions\n const interval = opts.interval ?? 50\n\n // ANSI codes for brightness modifiers only (no colors).\n // Yocto-spinner will apply the spinner's current color to each frame.\n const bold = '\\x1b[1m'\n const dim = '\\x1b[2m'\n const reset = '\\x1b[0m'\n\n // Using VS15 (\\uFE0E) to force text-style rendering.\n // Lightning bolt (\u26A1) is wider than stars. To keep consistent spacing:\n // - All frames have NO internal padding\n // - Yocto-spinner adds 1 space after each frame\n // - Success/fail symbols also get 1 space (consistent)\n const lightning = '\u26A1\\uFE0E'\n const starFilled = '\u2726\\uFE0E'\n const starOutline = '\u2727\\uFE0E'\n const starTiny = '\u22C6\\uFE0E'\n\n // Pulse frames with brightness modifiers only.\n // Each frame gets colored by yocto-spinner based on current spinner.color.\n // Yocto-spinner adds 1 space after the frame automatically.\n const frames = [\n // Build up from dim to bright\n `${dim}${starOutline}${reset}`,\n `${dim}${starOutline}${reset}`,\n `${dim}${starTiny}${reset}`,\n `${starFilled}${reset}`,\n `${starFilled}${reset}`,\n `${bold}${starFilled}${reset}`,\n `${bold}${starFilled}${reset}`,\n `${bold}${lightning}${reset}`,\n `${bold}${lightning}${reset}`,\n `${bold}${lightning}${reset}`,\n // Fade down\n `${bold}${lightning}${reset}`,\n `${bold}${lightning}${reset}`,\n `${bold}${starFilled}${reset}`,\n `${bold}${starFilled}${reset}`,\n `${starFilled}${reset}`,\n `${starFilled}${reset}`,\n `${dim}${starTiny}${reset}`,\n `${dim}${starOutline}${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,KAAK;AAAA,EAC9B;AAEA,SAAO;AAAA,IACL,WAAW;AAAA,IACX;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,6 +17,7 @@ type ShimmerOptions = {
|
|
|
17
17
|
readonly direction?: ShimmerDirection | undefined;
|
|
18
18
|
readonly shimmerWidth?: number | undefined;
|
|
19
19
|
readonly styles?: TextStyles | undefined;
|
|
20
|
+
readonly theme?: import('../themes/types').Theme | import('../themes/themes').ThemeName | undefined;
|
|
20
21
|
};
|
|
21
22
|
export declare const COLOR_INHERIT = "inherit";
|
|
22
23
|
export declare const DIR_LTR = "ltr";
|
|
@@ -30,6 +30,8 @@ module.exports = __toCommonJS(text_shimmer_exports);
|
|
|
30
30
|
var import_ansi = require("../ansi");
|
|
31
31
|
var import_arrays = require("../arrays");
|
|
32
32
|
var import_ci = require("#env/ci");
|
|
33
|
+
var import_utils = require("../themes/utils");
|
|
34
|
+
var import_themes = require("../themes/themes");
|
|
33
35
|
function detectStyles(text) {
|
|
34
36
|
return {
|
|
35
37
|
__proto__: null,
|
|
@@ -121,7 +123,17 @@ function applyShimmer(text, state, options) {
|
|
|
121
123
|
const opts = { __proto__: null, ...options };
|
|
122
124
|
const direction = opts.direction ?? DIR_NONE;
|
|
123
125
|
const shimmerWidth = opts.shimmerWidth ?? 2.5;
|
|
124
|
-
|
|
126
|
+
let color;
|
|
127
|
+
if (opts.theme) {
|
|
128
|
+
const theme = typeof opts.theme === "string" ? import_themes.THEMES[opts.theme] : opts.theme;
|
|
129
|
+
const themeColor = (0, import_utils.resolveColor)(
|
|
130
|
+
theme.colors.primary,
|
|
131
|
+
theme.colors
|
|
132
|
+
);
|
|
133
|
+
color = typeof themeColor === "string" ? [140, 82, 255] : themeColor;
|
|
134
|
+
} else {
|
|
135
|
+
color = opts.color ?? [140, 82, 255];
|
|
136
|
+
}
|
|
125
137
|
const styles = opts.styles ?? detectStyles(text);
|
|
126
138
|
const plainText = (0, import_ansi.stripAnsi)(text);
|
|
127
139
|
if ((0, import_ci.getCI)() || !plainText || direction === DIR_NONE) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/effects/text-shimmer.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Text shimmer animation utilities.\n * Provides animated highlight effects for spinner text with configurable directions:\n * - LTR (left-to-right): Shimmer wave moves from left to right\n * - RTL (right-to-left): Shimmer wave moves from right to left\n * - Bidirectional: Alternates between LTR and RTL each cycle\n * - Random: Picks a random direction each cycle\n * - None: No shimmer animation\n *\n * The shimmer effect creates a bright wave that travels across the text,\n * with characters near the wave appearing nearly white and fading to the\n * base color as they get further from the wave position.\n */\n\nimport { ANSI_RESET, stripAnsi } from '../ansi'\nimport { isArray } from '../arrays'\nimport { getCI } from '#env/ci'\n\nimport type {\n ShimmerColorGradient,\n ShimmerColorRgb,\n ShimmerDirection,\n ShimmerState,\n} from './types'\n\n// Re-export types for backward compatibility.\nexport type {\n ShimmerColor,\n ShimmerColorGradient,\n ShimmerColorInherit,\n ShimmerColorRgb,\n ShimmerConfig,\n ShimmerDirection,\n ShimmerState,\n} from './types'\n\n/**\n * Detected text formatting styles from ANSI codes.\n */\ntype TextStyles = {\n bold: boolean\n dim: boolean\n italic: boolean\n strikethrough: boolean\n underline: boolean\n}\n\n/**\n * Detect all text formatting styles present in ANSI-coded text.\n * Checks for bold, dim, italic, underline, and strikethrough.\n */\nfunction detectStyles(text: string): TextStyles {\n return {\n __proto__: null,\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n bold: /\\x1b\\[1m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n dim: /\\x1b\\[2m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n italic: /\\x1b\\[3m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n strikethrough: /\\x1b\\[9m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n underline: /\\x1b\\[4m/.test(text),\n } as TextStyles\n}\n\n/**\n * Build ANSI code string from text styles.\n * Returns the concatenated ANSI codes needed to apply the styles.\n */\nfunction stylesToAnsi(styles: TextStyles): string {\n let codes = ''\n if (styles.bold) {\n codes += '\\x1b[1m'\n }\n if (styles.dim) {\n codes += '\\x1b[2m'\n }\n if (styles.italic) {\n codes += '\\x1b[3m'\n }\n if (styles.underline) {\n codes += '\\x1b[4m'\n }\n if (styles.strikethrough) {\n codes += '\\x1b[9m'\n }\n return codes\n}\n\n// Internal options for applyShimmer function.\ntype ShimmerOptions = {\n readonly color?: ShimmerColorRgb | ShimmerColorGradient | undefined\n readonly direction?: ShimmerDirection | undefined\n readonly shimmerWidth?: number | undefined\n readonly styles?: TextStyles | undefined\n}\n\nexport const COLOR_INHERIT = 'inherit'\n\nexport const DIR_LTR = 'ltr'\n\nexport const DIR_NONE = 'none'\n\nexport const DIR_RANDOM = 'random'\n\nexport const DIR_RTL = 'rtl'\n\nexport const MODE_BI = 'bi'\n\n/**\n * Calculate shimmer intensity based on distance from shimmer wave position.\n * Uses a power curve for smooth falloff - characters close to the wave\n * get high intensity (bright white), while distant characters get 0.\n */\nfunction shimmerIntensity(\n distance: number,\n shimmerWidth: number = 2.5,\n): number {\n // Characters beyond shimmer width get no effect.\n if (distance > shimmerWidth) {\n return 0\n }\n // Smooth falloff using power curve.\n const normalized = distance / shimmerWidth\n return (1 - normalized) ** 2.5\n}\n\n/**\n * Blend two RGB colors based on a blend factor (0-1).\n * factor 0 = color1, factor 1 = color2, factor 0.5 = 50/50 blend.\n */\nfunction blendColors(\n color1: readonly [number, number, number],\n color2: readonly [number, number, number],\n factor: number,\n): readonly [number, number, number] {\n const r = Math.round(color1[0] + (color2[0] - color1[0]) * factor)\n const g = Math.round(color1[1] + (color2[1] - color1[1]) * factor)\n const b = Math.round(color1[2] + (color2[2] - color1[2]) * factor)\n return [r, g, b] as const\n}\n\n/**\n * Render character with shimmer effect based on distance from shimmer position.\n * Characters closer to the shimmer position get brighter (nearly white),\n * while characters further away use the base color.\n * Creates a smooth gradient by blending base color with white based on intensity.\n * Supports both single color and per-character color gradients.\n */\nfunction renderChar(\n char: string,\n index: number,\n shimmerPos: number,\n baseColor: readonly [number, number, number] | ShimmerColorGradient,\n styles: TextStyles,\n): string {\n // Calculate how far this character is from the shimmer wave.\n const distance = Math.abs(index - shimmerPos)\n const intensity = shimmerIntensity(distance)\n\n const styleCode = stylesToAnsi(styles)\n\n // Get base color for this character (single or per-character from gradient).\n const charColor: readonly [number, number, number] = isArray(baseColor[0])\n ? ((baseColor as ShimmerColorGradient)[index % baseColor.length] ?? [\n 140, 82, 255,\n ])\n : (baseColor as readonly [number, number, number])\n\n // If no shimmer intensity, use base color as-is.\n if (intensity === 0) {\n const base = `\\x1b[38;2;${charColor[0]};${charColor[1]};${charColor[2]}m`\n return `${styleCode}${base}${char}${ANSI_RESET}`\n }\n\n // Blend base color with white based on intensity to create smooth gradient.\n // Higher intensity = more white, creating the shimmer wave effect.\n const white: readonly [number, number, number] = [255, 255, 255] as const\n const blended = blendColors(charColor, white, intensity)\n\n const color = `\\x1b[38;2;${blended[0]};${blended[1]};${blended[2]}m`\n return `${styleCode}${color}${char}${ANSI_RESET}`\n}\n\n/**\n * Calculate shimmer wave position for current animation step.\n * The shimmer wave moves across the text length, with extra space\n * for the wave to fade in/out at the edges.\n */\nfunction getShimmerPos(\n textLength: number,\n step: number,\n currentDir: 'ltr' | 'rtl',\n shimmerWidth: number = 2.5,\n): number {\n // Total steps for one complete cycle (text length + fade in/out space).\n const totalSteps = textLength + shimmerWidth + 2\n\n // RTL: Shimmer moves from right to left.\n if (currentDir === DIR_RTL) {\n return textLength - (step % totalSteps)\n }\n\n // LTR: Shimmer moves from left to right.\n return step % totalSteps\n}\n\n/**\n * Resolve shimmer direction to a concrete 'ltr' or 'rtl' value.\n * Used for initializing shimmer state and picking random directions.\n */\nfunction pickDirection(direction: ShimmerDirection): 'ltr' | 'rtl' {\n // Random mode: 50/50 chance of LTR or RTL.\n if (direction === DIR_RANDOM) {\n return Math.random() < 0.5 ? DIR_LTR : DIR_RTL\n }\n // RTL mode: Use RTL direction.\n if (direction === DIR_RTL) {\n return DIR_RTL\n }\n // LTR mode (or any other): Default to LTR.\n return DIR_LTR\n}\n\n/**\n * Apply shimmer animation effect to text.\n * This is the main entry point for shimmer animations. It:\n * 1. Strips ANSI codes to get plain text for character positioning\n * 2. Detects any styling (bold, italic, underline, etc.) to preserve\n * 3. Calculates the current shimmer wave position based on animation step\n * 4. Renders each character with appropriate brightness based on distance from wave\n * 5. Updates the animation state for the next frame\n * 6. Handles direction changes for bidirectional and random modes\n */\nexport function applyShimmer(\n text: string,\n state: ShimmerState,\n options?: ShimmerOptions | undefined,\n): string {\n const opts = { __proto__: null, ...options } as ShimmerOptions\n const direction = opts.direction ?? DIR_NONE\n const shimmerWidth = opts.shimmerWidth ?? 2.5\n // Socket purple.\n const color = opts.color ?? ([140, 82, 255] as const)\n\n // Detect text formatting styles from original text.\n const styles = opts.styles ?? detectStyles(text)\n\n // Strip ANSI codes to get plain text.\n const plainText = stripAnsi(text)\n\n // No shimmer effect in CI or when direction is 'none'.\n if (getCI() || !plainText || direction === DIR_NONE) {\n const styleCode = stylesToAnsi(styles)\n\n // Support gradient colors (array of colors, one per character).\n const isGradient = isArray(color[0])\n\n return plainText\n .split('')\n .map((char, i) => {\n const charColor: readonly [number, number, number] = isGradient\n ? ((color as ShimmerColorGradient)[i % color.length] ?? [\n 140, 82, 255,\n ])\n : (color as readonly [number, number, number])\n const base = `\\x1b[38;2;${charColor[0]};${charColor[1]};${charColor[2]}m`\n return `${styleCode}${base}${char}${ANSI_RESET}`\n })\n .join('')\n }\n\n // Calculate shimmer position.\n const shimmerPos = getShimmerPos(\n plainText.length,\n state.step,\n state.currentDir,\n shimmerWidth,\n )\n\n // Render text with shimmer.\n const result = plainText\n .split('')\n .map((char, i) => renderChar(char, i, shimmerPos, color, styles))\n .join('')\n\n // Advance shimmer position by speed amount each frame.\n // Speed represents steps per frame (e.g., 0.33 = advance 0.33 steps per frame).\n // This creates smooth animation by moving in small increments every frame\n // instead of jumping larger distances every N frames.\n state.step += state.speed\n\n // Handle bidirectional direction changes.\n const totalSteps = plainText.length + shimmerWidth + 2\n if (state.mode === MODE_BI) {\n if (state.step >= totalSteps) {\n state.step = 0\n // Toggle direction every cycle.\n state.currentDir = state.currentDir === DIR_LTR ? DIR_RTL : DIR_LTR\n }\n } else if (state.mode === DIR_RANDOM) {\n // Change direction randomly at end of each cycle.\n if (state.step >= totalSteps) {\n state.step = 0\n state.currentDir = pickDirection(DIR_RANDOM)\n }\n } else {\n // Reset for continuous loops.\n if (state.step >= totalSteps) {\n state.step = 0\n }\n }\n\n return result\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,kBAAsC;AACtC,oBAAwB;AACxB,gBAAsB;
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Text shimmer animation utilities.\n * Provides animated highlight effects for spinner text with configurable directions:\n * - LTR (left-to-right): Shimmer wave moves from left to right\n * - RTL (right-to-left): Shimmer wave moves from right to left\n * - Bidirectional: Alternates between LTR and RTL each cycle\n * - Random: Picks a random direction each cycle\n * - None: No shimmer animation\n *\n * The shimmer effect creates a bright wave that travels across the text,\n * with characters near the wave appearing nearly white and fading to the\n * base color as they get further from the wave position.\n */\n\nimport { ANSI_RESET, stripAnsi } from '../ansi'\nimport { isArray } from '../arrays'\nimport { getCI } from '#env/ci'\nimport { resolveColor } from '../themes/utils'\nimport { THEMES } from '../themes/themes'\nimport type { ColorValue } from '../spinner'\n\nimport type {\n ShimmerColorGradient,\n ShimmerColorRgb,\n ShimmerDirection,\n ShimmerState,\n} from './types'\n\n// Re-export types for backward compatibility.\nexport type {\n ShimmerColor,\n ShimmerColorGradient,\n ShimmerColorInherit,\n ShimmerColorRgb,\n ShimmerConfig,\n ShimmerDirection,\n ShimmerState,\n} from './types'\n\n/**\n * Detected text formatting styles from ANSI codes.\n */\ntype TextStyles = {\n bold: boolean\n dim: boolean\n italic: boolean\n strikethrough: boolean\n underline: boolean\n}\n\n/**\n * Detect all text formatting styles present in ANSI-coded text.\n * Checks for bold, dim, italic, underline, and strikethrough.\n */\nfunction detectStyles(text: string): TextStyles {\n return {\n __proto__: null,\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n bold: /\\x1b\\[1m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n dim: /\\x1b\\[2m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n italic: /\\x1b\\[3m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n strikethrough: /\\x1b\\[9m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n underline: /\\x1b\\[4m/.test(text),\n } as TextStyles\n}\n\n/**\n * Build ANSI code string from text styles.\n * Returns the concatenated ANSI codes needed to apply the styles.\n */\nfunction stylesToAnsi(styles: TextStyles): string {\n let codes = ''\n if (styles.bold) {\n codes += '\\x1b[1m'\n }\n if (styles.dim) {\n codes += '\\x1b[2m'\n }\n if (styles.italic) {\n codes += '\\x1b[3m'\n }\n if (styles.underline) {\n codes += '\\x1b[4m'\n }\n if (styles.strikethrough) {\n codes += '\\x1b[9m'\n }\n return codes\n}\n\n// Internal options for applyShimmer function.\ntype ShimmerOptions = {\n readonly color?: ShimmerColorRgb | ShimmerColorGradient | undefined\n readonly direction?: ShimmerDirection | undefined\n readonly shimmerWidth?: number | undefined\n readonly styles?: TextStyles | undefined\n readonly theme?:\n | import('../themes/types').Theme\n | import('../themes/themes').ThemeName\n | undefined\n}\n\nexport const COLOR_INHERIT = 'inherit'\n\nexport const DIR_LTR = 'ltr'\n\nexport const DIR_NONE = 'none'\n\nexport const DIR_RANDOM = 'random'\n\nexport const DIR_RTL = 'rtl'\n\nexport const MODE_BI = 'bi'\n\n/**\n * Calculate shimmer intensity based on distance from shimmer wave position.\n * Uses a power curve for smooth falloff - characters close to the wave\n * get high intensity (bright white), while distant characters get 0.\n */\nfunction shimmerIntensity(\n distance: number,\n shimmerWidth: number = 2.5,\n): number {\n // Characters beyond shimmer width get no effect.\n if (distance > shimmerWidth) {\n return 0\n }\n // Smooth falloff using power curve.\n const normalized = distance / shimmerWidth\n return (1 - normalized) ** 2.5\n}\n\n/**\n * Blend two RGB colors based on a blend factor (0-1).\n * factor 0 = color1, factor 1 = color2, factor 0.5 = 50/50 blend.\n */\nfunction blendColors(\n color1: readonly [number, number, number],\n color2: readonly [number, number, number],\n factor: number,\n): readonly [number, number, number] {\n const r = Math.round(color1[0] + (color2[0] - color1[0]) * factor)\n const g = Math.round(color1[1] + (color2[1] - color1[1]) * factor)\n const b = Math.round(color1[2] + (color2[2] - color1[2]) * factor)\n return [r, g, b] as const\n}\n\n/**\n * Render character with shimmer effect based on distance from shimmer position.\n * Characters closer to the shimmer position get brighter (nearly white),\n * while characters further away use the base color.\n * Creates a smooth gradient by blending base color with white based on intensity.\n * Supports both single color and per-character color gradients.\n */\nfunction renderChar(\n char: string,\n index: number,\n shimmerPos: number,\n baseColor: readonly [number, number, number] | ShimmerColorGradient,\n styles: TextStyles,\n): string {\n // Calculate how far this character is from the shimmer wave.\n const distance = Math.abs(index - shimmerPos)\n const intensity = shimmerIntensity(distance)\n\n const styleCode = stylesToAnsi(styles)\n\n // Get base color for this character (single or per-character from gradient).\n const charColor: readonly [number, number, number] = isArray(baseColor[0])\n ? ((baseColor as ShimmerColorGradient)[index % baseColor.length] ?? [\n 140, 82, 255,\n ])\n : (baseColor as readonly [number, number, number])\n\n // If no shimmer intensity, use base color as-is.\n if (intensity === 0) {\n const base = `\\x1b[38;2;${charColor[0]};${charColor[1]};${charColor[2]}m`\n return `${styleCode}${base}${char}${ANSI_RESET}`\n }\n\n // Blend base color with white based on intensity to create smooth gradient.\n // Higher intensity = more white, creating the shimmer wave effect.\n const white: readonly [number, number, number] = [255, 255, 255] as const\n const blended = blendColors(charColor, white, intensity)\n\n const color = `\\x1b[38;2;${blended[0]};${blended[1]};${blended[2]}m`\n return `${styleCode}${color}${char}${ANSI_RESET}`\n}\n\n/**\n * Calculate shimmer wave position for current animation step.\n * The shimmer wave moves across the text length, with extra space\n * for the wave to fade in/out at the edges.\n */\nfunction getShimmerPos(\n textLength: number,\n step: number,\n currentDir: 'ltr' | 'rtl',\n shimmerWidth: number = 2.5,\n): number {\n // Total steps for one complete cycle (text length + fade in/out space).\n const totalSteps = textLength + shimmerWidth + 2\n\n // RTL: Shimmer moves from right to left.\n if (currentDir === DIR_RTL) {\n return textLength - (step % totalSteps)\n }\n\n // LTR: Shimmer moves from left to right.\n return step % totalSteps\n}\n\n/**\n * Resolve shimmer direction to a concrete 'ltr' or 'rtl' value.\n * Used for initializing shimmer state and picking random directions.\n */\nfunction pickDirection(direction: ShimmerDirection): 'ltr' | 'rtl' {\n // Random mode: 50/50 chance of LTR or RTL.\n if (direction === DIR_RANDOM) {\n return Math.random() < 0.5 ? DIR_LTR : DIR_RTL\n }\n // RTL mode: Use RTL direction.\n if (direction === DIR_RTL) {\n return DIR_RTL\n }\n // LTR mode (or any other): Default to LTR.\n return DIR_LTR\n}\n\n/**\n * Apply shimmer animation effect to text.\n * This is the main entry point for shimmer animations. It:\n * 1. Strips ANSI codes to get plain text for character positioning\n * 2. Detects any styling (bold, italic, underline, etc.) to preserve\n * 3. Calculates the current shimmer wave position based on animation step\n * 4. Renders each character with appropriate brightness based on distance from wave\n * 5. Updates the animation state for the next frame\n * 6. Handles direction changes for bidirectional and random modes\n */\nexport function applyShimmer(\n text: string,\n state: ShimmerState,\n options?: ShimmerOptions | undefined,\n): string {\n const opts = { __proto__: null, ...options } as ShimmerOptions\n const direction = opts.direction ?? DIR_NONE\n const shimmerWidth = opts.shimmerWidth ?? 2.5\n\n // Resolve color from theme or use provided color or default Socket purple.\n let color: ShimmerColorRgb | ShimmerColorGradient\n if (opts.theme) {\n // Resolve theme to Theme object\n const theme =\n typeof opts.theme === 'string' ? THEMES[opts.theme] : opts.theme\n // Use theme's primary color\n const themeColor = resolveColor(\n theme.colors.primary,\n theme.colors,\n ) as ColorValue\n // Convert ColorValue to ShimmerColorRgb\n // Fallback to Socket purple if color is a string\n color =\n typeof themeColor === 'string' ? ([140, 82, 255] as const) : themeColor\n } else {\n color = opts.color ?? ([140, 82, 255] as const)\n }\n\n // Detect text formatting styles from original text.\n const styles = opts.styles ?? detectStyles(text)\n\n // Strip ANSI codes to get plain text.\n const plainText = stripAnsi(text)\n\n // No shimmer effect in CI or when direction is 'none'.\n if (getCI() || !plainText || direction === DIR_NONE) {\n const styleCode = stylesToAnsi(styles)\n\n // Support gradient colors (array of colors, one per character).\n const isGradient = isArray(color[0])\n\n return plainText\n .split('')\n .map((char, i) => {\n const charColor: readonly [number, number, number] = isGradient\n ? ((color as ShimmerColorGradient)[i % color.length] ?? [\n 140, 82, 255,\n ])\n : (color as readonly [number, number, number])\n const base = `\\x1b[38;2;${charColor[0]};${charColor[1]};${charColor[2]}m`\n return `${styleCode}${base}${char}${ANSI_RESET}`\n })\n .join('')\n }\n\n // Calculate shimmer position.\n const shimmerPos = getShimmerPos(\n plainText.length,\n state.step,\n state.currentDir,\n shimmerWidth,\n )\n\n // Render text with shimmer.\n const result = plainText\n .split('')\n .map((char, i) => renderChar(char, i, shimmerPos, color, styles))\n .join('')\n\n // Advance shimmer position by speed amount each frame.\n // Speed represents steps per frame (e.g., 0.33 = advance 0.33 steps per frame).\n // This creates smooth animation by moving in small increments every frame\n // instead of jumping larger distances every N frames.\n state.step += state.speed\n\n // Handle bidirectional direction changes.\n const totalSteps = plainText.length + shimmerWidth + 2\n if (state.mode === MODE_BI) {\n if (state.step >= totalSteps) {\n state.step = 0\n // Toggle direction every cycle.\n state.currentDir = state.currentDir === DIR_LTR ? DIR_RTL : DIR_LTR\n }\n } else if (state.mode === DIR_RANDOM) {\n // Change direction randomly at end of each cycle.\n if (state.step >= totalSteps) {\n state.step = 0\n state.currentDir = pickDirection(DIR_RANDOM)\n }\n } else {\n // Reset for continuous loops.\n if (state.step >= totalSteps) {\n state.step = 0\n }\n }\n\n return result\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,kBAAsC;AACtC,oBAAwB;AACxB,gBAAsB;AACtB,mBAA6B;AAC7B,oBAAuB;AAoCvB,SAAS,aAAa,MAA0B;AAC9C,SAAO;AAAA,IACL,WAAW;AAAA;AAAA,IAEX,MAAM,WAAW,KAAK,IAAI;AAAA;AAAA,IAE1B,KAAK,WAAW,KAAK,IAAI;AAAA;AAAA,IAEzB,QAAQ,WAAW,KAAK,IAAI;AAAA;AAAA,IAE5B,eAAe,WAAW,KAAK,IAAI;AAAA;AAAA,IAEnC,WAAW,WAAW,KAAK,IAAI;AAAA,EACjC;AACF;AAMA,SAAS,aAAa,QAA4B;AAChD,MAAI,QAAQ;AACZ,MAAI,OAAO,MAAM;AACf,aAAS;AAAA,EACX;AACA,MAAI,OAAO,KAAK;AACd,aAAS;AAAA,EACX;AACA,MAAI,OAAO,QAAQ;AACjB,aAAS;AAAA,EACX;AACA,MAAI,OAAO,WAAW;AACpB,aAAS;AAAA,EACX;AACA,MAAI,OAAO,eAAe;AACxB,aAAS;AAAA,EACX;AACA,SAAO;AACT;AAcO,MAAM,gBAAgB;AAEtB,MAAM,UAAU;AAEhB,MAAM,WAAW;AAEjB,MAAM,aAAa;AAEnB,MAAM,UAAU;AAEhB,MAAM,UAAU;AAOvB,SAAS,iBACP,UACA,eAAuB,KACf;AAER,MAAI,WAAW,cAAc;A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AAU;AAAA,IAChD,CAAC,EACA,KAAK,EAAE;AAAA,EACZ;AAGA,QAAM,aAAa;AAAA,IACjB,UAAU;AAAA,IACV,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACF;AAGA,QAAM,SAAS,UACZ,MAAM,EAAE,EACR,IAAI,CAAC,MAAM,MAAM,WAAW,MAAM,GAAG,YAAY,OAAO,MAAM,CAAC,EAC/D,KAAK,EAAE;AAMV,QAAM,QAAQ,MAAM;AAGpB,QAAM,aAAa,UAAU,SAAS,eAAe;AACrD,MAAI,MAAM,SAAS,SAAS;AAC1B,QAAI,MAAM,QAAQ,YAAY;AAC5B,YAAM,OAAO;AAEb,YAAM,aAAa,MAAM,eAAe,UAAU,UAAU;AAAA,IAC9D;AAAA,EACF,WAAW,MAAM,SAAS,YAAY;AAEpC,QAAI,MAAM,QAAQ,YAAY;AAC5B,YAAM,OAAO;AACb,YAAM,aAAa,cAAc,UAAU;AAAA,IAC7C;AAAA,EACF,OAAO;AAEL,QAAI,MAAM,QAAQ,YAAY;AAC5B,YAAM,OAAO;AAAA,IACf;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/effects/types.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export type ShimmerConfig = {
|
|
|
20
20
|
* Default: 1/3 (~0.33).
|
|
21
21
|
*/
|
|
22
22
|
readonly speed?: number | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Theme to use for shimmer colors.
|
|
25
|
+
* Can be a theme name ('socket', 'sunset', etc.) or a Theme object.
|
|
26
|
+
* If provided, overrides the color option.
|
|
27
|
+
*/
|
|
28
|
+
readonly theme?: import('../themes/types').Theme | import('../themes/themes').ThemeName | undefined;
|
|
23
29
|
};
|
|
24
30
|
/**
|
|
25
31
|
* Internal shimmer animation state.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/effects/types.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Shared types for effects (shimmer, pulse, ultra, etc.).\n * Common type definitions used across multiple effect modules.\n */\n\nexport type ShimmerColorInherit = 'inherit'\n\nexport type ShimmerColorRgb = readonly [number, number, number]\n\nexport type ShimmerColor = ShimmerColorInherit | ShimmerColorRgb\n\nexport type ShimmerColorGradient = readonly ShimmerColorRgb[]\n\nexport type ShimmerDirection = 'ltr' | 'rtl' | 'bi' | 'random' | 'none'\n\n/**\n * Shimmer animation configuration.\n */\nexport type ShimmerConfig = {\n readonly color?: ShimmerColor | ShimmerColorGradient | undefined\n readonly dir?: ShimmerDirection | undefined\n /**\n * Animation speed in steps per frame.\n * Lower values = slower shimmer (e.g., 0.33 = ~150ms per step).\n * Higher values = faster shimmer (e.g., 1.0 = 50ms per step).\n * Default: 1/3 (~0.33).\n */\n readonly speed?: number | undefined\n}\n\n/**\n * Internal shimmer animation state.\n * Tracks current animation position and direction.\n */\nexport type ShimmerState = {\n currentDir: 'ltr' | 'rtl'\n mode: ShimmerDirection\n /**\n * Animation speed in steps per frame.\n * The shimmer position advances by this amount every frame.\n */\n speed: number\n /**\n * Current shimmer position.\n * Can be fractional for smooth sub-character movement.\n */\n step: number\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Shared types for effects (shimmer, pulse, ultra, etc.).\n * Common type definitions used across multiple effect modules.\n */\n\nexport type ShimmerColorInherit = 'inherit'\n\nexport type ShimmerColorRgb = readonly [number, number, number]\n\nexport type ShimmerColor = ShimmerColorInherit | ShimmerColorRgb\n\nexport type ShimmerColorGradient = readonly ShimmerColorRgb[]\n\nexport type ShimmerDirection = 'ltr' | 'rtl' | 'bi' | 'random' | 'none'\n\n/**\n * Shimmer animation configuration.\n */\nexport type ShimmerConfig = {\n readonly color?: ShimmerColor | ShimmerColorGradient | undefined\n readonly dir?: ShimmerDirection | undefined\n /**\n * Animation speed in steps per frame.\n * Lower values = slower shimmer (e.g., 0.33 = ~150ms per step).\n * Higher values = faster shimmer (e.g., 1.0 = 50ms per step).\n * Default: 1/3 (~0.33).\n */\n readonly speed?: number | undefined\n /**\n * Theme to use for shimmer colors.\n * Can be a theme name ('socket', 'sunset', etc.) or a Theme object.\n * If provided, overrides the color option.\n */\n readonly theme?:\n | import('../themes/types').Theme\n | import('../themes/themes').ThemeName\n | undefined\n}\n\n/**\n * Internal shimmer animation state.\n * Tracks current animation position and direction.\n */\nexport type ShimmerState = {\n currentDir: 'ltr' | 'rtl'\n mode: ShimmerDirection\n /**\n * Animation speed in steps per frame.\n * The shimmer position advances by this amount every frame.\n */\n speed: number\n /**\n * Current shimmer position.\n * Can be fractional for smooth sub-character movement.\n */\n step: number\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|