UNPKG

@infinityfx/fluid

Version:

React UI library, using zero-runtime CSS-in-JS.

3 lines (2 loc) 2.79 kB
import e from"fs";import{readFile as o}from"fs/promises";import t from"readline";import{glob as n}from"glob";import{mergeRecursive as s}from"../core/utils.js";import{GLOBAL_CONTEXT as i}from"../core/shared.js";function r(e){t.cursorTo(process.stdout,0),process.stdout.write(`${(100*e).toFixed(1)}% `+new Array(Math.round(40*e)).fill("=").join(""))}const c=e=>({index:0,entries:e,start:performance.now(),compiled:0,files:[]});function a(e){console.log("\n"),console.log(`Compiled ${e.compiled} components in ${((performance.now()-e.start)/1e3).toFixed(2)} sec.`),console.log(),console.log("File Size"),e.files.forEach((({name:e,size:o})=>console.log(`${e.padEnd(41," ")}${(o/1024).toFixed(1)}kb`))),console.log("")}function l(e,o,t="{}"){let n=1;for(;n>0;)e.charAt(o)==t.charAt(0)&&n++,e.charAt(o)==t.charAt(1)&&n--,n>0&&o++;return o}function m(e,o,t,n){return e.slice(0,o)+n+e.slice(t)}function p(e){return["core(\\/|\\\\)style\\.js","(\\/|\\\\)fluid(\\/|\\\\)css","styles(\\/|\\\\).+?"].map((e=>new RegExp(`import[^;]*?${e}("|');?`,"g"))).forEach((o=>e=e.replace(o,""))),e}const f=e=>e.replace(/^\s+|\s+(as\s+.+)?$/g,"").replace(/\.\w+$/,"").replace(/([a-z])([A-Z])/,"$1-$2").toLowerCase();function d(e,o){return Array.from(e.matchAll(new RegExp(`import\\s*(?:\\{([^\\}]+)\\}|\\*\\s+as.*|\\w+)\\s*from\\s*(?:'|")@infinityfx\\/${o}(?:'|")`,"g"))).map((([e,o])=>o?o.split(",").map(f):null)).flat()}let u;async function h(t){if(!u){const[t]=await n("./fluid.config.{js,mjs}");try{const[r,c,a]=await Promise.all([t&&import(`file://${process.cwd()}/${t}?nonce=${Math.random()}`),t&&o(process.cwd()+`/${t}`,{encoding:"ascii"}),n(["./node_modules/@infinityfx/fluid/package.json","./package.json"])]);r&&c&&(u=r.default,i.theme=s(u.theme,i.theme),i.components=u.components||{},i.paths=u.paths||i.paths,i.cssOutput=u.cssOutput||i.cssOutput,i.icons=u.icons||{},i.rawConfig=c);const l=a.length>1?a.find((e=>e.startsWith("node_modules"))):a[0],{name:m,version:p}=JSON.parse(e.readFileSync(l,{encoding:"ascii"}));i.name=m,i.version=p,i.isInternal=a.length<2}catch{}}return void 0!==t&&(i.isDev=t),i}function g(o,t=!1){const n=t&&/@infinityfx\/fluid\/$/.test(o)?"./":o;return e.existsSync(n)?{root:n,parent:o.match(/.+\/(.+)\/$/)?.[1]||"",timestamp:Date.now(),module:async e=>(await import(`file://${process.cwd()}/${n}dist/${e}?nonce=${Math.random()}`)).default,source:o=>e.readFileSync(n+"dist/"+o,{encoding:"ascii"}),output(o,t){e.writeFileSync(n+"compiled/"+o,t)},override(o,t){e.writeFileSync(n+"dist/"+o,t)}}:null}export{c as emptyStats,d as extractImports,h as getContext,g as getIOHelper,f as keyFromImport,l as matchBrackets,r as printProgress,a as printStats,m as replace,p as stripImports}; //# sourceMappingURL=utils.js.map