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
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ANIMATION_STATIC_NAMES,
|
|
3
|
+
BACKGROUND_STATIC_NAMES,
|
|
4
|
+
BORDER_STATIC_NAMES,
|
|
5
|
+
EFFECTS_STATIC_NAMES,
|
|
6
|
+
LAYOUT_STATIC_NAMES,
|
|
7
|
+
PREFIX_DISPATCH,
|
|
8
|
+
ROOT_GROUPS,
|
|
9
|
+
ROUNDED_CORNER_NAMES,
|
|
10
|
+
ROUNDED_SIDE_NAMES,
|
|
11
|
+
SPACING_SAMPLES,
|
|
12
|
+
STATIC_UTILITIES,
|
|
13
|
+
SVG_STATIC_NAMES,
|
|
14
|
+
TYPOGRAPHY_STATIC_NAMES,
|
|
15
|
+
codepointCompare,
|
|
16
|
+
parseUtility,
|
|
17
|
+
resolveUtilityDeclarations
|
|
18
|
+
} from "./chunk-6GTG5SZJ.mjs";
|
|
19
|
+
import {
|
|
20
|
+
SPECIAL_COLORS
|
|
21
|
+
} from "./chunk-KRZL4IDK.mjs";
|
|
22
|
+
|
|
23
|
+
// src/project/css-entry.ts
|
|
24
|
+
var CSS_ENTRY_CANDIDATES = Object.freeze([
|
|
25
|
+
"src/index.css",
|
|
26
|
+
"src/style.css",
|
|
27
|
+
"src/styles.css",
|
|
28
|
+
"src/app.css",
|
|
29
|
+
"src/global.css",
|
|
30
|
+
"index.css",
|
|
31
|
+
"style.css",
|
|
32
|
+
"styles.css",
|
|
33
|
+
"app.css",
|
|
34
|
+
"global.css"
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
// src/utilities/enumerate.ts
|
|
38
|
+
var COLOR_STOPS = Object.freeze([
|
|
39
|
+
"50",
|
|
40
|
+
"100",
|
|
41
|
+
"150",
|
|
42
|
+
"200",
|
|
43
|
+
"250",
|
|
44
|
+
"300",
|
|
45
|
+
"350",
|
|
46
|
+
"400",
|
|
47
|
+
"450",
|
|
48
|
+
"500",
|
|
49
|
+
"550",
|
|
50
|
+
"600",
|
|
51
|
+
"650",
|
|
52
|
+
"700",
|
|
53
|
+
"750",
|
|
54
|
+
"800",
|
|
55
|
+
"850",
|
|
56
|
+
"900",
|
|
57
|
+
"950"
|
|
58
|
+
]);
|
|
59
|
+
var FRACTION_SAMPLES = Object.freeze([
|
|
60
|
+
"1/2",
|
|
61
|
+
"1/3",
|
|
62
|
+
"2/3",
|
|
63
|
+
"1/4",
|
|
64
|
+
"3/4",
|
|
65
|
+
"1/5",
|
|
66
|
+
"2/5",
|
|
67
|
+
"3/5",
|
|
68
|
+
"4/5",
|
|
69
|
+
"1/6",
|
|
70
|
+
"5/6"
|
|
71
|
+
]);
|
|
72
|
+
var INT_SAMPLES = Object.freeze(["0", "1", "2", "3", "4", "6", "8", "10", "12"]);
|
|
73
|
+
var PERCENT_SAMPLES = Object.freeze([
|
|
74
|
+
"0",
|
|
75
|
+
"5",
|
|
76
|
+
"10",
|
|
77
|
+
"15",
|
|
78
|
+
"20",
|
|
79
|
+
"25",
|
|
80
|
+
"30",
|
|
81
|
+
"40",
|
|
82
|
+
"50",
|
|
83
|
+
"60",
|
|
84
|
+
"70",
|
|
85
|
+
"75",
|
|
86
|
+
"80",
|
|
87
|
+
"90",
|
|
88
|
+
"95",
|
|
89
|
+
"100"
|
|
90
|
+
]);
|
|
91
|
+
var BUILTIN_FONT_SLOTS = Object.freeze(["sans", "serif", "mono"]);
|
|
92
|
+
var DURATION_SAMPLES = Object.freeze(["75", "100", "150", "200", "300", "500", "700", "1000"]);
|
|
93
|
+
var ROUNDED_SIDES = Object.freeze([
|
|
94
|
+
...ROUNDED_SIDE_NAMES,
|
|
95
|
+
...ROUNDED_CORNER_NAMES
|
|
96
|
+
]);
|
|
97
|
+
function buildValueSpaces() {
|
|
98
|
+
const table = /* @__PURE__ */ new Map();
|
|
99
|
+
for (const { roots, spec } of ROOT_GROUPS) {
|
|
100
|
+
for (const root of roots) {
|
|
101
|
+
let entry = table.get(root);
|
|
102
|
+
if (!entry) {
|
|
103
|
+
entry = { kinds: /* @__PURE__ */ new Set(), keywords: /* @__PURE__ */ new Set() };
|
|
104
|
+
table.set(root, entry);
|
|
105
|
+
}
|
|
106
|
+
for (const kind of spec.kinds) entry.kinds.add(kind);
|
|
107
|
+
for (const kw of spec.keywords ?? []) entry.keywords.add(kw);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const out = /* @__PURE__ */ new Map();
|
|
111
|
+
for (const [root, entry] of table) {
|
|
112
|
+
out.set(root, {
|
|
113
|
+
kinds: Object.freeze([...entry.kinds]),
|
|
114
|
+
keywords: entry.keywords.size > 0 ? Object.freeze([...entry.keywords]) : void 0
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
var UTILITY_VALUE_SPACES = buildValueSpaces();
|
|
120
|
+
function candidateValues(kind, theme) {
|
|
121
|
+
switch (kind) {
|
|
122
|
+
case "color": {
|
|
123
|
+
const out = [];
|
|
124
|
+
for (const name of Object.keys(theme.colors)) {
|
|
125
|
+
for (const stop of COLOR_STOPS) out.push(`${name}-${stop}`);
|
|
126
|
+
}
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
case "special-color":
|
|
130
|
+
return Object.keys(SPECIAL_COLORS);
|
|
131
|
+
case "spacing":
|
|
132
|
+
return [...SPACING_SAMPLES];
|
|
133
|
+
case "fraction":
|
|
134
|
+
return [...FRACTION_SAMPLES];
|
|
135
|
+
case "text-size":
|
|
136
|
+
return Object.keys(theme.text);
|
|
137
|
+
case "fluid-text-size":
|
|
138
|
+
return Object.keys(theme.text).map((size) => `fluid-${size}`);
|
|
139
|
+
case "font-slot":
|
|
140
|
+
return [.../* @__PURE__ */ new Set([...BUILTIN_FONT_SLOTS, ...theme.fonts.map((slot) => slot.slot)])];
|
|
141
|
+
case "weight":
|
|
142
|
+
return Object.keys(theme.weights);
|
|
143
|
+
case "rounded":
|
|
144
|
+
return Object.keys(theme.rounded);
|
|
145
|
+
case "rounded-side": {
|
|
146
|
+
const tokens = Object.keys(theme.rounded);
|
|
147
|
+
const out = [];
|
|
148
|
+
for (const side of ROUNDED_SIDES) {
|
|
149
|
+
out.push(side);
|
|
150
|
+
for (const token of tokens) out.push(`${side}-${token}`);
|
|
151
|
+
}
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
case "shadow":
|
|
155
|
+
return Object.keys(theme.shadows);
|
|
156
|
+
case "z":
|
|
157
|
+
return Object.keys(theme.z);
|
|
158
|
+
case "ease":
|
|
159
|
+
return Object.keys(theme.easing);
|
|
160
|
+
case "blur":
|
|
161
|
+
return Object.keys(theme.blur);
|
|
162
|
+
case "animation":
|
|
163
|
+
return Object.keys(theme.animations);
|
|
164
|
+
case "leading":
|
|
165
|
+
return Object.keys(theme.leading);
|
|
166
|
+
case "tracking":
|
|
167
|
+
return Object.keys(theme.tracking);
|
|
168
|
+
case "opacity":
|
|
169
|
+
return Object.keys(theme.opacity);
|
|
170
|
+
case "duration":
|
|
171
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(theme.duration), ...DURATION_SAMPLES])];
|
|
172
|
+
case "breakpoint":
|
|
173
|
+
return Object.keys(theme.breakpoints);
|
|
174
|
+
case "int":
|
|
175
|
+
return [...INT_SAMPLES];
|
|
176
|
+
case "percent":
|
|
177
|
+
return [...PERCENT_SAMPLES];
|
|
178
|
+
case "keywords":
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function enumerateClassNames(theme) {
|
|
183
|
+
const seen = /* @__PURE__ */ new Set();
|
|
184
|
+
const classes = [];
|
|
185
|
+
const templates = [];
|
|
186
|
+
const probeWarnings = [];
|
|
187
|
+
const resolves = (name) => resolveUtilityDeclarations(parseUtility(name), theme, probeWarnings) !== null;
|
|
188
|
+
const emit = (name, kind, root) => {
|
|
189
|
+
if (seen.has(name)) return;
|
|
190
|
+
if (!resolves(name)) return;
|
|
191
|
+
seen.add(name);
|
|
192
|
+
classes.push({ name, kind, root });
|
|
193
|
+
};
|
|
194
|
+
for (const name of STATIC_UTILITIES) emit(name, "static", null);
|
|
195
|
+
for (const names of [
|
|
196
|
+
ANIMATION_STATIC_NAMES,
|
|
197
|
+
BORDER_STATIC_NAMES,
|
|
198
|
+
BACKGROUND_STATIC_NAMES,
|
|
199
|
+
EFFECTS_STATIC_NAMES,
|
|
200
|
+
LAYOUT_STATIC_NAMES,
|
|
201
|
+
SVG_STATIC_NAMES,
|
|
202
|
+
TYPOGRAPHY_STATIC_NAMES
|
|
203
|
+
]) {
|
|
204
|
+
for (const name of names) emit(name, "static", null);
|
|
205
|
+
}
|
|
206
|
+
for (const custom of theme.customUtilities) {
|
|
207
|
+
if (custom.functional) {
|
|
208
|
+
templates.push({ root: custom.name, kind: "custom", example: `${custom.name}-value` });
|
|
209
|
+
} else {
|
|
210
|
+
emit(custom.name, "custom", null);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (const root of PREFIX_DISPATCH.keys()) {
|
|
214
|
+
const spec = UTILITY_VALUE_SPACES.get(root);
|
|
215
|
+
if (!spec) continue;
|
|
216
|
+
let spacingHit = false;
|
|
217
|
+
let intHit = false;
|
|
218
|
+
for (const kind of spec.kinds) {
|
|
219
|
+
for (const value of candidateValues(kind, theme)) {
|
|
220
|
+
const name = `${root}-${value}`;
|
|
221
|
+
if (seen.has(name)) continue;
|
|
222
|
+
if (!resolves(name)) continue;
|
|
223
|
+
seen.add(name);
|
|
224
|
+
classes.push({ name, kind, root });
|
|
225
|
+
if (kind === "spacing") spacingHit = true;
|
|
226
|
+
if (kind === "int") intHit = true;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
for (const keyword of spec.keywords ?? []) {
|
|
230
|
+
emit(`${root}-${keyword}`, "keywords", root);
|
|
231
|
+
}
|
|
232
|
+
if (spacingHit) templates.push({ root, kind: "spacing", example: `${root}-4` });
|
|
233
|
+
else if (intHit) templates.push({ root, kind: "number", example: `${root}-2` });
|
|
234
|
+
}
|
|
235
|
+
classes.sort((a, b) => codepointCompare(a.name, b.name));
|
|
236
|
+
templates.sort((a, b) => codepointCompare(a.root, b.root));
|
|
237
|
+
return { classes, templates };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export {
|
|
241
|
+
CSS_ENTRY_CANDIDATES,
|
|
242
|
+
UTILITY_VALUE_SPACES,
|
|
243
|
+
enumerateClassNames
|
|
244
|
+
};
|