@infinityfx/fluid
Version:
React UI library, using zero-runtime CSS-in-JS.
3 lines (2 loc) • 1.95 kB
JavaScript
import e from"fs";import{unlink as s}from"fs/promises";import{compileFile as o,emitCss as t}from"./core.js";import{getContext as r,printProgress as i}from"./utils.js";import{glob as c}from"glob";async function a(e){const{theme:s}=await r();let o=Array.from(new Set([...Object.keys(s.palettes),"light","dark","system"]).keys()),t=e.source("./types/src/types.d.ts");t=t.replace(/(FluidColorScheme\s*=\s*).+?(;)/,`$1${o.map((e=>`'${e}'`)).join(" | ")}$2`),e.override("./types/src/types.d.ts",t)}async function n(e){const{icons:s,rawConfig:o}=await r();let t=e.source("./core/icons.js");for(const e in s)t=t.replace(new RegExp(`${e}:\\w+(,|\\})`),`${e}:${s[e].name}$1`);t=Array.from(o.matchAll(/import\s*(.+?)from\s*(?:"|')([^"']+)(?:"|')/g)).concat(Array.from(o.matchAll(/(?:const|let|var)\s*(.+?)\s*=\s*require\((?:'|")([^"']+)(?:"|')/g))).map((([e,s,o])=>`import ${s.replace(/:/g," as ")} from "${o}";`)).join("")+t,e.output("./core/icons.js",t)}async function l(o,t){for(const{file:e}of t){const s=o.source(e).replace(/\.\/compiled/g,"");o.override(e,s)}const r=await c(o.root+"compiled/*.css");await Promise.all(r.map(s)),e.cpSync(o.root+"dist/",o.root+"compiled/",{recursive:!0,filter:e=>!/((bin|styles|types)$|\.map$)/.test(e)})}async function m(e,s,c){(await r()).styles={};for(const{file:t,shallow:r,inject:a}of s){const s=e.source(t);if(!r){let t,r=Array.from(s.matchAll(/as\s*(.+?)\s*\}\s*from\s*(?:'|")(.+?)(?:'|");/g)),n=0,l=r.length;for(;t=r.shift();){const[s,m,f]=t;if(r.length>0&&m===a)r.push(t);else{if(/index.js$/.test(f)){const s=await e.module(f);for(const t in s)await o(e,`${m}.${t}`,f.replace(/index\.js$/,`${t.toLowerCase()}.js`))}else await o(e,m,f,m===a);i(c.index/c.entries+ ++n/l/c.entries)}}}e.override(t,s.replace(/(from\s*(?:'|"))\.\/(.*?(?:'|");)/g,"$1../compiled/$2"))}await t(e,c,"fluid"!==e.parent)}export{m as compileComponents,n as compileIcons,a as compileTypes,l as purge};
//# sourceMappingURL=compile.js.map