@designid/tokens 1.2.3 → 1.2.4
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 +123 -98
- package/bin/editor.js +133 -108
- package/bin/watch.js +133 -108
- package/package.json +1 -1
package/bin/build.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as HY}from"node:module";var GY=Object.create;var{getPrototypeOf:zY,defineProperty:m$,getOwnPropertyNames:AY}=Object;var EY=Object.prototype.hasOwnProperty;var LY=($,X,Y)=>{Y=$!=null?GY(zY($)):{};let Z=X||!$||!$.__esModule?m$(Y,"default",{value:$,enumerable:!0}):Y;for(let q of AY($))if(!EY.call(Z,q))m$(Z,q,{get:()=>$[q],enumerable:!0});return Z};var d$=($,X)=>{for(var Y in X)m$($,Y,{get:X[Y],enumerable:!0,configurable:!0,set:(Z)=>X[Y]=()=>Z})};var P=($,X)=>()=>($&&(X=$($=0)),X);var u$=HY(import.meta.url);var d0={};d$(d0,{transformColorValueAsync:()=>BY,transformColorValue:()=>F,transformColorToken:()=>M$,setAlpha:()=>U$,isColor:()=>p,initializeColorspace:()=>QY});import k$ from"colorjs.io";async function p0(){if(R$===null){let{colorspace:$}=await C();R$=$||"hex"}return R$}function _Y(){return R$||"hex"}async function QY(){await p0()}function U$($,X){let Y=new k$($);if(X||X===0)Y.alpha=X/100;return F(Y)}function m0($,X){if(!$)return $;if(X&&X.type!=="color")return $;if(typeof $==="string")$=new k$($);if(typeof $?.to!=="function")return $;let Y=_Y();try{switch(Y){case"hex":return $.to("srgb").toString({format:"hex"});case"rgb":case"srgb":return $.to("srgb").toString();case"srgb-linear":return $.to("srgb-linear").toString();case"display-p3":case"p3":return $.to("p3").toString();case"a98rgb":case"a98-rgb":return $.to("a98rgb").toString();case"prophoto":case"prophoto-rgb":return $.to("prophoto").toString();case"rec2020":case"rec-2020":return $.to("rec2020").toString();case"xyz":case"xyz-d65":return $.to("xyz-d65").toString();case"xyz-d50":return $.to("xyz-d50").toString();case"lab":case"cielab":return $.to("lab").toString();case"lab-d65":return $.to("lab-d65").toString();case"oklab":return $.to("oklab").toString();case"lch":case"cielch":return $.to("lch").toString();case"oklch":return $.to("oklch").toString();case"hsl":return $.to("hsl").toString();case"hsv":case"hsb":return $.to("hsv").toString();case"hwb":return $.to("hwb").toString();case"luv":return $.to("luv").toString();case"lchuv":return $.to("lchuv").toString();case"jzazbz":return $.to("jzazbz").toString();case"jzczhz":return $.to("jzczhz").toString();case"ictcp":return $.to("ictcp").toString();default:return $.to(Y).toString()}}catch(Z){return console.warn(`Unsupported colorspace '${Y}', falling back to hex. Error:`,Z),$.to("srgb").toString({format:"hex"})}}async function BY($,X){return await p0(),m0($,X)}function F($,X){return m0($,X)}function M$($,X,Y,Z){try{if($=T(X,Z),X.$type==="color"&&X.original?.$value&&X.original?.$value!==X.$value){if(S(X.original.$value))$=y(X.original.$value,Y,Z,X);else $=D(X);if(!j(Z)&&X.original?.$extensions?.mode?.[Z])$=X.original.$extensions.mode[Z]}if(S($))$=y($,Y,Z,X);return F($)}catch{return $=T(X,Z),F($)}}function p($){try{if($)return new k$($),!0;return!1}catch{return!1}}var R$=null;var W$=P(()=>{g()});function u0($,X){let Y=$.$extensions?.delimiter?.character||" ",Z=T($,X)??{},q=$.$extensions?.sort??[],U=D($)??{};if(q.length>0)U=Object.keys(U).sort((K,W)=>{let z=q.indexOf(K),G=q.indexOf(W);return z-G}).reduce((K,W)=>{return K[W]=Z[W],K},{});return Object.keys(U).reduce((K,W)=>{let z=D(Z[W]);if(Z[W]?.$type==="color"||Z[W].$property==="color")z=F(z,Z[W]);return[...Array.isArray(K)?K:[K],z]},[]).join(Y).trim()}function OY($,X,Y,Z){return Object.keys(X??{}).reduce((U,K)=>{let W=X[K];if(typeof W==="string"||typeof W==="number")W={$value:W,$type:typeof W,value:W};if(W.$type=W.type||$?.original?.$value?.[K]?.type||W.$type||$.$type,!j(Z)&&u(W,"mode",{isIncludedOriginalValue:!0}))W.$value=T(W,Z);if(W?.$type==="composition"&&(typeof W.$value!=="string"||typeof W.$value!=="number"||S(W.$value))&&Object.keys(W).length>0){if(S(W.$value))return W.$value=y(W.$value,Y,Z,W),{...U,[K]:{...W,$property:K,$type:W.$type,$value:t(W,Y,Z)}};return{...U,[K]:{...W,$property:K,$type:W.$type,$value:t(W,Y,Z)}}}if(W?.$value){let G=y(W.$value,Y,Z,W);return{...U,[K]:{...W,$property:K,$type:W.$type,$value:G}}}return U},{})}function t($,X,Y){let Z=D($,{isIncludedOriginalValue:!0});if(typeof Z==="string"){if(S(Z)){if(Z=l$(Z,X,Y,$),!j(Y)&&u(Z,"mode",{isIncludedOriginalValue:!0}))Z.$value=T(Z,Y)}let q=e(Z);if(q&&(q?.length??0)>1)Z=o(Z,q,X,Y)}else if(Array.isArray(Z))Z=Z.map((q)=>{if(typeof q==="string"&&S(q))return y(q,X,Y,$);return q});if(!$.name)return Z;return $.$value=OY($,Z,X,Y),u0($,Y)}var c$=P(()=>{g()});function D($,X){let{isIncludedOriginalValue:Y=!1,fallbackValue:Z=null}=X??{};if(Y)return $?.original?.$value??$?.$value??$.value??Z;return $?.$value??$?.value??Z}function T($,X){return X&&($?.$extensions?.mode?.[X]||typeof $?.$extensions?.mode?.[X]==="number")?$.$extensions.mode[X]:D($,{fallbackValue:$?.original?.$value??$?.$value??$?.value})??null}function u($,X,{isIncludedOriginalValue:Y=!1}={}){let Z=!1;if(Y&&$?.original?.$extensions?.[X])Z=!0;if($?.$extensions?.[X])Z=!0;return Z}function r$($,X,Y){let Z=D($,{isIncludedOriginalValue:!0});if(!j(Y)&&u($,"mode",{isIncludedOriginalValue:!0}))Z=T($,Y);if(S(Z))return s$(Z,X,Y,$);return Z}function o($,X,Y,Z){let q=X.reduce((U,K)=>{let W=i$(K,Y);if(!W)return U;let z=D(W,{isIncludedOriginalValue:!0});if(S(z))z=y(`{${K}}`,Y,Z,W);return{...U,[K]:N$(W,z,Y,Z)}},{});return $?.replace(/\{([^}]+)\}/g,(U,K)=>{return q[K]!==void 0?q[K]:U})??null}function l$($,X,Y,Z){if(S($))return y($,X,Y,Z);return $}function i$($,X){return X.allTokens.find((Y)=>Y.path.join(".")===$)??null}function y($,X,Y,Z){let q=S($),U=null,K=$??D(Z),W=null;if(q){if(U=i$(q,X),Y&&U&&U?.$extensions?.mode?.[Y]!==U.original?.$extensions?.mode?.[Y])K=U.original?.$extensions?.mode?.[Y],W=U.original?.$extensions?.alpha??W;else if(U?.$extensions?.mode?.[Y])K=U.$extensions.mode[Y],W=U.$extensions?.alpha??W;else if(U?.original?.$value)K=U?.original.$value??U?.$value,W=U?.original.$extensions?.alpha??W}if(K!==$&&S(K))K=y(K,X,Y,Z);if(K&&(W||Z?.$extensions?.alpha||W===0||Z?.original?.$extensions?.alpha===0))W=W??Z?.$extensions?.alpha??null,K=U$(K,W);return K=F(K,U??Z),K??$}function s$($,X,Y,Z){let q=Z?.original?.$extensions?.mode?.[Y]??Z?.original?.$value,U=S(q);if(Y&&U){let K=X.allTokens.find((z)=>z.path.join(".")===U);if(!K)return $;let W=D(K);if(S(W))return s$(W,X,Y,K);if(K?.$extensions?.mode?.[Y])W=K.$extensions.mode[Y];if(W&&K?.$extensions?.alpha)W=U$(K.$value,K.$extensions.alpha);return F(W,K)??$}else if(q)return F(q,Z);return $}function S($){if(typeof $!=="string")return null;let X=/{[^}]+}/g,Y=$.match(X);if(Y?.length!==1)return null;return Y[0].slice(1,-1)}function e($){if(typeof $!=="string")return null;return[...$.matchAll(/\{([^}]+)\}/g)].map(([,Y])=>Y)??null}function $$($){return $}function K$($){return $}var a$=P(()=>{g()});var H2={};d$(H2,{wrapThemeValue:()=>E0,wrapFormatCSSFile:()=>z2,typographyFileName:()=>o0,tokensFileName:()=>n0,removeDirectoryContents:()=>K0,readConfigFile:()=>Z$,namespaceUUID:()=>Y2,iconsFileName:()=>e0,getTokenfileName:()=>X2,getRelativePath:()=>L2,getRelativeCSSPath:()=>E2,getRawTokensFileName:()=>W2,getProjectPaths:()=>i,getProjectModes:()=>z0,getProjectMetaData:()=>C,getProjectFonts:()=>xY,getLazyTokensConfig:()=>n$,getLazyProjectPaths:()=>A0,getLazyProjectModes:()=>G$,getLazyProjectMetaData:()=>H$,getLazyProjectFonts:()=>FY,getLazyProjectData:()=>k,getLazyIcons:()=>S$,getJSDocHeader:()=>K2,getIconDestinationFileName:()=>X$,getFiles:()=>P$,getFileHeader:()=>G0,getDistThemeFileDelimeter:()=>Z2,getDistConfigFile:()=>x$,getDestinationFileName:()=>q2,getDefaultIconObjectPath:()=>$2,getCSSDestinationFileName:()=>U2,getBaseDirectory:()=>A$,getBaseConfigFile:()=>E$,generatedFileHeader:()=>Y$,filterTokensByType:()=>F$,createFileHeaderTitle:()=>z$,compileConfigFile:()=>W0,combineCSSFiles:()=>A2,checkAndCreateDirectory:()=>r,breakpointFileName:()=>t0});import{spawnSync as wY}from"child_process";import{existsSync as h,mkdirSync as IY,readFileSync as JY,unlinkSync as k0,writeFileSync as RY}from"fs";import{readdir as i0,rmdir as MY,unlink as NY}from"fs/promises";import{resolve as s0,join as N,basename as a0,normalize as c0,relative as l0,sep as t$,dirname as r0}from"path";async function $2(){return`${(await L$()).$metaData?.tokenNamespace||"tokens"}.icons`}async function W0($){let Y=N($,"designid.config.ts");if(h(N($,"designid.config.mjs")))k0(N($,"designid.config.mjs"));let Z=N($,"designid.config.js");if(h(Z))k0(Z);if(h(Y)){let q=wY("bun",["build",Y,"--outfile ./designid.config.mjs","--minify","--target","node","--packages","external","--no-bundle"],{stdio:"inherit",cwd:$,shell:!0});if(q.status!==0)console.error("Failed to compile designid.config.mjs with bun."),process.exit(q.status??1);if(q.status===0)return new Promise((U)=>U(!0))}}async function K0($){try{if(h($)){let X=await i0($,{withFileTypes:!0});for(let Y of X){let Z=N($,Y.name);if(Y.isDirectory())await K0(Z),await MY(Z);else await NY(Z)}}}catch(X){console.error(`Error removing contents of ${$}:`,X)}}async function P$($){let X=await i0($,{withFileTypes:!0}),Y=await Promise.all(X.map((Z)=>{let q=s0($,Z.name);return Z.isDirectory()?P$(q):q}));return Array.prototype.concat(...Y)}async function Y2($){let{dsNamespace:X,tokenNamespace:Y}=await C();return`${(X??Y).toUpperCase()}DesignSystem${$.charAt(0).toUpperCase()+$.slice(1)}Tokens`}function X2($,X="d.ts",Y){if(!$)return`tokens.${Y}.config.${X}`;return N($,`tokens.${Y}.config.${X}`)}function Z2($,X){return $.length>1?`.${X}`:""}async function q2($="d.ts",X){let{tokenNamespace:Y}=await C();if(X)return`${Y}-design-system.${X}.tokens.config.${$}`;return`${Y}-design-system.tokens.config.${$}`}async function X$($="json"){let{tokenNamespace:X}=await C();return`${X}-design-system.tokens.svg${$==="d.ts"||$==="js"?".config":""}.${$}`}async function U2(){let{tokenNamespace:$}=await C();return`${$}-design-system.tokens.css`}async function W2(){let{tokenNamespace:$}=await C();return`${$}-design-system-raw.tokens.json`}async function G0($){let{tokenNamespace:X}=await C();return`${X} | ${$}`}function K2($,X){return`/** @type {import("./${$}").${X}} */`}function z$($){return`/* ${G0($)} */`}function r($){if(!h($))IY($,{recursive:!0})}async function Z$($,X=!1){let Y=E$(),Z;if(Y.endsWith(".json"))Z=JSON.parse(JY(Y,"utf8").trim()??"{}");else if(Y.endsWith(".ts"))if(typeof globalThis.Bun!=="undefined"){if(Z=await import(Y),Z.default)Z=Z.default}else{$=$??r0(Y)+"/";let U=x$($);if(U&&(X||!h(U)))await W0($);if(Z=await import(U),Z.default)Z=Z.default}else{$=$??r0(Y)+"/";let q=x$($);if(q&&(X||!h(q)))await W0($);if(Z=await import(q),Z.default)Z=Z.default}return Z}async function A$($=!1){let{baseDir:X}=await i(),Y=process.cwd(),q=N(Y,X),{buildDir:U,distDir:K}=await i();if($)try{r(N(q,U)),r(N(q,K))}catch(W){console.error("Error creating directories:",W)}return q}function x$($){return $?N($,"designid.config.mjs"):N(process.cwd(),"designid.config.mjs")}function E$(){let $=process.argv.find((W)=>W.startsWith("--config=")),[,X]=$?.split("=")??[];if(X)return X;let Y=process.cwd(),Z=x$(Y),q=N(Y,"designid.config.ts"),U=h(Z),K=h(q);if(U)return Z;else if(K)return q;throw console.error("Config file not found"),new Error("Config file not found")}async function i($=!1){let X=E$(),Z=(await Z$(process.cwd(),$)).$paths;if(!Z)throw console.error("Project paths not found"),new Error("Project paths not found");return{configFile:X,...Z}}async function C(){let X=(await Z$(process.cwd())).$metaData;if(!X)throw console.error("Project metaData not found"),new Error("Project metaData not found");if(!X.colorspace)X.colorspace="hex";if(!X.fontNamespace)X.fontNamespace=`${X.dsNamespace}.font`;if(!X?.tokens?.css?.mediaQuery?.match)X={...X??{},tokens:{...X.tokens??{},css:{...X.tokens?.css??{},mediaQuery:{...X.tokens?.css?.mediaQuery??{},match:"[data-theme]"}}}};if(X?.tokens?.css?.mediaQuery&&typeof X.tokens.css.mediaQuery.separateThemeFiles!=="boolean")X.tokens.css.mediaQuery.separateThemeFiles=!1;if(!X.dsNamespace)X.dsNamespace=X.tokenNamespace;let Y=await $2();return{...X,icons:X.icons??{objectPath:Y},dsNamespace:X.dsNamespace}}async function z0(){return(await Z$(process.cwd())).$modes??{default:"light"}}async function L$(){if(!o$){let $=E$();o$=await Z$(process.cwd()),G2=$}return o$}async function G$(){if(!e$)e$=(await L$()).$modes??{default:"light"};return e$}async function H$(){if(!$0){let X=(await L$()).$metaData;if(!X)throw console.error("Project metaData not found"),new Error("Project metaData not found");if(!X.dsNamespace)X.dsNamespace=X.tokenNamespace;let Z=`${X.tokenNamespace||"tokens"}.icons`;$0={...X,icons:X.icons??{objectPath:Z},dsNamespace:X.dsNamespace}}return $0}async function A0($=!1){if(!Y0){let Y=(await L$()).$paths;if(!Y)throw console.error("Project paths not found"),new Error("Project paths not found");Y0={configFile:G2,...Y}}return Y0}async function k(){if(!X0){let{distDir:$,assets:X,buildDir:Y}=await A0(!0),{fontNamespace:Z,tokenNamespace:q,icons:U}=await H$(),K=await A$(),W=process.cwd(),z=N(W,$,"css");X0={distDir:$,assets:X,fontNamespace:Z,__dirname:K,workspaceRoot:W,distCSSPath:z,buildDir:Y,tokenNamespace:q,icons:U}}return X0}async function S$(){if(!Z0){let{icons:$}=await H$();Z0=$}return Z0}async function n$(){if(!q0){let{tokens:$}=await H$();q0=$}return q0}async function xY(){return(await Z$(process.cwd())).$fonts??[]}async function FY(){if(!U0)U0=(await L$()).$fonts??[];return U0}async function E0($){if(j($))return":root";let Y=(await C())?.tokens?.css?.mediaQuery?.match??"[data-theme]";if(Y.startsWith("[")&&Y.endsWith("]"))return`${Y.replace("]",`="${$}"]`)}`;else if(Y.startsWith(".")||Y.startsWith("#"))return`${Y}${$}`;else return`${Y}${$}`}async function z2($,X,Y,Z,q,U={}){let K;if(j(Y))K=X.allTokens;else K=$(X,Y);let z=(await C())?.tokens?.css?.mediaQuery?.separateThemeFiles?"Theme: "+Y:U.headerTitle??"",G=`${z$(z)}
|
|
3
|
-
${Y$}`,
|
|
2
|
+
import{createRequire as HY}from"node:module";var GY=Object.create;var{getPrototypeOf:zY,defineProperty:m$,getOwnPropertyNames:AY}=Object;var EY=Object.prototype.hasOwnProperty;var LY=($,X,Y)=>{Y=$!=null?GY(zY($)):{};let Z=X||!$||!$.__esModule?m$(Y,"default",{value:$,enumerable:!0}):Y;for(let q of AY($))if(!EY.call(Z,q))m$(Z,q,{get:()=>$[q],enumerable:!0});return Z};var d$=($,X)=>{for(var Y in X)m$($,Y,{get:X[Y],enumerable:!0,configurable:!0,set:(Z)=>X[Y]=()=>Z})};var P=($,X)=>()=>($&&(X=$($=0)),X);var u$=HY(import.meta.url);var d0={};d$(d0,{transformColorValueAsync:()=>BY,transformColorValue:()=>F,transformColorToken:()=>M$,setAlpha:()=>U$,isColor:()=>p,initializeColorspace:()=>QY});import k$ from"colorjs.io";async function p0(){if(R$===null){let{colorspace:$}=await C();R$=$||"hex"}return R$}function _Y(){return R$||"hex"}async function QY(){await p0()}function U$($,X){let Y=new k$($);if(X||X===0)Y.alpha=X/100;return F(Y)}function m0($,X){if(!$)return $;if(X&&X.type!=="color")return $;if(typeof $==="string")$=new k$($);if(typeof $?.to!=="function")return $;let Y=_Y();try{switch(Y){case"hex":return $.to("srgb").toString({format:"hex"});case"rgb":case"srgb":return $.to("srgb").toString();case"srgb-linear":return $.to("srgb-linear").toString();case"display-p3":case"p3":return $.to("p3").toString();case"a98rgb":case"a98-rgb":return $.to("a98rgb").toString();case"prophoto":case"prophoto-rgb":return $.to("prophoto").toString();case"rec2020":case"rec-2020":return $.to("rec2020").toString();case"xyz":case"xyz-d65":return $.to("xyz-d65").toString();case"xyz-d50":return $.to("xyz-d50").toString();case"lab":case"cielab":return $.to("lab").toString();case"lab-d65":return $.to("lab-d65").toString();case"oklab":return $.to("oklab").toString();case"lch":case"cielch":return $.to("lch").toString();case"oklch":return $.to("oklch").toString();case"hsl":return $.to("hsl").toString();case"hsv":case"hsb":return $.to("hsv").toString();case"hwb":return $.to("hwb").toString();case"luv":return $.to("luv").toString();case"lchuv":return $.to("lchuv").toString();case"jzazbz":return $.to("jzazbz").toString();case"jzczhz":return $.to("jzczhz").toString();case"ictcp":return $.to("ictcp").toString();default:return $.to(Y).toString()}}catch(Z){return console.warn(`Unsupported colorspace '${Y}', falling back to hex. Error:`,Z),$.to("srgb").toString({format:"hex"})}}async function BY($,X){return await p0(),m0($,X)}function F($,X){return m0($,X)}function M$($,X,Y,Z){try{if($=T(X,Z),X.$type==="color"&&X.original?.$value&&X.original?.$value!==X.$value){if(S(X.original.$value))$=h(X.original.$value,Y,Z,X);else $=D(X);if(!j(Z)&&X.original?.$extensions?.mode?.[Z])$=X.original.$extensions.mode[Z]}if(S($))$=h($,Y,Z,X);return F($)}catch{return $=T(X,Z),F($)}}function p($){try{if($)return new k$($),!0;return!1}catch{return!1}}var R$=null;var W$=P(()=>{g()});function u0($,X){let Y=$.$extensions?.delimiter?.character||" ",Z=T($,X)??{},q=$.$extensions?.sort??[],U=D($)??{};if(q.length>0)U=Object.keys(U).sort((K,W)=>{let G=q.indexOf(K),E=q.indexOf(W);return G-E}).reduce((K,W)=>{return K[W]=Z[W],K},{});return Object.keys(U).reduce((K,W)=>{let G=D(Z[W]);if(Z[W]?.$type==="color"||Z[W].$property==="color")G=F(G,Z[W]);return[...Array.isArray(K)?K:[K],G]},[]).join(Y).trim()}function OY($,X,Y,Z){return Object.keys(X??{}).reduce((U,K)=>{let W=X[K];if(typeof W==="string"||typeof W==="number")W={$value:W,$type:typeof W,value:W};if(W.$type=W.type||$?.original?.$value?.[K]?.type||W.$type||$.$type,!j(Z)&&u(W,"mode",{isIncludedOriginalValue:!0}))W.$value=T(W,Z);if(W?.$type==="composition"&&(typeof W.$value!=="string"||typeof W.$value!=="number"||S(W.$value))&&Object.keys(W).length>0){if(S(W.$value))return W.$value=h(W.$value,Y,Z,W),{...U,[K]:{...W,$property:K,$type:W.$type,$value:t(W,Y,Z)}};return{...U,[K]:{...W,$property:K,$type:W.$type,$value:t(W,Y,Z)}}}if(W?.$value){let E=h(W.$value,Y,Z,W);return{...U,[K]:{...W,$property:K,$type:W.$type,$value:E}}}return U},{})}function t($,X,Y){let Z=D($,{isIncludedOriginalValue:!0});if(typeof Z==="string"){if(S(Z)){if(Z=l$(Z,X,Y,$),!j(Y)&&u(Z,"mode",{isIncludedOriginalValue:!0}))Z.$value=T(Z,Y)}let q=e(Z);if(q&&(q?.length??0)>1)Z=o(Z,q,X,Y)}else if(Array.isArray(Z))Z=Z.map((q)=>{if(typeof q==="string"&&S(q))return h(q,X,Y,$);return q});if(!$.name)return Z;return $.$value=OY($,Z,X,Y),u0($,Y)}var c$=P(()=>{g()});function D($,X){let{isIncludedOriginalValue:Y=!1,fallbackValue:Z=null}=X??{};if(Y)return $?.original?.$value??$?.$value??$.value??Z;return $?.$value??$?.value??Z}function T($,X){return X&&($?.$extensions?.mode?.[X]||typeof $?.$extensions?.mode?.[X]==="number")?$.$extensions.mode[X]:D($,{fallbackValue:$?.original?.$value??$?.$value??$?.value})??null}function u($,X,{isIncludedOriginalValue:Y=!1}={}){let Z=!1;if(Y&&$?.original?.$extensions?.[X])Z=!0;if($?.$extensions?.[X])Z=!0;return Z}function r$($,X,Y){let Z=D($,{isIncludedOriginalValue:!0});if(!j(Y)&&u($,"mode",{isIncludedOriginalValue:!0}))Z=T($,Y);if(S(Z))return s$(Z,X,Y,$);return Z}function o($,X,Y,Z){let q=X.reduce((U,K)=>{let W=i$(K,Y);if(!W)return U;let G=D(W,{isIncludedOriginalValue:!0});if(S(G))G=h(`{${K}}`,Y,Z,W);return{...U,[K]:N$(W,G,Y,Z)}},{});return $?.replace(/\{([^}]+)\}/g,(U,K)=>{return q[K]!==void 0?q[K]:U})??null}function l$($,X,Y,Z){if(S($))return h($,X,Y,Z);return $}function i$($,X){return X.allTokens.find((Y)=>Y.path.join(".")===$)??null}function h($,X,Y,Z){let q=S($),U=null,K=$??D(Z),W=null;if(q){if(U=i$(q,X),Y&&U&&U?.$extensions?.mode?.[Y]!==U.original?.$extensions?.mode?.[Y])K=U.original?.$extensions?.mode?.[Y],W=U.original?.$extensions?.alpha??W;else if(U?.$extensions?.mode?.[Y])K=U.$extensions.mode[Y],W=U.$extensions?.alpha??W;else if(U?.original?.$value)K=U?.original.$value??U?.$value,W=U?.original.$extensions?.alpha??W}if(K!==$&&S(K))K=h(K,X,Y,Z);if(K&&(W||Z?.$extensions?.alpha||W===0||Z?.original?.$extensions?.alpha===0))W=W??Z?.$extensions?.alpha??null,K=U$(K,W);return K=F(K,U??Z),K??$}function s$($,X,Y,Z){let q=Z?.original?.$extensions?.mode?.[Y]??Z?.original?.$value,U=S(q);if(Y&&U){let K=X.allTokens.find((G)=>G.path.join(".")===U);if(!K)return $;let W=D(K);if(S(W))return s$(W,X,Y,K);if(K?.$extensions?.mode?.[Y])W=K.$extensions.mode[Y];if(W&&K?.$extensions?.alpha)W=U$(K.$value,K.$extensions.alpha);return F(W,K)??$}else if(q)return F(q,Z);return $}function S($){if(typeof $!=="string")return null;let X=/{[^}]+}/g,Y=$.match(X);if(Y?.length!==1)return null;return Y[0].slice(1,-1)}function e($){if(typeof $!=="string")return null;return[...$.matchAll(/\{([^}]+)\}/g)].map(([,Y])=>Y)??null}function $$($){return $}function K$($){return $}var a$=P(()=>{g()});var H2={};d$(H2,{wrapThemeValue:()=>E0,wrapFormatCSSFile:()=>z2,typographyFileName:()=>o0,tokensFileName:()=>n0,removeDirectoryContents:()=>K0,readConfigFile:()=>Z$,namespaceUUID:()=>Y2,iconsFileName:()=>e0,getTokenfileName:()=>X2,getRelativePath:()=>L2,getRelativeCSSPath:()=>E2,getRawTokensFileName:()=>W2,getProjectPaths:()=>i,getProjectModes:()=>z0,getProjectMetaData:()=>C,getProjectFonts:()=>xY,getLazyTokensConfig:()=>n$,getLazyProjectPaths:()=>A0,getLazyProjectModes:()=>G$,getLazyProjectMetaData:()=>H$,getLazyProjectFonts:()=>FY,getLazyProjectData:()=>k,getLazyIcons:()=>S$,getJSDocHeader:()=>K2,getIconDestinationFileName:()=>X$,getFiles:()=>P$,getFileHeader:()=>G0,getDistThemeFileDelimeter:()=>Z2,getDistConfigFile:()=>x$,getDestinationFileName:()=>q2,getDefaultIconObjectPath:()=>$2,getCSSDestinationFileName:()=>U2,getBaseDirectory:()=>A$,getBaseConfigFile:()=>E$,generatedFileHeader:()=>Y$,filterTokensByType:()=>F$,createFileHeaderTitle:()=>z$,compileConfigFile:()=>W0,combineCSSFiles:()=>A2,checkAndCreateDirectory:()=>r,breakpointFileName:()=>t0});import{spawnSync as wY}from"child_process";import{existsSync as v,mkdirSync as IY,readFileSync as JY,unlinkSync as k0,writeFileSync as RY}from"fs";import{readdir as i0,rmdir as MY,unlink as NY}from"fs/promises";import{resolve as s0,join as N,basename as a0,normalize as c0,relative as l0,sep as t$,dirname as r0}from"path";async function $2(){return`${(await L$()).$metaData?.tokenNamespace||"tokens"}.icons`}async function W0($){let Y=N($,"designid.config.ts");if(v(N($,"designid.config.mjs")))k0(N($,"designid.config.mjs"));let Z=N($,"designid.config.js");if(v(Z))k0(Z);if(v(Y)){let q=wY("bun",["build",Y,"--outfile ./designid.config.mjs","--minify","--target","node","--packages","external","--no-bundle"],{stdio:"inherit",cwd:$,shell:!0});if(q.status!==0)console.error("Failed to compile designid.config.mjs with bun."),process.exit(q.status??1);if(q.status===0)return new Promise((U)=>U(!0))}}async function K0($){try{if(v($)){let X=await i0($,{withFileTypes:!0});for(let Y of X){let Z=N($,Y.name);if(Y.isDirectory())await K0(Z),await MY(Z);else await NY(Z)}}}catch(X){console.error(`Error removing contents of ${$}:`,X)}}async function P$($){let X=await i0($,{withFileTypes:!0}),Y=await Promise.all(X.map((Z)=>{let q=s0($,Z.name);return Z.isDirectory()?P$(q):q}));return Array.prototype.concat(...Y)}async function Y2($){let{dsNamespace:X,tokenNamespace:Y}=await C();return`${(X??Y).toUpperCase()}DesignSystem${$.charAt(0).toUpperCase()+$.slice(1)}Tokens`}function X2($,X="d.ts",Y){if(!$)return`tokens.${Y}.config.${X}`;return N($,`tokens.${Y}.config.${X}`)}function Z2($,X){return $.length>1?`.${X}`:""}async function q2($="d.ts",X){let{tokenNamespace:Y}=await C();if(X)return`${Y}-design-system.${X}.tokens.config.${$}`;return`${Y}-design-system.tokens.config.${$}`}async function X$($="json"){let{tokenNamespace:X}=await C();return`${X}-design-system.tokens.svg${$==="d.ts"||$==="js"?".config":""}.${$}`}async function U2(){let{tokenNamespace:$}=await C();return`${$}-design-system.tokens.css`}async function W2(){let{tokenNamespace:$}=await C();return`${$}-design-system-raw.tokens.json`}async function G0($){let{tokenNamespace:X}=await C();return`${X} | ${$}`}function K2($,X){return`/** @type {import("./${$}").${X}} */`}function z$($){return`/* ${G0($)} */`}function r($){if(!v($))IY($,{recursive:!0})}async function Z$($,X=!1){let Y=E$(),Z;if(Y.endsWith(".json"))Z=JSON.parse(JY(Y,"utf8").trim()??"{}");else if(Y.endsWith(".ts"))if(typeof globalThis.Bun<"u"){if(Z=await import(Y),Z.default)Z=Z.default}else{$=$??r0(Y)+"/";let U=x$($);if(U&&(X||!v(U)))await W0($);if(Z=await import(U),Z.default)Z=Z.default}else{$=$??r0(Y)+"/";let q=x$($);if(q&&(X||!v(q)))await W0($);if(Z=await import(q),Z.default)Z=Z.default}return Z}async function A$($=!1){let{baseDir:X}=await i(),Y=process.cwd(),q=N(Y,X),{buildDir:U,distDir:K}=await i();if($)try{r(N(q,U)),r(N(q,K))}catch(W){console.error("Error creating directories:",W)}return q}function x$($){return $?N($,"designid.config.mjs"):N(process.cwd(),"designid.config.mjs")}function E$(){let $=process.argv.find((W)=>W.startsWith("--config=")),[,X]=$?.split("=")??[];if(X)return X;let Y=process.cwd(),Z=x$(Y),q=N(Y,"designid.config.ts"),U=v(Z),K=v(q);if(U)return Z;else if(K)return q;throw console.error("Config file not found"),Error("Config file not found")}async function i($=!1){let X=E$(),Z=(await Z$(process.cwd(),$)).$paths;if(!Z)throw console.error("Project paths not found"),Error("Project paths not found");return{configFile:X,...Z}}async function C(){let X=(await Z$(process.cwd())).$metaData;if(!X)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!X.colorspace)X.colorspace="hex";if(!X.fontNamespace)X.fontNamespace=`${X.dsNamespace}.font`;if(!X?.tokens?.css?.mediaQuery?.match)X={...X??{},tokens:{...X.tokens??{},css:{...X.tokens?.css??{},mediaQuery:{...X.tokens?.css?.mediaQuery??{},match:"[data-theme]"}}}};if(X?.tokens?.css?.mediaQuery&&typeof X.tokens.css.mediaQuery.separateThemeFiles!=="boolean")X.tokens.css.mediaQuery.separateThemeFiles=!1;if(!X.dsNamespace)X.dsNamespace=X.tokenNamespace;let Y=await $2();return{...X,icons:X.icons??{objectPath:Y},dsNamespace:X.dsNamespace}}async function z0(){return(await Z$(process.cwd())).$modes??{default:"light"}}async function L$(){if(!o$){let $=E$();o$=await Z$(process.cwd()),G2=$}return o$}async function G$(){if(!e$)e$=(await L$()).$modes??{default:"light"};return e$}async function H$(){if(!$0){let X=(await L$()).$metaData;if(!X)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!X.dsNamespace)X.dsNamespace=X.tokenNamespace;let Z=`${X.tokenNamespace||"tokens"}.icons`;$0={...X,icons:X.icons??{objectPath:Z},dsNamespace:X.dsNamespace}}return $0}async function A0($=!1){if(!Y0){let Y=(await L$()).$paths;if(!Y)throw console.error("Project paths not found"),Error("Project paths not found");Y0={configFile:G2,...Y}}return Y0}async function k(){if(!X0){let{distDir:$,assets:X,buildDir:Y}=await A0(!0),{fontNamespace:Z,tokenNamespace:q,icons:U}=await H$(),K=await A$(),W=process.cwd(),G=N(W,$,"css");X0={distDir:$,assets:X,fontNamespace:Z,__dirname:K,workspaceRoot:W,distCSSPath:G,buildDir:Y,tokenNamespace:q,icons:U}}return X0}async function S$(){if(!Z0){let{icons:$}=await H$();Z0=$}return Z0}async function n$(){if(!q0){let{tokens:$}=await H$();q0=$}return q0}async function xY(){return(await Z$(process.cwd())).$fonts??[]}async function FY(){if(!U0)U0=(await L$()).$fonts??[];return U0}async function E0($){if(j($))return":root";let Y=(await C())?.tokens?.css?.mediaQuery?.match??"[data-theme]";if(Y.startsWith("[")&&Y.endsWith("]"))return`${Y.replace("]",`="${$}"]`)}`;else if(Y.startsWith(".")||Y.startsWith("#"))return`${Y}${$}`;else return`${Y}${$}`}async function z2($,X,Y,Z,q,U={}){let K;if(j(Y))K=X.allTokens;else K=$(X,Y);let G=(await C())?.tokens?.css?.mediaQuery?.separateThemeFiles?"Theme: "+Y:U.headerTitle??"",E=`${z$(G)}
|
|
3
|
+
${Y$}`,A=j(Y)?`:root {
|
|
4
4
|
`:`@media (123prefers-color-scheme: ${Y}) {
|
|
5
5
|
:root {
|
|
6
|
-
`,
|
|
6
|
+
`,z=`${E}
|
|
7
7
|
|
|
8
|
-
${
|
|
8
|
+
${A}`;if(K.forEach((L)=>{if(F$(L,U,q))return;let H=j$(L,X,Y);if(U.transformValue)H=U.transformValue(H);H=K$(H),z+=`${!j(Y)?" ":" "}--${$$(L.name)}: ${H};
|
|
9
9
|
`}),Array.isArray(Z)&&Z.length>1){let L=`
|
|
10
|
-
`;for(let
|
|
11
|
-
`,$(X,
|
|
10
|
+
`;for(let H of Z){if(Y===H)continue;let _=await E0(H);L+=`${!j(Y)?" ":" "}&${_} {
|
|
11
|
+
`,$(X,H).forEach((O)=>{if(F$(O,U,q))return;let I=j$(O,X,H);if(U.transformValue)I=U.transformValue(I);I=K$(I),L+=`${!j(Y)?" ":" "}--${$$(O.name)}: ${I};
|
|
12
12
|
`}),L+=`${!j(Y)?" ":" "}}
|
|
13
13
|
|
|
14
|
-
`}
|
|
14
|
+
`}z+=L}return z+=!j(Y)?` }
|
|
15
15
|
`:`}
|
|
16
|
-
`,
|
|
17
|
-
`:"",
|
|
16
|
+
`,z+=!j(Y)?`}
|
|
17
|
+
`:"",z}function F$($,X,Y){let{namespace:Z}=X.filter??{};if(!$.$type)return!0;if(Z?.length&&$.path){let q=$.path.join("."),U=Z.some((W)=>q.startsWith(W)),K=X.filter?.isInclusion!==void 0&&X.filter.isInclusion;return U&&!K||!U&&K}if(X.filter?.isInclusion!==void 0&&X.filter.isInclusion===!1){if($.$type&&!Y.includes($.$type))return!0}else if(!$.$type||Y.includes($.$type))return!0;return!1}async function A2(){let $=await z0(),{baseDir:X,distDir:Y}=await i(),Z=await P$(N(X,Y,"css")),q=N(X,Y,await U2()),U=Y$+`
|
|
18
18
|
|
|
19
|
-
`,K=[{name:e0,order:100},{name:n0,order:200},{name:o0,order:300},{name:t0,order:400}];if(Z=Z.sort((W,
|
|
20
|
-
`}}),!
|
|
19
|
+
`,K=[{name:e0,order:100},{name:n0,order:200},{name:o0,order:300},{name:t0,order:400}];if(Z=Z.sort((W,G)=>{let E=(A)=>{let z=a0(A,".css"),L=K.find((H)=>z.includes(H.name));for(let H in $)if(z.includes(H)){let _=$[H]===$.default?1:2;return L?L.order+_:0}return L?L.order:0};return E(W)-E(G)}),Z.forEach((W)=>{if(W.endsWith(".css")){let E=`@import url("${E2(W,X,Y)}");`;U+=E+`
|
|
20
|
+
`}}),!v(N(X,Y)))r(N(X,Y));RY(q,U)}function E2($,X,Y){let Z=s0(X,Y);return $.startsWith(Z)?$.slice(Z.length+1):$}function L2($,X,Y,Z){let q=c0($),U=a0(c0(X)),K=q.split(t$),W=K.lastIndexOf(U);if(U===".")return l0(Y,Z).split(t$).join("/");else if(W===-1)throw Error(`Base directory '${U}' not found in '${q}'`);let G=N(...K.slice(0,W+1)),E=N(G,Y),A=N(G,Z);return l0(E,A).split(t$).join("/")}var n0="tokens",t0="breakpoints",o0="typography",e0="icons",Y$=`/*
|
|
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
|
-
*/`,o$=null,G2=null,e$=null,$0=null,Y0=null,X0=null,Z0=null,q0=null,U0=null;var _$=P(()=>{g()});function j($){return $===L0}var L0="light";var _2=P(()=>{_$()});async function H0($){let X=await S$();$=$.replace(/<\?xml[^>]*\?>\s*/,""),$=$.replace(/<!DOCTYPE [^>]*>\s*/,"");let Y=$.match(/<svg[^>]*>/),Z=$.match(/viewBox="([\d\s.]+)"/),[q]=Y??[],U=q;if(q&&U){let W=X?.style?.fill,
|
|
25
|
-
`,Q.linkHref){let
|
|
26
|
-
`}else if(Q?.src&&K){let O=Q.directory??Q.family.toLowerCase().replace(/\s+/g,"-"),
|
|
24
|
+
*/`,o$=null,G2=null,e$=null,$0=null,Y0=null,X0=null,Z0=null,q0=null,U0=null;var _$=P(()=>{g()});function j($){return $===L0}var L0="light";var _2=P(()=>{_$()});async function H0($){let X=await S$();$=$.replace(/<\?xml[^>]*\?>\s*/,""),$=$.replace(/<!DOCTYPE [^>]*>\s*/,"");let Y=$.match(/<svg[^>]*>/),Z=$.match(/viewBox="([\d\s.]+)"/),[q]=Y??[],U=q;if(q&&U){let W=X?.style?.fill,G=/id="[^"]*"/.test(q);if(!U.includes("xmlns="))U=U.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"');if(!G&&W)U=U.replace("<svg",`<svg id="${W}"`);else if(G&&W)U=U.replace(/id="[^"]*"/,`id="${W}"`)}if(Z&&q&&U){let W=Z[1].split(" ").map(Number),G=W[2],E=W[3],A=X?.size??24,z=G/E*A;$=$.replace(/height="[\d.]+px?"/,`height="${A}px"`),$=$.replace(/width="[\d.]+px?"/,`width="${z}px"`);let L=/width="[\d.]+(px)?"/.test(q),H=/height="[\d.]+(px)?"/.test(q);if(!L)U=U.replace("<svg",`<svg width="${z}px"`);else U=U.replace(/width="[\d.]+(px)?"/,`width="${z}px"`);if(!H)U=U.replace("<svg",`<svg height="${A}px"`);else U=U.replace(/height="[\d.]+(px)?"/,`height="${A}px"`);$=$.replace(q,U)}if(!$?.match(/data-style="([^"]*)"/)&&X?.style?.type)$=$.replace("<svg ",`<svg data-style="${X.style.type}" `);return $}var Q2=P(()=>{g()});var B2=P(()=>{_$();g()});import{copyFileSync as SY,existsSync as DY,mkdirSync as O2,statSync as bY}from"fs";import{writeFile as CY}from"fs/promises";import{join as V,relative as VY}from"path";async function _0($,X){try{let{assets:Y,workspaceRoot:Z,distDir:q,__dirname:U}=await k(),K=Y?.fonts?.sourceDir?V(U,Y.fonts.sourceDir):null,W=V("assets","fonts"),G=V(Z,q),E=Y?.fonts?.distDir?V(G,Y.fonts.distDir.replace(/^\.\//,"")):V(G,W);if(!$||!K)return;let A="",z=X&&Y?.fonts?.distDir?V(X,Y.fonts.distDir.replace(/^\.\//,"")):E;for(let Q of $){if(!Q)continue;if(A+=`/**** ${Q.family} ${Q.style} ****/
|
|
25
|
+
`,Q.linkHref){let I=await(await fetch(Q.linkHref)).text();A+=`${I.replace(/\s+/g," ").replace(/:\s+/g,":")}
|
|
26
|
+
`}else if(Q?.src&&K){let O=Q.directory??Q.family.toLowerCase().replace(/\s+/g,"-"),I=V(K,O,Q.src);try{if(!DY(I)||!bY(I).isFile()){console.warn(`Font file not found: ${I}`);continue}}catch{console.warn(`Error accessing font file: ${I}`);continue}try{O2(V(z,O),{recursive:!0}),SY(V(K,O,Q.src),V(z,O,Q.src))}catch(w){console.warn(`Error copying font file ${Q.src}:`,w instanceof Error?w.message:w);continue}let B;if(Y?.fonts?.cssImportPath)B=V(Y.fonts.cssImportPath,O,Q.src).replace(/\\/g,"/");else{let{distCSSPath:w}=await k(),J=X?V(X,"css"):w,R=VY(J,z);B=V(R,O,Q.src).replace(/\\/g,"/")}A+=`@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 k(),
|
|
33
|
-
${
|
|
34
|
-
`)}`;throw new Error(E)}return W}function S2($,X,Y){let Z=[];if(X.generateModes&&$.extensions?.mode){for(let[q,U]of Object.entries($.extensions.mode))if(U!==void 0)Z.push({...$,name:`${$.name}#${q}`,value:U,path:[...$.path,`#${q}`]})}if(X.generateModes&&!$.extensions?.mode&&(Array.isArray($.value)||typeof $.value==="object"&&$.value!==null)){let q=!1,U=!1,K=(W)=>{if(typeof W!=="object"||W===null)return!1;if(W.$extensions?.mode)return!0;return Object.values(W).some((z)=>{if(typeof z==="object"&&z!==null)return K(z);return!1})};if(Array.isArray($.value))q=$.value.some((W)=>typeof W==="string"&&W.includes("{")||typeof W==="object"&&W!==null&&Object.values(W).some((z)=>typeof z==="string"&&z.includes("{"))),U=$.value.some((W)=>K(W));else q=Object.values($.value).some((W)=>typeof W==="string"&&W.includes("{")),U=K($.value);if(q||U){if(["color","shadow","border","background","surface","composition"].includes($.type)){let G;if(Array.isArray($.value))G=$.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,_]of Object.entries(E))if(typeof _==="string"&&_.startsWith("{")&&_.endsWith("}")){let H=_.slice(1,-1),Q=`${H}#dark`,O=Y?.get(H),w=Y?.has(Q)||O?.extensions?.mode?.dark!==void 0||O&&(Array.isArray(O.value)||typeof O.value==="object"&&O.value!==null);if(!H.includes("#dark")&&!H.includes("@dark")&&w)A[L]=`{${Q}}`;else A[L]=_}else A[L]=_;return A}return E});else if(typeof $.value==="object"&&$.value!==null){G={};let E=(A)=>{if(typeof A==="string"){if(A.startsWith("{")&&A.endsWith("}")){let L=A.slice(1,-1),_=`${L}#dark`,H=(O,w=new Set)=>{if(w.has(O))return!1;w.add(O);let B=Y?.get(O);if(!B){let I=O.match(/^(.+)@([^@]+)$/);if(I){let[,J,R]=I,f=Y?.get(J);if(f){if(f.extensions?.mode?.dark!==void 0)return!0;if(f.extensions?.generators)return!0;return H(J,w)}}return!1}if(B.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${O}#dark`))return!0;if(typeof B.value==="string"&&B.value.startsWith("{")&&B.value.endsWith("}")){let I=B.value.slice(1,-1);return H(I,w)}if(Array.isArray(B.value)||typeof B.value==="object"&&B.value!==null){let I=(J)=>{if(typeof J!=="object"||J===null)return!1;if(J.$extensions?.mode)return!0;return Object.values(J).some((R)=>{if(typeof R==="object"&&R!==null)return I(R);return!1})};if(Array.isArray(B.value))return B.value.some((J)=>typeof J==="string"&&J.includes("{")&&H(J.slice(1,-1),new Set(w))||typeof J==="object"&&J!==null&&(Object.values(J).some((R)=>typeof R==="string"&&R.includes("{")&&H(R.slice(1,-1),new Set(w)))||I(J)));else if(typeof B.value==="object")return Object.values(B.value).some((J)=>typeof J==="string"&&J.includes("{")&&H(J.slice(1,-1),new Set(w)))||I(B.value)}return!1},Q=H(L);if(!L.includes("#dark")&&!L.includes("@dark")&&Q)return`{${_}}`}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[_]=E(H);return L}return A};for(let[A,L]of Object.entries($.value))G[A]=E(L)}Z.push({...$,name:`${$.name}#dark`,value:G,path:[...$.path,"#dark"],extensions:{...$.extensions,autoGenerated:!0}})}}}if(X.generateModes&&!$.extensions?.mode&&typeof $.value==="string"&&$.value.startsWith("{")&&$.value.endsWith("}")){let q=$.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 _=E.match(/^(.+)@([^@]+)$/);if(_){let[,H,Q]=_,O=Y?.get(H);if(O){if(O.extensions?.mode?.dark!==void 0)return!0;if(O.extensions?.generators)return!0;return U(H,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 _=L.value.slice(1,-1);return U(_,A)}if(Array.isArray(L.value)||typeof L.value==="object"&&L.value!==null){let _=(H)=>{if(typeof H!=="object"||H===null)return!1;if(H.$extensions?.mode)return!0;return Object.values(H).some((Q)=>{if(typeof Q==="object"&&Q!==null)return _(Q);return!1})};if(Array.isArray(L.value))return L.value.some((H)=>typeof H==="string"&&H.includes("{")&&U(H.slice(1,-1),new Set(A))||typeof H==="object"&&H!==null&&(Object.values(H).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((H)=>typeof H==="string"&&H.includes("{")&&U(H.slice(1,-1),new Set(A)))||_(L.value)}return!1},K=U(q);if(["color","shadow","border","background","surface","composition"].includes($.type)&&K&&K&&!q.includes("#dark")&&!q.includes("@dark")){let E=`{${q}#dark}`;Z.push({...$,name:`${$.name}#dark`,value:E,path:[...$.path,"#dark"],extensions:{...$.extensions,autoGenerated:!0}})}}if(X.generateDerivedTokens&&$.extensions?.generators)for(let q of $.extensions.generators)for(let[U,K]of Object.entries(q.value)){let W=R2($.name,U),{generators:z,...G}=$.extensions;Z.push({...$,name:W,value:$.value,path:[...$.path,U],extensions:{...G,generator:{type:q.type,value:K}}})}if(X.generateBreakpointTokens&&$.extensions?.breakpoints)for(let[q,U]of Object.entries($.extensions.breakpoints)){let K=`${$.name}@${q.replace(/[^a-zA-Z0-9]/g,"_")}`,W=U.$value||U.value;if(W&&typeof W==="object"&&"$value"in W)W=W.$value;else if(!W&&typeof U==="object"){let{...E}=U;if(Object.keys(E).length>0)W=E}let z=U.$extensions||U.$extensions,G=U.$type;if(!G&&U.value&&typeof U.value==="object")G=U.value.$type;Z.push({...$,name:K,value:W,path:[...$.path,`@${q}`],type:G||$.type,extensions:{mediaQuery:q,...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 Z}function uY($,X){let Y=s($.value,X),Z=$.type;if(typeof $.value==="string"&&Q$($.value)){let U=$.value.slice(1,-1),K=X.tokens.get(U);if(K){if(["border","shadow","typography","composition"].includes(K.type))Z=K.type;else if(typeof K.value==="string"&&B$(K.value)){let W=D$(K.value),z=new Set;for(let G of W)if(G.type==="reference"&&G.ref&&typeof G.ref==="string"){let E=G.ref.slice(1,-1),A=X.tokens.get(E);if(A&&["border","shadow","typography","composition"].includes(A.type))z.add(A.type)}if(z.size===1)Z=Array.from(z)[0]}}}if(typeof $.value==="string"&&B$($.value)){let U=D$($.value),K=new Set;for(let W of U)if(W.type==="reference"&&W.ref&&typeof W.ref==="string"){let z=W.ref.slice(1,-1),G=X.tokens.get(z);if(G&&["border","shadow","typography","composition"].includes(G.type))K.add(G.type)}if(K.size===1)Z=Array.from(K)[0]}if(typeof Y==="object"&&Y!==null&&["border","shadow","typography","composition"].includes(Z))Y=c(Y,X);if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=b$($.value,$.extensions.generator.type,$.extensions.generator.value,X);let q=kY($.name,X.options);if(Z==="color"&&typeof Y==="string"&&p(Y))Y=F(Y,$);if(typeof Y==="string"&&m(Y))Y=O$(Y);return{...$,type:Z,value:Y,cssVar:q}}function c($,X){if(typeof $==="string"){if(Q$($))return J0($,X);else if(B$($))return V2($,X)}if(Array.isArray($))return $.map((Y)=>c(Y,X));if(typeof $==="object"&&$!==null){if("$value"in $&&typeof $.$value==="string")return c($.$value,X);if("value"in $&&typeof $.value==="string"&&"$type"in $){if(X.mode&&$.$extensions?.mode?.[X.mode])return c($.$extensions.mode[X.mode],X);return c($.value,X)}if("value"in $&&typeof $.value==="object"&&"$type"in $){let Z=$.value,q=$.$extensions?.delimiter?.character||" ";if($.$type==="composition"&&Z&&typeof Z==="object")return Object.values(Z).map((K)=>c(K,X)).join(q);return c($.value,X)}let Y={};for(let[Z,q]of Object.entries($))Y[Z]=c(q,X);return Y}return $}function s($,X){if(typeof $==="string"){if(B$($))return V2($,X);else if(Q$($))return J0($,X)}else if(typeof $==="object"&&$!==null&&"$ref"in $)return C2($,X);return $}function J0($,X){let Y=$.slice(1,-1),Z=X.tokens.get(Y),q=X.options.modes||[];if(!Z){if(q.length>0){for(let W of q)if(Y.endsWith(`@${W}`)){let z=Y.slice(0,-W.length-1)+`#${W}`;if(Z=X.tokens.get(z),Z)return B0(Z,X);break}}let K=Y.match(/#([^#@]+)$/);if(K){let W=Y.substring(0,K.index),z=K[1];if(Z=X.tokens.get(W),Z){if(Z.extensions?.mode?.[z]){let G=Z.extensions.mode[z],E=s(G,{...X,mode:z});if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)E=b$(E,Z.extensions.generator.type,Z.extensions.generator.value,X);if(Z.type==="color"&&typeof E==="string"&&p(E))E=F(E,Z);if(typeof E==="string"&&m(E))E=O$(E);return E}}}if(q.length>0)for(let W of q){let z=new RegExp(`(@[^@]+)@${W}$`);if(z.test(Y)){let G=Y.replace(z,`$1#${W}`);if(Z=X.tokens.get(G),!Z){let E=G.match(/#([^#@]+)$/);if(E){let A=G.substring(0,E.index),L=E[1];if(Z=X.tokens.get(A),Z&&Z.extensions?.mode?.[L]){let _=Z.extensions.mode[L],H=s(_,{...X,mode:L});if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)H=b$(H,Z.extensions.generator.type,Z.extensions.generator.value,X);if(Z.type==="color"&&typeof H==="string"&&p(H))H=F(H,Z);if(typeof H==="string"&&m(H))H=O$(H);return H}}}else return B0(Z,X);break}}}if(!Z)return console.warn(`Token reference not found: ${$}`),X.brokenReferences.push($),$;return B0(Z,X)}function B0($,X){let Y;if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=b$($.value,$.extensions.generator.type,$.extensions.generator.value,X);else if(X.mode&&$.extensions?.mode?.[X.mode])Y=s($.extensions.mode[X.mode],X);else Y=s($.value,X);if($.type==="color"&&typeof Y==="string"&&p(Y))Y=F(Y,$);if(typeof Y==="string"&&m(Y))Y=O$(Y);return Y}function C2($,X){let Z=$.$ref.slice(2).replace(/\//g,"."),q=X.tokens.get(Z);if(!q)return console.warn(`JSON Pointer reference not found: ${$.$ref}`),X.brokenReferences.push($.$ref),$.$ref;return s(q.value,X)}function V2($,X){let Y=D$($),Z=Y.some((K)=>K.value.includes(",")),q=!0,U=[];for(let K of Y){let W;if(K.type==="reference"&&K.ref){if(typeof K.ref==="string"&&Q$(K.ref)){W=J0(K.ref,X);let z=K.ref.slice(1,-1),G=X.tokens.get(z);if(!G||!["border","shadow","typography","composition"].includes(G.type))q=!1}else if(typeof K.ref==="object"&&"$ref"in K.ref)W=C2(K.ref,X)}else if(W=K.value,K.value.trim()&&K.value.trim()!==",")q=!1;U.push(W)}if(Z&&q)return U.filter((K)=>typeof K==="object"&&K!==null&&typeof K!=="string");return U.map((K)=>String(K)).join("")}function b$($,X,Y,Z){let q=s($,Z);switch(X){case"alpha":if(typeof q==="string")return cY(q,Number(Y)/100);break;case"scale":if(typeof q==="string"&&q.match(/[\d.]+/))return lY(q,Number(Y));break;case"hue":if(typeof q==="string")return rY(q,Number(Y));break;default:return console.warn(`Unknown generator type: ${X}`),q}return q}function kY($,X,Y){let Z=$.replace(/\./g,"-");Z=Z.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),Z=Z.replace(/@[^@#]*(?:screen|width|height|min|max|orientation).*$/i,""),Z=Z.replace(/#[^#]*$/,""),Z=Z.replace(/-@/g,"-").replace(/@/g,"-");let q=Z,U=!0,K=X.prefix||"";if(X.transformName){if(q=X.transformName(Z),q=q.replace(/-+$/,""),q!==Z)U=!1}let W=U&&K?`${K}-${q}`:q,z=Y?`-${Y}`:"";return`--${W}${z}`.replace(/[^a-zA-Z0-9-_]/g,"-")}function cY($,X){try{if(!p($))return $;let Y=new D2($);return Y.alpha=X,F(Y)}catch(Y){return console.warn(`Failed to apply alpha to color "${$}": ${Y}`),$}}function lY($,X){let Y=$.match(/([\d.]+)(\w+)/);if(Y){let[,Z,q]=Y;return`${parseFloat(Z)*X}${q}`}return $}function rY($,X){try{if(!p($))return $;let Z=new D2($).to("oklch");return Z.h=(Z.h+X)%360,F(Z)}catch(Y){return console.warn(`Failed to shift hue for color "${$}": ${Y}`),$}}var R0=P(()=>{x2();W$()});function M0($){if($.type==="typography"||$.type==="fontWeight"||$.type==="fontFamily")return!0;if($.type==="dimension"&&$.name.includes("typography"))return!0;if($.name.includes("typography")||$.name.includes("font"))return!0;return!1}function a($,X,Y){if(Y){if($===X)return":host";return`:host([data-theme="${$}"])`}if($===X)return":root";return`[data-theme="${$}"]`}function C$($,X={}){let{rootSelector:Y=":root",separateThemeFiles:Z=!1,generateMediaQueries:q=!1,customHeader:U,modes:K=["light","dark"]}=X;if(Z)return sY($,X);let W=new Map,z=new Map;for(let B of K)W.set(B,[]);let G=K.join("|"),E=new RegExp(`#(${G})$`);for(let B of $){if(typeof B.value==="string"&&m(B.value))continue;if(M0(B))continue;let I=` ${B.cssVar}: ${v(B.value,B.type)};`;if(q&&B.name.includes("@media")){let R=T$(B);if(R){if(!z.has(R))z.set(R,[]);z.get(R).push(I);continue}}let J=B.name.match(E);if(J){let R=J[1];if(!W.has(R))W.set(R,[]);W.get(R).push(I)}else{let R=K[0]||"light";W.get(R).push(I)}}let A="";if(U)A+=`${U}
|
|
32
|
+
`}}let{distCSSPath:L}=await k(),H=X?V(X,"css"):L,_=`${H}/fonts.css`;O2(H,{recursive:!0}),await CY(_,A,{flag:"w",encoding:"utf-8"})}catch(Y){console.error("Error appending typography tokens:",Y)}}var Q0=P(()=>{g()});function Q$($){if(typeof $!=="string"||!$.startsWith("{")||!$.endsWith("}"))return!1;let X=$.slice(1,-1);return!X.includes("{")&&!X.includes("}")&&X.trim()!==""}function B$($){if(typeof $!=="string")return!1;let X=/\{[^}]+\}/g,Y=$.match(X);return!!(Y&&Y.length>0&&$.length>Y.join("").length)}function D$($){let X=[],Y=/\{[^}]+\}/g,Z=0,q;while((q=Y.exec($))!==null){if(q.index>Z){let K=$.slice(Z,q.index);if(K)X.push({type:"literal",value:K})}let U=q[0];if(U.startsWith("{#/"))X.push({type:"reference",value:U,ref:{$ref:U.slice(2,-1)}});else X.push({type:"reference",value:U,ref:U});Z=q.index+q[0].length}if(Z<$.length){let U=$.slice(Z);if(U)X.push({type:"literal",value:U})}return X}function w2($){return!!$.$extensions?.$mode}function I2($){return!!($.$extensions?.$generators&&Array.isArray($.$extensions.$generators))}function J2($){return!!($.$extensions?.$breakpoints&&typeof $.$extensions.$breakpoints==="object")}function R2($,X){return`${$}${X}`}function M2($){return typeof $==="object"&&$!==null&&"$value"in $}function N2($){return typeof $==="object"&&$!==null&&!("$value"in $)}var x2=()=>{};function F2($){if(typeof $!=="string")return!1;let X=$.trim();return X.startsWith("<svg")&&X.includes("</svg>")}function j2($){if(typeof $!=="string")return!1;return $.startsWith("data:image/png;base64,")||$.startsWith("iVBORw0KGgo")}function P2($){if(typeof $!=="string")return!1;return $.startsWith("data:image/jpeg;base64,")||$.startsWith("data:image/jpg;base64,")||$.startsWith("/9j/")}function gY($){let X=$.trim();return X=X.replace(/\s+/g," ").replace(/>\s+</g,"><").trim(),`data:image/svg+xml;base64,${Buffer.from(X,"utf-8").toString("base64")}`}function yY($){if($.startsWith("data:image/png;base64,"))return $;return`data:image/png;base64,${$}`}function hY($){if($.startsWith("data:image/jpeg;base64,")||$.startsWith("data:image/jpg;base64,"))return $;return`data:image/jpeg;base64,${$}`}function O$($){if(!$||typeof $!=="string")return $;if($.startsWith("data:"))return $;if(F2($))return gY($);else if(j2($))return yY($);else if(P2($))return hY($);return $}function vY($){if(typeof $!=="string")return!1;return $.startsWith("data:image/svg+xml;")||$.startsWith("data:image/png;")||$.startsWith("data:image/jpeg;")||$.startsWith("data:image/jpg;")||$.startsWith("data:image/gif;")||$.startsWith("data:image/webp;")}function m($){return F2($)||j2($)||P2($)||vY($)}import{readFileSync as fY,readdirSync as pY,statSync as mY}from"fs";import{join as dY}from"path";import D2 from"colorjs.io";function O0($){let X={};function Y(Z){let q=pY(Z);for(let U of q){let K=dY(Z,U);if(mY(K).isDirectory())Y(K);else if(U.endsWith(".tokens.json"))try{let G=fY(K,"utf-8");if(!G.trim())continue;let E=JSON.parse(G);b2(X,E)}catch(G){console.warn(`Failed to load token file: ${K}`,G)}}}return Y($),X}function b2($,X){for(let Y in X)if(X[Y]&&typeof X[Y]==="object"&&!Array.isArray(X[Y])){if(!$[Y])$[Y]={};b2($[Y],X[Y])}else $[Y]=X[Y]}function w0($,X={}){let Y=[];function Z(q,U=[]){for(let[K,W]of Object.entries(q)){if(K.startsWith("$"))continue;let G=[...U,K],E=G.join(".");if(M2(W)){let A={path:G,name:E,type:W.$type,value:W.$value,description:W.$description,extensions:W.$extensions?{mode:w2(W)?W.$extensions.$mode:W.$extensions.mode?W.$extensions.mode:void 0,generators:I2(W)?W.$extensions.$generators:W.$extensions.generators?W.$extensions.generators:void 0,breakpoints:J2(W)?W.$extensions.$breakpoints:W.$extensions.breakpoint?W.$extensions.breakpoint:void 0,...Object.fromEntries(Object.entries(W.$extensions).filter(([z])=>!["$mode","$generators","$breakpoints","mode","generators","breakpoint"].includes(z)))}:void 0,original:W};if(!X.namespace||E.startsWith(X.namespace))Y.push(A)}else if(N2(W))Z(W,G)}}return Z($),Y}function I0($,X={}){let Y=[...$],Z=new Map($.map((E)=>[E.name,E]));if(X.generateModes||X.generateDerivedTokens||X.generateBreakpointTokens)for(let E of $){let A=S2(E,X,Z);if(Y.push(...A),X.generateModes){for(let z of A)if(z.extensions?.mode&&!z.name.includes("#")){let L=S2(z,X,Z);Y.push(...L)}}}let q=X.modes||[],U=q.length>0?q[0]:void 0,K={tokens:new Map(Y.map((E)=>[E.name,E])),mode:X.generateModes?U:void 0,options:X,brokenReferences:[]},W=[];for(let E of Y){let A=void 0;for(let H of q)if(E.name.endsWith(`#${H}`)){A=H;break}if(!A&&X.generateModes)A=U;let z={...K,mode:A},L=uY(E,z);W.push(L)}if(X.failOnBrokenReferences!==!1&&K.brokenReferences.length>0){let E=[...new Set(K.brokenReferences)],A=`Token reference${E.length>1?"s":""} not found:
|
|
33
|
+
${E.map((z)=>` - ${z}`).join(`
|
|
34
|
+
`)}`;throw Error(A)}return W}function S2($,X,Y){let Z=[];if(X.generateModes&&$.extensions?.mode){for(let[q,U]of Object.entries($.extensions.mode))if(U!==void 0)Z.push({...$,name:`${$.name}#${q}`,value:U,path:[...$.path,`#${q}`]})}if(X.generateModes&&!$.extensions?.mode&&(Array.isArray($.value)||typeof $.value==="object"&&$.value!==null)){let q=!1,U=!1,K=(W)=>{if(typeof W!=="object"||W===null)return!1;if(W.$extensions?.mode)return!0;return Object.values(W).some((G)=>{if(typeof G==="object"&&G!==null)return K(G);return!1})};if(Array.isArray($.value))q=$.value.some((W)=>typeof W==="string"&&W.includes("{")||typeof W==="object"&&W!==null&&Object.values(W).some((G)=>typeof G==="string"&&G.includes("{"))),U=$.value.some((W)=>K(W));else q=Object.values($.value).some((W)=>typeof W==="string"&&W.includes("{")),U=K($.value);if(q||U){if(["color","shadow","border","background","surface","composition"].includes($.type)){let E;if(Array.isArray($.value))E=$.value.map((A)=>{if(typeof A==="string"&&A.startsWith("{")&&A.endsWith("}")){let z=A.slice(1,-1);if(!z.includes("#dark")&&!z.includes("@dark"))return`{${z}#dark}`;return A}else if(typeof A==="object"&&A!==null){let z={};for(let[L,H]of Object.entries(A))if(typeof H==="string"&&H.startsWith("{")&&H.endsWith("}")){let _=H.slice(1,-1),Q=`${_}#dark`,O=Y?.get(_),I=Y?.has(Q)||O?.extensions?.mode?.dark!==void 0||O&&(Array.isArray(O.value)||typeof O.value==="object"&&O.value!==null);if(!_.includes("#dark")&&!_.includes("@dark")&&I)z[L]=`{${Q}}`;else z[L]=H}else z[L]=H;return z}return A});else if(typeof $.value==="object"&&$.value!==null){E={};let A=(z)=>{if(typeof z==="string"){if(z.startsWith("{")&&z.endsWith("}")){let L=z.slice(1,-1),H=`${L}#dark`,_=(O,I=new Set)=>{if(I.has(O))return!1;I.add(O);let B=Y?.get(O);if(!B){let w=O.match(/^(.+)@([^@]+)$/);if(w){let[,J,R]=w,y=Y?.get(J);if(y){if(y.extensions?.mode?.dark!==void 0)return!0;if(y.extensions?.generators)return!0;return _(J,I)}}return!1}if(B.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${O}#dark`))return!0;if(typeof B.value==="string"&&B.value.startsWith("{")&&B.value.endsWith("}")){let w=B.value.slice(1,-1);return _(w,I)}if(Array.isArray(B.value)||typeof B.value==="object"&&B.value!==null){let w=(J)=>{if(typeof J!=="object"||J===null)return!1;if(J.$extensions?.mode)return!0;return Object.values(J).some((R)=>{if(typeof R==="object"&&R!==null)return w(R);return!1})};if(Array.isArray(B.value))return B.value.some((J)=>typeof J==="string"&&J.includes("{")&&_(J.slice(1,-1),new Set(I))||typeof J==="object"&&J!==null&&(Object.values(J).some((R)=>typeof R==="string"&&R.includes("{")&&_(R.slice(1,-1),new Set(I)))||w(J)));else if(typeof B.value==="object")return Object.values(B.value).some((J)=>typeof J==="string"&&J.includes("{")&&_(J.slice(1,-1),new Set(I)))||w(B.value)}return!1},Q=_(L);if(!L.includes("#dark")&&!L.includes("@dark")&&Q)return`{${H}}`}return z}if(typeof z==="object"&&z!==null){if(z.$extensions?.mode?.dark)return z.$extensions.mode.dark;let L={};for(let[H,_]of Object.entries(z))L[H]=A(_);return L}return z};for(let[z,L]of Object.entries($.value))E[z]=A(L)}Z.push({...$,name:`${$.name}#dark`,value:E,path:[...$.path,"#dark"],extensions:{...$.extensions,autoGenerated:!0}})}}}if(X.generateModes&&!$.extensions?.mode&&typeof $.value==="string"&&$.value.startsWith("{")&&$.value.endsWith("}")){let q=$.value.slice(1,-1),U=(A,z=new Set)=>{if(z.has(A))return!1;z.add(A);let L=Y?.get(A);if(!L){let H=A.match(/^(.+)@([^@]+)$/);if(H){let[,_,Q]=H,O=Y?.get(_);if(O){if(O.extensions?.mode?.dark!==void 0)return!0;if(O.extensions?.generators)return!0;return U(_,z)}}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,z)}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(z))||typeof _==="object"&&_!==null&&(Object.values(_).some((Q)=>typeof Q==="string"&&Q.includes("{")&&U(Q.slice(1,-1),new Set(z)))||H(_)));else if(typeof L.value==="object")return Object.values(L.value).some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(z)))||H(L.value)}return!1},K=U(q);if(["color","shadow","border","background","surface","composition"].includes($.type)&&K&&K&&!q.includes("#dark")&&!q.includes("@dark")){let A=`{${q}#dark}`;Z.push({...$,name:`${$.name}#dark`,value:A,path:[...$.path,"#dark"],extensions:{...$.extensions,autoGenerated:!0}})}}if(X.generateDerivedTokens&&$.extensions?.generators)for(let q of $.extensions.generators)for(let[U,K]of Object.entries(q.value)){let W=R2($.name,U),{generators:G,...E}=$.extensions;Z.push({...$,name:W,value:$.value,path:[...$.path,U],extensions:{...E,generator:{type:q.type,value:K}}})}if(X.generateBreakpointTokens&&$.extensions?.breakpoints)for(let[q,U]of Object.entries($.extensions.breakpoints)){let K=`${$.name}@${q.replace(/[^a-zA-Z0-9]/g,"_")}`,W=U.$value||U.value;if(W&&typeof W==="object"&&"$value"in W)W=W.$value;else if(!W&&typeof U==="object"){let{...A}=U;if(Object.keys(A).length>0)W=A}let G=U.$extensions||U.$extensions,E=U.$type;if(!E&&U.value&&typeof U.value==="object")E=U.value.$type;Z.push({...$,name:K,value:W,path:[...$.path,`@${q}`],type:E||$.type,extensions:{mediaQuery:q,...G?{mode:G.mode||G.$mode,generators:G.generators||G.$generators,...Object.fromEntries(Object.entries(G).filter(([A])=>!["mode","$mode","generators","$generators"].includes(A)))}:{}}})}return Z}function uY($,X){let Y=s($.value,X),Z=$.type;if(typeof $.value==="string"&&Q$($.value)){let U=$.value.slice(1,-1),K=X.tokens.get(U);if(K){if(["border","shadow","typography","composition"].includes(K.type))Z=K.type;else if(typeof K.value==="string"&&B$(K.value)){let W=D$(K.value),G=new Set;for(let E of W)if(E.type==="reference"&&E.ref&&typeof E.ref==="string"){let A=E.ref.slice(1,-1),z=X.tokens.get(A);if(z&&["border","shadow","typography","composition"].includes(z.type))G.add(z.type)}if(G.size===1)Z=Array.from(G)[0]}}}if(typeof $.value==="string"&&B$($.value)){let U=D$($.value),K=new Set;for(let W of U)if(W.type==="reference"&&W.ref&&typeof W.ref==="string"){let G=W.ref.slice(1,-1),E=X.tokens.get(G);if(E&&["border","shadow","typography","composition"].includes(E.type))K.add(E.type)}if(K.size===1)Z=Array.from(K)[0]}if(typeof Y==="object"&&Y!==null&&["border","shadow","typography","composition"].includes(Z))Y=c(Y,X);if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=b$($.value,$.extensions.generator.type,$.extensions.generator.value,X);let q=kY($.name,X.options);if(Z==="color"&&typeof Y==="string"&&p(Y))Y=F(Y,$);if(typeof Y==="string"&&m(Y))Y=O$(Y);return{...$,type:Z,value:Y,cssVar:q}}function c($,X){if(typeof $==="string"){if(Q$($))return J0($,X);else if(B$($))return V2($,X)}if(Array.isArray($))return $.map((Y)=>c(Y,X));if(typeof $==="object"&&$!==null){if("$value"in $&&typeof $.$value==="string")return c($.$value,X);if("value"in $&&typeof $.value==="string"&&"$type"in $){if(X.mode&&$.$extensions?.mode?.[X.mode])return c($.$extensions.mode[X.mode],X);return c($.value,X)}if("value"in $&&typeof $.value==="object"&&"$type"in $){let Z=$.value,q=$.$extensions?.delimiter?.character||" ";if($.$type==="composition"&&Z&&typeof Z==="object")return Object.values(Z).map((K)=>c(K,X)).join(q);return c($.value,X)}let Y={};for(let[Z,q]of Object.entries($))Y[Z]=c(q,X);return Y}return $}function s($,X){if(typeof $==="string"){if(B$($))return V2($,X);else if(Q$($))return J0($,X)}else if(typeof $==="object"&&$!==null&&"$ref"in $)return C2($,X);return $}function J0($,X){let Y=$.slice(1,-1),Z=X.tokens.get(Y),q=X.options.modes||[];if(!Z){if(q.length>0){for(let W of q)if(Y.endsWith(`@${W}`)){let G=Y.slice(0,-W.length-1)+`#${W}`;if(Z=X.tokens.get(G),Z)return B0(Z,X);break}}let K=Y.match(/#([^#@]+)$/);if(K){let W=Y.substring(0,K.index),G=K[1];if(Z=X.tokens.get(W),Z){if(Z.extensions?.mode?.[G]){let E=Z.extensions.mode[G],A=s(E,{...X,mode:G});if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)A=b$(A,Z.extensions.generator.type,Z.extensions.generator.value,X);if(Z.type==="color"&&typeof A==="string"&&p(A))A=F(A,Z);if(typeof A==="string"&&m(A))A=O$(A);return A}}}if(q.length>0)for(let W of q){let G=new RegExp(`(@[^@]+)@${W}$`);if(G.test(Y)){let E=Y.replace(G,`$1#${W}`);if(Z=X.tokens.get(E),!Z){let A=E.match(/#([^#@]+)$/);if(A){let z=E.substring(0,A.index),L=A[1];if(Z=X.tokens.get(z),Z&&Z.extensions?.mode?.[L]){let H=Z.extensions.mode[L],_=s(H,{...X,mode:L});if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)_=b$(_,Z.extensions.generator.type,Z.extensions.generator.value,X);if(Z.type==="color"&&typeof _==="string"&&p(_))_=F(_,Z);if(typeof _==="string"&&m(_))_=O$(_);return _}}}else return B0(Z,X);break}}}if(!Z)return console.warn(`Token reference not found: ${$}`),X.brokenReferences.push($),$;return B0(Z,X)}function B0($,X){let Y;if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=b$($.value,$.extensions.generator.type,$.extensions.generator.value,X);else if(X.mode&&$.extensions?.mode?.[X.mode])Y=s($.extensions.mode[X.mode],X);else Y=s($.value,X);if($.type==="color"&&typeof Y==="string"&&p(Y))Y=F(Y,$);if(typeof Y==="string"&&m(Y))Y=O$(Y);return Y}function C2($,X){let Z=$.$ref.slice(2).replace(/\//g,"."),q=X.tokens.get(Z);if(!q)return console.warn(`JSON Pointer reference not found: ${$.$ref}`),X.brokenReferences.push($.$ref),$.$ref;return s(q.value,X)}function V2($,X){let Y=D$($),Z=Y.some((K)=>K.value.includes(",")),q=!0,U=[];for(let K of Y){let W;if(K.type==="reference"&&K.ref){if(typeof K.ref==="string"&&Q$(K.ref)){W=J0(K.ref,X);let G=K.ref.slice(1,-1),E=X.tokens.get(G);if(!E||!["border","shadow","typography","composition"].includes(E.type))q=!1}else if(typeof K.ref==="object"&&"$ref"in K.ref)W=C2(K.ref,X)}else if(W=K.value,K.value.trim()&&K.value.trim()!==",")q=!1;U.push(W)}if(Z&&q)return U.filter((K)=>typeof K==="object"&&K!==null&&typeof K!=="string");return U.map((K)=>String(K)).join("")}function b$($,X,Y,Z){let q=s($,Z);switch(X){case"alpha":if(typeof q==="string")return cY(q,Number(Y)/100);break;case"scale":if(typeof q==="string"&&q.match(/[\d.]+/))return lY(q,Number(Y));break;case"hue":if(typeof q==="string")return rY(q,Number(Y));break;default:return console.warn(`Unknown generator type: ${X}`),q}return q}function kY($,X,Y){let Z=$.replace(/\./g,"-");Z=Z.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),Z=Z.replace(/@[^@#]*(?:screen|width|height|min|max|orientation).*$/i,""),Z=Z.replace(/#[^#]*$/,""),Z=Z.replace(/-@/g,"-").replace(/@/g,"-");let q=Z,U=!0,K=X.prefix||"";if(X.transformName){if(q=X.transformName(Z),q=q.replace(/-+$/,""),q!==Z)U=!1}let W=U&&K?`${K}-${q}`:q,G=Y?`-${Y}`:"";return`--${W}${G}`.replace(/[^a-zA-Z0-9-_]/g,"-")}function cY($,X){try{if(!p($))return $;let Y=new D2($);return Y.alpha=X,F(Y)}catch(Y){return console.warn(`Failed to apply alpha to color "${$}": ${Y}`),$}}function lY($,X){let Y=$.match(/([\d.]+)(\w+)/);if(Y){let[,Z,q]=Y;return`${parseFloat(Z)*X}${q}`}return $}function rY($,X){try{if(!p($))return $;let Z=new D2($).to("oklch");return Z.h=(Z.h+X)%360,F(Z)}catch(Y){return console.warn(`Failed to shift hue for color "${$}": ${Y}`),$}}var R0=P(()=>{x2();W$()});function M0($){if($.type==="typography"||$.type==="fontWeight"||$.type==="fontFamily")return!0;if($.type==="dimension"&&$.name.includes("typography"))return!0;if($.name.includes("typography")||$.name.includes("font"))return!0;return!1}function a($,X,Y){if(Y){if($===X)return":host";return`:host([data-theme="${$}"])`}if($===X)return":root";return`[data-theme="${$}"]`}function C$($,X={}){let{rootSelector:Y=":root",separateThemeFiles:Z=!1,generateMediaQueries:q=!1,customHeader:U,modes:K=["light","dark"]}=X;if(Z)return sY($,X);let W=new Map,G=new Map;for(let B of K)W.set(B,[]);let E=K.join("|"),A=new RegExp(`#(${E})$`);for(let B of $){if(typeof B.value==="string"&&m(B.value))continue;if(M0(B))continue;let w=` ${B.cssVar}: ${f(B.value,B.type)};`;if(q&&B.name.includes("@media")){let R=T$(B);if(R){if(!G.has(R))G.set(R,[]);G.get(R).push(w);continue}}let J=B.name.match(A);if(J){let R=J[1];if(!W.has(R))W.set(R,[]);W.get(R).push(w)}else{let R=K[0]||"light";W.get(R).push(w)}}let z="";if(U)z+=`${U}
|
|
35
35
|
|
|
36
|
-
`;let L=X.defaultMode||K[0]||"light",
|
|
37
|
-
${
|
|
36
|
+
`;let L=X.defaultMode||K[0]||"light",H=X.isHost||!1,_=W.get(L)||[];if(_.length>0){_.sort();let B=a(L,L,H);z+=`${B} {
|
|
37
|
+
${_.join(`
|
|
38
38
|
`)}
|
|
39
|
-
`;for(let
|
|
39
|
+
`;for(let w of K){if(w===L)continue;let J=W.get(w)||[];if(J.length>0){J.sort();let R=a(w,L,H);if(H)z+=`}
|
|
40
40
|
|
|
41
41
|
${R} {
|
|
42
42
|
${J.join(`
|
|
43
43
|
`)}
|
|
44
|
-
`;else{let
|
|
45
|
-
${
|
|
44
|
+
`;else{let y=R.replace("[data-theme=","&[data-theme=");z+=`
|
|
45
|
+
${y} {
|
|
46
46
|
${J.map((p$)=>` ${p$}`).join(`
|
|
47
47
|
`)}
|
|
48
48
|
}
|
|
49
|
-
`}}}
|
|
50
|
-
`}if(q&&
|
|
51
|
-
${
|
|
49
|
+
`}}}z+=`}
|
|
50
|
+
`}if(q&&G.size>0){let B=a(L,L,H);for(let[w,J]of G)J.sort(),z+=`
|
|
51
|
+
${w} {
|
|
52
52
|
${B} {
|
|
53
53
|
${J.map((R)=>` ${R}`).join(`
|
|
54
54
|
`)}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
`}let Q=[{fileName:"tokens.css",content:
|
|
57
|
+
`}let Q=[{fileName:"tokens.css",content:z}],O=h2($,X);Q.push(...O);let I=v2($,X);return Q.push(...I),Q}function iY($,X){let Y=[];for(let q of $){let K=` ${q.cssVar||V$(q,X)}: ${f(q.value,q.type)};`;Y.push(K)}let Z="";if(X.customHeader)Z+=`${X.customHeader}
|
|
58
58
|
|
|
59
59
|
`;if(Y.length>0)Y.sort(),Z+=`${X.rootSelector||":root"} {
|
|
60
60
|
${Y.join(`
|
|
61
61
|
`)}
|
|
62
62
|
}
|
|
63
|
-
`;return{fileName:"theme.css",content:Z}}function sY($,X){let Y=[],Z=new Map,q=[],U=X.modes||["light","dark"],K=new Set(U),W=U.join("|"),
|
|
63
|
+
`;return{fileName:"theme.css",content:Z}}function sY($,X){let Y=[],Z=new Map,q=[],U=X.modes||["light","dark"],K=new Set(U),W=U.join("|"),G=new RegExp(`#(${W})$`);for(let _ of $){if(T$(_))continue;if(typeof _.value==="string"&&m(_.value))continue;if(M0(_))continue;let Q=_.name.match(G);if(Q){let O=Q[1];if(K.has(O)){if(!Z.has(O))Z.set(O,[]);Z.get(O).push(_)}else q.push(_)}else q.push(_)}if(q.length>0){let _=C$(q,{...X,separateThemeFiles:!1})[0];Y.push({..._,fileName:"tokens.css"})}let E=X.defaultMode||(U.length>0?U[0]:"default"),A=X.isHost||!1;for(let[_,Q]of Z){let O=a(_,E,A),I=iY(Q,{...X,separateThemeFiles:!1,rootSelector:O});Y.push({...I,fileName:`tokens.${_}.css`,theme:_})}let z=aY($,X);Y.push(...z);let L=h2($,X);Y.push(...L);let H=v2($,X);return Y.push(...H),Y}function aY($,X){let Y=new Map;for(let U of $){let K=T$(U);if(K){let W=U.name.match(/@(dark|light)$/),G=W?W[1]:"light";if(!Y.has(K))Y.set(K,new Map);let E=Y.get(K);if(!E.has(G))E.set(G,[]);E.get(G).push(U)}}if(Y.size===0)return[];let Z=`/**
|
|
64
64
|
* Design System Tokens - Responsive Breakpoints
|
|
65
65
|
* Generated: ${new Date().toISOString()}
|
|
66
66
|
*
|
|
@@ -68,14 +68,15 @@ ${Y.join(`
|
|
|
68
68
|
* Each media query section overrides tokens for specific screen sizes.
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
|
-
`,q=Array.from(Y.keys()).sort();for(let U of q){let K=Y.get(U),W=X.defaultMode||(X.modes&&X.modes.length>0?X.modes[0]:"light"),
|
|
71
|
+
`,q=Array.from(Y.keys()).sort();for(let U of q){let K=Y.get(U),W=X.defaultMode||(X.modes&&X.modes.length>0?X.modes[0]:"light"),G=X.isHost||!1;for(let[E,A]of K){let z=[];for(let L of A){let _=` ${L.cssVar||V$(L,X)}: ${f(L.value,L.type)};`;z.push(_)}if(z.length>0){z.sort();let L=a(E,W,G);Z+=`${U} {
|
|
72
72
|
${L} {
|
|
73
|
-
${
|
|
73
|
+
${z.join(`
|
|
74
74
|
`)}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
`}}}return[{fileName:"tokens.breakpoints.css",content:Z.trim()
|
|
78
|
+
`}}}return[{fileName:"tokens.breakpoints.css",content:Z.trim()+`
|
|
79
|
+
`}]}function h2($,X){let Y=new Map;for(let q of $)if(typeof q.value==="string"&&m(q.value)){let U=q.name.match(/@(dark|light)$/),K=U?U[1]:"light";if(!Y.has(K))Y.set(K,[]);Y.get(K).push(q)}let Z=[];if(Y.size===0)return[];if(Y.size===1){let[q,U]=Array.from(Y.entries())[0],K=T2(U,q,X);Z.push({fileName:"tokens.icons.css",content:K})}else for(let[q,U]of Y){let K=T2(U,q,X);Z.push({fileName:`tokens.icons.${q}.css`,content:K})}return Z}function T2($,X,Y){let Z=`/**
|
|
79
80
|
* Design System Tokens - Icons (${X})
|
|
80
81
|
* Generated: ${new Date().toISOString()}
|
|
81
82
|
*
|
|
@@ -83,11 +84,12 @@ ${A.join(`
|
|
|
83
84
|
* Icons are provided as data URIs for direct embedding.
|
|
84
85
|
*/
|
|
85
86
|
|
|
86
|
-
`,q=[];for(let U of $){let W=` ${U.cssVar||V$(U,Y)}: ${
|
|
87
|
+
`,q=[];for(let U of $){let W=` ${U.cssVar||V$(U,Y)}: ${f(U.value,U.type)};`;q.push(W)}if(q.length>0){q.sort();let U=Y.defaultMode||"light",K=Y.isHost||!1,W=a(X,U,K);Z+=`${W} {
|
|
87
88
|
${q.join(`
|
|
88
89
|
`)}
|
|
89
90
|
}
|
|
90
|
-
`}return Z
|
|
91
|
+
`}return Z+`
|
|
92
|
+
`}function V$($,X){let Z=$.name.split("@")[0].replace(/\.$/,"").replace(/\.+/g,"."),q=N0(Z,X.hooks);return`--${X.prefix||w$}-${q.replace(/\./g,"-")}`}function N0($,X,Y){if(!X?.shortenName?.enabled)return $;let Z=$;if(X.shortenName.prefix)for(let q of X.shortenName.prefix)Z=Z.replace(new RegExp(q.find,"g"),q.replace);if(X.shortenName.suffix){for(let q of X.shortenName.suffix)if(Z.endsWith(q.find))Z=Z.substring(0,Z.length-q.find.length)+q.replace}if(Y&&Y!=="light"){let q=`-${Y}`;if(Z.endsWith(q))Z=Z.slice(0,-q.length)}return Z}function v2($,X){let Y=new Map,Z=X.modes||[];for(let U of $)if(M0(U)){if(T$(U))continue;let W=Z.length>0?Z[0]:"default";if(U.name.includes("#")){let G=U.name.split("#"),E=G[G.length-1];if(Z.includes(E))W=E}if(!Y.has(W))Y.set(W,[]);Y.get(W).push(U)}let q=[];for(let[U,K]of Y.entries()){let W=nY(K,U,X,Z);q.push({fileName:`tokens.typography.${U}.css`,content:W})}return q}function nY($,X,Y,Z){let q=`/**
|
|
91
93
|
* Design System Tokens - Typography (${X})
|
|
92
94
|
* Generated: ${new Date().toISOString()}
|
|
93
95
|
*
|
|
@@ -95,19 +97,20 @@ ${q.join(`
|
|
|
95
97
|
* Includes fontSize, fontWeight, fontFamily, lineHeight, and typography compositions.
|
|
96
98
|
*/
|
|
97
99
|
|
|
98
|
-
`,U=new Map;for(let K of $){let W="default";if(K.name.includes("@")){let
|
|
99
|
-
${
|
|
100
|
+
`,U=new Map;for(let K of $){let W="default";if(K.name.includes("@")){let G=K.name.split("@");for(let E of G)if(E.includes("screen_")||E.includes("min_width")||E.includes("max_width")){W=E.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(W))U.set(W,[]);U.get(W).push(K)}for(let[K,W]of U.entries()){let G=[];for(let E of W){let z=` ${E.cssVar||V$(E,Y)}: ${f(E.value,E.type)};`;G.push(z)}if(G.length>0){let E=Y.defaultMode||"light",A=Y.isHost||!1,z=a(X,E,A);if(K==="default")G.sort(),q+=`${z} {
|
|
101
|
+
${G.join(`
|
|
100
102
|
`)}
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
`;else{let L=K.startsWith("(")?K:`(${K})`;q+=`@media ${L} {
|
|
104
|
-
`,q+=` ${
|
|
105
|
-
${
|
|
106
|
+
`,q+=` ${z} {
|
|
107
|
+
${G.sort().map((H)=>` ${H}`).join(`
|
|
106
108
|
`)}
|
|
107
109
|
}
|
|
108
110
|
`,q+=`}
|
|
109
111
|
|
|
110
|
-
`}}}return q
|
|
112
|
+
`}}}return q+`
|
|
113
|
+
`}function f($,X){if($===null||$===void 0)return"";if(typeof $==="object"&&$!==null&&!Array.isArray($)){let Z=$;if(Z.$value!==void 0){if(typeof Z.$value==="string")return Z.$value;return f(Z.$value,Z.$type||X)}}let Y=String($);switch(X){case"color":return tY(Y);case"dimension":return oY(Y);case"duration":return eY(Y);case"fontFamily":return $1(Y);case"fontWeight":return Y1(Y);case"cubicBezier":return X1($);case"shadow":return Z1($);case"border":return q1($);case"typography":return U1($);case"composition":return x0($);default:if(Y.startsWith("data:"))return`"${Y}"`;return Y}}function tY($){if($.startsWith("oklch(")||$.startsWith("rgb(")||$.startsWith("rgba(")||$.startsWith("hsl(")||$.startsWith("hsla(")||$.startsWith("#"))return $;return $}function oY($){if(/^\d+(\.\d+)?(px|rem|em|%|vh|vw|vmin|vmax)$/.test($))return $;if(/^\d+(\.\d+)?$/.test($))return`${$}rem`;return $}function eY($){if(/^\d+(\.\d+)?(s|ms)$/.test($))return $;if(/^\d+(\.\d+)?$/.test($))return`${$}ms`;return $}function $1($){if(($.includes(",")||$.includes(" "))&&!$.startsWith('"')&&!$.startsWith("'"))return`"${$}"`;return $}function Y1($){return{thin:"100","extra-light":"200",light:"300",normal:"400",medium:"500","semi-bold":"600",bold:"700","extra-bold":"800",black:"900"}[$]||$}function X1($){if(Array.isArray($)&&$.length===4)return`cubic-bezier(${$.join(", ")})`;return String($)}function Z1($){if(Array.isArray($))return $.map((X)=>g2(X)).join(", ");return g2($)}function g2($){if(typeof $==="object"&&$!==null){let X=$,Y=X.color||"transparent";if(typeof Y==="string"&&Y.includes("{")&&Y.includes("}")){console.warn(`Unresolved token reference in shadow color: ${Y}`);let q=Y.match(/\{([^}]+)\}/)?.[1];if(q)Y=`var(${`--${w$}-${q.replace(/\./g,"-").replace(/@/g,"-")}`})`}let Z=[X.offsetX||"0",X.offsetY||"0",X.blur||"0",X.spread||"0",Y];if(X.inset)Z.unshift("inset");return Z.join(" ")}return String($)}function q1($){if(typeof $==="object"&&$!==null){let X=$,Y=x(X.width)||"1px",Z=x(X.style)||"solid",q=x(X.color)||"transparent";return`${Y} ${Z} ${q}`}return String($)}function U1($){if(typeof $==="object"&&$!==null){let X=$,Y=X.fontWeight||"normal",Z=X.fontSize||"1rem",q=X.lineHeight||"normal",U=X.fontFamily||"sans-serif";if(U.includes(" ")&&!U.startsWith('"')&&!U.startsWith("'"))U=`'${U}'`;let K;if(Z.includes("/"))K=Z;else K=`${Z}/${q}`;return`${Y} ${K} ${U}`}return String($)}function x0($){if(typeof $!=="object"||$===null)return String($);if(Array.isArray($))return $.map((Y)=>x0(Y)).join(", ");let X=$;if(X.offsetX!==void 0&&X.offsetY!==void 0)return f2(X);if(X.width!==void 0&&X.style!==void 0&&X.color!==void 0){let Y=String(X.width||"1px"),Z=String(X.style||"solid"),q=String(X.color||"transparent");return`${Y} ${Z} ${q}`}if(X.blur!==void 0||X.saturate!==void 0||X.brightness!==void 0)return W1(X);if(X.fontSize!==void 0||X.fontFamily!==void 0)return K1(X);return G1(X)}function f2($){let X=[x($.offsetX)||"0",x($.offsetY)||"0",x($.blur)||"0",x($.spread)||"0",x($.color)||"transparent"];if($.inset&&x($.inset)==="true")X.unshift("inset");return X.join(" ")}function W1($){let X=[];if($.blur)X.push(x($.blur)||"blur(0)");if($.saturate)X.push(x($.saturate)||"saturate(100%)");if($.brightness)X.push(x($.brightness)||"brightness(100%)");if($.contrast)X.push(x($.contrast)||"contrast(100%)");if($.hueRotate)X.push(x($.hueRotate)||"hue-rotate(0deg)");return X.join(" ")||"none"}function K1($){let X=x($.fontWeight)||"normal",Y=x($.fontSize)||"1rem",Z=x($.lineHeight),q=x($.fontFamily)||"sans-serif";if(q.includes(" ")&&!q.startsWith('"')&&!q.startsWith("'"))q=`'${q}'`;if(Y.includes("/"))return`${X} ${Y} ${q}`;else if(Z)return`${X} ${Y}/${Z} ${q}`;return`${X} ${Y} ${q}`}function y2($,X,Y){let Z=$.match(/^\{(.+)\}$/);if(!Z)return $;let U=Z[1].replace(/\./g,"-");if(Y)U=N0(U,{shortenName:Y.$metaData?.tokens?.css?.hooks?.shortenName});return`var(--${U})`}function x($,X,Y){if($===null||$===void 0)return"";if(typeof $==="string"){if($.match(/^\{.+\}$/))return y2($,X||"ds",Y);return $}if(typeof $==="object"&&$.value!==void 0){let Z=String($.value);if(Z.match(/^\{.+\}$/))return y2(Z,X||"ds",Y);return Z}return String($)}function G1($){let X=[];for(let[,q]of Object.entries($)){let U=q;if(typeof q==="object"&&q!==null&&U.$value&&typeof U.$value==="object"){let K=U.$value;if(K.offsetX!==void 0&&K.offsetY!==void 0){let W=f2(K);if(W)X.push(W)}else{let W=x0(K);if(W)X.push(W)}}else{let K=x(q);if(K)X.push(K)}}let Z=X.some((q)=>/^\d/.test(q)&&q.includes(" "))?", ":" ";return X.join(Z)||String($)}function T$($){if($.extensions?.mediaQuery&&typeof $.extensions.mediaQuery==="string"){let Y=$.extensions.mediaQuery;if(Y=Y.replace(/\{universe\.foundation\.breakpoint\.screen\.width\.lg\}/g,"64rem"),!Y.startsWith("@media"))Y=`@media ${Y}`;return Y}let X=$.name.match(/@(media[^@]+)/);if(X)return`@${X[1].replace(/_/g," ")}`;if($.name.includes("@screen_and__min_width__300px_"))return"@media screen and (min-width: 300px)";if($.name.includes("@screen_and__min_width__600px_"))return"@media screen and (min-width: 600px)";if($.name.includes("@")&&$.name.includes("_"))return"@media (unknown-breakpoint)";return null}function g$($){let X=$?.$name||"Design System",Y=$?.$version||"1.0.0",Z=new Date().toISOString();return`/**
|
|
111
114
|
* ${X} - CSS Custom Properties
|
|
112
115
|
* Version: ${Y}
|
|
113
116
|
* Generated: ${Z}
|
|
@@ -131,28 +134,34 @@ ${z.sort().map((_)=>` ${_}`).join(`
|
|
|
131
134
|
*/
|
|
132
135
|
|
|
133
136
|
`;U+=`:root {
|
|
134
|
-
`;let K=[...$].sort((W,
|
|
137
|
+
`;let K=[...$].sort((W,G)=>W.name.localeCompare(G.name));for(let W of K){let G=W.name.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""),E=`${q}-${W.category}-${G}`;if(X.hooks?.shortenName?.enabled)E=N0(E,X.hooks);let A=z1(W.value);U+=` ${E}: url("${A}");
|
|
135
138
|
`}return U+=`}
|
|
136
|
-
`,{fileName:"tokens.icons.css",content:U.trim()
|
|
139
|
+
`,{fileName:"tokens.icons.css",content:U.trim()+`
|
|
140
|
+
`}}var y$=P(()=>{g()});import{readFileSync as A1,existsSync as E1}from"fs";import{join as p2,relative as L1}from"path";async function j0(){try{let{assets:$}=await i(!0),{icons:X}=await C(),Y=await A$(),Z=$?.icons?.distDir??"build",q=p2(Y,Z),U=p2(q,"tokens",await X$("json"));if(!E1(U)){let z=L1(process.cwd(),U);return console.log(`ℹ️ Icon data not found (skipping icon types): ${z}`),console.log(" Run icon build first if you need icon types generated."),[]}let K=JSON.parse(A1(U,"utf8")),W=X?.objectPath??"universe.icons",G=W.split("."),E=K;for(let z of G)if(E&&typeof E==="object"&&z in E)E=E[z];else throw Error(`Icon path ${W} not found in icons file`);let A=[];for(let[z,L]of Object.entries(E))if(typeof L==="object"&&L!==null){for(let[H,_]of Object.entries(L))if(typeof _==="object"&&_!==null){let Q=_;A.push({name:H,category:z,value:Q.$value||"",description:Q.$description||"",style:Q.$style||"",dimensions:Q.$dimensions})}}return A}catch($){if($ instanceof Error){if("code"in $&&$.code!=="ENOENT")console.warn(`⚠️ Could not load icon data: ${$.message}`)}return[]}}async function P0($,X={}){let{generateTypes:Y=!0,generateConsts:Z=!0}=X,q=X.icons;if(!q)q=await j0();let U={...X,icons:q},K=[];if(Y)K.push({fileName:"tokens.types.ts",content:H1($,U),type:"types"});if(Z)K.push({fileName:"tokens.constants.ts",content:_1($,U),type:"constants"});return K.push({fileName:"index.ts",content:Q1(K),type:"index"}),K}function H1($,X){let{tokenInterface:Y="DesignTokens",includeJSDoc:Z=!0,icons:q=[]}=X,U=S0("Type Definitions");if(U+=B1($,Z),U+=O1($,Z),q.length>0)U+=w1(q,Z);return U+=I1($,Y,Z),U+=R1($,Z),U+`
|
|
141
|
+
`}function _1($,X){let{includeJSDoc:Y=!0,icons:Z=[]}=X,q=S0("Token Constants"),U="TokenPaths, CSSVariableNames";if(Z.length>0)U+=", IconNames, IconCategories, Icon";if(q+=`import type { ${U} } from './tokens.types';
|
|
137
142
|
|
|
138
|
-
`,q+=M1($,Y),q+=x1($,Y),Z.length>0)q+=N1(Z,Y);return q+=F1($,Y),q
|
|
143
|
+
`,q+=M1($,Y),q+=x1($,Y),Z.length>0)q+=N1(Z,Y);return q+=F1($,Y),q+`
|
|
144
|
+
`}function Q1($){let X=S0("Main Export");if($.some((Y)=>Y.type==="types"))X+=`export type * from './tokens.types';
|
|
139
145
|
`;if($.some((Y)=>Y.type==="constants"))X+=`export * from './tokens.constants';
|
|
140
146
|
`;return X+=`
|
|
141
|
-
`,X
|
|
147
|
+
`,X+`
|
|
148
|
+
`}function B1($,X){let Y=$.map((q)=>`"${q.name}"`).join(`
|
|
142
149
|
| `),Z="";if(X)Z+=`/**
|
|
143
150
|
* All available token paths as string literals
|
|
144
151
|
*/
|
|
145
152
|
`;return Z+=`export type TokenPaths =
|
|
146
153
|
| ${Y};
|
|
147
154
|
|
|
148
|
-
`,Z
|
|
155
|
+
`,Z+`
|
|
156
|
+
`}function O1($,X){let Y=j1($),Z="";for(let[q,U]of Y){let K=`${S1(q)}TokenValue`,W=new Set(U.map((E)=>I$(E.value))),G=Array.from(W).join(`
|
|
149
157
|
| `);if(X)Z+=`/**
|
|
150
158
|
* Possible values for ${q} tokens
|
|
151
159
|
*/
|
|
152
160
|
`;Z+=`export type ${K} =
|
|
153
|
-
| ${
|
|
161
|
+
| ${G};
|
|
154
162
|
|
|
155
|
-
`}return Z
|
|
163
|
+
`}return Z+`
|
|
164
|
+
`}function w1($,X){let Y="",Z=$.map((K)=>`"${K.name}"`).join(`
|
|
156
165
|
| `);if(X)Y+=`/**
|
|
157
166
|
* All available icon names as string literals
|
|
158
167
|
*/
|
|
@@ -187,7 +196,8 @@ ${z.sort().map((_)=>` ${_}`).join(`
|
|
|
187
196
|
`,Y+=` };
|
|
188
197
|
`,Y+=`}
|
|
189
198
|
|
|
190
|
-
`,Y
|
|
199
|
+
`,Y+`
|
|
200
|
+
`}function I1($,X,Y){let Z="";if(Y)Z+=`/**
|
|
191
201
|
* Design tokens interface with all token paths and their values
|
|
192
202
|
*/
|
|
193
203
|
`;Z+=`export interface ${X} {
|
|
@@ -195,20 +205,23 @@ ${z.sort().map((_)=>` ${_}`).join(`
|
|
|
195
205
|
`;Z+=` "${q.name}": ${I$(q.value)};
|
|
196
206
|
`}return Z+=`}
|
|
197
207
|
|
|
198
|
-
`,Z+=J1($,`${X}Nested`,Y),Z
|
|
208
|
+
`,Z+=J1($,`${X}Nested`,Y),Z+`
|
|
209
|
+
`}function J1($,X,Y){let Z=P1($),q="";if(Y)q+=`/**
|
|
199
210
|
* Design tokens interface with nested structure
|
|
200
211
|
*/
|
|
201
212
|
`;return q+=`export interface ${X} {
|
|
202
213
|
`,q+=m2(Z,1),q+=`}
|
|
203
214
|
|
|
204
|
-
`,q
|
|
215
|
+
`,q+`
|
|
216
|
+
`}function R1($,X){let Z=Array.from(new Set($.map((U)=>U.cssVar))).map((U)=>`"${U}"`).join(`
|
|
205
217
|
| `),q="";if(X)q+=`/**
|
|
206
218
|
* All available CSS variable names
|
|
207
219
|
*/
|
|
208
220
|
`;return q+=`export type CSSVariableNames =
|
|
209
221
|
| ${Z};
|
|
210
222
|
|
|
211
|
-
`,q
|
|
223
|
+
`,q+`
|
|
224
|
+
`}function M1($,X){let Y="";if(X)Y+=`/**
|
|
212
225
|
* Object containing all token values
|
|
213
226
|
*/
|
|
214
227
|
`;Y+=`export const tokenValues = {
|
|
@@ -258,14 +271,16 @@ ${z.sort().map((_)=>` ${_}`).join(`
|
|
|
258
271
|
`,Y+=` return icons.filter(icon => icon.category === category);
|
|
259
272
|
`,Y+=`}
|
|
260
273
|
|
|
261
|
-
`,Y
|
|
274
|
+
`,Y+`
|
|
275
|
+
`}function x1($,X){let Y="";if(X)Y+=`/**
|
|
262
276
|
* Object mapping token paths to CSS variable names
|
|
263
277
|
*/
|
|
264
278
|
`;Y+=`export const cssVariableNames = {
|
|
265
279
|
`;for(let Z of $)Y+=` "${Z.name}": "${Z.cssVar}",
|
|
266
280
|
`;return Y+=`} as const;
|
|
267
281
|
|
|
268
|
-
`,Y
|
|
282
|
+
`,Y+`
|
|
283
|
+
`}function F1($,X){let Y="";if(X)Y+=`/**
|
|
269
284
|
* Get the value of a design token
|
|
270
285
|
*/
|
|
271
286
|
`;if(Y+=`export function getTokenValue<T extends TokenPaths>(tokenPath: T): typeof tokenValues[T] {
|
|
@@ -293,7 +308,8 @@ ${z.sort().map((_)=>` ${_}`).join(`
|
|
|
293
308
|
return tokenPath in tokenValues;
|
|
294
309
|
}
|
|
295
310
|
|
|
296
|
-
`,Y
|
|
311
|
+
`,Y+`
|
|
312
|
+
`}function j1($){let X=new Map;for(let Y of $){if(!X.has(Y.type))X.set(Y.type,[]);X.get(Y.type).push(Y)}return X}function P1($){let X={};for(let Y of $){if(Y.path.some((G)=>G.includes("@")||G.includes("#")||G.includes("-")||G.includes(".")))continue;let q=X,U=[...Y.path];for(let G=0;G<U.length-1;G++){let E=U[G];if(!q[E])q[E]={};q=q[E]}let K=U[U.length-1],W=I$(Y.value);q[K]=W}return X}function m2($,X){let Y="",Z=" ".repeat(X);for(let[q,U]of Object.entries($)){let K=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(q)?q:`"${q}"`;if(typeof U==="object"&&!Array.isArray(U))Y+=`${Z}${K}: {
|
|
297
313
|
`,Y+=m2(U,X+1),Y+=`${Z}};
|
|
298
314
|
`;else Y+=`${Z}${K}: ${U};
|
|
299
315
|
`}return Y}function I$($){if(typeof $==="string")return`"${$}"`;else if(typeof $==="number")return $.toString();else if(typeof $==="boolean")return $.toString();else if(Array.isArray($)){let X=new Set($.map((Z)=>I$(Z)));return`Array<${Array.from(X).join(" | ")}>`}else if($===null)return"null";else if($===void 0)return"undefined";else if(typeof $==="object"&&$!==null)return`{ ${Object.entries($).map(([Z,q])=>`${Z}: ${I$(q)}`).join("; ")} }`;else return"unknown"}function S1($){if(!$||typeof $!=="string")return"";return $.charAt(0).toUpperCase()+$.slice(1)}function S0($){let X=new Date().toISOString();return`/**
|
|
@@ -304,25 +320,25 @@ ${z.sort().map((_)=>` ${_}`).join(`
|
|
|
304
320
|
* Do not edit this file directly - it will be overwritten.
|
|
305
321
|
*/
|
|
306
322
|
|
|
307
|
-
`}var D0=P(()=>{g()});function D1($,X,Y){let Z=D($,{isIncludedOriginalValue:!0}),q=T($,Y);if(!q||!u($,"mode",{isIncludedOriginalValue:!1}))q=Z;return N$($,q,X,Y)}function j$($,X,Y){let Z=D1($,X,Y),q=typeof Z==="string"?e(Z):null;if(q&&(q?.length??0)>=1)return o(Z,q,X,Y);else return b1($,X,Y)}function b1($,X,Y){return N$($,r$($,X,Y),X,Y)}function N$($,X,Y,Z){if(!$)return null;if($.$type==="color")X=M$(X,$,Y,Z);else if($.$type==="composition"||$.$type==="typography")X=t($,Y,Z);return X}var w$="did";var g=P(()=>{W$();c$();a$();W$();_$();_2();Q2();B2();c$();a$();Q0();R0();y$();D0();C0()});import{readFileSync as C1,mkdirSync as V1}from"fs";import{writeFile as u2,readdir as T1,mkdir as g1}from"fs/promises";import{resolve as y1,relative as k2,join as h$,dirname as h1}from"path";import v1 from"lodash";async function c2($){let X=await T1($,{withFileTypes:!0}),Y=await Promise.all(X.map((Z)=>{let q=y1($,Z.name);return Z.isDirectory()?c2(q):q}));return Array.prototype.concat(...Y)}async function T0(){let{assets:$,icons:X,tokenNamespace:Y,__dirname:Z,buildDir:q}=await k(),U=h$(Z,$?.icons?.sourceDir??"icons"),K="build",W=$?.icons?.distDir??"build",
|
|
323
|
+
`}var D0=P(()=>{g()});function D1($,X,Y){let Z=D($,{isIncludedOriginalValue:!0}),q=T($,Y);if(!q||!u($,"mode",{isIncludedOriginalValue:!1}))q=Z;return N$($,q,X,Y)}function j$($,X,Y){let Z=D1($,X,Y),q=typeof Z==="string"?e(Z):null;if(q&&(q?.length??0)>=1)return o(Z,q,X,Y);else return b1($,X,Y)}function b1($,X,Y){return N$($,r$($,X,Y),X,Y)}function N$($,X,Y,Z){if(!$)return null;if($.$type==="color")X=M$(X,$,Y,Z);else if($.$type==="composition"||$.$type==="typography")X=t($,Y,Z);return X}var w$="did";var g=P(()=>{W$();c$();a$();W$();_$();_2();Q2();B2();c$();a$();Q0();R0();y$();D0();C0()});import{readFileSync as C1,mkdirSync as V1}from"fs";import{writeFile as u2,readdir as T1,mkdir as g1}from"fs/promises";import{resolve as y1,relative as k2,join as h$,dirname as h1}from"path";import v1 from"lodash";async function c2($){let X=await T1($,{withFileTypes:!0}),Y=await Promise.all(X.map((Z)=>{let q=y1($,Z.name);return Z.isDirectory()?c2(q):q}));return Array.prototype.concat(...Y)}async function T0(){let{assets:$,icons:X,tokenNamespace:Y,__dirname:Z,buildDir:q}=await k(),U=h$(Z,$?.icons?.sourceDir??"icons"),K="build",W=$?.icons?.distDir??"build",G=h$(Z,W),E=h$(Z,q,"icons");if(!$?.icons?.sourceDir){console.warn("Skipping icon build: iconsDir is not defined in the project paths.");return}r(h$(Z,q));let A=(await c2(U)).filter((B)=>B.endsWith(".svg")),H=(await Promise.all(A.map(async(B)=>{let w=C1(B,"utf8").replace(/(\s+(?=(?:[^"]*"[^"]*")*[^"]*$))/g," ").trim()??"";w=await H0(w);let J=k2(U,B).split("/").pop(),R=(w.match(/name="(.*?)"/)??[])[1]??J?.replace(".svg",""),y=(w.match(/data-style="(.*?)"/)??[])[1],p$=(w.match(/description="(.*?)"/)??[])[1],[f0]=w.match(/<svg[^>]*>/)??[],[,WY]=f0?.match(/width="([\d.]+)(px)?"/)??[],[,KY]=f0?.match(/height="([\d.]+)(px)?"/)??[];if(y!=="animated"&&y!=="custom")return{path:B,folder:k2(U,B).split("/").slice(0,-1).concat(R),file:J,style:y,content:w,name:R,dimensions:{width:Number(WY),height:Number(KY)},description:p$??""};return}))).filter((B)=>B!==void 0).reduce((B,w)=>{if(w?.style!=="animated"&&w?.style!=="custom"&&w)V0(B,w.folder.join("."),{$type:"icon",$name:w.name,$description:w.description,$style:w.style,$value:w.content,$dimensions:w.dimensions,...f1(B,w.folder.join("."))});return B},{}),_=X?.objectPath??`${Y}.icons`;Object.keys(H).forEach(async(B)=>{let w=`${E}/${B}`,J=`${w}/svg.${B}.tokens.json`;await g1(w,{recursive:!0});let R=V0({},`${_}${_?".":""}${B}`,H[B]);await u2(J,JSON.stringify(R,null,2),{flag:"w",encoding:"utf-8"})});let Q=`${G}/tokens/${await X$("json")}`,O=h1(Q);V1(O,{recursive:!0});let I=V0({},_,H);await u2(Q,JSON.stringify(I,null,2),{flag:"w",encoding:"utf-8"})}var V0,f1,DX;var l2=P(()=>{g();({set:V0,get:f1}=v1);DX=T0().catch(($)=>{console.error($),process.exit(1)})});function s2($,X={}){let Y=[],Z=X.typescript?"ts":"js",q=X.modes||[],U=$.filter((W)=>W.extensions?.mediaQuery||W.name.includes("@screen")||W.name.includes("@_")),K=$.filter((W)=>!W.extensions?.mediaQuery&&!W.name.includes("@screen")&&!W.name.includes("@_"));if(X.separateThemeFiles&&q.length>0){let W=q.join("|"),G=new RegExp(`#(${W})$`),E=new Map;for(let A of q)E.set(A,[]);for(let A of K){let z=A.name.match(G);if(z){let L=z[1];E.get(L).push(A)}else{let L=q[0];E.get(L).push(A)}}for(let A of q){let z=E.get(A)||[];if(z.length>0){if(X.typescript){let L=a2(z,A);Y.push({fileName:`${A}.d.ts`,content:c1(L,X,A),theme:A})}Y.push({fileName:`${A}.${Z}`,content:i2(z,{...X,theme:A}),theme:A})}}}else Y.push({fileName:`tokens.${Z}`,content:i2(K,X)});if(U.length>0)Y.push({fileName:`breakpoints.${Z}`,content:p1(U,$,X)});if(X.separateThemeFiles&&Y.length>1)Y.push({fileName:`index.${Z}`,content:r1(Y,X)});return Y}function p1($,X,Y={}){let{typescript:Z,includeJSDoc:q,moduleType:U="es",customHeader:K,modes:W=[]}=Y,G=new Map(X.map((L)=>[L.name,L])),E={};for(let L of $){let H=L.extensions?.mediaQuery||m1(L.name),_=W.length>0?W[0]:"default";for(let I of W)if(L.name.includes(`#${I}`)){_=I;break}if(typeof H==="string"&&H.includes("{")&&H.includes("}"))H=u1(H,G);if(!E[H])E[H]={};if(!E[H][_])E[H][_]={};let Q=d1(L.name),O=k1(Q,v$(L.value,G));E[H][_]={...E[H][_],...O}}let A=Object.keys(E).sort((L,H)=>{let _=r2(L),Q=r2(H);return _-Q}).reduce((L,H)=>{return L[H]=E[H],L},{}),z="";if(K)z+=`${K}
|
|
308
324
|
|
|
309
|
-
`;else
|
|
310
|
-
`,
|
|
311
|
-
`,
|
|
312
|
-
`,
|
|
313
|
-
`,
|
|
325
|
+
`;else z+=`/**
|
|
326
|
+
`,z+=` * Design Tokens - Breakpoints
|
|
327
|
+
`,z+=` * Auto-generated from design token definitions
|
|
328
|
+
`,z+=` * Do not edit this file directly
|
|
329
|
+
`,z+=` */
|
|
314
330
|
|
|
315
|
-
`;if(Z)
|
|
316
|
-
`;if(U==="es"){if(Z)
|
|
331
|
+
`;if(Z)z+=n2(A,q),z+=`
|
|
332
|
+
`;if(U==="es"){if(Z)z+=`const breakpoints: Tokens = ${n(A,q,0)};
|
|
317
333
|
|
|
318
|
-
`;else
|
|
334
|
+
`;else z+=`const breakpoints = ${n(A,q,0)};
|
|
319
335
|
|
|
320
|
-
`;
|
|
321
|
-
`}else
|
|
336
|
+
`;z+=`export default breakpoints;
|
|
337
|
+
`}else z+=`const breakpoints = ${n(A,q,0)};
|
|
322
338
|
|
|
323
|
-
`,
|
|
324
|
-
`,
|
|
325
|
-
`;return
|
|
339
|
+
`,z+=`module.exports = breakpoints;
|
|
340
|
+
`,z+=`module.exports.default = breakpoints;
|
|
341
|
+
`;return z}function m1($){if($.includes("@_max_width_")){let X=$.match(/@_max_width___(.+?)__/);if(X)return`screen and (max-width: {${X[1].replace(/_/g,".")}})`}if($.includes("@_min_width_")){let X=$.match(/@_min_width___(.+?)__/);if(X)return`screen and (min-width: {${X[1].replace(/_/g,".")}})`}return"screen"}function d1($){let X=$.replace(/@_.*?__/,"").replace(/@screen.*/,"").replace(/#[^#]*$/,"").replace(/^universe\./,"");return X=X.replace(/_universe_foundation_breakpoint_screen_width_[^_]+__?$/,""),X}function r2($){let X=$.match(/(\d+(?:\.\d+)?)/);return X?parseFloat(X[1]):0}function u1($,X){return $.replace(/\{([^}]+)\}/g,(Y,Z)=>{let q=X.get(Z);if(q){let U=q.value;if(typeof U==="object"&&U!==null&&"$value"in U)U=U.$value;return String(U)}return Y})}function k1($,X){let Y=$.split("."),Z={},q=Z;for(let U=0;U<Y.length-1;U++)q[Y[U]]={},q=q[Y[U]];return q[Y[Y.length-1]]=X,Z}function i2($,X={}){let{typescript:Y,includeJSDoc:Z,moduleType:q="es",customHeader:U,theme:K}=X,W="";if(U)W+=`${U}
|
|
326
342
|
|
|
327
343
|
`;else W+=`/**
|
|
328
344
|
`,W+=` * Design Tokens - ${K?`${K.charAt(0).toUpperCase()+K.slice(1)} Theme`:"All Tokens"}
|
|
@@ -330,22 +346,23 @@ ${z.sort().map((_)=>` ${_}`).join(`
|
|
|
330
346
|
`,W+=` * Do not edit this file directly
|
|
331
347
|
`,W+=` */
|
|
332
348
|
|
|
333
|
-
`;let
|
|
349
|
+
`;let G=a2($,K);if(Y)if(X.separateThemeFiles&&K)W+=`import type { Tokens } from "./${K}.d";
|
|
334
350
|
|
|
335
|
-
`;else W+=n2(
|
|
336
|
-
`;if(q==="es"){if(Y)W+=`const tokens: Tokens = ${n(
|
|
351
|
+
`;else W+=n2(G,Z),W+=`
|
|
352
|
+
`;if(q==="es"){if(Y)W+=`const tokens: Tokens = ${n(G,Z,0)};
|
|
337
353
|
|
|
338
|
-
`;else W+=`const tokens = ${n(
|
|
354
|
+
`;else W+=`const tokens = ${n(G,Z,0)};
|
|
339
355
|
|
|
340
356
|
`;W+=`export default tokens;
|
|
341
|
-
`;let
|
|
357
|
+
`;let E=Object.keys(G);if(E.length>0){W+=`
|
|
342
358
|
// Named exports for convenience
|
|
343
|
-
`;for(let
|
|
344
|
-
`}}else W+=`const tokens = ${n(
|
|
359
|
+
`;for(let A of E)W+=`export const ${A} = tokens.${A};
|
|
360
|
+
`}}else W+=`const tokens = ${n(G,Z,0)};
|
|
345
361
|
|
|
346
362
|
`,W+=`module.exports = tokens;
|
|
347
363
|
`,W+=`module.exports.default = tokens;
|
|
348
|
-
`;return W
|
|
364
|
+
`;return W+`
|
|
365
|
+
`}function a2($,X){let Y={},Z=new Map($.map((q)=>[q.name,q]));for(let q of $){let U=q.name;if(X){if(U.includes(`#${X}`))U=U.replace(`#${X}`,"")}else U=U.replace(/#[^#]*$/,"");let K=U.split("."),W=Y;for(let E=0;E<K.length-1;E++){let A=K[E];if(!W[A])W[A]={};W=W[A]}let G=K[K.length-1];W[G]=v$(q.value,Z)}return Y}function v$($,X){if(typeof $==="object"&&$!==null&&!Array.isArray($)){let Y=$;if(Y.color&&typeof Y.color==="string"&&Y.color.includes("{")&&Y.color.includes("}")){let Z=f($,"shadow");if(typeof Z==="string"&&!Z.includes("{")){let q={...Y},U=Z.split(" "),K=U[U.length-1];if(K&&K.startsWith("#"))q.color=K;else q.color=f(Y.color,"color");return q}}}if(typeof $==="string"){if($.startsWith("{")&&$.endsWith("}")){let Y=$.slice(1,-1),Z=X.get(Y);if(Z)return Z.value;let q=f($,"color");if(q!==$)return q}return $}if(Array.isArray($))return $.map((Y)=>v$(Y,X));if(typeof $==="object"&&$!==null){let Y={};for(let[Z,q]of Object.entries($))Y[Z]=v$(q,X);return Y}return $}function n2($,X){let Y="";if(X)Y+=`/**
|
|
349
366
|
* Token object type definition
|
|
350
367
|
*/
|
|
351
368
|
`;return Y+=`type Tokens = ${g0($,0)};
|
|
@@ -361,29 +378,31 @@ ${z.sort().map((_)=>` ${_}`).join(`
|
|
|
361
378
|
* Token object type definition
|
|
362
379
|
*/
|
|
363
380
|
`;return U+=`export type Tokens = ${g0($,0)};
|
|
364
|
-
`,U
|
|
381
|
+
`,U+`
|
|
382
|
+
`}function g0($,X){if(typeof $!=="object"||$===null)return typeof $==="string"?"string":typeof $==="number"?"number":typeof $==="boolean"?"boolean":"any";let Y=" ".repeat(X+1),Z=Object.entries($);if(Z.length===0)return"{}";let q=`{
|
|
365
383
|
`;for(let[U,K]of Z){let W=l1(U)?`"${U}"`:U;q+=`${Y}${W}: ${g0(K,X+1)};
|
|
366
384
|
`}return q+=" ".repeat(X)+"}",q}function l1($){return $.startsWith("@")||$.includes(" ")||$.includes("-")||$.includes("(")||$.includes(")")||$.includes("@")||$.includes(":")||!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test($)}function n($,X,Y=0){if(typeof $!=="object"||$===null)return JSON.stringify($);let Z=" ".repeat(Y),q=" ".repeat(Y+1),U=Object.entries($);if(U.length===0)return"{}";let K=`{
|
|
367
|
-
`;for(let W=0;W<U.length;W++){let[
|
|
368
|
-
`;let
|
|
369
|
-
`}return K+=`${Z}}`,K}function r1($,X){let Y=X.typescript?"ts":"js",{moduleType:Z="es",customHeader:q}=X,U=(W)=>{return W.replace(/-([a-z])/g,(
|
|
385
|
+
`;for(let W=0;W<U.length;W++){let[G,E]=U[W],A=W===U.length-1;if(X&&typeof E==="string")K+=`${q}/** Token value: ${JSON.stringify(E)} */
|
|
386
|
+
`;let z=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(G)?G:JSON.stringify(G),L=n(E,X,Y+1);K+=`${q}${z}: ${L}${A?"":","}
|
|
387
|
+
`}return K+=`${Z}}`,K}function r1($,X){let Y=X.typescript?"ts":"js",{moduleType:Z="es",customHeader:q}=X,U=(W)=>{return W.replace(/-([a-z])/g,(G,E)=>E.toUpperCase())},K="";if(q)K+=`${q}
|
|
370
388
|
|
|
371
389
|
`;else K+=`/**
|
|
372
390
|
`,K+=` * Design Tokens - Index
|
|
373
391
|
`,K+=` * Exports all token themes for convenient importing
|
|
374
392
|
`,K+=` */
|
|
375
393
|
|
|
376
|
-
`;if(Z==="es"){for(let W of $){if(W.fileName===`index.${Y}`)continue;if(!W.fileName.endsWith(".d.ts"))continue;let
|
|
394
|
+
`;if(Z==="es"){for(let W of $){if(W.fileName===`index.${Y}`)continue;if(!W.fileName.endsWith(".d.ts"))continue;let G=W.fileName.replace(".d.ts",""),E=U(W.theme||G);K+=`export type { Tokens as ${E.charAt(0).toUpperCase()+E.slice(1)}Tokens } from './${G}.d';
|
|
377
395
|
`}K+=`
|
|
378
|
-
`;for(let W of $){if(W.fileName===`index.${Y}`)continue;if(W.fileName.endsWith(".d.ts"))continue;let
|
|
396
|
+
`;for(let W of $){if(W.fileName===`index.${Y}`)continue;if(W.fileName.endsWith(".d.ts"))continue;let G=W.fileName.replace(`.${Y}`,""),E=U(W.theme||G);K+=`export { default as ${E} } from './${G}${X.typescript?"":".js"}';
|
|
379
397
|
`}K+=`
|
|
380
398
|
// Convenience re-exports
|
|
381
399
|
`,K+=`export { default } from './light${X.typescript?"":".js"}';
|
|
382
|
-
`}else{for(let W of $){if(W.fileName===`index.${Y}`)continue;if(W.fileName.endsWith(".d.ts"))continue;let
|
|
400
|
+
`}else{for(let W of $){if(W.fileName===`index.${Y}`)continue;if(W.fileName.endsWith(".d.ts"))continue;let G=W.fileName.replace(`.${Y}`,""),E=U(W.theme||G);K+=`exports.${E} = require('./${G}');
|
|
383
401
|
`}K+=`
|
|
384
402
|
// Default export points to light theme
|
|
385
403
|
`,K+=`module.exports = require('./light');
|
|
386
|
-
`}return K
|
|
404
|
+
`}return K+`
|
|
405
|
+
`}var t2=P(()=>{y$()});var o2={};d$(o2,{validateCSSFiles:()=>i1,printValidationResults:()=>s1});import{readFileSync as y0,existsSync as q$}from"fs";import{join as d}from"path";function i1($,X){let Y={isValid:!0,errors:[],warnings:[],checks:[]},Z=d($,"css"),q=d(Z,"tokens.css"),U=q$(q);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(X.$metaData?.tokens?.css?.mediaQuery?.separateThemeFiles??!1){let z=d(Z,"tokens.dark.css"),L=q$(z);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 W=d(Z,"tokens.breakpoints.css");if(q$(W))Y.checks.push({name:"CSS file exists: tokens.breakpoints.css",passed:!0,message:void 0});let E=X.$metaData?.tokens?.css?.hooks?.shortenName;if(E?.enabled&&q$(d(Z,"tokens.css"))){let z=y0(d(Z,"tokens.css"),"utf8");if(E.prefix)for(let{find:L,replace:H}of E.prefix){let _=`--${w$}-${L}`,Q=`--${H}`,O=z.includes(_),I=z.includes(Q);if(Y.checks.push({name:`Prefix hook applied: ${L} → ${H}`,passed:!O&&I,message:O?`Old prefix "${_}" still found in CSS, should be "${Q}"`:void 0}),O)Y.errors.push(`Prefix transformation failed: "${_}" should be replaced with "${Q}"`),Y.isValid=!1}if(E.suffix)for(let{find:L,replace:H}of E.suffix){let Q=new RegExp(`--[^:]+${L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}:`,"g").test(z);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(q$(d(Z,"tokens.css"))){let L=y0(d(Z,"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 A=["tokens.css","tokens.dark.css","tokens.breakpoints.css"];for(let z of A){let L=d(Z,z);if(q$(L)){let H=y0(L,"utf8"),_=(H.match(/\{/g)||[]).length-(H.match(/\}/g)||[]).length;if(Y.checks.push({name:`CSS syntax valid: ${z}`,passed:_===0,message:_!==0?`Mismatched braces in ${z}`:void 0}),_!==0)Y.errors.push(`CSS syntax error in ${z}: mismatched braces`),Y.isValid=!1}}return Y}function s1($){console.log(`
|
|
387
406
|
|
|
388
407
|
Build Validation Results:`),console.log("========================================================");for(let X of $.checks){let Y=X.passed?"✓":"✗";if(console.log(` ${Y} ${X.name}`),X.message)console.log(` ${X.message}`)}if($.warnings.length>0){console.log(`
|
|
389
408
|
⚠️ Warnings:`);for(let X of $.warnings)console.log(` ${X}`)}if($.errors.length>0){console.log(`
|
|
@@ -391,7 +410,7 @@ Build Validation Results:`),console.log("=======================================
|
|
|
391
410
|
Validation Summary:`),console.log(` - Checks: ${$.checks.filter((X)=>X.passed).length}/${$.checks.length} passed`),console.log(` - Errors: ${$.errors.length}`),console.log(` - Warnings: ${$.warnings.length}`),console.log(`
|
|
392
411
|
${$.isValid?"✅":"❌"} Build ${$.isValid?"passed":"failed"}`),console.log(`
|
|
393
412
|
========================================================
|
|
394
|
-
`)}var e2=P(()=>{g()});import{writeFileSync as a1,mkdirSync as n1,existsSync as v0,readFileSync as h0,readdirSync as t1,statSync as $Y}from"fs";import{join as b,dirname as J$}from"path";function o1($,X,Y=!1,Z=!1){let q=[],U=[],K=[];for(let
|
|
413
|
+
`)}var e2=P(()=>{g()});import{writeFileSync as a1,mkdirSync as n1,existsSync as v0,readFileSync as h0,readdirSync as t1,statSync as $Y}from"fs";import{join as b,dirname as J$}from"path";function o1($,X,Y=!1,Z=!1){let q=[],U=[],K=[];for(let G of $)if(G.fileName.includes("breakpoint"))U.push(`@import url("./css/${G.fileName}");`);else K.push(`@import url("./css/${G.fileName}");`);if(q.push(...K),Y)q.push('@import url("./css/tokens.icons.css");');if(Z)q.push('@import url("./css/fonts.css");');q.push(...U);let W=`/**
|
|
395
414
|
* ${X} Design System - Main CSS Entry Point
|
|
396
415
|
* Generated: ${new Date().toISOString()}
|
|
397
416
|
*
|
|
@@ -403,7 +422,8 @@ ${$.isValid?"✅":"❌"} Build ${$.isValid?"passed":"failed"}`),console.log(`
|
|
|
403
422
|
|
|
404
423
|
${q.join(`
|
|
405
424
|
`)}
|
|
406
|
-
`;return{fileName:`${X}.design-system.tokens.css`,content:W
|
|
425
|
+
`;return{fileName:`${X}.design-system.tokens.css`,content:W+`
|
|
426
|
+
`,theme:void 0}}function e1($,X,Y=!1,Z=!1,q){let{readFileSync:U}=u$("fs"),{join:K}=u$("path"),W=[],G=(z)=>{try{let L=K(q,"css",z);return U(L,"utf-8")}catch(L){return console.warn(`Could not read ${z}:`,L),""}},E=[];for(let z of $){let L=G(z.fileName);if(!L)continue;if(z.fileName.includes("breakpoint"))E.push(L);else W.push(L)}if(Y){let z=G("tokens.icons.css");if(z)W.push(z)}if(Z){let z=G("fonts.css");if(z)W.push(z)}W.push(...E);let A=`/**
|
|
407
427
|
* ${X} Design System - Raw/Inline CSS
|
|
408
428
|
* Generated: ${new Date().toISOString()}
|
|
409
429
|
*
|
|
@@ -417,25 +437,30 @@ ${q.join(`
|
|
|
417
437
|
${W.join(`
|
|
418
438
|
|
|
419
439
|
`)}
|
|
420
|
-
`;return{fileName:`${X}.design-system.tokens.raw.css`,content:
|
|
440
|
+
`;return{fileName:`${X}.design-system.tokens.raw.css`,content:A+`
|
|
441
|
+
`,theme:void 0}}function $4($,X){let Y=$.replace(/\\/g,"/");if(X.replace(/\\/g,"/").startsWith(Y))return{valid:!1,error:`⚠️ Compositions directory cannot be inside tokens directory.
|
|
421
442
|
`+` Tokens dir: ${$}
|
|
422
443
|
Compositions dir: ${X}
|
|
423
|
-
Please move compositions to a separate directory (e.g., './compositions')`};return{valid:!0}}function Y4($,X){let Y=[];if(v0($)){let Z=$Y($);if(Z.isDirectory())try{let q=t1($);for(let U of q){if(!U.endsWith(".json"))continue;let K=b($,U);if($Y(K).isFile())try{let
|
|
424
|
-
`),
|
|
425
|
-
`)}let A
|
|
426
|
-
`);q.push({fileName:
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
Generating
|
|
433
|
-
Generating
|
|
444
|
+
Please move compositions to a separate directory (e.g., './compositions')`};return{valid:!0}}function Y4($,X){let Y=[];if(v0($)){let Z=$Y($);if(Z.isDirectory())try{let q=t1($);for(let U of q){if(!U.endsWith(".json"))continue;let K=b($,U);if($Y(K).isFile())try{let G=h0(K,"utf-8"),E=JSON.parse(G);if(Array.isArray(E))Y.push(...E);else Y.push(E)}catch(G){console.warn(`⚠️ Failed to parse composition file ${U}:`,G)}}}catch(q){console.warn("⚠️ Failed to read compositions directory:",q)}else if(Z.isFile()&&$.endsWith(".json"))try{let q=h0($,"utf-8"),U=JSON.parse(q);if(Array.isArray(U))Y.push(...U);else Y.push(U)}catch(q){console.warn("⚠️ Failed to parse compositions file:",q)}}if(X&&Y.length===0){let Z=b(X,"compositions.json");if(v0(Z))try{let q=h0(Z,"utf-8"),U=JSON.parse(q);if(Array.isArray(U))Y.push(...U)}catch(q){console.warn("⚠️ Failed to parse compositions.json:",q)}}return Y}function YY($,X){let Y=X.$metaData?.tokens?.css?.hooks?.shortenName;if(!Y?.enabled)return $;let Z=$;if(Y.prefix&&Array.isArray(Y.prefix))for(let q of Y.prefix)Z=Z.replace(new RegExp(q.find,"g"),q.replace);if(Y.suffix&&Array.isArray(Y.suffix)){for(let q of Y.suffix)if(Z.endsWith(q.find))Z=Z.substring(0,Z.length-q.find.length)+q.replace}return Z}function X4($,X){let Y=$.match(/^\{(.+)\}$/);if(Y){let q=Y[1].replace(/\./g,"-");return q=YY(q,X),`var(--${q})`}return $.replace(/\{([^}]+)\}/g,(Z,q)=>{let U=q.replace(/\./g,"-");return U=YY(U,X),`var(--${U})`})}function Z4($,X,Y,Z){let q=[],U=$.filter((G)=>G.platform==="css");if(U.length===0)return q;let K=new Map,W="compositions.css";for(let G of U){let E=G.fileName||"";if(E.endsWith(".css"))E=E.slice(0,-4);let A=E?`${E}.css`:W;if(!K.has(A))K.set(A,[]);K.get(A).push(G)}for(let[G,E]of K.entries()){let A=[];if(A.push("/**"),A.push(" * Design System Compositions - Generated Styles"),A.push(" * DO NOT EDIT THIS FILE DIRECTLY"),A.push(" * Generated from composition definitions"),A.push(` * Namespace: ${X.$metaData?.dsNamespace||"ds"}.${X.$metaData?.tokenNamespace||"tokens"}`),A.push(` * File: ${G}`),A.push(` */
|
|
445
|
+
`),E.length===0)A.push("/* No compositions defined */");else for(let L of E){A.push(`/* ${L.name} */`),A.push(`${L.selector} {`);for(let H of L.properties){let _=X4(H.token,X);A.push(` ${H.property}: ${_};`)}A.push(`}
|
|
446
|
+
`)}let z=A.join(`
|
|
447
|
+
`);q.push({fileName:G,content:z+`
|
|
448
|
+
`,theme:void 0})}return q}async function d2($){let X=Date.now(),Y={tokenCount:0,cssFiles:[],typescriptFiles:[],javascriptFiles:[],jsonFiles:[],duration:0,warnings:[],errors:[]};try{M(`
|
|
449
|
+
Starting token build process...`,$.verbose);let{initializeColorspace:Z}=await Promise.resolve().then(() => (W$(),d0));await Z(),M("Loading token files...",$.verbose);let q=O0($.tokensDir);M("Parsing tokens...",$.verbose);let U=q4($.config),K=w0(q,U);if(M(`Found ${K.length} tokens`,$.verbose),Y.tokenCount=K.length,K.length===0&&U.namespace){let A=Object.keys(q).filter((z)=>!z.startsWith("$"));if(A.length>0)Y.warnings.push(`⚠️ No tokens found matching tokenNamespace "${U.namespace}". Found root keys: ${A.join(", ")}. Please check if your $metaData.tokenNamespace in designid.config.ts matches.`)}let W=I0(K,U);if(M(`Resolved ${W.length} tokens`,$.verbose),$.generateCSS!==!1){M(`
|
|
450
|
+
Generating CSS files...`,$.verbose);let A=XY($.config,$.cssOptions),z=C$(W,A);for(let L of z){let H=b($.outputDir,"css",L.fileName);l(H,L.content),M(` ✓ ${L.fileName}`,$.verbose)}Y.cssFiles=z}if($.generateCSS!==!1)try{await T0(),M(`
|
|
451
|
+
Generated icon tokens`,$.verbose)}catch(A){if($.verbose)console.warn("Could not build icon tokens:",A)}if($.generateCSS!==!1)try{let A=await j0();if(A.length>0){let z=XY($.config,$.cssOptions),L=F0(A,{customHeader:g$($.config),objectPath:$.config.$metaData?.icons?.objectPath||"universe.custom.path.icons",hooks:z.hooks}),H=b($.outputDir,"css",L.fileName);if(l(H,L.content),M(` ✓ Generated ${L.fileName}`,$.verbose),Y.cssFiles)Y.cssFiles.push(L);else Y.cssFiles=[L]}}catch(A){if($.verbose)console.warn("Could not generate icon CSS:",A)}let G=!1;if($.generateCSS!==!1)try{let A=$.config.$fonts;if(A&&A.length>0){await _0(A,$.outputDir),M(" ✓ Generated fonts.css",$.verbose),G=!0;let z={fileName:"fonts.css",content:"Generated by appendTypographyTokens",theme:void 0};if(Y.cssFiles)Y.cssFiles.push(z);else Y.cssFiles=[z]}}catch(A){if($.verbose)console.warn("Could not generate font CSS:",A)}if($.generateCSS!==!1&&Y.cssFiles.length>0){let A=$.config.$metaData?.tokenNamespace||"tokens",z=Y.cssFiles.some((Q)=>Q.fileName==="tokens.icons.css"),L=$.config.$metaData?.modes?.isHost||!1,H=o1(Y.cssFiles.filter((Q)=>Q.fileName!=="tokens.icons.css"&&Q.fileName!=="fonts.css"),A,z,G),_=b($.outputDir,H.fileName);if(l(_,H.content),M(` ✓ Generated ${H.fileName}`,$.verbose),Y.cssFiles.push(H),L){let Q=e1(Y.cssFiles.filter((I)=>I.fileName!=="tokens.icons.css"&&I.fileName!=="fonts.css"&&!I.fileName.includes(".design-system.tokens.css")),A,z,G,$.outputDir),O=b($.outputDir,Q.fileName);l(O,Q.content),M(` ✓ Generated ${Q.fileName} (raw/inline for web components)`,$.verbose),Y.cssFiles.push(Q)}}let E=$.config.$metaData?.modes?.isHost??!1;if($.generateCSS!==!1&&$.config.$paths.compositionsDir&&!E)try{let A=$.config.$paths.baseDir,z=$.config.$paths.tokensDir,L=$.tokensDir,H=z.split("/").filter((B)=>B&&B!=="."&&B!=="..");for(let B=0;B<H.length;B++)L=J$(L);let _=A.split("/").filter((B)=>B&&B!=="."&&B!=="..");for(let B=0;B<_.length;B++)L=J$(L);let Q=b(L,A,$.config.$paths.compositionsDir),O=b(L,A);if($.verbose)console.log(` Project root: ${L}`),console.log(` Base dir: ${O}`),console.log(` Compositions dir: ${Q}`);let I=$4($.tokensDir,Q);if(!I.valid)console.error(I.error),Y.errors.push(I.error);else{M(`
|
|
452
|
+
Processing composition files...`,$.verbose);let B=Y4(Q,O);if(B.length>0){M(` Found ${B.length} composition(s)`,$.verbose);let w=new Map;for(let R of W)w.set(R.path,R);let J=Z4(B,$.config,w,$.outputDir);for(let R of J){let y=b($.outputDir,"css",R.fileName);l(y,R.content),M(` ✓ Generated ${R.fileName}`,$.verbose),Y.cssFiles.push(R)}}else M(` No compositions found in ${Q}`,$.verbose)}}catch(A){if($.verbose)console.warn("Could not generate composition CSS:",A)}if($.generateTypeScript!==!1){M(`
|
|
453
|
+
Generating TypeScript files...`,$.verbose);let A=U4($.config,$.typescriptOptions),z=await P0(W,A);for(let L of z){let H=b($.outputDir,"typescript",L.fileName);l(H,L.content),M(` ✓ Generated ${L.fileName}`,$.verbose)}Y.typescriptFiles=z}if($.generateJavaScript!==!1){M(`
|
|
454
|
+
Generating JavaScript files...`,$.verbose);let A=W4($.config,$.javascriptOptions),z=s2(W,A);for(let L of z){let H=b($.outputDir,"js",L.fileName);l(H,L.content),M(` ✓ Generated ${L.fileName}`,$.verbose)}Y.javascriptFiles=z}if($.generateJSON!==!1){M(`
|
|
455
|
+
Generating JSON files...`,$.verbose);let A=K4(W,K,$.config);for(let z of A){let L=b($.outputDir,"json",z.fileName);l(L,z.content),M(` ✓ Generated ${z.fileName}`,$.verbose)}Y.jsonFiles=A}Y.duration=Date.now()-X,M(`
|
|
434
456
|
Build completed in ${Y.duration}ms`,$.verbose)}catch(Z){let q=Z instanceof Error?Z.message:String(Z);Y.errors.push(q),M(`❌ Build failed: ${q}`,$.verbose)}if($.validate!==!1){M(`
|
|
435
|
-
Validating build output...`,$.verbose);let{validateCSSFiles:Z,printValidationResults:q}=await Promise.resolve().then(() => (e2(),o2)),U=Z($.outputDir,$.config);if($.verbose||!U.isValid)q(U);if(!U.isValid)Y.errors.push(...U.errors)}return Y}function q4($){let X=$.$metaData,Y=$.$modes?[...Object.values($.$modes)]:[];return{prefix:X.dsNamespace||X.tokenNamespace,namespace:X.tokenNamespace,generateModes:!0,modes:Y,generateDerivedTokens:!0,generateBreakpointTokens:!0,failOnBrokenReferences:!0,transformName:(Z)=>{let q=X.tokens?.css?.hooks?.shortenName;if(q?.enabled){let U=Z;if(q.prefix)for(let{find:K,replace:W}of q.prefix){let
|
|
457
|
+
Validating build output...`,$.verbose);let{validateCSSFiles:Z,printValidationResults:q}=await Promise.resolve().then(() => (e2(),o2)),U=Z($.outputDir,$.config);if($.verbose||!U.isValid)q(U);if(!U.isValid)Y.errors.push(...U.errors)}return Y}function q4($){let X=$.$metaData,Y=$.$modes?[...Object.values($.$modes)]:[];return{prefix:X.dsNamespace||X.tokenNamespace,namespace:X.tokenNamespace,generateModes:!0,modes:Y,generateDerivedTokens:!0,generateBreakpointTokens:!0,failOnBrokenReferences:!0,transformName:(Z)=>{let q=X.tokens?.css?.hooks?.shortenName;if(q?.enabled){let U=Z;if(q.prefix)for(let{find:K,replace:W}of q.prefix){let G=K.replace(/\./g,"-").replace(/-$/,""),E=W.replace(/\./g,"-").replace(/-$/,"");U=U.replace(G,E)}if(q.suffix){for(let{find:K,replace:W}of q.suffix)if(U.endsWith(K))U=U.substring(0,U.length-K.length)+W}return U}return Z}}}function XY($,X){let Y=$.$metaData,Z=Y.tokens?.css,q=$.$modes?[...Object.values($.$modes)]:["light","dark"],U=q.length>0?q[0]:"light",K=Y.modes?.isHost??!1;return{...X,separateThemeFiles:Z?.mediaQuery?.separateThemeFiles??!1,rootSelector:":root",generateMediaQueries:!0,customHeader:g$($),themeSelector:Z?.mediaQuery?.match||"[data-theme]",modes:q,defaultMode:U,isHost:K,hooks:Z?.hooks}}function U4($,X){let Y=$.$metaData;return{...X,tokenInterface:"DesignTokens",exportNamespace:Y.dsNamespace||Y.tokenNamespace,generateTypes:!0,generateConsts:!0,generateCSSVarMappings:!0,includeJSDoc:!0}}function W4($,X){let Y=$.$modes?[...Object.values($.$modes)]:["light","dark"];return{...X,modes:Y,typescript:!0,separateThemeFiles:!0,includeJSDoc:!1,moduleType:"es",customHeader:`/**
|
|
436
458
|
* ${$.$name}
|
|
437
459
|
* Generated: ${new Date().toISOString()}
|
|
438
|
-
*/`}}function K4($,X,Y){let Z=[],q=JSON.stringify({$schema:"https://schemas.designtokens.org/design-tokens.schema.json",$name:Y.$name,$version:Y.$version,tokens:X.reduce((W,
|
|
460
|
+
*/`}}function K4($,X,Y){let Z=[],q=JSON.stringify({$schema:"https://schemas.designtokens.org/design-tokens.schema.json",$name:Y.$name,$version:Y.$version,tokens:X.reduce((W,G)=>{return W[G.name]={$type:G.type,$value:G.value,$description:G.description,$extensions:G.extensions},W},{})},null,2);Z.push({fileName:"tokens.raw.json",content:q+`
|
|
461
|
+
`});let U=JSON.stringify({$name:Y.$name,$version:Y.$version,tokens:$.reduce((W,G)=>{return W[G.name]={$type:G.type,$value:G.value,$description:G.description,cssVar:G.cssVar},W},{})},null,2);Z.push({fileName:"tokens.resolved.json",content:U+`
|
|
462
|
+
`});let K=JSON.stringify({$name:`${Y.$name} - CSS Variables`,$version:Y.$version,variables:$.reduce((W,G)=>{return W[G.cssVar]=G.value,W},{})},null,2);return Z.push({fileName:"css-variables.json",content:K+`
|
|
463
|
+
`}),Z}function l($,X){let Y=J$($);if(!v0(Y))n1(Y,{recursive:!0});a1($,X,"utf-8")}function M($,X){if(X!==!1)console.log($)}async function b0($,X){let Y=typeof globalThis.Bun<"u",Z=$,q=null;if($.endsWith(".ts")&&!Y){let{compileConfigFile:z,getDistConfigFile:L}=await Promise.resolve().then(() => (_$(),H2)),H=J$($);await z(H),Z=L(H),q=Z}let K=(await import(Z)).default,W=J$($),G=(z)=>{if(z.startsWith("../"))return b(W,z);return b(W,K.$paths.baseDir,z)},E=b(W,K.$paths.baseDir,K.$paths.tokensDir),A=X||G(K.$paths.distDir);try{return await d2({config:K,tokensDir:E,outputDir:A,verbose:!0})}finally{if(q){let{existsSync:z,unlinkSync:L}=await import("fs");if(z(q))try{L(q)}catch(H){}}}}var C0=P(()=>{l2();y$();t2();R0();D0();Q0()});C0();import{existsSync as z4}from"fs";import{resolve as A4}from"path";import{existsSync as f$,statSync as ZY}from"fs";import{resolve as qY}from"path";import{execSync as G4}from"child_process";async function UY($,X=!1){let Y=process.cwd(),Z=$||qY(Y,"designid.config.ts"),q=qY(Y,"designid.config.mjs");if(!f$(Z))return!1;if(!(!f$(q)||f$(Z)&&f$(q)&&ZY(Z).mtimeMs>ZY(q).mtimeMs)){if(X)console.log("✓ Config file is up to date");return!1}if(X)console.log("\uD83D\uDD04 Compiling config file...");try{if(G4(`bun build ${Z} --outfile ${q} --minify --target node --packages external --no-bundle`,{stdio:X?"inherit":"pipe"}),X)console.log(`✅ Config compiled successfully
|
|
439
464
|
`);return!0}catch(K){if(console.error("❌ Failed to compile config file"),K instanceof Error)console.error(K.message);throw K}}function E4($){let X={};for(let Y=0;Y<$.length;Y++){let Z=$[Y];switch(Z){case"--config":case"-c":X.config=$[++Y];break;case"--input":case"-i":X.input=$[++Y];break;case"--output":case"-o":X.output=$[++Y];break;case"--verbose":case"-v":X.verbose=!0;break;case"--no-css":X.css=!1;break;case"--no-typescript":X.typescript=!1;break;case"--no-json":X.json=!1;break;case"--help":case"-h":X.help=!0;break;default:if(Z.startsWith("-"))console.warn(`Unknown option: ${Z}`);break}}return X}function L4(){console.log(`
|
|
440
465
|
Design Tokens Builder - W3C compliant token processor
|
|
441
466
|
|
|
@@ -470,7 +495,7 @@ Token Files:
|
|
|
470
495
|
- Include $type and $value properties
|
|
471
496
|
- Support token references with {token.path} syntax
|
|
472
497
|
- Support extensions for modes, generators, and breakpoints
|
|
473
|
-
`)}function H4($){let X=[$,"./designid.config.ts","./designid.config.mjs","./designid.config.js","./tokens.config.ts","./tokens.config.js"].filter(Boolean);for(let Y of X){let Z=A4(Y);if(z4(Z))return Z}throw
|
|
498
|
+
`)}function H4($){let X=[$,"./designid.config.ts","./designid.config.mjs","./designid.config.js","./tokens.config.ts","./tokens.config.js"].filter(Boolean);for(let Y of X){let Z=A4(Y);if(z4(Z))return Z}throw Error(`Config file not found. Tried: ${X.join(", ")}`)}async function _4(){let $=E4(process.argv.slice(2));if($.help){L4();return}try{await UY($.config,$.verbose);let X=H4($.config);console.log(`Using config: ${X}`);let Y=await b0(X,$.output);if(Y.errors.length>0)console.log(`
|
|
474
499
|
❌ Build failed with ${Y.errors.length} error${Y.errors.length>1?"s":""}:`),Y.errors.forEach((Z)=>console.log(` - ${Z}`)),process.exit(1);if(console.log(`Processed ${Y.tokenCount} tokens`),console.log(`Duration: ${Y.duration}ms`),console.log(`Build completed successfully!
|
|
475
500
|
`),Y.cssFiles.length>0)console.log(`
|
|
476
501
|
Generated ${Y.cssFiles.length} CSS files:`),Y.cssFiles.forEach((Z)=>console.log(` - ${Z.fileName}`));if(Y.typescriptFiles.length>0)console.log(`
|