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