rafters 0.0.75 → 0.0.77
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 +103 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -968,12 +968,61 @@ var RADIUS_UTILITIES = [
|
|
|
968
968
|
"rounded-bl"
|
|
969
969
|
];
|
|
970
970
|
var STATE_VARIANTS = ["hover", "focus-visible", "focus", "active", "dark"];
|
|
971
|
+
var CONTAINER_LAYOUT_UTILITIES = [
|
|
972
|
+
"grid-cols",
|
|
973
|
+
"gap",
|
|
974
|
+
"p",
|
|
975
|
+
"px",
|
|
976
|
+
"py",
|
|
977
|
+
"pt",
|
|
978
|
+
"pr",
|
|
979
|
+
"pb",
|
|
980
|
+
"pl",
|
|
981
|
+
"h",
|
|
982
|
+
"w",
|
|
983
|
+
"max-w",
|
|
984
|
+
"flex-row",
|
|
985
|
+
"flex-col",
|
|
986
|
+
"flex-col-reverse",
|
|
987
|
+
"flex-wrap",
|
|
988
|
+
"items-center",
|
|
989
|
+
"justify-end",
|
|
990
|
+
"justify-center",
|
|
991
|
+
"justify-between",
|
|
992
|
+
"text-left",
|
|
993
|
+
"text-center",
|
|
994
|
+
"text-right",
|
|
995
|
+
"space-x",
|
|
996
|
+
"space-y",
|
|
997
|
+
"mt",
|
|
998
|
+
"rounded",
|
|
999
|
+
"rounded-sm",
|
|
1000
|
+
"rounded-md",
|
|
1001
|
+
"rounded-lg"
|
|
1002
|
+
];
|
|
1003
|
+
function extractThemeBlocks(css) {
|
|
1004
|
+
const blocks = [];
|
|
1005
|
+
const re = /@theme\s*(?:inline\s*)?\{/g;
|
|
1006
|
+
let match;
|
|
1007
|
+
while ((match = re.exec(css)) !== null) {
|
|
1008
|
+
let depth = 1;
|
|
1009
|
+
const start = match.index + match[0].length;
|
|
1010
|
+
for (let i = start; i < css.length; i++) {
|
|
1011
|
+
if (css[i] === "{") depth++;
|
|
1012
|
+
if (css[i] === "}") {
|
|
1013
|
+
depth--;
|
|
1014
|
+
if (depth === 0) {
|
|
1015
|
+
blocks.push(css.slice(start, i));
|
|
1016
|
+
break;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
return blocks;
|
|
1022
|
+
}
|
|
971
1023
|
function deriveCandidates(themeCSS) {
|
|
972
1024
|
const themeVarNames = [];
|
|
973
|
-
const
|
|
974
|
-
let blockMatch;
|
|
975
|
-
while ((blockMatch = themeBlockRe.exec(themeCSS)) !== null) {
|
|
976
|
-
const block = blockMatch[1] ?? "";
|
|
1025
|
+
for (const block of extractThemeBlocks(themeCSS)) {
|
|
977
1026
|
const varRe = /--([a-z][a-z0-9-]*)\s*:/g;
|
|
978
1027
|
let varMatch;
|
|
979
1028
|
while ((varMatch = varRe.exec(block)) !== null) {
|
|
@@ -1009,10 +1058,19 @@ function deriveCandidates(themeCSS) {
|
|
|
1009
1058
|
candidates.add(`${variant}:${c4}`);
|
|
1010
1059
|
}
|
|
1011
1060
|
}
|
|
1061
|
+
const containerSizes = themeVarNames.filter((n2) => n2.startsWith("container-")).map((n2) => n2.slice(10));
|
|
1062
|
+
const layoutCandidates = base.filter(
|
|
1063
|
+
(c4) => CONTAINER_LAYOUT_UTILITIES.some((u) => c4 === u || c4.startsWith(`${u}-`))
|
|
1064
|
+
);
|
|
1065
|
+
for (const size of containerSizes) {
|
|
1066
|
+
for (const c4 of layoutCandidates) {
|
|
1067
|
+
candidates.add(`@${size}:${c4}`);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1012
1070
|
return [...candidates];
|
|
1013
1071
|
}
|
|
1014
1072
|
async function registryToDocumentation(registry2, options = {}) {
|
|
1015
|
-
const { minify = true } = options;
|
|
1073
|
+
const { minify = true, contentSources = [] } = options;
|
|
1016
1074
|
const themeBody = registryToTailwind(registry2, { includeImport: false });
|
|
1017
1075
|
const candidates = deriveCandidates(themeBody);
|
|
1018
1076
|
const { mkdtempSync, writeFileSync: writeFileSync2, rmSync } = await import("fs");
|
|
@@ -1031,9 +1089,12 @@ async function registryToDocumentation(registry2, options = {}) {
|
|
|
1031
1089
|
const tempDir = mkdtempSync(join15(pkgDir, ".tmp-doc-compile-"));
|
|
1032
1090
|
const candidateFile = join15(tempDir, "candidates.txt");
|
|
1033
1091
|
writeFileSync2(candidateFile, candidates.join("\n"));
|
|
1034
|
-
const
|
|
1092
|
+
const sourceDirectives = [
|
|
1093
|
+
`@source "${candidateFile}";`,
|
|
1094
|
+
...contentSources.map((src) => `@source "${src}";`)
|
|
1095
|
+
].join("\n");
|
|
1035
1096
|
const input = `@import "tailwindcss" source(none);
|
|
1036
|
-
${
|
|
1097
|
+
${sourceDirectives}
|
|
1037
1098
|
${themeBody}`;
|
|
1038
1099
|
const tempInput = join15(tempDir, "input.css");
|
|
1039
1100
|
const tempOutput = join15(tempDir, "output.css");
|
|
@@ -1045,7 +1106,8 @@ ${themeBody}`;
|
|
|
1045
1106
|
if (minify) args.push("--minify");
|
|
1046
1107
|
execFileSync("node", args, { stdio: "pipe", timeout: 6e4, cwd: pkgDir });
|
|
1047
1108
|
const { readFileSync: readFileSync3 } = await import("fs");
|
|
1048
|
-
|
|
1109
|
+
const raw = readFileSync3(tempOutput, "utf-8");
|
|
1110
|
+
return postProcessDocSheet(raw);
|
|
1049
1111
|
} catch (error47) {
|
|
1050
1112
|
const message = error47 instanceof Error ? error47.message : String(error47);
|
|
1051
1113
|
throw new Error(`Failed to compile documentation CSS: ${message}`);
|
|
@@ -1053,6 +1115,35 @@ ${themeBody}`;
|
|
|
1053
1115
|
rmSync(tempDir, { recursive: true, force: true });
|
|
1054
1116
|
}
|
|
1055
1117
|
}
|
|
1118
|
+
function postProcessDocSheet(css) {
|
|
1119
|
+
const parts = [];
|
|
1120
|
+
const themeLayerRe = /@layer theme\{(.*?)\}(?=@layer|$)/s;
|
|
1121
|
+
const themeMatch = themeLayerRe.exec(css);
|
|
1122
|
+
if (themeMatch) {
|
|
1123
|
+
let themeContent = themeMatch[1] ?? "";
|
|
1124
|
+
themeContent = themeContent.replace(/:root,:host/g, ":host");
|
|
1125
|
+
parts.push(`:host{container-type:inline-size}${themeContent}`);
|
|
1126
|
+
}
|
|
1127
|
+
const layerRe = /@layer (base|components|utilities)\{/g;
|
|
1128
|
+
let match;
|
|
1129
|
+
while ((match = layerRe.exec(css)) !== null) {
|
|
1130
|
+
const start = match.index;
|
|
1131
|
+
let depth = 0;
|
|
1132
|
+
let end = start;
|
|
1133
|
+
for (let i = start; i < css.length; i++) {
|
|
1134
|
+
if (css[i] === "{") depth++;
|
|
1135
|
+
if (css[i] === "}") {
|
|
1136
|
+
depth--;
|
|
1137
|
+
if (depth === 0) {
|
|
1138
|
+
end = i + 1;
|
|
1139
|
+
break;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
parts.push(css.slice(start, end));
|
|
1144
|
+
}
|
|
1145
|
+
return parts.join("");
|
|
1146
|
+
}
|
|
1056
1147
|
|
|
1057
1148
|
// ../design-tokens/src/exporters/typescript.ts
|
|
1058
1149
|
function tokenValueToTS(token) {
|
|
@@ -27043,7 +27134,7 @@ function extractShadcnRoot(css) {
|
|
|
27043
27134
|
var THEME_BLOCK = /@theme(?:\s+inline)?\s*\{([^}]*)\}/g;
|
|
27044
27135
|
var COMMENT = /\/\*[\s\S]*?\*\//g;
|
|
27045
27136
|
var DECLARATION = /--([A-Za-z_-][\w-]*)\s*:\s*([^;]+);/g;
|
|
27046
|
-
function
|
|
27137
|
+
function extractThemeBlocks2(css) {
|
|
27047
27138
|
const out = [];
|
|
27048
27139
|
for (const match of css.matchAll(THEME_BLOCK)) {
|
|
27049
27140
|
const body = (match[1] ?? "").replace(COMMENT, "");
|
|
@@ -27060,7 +27151,7 @@ function extractThemeBlocks(css) {
|
|
|
27060
27151
|
// ../design-tokens/src/importers/bases.ts
|
|
27061
27152
|
var LENGTH = /^(-?\d+(?:\.\d+)?)\s*(rem|px|em)$/;
|
|
27062
27153
|
function detectBase(css, names, parse7) {
|
|
27063
|
-
const decls = [...extractShadcnRoot(css), ...
|
|
27154
|
+
const decls = [...extractShadcnRoot(css), ...extractThemeBlocks2(css)];
|
|
27064
27155
|
let last2 = null;
|
|
27065
27156
|
for (const decl of decls) {
|
|
27066
27157
|
if (names.includes(decl.name)) last2 = decl.value.trim();
|
|
@@ -27285,7 +27376,7 @@ function detectFonts(css) {
|
|
|
27285
27376
|
accept(family, quoteIfNeeded(family));
|
|
27286
27377
|
}
|
|
27287
27378
|
const rootDecls = extractShadcnRoot(css);
|
|
27288
|
-
const themeDecls =
|
|
27379
|
+
const themeDecls = extractThemeBlocks2(css);
|
|
27289
27380
|
for (const decl of [...rootDecls, ...themeDecls]) {
|
|
27290
27381
|
if (!decl.name.startsWith("font-")) continue;
|
|
27291
27382
|
const first = firstFamilyFromStack(decl.value);
|
|
@@ -29953,7 +30044,7 @@ async function init(options) {
|
|
|
29953
30044
|
}
|
|
29954
30045
|
}
|
|
29955
30046
|
{
|
|
29956
|
-
const themeDecls =
|
|
30047
|
+
const themeDecls = extractThemeBlocks2(sourceCss);
|
|
29957
30048
|
if (themeDecls.length > 0) {
|
|
29958
30049
|
const POSITION_SUFFIX = new RegExp(`^(.+)-(${SCALE_POSITIONS.join("|")})$`);
|
|
29959
30050
|
const familySeeds = /* @__PURE__ */ new Map();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rafters",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.77",
|
|
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",
|