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