@aedis/cli 0.4.1 → 0.4.2
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/README.md +3 -3
- package/dist/aedis.js +17 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@ before any file is written, npm dependencies are pinned to exact versions at lea
|
|
|
6
6
|
script runs.
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
|
-
npx @aedis/cli@0.4.
|
|
10
|
-
npx @aedis/cli@0.4.
|
|
11
|
-
npx @aedis/cli@0.4.
|
|
9
|
+
npx @aedis/cli@0.4.2 init
|
|
10
|
+
npx @aedis/cli@0.4.2 add button approval-card
|
|
11
|
+
npx @aedis/cli@0.4.2 diff
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
Always pin the version, as above. Never run `npx aedis`: the unscoped `aedis` package on npm is not this one.
|
package/dist/aedis.js
CHANGED
|
@@ -47,36 +47,26 @@ function oklchToRgba({ l, c, h, alpha }) {
|
|
|
47
47
|
const l_ = (l + .3963377774 * a + .2158037573 * b) ** 3;
|
|
48
48
|
const m_ = (l - .1055613458 * a - .0638541728 * b) ** 3;
|
|
49
49
|
const s_ = (l - .0894841775 * a - 1.291485548 * b) ** 3;
|
|
50
|
-
const linear = [
|
|
51
|
-
4.0767416621 * l_ - 3.3077115913 * m_ + .2309699292 * s_,
|
|
52
|
-
-1.2684380046 * l_ + 2.6097574011 * m_ - .3413193965 * s_,
|
|
53
|
-
-.0041960863 * l_ - .7034186147 * m_ + 1.707614701 * s_
|
|
54
|
-
];
|
|
55
50
|
const gamma = (x) => x <= .0031308 ? 12.92 * x : 1.055 * x ** (1 / 2.4) - .055;
|
|
56
|
-
const
|
|
51
|
+
const channel = (x) => Math.round(Math.min(1, Math.max(0, gamma(x))) * 255);
|
|
57
52
|
return [
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
channel(4.0767416621 * l_ - 3.3077115913 * m_ + .2309699292 * s_),
|
|
54
|
+
channel(-1.2684380046 * l_ + 2.6097574011 * m_ - .3413193965 * s_),
|
|
55
|
+
channel(-.0041960863 * l_ - .7034186147 * m_ + 1.707614701 * s_),
|
|
61
56
|
alpha
|
|
62
57
|
];
|
|
63
58
|
}
|
|
64
59
|
/** Reads #rgb, #rrggbb, #rrggbbaa, rgb()/rgba() and oklch(). Throws on anything else. */
|
|
65
60
|
function parseColor(value) {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
const h =
|
|
69
|
-
const
|
|
70
|
-
0,
|
|
71
|
-
2,
|
|
72
|
-
4,
|
|
73
|
-
6
|
|
74
|
-
].filter((i) => i < h.length).map((i) => parseInt(h.slice(i, i + 2), 16));
|
|
61
|
+
const digits = HEX$1.exec(value)?.[1];
|
|
62
|
+
if (digits !== void 0) {
|
|
63
|
+
const h = digits.length === 3 ? [...digits].map((c) => c + c).join("") : digits;
|
|
64
|
+
const byte = (i) => parseInt(h.slice(i, i + 2), 16);
|
|
75
65
|
return [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
byte(0),
|
|
67
|
+
byte(2),
|
|
68
|
+
byte(4),
|
|
69
|
+
h.length === 8 ? byte(6) / 255 : 1
|
|
80
70
|
];
|
|
81
71
|
}
|
|
82
72
|
const rgba = RGBA.exec(value);
|
|
@@ -104,8 +94,8 @@ const luminance = ([r, g, b]) => {
|
|
|
104
94
|
function contrast(foreground, background, page = "#ffffff") {
|
|
105
95
|
const bg = over(parseColor(background), parseColor(page));
|
|
106
96
|
const fg = over(parseColor(foreground), bg);
|
|
107
|
-
const [
|
|
108
|
-
return (
|
|
97
|
+
const [a, b] = [luminance(fg), luminance(bg)];
|
|
98
|
+
return (Math.max(a, b) + .05) / (Math.min(a, b) + .05);
|
|
109
99
|
}
|
|
110
100
|
/** Euclidean distance in sRGB, 0–1: how far apart two opaque colors look at a glance. */
|
|
111
101
|
function colorDistance(a, b) {
|
|
@@ -1639,7 +1629,7 @@ function planFiles(items, config, root) {
|
|
|
1639
1629
|
}
|
|
1640
1630
|
//#endregion
|
|
1641
1631
|
//#region src/cli.ts
|
|
1642
|
-
const VERSION = "0.4.
|
|
1632
|
+
const VERSION = "0.4.2";
|
|
1643
1633
|
/** What `aedis init` installs: config, theme tokens, cn and the security primitives. */
|
|
1644
1634
|
const INIT_ITEMS = [
|
|
1645
1635
|
"theme",
|
|
@@ -1803,7 +1793,7 @@ async function run(argv, io) {
|
|
|
1803
1793
|
}
|
|
1804
1794
|
if (!existsSync(path.join(root, "package.json"))) throw new Error(`${root} has no package.json; run inside your app`);
|
|
1805
1795
|
if (command === "init") {
|
|
1806
|
-
const config = readConfig(root) ?? defaultConfig(root, flags.release ?? `v0.4.
|
|
1796
|
+
const config = readConfig(root) ?? defaultConfig(root, flags.release ?? `v0.4.2`);
|
|
1807
1797
|
if (!isRelease(config.release)) throw new Error(`invalid release ${config.release}`);
|
|
1808
1798
|
const decoded = flags.preset === void 0 ? null : decodePreset(flags.preset);
|
|
1809
1799
|
if (decoded && !decoded.ok) throw new Error(`preset refused: ${decoded.error}`);
|
|
@@ -1839,7 +1829,7 @@ ${themeToCss(theme)}
|
|
|
1839
1829
|
}
|
|
1840
1830
|
if (command === "theme" && args[0] === "import") {
|
|
1841
1831
|
if (!args[1]) throw new Error("theme import: give the theme's JSON file");
|
|
1842
|
-
const config = readConfig(root) ?? defaultConfig(root, `v0.4.
|
|
1832
|
+
const config = readConfig(root) ?? defaultConfig(root, `v0.4.2`);
|
|
1843
1833
|
const input = insideProject(root, path.relative(root, path.resolve(io.cwd, args[1])));
|
|
1844
1834
|
const result = themeImport(readFileSync(input, "utf8"), path.basename(input));
|
|
1845
1835
|
if (!result.ok) {
|
package/package.json
CHANGED