@designid/tokens 0.4.6 → 1.0.0
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 +413 -76
- package/bin/watch.js +25 -2
- package/package.json +8 -11
- package/types/design-tokens.ts +1083 -0
- package/types/files.d.ts +116 -3
- package/types/index.d.ts +79 -0
- package/types/token.d.ts +31 -0
- package/types/typography.d.ts +51 -0
- package/types/utils.d.ts +49 -0
- package/bin/build-icons.js +0 -2
- package/example/tokens/border/composition.tokens.json +0 -31
- package/example/tokens/colors/brand/primary.tokens.json +0 -44
- package/example/tokens/colors/icon/mono.tokens.json +0 -15
- package/example/tokens/effect/shadow.tokens.json +0 -41
- package/example/tokens/font/family.tokens.json +0 -110
- package/example/tokens/font/h1.tokens.json +0 -59
- package/example/tokens/foundation.tokens.json +0 -145
package/bin/build.js
CHANGED
|
@@ -1,78 +1,415 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
&${C$(L)} {
|
|
10
|
-
`,x.forEach((X)=>{H+=` --${_(X?.name??"")}: ${X.value};
|
|
11
|
-
`}),H+=` }
|
|
12
|
-
`});H+=` }
|
|
13
|
-
`,H+=`}
|
|
14
|
-
|
|
15
|
-
`}),H}import{copyFileSync as Nw,existsSync as Rw,mkdirSync as Ww,statSync as Ow}from"fs";import{writeFile as Tw}from"fs/promises";import{join as K}from"path";var{baseDir:pw,distDir:R$,assets:i}=await M(),{fontNamespace:M$}=await B(),h=await p(),Ew=K(h,R$,"css"),H$=i?.fonts?.sourceDir?K(h,i.fonts.sourceDir):null,U$=K("assets","fonts"),N$=i?.fonts?.distDir??U$,Hw=N$===U$?K(h,R$,i?.fonts?.distDir??U$):K(h,N$);async function O$($){try{if(!$||!H$)return;let w="";for(let G of $){if(!G)continue;if(w+=`/**** ${G.family} ${G.style} ****/
|
|
16
|
-
`,G.linkHref){let U=await(await fetch(G.linkHref)).text();w+=`${U.replace(/\s+/g," ").replace(/:\s+/g,":")}
|
|
17
|
-
`}else if(G?.src&&H$){let E=G.directory??G.family.toLowerCase().replace(/\s+/g,"-"),U=K(H$,E,G.src);try{if(!Rw(U)||!Ow(U).isFile())continue}catch{continue}Ww(K(Hw,E),{recursive:!0}),Nw(K(H$,E,G.src),K(Hw,E,G.src));let H=i?.fonts?.cssImportPath??null;if(!H)H=p$(K(h,N$,G.src),K(pw),K(h,R$,"/css"),K(h,U$,E,G.src));else H=K(i?.fonts?.cssImportPath??"assets/fonts",E,G.src);w+=`@font-face {
|
|
18
|
-
font-family: "${G.family}";
|
|
19
|
-
font-style: ${G.faceStyle};
|
|
20
|
-
font-weight: ${G.weight};
|
|
21
|
-
src: url("${H}") format("${G.format}");
|
|
2
|
+
var o0=Object.defineProperty;var t0=($,X)=>{for(var Y in X)o0($,Y,{get:X[Y],enumerable:!0,configurable:!0,set:(Z)=>X[Y]=()=>Z})};var N=($,X)=>()=>($&&(X=$($=0)),X);import n$ from"colorjs.io";function C($,X){if(!$)return $;if(X&&X.type!=="color")return $;if(typeof $==="string")$=new n$($);if(typeof $?.to!=="function")return $;return $.to("srgb").toString({format:"hex"})}function h($){try{if($)return new n$($),!0;return!1}catch{return!1}}var s=N(()=>{P()});var H$=N(()=>{P()});var L$=N(()=>{P()});import{spawnSync as X2}from"child_process";import{existsSync as v,mkdirSync as Z2,readFileSync as W2,unlinkSync as q2,writeFileSync as W1}from"fs";import{resolve as U1,join as j,basename as K1,normalize as G1,relative as H1,sep as z1,dirname as U2}from"path";async function K2(){return`${(await M$()).$metaData?.tokenNamespace||"tokens"}.icons`}async function G2($){let Y=j($,"designid.config.ts");if(v(j($,"designid.config.js")))q2(j($,"designid.config.js"));if(v(Y)){let Z=X2("bun",["build",Y,"--outfile ./designid.config.js","--minify","--target","node","--packages","external"],{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 u($="json"){let{tokenNamespace:X}=await $$();return`${X}-design-system.tokens.svg${$==="d.ts"||$==="js"?".config":""}.${$}`}function e$($){if(!v($))Z2($,{recursive:!0})}async function R$($,X=!1){let Y=e(),Z;if(Y.endsWith(".json"))Z=JSON.parse(W2(Y,"utf8").trim()??"{}");else{$=$??U2(Y)+"/";let W=Y0($);if(W&&(X||!v(W)))await G2($);if(Z=await import(W),Z.default)Z=Z.default}return Z}async function t(){let{baseDir:$}=await d(),X=process.cwd(),Z=j(X,$),{buildDir:W,distDir:q}=await d();try{e$(j(Z,W)),e$(j(Z,q))}catch(U){console.error("Error creating directories:",U)}return Z}function Y0($){return $?j($,"designid.config.js"):j(process.cwd(),"designid.config.js")}function e(){let $=process.argv.find((K)=>K.startsWith("--config=")),[,X]=$?.split("=")??[];if(X)return X;let Y=process.cwd(),Z=Y0(Y),W=j(Y,"designid.config.ts"),q=v(Z),U=v(W);if(q)return Z;else if(U)return W;throw console.error("Config file not found"),Error("Config file not found")}async function d($=!1){let X=e(),Z=(await R$(process.cwd(),$)).$paths;if(!Z)throw console.error("Project paths not found"),Error("Project paths not found");return{configFile:X,...Z}}async function $$(){let X=(await R$(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 K2();return{...X,icons:X.icons??{objectPath:Y},dsNamespace:X.dsNamespace}}async function M$(){if(!_$){let $=e();_$=await R$(process.cwd()),X0=$}return _$}async function N$(){if(!O$){let X=(await M$()).$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`;O$={...X,icons:X.icons??{objectPath:Z},dsNamespace:X.dsNamespace}}return O$}async function Z0($=!1){if(!w$){let Y=(await M$()).$paths;if(!Y)throw console.error("Project paths not found"),Error("Project paths not found");w$={configFile:X0,...Y}}return w$}async function T(){if(!Q$){let{distDir:$,assets:X,buildDir:Y}=await Z0(!0),{fontNamespace:Z,tokenNamespace:W,icons:q}=await N$(),U=await t(),K=process.cwd(),G=j(K,$,"css");Q$={distDir:$,assets:X,fontNamespace:Z,__dirname:U,workspaceRoot:K,distCSSPath:G,buildDir:Y,tokenNamespace:W,icons:q}}return Q$}async function F$(){if(!I$){let{icons:$}=await N$();I$=$}return I$}var _$=null,X0=null,O$=null,w$=null,Q$=null,I$=null;var Y$=N(()=>{P()});var W0=N(()=>{Y$()});async function x$($){let X=await F$();$=$.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 q0=N(()=>{P()});var H0=N(()=>{Y$();P()});import{copyFileSync as L2,existsSync as E2,mkdirSync as z0,statSync as _2}from"fs";import{writeFile as O2}from"fs/promises";import{join as x,relative as w2}from"path";async function P$($,X){try{let{assets:Y,workspaceRoot:Z,distDir:W,__dirname:q}=await T(),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
|
+
`,_.linkHref){let J=await(await fetch(_.linkHref)).text();z+=`${J.replace(/\s+/g," ").replace(/:\s+/g,":")}
|
|
4
|
+
`}else if(_?.src&&U){let O=_.directory??_.family.toLowerCase().replace(/\s+/g,"-"),J=x(U,O,_.src);try{if(!E2(J)||!_2(J).isFile()){console.warn(`Font file not found: ${J}`);continue}}catch{console.warn(`Error accessing font file: ${J}`);continue}try{z0(x(A,O),{recursive:!0}),L2(x(U,O,_.src),x(A,O,_.src))}catch(Q){console.warn(`Error copying font file ${_.src}:`,Q instanceof Error?Q.message:Q);continue}let w;if(Y?.fonts?.cssImportPath)w=x(Y.fonts.cssImportPath,O,_.src).replace(/\\/g,"/");else{let{distCSSPath:Q}=await T(),I=X?x(X,"css"):Q,F=w2(I,A);w=x(F,O,_.src).replace(/\\/g,"/")}z+=`@font-face {
|
|
5
|
+
font-family: "${_.family}";
|
|
6
|
+
font-style: ${_.faceStyle};
|
|
7
|
+
font-weight: ${_.weight};
|
|
8
|
+
src: url("${w}") format("${_.format}");
|
|
22
9
|
}
|
|
23
|
-
`}}let
|
|
24
|
-
${
|
|
25
|
-
`,G=`${w}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
`
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
${
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
`,H
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
`}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
${
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
10
|
+
`}}let{distCSSPath:B}=await T(),E=X?x(X,"css"):B,L=`${E}/fonts.css`;z0(E,{recursive:!0}),await O2(L,z,{flag:"w",encoding:"utf-8"})}catch(Y){console.error("Error appending typography tokens:",Y)}}var j$=N(()=>{P()});function k($){if(typeof $!=="string"||!$.startsWith("{")||!$.endsWith("}"))return!1;let X=$.slice(1,-1);return!X.includes("{")&&!X.includes("}")&&X.trim()!==""}function c($){if(typeof $!=="string")return!1;let X=/\{[^}]+\}/g,Y=$.match(X);return!!(Y&&Y.length>0&&$.length>Y.join("").length)}function X$($){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 A0($){return!!$.$extensions?.$mode}function B0($){return!!($.$extensions?.$generators&&Array.isArray($.$extensions.$generators))}function L0($){return!!($.$extensions?.$breakpoints&&typeof $.$extensions.$breakpoints==="object")}function E0($,X){return`${$}${X}`}function _0($){return typeof $==="object"&&$!==null&&"$value"in $}function O0($){return typeof $==="object"&&$!==null&&!("$value"in $)}var w0=()=>{};function Q0($){if(typeof $!=="string")return!1;let X=$.trim();return X.startsWith("<svg")&&X.includes("</svg>")}function I0($){if(typeof $!=="string")return!1;return $.startsWith("data:image/png;base64,")||$.startsWith("iVBORw0KGgo")}function J0($){if(typeof $!=="string")return!1;return $.startsWith("data:image/jpeg;base64,")||$.startsWith("data:image/jpg;base64,")||$.startsWith("/9j/")}function I2($){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 J2($){if($.startsWith("data:image/png;base64,"))return $;return`data:image/png;base64,${$}`}function R2($){if($.startsWith("data:image/jpeg;base64,")||$.startsWith("data:image/jpg;base64,"))return $;return`data:image/jpeg;base64,${$}`}function S$($){if(!$||typeof $!=="string")return $;if($.startsWith("data:"))return $;if(Q0($))return I2($);else if(I0($))return J2($);else if(J0($))return R2($);return $}function M2($){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 y($){return Q0($)||I0($)||J0($)||M2($)}import{readFileSync as N2,readdirSync as F2,statSync as x2}from"fs";import{join as P2}from"path";import M0 from"colorjs.io";function D$($){let X={};function Y(Z){let W=F2(Z);for(let q of W){let U=P2(Z,q);if(x2(U).isDirectory())Y(U);else if(q.endsWith(".tokens.json"))try{let G=N2(U,"utf-8");if(!G.trim())continue;let H=JSON.parse(G);N0(X,H)}catch(G){console.warn(`Failed to load token file: ${U}`,G)}}}return Y($),X}function N0($,X){for(let Y in X)if(X[Y]&&typeof X[Y]==="object"&&!Array.isArray(X[Y])){if(!$[Y])$[Y]={};N0($[Y],X[Y])}else $[Y]=X[Y]}function C$($,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(_0(K)){let z={path:G,name:H,type:K.$type,value:K.$value,description:K.$description,extensions:K.$extensions?{mode:A0(K)?K.$extensions.$mode:K.$extensions.mode?K.$extensions.mode:void 0,generators:B0(K)?K.$extensions.$generators:K.$extensions.generators?K.$extensions.generators:void 0,breakpoints:L0(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(O0(K))Z(K,G)}}return Z($),Y}function b$($,X={}){let Y=[...$],Z=new Map($.map((K)=>[K.name,K]));if(X.generateModes||X.generateDerivedTokens||X.generateBreakpointTokens)for(let K of $){let G=R0(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=R0(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=j2(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
|
+
${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}
|
|
13
|
+
|
|
14
|
+
`;let H=U.get("light")||[];if(H.length>0){H.sort(),G+=`${Y} {
|
|
15
|
+
${H.join(`
|
|
16
|
+
`)}
|
|
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
|
+
&${_} {
|
|
19
|
+
${E.map((O)=>` ${O}`).join(`
|
|
20
|
+
`)}
|
|
21
|
+
}
|
|
22
|
+
`}G+=`}
|
|
23
|
+
`}if(W&&K.size>0)for(let[E,L]of K)L.sort(),G+=`
|
|
24
|
+
${E} {
|
|
25
|
+
${Y} {
|
|
26
|
+
${L.map((_)=>` ${_}`).join(`
|
|
27
|
+
`)}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;let z=[{fileName:"tokens.css",content:G}],A=D0($,X);z.push(...A);let B=b0($,X);return z.push(...B),z}function V2($,X){let Y=[];for(let W of $){let U=` ${W.cssVar||W$(W,X)}: ${S(W.value,W.type)};`;Y.push(U)}let Z="";if(X.customHeader)Z+=`${X.customHeader}
|
|
31
|
+
|
|
32
|
+
`;if(Y.length>0)Y.sort(),Z+=`${X.rootSelector||":root"} {
|
|
33
|
+
${Y.join(`
|
|
34
|
+
`)}
|
|
35
|
+
}
|
|
36
|
+
`;return{fileName:"theme.css",content:Z}}function g2($,X){let Y=[],Z=new Map,W=[],q=new Set(["dark","light"]);for(let H of $){if(q$(H))continue;if(typeof H.value==="string"&&y(H.value))continue;if(T$(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=Z$(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=V2(z,{...X,separateThemeFiles:!1,rootSelector:A});Y.push({...B,fileName:`tokens.${H}.css`,theme:H})}let U=T2($,X);Y.push(...U);let K=D0($,X);Y.push(...K);let G=b0($,X);return Y.push(...G),Y}function T2($,X){let Y=new Map;for(let q of $){let U=q$(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
|
+
* Design System Tokens - Responsive Breakpoints
|
|
38
|
+
* Generated: ${new Date().toISOString()}
|
|
39
|
+
*
|
|
40
|
+
* This file contains CSS custom properties for responsive breakpoints.
|
|
41
|
+
* Each media query section overrides tokens for specific screen sizes.
|
|
42
|
+
*/
|
|
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||W$(z,X)}: ${S(z.value,z.type)};`;H.push(B)}if(H.length>0)H.sort(),Z+=`${q} {
|
|
45
|
+
[data-theme="${K}"] {
|
|
46
|
+
${H.join(`
|
|
47
|
+
`)}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
`}}return[{fileName:"tokens.breakpoints.css",content:Z.trim()}]}function D0($,X){let Y=new Map;for(let W of $)if(typeof W.value==="string"&&y(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=j0(q,W,X);Z.push({fileName:"tokens.icons.css",content:U})}else for(let[W,q]of Y){let U=j0(q,W,X);Z.push({fileName:`tokens.icons.${W}.css`,content:U})}return Z}function j0($,X,Y){let Z=`/**
|
|
52
|
+
* Design System Tokens - Icons (${X})
|
|
53
|
+
* Generated: ${new Date().toISOString()}
|
|
54
|
+
*
|
|
55
|
+
* This file contains CSS custom properties for icon tokens.
|
|
56
|
+
* Icons are provided as data URIs for direct embedding.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
`,W=[];for(let q of $){let K=` ${q.cssVar||W$(q,Y)}: ${S(q.value,q.type)};`;W.push(K)}if(W.length>0){W.sort();let q=X==="light"?":root":`[data-theme="${X}"]`;Z+=`${q} {
|
|
60
|
+
${W.join(`
|
|
61
|
+
`)}
|
|
62
|
+
}
|
|
63
|
+
`}return Z}function W$($,X){let Z=$.name.split("@")[0].replace(/\.$/,"").replace(/\.+/g,"."),W=C0(Z,X.hooks);return`--${X.prefix||r}-${W.replace(/\./g,"-")}`}function C0($,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 b0($,X){let Y=new Map;for(let W of $)if(T$(W)){if(q$(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=y2(q,W,X);Z.push({fileName:`tokens.typography.${W}.css`,content:U})}return Z}function y2($,X,Y){let Z=`/**
|
|
64
|
+
* Design System Tokens - Typography (${X})
|
|
65
|
+
* Generated: ${new Date().toISOString()}
|
|
66
|
+
*
|
|
67
|
+
* This file contains CSS custom properties for typography tokens.
|
|
68
|
+
* Includes fontSize, fontWeight, fontFamily, lineHeight, and typography compositions.
|
|
69
|
+
*/
|
|
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||W$(G,Y)}: ${S(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
|
+
${K.join(`
|
|
73
|
+
`)}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
`}else{let G=q.startsWith("(")?q:`(${q})`;Z+=`@media ${G} {
|
|
77
|
+
`;let H=X==="light"?":root":`[data-theme="${X}"]`;Z+=` ${H} {
|
|
78
|
+
${K.sort().map((z)=>` ${z}`).join(`
|
|
79
|
+
`)}
|
|
80
|
+
}
|
|
81
|
+
`,Z+=`}
|
|
82
|
+
|
|
83
|
+
`}}return Z}function S($,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 S(Z.$value,Z.$type||X)}}let Y=String($);switch(X){case"color":return f2(Y);case"dimension":return h2(Y);case"duration":return v2(Y);case"fontFamily":return p2(Y);case"fontWeight":return m2(Y);case"cubicBezier":return d2($);case"shadow":return u2($);case"border":return k2($);case"typography":return c2($);case"composition":return y$($);default:if(Y.startsWith("data:"))return`"${Y}"`;return Y}}function f2($){if($.startsWith("oklch(")||$.startsWith("rgb(")||$.startsWith("rgba(")||$.startsWith("hsl(")||$.startsWith("hsla(")||$.startsWith("#"))return $;return $}function h2($){if(/^\d+(\.\d+)?(px|rem|em|%|vh|vw|vmin|vmax)$/.test($))return $;if(/^\d+(\.\d+)?$/.test($))return`${$}rem`;return $}function v2($){if(/^\d+(\.\d+)?(s|ms)$/.test($))return $;if(/^\d+(\.\d+)?$/.test($))return`${$}ms`;return $}function p2($){if(($.includes(",")||$.includes(" "))&&!$.startsWith('"')&&!$.startsWith("'"))return`"${$}"`;return $}function m2($){return{thin:"100","extra-light":"200",light:"300",normal:"400",medium:"500","semi-bold":"600",bold:"700","extra-bold":"800",black:"900"}[$]||$}function d2($){if(Array.isArray($)&&$.length===4)return`cubic-bezier(${$.join(", ")})`;return String($)}function u2($){if(Array.isArray($))return $.map((X)=>S0(X)).join(", ");return S0($)}function S0($){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(${`--${r}-${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 k2($){if(typeof $==="object"&&$!==null){let X=$;return`${X.width||"1px"} ${X.style||"solid"} ${X.color||"transparent"}`}return String($)}function c2($){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 y$($){if(typeof $!=="object"||$===null)return String($);if(Array.isArray($))return $.map((Y)=>y$(Y)).join(", ");let X=$;if(X.offsetX!==void 0&&X.offsetY!==void 0)return V0(X);if(X.width!==void 0&&X.style!==void 0&&X.color!==void 0)return l2(X);if(X.blur!==void 0||X.saturate!==void 0||X.brightness!==void 0)return r2(X);if(X.fontSize!==void 0||X.fontFamily!==void 0)return i2(X);return s2(X)}function V0($){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 l2($){let X=M($.width)||"1px",Y=M($.style)||"solid",Z=M($.color)||"transparent";return`${X} ${Y} ${Z}`}function r2($){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 i2($){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 s2($){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=V0(U);if(K)X.push(K)}else{let K=y$(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 q$($){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 U$($){let X=$?.$name||"Design System",Y=$?.$version||"1.0.0",Z=new Date().toISOString();return`/**
|
|
84
|
+
* ${X} - CSS Custom Properties
|
|
85
|
+
* Version: ${Y}
|
|
86
|
+
* Generated: ${Z}
|
|
87
|
+
*
|
|
88
|
+
* This file contains CSS custom properties (CSS variables) generated from design tokens.
|
|
89
|
+
* Do not edit this file directly - it will be overwritten.
|
|
90
|
+
*/`}function a2($){let X=$.replace(/\r?\n|\r/g,"").replace(/\s+/g," ").trim();return`data:image/svg+xml;base64,${Buffer.from(X,"utf8").toString("base64")}`}function f$($,X={}){let{customHeader:Y,objectPath:Z="universe.custom.path.icons"}=X,W="--"+Z.replace(/\./g,"-"),q="";if(Y)q+=Y+`
|
|
91
|
+
|
|
92
|
+
`;else q+=`/**
|
|
93
|
+
* Icon CSS - Base64 Encoded SVG Icons as CSS Custom Properties
|
|
94
|
+
* Generated: ${new Date().toISOString()}
|
|
95
|
+
*
|
|
96
|
+
* This file contains CSS custom properties (variables) for icons with base64 encoded SVG values.
|
|
97
|
+
* Follows the object path structure: ${Z}.{category}.{IconName}
|
|
98
|
+
* Variable names may be shortened by configured hooks.
|
|
99
|
+
* Usage examples:
|
|
100
|
+
* background-image: var(--icon-actions-delete);
|
|
101
|
+
* content: var(--icon-misc-person);
|
|
102
|
+
*
|
|
103
|
+
* Do not edit this file directly - it will be overwritten.
|
|
104
|
+
*/
|
|
105
|
+
|
|
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=C0(H,X.hooks);let z=a2(K.value);q+=` ${H}: url("${z}");
|
|
108
|
+
`}return q+=`}
|
|
109
|
+
`,{fileName:"tokens.icons.css",content:q.trim()}}var K$=N(()=>{P()});import{readFileSync as n2}from"fs";import{join as g0}from"path";async function h$(){try{let{assets:$}=await d(!0),{icons:X}=await $$(),Y=await t(),Z=$?.icons?.distDir??"build",W=g0(Y,Z),q=g0(W,"tokens",await u("json")),U=JSON.parse(n2(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 v$($,X={}){let{generateTypes:Y=!0,generateConsts:Z=!0}=X,W=X.icons;if(!W)W=await h$();let q={...X,icons:W},U=[];if(Y)U.push({fileName:"tokens.types.ts",content:o2($,q),type:"types"});if(Z)U.push({fileName:"tokens.constants.ts",content:t2($,q),type:"constants"});return U.push({fileName:"index.ts",content:e2(U),type:"index"}),U}function o2($,X){let{tokenInterface:Y="DesignTokens",includeJSDoc:Z=!0,icons:W=[]}=X,q=p$("Type Definitions");if(q+=$Y($,Z),q+=YY($,Z),W.length>0)q+=XY(W,Z);return q+=ZY($,Y,Z),q+=qY($,Z),q}function t2($,X){let{includeJSDoc:Y=!0,icons:Z=[]}=X,W=p$("Token Constants"),q="TokenPaths, CSSVariableNames";if(Z.length>0)q+=", IconNames, IconCategories, Icon";if(W+=`import type { ${q} } from './tokens.types';
|
|
110
|
+
|
|
111
|
+
`,W+=UY($,Y),W+=GY($,Y),Z.length>0)W+=KY(Z,Y);return W+=HY($,Y),W}function e2($){let X=p$("Main Export");if($.some((Y)=>Y.type==="types"))X+=`export type * from './tokens.types';
|
|
112
|
+
`;if($.some((Y)=>Y.type==="constants"))X+=`export * from './tokens.constants';
|
|
113
|
+
`;return X+=`
|
|
114
|
+
`,X}function $Y($,X){let Y=$.map((W)=>`"${W.name}"`).join(`
|
|
115
|
+
| `),Z="";if(X)Z+=`/**
|
|
116
|
+
* All available token paths as string literals
|
|
117
|
+
*/
|
|
118
|
+
`;return Z+=`export type TokenPaths =
|
|
119
|
+
| ${Y};
|
|
120
|
+
|
|
121
|
+
`,Z}function YY($,X){let Y=zY($),Z="";for(let[W,q]of Y){let U=`${BY(W)}TokenValue`,K=new Set(q.map((H)=>i(H.value))),G=Array.from(K).join(`
|
|
122
|
+
| `);if(X)Z+=`/**
|
|
123
|
+
* Possible values for ${W} tokens
|
|
124
|
+
*/
|
|
125
|
+
`;Z+=`export type ${U} =
|
|
126
|
+
| ${G};
|
|
127
|
+
|
|
128
|
+
`}return Z}function XY($,X){let Y="",Z=$.map((U)=>`"${U.name}"`).join(`
|
|
129
|
+
| `);if(X)Y+=`/**
|
|
130
|
+
* All available icon names as string literals
|
|
131
|
+
*/
|
|
132
|
+
`;Y+=`export type IconNames =
|
|
133
|
+
| ${Z};
|
|
134
|
+
|
|
135
|
+
`;let q=[...new Set($.map((U)=>U.category))].map((U)=>`"${U}"`).join(`
|
|
136
|
+
| `);if(X)Y+=`/**
|
|
137
|
+
* All available icon categories
|
|
138
|
+
*/
|
|
139
|
+
`;if(Y+=`export type IconCategories =
|
|
140
|
+
| ${q};
|
|
141
|
+
|
|
142
|
+
`,X)Y+=`/**
|
|
143
|
+
* Icon data structure
|
|
144
|
+
*/
|
|
145
|
+
`;return Y+=`export interface Icon {
|
|
146
|
+
`,Y+=` /** Icon name */
|
|
147
|
+
`,Y+=` name: string;
|
|
148
|
+
`,Y+=` /** Icon category */
|
|
149
|
+
`,Y+=` category: string;
|
|
150
|
+
`,Y+=` /** SVG content */
|
|
151
|
+
`,Y+=` value: string;
|
|
152
|
+
`,Y+=` /** Icon description */
|
|
153
|
+
`,Y+=` description?: string;
|
|
154
|
+
`,Y+=` /** Icon style */
|
|
155
|
+
`,Y+=` style?: string;
|
|
156
|
+
`,Y+=` /** Icon dimensions */
|
|
157
|
+
`,Y+=` dimensions?: {
|
|
158
|
+
`,Y+=` width: number;
|
|
159
|
+
`,Y+=` height: number;
|
|
160
|
+
`,Y+=` };
|
|
161
|
+
`,Y+=`}
|
|
162
|
+
|
|
163
|
+
`,Y}function ZY($,X,Y){let Z="";if(Y)Z+=`/**
|
|
164
|
+
* Design tokens interface with all token paths and their values
|
|
165
|
+
*/
|
|
166
|
+
`;Z+=`export interface ${X} {
|
|
167
|
+
`;for(let W of $){if(Y&&W.description)Z+=` /** ${W.description} */
|
|
168
|
+
`;Z+=` "${W.name}": ${i(W.value)};
|
|
169
|
+
`}return Z+=`}
|
|
170
|
+
|
|
171
|
+
`,Z+=WY($,`${X}Nested`,Y),Z}function WY($,X,Y){let Z=AY($),W="";if(Y)W+=`/**
|
|
172
|
+
* Design tokens interface with nested structure
|
|
173
|
+
*/
|
|
174
|
+
`;return W+=`export interface ${X} {
|
|
175
|
+
`,W+=T0(Z,1),W+=`}
|
|
176
|
+
|
|
177
|
+
`,W}function qY($,X){let Y=$.map((W)=>`"${W.cssVar}"`).join(`
|
|
178
|
+
| `),Z="";if(X)Z+=`/**
|
|
179
|
+
* All available CSS variable names
|
|
180
|
+
*/
|
|
181
|
+
`;return Z+=`export type CSSVariableNames =
|
|
182
|
+
| ${Y};
|
|
183
|
+
|
|
184
|
+
`,Z}function UY($,X){let Y="";if(X)Y+=`/**
|
|
185
|
+
* Object containing all token values
|
|
186
|
+
*/
|
|
187
|
+
`;Y+=`export const tokenValues = {
|
|
188
|
+
`;for(let Z of $){if(X&&Z.description)Y+=` /** ${Z.description} */
|
|
189
|
+
`;Y+=` "${Z.name}": ${JSON.stringify(Z.value)},
|
|
190
|
+
`}return Y+=`} as const;
|
|
191
|
+
|
|
192
|
+
`,Y}function KY($,X){let Y="";if(X)Y+=`/**
|
|
193
|
+
* Array of all available icons
|
|
194
|
+
*/
|
|
195
|
+
`;Y+=`export const icons: Icon[] = [
|
|
196
|
+
`;for(let W of $){if(Y+=` {
|
|
197
|
+
`,Y+=` name: "${W.name}",
|
|
198
|
+
`,Y+=` category: "${W.category}",
|
|
199
|
+
`,Y+=` value: ${JSON.stringify(W.value)},
|
|
200
|
+
`,W.description)Y+=` description: ${JSON.stringify(W.description)},
|
|
201
|
+
`;if(W.style)Y+=` style: "${W.style}",
|
|
202
|
+
`;if(W.dimensions)Y+=` dimensions: { width: ${W.dimensions.width}, height: ${W.dimensions.height} },
|
|
203
|
+
`;Y+=` },
|
|
204
|
+
`}if(Y+=`];
|
|
205
|
+
|
|
206
|
+
`,X)Y+=`/**
|
|
207
|
+
* Array of all icon names
|
|
208
|
+
*/
|
|
209
|
+
`;Y+=`export const iconNames: IconNames[] = [
|
|
210
|
+
`;for(let W of $)Y+=` "${W.name}",
|
|
211
|
+
`;Y+=`] as const;
|
|
212
|
+
|
|
213
|
+
`;let Z=[...new Set($.map((W)=>W.category))];if(X)Y+=`/**
|
|
214
|
+
* Array of all icon categories
|
|
215
|
+
*/
|
|
216
|
+
`;Y+=`export const iconCategories: IconCategories[] = [
|
|
217
|
+
`;for(let W of Z)Y+=` "${W}",
|
|
218
|
+
`;if(Y+=`] as const;
|
|
219
|
+
|
|
220
|
+
`,X)Y+=`/**
|
|
221
|
+
* Get icon by name
|
|
222
|
+
*/
|
|
223
|
+
`;if(Y+=`export function getIcon(name: IconNames): Icon | undefined {
|
|
224
|
+
`,Y+=` return icons.find(icon => icon.name === name);
|
|
225
|
+
`,Y+=`}
|
|
226
|
+
|
|
227
|
+
`,X)Y+=`/**
|
|
228
|
+
* Get icons by category
|
|
229
|
+
*/
|
|
230
|
+
`;return Y+=`export function getIconsByCategory(category: IconCategories): Icon[] {
|
|
231
|
+
`,Y+=` return icons.filter(icon => icon.category === category);
|
|
232
|
+
`,Y+=`}
|
|
233
|
+
|
|
234
|
+
`,Y}function GY($,X){let Y="";if(X)Y+=`/**
|
|
235
|
+
* Object mapping token paths to CSS variable names
|
|
236
|
+
*/
|
|
237
|
+
`;Y+=`export const cssVariableNames = {
|
|
238
|
+
`;for(let Z of $)Y+=` "${Z.name}": "${Z.cssVar}",
|
|
239
|
+
`;return Y+=`} as const;
|
|
240
|
+
|
|
241
|
+
`,Y}function HY($,X){let Y="";if(X)Y+=`/**
|
|
242
|
+
* Get the value of a design token
|
|
243
|
+
*/
|
|
244
|
+
`;if(Y+=`export function getTokenValue<T extends TokenPaths>(tokenPath: T): typeof tokenValues[T] {
|
|
245
|
+
return tokenValues[tokenPath];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
`,X)Y+=`/**
|
|
249
|
+
* Get the CSS variable name for a design token
|
|
250
|
+
*/
|
|
251
|
+
`;if(Y+=`export function getCSSVariableName<T extends TokenPaths>(tokenPath: T): typeof cssVariableNames[T] {
|
|
252
|
+
return cssVariableNames[tokenPath];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
`,X)Y+=`/**
|
|
256
|
+
* Get a CSS var() reference for a design token
|
|
257
|
+
*/
|
|
258
|
+
`;if(Y+=`export function getCSSVariableReference<T extends TokenPaths>(tokenPath: T): string {
|
|
259
|
+
return \`var(\${cssVariableNames[tokenPath]})\`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
`,X)Y+=`/**
|
|
263
|
+
* Check if a token path exists
|
|
264
|
+
*/
|
|
265
|
+
`;return Y+=`export function hasToken(tokenPath: string): tokenPath is TokenPaths {
|
|
266
|
+
return tokenPath in tokenValues;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
`,Y}function zY($){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 AY($){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=i(Y.value);W[U]=K}return X}function T0($,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+=T0(q,X+1),Y+=`${Z}};
|
|
271
|
+
`;else Y+=`${Z}${U}: ${q};
|
|
272
|
+
`}return Y}function i($){if(typeof $==="string")return`"${$}"`;else if(typeof $==="number")return $.toString();else if(typeof $==="boolean")return $.toString();else if(Array.isArray($)){let X=new Set($.map((Z)=>i(Z)));return`Array<${Array.from(X).join(" | ")}>`}else if($===null)return"null";else if($===void 0)return"undefined";else if(typeof $==="object"&&$!==null)return`{ ${Object.entries($).map(([Z,W])=>`${Z}: ${i(W)}`).join("; ")} }`;else return"unknown"}function BY($){if(!$||typeof $!=="string")return"";return $.charAt(0).toUpperCase()+$.slice(1)}function p$($){let X=new Date().toISOString();return`/**
|
|
273
|
+
* ${$}
|
|
274
|
+
* Generated: ${X}
|
|
275
|
+
*
|
|
276
|
+
* This file is auto-generated from design tokens.
|
|
277
|
+
* Do not edit this file directly - it will be overwritten.
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
`}var m$=N(()=>{P()});var r="did";var P=N(()=>{s();H$();L$();s();Y$();W0();q0();H0();H$();L$();j$();g$();K$();m$();u$()});import{readFileSync as _Y,mkdirSync as OY}from"fs";import{writeFile as f0,readdir as wY,mkdir as QY}from"fs/promises";import{resolve as IY,relative as h0,join as k$,dirname as JY}from"path";import RY from"lodash";async function v0($){let X=await wY($,{withFileTypes:!0}),Y=await Promise.all(X.map((Z)=>{let W=IY($,Z.name);return Z.isDirectory()?v0(W):W}));return Array.prototype.concat(...Y)}async function l$(){let{assets:$,icons:X,tokenNamespace:Y,__dirname:Z,buildDir:W}=await T(),q=k$(Z,$?.icons?.sourceDir??"icons"),U="build",K=$?.icons?.distDir??"build",G=k$(Z,K),H=k$(Z,W,"icons");if(!$?.icons?.sourceDir){console.error("Skipping icon build: iconsDir is not defined in the project paths.");return}let z=(await v0(q)).filter((w)=>w.endsWith(".svg")),E=(await Promise.all(z.map(async(w)=>{let Q=_Y(w,"utf8").replace(/(\s+(?=(?:[^"]*"[^"]*")*[^"]*$))/g," ").trim()??"";Q=await x$(Q);let I=h0(q,w).split("/").pop(),F=(Q.match(/name="(.*?)"/)??[])[1]??I?.replace(".svg",""),g=(Q.match(/data-style="(.*?)"/)??[])[1],s0=(Q.match(/description="(.*?)"/)??[])[1],[a$]=Q.match(/<svg[^>]*>/)??[],[,a0]=a$?.match(/width="([\d.]+)(px)?"/)??[],[,n0]=a$?.match(/height="([\d.]+)(px)?"/)??[];if(g!=="animated"&&g!=="custom")return{path:w,folder:h0(q,w).split("/").slice(0,-1).concat(F),file:I,style:g,content:Q,name:F,dimensions:{width:Number(a0),height:Number(n0)},description:s0??""};return}))).filter((w)=>w!==void 0).reduce((w,Q)=>{if(Q?.style!=="animated"&&Q?.style!=="custom"&&Q)c$(w,Q.folder.join("."),{$type:"icon",$name:Q.name,$description:Q.description,$style:Q.style,$value:Q.content,$dimensions:Q.dimensions,...MY(w,Q.folder.join("."))});return w},{}),L=X?.objectPath??`${Y}.icons`;Object.keys(E).forEach(async(w)=>{let Q=`${H}/${w}`,I=`${Q}/svg.${w}.tokens.json`;await QY(Q,{recursive:!0});let F=c$({},`${L}${L?".":""}${w}`,E[w]);await f0(I,JSON.stringify(F,null,2),{flag:"w",encoding:"utf-8"})});let _=`${G}/tokens/${await u("json")}`,O=JY(_);OY(O,{recursive:!0});let J=c$({},L,E);await f0(_,JSON.stringify(J,null,2),{flag:"w",encoding:"utf-8"})}var c$,MY,b4;var p0=N(()=>{P();({set:c$,get:MY}=RY);b4=l$().catch(($)=>{console.error($),process.exit(1)})});function d0($,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(U.length>0)Y.push({fileName:`light.${Z}`,content:r$(U,{...X,theme:"light"}),theme:"light"});if(K.length>0)Y.push({fileName:`dark.${Z}`,content:r$(K,{...X,theme:"dark"}),theme:"dark"})}else Y.push({fileName:`tokens.${Z}`,content:r$(q,X)});if(W.length>0)Y.push({fileName:`breakpoints.${Z}`,content:NY(W,$,X)});if(X.separateThemeFiles&&Y.length>1)Y.push({fileName:`index.${Z}`,content:CY(Y,X)});return Y}function NY($,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||FY(A.name),E=A.name.includes("@dark")?"dark":"light";if(typeof B==="string"&&B.includes("{")&&B.includes("}"))B=PY(B,K);if(!G[B])G[B]={};if(!G[B][E])G[B][E]={};let L=xY(A.name),_=jY(L,G$(A.value,K));G[B][E]={...G[B][E],..._}}let H=Object.keys(G).sort((A,B)=>{let E=m0(A),L=m0(B);return E-L}).reduce((A,B)=>{return A[B]=G[B],A},{}),z="";if(U)z+=`${U}
|
|
281
|
+
|
|
282
|
+
`;else z+=`/**
|
|
283
|
+
`,z+=` * Design Tokens - Breakpoints
|
|
284
|
+
`,z+=` * Auto-generated from design token definitions
|
|
285
|
+
`,z+=` * Do not edit this file directly
|
|
286
|
+
`,z+=` */
|
|
287
|
+
|
|
288
|
+
`;if(Z)z+=u0(H,W),z+=`
|
|
289
|
+
`;if(q==="es"){if(Z)z+=`const breakpoints: Tokens = ${f(H,W,0)};
|
|
290
|
+
|
|
291
|
+
`;else z+=`const breakpoints = ${f(H,W,0)};
|
|
292
|
+
|
|
293
|
+
`;z+=`export default breakpoints;
|
|
294
|
+
`}else z+=`const breakpoints = ${f(H,W,0)};
|
|
295
|
+
|
|
296
|
+
`,z+=`module.exports = breakpoints;
|
|
297
|
+
`,z+=`module.exports.default = breakpoints;
|
|
298
|
+
`;return z}function FY($){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 xY($){let X=$.replace(/@_.*?__/,"").replace(/@screen.*/,"").replace(/@dark/,"").replace(/^universe\./,"");return X=X.replace(/_universe_foundation_breakpoint_screen_width_[^_]+__?$/,""),X}function m0($){let X=$.match(/(\d+(?:\.\d+)?)/);return X?parseFloat(X[1]):0}function PY($,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 jY($,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 r$($,X={}){let{typescript:Y,includeJSDoc:Z,moduleType:W="es",customHeader:q,theme:U}=X,K="";if(q)K+=`${q}
|
|
299
|
+
|
|
300
|
+
`;else K+=`/**
|
|
301
|
+
`,K+=` * Design Tokens - ${U?`${U.charAt(0).toUpperCase()+U.slice(1)} Theme`:"All Tokens"}
|
|
302
|
+
`,K+=` * Auto-generated from design token definitions
|
|
303
|
+
`,K+=` * Do not edit this file directly
|
|
304
|
+
`,K+=` */
|
|
305
|
+
|
|
306
|
+
`;let G=SY($,U);if(Y)K+=u0(G,Z),K+=`
|
|
307
|
+
`;if(W==="es"){if(Y)K+=`const tokens: Tokens = ${f(G,Z,0)};
|
|
308
|
+
|
|
309
|
+
`;else K+=`const tokens = ${f(G,Z,0)};
|
|
310
|
+
|
|
311
|
+
`;K+=`export default tokens;
|
|
312
|
+
`;let H=Object.keys(G);if(H.length>0){K+=`
|
|
313
|
+
// Named exports for convenience
|
|
314
|
+
`;for(let z of H)K+=`export const ${z} = tokens.${z};
|
|
315
|
+
`}}else K+=`const tokens = ${f(G,Z,0)};
|
|
316
|
+
|
|
317
|
+
`,K+=`module.exports = tokens;
|
|
318
|
+
`,K+=`module.exports.default = tokens;
|
|
319
|
+
`;return K}function SY($,X){let Y={},Z=new Map($.map((W)=>[W.name,W]));for(let W of $){let q=W.name;if(X&&q.includes(`@${X}`))q=q.replace(`@${X}`,"");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]=G$(W.value,Z)}return Y}function G$($,X){if(typeof $==="object"&&$!==null&&!Array.isArray($)){let Y=$;if(Y.color&&typeof Y.color==="string"&&Y.color.includes("{")&&Y.color.includes("}")){let Z=S($,"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=S(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=S($,"color");if(W!==$)return W}return $}if(Array.isArray($))return $.map((Y)=>G$(Y,X));if(typeof $==="object"&&$!==null){let Y={};for(let[Z,W]of Object.entries($))Y[Z]=G$(W,X);return Y}return $}function u0($,X){let Y="";if(X)Y+=`/**
|
|
320
|
+
* Token object type definition
|
|
321
|
+
*/
|
|
322
|
+
`;return Y+=`type Tokens = ${k0($,0)};
|
|
323
|
+
`,Y}function k0($,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=`{
|
|
324
|
+
`;for(let[q,U]of Z){let K=DY(q)?`"${q}"`:q;W+=`${Y}${K}: ${k0(U,X+1)};
|
|
325
|
+
`}return W+=" ".repeat(X)+"}",W}function DY($){return $.startsWith("@")||$.includes(" ")||$.includes("-")||$.includes("(")||$.includes(")")||$.includes("@")||$.includes(":")||!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test($)}function f($,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
|
+
`;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=f(H,X,Y+1);U+=`${W}${A}: ${B}${z?"":","}
|
|
328
|
+
`}return U+=`${Z}}`,U}function CY($,X){let Y=X.typescript?"ts":"js",{moduleType:Z="es",customHeader:W}=X,q="";if(W)q+=`${W}
|
|
329
|
+
|
|
330
|
+
`;else q+=`/**
|
|
331
|
+
`,q+=` * Design Tokens - Index
|
|
332
|
+
`,q+=` * Exports all token themes for convenient importing
|
|
333
|
+
`,q+=` */
|
|
334
|
+
|
|
335
|
+
`;if(Z==="es"){for(let U of $){if(U.fileName===`index.${Y}`)continue;let K=U.fileName.replace(`.${Y}`,""),G=U.theme||K;q+=`export { default as ${G} } from './${K}${X.typescript?"":".js"}';
|
|
336
|
+
`}q+=`
|
|
337
|
+
// Convenience re-exports
|
|
338
|
+
`,q+=`export { default } from './light${X.typescript?"":".js"}';
|
|
339
|
+
`}else{for(let U of $){if(U.fileName===`index.${Y}`)continue;let K=U.fileName.replace(`.${Y}`,""),G=U.theme||K;q+=`exports.${G} = require('./${K}');
|
|
340
|
+
`}q+=`
|
|
341
|
+
// Default export points to light theme
|
|
342
|
+
`,q+=`module.exports = require('./light');
|
|
343
|
+
`}return q}var c0=N(()=>{K$()});var l0={};t0(l0,{validateCSSFiles:()=>bY,printValidationResults:()=>VY});import{readFileSync as i$,existsSync as p}from"fs";import{join as D}from"path";function bY($,X){let Y={isValid:!0,errors:[],warnings:[],checks:[]},Z=D($,"css"),W=D(Z,"tokens.css"),q=p(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=D(Z,"tokens.dark.css"),B=p(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=D(Z,"tokens.breakpoints.css");if(p(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&&p(D(Z,"tokens.css"))){let A=i$(D(Z,"tokens.css"),"utf8");if(H.prefix)for(let{find:B,replace:E}of H.prefix){let L=`--${r}-${B}`,_=`--${E}`,O=A.includes(L),J=A.includes(_);if(Y.checks.push({name:`Prefix hook applied: ${B} → ${E}`,passed:!O&&J,message:O?`Old prefix "${L}" still found in CSS, should be "${_}"`:void 0}),O)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(p(D(Z,"tokens.css"))){let B=i$(D(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=D(Z,A);if(p(B)){let E=i$(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 VY($){console.log(`
|
|
344
|
+
|
|
345
|
+
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
|
+
⚠️ Warnings:`);for(let X of $.warnings)console.log(` ${X}`)}if($.errors.length>0){console.log(`
|
|
347
|
+
❌ Errors:`);for(let X of $.errors)console.log(` ${X}`)}console.log(`
|
|
348
|
+
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
|
+
${$.isValid?"✅":"❌"} Build ${$.isValid?"passed":"failed"}`),console.log(`
|
|
350
|
+
========================================================
|
|
351
|
+
`)}var r0=N(()=>{P()});import{writeFileSync as gY,mkdirSync as TY,existsSync as yY}from"fs";import{join as V,dirname as s$}from"path";function fY($,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
|
+
* ${X} Design System - Main CSS Entry Point
|
|
353
|
+
* Generated: ${new Date().toISOString()}
|
|
354
|
+
*
|
|
355
|
+
* This file imports all generated CSS files for the design system.
|
|
356
|
+
* Import this single file to get all design tokens, typography, icons, and breakpoints.
|
|
357
|
+
*
|
|
358
|
+
* Do not edit this file directly - it will be overwritten.
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
${W.join(`
|
|
362
|
+
`)}
|
|
363
|
+
`;return{fileName:`${X}.design-system.tokens.css`,content:K,theme:void 0}}async function y0($){let X=Date.now(),Y={tokenCount:0,cssFiles:[],typescriptFiles:[],javascriptFiles:[],jsonFiles:[],duration:0,warnings:[],errors:[]};try{R(`
|
|
364
|
+
Starting token build process...`,$.verbose),R("Loading token files...",$.verbose);let Z=D$($.tokensDir);R("Parsing tokens...",$.verbose);let W=hY($.config),q=C$(Z,W);R(`Found ${q.length} tokens`,$.verbose),Y.tokenCount=q.length;let U=b$(q,W);if(R(`Resolved ${U.length} tokens`,$.verbose),$.generateCSS!==!1){R(`
|
|
365
|
+
Generating CSS files...`,$.verbose);let G=i0($.config,$.cssOptions),H=Z$(U,G);for(let z of H){let A=V($.outputDir,"css",z.fileName);m(A,z.content),R(` ✓ ${z.fileName}`,$.verbose)}Y.cssFiles=H}if($.generateCSS!==!1)try{await l$(),R(`
|
|
366
|
+
Generated icon tokens`,$.verbose)}catch(G){if($.verbose)console.warn("Could not build icon tokens:",G)}if($.generateCSS!==!1)try{let G=await h$();if(G.length>0){let H=i0($.config,$.cssOptions),z=f$(G,{customHeader:U$($.config),objectPath:$.config.$metaData?.icons?.objectPath||"universe.custom.path.icons",hooks:H.hooks}),A=V($.outputDir,"css",z.fileName);if(m(A,z.content),R(` ✓ Generated ${z.fileName}`,$.verbose),Y.cssFiles)Y.cssFiles.push(z);else Y.cssFiles=[z]}}catch(G){if($.verbose)console.warn("Could not generate icon CSS:",G)}let K=!1;if($.generateCSS!==!1)try{let G=$.config.$fonts;if(G&&G.length>0){await P$(G,$.outputDir),R(" ✓ Generated fonts.css",$.verbose),K=!0;let H={fileName:"fonts.css",content:"Generated by appendTypographyTokens",theme:void 0};if(Y.cssFiles)Y.cssFiles.push(H);else Y.cssFiles=[H]}}catch(G){if($.verbose)console.warn("Could not generate font CSS:",G)}if($.generateCSS!==!1&&Y.cssFiles.length>0){let G=$.config.$metaData?.tokenNamespace||"tokens",H=Y.cssFiles.some((B)=>B.fileName==="tokens.icons.css"),z=fY(Y.cssFiles.filter((B)=>B.fileName!=="tokens.icons.css"&&B.fileName!=="fonts.css"),G,H,K),A=V($.outputDir,z.fileName);m(A,z.content),R(` ✓ Generated ${z.fileName}`,$.verbose),Y.cssFiles.push(z)}if($.generateTypeScript!==!1){R(`
|
|
367
|
+
Generating TypeScript files...`,$.verbose);let G=vY($.config,$.typescriptOptions),H=await v$(U,G);for(let z of H){let A=V($.outputDir,"typescript",z.fileName);m(A,z.content),R(` ✓ Generated ${z.fileName}`,$.verbose)}Y.typescriptFiles=H}if($.generateJavaScript!==!1){R(`
|
|
368
|
+
Generating JavaScript files...`,$.verbose);let G=pY($.config,$.javascriptOptions),H=d0(U,G);for(let z of H){let A=V($.outputDir,"js",z.fileName);m(A,z.content),R(` ✓ Generated ${z.fileName}`,$.verbose)}Y.javascriptFiles=H}if($.generateJSON!==!1){R(`
|
|
369
|
+
Generating JSON files...`,$.verbose);let G=mY(U,q,$.config);for(let H of G){let z=V($.outputDir,"json",H.fileName);m(z,H.content),R(` ✓ Generated ${H.fileName}`,$.verbose)}Y.jsonFiles=G}Y.duration=Date.now()-X,R(`
|
|
370
|
+
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(() => (r0(),l0)),q=Z($.outputDir,$.config);if($.verbose||!q.isValid)W(q);if(!q.isValid)Y.errors.push(...q.errors)}return Y}function hY($){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 i0($,X){let Z=$.$metaData.tokens?.css;return{...X,separateThemeFiles:Z?.mediaQuery?.separateThemeFiles??!1,rootSelector:":root",generateMediaQueries:!0,customHeader:U$($),themeSelector:Z?.mediaQuery?.match||"[data-theme]",hooks:Z?.hooks}}function vY($,X){let Y=$.$metaData;return{...X,tokenInterface:"DesignTokens",exportNamespace:Y.dsNamespace||Y.tokenNamespace,generateTypes:!0,generateConsts:!0,generateCSSVarMappings:!0,includeJSDoc:!0}}function pY($,X){return{...X,typescript:!0,separateThemeFiles:!0,includeJSDoc:!1,moduleType:"es",customHeader:`/**
|
|
372
|
+
* ${$.$name}
|
|
373
|
+
* Generated: ${new Date().toISOString()}
|
|
374
|
+
*/`}}function mY($,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 m($,X){let Y=s$($);if(!yY(Y))TY(Y,{recursive:!0});gY($,X,"utf-8")}function R($,X){if(X!==!1)console.log($)}async function d$($,X){let Z=(await import($)).default,W=V(s$($),Z.$paths.baseDir,Z.$paths.tokensDir),q=X||V(s$($),Z.$paths.baseDir,Z.$paths.distDir);return y0({config:Z,tokensDir:W,outputDir:q,verbose:!0})}var u$=N(()=>{p0();K$();c0();g$();m$();j$()});u$();import{existsSync as dY}from"fs";import{resolve as uY}from"path";function kY($){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 cY(){console.log(`
|
|
375
|
+
Design Tokens Builder - W3C compliant token processor
|
|
376
|
+
|
|
377
|
+
Usage: build-tokens [options]
|
|
378
|
+
|
|
379
|
+
Options:
|
|
380
|
+
-c, --config <path> Path to configuration file (required)
|
|
381
|
+
-i, --input <path> Input tokens directory (overrides config)
|
|
382
|
+
-o, --output <path> Output directory (overrides config)
|
|
383
|
+
-v, --verbose Enable verbose logging
|
|
384
|
+
--no-css Skip CSS generation
|
|
385
|
+
--no-typescript Skip TypeScript generation
|
|
386
|
+
--no-json Skip JSON generation
|
|
387
|
+
-h, --help Show this help message
|
|
388
|
+
|
|
389
|
+
Examples:
|
|
390
|
+
build-tokens --config ./designid.config.ts
|
|
391
|
+
build-tokens -c ./config.ts -o ./dist --verbose
|
|
392
|
+
build-tokens -c ./config.ts --no-css --no-json
|
|
393
|
+
|
|
394
|
+
Configuration File:
|
|
395
|
+
The configuration file should export a TConfigFile object with:
|
|
396
|
+
- $name: Project name
|
|
397
|
+
- $version: Version string
|
|
398
|
+
- $paths: Directory paths configuration
|
|
399
|
+
- $modes: Theme/mode definitions
|
|
400
|
+
- $metaData: Processing metadata and options
|
|
401
|
+
|
|
402
|
+
Token Files:
|
|
403
|
+
Token files should follow W3C Design Tokens specification:
|
|
404
|
+
- Use .tokens.json extension
|
|
405
|
+
- Include $type and $value properties
|
|
406
|
+
- Support token references with {token.path} syntax
|
|
407
|
+
- Support extensions for modes, generators, and breakpoints
|
|
408
|
+
`)}function lY($){let X=[$,"./designid.config.ts","./designid.config.js","./tokens.config.ts","./tokens.config.js"].filter(Boolean);for(let Y of X){let Z=uY(Y);if(dY(Z))return Z}throw Error(`Config file not found. Tried: ${X.join(", ")}`)}async function rY(){let $=kY(process.argv.slice(2));if($.help){cY();return}try{let X=lY($.config);console.log(`Using config: ${X}`);let Y=await d$(X,$.output);if(Y.errors.length>0)console.log(`
|
|
409
|
+
❌ 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
|
+
`),Y.cssFiles.length>0)console.log(`
|
|
411
|
+
Generated ${Y.cssFiles.length} CSS files:`),Y.cssFiles.forEach((Z)=>console.log(` - ${Z.fileName}`));if(Y.typescriptFiles.length>0)console.log(`
|
|
412
|
+
Generated ${Y.typescriptFiles.length} TypeScript files:`),Y.typescriptFiles.forEach((Z)=>console.log(` - ${Z.fileName}`));if(Y.javascriptFiles.length>0)console.log(`
|
|
413
|
+
Generated ${Y.javascriptFiles.length} JavaScript files:`),Y.javascriptFiles.forEach((Z)=>console.log(` - ${Z.fileName}`));if(Y.jsonFiles.length>0)console.log(`
|
|
414
|
+
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]}`)rY().catch(($)=>{console.error("Unexpected error:",$),process.exit(1)});export{rY as runCLI};
|