@frontfriend/tailwind 2.5.2 → 2.5.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/index.mjs +1 -1
- package/dist/index.mjs.map +2 -2
- package/dist/next.js +1 -1
- package/dist/next.js.map +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o=typeof window<"u"&&typeof window.document<"u",
|
|
1
|
+
var o=typeof window<"u"&&typeof window.document<"u",u=typeof process<"u"&&process.versions&&process.versions.node,i=function(){return o&&console.warn("[FrontFriend] The Tailwind plugin cannot be used directly in browser environments"),{}};function p(e){return!e||typeof e!="object"?new Proxy({},{get(n,_){return new Proxy({},{get(F,f){return new Proxy({},{get(){return""}})}})}}):e}var r=null,t=null;function s(){if(typeof __FF_CONFIG__<"u")return __FF_CONFIG__;if(typeof process<"u"&&process.env){if(process.env.NEXT_PUBLIC_FF_CONFIG)try{return JSON.parse(process.env.NEXT_PUBLIC_FF_CONFIG)}catch{console.warn("[FrontFriend] Failed to parse NEXT_PUBLIC_FF_CONFIG from environment")}if(process.env.__FF_CONFIG__)try{return JSON.parse(process.env.__FF_CONFIG__)}catch{console.warn("[FrontFriend] Failed to parse __FF_CONFIG__ from environment")}}return o&&window.__FF_CONFIG__?window.__FF_CONFIG__:null}function c(){if(typeof __FF_ICONS__<"u")return __FF_ICONS__;if(typeof process<"u"&&process.env){if(process.env.NEXT_PUBLIC_FF_ICONS)try{return JSON.parse(process.env.NEXT_PUBLIC_FF_ICONS)}catch{console.warn("[FrontFriend] Failed to parse NEXT_PUBLIC_FF_ICONS from environment")}if(process.env.__FF_ICONS__)try{return JSON.parse(process.env.__FF_ICONS__)}catch{console.warn("[FrontFriend] Failed to parse __FF_ICONS__ from environment")}}return o&&window.__FF_ICONS__?window.__FF_ICONS__:null}var d=new Proxy({},{get(e,n){return r||(r=s()),r&&n in r?r[n]:new Proxy({},{get(_,F){return new Proxy({},{get(){return""}})}})}}),N=new Proxy({},{get(e,n){return t||(t=c()),t&&n in t?t[n]:null}}),a=i;export{d as config,a as default,p as ffdc,N as iconSet};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../index.mjs"],
|
|
4
|
-
"sourcesContent": ["// ES Module wrapper for frontfriend-tailwind\n// This file provides ES module exports for browser environments\n\n// Determine environment\nconst isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';\nconst isNode = typeof process !== 'undefined' && process.versions && process.versions.node;\n\n// Default plugin stub for browser\nconst plugin = function() {\n if (isBrowser) {\n console.warn('[FrontFriend] The Tailwind plugin cannot be used directly in browser environments');\n }\n return {};\n};\n\n// The ffdc function - with graceful fallback for SSR\nexport function ffdc(config) {\n // During SSR or initial load, config might not be available yet\n // Return a proxy that provides empty objects/strings for any property access\n if (!config || typeof config !== 'object') {\n return new Proxy({}, {\n get(target, prop) {\n // Return another proxy for nested property access\n return new Proxy({}, {\n get(target2, prop2) {\n // For deeply nested properties, return empty string or another proxy\n return new Proxy({}, {\n get() {\n return '';\n }\n });\n }\n });\n }\n });\n }\n \n return config;\n}\n\n// In browser environments, config and iconSet must be provided by the build system\n// (e.g., Vite plugin, webpack plugin, etc.) or loaded from a global variable\nlet _config = null;\nlet _iconSet = null;\n\n// Function to get config - tries multiple sources\nfunction getConfig() {\n // Try global variable first (webpack DefinePlugin)\n if (typeof __FF_CONFIG__ !== 'undefined') {\n return __FF_CONFIG__;\n }\n // Try environment variable (Turbopack compatibility)\n if (typeof process !== 'undefined' && process.env
|
|
5
|
-
"mappings": "AAIA,IAAMA,EAAY,OAAO,OAAW,KAAe,OAAO,OAAO,SAAa,IACxEC,EAAS,OAAO,QAAY,KAAe,QAAQ,UAAY,QAAQ,SAAS,KAGhFC,EAAS,UAAW,CACxB,OAAIF,GACF,QAAQ,KAAK,mFAAmF,EAE3F,CAAC,CACV,EAGO,SAASG,EAAKC,EAAQ,CAG3B,MAAI,CAACA,GAAU,OAAOA,GAAW,SACxB,IAAI,MAAM,CAAC,EAAG,CACnB,IAAIC,EAAQC,EAAM,CAEhB,OAAO,IAAI,MAAM,CAAC,EAAG,CACnB,IAAIC,EAASC,EAAO,CAElB,OAAO,IAAI,MAAM,CAAC,EAAG,CACnB,KAAM,CACJ,MAAO,EACT,CACF,CAAC,CACH,CACF,CAAC,CACH,CACF,CAAC,EAGIJ,CACT,CAIA,IAAIK,EAAU,KACVC,EAAW,KAGf,SAASC,GAAY,CAEnB,GAAI,OAAO,cAAkB,IAC3B,OAAO,cAGT,GAAI,OAAO,QAAY,KAAe,QAAQ,
|
|
4
|
+
"sourcesContent": ["// ES Module wrapper for frontfriend-tailwind\n// This file provides ES module exports for browser environments\n\n// Determine environment\nconst isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';\nconst isNode = typeof process !== 'undefined' && process.versions && process.versions.node;\n\n// Default plugin stub for browser\nconst plugin = function() {\n if (isBrowser) {\n console.warn('[FrontFriend] The Tailwind plugin cannot be used directly in browser environments');\n }\n return {};\n};\n\n// The ffdc function - with graceful fallback for SSR\nexport function ffdc(config) {\n // During SSR or initial load, config might not be available yet\n // Return a proxy that provides empty objects/strings for any property access\n if (!config || typeof config !== 'object') {\n return new Proxy({}, {\n get(target, prop) {\n // Return another proxy for nested property access\n return new Proxy({}, {\n get(target2, prop2) {\n // For deeply nested properties, return empty string or another proxy\n return new Proxy({}, {\n get() {\n return '';\n }\n });\n }\n });\n }\n });\n }\n \n return config;\n}\n\n// In browser environments, config and iconSet must be provided by the build system\n// (e.g., Vite plugin, webpack plugin, etc.) or loaded from a global variable\nlet _config = null;\nlet _iconSet = null;\n\n// Function to get config - tries multiple sources\nfunction getConfig() {\n // Try global variable first (webpack DefinePlugin)\n if (typeof __FF_CONFIG__ !== 'undefined') {\n return __FF_CONFIG__;\n }\n // Try Next.js environment variable (Turbopack compatibility)\n if (typeof process !== 'undefined' && process.env) {\n // Try NEXT_PUBLIC_ prefixed version first (Next.js requirement)\n if (process.env.NEXT_PUBLIC_FF_CONFIG) {\n try {\n return JSON.parse(process.env.NEXT_PUBLIC_FF_CONFIG);\n } catch (e) {\n console.warn('[FrontFriend] Failed to parse NEXT_PUBLIC_FF_CONFIG from environment');\n }\n }\n // Fallback to __ prefixed version for non-Next.js environments\n if (process.env.__FF_CONFIG__) {\n try {\n return JSON.parse(process.env.__FF_CONFIG__);\n } catch (e) {\n console.warn('[FrontFriend] Failed to parse __FF_CONFIG__ from environment');\n }\n }\n }\n // Try window global\n if (isBrowser && window.__FF_CONFIG__) {\n return window.__FF_CONFIG__;\n }\n return null;\n}\n\n// Function to get icons - tries multiple sources\nfunction getIcons() {\n // Try global variable first (webpack DefinePlugin)\n if (typeof __FF_ICONS__ !== 'undefined') {\n return __FF_ICONS__;\n }\n // Try Next.js environment variable (Turbopack compatibility)\n if (typeof process !== 'undefined' && process.env) {\n // Try NEXT_PUBLIC_ prefixed version first (Next.js requirement)\n if (process.env.NEXT_PUBLIC_FF_ICONS) {\n try {\n return JSON.parse(process.env.NEXT_PUBLIC_FF_ICONS);\n } catch (e) {\n console.warn('[FrontFriend] Failed to parse NEXT_PUBLIC_FF_ICONS from environment');\n }\n }\n // Fallback to __ prefixed version for non-Next.js environments\n if (process.env.__FF_ICONS__) {\n try {\n return JSON.parse(process.env.__FF_ICONS__);\n } catch (e) {\n console.warn('[FrontFriend] Failed to parse __FF_ICONS__ from environment');\n }\n }\n }\n // Try window global\n if (isBrowser && window.__FF_ICONS__) {\n return window.__FF_ICONS__;\n }\n return null;\n}\n\n// Export config - returns empty object if not loaded\nexport const config = new Proxy({}, {\n get(target, prop) {\n // Try to get config if not already loaded\n if (!_config) {\n _config = getConfig();\n }\n \n if (_config && prop in _config) {\n return _config[prop];\n }\n \n // Return a proxy that provides empty objects for any nested access\n // This prevents errors when accessing nested properties during SSR\n return new Proxy({}, {\n get(target2, prop2) {\n return new Proxy({}, {\n get() {\n return '';\n }\n });\n }\n });\n }\n});\n\n// Export iconSet - returns null if not loaded\nexport const iconSet = new Proxy({}, {\n get(target, prop) {\n // Try to get icons if not already loaded\n if (!_iconSet) {\n _iconSet = getIcons();\n }\n \n if (_iconSet && prop in _iconSet) {\n return _iconSet[prop];\n }\n return null;\n }\n});\n\n// Default export\nexport default plugin;"],
|
|
5
|
+
"mappings": "AAIA,IAAMA,EAAY,OAAO,OAAW,KAAe,OAAO,OAAO,SAAa,IACxEC,EAAS,OAAO,QAAY,KAAe,QAAQ,UAAY,QAAQ,SAAS,KAGhFC,EAAS,UAAW,CACxB,OAAIF,GACF,QAAQ,KAAK,mFAAmF,EAE3F,CAAC,CACV,EAGO,SAASG,EAAKC,EAAQ,CAG3B,MAAI,CAACA,GAAU,OAAOA,GAAW,SACxB,IAAI,MAAM,CAAC,EAAG,CACnB,IAAIC,EAAQC,EAAM,CAEhB,OAAO,IAAI,MAAM,CAAC,EAAG,CACnB,IAAIC,EAASC,EAAO,CAElB,OAAO,IAAI,MAAM,CAAC,EAAG,CACnB,KAAM,CACJ,MAAO,EACT,CACF,CAAC,CACH,CACF,CAAC,CACH,CACF,CAAC,EAGIJ,CACT,CAIA,IAAIK,EAAU,KACVC,EAAW,KAGf,SAASC,GAAY,CAEnB,GAAI,OAAO,cAAkB,IAC3B,OAAO,cAGT,GAAI,OAAO,QAAY,KAAe,QAAQ,IAAK,CAEjD,GAAI,QAAQ,IAAI,sBACd,GAAI,CACF,OAAO,KAAK,MAAM,QAAQ,IAAI,qBAAqB,CACrD,MAAY,CACV,QAAQ,KAAK,sEAAsE,CACrF,CAGF,GAAI,QAAQ,IAAI,cACd,GAAI,CACF,OAAO,KAAK,MAAM,QAAQ,IAAI,aAAa,CAC7C,MAAY,CACV,QAAQ,KAAK,8DAA8D,CAC7E,CAEJ,CAEA,OAAIX,GAAa,OAAO,cACf,OAAO,cAET,IACT,CAGA,SAASY,GAAW,CAElB,GAAI,OAAO,aAAiB,IAC1B,OAAO,aAGT,GAAI,OAAO,QAAY,KAAe,QAAQ,IAAK,CAEjD,GAAI,QAAQ,IAAI,qBACd,GAAI,CACF,OAAO,KAAK,MAAM,QAAQ,IAAI,oBAAoB,CACpD,MAAY,CACV,QAAQ,KAAK,qEAAqE,CACpF,CAGF,GAAI,QAAQ,IAAI,aACd,GAAI,CACF,OAAO,KAAK,MAAM,QAAQ,IAAI,YAAY,CAC5C,MAAY,CACV,QAAQ,KAAK,6DAA6D,CAC5E,CAEJ,CAEA,OAAIZ,GAAa,OAAO,aACf,OAAO,aAET,IACT,CAGO,IAAMI,EAAS,IAAI,MAAM,CAAC,EAAG,CAClC,IAAIC,EAAQC,EAAM,CAMhB,OAJKG,IACHA,EAAUE,EAAU,GAGlBF,GAAWH,KAAQG,EACdA,EAAQH,CAAI,EAKd,IAAI,MAAM,CAAC,EAAG,CACnB,IAAIC,EAASC,EAAO,CAClB,OAAO,IAAI,MAAM,CAAC,EAAG,CACnB,KAAM,CACJ,MAAO,EACT,CACF,CAAC,CACH,CACF,CAAC,CACH,CACF,CAAC,EAGYK,EAAU,IAAI,MAAM,CAAC,EAAG,CACnC,IAAIR,EAAQC,EAAM,CAMhB,OAJKI,IACHA,EAAWE,EAAS,GAGlBF,GAAYJ,KAAQI,EACfA,EAASJ,CAAI,EAEf,IACT,CACF,CAAC,EAGMQ,EAAQZ",
|
|
6
6
|
"names": ["isBrowser", "isNode", "plugin", "ffdc", "config", "target", "prop", "target2", "prop2", "_config", "_iconSet", "getConfig", "getIcons", "iconSet", "frontfriend_tailwind_default"]
|
|
7
7
|
}
|
package/dist/next.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var u=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var S=u((
|
|
1
|
+
var u=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var S=u((W,m)=>{var L="https://app.frontfriend.dev",T="https://tokens-studio-donux.up.railway.app/api",k=".cache/frontfriend",P={JS:["tokens.js","variables.js","semanticVariables.js","semanticDarkVariables.js","safelist.js","custom.js"],JSON:["fonts.json","icons.json","components-config.json","version.json","metadata.json"]},J={FF_ID:"FF_ID",FF_API_URL:"FF_API_URL",FF_USE_LOCAL:"FF_USE_LOCAL"};m.exports={DEFAULT_API_URL:L,LEGACY_API_URL:T,CACHE_DIR_NAME:k,CACHE_TTL_DAYS:7,CACHE_TTL_MS:6048e5,CACHE_FILES:P,ENV_VARS:J}});var C=u((Z,y)=>{var h=class extends Error{constructor(e,t,n){super(e),this.name="APIError",this.statusCode=t,this.url=n,this.code=`API_${t}`}},p=class extends Error{constructor(e,t){super(e),this.name="CacheError",this.operation=t,this.code=`CACHE_${t.toUpperCase()}`}},_=class extends Error{constructor(e,t){super(e),this.name="ConfigError",this.field=t,this.code=`CONFIG_${t.toUpperCase()}`}},d=class extends Error{constructor(e,t){super(e),this.name="ProcessingError",this.token=t,this.code="PROCESSING_ERROR"}};y.exports={APIError:h,CacheError:p,ConfigError:_,ProcessingError:d}});var A=u((ee,E)=>{var c=require("fs");function b(s){try{let e=c.readFileSync(s,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function H(s){try{return c.readFileSync(s,"utf8")}catch(e){if(e.code==="ENOENT")return null;throw e}}function R(s,e,t=2){let n=JSON.stringify(e,null,t);c.writeFileSync(s,n,"utf8")}function U(s,e){if(e==null||typeof e=="object"&&Object.keys(e).length===0||Array.isArray(e)&&e.length===0){let n=`module.exports = ${Array.isArray(e)?"[]":"{}"};`;c.writeFileSync(s,n,"utf8")}else{let t=`module.exports = ${JSON.stringify(e,null,2)};`;c.writeFileSync(s,t,"utf8")}}function M(s){return c.existsSync(s)}function $(s){c.mkdirSync(s,{recursive:!0})}function V(s){c.rmSync(s,{recursive:!0,force:!0})}E.exports={readJsonFileSafe:b,readFileSafe:H,writeJsonFile:R,writeModuleExportsFile:U,fileExists:M,ensureDirectoryExists:$,removeDirectory:V}});var O=u((te,I)=>{var a=require("path"),{CACHE_DIR_NAME:q,CACHE_TTL_MS:G,CACHE_FILES:j}=S(),{CacheError:D}=C(),{readJsonFileSafe:w,readFileSafe:Y,writeJsonFile:x,writeModuleExportsFile:N,fileExists:g,ensureDirectoryExists:B,removeDirectory:X}=A(),F=class{constructor(e=process.cwd()){this.appRoot=e,this.cacheDir=a.join(e,"node_modules",q),this.metadataFile=a.join(this.cacheDir,"metadata.json"),this.maxAge=G}getCacheDir(){return this.cacheDir}exists(){return g(this.cacheDir)}isValid(){if(!this.exists())return!1;try{let e=w(this.metadataFile);if(!e)return!1;let 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=a.join(this.cacheDir,t);if(g(n)){let r=t.replace(".js","");try{let o=Y(n);if(o!==null){let l={},i={exports:l};new Function("module","exports",o)(i,l),e[r]=i.exports}}catch{}}}for(let t of j.JSON){let n=a.join(this.cacheDir,t),r=t.replace(".json",""),o=w(n);o!==null&&(e[r]=o)}return e["components-config"]&&(e.componentsConfig=e["components-config"],delete e["components-config"]),e.cls&&!e.safelist&&(e.safelist=e.cls,delete e.cls),e}catch(e){throw new D(`Failed to load cache: ${e.message}`,"read")}}save(e){var t,n;try{B(this.cacheDir);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};x(this.metadataFile,r);let o=["tokens","variables","semanticVariables","semanticDarkVariables","safelist","custom"];for(let i of o)if(e[i]!==void 0){let f=a.join(this.cacheDir,`${i}.js`);N(f,e[i])}if(e.safelist&&Array.isArray(e.safelist)){let i=a.join(this.cacheDir,"safelist.js");N(i,e.safelist)}let l={fonts:e.fonts,icons:e.icons||e.iconSet,"components-config":e.componentsConfig,version:e.version};for(let[i,f]of Object.entries(l))if(f!==void 0){let v=a.join(this.cacheDir,`${i}.json`);x(v,f)}}catch(r){throw new D(`Failed to save cache: ${r.message}`,"write")}}clear(){this.exists()&&X(this.cacheDir)}};I.exports=F});var z=O();function K(s={}){let e=new z(process.cwd()),t=null;return e.exists()?t=e.load():console.warn('[FrontFriend Next.js] No cache found. Please run "npx frontfriend init" first.'),{...s,env:{...s.env,NEXT_PUBLIC_FF_CONFIG:t?JSON.stringify(t.componentsConfig||null):"null",NEXT_PUBLIC_FF_ICONS:t?JSON.stringify(t.icons||null):"null"},webpack:(n,r)=>{if(typeof s.webpack=="function"&&(n=s.webpack(n,r)),!t)return n;let{webpack:o}=r,l=o.DefinePlugin,i={__FF_CONFIG__:JSON.stringify(t.componentsConfig||null),__FF_ICONS__:JSON.stringify(t.icons||null)};return n.plugins=n.plugins||[],n.plugins.push(new l(i)),r.dev&&!r.isServer&&console.log("[FrontFriend Next.js] Injected configuration and icons into client build"),n}}}module.exports=K;
|
|
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/file-utils.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://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 'safelist.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 FF_USE_LOCAL: 'FF_USE_LOCAL'\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');\n\n/**\n * Read a JSON file safely, returning null if file doesn't exist\n * @param {string} filepath - Path to the JSON file\n * @returns {Object|null} Parsed JSON or null if file not found\n * @throws {Error} If JSON is invalid\n */\nfunction readJsonFileSafe(filepath) {\n try {\n const content = fs.readFileSync(filepath, 'utf8');\n return JSON.parse(content);\n } catch (error) {\n if (error.code === 'ENOENT') {\n return null; // File not found, return null like API would return 404\n }\n throw error;\n }\n}\n\n/**\n * Read a file safely, returning null if file doesn't exist\n * @param {string} filepath - Path to the file\n * @returns {string|null} File content or null if file not found\n * @throws {Error} For other file system errors\n */\nfunction readFileSafe(filepath) {\n try {\n return fs.readFileSync(filepath, 'utf8');\n } catch (error) {\n if (error.code === 'ENOENT') {\n return null; // File not found\n }\n throw error;\n }\n}\n\n/**\n * Write JSON data to a file with proper formatting\n * @param {string} filepath - Path to write the file\n * @param {Object} data - Data to write\n * @param {number} indent - Indentation level (default: 2)\n */\nfunction writeJsonFile(filepath, data, indent = 2) {\n const content = JSON.stringify(data, null, indent);\n fs.writeFileSync(filepath, content, 'utf8');\n}\n\n/**\n * Write module.exports file with JSON data\n * @param {string} filepath - Path to write the file\n * @param {Object} data - Data to export\n */\nfunction writeModuleExportsFile(filepath, data) {\n // Handle empty data cases\n if (data === null || data === undefined || \n (typeof data === 'object' && Object.keys(data).length === 0) ||\n (Array.isArray(data) && data.length === 0)) {\n const emptyContent = Array.isArray(data) ? '[]' : '{}';\n const content = `module.exports = ${emptyContent};`;\n fs.writeFileSync(filepath, content, 'utf8');\n } else {\n const content = `module.exports = ${JSON.stringify(data, null, 2)};`;\n fs.writeFileSync(filepath, content, 'utf8');\n }\n}\n\n/**\n * Check if a file exists\n * @param {string} filepath - Path to check\n * @returns {boolean} True if file exists\n */\nfunction fileExists(filepath) {\n return fs.existsSync(filepath);\n}\n\n/**\n * Create directory recursively\n * @param {string} dirpath - Directory path to create\n */\nfunction ensureDirectoryExists(dirpath) {\n fs.mkdirSync(dirpath, { recursive: true });\n}\n\n/**\n * Remove directory recursively\n * @param {string} dirpath - Directory path to remove\n */\nfunction removeDirectory(dirpath) {\n fs.rmSync(dirpath, { recursive: true, force: true });\n}\n\nmodule.exports = {\n readJsonFileSafe,\n readFileSafe,\n writeJsonFile,\n writeModuleExportsFile,\n fileExists,\n ensureDirectoryExists,\n removeDirectory\n};", "const path = require('path');\nconst { CACHE_DIR_NAME, CACHE_TTL_MS, CACHE_FILES } = require('./constants');\nconst { CacheError } = require('./errors');\nconst { readJsonFileSafe, readFileSafe, writeJsonFile, writeModuleExportsFile, fileExists, ensureDirectoryExists, removeDirectory } = require('./file-utils');\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 fileExists(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 const metadata = readJsonFileSafe(this.metadataFile);\n if (!metadata) {\n return false;\n }\n\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 (fileExists(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 = readFileSafe(filePath);\n if (content !== null) {\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 }\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 const key = file.replace('.json', '');\n const content = readJsonFileSafe(filePath);\n if (content !== null) {\n data[key] = 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 // Backward compatibility: rename cls to safelist if present\n if (data.cls && !data.safelist) {\n data.safelist = data.cls;\n delete data.cls;\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 ensureDirectoryExists(this.cacheDir);\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 writeJsonFile(this.metadataFile, metadata);\n\n // Save .js files\n const jsFiles = [\n 'tokens',\n 'variables',\n 'semanticVariables',\n 'semanticDarkVariables',\n 'safelist',\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 writeModuleExportsFile(filePath, data[key]);\n }\n }\n \n // Also check for safelist specifically since it might be an array\n if (data.safelist && Array.isArray(data.safelist)) {\n const safelistPath = path.join(this.cacheDir, 'safelist.js');\n writeModuleExportsFile(safelistPath, data.safelist);\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 writeJsonFile(filePath, value);\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 removeDirectory(this.cacheDir);\n }\n }\n}\n\nmodule.exports = CacheManager;", "const CacheManager = require('./lib/core/cache-manager');\n\nfunction frontfriend(nextConfig = {}) {\n // Load cache once at config time\n const cacheManager = new CacheManager(process.cwd());\n let cache = null;\n\n if (cacheManager.exists()) {\n cache = cacheManager.load();\n } else {\n console.warn('[FrontFriend Next.js] No cache found. Please run \"npx frontfriend init\" first.');\n }\n\n return {\n ...nextConfig,\n // Environment variables work with both webpack and Turbopack\n env: {\n ...nextConfig.env,\n // Inject config as environment variables for Turbopack compatibility\n __FF_CONFIG__: cache ? JSON.stringify(cache.componentsConfig || null) : 'null',\n __FF_ICONS__: cache ? JSON.stringify(cache.icons || null) : 'null',\n },\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 if (!cache) {\n return config;\n }\n\n // 4. Use webpack.DefinePlugin from options (works with both webpack 4 and 5)\n // This is for webpack - Turbopack will use the env vars above\n const { webpack } = options;\n const DefinePlugin = webpack.DefinePlugin;\n\n // 5. Inject __FF_CONFIG__ and __FF_ICONS__ as globals for webpack\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 = frontfriend;"],
|
|
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,cACA,WACF,EACA,KAAM,CACJ,aACA,aACA,yBACA,eACA,eACF,CACF,EAGMC,EAAW,CACf,MAAO,QACP,WAAY,aACZ,aAAc,cAChB,EAEAL,EAAO,QAAU,CACf,gBAAAC,EACA,eAAAC,EACA,eAAAC,EACA,iBACA,oBACA,YAAAC,EACA,SAAAC,CACF,IC/CA,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,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AID,EAAa,OAAO,EACtBC,EAAQD,EAAa,KAAK,EAE1B,QAAQ,KAAK,gFAAgF,EAGxF,CACL,GAAGD,EAEH,IAAK,CACH,GAAGA,EAAW,
|
|
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 'safelist.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 FF_USE_LOCAL: 'FF_USE_LOCAL'\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');\n\n/**\n * Read a JSON file safely, returning null if file doesn't exist\n * @param {string} filepath - Path to the JSON file\n * @returns {Object|null} Parsed JSON or null if file not found\n * @throws {Error} If JSON is invalid\n */\nfunction readJsonFileSafe(filepath) {\n try {\n const content = fs.readFileSync(filepath, 'utf8');\n return JSON.parse(content);\n } catch (error) {\n if (error.code === 'ENOENT') {\n return null; // File not found, return null like API would return 404\n }\n throw error;\n }\n}\n\n/**\n * Read a file safely, returning null if file doesn't exist\n * @param {string} filepath - Path to the file\n * @returns {string|null} File content or null if file not found\n * @throws {Error} For other file system errors\n */\nfunction readFileSafe(filepath) {\n try {\n return fs.readFileSync(filepath, 'utf8');\n } catch (error) {\n if (error.code === 'ENOENT') {\n return null; // File not found\n }\n throw error;\n }\n}\n\n/**\n * Write JSON data to a file with proper formatting\n * @param {string} filepath - Path to write the file\n * @param {Object} data - Data to write\n * @param {number} indent - Indentation level (default: 2)\n */\nfunction writeJsonFile(filepath, data, indent = 2) {\n const content = JSON.stringify(data, null, indent);\n fs.writeFileSync(filepath, content, 'utf8');\n}\n\n/**\n * Write module.exports file with JSON data\n * @param {string} filepath - Path to write the file\n * @param {Object} data - Data to export\n */\nfunction writeModuleExportsFile(filepath, data) {\n // Handle empty data cases\n if (data === null || data === undefined || \n (typeof data === 'object' && Object.keys(data).length === 0) ||\n (Array.isArray(data) && data.length === 0)) {\n const emptyContent = Array.isArray(data) ? '[]' : '{}';\n const content = `module.exports = ${emptyContent};`;\n fs.writeFileSync(filepath, content, 'utf8');\n } else {\n const content = `module.exports = ${JSON.stringify(data, null, 2)};`;\n fs.writeFileSync(filepath, content, 'utf8');\n }\n}\n\n/**\n * Check if a file exists\n * @param {string} filepath - Path to check\n * @returns {boolean} True if file exists\n */\nfunction fileExists(filepath) {\n return fs.existsSync(filepath);\n}\n\n/**\n * Create directory recursively\n * @param {string} dirpath - Directory path to create\n */\nfunction ensureDirectoryExists(dirpath) {\n fs.mkdirSync(dirpath, { recursive: true });\n}\n\n/**\n * Remove directory recursively\n * @param {string} dirpath - Directory path to remove\n */\nfunction removeDirectory(dirpath) {\n fs.rmSync(dirpath, { recursive: true, force: true });\n}\n\nmodule.exports = {\n readJsonFileSafe,\n readFileSafe,\n writeJsonFile,\n writeModuleExportsFile,\n fileExists,\n ensureDirectoryExists,\n removeDirectory\n};", "const path = require('path');\nconst { CACHE_DIR_NAME, CACHE_TTL_MS, CACHE_FILES } = require('./constants');\nconst { CacheError } = require('./errors');\nconst { readJsonFileSafe, readFileSafe, writeJsonFile, writeModuleExportsFile, fileExists, ensureDirectoryExists, removeDirectory } = require('./file-utils');\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 fileExists(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 const metadata = readJsonFileSafe(this.metadataFile);\n if (!metadata) {\n return false;\n }\n\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 (fileExists(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 = readFileSafe(filePath);\n if (content !== null) {\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 }\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 const key = file.replace('.json', '');\n const content = readJsonFileSafe(filePath);\n if (content !== null) {\n data[key] = 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 // Backward compatibility: rename cls to safelist if present\n if (data.cls && !data.safelist) {\n data.safelist = data.cls;\n delete data.cls;\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 ensureDirectoryExists(this.cacheDir);\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 writeJsonFile(this.metadataFile, metadata);\n\n // Save .js files\n const jsFiles = [\n 'tokens',\n 'variables',\n 'semanticVariables',\n 'semanticDarkVariables',\n 'safelist',\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 writeModuleExportsFile(filePath, data[key]);\n }\n }\n \n // Also check for safelist specifically since it might be an array\n if (data.safelist && Array.isArray(data.safelist)) {\n const safelistPath = path.join(this.cacheDir, 'safelist.js');\n writeModuleExportsFile(safelistPath, data.safelist);\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 writeJsonFile(filePath, value);\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 removeDirectory(this.cacheDir);\n }\n }\n}\n\nmodule.exports = CacheManager;", "const CacheManager = require('./lib/core/cache-manager');\n\nfunction frontfriend(nextConfig = {}) {\n // Load cache once at config time\n const cacheManager = new CacheManager(process.cwd());\n let cache = null;\n\n if (cacheManager.exists()) {\n cache = cacheManager.load();\n } else {\n console.warn('[FrontFriend Next.js] No cache found. Please run \"npx frontfriend init\" first.');\n }\n\n return {\n ...nextConfig,\n // Environment variables work with both webpack and Turbopack\n env: {\n ...nextConfig.env,\n // Inject config as environment variables for Turbopack compatibility\n // Using NEXT_PUBLIC_ prefix as Next.js doesn't allow __ prefixed keys\n NEXT_PUBLIC_FF_CONFIG: cache ? JSON.stringify(cache.componentsConfig || null) : 'null',\n NEXT_PUBLIC_FF_ICONS: cache ? JSON.stringify(cache.icons || null) : 'null',\n },\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 if (!cache) {\n return config;\n }\n\n // 4. Use webpack.DefinePlugin from options (works with both webpack 4 and 5)\n // This is for webpack - Turbopack will use the env vars above\n const { webpack } = options;\n const DefinePlugin = webpack.DefinePlugin;\n\n // 5. Inject __FF_CONFIG__ and __FF_ICONS__ as globals for webpack\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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CAClD,EAGA,OAAAC,EAAO,QAAUA,EAAO,SAAW,CAAC,EACpCA,EAAO,QAAQ,KAAK,IAAIG,EAAaC,CAAW,CAAC,EAG7CH,EAAQ,KAAO,CAACA,EAAQ,UAC1B,QAAQ,IAAI,0EAA0E,EAIjFD,CACT,CACF,CACF,CAEA,OAAO,QAAUJ",
|
|
6
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_file_utils", "__commonJSMin", "exports", "module", "fs", "readJsonFileSafe", "filepath", "content", "error", "readFileSafe", "writeJsonFile", "data", "indent", "writeModuleExportsFile", "fileExists", "ensureDirectoryExists", "dirpath", "removeDirectory", "require_cache_manager", "__commonJSMin", "exports", "module", "path", "CACHE_DIR_NAME", "CACHE_TTL_MS", "CACHE_FILES", "CacheError", "readJsonFileSafe", "readFileSafe", "writeJsonFile", "writeModuleExportsFile", "fileExists", "ensureDirectoryExists", "removeDirectory", "CacheManager", "appRoot", "metadata", "timestamp", "data", "file", "filePath", "key", "content", "moduleExports", "fakeModule", "error", "_a", "_b", "jsFiles", "safelistPath", "jsonData", "value", "CacheManager", "frontfriend", "nextConfig", "cacheManager", "cache", "config", "options", "webpack", "DefinePlugin", "definitions"]
|
|
7
7
|
}
|