rainbowindex 0.6.0 → 0.7.0
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 +543 -0
- package/LICENSE +16 -17
- package/NOTICE.md +106 -0
- package/README.md +219 -65
- package/dist/browser.d.ts +4 -2
- package/dist/browser.mjs +12 -4
- package/dist/chunk-2T7V5XLK.mjs +912 -0
- package/dist/chunk-6OORICWF.mjs +16 -0
- package/dist/{chunk-KSNYSR3C.mjs → chunk-FJOZJIKB.mjs} +2499 -329
- package/dist/chunk-L56IRO7A.mjs +491 -0
- package/dist/chunk-PZDVDEZJ.mjs +196 -0
- package/dist/{chunk-3LWJTLOJ.mjs → chunk-RC6DDE4L.mjs} +23 -15
- package/dist/chunk-TQJYVQPE.mjs +217 -0
- package/dist/chunk-W756NVYI.mjs +33 -0
- package/dist/chunk-WBESS2ZD.mjs +598 -0
- package/dist/{chunk-3HRMFZGE.mjs → chunk-X66Z2YHT.mjs} +2 -1
- package/dist/{chunk-6U4IOFOS.mjs → chunk-XQGSG2HK.mjs} +199 -555
- package/dist/cli.mjs +1077 -123
- package/dist/{index-DSgpB6bS.d.ts → context-DcBtnnan.d.ts} +47 -103
- package/dist/editor.d.ts +71 -433
- package/dist/editor.mjs +51 -368
- package/dist/eslint.d.ts +16 -0
- package/dist/eslint.mjs +32 -0
- package/dist/{index-4Kyaq3IZ.d.ts → imports-C9esHd5Q.d.ts} +78 -84
- package/dist/index-CNqdL5U0.d.ts +56 -0
- package/dist/index-Czx-EUwh.d.ts +138 -0
- package/dist/index-DW8YSxTz.d.ts +104 -0
- package/dist/index.d.ts +46 -5
- package/dist/index.mjs +33 -9
- package/dist/oxlint.d.ts +21 -3
- package/dist/oxlint.mjs +19 -1
- package/dist/recipe.d.ts +111 -0
- package/dist/recipe.mjs +71 -0
- package/dist/safelist-CH3_PywB.d.ts +43 -0
- package/dist/session-CMaskdB7.d.ts +543 -0
- package/dist/tailwind.css +644 -0
- package/dist/theme-CIZiGlce.d.ts +115 -0
- package/dist/vite.d.ts +10 -1
- package/dist/vite.mjs +266 -118
- package/package.json +27 -5
- package/dist/chunk-WK6S4HTC.mjs +0 -1921
- package/dist/chunk-ZR7XJMUN.mjs +0 -251
- package/dist/safelist-CGCtF-Fr.d.ts +0 -96
package/dist/chunk-ZR7XJMUN.mjs
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
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-KSNYSR3C.mjs";
|
|
19
|
-
import {
|
|
20
|
-
SPECIAL_COLORS
|
|
21
|
-
} from "./chunk-6U4IOFOS.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 INT_RE = /^\d+$/;
|
|
74
|
-
var WEIGHT_STEPS = Object.freeze(["100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
75
|
-
var PERCENT_SAMPLES = Object.freeze([
|
|
76
|
-
"0",
|
|
77
|
-
"5",
|
|
78
|
-
"10",
|
|
79
|
-
"15",
|
|
80
|
-
"20",
|
|
81
|
-
"25",
|
|
82
|
-
"30",
|
|
83
|
-
"40",
|
|
84
|
-
"50",
|
|
85
|
-
"60",
|
|
86
|
-
"70",
|
|
87
|
-
"75",
|
|
88
|
-
"80",
|
|
89
|
-
"90",
|
|
90
|
-
"95",
|
|
91
|
-
"100"
|
|
92
|
-
]);
|
|
93
|
-
var BUILTIN_FONT_SLOTS = Object.freeze(["sans", "serif", "mono"]);
|
|
94
|
-
var DURATION_SAMPLES = Object.freeze(["75", "100", "150", "200", "300", "500", "700", "1000"]);
|
|
95
|
-
var ROUNDED_SIDES = Object.freeze([
|
|
96
|
-
...ROUNDED_SIDE_NAMES,
|
|
97
|
-
...ROUNDED_CORNER_NAMES
|
|
98
|
-
]);
|
|
99
|
-
var RADIUS_SAMPLES = Object.freeze([...SPACING_SAMPLES, "none", "full"]);
|
|
100
|
-
function buildValueSpaces() {
|
|
101
|
-
const table = /* @__PURE__ */ new Map();
|
|
102
|
-
for (const { roots, spec } of ROOT_GROUPS) {
|
|
103
|
-
for (const root of roots) {
|
|
104
|
-
let entry = table.get(root);
|
|
105
|
-
if (!entry) {
|
|
106
|
-
entry = { kinds: /* @__PURE__ */ new Set(), keywords: /* @__PURE__ */ new Set() };
|
|
107
|
-
table.set(root, entry);
|
|
108
|
-
}
|
|
109
|
-
for (const kind of spec.kinds) entry.kinds.add(kind);
|
|
110
|
-
for (const kw of spec.keywords ?? []) entry.keywords.add(kw);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
const out = /* @__PURE__ */ new Map();
|
|
114
|
-
for (const [root, entry] of table) {
|
|
115
|
-
out.set(root, {
|
|
116
|
-
kinds: Object.freeze([...entry.kinds]),
|
|
117
|
-
keywords: entry.keywords.size > 0 ? Object.freeze([...entry.keywords]) : void 0
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
return out;
|
|
121
|
-
}
|
|
122
|
-
var UTILITY_VALUE_SPACES = buildValueSpaces();
|
|
123
|
-
function candidateValues(kind, theme) {
|
|
124
|
-
switch (kind) {
|
|
125
|
-
case "color": {
|
|
126
|
-
const out = [];
|
|
127
|
-
for (const name of Object.keys(theme.colors)) {
|
|
128
|
-
for (const stop of COLOR_STOPS) out.push(`${name}-${stop}`);
|
|
129
|
-
}
|
|
130
|
-
return out;
|
|
131
|
-
}
|
|
132
|
-
case "special-color":
|
|
133
|
-
return Object.keys(SPECIAL_COLORS);
|
|
134
|
-
case "spacing":
|
|
135
|
-
return [...SPACING_SAMPLES];
|
|
136
|
-
case "fraction":
|
|
137
|
-
return [...FRACTION_SAMPLES];
|
|
138
|
-
case "text-size":
|
|
139
|
-
return Object.keys(theme.text);
|
|
140
|
-
case "fluid-text-size":
|
|
141
|
-
return Object.keys(theme.text).map((size) => `fluid-${size}`);
|
|
142
|
-
case "fluid-range":
|
|
143
|
-
return Object.keys(theme.fluidRanges);
|
|
144
|
-
case "font-slot":
|
|
145
|
-
return [.../* @__PURE__ */ new Set([...BUILTIN_FONT_SLOTS, ...theme.fonts.map((slot) => slot.slot)])];
|
|
146
|
-
case "weight":
|
|
147
|
-
return [...Object.keys(theme.weights), ...WEIGHT_STEPS];
|
|
148
|
-
// Named @rounded radii plus the spacing multiples, the way @weight pairs
|
|
149
|
-
// its tokens with the numeric steps. Without the names, `rounded-roof`
|
|
150
|
-
// compiles but is offered by neither completions nor generated types.
|
|
151
|
-
case "rounded":
|
|
152
|
-
return [...Object.keys(theme.radii), ...RADIUS_SAMPLES];
|
|
153
|
-
case "rounded-side": {
|
|
154
|
-
const out = [];
|
|
155
|
-
const sizes = [...Object.keys(theme.radii), ...RADIUS_SAMPLES];
|
|
156
|
-
for (const side of ROUNDED_SIDES) {
|
|
157
|
-
for (const size of sizes) out.push(`${side}-${size}`);
|
|
158
|
-
}
|
|
159
|
-
return out;
|
|
160
|
-
}
|
|
161
|
-
case "shadow":
|
|
162
|
-
return Object.keys(theme.shadows);
|
|
163
|
-
case "z":
|
|
164
|
-
return Object.keys(theme.z);
|
|
165
|
-
case "ease":
|
|
166
|
-
return Object.keys(theme.easing);
|
|
167
|
-
case "blur":
|
|
168
|
-
return Object.keys(theme.blur);
|
|
169
|
-
case "animation":
|
|
170
|
-
return Object.keys(theme.animations);
|
|
171
|
-
case "leading":
|
|
172
|
-
return Object.keys(theme.leading);
|
|
173
|
-
case "tracking":
|
|
174
|
-
return Object.keys(theme.tracking);
|
|
175
|
-
case "opacity":
|
|
176
|
-
return Object.keys(theme.opacity);
|
|
177
|
-
case "duration":
|
|
178
|
-
return [.../* @__PURE__ */ new Set([...Object.keys(theme.duration), ...DURATION_SAMPLES])];
|
|
179
|
-
case "breakpoint":
|
|
180
|
-
return Object.keys(theme.breakpoints);
|
|
181
|
-
case "int":
|
|
182
|
-
return [...INT_SAMPLES];
|
|
183
|
-
case "percent":
|
|
184
|
-
return [...PERCENT_SAMPLES];
|
|
185
|
-
case "keywords":
|
|
186
|
-
return [];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
function enumerateClassNames(theme) {
|
|
190
|
-
const seen = /* @__PURE__ */ new Set();
|
|
191
|
-
const classes = [];
|
|
192
|
-
const templates = [];
|
|
193
|
-
const probeWarnings = [];
|
|
194
|
-
const resolves = (name) => resolveUtilityDeclarations(parseUtility(name), theme, probeWarnings) !== null;
|
|
195
|
-
const emit = (name, kind, root) => {
|
|
196
|
-
if (seen.has(name)) return;
|
|
197
|
-
if (!resolves(name)) return;
|
|
198
|
-
seen.add(name);
|
|
199
|
-
classes.push({ name, kind, root });
|
|
200
|
-
};
|
|
201
|
-
for (const name of STATIC_UTILITIES) emit(name, "static", null);
|
|
202
|
-
for (const names of [
|
|
203
|
-
ANIMATION_STATIC_NAMES,
|
|
204
|
-
BORDER_STATIC_NAMES,
|
|
205
|
-
BACKGROUND_STATIC_NAMES,
|
|
206
|
-
EFFECTS_STATIC_NAMES,
|
|
207
|
-
LAYOUT_STATIC_NAMES,
|
|
208
|
-
SVG_STATIC_NAMES,
|
|
209
|
-
TYPOGRAPHY_STATIC_NAMES
|
|
210
|
-
]) {
|
|
211
|
-
for (const name of names) emit(name, "static", null);
|
|
212
|
-
}
|
|
213
|
-
for (const custom of theme.customUtilities) {
|
|
214
|
-
if (custom.functional) {
|
|
215
|
-
templates.push({ root: custom.name, kind: "custom", example: `${custom.name}-value` });
|
|
216
|
-
} else {
|
|
217
|
-
emit(custom.name, "custom", null);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
for (const root of PREFIX_DISPATCH.keys()) {
|
|
221
|
-
const spec = UTILITY_VALUE_SPACES.get(root);
|
|
222
|
-
if (!spec) continue;
|
|
223
|
-
let spacingHit = false;
|
|
224
|
-
let intHit = false;
|
|
225
|
-
for (const kind of spec.kinds) {
|
|
226
|
-
for (const value of candidateValues(kind, theme)) {
|
|
227
|
-
const name = `${root}-${value}`;
|
|
228
|
-
if (seen.has(name)) continue;
|
|
229
|
-
if (!resolves(name)) continue;
|
|
230
|
-
seen.add(name);
|
|
231
|
-
classes.push({ name, kind, root });
|
|
232
|
-
if (kind === "spacing") spacingHit = true;
|
|
233
|
-
if (kind === "int" || kind === "weight" && INT_RE.test(value)) intHit = true;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
for (const keyword of spec.keywords ?? []) {
|
|
237
|
-
emit(`${root}-${keyword}`, "keywords", root);
|
|
238
|
-
}
|
|
239
|
-
if (spacingHit) templates.push({ root, kind: "spacing", example: `${root}-4` });
|
|
240
|
-
else if (intHit) templates.push({ root, kind: "number", example: `${root}-2` });
|
|
241
|
-
}
|
|
242
|
-
classes.sort((a, b) => codepointCompare(a.name, b.name));
|
|
243
|
-
templates.sort((a, b) => codepointCompare(a.root, b.root));
|
|
244
|
-
return { classes, templates };
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export {
|
|
248
|
-
CSS_ENTRY_CANDIDATES,
|
|
249
|
-
UTILITY_VALUE_SPACES,
|
|
250
|
-
enumerateClassNames
|
|
251
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { b as CompilationSnapshot } from './index-DSgpB6bS.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ri() — class merge function.
|
|
5
|
-
* Replaces both tailwind-merge and clsx.
|
|
6
|
-
*
|
|
7
|
-
* Re-exported from the package's main and browser entries as `ri()`.
|
|
8
|
-
* Right-to-left scan: rightmost class wins when two classes set the same CSS property.
|
|
9
|
-
*
|
|
10
|
-
* This file is the pure merge runtime. Its siblings hold the other merge
|
|
11
|
-
* concepts: props.ts (claim data), resolve.ts (dual-mode claim resolution),
|
|
12
|
-
* context.ts (compilation-context lifecycle + published state), analyze.ts
|
|
13
|
-
* (editor-only merge diagnostics).
|
|
14
|
-
*
|
|
15
|
-
* ## Concurrency
|
|
16
|
-
*
|
|
17
|
-
* The default `ri()` export uses module-level state published by
|
|
18
|
-
* `finalizeCompilationContext()`. This is safe for single-compilation
|
|
19
|
-
* environments (typical browser usage, single Vite build, PostCSS).
|
|
20
|
-
*
|
|
21
|
-
* In multi-tenant / SSR / concurrent-compilation environments, use
|
|
22
|
-
* `createRi(snapshot)` instead — it captures a frozen snapshot of the
|
|
23
|
-
* compilation state and uses its own independent cache:
|
|
24
|
-
*
|
|
25
|
-
* const snapshot = finalizeCompilationContext(ctx);
|
|
26
|
-
* const ri = createRi(snapshot);
|
|
27
|
-
*/
|
|
28
|
-
type ClassInput = string | false | null | undefined | ClassInput[];
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Merge class names with conflict resolution (replaces both tailwind-merge and clsx).
|
|
32
|
-
* Rightmost class wins when two classes set the same CSS property.
|
|
33
|
-
* Falsy values are filtered.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ri('p-2 bg-red-500', 'p-4') // → 'bg-red-500 p-4'
|
|
37
|
-
* ri('px-2 py-1', 'p-4') // → 'p-4' (shorthand wins)
|
|
38
|
-
* ri('flex', isActive && 'bg-blue-500') // → 'flex bg-blue-500'
|
|
39
|
-
* ri('text-lg text-red-500') // → 'text-lg text-red-500' (different properties)
|
|
40
|
-
*/
|
|
41
|
-
declare function ri(...inputs: ClassInput[]): string;
|
|
42
|
-
/**
|
|
43
|
-
* Create an isolated ri() instance bound to a specific compilation snapshot.
|
|
44
|
-
* Use this in SSR or multi-compilation environments where the global ri()
|
|
45
|
-
* would be corrupted by concurrent compilations.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* const snapshot = finalizeCompilationContext(ctx);
|
|
49
|
-
* const ri = createRi(snapshot);
|
|
50
|
-
* ri('p-2 bg-red-500', 'p-4') // → 'bg-red-500 p-4'
|
|
51
|
-
*/
|
|
52
|
-
declare function createRi(snapshot?: CompilationSnapshot): (...inputs: ClassInput[]) => string;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* `safelist()` — declare utility classes that must be emitted regardless of
|
|
56
|
-
* whether the consumer's source files reference them directly.
|
|
57
|
-
*
|
|
58
|
-
* At runtime this is a plain identity-join: pass any number of strings (and
|
|
59
|
-
* falsy values, which are filtered) and receive a single space-joined string
|
|
60
|
-
* suitable for `className`. The function performs no global registration, has
|
|
61
|
-
* no side effects, and is tree-shake-safe.
|
|
62
|
-
*
|
|
63
|
-
* The build-time meaning comes from the scanner: when the source-file
|
|
64
|
-
* extractor encounters a `safelist(...)` call, it extracts every literal
|
|
65
|
-
* string argument as a class declaration — so the classes get emitted in the
|
|
66
|
-
* final CSS even though the consumer's source never names them literally.
|
|
67
|
-
*
|
|
68
|
-
* Primary use case is component libraries that ship classNames inside their
|
|
69
|
-
* bundled code (e.g. a curated icon set whose strokes are described by
|
|
70
|
-
* utility classes). The library wraps its declarations in `safelist(...)`,
|
|
71
|
-
* the consumer's setup points the scanner at the library's `dist/`, and the
|
|
72
|
-
* classes flow through unchanged. The Vite plugin auto-discovers libraries
|
|
73
|
-
* that opt in via a `rainbowindex.safelistSources` field in their
|
|
74
|
-
* `package.json`, so consumers typically don't have to add `@source` lines
|
|
75
|
-
* by hand.
|
|
76
|
-
*
|
|
77
|
-
* const ICON_BASE = safelist("stroke-cap-round", "stroke-join-round");
|
|
78
|
-
* const SidebarLeft = defineIcon({
|
|
79
|
-
* primitives: SIDEBAR,
|
|
80
|
-
* className: safelist(ICON_BASE, "-scale-x-100"),
|
|
81
|
-
* });
|
|
82
|
-
*
|
|
83
|
-
* Scanner contract:
|
|
84
|
-
* - Only STATIC string literals at the call site are extracted. Values
|
|
85
|
-
* passed through variables (`safelist(ICON_BASE, ...)`) won't be re-read
|
|
86
|
-
* at the outer call site, but the original `safelist("stroke-cap-round",
|
|
87
|
-
* ...)` that produced `ICON_BASE` is itself extracted, so the classes are
|
|
88
|
-
* still covered.
|
|
89
|
-
* - Template literals with no `${…}` interpolation are extracted; templates
|
|
90
|
-
* with interpolation are skipped.
|
|
91
|
-
* - Falsy arguments are dropped at runtime so conditional fragments compose
|
|
92
|
-
* naturally: `safelist("flex", side === "left" && "flex-row-reverse")`.
|
|
93
|
-
*/
|
|
94
|
-
declare function safelist(...parts: ReadonlyArray<string | false | null | undefined>): string;
|
|
95
|
-
|
|
96
|
-
export { createRi as c, ri as r, safelist as s };
|