@designid/tokens 1.2.8 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/build.js +226 -210
- package/bin/editor.js +287 -271
- package/bin/watch.js +226 -210
- package/package.json +1 -1
- package/types/design-tokens.ts +6 -0
- package/types/files.d.ts +9 -2
package/bin/watch.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as QY}from"node:module";var AY=Object.create;var{getPrototypeOf:EY,defineProperty:u$,getOwnPropertyNames:LY}=Object;var HY=Object.prototype.hasOwnProperty;var _Y=($,X,Y)=>{Y=$!=null?AY(EY($)):{};let Z=X||!$||!$.__esModule?u$(Y,"default",{value:$,enumerable:!0}):Y;for(let q of LY($))if(!HY.call(Z,q))u$(Z,q,{get:()=>$[q],enumerable:!0});return Z};var k$=($,X)=>{for(var Y in X)u$($,Y,{get:X[Y],enumerable:!0,configurable:!0,set:(Z)=>X[Y]=()=>Z})};var S=($,X)=>()=>($&&(X=$($=0)),X);var c$=QY(import.meta.url);var l0={};k$(l0,{transformColorValueAsync:()=>IY,transformColorValue:()=>F,transformColorToken:()=>x$,setAlpha:()=>W$,isColor:()=>p,initializeColorspace:()=>BY});import l$ from"colorjs.io";async function k0(){if(N$===null){let{colorspace:$}=await C();N$=$||"hex"}return N$}function wY(){return N$||"hex"}async function BY(){await k0()}function W$($,X){let Y=new l$($);if(X||X===0)Y.alpha=X/100;return F(Y)}function c0($,X){if(!$)return $;if(X&&X.type!=="color")return $;if(typeof $==="string")$=new l$($);if(typeof $?.to!=="function")return $;let Y=wY();try{switch(Y){case"hex":return $.to("srgb").toString({format:"hex"});case"rgb":case"srgb":return $.to("srgb").toString();case"srgb-linear":return $.to("srgb-linear").toString();case"display-p3":case"p3":return $.to("p3").toString();case"a98rgb":case"a98-rgb":return $.to("a98rgb").toString();case"prophoto":case"prophoto-rgb":return $.to("prophoto").toString();case"rec2020":case"rec-2020":return $.to("rec2020").toString();case"xyz":case"xyz-d65":return $.to("xyz-d65").toString();case"xyz-d50":return $.to("xyz-d50").toString();case"lab":case"cielab":return $.to("lab").toString();case"lab-d65":return $.to("lab-d65").toString();case"oklab":return $.to("oklab").toString();case"lch":case"cielch":return $.to("lch").toString();case"oklch":return $.to("oklch").toString();case"hsl":return $.to("hsl").toString();case"hsv":case"hsb":return $.to("hsv").toString();case"hwb":return $.to("hwb").toString();case"luv":return $.to("luv").toString();case"lchuv":return $.to("lchuv").toString();case"jzazbz":return $.to("jzazbz").toString();case"jzczhz":return $.to("jzczhz").toString();case"ictcp":return $.to("ictcp").toString();default:return $.to(Y).toString()}}catch(Z){return console.warn(`Unsupported colorspace '${Y}', falling back to hex. Error:`,Z),$.to("srgb").toString({format:"hex"})}}async function IY($,X){return await k0(),c0($,X)}function F($,X){return c0($,X)}function x$($,X,Y,Z){try{if($=g(X,Z),X.$type==="color"&&X.original?.$value&&X.original?.$value!==X.$value){if(D(X.original.$value))$=y(X.original.$value,Y,Z,X);else $=b(X);if(!j(Z)&&X.original?.$extensions?.mode?.[Z])$=X.original.$extensions.mode[Z]}if(D($))$=y($,Y,Z,X);return F($)}catch{return $=g(X,Z),F($)}}function p($){try{if($)return new l$($),!0;return!1}catch{return!1}}var N$=null;var G$=S(()=>{T()});function r0($,X){let Y=$.$extensions?.delimiter?.character||" ",Z=g($,X)??{},q=$.$extensions?.sort??[],U=b($)??{};if(q.length>0)U=Object.keys(U).sort((W,K)=>{let A=q.indexOf(W),G=q.indexOf(K);return A-G}).reduce((W,K)=>{return W[K]=Z[K],W},{});return Object.keys(U).reduce((W,K)=>{let A=b(Z[K]);if(Z[K]?.$type==="color"||Z[K].$property==="color")A=F(A,Z[K]);return[...Array.isArray(W)?W:[W],A]},[]).join(Y).trim()}function k($,X){let Y=(q)=>{if(q===void 0||q===null)return;if(typeof q==="object"&&"value"in q)return q.value;return q},Z=$.match(/^\{(.+)\}$/);if(Z){let q=Z[1],U=X.get(q);if(U===void 0)return`/* Unknown token: ${q} */`;let W=Y(U);if(W===void 0)return`/* Unknown token: ${q} */`;if(typeof W==="object"&&W!==null){let K=[];for(let A in W){if(A.startsWith("$"))continue;let G=W[A],E=typeof G==="object"&&G?.value!==void 0?G.value:G;if(typeof E==="string"&&E.match(/^\{.+\}$/))K.push(k(E,X));else K.push(String(E))}return K.join(" ")}if(typeof W==="string"&&W.match(/^\{.+\}$/))return k(W,X);return String(W)}if($.includes("{"))return $.replace(/\{([^}]+)\}/g,(q,U)=>{let W=X.get(U);if(W===void 0)return`/* Unknown token: ${U} */`;let K=Y(W);if(K===void 0)return`/* Unknown token: ${U} */`;if(typeof K==="object"&&K!==null)return`/* Cannot embed composite token: ${U} */`;if(typeof K==="string"&&K.match(/^\{.+\}$/))return k(K,X);return String(K)});return $}function JY($,X,Y,Z){return Object.keys(X??{}).reduce((U,W)=>{let K=X[W];if(typeof K==="string"||typeof K==="number")K={$value:K,$type:typeof K,value:K};if(K.$type=K.type||$?.original?.$value?.[W]?.type||K.$type||$.$type,!j(Z)&&c(K,"mode",{isIncludedOriginalValue:!0}))K.$value=g(K,Z);if(K?.$type==="composition"&&(typeof K.$value!=="string"||typeof K.$value!=="number"||D(K.$value))&&Object.keys(K).length>0){if(D(K.$value))return K.$value=y(K.$value,Y,Z,K),{...U,[W]:{...K,$property:W,$type:K.$type,$value:e(K,Y,Z)}};return{...U,[W]:{...K,$property:W,$type:K.$type,$value:e(K,Y,Z)}}}if(K?.$value){let G=y(K.$value,Y,Z,K);return{...U,[W]:{...K,$property:W,$type:K.$type,$value:G}}}return U},{})}function e($,X,Y){let Z=b($,{isIncludedOriginalValue:!0});if(typeof Z==="string"){if(D(Z)){if(Z=r$(Z,X,Y,$),!j(Y)&&c(Z,"mode",{isIncludedOriginalValue:!0}))Z.$value=g(Z,Y)}let q=Y$(Z);if(q&&(q?.length??0)>1)Z=$$(Z,q,X,Y)}else if(Array.isArray(Z))Z=Z.map((q)=>{if(typeof q==="string"&&D(q))return y(q,X,Y,$);return q});if(!$.name)return Z;return $.$value=JY($,Z,X,Y),r0($,Y)}var F$=S(()=>{T()});function b($,X){let{isIncludedOriginalValue:Y=!1,fallbackValue:Z=null}=X??{};if(Y)return $?.original?.$value??$?.$value??$.value??Z;return $?.$value??$?.value??Z}function g($,X){return X&&($?.$extensions?.mode?.[X]||typeof $?.$extensions?.mode?.[X]==="number")?$.$extensions.mode[X]:b($,{fallbackValue:$?.original?.$value??$?.$value??$?.value})??null}function c($,X,{isIncludedOriginalValue:Y=!1}={}){let Z=!1;if(Y&&$?.original?.$extensions?.[X])Z=!0;if($?.$extensions?.[X])Z=!0;return Z}function i$($,X,Y){let Z=b($,{isIncludedOriginalValue:!0});if(!j(Y)&&c($,"mode",{isIncludedOriginalValue:!0}))Z=g($,Y);if(D(Z))return a$(Z,X,Y,$);return Z}function $$($,X,Y,Z){let q=X.reduce((U,W)=>{let K=s$(W,Y);if(!K)return U;let A=b(K,{isIncludedOriginalValue:!0});if(D(A))A=y(`{${W}}`,Y,Z,K);return{...U,[W]:j$(K,A,Y,Z)}},{});return $?.replace(/\{([^}]+)\}/g,(U,W)=>{return q[W]!==void 0?q[W]:U})??null}function r$($,X,Y,Z){if(D($))return y($,X,Y,Z);return $}function s$($,X){return X.allTokens.find((Y)=>Y.path.join(".")===$)??null}function y($,X,Y,Z){let q=D($),U=null,W=$??b(Z),K=null;if(q){if(U=s$(q,X),Y&&U&&U?.$extensions?.mode?.[Y]!==U.original?.$extensions?.mode?.[Y])W=U.original?.$extensions?.mode?.[Y],K=U.original?.$extensions?.alpha??K;else if(U?.$extensions?.mode?.[Y])W=U.$extensions.mode[Y],K=U.$extensions?.alpha??K;else if(U?.original?.$value)W=U?.original.$value??U?.$value,K=U?.original.$extensions?.alpha??K}if(W!==$&&D(W))W=y(W,X,Y,Z);if(W&&(K||Z?.$extensions?.alpha||K===0||Z?.original?.$extensions?.alpha===0))K=K??Z?.$extensions?.alpha??null,W=W$(W,K);return W=F(W,U??Z),W??$}function a$($,X,Y,Z){let q=Z?.original?.$extensions?.mode?.[Y]??Z?.original?.$value,U=D(q);if(Y&&U){let W=X.allTokens.find((A)=>A.path.join(".")===U);if(!W)return $;let K=b(W);if(D(K))return a$(K,X,Y,W);if(W?.$extensions?.mode?.[Y])K=W.$extensions.mode[Y];if(K&&W?.$extensions?.alpha)K=W$(W.$value,W.$extensions.alpha);return F(K,W)??$}else if(q)return F(q,Z);return $}function D($){if(typeof $!=="string")return null;let X=/{[^}]+}/g,Y=$.match(X);if(Y?.length!==1)return null;return Y[0].slice(1,-1)}function Y$($){if(typeof $!=="string")return null;return[...$.matchAll(/\{([^}]+)\}/g)].map(([,Y])=>Y)??null}function X$($){return $}function z$($){return $}var n$=S(()=>{T()});var w2={};k$(w2,{wrapThemeValue:()=>L0,wrapFormatCSSFile:()=>H2,typographyFileName:()=>X2,tokensFileName:()=>$2,removeDirectoryContents:()=>G0,readConfigFile:()=>U$,namespaceUUID:()=>U2,iconsFileName:()=>Z2,getTokenfileName:()=>K2,getRelativePath:()=>O2,getRelativeCSSPath:()=>Q2,getRawTokensFileName:()=>A2,getProjectPaths:()=>m,getProjectModes:()=>A0,getProjectMetaData:()=>C,getProjectFonts:()=>SY,getLazyTokensConfig:()=>t$,getLazyProjectPaths:()=>E0,getLazyProjectModes:()=>A$,getLazyProjectMetaData:()=>_$,getLazyProjectFonts:()=>DY,getLazyProjectData:()=>l,getLazyIcons:()=>C$,getJSDocHeader:()=>E2,getIconDestinationFileName:()=>q$,getFiles:()=>P$,getFileHeader:()=>z0,getDistThemeFileDelimeter:()=>W2,getDistConfigFile:()=>S$,getDestinationFileName:()=>G2,getDefaultIconObjectPath:()=>q2,getCSSDestinationFileName:()=>z2,getBaseDirectory:()=>a,getBaseConfigFile:()=>L$,generatedFileHeader:()=>Z$,filterTokensByType:()=>D$,createFileHeaderTitle:()=>E$,compileConfigFile:()=>W0,combineCSSFiles:()=>_2,checkAndCreateDirectory:()=>s,breakpointFileName:()=>Y2});import{spawnSync as RY}from"child_process";import{existsSync as h,mkdirSync as MY,readFileSync as NY,unlinkSync as i0,writeFileSync as xY}from"fs";import{readdir as t0,rmdir as FY,unlink as jY}from"fs/promises";import{resolve as o0,join as N,basename as e0,normalize as s0,relative as a0,sep as o$,dirname as n0}from"path";async function q2(){return`${(await H$()).$metaData?.tokenNamespace||"tokens"}.icons`}async function W0($){let Y=N($,"designid.config.ts");if(h(N($,"designid.config.mjs")))i0(N($,"designid.config.mjs"));let Z=N($,"designid.config.js");if(h(Z))i0(Z);if(h(Y)){let q=RY("bun",["build",Y,"--outfile ./designid.config.mjs","--minify","--target","node","--packages","external","--no-bundle"],{stdio:"inherit",cwd:$,shell:!0});if(q.status!==0)console.error("Failed to compile designid.config.mjs with bun."),process.exit(q.status??1);if(q.status===0)return new Promise((U)=>U(!0))}}async function G0($){try{if(h($)){let X=await t0($,{withFileTypes:!0});for(let Y of X){let Z=N($,Y.name);if(Y.isDirectory())await G0(Z),await FY(Z);else await jY(Z)}}}catch(X){console.error(`Error removing contents of ${$}:`,X)}}async function P$($){let X=await t0($,{withFileTypes:!0}),Y=await Promise.all(X.map((Z)=>{let q=o0($,Z.name);return Z.isDirectory()?P$(q):q}));return Array.prototype.concat(...Y)}async function U2($){let{dsNamespace:X,tokenNamespace:Y}=await C();return`${(X??Y).toUpperCase()}DesignSystem${$.charAt(0).toUpperCase()+$.slice(1)}Tokens`}function K2($,X="d.ts",Y){if(!$)return`tokens.${Y}.config.${X}`;return N($,`tokens.${Y}.config.${X}`)}function W2($,X){return $.length>1?`.${X}`:""}async function G2($="d.ts",X){let{tokenNamespace:Y}=await C();if(X)return`${Y}-design-system.${X}.tokens.config.${$}`;return`${Y}-design-system.tokens.config.${$}`}async function q$($="json"){let{tokenNamespace:X}=await C();return`${X}-design-system.tokens.svg${$==="d.ts"||$==="js"?".config":""}.${$}`}async function z2(){let{tokenNamespace:$}=await C();return`${$}-design-system.tokens.css`}async function A2(){let{tokenNamespace:$}=await C();return`${$}-design-system-raw.tokens.json`}async function z0($){let{tokenNamespace:X}=await C();return`${X} | ${$}`}function E2($,X){return`/** @type {import("./${$}").${X}} */`}function E$($){return`/* ${z0($)} */`}function s($){if(!h($))MY($,{recursive:!0})}async function U$($,X=!1){let Y=L$(),Z;if(Y.endsWith(".json"))Z=JSON.parse(NY(Y,"utf8").trim()??"{}");else if(Y.endsWith(".ts"))if(typeof globalThis.Bun<"u"){if(Z=await import(Y),Z.default)Z=Z.default}else{$=$??n0(Y)+"/";let U=S$($);if(U&&(X||!h(U)))await W0($);if(Z=await import(U),Z.default)Z=Z.default}else{$=$??n0(Y)+"/";let q=S$($);if(q&&(X||!h(q)))await W0($);if(Z=await import(q),Z.default)Z=Z.default}return Z}async function a($=!1){let{baseDir:X}=await m(),Y=process.cwd(),q=N(Y,X),{buildDir:U,distDir:W}=await m();if($)try{s(N(q,U)),s(N(q,W))}catch(K){console.error("Error creating directories:",K)}return q}function S$($){return $?N($,"designid.config.mjs"):N(process.cwd(),"designid.config.mjs")}function L$(){let $=process.argv.find((K)=>K.startsWith("--config=")),[,X]=$?.split("=")??[];if(X)return X;let Y=process.cwd(),Z=S$(Y),q=N(Y,"designid.config.ts"),U=h(Z),W=h(q);if(U)return Z;else if(W)return q;throw console.error("Config file not found"),Error("Config file not found")}async function m($=!1){let X=L$(),Z=(await U$(process.cwd(),$)).$paths;if(!Z)throw console.error("Project paths not found"),Error("Project paths not found");return{configFile:X,...Z}}async function C(){let X=(await U$(process.cwd())).$metaData;if(!X)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!X.colorspace)X.colorspace="hex";if(!X.fontNamespace)X.fontNamespace=`${X.dsNamespace}.font`;if(!X?.tokens?.css?.mediaQuery?.match)X={...X??{},tokens:{...X.tokens??{},css:{...X.tokens?.css??{},mediaQuery:{...X.tokens?.css?.mediaQuery??{},match:"[data-theme]"}}}};if(X?.tokens?.css?.mediaQuery&&typeof X.tokens.css.mediaQuery.separateThemeFiles!=="boolean")X.tokens.css.mediaQuery.separateThemeFiles=!1;if(!X.dsNamespace)X.dsNamespace=X.tokenNamespace;let Y=await q2();return{...X,icons:X.icons??{objectPath:Y},dsNamespace:X.dsNamespace}}async function A0(){return(await U$(process.cwd())).$modes??{default:"light"}}async function H$(){if(!e$){let $=L$();e$=await U$(process.cwd()),L2=$}return e$}async function A$(){if(!$0)$0=(await H$()).$modes??{default:"light"};return $0}async function _$(){if(!Y0){let X=(await H$()).$metaData;if(!X)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!X.dsNamespace)X.dsNamespace=X.tokenNamespace;let Z=`${X.tokenNamespace||"tokens"}.icons`;Y0={...X,icons:X.icons??{objectPath:Z},dsNamespace:X.dsNamespace}}return Y0}async function E0($=!1){if(!X0){let Y=(await H$()).$paths;if(!Y)throw console.error("Project paths not found"),Error("Project paths not found");X0={configFile:L2,...Y}}return X0}async function l(){if(!Z0){let{distDir:$,assets:X,buildDir:Y}=await E0(!0),{fontNamespace:Z,tokenNamespace:q,icons:U}=await _$(),W=await a(),K=process.cwd(),A=N(K,$,"css");Z0={distDir:$,assets:X,fontNamespace:Z,__dirname:W,workspaceRoot:K,distCSSPath:A,buildDir:Y,tokenNamespace:q,icons:U}}return Z0}async function C$(){if(!q0){let{icons:$}=await _$();q0=$}return q0}async function t$(){if(!U0){let{tokens:$}=await _$();U0=$}return U0}async function SY(){return(await U$(process.cwd())).$fonts??[]}async function DY(){if(!K0)K0=(await H$()).$fonts??[];return K0}async function L0($){if(j($))return":root";let Y=(await C())?.tokens?.css?.mediaQuery?.match??"[data-theme]";if(Y.startsWith("[")&&Y.endsWith("]"))return`${Y.replace("]",`="${$}"]`)}`;else if(Y.startsWith(".")||Y.startsWith("#"))return`${Y}${$}`;else return`${Y}${$}`}async function H2($,X,Y,Z,q,U={}){let W;if(j(Y))W=X.allTokens;else W=$(X,Y);let A=(await C())?.tokens?.css?.mediaQuery?.separateThemeFiles?"Theme: "+Y:U.headerTitle??"",G=`${E$(A)}
|
|
3
|
-
${
|
|
2
|
+
import{createRequire as J0}from"node:module";var L0=Object.create;var{getPrototypeOf:H0,defineProperty:cX,getOwnPropertyNames:_0}=Object;var Q0=Object.prototype.hasOwnProperty;var O0=(X,Z,Y)=>{Y=X!=null?L0(H0(X)):{};let q=Z||!X||!X.__esModule?cX(Y,"default",{value:X,enumerable:!0}):Y;for(let $ of _0(X))if(!Q0.call(q,$))cX(q,$,{get:()=>X[$],enumerable:!0});return q};var lX=(X,Z)=>{for(var Y in Z)cX(X,Y,{get:Z[Y],enumerable:!0,configurable:!0,set:(q)=>Z[Y]=()=>q})};var b=(X,Z)=>()=>(X&&(Z=X(X=0)),Z);var a=J0(import.meta.url);var lY={};lX(lY,{transformColorValueAsync:()=>R0,transformColorValue:()=>x,transformColorToken:()=>jX,setAlpha:()=>zX,isColor:()=>m,initializeColorspace:()=>w0});import rX from"colorjs.io";async function kY(){if(xX===null){let{colorspace:X}=await V();xX=X||"hex"}return xX}function I0(){return xX||"hex"}async function w0(){await kY()}function zX(X,Z){let Y=new rX(X);if(Z||Z===0)Y.alpha=Z/100;return x(Y)}function cY(X,Z){if(!X)return X;if(Z&&Z.type!=="color")return X;if(typeof X==="string")X=new rX(X);if(typeof X?.to!=="function")return X;let Y=I0();try{switch(Y){case"hex":return X.to("srgb").toString({format:"hex"});case"rgb":case"srgb":return X.to("srgb").toString();case"srgb-linear":return X.to("srgb-linear").toString();case"display-p3":case"p3":return X.to("p3").toString();case"a98rgb":case"a98-rgb":return X.to("a98rgb").toString();case"prophoto":case"prophoto-rgb":return X.to("prophoto").toString();case"rec2020":case"rec-2020":return X.to("rec2020").toString();case"xyz":case"xyz-d65":return X.to("xyz-d65").toString();case"xyz-d50":return X.to("xyz-d50").toString();case"lab":case"cielab":return X.to("lab").toString();case"lab-d65":return X.to("lab-d65").toString();case"oklab":return X.to("oklab").toString();case"lch":case"cielch":return X.to("lch").toString();case"oklch":return X.to("oklch").toString();case"hsl":return X.to("hsl").toString();case"hsv":case"hsb":return X.to("hsv").toString();case"hwb":return X.to("hwb").toString();case"luv":return X.to("luv").toString();case"lchuv":return X.to("lchuv").toString();case"jzazbz":return X.to("jzazbz").toString();case"jzczhz":return X.to("jzczhz").toString();case"ictcp":return X.to("ictcp").toString();default:return X.to(Y).toString()}}catch(q){return console.warn(`Unsupported colorspace '${Y}', falling back to hex. Error:`,q),X.to("srgb").toString({format:"hex"})}}async function R0(X,Z){return await kY(),cY(X,Z)}function x(X,Z){return cY(X,Z)}function jX(X,Z,Y,q){try{if(X=g(Z,q),Z.$type==="color"&&Z.original?.$value&&Z.original?.$value!==Z.$value){if(D(Z.original.$value))X=f(Z.original.$value,Y,q,Z);else X=S(Z);if(!j(q)&&Z.original?.$extensions?.mode?.[q])X=Z.original.$extensions.mode[q]}if(D(X))X=f(X,Y,q,Z);return x(X)}catch{return X=g(Z,q),x(X)}}function m(X){try{if(X)return new rX(X),!0;return!1}catch{return!1}}var xX=null;var AX=b(()=>{y()});function rY(X,Z){let Y=X.$extensions?.delimiter?.character||" ",q=g(X,Z)??{},$=X.$extensions?.sort??[],U=S(X)??{};if($.length>0)U=Object.keys(U).sort((W,K)=>{let z=$.indexOf(W),G=$.indexOf(K);return z-G}).reduce((W,K)=>{return W[K]=q[K],W},{});return Object.keys(U).reduce((W,K)=>{let z=S(q[K]);if(q[K]?.$type==="color"||q[K].$property==="color")z=x(z,q[K]);return[...Array.isArray(W)?W:[W],z]},[]).join(Y).trim()}function k(X,Z){let Y=($)=>{if($===void 0||$===null)return;if(typeof $==="object"&&"value"in $)return $.value;return $},q=X.match(/^\{(.+)\}$/);if(q){let $=q[1],U=Z.get($);if(U===void 0)return`/* Unknown token: ${$} */`;let W=Y(U);if(W===void 0)return`/* Unknown token: ${$} */`;if(typeof W==="object"&&W!==null){let K=[];for(let z in W){if(z.startsWith("$"))continue;let G=W[z],E=typeof G==="object"&&G?.value!==void 0?G.value:G;if(typeof E==="string"&&E.match(/^\{.+\}$/))K.push(k(E,Z));else K.push(String(E))}return K.join(" ")}if(typeof W==="string"&&W.match(/^\{.+\}$/))return k(W,Z);return String(W)}if(X.includes("{"))return X.replace(/\{([^}]+)\}/g,($,U)=>{let W=Z.get(U);if(W===void 0)return`/* Unknown token: ${U} */`;let K=Y(W);if(K===void 0)return`/* Unknown token: ${U} */`;if(typeof K==="object"&&K!==null)return`/* Cannot embed composite token: ${U} */`;if(typeof K==="string"&&K.match(/^\{.+\}$/))return k(K,Z);return String(K)});return X}function M0(X,Z,Y,q){return Object.keys(Z??{}).reduce((U,W)=>{let K=Z[W];if(typeof K==="string"||typeof K==="number")K={$value:K,$type:typeof K,value:K};if(K.$type=K.type||X?.original?.$value?.[W]?.type||K.$type||X.$type,!j(q)&&c(K,"mode",{isIncludedOriginalValue:!0}))K.$value=g(K,q);if(K?.$type==="composition"&&(typeof K.$value!=="string"||typeof K.$value!=="number"||D(K.$value))&&Object.keys(K).length>0){if(D(K.$value))return K.$value=f(K.$value,Y,q,K),{...U,[W]:{...K,$property:W,$type:K.$type,$value:YX(K,Y,q)}};return{...U,[W]:{...K,$property:W,$type:K.$type,$value:YX(K,Y,q)}}}if(K?.$value){let G=f(K.$value,Y,q,K);return{...U,[W]:{...K,$property:W,$type:K.$type,$value:G}}}return U},{})}function YX(X,Z,Y){let q=S(X,{isIncludedOriginalValue:!0});if(typeof q==="string"){if(D(q)){if(q=sX(q,Z,Y,X),!j(Y)&&c(q,"mode",{isIncludedOriginalValue:!0}))q.$value=g(q,Y)}let $=qX(q);if($&&($?.length??0)>1)q=ZX(q,$,Z,Y)}else if(Array.isArray(q))q=q.map(($)=>{if(typeof $==="string"&&D($))return f($,Z,Y,X);return $});if(!X.name)return q;return X.$value=M0(X,q,Z,Y),rY(X,Y)}var bX=b(()=>{y()});function S(X,Z){let{isIncludedOriginalValue:Y=!1,fallbackValue:q=null}=Z??{};if(Y)return X?.original?.$value??X?.$value??X.value??q;return X?.$value??X?.value??q}function g(X,Z){return Z&&(X?.$extensions?.mode?.[Z]||typeof X?.$extensions?.mode?.[Z]==="number")?X.$extensions.mode[Z]:S(X,{fallbackValue:X?.original?.$value??X?.$value??X?.value})??null}function c(X,Z,{isIncludedOriginalValue:Y=!1}={}){let q=!1;if(Y&&X?.original?.$extensions?.[Z])q=!0;if(X?.$extensions?.[Z])q=!0;return q}function iX(X,Z,Y){let q=S(X,{isIncludedOriginalValue:!0});if(!j(Y)&&c(X,"mode",{isIncludedOriginalValue:!0}))q=g(X,Y);if(D(q))return nX(q,Z,Y,X);return q}function ZX(X,Z,Y,q){let $=Z.reduce((U,W)=>{let K=aX(W,Y);if(!K)return U;let z=S(K,{isIncludedOriginalValue:!0});if(D(z))z=f(`{${W}}`,Y,q,K);return{...U,[W]:DX(K,z,Y,q)}},{});return X?.replace(/\{([^}]+)\}/g,(U,W)=>{return $[W]!==void 0?$[W]:U})??null}function sX(X,Z,Y,q){if(D(X))return f(X,Z,Y,q);return X}function aX(X,Z){return Z.allTokens.find((Y)=>Y.path.join(".")===X)??null}function f(X,Z,Y,q){let $=D(X),U=null,W=X??S(q),K=null;if($){if(U=aX($,Z),Y&&U&&U?.$extensions?.mode?.[Y]!==U.original?.$extensions?.mode?.[Y])W=U.original?.$extensions?.mode?.[Y],K=U.original?.$extensions?.alpha??K;else if(U?.$extensions?.mode?.[Y])W=U.$extensions.mode[Y],K=U.$extensions?.alpha??K;else if(U?.original?.$value)W=U?.original.$value??U?.$value,K=U?.original.$extensions?.alpha??K}if(W!==X&&D(W))W=f(W,Z,Y,q);if(W&&(K||q?.$extensions?.alpha||K===0||q?.original?.$extensions?.alpha===0))K=K??q?.$extensions?.alpha??null,W=zX(W,K);return W=x(W,U??q),W??X}function nX(X,Z,Y,q){let $=q?.original?.$extensions?.mode?.[Y]??q?.original?.$value,U=D($);if(Y&&U){let W=Z.allTokens.find((z)=>z.path.join(".")===U);if(!W)return X;let K=S(W);if(D(K))return nX(K,Z,Y,W);if(W?.$extensions?.mode?.[Y])K=W.$extensions.mode[Y];if(K&&W?.$extensions?.alpha)K=zX(W.$value,W.$extensions.alpha);return x(K,W)??X}else if($)return x($,q);return X}function D(X){if(typeof X!=="string")return null;let Z=/{[^}]+}/g,Y=X.match(Z);if(Y?.length!==1)return null;return Y[0].slice(1,-1)}function qX(X){if(typeof X!=="string")return null;return[...X.matchAll(/\{([^}]+)\}/g)].map(([,Y])=>Y)??null}function $X(X){return X}function EX(X){return X}var tX=b(()=>{y()});var JZ={};lX(JZ,{wrapThemeValue:()=>HY,wrapFormatCSSFile:()=>HZ,typographyFileName:()=>ZZ,tokensFileName:()=>XZ,removeDirectoryContents:()=>zY,readConfigFile:()=>WX,namespaceUUID:()=>UZ,iconsFileName:()=>qZ,getTokenfileName:()=>KZ,getRelativePath:()=>OZ,getRelativeCSSPath:()=>QZ,getRawTokensFileName:()=>AZ,getProjectPaths:()=>p,getProjectModes:()=>EY,getProjectMetaData:()=>V,getProjectFonts:()=>S0,getLazyTokensConfig:()=>oX,getLazyProjectPaths:()=>LY,getLazyProjectModes:()=>LX,getLazyProjectMetaData:()=>OX,getLazyProjectFonts:()=>P0,getLazyProjectData:()=>l,getLazyIcons:()=>TX,getJSDocHeader:()=>EZ,getIconDestinationFileName:()=>KX,getFiles:()=>VX,getFileHeader:()=>AY,getDistThemeFileDelimeter:()=>WZ,getDistConfigFile:()=>SX,getDestinationFileName:()=>GZ,getDefaultIconObjectPath:()=>$Z,getCSSDestinationFileName:()=>zZ,getBaseDirectory:()=>t,getBaseConfigFile:()=>_X,generatedFileHeader:()=>UX,filterTokensByType:()=>PX,createFileHeaderTitle:()=>HX,compileConfigFile:()=>GY,combineCSSFiles:()=>_Z,checkAndCreateDirectory:()=>n,breakpointFileName:()=>YZ});import{spawnSync as N0}from"child_process";import{existsSync as v,mkdirSync as F0,readFileSync as x0,unlinkSync as sY,writeFileSync as j0}from"fs";import{readdir as tY,rmdir as b0,unlink as D0}from"fs/promises";import{resolve as oY,join as N,basename as eY,normalize as iY,relative as aY,sep as eX,dirname as nY}from"path";async function $Z(){return`${(await QX()).$metaData?.tokenNamespace||"tokens"}.icons`}async function GY(X){let Y=N(X,"designid.config.ts");if(v(N(X,"designid.config.mjs")))sY(N(X,"designid.config.mjs"));let q=N(X,"designid.config.js");if(v(q))sY(q);if(v(Y)){let $=N0("bun",["build",Y,"--outfile ./designid.config.mjs","--minify","--target","node","--packages","external","--no-bundle"],{stdio:"inherit",cwd:X,shell:!0});if($.status!==0)console.error("Failed to compile designid.config.mjs with bun."),process.exit($.status??1);if($.status===0)return new Promise((U)=>U(!0))}}async function zY(X){try{if(v(X)){let Z=await tY(X,{withFileTypes:!0});for(let Y of Z){let q=N(X,Y.name);if(Y.isDirectory())await zY(q),await b0(q);else await D0(q)}}}catch(Z){console.error(`Error removing contents of ${X}:`,Z)}}async function VX(X){let Z=await tY(X,{withFileTypes:!0}),Y=await Promise.all(Z.map((q)=>{let $=oY(X,q.name);return q.isDirectory()?VX($):$}));return Array.prototype.concat(...Y)}async function UZ(X){let{dsNamespace:Z,tokenNamespace:Y}=await V();return`${(Z??Y).toUpperCase()}DesignSystem${X.charAt(0).toUpperCase()+X.slice(1)}Tokens`}function KZ(X,Z="d.ts",Y){if(!X)return`tokens.${Y}.config.${Z}`;return N(X,`tokens.${Y}.config.${Z}`)}function WZ(X,Z){return X.length>1?`.${Z}`:""}async function GZ(X="d.ts",Z){let{tokenNamespace:Y}=await V();if(Z)return`${Y}-design-system.${Z}.tokens.config.${X}`;return`${Y}-design-system.tokens.config.${X}`}async function KX(X="json"){let{tokenNamespace:Z}=await V();return`${Z}-design-system.tokens.svg${X==="d.ts"||X==="js"?".config":""}.${X}`}async function zZ(){let{tokenNamespace:X}=await V();return`${X}-design-system.tokens.css`}async function AZ(){let{tokenNamespace:X}=await V();return`${X}-design-system-raw.tokens.json`}async function AY(X){let{tokenNamespace:Z}=await V();return`${Z} | ${X}`}function EZ(X,Z){return`/** @type {import("./${X}").${Z}} */`}function HX(X){return`/* ${AY(X)} */`}function n(X){if(!v(X))F0(X,{recursive:!0})}async function WX(X,Z=!1){let Y=_X(),q;if(Y.endsWith(".json"))q=JSON.parse(x0(Y,"utf8").trim()??"{}");else if(Y.endsWith(".ts"))if(typeof globalThis.Bun<"u"){if(q=await import(Y),q.default)q=q.default}else{X=X??nY(Y)+"/";let U=SX(X);if(U&&(Z||!v(U)))await GY(X);if(q=await import(U),q.default)q=q.default}else{X=X??nY(Y)+"/";let $=SX(X);if($&&(Z||!v($)))await GY(X);if(q=await import($),q.default)q=q.default}return q}async function t(X=!1){let{baseDir:Z}=await p(),Y=process.cwd(),$=N(Y,Z),{buildDir:U,distDir:W}=await p();if(X)try{n(N($,U)),n(N($,W))}catch(K){console.error("Error creating directories:",K)}return $}function SX(X){return X?N(X,"designid.config.mjs"):N(process.cwd(),"designid.config.mjs")}function _X(){let X=process.argv.find((K)=>K.startsWith("--config=")),[,Z]=X?.split("=")??[];if(Z)return Z;let Y=process.cwd(),q=SX(Y),$=N(Y,"designid.config.ts"),U=v(q),W=v($);if(U)return q;else if(W)return $;throw console.error("Config file not found"),Error("Config file not found")}async function p(X=!1){let Z=_X(),q=(await WX(process.cwd(),X)).$paths;if(!q)throw console.error("Project paths not found"),Error("Project paths not found");return{configFile:Z,...q}}async function V(){let Z=(await WX(process.cwd())).$metaData;if(!Z)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!Z.colorspace)Z.colorspace="hex";if(!Z.fontNamespace)Z.fontNamespace=`${Z.dsNamespace}.font`;if(!Z?.tokens?.css?.mediaQuery?.match)Z={...Z??{},tokens:{...Z.tokens??{},css:{...Z.tokens?.css??{},mediaQuery:{...Z.tokens?.css?.mediaQuery??{},match:"[data-theme]"}}}};if(Z?.tokens?.css?.mediaQuery&&typeof Z.tokens.css.mediaQuery.separateThemeFiles!=="boolean")Z.tokens.css.mediaQuery.separateThemeFiles=!1;if(!Z.dsNamespace)Z.dsNamespace=Z.tokenNamespace;let Y=await $Z();return{...Z,icons:Z.icons??{objectPath:Y},dsNamespace:Z.dsNamespace}}async function EY(){return(await WX(process.cwd())).$modes??{default:"light"}}async function QX(){if(!XY){let X=_X();XY=await WX(process.cwd()),LZ=X}return XY}async function LX(){if(!YY)YY=(await QX()).$modes??{default:"light"};return YY}async function OX(){if(!ZY){let Z=(await QX()).$metaData;if(!Z)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!Z.dsNamespace)Z.dsNamespace=Z.tokenNamespace;let q=`${Z.tokenNamespace||"tokens"}.icons`;ZY={...Z,icons:Z.icons??{objectPath:q},dsNamespace:Z.dsNamespace}}return ZY}async function LY(X=!1){if(!qY){let Y=(await QX()).$paths;if(!Y)throw console.error("Project paths not found"),Error("Project paths not found");qY={configFile:LZ,...Y}}return qY}async function l(){if(!$Y){let{distDir:X,assets:Z,buildDir:Y}=await LY(!0),{fontNamespace:q,tokenNamespace:$,icons:U}=await OX(),W=await t(),K=process.cwd(),z=N(K,X,"css");$Y={distDir:X,assets:Z,fontNamespace:q,__dirname:W,workspaceRoot:K,distCSSPath:z,buildDir:Y,tokenNamespace:$,icons:U}}return $Y}async function TX(){if(!UY){let{icons:X}=await OX();UY=X}return UY}async function oX(){if(!KY){let{tokens:X}=await OX();KY=X}return KY}async function S0(){return(await WX(process.cwd())).$fonts??[]}async function P0(){if(!WY)WY=(await QX()).$fonts??[];return WY}async function HY(X){if(j(X))return":root";let Y=(await V())?.tokens?.css?.mediaQuery?.match??"[data-theme]";if(Y.startsWith("[")&&Y.endsWith("]"))return`${Y.replace("]",`="${X}"]`)}`;else if(Y.startsWith(".")||Y.startsWith("#"))return`${Y}${X}`;else return`${Y}${X}`}async function HZ(X,Z,Y,q,$,U={}){let W;if(j(Y))W=Z.allTokens;else W=X(Z,Y);let z=(await V())?.tokens?.css?.mediaQuery?.separateThemeFiles?"Theme: "+Y:U.headerTitle??"",G=`${HX(z)}
|
|
3
|
+
${UX}`,E=j(Y)?`:root {
|
|
4
4
|
`:`@media (123prefers-color-scheme: ${Y}) {
|
|
5
5
|
:root {
|
|
6
|
-
`,
|
|
6
|
+
`,A=`${G}
|
|
7
7
|
|
|
8
|
-
${E}`;if(W.forEach((L)=>{if(
|
|
9
|
-
`}),Array.isArray(
|
|
10
|
-
`;for(let H of
|
|
11
|
-
|
|
8
|
+
${E}`;if(W.forEach((L)=>{if(PX(L,U,$))return;let H=CX(L,Z,Y);if(U.transformValue)H=U.transformValue(H);H=EX(H),A+=`${!j(Y)?" ":" "}--${$X(L.name)}: ${H};
|
|
9
|
+
`}),Array.isArray(q)&&q.length>1){let L=`
|
|
10
|
+
`;for(let H of q){if(Y===H)continue;let _=await HY(H);L+=`${!j(Y)?" ":" "}&${_} {
|
|
11
|
+
`,X(Z,H).forEach((J)=>{if(PX(J,U,$))return;let O=CX(J,Z,H);if(U.transformValue)O=U.transformValue(O);O=EX(O),L+=`${!j(Y)?" ":" "}--${$X(J.name)}: ${O};
|
|
12
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 PX(X,Z,Y){let{namespace:q}=Z.filter??{};if(!X.$type)return!0;if(q?.length&&X.path){let $=X.path.join("."),U=q.some((K)=>$.startsWith(K)),W=Z.filter?.isInclusion!==void 0&&Z.filter.isInclusion;return U&&!W||!U&&W}if(Z.filter?.isInclusion!==void 0&&Z.filter.isInclusion===!1){if(X.$type&&!Y.includes(X.$type))return!0}else if(!X.$type||Y.includes(X.$type))return!0;return!1}async function _Z(){let X=await EY(),{baseDir:Z,distDir:Y}=await p(),q=await VX(N(Z,Y,"css")),$=N(Z,Y,await zZ()),U=UX+`
|
|
18
18
|
|
|
19
|
-
`,W=[{name:
|
|
20
|
-
`}}),!
|
|
19
|
+
`,W=[{name:qZ,order:100},{name:XZ,order:200},{name:ZZ,order:300},{name:YZ,order:400}];if(q=q.sort((K,z)=>{let G=(E)=>{let A=eY(E,".css"),L=W.find((H)=>A.includes(H.name));for(let H in X)if(A.includes(H)){let _=X[H]===X.default?1:2;return L?L.order+_:0}return L?L.order:0};return G(K)-G(z)}),q.forEach((K)=>{if(K.endsWith(".css")){let G=`@import url("${QZ(K,Z,Y)}");`;U+=G+`
|
|
20
|
+
`}}),!v(N(Z,Y)))n(N(Z,Y));j0($,U)}function QZ(X,Z,Y){let q=oY(Z,Y);return X.startsWith(q)?X.slice(q.length+1):X}function OZ(X,Z,Y,q){let $=iY(X),U=eY(iY(Z)),W=$.split(eX),K=W.lastIndexOf(U);if(U===".")return aY(Y,q).split(eX).join("/");else if(K===-1)throw Error(`Base directory '${U}' not found in '${$}'`);let z=N(...W.slice(0,K+1)),G=N(z,Y),E=N(z,q);return aY(G,E).split(eX).join("/")}var XZ="tokens",YZ="breakpoints",ZZ="typography",qZ="icons",UX=`/*
|
|
21
21
|
* This file is automatically generated.
|
|
22
22
|
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
23
23
|
* Changes will be overwritten. Please update the source design tokens instead.
|
|
24
|
-
*/`,
|
|
24
|
+
*/`,XY=null,LZ=null,YY=null,ZY=null,qY=null,$Y=null,UY=null,KY=null,WY=null;var JX=b(()=>{y()});function j(X){return X===_Y}var _Y="light";var BZ=b(()=>{JX()});async function QY(X){let Z=await TX();X=X.replace(/<\?xml[^>]*\?>\s*/,""),X=X.replace(/<!DOCTYPE [^>]*>\s*/,"");let Y=X.match(/<svg[^>]*>/),q=X.match(/viewBox="([\d\s.]+)"/),[$]=Y??[],U=$;if($&&U){let K=Z?.style?.fill||Z?.style?.stroke?.color,z=/id="[^"]*"/.test($);if(!U.includes("xmlns="))U=U.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"');if(!z&&K)U=U.replace("<svg",`<svg id="${K}"`);else if(z&&K)U=U.replace(/id="[^"]*"/,`id="${K}"`)}if(q&&$&&U){let K=q[1].split(" ").map(Number),z=K[2],G=K[3],E=Z?.size??24,A=z/G*E;X=X.replace(/height="[\d.]+px?"/,`height="${E}px"`),X=X.replace(/width="[\d.]+px?"/,`width="${A}px"`);let L=/width="[\d.]+(px)?"/.test($),H=/height="[\d.]+(px)?"/.test($);if(!L)U=U.replace("<svg",`<svg width="${A}px"`);else U=U.replace(/width="[\d.]+(px)?"/,`width="${A}px"`);if(!H)U=U.replace("<svg",`<svg height="${E}px"`);else U=U.replace(/height="[\d.]+(px)?"/,`height="${E}px"`);X=X.replace($,U)}if(!X?.match(/data-style="([^"]*)"/)&&Z?.style?.type)X=X.replace("<svg ",`<svg data-style="${Z.style.type}" `);if(Z?.style?.type)X=C0(X,Z.style);return X}function C0(X,Z){switch(Z.type){case"mono":if(X=X.replace(/stroke="[^"]*"/g,""),X=X.replace(/stroke-width="[^"]*"/g,""),X=X.replace(/stroke-linecap="[^"]*"/g,""),X=X.replace(/stroke-linejoin="[^"]*"/g,""),X=X.replace(/fill="none"/g,'fill="currentColor"'),Z.fill&&!X.includes("fill="))X=X.replace("<svg",'<svg fill="currentColor"');else if(Z.fill)X=X.replace(/fill="(?!currentColor)[^"]*"/g,'fill="currentColor"');break;case"stroke":if(Z.stroke){let{color:q,width:$,linecap:U,linejoin:W}=Z.stroke;if(q){if(X=X.replace(/stroke="[^"]*"/g,'stroke="currentColor"'),!X.includes("stroke="))X=X.replace("<svg",'<svg stroke="currentColor"')}if($!==void 0){let K=typeof $==="number"?`${$}`:$;if(X=X.replace(/stroke-width="[^"]*"/g,`stroke-width="${K}"`),!X.includes("stroke-width="))X=X.replace("<svg",`<svg stroke-width="${K}"`)}if(U){if(X=X.replace(/stroke-linecap="[^"]*"/g,`stroke-linecap="${U}"`),!X.includes("stroke-linecap="))X=X.replace("<svg",`<svg stroke-linecap="${U}"`)}if(W){if(X=X.replace(/stroke-linejoin="[^"]*"/g,`stroke-linejoin="${W}"`),!X.includes("stroke-linejoin="))X=X.replace("<svg",`<svg stroke-linejoin="${W}"`)}if(!X.includes("fill="))X=X.replace("<svg",'<svg fill="none"')}break;case"fill":if(X=X.replace(/stroke="[^"]*"/g,""),X=X.replace(/stroke-width="[^"]*"/g,""),Z.fill){if(X=X.replace(/fill="[^"]*"/g,'fill="currentColor"'),!X.includes("fill="))X=X.replace("<svg",'<svg fill="currentColor"')}break;case"animated":case"custom":break;default:break}return X}var IZ=b(()=>{y()});var wZ=b(()=>{JX();y()});import{copyFileSync as y0,existsSync as g0,mkdirSync as RZ,statSync as f0}from"fs";import{writeFile as v0}from"fs/promises";import{join as T,relative as h0}from"path";async function OY(X,Z){try{let{assets:Y,workspaceRoot:q,distDir:$,__dirname:U}=await l(),W=Y?.fonts?.sourceDir?T(U,Y.fonts.sourceDir):null,K=T("assets","fonts"),z=T(q,$),G=Y?.fonts?.distDir?T(z,Y.fonts.distDir.replace(/^\.\//,"")):T(z,K);if(!X||!W)return;let E="",A=Z&&Y?.fonts?.distDir?T(Z,Y.fonts.distDir.replace(/^\.\//,"")):G;for(let Q of X){if(!Q)continue;if(E+=`/**** ${Q.family} ${Q.style} ****/
|
|
25
25
|
`,Q.linkHref){let O=await(await fetch(Q.linkHref)).text();E+=`${O.replace(/\s+/g," ").replace(/:\s+/g,":")}
|
|
26
|
-
`}else if(Q?.src&&W){let
|
|
26
|
+
`}else if(Q?.src&&W){let J=Q.directory??Q.family.toLowerCase().replace(/\s+/g,"-"),O=T(W,J,Q.src);try{if(!g0(O)||!f0(O).isFile()){console.warn(`Font file not found: ${O}`);continue}}catch{console.warn(`Error accessing font file: ${O}`);continue}try{RZ(T(A,J),{recursive:!0}),y0(T(W,J,Q.src),T(A,J,Q.src))}catch(R){console.warn(`Error copying font file ${Q.src}:`,R instanceof Error?R.message:R);continue}let w;if(Y?.fonts?.cssImportPath)w=T(Y.fonts.cssImportPath,J,Q.src).replace(/\\/g,"/");else{let{distCSSPath:R}=await l(),B=Z?T(Z,"css"):R,I=h0(B,A);w=T(I,J,Q.src).replace(/\\/g,"/")}E+=`@font-face {
|
|
27
27
|
font-family: "${Q.family}";
|
|
28
28
|
font-style: ${Q.faceStyle};
|
|
29
29
|
font-weight: ${Q.weight};
|
|
30
|
-
src: url("${
|
|
30
|
+
src: url("${w}") format("${Q.format}");
|
|
31
31
|
}
|
|
32
|
-
`}}let{distCSSPath:L}=await l(),H=
|
|
33
|
-
${G.map((
|
|
34
|
-
`)}`;throw Error(E)}return K}function V2($,X,Y){let Z=[];if(X.generateModes&&$.extensions?.mode){for(let[q,U]of Object.entries($.extensions.mode))if(U!==void 0)Z.push({...$,name:`${$.name}#${q}`,value:U,path:[...$.path,`#${q}`]})}if(X.generateModes&&!$.extensions?.mode&&(Array.isArray($.value)||typeof $.value==="object"&&$.value!==null)){let q=!1,U=!1,W=(K)=>{if(typeof K!=="object"||K===null)return!1;if(K.$extensions?.mode)return!0;return Object.values(K).some((A)=>{if(typeof A==="object"&&A!==null)return W(A);return!1})};if(Array.isArray($.value))q=$.value.some((K)=>typeof K==="string"&&K.includes("{")||typeof K==="object"&&K!==null&&Object.values(K).some((A)=>typeof A==="string"&&A.includes("{"))),U=$.value.some((K)=>W(K));else q=Object.values($.value).some((K)=>typeof K==="string"&&K.includes("{")),U=W($.value);if(q||U){if(["color","shadow","border","background","surface","composition"].includes($.type)){let G;if(Array.isArray($.value))G=$.value.map((E)=>{if(typeof E==="string"&&E.startsWith("{")&&E.endsWith("}")){let z=E.slice(1,-1);if(!z.includes("#dark")&&!z.includes("@dark"))return`{${z}#dark}`;return E}else if(typeof E==="object"&&E!==null){let z={};for(let[L,H]of Object.entries(E))if(typeof H==="string"&&H.startsWith("{")&&H.endsWith("}")){let _=H.slice(1,-1),Q=`${_}#dark`,w=Y?.get(_),O=Y?.has(Q)||w?.extensions?.mode?.dark!==void 0||w&&(Array.isArray(w.value)||typeof w.value==="object"&&w.value!==null);if(!_.includes("#dark")&&!_.includes("@dark")&&O)z[L]=`{${Q}}`;else z[L]=H}else z[L]=H;return z}return E});else if(typeof $.value==="object"&&$.value!==null){G={};let E=(z)=>{if(typeof z==="string"){if(z.startsWith("{")&&z.endsWith("}")){let L=z.slice(1,-1),H=`${L}#dark`,_=(w,O=new Set)=>{if(O.has(w))return!1;O.add(w);let B=Y?.get(w);if(!B){let I=w.match(/^(.+)@([^@]+)$/);if(I){let[,J,R]=I,f=Y?.get(J);if(f){if(f.extensions?.mode?.dark!==void 0)return!0;if(f.extensions?.generators)return!0;return _(J,O)}}return!1}if(B.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${w}#dark`))return!0;if(typeof B.value==="string"&&B.value.startsWith("{")&&B.value.endsWith("}")){let I=B.value.slice(1,-1);return _(I,O)}if(Array.isArray(B.value)||typeof B.value==="object"&&B.value!==null){let I=(J)=>{if(typeof J!=="object"||J===null)return!1;if(J.$extensions?.mode)return!0;return Object.values(J).some((R)=>{if(typeof R==="object"&&R!==null)return I(R);return!1})};if(Array.isArray(B.value))return B.value.some((J)=>typeof J==="string"&&J.includes("{")&&_(J.slice(1,-1),new Set(O))||typeof J==="object"&&J!==null&&(Object.values(J).some((R)=>typeof R==="string"&&R.includes("{")&&_(R.slice(1,-1),new Set(O)))||I(J)));else if(typeof B.value==="object")return Object.values(B.value).some((J)=>typeof J==="string"&&J.includes("{")&&_(J.slice(1,-1),new Set(O)))||I(B.value)}return!1},Q=_(L);if(!L.includes("#dark")&&!L.includes("@dark")&&Q)return`{${H}}`}return z}if(typeof z==="object"&&z!==null){if(z.$extensions?.mode?.dark)return z.$extensions.mode.dark;let L={};for(let[H,_]of Object.entries(z))L[H]=E(_);return L}return z};for(let[z,L]of Object.entries($.value))G[z]=E(L)}Z.push({...$,name:`${$.name}#dark`,value:G,path:[...$.path,"#dark"],extensions:{...$.extensions,autoGenerated:!0}})}}}if(X.generateModes&&!$.extensions?.mode&&typeof $.value==="string"&&$.value.startsWith("{")&&$.value.endsWith("}")){let q=$.value.slice(1,-1),U=(E,z=new Set)=>{if(z.has(E))return!1;z.add(E);let L=Y?.get(E);if(!L){let H=E.match(/^(.+)@([^@]+)$/);if(H){let[,_,Q]=H,w=Y?.get(_);if(w){if(w.extensions?.mode?.dark!==void 0)return!0;if(w.extensions?.generators)return!0;return U(_,z)}}return!1}if(L.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${E}#dark`))return!0;if(typeof L.value==="string"&&L.value.startsWith("{")&&L.value.endsWith("}")){let H=L.value.slice(1,-1);return U(H,z)}if(Array.isArray(L.value)||typeof L.value==="object"&&L.value!==null){let H=(_)=>{if(typeof _!=="object"||_===null)return!1;if(_.$extensions?.mode)return!0;return Object.values(_).some((Q)=>{if(typeof Q==="object"&&Q!==null)return H(Q);return!1})};if(Array.isArray(L.value))return L.value.some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(z))||typeof _==="object"&&_!==null&&(Object.values(_).some((Q)=>typeof Q==="string"&&Q.includes("{")&&U(Q.slice(1,-1),new Set(z)))||H(_)));else if(typeof L.value==="object")return Object.values(L.value).some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(z)))||H(L.value)}return!1},W=U(q);if(["color","shadow","border","background","surface","composition"].includes($.type)&&W&&W&&!q.includes("#dark")&&!q.includes("@dark")){let E=`{${q}#dark}`;Z.push({...$,name:`${$.name}#dark`,value:E,path:[...$.path,"#dark"],extensions:{...$.extensions,autoGenerated:!0}})}}if(X.generateDerivedTokens&&$.extensions?.generators)for(let q of $.extensions.generators)for(let[U,W]of Object.entries(q.value)){let K=F2($.name,U),{generators:A,...G}=$.extensions;Z.push({...$,name:K,value:$.value,path:[...$.path,U],extensions:{...G,generator:{type:q.type,value:W}}})}if(X.generateBreakpointTokens&&$.extensions?.breakpoints)for(let[q,U]of Object.entries($.extensions.breakpoints)){let W=`${$.name}@${q.replace(/[^a-zA-Z0-9]/g,"_")}`,K=U.$value||U.value;if(K&&typeof K==="object"&&"$value"in K)K=K.$value;else if(!K&&typeof U==="object"){let{...E}=U;if(Object.keys(E).length>0)K=E}let A=U.$extensions||U.$extensions,G=U.$type;if(!G&&U.value&&typeof U.value==="object")G=U.value.$type;Z.push({...$,name:W,value:K,path:[...$.path,`@${q}`],type:G||$.type,extensions:{mediaQuery:q,...A?{mode:A.mode||A.$mode,generators:A.generators||A.$generators,...Object.fromEntries(Object.entries(A).filter(([E])=>!["mode","$mode","generators","$generators"].includes(E)))}:{}}})}return Z}function lY($,X){let Y=n($.value,X),Z=$.type;if(typeof $.value==="string"&&O$($.value)){let U=$.value.slice(1,-1),W=X.tokens.get(U);if(W){if(["border","shadow","typography","composition"].includes(W.type))Z=W.type;else if(typeof W.value==="string"&&w$(W.value)){let K=V$(W.value),A=new Set;for(let G of K)if(G.type==="reference"&&G.ref&&typeof G.ref==="string"){let E=G.ref.slice(1,-1),z=X.tokens.get(E);if(z&&["border","shadow","typography","composition"].includes(z.type))A.add(z.type)}if(A.size===1)Z=Array.from(A)[0]}}}if(typeof $.value==="string"&&w$($.value)){let U=V$($.value),W=new Set;for(let K of U)if(K.type==="reference"&&K.ref&&typeof K.ref==="string"){let A=K.ref.slice(1,-1),G=X.tokens.get(A);if(G&&["border","shadow","typography","composition"].includes(G.type))W.add(G.type)}if(W.size===1)Z=Array.from(W)[0]}if(typeof Y==="object"&&Y!==null&&["border","shadow","typography","composition"].includes(Z))Y=r(Y,X);if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=T$($.value,$.extensions.generator.type,$.extensions.generator.value,X);let q=rY($.name,X.options);if(Z==="color"&&typeof Y==="string"&&p(Y))Y=F(Y,$);if(typeof Y==="string"&&d(Y))Y=B$(Y);return{...$,type:Z,value:Y,cssVar:q}}function r($,X){if(typeof $==="string"){if(O$($))return R0($,X);else if(w$($))return h2($,X)}if(Array.isArray($))return $.map((Y)=>r(Y,X));if(typeof $==="object"&&$!==null){if("$value"in $&&typeof $.$value==="string")return r($.$value,X);if("value"in $&&typeof $.value==="string"&&"$type"in $){if(X.mode&&$.$extensions?.mode?.[X.mode])return r($.$extensions.mode[X.mode],X);return r($.value,X)}if("value"in $&&typeof $.value==="object"&&"$type"in $){let Z=$.value,q=$.$extensions?.delimiter?.character||" ";if($.$type==="composition"&&Z&&typeof Z==="object")return Object.values(Z).map((W)=>r(W,X)).join(q);return r($.value,X)}let Y={};for(let[Z,q]of Object.entries($))Y[Z]=r(q,X);return Y}return $}function n($,X){if(typeof $==="string"){if(w$($))return h2($,X);else if(O$($))return R0($,X)}else if(typeof $==="object"&&$!==null&&"$ref"in $)return y2($,X);return $}function R0($,X){let Y=$.slice(1,-1),Z=X.tokens.get(Y),q=X.options.modes||[];if(!Z){if(q.length>0){for(let K of q)if(Y.endsWith(`@${K}`)){let A=Y.slice(0,-K.length-1)+`#${K}`;if(Z=X.tokens.get(A),Z)return w0(Z,X);break}}let W=Y.match(/#([^#@]+)$/);if(W){let K=Y.substring(0,W.index),A=W[1];if(Z=X.tokens.get(K),Z){if(Z.extensions?.mode?.[A]){let G=Z.extensions.mode[A],E=n(G,{...X,mode:A});if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)E=T$(E,Z.extensions.generator.type,Z.extensions.generator.value,X);if(Z.type==="color"&&typeof E==="string"&&p(E))E=F(E,Z);if(typeof E==="string"&&d(E))E=B$(E);return E}}}if(q.length>0)for(let K of q){let A=new RegExp(`(@[^@]+)@${K}$`);if(A.test(Y)){let G=Y.replace(A,`$1#${K}`);if(Z=X.tokens.get(G),!Z){let E=G.match(/#([^#@]+)$/);if(E){let z=G.substring(0,E.index),L=E[1];if(Z=X.tokens.get(z),Z&&Z.extensions?.mode?.[L]){let H=Z.extensions.mode[L],_=n(H,{...X,mode:L});if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)_=T$(_,Z.extensions.generator.type,Z.extensions.generator.value,X);if(Z.type==="color"&&typeof _==="string"&&p(_))_=F(_,Z);if(typeof _==="string"&&d(_))_=B$(_);return _}}}else return w0(Z,X);break}}}if(!Z)return console.warn(`Token reference not found: ${$}`),X.brokenReferences.push($),$;return w0(Z,X)}function w0($,X){let Y;if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=T$($.value,$.extensions.generator.type,$.extensions.generator.value,X);else if(X.mode&&$.extensions?.mode?.[X.mode])Y=n($.extensions.mode[X.mode],X);else Y=n($.value,X);if($.type==="color"&&typeof Y==="string"&&p(Y))Y=F(Y,$);if(typeof Y==="string"&&d(Y))Y=B$(Y);return Y}function y2($,X){let Z=$.$ref.slice(2).replace(/\//g,"."),q=X.tokens.get(Z);if(!q)return console.warn(`JSON Pointer reference not found: ${$.$ref}`),X.brokenReferences.push($.$ref),$.$ref;return n(q.value,X)}function h2($,X){let Y=V$($),Z=Y.some((W)=>W.value.includes(",")),q=!0,U=[];for(let W of Y){let K;if(W.type==="reference"&&W.ref){if(typeof W.ref==="string"&&O$(W.ref)){K=R0(W.ref,X);let A=W.ref.slice(1,-1),G=X.tokens.get(A);if(!G||!["border","shadow","typography","composition"].includes(G.type))q=!1}else if(typeof W.ref==="object"&&"$ref"in W.ref)K=y2(W.ref,X)}else if(K=W.value,W.value.trim()&&W.value.trim()!==",")q=!1;U.push(K)}if(Z&&q)return U.filter((W)=>typeof W==="object"&&W!==null&&typeof W!=="string");return U.map((W)=>String(W)).join("")}function T$($,X,Y,Z){let q=n($,Z);switch(X){case"alpha":if(typeof q==="string")return iY(q,Number(Y)/100);break;case"scale":if(typeof q==="string"&&q.match(/[\d.]+/))return sY(q,Number(Y));break;case"hue":if(typeof q==="string")return aY(q,Number(Y));break;default:return console.warn(`Unknown generator type: ${X}`),q}return q}function rY($,X,Y){let Z=$.replace(/\./g,"-");Z=Z.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),Z=Z.replace(/@[^@#]*(?:screen|width|height|min|max|orientation).*$/i,""),Z=Z.replace(/#[^#]*$/,""),Z=Z.replace(/-@/g,"-").replace(/@/g,"-");let q=Z,U=!0,W=X.prefix||"";if(X.transformName){if(q=X.transformName(Z),q=q.replace(/-+$/,""),q!==Z)U=!1}let K=U&&W?`${W}-${q}`:q,A=Y?`-${Y}`:"";return`--${K}${A}`.replace(/[^a-zA-Z0-9-_]/g,"-")}function iY($,X){try{if(!p($))return $;let Y=new T2($);return Y.alpha=X,F(Y)}catch(Y){return console.warn(`Failed to apply alpha to color "${$}": ${Y}`),$}}function sY($,X){let Y=$.match(/([\d.]+)(\w+)/);if(Y){let[,Z,q]=Y;return`${parseFloat(Z)*X}${q}`}return $}function aY($,X){try{if(!p($))return $;let Z=new T2($).to("oklch");return Z.h=(Z.h+X)%360,F(Z)}catch(Y){return console.warn(`Failed to shift hue for color "${$}": ${Y}`),$}}var M0=S(()=>{D2();G$()});function N0($){if($.type==="typography"||$.type==="fontWeight"||$.type==="fontFamily")return!0;if($.type==="dimension"&&$.name.includes("typography"))return!0;if($.name.includes("typography")||$.name.includes("font"))return!0;return!1}function t($,X,Y){if(Y){if($===X)return":host";return`:host([data-theme="${$}"])`}if($===X)return":root";return`[data-theme="${$}"]`}function g$($,X={}){let{rootSelector:Y=":root",separateThemeFiles:Z=!1,generateMediaQueries:q=!1,customHeader:U,modes:W=["light","dark"]}=X;if(Z)return tY($,X);let K=new Map,A=new Map;for(let B of W)K.set(B,[]);let G=W.join("|"),E=new RegExp(`#(${G})$`);for(let B of $){if(typeof B.value==="string"&&d(B.value))continue;if(N0(B))continue;let I=` ${B.cssVar}: ${v(B.value,B.type)};`;if(q&&B.name.includes("@media")){let R=h$(B);if(R){if(!A.has(R))A.set(R,[]);A.get(R).push(I);continue}}let J=B.name.match(E);if(J){let R=J[1];if(!K.has(R))K.set(R,[]);K.get(R).push(I)}else{let R=W[0]||"light";K.get(R).push(I)}}let z="";if(U)z+=`${U}
|
|
32
|
+
`}}let{distCSSPath:L}=await l(),H=Z?T(Z,"css"):L,_=`${H}/fonts.css`;RZ(H,{recursive:!0}),await v0(_,E,{flag:"w",encoding:"utf-8"})}catch(Y){console.error("Error appending typography tokens:",Y)}}var JY=b(()=>{y()});function BX(X){if(typeof X!=="string"||!X.startsWith("{")||!X.endsWith("}"))return!1;let Z=X.slice(1,-1);return!Z.includes("{")&&!Z.includes("}")&&Z.trim()!==""}function IX(X){if(typeof X!=="string")return!1;let Z=/\{[^}]+\}/g,Y=X.match(Z);return!!(Y&&Y.length>0&&X.length>Y.join("").length)}function yX(X){let Z=[],Y=/\{[^}]+\}/g,q=0,$;while(($=Y.exec(X))!==null){if($.index>q){let W=X.slice(q,$.index);if(W)Z.push({type:"literal",value:W})}let U=$[0];if(U.startsWith("{#/"))Z.push({type:"reference",value:U,ref:{$ref:U.slice(2,-1)}});else Z.push({type:"reference",value:U,ref:U});q=$.index+$[0].length}if(q<X.length){let U=X.slice(q);if(U)Z.push({type:"literal",value:U})}return Z}function MZ(X){return!!X.$extensions?.$mode}function NZ(X){return!!(X.$extensions?.$generators&&Array.isArray(X.$extensions.$generators))}function FZ(X){return!!(X.$extensions?.$breakpoints&&typeof X.$extensions.$breakpoints==="object")}function xZ(X,Z){return`${X}${Z}`}function jZ(X){return typeof X==="object"&&X!==null&&"$value"in X}function bZ(X){return typeof X==="object"&&X!==null&&!("$value"in X)}var DZ=()=>{};function SZ(X){if(typeof X!=="string")return!1;let Z=X.trim();return Z.startsWith("<svg")&&Z.includes("</svg>")}function PZ(X){if(typeof X!=="string")return!1;return X.startsWith("data:image/png;base64,")||X.startsWith("iVBORw0KGgo")}function CZ(X){if(typeof X!=="string")return!1;return X.startsWith("data:image/jpeg;base64,")||X.startsWith("data:image/jpg;base64,")||X.startsWith("/9j/")}function p0(X){let Z=X.trim();return Z=Z.replace(/\s+/g," ").replace(/>\s+</g,"><").trim(),`data:image/svg+xml;base64,${Buffer.from(Z,"utf-8").toString("base64")}`}function d0(X){if(X.startsWith("data:image/png;base64,"))return X;return`data:image/png;base64,${X}`}function u0(X){if(X.startsWith("data:image/jpeg;base64,")||X.startsWith("data:image/jpg;base64,"))return X;return`data:image/jpeg;base64,${X}`}function wX(X){if(!X||typeof X!=="string")return X;if(X.startsWith("data:"))return X;if(SZ(X))return p0(X);else if(PZ(X))return d0(X);else if(CZ(X))return u0(X);return X}function k0(X){if(typeof X!=="string")return!1;return X.startsWith("data:image/svg+xml;")||X.startsWith("data:image/png;")||X.startsWith("data:image/jpeg;")||X.startsWith("data:image/jpg;")||X.startsWith("data:image/gif;")||X.startsWith("data:image/webp;")}function d(X){return SZ(X)||PZ(X)||CZ(X)||k0(X)}import{readFileSync as c0,readdirSync as l0,statSync as r0}from"fs";import{join as s0}from"path";import TZ from"colorjs.io";function IY(X){let Z={};function Y(q){let $=l0(q);for(let U of $){let W=s0(q,U);if(r0(W).isDirectory())Y(W);else if(U.endsWith(".tokens.json"))try{let z=c0(W,"utf-8");if(!z.trim())continue;let G=JSON.parse(z);yZ(Z,G)}catch(z){console.warn(`Failed to load token file: ${W}`,z)}}}return Y(X),Z}function yZ(X,Z){for(let Y in Z)if(Z[Y]&&typeof Z[Y]==="object"&&!Array.isArray(Z[Y])){if(!X[Y])X[Y]={};yZ(X[Y],Z[Y])}else X[Y]=Z[Y]}function wY(X,Z={}){let Y=[];function q($,U=[]){for(let[W,K]of Object.entries($)){if(W.startsWith("$"))continue;let z=[...U,W],G=z.join(".");if(jZ(K)){let E={path:z,name:G,type:K.$type,value:K.$value,description:K.$description,extensions:K.$extensions?{mode:MZ(K)?K.$extensions.$mode:K.$extensions.mode?K.$extensions.mode:void 0,generators:NZ(K)?K.$extensions.$generators:K.$extensions.generators?K.$extensions.generators:void 0,breakpoints:FZ(K)?K.$extensions.$breakpoints:K.$extensions.breakpoint?K.$extensions.breakpoint:void 0,...Object.fromEntries(Object.entries(K.$extensions).filter(([A])=>!["$mode","$generators","$breakpoints","mode","generators","breakpoint"].includes(A)))}:void 0,original:K};if(!Z.namespace||G.startsWith(Z.namespace))Y.push(E)}else if(bZ(K))q(K,z)}}return q(X),Y}function RY(X,Z={}){let Y=[...X],q=new Map(X.map((G)=>[G.name,G]));if(Z.generateModes||Z.generateDerivedTokens||Z.generateBreakpointTokens)for(let G of X){let E=VZ(G,Z,q);if(Y.push(...E),Z.generateModes){for(let A of E)if(A.extensions?.mode&&!A.name.includes("#")){let L=VZ(A,Z,q);Y.push(...L)}}}let $=Z.modes||[],U=$.length>0?$[0]:void 0,W={tokens:new Map(Y.map((G)=>[G.name,G])),mode:Z.generateModes?U:void 0,options:Z,brokenReferences:[]},K=[];for(let G of Y){let E=void 0;for(let H of $)if(G.name.endsWith(`#${H}`)){E=H;break}if(!E&&Z.generateModes)E=U;let A={...W,mode:E},L=i0(G,A);K.push(L)}if(Z.failOnBrokenReferences!==!1&&W.brokenReferences.length>0){let G=[...new Set(W.brokenReferences)],E=`Token reference${G.length>1?"s":""} not found:
|
|
33
|
+
${G.map((A)=>` - ${A}`).join(`
|
|
34
|
+
`)}`;throw Error(E)}return K}function VZ(X,Z,Y){let q=[];if(Z.generateModes&&X.extensions?.mode){for(let[$,U]of Object.entries(X.extensions.mode))if(U!==void 0)q.push({...X,name:`${X.name}#${$}`,value:U,path:[...X.path,`#${$}`]})}if(Z.generateModes&&!X.extensions?.mode&&(Array.isArray(X.value)||typeof X.value==="object"&&X.value!==null)){let $=!1,U=!1,W=(K)=>{if(typeof K!=="object"||K===null)return!1;if(K.$extensions?.mode)return!0;return Object.values(K).some((z)=>{if(typeof z==="object"&&z!==null)return W(z);return!1})};if(Array.isArray(X.value))$=X.value.some((K)=>typeof K==="string"&&K.includes("{")||typeof K==="object"&&K!==null&&Object.values(K).some((z)=>typeof z==="string"&&z.includes("{"))),U=X.value.some((K)=>W(K));else $=Object.values(X.value).some((K)=>typeof K==="string"&&K.includes("{")),U=W(X.value);if($||U){if(["color","shadow","border","background","surface","composition"].includes(X.type)){let G;if(Array.isArray(X.value))G=X.value.map((E)=>{if(typeof E==="string"&&E.startsWith("{")&&E.endsWith("}")){let A=E.slice(1,-1);if(!A.includes("#dark")&&!A.includes("@dark"))return`{${A}#dark}`;return E}else if(typeof E==="object"&&E!==null){let A={};for(let[L,H]of Object.entries(E))if(typeof H==="string"&&H.startsWith("{")&&H.endsWith("}")){let _=H.slice(1,-1),Q=`${_}#dark`,J=Y?.get(_),O=Y?.has(Q)||J?.extensions?.mode?.dark!==void 0||J&&(Array.isArray(J.value)||typeof J.value==="object"&&J.value!==null);if(!_.includes("#dark")&&!_.includes("@dark")&&O)A[L]=`{${Q}}`;else A[L]=H}else A[L]=H;return A}return E});else if(typeof X.value==="object"&&X.value!==null){G={};let E=(A)=>{if(typeof A==="string"){if(A.startsWith("{")&&A.endsWith("}")){let L=A.slice(1,-1),H=`${L}#dark`,_=(J,O=new Set)=>{if(O.has(J))return!1;O.add(J);let w=Y?.get(J);if(!w){let R=J.match(/^(.+)@([^@]+)$/);if(R){let[,B,I]=R,C=Y?.get(B);if(C){if(C.extensions?.mode?.dark!==void 0)return!0;if(C.extensions?.generators)return!0;return _(B,O)}}return!1}if(w.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${J}#dark`))return!0;if(typeof w.value==="string"&&w.value.startsWith("{")&&w.value.endsWith("}")){let R=w.value.slice(1,-1);return _(R,O)}if(Array.isArray(w.value)||typeof w.value==="object"&&w.value!==null){let R=(B)=>{if(typeof B!=="object"||B===null)return!1;if(B.$extensions?.mode)return!0;return Object.values(B).some((I)=>{if(typeof I==="object"&&I!==null)return R(I);return!1})};if(Array.isArray(w.value))return w.value.some((B)=>typeof B==="string"&&B.includes("{")&&_(B.slice(1,-1),new Set(O))||typeof B==="object"&&B!==null&&(Object.values(B).some((I)=>typeof I==="string"&&I.includes("{")&&_(I.slice(1,-1),new Set(O)))||R(B)));else if(typeof w.value==="object")return Object.values(w.value).some((B)=>typeof B==="string"&&B.includes("{")&&_(B.slice(1,-1),new Set(O)))||R(w.value)}return!1},Q=_(L);if(!L.includes("#dark")&&!L.includes("@dark")&&Q)return`{${H}}`}return A}if(typeof A==="object"&&A!==null){if(A.$extensions?.mode?.dark)return A.$extensions.mode.dark;let L={};for(let[H,_]of Object.entries(A))L[H]=E(_);return L}return A};for(let[A,L]of Object.entries(X.value))G[A]=E(L)}q.push({...X,name:`${X.name}#dark`,value:G,path:[...X.path,"#dark"],extensions:{...X.extensions,autoGenerated:!0}})}}}if(Z.generateModes&&!X.extensions?.mode&&typeof X.value==="string"&&X.value.startsWith("{")&&X.value.endsWith("}")){let $=X.value.slice(1,-1),U=(E,A=new Set)=>{if(A.has(E))return!1;A.add(E);let L=Y?.get(E);if(!L){let H=E.match(/^(.+)@([^@]+)$/);if(H){let[,_,Q]=H,J=Y?.get(_);if(J){if(J.extensions?.mode?.dark!==void 0)return!0;if(J.extensions?.generators)return!0;return U(_,A)}}return!1}if(L.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${E}#dark`))return!0;if(typeof L.value==="string"&&L.value.startsWith("{")&&L.value.endsWith("}")){let H=L.value.slice(1,-1);return U(H,A)}if(Array.isArray(L.value)||typeof L.value==="object"&&L.value!==null){let H=(_)=>{if(typeof _!=="object"||_===null)return!1;if(_.$extensions?.mode)return!0;return Object.values(_).some((Q)=>{if(typeof Q==="object"&&Q!==null)return H(Q);return!1})};if(Array.isArray(L.value))return L.value.some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(A))||typeof _==="object"&&_!==null&&(Object.values(_).some((Q)=>typeof Q==="string"&&Q.includes("{")&&U(Q.slice(1,-1),new Set(A)))||H(_)));else if(typeof L.value==="object")return Object.values(L.value).some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(A)))||H(L.value)}return!1},W=U($);if(["color","shadow","border","background","surface","composition"].includes(X.type)&&W&&W&&!$.includes("#dark")&&!$.includes("@dark")){let E=`{${$}#dark}`;q.push({...X,name:`${X.name}#dark`,value:E,path:[...X.path,"#dark"],extensions:{...X.extensions,autoGenerated:!0}})}}if(Z.generateDerivedTokens&&X.extensions?.generators)for(let $ of X.extensions.generators)for(let[U,W]of Object.entries($.value)){let K=xZ(X.name,U),{generators:z,...G}=X.extensions;q.push({...X,name:K,value:X.value,path:[...X.path,U],extensions:{...G,generator:{type:$.type,value:W}}})}if(Z.generateBreakpointTokens&&X.extensions?.breakpoints)for(let[$,U]of Object.entries(X.extensions.breakpoints)){let W=`${X.name}@${$.replace(/[^a-zA-Z0-9]/g,"_")}`,K=U.$value||U.value;if(K&&typeof K==="object"&&"$value"in K)K=K.$value;else if(!K&&typeof U==="object"){let{...E}=U;if(Object.keys(E).length>0)K=E}let z=U.$extensions||U.$extensions,G=U.$type;if(!G&&U.value&&typeof U.value==="object")G=U.value.$type;q.push({...X,name:W,value:K,path:[...X.path,`@${$}`],type:G||X.type,extensions:{mediaQuery:$,...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 q}function i0(X,Z){let Y=o(X.value,Z),q=X.type;if(typeof X.value==="string"&&BX(X.value)){let U=X.value.slice(1,-1),W=Z.tokens.get(U);if(W){if(["border","shadow","typography","composition"].includes(W.type))q=W.type;else if(typeof W.value==="string"&&IX(W.value)){let K=yX(W.value),z=new Set;for(let G of K)if(G.type==="reference"&&G.ref&&typeof G.ref==="string"){let E=G.ref.slice(1,-1),A=Z.tokens.get(E);if(A&&["border","shadow","typography","composition"].includes(A.type))z.add(A.type)}if(z.size===1)q=Array.from(z)[0]}}}if(typeof X.value==="string"&&IX(X.value)){let U=yX(X.value),W=new Set;for(let K of U)if(K.type==="reference"&&K.ref&&typeof K.ref==="string"){let z=K.ref.slice(1,-1),G=Z.tokens.get(z);if(G&&["border","shadow","typography","composition"].includes(G.type))W.add(G.type)}if(W.size===1)q=Array.from(W)[0]}if(typeof Y==="object"&&Y!==null&&["border","shadow","typography","composition"].includes(q))Y=r(Y,Z);if(X.extensions?.generator&&typeof X.extensions.generator==="object"&&"type"in X.extensions.generator&&"value"in X.extensions.generator)Y=gX(X.value,X.extensions.generator.type,X.extensions.generator.value,Z);let $=a0(X.name,Z.options);if(q==="color"&&typeof Y==="string"&&m(Y))Y=x(Y,X);if(typeof Y==="string"&&d(Y))Y=wX(Y);return{...X,type:q,value:Y,cssVar:$}}function r(X,Z){if(typeof X==="string"){if(BX(X))return MY(X,Z);else if(IX(X))return fZ(X,Z)}if(Array.isArray(X))return X.map((Y)=>r(Y,Z));if(typeof X==="object"&&X!==null){if("$value"in X&&typeof X.$value==="string")return r(X.$value,Z);if("value"in X&&typeof X.value==="string"&&"$type"in X){if(Z.mode&&X.$extensions?.mode?.[Z.mode])return r(X.$extensions.mode[Z.mode],Z);return r(X.value,Z)}if("value"in X&&typeof X.value==="object"&&"$type"in X){let q=X.value,$=X.$extensions?.delimiter?.character||" ";if(X.$type==="composition"&&q&&typeof q==="object")return Object.values(q).map((W)=>r(W,Z)).join($);return r(X.value,Z)}let Y={};for(let[q,$]of Object.entries(X))Y[q]=r($,Z);return Y}return X}function o(X,Z){if(typeof X==="string"){if(IX(X))return fZ(X,Z);else if(BX(X))return MY(X,Z)}else if(typeof X==="object"&&X!==null&&"$ref"in X)return gZ(X,Z);return X}function MY(X,Z){let Y=X.slice(1,-1),q=Z.tokens.get(Y),$=Z.options.modes||[];if(!q){if($.length>0){for(let K of $)if(Y.endsWith(`@${K}`)){let z=Y.slice(0,-K.length-1)+`#${K}`;if(q=Z.tokens.get(z),q)return BY(q,Z);break}}let W=Y.match(/#([^#@]+)$/);if(W){let K=Y.substring(0,W.index),z=W[1];if(q=Z.tokens.get(K),q){if(q.extensions?.mode?.[z]){let G=q.extensions.mode[z],E=o(G,{...Z,mode:z});if(q.extensions?.generator&&typeof q.extensions.generator==="object"&&"type"in q.extensions.generator&&"value"in q.extensions.generator)E=gX(E,q.extensions.generator.type,q.extensions.generator.value,Z);if(q.type==="color"&&typeof E==="string"&&m(E))E=x(E,q);if(typeof E==="string"&&d(E))E=wX(E);return E}}}if($.length>0)for(let K of $){let z=new RegExp(`(@[^@]+)@${K}$`);if(z.test(Y)){let G=Y.replace(z,`$1#${K}`);if(q=Z.tokens.get(G),!q){let E=G.match(/#([^#@]+)$/);if(E){let A=G.substring(0,E.index),L=E[1];if(q=Z.tokens.get(A),q&&q.extensions?.mode?.[L]){let H=q.extensions.mode[L],_=o(H,{...Z,mode:L});if(q.extensions?.generator&&typeof q.extensions.generator==="object"&&"type"in q.extensions.generator&&"value"in q.extensions.generator)_=gX(_,q.extensions.generator.type,q.extensions.generator.value,Z);if(q.type==="color"&&typeof _==="string"&&m(_))_=x(_,q);if(typeof _==="string"&&d(_))_=wX(_);return _}}}else return BY(q,Z);break}}}if(!q)return console.warn(`Token reference not found: ${X}`),Z.brokenReferences.push(X),X;return BY(q,Z)}function BY(X,Z){let Y;if(X.extensions?.generator&&typeof X.extensions.generator==="object"&&"type"in X.extensions.generator&&"value"in X.extensions.generator)Y=gX(X.value,X.extensions.generator.type,X.extensions.generator.value,Z);else if(Z.mode&&X.extensions?.mode?.[Z.mode])Y=o(X.extensions.mode[Z.mode],Z);else Y=o(X.value,Z);if(X.type==="color"&&typeof Y==="string"&&m(Y))Y=x(Y,X);if(typeof Y==="string"&&d(Y))Y=wX(Y);return Y}function gZ(X,Z){let q=X.$ref.slice(2).replace(/\//g,"."),$=Z.tokens.get(q);if(!$)return console.warn(`JSON Pointer reference not found: ${X.$ref}`),Z.brokenReferences.push(X.$ref),X.$ref;return o($.value,Z)}function fZ(X,Z){let Y=yX(X),q=Y.some((W)=>W.value.includes(",")),$=!0,U=[];for(let W of Y){let K;if(W.type==="reference"&&W.ref){if(typeof W.ref==="string"&&BX(W.ref)){K=MY(W.ref,Z);let z=W.ref.slice(1,-1),G=Z.tokens.get(z);if(!G||!["border","shadow","typography","composition"].includes(G.type))$=!1}else if(typeof W.ref==="object"&&"$ref"in W.ref)K=gZ(W.ref,Z)}else if(K=W.value,W.value.trim()&&W.value.trim()!==",")$=!1;U.push(K)}if(q&&$)return U.filter((W)=>typeof W==="object"&&W!==null&&typeof W!=="string");return U.map((W)=>String(W)).join("")}function gX(X,Z,Y,q){let $=o(X,q);switch(Z){case"alpha":if(typeof $==="string")return n0($,Number(Y)/100);break;case"scale":if(typeof $==="string"&&$.match(/[\d.]+/))return t0($,Number(Y));break;case"hue":if(typeof $==="string")return o0($,Number(Y));break;default:return console.warn(`Unknown generator type: ${Z}`),$}return $}function a0(X,Z,Y){let q=X.replace(/\./g,"-");q=q.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),q=q.replace(/@[^@#]*(?:screen|width|height|min|max|orientation).*$/i,""),q=q.replace(/#[^#]*$/,""),q=q.replace(/-@/g,"-").replace(/@/g,"-");let $=q,U=!0,W=Z.prefix||"";if(Z.transformName){if($=Z.transformName(q),$=$.replace(/-+$/,""),$!==q)U=!1}let K=U&&W?`${W}-${$}`:$,z=Y?`-${Y}`:"";return`--${K}${z}`.replace(/[^a-zA-Z0-9-_]/g,"-")}function n0(X,Z){try{if(!m(X))return X;let Y=new TZ(X);return Y.alpha=Z,x(Y)}catch(Y){return console.warn(`Failed to apply alpha to color "${X}": ${Y}`),X}}function t0(X,Z){let Y=X.match(/([\d.]+)(\w+)/);if(Y){let[,q,$]=Y;return`${parseFloat(q)*Z}${$}`}return X}function o0(X,Z){try{if(!m(X))return X;let q=new TZ(X).to("oklch");return q.h=(q.h+Z)%360,x(q)}catch(Y){return console.warn(`Failed to shift hue for color "${X}": ${Y}`),X}}var NY=b(()=>{DZ();AX()});function FY(X){if(X.type==="typography"||X.type==="fontWeight"||X.type==="fontFamily")return!0;if(X.type==="dimension"&&X.name.includes("typography"))return!0;if(X.name.includes("typography")||X.name.includes("font"))return!0;return!1}function s(X,Z,Y){if(Y){if(X===Z)return":host";return`:host([data-theme="${X}"])`}if(X===Z)return":root";return`[data-theme="${X}"]`}function fX(X,Z={}){let{rootSelector:Y=":root",separateThemeFiles:q=!1,generateMediaQueries:$=!1,customHeader:U,modes:W=["light","dark"]}=Z;if(q)return X1(X,Z);let K=new Map,z=new Map;for(let w of W)K.set(w,[]);let G=W.join("|"),E=new RegExp(`#(${G})$`);for(let w of X){if(typeof w.value==="string"&&d(w.value))continue;if(FY(w))continue;let R=` ${w.cssVar}: ${h(w.value,w.type)};`;if($&&w.name.includes("@media")){let I=hX(w);if(I){if(!z.has(I))z.set(I,[]);z.get(I).push(R);continue}}let B=w.name.match(E);if(B){let I=B[1];if(!K.has(I))K.set(I,[]);K.get(I).push(R)}else{let I=W[0]||"light";K.get(I).push(R)}}let A="";if(U)A+=`${U}
|
|
35
35
|
|
|
36
|
-
`;let L=
|
|
36
|
+
`;let L=Z.defaultMode||W[0]||"light",H=Z.isHost||!1,_=K.get(L)||[];if(_.length>0){_.sort();let w=s(L,L,H);A+=`${w} {
|
|
37
37
|
${_.join(`
|
|
38
38
|
`)}
|
|
39
|
-
`;for(let
|
|
39
|
+
`;for(let R of W){if(R===L)continue;let B=K.get(R)||[];if(B.length>0){B.sort();let I=s(R,L,H);if(H)A+=`}
|
|
40
40
|
|
|
41
|
-
${
|
|
42
|
-
${
|
|
41
|
+
${I} {
|
|
42
|
+
${B.join(`
|
|
43
43
|
`)}
|
|
44
|
-
`;else{let
|
|
45
|
-
${
|
|
46
|
-
${
|
|
44
|
+
`;else{let C=I.replace("[data-theme=","&[data-theme=");A+=`
|
|
45
|
+
${C} {
|
|
46
|
+
${B.map((XX)=>` ${XX}`).join(`
|
|
47
47
|
`)}
|
|
48
48
|
}
|
|
49
|
-
`}}}
|
|
50
|
-
`}if(
|
|
51
|
-
${
|
|
52
|
-
${
|
|
53
|
-
${
|
|
49
|
+
`}}}A+=`}
|
|
50
|
+
`}if($&&z.size>0){let w=s(L,L,H);for(let[R,B]of z)B.sort(),A+=`
|
|
51
|
+
${R} {
|
|
52
|
+
${w} {
|
|
53
|
+
${B.map((I)=>` ${I}`).join(`
|
|
54
54
|
`)}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
`}let Q=[{fileName:"tokens.css",content:
|
|
58
|
-
`)?
|
|
59
|
-
`}],
|
|
57
|
+
`}let Q=[{fileName:"tokens.css",content:A.endsWith(`
|
|
58
|
+
`)?A:`${A}
|
|
59
|
+
`}],J=pZ(X,Z);Q.push(...J);let O=dZ(X,Z);return Q.push(...O),Q}function e0(X,Z){let Y=[];for(let $ of X){let W=` ${$.cssVar||vX($,Z)}: ${h($.value,$.type)};`;Y.push(W)}let q="";if(Z.customHeader)q+=`${Z.customHeader}
|
|
60
60
|
|
|
61
|
-
`;if(Y.length>0)Y.sort(),
|
|
61
|
+
`;if(Y.length>0)Y.sort(),q+=`${Z.rootSelector||":root"} {
|
|
62
62
|
${Y.join(`
|
|
63
63
|
`)}
|
|
64
64
|
}
|
|
65
|
-
`;return{fileName:"theme.css",content:
|
|
66
|
-
`)?
|
|
67
|
-
`}}function
|
|
65
|
+
`;return{fileName:"theme.css",content:q.endsWith(`
|
|
66
|
+
`)?q:`${q}
|
|
67
|
+
`}}function X1(X,Z){let Y=[],q=new Map,$=[],U=Z.modes||["light","dark"],W=new Set(U),K=U.join("|"),z=new RegExp(`#(${K})$`);for(let _ of X){if(hX(_))continue;if(typeof _.value==="string"&&d(_.value))continue;if(FY(_))continue;let Q=_.name.match(z);if(Q){let J=Q[1];if(W.has(J)){if(!q.has(J))q.set(J,[]);q.get(J).push(_)}else $.push(_)}else $.push(_)}if($.length>0){let _=fX($,{...Z,separateThemeFiles:!1})[0];Y.push({..._,fileName:"tokens.css"})}let G=Z.defaultMode||(U.length>0?U[0]:"default"),E=Z.isHost||!1;for(let[_,Q]of q){let J=s(_,G,E),O=e0(Q,{...Z,separateThemeFiles:!1,rootSelector:J});Y.push({...O,fileName:`tokens.${_}.css`,theme:_})}let A=Y1(X,Z);Y.push(...A);let L=pZ(X,Z);Y.push(...L);let H=dZ(X,Z);return Y.push(...H),Y}function Y1(X,Z){let Y=new Map;for(let U of X){let W=hX(U);if(W){let K=U.name.match(/@(dark|light)$/),z=K?K[1]:"light";if(!Y.has(W))Y.set(W,new Map);let G=Y.get(W);if(!G.has(z))G.set(z,[]);G.get(z).push(U)}}if(Y.size===0)return[];let q=`/**
|
|
68
68
|
* Design System Tokens - Responsive Breakpoints
|
|
69
69
|
* Generated: ${new Date().toISOString()}
|
|
70
70
|
*
|
|
@@ -72,69 +72,69 @@ ${Y.join(`
|
|
|
72
72
|
* Each media query section overrides tokens for specific screen sizes.
|
|
73
73
|
*/
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
`,$=Array.from(Y.keys()).sort();for(let U of $){let W=Y.get(U),K=Z.defaultMode||(Z.modes&&Z.modes.length>0?Z.modes[0]:"light"),z=Z.isHost||!1;for(let[G,E]of W){let A=[];for(let L of E){let _=` ${L.cssVar||vX(L,Z)}: ${h(L.value,L.type)};`;A.push(_)}if(A.length>0){A.sort();let L=s(G,K,z);q+=`${U} {
|
|
76
76
|
${L} {
|
|
77
|
-
${
|
|
77
|
+
${A.join(`
|
|
78
78
|
`)}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
`}}}return[{fileName:"tokens.breakpoints.css",content:
|
|
83
|
-
`}]}function
|
|
82
|
+
`}}}return[{fileName:"tokens.breakpoints.css",content:q.trim()+`
|
|
83
|
+
`}]}function pZ(X,Z){let Y=new Map;for(let $ of X)if(typeof $.value==="string"&&d($.value)){let U=$.name.match(/@(dark|light)$/),W=U?U[1]:"light";if(!Y.has(W))Y.set(W,[]);Y.get(W).push($)}let q=[];if(Y.size===0)return[];if(Y.size===1){let[$,U]=Array.from(Y.entries())[0],W=vZ(U,$,Z);q.push({fileName:"tokens.icons.css",content:W.endsWith(`
|
|
84
84
|
`)?W:`${W}
|
|
85
|
-
`})}else for(let[
|
|
85
|
+
`})}else for(let[$,U]of Y){let W=vZ(U,$,Z);q.push({fileName:`tokens.icons.${$}.css`,content:W.endsWith(`
|
|
86
86
|
`)?W:`${W}
|
|
87
|
-
`})}return
|
|
88
|
-
* Design System Tokens - Icons (${
|
|
87
|
+
`})}return q}function vZ(X,Z,Y){let q=`/**
|
|
88
|
+
* Design System Tokens - Icons (${Z})
|
|
89
89
|
* Generated: ${new Date().toISOString()}
|
|
90
90
|
*
|
|
91
91
|
* This file contains CSS custom properties for icon tokens.
|
|
92
92
|
* Icons are provided as data URIs for direct embedding.
|
|
93
93
|
*/
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
${
|
|
95
|
+
`,$=[];for(let U of X){let K=` ${U.cssVar||vX(U,Y)}: ${h(U.value,U.type)};`;$.push(K)}if($.length>0){$.sort();let U=Y.defaultMode||"light",W=Y.isHost||!1,K=s(Z,U,W);q+=`${K} {
|
|
96
|
+
${$.join(`
|
|
97
97
|
`)}
|
|
98
98
|
}
|
|
99
|
-
`}return
|
|
100
|
-
`}function
|
|
99
|
+
`}return q+`
|
|
100
|
+
`}function vX(X,Z){let q=X.name.split("@")[0].replace(/\.$/,"").replace(/\.+/g,"."),$=xY(q,Z.hooks);return`--${Z.prefix||RX}-${$.replace(/\./g,"-")}`}function xY(X,Z,Y){if(!Z?.shortenName?.enabled)return X;let q=X;if(Z.shortenName.prefix)for(let $ of Z.shortenName.prefix)q=q.replace(new RegExp($.find,"g"),$.replace);if(Z.shortenName.suffix){for(let $ of Z.shortenName.suffix)if(q.endsWith($.find))q=q.substring(0,q.length-$.find.length)+$.replace}if(Y&&Y!=="light"){let $=`-${Y}`;if(q.endsWith($))q=q.slice(0,-$.length)}return q}function dZ(X,Z){let Y=new Map,q=Z.modes||[];for(let U of X)if(FY(U)){if(hX(U))continue;let K=q.length>0?q[0]:"default";if(U.name.includes("#")){let z=U.name.split("#"),G=z[z.length-1];if(q.includes(G))K=G}if(!Y.has(K))Y.set(K,[]);Y.get(K).push(U)}let $=[];for(let[U,W]of Y.entries()){let K=Z1(W,U,Z,q);$.push({fileName:`tokens.typography.${U}.css`,content:K.endsWith(`
|
|
101
101
|
`)?K:`${K}
|
|
102
|
-
`})}return
|
|
103
|
-
* Design System Tokens - Typography (${
|
|
102
|
+
`})}return $}function Z1(X,Z,Y,q){let $=`/**
|
|
103
|
+
* Design System Tokens - Typography (${Z})
|
|
104
104
|
* Generated: ${new Date().toISOString()}
|
|
105
105
|
*
|
|
106
106
|
* This file contains CSS custom properties for typography tokens.
|
|
107
107
|
* Includes fontSize, fontWeight, fontFamily, lineHeight, and typography compositions.
|
|
108
108
|
*/
|
|
109
109
|
|
|
110
|
-
`,U=new Map;for(let W of
|
|
111
|
-
${
|
|
110
|
+
`,U=new Map;for(let W of X){let K="default";if(W.name.includes("@")){let z=W.name.split("@");for(let G of z)if(G.includes("screen_")||G.includes("min_width")||G.includes("max_width")){K=G.replace(/screen_and__/g,"").replace(/min_width__(\d+)px_/g,"min-width: $1px").replace(/max_width__(\d+)px_/g,"max-width: $1px").replace(/_/g," ");break}}if(!U.has(K))U.set(K,[]);U.get(K).push(W)}for(let[W,K]of U.entries()){let z=[];for(let G of K){let A=` ${G.cssVar||vX(G,Y)}: ${h(G.value,G.type)};`;z.push(A)}if(z.length>0){let G=Y.defaultMode||"light",E=Y.isHost||!1,A=s(Z,G,E);if(W==="default")z.sort(),$+=`${A} {
|
|
111
|
+
${z.join(`
|
|
112
112
|
`)}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
`;else{let L=W.startsWith("(")?W:`(${W})
|
|
116
|
-
|
|
117
|
-
${
|
|
115
|
+
`;else{let L=W.startsWith("(")?W:`(${W})`;$+=`@media ${L} {
|
|
116
|
+
`,$+=` ${A} {
|
|
117
|
+
${z.sort().map((H)=>` ${H}`).join(`
|
|
118
118
|
`)}
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
`,$+=`}
|
|
121
121
|
|
|
122
|
-
`}}}return
|
|
123
|
-
`}function
|
|
124
|
-
* ${
|
|
122
|
+
`}}}return $+`
|
|
123
|
+
`}function h(X,Z){if(X===null||X===void 0)return"";if(typeof X==="object"&&X!==null&&!Array.isArray(X)){let q=X;if(q.$value!==void 0){if(typeof q.$value==="string")return q.$value;return h(q.$value,q.$type||Z)}}let Y=String(X);switch(Z){case"color":return q1(Y);case"dimension":return $1(Y);case"duration":return U1(Y);case"fontFamily":return K1(Y);case"fontWeight":return W1(Y);case"cubicBezier":return G1(X);case"shadow":return z1(X);case"border":return A1(X);case"typography":return E1(X);case"composition":return jY(X);default:if(Y.startsWith("data:"))return`"${Y}"`;return Y}}function q1(X){if(X.startsWith("oklch(")||X.startsWith("rgb(")||X.startsWith("rgba(")||X.startsWith("hsl(")||X.startsWith("hsla(")||X.startsWith("#"))return X;return X}function $1(X){if(/^\d+(\.\d+)?(px|rem|em|%|vh|vw|vmin|vmax)$/.test(X))return X;if(/^\d+(\.\d+)?$/.test(X))return`${X}rem`;return X}function U1(X){if(/^\d+(\.\d+)?(s|ms)$/.test(X))return X;if(/^\d+(\.\d+)?$/.test(X))return`${X}ms`;return X}function K1(X){if((X.includes(",")||X.includes(" "))&&!X.startsWith('"')&&!X.startsWith("'"))return`"${X}"`;return X}function W1(X){return{thin:"100","extra-light":"200",light:"300",normal:"400",medium:"500","semi-bold":"600",bold:"700","extra-bold":"800",black:"900"}[X]||X}function G1(X){if(Array.isArray(X)&&X.length===4)return`cubic-bezier(${X.join(", ")})`;return String(X)}function z1(X){if(Array.isArray(X))return X.map((Z)=>hZ(Z)).join(", ");return hZ(X)}function hZ(X){if(typeof X==="object"&&X!==null){let Z=X,Y=Z.color||"transparent";if(typeof Y==="string"&&Y.includes("{")&&Y.includes("}")){console.warn(`Unresolved token reference in shadow color: ${Y}`);let $=Y.match(/\{([^}]+)\}/)?.[1];if($)Y=`var(${`--${RX}-${$.replace(/\./g,"-").replace(/@/g,"-")}`})`}let q=[Z.offsetX||"0",Z.offsetY||"0",Z.blur||"0",Z.spread||"0",Y];if(Z.inset)q.unshift("inset");return q.join(" ")}return String(X)}function A1(X){if(typeof X==="object"&&X!==null){let Z=X,Y=F(Z.width)||"1px",q=F(Z.style)||"solid",$=F(Z.color)||"transparent";return`${Y} ${q} ${$}`}return String(X)}function E1(X){if(typeof X==="object"&&X!==null){let Z=X,Y=Z.fontWeight||"normal",q=Z.fontSize||"1rem",$=Z.lineHeight||"normal",U=Z.fontFamily||"sans-serif";if(U.includes(" ")&&!U.startsWith('"')&&!U.startsWith("'"))U=`'${U}'`;let W;if(q.includes("/"))W=q;else W=`${q}/${$}`;return`${Y} ${W} ${U}`}return String(X)}function jY(X){if(typeof X!=="object"||X===null)return String(X);if(Array.isArray(X))return X.map((Y)=>jY(Y)).join(", ");let Z=X;if(Z.offsetX!==void 0&&Z.offsetY!==void 0)return uZ(Z);if(Z.width!==void 0&&Z.style!==void 0&&Z.color!==void 0){let Y=String(Z.width||"1px"),q=String(Z.style||"solid"),$=String(Z.color||"transparent");return`${Y} ${q} ${$}`}if(Z.blur!==void 0||Z.saturate!==void 0||Z.brightness!==void 0)return L1(Z);if(Z.fontSize!==void 0||Z.fontFamily!==void 0)return H1(Z);return _1(Z)}function uZ(X){let Z=[F(X.offsetX)||"0",F(X.offsetY)||"0",F(X.blur)||"0",F(X.spread)||"0",F(X.color)||"transparent"];if(X.inset&&F(X.inset)==="true")Z.unshift("inset");return Z.join(" ")}function L1(X){let Z=[];if(X.blur)Z.push(F(X.blur)||"blur(0)");if(X.saturate)Z.push(F(X.saturate)||"saturate(100%)");if(X.brightness)Z.push(F(X.brightness)||"brightness(100%)");if(X.contrast)Z.push(F(X.contrast)||"contrast(100%)");if(X.hueRotate)Z.push(F(X.hueRotate)||"hue-rotate(0deg)");return Z.join(" ")||"none"}function H1(X){let Z=F(X.fontWeight)||"normal",Y=F(X.fontSize)||"1rem",q=F(X.lineHeight),$=F(X.fontFamily)||"sans-serif";if($.includes(" ")&&!$.startsWith('"')&&!$.startsWith("'"))$=`'${$}'`;if(Y.includes("/"))return`${Z} ${Y} ${$}`;else if(q)return`${Z} ${Y}/${q} ${$}`;return`${Z} ${Y} ${$}`}function mZ(X,Z,Y){let q=X.match(/^\{(.+)\}$/);if(!q)return X;let U=q[1].replace(/\./g,"-");if(Y)U=xY(U,{shortenName:Y.$metaData?.tokens?.css?.hooks?.shortenName});return`var(--${U})`}function F(X,Z,Y){if(X===null||X===void 0)return"";if(typeof X==="string"){if(X.match(/^\{.+\}$/))return mZ(X,Z||"ds",Y);return X}if(typeof X==="object"&&X.value!==void 0){let q=String(X.value);if(q.match(/^\{.+\}$/))return mZ(q,Z||"ds",Y);return q}return String(X)}function _1(X){let Z=[];for(let[,$]of Object.entries(X)){let U=$;if(typeof $==="object"&&$!==null&&U.$value&&typeof U.$value==="object"){let W=U.$value;if(W.offsetX!==void 0&&W.offsetY!==void 0){let K=uZ(W);if(K)Z.push(K)}else{let K=jY(W);if(K)Z.push(K)}}else{let W=F($);if(W)Z.push(W)}}let q=Z.some(($)=>/^\d/.test($)&&$.includes(" "))?", ":" ";return Z.join(q)||String(X)}function hX(X){if(X.extensions?.mediaQuery&&typeof X.extensions.mediaQuery==="string"){let Y=X.extensions.mediaQuery;if(Y=Y.replace(/\{universe\.foundation\.breakpoint\.screen\.width\.lg\}/g,"64rem"),!Y.startsWith("@media"))Y=`@media ${Y}`;return Y}let Z=X.name.match(/@(media[^@]+)/);if(Z)return`@${Z[1].replace(/_/g," ")}`;if(X.name.includes("@screen_and__min_width__300px_"))return"@media screen and (min-width: 300px)";if(X.name.includes("@screen_and__min_width__600px_"))return"@media screen and (min-width: 600px)";if(X.name.includes("@")&&X.name.includes("_"))return"@media (unknown-breakpoint)";return null}function mX(X){let Z=X?.$name||"Design System",Y=X?.$version||"1.0.0",q=new Date().toISOString();return`/**
|
|
124
|
+
* ${Z} - CSS Custom Properties
|
|
125
125
|
* Version: ${Y}
|
|
126
|
-
* Generated: ${
|
|
126
|
+
* Generated: ${q}
|
|
127
127
|
*
|
|
128
128
|
* This file contains CSS custom properties (CSS variables) generated from design tokens.
|
|
129
129
|
* Do not edit this file directly - it will be overwritten.
|
|
130
|
-
*/`}function
|
|
130
|
+
*/`}function Q1(X){let Z=X.replace(/\r?\n|\r/g,"").replace(/\s+/g," ").trim();return`data:image/svg+xml;base64,${Buffer.from(Z,"utf8").toString("base64")}`}function bY(X,Z={}){let{customHeader:Y,objectPath:q="universe.custom.path.icons",isHost:$=!1,defaultMode:U="light"}=Z,W="--"+q.replace(/\./g,"-"),K="";if(Y)K+=Y+`
|
|
131
131
|
|
|
132
|
-
`;else
|
|
132
|
+
`;else K+=`/**
|
|
133
133
|
* Icon CSS - Base64 Encoded SVG Icons as CSS Custom Properties
|
|
134
134
|
* Generated: ${new Date().toISOString()}
|
|
135
135
|
*
|
|
136
136
|
* This file contains CSS custom properties (variables) for icons with base64 encoded SVG values.
|
|
137
|
-
* Follows the object path structure: ${
|
|
137
|
+
* Follows the object path structure: ${q}.{category}.{IconName}
|
|
138
138
|
* Variable names may be shortened by configured hooks.
|
|
139
139
|
* Usage examples:
|
|
140
140
|
* background-image: var(--icon-actions-delete);
|
|
@@ -143,49 +143,51 @@ ${A.sort().map((H)=>` ${H}`).join(`
|
|
|
143
143
|
* Do not edit this file directly - it will be overwritten.
|
|
144
144
|
*/
|
|
145
145
|
|
|
146
|
-
`;U
|
|
147
|
-
`;let
|
|
148
|
-
`}return
|
|
149
|
-
`,{fileName:"tokens.icons.css",content:
|
|
150
|
-
`}}var
|
|
151
|
-
`}function w1(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
`}function
|
|
155
|
-
`;if(
|
|
156
|
-
`;
|
|
157
|
-
`,
|
|
158
|
-
`}
|
|
159
|
-
|
|
146
|
+
`;let z=s(U,U,$);K+=`${z} {
|
|
147
|
+
`;let G=[...X].sort((E,A)=>E.name.localeCompare(A.name));for(let E of G){let A=E.name.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""),L=E.category?`${W}-${E.category}-${A}`:`${W}-${A}`;if(Z.hooks?.shortenName?.enabled)L=xY(L,Z.hooks);let H=Q1(E.value);K+=` ${L}: url("${H}");
|
|
148
|
+
`}return K+=`}
|
|
149
|
+
`,{fileName:"tokens.icons.css",content:K.trim()+`
|
|
150
|
+
`}}var pX=b(()=>{y()});import{readFileSync as O1,existsSync as J1}from"fs";import{join as kZ,relative as B1}from"path";async function DY(){try{let{assets:X}=await p(!0),{icons:Z}=await V(),Y=await t(),q=X?.icons?.distDir??"build",$=kZ(Y,q),U=kZ($,"tokens",await KX("json"));if(!J1(U)){let _=B1(process.cwd(),U);return console.log(`ℹ️ Icon data not found (skipping icon types): ${_}`),console.log(" Run icon build first if you need icon types generated."),[]}let W=JSON.parse(O1(U,"utf8")),K=Z?.objectPath??"universe.icons",z=K.split("."),G=W;for(let _ of z)if(G&&typeof G==="object"&&_ in G)G=G[_];else throw Error(`Icon path ${K} not found in icons file`);let E=[],A=Object.keys(G)[0],L=G[A];if(L&&typeof L==="object"&&"$value"in L){for(let[_,Q]of Object.entries(G))if(typeof Q==="object"&&Q!==null){let J=Q;if(_.startsWith("$"))continue;E.push({name:_,category:"",value:J.$value||"",description:J.$description||"",style:J.$style||"",dimensions:J.$extensions?.dimensions||J.$dimensions})}}else for(let[_,Q]of Object.entries(G))if(typeof Q==="object"&&Q!==null){for(let[J,O]of Object.entries(Q))if(typeof O==="object"&&O!==null){let w=O;if(J.startsWith("$"))continue;E.push({name:J,category:_,value:w.$value||"",description:w.$description||"",style:w.$style||"",dimensions:w.$extensions?.dimensions||w.$dimensions})}}return E}catch(X){if(X instanceof Error){if("code"in X&&X.code!=="ENOENT")console.warn(`⚠️ Could not load icon data: ${X.message}`)}return[]}}async function SY(X,Z={},Y){let{generateTypes:q=!0,generateConsts:$=!0}=Z,U=Z.icons;if(!U)U=await DY();let W={...Z,icons:U},K=[];if(q)K.push({fileName:"tokens.types.ts",content:I1(X,W),type:"types"});if($)K.push({fileName:"tokens.constants.ts",content:w1(X,W),type:"constants"});return K.push({fileName:"index.ts",content:R1(K,Y),type:"index"}),K}function I1(X,Z){let{tokenInterface:Y="DesignTokens",includeJSDoc:q=!0,icons:$=[]}=Z,U=PY("Type Definitions");if(U+=M1(X,q),U+=N1(X,q),$.length>0)U+=F1($,q);return U+=x1(X,Y,q),U+=b1(X,q),U+`
|
|
151
|
+
`}function w1(X,Z){let{includeJSDoc:Y=!0,icons:q=[]}=Z,$=PY("Token Constants"),U="TokenPaths, CSSVariableNames";if(q.length>0)U+=", IconNames, IconCategories, Icon";if($+=`import type { ${U} } from './tokens.types';
|
|
152
|
+
|
|
153
|
+
`,$+=D1(X,Y),$+=P1(X,Y),q.length>0)$+=S1(q,Y);return $+=C1(X,Y),$+`
|
|
154
|
+
`}function R1(X,Z){let Y=PY("Main Export");if(X.some((q)=>q.type==="types"))Y+=`export type * from './tokens.types';
|
|
155
|
+
`;if(X.some((q)=>q.type==="constants"))Y+=`export * from './tokens.constants';
|
|
156
|
+
`;if(Z)try{let q=a("fs"),U=a("path").join(Z,"typescript","tokens.icons.ts");if(q.existsSync(U))Y+=`export type * from './tokens.icons';
|
|
157
|
+
`,Y+=`export * from './tokens.icons';
|
|
158
|
+
`}catch(q){}return Y+=`
|
|
159
|
+
`,Y+`
|
|
160
|
+
`}function M1(X,Z){let Y=X.map(($)=>`"${$.name}"`).join(`
|
|
161
|
+
| `),q="";if(Z)q+=`/**
|
|
160
162
|
* All available token paths as string literals
|
|
161
163
|
*/
|
|
162
|
-
`;return
|
|
164
|
+
`;return q+=`export type TokenPaths =
|
|
163
165
|
| ${Y};
|
|
164
166
|
|
|
165
|
-
`,
|
|
166
|
-
`}function
|
|
167
|
-
| `);if(
|
|
168
|
-
* Possible values for ${
|
|
167
|
+
`,q+`
|
|
168
|
+
`}function N1(X,Z){let Y=V1(X),q="";for(let[$,U]of Y){let W=`${y1($)}TokenValue`,K=new Set(U.map((G)=>MX(G.value))),z=Array.from(K).join(`
|
|
169
|
+
| `);if(Z)q+=`/**
|
|
170
|
+
* Possible values for ${$} tokens
|
|
169
171
|
*/
|
|
170
|
-
`;
|
|
171
|
-
| ${
|
|
172
|
+
`;q+=`export type ${W} =
|
|
173
|
+
| ${z};
|
|
172
174
|
|
|
173
|
-
`}return
|
|
174
|
-
`}function
|
|
175
|
-
| `);if(
|
|
175
|
+
`}return q+`
|
|
176
|
+
`}function F1(X,Z){let Y="",q=X.map((W)=>`"${W.name}"`).join(`
|
|
177
|
+
| `);if(Z)Y+=`/**
|
|
176
178
|
* All available icon names as string literals
|
|
177
179
|
*/
|
|
178
180
|
`;Y+=`export type IconNames =
|
|
179
|
-
| ${
|
|
181
|
+
| ${q};
|
|
180
182
|
|
|
181
|
-
`;let U=[...new Set(
|
|
182
|
-
| `);if(
|
|
183
|
+
`;let U=[...new Set(X.map((W)=>W.category))].map((W)=>`"${W}"`).join(`
|
|
184
|
+
| `);if(Z)Y+=`/**
|
|
183
185
|
* All available icon categories
|
|
184
186
|
*/
|
|
185
187
|
`;if(Y+=`export type IconCategories =
|
|
186
188
|
| ${U};
|
|
187
189
|
|
|
188
|
-
`,
|
|
190
|
+
`,Z)Y+=`/**
|
|
189
191
|
* Icon data structure
|
|
190
192
|
*/
|
|
191
193
|
`;return Y+=`export interface Icon {
|
|
@@ -207,74 +209,74 @@ ${A.sort().map((H)=>` ${H}`).join(`
|
|
|
207
209
|
`,Y+=`}
|
|
208
210
|
|
|
209
211
|
`,Y+`
|
|
210
|
-
`}function
|
|
212
|
+
`}function x1(X,Z,Y){let q="";if(Y)q+=`/**
|
|
211
213
|
* Design tokens interface with all token paths and their values
|
|
212
214
|
*/
|
|
213
|
-
`;
|
|
214
|
-
`;for(let
|
|
215
|
-
`;
|
|
216
|
-
`}return
|
|
215
|
+
`;q+=`export interface ${Z} {
|
|
216
|
+
`;for(let $ of X){if(Y&&$.description)q+=` /** ${$.description} */
|
|
217
|
+
`;q+=` "${$.name}": ${MX($.value)};
|
|
218
|
+
`}return q+=`}
|
|
217
219
|
|
|
218
|
-
`,
|
|
219
|
-
`}function
|
|
220
|
+
`,q+=j1(X,`${Z}Nested`,Y),q+`
|
|
221
|
+
`}function j1(X,Z,Y){let q=T1(X),$="";if(Y)$+=`/**
|
|
220
222
|
* Design tokens interface with nested structure
|
|
221
223
|
*/
|
|
222
|
-
`;return
|
|
223
|
-
|
|
224
|
+
`;return $+=`export interface ${Z} {
|
|
225
|
+
`,$+=cZ(q,1),$+=`}
|
|
224
226
|
|
|
225
|
-
|
|
226
|
-
`}function
|
|
227
|
-
| `)
|
|
227
|
+
`,$+`
|
|
228
|
+
`}function b1(X,Z){let q=Array.from(new Set(X.map((U)=>U.cssVar))).map((U)=>`"${U}"`).join(`
|
|
229
|
+
| `),$="";if(Z)$+=`/**
|
|
228
230
|
* All available CSS variable names
|
|
229
231
|
*/
|
|
230
|
-
`;return
|
|
231
|
-
| ${
|
|
232
|
+
`;return $+=`export type CSSVariableNames =
|
|
233
|
+
| ${q};
|
|
232
234
|
|
|
233
|
-
|
|
234
|
-
`}function
|
|
235
|
+
`,$+`
|
|
236
|
+
`}function D1(X,Z){let Y="";if(Z)Y+=`/**
|
|
235
237
|
* Object containing all token values
|
|
236
238
|
*/
|
|
237
239
|
`;Y+=`export const tokenValues = {
|
|
238
|
-
`;for(let
|
|
239
|
-
`;Y+=` "${
|
|
240
|
+
`;for(let q of X){if(Z&&q.description)Y+=` /** ${q.description} */
|
|
241
|
+
`;Y+=` "${q.name}": ${JSON.stringify(q.value)},
|
|
240
242
|
`}return Y+=`} as const;
|
|
241
243
|
|
|
242
|
-
`,Y}function
|
|
244
|
+
`,Y}function S1(X,Z){let Y="";if(Z)Y+=`/**
|
|
243
245
|
* Array of all available icons
|
|
244
246
|
*/
|
|
245
247
|
`;Y+=`export const icons: Icon[] = [
|
|
246
|
-
`;for(let
|
|
247
|
-
`,Y+=` name: "${
|
|
248
|
-
`,Y+=` category: "${
|
|
249
|
-
`,Y+=` value: ${JSON.stringify(
|
|
250
|
-
|
|
251
|
-
`;if(
|
|
252
|
-
`;if(
|
|
248
|
+
`;for(let $ of X){if(Y+=` {
|
|
249
|
+
`,Y+=` name: "${$.name}",
|
|
250
|
+
`,Y+=` category: "${$.category}",
|
|
251
|
+
`,Y+=` value: ${JSON.stringify($.value)},
|
|
252
|
+
`,$.description)Y+=` description: ${JSON.stringify($.description)},
|
|
253
|
+
`;if($.style)Y+=` style: "${$.style}",
|
|
254
|
+
`;if($.dimensions)Y+=` dimensions: { width: ${$.dimensions.width}, height: ${$.dimensions.height} },
|
|
253
255
|
`;Y+=` },
|
|
254
256
|
`}if(Y+=`];
|
|
255
257
|
|
|
256
|
-
`,
|
|
258
|
+
`,Z)Y+=`/**
|
|
257
259
|
* Array of all icon names
|
|
258
260
|
*/
|
|
259
261
|
`;Y+=`export const iconNames: IconNames[] = [
|
|
260
|
-
`;for(let
|
|
262
|
+
`;for(let $ of X)Y+=` "${$.name}",
|
|
261
263
|
`;Y+=`] as const;
|
|
262
264
|
|
|
263
|
-
`;let
|
|
265
|
+
`;let q=[...new Set(X.map(($)=>$.category))];if(Z)Y+=`/**
|
|
264
266
|
* Array of all icon categories
|
|
265
267
|
*/
|
|
266
268
|
`;Y+=`export const iconCategories: IconCategories[] = [
|
|
267
|
-
`;for(let
|
|
269
|
+
`;for(let $ of q)Y+=` "${$}",
|
|
268
270
|
`;if(Y+=`] as const;
|
|
269
271
|
|
|
270
|
-
`,
|
|
272
|
+
`,Z)Y+=`/**
|
|
271
273
|
* Get icon by name
|
|
272
274
|
*/
|
|
273
275
|
`;if(Y+=`export function getIcon(name: IconNames): Icon | undefined {
|
|
274
276
|
`,Y+=` return icons.find(icon => icon.name === name);
|
|
275
277
|
`,Y+=`}
|
|
276
278
|
|
|
277
|
-
`,
|
|
279
|
+
`,Z)Y+=`/**
|
|
278
280
|
* Get icons by category
|
|
279
281
|
*/
|
|
280
282
|
`;return Y+=`export function getIconsByCategory(category: IconCategories): Icon[] {
|
|
@@ -282,36 +284,36 @@ ${A.sort().map((H)=>` ${H}`).join(`
|
|
|
282
284
|
`,Y+=`}
|
|
283
285
|
|
|
284
286
|
`,Y+`
|
|
285
|
-
`}function
|
|
287
|
+
`}function P1(X,Z){let Y="";if(Z)Y+=`/**
|
|
286
288
|
* Object mapping token paths to CSS variable names
|
|
287
289
|
*/
|
|
288
290
|
`;Y+=`export const cssVariableNames = {
|
|
289
|
-
`;for(let
|
|
291
|
+
`;for(let q of X)Y+=` "${q.name}": "${q.cssVar}",
|
|
290
292
|
`;return Y+=`} as const;
|
|
291
293
|
|
|
292
294
|
`,Y+`
|
|
293
|
-
`}function
|
|
295
|
+
`}function C1(X,Z){let Y="";if(Z)Y+=`/**
|
|
294
296
|
* Get the value of a design token
|
|
295
297
|
*/
|
|
296
298
|
`;if(Y+=`export function getTokenValue<T extends TokenPaths>(tokenPath: T): typeof tokenValues[T] {
|
|
297
299
|
return tokenValues[tokenPath];
|
|
298
300
|
}
|
|
299
301
|
|
|
300
|
-
`,
|
|
302
|
+
`,Z)Y+=`/**
|
|
301
303
|
* Get the CSS variable name for a design token
|
|
302
304
|
*/
|
|
303
305
|
`;if(Y+=`export function getCSSVariableName<T extends TokenPaths>(tokenPath: T): typeof cssVariableNames[T] {
|
|
304
306
|
return cssVariableNames[tokenPath];
|
|
305
307
|
}
|
|
306
308
|
|
|
307
|
-
`,
|
|
309
|
+
`,Z)Y+=`/**
|
|
308
310
|
* Get a CSS var() reference for a design token
|
|
309
311
|
*/
|
|
310
312
|
`;if(Y+=`export function getCSSVariableReference<T extends TokenPaths>(tokenPath: T): string {
|
|
311
313
|
return \`var(\${cssVariableNames[tokenPath]})\`;
|
|
312
314
|
}
|
|
313
315
|
|
|
314
|
-
`,
|
|
316
|
+
`,Z)Y+=`/**
|
|
315
317
|
* Check if a token path exists
|
|
316
318
|
*/
|
|
317
319
|
`;return Y+=`export function hasToken(tokenPath: string): tokenPath is TokenPaths {
|
|
@@ -319,36 +321,50 @@ ${A.sort().map((H)=>` ${H}`).join(`
|
|
|
319
321
|
}
|
|
320
322
|
|
|
321
323
|
`,Y+`
|
|
322
|
-
`}function
|
|
323
|
-
`,Y+=
|
|
324
|
-
`;else Y+=`${
|
|
325
|
-
`}return Y}function
|
|
326
|
-
* ${
|
|
327
|
-
* Generated: ${
|
|
324
|
+
`}function V1(X){let Z=new Map;for(let Y of X){if(!Z.has(Y.type))Z.set(Y.type,[]);Z.get(Y.type).push(Y)}return Z}function T1(X){let Z={};for(let Y of X){if(Y.path.some((z)=>z.includes("@")||z.includes("#")||z.includes("-")||z.includes(".")))continue;let $=Z,U=[...Y.path];for(let z=0;z<U.length-1;z++){let G=U[z];if(!$[G])$[G]={};$=$[G]}let W=U[U.length-1],K=MX(Y.value);$[W]=K}return Z}function cZ(X,Z){let Y="",q=" ".repeat(Z);for(let[$,U]of Object.entries(X)){let W=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test($)?$:`"${$}"`;if(typeof U==="object"&&!Array.isArray(U))Y+=`${q}${W}: {
|
|
325
|
+
`,Y+=cZ(U,Z+1),Y+=`${q}};
|
|
326
|
+
`;else Y+=`${q}${W}: ${U};
|
|
327
|
+
`}return Y}function MX(X){if(typeof X==="string")return`"${X}"`;else if(typeof X==="number")return X.toString();else if(typeof X==="boolean")return X.toString();else if(Array.isArray(X)){let Z=new Set(X.map((q)=>MX(q)));return`Array<${Array.from(Z).join(" | ")}>`}else if(X===null)return"null";else if(X===void 0)return"undefined";else if(typeof X==="object"&&X!==null)return`{ ${Object.entries(X).map(([q,$])=>`${q}: ${MX($)}`).join("; ")} }`;else return"unknown"}function y1(X){if(!X||typeof X!=="string")return"";return X.charAt(0).toUpperCase()+X.slice(1)}function PY(X){let Z=new Date().toISOString();return`/**
|
|
328
|
+
* ${X}
|
|
329
|
+
* Generated: ${Z}
|
|
328
330
|
*
|
|
329
331
|
* This file is auto-generated from design tokens.
|
|
330
332
|
* Do not edit this file directly - it will be overwritten.
|
|
331
333
|
*/
|
|
332
334
|
|
|
333
|
-
`}var
|
|
335
|
+
`}var CY=b(()=>{y()});import{readFileSync as g1,mkdirSync as f1}from"fs";import{writeFile as lZ,readdir as v1,mkdir as h1}from"fs/promises";import{resolve as m1,relative as rZ,join as dX,dirname as p1}from"path";import d1 from"lodash";async function sZ(X){let Z=await v1(X,{withFileTypes:!0}),Y=await Promise.all(Z.map((q)=>{let $=m1(X,q.name);return q.isDirectory()?sZ($):$}));return Array.prototype.concat(...Y)}async function iZ(X,Z){if(!X)throw Error("outputDir is required for buildIcons");let{assets:Y,icons:q,tokenNamespace:$,__dirname:U,buildDir:W}=await l(),K=dX(U,Y?.icons?.sourceDir??"icons"),z="build",G=Y?.icons?.distDir??z,E=dX(U,G),A=dX(U,W,"icons");if(!Y?.icons?.sourceDir){console.warn("Skipping icon build: iconsDir is not defined in the project paths.");return}n(dX(U,W));let L=(await sZ(K)).filter((B)=>B.endsWith(".svg")),Q=(await Promise.all(L.map(async(B)=>{let I=g1(B,"utf8").replace(/(\s+(?=(?:[^"]*"[^"]*")*[^"]*$))/g," ").trim()??"";I=await QY(I);let C=rZ(K,B).split("/").pop(),XX=(I.match(/name="(.*?)"/)??[])[1]??C?.replace(".svg",""),kX=(I.match(/data-style="(.*?)"/)??[])[1],z0=(I.match(/description="(.*?)"/)??[])[1],[mY]=I.match(/<svg[^>]*>/)??[],[,A0]=mY?.match(/width="([\d.]+)(px)?"/)??[],[,E0]=mY?.match(/height="([\d.]+)(px)?"/)??[];if(kX!=="animated"&&kX!=="custom")return{path:B,folder:rZ(K,B).split("/").slice(0,-1).concat(XX),file:C,style:kX,content:I,name:XX,dimensions:{width:Number(A0),height:Number(E0)},description:z0??""};return}))).filter((B)=>B!==void 0).reduce((B,I)=>{if(I?.style!=="animated"&&I?.style!=="custom"&&I)VY(B,I.folder.join("."),{$type:"icon",$name:I.name,$description:I.description,$style:I.style,$value:I.content,$extensions:{dimensions:I.dimensions},...u1(B,I.folder.join("."))});return B},{}),J=q?.objectPath??`${$}.icons`,w=Object.keys(Q).some((B)=>B.includes("."));if(Object.keys(Q).forEach(async(B)=>{let I,C;if(w)I=`${A}/${B}`,C=`${I}/svg.${B}.tokens.json`;else I=A,C=`${A}/svg.${B}.tokens.json`;await h1(I,{recursive:!0});let XX=VY({},`${J}${J?".":""}${B}`,Q[B]);await lZ(C,JSON.stringify(XX,null,2),{flag:"w",encoding:"utf-8"})}),!(Y?.icons?.excludeFromRaw??!1)){let B=`${E}/tokens/${await KX("json")}`,I=p1(B);f1(I,{recursive:!0});let C=VY({},J,Q);await lZ(B,JSON.stringify(C,null,2),{flag:"w",encoding:"utf-8"})}await k1(Q,X,Z)}async function k1(X,Z,Y){let{writeFileSync:q}=a("fs"),{join:$}=a("path");try{let U=Object.keys(X).sort(),W=`/**
|
|
336
|
+
* Icon Names Type Definition
|
|
337
|
+
* Generated: ${new Date().toISOString()}
|
|
338
|
+
*
|
|
339
|
+
* This file contains all available icon names for TypeScript typing.
|
|
340
|
+
* Do not edit this file directly - it will be overwritten.
|
|
341
|
+
*/
|
|
342
|
+
|
|
343
|
+
export const icons = [
|
|
344
|
+
${U.map((z)=>`'${z}'`).join(`,
|
|
345
|
+
`)}
|
|
346
|
+
] as const;
|
|
334
347
|
|
|
335
|
-
|
|
336
|
-
`,z
|
|
337
|
-
`,z+=` * Auto-generated from design token definitions
|
|
338
|
-
`,z+=` * Do not edit this file directly
|
|
339
|
-
`,z+=` */
|
|
348
|
+
export type IconName = typeof icons[number];
|
|
349
|
+
`,K=$(Z,"typescript","tokens.icons.ts");q(K,W,"utf-8"),console.log(`✓ Generated ${U.length} icon names`)}catch(U){console.error("Failed to generate icon names:",U)}}var VY,u1;var aZ=b(()=>{y();({set:VY,get:u1}=d1)});function oZ(X,Z={}){let Y=[],q=Z.typescript?"ts":"js",$=Z.modes||[],U=X.filter((K)=>K.extensions?.mediaQuery||K.name.includes("@screen")||K.name.includes("@_")),W=X.filter((K)=>!K.extensions?.mediaQuery&&!K.name.includes("@screen")&&!K.name.includes("@_"));if(Z.separateThemeFiles&&$.length>0){let K=$.join("|"),z=new RegExp(`#(${K})$`),G=new Map;for(let E of $)G.set(E,[]);for(let E of W){let A=E.name.match(z);if(A){let L=A[1];G.get(L).push(E)}else{let L=$[0];G.get(L).push(E)}}for(let E of $){let A=G.get(E)||[];if(A.length>0){if(Z.typescript){let L=eZ(A,E);Y.push({fileName:`${E}.d.ts`,content:a1(L,Z,E),theme:E})}Y.push({fileName:`${E}.${q}`,content:tZ(A,{...Z,theme:E}),theme:E})}}}else Y.push({fileName:`tokens.${q}`,content:tZ(W,Z)});if(U.length>0)Y.push({fileName:`breakpoints.${q}`,content:c1(U,X,Z)});if(Z.separateThemeFiles&&Y.length>1)Y.push({fileName:`index.${q}`,content:t1(Y,Z)});return Y}function c1(X,Z,Y={}){let{typescript:q,includeJSDoc:$,moduleType:U="es",customHeader:W,modes:K=[]}=Y,z=new Map(Z.map((L)=>[L.name,L])),G={};for(let L of X){let H=L.extensions?.mediaQuery||l1(L.name),_=K.length>0?K[0]:"default";for(let O of K)if(L.name.includes(`#${O}`)){_=O;break}if(typeof H==="string"&&H.includes("{")&&H.includes("}"))H=s1(H,z);if(!G[H])G[H]={};if(!G[H][_])G[H][_]={};let Q=r1(L.name),J=i1(Q,uX(L.value,z));G[H][_]={...G[H][_],...J}}let E=Object.keys(G).sort((L,H)=>{let _=nZ(L),Q=nZ(H);return _-Q}).reduce((L,H)=>{return L[H]=G[H],L},{}),A="";if(W)A+=`${W}
|
|
340
350
|
|
|
341
|
-
`;
|
|
342
|
-
|
|
351
|
+
`;else A+=`/**
|
|
352
|
+
`,A+=` * Design Tokens - Breakpoints
|
|
353
|
+
`,A+=` * Auto-generated from design token definitions
|
|
354
|
+
`,A+=` * Do not edit this file directly
|
|
355
|
+
`,A+=` */
|
|
343
356
|
|
|
344
|
-
`;
|
|
357
|
+
`;if(q)A+=X0(E,$),A+=`
|
|
358
|
+
`;if(U==="es"){if(q)A+=`const breakpoints: Tokens = ${e(E,$,0)};
|
|
345
359
|
|
|
346
|
-
`;
|
|
347
|
-
`}else z+=`const breakpoints = ${o(E,q,0)};
|
|
360
|
+
`;else A+=`const breakpoints = ${e(E,$,0)};
|
|
348
361
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
362
|
+
`;A+=`export default breakpoints;
|
|
363
|
+
`}else A+=`const breakpoints = ${e(E,$,0)};
|
|
364
|
+
|
|
365
|
+
`,A+=`module.exports = breakpoints;
|
|
366
|
+
`,A+=`module.exports.default = breakpoints;
|
|
367
|
+
`;return A}function l1(X){if(X.includes("@_max_width_")){let Z=X.match(/@_max_width___(.+?)__/);if(Z)return`screen and (max-width: {${Z[1].replace(/_/g,".")}})`}if(X.includes("@_min_width_")){let Z=X.match(/@_min_width___(.+?)__/);if(Z)return`screen and (min-width: {${Z[1].replace(/_/g,".")}})`}return"screen"}function r1(X){let Z=X.replace(/@_.*?__/,"").replace(/@screen.*/,"").replace(/#[^#]*$/,"").replace(/^universe\./,"");return Z=Z.replace(/_universe_foundation_breakpoint_screen_width_[^_]+__?$/,""),Z}function nZ(X){let Z=X.match(/(\d+(?:\.\d+)?)/);return Z?parseFloat(Z[1]):0}function s1(X,Z){return X.replace(/\{([^}]+)\}/g,(Y,q)=>{let $=Z.get(q);if($){let U=$.value;if(typeof U==="object"&&U!==null&&"$value"in U)U=U.$value;return String(U)}return Y})}function i1(X,Z){let Y=X.split("."),q={},$=q;for(let U=0;U<Y.length-1;U++)$[Y[U]]={},$=$[Y[U]];return $[Y[Y.length-1]]=Z,q}function tZ(X,Z={}){let{typescript:Y,includeJSDoc:q,moduleType:$="es",customHeader:U,theme:W}=Z,K="";if(U)K+=`${U}
|
|
352
368
|
|
|
353
369
|
`;else K+=`/**
|
|
354
370
|
`,K+=` * Design Tokens - ${W?`${W.charAt(0).toUpperCase()+W.slice(1)} Theme`:"All Tokens"}
|
|
@@ -356,27 +372,27 @@ ${A.sort().map((H)=>` ${H}`).join(`
|
|
|
356
372
|
`,K+=` * Do not edit this file directly
|
|
357
373
|
`,K+=` */
|
|
358
374
|
|
|
359
|
-
`;let
|
|
375
|
+
`;let z=eZ(X,W);if(Y)if(Z.separateThemeFiles&&W)K+=`import type { Tokens } from "./${W}.d";
|
|
360
376
|
|
|
361
|
-
`;else K+=
|
|
362
|
-
`;if(
|
|
377
|
+
`;else K+=X0(z,q),K+=`
|
|
378
|
+
`;if($==="es"){if(Y)K+=`const tokens: Tokens = ${e(z,q,0)};
|
|
363
379
|
|
|
364
|
-
`;else K+=`const tokens = ${
|
|
380
|
+
`;else K+=`const tokens = ${e(z,q,0)};
|
|
365
381
|
|
|
366
382
|
`;K+=`export default tokens;
|
|
367
|
-
`;let G=Object.keys(
|
|
383
|
+
`;let G=Object.keys(z);if(G.length>0){K+=`
|
|
368
384
|
// Named exports for convenience
|
|
369
385
|
`;for(let E of G)K+=`export const ${E} = tokens.${E};
|
|
370
|
-
`}}else K+=`const tokens = ${
|
|
386
|
+
`}}else K+=`const tokens = ${e(z,q,0)};
|
|
371
387
|
|
|
372
388
|
`,K+=`module.exports = tokens;
|
|
373
389
|
`,K+=`module.exports.default = tokens;
|
|
374
390
|
`;return K+`
|
|
375
|
-
`}function
|
|
391
|
+
`}function eZ(X,Z){let Y={},q=new Map(X.map(($)=>[$.name,$]));for(let $ of X){let U=$.name;if(Z){if(U.includes(`#${Z}`))U=U.replace(`#${Z}`,"")}else U=U.replace(/#[^#]*$/,"");let W=U.split("."),K=Y;for(let G=0;G<W.length-1;G++){let E=W[G];if(!K[E])K[E]={};K=K[E]}let z=W[W.length-1];K[z]=uX($.value,q)}return Y}function uX(X,Z){if(typeof X==="object"&&X!==null&&!Array.isArray(X)){let Y=X;if(Y.color&&typeof Y.color==="string"&&Y.color.includes("{")&&Y.color.includes("}")){let q=h(X,"shadow");if(typeof q==="string"&&!q.includes("{")){let $={...Y},U=q.split(" "),W=U[U.length-1];if(W&&W.startsWith("#"))$.color=W;else $.color=h(Y.color,"color");return $}}}if(typeof X==="string"){if(X.startsWith("{")&&X.endsWith("}")){let Y=X.slice(1,-1),q=Z.get(Y);if(q)return q.value;let $=h(X,"color");if($!==X)return $}return X}if(Array.isArray(X))return X.map((Y)=>uX(Y,Z));if(typeof X==="object"&&X!==null){let Y={};for(let[q,$]of Object.entries(X))Y[q]=uX($,Z);return Y}return X}function X0(X,Z){let Y="";if(Z)Y+=`/**
|
|
376
392
|
* Token object type definition
|
|
377
393
|
*/
|
|
378
|
-
`;return Y+=`type Tokens = ${
|
|
379
|
-
`,Y}function
|
|
394
|
+
`;return Y+=`type Tokens = ${TY(X,0)};
|
|
395
|
+
`,Y}function a1(X,Z,Y){let{customHeader:q,includeJSDoc:$}=Z,U="";if(q)U+=`${q}
|
|
380
396
|
|
|
381
397
|
`;else{let W=Y?` - ${Y.charAt(0).toUpperCase()+Y.slice(1)} Theme`:"";U+=`/**
|
|
382
398
|
`,U+=` * Universe Design System Tokens - Type Definitions${W}
|
|
@@ -384,44 +400,44 @@ ${A.sort().map((H)=>` ${H}`).join(`
|
|
|
384
400
|
`,U+=` * Do not edit this file directly
|
|
385
401
|
`,U+=` */
|
|
386
402
|
|
|
387
|
-
`}if(
|
|
403
|
+
`}if($)U+=`/**
|
|
388
404
|
* Token object type definition
|
|
389
405
|
*/
|
|
390
|
-
`;return U+=`export type Tokens = ${
|
|
406
|
+
`;return U+=`export type Tokens = ${TY(X,0)};
|
|
391
407
|
`,U+`
|
|
392
|
-
`}function
|
|
393
|
-
`;for(let[U,W]of
|
|
394
|
-
`}return
|
|
395
|
-
`;for(let K=0;K<U.length;K++){let[
|
|
396
|
-
`;let
|
|
397
|
-
`}return W+=`${
|
|
408
|
+
`}function TY(X,Z){if(typeof X!=="object"||X===null)return typeof X==="string"?"string":typeof X==="number"?"number":typeof X==="boolean"?"boolean":"any";let Y=" ".repeat(Z+1),q=Object.entries(X);if(q.length===0)return"{}";let $=`{
|
|
409
|
+
`;for(let[U,W]of q){let K=n1(U)?`"${U}"`:U;$+=`${Y}${K}: ${TY(W,Z+1)};
|
|
410
|
+
`}return $+=" ".repeat(Z)+"}",$}function n1(X){return X.startsWith("@")||X.includes(" ")||X.includes("-")||X.includes("(")||X.includes(")")||X.includes("@")||X.includes(":")||!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(X)}function e(X,Z,Y=0){if(typeof X!=="object"||X===null)return JSON.stringify(X);let q=" ".repeat(Y),$=" ".repeat(Y+1),U=Object.entries(X);if(U.length===0)return"{}";let W=`{
|
|
411
|
+
`;for(let K=0;K<U.length;K++){let[z,G]=U[K],E=K===U.length-1;if(Z&&typeof G==="string")W+=`${$}/** Token value: ${JSON.stringify(G)} */
|
|
412
|
+
`;let A=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(z)?z:JSON.stringify(z),L=e(G,Z,Y+1);W+=`${$}${A}: ${L}${E?"":","}
|
|
413
|
+
`}return W+=`${q}}`,W}function t1(X,Z){let Y=Z.typescript?"ts":"js",{moduleType:q="es",customHeader:$}=Z,U=(K)=>{return K.replace(/-([a-z])/g,(z,G)=>G.toUpperCase())},W="";if($)W+=`${$}
|
|
398
414
|
|
|
399
415
|
`;else W+=`/**
|
|
400
416
|
`,W+=` * Design Tokens - Index
|
|
401
417
|
`,W+=` * Exports all token themes for convenient importing
|
|
402
418
|
`,W+=` */
|
|
403
419
|
|
|
404
|
-
`;if(
|
|
420
|
+
`;if(q==="es"){for(let K of X){if(K.fileName===`index.${Y}`)continue;if(!K.fileName.endsWith(".d.ts"))continue;let z=K.fileName.replace(".d.ts",""),G=U(K.theme||z);W+=`export type { Tokens as ${G.charAt(0).toUpperCase()+G.slice(1)}Tokens } from './${z}.d';
|
|
405
421
|
`}W+=`
|
|
406
|
-
`;for(let K of
|
|
422
|
+
`;for(let K of X){if(K.fileName===`index.${Y}`)continue;if(K.fileName.endsWith(".d.ts"))continue;let z=K.fileName.replace(`.${Y}`,""),G=U(K.theme||z);W+=`export { default as ${G} } from './${z}${Z.typescript?"":".js"}';
|
|
407
423
|
`}W+=`
|
|
408
424
|
// Convenience re-exports
|
|
409
|
-
`,W+=`export { default } from './light${
|
|
410
|
-
`}else{for(let K of
|
|
425
|
+
`,W+=`export { default } from './light${Z.typescript?"":".js"}';
|
|
426
|
+
`}else{for(let K of X){if(K.fileName===`index.${Y}`)continue;if(K.fileName.endsWith(".d.ts"))continue;let z=K.fileName.replace(`.${Y}`,""),G=U(K.theme||z);W+=`exports.${G} = require('./${z}');
|
|
411
427
|
`}W+=`
|
|
412
428
|
// Default export points to light theme
|
|
413
429
|
`,W+=`module.exports = require('./light');
|
|
414
430
|
`}return W+`
|
|
415
|
-
`}var
|
|
431
|
+
`}var Y0=b(()=>{pX()});var Z0={};lX(Z0,{validateCSSFiles:()=>o1,printValidationResults:()=>e1});import{readFileSync as yY,existsSync as GX}from"fs";import{join as u}from"path";function o1(X,Z){let Y={isValid:!0,errors:[],warnings:[],checks:[]},q=u(X,"css"),$=u(q,"tokens.css"),U=GX($);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(Z.$metaData?.tokens?.css?.mediaQuery?.separateThemeFiles??!1){let A=u(q,"tokens.dark.css"),L=GX(A);if(Y.checks.push({name:"CSS file exists: tokens.dark.css",passed:L,message:L?void 0:"Missing required CSS file: tokens.dark.css (separateThemeFiles is enabled)"}),!L)Y.errors.push("Missing required CSS file: tokens.dark.css (separateThemeFiles is enabled)"),Y.isValid=!1}let K=u(q,"tokens.breakpoints.css");if(GX(K))Y.checks.push({name:"CSS file exists: tokens.breakpoints.css",passed:!0,message:void 0});let G=Z.$metaData?.tokens?.css?.hooks?.shortenName;if(G?.enabled&&GX(u(q,"tokens.css"))){let A=yY(u(q,"tokens.css"),"utf8");if(G.prefix)for(let{find:L,replace:H}of G.prefix){let _=`--${RX}-${L}`,Q=`--${H}`,J=A.includes(_),O=A.includes(Q);if(Y.checks.push({name:`Prefix hook applied: ${L} → ${H}`,passed:!J&&O,message:J?`Old prefix "${_}" still found in CSS, should be "${Q}"`:void 0}),J)Y.errors.push(`Prefix transformation failed: "${_}" should be replaced with "${Q}"`),Y.isValid=!1}if(G.suffix)for(let{find:L,replace:H}of G.suffix){let Q=new RegExp(`--[^:]+${L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}:`,"g").test(A);if(Y.checks.push({name:`Suffix hook applied: ${L} → ${H}`,passed:!Q,message:Q?`Old suffix "${L}" still found in CSS variable names`:void 0}),Q)Y.errors.push(`Suffix transformation failed: "${L}" should be removed/replaced with "${H}"`),Y.isValid=!1}}if(GX(u(q,"tokens.css"))){let L=yY(u(q,"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=u(q,A);if(GX(L)){let H=yY(L,"utf8"),_=(H.match(/\{/g)||[]).length-(H.match(/\}/g)||[]).length;if(Y.checks.push({name:`CSS syntax valid: ${A}`,passed:_===0,message:_!==0?`Mismatched braces in ${A}`:void 0}),_!==0)Y.errors.push(`CSS syntax error in ${A}: mismatched braces`),Y.isValid=!1}}return Y}function e1(X){console.log(`
|
|
416
432
|
|
|
417
|
-
Build Validation Results:`),console.log("========================================================");for(let
|
|
418
|
-
⚠️ Warnings:`);for(let
|
|
419
|
-
❌ Errors:`);for(let
|
|
420
|
-
Validation Summary:`),console.log(` - Checks: ${
|
|
421
|
-
${
|
|
433
|
+
Build Validation Results:`),console.log("========================================================");for(let Z of X.checks){let Y=Z.passed?"✓":"✗";if(console.log(` ${Y} ${Z.name}`),Z.message)console.log(` ${Z.message}`)}if(X.warnings.length>0){console.log(`
|
|
434
|
+
⚠️ Warnings:`);for(let Z of X.warnings)console.log(` ${Z}`)}if(X.errors.length>0){console.log(`
|
|
435
|
+
❌ Errors:`);for(let Z of X.errors)console.log(` ${Z}`)}console.log(`
|
|
436
|
+
Validation Summary:`),console.log(` - Checks: ${X.checks.filter((Z)=>Z.passed).length}/${X.checks.length} passed`),console.log(` - Errors: ${X.errors.length}`),console.log(` - Warnings: ${X.warnings.length}`),console.log(`
|
|
437
|
+
${X.isValid?"✅":"❌"} Build ${X.isValid?"passed":"failed"}`),console.log(`
|
|
422
438
|
========================================================
|
|
423
|
-
`)}var
|
|
424
|
-
* ${
|
|
439
|
+
`)}var q0=b(()=>{y()});import{writeFileSync as X2,mkdirSync as Y2,existsSync as fY,readFileSync as gY,readdirSync as Z2,statSync as $0}from"fs";import{join as P,dirname as NX}from"path";function q2(X,Z,Y=!1,q=!1){let $=[],U=[],W=[];for(let z of X)if(z.fileName.includes("breakpoint"))U.push(`@import url("./css/${z.fileName}");`);else W.push(`@import url("./css/${z.fileName}");`);if($.push(...W),Y)$.push('@import url("./css/tokens.icons.css");');if(q)$.push('@import url("./css/fonts.css");');$.push(...U);let K=`/**
|
|
440
|
+
* ${Z} Design System - Main CSS Entry Point
|
|
425
441
|
* Generated: ${new Date().toISOString()}
|
|
426
442
|
*
|
|
427
443
|
* This file imports all generated CSS files for the design system.
|
|
@@ -430,11 +446,11 @@ ${$.isValid?"✅":"❌"} Build ${$.isValid?"passed":"failed"}`),console.log(`
|
|
|
430
446
|
* Do not edit this file directly - it will be overwritten.
|
|
431
447
|
*/
|
|
432
448
|
|
|
433
|
-
${
|
|
449
|
+
${$.join(`
|
|
434
450
|
`)}
|
|
435
|
-
`;return{fileName:`${
|
|
436
|
-
`,theme:void 0}}function $
|
|
437
|
-
* ${
|
|
451
|
+
`;return{fileName:`${Z}.design-system.tokens.css`,content:K+`
|
|
452
|
+
`,theme:void 0}}function $2(X,Z,Y=!1,q=!1,$,U){let{readFileSync:W}=a("fs"),{join:K}=a("path"),z=[],G=(H)=>{try{let _=K($,"css",H);return W(_,"utf-8")}catch(_){return console.warn(`Could not read ${H}:`,_),""}},E=[];for(let H of X){let _=G(H.fileName);if(!_)continue;if(H.fileName.includes("breakpoint"))E.push(_);else z.push(_)}let A=U?.$paths?.assets?.icons?.excludeFromRaw??!1;if(Y&&!A){let H=G("tokens.icons.css");if(H)z.push(H)}if(q){let H=G("fonts.css");if(H)z.push(H)}z.push(...E);let L=`/**
|
|
453
|
+
* ${Z} Design System - Raw/Inline CSS
|
|
438
454
|
* Generated: ${new Date().toISOString()}
|
|
439
455
|
*
|
|
440
456
|
* This file contains all CSS inlined (no @import statements).
|
|
@@ -444,33 +460,33 @@ ${q.join(`
|
|
|
444
460
|
* Do not edit this file directly - it will be overwritten.
|
|
445
461
|
*/
|
|
446
462
|
|
|
447
|
-
${
|
|
463
|
+
${z.join(`
|
|
448
464
|
|
|
449
465
|
`)}
|
|
450
|
-
`;return{fileName:`${
|
|
451
|
-
`,theme:void 0}}function
|
|
452
|
-
`+` Tokens dir: ${
|
|
453
|
-
Compositions dir: ${
|
|
454
|
-
Please move compositions to a separate directory (e.g., './compositions')`};return{valid:!0}}function
|
|
455
|
-
`),G.length===0)E.push("/* No compositions defined */");else for(let L of G){E.push(`/* ${L.name} */`);let H=L.groupProperties,_=H&&(H.mediaQuery||H.parentSelector||H.containerQuery||H.customAtRule),Q="",
|
|
456
|
-
`)
|
|
457
|
-
`,theme:void 0})}return
|
|
458
|
-
Starting token build process
|
|
459
|
-
Generating CSS files
|
|
460
|
-
Generated icon tokens
|
|
461
|
-
Processing composition files
|
|
462
|
-
Generating TypeScript files
|
|
463
|
-
Generating JavaScript files
|
|
464
|
-
Generating JSON files
|
|
465
|
-
Build completed in ${Y.duration}ms
|
|
466
|
-
Validating build output
|
|
467
|
-
* ${
|
|
466
|
+
`;return{fileName:`${Z}.design-system.tokens.raw.css`,content:L+`
|
|
467
|
+
`,theme:void 0}}function U2(X,Z){let Y=X.replace(/\\/g,"/");if(Z.replace(/\\/g,"/").startsWith(Y))return{valid:!1,error:`⚠️ Compositions directory cannot be inside tokens directory.
|
|
468
|
+
`+` Tokens dir: ${X}
|
|
469
|
+
Compositions dir: ${Z}
|
|
470
|
+
Please move compositions to a separate directory (e.g., './compositions')`};return{valid:!0}}function K2(X,Z){let Y=[];if(fY(X)){let q=$0(X);if(q.isDirectory())try{let $=Z2(X);for(let U of $){if(!U.endsWith(".json"))continue;let W=P(X,U);if($0(W).isFile())try{let z=gY(W,"utf-8"),G=JSON.parse(z);if(Array.isArray(G))Y.push(...G);else Y.push(G)}catch(z){console.warn(`⚠️ Failed to parse composition file ${U}:`,z)}}}catch($){console.warn("⚠️ Failed to read compositions directory:",$)}else if(q.isFile()&&X.endsWith(".json"))try{let $=gY(X,"utf-8"),U=JSON.parse($);if(Array.isArray(U))Y.push(...U);else Y.push(U)}catch($){console.warn("⚠️ Failed to parse compositions file:",$)}}if(Z&&Y.length===0){let q=P(Z,"compositions.json");if(fY(q))try{let $=gY(q,"utf-8"),U=JSON.parse($);if(Array.isArray(U))Y.push(...U)}catch($){console.warn("⚠️ Failed to parse compositions.json:",$)}}return Y}function U0(X,Z){let Y=Z.$metaData?.tokens?.css?.hooks?.shortenName;if(!Y?.enabled)return X;let q=X;if(Y.prefix&&Array.isArray(Y.prefix))for(let $ of Y.prefix)q=q.replace(new RegExp($.find,"g"),$.replace);if(Y.suffix&&Array.isArray(Y.suffix)){for(let $ of Y.suffix)if(q.endsWith($.find))q=q.substring(0,q.length-$.find.length)+$.replace}return q}function W2(X,Z){let Y=X.match(/^\{(.+)\}$/);if(Y){let $=Y[1].replace(/\./g,"-");return $=U0($,Z),`var(--${$})`}return X.replace(/\{([^}]+)\}/g,(q,$)=>{let U=$.replace(/\./g,"-");return U=U0(U,Z),`var(--${U})`})}function G2(X,Z,Y,q){let $=[],U=X.filter((z)=>z.platform==="css");if(U.length===0)return $;let W=new Map,K="compositions.css";for(let z of U){let G=z.fileName||"";if(G.endsWith(".css"))G=G.slice(0,-4);let E=G?`${G}.css`:K;if(!W.has(E))W.set(E,[]);W.get(E).push(z)}for(let[z,G]of W.entries()){let E=[];if(E.push("/**"),E.push(" * Design System Compositions - Generated Styles"),E.push(" * DO NOT EDIT THIS FILE DIRECTLY"),E.push(" * Generated from composition definitions"),E.push(` * Namespace: ${Z.$metaData?.dsNamespace||"ds"}.${Z.$metaData?.tokenNamespace||"tokens"}`),E.push(` * File: ${z}`),E.push(` */
|
|
471
|
+
`),G.length===0)E.push("/* No compositions defined */");else for(let L of G){E.push(`/* ${L.name} */`);let H=L.groupProperties,_=H&&(H.mediaQuery||H.parentSelector||H.containerQuery||H.customAtRule),Q="",J=[];if(_){if(H.customAtRule){let O=k(H.customAtRule,Y);E.push(`${O} {`),J.push("}"),Q=" "}if(H.mediaQuery){let O=k(H.mediaQuery,Y);E.push(`${Q}${O} {`),J.push("}"),Q+=" "}if(H.containerQuery){let O=k(H.containerQuery,Y);E.push(`${Q}${O} {`),J.push("}"),Q+=" "}if(H.parentSelector){let O=k(H.parentSelector,Y);E.push(`${Q}${O} {`),J.push("}"),Q+=" "}}E.push(`${Q}${L.selector} {`);for(let O of L.properties){let w=W2(O.token,Z);E.push(`${Q} ${O.property}: ${w};`)}E.push(`${Q}}`);while(J.length>0)Q=Q.slice(2),E.push(`${Q}${J.pop()}`);E.push("")}let A=E.join(`
|
|
472
|
+
`);$.push({fileName:z,content:A+`
|
|
473
|
+
`,theme:void 0})}return $}async function W0(X){let Z=Date.now(),Y={tokenCount:0,cssFiles:[],typescriptFiles:[],javascriptFiles:[],jsonFiles:[],duration:0,warnings:[],errors:[]};try{M(`
|
|
474
|
+
Starting token build process...`,X.verbose);let{initializeColorspace:q}=await Promise.resolve().then(() => (AX(),lY));await q(),M("Loading token files...",X.verbose);let $=IY(X.tokensDir);M("Parsing tokens...",X.verbose);let U=z2(X.config),W=wY($,U);if(M(`Found ${W.length} tokens`,X.verbose),Y.tokenCount=W.length,W.length===0&&U.namespace){let G=Object.keys($).filter((E)=>!E.startsWith("$"));if(G.length>0)Y.warnings.push(`⚠️ No tokens found matching tokenNamespace "${U.namespace}". Found root keys: ${G.join(", ")}. Please check if your $metaData.tokenNamespace in designid.config.ts matches.`)}let K=RY(W,U);if(M(`Resolved ${K.length} tokens`,X.verbose),X.generateCSS!==!1){M(`
|
|
475
|
+
Generating CSS files...`,X.verbose);let G=K0(X.config,X.cssOptions),E=fX(K,G);for(let A of E){let L=P(X.outputDir,"css",A.fileName);i(L,A.content),M(` ✓ ${A.fileName}`,X.verbose)}Y.cssFiles=E}if(X.generateCSS!==!1)try{await iZ(X.outputDir,X.config),M(`
|
|
476
|
+
Generated icon tokens`,X.verbose)}catch(G){if(X.verbose)console.warn("Could not build icon tokens:",G)}if(X.generateCSS!==!1)try{let G=await DY();if(G.length>0){let E=K0(X.config,X.cssOptions),A=X.config.$metaData?.modes?.isHost??!1,L=X.config.$modes?.default||"light",H=bY(G,{customHeader:mX(X.config),objectPath:X.config.$metaData?.icons?.objectPath||"universe.custom.path.icons",hooks:E.hooks,isHost:A,defaultMode:L}),_=P(X.outputDir,"css",H.fileName);if(i(_,H.content),M(` ✓ Generated ${H.fileName}`,X.verbose),Y.cssFiles)Y.cssFiles.push(H);else Y.cssFiles=[H]}}catch(G){if(X.verbose)console.warn("Could not generate icon CSS:",G)}let z=!1;if(X.generateCSS!==!1)try{let G=X.config.$fonts;if(G&&G.length>0){await OY(G,X.outputDir),M(" ✓ Generated fonts.css",X.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(X.verbose)console.warn("Could not generate font CSS:",G)}if(X.generateCSS!==!1&&Y.cssFiles.length>0){let G=X.config.$metaData?.tokenNamespace||"tokens",E=Y.cssFiles.some((Q)=>Q.fileName==="tokens.icons.css"),A=X.config.$metaData?.modes?.isHost||!1,L=Y.cssFiles.filter((Q)=>{if(Q.fileName==="tokens.icons.css"||Q.fileName==="fonts.css")return!1;if(A&&Q.fileName.includes("composition"))return!1;return!0}),H=q2(L,G,E,z),_=P(X.outputDir,H.fileName);if(i(_,H.content),M(` ✓ Generated ${H.fileName}`,X.verbose),Y.cssFiles.push(H),A){let Q=$2(Y.cssFiles.filter((O)=>O.fileName!=="tokens.icons.css"&&O.fileName!=="fonts.css"&&!O.fileName.includes(".design-system.tokens.css")),G,E,z,X.outputDir,X.config),J=P(X.outputDir,Q.fileName);i(J,Q.content),M(` ✓ Generated ${Q.fileName} (raw/inline for web components)`,X.verbose),Y.cssFiles.push(Q)}}if(X.generateCSS!==!1&&X.config.$paths.compositionsDir)try{let G=X.config.$paths.baseDir,E=X.config.$paths.tokensDir,A=X.tokensDir,L=E.split("/").filter((O)=>O&&O!=="."&&O!=="..");for(let O=0;O<L.length;O++)A=NX(A);let H=G.split("/").filter((O)=>O&&O!=="."&&O!=="..");for(let O=0;O<H.length;O++)A=NX(A);let _=P(A,G,X.config.$paths.compositionsDir),Q=P(A,G);if(X.verbose)console.log(` Project root: ${A}`),console.log(` Base dir: ${Q}`),console.log(` Compositions dir: ${_}`);let J=U2(X.tokensDir,_);if(!J.valid)console.error(J.error),Y.errors.push(J.error);else{M(`
|
|
477
|
+
Processing composition files...`,X.verbose);let O=K2(_,Q);if(O.length>0){M(` Found ${O.length} composition(s)`,X.verbose);let w=new Map;for(let B of K){let I=Array.isArray(B.path)?B.path.join("."):B.path;w.set(I,B)}let R=G2(O,X.config,w,X.outputDir);for(let B of R){let I=P(X.outputDir,"css",B.fileName);i(I,B.content),M(` ✓ Generated ${B.fileName}`,X.verbose),Y.cssFiles.push(B)}}else M(` No compositions found in ${_}`,X.verbose)}}catch(G){if(X.verbose)console.warn("Could not generate composition CSS:",G)}if(X.generateTypeScript!==!1){M(`
|
|
478
|
+
Generating TypeScript files...`,X.verbose);let G=A2(X.config,X.typescriptOptions),E=await SY(K,G,X.outputDir);for(let A of E){let L=P(X.outputDir,"typescript",A.fileName);i(L,A.content),M(` ✓ Generated ${A.fileName}`,X.verbose)}Y.typescriptFiles=E}if(X.generateJavaScript!==!1){M(`
|
|
479
|
+
Generating JavaScript files...`,X.verbose);let G=E2(X.config,X.javascriptOptions),E=oZ(K,G);for(let A of E){let L=P(X.outputDir,"js",A.fileName);i(L,A.content),M(` ✓ Generated ${A.fileName}`,X.verbose)}Y.javascriptFiles=E}if(X.generateJSON!==!1){M(`
|
|
480
|
+
Generating JSON files...`,X.verbose);let G=L2(K,W,X.config);for(let E of G){let A=P(X.outputDir,"json",E.fileName);i(A,E.content),M(` ✓ Generated ${E.fileName}`,X.verbose)}Y.jsonFiles=G}Y.duration=Date.now()-Z,M(`
|
|
481
|
+
Build completed in ${Y.duration}ms`,X.verbose)}catch(q){let $=q instanceof Error?q.message:String(q);Y.errors.push($),M(`❌ Build failed: ${$}`,X.verbose)}if(X.validate!==!1){M(`
|
|
482
|
+
Validating build output...`,X.verbose);let{validateCSSFiles:q,printValidationResults:$}=await Promise.resolve().then(() => (q0(),Z0)),U=q(X.outputDir,X.config);if(X.verbose||!U.isValid)$(U);if(!U.isValid)Y.errors.push(...U.errors)}return Y}function z2(X){let Z=X.$metaData,Y=X.$modes?[...Object.values(X.$modes)]:[];return{prefix:Z.dsNamespace||Z.tokenNamespace,namespace:Z.tokenNamespace,generateModes:!0,modes:Y,generateDerivedTokens:!0,generateBreakpointTokens:!0,failOnBrokenReferences:!0,transformName:(q)=>{let $=Z.tokens?.css?.hooks?.shortenName;if($?.enabled){let U=q;if($.prefix)for(let{find:W,replace:K}of $.prefix){let z=W.replace(/\./g,"-").replace(/-$/,""),G=K.replace(/\./g,"-").replace(/-$/,"");U=U.replace(z,G)}if($.suffix){for(let{find:W,replace:K}of $.suffix)if(U.endsWith(W))U=U.substring(0,U.length-W.length)+K}return U}return q}}}function K0(X,Z){let Y=X.$metaData,q=Y.tokens?.css,$=X.$modes?[...Object.values(X.$modes)]:["light","dark"],U=$.length>0?$[0]:"light",W=Y.modes?.isHost??!1;return{...Z,separateThemeFiles:q?.mediaQuery?.separateThemeFiles??!1,rootSelector:":root",generateMediaQueries:!0,customHeader:mX(X),themeSelector:q?.mediaQuery?.match||"[data-theme]",modes:$,defaultMode:U,isHost:W,hooks:q?.hooks}}function A2(X,Z){let Y=X.$metaData;return{...Z,tokenInterface:"DesignTokens",exportNamespace:Y.dsNamespace||Y.tokenNamespace,generateTypes:!0,generateConsts:!0,generateCSSVarMappings:!0,includeJSDoc:!0}}function E2(X,Z){let Y=X.$modes?[...Object.values(X.$modes)]:["light","dark"];return{...Z,modes:Y,typescript:!0,separateThemeFiles:!0,includeJSDoc:!1,moduleType:"es",customHeader:`/**
|
|
483
|
+
* ${X.$name}
|
|
468
484
|
* Generated: ${new Date().toISOString()}
|
|
469
|
-
*/`}}function
|
|
470
|
-
`});let U=JSON.stringify({$name:Y.$name,$version:Y.$version,tokens
|
|
471
|
-
`});let W=JSON.stringify({$name:`${Y.$name} - CSS Variables`,$version:Y.$version,variables
|
|
472
|
-
`}),
|
|
473
|
-
`);return!0}catch(W){if(console.error("❌ Failed to compile config file"),W instanceof Error)console.error(W.message);throw W}}
|
|
485
|
+
*/`}}function L2(X,Z,Y){let q=[],$=JSON.stringify({$schema:"https://schemas.designtokens.org/design-tokens.schema.json",$name:Y.$name,$version:Y.$version,tokens:Z.reduce((K,z)=>{return K[z.name]={$type:z.type,$value:z.value,$description:z.description,$extensions:z.extensions},K},{})},null,2);q.push({fileName:"tokens.raw.json",content:$+`
|
|
486
|
+
`});let U=JSON.stringify({$name:Y.$name,$version:Y.$version,tokens:X.reduce((K,z)=>{return K[z.name]={$type:z.type,$value:z.value,$description:z.description,cssVar:z.cssVar},K},{})},null,2);q.push({fileName:"tokens.resolved.json",content:U+`
|
|
487
|
+
`});let W=JSON.stringify({$name:`${Y.$name} - CSS Variables`,$version:Y.$version,variables:X.reduce((K,z)=>{return K[z.cssVar]=z.value,K},{})},null,2);return q.push({fileName:"css-variables.json",content:W+`
|
|
488
|
+
`}),q}function i(X,Z){let Y=NX(X);if(!fY(Y))Y2(Y,{recursive:!0});X2(X,Z,"utf-8")}function M(X,Z){if(Z!==!1)console.log(X)}async function vY(X,Z){let Y=typeof globalThis.Bun<"u",q=X,$=null;if(X.endsWith(".ts")&&!Y){let{compileConfigFile:A,getDistConfigFile:L}=await Promise.resolve().then(() => (JX(),JZ)),H=NX(X);await A(H),q=L(H),$=q}let W=(await import(q)).default,K=NX(X),z=(A)=>{if(A.startsWith("../"))return P(K,A);return P(K,W.$paths.baseDir,A)},G=P(K,W.$paths.baseDir,W.$paths.tokensDir),E=Z||z(W.$paths.distDir);try{return await W0({config:W,tokensDir:G,outputDir:E,verbose:!0})}finally{if($){let{existsSync:A,unlinkSync:L}=await import("fs");if(A($))try{L($)}catch(H){}}}}var hY=b(()=>{aZ();pX();Y0();NY();CY();JY();bX()});function H2(X,Z,Y){let q=S(X,{isIncludedOriginalValue:!0}),$=g(X,Y);if(!$||!c(X,"mode",{isIncludedOriginalValue:!1}))$=q;return DX(X,$,Z,Y)}function CX(X,Z,Y){let q=H2(X,Z,Y),$=typeof q==="string"?qX(q):null;if($&&($?.length??0)>=1)return ZX(q,$,Z,Y);else return _2(X,Z,Y)}function _2(X,Z,Y){return DX(X,iX(X,Z,Y),Z,Y)}function DX(X,Z,Y,q){if(!X)return null;if(X.$type==="color")Z=jX(Z,X,Y,q);else if(X.$type==="composition"||X.$type==="typography")Z=YX(X,Y,q);return Z}var RX="did";var y=b(()=>{AX();bX();tX();AX();JX();BZ();IZ();wZ();bX();tX();JY();NY();pX();CY();hY()});import{existsSync as Q2}from"fs";import{resolve as O2,join as G0}from"path";import J2 from"chokidar";import{execSync as B0}from"child_process";import{existsSync as FX,statSync as pY}from"fs";import{resolve as dY}from"path";async function uY(X,Z=!1){let Y=process.cwd(),q=X||dY(Y,"designid.config.ts"),$=dY(Y,"designid.config.mjs");if(!FX(q))return!1;if(!(!FX($)||FX(q)&&FX($)&&pY(q).mtimeMs>pY($).mtimeMs)){if(Z)console.log("✓ Config file is up to date");return!1}if(Z)console.log("\uD83D\uDD04 Compiling config file...");try{if(B0(`bun build ${q} --outfile ${$} --minify --target node --packages external --no-bundle`,{stdio:Z?"inherit":"pipe"}),Z)console.log(`✅ Config compiled successfully
|
|
489
|
+
`);return!0}catch(W){if(console.error("❌ Failed to compile config file"),W instanceof Error)console.error(W.message);throw W}}y();hY();if(process.argv.includes("--help")||process.argv.includes("-h"))console.log(`
|
|
474
490
|
Watch Tokens - File watcher for design token changes
|
|
475
491
|
|
|
476
492
|
Usage:
|
|
@@ -485,12 +501,12 @@ Example:
|
|
|
485
501
|
bun src/scripts/watch-tokens.ts
|
|
486
502
|
bun src/scripts/watch-tokens.ts --config=./custom-config.ts
|
|
487
503
|
bun src/scripts/watch-tokens.ts --dev
|
|
488
|
-
`),process.exit(0);async function
|
|
489
|
-
`);let
|
|
504
|
+
`),process.exit(0);async function B2(){let X=await t(),{distDir:Z,buildDir:Y}=await p(),q=[/node_modules/,/dist/,/build/,G0(X,Z),G0(X,Y)],$=J2.watch(["**/*.tokens.json","designid.config.ts"],{ignored:q,persistent:!0}),U,W=300,K=!1;function z(A){let L=[A,"./designid.config.ts","./designid.config.mjs","./designid.config.js","./tokens.config.ts","./tokens.config.js"].filter(Boolean);for(let H of L){let _=O2(H);if(Q2(_))return _}throw Error(`Config file not found. Tried: ${L.join(", ")}`)}let G=async()=>{if(K){console.log(`[${new Date().toLocaleTimeString()}] Build already in progress, skipping...`);return}clearTimeout(U),U=setTimeout(async()=>{K=!0,console.clear(),process.stdout.write("\x1Bc"),console.log(`[${new Date().toLocaleTimeString()}] Changes detected. Re-building tokens...
|
|
505
|
+
`);let A=(()=>{let L=process.argv.find((H)=>H.startsWith("--config="));return L?L.split("=")[1]:void 0})();try{await uY(A,!1);let L=z(A);console.log(`Using config: ${L}`);let H=await vY(L);if(H.errors.length>0){console.log(`
|
|
490
506
|
❌ Build failed with ${H.errors.length} error${H.errors.length>1?"s":""}:`),H.errors.forEach((_)=>console.log(` - ${_}`)),K=!1;return}if(console.log(`
|
|
491
507
|
✅ Build completed successfully!`),console.log(`Processed ${H.tokenCount} tokens in ${H.duration}ms`),H.cssFiles.length>0)console.log(`Generated ${H.cssFiles.length} CSS files`);if(H.typescriptFiles.length>0)console.log(`Generated ${H.typescriptFiles.length} TypeScript files`);if(H.warnings.length>0)console.log(`
|
|
492
508
|
Warnings:`),H.warnings.forEach((_)=>console.log(` - ${_}`));console.log(`
|
|
493
509
|
Completed at ${new Date().toLocaleTimeString()}
|
|
494
510
|
`)}catch(L){console.error(`
|
|
495
|
-
❌ Build failed:`,L)}finally{K=!1}},300)}
|
|
496
|
-
`)}).on("change",(
|
|
511
|
+
❌ Build failed:`,L)}finally{K=!1}},300)};$.on("ready",()=>{console.log("Watching for changes in .tokens.json files and designid.config.ts..."),console.log(`Working directory: ${process.cwd()}`),console.log(`Press Ctrl+C to stop watching
|
|
512
|
+
`)}).on("change",(A)=>{console.log(`Changed: ${A}`),G().catch((L)=>{console.error("Error during token build:",L)})}).on("add",(A)=>{console.log(`Added: ${A}`),G().catch((L)=>{console.error("Error during token build:",L)})}).on("unlink",(A)=>{console.log(`Deleted: ${A}`),G().catch((L)=>{console.error("Error during token build:",L)})}).on("error",(A)=>{console.error(`Watcher error: ${A}`)});let E=()=>{clearTimeout(U),$.close().then(()=>{console.log("File watcher closed successfully"),process.exit(0)}).catch((A)=>{console.error("Error closing file watcher:",A),process.exit(1)})};process.on("SIGINT",E),process.on("SIGTERM",E),process.on("SIGHUP",E),process.on("uncaughtException",(A)=>{console.error("Uncaught Exception:",A),E()}),process.on("unhandledRejection",(A,L)=>{console.error("Unhandled Rejection at:",L,"reason:",A),E()})}var I2=process.argv[1]?.includes("tokens-watch")||process.argv[1]?.endsWith("watch.js")||import.meta.url===`file://${process.argv[1]}`;if(I2)B2().catch((X)=>{console.error("Error starting watch process:",X),process.exit(1)});export{B2 as runWatch};
|