rainbowindex 0.3.0 → 0.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.
- package/CHANGELOG.md +135 -0
- package/README.md +27 -4
- package/dist/browser.d.ts +2 -2
- package/dist/browser.mjs +1 -1
- package/dist/chunk-3HRMFZGE.mjs +19 -0
- package/dist/{chunk-AZXWJ625.mjs → chunk-53WD6U2X.mjs} +826 -610
- package/dist/{chunk-IE6N76PW.mjs → chunk-6GTG5SZJ.mjs} +5269 -4660
- package/dist/{chunk-AUWGHSTO.mjs → chunk-IYIUS7AE.mjs} +64 -126
- package/dist/{chunk-SOMDX7V6.mjs → chunk-KRZL4IDK.mjs} +337 -421
- package/dist/chunk-WYMCN5OC.mjs +244 -0
- package/dist/cli.mjs +280 -277
- package/dist/{index-CfDtWufj.d.ts → context-ruu2x_jR.d.ts} +15 -70
- package/dist/editor.d.ts +98 -28
- package/dist/editor.mjs +37 -8
- package/dist/{index-DK6APAGD.d.ts → index-Dp6i5TSv.d.ts} +16 -12
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/safelist-D9-Plqta.d.ts +109 -0
- package/dist/vite.mjs +80 -83
- package/package.json +2 -1
- package/dist/chunk-RHOQSN2B.mjs +0 -691
- package/dist/safelist-CH3_PywB.d.ts +0 -43
package/dist/vite.mjs
CHANGED
|
@@ -1,100 +1,89 @@
|
|
|
1
1
|
import {
|
|
2
2
|
postcss_default
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-IYIUS7AE.mjs";
|
|
4
|
+
import "./chunk-53WD6U2X.mjs";
|
|
5
5
|
import {
|
|
6
|
+
isSourceFile
|
|
7
|
+
} from "./chunk-3HRMFZGE.mjs";
|
|
8
|
+
import {
|
|
9
|
+
DIRECTIVE_TYPE_NAMES,
|
|
6
10
|
expandApplyGroups,
|
|
7
11
|
findClosingBrace,
|
|
8
12
|
hasRIActivation,
|
|
9
13
|
isAtRuleBoundary,
|
|
10
|
-
isAtRuleNameChar
|
|
11
|
-
|
|
12
|
-
} from "./chunk-IE6N76PW.mjs";
|
|
14
|
+
isAtRuleNameChar
|
|
15
|
+
} from "./chunk-6GTG5SZJ.mjs";
|
|
13
16
|
import {
|
|
14
17
|
devWarn
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KRZL4IDK.mjs";
|
|
16
19
|
|
|
17
20
|
// src/integrations/vite.ts
|
|
18
21
|
import { existsSync } from "fs";
|
|
19
|
-
import { access,
|
|
22
|
+
import { access, readdir, readFile } from "fs/promises";
|
|
20
23
|
import { join, relative, resolve } from "path";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
|
|
25
|
+
// src/directives/postcss-safe.ts
|
|
26
|
+
var BODY_GRAMMAR = {
|
|
27
|
+
color: "removal",
|
|
28
|
+
text: "removal",
|
|
29
|
+
spacing: "removal",
|
|
30
|
+
breakpoint: "removal",
|
|
31
|
+
rounded: "removal",
|
|
32
|
+
shadow: "removal",
|
|
33
|
+
weight: "removal",
|
|
34
|
+
ease: "removal",
|
|
35
|
+
blur: "removal",
|
|
36
|
+
z: "removal",
|
|
37
|
+
animate: "removal",
|
|
38
|
+
leading: "removal",
|
|
39
|
+
tracking: "removal",
|
|
40
|
+
opacity: "removal",
|
|
41
|
+
duration: "removal",
|
|
42
|
+
fluid: "keyword",
|
|
43
|
+
font: "raw",
|
|
44
|
+
preflight: "raw",
|
|
45
|
+
utility: "raw",
|
|
46
|
+
custom: "raw",
|
|
47
|
+
source: "raw",
|
|
48
|
+
layer: "raw",
|
|
49
|
+
register: "raw"
|
|
50
|
+
};
|
|
51
|
+
var REMOVAL_BODY_DIRECTIVES = new Set(
|
|
52
|
+
DIRECTIVE_TYPE_NAMES.filter((n) => BODY_GRAMMAR[n] === "removal")
|
|
53
|
+
);
|
|
54
|
+
var KEYWORD_BODY_DIRECTIVES = new Set(
|
|
55
|
+
DIRECTIVE_TYPE_NAMES.filter((n) => BODY_GRAMMAR[n] === "keyword")
|
|
56
|
+
);
|
|
40
57
|
var REMOVAL_RE = /!([\w][\w-]*)\s*;/g;
|
|
41
58
|
var FLUID_KEYWORD_RE = /\b(no-parabolic|parabolic|no-shift|shift)\s*;?/g;
|
|
42
59
|
var COLOR_FLAG_RE = /(?<=[{;\s]|^)(inline|no-parabolic|parabolic)\s*(?:;|(?=}))/g;
|
|
43
|
-
function
|
|
44
|
-
|
|
60
|
+
function mapTopLevelSpans(body, mapOutside, mapBlock) {
|
|
61
|
+
let brace = body.indexOf("{");
|
|
62
|
+
if (brace === -1) return mapOutside(body);
|
|
45
63
|
let out = "";
|
|
46
64
|
let segStart = 0;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
depth++;
|
|
56
|
-
} else if (ch === "}") {
|
|
57
|
-
if (depth > 0) depth--;
|
|
58
|
-
if (depth === 0) {
|
|
59
|
-
out += body.slice(segStart, i + 1);
|
|
60
|
-
segStart = i + 1;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
65
|
+
while (brace !== -1) {
|
|
66
|
+
out += mapOutside(body.slice(segStart, brace));
|
|
67
|
+
const close = findClosingBrace(body, brace);
|
|
68
|
+
if (close === -1) return out + body.slice(brace);
|
|
69
|
+
out += `{${mapBlock(body.slice(brace + 1, close))}}`;
|
|
70
|
+
segStart = close + 1;
|
|
71
|
+
brace = body.indexOf("{", segStart);
|
|
63
72
|
}
|
|
64
|
-
out
|
|
65
|
-
return out;
|
|
73
|
+
return out + mapOutside(body.slice(segStart));
|
|
66
74
|
}
|
|
75
|
+
var keepSpan = (span) => span;
|
|
67
76
|
function rewriteColorOptionFlag(_match, keyword) {
|
|
68
77
|
if (keyword === "inline") return "--ri-inline: true;";
|
|
69
78
|
const negated = keyword.startsWith("no-");
|
|
70
79
|
return `--ri-${negated ? keyword.slice(3) : keyword}: ${negated ? "false" : "true"};`;
|
|
71
80
|
}
|
|
72
81
|
function rewriteColorOptionFlags(body) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
for (let i = 0; i < body.length; i++) {
|
|
79
|
-
const ch = body[i];
|
|
80
|
-
if (ch === "{") {
|
|
81
|
-
if (depth === 0) {
|
|
82
|
-
out += body.slice(segStart, i + 1);
|
|
83
|
-
blockStart = i + 1;
|
|
84
|
-
}
|
|
85
|
-
depth++;
|
|
86
|
-
} else if (ch === "}") {
|
|
87
|
-
if (depth > 0) depth--;
|
|
88
|
-
if (depth === 0 && blockStart !== -1) {
|
|
89
|
-
out += body.slice(blockStart, i).replace(COLOR_FLAG_RE, rewriteColorOptionFlag);
|
|
90
|
-
out += "}";
|
|
91
|
-
segStart = i + 1;
|
|
92
|
-
blockStart = -1;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
out += body.slice(segStart);
|
|
97
|
-
return out;
|
|
82
|
+
return mapTopLevelSpans(
|
|
83
|
+
body,
|
|
84
|
+
keepSpan,
|
|
85
|
+
(interior) => interior.replace(COLOR_FLAG_RE, rewriteColorOptionFlag)
|
|
86
|
+
);
|
|
98
87
|
}
|
|
99
88
|
function rewriteDirectiveBodies(code) {
|
|
100
89
|
let out = "";
|
|
@@ -129,17 +118,21 @@ function rewriteDirectiveBodies(code) {
|
|
|
129
118
|
const close = findClosingBrace(code, braceIdx);
|
|
130
119
|
const bodyStart = braceIdx + 1;
|
|
131
120
|
const bodyEnd = close === -1 ? code.length : close;
|
|
132
|
-
let rewritten =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
s = s.replace(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
121
|
+
let rewritten = mapTopLevelSpans(
|
|
122
|
+
code.slice(bodyStart, bodyEnd),
|
|
123
|
+
(span) => {
|
|
124
|
+
let s = span;
|
|
125
|
+
if (removals) s = s.replace(REMOVAL_RE, "--ri-rm: $1;");
|
|
126
|
+
if (keywords) {
|
|
127
|
+
s = s.replace(FLUID_KEYWORD_RE, (_, kw) => {
|
|
128
|
+
const negated = kw.startsWith("no-");
|
|
129
|
+
return `--ri-${negated ? kw.slice(3) : kw}: ${negated ? "false" : "true"};`;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return s;
|
|
133
|
+
},
|
|
134
|
+
keepSpan
|
|
135
|
+
);
|
|
143
136
|
if (name === "color") rewritten = rewriteColorOptionFlags(rewritten);
|
|
144
137
|
out += code.slice(last, bodyStart) + rewritten;
|
|
145
138
|
last = bodyEnd;
|
|
@@ -148,6 +141,9 @@ function rewriteDirectiveBodies(code) {
|
|
|
148
141
|
if (last === 0) return code;
|
|
149
142
|
return out + code.slice(last);
|
|
150
143
|
}
|
|
144
|
+
|
|
145
|
+
// src/integrations/vite.ts
|
|
146
|
+
var CSS_FILE_RE = /\.(?:module\.)?css$/;
|
|
151
147
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist"]);
|
|
152
148
|
var POSTCSS_CONFIG_FILES = [
|
|
153
149
|
"postcss.config.js",
|
|
@@ -248,11 +244,12 @@ function rainbowindexVite() {
|
|
|
248
244
|
}
|
|
249
245
|
if (!isSourceFile(file)) return;
|
|
250
246
|
const extraModules = [];
|
|
247
|
+
const hmrModules = new Set(modules);
|
|
251
248
|
for (const cssFile of riCSSFiles) {
|
|
252
249
|
const mods = server.moduleGraph.getModulesByFile(cssFile);
|
|
253
250
|
if (mods) {
|
|
254
251
|
for (const mod of mods) {
|
|
255
|
-
if (!
|
|
252
|
+
if (!hmrModules.has(mod)) {
|
|
256
253
|
extraModules.push(mod);
|
|
257
254
|
}
|
|
258
255
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rainbowindex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "CSS-first system for building and maintaining consistent user interfaces",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@biomejs/biome": "^2.4.16",
|
|
100
|
+
"@capsizecss/metrics": "^4.2.0",
|
|
100
101
|
"@types/node": "^25.9.1",
|
|
101
102
|
"@vitest/coverage-v8": "^4.1.0",
|
|
102
103
|
"postcss": "^8.5.8",
|