rainbowindex 0.5.1 → 0.6.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 +333 -0
- package/README.md +6 -4
- package/dist/browser.d.ts +2 -2
- package/dist/browser.mjs +1 -3
- package/dist/{chunk-4CTJLMYM.mjs → chunk-3LWJTLOJ.mjs} +17 -11
- package/dist/{chunk-4UKFK2GE.mjs → chunk-6U4IOFOS.mjs} +682 -869
- package/dist/{chunk-PDORZSQX.mjs → chunk-KSNYSR3C.mjs} +5547 -5077
- package/dist/{chunk-F4VCBISU.mjs → chunk-WK6S4HTC.mjs} +97 -42
- package/dist/{chunk-RU4756NG.mjs → chunk-ZR7XJMUN.mjs} +14 -6
- package/dist/cli.mjs +31 -9
- package/dist/editor.d.ts +30 -7
- package/dist/editor.mjs +29 -7
- package/dist/{index-Dx-NpFFx.d.ts → index-4Kyaq3IZ.d.ts} +25 -2
- package/dist/{context-B9yhJxd5.d.ts → index-DSgpB6bS.d.ts} +91 -88
- package/dist/index.d.ts +7 -4
- package/dist/index.mjs +12 -9
- package/dist/{safelist-DAkKuxCk.d.ts → safelist-CGCtF-Fr.d.ts} +1 -1
- package/dist/vite.mjs +19 -7
- package/package.json +1 -1
|
@@ -1,3 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claim resolution for ri() — utility name → CSS properties it sets.
|
|
3
|
+
*
|
|
4
|
+
* Split from merge/index.ts so each merge file is one concept: this file owns
|
|
5
|
+
* the dual-mode dispatch tables and resolvePropsWith(); index.ts owns the
|
|
6
|
+
* merge algorithm; context.ts owns the compilation-context lifecycle.
|
|
7
|
+
*
|
|
8
|
+
* Everything here is immutable module-init data plus pure closures over it —
|
|
9
|
+
* the mutable published compilation state lives in context.ts, and callers
|
|
10
|
+
* thread it in through resolvePropsWith()'s parameters.
|
|
11
|
+
*/
|
|
12
|
+
/** One functional `@utility name-*` root and the properties it claims. Declared
|
|
13
|
+
* here rather than in context.ts so this layer keeps taking its state as
|
|
14
|
+
* parameters instead of importing the context module. */
|
|
15
|
+
type CustomFunctionalEntry = readonly [root: string, properties: readonly string[]];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Compilation-context lifecycle — all mutable state behind ri().
|
|
19
|
+
*
|
|
20
|
+
* The engine creates a CompilationContext via createCompilationContext(),
|
|
21
|
+
* mutates it during compilation (register* functions), then finalizes it so
|
|
22
|
+
* ri() can read the published snapshot without interference from concurrent
|
|
23
|
+
* compilations. Split from merge/index.ts so the merge algorithm stays pure
|
|
24
|
+
* runtime and every piece of mutable state lives in one file.
|
|
25
|
+
*
|
|
26
|
+
* The default ri() cache lives here rather than next to the merge loop
|
|
27
|
+
* because finalizeCompilationContext() must clear it: conflict resolution
|
|
28
|
+
* rules may change between compilations, and stale entries from a previous
|
|
29
|
+
* compilation (with different custom utilities) must never be returned.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
interface CompilationContext {
|
|
33
|
+
customStaticProps: Record<string, string[]>;
|
|
34
|
+
/** Roots of functional `@utility name-*` entries → the properties they set. */
|
|
35
|
+
customFunctionalProps: Record<string, string[]>;
|
|
36
|
+
textSizes: Set<string>;
|
|
37
|
+
fontFamilies: Set<string>;
|
|
38
|
+
colorNames: Set<string>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface CompilationSnapshot {
|
|
42
|
+
readonly customStaticProps: Readonly<Record<string, string[]>>;
|
|
43
|
+
/** Longest root first, so `glow-outer-*` wins over `glow-*` for `glow-outer-4`. */
|
|
44
|
+
readonly customFunctionalProps: readonly CustomFunctionalEntry[];
|
|
45
|
+
readonly textSizes: ReadonlySet<string>;
|
|
46
|
+
readonly fontFamilies: ReadonlySet<string>;
|
|
47
|
+
readonly colorNames: ReadonlySet<string>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a fresh compilation context.
|
|
51
|
+
* Called at the start of each compile() pass.
|
|
52
|
+
*/
|
|
53
|
+
declare function createCompilationContext(): CompilationContext;
|
|
54
|
+
/**
|
|
55
|
+
* Register a custom utility's CSS properties in the compilation context.
|
|
56
|
+
* Called by the engine when processing @utility directives.
|
|
57
|
+
*/
|
|
58
|
+
declare function registerCustomUtility(ctx: CompilationContext, name: string, properties: string[], functional?: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* Register custom text sizes so the merge function correctly classifies
|
|
61
|
+
* text-{custom} as a font-size utility rather than a color utility.
|
|
62
|
+
*/
|
|
63
|
+
declare function registerCustomTextSizes(ctx: CompilationContext, sizes: string[]): void;
|
|
64
|
+
/**
|
|
65
|
+
* Register custom font family names so the merge function correctly classifies
|
|
66
|
+
* font-{custom} as a font-family utility rather than a font-weight utility.
|
|
67
|
+
*/
|
|
68
|
+
declare function registerCustomFontFamilies(ctx: CompilationContext, families: string[]): void;
|
|
69
|
+
/**
|
|
70
|
+
* Register the resolved theme's color names so the merge function classifies
|
|
71
|
+
* bare flat colors (border-accent for `@color { accent: … }`) as color
|
|
72
|
+
* utilities rather than width/weight ones. Shaded forms (accent-500) already
|
|
73
|
+
* match the shade pattern and need no registration.
|
|
74
|
+
*/
|
|
75
|
+
declare function registerColorNames(ctx: CompilationContext, names: string[]): void;
|
|
76
|
+
/**
|
|
77
|
+
* Snapshot compilation context into module-level state that ri() reads from.
|
|
78
|
+
* Called at the end of compile() to atomically publish the new state.
|
|
79
|
+
*/
|
|
80
|
+
declare function finalizeCompilationContext(ctx: CompilationContext): CompilationSnapshot;
|
|
81
|
+
|
|
1
82
|
/**
|
|
2
83
|
* Generative color system — color domain model, OKLCH ramp generation,
|
|
3
84
|
* and light-dark() pairing.
|
|
@@ -57,18 +138,22 @@ interface DarkModeConfig {
|
|
|
57
138
|
}
|
|
58
139
|
|
|
59
140
|
/**
|
|
60
|
-
* Default theme values — the static data that ships if the user writes no
|
|
61
|
-
*
|
|
141
|
+
* Default theme values — the static data that ships if the user writes no
|
|
142
|
+
* directives. Only the colour palette and the spacing base ship a value; every
|
|
143
|
+
* named scale starts empty and is filled by its directive.
|
|
62
144
|
*/
|
|
63
145
|
|
|
64
146
|
interface TextSize {
|
|
65
147
|
fontSize: string;
|
|
66
148
|
lineHeight: string;
|
|
67
149
|
}
|
|
68
|
-
|
|
150
|
+
/** Viewport units, and the container-query units that track a container
|
|
151
|
+
* instead. Keep in step with `FLUID_UNITS` in directives/resolver.ts, which
|
|
152
|
+
* validates the `unit` a `@fluid` block asks for. */
|
|
153
|
+
type FluidUnit = "vw" | "vi" | "vmin" | "vmax" | "cqw" | "cqi" | "cqmin" | "cqmax";
|
|
69
154
|
interface FluidConfig {
|
|
70
|
-
min
|
|
71
|
-
max
|
|
155
|
+
min?: string;
|
|
156
|
+
max?: string;
|
|
72
157
|
unit?: FluidUnit;
|
|
73
158
|
multiplier?: number;
|
|
74
159
|
}
|
|
@@ -103,86 +188,4 @@ type CornerShape = CornerShapeKeyword | {
|
|
|
103
188
|
};
|
|
104
189
|
declare const defaultTheme: Theme;
|
|
105
190
|
|
|
106
|
-
|
|
107
|
-
* Claim resolution for ri() — utility name → CSS properties it sets.
|
|
108
|
-
*
|
|
109
|
-
* Split from merge/index.ts so each merge file is one concept: this file owns
|
|
110
|
-
* the dual-mode dispatch tables and resolvePropsWith(); index.ts owns the
|
|
111
|
-
* merge algorithm; context.ts owns the compilation-context lifecycle.
|
|
112
|
-
*
|
|
113
|
-
* Everything here is immutable module-init data plus pure closures over it —
|
|
114
|
-
* the mutable published compilation state lives in context.ts, and callers
|
|
115
|
-
* thread it in through resolvePropsWith()'s parameters.
|
|
116
|
-
*/
|
|
117
|
-
/** One functional `@utility name-*` root and the properties it claims. Declared
|
|
118
|
-
* here rather than in context.ts so this layer keeps taking its state as
|
|
119
|
-
* parameters instead of importing the context module. */
|
|
120
|
-
type CustomFunctionalEntry = readonly [root: string, properties: readonly string[]];
|
|
121
|
-
declare const DEFAULT_TEXT_SIZES: readonly ["xs", "sm", "base", "lg", "xl", "2xl", "3xl", "4xl", "5xl"];
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Compilation-context lifecycle — all mutable state behind ri().
|
|
125
|
-
*
|
|
126
|
-
* The engine creates a CompilationContext via createCompilationContext(),
|
|
127
|
-
* mutates it during compilation (register* functions), then finalizes it so
|
|
128
|
-
* ri() can read the published snapshot without interference from concurrent
|
|
129
|
-
* compilations. Split from merge/index.ts so the merge algorithm stays pure
|
|
130
|
-
* runtime and every piece of mutable state lives in one file.
|
|
131
|
-
*
|
|
132
|
-
* The default ri() cache lives here rather than next to the merge loop
|
|
133
|
-
* because finalizeCompilationContext() must clear it: conflict resolution
|
|
134
|
-
* rules may change between compilations, and stale entries from a previous
|
|
135
|
-
* compilation (with different custom utilities) must never be returned.
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
interface CompilationContext {
|
|
139
|
-
customStaticProps: Record<string, string[]>;
|
|
140
|
-
/** Roots of functional `@utility name-*` entries → the properties they set. */
|
|
141
|
-
customFunctionalProps: Record<string, string[]>;
|
|
142
|
-
textSizes: Set<string>;
|
|
143
|
-
fontFamilies: Set<string>;
|
|
144
|
-
colorNames: Set<string>;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
interface CompilationSnapshot {
|
|
148
|
-
readonly customStaticProps: Readonly<Record<string, string[]>>;
|
|
149
|
-
/** Longest root first, so `glow-outer-*` wins over `glow-*` for `glow-outer-4`. */
|
|
150
|
-
readonly customFunctionalProps: readonly CustomFunctionalEntry[];
|
|
151
|
-
readonly textSizes: ReadonlySet<string>;
|
|
152
|
-
readonly fontFamilies: ReadonlySet<string>;
|
|
153
|
-
readonly colorNames: ReadonlySet<string>;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Create a fresh compilation context.
|
|
157
|
-
* Called at the start of each compile() pass.
|
|
158
|
-
*/
|
|
159
|
-
declare function createCompilationContext(): CompilationContext;
|
|
160
|
-
/**
|
|
161
|
-
* Register a custom utility's CSS properties in the compilation context.
|
|
162
|
-
* Called by the engine when processing @utility directives.
|
|
163
|
-
*/
|
|
164
|
-
declare function registerCustomUtility(ctx: CompilationContext, name: string, properties: string[], functional?: boolean): void;
|
|
165
|
-
/**
|
|
166
|
-
* Register custom text sizes so the merge function correctly classifies
|
|
167
|
-
* text-{custom} as a font-size utility rather than a color utility.
|
|
168
|
-
*/
|
|
169
|
-
declare function registerCustomTextSizes(ctx: CompilationContext, sizes: string[]): void;
|
|
170
|
-
/**
|
|
171
|
-
* Register custom font family names so the merge function correctly classifies
|
|
172
|
-
* font-{custom} as a font-family utility rather than a font-weight utility.
|
|
173
|
-
*/
|
|
174
|
-
declare function registerCustomFontFamilies(ctx: CompilationContext, families: string[]): void;
|
|
175
|
-
/**
|
|
176
|
-
* Register the resolved theme's color names so the merge function classifies
|
|
177
|
-
* bare flat colors (border-accent for `@color { accent: … }`) as color
|
|
178
|
-
* utilities rather than width/weight ones. Shaded forms (accent-500) already
|
|
179
|
-
* match the shade pattern and need no registration.
|
|
180
|
-
*/
|
|
181
|
-
declare function registerColorNames(ctx: CompilationContext, names: string[]): void;
|
|
182
|
-
/**
|
|
183
|
-
* Snapshot compilation context into module-level state that ri() reads from.
|
|
184
|
-
* Called at the end of compile() to atomically publish the new state.
|
|
185
|
-
*/
|
|
186
|
-
declare function finalizeCompilationContext(ctx: CompilationContext): CompilationSnapshot;
|
|
187
|
-
|
|
188
|
-
export { type AnimationDefinition as A, type ColorDefinition as C, DEFAULT_TEXT_SIZES 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 DarkModeConfig as j, type CornerShape as k, registerColorNames as r };
|
|
191
|
+
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/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { R as ResolvedTheme, P as ParsedDirective } from './index-4Kyaq3IZ.js';
|
|
2
|
+
export { C as CompilationResult, a as CompiledRule, c as createCompiler } from './index-4Kyaq3IZ.js';
|
|
1
3
|
import { PluginCreator } from 'postcss';
|
|
2
|
-
export { C as ColorDefinition, a as CompilationContext, b as CompilationSnapshot,
|
|
3
|
-
export { c as createRi, r as ri, s as safelist } from './safelist-
|
|
4
|
-
import { R as ResolvedTheme, P as ParsedDirective } from './index-Dx-NpFFx.js';
|
|
5
|
-
export { C as CompilationResult, a as CompiledRule, c as createCompiler } from './index-Dx-NpFFx.js';
|
|
4
|
+
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 './index-DSgpB6bS.js';
|
|
5
|
+
export { c as createRi, r as ri, s as safelist } from './safelist-CGCtF-Fr.js';
|
|
6
6
|
|
|
7
7
|
interface RainbowIndexOptions {
|
|
8
8
|
sources?: string[];
|
|
@@ -21,6 +21,9 @@ interface FinalizeProjectResult {
|
|
|
21
21
|
theme: ResolvedTheme;
|
|
22
22
|
directives: ParsedDirective[];
|
|
23
23
|
warnings: string[];
|
|
24
|
+
/** Codes silenced for this entry by `/* ri-disable … *\/`. A consumer that
|
|
25
|
+
* pushes further warnings into `warnings` must push through this too. */
|
|
26
|
+
suppressed: ReadonlySet<string>;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
interface SourceEntry {
|
package/dist/index.mjs
CHANGED
|
@@ -3,19 +3,18 @@ import {
|
|
|
3
3
|
} from "./chunk-PD4ZXGJ6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
postcss_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-3LWJTLOJ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
finalizeProjectCompilation,
|
|
9
9
|
resolveGoogleFonts
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WK6S4HTC.mjs";
|
|
11
11
|
import {
|
|
12
|
-
|
|
12
|
+
analyzeProjectCSSMemo,
|
|
13
13
|
createCompiler,
|
|
14
14
|
extractClassesFromSource,
|
|
15
15
|
pushWarningsDeduped
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KSNYSR3C.mjs";
|
|
17
17
|
import {
|
|
18
|
-
DEFAULT_TEXT_SIZES,
|
|
19
18
|
createCompilationContext,
|
|
20
19
|
createRi,
|
|
21
20
|
defaultTheme,
|
|
@@ -25,11 +24,11 @@ import {
|
|
|
25
24
|
registerCustomTextSizes,
|
|
26
25
|
registerCustomUtility,
|
|
27
26
|
ri
|
|
28
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-6U4IOFOS.mjs";
|
|
29
28
|
|
|
30
29
|
// src/project/index.ts
|
|
31
30
|
async function compileProject(options) {
|
|
32
|
-
const analysis =
|
|
31
|
+
const analysis = analyzeProjectCSSMemo(options.css);
|
|
33
32
|
const classNames = /* @__PURE__ */ new Set();
|
|
34
33
|
if (options.classNames) {
|
|
35
34
|
for (const cls of options.classNames) {
|
|
@@ -44,7 +43,12 @@ async function compileProject(options) {
|
|
|
44
43
|
classNames.add(cls);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
|
-
pushWarningsDeduped(
|
|
46
|
+
pushWarningsDeduped(
|
|
47
|
+
analysis.warnings,
|
|
48
|
+
extractionWarnings,
|
|
49
|
+
analysis.warningSeen,
|
|
50
|
+
analysis.suppressed
|
|
51
|
+
);
|
|
48
52
|
}
|
|
49
53
|
return finalizeProjectCompilation({
|
|
50
54
|
css: options.css,
|
|
@@ -58,7 +62,6 @@ async function compileProject(options) {
|
|
|
58
62
|
});
|
|
59
63
|
}
|
|
60
64
|
export {
|
|
61
|
-
DEFAULT_TEXT_SIZES,
|
|
62
65
|
compileProject,
|
|
63
66
|
createCompilationContext,
|
|
64
67
|
createCompiler,
|
package/dist/vite.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
postcss_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3LWJTLOJ.mjs";
|
|
4
4
|
import {
|
|
5
|
+
disableScanChangeTracking,
|
|
6
|
+
enableScanChangeTracking,
|
|
5
7
|
enableSourceFileListCache,
|
|
6
|
-
invalidateSourceFileListCache
|
|
7
|
-
|
|
8
|
+
invalidateSourceFileListCache,
|
|
9
|
+
markSourceFileChanged
|
|
10
|
+
} from "./chunk-WK6S4HTC.mjs";
|
|
8
11
|
import {
|
|
9
12
|
isSourceFile
|
|
10
13
|
} from "./chunk-3HRMFZGE.mjs";
|
|
@@ -16,11 +19,13 @@ import {
|
|
|
16
19
|
findClosingBrace,
|
|
17
20
|
hasRIActivation,
|
|
18
21
|
isAtRuleBoundary,
|
|
19
|
-
isAtRuleNameChar
|
|
20
|
-
|
|
22
|
+
isAtRuleNameChar,
|
|
23
|
+
parseFileDisables,
|
|
24
|
+
warningCode
|
|
25
|
+
} from "./chunk-KSNYSR3C.mjs";
|
|
21
26
|
import {
|
|
22
27
|
devWarn
|
|
23
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-6U4IOFOS.mjs";
|
|
24
29
|
|
|
25
30
|
// src/integrations/vite.ts
|
|
26
31
|
import { existsSync } from "fs";
|
|
@@ -196,6 +201,9 @@ function rainbowindexVite() {
|
|
|
196
201
|
server.watcher?.on("unlink", invalidateSourceFileListCache);
|
|
197
202
|
server.watcher?.on("unlinkDir", invalidateSourceFileListCache);
|
|
198
203
|
server.httpServer?.once("close", invalidateSourceFileListCache);
|
|
204
|
+
enableScanChangeTracking();
|
|
205
|
+
server.watcher?.on("change", (file) => markSourceFileChanged(file));
|
|
206
|
+
server.httpServer?.once("close", disableScanChangeTracking);
|
|
199
207
|
logger = {
|
|
200
208
|
info: (msg) => server.config.logger?.info?.(msg, { timestamp: true }),
|
|
201
209
|
warn: (msg) => server.config.logger?.warn?.(msg, { timestamp: true })
|
|
@@ -238,8 +246,11 @@ function rainbowindexVite() {
|
|
|
238
246
|
riCSSFiles.add(file);
|
|
239
247
|
let safe = rewriteDirectiveBodies(code);
|
|
240
248
|
const expandWarnings = [];
|
|
241
|
-
safe = expandApplyGroups(safe, expandWarnings);
|
|
249
|
+
safe = expandApplyGroups(safe, expandWarnings, file);
|
|
250
|
+
const suppressed = parseFileDisables(code);
|
|
242
251
|
for (const w of expandWarnings) {
|
|
252
|
+
const warned = warningCode(w);
|
|
253
|
+
if (warned !== null && suppressed.has(warned)) continue;
|
|
243
254
|
(logger?.warn ?? console.warn)(`[rainbowindex] ${w}`);
|
|
244
255
|
}
|
|
245
256
|
return safe !== code ? safe : null;
|
|
@@ -258,6 +269,7 @@ function rainbowindexVite() {
|
|
|
258
269
|
return;
|
|
259
270
|
}
|
|
260
271
|
if (!isSourceFile(file)) return;
|
|
272
|
+
markSourceFileChanged(file);
|
|
261
273
|
const previous = candidateSignatures.get(file);
|
|
262
274
|
let signature;
|
|
263
275
|
try {
|