@designid/tokens 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/build.js +77 -63
- package/bin/watch.js +3 -3
- package/package.json +1 -1
package/bin/build.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var G2=Object.defineProperty;var q0=($,X)=>{for(var Y in X)G2($,Y,{get:X[Y],enumerable:!0,configurable:!0,set:(Z)=>X[Y]=()=>Z})};var N=($,X)=>()=>($&&(X=$($=0)),X);var G0={};q0(G0,{transformColorValueAsync:()=>A2,transformColorValue:()=>P,transformColorToken:()=>E$,setAlpha:()=>X$,isColor:()=>h,initializeColorspace:()=>z2});import L$ from"colorjs.io";async function U0(){if(Y$===null){let{colorspace:$}=await u();Y$=$||"hex"}return Y$}function H2(){return Y$||"hex"}async function z2(){await U0()}function X$($,X){let Y=new L$($);if(X||X===0)Y.alpha=X/100;return P(Y)}function K0($,X){if(!$)return $;if(X&&X.type!=="color")return $;if(typeof $==="string")$=new L$($);if(typeof $?.to!=="function")return $;let Y=H2();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 A2($,X){return await U0(),K0($,X)}function P($,X){return K0($,X)}function E$($,X,Y,Z){try{if($=y(X,Z),X.$type==="color"&&X.original?.$value&&X.original?.$value!==X.$value){if(f(X.original.$value))$=d(X.original.$value,Y,Z,X);else $=C(X);if(!k(Z)&&X.original?.$extensions?.mode?.[Z])$=X.original.$extensions.mode[Z]}if(f($))$=d($,Y,Z,X);return P($)}catch{return $=y(X,Z),P($)}}function h($){try{if($)return new L$($),!0;return!1}catch{return!1}}var Y$=null;var i=N(()=>{j()});var _$=N(()=>{j()});function C($,X){let{isIncludedOriginalValue:Y=!1,fallbackValue:Z=null}=X??{};if(Y)return $?.original?.$value??$?.$value??$.value??Z;return $?.$value??$?.value??Z}function y($,X){return X&&($?.$extensions?.mode?.[X]||typeof $?.$extensions?.mode?.[X]==="number")?$.$extensions.mode[X]:C($,{fallbackValue:$?.original?.$value??$?.$value??$?.value})??null}function H0($,X){return X.allTokens.find((Y)=>Y.path.join(".")===$)??null}function d($,X,Y,Z){let W=f($),q=null,U=$??C(Z),K=null;if(W){if(q=H0(W,X),Y&&q&&q?.$extensions?.mode?.[Y]!==q.original?.$extensions?.mode?.[Y])U=q.original?.$extensions?.mode?.[Y],K=q.original?.$extensions?.alpha??K;else if(q?.$extensions?.mode?.[Y])U=q.$extensions.mode[Y],K=q.$extensions?.alpha??K;else if(q?.original?.$value)U=q?.original.$value??q?.$value,K=q?.original.$extensions?.alpha??K}if(U!==$&&f(U))U=d(U,X,Y,Z);if(U&&(K||Z?.$extensions?.alpha||K===0||Z?.original?.$extensions?.alpha===0))K=K??Z?.$extensions?.alpha??null,U=X$(U,K);return U=P(U,q??Z),U??$}function f($){if(typeof $!=="string")return null;let X=/{[^}]+}/g,Y=$.match(X);if(Y?.length!==1)return null;return Y[0].slice(1,-1)}var I$=N(()=>{j()});import{spawnSync as E2}from"child_process";import{existsSync as c,mkdirSync as _2,readFileSync as w2,unlinkSync as O2,writeFileSync as B1}from"fs";import{resolve as E1,join as S,basename as _1,normalize as w1,relative as O1,sep as Q1,dirname as Q2}from"path";async function I2(){return`${(await S$()).$metaData?.tokenNamespace||"tokens"}.icons`}async function J2($){let Y=S($,"designid.config.ts");if(c(S($,"designid.config.js")))O2(S($,"designid.config.js"));if(c(Y)){let Z=E2("bun",["build",Y,"--outfile ./designid.config.js","--minify","--target","node","--packages","external","--no-bundle"],{stdio:"inherit",cwd:$,shell:!0});if(Z.status!==0)console.error("Failed to compile designid.config.js with bun."),process.exit(Z.status??1);if(Z.status===0)return new Promise((W)=>W(!0))}}async function a($="json"){let{tokenNamespace:X}=await u();return`${X}-design-system.tokens.svg${$==="d.ts"||$==="js"?".config":""}.${$}`}function z0($){if(!c($))_2($,{recursive:!0})}async function j$($,X=!1){let Y=W$(),Z;if(Y.endsWith(".json"))Z=JSON.parse(w2(Y,"utf8").trim()??"{}");else{$=$??Q2(Y)+"/";let W=B0($);if(W&&(X||!c(W)))await J2($);if(Z=await import(W),Z.default)Z=Z.default}return Z}async function Z$(){let{baseDir:$}=await s(),X=process.cwd(),Z=S(X,$),{buildDir:W,distDir:q}=await s();try{z0(S(Z,W)),z0(S(Z,q))}catch(U){console.error("Error creating directories:",U)}return Z}function B0($){return $?S($,"designid.config.js"):S(process.cwd(),"designid.config.js")}function W$(){let $=process.argv.find((K)=>K.startsWith("--config=")),[,X]=$?.split("=")??[];if(X)return X;let Y=process.cwd(),Z=B0(Y),W=S(Y,"designid.config.ts"),q=c(Z),U=c(W);if(q)return Z;else if(U)return W;throw console.error("Config file not found"),Error("Config file not found")}async function s($=!1){let X=W$(),Z=(await j$(process.cwd(),$)).$paths;if(!Z)throw console.error("Project paths not found"),Error("Project paths not found");return{configFile:X,...Z}}async function u(){let X=(await j$(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 I2();return{...X,icons:X.icons??{objectPath:Y},dsNamespace:X.dsNamespace}}async function S$(){if(!R$){let $=W$();R$=await j$(process.cwd()),L0=$}return R$}async function D$(){if(!M$){let X=(await S$()).$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`;M$={...X,icons:X.icons??{objectPath:Z},dsNamespace:X.dsNamespace}}return M$}async function E0($=!1){if(!N$){let Y=(await S$()).$paths;if(!Y)throw console.error("Project paths not found"),Error("Project paths not found");N$={configFile:L0,...Y}}return N$}async function v(){if(!F$){let{distDir:$,assets:X,buildDir:Y}=await E0(!0),{fontNamespace:Z,tokenNamespace:W,icons:q}=await D$(),U=await Z$(),K=process.cwd(),G=S(K,$,"css");F$={distDir:$,assets:X,fontNamespace:Z,__dirname:U,workspaceRoot:K,distCSSPath:G,buildDir:Y,tokenNamespace:W,icons:q}}return F$}async function b$(){if(!x$){let{icons:$}=await D$();x$=$}return x$}var R$=null,L0=null,M$=null,N$=null,F$=null,x$=null;var q$=N(()=>{j()});function k($){return $===C$}var C$="light";var _0=N(()=>{q$()});async function V$($){let X=await b$();$=$.replace(/<\?xml[^>]*\?>\s*/,""),$=$.replace(/<!DOCTYPE [^>]*>\s*/,"");let Y=$.match(/<svg[^>]*>/),Z=$.match(/viewBox="([\d\s.]+)"/),[W]=Y??[],q=W;if(W&&q){let K=X?.style?.fill,G=/id="[^"]*"/.test(W);if(!q.includes("xmlns="))q=q.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"');if(!G&&K)q=q.replace("<svg",`<svg id="${K}"`);else if(G&&K)q=q.replace(/id="[^"]*"/,`id="${K}"`)}if(Z&&W&&q){let K=Z[1].split(" ").map(Number),G=K[2],H=K[3],z=X?.size??24,A=G/H*z;$=$.replace(/height="[\d.]+px?"/,`height="${z}px"`),$=$.replace(/width="[\d.]+px?"/,`width="${A}px"`);let B=/width="[\d.]+(px)?"/.test(W),E=/height="[\d.]+(px)?"/.test(W);if(!B)q=q.replace("<svg",`<svg width="${A}px"`);else q=q.replace(/width="[\d.]+(px)?"/,`width="${A}px"`);if(!E)q=q.replace("<svg",`<svg height="${z}px"`);else q=q.replace(/height="[\d.]+(px)?"/,`height="${z}px"`);$=$.replace(W,q)}if(!$?.match(/data-style="([^"]*)"/)&&X?.style?.type)$=$.replace("<svg ",`<svg data-style="${X.style.type}" `);return $}var w0=N(()=>{j()});var J0=N(()=>{q$();j()});import{copyFileSync as F2,existsSync as x2,mkdirSync as R0,statSync as P2}from"fs";import{writeFile as j2}from"fs/promises";import{join as x,relative as S2}from"path";async function g$($,X){try{let{assets:Y,workspaceRoot:Z,distDir:W,__dirname:q}=await v(),U=Y?.fonts?.sourceDir?x(q,Y.fonts.sourceDir):null,K=x("assets","fonts"),G=x(Z,W),H=Y?.fonts?.distDir?x(G,Y.fonts.distDir.replace(/^\.\//,"")):x(G,K);if(!$||!U)return;let z="",A=X&&Y?.fonts?.distDir?x(X,Y.fonts.distDir.replace(/^\.\//,"")):H;for(let _ of $){if(!_)continue;if(z+=`/**** ${_.family} ${_.style} ****/
|
|
3
3
|
`,_.linkHref){let J=await(await fetch(_.linkHref)).text();z+=`${J.replace(/\s+/g," ").replace(/:\s+/g,":")}
|
|
4
|
-
`}else if(_?.src&&U){let
|
|
4
|
+
`}else if(_?.src&&U){let w=_.directory??_.family.toLowerCase().replace(/\s+/g,"-"),J=x(U,w,_.src);try{if(!x2(J)||!P2(J).isFile()){console.warn(`Font file not found: ${J}`);continue}}catch{console.warn(`Error accessing font file: ${J}`);continue}try{R0(x(A,w),{recursive:!0}),F2(x(U,w,_.src),x(A,w,_.src))}catch(Q){console.warn(`Error copying font file ${_.src}:`,Q instanceof Error?Q.message:Q);continue}let O;if(Y?.fonts?.cssImportPath)O=x(Y.fonts.cssImportPath,w,_.src).replace(/\\/g,"/");else{let{distCSSPath:Q}=await v(),I=X?x(X,"css"):Q,F=S2(I,A);O=x(F,w,_.src).replace(/\\/g,"/")}z+=`@font-face {
|
|
5
5
|
font-family: "${_.family}";
|
|
6
6
|
font-style: ${_.faceStyle};
|
|
7
7
|
font-weight: ${_.weight};
|
|
8
|
-
src: url("${
|
|
8
|
+
src: url("${O}") format("${_.format}");
|
|
9
9
|
}
|
|
10
|
-
`}}let{distCSSPath:B}=await
|
|
10
|
+
`}}let{distCSSPath:B}=await v(),E=X?x(X,"css"):B,L=`${E}/fonts.css`;R0(E,{recursive:!0}),await j2(L,z,{flag:"w",encoding:"utf-8"})}catch(Y){console.error("Error appending typography tokens:",Y)}}var T$=N(()=>{j()});function n($){if(typeof $!=="string"||!$.startsWith("{")||!$.endsWith("}"))return!1;let X=$.slice(1,-1);return!X.includes("{")&&!X.includes("}")&&X.trim()!==""}function o($){if(typeof $!=="string")return!1;let X=/\{[^}]+\}/g,Y=$.match(X);return!!(Y&&Y.length>0&&$.length>Y.join("").length)}function U$($){let X=[],Y=/\{[^}]+\}/g,Z=0,W;while((W=Y.exec($))!==null){if(W.index>Z){let U=$.slice(Z,W.index);if(U)X.push({type:"literal",value:U})}let q=W[0];if(q.startsWith("{#/"))X.push({type:"reference",value:q,ref:{$ref:q.slice(2,-1)}});else X.push({type:"reference",value:q,ref:q});Z=W.index+W[0].length}if(Z<$.length){let q=$.slice(Z);if(q)X.push({type:"literal",value:q})}return X}function M0($){return!!$.$extensions?.$mode}function N0($){return!!($.$extensions?.$generators&&Array.isArray($.$extensions.$generators))}function F0($){return!!($.$extensions?.$breakpoints&&typeof $.$extensions.$breakpoints==="object")}function x0($,X){return`${$}${X}`}function P0($){return typeof $==="object"&&$!==null&&"$value"in $}function j0($){return typeof $==="object"&&$!==null&&!("$value"in $)}var S0=()=>{};function D0($){if(typeof $!=="string")return!1;let X=$.trim();return X.startsWith("<svg")&&X.includes("</svg>")}function b0($){if(typeof $!=="string")return!1;return $.startsWith("data:image/png;base64,")||$.startsWith("iVBORw0KGgo")}function C0($){if(typeof $!=="string")return!1;return $.startsWith("data:image/jpeg;base64,")||$.startsWith("data:image/jpg;base64,")||$.startsWith("/9j/")}function b2($){let X=$.trim();return X=X.replace(/\s+/g," ").replace(/>\s+</g,"><").trim(),`data:image/svg+xml;base64,${Buffer.from(X,"utf-8").toString("base64")}`}function C2($){if($.startsWith("data:image/png;base64,"))return $;return`data:image/png;base64,${$}`}function V2($){if($.startsWith("data:image/jpeg;base64,")||$.startsWith("data:image/jpg;base64,"))return $;return`data:image/jpeg;base64,${$}`}function y$($){if(!$||typeof $!=="string")return $;if($.startsWith("data:"))return $;if(D0($))return b2($);else if(b0($))return C2($);else if(C0($))return V2($);return $}function g2($){if(typeof $!=="string")return!1;return $.startsWith("data:image/svg+xml;")||$.startsWith("data:image/png;")||$.startsWith("data:image/jpeg;")||$.startsWith("data:image/jpg;")||$.startsWith("data:image/gif;")||$.startsWith("data:image/webp;")}function p($){return D0($)||b0($)||C0($)||g2($)}import{readFileSync as T2,readdirSync as y2,statSync as f2}from"fs";import{join as h2}from"path";import g0 from"colorjs.io";function f$($){let X={};function Y(Z){let W=y2(Z);for(let q of W){let U=h2(Z,q);if(f2(U).isDirectory())Y(U);else if(q.endsWith(".tokens.json"))try{let G=T2(U,"utf-8");if(!G.trim())continue;let H=JSON.parse(G);T0(X,H)}catch(G){console.warn(`Failed to load token file: ${U}`,G)}}}return Y($),X}function T0($,X){for(let Y in X)if(X[Y]&&typeof X[Y]==="object"&&!Array.isArray(X[Y])){if(!$[Y])$[Y]={};T0($[Y],X[Y])}else $[Y]=X[Y]}function h$($,X={}){let Y=[];function Z(W,q=[]){for(let[U,K]of Object.entries(W)){if(U.startsWith("$"))continue;let G=[...q,U],H=G.join(".");if(P0(K)){let z={path:G,name:H,type:K.$type,value:K.$value,description:K.$description,extensions:K.$extensions?{mode:M0(K)?K.$extensions.$mode:K.$extensions.mode?K.$extensions.mode:void 0,generators:N0(K)?K.$extensions.$generators:K.$extensions.generators?K.$extensions.generators:void 0,breakpoints:F0(K)?K.$extensions.$breakpoints:K.$extensions.breakpoint?K.$extensions.breakpoint:void 0,...Object.fromEntries(Object.entries(K.$extensions).filter(([A])=>!["$mode","$generators","$breakpoints","mode","generators","breakpoint"].includes(A)))}:void 0,original:K};if(!X.namespace||H.startsWith(X.namespace))Y.push(z)}else if(j0(K))Z(K,G)}}return Z($),Y}function v$($,X={}){let Y=[...$],Z=new Map($.map((K)=>[K.name,K]));if(X.generateModes||X.generateDerivedTokens||X.generateBreakpointTokens)for(let K of $){let G=V0(K,X,Z);if(Y.push(...G),X.generateModes){for(let H of G)if(H.extensions?.mode&&!H.name.match(/@(dark|light)$/)){let z=V0(H,X,Z);Y.push(...z)}}}let W={tokens:new Map(Y.map((K)=>[K.name,K])),mode:X.generateModes?"light":void 0,options:X,brokenReferences:[]},q=[];for(let K of Y){let G=K.name.endsWith("@dark")?"dark":K.name.endsWith("@light")?"light":X.generateModes?"light":void 0,H={...W,mode:G},z=v2(K,H);q.push(z)}if(X.failOnBrokenReferences!==!1&&W.brokenReferences.length>0){let K=[...new Set(W.brokenReferences)],G=`Token reference${K.length>1?"s":""} not found:
|
|
11
11
|
${K.map((H)=>` - ${H}`).join(`
|
|
12
|
-
`)}`;throw Error(G)}return q}function R0($,X,Y){let Z=[];if(X.generateModes&&$.extensions?.mode){for(let[W,q]of Object.entries($.extensions.mode))if(q!==void 0)Z.push({...$,name:`${$.name}@${W}`,value:q,path:[...$.path,`@${W}`]})}if(X.generateModes&&!$.extensions?.mode&&(Array.isArray($.value)||typeof $.value==="object"&&$.value!==null)){let W=!1,q=!1,U=(K)=>{if(typeof K!=="object"||K===null)return!1;if(K.$extensions?.mode)return!0;return Object.values(K).some((G)=>{if(typeof G==="object"&&G!==null)return U(G);return!1})};if(Array.isArray($.value))W=$.value.some((K)=>typeof K==="string"&&K.includes("{")||typeof K==="object"&&K!==null&&Object.values(K).some((G)=>typeof G==="string"&&G.includes("{"))),q=$.value.some((K)=>U(K));else W=Object.values($.value).some((K)=>typeof K==="string"&&K.includes("{")),q=U($.value);if(W||q){if(["color","shadow","border","background","surface","composition"].includes($.type)){let H;if(Array.isArray($.value))H=$.value.map((z)=>{if(typeof z==="string"&&z.startsWith("{")&&z.endsWith("}")){let A=z.slice(1,-1);if(!A.includes("@dark"))return`{${A}@dark}`;return z}else if(typeof z==="object"&&z!==null){let A={};for(let[B,E]of Object.entries(z))if(typeof E==="string"&&E.startsWith("{")&&E.endsWith("}")){let L=E.slice(1,-1),_=`${L}@dark`,O=Y?.get(L),J=Y?.has(_)||O?.extensions?.mode?.dark!==void 0||O&&(Array.isArray(O.value)||typeof O.value==="object"&&O.value!==null);if(!L.includes("@dark")&&J)A[B]=`{${_}}`;else A[B]=E}else A[B]=E;return A}return z});else if(typeof $.value==="object"&&$.value!==null){H={};let z=(A)=>{if(typeof A==="string"){if(A.startsWith("{")&&A.endsWith("}")){let B=A.slice(1,-1),E=`${B}@dark`,L=(O,J=new Set)=>{if(J.has(O))return!1;J.add(O);let w=Y?.get(O);if(!w){let Q=O.match(/^(.+)@([^@]+)$/);if(Q){let[,I,F]=Q,g=Y?.get(I);if(g){if(g.extensions?.mode?.dark!==void 0)return!0;if(g.extensions?.generators)return!0;return L(I,J)}}return!1}if(w.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${O}@dark`))return!0;if(typeof w.value==="string"&&w.value.startsWith("{")&&w.value.endsWith("}")){let Q=w.value.slice(1,-1);return L(Q,J)}if(Array.isArray(w.value)||typeof w.value==="object"&&w.value!==null){let Q=(I)=>{if(typeof I!=="object"||I===null)return!1;if(I.$extensions?.mode)return!0;return Object.values(I).some((F)=>{if(typeof F==="object"&&F!==null)return Q(F);return!1})};if(Array.isArray(w.value))return w.value.some((I)=>typeof I==="string"&&I.includes("{")&&L(I.slice(1,-1),new Set(J))||typeof I==="object"&&I!==null&&(Object.values(I).some((F)=>typeof F==="string"&&F.includes("{")&&L(F.slice(1,-1),new Set(J)))||Q(I)));else if(typeof w.value==="object")return Object.values(w.value).some((I)=>typeof I==="string"&&I.includes("{")&&L(I.slice(1,-1),new Set(J)))||Q(w.value)}return!1},_=L(B);if(!B.includes("@dark")&&_)return`{${E}}`}return A}if(typeof A==="object"&&A!==null){if(A.$extensions?.mode?.dark)return A.$extensions.mode.dark;let B={};for(let[E,L]of Object.entries(A))B[E]=z(L);return B}return A};for(let[A,B]of Object.entries($.value))H[A]=z(B)}Z.push({...$,name:`${$.name}@dark`,value:H,path:[...$.path,"@dark"],extensions:{...$.extensions,autoGenerated:!0}})}}}if(X.generateModes&&!$.extensions?.mode&&typeof $.value==="string"&&$.value.startsWith("{")&&$.value.endsWith("}")){let W=$.value.slice(1,-1),q=(z,A=new Set)=>{if(A.has(z))return!1;A.add(z);let B=Y?.get(z);if(!B){let E=z.match(/^(.+)@([^@]+)$/);if(E){let[,L,_]=E,O=Y?.get(L);if(O){if(O.extensions?.mode?.dark!==void 0)return!0;if(O.extensions?.generators)return!0;return q(L,A)}}return!1}if(B.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${z}@dark`))return!0;if(typeof B.value==="string"&&B.value.startsWith("{")&&B.value.endsWith("}")){let E=B.value.slice(1,-1);return q(E,A)}if(Array.isArray(B.value)||typeof B.value==="object"&&B.value!==null){let E=(L)=>{if(typeof L!=="object"||L===null)return!1;if(L.$extensions?.mode)return!0;return Object.values(L).some((_)=>{if(typeof _==="object"&&_!==null)return E(_);return!1})};if(Array.isArray(B.value))return B.value.some((L)=>typeof L==="string"&&L.includes("{")&&q(L.slice(1,-1),new Set(A))||typeof L==="object"&&L!==null&&(Object.values(L).some((_)=>typeof _==="string"&&_.includes("{")&&q(_.slice(1,-1),new Set(A)))||E(L)));else if(typeof B.value==="object")return Object.values(B.value).some((L)=>typeof L==="string"&&L.includes("{")&&q(L.slice(1,-1),new Set(A)))||E(B.value)}return!1},U=q(W);if(["color","shadow","border","background","surface","composition"].includes($.type)&&U&&U&&!W.includes("@dark")){let z=`{${W}@dark}`;Z.push({...$,name:`${$.name}@dark`,value:z,path:[...$.path,"@dark"],extensions:{...$.extensions,autoGenerated:!0}})}}if(X.generateDerivedTokens&&$.extensions?.generators)for(let W of $.extensions.generators)for(let[q,U]of Object.entries(W.value)){let K=E0($.name,q),{...G}=$.extensions;Z.push({...$,name:K,value:$.value,path:[...$.path,q],extensions:{...G,generator:{type:W.type,value:U}}})}if(X.generateBreakpointTokens&&$.extensions?.breakpoints)for(let[W,q]of Object.entries($.extensions.breakpoints)){let U=`${$.name}@${W.replace(/[^a-zA-Z0-9]/g,"_")}`,K=q.$value||q.value;if(K&&typeof K==="object"&&"$value"in K)K=K.$value;else if(!K&&typeof q==="object"){let{...z}=q;if(Object.keys(z).length>0)K=z}let G=q.$extensions||q.$extensions,H=q.$type;if(!H&&q.value&&typeof q.value==="object")H=q.value.$type;Z.push({...$,name:U,value:K,path:[...$.path,`@${W}`],type:H||$.type,extensions:{mediaQuery:W,...G?{mode:G.mode||G.$mode,generators:G.generators||G.$generators,...Object.fromEntries(Object.entries(G).filter(([z])=>!["mode","$mode","generators","$generators"].includes(z)))}:{}}})}return Z}function j2($,X){let Y=l($.value,X),Z=$.type;if(typeof $.value==="string"&&k($.value)){let q=$.value.slice(1,-1),U=X.tokens.get(q);if(U){if(["border","shadow","typography","composition"].includes(U.type))Z=U.type;else if(typeof U.value==="string"&&c(U.value)){let K=X$(U.value),G=new Set;for(let H of K)if(H.type==="reference"&&H.ref&&typeof H.ref==="string"){let z=H.ref.slice(1,-1),A=X.tokens.get(z);if(A&&["border","shadow","typography","composition"].includes(A.type))G.add(A.type)}if(G.size===1)Z=Array.from(G)[0]}}}if(typeof $.value==="string"&&c($.value)){let q=X$($.value),U=new Set;for(let K of q)if(K.type==="reference"&&K.ref&&typeof K.ref==="string"){let G=K.ref.slice(1,-1),H=X.tokens.get(G);if(H&&["border","shadow","typography","composition"].includes(H.type))U.add(H.type)}if(U.size===1)Z=Array.from(U)[0]}if(typeof Y==="object"&&Y!==null&&["border","shadow","typography","composition"].includes(Z))Y=b(Y,X);if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=P0($.value,$.extensions.generator.type,$.extensions.generator.value,X);let W=S2($.name,X.options);if(Z==="color"&&typeof Y==="string"&&h(Y))Y=C(Y,$);if(typeof Y==="string"&&y(Y))Y=S$(Y);return{...$,type:Z,value:Y,cssVar:W}}function b($,X){if(typeof $==="string"){if(k($))return V$($,X);else if(c($))return x0($,X)}if(Array.isArray($))return $.map((Y)=>b(Y,X));if(typeof $==="object"&&$!==null){if("$value"in $&&typeof $.$value==="string")return b($.$value,X);if("value"in $&&typeof $.value==="string"&&"$type"in $){if(X.mode&&$.$extensions?.mode?.[X.mode])return b($.$extensions.mode[X.mode],X);return b($.value,X)}if("value"in $&&typeof $.value==="object"&&"$type"in $){let Z=$.value,W=$.$extensions?.delimiter?.character||" ";if($.$type==="composition"&&Z&&typeof Z==="object")return Object.values(Z).map((U)=>b(U,X)).join(W);return b($.value,X)}let Y={};for(let[Z,W]of Object.entries($))Y[Z]=b(W,X);return Y}return $}function l($,X){if(typeof $==="string"){if(c($))return x0($,X);else if(k($))return V$($,X)}else if(typeof $==="object"&&$!==null&&"$ref"in $)return F0($,X);return $}function V$($,X){let Y=$.slice(1,-1),Z=X.tokens.get(Y);if(!Z)return console.warn(`Token reference not found: ${$}`),X.brokenReferences.push($),$;let W;if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)W=P0(Z.value,Z.extensions.generator.type,Z.extensions.generator.value,X);else if(X.mode&&Z.extensions?.mode?.[X.mode])W=l(Z.extensions.mode[X.mode],X);else W=l(Z.value,X);if(Z.type==="color"&&typeof W==="string"&&h(W))W=C(W,Z);if(typeof W==="string"&&y(W))W=S$(W);return W}function F0($,X){let Z=$.$ref.slice(2).replace(/\//g,"."),W=X.tokens.get(Z);if(!W)return console.warn(`JSON Pointer reference not found: ${$.$ref}`),X.brokenReferences.push($.$ref),$.$ref;return l(W.value,X)}function x0($,X){let Y=X$($),Z=Y.some((U)=>U.value.includes(",")),W=!0,q=[];for(let U of Y){let K;if(U.type==="reference"&&U.ref){if(typeof U.ref==="string"&&k(U.ref)){K=V$(U.ref,X);let G=U.ref.slice(1,-1),H=X.tokens.get(G);if(!H||!["border","shadow","typography","composition"].includes(H.type))W=!1}else if(typeof U.ref==="object"&&"$ref"in U.ref)K=F0(U.ref,X)}else if(K=U.value,U.value.trim()&&U.value.trim()!==",")W=!1;q.push(K)}if(Z&&W)return q.filter((U)=>typeof U==="object"&&U!==null&&typeof U!=="string");return q.map((U)=>String(U)).join("")}function P0($,X,Y,Z){let W=l($,Z);switch(X){case"alpha":if(typeof W==="string")return D2(W,Number(Y)/100);break;case"scale":if(typeof W==="string"&&W.match(/[\d.]+/))return C2(W,Number(Y));break;case"hue":if(typeof W==="string")return b2(W,Number(Y));break;default:return console.warn(`Unknown generator type: ${X}`),W}return W}function S2($,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(/-@/g,"-").replace(/@/g,"-"),Z=Z.replace(/-(?:dark|light)$/,"");let W=Z,q=!0,U=X.prefix||"";if(X.transformName){if(W=X.transformName(Z),W=W.replace(/-+$/,""),W!==Z)q=!1}let K=q&&U?`${U}-${W}`:W,G=Y?`-${Y}`:"";return`--${K}${G}`.replace(/[^a-zA-Z0-9-_]/g,"-")}function D2($,X){try{if(!h($))return $;let Y=new M0($);return Y.alpha=X,C(Y)}catch(Y){return console.warn(`Failed to apply alpha to color "${$}": ${Y}`),$}}function C2($,X){let Y=$.match(/([\d.]+)(\w+)/);if(Y){let[,Z,W]=Y;return`${parseFloat(Z)*X}${W}`}return $}function b2($,X){try{if(!h($))return $;let Z=new M0($).to("oklch");return Z.h=(Z.h+X)%360,C(Z)}catch(Y){return console.warn(`Failed to shift hue for color "${$}": ${Y}`),$}}var g$=N(()=>{w0();s()});function T$($){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 Z$($,X={}){let{rootSelector:Y=":root",separateThemeFiles:Z=!1,generateMediaQueries:W=!1,customHeader:q}=X;if(Z)return g2($,X);let U=new Map,K=new Map;U.set("light",[]),U.set("dark",[]);for(let E of $){if(typeof E.value==="string"&&y(E.value))continue;if(T$(E))continue;let L=` ${E.cssVar}: ${S(E.value,E.type)};`;if(W&&E.name.includes("@media")){let O=q$(E);if(O){if(!K.has(O))K.set(O,[]);K.get(O).push(L);continue}}let _=E.name.match(/@(dark|light)$/);if(_){let O=_[1];U.get(O).push(L)}else U.get("light").push(L)}let G="";if(q)G+=`${q}
|
|
12
|
+
`)}`;throw Error(G)}return q}function V0($,X,Y){let Z=[];if(X.generateModes&&$.extensions?.mode){for(let[W,q]of Object.entries($.extensions.mode))if(q!==void 0)Z.push({...$,name:`${$.name}@${W}`,value:q,path:[...$.path,`@${W}`]})}if(X.generateModes&&!$.extensions?.mode&&(Array.isArray($.value)||typeof $.value==="object"&&$.value!==null)){let W=!1,q=!1,U=(K)=>{if(typeof K!=="object"||K===null)return!1;if(K.$extensions?.mode)return!0;return Object.values(K).some((G)=>{if(typeof G==="object"&&G!==null)return U(G);return!1})};if(Array.isArray($.value))W=$.value.some((K)=>typeof K==="string"&&K.includes("{")||typeof K==="object"&&K!==null&&Object.values(K).some((G)=>typeof G==="string"&&G.includes("{"))),q=$.value.some((K)=>U(K));else W=Object.values($.value).some((K)=>typeof K==="string"&&K.includes("{")),q=U($.value);if(W||q){if(["color","shadow","border","background","surface","composition"].includes($.type)){let H;if(Array.isArray($.value))H=$.value.map((z)=>{if(typeof z==="string"&&z.startsWith("{")&&z.endsWith("}")){let A=z.slice(1,-1);if(!A.includes("@dark"))return`{${A}@dark}`;return z}else if(typeof z==="object"&&z!==null){let A={};for(let[B,E]of Object.entries(z))if(typeof E==="string"&&E.startsWith("{")&&E.endsWith("}")){let L=E.slice(1,-1),_=`${L}@dark`,w=Y?.get(L),J=Y?.has(_)||w?.extensions?.mode?.dark!==void 0||w&&(Array.isArray(w.value)||typeof w.value==="object"&&w.value!==null);if(!L.includes("@dark")&&J)A[B]=`{${_}}`;else A[B]=E}else A[B]=E;return A}return z});else if(typeof $.value==="object"&&$.value!==null){H={};let z=(A)=>{if(typeof A==="string"){if(A.startsWith("{")&&A.endsWith("}")){let B=A.slice(1,-1),E=`${B}@dark`,L=(w,J=new Set)=>{if(J.has(w))return!1;J.add(w);let O=Y?.get(w);if(!O){let Q=w.match(/^(.+)@([^@]+)$/);if(Q){let[,I,F]=Q,T=Y?.get(I);if(T){if(T.extensions?.mode?.dark!==void 0)return!0;if(T.extensions?.generators)return!0;return L(I,J)}}return!1}if(O.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${w}@dark`))return!0;if(typeof O.value==="string"&&O.value.startsWith("{")&&O.value.endsWith("}")){let Q=O.value.slice(1,-1);return L(Q,J)}if(Array.isArray(O.value)||typeof O.value==="object"&&O.value!==null){let Q=(I)=>{if(typeof I!=="object"||I===null)return!1;if(I.$extensions?.mode)return!0;return Object.values(I).some((F)=>{if(typeof F==="object"&&F!==null)return Q(F);return!1})};if(Array.isArray(O.value))return O.value.some((I)=>typeof I==="string"&&I.includes("{")&&L(I.slice(1,-1),new Set(J))||typeof I==="object"&&I!==null&&(Object.values(I).some((F)=>typeof F==="string"&&F.includes("{")&&L(F.slice(1,-1),new Set(J)))||Q(I)));else if(typeof O.value==="object")return Object.values(O.value).some((I)=>typeof I==="string"&&I.includes("{")&&L(I.slice(1,-1),new Set(J)))||Q(O.value)}return!1},_=L(B);if(!B.includes("@dark")&&_)return`{${E}}`}return A}if(typeof A==="object"&&A!==null){if(A.$extensions?.mode?.dark)return A.$extensions.mode.dark;let B={};for(let[E,L]of Object.entries(A))B[E]=z(L);return B}return A};for(let[A,B]of Object.entries($.value))H[A]=z(B)}Z.push({...$,name:`${$.name}@dark`,value:H,path:[...$.path,"@dark"],extensions:{...$.extensions,autoGenerated:!0}})}}}if(X.generateModes&&!$.extensions?.mode&&typeof $.value==="string"&&$.value.startsWith("{")&&$.value.endsWith("}")){let W=$.value.slice(1,-1),q=(z,A=new Set)=>{if(A.has(z))return!1;A.add(z);let B=Y?.get(z);if(!B){let E=z.match(/^(.+)@([^@]+)$/);if(E){let[,L,_]=E,w=Y?.get(L);if(w){if(w.extensions?.mode?.dark!==void 0)return!0;if(w.extensions?.generators)return!0;return q(L,A)}}return!1}if(B.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${z}@dark`))return!0;if(typeof B.value==="string"&&B.value.startsWith("{")&&B.value.endsWith("}")){let E=B.value.slice(1,-1);return q(E,A)}if(Array.isArray(B.value)||typeof B.value==="object"&&B.value!==null){let E=(L)=>{if(typeof L!=="object"||L===null)return!1;if(L.$extensions?.mode)return!0;return Object.values(L).some((_)=>{if(typeof _==="object"&&_!==null)return E(_);return!1})};if(Array.isArray(B.value))return B.value.some((L)=>typeof L==="string"&&L.includes("{")&&q(L.slice(1,-1),new Set(A))||typeof L==="object"&&L!==null&&(Object.values(L).some((_)=>typeof _==="string"&&_.includes("{")&&q(_.slice(1,-1),new Set(A)))||E(L)));else if(typeof B.value==="object")return Object.values(B.value).some((L)=>typeof L==="string"&&L.includes("{")&&q(L.slice(1,-1),new Set(A)))||E(B.value)}return!1},U=q(W);if(["color","shadow","border","background","surface","composition"].includes($.type)&&U&&U&&!W.includes("@dark")){let z=`{${W}@dark}`;Z.push({...$,name:`${$.name}@dark`,value:z,path:[...$.path,"@dark"],extensions:{...$.extensions,autoGenerated:!0}})}}if(X.generateDerivedTokens&&$.extensions?.generators)for(let W of $.extensions.generators)for(let[q,U]of Object.entries(W.value)){let K=x0($.name,q),{generators:G,...H}=$.extensions;Z.push({...$,name:K,value:$.value,path:[...$.path,q],extensions:{...H,generator:{type:W.type,value:U}}})}if(X.generateBreakpointTokens&&$.extensions?.breakpoints)for(let[W,q]of Object.entries($.extensions.breakpoints)){let U=`${$.name}@${W.replace(/[^a-zA-Z0-9]/g,"_")}`,K=q.$value||q.value;if(K&&typeof K==="object"&&"$value"in K)K=K.$value;else if(!K&&typeof q==="object"){let{...z}=q;if(Object.keys(z).length>0)K=z}let G=q.$extensions||q.$extensions,H=q.$type;if(!H&&q.value&&typeof q.value==="object")H=q.value.$type;Z.push({...$,name:U,value:K,path:[...$.path,`@${W}`],type:H||$.type,extensions:{mediaQuery:W,...G?{mode:G.mode||G.$mode,generators:G.generators||G.$generators,...Object.fromEntries(Object.entries(G).filter(([z])=>!["mode","$mode","generators","$generators"].includes(z)))}:{}}})}return Z}function v2($,X){let Y=t($.value,X),Z=$.type;if(typeof $.value==="string"&&n($.value)){let q=$.value.slice(1,-1),U=X.tokens.get(q);if(U){if(["border","shadow","typography","composition"].includes(U.type))Z=U.type;else if(typeof U.value==="string"&&o(U.value)){let K=U$(U.value),G=new Set;for(let H of K)if(H.type==="reference"&&H.ref&&typeof H.ref==="string"){let z=H.ref.slice(1,-1),A=X.tokens.get(z);if(A&&["border","shadow","typography","composition"].includes(A.type))G.add(A.type)}if(G.size===1)Z=Array.from(G)[0]}}}if(typeof $.value==="string"&&o($.value)){let q=U$($.value),U=new Set;for(let K of q)if(K.type==="reference"&&K.ref&&typeof K.ref==="string"){let G=K.ref.slice(1,-1),H=X.tokens.get(G);if(H&&["border","shadow","typography","composition"].includes(H.type))U.add(H.type)}if(U.size===1)Z=Array.from(U)[0]}if(typeof Y==="object"&&Y!==null&&["border","shadow","typography","composition"].includes(Z))Y=V(Y,X);if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=h0($.value,$.extensions.generator.type,$.extensions.generator.value,X);let W=p2($.name,X.options);if(Z==="color"&&typeof Y==="string"&&h(Y))Y=P(Y,$);if(typeof Y==="string"&&p(Y))Y=y$(Y);return{...$,type:Z,value:Y,cssVar:W}}function V($,X){if(typeof $==="string"){if(n($))return p$($,X);else if(o($))return f0($,X)}if(Array.isArray($))return $.map((Y)=>V(Y,X));if(typeof $==="object"&&$!==null){if("$value"in $&&typeof $.$value==="string")return V($.$value,X);if("value"in $&&typeof $.value==="string"&&"$type"in $){if(X.mode&&$.$extensions?.mode?.[X.mode])return V($.$extensions.mode[X.mode],X);return V($.value,X)}if("value"in $&&typeof $.value==="object"&&"$type"in $){let Z=$.value,W=$.$extensions?.delimiter?.character||" ";if($.$type==="composition"&&Z&&typeof Z==="object")return Object.values(Z).map((U)=>V(U,X)).join(W);return V($.value,X)}let Y={};for(let[Z,W]of Object.entries($))Y[Z]=V(W,X);return Y}return $}function t($,X){if(typeof $==="string"){if(o($))return f0($,X);else if(n($))return p$($,X)}else if(typeof $==="object"&&$!==null&&"$ref"in $)return y0($,X);return $}function p$($,X){let Y=$.slice(1,-1),Z=X.tokens.get(Y);if(!Z)return console.warn(`Token reference not found: ${$}`),X.brokenReferences.push($),$;let W;if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)W=h0(Z.value,Z.extensions.generator.type,Z.extensions.generator.value,X);else if(X.mode&&Z.extensions?.mode?.[X.mode])W=t(Z.extensions.mode[X.mode],X);else W=t(Z.value,X);if(Z.type==="color"&&typeof W==="string"&&h(W))W=P(W,Z);if(typeof W==="string"&&p(W))W=y$(W);return W}function y0($,X){let Z=$.$ref.slice(2).replace(/\//g,"."),W=X.tokens.get(Z);if(!W)return console.warn(`JSON Pointer reference not found: ${$.$ref}`),X.brokenReferences.push($.$ref),$.$ref;return t(W.value,X)}function f0($,X){let Y=U$($),Z=Y.some((U)=>U.value.includes(",")),W=!0,q=[];for(let U of Y){let K;if(U.type==="reference"&&U.ref){if(typeof U.ref==="string"&&n(U.ref)){K=p$(U.ref,X);let G=U.ref.slice(1,-1),H=X.tokens.get(G);if(!H||!["border","shadow","typography","composition"].includes(H.type))W=!1}else if(typeof U.ref==="object"&&"$ref"in U.ref)K=y0(U.ref,X)}else if(K=U.value,U.value.trim()&&U.value.trim()!==",")W=!1;q.push(K)}if(Z&&W)return q.filter((U)=>typeof U==="object"&&U!==null&&typeof U!=="string");return q.map((U)=>String(U)).join("")}function h0($,X,Y,Z){let W=t($,Z);switch(X){case"alpha":if(typeof W==="string")return m2(W,Number(Y)/100);break;case"scale":if(typeof W==="string"&&W.match(/[\d.]+/))return d2(W,Number(Y));break;case"hue":if(typeof W==="string")return u2(W,Number(Y));break;default:return console.warn(`Unknown generator type: ${X}`),W}return W}function p2($,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(/-@/g,"-").replace(/@/g,"-"),Z=Z.replace(/-(?:dark|light)$/,"");let W=Z,q=!0,U=X.prefix||"";if(X.transformName){if(W=X.transformName(Z),W=W.replace(/-+$/,""),W!==Z)q=!1}let K=q&&U?`${U}-${W}`:W,G=Y?`-${Y}`:"";return`--${K}${G}`.replace(/[^a-zA-Z0-9-_]/g,"-")}function m2($,X){try{if(!h($))return $;let Y=new g0($);return Y.alpha=X,P(Y)}catch(Y){return console.warn(`Failed to apply alpha to color "${$}": ${Y}`),$}}function d2($,X){let Y=$.match(/([\d.]+)(\w+)/);if(Y){let[,Z,W]=Y;return`${parseFloat(Z)*X}${W}`}return $}function u2($,X){try{if(!h($))return $;let Z=new g0($).to("oklch");return Z.h=(Z.h+X)%360,P(Z)}catch(Y){return console.warn(`Failed to shift hue for color "${$}": ${Y}`),$}}var m$=N(()=>{S0();i()});function d$($){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 K$($,X={}){let{rootSelector:Y=":root",separateThemeFiles:Z=!1,generateMediaQueries:W=!1,customHeader:q}=X;if(Z)return c2($,X);let U=new Map,K=new Map;U.set("light",[]),U.set("dark",[]);for(let E of $){if(typeof E.value==="string"&&p(E.value))continue;if(d$(E))continue;let L=` ${E.cssVar}: ${D(E.value,E.type)};`;if(W&&E.name.includes("@media")){let w=H$(E);if(w){if(!K.has(w))K.set(w,[]);K.get(w).push(L);continue}}let _=E.name.match(/@(dark|light)$/);if(_){let w=_[1];U.get(w).push(L)}else U.get("light").push(L)}let G="";if(q)G+=`${q}
|
|
13
13
|
|
|
14
14
|
`;let H=U.get("light")||[];if(H.length>0){H.sort(),G+=`${Y} {
|
|
15
15
|
${H.join(`
|
|
16
16
|
`)}
|
|
17
17
|
`;let E=U.get("dark")||[];if(E.length>0){E.sort();let L=X.themeSelector||"[data-theme]",_;if(L.startsWith("."))if(L===".")_=".dark";else _=`${L}-dark`;else if(L.startsWith("[")&&L.endsWith("]"))if(L.includes("="))_=L.replace(/="[^"]*"/,'="dark"');else _=L.replace("]",'="dark"]');else _=`${L}-dark`;G+=`
|
|
18
18
|
&${_} {
|
|
19
|
-
${E.map((
|
|
19
|
+
${E.map((w)=>` ${w}`).join(`
|
|
20
20
|
`)}
|
|
21
21
|
}
|
|
22
22
|
`}G+=`}
|
|
@@ -27,13 +27,13 @@ ${L.map((_)=>` ${_}`).join(`
|
|
|
27
27
|
`)}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
`;let z=[{fileName:"tokens.css",content:G}],A=
|
|
30
|
+
`;let z=[{fileName:"tokens.css",content:G}],A=m0($,X);z.push(...A);let B=u0($,X);return z.push(...B),z}function k2($,X){let Y=[];for(let W of $){let U=` ${W.cssVar||G$(W,X)}: ${D(W.value,W.type)};`;Y.push(U)}let Z="";if(X.customHeader)Z+=`${X.customHeader}
|
|
31
31
|
|
|
32
32
|
`;if(Y.length>0)Y.sort(),Z+=`${X.rootSelector||":root"} {
|
|
33
33
|
${Y.join(`
|
|
34
34
|
`)}
|
|
35
35
|
}
|
|
36
|
-
`;return{fileName:"theme.css",content:Z}}function
|
|
36
|
+
`;return{fileName:"theme.css",content:Z}}function c2($,X){let Y=[],Z=new Map,W=[],q=new Set(["dark","light"]);for(let H of $){if(H$(H))continue;if(typeof H.value==="string"&&p(H.value))continue;if(d$(H))continue;let z=H.name.match(/@(dark|light)$/);if(z){let A=z[1];if(q.has(A)){if(!Z.has(A))Z.set(A,[]);Z.get(A).push(H)}else W.push(H)}else W.push(H)}if(W.length>0){let H=K$(W,{...X,separateThemeFiles:!1})[0];Y.push({...H,fileName:"tokens.css"})}for(let[H,z]of Z){let A=H==="light"?":root":`[data-theme="${H}"]`,B=k2(z,{...X,separateThemeFiles:!1,rootSelector:A});Y.push({...B,fileName:`tokens.${H}.css`,theme:H})}let U=l2($,X);Y.push(...U);let K=m0($,X);Y.push(...K);let G=u0($,X);return Y.push(...G),Y}function l2($,X){let Y=new Map;for(let q of $){let U=H$(q);if(U){let K=q.name.match(/@(dark|light)$/),G=K?K[1]:"light";if(!Y.has(U))Y.set(U,new Map);let H=Y.get(U);if(!H.has(G))H.set(G,[]);H.get(G).push(q)}}if(Y.size===0)return[];let Z=`/**
|
|
37
37
|
* Design System Tokens - Responsive Breakpoints
|
|
38
38
|
* Generated: ${new Date().toISOString()}
|
|
39
39
|
*
|
|
@@ -41,14 +41,14 @@ ${Y.join(`
|
|
|
41
41
|
* Each media query section overrides tokens for specific screen sizes.
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
|
-
`,W=Array.from(Y.keys()).sort();for(let q of W){let U=Y.get(q);for(let[K,G]of U){let H=[];for(let z of G){let B=` ${z.cssVar||
|
|
44
|
+
`,W=Array.from(Y.keys()).sort();for(let q of W){let U=Y.get(q);for(let[K,G]of U){let H=[];for(let z of G){let B=` ${z.cssVar||G$(z,X)}: ${D(z.value,z.type)};`;H.push(B)}if(H.length>0)H.sort(),Z+=`${q} {
|
|
45
45
|
[data-theme="${K}"] {
|
|
46
46
|
${H.join(`
|
|
47
47
|
`)}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
`}}return[{fileName:"tokens.breakpoints.css",content:Z.trim()}]}function
|
|
51
|
+
`}}return[{fileName:"tokens.breakpoints.css",content:Z.trim()}]}function m0($,X){let Y=new Map;for(let W of $)if(typeof W.value==="string"&&p(W.value)){let q=W.name.match(/@(dark|light)$/),U=q?q[1]:"light";if(!Y.has(U))Y.set(U,[]);Y.get(U).push(W)}let Z=[];if(Y.size===0)return[];if(Y.size===1){let[W,q]=Array.from(Y.entries())[0],U=v0(q,W,X);Z.push({fileName:"tokens.icons.css",content:U})}else for(let[W,q]of Y){let U=v0(q,W,X);Z.push({fileName:`tokens.icons.${W}.css`,content:U})}return Z}function v0($,X,Y){let Z=`/**
|
|
52
52
|
* Design System Tokens - Icons (${X})
|
|
53
53
|
* Generated: ${new Date().toISOString()}
|
|
54
54
|
*
|
|
@@ -56,11 +56,11 @@ ${H.join(`
|
|
|
56
56
|
* Icons are provided as data URIs for direct embedding.
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
|
-
`,W=[];for(let q of $){let K=` ${q.cssVar||
|
|
59
|
+
`,W=[];for(let q of $){let K=` ${q.cssVar||G$(q,Y)}: ${D(q.value,q.type)};`;W.push(K)}if(W.length>0){W.sort();let q=X==="light"?":root":`[data-theme="${X}"]`;Z+=`${q} {
|
|
60
60
|
${W.join(`
|
|
61
61
|
`)}
|
|
62
62
|
}
|
|
63
|
-
`}return Z}function
|
|
63
|
+
`}return Z}function G$($,X){let Z=$.name.split("@")[0].replace(/\.$/,"").replace(/\.+/g,"."),W=d0(Z,X.hooks);return`--${X.prefix||e}-${W.replace(/\./g,"-")}`}function d0($,X,Y){if(!X?.shortenName?.enabled)return $;let Z=$;if(X.shortenName.prefix)for(let W of X.shortenName.prefix)Z=Z.replace(new RegExp(W.find,"g"),W.replace);if(X.shortenName.suffix){for(let W of X.shortenName.suffix)if(Z.endsWith(W.find))Z=Z.substring(0,Z.length-W.find.length)+W.replace}if(Y&&Y!=="light"){let W=`-${Y}`;if(Z.endsWith(W))Z=Z.slice(0,-W.length)}return Z}function u0($,X){let Y=new Map;for(let W of $)if(d$(W)){if(H$(W))continue;let q="light";if(W.name.includes("@")){if(W.name.endsWith("@dark")||W.name.includes("@dark@")||W.name.includes("@dark_"))q="dark";let U=W.name.split("@");if(U[U.length-1]==="dark")q="dark"}if(!Y.has(q))Y.set(q,[]);Y.get(q).push(W)}let Z=[];for(let[W,q]of Y.entries()){let U=r2(q,W,X);Z.push({fileName:`tokens.typography.${W}.css`,content:U})}return Z}function r2($,X,Y){let Z=`/**
|
|
64
64
|
* Design System Tokens - Typography (${X})
|
|
65
65
|
* Generated: ${new Date().toISOString()}
|
|
66
66
|
*
|
|
@@ -68,7 +68,7 @@ ${W.join(`
|
|
|
68
68
|
* Includes fontSize, fontWeight, fontFamily, lineHeight, and typography compositions.
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
|
-
`,W=new Map;for(let q of $){let U="default";if(q.name.includes("@")){let K=q.name.split("@");for(let G of K)if(G.includes("screen_")||G.includes("min_width")||G.includes("max_width")){U=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(!W.has(U))W.set(U,[]);W.get(U).push(q)}for(let[q,U]of W.entries()){let K=[];for(let G of U){let z=` ${G.cssVar||
|
|
71
|
+
`,W=new Map;for(let q of $){let U="default";if(q.name.includes("@")){let K=q.name.split("@");for(let G of K)if(G.includes("screen_")||G.includes("min_width")||G.includes("max_width")){U=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(!W.has(U))W.set(U,[]);W.get(U).push(q)}for(let[q,U]of W.entries()){let K=[];for(let G of U){let z=` ${G.cssVar||G$(G,Y)}: ${D(G.value,G.type)};`;K.push(z)}if(K.length>0)if(q==="default"){let G=X==="light"?":root":`[data-theme="${X}"]`;K.sort(),Z+=`${G} {
|
|
72
72
|
${K.join(`
|
|
73
73
|
`)}
|
|
74
74
|
}
|
|
@@ -80,14 +80,14 @@ ${K.sort().map((z)=>` ${z}`).join(`
|
|
|
80
80
|
}
|
|
81
81
|
`,Z+=`}
|
|
82
82
|
|
|
83
|
-
`}}return Z}function
|
|
83
|
+
`}}return Z}function D($,X){if($===null||$===void 0)return"";if(typeof $==="object"&&$!==null&&!Array.isArray($)){let Z=$;if(Z.$value!==void 0){if(typeof Z.$value==="string")return Z.$value;return D(Z.$value,Z.$type||X)}}let Y=String($);switch(X){case"color":return i2(Y);case"dimension":return s2(Y);case"duration":return a2(Y);case"fontFamily":return n2(Y);case"fontWeight":return o2(Y);case"cubicBezier":return t2($);case"shadow":return e2($);case"border":return $Y($);case"typography":return YY($);case"composition":return u$($);default:if(Y.startsWith("data:"))return`"${Y}"`;return Y}}function i2($){if($.startsWith("oklch(")||$.startsWith("rgb(")||$.startsWith("rgba(")||$.startsWith("hsl(")||$.startsWith("hsla(")||$.startsWith("#"))return $;return $}function s2($){if(/^\d+(\.\d+)?(px|rem|em|%|vh|vw|vmin|vmax)$/.test($))return $;if(/^\d+(\.\d+)?$/.test($))return`${$}rem`;return $}function a2($){if(/^\d+(\.\d+)?(s|ms)$/.test($))return $;if(/^\d+(\.\d+)?$/.test($))return`${$}ms`;return $}function n2($){if(($.includes(",")||$.includes(" "))&&!$.startsWith('"')&&!$.startsWith("'"))return`"${$}"`;return $}function o2($){return{thin:"100","extra-light":"200",light:"300",normal:"400",medium:"500","semi-bold":"600",bold:"700","extra-bold":"800",black:"900"}[$]||$}function t2($){if(Array.isArray($)&&$.length===4)return`cubic-bezier(${$.join(", ")})`;return String($)}function e2($){if(Array.isArray($))return $.map((X)=>p0(X)).join(", ");return p0($)}function p0($){if(typeof $==="object"&&$!==null){let X=$,Y=X.color||"transparent";if(typeof Y==="string"&&Y.includes("{")&&Y.includes("}")){console.warn(`Unresolved token reference in shadow color: ${Y}`);let W=Y.match(/\{([^}]+)\}/)?.[1];if(W)Y=`var(${`--${e}-${W.replace(/\./g,"-").replace(/@/g,"-")}`})`}let Z=[X.offsetX||"0",X.offsetY||"0",X.blur||"0",X.spread||"0",Y];if(X.inset)Z.unshift("inset");return Z.join(" ")}return String($)}function $Y($){if(typeof $==="object"&&$!==null){let X=$;return`${X.width||"1px"} ${X.style||"solid"} ${X.color||"transparent"}`}return String($)}function YY($){if(typeof $==="object"&&$!==null){let X=$,Y=X.fontWeight||"normal",Z=X.fontSize||"1rem",W=X.lineHeight||"normal",q=X.fontFamily||"sans-serif";if(q.includes(" ")&&!q.startsWith('"')&&!q.startsWith("'"))q=`'${q}'`;let U;if(Z.includes("/"))U=Z;else U=`${Z}/${W}`;return`${Y} ${U} ${q}`}return String($)}function u$($){if(typeof $!=="object"||$===null)return String($);if(Array.isArray($))return $.map((Y)=>u$(Y)).join(", ");let X=$;if(X.offsetX!==void 0&&X.offsetY!==void 0)return k0(X);if(X.width!==void 0&&X.style!==void 0&&X.color!==void 0)return XY(X);if(X.blur!==void 0||X.saturate!==void 0||X.brightness!==void 0)return ZY(X);if(X.fontSize!==void 0||X.fontFamily!==void 0)return WY(X);return qY(X)}function k0($){let X=[M($.offsetX)||"0",M($.offsetY)||"0",M($.blur)||"0",M($.spread)||"0",M($.color)||"transparent"];if($.inset&&M($.inset)==="true")X.unshift("inset");return X.join(" ")}function XY($){let X=M($.width)||"1px",Y=M($.style)||"solid",Z=M($.color)||"transparent";return`${X} ${Y} ${Z}`}function ZY($){let X=[];if($.blur)X.push(M($.blur)||"blur(0)");if($.saturate)X.push(M($.saturate)||"saturate(100%)");if($.brightness)X.push(M($.brightness)||"brightness(100%)");if($.contrast)X.push(M($.contrast)||"contrast(100%)");if($.hueRotate)X.push(M($.hueRotate)||"hue-rotate(0deg)");return X.join(" ")||"none"}function WY($){let X=M($.fontWeight)||"normal",Y=M($.fontSize)||"1rem",Z=M($.lineHeight),W=M($.fontFamily)||"sans-serif";if(W.includes(" ")&&!W.startsWith('"')&&!W.startsWith("'"))W=`'${W}'`;if(Y.includes("/"))return`${X} ${Y} ${W}`;else return`${X} ${Y}/${Z||"normal"} ${W}`}function M($){if($===null||$===void 0)return"";if(typeof $==="string")return $;if(typeof $==="object"&&$.value!==void 0)return String($.value);return String($)}function qY($){let X=[];for(let[,W]of Object.entries($)){let q=W;if(typeof W==="object"&&W!==null&&q.$value&&typeof q.$value==="object"){let U=q.$value;if(U.offsetX!==void 0&&U.offsetY!==void 0){let K=k0(U);if(K)X.push(K)}else{let K=u$(U);if(K)X.push(K)}}else{let U=M(W);if(U)X.push(U)}}let Z=X.some((W)=>/^\d/.test(W)&&W.includes(" "))?", ":" ";return X.join(Z)||String($)}function H$($){if($.extensions?.mediaQuery&&typeof $.extensions.mediaQuery==="string"){let Y=$.extensions.mediaQuery;if(Y=Y.replace(/\{universe\.foundation\.breakpoint\.screen\.width\.lg\}/g,"64rem"),!Y.startsWith("@media"))Y=`@media ${Y}`;return Y}let X=$.name.match(/@(media[^@]+)/);if(X)return`@${X[1].replace(/_/g," ")}`;if($.name.includes("@screen_and__min_width__300px_"))return"@media screen and (min-width: 300px)";if($.name.includes("@screen_and__min_width__600px_"))return"@media screen and (min-width: 600px)";if($.name.includes("@")&&$.name.includes("_"))return"@media (unknown-breakpoint)";return null}function z$($){let X=$?.$name||"Design System",Y=$?.$version||"1.0.0",Z=new Date().toISOString();return`/**
|
|
84
84
|
* ${X} - CSS Custom Properties
|
|
85
85
|
* Version: ${Y}
|
|
86
86
|
* Generated: ${Z}
|
|
87
87
|
*
|
|
88
88
|
* This file contains CSS custom properties (CSS variables) generated from design tokens.
|
|
89
89
|
* Do not edit this file directly - it will be overwritten.
|
|
90
|
-
*/`}function
|
|
90
|
+
*/`}function UY($){let X=$.replace(/\r?\n|\r/g,"").replace(/\s+/g," ").trim();return`data:image/svg+xml;base64,${Buffer.from(X,"utf8").toString("base64")}`}function k$($,X={}){let{customHeader:Y,objectPath:Z="universe.custom.path.icons"}=X,W="--"+Z.replace(/\./g,"-"),q="";if(Y)q+=Y+`
|
|
91
91
|
|
|
92
92
|
`;else q+=`/**
|
|
93
93
|
* Icon CSS - Base64 Encoded SVG Icons as CSS Custom Properties
|
|
@@ -104,28 +104,28 @@ ${K.sort().map((z)=>` ${z}`).join(`
|
|
|
104
104
|
*/
|
|
105
105
|
|
|
106
106
|
`;q+=`:root {
|
|
107
|
-
`;let U=[...$].sort((K,G)=>K.name.localeCompare(G.name));for(let K of U){let G=K.name.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""),H=`${W}-${K.category}-${G}`;if(X.hooks?.shortenName?.enabled)H=
|
|
107
|
+
`;let U=[...$].sort((K,G)=>K.name.localeCompare(G.name));for(let K of U){let G=K.name.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""),H=`${W}-${K.category}-${G}`;if(X.hooks?.shortenName?.enabled)H=d0(H,X.hooks);let z=UY(K.value);q+=` ${H}: url("${z}");
|
|
108
108
|
`}return q+=`}
|
|
109
|
-
`,{fileName:"tokens.icons.css",content:q.trim()}}var
|
|
109
|
+
`,{fileName:"tokens.icons.css",content:q.trim()}}var A$=N(()=>{j()});import{readFileSync as KY}from"fs";import{join as c0}from"path";async function c$(){try{let{assets:$}=await s(!0),{icons:X}=await u(),Y=await Z$(),Z=$?.icons?.distDir??"build",W=c0(Y,Z),q=c0(W,"tokens",await a("json")),U=JSON.parse(KY(q,"utf8")),K=X?.objectPath??"universe.icons",G=K.split("."),H=U;for(let A of G)if(H&&typeof H==="object"&&A in H)H=H[A];else throw Error(`Icon path ${K} not found in icons file`);let z=[];for(let[A,B]of Object.entries(H))if(typeof B==="object"&&B!==null){for(let[E,L]of Object.entries(B))if(typeof L==="object"&&L!==null){let _=L;z.push({name:E,category:A,value:_.$value||"",description:_.$description||"",style:_.$style||"",dimensions:_.$dimensions})}}return z}catch($){return console.warn("Could not load icon data:",$),[]}}async function l$($,X={}){let{generateTypes:Y=!0,generateConsts:Z=!0}=X,W=X.icons;if(!W)W=await c$();let q={...X,icons:W},U=[];if(Y)U.push({fileName:"tokens.types.ts",content:GY($,q),type:"types"});if(Z)U.push({fileName:"tokens.constants.ts",content:HY($,q),type:"constants"});return U.push({fileName:"index.ts",content:zY(U),type:"index"}),U}function GY($,X){let{tokenInterface:Y="DesignTokens",includeJSDoc:Z=!0,icons:W=[]}=X,q=r$("Type Definitions");if(q+=AY($,Z),q+=BY($,Z),W.length>0)q+=LY(W,Z);return q+=EY($,Y,Z),q+=wY($,Z),q}function HY($,X){let{includeJSDoc:Y=!0,icons:Z=[]}=X,W=r$("Token Constants"),q="TokenPaths, CSSVariableNames";if(Z.length>0)q+=", IconNames, IconCategories, Icon";if(W+=`import type { ${q} } from './tokens.types';
|
|
110
110
|
|
|
111
|
-
`,W+=
|
|
111
|
+
`,W+=OY($,Y),W+=IY($,Y),Z.length>0)W+=QY(Z,Y);return W+=JY($,Y),W}function zY($){let X=r$("Main Export");if($.some((Y)=>Y.type==="types"))X+=`export type * from './tokens.types';
|
|
112
112
|
`;if($.some((Y)=>Y.type==="constants"))X+=`export * from './tokens.constants';
|
|
113
113
|
`;return X+=`
|
|
114
|
-
`,X}function
|
|
114
|
+
`,X}function AY($,X){let Y=$.map((W)=>`"${W.name}"`).join(`
|
|
115
115
|
| `),Z="";if(X)Z+=`/**
|
|
116
116
|
* All available token paths as string literals
|
|
117
117
|
*/
|
|
118
118
|
`;return Z+=`export type TokenPaths =
|
|
119
119
|
| ${Y};
|
|
120
120
|
|
|
121
|
-
`,Z}function
|
|
121
|
+
`,Z}function BY($,X){let Y=RY($),Z="";for(let[W,q]of Y){let U=`${NY(W)}TokenValue`,K=new Set(q.map((H)=>$$(H.value))),G=Array.from(K).join(`
|
|
122
122
|
| `);if(X)Z+=`/**
|
|
123
123
|
* Possible values for ${W} tokens
|
|
124
124
|
*/
|
|
125
125
|
`;Z+=`export type ${U} =
|
|
126
126
|
| ${G};
|
|
127
127
|
|
|
128
|
-
`}return Z}function
|
|
128
|
+
`}return Z}function LY($,X){let Y="",Z=$.map((U)=>`"${U.name}"`).join(`
|
|
129
129
|
| `);if(X)Y+=`/**
|
|
130
130
|
* All available icon names as string literals
|
|
131
131
|
*/
|
|
@@ -160,28 +160,28 @@ ${K.sort().map((z)=>` ${z}`).join(`
|
|
|
160
160
|
`,Y+=` };
|
|
161
161
|
`,Y+=`}
|
|
162
162
|
|
|
163
|
-
`,Y}function
|
|
163
|
+
`,Y}function EY($,X,Y){let Z="";if(Y)Z+=`/**
|
|
164
164
|
* Design tokens interface with all token paths and their values
|
|
165
165
|
*/
|
|
166
166
|
`;Z+=`export interface ${X} {
|
|
167
167
|
`;for(let W of $){if(Y&&W.description)Z+=` /** ${W.description} */
|
|
168
|
-
`;Z+=` "${W.name}": ${
|
|
168
|
+
`;Z+=` "${W.name}": ${$$(W.value)};
|
|
169
169
|
`}return Z+=`}
|
|
170
170
|
|
|
171
|
-
`,Z+=
|
|
171
|
+
`,Z+=_Y($,`${X}Nested`,Y),Z}function _Y($,X,Y){let Z=MY($),W="";if(Y)W+=`/**
|
|
172
172
|
* Design tokens interface with nested structure
|
|
173
173
|
*/
|
|
174
174
|
`;return W+=`export interface ${X} {
|
|
175
|
-
`,W+=
|
|
175
|
+
`,W+=l0(Z,1),W+=`}
|
|
176
176
|
|
|
177
|
-
`,W}function
|
|
177
|
+
`,W}function wY($,X){let Y=$.map((W)=>`"${W.cssVar}"`).join(`
|
|
178
178
|
| `),Z="";if(X)Z+=`/**
|
|
179
179
|
* All available CSS variable names
|
|
180
180
|
*/
|
|
181
181
|
`;return Z+=`export type CSSVariableNames =
|
|
182
182
|
| ${Y};
|
|
183
183
|
|
|
184
|
-
`,Z}function
|
|
184
|
+
`,Z}function OY($,X){let Y="";if(X)Y+=`/**
|
|
185
185
|
* Object containing all token values
|
|
186
186
|
*/
|
|
187
187
|
`;Y+=`export const tokenValues = {
|
|
@@ -189,7 +189,7 @@ ${K.sort().map((z)=>` ${z}`).join(`
|
|
|
189
189
|
`;Y+=` "${Z.name}": ${JSON.stringify(Z.value)},
|
|
190
190
|
`}return Y+=`} as const;
|
|
191
191
|
|
|
192
|
-
`,Y}function
|
|
192
|
+
`,Y}function QY($,X){let Y="";if(X)Y+=`/**
|
|
193
193
|
* Array of all available icons
|
|
194
194
|
*/
|
|
195
195
|
`;Y+=`export const icons: Icon[] = [
|
|
@@ -231,14 +231,14 @@ ${K.sort().map((z)=>` ${z}`).join(`
|
|
|
231
231
|
`,Y+=` return icons.filter(icon => icon.category === category);
|
|
232
232
|
`,Y+=`}
|
|
233
233
|
|
|
234
|
-
`,Y}function
|
|
234
|
+
`,Y}function IY($,X){let Y="";if(X)Y+=`/**
|
|
235
235
|
* Object mapping token paths to CSS variable names
|
|
236
236
|
*/
|
|
237
237
|
`;Y+=`export const cssVariableNames = {
|
|
238
238
|
`;for(let Z of $)Y+=` "${Z.name}": "${Z.cssVar}",
|
|
239
239
|
`;return Y+=`} as const;
|
|
240
240
|
|
|
241
|
-
`,Y}function
|
|
241
|
+
`,Y}function JY($,X){let Y="";if(X)Y+=`/**
|
|
242
242
|
* Get the value of a design token
|
|
243
243
|
*/
|
|
244
244
|
`;if(Y+=`export function getTokenValue<T extends TokenPaths>(tokenPath: T): typeof tokenValues[T] {
|
|
@@ -266,10 +266,10 @@ ${K.sort().map((z)=>` ${z}`).join(`
|
|
|
266
266
|
return tokenPath in tokenValues;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
`,Y}function
|
|
270
|
-
`,Y+=
|
|
269
|
+
`,Y}function RY($){let X=new Map;for(let Y of $){if(!X.has(Y.type))X.set(Y.type,[]);X.get(Y.type).push(Y)}return X}function MY($){let X={};for(let Y of $){if(Y.path.some((G)=>G.includes("@")||G.includes("-")||G.includes(".")))continue;let W=X,q=[...Y.path];for(let G=0;G<q.length-1;G++){let H=q[G];if(!W[H])W[H]={};W=W[H]}let U=q[q.length-1],K=$$(Y.value);W[U]=K}return X}function l0($,X){let Y="",Z=" ".repeat(X);for(let[W,q]of Object.entries($)){let U=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(W)?W:`"${W}"`;if(typeof q==="object"&&!Array.isArray(q))Y+=`${Z}${U}: {
|
|
270
|
+
`,Y+=l0(q,X+1),Y+=`${Z}};
|
|
271
271
|
`;else Y+=`${Z}${U}: ${q};
|
|
272
|
-
`}return Y}function
|
|
272
|
+
`}return Y}function $$($){if(typeof $==="string")return`"${$}"`;else if(typeof $==="number")return $.toString();else if(typeof $==="boolean")return $.toString();else if(Array.isArray($)){let X=new Set($.map((Z)=>$$(Z)));return`Array<${Array.from(X).join(" | ")}>`}else if($===null)return"null";else if($===void 0)return"undefined";else if(typeof $==="object"&&$!==null)return`{ ${Object.entries($).map(([Z,W])=>`${Z}: ${$$(W)}`).join("; ")} }`;else return"unknown"}function NY($){if(!$||typeof $!=="string")return"";return $.charAt(0).toUpperCase()+$.slice(1)}function r$($){let X=new Date().toISOString();return`/**
|
|
273
273
|
* ${$}
|
|
274
274
|
* Generated: ${X}
|
|
275
275
|
*
|
|
@@ -277,7 +277,7 @@ ${K.sort().map((z)=>` ${z}`).join(`
|
|
|
277
277
|
* Do not edit this file directly - it will be overwritten.
|
|
278
278
|
*/
|
|
279
279
|
|
|
280
|
-
`}var
|
|
280
|
+
`}var i$=N(()=>{j()});var e="did";var j=N(()=>{i();_$();I$();i();q$();_0();w0();J0();_$();I$();T$();m$();A$();i$();a$()});import{readFileSync as xY,mkdirSync as PY}from"fs";import{writeFile as i0,readdir as jY,mkdir as SY}from"fs/promises";import{resolve as DY,relative as s0,join as n$,dirname as bY}from"path";import CY from"lodash";async function a0($){let X=await jY($,{withFileTypes:!0}),Y=await Promise.all(X.map((Z)=>{let W=DY($,Z.name);return Z.isDirectory()?a0(W):W}));return Array.prototype.concat(...Y)}async function t$(){let{assets:$,icons:X,tokenNamespace:Y,__dirname:Z,buildDir:W}=await v(),q=n$(Z,$?.icons?.sourceDir??"icons"),U="build",K=$?.icons?.distDir??"build",G=n$(Z,K),H=n$(Z,W,"icons");if(!$?.icons?.sourceDir){console.error("Skipping icon build: iconsDir is not defined in the project paths.");return}let z=(await a0(q)).filter((O)=>O.endsWith(".svg")),E=(await Promise.all(z.map(async(O)=>{let Q=xY(O,"utf8").replace(/(\s+(?=(?:[^"]*"[^"]*")*[^"]*$))/g," ").trim()??"";Q=await V$(Q);let I=s0(q,O).split("/").pop(),F=(Q.match(/name="(.*?)"/)??[])[1]??I?.replace(".svg",""),T=(Q.match(/data-style="(.*?)"/)??[])[1],q2=(Q.match(/description="(.*?)"/)??[])[1],[W0]=Q.match(/<svg[^>]*>/)??[],[,U2]=W0?.match(/width="([\d.]+)(px)?"/)??[],[,K2]=W0?.match(/height="([\d.]+)(px)?"/)??[];if(T!=="animated"&&T!=="custom")return{path:O,folder:s0(q,O).split("/").slice(0,-1).concat(F),file:I,style:T,content:Q,name:F,dimensions:{width:Number(U2),height:Number(K2)},description:q2??""};return}))).filter((O)=>O!==void 0).reduce((O,Q)=>{if(Q?.style!=="animated"&&Q?.style!=="custom"&&Q)o$(O,Q.folder.join("."),{$type:"icon",$name:Q.name,$description:Q.description,$style:Q.style,$value:Q.content,$dimensions:Q.dimensions,...VY(O,Q.folder.join("."))});return O},{}),L=X?.objectPath??`${Y}.icons`;Object.keys(E).forEach(async(O)=>{let Q=`${H}/${O}`,I=`${Q}/svg.${O}.tokens.json`;await SY(Q,{recursive:!0});let F=o$({},`${L}${L?".":""}${O}`,E[O]);await i0(I,JSON.stringify(F,null,2),{flag:"w",encoding:"utf-8"})});let _=`${G}/tokens/${await a("json")}`,w=bY(_);PY(w,{recursive:!0});let J=o$({},L,E);await i0(_,JSON.stringify(J,null,2),{flag:"w",encoding:"utf-8"})}var o$,VY,v4;var n0=N(()=>{j();({set:o$,get:VY}=CY);v4=t$().catch(($)=>{console.error($),process.exit(1)})});function e0($,X={}){let Y=[],Z=X.typescript?"ts":"js",W=$.filter((U)=>U.extensions?.mediaQuery||U.name.includes("@screen")||U.name.includes("@_")),q=$.filter((U)=>!U.extensions?.mediaQuery&&!U.name.includes("@screen")&&!U.name.includes("@_"));if(X.separateThemeFiles){let U=q.filter((G)=>!G.name.includes("@dark")),K=q.filter((G)=>G.name.includes("@dark"));if(X.typescript){if(U.length>0){let G=$0(U,"light");Y.push({fileName:"light.d.ts",content:t0(G,X,"light")})}if(K.length>0){let G=$0(K,"dark");Y.push({fileName:"dark.d.ts",content:t0(G,X,"dark")})}}if(U.length>0)Y.push({fileName:`light.${Z}`,content:e$(U,{...X,theme:"light"}),theme:"light"});if(K.length>0)Y.push({fileName:`dark.${Z}`,content:e$(K,{...X,theme:"dark"}),theme:"dark"})}else Y.push({fileName:`tokens.${Z}`,content:e$(q,X)});if(W.length>0)Y.push({fileName:`breakpoints.${Z}`,content:gY(W,$,X)});if(X.separateThemeFiles&&Y.length>1)Y.push({fileName:`index.${Z}`,content:pY(Y,X)});return Y}function gY($,X,Y={}){let{typescript:Z,includeJSDoc:W,moduleType:q="es",customHeader:U}=Y,K=new Map(X.map((A)=>[A.name,A])),G={};for(let A of $){let B=A.extensions?.mediaQuery||TY(A.name),E=A.name.includes("@dark")?"dark":"light";if(typeof B==="string"&&B.includes("{")&&B.includes("}"))B=fY(B,K);if(!G[B])G[B]={};if(!G[B][E])G[B][E]={};let L=yY(A.name),_=hY(L,B$(A.value,K));G[B][E]={...G[B][E],..._}}let H=Object.keys(G).sort((A,B)=>{let E=o0(A),L=o0(B);return E-L}).reduce((A,B)=>{return A[B]=G[B],A},{}),z="";if(U)z+=`${U}
|
|
281
281
|
|
|
282
282
|
`;else z+=`/**
|
|
283
283
|
`,z+=` * Design Tokens - Breakpoints
|
|
@@ -285,17 +285,17 @@ ${K.sort().map((z)=>` ${z}`).join(`
|
|
|
285
285
|
`,z+=` * Do not edit this file directly
|
|
286
286
|
`,z+=` */
|
|
287
287
|
|
|
288
|
-
`;if(Z)z
|
|
289
|
-
`;if(q==="es"){if(Z)z+=`const breakpoints: Tokens = ${
|
|
288
|
+
`;if(Z)z+=$2(H,W),z+=`
|
|
289
|
+
`;if(q==="es"){if(Z)z+=`const breakpoints: Tokens = ${m(H,W,0)};
|
|
290
290
|
|
|
291
|
-
`;else z+=`const breakpoints = ${
|
|
291
|
+
`;else z+=`const breakpoints = ${m(H,W,0)};
|
|
292
292
|
|
|
293
293
|
`;z+=`export default breakpoints;
|
|
294
|
-
`}else z+=`const breakpoints = ${
|
|
294
|
+
`}else z+=`const breakpoints = ${m(H,W,0)};
|
|
295
295
|
|
|
296
296
|
`,z+=`module.exports = breakpoints;
|
|
297
297
|
`,z+=`module.exports.default = breakpoints;
|
|
298
|
-
`;return z}function
|
|
298
|
+
`;return z}function TY($){if($.includes("@_max_width_")){let X=$.match(/@_max_width___(.+?)__/);if(X)return`screen and (max-width: {${X[1].replace(/_/g,".")}})`}if($.includes("@_min_width_")){let X=$.match(/@_min_width___(.+?)__/);if(X)return`screen and (min-width: {${X[1].replace(/_/g,".")}})`}return"screen"}function yY($){let X=$.replace(/@_.*?__/,"").replace(/@screen.*/,"").replace(/@dark/,"").replace(/^universe\./,"");return X=X.replace(/_universe_foundation_breakpoint_screen_width_[^_]+__?$/,""),X}function o0($){let X=$.match(/(\d+(?:\.\d+)?)/);return X?parseFloat(X[1]):0}function fY($,X){return $.replace(/\{([^}]+)\}/g,(Y,Z)=>{let W=X.get(Z);if(W){let q=W.value;if(typeof q==="object"&&q!==null&&"$value"in q)q=q.$value;return String(q)}return Y})}function hY($,X){let Y=$.split("."),Z={},W=Z;for(let q=0;q<Y.length-1;q++)W[Y[q]]={},W=W[Y[q]];return W[Y[Y.length-1]]=X,Z}function e$($,X={}){let{typescript:Y,includeJSDoc:Z,moduleType:W="es",customHeader:q,theme:U}=X,K="";if(q)K+=`${q}
|
|
299
299
|
|
|
300
300
|
`;else K+=`/**
|
|
301
301
|
`,K+=` * Design Tokens - ${U?`${U.charAt(0).toUpperCase()+U.slice(1)} Theme`:"All Tokens"}
|
|
@@ -303,29 +303,43 @@ ${K.sort().map((z)=>` ${z}`).join(`
|
|
|
303
303
|
`,K+=` * Do not edit this file directly
|
|
304
304
|
`,K+=` */
|
|
305
305
|
|
|
306
|
-
`;let G
|
|
307
|
-
`;if(W==="es"){if(Y)K+=`const tokens: Tokens = ${f(G,Z,0)};
|
|
306
|
+
`;let G=$0($,U);if(Y)if(X.separateThemeFiles&&U)K+=`import type { Tokens } from "./${U}.d";
|
|
308
307
|
|
|
309
|
-
`;else K
|
|
308
|
+
`;else K+=$2(G,Z),K+=`
|
|
309
|
+
`;if(W==="es"){if(Y)K+=`const tokens: Tokens = ${m(G,Z,0)};
|
|
310
|
+
|
|
311
|
+
`;else K+=`const tokens = ${m(G,Z,0)};
|
|
310
312
|
|
|
311
313
|
`;K+=`export default tokens;
|
|
312
314
|
`;let H=Object.keys(G);if(H.length>0){K+=`
|
|
313
315
|
// Named exports for convenience
|
|
314
316
|
`;for(let z of H)K+=`export const ${z} = tokens.${z};
|
|
315
|
-
`}}else K+=`const tokens = ${
|
|
317
|
+
`}}else K+=`const tokens = ${m(G,Z,0)};
|
|
316
318
|
|
|
317
319
|
`,K+=`module.exports = tokens;
|
|
318
320
|
`,K+=`module.exports.default = tokens;
|
|
319
|
-
`;return K}function
|
|
321
|
+
`;return K}function $0($,X){let Y={},Z=new Map($.map((W)=>[W.name,W]));for(let W of $){let q=W.name;if(X){if(q.includes(`@${X}`))q=q.replace(`@${X}`,"")}else q=q.replace(/@(?:light|dark)$/,"");let U=q.split("."),K=Y;for(let H=0;H<U.length-1;H++){let z=U[H];if(!K[z])K[z]={};K=K[z]}let G=U[U.length-1];K[G]=B$(W.value,Z)}return Y}function B$($,X){if(typeof $==="object"&&$!==null&&!Array.isArray($)){let Y=$;if(Y.color&&typeof Y.color==="string"&&Y.color.includes("{")&&Y.color.includes("}")){let Z=D($,"shadow");if(typeof Z==="string"&&!Z.includes("{")){let W={...Y},q=Z.split(" "),U=q[q.length-1];if(U&&U.startsWith("#"))W.color=U;else W.color=D(Y.color,"color");return W}}}if(typeof $==="string"){if($.startsWith("{")&&$.endsWith("}")){let Y=$.slice(1,-1),Z=X.get(Y);if(Z)return Z.value;let W=D($,"color");if(W!==$)return W}return $}if(Array.isArray($))return $.map((Y)=>B$(Y,X));if(typeof $==="object"&&$!==null){let Y={};for(let[Z,W]of Object.entries($))Y[Z]=B$(W,X);return Y}return $}function $2($,X){let Y="";if(X)Y+=`/**
|
|
322
|
+
* Token object type definition
|
|
323
|
+
*/
|
|
324
|
+
`;return Y+=`type Tokens = ${Y0($,0)};
|
|
325
|
+
`,Y}function t0($,X,Y){let{customHeader:Z,includeJSDoc:W}=X,q="";if(Z)q+=`${Z}
|
|
326
|
+
|
|
327
|
+
`;else{let U=Y?` - ${Y.charAt(0).toUpperCase()+Y.slice(1)} Theme`:"";q+=`/**
|
|
328
|
+
`,q+=` * Universe Design System Tokens - Type Definitions${U}
|
|
329
|
+
`,q+=` * Auto-generated from design token definitions
|
|
330
|
+
`,q+=` * Do not edit this file directly
|
|
331
|
+
`,q+=` */
|
|
332
|
+
|
|
333
|
+
`}if(W)q+=`/**
|
|
320
334
|
* Token object type definition
|
|
321
335
|
*/
|
|
322
|
-
`;return
|
|
323
|
-
`,
|
|
324
|
-
`;for(let[q,U]of Z){let K=
|
|
325
|
-
`}return W+=" ".repeat(X)+"}",W}function
|
|
336
|
+
`;return q+=`export type Tokens = ${Y0($,0)};
|
|
337
|
+
`,q}function Y0($,X){if(typeof $!=="object"||$===null)return typeof $==="string"?"string":typeof $==="number"?"number":typeof $==="boolean"?"boolean":"any";let Y=" ".repeat(X+1),Z=Object.entries($);if(Z.length===0)return"{}";let W=`{
|
|
338
|
+
`;for(let[q,U]of Z){let K=vY(q)?`"${q}"`:q;W+=`${Y}${K}: ${Y0(U,X+1)};
|
|
339
|
+
`}return W+=" ".repeat(X)+"}",W}function vY($){return $.startsWith("@")||$.includes(" ")||$.includes("-")||$.includes("(")||$.includes(")")||$.includes("@")||$.includes(":")||!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test($)}function m($,X,Y=0){if(typeof $!=="object"||$===null)return JSON.stringify($);let Z=" ".repeat(Y),W=" ".repeat(Y+1),q=Object.entries($);if(q.length===0)return"{}";let U=`{
|
|
326
340
|
`;for(let K=0;K<q.length;K++){let[G,H]=q[K],z=K===q.length-1;if(X&&typeof H==="string")U+=`${W}/** Token value: ${JSON.stringify(H)} */
|
|
327
|
-
`;let A=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(G)?G:JSON.stringify(G),B=
|
|
328
|
-
`}return U+=`${Z}}`,U}function
|
|
341
|
+
`;let A=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(G)?G:JSON.stringify(G),B=m(H,X,Y+1);U+=`${W}${A}: ${B}${z?"":","}
|
|
342
|
+
`}return U+=`${Z}}`,U}function pY($,X){let Y=X.typescript?"ts":"js",{moduleType:Z="es",customHeader:W}=X,q="";if(W)q+=`${W}
|
|
329
343
|
|
|
330
344
|
`;else q+=`/**
|
|
331
345
|
`,q+=` * Design Tokens - Index
|
|
@@ -340,7 +354,7 @@ ${K.sort().map((z)=>` ${z}`).join(`
|
|
|
340
354
|
`}q+=`
|
|
341
355
|
// Default export points to light theme
|
|
342
356
|
`,q+=`module.exports = require('./light');
|
|
343
|
-
`}return q}var
|
|
357
|
+
`}return q}var Y2=N(()=>{A$()});var X2={};q0(X2,{validateCSSFiles:()=>mY,printValidationResults:()=>dY});import{readFileSync as X0,existsSync as l}from"fs";import{join as b}from"path";function mY($,X){let Y={isValid:!0,errors:[],warnings:[],checks:[]},Z=b($,"css"),W=b(Z,"tokens.css"),q=l(W);if(Y.checks.push({name:"CSS file exists: tokens.css",passed:q,message:q?void 0:"Missing required CSS file: tokens.css"}),!q)Y.errors.push("Missing required CSS file: tokens.css"),Y.isValid=!1;if(X.$metaData?.tokens?.css?.mediaQuery?.separateThemeFiles??!1){let A=b(Z,"tokens.dark.css"),B=l(A);if(Y.checks.push({name:"CSS file exists: tokens.dark.css",passed:B,message:B?void 0:"Missing required CSS file: tokens.dark.css (separateThemeFiles is enabled)"}),!B)Y.errors.push("Missing required CSS file: tokens.dark.css (separateThemeFiles is enabled)"),Y.isValid=!1}let K=b(Z,"tokens.breakpoints.css");if(l(K))Y.checks.push({name:"CSS file exists: tokens.breakpoints.css",passed:!0,message:void 0});let H=X.$metaData?.tokens?.css?.hooks?.shortenName;if(H?.enabled&&l(b(Z,"tokens.css"))){let A=X0(b(Z,"tokens.css"),"utf8");if(H.prefix)for(let{find:B,replace:E}of H.prefix){let L=`--${e}-${B}`,_=`--${E}`,w=A.includes(L),J=A.includes(_);if(Y.checks.push({name:`Prefix hook applied: ${B} → ${E}`,passed:!w&&J,message:w?`Old prefix "${L}" still found in CSS, should be "${_}"`:void 0}),w)Y.errors.push(`Prefix transformation failed: "${L}" should be replaced with "${_}"`),Y.isValid=!1}if(H.suffix)for(let{find:B,replace:E}of H.suffix){let _=new RegExp(`--[^:]+${B.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}:`,"g").test(A);if(Y.checks.push({name:`Suffix hook applied: ${B} → ${E}`,passed:!_,message:_?`Old suffix "${B}" still found in CSS variable names`:void 0}),_)Y.errors.push(`Suffix transformation failed: "${B}" should be removed/replaced with "${E}"`),Y.isValid=!1}}if(l(b(Z,"tokens.css"))){let B=X0(b(Z,"tokens.css"),"utf8").match(/:\s*{[^}]+}/g);if(Y.checks.push({name:"No unresolved token references",passed:!B,message:B?`Found unresolved references: ${B.join(", ")}`:void 0}),B)Y.errors.push(`Unresolved token references found: ${B.join(", ")}`),Y.isValid=!1}let z=["tokens.css","tokens.dark.css","tokens.breakpoints.css"];for(let A of z){let B=b(Z,A);if(l(B)){let E=X0(B,"utf8"),L=(E.match(/\{/g)||[]).length-(E.match(/\}/g)||[]).length;if(Y.checks.push({name:`CSS syntax valid: ${A}`,passed:L===0,message:L!==0?`Mismatched braces in ${A}`:void 0}),L!==0)Y.errors.push(`CSS syntax error in ${A}: mismatched braces`),Y.isValid=!1}}return Y}function dY($){console.log(`
|
|
344
358
|
|
|
345
359
|
Build Validation Results:`),console.log("========================================================");for(let X of $.checks){let Y=X.passed?"✓":"✗";if(console.log(` ${Y} ${X.name}`),X.message)console.log(` ${X.message}`)}if($.warnings.length>0){console.log(`
|
|
346
360
|
⚠️ Warnings:`);for(let X of $.warnings)console.log(` ${X}`)}if($.errors.length>0){console.log(`
|
|
@@ -348,7 +362,7 @@ Build Validation Results:`),console.log("=======================================
|
|
|
348
362
|
Validation Summary:`),console.log(` - Checks: ${$.checks.filter((X)=>X.passed).length}/${$.checks.length} passed`),console.log(` - Errors: ${$.errors.length}`),console.log(` - Warnings: ${$.warnings.length}`),console.log(`
|
|
349
363
|
${$.isValid?"✅":"❌"} Build ${$.isValid?"passed":"failed"}`),console.log(`
|
|
350
364
|
========================================================
|
|
351
|
-
`)}var
|
|
365
|
+
`)}var Z2=N(()=>{j()});import{writeFileSync as uY,mkdirSync as kY,existsSync as cY}from"fs";import{join as g,dirname as Z0}from"path";function lY($,X,Y=!1,Z=!1){let W=[],q=[],U=[];for(let G of $)if(G.fileName.includes("breakpoint"))q.push(`@import url("./css/${G.fileName}");`);else U.push(`@import url("./css/${G.fileName}");`);if(W.push(...U),Y)W.push('@import url("./css/tokens.icons.css");');if(Z)W.push('@import url("./css/fonts.css");');W.push(...q);let K=`/**
|
|
352
366
|
* ${X} Design System - Main CSS Entry Point
|
|
353
367
|
* Generated: ${new Date().toISOString()}
|
|
354
368
|
*
|
|
@@ -360,18 +374,18 @@ ${$.isValid?"✅":"❌"} Build ${$.isValid?"passed":"failed"}`),console.log(`
|
|
|
360
374
|
|
|
361
375
|
${W.join(`
|
|
362
376
|
`)}
|
|
363
|
-
`;return{fileName:`${X}.design-system.tokens.css`,content:K,theme:void 0}}async function
|
|
364
|
-
Starting token build process...`,$.verbose),R("Loading token files...",$.verbose);let
|
|
365
|
-
Generating CSS files...`,$.verbose);let
|
|
366
|
-
Generated icon tokens`,$.verbose)}catch(
|
|
367
|
-
Generating TypeScript files...`,$.verbose);let
|
|
368
|
-
Generating JavaScript files...`,$.verbose);let
|
|
369
|
-
Generating JSON files...`,$.verbose);let
|
|
377
|
+
`;return{fileName:`${X}.design-system.tokens.css`,content:K,theme:void 0}}async function r0($){let X=Date.now(),Y={tokenCount:0,cssFiles:[],typescriptFiles:[],javascriptFiles:[],jsonFiles:[],duration:0,warnings:[],errors:[]};try{R(`
|
|
378
|
+
Starting token build process...`,$.verbose);let{initializeColorspace:Z}=await Promise.resolve().then(() => (i(),G0));await Z(),R("Loading token files...",$.verbose);let W=f$($.tokensDir);R("Parsing tokens...",$.verbose);let q=rY($.config),U=h$(W,q);R(`Found ${U.length} tokens`,$.verbose),Y.tokenCount=U.length;let K=v$(U,q);if(R(`Resolved ${K.length} tokens`,$.verbose),$.generateCSS!==!1){R(`
|
|
379
|
+
Generating CSS files...`,$.verbose);let H=W2($.config,$.cssOptions),z=K$(K,H);for(let A of z){let B=g($.outputDir,"css",A.fileName);r(B,A.content),R(` ✓ ${A.fileName}`,$.verbose)}Y.cssFiles=z}if($.generateCSS!==!1)try{await t$(),R(`
|
|
380
|
+
Generated icon tokens`,$.verbose)}catch(H){if($.verbose)console.warn("Could not build icon tokens:",H)}if($.generateCSS!==!1)try{let H=await c$();if(H.length>0){let z=W2($.config,$.cssOptions),A=k$(H,{customHeader:z$($.config),objectPath:$.config.$metaData?.icons?.objectPath||"universe.custom.path.icons",hooks:z.hooks}),B=g($.outputDir,"css",A.fileName);if(r(B,A.content),R(` ✓ Generated ${A.fileName}`,$.verbose),Y.cssFiles)Y.cssFiles.push(A);else Y.cssFiles=[A]}}catch(H){if($.verbose)console.warn("Could not generate icon CSS:",H)}let G=!1;if($.generateCSS!==!1)try{let H=$.config.$fonts;if(H&&H.length>0){await g$(H,$.outputDir),R(" ✓ Generated fonts.css",$.verbose),G=!0;let z={fileName:"fonts.css",content:"Generated by appendTypographyTokens",theme:void 0};if(Y.cssFiles)Y.cssFiles.push(z);else Y.cssFiles=[z]}}catch(H){if($.verbose)console.warn("Could not generate font CSS:",H)}if($.generateCSS!==!1&&Y.cssFiles.length>0){let H=$.config.$metaData?.tokenNamespace||"tokens",z=Y.cssFiles.some((E)=>E.fileName==="tokens.icons.css"),A=lY(Y.cssFiles.filter((E)=>E.fileName!=="tokens.icons.css"&&E.fileName!=="fonts.css"),H,z,G),B=g($.outputDir,A.fileName);r(B,A.content),R(` ✓ Generated ${A.fileName}`,$.verbose),Y.cssFiles.push(A)}if($.generateTypeScript!==!1){R(`
|
|
381
|
+
Generating TypeScript files...`,$.verbose);let H=iY($.config,$.typescriptOptions),z=await l$(K,H);for(let A of z){let B=g($.outputDir,"typescript",A.fileName);r(B,A.content),R(` ✓ Generated ${A.fileName}`,$.verbose)}Y.typescriptFiles=z}if($.generateJavaScript!==!1){R(`
|
|
382
|
+
Generating JavaScript files...`,$.verbose);let H=sY($.config,$.javascriptOptions),z=e0(K,H);for(let A of z){let B=g($.outputDir,"js",A.fileName);r(B,A.content),R(` ✓ Generated ${A.fileName}`,$.verbose)}Y.javascriptFiles=z}if($.generateJSON!==!1){R(`
|
|
383
|
+
Generating JSON files...`,$.verbose);let H=aY(K,U,$.config);for(let z of H){let A=g($.outputDir,"json",z.fileName);r(A,z.content),R(` ✓ Generated ${z.fileName}`,$.verbose)}Y.jsonFiles=H}Y.duration=Date.now()-X,R(`
|
|
370
384
|
Build completed in ${Y.duration}ms`,$.verbose)}catch(Z){let W=Z instanceof Error?Z.message:String(Z);Y.errors.push(W),R(`❌ Build failed: ${W}`,$.verbose)}if($.validate!==!1){R(`
|
|
371
|
-
Validating build output...`,$.verbose);let{validateCSSFiles:Z,printValidationResults:W}=await Promise.resolve().then(() => (
|
|
385
|
+
Validating build output...`,$.verbose);let{validateCSSFiles:Z,printValidationResults:W}=await Promise.resolve().then(() => (Z2(),X2)),q=Z($.outputDir,$.config);if($.verbose||!q.isValid)W(q);if(!q.isValid)Y.errors.push(...q.errors)}return Y}function rY($){let X=$.$metaData;return{prefix:X.dsNamespace||X.tokenNamespace,namespace:X.tokenNamespace,generateModes:!0,generateDerivedTokens:!0,generateBreakpointTokens:!0,failOnBrokenReferences:!0,transformName:(Y)=>{let Z=X.tokens?.css?.hooks?.shortenName;if(Z?.enabled){let W=Y;if(Z.prefix)for(let{find:q,replace:U}of Z.prefix){let K=q.replace(/\./g,"-").replace(/-$/,""),G=U.replace(/\./g,"-").replace(/-$/,"");W=W.replace(K,G)}if(Z.suffix){for(let{find:q,replace:U}of Z.suffix)if(W.endsWith(q))W=W.substring(0,W.length-q.length)+U}return W}return Y}}}function W2($,X){let Z=$.$metaData.tokens?.css;return{...X,separateThemeFiles:Z?.mediaQuery?.separateThemeFiles??!1,rootSelector:":root",generateMediaQueries:!0,customHeader:z$($),themeSelector:Z?.mediaQuery?.match||"[data-theme]",hooks:Z?.hooks}}function iY($,X){let Y=$.$metaData;return{...X,tokenInterface:"DesignTokens",exportNamespace:Y.dsNamespace||Y.tokenNamespace,generateTypes:!0,generateConsts:!0,generateCSSVarMappings:!0,includeJSDoc:!0}}function sY($,X){return{...X,typescript:!0,separateThemeFiles:!0,includeJSDoc:!1,moduleType:"es",customHeader:`/**
|
|
372
386
|
* ${$.$name}
|
|
373
387
|
* Generated: ${new Date().toISOString()}
|
|
374
|
-
*/`}}function
|
|
388
|
+
*/`}}function aY($,X,Y){let Z=[],W=JSON.stringify({$schema:"https://schemas.designtokens.org/design-tokens.schema.json",$name:Y.$name,$version:Y.$version,tokens:X.reduce((K,G)=>{return K[G.name]={$type:G.type,$value:G.value,$description:G.description,$extensions:G.extensions},K},{})},null,2);Z.push({fileName:"tokens.raw.json",content:W});let q=JSON.stringify({$name:Y.$name,$version:Y.$version,tokens:$.reduce((K,G)=>{return K[G.name]={$type:G.type,$value:G.value,$description:G.description,cssVar:G.cssVar},K},{})},null,2);Z.push({fileName:"tokens.resolved.json",content:q});let U=JSON.stringify({$name:`${Y.$name} - CSS Variables`,$version:Y.$version,variables:$.reduce((K,G)=>{return K[G.cssVar]=G.value,K},{})},null,2);return Z.push({fileName:"css-variables.json",content:U}),Z}function r($,X){let Y=Z0($);if(!cY(Y))kY(Y,{recursive:!0});uY($,X,"utf-8")}function R($,X){if(X!==!1)console.log($)}async function s$($,X){let Z=(await import($)).default,W=g(Z0($),Z.$paths.baseDir,Z.$paths.tokensDir),q=X||g(Z0($),Z.$paths.baseDir,Z.$paths.distDir);return r0({config:Z,tokensDir:W,outputDir:q,verbose:!0})}var a$=N(()=>{n0();A$();Y2();m$();i$();T$()});a$();import{existsSync as nY}from"fs";import{resolve as oY}from"path";function tY($){let X={};for(let Y=0;Y<$.length;Y++){let Z=$[Y];switch(Z){case"--config":case"-c":X.config=$[++Y];break;case"--input":case"-i":X.input=$[++Y];break;case"--output":case"-o":X.output=$[++Y];break;case"--verbose":case"-v":X.verbose=!0;break;case"--no-css":X.css=!1;break;case"--no-typescript":X.typescript=!1;break;case"--no-json":X.json=!1;break;case"--help":case"-h":X.help=!0;break;default:if(Z.startsWith("-"))console.warn(`Unknown option: ${Z}`);break}}return X}function eY(){console.log(`
|
|
375
389
|
Design Tokens Builder - W3C compliant token processor
|
|
376
390
|
|
|
377
391
|
Usage: build-tokens [options]
|
|
@@ -405,11 +419,11 @@ Token Files:
|
|
|
405
419
|
- Include $type and $value properties
|
|
406
420
|
- Support token references with {token.path} syntax
|
|
407
421
|
- Support extensions for modes, generators, and breakpoints
|
|
408
|
-
`)}function
|
|
422
|
+
`)}function $1($){let X=[$,"./designid.config.ts","./designid.config.js","./tokens.config.ts","./tokens.config.js"].filter(Boolean);for(let Y of X){let Z=oY(Y);if(nY(Z))return Z}throw Error(`Config file not found. Tried: ${X.join(", ")}`)}async function Y1(){let $=tY(process.argv.slice(2));if($.help){eY();return}try{let X=$1($.config);console.log(`Using config: ${X}`);let Y=await s$(X,$.output);if(Y.errors.length>0)console.log(`
|
|
409
423
|
❌ Build failed with ${Y.errors.length} error${Y.errors.length>1?"s":""}:`),Y.errors.forEach((Z)=>console.log(` - ${Z}`)),process.exit(1);if(console.log(`Processed ${Y.tokenCount} tokens`),console.log(`Duration: ${Y.duration}ms`),console.log(`Build completed successfully!
|
|
410
424
|
`),Y.cssFiles.length>0)console.log(`
|
|
411
425
|
Generated ${Y.cssFiles.length} CSS files:`),Y.cssFiles.forEach((Z)=>console.log(` - ${Z.fileName}`));if(Y.typescriptFiles.length>0)console.log(`
|
|
412
426
|
Generated ${Y.typescriptFiles.length} TypeScript files:`),Y.typescriptFiles.forEach((Z)=>console.log(` - ${Z.fileName}`));if(Y.javascriptFiles.length>0)console.log(`
|
|
413
427
|
Generated ${Y.javascriptFiles.length} JavaScript files:`),Y.javascriptFiles.forEach((Z)=>console.log(` - ${Z.fileName}`));if(Y.jsonFiles.length>0)console.log(`
|
|
414
428
|
Generated ${Y.jsonFiles.length} JSON files:`),Y.jsonFiles.forEach((Z)=>console.log(` - ${Z.fileName}`));if(Y.warnings.length>0)console.log(`
|
|
415
|
-
Warnings:`),Y.warnings.forEach((Z)=>console.log(` - ${Z}`))}catch(X){console.error("❌ Build failed:",X),process.exit(1)}}if(import.meta.url===`file://${process.argv[1]}`)
|
|
429
|
+
Warnings:`),Y.warnings.forEach((Z)=>console.log(` - ${Z}`))}catch(X){console.error("❌ Build failed:",X),process.exit(1)}}if(import.meta.url===`file://${process.argv[1]}`)Y1().catch(($)=>{console.error("Unexpected error:",$),process.exit(1)});export{Y1 as runCLI};
|
package/bin/watch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var z=($,Y)=>()=>($&&(Y=$($=0)),Y);import J0 from"colorjs.io";var j=z(()=>{B()});var
|
|
2
|
+
var z=($,Y)=>()=>($&&(Y=$($=0)),Y);import J0 from"colorjs.io";var j=z(()=>{B()});var m=z(()=>{B()});var c=z(()=>{B()});import{spawnSync as h$}from"child_process";import{existsSync as R,mkdirSync as v$,readFileSync as p$,unlinkSync as m$,writeFileSync as C0}from"fs";import{resolve as V0,join as O,basename as g0,normalize as T0,relative as y0,sep as f0,dirname as d$}from"path";async function u$(){return`${(await e()).$metaData?.tokenNamespace||"tokens"}.icons`}async function k$($){let W=O($,"designid.config.ts");if(R(O($,"designid.config.js")))m$(O($,"designid.config.js"));if(R(W)){let X=h$("bun",["build",W,"--outfile ./designid.config.js","--minify","--target","node","--packages","external","--no-bundle"],{stdio:"inherit",cwd:$,shell:!0});if(X.status!==0)console.error("Failed to compile designid.config.js with bun."),process.exit(X.status??1);if(X.status===0)return new Promise((q)=>q(!0))}}async function g($="json"){let{tokenNamespace:Y}=await b();return`${Y}-design-system.tokens.svg${$==="d.ts"||$==="js"?".config":""}.${$}`}function E$($){if(!R($))v$($,{recursive:!0})}async function t($,Y=!1){let W=T(),X;if(W.endsWith(".json"))X=JSON.parse(p$(W,"utf8").trim()??"{}");else{$=$??d$(W)+"/";let q=B$($);if(q&&(Y||!R(q)))await k$($);if(X=await import(q),X.default)X=X.default}return X}async function F(){let{baseDir:$}=await M(),Y=process.cwd(),X=O(Y,$),{buildDir:q,distDir:Z}=await M();try{E$(O(X,q)),E$(O(X,Z))}catch(w){console.error("Error creating directories:",w)}return X}function B$($){return $?O($,"designid.config.js"):O(process.cwd(),"designid.config.js")}function T(){let $=process.argv.find((H)=>H.startsWith("--config=")),[,Y]=$?.split("=")??[];if(Y)return Y;let W=process.cwd(),X=B$(W),q=O(W,"designid.config.ts"),Z=R(X),w=R(q);if(Z)return X;else if(w)return q;throw console.error("Config file not found"),Error("Config file not found")}async function M($=!1){let Y=T(),X=(await t(process.cwd(),$)).$paths;if(!X)throw console.error("Project paths not found"),Error("Project paths not found");return{configFile:Y,...X}}async function b(){let Y=(await t(process.cwd())).$metaData;if(!Y)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!Y.colorspace)Y.colorspace="hex";if(!Y.fontNamespace)Y.fontNamespace=`${Y.dsNamespace}.font`;if(!Y?.tokens?.css?.mediaQuery?.match)Y={...Y??{},tokens:{...Y.tokens??{},css:{...Y.tokens?.css??{},mediaQuery:{...Y.tokens?.css?.mediaQuery??{},match:"[data-theme]"}}}};if(Y?.tokens?.css?.mediaQuery&&typeof Y.tokens.css.mediaQuery.separateThemeFiles!=="boolean")Y.tokens.css.mediaQuery.separateThemeFiles=!1;if(!Y.dsNamespace)Y.dsNamespace=Y.tokenNamespace;let W=await u$();return{...Y,icons:Y.icons??{objectPath:W},dsNamespace:Y.dsNamespace}}async function e(){if(!s){let $=T();s=await t(process.cwd()),L$=$}return s}async function $$(){if(!r){let Y=(await e()).$metaData;if(!Y)throw console.error("Project metaData not found"),Error("Project metaData not found");if(!Y.dsNamespace)Y.dsNamespace=Y.tokenNamespace;let X=`${Y.tokenNamespace||"tokens"}.icons`;r={...Y,icons:Y.icons??{objectPath:X},dsNamespace:Y.dsNamespace}}return r}async function O$($=!1){if(!i){let W=(await e()).$paths;if(!W)throw console.error("Project paths not found"),Error("Project paths not found");i={configFile:L$,...W}}return i}async function y(){if(!a){let{distDir:$,assets:Y,buildDir:W}=await O$(!0),{fontNamespace:X,tokenNamespace:q,icons:Z}=await $$(),w=await F(),H=process.cwd(),E=O(H,$,"css");a={distDir:$,assets:Y,fontNamespace:X,__dirname:w,workspaceRoot:H,distCSSPath:E,buildDir:W,tokenNamespace:q,icons:Z}}return a}async function Y$(){if(!n){let{icons:$}=await $$();n=$}return n}var s=null,L$=null,r=null,i=null,a=null,n=null;var f=z(()=>{B()});var _$=z(()=>{f()});async function X$($){let Y=await Y$();$=$.replace(/<\?xml[^>]*\?>\s*/,""),$=$.replace(/<!DOCTYPE [^>]*>\s*/,"");let W=$.match(/<svg[^>]*>/),X=$.match(/viewBox="([\d\s.]+)"/),[q]=W??[],Z=q;if(q&&Z){let H=Y?.style?.fill,E=/id="[^"]*"/.test(q);if(!Z.includes("xmlns="))Z=Z.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"');if(!E&&H)Z=Z.replace("<svg",`<svg id="${H}"`);else if(E&&H)Z=Z.replace(/id="[^"]*"/,`id="${H}"`)}if(X&&q&&Z){let H=X[1].split(" ").map(Number),E=H[2],_=H[3],U=Y?.size??24,Q=E/_*U;$=$.replace(/height="[\d.]+px?"/,`height="${U}px"`),$=$.replace(/width="[\d.]+px?"/,`width="${Q}px"`);let P=/width="[\d.]+(px)?"/.test(q),I=/height="[\d.]+(px)?"/.test(q);if(!P)Z=Z.replace("<svg",`<svg width="${Q}px"`);else Z=Z.replace(/width="[\d.]+(px)?"/,`width="${Q}px"`);if(!I)Z=Z.replace("<svg",`<svg height="${U}px"`);else Z=Z.replace(/height="[\d.]+(px)?"/,`height="${U}px"`);$=$.replace(q,Z)}if(!$?.match(/data-style="([^"]*)"/)&&Y?.style?.type)$=$.replace("<svg ",`<svg data-style="${Y.style.type}" `);return $}var w$=z(()=>{B()});var R$=z(()=>{f();B()});var Z$=z(()=>{B()});var M$=()=>{};import G2 from"colorjs.io";var W$=z(()=>{M$();j()});var h=z(()=>{B()});var q$=z(()=>{B()});import{readFileSync as o$,mkdirSync as t$}from"fs";import{writeFile as N$,readdir as e$,mkdir as $0}from"fs/promises";import{resolve as Y0,relative as x$,join as U$,dirname as X0}from"path";import Z0 from"lodash";async function F$($){let Y=await e$($,{withFileTypes:!0}),W=await Promise.all(Y.map((X)=>{let q=Y0($,X.name);return X.isDirectory()?F$(q):q}));return Array.prototype.concat(...W)}async function P$(){let{assets:$,icons:Y,tokenNamespace:W,__dirname:X,buildDir:q}=await y(),Z=U$(X,$?.icons?.sourceDir??"icons"),w="build",H=$?.icons?.distDir??"build",E=U$(X,H),_=U$(X,q,"icons");if(!$?.icons?.sourceDir){console.error("Skipping icon build: iconsDir is not defined in the project paths.");return}let U=(await F$(Z)).filter((G)=>G.endsWith(".svg")),I=(await Promise.all(U.map(async(G)=>{let K=o$(G,"utf8").replace(/(\s+(?=(?:[^"]*"[^"]*")*[^"]*$))/g," ").trim()??"";K=await X$(K);let A=x$(Z,G).split("/").pop(),S=(K.match(/name="(.*?)"/)??[])[1]??A?.replace(".svg",""),v=(K.match(/data-style="(.*?)"/)??[])[1],b$=(K.match(/description="(.*?)"/)??[])[1],[G$]=K.match(/<svg[^>]*>/)??[],[,V$]=G$?.match(/width="([\d.]+)(px)?"/)??[],[,g$]=G$?.match(/height="([\d.]+)(px)?"/)??[];if(v!=="animated"&&v!=="custom")return{path:G,folder:x$(Z,G).split("/").slice(0,-1).concat(S),file:A,style:v,content:K,name:S,dimensions:{width:Number(V$),height:Number(g$)},description:b$??""};return}))).filter((G)=>G!==void 0).reduce((G,K)=>{if(K?.style!=="animated"&&K?.style!=="custom"&&K)K$(G,K.folder.join("."),{$type:"icon",$name:K.name,$description:K.description,$style:K.style,$value:K.content,$dimensions:K.dimensions,...W0(G,K.folder.join("."))});return G},{}),N=Y?.objectPath??`${W}.icons`;Object.keys(I).forEach(async(G)=>{let K=`${_}/${G}`,A=`${K}/svg.${G}.tokens.json`;await $0(K,{recursive:!0});let S=K$({},`${N}${N?".":""}${G}`,I[G]);await N$(A,JSON.stringify(S,null,2),{flag:"w",encoding:"utf-8"})});let L=`${E}/tokens/${await g("json")}`,J=X0(L);t$(J,{recursive:!0});let x=K$({},N,I);await N$(L,JSON.stringify(x,null,2),{flag:"w",encoding:"utf-8"})}var K$,W0,x2;var S$=z(()=>{B();({set:K$,get:W0}=Z0);x2=P$().catch(($)=>{console.error($),process.exit(1)})});var j$=z(()=>{h()});var D$=z(()=>{S$();h();j$();W$();q$();Z$()});var B=z(()=>{j();m();c();j();f();_$();w$();R$();m();c();Z$();W$();h();q$();D$()});B();import{exec as O0}from"child_process";import{join as C$}from"path";import _0 from"chokidar";if(process.argv.includes("--help")||process.argv.includes("-h"))console.log(`
|
|
3
3
|
Watch Tokens - File watcher for design token changes
|
|
4
4
|
|
|
5
5
|
Usage:
|
|
@@ -15,8 +15,8 @@ Example:
|
|
|
15
15
|
bun src/scripts/watch-tokens.ts --config=./custom-config.ts
|
|
16
16
|
bun src/scripts/watch-tokens.ts --dev
|
|
17
17
|
`),process.exit(0);async function w0(){let $=await F(),{distDir:Y,buildDir:W}=await M(),X=[/node_modules/,/dist/,/build/,C$($,Y),C$($,W)],q=_0.watch(["**/*.tokens.json","designid.config.ts"],{ignored:X,persistent:!0}),Z,w=300,H=!1,E=()=>{if(H){console.log(`[${new Date().toLocaleTimeString()}] Build already in progress, skipping...`);return}clearTimeout(Z),Z=setTimeout(()=>{H=!0,console.clear(),process.stdout.write("\x1Bc"),console.log(`[${new Date().toLocaleTimeString()}] Changes detected. Re-building tokens...
|
|
18
|
-
`);let U=(()=>{let
|
|
19
|
-
❌ Build failed: ${
|
|
18
|
+
`);let U=(()=>{let L=process.argv.find((J)=>J.startsWith("--config="));return L?L.split("=")[1]:""})(),Q=(()=>{return process.argv.find((L)=>L==="--dev")??null})(),P=U?`--config=${U}`:"",I=U?`CONFIG=${U}`:"",N=Q?`make build ${I}`:`bun run build ${P}`;O0(N,{cwd:process.cwd()},(L,J,x)=>{if(H=!1,L){console.error(`
|
|
19
|
+
❌ Build failed: ${L.message}`);return}if(x&&x.trim())console.warn(`⚠️ Warnings:
|
|
20
20
|
${x}`);if(J&&J.trim()){let G=J.split(`
|
|
21
21
|
`).filter((K)=>{let A=K.trim();return A&&(A.includes("✅")||A.includes("❌")||A.includes("Generated")||A.includes("Build completed")||A.includes("PASSED")||A.includes("FAILED"))});if(G.length>0)console.log(`
|
|
22
22
|
${G.join(`
|