@frontfriend/tailwind 2.0.0 → 2.0.3
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/cli.js +19 -16
- package/dist/ffdc.d.ts +6 -0
- package/dist/lib/config/cache-manager.js +14 -2
- package/dist/lib/core/api-client.js +1 -1
- package/dist/lib/core/api-client.js.map +3 -3
- package/dist/lib/core/component-downloader.js +2 -1
- package/dist/lib/core/component-downloader.js.map +3 -3
- package/dist/lib/core/constants.js +1 -1
- package/dist/lib/core/constants.js.map +3 -3
- package/dist/lib/core/token-processor.js +1 -1
- package/dist/lib/core/token-processor.js.map +3 -3
- package/dist/lib/react/utils.d.ts +25 -0
- package/dist/lib/vue/utils.d.ts +25 -0
- package/dist/next.d.ts +8 -0
- package/dist/next.js +1 -1
- package/dist/next.js.map +3 -3
- package/dist/runtime.d.ts +13 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.js +3 -3
- package/dist/vite.js.map +3 -3
- package/package.json +26 -15
package/dist/cli.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var{Command:
|
|
3
|
-
`);let
|
|
4
|
-
Please add "ff-id" to your frontfriend.config.js file`,"ff-id");console.log("\u{1F4CB} Configuration loaded"),console.log(` FF_ID: ${
|
|
5
|
-
`);let l=new
|
|
2
|
+
var{Command:v}=require("commander"),m=require("./lib/config/config-loader"),h=require("./lib/config/cache-manager"),{APIClient:y}=require("./lib/core/api-client"),{ComponentDownloader:b}=require("./lib/core/component-downloader"),x=require("./lib/core/token-processor"),{ConfigError:d,APIError:D,CacheError:w}=require("./lib/core/errors"),I=require("path"),i=new v;i.name("frontfriend").description("FrontFriend Tailwind CLI - Manage design tokens and cache").version("2.0.0");i.command("init").description("Initialize FrontFriend configuration and fetch from API").option("--force","Force refresh even if cache is valid").action(async n=>{try{console.log("\u{1F527} FrontFriend Setup"),console.log(`==================
|
|
3
|
+
`);let o=await new m().load();if(!o.ffId)throw new d(`ff-id not found in frontfriend.config.js
|
|
4
|
+
Please add "ff-id" to your frontfriend.config.js file`,"ff-id");console.log("\u{1F4CB} Configuration loaded"),console.log(` FF_ID: ${o.ffId}`),console.log(` App Root: ${o.appRoot}
|
|
5
|
+
`);let l=new h(o.appRoot);!n.force&&l.exists()&&l.isValid()&&(console.log("\u2705 Cache is valid and up to date"),console.log(" Use --force to refresh anyway"),process.exit(0)),console.log("\u{1F50D} Checking cache..."),n.force?console.log(` Force refresh requested
|
|
6
6
|
`):l.exists()?console.log(` Cache expired
|
|
7
7
|
`):console.log(` No cache found
|
|
8
|
-
`),console.log("\u{1F310} Fetching configuration...");let c=new
|
|
9
|
-
`),console.log("\
|
|
10
|
-
`)
|
|
11
|
-
`),
|
|
12
|
-
`);let
|
|
13
|
-
`);let a=
|
|
14
|
-
`)
|
|
15
|
-
`);let
|
|
16
|
-
|
|
17
|
-
`);let
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
`),console.log("\u{1F310} Fetching configuration...");let c=new y(o.ffId,{baseURL:o["api-url"]||o.apiUrl});(o["api-url"]||o.apiUrl)&&console.log(` Using API URL: ${o["api-url"]||o.apiUrl}`);let r=null;try{r=await c.fetchProcessedTokens()}catch(u){console.log(` \u26A0\uFE0F Failed to fetch pre-processed tokens: ${u.message}`)}r&&(console.log(" \u2713 Pre-processed tokens fetched from server"),console.log(` \u2713 Skipping local processing
|
|
9
|
+
`),console.log("\u{1F4BE} Saving cache..."),l.save(r),console.log(` \u2713 Cache saved successfully
|
|
10
|
+
`),console.log("\u2705 Setup complete!"),console.log(" Your FrontFriend configuration has been cached."),console.log(" The Tailwind plugin will now use this cached data."),process.exit(0)),console.log(` \u2139\uFE0F Pre-processed tokens not available, falling back to local processing
|
|
11
|
+
`);let[e,a,g,k,p,$]=await Promise.all([c.fetchTokens(),c.fetchComponentsConfig(),c.fetchFonts(),c.fetchIcons(),c.fetchVersion(),c.fetchCustomCss()]);if(console.log(" \u2713 Tokens fetched"),e.global||e.colors||e.semantic||e.semanticDark){let u=[e.global?"global":null,e.colors?"colors":null,e.semantic?"semantic":null,e.semanticDark?"semanticDark":null].filter(Boolean).join(", ");console.log(` (Found: ${u})`)}console.log(" \u2713 Components config fetched"),console.log(" \u2713 Fonts fetched"),console.log(" \u2713 Icons fetched"),console.log(" \u2713 Version fetched"),console.log(` \u2713 Custom CSS fetched
|
|
12
|
+
`),console.log("\u2699\uFE0F Processing tokens...");let C=new x;console.log(" Processing raw token data...");let t=await C.process({colors:e.colors||e.global,semantic:e.semantic,semanticDark:e.semanticDark,fonts:g,globalTokens:e.global,animations:e.animations,version:p==null?void 0:p.version,ffId:o.ffId,customCss:$});console.log(" \u2713 Colors processed"),console.log(" \u2713 Semantic tokens processed"),t.fontFaces.length>0&&console.log(` \u2713 ${t.fontFaces.length} font faces processed`),Object.keys(t.animations).length>0&&console.log(` \u2713 ${Object.keys(t.animations).length} animations processed`),console.log(`
|
|
13
|
+
`);let F=C.extractClassesFromComponentsConfig(a),f={tokens:t.utilities,variables:t.variables,semanticVariables:t.semanticVariables,semanticDarkVariables:t.semanticDarkVariables,fonts:t.fontFaces,icons:k,componentsConfig:a,keyframes:t.keyframes,animations:t.animations,safelist:t.safelist,version:p,metadata:t.metadata,cls:F||[],custom:t.custom};console.log("\u{1F4BE} Saving cache..."),console.log(" Cache data summary:"),console.log(` - Tokens: ${Object.keys(f.tokens||{}).length} utilities`),console.log(` - Variables: ${Object.keys(f.variables||{}).length} CSS variables`),console.log(` - Semantic variables: ${Object.keys(f.semanticVariables||{}).length} semantic variables`),console.log(` - Font faces: ${(f.fonts||[]).length} fonts`),console.log(` - Classes: ${(f.cls||[]).length} extracted classes`),l.save(f),console.log(` \u2713 Cache saved successfully
|
|
14
|
+
`),console.log("\u2705 Setup complete!"),console.log(" Your FrontFriend configuration has been cached."),console.log(" The Tailwind plugin will now use this cached data."),process.exit(0)}catch(s){s instanceof d?console.error("\u274C Configuration Error:",s.message):s instanceof D?(console.error("\u274C API Error:",s.message),console.error(` Status: ${s.statusCode}`),console.error(` URL: ${s.url}`)):s instanceof w?(console.error("\u274C Cache Error:",s.message),console.error(` Operation: ${s.operation}`)):console.error("\u274C Setup failed:",s.message),process.exit(1)}});i.command("clean").description("Remove cached configuration").action(async()=>{try{console.log(`\u{1F9F9} Cleaning FrontFriend cache...
|
|
15
|
+
`);let s=new m().load(),o=new h(s.appRoot);o.exists()?(o.clear(),console.log("\u2705 Cache cleared successfully")):console.log("\u2139\uFE0F No cache found"),process.exit(0)}catch(n){n instanceof w?(console.error("\u274C Cache Error:",n.message),console.error(` Operation: ${n.operation}`)):console.error("\u274C Clean failed:",n.message),process.exit(1)}});i.command("status").description("Show cache status and configuration").action(async()=>{try{console.log("\u{1F4CA} FrontFriend Status"),console.log(`===================
|
|
16
|
+
`);let s=await new m().load();console.log("Configuration:"),console.log(` FF_ID: ${s.ffId||"Not set"}`),console.log(` App Root: ${s.appRoot}
|
|
17
|
+
`);let o=new h(s.appRoot),l=o.getCacheDir();if(console.log("Cache:"),console.log(` Directory: ${I.relative(process.cwd(),l)}`),o.exists()){console.log(` Status: ${o.isValid()?"\u2705 Valid":"\u26A0\uFE0F Expired"}`);let c=o.load();if(c&&c.metadata){let r=new Date(c.metadata.timestamp);console.log(` Created: ${r.toLocaleString()}`),console.log(` Version: ${c.metadata.version||"Unknown"}`)}}else console.log(" Status: \u274C Not found");process.exit(0)}catch(n){n instanceof d?console.error("\u274C Configuration Error:",n.message):n instanceof w?(console.error("\u274C Cache Error:",n.message),console.error(` Operation: ${n.operation}`)):console.error("\u274C Status check failed:",n.message),process.exit(1)}});i.command("download").description("Download components from registry").argument("<components...>",'component names to download (or "all" to download all components)').option("-f, --framework <framework>","Framework to download components for (react/vue)").option("-o, --output <path>","Output directory for components").option("--overwrite","Overwrite existing files").action(async(n,s)=>{try{console.log(`\u{1F4E6} Downloading components...
|
|
18
|
+
`);let l=await new m().load();if(!l.ffId)throw new d(`ff-id not found in frontfriend.config.js
|
|
19
|
+
Please add "ff-id" to your frontfriend.config.js file`,"ff-id");let c=new b({appRoot:l.appRoot,config:l,framework:s.framework,outputPath:s.output,overwrite:s.overwrite}),r=n;if(n.length===1&&n[0].toLowerCase()==="all"){let a=await c.getAllComponents(),g=await c.getCustomComponents();a.length===0&&(console.error("\u274C Failed to fetch component list"),process.exit(1)),r=[...a,...g],console.log("\u{1F4CB} Configuration"),console.log(` Framework: ${c.framework}`),console.log(` Output: ${c.outputPath}`),console.log(` Components: All ${a.length} standard components`),g.length>0&&console.log(` Custom: ${g.length} custom components for ff-id: ${l.ffId||l["ff-id"]}`),console.log("")}else console.log("\u{1F4CB} Configuration"),console.log(` Framework: ${c.framework}`),console.log(` Output: ${c.outputPath}`),console.log(` Components: ${n.join(", ")}
|
|
20
|
+
`);let e=await c.downloadComponents(r);e.successful.length>0&&(console.log(`
|
|
21
|
+
\u2705 Download complete!`),console.log(` Downloaded: ${e.successful.length} components`)),e.failed.length>0&&(console.log(""),e.failed.forEach(a=>{a.error.includes("not found")?console.log(`\u274C ${a.error}`):console.log(`\u274C Failed to download ${a.component}: ${a.error}`)})),e.successful.length>0&&e.dependencies.length>0&&(console.log(`
|
|
22
|
+
\u{1F4E6} Install dependencies:`),console.log(` npm install ${e.dependencies.join(" ")}`)),e.successful.length===0&&e.failed.length>0&&process.exit(1),process.exit(0)}catch(o){o instanceof d?(console.error("\u274C Configuration Error:",o.message),o.missingKey&&console.error(` Missing key: ${o.missingKey}`)):console.error("\u274C Download failed:",o.message),process.exit(1)}});i.parse(process.argv);process.argv.slice(2).length||(i.outputHelp(),process.exit(0));
|
|
20
23
|
//# sourceMappingURL=cli-temp.js.map
|
package/dist/ffdc.d.ts
ADDED
|
@@ -143,8 +143,20 @@ class CacheManager {
|
|
|
143
143
|
for (const key of jsFiles) {
|
|
144
144
|
if (data[key] !== undefined) {
|
|
145
145
|
const filePath = path.join(this.cacheDir, `${key}.js`);
|
|
146
|
-
const
|
|
147
|
-
|
|
146
|
+
const value = data[key];
|
|
147
|
+
|
|
148
|
+
// Ensure we have actual data to save
|
|
149
|
+
if (value === null || value === undefined ||
|
|
150
|
+
(typeof value === 'object' && Object.keys(value).length === 0) ||
|
|
151
|
+
(Array.isArray(value) && value.length === 0)) {
|
|
152
|
+
// For empty objects/arrays, save a proper empty structure
|
|
153
|
+
const emptyContent = Array.isArray(value) ? '[]' : '{}';
|
|
154
|
+
const content = `module.exports = ${emptyContent};`;
|
|
155
|
+
fs.writeFileSync(filePath, content);
|
|
156
|
+
} else {
|
|
157
|
+
const content = `module.exports = ${JSON.stringify(value, null, 2)};`;
|
|
158
|
+
fs.writeFileSync(filePath, content);
|
|
159
|
+
}
|
|
148
160
|
}
|
|
149
161
|
}
|
|
150
162
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var C=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var $=C((b,g)=>{var k="https://app.frontfriend.dev",p="https://tokens-studio-donux.up.railway.app/api",A=".cache/frontfriend",L={JS:["tokens.js","variables.js","semanticVariables.js","semanticDarkVariables.js","cls.js","custom.js"],JSON:["fonts.json","icons.json","components-config.json","version.json","metadata.json"]},R={FF_ID:"FF_ID",FF_API_URL:"FF_API_URL"};g.exports={DEFAULT_API_URL:k,LEGACY_API_URL:p,CACHE_DIR_NAME:A,CACHE_TTL_DAYS:7,CACHE_TTL_MS:6048e5,CACHE_FILES:L,ENV_VARS:R}});var w=C((D,_)=>{var l=class extends Error{constructor(t,s,n){super(t),this.name="APIError",this.statusCode=s,this.url=n,this.code=`API_${s}`}},u=class extends Error{constructor(t,s){super(t),this.name="CacheError",this.operation=s,this.code=`CACHE_${s.toUpperCase()}`}},f=class extends Error{constructor(t,s){super(t),this.name="ConfigError",this.field=s,this.code=`CONFIG_${s.toUpperCase()}`}},d=class extends Error{constructor(t,s){super(t),this.name="ProcessingError",this.token=s,this.code="PROCESSING_ERROR"}};_.exports={APIError:l,CacheError:u,ConfigError:f,ProcessingError:d}});var y=require("https"),I=require("http"),{URL:F}=require("url"),{DEFAULT_API_URL:E,LEGACY_API_URL:h,ENV_VARS:P}=$(),{APIError:c}=w(),m=class{constructor(t,s={}){this.ffId=t,this.baseURL=s.baseURL||process.env[P.FF_API_URL]||E}fetchJson(t){return new Promise((s,n)=>{(t.startsWith("https")?y:I).get(t,e=>{let r="";if(e.statusCode>=400){n(new c(`HTTP ${e.statusCode}: ${e.statusMessage}`,e.statusCode,t));return}e.on("data",a=>{r+=a}),e.on("end",()=>{try{let a=JSON.parse(r);s(a)}catch(a){n(new c(`Invalid JSON response: ${a.message}`,e.statusCode,t))}}),e.on("error",a=>{n(new c(`Response error: ${a.message}`,e.statusCode,t))})}).on("error",e=>{n(new c(`Network error: ${e.message}`,0,t))})})}fetchRaw(t){return new Promise((s,n)=>{(t.startsWith("https")?y:I).get(t,e=>{let r="";if(e.statusCode>=400){n(new c(`HTTP ${e.statusCode}: ${e.statusMessage}`,e.statusCode,t));return}e.on("data",a=>{r+=a}),e.on("end",()=>{s(r)}),e.on("error",a=>{n(new c(`Response error: ${a.message}`,e.statusCode,t))})}).on("error",e=>{n(new c(`Network error: ${e.message}`,0,t))})})}async fetchTokens(){try{let o=`${this.baseURL}/api/design-systems/${this.ffId}/tokens`,e=await this.fetchJson(o);if(e&&e.tokens){let r=e.tokens;return{global:r["Global Tokens/Default"]||r.global||null,colors:r["Global Colors/Default"]||r.colors||null,semantic:r["Semantic/Light"]||r["semantic/light"]||null,semanticDark:r["Semantic/Dark"]||r["semantic/dark"]||null}}}catch(o){if(o.statusCode===400)throw new c("Design system not synced with Figma. Please sync tokens from Figma before using this design system.",400,`${this.baseURL}/api/design-systems/${this.ffId}/tokens`)}let t=h,s={global:`${t}/${this.ffId}/global-tokens/default.json`,colors:`${t}/${this.ffId}/global-colors/default.json`,semantic:`${t}/${this.ffId}/semantic/light.json`,semanticDark:`${t}/${this.ffId}/semantic/dark.json`},n=await Promise.all([this.fetchJson(s.global).catch(o=>o.statusCode===404?null:Promise.reject(o)),this.fetchJson(s.colors).catch(o=>o.statusCode===404?null:Promise.reject(o)),this.fetchJson(s.semantic).catch(o=>o.statusCode===404?null:Promise.reject(o)),this.fetchJson(s.semanticDark).catch(o=>o.statusCode===404?null:Promise.reject(o))]);return{global:n[0],colors:n[1],semantic:n[2],semanticDark:n[3]}}async fetchProcessedTokens(){let t=`${this.baseURL}/api/design-systems/${this.ffId}/processed-tokens`;try{return await this.fetchJson(t)}catch(s){if(s.statusCode===404)return null;throw s.statusCode===400?new c("Design system not synced with Figma. Please sync tokens from Figma before using this design system.",400,t):s}}async fetchComponentsConfig(){let t=`${h}/${this.ffId}/components-config.json`;try{return await this.fetchJson(t)}catch(s){if(s.statusCode===404)return null;throw s}}async fetchFonts(){let t=`${h}/${this.ffId}/font.json`;try{return await this.fetchJson(t)}catch(s){if(s.statusCode===404)return null;throw s}}async fetchIcons(){let t=`${h}/${this.ffId}/icons.json`;try{return await this.fetchJson(t)}catch(s){if(s.statusCode===404)return null;throw s}}async fetchVersion(){let t=`${h}/${this.ffId}/version.json`;try{return await this.fetchJson(t)}catch(s){if(s.statusCode===404)return null;throw s}}async fetchCustomCss(){let t=`${h}/${this.ffId}/custom.css`;try{return await this.fetchRaw(t)}catch(s){if(s.statusCode===404)return null;throw s}}};module.exports={APIClient:m};
|
|
2
2
|
//# sourceMappingURL=api-client.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../lib/core/constants.js", "../../../lib/core/errors.js", "../../../lib/core/api-client.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Configuration constants for FrontFriend Tailwind v2\n */\n\n// API Configuration\nconst DEFAULT_API_URL = 'https://tokens-studio-donux.up.railway.app/api';\n\n// Cache Configuration\nconst CACHE_DIR_NAME = '.cache/frontfriend';\nconst CACHE_TTL_DAYS = 7;\nconst CACHE_TTL_MS = CACHE_TTL_DAYS * 24 * 60 * 60 * 1000;\n\n// File names\nconst CACHE_FILES = {\n JS: [\n 'tokens.js',\n 'variables.js',\n 'semanticVariables.js',\n 'semanticDarkVariables.js',\n 'cls.js',\n 'custom.js'\n ],\n JSON: [\n 'fonts.json',\n 'icons.json',\n 'components-config.json',\n 'version.json',\n 'metadata.json'\n ]\n};\n\n// Environment variables\nconst ENV_VARS = {\n FF_ID: 'FF_ID',\n FF_API_URL: 'FF_API_URL'\n};\n\nmodule.exports = {\n DEFAULT_API_URL,\n CACHE_DIR_NAME,\n CACHE_TTL_DAYS,\n CACHE_TTL_MS,\n CACHE_FILES,\n ENV_VARS\n};", "class APIError extends Error {\n constructor(message, statusCode, url) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.url = url;\n this.code = `API_${statusCode}`;\n }\n}\n\nclass CacheError extends Error {\n constructor(message, operation) {\n super(message);\n this.name = 'CacheError';\n this.operation = operation;\n this.code = `CACHE_${operation.toUpperCase()}`;\n }\n}\n\nclass ConfigError extends Error {\n constructor(message, field) {\n super(message);\n this.name = 'ConfigError';\n this.field = field;\n this.code = `CONFIG_${field.toUpperCase()}`;\n }\n}\n\nclass ProcessingError extends Error {\n constructor(message, token) {\n super(message);\n this.name = 'ProcessingError';\n this.token = token;\n this.code = 'PROCESSING_ERROR';\n }\n}\n\nmodule.exports = {\n APIError,\n CacheError,\n ConfigError,\n ProcessingError\n};", "const https = require('https');\nconst { URL } = require('url');\nconst { DEFAULT_API_URL, ENV_VARS } = require('./constants');\nconst { APIError } = require('./errors');\n\nclass APIClient {\n constructor(ffId, options = {}) {\n this.ffId = ffId;\n this.baseURL = options.baseURL || process.env[ENV_VARS.FF_API_URL] || DEFAULT_API_URL;\n }\n\n /**\n * Fetch JSON data from a URL using native https module\n * @param {string} url - The URL to fetch\n * @returns {Promise<any>} Parsed JSON data\n */\n fetchJson(url) {\n return new Promise((resolve, reject) => {\n https.get(url, (response) => {\n let data = '';\n \n // Check for HTTP errors\n if (response.statusCode >= 400) {\n reject(new APIError(\n `HTTP ${response.statusCode}: ${response.statusMessage}`,\n response.statusCode,\n url\n ));\n return;\n }\n\n // Collect response chunks\n response.on('data', (chunk) => {\n data += chunk;\n });\n\n // Parse JSON when complete\n response.on('end', () => {\n try {\n const parsed = JSON.parse(data);\n resolve(parsed);\n } catch (error) {\n reject(new APIError(\n `Invalid JSON response: ${error.message}`,\n response.statusCode,\n url\n ));\n }\n });\n\n // Handle response errors\n response.on('error', (error) => {\n reject(new APIError(\n `Response error: ${error.message}`,\n response.statusCode,\n url\n ));\n });\n }).on('error', (error) => {\n // Handle network errors\n reject(new APIError(\n `Network error: ${error.message}`,\n 0,\n url\n ));\n });\n });\n }\n\n /**\n * Fetch raw content from a URL\n * @param {string} url - The URL to fetch\n * @returns {Promise<string>} Raw text content\n */\n fetchRaw(url) {\n return new Promise((resolve, reject) => {\n https.get(url, (response) => {\n let data = '';\n \n // Check for HTTP errors\n if (response.statusCode >= 400) {\n reject(new APIError(\n `HTTP ${response.statusCode}: ${response.statusMessage}`,\n response.statusCode,\n url\n ));\n return;\n }\n\n // Collect response chunks\n response.on('data', (chunk) => {\n data += chunk;\n });\n\n // Return raw data when complete\n response.on('end', () => {\n resolve(data);\n });\n\n // Handle response errors\n response.on('error', (error) => {\n reject(new APIError(\n `Response error: ${error.message}`,\n response.statusCode,\n url\n ));\n });\n }).on('error', (error) => {\n // Handle network errors\n reject(new APIError(\n `Network error: ${error.message}`,\n 0,\n url\n ));\n });\n });\n }\n\n /**\n * Fetch all token files (global, colors, semantic)\n * @returns {Promise<Object>} Object with all token data\n */\n async fetchTokens() {\n const urls = {\n global: `${this.baseURL}/${this.ffId}/global-tokens/default.json`,\n colors: `${this.baseURL}/${this.ffId}/global-colors/default.json`,\n semantic: `${this.baseURL}/${this.ffId}/semantic/light.json`,\n semanticDark: `${this.baseURL}/${this.ffId}/semantic/dark.json`\n };\n\n const results = await Promise.all([\n this.fetchJson(urls.global).catch(err => err.statusCode === 404 ? null : Promise.reject(err)),\n this.fetchJson(urls.colors).catch(err => err.statusCode === 404 ? null : Promise.reject(err)),\n this.fetchJson(urls.semantic).catch(err => err.statusCode === 404 ? null : Promise.reject(err)),\n this.fetchJson(urls.semanticDark).catch(err => err.statusCode === 404 ? null : Promise.reject(err))\n ]);\n\n return {\n global: results[0],\n colors: results[1],\n semantic: results[2],\n semanticDark: results[3]\n };\n }\n\n /**\n * Fetch components configuration\n * @returns {Promise<Object|null>} Components config or null if not found\n */\n async fetchComponentsConfig() {\n const url = `${this.baseURL}/${this.ffId}/components-config.json`;\n try {\n return await this.fetchJson(url);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch fonts configuration\n * @returns {Promise<Object|null>} Fonts object with font1, font2, etc. URLs or null\n */\n async fetchFonts() {\n const url = `${this.baseURL}/${this.ffId}/font.json`;\n try {\n return await this.fetchJson(url);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch icons configuration\n * @returns {Promise<Object|null>} Icons data or null if not found\n */\n async fetchIcons() {\n const url = `${this.baseURL}/${this.ffId}/icons.json`;\n try {\n return await this.fetchJson(url);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch version information\n * @returns {Promise<Object|null>} Version data or null if not found\n */\n async fetchVersion() {\n const url = `${this.baseURL}/${this.ffId}/version.json`;\n try {\n return await this.fetchJson(url);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch custom CSS\n * @returns {Promise<string|null>} Custom CSS string or null if not found\n */\n async fetchCustomCss() {\n const url = `${this.baseURL}/${this.ffId}/custom.css`;\n try {\n return await this.fetchRaw(url);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n}\n\nmodule.exports = { APIClient };"],
|
|
5
|
-
"mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAKA,IAAMC,EAAkB,
|
|
6
|
-
"names": ["require_constants", "__commonJSMin", "exports", "module", "DEFAULT_API_URL", "CACHE_DIR_NAME", "CACHE_FILES", "ENV_VARS", "require_errors", "__commonJSMin", "exports", "module", "APIError", "message", "statusCode", "url", "CacheError", "operation", "ConfigError", "field", "ProcessingError", "token", "https", "URL", "DEFAULT_API_URL", "ENV_VARS", "APIError", "APIClient", "ffId", "options", "url", "resolve", "reject", "response", "data", "chunk", "parsed", "error", "urls", "results", "
|
|
4
|
+
"sourcesContent": ["/**\n * Configuration constants for FrontFriend Tailwind v2\n */\n\n// API Configuration\nconst DEFAULT_API_URL = 'https://app.frontfriend.dev';\nconst LEGACY_API_URL = 'https://tokens-studio-donux.up.railway.app/api';\n\n// Cache Configuration\nconst CACHE_DIR_NAME = '.cache/frontfriend';\nconst CACHE_TTL_DAYS = 7;\nconst CACHE_TTL_MS = CACHE_TTL_DAYS * 24 * 60 * 60 * 1000;\n\n// File names\nconst CACHE_FILES = {\n JS: [\n 'tokens.js',\n 'variables.js',\n 'semanticVariables.js',\n 'semanticDarkVariables.js',\n 'cls.js',\n 'custom.js'\n ],\n JSON: [\n 'fonts.json',\n 'icons.json',\n 'components-config.json',\n 'version.json',\n 'metadata.json'\n ]\n};\n\n// Environment variables\nconst ENV_VARS = {\n FF_ID: 'FF_ID',\n FF_API_URL: 'FF_API_URL'\n};\n\nmodule.exports = {\n DEFAULT_API_URL,\n LEGACY_API_URL,\n CACHE_DIR_NAME,\n CACHE_TTL_DAYS,\n CACHE_TTL_MS,\n CACHE_FILES,\n ENV_VARS\n};", "class APIError extends Error {\n constructor(message, statusCode, url) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.url = url;\n this.code = `API_${statusCode}`;\n }\n}\n\nclass CacheError extends Error {\n constructor(message, operation) {\n super(message);\n this.name = 'CacheError';\n this.operation = operation;\n this.code = `CACHE_${operation.toUpperCase()}`;\n }\n}\n\nclass ConfigError extends Error {\n constructor(message, field) {\n super(message);\n this.name = 'ConfigError';\n this.field = field;\n this.code = `CONFIG_${field.toUpperCase()}`;\n }\n}\n\nclass ProcessingError extends Error {\n constructor(message, token) {\n super(message);\n this.name = 'ProcessingError';\n this.token = token;\n this.code = 'PROCESSING_ERROR';\n }\n}\n\nmodule.exports = {\n APIError,\n CacheError,\n ConfigError,\n ProcessingError\n};", "const https = require('https');\nconst http = require('http');\nconst { URL } = require('url');\nconst { DEFAULT_API_URL, LEGACY_API_URL, ENV_VARS } = require('./constants');\nconst { APIError } = require('./errors');\n\nclass APIClient {\n constructor(ffId, options = {}) {\n this.ffId = ffId;\n this.baseURL = options.baseURL || process.env[ENV_VARS.FF_API_URL] || DEFAULT_API_URL;\n }\n\n /**\n * Fetch JSON data from a URL using native https module\n * @param {string} url - The URL to fetch\n * @returns {Promise<any>} Parsed JSON data\n */\n fetchJson(url) {\n return new Promise((resolve, reject) => {\n // Determine if we should use http or https\n const protocol = url.startsWith('https') ? https : http;\n \n protocol.get(url, (response) => {\n let data = '';\n \n // Check for HTTP errors\n if (response.statusCode >= 400) {\n reject(new APIError(\n `HTTP ${response.statusCode}: ${response.statusMessage}`,\n response.statusCode,\n url\n ));\n return;\n }\n\n // Collect response chunks\n response.on('data', (chunk) => {\n data += chunk;\n });\n\n // Parse JSON when complete\n response.on('end', () => {\n try {\n const parsed = JSON.parse(data);\n resolve(parsed);\n } catch (error) {\n reject(new APIError(\n `Invalid JSON response: ${error.message}`,\n response.statusCode,\n url\n ));\n }\n });\n\n // Handle response errors\n response.on('error', (error) => {\n reject(new APIError(\n `Response error: ${error.message}`,\n response.statusCode,\n url\n ));\n });\n }).on('error', (error) => {\n // Handle network errors\n reject(new APIError(\n `Network error: ${error.message}`,\n 0,\n url\n ));\n });\n });\n }\n\n /**\n * Fetch raw content from a URL\n * @param {string} url - The URL to fetch\n * @returns {Promise<string>} Raw text content\n */\n fetchRaw(url) {\n return new Promise((resolve, reject) => {\n // Determine if we should use http or https\n const protocol = url.startsWith('https') ? https : http;\n \n protocol.get(url, (response) => {\n let data = '';\n \n // Check for HTTP errors\n if (response.statusCode >= 400) {\n reject(new APIError(\n `HTTP ${response.statusCode}: ${response.statusMessage}`,\n response.statusCode,\n url\n ));\n return;\n }\n\n // Collect response chunks\n response.on('data', (chunk) => {\n data += chunk;\n });\n\n // Return raw data when complete\n response.on('end', () => {\n resolve(data);\n });\n\n // Handle response errors\n response.on('error', (error) => {\n reject(new APIError(\n `Response error: ${error.message}`,\n response.statusCode,\n url\n ));\n });\n }).on('error', (error) => {\n // Handle network errors\n reject(new APIError(\n `Network error: ${error.message}`,\n 0,\n url\n ));\n });\n });\n }\n\n /**\n * Fetch all token files (global, colors, semantic)\n * @returns {Promise<Object>} Object with all token data\n */\n async fetchTokens() {\n // First try the new design system endpoint\n try {\n const designSystemUrl = `${this.baseURL}/api/design-systems/${this.ffId}/tokens`;\n const tokensData = await this.fetchJson(designSystemUrl);\n \n // If we have the new format, parse it\n if (tokensData && tokensData.tokens) {\n const tokens = tokensData.tokens;\n \n // Extract specific token sets from the new format\n return {\n global: tokens['Global Tokens/Default'] || tokens['global'] || null,\n colors: tokens['Global Colors/Default'] || tokens['colors'] || null,\n semantic: tokens['Semantic/Light'] || tokens['semantic/light'] || null,\n semanticDark: tokens['Semantic/Dark'] || tokens['semantic/dark'] || null\n };\n }\n } catch (err) {\n // If design system is not synced (400 error), throw with clear message\n if (err.statusCode === 400) {\n throw new APIError(\n 'Design system not synced with Figma. Please sync tokens from Figma before using this design system.',\n 400,\n `${this.baseURL}/api/design-systems/${this.ffId}/tokens`\n );\n }\n // Failed to fetch from design system endpoint, falling back to legacy URLs\n }\n \n // Fall back to legacy token URLs\n // Use legacy API URL for backward compatibility\n const legacyBaseURL = LEGACY_API_URL;\n const urls = {\n global: `${legacyBaseURL}/${this.ffId}/global-tokens/default.json`,\n colors: `${legacyBaseURL}/${this.ffId}/global-colors/default.json`,\n semantic: `${legacyBaseURL}/${this.ffId}/semantic/light.json`,\n semanticDark: `${legacyBaseURL}/${this.ffId}/semantic/dark.json`\n };\n\n const results = await Promise.all([\n this.fetchJson(urls.global).catch(err => err.statusCode === 404 ? null : Promise.reject(err)),\n this.fetchJson(urls.colors).catch(err => err.statusCode === 404 ? null : Promise.reject(err)),\n this.fetchJson(urls.semantic).catch(err => err.statusCode === 404 ? null : Promise.reject(err)),\n this.fetchJson(urls.semanticDark).catch(err => err.statusCode === 404 ? null : Promise.reject(err))\n ]);\n\n return {\n global: results[0],\n colors: results[1],\n semantic: results[2],\n semanticDark: results[3]\n };\n }\n\n /**\n * Fetch pre-processed tokens from the design system endpoint\n * @returns {Promise<Object|null>} Processed tokens ready for caching or null if not found\n */\n async fetchProcessedTokens() {\n const processedUrl = `${this.baseURL}/api/design-systems/${this.ffId}/processed-tokens`;\n try {\n return await this.fetchJson(processedUrl);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n // If design system is not synced (400 error), throw with clear message\n if (error.statusCode === 400) {\n throw new APIError(\n 'Design system not synced with Figma. Please sync tokens from Figma before using this design system.',\n 400,\n processedUrl\n );\n }\n throw error;\n }\n }\n\n /**\n * Fetch components configuration\n * @returns {Promise<Object|null>} Components config or null if not found\n */\n async fetchComponentsConfig() {\n // Always use legacy URL for these endpoints\n const url = `${LEGACY_API_URL}/${this.ffId}/components-config.json`;\n try {\n return await this.fetchJson(url);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch fonts configuration\n * @returns {Promise<Object|null>} Fonts object with font1, font2, etc. URLs or null\n */\n async fetchFonts() {\n // Always use legacy URL for these endpoints\n const url = `${LEGACY_API_URL}/${this.ffId}/font.json`;\n try {\n return await this.fetchJson(url);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch icons configuration\n * @returns {Promise<Object|null>} Icons data or null if not found\n */\n async fetchIcons() {\n // Always use legacy URL for these endpoints\n const url = `${LEGACY_API_URL}/${this.ffId}/icons.json`;\n try {\n return await this.fetchJson(url);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch version information\n * @returns {Promise<Object|null>} Version data or null if not found\n */\n async fetchVersion() {\n // Always use legacy URL for these endpoints\n const url = `${LEGACY_API_URL}/${this.ffId}/version.json`;\n try {\n return await this.fetchJson(url);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Fetch custom CSS\n * @returns {Promise<string|null>} Custom CSS string or null if not found\n */\n async fetchCustomCss() {\n // Always use legacy URL for these endpoints\n const url = `${LEGACY_API_URL}/${this.ffId}/custom.css`;\n try {\n return await this.fetchRaw(url);\n } catch (error) {\n if (error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n}\n\nmodule.exports = { APIClient };"],
|
|
5
|
+
"mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAKA,IAAMC,EAAkB,8BAClBC,EAAiB,iDAGjBC,EAAiB,qBAKjBC,EAAc,CAClB,GAAI,CACF,YACA,eACA,uBACA,2BACA,SACA,WACF,EACA,KAAM,CACJ,aACA,aACA,yBACA,eACA,eACF,CACF,EAGMC,EAAW,CACf,MAAO,QACP,WAAY,YACd,EAEAL,EAAO,QAAU,CACf,gBAAAC,EACA,eAAAC,EACA,eAAAC,EACA,iBACA,oBACA,YAAAC,EACA,SAAAC,CACF,IC9CA,IAAAC,EAAAC,EAAA,CAAAC,EAAAC,IAAA,KAAMC,EAAN,cAAuB,KAAM,CAC3B,YAAYC,EAASC,EAAYC,EAAK,CACpC,MAAMF,CAAO,EACb,KAAK,KAAO,WACZ,KAAK,WAAaC,EAClB,KAAK,IAAMC,EACX,KAAK,KAAO,OAAOD,CAAU,EAC/B,CACF,EAEME,EAAN,cAAyB,KAAM,CAC7B,YAAYH,EAASI,EAAW,CAC9B,MAAMJ,CAAO,EACb,KAAK,KAAO,aACZ,KAAK,UAAYI,EACjB,KAAK,KAAO,SAAS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UAAUA,CAAY,CAC1C,OAASR,EAAO,CACd,GAAIA,EAAM,aAAe,IACvB,OAAO,KAGT,MAAIA,EAAM,aAAe,IACjB,IAAIX,EACR,sGACA,IACAmB,CACF,EAEIR,CACR,CACF,CAMA,MAAM,uBAAwB,CAE5B,IAAMP,EAAM,GAAGN,CAAc,IAAI,KAAK,IAAI,0BAC1C,GAAI,CACF,OAAO,MAAM,KAAK,UAAUM,CAAG,CACjC,OAASO,EAAO,CACd,GAAIA,EAAM,aAAe,IACvB,OAAO,KAET,MAAMA,CACR,CACF,CAMA,MAAM,YAAa,CAEjB,IAAMP,EAAM,GAAGN,CAAc,IAAI,KAAK,IAAI,aAC1C,GAAI,CACF,OAAO,MAAM,KAAK,UAAUM,CAAG,CACjC,OAASO,EAAO,CACd,GAAIA,EAAM,aAAe,IACvB,OAAO,KAET,MAAMA,CACR,CACF,CAMA,MAAM,YAAa,CAEjB,IAAMP,EAAM,GAAGN,CAAc,IAAI,KAAK,IAAI,cAC1C,GAAI,CACF,OAAO,MAAM,KAAK,UAAUM,CAAG,CACjC,OAASO,EAAO,CACd,GAAIA,EAAM,aAAe,IACvB,OAAO,KAET,MAAMA,CACR,CACF,CAMA,MAAM,cAAe,CAEnB,IAAMP,EAAM,GAAGN,CAAc,IAAI,KAAK,IAAI,gBAC1C,GAAI,CACF,OAAO,MAAM,KAAK,UAAUM,CAAG,CACjC,OAASO,EAAO,CACd,GAAIA,EAAM,aAAe,IACvB,OAAO,KAET,MAAMA,CACR,CACF,CAMA,MAAM,gBAAiB,CAErB,IAAMP,EAAM,GAAGN,CAAc,IAAI,KAAK,IAAI,cAC1C,GAAI,CACF,OAAO,MAAM,KAAK,SAASM,CAAG,CAChC,OAASO,EAAO,CACd,GAAIA,EAAM,aAAe,IACvB,OAAO,KAET,MAAMA,CACR,CACF,CACF,EAEA,OAAO,QAAU,CAAE,UAAAV,CAAU",
|
|
6
|
+
"names": ["require_constants", "__commonJSMin", "exports", "module", "DEFAULT_API_URL", "LEGACY_API_URL", "CACHE_DIR_NAME", "CACHE_FILES", "ENV_VARS", "require_errors", "__commonJSMin", "exports", "module", "APIError", "message", "statusCode", "url", "CacheError", "operation", "ConfigError", "field", "ProcessingError", "token", "https", "http", "URL", "DEFAULT_API_URL", "LEGACY_API_URL", "ENV_VARS", "APIError", "APIClient", "ffId", "options", "url", "resolve", "reject", "response", "data", "chunk", "parsed", "error", "designSystemUrl", "tokensData", "tokens", "err", "legacyBaseURL", "urls", "results", "processedUrl"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u=require("https"),a=require("fs"),i=require("path"),{URL:w}=require("url"),l=require("os"),c=process.env.FF_REGISTRY_URL||"https://ff-registry.up.railway.app",p=process.env.FF_USE_LOCAL_REGISTRY==="true",d=class{constructor(e={}){this.appRoot=e.appRoot||process.cwd(),this.framework=e.framework||this.detectFramework(),this.config=e.config||{},this.outputPath=e.outputPath||this.getDefaultOutputPath(),this.overwrite=e.overwrite||!1,this.downloadedComponents=new Set,this.ffId=this.config.ffId||this.config["ff-id"]||null}detectFramework(){let e=i.join(this.appRoot,"package.json");if(a.existsSync(e)){let t=JSON.parse(a.readFileSync(e,"utf8")),s={...t.dependencies,...t.devDependencies};if(s.vue)return"vue";if(s.react)return"react"}return"react"}getDefaultOutputPath(){if(this.config.aliases&&this.config.aliases.ui){let t=this.config.aliases.ui.replace(/^@\//,"");return i.join(this.appRoot,t)}return this.framework==="vue"?i.join(this.appRoot,"src/components/ui"):i.join(this.appRoot,"components/ui")}fetchJson(e){if(p){let t,s=[i.join(process.cwd(),"../../packages/registry"),i.join(process.cwd(),"../../../packages/registry"),i.join(process.cwd(),"../../../../packages/registry"),i.join(__dirname,"../../../registry"),i.join(process.cwd(),"packages/registry")];if(t=s.find(n=>a.existsSync(n)),!t)return Promise.reject(new Error(`Local registry not found. Tried paths: ${s.join(", ")}`));let r=e.replace(c,"").replace(/^\//,""),o=i.join(t,...r.split("/"));try{let n=a.readFileSync(o,"utf8");return Promise.resolve(JSON.parse(n))}catch(n){return n.code==="ENOENT"?Promise.reject(new Error("HTTP 404: Not Found")):Promise.reject(new Error(`Failed to read local file: ${n.message}`))}}return new Promise((t,s)=>{u.get(e,r=>{let o="";if(r.statusCode>=400){s(new Error(`HTTP ${r.statusCode}: ${r.statusMessage}`));return}r.on("data",n=>{o+=n}),r.on("end",()=>{try{t(JSON.parse(o))}catch(n){s(new Error(`Invalid JSON response: ${n.message}`))}})}).on("error",r=>{s(r)})})}async getAllComponents(){try{let e=`${c}/components/${this.framework}/index.json`;return(await this.fetchJson(e)).components||[]}catch(e){return console.error("Failed to fetch component index:",e.message),[]}}async getCustomComponents(){if(!this.ffId)return[];try{let e=`${c}/custom/${this.ffId}/${this.framework}/index.json`;return(await this.fetchJson(e)).components||[]}catch{return[]}}async downloadComponents(e){let t={successful:[],failed:[],dependencies:new Set};for(let s of e)try{let r=await this.downloadComponent(s);t.successful.push(s),r.forEach(o=>t.dependencies.add(o))}catch(r){t.failed.push({component:s,error:r.message})}return{successful:t.successful,failed:t.failed,dependencies:Array.from(t.dependencies)}}async downloadComponent(e){if(this.downloadedComponents.has(e))return[];console.log(`\u{1F4E5} Downloading ${e}...`);let t,s=!1;if(this.ffId){let o=`${c}/custom/${this.ffId}/${this.framework}/${e}.json`;try{t=await this.fetchJson(o),s=!0}catch{}}if(!t){let o=`${c}/components/${this.framework}/${e}.json`;try{t=await this.fetchJson(o)}catch(n){throw n.message.includes("404")?new Error(`Component "${e}" not found`):new Error(`Failed to fetch ${e}: ${n.message}`)}}if(!t.files||!Array.isArray(t.files))throw new Error(`Invalid component data for ${e}`);for(let o of t.files)await this.writeComponentFile(o);this.downloadedComponents.add(e),console.log(` \u2713 ${e} downloaded`);let r=[...t.dependencies||[]];if(t.registryDependencies&&t.registryDependencies.length>0){console.log(` \u{1F4E6} Installing registry dependencies: ${t.registryDependencies.join(", ")}`);for(let o of t.registryDependencies)try{(await this.downloadComponent(o)).forEach(f=>r.push(f))}catch(n){console.warn(` \u26A0\uFE0F Failed to download dependency ${o}: ${n.message}`)}}return r}async writeComponentFile(e){let t=e.name.split("/").join(i.sep),s=i.join(this.outputPath,t),r=i.dirname(s);if(a.existsSync(r)||a.mkdirSync(r,{recursive:!0}),a.existsSync(s)&&!this.overwrite){console.log(` \u26A0\uFE0F Skipping ${e.name} (already exists)`);return}let o=e.content;l.EOL!==`
|
|
2
|
+
`&&(o=e.content.replace(/\n/g,l.EOL)),a.writeFileSync(s,o,"utf8")}};module.exports={ComponentDownloader:d};
|
|
2
3
|
//# sourceMappingURL=component-downloader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../lib/core/component-downloader.js"],
|
|
4
|
-
"sourcesContent": ["const https = require('https');\nconst fs = require('fs');\nconst path = require('path');\nconst { URL } = require('url');\n\nconst REGISTRY_URL = process.env.FF_REGISTRY_URL || 'https://ff-registry.up.railway.app';\nconst USE_LOCAL_REGISTRY = process.env.FF_USE_LOCAL_REGISTRY === 'true';\n\nclass ComponentDownloader {\n constructor(options = {}) {\n this.appRoot = options.appRoot || process.cwd();\n this.framework = options.framework || this.detectFramework();\n this.config = options.config || {};\n this.outputPath = options.outputPath || this.getDefaultOutputPath();\n this.overwrite = options.overwrite || false;\n this.downloadedComponents = new Set();\n this.ffId = this.config.ffId || this.config['ff-id'] || null;\n }\n\n /**\n * Detect framework from package.json\n */\n detectFramework() {\n const packageJsonPath = path.join(this.appRoot, 'package.json');\n \n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };\n \n if (deps.vue) {\n return 'vue';\n } else if (deps.react) {\n return 'react';\n }\n }\n \n // Default to React if can't detect\n return 'react';\n }\n\n /**\n * Get default output path based on framework and config\n */\n getDefaultOutputPath() {\n // Check if config has ui alias\n if (this.config.aliases && this.config.aliases.ui) {\n const uiAlias = this.config.aliases.ui;\n // Convert alias to actual path (e.g., @/components/ui -> components/ui)\n const cleanPath = uiAlias.replace(/^@\\//, '');\n return path.join(this.appRoot, cleanPath);\n }\n \n // Fallback to default paths\n if (this.framework === 'vue') {\n return path.join(this.appRoot, 'src/components/ui');\n }\n return path.join(this.appRoot, 'components/ui');\n }\n\n /**\n * Fetch JSON from URL or local file\n */\n fetchJson(url) {\n // If using local registry, read from file system\n if (USE_LOCAL_REGISTRY) {\n const
|
|
5
|
-
"mappings": "AAAA,IAAMA,EAAQ,QAAQ,OAAO,EACvBC,EAAK,QAAQ,IAAI,EACjBC,EAAO,QAAQ,MAAM,EACrB,CAAE,IAAAC,CAAI,EAAI,QAAQ,KAAK,
|
|
6
|
-
"names": ["https", "fs", "path", "URL", "REGISTRY_URL", "USE_LOCAL_REGISTRY", "ComponentDownloader", "options", "packageJsonPath", "packageJson", "deps", "cleanPath", "url", "localPath", "content", "error", "resolve", "reject", "response", "data", "chunk", "components", "results", "component", "dep", "componentName", "componentData", "isCustom", "customUrl", "file", "allDependencies", "d", "filePath", "dir"]
|
|
4
|
+
"sourcesContent": ["const https = require('https');\nconst fs = require('fs');\nconst path = require('path');\nconst { URL } = require('url');\nconst os = require('os');\n\nconst REGISTRY_URL = process.env.FF_REGISTRY_URL || 'https://ff-registry.up.railway.app';\nconst USE_LOCAL_REGISTRY = process.env.FF_USE_LOCAL_REGISTRY === 'true';\n\nclass ComponentDownloader {\n constructor(options = {}) {\n this.appRoot = options.appRoot || process.cwd();\n this.framework = options.framework || this.detectFramework();\n this.config = options.config || {};\n this.outputPath = options.outputPath || this.getDefaultOutputPath();\n this.overwrite = options.overwrite || false;\n this.downloadedComponents = new Set();\n this.ffId = this.config.ffId || this.config['ff-id'] || null;\n }\n\n /**\n * Detect framework from package.json\n */\n detectFramework() {\n const packageJsonPath = path.join(this.appRoot, 'package.json');\n \n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };\n \n if (deps.vue) {\n return 'vue';\n } else if (deps.react) {\n return 'react';\n }\n }\n \n // Default to React if can't detect\n return 'react';\n }\n\n /**\n * Get default output path based on framework and config\n */\n getDefaultOutputPath() {\n // Check if config has ui alias\n if (this.config.aliases && this.config.aliases.ui) {\n const uiAlias = this.config.aliases.ui;\n // Convert alias to actual path (e.g., @/components/ui -> components/ui)\n const cleanPath = uiAlias.replace(/^@\\//, '');\n return path.join(this.appRoot, cleanPath);\n }\n \n // Fallback to default paths\n if (this.framework === 'vue') {\n return path.join(this.appRoot, 'src/components/ui');\n }\n return path.join(this.appRoot, 'components/ui');\n }\n\n /**\n * Fetch JSON from URL or local file\n */\n fetchJson(url) {\n // If using local registry, read from file system\n if (USE_LOCAL_REGISTRY) {\n // Try to find the registry in the monorepo structure\n let registryPath;\n \n // Try multiple paths to find the registry\n const possiblePaths = [\n // From apps/prj to packages/registry\n path.join(process.cwd(), '../../packages/registry'),\n // From any deep directory in monorepo\n path.join(process.cwd(), '../../../packages/registry'),\n path.join(process.cwd(), '../../../../packages/registry'),\n // From the package itself\n path.join(__dirname, '../../../registry'),\n // Direct path if running from monorepo root\n path.join(process.cwd(), 'packages/registry')\n ];\n \n registryPath = possiblePaths.find(p => fs.existsSync(p));\n \n if (!registryPath) {\n return Promise.reject(new Error(`Local registry not found. Tried paths: ${possiblePaths.join(', ')}`));\n }\n \n // Extract the path from the URL and construct proper local path\n const urlPath = url.replace(REGISTRY_URL, '').replace(/^\\//, '');\n const localPath = path.join(registryPath, ...urlPath.split('/'));\n \n try {\n const content = fs.readFileSync(localPath, 'utf8');\n return Promise.resolve(JSON.parse(content));\n } catch (error) {\n // Return 404-like error for missing files\n if (error.code === 'ENOENT') {\n return Promise.reject(new Error('HTTP 404: Not Found'));\n }\n return Promise.reject(new Error(`Failed to read local file: ${error.message}`));\n }\n }\n\n return new Promise((resolve, reject) => {\n https.get(url, (response) => {\n let data = '';\n \n if (response.statusCode >= 400) {\n reject(new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`));\n return;\n }\n\n response.on('data', (chunk) => {\n data += chunk;\n });\n\n response.on('end', () => {\n try {\n resolve(JSON.parse(data));\n } catch (error) {\n reject(new Error(`Invalid JSON response: ${error.message}`));\n }\n });\n\n }).on('error', (error) => {\n reject(error);\n });\n });\n }\n\n /**\n * Get all available components from registry\n */\n async getAllComponents() {\n try {\n const url = `${REGISTRY_URL}/components/${this.framework}/index.json`;\n const index = await this.fetchJson(url);\n return index.components || [];\n } catch (error) {\n console.error('Failed to fetch component index:', error.message);\n return [];\n }\n }\n\n /**\n * Get all custom components for this ff-id\n */\n async getCustomComponents() {\n if (!this.ffId) {\n return [];\n }\n \n try {\n const url = `${REGISTRY_URL}/custom/${this.ffId}/${this.framework}/index.json`;\n const index = await this.fetchJson(url);\n return index.components || [];\n } catch (error) {\n // Custom components might not exist, that's ok\n return [];\n }\n }\n\n /**\n * Download multiple components\n */\n async downloadComponents(components) {\n const results = {\n successful: [],\n failed: [],\n dependencies: new Set()\n };\n\n for (const component of components) {\n try {\n const deps = await this.downloadComponent(component);\n results.successful.push(component);\n \n // Add dependencies\n deps.forEach(dep => results.dependencies.add(dep));\n } catch (error) {\n results.failed.push({\n component,\n error: error.message\n });\n }\n }\n\n return {\n successful: results.successful,\n failed: results.failed,\n dependencies: Array.from(results.dependencies)\n };\n }\n\n /**\n * Download a single component and its registry dependencies\n */\n async downloadComponent(componentName) {\n // Avoid downloading the same component twice\n if (this.downloadedComponents.has(componentName)) {\n return [];\n }\n\n console.log(`\uD83D\uDCE5 Downloading ${componentName}...`);\n\n // Try to fetch from custom components first if ff-id is available\n let componentData;\n let isCustom = false;\n \n if (this.ffId) {\n const customUrl = `${REGISTRY_URL}/custom/${this.ffId}/${this.framework}/${componentName}.json`;\n try {\n componentData = await this.fetchJson(customUrl);\n isCustom = true;\n } catch (error) {\n // Custom component not found, try standard registry\n }\n }\n \n // If not found in custom, try standard registry\n if (!componentData) {\n const url = `${REGISTRY_URL}/components/${this.framework}/${componentName}.json`;\n \n try {\n componentData = await this.fetchJson(url);\n } catch (error) {\n // Check if it's a 404 (component not found)\n if (error.message.includes('404')) {\n throw new Error(`Component \"${componentName}\" not found`);\n }\n throw new Error(`Failed to fetch ${componentName}: ${error.message}`);\n }\n }\n\n // Validate component data\n if (!componentData.files || !Array.isArray(componentData.files)) {\n throw new Error(`Invalid component data for ${componentName}`);\n }\n\n // Write component files\n for (const file of componentData.files) {\n await this.writeComponentFile(file);\n }\n\n this.downloadedComponents.add(componentName);\n console.log(` \u2713 ${componentName} downloaded`);\n\n // Download registry dependencies\n const allDependencies = [...(componentData.dependencies || [])];\n \n if (componentData.registryDependencies && componentData.registryDependencies.length > 0) {\n console.log(` \uD83D\uDCE6 Installing registry dependencies: ${componentData.registryDependencies.join(', ')}`);\n \n for (const dep of componentData.registryDependencies) {\n try {\n const depDeps = await this.downloadComponent(dep);\n depDeps.forEach(d => allDependencies.push(d));\n } catch (error) {\n console.warn(` \u26A0\uFE0F Failed to download dependency ${dep}: ${error.message}`);\n }\n }\n }\n\n return allDependencies;\n }\n\n /**\n * Write component file to disk\n */\n async writeComponentFile(file) {\n // Normalize the file path for the current platform\n // Convert forward slashes to the platform-specific separator\n const normalizedFileName = file.name.split('/').join(path.sep);\n const filePath = path.join(this.outputPath, normalizedFileName);\n const dir = path.dirname(filePath);\n\n // Create directory if it doesn't exist\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n // Check if file exists and overwrite setting\n if (fs.existsSync(filePath) && !this.overwrite) {\n console.log(` \u26A0\uFE0F Skipping ${file.name} (already exists)`);\n return;\n }\n\n // Normalize line endings to match the platform\n // This prevents git from showing every line as changed\n let normalizedContent = file.content;\n if (os.EOL !== '\\n') {\n // On Windows, replace LF with CRLF\n normalizedContent = file.content.replace(/\\n/g, os.EOL);\n }\n\n // Write file\n fs.writeFileSync(filePath, normalizedContent, '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CACT,CAKA,MAAM,mBAAmBD,EAAM,CAG7B,IAAMG,EAAqBH,EAAK,KAAK,MAAM,GAAG,EAAE,KAAKhC,EAAK,GAAG,EACvDoC,EAAWpC,EAAK,KAAK,KAAK,WAAYmC,CAAkB,EACxDE,EAAMrC,EAAK,QAAQoC,CAAQ,EAQjC,GALKrC,EAAG,WAAWsC,CAAG,GACpBtC,EAAG,UAAUsC,EAAK,CAAE,UAAW,EAAK,CAAC,EAInCtC,EAAG,WAAWqC,CAAQ,GAAK,CAAC,KAAK,UAAW,CAC9C,QAAQ,IAAI,6BAAmBJ,EAAK,IAAI,mBAAmB,EAC3D,MACF,CAIA,IAAIM,EAAoBN,EAAK,QACzB9B,EAAG,MAAQ;AAAA,IAEboC,EAAoBN,EAAK,QAAQ,QAAQ,MAAO9B,EAAG,GAAG,GAIxDH,EAAG,cAAcqC,EAAUE,EAAmB,MAAM,CACtD,CACF,EAEA,OAAO,QAAU,CAAE,oBAAAjC,CAAoB",
|
|
6
|
+
"names": ["https", "fs", "path", "URL", "os", "REGISTRY_URL", "USE_LOCAL_REGISTRY", "ComponentDownloader", "options", "packageJsonPath", "packageJson", "deps", "cleanPath", "url", "registryPath", "possiblePaths", "p", "urlPath", "localPath", "content", "error", "resolve", "reject", "response", "data", "chunk", "components", "results", "component", "dep", "componentName", "componentData", "isCustom", "customUrl", "file", "allDependencies", "d", "normalizedFileName", "filePath", "dir", "normalizedContent"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var s="https://tokens-studio-donux.up.railway.app/api",
|
|
1
|
+
var s="https://app.frontfriend.dev",n="https://tokens-studio-donux.up.railway.app/api",o=".cache/frontfriend";var t={JS:["tokens.js","variables.js","semanticVariables.js","semanticDarkVariables.js","cls.js","custom.js"],JSON:["fonts.json","icons.json","components-config.json","version.json","metadata.json"]},_={FF_ID:"FF_ID",FF_API_URL:"FF_API_URL"};module.exports={DEFAULT_API_URL:s,LEGACY_API_URL:n,CACHE_DIR_NAME:o,CACHE_TTL_DAYS:7,CACHE_TTL_MS:6048e5,CACHE_FILES:t,ENV_VARS:_};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../lib/core/constants.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Configuration constants for FrontFriend Tailwind v2\n */\n\n// API Configuration\nconst DEFAULT_API_URL = 'https://tokens-studio-donux.up.railway.app/api';\n\n// Cache Configuration\nconst CACHE_DIR_NAME = '.cache/frontfriend';\nconst CACHE_TTL_DAYS = 7;\nconst CACHE_TTL_MS = CACHE_TTL_DAYS * 24 * 60 * 60 * 1000;\n\n// File names\nconst CACHE_FILES = {\n JS: [\n 'tokens.js',\n 'variables.js',\n 'semanticVariables.js',\n 'semanticDarkVariables.js',\n 'cls.js',\n 'custom.js'\n ],\n JSON: [\n 'fonts.json',\n 'icons.json',\n 'components-config.json',\n 'version.json',\n 'metadata.json'\n ]\n};\n\n// Environment variables\nconst ENV_VARS = {\n FF_ID: 'FF_ID',\n FF_API_URL: 'FF_API_URL'\n};\n\nmodule.exports = {\n DEFAULT_API_URL,\n CACHE_DIR_NAME,\n CACHE_TTL_DAYS,\n CACHE_TTL_MS,\n CACHE_FILES,\n ENV_VARS\n};"],
|
|
5
|
-
"mappings": "AAKA,IAAMA,EAAkB,
|
|
6
|
-
"names": ["DEFAULT_API_URL", "CACHE_DIR_NAME", "CACHE_FILES", "ENV_VARS", "DEFAULT_API_URL", "CACHE_DIR_NAME"]
|
|
4
|
+
"sourcesContent": ["/**\n * Configuration constants for FrontFriend Tailwind v2\n */\n\n// API Configuration\nconst DEFAULT_API_URL = 'https://app.frontfriend.dev';\nconst LEGACY_API_URL = 'https://tokens-studio-donux.up.railway.app/api';\n\n// Cache Configuration\nconst CACHE_DIR_NAME = '.cache/frontfriend';\nconst CACHE_TTL_DAYS = 7;\nconst CACHE_TTL_MS = CACHE_TTL_DAYS * 24 * 60 * 60 * 1000;\n\n// File names\nconst CACHE_FILES = {\n JS: [\n 'tokens.js',\n 'variables.js',\n 'semanticVariables.js',\n 'semanticDarkVariables.js',\n 'cls.js',\n 'custom.js'\n ],\n JSON: [\n 'fonts.json',\n 'icons.json',\n 'components-config.json',\n 'version.json',\n 'metadata.json'\n ]\n};\n\n// Environment variables\nconst ENV_VARS = {\n FF_ID: 'FF_ID',\n FF_API_URL: 'FF_API_URL'\n};\n\nmodule.exports = {\n DEFAULT_API_URL,\n LEGACY_API_URL,\n CACHE_DIR_NAME,\n CACHE_TTL_DAYS,\n CACHE_TTL_MS,\n CACHE_FILES,\n ENV_VARS\n};"],
|
|
5
|
+
"mappings": "AAKA,IAAMA,EAAkB,8BAClBC,EAAiB,iDAGjBC,EAAiB,qBAKvB,IAAMC,EAAc,CAClB,GAAI,CACF,YACA,eACA,uBACA,2BACA,SACA,WACF,EACA,KAAM,CACJ,aACA,aACA,yBACA,eACA,eACF,CACF,EAGMC,EAAW,CACf,MAAO,QACP,WAAY,YACd,EAEA,OAAO,QAAU,CACf,gBAAAC,EACA,eAAAC,EACA,eAAAC,EACA,iBACA,oBACA,YAAAJ,EACA,SAAAC,CACF",
|
|
6
|
+
"names": ["DEFAULT_API_URL", "LEGACY_API_URL", "CACHE_DIR_NAME", "CACHE_FILES", "ENV_VARS", "DEFAULT_API_URL", "LEGACY_API_URL", "CACHE_DIR_NAME"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var O=(v,
|
|
1
|
+
var O=(v,e)=>()=>(e||v((e={exports:{}}).exports,e),e.exports);var x=O((W,V)=>{var b=class extends Error{constructor(e,s,o){super(e),this.name="APIError",this.statusCode=s,this.url=o,this.code=`API_${s}`}},C=class extends Error{constructor(e,s){super(e),this.name="CacheError",this.operation=s,this.code=`CACHE_${s.toUpperCase()}`}},k=class extends Error{constructor(e,s){super(e),this.name="ConfigError",this.field=s,this.code=`CONFIG_${s.toUpperCase()}`}},F=class extends Error{constructor(e,s){super(e),this.name="ProcessingError",this.token=s,this.code="PROCESSING_ERROR"}};V.exports={APIError:b,CacheError:C,ConfigError:k,ProcessingError:F}});var w=require("color"),N=require("https"),{ProcessingError:E}=x(),g=class{hexToHsl(e){try{let s=w(e),o=s.hsl(),t=Math.round(o.hue()),r=Math.round(o.saturationl()),a=Math.round(o.lightness()),i=s.alpha();if(i<1){let c=Math.round(i*100)/100;return`${t} ${r}% ${a}% / ${c}`}return`${t} ${r}% ${a}%`}catch(s){throw new E(`Failed to convert color ${e}: ${s.message}`,e)}}processColors(e){let s={},o={},t={backgroundColor:{},textColor:{},borderColor:{}};if(!e||typeof e!="object")return console.log(" \u26A0\uFE0F No valid color data to process"),{variables:s,colorMap:o,utilities:t};let r=(a,i="")=>{for(let[c,l]of Object.entries(a))if(l&&typeof l=="object")if(l.$value){let n=i?`${i}-${c}`:c,u=`--color-${n}`,f=this.hexToHsl(l.$value);s[u]=f,o[n]=u,t.backgroundColor[n]=`hsl(var(${u}))`,t.textColor[n]=`hsl(var(${u}))`,t.borderColor[n]=`hsl(var(${u}))`}else{let n=i?`${i}-${c}`:c;r(l,n)}};return e&&(e.colors?r(e.colors):r(e)),{variables:s,colorMap:o,utilities:t}}processSemanticTokens(e,s){let o={},t={backgroundColor:{},textColor:{},borderColor:{}},r=c=>c.replace(/ /g,"").replace(/\./g,"-").toLowerCase(),a=c=>{if(typeof c!="string")return null;let l=c.match(/^\{(.+)\}$/);if(!l)return null;let n=l[1].split(".");return n[0]==="colors"&&n.length>1?n[1]==="colors"&&n.length>2?n.slice(2).join("-"):n.slice(1).join("-"):n.join("-")},i=(c,l)=>{if(e[c])for(let[n,u]of Object.entries(e[c])){if(n==="disabled"){let f=a(u.$value);if(f){let m=s[f];if(m){let h=`--${c}-disabled`;o[h]=`var(${m})`,t[l].disabled=`var(${h})`}}continue}for(let[f,m]of Object.entries(u))for(let[h,p]of Object.entries(m)){let $=r(`${n}-${f}-${h}`);$.endsWith("-default")&&($=$.slice(0,-8));let d=`--${c}-${$}`,j=a(p.$value);if(j){let y=s[j];y&&(o[d]=`var(${y})`,t[l][$]=`var(${d})`)}else if(p.$value){let y=this.hexToHsl(p.$value);o[d]=y,t[l][$]=`hsl(var(${d}))`}}}};if(i("bg","backgroundColor"),i("text","textColor"),i("border","borderColor"),e.layer)for(let[c,l]of Object.entries(e.layer)){let n=`--layer-${c}`,u=a(l.$value);if(u){let f=u.replace(/\./g,"-").toLowerCase();if(f.endsWith("-default")&&(f=f.slice(0,-8)),f.startsWith("bg-")||f.startsWith("text-")||f.startsWith("border-")){let m=`--${f}`;o[n]=`var(${m})`,t.backgroundColor[`layer-${c}`]=`var(${n})`}else{let m=s[f];m&&(o[n]=`var(${m})`,t.backgroundColor[`layer-${c}`]=`var(${n})`)}}else if(l.$value){let f=this.hexToHsl(l.$value);o[n]=f,t.backgroundColor[`layer-${c}`]=`hsl(var(${n}))`}}if(e.overlay)for(let[c,l]of Object.entries(e.overlay)){let n=`--overlay-${c}`;l.$value&&(o[n]=l.$value,t.backgroundColor[`overlay-${c}`]=`var(${n})`)}if(e.icon){t.fill||(t.fill={});for(let[c,l]of Object.entries(e.icon)){if(c==="disabled"){let n=a(l.$value);if(n){let u=s[n];if(u){let f="--icon-disabled";o[f]=`var(${u})`,t.textColor["icon-disabled"]=`var(${f})`,t.fill["icon-disabled"]=`var(${f})`}}continue}for(let[n,u]of Object.entries(l))for(let[f,m]of Object.entries(u)){let h=r(`icon-${c}-${n}-${f}`);h.endsWith("-default")&&(h=h.slice(0,-8));let p=`--${h}`,$=a(m.$value);if($){let d=s[$];d&&(o[p]=`var(${d})`,t.textColor[h]=`var(${p})`,t.fill[h]=`var(${p})`)}}}}return{semanticVariables:o,tokens:t}}async fetchFontCss(e){return new Promise((s,o)=>{N.get(e,t=>{let r="";if(t.statusCode!==200){o(new Error(`Failed to fetch font CSS: ${t.statusCode}`));return}t.on("data",a=>{r+=a}),t.on("end",()=>{s(r)}),t.on("error",a=>{o(a)})}).on("error",t=>{o(t)})})}parseFontFaces(e){let s=/@font-face\s*{([^}]+)}/g,o=[],t;for(;(t=s.exec(e))!==null;){let r=t[1].trim().split(";").filter(Boolean),a={};r.forEach(i=>{let c=i.indexOf(":");if(c!==-1){let l=i.slice(0,c).trim(),n=i.slice(c+1).trim();l==="font-family"?a[l]=n.replace(/["']/g,""):a[l]=n}}),a.src&&(a.src=a.src.replace(/url\(["']?/,"url('").replace(/["']?\)/,"')")),o.push(a)}return o}async processFonts(e){let s=[];if(!e||typeof e!="object")return s;let o=Object.keys(e).filter(t=>t.startsWith("font"));for(let t of o){let r=e[t];if(typeof r=="string"&&r.startsWith("http"))try{let a=await this.fetchFontCss(r),i=this.parseFontFaces(a);i.length>0&&s.push(...i)}catch(a){console.warn(`Failed to process font ${t}:`,a.message)}}return s}processFontFamilies(e){let s={};if(!e||!e.font||!e.font.family)return s;let o=e.font.family;for(let[t,r]of Object.entries(o))if(r&&r.$value){let a=t.toLowerCase(),i=r.$value;typeof i=="string"&&i.startsWith("{")&&i.endsWith("}")&&(i=i.slice(1,-1));let c=l=>l.split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(" ");if(i.includes(","))s[a]=i;else{let l=c(i);l.includes(" ")&&!l.startsWith('"')&&!l.startsWith("'")?s[a]=`"${l}", sans-serif`:s[a]=`${l}, sans-serif`}}return s}processAnimations(e){let s={},o={};if(!e||typeof e!="object")return{keyframes:s,animations:o};for(let[t,r]of Object.entries(e))if(r&&typeof r=="object"){let a=`${t}`;if(r.keyframes){let c={};for(let[l,n]of Object.entries(r.keyframes))n&&typeof n=="object"&&(c[l]=n);s[a]=c}let i=[a,r.duration||"1s",r.easing||"ease",r.delay||"0s",r.iterations||"1",r.direction||"normal",r.fillMode||"none"].join(" ");o[t]=i}return{keyframes:s,animations:o}}generateSafelistClasses(e){let s=[];if(e.colorMap){let o=["hover:","focus:","active:","disabled:","dark:"],t=["bg-","text-","border-"];for(let r of Object.keys(e.colorMap))t.forEach(a=>{s.push(`${a}${r}`),o.forEach(i=>{s.push(`${i}${a}${r}`)})})}if(e.animations)for(let o of Object.keys(e.animations))s.push(`animate-${o}`);return s}extractClassesFromComponentsConfig(e){let s=new Set,o=r=>{typeof r=="string"&&r.split(/\s+/).filter(i=>i.length>0).forEach(i=>{s.add(i)})},t=r=>{if(!(!r||typeof r!="object"))for(let a in r){let i=r[a];typeof i=="string"?o(i):typeof i=="object"&&t(i)}};return e&&t(e),Array.from(s).sort()}processCustomCss(e){return!e||typeof e!="string"?{}:{raw:e}}async process(e){try{let s={variables:{},semanticVariables:{},semanticDarkVariables:{},utilities:{},fontFaces:[],keyframes:{},animations:{},safelist:[],metadata:{},custom:e.customCss?this.processCustomCss(e.customCss):{}},o=null;if(e.tokens&&typeof e.tokens=="object"){let t=e.tokens;o=t["Global Colors/Default"]||t["Global Colors"]||t.colors||t}else e.colors&&(o=e.colors);if(o){let t=this.processColors(o);s.variables={...s.variables,...t.variables},s.utilities={...s.utilities,...t.utilities},s.colorMap=t.colorMap||{}}else s.colorMap={};if(e.semantic&&s.colorMap){let t=this.processSemanticTokens(e.semantic,s.colorMap);s.semanticVariables=t.semanticVariables,t.tokens&&(s.tokens=t.tokens,s.utilities=t.tokens)}if(e.semanticDark&&s.colorMap){let t=this.processSemanticTokens(e.semanticDark,s.colorMap);s.semanticDarkVariables=t.semanticVariables}if(e.fonts&&(s.fontFaces=await this.processFonts(e.fonts)),e.globalTokens&&(s.fontFamilies=this.processFontFamilies(e.globalTokens),s.fontFamilies&&(s.utilities.fontFamily||(s.utilities.fontFamily={}),Object.assign(s.utilities.fontFamily,s.fontFamilies))),e.animations){let t=this.processAnimations(e.animations);s.keyframes=t.keyframes,s.animations=t.animations}return s.safelist=this.generateSafelistClasses(s),s.metadata={timestamp:new Date().toISOString(),version:e.version||"2.0.0",ffId:e.ffId},s}catch(s){throw console.error("Error processing tokens:",s),s}}};module.exports=g;
|
|
2
2
|
//# sourceMappingURL=token-processor.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../lib/core/errors.js", "../../../lib/core/token-processor.js"],
|
|
4
|
-
"sourcesContent": ["class APIError extends Error {\n constructor(message, statusCode, url) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.url = url;\n this.code = `API_${statusCode}`;\n }\n}\n\nclass CacheError extends Error {\n constructor(message, operation) {\n super(message);\n this.name = 'CacheError';\n this.operation = operation;\n this.code = `CACHE_${operation.toUpperCase()}`;\n }\n}\n\nclass ConfigError extends Error {\n constructor(message, field) {\n super(message);\n this.name = 'ConfigError';\n this.field = field;\n this.code = `CONFIG_${field.toUpperCase()}`;\n }\n}\n\nclass ProcessingError extends Error {\n constructor(message, token) {\n super(message);\n this.name = 'ProcessingError';\n this.token = token;\n this.code = 'PROCESSING_ERROR';\n }\n}\n\nmodule.exports = {\n APIError,\n CacheError,\n ConfigError,\n ProcessingError\n};", "const Color = require('color');\nconst https = require('https');\nconst { ProcessingError } = require('./errors');\n\nclass TokenProcessor {\n /**\n * Convert hex color to HSL format for Tailwind CSS\n * @param {string} hex - Hex color value\n * @returns {string} HSL string in format \"H S% L%\"\n */\n hexToHsl(hex) {\n try {\n const color = Color(hex);\n const hsl = color.hsl();\n \n // Get HSL values\n const h = Math.round(hsl.hue());\n const s = Math.round(hsl.saturationl());\n const l = Math.round(hsl.lightness());\n \n // Handle alpha channel if present\n const alpha = color.alpha();\n if (alpha < 1) {\n // Round alpha to 2 decimal places\n const roundedAlpha = Math.round(alpha * 100) / 100;\n return `${h} ${s}% ${l}% / ${roundedAlpha}`;\n }\n \n return `${h} ${s}% ${l}%`;\n } catch (error) {\n throw new ProcessingError(`Failed to convert color ${hex}: ${error.message}`, hex);\n }\n }\n\n /**\n * Process color tokens into CSS variables\n * @param {Object} colorsData - Color tokens data\n * @returns {Object} Processed variables and color map\n */\n processColors(colorsData) {\n const variables = {};\n const colorMap = {};\n const utilities = {\n backgroundColor: {},\n textColor: {},\n borderColor: {}\n };\n\n // Recursive function to process nested color structures\n const processColorGroup = (obj, prefix = '') => {\n for (const [key, value] of Object.entries(obj)) {\n if (value && typeof value === 'object') {\n if (value.$value) {\n // This is a color value\n const colorName = prefix ? `${prefix}-${key}` : key;\n const varName = `--color-${colorName}`;\n \n // Convert hex to HSL\n const hslValue = this.hexToHsl(value.$value);\n variables[varName] = hslValue;\n colorMap[colorName] = varName;\n \n // Generate Tailwind utilities\n utilities.backgroundColor[colorName] = `hsl(var(${varName}))`;\n utilities.textColor[colorName] = `hsl(var(${varName}))`;\n utilities.borderColor[colorName] = `hsl(var(${varName}))`;\n } else {\n // Nested structure, recurse\n const newPrefix = prefix ? `${prefix}-${key}` : key;\n processColorGroup(value, newPrefix);\n }\n }\n }\n };\n\n // Process colors - handle both nested and flat structures\n if (colorsData) {\n if (colorsData.colors) {\n processColorGroup(colorsData.colors);\n } else {\n // Direct color structure\n processColorGroup(colorsData);\n }\n }\n\n return {\n variables,\n colorMap,\n utilities\n };\n }\n\n /**\n * Process semantic tokens that reference other tokens\n * @param {Object} semanticData - Semantic tokens data\n * @param {Object} colorMap - Map of color names to CSS variables\n * @returns {Object} Semantic CSS variables and token utilities\n */\n processSemanticTokens(semanticData, colorMap) {\n const semanticVariables = {};\n const tokens = {\n backgroundColor: {},\n textColor: {},\n borderColor: {}\n };\n\n // Format token name (similar to current plugin)\n const formatTokenName = (name) => {\n return name.replace(/ /g, '').replace(/\\./g, '-').toLowerCase();\n };\n\n // Extract token reference from string like \"{colors.primary.500}\"\n const extractReference = (refString) => {\n // Handle non-string values\n if (typeof refString !== 'string') return null;\n \n const match = refString.match(/^\\{(.+)\\}$/);\n if (!match) return null;\n \n // Split the reference path and remove the first part if it's \"colors\"\n const parts = match[1].split('.');\n if (parts[0] === 'colors' && parts.length > 1) {\n // Check if second part is also \"colors\" (nested structure)\n if (parts[1] === 'colors' && parts.length > 2) {\n return parts.slice(2).join('-');\n }\n return parts.slice(1).join('-');\n }\n return parts.join('-');\n };\n\n // Process semantic category (bg, text, border)\n const processCategory = (category, outputCategory) => {\n if (!semanticData[category]) return;\n\n for (const [key, value] of Object.entries(semanticData[category])) {\n if (key === 'disabled') {\n // Handle disabled state specially\n const reference = extractReference(value.$value);\n if (reference) {\n const referencedVar = colorMap[reference];\n if (referencedVar) {\n const varName = `--${category}-disabled`;\n semanticVariables[varName] = `var(${referencedVar})`;\n tokens[outputCategory]['disabled'] = `var(${varName})`;\n }\n }\n continue;\n }\n\n // Process nested structure (e.g., neutral -> low -> default)\n for (const [mainKey, mainValue] of Object.entries(value)) {\n for (const [stateKey, stateValue] of Object.entries(mainValue)) {\n let tokenKey = formatTokenName(`${key}-${mainKey}-${stateKey}`);\n \n // Remove '-default' suffix for cleaner class names\n if (tokenKey.endsWith('-default')) {\n tokenKey = tokenKey.slice(0, -8);\n }\n\n const varName = `--${category}-${tokenKey}`;\n \n // Check if it's a reference\n const reference = extractReference(stateValue.$value);\n if (reference) {\n // Look up the referenced color variable\n const referencedVar = colorMap[reference];\n if (referencedVar) {\n semanticVariables[varName] = `var(${referencedVar})`;\n tokens[outputCategory][tokenKey] = `var(${varName})`;\n }\n } else if (stateValue.$value) {\n // Direct hex value - convert to HSL\n const hslValue = this.hexToHsl(stateValue.$value);\n semanticVariables[varName] = hslValue;\n tokens[outputCategory][tokenKey] = `hsl(var(${varName}))`;\n }\n }\n }\n }\n };\n\n // Process semantic categories\n processCategory('bg', 'backgroundColor');\n processCategory('text', 'textColor');\n processCategory('border', 'borderColor');\n\n // Process layer tokens\n if (semanticData.layer) {\n for (const [layerKey, layerValue] of Object.entries(semanticData.layer)) {\n const varName = `--layer-${layerKey}`;\n const reference = extractReference(layerValue.$value);\n \n if (reference) {\n // Format the reference to match semantic token naming\n let formattedRef = reference.replace(/\\./g, '-').toLowerCase();\n \n // Remove -default suffix if present\n if (formattedRef.endsWith('-default')) {\n formattedRef = formattedRef.slice(0, -8);\n }\n \n // Check if it's a semantic reference (e.g., bg-neutral-subtle)\n if (formattedRef.startsWith('bg-') || formattedRef.startsWith('text-') || formattedRef.startsWith('border-')) {\n // It's referencing a semantic token\n const semanticVar = `--${formattedRef}`;\n semanticVariables[varName] = `var(${semanticVar})`;\n tokens.backgroundColor[`layer-${layerKey}`] = `var(${varName})`;\n } else {\n // It's referencing a color token\n const referencedVar = colorMap[formattedRef];\n if (referencedVar) {\n semanticVariables[varName] = `var(${referencedVar})`;\n tokens.backgroundColor[`layer-${layerKey}`] = `var(${varName})`;\n }\n }\n } else if (layerValue.$value) {\n // Direct value\n const hslValue = this.hexToHsl(layerValue.$value);\n semanticVariables[varName] = hslValue;\n tokens.backgroundColor[`layer-${layerKey}`] = `hsl(var(${varName}))`;\n }\n }\n }\n\n // Process overlay tokens\n if (semanticData.overlay) {\n for (const [overlayKey, overlayValue] of Object.entries(semanticData.overlay)) {\n const varName = `--overlay-${overlayKey}`;\n \n if (overlayValue.$value) {\n // Overlay values are hex colors with alpha, keep them as-is\n semanticVariables[varName] = overlayValue.$value;\n tokens.backgroundColor[`overlay-${overlayKey}`] = `var(${varName})`;\n }\n }\n }\n\n // Process icon tokens (map to text and fill colors)\n if (semanticData.icon) {\n // Ensure fill property exists\n if (!tokens.fill) {\n tokens.fill = {};\n }\n \n for (const [iconKey, iconValue] of Object.entries(semanticData.icon)) {\n if (iconKey === 'disabled') {\n const reference = extractReference(iconValue.$value);\n if (reference) {\n const referencedVar = colorMap[reference];\n if (referencedVar) {\n const varName = `--icon-disabled`;\n semanticVariables[varName] = `var(${referencedVar})`;\n tokens.textColor['icon-disabled'] = `var(${varName})`;\n tokens.fill['icon-disabled'] = `var(${varName})`;\n }\n }\n continue;\n }\n\n for (const [mainKey, mainValue] of Object.entries(iconValue)) {\n for (const [stateKey, stateValue] of Object.entries(mainValue)) {\n let tokenKey = formatTokenName(`icon-${iconKey}-${mainKey}-${stateKey}`);\n if (tokenKey.endsWith('-default')) {\n tokenKey = tokenKey.slice(0, -8);\n }\n\n const varName = `--${tokenKey}`;\n const reference = extractReference(stateValue.$value);\n \n if (reference) {\n const referencedVar = colorMap[reference];\n if (referencedVar) {\n semanticVariables[varName] = `var(${referencedVar})`;\n tokens.textColor[tokenKey] = `var(${varName})`;\n tokens.fill[tokenKey] = `var(${varName})`;\n }\n }\n }\n }\n }\n }\n\n return { semanticVariables, tokens };\n }\n\n /**\n * Fetch CSS from URL and parse font-face rules\n * @param {string} url - Font CSS URL\n * @returns {Promise<string>} Font face CSS\n */\n async fetchFontCss(url) {\n return new Promise((resolve, reject) => {\n https.get(url, (response) => {\n let data = '';\n \n if (response.statusCode !== 200) {\n reject(new Error(`Failed to fetch font CSS: ${response.statusCode}`));\n return;\n }\n\n response.on('data', (chunk) => {\n data += chunk;\n });\n\n response.on('end', () => {\n resolve(data);\n });\n\n response.on('error', (error) => {\n reject(error);\n });\n }).on('error', (error) => {\n reject(error);\n });\n });\n }\n\n /**\n * Parse font-face CSS into structured objects\n * @param {string} css - CSS text containing @font-face rules\n * @returns {Array} Array of font-face objects\n */\n parseFontFaces(css) {\n const fontFaceRegex = /@font-face\\s*{([^}]+)}/g;\n const fontFaces = [];\n let match;\n\n while ((match = fontFaceRegex.exec(css)) !== null) {\n const fontProperties = match[1].trim().split(';').filter(Boolean);\n const fontObj = {};\n\n fontProperties.forEach(prop => {\n const colonIndex = prop.indexOf(':');\n if (colonIndex !== -1) {\n const key = prop.slice(0, colonIndex).trim();\n const value = prop.slice(colonIndex + 1).trim();\n \n // Clean up quotes from font-family\n if (key === 'font-family') {\n fontObj[key] = value.replace(/[\"']/g, '');\n } else {\n fontObj[key] = value;\n }\n }\n });\n\n // Ensure src URLs are properly quoted\n if (fontObj['src']) {\n fontObj['src'] = fontObj['src']\n .replace(/url\\([\"']?/, 'url(\\'')\n .replace(/[\"']?\\)/, '\\')');\n }\n\n fontFaces.push(fontObj);\n }\n\n return fontFaces;\n }\n\n /**\n * Process fonts data\n * @param {Object} fontData - Font URLs object\n * @returns {Promise<Array>} Array of font-face objects\n */\n async processFonts(fontData) {\n const fontFaces = [];\n\n if (!fontData || typeof fontData !== 'object') {\n return fontFaces;\n }\n\n // Process each font URL (font, font2, etc.)\n const fontFields = Object.keys(fontData).filter(key => key.startsWith('font'));\n \n for (const field of fontFields) {\n const url = fontData[field];\n if (typeof url === 'string' && url.startsWith('http')) {\n try {\n const css = await this.fetchFontCss(url);\n const parsedFonts = this.parseFontFaces(css);\n \n if (parsedFonts.length > 0) {\n fontFaces.push(...parsedFonts);\n }\n } catch (error) {\n console.warn(`Failed to process font ${field}:`, error.message);\n }\n }\n }\n\n return fontFaces;\n }\n\n /**\n * Process font family tokens\n * @param {Object} globalTokens - Global tokens data containing font families\n * @returns {Object} Font family utilities\n */\n processFontFamilies(globalTokens) {\n const fontFamilyUtilities = {};\n \n if (!globalTokens || !globalTokens.font || !globalTokens.font.family) {\n return fontFamilyUtilities;\n }\n\n const fontFamilies = globalTokens.font.family;\n \n // Process each font family (primary, secondary, etc.)\n for (const [key, value] of Object.entries(fontFamilies)) {\n if (value && value.$value) {\n // Format the key (e.g., primary -> primary)\n const fontKey = key.toLowerCase();\n \n // Extract font family value\n let fontFamilyValue = value.$value;\n \n // If it's a reference, extract it\n if (typeof fontFamilyValue === 'string' && fontFamilyValue.startsWith('{') && fontFamilyValue.endsWith('}')) {\n // This is a reference, but for font families we usually have direct values\n fontFamilyValue = fontFamilyValue.slice(1, -1);\n }\n \n // Store the font family utility\n // Store the font family utility - ensure proper quoting for multi-word fonts\n // For Tailwind, we need to format font families properly\n \n // Capitalize the first letter of each word in font names for proper rendering\n const capitalizeFontName = (name) => {\n return name.split(' ').map(word => \n word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n ).join(' ');\n };\n \n // Check if it's already a font stack or needs quoting\n if (fontFamilyValue.includes(',')) {\n // It's already a font stack, use as is\n fontFamilyUtilities[fontKey] = fontFamilyValue;\n } else {\n // Capitalize the font name\n const capitalizedFont = capitalizeFontName(fontFamilyValue);\n \n if (capitalizedFont.includes(' ') && !capitalizedFont.startsWith('\"') && !capitalizedFont.startsWith(\"'\")) {\n // Multi-word font needs quotes, add generic fallback\n fontFamilyUtilities[fontKey] = `\"${capitalizedFont}\", sans-serif`;\n } else {\n // Single word font, add generic fallback\n fontFamilyUtilities[fontKey] = `${capitalizedFont}, sans-serif`;\n }\n }\n }\n }\n \n return fontFamilyUtilities;\n }\n\n /**\n * Process animations data\n * @param {Object} animationData - Animation definitions\n * @returns {Object} Keyframes and animation utilities\n */\n processAnimations(animationData) {\n const keyframes = {};\n const animations = {};\n\n if (!animationData || typeof animationData !== 'object') {\n return { keyframes, animations };\n }\n\n // Process each animation\n for (const [name, definition] of Object.entries(animationData)) {\n if (definition && typeof definition === 'object') {\n // Generate keyframe name\n const keyframeName = `${name}`;\n \n // Process keyframe steps\n if (definition.keyframes) {\n const keyframeSteps = {};\n \n for (const [step, props] of Object.entries(definition.keyframes)) {\n if (props && typeof props === 'object') {\n keyframeSteps[step] = props;\n }\n }\n \n keyframes[keyframeName] = keyframeSteps;\n }\n\n // Create animation utility\n const animationValue = [\n keyframeName,\n definition.duration || '1s',\n definition.easing || 'ease',\n definition.delay || '0s',\n definition.iterations || '1',\n definition.direction || 'normal',\n definition.fillMode || 'none'\n ].join(' ');\n\n animations[name] = animationValue;\n }\n }\n\n return { keyframes, animations };\n }\n\n /**\n * Generate safelist classes for Tailwind\n * @param {Object} tokens - All processed tokens\n * @returns {Array} Safelist patterns\n */\n generateSafelistClasses(tokens) {\n const safelist = [];\n\n // Add color utilities with common variants\n if (tokens.colorMap) {\n const variants = ['hover:', 'focus:', 'active:', 'disabled:', 'dark:'];\n const utilities = ['bg-', 'text-', 'border-'];\n\n for (const colorName of Object.keys(tokens.colorMap)) {\n // Add base utilities\n utilities.forEach(utility => {\n safelist.push(`${utility}${colorName}`);\n \n // Add variants\n variants.forEach(variant => {\n safelist.push(`${variant}${utility}${colorName}`);\n });\n });\n }\n }\n\n // Add animation classes\n if (tokens.animations) {\n for (const animationName of Object.keys(tokens.animations)) {\n safelist.push(`animate-${animationName}`);\n }\n }\n\n return safelist;\n }\n\n /**\n * Extract unique classes from components configuration\n * @param {Object} componentsConfig - Components configuration object\n * @returns {Array} Array of unique class names\n */\n extractClassesFromComponentsConfig(componentsConfig) {\n const classSet = new Set();\n\n // Helper function to extract classes from a string\n const extractClasses = (classString) => {\n if (typeof classString === 'string') {\n // Split by spaces and filter out empty strings\n const classes = classString.split(/\\s+/).filter(c => c.length > 0);\n classes.forEach(cls => {\n // Skip variant selectors like [&>svg]:absolute\n classSet.add(cls);\n });\n }\n };\n\n // Recursive function to traverse the config object\n const traverse = (obj) => {\n if (!obj || typeof obj !== 'object') return;\n\n for (const key in obj) {\n const value = obj[key];\n \n if (typeof value === 'string') {\n extractClasses(value);\n } else if (typeof value === 'object') {\n traverse(value);\n }\n }\n };\n\n // Process the components config\n if (componentsConfig) {\n traverse(componentsConfig);\n }\n\n // Convert set to array and sort\n return Array.from(classSet).sort();\n }\n\n /**\n * Process custom CSS into a format compatible with Tailwind's addBase\n * @param {string} css - Raw CSS string\n * @returns {Object} CSS rules as object for Tailwind addBase\n */\n processCustomCss(css) {\n if (!css || typeof css !== 'string') {\n return {};\n }\n\n // Simply return the raw CSS as a string that can be added via addBase\n return { raw: css };\n }\n\n /**\n * Main orchestration method to process all token data\n * @param {Object} data - Complete token data from API\n * @returns {Promise<Object>} Processed token data\n */\n async process(data) {\n try {\n const result = {\n variables: {},\n semanticVariables: {},\n semanticDarkVariables: {},\n utilities: {},\n fontFaces: [],\n keyframes: {},\n animations: {},\n safelist: [],\n metadata: {},\n custom: data.customCss ? this.processCustomCss(data.customCss) : {}\n };\n\n // Process colors\n if (data.colors) {\n const colorResult = this.processColors(data);\n result.variables = { ...result.variables, ...colorResult.variables };\n result.utilities = { ...result.utilities, ...colorResult.utilities };\n result.colorMap = colorResult.colorMap || {};\n } else {\n result.colorMap = {};\n }\n\n // Process semantic tokens (light mode)\n if (data.semantic && result.colorMap) {\n const semanticResult = this.processSemanticTokens(data.semantic, result.colorMap);\n result.semanticVariables = semanticResult.semanticVariables;\n // Merge tokens into utilities\n if (semanticResult.tokens) {\n result.tokens = semanticResult.tokens;\n // Replace color utilities with semantic token utilities\n result.utilities = semanticResult.tokens;\n }\n }\n\n // Process semantic tokens (dark mode)\n if (data.semanticDark && result.colorMap) {\n const semanticDarkResult = this.processSemanticTokens(data.semanticDark, result.colorMap);\n result.semanticDarkVariables = semanticDarkResult.semanticVariables;\n }\n\n // Process fonts\n if (data.fonts) {\n result.fontFaces = await this.processFonts(data.fonts);\n }\n\n // Process font families from global tokens\n if (data.globalTokens) {\n result.fontFamilies = this.processFontFamilies(data.globalTokens);\n \n // Add font family utilities\n if (result.fontFamilies) {\n if (!result.utilities.fontFamily) {\n result.utilities.fontFamily = {};\n }\n Object.assign(result.utilities.fontFamily, result.fontFamilies);\n }\n }\n\n // Process animations\n if (data.animations) {\n const animationResult = this.processAnimations(data.animations);\n result.keyframes = animationResult.keyframes;\n result.animations = animationResult.animations;\n }\n\n // Generate safelist\n result.safelist = this.generateSafelistClasses(result);\n\n // Add metadata\n result.metadata = {\n timestamp: new Date().toISOString(),\n version: data.version || '2.0.0',\n ffId: data.ffId\n };\n\n return result;\n } catch (error) {\n console.error('Error processing tokens:', error);\n throw error;\n }\n }\n}\n\nmodule.exports = TokenProcessor;"],
|
|
5
|
-
"mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,KAAMC,EAAN,cAAuB,KAAM,CAC3B,YAAYC,EAASC,EAAYC,EAAK,CACpC,MAAMF,CAAO,EACb,KAAK,KAAO,WACZ,KAAK,WAAaC,EAClB,KAAK,IAAMC,EACX,KAAK,KAAO,OAAOD,CAAU,EAC/B,CACF,EAEME,EAAN,cAAyB,KAAM,CAC7B,YAAYH,EAASI,EAAW,CAC9B,MAAMJ,CAAO,EACb,KAAK,KAAO,aACZ,KAAK,UAAYI,EACjB,KAAK,KAAO,SAASA,EAAU,YAAY,CAAC,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C,MACED,EAAO,SAAW,CAAC,EAIrB,GAAI1C,EAAK,UAAY0C,EAAO,SAAU,CACpC,IAAME,EAAiB,KAAK,sBAAsB5C,EAAK,SAAU0C,EAAO,QAAQ,EAChFA,EAAO,kBAAoBE,EAAe,kBAEtCA,EAAe,SACjBF,EAAO,OAASE,EAAe,OAE/BF,EAAO,UAAYE,EAAe,OAEtC,CAGA,GAAI5C,EAAK,cAAgB0C,EAAO,SAAU,CACxC,IAAMG,EAAqB,KAAK,sBAAsB7C,EAAK,aAAc0C,EAAO,QAAQ,EACxFA,EAAO,sBAAwBG,EAAmB,iBACpD,CAqBA,GAlBI7C,EAAK,QACP0C,EAAO,UAAY,MAAM,KAAK,aAAa1C,EAAK,KAAK,GAInDA,EAAK,eACP0C,EAAO,aAAe,KAAK,oBAAoB1C,EAAK,YAAY,EAG5D0C,EAAO,eACJA,EAAO,UAAU,aACpBA,EAAO,UAAU,WAAa,CAAC,GAEjC,OAAO,OAAOA,EAAO,UAAU,WAAYA,EAAO,YAAY,IAK9D1C,EAAK,WAAY,CACnB,IAAM8C,EAAkB,KAAK,kBAAkB9C,EAAK,UAAU,EAC9D0C,EAAO,UAAYI,EAAgB,UACnCJ,EAAO,WAAaI,EAAgB,UACtC,CAGA,OAAAJ,EAAO,SAAW,KAAK,wBAAwBA,CAAM,EAGrDA,EAAO,SAAW,CAChB,UAAW,IAAI,KAAK,EAAE,YAAY,EAClC,QAAS1C,EAAK,SAAW,QACzB,KAAMA,EAAK,IACb,EAEO0C,CACT,OAASvF,EAAO,CACd,cAAQ,MAAM,2BAA4BA,CAAK,EACzCA,CACR,CACF,CACF,EAEA,OAAO,QAAUT",
|
|
6
|
-
"names": ["require_errors", "__commonJSMin", "exports", "module", "APIError", "message", "statusCode", "url", "CacheError", "operation", "ConfigError", "field", "ProcessingError", "token", "Color", "https", "ProcessingError", "TokenProcessor", "hex", "color", "hsl", "h", "s", "l", "alpha", "roundedAlpha", "error", "colorsData", "variables", "colorMap", "utilities", "processColorGroup", "obj", "prefix", "key", "value", "colorName", "varName", "hslValue", "newPrefix", "semanticData", "semanticVariables", "tokens", "formatTokenName", "name", "extractReference", "refString", "match", "parts", "processCategory", "category", "outputCategory", "reference", "referencedVar", "mainKey", "mainValue", "stateKey", "stateValue", "tokenKey", "layerKey", "layerValue", "formattedRef", "semanticVar", "overlayKey", "overlayValue", "iconKey", "iconValue", "url", "resolve", "reject", "response", "data", "chunk", "css", "fontFaceRegex", "fontFaces", "fontProperties", "fontObj", "prop", "colonIndex", "fontData", "fontFields", "field", "parsedFonts", "globalTokens", "fontFamilyUtilities", "fontFamilies", "fontKey", "fontFamilyValue", "capitalizeFontName", "word", "capitalizedFont", "animationData", "keyframes", "animations", "definition", "keyframeName", "keyframeSteps", "step", "props", "animationValue", "safelist", "variants", "utility", "variant", "animationName", "componentsConfig", "classSet", "extractClasses", "classString", "c", "cls", "traverse", "result", "colorResult", "semanticResult", "semanticDarkResult", "animationResult"]
|
|
4
|
+
"sourcesContent": ["class APIError extends Error {\n constructor(message, statusCode, url) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.url = url;\n this.code = `API_${statusCode}`;\n }\n}\n\nclass CacheError extends Error {\n constructor(message, operation) {\n super(message);\n this.name = 'CacheError';\n this.operation = operation;\n this.code = `CACHE_${operation.toUpperCase()}`;\n }\n}\n\nclass ConfigError extends Error {\n constructor(message, field) {\n super(message);\n this.name = 'ConfigError';\n this.field = field;\n this.code = `CONFIG_${field.toUpperCase()}`;\n }\n}\n\nclass ProcessingError extends Error {\n constructor(message, token) {\n super(message);\n this.name = 'ProcessingError';\n this.token = token;\n this.code = 'PROCESSING_ERROR';\n }\n}\n\nmodule.exports = {\n APIError,\n CacheError,\n ConfigError,\n ProcessingError\n};", "const Color = require('color');\nconst https = require('https');\nconst { ProcessingError } = require('./errors');\n\nclass TokenProcessor {\n /**\n * Convert hex color to HSL format for Tailwind CSS\n * @param {string} hex - Hex color value\n * @returns {string} HSL string in format \"H S% L%\"\n */\n hexToHsl(hex) {\n try {\n const color = Color(hex);\n const hsl = color.hsl();\n \n // Get HSL values\n const h = Math.round(hsl.hue());\n const s = Math.round(hsl.saturationl());\n const l = Math.round(hsl.lightness());\n \n // Handle alpha channel if present\n const alpha = color.alpha();\n if (alpha < 1) {\n // Round alpha to 2 decimal places\n const roundedAlpha = Math.round(alpha * 100) / 100;\n return `${h} ${s}% ${l}% / ${roundedAlpha}`;\n }\n \n return `${h} ${s}% ${l}%`;\n } catch (error) {\n throw new ProcessingError(`Failed to convert color ${hex}: ${error.message}`, hex);\n }\n }\n\n /**\n * Process color tokens into CSS variables\n * @param {Object} colorsData - Color tokens data\n * @returns {Object} Processed variables and color map\n */\n processColors(colorsData) {\n const variables = {};\n const colorMap = {};\n const utilities = {\n backgroundColor: {},\n textColor: {},\n borderColor: {}\n };\n\n // Check if we have valid color data\n if (!colorsData || typeof colorsData !== 'object') {\n console.log(' \u26A0\uFE0F No valid color data to process');\n return { variables, colorMap, utilities };\n }\n\n // Recursive function to process nested color structures\n const processColorGroup = (obj, prefix = '') => {\n for (const [key, value] of Object.entries(obj)) {\n if (value && typeof value === 'object') {\n if (value.$value) {\n // This is a color value\n const colorName = prefix ? `${prefix}-${key}` : key;\n const varName = `--color-${colorName}`;\n \n // Convert hex to HSL\n const hslValue = this.hexToHsl(value.$value);\n variables[varName] = hslValue;\n colorMap[colorName] = varName;\n \n // Generate Tailwind utilities\n utilities.backgroundColor[colorName] = `hsl(var(${varName}))`;\n utilities.textColor[colorName] = `hsl(var(${varName}))`;\n utilities.borderColor[colorName] = `hsl(var(${varName}))`;\n } else {\n // Nested structure, recurse\n const newPrefix = prefix ? `${prefix}-${key}` : key;\n processColorGroup(value, newPrefix);\n }\n }\n }\n };\n\n // Process colors - handle both nested and flat structures\n if (colorsData) {\n if (colorsData.colors) {\n processColorGroup(colorsData.colors);\n } else {\n // Direct color structure\n processColorGroup(colorsData);\n }\n }\n\n return {\n variables,\n colorMap,\n utilities\n };\n }\n\n /**\n * Process semantic tokens that reference other tokens\n * @param {Object} semanticData - Semantic tokens data\n * @param {Object} colorMap - Map of color names to CSS variables\n * @returns {Object} Semantic CSS variables and token utilities\n */\n processSemanticTokens(semanticData, colorMap) {\n const semanticVariables = {};\n const tokens = {\n backgroundColor: {},\n textColor: {},\n borderColor: {}\n };\n\n // Format token name (similar to current plugin)\n const formatTokenName = (name) => {\n return name.replace(/ /g, '').replace(/\\./g, '-').toLowerCase();\n };\n\n // Extract token reference from string like \"{colors.primary.500}\"\n const extractReference = (refString) => {\n // Handle non-string values\n if (typeof refString !== 'string') return null;\n \n const match = refString.match(/^\\{(.+)\\}$/);\n if (!match) return null;\n \n // Split the reference path and remove the first part if it's \"colors\"\n const parts = match[1].split('.');\n if (parts[0] === 'colors' && parts.length > 1) {\n // Check if second part is also \"colors\" (nested structure)\n if (parts[1] === 'colors' && parts.length > 2) {\n return parts.slice(2).join('-');\n }\n return parts.slice(1).join('-');\n }\n return parts.join('-');\n };\n\n // Process semantic category (bg, text, border)\n const processCategory = (category, outputCategory) => {\n if (!semanticData[category]) return;\n\n for (const [key, value] of Object.entries(semanticData[category])) {\n if (key === 'disabled') {\n // Handle disabled state specially\n const reference = extractReference(value.$value);\n if (reference) {\n const referencedVar = colorMap[reference];\n if (referencedVar) {\n const varName = `--${category}-disabled`;\n semanticVariables[varName] = `var(${referencedVar})`;\n tokens[outputCategory]['disabled'] = `var(${varName})`;\n }\n }\n continue;\n }\n\n // Process nested structure (e.g., neutral -> low -> default)\n for (const [mainKey, mainValue] of Object.entries(value)) {\n for (const [stateKey, stateValue] of Object.entries(mainValue)) {\n let tokenKey = formatTokenName(`${key}-${mainKey}-${stateKey}`);\n \n // Remove '-default' suffix for cleaner class names\n if (tokenKey.endsWith('-default')) {\n tokenKey = tokenKey.slice(0, -8);\n }\n\n const varName = `--${category}-${tokenKey}`;\n \n // Check if it's a reference\n const reference = extractReference(stateValue.$value);\n if (reference) {\n // Look up the referenced color variable\n const referencedVar = colorMap[reference];\n if (referencedVar) {\n semanticVariables[varName] = `var(${referencedVar})`;\n tokens[outputCategory][tokenKey] = `var(${varName})`;\n }\n } else if (stateValue.$value) {\n // Direct hex value - convert to HSL\n const hslValue = this.hexToHsl(stateValue.$value);\n semanticVariables[varName] = hslValue;\n tokens[outputCategory][tokenKey] = `hsl(var(${varName}))`;\n }\n }\n }\n }\n };\n\n // Process semantic categories\n processCategory('bg', 'backgroundColor');\n processCategory('text', 'textColor');\n processCategory('border', 'borderColor');\n\n // Process layer tokens\n if (semanticData.layer) {\n for (const [layerKey, layerValue] of Object.entries(semanticData.layer)) {\n const varName = `--layer-${layerKey}`;\n const reference = extractReference(layerValue.$value);\n \n if (reference) {\n // Format the reference to match semantic token naming\n let formattedRef = reference.replace(/\\./g, '-').toLowerCase();\n \n // Remove -default suffix if present\n if (formattedRef.endsWith('-default')) {\n formattedRef = formattedRef.slice(0, -8);\n }\n \n // Check if it's a semantic reference (e.g., bg-neutral-subtle)\n if (formattedRef.startsWith('bg-') || formattedRef.startsWith('text-') || formattedRef.startsWith('border-')) {\n // It's referencing a semantic token\n const semanticVar = `--${formattedRef}`;\n semanticVariables[varName] = `var(${semanticVar})`;\n tokens.backgroundColor[`layer-${layerKey}`] = `var(${varName})`;\n } else {\n // It's referencing a color token\n const referencedVar = colorMap[formattedRef];\n if (referencedVar) {\n semanticVariables[varName] = `var(${referencedVar})`;\n tokens.backgroundColor[`layer-${layerKey}`] = `var(${varName})`;\n }\n }\n } else if (layerValue.$value) {\n // Direct value\n const hslValue = this.hexToHsl(layerValue.$value);\n semanticVariables[varName] = hslValue;\n tokens.backgroundColor[`layer-${layerKey}`] = `hsl(var(${varName}))`;\n }\n }\n }\n\n // Process overlay tokens\n if (semanticData.overlay) {\n for (const [overlayKey, overlayValue] of Object.entries(semanticData.overlay)) {\n const varName = `--overlay-${overlayKey}`;\n \n if (overlayValue.$value) {\n // Overlay values are hex colors with alpha, keep them as-is\n semanticVariables[varName] = overlayValue.$value;\n tokens.backgroundColor[`overlay-${overlayKey}`] = `var(${varName})`;\n }\n }\n }\n\n // Process icon tokens (map to text and fill colors)\n if (semanticData.icon) {\n // Ensure fill property exists\n if (!tokens.fill) {\n tokens.fill = {};\n }\n \n for (const [iconKey, iconValue] of Object.entries(semanticData.icon)) {\n if (iconKey === 'disabled') {\n const reference = extractReference(iconValue.$value);\n if (reference) {\n const referencedVar = colorMap[reference];\n if (referencedVar) {\n const varName = `--icon-disabled`;\n semanticVariables[varName] = `var(${referencedVar})`;\n tokens.textColor['icon-disabled'] = `var(${varName})`;\n tokens.fill['icon-disabled'] = `var(${varName})`;\n }\n }\n continue;\n }\n\n for (const [mainKey, mainValue] of Object.entries(iconValue)) {\n for (const [stateKey, stateValue] of Object.entries(mainValue)) {\n let tokenKey = formatTokenName(`icon-${iconKey}-${mainKey}-${stateKey}`);\n if (tokenKey.endsWith('-default')) {\n tokenKey = tokenKey.slice(0, -8);\n }\n\n const varName = `--${tokenKey}`;\n const reference = extractReference(stateValue.$value);\n \n if (reference) {\n const referencedVar = colorMap[reference];\n if (referencedVar) {\n semanticVariables[varName] = `var(${referencedVar})`;\n tokens.textColor[tokenKey] = `var(${varName})`;\n tokens.fill[tokenKey] = `var(${varName})`;\n }\n }\n }\n }\n }\n }\n\n return { semanticVariables, tokens };\n }\n\n /**\n * Fetch CSS from URL and parse font-face rules\n * @param {string} url - Font CSS URL\n * @returns {Promise<string>} Font face CSS\n */\n async fetchFontCss(url) {\n return new Promise((resolve, reject) => {\n https.get(url, (response) => {\n let data = '';\n \n if (response.statusCode !== 200) {\n reject(new Error(`Failed to fetch font CSS: ${response.statusCode}`));\n return;\n }\n\n response.on('data', (chunk) => {\n data += chunk;\n });\n\n response.on('end', () => {\n resolve(data);\n });\n\n response.on('error', (error) => {\n reject(error);\n });\n }).on('error', (error) => {\n reject(error);\n });\n });\n }\n\n /**\n * Parse font-face CSS into structured objects\n * @param {string} css - CSS text containing @font-face rules\n * @returns {Array} Array of font-face objects\n */\n parseFontFaces(css) {\n const fontFaceRegex = /@font-face\\s*{([^}]+)}/g;\n const fontFaces = [];\n let match;\n\n while ((match = fontFaceRegex.exec(css)) !== null) {\n const fontProperties = match[1].trim().split(';').filter(Boolean);\n const fontObj = {};\n\n fontProperties.forEach(prop => {\n const colonIndex = prop.indexOf(':');\n if (colonIndex !== -1) {\n const key = prop.slice(0, colonIndex).trim();\n const value = prop.slice(colonIndex + 1).trim();\n \n // Clean up quotes from font-family\n if (key === 'font-family') {\n fontObj[key] = value.replace(/[\"']/g, '');\n } else {\n fontObj[key] = value;\n }\n }\n });\n\n // Ensure src URLs are properly quoted\n if (fontObj['src']) {\n fontObj['src'] = fontObj['src']\n .replace(/url\\([\"']?/, 'url(\\'')\n .replace(/[\"']?\\)/, '\\')');\n }\n\n fontFaces.push(fontObj);\n }\n\n return fontFaces;\n }\n\n /**\n * Process fonts data\n * @param {Object} fontData - Font URLs object\n * @returns {Promise<Array>} Array of font-face objects\n */\n async processFonts(fontData) {\n const fontFaces = [];\n\n if (!fontData || typeof fontData !== 'object') {\n return fontFaces;\n }\n\n // Process each font URL (font, font2, etc.)\n const fontFields = Object.keys(fontData).filter(key => key.startsWith('font'));\n \n for (const field of fontFields) {\n const url = fontData[field];\n if (typeof url === 'string' && url.startsWith('http')) {\n try {\n const css = await this.fetchFontCss(url);\n const parsedFonts = this.parseFontFaces(css);\n \n if (parsedFonts.length > 0) {\n fontFaces.push(...parsedFonts);\n }\n } catch (error) {\n console.warn(`Failed to process font ${field}:`, error.message);\n }\n }\n }\n\n return fontFaces;\n }\n\n /**\n * Process font family tokens\n * @param {Object} globalTokens - Global tokens data containing font families\n * @returns {Object} Font family utilities\n */\n processFontFamilies(globalTokens) {\n const fontFamilyUtilities = {};\n \n if (!globalTokens || !globalTokens.font || !globalTokens.font.family) {\n return fontFamilyUtilities;\n }\n\n const fontFamilies = globalTokens.font.family;\n \n // Process each font family (primary, secondary, etc.)\n for (const [key, value] of Object.entries(fontFamilies)) {\n if (value && value.$value) {\n // Format the key (e.g., primary -> primary)\n const fontKey = key.toLowerCase();\n \n // Extract font family value\n let fontFamilyValue = value.$value;\n \n // If it's a reference, extract it\n if (typeof fontFamilyValue === 'string' && fontFamilyValue.startsWith('{') && fontFamilyValue.endsWith('}')) {\n // This is a reference, but for font families we usually have direct values\n fontFamilyValue = fontFamilyValue.slice(1, -1);\n }\n \n // Store the font family utility\n // Store the font family utility - ensure proper quoting for multi-word fonts\n // For Tailwind, we need to format font families properly\n \n // Capitalize the first letter of each word in font names for proper rendering\n const capitalizeFontName = (name) => {\n return name.split(' ').map(word => \n word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n ).join(' ');\n };\n \n // Check if it's already a font stack or needs quoting\n if (fontFamilyValue.includes(',')) {\n // It's already a font stack, use as is\n fontFamilyUtilities[fontKey] = fontFamilyValue;\n } else {\n // Capitalize the font name\n const capitalizedFont = capitalizeFontName(fontFamilyValue);\n \n if (capitalizedFont.includes(' ') && !capitalizedFont.startsWith('\"') && !capitalizedFont.startsWith(\"'\")) {\n // Multi-word font needs quotes, add generic fallback\n fontFamilyUtilities[fontKey] = `\"${capitalizedFont}\", sans-serif`;\n } else {\n // Single word font, add generic fallback\n fontFamilyUtilities[fontKey] = `${capitalizedFont}, sans-serif`;\n }\n }\n }\n }\n \n return fontFamilyUtilities;\n }\n\n /**\n * Process animations data\n * @param {Object} animationData - Animation definitions\n * @returns {Object} Keyframes and animation utilities\n */\n processAnimations(animationData) {\n const keyframes = {};\n const animations = {};\n\n if (!animationData || typeof animationData !== 'object') {\n return { keyframes, animations };\n }\n\n // Process each animation\n for (const [name, definition] of Object.entries(animationData)) {\n if (definition && typeof definition === 'object') {\n // Generate keyframe name\n const keyframeName = `${name}`;\n \n // Process keyframe steps\n if (definition.keyframes) {\n const keyframeSteps = {};\n \n for (const [step, props] of Object.entries(definition.keyframes)) {\n if (props && typeof props === 'object') {\n keyframeSteps[step] = props;\n }\n }\n \n keyframes[keyframeName] = keyframeSteps;\n }\n\n // Create animation utility\n const animationValue = [\n keyframeName,\n definition.duration || '1s',\n definition.easing || 'ease',\n definition.delay || '0s',\n definition.iterations || '1',\n definition.direction || 'normal',\n definition.fillMode || 'none'\n ].join(' ');\n\n animations[name] = animationValue;\n }\n }\n\n return { keyframes, animations };\n }\n\n /**\n * Generate safelist classes for Tailwind\n * @param {Object} tokens - All processed tokens\n * @returns {Array} Safelist patterns\n */\n generateSafelistClasses(tokens) {\n const safelist = [];\n\n // Add color utilities with common variants\n if (tokens.colorMap) {\n const variants = ['hover:', 'focus:', 'active:', 'disabled:', 'dark:'];\n const utilities = ['bg-', 'text-', 'border-'];\n\n for (const colorName of Object.keys(tokens.colorMap)) {\n // Add base utilities\n utilities.forEach(utility => {\n safelist.push(`${utility}${colorName}`);\n \n // Add variants\n variants.forEach(variant => {\n safelist.push(`${variant}${utility}${colorName}`);\n });\n });\n }\n }\n\n // Add animation classes\n if (tokens.animations) {\n for (const animationName of Object.keys(tokens.animations)) {\n safelist.push(`animate-${animationName}`);\n }\n }\n\n return safelist;\n }\n\n /**\n * Extract unique classes from components configuration\n * @param {Object} componentsConfig - Components configuration object\n * @returns {Array} Array of unique class names\n */\n extractClassesFromComponentsConfig(componentsConfig) {\n const classSet = new Set();\n\n // Helper function to extract classes from a string\n const extractClasses = (classString) => {\n if (typeof classString === 'string') {\n // Split by spaces and filter out empty strings\n const classes = classString.split(/\\s+/).filter(c => c.length > 0);\n classes.forEach(cls => {\n // Skip variant selectors like [&>svg]:absolute\n classSet.add(cls);\n });\n }\n };\n\n // Recursive function to traverse the config object\n const traverse = (obj) => {\n if (!obj || typeof obj !== 'object') return;\n\n for (const key in obj) {\n const value = obj[key];\n \n if (typeof value === 'string') {\n extractClasses(value);\n } else if (typeof value === 'object') {\n traverse(value);\n }\n }\n };\n\n // Process the components config\n if (componentsConfig) {\n traverse(componentsConfig);\n }\n\n // Convert set to array and sort\n return Array.from(classSet).sort();\n }\n\n /**\n * Process custom CSS into a format compatible with Tailwind's addBase\n * @param {string} css - Raw CSS string\n * @returns {Object} CSS rules as object for Tailwind addBase\n */\n processCustomCss(css) {\n if (!css || typeof css !== 'string') {\n return {};\n }\n\n // Simply return the raw CSS as a string that can be added via addBase\n return { raw: css };\n }\n\n /**\n * Main orchestration method to process all token data\n * @param {Object} data - Complete token data from API\n * @returns {Promise<Object>} Processed token data\n */\n async process(data) {\n try {\n const result = {\n variables: {},\n semanticVariables: {},\n semanticDarkVariables: {},\n utilities: {},\n fontFaces: [],\n keyframes: {},\n animations: {},\n safelist: [],\n metadata: {},\n custom: data.customCss ? this.processCustomCss(data.customCss) : {}\n };\n\n // Handle different token formats (new vs legacy)\n let colorData = null;\n \n // Check if we have tokens in the new format\n if (data.tokens && typeof data.tokens === 'object') {\n // New format from processed-tokens endpoint\n const tokens = data.tokens;\n \n // Extract color data from various possible locations\n colorData = tokens['Global Colors/Default'] || \n tokens['Global Colors'] || \n tokens['colors'] ||\n tokens;\n } else if (data.colors) {\n // Legacy format or direct colors data\n colorData = data.colors;\n }\n\n // Process colors\n if (colorData) {\n const colorResult = this.processColors(colorData);\n result.variables = { ...result.variables, ...colorResult.variables };\n result.utilities = { ...result.utilities, ...colorResult.utilities };\n result.colorMap = colorResult.colorMap || {};\n } else {\n result.colorMap = {};\n }\n\n // Process semantic tokens (light mode)\n if (data.semantic && result.colorMap) {\n const semanticResult = this.processSemanticTokens(data.semantic, result.colorMap);\n result.semanticVariables = semanticResult.semanticVariables;\n // Merge tokens into utilities\n if (semanticResult.tokens) {\n result.tokens = semanticResult.tokens;\n // Replace color utilities with semantic token utilities\n result.utilities = semanticResult.tokens;\n }\n }\n\n // Process semantic tokens (dark mode)\n if (data.semanticDark && result.colorMap) {\n const semanticDarkResult = this.processSemanticTokens(data.semanticDark, result.colorMap);\n result.semanticDarkVariables = semanticDarkResult.semanticVariables;\n }\n\n // Process fonts\n if (data.fonts) {\n result.fontFaces = await this.processFonts(data.fonts);\n }\n\n // Process font families from global tokens\n if (data.globalTokens) {\n result.fontFamilies = this.processFontFamilies(data.globalTokens);\n \n // Add font family utilities\n if (result.fontFamilies) {\n if (!result.utilities.fontFamily) {\n result.utilities.fontFamily = {};\n }\n Object.assign(result.utilities.fontFamily, result.fontFamilies);\n }\n }\n\n // Process animations\n if (data.animations) {\n const animationResult = this.processAnimations(data.animations);\n result.keyframes = animationResult.keyframes;\n result.animations = animationResult.animations;\n }\n\n // Generate safelist\n result.safelist = this.generateSafelistClasses(result);\n\n // Add metadata\n result.metadata = {\n timestamp: new Date().toISOString(),\n version: data.version || '2.0.0',\n ffId: data.ffId\n };\n\n return result;\n } catch (error) {\n console.error('Error processing tokens:', error);\n throw error;\n }\n }\n}\n\nmodule.exports = TokenProcessor;"],
|
|
5
|
+
"mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,KAAMC,EAAN,cAAuB,KAAM,CAC3B,YAAYC,EAASC,EAAYC,EAAK,CACpC,MAAMF,CAAO,EACb,KAAK,KAAO,WACZ,KAAK,WAAaC,EAClB,KAAK,IAAMC,EACX,KAAK,KAAO,OAAOD,CAAU,EAC/B,CACF,EAEME,EAAN,cAAyB,KAAM,CAC7B,YAAYH,EAASI,EAAW,CAC9B,MAAMJ,CAAO,EACb,KAAK,KAAO,aACZ,KAAK,UAAYI,EACjB,KAAK,KAAO,SAASA,EAAU,YAAY,CAAC,EAC9C,CACF,EAEMC,EAAN,cAA0B,KAAM,CAC9B,YAAYL,EAASM,EAAO,CAC1B,MAAMN,CAAO,EACb,KAAK,KAAO,cACZ,KAAK,MAAQM,EACb,KAAK,KAAO,UAAUA,EAAM,YAAY,CAAC,EAC3C,CACF,EAEMC,EAAN,cAA8B,KAAM,CAClC,YAAYP,EAASQ,EAAO,CAC1B,MAAMR,CAAO,EACb,KAAK,KAAO,kBACZ,KAAK,MAAQQ,EACb,KAAK,KAAO,kBACd,CACF,EAEAV,EAAO,QAAU,CACf,SAAAC,EACA,WAAAI,EACA,YAAAE,EACA,gBAAAE,CACF,IC1CA,IAAME,EAAQ,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EAAiB,KAAK,sBAAsB7C,EAAK,SAAU0C,EAAO,QAAQ,EAChFA,EAAO,kBAAoBG,EAAe,kBAEtCA,EAAe,SACjBH,EAAO,OAASG,EAAe,OAE/BH,EAAO,UAAYG,EAAe,OAEtC,CAGA,GAAI7C,EAAK,cAAgB0C,EAAO,SAAU,CACxC,IAAMI,EAAqB,KAAK,sBAAsB9C,EAAK,aAAc0C,EAAO,QAAQ,EACxFA,EAAO,sBAAwBI,EAAmB,iBACpD,CAqBA,GAlBI9C,EAAK,QACP0C,EAAO,UAAY,MAAM,KAAK,aAAa1C,EAAK,KAAK,GAInDA,EAAK,eACP0C,EAAO,aAAe,KAAK,oBAAoB1C,EAAK,YAAY,EAG5D0C,EAAO,eACJA,EAAO,UAAU,aACpBA,EAAO,UAAU,WAAa,CAAC,GAEjC,OAAO,OAAOA,EAAO,UAAU,WAAYA,EAAO,YAAY,IAK9D1C,EAAK,WAAY,CACnB,IAAM+C,EAAkB,KAAK,kBAAkB/C,EAAK,UAAU,EAC9D0C,EAAO,UAAYK,EAAgB,UACnCL,EAAO,WAAaK,EAAgB,UACtC,CAGA,OAAAL,EAAO,SAAW,KAAK,wBAAwBA,CAAM,EAGrDA,EAAO,SAAW,CAChB,UAAW,IAAI,KAAK,EAAE,YAAY,EAClC,QAAS1C,EAAK,SAAW,QACzB,KAAMA,EAAK,IACb,EAEO0C,CACT,OAASvF,EAAO,CACd,cAAQ,MAAM,2BAA4BA,CAAK,EACzCA,CACR,CACF,CACF,EAEA,OAAO,QAAUT",
|
|
6
|
+
"names": ["require_errors", "__commonJSMin", "exports", "module", "APIError", "message", "statusCode", "url", "CacheError", "operation", "ConfigError", "field", "ProcessingError", "token", "Color", "https", "ProcessingError", "TokenProcessor", "hex", "color", "hsl", "h", "s", "l", "alpha", "roundedAlpha", "error", "colorsData", "variables", "colorMap", "utilities", "processColorGroup", "obj", "prefix", "key", "value", "colorName", "varName", "hslValue", "newPrefix", "semanticData", "semanticVariables", "tokens", "formatTokenName", "name", "extractReference", "refString", "match", "parts", "processCategory", "category", "outputCategory", "reference", "referencedVar", "mainKey", "mainValue", "stateKey", "stateValue", "tokenKey", "layerKey", "layerValue", "formattedRef", "semanticVar", "overlayKey", "overlayValue", "iconKey", "iconValue", "url", "resolve", "reject", "response", "data", "chunk", "css", "fontFaceRegex", "fontFaces", "fontProperties", "fontObj", "prop", "colonIndex", "fontData", "fontFields", "field", "parsedFonts", "globalTokens", "fontFamilyUtilities", "fontFamilies", "fontKey", "fontFamilyValue", "capitalizeFontName", "word", "capitalizedFont", "animationData", "keyframes", "animations", "definition", "keyframeName", "keyframeSteps", "step", "props", "animationValue", "safelist", "variants", "utility", "variant", "animationName", "componentsConfig", "classSet", "extractClasses", "classString", "c", "cls", "traverse", "result", "colorData", "colorResult", "semanticResult", "semanticDarkResult", "animationResult"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combines class names with tailwind-merge
|
|
3
|
+
* @param inputs - Class names to combine
|
|
4
|
+
* @returns Merged class string
|
|
5
|
+
*/
|
|
6
|
+
export function cn(...inputs: any[]): string;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* React hook for media query
|
|
10
|
+
* @param query - Media query string
|
|
11
|
+
* @returns Boolean indicating if query matches
|
|
12
|
+
*/
|
|
13
|
+
export function useMediaQuery(query: string): boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* React hook for responsive breakpoints
|
|
17
|
+
* @returns Object with breakpoint states and active breakpoint
|
|
18
|
+
*/
|
|
19
|
+
export function useBreakpoints(): {
|
|
20
|
+
isXs: boolean;
|
|
21
|
+
isSm: boolean;
|
|
22
|
+
isMd: boolean;
|
|
23
|
+
isLg: boolean;
|
|
24
|
+
active: 'xs' | 'sm' | 'md' | 'lg';
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combines class names with tailwind-merge
|
|
3
|
+
* @param inputs - Class names to combine
|
|
4
|
+
* @returns Merged class string
|
|
5
|
+
*/
|
|
6
|
+
export function cn(...inputs: any[]): string;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Vue composition API hook for media query
|
|
10
|
+
* @param query - Media query string
|
|
11
|
+
* @returns Ref<boolean> indicating if query matches
|
|
12
|
+
*/
|
|
13
|
+
export function useMediaQuery(query: string): import('vue').Ref<boolean>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Vue composition API hook for responsive breakpoints
|
|
17
|
+
* @returns Object with breakpoint states and active breakpoint
|
|
18
|
+
*/
|
|
19
|
+
export function useBreakpoints(): {
|
|
20
|
+
isXs: import('vue').Ref<boolean>;
|
|
21
|
+
isSm: import('vue').Ref<boolean>;
|
|
22
|
+
isMd: import('vue').Ref<boolean>;
|
|
23
|
+
isLg: import('vue').Ref<boolean>;
|
|
24
|
+
active: import('vue').ComputedRef<'xs' | 'sm' | 'md' | 'lg'>;
|
|
25
|
+
};
|
package/dist/next.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NextConfig } from 'next';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wraps Next.js configuration to inject FrontFriend globals
|
|
5
|
+
* @param config - Next.js configuration object
|
|
6
|
+
* @returns Modified Next.js configuration
|
|
7
|
+
*/
|
|
8
|
+
export default function withFrontFriend(config?: NextConfig): NextConfig;
|
package/dist/next.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var f=(
|
|
1
|
+
var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var C=f((J,y)=>{var N="https://app.frontfriend.dev",I="https://tokens-studio-donux.up.railway.app/api",v=".cache/frontfriend",k={JS:["tokens.js","variables.js","semanticVariables.js","semanticDarkVariables.js","cls.js","custom.js"],JSON:["fonts.json","icons.json","components-config.json","version.json","metadata.json"]},O={FF_ID:"FF_ID",FF_API_URL:"FF_API_URL"};y.exports={DEFAULT_API_URL:N,LEGACY_API_URL:I,CACHE_DIR_NAME:v,CACHE_TTL_DAYS:7,CACHE_TTL_MS:6048e5,CACHE_FILES:k,ENV_VARS:O}});var A=f((R,j)=>{var d=class extends Error{constructor(e,t,s){super(e),this.name="APIError",this.statusCode=t,this.url=s,this.code=`API_${t}`}},p=class extends Error{constructor(e,t){super(e),this.name="CacheError",this.operation=t,this.code=`CACHE_${t.toUpperCase()}`}},m=class extends Error{constructor(e,t){super(e),this.name="ConfigError",this.field=t,this.code=`CONFIG_${t.toUpperCase()}`}},_=class extends Error{constructor(e,t){super(e),this.name="ProcessingError",this.token=t,this.code="PROCESSING_ERROR"}};j.exports={APIError:d,CacheError:p,ConfigError:m,ProcessingError:_}});var E=f(($,w)=>{var n=require("fs"),h=require("path"),{CACHE_DIR_NAME:b,CACHE_TTL_MS:L,CACHE_FILES:x}=C(),{CacheError:D}=A(),F=class{constructor(e=process.cwd()){this.appRoot=e,this.cacheDir=h.join(e,"node_modules",b),this.metadataFile=h.join(this.cacheDir,"metadata.json"),this.maxAge=L}getCacheDir(){return this.cacheDir}exists(){return n.existsSync(this.cacheDir)}isValid(){if(!this.exists())return!1;try{if(!n.existsSync(this.metadataFile))return!1;let e=JSON.parse(n.readFileSync(this.metadataFile,"utf-8")),t=new Date(e.timestamp).getTime();return Date.now()-t<this.maxAge}catch{return!1}}load(){if(!this.exists())return null;try{let e={};for(let t of x.JS){let s=h.join(this.cacheDir,t);if(n.existsSync(s)){let o=t.replace(".js","");try{let a=n.readFileSync(s,"utf-8"),l={},i={exports:l};new Function("module","exports",a)(i,l),e[o]=i.exports}catch{}}}for(let t of x.JSON){let s=h.join(this.cacheDir,t);if(n.existsSync(s)){let o=t.replace(".json",""),a=n.readFileSync(s,"utf-8");e[o]=JSON.parse(a)}}return e["components-config"]&&(e.componentsConfig=e["components-config"],delete e["components-config"]),e}catch(e){throw new D(`Failed to load cache: ${e.message}`,"read")}}save(e){var t,s;try{n.mkdirSync(this.cacheDir,{recursive:!0});let o={timestamp:new Date().toISOString(),version:((t=e.metadata)==null?void 0:t.version)||"2.0.0",ffId:(s=e.metadata)==null?void 0:s.ffId};n.writeFileSync(this.metadataFile,JSON.stringify(o,null,2));let a=["tokens","variables","semanticVariables","semanticDarkVariables","cls","custom"];for(let i of a)if(e[i]!==void 0){let u=h.join(this.cacheDir,`${i}.js`),c=e[i];if(c==null||typeof c=="object"&&Object.keys(c).length===0||Array.isArray(c)&&c.length===0){let g=`module.exports = ${Array.isArray(c)?"[]":"{}"};`;n.writeFileSync(u,g)}else{let S=`module.exports = ${JSON.stringify(c,null,2)};`;n.writeFileSync(u,S)}}let l={fonts:e.fonts,icons:e.icons||e.iconSet,"components-config":e.componentsConfig,version:e.version};for(let[i,u]of Object.entries(l))if(u!==void 0){let c=h.join(this.cacheDir,`${i}.json`);n.writeFileSync(c,JSON.stringify(u,null,2))}}catch(o){throw new D(`Failed to save cache: ${o.message}`,"write")}}clear(){this.exists()&&n.rmSync(this.cacheDir,{recursive:!0,force:!0})}};w.exports=F});var T=E();function P(r={}){return{...r,webpack:(e,t)=>{typeof r.webpack=="function"&&(e=r.webpack(e,t));let s=new T(process.cwd());if(!s.exists())return console.warn('[FrontFriend Next.js] No cache found. Please run "npx frontfriend init" first.'),e;let o=s.load();if(!o)return console.error("[FrontFriend Next.js] Failed to load cache."),e;let{webpack:a}=t,l=a.DefinePlugin,i={__FF_CONFIG__:JSON.stringify(o.componentsConfig||null),__FF_ICONS__:JSON.stringify(o.icons||null)};return e.plugins=e.plugins||[],e.plugins.push(new l(i)),t.dev&&!t.isServer&&console.log("[FrontFriend Next.js] Injected configuration and icons into client build"),e}}}module.exports=P;
|
|
2
2
|
//# sourceMappingURL=next.js.map
|
package/dist/next.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/core/constants.js", "../lib/core/errors.js", "../lib/core/cache-manager.js", "../next.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Configuration constants for FrontFriend Tailwind v2\n */\n\n// API Configuration\nconst DEFAULT_API_URL = 'https://tokens-studio-donux.up.railway.app/api';\n\n// Cache Configuration\nconst CACHE_DIR_NAME = '.cache/frontfriend';\nconst CACHE_TTL_DAYS = 7;\nconst CACHE_TTL_MS = CACHE_TTL_DAYS * 24 * 60 * 60 * 1000;\n\n// File names\nconst CACHE_FILES = {\n JS: [\n 'tokens.js',\n 'variables.js',\n 'semanticVariables.js',\n 'semanticDarkVariables.js',\n 'cls.js',\n 'custom.js'\n ],\n JSON: [\n 'fonts.json',\n 'icons.json',\n 'components-config.json',\n 'version.json',\n 'metadata.json'\n ]\n};\n\n// Environment variables\nconst ENV_VARS = {\n FF_ID: 'FF_ID',\n FF_API_URL: 'FF_API_URL'\n};\n\nmodule.exports = {\n DEFAULT_API_URL,\n CACHE_DIR_NAME,\n CACHE_TTL_DAYS,\n CACHE_TTL_MS,\n CACHE_FILES,\n ENV_VARS\n};", "class APIError extends Error {\n constructor(message, statusCode, url) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.url = url;\n this.code = `API_${statusCode}`;\n }\n}\n\nclass CacheError extends Error {\n constructor(message, operation) {\n super(message);\n this.name = 'CacheError';\n this.operation = operation;\n this.code = `CACHE_${operation.toUpperCase()}`;\n }\n}\n\nclass ConfigError extends Error {\n constructor(message, field) {\n super(message);\n this.name = 'ConfigError';\n this.field = field;\n this.code = `CONFIG_${field.toUpperCase()}`;\n }\n}\n\nclass ProcessingError extends Error {\n constructor(message, token) {\n super(message);\n this.name = 'ProcessingError';\n this.token = token;\n this.code = 'PROCESSING_ERROR';\n }\n}\n\nmodule.exports = {\n APIError,\n CacheError,\n ConfigError,\n ProcessingError\n};", "const fs = require('fs');\nconst path = require('path');\nconst { CACHE_DIR_NAME, CACHE_TTL_MS, CACHE_FILES } = require('./constants');\nconst { CacheError } = require('./errors');\n\nclass CacheManager {\n constructor(appRoot = process.cwd()) {\n this.appRoot = appRoot;\n this.cacheDir = path.join(appRoot, 'node_modules', CACHE_DIR_NAME);\n this.metadataFile = path.join(this.cacheDir, 'metadata.json');\n this.maxAge = CACHE_TTL_MS;\n }\n\n /**\n * Get the cache directory path\n * @returns {string} Cache directory path\n */\n getCacheDir() {\n return this.cacheDir;\n }\n\n /**\n * Check if cache directory exists\n * @returns {boolean} True if cache exists\n */\n exists() {\n return fs.existsSync(this.cacheDir);\n }\n\n /**\n * Check if cache is valid (exists and not expired)\n * @returns {boolean} True if cache is valid\n */\n isValid() {\n if (!this.exists()) {\n return false;\n }\n\n try {\n if (!fs.existsSync(this.metadataFile)) {\n return false;\n }\n\n const metadata = JSON.parse(fs.readFileSync(this.metadataFile, 'utf-8'));\n const timestamp = new Date(metadata.timestamp).getTime();\n const now = Date.now();\n \n return (now - timestamp) < this.maxAge;\n } catch (error) {\n return false;\n }\n }\n\n /**\n * Load all cached data\n * @returns {Object|null} Cached data object or null if not found\n */\n load() {\n if (!this.exists()) {\n return null;\n }\n\n try {\n const data = {};\n \n // Load all .js files\n for (const file of CACHE_FILES.JS) {\n const filePath = path.join(this.cacheDir, file);\n if (fs.existsSync(filePath)) {\n // Remove .js extension for key\n const key = file.replace('.js', '');\n try {\n // Use a more secure approach - parse the exported data\n const content = fs.readFileSync(filePath, 'utf-8');\n // Create a safe evaluation context\n const moduleExports = {};\n const fakeModule = { exports: moduleExports };\n \n // Use Function constructor to evaluate in isolated scope\n const evalFunc = new Function('module', 'exports', content);\n evalFunc(fakeModule, moduleExports);\n \n data[key] = fakeModule.exports;\n } catch (e) {\n // Skip files that can't be parsed\n }\n }\n }\n\n // Load all .json files\n for (const file of CACHE_FILES.JSON) {\n const filePath = path.join(this.cacheDir, file);\n if (fs.existsSync(filePath)) {\n const key = file.replace('.json', '');\n const content = fs.readFileSync(filePath, 'utf-8');\n data[key] = JSON.parse(content);\n }\n }\n\n // Rename components-config to componentsConfig for consistency\n if (data['components-config']) {\n data.componentsConfig = data['components-config'];\n delete data['components-config'];\n }\n\n return data;\n } catch (error) {\n throw new CacheError(`Failed to load cache: ${error.message}`, 'read');\n }\n }\n\n /**\n * Save data to cache\n * @param {Object} data - Data object to save\n * @throws {Error} If save operation fails\n */\n save(data) {\n try {\n // Create cache directory\n fs.mkdirSync(this.cacheDir, { recursive: true });\n\n // Save metadata first\n const metadata = {\n timestamp: new Date().toISOString(),\n version: data.metadata?.version || '2.0.0',\n ffId: data.metadata?.ffId\n };\n fs.writeFileSync(\n this.metadataFile,\n JSON.stringify(metadata, null, 2)\n );\n\n // Save .js files\n const jsFiles = [\n 'tokens',\n 'variables',\n 'semanticVariables',\n 'semanticDarkVariables',\n 'cls',\n 'custom'\n ];\n\n for (const key of jsFiles) {\n if (data[key] !== undefined) {\n const filePath = path.join(this.cacheDir, `${key}.js`);\n const content = `module.exports = ${JSON.stringify(
|
|
5
|
-
"mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAKA,IAAMC,EAAkB,
|
|
6
|
-
"names": ["require_constants", "__commonJSMin", "exports", "module", "DEFAULT_API_URL", "CACHE_DIR_NAME", "CACHE_FILES", "ENV_VARS", "require_errors", "__commonJSMin", "exports", "module", "APIError", "message", "statusCode", "url", "CacheError", "operation", "ConfigError", "field", "ProcessingError", "token", "require_cache_manager", "__commonJSMin", "exports", "module", "fs", "path", "CACHE_DIR_NAME", "CACHE_TTL_MS", "CACHE_FILES", "CacheError", "CacheManager", "appRoot", "metadata", "timestamp", "data", "file", "filePath", "key", "content", "moduleExports", "fakeModule", "error", "_a", "_b", "jsFiles", "
|
|
4
|
+
"sourcesContent": ["/**\n * Configuration constants for FrontFriend Tailwind v2\n */\n\n// API Configuration\nconst DEFAULT_API_URL = 'https://app.frontfriend.dev';\nconst LEGACY_API_URL = 'https://tokens-studio-donux.up.railway.app/api';\n\n// Cache Configuration\nconst CACHE_DIR_NAME = '.cache/frontfriend';\nconst CACHE_TTL_DAYS = 7;\nconst CACHE_TTL_MS = CACHE_TTL_DAYS * 24 * 60 * 60 * 1000;\n\n// File names\nconst CACHE_FILES = {\n JS: [\n 'tokens.js',\n 'variables.js',\n 'semanticVariables.js',\n 'semanticDarkVariables.js',\n 'cls.js',\n 'custom.js'\n ],\n JSON: [\n 'fonts.json',\n 'icons.json',\n 'components-config.json',\n 'version.json',\n 'metadata.json'\n ]\n};\n\n// Environment variables\nconst ENV_VARS = {\n FF_ID: 'FF_ID',\n FF_API_URL: 'FF_API_URL'\n};\n\nmodule.exports = {\n DEFAULT_API_URL,\n LEGACY_API_URL,\n CACHE_DIR_NAME,\n CACHE_TTL_DAYS,\n CACHE_TTL_MS,\n CACHE_FILES,\n ENV_VARS\n};", "class APIError extends Error {\n constructor(message, statusCode, url) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.url = url;\n this.code = `API_${statusCode}`;\n }\n}\n\nclass CacheError extends Error {\n constructor(message, operation) {\n super(message);\n this.name = 'CacheError';\n this.operation = operation;\n this.code = `CACHE_${operation.toUpperCase()}`;\n }\n}\n\nclass ConfigError extends Error {\n constructor(message, field) {\n super(message);\n this.name = 'ConfigError';\n this.field = field;\n this.code = `CONFIG_${field.toUpperCase()}`;\n }\n}\n\nclass ProcessingError extends Error {\n constructor(message, token) {\n super(message);\n this.name = 'ProcessingError';\n this.token = token;\n this.code = 'PROCESSING_ERROR';\n }\n}\n\nmodule.exports = {\n APIError,\n CacheError,\n ConfigError,\n ProcessingError\n};", "const fs = require('fs');\nconst path = require('path');\nconst { CACHE_DIR_NAME, CACHE_TTL_MS, CACHE_FILES } = require('./constants');\nconst { CacheError } = require('./errors');\n\nclass CacheManager {\n constructor(appRoot = process.cwd()) {\n this.appRoot = appRoot;\n this.cacheDir = path.join(appRoot, 'node_modules', CACHE_DIR_NAME);\n this.metadataFile = path.join(this.cacheDir, 'metadata.json');\n this.maxAge = CACHE_TTL_MS;\n }\n\n /**\n * Get the cache directory path\n * @returns {string} Cache directory path\n */\n getCacheDir() {\n return this.cacheDir;\n }\n\n /**\n * Check if cache directory exists\n * @returns {boolean} True if cache exists\n */\n exists() {\n return fs.existsSync(this.cacheDir);\n }\n\n /**\n * Check if cache is valid (exists and not expired)\n * @returns {boolean} True if cache is valid\n */\n isValid() {\n if (!this.exists()) {\n return false;\n }\n\n try {\n if (!fs.existsSync(this.metadataFile)) {\n return false;\n }\n\n const metadata = JSON.parse(fs.readFileSync(this.metadataFile, 'utf-8'));\n const timestamp = new Date(metadata.timestamp).getTime();\n const now = Date.now();\n \n return (now - timestamp) < this.maxAge;\n } catch (error) {\n return false;\n }\n }\n\n /**\n * Load all cached data\n * @returns {Object|null} Cached data object or null if not found\n */\n load() {\n if (!this.exists()) {\n return null;\n }\n\n try {\n const data = {};\n \n // Load all .js files\n for (const file of CACHE_FILES.JS) {\n const filePath = path.join(this.cacheDir, file);\n if (fs.existsSync(filePath)) {\n // Remove .js extension for key\n const key = file.replace('.js', '');\n try {\n // Use a more secure approach - parse the exported data\n const content = fs.readFileSync(filePath, 'utf-8');\n // Create a safe evaluation context\n const moduleExports = {};\n const fakeModule = { exports: moduleExports };\n \n // Use Function constructor to evaluate in isolated scope\n const evalFunc = new Function('module', 'exports', content);\n evalFunc(fakeModule, moduleExports);\n \n data[key] = fakeModule.exports;\n } catch (e) {\n // Skip files that can't be parsed\n }\n }\n }\n\n // Load all .json files\n for (const file of CACHE_FILES.JSON) {\n const filePath = path.join(this.cacheDir, file);\n if (fs.existsSync(filePath)) {\n const key = file.replace('.json', '');\n const content = fs.readFileSync(filePath, 'utf-8');\n data[key] = JSON.parse(content);\n }\n }\n\n // Rename components-config to componentsConfig for consistency\n if (data['components-config']) {\n data.componentsConfig = data['components-config'];\n delete data['components-config'];\n }\n\n return data;\n } catch (error) {\n throw new CacheError(`Failed to load cache: ${error.message}`, 'read');\n }\n }\n\n /**\n * Save data to cache\n * @param {Object} data - Data object to save\n * @throws {Error} If save operation fails\n */\n save(data) {\n try {\n // Create cache directory\n fs.mkdirSync(this.cacheDir, { recursive: true });\n\n // Save metadata first\n const metadata = {\n timestamp: new Date().toISOString(),\n version: data.metadata?.version || '2.0.0',\n ffId: data.metadata?.ffId\n };\n fs.writeFileSync(\n this.metadataFile,\n JSON.stringify(metadata, null, 2)\n );\n\n // Save .js files\n const jsFiles = [\n 'tokens',\n 'variables',\n 'semanticVariables',\n 'semanticDarkVariables',\n 'cls',\n 'custom'\n ];\n\n for (const key of jsFiles) {\n if (data[key] !== undefined) {\n const filePath = path.join(this.cacheDir, `${key}.js`);\n const value = data[key];\n \n // Ensure we have actual data to save\n if (value === null || value === undefined || \n (typeof value === 'object' && Object.keys(value).length === 0) ||\n (Array.isArray(value) && value.length === 0)) {\n // For empty objects/arrays, save a proper empty structure\n const emptyContent = Array.isArray(value) ? '[]' : '{}';\n const content = `module.exports = ${emptyContent};`;\n fs.writeFileSync(filePath, content);\n } else {\n const content = `module.exports = ${JSON.stringify(value, null, 2)};`;\n fs.writeFileSync(filePath, content);\n }\n }\n }\n\n // Save .json files\n const jsonData = {\n fonts: data.fonts,\n icons: data.icons || data.iconSet,\n 'components-config': data.componentsConfig,\n version: data.version\n };\n\n for (const [key, value] of Object.entries(jsonData)) {\n if (value !== undefined) {\n const filePath = path.join(this.cacheDir, `${key}.json`);\n fs.writeFileSync(filePath, JSON.stringify(value, null, 2));\n }\n }\n } catch (error) {\n throw new CacheError(`Failed to save cache: ${error.message}`, 'write');\n }\n }\n\n /**\n * Clear the cache directory\n */\n clear() {\n if (this.exists()) {\n fs.rmSync(this.cacheDir, { recursive: true, force: true });\n }\n }\n}\n\nmodule.exports = CacheManager;", "const CacheManager = require('./lib/core/cache-manager');\n\nfunction withFrontFriend(nextConfig = {}) {\n return {\n ...nextConfig,\n webpack: (config, options) => {\n // 1. Call existing webpack config if provided\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // 2. Load cache with CacheManager\n const cacheManager = new CacheManager(process.cwd());\n \n if (!cacheManager.exists()) {\n console.warn('[FrontFriend Next.js] No cache found. Please run \"npx frontfriend init\" first.');\n return config;\n }\n\n const cache = cacheManager.load();\n if (!cache) {\n console.error('[FrontFriend Next.js] Failed to load cache.');\n return config;\n }\n\n // 4. Use webpack.DefinePlugin from options (works with both webpack 4 and 5)\n const { webpack } = options;\n const DefinePlugin = webpack.DefinePlugin;\n\n // 5. Inject __FF_CONFIG__ and __FF_ICONS__ as globals\n const definitions = {\n __FF_CONFIG__: JSON.stringify(cache.componentsConfig || null),\n __FF_ICONS__: JSON.stringify(cache.icons || null)\n };\n\n // Add DefinePlugin to plugins array\n config.plugins = config.plugins || [];\n config.plugins.push(new DefinePlugin(definitions));\n\n // Log success in development\n if (options.dev && !options.isServer) {\n console.log('[FrontFriend Next.js] Injected configuration and icons into client build');\n }\n\n // 6. Return modified config\n return config;\n }\n };\n}\n\nmodule.exports = withFrontFriend;"],
|
|
5
|
+
"mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAKA,IAAMC,EAAkB,8BAClBC,EAAiB,iDAGjBC,EAAiB,qBAKjBC,EAAc,CAClB,GAAI,CACF,YACA,eACA,uBACA,2BACA,SACA,WACF,EACA,KAAM,CACJ,aACA,aACA,yBACA,eACA,eACF,CACF,EAGMC,EAAW,CACf,MAAO,QACP,WAAY,YACd,EAEAL,EAAO,QAAU,CACf,gBAAAC,EACA,eAAAC,EACA,eAAAC,EACA,iBACA,oBACA,YAAAC,EACA,SAAAC,CACF,IC9CA,IAAAC,EAAAC,EAAA,CAAAC,EAAAC,IAAA,KAAMC,EAAN,cAAuB,KAAM,CAC3B,YAAYC,EAASC,EAAYC,EAAK,CACpC,MAAMF,CAAO,EACb,KAAK,KAAO,WACZ,KAAK,WAAaC,EAClB,KAAK,IAAMC,EACX,KAAK,KAAO,OAAOD,CAAU,EAC/B,CACF,EAEME,EAAN,cAAyB,KAAM,CAC7B,YAAYH,EAASI,EAAW,CAC9B,MAAMJ,CAAO,EACb,KAAK,KAAO,aACZ,KAAK,UAAYI,EACjB,KAAK,KAAO,S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L,GAAGA,EACH,QAAS,CAACC,EAAQC,IAAY,CAExB,OAAOF,EAAW,SAAY,aAChCC,EAASD,EAAW,QAAQC,EAAQC,CAAO,GAI7C,IAAMC,EAAe,IAAIL,EAAa,QAAQ,IAAI,CAAC,EAEnD,GAAI,CAACK,EAAa,OAAO,EACvB,eAAQ,KAAK,gFAAgF,EACtFF,EAGT,IAAMG,EAAQD,EAAa,KAAK,EAChC,GAAI,CAACC,EACH,eAAQ,MAAM,6CAA6C,EACpDH,EAIT,GAAM,CAAE,QAAAI,CAAQ,EAAIH,EACdI,EAAeD,EAAQ,aAGvBE,EAAc,CAClB,cAAe,KAAK,UAAUH,EAAM,kBAAoB,IAAI,EAC5D,aAAc,KAAK,UAAUA,EAAM,OAAS,IAAI,CAClD,EAGA,OAAAH,EAAO,QAAUA,EAAO,SAAW,CAAC,EACpCA,EAAO,QAAQ,KAAK,IAAIK,EAAaC,CAAW,CAAC,EAG7CL,EAAQ,KAAO,CAACA,EAAQ,UAC1B,QAAQ,IAAI,0EAA0E,EAIjFD,CACT,CACF,CACF,CAEA,OAAO,QAAUF",
|
|
6
|
+
"names": ["require_constants", "__commonJSMin", "exports", "module", "DEFAULT_API_URL", "LEGACY_API_URL", "CACHE_DIR_NAME", "CACHE_FILES", "ENV_VARS", "require_errors", "__commonJSMin", "exports", "module", "APIError", "message", "statusCode", "url", "CacheError", "operation", "ConfigError", "field", "ProcessingError", "token", "require_cache_manager", "__commonJSMin", "exports", "module", "fs", "path", "CACHE_DIR_NAME", "CACHE_TTL_MS", "CACHE_FILES", "CacheError", "CacheManager", "appRoot", "metadata", "timestamp", "data", "file", "filePath", "key", "content", "moduleExports", "fakeModule", "error", "_a", "_b", "jsFiles", "value", "jsonData", "CacheManager", "withFrontFriend", "nextConfig", "config", "options", "cacheManager", "cache", "webpack", "DefinePlugin", "definitions"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface FrontFriend {
|
|
2
|
+
/** Current configuration */
|
|
3
|
+
config: Record<string, any> | null;
|
|
4
|
+
/** Icon set */
|
|
5
|
+
iconSet: Record<string, string> | null;
|
|
6
|
+
/** Get an icon by name */
|
|
7
|
+
getIcon(name: string): string | null;
|
|
8
|
+
/** Refresh configuration from globals */
|
|
9
|
+
refresh(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const FrontFriend: FrontFriend;
|
|
13
|
+
export default FrontFriend;
|
package/dist/vite.d.ts
ADDED
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var u=(
|
|
1
|
+
var u=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var y=u((P,S)=>{var N="https://app.frontfriend.dev",O="https://tokens-studio-donux.up.railway.app/api",T=".cache/frontfriend",w={JS:["tokens.js","variables.js","semanticVariables.js","semanticDarkVariables.js","cls.js","custom.js"],JSON:["fonts.json","icons.json","components-config.json","version.json","metadata.json"]},b={FF_ID:"FF_ID",FF_API_URL:"FF_API_URL"};S.exports={DEFAULT_API_URL:N,LEGACY_API_URL:O,CACHE_DIR_NAME:T,CACHE_TTL_DAYS:7,CACHE_TTL_MS:6048e5,CACHE_FILES:w,ENV_VARS:b}});var A=u((R,g)=>{var f=class extends Error{constructor(e,t,n){super(e),this.name="APIError",this.statusCode=t,this.url=n,this.code=`API_${t}`}},d=class extends Error{constructor(e,t){super(e),this.name="CacheError",this.operation=t,this.code=`CACHE_${t.toUpperCase()}`}},F=class extends Error{constructor(e,t){super(e),this.name="ConfigError",this.field=t,this.code=`CONFIG_${t.toUpperCase()}`}},m=class extends Error{constructor(e,t){super(e),this.name="ProcessingError",this.token=t,this.code="PROCESSING_ERROR"}};g.exports={APIError:f,CacheError:d,ConfigError:F,ProcessingError:m}});var E=u((H,I)=>{var s=require("fs"),h=require("path"),{CACHE_DIR_NAME:v,CACHE_TTL_MS:L,CACHE_FILES:j}=y(),{CacheError:x}=A(),p=class{constructor(e=process.cwd()){this.appRoot=e,this.cacheDir=h.join(e,"node_modules",v),this.metadataFile=h.join(this.cacheDir,"metadata.json"),this.maxAge=L}getCacheDir(){return this.cacheDir}exists(){return s.existsSync(this.cacheDir)}isValid(){if(!this.exists())return!1;try{if(!s.existsSync(this.metadataFile))return!1;let e=JSON.parse(s.readFileSync(this.metadataFile,"utf-8")),t=new Date(e.timestamp).getTime();return Date.now()-t<this.maxAge}catch{return!1}}load(){if(!this.exists())return null;try{let e={};for(let t of j.JS){let n=h.join(this.cacheDir,t);if(s.existsSync(n)){let r=t.replace(".js","");try{let o=s.readFileSync(n,"utf-8"),_={},i={exports:_};new Function("module","exports",o)(i,_),e[r]=i.exports}catch{}}}for(let t of j.JSON){let n=h.join(this.cacheDir,t);if(s.existsSync(n)){let r=t.replace(".json",""),o=s.readFileSync(n,"utf-8");e[r]=JSON.parse(o)}}return e["components-config"]&&(e.componentsConfig=e["components-config"],delete e["components-config"]),e}catch(e){throw new x(`Failed to load cache: ${e.message}`,"read")}}save(e){var t,n;try{s.mkdirSync(this.cacheDir,{recursive:!0});let r={timestamp:new Date().toISOString(),version:((t=e.metadata)==null?void 0:t.version)||"2.0.0",ffId:(n=e.metadata)==null?void 0:n.ffId};s.writeFileSync(this.metadataFile,JSON.stringify(r,null,2));let o=["tokens","variables","semanticVariables","semanticDarkVariables","cls","custom"];for(let i of o)if(e[i]!==void 0){let l=h.join(this.cacheDir,`${i}.js`),c=e[i];if(c==null||typeof c=="object"&&Object.keys(c).length===0||Array.isArray(c)&&c.length===0){let D=`module.exports = ${Array.isArray(c)?"[]":"{}"};`;s.writeFileSync(l,D)}else{let C=`module.exports = ${JSON.stringify(c,null,2)};`;s.writeFileSync(l,C)}}let _={fonts:e.fonts,icons:e.icons||e.iconSet,"components-config":e.componentsConfig,version:e.version};for(let[i,l]of Object.entries(_))if(l!==void 0){let c=h.join(this.cacheDir,`${i}.json`);s.writeFileSync(c,JSON.stringify(l,null,2))}}catch(r){throw new x(`Failed to save cache: ${r.message}`,"write")}}clear(){this.exists()&&s.rmSync(this.cacheDir,{recursive:!0,force:!0})}};I.exports=p});module.exports=function(){let e;return{name:"frontfriend-tailwind",configResolved(t){e=t},load(t){if(t==="virtual:frontfriend-config")try{let n=E(),r=new n((e==null?void 0:e.root)||process.cwd());if(!r.exists())return console.warn('[FrontFriend Vite] No cache found. Please run "npx frontfriend init" first.'),`
|
|
2
2
|
globalThis.__FF_CONFIG__ = null;
|
|
3
3
|
globalThis.__FF_ICONS__ = null;
|
|
4
4
|
`;let o;try{o=r.load()}catch{return console.error("[FrontFriend Vite] Failed to load cache."),`
|
|
@@ -7,8 +7,8 @@ var u=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var S=u((v,C)=>{va
|
|
|
7
7
|
`}if(!o)return console.error("[FrontFriend Vite] Failed to load cache."),`
|
|
8
8
|
globalThis.__FF_CONFIG__ = null;
|
|
9
9
|
globalThis.__FF_ICONS__ = null;
|
|
10
|
-
`;let
|
|
11
|
-
globalThis.__FF_CONFIG__ = ${JSON.stringify(
|
|
10
|
+
`;let _=o.componentsConfig||null,i=o.icons||null;return(e==null?void 0:e.command)==="serve"&&console.log("[FrontFriend Vite] Injected configuration and icons into build"),`
|
|
11
|
+
globalThis.__FF_CONFIG__ = ${JSON.stringify(_)};
|
|
12
12
|
globalThis.__FF_ICONS__ = ${JSON.stringify(i)};
|
|
13
13
|
`}catch{return`
|
|
14
14
|
globalThis.__FF_CONFIG__ = null;
|
package/dist/vite.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/core/constants.js", "../lib/core/errors.js", "../lib/core/cache-manager.js", "../vite.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Configuration constants for FrontFriend Tailwind v2\n */\n\n// API Configuration\nconst DEFAULT_API_URL = 'https://tokens-studio-donux.up.railway.app/api';\n\n// Cache Configuration\nconst CACHE_DIR_NAME = '.cache/frontfriend';\nconst CACHE_TTL_DAYS = 7;\nconst CACHE_TTL_MS = CACHE_TTL_DAYS * 24 * 60 * 60 * 1000;\n\n// File names\nconst CACHE_FILES = {\n JS: [\n 'tokens.js',\n 'variables.js',\n 'semanticVariables.js',\n 'semanticDarkVariables.js',\n 'cls.js',\n 'custom.js'\n ],\n JSON: [\n 'fonts.json',\n 'icons.json',\n 'components-config.json',\n 'version.json',\n 'metadata.json'\n ]\n};\n\n// Environment variables\nconst ENV_VARS = {\n FF_ID: 'FF_ID',\n FF_API_URL: 'FF_API_URL'\n};\n\nmodule.exports = {\n DEFAULT_API_URL,\n CACHE_DIR_NAME,\n CACHE_TTL_DAYS,\n CACHE_TTL_MS,\n CACHE_FILES,\n ENV_VARS\n};", "class APIError extends Error {\n constructor(message, statusCode, url) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.url = url;\n this.code = `API_${statusCode}`;\n }\n}\n\nclass CacheError extends Error {\n constructor(message, operation) {\n super(message);\n this.name = 'CacheError';\n this.operation = operation;\n this.code = `CACHE_${operation.toUpperCase()}`;\n }\n}\n\nclass ConfigError extends Error {\n constructor(message, field) {\n super(message);\n this.name = 'ConfigError';\n this.field = field;\n this.code = `CONFIG_${field.toUpperCase()}`;\n }\n}\n\nclass ProcessingError extends Error {\n constructor(message, token) {\n super(message);\n this.name = 'ProcessingError';\n this.token = token;\n this.code = 'PROCESSING_ERROR';\n }\n}\n\nmodule.exports = {\n APIError,\n CacheError,\n ConfigError,\n ProcessingError\n};", "const fs = require('fs');\nconst path = require('path');\nconst { CACHE_DIR_NAME, CACHE_TTL_MS, CACHE_FILES } = require('./constants');\nconst { CacheError } = require('./errors');\n\nclass CacheManager {\n constructor(appRoot = process.cwd()) {\n this.appRoot = appRoot;\n this.cacheDir = path.join(appRoot, 'node_modules', CACHE_DIR_NAME);\n this.metadataFile = path.join(this.cacheDir, 'metadata.json');\n this.maxAge = CACHE_TTL_MS;\n }\n\n /**\n * Get the cache directory path\n * @returns {string} Cache directory path\n */\n getCacheDir() {\n return this.cacheDir;\n }\n\n /**\n * Check if cache directory exists\n * @returns {boolean} True if cache exists\n */\n exists() {\n return fs.existsSync(this.cacheDir);\n }\n\n /**\n * Check if cache is valid (exists and not expired)\n * @returns {boolean} True if cache is valid\n */\n isValid() {\n if (!this.exists()) {\n return false;\n }\n\n try {\n if (!fs.existsSync(this.metadataFile)) {\n return false;\n }\n\n const metadata = JSON.parse(fs.readFileSync(this.metadataFile, 'utf-8'));\n const timestamp = new Date(metadata.timestamp).getTime();\n const now = Date.now();\n \n return (now - timestamp) < this.maxAge;\n } catch (error) {\n return false;\n }\n }\n\n /**\n * Load all cached data\n * @returns {Object|null} Cached data object or null if not found\n */\n load() {\n if (!this.exists()) {\n return null;\n }\n\n try {\n const data = {};\n \n // Load all .js files\n for (const file of CACHE_FILES.JS) {\n const filePath = path.join(this.cacheDir, file);\n if (fs.existsSync(filePath)) {\n // Remove .js extension for key\n const key = file.replace('.js', '');\n try {\n // Use a more secure approach - parse the exported data\n const content = fs.readFileSync(filePath, 'utf-8');\n // Create a safe evaluation context\n const moduleExports = {};\n const fakeModule = { exports: moduleExports };\n \n // Use Function constructor to evaluate in isolated scope\n const evalFunc = new Function('module', 'exports', content);\n evalFunc(fakeModule, moduleExports);\n \n data[key] = fakeModule.exports;\n } catch (e) {\n // Skip files that can't be parsed\n }\n }\n }\n\n // Load all .json files\n for (const file of CACHE_FILES.JSON) {\n const filePath = path.join(this.cacheDir, file);\n if (fs.existsSync(filePath)) {\n const key = file.replace('.json', '');\n const content = fs.readFileSync(filePath, 'utf-8');\n data[key] = JSON.parse(content);\n }\n }\n\n // Rename components-config to componentsConfig for consistency\n if (data['components-config']) {\n data.componentsConfig = data['components-config'];\n delete data['components-config'];\n }\n\n return data;\n } catch (error) {\n throw new CacheError(`Failed to load cache: ${error.message}`, 'read');\n }\n }\n\n /**\n * Save data to cache\n * @param {Object} data - Data object to save\n * @throws {Error} If save operation fails\n */\n save(data) {\n try {\n // Create cache directory\n fs.mkdirSync(this.cacheDir, { recursive: true });\n\n // Save metadata first\n const metadata = {\n timestamp: new Date().toISOString(),\n version: data.metadata?.version || '2.0.0',\n ffId: data.metadata?.ffId\n };\n fs.writeFileSync(\n this.metadataFile,\n JSON.stringify(metadata, null, 2)\n );\n\n // Save .js files\n const jsFiles = [\n 'tokens',\n 'variables',\n 'semanticVariables',\n 'semanticDarkVariables',\n 'cls',\n 'custom'\n ];\n\n for (const key of jsFiles) {\n if (data[key] !== undefined) {\n const filePath = path.join(this.cacheDir, `${key}.js`);\n const content = `module.exports = ${JSON.stringify(
|
|
5
|
-
"mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAKA,IAAMC,EAAkB,
|
|
6
|
-
"names": ["require_constants", "__commonJSMin", "exports", "module", "DEFAULT_API_URL", "CACHE_DIR_NAME", "CACHE_FILES", "ENV_VARS", "require_errors", "__commonJSMin", "exports", "module", "APIError", "message", "statusCode", "url", "CacheError", "operation", "ConfigError", "field", "ProcessingError", "token", "require_cache_manager", "__commonJSMin", "exports", "module", "fs", "path", "CACHE_DIR_NAME", "CACHE_TTL_MS", "CACHE_FILES", "CacheError", "CacheManager", "appRoot", "metadata", "timestamp", "data", "file", "filePath", "key", "content", "moduleExports", "fakeModule", "error", "_a", "_b", "jsFiles", "
|
|
4
|
+
"sourcesContent": ["/**\n * Configuration constants for FrontFriend Tailwind v2\n */\n\n// API Configuration\nconst DEFAULT_API_URL = 'https://app.frontfriend.dev';\nconst LEGACY_API_URL = 'https://tokens-studio-donux.up.railway.app/api';\n\n// Cache Configuration\nconst CACHE_DIR_NAME = '.cache/frontfriend';\nconst CACHE_TTL_DAYS = 7;\nconst CACHE_TTL_MS = CACHE_TTL_DAYS * 24 * 60 * 60 * 1000;\n\n// File names\nconst CACHE_FILES = {\n JS: [\n 'tokens.js',\n 'variables.js',\n 'semanticVariables.js',\n 'semanticDarkVariables.js',\n 'cls.js',\n 'custom.js'\n ],\n JSON: [\n 'fonts.json',\n 'icons.json',\n 'components-config.json',\n 'version.json',\n 'metadata.json'\n ]\n};\n\n// Environment variables\nconst ENV_VARS = {\n FF_ID: 'FF_ID',\n FF_API_URL: 'FF_API_URL'\n};\n\nmodule.exports = {\n DEFAULT_API_URL,\n LEGACY_API_URL,\n CACHE_DIR_NAME,\n CACHE_TTL_DAYS,\n CACHE_TTL_MS,\n CACHE_FILES,\n ENV_VARS\n};", "class APIError extends Error {\n constructor(message, statusCode, url) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.url = url;\n this.code = `API_${statusCode}`;\n }\n}\n\nclass CacheError extends Error {\n constructor(message, operation) {\n super(message);\n this.name = 'CacheError';\n this.operation = operation;\n this.code = `CACHE_${operation.toUpperCase()}`;\n }\n}\n\nclass ConfigError extends Error {\n constructor(message, field) {\n super(message);\n this.name = 'ConfigError';\n this.field = field;\n this.code = `CONFIG_${field.toUpperCase()}`;\n }\n}\n\nclass ProcessingError extends Error {\n constructor(message, token) {\n super(message);\n this.name = 'ProcessingError';\n this.token = token;\n this.code = 'PROCESSING_ERROR';\n }\n}\n\nmodule.exports = {\n APIError,\n CacheError,\n ConfigError,\n ProcessingError\n};", "const fs = require('fs');\nconst path = require('path');\nconst { CACHE_DIR_NAME, CACHE_TTL_MS, CACHE_FILES } = require('./constants');\nconst { CacheError } = require('./errors');\n\nclass CacheManager {\n constructor(appRoot = process.cwd()) {\n this.appRoot = appRoot;\n this.cacheDir = path.join(appRoot, 'node_modules', CACHE_DIR_NAME);\n this.metadataFile = path.join(this.cacheDir, 'metadata.json');\n this.maxAge = CACHE_TTL_MS;\n }\n\n /**\n * Get the cache directory path\n * @returns {string} Cache directory path\n */\n getCacheDir() {\n return this.cacheDir;\n }\n\n /**\n * Check if cache directory exists\n * @returns {boolean} True if cache exists\n */\n exists() {\n return fs.existsSync(this.cacheDir);\n }\n\n /**\n * Check if cache is valid (exists and not expired)\n * @returns {boolean} True if cache is valid\n */\n isValid() {\n if (!this.exists()) {\n return false;\n }\n\n try {\n if (!fs.existsSync(this.metadataFile)) {\n return false;\n }\n\n const metadata = JSON.parse(fs.readFileSync(this.metadataFile, 'utf-8'));\n const timestamp = new Date(metadata.timestamp).getTime();\n const now = Date.now();\n \n return (now - timestamp) < this.maxAge;\n } catch (error) {\n return false;\n }\n }\n\n /**\n * Load all cached data\n * @returns {Object|null} Cached data object or null if not found\n */\n load() {\n if (!this.exists()) {\n return null;\n }\n\n try {\n const data = {};\n \n // Load all .js files\n for (const file of CACHE_FILES.JS) {\n const filePath = path.join(this.cacheDir, file);\n if (fs.existsSync(filePath)) {\n // Remove .js extension for key\n const key = file.replace('.js', '');\n try {\n // Use a more secure approach - parse the exported data\n const content = fs.readFileSync(filePath, 'utf-8');\n // Create a safe evaluation context\n const moduleExports = {};\n const fakeModule = { exports: moduleExports };\n \n // Use Function constructor to evaluate in isolated scope\n const evalFunc = new Function('module', 'exports', content);\n evalFunc(fakeModule, moduleExports);\n \n data[key] = fakeModule.exports;\n } catch (e) {\n // Skip files that can't be parsed\n }\n }\n }\n\n // Load all .json files\n for (const file of CACHE_FILES.JSON) {\n const filePath = path.join(this.cacheDir, file);\n if (fs.existsSync(filePath)) {\n const key = file.replace('.json', '');\n const content = fs.readFileSync(filePath, 'utf-8');\n data[key] = JSON.parse(content);\n }\n }\n\n // Rename components-config to componentsConfig for consistency\n if (data['components-config']) {\n data.componentsConfig = data['components-config'];\n delete data['components-config'];\n }\n\n return data;\n } catch (error) {\n throw new CacheError(`Failed to load cache: ${error.message}`, 'read');\n }\n }\n\n /**\n * Save data to cache\n * @param {Object} data - Data object to save\n * @throws {Error} If save operation fails\n */\n save(data) {\n try {\n // Create cache directory\n fs.mkdirSync(this.cacheDir, { recursive: true });\n\n // Save metadata first\n const metadata = {\n timestamp: new Date().toISOString(),\n version: data.metadata?.version || '2.0.0',\n ffId: data.metadata?.ffId\n };\n fs.writeFileSync(\n this.metadataFile,\n JSON.stringify(metadata, null, 2)\n );\n\n // Save .js files\n const jsFiles = [\n 'tokens',\n 'variables',\n 'semanticVariables',\n 'semanticDarkVariables',\n 'cls',\n 'custom'\n ];\n\n for (const key of jsFiles) {\n if (data[key] !== undefined) {\n const filePath = path.join(this.cacheDir, `${key}.js`);\n const value = data[key];\n \n // Ensure we have actual data to save\n if (value === null || value === undefined || \n (typeof value === 'object' && Object.keys(value).length === 0) ||\n (Array.isArray(value) && value.length === 0)) {\n // For empty objects/arrays, save a proper empty structure\n const emptyContent = Array.isArray(value) ? '[]' : '{}';\n const content = `module.exports = ${emptyContent};`;\n fs.writeFileSync(filePath, content);\n } else {\n const content = `module.exports = ${JSON.stringify(value, null, 2)};`;\n fs.writeFileSync(filePath, content);\n }\n }\n }\n\n // Save .json files\n const jsonData = {\n fonts: data.fonts,\n icons: data.icons || data.iconSet,\n 'components-config': data.componentsConfig,\n version: data.version\n };\n\n for (const [key, value] of Object.entries(jsonData)) {\n if (value !== undefined) {\n const filePath = path.join(this.cacheDir, `${key}.json`);\n fs.writeFileSync(filePath, JSON.stringify(value, null, 2));\n }\n }\n } catch (error) {\n throw new CacheError(`Failed to save cache: ${error.message}`, 'write');\n }\n }\n\n /**\n * Clear the cache directory\n */\n clear() {\n if (this.exists()) {\n fs.rmSync(this.cacheDir, { recursive: true, force: true });\n }\n }\n}\n\nmodule.exports = CacheManager;", "// CommonJS wrapper for vite.mjs to support Jest testing\nmodule.exports = function vitePlugin() {\n // Return a mock plugin for testing\n let config;\n \n return {\n name: 'frontfriend-tailwind',\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n load(id) {\n if (id === 'virtual:frontfriend-config') {\n // Mock implementation for testing\n try {\n const CacheManager = require('./lib/core/cache-manager');\n const cacheManager = new CacheManager(config?.root || process.cwd());\n \n if (!cacheManager.exists()) {\n console.warn('[FrontFriend Vite] No cache found. Please run \"npx frontfriend init\" first.');\n return `\n globalThis.__FF_CONFIG__ = null;\n globalThis.__FF_ICONS__ = null;\n `;\n }\n \n let cache;\n try {\n cache = cacheManager.load();\n } catch (error) {\n console.error('[FrontFriend Vite] Failed to load cache.');\n return `\n globalThis.__FF_CONFIG__ = null;\n globalThis.__FF_ICONS__ = null;\n `;\n }\n \n if (!cache) {\n console.error('[FrontFriend Vite] Failed to load cache.');\n return `\n globalThis.__FF_CONFIG__ = null;\n globalThis.__FF_ICONS__ = null;\n `;\n }\n \n const componentsConfig = cache.componentsConfig || null;\n const icons = cache.icons || null;\n \n if (config?.command === 'serve') {\n console.log('[FrontFriend Vite] Injected configuration and icons into build');\n }\n \n return `\n globalThis.__FF_CONFIG__ = ${JSON.stringify(componentsConfig)};\n globalThis.__FF_ICONS__ = ${JSON.stringify(icons)};\n `;\n } catch (error) {\n // Handle any errors gracefully\n return `\n globalThis.__FF_CONFIG__ = null;\n globalThis.__FF_ICONS__ = null;\n `;\n }\n }\n \n return null;\n }\n };\n};"],
|
|
5
|
+
"mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAKA,IAAMC,EAAkB,8BAClBC,EAAiB,iDAGjBC,EAAiB,qBAKjBC,EAAc,CAClB,GAAI,CACF,YACA,eACA,uBACA,2BACA,SACA,WACF,EACA,KAAM,CACJ,aACA,aACA,yBACA,eACA,eACF,CACF,EAGMC,EAAW,CACf,MAAO,QACP,WAAY,YACd,EAEAL,EAAO,QAAU,CACf,gBAAAC,EACA,eAAAC,EACA,eAAAC,EACA,iBACA,oBACA,YAAAC,EACA,SAAAC,CACF,IC9CA,IAAAC,EAAAC,EAAA,CAAAC,EAAAC,IAAA,KAAMC,EAAN,cAAuB,KAAM,CAC3B,YAAYC,EAASC,EAAYC,EAAK,CACpC,MAAMF,CAAO,EACb,KAAK,KAAO,WACZ,KAAK,WAAaC,EAClB,KAAK,IAAMC,EACX,KAAK,KAAO,OAAOD,CAAU,EAC/B,CACF,EAEME,EAAN,cAAyB,KAAM,CAC7B,YAAYH,EAASI,EAAW,CAC9B,MAAMJ,CAAO,EACb,KAAK,KAAO,aACZ,KAAK,UAAYI,EACjB,KAAK,KAAO,SAASA,EAAU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,CAC7BD,EAASC,CACX,EACA,KAAKC,EAAI,CACP,GAAIA,IAAO,6BAET,GAAI,CACF,IAAMC,EAAe,IACfC,EAAe,IAAID,GAAaH,GAAA,YAAAA,EAAQ,OAAQ,QAAQ,IAAI,CAAC,EAEnE,GAAI,CAACI,EAAa,OAAO,EACvB,eAAQ,KAAK,6EAA6E,EACnF;AAAA;AAAA;AAAA,cAMT,IAAIC,EACJ,GAAI,CACFA,EAAQD,EAAa,KAAK,CAC5B,MAAgB,CACd,eAAQ,MAAM,0CAA0C,EACjD;AAAA;AAAA;AAAA,aAIT,CAEA,GAAI,CAACC,EACH,eAAQ,MAAM,0CAA0C,EACjD;AAAA;AAAA;AAAA,cAMT,IAAMC,EAAmBD,EAAM,kBAAoB,KAC7CE,EAAQF,EAAM,OAAS,KAE7B,OAAIL,GAAA,YAAAA,EAAQ,WAAY,SACtB,QAAQ,IAAI,gEAAgE,EAGvE;AAAA,yCACwB,KAAK,UAAUM,CAAgB,CAAC;AAAA,wCACjC,KAAK,UAAUC,CAAK,CAAC;AAAA,WAErD,MAAgB,CAEd,MAAO;AAAA;AAAA;AAAA,WAIT,CAGF,OAAO,IACT,CACF,CACF",
|
|
6
|
+
"names": ["require_constants", "__commonJSMin", "exports", "module", "DEFAULT_API_URL", "LEGACY_API_URL", "CACHE_DIR_NAME", "CACHE_FILES", "ENV_VARS", "require_errors", "__commonJSMin", "exports", "module", "APIError", "message", "statusCode", "url", "CacheError", "operation", "ConfigError", "field", "ProcessingError", "token", "require_cache_manager", "__commonJSMin", "exports", "module", "fs", "path", "CACHE_DIR_NAME", "CACHE_TTL_MS", "CACHE_FILES", "CacheError", "CacheManager", "appRoot", "metadata", "timestamp", "data", "file", "filePath", "key", "content", "moduleExports", "fakeModule", "error", "_a", "_b", "jsFiles", "value", "jsonData", "config", "resolvedConfig", "id", "CacheManager", "cacheManager", "cache", "componentsConfig", "icons"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontfriend/tailwind",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Design token management for Tailwind CSS",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -9,16 +9,35 @@
|
|
|
9
9
|
},
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
12
13
|
"import": "./dist/index.mjs",
|
|
13
14
|
"require": "./dist/index.js",
|
|
14
15
|
"default": "./dist/index.js"
|
|
15
16
|
},
|
|
16
|
-
"./runtime":
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"./
|
|
21
|
-
|
|
17
|
+
"./runtime": {
|
|
18
|
+
"types": "./dist/runtime.d.ts",
|
|
19
|
+
"default": "./dist/runtime.js"
|
|
20
|
+
},
|
|
21
|
+
"./next": {
|
|
22
|
+
"types": "./dist/next.d.ts",
|
|
23
|
+
"default": "./dist/next.js"
|
|
24
|
+
},
|
|
25
|
+
"./vite": {
|
|
26
|
+
"types": "./dist/vite.d.ts",
|
|
27
|
+
"default": "./dist/vite.mjs"
|
|
28
|
+
},
|
|
29
|
+
"./lib/react/utils": {
|
|
30
|
+
"types": "./dist/lib/react/utils.d.ts",
|
|
31
|
+
"default": "./dist/lib/react/utils.mjs"
|
|
32
|
+
},
|
|
33
|
+
"./lib/vue/utils": {
|
|
34
|
+
"types": "./dist/lib/vue/utils.d.ts",
|
|
35
|
+
"default": "./dist/lib/vue/utils.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./ffdc": {
|
|
38
|
+
"types": "./dist/ffdc.d.ts",
|
|
39
|
+
"default": "./dist/ffdc.js"
|
|
40
|
+
}
|
|
22
41
|
},
|
|
23
42
|
"scripts": {
|
|
24
43
|
"test": "jest",
|
|
@@ -32,14 +51,6 @@
|
|
|
32
51
|
],
|
|
33
52
|
"author": "Donux",
|
|
34
53
|
"license": "SEE LICENSE IN LICENSE",
|
|
35
|
-
"repository": {
|
|
36
|
-
"type": "git",
|
|
37
|
-
"url": "git+https://github.com/frontfriend/tailwind.git"
|
|
38
|
-
},
|
|
39
|
-
"homepage": "https://github.com/frontfriend/tailwind#readme",
|
|
40
|
-
"bugs": {
|
|
41
|
-
"url": "https://github.com/frontfriend/tailwind/issues"
|
|
42
|
-
},
|
|
43
54
|
"files": [
|
|
44
55
|
"dist/",
|
|
45
56
|
"README.md",
|