rainbowindex 0.4.1 → 0.5.1
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 +268 -0
- package/README.md +66 -37
- package/dist/browser.d.ts +2 -2
- package/dist/browser.mjs +1 -1
- package/dist/{chunk-IYIUS7AE.mjs → chunk-4CTJLMYM.mjs} +47 -29
- package/dist/{chunk-KRZL4IDK.mjs → chunk-4UKFK2GE.mjs} +62 -47
- package/dist/{chunk-53WD6U2X.mjs → chunk-F4VCBISU.mjs} +895 -880
- package/dist/{chunk-6GTG5SZJ.mjs → chunk-PDORZSQX.mjs} +244 -159
- package/dist/{chunk-WYMCN5OC.mjs → chunk-RU4756NG.mjs} +5 -6
- package/dist/cli.mjs +96 -40
- package/dist/{context-ruu2x_jR.d.ts → context-B9yhJxd5.d.ts} +26 -8
- package/dist/editor.d.ts +9 -6
- package/dist/editor.mjs +9 -5
- package/dist/{index-Dp6i5TSv.d.ts → index-Dx-NpFFx.d.ts} +5 -5
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +6 -4
- package/dist/oxlint.d.ts +55 -0
- package/dist/oxlint.mjs +38 -0
- package/dist/{safelist-D9-Plqta.d.ts → safelist-DAkKuxCk.d.ts} +2 -15
- package/dist/vite.mjs +53 -12
- 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-PDORZSQX.mjs";
|
|
19
19
|
import {
|
|
20
20
|
SPECIAL_COLORS
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-4UKFK2GE.mjs";
|
|
22
22
|
|
|
23
23
|
// src/project/css-entry.ts
|
|
24
24
|
var CSS_ENTRY_CANDIDATES = Object.freeze([
|
|
@@ -94,6 +94,7 @@ var ROUNDED_SIDES = Object.freeze([
|
|
|
94
94
|
...ROUNDED_SIDE_NAMES,
|
|
95
95
|
...ROUNDED_CORNER_NAMES
|
|
96
96
|
]);
|
|
97
|
+
var RADIUS_SAMPLES = Object.freeze([...SPACING_SAMPLES, "none", "full"]);
|
|
97
98
|
function buildValueSpaces() {
|
|
98
99
|
const table = /* @__PURE__ */ new Map();
|
|
99
100
|
for (const { roots, spec } of ROOT_GROUPS) {
|
|
@@ -141,13 +142,11 @@ function candidateValues(kind, theme) {
|
|
|
141
142
|
case "weight":
|
|
142
143
|
return Object.keys(theme.weights);
|
|
143
144
|
case "rounded":
|
|
144
|
-
return
|
|
145
|
+
return [...RADIUS_SAMPLES];
|
|
145
146
|
case "rounded-side": {
|
|
146
|
-
const tokens = Object.keys(theme.rounded);
|
|
147
147
|
const out = [];
|
|
148
148
|
for (const side of ROUNDED_SIDES) {
|
|
149
|
-
out.push(side);
|
|
150
|
-
for (const token of tokens) out.push(`${side}-${token}`);
|
|
149
|
+
for (const size of RADIUS_SAMPLES) out.push(`${side}-${size}`);
|
|
151
150
|
}
|
|
152
151
|
return out;
|
|
153
152
|
}
|
package/dist/cli.mjs
CHANGED
|
@@ -2,28 +2,30 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CSS_ENTRY_CANDIDATES,
|
|
4
4
|
enumerateClassNames
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RU4756NG.mjs";
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_EXCLUDES,
|
|
8
8
|
DEFAULT_PATTERNS,
|
|
9
9
|
compileScannedProject,
|
|
10
10
|
getFontPreloadLinks
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-F4VCBISU.mjs";
|
|
12
12
|
import {
|
|
13
13
|
MAX_DIRECTIVE_INPUT_SIZE,
|
|
14
|
+
codepointCompare,
|
|
15
|
+
extractClassesFromSource,
|
|
14
16
|
extractDirectives,
|
|
15
17
|
hasApplyLikeDirective,
|
|
16
18
|
hasRIActivation,
|
|
17
19
|
listVariants,
|
|
18
20
|
resolveDirectives
|
|
19
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-PDORZSQX.mjs";
|
|
20
22
|
import {
|
|
21
23
|
devWarn
|
|
22
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-4UKFK2GE.mjs";
|
|
23
25
|
|
|
24
26
|
// src/entries/cli.ts
|
|
25
27
|
import { realpathSync } from "fs";
|
|
26
|
-
import { resolve as
|
|
28
|
+
import { resolve as resolve7 } from "path";
|
|
27
29
|
import { pathToFileURL } from "url";
|
|
28
30
|
|
|
29
31
|
// src/cli/args.ts
|
|
@@ -153,14 +155,31 @@ Examples:
|
|
|
153
155
|
rainbowindex generate-types
|
|
154
156
|
rainbowindex generate-types --strict --css src/styles.css`
|
|
155
157
|
},
|
|
158
|
+
scan: {
|
|
159
|
+
summary: "Show what the class scanner extracts (debugging)",
|
|
160
|
+
usage: " rainbowindex scan <file|glob...>",
|
|
161
|
+
flags: [],
|
|
162
|
+
positionals: "globs",
|
|
163
|
+
body: `Output:
|
|
164
|
+
One line per extracted class candidate, per file. Scanner warnings (skipped
|
|
165
|
+
over-long lines, unreadable files) print to stderr with [RI-NNNN] codes.
|
|
166
|
+
A class missing here was never seen by the scanner \u2014 check how it appears
|
|
167
|
+
in the markup. A class listed here that still does not generate fails
|
|
168
|
+
later \u2014 check the build warnings.
|
|
169
|
+
|
|
170
|
+
Examples:
|
|
171
|
+
rainbowindex scan src/components/icons/logo.tsx
|
|
172
|
+
rainbowindex scan "src/**/*.tsx"`
|
|
173
|
+
},
|
|
156
174
|
"preload-fonts": {
|
|
157
175
|
summary: 'Generate <link rel="preload"> tags',
|
|
158
176
|
usage: " rainbowindex preload-fonts [options]",
|
|
159
177
|
flags: [CSS_INPUT_FONTS],
|
|
160
178
|
positionals: "none",
|
|
161
179
|
body: `Output:
|
|
162
|
-
Prints <link rel="preload"> tags to stdout
|
|
163
|
-
|
|
180
|
+
Prints <link rel="preload"> tags to stdout, one per @font face marked
|
|
181
|
+
preload. Only local-file and raw-URL faces qualify \u2014 Google serves CSS, not
|
|
182
|
+
the font binary, so a Google or system slot never produces a tag.
|
|
164
183
|
|
|
165
184
|
Examples:
|
|
166
185
|
rainbowindex preload-fonts --css src/styles.css > preload.html`
|
|
@@ -261,6 +280,11 @@ function parseArgs(argv, callbacks) {
|
|
|
261
280
|
if (opts.command === "create" && !opts.targetDir) {
|
|
262
281
|
throw new Error("create requires a project directory. Example: rainbowindex create my-app");
|
|
263
282
|
}
|
|
283
|
+
if (opts.command === "scan" && opts.globs.length === 0) {
|
|
284
|
+
throw new Error(
|
|
285
|
+
'scan requires at least one file or glob. Example: rainbowindex scan "src/**/*.tsx"'
|
|
286
|
+
);
|
|
287
|
+
}
|
|
264
288
|
if (opts.watch && !opts.output) {
|
|
265
289
|
throw new Error(
|
|
266
290
|
'--output is required with --watch. Example: rainbowindex "src/**/*.tsx" --watch -o dist/styles.css'
|
|
@@ -303,8 +327,7 @@ function printHelp(subcommand) {
|
|
|
303
327
|
${spec.usage}`,
|
|
304
328
|
...spec.intro ? [spec.intro] : [],
|
|
305
329
|
`Options:
|
|
306
|
-
${renderFlagLines(spec.flags)}
|
|
307
|
-
${HELP_LINE}`,
|
|
330
|
+
${[renderFlagLines(spec.flags), HELP_LINE].filter(Boolean).join("\n")}`,
|
|
308
331
|
spec.body
|
|
309
332
|
];
|
|
310
333
|
console.log(`
|
|
@@ -321,6 +344,7 @@ Usage:
|
|
|
321
344
|
rainbowindex create <dir> Scaffold a Vite app with Rainbow Index ready
|
|
322
345
|
rainbowindex generate-types Generate TypeScript types for ri()
|
|
323
346
|
rainbowindex preload-fonts Generate font preload link tags
|
|
347
|
+
rainbowindex scan <file...> Show what the class scanner extracts
|
|
324
348
|
|
|
325
349
|
Run \`rainbowindex <subcommand> --help\` for subcommand-specific options.
|
|
326
350
|
|
|
@@ -772,11 +796,40 @@ async function watchMode(opts, cwd) {
|
|
|
772
796
|
process.on("SIGTERM", cleanup);
|
|
773
797
|
}
|
|
774
798
|
|
|
799
|
+
// src/cli/scan.ts
|
|
800
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
801
|
+
import { relative as relative2, resolve as resolve5 } from "path";
|
|
802
|
+
import { glob } from "tinyglobby";
|
|
803
|
+
async function scanFiles(opts, cwd) {
|
|
804
|
+
const files = [...new Set(await glob(opts.globs, { cwd }))].sort(codepointCompare);
|
|
805
|
+
if (files.length === 0) {
|
|
806
|
+
throw new Error(`No files matched ${opts.globs.map((g) => `"${g}"`).join(", ")}.`);
|
|
807
|
+
}
|
|
808
|
+
for (const file of files) {
|
|
809
|
+
const path = resolve5(cwd, file);
|
|
810
|
+
const warnings = [];
|
|
811
|
+
const classes = extractClassesFromSource(
|
|
812
|
+
{ path, content: await readFile3(path, "utf-8") },
|
|
813
|
+
warnings
|
|
814
|
+
);
|
|
815
|
+
const sorted = [...classes].sort(codepointCompare);
|
|
816
|
+
console.log(
|
|
817
|
+
`${relative2(cwd, path)} (${sorted.length} class${sorted.length === 1 ? "" : "es"})`
|
|
818
|
+
);
|
|
819
|
+
for (const cls of sorted) {
|
|
820
|
+
console.log(` ${cls}`);
|
|
821
|
+
}
|
|
822
|
+
for (const warning of warnings) {
|
|
823
|
+
console.error(` ${warning}`);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
|
|
775
828
|
// src/cli/vite-setup.ts
|
|
776
829
|
import { spawn } from "child_process";
|
|
777
830
|
import { existsSync as existsSync3, readFileSync } from "fs";
|
|
778
|
-
import { mkdir as mkdir2, readFile as
|
|
779
|
-
import { dirname as dirname3, relative as
|
|
831
|
+
import { mkdir as mkdir2, readFile as readFile4, readdir, writeFile as writeFile3 } from "fs/promises";
|
|
832
|
+
import { dirname as dirname3, relative as relative3, resolve as resolve6 } from "path";
|
|
780
833
|
var VITE_CONFIG_FILES = [
|
|
781
834
|
"vite.config.ts",
|
|
782
835
|
"vite.config.mts",
|
|
@@ -839,32 +892,32 @@ async function initViteProject(opts, cwd, deps = {}) {
|
|
|
839
892
|
ensureStylesheet(cssPath)
|
|
840
893
|
]);
|
|
841
894
|
const entryChanged = cssCreated ? await ensureStylesheetImport(entryFile, cssPath) : false;
|
|
842
|
-
const rootLabel =
|
|
895
|
+
const rootLabel = relative3(process.cwd(), cwd) || ".";
|
|
843
896
|
console.log(`[rainbowindex] Initialized Vite project: ${rootLabel}`);
|
|
844
897
|
if (dependencyInstalled) {
|
|
845
898
|
console.log("[rainbowindex] Added dev dependency: rainbowindex");
|
|
846
899
|
}
|
|
847
900
|
if (configCreated) {
|
|
848
901
|
console.log(
|
|
849
|
-
`[rainbowindex] Created Vite config: ${
|
|
902
|
+
`[rainbowindex] Created Vite config: ${relative3(cwd, configPath).replaceAll("\\", "/")}`
|
|
850
903
|
);
|
|
851
904
|
} else if (configChanged) {
|
|
852
905
|
console.log(
|
|
853
|
-
`[rainbowindex] Updated Vite config: ${
|
|
906
|
+
`[rainbowindex] Updated Vite config: ${relative3(cwd, configPath).replaceAll("\\", "/")}`
|
|
854
907
|
);
|
|
855
908
|
}
|
|
856
909
|
if (cssCreated) {
|
|
857
910
|
console.log(
|
|
858
|
-
`[rainbowindex] Created stylesheet: ${
|
|
911
|
+
`[rainbowindex] Created stylesheet: ${relative3(cwd, cssPath).replaceAll("\\", "/")}`
|
|
859
912
|
);
|
|
860
913
|
} else if (cssChanged) {
|
|
861
914
|
console.log(
|
|
862
|
-
`[rainbowindex] Updated stylesheet: ${
|
|
915
|
+
`[rainbowindex] Updated stylesheet: ${relative3(cwd, cssPath).replaceAll("\\", "/")}`
|
|
863
916
|
);
|
|
864
917
|
}
|
|
865
918
|
if (entryChanged && entryFile) {
|
|
866
919
|
console.log(
|
|
867
|
-
`[rainbowindex] Added stylesheet import: ${
|
|
920
|
+
`[rainbowindex] Added stylesheet import: ${relative3(cwd, entryFile).replaceAll("\\", "/")}`
|
|
868
921
|
);
|
|
869
922
|
}
|
|
870
923
|
if (!dependencyInstalled && !configChanged && !configCreated && !cssChanged && !cssCreated) {
|
|
@@ -888,7 +941,7 @@ async function createViteProject(opts, cwd, deps = {}) {
|
|
|
888
941
|
const packageManager = deps.packageManager ?? detectPackageManager(cwd, deps.env);
|
|
889
942
|
const runner = deps.runner ?? DEFAULT_RUNNER;
|
|
890
943
|
const targetDir = opts.targetDir;
|
|
891
|
-
const targetRoot =
|
|
944
|
+
const targetRoot = resolve6(cwd, targetDir);
|
|
892
945
|
await ensureScaffoldTargetIsUsable(targetRoot);
|
|
893
946
|
const template = opts.template || DEFAULT_CREATE_TEMPLATE;
|
|
894
947
|
const scaffold = getCreateCommand(packageManager, targetDir, template);
|
|
@@ -899,15 +952,15 @@ async function createViteProject(opts, cwd, deps = {}) {
|
|
|
899
952
|
packageManager,
|
|
900
953
|
runner
|
|
901
954
|
});
|
|
902
|
-
const displayTarget =
|
|
955
|
+
const displayTarget = relative3(cwd, targetRoot) || ".";
|
|
903
956
|
console.log(`[rainbowindex] Ready: ${displayTarget}`);
|
|
904
957
|
console.log(`[rainbowindex] Next: cd ${displayTarget} && ${packageManager} run dev`);
|
|
905
958
|
}
|
|
906
959
|
function detectPackageManager(cwd, env = process.env) {
|
|
907
|
-
if (existsSync3(
|
|
908
|
-
if (existsSync3(
|
|
909
|
-
if (existsSync3(
|
|
910
|
-
if (existsSync3(
|
|
960
|
+
if (existsSync3(resolve6(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
961
|
+
if (existsSync3(resolve6(cwd, "yarn.lock"))) return "yarn";
|
|
962
|
+
if (existsSync3(resolve6(cwd, "bun.lock")) || existsSync3(resolve6(cwd, "bun.lockb"))) return "bun";
|
|
963
|
+
if (existsSync3(resolve6(cwd, "package-lock.json")) || existsSync3(resolve6(cwd, "npm-shrinkwrap.json"))) {
|
|
911
964
|
return "npm";
|
|
912
965
|
}
|
|
913
966
|
const packageJSON = readPackageJSONSync(cwd);
|
|
@@ -952,12 +1005,12 @@ async function installRainbowIndex(cwd, packageManager, runner) {
|
|
|
952
1005
|
async function ensureViteConfig(cwd, packageJSON, existingPath) {
|
|
953
1006
|
if (!existingPath) {
|
|
954
1007
|
const fileName = chooseViteConfigName(cwd, packageJSON);
|
|
955
|
-
const configPath =
|
|
1008
|
+
const configPath = resolve6(cwd, fileName);
|
|
956
1009
|
const content = 'import { defineConfig } from "vite";\nimport rainbowindex from "rainbowindex/vite";\n\nexport default defineConfig({\n plugins: [rainbowindex()],\n});\n';
|
|
957
1010
|
await writeFile3(configPath, content, "utf-8");
|
|
958
1011
|
return { path: configPath, changed: true, created: true };
|
|
959
1012
|
}
|
|
960
|
-
const original = await
|
|
1013
|
+
const original = await readFile4(existingPath, "utf-8");
|
|
961
1014
|
const updated = patchViteConfig(original, existingPath);
|
|
962
1015
|
if (updated === original) {
|
|
963
1016
|
return { path: existingPath, changed: false, created: false };
|
|
@@ -1086,14 +1139,14 @@ function findMatchingDelimiter(input, start, open, close) {
|
|
|
1086
1139
|
return -1;
|
|
1087
1140
|
}
|
|
1088
1141
|
async function resolveStylesheetPath(cwd, cssFile) {
|
|
1089
|
-
if (cssFile) return
|
|
1142
|
+
if (cssFile) return resolve6(cwd, cssFile);
|
|
1090
1143
|
const importedCSS = await findImportedStylesheet(cwd);
|
|
1091
1144
|
if (importedCSS) return importedCSS;
|
|
1092
1145
|
for (const candidate of CSS_ENTRY_CANDIDATES) {
|
|
1093
|
-
const fullPath =
|
|
1146
|
+
const fullPath = resolve6(cwd, candidate);
|
|
1094
1147
|
if (existsSync3(fullPath)) return fullPath;
|
|
1095
1148
|
}
|
|
1096
|
-
return existsSync3(
|
|
1149
|
+
return existsSync3(resolve6(cwd, "src")) ? resolve6(cwd, "src/index.css") : resolve6(cwd, "index.css");
|
|
1097
1150
|
}
|
|
1098
1151
|
async function ensureStylesheet(cssPath) {
|
|
1099
1152
|
if (!existsSync3(cssPath)) {
|
|
@@ -1101,7 +1154,7 @@ async function ensureStylesheet(cssPath) {
|
|
|
1101
1154
|
await writeFile3(cssPath, '@import "rainbowindex";\n', "utf-8");
|
|
1102
1155
|
return { changed: true, created: true };
|
|
1103
1156
|
}
|
|
1104
|
-
const original = await
|
|
1157
|
+
const original = await readFile4(cssPath, "utf-8");
|
|
1105
1158
|
if (/@import\s+["']rainbowindex["']/.test(original)) {
|
|
1106
1159
|
return { changed: false, created: false };
|
|
1107
1160
|
}
|
|
@@ -1128,7 +1181,7 @@ ${content}`;
|
|
|
1128
1181
|
}
|
|
1129
1182
|
async function ensureStylesheetImport(entryFile, cssPath) {
|
|
1130
1183
|
if (!entryFile || !existsSync3(entryFile)) return false;
|
|
1131
|
-
const original = await
|
|
1184
|
+
const original = await readFile4(entryFile, "utf-8");
|
|
1132
1185
|
const relativePath = toImportPath(dirname3(entryFile), cssPath);
|
|
1133
1186
|
if (hasStylesheetImport(original, relativePath)) {
|
|
1134
1187
|
return false;
|
|
@@ -1139,16 +1192,16 @@ async function ensureStylesheetImport(entryFile, cssPath) {
|
|
|
1139
1192
|
}
|
|
1140
1193
|
async function findImportedStylesheet(cwd) {
|
|
1141
1194
|
for (const entryFile of ENTRY_FILES) {
|
|
1142
|
-
const fullPath =
|
|
1195
|
+
const fullPath = resolve6(cwd, entryFile);
|
|
1143
1196
|
if (!existsSync3(fullPath)) continue;
|
|
1144
|
-
const content = await
|
|
1197
|
+
const content = await readFile4(fullPath, "utf-8");
|
|
1145
1198
|
const matches = content.matchAll(
|
|
1146
1199
|
/import\s+(?:.+?\s+from\s+)?["']([^"']+\.css(?:\?[^"']*)?)["']/g
|
|
1147
1200
|
);
|
|
1148
1201
|
for (const match of matches) {
|
|
1149
1202
|
const importPath = match[1].split("?")[0];
|
|
1150
1203
|
if (!importPath.startsWith(".")) continue;
|
|
1151
|
-
const stylesheet =
|
|
1204
|
+
const stylesheet = resolve6(dirname3(fullPath), importPath);
|
|
1152
1205
|
if (existsSync3(stylesheet)) return stylesheet;
|
|
1153
1206
|
}
|
|
1154
1207
|
}
|
|
@@ -1156,7 +1209,7 @@ async function findImportedStylesheet(cwd) {
|
|
|
1156
1209
|
}
|
|
1157
1210
|
async function findEntryFile(cwd) {
|
|
1158
1211
|
for (const entryFile of ENTRY_FILES) {
|
|
1159
|
-
const fullPath =
|
|
1212
|
+
const fullPath = resolve6(cwd, entryFile);
|
|
1160
1213
|
if (existsSync3(fullPath)) return fullPath;
|
|
1161
1214
|
}
|
|
1162
1215
|
return null;
|
|
@@ -1166,18 +1219,18 @@ function hasStylesheetImport(source, importPath) {
|
|
|
1166
1219
|
return new RegExp(`import\\s+(?:.+?\\s+from\\s+)?["']${escapedPath}["']`).test(source);
|
|
1167
1220
|
}
|
|
1168
1221
|
function toImportPath(fromDir, targetFile) {
|
|
1169
|
-
const rel =
|
|
1222
|
+
const rel = relative3(fromDir, targetFile).replaceAll("\\", "/");
|
|
1170
1223
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
1171
1224
|
}
|
|
1172
1225
|
function findExistingViteConfig(cwd) {
|
|
1173
1226
|
for (const name of VITE_CONFIG_FILES) {
|
|
1174
|
-
const fullPath =
|
|
1227
|
+
const fullPath = resolve6(cwd, name);
|
|
1175
1228
|
if (existsSync3(fullPath)) return fullPath;
|
|
1176
1229
|
}
|
|
1177
1230
|
return null;
|
|
1178
1231
|
}
|
|
1179
1232
|
function chooseViteConfigName(cwd, packageJSON) {
|
|
1180
|
-
if (existsSync3(
|
|
1233
|
+
if (existsSync3(resolve6(cwd, "tsconfig.json")) || existsSync3(resolve6(cwd, "tsconfig.app.json")) || existsSync3(resolve6(cwd, "src/main.ts")) || existsSync3(resolve6(cwd, "src/main.tsx")) || packageJSON?.dependencies?.typescript || packageJSON?.devDependencies?.typescript) {
|
|
1181
1234
|
return "vite.config.ts";
|
|
1182
1235
|
}
|
|
1183
1236
|
return packageJSON?.type === "module" ? "vite.config.js" : "vite.config.mjs";
|
|
@@ -1225,7 +1278,7 @@ function getInstallCommand(packageManager) {
|
|
|
1225
1278
|
}
|
|
1226
1279
|
}
|
|
1227
1280
|
function readPackageJSONSync(cwd) {
|
|
1228
|
-
const packagePath =
|
|
1281
|
+
const packagePath = resolve6(cwd, "package.json");
|
|
1229
1282
|
if (!existsSync3(packagePath)) return null;
|
|
1230
1283
|
try {
|
|
1231
1284
|
return JSON.parse(readFileSync(packagePath, "utf-8"));
|
|
@@ -1236,7 +1289,7 @@ function readPackageJSONSync(cwd) {
|
|
|
1236
1289
|
|
|
1237
1290
|
// src/entries/cli.ts
|
|
1238
1291
|
function getVersion() {
|
|
1239
|
-
return true ? "0.
|
|
1292
|
+
return true ? "0.5.1" : "unknown";
|
|
1240
1293
|
}
|
|
1241
1294
|
async function main() {
|
|
1242
1295
|
const args = process.argv.slice(2);
|
|
@@ -1260,6 +1313,9 @@ async function main() {
|
|
|
1260
1313
|
case "preload-fonts":
|
|
1261
1314
|
await preloadFonts(opts, cwd);
|
|
1262
1315
|
break;
|
|
1316
|
+
case "scan":
|
|
1317
|
+
await scanFiles(opts, cwd);
|
|
1318
|
+
break;
|
|
1263
1319
|
case "build": {
|
|
1264
1320
|
if (opts.watch) {
|
|
1265
1321
|
await watchMode(opts, cwd);
|
|
@@ -1280,7 +1336,7 @@ var isDirectExecution = (() => {
|
|
|
1280
1336
|
const entry = process.argv[1];
|
|
1281
1337
|
if (entry === void 0) return false;
|
|
1282
1338
|
try {
|
|
1283
|
-
return import.meta.url === pathToFileURL(realpathSync(
|
|
1339
|
+
return import.meta.url === pathToFileURL(realpathSync(resolve7(entry))).href;
|
|
1284
1340
|
} catch {
|
|
1285
1341
|
return false;
|
|
1286
1342
|
}
|
|
@@ -83,7 +83,6 @@ interface Theme {
|
|
|
83
83
|
colors: Record<string, ColorDefinition>;
|
|
84
84
|
text: Record<string, TextSize>;
|
|
85
85
|
breakpoints: Record<string, string>;
|
|
86
|
-
rounded: Record<string, string>;
|
|
87
86
|
shadows: Record<string, string>;
|
|
88
87
|
weights: Record<string, number>;
|
|
89
88
|
easing: Record<string, string>;
|
|
@@ -104,6 +103,23 @@ type CornerShape = CornerShapeKeyword | {
|
|
|
104
103
|
};
|
|
105
104
|
declare const defaultTheme: Theme;
|
|
106
105
|
|
|
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
|
+
|
|
107
123
|
/**
|
|
108
124
|
* Compilation-context lifecycle — all mutable state behind ri().
|
|
109
125
|
*
|
|
@@ -113,23 +129,25 @@ declare const defaultTheme: Theme;
|
|
|
113
129
|
* compilations. Split from merge/index.ts so the merge algorithm stays pure
|
|
114
130
|
* runtime and every piece of mutable state lives in one file.
|
|
115
131
|
*
|
|
116
|
-
* The default ri()
|
|
132
|
+
* The default ri() cache lives here rather than next to the merge loop
|
|
117
133
|
* because finalizeCompilationContext() must clear it: conflict resolution
|
|
118
134
|
* rules may change between compilations, and stale entries from a previous
|
|
119
135
|
* compilation (with different custom utilities) must never be returned.
|
|
120
136
|
*/
|
|
137
|
+
|
|
121
138
|
interface CompilationContext {
|
|
122
139
|
customStaticProps: Record<string, string[]>;
|
|
140
|
+
/** Roots of functional `@utility name-*` entries → the properties they set. */
|
|
141
|
+
customFunctionalProps: Record<string, string[]>;
|
|
123
142
|
textSizes: Set<string>;
|
|
124
143
|
fontFamilies: Set<string>;
|
|
125
144
|
colorNames: Set<string>;
|
|
126
145
|
}
|
|
127
|
-
|
|
128
|
-
* Frozen snapshot of compilation state for SSR-safe ri() instances.
|
|
129
|
-
* Created by finalizeCompilationContext() and consumed by createRi().
|
|
130
|
-
*/
|
|
146
|
+
|
|
131
147
|
interface CompilationSnapshot {
|
|
132
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[];
|
|
133
151
|
readonly textSizes: ReadonlySet<string>;
|
|
134
152
|
readonly fontFamilies: ReadonlySet<string>;
|
|
135
153
|
readonly colorNames: ReadonlySet<string>;
|
|
@@ -143,7 +161,7 @@ declare function createCompilationContext(): CompilationContext;
|
|
|
143
161
|
* Register a custom utility's CSS properties in the compilation context.
|
|
144
162
|
* Called by the engine when processing @utility directives.
|
|
145
163
|
*/
|
|
146
|
-
declare function registerCustomUtility(ctx: CompilationContext, name: string, properties: string[]): void;
|
|
164
|
+
declare function registerCustomUtility(ctx: CompilationContext, name: string, properties: string[], functional?: boolean): void;
|
|
147
165
|
/**
|
|
148
166
|
* Register custom text sizes so the merge function correctly classifies
|
|
149
167
|
* text-{custom} as a font-size utility rather than a color utility.
|
|
@@ -167,4 +185,4 @@ declare function registerColorNames(ctx: CompilationContext, names: string[]): v
|
|
|
167
185
|
*/
|
|
168
186
|
declare function finalizeCompilationContext(ctx: CompilationContext): CompilationSnapshot;
|
|
169
187
|
|
|
170
|
-
export { type AnimationDefinition as A, type ColorDefinition as C,
|
|
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 };
|
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 './context-
|
|
4
|
-
export { e as defaultTheme } from './context-
|
|
1
|
+
import { P as ParsedDirective, R as ResolvedTheme } from './index-Dx-NpFFx.js';
|
|
2
|
+
export { b as createThemeSnapshot } from './index-Dx-NpFFx.js';
|
|
3
|
+
import { b as CompilationSnapshot, C as ColorDefinition } from './context-B9yhJxd5.js';
|
|
4
|
+
export { e as defaultTheme } from './context-B9yhJxd5.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
|
|
@@ -455,7 +459,6 @@ interface ThemeTokens {
|
|
|
455
459
|
lineHeight: string;
|
|
456
460
|
}>;
|
|
457
461
|
breakpoints: Record<string, string>;
|
|
458
|
-
rounded: Record<string, string>;
|
|
459
462
|
shadows: Record<string, string>;
|
|
460
463
|
weights: Record<string, number>;
|
|
461
464
|
easing: Record<string, string>;
|
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-RU4756NG.mjs";
|
|
6
6
|
import {
|
|
7
7
|
isSourceFile
|
|
8
8
|
} from "./chunk-3HRMFZGE.mjs";
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
parseUtility,
|
|
28
28
|
severityForCode,
|
|
29
29
|
warningCode
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-PDORZSQX.mjs";
|
|
31
31
|
import {
|
|
32
32
|
computeDarkStop,
|
|
33
33
|
defaultTheme,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
oklabToLinearSrgb,
|
|
39
39
|
oklchToOklab,
|
|
40
40
|
resolverFor
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-4UKFK2GE.mjs";
|
|
42
42
|
|
|
43
43
|
// src/engine/inspector.ts
|
|
44
44
|
var RESOLUTION_CACHE_CAP = 1e4;
|
|
@@ -307,7 +307,6 @@ function listThemeTokens(theme) {
|
|
|
307
307
|
lineHeight: def.lineHeight
|
|
308
308
|
})),
|
|
309
309
|
breakpoints: { ...theme.breakpoints },
|
|
310
|
-
rounded: { ...theme.rounded },
|
|
311
310
|
shadows: { ...theme.shadows },
|
|
312
311
|
weights: { ...theme.weights },
|
|
313
312
|
easing: { ...theme.easing },
|
|
@@ -383,11 +382,16 @@ function createEditorSession(options = {}) {
|
|
|
383
382
|
}
|
|
384
383
|
|
|
385
384
|
// src/entries/editor.ts
|
|
386
|
-
var version = true ? "0.
|
|
385
|
+
var version = true ? "0.5.1" : "0.0.0-dev";
|
|
387
386
|
var EDITOR_API_VERSION = 1;
|
|
388
387
|
var editorCapabilities = Object.freeze([
|
|
389
388
|
"class-candidates",
|
|
390
389
|
"candidate-call-ids",
|
|
390
|
+
// A candidate carries a certain origin only when a context-aware collector
|
|
391
|
+
// tokenized it, so bare JS identifiers stay "plain"; equality operands
|
|
392
|
+
// report the "expression" origin. Without this, position alone decided,
|
|
393
|
+
// and `ri(mode === "x" ? …)` reported `mode` as a helper-origin class.
|
|
394
|
+
"candidate-origin-provenance",
|
|
391
395
|
"css-entry-detection",
|
|
392
396
|
"theme-analysis",
|
|
393
397
|
"class-inspection",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ColorDefinition,
|
|
1
|
+
import { C as ColorDefinition, j as DarkModeConfig, k as CornerShape, A as AnimationDefinition, F as FluidConfig, b as CompilationSnapshot } from './context-B9yhJxd5.js';
|
|
2
2
|
|
|
3
3
|
/** Provider discriminant for a slot, derived from its faces. */
|
|
4
4
|
type FontProviderKind = "google" | "system" | "local" | "manual";
|
|
@@ -149,8 +149,6 @@ interface ResolvedTheme {
|
|
|
149
149
|
base: string;
|
|
150
150
|
}>;
|
|
151
151
|
readonly breakpoints: Readonly<Record<string, string>>;
|
|
152
|
-
readonly rounded: Readonly<Record<string, string>>;
|
|
153
|
-
readonly roundedRoof: string;
|
|
154
152
|
/**
|
|
155
153
|
* Corner shape set via `@rounded <shape>`. `null` means no shape was configured —
|
|
156
154
|
* the compiler emits neither a `corner-shape` rule nor the fallback `@supports not`
|
|
@@ -213,7 +211,6 @@ interface CompilationResult {
|
|
|
213
211
|
/** Set of used font slot names (for token pruning). */
|
|
214
212
|
usedFonts: Set<string>;
|
|
215
213
|
/** Set of used rounded value names (for token pruning). */
|
|
216
|
-
usedRounded: Set<string>;
|
|
217
214
|
/** Set of used shadow names (for token pruning). */
|
|
218
215
|
usedShadows: Set<string>;
|
|
219
216
|
/** Set of used animation shorthand names (for token pruning). */
|
|
@@ -254,7 +251,10 @@ declare function createThemeSnapshot(theme: ResolvedTheme): CompilationSnapshot;
|
|
|
254
251
|
* ```
|
|
255
252
|
*/
|
|
256
253
|
declare function createCompiler(): {
|
|
257
|
-
|
|
254
|
+
/** `authored` names the classes the user wrote by hand (`@source inline`,
|
|
255
|
+
* `@apply`, a caller-supplied list). Omit it to treat every class as
|
|
256
|
+
* authored — correct for callers who assembled the list themselves. */
|
|
257
|
+
compile: (classNames: Iterable<string>, theme: ResolvedTheme, authored?: ReadonlySet<string>) => CompilationResult;
|
|
258
258
|
createRi: () => (...inputs: (string | false | null | undefined)[]) => string;
|
|
259
259
|
/** Isolated font output cache for this compiler instance. Pass to
|
|
260
260
|
* `assembleSections()` to avoid sharing module-level font state. */
|
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, 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-
|
|
3
|
-
export {
|
|
4
|
-
import { R as ResolvedTheme, P as ParsedDirective } from './index-
|
|
5
|
-
export { C as CompilationResult, a as CompiledRule, c as createCompiler } from './index-
|
|
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 defaultTheme, f as finalizeCompilationContext, r as registerColorNames, g as registerCustomFontFamilies, h as registerCustomTextSizes, i as registerCustomUtility } from './context-B9yhJxd5.js';
|
|
3
|
+
export { c as createRi, r as ri, s as safelist } from './safelist-DAkKuxCk.js';
|
|
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';
|
|
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-4CTJLMYM.mjs";
|
|
7
7
|
import {
|
|
8
8
|
finalizeProjectCompilation,
|
|
9
9
|
resolveGoogleFonts
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-F4VCBISU.mjs";
|
|
11
11
|
import {
|
|
12
12
|
analyzeProjectCSS,
|
|
13
13
|
createCompiler,
|
|
14
14
|
extractClassesFromSource,
|
|
15
15
|
pushWarningsDeduped
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-PDORZSQX.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-4UKFK2GE.mjs";
|
|
29
29
|
|
|
30
30
|
// src/project/index.ts
|
|
31
31
|
async function compileProject(options) {
|
|
@@ -36,6 +36,7 @@ async function compileProject(options) {
|
|
|
36
36
|
classNames.add(cls);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
const authored = new Set(classNames);
|
|
39
40
|
if (options.sources) {
|
|
40
41
|
const extractionWarnings = [];
|
|
41
42
|
for (const source of options.sources) {
|
|
@@ -48,6 +49,7 @@ async function compileProject(options) {
|
|
|
48
49
|
return finalizeProjectCompilation({
|
|
49
50
|
css: options.css,
|
|
50
51
|
classNames,
|
|
52
|
+
authoredClassNames: authored,
|
|
51
53
|
analysis,
|
|
52
54
|
// Default to resolving google font weights so headless callers aren't silently
|
|
53
55
|
// stuck with "100 900" defaults; opt out with RI_OFFLINE / RI_FETCH_FONTS.
|