rafters 0.0.30 → 0.0.32

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 +125 -29
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13431,30 +13431,33 @@ function transformFileContent(content, config3, fileType = "component") {
13431
13431
  let transformed = content;
13432
13432
  const componentsPath = config3?.componentsPath ?? "components/ui";
13433
13433
  const primitivesPath = config3?.primitivesPath ?? "lib/primitives";
13434
+ const stripSourceRoot = (p2) => p2.replace(/^(src|app)\//, "");
13435
+ const aliasComponents = stripSourceRoot(componentsPath);
13436
+ const aliasPrimitives = stripSourceRoot(primitivesPath);
13434
13437
  transformed = transformed.replace(
13435
13438
  /from\s+['"]\.\.\/\.\.\/primitives\/([^'"]+)['"]/g,
13436
- `from '@/${primitivesPath}/$1'`
13439
+ `from '@/${aliasPrimitives}/$1'`
13437
13440
  );
13438
13441
  transformed = transformed.replace(
13439
13442
  /from\s+['"]\.\.\/primitives\/([^'"]+)['"]/g,
13440
- `from '@/${primitivesPath}/$1'`
13443
+ `from '@/${aliasPrimitives}/$1'`
13441
13444
  );
13442
- const siblingPath = fileType === "primitive" ? primitivesPath : componentsPath;
13443
- transformed = transformed.replace(/from\s+['"]\.\/([^'"]+)['"]/g, `from '@/${siblingPath}/$1'`);
13444
- const libPath = dirname(primitivesPath);
13445
+ const aliasSibling = fileType === "primitive" ? aliasPrimitives : aliasComponents;
13446
+ transformed = transformed.replace(/from\s+['"]\.\/([^'"]+)['"]/g, `from '@/${aliasSibling}/$1'`);
13447
+ const aliasLib = stripSourceRoot(dirname(primitivesPath));
13445
13448
  transformed = transformed.replace(
13446
13449
  /from\s+['"]\.\.\/lib\/([^'"]+)['"]/g,
13447
- `from '@/${libPath}/$1'`
13450
+ `from '@/${aliasLib}/$1'`
13448
13451
  );
13449
- const componentsMatch = componentsPath.match(/^(.*)components\/ui$/);
13450
- const hooksPath = componentsMatch ? `${componentsMatch[1]}hooks`.replace(/^\//, "") : "hooks";
13452
+ const componentsMatch = aliasComponents.match(/^(.*)components\/ui$/);
13453
+ const aliasHooks = componentsMatch ? `${componentsMatch[1]}hooks`.replace(/^\//, "") : "hooks";
13451
13454
  transformed = transformed.replace(
13452
13455
  /from\s+['"]\.\.\/hooks\/([^'"]+)['"]/g,
13453
- `from '@/${hooksPath}/$1'`
13456
+ `from '@/${aliasHooks}/$1'`
13454
13457
  );
13455
13458
  transformed = transformed.replace(
13456
13459
  /from\s+['"]\.\.\/(?!lib\/|hooks\/)([^'"]+)['"]/g,
13457
- `from '@/${componentsPath}/$1'`
13460
+ `from '@/${aliasComponents}/$1'`
13458
13461
  );
13459
13462
  return transformed;
13460
13463
  }
@@ -46876,7 +46879,7 @@ function generateThemeInlineBlock(semanticTokens) {
46876
46879
  lines.push("}");
46877
46880
  return lines.join("\n");
46878
46881
  }
46879
- function generateRootBlock(semanticTokens) {
46882
+ function generateRootBlock(semanticTokens, darkMode = "class") {
46880
46883
  const semanticMappings = getSemanticMappingsFromTokens(semanticTokens);
46881
46884
  const lines = [];
46882
46885
  lines.push(":root {");
@@ -46893,17 +46896,20 @@ function generateRootBlock(semanticTokens) {
46893
46896
  }
46894
46897
  lines.push("}");
46895
46898
  lines.push("");
46896
- lines.push("@media (prefers-color-scheme: dark) {");
46897
- lines.push(" :root {");
46898
- for (const name2 of Object.keys(semanticMappings)) {
46899
- lines.push(` --${name2}: var(--rafters-dark-${name2});`);
46899
+ if (darkMode === "class") {
46900
+ lines.push("@custom-variant dark (&:where(.dark, .dark *));");
46901
+ lines.push("");
46902
+ lines.push(".dark {");
46903
+ } else {
46904
+ lines.push("@media (prefers-color-scheme: dark) {");
46905
+ lines.push(" :root {");
46900
46906
  }
46901
- lines.push(" }");
46902
- lines.push("}");
46903
- lines.push("");
46904
- lines.push(".dark {");
46905
46907
  for (const name2 of Object.keys(semanticMappings)) {
46906
- lines.push(` --${name2}: var(--rafters-dark-${name2});`);
46908
+ const indent2 = darkMode === "media" ? " " : " ";
46909
+ lines.push(`${indent2}--${name2}: var(--rafters-dark-${name2});`);
46910
+ }
46911
+ if (darkMode === "media") {
46912
+ lines.push(" }");
46907
46913
  }
46908
46914
  lines.push("}");
46909
46915
  lines.push("");
@@ -47126,7 +47132,7 @@ function tokensToTailwind(tokens, options = {}) {
47126
47132
  const themeInlineBlock = generateThemeInlineBlock(groups.semantic);
47127
47133
  sections.push(themeInlineBlock);
47128
47134
  sections.push("");
47129
- const rootBlock = generateRootBlock(groups.semantic);
47135
+ const rootBlock = generateRootBlock(groups.semantic, options.darkMode ?? "class");
47130
47136
  sections.push(rootBlock);
47131
47137
  sections.push("");
47132
47138
  const keyframes = generateKeyframes(groups.motion);
@@ -57654,11 +57660,13 @@ function generateRadiusTokens(config3, radiusDefs) {
57654
57660
  } else if (def.step === "full") {
57655
57661
  value2 = "9999px";
57656
57662
  mathRelationship = "infinite (9999px)";
57663
+ } else if (def.step === 0) {
57664
+ value2 = "var(--rafters-radius-base)";
57665
+ mathRelationship = `${baseRadiusRem}rem (base)`;
57657
57666
  } else {
57658
- const computedPx = Math.round(progression.compute(baseRadius, def.step) * 100) / 100;
57659
- const computedRem = Math.round(computedPx / 16 * 100) / 100;
57660
- value2 = `${computedRem}rem`;
57661
- mathRelationship = def.step === 0 ? `${baseRadiusRem}rem (base)` : `${baseRadiusRem} \xD7 ${progression.ratio}^${def.step}`;
57667
+ const multiplier = Math.round(progression.ratio ** def.step * 1e3) / 1e3;
57668
+ value2 = `calc(var(--rafters-radius-base) * ${multiplier})`;
57669
+ mathRelationship = `base \xD7 ${progression.ratio}^${def.step} (\xD7${multiplier})`;
57662
57670
  }
57663
57671
  tokens.push({
57664
57672
  name: scale3 === "DEFAULT" ? "radius" : `radius-${scale3}`,
@@ -57910,9 +57918,10 @@ function generateSpacingTokens(config3, spacingMultipliers) {
57910
57918
  usageContext = ["hero-spacing", "page-margins", "major-sections"];
57911
57919
  }
57912
57920
  const remValue = value2 / 16;
57921
+ const cssValue = multiplier === 0 ? "0" : multiplier === 1 ? "var(--rafters-spacing-base)" : `calc(var(--rafters-spacing-base) * ${multiplier})`;
57913
57922
  tokens.push({
57914
57923
  name: `spacing-${scale3}`,
57915
- value: value2 === 0 ? "0" : `${remValue}rem`,
57924
+ value: cssValue,
57916
57925
  category: "spacing",
57917
57926
  namespace: "spacing",
57918
57927
  semanticMeaning: meaning,
@@ -58440,10 +58449,10 @@ async function ensureTailwindCli(cwd) {
58440
58449
  );
58441
58450
  }
58442
58451
  }
58443
- async function generateOutputs(cwd, paths, registry2, exports, shadcn) {
58452
+ async function generateOutputs(cwd, paths, registry2, exports, shadcn, darkMode = "class") {
58444
58453
  const outputs = [];
58445
58454
  if (exports.tailwind) {
58446
- const tailwindCss = registryToTailwind(registry2, { includeImport: !shadcn });
58455
+ const tailwindCss = registryToTailwind(registry2, { includeImport: !shadcn, darkMode });
58447
58456
  await writeFile3(join9(paths.output, "rafters.css"), tailwindCss);
58448
58457
  outputs.push("rafters.css");
58449
58458
  }
@@ -58628,6 +58637,91 @@ async function resetToDefaults(cwd, paths, shadcn, isAgentMode2, framework) {
58628
58637
  path: paths.output
58629
58638
  });
58630
58639
  }
58640
+ async function writeRaftersSkill(cwd) {
58641
+ const skillDir = join9(cwd, ".claude", "skills", "rafters-frontend");
58642
+ await mkdir3(skillDir, { recursive: true });
58643
+ const skill = `---
58644
+ name: rafters-frontend
58645
+ description: Use when building frontend UI in a Rafters project -- enforces Container, Grid, typography components, and design token usage.
58646
+ ---
58647
+
58648
+ ## Layout Is Solved
58649
+
58650
+ Container and Grid handle ALL layout. You do not write layout code.
58651
+
58652
+ \`\`\`tsx
58653
+ // WRONG
58654
+ <div className={classy("flex gap-4 p-6")}>
58655
+
58656
+ // RIGHT
58657
+ <Container>
58658
+ <Grid preset="sidebar-main">
58659
+ <aside>Sidebar</aside>
58660
+ <main>Content</main>
58661
+ </Grid>
58662
+ </Container>
58663
+ \`\`\`
58664
+
58665
+ **Never use:** flex, grid, gap-*, p-*, m-*, items-*, justify-*
58666
+
58667
+ ### Grid Presets
58668
+
58669
+ | Preset | Use for |
58670
+ |---|---|
58671
+ | sidebar-main | Navigation + content |
58672
+ | form | Label/input pairs |
58673
+ | cards | Responsive card grid |
58674
+ | row | Horizontal group |
58675
+ | stack | Vertical sequence |
58676
+ | split | Equal columns |
58677
+
58678
+ ## Typography -- Components, Not Utilities
58679
+
58680
+ | Instead of | Use |
58681
+ |---|---|
58682
+ | \`<p className="text-sm text-muted-foreground">\` | \`<Muted>\` |
58683
+ | \`<p>\` | \`<P>\` |
58684
+ | \`<h1 className="text-4xl font-bold">\` | \`<H1>\` |
58685
+ | \`<h2>\` | \`<H2>\` |
58686
+ | \`<h3>\` | \`<H3>\` |
58687
+ | \`<span className="text-xs">\` | \`<Small>\` |
58688
+ | \`<span className="text-lg font-semibold">\` | \`<Large>\` |
58689
+
58690
+ ## Color -- Tokens, Not Values
58691
+
58692
+ Use semantic tokens as Tailwind classes: \`bg-primary\`, \`text-destructive\`, \`border-success\`.
58693
+ Never use hex, HSL, or palette internals.
58694
+
58695
+ ## A Correct Page
58696
+
58697
+ \`\`\`tsx
58698
+ import { Container, Grid } from "@rafters/ui"
58699
+ import { H1, Lead } from "@rafters/ui/components/ui/typography"
58700
+ import { Card } from "@rafters/ui/components/ui/card"
58701
+ import { Button } from "@rafters/ui/components/ui/button"
58702
+
58703
+ export default function Page() {
58704
+ return (
58705
+ <Container>
58706
+ <H1>Title</H1>
58707
+ <Lead>Description.</Lead>
58708
+ <Grid preset="cards">
58709
+ <Card>...</Card>
58710
+ <Card>...</Card>
58711
+ </Grid>
58712
+ <Grid preset="row">
58713
+ <Button variant="secondary">Cancel</Button>
58714
+ <Button>Save</Button>
58715
+ </Grid>
58716
+ </Container>
58717
+ )
58718
+ }
58719
+ \`\`\`
58720
+
58721
+ No flex. No gap. No padding. No text utilities.
58722
+ `;
58723
+ await writeFile3(join9(skillDir, "SKILL.md"), skill);
58724
+ }
58631
58725
  async function init(options) {
58632
58726
  setAgentMode(options.agent ?? false);
58633
58727
  const isAgentMode2 = options.agent ?? false;
@@ -58747,6 +58841,7 @@ async function init(options) {
58747
58841
  }
58748
58842
  };
58749
58843
  await writeFile3(paths.config, JSON.stringify(config3, null, 2));
58844
+ await writeRaftersSkill(cwd);
58750
58845
  const existingCssPath = detectedCssPath ?? (shadcn?.tailwind?.css || null);
58751
58846
  if (existingCssPath) {
58752
58847
  try {
@@ -60972,7 +61067,8 @@ var RaftersToolHandler = class _RaftersToolHandler {
60972
61067
  const shadcn = config3?.shadcn ?? false;
60973
61068
  await mkdir4(paths.output, { recursive: true });
60974
61069
  if (exports.tailwind) {
60975
- const css3 = registryToTailwind(registry2, { includeImport: !shadcn });
61070
+ const darkMode = config3?.darkMode ?? "class";
61071
+ const css3 = registryToTailwind(registry2, { includeImport: !shadcn, darkMode });
60976
61072
  await writeFile4(join10(paths.output, "rafters.css"), css3);
60977
61073
  }
60978
61074
  if (exports.typescript) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rafters",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "CLI for Rafters design system - scaffold tokens and add components",
5
5
  "license": "MIT",
6
6
  "type": "module",