@designid/tokens 1.2.4 → 1.2.5
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 +18 -18
- package/bin/editor.js +21 -21
- package/bin/watch.js +18 -18
- package/package.json +1 -1
package/bin/build.js
CHANGED
|
@@ -21,19 +21,19 @@ ${A}`;if(K.forEach((L)=>{if(F$(L,U,q))return;let H=j$(L,X,Y);if(U.transformValue
|
|
|
21
21
|
* This file is automatically generated.
|
|
22
22
|
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
23
23
|
* Changes will be overwritten. Please update the source design tokens instead.
|
|
24
|
-
*/`,o$=null,G2=null,e$=null,$0=null,Y0=null,X0=null,Z0=null,q0=null,U0=null;var _$=P(()=>{g()});function j($){return $===L0}var L0="light";var _2=P(()=>{_$()});async function H0($){let X=await S$();$=$.replace(/<\?xml[^>]*\?>\s*/,""),$=$.replace(/<!DOCTYPE [^>]*>\s*/,"");let Y=$.match(/<svg[^>]*>/),Z=$.match(/viewBox="([\d\s.]+)"/),[q]=Y??[],U=q;if(q&&U){let W=X?.style?.fill,G=/id="[^"]*"/.test(q);if(!U.includes("xmlns="))U=U.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"');if(!G&&W)U=U.replace("<svg",`<svg id="${W}"`);else if(G&&W)U=U.replace(/id="[^"]*"/,`id="${W}"`)}if(Z&&q&&U){let W=Z[1].split(" ").map(Number),G=W[2],E=W[3],A=X?.size??24,z=G/E*A;$=$.replace(/height="[\d.]+px?"/,`height="${A}px"`),$=$.replace(/width="[\d.]+px?"/,`width="${z}px"`);let L=/width="[\d.]+(px)?"/.test(q),H=/height="[\d.]+(px)?"/.test(q);if(!L)U=U.replace("<svg",`<svg width="${z}px"`);else U=U.replace(/width="[\d.]+(px)?"/,`width="${z}px"`);if(!H)U=U.replace("<svg",`<svg height="${A}px"`);else U=U.replace(/height="[\d.]+(px)?"/,`height="${A}px"`);$=$.replace(q,U)}if(!$?.match(/data-style="([^"]*)"/)&&X?.style?.type)$=$.replace("<svg ",`<svg data-style="${X.style.type}" `);return $}var Q2=P(()=>{g()});var B2=P(()=>{_$();g()});import{copyFileSync as SY,existsSync as DY,mkdirSync as O2,statSync as bY}from"fs";import{writeFile as CY}from"fs/promises";import{join as V,relative as VY}from"path";async function _0($,X){try{let{assets:Y,workspaceRoot:Z,distDir:q,__dirname:U}=await k(),K=Y?.fonts?.sourceDir?V(U,Y.fonts.sourceDir):null,W=V("assets","fonts"),G=V(Z,q),E=Y?.fonts?.distDir?V(G,Y.fonts.distDir.replace(/^\.\//,"")):V(G,W);if(!$||!K)return;let A="",z=X&&Y?.fonts?.distDir?V(X,Y.fonts.distDir.replace(/^\.\//,"")):E;for(let
|
|
25
|
-
`,
|
|
26
|
-
`}else if(
|
|
27
|
-
font-family: "${
|
|
28
|
-
font-style: ${
|
|
29
|
-
font-weight: ${
|
|
30
|
-
src: url("${
|
|
24
|
+
*/`,o$=null,G2=null,e$=null,$0=null,Y0=null,X0=null,Z0=null,q0=null,U0=null;var _$=P(()=>{g()});function j($){return $===L0}var L0="light";var _2=P(()=>{_$()});async function H0($){let X=await S$();$=$.replace(/<\?xml[^>]*\?>\s*/,""),$=$.replace(/<!DOCTYPE [^>]*>\s*/,"");let Y=$.match(/<svg[^>]*>/),Z=$.match(/viewBox="([\d\s.]+)"/),[q]=Y??[],U=q;if(q&&U){let W=X?.style?.fill,G=/id="[^"]*"/.test(q);if(!U.includes("xmlns="))U=U.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"');if(!G&&W)U=U.replace("<svg",`<svg id="${W}"`);else if(G&&W)U=U.replace(/id="[^"]*"/,`id="${W}"`)}if(Z&&q&&U){let W=Z[1].split(" ").map(Number),G=W[2],E=W[3],A=X?.size??24,z=G/E*A;$=$.replace(/height="[\d.]+px?"/,`height="${A}px"`),$=$.replace(/width="[\d.]+px?"/,`width="${z}px"`);let L=/width="[\d.]+(px)?"/.test(q),H=/height="[\d.]+(px)?"/.test(q);if(!L)U=U.replace("<svg",`<svg width="${z}px"`);else U=U.replace(/width="[\d.]+(px)?"/,`width="${z}px"`);if(!H)U=U.replace("<svg",`<svg height="${A}px"`);else U=U.replace(/height="[\d.]+(px)?"/,`height="${A}px"`);$=$.replace(q,U)}if(!$?.match(/data-style="([^"]*)"/)&&X?.style?.type)$=$.replace("<svg ",`<svg data-style="${X.style.type}" `);return $}var Q2=P(()=>{g()});var B2=P(()=>{_$();g()});import{copyFileSync as SY,existsSync as DY,mkdirSync as O2,statSync as bY}from"fs";import{writeFile as CY}from"fs/promises";import{join as V,relative as VY}from"path";async function _0($,X){try{let{assets:Y,workspaceRoot:Z,distDir:q,__dirname:U}=await k(),K=Y?.fonts?.sourceDir?V(U,Y.fonts.sourceDir):null,W=V("assets","fonts"),G=V(Z,q),E=Y?.fonts?.distDir?V(G,Y.fonts.distDir.replace(/^\.\//,"")):V(G,W);if(!$||!K)return;let A="",z=X&&Y?.fonts?.distDir?V(X,Y.fonts.distDir.replace(/^\.\//,"")):E;for(let B of $){if(!B)continue;if(A+=`/**** ${B.family} ${B.style} ****/
|
|
25
|
+
`,B.linkHref){let I=await(await fetch(B.linkHref)).text();A+=`${I.replace(/\s+/g," ").replace(/:\s+/g,":")}
|
|
26
|
+
`}else if(B?.src&&K){let O=B.directory??B.family.toLowerCase().replace(/\s+/g,"-"),I=V(K,O,B.src);try{if(!DY(I)||!bY(I).isFile()){console.warn(`Font file not found: ${I}`);continue}}catch{console.warn(`Error accessing font file: ${I}`);continue}try{O2(V(z,O),{recursive:!0}),SY(V(K,O,B.src),V(z,O,B.src))}catch(w){console.warn(`Error copying font file ${B.src}:`,w instanceof Error?w.message:w);continue}let Q;if(Y?.fonts?.cssImportPath)Q=V(Y.fonts.cssImportPath,O,B.src).replace(/\\/g,"/");else{let{distCSSPath:w}=await k(),J=X?V(X,"css"):w,R=VY(J,z);Q=V(R,O,B.src).replace(/\\/g,"/")}A+=`@font-face {
|
|
27
|
+
font-family: "${B.family}";
|
|
28
|
+
font-style: ${B.faceStyle};
|
|
29
|
+
font-weight: ${B.weight};
|
|
30
|
+
src: url("${Q}") format("${B.format}");
|
|
31
31
|
}
|
|
32
32
|
`}}let{distCSSPath:L}=await k(),H=X?V(X,"css"):L,_=`${H}/fonts.css`;O2(H,{recursive:!0}),await CY(_,A,{flag:"w",encoding:"utf-8"})}catch(Y){console.error("Error appending typography tokens:",Y)}}var Q0=P(()=>{g()});function Q$($){if(typeof $!=="string"||!$.startsWith("{")||!$.endsWith("}"))return!1;let X=$.slice(1,-1);return!X.includes("{")&&!X.includes("}")&&X.trim()!==""}function B$($){if(typeof $!=="string")return!1;let X=/\{[^}]+\}/g,Y=$.match(X);return!!(Y&&Y.length>0&&$.length>Y.join("").length)}function D$($){let X=[],Y=/\{[^}]+\}/g,Z=0,q;while((q=Y.exec($))!==null){if(q.index>Z){let K=$.slice(Z,q.index);if(K)X.push({type:"literal",value:K})}let U=q[0];if(U.startsWith("{#/"))X.push({type:"reference",value:U,ref:{$ref:U.slice(2,-1)}});else X.push({type:"reference",value:U,ref:U});Z=q.index+q[0].length}if(Z<$.length){let U=$.slice(Z);if(U)X.push({type:"literal",value:U})}return X}function w2($){return!!$.$extensions?.$mode}function I2($){return!!($.$extensions?.$generators&&Array.isArray($.$extensions.$generators))}function J2($){return!!($.$extensions?.$breakpoints&&typeof $.$extensions.$breakpoints==="object")}function R2($,X){return`${$}${X}`}function M2($){return typeof $==="object"&&$!==null&&"$value"in $}function N2($){return typeof $==="object"&&$!==null&&!("$value"in $)}var x2=()=>{};function F2($){if(typeof $!=="string")return!1;let X=$.trim();return X.startsWith("<svg")&&X.includes("</svg>")}function j2($){if(typeof $!=="string")return!1;return $.startsWith("data:image/png;base64,")||$.startsWith("iVBORw0KGgo")}function P2($){if(typeof $!=="string")return!1;return $.startsWith("data:image/jpeg;base64,")||$.startsWith("data:image/jpg;base64,")||$.startsWith("/9j/")}function gY($){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 yY($){if($.startsWith("data:image/png;base64,"))return $;return`data:image/png;base64,${$}`}function hY($){if($.startsWith("data:image/jpeg;base64,")||$.startsWith("data:image/jpg;base64,"))return $;return`data:image/jpeg;base64,${$}`}function O$($){if(!$||typeof $!=="string")return $;if($.startsWith("data:"))return $;if(F2($))return gY($);else if(j2($))return yY($);else if(P2($))return hY($);return $}function vY($){if(typeof $!=="string")return!1;return $.startsWith("data:image/svg+xml;")||$.startsWith("data:image/png;")||$.startsWith("data:image/jpeg;")||$.startsWith("data:image/jpg;")||$.startsWith("data:image/gif;")||$.startsWith("data:image/webp;")}function m($){return F2($)||j2($)||P2($)||vY($)}import{readFileSync as fY,readdirSync as pY,statSync as mY}from"fs";import{join as dY}from"path";import D2 from"colorjs.io";function O0($){let X={};function Y(Z){let q=pY(Z);for(let U of q){let K=dY(Z,U);if(mY(K).isDirectory())Y(K);else if(U.endsWith(".tokens.json"))try{let G=fY(K,"utf-8");if(!G.trim())continue;let E=JSON.parse(G);b2(X,E)}catch(G){console.warn(`Failed to load token file: ${K}`,G)}}}return Y($),X}function b2($,X){for(let Y in X)if(X[Y]&&typeof X[Y]==="object"&&!Array.isArray(X[Y])){if(!$[Y])$[Y]={};b2($[Y],X[Y])}else $[Y]=X[Y]}function w0($,X={}){let Y=[];function Z(q,U=[]){for(let[K,W]of Object.entries(q)){if(K.startsWith("$"))continue;let G=[...U,K],E=G.join(".");if(M2(W)){let A={path:G,name:E,type:W.$type,value:W.$value,description:W.$description,extensions:W.$extensions?{mode:w2(W)?W.$extensions.$mode:W.$extensions.mode?W.$extensions.mode:void 0,generators:I2(W)?W.$extensions.$generators:W.$extensions.generators?W.$extensions.generators:void 0,breakpoints:J2(W)?W.$extensions.$breakpoints:W.$extensions.breakpoint?W.$extensions.breakpoint:void 0,...Object.fromEntries(Object.entries(W.$extensions).filter(([z])=>!["$mode","$generators","$breakpoints","mode","generators","breakpoint"].includes(z)))}:void 0,original:W};if(!X.namespace||E.startsWith(X.namespace))Y.push(A)}else if(N2(W))Z(W,G)}}return Z($),Y}function I0($,X={}){let Y=[...$],Z=new Map($.map((E)=>[E.name,E]));if(X.generateModes||X.generateDerivedTokens||X.generateBreakpointTokens)for(let E of $){let A=S2(E,X,Z);if(Y.push(...A),X.generateModes){for(let z of A)if(z.extensions?.mode&&!z.name.includes("#")){let L=S2(z,X,Z);Y.push(...L)}}}let q=X.modes||[],U=q.length>0?q[0]:void 0,K={tokens:new Map(Y.map((E)=>[E.name,E])),mode:X.generateModes?U:void 0,options:X,brokenReferences:[]},W=[];for(let E of Y){let A=void 0;for(let H of q)if(E.name.endsWith(`#${H}`)){A=H;break}if(!A&&X.generateModes)A=U;let z={...K,mode:A},L=uY(E,z);W.push(L)}if(X.failOnBrokenReferences!==!1&&K.brokenReferences.length>0){let E=[...new Set(K.brokenReferences)],A=`Token reference${E.length>1?"s":""} not found:
|
|
33
33
|
${E.map((z)=>` - ${z}`).join(`
|
|
34
|
-
`)}`;throw Error(A)}return W}function S2($,X,Y){let Z=[];if(X.generateModes&&$.extensions?.mode){for(let[q,U]of Object.entries($.extensions.mode))if(U!==void 0)Z.push({...$,name:`${$.name}#${q}`,value:U,path:[...$.path,`#${q}`]})}if(X.generateModes&&!$.extensions?.mode&&(Array.isArray($.value)||typeof $.value==="object"&&$.value!==null)){let q=!1,U=!1,K=(W)=>{if(typeof W!=="object"||W===null)return!1;if(W.$extensions?.mode)return!0;return Object.values(W).some((G)=>{if(typeof G==="object"&&G!==null)return K(G);return!1})};if(Array.isArray($.value))q=$.value.some((W)=>typeof W==="string"&&W.includes("{")||typeof W==="object"&&W!==null&&Object.values(W).some((G)=>typeof G==="string"&&G.includes("{"))),U=$.value.some((W)=>K(W));else q=Object.values($.value).some((W)=>typeof W==="string"&&W.includes("{")),U=K($.value);if(q||U){if(["color","shadow","border","background","surface","composition"].includes($.type)){let E;if(Array.isArray($.value))E=$.value.map((A)=>{if(typeof A==="string"&&A.startsWith("{")&&A.endsWith("}")){let z=A.slice(1,-1);if(!z.includes("#dark")&&!z.includes("@dark"))return`{${z}#dark}`;return A}else if(typeof A==="object"&&A!==null){let z={};for(let[L,H]of Object.entries(A))if(typeof H==="string"&&H.startsWith("{")&&H.endsWith("}")){let _=H.slice(1,-1),Q=`${_}#dark`,O=Y?.get(_),I=Y?.has(Q)||O?.extensions?.mode?.dark!==void 0||O&&(Array.isArray(O.value)||typeof O.value==="object"&&O.value!==null);if(!_.includes("#dark")&&!_.includes("@dark")&&I)z[L]=`{${Q}}`;else z[L]=H}else z[L]=H;return z}return A});else if(typeof $.value==="object"&&$.value!==null){E={};let A=(z)=>{if(typeof z==="string"){if(z.startsWith("{")&&z.endsWith("}")){let L=z.slice(1,-1),H=`${L}#dark`,_=(O,I=new Set)=>{if(I.has(O))return!1;I.add(O);let B=Y?.get(O);if(!B){let w=O.match(/^(.+)@([^@]+)$/);if(w){let[,J,R]=w,y=Y?.get(J);if(y){if(y.extensions?.mode?.dark!==void 0)return!0;if(y.extensions?.generators)return!0;return _(J,I)}}return!1}if(B.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${O}#dark`))return!0;if(typeof B.value==="string"&&B.value.startsWith("{")&&B.value.endsWith("}")){let w=B.value.slice(1,-1);return _(w,I)}if(Array.isArray(B.value)||typeof B.value==="object"&&B.value!==null){let w=(J)=>{if(typeof J!=="object"||J===null)return!1;if(J.$extensions?.mode)return!0;return Object.values(J).some((R)=>{if(typeof R==="object"&&R!==null)return w(R);return!1})};if(Array.isArray(B.value))return B.value.some((J)=>typeof J==="string"&&J.includes("{")&&_(J.slice(1,-1),new Set(I))||typeof J==="object"&&J!==null&&(Object.values(J).some((R)=>typeof R==="string"&&R.includes("{")&&_(R.slice(1,-1),new Set(I)))||w(J)));else if(typeof B.value==="object")return Object.values(B.value).some((J)=>typeof J==="string"&&J.includes("{")&&_(J.slice(1,-1),new Set(I)))||w(B.value)}return!1},Q=_(L);if(!L.includes("#dark")&&!L.includes("@dark")&&Q)return`{${H}}`}return z}if(typeof z==="object"&&z!==null){if(z.$extensions?.mode?.dark)return z.$extensions.mode.dark;let L={};for(let[H,_]of Object.entries(z))L[H]=A(_);return L}return z};for(let[z,L]of Object.entries($.value))E[z]=A(L)}Z.push({...$,name:`${$.name}#dark`,value:E,path:[...$.path,"#dark"],extensions:{...$.extensions,autoGenerated:!0}})}}}if(X.generateModes&&!$.extensions?.mode&&typeof $.value==="string"&&$.value.startsWith("{")&&$.value.endsWith("}")){let q=$.value.slice(1,-1),U=(A,z=new Set)=>{if(z.has(A))return!1;z.add(A);let L=Y?.get(A);if(!L){let H=A.match(/^(.+)@([^@]+)$/);if(H){let[,_,Q]=H,O=Y?.get(_);if(O){if(O.extensions?.mode?.dark!==void 0)return!0;if(O.extensions?.generators)return!0;return U(_,z)}}return!1}if(L.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${A}#dark`))return!0;if(typeof L.value==="string"&&L.value.startsWith("{")&&L.value.endsWith("}")){let H=L.value.slice(1,-1);return U(H,z)}if(Array.isArray(L.value)||typeof L.value==="object"&&L.value!==null){let H=(_)=>{if(typeof _!=="object"||_===null)return!1;if(_.$extensions?.mode)return!0;return Object.values(_).some((Q)=>{if(typeof Q==="object"&&Q!==null)return H(Q);return!1})};if(Array.isArray(L.value))return L.value.some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(z))||typeof _==="object"&&_!==null&&(Object.values(_).some((Q)=>typeof Q==="string"&&Q.includes("{")&&U(Q.slice(1,-1),new Set(z)))||H(_)));else if(typeof L.value==="object")return Object.values(L.value).some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(z)))||H(L.value)}return!1},K=U(q);if(["color","shadow","border","background","surface","composition"].includes($.type)&&K&&K&&!q.includes("#dark")&&!q.includes("@dark")){let A=`{${q}#dark}`;Z.push({...$,name:`${$.name}#dark`,value:A,path:[...$.path,"#dark"],extensions:{...$.extensions,autoGenerated:!0}})}}if(X.generateDerivedTokens&&$.extensions?.generators)for(let q of $.extensions.generators)for(let[U,K]of Object.entries(q.value)){let W=R2($.name,U),{generators:G,...E}=$.extensions;Z.push({...$,name:W,value:$.value,path:[...$.path,U],extensions:{...E,generator:{type:q.type,value:K}}})}if(X.generateBreakpointTokens&&$.extensions?.breakpoints)for(let[q,U]of Object.entries($.extensions.breakpoints)){let K=`${$.name}@${q.replace(/[^a-zA-Z0-9]/g,"_")}`,W=U.$value||U.value;if(W&&typeof W==="object"&&"$value"in W)W=W.$value;else if(!W&&typeof U==="object"){let{...A}=U;if(Object.keys(A).length>0)W=A}let G=U.$extensions||U.$extensions,E=U.$type;if(!E&&U.value&&typeof U.value==="object")E=U.value.$type;Z.push({...$,name:K,value:W,path:[...$.path,`@${q}`],type:E||$.type,extensions:{mediaQuery:q,...G?{mode:G.mode||G.$mode,generators:G.generators||G.$generators,...Object.fromEntries(Object.entries(G).filter(([A])=>!["mode","$mode","generators","$generators"].includes(A)))}:{}}})}return Z}function uY($,X){let Y=s($.value,X),Z=$.type;if(typeof $.value==="string"&&Q$($.value)){let U=$.value.slice(1,-1),K=X.tokens.get(U);if(K){if(["border","shadow","typography","composition"].includes(K.type))Z=K.type;else if(typeof K.value==="string"&&B$(K.value)){let W=D$(K.value),G=new Set;for(let E of W)if(E.type==="reference"&&E.ref&&typeof E.ref==="string"){let A=E.ref.slice(1,-1),z=X.tokens.get(A);if(z&&["border","shadow","typography","composition"].includes(z.type))G.add(z.type)}if(G.size===1)Z=Array.from(G)[0]}}}if(typeof $.value==="string"&&B$($.value)){let U=D$($.value),K=new Set;for(let W of U)if(W.type==="reference"&&W.ref&&typeof W.ref==="string"){let G=W.ref.slice(1,-1),E=X.tokens.get(G);if(E&&["border","shadow","typography","composition"].includes(E.type))K.add(E.type)}if(K.size===1)Z=Array.from(K)[0]}if(typeof Y==="object"&&Y!==null&&["border","shadow","typography","composition"].includes(Z))Y=c(Y,X);if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=b$($.value,$.extensions.generator.type,$.extensions.generator.value,X);let q=kY($.name,X.options);if(Z==="color"&&typeof Y==="string"&&p(Y))Y=F(Y,$);if(typeof Y==="string"&&m(Y))Y=O$(Y);return{...$,type:Z,value:Y,cssVar:q}}function c($,X){if(typeof $==="string"){if(Q$($))return J0($,X);else if(B$($))return V2($,X)}if(Array.isArray($))return $.map((Y)=>c(Y,X));if(typeof $==="object"&&$!==null){if("$value"in $&&typeof $.$value==="string")return c($.$value,X);if("value"in $&&typeof $.value==="string"&&"$type"in $){if(X.mode&&$.$extensions?.mode?.[X.mode])return c($.$extensions.mode[X.mode],X);return c($.value,X)}if("value"in $&&typeof $.value==="object"&&"$type"in $){let Z=$.value,q=$.$extensions?.delimiter?.character||" ";if($.$type==="composition"&&Z&&typeof Z==="object")return Object.values(Z).map((K)=>c(K,X)).join(q);return c($.value,X)}let Y={};for(let[Z,q]of Object.entries($))Y[Z]=c(q,X);return Y}return $}function s($,X){if(typeof $==="string"){if(B$($))return V2($,X);else if(Q$($))return J0($,X)}else if(typeof $==="object"&&$!==null&&"$ref"in $)return C2($,X);return $}function J0($,X){let Y=$.slice(1,-1),Z=X.tokens.get(Y),q=X.options.modes||[];if(!Z){if(q.length>0){for(let W of q)if(Y.endsWith(`@${W}`)){let G=Y.slice(0,-W.length-1)+`#${W}`;if(Z=X.tokens.get(G),Z)return B0(Z,X);break}}let K=Y.match(/#([^#@]+)$/);if(K){let W=Y.substring(0,K.index),G=K[1];if(Z=X.tokens.get(W),Z){if(Z.extensions?.mode?.[G]){let E=Z.extensions.mode[G],A=s(E,{...X,mode:G});if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)A=b$(A,Z.extensions.generator.type,Z.extensions.generator.value,X);if(Z.type==="color"&&typeof A==="string"&&p(A))A=F(A,Z);if(typeof A==="string"&&m(A))A=O$(A);return A}}}if(q.length>0)for(let W of q){let G=new RegExp(`(@[^@]+)@${W}$`);if(G.test(Y)){let E=Y.replace(G,`$1#${W}`);if(Z=X.tokens.get(E),!Z){let A=E.match(/#([^#@]+)$/);if(A){let z=E.substring(0,A.index),L=A[1];if(Z=X.tokens.get(z),Z&&Z.extensions?.mode?.[L]){let H=Z.extensions.mode[L],_=s(H,{...X,mode:L});if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)_=b$(_,Z.extensions.generator.type,Z.extensions.generator.value,X);if(Z.type==="color"&&typeof _==="string"&&p(_))_=F(_,Z);if(typeof _==="string"&&m(_))_=O$(_);return _}}}else return B0(Z,X);break}}}if(!Z)return console.warn(`Token reference not found: ${$}`),X.brokenReferences.push($),$;return B0(Z,X)}function B0($,X){let Y;if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=b$($.value,$.extensions.generator.type,$.extensions.generator.value,X);else if(X.mode&&$.extensions?.mode?.[X.mode])Y=s($.extensions.mode[X.mode],X);else Y=s($.value,X);if($.type==="color"&&typeof Y==="string"&&p(Y))Y=F(Y,$);if(typeof Y==="string"&&m(Y))Y=O$(Y);return Y}function C2($,X){let Z=$.$ref.slice(2).replace(/\//g,"."),q=X.tokens.get(Z);if(!q)return console.warn(`JSON Pointer reference not found: ${$.$ref}`),X.brokenReferences.push($.$ref),$.$ref;return s(q.value,X)}function V2($,X){let Y=D$($),Z=Y.some((K)=>K.value.includes(",")),q=!0,U=[];for(let K of Y){let W;if(K.type==="reference"&&K.ref){if(typeof K.ref==="string"&&Q$(K.ref)){W=J0(K.ref,X);let G=K.ref.slice(1,-1),E=X.tokens.get(G);if(!E||!["border","shadow","typography","composition"].includes(E.type))q=!1}else if(typeof K.ref==="object"&&"$ref"in K.ref)W=C2(K.ref,X)}else if(W=K.value,K.value.trim()&&K.value.trim()!==",")q=!1;U.push(W)}if(Z&&q)return U.filter((K)=>typeof K==="object"&&K!==null&&typeof K!=="string");return U.map((K)=>String(K)).join("")}function b$($,X,Y,Z){let q=s($,Z);switch(X){case"alpha":if(typeof q==="string")return cY(q,Number(Y)/100);break;case"scale":if(typeof q==="string"&&q.match(/[\d.]+/))return lY(q,Number(Y));break;case"hue":if(typeof q==="string")return rY(q,Number(Y));break;default:return console.warn(`Unknown generator type: ${X}`),q}return q}function kY($,X,Y){let Z=$.replace(/\./g,"-");Z=Z.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),Z=Z.replace(/@[^@#]*(?:screen|width|height|min|max|orientation).*$/i,""),Z=Z.replace(/#[^#]*$/,""),Z=Z.replace(/-@/g,"-").replace(/@/g,"-");let q=Z,U=!0,K=X.prefix||"";if(X.transformName){if(q=X.transformName(Z),q=q.replace(/-+$/,""),q!==Z)U=!1}let W=U&&K?`${K}-${q}`:q,G=Y?`-${Y}`:"";return`--${W}${G}`.replace(/[^a-zA-Z0-9-_]/g,"-")}function cY($,X){try{if(!p($))return $;let Y=new D2($);return Y.alpha=X,F(Y)}catch(Y){return console.warn(`Failed to apply alpha to color "${$}": ${Y}`),$}}function lY($,X){let Y=$.match(/([\d.]+)(\w+)/);if(Y){let[,Z,q]=Y;return`${parseFloat(Z)*X}${q}`}return $}function rY($,X){try{if(!p($))return $;let Z=new D2($).to("oklch");return Z.h=(Z.h+X)%360,F(Z)}catch(Y){return console.warn(`Failed to shift hue for color "${$}": ${Y}`),$}}var R0=P(()=>{x2();W$()});function M0($){if($.type==="typography"||$.type==="fontWeight"||$.type==="fontFamily")return!0;if($.type==="dimension"&&$.name.includes("typography"))return!0;if($.name.includes("typography")||$.name.includes("font"))return!0;return!1}function a($,X,Y){if(Y){if($===X)return":host";return`:host([data-theme="${$}"])`}if($===X)return":root";return`[data-theme="${$}"]`}function C$($,X={}){let{rootSelector:Y=":root",separateThemeFiles:Z=!1,generateMediaQueries:q=!1,customHeader:U,modes:K=["light","dark"]}=X;if(Z)return sY($,X);let W=new Map,G=new Map;for(let B of K)W.set(B,[]);let E=K.join("|"),A=new RegExp(`#(${E})$`);for(let B of $){if(typeof B.value==="string"&&m(B.value))continue;if(M0(B))continue;let w=` ${B.cssVar}: ${f(B.value,B.type)};`;if(q&&B.name.includes("@media")){let R=T$(B);if(R){if(!G.has(R))G.set(R,[]);G.get(R).push(w);continue}}let J=B.name.match(A);if(J){let R=J[1];if(!W.has(R))W.set(R,[]);W.get(R).push(w)}else{let R=K[0]||"light";W.get(R).push(w)}}let z="";if(U)z+=`${U}
|
|
34
|
+
`)}`;throw Error(A)}return W}function S2($,X,Y){let Z=[];if(X.generateModes&&$.extensions?.mode){for(let[q,U]of Object.entries($.extensions.mode))if(U!==void 0)Z.push({...$,name:`${$.name}#${q}`,value:U,path:[...$.path,`#${q}`]})}if(X.generateModes&&!$.extensions?.mode&&(Array.isArray($.value)||typeof $.value==="object"&&$.value!==null)){let q=!1,U=!1,K=(W)=>{if(typeof W!=="object"||W===null)return!1;if(W.$extensions?.mode)return!0;return Object.values(W).some((G)=>{if(typeof G==="object"&&G!==null)return K(G);return!1})};if(Array.isArray($.value))q=$.value.some((W)=>typeof W==="string"&&W.includes("{")||typeof W==="object"&&W!==null&&Object.values(W).some((G)=>typeof G==="string"&&G.includes("{"))),U=$.value.some((W)=>K(W));else q=Object.values($.value).some((W)=>typeof W==="string"&&W.includes("{")),U=K($.value);if(q||U){if(["color","shadow","border","background","surface","composition"].includes($.type)){let E;if(Array.isArray($.value))E=$.value.map((A)=>{if(typeof A==="string"&&A.startsWith("{")&&A.endsWith("}")){let z=A.slice(1,-1);if(!z.includes("#dark")&&!z.includes("@dark"))return`{${z}#dark}`;return A}else if(typeof A==="object"&&A!==null){let z={};for(let[L,H]of Object.entries(A))if(typeof H==="string"&&H.startsWith("{")&&H.endsWith("}")){let _=H.slice(1,-1),B=`${_}#dark`,O=Y?.get(_),I=Y?.has(B)||O?.extensions?.mode?.dark!==void 0||O&&(Array.isArray(O.value)||typeof O.value==="object"&&O.value!==null);if(!_.includes("#dark")&&!_.includes("@dark")&&I)z[L]=`{${B}}`;else z[L]=H}else z[L]=H;return z}return A});else if(typeof $.value==="object"&&$.value!==null){E={};let A=(z)=>{if(typeof z==="string"){if(z.startsWith("{")&&z.endsWith("}")){let L=z.slice(1,-1),H=`${L}#dark`,_=(O,I=new Set)=>{if(I.has(O))return!1;I.add(O);let Q=Y?.get(O);if(!Q){let w=O.match(/^(.+)@([^@]+)$/);if(w){let[,J,R]=w,y=Y?.get(J);if(y){if(y.extensions?.mode?.dark!==void 0)return!0;if(y.extensions?.generators)return!0;return _(J,I)}}return!1}if(Q.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${O}#dark`))return!0;if(typeof Q.value==="string"&&Q.value.startsWith("{")&&Q.value.endsWith("}")){let w=Q.value.slice(1,-1);return _(w,I)}if(Array.isArray(Q.value)||typeof Q.value==="object"&&Q.value!==null){let w=(J)=>{if(typeof J!=="object"||J===null)return!1;if(J.$extensions?.mode)return!0;return Object.values(J).some((R)=>{if(typeof R==="object"&&R!==null)return w(R);return!1})};if(Array.isArray(Q.value))return Q.value.some((J)=>typeof J==="string"&&J.includes("{")&&_(J.slice(1,-1),new Set(I))||typeof J==="object"&&J!==null&&(Object.values(J).some((R)=>typeof R==="string"&&R.includes("{")&&_(R.slice(1,-1),new Set(I)))||w(J)));else if(typeof Q.value==="object")return Object.values(Q.value).some((J)=>typeof J==="string"&&J.includes("{")&&_(J.slice(1,-1),new Set(I)))||w(Q.value)}return!1},B=_(L);if(!L.includes("#dark")&&!L.includes("@dark")&&B)return`{${H}}`}return z}if(typeof z==="object"&&z!==null){if(z.$extensions?.mode?.dark)return z.$extensions.mode.dark;let L={};for(let[H,_]of Object.entries(z))L[H]=A(_);return L}return z};for(let[z,L]of Object.entries($.value))E[z]=A(L)}Z.push({...$,name:`${$.name}#dark`,value:E,path:[...$.path,"#dark"],extensions:{...$.extensions,autoGenerated:!0}})}}}if(X.generateModes&&!$.extensions?.mode&&typeof $.value==="string"&&$.value.startsWith("{")&&$.value.endsWith("}")){let q=$.value.slice(1,-1),U=(A,z=new Set)=>{if(z.has(A))return!1;z.add(A);let L=Y?.get(A);if(!L){let H=A.match(/^(.+)@([^@]+)$/);if(H){let[,_,B]=H,O=Y?.get(_);if(O){if(O.extensions?.mode?.dark!==void 0)return!0;if(O.extensions?.generators)return!0;return U(_,z)}}return!1}if(L.extensions?.mode?.dark!==void 0)return!0;if(Y?.has(`${A}#dark`))return!0;if(typeof L.value==="string"&&L.value.startsWith("{")&&L.value.endsWith("}")){let H=L.value.slice(1,-1);return U(H,z)}if(Array.isArray(L.value)||typeof L.value==="object"&&L.value!==null){let H=(_)=>{if(typeof _!=="object"||_===null)return!1;if(_.$extensions?.mode)return!0;return Object.values(_).some((B)=>{if(typeof B==="object"&&B!==null)return H(B);return!1})};if(Array.isArray(L.value))return L.value.some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(z))||typeof _==="object"&&_!==null&&(Object.values(_).some((B)=>typeof B==="string"&&B.includes("{")&&U(B.slice(1,-1),new Set(z)))||H(_)));else if(typeof L.value==="object")return Object.values(L.value).some((_)=>typeof _==="string"&&_.includes("{")&&U(_.slice(1,-1),new Set(z)))||H(L.value)}return!1},K=U(q);if(["color","shadow","border","background","surface","composition"].includes($.type)&&K&&K&&!q.includes("#dark")&&!q.includes("@dark")){let A=`{${q}#dark}`;Z.push({...$,name:`${$.name}#dark`,value:A,path:[...$.path,"#dark"],extensions:{...$.extensions,autoGenerated:!0}})}}if(X.generateDerivedTokens&&$.extensions?.generators)for(let q of $.extensions.generators)for(let[U,K]of Object.entries(q.value)){let W=R2($.name,U),{generators:G,...E}=$.extensions;Z.push({...$,name:W,value:$.value,path:[...$.path,U],extensions:{...E,generator:{type:q.type,value:K}}})}if(X.generateBreakpointTokens&&$.extensions?.breakpoints)for(let[q,U]of Object.entries($.extensions.breakpoints)){let K=`${$.name}@${q.replace(/[^a-zA-Z0-9]/g,"_")}`,W=U.$value||U.value;if(W&&typeof W==="object"&&"$value"in W)W=W.$value;else if(!W&&typeof U==="object"){let{...A}=U;if(Object.keys(A).length>0)W=A}let G=U.$extensions||U.$extensions,E=U.$type;if(!E&&U.value&&typeof U.value==="object")E=U.value.$type;Z.push({...$,name:K,value:W,path:[...$.path,`@${q}`],type:E||$.type,extensions:{mediaQuery:q,...G?{mode:G.mode||G.$mode,generators:G.generators||G.$generators,...Object.fromEntries(Object.entries(G).filter(([A])=>!["mode","$mode","generators","$generators"].includes(A)))}:{}}})}return Z}function uY($,X){let Y=s($.value,X),Z=$.type;if(typeof $.value==="string"&&Q$($.value)){let U=$.value.slice(1,-1),K=X.tokens.get(U);if(K){if(["border","shadow","typography","composition"].includes(K.type))Z=K.type;else if(typeof K.value==="string"&&B$(K.value)){let W=D$(K.value),G=new Set;for(let E of W)if(E.type==="reference"&&E.ref&&typeof E.ref==="string"){let A=E.ref.slice(1,-1),z=X.tokens.get(A);if(z&&["border","shadow","typography","composition"].includes(z.type))G.add(z.type)}if(G.size===1)Z=Array.from(G)[0]}}}if(typeof $.value==="string"&&B$($.value)){let U=D$($.value),K=new Set;for(let W of U)if(W.type==="reference"&&W.ref&&typeof W.ref==="string"){let G=W.ref.slice(1,-1),E=X.tokens.get(G);if(E&&["border","shadow","typography","composition"].includes(E.type))K.add(E.type)}if(K.size===1)Z=Array.from(K)[0]}if(typeof Y==="object"&&Y!==null&&["border","shadow","typography","composition"].includes(Z))Y=c(Y,X);if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=b$($.value,$.extensions.generator.type,$.extensions.generator.value,X);let q=kY($.name,X.options);if(Z==="color"&&typeof Y==="string"&&p(Y))Y=F(Y,$);if(typeof Y==="string"&&m(Y))Y=O$(Y);return{...$,type:Z,value:Y,cssVar:q}}function c($,X){if(typeof $==="string"){if(Q$($))return J0($,X);else if(B$($))return V2($,X)}if(Array.isArray($))return $.map((Y)=>c(Y,X));if(typeof $==="object"&&$!==null){if("$value"in $&&typeof $.$value==="string")return c($.$value,X);if("value"in $&&typeof $.value==="string"&&"$type"in $){if(X.mode&&$.$extensions?.mode?.[X.mode])return c($.$extensions.mode[X.mode],X);return c($.value,X)}if("value"in $&&typeof $.value==="object"&&"$type"in $){let Z=$.value,q=$.$extensions?.delimiter?.character||" ";if($.$type==="composition"&&Z&&typeof Z==="object")return Object.values(Z).map((K)=>c(K,X)).join(q);return c($.value,X)}let Y={};for(let[Z,q]of Object.entries($))Y[Z]=c(q,X);return Y}return $}function s($,X){if(typeof $==="string"){if(B$($))return V2($,X);else if(Q$($))return J0($,X)}else if(typeof $==="object"&&$!==null&&"$ref"in $)return C2($,X);return $}function J0($,X){let Y=$.slice(1,-1),Z=X.tokens.get(Y),q=X.options.modes||[];if(!Z){if(q.length>0){for(let W of q)if(Y.endsWith(`@${W}`)){let G=Y.slice(0,-W.length-1)+`#${W}`;if(Z=X.tokens.get(G),Z)return B0(Z,X);break}}let K=Y.match(/#([^#@]+)$/);if(K){let W=Y.substring(0,K.index),G=K[1];if(Z=X.tokens.get(W),Z){if(Z.extensions?.mode?.[G]){let E=Z.extensions.mode[G],A=s(E,{...X,mode:G});if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)A=b$(A,Z.extensions.generator.type,Z.extensions.generator.value,X);if(Z.type==="color"&&typeof A==="string"&&p(A))A=F(A,Z);if(typeof A==="string"&&m(A))A=O$(A);return A}}}if(q.length>0)for(let W of q){let G=new RegExp(`(@[^@]+)@${W}$`);if(G.test(Y)){let E=Y.replace(G,`$1#${W}`);if(Z=X.tokens.get(E),!Z){let A=E.match(/#([^#@]+)$/);if(A){let z=E.substring(0,A.index),L=A[1];if(Z=X.tokens.get(z),Z&&Z.extensions?.mode?.[L]){let H=Z.extensions.mode[L],_=s(H,{...X,mode:L});if(Z.extensions?.generator&&typeof Z.extensions.generator==="object"&&"type"in Z.extensions.generator&&"value"in Z.extensions.generator)_=b$(_,Z.extensions.generator.type,Z.extensions.generator.value,X);if(Z.type==="color"&&typeof _==="string"&&p(_))_=F(_,Z);if(typeof _==="string"&&m(_))_=O$(_);return _}}}else return B0(Z,X);break}}}if(!Z)return console.warn(`Token reference not found: ${$}`),X.brokenReferences.push($),$;return B0(Z,X)}function B0($,X){let Y;if($.extensions?.generator&&typeof $.extensions.generator==="object"&&"type"in $.extensions.generator&&"value"in $.extensions.generator)Y=b$($.value,$.extensions.generator.type,$.extensions.generator.value,X);else if(X.mode&&$.extensions?.mode?.[X.mode])Y=s($.extensions.mode[X.mode],X);else Y=s($.value,X);if($.type==="color"&&typeof Y==="string"&&p(Y))Y=F(Y,$);if(typeof Y==="string"&&m(Y))Y=O$(Y);return Y}function C2($,X){let Z=$.$ref.slice(2).replace(/\//g,"."),q=X.tokens.get(Z);if(!q)return console.warn(`JSON Pointer reference not found: ${$.$ref}`),X.brokenReferences.push($.$ref),$.$ref;return s(q.value,X)}function V2($,X){let Y=D$($),Z=Y.some((K)=>K.value.includes(",")),q=!0,U=[];for(let K of Y){let W;if(K.type==="reference"&&K.ref){if(typeof K.ref==="string"&&Q$(K.ref)){W=J0(K.ref,X);let G=K.ref.slice(1,-1),E=X.tokens.get(G);if(!E||!["border","shadow","typography","composition"].includes(E.type))q=!1}else if(typeof K.ref==="object"&&"$ref"in K.ref)W=C2(K.ref,X)}else if(W=K.value,K.value.trim()&&K.value.trim()!==",")q=!1;U.push(W)}if(Z&&q)return U.filter((K)=>typeof K==="object"&&K!==null&&typeof K!=="string");return U.map((K)=>String(K)).join("")}function b$($,X,Y,Z){let q=s($,Z);switch(X){case"alpha":if(typeof q==="string")return cY(q,Number(Y)/100);break;case"scale":if(typeof q==="string"&&q.match(/[\d.]+/))return lY(q,Number(Y));break;case"hue":if(typeof q==="string")return rY(q,Number(Y));break;default:return console.warn(`Unknown generator type: ${X}`),q}return q}function kY($,X,Y){let Z=$.replace(/\./g,"-");Z=Z.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),Z=Z.replace(/@[^@#]*(?:screen|width|height|min|max|orientation).*$/i,""),Z=Z.replace(/#[^#]*$/,""),Z=Z.replace(/-@/g,"-").replace(/@/g,"-");let q=Z,U=!0,K=X.prefix||"";if(X.transformName){if(q=X.transformName(Z),q=q.replace(/-+$/,""),q!==Z)U=!1}let W=U&&K?`${K}-${q}`:q,G=Y?`-${Y}`:"";return`--${W}${G}`.replace(/[^a-zA-Z0-9-_]/g,"-")}function cY($,X){try{if(!p($))return $;let Y=new D2($);return Y.alpha=X,F(Y)}catch(Y){return console.warn(`Failed to apply alpha to color "${$}": ${Y}`),$}}function lY($,X){let Y=$.match(/([\d.]+)(\w+)/);if(Y){let[,Z,q]=Y;return`${parseFloat(Z)*X}${q}`}return $}function rY($,X){try{if(!p($))return $;let Z=new D2($).to("oklch");return Z.h=(Z.h+X)%360,F(Z)}catch(Y){return console.warn(`Failed to shift hue for color "${$}": ${Y}`),$}}var R0=P(()=>{x2();W$()});function M0($){if($.type==="typography"||$.type==="fontWeight"||$.type==="fontFamily")return!0;if($.type==="dimension"&&$.name.includes("typography"))return!0;if($.name.includes("typography")||$.name.includes("font"))return!0;return!1}function a($,X,Y){if(Y){if($===X)return":host";return`:host([data-theme="${$}"])`}if($===X)return":root";return`[data-theme="${$}"]`}function C$($,X={}){let{rootSelector:Y=":root",separateThemeFiles:Z=!1,generateMediaQueries:q=!1,customHeader:U,modes:K=["light","dark"]}=X;if(Z)return sY($,X);let W=new Map,G=new Map;for(let Q of K)W.set(Q,[]);let E=K.join("|"),A=new RegExp(`#(${E})$`);for(let Q of $){if(typeof Q.value==="string"&&m(Q.value))continue;if(M0(Q))continue;let w=` ${Q.cssVar}: ${f(Q.value,Q.type)};`;if(q&&Q.name.includes("@media")){let R=T$(Q);if(R){if(!G.has(R))G.set(R,[]);G.get(R).push(w);continue}}let J=Q.name.match(A);if(J){let R=J[1];if(!W.has(R))W.set(R,[]);W.get(R).push(w)}else{let R=K[0]||"light";W.get(R).push(w)}}let z="";if(U)z+=`${U}
|
|
35
35
|
|
|
36
|
-
`;let L=X.defaultMode||K[0]||"light",H=X.isHost||!1,_=W.get(L)||[];if(_.length>0){_.sort();let
|
|
36
|
+
`;let L=X.defaultMode||K[0]||"light",H=X.isHost||!1,_=W.get(L)||[];if(_.length>0){_.sort();let Q=a(L,L,H);z+=`${Q} {
|
|
37
37
|
${_.join(`
|
|
38
38
|
`)}
|
|
39
39
|
`;for(let w of K){if(w===L)continue;let J=W.get(w)||[];if(J.length>0){J.sort();let R=a(w,L,H);if(H)z+=`}
|
|
@@ -47,20 +47,20 @@ ${J.map((p$)=>` ${p$}`).join(`
|
|
|
47
47
|
`)}
|
|
48
48
|
}
|
|
49
49
|
`}}}z+=`}
|
|
50
|
-
`}if(q&&G.size>0){let
|
|
50
|
+
`}if(q&&G.size>0){let Q=a(L,L,H);for(let[w,J]of G)J.sort(),z+=`
|
|
51
51
|
${w} {
|
|
52
|
-
${
|
|
52
|
+
${Q} {
|
|
53
53
|
${J.map((R)=>` ${R}`).join(`
|
|
54
54
|
`)}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
`}let
|
|
57
|
+
`}let B=[{fileName:"tokens.css",content:z}],O=h2($,X);B.push(...O);let I=v2($,X);return B.push(...I),B}function iY($,X){let Y=[];for(let q of $){let K=` ${q.cssVar||V$(q,X)}: ${f(q.value,q.type)};`;Y.push(K)}let Z="";if(X.customHeader)Z+=`${X.customHeader}
|
|
58
58
|
|
|
59
59
|
`;if(Y.length>0)Y.sort(),Z+=`${X.rootSelector||":root"} {
|
|
60
60
|
${Y.join(`
|
|
61
61
|
`)}
|
|
62
62
|
}
|
|
63
|
-
`;return{fileName:"theme.css",content:Z}}function sY($,X){let Y=[],Z=new Map,q=[],U=X.modes||["light","dark"],K=new Set(U),W=U.join("|"),G=new RegExp(`#(${W})$`);for(let _ of $){if(T$(_))continue;if(typeof _.value==="string"&&m(_.value))continue;if(M0(_))continue;let
|
|
63
|
+
`;return{fileName:"theme.css",content:Z}}function sY($,X){let Y=[],Z=new Map,q=[],U=X.modes||["light","dark"],K=new Set(U),W=U.join("|"),G=new RegExp(`#(${W})$`);for(let _ of $){if(T$(_))continue;if(typeof _.value==="string"&&m(_.value))continue;if(M0(_))continue;let B=_.name.match(G);if(B){let O=B[1];if(K.has(O)){if(!Z.has(O))Z.set(O,[]);Z.get(O).push(_)}else q.push(_)}else q.push(_)}if(q.length>0){let _=C$(q,{...X,separateThemeFiles:!1})[0];Y.push({..._,fileName:"tokens.css"})}let E=X.defaultMode||(U.length>0?U[0]:"default"),A=X.isHost||!1;for(let[_,B]of Z){let O=a(_,E,A),I=iY(B,{...X,separateThemeFiles:!1,rootSelector:O});Y.push({...I,fileName:`tokens.${_}.css`,theme:_})}let z=aY($,X);Y.push(...z);let L=h2($,X);Y.push(...L);let H=v2($,X);return Y.push(...H),Y}function aY($,X){let Y=new Map;for(let U of $){let K=T$(U);if(K){let W=U.name.match(/@(dark|light)$/),G=W?W[1]:"light";if(!Y.has(K))Y.set(K,new Map);let E=Y.get(K);if(!E.has(G))E.set(G,[]);E.get(G).push(U)}}if(Y.size===0)return[];let Z=`/**
|
|
64
64
|
* Design System Tokens - Responsive Breakpoints
|
|
65
65
|
* Generated: ${new Date().toISOString()}
|
|
66
66
|
*
|
|
@@ -137,7 +137,7 @@ ${G.sort().map((H)=>` ${H}`).join(`
|
|
|
137
137
|
`;let K=[...$].sort((W,G)=>W.name.localeCompare(G.name));for(let W of K){let G=W.name.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""),E=`${q}-${W.category}-${G}`;if(X.hooks?.shortenName?.enabled)E=N0(E,X.hooks);let A=z1(W.value);U+=` ${E}: url("${A}");
|
|
138
138
|
`}return U+=`}
|
|
139
139
|
`,{fileName:"tokens.icons.css",content:U.trim()+`
|
|
140
|
-
`}}var y$=P(()=>{g()});import{readFileSync as A1,existsSync as E1}from"fs";import{join as p2,relative as L1}from"path";async function j0(){try{let{assets:$}=await i(!0),{icons:X}=await C(),Y=await A$(),Z=$?.icons?.distDir??"build",q=p2(Y,Z),U=p2(q,"tokens",await X$("json"));if(!E1(U)){let z=L1(process.cwd(),U);return console.log(`ℹ️ Icon data not found (skipping icon types): ${z}`),console.log(" Run icon build first if you need icon types generated."),[]}let K=JSON.parse(A1(U,"utf8")),W=X?.objectPath??"universe.icons",G=W.split("."),E=K;for(let z of G)if(E&&typeof E==="object"&&z in E)E=E[z];else throw Error(`Icon path ${W} not found in icons file`);let A=[];for(let[z,L]of Object.entries(E))if(typeof L==="object"&&L!==null){for(let[H,_]of Object.entries(L))if(typeof _==="object"&&_!==null){let
|
|
140
|
+
`}}var y$=P(()=>{g()});import{readFileSync as A1,existsSync as E1}from"fs";import{join as p2,relative as L1}from"path";async function j0(){try{let{assets:$}=await i(!0),{icons:X}=await C(),Y=await A$(),Z=$?.icons?.distDir??"build",q=p2(Y,Z),U=p2(q,"tokens",await X$("json"));if(!E1(U)){let z=L1(process.cwd(),U);return console.log(`ℹ️ Icon data not found (skipping icon types): ${z}`),console.log(" Run icon build first if you need icon types generated."),[]}let K=JSON.parse(A1(U,"utf8")),W=X?.objectPath??"universe.icons",G=W.split("."),E=K;for(let z of G)if(E&&typeof E==="object"&&z in E)E=E[z];else throw Error(`Icon path ${W} not found in icons file`);let A=[];for(let[z,L]of Object.entries(E))if(typeof L==="object"&&L!==null){for(let[H,_]of Object.entries(L))if(typeof _==="object"&&_!==null){let B=_;A.push({name:H,category:z,value:B.$value||"",description:B.$description||"",style:B.$style||"",dimensions:B.$dimensions})}}return A}catch($){if($ instanceof Error){if("code"in $&&$.code!=="ENOENT")console.warn(`⚠️ Could not load icon data: ${$.message}`)}return[]}}async function P0($,X={}){let{generateTypes:Y=!0,generateConsts:Z=!0}=X,q=X.icons;if(!q)q=await j0();let U={...X,icons:q},K=[];if(Y)K.push({fileName:"tokens.types.ts",content:H1($,U),type:"types"});if(Z)K.push({fileName:"tokens.constants.ts",content:_1($,U),type:"constants"});return K.push({fileName:"index.ts",content:Q1(K),type:"index"}),K}function H1($,X){let{tokenInterface:Y="DesignTokens",includeJSDoc:Z=!0,icons:q=[]}=X,U=S0("Type Definitions");if(U+=B1($,Z),U+=O1($,Z),q.length>0)U+=w1(q,Z);return U+=I1($,Y,Z),U+=R1($,Z),U+`
|
|
141
141
|
`}function _1($,X){let{includeJSDoc:Y=!0,icons:Z=[]}=X,q=S0("Token Constants"),U="TokenPaths, CSSVariableNames";if(Z.length>0)U+=", IconNames, IconCategories, Icon";if(q+=`import type { ${U} } from './tokens.types';
|
|
142
142
|
|
|
143
143
|
`,q+=M1($,Y),q+=x1($,Y),Z.length>0)q+=N1(Z,Y);return q+=F1($,Y),q+`
|
|
@@ -320,7 +320,7 @@ ${G.sort().map((H)=>` ${H}`).join(`
|
|
|
320
320
|
* Do not edit this file directly - it will be overwritten.
|
|
321
321
|
*/
|
|
322
322
|
|
|
323
|
-
`}var D0=P(()=>{g()});function D1($,X,Y){let Z=D($,{isIncludedOriginalValue:!0}),q=T($,Y);if(!q||!u($,"mode",{isIncludedOriginalValue:!1}))q=Z;return N$($,q,X,Y)}function j$($,X,Y){let Z=D1($,X,Y),q=typeof Z==="string"?e(Z):null;if(q&&(q?.length??0)>=1)return o(Z,q,X,Y);else return b1($,X,Y)}function b1($,X,Y){return N$($,r$($,X,Y),X,Y)}function N$($,X,Y,Z){if(!$)return null;if($.$type==="color")X=M$(X,$,Y,Z);else if($.$type==="composition"||$.$type==="typography")X=t($,Y,Z);return X}var w$="did";var g=P(()=>{W$();c$();a$();W$();_$();_2();Q2();B2();c$();a$();Q0();R0();y$();D0();C0()});import{readFileSync as C1,mkdirSync as V1}from"fs";import{writeFile as u2,readdir as T1,mkdir as g1}from"fs/promises";import{resolve as y1,relative as k2,join as h$,dirname as h1}from"path";import v1 from"lodash";async function c2($){let X=await T1($,{withFileTypes:!0}),Y=await Promise.all(X.map((Z)=>{let q=y1($,Z.name);return Z.isDirectory()?c2(q):q}));return Array.prototype.concat(...Y)}async function T0(){let{assets:$,icons:X,tokenNamespace:Y,__dirname:Z,buildDir:q}=await k(),U=h$(Z,$?.icons?.sourceDir??"icons"),K="build",W=$?.icons?.distDir??"build",G=h$(Z,W),E=h$(Z,q,"icons");if(!$?.icons?.sourceDir){console.warn("Skipping icon build: iconsDir is not defined in the project paths.");return}r(h$(Z,q));let A=(await c2(U)).filter((
|
|
323
|
+
`}var D0=P(()=>{g()});function D1($,X,Y){let Z=D($,{isIncludedOriginalValue:!0}),q=T($,Y);if(!q||!u($,"mode",{isIncludedOriginalValue:!1}))q=Z;return N$($,q,X,Y)}function j$($,X,Y){let Z=D1($,X,Y),q=typeof Z==="string"?e(Z):null;if(q&&(q?.length??0)>=1)return o(Z,q,X,Y);else return b1($,X,Y)}function b1($,X,Y){return N$($,r$($,X,Y),X,Y)}function N$($,X,Y,Z){if(!$)return null;if($.$type==="color")X=M$(X,$,Y,Z);else if($.$type==="composition"||$.$type==="typography")X=t($,Y,Z);return X}var w$="did";var g=P(()=>{W$();c$();a$();W$();_$();_2();Q2();B2();c$();a$();Q0();R0();y$();D0();C0()});import{readFileSync as C1,mkdirSync as V1}from"fs";import{writeFile as u2,readdir as T1,mkdir as g1}from"fs/promises";import{resolve as y1,relative as k2,join as h$,dirname as h1}from"path";import v1 from"lodash";async function c2($){let X=await T1($,{withFileTypes:!0}),Y=await Promise.all(X.map((Z)=>{let q=y1($,Z.name);return Z.isDirectory()?c2(q):q}));return Array.prototype.concat(...Y)}async function T0(){let{assets:$,icons:X,tokenNamespace:Y,__dirname:Z,buildDir:q}=await k(),U=h$(Z,$?.icons?.sourceDir??"icons"),K="build",W=$?.icons?.distDir??"build",G=h$(Z,W),E=h$(Z,q,"icons");if(!$?.icons?.sourceDir){console.warn("Skipping icon build: iconsDir is not defined in the project paths.");return}r(h$(Z,q));let A=(await c2(U)).filter((Q)=>Q.endsWith(".svg")),H=(await Promise.all(A.map(async(Q)=>{let w=C1(Q,"utf8").replace(/(\s+(?=(?:[^"]*"[^"]*")*[^"]*$))/g," ").trim()??"";w=await H0(w);let J=k2(U,Q).split("/").pop(),R=(w.match(/name="(.*?)"/)??[])[1]??J?.replace(".svg",""),y=(w.match(/data-style="(.*?)"/)??[])[1],p$=(w.match(/description="(.*?)"/)??[])[1],[f0]=w.match(/<svg[^>]*>/)??[],[,WY]=f0?.match(/width="([\d.]+)(px)?"/)??[],[,KY]=f0?.match(/height="([\d.]+)(px)?"/)??[];if(y!=="animated"&&y!=="custom")return{path:Q,folder:k2(U,Q).split("/").slice(0,-1).concat(R),file:J,style:y,content:w,name:R,dimensions:{width:Number(WY),height:Number(KY)},description:p$??""};return}))).filter((Q)=>Q!==void 0).reduce((Q,w)=>{if(w?.style!=="animated"&&w?.style!=="custom"&&w)V0(Q,w.folder.join("."),{$type:"icon",$name:w.name,$description:w.description,$style:w.style,$value:w.content,$dimensions:w.dimensions,...f1(Q,w.folder.join("."))});return Q},{}),_=X?.objectPath??`${Y}.icons`;Object.keys(H).forEach(async(Q)=>{let w=`${E}/${Q}`,J=`${w}/svg.${Q}.tokens.json`;await g1(w,{recursive:!0});let R=V0({},`${_}${_?".":""}${Q}`,H[Q]);await u2(J,JSON.stringify(R,null,2),{flag:"w",encoding:"utf-8"})});let B=`${G}/tokens/${await X$("json")}`,O=h1(B);V1(O,{recursive:!0});let I=V0({},_,H);await u2(B,JSON.stringify(I,null,2),{flag:"w",encoding:"utf-8"})}var V0,f1,DX;var l2=P(()=>{g();({set:V0,get:f1}=v1);DX=T0().catch(($)=>{console.error($),process.exit(1)})});function s2($,X={}){let Y=[],Z=X.typescript?"ts":"js",q=X.modes||[],U=$.filter((W)=>W.extensions?.mediaQuery||W.name.includes("@screen")||W.name.includes("@_")),K=$.filter((W)=>!W.extensions?.mediaQuery&&!W.name.includes("@screen")&&!W.name.includes("@_"));if(X.separateThemeFiles&&q.length>0){let W=q.join("|"),G=new RegExp(`#(${W})$`),E=new Map;for(let A of q)E.set(A,[]);for(let A of K){let z=A.name.match(G);if(z){let L=z[1];E.get(L).push(A)}else{let L=q[0];E.get(L).push(A)}}for(let A of q){let z=E.get(A)||[];if(z.length>0){if(X.typescript){let L=a2(z,A);Y.push({fileName:`${A}.d.ts`,content:c1(L,X,A),theme:A})}Y.push({fileName:`${A}.${Z}`,content:i2(z,{...X,theme:A}),theme:A})}}}else Y.push({fileName:`tokens.${Z}`,content:i2(K,X)});if(U.length>0)Y.push({fileName:`breakpoints.${Z}`,content:p1(U,$,X)});if(X.separateThemeFiles&&Y.length>1)Y.push({fileName:`index.${Z}`,content:r1(Y,X)});return Y}function p1($,X,Y={}){let{typescript:Z,includeJSDoc:q,moduleType:U="es",customHeader:K,modes:W=[]}=Y,G=new Map(X.map((L)=>[L.name,L])),E={};for(let L of $){let H=L.extensions?.mediaQuery||m1(L.name),_=W.length>0?W[0]:"default";for(let I of W)if(L.name.includes(`#${I}`)){_=I;break}if(typeof H==="string"&&H.includes("{")&&H.includes("}"))H=u1(H,G);if(!E[H])E[H]={};if(!E[H][_])E[H][_]={};let B=d1(L.name),O=k1(B,v$(L.value,G));E[H][_]={...E[H][_],...O}}let A=Object.keys(E).sort((L,H)=>{let _=r2(L),B=r2(H);return _-B}).reduce((L,H)=>{return L[H]=E[H],L},{}),z="";if(K)z+=`${K}
|
|
324
324
|
|
|
325
325
|
`;else z+=`/**
|
|
326
326
|
`,z+=` * Design Tokens - Breakpoints
|
|
@@ -402,7 +402,7 @@ ${G.sort().map((H)=>` ${H}`).join(`
|
|
|
402
402
|
// Default export points to light theme
|
|
403
403
|
`,K+=`module.exports = require('./light');
|
|
404
404
|
`}return K+`
|
|
405
|
-
`}var t2=P(()=>{y$()});var o2={};d$(o2,{validateCSSFiles:()=>i1,printValidationResults:()=>s1});import{readFileSync as y0,existsSync as q$}from"fs";import{join as d}from"path";function i1($,X){let Y={isValid:!0,errors:[],warnings:[],checks:[]},Z=d($,"css"),q=d(Z,"tokens.css"),U=q$(q);if(Y.checks.push({name:"CSS file exists: tokens.css",passed:U,message:U?void 0:"Missing required CSS file: tokens.css"}),!U)Y.errors.push("Missing required CSS file: tokens.css"),Y.isValid=!1;if(X.$metaData?.tokens?.css?.mediaQuery?.separateThemeFiles??!1){let z=d(Z,"tokens.dark.css"),L=q$(z);if(Y.checks.push({name:"CSS file exists: tokens.dark.css",passed:L,message:L?void 0:"Missing required CSS file: tokens.dark.css (separateThemeFiles is enabled)"}),!L)Y.errors.push("Missing required CSS file: tokens.dark.css (separateThemeFiles is enabled)"),Y.isValid=!1}let W=d(Z,"tokens.breakpoints.css");if(q$(W))Y.checks.push({name:"CSS file exists: tokens.breakpoints.css",passed:!0,message:void 0});let E=X.$metaData?.tokens?.css?.hooks?.shortenName;if(E?.enabled&&q$(d(Z,"tokens.css"))){let z=y0(d(Z,"tokens.css"),"utf8");if(E.prefix)for(let{find:L,replace:H}of E.prefix){let _=`--${w$}-${L}`,
|
|
405
|
+
`}var t2=P(()=>{y$()});var o2={};d$(o2,{validateCSSFiles:()=>i1,printValidationResults:()=>s1});import{readFileSync as y0,existsSync as q$}from"fs";import{join as d}from"path";function i1($,X){let Y={isValid:!0,errors:[],warnings:[],checks:[]},Z=d($,"css"),q=d(Z,"tokens.css"),U=q$(q);if(Y.checks.push({name:"CSS file exists: tokens.css",passed:U,message:U?void 0:"Missing required CSS file: tokens.css"}),!U)Y.errors.push("Missing required CSS file: tokens.css"),Y.isValid=!1;if(X.$metaData?.tokens?.css?.mediaQuery?.separateThemeFiles??!1){let z=d(Z,"tokens.dark.css"),L=q$(z);if(Y.checks.push({name:"CSS file exists: tokens.dark.css",passed:L,message:L?void 0:"Missing required CSS file: tokens.dark.css (separateThemeFiles is enabled)"}),!L)Y.errors.push("Missing required CSS file: tokens.dark.css (separateThemeFiles is enabled)"),Y.isValid=!1}let W=d(Z,"tokens.breakpoints.css");if(q$(W))Y.checks.push({name:"CSS file exists: tokens.breakpoints.css",passed:!0,message:void 0});let E=X.$metaData?.tokens?.css?.hooks?.shortenName;if(E?.enabled&&q$(d(Z,"tokens.css"))){let z=y0(d(Z,"tokens.css"),"utf8");if(E.prefix)for(let{find:L,replace:H}of E.prefix){let _=`--${w$}-${L}`,B=`--${H}`,O=z.includes(_),I=z.includes(B);if(Y.checks.push({name:`Prefix hook applied: ${L} → ${H}`,passed:!O&&I,message:O?`Old prefix "${_}" still found in CSS, should be "${B}"`:void 0}),O)Y.errors.push(`Prefix transformation failed: "${_}" should be replaced with "${B}"`),Y.isValid=!1}if(E.suffix)for(let{find:L,replace:H}of E.suffix){let B=new RegExp(`--[^:]+${L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}:`,"g").test(z);if(Y.checks.push({name:`Suffix hook applied: ${L} → ${H}`,passed:!B,message:B?`Old suffix "${L}" still found in CSS variable names`:void 0}),B)Y.errors.push(`Suffix transformation failed: "${L}" should be removed/replaced with "${H}"`),Y.isValid=!1}}if(q$(d(Z,"tokens.css"))){let L=y0(d(Z,"tokens.css"),"utf8").match(/:\s*{[^}]+}/g);if(Y.checks.push({name:"No unresolved token references",passed:!L,message:L?`Found unresolved references: ${L.join(", ")}`:void 0}),L)Y.errors.push(`Unresolved token references found: ${L.join(", ")}`),Y.isValid=!1}let A=["tokens.css","tokens.dark.css","tokens.breakpoints.css"];for(let z of A){let L=d(Z,z);if(q$(L)){let H=y0(L,"utf8"),_=(H.match(/\{/g)||[]).length-(H.match(/\}/g)||[]).length;if(Y.checks.push({name:`CSS syntax valid: ${z}`,passed:_===0,message:_!==0?`Mismatched braces in ${z}`:void 0}),_!==0)Y.errors.push(`CSS syntax error in ${z}: mismatched braces`),Y.isValid=!1}}return Y}function s1($){console.log(`
|
|
406
406
|
|
|
407
407
|
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(`
|
|
408
408
|
⚠️ Warnings:`);for(let X of $.warnings)console.log(` ${X}`)}if($.errors.length>0){console.log(`
|
|
@@ -448,8 +448,8 @@ ${W.join(`
|
|
|
448
448
|
`,theme:void 0})}return q}async function d2($){let X=Date.now(),Y={tokenCount:0,cssFiles:[],typescriptFiles:[],javascriptFiles:[],jsonFiles:[],duration:0,warnings:[],errors:[]};try{M(`
|
|
449
449
|
Starting token build process...`,$.verbose);let{initializeColorspace:Z}=await Promise.resolve().then(() => (W$(),d0));await Z(),M("Loading token files...",$.verbose);let q=O0($.tokensDir);M("Parsing tokens...",$.verbose);let U=q4($.config),K=w0(q,U);if(M(`Found ${K.length} tokens`,$.verbose),Y.tokenCount=K.length,K.length===0&&U.namespace){let A=Object.keys(q).filter((z)=>!z.startsWith("$"));if(A.length>0)Y.warnings.push(`⚠️ No tokens found matching tokenNamespace "${U.namespace}". Found root keys: ${A.join(", ")}. Please check if your $metaData.tokenNamespace in designid.config.ts matches.`)}let W=I0(K,U);if(M(`Resolved ${W.length} tokens`,$.verbose),$.generateCSS!==!1){M(`
|
|
450
450
|
Generating CSS files...`,$.verbose);let A=XY($.config,$.cssOptions),z=C$(W,A);for(let L of z){let H=b($.outputDir,"css",L.fileName);l(H,L.content),M(` ✓ ${L.fileName}`,$.verbose)}Y.cssFiles=z}if($.generateCSS!==!1)try{await T0(),M(`
|
|
451
|
-
Generated icon tokens`,$.verbose)}catch(A){if($.verbose)console.warn("Could not build icon tokens:",A)}if($.generateCSS!==!1)try{let A=await j0();if(A.length>0){let z=XY($.config,$.cssOptions),L=F0(A,{customHeader:g$($.config),objectPath:$.config.$metaData?.icons?.objectPath||"universe.custom.path.icons",hooks:z.hooks}),H=b($.outputDir,"css",L.fileName);if(l(H,L.content),M(` ✓ Generated ${L.fileName}`,$.verbose),Y.cssFiles)Y.cssFiles.push(L);else Y.cssFiles=[L]}}catch(A){if($.verbose)console.warn("Could not generate icon CSS:",A)}let G=!1;if($.generateCSS!==!1)try{let A=$.config.$fonts;if(A&&A.length>0){await _0(A,$.outputDir),M(" ✓ 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(A){if($.verbose)console.warn("Could not generate font CSS:",A)}if($.generateCSS!==!1&&Y.cssFiles.length>0){let A=$.config.$metaData?.tokenNamespace||"tokens",z=Y.cssFiles.some((
|
|
452
|
-
Processing composition files...`,$.verbose);let
|
|
451
|
+
Generated icon tokens`,$.verbose)}catch(A){if($.verbose)console.warn("Could not build icon tokens:",A)}if($.generateCSS!==!1)try{let A=await j0();if(A.length>0){let z=XY($.config,$.cssOptions),L=F0(A,{customHeader:g$($.config),objectPath:$.config.$metaData?.icons?.objectPath||"universe.custom.path.icons",hooks:z.hooks}),H=b($.outputDir,"css",L.fileName);if(l(H,L.content),M(` ✓ Generated ${L.fileName}`,$.verbose),Y.cssFiles)Y.cssFiles.push(L);else Y.cssFiles=[L]}}catch(A){if($.verbose)console.warn("Could not generate icon CSS:",A)}let G=!1;if($.generateCSS!==!1)try{let A=$.config.$fonts;if(A&&A.length>0){await _0(A,$.outputDir),M(" ✓ 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(A){if($.verbose)console.warn("Could not generate font CSS:",A)}if($.generateCSS!==!1&&Y.cssFiles.length>0){let A=$.config.$metaData?.tokenNamespace||"tokens",z=Y.cssFiles.some((O)=>O.fileName==="tokens.icons.css"),L=$.config.$metaData?.modes?.isHost||!1,H=Y.cssFiles.filter((O)=>{if(O.fileName==="tokens.icons.css"||O.fileName==="fonts.css")return!1;if(L&&O.fileName.includes("composition"))return!1;return!0}),_=o1(H,A,z,G),B=b($.outputDir,_.fileName);if(l(B,_.content),M(` ✓ Generated ${_.fileName}`,$.verbose),Y.cssFiles.push(_),L){let O=e1(Y.cssFiles.filter((Q)=>Q.fileName!=="tokens.icons.css"&&Q.fileName!=="fonts.css"&&!Q.fileName.includes(".design-system.tokens.css")),A,z,G,$.outputDir),I=b($.outputDir,O.fileName);l(I,O.content),M(` ✓ Generated ${O.fileName} (raw/inline for web components)`,$.verbose),Y.cssFiles.push(O)}}let E=$.config.$metaData?.modes?.isHost??!1;if($.generateCSS!==!1&&$.config.$paths.compositionsDir&&!E)try{let A=$.config.$paths.baseDir,z=$.config.$paths.tokensDir,L=$.tokensDir,H=z.split("/").filter((Q)=>Q&&Q!=="."&&Q!=="..");for(let Q=0;Q<H.length;Q++)L=J$(L);let _=A.split("/").filter((Q)=>Q&&Q!=="."&&Q!=="..");for(let Q=0;Q<_.length;Q++)L=J$(L);let B=b(L,A,$.config.$paths.compositionsDir),O=b(L,A);if($.verbose)console.log(` Project root: ${L}`),console.log(` Base dir: ${O}`),console.log(` Compositions dir: ${B}`);let I=$4($.tokensDir,B);if(!I.valid)console.error(I.error),Y.errors.push(I.error);else{M(`
|
|
452
|
+
Processing composition files...`,$.verbose);let Q=Y4(B,O);if(Q.length>0){M(` Found ${Q.length} composition(s)`,$.verbose);let w=new Map;for(let R of W)w.set(R.path,R);let J=Z4(Q,$.config,w,$.outputDir);for(let R of J){let y=b($.outputDir,"css",R.fileName);l(y,R.content),M(` ✓ Generated ${R.fileName}`,$.verbose),Y.cssFiles.push(R)}}else M(` No compositions found in ${B}`,$.verbose)}}catch(A){if($.verbose)console.warn("Could not generate composition CSS:",A)}if($.generateTypeScript!==!1){M(`
|
|
453
453
|
Generating TypeScript files...`,$.verbose);let A=U4($.config,$.typescriptOptions),z=await P0(W,A);for(let L of z){let H=b($.outputDir,"typescript",L.fileName);l(H,L.content),M(` ✓ Generated ${L.fileName}`,$.verbose)}Y.typescriptFiles=z}if($.generateJavaScript!==!1){M(`
|
|
454
454
|
Generating JavaScript files...`,$.verbose);let A=W4($.config,$.javascriptOptions),z=s2(W,A);for(let L of z){let H=b($.outputDir,"js",L.fileName);l(H,L.content),M(` ✓ Generated ${L.fileName}`,$.verbose)}Y.javascriptFiles=z}if($.generateJSON!==!1){M(`
|
|
455
455
|
Generating JSON files...`,$.verbose);let A=K4(W,K,$.config);for(let z of A){let L=b($.outputDir,"json",z.fileName);l(L,z.content),M(` ✓ Generated ${z.fileName}`,$.verbose)}Y.jsonFiles=A}Y.duration=Date.now()-X,M(`
|