rafters 0.0.13 → 0.0.15
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 +355 -257
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
import { Command } from "commander";
|
|
9
9
|
|
|
10
10
|
// src/commands/add.ts
|
|
11
|
-
import { existsSync } from "fs";
|
|
12
|
-
import { access, mkdir, readFile as
|
|
13
|
-
import { dirname, join as
|
|
11
|
+
import { existsSync as existsSync2 } from "fs";
|
|
12
|
+
import { access, mkdir, readFile as readFile3, writeFile } from "fs/promises";
|
|
13
|
+
import { dirname, join as join4 } from "path";
|
|
14
14
|
|
|
15
15
|
// ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/external.js
|
|
16
16
|
var external_exports = {};
|
|
@@ -12751,6 +12751,159 @@ var RegistryClient = class {
|
|
|
12751
12751
|
};
|
|
12752
12752
|
var registryClient = new RegistryClient();
|
|
12753
12753
|
|
|
12754
|
+
// src/utils/detect.ts
|
|
12755
|
+
import { existsSync } from "fs";
|
|
12756
|
+
import { readFile } from "fs/promises";
|
|
12757
|
+
import { join } from "path";
|
|
12758
|
+
var CONFIG_FILE_FRAMEWORKS = [
|
|
12759
|
+
{ files: ["astro.config.mjs", "astro.config.ts", "astro.config.js"], framework: "astro" },
|
|
12760
|
+
{ files: ["next.config.mjs", "next.config.ts", "next.config.js"], framework: "next" },
|
|
12761
|
+
{ files: ["remix.config.js", "remix.config.ts"], framework: "remix" },
|
|
12762
|
+
{ files: ["vite.config.ts", "vite.config.js", "vite.config.mjs"], framework: "vite" }
|
|
12763
|
+
];
|
|
12764
|
+
async function detectFramework(cwd) {
|
|
12765
|
+
try {
|
|
12766
|
+
const content = await readFile(join(cwd, "package.json"), "utf-8");
|
|
12767
|
+
const pkg = JSON.parse(content);
|
|
12768
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
12769
|
+
if (deps.next) {
|
|
12770
|
+
return "next";
|
|
12771
|
+
}
|
|
12772
|
+
if (deps["react-router"]) {
|
|
12773
|
+
return "react-router";
|
|
12774
|
+
}
|
|
12775
|
+
const hasRemix = Object.keys(deps).some((dep) => dep.startsWith("@remix-run/"));
|
|
12776
|
+
if (hasRemix) {
|
|
12777
|
+
return "remix";
|
|
12778
|
+
}
|
|
12779
|
+
if (deps.astro) {
|
|
12780
|
+
return "astro";
|
|
12781
|
+
}
|
|
12782
|
+
if (deps.vite) {
|
|
12783
|
+
return "vite";
|
|
12784
|
+
}
|
|
12785
|
+
} catch {
|
|
12786
|
+
}
|
|
12787
|
+
return detectFrameworkFromConfigFiles(cwd);
|
|
12788
|
+
}
|
|
12789
|
+
function detectFrameworkFromConfigFiles(cwd) {
|
|
12790
|
+
for (const { files, framework } of CONFIG_FILE_FRAMEWORKS) {
|
|
12791
|
+
for (const file2 of files) {
|
|
12792
|
+
if (existsSync(join(cwd, file2))) {
|
|
12793
|
+
return framework;
|
|
12794
|
+
}
|
|
12795
|
+
}
|
|
12796
|
+
}
|
|
12797
|
+
return "unknown";
|
|
12798
|
+
}
|
|
12799
|
+
async function detectTailwindVersion(cwd) {
|
|
12800
|
+
try {
|
|
12801
|
+
const content = await readFile(join(cwd, "package.json"), "utf-8");
|
|
12802
|
+
const pkg = JSON.parse(content);
|
|
12803
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
12804
|
+
const tailwindVersion = deps.tailwindcss;
|
|
12805
|
+
if (!tailwindVersion) {
|
|
12806
|
+
return null;
|
|
12807
|
+
}
|
|
12808
|
+
const versionMatch = tailwindVersion.match(/\d+\.\d+\.\d+/);
|
|
12809
|
+
return versionMatch ? versionMatch[0] : tailwindVersion;
|
|
12810
|
+
} catch {
|
|
12811
|
+
return null;
|
|
12812
|
+
}
|
|
12813
|
+
}
|
|
12814
|
+
function isTailwindV3(version2) {
|
|
12815
|
+
if (!version2) {
|
|
12816
|
+
return false;
|
|
12817
|
+
}
|
|
12818
|
+
return version2.startsWith("3.");
|
|
12819
|
+
}
|
|
12820
|
+
async function detectShadcn(cwd) {
|
|
12821
|
+
try {
|
|
12822
|
+
const content = await readFile(join(cwd, "components.json"), "utf-8");
|
|
12823
|
+
return JSON.parse(content);
|
|
12824
|
+
} catch {
|
|
12825
|
+
return null;
|
|
12826
|
+
}
|
|
12827
|
+
}
|
|
12828
|
+
function parseCssVariables(css3) {
|
|
12829
|
+
const light = {};
|
|
12830
|
+
const dark = {};
|
|
12831
|
+
const rootMatch = css3.match(/:root\s*\{([^}]+)\}/);
|
|
12832
|
+
if (rootMatch?.[1]) {
|
|
12833
|
+
parseVariablesIntoColors(rootMatch[1], light);
|
|
12834
|
+
}
|
|
12835
|
+
const darkMatch = css3.match(/\.dark\s*\{([^}]+)\}/);
|
|
12836
|
+
if (darkMatch?.[1]) {
|
|
12837
|
+
parseVariablesIntoColors(darkMatch[1], dark);
|
|
12838
|
+
}
|
|
12839
|
+
return { light, dark };
|
|
12840
|
+
}
|
|
12841
|
+
function parseVariablesIntoColors(block, colors) {
|
|
12842
|
+
const varMap = {
|
|
12843
|
+
"--background": "background",
|
|
12844
|
+
"--foreground": "foreground",
|
|
12845
|
+
"--card": "card",
|
|
12846
|
+
"--card-foreground": "cardForeground",
|
|
12847
|
+
"--popover": "popover",
|
|
12848
|
+
"--popover-foreground": "popoverForeground",
|
|
12849
|
+
"--primary": "primary",
|
|
12850
|
+
"--primary-foreground": "primaryForeground",
|
|
12851
|
+
"--secondary": "secondary",
|
|
12852
|
+
"--secondary-foreground": "secondaryForeground",
|
|
12853
|
+
"--muted": "muted",
|
|
12854
|
+
"--muted-foreground": "mutedForeground",
|
|
12855
|
+
"--accent": "accent",
|
|
12856
|
+
"--accent-foreground": "accentForeground",
|
|
12857
|
+
"--destructive": "destructive",
|
|
12858
|
+
"--destructive-foreground": "destructiveForeground",
|
|
12859
|
+
"--border": "border",
|
|
12860
|
+
"--input": "input",
|
|
12861
|
+
"--ring": "ring"
|
|
12862
|
+
};
|
|
12863
|
+
for (const [cssVar, colorKey] of Object.entries(varMap)) {
|
|
12864
|
+
const regex = new RegExp(`${cssVar}:\\s*([^;]+);`);
|
|
12865
|
+
const match2 = block.match(regex);
|
|
12866
|
+
if (match2?.[1]) {
|
|
12867
|
+
colors[colorKey] = match2[1].trim();
|
|
12868
|
+
}
|
|
12869
|
+
}
|
|
12870
|
+
}
|
|
12871
|
+
function frameworkToTarget(framework) {
|
|
12872
|
+
if (framework === "astro") return "astro";
|
|
12873
|
+
return "react";
|
|
12874
|
+
}
|
|
12875
|
+
function targetToExtension(target) {
|
|
12876
|
+
const map2 = {
|
|
12877
|
+
react: ".tsx",
|
|
12878
|
+
astro: ".astro",
|
|
12879
|
+
vue: ".vue",
|
|
12880
|
+
svelte: ".svelte"
|
|
12881
|
+
};
|
|
12882
|
+
return map2[target];
|
|
12883
|
+
}
|
|
12884
|
+
async function hasAstroReact(cwd) {
|
|
12885
|
+
try {
|
|
12886
|
+
const content = await readFile(join(cwd, "package.json"), "utf-8");
|
|
12887
|
+
const pkg = JSON.parse(content);
|
|
12888
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
12889
|
+
return Boolean(deps["@astrojs/react"]);
|
|
12890
|
+
} catch {
|
|
12891
|
+
return false;
|
|
12892
|
+
}
|
|
12893
|
+
}
|
|
12894
|
+
async function detectProject(cwd) {
|
|
12895
|
+
const [framework, shadcn, tailwindVersion] = await Promise.all([
|
|
12896
|
+
detectFramework(cwd),
|
|
12897
|
+
detectShadcn(cwd),
|
|
12898
|
+
detectTailwindVersion(cwd)
|
|
12899
|
+
]);
|
|
12900
|
+
return {
|
|
12901
|
+
framework,
|
|
12902
|
+
shadcn,
|
|
12903
|
+
tailwindVersion
|
|
12904
|
+
};
|
|
12905
|
+
}
|
|
12906
|
+
|
|
12754
12907
|
// src/utils/exports.ts
|
|
12755
12908
|
var DEFAULT_EXPORTS = {
|
|
12756
12909
|
tailwind: true,
|
|
@@ -12806,8 +12959,8 @@ function selectionsToConfig(selections) {
|
|
|
12806
12959
|
}
|
|
12807
12960
|
|
|
12808
12961
|
// src/utils/install-registry-deps.ts
|
|
12809
|
-
import { readFile } from "fs/promises";
|
|
12810
|
-
import { join } from "path";
|
|
12962
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
12963
|
+
import { join as join2 } from "path";
|
|
12811
12964
|
|
|
12812
12965
|
// src/utils/ui.ts
|
|
12813
12966
|
import ora from "ora";
|
|
@@ -13098,7 +13251,7 @@ function parseDependency(dep) {
|
|
|
13098
13251
|
async function readInstalledDeps(targetDir) {
|
|
13099
13252
|
let raw;
|
|
13100
13253
|
try {
|
|
13101
|
-
raw = await
|
|
13254
|
+
raw = await readFile2(join2(targetDir, "package.json"), "utf-8");
|
|
13102
13255
|
} catch {
|
|
13103
13256
|
return { packageJsonFound: false, installed: /* @__PURE__ */ new Set() };
|
|
13104
13257
|
}
|
|
@@ -13190,14 +13343,14 @@ async function installRegistryDependencies(items, targetDir, options = {}) {
|
|
|
13190
13343
|
}
|
|
13191
13344
|
|
|
13192
13345
|
// src/utils/paths.ts
|
|
13193
|
-
import { join as
|
|
13346
|
+
import { join as join3 } from "path";
|
|
13194
13347
|
function getRaftersPaths(projectRoot = process.cwd()) {
|
|
13195
|
-
const root =
|
|
13348
|
+
const root = join3(projectRoot, ".rafters");
|
|
13196
13349
|
return {
|
|
13197
13350
|
root,
|
|
13198
|
-
config:
|
|
13199
|
-
tokens:
|
|
13200
|
-
output:
|
|
13351
|
+
config: join3(root, "config.rafters.json"),
|
|
13352
|
+
tokens: join3(root, "tokens"),
|
|
13353
|
+
output: join3(root, "output")
|
|
13201
13354
|
};
|
|
13202
13355
|
}
|
|
13203
13356
|
|
|
@@ -13214,10 +13367,10 @@ async function isInitialized(cwd) {
|
|
|
13214
13367
|
async function loadConfig(cwd) {
|
|
13215
13368
|
const paths = getRaftersPaths(cwd);
|
|
13216
13369
|
try {
|
|
13217
|
-
const content = await
|
|
13370
|
+
const content = await readFile3(paths.config, "utf-8");
|
|
13218
13371
|
return JSON.parse(content);
|
|
13219
13372
|
} catch (err) {
|
|
13220
|
-
if (
|
|
13373
|
+
if (existsSync2(paths.config)) {
|
|
13221
13374
|
const message = err instanceof Error ? err.message : String(err);
|
|
13222
13375
|
log({ event: "add:warning", message: `Failed to load config: ${message}` });
|
|
13223
13376
|
}
|
|
@@ -13237,6 +13390,33 @@ function getInstalledNames(config3) {
|
|
|
13237
13390
|
]);
|
|
13238
13391
|
return [...names2].sort();
|
|
13239
13392
|
}
|
|
13393
|
+
function getComponentTarget(config3) {
|
|
13394
|
+
if (config3?.componentTarget) return config3.componentTarget;
|
|
13395
|
+
if (config3?.framework) return frameworkToTarget(config3.framework);
|
|
13396
|
+
return "react";
|
|
13397
|
+
}
|
|
13398
|
+
var SHARED_EXTENSIONS = /* @__PURE__ */ new Set([".classes.ts", ".types.ts", ".constants.ts"]);
|
|
13399
|
+
function isSharedFile(path2) {
|
|
13400
|
+
for (const ext2 of SHARED_EXTENSIONS) {
|
|
13401
|
+
if (path2.endsWith(ext2)) return true;
|
|
13402
|
+
}
|
|
13403
|
+
return false;
|
|
13404
|
+
}
|
|
13405
|
+
function selectFilesForFramework(files, target) {
|
|
13406
|
+
const preferredExt = targetToExtension(target);
|
|
13407
|
+
const shared = files.filter((f) => isSharedFile(f.path));
|
|
13408
|
+
const matched = files.filter((f) => f.path.endsWith(preferredExt));
|
|
13409
|
+
if (matched.length > 0) {
|
|
13410
|
+
return { files: [...matched, ...shared], fallback: false };
|
|
13411
|
+
}
|
|
13412
|
+
if (target !== "react") {
|
|
13413
|
+
const fallbackFiles = files.filter((f) => f.path.endsWith(".tsx"));
|
|
13414
|
+
if (fallbackFiles.length > 0) {
|
|
13415
|
+
return { files: [...fallbackFiles, ...shared], fallback: true };
|
|
13416
|
+
}
|
|
13417
|
+
}
|
|
13418
|
+
return { files, fallback: false };
|
|
13419
|
+
}
|
|
13240
13420
|
var FOLDER_NAMES = /* @__PURE__ */ new Set(["composites"]);
|
|
13241
13421
|
function isAlreadyInstalled(config3, item) {
|
|
13242
13422
|
if (!config3?.installed) return false;
|
|
@@ -13288,7 +13468,7 @@ function transformPath(registryPath, config3) {
|
|
|
13288
13468
|
return registryPath;
|
|
13289
13469
|
}
|
|
13290
13470
|
function fileExists(cwd, relativePath) {
|
|
13291
|
-
return
|
|
13471
|
+
return existsSync2(join4(cwd, relativePath));
|
|
13292
13472
|
}
|
|
13293
13473
|
function transformFileContent(content, config3, fileType = "component") {
|
|
13294
13474
|
let transformed = content;
|
|
@@ -13324,9 +13504,23 @@ function transformFileContent(content, config3, fileType = "component") {
|
|
|
13324
13504
|
async function installItem(cwd, item, options, config3) {
|
|
13325
13505
|
const installedFiles = [];
|
|
13326
13506
|
let skipped = false;
|
|
13327
|
-
|
|
13507
|
+
let filesToInstall = item.files;
|
|
13508
|
+
if (item.type === "ui") {
|
|
13509
|
+
const target = getComponentTarget(config3);
|
|
13510
|
+
const selection = selectFilesForFramework(item.files, target);
|
|
13511
|
+
filesToInstall = selection.files;
|
|
13512
|
+
if (selection.fallback) {
|
|
13513
|
+
log({
|
|
13514
|
+
event: "add:fallback",
|
|
13515
|
+
component: item.name,
|
|
13516
|
+
target,
|
|
13517
|
+
message: `No ${targetToExtension(target)} version available for ${item.name}. Installing React version.`
|
|
13518
|
+
});
|
|
13519
|
+
}
|
|
13520
|
+
}
|
|
13521
|
+
for (const file2 of filesToInstall) {
|
|
13328
13522
|
const projectPath = transformPath(file2.path, config3);
|
|
13329
|
-
const targetPath =
|
|
13523
|
+
const targetPath = join4(cwd, projectPath);
|
|
13330
13524
|
if (fileExists(cwd, projectPath)) {
|
|
13331
13525
|
if (!options.overwrite) {
|
|
13332
13526
|
log({
|
|
@@ -13548,7 +13742,7 @@ import { existsSync as existsSync3 } from "fs";
|
|
|
13548
13742
|
import { copyFile, mkdir as mkdir3, readFile as readFile5, rm, writeFile as writeFile3 } from "fs/promises";
|
|
13549
13743
|
import { createRequire } from "module";
|
|
13550
13744
|
import { join as join9, relative } from "path";
|
|
13551
|
-
import { checkbox, confirm } from "@inquirer/prompts";
|
|
13745
|
+
import { checkbox, confirm, select } from "@inquirer/prompts";
|
|
13552
13746
|
|
|
13553
13747
|
// ../design-tokens/src/plugins/scale.ts
|
|
13554
13748
|
function scale(registry2, tokenName, dependencies) {
|
|
@@ -27861,7 +28055,7 @@ var posix = {
|
|
|
27861
28055
|
|
|
27862
28056
|
// ../../node_modules/.pnpm/path-unified@0.2.0/node_modules/path-unified/src/posix.js
|
|
27863
28057
|
var resolve = posResolve;
|
|
27864
|
-
var
|
|
28058
|
+
var join5 = posJoin;
|
|
27865
28059
|
|
|
27866
28060
|
// ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
|
|
27867
28061
|
var balanced = (a, b, str) => {
|
|
@@ -37760,7 +37954,7 @@ var transforms_default = {
|
|
|
37760
37954
|
type: value,
|
|
37761
37955
|
filter: isAsset,
|
|
37762
37956
|
transform: function(token, _, options) {
|
|
37763
|
-
return
|
|
37957
|
+
return join5(process?.cwd() ?? "/", options.usesDtcg ? token.$value : token.value);
|
|
37764
37958
|
}
|
|
37765
37959
|
},
|
|
37766
37960
|
/**
|
|
@@ -43960,12 +44154,12 @@ var formats_default = formats2;
|
|
|
43960
44154
|
var { androidCopyImages, copyAssets } = actions;
|
|
43961
44155
|
var { silent } = logVerbosityLevels;
|
|
43962
44156
|
function getAssetDir(config3) {
|
|
43963
|
-
return
|
|
44157
|
+
return join5(config3.buildPath ?? "", "android/main/res/drawable-").replace(/\\/g, "/");
|
|
43964
44158
|
}
|
|
43965
44159
|
function getAssetPath(token, imagesDir) {
|
|
43966
44160
|
const name2 = token.path.slice(2, 4).join("_");
|
|
43967
44161
|
const dir = `${imagesDir}${token.attributes?.state}`;
|
|
43968
|
-
return { file:
|
|
44162
|
+
return { file: join5(dir, `${name2}.png`), dir };
|
|
43969
44163
|
}
|
|
43970
44164
|
var actions_default = {
|
|
43971
44165
|
/**
|
|
@@ -44006,7 +44200,7 @@ var actions_default = {
|
|
|
44006
44200
|
*/
|
|
44007
44201
|
[copyAssets]: {
|
|
44008
44202
|
do: async function(_, config3, _options, vol2 = fs2) {
|
|
44009
|
-
const assetsPath =
|
|
44203
|
+
const assetsPath = join5(config3.buildPath ?? "", "assets");
|
|
44010
44204
|
if (config3.log?.verbosity !== silent) {
|
|
44011
44205
|
console.log(`Copying assets directory to ${assetsPath}`);
|
|
44012
44206
|
}
|
|
@@ -44020,7 +44214,7 @@ var actions_default = {
|
|
|
44020
44214
|
);
|
|
44021
44215
|
},
|
|
44022
44216
|
undo: async function(_, config3, _options, vol2 = fs2) {
|
|
44023
|
-
const assetsPath =
|
|
44217
|
+
const assetsPath = join5(config3.buildPath ?? "", "assets");
|
|
44024
44218
|
if (config3.log?.verbosity !== silent) {
|
|
44025
44219
|
console.log(`Removing assets directory from ${assetsPath}`);
|
|
44026
44220
|
}
|
|
@@ -47486,11 +47680,11 @@ function getParser4({ startLine = 0, fence = "```", spacing = "compact", markers
|
|
|
47486
47680
|
}
|
|
47487
47681
|
|
|
47488
47682
|
// ../../node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/stringifier/index.js
|
|
47489
|
-
function
|
|
47683
|
+
function join6(tokens) {
|
|
47490
47684
|
return tokens.start + tokens.delimiter + tokens.postDelimiter + tokens.tag + tokens.postTag + tokens.type + tokens.postType + tokens.name + tokens.postName + tokens.description + tokens.end + tokens.lineEnd;
|
|
47491
47685
|
}
|
|
47492
47686
|
function getStringifier() {
|
|
47493
|
-
return (block) => block.source.map(({ tokens }) =>
|
|
47687
|
+
return (block) => block.source.map(({ tokens }) => join6(tokens)).join("\n");
|
|
47494
47688
|
}
|
|
47495
47689
|
|
|
47496
47690
|
// ../../node_modules/.pnpm/comment-parser@1.4.1/node_modules/comment-parser/es6/stringifier/inspect.js
|
|
@@ -49003,74 +49197,27 @@ function validateScaleGeneration(baseColor) {
|
|
|
49003
49197
|
}
|
|
49004
49198
|
return { isValid: true };
|
|
49005
49199
|
}
|
|
49006
|
-
function
|
|
49007
|
-
const
|
|
49008
|
-
const
|
|
49009
|
-
const
|
|
49010
|
-
|
|
49011
|
-
// Ultra-subtle (dark mode borders)
|
|
49012
|
-
"100": 1.45,
|
|
49013
|
-
// Subtle (dark mode disabled text)
|
|
49014
|
-
"200": 2.05,
|
|
49015
|
-
// Functional (dark mode secondary UI)
|
|
49016
|
-
"300": 3,
|
|
49017
|
-
// Large text AA minimum
|
|
49018
|
-
"400": 4.54,
|
|
49019
|
-
// Normal text AA (light mode)
|
|
49020
|
-
"500": null,
|
|
49021
|
-
// Crossover - avoid this zone
|
|
49022
|
-
"600": 7,
|
|
49023
|
-
// Normal text AAA
|
|
49024
|
-
"700": 10.86,
|
|
49025
|
-
// High contrast
|
|
49026
|
-
"800": 11.86,
|
|
49027
|
-
// Higher contrast
|
|
49028
|
-
"900": 12.86,
|
|
49029
|
-
// Maximum usable
|
|
49030
|
-
"950": 13.86
|
|
49031
|
-
// Absolute maximum
|
|
49032
|
-
};
|
|
49200
|
+
function generateLightnessProgression(baseLightness) {
|
|
49201
|
+
const MAX_LIGHT = 0.95;
|
|
49202
|
+
const MIN_DARK = 0.05;
|
|
49203
|
+
const positions = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
49204
|
+
const baseIndex = 6;
|
|
49033
49205
|
const lightness = {};
|
|
49034
|
-
|
|
49035
|
-
|
|
49036
|
-
|
|
49037
|
-
|
|
49038
|
-
|
|
49039
|
-
|
|
49040
|
-
|
|
49041
|
-
|
|
49042
|
-
for (
|
|
49043
|
-
|
|
49044
|
-
|
|
49045
|
-
|
|
49046
|
-
|
|
49047
|
-
|
|
49048
|
-
|
|
49049
|
-
calculatedL = lightnessForContrast(targetRatio, BLACK_L, true);
|
|
49050
|
-
const stepNum = Number.parseInt(step, 10);
|
|
49051
|
-
if (stepNum === 50)
|
|
49052
|
-
calculatedL = 0.98;
|
|
49053
|
-
else if (stepNum === 100)
|
|
49054
|
-
calculatedL = 0.95;
|
|
49055
|
-
else if (stepNum === 200)
|
|
49056
|
-
calculatedL = 0.9;
|
|
49057
|
-
else if (stepNum === 300)
|
|
49058
|
-
calculatedL = 0.8;
|
|
49059
|
-
else if (stepNum === 400) calculatedL = 0.7;
|
|
49060
|
-
} else {
|
|
49061
|
-
calculatedL = lightnessForContrast(targetRatio, WHITE_L, false);
|
|
49062
|
-
const stepNum = Number.parseInt(step, 10);
|
|
49063
|
-
if (stepNum === 600)
|
|
49064
|
-
calculatedL = 0.4;
|
|
49065
|
-
else if (stepNum === 700)
|
|
49066
|
-
calculatedL = 0.25;
|
|
49067
|
-
else if (stepNum === 800)
|
|
49068
|
-
calculatedL = 0.15;
|
|
49069
|
-
else if (stepNum === 900)
|
|
49070
|
-
calculatedL = 0.08;
|
|
49071
|
-
else if (stepNum === 950) calculatedL = 0.04;
|
|
49072
|
-
}
|
|
49073
|
-
lightness[step] = Math.max(5e-3, Math.min(0.98, calculatedL));
|
|
49206
|
+
for (let i = 0; i < baseIndex; i++) {
|
|
49207
|
+
const stepsFromBase = baseIndex - i;
|
|
49208
|
+
const totalLighterSteps = baseIndex;
|
|
49209
|
+
const t2 = (stepsFromBase / totalLighterSteps) ** 0.8;
|
|
49210
|
+
const calculatedL = baseLightness + (MAX_LIGHT - baseLightness) * t2;
|
|
49211
|
+
lightness[positions[i].toString()] = Math.min(MAX_LIGHT, calculatedL);
|
|
49212
|
+
}
|
|
49213
|
+
lightness["600"] = baseLightness;
|
|
49214
|
+
for (let i = baseIndex + 1; i < positions.length; i++) {
|
|
49215
|
+
const stepsFromBase = i - baseIndex;
|
|
49216
|
+
const totalDarkerSteps = positions.length - 1 - baseIndex;
|
|
49217
|
+
const t2 = stepsFromBase / totalDarkerSteps;
|
|
49218
|
+
const darkenAmount = (baseLightness - MIN_DARK) * t2;
|
|
49219
|
+
const calculatedL = Math.max(MIN_DARK, baseLightness - darkenAmount);
|
|
49220
|
+
lightness[positions[i].toString()] = calculatedL;
|
|
49074
49221
|
}
|
|
49075
49222
|
return lightness;
|
|
49076
49223
|
}
|
|
@@ -49080,25 +49227,18 @@ function generateOKLCHScale(baseColor) {
|
|
|
49080
49227
|
const adjustedColor = validation.suggestedLightness ? { ...baseColor, l: validation.suggestedLightness } : baseColor;
|
|
49081
49228
|
return generateOKLCHScale(adjustedColor);
|
|
49082
49229
|
}
|
|
49083
|
-
const lightnessSteps =
|
|
49230
|
+
const lightnessSteps = generateLightnessProgression(baseColor.l);
|
|
49084
49231
|
const scale2 = {};
|
|
49085
49232
|
for (const [step, lightness] of Object.entries(lightnessSteps)) {
|
|
49086
49233
|
let adjustedChroma = baseColor.c;
|
|
49087
49234
|
if (lightness > 0.9) {
|
|
49088
|
-
adjustedChroma *= 0.
|
|
49089
|
-
} else if (lightness > 0.8) {
|
|
49090
|
-
adjustedChroma *= 0.25;
|
|
49091
|
-
} else if (lightness > 0.6) {
|
|
49092
|
-
adjustedChroma *= 0.7;
|
|
49235
|
+
adjustedChroma *= 0.3;
|
|
49093
49236
|
} else if (lightness < 0.15) {
|
|
49094
|
-
adjustedChroma *= 0.
|
|
49095
|
-
} else if (lightness < 0.3) {
|
|
49096
|
-
adjustedChroma *= 0.9;
|
|
49237
|
+
adjustedChroma *= 0.6;
|
|
49097
49238
|
}
|
|
49098
49239
|
scale2[step] = roundOKLCH({
|
|
49099
49240
|
l: lightness,
|
|
49100
|
-
c:
|
|
49101
|
-
// Ensure minimum chroma
|
|
49241
|
+
c: adjustedChroma,
|
|
49102
49242
|
h: baseColor.h,
|
|
49103
49243
|
alpha: baseColor.alpha
|
|
49104
49244
|
});
|
|
@@ -50844,14 +50984,14 @@ function buildColorSystem(options = {}) {
|
|
|
50844
50984
|
}
|
|
50845
50985
|
|
|
50846
50986
|
// ../design-tokens/src/persistence/node-adapter.ts
|
|
50847
|
-
import { mkdir as mkdir2, readdir as readdir2, readFile as
|
|
50848
|
-
import { join as
|
|
50987
|
+
import { mkdir as mkdir2, readdir as readdir2, readFile as readFile4, writeFile as writeFile2 } from "fs/promises";
|
|
50988
|
+
import { join as join7 } from "path";
|
|
50849
50989
|
var SCHEMA_URL = "https://rafters.studio/schemas/namespace-tokens.json";
|
|
50850
50990
|
var VERSION = "1.0.0";
|
|
50851
50991
|
var NodePersistenceAdapter = class {
|
|
50852
50992
|
tokensDir;
|
|
50853
50993
|
constructor(projectRoot) {
|
|
50854
|
-
this.tokensDir =
|
|
50994
|
+
this.tokensDir = join7(projectRoot, ".rafters", "tokens");
|
|
50855
50995
|
}
|
|
50856
50996
|
async load() {
|
|
50857
50997
|
let files;
|
|
@@ -50863,7 +51003,7 @@ var NodePersistenceAdapter = class {
|
|
|
50863
51003
|
const allTokens = [];
|
|
50864
51004
|
for (const file2 of files) {
|
|
50865
51005
|
if (!file2.endsWith(".rafters.json")) continue;
|
|
50866
|
-
const content = await
|
|
51006
|
+
const content = await readFile4(join7(this.tokensDir, file2), "utf-8");
|
|
50867
51007
|
const data = NamespaceFileSchema.parse(JSON.parse(content));
|
|
50868
51008
|
allTokens.push(...data.tokens);
|
|
50869
51009
|
}
|
|
@@ -50891,7 +51031,7 @@ var NodePersistenceAdapter = class {
|
|
|
50891
51031
|
};
|
|
50892
51032
|
NamespaceFileSchema.parse(data);
|
|
50893
51033
|
await writeFile2(
|
|
50894
|
-
|
|
51034
|
+
join7(this.tokensDir, `${namespace}.rafters.json`),
|
|
50895
51035
|
JSON.stringify(data, null, 2)
|
|
50896
51036
|
);
|
|
50897
51037
|
}
|
|
@@ -50900,7 +51040,7 @@ var NodePersistenceAdapter = class {
|
|
|
50900
51040
|
|
|
50901
51041
|
// ../design-tokens/src/rule-engine.ts
|
|
50902
51042
|
import { promises as fs3 } from "fs";
|
|
50903
|
-
import { join as
|
|
51043
|
+
import { join as join8 } from "path";
|
|
50904
51044
|
var RuleResultSchema = external_exports.union([
|
|
50905
51045
|
external_exports.string(),
|
|
50906
51046
|
external_exports.object({
|
|
@@ -50915,136 +51055,6 @@ var RuleContextSchema = external_exports.object({
|
|
|
50915
51055
|
// Functions validated at runtime
|
|
50916
51056
|
});
|
|
50917
51057
|
|
|
50918
|
-
// src/utils/detect.ts
|
|
50919
|
-
import { existsSync as existsSync2 } from "fs";
|
|
50920
|
-
import { readFile as readFile4 } from "fs/promises";
|
|
50921
|
-
import { join as join8 } from "path";
|
|
50922
|
-
var CONFIG_FILE_FRAMEWORKS = [
|
|
50923
|
-
{ files: ["astro.config.mjs", "astro.config.ts", "astro.config.js"], framework: "astro" },
|
|
50924
|
-
{ files: ["next.config.mjs", "next.config.ts", "next.config.js"], framework: "next" },
|
|
50925
|
-
{ files: ["remix.config.js", "remix.config.ts"], framework: "remix" },
|
|
50926
|
-
{ files: ["vite.config.ts", "vite.config.js", "vite.config.mjs"], framework: "vite" }
|
|
50927
|
-
];
|
|
50928
|
-
async function detectFramework(cwd) {
|
|
50929
|
-
try {
|
|
50930
|
-
const content = await readFile4(join8(cwd, "package.json"), "utf-8");
|
|
50931
|
-
const pkg = JSON.parse(content);
|
|
50932
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
50933
|
-
if (deps.next) {
|
|
50934
|
-
return "next";
|
|
50935
|
-
}
|
|
50936
|
-
if (deps["react-router"]) {
|
|
50937
|
-
return "react-router";
|
|
50938
|
-
}
|
|
50939
|
-
const hasRemix = Object.keys(deps).some((dep) => dep.startsWith("@remix-run/"));
|
|
50940
|
-
if (hasRemix) {
|
|
50941
|
-
return "remix";
|
|
50942
|
-
}
|
|
50943
|
-
if (deps.astro) {
|
|
50944
|
-
return "astro";
|
|
50945
|
-
}
|
|
50946
|
-
if (deps.vite) {
|
|
50947
|
-
return "vite";
|
|
50948
|
-
}
|
|
50949
|
-
} catch {
|
|
50950
|
-
}
|
|
50951
|
-
return detectFrameworkFromConfigFiles(cwd);
|
|
50952
|
-
}
|
|
50953
|
-
function detectFrameworkFromConfigFiles(cwd) {
|
|
50954
|
-
for (const { files, framework } of CONFIG_FILE_FRAMEWORKS) {
|
|
50955
|
-
for (const file2 of files) {
|
|
50956
|
-
if (existsSync2(join8(cwd, file2))) {
|
|
50957
|
-
return framework;
|
|
50958
|
-
}
|
|
50959
|
-
}
|
|
50960
|
-
}
|
|
50961
|
-
return "unknown";
|
|
50962
|
-
}
|
|
50963
|
-
async function detectTailwindVersion(cwd) {
|
|
50964
|
-
try {
|
|
50965
|
-
const content = await readFile4(join8(cwd, "package.json"), "utf-8");
|
|
50966
|
-
const pkg = JSON.parse(content);
|
|
50967
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
50968
|
-
const tailwindVersion = deps.tailwindcss;
|
|
50969
|
-
if (!tailwindVersion) {
|
|
50970
|
-
return null;
|
|
50971
|
-
}
|
|
50972
|
-
const versionMatch = tailwindVersion.match(/\d+\.\d+\.\d+/);
|
|
50973
|
-
return versionMatch ? versionMatch[0] : tailwindVersion;
|
|
50974
|
-
} catch {
|
|
50975
|
-
return null;
|
|
50976
|
-
}
|
|
50977
|
-
}
|
|
50978
|
-
function isTailwindV3(version2) {
|
|
50979
|
-
if (!version2) {
|
|
50980
|
-
return false;
|
|
50981
|
-
}
|
|
50982
|
-
return version2.startsWith("3.");
|
|
50983
|
-
}
|
|
50984
|
-
async function detectShadcn(cwd) {
|
|
50985
|
-
try {
|
|
50986
|
-
const content = await readFile4(join8(cwd, "components.json"), "utf-8");
|
|
50987
|
-
return JSON.parse(content);
|
|
50988
|
-
} catch {
|
|
50989
|
-
return null;
|
|
50990
|
-
}
|
|
50991
|
-
}
|
|
50992
|
-
function parseCssVariables(css3) {
|
|
50993
|
-
const light = {};
|
|
50994
|
-
const dark = {};
|
|
50995
|
-
const rootMatch = css3.match(/:root\s*\{([^}]+)\}/);
|
|
50996
|
-
if (rootMatch?.[1]) {
|
|
50997
|
-
parseVariablesIntoColors(rootMatch[1], light);
|
|
50998
|
-
}
|
|
50999
|
-
const darkMatch = css3.match(/\.dark\s*\{([^}]+)\}/);
|
|
51000
|
-
if (darkMatch?.[1]) {
|
|
51001
|
-
parseVariablesIntoColors(darkMatch[1], dark);
|
|
51002
|
-
}
|
|
51003
|
-
return { light, dark };
|
|
51004
|
-
}
|
|
51005
|
-
function parseVariablesIntoColors(block, colors) {
|
|
51006
|
-
const varMap = {
|
|
51007
|
-
"--background": "background",
|
|
51008
|
-
"--foreground": "foreground",
|
|
51009
|
-
"--card": "card",
|
|
51010
|
-
"--card-foreground": "cardForeground",
|
|
51011
|
-
"--popover": "popover",
|
|
51012
|
-
"--popover-foreground": "popoverForeground",
|
|
51013
|
-
"--primary": "primary",
|
|
51014
|
-
"--primary-foreground": "primaryForeground",
|
|
51015
|
-
"--secondary": "secondary",
|
|
51016
|
-
"--secondary-foreground": "secondaryForeground",
|
|
51017
|
-
"--muted": "muted",
|
|
51018
|
-
"--muted-foreground": "mutedForeground",
|
|
51019
|
-
"--accent": "accent",
|
|
51020
|
-
"--accent-foreground": "accentForeground",
|
|
51021
|
-
"--destructive": "destructive",
|
|
51022
|
-
"--destructive-foreground": "destructiveForeground",
|
|
51023
|
-
"--border": "border",
|
|
51024
|
-
"--input": "input",
|
|
51025
|
-
"--ring": "ring"
|
|
51026
|
-
};
|
|
51027
|
-
for (const [cssVar, colorKey] of Object.entries(varMap)) {
|
|
51028
|
-
const regex = new RegExp(`${cssVar}:\\s*([^;]+);`);
|
|
51029
|
-
const match2 = block.match(regex);
|
|
51030
|
-
if (match2?.[1]) {
|
|
51031
|
-
colors[colorKey] = match2[1].trim();
|
|
51032
|
-
}
|
|
51033
|
-
}
|
|
51034
|
-
}
|
|
51035
|
-
async function detectProject(cwd) {
|
|
51036
|
-
const [framework, shadcn, tailwindVersion] = await Promise.all([
|
|
51037
|
-
detectFramework(cwd),
|
|
51038
|
-
detectShadcn(cwd),
|
|
51039
|
-
detectTailwindVersion(cwd)
|
|
51040
|
-
]);
|
|
51041
|
-
return {
|
|
51042
|
-
framework,
|
|
51043
|
-
shadcn,
|
|
51044
|
-
tailwindVersion
|
|
51045
|
-
};
|
|
51046
|
-
}
|
|
51047
|
-
|
|
51048
51058
|
// src/commands/init.ts
|
|
51049
51059
|
async function backupCss(cssPath) {
|
|
51050
51060
|
const backupPath = cssPath.replace(/\.css$/, ".backup.css");
|
|
@@ -51479,9 +51489,29 @@ async function init(options) {
|
|
|
51479
51489
|
} else if (shadcn?.tailwind?.css) {
|
|
51480
51490
|
detectedCssPath = shadcn.tailwind.css;
|
|
51481
51491
|
}
|
|
51492
|
+
let componentTarget = frameworkToTarget(framework);
|
|
51493
|
+
if (framework === "astro" && isInteractive() && !isAgentMode2) {
|
|
51494
|
+
const astroHasReact = await hasAstroReact(cwd);
|
|
51495
|
+
if (astroHasReact) {
|
|
51496
|
+
componentTarget = await select({
|
|
51497
|
+
message: "This Astro project has React integration. Install components as:",
|
|
51498
|
+
choices: [
|
|
51499
|
+
{
|
|
51500
|
+
name: "Astro components (zero client JS, server-rendered)",
|
|
51501
|
+
value: "astro"
|
|
51502
|
+
},
|
|
51503
|
+
{
|
|
51504
|
+
name: "React components (client islands with client:load)",
|
|
51505
|
+
value: "react"
|
|
51506
|
+
}
|
|
51507
|
+
]
|
|
51508
|
+
});
|
|
51509
|
+
}
|
|
51510
|
+
}
|
|
51482
51511
|
const frameworkPaths = COMPONENT_PATHS[framework] || COMPONENT_PATHS.unknown;
|
|
51483
51512
|
const config3 = {
|
|
51484
51513
|
framework,
|
|
51514
|
+
componentTarget,
|
|
51485
51515
|
componentsPath: frameworkPaths.components,
|
|
51486
51516
|
primitivesPath: frameworkPaths.primitives,
|
|
51487
51517
|
compositesPath: frameworkPaths.composites,
|
|
@@ -52417,7 +52447,37 @@ Rafters Button, Input, Card, etc. include their own spacing, sizing, and states.
|
|
|
52417
52447
|
UTILITIES EXIST FOR EDGE CASES.
|
|
52418
52448
|
If no component fits your need, check @/lib/utils for official behavioral utilities. Do not invent your own. If nothing exists there either, ask the human.
|
|
52419
52449
|
|
|
52450
|
+
COLORS ARE TAILWIND CLASSES.
|
|
52451
|
+
Write border-l-primary, bg-success, text-info-foreground. Do not create color constants, mapping objects, or reference palette names. Palette families are internal. See quickstart.colorTokens for the full list of semantic tokens and usage examples.
|
|
52452
|
+
|
|
52420
52453
|
When in doubt: less code, not more. Rafters has already made the design decision.`;
|
|
52454
|
+
var CONSUMER_QUICKSTART = {
|
|
52455
|
+
rule1: "Components are pre-styled. Import and render. Do not add className for visual styling -- only for layout context (e.g. border-l-4 for accent). Input knows its focus ring. Label knows its weight. You arrange, you do not style.",
|
|
52456
|
+
rule2: "Colors are Tailwind classes. Write border-l-primary, bg-success, text-info-foreground. Do not create color constants, mapping objects, or reference palette internals.",
|
|
52457
|
+
rule3: "Layout uses Container and Grid presets (sidebar-main, form, cards, row, stack, split). Do not write flex, grid, gap-* directly.",
|
|
52458
|
+
antiPatterns: [
|
|
52459
|
+
"Do NOT reference palette families (silver-true-sky-500, neutral-400). Those are internal.",
|
|
52460
|
+
"Do NOT add className to Input/Label/Select for styling. They handle their own styles.",
|
|
52461
|
+
"Do NOT create wrapper components that add styling to Rafters components.",
|
|
52462
|
+
"Do NOT define focus states, hover states, or error states. Components include these.",
|
|
52463
|
+
"Do NOT create color mapping objects. The Tailwind class name IS the mapping."
|
|
52464
|
+
],
|
|
52465
|
+
colorTokens: {
|
|
52466
|
+
semantic: [
|
|
52467
|
+
"primary -- Main brand, CTA buttons, links",
|
|
52468
|
+
"secondary -- Less prominent actions",
|
|
52469
|
+
"accent -- Hover highlights, emphasis",
|
|
52470
|
+
"muted -- Subdued backgrounds, disabled text",
|
|
52471
|
+
"destructive -- Delete, remove, errors",
|
|
52472
|
+
"success -- Confirmations, positive feedback",
|
|
52473
|
+
"warning -- Caution, important notices",
|
|
52474
|
+
"info -- Tips, help, neutral information"
|
|
52475
|
+
],
|
|
52476
|
+
categorical: "chart-1 through chart-5 -- For data viz and categorical distinction (guaranteed harmonious)",
|
|
52477
|
+
structural: "card, popover, border, input, ring -- Surface and boundary tokens",
|
|
52478
|
+
usage: "Use as Tailwind class fragments: bg-primary, text-info-foreground, border-l-success. Each token has a -foreground variant for text on that background."
|
|
52479
|
+
}
|
|
52480
|
+
};
|
|
52421
52481
|
var DESIGN_PATTERNS = {
|
|
52422
52482
|
"destructive-action": {
|
|
52423
52483
|
name: "Destructive Action",
|
|
@@ -52717,7 +52777,7 @@ var DESIGN_PATTERNS = {
|
|
|
52717
52777
|
var TOOL_DEFINITIONS = [
|
|
52718
52778
|
{
|
|
52719
52779
|
name: "rafters_vocabulary",
|
|
52720
|
-
description: "Get
|
|
52780
|
+
description: "Get design system vocabulary with consumer quickstart guide. Returns: system rules, onboarding guidance (what to do and what NOT to do), semantic color tokens, spacing scale, type scale, layout presets, and component list. ALWAYS call this first before building with Rafters.",
|
|
52721
52781
|
inputSchema: {
|
|
52722
52782
|
type: "object",
|
|
52723
52783
|
properties: {},
|
|
@@ -52829,7 +52889,7 @@ var RaftersToolHandler = class {
|
|
|
52829
52889
|
// ==================== Tool 1: Vocabulary ====================
|
|
52830
52890
|
/**
|
|
52831
52891
|
* Get compact design system vocabulary
|
|
52832
|
-
* Returns: color
|
|
52892
|
+
* Returns: system rules, consumer quickstart, color tokens, spacing, type scale, components
|
|
52833
52893
|
*/
|
|
52834
52894
|
async getVocabulary() {
|
|
52835
52895
|
try {
|
|
@@ -52841,6 +52901,7 @@ var RaftersToolHandler = class {
|
|
|
52841
52901
|
]);
|
|
52842
52902
|
const vocabulary = {
|
|
52843
52903
|
system: SYSTEM_PREAMBLE,
|
|
52904
|
+
quickstart: CONSUMER_QUICKSTART,
|
|
52844
52905
|
components,
|
|
52845
52906
|
colors,
|
|
52846
52907
|
spacing,
|
|
@@ -52860,16 +52921,19 @@ var RaftersToolHandler = class {
|
|
|
52860
52921
|
}
|
|
52861
52922
|
}
|
|
52862
52923
|
/**
|
|
52863
|
-
* Extract compact color vocabulary
|
|
52924
|
+
* Extract compact color vocabulary.
|
|
52925
|
+
* Always includes the known semantic token list so consumers get guidance
|
|
52926
|
+
* even when dynamic token loading fails or returns empty.
|
|
52864
52927
|
*/
|
|
52865
52928
|
async getColorVocabulary() {
|
|
52929
|
+
const knownSemantic = Object.keys(DEFAULT_SEMANTIC_COLOR_MAPPINGS);
|
|
52866
52930
|
try {
|
|
52867
52931
|
const tokens = await this.loadNamespace("color");
|
|
52868
|
-
const
|
|
52932
|
+
const dynamicSemantic = [];
|
|
52869
52933
|
const palettes = /* @__PURE__ */ new Map();
|
|
52870
52934
|
for (const token of tokens) {
|
|
52871
52935
|
if (typeof token.value === "object" && "family" in token.value) {
|
|
52872
|
-
|
|
52936
|
+
dynamicSemantic.push(token.name);
|
|
52873
52937
|
} else if (typeof token.value === "object" && "scale" in token.value) {
|
|
52874
52938
|
const colorValue = token.value;
|
|
52875
52939
|
palettes.set(
|
|
@@ -52878,55 +52942,89 @@ var RaftersToolHandler = class {
|
|
|
52878
52942
|
);
|
|
52879
52943
|
}
|
|
52880
52944
|
}
|
|
52945
|
+
const allSemantic = [.../* @__PURE__ */ new Set([...knownSemantic, ...dynamicSemantic])];
|
|
52881
52946
|
return {
|
|
52882
|
-
semantic,
|
|
52947
|
+
semantic: allSemantic,
|
|
52883
52948
|
palettes: [...palettes.entries()].map(([name2, positions]) => ({
|
|
52884
52949
|
name: name2,
|
|
52885
52950
|
positions: [...positions]
|
|
52886
|
-
}))
|
|
52951
|
+
})),
|
|
52952
|
+
usage: "Use as Tailwind classes: bg-primary, text-info-foreground, border-l-success. Palette families are internal -- never reference them in consumer code."
|
|
52887
52953
|
};
|
|
52888
52954
|
} catch {
|
|
52889
|
-
return {
|
|
52955
|
+
return {
|
|
52956
|
+
semantic: knownSemantic,
|
|
52957
|
+
palettes: [],
|
|
52958
|
+
usage: "Use as Tailwind classes: bg-primary, text-info-foreground, border-l-success. Palette families are internal -- never reference them in consumer code."
|
|
52959
|
+
};
|
|
52890
52960
|
}
|
|
52891
52961
|
}
|
|
52892
52962
|
/**
|
|
52893
|
-
* Extract compact spacing vocabulary
|
|
52963
|
+
* Extract compact spacing vocabulary.
|
|
52964
|
+
* Includes static scale names so consumers always get guidance.
|
|
52894
52965
|
*/
|
|
52895
52966
|
async getSpacingVocabulary() {
|
|
52896
52967
|
try {
|
|
52897
52968
|
const tokens = await this.loadNamespace("spacing");
|
|
52898
|
-
const
|
|
52969
|
+
const scale3 = {};
|
|
52899
52970
|
for (const token of tokens) {
|
|
52900
52971
|
if (typeof token.value === "string") {
|
|
52901
|
-
|
|
52972
|
+
scale3[token.name] = token.value;
|
|
52902
52973
|
}
|
|
52903
52974
|
}
|
|
52904
|
-
|
|
52975
|
+
if (Object.keys(scale3).length > 0) {
|
|
52976
|
+
return {
|
|
52977
|
+
scale: scale3,
|
|
52978
|
+
usage: "Container and Grid handle spacing. Do not use gap-*, p-*, m-* directly."
|
|
52979
|
+
};
|
|
52980
|
+
}
|
|
52905
52981
|
} catch {
|
|
52906
|
-
return { scale: {} };
|
|
52907
52982
|
}
|
|
52983
|
+
const scale2 = {};
|
|
52984
|
+
for (const [key, multiplier] of Object.entries(DEFAULT_SPACING_MULTIPLIERS)) {
|
|
52985
|
+
scale2[`spacing-${key}`] = `${multiplier * 0.25}rem`;
|
|
52986
|
+
}
|
|
52987
|
+
return {
|
|
52988
|
+
scale: scale2,
|
|
52989
|
+
usage: "Container and Grid handle spacing. Do not use gap-*, p-*, m-* directly."
|
|
52990
|
+
};
|
|
52908
52991
|
}
|
|
52909
52992
|
/**
|
|
52910
|
-
* Extract compact typography vocabulary
|
|
52993
|
+
* Extract compact typography vocabulary.
|
|
52994
|
+
* Includes static fallbacks so consumers always get guidance.
|
|
52911
52995
|
*/
|
|
52912
52996
|
async getTypographyVocabulary() {
|
|
52913
52997
|
try {
|
|
52914
52998
|
const tokens = await this.loadNamespace("typography");
|
|
52915
|
-
const
|
|
52999
|
+
const sizes2 = {};
|
|
52916
53000
|
const weights = /* @__PURE__ */ new Set();
|
|
52917
53001
|
for (const token of tokens) {
|
|
52918
53002
|
if (typeof token.value === "string") {
|
|
52919
53003
|
if (token.name.includes("weight")) {
|
|
52920
53004
|
weights.add(token.name.replace("-weight", ""));
|
|
52921
53005
|
} else {
|
|
52922
|
-
|
|
53006
|
+
sizes2[token.name] = token.value;
|
|
52923
53007
|
}
|
|
52924
53008
|
}
|
|
52925
53009
|
}
|
|
52926
|
-
|
|
53010
|
+
if (Object.keys(sizes2).length > 0) {
|
|
53011
|
+
return {
|
|
53012
|
+
sizes: sizes2,
|
|
53013
|
+
weights: [...weights],
|
|
53014
|
+
usage: "Typography components (H1-H4, P, Label) handle sizing. Do not set font sizes directly."
|
|
53015
|
+
};
|
|
53016
|
+
}
|
|
52927
53017
|
} catch {
|
|
52928
|
-
return { sizes: {}, weights: [] };
|
|
52929
53018
|
}
|
|
53019
|
+
const sizes = {};
|
|
53020
|
+
for (const name2 of Object.keys(DEFAULT_TYPOGRAPHY_SCALE)) {
|
|
53021
|
+
sizes[`font-size-${name2}`] = name2;
|
|
53022
|
+
}
|
|
53023
|
+
return {
|
|
53024
|
+
sizes,
|
|
53025
|
+
weights: Object.keys(DEFAULT_FONT_WEIGHTS),
|
|
53026
|
+
usage: "Typography components (H1-H4, P, Label) handle sizing. Do not set font sizes directly."
|
|
53027
|
+
};
|
|
52930
53028
|
}
|
|
52931
53029
|
/**
|
|
52932
53030
|
* Load and cache the project's Rafters config from .rafters/config.rafters.json.
|