rainbowindex 0.2.0 → 0.2.2

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.
@@ -0,0 +1,260 @@
1
+ import { C as ColorDefinition, l as DarkModeConfig, m as CornerShape, A as AnimationDefinition, F as FluidConfig, b as CompilationSnapshot } from './index-CfDtWufj.js';
2
+
3
+ /** Provider discriminant for a slot, derived from its faces. */
4
+ type FontProviderKind = "google" | "system" | "local" | "manual";
5
+ interface FontFace {
6
+ /** Provider: "google", "system", a file path/URL, or "" (manual stack — no @font-face). */
7
+ provider: string;
8
+ /** Weight range ("300 900"), list ("400,700"), or single ("400"). */
9
+ weight: string;
10
+ /** A single valid font-style descriptor: "normal", "italic", or "oblique <range>".
11
+ * (Google faces may carry "normal italic" — that drives the URL's ital axis, not a descriptor.) */
12
+ style: string;
13
+ /** font-display strategy. */
14
+ display: string;
15
+ /** Unicode subsets — used as a Google Fonts URL hint. */
16
+ subset: string;
17
+ /** Optional unicode-range descriptor emitted into the @font-face (local subsetting). */
18
+ unicodeRange?: string;
19
+ /** Per-face preload override; when undefined the slot-level default applies. */
20
+ preload?: boolean;
21
+ /** Whether the weight was explicitly set by the user (not a default).
22
+ * Used by refreshFontWeightDefaults() to avoid overriding user intent. */
23
+ _weightExplicit?: boolean;
24
+ /** Whether the style was explicitly set by the user (not a default).
25
+ * Used by refreshFontWeightDefaults() to avoid overriding user intent. */
26
+ _styleExplicit?: boolean;
27
+ }
28
+ interface FontSlot {
29
+ /** Target slot: "sans", "serif", "mono", or custom like "display". */
30
+ slot: string;
31
+ /** Font family name — shared by every face in the slot. */
32
+ family: string;
33
+ /** Provider discriminant, derived from the slot's faces. */
34
+ kind: FontProviderKind;
35
+ /** Fallback font stack. */
36
+ fallback: string[];
37
+ /** Font feature settings — applied via the font-<slot> utility. */
38
+ features: string | null;
39
+ /** Font variation settings — applied via the font-<slot> utility. */
40
+ variation: string | null;
41
+ /** Slot-level preload default for faces that don't set their own. */
42
+ preload: boolean;
43
+ /** One or more faces — each emits an @font-face for local providers. */
44
+ faces: FontFace[];
45
+ /** User-specified fallback font for metrics-adjusted @font-face. */
46
+ metricsFallback?: string;
47
+ /** User-specified size-adjust percentage. */
48
+ sizeAdjust?: number;
49
+ /** User-specified ascent-override percentage. */
50
+ ascent?: number;
51
+ /** User-specified descent-override percentage. */
52
+ descent?: number;
53
+ /** User-specified line-gap-override percentage. */
54
+ lineGap?: number;
55
+ }
56
+
57
+ /**
58
+ * Font loading system — @font directive processing, @font-face generation,
59
+ * metrics-adjusted fallbacks for zero CLS.
60
+ *
61
+ * A slot (sans/serif/mono/custom) maps to one --font-<slot> variable and one
62
+ * family name, but can own multiple faces — e.g. an upright + an italic file,
63
+ * or split unicode ranges. Each FontFace emits one @font-face for local
64
+ * providers; google/system/manual slots carry a single face.
65
+ */
66
+
67
+ interface FontOutput {
68
+ imports: string[];
69
+ fontFaces: string[];
70
+ variables: string[];
71
+ warnings: string[];
72
+ }
73
+
74
+ /**
75
+ * Raw-extractable directive names — the single source for the DirectiveType
76
+ * union and the name sets in directives/index.ts (which add the PostCSS-only
77
+ * apply/slot names on top for activation detection).
78
+ */
79
+ declare const DIRECTIVE_TYPE_NAMES: readonly ["color", "text", "spacing", "breakpoint", "rounded", "shadow", "weight", "ease", "blur", "z", "animate", "fluid", "font", "preflight", "utility", "custom", "source", "leading", "tracking", "opacity", "duration", "layer", "register"];
80
+ type DirectiveType = (typeof DIRECTIVE_TYPE_NAMES)[number];
81
+ interface ParsedDirective {
82
+ type: DirectiveType;
83
+ body: string;
84
+ modifier?: string;
85
+ }
86
+ interface PreflightConfig {
87
+ core: boolean;
88
+ typography: boolean;
89
+ content: boolean;
90
+ forms: boolean;
91
+ interactive: boolean;
92
+ modern: boolean;
93
+ }
94
+ interface CustomUtility {
95
+ name: string;
96
+ functional: boolean;
97
+ body: string;
98
+ }
99
+ interface CustomVariant {
100
+ name: string;
101
+ selector: string;
102
+ }
103
+ interface SourceDirective {
104
+ pattern: string;
105
+ negated: boolean;
106
+ inline: boolean;
107
+ classes?: string[];
108
+ /**
109
+ * Marks the pattern as a trusted, fully-qualified absolute path produced
110
+ * by internal machinery (auto-discovery from installed deps). User-facing
111
+ * `@source` patterns are validated to be relative — this flag bypasses
112
+ * that check for patterns we generate ourselves and that intentionally
113
+ * point outside the project's cwd (into `node_modules`).
114
+ */
115
+ absolute?: boolean;
116
+ }
117
+ interface LayerConfig {
118
+ order: string[] | null;
119
+ utilities: string | null;
120
+ base: string | null;
121
+ wrapAll: string | null;
122
+ }
123
+ /**
124
+ * A custom-property registration produced by an `@register` directive — the
125
+ * structured form of a CSS `@property` rule. `syntax` is stored already quoted
126
+ * (e.g. `"<length>"`) so it can be emitted verbatim. `initialValue` is optional
127
+ * only when `syntax` is the universal `"*"`; the parser drops typed registrations
128
+ * that lack one (a typed `@property` without `initial-value` is invalid CSS and
129
+ * silently ignored by browsers).
130
+ */
131
+ interface PropertyRegistration {
132
+ name: string;
133
+ syntax: string;
134
+ inherits: boolean;
135
+ initialValue?: string;
136
+ }
137
+ interface ResolvedTheme {
138
+ readonly colors: Readonly<Record<string, ColorDefinition>>;
139
+ readonly darkConfig: Readonly<DarkModeConfig>;
140
+ readonly text: Readonly<Record<string, {
141
+ fontSize: string;
142
+ lineHeight: string;
143
+ }>>;
144
+ readonly spacing: Readonly<{
145
+ base: string;
146
+ }>;
147
+ readonly breakpoints: Readonly<Record<string, string>>;
148
+ readonly rounded: Readonly<Record<string, string>>;
149
+ readonly roundedRoof: string;
150
+ /**
151
+ * Corner shape set via `@rounded <shape>`. `null` means no shape was configured —
152
+ * the compiler emits neither a `corner-shape` rule nor the fallback `@supports not`
153
+ * block. Non-null values trigger both.
154
+ */
155
+ readonly roundedShape: CornerShape | null;
156
+ /**
157
+ * Multiplier applied to `border-radius` inside
158
+ * `@supports (corner-shape: <shape>)` so that — in browsers that do
159
+ * render the configured shape — radii are bumped to match the visual
160
+ * weight a plain round corner would have at the raw radius in
161
+ * non-supporting browsers. Derived from the per-shape default table,
162
+ * overridable via `--corner-scale` in the `@rounded` body. Ignored when
163
+ * `roundedShape` is null.
164
+ */
165
+ readonly roundedShapeScale: number;
166
+ readonly shadows: Readonly<Record<string, string>>;
167
+ readonly weights: Readonly<Record<string, number>>;
168
+ readonly easing: Readonly<Record<string, string>>;
169
+ readonly blur: Readonly<Record<string, string>>;
170
+ readonly z: Readonly<Record<string, string>>;
171
+ readonly animations: Readonly<Record<string, AnimationDefinition>>;
172
+ readonly fluid: Readonly<FluidConfig>;
173
+ readonly textFluid?: Readonly<FluidConfig>;
174
+ readonly spacingFluid?: Readonly<FluidConfig>;
175
+ readonly fonts: readonly FontSlot[];
176
+ readonly preflight: Readonly<PreflightConfig>;
177
+ readonly customUtilities: readonly CustomUtility[];
178
+ readonly customVariants: readonly CustomVariant[];
179
+ readonly sources: readonly SourceDirective[];
180
+ readonly leading: Readonly<Record<string, string>>;
181
+ readonly tracking: Readonly<Record<string, string>>;
182
+ readonly opacity: Readonly<Record<string, string>>;
183
+ readonly duration: Readonly<Record<string, string>>;
184
+ readonly layer: Readonly<LayerConfig> | null;
185
+ /** Custom properties registered via `@register` → emitted as `@property` rules. */
186
+ readonly registeredProperties: readonly PropertyRegistration[];
187
+ readonly warnings: readonly string[];
188
+ }
189
+
190
+ interface CompiledRule {
191
+ /** The original class name (escaped for CSS selector). */
192
+ selector: string;
193
+ /** Sort key for deterministic ordering. */
194
+ sortKey: number;
195
+ /** CSS declarations as a string block. */
196
+ css: string;
197
+ }
198
+ interface CompilationResult {
199
+ /** All compiled CSS rules. */
200
+ rules: CompiledRule[];
201
+ /** @keyframes blocks needed. */
202
+ keyframes: string[];
203
+ /** @property declarations needed. */
204
+ properties: string[];
205
+ /** Map of used color hue → set of used suffixes (for token pruning). */
206
+ usedColorStops: Map<string, Set<number>>;
207
+ /** Set of used text size names (for token pruning). */
208
+ usedTextSizes: Set<string>;
209
+ /** Set of used font slot names (for token pruning). */
210
+ usedFonts: Set<string>;
211
+ /** Set of used rounded value names (for token pruning). */
212
+ usedRounded: Set<string>;
213
+ /** Set of used shadow names (for token pruning). */
214
+ usedShadows: Set<string>;
215
+ /** Set of used animation shorthand names (for token pruning). */
216
+ usedAnimations: Set<string>;
217
+ /** Warnings emitted during compilation. */
218
+ warnings: string[];
219
+ }
220
+
221
+ /**
222
+ * Build a CompilationSnapshot straight from a resolved theme — no compile
223
+ * pass, no module-level state. Editor tooling pairs this with
224
+ * analyzeMerge()/createRi() for theme-accurate merge semantics.
225
+ */
226
+ declare function createThemeSnapshot(theme: ResolvedTheme): CompilationSnapshot;
227
+ /**
228
+ * Create an isolated compiler instance for SSR / concurrent-compilation
229
+ * environments. Returns a `compile()` function that does NOT touch module-level
230
+ * state, and a `createRi()` that produces a merge function bound to the
231
+ * compilation's snapshot.
232
+ *
233
+ * **Isolation scope:** Compilation context, variant map cache, and font output
234
+ * cache are fully isolated per instance. Google Fonts metadata (from fonts.ts)
235
+ * is intentionally shared read-only across instances — it is populated once
236
+ * via atomic swap and never mutated afterward, so concurrent reads are safe.
237
+ *
238
+ * **Font output cache lifecycle:** `fontOutputCache` is cleared at the start
239
+ * of each `compile()` call, so it only caches within a single compilation pass.
240
+ * If the same compiler instance is reused across compilations (the expected SSR
241
+ * pattern), each compilation starts with a fresh font cache.
242
+ *
243
+ * @example
244
+ * ```ts
245
+ * import { createCompiler } from "rainbowindex";
246
+ *
247
+ * const compiler = createCompiler();
248
+ * const result = compiler.compile(classNames, theme);
249
+ * const ri = compiler.createRi();
250
+ * ```
251
+ */
252
+ declare function createCompiler(): {
253
+ compile: (classNames: Iterable<string>, theme: ResolvedTheme) => CompilationResult;
254
+ createRi: () => (...inputs: (string | false | null | undefined)[]) => string;
255
+ /** Isolated font output cache for this compiler instance. Pass to
256
+ * `assembleSections()` to avoid sharing module-level font state. */
257
+ fontOutputCache: Map<string, FontOutput>;
258
+ };
259
+
260
+ export { type CompilationResult as C, type ParsedDirective as P, type ResolvedTheme as R, type CompiledRule as a, createThemeSnapshot as b, createCompiler as c };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { PluginCreator } from 'postcss';
2
- import { C as ColorDefinition, l as DarkModeConfig, m as CornerShape, A as AnimationDefinition, F as FluidConfig } from './safelist-DRk1XXxi.js';
3
- export { a as CompilationContext, b as CompilationSnapshot, D as DEFAULT_TEXT_SIZES, T as TextSize, c as Theme, d as createCompilationContext, e as createRi, f as defaultTheme, g as finalizeCompilationContext, r as registerColorNames, h as registerCustomFontFamilies, i as registerCustomTextSizes, j as registerCustomUtility, k as ri, s as safelist } from './safelist-DRk1XXxi.js';
2
+ export { C as ColorDefinition, a as CompilationContext, b as CompilationSnapshot, D as DEFAULT_TEXT_SIZES, F as FluidConfig, T as TextSize, c as Theme, d as createCompilationContext, e as createRi, f as defaultTheme, g as finalizeCompilationContext, r as registerColorNames, h as registerCustomFontFamilies, i as registerCustomTextSizes, j as registerCustomUtility, k as ri } from './index-CfDtWufj.js';
3
+ import { R as ResolvedTheme, P as ParsedDirective } from './index-DK6APAGD.js';
4
+ export { C as CompilationResult, a as CompiledRule, c as createCompiler } from './index-DK6APAGD.js';
5
+ export { s as safelist } from './safelist-CH3_PywB.js';
4
6
 
5
7
  interface RainbowIndexOptions {
6
8
  sources?: string[];
@@ -8,192 +10,6 @@ interface RainbowIndexOptions {
8
10
  }
9
11
  declare const rainbowindex: PluginCreator<RainbowIndexOptions>;
10
12
 
11
- /**
12
- * Font loading system — @font directive processing, @font-face generation,
13
- * metrics-adjusted fallbacks for zero CLS.
14
- *
15
- * A slot (sans/serif/mono/custom) maps to one --font-<slot> variable and one
16
- * family name, but can own multiple faces — e.g. an upright + an italic file,
17
- * or split unicode ranges. Each FontFace emits one @font-face for local
18
- * providers; google/system/manual slots carry a single face.
19
- */
20
-
21
- /** Provider discriminant for a slot, derived from its faces. */
22
- type FontProviderKind = "google" | "system" | "local" | "manual";
23
- interface FontFace {
24
- /** Provider: "google", "system", a file path/URL, or "" (manual stack — no @font-face). */
25
- provider: string;
26
- /** Weight range ("300 900"), list ("400,700"), or single ("400"). */
27
- weight: string;
28
- /** A single valid font-style descriptor: "normal", "italic", or "oblique <range>".
29
- * (Google faces may carry "normal italic" — that drives the URL's ital axis, not a descriptor.) */
30
- style: string;
31
- /** font-display strategy. */
32
- display: string;
33
- /** Unicode subsets — used as a Google Fonts URL hint. */
34
- subset: string;
35
- /** Optional unicode-range descriptor emitted into the @font-face (local subsetting). */
36
- unicodeRange?: string;
37
- /** Per-face preload override; when undefined the slot-level default applies. */
38
- preload?: boolean;
39
- /** Whether the weight was explicitly set by the user (not a default).
40
- * Used by refreshFontWeightDefaults() to avoid overriding user intent. */
41
- _weightExplicit?: boolean;
42
- /** Whether the style was explicitly set by the user (not a default).
43
- * Used by refreshFontWeightDefaults() to avoid overriding user intent. */
44
- _styleExplicit?: boolean;
45
- }
46
- interface FontSlot {
47
- /** Target slot: "sans", "serif", "mono", or custom like "display". */
48
- slot: string;
49
- /** Font family name — shared by every face in the slot. */
50
- family: string;
51
- /** Provider discriminant, derived from the slot's faces. */
52
- kind: FontProviderKind;
53
- /** Fallback font stack. */
54
- fallback: string[];
55
- /** Font feature settings — applied via the font-<slot> utility. */
56
- features: string | null;
57
- /** Font variation settings — applied via the font-<slot> utility. */
58
- variation: string | null;
59
- /** Slot-level preload default for faces that don't set their own. */
60
- preload: boolean;
61
- /** One or more faces — each emits an @font-face for local providers. */
62
- faces: FontFace[];
63
- /** User-specified fallback font for metrics-adjusted @font-face. */
64
- metricsFallback?: string;
65
- /** User-specified size-adjust percentage. */
66
- sizeAdjust?: number;
67
- /** User-specified ascent-override percentage. */
68
- ascent?: number;
69
- /** User-specified descent-override percentage. */
70
- descent?: number;
71
- /** User-specified line-gap-override percentage. */
72
- lineGap?: number;
73
- }
74
- interface FontOutput {
75
- imports: string[];
76
- fontFaces: string[];
77
- variables: string[];
78
- warnings: string[];
79
- }
80
-
81
- /**
82
- * Raw-extractable directive names — the single source for the DirectiveType
83
- * union and the name sets in directives/index.ts (which add the PostCSS-only
84
- * apply/slot names on top for activation detection).
85
- */
86
- declare const DIRECTIVE_TYPE_NAMES: readonly ["color", "text", "spacing", "breakpoint", "rounded", "shadow", "weight", "ease", "blur", "z", "animate", "fluid", "font", "preflight", "utility", "custom", "source", "leading", "tracking", "opacity", "duration", "layer", "register"];
87
- type DirectiveType = (typeof DIRECTIVE_TYPE_NAMES)[number];
88
- interface ParsedDirective {
89
- type: DirectiveType;
90
- body: string;
91
- modifier?: string;
92
- }
93
- interface PreflightConfig {
94
- core: boolean;
95
- typography: boolean;
96
- content: boolean;
97
- forms: boolean;
98
- interactive: boolean;
99
- modern: boolean;
100
- }
101
- interface CustomUtility {
102
- name: string;
103
- functional: boolean;
104
- body: string;
105
- }
106
- interface CustomVariant {
107
- name: string;
108
- selector: string;
109
- }
110
- interface SourceDirective {
111
- pattern: string;
112
- negated: boolean;
113
- inline: boolean;
114
- classes?: string[];
115
- /**
116
- * Marks the pattern as a trusted, fully-qualified absolute path produced
117
- * by internal machinery (auto-discovery from installed deps). User-facing
118
- * `@source` patterns are validated to be relative — this flag bypasses
119
- * that check for patterns we generate ourselves and that intentionally
120
- * point outside the project's cwd (into `node_modules`).
121
- */
122
- absolute?: boolean;
123
- }
124
- interface LayerConfig {
125
- order: string[] | null;
126
- utilities: string | null;
127
- base: string | null;
128
- wrapAll: string | null;
129
- }
130
- /**
131
- * A custom-property registration produced by an `@register` directive — the
132
- * structured form of a CSS `@property` rule. `syntax` is stored already quoted
133
- * (e.g. `"<length>"`) so it can be emitted verbatim. `initialValue` is optional
134
- * only when `syntax` is the universal `"*"`; the parser drops typed registrations
135
- * that lack one (a typed `@property` without `initial-value` is invalid CSS and
136
- * silently ignored by browsers).
137
- */
138
- interface PropertyRegistration {
139
- name: string;
140
- syntax: string;
141
- inherits: boolean;
142
- initialValue?: string;
143
- }
144
- interface ResolvedTheme {
145
- readonly colors: Readonly<Record<string, ColorDefinition>>;
146
- readonly darkConfig: Readonly<DarkModeConfig>;
147
- readonly text: Readonly<Record<string, {
148
- fontSize: string;
149
- lineHeight: string;
150
- }>>;
151
- readonly spacing: Readonly<{
152
- base: string;
153
- }>;
154
- readonly breakpoints: Readonly<Record<string, string>>;
155
- readonly rounded: Readonly<Record<string, string>>;
156
- readonly roundedRoof: string;
157
- /**
158
- * Corner shape set via `@rounded <shape>`. `null` means no shape was configured —
159
- * the compiler emits neither a `corner-shape` rule nor the fallback `@supports not`
160
- * block. Non-null values trigger both.
161
- */
162
- readonly roundedShape: CornerShape | null;
163
- /**
164
- * Multiplier applied to `border-radius` inside
165
- * `@supports (corner-shape: <shape>)` so that — in browsers that do
166
- * render the configured shape — radii are bumped to match the visual
167
- * weight a plain round corner would have at the raw radius in
168
- * non-supporting browsers. Derived from the per-shape default table,
169
- * overridable via `--corner-scale` in the `@rounded` body. Ignored when
170
- * `roundedShape` is null.
171
- */
172
- readonly roundedShapeScale: number;
173
- readonly shadows: Readonly<Record<string, string>>;
174
- readonly weights: Readonly<Record<string, number>>;
175
- readonly easing: Readonly<Record<string, string>>;
176
- readonly blur: Readonly<Record<string, string>>;
177
- readonly z: Readonly<Record<string, string>>;
178
- readonly animations: Readonly<Record<string, AnimationDefinition>>;
179
- readonly fluid: Readonly<FluidConfig>;
180
- readonly textFluid?: Readonly<FluidConfig>;
181
- readonly spacingFluid?: Readonly<FluidConfig>;
182
- readonly fonts: readonly FontSlot[];
183
- readonly preflight: Readonly<PreflightConfig>;
184
- readonly customUtilities: readonly CustomUtility[];
185
- readonly customVariants: readonly CustomVariant[];
186
- readonly sources: readonly SourceDirective[];
187
- readonly leading: Readonly<Record<string, string>>;
188
- readonly tracking: Readonly<Record<string, string>>;
189
- readonly opacity: Readonly<Record<string, string>>;
190
- readonly duration: Readonly<Record<string, string>>;
191
- readonly layer: Readonly<LayerConfig> | null;
192
- /** Custom properties registered via `@register` → emitted as `@property` rules. */
193
- readonly registeredProperties: readonly PropertyRegistration[];
194
- readonly warnings: readonly string[];
195
- }
196
-
197
13
  type FontResolver = (fonts: ResolvedTheme["fonts"]) => Promise<ResolvedTheme["fonts"]> | ResolvedTheme["fonts"];
198
14
  interface FinalizeProjectResult {
199
15
  css: string;
@@ -222,68 +38,4 @@ interface CompileProjectOptions {
222
38
  type CompileProjectResult = FinalizeProjectResult;
223
39
  declare function compileProject(options: CompileProjectOptions): Promise<CompileProjectResult>;
224
40
 
225
- interface CompiledRule {
226
- /** The original class name (escaped for CSS selector). */
227
- selector: string;
228
- /** Sort key for deterministic ordering. */
229
- sortKey: number;
230
- /** CSS declarations as a string block. */
231
- css: string;
232
- }
233
- interface CompilationResult {
234
- /** All compiled CSS rules. */
235
- rules: CompiledRule[];
236
- /** @keyframes blocks needed. */
237
- keyframes: string[];
238
- /** @property declarations needed. */
239
- properties: string[];
240
- /** Map of used color hue → set of used suffixes (for token pruning). */
241
- usedColorStops: Map<string, Set<number>>;
242
- /** Set of used text size names (for token pruning). */
243
- usedTextSizes: Set<string>;
244
- /** Set of used font slot names (for token pruning). */
245
- usedFonts: Set<string>;
246
- /** Set of used rounded value names (for token pruning). */
247
- usedRounded: Set<string>;
248
- /** Set of used shadow names (for token pruning). */
249
- usedShadows: Set<string>;
250
- /** Set of used animation shorthand names (for token pruning). */
251
- usedAnimations: Set<string>;
252
- /** Warnings emitted during compilation. */
253
- warnings: string[];
254
- }
255
-
256
- /**
257
- * Create an isolated compiler instance for SSR / concurrent-compilation
258
- * environments. Returns a `compile()` function that does NOT touch module-level
259
- * state, and a `createRi()` that produces a merge function bound to the
260
- * compilation's snapshot.
261
- *
262
- * **Isolation scope:** Compilation context, variant map cache, and font output
263
- * cache are fully isolated per instance. Google Fonts metadata (from fonts.ts)
264
- * is intentionally shared read-only across instances — it is populated once
265
- * via atomic swap and never mutated afterward, so concurrent reads are safe.
266
- *
267
- * **Font output cache lifecycle:** `fontOutputCache` is cleared at the start
268
- * of each `compile()` call, so it only caches within a single compilation pass.
269
- * If the same compiler instance is reused across compilations (the expected SSR
270
- * pattern), each compilation starts with a fresh font cache.
271
- *
272
- * @example
273
- * ```ts
274
- * import { createCompiler } from "rainbowindex";
275
- *
276
- * const compiler = createCompiler();
277
- * const result = compiler.compile(classNames, theme);
278
- * const ri = compiler.createRi();
279
- * ```
280
- */
281
- declare function createCompiler(): {
282
- compile: (classNames: Iterable<string>, theme: ResolvedTheme) => CompilationResult;
283
- createRi: () => (...inputs: (string | false | null | undefined)[]) => string;
284
- /** Isolated font output cache for this compiler instance. Pass to
285
- * `assembleSections()` to avoid sharing module-level font state. */
286
- fontOutputCache: Map<string, FontOutput>;
287
- };
288
-
289
- export { ColorDefinition, type CompilationResult, type CompileProjectOptions, type CompileProjectResult, type CompiledRule, FluidConfig, type RainbowIndexOptions, compileProject, createCompiler, rainbowindex as default };
41
+ export { type CompileProjectOptions, type CompileProjectResult, type RainbowIndexOptions, compileProject, rainbowindex as default };
package/dist/index.mjs CHANGED
@@ -3,15 +3,17 @@ import {
3
3
  } from "./chunk-PD4ZXGJ6.mjs";
4
4
  import {
5
5
  postcss_default
6
- } from "./chunk-KCSNR2TV.mjs";
6
+ } from "./chunk-CUUW2K35.mjs";
7
+ import {
8
+ finalizeProjectCompilation,
9
+ resolveGoogleFonts
10
+ } from "./chunk-FHATRQMN.mjs";
7
11
  import {
8
12
  analyzeProjectCSS,
9
13
  createCompiler,
10
14
  extractClassesFromSource,
11
- finalizeProjectCompilation,
12
- pushWarningsDeduped,
13
- resolveGoogleFonts
14
- } from "./chunk-RPXZ3O6R.mjs";
15
+ pushWarningsDeduped
16
+ } from "./chunk-W6XIBM4M.mjs";
15
17
  import {
16
18
  DEFAULT_TEXT_SIZES,
17
19
  createCompilationContext,
@@ -23,7 +25,7 @@ import {
23
25
  registerCustomTextSizes,
24
26
  registerCustomUtility,
25
27
  ri
26
- } from "./chunk-5N4GPK26.mjs";
28
+ } from "./chunk-SOMDX7V6.mjs";
27
29
 
28
30
  // src/project/index.ts
29
31
  async function compileProject(options) {
@@ -0,0 +1,43 @@
1
+ /**
2
+ * `safelist()` — declare utility classes that must be emitted regardless of
3
+ * whether the consumer's source files reference them directly.
4
+ *
5
+ * At runtime this is a plain identity-join: pass any number of strings (and
6
+ * falsy values, which are filtered) and receive a single space-joined string
7
+ * suitable for `className`. The function performs no global registration, has
8
+ * no side effects, and is tree-shake-safe.
9
+ *
10
+ * The build-time meaning comes from the scanner: when the source-file
11
+ * extractor encounters a `safelist(...)` call, it extracts every literal
12
+ * string argument as a class declaration — so the classes get emitted in the
13
+ * final CSS even though the consumer's source never names them literally.
14
+ *
15
+ * Primary use case is component libraries that ship classNames inside their
16
+ * bundled code (e.g. a curated icon set whose strokes are described by
17
+ * utility classes). The library wraps its declarations in `safelist(...)`,
18
+ * the consumer's setup points the scanner at the library's `dist/`, and the
19
+ * classes flow through unchanged. The Vite plugin auto-discovers libraries
20
+ * that opt in via a `rainbowindex.safelistSources` field in their
21
+ * `package.json`, so consumers typically don't have to add `@source` lines
22
+ * by hand.
23
+ *
24
+ * const ICON_BASE = safelist("stroke-cap-round", "stroke-join-round");
25
+ * const SidebarLeft = defineIcon({
26
+ * primitives: SIDEBAR,
27
+ * className: safelist(ICON_BASE, "-scale-x-100"),
28
+ * });
29
+ *
30
+ * Scanner contract:
31
+ * - Only STATIC string literals at the call site are extracted. Values
32
+ * passed through variables (`safelist(ICON_BASE, ...)`) won't be re-read
33
+ * at the outer call site, but the original `safelist("stroke-cap-round",
34
+ * ...)` that produced `ICON_BASE` is itself extracted, so the classes are
35
+ * still covered.
36
+ * - Template literals with no `${…}` interpolation are extracted; templates
37
+ * with interpolation are skipped.
38
+ * - Falsy arguments are dropped at runtime so conditional fragments compose
39
+ * naturally: `safelist("flex", side === "left" && "flex-row-reverse")`.
40
+ */
41
+ declare function safelist(...parts: ReadonlyArray<string | false | null | undefined>): string;
42
+
43
+ export { safelist as s };
package/dist/vite.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  postcss_default
3
- } from "./chunk-KCSNR2TV.mjs";
3
+ } from "./chunk-CUUW2K35.mjs";
4
+ import "./chunk-FHATRQMN.mjs";
4
5
  import {
5
6
  expandApplyGroups,
6
7
  findClosingBrace,
@@ -8,10 +9,10 @@ import {
8
9
  isAtRuleBoundary,
9
10
  isAtRuleNameChar,
10
11
  isSourceFile
11
- } from "./chunk-RPXZ3O6R.mjs";
12
+ } from "./chunk-W6XIBM4M.mjs";
12
13
  import {
13
14
  devWarn
14
- } from "./chunk-5N4GPK26.mjs";
15
+ } from "./chunk-SOMDX7V6.mjs";
15
16
 
16
17
  // src/integrations/vite.ts
17
18
  import { existsSync } from "fs";