@frontfriend/sdk 0.0.0-stage → 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/LICENSE +46 -0
- package/README.md +352 -2
- package/dist/THIRD_PARTY_NOTICES +44 -0
- package/dist/application-adoption-lock.d.ts +31 -0
- package/dist/application-adoption.d.ts +103 -0
- package/dist/browser.mjs +1 -0
- package/dist/cli.js +372 -0
- package/dist/cn.d.ts +2 -0
- package/dist/cn.js +1 -0
- package/dist/cn.mjs +1 -0
- package/dist/component-config.d.ts +330 -0
- package/dist/component-config.mjs +1 -0
- package/dist/component-recipes.d.ts +29 -0
- package/dist/components-config-schema.d.ts +2 -0
- package/dist/components-config-schema.js +1 -0
- package/dist/ffdc.d.ts +17 -0
- package/dist/ffdc.js +1 -0
- package/dist/ffdc.mjs +1 -0
- package/dist/foundation-contract.json +56 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/lib/core/adoption.js +1 -0
- package/dist/lib/core/api-client.js +10 -0
- package/dist/lib/core/application-adoption-lock.js +6 -0
- package/dist/lib/core/application-adoption.js +28 -0
- package/dist/lib/core/cache-manager.js +1 -0
- package/dist/lib/core/cached-components-config.js +1 -0
- package/dist/lib/core/classes-source.js +1 -0
- package/dist/lib/core/component-config.js +1 -0
- package/dist/lib/core/component-recipes.js +8 -0
- package/dist/lib/core/components-config-schema.js +1 -0
- package/dist/lib/core/config-loader.js +1 -0
- package/dist/lib/core/constants.js +1 -0
- package/dist/lib/core/credentials.js +2 -0
- package/dist/lib/core/env-utils.js +2 -0
- package/dist/lib/core/errors.js +1 -0
- package/dist/lib/core/file-utils.js +2 -0
- package/dist/lib/core/nativeSource.d.ts +10 -0
- package/dist/lib/core/nativeSource.js +2 -0
- package/dist/lib/core/package-identity.js +1 -0
- package/dist/lib/core/path-utils.js +2 -0
- package/dist/lib/core/project-target.js +1 -0
- package/dist/lib/core/static-config.js +9 -0
- package/dist/lib/core/token-artifact-client.js +8 -0
- package/dist/lib/core/token-artifact.d.ts +39 -0
- package/dist/lib/core/token-artifact.js +1 -0
- package/dist/lib/core/token-processor.d.ts +23 -0
- package/dist/lib/core/token-processor.js +5 -0
- package/dist/lib/react/utils.d.ts +25 -0
- package/dist/lib/react/utils.mjs +1 -0
- package/dist/lib/vue/utils.d.ts +27 -0
- package/dist/lib/vue/utils.mjs +1 -0
- package/dist/mcp.cjs +226 -0
- package/dist/next.d.ts +11 -0
- package/dist/next.js +2 -0
- package/dist/next.mjs +1 -0
- package/dist/package.json +4 -0
- package/dist/project-target.d.ts +22 -0
- package/dist/runtime.d.ts +15 -0
- package/dist/runtime.js +1 -0
- package/dist/runtime.mjs +1 -0
- package/dist/scripts/generate-icon-types.js +38 -0
- package/dist/theme.css +3 -0
- package/dist/types/index.d.ts +68 -0
- package/dist/vite.d.mts +9 -0
- package/dist/vite.d.ts +8 -0
- package/dist/vite.js +9 -0
- package/dist/vite.mjs +1 -0
- package/package.json +202 -3
package/dist/next.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NextConfig } from 'next';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wraps Next.js configuration to inject FrontFriend globals
|
|
5
|
+
* @param config - Next.js configuration object
|
|
6
|
+
* @returns Modified Next.js configuration
|
|
7
|
+
*/
|
|
8
|
+
export default function frontfriend(
|
|
9
|
+
config?: NextConfig,
|
|
10
|
+
options?: { fixture?: boolean }
|
|
11
|
+
): NextConfig;
|
package/dist/next.js
ADDED
|
@@ -0,0 +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.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
|
+
`,{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/next.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./next.js";var r=e;export{r as default};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ProjectTarget =
|
|
2
|
+
| { framework: 'react'; primitive: 'radix' | 'base' | 'aria' }
|
|
3
|
+
| { framework: 'vue'; primitive: 'reka' };
|
|
4
|
+
|
|
5
|
+
export class ProjectTargetError extends Error {
|
|
6
|
+
code: 'INVALID_PROJECT_TARGET' | 'PROJECT_TARGET_REQUIRED' | 'PROJECT_TARGET_MISMATCH' | 'INVALID_CANONICAL_NAME';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const SUPPORTED_PROJECT_TARGETS: readonly ProjectTarget[];
|
|
10
|
+
export function parseProjectTarget(value: unknown, label?: string): ProjectTarget;
|
|
11
|
+
export function projectTargetKey(target: ProjectTarget): string;
|
|
12
|
+
export function defaultV4ProjectTarget(framework?: string): ProjectTarget;
|
|
13
|
+
export function assertMatchingProjectTargets(sources: Record<string, unknown>): ProjectTarget;
|
|
14
|
+
export function resolveProjectTarget(sources?: {
|
|
15
|
+
persisted?: unknown;
|
|
16
|
+
configured?: unknown;
|
|
17
|
+
app?: unknown;
|
|
18
|
+
release?: unknown;
|
|
19
|
+
lock?: unknown;
|
|
20
|
+
proposed?: unknown;
|
|
21
|
+
}): ProjectTarget;
|
|
22
|
+
export function registryRoute(target: ProjectTarget, componentName: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IconSetStructure } from './types/index';
|
|
2
|
+
|
|
3
|
+
export interface FrontFriend {
|
|
4
|
+
/** Current configuration */
|
|
5
|
+
config: Record<string, any> | null;
|
|
6
|
+
/** Icon set */
|
|
7
|
+
iconSet: IconSetStructure | null;
|
|
8
|
+
/** Get an icon by name */
|
|
9
|
+
getIcon(name: string): string | null;
|
|
10
|
+
/** Refresh configuration from globals */
|
|
11
|
+
refresh(): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare const FrontFriend: FrontFriend;
|
|
15
|
+
export default FrontFriend;
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";function d(){let n=new Map,e={get:function(u,t){return t===Symbol.toPrimitive||t==="valueOf"?function(){return""}:t==="toString"||t===Symbol.toStringTag?function(){return""}:t==="constructor"?Object:(n.has(t)||n.set(t,d()),n.get(t))},has:function(u,t){return!(typeof t=="symbol"&&t.toString().includes("nodejs.util.inspect"))},ownKeys:function(u){return[]},getOwnPropertyDescriptor:function(u,t){return{enumerable:!0,configurable:!0}}};return new Proxy({},e)}function f(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function g(n,e){if(!f(n)||!f(e))return e===void 0?n:e;var u=Object.assign({},n);return Object.keys(e).forEach(function(t){u[t]=t in u?g(u[t],e[t]):e[t]}),u}function y(n,e,u,t){return t=t||[],n===void 0||e===void 0?t:!f(n)||!f(e)?(t.push(u.join(".")),t):(Object.keys(n).forEach(function(o){o in e&&y(n[o],e[o],u.concat(o),t)}),t)}function b(n){var e=!1,u={};return Object.keys(n).forEach(function(t){var o=n[t];if(f(o)&&f(o.styles)&&(o.behavior===void 0||f(o.behavior))&&Object.keys(o).every(j=>["styles","behavior"].includes(j))){var w=y(o.styles,o.behavior,[t]);if(w.length>0)throw new Error("Component config styles/behavior conflict at "+w.join(", "));u[t]=g(o.styles||{},o.behavior||{}),e=!0}else throw new TypeError("Component "+t+" must use the styles/behavior envelope")}),e?u:n}let r=null,i=null,c=function(){return typeof window<"u"&&window.__FF_CONFIG__?b(window.__FF_CONFIG__):typeof global<"u"&&global.__FF_CONFIG__?b(global.__FF_CONFIG__):null},s=function(){return typeof window<"u"&&window.__FF_ICONS__?window.__FF_ICONS__:typeof global<"u"&&global.__FF_ICONS__?global.__FF_ICONS__:null},a=new Map,O=new Proxy({},{get:function(n,e){return e===Symbol.toPrimitive||e==="valueOf"?function(){return""}:e==="toString"||e===Symbol.toStringTag?function(){return"[object Object]"}:e==="constructor"?Object:(r||(r=c()),r&&e in r?r[e]:(a.has(e)||a.set(e,d()),a.get(e)))},has:function(n,e){return r||(r=c()),r?e in r:!0},ownKeys:function(n){return r||(r=c()),r?Object.keys(r):[]},getOwnPropertyDescriptor:function(n,e){return r||(r=c()),r&&e in r?Object.getOwnPropertyDescriptor(r,e):{enumerable:!0,configurable:!0}}}),_=new Proxy({},{get:function(n,e){return e===Symbol.toPrimitive||e==="valueOf"?function(){return""}:e==="toString"||e===Symbol.toStringTag?function(){return"[object Object]"}:e==="constructor"?Object:(i||(i=s()),i&&e in i?i[e]:null)},has:function(n,e){return i||(i=s()),i?e in i:!1},ownKeys:function(n){return i||(i=s()),i?Object.keys(i):[]},getOwnPropertyDescriptor:function(n,e){if(i||(i=s()),i&&e in i)return Object.getOwnPropertyDescriptor(i,e)}});function F(n){return!n||typeof n!="object"?d():b(n)}let l={config:O,iconSet:_,ffdc:F,getIcon:function(n){return _[n]},refresh:function(){r=null,i=null,a.clear()}};typeof define=="function"&&define.amd?define([],function(){return l}):typeof module<"u"&&typeof module.exports<"u"&&(module.exports=l,module.exports.default=l),typeof window<"u"&&(window.FrontFriend=l)})();
|
package/dist/runtime.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C=Object.create;var F=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var D=(u,r)=>()=>(r||u((r={exports:{}}).exports,r),r.exports);var T=(u,r,a,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of x(r))!N.call(u,s)&&s!==a&&F(u,s,{get:()=>r[s],enumerable:!(l=P(r,s))||l.enumerable});return u};var E=(u,r,a)=>(a=u!=null?C(I(u)):{},T(r||!u||!u.__esModule?F(a,"default",{value:u,enumerable:!0}):a,u));var j=D((K,d)=>{(function(){"use strict";function u(){let n=new Map,e={get:function(f,t){return t===Symbol.toPrimitive||t==="valueOf"?function(){return""}:t==="toString"||t===Symbol.toStringTag?function(){return""}:t==="constructor"?Object:(n.has(t)||n.set(t,u()),n.get(t))},has:function(f,t){return!(typeof t=="symbol"&&t.toString().includes("nodejs.util.inspect"))},ownKeys:function(f){return[]},getOwnPropertyDescriptor:function(f,t){return{enumerable:!0,configurable:!0}}};return new Proxy({},e)}function r(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function a(n,e){if(!r(n)||!r(e))return e===void 0?n:e;var f=Object.assign({},n);return Object.keys(e).forEach(function(t){f[t]=t in f?a(f[t],e[t]):e[t]}),f}function l(n,e,f,t){return t=t||[],n===void 0||e===void 0?t:!r(n)||!r(e)?(t.push(f.join(".")),t):(Object.keys(n).forEach(function(c){c in e&&l(n[c],e[c],f.concat(c),t)}),t)}function s(n){var e=!1,f={};return Object.keys(n).forEach(function(t){var c=n[t];if(r(c)&&r(c.styles)&&(c.behavior===void 0||r(c.behavior))&&Object.keys(c).every(h=>["styles","behavior"].includes(h))){var O=l(c.styles,c.behavior,[t]);if(O.length>0)throw new Error("Component config styles/behavior conflict at "+O.join(", "));f[t]=a(c.styles||{},c.behavior||{}),e=!0}else throw new TypeError("Component "+t+" must use the styles/behavior envelope")}),e?f:n}let i=null,o=null,b=function(){return typeof window<"u"&&window.__FF_CONFIG__?s(window.__FF_CONFIG__):typeof global<"u"&&global.__FF_CONFIG__?s(global.__FF_CONFIG__):null},g=function(){return typeof window<"u"&&window.__FF_ICONS__?window.__FF_ICONS__:typeof global<"u"&&global.__FF_ICONS__?global.__FF_ICONS__:null},y=new Map,S=new Proxy({},{get:function(n,e){return e===Symbol.toPrimitive||e==="valueOf"?function(){return""}:e==="toString"||e===Symbol.toStringTag?function(){return"[object Object]"}:e==="constructor"?Object:(i||(i=b()),i&&e in i?i[e]:(y.has(e)||y.set(e,u()),y.get(e)))},has:function(n,e){return i||(i=b()),i?e in i:!0},ownKeys:function(n){return i||(i=b()),i?Object.keys(i):[]},getOwnPropertyDescriptor:function(n,e){return i||(i=b()),i&&e in i?Object.getOwnPropertyDescriptor(i,e):{enumerable:!0,configurable:!0}}}),w=new Proxy({},{get:function(n,e){return e===Symbol.toPrimitive||e==="valueOf"?function(){return""}:e==="toString"||e===Symbol.toStringTag?function(){return"[object Object]"}:e==="constructor"?Object:(o||(o=g()),o&&e in o?o[e]:null)},has:function(n,e){return o||(o=g()),o?e in o:!1},ownKeys:function(n){return o||(o=g()),o?Object.keys(o):[]},getOwnPropertyDescriptor:function(n,e){if(o||(o=g()),o&&e in o)return Object.getOwnPropertyDescriptor(o,e)}});function m(n){return!n||typeof n!="object"?u():s(n)}let _={config:S,iconSet:w,ffdc:m,getIcon:function(n){return w[n]},refresh:function(){i=null,o=null,y.clear()}};typeof define=="function"&&define.amd?define([],function(){return _}):typeof d<"u"&&typeof d.exports<"u"&&(d.exports=_,d.exports.default=_),typeof window<"u"&&(window.FrontFriend=_)})()});var v=E(j(),1),A=v.default;export{A as default};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const{PACKAGE_NAME}=require("../lib/core/package-identity"),fs=require("fs"),path=require("path");function generateIconTypes(d={}){const c=d.projectRoot||process.cwd(),l=path.join(c,"node_modules",".cache","frontfriend","icons.json"),i=d.outputPath||path.join(c,"types","frontfriend.d.ts");fs.existsSync(l)||(console.error('[FrontFriend] Error: icons.json not found. Please run "npx frontfriend init" first.'),process.exit(1));try{let u=function(n){for(const e of Object.values(n))typeof e=="string"?f.add(e):typeof e=="object"&&e!==null&&u(e)},p=function(n,e=" "){const o=[];for(const[m,r]of Object.entries(n))typeof r=="string"?o.push(`${e}${m}: '${r}';`):typeof r=="object"&&r!==null&&(o.push(`${e}${m}: {`),o.push(p(r,e+" ")),o.push(`${e}};`));return o.join(`
|
|
3
|
+
`)};var S=u,j=p;const s=JSON.parse(fs.readFileSync(l,"utf-8")),f=new Set;u(s);const t=Array.from(f).map(n=>`'${n}'`).join(" | "),g=`// Generated by ${PACKAGE_NAME}
|
|
4
|
+
// DO NOT EDIT THIS FILE MANUALLY
|
|
5
|
+
|
|
6
|
+
import type { IconSetStructure } from '${PACKAGE_NAME}';
|
|
7
|
+
|
|
8
|
+
declare module '${PACKAGE_NAME}' {
|
|
9
|
+
// Icon names used in this project
|
|
10
|
+
export type ProjectIconName = ${t||"string"};
|
|
11
|
+
|
|
12
|
+
// Typed iconSet structure with exact icon names
|
|
13
|
+
export interface TypedIconSet extends IconSetStructure {
|
|
14
|
+
${p(s)}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Augment Vue component types with exact icon names
|
|
19
|
+
declare module '*/components/ui/icon/*.vue' {
|
|
20
|
+
export type IconName = ${t||"string"};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare module '@/components/ui/icon/*.vue' {
|
|
24
|
+
export type IconName = ${t||"string"};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare module '@/components/ui/icon' {
|
|
28
|
+
export type IconName = ${t||"string"};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module '@/src/components/ui/icon' {
|
|
32
|
+
export type IconName = ${t||"string"};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare module '@/src/components/ui/icon/Icon.vue' {
|
|
36
|
+
export type IconName = ${t||"string"};
|
|
37
|
+
}
|
|
38
|
+
`,y=path.dirname(i);fs.existsSync(y)||fs.mkdirSync(y,{recursive:!0}),fs.writeFileSync(i,g),console.log("[FrontFriend] \u2713 Generated types at",path.relative(c,i));const a=path.join(c,"tsconfig.json");if(fs.existsSync(a)){const n=JSON.parse(fs.readFileSync(a,"utf-8"));n.include||(n.include=[]);const e="types/**/*.d.ts";n.include.includes(e)||(n.include.push(e),fs.writeFileSync(a,JSON.stringify(n,null,2)),console.log("[FrontFriend] \u2713 Updated tsconfig.json to include generated types"))}}catch(s){console.error("[FrontFriend] Error generating icon types:",s.message),process.exit(1)}}require.main===module&&generateIconTypes(),module.exports={generateIconTypes};
|
package/dist/theme.css
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
type ComponentConfigPolicies =
|
|
2
|
+
import("../component-config").ComponentConfigPolicies;
|
|
3
|
+
|
|
4
|
+
type ConfiguredComponentName =
|
|
5
|
+
import("../component-config").ConfiguredComponentName;
|
|
6
|
+
|
|
7
|
+
export type ComponentStyles = string | { [key: string]: ComponentStyles };
|
|
8
|
+
|
|
9
|
+
export type ComponentBehavior =
|
|
10
|
+
| string
|
|
11
|
+
| number
|
|
12
|
+
| boolean
|
|
13
|
+
| null
|
|
14
|
+
| ComponentBehavior[]
|
|
15
|
+
| { [key: string]: ComponentBehavior };
|
|
16
|
+
|
|
17
|
+
export interface ComponentConfigEnvelope {
|
|
18
|
+
styles: Record<string, ComponentStyles>;
|
|
19
|
+
behavior?: Record<string, ComponentBehavior>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type ComponentsConfig = Record<string, ComponentConfigEnvelope>;
|
|
23
|
+
|
|
24
|
+
export const config: Record<string, any> | null;
|
|
25
|
+
|
|
26
|
+
export const iconSet: IconSetStructure;
|
|
27
|
+
|
|
28
|
+
export function ffdc<N extends ConfiguredComponentName>(
|
|
29
|
+
config: ComponentsConfig | Record<string, any> | null | undefined,
|
|
30
|
+
component: N,
|
|
31
|
+
): ComponentConfigPolicies[N]["output"] | null | undefined;
|
|
32
|
+
|
|
33
|
+
export function ffdc(
|
|
34
|
+
config: ComponentsConfig | Record<string, any> | null | undefined,
|
|
35
|
+
): Record<string, any>;
|
|
36
|
+
|
|
37
|
+
export const componentsConfigSchema: Record<string, any>;
|
|
38
|
+
|
|
39
|
+
export function isCSSClassString(value: string): boolean;
|
|
40
|
+
|
|
41
|
+
export interface CacheData {
|
|
42
|
+
variables?: Record<string, string>;
|
|
43
|
+
semanticVariables?: Record<string, string>;
|
|
44
|
+
semanticDarkVariables?: Record<string, string>;
|
|
45
|
+
tokens?: TokenData;
|
|
46
|
+
keyframes?: Record<string, Record<string, any>>;
|
|
47
|
+
animations?: Record<string, string>;
|
|
48
|
+
fonts?: string[];
|
|
49
|
+
safelist?: string[];
|
|
50
|
+
custom?: Record<string, any>;
|
|
51
|
+
componentsConfig?: Record<string, any>;
|
|
52
|
+
icons?: Record<string, string>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface TokenData {
|
|
56
|
+
backgroundColor?: Record<string, string>;
|
|
57
|
+
textColor?: Record<string, string>;
|
|
58
|
+
borderColor?: Record<string, string>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface ProcessedData {
|
|
62
|
+
variables: Record<string, string>;
|
|
63
|
+
colorMap: Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface IconSetStructure {
|
|
67
|
+
[key: string]: any;
|
|
68
|
+
}
|
package/dist/vite.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin for FrontFriend globals injection
|
|
5
|
+
* @returns Vite plugin configuration
|
|
6
|
+
*/
|
|
7
|
+
declare function frontfriend(options?: { fixture?: boolean }): Plugin;
|
|
8
|
+
export { frontfriend };
|
|
9
|
+
export default frontfriend;
|
package/dist/vite.d.ts
ADDED
package/dist/vite.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
`,{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
|
+
|
|
4
|
+
/* Frontfriend Tailwind v4 registry source */
|
|
5
|
+
${S}
|
|
6
|
+
`,map:null}},load(c){if(c!=="virtual:frontfriend-config")return null;let{componentsConfig:u,icons:f}=a||d(r?.root||process.cwd());return r?.command==="serve"&&console.log("[FrontFriend Vite] Injected configuration and icons into build"),`
|
|
7
|
+
globalThis.__FF_CONFIG__ = ${JSON.stringify(u)};
|
|
8
|
+
globalThis.__FF_ICONS__ = ${JSON.stringify(f)};
|
|
9
|
+
`}}};
|
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"module";var r=e(import.meta.url),t=r("./vite.js");var i=t;export{i as default,t as frontfriend};
|
package/package.json
CHANGED
|
@@ -1,6 +1,205 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontfriend/sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Frontfriend SDK: design contracts, tokens, components, CLI and MCP integrations",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/types/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"frontfriend": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
"./token-artifact": {
|
|
12
|
+
"types": "./dist/lib/core/token-artifact.d.ts",
|
|
13
|
+
"default": "./dist/lib/core/token-artifact.js"
|
|
14
|
+
},
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/types/index.d.ts",
|
|
17
|
+
"browser": "./dist/browser.mjs",
|
|
18
|
+
"import": "./dist/index.mjs",
|
|
19
|
+
"require": "./dist/index.js",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./cn": {
|
|
23
|
+
"types": "./dist/cn.d.ts",
|
|
24
|
+
"import": "./dist/cn.mjs",
|
|
25
|
+
"require": "./dist/cn.js",
|
|
26
|
+
"default": "./dist/cn.js"
|
|
27
|
+
},
|
|
28
|
+
"./runtime": {
|
|
29
|
+
"types": "./dist/runtime.d.ts",
|
|
30
|
+
"import": "./dist/runtime.mjs",
|
|
31
|
+
"require": "./dist/runtime.js",
|
|
32
|
+
"default": "./dist/runtime.js"
|
|
33
|
+
},
|
|
34
|
+
"./next": {
|
|
35
|
+
"types": "./dist/next.d.ts",
|
|
36
|
+
"import": "./dist/next.mjs",
|
|
37
|
+
"require": "./dist/next.js",
|
|
38
|
+
"default": "./dist/next.js"
|
|
39
|
+
},
|
|
40
|
+
"./vite": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/vite.d.mts",
|
|
43
|
+
"default": "./dist/vite.mjs"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/vite.d.ts",
|
|
47
|
+
"default": "./dist/vite.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"./lib/react/utils": {
|
|
51
|
+
"types": "./dist/lib/react/utils.d.ts",
|
|
52
|
+
"default": "./dist/lib/react/utils.mjs"
|
|
53
|
+
},
|
|
54
|
+
"./lib/vue/utils": {
|
|
55
|
+
"types": "./dist/lib/vue/utils.d.ts",
|
|
56
|
+
"default": "./dist/lib/vue/utils.mjs"
|
|
57
|
+
},
|
|
58
|
+
"./ffdc": {
|
|
59
|
+
"types": "./dist/ffdc.d.ts",
|
|
60
|
+
"import": "./dist/ffdc.mjs",
|
|
61
|
+
"require": "./dist/ffdc.js",
|
|
62
|
+
"default": "./dist/ffdc.js"
|
|
63
|
+
},
|
|
64
|
+
"./theme": "./dist/theme.css",
|
|
65
|
+
"./theme.css": "./dist/theme.css",
|
|
66
|
+
"./components-config-schema": {
|
|
67
|
+
"types": "./dist/components-config-schema.d.ts",
|
|
68
|
+
"require": "./dist/components-config-schema.js",
|
|
69
|
+
"import": "./dist/components-config-schema.js",
|
|
70
|
+
"default": "./dist/components-config-schema.js"
|
|
71
|
+
},
|
|
72
|
+
"./component-recipes": {
|
|
73
|
+
"types": "./dist/component-recipes.d.ts",
|
|
74
|
+
"require": "./dist/lib/core/component-recipes.js",
|
|
75
|
+
"import": "./dist/lib/core/component-recipes.js",
|
|
76
|
+
"default": "./dist/lib/core/component-recipes.js"
|
|
77
|
+
},
|
|
78
|
+
"./component-config": {
|
|
79
|
+
"types": "./dist/component-config.d.ts",
|
|
80
|
+
"browser": "./dist/component-config.mjs",
|
|
81
|
+
"import": "./dist/component-config.mjs",
|
|
82
|
+
"require": "./dist/lib/core/component-config.js",
|
|
83
|
+
"default": "./dist/lib/core/component-config.js"
|
|
84
|
+
},
|
|
85
|
+
"./project-target": {
|
|
86
|
+
"types": "./dist/project-target.d.ts",
|
|
87
|
+
"require": "./dist/lib/core/project-target.js",
|
|
88
|
+
"import": "./dist/lib/core/project-target.js",
|
|
89
|
+
"default": "./dist/lib/core/project-target.js"
|
|
90
|
+
},
|
|
91
|
+
"./application-adoption": {
|
|
92
|
+
"types": "./dist/application-adoption.d.ts",
|
|
93
|
+
"require": "./dist/lib/core/application-adoption.js",
|
|
94
|
+
"import": "./dist/lib/core/application-adoption.js",
|
|
95
|
+
"default": "./dist/lib/core/application-adoption.js"
|
|
96
|
+
},
|
|
97
|
+
"./application-adoption-lock": {
|
|
98
|
+
"types": "./dist/application-adoption-lock.d.ts",
|
|
99
|
+
"require": "./dist/lib/core/application-adoption-lock.js",
|
|
100
|
+
"import": "./dist/lib/core/application-adoption-lock.js",
|
|
101
|
+
"default": "./dist/lib/core/application-adoption-lock.js"
|
|
102
|
+
},
|
|
103
|
+
"./native-source": {
|
|
104
|
+
"types": "./dist/lib/core/nativeSource.d.ts",
|
|
105
|
+
"default": "./dist/lib/core/nativeSource.js"
|
|
106
|
+
},
|
|
107
|
+
"./foundation-contract": "./dist/foundation-contract.json",
|
|
108
|
+
"./token-processor": {
|
|
109
|
+
"types": "./dist/lib/core/token-processor.d.ts",
|
|
110
|
+
"default": "./dist/lib/core/token-processor.js"
|
|
111
|
+
},
|
|
112
|
+
"./package.json": "./package.json"
|
|
113
|
+
},
|
|
114
|
+
"keywords": [
|
|
115
|
+
"frontfriend",
|
|
116
|
+
"design-contracts",
|
|
117
|
+
"design-tokens",
|
|
118
|
+
"design-system",
|
|
119
|
+
"mcp",
|
|
120
|
+
"cli"
|
|
121
|
+
],
|
|
122
|
+
"author": "Donux",
|
|
123
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
124
|
+
"publishConfig": {
|
|
125
|
+
"access": "public",
|
|
126
|
+
"tag": "latest"
|
|
127
|
+
},
|
|
128
|
+
"files": [
|
|
129
|
+
"dist/",
|
|
130
|
+
"README.md",
|
|
131
|
+
"LICENSE"
|
|
132
|
+
],
|
|
133
|
+
"dependencies": {
|
|
134
|
+
"cn": "0.3.0",
|
|
135
|
+
"color": "^4.2.3",
|
|
136
|
+
"commander": "^11.0.0",
|
|
137
|
+
"dotenv": "^16.0.0"
|
|
138
|
+
},
|
|
139
|
+
"peerDependencies": {
|
|
140
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
141
|
+
"tailwindcss": "^4.0.0",
|
|
142
|
+
"tw-animate-css": "^1.3.0",
|
|
143
|
+
"vue": ">=3.0.0",
|
|
144
|
+
"typescript": "^5.0.0"
|
|
145
|
+
},
|
|
146
|
+
"devDependencies": {
|
|
147
|
+
"@modelcontextprotocol/client": "2.0.0",
|
|
148
|
+
"@modelcontextprotocol/server": "2.0.0",
|
|
149
|
+
"@tailwindcss/oxide": "4.3.3",
|
|
150
|
+
"@types/node": "^22.0.0",
|
|
151
|
+
"esbuild": "^0.19.0",
|
|
152
|
+
"glob": "^10.0.0",
|
|
153
|
+
"jest": "^29.0.0",
|
|
154
|
+
"smol-toml": "^1.7.0",
|
|
155
|
+
"typescript": "^5.0.0",
|
|
156
|
+
"@radix-ui/react-slot": "^1.0.2",
|
|
157
|
+
"class-variance-authority": "^0.7.0",
|
|
158
|
+
"tailwindcss": "4.3.3",
|
|
159
|
+
"tailwind-merge": "3.7.0",
|
|
160
|
+
"tailwindcss-min": "npm:tailwindcss@4.0.0",
|
|
161
|
+
"postcss": "^8.5.6",
|
|
162
|
+
"acorn": "8.17.0",
|
|
163
|
+
"semver": "^7.7.2",
|
|
164
|
+
"cross-spawn": "7.0.6",
|
|
165
|
+
"tw-animate-css": "^1.3.4",
|
|
166
|
+
"@frontfriend/design-brain": "0.16.1"
|
|
167
|
+
},
|
|
168
|
+
"engines": {
|
|
169
|
+
"node": ">=20.19.0"
|
|
170
|
+
},
|
|
171
|
+
"peerDependenciesMeta": {
|
|
172
|
+
"react": {
|
|
173
|
+
"optional": true
|
|
174
|
+
},
|
|
175
|
+
"tailwindcss": {
|
|
176
|
+
"optional": true
|
|
177
|
+
},
|
|
178
|
+
"vue": {
|
|
179
|
+
"optional": true
|
|
180
|
+
},
|
|
181
|
+
"typescript": {
|
|
182
|
+
"optional": true
|
|
183
|
+
},
|
|
184
|
+
"tw-animate-css": {
|
|
185
|
+
"optional": true
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"homepage": "https://frontfriend.dev/docs/sdk/",
|
|
189
|
+
"bugs": {
|
|
190
|
+
"email": "frontfriend@donux.com"
|
|
191
|
+
},
|
|
192
|
+
"sideEffects": [
|
|
193
|
+
"**/*.css",
|
|
194
|
+
"./dist/runtime.js",
|
|
195
|
+
"./dist/runtime.mjs"
|
|
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
|
+
}
|
|
6
205
|
}
|