rafters 0.0.75 → 0.0.76
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/dist/index.js +37 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1012,7 +1012,7 @@ function deriveCandidates(themeCSS) {
|
|
|
1012
1012
|
return [...candidates];
|
|
1013
1013
|
}
|
|
1014
1014
|
async function registryToDocumentation(registry2, options = {}) {
|
|
1015
|
-
const { minify = true } = options;
|
|
1015
|
+
const { minify = true, contentSources = [] } = options;
|
|
1016
1016
|
const themeBody = registryToTailwind(registry2, { includeImport: false });
|
|
1017
1017
|
const candidates = deriveCandidates(themeBody);
|
|
1018
1018
|
const { mkdtempSync, writeFileSync: writeFileSync2, rmSync } = await import("fs");
|
|
@@ -1031,9 +1031,12 @@ async function registryToDocumentation(registry2, options = {}) {
|
|
|
1031
1031
|
const tempDir = mkdtempSync(join15(pkgDir, ".tmp-doc-compile-"));
|
|
1032
1032
|
const candidateFile = join15(tempDir, "candidates.txt");
|
|
1033
1033
|
writeFileSync2(candidateFile, candidates.join("\n"));
|
|
1034
|
-
const
|
|
1034
|
+
const sourceDirectives = [
|
|
1035
|
+
`@source "${candidateFile}";`,
|
|
1036
|
+
...contentSources.map((src) => `@source "${src}";`)
|
|
1037
|
+
].join("\n");
|
|
1035
1038
|
const input = `@import "tailwindcss" source(none);
|
|
1036
|
-
${
|
|
1039
|
+
${sourceDirectives}
|
|
1037
1040
|
${themeBody}`;
|
|
1038
1041
|
const tempInput = join15(tempDir, "input.css");
|
|
1039
1042
|
const tempOutput = join15(tempDir, "output.css");
|
|
@@ -1045,7 +1048,8 @@ ${themeBody}`;
|
|
|
1045
1048
|
if (minify) args.push("--minify");
|
|
1046
1049
|
execFileSync("node", args, { stdio: "pipe", timeout: 6e4, cwd: pkgDir });
|
|
1047
1050
|
const { readFileSync: readFileSync3 } = await import("fs");
|
|
1048
|
-
|
|
1051
|
+
const raw = readFileSync3(tempOutput, "utf-8");
|
|
1052
|
+
return postProcessDocSheet(raw);
|
|
1049
1053
|
} catch (error47) {
|
|
1050
1054
|
const message = error47 instanceof Error ? error47.message : String(error47);
|
|
1051
1055
|
throw new Error(`Failed to compile documentation CSS: ${message}`);
|
|
@@ -1053,6 +1057,35 @@ ${themeBody}`;
|
|
|
1053
1057
|
rmSync(tempDir, { recursive: true, force: true });
|
|
1054
1058
|
}
|
|
1055
1059
|
}
|
|
1060
|
+
function postProcessDocSheet(css) {
|
|
1061
|
+
const parts = [];
|
|
1062
|
+
const themeLayerRe = /@layer theme\{(.*?)\}(?=@layer|$)/s;
|
|
1063
|
+
const themeMatch = themeLayerRe.exec(css);
|
|
1064
|
+
if (themeMatch) {
|
|
1065
|
+
let themeContent = themeMatch[1] ?? "";
|
|
1066
|
+
themeContent = themeContent.replace(/:root,:host/g, ":host");
|
|
1067
|
+
parts.push(`:host{container-type:inline-size}${themeContent}`);
|
|
1068
|
+
}
|
|
1069
|
+
const layerRe = /@layer (base|components|utilities)\{/g;
|
|
1070
|
+
let match;
|
|
1071
|
+
while ((match = layerRe.exec(css)) !== null) {
|
|
1072
|
+
const start = match.index;
|
|
1073
|
+
let depth = 0;
|
|
1074
|
+
let end = start;
|
|
1075
|
+
for (let i = start; i < css.length; i++) {
|
|
1076
|
+
if (css[i] === "{") depth++;
|
|
1077
|
+
if (css[i] === "}") {
|
|
1078
|
+
depth--;
|
|
1079
|
+
if (depth === 0) {
|
|
1080
|
+
end = i + 1;
|
|
1081
|
+
break;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
parts.push(css.slice(start, end));
|
|
1086
|
+
}
|
|
1087
|
+
return parts.join("");
|
|
1088
|
+
}
|
|
1056
1089
|
|
|
1057
1090
|
// ../design-tokens/src/exporters/typescript.ts
|
|
1058
1091
|
function tokenValueToTS(token) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rafters",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.76",
|
|
4
4
|
"description": "Design Intelligence CLI. Scaffold tokens, import existing shadcn/Tailwind v4 sources, add components, and serve an MCP server so AI agents read decisions instead of guessing.",
|
|
5
5
|
"homepage": "https://rafters.studio",
|
|
6
6
|
"license": "MIT",
|