@designid/tokens 1.2.13 → 1.2.14
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/bin/build.js +82 -82
- package/bin/editor.js +143 -143
- package/bin/watch.js +106 -106
- package/package.json +1 -1
package/bin/watch.js
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as M0}from"node:module";var J0=Object.create;var{getPrototypeOf:B0,defineProperty:rX,getOwnPropertyNames:I0}=Object;var w0=Object.prototype.hasOwnProperty;var R0=(X,Z,Y)=>{Y=X!=null?J0(B0(X)):{};let q=Z||!X||!X.__esModule?rX(Y,"default",{value:X,enumerable:!0}):Y;for(let $ of I0(X))if(!w0.call(q,$))rX(q,$,{get:()=>X[$],enumerable:!0});return q};var sX=(X,Z)=>{for(var Y in Z)rX(X,Y,{get:Z[Y],enumerable:!0,configurable:!0,set:(q)=>Z[Y]=()=>q})};var S=(X,Z)=>()=>(X&&(Z=X(X=0)),Z);var n=M0(import.meta.url);var sY={};sX(sY,{transformColorValueAsync:()=>j0,transformColorValue:()=>b,transformColorToken:()=>DX,setAlpha:()=>AX,isColor:()=>p,initializeColorspace:()=>x0});import iX from"colorjs.io";async function lY(){if(bX===null){let{colorspace:X}=await T();bX=X||"hex"}return bX}function F0(){return bX||"hex"}async function x0(){await lY()}function AX(X,Z){let Y=new iX(X);if(Z||Z===0)Y.alpha=Z/100;return b(Y)}function rY(X,Z){if(!X)return X;if(Z&&Z.type!=="color")return X;if(typeof X==="string")X=new iX(X);if(typeof X?.to!=="function")return X;let Y=F0();try{switch(Y){case"hex":return X.to("srgb").toString({format:"hex"});case"rgb":case"srgb":return X.to("srgb").toString();case"srgb-linear":return X.to("srgb-linear").toString();case"display-p3":case"p3":return X.to("p3").toString();case"a98rgb":case"a98-rgb":return X.to("a98rgb").toString();case"prophoto":case"prophoto-rgb":return X.to("prophoto").toString();case"rec2020":case"rec-2020":return X.to("rec2020").toString();case"xyz":case"xyz-d65":return X.to("xyz-d65").toString();case"xyz-d50":return X.to("xyz-d50").toString();case"lab":case"cielab":return X.to("lab").toString();case"lab-d65":return X.to("lab-d65").toString();case"oklab":return X.to("oklab").toString();case"lch":case"cielch":return X.to("lch").toString();case"oklch":return X.to("oklch").toString();case"hsl":return X.to("hsl").toString();case"hsv":case"hsb":return X.to("hsv").toString();case"hwb":return X.to("hwb").toString();case"luv":return X.to("luv").toString();case"lchuv":return X.to("lchuv").toString();case"jzazbz":return X.to("jzazbz").toString();case"jzczhz":return X.to("jzczhz").toString();case"ictcp":return X.to("ictcp").toString();default:return X.to(Y).toString()}}catch(q){return console.warn(`Unsupported colorspace '${Y}', falling back to hex. Error:`,q),X.to("srgb").toString({format:"hex"})}}async function j0(X,Z){return await lY(),rY(X,Z)}function b(X,Z){return rY(X,Z)}function DX(X,Z,Y,q){try{if(X=v(Z,q),Z.$type==="color"&&Z.original?.$value&&Z.original?.$value!==Z.$value){if(P(Z.original.$value))X=f(Z.original.$value,Y,q,Z);else X=C(Z);if(!D(q)&&Z.original?.$extensions?.mode?.[q])X=Z.original.$extensions.mode[q]}if(P(X))X=f(X,Y,q,Z);return b(X)}catch{return X=v(Z,q),b(X)}}function p(X){try{if(X)return new iX(X),!0;return!1}catch{return!1}}var bX=null;var EX=S(()=>{g()});function iY(X,Z){let Y=X.$extensions?.delimiter?.character||" ",q=v(X,Z)??{},$=X.$extensions?.sort??[],U=C(X)??{};if($.length>0)U=Object.keys(U).sort((W,K)=>{let z=$.indexOf(W),G=$.indexOf(K);return z-G}).reduce((W,K)=>{return W[K]=q[K],W},{});return Object.keys(U).reduce((W,K)=>{let z=C(q[K]);if(q[K]?.$type==="color"||q[K].$property==="color")z=b(z,q[K]);return[...Array.isArray(W)?W:[W],z]},[]).join(Y).trim()}function c(X,Z){let Y=($)=>{if($===void 0||$===null)return;if(typeof $==="object"&&"value"in $)return $.value;return $},q=X.match(/^\{(.+)\}$/);if(q){let $=q[1],U=Z.get($);if(U===void 0)return`/* Unknown token: ${$} */`;let W=Y(U);if(W===void 0)return`/* Unknown token: ${$} */`;if(typeof W==="object"&&W!==null){let K=[];for(let z in W){if(z.startsWith("$"))continue;let G=W[z],A=typeof G==="object"&&G?.value!==void 0?G.value:G;if(typeof A==="string"&&A.match(/^\{.+\}$/))K.push(c(A,Z));else K.push(String(A))}return K.join(" ")}if(typeof W==="string"&&W.match(/^\{.+\}$/))return c(W,Z);return String(W)}if(X.includes("{"))return X.replace(/\{([^}]+)\}/g,($,U)=>{let W=Z.get(U);if(W===void 0)return`/* Unknown token: ${U} */`;let K=Y(W);if(K===void 0)return`/* Unknown token: ${U} */`;if(typeof K==="object"&&K!==null)return`/* Cannot embed composite token: ${U} */`;if(typeof K==="string"&&K.match(/^\{.+\}$/))return c(K,Z);return String(K)});return X}function b0(X,Z,Y,q){return Object.keys(Z??{}).reduce((U,W)=>{let K=Z[W];if(typeof K==="string"||typeof K==="number")K={$value:K,$type:typeof K,value:K};if(K.$type=K.type||X?.original?.$value?.[W]?.type||K.$type||X.$type,!D(q)&&l(K,"mode",{isIncludedOriginalValue:!0}))K.$value=v(K,q);if(K?.$type==="composition"&&(typeof K.$value!=="string"||typeof K.$value!=="number"||P(K.$value))&&Object.keys(K).length>0){if(P(K.$value))return K.$value=f(K.$value,Y,q,K),{...U,[W]:{...K,$property:W,$type:K.$type,$value:ZX(K,Y,q)}};return{...U,[W]:{...K,$property:W,$type:K.$type,$value:ZX(K,Y,q)}}}if(K?.$value){let G=f(K.$value,Y,q,K);return{...U,[W]:{...K,$property:W,$type:K.$type,$value:G}}}return U},{})}function ZX(X,Z,Y){let q=C(X,{isIncludedOriginalValue:!0});if(typeof q==="string"){if(P(q)){if(q=aX(q,Z,Y,X),!D(Y)&&l(q,"mode",{isIncludedOriginalValue:!0}))q.$value=v(q,Y)}let $=$X(q);if($&&($?.length??0)>1)q=qX(q,$,Z,Y)}else if(Array.isArray(q))q=q.map(($)=>{if(typeof $==="string"&&P($))return f($,Z,Y,X);return $});if(!X.name)return q;return X.$value=b0(X,q,Z,Y),iY(X,Y)}var SX=S(()=>{g()});function C(X,Z){let{isIncludedOriginalValue:Y=!1,fallbackValue:q=null}=Z??{};if(Y)return X?.original?.$value??X?.$value??X.value??q;return X?.$value??X?.value??q}function v(X,Z){return Z&&(X?.$extensions?.mode?.[Z]||typeof X?.$extensions?.mode?.[Z]==="number")?X.$extensions.mode[Z]:C(X,{fallbackValue:X?.original?.$value??X?.$value??X?.value})??null}function l(X,Z,{isIncludedOriginalValue:Y=!1}={}){let q=!1;if(Y&&X?.original?.$extensions?.[Z])q=!0;if(X?.$extensions?.[Z])q=!0;return q}function nX(X,Z,Y){let q=C(X,{isIncludedOriginalValue:!0});if(!D(Y)&&l(X,"mode",{isIncludedOriginalValue:!0}))q=v(X,Y);if(P(q))return oX(q,Z,Y,X);return q}function qX(X,Z,Y,q){let $=Z.reduce((U,W)=>{let K=tX(W,Y);if(!K)return U;let z=C(K,{isIncludedOriginalValue:!0});if(P(z))z=f(`{${W}}`,Y,q,K);return{...U,[W]:PX(K,z,Y,q)}},{});return X?.replace(/\{([^}]+)\}/g,(U,W)=>{return $[W]!==void 0?$[W]:U})??null}function aX(X,Z,Y,q){if(P(X))return f(X,Z,Y,q);return X}function tX(X,Z){return Z.allTokens.find((Y)=>Y.path.join(".")===X)??null}function f(X,Z,Y,q){let $=P(X),U=null,W=X??C(q),K=null;if($){if(U=tX($,Z),Y&&U&&U?.$extensions?.mode?.[Y]!==U.original?.$extensions?.mode?.[Y])W=U.original?.$extensions?.mode?.[Y],K=U.original?.$extensions?.alpha??K;else if(U?.$extensions?.mode?.[Y])W=U.$extensions.mode[Y],K=U.$extensions?.alpha??K;else if(U?.original?.$value)W=U?.original.$value??U?.$value,K=U?.original.$extensions?.alpha??K}if(W!==X&&P(W))W=f(W,Z,Y,q);if(W&&(K||q?.$extensions?.alpha||K===0||q?.original?.$extensions?.alpha===0))K=K??q?.$extensions?.alpha??null,W=AX(W,K);return W=b(W,U??q),W??X}function oX(X,Z,Y,q){let $=q?.original?.$extensions?.mode?.[Y]??q?.original?.$value,U=P($);if(Y&&U){let W=Z.allTokens.find((z)=>z.path.join(".")===U);if(!W)return X;let K=C(W);if(P(K))return oX(K,Z,Y,W);if(W?.$extensions?.mode?.[Y])K=W.$extensions.mode[Y];if(K&&W?.$extensions?.alpha)K=AX(W.$value,W.$extensions.alpha);return b(K,W)??X}else if($)return b($,q);return X}function P(X){if(typeof X!=="string")return null;let Z=/{[^}]+}/g,Y=X.match(Z);if(Y?.length!==1)return null;return Y[0].slice(1,-1)}function $X(X){if(typeof X!=="string")return null;return[...X.matchAll(/\{([^}]+)\}/g)].map(([,Y])=>Y)??null}function UX(X){return X}function LX(X){return X}var eX=S(()=>{g()});var IZ={};sX(IZ,{wrapThemeValue:()=>QY,wrapFormatCSSFile:()=>QZ,typographyFileName:()=>$Z,tokensFileName:()=>ZZ,removeDirectoryContents:()=>EY,readConfigFile:()=>GX,namespaceUUID:()=>WZ,iconsFileName:()=>UZ,getTokenfileName:()=>GZ,getRelativePath:()=>BZ,getRelativeCSSPath:()=>JZ,getRawTokensFileName:()=>LZ,getProjectPaths:()=>d,getProjectModes:()=>HY,getProjectMetaData:()=>T,getProjectFonts:()=>y0,getLazyTokensConfig:()=>XY,getLazyProjectPaths:()=>_Y,getLazyProjectModes:()=>HX,getLazyProjectMetaData:()=>JX,getLazyProjectFonts:()=>g0,getLazyProjectData:()=>r,getLazyIcons:()=>gX,getJSDocHeader:()=>HZ,getIconDestinationFileName:()=>WX,getFiles:()=>yX,getFileHeader:()=>LY,getDistThemeFileDelimeter:()=>zZ,getDistConfigFile:()=>CX,getDestinationFileName:()=>AZ,getDefaultIconObjectPath:()=>KZ,getCSSDestinationFileName:()=>EZ,getBaseDirectory:()=>o,getBaseConfigFile:()=>QX,generatedFileHeader:()=>KX,filterTokensByType:()=>VX,createFileHeaderTitle:()=>_X,compileConfigFile:()=>AY,combineCSSFiles:()=>OZ,checkAndCreateDirectory:()=>t,breakpointFileName:()=>qZ});import{spawnSync as D0}from"child_process";import{existsSync as h,mkdirSync as S0,readFileSync as P0,unlinkSync as aY,writeFileSync as C0}from"fs";import{readdir as eY,rmdir as V0,unlink as T0}from"fs/promises";import{resolve as XZ,join as x,basename as YZ,normalize as nY,relative as tY,sep as YY,dirname as oY}from"path";async function KZ(){return`${(await OX()).$metaData?.tokenNamespace||"tokens"}.icons`}async function AY(X){let Y=x(X,"designid.config.ts");if(h(x(X,"designid.config.mjs")))aY(x(X,"designid.config.mjs"));let q=x(X,"designid.config.js");if(h(q))aY(q);if(h(Y)){let $=D0("bun",["build",Y,"--outfile ./designid.config.mjs","--minify","--target","node","--packages","external","--no-bundle"],{stdio:"inherit",cwd:X,shell:!0});if($.status!==0)console.error("Failed to compile designid.config.mjs with bun."),process.exit($.status??1);if($.status===0)return new Promise((U)=>U(!0))}}async function EY(X){try{if(h(X)){let Z=await eY(X,{withFileTypes:!0});for(let Y of Z){let q=x(X,Y.name);if(Y.isDirectory())await EY(q),await V0(q);else await T0(q)}}}catch(Z){console.error(`Error removing contents of ${X}:`,Z)}}async function yX(X){let Z=await eY(X,{withFileTypes:!0}),Y=await Promise.all(Z.map((q)=>{let $=XZ(X,q.name);return q.isDirectory()?yX($):$}));return Array.prototype.concat(...Y)}async function WZ(X){let{dsNamespace:Z,tokenNamespace:Y}=await T();return`${(Z??Y).toUpperCase()}DesignSystem${X.charAt(0).toUpperCase()+X.slice(1)}Tokens`}function GZ(X,Z="d.ts",Y){if(!X)return`tokens.${Y}.config.${Z}`;return x(X,`tokens.${Y}.config.${Z}`)}function zZ(X,Z){return X.length>1?`.${Z}`:""}async function AZ(X="d.ts",Z){let{tokenNamespace:Y}=await T();if(Z)return`${Y}-design-system.${Z}.tokens.config.${X}`;return`${Y}-design-system.tokens.config.${X}`}async function WX(X="json"){let{tokenNamespace:Z}=await T();return`${Z}-design-system.tokens.svg${X==="d.ts"||X==="js"?".config":""}.${X}`}async function EZ(){let{tokenNamespace:X}=await T();return`${X}-design-system.tokens.css`}async function LZ(){let{tokenNamespace:X}=await T();return`${X}-design-system-raw.tokens.json`}async function LY(X){let{tokenNamespace:Z}=await T();return`${Z} | ${X}`}function HZ(X,Z){return`/** @type {import("./${X}").${Z}} */`}function _X(X){return`/* ${LY(X)} */`}function t(X){if(!h(X))S0(X,{recursive:!0})}async function GX(X,Z=!1){let Y=QX(),q;if(Y.endsWith(".json"))q=JSON.parse(P0(Y,"utf8").trim()??"{}");else if(Y.endsWith(".ts"))if(typeof globalThis.Bun<"u"){if(q=await import(Y),q.default)q=q.default}else{X=X??oY(Y)+"/";let U=CX(X);if(U&&(Z||!h(U)))await AY(X);if(q=await import(U),q.default)q=q.default}else{X=X??oY(Y)+"/";let $=CX(X);if($&&(Z||!h($)))await AY(X);if(q=await import($),q.default)q=q.default}return q}async function o(X=!1){let{baseDir:Z}=await d(),Y=process.cwd(),$=x(Y,Z),{buildDir:U,distDir:W}=await d();if(X)try{t(x($,U)),t(x($,W))}catch(K){console.error("Error creating directories:",K)}return $}function CX(X){return X?x(X,"designid.config.mjs"):x(process.cwd(),"designid.config.mjs")}function QX(){let X=process.argv.find((K)=>K.startsWith("--config=")),[,Z]=X?.split("=")??[];if(Z)return Z;let Y=process.cwd(),q=CX(Y),$=x(Y,"designid.config.ts"),U=h(q),W=h($);if(U)return q;else if(W)return $;throw console.error("Config file not found"),Error("Config file not found")}async function d(X=!1){let Z=QX(),q=(await GX(process.cwd(),X)).$paths;if(!q)throw console.error("Project paths not found"),Error("Project paths not found");return{configFile:Z,...q}}async function T(){let Z=(await GX(process.cwd())).$metaData;if(!Z)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!Z.colorspace)Z.colorspace="hex";if(!Z.fontNamespace)Z.fontNamespace=`${Z.dsNamespace}.font`;if(!Z?.tokens?.css?.mediaQuery?.match)Z={...Z??{},tokens:{...Z.tokens??{},css:{...Z.tokens?.css??{},mediaQuery:{...Z.tokens?.css?.mediaQuery??{},match:"[data-theme]"}}}};if(Z?.tokens?.css?.mediaQuery&&typeof Z.tokens.css.mediaQuery.separateThemeFiles!=="boolean")Z.tokens.css.mediaQuery.separateThemeFiles=!1;if(!Z.dsNamespace)Z.dsNamespace=Z.tokenNamespace;let Y=await KZ();return{...Z,icons:Z.icons??{objectPath:Y},dsNamespace:Z.dsNamespace}}async function HY(){return(await GX(process.cwd())).$modes??{default:"light"}}async function OX(){if(!ZY){let X=QX();ZY=await GX(process.cwd()),_Z=X}return ZY}async function HX(){if(!qY)qY=(await OX()).$modes??{default:"light"};return qY}async function JX(){if(!$Y){let Z=(await OX()).$metaData;if(!Z)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!Z.dsNamespace)Z.dsNamespace=Z.tokenNamespace;let q=`${Z.tokenNamespace||"tokens"}.icons`;$Y={...Z,icons:Z.icons??{objectPath:q},dsNamespace:Z.dsNamespace}}return $Y}async function _Y(X=!1){if(!UY){let Y=(await OX()).$paths;if(!Y)throw console.error("Project paths not found"),Error("Project paths not found");UY={configFile:_Z,...Y}}return UY}async function r(){if(!KY){let{distDir:X,assets:Z,buildDir:Y}=await _Y(!0),{fontNamespace:q,tokenNamespace:$,icons:U}=await JX(),W=await o(),K=process.cwd(),z=x(K,X,"css");KY={distDir:X,assets:Z,fontNamespace:q,__dirname:W,workspaceRoot:K,distCSSPath:z,buildDir:Y,tokenNamespace:$,icons:U}}return KY}async function gX(){if(!WY){let{icons:X}=await JX();WY=X}return WY}async function XY(){if(!GY){let{tokens:X}=await JX();GY=X}return GY}async function y0(){return(await GX(process.cwd())).$fonts??[]}async function g0(){if(!zY)zY=(await OX()).$fonts??[];return zY}async function QY(X){if(D(X))return":root";let Y=(await T())?.tokens?.css?.mediaQuery?.match??"[data-theme]";if(Y.startsWith("[")&&Y.endsWith("]"))return`${Y.replace("]",`="${X}"]`)}`;else if(Y.startsWith(".")||Y.startsWith("#"))return`${Y}${X}`;else return`${Y}${X}`}async function QZ(X,Z,Y,q,$,U={}){let W;if(D(Y))W=Z.allTokens;else W=X(Z,Y);let z=(await T())?.tokens?.css?.mediaQuery?.separateThemeFiles?"Theme: "+Y:U.headerTitle??"",G=`${_X(z)}
|
|
3
|
-
${KX}`,
|
|
2
|
+
import{createRequire as N0}from"node:module";var B0=Object.create;var{getPrototypeOf:I0,defineProperty:sX,getOwnPropertyNames:w0}=Object;var R0=Object.prototype.hasOwnProperty;var M0=(X,Z,Y)=>{Y=X!=null?B0(I0(X)):{};let q=Z||!X||!X.__esModule?sX(Y,"default",{value:X,enumerable:!0}):Y;for(let $ of w0(X))if(!R0.call(q,$))sX(q,$,{get:()=>X[$],enumerable:!0});return q};var iX=(X,Z)=>{for(var Y in Z)sX(X,Y,{get:Z[Y],enumerable:!0,configurable:!0,set:(q)=>Z[Y]=()=>q})};var S=(X,Z)=>()=>(X&&(Z=X(X=0)),Z);var n=N0(import.meta.url);var sY={};iX(sY,{transformColorValueAsync:()=>D0,transformColorValue:()=>D,transformColorToken:()=>bX,setAlpha:()=>AX,isColor:()=>p,initializeColorspace:()=>j0});import aX from"colorjs.io";async function lY(){if(DX===null){let{colorspace:X}=await T();DX=X||"hex"}return DX}function x0(){return DX||"hex"}async function j0(){await lY()}function AX(X,Z){let Y=new aX(X);if(Z||Z===0)Y.alpha=Z/100;return D(Y)}function rY(X,Z){if(!X)return X;if(Z&&Z.type!=="color")return X;if(typeof X==="string")X=new aX(X);if(typeof X?.to!=="function")return X;let Y=x0();try{switch(Y){case"hex":return X.to("srgb").toString({format:"hex"});case"rgb":case"srgb":return X.to("srgb").toString();case"srgb-linear":return X.to("srgb-linear").toString();case"display-p3":case"p3":return X.to("p3").toString();case"a98rgb":case"a98-rgb":return X.to("a98rgb").toString();case"prophoto":case"prophoto-rgb":return X.to("prophoto").toString();case"rec2020":case"rec-2020":return X.to("rec2020").toString();case"xyz":case"xyz-d65":return X.to("xyz-d65").toString();case"xyz-d50":return X.to("xyz-d50").toString();case"lab":case"cielab":return X.to("lab").toString();case"lab-d65":return X.to("lab-d65").toString();case"oklab":return X.to("oklab").toString();case"lch":case"cielch":return X.to("lch").toString();case"oklch":return X.to("oklch").toString();case"hsl":return X.to("hsl").toString();case"hsv":case"hsb":return X.to("hsv").toString();case"hwb":return X.to("hwb").toString();case"luv":return X.to("luv").toString();case"lchuv":return X.to("lchuv").toString();case"jzazbz":return X.to("jzazbz").toString();case"jzczhz":return X.to("jzczhz").toString();case"ictcp":return X.to("ictcp").toString();default:return X.to(Y).toString()}}catch(q){return console.warn(`Unsupported colorspace '${Y}', falling back to hex. Error:`,q),X.to("srgb").toString({format:"hex"})}}async function D0(X,Z){return await lY(),rY(X,Z)}function D(X,Z){return rY(X,Z)}function bX(X,Z,Y,q){try{if(X=v(Z,q),Z.$type==="color"&&Z.original?.$value&&Z.original?.$value!==Z.$value){if(P(Z.original.$value))X=f(Z.original.$value,Y,q,Z);else X=C(Z);if(!b(q)&&Z.original?.$extensions?.mode?.[q])X=Z.original.$extensions.mode[q]}if(P(X))X=f(X,Y,q,Z);return D(X)}catch{return X=v(Z,q),D(X)}}function p(X){try{if(X)return new aX(X),!0;return!1}catch{return!1}}var DX=null;var EX=S(()=>{g()});function iY(X,Z){let Y=X.$extensions?.delimiter?.character||" ",q=v(X,Z)??{},$=X.$extensions?.sort??[],U=C(X)??{};if($.length>0)U=Object.keys(U).sort((W,K)=>{let z=$.indexOf(W),G=$.indexOf(K);return z-G}).reduce((W,K)=>{return W[K]=q[K],W},{});return Object.keys(U).reduce((W,K)=>{let z=C(q[K]);if(q[K]?.$type==="color"||q[K].$property==="color")z=D(z,q[K]);return[...Array.isArray(W)?W:[W],z]},[]).join(Y).trim()}function c(X,Z){let Y=($)=>{if($===void 0||$===null)return;if(typeof $==="object"&&"value"in $)return $.value;return $},q=X.match(/^\{(.+)\}$/);if(q){let $=q[1],U=Z.get($);if(U===void 0)return`/* Unknown token: ${$} */`;let W=Y(U);if(W===void 0)return`/* Unknown token: ${$} */`;if(typeof W==="object"&&W!==null){let K=[];for(let z in W){if(z.startsWith("$"))continue;let G=W[z],E=typeof G==="object"&&G?.value!==void 0?G.value:G;if(typeof E==="string"&&E.match(/^\{.+\}$/))K.push(c(E,Z));else K.push(String(E))}return K.join(" ")}if(typeof W==="string"&&W.match(/^\{.+\}$/))return c(W,Z);return String(W)}if(X.includes("{"))return X.replace(/\{([^}]+)\}/g,($,U)=>{let W=Z.get(U);if(W===void 0)return`/* Unknown token: ${U} */`;let K=Y(W);if(K===void 0)return`/* Unknown token: ${U} */`;if(typeof K==="object"&&K!==null)return`/* Cannot embed composite token: ${U} */`;if(typeof K==="string"&&K.match(/^\{.+\}$/))return c(K,Z);return String(K)});return X}function b0(X,Z,Y,q){return Object.keys(Z??{}).reduce((U,W)=>{let K=Z[W];if(typeof K==="string"||typeof K==="number")K={$value:K,$type:typeof K,value:K};if(K.$type=K.type||X?.original?.$value?.[W]?.type||K.$type||X.$type,!b(q)&&l(K,"mode",{isIncludedOriginalValue:!0}))K.$value=v(K,q);if(K?.$type==="composition"&&(typeof K.$value!=="string"||typeof K.$value!=="number"||P(K.$value))&&Object.keys(K).length>0){if(P(K.$value))return K.$value=f(K.$value,Y,q,K),{...U,[W]:{...K,$property:W,$type:K.$type,$value:ZX(K,Y,q)}};return{...U,[W]:{...K,$property:W,$type:K.$type,$value:ZX(K,Y,q)}}}if(K?.$value){let G=f(K.$value,Y,q,K);return{...U,[W]:{...K,$property:W,$type:K.$type,$value:G}}}return U},{})}function ZX(X,Z,Y){let q=C(X,{isIncludedOriginalValue:!0});if(typeof q==="string"){if(P(q)){if(q=nX(q,Z,Y,X),!b(Y)&&l(q,"mode",{isIncludedOriginalValue:!0}))q.$value=v(q,Y)}let $=$X(q);if($&&($?.length??0)>1)q=qX(q,$,Z,Y)}else if(Array.isArray(q))q=q.map(($)=>{if(typeof $==="string"&&P($))return f($,Z,Y,X);return $});if(!X.name)return q;return X.$value=b0(X,q,Z,Y),iY(X,Y)}var SX=S(()=>{g()});function C(X,Z){let{isIncludedOriginalValue:Y=!1,fallbackValue:q=null}=Z??{};if(Y)return X?.original?.$value??X?.$value??X.value??q;return X?.$value??X?.value??q}function v(X,Z){return Z&&(X?.$extensions?.mode?.[Z]||typeof X?.$extensions?.mode?.[Z]==="number")?X.$extensions.mode[Z]:C(X,{fallbackValue:X?.original?.$value??X?.$value??X?.value})??null}function l(X,Z,{isIncludedOriginalValue:Y=!1}={}){let q=!1;if(Y&&X?.original?.$extensions?.[Z])q=!0;if(X?.$extensions?.[Z])q=!0;return q}function tX(X,Z,Y){let q=C(X,{isIncludedOriginalValue:!0});if(!b(Y)&&l(X,"mode",{isIncludedOriginalValue:!0}))q=v(X,Y);if(P(q))return eX(q,Z,Y,X);return q}function qX(X,Z,Y,q){let $=Z.reduce((U,W)=>{let K=oX(W,Y);if(!K)return U;let z=C(K,{isIncludedOriginalValue:!0});if(P(z))z=f(`{${W}}`,Y,q,K);return{...U,[W]:PX(K,z,Y,q)}},{});return X?.replace(/\{([^}]+)\}/g,(U,W)=>{return $[W]!==void 0?$[W]:U})??null}function nX(X,Z,Y,q){if(P(X))return f(X,Z,Y,q);return X}function oX(X,Z){return Z.allTokens.find((Y)=>Y.path.join(".")===X)??null}function f(X,Z,Y,q){let $=P(X),U=null,W=X??C(q),K=null;if($){if(U=oX($,Z),Y&&U&&U?.$extensions?.mode?.[Y]!==U.original?.$extensions?.mode?.[Y])W=U.original?.$extensions?.mode?.[Y],K=U.original?.$extensions?.alpha??K;else if(U?.$extensions?.mode?.[Y])W=U.$extensions.mode[Y],K=U.$extensions?.alpha??K;else if(U?.original?.$value)W=U?.original.$value??U?.$value,K=U?.original.$extensions?.alpha??K}if(W!==X&&P(W))W=f(W,Z,Y,q);if(W&&(K||q?.$extensions?.alpha||K===0||q?.original?.$extensions?.alpha===0))K=K??q?.$extensions?.alpha??null,W=AX(W,K);return W=D(W,U??q),W??X}function eX(X,Z,Y,q){let $=q?.original?.$extensions?.mode?.[Y]??q?.original?.$value,U=P($);if(Y&&U){let W=Z.allTokens.find((z)=>z.path.join(".")===U);if(!W)return X;let K=C(W);if(P(K))return eX(K,Z,Y,W);if(W?.$extensions?.mode?.[Y])K=W.$extensions.mode[Y];if(K&&W?.$extensions?.alpha)K=AX(W.$value,W.$extensions.alpha);return D(K,W)??X}else if($)return D($,q);return X}function P(X){if(typeof X!=="string")return null;let Z=/{[^}]+}/g,Y=X.match(Z);if(Y?.length!==1)return null;return Y[0].slice(1,-1)}function $X(X){if(typeof X!=="string")return null;return[...X.matchAll(/\{([^}]+)\}/g)].map(([,Y])=>Y)??null}function UX(X){return X}function LX(X){return X}var XY=S(()=>{g()});var IZ={};iX(IZ,{wrapThemeValue:()=>OY,wrapFormatCSSFile:()=>QZ,typographyFileName:()=>$Z,tokensFileName:()=>ZZ,removeDirectoryContents:()=>LY,readConfigFile:()=>GX,namespaceUUID:()=>WZ,iconsFileName:()=>UZ,getTokenfileName:()=>GZ,getRelativePath:()=>BZ,getRelativeCSSPath:()=>JZ,getRawTokensFileName:()=>LZ,getProjectPaths:()=>d,getProjectModes:()=>_Y,getProjectMetaData:()=>T,getProjectFonts:()=>g0,getLazyTokensConfig:()=>YY,getLazyProjectPaths:()=>QY,getLazyProjectModes:()=>HX,getLazyProjectMetaData:()=>JX,getLazyProjectFonts:()=>v0,getLazyProjectData:()=>r,getLazyIcons:()=>gX,getJSDocHeader:()=>HZ,getIconDestinationFileName:()=>WX,getFiles:()=>yX,getFileHeader:()=>HY,getDistThemeFileDelimeter:()=>zZ,getDistConfigFile:()=>CX,getDestinationFileName:()=>AZ,getDefaultIconObjectPath:()=>KZ,getCSSDestinationFileName:()=>EZ,getBaseDirectory:()=>o,getBaseConfigFile:()=>QX,generatedFileHeader:()=>KX,filterTokensByType:()=>VX,createFileHeaderTitle:()=>_X,compileConfigFile:()=>EY,combineCSSFiles:()=>OZ,checkAndCreateDirectory:()=>t,breakpointFileName:()=>qZ});import{spawnSync as S0}from"child_process";import{existsSync as h,mkdirSync as P0,readFileSync as C0,unlinkSync as aY,writeFileSync as V0}from"fs";import{readdir as eY,rmdir as T0,unlink as y0}from"fs/promises";import{resolve as XZ,join as x,basename as YZ,normalize as nY,relative as tY,sep as ZY,dirname as oY}from"path";async function KZ(){return`${(await OX()).$metaData?.tokenNamespace||"tokens"}.icons`}async function EY(X){let Y=x(X,"designid.config.ts");if(h(x(X,"designid.config.mjs")))aY(x(X,"designid.config.mjs"));let q=x(X,"designid.config.js");if(h(q))aY(q);if(h(Y)){let $=S0("bun",["build",Y,"--outfile ./designid.config.mjs","--minify","--target","node","--packages","external","--no-bundle"],{stdio:"inherit",cwd:X,shell:!0});if($.status!==0)console.error("Failed to compile designid.config.mjs with bun."),process.exit($.status??1);if($.status===0)return new Promise((U)=>U(!0))}}async function LY(X){try{if(h(X)){let Z=await eY(X,{withFileTypes:!0});for(let Y of Z){let q=x(X,Y.name);if(Y.isDirectory())await LY(q),await T0(q);else await y0(q)}}}catch(Z){console.error(`Error removing contents of ${X}:`,Z)}}async function yX(X){let Z=await eY(X,{withFileTypes:!0}),Y=await Promise.all(Z.map((q)=>{let $=XZ(X,q.name);return q.isDirectory()?yX($):$}));return Array.prototype.concat(...Y)}async function WZ(X){let{dsNamespace:Z,tokenNamespace:Y}=await T();return`${(Z??Y).toUpperCase()}DesignSystem${X.charAt(0).toUpperCase()+X.slice(1)}Tokens`}function GZ(X,Z="d.ts",Y){if(!X)return`tokens.${Y}.config.${Z}`;return x(X,`tokens.${Y}.config.${Z}`)}function zZ(X,Z){return X.length>1?`.${Z}`:""}async function AZ(X="d.ts",Z){let{tokenNamespace:Y}=await T();if(Z)return`${Y}-design-system.${Z}.tokens.config.${X}`;return`${Y}-design-system.tokens.config.${X}`}async function WX(X="json"){let{tokenNamespace:Z}=await T();return`${Z}-design-system.tokens.svg${X==="d.ts"||X==="js"?".config":""}.${X}`}async function EZ(){let{tokenNamespace:X}=await T();return`${X}-design-system.tokens.css`}async function LZ(){let{tokenNamespace:X}=await T();return`${X}-design-system-raw.tokens.json`}async function HY(X){let{tokenNamespace:Z}=await T();return`${Z} | ${X}`}function HZ(X,Z){return`/** @type {import("./${X}").${Z}} */`}function _X(X){return`/* ${HY(X)} */`}function t(X){if(!h(X))P0(X,{recursive:!0})}async function GX(X,Z=!1){let Y=QX(),q;if(Y.endsWith(".json"))q=JSON.parse(C0(Y,"utf8").trim()??"{}");else if(Y.endsWith(".ts"))if(typeof globalThis.Bun<"u"){if(q=await import(Y),q.default)q=q.default}else{X=X??oY(Y)+"/";let U=CX(X);if(U&&(Z||!h(U)))await EY(X);if(q=await import(U),q.default)q=q.default}else{X=X??oY(Y)+"/";let $=CX(X);if($&&(Z||!h($)))await EY(X);if(q=await import($),q.default)q=q.default}return q}async function o(X=!1){let{baseDir:Z}=await d(),Y=process.cwd(),$=x(Y,Z),{buildDir:U,distDir:W}=await d();if(X)try{t(x($,U)),t(x($,W))}catch(K){console.error("Error creating directories:",K)}return $}function CX(X){return X?x(X,"designid.config.mjs"):x(process.cwd(),"designid.config.mjs")}function QX(){let X=process.argv.find((K)=>K.startsWith("--config=")),[,Z]=X?.split("=")??[];if(Z)return Z;let Y=process.cwd(),q=CX(Y),$=x(Y,"designid.config.ts"),U=h(q),W=h($);if(U)return q;else if(W)return $;throw console.error("Config file not found"),Error("Config file not found")}async function d(X=!1){let Z=QX(),q=(await GX(process.cwd(),X)).$paths;if(!q)throw console.error("Project paths not found"),Error("Project paths not found");return{configFile:Z,...q}}async function T(){let Z=(await GX(process.cwd())).$metaData;if(!Z)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!Z.colorspace)Z.colorspace="hex";if(!Z.fontNamespace)Z.fontNamespace=`${Z.dsNamespace}.font`;if(!Z?.tokens?.css?.mediaQuery?.match)Z={...Z??{},tokens:{...Z.tokens??{},css:{...Z.tokens?.css??{},mediaQuery:{...Z.tokens?.css?.mediaQuery??{},match:"[data-theme]"}}}};if(Z?.tokens?.css?.mediaQuery&&typeof Z.tokens.css.mediaQuery.separateThemeFiles!=="boolean")Z.tokens.css.mediaQuery.separateThemeFiles=!1;if(!Z.dsNamespace)Z.dsNamespace=Z.tokenNamespace;let Y=await KZ();return{...Z,icons:Z.icons??{objectPath:Y},dsNamespace:Z.dsNamespace}}async function _Y(){return(await GX(process.cwd())).$modes??{default:"light"}}async function OX(){if(!qY){let X=QX();qY=await GX(process.cwd()),_Z=X}return qY}async function HX(){if(!$Y)$Y=(await OX()).$modes??{default:"light"};return $Y}async function JX(){if(!UY){let Z=(await OX()).$metaData;if(!Z)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!Z.dsNamespace)Z.dsNamespace=Z.tokenNamespace;let q=`${Z.tokenNamespace||"tokens"}.icons`;UY={...Z,icons:Z.icons??{objectPath:q},dsNamespace:Z.dsNamespace}}return UY}async function QY(X=!1){if(!KY){let Y=(await OX()).$paths;if(!Y)throw console.error("Project paths not found"),Error("Project paths not found");KY={configFile:_Z,...Y}}return KY}async function r(){if(!WY){let{distDir:X,assets:Z,buildDir:Y}=await QY(!0),{fontNamespace:q,tokenNamespace:$,icons:U}=await JX(),W=await o(),K=process.cwd(),z=x(K,X,"css");WY={distDir:X,assets:Z,fontNamespace:q,__dirname:W,workspaceRoot:K,distCSSPath:z,buildDir:Y,tokenNamespace:$,icons:U}}return WY}async function gX(){if(!GY){let{icons:X}=await JX();GY=X}return GY}async function YY(){if(!zY){let{tokens:X}=await JX();zY=X}return zY}async function g0(){return(await GX(process.cwd())).$fonts??[]}async function v0(){if(!AY)AY=(await OX()).$fonts??[];return AY}async function OY(X){if(b(X))return":root";let Y=(await T())?.tokens?.css?.mediaQuery?.match??"[data-theme]";if(Y.startsWith("[")&&Y.endsWith("]"))return`${Y.replace("]",`="${X}"]`)}`;else if(Y.startsWith(".")||Y.startsWith("#"))return`${Y}${X}`;else return`${Y}${X}`}async function QZ(X,Z,Y,q,$,U={}){let W;if(b(Y))W=Z.allTokens;else W=X(Z,Y);let z=(await T())?.tokens?.css?.mediaQuery?.separateThemeFiles?"Theme: "+Y:U.headerTitle??"",G=`${_X(z)}
|
|
3
|
+
${KX}`,E=b(Y)?`:root {
|
|
4
4
|
`:`@media (123prefers-color-scheme: ${Y}) {
|
|
5
5
|
:root {
|
|
6
|
-
`,
|
|
6
|
+
`,A=`${G}
|
|
7
7
|
|
|
8
|
-
${
|
|
8
|
+
${E}`;if(W.forEach((L)=>{if(VX(L,U,$))return;let H=TX(L,Z,Y);if(U.transformValue)H=U.transformValue(H);H=LX(H),A+=`${!b(Y)?" ":" "}--${UX(L.name)}: ${H};
|
|
9
9
|
`}),Array.isArray(q)&&q.length>1){let L=`
|
|
10
|
-
`;for(let H of q){if(Y===H)continue;let _=await
|
|
11
|
-
`,X(Z,H).forEach((J)=>{if(VX(J,U,$))return;let O=TX(J,Z,H);if(U.transformValue)O=U.transformValue(O);O=LX(O),L+=`${!
|
|
12
|
-
`}),L+=`${!
|
|
10
|
+
`;for(let H of q){if(Y===H)continue;let _=await OY(H);L+=`${!b(Y)?" ":" "}&${_} {
|
|
11
|
+
`,X(Z,H).forEach((J)=>{if(VX(J,U,$))return;let O=TX(J,Z,H);if(U.transformValue)O=U.transformValue(O);O=LX(O),L+=`${!b(Y)?" ":" "}--${UX(J.name)}: ${O};
|
|
12
|
+
`}),L+=`${!b(Y)?" ":" "}}
|
|
13
13
|
|
|
14
|
-
`}
|
|
14
|
+
`}A+=L}return A+=!b(Y)?` }
|
|
15
15
|
`:`}
|
|
16
|
-
`,
|
|
17
|
-
`:"",
|
|
16
|
+
`,A+=!b(Y)?`}
|
|
17
|
+
`:"",A}function VX(X,Z,Y){let{namespace:q}=Z.filter??{};if(!X.$type)return!0;if(q?.length&&X.path){let $=X.path.join("."),U=q.some((K)=>$.startsWith(K)),W=Z.filter?.isInclusion!==void 0&&Z.filter.isInclusion;return U&&!W||!U&&W}if(Z.filter?.isInclusion!==void 0&&Z.filter.isInclusion===!1){if(X.$type&&!Y.includes(X.$type))return!0}else if(!X.$type||Y.includes(X.$type))return!0;return!1}async function OZ(){let X=await _Y(),{baseDir:Z,distDir:Y}=await d(),q=await yX(x(Z,Y,"css")),$=x(Z,Y,await EZ()),U=KX+`
|
|
18
18
|
|
|
19
|
-
`,W=[{name:UZ,order:100},{name:ZZ,order:200},{name:$Z,order:300},{name:qZ,order:400}];if(q=q.sort((K,z)=>{let G=(
|
|
20
|
-
`}}),!h(x(Z,Y)))t(x(Z,Y));
|
|
19
|
+
`,W=[{name:UZ,order:100},{name:ZZ,order:200},{name:$Z,order:300},{name:qZ,order:400}];if(q=q.sort((K,z)=>{let G=(E)=>{let A=YZ(E,".css"),L=W.find((H)=>A.includes(H.name));for(let H in X)if(A.includes(H)){let _=X[H]===X.default?1:2;return L?L.order+_:0}return L?L.order:0};return G(K)-G(z)}),q.forEach((K)=>{if(K.endsWith(".css")){let G=`@import url("${JZ(K,Z,Y)}");`;U+=G+`
|
|
20
|
+
`}}),!h(x(Z,Y)))t(x(Z,Y));V0($,U)}function JZ(X,Z,Y){let q=XZ(Z,Y);return X.startsWith(q)?X.slice(q.length+1):X}function BZ(X,Z,Y,q){let $=nY(X),U=YZ(nY(Z)),W=$.split(ZY),K=W.lastIndexOf(U);if(U===".")return tY(Y,q).split(ZY).join("/");else if(K===-1)throw Error(`Base directory '${U}' not found in '${$}'`);let z=x(...W.slice(0,K+1)),G=x(z,Y),E=x(z,q);return tY(G,E).split(ZY).join("/")}var ZZ="tokens",qZ="breakpoints",$Z="typography",UZ="icons",KX=`/*
|
|
21
21
|
* This file is automatically generated.
|
|
22
22
|
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
23
23
|
* Changes will be overwritten. Please update the source design tokens instead.
|
|
24
|
-
*/`,
|
|
25
|
-
`,Q.linkHref){let O=await(await fetch(Q.linkHref)).text();
|
|
26
|
-
`}else if(Q?.src&&W){let J=Q.directory??Q.family.toLowerCase().replace(/\s+/g,"-"),O=y(W,J,Q.src);try{if(!
|
|
24
|
+
*/`,qY=null,_Z=null,$Y=null,UY=null,KY=null,WY=null,GY=null,zY=null,AY=null;var BX=S(()=>{g()});function b(X){return X===JY}var JY="light";var wZ=S(()=>{BX()});async function BY(X){let Z=await gX();X=X.replace(/<\?xml[^>]*\?>\s*/,""),X=X.replace(/<!DOCTYPE [^>]*>\s*/,"");let Y=X.match(/<svg[^>]*>/),q=X.match(/viewBox="([\d\s.]+)"/),[$]=Y??[],U=$;if($&&U){let K=Z?.style?.fill||Z?.style?.stroke?.color,z=/id="[^"]*"/.test($);if(!U.includes("xmlns="))U=U.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"');if(!z&&K)U=U.replace("<svg",`<svg id="${K}"`);else if(z&&K)U=U.replace(/id="[^"]*"/,`id="${K}"`)}if(q&&$&&U){let K=q[1].split(" ").map(Number),z=K[2],G=K[3],E=Z?.size??24,A=z/G*E;X=X.replace(/height="[\d.]+px?"/,`height="${E}px"`),X=X.replace(/width="[\d.]+px?"/,`width="${A}px"`);let L=/width="[\d.]+(px)?"/.test($),H=/height="[\d.]+(px)?"/.test($);if(!L)U=U.replace("<svg",`<svg width="${A}px"`);else U=U.replace(/width="[\d.]+(px)?"/,`width="${A}px"`);if(!H)U=U.replace("<svg",`<svg height="${E}px"`);else U=U.replace(/height="[\d.]+(px)?"/,`height="${E}px"`);X=X.replace($,U)}if(!X?.match(/data-style="([^"]*)"/)&&Z?.style?.type)X=X.replace("<svg ",`<svg data-style="${Z.style.type}" `);if(Z?.style?.type)X=f0(X,Z.style);return X}function f0(X,Z){switch(Z.type){case"mono":if(X=X.replace(/stroke="[^"]*"/g,""),X=X.replace(/stroke-width="[^"]*"/g,""),X=X.replace(/stroke-linecap="[^"]*"/g,""),X=X.replace(/stroke-linejoin="[^"]*"/g,""),X=X.replace(/fill="none"/g,'fill="currentColor"'),Z.fill&&!X.includes("fill="))X=X.replace("<svg",'<svg fill="currentColor"');else if(Z.fill)X=X.replace(/fill="(?!currentColor)[^"]*"/g,'fill="currentColor"');break;case"stroke":if(Z.stroke){let{color:q,width:$,linecap:U,linejoin:W}=Z.stroke;if(q){if(X=X.replace(/stroke="[^"]*"/g,'stroke="currentColor"'),!X.includes("stroke="))X=X.replace("<svg",'<svg stroke="currentColor"')}if($!==void 0){let K=typeof $==="number"?`${$}`:$;if(X=X.replace(/stroke-width="[^"]*"/g,`stroke-width="${K}"`),!X.includes("stroke-width="))X=X.replace("<svg",`<svg stroke-width="${K}"`)}if(U){if(X=X.replace(/stroke-linecap="[^"]*"/g,`stroke-linecap="${U}"`),!X.includes("stroke-linecap="))X=X.replace("<svg",`<svg stroke-linecap="${U}"`)}if(W){if(X=X.replace(/stroke-linejoin="[^"]*"/g,`stroke-linejoin="${W}"`),!X.includes("stroke-linejoin="))X=X.replace("<svg",`<svg stroke-linejoin="${W}"`)}if(!X.includes("fill="))X=X.replace("<svg",'<svg fill="none"')}break;case"fill":if(X=X.replace(/stroke="[^"]*"/g,""),X=X.replace(/stroke-width="[^"]*"/g,""),Z.fill){if(X=X.replace(/fill="[^"]*"/g,'fill="currentColor"'),!X.includes("fill="))X=X.replace("<svg",'<svg fill="currentColor"')}break;case"animated":case"custom":break;default:break}return X}var RZ=S(()=>{g()});var MZ=S(()=>{BX();g()});import{copyFileSync as p0,existsSync as d0,mkdirSync as NZ,statSync as u0}from"fs";import{writeFile as k0}from"fs/promises";import{join as y,relative as c0}from"path";async function IY(X,Z){try{let{assets:Y,workspaceRoot:q,distDir:$,__dirname:U}=await r(),W=Y?.fonts?.sourceDir?y(U,Y.fonts.sourceDir):null,K=y("assets","fonts"),z=y(q,$),G=Y?.fonts?.distDir?y(z,Y.fonts.distDir.replace(/^\.\//,"")):y(z,K);if(!X||!W)return;let E="",A=Z&&Y?.fonts?.distDir?y(Z,Y.fonts.distDir.replace(/^\.\//,"")):G;for(let Q of X){if(!Q)continue;if(E+=`/**** ${Q.family} ${Q.style} ****/
|
|
25
|
+
`,Q.linkHref){let O=await(await fetch(Q.linkHref)).text();E+=`${O.replace(/\s+/g," ").replace(/:\s+/g,":")}
|
|
26
|
+
`}else if(Q?.src&&W){let J=Q.directory??Q.family.toLowerCase().replace(/\s+/g,"-"),O=y(W,J,Q.src);try{if(!d0(O)||!u0(O).isFile()){console.warn(`Font file not found: ${O}`);continue}}catch{console.warn(`Error accessing font file: ${O}`);continue}try{NZ(y(A,J),{recursive:!0}),p0(y(W,J,Q.src),y(A,J,Q.src))}catch(R){console.warn(`Error copying font file ${Q.src}:`,R instanceof Error?R.message:R);continue}let B;if(Y?.fonts?.cssImportPath)B=y(Y.fonts.cssImportPath,J,Q.src).replace(/\\/g,"/");else{let{distCSSPath:R}=await r(),I=Z?y(Z,"css"):R,w=c0(I,A);B=y(w,J,Q.src).replace(/\\/g,"/")}E+=`@font-face {
|
|
27
27
|
font-family: "${Q.family}";
|
|
28
28
|
font-style: ${Q.faceStyle};
|
|
29
29
|
font-weight: ${Q.weight};
|
|
30
30
|
src: url("${B}") format("${Q.format}");
|
|
31
31
|
}
|
|
32
|
-
`}}let{distCSSPath:L}=await r(),H=Z?y(Z,"css"):L,_=`${H}/fonts.css`;NZ(H,{recursive:!0}),await
|
|
33
|
-
${G.map((
|
|
34
|
-
`)}`;throw Error(A)}return K}function yZ(X,Z,Y){let q=[];if(Z.generateModes&&X.extensions?.mode){for(let[$,U]of Object.entries(X.extensions.mode))if(U!==void 0)q.push({...X,name:`${X.name}#${$}`,value:U,path:[...X.path,`#${$}`]})}if(Z.generateModes&&!X.extensions?.mode&&(Array.isArray(X.value)||typeof X.value==="object"&&X.value!==null)){let $=!1,U=!1,W=(K)=>{if(typeof K!=="object"||K===null)return!1;if(K.$extensions?.mode)return!0;return Object.values(K).some((z)=>{if(typeof z==="object"&&z!==null)return W(z);return!1})};if(Array.isArray(X.value))$=X.value.some((K)=>typeof K==="string"&&K.includes("{")||typeof K==="object"&&K!==null&&Object.values(K).some((z)=>typeof z==="string"&&z.includes("{"))),U=X.value.some((K)=>W(K));else $=Object.values(X.value).some((K)=>typeof K==="string"&&K.includes("{")),U=W(X.value);if($||U){if(["color","shadow","border","background","surface","composition"].includes(X.type)){let G;if(Array.isArray(X.value))G=X.value.map((A)=>{if(typeof A==="string"&&A.startsWith("{")&&A.endsWith("}")){let E=A.slice(1,-1);if(!E.includes("#dark")&&!E.includes("@dark"))return`{${E}#dark}`;return A}else if(typeof A==="object"&&A!==null){let E={};for(let[L,H]of Object.entries(A))if(typeof H==="string"&&H.startsWith("{")&&H.endsWith("}")){let _=H.slice(1,-1),Q=`${_}#dark`,J=Y?.get(_),O=Y?.has(Q)||J?.extensions?.mode?.dark!==void 0||J&&(Array.isArray(J.value)||typeof J.value==="object"&&J.value!==null);if(!_.includes("#dark")&&!_.includes("@dark")&&O)E[L]=`{${Q}}`;else E[L]=H}else E[L]=H;return E}return A});else if(typeof X.value==="object"&&X.value!==null){G={};let A=(E)=>{if(typeof E==="string"){if(E.startsWith("{")&&E.endsWith("}")){let L=E.slice(1,-1),H=`${L}#dark`,_=(J,O=new Set)=>{if(O.has(J))return!1;O.add(J);let B=Y?.get(J);if(!B){let R=J.match(/^(.+)@([^@]+)$/);if(R){let[,I,w]=R,M=Y?.get(I);if(M){if(M.extensions?.mode?.dark!==void 0)return!0;if(M.extensions?.generators)return!0;return _(I,O)}}return!1}if(B.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${J}#dark`))return!0;if(typeof B.value==="string"&&B.value.startsWith("{")&&B.value.endsWith("}")){let R=B.value.slice(1,-1);return _(R,O)}if(Array.isArray(B.value)||typeof B.value==="object"&&B.value!==null){let R=(I)=>{if(typeof I!=="object"||I===null)return!1;if(I.$extensions?.mode)return!0;return Object.values(I).some((w)=>{if(typeof w==="object"&&w!==null)return R(w);return!1})};if(Array.isArray(B.value))return B.value.some((I)=>typeof I==="string"&&I.includes("{")&&_(I.slice(1,-1),new Set(O))||typeof I==="object"&&I!==null&&(Object.values(I).some((w)=>typeof w==="string"&&w.includes("{")&&_(w.slice(1,-1),new Set(O)))||R(I)));else if(typeof B.value==="object")return Object.values(B.value).some((I)=>typeof I==="string"&&I.includes("{")&&_(I.slice(1,-1),new Set(O)))||R(B.value)}return!1},Q=_(L);if(!L.includes("#dark")&&!L.includes("@dark")&&Q)return`{${H}}`}return E}if(typeof E==="object"&&E!==null){if(E.$extensions?.mode?.dark)return E.$extensions.mode.dark;let L={};for(let[H,_]of Object.entries(E))L[H]=A(_);return L}return E};for(let[E,L]of Object.entries(X.value))G[E]=A(L)}q.push({...X,name:`${X.name}#dark`,value:G,path:[...X.path,"#dark"],extensions:{...X.extensions,autoGenerated:!0}})}}}if(Z.generateModes&&!X.extensions?.mode&&typeof X.value==="string"&&X.value.startsWith("{")&&X.value.endsWith("}")){let $=X.value.slice(1,-1),U=(A,E=new Set)=>{if(E.has(A))return!1;E.add(A);let L=Y?.get(A);if(!L){let H=A.match(/^(.+)@([^@]+)$/);if(H){let[,_,Q]=H,J=Y?.get(_);if(J){if(J.extensions?.mode?.dark!==void 0)return!0;if(J.extensions?.generators)return!0;return U(_,E)}}return!1}if(L.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${A}#dark`))return!0;if(typeof L.value==="string"&&L.value.startsWith("{")&&L.value.endsWith("}")){let H=L.value.slice(1,-1);return U(H,E)}if(Array.isArray(L.value)||typeof L.value==="object"&&L.value!==null){let H=(_)=>{if(typeof _!=="object"||_===null)return!1;if(_.$extensions?.mode)return!0;return Object.values(_).some((Q)=>{if(typeof Q==="object"&&Q!==null)return H(Q);return!1})};if(Array.isArray(L.value))return L.value.some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(E))||typeof _==="object"&&_!==null&&(Object.values(_).some((Q)=>typeof Q==="string"&&Q.includes("{")&&U(Q.slice(1,-1),new Set(E)))||H(_)));else if(typeof L.value==="object")return Object.values(L.value).some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(E)))||H(L.value)}return!1},W=U($);if(["color","shadow","border","background","surface","composition"].includes(X.type)&&W&&W&&!$.includes("#dark")&&!$.includes("@dark")){let A=`{${$}#dark}`;q.push({...X,name:`${X.name}#dark`,value:A,path:[...X.path,"#dark"],extensions:{...X.extensions,autoGenerated:!0}})}}if(Z.generateDerivedTokens&&X.extensions?.generators)for(let $ of X.extensions.generators)for(let[U,W]of Object.entries($.value)){let K=bZ(X.name,U),{generators:z,...G}=X.extensions;q.push({...X,name:K,value:X.value,path:[...X.path,U],extensions:{...G,generator:{type:$.type,value:W}}})}if(Z.generateBreakpointTokens&&X.extensions?.breakpoints)for(let[$,U]of Object.entries(X.extensions.breakpoints)){let W=`${X.name}@${$.replace(/[^a-zA-Z0-9]/g,"_")}`,K=U.$value||U.value;if(K&&typeof K==="object"&&"$value"in K)K=K.$value;else if(!K&&typeof U==="object"){let{...A}=U;if(Object.keys(A).length>0)K=A}let z=U.$extensions||U.$extensions,G=U.$type;if(!G&&U.value&&typeof U.value==="object")G=U.value.$type;q.push({...X,name:W,value:K,path:[...X.path,`@${$}`],type:G||X.type,extensions:{mediaQuery:$,...z?{mode:z.mode||z.$mode,generators:z.generators||z.$generators,...Object.fromEntries(Object.entries(z).filter(([A])=>!["mode","$mode","generators","$generators"].includes(A)))}:{}}})}return q}function e0(X,Z){let Y=e(X.value,Z),q=X.type;if(typeof X.value==="string"&&IX(X.value)){let U=X.value.slice(1,-1),W=Z.tokens.get(U);if(W){if(["border","shadow","typography","composition"].includes(W.type))q=W.type;else if(typeof W.value==="string"&&wX(W.value)){let K=vX(W.value),z=new Set;for(let G of K)if(G.type==="reference"&&G.ref&&typeof G.ref==="string"){let A=G.ref.slice(1,-1),E=Z.tokens.get(A);if(E&&["border","shadow","typography","composition"].includes(E.type))z.add(E.type)}if(z.size===1)q=Array.from(z)[0]}}}if(typeof X.value==="string"&&wX(X.value)){let U=vX(X.value),W=new Set;for(let K of U)if(K.type==="reference"&&K.ref&&typeof K.ref==="string"){let z=K.ref.slice(1,-1),G=Z.tokens.get(z);if(G&&["border","shadow","typography","composition"].includes(G.type))W.add(G.type)}if(W.size===1)q=Array.from(W)[0]}if(typeof Y==="object"&&Y!==null&&["border","shadow","typography","composition"].includes(q))Y=s(Y,Z);if(X.extensions?.generator&&typeof X.extensions.generator==="object"&&"type"in X.extensions.generator&&"value"in X.extensions.generator)Y=fX(X.value,X.extensions.generator.type,X.extensions.generator.value,Z);let $=X1(X.name,Z.options);if(q==="color"&&typeof Y==="string"&&p(Y))Y=b(Y,X);if(typeof Y==="string"&&u(Y))Y=RX(Y);return{...X,type:q,value:Y,cssVar:$}}function s(X,Z){if(typeof X==="string"){if(IX(X))return FY(X,Z);else if(wX(X))return hZ(X,Z)}if(Array.isArray(X))return X.map((Y)=>s(Y,Z));if(typeof X==="object"&&X!==null){if("$value"in X&&typeof X.$value==="string")return s(X.$value,Z);if("value"in X&&typeof X.value==="string"&&"$type"in X){if(Z.mode&&X.$extensions?.mode?.[Z.mode])return s(X.$extensions.mode[Z.mode],Z);return s(X.value,Z)}if("value"in X&&typeof X.value==="object"&&"$type"in X){let q=X.value,$=X.$extensions?.delimiter?.character||" ";if(X.$type==="composition"&&q&&typeof q==="object")return Object.values(q).map((W)=>s(W,Z)).join($);return s(X.value,Z)}let Y={};for(let[q,$]of Object.entries(X))Y[q]=s($,Z);return Y}return X}function e(X,Z){if(typeof X==="string"){if(wX(X))return hZ(X,Z);else if(IX(X))return FY(X,Z)}else if(typeof X==="object"&&X!==null&&"$ref"in X)return fZ(X,Z);return X}function FY(X,Z){let Y=X.slice(1,-1),q=Z.tokens.get(Y),$=Z.options.modes||[];if(!q){if($.length>0){for(let K of $)if(Y.endsWith(`@${K}`)){let z=Y.slice(0,-K.length-1)+`#${K}`;if(q=Z.tokens.get(z),q)return wY(q,Z);break}}let W=Y.match(/#([^#@]+)$/);if(W){let K=Y.substring(0,W.index),z=W[1];if(q=Z.tokens.get(K),q){if(q.extensions?.mode?.[z]){let G=q.extensions.mode[z],A=e(G,{...Z,mode:z});if(q.extensions?.generator&&typeof q.extensions.generator==="object"&&"type"in q.extensions.generator&&"value"in q.extensions.generator)A=fX(A,q.extensions.generator.type,q.extensions.generator.value,Z);if(q.type==="color"&&typeof A==="string"&&p(A))A=b(A,q);if(typeof A==="string"&&u(A))A=RX(A);return A}}}if($.length>0)for(let K of $){let z=new RegExp(`(@[^@]+)@${K}$`);if(z.test(Y)){let G=Y.replace(z,`$1#${K}`);if(q=Z.tokens.get(G),!q){let A=G.match(/#([^#@]+)$/);if(A){let E=G.substring(0,A.index),L=A[1];if(q=Z.tokens.get(E),q&&q.extensions?.mode?.[L]){let H=q.extensions.mode[L],_=e(H,{...Z,mode:L});if(q.extensions?.generator&&typeof q.extensions.generator==="object"&&"type"in q.extensions.generator&&"value"in q.extensions.generator)_=fX(_,q.extensions.generator.type,q.extensions.generator.value,Z);if(q.type==="color"&&typeof _==="string"&&p(_))_=b(_,q);if(typeof _==="string"&&u(_))_=RX(_);return _}}}else return wY(q,Z);break}}}if(!q)return console.warn(`Token reference not found: ${X}`),Z.brokenReferences.push(X),X;return wY(q,Z)}function wY(X,Z){let Y;if(X.extensions?.generator&&typeof X.extensions.generator==="object"&&"type"in X.extensions.generator&&"value"in X.extensions.generator)Y=fX(X.value,X.extensions.generator.type,X.extensions.generator.value,Z);else if(Z.mode&&X.extensions?.mode?.[Z.mode])Y=e(X.extensions.mode[Z.mode],Z);else Y=e(X.value,Z);if(X.type==="color"&&typeof Y==="string"&&p(Y))Y=b(Y,X);if(typeof Y==="string"&&u(Y))Y=RX(Y);return Y}function fZ(X,Z){let q=X.$ref.slice(2).replace(/\//g,"."),$=Z.tokens.get(q);if(!$)return console.warn(`JSON Pointer reference not found: ${X.$ref}`),Z.brokenReferences.push(X.$ref),X.$ref;return e($.value,Z)}function hZ(X,Z){let Y=vX(X),q=Y.some((W)=>W.value.includes(",")),$=!0,U=[];for(let W of Y){let K;if(W.type==="reference"&&W.ref){if(typeof W.ref==="string"&&IX(W.ref)){K=FY(W.ref,Z);let z=W.ref.slice(1,-1),G=Z.tokens.get(z);if(!G||!["border","shadow","typography","composition"].includes(G.type))$=!1}else if(typeof W.ref==="object"&&"$ref"in W.ref)K=fZ(W.ref,Z)}else if(K=W.value,W.value.trim()&&W.value.trim()!==",")$=!1;U.push(K)}if(q&&$)return U.filter((W)=>typeof W==="object"&&W!==null&&typeof W!=="string");return U.map((W)=>String(W)).join("")}function fX(X,Z,Y,q){let $=e(X,q);switch(Z){case"alpha":if(typeof $==="string")return Y1($,Number(Y)/100);break;case"scale":if(typeof $==="string"&&$.match(/[\d.]+/))return Z1($,Number(Y));break;case"hue":if(typeof $==="string")return q1($,Number(Y));break;default:return console.warn(`Unknown generator type: ${Z}`),$}return $}function X1(X,Z,Y){let q=X.replace(/\./g,"-");q=q.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),q=q.replace(/@[^@#]*(?:screen|width|height|min|max|orientation).*$/i,""),q=q.replace(/#[^#]*$/,""),q=q.replace(/-@/g,"-").replace(/@/g,"-");let $=q,U=!0,W=Z.prefix||"";if(Z.transformName){if($=Z.transformName(q),$=$.replace(/-+$/,""),$!==q)U=!1}let K=U&&W?`${W}-${$}`:$,z=Y?`-${Y}`:"";return`--${K}${z}`.replace(/[^a-zA-Z0-9-_]/g,"-")}function Y1(X,Z){try{if(!p(X))return X;let Y=new gZ(X);return Y.alpha=Z,b(Y)}catch(Y){return console.warn(`Failed to apply alpha to color "${X}": ${Y}`),X}}function Z1(X,Z){let Y=X.match(/([\d.]+)(\w+)/);if(Y){let[,q,$]=Y;return`${parseFloat(q)*Z}${$}`}return X}function q1(X,Z){try{if(!p(X))return X;let q=new gZ(X).to("oklch");return q.h=(q.h+Z)%360,b(q)}catch(Y){return console.warn(`Failed to shift hue for color "${X}": ${Y}`),X}}var xY=S(()=>{PZ();EX()});function jY(X){if(X.type==="typography"||X.type==="fontWeight"||X.type==="fontFamily")return!0;if(X.type==="dimension"&&X.name.includes("typography"))return!0;if(X.name.includes("typography")||X.name.includes("font"))return!0;return!1}function i(X,Z,Y){if(Y){if(X===Z)return":host";return`:host([data-theme="${X}"])`}if(X===Z)return":root";return`[data-theme="${X}"]`}function hX(X,Z={}){let{rootSelector:Y=":root",separateThemeFiles:q=!1,generateMediaQueries:$=!1,customHeader:U,modes:W=["light","dark"]}=Z;if(q)return U1(X,Z);let K=new Map,z=new Map;for(let B of W)K.set(B,[]);let G=W.join("|"),A=new RegExp(`#(${G})$`);for(let B of X){if(typeof B.value==="string"&&u(B.value))continue;if(jY(B))continue;let R=` ${B.cssVar}: ${m(B.value,B.type)};`;if($&&B.name.includes("@media")){let w=pX(B);if(w){if(!z.has(w))z.set(w,[]);z.get(w).push(R);continue}}let I=B.name.match(A);if(I){let w=I[1];if(!K.has(w))K.set(w,[]);K.get(w).push(R)}else{let w=W[0]||"light";K.get(w).push(R)}}let E="";if(U)E+=`${U}
|
|
32
|
+
`}}let{distCSSPath:L}=await r(),H=Z?y(Z,"css"):L,_=`${H}/fonts.css`;NZ(H,{recursive:!0}),await k0(_,E,{flag:"w",encoding:"utf-8"})}catch(Y){console.error("Error appending typography tokens:",Y)}}var wY=S(()=>{g()});function IX(X){if(typeof X!=="string"||!X.startsWith("{")||!X.endsWith("}"))return!1;let Z=X.slice(1,-1);return!Z.includes("{")&&!Z.includes("}")&&Z.trim()!==""}function wX(X){if(typeof X!=="string")return!1;let Z=/\{[^}]+\}/g,Y=X.match(Z);return!!(Y&&Y.length>0&&X.length>Y.join("").length)}function vX(X){let Z=[],Y=/\{[^}]+\}/g,q=0,$;while(($=Y.exec(X))!==null){if($.index>q){let W=X.slice(q,$.index);if(W)Z.push({type:"literal",value:W})}let U=$[0];if(U.startsWith("{#/"))Z.push({type:"reference",value:U,ref:{$ref:U.slice(2,-1)}});else Z.push({type:"reference",value:U,ref:U});q=$.index+$[0].length}if(q<X.length){let U=X.slice(q);if(U)Z.push({type:"literal",value:U})}return Z}function FZ(X){return!!X.$extensions?.$mode}function xZ(X){return!!(X.$extensions?.$generators&&Array.isArray(X.$extensions.$generators))}function jZ(X){return!!(X.$extensions?.$breakpoints&&typeof X.$extensions.$breakpoints==="object")}function DZ(X,Z){return`${X}${Z}`}function bZ(X){return typeof X==="object"&&X!==null&&"$value"in X}function SZ(X){return typeof X==="object"&&X!==null&&!("$value"in X)}var PZ=()=>{};function CZ(X){if(typeof X!=="string")return!1;let Z=X.trim();return Z.startsWith("<svg")&&Z.includes("</svg>")}function VZ(X){if(typeof X!=="string")return!1;return X.startsWith("data:image/png;base64,")||X.startsWith("iVBORw0KGgo")}function TZ(X){if(typeof X!=="string")return!1;return X.startsWith("data:image/jpeg;base64,")||X.startsWith("data:image/jpg;base64,")||X.startsWith("/9j/")}function r0(X){let Z=X.trim();return Z=Z.replace(/\s+/g," ").replace(/>\s+</g,"><").trim(),`data:image/svg+xml;base64,${Buffer.from(Z,"utf-8").toString("base64")}`}function s0(X){if(X.startsWith("data:image/png;base64,"))return X;return`data:image/png;base64,${X}`}function i0(X){if(X.startsWith("data:image/jpeg;base64,")||X.startsWith("data:image/jpg;base64,"))return X;return`data:image/jpeg;base64,${X}`}function RX(X){if(!X||typeof X!=="string")return X;if(X.startsWith("data:"))return X;if(CZ(X))return r0(X);else if(VZ(X))return s0(X);else if(TZ(X))return i0(X);return X}function a0(X){if(typeof X!=="string")return!1;return X.startsWith("data:image/svg+xml;")||X.startsWith("data:image/png;")||X.startsWith("data:image/jpeg;")||X.startsWith("data:image/jpg;")||X.startsWith("data:image/gif;")||X.startsWith("data:image/webp;")}function u(X){return CZ(X)||VZ(X)||TZ(X)||a0(X)}import{readFileSync as n0,readdirSync as t0,statSync as o0}from"fs";import{join as e0}from"path";import gZ from"colorjs.io";function MY(X){let Z={};function Y(q){let $=t0(q);for(let U of $){let W=e0(q,U);if(o0(W).isDirectory())Y(W);else if(U.endsWith(".tokens.json"))try{let z=n0(W,"utf-8");if(!z.trim())continue;let G=JSON.parse(z);vZ(Z,G)}catch(z){console.warn(`Failed to load token file: ${W}`,z)}}}return Y(X),Z}function vZ(X,Z){for(let Y in Z)if(Z[Y]&&typeof Z[Y]==="object"&&!Array.isArray(Z[Y])){if(!X[Y])X[Y]={};vZ(X[Y],Z[Y])}else X[Y]=Z[Y]}function NY(X,Z={}){let Y=[];function q($,U=[]){for(let[W,K]of Object.entries($)){if(W.startsWith("$"))continue;let z=[...U,W],G=z.join(".");if(bZ(K)){let E={path:z,name:G,type:K.$type,value:K.$value,description:K.$description,extensions:K.$extensions?{mode:FZ(K)?K.$extensions.$mode:K.$extensions.mode?K.$extensions.mode:void 0,generators:xZ(K)?K.$extensions.$generators:K.$extensions.generators?K.$extensions.generators:void 0,breakpoints:jZ(K)?K.$extensions.$breakpoints:K.$extensions.breakpoint?K.$extensions.breakpoint:void 0,...Object.fromEntries(Object.entries(K.$extensions).filter(([A])=>!["$mode","$generators","$breakpoints","mode","generators","breakpoint"].includes(A)))}:void 0,original:K};if(!Z.namespace||G.startsWith(Z.namespace))Y.push(E)}else if(SZ(K))q(K,z)}}return q(X),Y}function FY(X,Z={}){let Y=[...X],q=new Map(X.map((G)=>[G.name,G]));if(Z.generateModes||Z.generateDerivedTokens||Z.generateBreakpointTokens)for(let G of X){let E=yZ(G,Z,q);if(Y.push(...E),Z.generateModes){for(let A of E)if(A.extensions?.mode&&!A.name.includes("#")){let L=yZ(A,Z,q);Y.push(...L)}}}let $=Z.modes||[],U=$.length>0?$[0]:void 0,W={tokens:new Map(Y.map((G)=>[G.name,G])),mode:Z.generateModes?U:void 0,options:Z,brokenReferences:[]},K=[];for(let G of Y){let E=void 0;for(let H of $)if(G.name.endsWith(`#${H}`)){E=H;break}if(!E&&Z.generateModes)E=U;let A={...W,mode:E},L=X1(G,A);K.push(L)}if(Z.failOnBrokenReferences!==!1&&W.brokenReferences.length>0){let G=[...new Set(W.brokenReferences)],E=`Token reference${G.length>1?"s":""} not found:
|
|
33
|
+
${G.map((A)=>` - ${A}`).join(`
|
|
34
|
+
`)}`;throw Error(E)}return K}function yZ(X,Z,Y){let q=[];if(Z.generateModes&&X.extensions?.mode){for(let[$,U]of Object.entries(X.extensions.mode))if(U!==void 0)q.push({...X,name:`${X.name}#${$}`,value:U,path:[...X.path,`#${$}`]})}if(Z.generateModes&&!X.extensions?.mode&&(Array.isArray(X.value)||typeof X.value==="object"&&X.value!==null)){let $=!1,U=!1,W=(K)=>{if(typeof K!=="object"||K===null)return!1;if(K.$extensions?.mode)return!0;return Object.values(K).some((z)=>{if(typeof z==="object"&&z!==null)return W(z);return!1})};if(Array.isArray(X.value))$=X.value.some((K)=>typeof K==="string"&&K.includes("{")||typeof K==="object"&&K!==null&&Object.values(K).some((z)=>typeof z==="string"&&z.includes("{"))),U=X.value.some((K)=>W(K));else $=Object.values(X.value).some((K)=>typeof K==="string"&&K.includes("{")),U=W(X.value);if($||U){if(["color","shadow","border","background","surface","composition"].includes(X.type)){let G;if(Array.isArray(X.value))G=X.value.map((E)=>{if(typeof E==="string"&&E.startsWith("{")&&E.endsWith("}")){let A=E.slice(1,-1);if(!A.includes("#dark")&&!A.includes("@dark"))return`{${A}#dark}`;return E}else if(typeof E==="object"&&E!==null){let A={};for(let[L,H]of Object.entries(E))if(typeof H==="string"&&H.startsWith("{")&&H.endsWith("}")){let _=H.slice(1,-1),Q=`${_}#dark`,J=Y?.get(_),O=Y?.has(Q)||J?.extensions?.mode?.dark!==void 0||J&&(Array.isArray(J.value)||typeof J.value==="object"&&J.value!==null);if(!_.includes("#dark")&&!_.includes("@dark")&&O)A[L]=`{${Q}}`;else A[L]=H}else A[L]=H;return A}return E});else if(typeof X.value==="object"&&X.value!==null){G={};let E=(A)=>{if(typeof A==="string"){if(A.startsWith("{")&&A.endsWith("}")){let L=A.slice(1,-1),H=`${L}#dark`,_=(J,O=new Set)=>{if(O.has(J))return!1;O.add(J);let B=Y?.get(J);if(!B){let R=J.match(/^(.+)@([^@]+)$/);if(R){let[,I,w]=R,M=Y?.get(I);if(M){if(M.extensions?.mode?.dark!==void 0)return!0;if(M.extensions?.generators)return!0;return _(I,O)}}return!1}if(B.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${J}#dark`))return!0;if(typeof B.value==="string"&&B.value.startsWith("{")&&B.value.endsWith("}")){let R=B.value.slice(1,-1);return _(R,O)}if(Array.isArray(B.value)||typeof B.value==="object"&&B.value!==null){let R=(I)=>{if(typeof I!=="object"||I===null)return!1;if(I.$extensions?.mode)return!0;return Object.values(I).some((w)=>{if(typeof w==="object"&&w!==null)return R(w);return!1})};if(Array.isArray(B.value))return B.value.some((I)=>typeof I==="string"&&I.includes("{")&&_(I.slice(1,-1),new Set(O))||typeof I==="object"&&I!==null&&(Object.values(I).some((w)=>typeof w==="string"&&w.includes("{")&&_(w.slice(1,-1),new Set(O)))||R(I)));else if(typeof B.value==="object")return Object.values(B.value).some((I)=>typeof I==="string"&&I.includes("{")&&_(I.slice(1,-1),new Set(O)))||R(B.value)}return!1},Q=_(L);if(!L.includes("#dark")&&!L.includes("@dark")&&Q)return`{${H}}`}return A}if(typeof A==="object"&&A!==null){if(A.$extensions?.mode?.dark)return A.$extensions.mode.dark;let L={};for(let[H,_]of Object.entries(A))L[H]=E(_);return L}return A};for(let[A,L]of Object.entries(X.value))G[A]=E(L)}q.push({...X,name:`${X.name}#dark`,value:G,path:[...X.path,"#dark"],extensions:{...X.extensions,autoGenerated:!0}})}}}if(Z.generateModes&&!X.extensions?.mode&&typeof X.value==="string"&&X.value.startsWith("{")&&X.value.endsWith("}")){let $=X.value.slice(1,-1),U=(E,A=new Set)=>{if(A.has(E))return!1;A.add(E);let L=Y?.get(E);if(!L){let H=E.match(/^(.+)@([^@]+)$/);if(H){let[,_,Q]=H,J=Y?.get(_);if(J){if(J.extensions?.mode?.dark!==void 0)return!0;if(J.extensions?.generators)return!0;return U(_,A)}}return!1}if(L.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${E}#dark`))return!0;if(typeof L.value==="string"&&L.value.startsWith("{")&&L.value.endsWith("}")){let H=L.value.slice(1,-1);return U(H,A)}if(Array.isArray(L.value)||typeof L.value==="object"&&L.value!==null){let H=(_)=>{if(typeof _!=="object"||_===null)return!1;if(_.$extensions?.mode)return!0;return Object.values(_).some((Q)=>{if(typeof Q==="object"&&Q!==null)return H(Q);return!1})};if(Array.isArray(L.value))return L.value.some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(A))||typeof _==="object"&&_!==null&&(Object.values(_).some((Q)=>typeof Q==="string"&&Q.includes("{")&&U(Q.slice(1,-1),new Set(A)))||H(_)));else if(typeof L.value==="object")return Object.values(L.value).some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(A)))||H(L.value)}return!1},W=U($);if(["color","shadow","border","background","surface","composition"].includes(X.type)&&W&&W&&!$.includes("#dark")&&!$.includes("@dark")){let E=`{${$}#dark}`;q.push({...X,name:`${X.name}#dark`,value:E,path:[...X.path,"#dark"],extensions:{...X.extensions,autoGenerated:!0}})}}if(Z.generateDerivedTokens&&X.extensions?.generators)for(let $ of X.extensions.generators)for(let[U,W]of Object.entries($.value)){let K=DZ(X.name,U),{generators:z,...G}=X.extensions;q.push({...X,name:K,value:X.value,path:[...X.path,U],extensions:{...G,generator:{type:$.type,value:W}}})}if(Z.generateBreakpointTokens&&X.extensions?.breakpoints)for(let[$,U]of Object.entries(X.extensions.breakpoints)){let W=`${X.name}@${$.replace(/[^a-zA-Z0-9]/g,"_")}`,K=U.$value||U.value;if(K&&typeof K==="object"&&"$value"in K)K=K.$value;else if(!K&&typeof U==="object"){let{...E}=U;if(Object.keys(E).length>0)K=E}let z=U.$extensions||U.$extensions,G=U.$type;if(!G&&U.value&&typeof U.value==="object")G=U.value.$type;q.push({...X,name:W,value:K,path:[...X.path,`@${$}`],type:G||X.type,extensions:{mediaQuery:$,...z?{mode:z.mode||z.$mode,generators:z.generators||z.$generators,...Object.fromEntries(Object.entries(z).filter(([E])=>!["mode","$mode","generators","$generators"].includes(E)))}:{}}})}return q}function X1(X,Z){let Y=e(X.value,Z),q=X.type;if(typeof X.value==="string"&&IX(X.value)){let U=X.value.slice(1,-1),W=Z.tokens.get(U);if(W){if(["border","shadow","typography","composition"].includes(W.type))q=W.type;else if(typeof W.value==="string"&&wX(W.value)){let K=vX(W.value),z=new Set;for(let G of K)if(G.type==="reference"&&G.ref&&typeof G.ref==="string"){let E=G.ref.slice(1,-1),A=Z.tokens.get(E);if(A&&["border","shadow","typography","composition"].includes(A.type))z.add(A.type)}if(z.size===1)q=Array.from(z)[0]}}}if(typeof X.value==="string"&&wX(X.value)){let U=vX(X.value),W=new Set;for(let K of U)if(K.type==="reference"&&K.ref&&typeof K.ref==="string"){let z=K.ref.slice(1,-1),G=Z.tokens.get(z);if(G&&["border","shadow","typography","composition"].includes(G.type))W.add(G.type)}if(W.size===1)q=Array.from(W)[0]}if(typeof Y==="object"&&Y!==null&&["border","shadow","typography","composition"].includes(q))Y=s(Y,Z);if(X.extensions?.generator&&typeof X.extensions.generator==="object"&&"type"in X.extensions.generator&&"value"in X.extensions.generator)Y=fX(X.value,X.extensions.generator.type,X.extensions.generator.value,Z);let $=Y1(X.name,Z.options);if(q==="color"&&typeof Y==="string"&&p(Y))Y=D(Y,X);if(typeof Y==="string"&&u(Y))Y=RX(Y);return{...X,type:q,value:Y,cssVar:$}}function s(X,Z){if(typeof X==="string"){if(IX(X))return xY(X,Z);else if(wX(X))return hZ(X,Z)}if(Array.isArray(X))return X.map((Y)=>s(Y,Z));if(typeof X==="object"&&X!==null){if("$value"in X&&typeof X.$value==="string")return s(X.$value,Z);if("value"in X&&typeof X.value==="string"&&"$type"in X){if(Z.mode&&X.$extensions?.mode?.[Z.mode])return s(X.$extensions.mode[Z.mode],Z);return s(X.value,Z)}if("value"in X&&typeof X.value==="object"&&"$type"in X){let q=X.value,$=X.$extensions?.delimiter?.character||" ";if(X.$type==="composition"&&q&&typeof q==="object")return Object.values(q).map((W)=>s(W,Z)).join($);return s(X.value,Z)}let Y={};for(let[q,$]of Object.entries(X))Y[q]=s($,Z);return Y}return X}function e(X,Z){if(typeof X==="string"){if(wX(X))return hZ(X,Z);else if(IX(X))return xY(X,Z)}else if(typeof X==="object"&&X!==null&&"$ref"in X)return fZ(X,Z);return X}function xY(X,Z){let Y=X.slice(1,-1),q=Z.tokens.get(Y),$=Z.options.modes||[];if(!q){if($.length>0){for(let K of $)if(Y.endsWith(`@${K}`)){let z=Y.slice(0,-K.length-1)+`#${K}`;if(q=Z.tokens.get(z),q)return RY(q,Z);break}}let W=Y.match(/#([^#@]+)$/);if(W){let K=Y.substring(0,W.index),z=W[1];if(q=Z.tokens.get(K),q){if(q.extensions?.mode?.[z]){let G=q.extensions.mode[z],E=e(G,{...Z,mode:z});if(q.extensions?.generator&&typeof q.extensions.generator==="object"&&"type"in q.extensions.generator&&"value"in q.extensions.generator)E=fX(E,q.extensions.generator.type,q.extensions.generator.value,Z);if(q.type==="color"&&typeof E==="string"&&p(E))E=D(E,q);if(typeof E==="string"&&u(E))E=RX(E);return E}}}if($.length>0)for(let K of $){let z=new RegExp(`(@[^@]+)@${K}$`);if(z.test(Y)){let G=Y.replace(z,`$1#${K}`);if(q=Z.tokens.get(G),!q){let E=G.match(/#([^#@]+)$/);if(E){let A=G.substring(0,E.index),L=E[1];if(q=Z.tokens.get(A),q&&q.extensions?.mode?.[L]){let H=q.extensions.mode[L],_=e(H,{...Z,mode:L});if(q.extensions?.generator&&typeof q.extensions.generator==="object"&&"type"in q.extensions.generator&&"value"in q.extensions.generator)_=fX(_,q.extensions.generator.type,q.extensions.generator.value,Z);if(q.type==="color"&&typeof _==="string"&&p(_))_=D(_,q);if(typeof _==="string"&&u(_))_=RX(_);return _}}}else return RY(q,Z);break}}}if(!q)return console.warn(`Token reference not found: ${X}`),Z.brokenReferences.push(X),X;return RY(q,Z)}function RY(X,Z){let Y;if(X.extensions?.generator&&typeof X.extensions.generator==="object"&&"type"in X.extensions.generator&&"value"in X.extensions.generator)Y=fX(X.value,X.extensions.generator.type,X.extensions.generator.value,Z);else if(Z.mode&&X.extensions?.mode?.[Z.mode])Y=e(X.extensions.mode[Z.mode],Z);else Y=e(X.value,Z);if(X.type==="color"&&typeof Y==="string"&&p(Y))Y=D(Y,X);if(typeof Y==="string"&&u(Y))Y=RX(Y);return Y}function fZ(X,Z){let q=X.$ref.slice(2).replace(/\//g,"."),$=Z.tokens.get(q);if(!$)return console.warn(`JSON Pointer reference not found: ${X.$ref}`),Z.brokenReferences.push(X.$ref),X.$ref;return e($.value,Z)}function hZ(X,Z){let Y=vX(X),q=Y.some((W)=>W.value.includes(",")),$=!0,U=[];for(let W of Y){let K;if(W.type==="reference"&&W.ref){if(typeof W.ref==="string"&&IX(W.ref)){K=xY(W.ref,Z);let z=W.ref.slice(1,-1),G=Z.tokens.get(z);if(!G||!["border","shadow","typography","composition"].includes(G.type))$=!1}else if(typeof W.ref==="object"&&"$ref"in W.ref)K=fZ(W.ref,Z)}else if(K=W.value,W.value.trim()&&W.value.trim()!==",")$=!1;U.push(K)}if(q&&$)return U.filter((W)=>typeof W==="object"&&W!==null&&typeof W!=="string");return U.map((W)=>String(W)).join("")}function fX(X,Z,Y,q){let $=e(X,q);switch(Z){case"alpha":if(typeof $==="string")return Z1($,Number(Y)/100);break;case"scale":if(typeof $==="string"&&$.match(/[\d.]+/))return q1($,Number(Y));break;case"hue":if(typeof $==="string")return $1($,Number(Y));break;default:return console.warn(`Unknown generator type: ${Z}`),$}return $}function Y1(X,Z,Y){let q=X.replace(/\./g,"-");q=q.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),q=q.replace(/@[^@#]*(?:screen|width|height|min|max|orientation).*$/i,""),q=q.replace(/#[^#]*$/,""),q=q.replace(/-@/g,"-").replace(/@/g,"-");let $=q,U=!0,W=Z.prefix||"";if(Z.transformName){if($=Z.transformName(q),$=$.replace(/-+$/,""),$!==q)U=!1}let K=U&&W?`${W}-${$}`:$,z=Y?`-${Y}`:"";return`--${K}${z}`.replace(/[^a-zA-Z0-9-_]/g,"-")}function Z1(X,Z){try{if(!p(X))return X;let Y=new gZ(X);return Y.alpha=Z,D(Y)}catch(Y){return console.warn(`Failed to apply alpha to color "${X}": ${Y}`),X}}function q1(X,Z){let Y=X.match(/([\d.]+)(\w+)/);if(Y){let[,q,$]=Y;return`${parseFloat(q)*Z}${$}`}return X}function $1(X,Z){try{if(!p(X))return X;let q=new gZ(X).to("oklch");return q.h=(q.h+Z)%360,D(q)}catch(Y){return console.warn(`Failed to shift hue for color "${X}": ${Y}`),X}}function mZ(X,Z){let Y=new Map,q=[],$=[],U=Z.join("|"),W=new RegExp(`#(${U})$`);for(let z of Z)Y.set(z,[]);for(let z of X){let G=z.name.match(W);if(G){let E=G[1];if(Y.has(E))Y.get(E).push(z)}else $.push(z)}let K=new Set;for(let z of Y.values())for(let G of z){let E=G.name.replace(/#[^#]+$/,"");K.add(E)}for(let z of $)if(K.has(z.name)){let G=Z[0]||"light";if(Y.has(G))Y.get(G).push(z)}else q.push(z);return{byMode:Y,shared:q}}var hX=S(()=>{PZ();EX()});function jY(X){if(X.type==="typography"||X.type==="fontWeight"||X.type==="fontFamily")return!0;if(X.type==="dimension"&&X.name.includes("typography"))return!0;if(X.name.includes("typography")||X.name.includes("font"))return!0;return!1}function i(X,Z,Y){if(Y){if(X===Z)return":host";return`:host([data-theme="${X}"])`}if(X===Z)return":root";return`[data-theme="${X}"]`}function mX(X,Z={}){let{rootSelector:Y=":root",separateThemeFiles:q=!1,generateMediaQueries:$=!1,customHeader:U,modes:W=["light","dark"]}=Z;if(q)return K1(X,Z);let K=new Map,z=new Map;for(let B of W)K.set(B,[]);let G=W.join("|"),E=new RegExp(`#(${G})$`);for(let B of X){if(typeof B.value==="string"&&u(B.value))continue;if(jY(B))continue;let R=` ${B.cssVar}: ${m(B.value,B.type)};`;if($&&B.name.includes("@media")){let w=dX(B);if(w){if(!z.has(w))z.set(w,[]);z.get(w).push(R);continue}}let I=B.name.match(E);if(I){let w=I[1];if(!K.has(w))K.set(w,[]);K.get(w).push(R)}else{let w=W[0]||"light";K.get(w).push(R)}}let A="";if(U)A+=`${U}
|
|
35
35
|
|
|
36
|
-
`;let L=Z.defaultMode||W[0]||"light",H=Z.isHost||!1,_=K.get(L)||[];if(_.length>0){_.sort();let B=i(L,L,H);
|
|
36
|
+
`;let L=Z.defaultMode||W[0]||"light",H=Z.isHost||!1,_=K.get(L)||[];if(_.length>0){_.sort();let B=i(L,L,H);A+=`${B} {
|
|
37
37
|
${_.join(`
|
|
38
38
|
`)}
|
|
39
|
-
`;for(let R of W){if(R===L)continue;let I=K.get(R)||[];if(I.length>0){I.sort();let w=i(R,L,H);if(H)
|
|
39
|
+
`;for(let R of W){if(R===L)continue;let I=K.get(R)||[];if(I.length>0){I.sort();let w=i(R,L,H);if(H)A+=`}
|
|
40
40
|
|
|
41
41
|
${w} {
|
|
42
42
|
${I.join(`
|
|
43
43
|
`)}
|
|
44
|
-
`;else{let M=w.replace("[data-theme=","&[data-theme=");
|
|
44
|
+
`;else{let M=w.replace("[data-theme=","&[data-theme=");A+=`
|
|
45
45
|
${M} {
|
|
46
46
|
${I.map((N)=>` ${N}`).join(`
|
|
47
47
|
`)}
|
|
48
48
|
}
|
|
49
|
-
`}}}
|
|
50
|
-
`}if($&&z.size>0){let B=i(L,L,H);for(let[R,I]of z)I.sort(),
|
|
49
|
+
`}}}A+=`}
|
|
50
|
+
`}if($&&z.size>0){let B=i(L,L,H);for(let[R,I]of z)I.sort(),A+=`
|
|
51
51
|
${R} {
|
|
52
52
|
${B} {
|
|
53
53
|
${I.map((w)=>` ${w}`).join(`
|
|
54
54
|
`)}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
`}let Q=[{fileName:"tokens.css",content:
|
|
58
|
-
`)?
|
|
59
|
-
`}],J=
|
|
57
|
+
`}let Q=[{fileName:"tokens.css",content:A.endsWith(`
|
|
58
|
+
`)?A:`${A}
|
|
59
|
+
`}],J=cZ(X,Z);Q.push(...J);let O=lZ(X,Z);return Q.push(...O),Q}function U1(X,Z){let Y=[];for(let $ of X){let W=` ${$.cssVar||pX($,Z)}: ${m($.value,$.type)};`;Y.push(W)}let q="";if(Z.customHeader)q+=`${Z.customHeader}
|
|
60
60
|
|
|
61
61
|
`;if(Y.length>0)Y.sort(),q+=`${Z.rootSelector||":root"} {
|
|
62
62
|
${Y.join(`
|
|
@@ -64,7 +64,7 @@ ${Y.join(`
|
|
|
64
64
|
}
|
|
65
65
|
`;return{fileName:"theme.css",content:q.endsWith(`
|
|
66
66
|
`)?q:`${q}
|
|
67
|
-
`}}function
|
|
67
|
+
`}}function K1(X,Z){let Y=[],q=new Map,$=[],U=Z.modes||["light","dark"],W=new Set(U),K=U.join("|"),z=new RegExp(`#(${K})$`);for(let _ of X){if(dX(_))continue;if(typeof _.value==="string"&&u(_.value))continue;if(jY(_))continue;let Q=_.name.match(z);if(Q){let J=Q[1];if(W.has(J)){if(!q.has(J))q.set(J,[]);q.get(J).push(_)}else $.push(_)}else $.push(_)}if($.length>0){let _=mX($,{...Z,separateThemeFiles:!1})[0];Y.push({..._,fileName:"tokens.css"})}let G=Z.defaultMode||(U.length>0?U[0]:"default"),E=Z.isHost||!1;for(let[_,Q]of q){let J=i(_,G,E),O=U1(Q,{...Z,separateThemeFiles:!1,rootSelector:J});Y.push({...O,fileName:`tokens.${_}.css`,theme:_})}let A=W1(X,Z);Y.push(...A);let L=cZ(X,Z);Y.push(...L);let H=lZ(X,Z);return Y.push(...H),Y}function W1(X,Z){let Y=new Map;for(let U of X){let W=dX(U);if(W){let K=U.name.match(/@(dark|light)$/),z=K?K[1]:"light";if(!Y.has(W))Y.set(W,new Map);let G=Y.get(W);if(!G.has(z))G.set(z,[]);G.get(z).push(U)}}if(Y.size===0)return[];let q=`/**
|
|
68
68
|
* Design System Tokens - Responsive Breakpoints
|
|
69
69
|
* Generated: ${new Date().toISOString()}
|
|
70
70
|
*
|
|
@@ -72,19 +72,19 @@ ${Y.join(`
|
|
|
72
72
|
* Each media query section overrides tokens for specific screen sizes.
|
|
73
73
|
*/
|
|
74
74
|
|
|
75
|
-
`,$=Array.from(Y.keys()).sort();for(let U of $){let W=Y.get(U),K=Z.defaultMode||(Z.modes&&Z.modes.length>0?Z.modes[0]:"light"),z=Z.isHost||!1;for(let[G,
|
|
75
|
+
`,$=Array.from(Y.keys()).sort();for(let U of $){let W=Y.get(U),K=Z.defaultMode||(Z.modes&&Z.modes.length>0?Z.modes[0]:"light"),z=Z.isHost||!1;for(let[G,E]of W){let A=[];for(let L of E){let _=` ${L.cssVar||pX(L,Z)}: ${m(L.value,L.type)};`;A.push(_)}if(A.length>0){A.sort();let L=i(G,K,z);q+=`${U} {
|
|
76
76
|
${L} {
|
|
77
|
-
${
|
|
77
|
+
${A.join(`
|
|
78
78
|
`)}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
`}}}return[{fileName:"tokens.breakpoints.css",content:q.trim()+`
|
|
83
|
-
`}]}function
|
|
83
|
+
`}]}function cZ(X,Z){let Y=new Map;for(let $ of X)if(typeof $.value==="string"&&u($.value)){let U=$.name.match(/@(dark|light)$/),W=U?U[1]:"light";if(!Y.has(W))Y.set(W,[]);Y.get(W).push($)}let q=[];if(Y.size===0)return[];if(Y.size===1){let[$,U]=Array.from(Y.entries())[0],W=pZ(U,$,Z);q.push({fileName:"tokens.icons.css",content:W.endsWith(`
|
|
84
84
|
`)?W:`${W}
|
|
85
|
-
`})}else for(let[$,U]of Y){let W=
|
|
85
|
+
`})}else for(let[$,U]of Y){let W=pZ(U,$,Z);q.push({fileName:`tokens.icons.${$}.css`,content:W.endsWith(`
|
|
86
86
|
`)?W:`${W}
|
|
87
|
-
`})}return q}function
|
|
87
|
+
`})}return q}function pZ(X,Z,Y){let q=`/**
|
|
88
88
|
* Design System Tokens - Icons (${Z})
|
|
89
89
|
* Generated: ${new Date().toISOString()}
|
|
90
90
|
*
|
|
@@ -92,17 +92,17 @@ ${E.join(`
|
|
|
92
92
|
* Icons are provided as data URIs for direct embedding.
|
|
93
93
|
*/
|
|
94
94
|
|
|
95
|
-
`,$=[];for(let U of X){let K=` ${U.cssVar||
|
|
95
|
+
`,$=[];for(let U of X){let K=` ${U.cssVar||pX(U,Y)}: ${m(U.value,U.type)};`;$.push(K)}if($.length>0){$.sort();let U=Y.defaultMode||"light",W=Y.isHost||!1,K=i(Z,U,W);q+=`${K} {
|
|
96
96
|
${$.join(`
|
|
97
97
|
`)}
|
|
98
98
|
}
|
|
99
99
|
`}return q+`
|
|
100
|
-
`}function
|
|
100
|
+
`}function pX(X,Z){let q=X.name.split("@")[0].replace(/\.$/,"").replace(/\.+/g,"."),$=DY(q,Z.hooks);return`--${Z.prefix||MX}-${$.replace(/\./g,"-")}`}function DY(X,Z,Y){if(!Z?.shortenName?.enabled)return X;let q=X;if(Z.shortenName.prefix)for(let $ of Z.shortenName.prefix)q=q.replace(new RegExp($.find,"g"),$.replace);if(Z.shortenName.suffix){for(let $ of Z.shortenName.suffix)if(q.endsWith($.find))q=q.substring(0,q.length-$.find.length)+$.replace}if(Y&&Y!=="light"){let $=`-${Y}`;if(q.endsWith($))q=q.slice(0,-$.length)}return q}function lZ(X,Z){let Y=new Map,q=Z.modes||[];for(let W of X)if(jY(W)){if(dX(W))continue;let z=q.length>0?q[0]:"default";if(W.name.includes("#")){let G=W.name.split("#"),E=G[G.length-1];if(q.includes(E))z=E}if(!Y.has(z))Y.set(z,[]);Y.get(z).push(W)}let $=[];if(Z.separateThemeFiles??!1)for(let[W,K]of Y.entries()){let z=dZ(K,W,Z,q);$.push({fileName:`tokens.typography.${W}.css`,content:z.endsWith(`
|
|
101
101
|
`)?z:`${z}
|
|
102
|
-
`})}else{let W="";for(let[K,z]of Y.entries()){let G=
|
|
102
|
+
`})}else{let W="";for(let[K,z]of Y.entries()){let G=dZ(z,K,Z,q);if(W)W+=`
|
|
103
103
|
`;W+=G}if(W)$.push({fileName:"tokens.typography.css",content:W.endsWith(`
|
|
104
104
|
`)?W:`${W}
|
|
105
|
-
`})}return $}function
|
|
105
|
+
`})}return $}function dZ(X,Z,Y,q){let $=`/**
|
|
106
106
|
* Design System Tokens - Typography (${Z})
|
|
107
107
|
* Generated: ${new Date().toISOString()}
|
|
108
108
|
*
|
|
@@ -110,27 +110,27 @@ ${$.join(`
|
|
|
110
110
|
* Includes fontSize, fontWeight, fontFamily, lineHeight, and typography compositions.
|
|
111
111
|
*/
|
|
112
112
|
|
|
113
|
-
`,U=new Map;for(let W of X){let K="default";if(W.name.includes("@")){let z=W.name.split("@");for(let G of z)if(G.includes("screen_")||G.includes("min_width")||G.includes("max_width")){K=G.replace(/screen_and__/g,"").replace(/min_width__(\d+)px_/g,"min-width: $1px").replace(/max_width__(\d+)px_/g,"max-width: $1px").replace(/_/g," ");break}}if(!U.has(K))U.set(K,[]);U.get(K).push(W)}for(let[W,K]of U.entries()){let z=[];for(let G of K){let
|
|
113
|
+
`,U=new Map;for(let W of X){let K="default";if(W.name.includes("@")){let z=W.name.split("@");for(let G of z)if(G.includes("screen_")||G.includes("min_width")||G.includes("max_width")){K=G.replace(/screen_and__/g,"").replace(/min_width__(\d+)px_/g,"min-width: $1px").replace(/max_width__(\d+)px_/g,"max-width: $1px").replace(/_/g," ");break}}if(!U.has(K))U.set(K,[]);U.get(K).push(W)}for(let[W,K]of U.entries()){let z=[];for(let G of K){let A=` ${G.cssVar||pX(G,Y)}: ${m(G.value,G.type)};`;z.push(A)}if(z.length>0){let G=Y.defaultMode||"light",E=Y.isHost||!1,A=i(Z,G,E);if(W==="default")z.sort(),$+=`${A} {
|
|
114
114
|
${z.join(`
|
|
115
115
|
`)}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
`;else{let L=W.startsWith("(")?W:`(${W})`;$+=`@media ${L} {
|
|
119
|
-
`,$+=` ${
|
|
119
|
+
`,$+=` ${A} {
|
|
120
120
|
${z.sort().map((H)=>` ${H}`).join(`
|
|
121
121
|
`)}
|
|
122
122
|
}
|
|
123
123
|
`,$+=`}
|
|
124
124
|
|
|
125
125
|
`}}}return $+`
|
|
126
|
-
`}function m(X,Z){if(X===null||X===void 0)return"";if(typeof X==="object"&&X!==null&&!Array.isArray(X)){let q=X;if(q.$value!==void 0){if(typeof q.$value==="string")return q.$value;return m(q.$value,q.$type||Z)}}let Y=String(X);switch(Z){case"color":return
|
|
126
|
+
`}function m(X,Z){if(X===null||X===void 0)return"";if(typeof X==="object"&&X!==null&&!Array.isArray(X)){let q=X;if(q.$value!==void 0){if(typeof q.$value==="string")return q.$value;return m(q.$value,q.$type||Z)}}let Y=String(X);switch(Z){case"color":return G1(Y);case"dimension":return z1(Y);case"duration":return A1(Y);case"fontFamily":return E1(Y);case"fontWeight":return L1(Y);case"cubicBezier":return H1(X);case"shadow":return _1(X);case"border":return Q1(X);case"typography":return O1(X);case"composition":return bY(X);default:if(Y.startsWith("data:"))return`"${Y}"`;return Y}}function G1(X){if(X.startsWith("oklch(")||X.startsWith("rgb(")||X.startsWith("rgba(")||X.startsWith("hsl(")||X.startsWith("hsla(")||X.startsWith("#"))return X;return X}function z1(X){if(/^\d+(\.\d+)?(px|rem|em|%|vh|vw|vmin|vmax)$/.test(X))return X;if(/^\d+(\.\d+)?$/.test(X))return`${X}rem`;return X}function A1(X){if(/^\d+(\.\d+)?(s|ms)$/.test(X))return X;if(/^\d+(\.\d+)?$/.test(X))return`${X}ms`;return X}function E1(X){return X.split(",").map((q)=>q.trim()).map((q)=>{if(q.includes(" ")&&!q.startsWith('"')&&!q.startsWith("'"))return`"${q}"`;return q}).join(", ")}function L1(X){return{thin:"100","extra-light":"200",light:"300",normal:"400",medium:"500","semi-bold":"600",bold:"700","extra-bold":"800",black:"900"}[X]||X}function H1(X){if(Array.isArray(X)&&X.length===4)return`cubic-bezier(${X.join(", ")})`;return String(X)}function _1(X){if(Array.isArray(X))return X.map((Z)=>uZ(Z)).join(", ");return uZ(X)}function uZ(X){if(typeof X==="object"&&X!==null){let Z=X,Y=Z.color||"transparent";if(typeof Y==="string"&&Y.includes("{")&&Y.includes("}")){console.warn(`Unresolved token reference in shadow color: ${Y}`);let $=Y.match(/\{([^}]+)\}/)?.[1];if($)Y=`var(${`--${MX}-${$.replace(/\./g,"-").replace(/@/g,"-")}`})`}let q=[Z.offsetX||"0",Z.offsetY||"0",Z.blur||"0",Z.spread||"0",Y];if(Z.inset)q.unshift("inset");return q.join(" ")}return String(X)}function Q1(X){if(typeof X==="object"&&X!==null){let Z=X,Y=j(Z.width)||"1px",q=j(Z.style)||"solid",$=j(Z.color)||"transparent";return`${Y} ${q} ${$}`}return String(X)}function O1(X){if(typeof X==="object"&&X!==null){let Z=X,Y=Z.fontWeight||"normal",q=Z.fontSize||"1rem",$=Z.lineHeight||"normal",U=Z.fontFamily||"sans-serif";if(U.includes(" ")&&!U.startsWith('"')&&!U.startsWith("'"))U=`'${U}'`;let W;if(q.includes("/"))W=q;else W=`${q}/${$}`;return`${Y} ${W} ${U}`}return String(X)}function bY(X){if(typeof X!=="object"||X===null)return String(X);if(Array.isArray(X))return X.map((Y)=>bY(Y)).join(", ");let Z=X;if(Z.offsetX!==void 0&&Z.offsetY!==void 0)return rZ(Z);if(Z.width!==void 0&&Z.style!==void 0&&Z.color!==void 0){let Y=String(Z.width||"1px"),q=String(Z.style||"solid"),$=String(Z.color||"transparent");return`${Y} ${q} ${$}`}if(Z.blur!==void 0||Z.saturate!==void 0||Z.brightness!==void 0)return J1(Z);if(Z.fontSize!==void 0||Z.fontFamily!==void 0)return B1(Z);return I1(Z)}function rZ(X){let Z=[j(X.offsetX)||"0",j(X.offsetY)||"0",j(X.blur)||"0",j(X.spread)||"0",j(X.color)||"transparent"];if(X.inset&&j(X.inset)==="true")Z.unshift("inset");return Z.join(" ")}function J1(X){let Z=[];if(X.blur)Z.push(j(X.blur)||"blur(0)");if(X.saturate)Z.push(j(X.saturate)||"saturate(100%)");if(X.brightness)Z.push(j(X.brightness)||"brightness(100%)");if(X.contrast)Z.push(j(X.contrast)||"contrast(100%)");if(X.hueRotate)Z.push(j(X.hueRotate)||"hue-rotate(0deg)");return Z.join(" ")||"none"}function B1(X){let Z=j(X.fontWeight)||"normal",Y=j(X.fontSize)||"1rem",q=j(X.lineHeight),$=j(X.fontFamily)||"sans-serif";if($.includes(" ")&&!$.startsWith('"')&&!$.startsWith("'"))$=`'${$}'`;if(Y.includes("/"))return`${Z} ${Y} ${$}`;else if(q)return`${Z} ${Y}/${q} ${$}`;return`${Z} ${Y} ${$}`}function kZ(X,Z,Y){let q=X.match(/^\{(.+)\}$/);if(!q)return X;let U=q[1].replace(/\./g,"-");if(Y)U=DY(U,{shortenName:Y.$metaData?.tokens?.css?.hooks?.shortenName});return`var(--${U})`}function j(X,Z,Y){if(X===null||X===void 0)return"";if(typeof X==="string"){if(X.match(/^\{.+\}$/))return kZ(X,Z||"ds",Y);return X}if(typeof X==="object"&&X.value!==void 0){let q=String(X.value);if(q.match(/^\{.+\}$/))return kZ(q,Z||"ds",Y);return q}return String(X)}function I1(X){let Z=[];for(let[,$]of Object.entries(X)){let U=$;if(typeof $==="object"&&$!==null&&U.$value&&typeof U.$value==="object"){let W=U.$value;if(W.offsetX!==void 0&&W.offsetY!==void 0){let K=rZ(W);if(K)Z.push(K)}else{let K=bY(W);if(K)Z.push(K)}}else{let W=j($);if(W)Z.push(W)}}let q=Z.some(($)=>/^\d/.test($)&&$.includes(" "))?", ":" ";return Z.join(q)||String(X)}function dX(X){if(X.extensions?.mediaQuery&&typeof X.extensions.mediaQuery==="string"){let Y=X.extensions.mediaQuery;if(Y=Y.replace(/\{universe\.foundation\.breakpoint\.screen\.width\.lg\}/g,"64rem"),!Y.startsWith("@media"))Y=`@media ${Y}`;return Y}let Z=X.name.match(/@(media[^@]+)/);if(Z)return`@${Z[1].replace(/_/g," ")}`;if(X.name.includes("@screen_and__min_width__300px_"))return"@media screen and (min-width: 300px)";if(X.name.includes("@screen_and__min_width__600px_"))return"@media screen and (min-width: 600px)";if(X.name.includes("@")&&X.name.includes("_"))return"@media (unknown-breakpoint)";return null}function uX(X){let Z=X?.$name||"Design System",Y=X?.$version||"1.0.0",q=new Date().toISOString();return`/**
|
|
127
127
|
* ${Z} - CSS Custom Properties
|
|
128
128
|
* Version: ${Y}
|
|
129
129
|
* Generated: ${q}
|
|
130
130
|
*
|
|
131
131
|
* This file contains CSS custom properties (CSS variables) generated from design tokens.
|
|
132
132
|
* Do not edit this file directly - it will be overwritten.
|
|
133
|
-
*/`}function
|
|
133
|
+
*/`}function w1(X){let Z=X.replace(/\r?\n|\r/g,"").replace(/\s+/g," ").trim();return`data:image/svg+xml;base64,${Buffer.from(Z,"utf8").toString("base64")}`}function SY(X,Z={}){let{customHeader:Y,objectPath:q="universe.custom.path.icons",isHost:$=!1,defaultMode:U="light"}=Z,W="--"+q.replace(/\./g,"-"),K="";if(Y)K+=Y+`
|
|
134
134
|
|
|
135
135
|
`;else K+=`/**
|
|
136
136
|
* Icon CSS - Base64 Encoded SVG Icons as CSS Custom Properties
|
|
@@ -147,20 +147,20 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
147
147
|
*/
|
|
148
148
|
|
|
149
149
|
`;let z=i(U,U,$);K+=`${z} {
|
|
150
|
-
`;let G=[...X].sort((A
|
|
150
|
+
`;let G=[...X].sort((E,A)=>E.name.localeCompare(A.name));for(let E of G){let A=E.name.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""),L=E.category?`${W}-${E.category}-${A}`:`${W}-${A}`;if(Z.hooks?.shortenName?.enabled)L=DY(L,Z.hooks);let H=w1(E.value);K+=` ${L}: url("${H}");
|
|
151
151
|
`}return K+=`}
|
|
152
152
|
`,{fileName:"tokens.icons.css",content:K.trim()+`
|
|
153
|
-
`}}var
|
|
154
|
-
`}function
|
|
153
|
+
`}}var kX=S(()=>{g()});import{readFileSync as R1,existsSync as M1}from"fs";import{join as sZ,relative as N1}from"path";async function PY(){try{let{assets:X}=await d(!0),{icons:Z}=await T(),Y=await o(),q=X?.icons?.distDir??"build",$=sZ(Y,q),U=sZ($,"tokens",await WX("json"));if(!M1(U)){let _=N1(process.cwd(),U);return console.log(`ℹ️ Icon data not found (skipping icon types): ${_}`),console.log(" Run icon build first if you need icon types generated."),[]}let W=JSON.parse(R1(U,"utf8")),K=Z?.objectPath??"universe.icons",z=K.split("."),G=W;for(let _ of z)if(G&&typeof G==="object"&&_ in G)G=G[_];else throw Error(`Icon path ${K} not found in icons file`);let E=[],A=Object.keys(G)[0],L=G[A];if(L&&typeof L==="object"&&"$value"in L){for(let[_,Q]of Object.entries(G))if(typeof Q==="object"&&Q!==null){let J=Q;if(_.startsWith("$"))continue;E.push({name:_,category:"",value:J.$value||"",description:J.$description||"",style:J.$style||"",dimensions:J.$extensions?.dimensions||J.$dimensions})}}else for(let[_,Q]of Object.entries(G))if(typeof Q==="object"&&Q!==null){for(let[J,O]of Object.entries(Q))if(typeof O==="object"&&O!==null){let B=O;if(J.startsWith("$"))continue;E.push({name:J,category:_,value:B.$value||"",description:B.$description||"",style:B.$style||"",dimensions:B.$extensions?.dimensions||B.$dimensions})}}return E}catch(X){if(X instanceof Error){if("code"in X&&X.code!=="ENOENT")console.warn(`⚠️ Could not load icon data: ${X.message}`)}return[]}}async function CY(X,Z={},Y){let{generateTypes:q=!0,generateConsts:$=!0}=Z,U=Z.icons;if(!U)U=await PY();let W={...Z,icons:U},K=[];if(q)K.push({fileName:"tokens.types.ts",content:F1(X,W),type:"types"});if($)K.push({fileName:"tokens.constants.ts",content:x1(X,W),type:"constants"});return K.push({fileName:"index.ts",content:j1(K,Y),type:"index"}),K}function F1(X,Z){let{tokenInterface:Y="DesignTokens",includeJSDoc:q=!0,icons:$=[]}=Z,U=VY("Type Definitions");if(U+=D1(X,q),U+=b1(X,q),$.length>0)U+=S1($,q);return U+=P1(X,Y,q),U+=V1(X,q),U+`
|
|
154
|
+
`}function x1(X,Z){let{includeJSDoc:Y=!0,icons:q=[]}=Z,$=VY("Token Constants"),U="TokenPaths, CSSVariableNames";if(q.length>0)U+=", IconNames, IconCategories, Icon";if($+=`import type { ${U} } from './tokens.types';
|
|
155
155
|
|
|
156
|
-
`,$+=
|
|
157
|
-
`}function
|
|
156
|
+
`,$+=T1(X,Y),$+=g1(X,Y),q.length>0)$+=y1(q,Y);return $+=v1(X,Y),$+`
|
|
157
|
+
`}function j1(X,Z){let Y=VY("Main Export");if(X.some((q)=>q.type==="types"))Y+=`export type * from './tokens.types';
|
|
158
158
|
`;if(X.some((q)=>q.type==="constants"))Y+=`export * from './tokens.constants';
|
|
159
159
|
`;if(Z)try{let q=n("fs"),U=n("path").join(Z,"typescript","tokens.icons.ts");if(q.existsSync(U))Y+=`export type * from './tokens.icons';
|
|
160
160
|
`,Y+=`export * from './tokens.icons';
|
|
161
161
|
`}catch(q){}return Y+=`
|
|
162
162
|
`,Y+`
|
|
163
|
-
`}function
|
|
163
|
+
`}function D1(X,Z){let Y=X.map(($)=>`"${$.name}"`).join(`
|
|
164
164
|
| `),q="";if(Z)q+=`/**
|
|
165
165
|
* All available token paths as string literals
|
|
166
166
|
*/
|
|
@@ -168,7 +168,7 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
168
168
|
| ${Y};
|
|
169
169
|
|
|
170
170
|
`,q+`
|
|
171
|
-
`}function b1(X,Z){let Y=
|
|
171
|
+
`}function b1(X,Z){let Y=f1(X),q="";for(let[$,U]of Y){let W=`${m1($)}TokenValue`,K=new Set(U.map((G)=>NX(G.value))),z=Array.from(K).join(`
|
|
172
172
|
| `);if(Z)q+=`/**
|
|
173
173
|
* Possible values for ${$} tokens
|
|
174
174
|
*/
|
|
@@ -176,7 +176,7 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
176
176
|
| ${z};
|
|
177
177
|
|
|
178
178
|
`}return q+`
|
|
179
|
-
`}function
|
|
179
|
+
`}function S1(X,Z){let Y="",q=X.map((W)=>`"${W.name}"`).join(`
|
|
180
180
|
| `);if(Z)Y+=`/**
|
|
181
181
|
* All available icon names as string literals
|
|
182
182
|
*/
|
|
@@ -212,7 +212,7 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
212
212
|
`,Y+=`}
|
|
213
213
|
|
|
214
214
|
`,Y+`
|
|
215
|
-
`}function
|
|
215
|
+
`}function P1(X,Z,Y){let q="";if(Y)q+=`/**
|
|
216
216
|
* Design tokens interface with all token paths and their values
|
|
217
217
|
*/
|
|
218
218
|
`;q+=`export interface ${Z} {
|
|
@@ -220,15 +220,15 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
220
220
|
`;q+=` "${$.name}": ${NX($.value)};
|
|
221
221
|
`}return q+=`}
|
|
222
222
|
|
|
223
|
-
`,q+=
|
|
224
|
-
`}function
|
|
223
|
+
`,q+=C1(X,`${Z}Nested`,Y),q+`
|
|
224
|
+
`}function C1(X,Z,Y){let q=h1(X),$="";if(Y)$+=`/**
|
|
225
225
|
* Design tokens interface with nested structure
|
|
226
226
|
*/
|
|
227
227
|
`;return $+=`export interface ${Z} {
|
|
228
|
-
`,$+=
|
|
228
|
+
`,$+=iZ(q,1),$+=`}
|
|
229
229
|
|
|
230
230
|
`,$+`
|
|
231
|
-
`}function
|
|
231
|
+
`}function V1(X,Z){let q=Array.from(new Set(X.map((U)=>U.cssVar))).map((U)=>`"${U}"`).join(`
|
|
232
232
|
| `),$="";if(Z)$+=`/**
|
|
233
233
|
* All available CSS variable names
|
|
234
234
|
*/
|
|
@@ -236,7 +236,7 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
236
236
|
| ${q};
|
|
237
237
|
|
|
238
238
|
`,$+`
|
|
239
|
-
`}function
|
|
239
|
+
`}function T1(X,Z){let Y="";if(Z)Y+=`/**
|
|
240
240
|
* Object containing all token values
|
|
241
241
|
*/
|
|
242
242
|
`;Y+=`export const tokenValues = {
|
|
@@ -244,7 +244,7 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
244
244
|
`;Y+=` "${q.name}": ${JSON.stringify(q.value)},
|
|
245
245
|
`}return Y+=`} as const;
|
|
246
246
|
|
|
247
|
-
`,Y}function
|
|
247
|
+
`,Y}function y1(X,Z){let Y="";if(Z)Y+=`/**
|
|
248
248
|
* Array of all available icons
|
|
249
249
|
*/
|
|
250
250
|
`;Y+=`export const icons: Icon[] = [
|
|
@@ -287,7 +287,7 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
287
287
|
`,Y+=`}
|
|
288
288
|
|
|
289
289
|
`,Y+`
|
|
290
|
-
`}function
|
|
290
|
+
`}function g1(X,Z){let Y="";if(Z)Y+=`/**
|
|
291
291
|
* Object mapping token paths to CSS variable names
|
|
292
292
|
*/
|
|
293
293
|
`;Y+=`export const cssVariableNames = {
|
|
@@ -295,7 +295,7 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
295
295
|
`;return Y+=`} as const;
|
|
296
296
|
|
|
297
297
|
`,Y+`
|
|
298
|
-
`}function
|
|
298
|
+
`}function v1(X,Z){let Y="";if(Z)Y+=`/**
|
|
299
299
|
* Get the value of a design token
|
|
300
300
|
*/
|
|
301
301
|
`;if(Y+=`export function getTokenValue<T extends TokenPaths>(tokenPath: T): typeof tokenValues[T] {
|
|
@@ -324,10 +324,10 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
`,Y+`
|
|
327
|
-
`}function
|
|
328
|
-
`,Y+=
|
|
327
|
+
`}function f1(X){let Z=new Map;for(let Y of X){if(!Z.has(Y.type))Z.set(Y.type,[]);Z.get(Y.type).push(Y)}return Z}function h1(X){let Z={};for(let Y of X){if(Y.path.some((z)=>z.includes("@")||z.includes("#")||z.includes("-")||z.includes(".")))continue;let $=Z,U=[...Y.path];for(let z=0;z<U.length-1;z++){let G=U[z];if(!$[G])$[G]={};$=$[G]}let W=U[U.length-1],K=NX(Y.value);$[W]=K}return Z}function iZ(X,Z){let Y="",q=" ".repeat(Z);for(let[$,U]of Object.entries(X)){let W=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test($)?$:`"${$}"`;if(typeof U==="object"&&!Array.isArray(U))Y+=`${q}${W}: {
|
|
328
|
+
`,Y+=iZ(U,Z+1),Y+=`${q}};
|
|
329
329
|
`;else Y+=`${q}${W}: ${U};
|
|
330
|
-
`}return Y}function NX(X){if(typeof X==="string")return`"${X}"`;else if(typeof X==="number")return X.toString();else if(typeof X==="boolean")return X.toString();else if(Array.isArray(X)){let Z=new Set(X.map((q)=>NX(q)));return`Array<${Array.from(Z).join(" | ")}>`}else if(X===null)return"null";else if(X===void 0)return"undefined";else if(typeof X==="object"&&X!==null)return`{ ${Object.entries(X).map(([q,$])=>`${q}: ${NX($)}`).join("; ")} }`;else return"unknown"}function
|
|
330
|
+
`}return Y}function NX(X){if(typeof X==="string")return`"${X}"`;else if(typeof X==="number")return X.toString();else if(typeof X==="boolean")return X.toString();else if(Array.isArray(X)){let Z=new Set(X.map((q)=>NX(q)));return`Array<${Array.from(Z).join(" | ")}>`}else if(X===null)return"null";else if(X===void 0)return"undefined";else if(typeof X==="object"&&X!==null)return`{ ${Object.entries(X).map(([q,$])=>`${q}: ${NX($)}`).join("; ")} }`;else return"unknown"}function m1(X){if(!X||typeof X!=="string")return"";return X.charAt(0).toUpperCase()+X.slice(1)}function VY(X){let Z=new Date().toISOString();return`/**
|
|
331
331
|
* ${X}
|
|
332
332
|
* Generated: ${Z}
|
|
333
333
|
*
|
|
@@ -335,7 +335,7 @@ ${z.sort().map((H)=>` ${H}`).join(`
|
|
|
335
335
|
* Do not edit this file directly - it will be overwritten.
|
|
336
336
|
*/
|
|
337
337
|
|
|
338
|
-
`}var TY=S(()=>{g()});import{readFileSync as
|
|
338
|
+
`}var TY=S(()=>{g()});import{readFileSync as p1,mkdirSync as tZ}from"fs";import{writeFile as aZ,readdir as d1,mkdir as u1}from"fs/promises";import{resolve as k1,relative as nZ,join as cX,dirname as oZ}from"path";import c1 from"lodash";async function eZ(X){let Z=await d1(X,{withFileTypes:!0}),Y=await Promise.all(Z.map((q)=>{let $=k1(X,q.name);return q.isDirectory()?eZ($):$}));return Array.prototype.concat(...Y)}async function X0(X,Z){if(!X)throw Error("outputDir is required for buildIcons");let{assets:Y,icons:q,tokenNamespace:$,__dirname:U,buildDir:W}=await r(),K=cX(U,Y?.icons?.sourceDir??"icons"),z="build",G=Y?.icons?.distDir??z,E=cX(U,G),A=cX(U,W,"icons");if(!Y?.icons?.sourceDir){console.warn("Skipping icon build: iconsDir is not defined in the project paths.");return}t(cX(U,W));let L=(await eZ(K)).filter((M)=>M.endsWith(".svg")),Q=(await Promise.all(L.map(async(M)=>{let N=p1(M,"utf8").replace(/(\s+(?=(?:[^"]*"[^"]*")*[^"]*$))/g," ").trim()??"";N=await BY(N);let YX=nZ(K,M).split("/").pop(),xX=(N.match(/name="(.*?)"/)??[])[1]??YX?.replace(".svg",""),rX=(N.match(/data-style="(.*?)"/)??[])[1],Q0=(N.match(/description="(.*?)"/)??[])[1],[dY]=N.match(/<svg[^>]*>/)??[],[,O0]=dY?.match(/width="([\d.]+)(px)?"/)??[],[,J0]=dY?.match(/height="([\d.]+)(px)?"/)??[];if(rX!=="animated"&&rX!=="custom")return{path:M,folder:nZ(K,M).split("/").slice(0,-1).concat(xX),file:YX,style:rX,content:N,name:xX,dimensions:{width:Number(O0),height:Number(J0)},description:Q0??""};return}))).filter((M)=>M!==void 0).reduce((M,N)=>{if(N?.style!=="animated"&&N?.style!=="custom"&&N)yY(M,N.folder.join("."),{$type:"icon",$name:N.name,$description:N.description,$style:N.style,$value:N.content,$extensions:{dimensions:N.dimensions},...l1(M,N.folder.join("."))});return M},{}),J=q?.objectPath??`${$}.icons`,B=Object.keys(Q).some((M)=>M.includes("."));Object.keys(Q).forEach(async(M)=>{let N,YX;if(B)N=`${A}/${M}`,YX=`${N}/svg.${M}.tokens.json`;else N=A,YX=`${A}/svg.${M}.tokens.json`;await u1(N,{recursive:!0});let xX=yY({},`${J}${J?".":""}${M}`,Q[M]);await aZ(YX,JSON.stringify(xX,null,2),{flag:"w",encoding:"utf-8"})});let R=`${E}/tokens/${await WX("json")}`,I=oZ(R);tZ(I,{recursive:!0});let w=yY({},J,Q);await aZ(R,JSON.stringify(w,null,2),{flag:"w",encoding:"utf-8"}),await r1(Q,X,Z)}async function r1(X,Z,Y){let{writeFileSync:q}=n("fs"),{join:$}=n("path");try{let U=Object.keys(X).sort(),W=`/**
|
|
339
339
|
* Icon Names Type Definition
|
|
340
340
|
* Generated: ${new Date().toISOString()}
|
|
341
341
|
*
|
|
@@ -349,25 +349,25 @@ export const icons = [
|
|
|
349
349
|
] as const;
|
|
350
350
|
|
|
351
351
|
export type IconName = typeof icons[number];
|
|
352
|
-
`,K=$(Z,"typescript","tokens.icons.ts"),z=
|
|
352
|
+
`,K=$(Z,"typescript","tokens.icons.ts"),z=oZ(K);tZ(z,{recursive:!0}),q(K,W,"utf-8"),console.log(`✓ Generated ${U.length} icon names`)}catch(U){console.error("Failed to generate icon names:",U)}}var yY,l1;var Y0=S(()=>{g();({set:yY,get:l1}=c1)});function $0(X,Z={}){let Y=[],q=Z.typescript?"ts":"js",$=Z.modes||[],U=X.filter((K)=>K.extensions?.mediaQuery||K.name.includes("@screen")||K.name.includes("@_")),W=X.filter((K)=>!K.extensions?.mediaQuery&&!K.name.includes("@screen")&&!K.name.includes("@_"));if(Z.separateThemeFiles&&$.length>0){let{byMode:K,shared:z}=mZ(W,$);for(let G of $){let A=[...K.get(G)||[],...z];if(A.length>0){if(Z.typescript){let L=U0(A,G);Y.push({fileName:`${G}.d.ts`,content:o1(L,Z,G),theme:G})}Y.push({fileName:`${G}.${q}`,content:q0(A,{...Z,theme:G}),theme:G})}}}else Y.push({fileName:`tokens.${q}`,content:q0(W,Z)});if(U.length>0)Y.push({fileName:`breakpoints.${q}`,content:s1(U,X,Z)});if(Z.separateThemeFiles&&Y.length>1)Y.push({fileName:`index.${q}`,content:X2(Y,Z)});return Y}function s1(X,Z,Y={}){let{typescript:q,includeJSDoc:$,moduleType:U="es",customHeader:W,modes:K=[]}=Y,z=new Map(Z.map((L)=>[L.name,L])),G={};for(let L of X){let H=L.extensions?.mediaQuery||i1(L.name),_=K.length>0?K[0]:"default";for(let O of K)if(L.name.includes(`#${O}`)){_=O;break}if(typeof H==="string"&&H.includes("{")&&H.includes("}"))H=n1(H,z);if(!G[H])G[H]={};if(!G[H][_])G[H][_]={};let Q=a1(L.name),J=t1(Q,lX(L.value,z));G[H][_]={...G[H][_],...J}}let E=Object.keys(G).sort((L,H)=>{let _=Z0(L),Q=Z0(H);return _-Q}).reduce((L,H)=>{return L[H]=G[H],L},{}),A="";if(W)A+=`${W}
|
|
353
353
|
|
|
354
|
-
`;else
|
|
355
|
-
`,
|
|
356
|
-
`,
|
|
357
|
-
`,
|
|
358
|
-
`,
|
|
354
|
+
`;else A+=`/**
|
|
355
|
+
`,A+=` * Design Tokens - Breakpoints
|
|
356
|
+
`,A+=` * Auto-generated from design token definitions
|
|
357
|
+
`,A+=` * Do not edit this file directly
|
|
358
|
+
`,A+=` */
|
|
359
359
|
|
|
360
|
-
`;if(q)
|
|
361
|
-
`;if(U==="es"){if(q)
|
|
360
|
+
`;if(q)A+=K0(E,$),A+=`
|
|
361
|
+
`;if(U==="es"){if(q)A+=`const breakpoints: Tokens = ${XX(E,$,0)};
|
|
362
362
|
|
|
363
|
-
`;else
|
|
363
|
+
`;else A+=`const breakpoints = ${XX(E,$,0)};
|
|
364
364
|
|
|
365
|
-
`;
|
|
366
|
-
`}else
|
|
365
|
+
`;A+=`export default breakpoints;
|
|
366
|
+
`}else A+=`const breakpoints = ${XX(E,$,0)};
|
|
367
367
|
|
|
368
|
-
`,
|
|
369
|
-
`,
|
|
370
|
-
`;return
|
|
368
|
+
`,A+=`module.exports = breakpoints;
|
|
369
|
+
`,A+=`module.exports.default = breakpoints;
|
|
370
|
+
`;return A}function i1(X){if(X.includes("@_max_width_")){let Z=X.match(/@_max_width___(.+?)__/);if(Z)return`screen and (max-width: {${Z[1].replace(/_/g,".")}})`}if(X.includes("@_min_width_")){let Z=X.match(/@_min_width___(.+?)__/);if(Z)return`screen and (min-width: {${Z[1].replace(/_/g,".")}})`}return"screen"}function a1(X){let Z=X.replace(/@_.*?__/,"").replace(/@screen.*/,"").replace(/#[^#]*$/,"").replace(/^universe\./,"");return Z=Z.replace(/_universe_foundation_breakpoint_screen_width_[^_]+__?$/,""),Z}function Z0(X){let Z=X.match(/(\d+(?:\.\d+)?)/);return Z?parseFloat(Z[1]):0}function n1(X,Z){return X.replace(/\{([^}]+)\}/g,(Y,q)=>{let $=Z.get(q);if($){let U=$.value;if(typeof U==="object"&&U!==null&&"$value"in U)U=U.$value;return String(U)}return Y})}function t1(X,Z){let Y=X.split("."),q={},$=q;for(let U=0;U<Y.length-1;U++)$[Y[U]]={},$=$[Y[U]];return $[Y[Y.length-1]]=Z,q}function q0(X,Z={}){let{typescript:Y,includeJSDoc:q,moduleType:$="es",customHeader:U,theme:W}=Z,K="";if(U)K+=`${U}
|
|
371
371
|
|
|
372
372
|
`;else K+=`/**
|
|
373
373
|
`,K+=` * Design Tokens - ${W?`${W.charAt(0).toUpperCase()+W.slice(1)} Theme`:"All Tokens"}
|
|
@@ -375,9 +375,9 @@ export type IconName = typeof icons[number];
|
|
|
375
375
|
`,K+=` * Do not edit this file directly
|
|
376
376
|
`,K+=` */
|
|
377
377
|
|
|
378
|
-
`;let z
|
|
378
|
+
`;let z=U0(X,W);if(Y)if(Z.separateThemeFiles&&W)K+=`import type { Tokens } from "./${W}.d";
|
|
379
379
|
|
|
380
|
-
`;else K+=
|
|
380
|
+
`;else K+=K0(z,q),K+=`
|
|
381
381
|
`;if($==="es"){if(Y)K+=`const tokens: Tokens = ${XX(z,q,0)};
|
|
382
382
|
|
|
383
383
|
`;else K+=`const tokens = ${XX(z,q,0)};
|
|
@@ -385,17 +385,17 @@ export type IconName = typeof icons[number];
|
|
|
385
385
|
`;K+=`export default tokens;
|
|
386
386
|
`;let G=Object.keys(z);if(G.length>0){K+=`
|
|
387
387
|
// Named exports for convenience
|
|
388
|
-
`;for(let
|
|
388
|
+
`;for(let E of G)K+=`export const ${E} = tokens.${E};
|
|
389
389
|
`}}else K+=`const tokens = ${XX(z,q,0)};
|
|
390
390
|
|
|
391
391
|
`,K+=`module.exports = tokens;
|
|
392
392
|
`,K+=`module.exports.default = tokens;
|
|
393
393
|
`;return K+`
|
|
394
|
-
`}function
|
|
394
|
+
`}function U0(X,Z){let Y={},q=new Map(X.map(($)=>[$.name,$]));for(let $ of X){let U=$.name;if(Z){if(U.includes(`#${Z}`))U=U.replace(`#${Z}`,"")}else U=U.replace(/#[^#]*$/,"");let W=U.split("."),K=Y;for(let G=0;G<W.length-1;G++){let E=W[G];if(!K[E])K[E]={};K=K[E]}let z=W[W.length-1];K[z]=lX($.value,q)}return Y}function lX(X,Z){if(typeof X==="object"&&X!==null&&!Array.isArray(X)){let Y=X;if(Y.color&&typeof Y.color==="string"&&Y.color.includes("{")&&Y.color.includes("}")){let q=m(X,"shadow");if(typeof q==="string"&&!q.includes("{")){let $={...Y},U=q.split(" "),W=U[U.length-1];if(W&&W.startsWith("#"))$.color=W;else $.color=m(Y.color,"color");return $}}}if(typeof X==="string"){if(X.startsWith("{")&&X.endsWith("}")){let Y=X.slice(1,-1),q=Z.get(Y);if(q)return q.value;let $=m(X,"color");if($!==X)return $}return X}if(Array.isArray(X))return X.map((Y)=>lX(Y,Z));if(typeof X==="object"&&X!==null){let Y={};for(let[q,$]of Object.entries(X))Y[q]=lX($,Z);return Y}return X}function K0(X,Z){let Y="";if(Z)Y+=`/**
|
|
395
395
|
* Token object type definition
|
|
396
396
|
*/
|
|
397
397
|
`;return Y+=`type Tokens = ${gY(X,0)};
|
|
398
|
-
`,Y}function
|
|
398
|
+
`,Y}function o1(X,Z,Y){let{customHeader:q,includeJSDoc:$}=Z,U="";if(q)U+=`${q}
|
|
399
399
|
|
|
400
400
|
`;else{let W=Y?` - ${Y.charAt(0).toUpperCase()+Y.slice(1)} Theme`:"";U+=`/**
|
|
401
401
|
`,U+=` * Universe Design System Tokens - Type Definitions${W}
|
|
@@ -409,11 +409,11 @@ export type IconName = typeof icons[number];
|
|
|
409
409
|
`;return U+=`export type Tokens = ${gY(X,0)};
|
|
410
410
|
`,U+`
|
|
411
411
|
`}function gY(X,Z){if(typeof X!=="object"||X===null)return typeof X==="string"?"string":typeof X==="number"?"number":typeof X==="boolean"?"boolean":"any";let Y=" ".repeat(Z+1),q=Object.entries(X);if(q.length===0)return"{}";let $=`{
|
|
412
|
-
`;for(let[U,W]of q){let K=
|
|
413
|
-
`}return $+=" ".repeat(Z)+"}",$}function
|
|
414
|
-
`;for(let K=0;K<U.length;K++){let[z,G]=U[K],
|
|
415
|
-
`;let
|
|
416
|
-
`}return W+=`${q}}`,W}function
|
|
412
|
+
`;for(let[U,W]of q){let K=e1(U)?`"${U}"`:U;$+=`${Y}${K}: ${gY(W,Z+1)};
|
|
413
|
+
`}return $+=" ".repeat(Z)+"}",$}function e1(X){return X.startsWith("@")||X.includes(" ")||X.includes("-")||X.includes("(")||X.includes(")")||X.includes("@")||X.includes(":")||!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(X)}function XX(X,Z,Y=0){if(typeof X!=="object"||X===null)return JSON.stringify(X);let q=" ".repeat(Y),$=" ".repeat(Y+1),U=Object.entries(X);if(U.length===0)return"{}";let W=`{
|
|
414
|
+
`;for(let K=0;K<U.length;K++){let[z,G]=U[K],E=K===U.length-1;if(Z&&typeof G==="string")W+=`${$}/** Token value: ${JSON.stringify(G)} */
|
|
415
|
+
`;let A=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(z)?z:JSON.stringify(z),L=XX(G,Z,Y+1);W+=`${$}${A}: ${L}${E?"":","}
|
|
416
|
+
`}return W+=`${q}}`,W}function X2(X,Z){let Y=Z.typescript?"ts":"js",{moduleType:q="es",customHeader:$}=Z,U=(K)=>{return K.replace(/-([a-z])/g,(z,G)=>G.toUpperCase())},W="";if($)W+=`${$}
|
|
417
417
|
|
|
418
418
|
`;else W+=`/**
|
|
419
419
|
`,W+=` * Design Tokens - Index
|
|
@@ -431,7 +431,7 @@ export type IconName = typeof icons[number];
|
|
|
431
431
|
// Default export points to light theme
|
|
432
432
|
`,W+=`module.exports = require('./light');
|
|
433
433
|
`}return W+`
|
|
434
|
-
`}var
|
|
434
|
+
`}var W0=S(()=>{kX();hX()});var G0={};iX(G0,{validateCSSFiles:()=>Y2,printValidationResults:()=>Z2});import{readFileSync as vY,existsSync as zX}from"fs";import{join as k}from"path";function Y2(X,Z){let Y={isValid:!0,errors:[],warnings:[],checks:[]},q=k(X,"css"),$=k(q,"tokens.css"),U=zX($);if(Y.checks.push({name:"CSS file exists: tokens.css",passed:U,message:U?void 0:"Missing required CSS file: tokens.css"}),!U)Y.errors.push("Missing required CSS file: tokens.css"),Y.isValid=!1;if(Z.$metaData?.tokens?.css?.mediaQuery?.separateThemeFiles??!1){let A=k(q,"tokens.dark.css"),L=zX(A);if(Y.checks.push({name:"CSS file exists: tokens.dark.css",passed:L,message:L?void 0:"Missing required CSS file: tokens.dark.css (separateThemeFiles is enabled)"}),!L)Y.errors.push("Missing required CSS file: tokens.dark.css (separateThemeFiles is enabled)"),Y.isValid=!1}let K=k(q,"tokens.breakpoints.css");if(zX(K))Y.checks.push({name:"CSS file exists: tokens.breakpoints.css",passed:!0,message:void 0});let G=Z.$metaData?.tokens?.css?.hooks?.shortenName;if(G?.enabled&&zX(k(q,"tokens.css"))){let A=vY(k(q,"tokens.css"),"utf8");if(G.prefix)for(let{find:L,replace:H}of G.prefix){let _=`--${MX}-${L}`,Q=`--${H}`,J=A.includes(_),O=A.includes(Q);if(Y.checks.push({name:`Prefix hook applied: ${L} → ${H}`,passed:!J&&O,message:J?`Old prefix "${_}" still found in CSS, should be "${Q}"`:void 0}),J)Y.errors.push(`Prefix transformation failed: "${_}" should be replaced with "${Q}"`),Y.isValid=!1}if(G.suffix)for(let{find:L,replace:H}of G.suffix){let Q=new RegExp(`--[^:]+${L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}:`,"g").test(A);if(Y.checks.push({name:`Suffix hook applied: ${L} → ${H}`,passed:!Q,message:Q?`Old suffix "${L}" still found in CSS variable names`:void 0}),Q)Y.errors.push(`Suffix transformation failed: "${L}" should be removed/replaced with "${H}"`),Y.isValid=!1}}if(zX(k(q,"tokens.css"))){let L=vY(k(q,"tokens.css"),"utf8").match(/:\s*{[^}]+}/g);if(Y.checks.push({name:"No unresolved token references",passed:!L,message:L?`Found unresolved references: ${L.join(", ")}`:void 0}),L)Y.errors.push(`Unresolved token references found: ${L.join(", ")}`),Y.isValid=!1}let E=["tokens.css","tokens.dark.css","tokens.breakpoints.css"];for(let A of E){let L=k(q,A);if(zX(L)){let H=vY(L,"utf8"),_=(H.match(/\{/g)||[]).length-(H.match(/\}/g)||[]).length;if(Y.checks.push({name:`CSS syntax valid: ${A}`,passed:_===0,message:_!==0?`Mismatched braces in ${A}`:void 0}),_!==0)Y.errors.push(`CSS syntax error in ${A}: mismatched braces`),Y.isValid=!1}}return Y}function Z2(X){console.log(`
|
|
435
435
|
|
|
436
436
|
Build Validation Results:`),console.log("========================================================");for(let Z of X.checks){let Y=Z.passed?"✓":"✗";if(console.log(` ${Y} ${Z.name}`),Z.message)console.log(` ${Z.message}`)}if(X.warnings.length>0){console.log(`
|
|
437
437
|
⚠️ Warnings:`);for(let Z of X.warnings)console.log(` ${Z}`)}if(X.errors.length>0){console.log(`
|
|
@@ -439,7 +439,7 @@ Build Validation Results:`),console.log("=======================================
|
|
|
439
439
|
Validation Summary:`),console.log(` - Checks: ${X.checks.filter((Z)=>Z.passed).length}/${X.checks.length} passed`),console.log(` - Errors: ${X.errors.length}`),console.log(` - Warnings: ${X.warnings.length}`),console.log(`
|
|
440
440
|
${X.isValid?"✅":"❌"} Build ${X.isValid?"passed":"failed"}`),console.log(`
|
|
441
441
|
========================================================
|
|
442
|
-
`)}var
|
|
442
|
+
`)}var z0=S(()=>{g()});import{writeFileSync as q2,mkdirSync as $2,existsSync as fY,readFileSync as hY,readdirSync as U2,statSync as K2}from"fs";import{join as V,dirname as FX}from"path";function W2(X,Z,Y=!1,q=!1){let $=[],U=[],W=[];for(let z of X)if(z.fileName.includes("breakpoint"))U.push(`@import url("./css/${z.fileName}");`);else W.push(`@import url("./css/${z.fileName}");`);if($.push(...W),Y)$.push('@import url("./css/tokens.icons.css");');if(q)$.push('@import url("./css/fonts.css");');$.push(...U);let K=`/**
|
|
443
443
|
* ${Z} Design System - Main CSS Entry Point
|
|
444
444
|
* Generated: ${new Date().toISOString()}
|
|
445
445
|
*
|
|
@@ -452,7 +452,7 @@ ${X.isValid?"✅":"❌"} Build ${X.isValid?"passed":"failed"}`),console.log(`
|
|
|
452
452
|
${$.join(`
|
|
453
453
|
`)}
|
|
454
454
|
`;return{fileName:`${Z}.design-system.tokens.css`,content:K+`
|
|
455
|
-
`,theme:void 0}}function
|
|
455
|
+
`,theme:void 0}}function G2(X,Z,Y=!1,q=!1,$,U){let{readFileSync:W}=n("fs"),{join:K}=n("path"),z=[],G=(H)=>{try{let _=K($,"css",H);return W(_,"utf-8")}catch(_){return console.warn(`Could not read ${H}:`,_),""}},E=[];for(let H of X){let _=G(H.fileName);if(!_)continue;if(H.fileName.includes("breakpoint"))E.push(_);else z.push(_)}let A=U?.$paths?.assets?.icons?.excludeFromRaw??!1;if(Y&&!A){let H=G("tokens.icons.css");if(H)z.push(H)}if(q){let H=G("fonts.css");if(H)z.push(H)}z.push(...E);let L=`/**
|
|
456
456
|
* ${Z} Design System - Raw/Inline CSS
|
|
457
457
|
* Generated: ${new Date().toISOString()}
|
|
458
458
|
*
|
|
@@ -467,28 +467,28 @@ ${z.join(`
|
|
|
467
467
|
|
|
468
468
|
`)}
|
|
469
469
|
`;return{fileName:`${Z}.design-system.tokens.raw.css`,content:L+`
|
|
470
|
-
`,theme:void 0}}function
|
|
470
|
+
`,theme:void 0}}function z2(X,Z){let Y=X.replace(/\\/g,"/");if(Z.replace(/\\/g,"/").startsWith(Y))return{valid:!1,error:`⚠️ Compositions directory cannot be inside tokens directory.
|
|
471
471
|
`+` Tokens dir: ${X}
|
|
472
472
|
Compositions dir: ${Z}
|
|
473
|
-
Please move compositions to a separate directory (e.g., './compositions')`};return{valid:!0}}function
|
|
474
|
-
`),G.length===0)
|
|
475
|
-
`);$.push({fileName:z,content:
|
|
476
|
-
`,theme:void 0})}return $}async function
|
|
477
|
-
Starting token build process...`,X.verbose);let{initializeColorspace:q}=await Promise.resolve().then(() => (EX(),sY));await q(),F("Loading token files...",X.verbose);let $=
|
|
478
|
-
Generating CSS files...`,X.verbose);let G=
|
|
479
|
-
Generated icon tokens`,X.verbose)}catch(G){if(X.verbose)console.warn("Could not build icon tokens:",G)}if(X.generateCSS!==!1)try{let G=await PY();if(G.length>0){let
|
|
480
|
-
Processing composition files...`,X.verbose);let O=
|
|
481
|
-
Generating TypeScript files...`,X.verbose);let G=
|
|
482
|
-
Generating JavaScript files...`,X.verbose);let G=
|
|
483
|
-
Generating JSON files...`,X.verbose);let G=
|
|
473
|
+
Please move compositions to a separate directory (e.g., './compositions')`};return{valid:!0}}function L0(X,Z){try{let Y=U2(X,{withFileTypes:!0});for(let q of Y){let $=V(X,q.name);if(q.isDirectory())L0($,Z);else if(q.isFile()&&q.name.endsWith(".json"))try{let U=hY($,"utf-8"),W=JSON.parse(U);if(Array.isArray(W))Z.push(...W);else Z.push(W)}catch(U){console.warn(`⚠️ Failed to parse composition file ${$}:`,U)}}}catch(Y){console.warn(`⚠️ Failed to read directory ${X}:`,Y)}}function A2(X,Z){let Y=[];if(fY(X)){let q=K2(X);if(q.isDirectory())L0(X,Y);else if(q.isFile()&&X.endsWith(".json"))try{let $=hY(X,"utf-8"),U=JSON.parse($);if(Array.isArray(U))Y.push(...U);else Y.push(U)}catch($){console.warn("⚠️ Failed to parse compositions file:",$)}}if(Z&&Y.length===0){let q=V(Z,"compositions.json");if(fY(q))try{let $=hY(q,"utf-8"),U=JSON.parse($);if(Array.isArray(U))Y.push(...U)}catch($){console.warn("⚠️ Failed to parse compositions.json:",$)}}return Y}function A0(X,Z){let Y=Z.$metaData?.tokens?.css?.hooks?.shortenName;if(!Y?.enabled)return X;let q=X;if(Y.prefix&&Array.isArray(Y.prefix))for(let $ of Y.prefix)q=q.replace(new RegExp($.find,"g"),$.replace);if(Y.suffix&&Array.isArray(Y.suffix)){for(let $ of Y.suffix)if(q.endsWith($.find))q=q.substring(0,q.length-$.find.length)+$.replace}return q}function E2(X,Z){let Y=X.match(/^\{(.+)\}$/);if(Y){let $=Y[1].replace(/\./g,"-");return $=A0($,Z),`var(--${$})`}return X.replace(/\{([^}]+)\}/g,(q,$)=>{let U=$.replace(/\./g,"-");return U=A0(U,Z),`var(--${U})`})}function L2(X,Z,Y,q){let $=[],U=X.filter((z)=>z.platform==="css");if(U.length===0)return $;let W=new Map,K="compositions.css";for(let z of U){let G=z.fileName||"";if(G.endsWith(".css"))G=G.slice(0,-4);let E=G?`${G}.css`:K;if(!W.has(E))W.set(E,[]);W.get(E).push(z)}for(let[z,G]of W.entries()){let E=[];if(E.push("/**"),E.push(" * Design System Compositions - Generated Styles"),E.push(" * DO NOT EDIT THIS FILE DIRECTLY"),E.push(" * Generated from composition definitions"),E.push(` * Namespace: ${Z.$metaData?.dsNamespace||"ds"}.${Z.$metaData?.tokenNamespace||"tokens"}`),E.push(` * File: ${z}`),E.push(` */
|
|
474
|
+
`),G.length===0)E.push("/* No compositions defined */");else for(let L of G){E.push(`/* ${L.name} */`);let H=L.groupProperties,_=H&&(H.mediaQuery||H.parentSelector||H.containerQuery||H.customAtRule),Q="",J=[];if(_){if(H.customAtRule){let O=c(H.customAtRule,Y);E.push(`${O} {`),J.push("}"),Q=" "}if(H.mediaQuery){let O=c(H.mediaQuery,Y);E.push(`${Q}${O} {`),J.push("}"),Q+=" "}if(H.containerQuery){let O=c(H.containerQuery,Y);E.push(`${Q}${O} {`),J.push("}"),Q+=" "}if(H.parentSelector){let O=c(H.parentSelector,Y);E.push(`${Q}${O} {`),J.push("}"),Q+=" "}}E.push(`${Q}${L.selector} {`);for(let O of L.properties){let B=E2(O.token,Z);E.push(`${Q} ${O.property}: ${B};`)}E.push(`${Q}}`);while(J.length>0)Q=Q.slice(2),E.push(`${Q}${J.pop()}`);E.push("")}let A=E.join(`
|
|
475
|
+
`);$.push({fileName:z,content:A+`
|
|
476
|
+
`,theme:void 0})}return $}async function H0(X){let Z=Date.now(),Y={tokenCount:0,cssFiles:[],typescriptFiles:[],javascriptFiles:[],jsonFiles:[],duration:0,warnings:[],errors:[]};try{F(`
|
|
477
|
+
Starting token build process...`,X.verbose);let{initializeColorspace:q}=await Promise.resolve().then(() => (EX(),sY));await q(),F("Loading token files...",X.verbose);let $=MY(X.tokensDir);F("Parsing tokens...",X.verbose);let U=H2(X.config),W=NY($,U);if(F(`Found ${W.length} tokens`,X.verbose),Y.tokenCount=W.length,W.length===0&&U.namespace){let G=Object.keys($).filter((E)=>!E.startsWith("$"));if(G.length>0)Y.warnings.push(`⚠️ No tokens found matching tokenNamespace "${U.namespace}". Found root keys: ${G.join(", ")}. Please check if your $metaData.tokenNamespace in designid.config.ts matches.`)}let K=FY(W,U);if(F(`Resolved ${K.length} tokens`,X.verbose),X.generateCSS!==!1){F(`
|
|
478
|
+
Generating CSS files...`,X.verbose);let G=E0(X.config,X.cssOptions),E=mX(K,G);for(let A of E){let L=V(X.outputDir,"css",A.fileName);a(L,A.content),F(` ✓ ${A.fileName}`,X.verbose)}Y.cssFiles=E}if(X.generateCSS!==!1)try{await X0(X.outputDir,X.config),F(`
|
|
479
|
+
Generated icon tokens`,X.verbose)}catch(G){if(X.verbose)console.warn("Could not build icon tokens:",G)}if(X.generateCSS!==!1)try{let G=await PY();if(G.length>0){let E=E0(X.config,X.cssOptions),A=X.config.$metaData?.modes?.isHost??!1,L=X.config.$modes?.default||"light",H=SY(G,{customHeader:uX(X.config),objectPath:X.config.$metaData?.icons?.objectPath||"universe.custom.path.icons",hooks:E.hooks,isHost:A,defaultMode:L}),_=V(X.outputDir,"css",H.fileName);if(a(_,H.content),F(` ✓ Generated ${H.fileName}`,X.verbose),Y.cssFiles)Y.cssFiles.push(H);else Y.cssFiles=[H]}}catch(G){if(X.verbose)console.warn("Could not generate icon CSS:",G)}let z=!1;if(X.generateCSS!==!1)try{let G=X.config.$fonts;if(G&&G.length>0){await IY(G,X.outputDir),F(" ✓ Generated fonts.css",X.verbose),z=!0;let E={fileName:"fonts.css",content:"Generated by appendTypographyTokens",theme:void 0};if(Y.cssFiles)Y.cssFiles.push(E);else Y.cssFiles=[E]}}catch(G){if(X.verbose)console.warn("Could not generate font CSS:",G)}if(X.generateCSS!==!1&&Y.cssFiles.length>0){let G=X.config.$metaData?.tokenNamespace||"tokens",E=Y.cssFiles.some((Q)=>Q.fileName==="tokens.icons.css"),A=X.config.$metaData?.modes?.isHost||!1,L=Y.cssFiles.filter((Q)=>{if(Q.fileName==="tokens.icons.css"||Q.fileName==="fonts.css")return!1;if(A&&Q.fileName.includes("composition"))return!1;return!0}),H=W2(L,G,E,z),_=V(X.outputDir,H.fileName);if(a(_,H.content),F(` ✓ Generated ${H.fileName}`,X.verbose),Y.cssFiles.push(H),A){let Q=G2(Y.cssFiles.filter((O)=>O.fileName!=="tokens.icons.css"&&O.fileName!=="fonts.css"&&!O.fileName.includes(".design-system.tokens.css")),G,E,z,X.outputDir,X.config),J=V(X.outputDir,Q.fileName);a(J,Q.content),F(` ✓ Generated ${Q.fileName} (raw/inline for web components)`,X.verbose),Y.cssFiles.push(Q)}}if(X.generateCSS!==!1&&X.config.$paths.compositionsDir)try{let G=X.config.$paths.baseDir,E=X.config.$paths.tokensDir,A=X.tokensDir,L=E.split("/").filter((O)=>O&&O!=="."&&O!=="..");for(let O=0;O<L.length;O++)A=FX(A);let H=G.split("/").filter((O)=>O&&O!=="."&&O!=="..");for(let O=0;O<H.length;O++)A=FX(A);let _=V(A,G,X.config.$paths.compositionsDir),Q=V(A,G);if(X.verbose)console.log(` Project root: ${A}`),console.log(` Base dir: ${Q}`),console.log(` Compositions dir: ${_}`);let J=z2(X.tokensDir,_);if(!J.valid)console.error(J.error),Y.errors.push(J.error);else{F(`
|
|
480
|
+
Processing composition files...`,X.verbose);let O=A2(_,Q);if(O.length>0){F(` Found ${O.length} composition(s)`,X.verbose);let B=new Map;for(let I of K){let w=Array.isArray(I.path)?I.path.join("."):I.path;B.set(w,I)}let R=L2(O,X.config,B,X.outputDir);for(let I of R){let w=V(X.outputDir,"css",I.fileName);a(w,I.content),F(` ✓ Generated ${I.fileName}`,X.verbose),Y.cssFiles.push(I)}}else F(` No compositions found in ${_}`,X.verbose)}}catch(G){if(X.verbose)console.warn("Could not generate composition CSS:",G)}if(X.generateTypeScript!==!1){F(`
|
|
481
|
+
Generating TypeScript files...`,X.verbose);let G=_2(X.config,X.typescriptOptions),E=await CY(K,G,X.outputDir);for(let A of E){let L=V(X.outputDir,"typescript",A.fileName);a(L,A.content),F(` ✓ Generated ${A.fileName}`,X.verbose)}Y.typescriptFiles=E}if(X.generateJavaScript!==!1){F(`
|
|
482
|
+
Generating JavaScript files...`,X.verbose);let G=Q2(X.config,X.javascriptOptions),E=$0(K,G);for(let A of E){let L=V(X.outputDir,"js",A.fileName);a(L,A.content),F(` ✓ Generated ${A.fileName}`,X.verbose)}Y.javascriptFiles=E}if(X.generateJSON!==!1){F(`
|
|
483
|
+
Generating JSON files...`,X.verbose);let G=O2(K,W,X.config);for(let E of G){let A=V(X.outputDir,"json",E.fileName);a(A,E.content),F(` ✓ Generated ${E.fileName}`,X.verbose)}Y.jsonFiles=G}Y.duration=Date.now()-Z,F(`
|
|
484
484
|
Build completed in ${Y.duration}ms`,X.verbose)}catch(q){let $=q instanceof Error?q.message:String(q);Y.errors.push($),F(`❌ Build failed: ${$}`,X.verbose)}if(X.validate!==!1){F(`
|
|
485
|
-
Validating build output...`,X.verbose);let{validateCSSFiles:q,printValidationResults:$}=await Promise.resolve().then(() => (
|
|
485
|
+
Validating build output...`,X.verbose);let{validateCSSFiles:q,printValidationResults:$}=await Promise.resolve().then(() => (z0(),G0)),U=q(X.outputDir,X.config);if(X.verbose||!U.isValid)$(U);if(!U.isValid)Y.errors.push(...U.errors)}return Y}function H2(X){let Z=X.$metaData,Y=X.$modes?[...Object.values(X.$modes)]:[];return{prefix:Z.dsNamespace||Z.tokenNamespace,namespace:Z.tokenNamespace,generateModes:!0,modes:Y,generateDerivedTokens:!0,generateBreakpointTokens:!0,failOnBrokenReferences:!0,transformName:(q)=>{let $=Z.tokens?.css?.hooks?.shortenName;if($?.enabled){let U=q;if($.prefix)for(let{find:W,replace:K}of $.prefix){let z=W.replace(/\./g,"-").replace(/-$/,""),G=K.replace(/\./g,"-").replace(/-$/,"");U=U.replace(z,G)}if($.suffix){for(let{find:W,replace:K}of $.suffix)if(U.endsWith(W))U=U.substring(0,U.length-W.length)+K}return U}return q}}}function E0(X,Z){let Y=X.$metaData,q=Y.tokens?.css,$=X.$modes?[...Object.values(X.$modes)]:["light","dark"],U=$.length>0?$[0]:"light",W=Y.modes?.isHost??!1;return{...Z,separateThemeFiles:q?.mediaQuery?.separateThemeFiles??!1,rootSelector:":root",generateMediaQueries:!0,customHeader:uX(X),themeSelector:q?.mediaQuery?.match||"[data-theme]",modes:$,defaultMode:U,isHost:W,hooks:q?.hooks}}function _2(X,Z){let Y=X.$metaData;return{...Z,tokenInterface:"DesignTokens",exportNamespace:Y.dsNamespace||Y.tokenNamespace,generateTypes:!0,generateConsts:!0,generateCSSVarMappings:!0,includeJSDoc:!0}}function Q2(X,Z){let Y=X.$modes?[...Object.values(X.$modes)]:["light","dark"];return{...Z,modes:Y,typescript:!0,separateThemeFiles:!0,includeJSDoc:!1,moduleType:"es",customHeader:`/**
|
|
486
486
|
* ${X.$name}
|
|
487
487
|
* Generated: ${new Date().toISOString()}
|
|
488
|
-
*/`}}function
|
|
488
|
+
*/`}}function O2(X,Z,Y){let q=[],$=JSON.stringify({$schema:"https://schemas.designtokens.org/design-tokens.schema.json",$name:Y.$name,$version:Y.$version,tokens:Z.reduce((K,z)=>{return K[z.name]={$type:z.type,$value:z.value,$description:z.description,$extensions:z.extensions},K},{})},null,2);q.push({fileName:"tokens.raw.json",content:$+`
|
|
489
489
|
`});let U=JSON.stringify({$name:Y.$name,$version:Y.$version,tokens:X.reduce((K,z)=>{return K[z.name]={$type:z.type,$value:z.value,$description:z.description,cssVar:z.cssVar},K},{})},null,2);q.push({fileName:"tokens.resolved.json",content:U+`
|
|
490
490
|
`});let W=JSON.stringify({$name:`${Y.$name} - CSS Variables`,$version:Y.$version,variables:X.reduce((K,z)=>{return K[z.cssVar]=z.value,K},{})},null,2);return q.push({fileName:"css-variables.json",content:W+`
|
|
491
|
-
`}),q}function a(X,Z){let Y=FX(X);if(!fY(Y))
|
|
491
|
+
`}),q}function a(X,Z){let Y=FX(X);if(!fY(Y))$2(Y,{recursive:!0});q2(X,Z,"utf-8")}function F(X,Z){if(Z!==!1)console.log(X)}async function mY(X,Z){let Y=typeof globalThis.Bun<"u",q=X,$=null;if(X.endsWith(".ts")&&!Y){let{compileConfigFile:A,getDistConfigFile:L}=await Promise.resolve().then(() => (BX(),IZ)),H=FX(X);await A(H),q=L(H),$=q}let W=(await import(q)).default,K=FX(X),z=(A)=>{if(A.startsWith("../"))return V(K,A);return V(K,W.$paths.baseDir,A)},G=V(K,W.$paths.baseDir,W.$paths.tokensDir),E=Z||z(W.$paths.distDir);try{return await H0({config:W,tokensDir:G,outputDir:E,verbose:!0})}finally{if($){let{existsSync:A,unlinkSync:L}=await import("fs");if(A($))try{L($)}catch(H){}}}}var pY=S(()=>{Y0();kX();W0();hX();TY();wY();SX()});function J2(X,Z,Y){let q=C(X,{isIncludedOriginalValue:!0}),$=v(X,Y);if(!$||!l(X,"mode",{isIncludedOriginalValue:!1}))$=q;return PX(X,$,Z,Y)}function TX(X,Z,Y){let q=J2(X,Z,Y),$=typeof q==="string"?$X(q):null;if($&&($?.length??0)>=1)return qX(q,$,Z,Y);else return B2(X,Z,Y)}function B2(X,Z,Y){return PX(X,tX(X,Z,Y),Z,Y)}function PX(X,Z,Y,q){if(!X)return null;if(X.$type==="color")Z=bX(Z,X,Y,q);else if(X.$type==="composition"||X.$type==="typography")Z=ZX(X,Y,q);return Z}var MX="did";var g=S(()=>{EX();SX();XY();EX();BX();wZ();RZ();MZ();SX();XY();wY();hX();kX();TY();pY()});import{existsSync as I2}from"fs";import{resolve as w2,join as _0}from"path";import R2 from"chokidar";import{execSync as F0}from"child_process";import{existsSync as jX,statSync as uY}from"fs";import{resolve as kY}from"path";async function cY(X,Z=!1){let Y=process.cwd(),q=X||kY(Y,"designid.config.ts"),$=kY(Y,"designid.config.mjs");if(!jX(q))return!1;if(!(!jX($)||jX(q)&&jX($)&&uY(q).mtimeMs>uY($).mtimeMs)){if(Z)console.log("✓ Config file is up to date");return!1}if(Z)console.log("\uD83D\uDD04 Compiling config file...");try{if(F0(`bun build ${q} --outfile ${$} --minify --target node --packages external --no-bundle`,{stdio:Z?"inherit":"pipe"}),Z)console.log(`✅ Config compiled successfully
|
|
492
492
|
`);return!0}catch(W){if(console.error("❌ Failed to compile config file"),W instanceof Error)console.error(W.message);throw W}}g();pY();if(process.argv.includes("--help")||process.argv.includes("-h"))console.log(`
|
|
493
493
|
Watch Tokens - File watcher for design token changes
|
|
494
494
|
|
|
@@ -504,12 +504,12 @@ Example:
|
|
|
504
504
|
bun src/scripts/watch-tokens.ts
|
|
505
505
|
bun src/scripts/watch-tokens.ts --config=./custom-config.ts
|
|
506
506
|
bun src/scripts/watch-tokens.ts --dev
|
|
507
|
-
`),process.exit(0);async function
|
|
508
|
-
`);let
|
|
507
|
+
`),process.exit(0);async function M2(){let X=await o(),{distDir:Z,buildDir:Y}=await d(),q=[/node_modules/,/dist/,/build/,_0(X,Z),_0(X,Y)],$=R2.watch(["**/*.tokens.json","designid.config.ts"],{ignored:q,persistent:!0}),U,W=300,K=!1;function z(A){let L=[A,"./designid.config.ts","./designid.config.mjs","./designid.config.js","./tokens.config.ts","./tokens.config.js"].filter(Boolean);for(let H of L){let _=w2(H);if(I2(_))return _}throw Error(`Config file not found. Tried: ${L.join(", ")}`)}let G=async()=>{if(K){console.log(`[${new Date().toLocaleTimeString()}] Build already in progress, skipping...`);return}clearTimeout(U),U=setTimeout(async()=>{K=!0,console.clear(),process.stdout.write("\x1Bc"),console.log(`[${new Date().toLocaleTimeString()}] Changes detected. Re-building tokens...
|
|
508
|
+
`);let A=(()=>{let L=process.argv.find((H)=>H.startsWith("--config="));return L?L.split("=")[1]:void 0})();try{await cY(A,!1);let L=z(A);console.log(`Using config: ${L}`);let H=await mY(L);if(H.errors.length>0){console.log(`
|
|
509
509
|
❌ Build failed with ${H.errors.length} error${H.errors.length>1?"s":""}:`),H.errors.forEach((_)=>console.log(` - ${_}`)),K=!1;return}if(console.log(`
|
|
510
510
|
✅ Build completed successfully!`),console.log(`Processed ${H.tokenCount} tokens in ${H.duration}ms`),H.cssFiles.length>0)console.log(`Generated ${H.cssFiles.length} CSS files`);if(H.typescriptFiles.length>0)console.log(`Generated ${H.typescriptFiles.length} TypeScript files`);if(H.warnings.length>0)console.log(`
|
|
511
511
|
Warnings:`),H.warnings.forEach((_)=>console.log(` - ${_}`));console.log(`
|
|
512
512
|
Completed at ${new Date().toLocaleTimeString()}
|
|
513
513
|
`)}catch(L){console.error(`
|
|
514
514
|
❌ Build failed:`,L)}finally{K=!1}},300)};$.on("ready",()=>{console.log("Watching for changes in .tokens.json files and designid.config.ts..."),console.log(`Working directory: ${process.cwd()}`),console.log(`Press Ctrl+C to stop watching
|
|
515
|
-
`)}).on("change",(
|
|
515
|
+
`)}).on("change",(A)=>{console.log(`Changed: ${A}`),G().catch((L)=>{console.error("Error during token build:",L)})}).on("add",(A)=>{console.log(`Added: ${A}`),G().catch((L)=>{console.error("Error during token build:",L)})}).on("unlink",(A)=>{console.log(`Deleted: ${A}`),G().catch((L)=>{console.error("Error during token build:",L)})}).on("error",(A)=>{console.error(`Watcher error: ${A}`)});let E=()=>{clearTimeout(U),$.close().then(()=>{console.log("File watcher closed successfully"),process.exit(0)}).catch((A)=>{console.error("Error closing file watcher:",A),process.exit(1)})};process.on("SIGINT",E),process.on("SIGTERM",E),process.on("SIGHUP",E),process.on("uncaughtException",(A)=>{console.error("Uncaught Exception:",A),E()}),process.on("unhandledRejection",(A,L)=>{console.error("Unhandled Rejection at:",L,"reason:",A),E()})}var N2=process.argv[1]?.includes("tokens-watch")||process.argv[1]?.endsWith("watch.js")||import.meta.url===`file://${process.argv[1]}`;if(N2)M2().catch((X)=>{console.error("Error starting watch process:",X),process.exit(1)});export{M2 as runWatch};
|