@reliverse/relico 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ {
2
+ "recommendations": [
3
+ "fabiospampinato.vscode-open-multiple-files",
4
+ "davidanson.vscode-markdownlint",
5
+ "usernamehw.errorlens",
6
+ "yoavbls.pretty-ts-errors"
7
+ ]
8
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "editor.codeActionsOnSave": {
4
+ "source.addMissingImports.ts": "never",
5
+ "source.biome": "explicit",
6
+ "source.fixAll.biome": "explicit",
7
+ "source.fixAll.ts": "never",
8
+ "source.organizeImports.biome": "explicit",
9
+ "source.organizeImports": "never",
10
+ "source.removeUnused.ts": "never",
11
+ "source.removeUnusedImports": "never",
12
+ "source.sortImports": "never"
13
+ },
14
+ "editor.defaultFormatter": "biomejs.biome",
15
+ "[typescript]": {
16
+ "editor.defaultFormatter": "biomejs.biome"
17
+ },
18
+ "[json]": {
19
+ "editor.defaultFormatter": "biomejs.biome"
20
+ },
21
+ "[javascript]": {
22
+ "editor.defaultFormatter": "biomejs.biome"
23
+ },
24
+ "[jsonc]": {
25
+ "editor.defaultFormatter": "biomejs.biome"
26
+ },
27
+ "[typescriptreact]": {
28
+ "editor.defaultFormatter": "biomejs.biome"
29
+ },
30
+ "[markdown]": {
31
+ "editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
32
+ },
33
+ "markdownlint.config": {
34
+ "MD033": false,
35
+ "MD024": false
36
+ },
37
+ "json.schemaDownload.enable": true,
38
+ "css.lint.unknownAtRules": "ignore",
39
+ "emmet.showExpandedAbbreviation": "never",
40
+ "typescript.preferences.importModuleSpecifier": "shortest",
41
+ "typescript.updateImportsOnFileMove.enabled": "never",
42
+ "javascript.updateImportsOnFileMove.enabled": "never",
43
+ "typescript.updateImportsOnPaste.enabled": false,
44
+ "javascript.updateImportsOnPaste.enabled": false
45
+ }
package/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Reliverse Relico
2
2
 
3
- > @reliverse/relico is a themeable, chainable, typed, truecolor-powered terminal styling toolkit — built for humans, not just terminals. It makes your CLI output beautiful, accessible, and expressive — with developer-first ergonomics, smart config, and blazing-fast performance.
3
+ > @reliverse/dler-colors is a themeable, chainable, typed, truecolor-powered terminal styling toolkit — built for humans, not just terminals. It makes your CLI output beautiful, accessible, and expressive — with developer-first ergonomics, smart config, and blazing-fast performance.
4
4
 
5
- [sponsor](https://github.com/sponsors/blefnk) — [discord](https://discord.gg/Pb8uKbwpsJ) — [repo](https://github.com/reliverse/relico) — [npm](https://npmjs.com/@reliverse/relico)
5
+ [sponsor](https://github.com/sponsors/blefnk) — [discord](https://discord.gg/Pb8uKbwpsJ) — [repo](https://github.com/reliverse/relico) — [npm](https://npmjs.com/@reliverse/dler-colors)
6
+
7
+ ---
8
+
9
+ ‼️Attention! The latest implementation of `@reliverse/relico` now lives in the framework repository for building libraries — `@reliverse/dler`. Please use [@reliverse/dler-colors](https://github.com/reliverse/dler/tree/main/packages/colors) instead of `@reliverse/relico`.
6
10
 
7
11
  ## Why Relico?
8
12
 
@@ -24,7 +28,7 @@ Because terminal styling shouldn't feel like duct tape. **Relico** brings design
24
28
  ## Installation
25
29
 
26
30
  ```bash
27
- bun add @reliverse/relico
31
+ bun add @reliverse/dler-colors
28
32
  # bun • pnpm • yarn • npm
29
33
  ```
30
34
 
@@ -91,7 +95,7 @@ The readme will be updated soon.
91
95
  **If you're end-user OR developer, create `relico.config.ts` in your root**:
92
96
 
93
97
  ```ts
94
- import { defineConfig } from "@reliverse/relico";
98
+ import { defineConfig } from "@reliverse/dler-colors";
95
99
 
96
100
  export default defineConfig({
97
101
  colorLevel: 3, // 0 = off, 1 = basic, 2 = 256, 3 = truecolor
@@ -108,7 +112,7 @@ export default defineConfig({
108
112
  **If you're developer, initialize in your app (optional)**:
109
113
 
110
114
  ```ts
111
- import { initUserConfig, re } from "@reliverse/relico";
115
+ import { initUserConfig, re } from "@reliverse/dler-colors";
112
116
 
113
117
  // Use this to override Relico's
114
118
  // default settings for your app
@@ -120,7 +124,7 @@ console.log(re.info("Custom config loaded!"));
120
124
  ## API Sneak Peek
121
125
 
122
126
  ```ts
123
- import { re, rgb } from "@reliverse/relico";
127
+ import { re, rgb } from "@reliverse/dler-colors";
124
128
 
125
129
  console.log(re.red("Red!"));
126
130
  console.log(re.bold(re.green("Bold green")));
@@ -171,7 +175,7 @@ console.log(boldRed("This text is bold and red"));
171
175
  ### Want to Get Only Certain Colors?
172
176
 
173
177
  ```ts
174
- import type { DefaultColorKeys } from "@reliverse/relico";
178
+ import type { DefaultColorKeys } from "@reliverse/dler-colors";
175
179
  const brandColors: DefaultColorKeys[] = ["magentaBright", "maroon"];
176
180
  ```
177
181
 
@@ -180,7 +184,7 @@ const brandColors: DefaultColorKeys[] = ["magentaBright", "maroon"];
180
184
  Relico detects your terminal's capability:
181
185
 
182
186
  ```ts
183
- import { colorSupport } from "@reliverse/relico";
187
+ import { colorSupport } from "@reliverse/dler-colors";
184
188
 
185
189
  console.log(colorSupport.terminalName); // iTerm2, Windows Terminal, etc.
186
190
  console.log(colorSupport.level); // 0, 1, 2, or 3
@@ -196,7 +200,7 @@ console.log(colorSupport.level); // 0, 1, 2, or 3
196
200
  ### Custom RGB + Hex
197
201
 
198
202
  ```ts
199
- import { rgb, bgHex, hex } from "@reliverse/relico";
203
+ import { rgb, bgHex, hex } from "@reliverse/dler-colors";
200
204
 
201
205
  console.log(rgb(255, 105, 180)("Hot pink"));
202
206
  console.log(bgHex("#1e90ff")("Dodger blue background"));
@@ -205,7 +209,7 @@ console.log(bgHex("#1e90ff")("Dodger blue background"));
205
209
  ### Gradients & Rainbow
206
210
 
207
211
  ```ts
208
- import { gradient, multiGradient, rainbow } from "@reliverse/relico";
212
+ import { gradient, multiGradient, rainbow } from "@reliverse/dler-colors";
209
213
 
210
214
  console.log(rainbow("🎉 Woohoo!"));
211
215
  console.log(gradient("From red to blue", "#ff0000", "#0000ff"));
@@ -218,7 +222,7 @@ This function allows you to combine multiple color formatters into a single form
218
222
  ## Basic Usage
219
223
 
220
224
  ```typescript
221
- import { re, chain } from "@reliverse/relico";
225
+ import { re, chain } from "@reliverse/dler-colors";
222
226
 
223
227
  // Create a custom style that combines bold and red text
224
228
  const boldRed = chain(re.bold, re.red);
@@ -236,7 +240,7 @@ console.log(importantError("CRITICAL ERROR: System failure"));
236
240
  ## Creating Theme Combinations
237
241
 
238
242
  ```typescript
239
- import { re, chain } from "@reliverse/relico";
243
+ import { re, chain } from "@reliverse/dler-colors";
240
244
 
241
245
  // Create themed message styles
242
246
  const successStyle = chain(re.bold, re.green);
@@ -254,7 +258,7 @@ console.log(warnStyle("⚠ API rate limit approaching"));
254
258
  ## Custom RGB Combinations
255
259
 
256
260
  ```typescript
257
- import { re, rgb, bgRgb, chain } from "@reliverse/relico";
261
+ import { re, rgb, bgRgb, chain } from "@reliverse/dler-colors";
258
262
 
259
263
  // Create a custom color scheme with RGB values
260
264
  const customHeader = chain(
@@ -278,7 +282,7 @@ console.log(danger("Danger: High voltage detected!"));
278
282
  The `chain()` function automatically handles multiline text to prevent style leakage:
279
283
 
280
284
  ```typescript
281
- import { re, chain } from "@reliverse/relico";
285
+ import { re, chain } from "@reliverse/dler-colors";
282
286
 
283
287
  const highlight = chain(re.bgYellow, re.black, re.bold);
284
288
 
@@ -293,7 +297,7 @@ console.log(highlight(multilineText));
293
297
  ## Creating a Simple Logger
294
298
 
295
299
  ```typescript
296
- import { re, chain } from "@reliverse/relico";
300
+ import { re, chain } from "@reliverse/dler-colors";
297
301
 
298
302
  // Create logger styles
299
303
  const styles = {
package/biome.json ADDED
@@ -0,0 +1,86 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
3
+ "extends": ["ultracite"],
4
+ "vcs": {
5
+ "enabled": false,
6
+ "clientKind": "git",
7
+ "useIgnoreFile": false
8
+ },
9
+ "files": {
10
+ "ignoreUnknown": false,
11
+ "maxSize": 1700000,
12
+ "includes": [
13
+ "**",
14
+ "!**/.js",
15
+ "!**/.d.ts",
16
+ "!**/_generated",
17
+ "!**/.basehub",
18
+ "!**/.expo",
19
+ "!**/.next",
20
+ "!**/.nuxt",
21
+ "!**/.react-email",
22
+ "!**/.source",
23
+ "!**/.turbo",
24
+ "!**/.vercel",
25
+ "!**/.wrangler",
26
+ "!**/.zed",
27
+ "!**/dev-dist",
28
+ "!**/dist-npm",
29
+ "!**/dist",
30
+ "!**/drizzle/migrations",
31
+ "!**/node_modules",
32
+ "!**/routeTree.gen.ts",
33
+ "!**/src-tauri"
34
+ ]
35
+ },
36
+ "formatter": {
37
+ "enabled": true,
38
+ "indentStyle": "space",
39
+ "lineWidth": 100
40
+ },
41
+ "linter": {
42
+ "enabled": true,
43
+ "rules": {
44
+ "recommended": true,
45
+ "suspicious": {
46
+ "noConsole": "off",
47
+ "noVar": "off",
48
+ "noExplicitAny": "off"
49
+ },
50
+ "style": {
51
+ "useNodejsImportProtocol": "off",
52
+ "noMagicNumbers": "off",
53
+ "useBlockStatements": "off"
54
+ },
55
+ "complexity": { "noExcessiveLinesPerFunction": "off" },
56
+ "nursery": {
57
+ "useConsistentTypeDefinitions": {
58
+ "level": "off",
59
+ "options": { "style": "interface" }
60
+ }
61
+ }
62
+ }
63
+ },
64
+ "javascript": {
65
+ "globals": ["Bun"],
66
+ "formatter": {
67
+ "jsxQuoteStyle": "double",
68
+ "quoteProperties": "asNeeded",
69
+ "trailingCommas": "all",
70
+ "semicolons": "always",
71
+ "arrowParentheses": "always",
72
+ "bracketSpacing": true,
73
+ "bracketSameLine": false,
74
+ "quoteStyle": "double",
75
+ "attributePosition": "auto"
76
+ }
77
+ },
78
+ "assist": {
79
+ "enabled": true,
80
+ "actions": {
81
+ "source": {
82
+ "organizeImports": "on"
83
+ }
84
+ }
85
+ }
86
+ }
@@ -0,0 +1,143 @@
1
+ // Bundle size analysis for relico
2
+ import { readFileSync, statSync } from "fs";
3
+ import { dirname, resolve } from "path";
4
+ import { fileURLToPath } from "url";
5
+ import { config, getEnabledDirs, getFilePaths, getImportPath } from "./config";
6
+
7
+ // Get the directory where this benchmark file is located
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+
11
+ // Constants for size formatting
12
+ const BYTES_PER_KB = 1024;
13
+ const BYTES_PER_MB = 1024 * 1024;
14
+ const NEWLINE_LENGTH = 1;
15
+ const PERCENT_MULTIPLIER = 100;
16
+ const DECIMAL_PLACES = 1;
17
+ const SEPARATOR_LENGTH = 60;
18
+
19
+ function getFileSize(path: string): number {
20
+ try {
21
+ const stats = statSync(path);
22
+ return stats.size;
23
+ } catch {
24
+ return 0;
25
+ }
26
+ }
27
+
28
+ function formatSize(bytes: number): string {
29
+ if (bytes < BYTES_PER_KB) {
30
+ return `${bytes}B`;
31
+ }
32
+ if (bytes < BYTES_PER_MB) {
33
+ return `${(bytes / BYTES_PER_KB).toFixed(DECIMAL_PLACES)}KB`;
34
+ }
35
+ return `${(bytes / BYTES_PER_MB).toFixed(DECIMAL_PLACES)}MB`;
36
+ }
37
+
38
+ function analyzeFile(filePath: string): { types: number; constants: number; logic: number } {
39
+ try {
40
+ const sourceCode = readFileSync(filePath, "utf8");
41
+ const lines = sourceCode.split("\n");
42
+
43
+ let typeDefinitions = 0;
44
+ let constants = 0;
45
+ let logic = 0;
46
+
47
+ for (const line of lines) {
48
+ const trimmed = line.trim();
49
+
50
+ // Type definitions
51
+ if (trimmed.includes("type ") || trimmed.includes("interface ")) {
52
+ typeDefinitions += line.length + NEWLINE_LENGTH;
53
+ continue;
54
+ }
55
+
56
+ // Constants and color data
57
+ if (
58
+ trimmed.includes("const ") ||
59
+ trimmed.includes("COLOR_LEVEL") ||
60
+ trimmed.includes("SGR_")
61
+ ) {
62
+ constants += line.length + NEWLINE_LENGTH;
63
+ continue;
64
+ }
65
+
66
+ // Everything else is logic
67
+ if (trimmed.length > 0) {
68
+ logic += line.length + NEWLINE_LENGTH;
69
+ }
70
+ }
71
+
72
+ return { types: typeDefinitions, constants, logic };
73
+ } catch (error) {
74
+ console.warn(`⚠️ Could not analyze ${filePath}:`, error);
75
+ return { types: 0, constants: 0, logic: 0 };
76
+ }
77
+ }
78
+
79
+ function analyzeSingleDirectory(dir: "src" | "distNpmBin"): void {
80
+ const importPath = getImportPath(dir);
81
+ const filePaths = getFilePaths(dir);
82
+
83
+ console.log(`\n🔍 Analyzing ${dir.toUpperCase()} directory: ${importPath}`);
84
+ console.log("=".repeat(SEPARATOR_LENGTH));
85
+
86
+ // Analyze JavaScript/TypeScript file
87
+ if (filePaths.js) {
88
+ const jsFilePath = resolve(__dirname, filePaths.js);
89
+ console.log(`📄 JavaScript/TypeScript file: ${filePaths.js}`);
90
+ console.log(`Resolved path: ${jsFilePath}`);
91
+
92
+ const jsFileSize = getFileSize(jsFilePath);
93
+ if (jsFileSize === 0) {
94
+ console.log(`❌ File not found or empty: ${jsFilePath}`);
95
+ } else {
96
+ console.log(`File size: ${formatSize(jsFileSize)}`);
97
+
98
+ const jsAnalysis = analyzeFile(jsFilePath);
99
+
100
+ console.log("\nBreakdown:");
101
+ console.log(
102
+ `- Types: ${formatSize(jsAnalysis.types)} (${((jsAnalysis.types / jsFileSize) * PERCENT_MULTIPLIER).toFixed(DECIMAL_PLACES)}%)`,
103
+ );
104
+ console.log(
105
+ `- Constants: ${formatSize(jsAnalysis.constants)} (${((jsAnalysis.constants / jsFileSize) * PERCENT_MULTIPLIER).toFixed(DECIMAL_PLACES)}%)`,
106
+ );
107
+ console.log(
108
+ `- Logic: ${formatSize(jsAnalysis.logic)} (${((jsAnalysis.logic / jsFileSize) * PERCENT_MULTIPLIER).toFixed(DECIMAL_PLACES)}%)`,
109
+ );
110
+
111
+ if (config.bundleAnalysis.analyzeDependencies) {
112
+ console.log("\n📊 Additional Info:");
113
+ try {
114
+ const sourceCode = readFileSync(jsFilePath, "utf8");
115
+ const lines = sourceCode.split("\n");
116
+ console.log(`- Total lines: ${lines.length}`);
117
+ console.log("- File type: TypeScript");
118
+ } catch (error) {
119
+ console.log(`- Could not read file for line count: ${error}`);
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+
126
+ function analyzeAllDirectories(): void {
127
+ const enabledDirs = getEnabledDirs();
128
+
129
+ for (const dir of enabledDirs) {
130
+ analyzeSingleDirectory(dir);
131
+ }
132
+ }
133
+
134
+ // Main execution
135
+ console.log("📦 Relico Bundle Size Analysis");
136
+ console.log("=".repeat(50));
137
+
138
+ console.log("Starting analysis...");
139
+ analyzeAllDirectories();
140
+ console.log("\n✅ All analyses completed!");
141
+ console.log("Starting analysis...");
142
+ analyzeAllDirectories();
143
+ console.log("\n✅ All analyses completed!");
@@ -0,0 +1,55 @@
1
+ // Example configuration for relico benchmarks
2
+ // Copy this file to config.ts and modify as needed
3
+
4
+ import type { BenchmarkConfig } from "./config";
5
+
6
+ // Custom configuration example
7
+ export const customConfig: BenchmarkConfig = {
8
+ sourceDirs: {
9
+ src: "../../src", // Source TypeScript files
10
+ distNpmBin: "../../dist-npm/bin", // Binary distribution files
11
+ },
12
+
13
+ // Choose which directories to test
14
+ enabledDirs: ["src", "distNpmBin"], // Only test src and dist-npm/bin
15
+
16
+ performance: {
17
+ iterations: 50_000, // Reduce iterations for faster testing
18
+ warmupRuns: 500, // Reduce warmup runs
19
+ },
20
+
21
+ bundleAnalysis: {
22
+ includeSourceMaps: false, // Skip source map analysis
23
+ analyzeDependencies: true, // Include dependency analysis
24
+ },
25
+ };
26
+
27
+ // Example: Test only source files
28
+ export const sourceOnlyConfig: BenchmarkConfig = {
29
+ ...customConfig,
30
+ enabledDirs: ["src"],
31
+ };
32
+
33
+ // Example: Test only built files
34
+ export const builtOnlyConfig: BenchmarkConfig = {
35
+ ...customConfig,
36
+ enabledDirs: ["distNpmBin"],
37
+ };
38
+
39
+ // Example: High-performance testing
40
+ export const highPerfConfig: BenchmarkConfig = {
41
+ ...customConfig,
42
+ performance: {
43
+ iterations: 1_000_000, // 1M iterations for accurate results
44
+ warmupRuns: 10_000, // 10K warmup runs
45
+ },
46
+ };
47
+
48
+ // Example: Quick testing
49
+ export const quickConfig: BenchmarkConfig = {
50
+ ...customConfig,
51
+ performance: {
52
+ iterations: 10_000, // 10K iterations for quick results
53
+ warmupRuns: 100, // Minimal warmup
54
+ },
55
+ };
@@ -0,0 +1,93 @@
1
+ // Benchmark configuration for relico
2
+ export interface BenchmarkConfig {
3
+ // Source directories to test
4
+ sourceDirs: {
5
+ src?: string;
6
+ distNpmBin: string;
7
+ };
8
+
9
+ // Which directories to include in testing
10
+ enabledDirs: ("src" | "distNpmBin")[];
11
+
12
+ // Performance test settings
13
+ performance: {
14
+ iterations: number;
15
+ warmupRuns: number;
16
+ };
17
+
18
+ // Bundle analysis settings
19
+ bundleAnalysis: {
20
+ includeSourceMaps: boolean;
21
+ analyzeDependencies: boolean;
22
+ };
23
+ }
24
+
25
+ // Default configuration
26
+ export const defaultConfig: BenchmarkConfig = {
27
+ sourceDirs: {
28
+ src: "../../src",
29
+ distNpmBin: "../../dist-npm/bin", // Binary distribution (where .js and .d.ts files are)
30
+ },
31
+
32
+ // Test source directory by default since we don't have a built version
33
+ enabledDirs: ["src"],
34
+
35
+ performance: {
36
+ iterations: 100_000,
37
+ warmupRuns: 1000,
38
+ },
39
+
40
+ bundleAnalysis: {
41
+ includeSourceMaps: false,
42
+ analyzeDependencies: true,
43
+ },
44
+ };
45
+
46
+ // Helper function to get import path for a specific directory
47
+ export function getImportPath(dir: keyof BenchmarkConfig["sourceDirs"], module = "mod"): string {
48
+ const config = defaultConfig;
49
+ const basePath = config.sourceDirs[dir];
50
+
51
+ switch (dir) {
52
+ case "src":
53
+ return `${basePath}/${module}.ts`;
54
+ case "distNpmBin":
55
+ return `${basePath}/${module}.js`;
56
+ default:
57
+ return `${basePath}/${module}.ts`;
58
+ }
59
+ }
60
+
61
+ // Helper function to get file paths for analysis (both .js and .d.ts files)
62
+ export function getFilePaths(
63
+ dir: keyof BenchmarkConfig["sourceDirs"],
64
+ module = "mod",
65
+ ): { js?: string; dts?: string } {
66
+ const config = defaultConfig;
67
+ const basePath = config.sourceDirs[dir];
68
+
69
+ switch (dir) {
70
+ case "src":
71
+ return { js: `${basePath}/${module}.ts` };
72
+ case "distNpmBin":
73
+ return {
74
+ js: `${basePath}/${module}.js`,
75
+ dts: `${basePath}/${module}.d.ts`,
76
+ };
77
+ default:
78
+ return { js: `${basePath}/${module}.ts` };
79
+ }
80
+ }
81
+
82
+ // Helper to check if directory is enabled
83
+ export function isDirEnabled(dir: keyof BenchmarkConfig["sourceDirs"]): boolean {
84
+ return defaultConfig.enabledDirs.includes(dir);
85
+ }
86
+
87
+ // Helper to get all enabled directories
88
+ export function getEnabledDirs(): (keyof BenchmarkConfig["sourceDirs"])[] {
89
+ return defaultConfig.enabledDirs;
90
+ }
91
+
92
+ // Export the config for easy access
93
+ export const config = defaultConfig;