@frontfriend/tailwind 3.0.4 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +94 -1
  2. package/dist/browser.mjs +2 -0
  3. package/dist/browser.mjs.map +7 -0
  4. package/dist/cli.js +47 -41
  5. package/dist/components-config-schema.d.ts +2 -0
  6. package/dist/components-config-schema.js +2 -0
  7. package/dist/components-config-schema.js.map +7 -0
  8. package/dist/ffdc.d.ts +3 -1
  9. package/dist/ffdc.js +1 -1
  10. package/dist/ffdc.js.map +4 -4
  11. package/dist/index.js +3 -3
  12. package/dist/index.js.map +4 -4
  13. package/dist/index.mjs +1 -1
  14. package/dist/index.mjs.map +3 -3
  15. package/dist/lib/core/api-client.js +2 -1
  16. package/dist/lib/core/api-client.js.map +4 -4
  17. package/dist/lib/core/cache-manager.js +11 -2
  18. package/dist/lib/core/component-downloader.js +3 -2
  19. package/dist/lib/core/component-downloader.js.map +4 -4
  20. package/dist/lib/core/components-config-schema.js +2 -0
  21. package/dist/lib/core/components-config-schema.js.map +7 -0
  22. package/dist/lib/core/constants.js +1 -1
  23. package/dist/lib/core/constants.js.map +2 -2
  24. package/dist/lib/core/credentials.js +3 -0
  25. package/dist/lib/core/credentials.js.map +7 -0
  26. package/dist/lib/core/default-config-data.js +2 -0
  27. package/dist/lib/core/default-config-data.js.map +7 -0
  28. package/dist/lib/core/default-config.js +2 -0
  29. package/dist/lib/core/default-config.js.map +7 -0
  30. package/dist/lib/core/env-utils.js +1 -1
  31. package/dist/lib/core/env-utils.js.map +3 -3
  32. package/dist/lib/core/file-utils.js +1 -1
  33. package/dist/lib/core/file-utils.js.map +3 -3
  34. package/dist/lib/core/local-token-reader.js +1 -1
  35. package/dist/lib/core/local-token-reader.js.map +3 -3
  36. package/dist/lib/core/path-utils.js +1 -1
  37. package/dist/lib/core/path-utils.js.map +3 -3
  38. package/dist/lib/core/token-processor.js +3 -1
  39. package/dist/lib/core/token-processor.js.map +3 -3
  40. package/dist/next.js +1 -1
  41. package/dist/next.js.map +4 -4
  42. package/dist/types/index.d.ts +107 -11
  43. package/dist/vite.js +13 -8
  44. package/dist/vite.js.map +4 -4
  45. package/dist/vite.mjs +6 -1
  46. package/dist/vite.mjs.map +3 -3
  47. package/package.json +15 -5
  48. package/scripts/build.js +21 -4
  49. package/scripts/master-components-config.json +953 -0
  50. package/scripts/update-default-config-data.js +690 -0
  51. package/src/theme.css +9 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../lib/core/file-utils.js", "../../../lib/core/env-utils.js"],
4
- "sourcesContent": ["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 * Strips UTF-8 BOM if present (fixes Windows compatibility)\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 const content = fs.readFileSync(filepath, 'utf8');\n // Strip UTF-8 BOM if present (Windows compatibility)\n return content.replace(/^\\uFEFF/, '');\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 { fileExists } = require('./file-utils');\n\n/**\n * Load .env.local file if it exists in the current working directory\n * @param {string} cwd - Current working directory (defaults to process.cwd())\n * @returns {boolean} True if .env.local was loaded\n */\nfunction loadEnvLocal(cwd = process.cwd()) {\n const envLocalPath = path.join(cwd, '.env.local');\n \n if (fileExists(envLocalPath)) {\n require('dotenv').config({ path: envLocalPath });\n console.log('\uD83D\uDCC4 Loaded .env.local');\n return true;\n }\n \n return false;\n}\n\n/**\n * Get an environment variable with optional default value\n * @param {string} name - Environment variable name\n * @param {string} defaultValue - Default value if not set\n * @returns {string|undefined} Environment variable value or default\n */\nfunction getEnvVar(name, defaultValue = undefined) {\n return process.env[name] || defaultValue;\n}\n\n/**\n * Check if an environment variable is set to 'true'\n * @param {string} name - Environment variable name\n * @returns {boolean} True if the env var is set to 'true'\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CAAC,CAC3C,CAMA,SAASC,EAAgBD,EAAS,CAChCZ,EAAG,OAAOY,EAAS,CAAE,UAAW,GAAM,MAAO,EAAK,CAAC,CACrD,CAEAb,EAAO,QAAU,CACf,iBAAAE,EACA,aAAAI,EACA,cAAAC,EACA,uBAAAG,EACA,WAAAC,EACA,sBAAAC,EACA,gBAAAE,CACF,ICvGA,IAAMC,EAAO,QAAQ,MAAM,EACrB,CAAE,WAAAC,CAAW,EAAI,IAOvB,SAASC,EAAaC,EAAM,QAAQ,IAAI,EAAG,CACzC,IAAMC,EAAeJ,EAAK,KAAKG,EAAK,YAAY,EAEhD,OAAIF,EAAWG,CAAY,GACzB,QAAQ,QAAQ,EAAE,OAAO,CAAE,KAAMA,CAAa,CAAC,EAC/C,QAAQ,IAAI,6BAAsB,EAC3B,IAGF,EACT,CAQA,SAASC,EAAUC,EAAMC,EAAe,OAAW,CACjD,OAAO,QAAQ,IAAID,CAAI,GAAKC,CAC9B,CAOA,SAASC,EAAUF,EAAM,CACvB,OAAO,QAAQ,IAAIA,CAAI,IAAM,MAC/B,CAEA,OAAO,QAAU,CACf,aAAAJ,EACA,UAAAG,EACA,UAAAG,CACF",
6
- "names": ["require_file_utils", "__commonJSMin", "exports", "module", "fs", "readJsonFileSafe", "filepath", "content", "error", "readFileSafe", "writeJsonFile", "data", "indent", "writeModuleExportsFile", "fileExists", "ensureDirectoryExists", "dirpath", "removeDirectory", "path", "fileExists", "loadEnvLocal", "cwd", "envLocalPath", "getEnvVar", "name", "defaultValue", "isEnvTrue"]
4
+ "sourcesContent": ["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 * Strips UTF-8 BOM if present (fixes Windows compatibility)\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 const content = fs.readFileSync(filepath, 'utf8');\n // Strip UTF-8 BOM if present (Windows compatibility)\n return content.replace(/^\\uFEFF/, '');\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 plain text content to a file\n * @param {string} filepath - Path to write the file\n * @param {string} content - Text content to write\n */\nfunction writeTextFile(filepath, content) {\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 writeTextFile,\n writeModuleExportsFile,\n fileExists,\n ensureDirectoryExists,\n removeDirectory\n};\n", "const path = require('path');\nconst { fileExists } = require('./file-utils');\n\n/**\n * Load .env.local file if it exists in the current working directory\n * @param {string} cwd - Current working directory (defaults to process.cwd())\n * @returns {boolean} True if .env.local was loaded\n */\nfunction loadEnvLocal(cwd = process.cwd()) {\n const envLocalPath = path.join(cwd, '.env.local');\n \n if (fileExists(envLocalPath)) {\n require('dotenv').config({ path: envLocalPath });\n console.log('\uD83D\uDCC4 Loaded .env.local');\n return true;\n }\n \n return false;\n}\n\n/**\n * Get an environment variable with optional default value\n * @param {string} name - Environment variable name\n * @param {string} defaultValue - Default value if not set\n * @returns {string|undefined} Environment variable value or default\n */\nfunction getEnvVar(name, defaultValue = undefined) {\n return process.env[name] || defaultValue;\n}\n\n/**\n * Check if an environment variable is set to 'true'\n * @param {string} name - Environment variable name\n * @returns {boolean} True if the env var is set to 'true'\n */\nfunction isEnvTrue(name) {\n return process.env[name] === 'true';\n}\n\nmodule.exports = {\n loadEnvLocal,\n getEnvVar,\n isEnvTrue\n};"],
5
+ "mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,KAAMC,EAAK,QAAQ,IAAI,EAQvB,SAASC,EAAiBC,EAAU,CAClC,GAAI,CACF,IAAMC,EAAUH,EAAG,aAAaE,EAAU,MAAM,EAChD,OAAO,KAAK,MAAMC,CAAO,CAC3B,OAASC,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET,MAAMA,CACR,CACF,CASA,SAASC,EAAaH,EAAU,CAC9B,GAAI,CAGF,OAFgBF,EAAG,aAAaE,EAAU,MAAM,EAEjC,QAAQ,UAAW,EAAE,CACtC,OAASE,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET,MAA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,CAAa,CAAC,EAC/C,QAAQ,IAAI,6BAAsB,EAC3B,IAGF,EACT,CAQA,SAASC,EAAUC,EAAMC,EAAe,OAAW,CACjD,OAAO,QAAQ,IAAID,CAAI,GAAKC,CAC9B,CAOA,SAASC,EAAUF,EAAM,CACvB,OAAO,QAAQ,IAAIA,CAAI,IAAM,MAC/B,CAEA,OAAO,QAAU,CACf,aAAAJ,EACA,UAAAG,EACA,UAAAG,CACF",
6
+ "names": ["require_file_utils", "__commonJSMin", "exports", "module", "fs", "readJsonFileSafe", "filepath", "content", "error", "readFileSafe", "writeJsonFile", "data", "indent", "writeTextFile", "writeModuleExportsFile", "fileExists", "ensureDirectoryExists", "dirpath", "removeDirectory", "path", "fileExists", "loadEnvLocal", "cwd", "envLocalPath", "getEnvVar", "name", "defaultValue", "isEnvTrue"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var t=require("fs");function c(n){try{let e=t.readFileSync(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function i(n){try{return t.readFileSync(n,"utf8").replace(/^\uFEFF/,"")}catch(e){if(e.code==="ENOENT")return null;throw e}}function u(n,e,r=2){let o=JSON.stringify(e,null,r);t.writeFileSync(n,o,"utf8")}function s(n,e){if(e==null||typeof e=="object"&&Object.keys(e).length===0||Array.isArray(e)&&e.length===0){let o=`module.exports = ${Array.isArray(e)?"[]":"{}"};`;t.writeFileSync(n,o,"utf8")}else{let r=`module.exports = ${JSON.stringify(e,null,2)};`;t.writeFileSync(n,r,"utf8")}}function l(n){return t.existsSync(n)}function f(n){t.mkdirSync(n,{recursive:!0})}function y(n){t.rmSync(n,{recursive:!0,force:!0})}module.exports={readJsonFileSafe:c,readFileSafe:i,writeJsonFile:u,writeModuleExportsFile:s,fileExists:l,ensureDirectoryExists:f,removeDirectory:y};
1
+ var n=require("fs");function c(t){try{let e=n.readFileSync(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function o(t){try{return n.readFileSync(t,"utf8").replace(/^\uFEFF/,"")}catch(e){if(e.code==="ENOENT")return null;throw e}}function u(t,e,r=2){let i=JSON.stringify(e,null,r);n.writeFileSync(t,i,"utf8")}function s(t,e){n.writeFileSync(t,e,"utf8")}function l(t,e){if(e==null||typeof e=="object"&&Object.keys(e).length===0||Array.isArray(e)&&e.length===0){let i=`module.exports = ${Array.isArray(e)?"[]":"{}"};`;n.writeFileSync(t,i,"utf8")}else{let r=`module.exports = ${JSON.stringify(e,null,2)};`;n.writeFileSync(t,r,"utf8")}}function f(t){return n.existsSync(t)}function y(t){n.mkdirSync(t,{recursive:!0})}function F(t){n.rmSync(t,{recursive:!0,force:!0})}module.exports={readJsonFileSafe:c,readFileSafe:o,writeJsonFile:u,writeTextFile:s,writeModuleExportsFile:l,fileExists:f,ensureDirectoryExists:y,removeDirectory:F};
2
2
  //# sourceMappingURL=file-utils.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../lib/core/file-utils.js"],
4
- "sourcesContent": ["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 * Strips UTF-8 BOM if present (fixes Windows compatibility)\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 const content = fs.readFileSync(filepath, 'utf8');\n // Strip UTF-8 BOM if present (Windows compatibility)\n return content.replace(/^\\uFEFF/, '');\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};"],
5
- "mappings": "AAAA,IAAMA,EAAK,QAAQ,IAAI,EAQvB,SAASC,EAAiBC,EAAU,CAClC,GAAI,CACF,IAAMC,EAAUH,EAAG,aAAaE,EAAU,MAAM,EAChD,OAAO,KAAK,MAAMC,CAAO,CAC3B,OAASC,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET,MAAMA,CACR,CACF,CASA,SAASC,EAAaH,EAAU,CAC9B,GAAI,CAGF,OAFgBF,EAAG,aAAaE,EAAU,MAAM,EAEjC,QAAQ,UAAW,EAAE,CACtC,OAASE,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET,MAAMA,CACR,CACF,CAQA,SAASE,EAAcJ,EAAUK,EAAMC,EAAS,EAAG,CACjD,IAAML,EAAU,KAAK,UAAUI,EAAM,KAAMC,CAAM,EACjDR,EAAG,cAAcE,EAAUC,EAAS,MAAM,CAC5C,CAOA,SAASM,EAAuBP,EAAUK,EAAM,CAE9C,GAAIA,GAAS,MACR,OAAOA,GAAS,UAAY,OAAO,KAAKA,CAAI,EAAE,SAAW,GACzD,MAAM,QAAQA,CAAI,GAAKA,EAAK,SAAW,EAAI,CAE9C,IAAMJ,EAAU,oBADK,MAAM,QAAQI,CAAI,EAAI,KAAO,IACF,IAChDP,EAAG,cAAcE,EAAUC,EAAS,MAAM,CAC5C,KAAO,CACL,IAAMA,EAAU,oBAAoB,KAAK,UAAUI,EAAM,KAAM,CAAC,CAAC,IACjEP,EAAG,cAAcE,EAAUC,EAAS,MAAM,CAC5C,CACF,CAOA,SAASO,EAAWR,EAAU,CAC5B,OAAOF,EAAG,WAAWE,CAAQ,CAC/B,CAMA,SAASS,EAAsBC,EAAS,CACtCZ,EAAG,UAAUY,EAAS,CAAE,UAAW,EAAK,CAAC,CAC3C,CAMA,SAASC,EAAgBD,EAAS,CAChCZ,EAAG,OAAOY,EAAS,CAAE,UAAW,GAAM,MAAO,EAAK,CAAC,CACrD,CAEA,OAAO,QAAU,CACf,iBAAAX,EACA,aAAAI,EACA,cAAAC,EACA,uBAAAG,EACA,WAAAC,EACA,sBAAAC,EACA,gBAAAE,CACF",
6
- "names": ["fs", "readJsonFileSafe", "filepath", "content", "error", "readFileSafe", "writeJsonFile", "data", "indent", "writeModuleExportsFile", "fileExists", "ensureDirectoryExists", "dirpath", "removeDirectory"]
4
+ "sourcesContent": ["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 * Strips UTF-8 BOM if present (fixes Windows compatibility)\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 const content = fs.readFileSync(filepath, 'utf8');\n // Strip UTF-8 BOM if present (Windows compatibility)\n return content.replace(/^\\uFEFF/, '');\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 plain text content to a file\n * @param {string} filepath - Path to write the file\n * @param {string} content - Text content to write\n */\nfunction writeTextFile(filepath, content) {\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 writeTextFile,\n writeModuleExportsFile,\n fileExists,\n ensureDirectoryExists,\n removeDirectory\n};\n"],
5
+ "mappings": "AAAA,IAAMA,EAAK,QAAQ,IAAI,EAQvB,SAASC,EAAiBC,EAAU,CAClC,GAAI,CACF,IAAMC,EAAUH,EAAG,aAAaE,EAAU,MAAM,EAChD,OAAO,KAAK,MAAMC,CAAO,CAC3B,OAASC,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET,MAAMA,CACR,CACF,CASA,SAASC,EAAaH,EAAU,CAC9B,GAAI,CAGF,OAFgBF,EAAG,aAAaE,EAAU,MAAM,EAEjC,QAAQ,UAAW,EAAE,CACtC,OAASE,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET,MAAMA,CACR,CACF,CAQA,SAASE,EAAcJ,EAAUK,EAAMC,EAAS,EAAG,CACjD,IAAML,EAAU,KAAK,UAAUI,EAAM,KAAMC,CAAM,EACjDR,EAAG,cAAcE,EAAUC,EAAS,MAAM,CAC5C,CAOA,SAASM,EAAcP,EAAUC,EAAS,CACxCH,EAAG,cAAcE,EAAUC,EAAS,MAAM,CAC5C,CAOA,SAASO,EAAuBR,EAAUK,EAAM,CAE9C,GAAIA,GAAS,MACR,OAAOA,GAAS,UAAY,OAAO,KAAKA,CAAI,EAAE,SAAW,GACzD,MAAM,QAAQA,CAAI,GAAKA,EAAK,SAAW,EAAI,CAE9C,IAAMJ,EAAU,oBADK,MAAM,QAAQI,CAAI,EAAI,KAAO,IACF,IAChDP,EAAG,cAAcE,EAAUC,EAAS,MAAM,CAC5C,KAAO,CACL,IAAMA,EAAU,oBAAoB,KAAK,UAAUI,EAAM,KAAM,CAAC,CAAC,IACjEP,EAAG,cAAcE,EAAUC,EAAS,MAAM,CAC5C,CACF,CAOA,SAASQ,EAAWT,EAAU,CAC5B,OAAOF,EAAG,WAAWE,CAAQ,CAC/B,CAMA,SAASU,EAAsBC,EAAS,CACtCb,EAAG,UAAUa,EAAS,CAAE,UAAW,EAAK,CAAC,CAC3C,CAMA,SAASC,EAAgBD,EAAS,CAChCb,EAAG,OAAOa,EAAS,CAAE,UAAW,GAAM,MAAO,EAAK,CAAC,CACrD,CAEA,OAAO,QAAU,CACf,iBAAAZ,EACA,aAAAI,EACA,cAAAC,EACA,cAAAG,EACA,uBAAAC,EACA,WAAAC,EACA,sBAAAC,EACA,gBAAAE,CACF",
6
+ "names": ["fs", "readJsonFileSafe", "filepath", "content", "error", "readFileSafe", "writeJsonFile", "data", "indent", "writeTextFile", "writeModuleExportsFile", "fileExists", "ensureDirectoryExists", "dirpath", "removeDirectory"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var m=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var u=m((v,y)=>{var f=require("fs");function b(o){try{let e=f.readFileSync(o,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function S(o){try{return f.readFileSync(o,"utf8").replace(/^\uFEFF/,"")}catch(e){if(e.code==="ENOENT")return null;throw e}}function D(o,e,t=2){let n=JSON.stringify(e,null,t);f.writeFileSync(o,n,"utf8")}function g(o,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)?"[]":"{}"};`;f.writeFileSync(o,n,"utf8")}else{let t=`module.exports = ${JSON.stringify(e,null,2)};`;f.writeFileSync(o,t,"utf8")}}function E(o){return f.existsSync(o)}function M(o){f.mkdirSync(o,{recursive:!0})}function x(o){f.rmSync(o,{recursive:!0,force:!0})}y.exports={readJsonFileSafe:b,readFileSafe:S,writeJsonFile:D,writeModuleExportsFile:g,fileExists:E,ensureDirectoryExists:M,removeDirectory:x}});var P=m((J,w)=>{var a=require("path"),{fileExists:j}=u();function C(o,e=process.cwd()){let t=e;for(;t!==a.parse(t).root;){let n=a.join(t,o);if(j(n))return n;t=a.dirname(t)}return null}function T(o,e=process.cwd(),t=null){let n=[],i=e,c=10;for(let r=0;r<c;r++){n.push(a.join(i,o)),r<3&&n.push(a.join(i,"../".repeat(r+1)+o));let l=a.dirname(i);if(l===i)break;i=l}n.push(a.join(__dirname,"../../../",o));for(let r of n)if(j(r)&&(!t||t(r)))return r;return null}function N(o,e=process.cwd()){let t=o.map(n=>a.isAbsolute(n)?n:a.join(e,n));for(let n of t)if(j(n))return n;return null}w.exports={findFileUpward:C,findDirectoryUpward:T,findDirectoryWithPaths:N}});var s=require("path"),{findDirectoryUpward:k}=P(),{readJsonFileSafe:h,readFileSafe:F,fileExists:d}=u(),p=class{constructor(e,t={}){if(this.ffId=e,this.tokensBasePath=t.tokensBasePath||this.findTokensPath(),this.folderMap=this.loadFolderMap(),this.projectFolder=this.folderMap[e],!this.projectFolder)throw new Error(`No folder mapping found for ff-id: ${e}`);this.projectPath=s.join(this.tokensBasePath,this.projectFolder)}findTokensPath(){let e=k("apps/tokens",process.cwd(),t=>d(s.join(t,"folderMap.json")));if(e||(e=k("tokens",process.cwd(),t=>d(s.join(t,"folderMap.json")))),!e)throw new Error("Could not find tokens directory with folderMap.json");return e}loadFolderMap(){let e=s.join(this.tokensBasePath,"folderMap.json"),t=h(e);if(!t)throw new Error("Failed to load folderMap.json: File not found");return t}async fetchTokens(){let e=s.join(this.projectPath,"figma"),t={global:[s.join(e,"Global Tokens","Default.json"),s.join(e,"global.json")],colors:[s.join(e,"Global Colors","Default.json"),s.join(e,"Global Colors","Light.json")],semantic:[s.join(e,"Semantic","Light.json"),s.join(e,"Semantic","Default.json")],semanticDark:[s.join(e,"Semantic","Dark.json")]},n={};for(let[i,c]of Object.entries(t)){for(let r of c){let l=h(r);if(l!==null){n[i]=l;break}}n[i]||(n[i]=null)}return n}async fetchProcessedTokens(){let e=s.join(this.projectPath,"cache");if(!d(e))return null;let t={"tokens.js":"hashedTokens.js","variables.js":"hashedVariables.js","semanticVariables.js":"hashedSemanticVariables.js","semanticDarkVariables.js":"hashedSemanticDarkVariables.js","safelist.js":"safelist.js","custom.js":"custom.js","fonts.json":"fonts.json","icons.json":"icons.json","components-config.json":"encoded-config.json","version.json":"version.json"},n={};for(let[c,r]of Object.entries(t)){let l=s.join(e,r);c.endsWith(".js")?n[c]=F(l):n[c]=h(l)}return Object.values(n).some(c=>c!==null)?n:null}async fetchComponentsConfig(){return h(s.join(this.projectPath,"components-config.json"))}async fetchFonts(){return h(s.join(this.projectPath,"font.json"))}async fetchIcons(){return h(s.join(this.projectPath,"icons.json"))}async fetchVersion(){return h(s.join(this.projectPath,"version.json"))}async fetchCustomCss(){return F(s.join(this.projectPath,"custom.css"))}async fetchPlanMetadata(){return h(s.join(this.projectPath,"metadata.json"))||{planType:"full",allowedComponents:null}}fetchJson(){throw new Error("fetchJson is not implemented in LocalTokenReader. Use specific fetch methods.")}fetchRaw(){throw new Error("fetchRaw is not implemented in LocalTokenReader. Use specific fetch methods.")}};module.exports={LocalTokenReader:p};
1
+ var P=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var d=P((A,k)=>{var a=require("fs");function x(o){try{let e=a.readFileSync(o,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function D(o){try{return a.readFileSync(o,"utf8").replace(/^\uFEFF/,"")}catch(e){if(e.code==="ENOENT")return null;throw e}}function E(o,e,t=2){let n=JSON.stringify(e,null,t);a.writeFileSync(o,n,"utf8")}function g(o,e){a.writeFileSync(o,e,"utf8")}function M(o,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)?"[]":"{}"};`;a.writeFileSync(o,n,"utf8")}else{let t=`module.exports = ${JSON.stringify(e,null,2)};`;a.writeFileSync(o,t,"utf8")}}function v(o){return a.existsSync(o)}function C(o){a.mkdirSync(o,{recursive:!0})}function T(o){a.rmSync(o,{recursive:!0,force:!0})}k.exports={readJsonFileSafe:x,readFileSafe:D,writeJsonFile:E,writeTextFile:g,writeModuleExportsFile:M,fileExists:v,ensureDirectoryExists:C,removeDirectory:T}});var b=P((U,F)=>{var l=require("path"),{fileExists:j}=d();function O(o,e=process.cwd()){let t=e;for(;t!==l.parse(t).root;){let n=l.join(t,o);if(j(n))return n;t=l.dirname(t)}return null}function J(o,e=process.cwd(),t=null){let n=[],i=e,u=10;for(let r=0;r<u;r++){n.push(l.join(i,o)),r<3&&n.push(l.join(i,"../".repeat(r+1)+o));let c=l.dirname(i);if(c===i)break;i=c}n.push(l.join(__dirname,"../../../",o));for(let r of n)if(j(r)&&(!t||t(r)))return r;return null}function q(o,e=process.cwd()){let t=o.map(n=>l.isAbsolute(n)?n:l.join(e,n));for(let n of t)if(j(n))return n;return null}F.exports={findFileUpward:O,findDirectoryUpward:J,findDirectoryWithPaths:q}});var s=require("path"),{findDirectoryUpward:S}=b(),{readJsonFileSafe:f,readFileSafe:N,fileExists:m}=d(),y=class{constructor(e,t={}){if(this.ffId=e,this.tokensBasePath=t.tokensBasePath||this.findTokensPath(),this.folderMap=this.loadFolderMap(),this.projectFolder=this.folderMap[e],!this.projectFolder)throw new Error(`No folder mapping found for ff-id: ${e}`);this.projectPath=s.join(this.tokensBasePath,this.projectFolder)}findTokensPath(){let e=S("apps/tokens",process.cwd(),t=>m(s.join(t,"folderMap.json")));if(e||(e=S("tokens",process.cwd(),t=>m(s.join(t,"folderMap.json")))),!e)throw new Error("Could not find tokens directory with folderMap.json");return e}loadFolderMap(){let e=s.join(this.tokensBasePath,"folderMap.json"),t=f(e);if(!t)throw new Error("Failed to load folderMap.json: File not found");return t}async fetchTokens(){let e=s.join(this.projectPath,"figma"),t={global:[s.join(e,"Global Tokens","Default.json"),s.join(e,"global.json")],colors:[s.join(e,"Global Colors","Default.json"),s.join(e,"Global Colors","Light.json")],semantic:[s.join(e,"Semantic","Light.json"),s.join(e,"Semantic","Default.json")],semanticDark:[s.join(e,"Semantic","Dark.json")]},n={};for(let[i,u]of Object.entries(t)){for(let r of u){let c=f(r);if(c!==null){n[i]=c;break}}n[i]||(n[i]=null)}return n}async fetchProcessedTokens(){let e=s.join(this.projectPath,"cache");if(!m(e))return null;let t=r=>{if(r===null)return null;let c={},h={exports:c};return new Function("module","exports",r)(h,c),h.exports},n={tokens:{fileName:"hashedTokens.js",type:"module"},variables:{fileName:"hashedVariables.js",type:"module"},semanticVariables:{fileName:"hashedSemanticVariables.js",type:"module"},semanticDarkVariables:{fileName:"hashedSemanticDarkVariables.js",type:"module"},safelist:{fileName:"safelist.js",type:"module"},custom:{fileName:"custom.js",type:"module"},fonts:{fileName:"fonts.json",type:"json"},icons:{fileName:"icons.json",type:"json"},componentsConfig:{fileName:"encoded-config.json",type:"json"},version:{fileName:"version.json",type:"json"}},i={};for(let[r,{fileName:c,type:h}]of Object.entries(n)){let p=s.join(e,c),w=h==="module"?t(N(p)):f(p);w!==null&&(i[r]=w)}return Object.values(i).some(r=>r!==null)?i:null}async fetchComponentsConfig(){return f(s.join(this.projectPath,"components-config.json"))}async fetchFonts(){return f(s.join(this.projectPath,"font.json"))}async fetchIcons(){return f(s.join(this.projectPath,"icons.json"))}async fetchVersion(){return f(s.join(this.projectPath,"version.json"))}async fetchCustomCss(){return N(s.join(this.projectPath,"custom.css"))}async fetchPlanMetadata(){return f(s.join(this.projectPath,"metadata.json"))||{planType:"full",allowedComponents:null}}fetchJson(){throw new Error("fetchJson is not implemented in LocalTokenReader. Use specific fetch methods.")}fetchRaw(){throw new Error("fetchRaw is not implemented in LocalTokenReader. Use specific fetch methods.")}};module.exports={LocalTokenReader:y};
2
2
  //# sourceMappingURL=local-token-reader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../lib/core/file-utils.js", "../../../lib/core/path-utils.js", "../../../lib/core/local-token-reader.js"],
4
- "sourcesContent": ["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 * Strips UTF-8 BOM if present (fixes Windows compatibility)\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 const content = fs.readFileSync(filepath, 'utf8');\n // Strip UTF-8 BOM if present (Windows compatibility)\n return content.replace(/^\\uFEFF/, '');\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 { fileExists } = require('./file-utils');\n\n/**\n * Find a file by traversing up the directory tree\n * @param {string} filename - Name of the file to find\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @returns {string|null} Full path to the file or null if not found\n */\nfunction findFileUpward(filename, startDir = process.cwd()) {\n let currentDir = startDir;\n \n while (currentDir !== path.parse(currentDir).root) {\n const filePath = path.join(currentDir, filename);\n \n if (fileExists(filePath)) {\n return filePath;\n }\n \n currentDir = path.dirname(currentDir);\n }\n \n return null;\n}\n\n/**\n * Find a directory by traversing up and checking multiple possible paths\n * @param {string} dirname - Name of the directory to find\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @param {Function} validator - Optional function to validate the directory\n * @returns {string|null} Full path to the directory or null if not found\n */\nfunction findDirectoryUpward(dirname, startDir = process.cwd(), validator = null) {\n const possiblePaths = [];\n let currentDir = startDir;\n const maxLevels = 10; // Prevent infinite loop\n \n // Build list of possible paths\n for (let i = 0; i < maxLevels; i++) {\n // Direct path\n possiblePaths.push(path.join(currentDir, dirname));\n \n // Relative paths up to 3 levels\n if (i < 3) {\n possiblePaths.push(path.join(currentDir, '../'.repeat(i + 1) + dirname));\n }\n \n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) break; // Reached root\n currentDir = parentDir;\n }\n \n // Also check from module directory (for when running from node_modules)\n possiblePaths.push(path.join(__dirname, '../../../', dirname));\n \n // Find first existing directory that passes validation\n for (const dirPath of possiblePaths) {\n if (fileExists(dirPath)) {\n if (!validator || validator(dirPath)) {\n return dirPath;\n }\n }\n }\n \n return null;\n}\n\n/**\n * Find a directory with multiple possible relative paths\n * @param {string[]} possiblePaths - Array of possible paths to check\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @returns {string|null} Full path to the directory or null if not found\n */\nfunction findDirectoryWithPaths(possiblePaths, startDir = process.cwd()) {\n // Build absolute paths from the start directory\n const absolutePaths = possiblePaths.map(p => {\n if (path.isAbsolute(p)) {\n return p;\n }\n return path.join(startDir, p);\n });\n \n // Find first existing path\n for (const dirPath of absolutePaths) {\n if (fileExists(dirPath)) {\n return dirPath;\n }\n }\n \n return null;\n}\n\nmodule.exports = {\n findFileUpward,\n findDirectoryUpward,\n findDirectoryWithPaths\n};", "const path = require('path');\nconst { findDirectoryUpward } = require('./path-utils');\nconst { readJsonFileSafe, readFileSafe, fileExists } = require('./file-utils');\n\n/**\n * LocalTokenReader - Reads tokens directly from the local file system\n * Mimics the APIClient interface but reads from apps/tokens directory\n */\nclass LocalTokenReader {\n constructor(ffId, options = {}) {\n this.ffId = ffId;\n this.tokensBasePath = options.tokensBasePath || this.findTokensPath();\n this.folderMap = this.loadFolderMap();\n this.projectFolder = this.folderMap[ffId];\n \n if (!this.projectFolder) {\n throw new Error(`No folder mapping found for ff-id: ${ffId}`);\n }\n \n this.projectPath = path.join(this.tokensBasePath, this.projectFolder);\n }\n\n /**\n * Find the tokens directory by looking for apps/tokens in parent directories\n */\n findTokensPath() {\n // Try to find apps/tokens first\n let tokensPath = findDirectoryUpward('apps/tokens', process.cwd(), (dir) => {\n return fileExists(path.join(dir, 'folderMap.json'));\n });\n \n // If not found, try just 'tokens'\n if (!tokensPath) {\n tokensPath = findDirectoryUpward('tokens', process.cwd(), (dir) => {\n return fileExists(path.join(dir, 'folderMap.json'));\n });\n }\n \n if (!tokensPath) {\n throw new Error('Could not find tokens directory with folderMap.json');\n }\n \n return tokensPath;\n }\n\n /**\n * Load the folder mapping from folderMap.json\n */\n loadFolderMap() {\n const folderMapPath = path.join(this.tokensBasePath, 'folderMap.json');\n const folderMap = readJsonFileSafe(folderMapPath);\n \n if (!folderMap) {\n throw new Error(`Failed to load folderMap.json: File not found`);\n }\n \n return folderMap;\n }\n\n /**\n * Fetch all token files (global, colors, semantic)\n * Mimics the APIClient.fetchTokens() method\n */\n async fetchTokens() {\n const figmaPath = path.join(this.projectPath, 'figma');\n \n // Try different possible paths for tokens\n const tokenPaths = {\n global: [\n path.join(figmaPath, 'Global Tokens', 'Default.json'),\n path.join(figmaPath, 'global.json')\n ],\n colors: [\n path.join(figmaPath, 'Global Colors', 'Default.json'),\n path.join(figmaPath, 'Global Colors', 'Light.json')\n ],\n semantic: [\n path.join(figmaPath, 'Semantic', 'Light.json'),\n path.join(figmaPath, 'Semantic', 'Default.json')\n ],\n semanticDark: [\n path.join(figmaPath, 'Semantic', 'Dark.json')\n ]\n };\n\n const results = {};\n \n // Try each possible path for each token type\n for (const [key, paths] of Object.entries(tokenPaths)) {\n for (const tokenPath of paths) {\n const content = readJsonFileSafe(tokenPath);\n if (content !== null) {\n results[key] = content;\n break; // Found it, no need to try other paths\n }\n }\n // If not found in any path, set to null\n if (!results[key]) {\n results[key] = null;\n }\n }\n\n return results;\n }\n\n /**\n * Fetch pre-processed tokens (if available in cache folder)\n */\n async fetchProcessedTokens() {\n const cachePath = path.join(this.projectPath, 'cache');\n \n if (!fileExists(cachePath)) {\n return null;\n }\n\n // Read all the cache files that would be in processed tokens\n const cacheFiles = {\n 'tokens.js': 'hashedTokens.js',\n 'variables.js': 'hashedVariables.js', \n 'semanticVariables.js': 'hashedSemanticVariables.js',\n 'semanticDarkVariables.js': 'hashedSemanticDarkVariables.js',\n 'safelist.js': 'safelist.js',\n 'custom.js': 'custom.js',\n 'fonts.json': 'fonts.json',\n 'icons.json': 'icons.json',\n 'components-config.json': 'encoded-config.json',\n 'version.json': 'version.json'\n };\n\n const processedData = {};\n \n for (const [key, fileName] of Object.entries(cacheFiles)) {\n const filePath = path.join(cachePath, fileName);\n if (key.endsWith('.js')) {\n processedData[key] = readFileSafe(filePath);\n } else {\n processedData[key] = readJsonFileSafe(filePath);\n }\n }\n\n // Only return if we have at least some data\n const hasData = Object.values(processedData).some(val => val !== null);\n return hasData ? processedData : null;\n }\n\n /**\n * Fetch components configuration\n */\n async fetchComponentsConfig() {\n return readJsonFileSafe(path.join(this.projectPath, 'components-config.json'));\n }\n\n /**\n * Fetch fonts configuration\n */\n async fetchFonts() {\n return readJsonFileSafe(path.join(this.projectPath, 'font.json'));\n }\n\n /**\n * Fetch icons configuration\n */\n async fetchIcons() {\n return readJsonFileSafe(path.join(this.projectPath, 'icons.json'));\n }\n\n /**\n * Fetch version information\n */\n async fetchVersion() {\n return readJsonFileSafe(path.join(this.projectPath, 'version.json'));\n }\n\n /**\n * Fetch custom CSS\n */\n async fetchCustomCss() {\n return readFileSafe(path.join(this.projectPath, 'custom.css'));\n }\n\n /**\n * Fetch plan metadata\n */\n async fetchPlanMetadata() {\n const metadata = readJsonFileSafe(path.join(this.projectPath, 'metadata.json'));\n \n // Default to full plan if no metadata exists\n return metadata || {\n planType: 'full',\n allowedComponents: null\n };\n }\n\n // Compatibility methods to match APIClient interface\n fetchJson() {\n throw new Error('fetchJson is not implemented in LocalTokenReader. Use specific fetch methods.');\n }\n\n fetchRaw() {\n throw new Error('fetchRaw is not implemented in LocalTokenReader. Use specific fetch methods.');\n }\n}\n\nmodule.exports = { LocalTokenReader };"],
5
- "mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,KAAMC,EAAK,QAAQ,IAAI,EAQvB,SAASC,EAAiBC,EAAU,CAClC,GAAI,CACF,IAAMC,EAAUH,EAAG,aAAaE,EAAU,MAAM,EAChD,OAAO,KAAK,MAAMC,CAAO,CAC3B,OAASC,EAAO,CACd,GAAIA,EAA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nB,OAAOE,EAAiBF,EAAK,KAAK,KAAK,YAAa,cAAc,CAAC,CACrE,CAKA,MAAM,gBAAiB,CACrB,OAAOG,EAAaH,EAAK,KAAK,KAAK,YAAa,YAAY,CAAC,CAC/D,CAKA,MAAM,mBAAoB,CAIxB,OAHiBE,EAAiBF,EAAK,KAAK,KAAK,YAAa,eAAe,CAAC,GAG3D,CACjB,SAAU,OACV,kBAAmB,IACrB,CACF,CAGA,WAAY,CACV,MAAM,IAAI,MAAM,+EAA+E,CACjG,CAEA,UAAW,CACT,MAAM,IAAI,MAAM,8EAA8E,CAChG,CACF,EAEA,OAAO,QAAU,CAAE,iBAAAK,CAAiB",
6
- "names": ["require_file_utils", "__commonJSMin", "exports", "module", "fs", "readJsonFileSafe", "filepath", "content", "error", "readFileSafe", "writeJsonFile", "data", "indent", "writeModuleExportsFile", "fileExists", "ensureDirectoryExists", "dirpath", "removeDirectory", "require_path_utils", "__commonJSMin", "exports", "module", "path", "fileExists", "findFileUpward", "filename", "startDir", "currentDir", "filePath", "findDirectoryUpward", "dirname", "validator", "possiblePaths", "maxLevels", "i", "parentDir", "dirPath", "findDirectoryWithPaths", "absolutePaths", "p", "path", "findDirectoryUpward", "readJsonFileSafe", "readFileSafe", "fileExists", "LocalTokenReader", "ffId", "options", "tokensPath", "dir", "folderMapPath", "folderMap", "figmaPath", "tokenPaths", "results", "key", "paths", "tokenPath", "content", "cachePath", "cacheFiles", "processedData", "fileName", "filePath", "val"]
4
+ "sourcesContent": ["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 * Strips UTF-8 BOM if present (fixes Windows compatibility)\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 const content = fs.readFileSync(filepath, 'utf8');\n // Strip UTF-8 BOM if present (Windows compatibility)\n return content.replace(/^\\uFEFF/, '');\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 plain text content to a file\n * @param {string} filepath - Path to write the file\n * @param {string} content - Text content to write\n */\nfunction writeTextFile(filepath, content) {\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 writeTextFile,\n writeModuleExportsFile,\n fileExists,\n ensureDirectoryExists,\n removeDirectory\n};\n", "const path = require('path');\nconst { fileExists } = require('./file-utils');\n\n/**\n * Find a file by traversing up the directory tree\n * @param {string} filename - Name of the file to find\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @returns {string|null} Full path to the file or null if not found\n */\nfunction findFileUpward(filename, startDir = process.cwd()) {\n let currentDir = startDir;\n \n while (currentDir !== path.parse(currentDir).root) {\n const filePath = path.join(currentDir, filename);\n \n if (fileExists(filePath)) {\n return filePath;\n }\n \n currentDir = path.dirname(currentDir);\n }\n \n return null;\n}\n\n/**\n * Find a directory by traversing up and checking multiple possible paths\n * @param {string} dirname - Name of the directory to find\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @param {Function} validator - Optional function to validate the directory\n * @returns {string|null} Full path to the directory or null if not found\n */\nfunction findDirectoryUpward(dirname, startDir = process.cwd(), validator = null) {\n const possiblePaths = [];\n let currentDir = startDir;\n const maxLevels = 10; // Prevent infinite loop\n \n // Build list of possible paths\n for (let i = 0; i < maxLevels; i++) {\n // Direct path\n possiblePaths.push(path.join(currentDir, dirname));\n \n // Relative paths up to 3 levels\n if (i < 3) {\n possiblePaths.push(path.join(currentDir, '../'.repeat(i + 1) + dirname));\n }\n \n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) break; // Reached root\n currentDir = parentDir;\n }\n \n // Also check from module directory (for when running from node_modules)\n possiblePaths.push(path.join(__dirname, '../../../', dirname));\n \n // Find first existing directory that passes validation\n for (const dirPath of possiblePaths) {\n if (fileExists(dirPath)) {\n if (!validator || validator(dirPath)) {\n return dirPath;\n }\n }\n }\n \n return null;\n}\n\n/**\n * Find a directory with multiple possible relative paths\n * @param {string[]} possiblePaths - Array of possible paths to check\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @returns {string|null} Full path to the directory or null if not found\n */\nfunction findDirectoryWithPaths(possiblePaths, startDir = process.cwd()) {\n // Build absolute paths from the start directory\n const absolutePaths = possiblePaths.map(p => {\n if (path.isAbsolute(p)) {\n return p;\n }\n return path.join(startDir, p);\n });\n \n // Find first existing path\n for (const dirPath of absolutePaths) {\n if (fileExists(dirPath)) {\n return dirPath;\n }\n }\n \n return null;\n}\n\nmodule.exports = {\n findFileUpward,\n findDirectoryUpward,\n findDirectoryWithPaths\n};", "const path = require('path');\nconst { findDirectoryUpward } = require('./path-utils');\nconst { readJsonFileSafe, readFileSafe, fileExists } = require('./file-utils');\n\n/**\n * LocalTokenReader - Reads tokens directly from the local file system\n * Mimics the APIClient interface but reads from apps/tokens directory\n */\nclass LocalTokenReader {\n constructor(ffId, options = {}) {\n this.ffId = ffId;\n this.tokensBasePath = options.tokensBasePath || this.findTokensPath();\n this.folderMap = this.loadFolderMap();\n this.projectFolder = this.folderMap[ffId];\n \n if (!this.projectFolder) {\n throw new Error(`No folder mapping found for ff-id: ${ffId}`);\n }\n \n this.projectPath = path.join(this.tokensBasePath, this.projectFolder);\n }\n\n /**\n * Find the tokens directory by looking for apps/tokens in parent directories\n */\n findTokensPath() {\n // Try to find apps/tokens first\n let tokensPath = findDirectoryUpward('apps/tokens', process.cwd(), (dir) => {\n return fileExists(path.join(dir, 'folderMap.json'));\n });\n \n // If not found, try just 'tokens'\n if (!tokensPath) {\n tokensPath = findDirectoryUpward('tokens', process.cwd(), (dir) => {\n return fileExists(path.join(dir, 'folderMap.json'));\n });\n }\n \n if (!tokensPath) {\n throw new Error('Could not find tokens directory with folderMap.json');\n }\n \n return tokensPath;\n }\n\n /**\n * Load the folder mapping from folderMap.json\n */\n loadFolderMap() {\n const folderMapPath = path.join(this.tokensBasePath, 'folderMap.json');\n const folderMap = readJsonFileSafe(folderMapPath);\n \n if (!folderMap) {\n throw new Error(`Failed to load folderMap.json: File not found`);\n }\n \n return folderMap;\n }\n\n /**\n * Fetch all token files (global, colors, semantic)\n * Mimics the APIClient.fetchTokens() method\n */\n async fetchTokens() {\n const figmaPath = path.join(this.projectPath, 'figma');\n \n // Try different possible paths for tokens\n const tokenPaths = {\n global: [\n path.join(figmaPath, 'Global Tokens', 'Default.json'),\n path.join(figmaPath, 'global.json')\n ],\n colors: [\n path.join(figmaPath, 'Global Colors', 'Default.json'),\n path.join(figmaPath, 'Global Colors', 'Light.json')\n ],\n semantic: [\n path.join(figmaPath, 'Semantic', 'Light.json'),\n path.join(figmaPath, 'Semantic', 'Default.json')\n ],\n semanticDark: [\n path.join(figmaPath, 'Semantic', 'Dark.json')\n ]\n };\n\n const results = {};\n \n // Try each possible path for each token type\n for (const [key, paths] of Object.entries(tokenPaths)) {\n for (const tokenPath of paths) {\n const content = readJsonFileSafe(tokenPath);\n if (content !== null) {\n results[key] = content;\n break; // Found it, no need to try other paths\n }\n }\n // If not found in any path, set to null\n if (!results[key]) {\n results[key] = null;\n }\n }\n\n return results;\n }\n\n /**\n * Fetch pre-processed tokens (if available in cache folder)\n */\n async fetchProcessedTokens() {\n const cachePath = path.join(this.projectPath, 'cache');\n \n if (!fileExists(cachePath)) {\n return null;\n }\n\n const parseModuleExports = (content) => {\n if (content === null) return null;\n\n const moduleExports = {};\n const fakeModule = { exports: moduleExports };\n const evalFunc = new Function('module', 'exports', content);\n evalFunc(fakeModule, moduleExports);\n return fakeModule.exports;\n };\n\n // Read all local cache files and normalize them to CacheManager.save() keys.\n const cacheFiles = {\n tokens: { fileName: 'hashedTokens.js', type: 'module' },\n variables: { fileName: 'hashedVariables.js', type: 'module' },\n semanticVariables: { fileName: 'hashedSemanticVariables.js', type: 'module' },\n semanticDarkVariables: { fileName: 'hashedSemanticDarkVariables.js', type: 'module' },\n safelist: { fileName: 'safelist.js', type: 'module' },\n custom: { fileName: 'custom.js', type: 'module' },\n fonts: { fileName: 'fonts.json', type: 'json' },\n icons: { fileName: 'icons.json', type: 'json' },\n componentsConfig: { fileName: 'encoded-config.json', type: 'json' },\n version: { fileName: 'version.json', type: 'json' }\n };\n\n const processedData = {};\n \n for (const [key, { fileName, type }] of Object.entries(cacheFiles)) {\n const filePath = path.join(cachePath, fileName);\n const value = type === 'module'\n ? parseModuleExports(readFileSafe(filePath))\n : readJsonFileSafe(filePath);\n\n if (value !== null) {\n processedData[key] = value;\n }\n }\n\n // Only return if we have at least some data\n const hasData = Object.values(processedData).some(val => val !== null);\n return hasData ? processedData : null;\n }\n\n /**\n * Fetch components configuration\n */\n async fetchComponentsConfig() {\n return readJsonFileSafe(path.join(this.projectPath, 'components-config.json'));\n }\n\n /**\n * Fetch fonts configuration\n */\n async fetchFonts() {\n return readJsonFileSafe(path.join(this.projectPath, 'font.json'));\n }\n\n /**\n * Fetch icons configuration\n */\n async fetchIcons() {\n return readJsonFileSafe(path.join(this.projectPath, 'icons.json'));\n }\n\n /**\n * Fetch version information\n */\n async fetchVersion() {\n return readJsonFileSafe(path.join(this.projectPath, 'version.json'));\n }\n\n /**\n * Fetch custom CSS\n */\n async fetchCustomCss() {\n return readFileSafe(path.join(this.projectPath, 'custom.css'));\n }\n\n /**\n * Fetch plan metadata\n */\n async fetchPlanMetadata() {\n const metadata = readJsonFileSafe(path.join(this.projectPath, 'metadata.json'));\n \n // Default to full plan if no metadata exists\n return metadata || {\n planType: 'full',\n allowedComponents: null\n };\n }\n\n // Compatibility methods to match APIClient interface\n fetchJson() {\n throw new Error('fetchJson is not implemented in LocalTokenReader. Use specific fetch methods.');\n }\n\n fetchRaw() {\n throw new Error('fetchRaw is not implemented in LocalTokenReader. Use specific fetch methods.');\n }\n}\n\nmodule.exports = { LocalTokenReader };\n"],
5
+ "mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,KAAMC,EAAK,QAAQ,IAAI,EAQvB,SAASC,EAAiBC,EAAU,CAClC,GAAI,CACF,IAAMC,EAAUH,EAAG,aAAaE,EAAU,MAAM,EAChD,OAAO,KAAK,MAAMC,CAAO,CAC3B,OAASC,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET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,EAAK,CAAE,SAAAU,EAAU,KAAAC,CAAK,CAAC,IAAK,OAAO,QAAQH,CAAU,EAAG,CAClE,IAAMI,EAAW3B,EAAK,KAAKmB,EAAWM,CAAQ,EACxCG,EAAQF,IAAS,SACnBN,EAAmBjB,EAAawB,CAAQ,CAAC,EACzCzB,EAAiByB,CAAQ,EAEzBC,IAAU,OACZJ,EAAcT,CAAG,EAAIa,EAEzB,CAIA,OADgB,OAAO,OAAOJ,CAAa,EAAE,KAAKK,GAAOA,IAAQ,IAAI,EACpDL,EAAgB,IACnC,CAKA,MAAM,uBAAwB,CAC5B,OAAOtB,EAAiBF,EAAK,KAAK,KAAK,YAAa,wBAAwB,CAAC,CAC/E,CAKA,MAAM,YAAa,CACjB,OAAOE,EAAiBF,EAAK,KAAK,KAAK,YAAa,WAAW,CAAC,CAClE,CAKA,MAAM,YAAa,CACjB,OAAOE,EAAiBF,EAAK,KAAK,KAAK,YAAa,YAAY,CAAC,CACnE,CAKA,MAAM,cAAe,CACnB,OAAOE,EAAiBF,EAAK,KAAK,KAAK,YAAa,cAAc,CAAC,CACrE,CAKA,MAAM,gBAAiB,CACrB,OAAOG,EAAaH,EAAK,KAAK,KAAK,YAAa,YAAY,CAAC,CAC/D,CAKA,MAAM,mBAAoB,CAIxB,OAHiBE,EAAiBF,EAAK,KAAK,KAAK,YAAa,eAAe,CAAC,GAG3D,CACjB,SAAU,OACV,kBAAmB,IACrB,CACF,CAGA,WAAY,CACV,MAAM,IAAI,MAAM,+EAA+E,CACjG,CAEA,UAAW,CACT,MAAM,IAAI,MAAM,8EAA8E,CAChG,CACF,EAEA,OAAO,QAAU,CAAE,iBAAAK,CAAiB",
6
+ "names": ["require_file_utils", "__commonJSMin", "exports", "module", "fs", "readJsonFileSafe", "filepath", "content", "error", "readFileSafe", "writeJsonFile", "data", "indent", "writeTextFile", "writeModuleExportsFile", "fileExists", "ensureDirectoryExists", "dirpath", "removeDirectory", "require_path_utils", "__commonJSMin", "exports", "module", "path", "fileExists", "findFileUpward", "filename", "startDir", "currentDir", "filePath", "findDirectoryUpward", "dirname", "validator", "possiblePaths", "maxLevels", "i", "parentDir", "dirPath", "findDirectoryWithPaths", "absolutePaths", "p", "path", "findDirectoryUpward", "readJsonFileSafe", "readFileSafe", "fileExists", "LocalTokenReader", "ffId", "options", "tokensPath", "dir", "folderMapPath", "folderMap", "figmaPath", "tokenPaths", "results", "key", "paths", "tokenPath", "content", "cachePath", "parseModuleExports", "moduleExports", "fakeModule", "cacheFiles", "processedData", "fileName", "type", "filePath", "value", "val"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var y=h((b,f)=>{var c=require("fs");function d(r){try{let e=c.readFileSync(r,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function a(r){try{return c.readFileSync(r,"utf8").replace(/^\uFEFF/,"")}catch(e){if(e.code==="ENOENT")return null;throw e}}function w(r,e,n=2){let t=JSON.stringify(e,null,n);c.writeFileSync(r,t,"utf8")}function F(r,e){if(e==null||typeof e=="object"&&Object.keys(e).length===0||Array.isArray(e)&&e.length===0){let t=`module.exports = ${Array.isArray(e)?"[]":"{}"};`;c.writeFileSync(r,t,"utf8")}else{let n=`module.exports = ${JSON.stringify(e,null,2)};`;c.writeFileSync(r,n,"utf8")}}function S(r){return c.existsSync(r)}function m(r){c.mkdirSync(r,{recursive:!0})}function x(r){c.rmSync(r,{recursive:!0,force:!0})}f.exports={readJsonFileSafe:d,readFileSafe:a,writeJsonFile:w,writeModuleExportsFile:F,fileExists:S,ensureDirectoryExists:m,removeDirectory:x}});var i=require("path"),{fileExists:u}=y();function E(r,e=process.cwd()){let n=e;for(;n!==i.parse(n).root;){let t=i.join(n,r);if(u(t))return t;n=i.dirname(n)}return null}function j(r,e=process.cwd(),n=null){let t=[],s=e,p=10;for(let o=0;o<p;o++){t.push(i.join(s,r)),o<3&&t.push(i.join(s,"../".repeat(o+1)+r));let l=i.dirname(s);if(l===s)break;s=l}t.push(i.join(__dirname,"../../../",r));for(let o of t)if(u(o)&&(!n||n(o)))return o;return null}function D(r,e=process.cwd()){let n=r.map(t=>i.isAbsolute(t)?t:i.join(e,t));for(let t of n)if(u(t))return t;return null}module.exports={findFileUpward:E,findDirectoryUpward:j,findDirectoryWithPaths:D};
1
+ var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var y=h((O,f)=>{var i=require("fs");function d(r){try{let e=i.readFileSync(r,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function w(r){try{return i.readFileSync(r,"utf8").replace(/^\uFEFF/,"")}catch(e){if(e.code==="ENOENT")return null;throw e}}function F(r,e,n=2){let t=JSON.stringify(e,null,n);i.writeFileSync(r,t,"utf8")}function a(r,e){i.writeFileSync(r,e,"utf8")}function S(r,e){if(e==null||typeof e=="object"&&Object.keys(e).length===0||Array.isArray(e)&&e.length===0){let t=`module.exports = ${Array.isArray(e)?"[]":"{}"};`;i.writeFileSync(r,t,"utf8")}else{let n=`module.exports = ${JSON.stringify(e,null,2)};`;i.writeFileSync(r,n,"utf8")}}function x(r){return i.existsSync(r)}function m(r){i.mkdirSync(r,{recursive:!0})}function E(r){i.rmSync(r,{recursive:!0,force:!0})}f.exports={readJsonFileSafe:d,readFileSafe:w,writeJsonFile:F,writeTextFile:a,writeModuleExportsFile:S,fileExists:x,ensureDirectoryExists:m,removeDirectory:E}});var o=require("path"),{fileExists:u}=y();function j(r,e=process.cwd()){let n=e;for(;n!==o.parse(n).root;){let t=o.join(n,r);if(u(t))return t;n=o.dirname(n)}return null}function D(r,e=process.cwd(),n=null){let t=[],s=e,p=10;for(let c=0;c<p;c++){t.push(o.join(s,r)),c<3&&t.push(o.join(s,"../".repeat(c+1)+r));let l=o.dirname(s);if(l===s)break;s=l}t.push(o.join(__dirname,"../../../",r));for(let c of t)if(u(c)&&(!n||n(c)))return c;return null}function N(r,e=process.cwd()){let n=r.map(t=>o.isAbsolute(t)?t:o.join(e,t));for(let t of n)if(u(t))return t;return null}module.exports={findFileUpward:j,findDirectoryUpward:D,findDirectoryWithPaths:N};
2
2
  //# sourceMappingURL=path-utils.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../lib/core/file-utils.js", "../../../lib/core/path-utils.js"],
4
- "sourcesContent": ["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 * Strips UTF-8 BOM if present (fixes Windows compatibility)\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 const content = fs.readFileSync(filepath, 'utf8');\n // Strip UTF-8 BOM if present (Windows compatibility)\n return content.replace(/^\\uFEFF/, '');\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 { fileExists } = require('./file-utils');\n\n/**\n * Find a file by traversing up the directory tree\n * @param {string} filename - Name of the file to find\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @returns {string|null} Full path to the file or null if not found\n */\nfunction findFileUpward(filename, startDir = process.cwd()) {\n let currentDir = startDir;\n \n while (currentDir !== path.parse(currentDir).root) {\n const filePath = path.join(currentDir, filename);\n \n if (fileExists(filePath)) {\n return filePath;\n }\n \n currentDir = path.dirname(currentDir);\n }\n \n return null;\n}\n\n/**\n * Find a directory by traversing up and checking multiple possible paths\n * @param {string} dirname - Name of the directory to find\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @param {Function} validator - Optional function to validate the directory\n * @returns {string|null} Full path to the directory or null if not found\n */\nfunction findDirectoryUpward(dirname, startDir = process.cwd(), validator = null) {\n const possiblePaths = [];\n let currentDir = startDir;\n const maxLevels = 10; // Prevent infinite loop\n \n // Build list of possible paths\n for (let i = 0; i < maxLevels; i++) {\n // Direct path\n possiblePaths.push(path.join(currentDir, dirname));\n \n // Relative paths up to 3 levels\n if (i < 3) {\n possiblePaths.push(path.join(currentDir, '../'.repeat(i + 1) + dirname));\n }\n \n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) break; // Reached root\n currentDir = parentDir;\n }\n \n // Also check from module directory (for when running from node_modules)\n possiblePaths.push(path.join(__dirname, '../../../', dirname));\n \n // Find first existing directory that passes validation\n for (const dirPath of possiblePaths) {\n if (fileExists(dirPath)) {\n if (!validator || validator(dirPath)) {\n return dirPath;\n }\n }\n }\n \n return null;\n}\n\n/**\n * Find a directory with multiple possible relative paths\n * @param {string[]} possiblePaths - Array of possible paths to check\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @returns {string|null} Full path to the directory or null if not found\n */\nfunction findDirectoryWithPaths(possiblePaths, startDir = process.cwd()) {\n // Build absolute paths from the start directory\n const absolutePaths = possiblePaths.map(p => {\n if (path.isAbsolute(p)) {\n return p;\n }\n return path.join(startDir, p);\n });\n \n // Find first existing path\n for (const dirPath of absolutePaths) {\n if (fileExists(dirPath)) {\n return dirPath;\n }\n }\n \n return null;\n}\n\nmodule.exports = {\n findFileUpward,\n findDirectoryUpward,\n findDirectoryWithPaths\n};"],
5
- "mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,KAAMC,EAAK,QAAQ,IAAI,EAQvB,SAASC,EAAiBC,EAAU,CAClC,GAAI,CACF,IAAMC,EAAUH,EAAG,aAAaE,EAAU,MAAM,EAChD,OAAO,KAAK,MAAMC,CAAO,CAC3B,OAASC,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET,MAAMA,CACR,CACF,CASA,SAASC,EAAaH,EAAU,CAC9B,GAAI,CAGF,OAFgBF,EAAG,aAAaE,EAAU,MAAM,EAEjC,QAAQ,UAAW,EAAE,CACtC,OAASE,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET,MAAMA,CACR,CACF,CAQA,SAASE,EAAcJ,EAAUK,EAAMC,EAAS,EAAG,CACjD,IAAML,EAAU,KAAK,UAAUI,EAAM,KAAMC,CAAM,EACjDR,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EAAaD,EACXO,EAAY,GAGlB,QAASC,EAAI,EAAGA,EAAID,EAAWC,IAAK,CAElCF,EAAc,KAAKV,EAAK,KAAKK,EAAYG,CAAO,CAAC,EAG7CI,EAAI,GACNF,EAAc,KAAKV,EAAK,KAAKK,EAAY,MAAM,OAAOO,EAAI,CAAC,EAAIJ,CAAO,CAAC,EAGzE,IAAMK,EAAYb,EAAK,QAAQK,CAAU,EACzC,GAAIQ,IAAcR,EAAY,MAC9BA,EAAaQ,CACf,CAGAH,EAAc,KAAKV,EAAK,KAAK,UAAW,YAAaQ,CAAO,CAAC,EAG7D,QAAWM,KAAWJ,EACpB,GAAIT,EAAWa,CAAO,IAChB,CAACL,GAAaA,EAAUK,CAAO,GACjC,OAAOA,EAKb,OAAO,IACT,CAQA,SAASC,EAAuBL,EAAeN,EAAW,QAAQ,IAAI,EAAG,CAEvE,IAAMY,EAAgBN,EAAc,IAAIO,GAClCjB,EAAK,WAAWiB,CAAC,EACZA,EAEFjB,EAAK,KAAKI,EAAUa,CAAC,CAC7B,EAGD,QAAWH,KAAWE,EACpB,GAAIf,EAAWa,CAAO,EACpB,OAAOA,EAIX,OAAO,IACT,CAEA,OAAO,QAAU,CACf,eAAAZ,EACA,oBAAAK,EACA,uBAAAQ,CACF",
6
- "names": ["require_file_utils", "__commonJSMin", "exports", "module", "fs", "readJsonFileSafe", "filepath", "content", "error", "readFileSafe", "writeJsonFile", "data", "indent", "writeModuleExportsFile", "fileExists", "ensureDirectoryExists", "dirpath", "removeDirectory", "path", "fileExists", "findFileUpward", "filename", "startDir", "currentDir", "filePath", "findDirectoryUpward", "dirname", "validator", "possiblePaths", "maxLevels", "i", "parentDir", "dirPath", "findDirectoryWithPaths", "absolutePaths", "p"]
4
+ "sourcesContent": ["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 * Strips UTF-8 BOM if present (fixes Windows compatibility)\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 const content = fs.readFileSync(filepath, 'utf8');\n // Strip UTF-8 BOM if present (Windows compatibility)\n return content.replace(/^\\uFEFF/, '');\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 plain text content to a file\n * @param {string} filepath - Path to write the file\n * @param {string} content - Text content to write\n */\nfunction writeTextFile(filepath, content) {\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 writeTextFile,\n writeModuleExportsFile,\n fileExists,\n ensureDirectoryExists,\n removeDirectory\n};\n", "const path = require('path');\nconst { fileExists } = require('./file-utils');\n\n/**\n * Find a file by traversing up the directory tree\n * @param {string} filename - Name of the file to find\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @returns {string|null} Full path to the file or null if not found\n */\nfunction findFileUpward(filename, startDir = process.cwd()) {\n let currentDir = startDir;\n \n while (currentDir !== path.parse(currentDir).root) {\n const filePath = path.join(currentDir, filename);\n \n if (fileExists(filePath)) {\n return filePath;\n }\n \n currentDir = path.dirname(currentDir);\n }\n \n return null;\n}\n\n/**\n * Find a directory by traversing up and checking multiple possible paths\n * @param {string} dirname - Name of the directory to find\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @param {Function} validator - Optional function to validate the directory\n * @returns {string|null} Full path to the directory or null if not found\n */\nfunction findDirectoryUpward(dirname, startDir = process.cwd(), validator = null) {\n const possiblePaths = [];\n let currentDir = startDir;\n const maxLevels = 10; // Prevent infinite loop\n \n // Build list of possible paths\n for (let i = 0; i < maxLevels; i++) {\n // Direct path\n possiblePaths.push(path.join(currentDir, dirname));\n \n // Relative paths up to 3 levels\n if (i < 3) {\n possiblePaths.push(path.join(currentDir, '../'.repeat(i + 1) + dirname));\n }\n \n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) break; // Reached root\n currentDir = parentDir;\n }\n \n // Also check from module directory (for when running from node_modules)\n possiblePaths.push(path.join(__dirname, '../../../', dirname));\n \n // Find first existing directory that passes validation\n for (const dirPath of possiblePaths) {\n if (fileExists(dirPath)) {\n if (!validator || validator(dirPath)) {\n return dirPath;\n }\n }\n }\n \n return null;\n}\n\n/**\n * Find a directory with multiple possible relative paths\n * @param {string[]} possiblePaths - Array of possible paths to check\n * @param {string} startDir - Starting directory (defaults to cwd)\n * @returns {string|null} Full path to the directory or null if not found\n */\nfunction findDirectoryWithPaths(possiblePaths, startDir = process.cwd()) {\n // Build absolute paths from the start directory\n const absolutePaths = possiblePaths.map(p => {\n if (path.isAbsolute(p)) {\n return p;\n }\n return path.join(startDir, p);\n });\n \n // Find first existing path\n for (const dirPath of absolutePaths) {\n if (fileExists(dirPath)) {\n return dirPath;\n }\n }\n \n return null;\n}\n\nmodule.exports = {\n findFileUpward,\n findDirectoryUpward,\n findDirectoryWithPaths\n};"],
5
+ "mappings": "8DAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,KAAMC,EAAK,QAAQ,IAAI,EAQvB,SAASC,EAAiBC,EAAU,CAClC,GAAI,CACF,IAAMC,EAAUH,EAAG,aAAaE,EAAU,MAAM,EAChD,OAAO,KAAK,MAAMC,CAAO,CAC3B,OAASC,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET,MAAMA,CACR,CACF,CASA,SAASC,EAAaH,EAAU,CAC9B,GAAI,CAGF,OAFgBF,EAAG,aAAaE,EAAU,MAAM,EAEjC,QAAQ,UAAW,EAAE,CACtC,OAASE,EAAO,CACd,GAAIA,EAAM,OAAS,SACjB,OAAO,KAET,MAAMA,CACR,CACF,CAQA,SAASE,EAAcJ,EAAUK,EAAMC,EAAS,EAAG,CACjD,IAAML,EAAU,KAAK,UAAUI,EAAM,KAAMC,CAAM,EACjDR,EAAG,cAAcE,EAAUC,EAAS,MAAM,CAC5C,CAOA,SAASM,EAAcP,EAAUC,EAAS,CACxCH,EAAG,cAAcE,EAAUC,EAAS,MAAM,CAC5C,CAOA,SAASO,EAAuBR,EAAUK,EAAM,CAE9C,GAAIA,GAAS,MACR,OAAOA,GAAS,UAAY,OAAO,KAAKA,CAAI,EAAE,SAAW,GACzD,MA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AKV,EAAK,KAAKK,EAAY,MAAM,OAAOO,EAAI,CAAC,EAAIJ,CAAO,CAAC,EAGzE,IAAMK,EAAYb,EAAK,QAAQK,CAAU,EACzC,GAAIQ,IAAcR,EAAY,MAC9BA,EAAaQ,CACf,CAGAH,EAAc,KAAKV,EAAK,KAAK,UAAW,YAAaQ,CAAO,CAAC,EAG7D,QAAWM,KAAWJ,EACpB,GAAIT,EAAWa,CAAO,IAChB,CAACL,GAAaA,EAAUK,CAAO,GACjC,OAAOA,EAKb,OAAO,IACT,CAQA,SAASC,EAAuBL,EAAeN,EAAW,QAAQ,IAAI,EAAG,CAEvE,IAAMY,EAAgBN,EAAc,IAAIO,GAClCjB,EAAK,WAAWiB,CAAC,EACZA,EAEFjB,EAAK,KAAKI,EAAUa,CAAC,CAC7B,EAGD,QAAWH,KAAWE,EACpB,GAAIf,EAAWa,CAAO,EACpB,OAAOA,EAIX,OAAO,IACT,CAEA,OAAO,QAAU,CACf,eAAAZ,EACA,oBAAAK,EACA,uBAAAQ,CACF",
6
+ "names": ["require_file_utils", "__commonJSMin", "exports", "module", "fs", "readJsonFileSafe", "filepath", "content", "error", "readFileSafe", "writeJsonFile", "data", "indent", "writeTextFile", "writeModuleExportsFile", "fileExists", "ensureDirectoryExists", "dirpath", "removeDirectory", "path", "fileExists", "findFileUpward", "filename", "startDir", "currentDir", "filePath", "findDirectoryUpward", "dirname", "validator", "possiblePaths", "maxLevels", "i", "parentDir", "dirPath", "findDirectoryWithPaths", "absolutePaths", "p"]
7
7
  }
@@ -1,2 +1,4 @@
1
- var V=(d,e)=>()=>(e||d((e={exports:{}}).exports,e),e.exports);var x=V((S,O)=>{var v=class extends Error{constructor(e,t,o){super(e),this.name="APIError",this.statusCode=t,this.url=o,this.code=`API_${t}`}},C=class extends Error{constructor(e,t){super(e),this.name="CacheError",this.operation=t,this.code=`CACHE_${t.toUpperCase()}`}},k=class extends Error{constructor(e,t){super(e),this.name="ConfigError",this.field=t,this.code=`CONFIG_${t.toUpperCase()}`}},F=class extends Error{constructor(e,t){super(e),this.name="ProcessingError",this.token=t,this.code="PROCESSING_ERROR"}};O.exports={APIError:v,CacheError:C,ConfigError:k,ProcessingError:F}});var N=require("color"),w=require("https"),{ProcessingError:W}=x(),g=class{hexToHsl(e){try{let t=N(e),o=t.hsl(),s=Math.round(o.hue()),r=Math.round(o.saturationl()),c=Math.round(o.lightness()),i=t.alpha();if(i<1){let a=Math.round(i*100)/100;return`${s} ${r}% ${c}% / ${a}`}return`${s} ${r}% ${c}%`}catch(t){throw new W(`Failed to convert color ${e}: ${t.message}`,e)}}processColors(e){let t={},o={},s={backgroundColor:{},textColor:{},borderColor:{}};if(!e||typeof e!="object")return console.log(" \u26A0\uFE0F No valid color data to process"),{variables:t,colorMap:o,utilities:s};let r=(c,i="")=>{for(let[a,l]of Object.entries(c))if(l&&typeof l=="object")if(l.$value){let n=i?`${i}-${a}`:a,u=`--color-${n}`,f=this.hexToHsl(l.$value);t[u]=f,o[n]=u,s.backgroundColor[n]=`hsl(var(${u}))`,s.textColor[n]=`hsl(var(${u}))`,s.borderColor[n]=`hsl(var(${u}))`}else{let n=i?`${i}-${a}`:a;r(l,n)}};return e&&(e.colors?r(e.colors):r(e)),{variables:t,colorMap:o,utilities:s}}processSemanticTokens(e,t){let o={},s={backgroundColor:{},textColor:{},borderColor:{}},r=a=>a.replace(/ /g,"").replace(/\./g,"-").toLowerCase(),c=a=>{if(typeof a!="string")return null;let l=a.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=(a,l)=>{if(e[a])for(let[n,u]of Object.entries(e[a])){if(n==="disabled"){let f=c(u.$value);if(f){let m=t[f];if(m){let h=`--${a}-disabled`;o[h]=`var(${m})`,s[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 y=`--${a}-${$}`,j=c(p.$value);if(j){let b=t[j];b&&(o[y]=`var(${b})`,s[l][$]=`var(${y})`)}else if(p.$value){let b=this.hexToHsl(p.$value);o[y]=b,s[l][$]=`hsl(var(${y}))`}}}};if(i("bg","backgroundColor"),i("text","textColor"),i("border","borderColor"),e.layer)for(let[a,l]of Object.entries(e.layer)){let n=`--layer-${a}`,u=c(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})`,s.backgroundColor[`layer-${a}`]=`var(${n})`}else{let m=t[f];m&&(o[n]=`var(${m})`,s.backgroundColor[`layer-${a}`]=`var(${n})`)}}else if(l.$value){let f=this.hexToHsl(l.$value);o[n]=f,s.backgroundColor[`layer-${a}`]=`hsl(var(${n}))`}}if(e.overlay)for(let[a,l]of Object.entries(e.overlay)){let n=`--overlay-${a}`;l.$value&&(o[n]=l.$value,s.backgroundColor[`overlay-${a}`]=`var(${n})`)}if(e.icon){s.fill||(s.fill={});for(let[a,l]of Object.entries(e.icon)){if(a==="disabled"){let n=c(l.$value);if(n){let u=t[n];if(u){let f="--icon-disabled";o[f]=`var(${u})`,s.textColor["icon-disabled"]=`var(${f})`,s.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-${a}-${n}-${f}`);h.endsWith("-default")&&(h=h.slice(0,-8));let p=`--${h}`,$=c(m.$value);if($){let y=t[$];y&&(o[p]=`var(${y})`,s.textColor[h]=`var(${p})`,s.fill[h]=`var(${p})`)}}}}return{semanticVariables:o,tokens:s}}async fetchFontCss(e){return new Promise((t,o)=>{w.get(e,s=>{let r="";if(s.statusCode!==200){o(new Error(`Failed to fetch font CSS: ${s.statusCode}`));return}s.on("data",c=>{r+=c}),s.on("end",()=>{t(r)}),s.on("error",c=>{o(c)})}).on("error",s=>{o(s)})})}parseFontFaces(e){let t=/@font-face\s*{([^}]+)}/g,o=[],s;for(;(s=t.exec(e))!==null;){let r=s[1].trim().split(";").filter(Boolean),c={};r.forEach(i=>{let a=i.indexOf(":");if(a!==-1){let l=i.slice(0,a).trim(),n=i.slice(a+1).trim();l==="font-family"?c[l]=n.replace(/["']/g,""):c[l]=n}}),c.src&&(c.src=c.src.replace(/url\(["']?/,"url('").replace(/["']?\)/,"')")),o.push(c)}return o}async processFonts(e){let t=[];if(!e||typeof e!="object")return t;let o=Object.keys(e).filter(s=>s.startsWith("font"));for(let s of o){let r=e[s];if(typeof r=="string"&&r.startsWith("http"))try{let c=await this.fetchFontCss(r),i=this.parseFontFaces(c);i.length>0&&t.push(...i)}catch(c){console.warn(`Failed to process font ${s}:`,c.message)}}return t}processFontFamilies(e){let t={};if(!e||!e.font||!e.font.family)return t;let o=e.font.family;for(let[s,r]of Object.entries(o))if(r&&r.$value){let c=s.toLowerCase(),i=r.$value;typeof i=="string"&&i.startsWith("{")&&i.endsWith("}")&&(i=i.slice(1,-1));let a=l=>l.split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(" ");if(i.includes(","))t[c]=i;else{let l=a(i);l.includes(" ")&&!l.startsWith('"')&&!l.startsWith("'")?t[c]=`"${l}", sans-serif`:t[c]=`${l}, sans-serif`}}return t}processAnimations(e){let t={},o={};if(!e||typeof e!="object")return{keyframes:t,animations:o};for(let[s,r]of Object.entries(e))if(r&&typeof r=="object"){let c=`${s}`;if(r.keyframes){let a={};for(let[l,n]of Object.entries(r.keyframes))n&&typeof n=="object"&&(a[l]=n);t[c]=a}let i=[c,r.duration||"1s",r.easing||"ease",r.delay||"0s",r.iterations||"1",r.direction||"normal",r.fillMode||"none"].join(" ");o[s]=i}return{keyframes:t,animations:o}}generateSafelistClasses(e){let t=[];if(e.backgroundColor)for(let o of Object.keys(e.backgroundColor))t.push(`bg-${o}`);if(e.textColor)for(let o of Object.keys(e.textColor))t.push(`text-${o}`);if(e.borderColor)for(let o of Object.keys(e.borderColor))t.push(`border-${o}`);if(e.fill)for(let o of Object.keys(e.fill))t.push(`fill-${o}`),o.startsWith("icon-")&&t.push(`text-${o}`);if(e.fontFamily)for(let o of Object.keys(e.fontFamily))t.push(`font-${o}`);if(e.animations)for(let o of Object.keys(e.animations))t.push(`animate-${o}`);return t}extractClassesFromComponentsConfig(e){let t=new Set,o=r=>{typeof r=="string"&&r.split(/\s+/).filter(i=>i.length>0).forEach(i=>{t.add(i)})},s=r=>{if(!(!r||typeof r!="object"))for(let c in r){let i=r[c];typeof i=="string"?o(i):typeof i=="object"&&s(i)}};return e&&s(e),Array.from(t).filter(r=>!r.startsWith("file:")).sort()}processCustomCss(e){return!e||typeof e!="string"?{}:{raw:e}}async process(e){try{let t={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 s=e.tokens;o=s["Global Colors/Default"]||s["Global Colors"]||s.colors||s}else e.colors&&(o=e.colors);if(o){let s=this.processColors(o);t.variables={...t.variables,...s.variables},t.utilities={...t.utilities,...s.utilities},t.colorMap=s.colorMap||{}}else t.colorMap={};if(e.semantic&&t.colorMap){let s=this.processSemanticTokens(e.semantic,t.colorMap);t.semanticVariables=s.semanticVariables,s.tokens&&(t.tokens=s.tokens,t.utilities=s.tokens)}if(e.semanticDark&&t.colorMap){let s=this.processSemanticTokens(e.semanticDark,t.colorMap);t.semanticDarkVariables=s.semanticVariables}if(e.fonts&&(t.fontFaces=await this.processFonts(e.fonts)),e.globalTokens&&(t.fontFamilies=this.processFontFamilies(e.globalTokens),t.fontFamilies&&(t.utilities.fontFamily||(t.utilities.fontFamily={}),Object.assign(t.utilities.fontFamily,t.fontFamilies))),e.animations){let s=this.processAnimations(e.animations);t.keyframes=s.keyframes,t.animations=s.animations}return t.safelist=this.generateSafelistClasses(t.tokens||t.utilities),t.metadata={timestamp:new Date().toISOString(),version:e.version||"2.0.0",ffId:e.ffId},t}catch(t){throw console.error("Error processing tokens:",t),t}}};module.exports=g;
1
+ var H=(g,t)=>()=>(t||g((t={exports:{}}).exports,t),t.exports);var M=H((U,S)=>{var C=class extends Error{constructor(t,e,r){super(t),this.name="APIError",this.statusCode=e,this.url=r,this.code=`API_${e}`}},x=class extends Error{constructor(t,e){super(t),this.name="CacheError",this.operation=e,this.code=`CACHE_${e.toUpperCase()}`}},w=class extends Error{constructor(t,e){super(t),this.name="ConfigError",this.field=e,this.code=`CONFIG_${e.toUpperCase()}`}},j=class extends Error{constructor(t,e){super(t),this.name="ProcessingError",this.token=e,this.code="PROCESSING_ERROR"}};S.exports={APIError:C,CacheError:x,ConfigError:w,ProcessingError:j}});var W=require("color"),K=require("https"),A=require("fs"),I=require("path"),{ProcessingError:E}=M(),P={"--background":"oklch(1 0 0)","--foreground":"oklch(0.145 0 0)","--card":"oklch(1 0 0)","--card-foreground":"oklch(0.145 0 0)","--popover":"oklch(1 0 0)","--popover-foreground":"oklch(0.145 0 0)","--primary":"oklch(0.205 0 0)","--primary-foreground":"oklch(0.985 0 0)","--secondary":"oklch(0.97 0 0)","--secondary-foreground":"oklch(0.205 0 0)","--muted":"oklch(0.97 0 0)","--muted-foreground":"oklch(0.556 0 0)","--accent":"oklch(0.97 0 0)","--accent-foreground":"oklch(0.205 0 0)","--destructive":"oklch(0.577 0.245 27.325)","--destructive-foreground":"oklch(0.985 0 0)","--border":"oklch(0.922 0 0)","--input":"oklch(0.922 0 0)","--ring":"oklch(0.708 0 0)","--sidebar":"oklch(0.985 0 0)","--sidebar-foreground":"oklch(0.145 0 0)","--sidebar-primary":"oklch(0.205 0 0)","--sidebar-primary-foreground":"oklch(0.985 0 0)","--sidebar-accent":"oklch(0.97 0 0)","--sidebar-accent-foreground":"oklch(0.205 0 0)","--sidebar-border":"oklch(0.922 0 0)","--sidebar-ring":"oklch(0.708 0 0)","--chart-1":"oklch(0.646 0.222 41.116)","--chart-2":"oklch(0.6 0.118 184.704)","--chart-3":"oklch(0.398 0.07 227.392)","--chart-4":"oklch(0.828 0.189 84.429)","--chart-5":"oklch(0.769 0.188 70.08)"},_={"--background":["--bg-default","--bg-neutral-low","--layer-base"],"--foreground":["--text-neutral-strong","--text-default"],"--card":["--layer-1","--bg-neutral-low","--bg-default"],"--card-foreground":["--text-neutral-strong","--text-default"],"--popover":["--layer-1","--bg-neutral-low","--bg-default"],"--popover-foreground":["--text-neutral-strong","--text-default"],"--primary":["--bg-brand-mid","--bg-brand-strong"],"--primary-foreground":["--text-onbrand-strong","--text-inverse-low"],"--secondary":["--bg-interactive-subtle","--bg-neutral-low"],"--secondary-foreground":["--text-oninteractive-subtle","--text-neutral-strong"],"--muted":["--bg-neutral-low","--bg-disabled"],"--muted-foreground":["--text-neutral-subtle","--text-disabled"],"--accent":["--bg-interactive-low","--bg-brand-low","--bg-neutral-low"],"--accent-foreground":["--text-oninteractive-low","--text-brand-strong","--text-neutral-strong"],"--destructive":["--bg-negative-mid","--bg-negative-subtle"],"--destructive-foreground":["--text-onnegative-subtle","--text-inverse-low"],"--border":["--border-neutral-subtle","--border-default"],"--input":["--border-neutral-subtle","--border-default"],"--ring":["--border-brand-mid","--bg-brand-mid"],"--sidebar":["--layer-1","--bg-neutral-low","--bg-default"],"--sidebar-foreground":["--text-neutral-strong","--text-default"],"--sidebar-primary":["--bg-brand-mid","--bg-brand-strong"],"--sidebar-primary-foreground":["--text-onbrand-strong","--text-inverse-low"],"--sidebar-accent":["--bg-interactive-low","--bg-neutral-low"],"--sidebar-accent-foreground":["--text-oninteractive-low","--text-neutral-strong"],"--sidebar-border":["--border-neutral-subtle","--border-default"],"--sidebar-ring":["--border-brand-mid","--bg-brand-mid"],"--chart-1":["--bg-brand-mid","--bg-brand-strong"],"--chart-2":["--bg-interactive-mid","--bg-interactive-low"],"--chart-3":["--bg-positive-mid","--bg-positive-subtle"],"--chart-4":["--bg-warning-mid","--bg-warning-subtle"],"--chart-5":["--bg-negative-mid","--bg-negative-subtle"]};function q(g,t,e){for(let r of t||[])if(g[r])return g[r];return e}function L(g={},t={}){let e={};for(let[s,n]of Object.entries(_))e[s]=q(g,n,P[s]);let r=t.borderRadius||{};return e["--radius"]=r.default||r.md||r.lg||"0.625rem",e["--radius-sm"]=r.sm||"calc(var(--radius) - 4px)",e["--radius-md"]=r.md||"calc(var(--radius) - 2px)",e["--radius-lg"]=r.lg||"var(--radius)",e["--radius-xl"]=r.xl||"calc(var(--radius) + 4px)",e}var V=class{constructor(){this.useTailwindV4=this.detectTailwindVersion()}detectTailwindVersion(){var t,e,r,s;try{let n=I.join(process.cwd(),"package.json");if(!A.existsSync(n))return!1;let i=JSON.parse(A.readFileSync(n,"utf8")),a=((t=i.devDependencies)==null?void 0:t.tailwindcss)||((e=i.dependencies)==null?void 0:e.tailwindcss)||((r=i.peerDependencies)==null?void 0:r.tailwindcss),c=(s=a==null?void 0:a.match(/(\d+)\./))==null?void 0:s[1];return c?Number(c)>=4:!1}catch{return console.warn("[FrontFriend] Could not detect Tailwind version, defaulting to v3 (hex/HSL plugin mode)"),!1}}hexToHsl(t){try{let e=W(t),r=e.hsl(),s=Math.round(r.hue()),n=Math.round(r.saturationl()),i=Math.round(r.lightness()),a=e.alpha();if(a<1){let c=Math.round(a*100)/100;return`${s} ${n}% ${i}% / ${c}`}return`${s} ${n}% ${i}%`}catch(e){throw new E(`Failed to convert color ${t}: ${e.message}`,t)}}hexToOklch(t){try{let e=W(t),r=e.rgb(),s=r.red()/255,n=r.green()/255,i=r.blue()/255,a=y=>y<=.04045?y/12.92:Math.pow((y+.055)/1.055,2.4),c=a(s),l=a(n),o=a(i),u=c*.4124564+l*.3575761+o*.1804375,f=c*.2126729+l*.7151522+o*.072175,d=c*.0193339+l*.119192+o*.9503041,h=Math.cbrt(.8189330101*u+.3618667424*f-.1288597137*d),m=Math.cbrt(.0329845436*u+.9293118715*f+.0361456387*d),b=Math.cbrt(.0482003018*u+.2643662691*f+.633851707*d),p=.2104542553*h+.793617785*m-.0040720468*b,v=1.9779984951*h-2.428592205*m+.4505937099*b,$=.0259040371*h+.7827717662*m-.808675766*b,R=Math.sqrt(v*v+$*$),k=Math.atan2($,v)*180/Math.PI;k<0&&(k+=360);let O=Math.round(p*1e3)/1e3,F=Math.round(R*1e3)/1e3,N=Math.round(k*100)/100,T=e.alpha();if(T<1){let y=Math.round(T*100)/100;return`oklch(${O} ${F} ${N} / ${y})`}return`oklch(${O} ${F} ${N})`}catch(e){throw new E(`Failed to convert color ${t}: ${e.message}`,t)}}processColors(t){let e={},r={},s={backgroundColor:{},textColor:{},borderColor:{}};if(!t||typeof t!="object")return console.log(" \u26A0\uFE0F No valid color data to process"),{variables:e,colorMap:r,utilities:s};let n=(i,a="")=>{for(let[c,l]of Object.entries(i))if(l&&typeof l=="object")if(l.$value){let o=a?`${a}-${c}`:c,u=`--color-${o}`,f=this.useTailwindV4?this.hexToOklch(l.$value):this.hexToHsl(l.$value);e[u]=f,r[o]=u;let d=this.useTailwindV4?`var(${u})`:`hsl(var(${u}))`;s.backgroundColor[o]=d,s.textColor[o]=d,s.borderColor[o]=d}else{let o=a?`${a}-${c}`:c;n(l,o)}};return t&&(t.colors?n(t.colors):n(t)),{variables:e,colorMap:r,utilities:s}}processSemanticTokens(t,e){let r={},s={backgroundColor:{},textColor:{},borderColor:{}},n=c=>c.replace(/ /g,"").replace(/\./g,"-").toLowerCase(),i=c=>{if(typeof c!="string")return null;let l=c.match(/^\{(.+)\}$/);if(!l)return null;let o=l[1].split(".");return o[0]==="colors"&&o.length>1?o[1]==="colors"&&o.length>2?o.slice(2).join("-"):o.slice(1).join("-"):o.join("-")},a=(c,l)=>{if(t[c])for(let[o,u]of Object.entries(t[c])){if(o==="disabled"){let f=i(u.$value);if(f){let d=e[f];if(d){let h=`--${c}-disabled`;r[h]=`var(${d})`,s[l].disabled=`var(${h})`}}continue}for(let[f,d]of Object.entries(u))for(let[h,m]of Object.entries(d)){let b=n(`${o}-${f}-${h}`);b.endsWith("-default")&&(b=b.slice(0,-8));let p=`--${c}-${b}`,v=i(m.$value);if(v){let $=e[v];$&&(r[p]=`var(${$})`,s[l][b]=`var(${p})`)}else if(m.$value){let $=this.useTailwindV4?this.hexToOklch(m.$value):this.hexToHsl(m.$value);r[p]=$,s[l][b]=this.useTailwindV4?`var(${p})`:`hsl(var(${p}))`}}}};if(a("bg","backgroundColor"),a("text","textColor"),a("border","borderColor"),t.layer)for(let[c,l]of Object.entries(t.layer)){let o=`--layer-${c}`,u=i(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 d=`--${f}`;r[o]=`var(${d})`,s.backgroundColor[`layer-${c}`]=`var(${o})`}else{let d=e[f];d&&(r[o]=`var(${d})`,s.backgroundColor[`layer-${c}`]=`var(${o})`)}}else if(l.$value){let f=this.useTailwindV4?this.hexToOklch(l.$value):this.hexToHsl(l.$value);r[o]=f,s.backgroundColor[`layer-${c}`]=this.useTailwindV4?`var(${o})`:`hsl(var(${o}))`}}if(t.overlay)for(let[c,l]of Object.entries(t.overlay)){let o=`--overlay-${c}`;l.$value&&(r[o]=l.$value,s.backgroundColor[`overlay-${c}`]=`var(${o})`)}if(t.icon){s.fill||(s.fill={});for(let[c,l]of Object.entries(t.icon)){if(c==="disabled"){let o=i(l.$value);if(o){let u=e[o];if(u){let f="--icon-disabled";r[f]=`var(${u})`,s.textColor["icon-disabled"]=`var(${f})`,s.fill["icon-disabled"]=`var(${f})`}}continue}for(let[o,u]of Object.entries(l))for(let[f,d]of Object.entries(u)){let h=n(`icon-${c}-${o}-${f}`);h.endsWith("-default")&&(h=h.slice(0,-8));let m=`--${h}`,b=i(d.$value);if(b){let p=e[b];p&&(r[m]=`var(${p})`,s.textColor[h]=`var(${m})`,s.fill[h]=`var(${m})`)}}}}return{semanticVariables:r,tokens:s}}async fetchFontCss(t){return new Promise((e,r)=>{K.get(t,s=>{let n="";if(s.statusCode!==200){r(new Error(`Failed to fetch font CSS: ${s.statusCode}`));return}s.on("data",i=>{n+=i}),s.on("end",()=>{e(n)}),s.on("error",i=>{r(i)})}).on("error",s=>{r(s)})})}parseFontFaces(t){let e=/@font-face\s*{([^}]+)}/g,r=[],s;for(;(s=e.exec(t))!==null;){let n=s[1].trim().split(";").filter(Boolean),i={};n.forEach(a=>{let c=a.indexOf(":");if(c!==-1){let l=a.slice(0,c).trim(),o=a.slice(c+1).trim();l==="font-family"?i[l]=o.replace(/["']/g,""):i[l]=o}}),i.src&&(i.src=i.src.replace(/url\(["']?/,"url('").replace(/["']?\)/,"')")),r.push(i)}return r}async processFonts(t){let e=[];if(!t||typeof t!="object")return e;let r=Object.keys(t).filter(s=>s.startsWith("font"));for(let s of r){let n=t[s];if(typeof n=="string"&&n.startsWith("http"))try{let i=await this.fetchFontCss(n),a=this.parseFontFaces(i);a.length>0&&e.push(...a)}catch(i){console.warn(`Failed to process font ${s}:`,i.message)}}return e}processFontFamilies(t){let e={};if(!t||!t.font||!t.font.family)return e;let r=t.font.family;for(let[s,n]of Object.entries(r))if(n&&n.$value){let i=s.toLowerCase(),a=n.$value;typeof a=="string"&&a.startsWith("{")&&a.endsWith("}")&&(a=a.slice(1,-1));let c=l=>l.split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join(" ");if(a.includes(","))e[i]=a;else{let l=c(a);l.includes(" ")&&!l.startsWith('"')&&!l.startsWith("'")?e[i]=`"${l}", sans-serif`:e[i]=`${l}, sans-serif`}}return e}processAnimations(t){let e={},r={};if(!t||typeof t!="object")return{keyframes:e,animations:r};for(let[s,n]of Object.entries(t))if(n&&typeof n=="object"){let i=`${s}`;if(n.keyframes){let c={};for(let[l,o]of Object.entries(n.keyframes))o&&typeof o=="object"&&(c[l]=o);e[i]=c}let a=[i,n.duration||"1s",n.easing||"ease",n.delay||"0s",n.iterations||"1",n.direction||"normal",n.fillMode||"none"].join(" ");r[s]=a}return{keyframes:e,animations:r}}generateSafelistClasses(t){let e=[];if(t.backgroundColor)for(let r of Object.keys(t.backgroundColor))e.push(`bg-${r}`);if(t.textColor)for(let r of Object.keys(t.textColor))e.push(`text-${r}`);if(t.borderColor)for(let r of Object.keys(t.borderColor))e.push(`border-${r}`);if(t.fill)for(let r of Object.keys(t.fill))e.push(`fill-${r}`),r.startsWith("icon-")&&e.push(`text-${r}`);if(t.fontFamily)for(let r of Object.keys(t.fontFamily))e.push(`font-${r}`);if(t.animations)for(let r of Object.keys(t.animations))e.push(`animate-${r}`);return e}extractClassesFromComponentsConfig(t){let e=new Set,r=n=>{typeof n=="string"&&n.split(/\s+/).filter(a=>a.length>0).forEach(a=>{e.add(a)})},s=n=>{if(!(!n||typeof n!="object"))for(let i in n){let a=n[i];typeof a=="string"?r(a):typeof a=="object"&&s(a)}};return t&&s(t),Array.from(e).filter(n=>!n.startsWith("file:")).sort()}generateClassesContent(t=[]){let e=["/*"," * Frontfriend Component Classes"," *"," * This file contains all classes used in Frontfriend component configs."," * Tailwind v4 scans this file via @source to generate utilities."," * DO NOT EDIT - Auto-generated by frontfriend CLI"," */","","/*"," * Classes:"],r=" * ";for(let s of[...new Set(t)].sort())r.length+s.length+1>100?(e.push(r),r=` * ${s}`):r+=(r===" * "?"":" ")+s;return r!==" * "&&e.push(r),e.push(" */"),e.join(`
2
+ `)}processCustomCss(t){return!t||typeof t!="string"?{}:{raw:t}}async process(t){try{let e={variables:{},semanticVariables:{},semanticDarkVariables:{},utilities:{},fontFaces:[],keyframes:{},animations:{},safelist:[],metadata:{},custom:t.customCss?this.processCustomCss(t.customCss):{}},r=null;if(t.tokens&&typeof t.tokens=="object"){let s=t.tokens;r=s["Global Colors/Default"]||s["Global Colors"]||s.colors||s}else t.colors&&(r=t.colors);if(r){let s=this.processColors(r);e.variables={...e.variables,...s.variables},e.utilities={...e.utilities,...s.utilities},e.colorMap=s.colorMap||{}}else e.colorMap={};if(t.semantic&&e.colorMap){let s=this.processSemanticTokens(t.semantic,e.colorMap);e.semanticVariables=s.semanticVariables,s.tokens&&(e.tokens=s.tokens,e.utilities=s.tokens)}if(t.semanticDark&&e.colorMap){let s=this.processSemanticTokens(t.semanticDark,e.colorMap);e.semanticDarkVariables=s.semanticVariables}if(t.fonts&&(e.fontFaces=await this.processFonts(t.fonts)),t.globalTokens&&(e.fontFamilies=this.processFontFamilies(t.globalTokens),e.fontFamilies&&(e.utilities.fontFamily||(e.utilities.fontFamily={}),Object.assign(e.utilities.fontFamily,e.fontFamilies))),t.animations){let s=this.processAnimations(t.animations);e.keyframes=s.keyframes,e.animations=s.animations}return e.safelist=this.generateSafelistClasses(e.tokens||e.utilities),e.metadata={timestamp:new Date().toISOString(),version:t.version||"2.0.0",ffId:t.ffId},e}catch(e){throw console.error("Error processing tokens:",e),e}}generateThemeCSS(t){var a,c,l;let e=['@import "tw-animate-css";',"","@theme {"];for(let[o,u]of Object.entries(t.variables||{}))e.push(` ${o}: ${u};`);for(let[o,u]of Object.entries(t.fontFamilies||{})){let f=o.startsWith("--")?o:`--font-${o}`,d=Array.isArray(u)?u.join(", "):u;e.push(` ${f}: ${d};`)}for(let[o,u]of Object.entries(((a=t.utilities)==null?void 0:a.spacing)||{})){let f=o.startsWith("--")?o:`--spacing-${o}`;e.push(` ${f}: ${u};`)}for(let[o,u]of Object.entries(((c=t.utilities)==null?void 0:c.borderRadius)||{})){let f=o.startsWith("--")?o:`--radius-${o}`;e.push(` ${f}: ${u};`)}e.push("}","");let r=t.semanticVariables||{},s=L(r,t.utilities||{});e.push(":root:not(.dark) {");for(let[o,u]of Object.entries(s))e.push(` ${o}: ${u};`);for(let[o,u]of Object.entries(r))e.push(` ${o}: ${u};`);if(e.push("}"),t.semanticDarkVariables&&Object.keys(t.semanticDarkVariables).length>0){let o={...r,...t.semanticDarkVariables},u=L(o,t.utilities||{});e.push("",":root:not(.light) {");for(let[f,d]of Object.entries(u))e.push(` ${f}: ${d};`);for(let[f,d]of Object.entries(t.semanticDarkVariables))e.push(` ${f}: ${d};`);e.push("}")}let n={bg:[],text:[],border:[],icon:[],layer:[],overlay:[]};for(let o of Object.keys(t.semanticVariables||{}))o.startsWith("--bg-")&&n.bg.push(o.slice(5)),o.startsWith("--text-")&&n.text.push(o.slice(7)),o.startsWith("--border-")&&n.border.push(o.slice(9)),o.startsWith("--icon-")&&n.icon.push(o.slice(7)),o.startsWith("--layer-")&&n.layer.push(o.slice(8)),o.startsWith("--overlay-")&&n.overlay.push(o.slice(10));let i=(o,u)=>{e.push("",`@utility ${o} {`);for(let f of u)e.push(` ${f}`);e.push("}")};for(let o of n.bg)i(`bg-${o}`,[`background-color: var(--bg-${o});`]);for(let o of n.layer)i(`bg-layer-${o}`,[`background-color: var(--layer-${o});`]);for(let o of n.overlay)i(`bg-overlay-${o}`,[`background-color: var(--overlay-${o});`]);for(let o of n.text)i(`text-${o}`,[`color: var(--text-${o});`]);for(let o of n.border)i(`border-${o}`,[`border-color: var(--border-${o});`]);for(let o of n.icon)i(`icon-${o}`,[`color: var(--icon-${o});`]),i(`text-icon-${o}`,[`color: var(--icon-${o});`]);for(let o of t.fontFaces||[]){e.push("","@font-face {");for(let[u,f]of Object.entries(o)){let d=u.replace(/([A-Z])/g,"-$1").toLowerCase(),h=Array.isArray(f)?f.join(", "):f;e.push(` ${d}: ${h};`)}e.push("}")}for(let[o,u]of Object.entries(t.keyframes||{})){e.push("",`@keyframes ${o} {`);for(let[f,d]of Object.entries(u)){e.push(` ${f} {`);for(let[h,m]of Object.entries(d)){let b=h.replace(/([A-Z])/g,"-$1").toLowerCase();e.push(` ${b}: ${m};`)}e.push(" }")}e.push("}")}for(let[o,u]of Object.entries(t.animations||{}))i(`animate-${o}`,[`animation: ${u};`]);return(l=t.custom)!=null&&l.raw&&e.push("","/* Custom CSS */",t.custom.raw),e.push("","/* Component classes for Tailwind scanning */","@source './classes.css';"),e.join(`
3
+ `)}};module.exports=V;
2
4
  //# sourceMappingURL=token-processor.js.map