@reliverse/relico 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.config/dler.ts +235 -0
- package/.config/rse.ts +167 -0
- package/.config/types/dler.schema.ts +1066 -0
- package/.cursor/rules/general-rules.mdc +276 -0
- package/.vscode/extensions.json +8 -0
- package/.vscode/settings.json +45 -0
- package/LICENSE +1 -1
- package/README.md +64 -6
- package/biome.json +78 -0
- package/deprecated.zip +0 -0
- package/examples/benchmarks/bundle-size.ts +143 -0
- package/examples/benchmarks/config.example.ts +55 -0
- package/examples/benchmarks/config.ts +93 -0
- package/examples/benchmarks/performance.ts +174 -0
- package/examples/core.ts +62 -0
- package/knip.json +13 -0
- package/package.json +24 -32
- package/reset.d.ts +1 -0
- package/src/mod.ts +492 -0
- package/tsconfig.json +33 -0
- package/bin/mod.d.ts +0 -357
- package/bin/mod.js +0 -1160
- package/bin/utils.d.ts +0 -4
- package/bin/utils.js +0 -10
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
globs: *.ts
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Dependency-Free TypeScript Library: General Rules
|
|
8
|
+
|
|
9
|
+
Always follow ultracite's coding rules. Ultracite enforces strict type safety, accessibility standards, and consistent code quality for JavaScript/TypeScript projects using Biome's lightning-fast formatter and linter.
|
|
10
|
+
|
|
11
|
+
## Key Principles
|
|
12
|
+
|
|
13
|
+
- Zero configuration required
|
|
14
|
+
- Subsecond performance
|
|
15
|
+
- Maximum type safety
|
|
16
|
+
|
|
17
|
+
## Remember
|
|
18
|
+
|
|
19
|
+
1. Consider edge cases and error scenarios
|
|
20
|
+
2. Follow the rules below strictly
|
|
21
|
+
3. As an AI you can't see terminal's colors
|
|
22
|
+
|
|
23
|
+
## Rules
|
|
24
|
+
|
|
25
|
+
### Code Complexity and Quality
|
|
26
|
+
|
|
27
|
+
- Don't use consecutive spaces in regular expression literals.
|
|
28
|
+
- Don't use the `arguments` object.
|
|
29
|
+
- Don't use primitive type aliases or misleading types.
|
|
30
|
+
- Don't use the comma operator.
|
|
31
|
+
- Don't use empty type parameters in type aliases and interfaces.
|
|
32
|
+
- Don't write functions that exceed a given Cognitive Complexity score.
|
|
33
|
+
- Don't nest describe() blocks too deeply in test files.
|
|
34
|
+
- Don't use unnecessary boolean casts.
|
|
35
|
+
- Don't use unnecessary callbacks with flatMap.
|
|
36
|
+
- Use for...of statements instead of Array.forEach.
|
|
37
|
+
- Don't create classes that only have static members (like a static namespace).
|
|
38
|
+
- Don't use this and super in static contexts.
|
|
39
|
+
- Don't use unnecessary catch clauses.
|
|
40
|
+
- Don't use unnecessary constructors.
|
|
41
|
+
- Don't use unnecessary continue statements.
|
|
42
|
+
- Don't export empty modules that don't change anything.
|
|
43
|
+
- Don't use unnecessary escape sequences in regular expression literals.
|
|
44
|
+
- Don't use unnecessary fragments.
|
|
45
|
+
- Don't use unnecessary labels.
|
|
46
|
+
- Don't use unnecessary nested block statements.
|
|
47
|
+
- Don't rename imports, exports, and destructured assignments to the same name.
|
|
48
|
+
- Don't use unnecessary string or template literal concatenation.
|
|
49
|
+
- Don't use String.raw in template literals when there are no escape sequences.
|
|
50
|
+
- Don't use useless case statements in switch statements.
|
|
51
|
+
- Don't use ternary operators when simpler alternatives exist.
|
|
52
|
+
- Don't use useless `this` aliasing.
|
|
53
|
+
- Don't use any or unknown as type constraints.
|
|
54
|
+
- Don't initialize variables to undefined.
|
|
55
|
+
- Don't use the void operators (they're not familiar).
|
|
56
|
+
- Use arrow functions instead of function expressions.
|
|
57
|
+
- Use Date.now() to get milliseconds since the Unix Epoch.
|
|
58
|
+
- Use .flatMap() instead of map().flat() when possible.
|
|
59
|
+
- Use literal property access instead of computed property access.
|
|
60
|
+
- Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
|
|
61
|
+
- Use concise optional chaining instead of chained logical expressions.
|
|
62
|
+
- Use regular expression literals instead of the RegExp constructor when possible.
|
|
63
|
+
- Don't use number literal object member names that aren't base 10 or use underscore separators.
|
|
64
|
+
- Remove redundant terms from logical expressions.
|
|
65
|
+
- Use while loops instead of for loops when you don't need initializer and update expressions.
|
|
66
|
+
- Don't pass children as props.
|
|
67
|
+
- Don't reassign const variables.
|
|
68
|
+
- Don't use constant expressions in conditions.
|
|
69
|
+
- Don't use `Math.min` and `Math.max` to clamp values when the result is constant.
|
|
70
|
+
- Don't return a value from a constructor.
|
|
71
|
+
- Don't use empty character classes in regular expression literals.
|
|
72
|
+
- Don't use empty destructuring patterns.
|
|
73
|
+
- Don't call global object properties as functions.
|
|
74
|
+
- Don't declare functions and vars that are accessible outside their block.
|
|
75
|
+
- Make sure builtins are correctly instantiated.
|
|
76
|
+
- Don't use super() incorrectly inside classes. Also check that super() is called in classes that extend other constructors.
|
|
77
|
+
- Don't use variables and function parameters before they're declared.
|
|
78
|
+
- Don't use 8 and 9 escape sequences in string literals.
|
|
79
|
+
- Don't use literal numbers that lose precision.
|
|
80
|
+
|
|
81
|
+
### Correctness and Safety
|
|
82
|
+
|
|
83
|
+
- Don't assign a value to itself.
|
|
84
|
+
- Don't return a value from a setter.
|
|
85
|
+
- Don't compare expressions that modify string case with non-compliant values.
|
|
86
|
+
- Don't use lexical declarations in switch clauses.
|
|
87
|
+
- Don't use variables that haven't been declared in the document.
|
|
88
|
+
- Don't write unreachable code.
|
|
89
|
+
- Make sure super() is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass.
|
|
90
|
+
- Don't use control flow statements in finally blocks.
|
|
91
|
+
- Don't use optional chaining where undefined values aren't allowed.
|
|
92
|
+
- Don't have unused function parameters.
|
|
93
|
+
- Don't have unused imports.
|
|
94
|
+
- Don't have unused labels.
|
|
95
|
+
- Don't have unused private class members.
|
|
96
|
+
- Don't have unused variables.
|
|
97
|
+
- Make sure void (self-closing) elements don't have children.
|
|
98
|
+
- Don't return a value from a function with the return type 'void'
|
|
99
|
+
- Use isNaN() when checking for NaN.
|
|
100
|
+
- Make sure "for" loop update clauses move the counter in the right direction.
|
|
101
|
+
- Make sure typeof expressions are compared to valid values.
|
|
102
|
+
- Make sure generator functions contain yield.
|
|
103
|
+
- Don't use await inside loops.
|
|
104
|
+
- Don't use bitwise operators.
|
|
105
|
+
- Don't use expressions where the operation doesn't change the value.
|
|
106
|
+
- Make sure Promise-like statements are handled appropriately.
|
|
107
|
+
- Don't use __dirname and__filename in the global scope.
|
|
108
|
+
- Prevent import cycles.
|
|
109
|
+
- Don't use configured elements.
|
|
110
|
+
- Don't hardcode sensitive data like API keys and tokens.
|
|
111
|
+
- Don't let variable declarations shadow variables from outer scopes.
|
|
112
|
+
- Don't use the TypeScript directive @ts-ignore.
|
|
113
|
+
- Prevent duplicate polyfills from Polyfill.io.
|
|
114
|
+
- Don't use useless backreferences in regular expressions that always match empty strings.
|
|
115
|
+
- Don't use unnecessary escapes in string literals.
|
|
116
|
+
- Don't use useless undefined.
|
|
117
|
+
- Make sure getters and setters for the same property are next to each other in class and object definitions.
|
|
118
|
+
- Make sure object literals are declared consistently (defaults to explicit definitions).
|
|
119
|
+
- Use static Response methods instead of new Response() constructor when possible.
|
|
120
|
+
- Make sure switch-case statements are exhaustive.
|
|
121
|
+
- Make sure the `preconnect` attribute is used when using Google Fonts.
|
|
122
|
+
- Use `Array#{indexOf,lastIndexOf}()` instead of `Array#{findIndex,findLastIndex}()` when looking for the index of an item.
|
|
123
|
+
- Make sure iterable callbacks return consistent values.
|
|
124
|
+
- Use `with { type: "json" }` for JSON module imports.
|
|
125
|
+
- Use numeric separators in numeric literals.
|
|
126
|
+
- Use object spread instead of `Object.assign()` when constructing new objects.
|
|
127
|
+
- Always use the radix argument when using `parseInt()`.
|
|
128
|
+
- Make sure JSDoc comment lines start with a single asterisk, except for the first one.
|
|
129
|
+
- Include a description parameter for `Symbol()`.
|
|
130
|
+
- Don't use spread (`...`) syntax on accumulators.
|
|
131
|
+
- Don't use the `delete` operator.
|
|
132
|
+
- Don't access namespace imports dynamically.
|
|
133
|
+
- Don't use namespace imports.
|
|
134
|
+
- Declare regex literals at the top level.
|
|
135
|
+
- Don't use `target="_blank"` without `rel="noopener"`.
|
|
136
|
+
|
|
137
|
+
### TypeScript Best Practices
|
|
138
|
+
|
|
139
|
+
- Don't use TypeScript enums.
|
|
140
|
+
- Don't export imported variables.
|
|
141
|
+
- Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.
|
|
142
|
+
- Don't use TypeScript namespaces.
|
|
143
|
+
- Don't use non-null assertions with the `!` postfix operator.
|
|
144
|
+
- Don't use parameter properties in class constructors.
|
|
145
|
+
- Don't use user-defined types.
|
|
146
|
+
- Use `as const` instead of literal types and type annotations.
|
|
147
|
+
- Use either `T[]` or `Array<T>` consistently.
|
|
148
|
+
- Initialize each enum member value explicitly.
|
|
149
|
+
- Use `export type` for types.
|
|
150
|
+
- Use `import type` for types.
|
|
151
|
+
- Make sure all enum members are literal values.
|
|
152
|
+
- Don't use TypeScript const enum.
|
|
153
|
+
- Don't declare empty interfaces.
|
|
154
|
+
- Don't let variables evolve into any type through reassignments.
|
|
155
|
+
- Don't use the any type.
|
|
156
|
+
- Don't misuse the non-null assertion operator (!) in TypeScript files.
|
|
157
|
+
- Don't use implicit any type on variable declarations.
|
|
158
|
+
- Don't merge interfaces and classes unsafely.
|
|
159
|
+
- Don't use overload signatures that aren't next to each other.
|
|
160
|
+
- Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
|
|
161
|
+
|
|
162
|
+
### Style and Consistency
|
|
163
|
+
|
|
164
|
+
- Don't use global `eval()`.
|
|
165
|
+
- Don't use callbacks in asynchronous tests and hooks.
|
|
166
|
+
- Don't use negation in `if` statements that have `else` clauses.
|
|
167
|
+
- Don't use nested ternary expressions.
|
|
168
|
+
- Don't reassign function parameters.
|
|
169
|
+
- This rule lets you specify global variable names you don't want to use in your application.
|
|
170
|
+
- Don't use specified modules when loaded by import or require.
|
|
171
|
+
- Don't use constants whose value is the upper-case version of their name.
|
|
172
|
+
- Use `String.slice()` instead of `String.substr()` and `String.substring()`.
|
|
173
|
+
- Don't use template literals if you don't need interpolation or special-character handling.
|
|
174
|
+
- Don't use `else` blocks when the `if` block breaks early.
|
|
175
|
+
- Don't use yoda expressions.
|
|
176
|
+
- Don't use Array constructors.
|
|
177
|
+
- Use `at()` instead of integer index access.
|
|
178
|
+
- Follow curly brace conventions.
|
|
179
|
+
- Use `else if` instead of nested `if` statements in `else` clauses.
|
|
180
|
+
- Use single `if` statements instead of nested `if` clauses.
|
|
181
|
+
- Use `new` for all builtins except `String`, `Number`, and `Boolean`.
|
|
182
|
+
- Use consistent accessibility modifiers on class properties and methods.
|
|
183
|
+
- Use `const` declarations for variables that are only assigned once.
|
|
184
|
+
- Put default function parameters and optional function parameters last.
|
|
185
|
+
- Include a `default` clause in switch statements.
|
|
186
|
+
- Use the `**` operator instead of `Math.pow`.
|
|
187
|
+
- Use `for-of` loops when you need the index to extract an item from the iterated array.
|
|
188
|
+
- Use `node:assert/strict` over `node:assert`.
|
|
189
|
+
- Use the `node:` protocol for Node.js builtin modules.
|
|
190
|
+
- Use Number properties instead of global ones.
|
|
191
|
+
- Use assignment operator shorthand where possible.
|
|
192
|
+
- Use function types instead of object types with call signatures.
|
|
193
|
+
- Use template literals over string concatenation.
|
|
194
|
+
- Use `new` when throwing an error.
|
|
195
|
+
- Don't throw non-Error values.
|
|
196
|
+
- Use `String.trimStart()` and `String.trimEnd()` over `String.trimLeft()` and `String.trimRight()`.
|
|
197
|
+
- Use standard constants instead of approximated literals.
|
|
198
|
+
- Don't assign values in expressions.
|
|
199
|
+
- Don't use async functions as Promise executors.
|
|
200
|
+
- Don't reassign exceptions in catch clauses.
|
|
201
|
+
- Don't reassign class members.
|
|
202
|
+
- Don't compare against -0.
|
|
203
|
+
- Don't use labeled statements that aren't loops.
|
|
204
|
+
- Don't use void type outside of generic or return types.
|
|
205
|
+
- Don't use console.
|
|
206
|
+
- Don't use control characters and escape sequences that match control characters in regular expression literals.
|
|
207
|
+
- Don't use debugger.
|
|
208
|
+
- Don't assign directly to document.cookie.
|
|
209
|
+
- Use `===` and `!==`.
|
|
210
|
+
- Don't use duplicate case labels.
|
|
211
|
+
- Don't use duplicate class members.
|
|
212
|
+
- Don't use duplicate conditions in if-else-if chains.
|
|
213
|
+
- Don't use two keys with the same name inside objects.
|
|
214
|
+
- Don't use duplicate function parameter names.
|
|
215
|
+
- Don't have duplicate hooks in describe blocks.
|
|
216
|
+
- Don't use empty block statements and static blocks.
|
|
217
|
+
- Don't let switch clauses fall through.
|
|
218
|
+
- Don't reassign function declarations.
|
|
219
|
+
- Don't allow assignments to native objects and read-only global variables.
|
|
220
|
+
- Use Number.isFinite instead of global isFinite.
|
|
221
|
+
- Use Number.isNaN instead of global isNaN.
|
|
222
|
+
- Don't assign to imported bindings.
|
|
223
|
+
- Don't use irregular whitespace characters.
|
|
224
|
+
- Don't use labels that share a name with a variable.
|
|
225
|
+
- Don't use characters made with multiple code points in character class syntax.
|
|
226
|
+
- Make sure to use new and constructor properly.
|
|
227
|
+
- Don't use shorthand assign when the variable appears on both sides.
|
|
228
|
+
- Don't use octal escape sequences in string literals.
|
|
229
|
+
- Don't use Object.prototype builtins directly.
|
|
230
|
+
- Don't redeclare variables, functions, classes, and types in the same scope.
|
|
231
|
+
- Don't have redundant "use strict".
|
|
232
|
+
- Don't compare things where both sides are exactly the same.
|
|
233
|
+
- Don't let identifiers shadow restricted names.
|
|
234
|
+
- Don't use sparse arrays (arrays with holes).
|
|
235
|
+
- Don't use template literal placeholder syntax in regular strings.
|
|
236
|
+
- Don't use the then property.
|
|
237
|
+
- Don't use unsafe negation.
|
|
238
|
+
- Don't use var.
|
|
239
|
+
- Don't use with statements in non-strict contexts.
|
|
240
|
+
- Make sure async functions actually use await.
|
|
241
|
+
- Make sure default clauses in switch statements come last.
|
|
242
|
+
- Make sure to pass a message value when creating a built-in error.
|
|
243
|
+
- Make sure get methods always return a value.
|
|
244
|
+
- Use a recommended display strategy with Google Fonts.
|
|
245
|
+
- Make sure for-in loops include an if statement.
|
|
246
|
+
- Use Array.isArray() instead of instanceof Array.
|
|
247
|
+
- Make sure to use the digits argument with Number#toFixed().
|
|
248
|
+
- Make sure to use the "use strict" directive in script files.
|
|
249
|
+
|
|
250
|
+
### Testing Best Practices
|
|
251
|
+
|
|
252
|
+
- Don't use export or module.exports in test files.
|
|
253
|
+
- Don't use focused tests.
|
|
254
|
+
- Make sure the assertion function, like expect, is placed inside an it() function call.
|
|
255
|
+
- Don't use disabled tests.
|
|
256
|
+
- Use Bun.
|
|
257
|
+
|
|
258
|
+
## Example: Error Handling
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
// ✅ Good: Comprehensive error handling
|
|
262
|
+
try {
|
|
263
|
+
const result = await fetchData();
|
|
264
|
+
return { success: true, data: result };
|
|
265
|
+
} catch (error) {
|
|
266
|
+
console.error('API call failed:', error);
|
|
267
|
+
return { success: false, error: error.message };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// ❌ Bad: Swallowing errors
|
|
271
|
+
try {
|
|
272
|
+
return await fetchData();
|
|
273
|
+
} catch (e) {
|
|
274
|
+
console.log(e);
|
|
275
|
+
}
|
|
276
|
+
```
|
|
@@ -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/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) Nazar Kornienko (blefnk), Bleverse, Reliverse
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
[sponsor](https://github.com/sponsors/blefnk) — [discord](https://discord.gg/Pb8uKbwpsJ) — [repo](https://github.com/reliverse/relico) — [npm](https://npmjs.com/@reliverse/relico)
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Why Relico?
|
|
8
8
|
|
|
9
|
-
Because terminal styling shouldn
|
|
9
|
+
Because terminal styling shouldn't feel like duct tape. **Relico** brings design-system-level polish to your CLI logs, banners, errors, and output — without battling your runtime, shell, or platform. Terminal styling should be *fun*, not frustrating. Relico makes it feel *right*.
|
|
10
10
|
|
|
11
|
+
- ⚡ **Blazing-fast & lightweight** — type-safe, runtime-safe, build-time aware, zero bloat, zero dependencies, zero configuration
|
|
11
12
|
- 🎨 **80+ built-in colors** — easily customize or override with your own [`HEX`](https://chatgpt.com/share/67fd24cd-e7b0-8008-a815-f33d01f33758) palette
|
|
12
13
|
- 🧩 **Themeable by default** — end-users can configure themes+typography+colors via `relico.config.ts`, developers via `await initUserConfig({ ... })`
|
|
13
14
|
- 🌈 **Smart color detection** — full support for truecolor (16M), 256-color, and fallback modes across environments
|
|
14
15
|
- 🦄 **A modern alternative** to `chalk`, `kleur`, `colorette`, `gradient-string`, and legacy console hacks
|
|
15
16
|
- 🧠 **Typed, chainable, DX-optimized** — with autocompletion, inline docs, and expressive API ergonomics
|
|
16
17
|
- 🌿 **Respects your environment** — including `NO_COLOR`, `FORCE_COLOR`, and terminal capabilities
|
|
17
|
-
- ⚡ **Blazing-fast & lightweight** — zero bloat, runtime-safe, build-time aware, minimal dependencies
|
|
18
18
|
- 🛡️ **Cross-platform & runtime-ready** — works everywhere — even when your users' terminals are weird — in Node.js, Bun, Deno, CI, Windows, macOS, Linux, Docker & more
|
|
19
19
|
- 🎯 **Precision-crafted ANSI output** — every color, reset, and style code is finely tuned for contrast, legibility, and glitch-free rendering — even in flaky terminals (as far as Node.js permits)
|
|
20
|
-
- 🦾 **Relico isn
|
|
20
|
+
- 🦾 **Relico isn't just about color** — it's about communication — make your CLI users' output more than readable — make it feel *intentional*.
|
|
21
21
|
|
|
22
22
|
<img src="./example/example.png" width="50%" alt="Available Relico colors" />
|
|
23
23
|
|
|
@@ -28,6 +28,64 @@ bun add @reliverse/relico
|
|
|
28
28
|
# bun • pnpm • yarn • npm
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
## Performance
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
$ bun bench
|
|
35
|
+
$ bun examples/benchmarks/performance.ts
|
|
36
|
+
|
|
37
|
+
🚀 Relico Performance Benchmarks
|
|
38
|
+
==================================================
|
|
39
|
+
C:/B/R/reliverse/relico/dist-npm/bin/mod.js
|
|
40
|
+
|
|
41
|
+
Basic color access: 107.02ms (934 379 ops/sec)
|
|
42
|
+
Chained colors: 191.49ms (522 227 ops/sec)
|
|
43
|
+
RGB color creation: 73.79ms (1 355 276 ops/sec)
|
|
44
|
+
Hex color creation: 87.73ms (1 139 866 ops/sec)
|
|
45
|
+
HSL color creation: 78.10ms (1 280 444 ops/sec)
|
|
46
|
+
Chain function: 226.13ms (442 219 ops/sec)
|
|
47
|
+
Background colors: 208.55ms (479 492 ops/sec)
|
|
48
|
+
Bright colors: 124.96ms (800 282 ops/sec)
|
|
49
|
+
Pastel colors: 126.03ms (793 446 ops/sec)
|
|
50
|
+
Multiline text (small): 165.08ms (605 769 ops/sec)
|
|
51
|
+
Multiline text (large): 1089.44ms (91 790 ops/sec)
|
|
52
|
+
|
|
53
|
+
Bundle Size Test:
|
|
54
|
+
Core exports imported: 5
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
$ bun size
|
|
59
|
+
$ bun examples/benchmarks/bundle-size.ts
|
|
60
|
+
|
|
61
|
+
📦 Bundle Size Analysis
|
|
62
|
+
==============================
|
|
63
|
+
C:/B/R/reliverse/relico/dist-npm/bin/mod.js
|
|
64
|
+
|
|
65
|
+
Size:
|
|
66
|
+
- File size: 12.9KB
|
|
67
|
+
- Declaration file size: 2.9KB
|
|
68
|
+
- Total bundle size: 15.8KB
|
|
69
|
+
|
|
70
|
+
Breakdown:
|
|
71
|
+
- Color data: 554B (4.2%)
|
|
72
|
+
- Logic: 12.4KB (95.8%)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 🔥 Important Notice
|
|
76
|
+
|
|
77
|
+
Relico (v1.3.0+) was recently rewritten from scratch:
|
|
78
|
+
|
|
79
|
+
- To have zero dependencies and zero configuration
|
|
80
|
+
- Include only the really necessary for daily usage features
|
|
81
|
+
- To be as fast as possible
|
|
82
|
+
|
|
83
|
+
Some missing important features may be added back in the coming future.
|
|
84
|
+
|
|
85
|
+
This means everything or most of the things described below in this readme may be different now.
|
|
86
|
+
|
|
87
|
+
The readme will be updated soon.
|
|
88
|
+
|
|
31
89
|
## Configuration
|
|
32
90
|
|
|
33
91
|
**If you're end-user OR developer, create `relico.config.ts` in your root**:
|
|
@@ -119,7 +177,7 @@ const brandColors: DefaultColorKeys[] = ["magentaBright", "maroon"];
|
|
|
119
177
|
|
|
120
178
|
## Color Detection
|
|
121
179
|
|
|
122
|
-
Relico detects your terminal
|
|
180
|
+
Relico detects your terminal's capability:
|
|
123
181
|
|
|
124
182
|
```ts
|
|
125
183
|
import { colorSupport } from "@reliverse/relico";
|
|
@@ -293,7 +351,7 @@ Relico draws inspiration from all — and goes beyond them with modern configs,
|
|
|
293
351
|
|
|
294
352
|
## 🛠 Contributing
|
|
295
353
|
|
|
296
|
-
We
|
|
354
|
+
We'd love your help! Bug? Feature? Example? PR it!
|
|
297
355
|
Or hop into [Discord](https://discord.gg/Pb8uKbwpsJ) to discuss CLI theming and terminal art 💜
|
|
298
356
|
|
|
299
357
|
```bash
|
package/biome.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.2.0/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-*",
|
|
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": { "noConsole": "off" },
|
|
46
|
+
"style": { "useNodejsImportProtocol": "off", "noMagicNumbers": "off" },
|
|
47
|
+
"complexity": { "noExcessiveLinesPerFunction": "off" },
|
|
48
|
+
"nursery": {
|
|
49
|
+
"useConsistentTypeDefinitions": {
|
|
50
|
+
"level": "error",
|
|
51
|
+
"options": { "style": "interface" }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"javascript": {
|
|
57
|
+
"globals": ["Bun"],
|
|
58
|
+
"formatter": {
|
|
59
|
+
"jsxQuoteStyle": "double",
|
|
60
|
+
"quoteProperties": "asNeeded",
|
|
61
|
+
"trailingCommas": "all",
|
|
62
|
+
"semicolons": "always",
|
|
63
|
+
"arrowParentheses": "always",
|
|
64
|
+
"bracketSpacing": true,
|
|
65
|
+
"bracketSameLine": false,
|
|
66
|
+
"quoteStyle": "double",
|
|
67
|
+
"attributePosition": "auto"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"assist": {
|
|
71
|
+
"enabled": true,
|
|
72
|
+
"actions": {
|
|
73
|
+
"source": {
|
|
74
|
+
"organizeImports": "on"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
package/deprecated.zip
ADDED
|
Binary file
|
|
@@ -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!");
|