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