@frontfriend/tailwind 2.0.0
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/LICENSE +35 -0
- package/README.md +231 -0
- package/dist/cli.js +20 -0
- package/dist/ffdc.js +2 -0
- package/dist/ffdc.js.map +7 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +7 -0
- package/dist/lib/config/cache-manager.js +180 -0
- package/dist/lib/config/config-loader.js +129 -0
- package/dist/lib/core/api-client.js +2 -0
- package/dist/lib/core/api-client.js.map +7 -0
- package/dist/lib/core/component-downloader.js +2 -0
- package/dist/lib/core/component-downloader.js.map +7 -0
- package/dist/lib/core/constants.js +2 -0
- package/dist/lib/core/constants.js.map +7 -0
- package/dist/lib/core/errors.js +2 -0
- package/dist/lib/core/errors.js.map +7 -0
- package/dist/lib/core/token-processor.js +2 -0
- package/dist/lib/core/token-processor.js.map +7 -0
- package/dist/lib/react/utils.mjs +2 -0
- package/dist/lib/react/utils.mjs.map +7 -0
- package/dist/lib/vue/utils.mjs +2 -0
- package/dist/lib/vue/utils.mjs.map +7 -0
- package/dist/next.js +2 -0
- package/dist/next.js.map +7 -0
- package/dist/runtime.js +2 -0
- package/dist/runtime.js.map +7 -0
- package/dist/types/index.d.ts +249 -0
- package/dist/vite.js +17 -0
- package/dist/vite.js.map +7 -0
- package/dist/vite.mjs +2 -0
- package/dist/vite.mjs.map +7 -0
- package/package.json +65 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
declare module '@frontfriend/tailwind' {
|
|
2
|
+
// Main plugin
|
|
3
|
+
import { Config, PluginCreator } from 'tailwindcss/types/config';
|
|
4
|
+
|
|
5
|
+
export interface PluginOptions {
|
|
6
|
+
/** Force refresh cache even if valid */
|
|
7
|
+
force?: boolean;
|
|
8
|
+
/** Enable verbose logging */
|
|
9
|
+
verbose?: boolean;
|
|
10
|
+
/** Extend Tailwind colors */
|
|
11
|
+
extendColors?: Record<string, string>;
|
|
12
|
+
/** Extend Tailwind animations */
|
|
13
|
+
extendAnimations?: Record<string, string>;
|
|
14
|
+
/** Content paths for Tailwind */
|
|
15
|
+
content?: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Exported configuration and utilities
|
|
19
|
+
export const config: Record<string, any> | null;
|
|
20
|
+
export const iconSet: Record<string, string> | null;
|
|
21
|
+
export function ffdc(config: Record<string, any>): Record<string, any>;
|
|
22
|
+
|
|
23
|
+
export interface CacheData {
|
|
24
|
+
variables?: Record<string, string>;
|
|
25
|
+
semanticVariables?: Record<string, string>;
|
|
26
|
+
semanticDarkVariables?: Record<string, string>;
|
|
27
|
+
tokens?: TokenData;
|
|
28
|
+
keyframes?: Record<string, Record<string, any>>;
|
|
29
|
+
animations?: Record<string, string>;
|
|
30
|
+
fonts?: string[];
|
|
31
|
+
safelist?: string[];
|
|
32
|
+
custom?: Record<string, any>;
|
|
33
|
+
componentsConfig?: Record<string, any>;
|
|
34
|
+
icons?: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface TokenData {
|
|
38
|
+
backgroundColor?: Record<string, string>;
|
|
39
|
+
textColor?: Record<string, string>;
|
|
40
|
+
borderColor?: Record<string, string>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ProcessedData {
|
|
44
|
+
variables: Record<string, string>;
|
|
45
|
+
colorMap: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const plugin: PluginCreator<PluginOptions>;
|
|
49
|
+
export default plugin;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare module '@frontfriend/tailwind/runtime' {
|
|
53
|
+
export interface FrontFriend {
|
|
54
|
+
/** Current configuration */
|
|
55
|
+
config: Record<string, any> | null;
|
|
56
|
+
/** Icon set */
|
|
57
|
+
iconSet: Record<string, string> | null;
|
|
58
|
+
/** Get an icon by name */
|
|
59
|
+
getIcon(name: string): string | null;
|
|
60
|
+
/** Refresh configuration from globals */
|
|
61
|
+
refresh(): void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const FrontFriend: FrontFriend;
|
|
65
|
+
export default FrontFriend;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare module '@frontfriend/tailwind/next' {
|
|
69
|
+
import { NextConfig } from 'next';
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Wraps Next.js configuration to inject FrontFriend globals
|
|
73
|
+
* @param config - Next.js configuration object
|
|
74
|
+
* @returns Modified Next.js configuration
|
|
75
|
+
*/
|
|
76
|
+
export default function withFrontFriend(config?: NextConfig): NextConfig;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
declare module '@frontfriend/tailwind/cli' {
|
|
80
|
+
/** Run the FrontFriend CLI */
|
|
81
|
+
export function run(): void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare module '@frontfriend/tailwind/lib/react/utils' {
|
|
85
|
+
/**
|
|
86
|
+
* Combines class names with tailwind-merge
|
|
87
|
+
* @param inputs - Class names to combine
|
|
88
|
+
* @returns Merged class string
|
|
89
|
+
*/
|
|
90
|
+
export function cn(...inputs: any[]): string;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* React hook for media query
|
|
94
|
+
* @param query - Media query string
|
|
95
|
+
* @returns Boolean indicating if query matches
|
|
96
|
+
*/
|
|
97
|
+
export function useMediaQuery(query: string): boolean;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* React hook for responsive breakpoints
|
|
101
|
+
* @returns Object with breakpoint states and active breakpoint
|
|
102
|
+
*/
|
|
103
|
+
export function useBreakpoints(): {
|
|
104
|
+
isXs: boolean;
|
|
105
|
+
isSm: boolean;
|
|
106
|
+
isMd: boolean;
|
|
107
|
+
isLg: boolean;
|
|
108
|
+
active: 'xs' | 'sm' | 'md' | 'lg';
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare module '@frontfriend/tailwind/lib/react/utils.mjs' {
|
|
113
|
+
/**
|
|
114
|
+
* Combines class names with tailwind-merge
|
|
115
|
+
* @param inputs - Class names to combine
|
|
116
|
+
* @returns Merged class string
|
|
117
|
+
*/
|
|
118
|
+
export function cn(...inputs: any[]): string;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* React hook for media query
|
|
122
|
+
* @param query - Media query string
|
|
123
|
+
* @returns Boolean indicating if query matches
|
|
124
|
+
*/
|
|
125
|
+
export function useMediaQuery(query: string): boolean;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* React hook for responsive breakpoints
|
|
129
|
+
* @returns Object with breakpoint states and active breakpoint
|
|
130
|
+
*/
|
|
131
|
+
export function useBreakpoints(): {
|
|
132
|
+
isXs: boolean;
|
|
133
|
+
isSm: boolean;
|
|
134
|
+
isMd: boolean;
|
|
135
|
+
isLg: boolean;
|
|
136
|
+
active: 'xs' | 'sm' | 'md' | 'lg';
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
declare module '@frontfriend/tailwind/lib/vue/utils' {
|
|
141
|
+
/**
|
|
142
|
+
* Combines class names with tailwind-merge
|
|
143
|
+
* @param inputs - Class names to combine
|
|
144
|
+
* @returns Merged class string
|
|
145
|
+
*/
|
|
146
|
+
export function cn(...inputs: any[]): string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
declare module '@frontfriend/tailwind/lib/vue/utils.mjs' {
|
|
150
|
+
/**
|
|
151
|
+
* Combines class names with tailwind-merge
|
|
152
|
+
* @param inputs - Class names to combine
|
|
153
|
+
* @returns Merged class string
|
|
154
|
+
*/
|
|
155
|
+
export function cn(...inputs: any[]): string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Internal modules (for advanced usage)
|
|
159
|
+
declare module '@frontfriend/tailwind/lib/core/config-loader' {
|
|
160
|
+
export class ConfigLoader {
|
|
161
|
+
constructor(projectRoot?: string);
|
|
162
|
+
load(): { ffId: string | null; appRoot: string };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare module '@frontfriend/tailwind/lib/core/cache-manager' {
|
|
167
|
+
export class CacheManager {
|
|
168
|
+
constructor(projectRoot: string);
|
|
169
|
+
exists(): boolean;
|
|
170
|
+
isValid(): boolean;
|
|
171
|
+
load(): any;
|
|
172
|
+
save(data: any): void;
|
|
173
|
+
clean(): void;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
declare module '@frontfriend/tailwind/lib/core/api-client' {
|
|
178
|
+
export class APIClient {
|
|
179
|
+
constructor(ffId: string, options?: { baseURL?: string });
|
|
180
|
+
fetchAll(): Promise<any>;
|
|
181
|
+
fetchConfig(): Promise<any>;
|
|
182
|
+
fetchColors(): Promise<any>;
|
|
183
|
+
fetchComponents(): Promise<any>;
|
|
184
|
+
fetchFonts(): Promise<any>;
|
|
185
|
+
fetchIcons(): Promise<any>;
|
|
186
|
+
getFFId(): string;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare module '@frontfriend/tailwind/lib/core/token-processor' {
|
|
191
|
+
export class TokenProcessor {
|
|
192
|
+
constructor(customPrefix?: string);
|
|
193
|
+
processColors(colorsData: any): { variables: Record<string, string>; colorMap: Record<string, string> };
|
|
194
|
+
processSemanticTokens(tokensData: any, colorMap: Record<string, string>): {
|
|
195
|
+
semanticVariables: Record<string, string>;
|
|
196
|
+
semanticDarkVariables: Record<string, string>;
|
|
197
|
+
};
|
|
198
|
+
processTokens(colorMap: Record<string, string>): {
|
|
199
|
+
backgroundColor: Record<string, string>;
|
|
200
|
+
textColor: Record<string, string>;
|
|
201
|
+
borderColor: Record<string, string>;
|
|
202
|
+
};
|
|
203
|
+
processFonts(fontsData: any): string[];
|
|
204
|
+
processAnimations(animationsData: any): {
|
|
205
|
+
keyframes: Record<string, any>;
|
|
206
|
+
animations: Record<string, string>;
|
|
207
|
+
};
|
|
208
|
+
processAll(data: any): any;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare module '@frontfriend/tailwind/lib/core/errors' {
|
|
213
|
+
export class APIError extends Error {
|
|
214
|
+
statusCode: number;
|
|
215
|
+
url: string;
|
|
216
|
+
constructor(message: string, statusCode: number, url: string);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export class CacheError extends Error {
|
|
220
|
+
operation: string;
|
|
221
|
+
constructor(message: string, operation: string);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export class ConfigError extends Error {
|
|
225
|
+
field: string;
|
|
226
|
+
constructor(message: string, field: string);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export class ProcessingError extends Error {
|
|
230
|
+
token: string;
|
|
231
|
+
constructor(message: string, token: string);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
declare module '@frontfriend/tailwind/lib/core/constants' {
|
|
236
|
+
export const ENV_VARS: {
|
|
237
|
+
FF_ID: string;
|
|
238
|
+
FF_API_URL: string;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export const CACHE_FILES: {
|
|
242
|
+
JS: string[];
|
|
243
|
+
JSON: string[];
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export const DEFAULT_API_URL: string;
|
|
247
|
+
export const DEFAULT_PREFIX: string;
|
|
248
|
+
export const CACHE_TTL: number;
|
|
249
|
+
}
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var u=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var S=u((v,C)=>{var E="https://tokens-studio-donux.up.railway.app/api",N=".cache/frontfriend",A={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"};C.exports={DEFAULT_API_URL:E,CACHE_DIR_NAME:N,CACHE_TTL_DAYS:7,CACHE_TTL_MS:6048e5,CACHE_FILES:A,ENV_VARS:O}});var y=u((k,g)=>{var f=class extends Error{constructor(e,t,s){super(e),this.name="APIError",this.statusCode=t,this.url=s,this.code=`API_${t}`}},F=class extends Error{constructor(e,t){super(e),this.name="CacheError",this.operation=t,this.code=`CACHE_${t.toUpperCase()}`}},d=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:F,ConfigError:d,ProcessingError:m}});var D=u((L,I)=>{var n=require("fs"),_=require("path"),{CACHE_DIR_NAME:T,CACHE_TTL_MS:w,CACHE_FILES:j}=S(),{CacheError:x}=y(),p=class{constructor(e=process.cwd()){this.appRoot=e,this.cacheDir=_.join(e,"node_modules",T),this.metadataFile=_.join(this.cacheDir,"metadata.json"),this.maxAge=w}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 j.JS){let s=_.join(this.cacheDir,t);if(n.existsSync(s)){let r=t.replace(".js","");try{let o=n.readFileSync(s,"utf-8"),a={},i={exports:a};new Function("module","exports",o)(i,a),e[r]=i.exports}catch{}}}for(let t of j.JSON){let s=_.join(this.cacheDir,t);if(n.existsSync(s)){let r=t.replace(".json",""),o=n.readFileSync(s,"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,s;try{n.mkdirSync(this.cacheDir,{recursive:!0});let r={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(r,null,2));let o=["tokens","variables","semanticVariables","semanticDarkVariables","cls","custom"];for(let i of o)if(e[i]!==void 0){let l=_.join(this.cacheDir,`${i}.js`),h=`module.exports = ${JSON.stringify(e[i],null,2)};`;n.writeFileSync(l,h)}let a={fonts:e.fonts,icons:e.icons||e.iconSet,"components-config":e.componentsConfig,version:e.version};for(let[i,l]of Object.entries(a))if(l!==void 0){let h=_.join(this.cacheDir,`${i}.json`);n.writeFileSync(h,JSON.stringify(l,null,2))}}catch(r){throw new x(`Failed to save cache: ${r.message}`,"write")}}clear(){this.exists()&&n.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 s=D(),r=new s((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
|
+
globalThis.__FF_CONFIG__ = null;
|
|
3
|
+
globalThis.__FF_ICONS__ = null;
|
|
4
|
+
`;let o;try{o=r.load()}catch{return console.error("[FrontFriend Vite] Failed to load cache."),`
|
|
5
|
+
globalThis.__FF_CONFIG__ = null;
|
|
6
|
+
globalThis.__FF_ICONS__ = null;
|
|
7
|
+
`}if(!o)return console.error("[FrontFriend Vite] Failed to load cache."),`
|
|
8
|
+
globalThis.__FF_CONFIG__ = null;
|
|
9
|
+
globalThis.__FF_ICONS__ = null;
|
|
10
|
+
`;let a=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(a)};
|
|
12
|
+
globalThis.__FF_ICONS__ = ${JSON.stringify(i)};
|
|
13
|
+
`}catch{return`
|
|
14
|
+
globalThis.__FF_CONFIG__ = null;
|
|
15
|
+
globalThis.__FF_ICONS__ = null;
|
|
16
|
+
`}return null}}};
|
|
17
|
+
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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(data[key], null, 2)};`;\n fs.writeFileSync(filePath, content);\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,iDAGlBC,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,EAEAJ,EAAO,QAAU,CACf,gBAAAC,EACA,eAAAC,EACA,iBACA,oBACA,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AC,CAE7D,CACF,EAEAD,EAAO,QAAUO,IClLjB,OAAO,QAAU,UAAsB,CAErC,IAAIiB,EAEJ,MAAO,CACL,KAAM,uBACN,eAAeC,EAAgB,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", "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", "jsonData", "value", "config", "resolvedConfig", "id", "CacheManager", "cacheManager", "cache", "componentsConfig", "icons"]
|
|
7
|
+
}
|
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"fs";import o from"path";function a(){let i=null,r=null;return{name:"vite-plugin-frontfriend",config(){try{let n=o.join(process.cwd(),"node_modules",".cache","frontfriend");if(!e.existsSync(n))return console.warn('[FrontFriend Vite] No cache found. Please run "npx frontfriend init" first.'),{define:{__FF_CONFIG__:JSON.stringify({}),__FF_ICONS__:JSON.stringify({})}};let t=o.join(n,"components-config.json");e.existsSync(t)&&(i=JSON.parse(e.readFileSync(t,"utf-8")));let s=o.join(n,"icons.json");e.existsSync(s)&&(r=JSON.parse(e.readFileSync(s,"utf-8"))),!i&&!r&&console.warn('[FrontFriend Vite] Cache directory exists but no cache files found. Please run "npx frontfriend init" to refresh.')}catch(n){console.error("[FrontFriend Vite] Failed to load cache:",n.message)}return{define:{__FF_CONFIG__:JSON.stringify(i||{}),__FF_ICONS__:JSON.stringify(r||{})}}}}}export{a as frontfriendPlugin};
|
|
2
|
+
//# sourceMappingURL=vite.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../vite.mjs"],
|
|
4
|
+
"sourcesContent": ["// Vite plugin for FrontFriend Tailwind\nimport fs from 'fs';\nimport path from 'path';\n\nexport function frontfriendPlugin() {\n let config = null;\n let icons = null;\n\n return {\n name: 'vite-plugin-frontfriend',\n \n config() {\n // Load cache during config phase\n try {\n const cacheDir = path.join(process.cwd(), 'node_modules', '.cache', 'frontfriend');\n \n // Check if cache directory exists\n if (!fs.existsSync(cacheDir)) {\n console.warn('[FrontFriend Vite] No cache found. Please run \"npx frontfriend init\" first.');\n return {\n define: {\n __FF_CONFIG__: JSON.stringify({}),\n __FF_ICONS__: JSON.stringify({})\n }\n };\n }\n \n const configPath = path.join(cacheDir, 'components-config.json');\n if (fs.existsSync(configPath)) {\n config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));\n }\n \n const iconsPath = path.join(cacheDir, 'icons.json');\n if (fs.existsSync(iconsPath)) {\n icons = JSON.parse(fs.readFileSync(iconsPath, 'utf-8'));\n }\n \n // Warn if cache files don't exist\n if (!config && !icons) {\n console.warn('[FrontFriend Vite] Cache directory exists but no cache files found. Please run \"npx frontfriend init\" to refresh.');\n }\n } catch (error) {\n console.error('[FrontFriend Vite] Failed to load cache:', error.message);\n }\n\n // Define global constants\n return {\n define: {\n __FF_CONFIG__: JSON.stringify(config || {}),\n __FF_ICONS__: JSON.stringify(icons || {})\n }\n };\n }\n };\n}"],
|
|
5
|
+
"mappings": "AACA,OAAOA,MAAQ,KACf,OAAOC,MAAU,OAEV,SAASC,GAAoB,CAClC,IAAIC,EAAS,KACTC,EAAQ,KAEZ,MAAO,CACL,KAAM,0BAEN,QAAS,CAEP,GAAI,CACF,IAAMC,EAAWJ,EAAK,KAAK,QAAQ,IAAI,EAAG,eAAgB,SAAU,aAAa,EAGjF,GAAI,CAACD,EAAG,WAAWK,CAAQ,EACzB,eAAQ,KAAK,6EAA6E,EACnF,CACL,OAAQ,CACN,cAAe,KAAK,UAAU,CAAC,CAAC,EAChC,aAAc,KAAK,UAAU,CAAC,CAAC,CACjC,CACF,EAGF,IAAMC,EAAaL,EAAK,KAAKI,EAAU,wBAAwB,EAC3DL,EAAG,WAAWM,CAAU,IAC1BH,EAAS,KAAK,MAAMH,EAAG,aAAaM,EAAY,OAAO,CAAC,GAG1D,IAAMC,EAAYN,EAAK,KAAKI,EAAU,YAAY,EAC9CL,EAAG,WAAWO,CAAS,IACzBH,EAAQ,KAAK,MAAMJ,EAAG,aAAaO,EAAW,OAAO,CAAC,GAIpD,CAACJ,GAAU,CAACC,GACd,QAAQ,KAAK,mHAAmH,CAEpI,OAASI,EAAO,CACd,QAAQ,MAAM,2CAA4CA,EAAM,OAAO,CACzE,CAGA,MAAO,CACL,OAAQ,CACN,cAAe,KAAK,UAAUL,GAAU,CAAC,CAAC,EAC1C,aAAc,KAAK,UAAUC,GAAS,CAAC,CAAC,CAC1C,CACF,CACF,CACF,CACF",
|
|
6
|
+
"names": ["fs", "path", "frontfriendPlugin", "config", "icons", "cacheDir", "configPath", "iconsPath", "error"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@frontfriend/tailwind",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Design token management for Tailwind CSS",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/types/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"frontfriend": "./dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./runtime": "./dist/runtime.js",
|
|
17
|
+
"./next": "./dist/next.js",
|
|
18
|
+
"./vite": "./dist/vite.mjs",
|
|
19
|
+
"./lib/react/utils": "./dist/lib/react/utils.mjs",
|
|
20
|
+
"./lib/vue/utils": "./dist/lib/vue/utils.mjs",
|
|
21
|
+
"./ffdc": "./dist/ffdc.js"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "jest",
|
|
25
|
+
"build": "node scripts/build.js",
|
|
26
|
+
"prepublishOnly": "npm run build"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"tailwindcss",
|
|
30
|
+
"design-tokens",
|
|
31
|
+
"frontfriend"
|
|
32
|
+
],
|
|
33
|
+
"author": "Donux",
|
|
34
|
+
"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
|
+
"files": [
|
|
44
|
+
"dist/",
|
|
45
|
+
"README.md",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"commander": "^11.0.0",
|
|
50
|
+
"dotenv": "^16.0.0",
|
|
51
|
+
"color": "^4.2.3",
|
|
52
|
+
"clsx": "^2.0.0",
|
|
53
|
+
"tailwind-merge": "^2.0.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"tailwindcss": "^3.0.0",
|
|
57
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
58
|
+
"vue": ">=3.0.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"jest": "^29.0.0",
|
|
62
|
+
"esbuild": "^0.19.0",
|
|
63
|
+
"glob": "^10.0.0"
|
|
64
|
+
}
|
|
65
|
+
}
|