rainbowindex 0.5.0 → 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 +530 -0
- package/README.md +70 -39
- package/dist/browser.d.ts +2 -2
- package/dist/browser.mjs +1 -3
- package/dist/{chunk-CMB6BHVE.mjs → chunk-3LWJTLOJ.mjs} +62 -38
- package/dist/{chunk-KRZL4IDK.mjs → chunk-6U4IOFOS.mjs} +687 -859
- package/dist/{chunk-ZI5ZYNSU.mjs → chunk-KSNYSR3C.mjs} +5629 -5092
- package/dist/{chunk-DT5HYIM3.mjs → chunk-WK6S4HTC.mjs} +978 -901
- package/dist/{chunk-NXJZX6KI.mjs → chunk-ZR7XJMUN.mjs} +15 -8
- package/dist/cli.mjs +34 -11
- package/dist/editor.d.ts +35 -9
- package/dist/editor.mjs +34 -8
- package/dist/{index-Dp6i5TSv.d.ts → index-4Kyaq3IZ.d.ts} +29 -6
- package/dist/{context-ruu2x_jR.d.ts → index-DSgpB6bS.d.ts} +90 -69
- package/dist/index.d.ts +7 -4
- package/dist/index.mjs +14 -9
- package/dist/oxlint.d.ts +55 -0
- package/dist/oxlint.mjs +38 -0
- package/dist/{safelist-D9-Plqta.d.ts → safelist-CGCtF-Fr.d.ts} +2 -15
- package/dist/vite.mjs +67 -14
- package/package.json +7 -1
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
codepointCompare,
|
|
16
16
|
parseUtility,
|
|
17
17
|
resolveUtilityDeclarations
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KSNYSR3C.mjs";
|
|
19
19
|
import {
|
|
20
20
|
SPECIAL_COLORS
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-6U4IOFOS.mjs";
|
|
22
22
|
|
|
23
23
|
// src/project/css-entry.ts
|
|
24
24
|
var CSS_ENTRY_CANDIDATES = Object.freeze([
|
|
@@ -70,6 +70,8 @@ var FRACTION_SAMPLES = Object.freeze([
|
|
|
70
70
|
"5/6"
|
|
71
71
|
]);
|
|
72
72
|
var INT_SAMPLES = Object.freeze(["0", "1", "2", "3", "4", "6", "8", "10", "12"]);
|
|
73
|
+
var INT_RE = /^\d+$/;
|
|
74
|
+
var WEIGHT_STEPS = Object.freeze(["100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
73
75
|
var PERCENT_SAMPLES = Object.freeze([
|
|
74
76
|
"0",
|
|
75
77
|
"5",
|
|
@@ -94,6 +96,7 @@ var ROUNDED_SIDES = Object.freeze([
|
|
|
94
96
|
...ROUNDED_SIDE_NAMES,
|
|
95
97
|
...ROUNDED_CORNER_NAMES
|
|
96
98
|
]);
|
|
99
|
+
var RADIUS_SAMPLES = Object.freeze([...SPACING_SAMPLES, "none", "full"]);
|
|
97
100
|
function buildValueSpaces() {
|
|
98
101
|
const table = /* @__PURE__ */ new Map();
|
|
99
102
|
for (const { roots, spec } of ROOT_GROUPS) {
|
|
@@ -136,18 +139,22 @@ function candidateValues(kind, theme) {
|
|
|
136
139
|
return Object.keys(theme.text);
|
|
137
140
|
case "fluid-text-size":
|
|
138
141
|
return Object.keys(theme.text).map((size) => `fluid-${size}`);
|
|
142
|
+
case "fluid-range":
|
|
143
|
+
return Object.keys(theme.fluidRanges);
|
|
139
144
|
case "font-slot":
|
|
140
145
|
return [.../* @__PURE__ */ new Set([...BUILTIN_FONT_SLOTS, ...theme.fonts.map((slot) => slot.slot)])];
|
|
141
146
|
case "weight":
|
|
142
|
-
return Object.keys(theme.weights);
|
|
147
|
+
return [...Object.keys(theme.weights), ...WEIGHT_STEPS];
|
|
148
|
+
// Named @rounded radii plus the spacing multiples, the way @weight pairs
|
|
149
|
+
// its tokens with the numeric steps. Without the names, `rounded-roof`
|
|
150
|
+
// compiles but is offered by neither completions nor generated types.
|
|
143
151
|
case "rounded":
|
|
144
|
-
return Object.keys(theme.
|
|
152
|
+
return [...Object.keys(theme.radii), ...RADIUS_SAMPLES];
|
|
145
153
|
case "rounded-side": {
|
|
146
|
-
const tokens = Object.keys(theme.rounded);
|
|
147
154
|
const out = [];
|
|
155
|
+
const sizes = [...Object.keys(theme.radii), ...RADIUS_SAMPLES];
|
|
148
156
|
for (const side of ROUNDED_SIDES) {
|
|
149
|
-
out.push(side);
|
|
150
|
-
for (const token of tokens) out.push(`${side}-${token}`);
|
|
157
|
+
for (const size of sizes) out.push(`${side}-${size}`);
|
|
151
158
|
}
|
|
152
159
|
return out;
|
|
153
160
|
}
|
|
@@ -223,7 +230,7 @@ function enumerateClassNames(theme) {
|
|
|
223
230
|
seen.add(name);
|
|
224
231
|
classes.push({ name, kind, root });
|
|
225
232
|
if (kind === "spacing") spacingHit = true;
|
|
226
|
-
if (kind === "int") intHit = true;
|
|
233
|
+
if (kind === "int" || kind === "weight" && INT_RE.test(value)) intHit = true;
|
|
227
234
|
}
|
|
228
235
|
}
|
|
229
236
|
for (const keyword of spec.keywords ?? []) {
|
package/dist/cli.mjs
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CSS_ENTRY_CANDIDATES,
|
|
4
4
|
enumerateClassNames
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZR7XJMUN.mjs";
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_EXCLUDES,
|
|
8
8
|
DEFAULT_PATTERNS,
|
|
9
9
|
compileScannedProject,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
disableScanChangeTracking,
|
|
11
|
+
enableScanChangeTracking,
|
|
12
|
+
enableSourceFileListCache,
|
|
13
|
+
getFontPreloadLinks,
|
|
14
|
+
invalidateSourceFileListCache,
|
|
15
|
+
markSourceFileChanged
|
|
16
|
+
} from "./chunk-WK6S4HTC.mjs";
|
|
12
17
|
import {
|
|
13
18
|
MAX_DIRECTIVE_INPUT_SIZE,
|
|
14
19
|
codepointCompare,
|
|
@@ -18,10 +23,10 @@ import {
|
|
|
18
23
|
hasRIActivation,
|
|
19
24
|
listVariants,
|
|
20
25
|
resolveDirectives
|
|
21
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-KSNYSR3C.mjs";
|
|
22
27
|
import {
|
|
23
28
|
devWarn
|
|
24
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-6U4IOFOS.mjs";
|
|
25
30
|
|
|
26
31
|
// src/entries/cli.ts
|
|
27
32
|
import { realpathSync } from "fs";
|
|
@@ -177,8 +182,9 @@ Examples:
|
|
|
177
182
|
flags: [CSS_INPUT_FONTS],
|
|
178
183
|
positionals: "none",
|
|
179
184
|
body: `Output:
|
|
180
|
-
Prints <link rel="preload"> tags to stdout
|
|
181
|
-
|
|
185
|
+
Prints <link rel="preload"> tags to stdout, one per @font face marked
|
|
186
|
+
preload. Only local-file and raw-URL faces qualify \u2014 Google serves CSS, not
|
|
187
|
+
the font binary, so a Google or system slot never produces a tag.
|
|
182
188
|
|
|
183
189
|
Examples:
|
|
184
190
|
rainbowindex preload-fonts --css src/styles.css > preload.html`
|
|
@@ -433,6 +439,7 @@ async function buildCSS(opts, cwd) {
|
|
|
433
439
|
const { css: cssSource, cssFile } = await loadProjectCSS(opts, cwd);
|
|
434
440
|
const { compiled } = await compileScannedProject({
|
|
435
441
|
css: cssSource,
|
|
442
|
+
cssPath: cssFile ?? void 0,
|
|
436
443
|
cwd,
|
|
437
444
|
surfacePatterns: opts.globs,
|
|
438
445
|
onInvalidPattern: (err) => {
|
|
@@ -764,9 +771,23 @@ async function watchMode(opts, cwd) {
|
|
|
764
771
|
currentBuild = runBuild();
|
|
765
772
|
}, delay);
|
|
766
773
|
};
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
watcher.on("
|
|
774
|
+
enableSourceFileListCache();
|
|
775
|
+
enableScanChangeTracking();
|
|
776
|
+
watcher.on("change", (file) => {
|
|
777
|
+
markSourceFileChanged(file, cwd);
|
|
778
|
+
scheduleRebuild();
|
|
779
|
+
});
|
|
780
|
+
watcher.on("add", (file) => {
|
|
781
|
+
invalidateSourceFileListCache();
|
|
782
|
+
markSourceFileChanged(file, cwd);
|
|
783
|
+
scheduleRebuild();
|
|
784
|
+
});
|
|
785
|
+
watcher.on("unlink", (file) => {
|
|
786
|
+
invalidateSourceFileListCache();
|
|
787
|
+
markSourceFileChanged(file, cwd);
|
|
788
|
+
scheduleRebuild();
|
|
789
|
+
});
|
|
790
|
+
watcher.on("unlinkDir", invalidateSourceFileListCache);
|
|
770
791
|
watcher.on("error", (err) => {
|
|
771
792
|
console.error("[rainbowindex] Watcher error:", err);
|
|
772
793
|
});
|
|
@@ -776,6 +797,8 @@ async function watchMode(opts, cwd) {
|
|
|
776
797
|
cleanupCalled = true;
|
|
777
798
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
778
799
|
dirty = false;
|
|
800
|
+
invalidateSourceFileListCache();
|
|
801
|
+
disableScanChangeTracking();
|
|
779
802
|
const doExit = () => {
|
|
780
803
|
watcher.close().then(() => {
|
|
781
804
|
console.log("\n[rainbowindex] Watcher stopped.");
|
|
@@ -1288,7 +1311,7 @@ function readPackageJSONSync(cwd) {
|
|
|
1288
1311
|
|
|
1289
1312
|
// src/entries/cli.ts
|
|
1290
1313
|
function getVersion() {
|
|
1291
|
-
return true ? "0.
|
|
1314
|
+
return true ? "0.6.0" : "unknown";
|
|
1292
1315
|
}
|
|
1293
1316
|
async function main() {
|
|
1294
1317
|
const args = process.argv.slice(2);
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { P as ParsedDirective, R as ResolvedTheme } from './index-
|
|
2
|
-
export { b as createThemeSnapshot } from './index-
|
|
3
|
-
import { b as CompilationSnapshot, C as ColorDefinition } from './
|
|
4
|
-
export { e as defaultTheme } from './
|
|
1
|
+
import { P as ParsedDirective, R as ResolvedTheme } from './index-4Kyaq3IZ.js';
|
|
2
|
+
export { b as createThemeSnapshot, d as describeLoadedWeights, w as weightIsLoaded } from './index-4Kyaq3IZ.js';
|
|
3
|
+
import { b as CompilationSnapshot, C as ColorDefinition } from './index-DSgpB6bS.js';
|
|
4
|
+
export { e as defaultTheme } from './index-DSgpB6bS.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/** Where a candidate was found. "expression" marks a string literal sitting
|
|
7
|
+
* in a JS expression position that cannot be a class list — today, an
|
|
8
|
+
* operand of `==`/`!=` (`mode === "default"`). It is NOT a certain origin:
|
|
9
|
+
* editors should treat it like "plain" and never report it as a bad class. */
|
|
10
|
+
type CandidateOrigin = "attribute" | "helper" | "safelist" | "plain" | "expression";
|
|
7
11
|
interface ClassCandidate {
|
|
8
12
|
/** The class string in expanded form — for variant-group members this
|
|
9
13
|
* includes the group prefix (`hover:bg-red-500`) even though the span
|
|
@@ -40,7 +44,7 @@ declare const CLASS_HELPER_NAMES: readonly string[];
|
|
|
40
44
|
declare const VARIANT_HELPER_NAMES: readonly string[];
|
|
41
45
|
declare function extractClasses(source: string, warnings?: string[]): Set<string>;
|
|
42
46
|
|
|
43
|
-
declare function expandVariantGroups(input: string, warnings?: string[]): string;
|
|
47
|
+
declare function expandVariantGroups(input: string, warnings?: string[], path?: string): string;
|
|
44
48
|
|
|
45
49
|
interface SourceExtractionInput {
|
|
46
50
|
path?: string;
|
|
@@ -140,9 +144,23 @@ interface ProjectAnalysis {
|
|
|
140
144
|
* at-rule, resolver problems at the directive whose body produced them.
|
|
141
145
|
*/
|
|
142
146
|
diagnostics: Diagnostic[];
|
|
147
|
+
/**
|
|
148
|
+
* Codes silenced for the whole entry by `/* ri-disable … *\/`. Later stages
|
|
149
|
+
* push through this so a code the author hid never reaches the caller —
|
|
150
|
+
* scanner and compile warnings included, which no stylesheet comment could
|
|
151
|
+
* reach by position.
|
|
152
|
+
*/
|
|
153
|
+
suppressed: ReadonlySet<string>;
|
|
143
154
|
}
|
|
144
155
|
declare function analyzeProjectCSS(css: string): ProjectAnalysis;
|
|
145
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Fatal bootstrap (RI-00xx) and runtime (RI-20xx) codes are never silenceable.
|
|
159
|
+
* They report a broken build or a broken call, not a style choice, and a
|
|
160
|
+
* stylesheet that could hide them would hide the reason the build failed.
|
|
161
|
+
*/
|
|
162
|
+
declare function isSuppressible(code: string): boolean;
|
|
163
|
+
|
|
146
164
|
/**
|
|
147
165
|
* Parses utility class strings into structured tokens.
|
|
148
166
|
*
|
|
@@ -305,7 +323,7 @@ declare function findClosest(input: string, candidates: string[], maxDistance?:
|
|
|
305
323
|
* per-root resolver order fixes which generator wins a contested root.
|
|
306
324
|
*/
|
|
307
325
|
|
|
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";
|
|
326
|
+
type ValueSpaceKind = "color" | "special-color" | "spacing" | "fraction" | "text-size" | "fluid-text-size" | "font-slot" | "weight" | "rounded" | "rounded-side" | "shadow" | "z" | "ease" | "blur" | "animation" | "leading" | "fluid-range" | "tracking" | "opacity" | "duration" | "breakpoint" | "int" | "percent" | "keywords";
|
|
309
327
|
interface ValueSpaceSpec {
|
|
310
328
|
kinds: readonly ValueSpaceKind[];
|
|
311
329
|
/** Extra value parts to try verbatim (for "keywords" and beyond). */
|
|
@@ -455,7 +473,6 @@ interface ThemeTokens {
|
|
|
455
473
|
lineHeight: string;
|
|
456
474
|
}>;
|
|
457
475
|
breakpoints: Record<string, string>;
|
|
458
|
-
rounded: Record<string, string>;
|
|
459
476
|
shadows: Record<string, string>;
|
|
460
477
|
weights: Record<string, number>;
|
|
461
478
|
easing: Record<string, string>;
|
|
@@ -465,6 +482,15 @@ interface ThemeTokens {
|
|
|
465
482
|
tracking: Record<string, string>;
|
|
466
483
|
opacity: Record<string, string>;
|
|
467
484
|
duration: Record<string, string>;
|
|
485
|
+
/** Named radii from `@rounded { roof: 24px; }` — the class is `rounded-roof`.
|
|
486
|
+
* Unnamed radii are spacing multiples and carry no token. */
|
|
487
|
+
radii: Record<string, string>;
|
|
488
|
+
/** Named ranges from `@fluid <name> { min; max; }` — each one makes the scope
|
|
489
|
+
* class `fluid-<name>`. A bound absent from the block is absent here. */
|
|
490
|
+
fluidRanges: Record<string, {
|
|
491
|
+
min?: string;
|
|
492
|
+
max?: string;
|
|
493
|
+
}>;
|
|
468
494
|
fonts: Array<{
|
|
469
495
|
slot: string;
|
|
470
496
|
family: string;
|
|
@@ -539,4 +565,4 @@ declare const EDITOR_API_VERSION = 1;
|
|
|
539
565
|
/** Feature-detection roster for this entry. */
|
|
540
566
|
declare const editorCapabilities: readonly string[];
|
|
541
567
|
|
|
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 };
|
|
568
|
+
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, isSuppressible, listThemeTokens, listVariants, oklchToHex, parseUtility, resolveColorSwatch, severityForCode, version, warningCode };
|
package/dist/editor.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
CSS_ENTRY_CANDIDATES,
|
|
3
3
|
UTILITY_VALUE_SPACES,
|
|
4
4
|
enumerateClassNames
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZR7XJMUN.mjs";
|
|
6
6
|
import {
|
|
7
7
|
isSourceFile
|
|
8
8
|
} from "./chunk-3HRMFZGE.mjs";
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
compileUtility,
|
|
17
17
|
createEmptyCompilationResult,
|
|
18
18
|
createThemeSnapshot,
|
|
19
|
+
describeLoadedWeights,
|
|
19
20
|
diagnosticFromWarning,
|
|
20
21
|
expandVariantGroups,
|
|
21
22
|
extractClassCandidates,
|
|
@@ -23,11 +24,13 @@ import {
|
|
|
23
24
|
extractClassesFromSource,
|
|
24
25
|
findClosest,
|
|
25
26
|
hasRIActivation,
|
|
27
|
+
isSuppressible,
|
|
26
28
|
listVariants,
|
|
27
29
|
parseUtility,
|
|
28
30
|
severityForCode,
|
|
29
|
-
warningCode
|
|
30
|
-
|
|
31
|
+
warningCode,
|
|
32
|
+
weightIsLoaded
|
|
33
|
+
} from "./chunk-KSNYSR3C.mjs";
|
|
31
34
|
import {
|
|
32
35
|
computeDarkStop,
|
|
33
36
|
defaultTheme,
|
|
@@ -38,7 +41,7 @@ import {
|
|
|
38
41
|
oklabToLinearSrgb,
|
|
39
42
|
oklchToOklab,
|
|
40
43
|
resolverFor
|
|
41
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-6U4IOFOS.mjs";
|
|
42
45
|
|
|
43
46
|
// src/engine/inspector.ts
|
|
44
47
|
var RESOLUTION_CACHE_CAP = 1e4;
|
|
@@ -307,7 +310,6 @@ function listThemeTokens(theme) {
|
|
|
307
310
|
lineHeight: def.lineHeight
|
|
308
311
|
})),
|
|
309
312
|
breakpoints: { ...theme.breakpoints },
|
|
310
|
-
rounded: { ...theme.rounded },
|
|
311
313
|
shadows: { ...theme.shadows },
|
|
312
314
|
weights: { ...theme.weights },
|
|
313
315
|
easing: { ...theme.easing },
|
|
@@ -317,6 +319,13 @@ function listThemeTokens(theme) {
|
|
|
317
319
|
tracking: { ...theme.tracking },
|
|
318
320
|
opacity: { ...theme.opacity },
|
|
319
321
|
duration: { ...theme.duration },
|
|
322
|
+
radii: { ...theme.radii },
|
|
323
|
+
fluidRanges: Object.fromEntries(
|
|
324
|
+
Object.entries(theme.fluidRanges).map(([name, range]) => [
|
|
325
|
+
name,
|
|
326
|
+
{ min: range.min, max: range.max }
|
|
327
|
+
])
|
|
328
|
+
),
|
|
320
329
|
fonts: theme.fonts.map((slot) => ({ slot: slot.slot, family: slot.family })),
|
|
321
330
|
animations: Object.keys(theme.animations)
|
|
322
331
|
};
|
|
@@ -383,11 +392,16 @@ function createEditorSession(options = {}) {
|
|
|
383
392
|
}
|
|
384
393
|
|
|
385
394
|
// src/entries/editor.ts
|
|
386
|
-
var version = true ? "0.
|
|
395
|
+
var version = true ? "0.6.0" : "0.0.0-dev";
|
|
387
396
|
var EDITOR_API_VERSION = 1;
|
|
388
397
|
var editorCapabilities = Object.freeze([
|
|
389
398
|
"class-candidates",
|
|
390
399
|
"candidate-call-ids",
|
|
400
|
+
// A candidate carries a certain origin only when a context-aware collector
|
|
401
|
+
// tokenized it, so bare JS identifiers stay "plain"; equality operands
|
|
402
|
+
// report the "expression" origin. Without this, position alone decided,
|
|
403
|
+
// and `ri(mode === "x" ? …)` reported `mode` as a helper-origin class.
|
|
404
|
+
"candidate-origin-provenance",
|
|
391
405
|
"css-entry-detection",
|
|
392
406
|
"theme-analysis",
|
|
393
407
|
"class-inspection",
|
|
@@ -396,7 +410,16 @@ var editorCapabilities = Object.freeze([
|
|
|
396
410
|
"merge-analysis",
|
|
397
411
|
"structured-diagnostics",
|
|
398
412
|
"color-swatches",
|
|
399
|
-
"editor-session"
|
|
413
|
+
"editor-session",
|
|
414
|
+
// `isSuppressible` — which diagnostic codes a `ri-disable` comment may name,
|
|
415
|
+
// so an editor can offer the comment only where it would work.
|
|
416
|
+
"diagnostic-suppression",
|
|
417
|
+
// `ThemeTokens.radii` and `ThemeTokens.fluidRanges`, for the named radii and
|
|
418
|
+
// named `@fluid` ranges that carry no token before this release.
|
|
419
|
+
"named-radii-and-fluid-ranges",
|
|
420
|
+
// `weightIsLoaded` / `describeLoadedWeights` — the RI-1504 coverage check,
|
|
421
|
+
// so an editor can answer "does any loaded font have this weight?".
|
|
422
|
+
"font-weight-coverage"
|
|
400
423
|
]);
|
|
401
424
|
export {
|
|
402
425
|
CANONICAL_COLOR_STOPS,
|
|
@@ -413,6 +436,7 @@ export {
|
|
|
413
436
|
createThemeSnapshot,
|
|
414
437
|
cssColorToHex,
|
|
415
438
|
defaultTheme,
|
|
439
|
+
describeLoadedWeights,
|
|
416
440
|
diagnosticFromWarning,
|
|
417
441
|
editorCapabilities,
|
|
418
442
|
enumerateClassNames,
|
|
@@ -423,6 +447,7 @@ export {
|
|
|
423
447
|
findClosest,
|
|
424
448
|
hasRIActivation,
|
|
425
449
|
isSourceFile,
|
|
450
|
+
isSuppressible,
|
|
426
451
|
listThemeTokens,
|
|
427
452
|
listVariants,
|
|
428
453
|
oklchToHex,
|
|
@@ -430,5 +455,6 @@ export {
|
|
|
430
455
|
resolveColorSwatch,
|
|
431
456
|
severityForCode,
|
|
432
457
|
version,
|
|
433
|
-
warningCode
|
|
458
|
+
warningCode,
|
|
459
|
+
weightIsLoaded
|
|
434
460
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ColorDefinition, D as DarkModeConfig, j as CornerShape, A as AnimationDefinition, F as FluidConfig, b as CompilationSnapshot } from './
|
|
1
|
+
import { C as ColorDefinition, D as DarkModeConfig, j as CornerShape, A as AnimationDefinition, F as FluidConfig, b as CompilationSnapshot } from './index-DSgpB6bS.js';
|
|
2
2
|
|
|
3
3
|
/** Provider discriminant for a slot, derived from its faces. */
|
|
4
4
|
type FontProviderKind = "google" | "system" | "local" | "manual";
|
|
@@ -57,6 +57,21 @@ interface FontMetricsConfig {
|
|
|
57
57
|
descent?: number;
|
|
58
58
|
lineGap?: number;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Whether any loaded font can render `weight` — the check behind RI-1504.
|
|
62
|
+
*
|
|
63
|
+
* A slot's faces are the authority: their `weight` descriptor is exactly what
|
|
64
|
+
* the emitted @font-face (or the Google URL) asks for, so a weight outside it
|
|
65
|
+
* is a weight the browser has to synthesize.
|
|
66
|
+
*
|
|
67
|
+
* Deliberately fails open, since `font-<n>` names no family and a page can
|
|
68
|
+
* load several: no faces to check, a system/manual slot (the OS font carries
|
|
69
|
+
* every weight), or a single covering slot all count as available.
|
|
70
|
+
*/
|
|
71
|
+
declare function weightIsLoaded(weight: number, fonts: readonly FontSlot[]): boolean;
|
|
72
|
+
/** Human-readable weight inventory for the RI-1504 message:
|
|
73
|
+
* `Inter 300–900; Fira Code 400, 700`. */
|
|
74
|
+
declare function describeLoadedWeights(fonts: readonly FontSlot[]): string;
|
|
60
75
|
|
|
61
76
|
/**
|
|
62
77
|
* Font loading system — @font directive processing, @font-face generation,
|
|
@@ -149,8 +164,6 @@ interface ResolvedTheme {
|
|
|
149
164
|
base: string;
|
|
150
165
|
}>;
|
|
151
166
|
readonly breakpoints: Readonly<Record<string, string>>;
|
|
152
|
-
readonly rounded: Readonly<Record<string, string>>;
|
|
153
|
-
readonly roundedRoof: string;
|
|
154
167
|
/**
|
|
155
168
|
* Corner shape set via `@rounded <shape>`. `null` means no shape was configured —
|
|
156
169
|
* the compiler emits neither a `corner-shape` rule nor the fallback `@supports not`
|
|
@@ -167,6 +180,10 @@ interface ResolvedTheme {
|
|
|
167
180
|
* `roundedShape` is null.
|
|
168
181
|
*/
|
|
169
182
|
readonly roundedShapeScale: number;
|
|
183
|
+
/** Named radii from `@rounded { roof: 24px; }` — each one makes the class
|
|
184
|
+
* `rounded-<name>` and the token `--rounded-<name>`. A name that matches a
|
|
185
|
+
* built-in radius keyword replaces it; RI-1124 warns at definition. */
|
|
186
|
+
readonly radii: Readonly<Record<string, string>>;
|
|
170
187
|
readonly shadows: Readonly<Record<string, string>>;
|
|
171
188
|
readonly weights: Readonly<Record<string, number>>;
|
|
172
189
|
readonly easing: Readonly<Record<string, string>>;
|
|
@@ -176,6 +193,10 @@ interface ResolvedTheme {
|
|
|
176
193
|
readonly fluid: Readonly<FluidConfig>;
|
|
177
194
|
readonly textFluid?: Readonly<FluidConfig>;
|
|
178
195
|
readonly spacingFluid?: Readonly<FluidConfig>;
|
|
196
|
+
/** Named viewport ranges from `@fluid <name> { min; max; }` — each one makes
|
|
197
|
+
* the scope class `fluid-<name>` and the tokens `--fluid-<name>-{min,max}`.
|
|
198
|
+
* Ranges carry no unit: the ramp unit is baked per family. */
|
|
199
|
+
readonly fluidRanges: Readonly<Record<string, Readonly<FluidConfig>>>;
|
|
179
200
|
readonly fonts: readonly FontSlot[];
|
|
180
201
|
readonly preflight: Readonly<PreflightConfig>;
|
|
181
202
|
readonly customUtilities: readonly CustomUtility[];
|
|
@@ -213,7 +234,6 @@ interface CompilationResult {
|
|
|
213
234
|
/** Set of used font slot names (for token pruning). */
|
|
214
235
|
usedFonts: Set<string>;
|
|
215
236
|
/** Set of used rounded value names (for token pruning). */
|
|
216
|
-
usedRounded: Set<string>;
|
|
217
237
|
/** Set of used shadow names (for token pruning). */
|
|
218
238
|
usedShadows: Set<string>;
|
|
219
239
|
/** Set of used animation shorthand names (for token pruning). */
|
|
@@ -254,11 +274,14 @@ declare function createThemeSnapshot(theme: ResolvedTheme): CompilationSnapshot;
|
|
|
254
274
|
* ```
|
|
255
275
|
*/
|
|
256
276
|
declare function createCompiler(): {
|
|
257
|
-
|
|
277
|
+
/** `authored` names the classes the user wrote by hand (`@source inline`,
|
|
278
|
+
* `@apply`, a caller-supplied list). Omit it to treat every class as
|
|
279
|
+
* authored — correct for callers who assembled the list themselves. */
|
|
280
|
+
compile: (classNames: Iterable<string>, theme: ResolvedTheme, authored?: ReadonlySet<string>) => CompilationResult;
|
|
258
281
|
createRi: () => (...inputs: (string | false | null | undefined)[]) => string;
|
|
259
282
|
/** Isolated font output cache for this compiler instance. Pass to
|
|
260
283
|
* `assembleSections()` to avoid sharing module-level font state. */
|
|
261
284
|
fontOutputCache: Map<string, FontOutput>;
|
|
262
285
|
};
|
|
263
286
|
|
|
264
|
-
export { type CompilationResult as C, type ParsedDirective as P, type ResolvedTheme as R, type CompiledRule as a, createThemeSnapshot as b, createCompiler as c };
|
|
287
|
+
export { type CompilationResult as C, type ParsedDirective as P, type ResolvedTheme as R, type CompiledRule as a, createThemeSnapshot as b, createCompiler as c, describeLoadedWeights as d, weightIsLoaded as w };
|
|
@@ -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
|
}
|
|
@@ -83,7 +168,6 @@ interface Theme {
|
|
|
83
168
|
colors: Record<string, ColorDefinition>;
|
|
84
169
|
text: Record<string, TextSize>;
|
|
85
170
|
breakpoints: Record<string, string>;
|
|
86
|
-
rounded: Record<string, string>;
|
|
87
171
|
shadows: Record<string, string>;
|
|
88
172
|
weights: Record<string, number>;
|
|
89
173
|
easing: Record<string, string>;
|
|
@@ -104,67 +188,4 @@ type CornerShape = CornerShapeKeyword | {
|
|
|
104
188
|
};
|
|
105
189
|
declare const defaultTheme: Theme;
|
|
106
190
|
|
|
107
|
-
/**
|
|
108
|
-
* Compilation-context lifecycle — all mutable state behind ri().
|
|
109
|
-
*
|
|
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.
|
|
115
|
-
*
|
|
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.
|
|
120
|
-
*/
|
|
121
|
-
interface CompilationContext {
|
|
122
|
-
customStaticProps: Record<string, string[]>;
|
|
123
|
-
textSizes: Set<string>;
|
|
124
|
-
fontFamilies: Set<string>;
|
|
125
|
-
colorNames: Set<string>;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Frozen snapshot of compilation state for SSR-safe ri() instances.
|
|
129
|
-
* Created by finalizeCompilationContext() and consumed by createRi().
|
|
130
|
-
*/
|
|
131
|
-
interface CompilationSnapshot {
|
|
132
|
-
readonly customStaticProps: Readonly<Record<string, string[]>>;
|
|
133
|
-
readonly textSizes: ReadonlySet<string>;
|
|
134
|
-
readonly fontFamilies: ReadonlySet<string>;
|
|
135
|
-
readonly colorNames: ReadonlySet<string>;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Create a fresh compilation context.
|
|
139
|
-
* Called at the start of each compile() pass.
|
|
140
|
-
*/
|
|
141
|
-
declare function createCompilationContext(): CompilationContext;
|
|
142
|
-
/**
|
|
143
|
-
* Register a custom utility's CSS properties in the compilation context.
|
|
144
|
-
* Called by the engine when processing @utility directives.
|
|
145
|
-
*/
|
|
146
|
-
declare function registerCustomUtility(ctx: CompilationContext, name: string, properties: string[]): void;
|
|
147
|
-
/**
|
|
148
|
-
* Register custom text sizes so the merge function correctly classifies
|
|
149
|
-
* text-{custom} as a font-size utility rather than a color utility.
|
|
150
|
-
*/
|
|
151
|
-
declare function registerCustomTextSizes(ctx: CompilationContext, sizes: string[]): void;
|
|
152
|
-
/**
|
|
153
|
-
* Register custom font family names so the merge function correctly classifies
|
|
154
|
-
* font-{custom} as a font-family utility rather than a font-weight utility.
|
|
155
|
-
*/
|
|
156
|
-
declare function registerCustomFontFamilies(ctx: CompilationContext, families: string[]): void;
|
|
157
|
-
/**
|
|
158
|
-
* Register the resolved theme's color names so the merge function classifies
|
|
159
|
-
* bare flat colors (border-accent for `@color { accent: … }`) as color
|
|
160
|
-
* utilities rather than width/weight ones. Shaded forms (accent-500) already
|
|
161
|
-
* match the shade pattern and need no registration.
|
|
162
|
-
*/
|
|
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
|
-
*/
|
|
168
|
-
declare function finalizeCompilationContext(ctx: CompilationContext): CompilationSnapshot;
|
|
169
|
-
|
|
170
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, 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 './
|
|
3
|
-
export {
|
|
4
|
-
import { R as ResolvedTheme, P as ParsedDirective } from './index-Dp6i5TSv.js';
|
|
5
|
-
export { C as CompilationResult, a as CompiledRule, c as createCompiler } from './index-Dp6i5TSv.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 {
|