bernova 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to Bernova will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.2] - 2926-01-28
9
+
10
+ ### Patch
11
+
12
+ - **Fixed js modules compability**: Fixed the compability when the js modules are transpiled with ts-node
13
+ - **Deleted multiple ora instances**: Delete the multiple ora instances to prevent failures
14
+
15
+ ## [1.3.1] - 2026-01-21
16
+
17
+ ### Patch
18
+
19
+ - **prevent minify provider**: Prevent minify providerTemplate.js file
20
+
8
21
  ## [1.3.0] - 2026-01-21
9
22
 
10
23
  ### New Features
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const{bernovaStyles:e}=require("../src/app.js"),{compilerTypeValid:r}=require("../src/constants/compilerType.js");(async()=>{const{default:o}=await import("ora"),s=o("Starting Bernova compilation process...").start();try{const o=(process.argv.find(e=>e===`--${r.full}`||e===`--${r.foundationOnly}`||e===`--${r.componentOnly}`)||`--${r.full}`).replace("--","");await e(o),s.succeed("Bernova compilation process completed successfully.")}catch(e){s.fail("An error occurred during the Bernova compilation process."),console.error("Error details:",e.message),process.exit(1)}})();
2
+ const{bernovaStyles:e}=require("../src/app.js"),{compilerTypeValid:r}=require("../src/constants/compilerType.js");(async()=>{try{const s=(process.argv.find(e=>e===`--${r.full}`||e===`--${r.foundationOnly}`||e===`--${r.componentOnly}`)||`--${r.full}`).replace("--","");await e(s)}catch(e){console.error("Error details:",e.message),process.exit(1)}})();
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const e=require("fs").promises,s=require("path"),t=require("@babel/core"),{minify:n}=require("terser"),{extractDocFragment:r,writeDoc:a,fileExists:o,readConfigData:i,buildRelativePath:c}=require("../src/lib");async function l({baseOutPath:t,jsFile:n,rootDir:i,customOutDirs:l,dir:m,minifyJS:p,preventMoveJS:h,provider:f,type:y="",embedCss:b,cssFiles:g}){const D=n.name.endsWith(".d.ts"),j=s.resolve(m,n.path,n.name);if(!o(m,j))return void console.error(`File not found: ${j}`);let C=await e.readFile(j,"utf8");const O=!!l?.css||b&&g.length>0;if("stats.js"===n.name&&O){const t=r({section:"CssThemes",doc:C}),n=t.replace(/export const cssThemes\s*=\s*/,""),a=new Function(`return (${n})`)();if(l?.css){const e=s.relative(i||"",f.path),n=c({from:s.resolve(e),to:s.resolve(m,l.css)}),r=v({cssThemes:a,cssOutPath:""!==y?s.join("../",n):n});C=C.replace(t,`export const cssThemes = {\n${r}};\n`)}else if(b&&g.length>0){const n={},r=await g.reduce(async(t,{name:r,path:a,parent:i})=>{const c=s.resolve(m,a,r);if(o(m,c)){const s=await e.readFile(c,"utf8");if(i)i.forEach(e=>{const{name:t,position:r}=e;t in n||(n[t]={before:"",after:""}),n[t][r]+=s.replace(/\s+/g,"")});else{const e=r.replace(".css","").replace(".min","");e in t||(t[e]=""),t[e]+=s.replace(/\s+/g,"")}}return t},{}),a=`export const cssThemes = {\n${Object.entries(r).reduce((e,[s,t])=>{const r=n[s]||{before:"",after:""};return e+`'${s}': { css: \`${r.before+t+r.after}\` },\n`},"")}};\n`;C=C.replace(t,a)}}if(n.name===`${f.name.toLocaleLowerCase()}.js`&&O){const t="\n #linkBuilder = (css, id) => {\n if (typeof document === 'undefined') return;\n let styleElement = document.getElementById(id);\n if (!styleElement) {\n styleElement = document.createElement('style');\n styleElement.id = id;\n styleElement.type = 'text/css';\n document.head.appendChild(styleElement);\n }\n styleElement.innerHTML = css;\n };\n #handlerThemes = (data) => {\n const { css } = data;\n this.#linkBuilder(css, this.#linkId);\n };\n #cleanUpLinks = () => {\n if (typeof document === 'undefined') return;\n const style = document.getElementById(this.#linkId);\n if (style) style.remove();\n };\n ",n="../src/lib/generateProvider/template/providerTemplate.js";let a=await e.readFile(s.resolve(__dirname,n),"utf8");a=a.replace(/\$_Provider_\$/g,f.name);const o=r({section:"Bernova provider methods",doc:a});C=a.replace(o,t.trim())}if(n.name===`${f.name.toLocaleLowerCase()}.d.ts`&&O){const t="\n #linkBuilder(css: string, id: string): void;\n #handlerThemes(data: { css: string }): void;\n #cleanUpLinks(): void;\n ",n="../src/lib/generateProvider/template/providerTemplate.d.ts";let a=await e.readFile(s.resolve(__dirname,n),"utf8");a=a.replace(/\$_Provider_\$/g,f.name);const o=r({section:"Bernova provider methods",doc:a});C=a.replace(o,t.trim())}"cjs"!==y||D||(C=await d(C,j,!0)),"esm"!==y||D||(C=await d(C,j)),p&&!D&&(C=await u(C));const $=s.relative(i||"",n.path),w=h?j:s.resolve(t,$,n.name);await a(w,C,n.name)}async function m({baseOutPath:t,cssFiles:n,rootDir:r,customOutDirs:i,dir:c}){for(const l of n){const n=(()=>r&&!i?.css?s.relative(r,l.path):i?.css?i.css:l.path)(),m=s.resolve(c,l.path,l.name);if(o(c,m)){const r=await e.readFile(m,"utf8"),o=l.name.replace(".min","");await a(s.resolve(t,n,o),r,o)}}}function p({baseOutDir:e,type:t="-"}){const n=(()=>{switch(t){case"cjs":return"cjs";case"esm":return"esm";default:return""}})();return s.join(e,n)}async function d(e,s,n=!1){const r=!!n&&"commonjs";return(await t.transformAsync(e,{filename:s,presets:[["@babel/preset-env",{modules:r,targets:{node:"current"}}]]})).code}async function u(e){return(await n(e,{compress:{dead_code:!0,drop_console:!1,drop_debugger:!0,keep_classnames:!1,keep_fargs:!0,keep_fnames:!1,keep_infinity:!1},mangle:{toplevel:!1},format:{comments:!1}})).code}function h({themes:e,minifyCss:t}){return e&&Array.isArray(e)&&e.length>0?e.reduce((e,n)=>{const{name:r,stylesPath:a,foreignThemes:o}=n;return r&&a&&y(e,{name:t?`${r}.min.css`:`${r}.css`,path:a}),o&&Array.isArray(o)&&o.length>0&&o.forEach(t=>{const n=s.basename(t.path),a=t.path.replace(n,"").trim(),o=e.findIndex(e=>e.name===n&&e.path===a);o>=0?e[o].parent.push({name:r,position:t.position}):e.push({name:n,path:a,parent:[{name:r,position:t.position}]})}),e},[]):[]}function f({provider:e,themes:s,preventMoveDTS:t=!1}){const n=s&&s.bvTools?s.reduce((e,{bvTools:s})=>{const{path:n,declarationHelp:r,cssVariables:a,cssClassNames:o,cssMediaQueries:i,cssGlobalStyles:c,availableComponents:l}=s,m=r&&!t;return a&&(y(e,{name:"cssVars.js",path:n}),m&&y(e,{name:"cssVars.d.ts",path:n})),o&&(y(e,{name:"cssClasses.js",path:n}),m&&y(e,{name:"cssClasses.d.ts",path:n})),i&&(y(e,{name:"cssMediaQueries.js",path:n}),m&&y(e,{name:"cssMediaQueries.d.ts",path:n})),c&&(y(e,{name:"cssGlobalStyles.js",path:n}),m&&y(e,{name:"cssGlobalStyles.d.ts",path:n})),l&&(y(e,{name:"cssAvailableComponents.js",path:n}),m&&y(e,{name:"cssAvailableComponents.d.js",path:n})),e},[]):[];return e&&(y(n,{name:`${e.name.toLocaleLowerCase()}.js`,path:e.path}),y(n,{name:"stats.js",path:`${e.path}/stats`}),e.declarationHelp&&!t&&(y(n,{name:`${e.name.toLocaleLowerCase()}.d.ts`,path:e.path}),y(n,{name:"stats.d.ts",path:`${e.path}/stats`}))),n}function v({cssThemes:e,cssOutPath:t}){return Object.entries(e).reduce((e,[n,{foreign:r}])=>{const{before:a,after:o}=r,i=a&&Array.isArray(a)&&a.length>0?a.reduce((e,n,r)=>{const a=s.basename(n);return r>0&&(e+=", "),e+`'${t}/${a}'`},""):"",c=o&&Array.isArray(o)&&o.length>0?o.reduce((e,n,r)=>{const a=s.basename(n);return r>0&&(e+=", "),e+`'${t}/${a}'`},""):"";return e+`'${n}': { css: '${t}/${n}.css', foreign: { before: [${i}], after: [${c}] } },\n`},"")}function y(e,s){e.some(e=>e.name===s.name&&e.path===s.path)||e.push(s)}function b(){const e=["--base-out-dir","--root-dir","--prevent-process-js","--prevent-move-js","--prevent-move-dts","--types","--css","--tools","--provider","--embed-css"],s={};for(let t=0;t<process.argv.length;t++)if(e.includes(process.argv[t])){const n=process.argv[t].replace("--","").replace(/-([a-z])/g,(e,s)=>s.toUpperCase()),r=process.argv[t+1];s[n]=(()=>!(r&&!e.includes(r))||("none"===r.toLocaleLowerCase()?"":r))()}return s}function g({jsonCustomOutDirs:e,cliCustomOutDirs:s}){let t={};return e&&(t={...e}),s&&(t={...t,...s}),Object.keys(t).length>0?t:void 0}(async()=>{const e=process.cwd(),t=await i(s.resolve(e,"bernova.config.json")),{compilerOptions:n,provider:r,themes:a}=t;n&&r&&a||(console.error("Invalid configuration: Missing compilerOptions, themes or provider"),process.exit(1));const{baseOutDir:o,rootDir:c,minifyCss:d,minifyJS:u,preventMoveJS:v,preventMoveDTS:y,types:D,embedCss:j,customOutDirs:C}=n,{baseOutDir:O,rootDir:$,types:w,preventMoveJs:T,preventMoveDts:F,preventProcessJs:_=!1,embedCss:M,...P}=b(),S=O??o??"",A=$??c??void 0,E=T??v??!1,L=F??y??!1,k=w??D??void 0,J=M??j??!1,x=g({jsonCustomOutDirs:C,cliCustomOutDirs:P}),B=h({themes:a,minifyCss:d}),I=_?[]:f({provider:r,themes:a,preventMoveDTS:L}),q=p({baseOutDir:S});if(B&&B.length>0&&!J&&await m({baseOutPath:q,cssFiles:B,rootDir:A,customOutDirs:x,dir:e}),I&&I.length>0)if(k&&Array.isArray(k)&&k.length>0)for(const s of k){const t=p({baseOutDir:S,type:s});for(const n of I)await l({baseOutPath:t,jsFile:n,rootDir:A,customOutDirs:x,dir:e,minifyJS:u,preventMoveJS:E,provider:r,type:s,embedCss:J,cssFiles:B})}else for(const s of I)await l({baseOutPath:q,jsFile:s,rootDir:A,customOutDirs:x,dir:e,minifyJS:u,preventMoveJS:E,provider:r,embedCss:J,cssFiles:B})})();
2
+ const e=require("fs").promises,s=require("path"),t=require("@babel/core"),{minify:n}=require("terser"),{extractDocFragment:r,writeDoc:a,fileExists:o,readConfigData:i}=require("../src/lib");async function c({baseOutPath:t,jsFile:n,rootDir:i,customOutDirs:c,dir:l,minifyJS:m,preventMoveJS:u,provider:h,type:v="",embedCss:y,cssFiles:b}){const g=n.name.endsWith(".d.ts"),D=s.resolve(l,n.path,n.name);if(!o(l,D))return void console.error(`File not found: ${D}`);let j=await e.readFile(D,"utf8");const C=!!c?.css||y&&b.length>0;if("stats.js"===n.name&&C){const t=r({section:"CssThemes",doc:j}),n=t.replace(/export const cssThemes\s*=\s*/,""),a=new Function(`return (${n})`)();if(c?.css){const e=f({cssThemes:a,cssOutPath:c.css});j=j.replace(t,`export const cssThemes = {\n${e}};\n`)}else if(y&&b.length>0){const n={},r=await b.reduce(async(t,{name:r,path:a,parent:i})=>{const c=s.resolve(l,a,r);if(o(l,c)){const s=await e.readFile(c,"utf8");if(i)i.forEach(e=>{const{name:t,position:r}=e;t in n||(n[t]={before:"",after:""}),n[t][r]+=s.replace(/\s+/g,"")});else{const e=r.replace(".css","").replace(".min","");e in t||(t[e]=""),t[e]+=s.replace(/\s+/g,"")}}return t},{}),a=`export const cssThemes = {\n${Object.entries(r).reduce((e,[s,t])=>{const r=n[s]||{before:"",after:""};return e+`'${s}': { css: \`${r.before+t+r.after}\` },\n`},"")}};\n`;j=j.replace(t,a)}}if(n.name===`${h.name.toLocaleLowerCase()}.js`&&C){const t="\n #linkBuilder = (css, id) => {\n if (typeof document === 'undefined') return;\n let styleElement = document.getElementById(id);\n if (!styleElement) {\n styleElement = document.createElement('style');\n styleElement.id = id;\n styleElement.type = 'text/css';\n document.head.appendChild(styleElement);\n }\n styleElement.innerHTML = css;\n };\n #handlerThemes = (data) => {\n const { css } = data;\n this.#linkBuilder(css, this.#linkId);\n };\n #cleanUpLinks = () => {\n if (typeof document === 'undefined') return;\n const style = document.getElementById(this.#linkId);\n if (style) style.remove();\n };\n ",n="../src/lib/generateProvider/template/providerTemplate.js";let a=await e.readFile(s.resolve(__dirname,n),"utf8");a=a.replace(/\$_Provider_\$/g,h.name);const o=r({section:"Bernova provider methods",doc:a});j=a.replace(o,t.trim())}if(n.name===`${h.name.toLocaleLowerCase()}.d.ts`&&C){const t="\n #linkBuilder(css: string, id: string): void;\n #handlerThemes(data: { css: string }): void;\n #cleanUpLinks(): void;\n ",n="../src/lib/generateProvider/template/providerTemplate.d.ts";let a=await e.readFile(s.resolve(__dirname,n),"utf8");a=a.replace(/\$_Provider_\$/g,h.name);const o=r({section:"Bernova provider methods",doc:a});j=a.replace(o,t.trim())}"cjs"!==v||g||(j=await p(j,D,!0)),"esm"!==v||g||(j=await p(j,D)),m&&!g&&(j=await d(j));const O=s.relative(i||"",n.path),$=u?D:s.resolve(t,O,n.name);await a($,j,n.name)}async function l({baseOutPath:t,cssFiles:n,rootDir:r,customOutDirs:i,dir:c}){for(const l of n){const n=(()=>r&&!i?.css?s.relative(r,l.path):i?.css?i.css:l.path)(),m=s.resolve(c,l.path,l.name);if(o(c,m)){const r=await e.readFile(m,"utf8"),o=l.name.replace(".min","");await a(s.resolve(t,n,o),r,o)}}}function m({baseOutDir:e,type:t="-"}){const n=(()=>{switch(t){case"cjs":return"cjs";case"esm":return"esm";default:return""}})();return s.join(e,n)}async function p(e,s,n=!1){const r=!!n&&"commonjs";return(await t.transformAsync(e,{filename:s,presets:[["@babel/preset-env",{modules:r,targets:{node:"current"}}]]})).code}async function d(e){return(await n(e,{compress:{dead_code:!0,drop_console:!1,drop_debugger:!0,keep_classnames:!1,keep_fargs:!0,keep_fnames:!1,keep_infinity:!1},mangle:{toplevel:!1},format:{comments:!1}})).code}function u({themes:e,minifyCss:t}){return e&&Array.isArray(e)&&e.length>0?e.reduce((e,n)=>{const{name:r,stylesPath:a,foreignThemes:o}=n;return r&&a&&v(e,{name:t?`${r}.min.css`:`${r}.css`,path:a}),o&&Array.isArray(o)&&o.length>0&&o.forEach(t=>{const n=s.basename(t.path),a=t.path.replace(n,"").trim(),o=e.findIndex(e=>e.name===n&&e.path===a);o>=0?e[o].parent.push({name:r,position:t.position}):e.push({name:n,path:a,parent:[{name:r,position:t.position}]})}),e},[]):[]}function h({provider:e,themes:s,preventMoveDTS:t=!1}){const n=s&&s.bvTools?s.reduce((e,{bvTools:s})=>{const{path:n,declarationHelp:r,cssVariables:a,cssClassNames:o,cssMediaQueries:i,cssGlobalStyles:c,availableComponents:l}=s,m=r&&!t;return a&&(v(e,{name:"cssVars.js",path:n}),m&&v(e,{name:"cssVars.d.ts",path:n})),o&&(v(e,{name:"cssClasses.js",path:n}),m&&v(e,{name:"cssClasses.d.ts",path:n})),i&&(v(e,{name:"cssMediaQueries.js",path:n}),m&&v(e,{name:"cssMediaQueries.d.ts",path:n})),c&&(v(e,{name:"cssGlobalStyles.js",path:n}),m&&v(e,{name:"cssGlobalStyles.d.ts",path:n})),l&&(v(e,{name:"cssAvailableComponents.js",path:n}),m&&v(e,{name:"cssAvailableComponents.d.js",path:n})),e},[]):[];return e&&(v(n,{name:`${e.name.toLocaleLowerCase()}.js`,path:e.path}),v(n,{name:"stats.js",path:`${e.path}/stats`}),e.declarationHelp&&!t&&(v(n,{name:`${e.name.toLocaleLowerCase()}.d.ts`,path:e.path}),v(n,{name:"stats.d.ts",path:`${e.path}/stats`}))),n}function f({cssThemes:e,cssOutPath:t}){return Object.entries(e).reduce((e,[n,{foreign:r}])=>{const{before:a,after:o}=r,i=a&&Array.isArray(a)&&a.length>0?a.reduce((e,n,r)=>{const a=s.basename(n);return r>0&&(e+=", "),e+`'${t}/${a}'`},""):"",c=o&&Array.isArray(o)&&o.length>0?o.reduce((e,n,r)=>{const a=s.basename(n);return r>0&&(e+=", "),e+`'${t}/${a}'`},""):"";return e+`'${n}': { css: '${t}/${n}.css', foreign: { before: [${i}], after: [${c}] } },\n`},"")}function v(e,s){e.some(e=>e.name===s.name&&e.path===s.path)||e.push(s)}function y(){const e=["--base-out-dir","--root-dir","--prevent-process-js","--prevent-move-js","--prevent-move-dts","--types","--css","--tools","--provider","--embed-css"],s={};for(let t=0;t<process.argv.length;t++)if(e.includes(process.argv[t])){const n=process.argv[t].replace("--","").replace(/-([a-z])/g,(e,s)=>s.toUpperCase()),r=process.argv[t+1];s[n]=(()=>!(r&&!e.includes(r))||("none"===r.toLocaleLowerCase()?"":r))()}return s}function b({jsonCustomOutDirs:e,cliCustomOutDirs:s}){let t={};return e&&(t={...e}),s&&(t={...t,...s}),Object.keys(t).length>0?t:void 0}(async()=>{const e=process.cwd(),t=await i(s.resolve(e,"bernova.config.json")),{compilerOptions:n,provider:r,themes:a}=t;n&&r&&a||(console.error("Invalid configuration: Missing compilerOptions, themes or provider"),process.exit(1));const{baseOutDir:o,rootDir:p,minifyCss:d,minifyJS:f,preventMoveJS:v,preventMoveDTS:g,types:D,embedCss:j,customOutDirs:C}=n,{baseOutDir:O,rootDir:$,types:w,preventMoveJs:T,preventMoveDts:F,preventProcessJs:_=!1,embedCss:M,...S}=y(),A=O??o??"",E=$??p??void 0,L=T??v??!1,P=F??g??!1,k=w??D??void 0,J=M??j??!1,x=b({jsonCustomOutDirs:C,cliCustomOutDirs:S}),B=u({themes:a,minifyCss:d}),I=_?[]:h({provider:r,themes:a,preventMoveDTS:P}),q=m({baseOutDir:A});if(B&&B.length>0&&!J&&await l({baseOutPath:q,cssFiles:B,rootDir:E,customOutDirs:x,dir:e}),I&&I.length>0)if(k&&Array.isArray(k)&&k.length>0)for(const s of k){const t=m({baseOutDir:A,type:s});for(const n of I)await c({baseOutPath:t,jsFile:n,rootDir:E,customOutDirs:x,dir:e,minifyJS:f,preventMoveJS:L,provider:r,type:s,embedCss:J,cssFiles:B})}else for(const s of I)await c({baseOutPath:q,jsFile:s,rootDir:E,customOutDirs:x,dir:e,minifyJS:f,preventMoveJS:L,provider:r,embedCss:J,cssFiles:B})})();
package/dist/src/app.js CHANGED
@@ -1 +1 @@
1
- const e=require("path"),{generateBaseCss:s,compileThemes:o,generateCSS:t,compileConfig:r,writeDoc:i,generateProvider:a,processMediaConfig:l,generateThemeRegister:n,generateCssDoc:c,handlerForeignThemes:d,buildRelativePath:f}=require("./lib"),{validatePreviouslyExists:m,processCssWithPostcss:p}=require("./lib/generateCss/helpers"),{compilerTypeValid:g}=require("./constants"),{generateTypesTools:u}=require("./lib/generateTypesTools/generateTypesTools.utils"),{generateTools:h}=require("./lib/generateTools/generateTools.utils");async function y(y){const T=process.cwd(),v={},{default:D}=await import("ora"),C=D("Starting BernovaStyled process...").start(),{themes:b,provider:w}=await r({dir:T});for(const r of b){const{themeCss:a,fonts:D,resetCss:b,bvTools:$,name:P,stylesPath:S,typesTools:q,foreignThemes:x,prefix:B}=o({themeConfig:r,dir:T}),E=await s({fonts:D,resetCss:b,stylesPath:S}),{theme:F,media:N=[],...R}=a,V=(()=>{switch(y){case g.foundationOnly:return R;case g.componentOnly:return{theme:F,media:N};default:return a}})(),{stylesCss:H,foundationsCss:M,stylesDocs:O,rootDocs:W,globalDocs:j}=await t({source:V,baseCss:E,compilerType:y,prefix:B}),A=S?e.resolve(T,S):e.resolve(T,"styles"),{cssDir:G,cssMinifiedDir:k,oldData:z}=await m({stylesDir:A,compilerType:y,name:P}),I=c({compilerType:y,stylesCss:H,foundationsCss:M,oldData:z}),J=await p(I,!1,null),K=await p(I,!0,null);C.start(`Writing CSS to file for theme: ${P}...`),await i(G,J,"css"),await i(k,K,"css minified"),C.succeed(`CSS written to file for theme: ${P}.`),C.start(`Compiling register for theme: ${P}...`),C.succeed(`Register compiled for theme: ${P}.`),C.start("Verifying types tools..."),q?(C.succeed(`Types tools verified for theme: ${P}.`),await u({dir:T,typesTools:q,mediaConfig:N,stylesDocs:O})):C.succeed(`No types tools found for theme: ${P}.`);const L=N?l({mediaConfig:N}):null;if(C.start(`Processing bvTools for theme: ${P}...`),$?(C.succeed(`bvTools found for theme: ${P}.`),await h({bvTools:$,compilerType:y,name:P,dir:T,stylesDir:A,stylesDocs:O,rootDocs:W,globalDocs:j,mediaDocs:L})):C.succeed(`No bvTools found for theme: ${P}.`),w){C.start(`Generating theme register for theme: ${P}...`);const s=e.resolve(w.path),o=f({from:s,to:e.join(A,`${P}.css`)}),{themeByPosition:t,variablesExtracted:r,classesExtracted:i}=await d({dir:T,providerDir:s,foreignThemes:x});v[P]=n({cssPath:o,rootDocs:W,stylesDocs:O,globalDocs:j,mediaDocs:L,foreignStyles:i,foreignVars:r,foreignBeforeFiles:t.before,foreignAfterFiles:t.after}),C.succeed(`Theme register generated for provider for theme: ${P}`)}}w&&(C.start("Provider configuration found, generating tools..."),await a({dir:e.resolve(T,w.path),providerDocs:v,declarationHelp:w.declarationHelp,providerName:w.name,compilerType:y}),C.succeed("Provider tools generated successfully."))}module.exports={bernovaStyles:y};
1
+ const e=require("path"),{generateBaseCss:s,compileThemes:o,generateCSS:t,compileConfig:r,writeDoc:i,generateProvider:a,processMediaConfig:l,generateThemeRegister:n,generateCssDoc:c,handlerForeignThemes:d}=require("./lib"),{validatePreviouslyExists:f,processCssWithPostcss:m}=require("./lib/generateCss/helpers"),{compilerTypeValid:g}=require("./constants"),{generateTypesTools:p}=require("./lib/generateTypesTools/generateTypesTools.utils"),{generateTools:u}=require("./lib/generateTools/generateTools.utils");async function y(y){const h=process.cwd(),T={},{default:v}=await import("ora"),C=v("Starting BernovaStyled process...").start(),{themes:D,provider:w}=await r({dir:h});for(const r of D){const{themeCss:a,fonts:v,resetCss:D,bvTools:b,name:$,stylesPath:P,typesTools:S,foreignThemes:q,prefix:x}=o({themeConfig:r,dir:h}),B=await s({fonts:v,resetCss:D,stylesPath:P}),{theme:E,media:F=[],...N}=a,V=(()=>{switch(y){case g.foundationOnly:return N;case g.componentOnly:return{theme:E,media:F};default:return a}})(),{stylesCss:j,foundationsCss:H,stylesDocs:M,rootDocs:O,globalDocs:R}=await t({source:V,baseCss:B,compilerType:y,prefix:x}),W=P?e.resolve(h,P):e.resolve(h,"styles"),{cssDir:A,cssMinifiedDir:G,oldData:k}=await f({stylesDir:W,compilerType:y,name:$}),z=c({compilerType:y,stylesCss:j,foundationsCss:H,oldData:k}),I=await m(z,!1,null),J=await m(z,!0,null);C.start(`Writing CSS to file for theme: ${$}...`),await i(A,I,"css"),await i(G,J,"css minified"),C.succeed(`CSS written to file for theme: ${$}.`),C.start(`Compiling register for theme: ${$}...`),C.succeed(`Register compiled for theme: ${$}.`),C.start("Verifying types tools..."),S?(C.succeed(`Types tools verified for theme: ${$}.`),await p({dir:h,typesTools:S,mediaConfig:F,stylesDocs:M})):C.succeed(`No types tools found for theme: ${$}.`);const K=F?l({mediaConfig:F}):null;if(C.start(`Processing bvTools for theme: ${$}...`),b?(C.succeed(`bvTools found for theme: ${$}.`),await u({bvTools:b,compilerType:y,name:$,dir:h,stylesDir:W,stylesDocs:M,rootDocs:O,globalDocs:R,mediaDocs:K})):C.succeed(`No bvTools found for theme: ${$}.`),w){C.start(`Generating theme register for theme: ${$}...`);const s=P?e.join(P,`${$}.css`):e.join("./styles",`${$}.css`),{themeByPosition:o,variablesExtracted:t,classesExtracted:r}=await d({dir:h,foreignThemes:q});T[$]=n({cssPath:s,rootDocs:O,stylesDocs:M,globalDocs:R,mediaDocs:K,foreignStyles:r,foreignVars:t,foreignBeforeFiles:o.before,foreignAfterFiles:o.after}),C.succeed(`Theme register generated for provider for theme: ${$}`)}}w&&(C.start("Provider configuration found, generating tools..."),await a({dir:e.resolve(h,w.path),providerDocs:T,declarationHelp:w.declarationHelp,providerName:w.name,compilerType:y}),C.succeed("Provider tools generated successfully."))}module.exports={bernovaStyles:y};
@@ -1 +1 @@
1
- const o=require("path"),e=require("fs").promises,s=async(s,t)=>{if(!s||0===s.length)return void console.log("No local fonts to copy.");const{default:r}=await import("ora"),l=r("Copying local fonts...").start();try{for(const r of s)for(const s in r.files){const c=o.resolve(r.files[s]),a=o.resolve(t,"fonts"),i=o.resolve(a,o.basename(r.files[s]));await e.mkdir(a,{recursive:!0}),await e.copyFile(c,i),l.succeed(`Copied ${c} to ${i}`)}}catch(o){l.fail("Failed to copy local fonts."),console.error(o)}};module.exports={copyLocalFonts:s};
1
+ const o=require("path"),e=require("fs").promises,s=async(s,r)=>{if(s&&0!==s.length)try{for(const l of s)for(const s in l.files){const c=o.resolve(l.files[s]),t=o.resolve(r,"fonts"),i=o.resolve(t,o.basename(l.files[s]));await e.mkdir(t,{recursive:!0}),await e.copyFile(c,i)}}catch(o){console.error(o)}else console.log("No local fonts to copy.")};module.exports={copyLocalFonts:s};
@@ -1 +1 @@
1
- const{filterGenerateCss:s}=require("./helpers/filterGenerateCss.utils"),e=async({source:e,prefix:o,baseCss:r="",compilerType:t})=>{const{default:c}=await import("ora"),l=c("Generating CSS...").start();try{const{stylesCss:c,foundationsCss:a,stylesDocs:n,rootDocs:i,globalDocs:u}=s({source:e,compilerType:t,baseCss:r,prefix:o});return l.succeed("CSS generation completed successfully."),{stylesCss:c,foundationsCss:a,stylesDocs:n,rootDocs:i,globalDocs:u}}catch(s){throw l.fail("Error generating CSS."),console.error(s),s}};module.exports={generateCSS:e};
1
+ const{filterGenerateCss:s}=require("./helpers/filterGenerateCss.utils"),e=async({source:e,prefix:o,baseCss:r="",compilerType:t})=>{try{const{stylesCss:c,foundationsCss:l,stylesDocs:n,rootDocs:a,globalDocs:i}=s({source:e,compilerType:t,baseCss:r,prefix:o});return{stylesCss:c,foundationsCss:l,stylesDocs:n,rootDocs:a,globalDocs:i}}catch(s){throw console.error(s),s}};module.exports={generateCSS:e};
@@ -1 +1,164 @@
1
- import{cssThemes as e,cssClasses as t,cssVars as s,cssAvailableComponents as i,cssGlobalStyles as n,cssMediaQueries as h}from"./stats/stats";export class $_Provider_${#e;#t;#s;#i;#n;#h;#r;#l;#m;#o=(e,t)=>{if("undefined"==typeof document)return;let s=document.getElementById(t);s||(s=document.createElement("link"),s.id=t,s.rel="stylesheet",document.head.appendChild(s));const i=new URL(e,import.meta.url).href;s.href=i};#a=e=>{const{css:t,foreign:s}=e,i=s?.before||[],n=s?.after||[];i.forEach((e,t)=>{const s=`${this.#l}-foreign-before-${t+1}`;this.#o(e,s)}),this.#o(t,this.#l),n.forEach((e,t)=>{const s=`${this.#l}-foreign-after-${t+1}`;this.#o(e,s)})};#c=()=>{"undefined"!=typeof document&&document.querySelectorAll(`link[id^="${this.#l}"]`).forEach(e=>e.remove())};constructor({linkId:r,jsInCss:l}={}){this.#t=e,this.#s=s,this.#i=t,this.#n=i,this.#h=n,this.#r=h,this.#l=r||"kb-styled-link",this.#e=Object.keys(e)[0],this.#m=!!l,this.getComponentStyles=this.getComponentStyles.bind(this),"undefined"!=typeof window&&"undefined"!=typeof document&&this.#m&&(this.#c(),this.#a(this.#t[this.#e]))}get themeSelected(){return this.#e}set themeSelected(e){if(!(e in this.#t))throw new Error(`${e} is not exists`);this.#m&&(this.#c(),this.#a(this.#t[e])),this.#e=e}get allThemesNames(){return Object.keys(this.#t)}get allThemes(){return this.#t}get variables(){return this.#s[this.#e]}get classNames(){return this.#i[this.#e]}get components(){return this.#n[this.#e]}get globalStyles(){return this.#h[this.#e]}get mediaQueries(){return this.#r[this.#e]}getComponentStyles({variant:e,component:t,additionalClassNames:s}){const i=this.#i[this.#e][t.toLocaleUpperCase()];if(!i)return{};const n={},h=!!e&&`$_${e.toLocaleLowerCase().replace(/-/g,"_")}`;if(h&&h in i){const e=i[h];Object.entries(e).forEach(([e,t])=>{e in n||(n[e]=t)})}return Object.entries(i).forEach(([e,t])=>{e.startsWith("$_")||e in n||(n[e]=t)}),s&&Object.keys(s).length&&Object.entries(s).forEach(([e,t])=>{e in n||(n[e]=""),n[e]+=` ${t}`}),n}}
1
+ import {
2
+ cssThemes,
3
+ cssClasses,
4
+ cssVars,
5
+ cssAvailableComponents,
6
+ cssGlobalStyles,
7
+ cssMediaQueries,
8
+ } from './stats/stats';
9
+
10
+ export class $_Provider_$ {
11
+ #currentTheme;
12
+ #themes;
13
+ #themesVariables;
14
+ #themesClassNames;
15
+ #themesComponents;
16
+ #themesGlobalStyles;
17
+ #themesMediaQueries;
18
+ #linkId;
19
+ #jsInCss;
20
+ /* Bernova provider methods */
21
+ #linkBuilder = (url, id) => {
22
+ if (typeof document === 'undefined') return;
23
+ let linkElement = document.getElementById(id);
24
+ if (!linkElement) {
25
+ linkElement = document.createElement('link');
26
+ linkElement.id = id;
27
+ linkElement.rel = 'stylesheet';
28
+ document.head.appendChild(linkElement);
29
+ }
30
+ const baseUrl = document.location.origin;
31
+ const href = new URL(url, baseUrl).href;
32
+ linkElement.href = href;
33
+ };
34
+ #handlerThemes = (data) => {
35
+ const { css, foreign } = data;
36
+ const beforeFiles = foreign?.before || [];
37
+ const afterFiles = foreign?.after || [];
38
+ //* set the lower priority foreign themes
39
+ beforeFiles.forEach((url, idx) => {
40
+ const id = `${this.#linkId}-foreign-before-${idx + 1}`;
41
+ this.#linkBuilder(url, id);
42
+ });
43
+ //* set main theme
44
+ this.#linkBuilder(css, this.#linkId);
45
+ //* set the higher priority foreign themes
46
+ afterFiles.forEach((url, idx) => {
47
+ const id = `${this.#linkId}-foreign-after-${idx + 1}`;
48
+ this.#linkBuilder(url, id);
49
+ });
50
+ };
51
+ #cleanUpLinks = () => {
52
+ if (typeof document === 'undefined') return;
53
+ const links = document.querySelectorAll(`link[id^="${this.#linkId}"]`);
54
+ links.forEach((link) => link.remove());
55
+ };
56
+ /* Bernova provider methods */
57
+
58
+ constructor({ linkId, jsInCss } = {}) {
59
+ this.#themes = cssThemes;
60
+ this.#themesVariables = cssVars;
61
+ this.#themesClassNames = cssClasses;
62
+ this.#themesComponents = cssAvailableComponents;
63
+ this.#themesGlobalStyles = cssGlobalStyles;
64
+ this.#themesMediaQueries = cssMediaQueries;
65
+ this.#linkId = linkId || 'kb-styled-link';
66
+ this.#currentTheme = Object.keys(cssThemes)[0];
67
+ this.#jsInCss = !!jsInCss;
68
+ this.getComponentStyles = this.getComponentStyles.bind(this);
69
+
70
+ if (
71
+ typeof window !== 'undefined' &&
72
+ typeof document !== 'undefined' &&
73
+ this.#jsInCss
74
+ ) {
75
+ this.#cleanUpLinks();
76
+ this.#handlerThemes(this.#themes[this.#currentTheme]);
77
+ }
78
+ }
79
+ // ? getters and setters
80
+ //* theme selected
81
+ get themeSelected() {
82
+ return this.#currentTheme;
83
+ }
84
+ set themeSelected(themeName) {
85
+ if (themeName in this.#themes) {
86
+ if (this.#jsInCss) {
87
+ this.#cleanUpLinks();
88
+ this.#handlerThemes(this.#themes[themeName]);
89
+ }
90
+ this.#currentTheme = themeName;
91
+ } else {
92
+ throw new Error(`${themeName} is not exists`);
93
+ }
94
+ }
95
+ //* themes
96
+ get allThemesNames() {
97
+ return Object.keys(this.#themes);
98
+ }
99
+ get allThemes() {
100
+ return this.#themes;
101
+ }
102
+ //* variables
103
+ get variables() {
104
+ return this.#themesVariables[this.#currentTheme];
105
+ }
106
+ //* classNames
107
+ get classNames() {
108
+ return this.#themesClassNames[this.#currentTheme];
109
+ }
110
+ //* components
111
+ get components() {
112
+ return this.#themesComponents[this.#currentTheme];
113
+ }
114
+ //* global styles
115
+ get globalStyles() {
116
+ return this.#themesGlobalStyles[this.#currentTheme];
117
+ }
118
+ //* media queries
119
+ get mediaQueries() {
120
+ return this.#themesMediaQueries[this.#currentTheme];
121
+ }
122
+ //? methods
123
+ getComponentStyles({ variant, component, additionalClassNames }) {
124
+ const THEME = this.#themesClassNames[this.#currentTheme];
125
+ const upperComponent = component.toLocaleUpperCase();
126
+ const COMPONENT = THEME[upperComponent];
127
+
128
+ if (!COMPONENT) return {};
129
+
130
+ const structure = {};
131
+ const startV = '$_';
132
+ const componentVariant = (() => {
133
+ if (!!variant) {
134
+ const lowerVariant = variant.toLocaleLowerCase().replace(/-/g, '_');
135
+ return `${startV}${lowerVariant}`;
136
+ } else {
137
+ return false;
138
+ }
139
+ })();
140
+ if (componentVariant && componentVariant in COMPONENT) {
141
+ const variantFragment = COMPONENT[componentVariant];
142
+ Object.entries(variantFragment).forEach(([key, value]) => {
143
+ if (!(key in structure)) {
144
+ structure[key] = value;
145
+ }
146
+ });
147
+ }
148
+ Object.entries(COMPONENT).forEach(([key, value]) => {
149
+ if (key.startsWith(startV)) return;
150
+ if (!(key in structure)) {
151
+ structure[key] = value;
152
+ }
153
+ });
154
+ if (!!additionalClassNames && Object.keys(additionalClassNames).length) {
155
+ Object.entries(additionalClassNames).forEach(([key, value]) => {
156
+ if (!(key in structure)) {
157
+ structure[key] = '';
158
+ }
159
+ structure[key] += ` ${value}`;
160
+ });
161
+ }
162
+ return structure;
163
+ }
164
+ }
@@ -1 +1 @@
1
- const e=require("fs").promises,t=require("path"),{fileExists:r}=require("../fileExists/fileExists.utils"),{simplifyName:i}=require("../simplifyName/simplifyName.utils"),{buildRelativePath:a}=require("../buildRelativePath/buildRelativePath.utils"),s=async({dir:s,providerDir:o,foreignThemes:n})=>{const c={after:"",before:""},l={doc:"",declare:""},d={doc:"",declare:""},f=new Set;if(n&&n.length>0)for(const{path:m,position:u,name:h}of n){if(!r(s,m))continue;const n=i(h).toLocaleUpperCase(),$=t.resolve(s,m),p=a({from:o,to:$}),g=await e.readFile($,"utf-8");c[u]+=0===c[u].length?`'${p}'`:`, '${p}'`;const b=g.match(/--[a-zA-Z0-9-_]+:\s*[^;]+;/g);b&&[...new Set(b)].forEach(e=>{const[t]=e.split(":").map(e=>e.trim()),r=i(t);f.has(r)||(f.add(r),d.doc+=` ${r}: 'var(${t})',\n`,d.declare+=` ${r}: string; \n`)});const v=g.match(/\.[a-zA-Z0-9_-]+/g);if(v){const{doc:e,declare:t}=[...new Set(v)].reduce((e,t)=>{const r=t.slice(1),a=i(r);return e.doc+=` ${a}: '${r}',\n`,e.declare+=` ${a}: string; \n`,e},{doc:"",declare:""});l.doc+=` ${n}: {\n${e} },\n`,l.declare+=` ${n}: {\n${t} },\n`}}return{themeByPosition:{after:`[${c.after}]`,before:`[${c.before}]`},variablesExtracted:d,classesExtracted:l}};module.exports={handlerForeignThemes:s};
1
+ const e=require("fs").promises,r=require("path"),{fileExists:t}=require("../fileExists/fileExists.utils"),{simplifyName:s}=require("../simplifyName/simplifyName.utils"),i=async({dir:i,foreignThemes:a})=>{const n={after:"",before:""},o={doc:"",declare:""},c={doc:"",declare:""},l=new Set;if(a&&a.length>0)for(const{path:d,position:f,name:m}of a){if(!t(i,d))continue;const a=s(m).toLocaleUpperCase(),$=r.resolve(i,d),h=await e.readFile($,"utf-8");n[f]+=0===n[f].length?`'${d}'`:`, '${d}'`;const p=h.match(/--[a-zA-Z0-9-_]+:\s*[^;]+;/g);p&&[...new Set(p)].forEach(e=>{const[r]=e.split(":").map(e=>e.trim()),t=s(r);l.has(t)||(l.add(t),c.doc+=` ${t}: 'var(${r})',\n`,c.declare+=` ${t}: string; \n`)});const u=h.match(/\.[a-zA-Z0-9_-]+/g);if(u){const{doc:e,declare:r}=[...new Set(u)].reduce((e,r)=>{const t=r.slice(1),i=s(t);return e.doc+=` ${i}: '${t}',\n`,e.declare+=` ${i}: string; \n`,e},{doc:"",declare:""});o.doc+=` ${a}: {\n${e} },\n`,o.declare+=` ${a}: {\n${r} },\n`}}return{themeByPosition:{after:`[${n.after}]`,before:`[${n.before}]`},variablesExtracted:c,classesExtracted:o}};module.exports={handlerForeignThemes:i};
@@ -1 +1 @@
1
- const r=require("path"),t=require("fs/promises"),e=async(e,i,o)=>{const{default:s}=await import("ora"),a=s(`Writing ${o} to ${e}...`).start();try{await t.mkdir(r.dirname(e),{recursive:!0});const s=await Promise.resolve(i);await t.writeFile(e,s),a.succeed(`${o} successfully written to ${e}`)}catch(r){a.fail(`Error writing ${o} to ${e}`),console.error(r)}};module.exports={writeDoc:e};
1
+ const e=require("path"),r=require("fs/promises"),i=async(i,o,s)=>{try{await r.mkdir(e.dirname(i),{recursive:!0});const s=await Promise.resolve(o);await r.writeFile(i,s)}catch(e){console.error(e)}};module.exports={writeDoc:i};
@@ -3,11 +3,10 @@
3
3
  * Extracts CSS variables and class names from external stylesheets
4
4
  *
5
5
  * @param {string} dir - Base directory for resolving theme file paths
6
- * @param {string} providerDir - Directory of the provider for relative path calculation
7
6
  * @param {Array} foreignThemes - Array of foreign theme configurations
8
7
  * @param {string} foreignThemes[].path - Relative path to the theme CSS file
9
8
  * @param {string} foreignThemes[].position - Where to include ('before' or 'after')
10
9
  * @param {string} foreignThemes[].name - Theme identifier name
11
10
  * @returns {Object} Processed theme data with variables, classes, and file paths
12
11
  */
13
- export function handlerForeignThemes({ dir, providerDir, foreignThemes }: string): any;
12
+ export function handlerForeignThemes({ dir, foreignThemes }: string): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bernova",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "The best way to write CSS with Javascript syntax",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
package/src/app.js CHANGED
@@ -10,7 +10,6 @@ const {
10
10
  generateThemeRegister,
11
11
  generateCssDoc,
12
12
  handlerForeignThemes,
13
- buildRelativePath,
14
13
  } = require('./lib');
15
14
  const {
16
15
  validatePreviouslyExists,
@@ -146,14 +145,11 @@ async function bernovaStyles(compilerType) {
146
145
 
147
146
  if (provider) {
148
147
  spinner.start(`Generating theme register for theme: ${name}...`);
149
- // build a relative path to CSS file from provider
150
- const providerDir = path.resolve(provider.path);
151
- const cssPath = buildRelativePath({
152
- from: providerDir,
153
- to: path.join(stylesDir, `${name}.css`),
154
- })
148
+ const cssPath = stylesPath
149
+ ? path.join(stylesPath, `${name}.css`)
150
+ : path.join('./styles', `${name}.css`);
155
151
  const { themeByPosition, variablesExtracted, classesExtracted } =
156
- await handlerForeignThemes({ dir, providerDir, foreignThemes });
152
+ await handlerForeignThemes({ dir, foreignThemes });
157
153
 
158
154
  themeRegister[name] = generateThemeRegister({
159
155
  cssPath,
@@ -12,8 +12,6 @@ const copyLocalFonts = async (localFonts, outputDir) => {
12
12
  console.log('No local fonts to copy.');
13
13
  return;
14
14
  }
15
- const { default: ora } = await import('ora');
16
- const spinner = ora('Copying local fonts...').start();
17
15
 
18
16
  try {
19
17
  for (const font of localFonts) {
@@ -30,11 +28,9 @@ const copyLocalFonts = async (localFonts, outputDir) => {
30
28
 
31
29
  // Copy the font file
32
30
  await fs.copyFile(srcPath, destPath);
33
- spinner.succeed(`Copied ${srcPath} to ${destPath}`);
34
31
  }
35
32
  }
36
33
  } catch (error) {
37
- spinner.fail('Failed to copy local fonts.');
38
34
  console.error(error);
39
35
  }
40
36
  };
@@ -12,9 +12,6 @@ const { filterGenerateCss } = require('./helpers/filterGenerateCss.utils');
12
12
  * @returns {Promise<Object>} - A promise that resolves to an object containing the generated CSS and minified CSS.
13
13
  */
14
14
  const generateCSS = async ({ source, prefix, baseCss = '', compilerType }) => {
15
- const { default: ora } = await import('ora');
16
- const spinner = ora('Generating CSS...').start();
17
-
18
15
  try {
19
16
  const { stylesCss, foundationsCss, stylesDocs, rootDocs, globalDocs } =
20
17
  filterGenerateCss({
@@ -24,7 +21,6 @@ const generateCSS = async ({ source, prefix, baseCss = '', compilerType }) => {
24
21
  prefix,
25
22
  });
26
23
 
27
- spinner.succeed('CSS generation completed successfully.');
28
24
  return {
29
25
  stylesCss,
30
26
  foundationsCss,
@@ -33,7 +29,6 @@ const generateCSS = async ({ source, prefix, baseCss = '', compilerType }) => {
33
29
  globalDocs,
34
30
  };
35
31
  } catch (error) {
36
- spinner.fail('Error generating CSS.');
37
32
  console.error(error);
38
33
  throw error; // Re-throw the error after logging it
39
34
  }
@@ -27,7 +27,8 @@ export class $_Provider_$ {
27
27
  linkElement.rel = 'stylesheet';
28
28
  document.head.appendChild(linkElement);
29
29
  }
30
- const href = new URL(url, import.meta.url).href;
30
+ const baseUrl = document.location.origin;
31
+ const href = new URL(url, baseUrl).href;
31
32
  linkElement.href = href;
32
33
  };
33
34
  #handlerThemes = (data) => {
@@ -10,21 +10,19 @@ const fs = require('fs').promises;
10
10
  const path = require('path');
11
11
  const { fileExists } = require('../fileExists/fileExists.utils');
12
12
  const { simplifyName } = require('../simplifyName/simplifyName.utils');
13
- const { buildRelativePath } = require('../buildRelativePath/buildRelativePath.utils');
14
13
 
15
14
  /**
16
15
  * Processes and integrates foreign CSS theme files into Bernova compilation
17
16
  * Extracts CSS variables and class names from external stylesheets
18
17
  *
19
18
  * @param {string} dir - Base directory for resolving theme file paths
20
- * @param {string} providerDir - Directory of the provider for relative path calculation
21
19
  * @param {Array} foreignThemes - Array of foreign theme configurations
22
20
  * @param {string} foreignThemes[].path - Relative path to the theme CSS file
23
21
  * @param {string} foreignThemes[].position - Where to include ('before' or 'after')
24
22
  * @param {string} foreignThemes[].name - Theme identifier name
25
23
  * @returns {Object} Processed theme data with variables, classes, and file paths
26
24
  */
27
- const handlerForeignThemes = async ({ dir, providerDir, foreignThemes }) => {
25
+ const handlerForeignThemes = async ({ dir, foreignThemes }) => {
28
26
  // Initialize data structures for organizing theme content
29
27
  const themeByPosition = { after: '', before: '' }; // File paths by position
30
28
  const classesExtracted = { doc: '', declare: '' }; // CSS class documentation
@@ -41,12 +39,6 @@ const handlerForeignThemes = async ({ dir, providerDir, foreignThemes }) => {
41
39
 
42
40
  // Build absolute path to the theme CSS file
43
41
  const themePathAbsolute = path.resolve(dir, themePath);
44
-
45
- // build a relative path to CSS file from provider location
46
- const themeRoute = buildRelativePath({
47
- from: providerDir,
48
- to: themePathAbsolute
49
- });
50
42
 
51
43
  // Read and parse theme CSS content
52
44
  const data = await fs.readFile(themePathAbsolute, 'utf-8');
@@ -55,8 +47,8 @@ const handlerForeignThemes = async ({ dir, providerDir, foreignThemes }) => {
55
47
  // idx === 0 ? `'${themeRoute}'` : `, '${themeRoute}'`;
56
48
  themeByPosition[position] +=
57
49
  themeByPosition[position].length === 0
58
- ? `'${themeRoute}'`
59
- : `, '${themeRoute}'`;
50
+ ? `'${themePath}'`
51
+ : `, '${themePath}'`;
60
52
  //* get the css variables
61
53
  const variableMatches = data.match(/--[a-zA-Z0-9-_]+:\s*[^;]+;/g);
62
54
  if (variableMatches) {
@@ -9,8 +9,6 @@ const fs = require('fs/promises');
9
9
  * @param {string | Promise<string>} source - The CSS content to write.
10
10
  */
11
11
  const writeDoc = async (dir, source, docName) => {
12
- const { default: ora } = await import('ora');
13
- const spinner = ora(`Writing ${docName} to ${dir}...`).start();
14
12
  try {
15
13
  // Ensure the directory exists
16
14
  await fs.mkdir(path.dirname(dir), { recursive: true });
@@ -20,9 +18,7 @@ const writeDoc = async (dir, source, docName) => {
20
18
 
21
19
  // Write the CSS content to the file
22
20
  await fs.writeFile(dir, cssContent);
23
- spinner.succeed(`${docName} successfully written to ${dir}`);
24
21
  } catch (err) {
25
- spinner.fail(`Error writing ${docName} to ${dir}`);
26
22
  console.error(err);
27
23
  }
28
24
  };