@frontfriend/sdk 1.0.0 → 1.1.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/cli.js +154 -154
- 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/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/mcp.cjs +3 -3
- package/dist/next.js +1 -1
- package/dist/package.json +1 -1
- package/dist/vite.js +1 -1
- package/package.json +13 -15
package/dist/next.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var f=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var O=f((Ue,ne)=>{ne.exports={name:"@frontfriend/sdk",version:"1.
|
|
1
|
+
var f=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var O=f((Ue,ne)=>{ne.exports={name:"@frontfriend/sdk",version:"1.1.0"}});var g=f((He,k)=>{var{name:re}=O();k.exports={PACKAGE_NAME:re}});var T=f((qe,N)=>{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(t){if(!t)return null;try{let e=new URL(t);return e.hostname.startsWith("app.")?`${e.protocol}//${e.hostname.replace(/^app\./,"registry.")}`:null}catch{return null}}N.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((Je,I)=>{var F=class extends Error{constructor(e,r,n){super(e),this.name="APIError",this.statusCode=r,this.url=n,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:F,CacheError:_,ConfigError:C,ProcessingError:w}});var $=f((Ge,L)=>{var a=require("fs");function ue(t){try{let e=a.readFileSync(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function le(t){try{return a.readFileSync(t,"utf8").replace(/^\uFEFF/,"")}catch(e){if(e.code==="ENOENT")return null;throw e}}function fe(t,e,r=2){let n=JSON.stringify(e,null,r);a.writeFileSync(t,n,"utf8")}function he(t,e){a.writeFileSync(t,e,"utf8")}function me(t,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(t,n,"utf8")}else{let r=`module.exports = ${JSON.stringify(e,null,2)};`;a.writeFileSync(t,r,"utf8")}}function ye(t){return a.existsSync(t)}function de(t){a.mkdirSync(t,{recursive:!0})}function Se(t){a.rmSync(t,{recursive:!0,force:!0})}function pe(t){a.rmSync(t,{force:!0})}function Ee(t,e){a.mkdirSync(require("path").dirname(t),{recursive:!0,mode:448});let r=`${t}.${process.pid}.${Date.now()}.tmp`;try{a.writeFileSync(r,`${JSON.stringify(e,null,2)}
|
|
2
2
|
`,{mode:384}),a.renameSync(r,t);try{a.chmodSync(t,384)}catch{}}finally{a.rmSync(r,{force:!0})}}async function Fe(t,e,r){a.mkdirSync(require("path").dirname(t),{recursive:!0,mode:448});let n=`${t}.lock`,c=Date.now()+2e4,s;for(;s===void 0;)try{s=a.openSync(n,"wx",384),a.writeFileSync(s,String(process.pid))}catch(i){if(i.code!=="EEXIST")throw i;try{let o=Number(a.readFileSync(n,"utf8"));if(Number.isInteger(o)&&o>0)try{process.kill(o,0)}catch(l){if(l.code==="ESRCH"){a.unlinkSync(n);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(n)}}L.exports={writePrivateJsonFileAtomic:Ee,withPrivateFileLock:Fe,readJsonFileSafe:ue,readFileSafe:le,writeJsonFile:fe,writeTextFile:he,writeModuleExportsFile:me,fileExists:ye,ensureDirectoryExists:de,removeDirectory:Se,removeFile:pe}});var M=f((Ve,P)=>{var _e="classes.txt",Ce="classes.css",we=new Set(["after","backdrop","before","file","first-letter","first-line","marker","placeholder","selection"]);function je(t){if(typeof t!="string")return!0;let e=t.split(":").slice(0,-1);return e.every((r,n)=>!we.has(r)||n===e.length-1)}P.exports={CLASSES_SOURCE_FILE:_e,CSS_CLASSES_SOURCE_FILE:Ce,isCompilableClass:je}});var V=f((Ke,G)=>{var u=require("path"),{CACHE_DIR_NAME:Ae,CACHE_TTL_MS:De,CACHE_FILES:U}=T(),{CacheError:j}=R(),{readJsonFileSafe:S,readFileSafe:ve,writeJsonFile:H,writeTextFile:q,writeModuleExportsFile:J,fileExists:A,ensureDirectoryExists:be,removeDirectory:xe,removeFile:Oe}=$(),{CLASSES_SOURCE_FILE:ke,CSS_CLASSES_SOURCE_FILE:ge}=M(),D=class t{constructor(e=process.cwd()){this.appRoot=e,this.cacheDir=u.join(e,"node_modules",Ae),this.metadataFile=u.join(this.cacheDir,"metadata.json"),this.maxAge=De}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 U.JS){let n=u.join(this.cacheDir,r);if(A(n)){let c=r.replace(".js","");try{let s=ve(n);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 U.JSON){let n=u.join(this.cacheDir,r),c=r.replace(".json",""),s=S(n);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{be(this.cacheDir);let r={timestamp:new Date().toISOString(),version:e.metadata?.version||"2.0.0",ffId:e.metadata?.ffId},n=["tokens","variables","semanticVariables","semanticDarkVariables","keyframes","animations","safelist","custom"];for(let s of n)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`);H(o,i)}e.themeCSS!==void 0&&q(u.join(this.cacheDir,"theme.css"),e.themeCSS),e.classesContent!==void 0&&(q(u.join(this.cacheDir,ke),e.classesContent),Oe(u.join(this.cacheDir,ge))),H(this.metadataFile,r)}catch(r){throw new j(`Failed to save cache: ${r.message}`,"write")}}saveAtomic(e,r=()=>{}){let n=require("node:fs"),{randomUUID:c}=require("node:crypto");n.mkdirSync(u.dirname(this.cacheDir),{recursive:!0});let s=`${this.cacheDir}.write-lock`,i;try{i=n.openSync(s,"wx")}catch(m){if(m.code!=="EEXIST")throw m;let y=Number(n.readFileSync(s,"utf8")),d=!0;if(y>0)try{process.kill(y,0)}catch(E){d=E.code!=="ESRCH"}if(d)throw new j("Another process is installing tokens. Retry after it completes.","write");n.unlinkSync(s),i=n.openSync(s,"wx")}let o=`${this.cacheDir}.previous`,l=`${this.cacheDir}.${c()}.pending`;try{n.writeFileSync(i,String(process.pid)),!n.existsSync(this.cacheDir)&&n.existsSync(o)&&n.renameSync(o,this.cacheDir);let m=new t(this.appRoot);m.cacheDir=l,m.metadataFile=u.join(l,"metadata.json"),m.save(e),n.existsSync(o)&&n.rmSync(o,{recursive:!0}),n.existsSync(this.cacheDir)&&n.renameSync(this.cacheDir,o);try{n.renameSync(l,this.cacheDir),r()}catch(y){throw n.rmSync(this.cacheDir,{recursive:!0,force:!0}),n.existsSync(o)&&n.renameSync(o,this.cacheDir),y}n.rmSync(o,{recursive:!0,force:!0})}finally{n.rmSync(l,{recursive:!0,force:!0}),n.closeSync(i),n.rmSync(s,{force:!0})}}clear(){this.exists()&&xe(this.cacheDir)}};G.exports=D});var Y=f((Xe,B)=>{function h(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function v(t,e){if(!h(t)||!h(e))return e===void 0?t:e;let r={...t};for(let[n,c]of Object.entries(e))r[n]=n in r?v(r[n],c):c;return r}function b(t,e,r=[],n=[]){if(t===void 0||e===void 0)return n;if(!h(t)||!h(e))return n.push(r.join(".")),n;for(let c of Object.keys(t))c in e&&b(t[c],e[c],[...r,c],n);return n}function K(t){return h(t)&&("styles"in t||"behavior"in t)}function X(t,e="component"){if(!K(t)||!h(t.styles)||t.behavior!==void 0&&!h(t.behavior)||Object.keys(t).some(n=>!["styles","behavior"].includes(n)))throw new TypeError(`Component ${e} must use the styles/behavior envelope`);let r=b(t.styles,t.behavior,[e]);if(r.length>0)throw new Error(`Component config styles/behavior conflict at ${r.join(", ")}`);return v(t.styles||{},t.behavior||{})}function Ne(t){if(!h(t))return t;let e=!1,r={};for(let[n,c]of Object.entries(t))r[n]=X(c,n),r[n]!==c&&(e=!0);return e?r:t}B.exports={isPlainObject:h,deepMerge:v,findTreeConflicts:b,isComponentEnvelope:K,toRuntimeComponentConfig:X,toRuntimeComponentsConfig:Ne}});var Z=f((Be,Q)=>{var{toRuntimeComponentConfig:Te}=Y(),x='FrontFriend components configuration not found. Run "npx frontfriend init" or "npx frontfriend sync".',Ie="FrontFriend components configuration was not returned by the SaaS app. The cache was not updated.";function W(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function z(t,e=x){if(!W(t)||Object.keys(t).length===0)throw new Error(e);for(let[r,n]of Object.entries(t))Te(n,r);return t}function Re(t){if(!t.exists())throw new Error(x);let e=t.load();return{componentsConfig:z(e?.componentsConfig),icons:W(e.icons)?e.icons:{}}}Q.exports={CACHE_ERROR_MESSAGE:x,SAAS_ERROR_MESSAGE:Ie,assertComponentsConfig:z,loadCachedComponents:Re}});var{PACKAGE_NAME:ee}=g(),Le=V(),{loadCachedComponents:$e}=Z(),Pe=require("fs"),p=require("path");function te(t={},e={}){let r=e.fixture===!0,n=new Le(process.cwd()),{componentsConfig:c,icons:s}=r?{componentsConfig:{fixture:{styles:{}}},icons:{}}:$e(n);return{...t,env:{...t.env,NEXT_PUBLIC_FF_CONFIG:JSON.stringify(c),NEXT_PUBLIC_FF_ICONS:JSON.stringify(s)},webpack:(i,o)=>{if(typeof t.webpack=="function"&&(i=t.webpack(i,o)),r||typeof n.getCacheDir=="function"){let d=r?[p.join(__dirname,"src","theme.css"),p.join(__dirname,"..","src","theme.css"),p.join(__dirname,"theme.css")].find(E=>Pe.existsSync(E)):p.join(n.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=te;module.exports.default=te;
|
package/dist/package.json
CHANGED
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var y=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var N=y((Ke,ie)=>{ie.exports={name:"@frontfriend/sdk",version:"1.
|
|
1
|
+
var y=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var N=y((Ke,ie)=>{ie.exports={name:"@frontfriend/sdk",version:"1.1.0"}});var $=y((We,I)=>{var{name:se}=N();I.exports={PACKAGE_NAME:se}});var P=y((Ye,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(t){if(!t)return null;try{let e=new URL(t);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((Be,M)=>{var g=class extends Error{constructor(e,n,r){super(e),this.name="APIError",this.statusCode=n,this.url=r,this.code=`API_${n}`}},j=class extends Error{constructor(e,n){super(e),this.name="CacheError",this.operation=n,this.code=`CACHE_${n.toUpperCase()}`}},x=class extends Error{constructor(e,n){super(e),this.name="ConfigError",this.field=n,this.code=n?`CONFIG_${String(n).toUpperCase()}`:"CONFIG_ERROR"}},A=class extends Error{constructor(e,n){super(e),this.name="ProcessingError",this.token=n,this.code="PROCESSING_ERROR"}};M.exports={APIError:g,CacheError:j,ConfigError:x,ProcessingError:A}});var H=y((Xe,U)=>{var l=require("fs");function fe(t){try{let e=l.readFileSync(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}function he(t){try{return l.readFileSync(t,"utf8").replace(/^\uFEFF/,"")}catch(e){if(e.code==="ENOENT")return null;throw e}}function me(t,e,n=2){let r=JSON.stringify(e,null,n);l.writeFileSync(t,r,"utf8")}function de(t,e){l.writeFileSync(t,e,"utf8")}function ye(t,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(t,r,"utf8")}else{let n=`module.exports = ${JSON.stringify(e,null,2)};`;l.writeFileSync(t,n,"utf8")}}function pe(t){return l.existsSync(t)}function Se(t){l.mkdirSync(t,{recursive:!0})}function Fe(t){l.rmSync(t,{recursive:!0,force:!0})}function _e(t){l.rmSync(t,{force:!0})}function we(t,e){l.mkdirSync(require("path").dirname(t),{recursive:!0,mode:448});let n=`${t}.${process.pid}.${Date.now()}.tmp`;try{l.writeFileSync(n,`${JSON.stringify(e,null,2)}
|
|
2
2
|
`,{mode:384}),l.renameSync(n,t);try{l.chmodSync(t,384)}catch{}}finally{l.rmSync(n,{force:!0})}}async function Ee(t,e,n){l.mkdirSync(require("path").dirname(t),{recursive:!0,mode:448});let r=`${t}.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 n();await new Promise(o=>setTimeout(o,50))}try{return await e()}finally{l.closeSync(i),l.unlinkSync(r)}}U.exports={writePrivateJsonFileAtomic:we,withPrivateFileLock:Ee,readJsonFileSafe:fe,readFileSafe:he,writeJsonFile:me,writeTextFile:de,writeModuleExportsFile:ye,fileExists:pe,ensureDirectoryExists:Se,removeDirectory:Fe,removeFile:_e}});var D=y((ze,J)=>{var Ce="classes.txt",ge="classes.css",je=new Set(["after","backdrop","before","file","first-letter","first-line","marker","placeholder","selection"]);function xe(t){if(typeof t!="string")return!0;let e=t.split(":").slice(0,-1);return e.every((n,r)=>!je.has(n)||r===e.length-1)}J.exports={CLASSES_SOURCE_FILE:Ce,CSS_CLASSES_SOURCE_FILE:ge,isCompilableClass:xe}});var B=y((Qe,Y)=>{var h=require("path"),{CACHE_DIR_NAME:Ae,CACHE_TTL_MS:De,CACHE_FILES:V}=P(),{CacheError:v}=q(),{readJsonFileSafe:E,readFileSafe:ve,writeJsonFile:G,writeTextFile:K,writeModuleExportsFile:W,fileExists:b,ensureDirectoryExists:be,removeDirectory:Oe,removeFile:Te}=H(),{CLASSES_SOURCE_FILE:Re,CSS_CLASSES_SOURCE_FILE:ke}=D(),O=class t{constructor(e=process.cwd()){this.appRoot=e,this.cacheDir=h.join(e,"node_modules",Ae),this.metadataFile=h.join(this.cacheDir,"metadata.json"),this.maxAge=De}getCacheDir(){return this.cacheDir}isLocalOnly(){return E(this.metadataFile)?.version==="local-components"}getIconLibrary(){let e=h.join(this.cacheDir,"iconLibrary.json");return b(e)?E(e):null}exists(){return b(this.cacheDir)}isValid(){if(!this.exists())return!1;try{let e=E(this.metadataFile);if(!e)return!1;let n=new Date(e.timestamp).getTime();return Date.now()-n<this.maxAge}catch{return!1}}load(){if(!this.exists())return null;try{let e={};for(let n of V.JS){let r=h.join(this.cacheDir,n);if(b(r)){let s=n.replace(".js","");try{let i=ve(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 ${n}: ${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 n of V.JSON){let r=h.join(this.cacheDir,n),s=n.replace(".json",""),i=E(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{be(this.cacheDir);let n={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,Re),e.classesContent),Te(h.join(this.cacheDir,ke))),G(this.metadataFile,n)}catch(n){throw new v(`Failed to save cache: ${n.message}`,"write")}}saveAtomic(e,n=()=>{}){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 t(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),n()}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()&&Oe(this.cacheDir)}};Y.exports=O});var Z=y((Ze,Q)=>{function p(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function T(t,e){if(!p(t)||!p(e))return e===void 0?t:e;let n={...t};for(let[r,s]of Object.entries(e))n[r]=r in n?T(n[r],s):s;return n}function R(t,e,n=[],r=[]){if(t===void 0||e===void 0)return r;if(!p(t)||!p(e))return r.push(n.join(".")),r;for(let s of Object.keys(t))s in e&&R(t[s],e[s],[...n,s],r);return r}function X(t){return p(t)&&("styles"in t||"behavior"in t)}function z(t,e="component"){if(!X(t)||!p(t.styles)||t.behavior!==void 0&&!p(t.behavior)||Object.keys(t).some(r=>!["styles","behavior"].includes(r)))throw new TypeError(`Component ${e} must use the styles/behavior envelope`);let n=R(t.styles,t.behavior,[e]);if(n.length>0)throw new Error(`Component config styles/behavior conflict at ${n.join(", ")}`);return T(t.styles||{},t.behavior||{})}function Ne(t){if(!p(t))return t;let e=!1,n={};for(let[r,s]of Object.entries(t))n[r]=z(s,r),n[r]!==s&&(e=!0);return e?n:t}Q.exports={isPlainObject:p,deepMerge:T,findTreeConflicts:R,isComponentEnvelope:X,toRuntimeComponentConfig:z,toRuntimeComponentsConfig:Ne}});var re=y((et,ne)=>{var{toRuntimeComponentConfig:Ie}=Z(),k='FrontFriend components configuration not found. Run "npx frontfriend init" or "npx frontfriend sync".',$e="FrontFriend components configuration was not returned by the SaaS app. The cache was not updated.";function ee(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function te(t,e=k){if(!ee(t)||Object.keys(t).length===0)throw new Error(e);for(let[n,r]of Object.entries(t))Ie(r,n);return t}function Le(t){if(!t.exists())throw new Error(k);let e=t.load();return{componentsConfig:te(e?.componentsConfig),icons:ee(e.icons)?e.icons:{}}}ne.exports={CACHE_ERROR_MESSAGE:k,SAAS_ERROR_MESSAGE:$e,assertComponentsConfig:te,loadCachedComponents:Le}});var{PACKAGE_NAME:C}=$(),_=require("fs"),m=require("path"),Pe=B(),{loadCachedComponents:Me}=re(),{CLASSES_SOURCE_FILE:qe}=D();function Ue(t){return t.split(m.sep).join("/")}function He(t,e){let n=Ue(m.relative(m.dirname(t),e));return n.startsWith(".")||(n=`./${n}`),`@source "${n}";`}function Je(t){let e=t.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 Ve(t,e,n){let r=m.join(t,"metadata.json"),s=null,i=(a,o)=>{a.mtimeMs!==o.mtimeMs&&(clearTimeout(s),s=setTimeout(n,100))};return _.watchFile(r,{interval:e,persistent:!1},i),()=>{clearTimeout(s),_.unwatchFile(r,i)}}module.exports=function(e={}){let n=e.fixture===!0,r,s,i,a,o;function d(c){if(n)return a={componentsConfig:{fixture:{styles:{}}},icons:{}},a;let u=c||process.cwd(),f=new Pe(u);return s=typeof f.getCacheDir=="function"?f.getCacheDir():m.join(u,"node_modules",".cache","frontfriend"),a=Me(f),a}return{name:C.slice(1).replace("/","-"),enforce:"pre",config(c={}){let{componentsConfig:u,icons:f}=d(c.root||process.cwd());if(i=n?[m.join(__dirname,"src","theme.css"),m.join(__dirname,"..","src","theme.css"),m.join(__dirname,"theme.css")].find(S=>_.existsSync(S)):m.join(s,"theme.css"),!i)throw new Error("FrontFriend fixture theme.css not found.");let F=[`${C}/theme.css`,`${C}/theme`].map(S=>({find:S,replacement:i,...!_.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.`)}}})),w=m.join(__dirname,"browser.mjs");return{define:{__FF_CONFIG__:JSON.stringify(u),__FF_ICONS__:JSON.stringify(f)},resolve:{alias:[{find:new RegExp(`^${C}$`),replacement:w},...F]}}},configResolved(c){r=c,s=s||m.join(c?.root||process.cwd(),"node_modules",".cache","frontfriend")},configureServer(c){n||!s||(o?.(),o=Ve(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)||n||!Je(c))return null;let w=m.join(s||process.cwd(),qe);if(!_.existsSync(w))return null;let S=He(f,w);return c.includes(S)?null:{code:`${c}
|
|
3
3
|
|
|
4
4
|
/* Frontfriend Tailwind v4 registry source */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontfriend/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.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",
|
|
@@ -173,7 +162,8 @@
|
|
|
173
162
|
"acorn": "8.17.0",
|
|
174
163
|
"semver": "^7.7.2",
|
|
175
164
|
"cross-spawn": "7.0.6",
|
|
176
|
-
"tw-animate-css": "^1.3.4"
|
|
165
|
+
"tw-animate-css": "^1.3.4",
|
|
166
|
+
"@frontfriend/design-brain": "0.16.1"
|
|
177
167
|
},
|
|
178
168
|
"engines": {
|
|
179
169
|
"node": ">=20.19.0"
|
|
@@ -203,5 +193,13 @@
|
|
|
203
193
|
"**/*.css",
|
|
204
194
|
"./dist/runtime.js",
|
|
205
195
|
"./dist/runtime.mjs"
|
|
206
|
-
]
|
|
207
|
-
|
|
196
|
+
],
|
|
197
|
+
"scripts": {
|
|
198
|
+
"build": "tsc --noEmit && node scripts/build.js",
|
|
199
|
+
"check-types": "tsc --noEmit",
|
|
200
|
+
"test": "pnpm run test:unit && pnpm run test:package",
|
|
201
|
+
"test:unit": "jest --runInBand",
|
|
202
|
+
"test:package": "node --test tests/*.test.mjs",
|
|
203
|
+
"pretest:unit": "pnpm run build"
|
|
204
|
+
}
|
|
205
|
+
}
|