rafters 0.0.72 → 0.0.74

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.
Files changed (2) hide show
  1. package/dist/index.js +177 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -912,6 +912,147 @@ ${themeBody}`;
912
912
  rmSync(tempDir, { recursive: true, force: true });
913
913
  }
914
914
  }
915
+ var COLOR_UTILITIES = [
916
+ "bg",
917
+ "text",
918
+ "border",
919
+ "ring",
920
+ "outline",
921
+ "fill",
922
+ "stroke",
923
+ "accent",
924
+ "caret",
925
+ "decoration",
926
+ "divide",
927
+ "shadow",
928
+ "placeholder"
929
+ ];
930
+ var SPACING_UTILITIES = [
931
+ "p",
932
+ "px",
933
+ "py",
934
+ "pt",
935
+ "pr",
936
+ "pb",
937
+ "pl",
938
+ "m",
939
+ "mx",
940
+ "my",
941
+ "mt",
942
+ "mr",
943
+ "mb",
944
+ "ml",
945
+ "gap",
946
+ "gap-x",
947
+ "gap-y",
948
+ "w",
949
+ "h",
950
+ "size",
951
+ "inset",
952
+ "top",
953
+ "right",
954
+ "bottom",
955
+ "left",
956
+ "space-x",
957
+ "space-y"
958
+ ];
959
+ var RADIUS_UTILITIES = [
960
+ "rounded",
961
+ "rounded-t",
962
+ "rounded-r",
963
+ "rounded-b",
964
+ "rounded-l",
965
+ "rounded-tl",
966
+ "rounded-tr",
967
+ "rounded-br",
968
+ "rounded-bl"
969
+ ];
970
+ var STATE_VARIANTS = ["hover", "focus-visible", "focus", "active", "dark"];
971
+ function deriveCandidates(themeCSS) {
972
+ const themeVarNames = [];
973
+ const themeBlockRe = /@theme\s*(?:inline\s*)?\{([^}]*)\}/gs;
974
+ let blockMatch;
975
+ while ((blockMatch = themeBlockRe.exec(themeCSS)) !== null) {
976
+ const block = blockMatch[1] ?? "";
977
+ const varRe = /--([a-z][a-z0-9-]*)\s*:/g;
978
+ let varMatch;
979
+ while ((varMatch = varRe.exec(block)) !== null) {
980
+ if (varMatch[1]) themeVarNames.push(varMatch[1]);
981
+ }
982
+ }
983
+ const candidates = /* @__PURE__ */ new Set();
984
+ for (const name of themeVarNames) {
985
+ if (name.startsWith("color-")) {
986
+ const slug = name.slice(6);
987
+ for (const p2 of COLOR_UTILITIES) candidates.add(`${p2}-${slug}`);
988
+ } else if (name.startsWith("spacing-")) {
989
+ const slug = name.slice(8);
990
+ for (const p2 of SPACING_UTILITIES) candidates.add(`${p2}-${slug}`);
991
+ } else if (name.startsWith("radius-")) {
992
+ const slug = name.slice(7);
993
+ for (const p2 of RADIUS_UTILITIES) candidates.add(`${p2}-${slug}`);
994
+ } else if (name.startsWith("shadow-") && !/-(blur|spread|offset|color|inset)/.test(name)) {
995
+ candidates.add(`shadow-${name.slice(7)}`);
996
+ } else if (name.startsWith("font-size-")) {
997
+ candidates.add(`text-${name.slice(10)}`);
998
+ } else if (name.startsWith("font-weight-")) {
999
+ candidates.add(`font-${name.slice(12)}`);
1000
+ } else if (name.startsWith("ease-")) {
1001
+ candidates.add(name);
1002
+ } else if (name.startsWith("animate-")) {
1003
+ candidates.add(name);
1004
+ }
1005
+ }
1006
+ const base = [...candidates];
1007
+ for (const variant of STATE_VARIANTS) {
1008
+ for (const c4 of base) {
1009
+ candidates.add(`${variant}:${c4}`);
1010
+ }
1011
+ }
1012
+ return [...candidates];
1013
+ }
1014
+ async function registryToDocumentation(registry2, options = {}) {
1015
+ const { minify = true } = options;
1016
+ const themeBody = registryToTailwind(registry2, { includeImport: false });
1017
+ const candidates = deriveCandidates(themeBody);
1018
+ const { mkdtempSync, writeFileSync: writeFileSync2, rmSync } = await import("fs");
1019
+ const { join: join15, dirname: dirname4 } = await import("path");
1020
+ const { createRequire: createRequire2 } = await import("module");
1021
+ const require2 = createRequire2(import.meta.url);
1022
+ let pkgDir;
1023
+ try {
1024
+ const pkgJsonPath = require2.resolve("@tailwindcss/cli/package.json");
1025
+ pkgDir = dirname4(pkgJsonPath);
1026
+ } catch {
1027
+ throw new Error(
1028
+ "Failed to resolve @tailwindcss/cli -- install it to generate documentation CSS"
1029
+ );
1030
+ }
1031
+ const tempDir = mkdtempSync(join15(pkgDir, ".tmp-doc-compile-"));
1032
+ const candidateFile = join15(tempDir, "candidates.txt");
1033
+ writeFileSync2(candidateFile, candidates.join("\n"));
1034
+ const sourceDirective = `@source "${candidateFile}";`;
1035
+ const input = `@import "tailwindcss" source(none);
1036
+ ${sourceDirective}
1037
+ ${themeBody}`;
1038
+ const tempInput = join15(tempDir, "input.css");
1039
+ const tempOutput = join15(tempDir, "output.css");
1040
+ try {
1041
+ writeFileSync2(tempInput, input);
1042
+ const { execFileSync } = await import("child_process");
1043
+ const binPath = join15(pkgDir, "dist", "index.mjs");
1044
+ const args = [binPath, "-i", tempInput, "-o", tempOutput];
1045
+ if (minify) args.push("--minify");
1046
+ execFileSync("node", args, { stdio: "pipe", timeout: 6e4, cwd: pkgDir });
1047
+ const { readFileSync: readFileSync3 } = await import("fs");
1048
+ return readFileSync3(tempOutput, "utf-8");
1049
+ } catch (error47) {
1050
+ const message = error47 instanceof Error ? error47.message : String(error47);
1051
+ throw new Error(`Failed to compile documentation CSS: ${message}`);
1052
+ } finally {
1053
+ rmSync(tempDir, { recursive: true, force: true });
1054
+ }
1055
+ }
915
1056
 
916
1057
  // ../design-tokens/src/exporters/typescript.ts
917
1058
  function tokenValueToTS(token) {
@@ -27302,6 +27443,11 @@ async function regenerateOutputs(registry2, input, hooks2 = {}) {
27302
27443
  await writeFile(join2(outputDir2, "rafters.standalone.css"), compiled);
27303
27444
  written.push("rafters.standalone.css");
27304
27445
  }
27446
+ if (exports.documentation) {
27447
+ const doc = await registryToDocumentation(registry2);
27448
+ await writeFile(join2(outputDir2, "rafters.documentation.css"), doc);
27449
+ written.push("rafters.documentation.css");
27450
+ }
27305
27451
  hooks2.notify?.();
27306
27452
  return written;
27307
27453
  }
@@ -28019,7 +28165,8 @@ var DEFAULT_EXPORTS = {
28019
28165
  tailwind: true,
28020
28166
  typescript: true,
28021
28167
  dtcg: false,
28022
- compiled: false
28168
+ compiled: false,
28169
+ documentation: false
28023
28170
  };
28024
28171
  var EXPORT_CHOICES = [
28025
28172
  {
@@ -28041,6 +28188,11 @@ var EXPORT_CHOICES = [
28041
28188
  name: "Standalone CSS (pre-built, no Tailwind required)",
28042
28189
  value: "compiled",
28043
28190
  checked: false
28191
+ },
28192
+ {
28193
+ name: "Documentation CSS (complete utility surface for docs/previews)",
28194
+ value: "documentation",
28195
+ checked: false
28044
28196
  }
28045
28197
  ];
28046
28198
  var FUTURE_EXPORTS = [
@@ -28064,7 +28216,8 @@ function selectionsToConfig(selections) {
28064
28216
  tailwind: selections.includes("tailwind"),
28065
28217
  typescript: selections.includes("typescript"),
28066
28218
  dtcg: selections.includes("dtcg"),
28067
- compiled: selections.includes("compiled")
28219
+ compiled: selections.includes("compiled"),
28220
+ documentation: selections.includes("documentation")
28068
28221
  };
28069
28222
  }
28070
28223
 
@@ -28834,6 +28987,10 @@ function transformFileContent(content, config2, fileType = "component", cwd = pr
28834
28987
  "from '@/$1/$2'"
28835
28988
  );
28836
28989
  }
28990
+ transformed = transformed.replace(
28991
+ /from\s+['"]\.\.\/([^/'"]+)\/\1([^'"]*)['"]/g,
28992
+ `from '@/${aliasComponents}/$1$2'`
28993
+ );
28837
28994
  transformed = transformed.replace(
28838
28995
  /from\s+['"]\.\.\/([^'"]+)['"]/g,
28839
28996
  `from '@/${aliasComponents}/$1'`
@@ -31176,9 +31333,10 @@ function studioApiPlugin() {
31176
31333
  const config2 = await loadStudioConfig();
31177
31334
  const exports = config2?.exports ?? {
31178
31335
  tailwind: true,
31179
- typescript: false,
31336
+ typescript: true,
31180
31337
  dtcg: false,
31181
- compiled: false
31338
+ compiled: false,
31339
+ documentation: false
31182
31340
  };
31183
31341
  await regenerateOutputs(
31184
31342
  registry2,
@@ -31215,21 +31373,27 @@ function studioApiPlugin() {
31215
31373
  }
31216
31374
  };
31217
31375
  {
31218
- const watchConfig = await loadStudioConfig();
31219
- const classDirs = watchConfig ? resolveContentSources(projectPath, watchConfig) : [];
31220
- const watchTargets = [
31221
- join14(tokensDir, "*.rafters.json"),
31222
- configPath,
31223
- ...classDirs.map((dir) => join14(dir, "**/*.classes.ts"))
31224
- ];
31225
- server.watcher.add(watchTargets);
31376
+ const trackedClassDirs = /* @__PURE__ */ new Set();
31377
+ const syncWatchTargets = async () => {
31378
+ const watchConfig = await loadStudioConfig();
31379
+ const classDirs = watchConfig ? resolveContentSources(projectPath, watchConfig) : [];
31380
+ const newDirs = classDirs.filter((d2) => !trackedClassDirs.has(d2));
31381
+ if (newDirs.length > 0) {
31382
+ server.watcher.add(newDirs.map((dir) => join14(dir, "**/*.classes.ts")));
31383
+ for (const d2 of newDirs) trackedClassDirs.add(d2);
31384
+ }
31385
+ };
31386
+ server.watcher.add([join14(tokensDir, "*.rafters.json"), configPath]);
31387
+ await syncWatchTargets();
31226
31388
  let debounce = null;
31227
31389
  const onChange = (changed) => {
31228
31390
  const watched = changed.endsWith(".classes.ts") || changed.endsWith(".rafters.json") || changed === configPath;
31229
31391
  if (!watched) return;
31230
31392
  if (debounce) clearTimeout(debounce);
31231
31393
  debounce = setTimeout(() => {
31232
- void reloadAndRegenerate();
31394
+ const isConfigChange = changed === configPath;
31395
+ const run = isConfigChange ? syncWatchTargets().then(reloadAndRegenerate) : reloadAndRegenerate();
31396
+ void run;
31233
31397
  }, 150);
31234
31398
  };
31235
31399
  server.watcher.on("change", onChange);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rafters",
3
- "version": "0.0.72",
3
+ "version": "0.0.74",
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",