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