@frontfriend/sdk 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/dist/browser.mjs +1 -1
- package/dist/cli.js +154 -154
- package/dist/components-config-schema.d.ts +9 -1
- package/dist/components-config-schema.js +1 -1
- package/dist/ffdc.js +1 -1
- package/dist/ffdc.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/core/adoption.js +1 -1
- package/dist/lib/core/api-client.js +1 -1
- package/dist/lib/core/application-adoption.js +1 -1
- package/dist/lib/core/classes-source.js +1 -1
- package/dist/lib/core/components-config-schema.js +1 -1
- package/dist/lib/core/credentials.js +2 -2
- package/dist/lib/core/token-artifact-client.js +6 -6
- package/dist/lib/core/token-artifact.d.ts +12 -0
- package/dist/lib/core/token-artifact.js +1 -1
- package/dist/lib/core/token-processor.js +5 -5
- package/dist/mcp.cjs +32 -32
- package/dist/next.js +2 -2
- package/dist/package.json +1 -1
- package/dist/vite.js +2 -2
- package/package.json +14 -15
package/dist/next.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var f=(
|
|
2
|
-
`,{mode:384}),a.renameSync(r,
|
|
1
|
+
var f=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var O=f((Pe,te)=>{te.exports={name:"@frontfriend/sdk",version:"1.2.0"}});var N=f((Me,k)=>{var{name:re}=O();k.exports={PACKAGE_NAME:re}});var T=f((He,g)=>{var se="https://app.frontfriend.dev",ie=".cache/frontfriend",oe={JS:["tokens.js","variables.js","semanticVariables.js","semanticDarkVariables.js","keyframes.js","animations.js","safelist.js","custom.js"],JSON:["fonts.json","icons.json","components-config.json","iconLibrary.json","version.json","versionMetadata.json","metadata.json","base.json","nativeTokens.json"]},ce={FF_ID:"FF_ID",FF_API_URL:"FF_API_URL",FF_AUTH_TOKEN:"FF_AUTH_TOKEN",FF_MACHINE_TOKEN:"FRONTFRIEND_MACHINE_TOKEN"};function ae(n){if(!n)return null;try{let e=new URL(n);return e.hostname.startsWith("app.")?`${e.protocol}//${e.hostname.replace(/^app\./,"registry.")}`:null}catch{return null}}g.exports={DEFAULT_API_URL:se,CACHE_DIR_NAME:ie,CACHE_TTL_DAYS:7,CACHE_TTL_MS:6048e5,CACHE_FILES:oe,ENV_VARS:ce,deriveRegistryFromApiUrl:ae}});var R=f((Ue,I)=>{var E=class extends Error{constructor(e,r,t){super(e),this.name="APIError",this.statusCode=r,this.url=t,this.code=`API_${r}`}},_=class extends Error{constructor(e,r){super(e),this.name="CacheError",this.operation=r,this.code=`CACHE_${r.toUpperCase()}`}},C=class extends Error{constructor(e,r){super(e),this.name="ConfigError",this.field=r,this.code=r?`CONFIG_${String(r).toUpperCase()}`:"CONFIG_ERROR"}},w=class extends Error{constructor(e,r){super(e),this.name="ProcessingError",this.token=r,this.code="PROCESSING_ERROR"}};I.exports={APIError:E,CacheError:_,ConfigError:C,ProcessingError:w}});var $=f((qe,L)=>{var a=require("fs");function ue(n){try{let e=a.readFileSync(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function le(n){try{return a.readFileSync(n,"utf8").replace(/^\uFEFF/,"")}catch(e){if(e.code==="ENOENT")return null;throw e}}function fe(n,e,r=2){let t=JSON.stringify(e,null,r);a.writeFileSync(n,t,"utf8")}function he(n,e){a.writeFileSync(n,e,"utf8")}function me(n,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)?"[]":"{}"};`;a.writeFileSync(n,t,"utf8")}else{let r=`module.exports = ${JSON.stringify(e,null,2)};`;a.writeFileSync(n,r,"utf8")}}function ye(n){return a.existsSync(n)}function de(n){a.mkdirSync(n,{recursive:!0})}function Se(n){a.rmSync(n,{recursive:!0,force:!0})}function pe(n){a.rmSync(n,{force:!0})}function Fe(n,e){a.mkdirSync(require("path").dirname(n),{recursive:!0,mode:448});let r=`${n}.${process.pid}.${Date.now()}.tmp`;try{a.writeFileSync(r,`${JSON.stringify(e,null,2)}
|
|
2
|
+
`,{mode:384}),a.renameSync(r,n);try{a.chmodSync(n,384)}catch{}}finally{a.rmSync(r,{force:!0})}}async function Ee(n,e,r){a.mkdirSync(require("path").dirname(n),{recursive:!0,mode:448});let t=`${n}.lock`,c=Date.now()+2e4,s;for(;s===void 0;)try{s=a.openSync(t,"wx",384),a.writeFileSync(s,String(process.pid))}catch(i){if(i.code!=="EEXIST")throw i;try{let o=Number(a.readFileSync(t,"utf8"));if(Number.isInteger(o)&&o>0)try{process.kill(o,0)}catch(l){if(l.code==="ESRCH"){a.unlinkSync(t);continue}}}catch(o){if(o.code==="ENOENT")continue}if(Date.now()>=c)throw r();await new Promise(o=>setTimeout(o,50))}try{return await e()}finally{a.closeSync(s),a.unlinkSync(t)}}L.exports={writePrivateJsonFileAtomic:Fe,withPrivateFileLock:Ee,readJsonFileSafe:ue,readFileSafe:le,writeJsonFile:fe,writeTextFile:he,writeModuleExportsFile:me,fileExists:ye,ensureDirectoryExists:de,removeDirectory:Se,removeFile:pe}});var M=f((Je,P)=>{var _e="classes.txt",Ce="classes.css";P.exports={CLASSES_SOURCE_FILE:_e,CSS_CLASSES_SOURCE_FILE:Ce}});var V=f((Ge,G)=>{var u=require("path"),{CACHE_DIR_NAME:we,CACHE_TTL_MS:je,CACHE_FILES:H}=T(),{CacheError:j}=R(),{readJsonFileSafe:S,readFileSafe:Ae,writeJsonFile:U,writeTextFile:q,writeModuleExportsFile:J,fileExists:A,ensureDirectoryExists:De,removeDirectory:ve,removeFile:xe}=$(),{CLASSES_SOURCE_FILE:be,CSS_CLASSES_SOURCE_FILE:Oe}=M(),D=class n{constructor(e=process.cwd()){this.appRoot=e,this.cacheDir=u.join(e,"node_modules",we),this.metadataFile=u.join(this.cacheDir,"metadata.json"),this.maxAge=je}getCacheDir(){return this.cacheDir}isLocalOnly(){return S(this.metadataFile)?.version==="local-components"}getIconLibrary(){let e=u.join(this.cacheDir,"iconLibrary.json");return A(e)?S(e):null}exists(){return A(this.cacheDir)}isValid(){if(!this.exists())return!1;try{let e=S(this.metadataFile);if(!e)return!1;let r=new Date(e.timestamp).getTime();return Date.now()-r<this.maxAge}catch{return!1}}load(){if(!this.exists())return null;try{let e={};for(let r of H.JS){let t=u.join(this.cacheDir,r);if(A(t)){let c=r.replace(".js","");try{let s=Ae(t);if(s!==null){let i={},o={exports:i};new Function("module","exports",s)(o,i),e[c]=o.exports}}catch(s){console.warn(`[Frontfriend] Failed to load ${r}: ${s.message}`),(s.message.includes("Unexpected token")||s.message.includes("Invalid character"))&&console.warn("[Frontfriend] This might be a BOM or encoding issue. Try deleting node_modules/.cache/frontfriend and running `npx frontfriend init` again.")}}}for(let r of H.JSON){let t=u.join(this.cacheDir,r),c=r.replace(".json",""),s=S(t);s!==null&&(e[c]=s)}return e["components-config"]&&(e.componentsConfig=e["components-config"],delete e["components-config"]),e.cls&&!e.safelist&&(e.safelist=e.cls,delete e.cls),e}catch(e){throw new j(`Failed to load cache: ${e.message}`,"read")}}save(e){try{De(this.cacheDir);let r={timestamp:new Date().toISOString(),version:e.metadata?.version||"2.0.0",ffId:e.metadata?.ffId},t=["tokens","variables","semanticVariables","semanticDarkVariables","keyframes","animations","safelist","custom"];for(let s of t)if(e[s]!==void 0){let i=u.join(this.cacheDir,`${s}.js`);J(i,e[s])}if(e.safelist&&Array.isArray(e.safelist)){let s=u.join(this.cacheDir,"safelist.js");J(s,e.safelist)}let c={fonts:e.fonts,icons:e.icons||e.iconSet,"components-config":e.componentsConfig,iconLibrary:e.iconLibrary,version:e.version,versionMetadata:e.versionMetadata,base:e.base,nativeTokens:e.nativeTokens};for(let[s,i]of Object.entries(c))if(i!==void 0){let o=u.join(this.cacheDir,`${s}.json`);U(o,i)}e.themeCSS!==void 0&&q(u.join(this.cacheDir,"theme.css"),e.themeCSS),e.classesContent!==void 0&&(q(u.join(this.cacheDir,be),e.classesContent),xe(u.join(this.cacheDir,Oe))),U(this.metadataFile,r)}catch(r){throw new j(`Failed to save cache: ${r.message}`,"write")}}saveAtomic(e,r=()=>{}){let t=require("node:fs"),{randomUUID:c}=require("node:crypto");t.mkdirSync(u.dirname(this.cacheDir),{recursive:!0});let s=`${this.cacheDir}.write-lock`,i;try{i=t.openSync(s,"wx")}catch(m){if(m.code!=="EEXIST")throw m;let y=Number(t.readFileSync(s,"utf8")),d=!0;if(y>0)try{process.kill(y,0)}catch(F){d=F.code!=="ESRCH"}if(d)throw new j("Another process is installing tokens. Retry after it completes.","write");t.unlinkSync(s),i=t.openSync(s,"wx")}let o=`${this.cacheDir}.previous`,l=`${this.cacheDir}.${c()}.pending`;try{t.writeFileSync(i,String(process.pid)),!t.existsSync(this.cacheDir)&&t.existsSync(o)&&t.renameSync(o,this.cacheDir);let m=new n(this.appRoot);m.cacheDir=l,m.metadataFile=u.join(l,"metadata.json"),m.save(e),t.existsSync(o)&&t.rmSync(o,{recursive:!0}),t.existsSync(this.cacheDir)&&t.renameSync(this.cacheDir,o);try{t.renameSync(l,this.cacheDir),r()}catch(y){throw t.rmSync(this.cacheDir,{recursive:!0,force:!0}),t.existsSync(o)&&t.renameSync(o,this.cacheDir),y}t.rmSync(o,{recursive:!0,force:!0})}finally{t.rmSync(l,{recursive:!0,force:!0}),t.closeSync(i),t.rmSync(s,{force:!0})}}clear(){this.exists()&&ve(this.cacheDir)}};G.exports=D});var Y=f((Ve,B)=>{function h(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function v(n,e){if(!h(n)||!h(e))return e===void 0?n:e;let r={...n};for(let[t,c]of Object.entries(e))r[t]=t in r?v(r[t],c):c;return r}function x(n,e,r=[],t=[]){if(n===void 0||e===void 0)return t;if(!h(n)||!h(e))return t.push(r.join(".")),t;for(let c of Object.keys(n))c in e&&x(n[c],e[c],[...r,c],t);return t}function K(n){return h(n)&&("styles"in n||"behavior"in n)}function X(n,e="component"){if(!K(n)||!h(n.styles)||n.behavior!==void 0&&!h(n.behavior)||Object.keys(n).some(t=>!["styles","behavior"].includes(t)))throw new TypeError(`Component ${e} must use the styles/behavior envelope`);let r=x(n.styles,n.behavior,[e]);if(r.length>0)throw new Error(`Component config styles/behavior conflict at ${r.join(", ")}`);return v(n.styles||{},n.behavior||{})}function ke(n){if(!h(n))return n;let e=!1,r={};for(let[t,c]of Object.entries(n))r[t]=X(c,t),r[t]!==c&&(e=!0);return e?r:n}B.exports={isPlainObject:h,deepMerge:v,findTreeConflicts:x,isComponentEnvelope:K,toRuntimeComponentConfig:X,toRuntimeComponentsConfig:ke}});var Z=f((Ke,Q)=>{var{toRuntimeComponentConfig:Ne}=Y(),b='FrontFriend components configuration not found. Run "npx frontfriend init" or "npx frontfriend sync".',ge="FrontFriend components configuration was not returned by the SaaS app. The cache was not updated.";function W(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function z(n,e=b){if(!W(n)||Object.keys(n).length===0)throw new Error(e);for(let[r,t]of Object.entries(n))Ne(t,r);return n}function Te(n){if(!n.exists())throw new Error(b);let e=n.load();return{componentsConfig:z(e?.componentsConfig),icons:W(e.icons)?e.icons:{}}}Q.exports={CACHE_ERROR_MESSAGE:b,SAAS_ERROR_MESSAGE:ge,assertComponentsConfig:z,loadCachedComponents:Te}});var{PACKAGE_NAME:ee}=N(),Ie=V(),{loadCachedComponents:Re}=Z(),Le=require("fs"),p=require("path");function ne(n={},e={}){let r=e.fixture===!0,t=new Ie(process.cwd()),{componentsConfig:c,icons:s}=r?{componentsConfig:{fixture:{styles:{}}},icons:{}}:Re(t);return{...n,env:{...n.env,NEXT_PUBLIC_FF_CONFIG:JSON.stringify(c),NEXT_PUBLIC_FF_ICONS:JSON.stringify(s)},webpack:(i,o)=>{if(typeof n.webpack=="function"&&(i=n.webpack(i,o)),r||typeof t.getCacheDir=="function"){let d=r?[p.join(__dirname,"src","theme.css"),p.join(__dirname,"..","src","theme.css"),p.join(__dirname,"theme.css")].find(F=>Le.existsSync(F)):p.join(t.getCacheDir(),"theme.css");i.resolve=i.resolve||{},i.resolve.alias=i.resolve.alias||{},i.resolve.alias[`${ee}/theme`]=d,i.resolve.alias[`${ee}/theme.css`]=d}let{webpack:l}=o,m=l.DefinePlugin,y={__FF_CONFIG__:JSON.stringify(c),__FF_ICONS__:JSON.stringify(s)};return i.plugins=i.plugins||[],i.plugins.push(new m(y)),o.dev&&!o.isServer&&console.log("[FrontFriend Next.js] Injected configuration and icons into client build"),i}}}module.exports=ne;module.exports.default=ne;
|
package/dist/package.json
CHANGED
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var y=(
|
|
2
|
-
`,{mode:384}),l.renameSync(n
|
|
1
|
+
var y=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var N=y((Ve,ie)=>{ie.exports={name:"@frontfriend/sdk",version:"1.2.0"}});var I=y((Ge,$)=>{var{name:se}=N();$.exports={PACKAGE_NAME:se}});var P=y((Ke,L)=>{var oe="https://app.frontfriend.dev",ce=".cache/frontfriend",ae={JS:["tokens.js","variables.js","semanticVariables.js","semanticDarkVariables.js","keyframes.js","animations.js","safelist.js","custom.js"],JSON:["fonts.json","icons.json","components-config.json","iconLibrary.json","version.json","versionMetadata.json","metadata.json","base.json","nativeTokens.json"]},le={FF_ID:"FF_ID",FF_API_URL:"FF_API_URL",FF_AUTH_TOKEN:"FF_AUTH_TOKEN",FF_MACHINE_TOKEN:"FRONTFRIEND_MACHINE_TOKEN"};function ue(n){if(!n)return null;try{let e=new URL(n);return e.hostname.startsWith("app.")?`${e.protocol}//${e.hostname.replace(/^app\./,"registry.")}`:null}catch{return null}}L.exports={DEFAULT_API_URL:oe,CACHE_DIR_NAME:ce,CACHE_TTL_DAYS:7,CACHE_TTL_MS:6048e5,CACHE_FILES:ae,ENV_VARS:le,deriveRegistryFromApiUrl:ue}});var q=y((We,M)=>{var g=class extends Error{constructor(e,t,r){super(e),this.name="APIError",this.statusCode=t,this.url=r,this.code=`API_${t}`}},j=class extends Error{constructor(e,t){super(e),this.name="CacheError",this.operation=t,this.code=`CACHE_${t.toUpperCase()}`}},x=class extends Error{constructor(e,t){super(e),this.name="ConfigError",this.field=t,this.code=t?`CONFIG_${String(t).toUpperCase()}`:"CONFIG_ERROR"}},A=class extends Error{constructor(e,t){super(e),this.name="ProcessingError",this.token=t,this.code="PROCESSING_ERROR"}};M.exports={APIError:g,CacheError:j,ConfigError:x,ProcessingError:A}});var U=y((Ye,H)=>{var l=require("fs");function fe(n){try{let e=l.readFileSync(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function he(n){try{return l.readFileSync(n,"utf8").replace(/^\uFEFF/,"")}catch(e){if(e.code==="ENOENT")return null;throw e}}function me(n,e,t=2){let r=JSON.stringify(e,null,t);l.writeFileSync(n,r,"utf8")}function de(n,e){l.writeFileSync(n,e,"utf8")}function ye(n,e){if(e==null||typeof e=="object"&&Object.keys(e).length===0||Array.isArray(e)&&e.length===0){let r=`module.exports = ${Array.isArray(e)?"[]":"{}"};`;l.writeFileSync(n,r,"utf8")}else{let t=`module.exports = ${JSON.stringify(e,null,2)};`;l.writeFileSync(n,t,"utf8")}}function pe(n){return l.existsSync(n)}function Se(n){l.mkdirSync(n,{recursive:!0})}function Fe(n){l.rmSync(n,{recursive:!0,force:!0})}function we(n){l.rmSync(n,{force:!0})}function _e(n,e){l.mkdirSync(require("path").dirname(n),{recursive:!0,mode:448});let t=`${n}.${process.pid}.${Date.now()}.tmp`;try{l.writeFileSync(t,`${JSON.stringify(e,null,2)}
|
|
2
|
+
`,{mode:384}),l.renameSync(t,n);try{l.chmodSync(n,384)}catch{}}finally{l.rmSync(t,{force:!0})}}async function Ce(n,e,t){l.mkdirSync(require("path").dirname(n),{recursive:!0,mode:448});let r=`${n}.lock`,s=Date.now()+2e4,i;for(;i===void 0;)try{i=l.openSync(r,"wx",384),l.writeFileSync(i,String(process.pid))}catch(a){if(a.code!=="EEXIST")throw a;try{let o=Number(l.readFileSync(r,"utf8"));if(Number.isInteger(o)&&o>0)try{process.kill(o,0)}catch(d){if(d.code==="ESRCH"){l.unlinkSync(r);continue}}}catch(o){if(o.code==="ENOENT")continue}if(Date.now()>=s)throw t();await new Promise(o=>setTimeout(o,50))}try{return await e()}finally{l.closeSync(i),l.unlinkSync(r)}}H.exports={writePrivateJsonFileAtomic:_e,withPrivateFileLock:Ce,readJsonFileSafe:fe,readFileSafe:he,writeJsonFile:me,writeTextFile:de,writeModuleExportsFile:ye,fileExists:pe,ensureDirectoryExists:Se,removeDirectory:Fe,removeFile:we}});var D=y((Be,J)=>{var Ee="classes.txt",ge="classes.css";J.exports={CLASSES_SOURCE_FILE:Ee,CSS_CLASSES_SOURCE_FILE:ge}});var B=y((Xe,Y)=>{var h=require("path"),{CACHE_DIR_NAME:je,CACHE_TTL_MS:xe,CACHE_FILES:V}=P(),{CacheError:v}=q(),{readJsonFileSafe:C,readFileSafe:Ae,writeJsonFile:G,writeTextFile:K,writeModuleExportsFile:W,fileExists:b,ensureDirectoryExists:De,removeDirectory:ve,removeFile:be}=U(),{CLASSES_SOURCE_FILE:Oe,CSS_CLASSES_SOURCE_FILE:Te}=D(),O=class n{constructor(e=process.cwd()){this.appRoot=e,this.cacheDir=h.join(e,"node_modules",je),this.metadataFile=h.join(this.cacheDir,"metadata.json"),this.maxAge=xe}getCacheDir(){return this.cacheDir}isLocalOnly(){return C(this.metadataFile)?.version==="local-components"}getIconLibrary(){let e=h.join(this.cacheDir,"iconLibrary.json");return b(e)?C(e):null}exists(){return b(this.cacheDir)}isValid(){if(!this.exists())return!1;try{let e=C(this.metadataFile);if(!e)return!1;let t=new Date(e.timestamp).getTime();return Date.now()-t<this.maxAge}catch{return!1}}load(){if(!this.exists())return null;try{let e={};for(let t of V.JS){let r=h.join(this.cacheDir,t);if(b(r)){let s=t.replace(".js","");try{let i=Ae(r);if(i!==null){let a={},o={exports:a};new Function("module","exports",i)(o,a),e[s]=o.exports}}catch(i){console.warn(`[Frontfriend] Failed to load ${t}: ${i.message}`),(i.message.includes("Unexpected token")||i.message.includes("Invalid character"))&&console.warn("[Frontfriend] This might be a BOM or encoding issue. Try deleting node_modules/.cache/frontfriend and running `npx frontfriend init` again.")}}}for(let t of V.JSON){let r=h.join(this.cacheDir,t),s=t.replace(".json",""),i=C(r);i!==null&&(e[s]=i)}return e["components-config"]&&(e.componentsConfig=e["components-config"],delete e["components-config"]),e.cls&&!e.safelist&&(e.safelist=e.cls,delete e.cls),e}catch(e){throw new v(`Failed to load cache: ${e.message}`,"read")}}save(e){try{De(this.cacheDir);let t={timestamp:new Date().toISOString(),version:e.metadata?.version||"2.0.0",ffId:e.metadata?.ffId},r=["tokens","variables","semanticVariables","semanticDarkVariables","keyframes","animations","safelist","custom"];for(let i of r)if(e[i]!==void 0){let a=h.join(this.cacheDir,`${i}.js`);W(a,e[i])}if(e.safelist&&Array.isArray(e.safelist)){let i=h.join(this.cacheDir,"safelist.js");W(i,e.safelist)}let s={fonts:e.fonts,icons:e.icons||e.iconSet,"components-config":e.componentsConfig,iconLibrary:e.iconLibrary,version:e.version,versionMetadata:e.versionMetadata,base:e.base,nativeTokens:e.nativeTokens};for(let[i,a]of Object.entries(s))if(a!==void 0){let o=h.join(this.cacheDir,`${i}.json`);G(o,a)}e.themeCSS!==void 0&&K(h.join(this.cacheDir,"theme.css"),e.themeCSS),e.classesContent!==void 0&&(K(h.join(this.cacheDir,Oe),e.classesContent),be(h.join(this.cacheDir,Te))),G(this.metadataFile,t)}catch(t){throw new v(`Failed to save cache: ${t.message}`,"write")}}saveAtomic(e,t=()=>{}){let r=require("node:fs"),{randomUUID:s}=require("node:crypto");r.mkdirSync(h.dirname(this.cacheDir),{recursive:!0});let i=`${this.cacheDir}.write-lock`,a;try{a=r.openSync(i,"wx")}catch(c){if(c.code!=="EEXIST")throw c;let u=Number(r.readFileSync(i,"utf8")),f=!0;if(u>0)try{process.kill(u,0)}catch(F){f=F.code!=="ESRCH"}if(f)throw new v("Another process is installing tokens. Retry after it completes.","write");r.unlinkSync(i),a=r.openSync(i,"wx")}let o=`${this.cacheDir}.previous`,d=`${this.cacheDir}.${s()}.pending`;try{r.writeFileSync(a,String(process.pid)),!r.existsSync(this.cacheDir)&&r.existsSync(o)&&r.renameSync(o,this.cacheDir);let c=new n(this.appRoot);c.cacheDir=d,c.metadataFile=h.join(d,"metadata.json"),c.save(e),r.existsSync(o)&&r.rmSync(o,{recursive:!0}),r.existsSync(this.cacheDir)&&r.renameSync(this.cacheDir,o);try{r.renameSync(d,this.cacheDir),t()}catch(u){throw r.rmSync(this.cacheDir,{recursive:!0,force:!0}),r.existsSync(o)&&r.renameSync(o,this.cacheDir),u}r.rmSync(o,{recursive:!0,force:!0})}finally{r.rmSync(d,{recursive:!0,force:!0}),r.closeSync(a),r.rmSync(i,{force:!0})}}clear(){this.exists()&&ve(this.cacheDir)}};Y.exports=O});var Z=y((ze,Q)=>{function p(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function T(n,e){if(!p(n)||!p(e))return e===void 0?n:e;let t={...n};for(let[r,s]of Object.entries(e))t[r]=r in t?T(t[r],s):s;return t}function R(n,e,t=[],r=[]){if(n===void 0||e===void 0)return r;if(!p(n)||!p(e))return r.push(t.join(".")),r;for(let s of Object.keys(n))s in e&&R(n[s],e[s],[...t,s],r);return r}function X(n){return p(n)&&("styles"in n||"behavior"in n)}function z(n,e="component"){if(!X(n)||!p(n.styles)||n.behavior!==void 0&&!p(n.behavior)||Object.keys(n).some(r=>!["styles","behavior"].includes(r)))throw new TypeError(`Component ${e} must use the styles/behavior envelope`);let t=R(n.styles,n.behavior,[e]);if(t.length>0)throw new Error(`Component config styles/behavior conflict at ${t.join(", ")}`);return T(n.styles||{},n.behavior||{})}function Re(n){if(!p(n))return n;let e=!1,t={};for(let[r,s]of Object.entries(n))t[r]=z(s,r),t[r]!==s&&(e=!0);return e?t:n}Q.exports={isPlainObject:p,deepMerge:T,findTreeConflicts:R,isComponentEnvelope:X,toRuntimeComponentConfig:z,toRuntimeComponentsConfig:Re}});var re=y((Qe,te)=>{var{toRuntimeComponentConfig:ke}=Z(),k='FrontFriend components configuration not found. Run "npx frontfriend init" or "npx frontfriend sync".',Ne="FrontFriend components configuration was not returned by the SaaS app. The cache was not updated.";function ee(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function ne(n,e=k){if(!ee(n)||Object.keys(n).length===0)throw new Error(e);for(let[t,r]of Object.entries(n))ke(r,t);return n}function $e(n){if(!n.exists())throw new Error(k);let e=n.load();return{componentsConfig:ne(e?.componentsConfig),icons:ee(e.icons)?e.icons:{}}}te.exports={CACHE_ERROR_MESSAGE:k,SAAS_ERROR_MESSAGE:Ne,assertComponentsConfig:ne,loadCachedComponents:$e}});var{PACKAGE_NAME:E}=I(),w=require("fs"),m=require("path"),Ie=B(),{loadCachedComponents:Le}=re(),{CLASSES_SOURCE_FILE:Pe}=D();function Me(n){return n.split(m.sep).join("/")}function qe(n,e){let t=Me(m.relative(m.dirname(n),e));return t.startsWith(".")||(t=`./${t}`),`@source "${t}";`}function He(n){let e=n.replace(/\/\*[\s\S]*?\*\//g,"");return/@tailwind\s+utilities\b/.test(e)||/@import\s+(?:url\(\s*)?["']tailwindcss(?:\/(?:index|utilities)(?:\.css)?)?["']/.test(e)||/@import\s+url\(\s*tailwindcss(?:\/(?:index|utilities)(?:\.css)?)?\s*\)/.test(e)}function Ue(n,e,t){let r=m.join(n,"metadata.json"),s=null,i=(a,o)=>{a.mtimeMs!==o.mtimeMs&&(clearTimeout(s),s=setTimeout(t,100))};return w.watchFile(r,{interval:e,persistent:!1},i),()=>{clearTimeout(s),w.unwatchFile(r,i)}}module.exports=function(e={}){let t=e.fixture===!0,r,s,i,a,o;function d(c){if(t)return a={componentsConfig:{fixture:{styles:{}}},icons:{}},a;let u=c||process.cwd(),f=new Ie(u);return s=typeof f.getCacheDir=="function"?f.getCacheDir():m.join(u,"node_modules",".cache","frontfriend"),a=Le(f),a}return{name:E.slice(1).replace("/","-"),enforce:"pre",config(c={}){let{componentsConfig:u,icons:f}=d(c.root||process.cwd());if(i=t?[m.join(__dirname,"src","theme.css"),m.join(__dirname,"..","src","theme.css"),m.join(__dirname,"theme.css")].find(S=>w.existsSync(S)):m.join(s,"theme.css"),!i)throw new Error("FrontFriend fixture theme.css not found.");let F=[`${E}/theme.css`,`${E}/theme`].map(S=>({find:S,replacement:i,...!w.existsSync(i)&&{customResolver(){throw new Error(`FrontFriend theme.css not found in ${s}. Run "npx frontfriend init" or "npx frontfriend sync" to generate the Tailwind v4 theme.`)}}})),_=m.join(__dirname,"browser.mjs");return{define:{__FF_CONFIG__:JSON.stringify(u),__FF_ICONS__:JSON.stringify(f)},resolve:{alias:[{find:new RegExp(`^${E}$`),replacement:_},...F]}}},configResolved(c){r=c,s=s||m.join(c?.root||process.cwd(),"node_modules",".cache","frontfriend")},configureServer(c){t||!s||(o?.(),o=Ue(s,e.cacheWatchInterval??500,()=>{let u="[FrontFriend Vite] Design System cache changed: reloading with the new tokens and component config.";c.config?.logger?.info?c.config.logger.info(u,{timestamp:!0}):console.log(u),typeof c.restart=="function"?Promise.resolve(c.restart()).catch(f=>console.error(`[FrontFriend Vite] Restart failed: ${f.message}`)):c.ws?.send({type:"full-reload"})}),c.httpServer?.once("close",()=>o?.()))},closeBundle(){o?.(),o=void 0},transform(c,u){let[f,F=""]=u.split("?");if(!f.endsWith(".css")||/(?:^|&)(?:url|raw|inline)(?:&|=|$)/.test(F)||t||!He(c))return null;let _=m.join(s||process.cwd(),Pe);if(!w.existsSync(_))return null;let S=qe(f,_);return c.includes(S)?null:{code:`${c}
|
|
3
3
|
|
|
4
4
|
/* Frontfriend Tailwind v4 registry source */
|
|
5
5
|
${S}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontfriend/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Frontfriend SDK: design contracts, tokens, components, CLI and MCP integrations",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -111,16 +111,6 @@
|
|
|
111
111
|
},
|
|
112
112
|
"./package.json": "./package.json"
|
|
113
113
|
},
|
|
114
|
-
"scripts": {
|
|
115
|
-
"build": "tsc --noEmit && node scripts/build.js",
|
|
116
|
-
"check-types": "tsc --noEmit",
|
|
117
|
-
"test": "pnpm run test:unit && pnpm run test:package",
|
|
118
|
-
"test:unit": "jest --runInBand",
|
|
119
|
-
"test:package": "node --test tests/*.test.mjs",
|
|
120
|
-
"prepack": "pnpm run build",
|
|
121
|
-
"prepublishOnly": "pnpm test",
|
|
122
|
-
"pretest:unit": "pnpm run build"
|
|
123
|
-
},
|
|
124
114
|
"keywords": [
|
|
125
115
|
"frontfriend",
|
|
126
116
|
"design-contracts",
|
|
@@ -154,7 +144,6 @@
|
|
|
154
144
|
"typescript": "^5.0.0"
|
|
155
145
|
},
|
|
156
146
|
"devDependencies": {
|
|
157
|
-
"@frontfriend/design-brain": "workspace:*",
|
|
158
147
|
"@modelcontextprotocol/client": "2.0.0",
|
|
159
148
|
"@modelcontextprotocol/server": "2.0.0",
|
|
160
149
|
"@tailwindcss/oxide": "4.3.3",
|
|
@@ -162,6 +151,7 @@
|
|
|
162
151
|
"esbuild": "^0.19.0",
|
|
163
152
|
"glob": "^10.0.0",
|
|
164
153
|
"jest": "^29.0.0",
|
|
154
|
+
"lightningcss": "1.33.0",
|
|
165
155
|
"smol-toml": "^1.7.0",
|
|
166
156
|
"typescript": "^5.0.0",
|
|
167
157
|
"@radix-ui/react-slot": "^1.0.2",
|
|
@@ -173,7 +163,8 @@
|
|
|
173
163
|
"acorn": "8.17.0",
|
|
174
164
|
"semver": "^7.7.2",
|
|
175
165
|
"cross-spawn": "7.0.6",
|
|
176
|
-
"tw-animate-css": "^1.3.4"
|
|
166
|
+
"tw-animate-css": "^1.3.4",
|
|
167
|
+
"@frontfriend/design-brain": "0.16.1"
|
|
177
168
|
},
|
|
178
169
|
"engines": {
|
|
179
170
|
"node": ">=20.19.0"
|
|
@@ -203,5 +194,13 @@
|
|
|
203
194
|
"**/*.css",
|
|
204
195
|
"./dist/runtime.js",
|
|
205
196
|
"./dist/runtime.mjs"
|
|
206
|
-
]
|
|
207
|
-
|
|
197
|
+
],
|
|
198
|
+
"scripts": {
|
|
199
|
+
"build": "tsc --noEmit && node scripts/build.js",
|
|
200
|
+
"check-types": "tsc --noEmit",
|
|
201
|
+
"test": "pnpm run test:unit && pnpm run test:package",
|
|
202
|
+
"test:unit": "jest --runInBand",
|
|
203
|
+
"test:package": "node --test tests/*.test.mjs",
|
|
204
|
+
"pretest:unit": "pnpm run build"
|
|
205
|
+
}
|
|
206
|
+
}
|