rainbowindex 0.5.1 → 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.
Files changed (43) hide show
  1. package/CHANGELOG.md +876 -0
  2. package/LICENSE +16 -17
  3. package/NOTICE.md +106 -0
  4. package/README.md +225 -69
  5. package/dist/browser.d.ts +4 -2
  6. package/dist/browser.mjs +12 -6
  7. package/dist/chunk-2T7V5XLK.mjs +912 -0
  8. package/dist/chunk-6OORICWF.mjs +16 -0
  9. package/dist/{chunk-PDORZSQX.mjs → chunk-FJOZJIKB.mjs} +7814 -5174
  10. package/dist/chunk-L56IRO7A.mjs +491 -0
  11. package/dist/chunk-PZDVDEZJ.mjs +196 -0
  12. package/dist/{chunk-4CTJLMYM.mjs → chunk-RC6DDE4L.mjs} +37 -23
  13. package/dist/chunk-TQJYVQPE.mjs +217 -0
  14. package/dist/chunk-W756NVYI.mjs +33 -0
  15. package/dist/chunk-WBESS2ZD.mjs +598 -0
  16. package/dist/{chunk-3HRMFZGE.mjs → chunk-X66Z2YHT.mjs} +2 -1
  17. package/dist/{chunk-4UKFK2GE.mjs → chunk-XQGSG2HK.mjs} +213 -756
  18. package/dist/cli.mjs +1101 -125
  19. package/dist/{context-B9yhJxd5.d.ts → context-DcBtnnan.d.ts} +55 -108
  20. package/dist/editor.d.ts +82 -421
  21. package/dist/editor.mjs +68 -363
  22. package/dist/eslint.d.ts +16 -0
  23. package/dist/eslint.mjs +32 -0
  24. package/dist/{index-Dx-NpFFx.d.ts → imports-C9esHd5Q.d.ts} +98 -81
  25. package/dist/index-CNqdL5U0.d.ts +56 -0
  26. package/dist/index-Czx-EUwh.d.ts +138 -0
  27. package/dist/index-DW8YSxTz.d.ts +104 -0
  28. package/dist/index.d.ts +49 -5
  29. package/dist/index.mjs +40 -13
  30. package/dist/oxlint.d.ts +21 -3
  31. package/dist/oxlint.mjs +19 -1
  32. package/dist/recipe.d.ts +111 -0
  33. package/dist/recipe.mjs +71 -0
  34. package/dist/safelist-CH3_PywB.d.ts +43 -0
  35. package/dist/session-CMaskdB7.d.ts +543 -0
  36. package/dist/tailwind.css +644 -0
  37. package/dist/theme-CIZiGlce.d.ts +115 -0
  38. package/dist/vite.d.ts +10 -1
  39. package/dist/vite.mjs +273 -113
  40. package/package.json +27 -5
  41. package/dist/chunk-F4VCBISU.mjs +0 -1866
  42. package/dist/chunk-RU4756NG.mjs +0 -243
  43. package/dist/safelist-DAkKuxCk.d.ts +0 -96
@@ -1,243 +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-PDORZSQX.mjs";
19
- import {
20
- SPECIAL_COLORS
21
- } from "./chunk-4UKFK2GE.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
- var RADIUS_SAMPLES = Object.freeze([...SPACING_SAMPLES, "none", "full"]);
98
- function buildValueSpaces() {
99
- const table = /* @__PURE__ */ new Map();
100
- for (const { roots, spec } of ROOT_GROUPS) {
101
- for (const root of roots) {
102
- let entry = table.get(root);
103
- if (!entry) {
104
- entry = { kinds: /* @__PURE__ */ new Set(), keywords: /* @__PURE__ */ new Set() };
105
- table.set(root, entry);
106
- }
107
- for (const kind of spec.kinds) entry.kinds.add(kind);
108
- for (const kw of spec.keywords ?? []) entry.keywords.add(kw);
109
- }
110
- }
111
- const out = /* @__PURE__ */ new Map();
112
- for (const [root, entry] of table) {
113
- out.set(root, {
114
- kinds: Object.freeze([...entry.kinds]),
115
- keywords: entry.keywords.size > 0 ? Object.freeze([...entry.keywords]) : void 0
116
- });
117
- }
118
- return out;
119
- }
120
- var UTILITY_VALUE_SPACES = buildValueSpaces();
121
- function candidateValues(kind, theme) {
122
- switch (kind) {
123
- case "color": {
124
- const out = [];
125
- for (const name of Object.keys(theme.colors)) {
126
- for (const stop of COLOR_STOPS) out.push(`${name}-${stop}`);
127
- }
128
- return out;
129
- }
130
- case "special-color":
131
- return Object.keys(SPECIAL_COLORS);
132
- case "spacing":
133
- return [...SPACING_SAMPLES];
134
- case "fraction":
135
- return [...FRACTION_SAMPLES];
136
- case "text-size":
137
- return Object.keys(theme.text);
138
- case "fluid-text-size":
139
- return Object.keys(theme.text).map((size) => `fluid-${size}`);
140
- case "font-slot":
141
- return [.../* @__PURE__ */ new Set([...BUILTIN_FONT_SLOTS, ...theme.fonts.map((slot) => slot.slot)])];
142
- case "weight":
143
- return Object.keys(theme.weights);
144
- case "rounded":
145
- return [...RADIUS_SAMPLES];
146
- case "rounded-side": {
147
- const out = [];
148
- for (const side of ROUNDED_SIDES) {
149
- for (const size of RADIUS_SAMPLES) out.push(`${side}-${size}`);
150
- }
151
- return out;
152
- }
153
- case "shadow":
154
- return Object.keys(theme.shadows);
155
- case "z":
156
- return Object.keys(theme.z);
157
- case "ease":
158
- return Object.keys(theme.easing);
159
- case "blur":
160
- return Object.keys(theme.blur);
161
- case "animation":
162
- return Object.keys(theme.animations);
163
- case "leading":
164
- return Object.keys(theme.leading);
165
- case "tracking":
166
- return Object.keys(theme.tracking);
167
- case "opacity":
168
- return Object.keys(theme.opacity);
169
- case "duration":
170
- return [.../* @__PURE__ */ new Set([...Object.keys(theme.duration), ...DURATION_SAMPLES])];
171
- case "breakpoint":
172
- return Object.keys(theme.breakpoints);
173
- case "int":
174
- return [...INT_SAMPLES];
175
- case "percent":
176
- return [...PERCENT_SAMPLES];
177
- case "keywords":
178
- return [];
179
- }
180
- }
181
- function enumerateClassNames(theme) {
182
- const seen = /* @__PURE__ */ new Set();
183
- const classes = [];
184
- const templates = [];
185
- const probeWarnings = [];
186
- const resolves = (name) => resolveUtilityDeclarations(parseUtility(name), theme, probeWarnings) !== null;
187
- const emit = (name, kind, root) => {
188
- if (seen.has(name)) return;
189
- if (!resolves(name)) return;
190
- seen.add(name);
191
- classes.push({ name, kind, root });
192
- };
193
- for (const name of STATIC_UTILITIES) emit(name, "static", null);
194
- for (const names of [
195
- ANIMATION_STATIC_NAMES,
196
- BORDER_STATIC_NAMES,
197
- BACKGROUND_STATIC_NAMES,
198
- EFFECTS_STATIC_NAMES,
199
- LAYOUT_STATIC_NAMES,
200
- SVG_STATIC_NAMES,
201
- TYPOGRAPHY_STATIC_NAMES
202
- ]) {
203
- for (const name of names) emit(name, "static", null);
204
- }
205
- for (const custom of theme.customUtilities) {
206
- if (custom.functional) {
207
- templates.push({ root: custom.name, kind: "custom", example: `${custom.name}-value` });
208
- } else {
209
- emit(custom.name, "custom", null);
210
- }
211
- }
212
- for (const root of PREFIX_DISPATCH.keys()) {
213
- const spec = UTILITY_VALUE_SPACES.get(root);
214
- if (!spec) continue;
215
- let spacingHit = false;
216
- let intHit = false;
217
- for (const kind of spec.kinds) {
218
- for (const value of candidateValues(kind, theme)) {
219
- const name = `${root}-${value}`;
220
- if (seen.has(name)) continue;
221
- if (!resolves(name)) continue;
222
- seen.add(name);
223
- classes.push({ name, kind, root });
224
- if (kind === "spacing") spacingHit = true;
225
- if (kind === "int") intHit = true;
226
- }
227
- }
228
- for (const keyword of spec.keywords ?? []) {
229
- emit(`${root}-${keyword}`, "keywords", root);
230
- }
231
- if (spacingHit) templates.push({ root, kind: "spacing", example: `${root}-4` });
232
- else if (intHit) templates.push({ root, kind: "number", example: `${root}-2` });
233
- }
234
- classes.sort((a, b) => codepointCompare(a.name, b.name));
235
- templates.sort((a, b) => codepointCompare(a.root, b.root));
236
- return { classes, templates };
237
- }
238
-
239
- export {
240
- CSS_ENTRY_CANDIDATES,
241
- UTILITY_VALUE_SPACES,
242
- enumerateClassNames
243
- };
@@ -1,96 +0,0 @@
1
- import { b as CompilationSnapshot } from './context-B9yhJxd5.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 };