rainbowindex 0.2.2 → 0.4.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 +70 -14
- package/LICENSE +1 -1
- package/README.md +23 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.mjs +1 -1
- package/dist/chunk-3HRMFZGE.mjs +19 -0
- package/dist/{chunk-FHATRQMN.mjs → chunk-4SVFFDS2.mjs} +495 -461
- package/dist/{chunk-SOMDX7V6.mjs → chunk-5Y7EXXLS.mjs} +320 -417
- package/dist/{chunk-W6XIBM4M.mjs → chunk-6DAHUFNU.mjs} +5278 -4928
- package/dist/{chunk-CUUW2K35.mjs → chunk-TLR6RP5L.mjs} +41 -120
- package/dist/chunk-YLB6FGIG.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 +106 -28
- package/dist/editor.mjs +44 -12
- package/dist/{index-DK6APAGD.d.ts → index-BB2HoeMj.d.ts} +1 -1
- 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 +48 -27
- package/package.json +1 -1
- package/dist/chunk-KYDEHYIE.mjs +0 -691
- package/dist/safelist-CH3_PywB.d.ts +0 -43
|
@@ -105,27 +105,19 @@ type CornerShape = CornerShapeKeyword | {
|
|
|
105
105
|
declare const defaultTheme: Theme;
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
|
-
*
|
|
109
|
-
* Replaces both tailwind-merge and clsx.
|
|
108
|
+
* Compilation-context lifecycle — all mutable state behind ri().
|
|
110
109
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
110
|
+
* The engine creates a CompilationContext via createCompilationContext(),
|
|
111
|
+
* mutates it during compilation (register* functions), then finalizes it so
|
|
112
|
+
* ri() can read the published snapshot without interference from concurrent
|
|
113
|
+
* compilations. Split from merge/index.ts so the merge algorithm stays pure
|
|
114
|
+
* runtime and every piece of mutable state lives in one file.
|
|
113
115
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* environments (typical browser usage, single Vite build, PostCSS).
|
|
119
|
-
*
|
|
120
|
-
* In multi-tenant / SSR / concurrent-compilation environments, use
|
|
121
|
-
* `createRi(snapshot)` instead — it captures a frozen snapshot of the
|
|
122
|
-
* compilation state and uses its own independent cache:
|
|
123
|
-
*
|
|
124
|
-
* const snapshot = finalizeCompilationContext(ctx);
|
|
125
|
-
* const ri = createRi(snapshot);
|
|
116
|
+
* The default ri() LRU cache lives here rather than next to the merge loop
|
|
117
|
+
* because finalizeCompilationContext() must clear it: conflict resolution
|
|
118
|
+
* rules may change between compilations, and stale entries from a previous
|
|
119
|
+
* compilation (with different custom utilities) must never be returned.
|
|
126
120
|
*/
|
|
127
|
-
type ClassInput = string | false | null | undefined | ClassInput[];
|
|
128
|
-
declare const DEFAULT_TEXT_SIZES: readonly ["xs", "sm", "base", "lg", "xl", "2xl", "3xl", "4xl", "5xl"];
|
|
129
121
|
interface CompilationContext {
|
|
130
122
|
customStaticProps: Record<string, string[]>;
|
|
131
123
|
textSizes: Set<string>;
|
|
@@ -142,57 +134,6 @@ interface CompilationSnapshot {
|
|
|
142
134
|
readonly fontFamilies: ReadonlySet<string>;
|
|
143
135
|
readonly colorNames: ReadonlySet<string>;
|
|
144
136
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Merge class names with conflict resolution (replaces both tailwind-merge and clsx).
|
|
147
|
-
* Rightmost class wins when two classes set the same CSS property.
|
|
148
|
-
* Falsy values are filtered.
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ri('p-2 bg-red-500', 'p-4') // → 'bg-red-500 p-4'
|
|
152
|
-
* ri('px-2 py-1', 'p-4') // → 'p-4' (shorthand wins)
|
|
153
|
-
* ri('flex', isActive && 'bg-blue-500') // → 'flex bg-blue-500'
|
|
154
|
-
* ri('text-lg text-red-500') // → 'text-lg text-red-500' (different properties)
|
|
155
|
-
*/
|
|
156
|
-
declare function ri(...inputs: ClassInput[]): string;
|
|
157
|
-
/**
|
|
158
|
-
* Create an isolated ri() instance bound to a specific compilation snapshot.
|
|
159
|
-
* Use this in SSR or multi-compilation environments where the global ri()
|
|
160
|
-
* would be corrupted by concurrent compilations.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* const snapshot = finalizeCompilationContext(ctx);
|
|
164
|
-
* const ri = createRi(snapshot);
|
|
165
|
-
* ri('p-2 bg-red-500', 'p-4') // → 'bg-red-500 p-4'
|
|
166
|
-
*/
|
|
167
|
-
declare function createRi(snapshot?: CompilationSnapshot): (...inputs: ClassInput[]) => string;
|
|
168
|
-
interface MergeDrop {
|
|
169
|
-
index: number;
|
|
170
|
-
className: string;
|
|
171
|
-
/** Ascending indices of the surviving classes that together claimed every
|
|
172
|
-
* CSS property this class sets (px-4 + py-4 jointly dominate p-2). */
|
|
173
|
-
overriddenBy: number[];
|
|
174
|
-
}
|
|
175
|
-
interface MergeAnalysis {
|
|
176
|
-
/** The merged output — identical to ri()'s result for this token list. */
|
|
177
|
-
output: string;
|
|
178
|
-
/** Indices of surviving classes, ascending. */
|
|
179
|
-
kept: number[];
|
|
180
|
-
/** Dropped classes with attribution, ascending by index. */
|
|
181
|
-
dropped: MergeDrop[];
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Explain ri()'s conflict resolution for a list of class tokens — which
|
|
185
|
-
* classes the right-most-wins scan drops, and which survivors claimed their
|
|
186
|
-
* properties. Powers "this class is overridden" editor diagnostics.
|
|
187
|
-
*
|
|
188
|
-
* Unlike ri(), the input is pre-tokenized: one class per element, no falsy
|
|
189
|
-
* filtering, no whitespace splitting — exactly the token list an editor
|
|
190
|
-
* extracts from one class attribute. `snapshot` binds custom utilities, text
|
|
191
|
-
* sizes, and color names the same way createRi(snapshot) does (editors build
|
|
192
|
-
* one with createThemeSnapshot()); without it, the module-level state of the
|
|
193
|
-
* most recent compile applies. Uncached — call sites own their memoization.
|
|
194
|
-
*/
|
|
195
|
-
declare function analyzeMerge(classes: readonly string[], snapshot?: CompilationSnapshot): MergeAnalysis;
|
|
196
137
|
/**
|
|
197
138
|
* Create a fresh compilation context.
|
|
198
139
|
* Called at the start of each compile() pass.
|
|
@@ -220,6 +161,10 @@ declare function registerCustomFontFamilies(ctx: CompilationContext, families: s
|
|
|
220
161
|
* match the shade pattern and need no registration.
|
|
221
162
|
*/
|
|
222
163
|
declare function registerColorNames(ctx: CompilationContext, names: string[]): void;
|
|
164
|
+
/**
|
|
165
|
+
* Snapshot compilation context into module-level state that ri() reads from.
|
|
166
|
+
* Called at the end of compile() to atomically publish the new state.
|
|
167
|
+
*/
|
|
223
168
|
declare function finalizeCompilationContext(ctx: CompilationContext): CompilationSnapshot;
|
|
224
169
|
|
|
225
|
-
export { type AnimationDefinition as A, type ColorDefinition as C,
|
|
170
|
+
export { type AnimationDefinition as A, type ColorDefinition as C, type DarkModeConfig as D, type FluidConfig as F, type TextSize as T, type CompilationContext as a, type CompilationSnapshot as b, type Theme as c, createCompilationContext as d, defaultTheme as e, finalizeCompilationContext as f, registerCustomFontFamilies as g, registerCustomTextSizes as h, registerCustomUtility as i, type CornerShape as j, registerColorNames as r };
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import { P as ParsedDirective, R as ResolvedTheme } from './index-
|
|
2
|
-
export { b as createThemeSnapshot } from './index-
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
1
|
+
import { P as ParsedDirective, R as ResolvedTheme } from './index-BB2HoeMj.js';
|
|
2
|
+
export { b as createThemeSnapshot } from './index-BB2HoeMj.js';
|
|
3
|
+
import { b as CompilationSnapshot, C as ColorDefinition } from './context-ruu2x_jR.js';
|
|
4
|
+
export { e as defaultTheme } from './context-ruu2x_jR.js';
|
|
5
5
|
|
|
6
|
-
/** Helper-call names whose string arguments are walked for class literals.
|
|
7
|
-
* Exported for editor tooling so completion-context detection can match the
|
|
8
|
-
* scanner's own behavior. */
|
|
9
|
-
declare const CLASS_HELPER_NAMES: readonly string[];
|
|
10
|
-
/** Variant-config helper names (`cva`/`tv`) whose config objects are walked. */
|
|
11
|
-
declare const VARIANT_HELPER_NAMES: readonly string[];
|
|
12
|
-
interface SourceExtractionInput {
|
|
13
|
-
path?: string;
|
|
14
|
-
content: string;
|
|
15
|
-
}
|
|
16
6
|
type CandidateOrigin = "attribute" | "helper" | "safelist" | "plain";
|
|
17
7
|
interface ClassCandidate {
|
|
18
8
|
/** The class string in expanded form — for variant-group members this
|
|
@@ -27,14 +17,35 @@ interface ClassCandidate {
|
|
|
27
17
|
origin: CandidateOrigin;
|
|
28
18
|
/** The call the class was found in, when origin is "helper"/"safelist". */
|
|
29
19
|
helperName?: string;
|
|
20
|
+
/** Identity of the innermost scanned helper/safelist call context:
|
|
21
|
+
* candidates from the same call share one id, distinct calls get distinct
|
|
22
|
+
* ids. A class helper nested inside another class helper's arguments is
|
|
23
|
+
* not scanned as its own call — its literals belong to the outer call —
|
|
24
|
+
* while a class helper inside a cva/tv config does get its own id. Ids
|
|
25
|
+
* are only comparable within one extraction's result. Absent for
|
|
26
|
+
* attribute/plain candidates. */
|
|
27
|
+
callId?: number;
|
|
30
28
|
/** For variant-group members: span of the group's variant prefix (`hover:`). */
|
|
31
29
|
groupPrefix?: {
|
|
32
30
|
start: number;
|
|
33
31
|
end: number;
|
|
34
32
|
};
|
|
35
33
|
}
|
|
36
|
-
|
|
34
|
+
|
|
35
|
+
/** Helper-call names whose string arguments are walked for class literals.
|
|
36
|
+
* Exported for editor tooling so completion-context detection can match the
|
|
37
|
+
* scanner's own behavior. */
|
|
38
|
+
declare const CLASS_HELPER_NAMES: readonly string[];
|
|
39
|
+
/** Variant-config helper names (`cva`/`tv`) whose config objects are walked. */
|
|
40
|
+
declare const VARIANT_HELPER_NAMES: readonly string[];
|
|
37
41
|
declare function extractClasses(source: string, warnings?: string[]): Set<string>;
|
|
42
|
+
|
|
43
|
+
declare function expandVariantGroups(input: string, warnings?: string[]): string;
|
|
44
|
+
|
|
45
|
+
interface SourceExtractionInput {
|
|
46
|
+
path?: string;
|
|
47
|
+
content: string;
|
|
48
|
+
}
|
|
38
49
|
declare function extractClassesFromSource(input: SourceExtractionInput, warnings?: string[]): Set<string>;
|
|
39
50
|
/**
|
|
40
51
|
* Position-aware variant of `extractClassesFromSource` for editor tooling.
|
|
@@ -177,6 +188,13 @@ interface ParsedUtility {
|
|
|
177
188
|
*/
|
|
178
189
|
declare function parseUtility(raw: string): ParsedUtility;
|
|
179
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Shared leaf helpers for the utility generators — result types, tiny
|
|
193
|
+
* constructors, and value-grammar helpers. Lives below both the generators
|
|
194
|
+
* and the dispatch index (which imports every generator) so that generators
|
|
195
|
+
* never import their own aggregator: generator ↔ index cycles would let
|
|
196
|
+
* modules observe partially initialized exports.
|
|
197
|
+
*/
|
|
180
198
|
interface CSSDeclaration {
|
|
181
199
|
property: string;
|
|
182
200
|
value: string;
|
|
@@ -268,6 +286,32 @@ declare function createClassInspector(theme: ResolvedTheme): ClassInspector;
|
|
|
268
286
|
*/
|
|
269
287
|
declare function findClosest(input: string, candidates: string[], maxDistance?: number): string | null;
|
|
270
288
|
|
|
289
|
+
/**
|
|
290
|
+
* The single registration table for built-in utility roots: each row binds a
|
|
291
|
+
* set of roots to the generators that resolve them (in probe order) AND to the
|
|
292
|
+
* value space editor enumeration tries for them. index.ts derives
|
|
293
|
+
* PREFIX_DISPATCH from the resolver columns; enumerate.ts derives
|
|
294
|
+
* UTILITY_VALUE_SPACES from the spec column — adding a root forces deciding
|
|
295
|
+
* both in one row, so the two can never drift.
|
|
296
|
+
*
|
|
297
|
+
* Value spaces are deliberately GENEROUS (which theme namespaces and keyword
|
|
298
|
+
* families to TRY per functional root): every enumeration candidate is probed
|
|
299
|
+
* through the real utility resolver, which stays the single authority — a
|
|
300
|
+
* spec can over-approximate freely and never emit something `validate()`
|
|
301
|
+
* would reject. `{ kinds: [] }` marks a statics-only root.
|
|
302
|
+
*
|
|
303
|
+
* Ordering is load-bearing twice over: row order fixes PREFIX_DISPATCH key
|
|
304
|
+
* insertion order (which drives cross-root enumeration dedup labels), and
|
|
305
|
+
* per-root resolver order fixes which generator wins a contested root.
|
|
306
|
+
*/
|
|
307
|
+
|
|
308
|
+
type ValueSpaceKind = "color" | "special-color" | "spacing" | "fraction" | "text-size" | "fluid-text-size" | "font-slot" | "weight" | "rounded" | "rounded-side" | "shadow" | "z" | "ease" | "blur" | "animation" | "leading" | "tracking" | "opacity" | "duration" | "breakpoint" | "int" | "percent" | "keywords";
|
|
309
|
+
interface ValueSpaceSpec {
|
|
310
|
+
kinds: readonly ValueSpaceKind[];
|
|
311
|
+
/** Extra value parts to try verbatim (for "keywords" and beyond). */
|
|
312
|
+
keywords?: readonly string[];
|
|
313
|
+
}
|
|
314
|
+
|
|
271
315
|
/**
|
|
272
316
|
* Class enumeration — the completion universe for editor tooling.
|
|
273
317
|
*
|
|
@@ -276,23 +320,19 @@ declare function findClosest(input: string, candidates: string[], maxDistance?:
|
|
|
276
320
|
* root), then every candidate is probed through the real utility resolver.
|
|
277
321
|
* The resolver is the single authority — an enumerated class is one that
|
|
278
322
|
* actually compiles, so the table can over-approximate freely and can never
|
|
279
|
-
* emit something `validate()` would reject. Coverage is
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
323
|
+
* emit something `validate()` would reject. Coverage is structural: the table
|
|
324
|
+
* derives from ROOT_GROUPS (roots.ts), where `spec` is a required field of
|
|
325
|
+
* every row — adding a root forces deciding its value space in the same row
|
|
326
|
+
* (an empty spec marks a statics-only root); the CI check in enumerate.test.ts
|
|
327
|
+
* stays on as a regression tripwire.
|
|
283
328
|
*
|
|
284
329
|
* Statics come from the merge conflict tables (STATIC_UTILITIES) plus each
|
|
285
330
|
* generator's own static-map keys — probed too, for the same guarantee.
|
|
286
331
|
*/
|
|
287
332
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
/** Extra value parts to try verbatim (for "keywords" and beyond). */
|
|
292
|
-
keywords?: readonly string[];
|
|
293
|
-
}
|
|
294
|
-
/** Root → value spaces to try. Coverage of every PREFIX_DISPATCH root is
|
|
295
|
-
* enforced by __tests__/core/enumerate.test.ts. */
|
|
333
|
+
/** Root → value spaces to try, derived from ROOT_GROUPS. Every
|
|
334
|
+
* PREFIX_DISPATCH root is present by construction — both maps are built
|
|
335
|
+
* from the same rows. */
|
|
296
336
|
declare const UTILITY_VALUE_SPACES: ReadonlyMap<string, ValueSpaceSpec>;
|
|
297
337
|
interface EnumeratedClass {
|
|
298
338
|
name: string;
|
|
@@ -324,6 +364,44 @@ interface ClassEnumeration {
|
|
|
324
364
|
*/
|
|
325
365
|
declare function enumerateClassNames(theme: ResolvedTheme): ClassEnumeration;
|
|
326
366
|
|
|
367
|
+
/**
|
|
368
|
+
* analyzeMerge() — editor-only merge diagnostics.
|
|
369
|
+
*
|
|
370
|
+
* Explains ri()'s right-most-wins conflict resolution by threading a
|
|
371
|
+
* MergeTrace through the shared merge loop. Split from merge/index.ts so the
|
|
372
|
+
* browser-facing runtime file stays free of editor-only analysis; consumed by
|
|
373
|
+
* editor/session.ts and the editor entry.
|
|
374
|
+
*/
|
|
375
|
+
|
|
376
|
+
interface MergeDrop {
|
|
377
|
+
index: number;
|
|
378
|
+
className: string;
|
|
379
|
+
/** Ascending indices of the surviving classes that together claimed every
|
|
380
|
+
* CSS property this class sets (px-4 + py-4 jointly dominate p-2). */
|
|
381
|
+
overriddenBy: number[];
|
|
382
|
+
}
|
|
383
|
+
interface MergeAnalysis {
|
|
384
|
+
/** The merged output — identical to ri()'s result for this token list. */
|
|
385
|
+
output: string;
|
|
386
|
+
/** Indices of surviving classes, ascending. */
|
|
387
|
+
kept: number[];
|
|
388
|
+
/** Dropped classes with attribution, ascending by index. */
|
|
389
|
+
dropped: MergeDrop[];
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Explain ri()'s conflict resolution for a list of class tokens — which
|
|
393
|
+
* classes the right-most-wins scan drops, and which survivors claimed their
|
|
394
|
+
* properties. Powers "this class is overridden" editor diagnostics.
|
|
395
|
+
*
|
|
396
|
+
* Unlike ri(), the input is pre-tokenized: one class per element, no falsy
|
|
397
|
+
* filtering, no whitespace splitting — exactly the token list an editor
|
|
398
|
+
* extracts from one class attribute. `snapshot` binds custom utilities, text
|
|
399
|
+
* sizes, and color names the same way createRi(snapshot) does (editors build
|
|
400
|
+
* one with createThemeSnapshot()); without it, the module-level state of the
|
|
401
|
+
* most recent compile applies. Uncached — call sites own their memoization.
|
|
402
|
+
*/
|
|
403
|
+
declare function analyzeMerge(classes: readonly string[], snapshot?: CompilationSnapshot): MergeAnalysis;
|
|
404
|
+
|
|
327
405
|
/**
|
|
328
406
|
* Color swatches and theme-token introspection for editor tooling.
|
|
329
407
|
*
|
|
@@ -461,4 +539,4 @@ declare const EDITOR_API_VERSION = 1;
|
|
|
461
539
|
/** Feature-detection roster for this entry. */
|
|
462
540
|
declare const editorCapabilities: readonly string[];
|
|
463
541
|
|
|
464
|
-
export { CANONICAL_COLOR_STOPS, CLASS_HELPER_NAMES, CSS_ENTRY_CANDIDATES, type CandidateOrigin, type ClassCandidate, type ClassEnumeration, type ClassExplanation, type ClassInspector, type ClassTemplate, type ClassValidation, ColorDefinition, type ColorSwatch, CompilationSnapshot, type Diagnostic, type DiagnosticSeverity, EDITOR_API_VERSION, type EditorSession, type EnumeratedClass, MergeAnalysis, ParsedDirective, type ParsedUtility, type ProjectAnalysis, RI_IMPORT_SPECIFIERS, ResolvedTheme, type SourceExtractionInput, type SwatchColor, type ThemeTokens, UTILITY_VALUE_SPACES, VARIANT_HELPER_NAMES, type ValueSpaceKind, type ValueSpaceSpec, type VariantInfo, type VariantKind, analyzeProjectCSS, createClassInspector, createEditorSession, cssColorToHex, diagnosticFromWarning, editorCapabilities, enumerateClassNames, expandVariantGroups, extractClassCandidates, extractClasses, extractClassesFromSource, findClosest, hasRIActivation, isSourceFile, listThemeTokens, listVariants, oklchToHex, parseUtility, resolveColorSwatch, severityForCode, version, warningCode };
|
|
542
|
+
export { CANONICAL_COLOR_STOPS, CLASS_HELPER_NAMES, CSS_ENTRY_CANDIDATES, type CandidateOrigin, type ClassCandidate, type ClassEnumeration, type ClassExplanation, type ClassInspector, type ClassTemplate, type ClassValidation, ColorDefinition, type ColorSwatch, CompilationSnapshot, type Diagnostic, type DiagnosticSeverity, EDITOR_API_VERSION, type EditorSession, type EnumeratedClass, type MergeAnalysis, type MergeDrop, ParsedDirective, type ParsedUtility, type ProjectAnalysis, RI_IMPORT_SPECIFIERS, ResolvedTheme, type SourceExtractionInput, type SwatchColor, type ThemeTokens, UTILITY_VALUE_SPACES, VARIANT_HELPER_NAMES, type ValueSpaceKind, type ValueSpaceSpec, type VariantInfo, type VariantKind, analyzeMerge, analyzeProjectCSS, createClassInspector, createEditorSession, cssColorToHex, diagnosticFromWarning, editorCapabilities, enumerateClassNames, expandVariantGroups, extractClassCandidates, extractClasses, extractClassesFromSource, findClosest, hasRIActivation, isSourceFile, listThemeTokens, listVariants, oklchToHex, parseUtility, resolveColorSwatch, severityForCode, version, warningCode };
|
package/dist/editor.mjs
CHANGED
|
@@ -2,7 +2,10 @@ import {
|
|
|
2
2
|
CSS_ENTRY_CANDIDATES,
|
|
3
3
|
UTILITY_VALUE_SPACES,
|
|
4
4
|
enumerateClassNames
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-YLB6FGIG.mjs";
|
|
6
|
+
import {
|
|
7
|
+
isSourceFile
|
|
8
|
+
} from "./chunk-3HRMFZGE.mjs";
|
|
6
9
|
import {
|
|
7
10
|
CLASS_HELPER_NAMES,
|
|
8
11
|
RI_IMPORT_SPECIFIERS,
|
|
@@ -20,22 +23,22 @@ import {
|
|
|
20
23
|
extractClassesFromSource,
|
|
21
24
|
findClosest,
|
|
22
25
|
hasRIActivation,
|
|
23
|
-
isSourceFile,
|
|
24
26
|
listVariants,
|
|
25
27
|
parseUtility,
|
|
26
28
|
severityForCode,
|
|
27
29
|
warningCode
|
|
28
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-6DAHUFNU.mjs";
|
|
29
31
|
import {
|
|
30
|
-
analyzeMerge,
|
|
31
32
|
computeDarkStop,
|
|
32
33
|
defaultTheme,
|
|
33
34
|
formatOklch,
|
|
34
35
|
generateStop,
|
|
35
36
|
linearToSrgb,
|
|
37
|
+
mergeUncached,
|
|
36
38
|
oklabToLinearSrgb,
|
|
37
|
-
oklchToOklab
|
|
38
|
-
|
|
39
|
+
oklchToOklab,
|
|
40
|
+
resolverFor
|
|
41
|
+
} from "./chunk-5Y7EXXLS.mjs";
|
|
39
42
|
|
|
40
43
|
// src/engine/inspector.ts
|
|
41
44
|
var RESOLUTION_CACHE_CAP = 1e4;
|
|
@@ -57,16 +60,22 @@ function createClassInspector(theme) {
|
|
|
57
60
|
}
|
|
58
61
|
function variantSuggestionCorpus() {
|
|
59
62
|
if (!variantNames) {
|
|
60
|
-
|
|
63
|
+
const names = [];
|
|
64
|
+
for (const v of variants()) {
|
|
65
|
+
if (v.kind !== "pattern") names.push(v.name);
|
|
66
|
+
}
|
|
67
|
+
variantNames = names;
|
|
61
68
|
}
|
|
62
69
|
return variantNames;
|
|
63
70
|
}
|
|
64
71
|
function utilitySuggestionCorpus() {
|
|
65
72
|
if (!utilityCorpus) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
const names = new Set(STATIC_UTILITIES);
|
|
74
|
+
for (const custom of theme.customUtilities) {
|
|
75
|
+
if (!custom.functional) names.add(custom.name);
|
|
76
|
+
}
|
|
77
|
+
for (const entry of enumerateClassNames(theme).classes) names.add(entry.name);
|
|
78
|
+
utilityCorpus = [...names];
|
|
70
79
|
}
|
|
71
80
|
return utilityCorpus;
|
|
72
81
|
}
|
|
@@ -153,6 +162,28 @@ function createClassInspector(theme) {
|
|
|
153
162
|
};
|
|
154
163
|
}
|
|
155
164
|
|
|
165
|
+
// src/merge/analyze.ts
|
|
166
|
+
function analyzeMerge(classes, snapshot) {
|
|
167
|
+
const resolve = resolverFor(snapshot);
|
|
168
|
+
const trace = { claimers: /* @__PURE__ */ new Map(), dropped: [] };
|
|
169
|
+
const output = mergeUncached(classes, resolve, trace);
|
|
170
|
+
trace.dropped.sort((a, b) => a.index - b.index);
|
|
171
|
+
const droppedIndexes = new Set(trace.dropped.map((d) => d.index));
|
|
172
|
+
const kept = [];
|
|
173
|
+
for (let i = 0; i < classes.length; i++) {
|
|
174
|
+
if (!droppedIndexes.has(i)) kept.push(i);
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
output,
|
|
178
|
+
kept,
|
|
179
|
+
dropped: trace.dropped.map((d) => ({
|
|
180
|
+
index: d.index,
|
|
181
|
+
className: classes[d.index],
|
|
182
|
+
overriddenBy: d.overriddenBy
|
|
183
|
+
}))
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
156
187
|
// src/theme/swatch.ts
|
|
157
188
|
var CANONICAL_COLOR_STOPS = Object.freeze([
|
|
158
189
|
50,
|
|
@@ -352,10 +383,11 @@ function createEditorSession(options = {}) {
|
|
|
352
383
|
}
|
|
353
384
|
|
|
354
385
|
// src/entries/editor.ts
|
|
355
|
-
var version = true ? "0.
|
|
386
|
+
var version = true ? "0.4.0" : "0.0.0-dev";
|
|
356
387
|
var EDITOR_API_VERSION = 1;
|
|
357
388
|
var editorCapabilities = Object.freeze([
|
|
358
389
|
"class-candidates",
|
|
390
|
+
"candidate-call-ids",
|
|
359
391
|
"css-entry-detection",
|
|
360
392
|
"theme-analysis",
|
|
361
393
|
"class-inspection",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ColorDefinition,
|
|
1
|
+
import { C as ColorDefinition, D as DarkModeConfig, j as CornerShape, A as AnimationDefinition, F as FluidConfig, b as CompilationSnapshot } from './context-ruu2x_jR.js';
|
|
2
2
|
|
|
3
3
|
/** Provider discriminant for a slot, derived from its faces. */
|
|
4
4
|
type FontProviderKind = "google" | "system" | "local" | "manual";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PluginCreator } from 'postcss';
|
|
2
|
-
export { C as ColorDefinition, a as CompilationContext, b as CompilationSnapshot,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export {
|
|
2
|
+
export { C as ColorDefinition, a as CompilationContext, b as CompilationSnapshot, F as FluidConfig, T as TextSize, c as Theme, d as createCompilationContext, e as defaultTheme, f as finalizeCompilationContext, r as registerColorNames, g as registerCustomFontFamilies, h as registerCustomTextSizes, i as registerCustomUtility } from './context-ruu2x_jR.js';
|
|
3
|
+
export { D as DEFAULT_TEXT_SIZES, c as createRi, r as ri, s as safelist } from './safelist-D9-Plqta.js';
|
|
4
|
+
import { R as ResolvedTheme, P as ParsedDirective } from './index-BB2HoeMj.js';
|
|
5
|
+
export { C as CompilationResult, a as CompiledRule, c as createCompiler } from './index-BB2HoeMj.js';
|
|
6
6
|
|
|
7
7
|
interface RainbowIndexOptions {
|
|
8
8
|
sources?: string[];
|
package/dist/index.mjs
CHANGED
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
} from "./chunk-PD4ZXGJ6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
postcss_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TLR6RP5L.mjs";
|
|
7
7
|
import {
|
|
8
8
|
finalizeProjectCompilation,
|
|
9
9
|
resolveGoogleFonts
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4SVFFDS2.mjs";
|
|
11
11
|
import {
|
|
12
12
|
analyzeProjectCSS,
|
|
13
13
|
createCompiler,
|
|
14
14
|
extractClassesFromSource,
|
|
15
15
|
pushWarningsDeduped
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6DAHUFNU.mjs";
|
|
17
17
|
import {
|
|
18
18
|
DEFAULT_TEXT_SIZES,
|
|
19
19
|
createCompilationContext,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
registerCustomTextSizes,
|
|
26
26
|
registerCustomUtility,
|
|
27
27
|
ri
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-5Y7EXXLS.mjs";
|
|
29
29
|
|
|
30
30
|
// src/project/index.ts
|
|
31
31
|
async function compileProject(options) {
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { b as CompilationSnapshot } from './context-ruu2x_jR.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
|
+
* Claim resolution for ri() — utility name → CSS properties it sets.
|
|
56
|
+
*
|
|
57
|
+
* Split from merge/index.ts so each merge file is one concept: this file owns
|
|
58
|
+
* the dual-mode dispatch tables and resolvePropsWith(); index.ts owns the
|
|
59
|
+
* merge algorithm; context.ts owns the compilation-context lifecycle.
|
|
60
|
+
*
|
|
61
|
+
* Everything here is immutable module-init data plus pure closures over it —
|
|
62
|
+
* the mutable published compilation state lives in context.ts, and callers
|
|
63
|
+
* thread it in through resolvePropsWith()'s parameters.
|
|
64
|
+
*/
|
|
65
|
+
declare const DEFAULT_TEXT_SIZES: readonly ["xs", "sm", "base", "lg", "xl", "2xl", "3xl", "4xl", "5xl"];
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* `safelist()` — declare utility classes that must be emitted regardless of
|
|
69
|
+
* whether the consumer's source files reference them directly.
|
|
70
|
+
*
|
|
71
|
+
* At runtime this is a plain identity-join: pass any number of strings (and
|
|
72
|
+
* falsy values, which are filtered) and receive a single space-joined string
|
|
73
|
+
* suitable for `className`. The function performs no global registration, has
|
|
74
|
+
* no side effects, and is tree-shake-safe.
|
|
75
|
+
*
|
|
76
|
+
* The build-time meaning comes from the scanner: when the source-file
|
|
77
|
+
* extractor encounters a `safelist(...)` call, it extracts every literal
|
|
78
|
+
* string argument as a class declaration — so the classes get emitted in the
|
|
79
|
+
* final CSS even though the consumer's source never names them literally.
|
|
80
|
+
*
|
|
81
|
+
* Primary use case is component libraries that ship classNames inside their
|
|
82
|
+
* bundled code (e.g. a curated icon set whose strokes are described by
|
|
83
|
+
* utility classes). The library wraps its declarations in `safelist(...)`,
|
|
84
|
+
* the consumer's setup points the scanner at the library's `dist/`, and the
|
|
85
|
+
* classes flow through unchanged. The Vite plugin auto-discovers libraries
|
|
86
|
+
* that opt in via a `rainbowindex.safelistSources` field in their
|
|
87
|
+
* `package.json`, so consumers typically don't have to add `@source` lines
|
|
88
|
+
* by hand.
|
|
89
|
+
*
|
|
90
|
+
* const ICON_BASE = safelist("stroke-cap-round", "stroke-join-round");
|
|
91
|
+
* const SidebarLeft = defineIcon({
|
|
92
|
+
* primitives: SIDEBAR,
|
|
93
|
+
* className: safelist(ICON_BASE, "-scale-x-100"),
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* Scanner contract:
|
|
97
|
+
* - Only STATIC string literals at the call site are extracted. Values
|
|
98
|
+
* passed through variables (`safelist(ICON_BASE, ...)`) won't be re-read
|
|
99
|
+
* at the outer call site, but the original `safelist("stroke-cap-round",
|
|
100
|
+
* ...)` that produced `ICON_BASE` is itself extracted, so the classes are
|
|
101
|
+
* still covered.
|
|
102
|
+
* - Template literals with no `${…}` interpolation are extracted; templates
|
|
103
|
+
* with interpolation are skipped.
|
|
104
|
+
* - Falsy arguments are dropped at runtime so conditional fragments compose
|
|
105
|
+
* naturally: `safelist("flex", side === "left" && "flex-row-reverse")`.
|
|
106
|
+
*/
|
|
107
|
+
declare function safelist(...parts: ReadonlyArray<string | false | null | undefined>): string;
|
|
108
|
+
|
|
109
|
+
export { DEFAULT_TEXT_SIZES as D, createRi as c, ri as r, safelist as s };
|