bernova 1.7.3 → 1.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Merge pull request #34 from kubit-ui/feat/new-bv-scripts-options-and-improve-stats-interfaces
8
+
9
+ ## 1.7.4
10
+
11
+ ### Patch Changes
12
+
13
+ - Remove Yarn Berry packageManager constraint for Yarn 1 compatibility
14
+
3
15
  ## 1.7.3
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -1907,13 +1907,36 @@ npx bv-build --prevent-move-dts
1907
1907
  # unset types values from bernova.config.json
1908
1908
  npx bv-build --types none
1909
1909
 
1910
- # Prevent process the js ad dts files
1910
+ # Prevent process the js ad dts files [deprecated]
1911
1911
  npx bv-build --prevent-process-js
1912
1912
 
1913
1913
  # Embed styles
1914
1914
  npx bv-build --embed-css
1915
1915
  ```
1916
1916
 
1917
+ ### Partial Compilation
1918
+
1919
+ There may be occasions when you need to compile only part of Bernova's tools, or prepare them to be processed with other bundlers or processors. For these cases, Bernova provides scripts that allow you to perform only part of the process.
1920
+
1921
+ **IMPORTANT**: _Although all flags are available, some will not perform any action in certain individual processes._
1922
+
1923
+ ```bash
1924
+ # Available flags: --embed-css | --css
1925
+ npx bv-pre-build
1926
+ # Available flags: --base-out-dir & --css
1927
+ npx bv-copy-css
1928
+ # Available flags: --base-out-dir & --root-dir & --tools & --prevent-move-dts
1929
+ npx bv-copy-tools
1930
+ # Available flags: --base-out-dir & --root-dir & --provider & --prevent-process-js [deprecated]
1931
+ # Available flags: --prevent-move-dts & --embed-css & --css
1932
+ npx bv-copy-provider
1933
+ ```
1934
+
1935
+ - **bv-pre-build**: Prepares and updates the provider (and its stats) to production, without moving it to the final build folder.
1936
+ - **bv-copy-css**: Copies the files generated or used by Bernova to the final build folder.
1937
+ - **bv-copy-tools**: Copies the tools generated by Bernova to the final build folder.
1938
+ - **bv-copy-provider**: Copies the provider and its stats to the final build folder.
1939
+
1917
1940
  ---
1918
1941
 
1919
1942
  ## Contributing
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const e=require("fs").promises,t=require("path"),s=require("@babel/core"),{minify:a}=require("terser"),{extractDocFragment:n,writeDoc:r,fileExists:o,readConfigData:i}=require("../src/lib");async function c({baseOutPath:s,jsFile:a,rootDir:i,customOutDirs:c,dir:l,minifyJS:m,preventMoveJS:d,provider:h={name:""},type:v="",embedCss:y,cssFiles:b}){const P=a.name.endsWith(".d.ts"),j=t.resolve(l,a.path,a.name);if(!o(l,j))return void console.error(`File not found: ${j}`);let D=await e.readFile(j,"utf8");const O=!!c?.css||y&&b.length>0;if("cssTheme.js"===a.name&&O){const s=D.replace("export default","").replaceAll(";","").trim(),a=new Function(`return (${s})`)();if(c?.css)D=`export default {\n${f({cssThemes:a,cssOutPath:c.css})}};\n`;else if(y&&b.length>0){const s=Object.keys(a)[0],n=b.find(e=>e.name===`${s}.css`||e.name===`${s}.min.css`);if(n){const{name:a,path:r}=n,i=t.resolve(l,r,a),c=o(l,i)?(await e.readFile(i,"utf8")).replace(/\s+/g,""):"",m={before:"",after:""};for(const a of b){const{name:n,path:r,parent:i}=a;if(i)for(const{name:a,position:c}of i)if(a===s){const s=t.resolve(l,r,n);if(o(l,s)){const t=(await e.readFile(s,"utf8")).replace(/\s+/g,"");m[c]+=t}}}const p=m.before+c+m.after;D=`export default {'${s}':{css:\`${p}\`}};`}}}if(a.name===`${g(h.name)}.js`&&y&&b.length>0){const s="\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 ",a="../src/lib/generateProvider/template/providerTemplate.js";let r=await e.readFile(t.resolve(__dirname,a),"utf8");r=r.replace(/\$_Provider_\$/g,h.name);const o=n({section:"Bernova provider methods",doc:r});D=r.replace(o,s.trim())}if(a.name===`${g(h.name)}.d.ts`&&y&&b.length>0){const s="\n #linkBuilder(css: string, id: string): void;\n #handlerThemes(data: { css: string }): void;\n #cleanUpLinks(): void;\n ",a="../src/lib/generateProvider/template/providerTemplate.d.ts";let r=await e.readFile(t.resolve(__dirname,a),"utf8");r=r.replace(/\$_Provider_\$/g,h.name);const o=n({section:"Bernova provider methods",doc:r});D=r.replace(o,s.trim())}"cjs"!==v||P||(D=await p(D,j,!0)),"esm"!==v||P||(D=await p(D,j)),m&&!P&&(D=await u(D));const C=t.relative(i||"",a.outPath),w=d?j:t.resolve(s,C,a.name);await r(w,D,a.name)}async function l({baseOutPath:s,cssFiles:a,rootDir:n,customOutDirs:i,dir:c}){for(const l of a){const a=(()=>n&&!i?.css?t.relative(n,l.path):i?.css?i.css:l.path)(),m=t.resolve(c,l.path,l.name);if(o(c,m)){const n=await e.readFile(m,"utf8"),o=l.name.replace(".min","");await r(t.resolve(s,a,o),n,o)}}}function m({baseOutDir:e,type:s="-"}){const a=(()=>{switch(s){case"cjs":return"cjs";case"esm":return"esm";default:return""}})();return t.join(e,a)}async function p(e,t,a=!1){const n=!!a&&"commonjs";return(await s.transformAsync(e,{filename:t,presets:[["@babel/preset-env",{modules:n,targets:{node:"current"}}]]})).code}async function u(e){return(await a(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 d({themes:e,minifyCss:s}){return e&&Array.isArray(e)&&e.length>0?e.reduce((e,a)=>{const{name:n,stylesPath:r,foreignThemes:o}=a;return n&&r&&v(e,{name:s?`${n}.min.css`:`${n}.css`,path:r}),o&&Array.isArray(o)&&o.length>0&&o.forEach(s=>{const a=t.basename(s.path),r=s.path.replace(a,"").trim(),o=e.findIndex(e=>e.name===a&&e.path===r);o>=0?e[o].parent.push({name:n,position:s.position}):e.push({name:a,path:r,parent:[{name:n,position:s.position}]})}),e},[]):[]}async function h({dir:s,customOutDirs:a,provider:n,themes:r,preventMoveDTS:o=!1}){const i=r&&r.bvTools?r.reduce((e,{bvTools:t})=>{const{path:s,declarationHelp:n,cssVariables:r,cssClassNames:i,cssMediaQueries:c,cssGlobalStyles:l,availableComponents:m}=t,p=n&&!o,u=a?.tools?a.tools:s;return r&&(v(e,{name:"cssVars.js",path:s,outPath:u}),p&&v(e,{name:"cssVars.d.ts",path:s,outPath:u})),i&&(v(e,{name:"cssClasses.js",path:s,outPath:u}),p&&v(e,{name:"cssClasses.d.ts",path:s,outPath:u})),c&&(v(e,{name:"cssMediaQueries.js",path:s,outPath:u}),p&&v(e,{name:"cssMediaQueries.d.ts",path:s,outPath:u})),l&&(v(e,{name:"cssGlobalStyles.js",path:s,outPath:u}),p&&v(e,{name:"cssGlobalStyles.d.ts",path:s,outPath:u})),m&&(v(e,{name:"cssAvailableComponents.js",path:s,outPath:u}),p&&v(e,{name:"cssAvailableComponents.d.js",path:s,outPath:u})),e},[]):[];if(n){const r=g(n.name),c=`${r}.js`,l=a?.provider?a.provider:n.path;v(i,{name:c,path:n.path,outPath:l});const m=t.join(n.path,"stats"),p=a?.provider?t.join(a.provider,"stats"):m;v(i,{name:"stats.js",path:m,outPath:p});const u=t.resolve(s,m),d=await e.readdir(u,{withFileTypes:!0});d.forEach(e=>{if(e.isDirectory()){const s=t.join(m,e.name),a=t.join(p,e.name);v(i,{name:"cssAvailableComponents.js",path:s,outPath:a}),v(i,{name:"cssClassNames.js",path:s,outPath:a}),v(i,{name:"cssGlobalStyles.js",path:s,outPath:a}),v(i,{name:"cssMediaQueries.js",path:s,outPath:a}),v(i,{name:"cssTheme.js",path:s,outPath:a}),v(i,{name:"cssVars.js",path:s,outPath:a})}}),n.declarationHelp&&!o&&(v(i,{name:`${r}.d.ts`,path:n.path,outPath:l}),v(i,{name:"stats.d.ts",path:m,outPath:p}),d.forEach(e=>{if(e.isDirectory()){const s=t.join(m,e.name),a=t.join(p,e.name);v(i,{name:"cssAvailableComponents.d.ts",path:s,outPath:a}),v(i,{name:"cssClassNames.d.ts",path:s,outPath:a}),v(i,{name:"cssGlobalStyles.d.ts",path:s,outPath:a}),v(i,{name:"cssMediaQueries.d.ts",path:s,outPath:a}),v(i,{name:"cssTheme.d.ts",path:s,outPath:a}),v(i,{name:"cssVars.d.ts",path:s,outPath:a})}}))}return i}function f({cssThemes:e,cssOutPath:s}){return Object.entries(e).reduce((e,[a,{foreign:n}])=>{const{before:r,after:o}=n,i=r&&Array.isArray(r)&&r.length>0?r.reduce((e,a,n)=>{const r=t.basename(a);return n>0&&(e+=", "),e+`'${s}/${r}'`},""):"",c=o&&Array.isArray(o)&&o.length>0?o.reduce((e,a,n)=>{const r=t.basename(a);return n>0&&(e+=", "),e+`'${s}/${r}'`},""):"";return e+`'${a}':{css:'${s}/${a}.css',foreign:{before: [${i}],after: [${c}]}}`},"")}function v(e,t){e.some(e=>e.name===t.name&&e.path===t.path)||e.push(t)}function y(){const e=["--base-out-dir","--root-dir","--prevent-process-js","--prevent-move-js","--prevent-move-dts","--types","--css","--tools","--provider","--embed-css"],t={};for(let s=0;s<process.argv.length;s++)if(e.includes(process.argv[s])){const a=process.argv[s].replace("--","").replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),n=process.argv[s+1];t[a]=(()=>!(n&&!e.includes(n))||("none"===n.toLocaleLowerCase()?"":n))()}return t}function b({jsonCustomOutDirs:e,cliCustomOutDirs:t}){let s={};return e&&(s={...e}),t&&(s={...s,...t}),Object.keys(s).length>0?s:void 0}function g(e="provider"){return e.charAt(0).toLowerCase()+e.slice(1)}(async()=>{const e=process.cwd(),s=await i(t.resolve(e,"bernova.config.json")),{compilerOptions:a,provider:n,themes:r}=s;a&&n&&r||(console.error("Invalid configuration: Missing compilerOptions, themes or provider"),process.exit(1));const{baseOutDir:o,rootDir:p,minifyCss:u,minifyJS:f,preventMoveJS:v,preventMoveDTS:g,types:P,embedCss:j,customOutDirs:D}=a,{baseOutDir:O,rootDir:C,types:w,preventMoveJs:$,preventMoveDts:F,preventProcessJs:A=!1,embedCss:T,...M}=y(),S=O??o??"",_=C??p??void 0,E=$??v??!1,k=F??g??!1,J=w??P??void 0,x=T??j??!1,B=b({jsonCustomOutDirs:D,cliCustomOutDirs:M}),I=d({themes:r,minifyCss:u}),L=A?[]:await h({dir:e,customOutDirs:B,provider:n,themes:r,preventMoveDTS:k}),q=m({baseOutDir:S});if(I&&I.length>0&&!x&&await l({baseOutPath:q,cssFiles:I,rootDir:_,customOutDirs:B,dir:e}),L&&L.length>0)if(J&&Array.isArray(J)&&J.length>0)for(const t of J){const s=m({baseOutDir:S,type:t});for(const a of L)await c({baseOutPath:s,jsFile:a,rootDir:_,customOutDirs:B,dir:e,minifyJS:f,preventMoveJS:E,provider:n,type:t,embedCss:x,cssFiles:I})}else for(const t of L)await c({baseOutPath:q,jsFile:t,rootDir:_,customOutDirs:B,dir:e,minifyJS:f,preventMoveJS:E,provider:n,embedCss:x,cssFiles:I})})();
2
+ const{bvBuildScript:s}=require("./functions/scriptFx");(async()=>{try{const c=await s();await c.fullBuild(),console.log("Styles built successfully.")}catch(s){console.error("Error building styles:",s),process.exit(1)}})();
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ const{bvBuildScript:c}=require("./functions/scriptFx");(async()=>{try{const s=await c();await s.copyCss(),console.log("CSS files copied successfully.")}catch(c){console.error("Error copying CSS files:",c),process.exit(1)}})();
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ const{bvBuildScript:o}=require("./functions/scriptFx");(async()=>{try{const r=await o();await r.copyProvider(),await r.copyStats(),console.log("Provider files copied successfully.")}catch(o){console.error("Error copying provider files:",o),process.exit(1)}})();
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ const{bvBuildScript:o}=require("./functions/scriptFx");(async()=>{try{const s=await o();await s.copyTools(),console.log("Tools files copied successfully.")}catch(o){console.error("Error copying tools files:",o),process.exit(1)}})();
@@ -0,0 +1 @@
1
+ const s=require("fs").promises,t=require("path"),{pushUniqueFile:a,lowerCaseFirstChar:e}=require("./utils");function o(s){const t={};for(let a=0;a<process.argv.length;a++)if(s.includes(process.argv[a])){const e=process.argv[a].replace("--","").replace(/-([a-z])/g,(s,t)=>t.toUpperCase()),o=process.argv[a+1];t[e]=(()=>!(o&&!s.includes(o))||("none"===o.toLocaleLowerCase()?"":o))()}return t}async function n({dir:o,customOutDirs:n,provider:r,themes:h,preventMoveDTS:i=!1}){const c=h&&h.bvTools?h.reduce((s,{bvTools:t})=>{const{path:e,declarationHelp:o,cssVariables:r,cssClassNames:h,cssMediaQueries:c,cssGlobalStyles:p,availableComponents:u}=t,l=o&&!i,m=n?.tools?n.tools:e;return r&&(a(s,{name:"cssVars.js",path:e,outPath:m}),l&&a(s,{name:"cssVars.d.ts",path:e,outPath:m})),h&&(a(s,{name:"cssClasses.js",path:e,outPath:m}),l&&a(s,{name:"cssClasses.d.ts",path:e,outPath:m})),c&&(a(s,{name:"cssMediaQueries.js",path:e,outPath:m}),l&&a(s,{name:"cssMediaQueries.d.ts",path:e,outPath:m})),p&&(a(s,{name:"cssGlobalStyles.js",path:e,outPath:m}),l&&a(s,{name:"cssGlobalStyles.d.ts",path:e,outPath:m})),u&&(a(s,{name:"cssAvailableComponents.js",path:e,outPath:m}),l&&a(s,{name:"cssAvailableComponents.d.js",path:e,outPath:m})),s},[]):[];if(r){const h=`${e(r.name)}.js`,p=n?.provider?n.provider:r.path;a(c,{name:h,path:r.path,outPath:p});const u=t.join(r.path,"stats"),l=n?.provider?t.join(n.provider,"stats"):u;a(c,{name:"stats.js",path:u,outPath:l});const m=t.resolve(o,u),d=await s.readdir(m,{withFileTypes:!0});if(d.forEach(s=>{if(s.isDirectory()){const e=t.join(u,s.name),o=t.join(l,s.name);a(c,{name:"cssAvailableComponents.js",path:e,outPath:o}),a(c,{name:"cssClassNames.js",path:e,outPath:o}),a(c,{name:"cssGlobalStyles.js",path:e,outPath:o}),a(c,{name:"cssMediaQueries.js",path:e,outPath:o}),a(c,{name:"cssTheme.js",path:e,outPath:o}),a(c,{name:"cssVars.js",path:e,outPath:o})}}),r.declarationHelp&&!i){const s=`${e(r.name)}.d.ts`;a(c,{name:s,path:r.path,outPath:p}),a(c,{name:"stats.d.ts",path:u,outPath:l}),d.forEach(s=>{if(s.isDirectory()){const e=t.join(u,s.name),o=t.join(l,s.name);a(c,{name:"cssAvailableComponents.d.ts",path:e,outPath:o}),a(c,{name:"cssClassNames.d.ts",path:e,outPath:o}),a(c,{name:"cssGlobalStyles.d.ts",path:e,outPath:o}),a(c,{name:"cssMediaQueries.d.ts",path:e,outPath:o}),a(c,{name:"cssTheme.d.ts",path:e,outPath:o}),a(c,{name:"cssVars.d.ts",path:e,outPath:o})}})}}return c}function r({themes:s,minifyCss:e}){return s&&Array.isArray(s)&&s.length>0?s.reduce((s,o)=>{const{name:n,stylesPath:r,foreignThemes:h}=o;return n&&r&&a(s,{name:e?`${n}.min.css`:`${n}.css`,path:r}),h&&Array.isArray(h)&&h.length>0&&h.forEach(a=>{const e=t.basename(a.path),o=a.path.replace(e,"").trim(),r=s.findIndex(s=>s.name===e&&s.path===o);r>=0?s[r].parent.push({name:n,position:a.position}):s.push({name:e,path:o,parent:[{name:n,position:a.position}]})}),s},[]):[]}function h({baseOutDir:s="",type:a="-"}){const e=(()=>{switch(a){case"cjs":return"cjs";case"esm":return"esm";default:return""}})();return s?t.join(s,e):e}module.exports={getBernovaBuildArgs:o,getJsFiles:n,getCssFiles:r,getBaseOutDir:h};
@@ -0,0 +1 @@
1
+ const o=require("path"),{getBernovaBuildArgs:e,getBaseOutDir:t}=require("./getFx"),{readConfigData:s}=require("../../src/lib"),{copyCssFiles:i,embedCssForProvider:r,rewriteCssPathInStats:n,writeStatsinBuild:a,writeToolsInBuild:c,rewriteProviderTemplate:l}=require("./writeFx"),{isIterableArray:p,buildCustomOutDirs:u}=require("./utils");async function d(){console.log("Reading configuration...");const d=process.cwd(),{themes:f,provider:v,compilerOptions:y}=await s(o.resolve(d,"bernova.config.json")),{minifyCss:g,minifyJS:m,...h}=y,{css:w,tools:S,provider:C,...b}=e(["--base-out-dir","--root-dir","--prevent-process-js","--prevent-move-js","--prevent-move-dts","--types","--css","--tools","--provider","--embed-css"]),D=(()=>{const o={};return w&&(o.css=w),S&&(o.tools=S),C&&(o.provider=C),Object.keys(o).length>0?o:void 0})(),{baseOutDir:P="",rootDir:O,preventMoveJS:j,preventMoveDTS:B,preventProcessJs:T,types:J,embedCss:q,customOutDirs:M}=u({jsonConfig:h,cliConfig:{...b,customOutDirs:D}}),F=p(J)?J:[""];async function x(){const o=M?.css;if(p(f)){for(const e of f)q?await r({dir:d,theme:e,provider:v}):o&&await n({dir:d,theme:e,css:o,provider:v});await l({dir:d,embedCss:q,provider:v})}}async function I(){const e=M?.css;if(p(f))for(const t of f){const s=e??t.stylesPath??"",r=o.join(P,s);await i({dir:d,cssPath:r,theme:t})}}async function A(){let e=M?.provider??v.path??"";O&&(e=o.relative(O,e));for(const s of F){const i=t({baseOutDir:P,type:s}),r=o.join(i,e,"stats");await a({dir:d,providerPath:v.path,outPath:r,type:s,preventMoveDTS:B,minifyJS:m})}}async function k(){let e=M?.provider??v.path??"";O&&(e=o.relative(O,e));for(const s of F){const i=t({baseOutDir:P,type:s}),r=o.join(i,e);T&&await x(),await c({dir:d,toolsPath:v.path,outPath:r,preventMoveDTS:B,type:s,minifyJS:m})}}return console.log("Configuration read successfully"),{preBuildStyles:x,copyCss:I,copyStats:A,copyProvider:k,fullBuild:async function(){console.log("Copying CSS files..."),await I(),console.log("CSS files copied successfully"),j||(console.log("Copying tools files..."),await async function(){if(p(f))for(const e of f){const{bvTools:s}=e,i=s?.path;if(i){let e=M?.tools??i??"";O&&(e=o.relative(O,e));for(const s of F){const r=t({baseOutDir:P,type:s}),n=o.join(r,e);await c({dir:d,toolsPath:i,outPath:n,preventMoveDTS:B,type:s,minifyJS:m})}}}}(),console.log("Tools files copied successfully"),console.log("Copying provider and stats files..."),await k(),await A(),console.log("Provider and stats files copied successfully"))}}}module.exports={bvBuildScript:d};
@@ -0,0 +1 @@
1
+ const e=require("fs").promises,r=require("path"),t=require("@babel/core"),{minify:s}=require("terser");function o({cssThemes:e,cssOutPath:t}){return Object.entries(e).reduce((e,[s,{foreign:o}])=>{const{before:n,after:i}=o,a=n&&Array.isArray(n)&&n.length>0?n.reduce((e,s,o)=>{const n=r.basename(s);return o>0&&(e+=", "),e+`'${t}/${n}'`},""):"",u=i&&Array.isArray(i)&&i.length>0?i.reduce((e,s,o)=>{const n=r.basename(s);return o>0&&(e+=", "),e+`'${t}/${n}'`},""):"";return e+`'${s}':{css:'${t}/${s}.css',foreign:{before: [${a}],after: [${u}]}}`},"")}async function n(e,r,s=!1){const o=!!s&&"commonjs";return(await t.transformAsync(e,{filename:r,presets:[["@babel/preset-env",{modules:o,targets:{node:"current"}}]]})).code}async function i(e){return(await s(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 a(e,r){e.some(e=>e.name===r.name&&e.path===r.path)||e.push(r)}function u({jsonCustomOutDirs:e,cliCustomOutDirs:r}){let t={};return e&&(t={...e}),r&&(t={...t,...r}),Object.keys(t).length>0?t:void 0}function c(e="provider"){return e.charAt(0).toLowerCase()+e.slice(1)}async function m({dir:t,theme:s,foreignThemes:o}){const n=r.resolve(t,s.stylesPath,`${s.name}.min.css`),i=await e.readFile(n,"utf-8"),a={before:"",after:""};if(o)for(const s of o){const o=await e.readFile(r.resolve(t,s.path),"utf-8");a[s.position]+=o.replace(/\s+/g," ")}return a.before+i+a.after}function f({jsonConfig:e,cliConfig:r}){return{baseOutDir:r?.baseOutDir??e?.baseOutDir??"",rootDir:r?.rootDir??e?.rootDir??void 0,preventMoveJS:r?.preventMoveJs??e?.preventMoveJS??!1,preventMoveDTS:r?.preventMoveDts??e?.preventMoveDts??!1,types:r?.types??e?.types??void 0,embedCss:r?.embedCss??e?.embedCss??!1,customOutDirs:u({jsonCustomOutDirs:e?.customOutDirs,cliCustomOutDirs:r?.customOutDirs})}}function l(e){return e&&Array.isArray(e)&&e.length>0}module.exports={modifyThemesPath:o,isIterableArray:l,transpileTo:n,minifyJSFile:i,pushUniqueFile:a,overwriteCustomOutDirs:u,lowerCaseFirstChar:c,generateEmbedCssContent:m,buildCustomOutDirs:f};
@@ -0,0 +1 @@
1
+ const e=require("fs").promises,t=require("path"),{writeDoc:s,fileExists:i}=require("../../src/lib"),{modifyThemesPath:a,transpileTo:r,minifyJSFile:o,lowerCaseFirstChar:n,generateEmbedCssContent:l}=require("./utils");async function c({baseOutPath:a,cssFiles:r,rootDir:o,customOutDirs:n,dir:l}){for(const c of r){const r=(()=>o&&!n?.css?t.relative(o,c.path):n?.css?n.css:c.path)(),m=t.resolve(l,c.path,c.name);if(i(l,m)){const i=await e.readFile(m,"utf8"),o=c.name.replace(".min","");await s(t.resolve(a,r,o),i,o)}}}async function m({dir:a,cssPath:r,theme:o}){const{stylesPath:n,foreignThemes:l}=o,c=t.resolve(a,n,`${o.name}.min.css`);if(i(a,c)){const i=await e.readFile(c,"utf-8"),n=t.resolve(a,r,`${o.name}.css`);await s(n,i,`${o.name}.css`)}if(l&&Array.isArray(l)&&l.length>0)for(const o of l){const n=t.basename(o.path),l=t.resolve(a,o.path);if(i(a,l)){const i=(await e.readFile(l,"utf-8")).replace(/\s+/g," "),o=t.resolve(a,r,n);await s(o,i,n)}}}async function f({dir:e,theme:i,provider:a}){const{foreignThemes:r}=i,o=r&&Array.isArray(r)&&r.length>0?r.reduce((e,t)=>(e.push({position:t.position,path:t.path}),e),[]):void 0,n=await l({dir:e,theme:i,foreignThemes:o}),c=`export default {'${i.name}':{css:\`${n}\`}};`,m=t.resolve(e,a.path,"stats",i.name,"cssTheme.js");await s(m,c,"cssTheme.js")}async function h({dir:e,theme:i,css:r,provider:o}){const n=t.resolve(e,o.path,"stats",i.name,"cssTheme.js"),{default:l}=require(n),c=`export default {${a({cssThemes:l,cssOutPath:r})}};`;await s(n,c,"cssTheme.js")}async function p({dir:i,embedCss:a,provider:r}){const o=a?"style":"link",l=t.resolve(__dirname,`../../src/lib/generateProvider/template/providerTemplate-${o}.js`);let c=await e.readFile(l,"utf-8");c=c.replace(/\$_Provider_\$/g,r.name);const m=`${n(r.name)}.js`,f=t.resolve(i,r.path,m);await s(f,c,m)}async function d({file:i,type:a,minifyJS:n,outPath:l,currentPath:c,preventMoveDTS:m=!1}){if(i.name.endsWith(".js")){const m=t.resolve(c,i.name);let f=await e.readFile(m,"utf-8");"cjs"===a?f=await r(f,m,!0):"esm"===a&&(f=await r(f,m)),n&&(f=await o(f)),s(t.join(l,i.name),f,i.name)}if(i.name.endsWith(".d.ts")&&!m){const a=t.resolve(c,i.name),r=await e.readFile(a,"utf-8");s(t.join(l,i.name),r,i.name)}}async function u({dir:s,providerPath:i,outPath:a,minifyJS:r,preventMoveDTS:o,type:n}){const l=t.resolve(s,i,"stats"),c=await e.readdir(l,{withFileTypes:!0});for(const i of c)if(i.isDirectory()){const c=t.resolve(l,i.name),m=await e.readdir(c,{withFileTypes:!0});for(file of m)file.isFile()&&await d({file:file,type:n,minifyJS:r,outPath:t.resolve(s,a,i.name),currentPath:c,preventMoveDTS:o})}else i.isFile()&&await d({file:i,type:n,minifyJS:r,outPath:t.resolve(s,a),currentPath:l,preventMoveDTS:o})}async function v({dir:s,toolsPath:i,outPath:a,type:r,minifyJS:o,preventMoveDTS:n=!1}){const l=t.resolve(s,i),c=await e.readdir(l,{withFileTypes:!0});for(const e of c)e.isFile()&&await d({file:e,type:r,minifyJS:o,outPath:t.resolve(s,a),currentPath:l,preventMoveDTS:n})}module.exports={writeJs:d,writeCss:c,copyCssFiles:m,embedCssForProvider:f,rewriteCssPathInStats:h,rewriteProviderTemplate:p,writeStatsinBuild:u,writeToolsInBuild:v};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ const{bvBuildScript:s}=require("./functions/scriptFx");(async()=>{try{const e=await s();await e.preBuildStyles(),console.log("Pre-build styles processing completed successfully.")}catch(s){console.error("Error during pre-build styles processing:",s),process.exit(1)}})();
@@ -1 +1 @@
1
- const s=require("fs"),e=require("fs").promises,a=require("path"),{writeDoc:t}=require("../writeDoc/writeDoc.utils"),{compilerTypeValid:o}=require("../../constants"),{simplifyName:l}=require("../simplifyName/simplifyName.utils"),i=(s="provider")=>s.charAt(0).toLowerCase()+s.slice(1),r=s=>`export default {${s}}`,c=(s,e)=>`export interface ${e} {${s}}\n`,n=async({dir:s,content:e,fileName:o,theme:l,declare:i=null})=>{const n=i?c(e,i):r(e),m=`stats/${l}/${o}`,p=a.resolve(s,m);await t(p,n,m)},m=async({providerDocs:s,declarationHelp:e,compilerType:i,dir:r})=>{const c=Object.entries(s),m=[];for(const[s,a]of c){m.push(s);const t=a.beforeFiles?.length>0,c=a.afterFiles?.length>0,p=t?`before:${a.beforeFiles}`:"",d=c?`after:${a.afterFiles}`:"",$=t||c;let C=$?"foreign:{":"";C+=p,C+=p.length&&d.length?",":"",C+=d,C+=$?"}":"";const b="cssPath"in a?`'${s}':{css:'${a.cssPath}',${C}}`:"";if(await n({dir:r,content:b,fileName:"cssTheme.js",theme:s}),e){const e="cssPath"in a?`'${s}':{css:string,foreign?:{before?:string[],after?:string[]}}`:"",t=`${l(s)}CssTheme`;await n({dir:r,content:e,fileName:"cssTheme.d.ts",theme:s,declare:t})}if(i!==o.foundationOnly){const t="classNames"in a?`'${s}':{${a.classNames.doc}}`:"";await n({dir:r,content:t,fileName:"cssClassNames.js",theme:s});const o="availableComp"in a?`'${s}':{${a.availableComp.doc}}`:"";if(await n({dir:r,content:o,fileName:"cssAvailableComponents.js",theme:s}),e){const e="classNames"in a?`'${s}':{${a.classNames.declare}}`:"",t=`${l(s)}CssClassNames`;await n({dir:r,content:e,fileName:"cssClassNames.d.ts",theme:s,declare:t});const o="availableComp"in a?`'${s}':{${a.availableComp.declare}}`:"",i=`${l(s)}CssAvailableComponents`;await n({dir:r,content:o,fileName:"cssAvailableComponents.d.ts",theme:s,declare:i})}}if(i!==o.componentOnly){const t="variables"in a?`'${s}':{${a.variables.doc}}`:"";await n({dir:r,content:t,fileName:"cssVars.js",theme:s});const o="globalStyles"in a?`'${s}':{${a.globalStyles.doc}}`:"";await n({dir:r,content:o,fileName:"cssGlobalStyles.js",theme:s});const i="mediaQueries"in a?`'${s}':{${a.mediaQueries.doc}}`:"";if(await n({dir:r,content:i,fileName:"cssMediaQueries.js",theme:s}),e){const e="variables"in a?`'${s}':{${a.variables.declare}}`:"",t=`${l(s)}CssVars`;await n({dir:r,content:e,fileName:"cssVars.d.ts",theme:s,declare:t});const o="globalStyles"in a?`'${s}':{${a.globalStyles.declare}}`:"",i=`${l(s)}CssGlobalStyles`;await n({dir:r,content:o,fileName:"cssGlobalStyles.d.ts",theme:s,declare:i});const c="mediaQueries"in a?`'${s}':{${a.mediaQueries.declare}}`:"",m=`${l(s)}CssMediaQueries`;await n({dir:r,content:c,fileName:"cssMediaQueries.d.ts",theme:s,declare:m})}}}const p={toImport:"",cssThemes:"export const cssThemes = {",cssVars:"export const cssVars = {",cssClassNames:"export const cssClasses = {",cssAvailableComponents:"export const cssAvailableComponents = {",cssGlobalStyles:"export const cssGlobalStyles = {",cssMediaQueries:"export const cssMediaQueries = {"},d={toImport:"",cssThemes:"export declare const cssThemes: ",cssVars:"export declare const cssVars: ",cssClassNames:"export declare const cssClasses: ",cssAvailableComponents:"export declare const cssAvailableComponents: ",cssGlobalStyles:"export declare const cssGlobalStyles: ",cssMediaQueries:"export declare const cssMediaQueries: "};m.forEach((s,a)=>{const t=l(s);p.toImport+=`import ${t}CssTheme from './${s}/cssTheme.js';\n`,p.toImport+=`import ${t}CssVars from './${s}/cssVars.js';\n`,p.toImport+=`import ${t}CssClassNames from './${s}/cssClassNames.js';\n`,p.toImport+=`import ${t}CssAvailableComponents from './${s}/cssAvailableComponents.js';\n`,p.toImport+=`import ${t}CssGlobalStyles from './${s}/cssGlobalStyles.js';\n`,p.toImport+=`import ${t}CssMediaQueries from './${s}/cssMediaQueries.js';\n`,p.cssThemes+=`...${t}CssTheme,`,p.cssVars+=`...${t}CssVars,`,p.cssClassNames+=`...${t}CssClassNames,`,p.cssAvailableComponents+=`...${t}CssAvailableComponents,`,p.cssGlobalStyles+=`...${t}CssGlobalStyles,`,p.cssMediaQueries+=`...${t}CssMediaQueries,`,e&&(d.toImport+=`import type { ${t}CssTheme } from './${s}/cssTheme.d.ts';\n`,d.toImport+=`import type { ${t}CssVars } from './${s}/cssVars.d.ts';\n`,d.toImport+=`import type { ${t}CssClassNames } from './${s}/cssClassNames.d.ts';\n`,d.toImport+=`import type { ${t}CssAvailableComponents } from './${s}/cssAvailableComponents.d.ts';\n`,d.toImport+=`import type { ${t}CssGlobalStyles } from './${s}/cssGlobalStyles.d.ts';\n`,d.toImport+=`import type { ${t}CssMediaQueries } from './${s}/cssMediaQueries.d.ts';\n`,a>0&&(d.cssThemes+=" & ",d.cssVars+=" & ",d.cssClassNames+=" & ",d.cssAvailableComponents+=" & ",d.cssGlobalStyles+=" & ",d.cssMediaQueries+=" & "),d.cssThemes+=`${t}CssTheme`,d.cssVars+=`${t}CssVars`,d.cssClassNames+=`${t}CssClassNames`,d.cssAvailableComponents+=`${t}CssAvailableComponents`,d.cssGlobalStyles+=`${t}CssGlobalStyles`,d.cssMediaQueries+=`${t}CssMediaQueries`)}),p.cssThemes+="}",p.cssVars+="}",p.cssClassNames+="}",p.cssAvailableComponents+="}",p.cssGlobalStyles+="}",p.cssMediaQueries+="}";const $=`${p.toImport}\n${p.cssThemes}\n${p.cssVars}\n${p.cssClassNames}\n${p.cssAvailableComponents}\n${p.cssGlobalStyles}\n${p.cssMediaQueries}\n`;if(await t(a.join(r,"stats/stats.js"),$,"stats.js"),e){d.cssThemes+=";",d.cssVars+=";",d.cssClassNames+=";",d.cssAvailableComponents+=";",d.cssGlobalStyles+=";",d.cssMediaQueries+=";";const s=`${d.toImport}\n${d.cssThemes}\n${d.cssVars}\n${d.cssClassNames}\n${d.cssAvailableComponents}\n${d.cssGlobalStyles}\n${d.cssMediaQueries}\n`;await t(a.join(r,"stats/stats.d.ts"),s,"stats.d.ts")}},p=async({dir:s,providerDocs:o,declarationHelp:l,providerName:r,compilerType:c})=>{await m({providerDocs:o,declarationHelp:l,compilerType:c,dir:s});const n=a.resolve(__dirname,"./template/providerTemplate.js");let p=await e.readFile(n,"utf8");const d=i(r);if(p=p.replace(/\$_Provider_\$/g,r),await t(a.join(s,`${d}.js`),p,`${d}.js`),l){const o=a.resolve(__dirname,"./template/providerTemplate.d.ts");let l=await e.readFile(o,"utf8");l=l.replace(/\$_Provider_\$/g,r),await t(a.join(s,`${d}.d.ts`),l,`${d}.d.ts`)}};module.exports={generateProvider:p};
1
+ const s=require("fs"),e=require("fs").promises,a=require("path"),{writeDoc:t}=require("../writeDoc/writeDoc.utils"),{compilerTypeValid:o}=require("../../constants"),{simplifyName:l}=require("../simplifyName/simplifyName.utils"),i=(s="provider")=>s.charAt(0).toLowerCase()+s.slice(1),r=s=>`export default {${s}}`,c=(s,e)=>`interface ${e} {${s}}\ndeclare const ${e}: ${e};\nexport default ${e};`,n=async({dir:s,content:e,fileName:o,theme:l,declare:i=null})=>{const n=i?c(e,i):r(e),m=`stats/${l}/${o}`,p=a.resolve(s,m);await t(p,n,m)},m=async({providerDocs:s,declarationHelp:e,compilerType:i,dir:r})=>{const c=Object.entries(s),m=[];for(const[s,a]of c){m.push(s);const t=a.beforeFiles?.length>0,c=a.afterFiles?.length>0,p=t?`before:${a.beforeFiles}`:"",d=c?`after:${a.afterFiles}`:"",$=t||c;let C=$?"foreign:{":"";C+=p,C+=p.length&&d.length?",":"",C+=d,C+=$?"}":"";const b="cssPath"in a?`'${s}':{css:'${a.cssPath}',${C}}`:"";if(await n({dir:r,content:b,fileName:"cssTheme.js",theme:s}),e){const e="cssPath"in a?`'${s}':{css:string,foreign?:{before?:string[],after?:string[]}}`:"",t=`${l(s)}CssTheme`;await n({dir:r,content:e,fileName:"cssTheme.d.ts",theme:s,declare:t})}if(i!==o.foundationOnly){const t="classNames"in a?`'${s}':{${a.classNames.doc}}`:"";await n({dir:r,content:t,fileName:"cssClassNames.js",theme:s});const o="availableComp"in a?`'${s}':{${a.availableComp.doc}}`:"";if(await n({dir:r,content:o,fileName:"cssAvailableComponents.js",theme:s}),e){const e="classNames"in a?`'${s}':{${a.classNames.declare}}`:"",t=`${l(s)}CssClassNames`;await n({dir:r,content:e,fileName:"cssClassNames.d.ts",theme:s,declare:t});const o="availableComp"in a?`'${s}':{${a.availableComp.declare}}`:"",i=`${l(s)}CssAvailableComponents`;await n({dir:r,content:o,fileName:"cssAvailableComponents.d.ts",theme:s,declare:i})}}if(i!==o.componentOnly){const t="variables"in a?`'${s}':{${a.variables.doc}}`:"";await n({dir:r,content:t,fileName:"cssVars.js",theme:s});const o="globalStyles"in a?`'${s}':{${a.globalStyles.doc}}`:"";await n({dir:r,content:o,fileName:"cssGlobalStyles.js",theme:s});const i="mediaQueries"in a?`'${s}':{${a.mediaQueries.doc}}`:"";if(await n({dir:r,content:i,fileName:"cssMediaQueries.js",theme:s}),e){const e="variables"in a?`'${s}':{${a.variables.declare}}`:"",t=`${l(s)}CssVars`;await n({dir:r,content:e,fileName:"cssVars.d.ts",theme:s,declare:t});const o="globalStyles"in a?`'${s}':{${a.globalStyles.declare}}`:"",i=`${l(s)}CssGlobalStyles`;await n({dir:r,content:o,fileName:"cssGlobalStyles.d.ts",theme:s,declare:i});const c="mediaQueries"in a?`'${s}':{${a.mediaQueries.declare}}`:"",m=`${l(s)}CssMediaQueries`;await n({dir:r,content:c,fileName:"cssMediaQueries.d.ts",theme:s,declare:m})}}}const p={toImport:"",cssThemes:"export const cssThemes = {",cssVars:"export const cssVars = {",cssClassNames:"export const cssClasses = {",cssAvailableComponents:"export const cssAvailableComponents = {",cssGlobalStyles:"export const cssGlobalStyles = {",cssMediaQueries:"export const cssMediaQueries = {"},d={toImport:"",cssThemes:"export declare const cssThemes: ",cssVars:"export declare const cssVars: ",cssClassNames:"export declare const cssClasses: ",cssAvailableComponents:"export declare const cssAvailableComponents: ",cssGlobalStyles:"export declare const cssGlobalStyles: ",cssMediaQueries:"export declare const cssMediaQueries: "};m.forEach((s,a)=>{const t=l(s);p.toImport+=`import ${t}CssTheme from './${s}/cssTheme.js';\n`,p.toImport+=`import ${t}CssVars from './${s}/cssVars.js';\n`,p.toImport+=`import ${t}CssClassNames from './${s}/cssClassNames.js';\n`,p.toImport+=`import ${t}CssAvailableComponents from './${s}/cssAvailableComponents.js';\n`,p.toImport+=`import ${t}CssGlobalStyles from './${s}/cssGlobalStyles.js';\n`,p.toImport+=`import ${t}CssMediaQueries from './${s}/cssMediaQueries.js';\n`,p.cssThemes+=`...${t}CssTheme,`,p.cssVars+=`...${t}CssVars,`,p.cssClassNames+=`...${t}CssClassNames,`,p.cssAvailableComponents+=`...${t}CssAvailableComponents,`,p.cssGlobalStyles+=`...${t}CssGlobalStyles,`,p.cssMediaQueries+=`...${t}CssMediaQueries,`,e&&(d.toImport+=`import type ${t}CssTheme from './${s}/cssTheme.d.ts';\n`,d.toImport+=`import type ${t}CssVars from './${s}/cssVars.d.ts';\n`,d.toImport+=`import type ${t}CssClassNames from './${s}/cssClassNames.d.ts';\n`,d.toImport+=`import type ${t}CssAvailableComponents from './${s}/cssAvailableComponents.d.ts';\n`,d.toImport+=`import type ${t}CssGlobalStyles from './${s}/cssGlobalStyles.d.ts';\n`,d.toImport+=`import type ${t}CssMediaQueries from './${s}/cssMediaQueries.d.ts';\n`,a>0&&(d.cssThemes+=" & ",d.cssVars+=" & ",d.cssClassNames+=" & ",d.cssAvailableComponents+=" & ",d.cssGlobalStyles+=" & ",d.cssMediaQueries+=" & "),d.cssThemes+=`${t}CssTheme`,d.cssVars+=`${t}CssVars`,d.cssClassNames+=`${t}CssClassNames`,d.cssAvailableComponents+=`${t}CssAvailableComponents`,d.cssGlobalStyles+=`${t}CssGlobalStyles`,d.cssMediaQueries+=`${t}CssMediaQueries`)}),p.cssThemes+="}",p.cssVars+="}",p.cssClassNames+="}",p.cssAvailableComponents+="}",p.cssGlobalStyles+="}",p.cssMediaQueries+="}";const $=`${p.toImport}\n${p.cssThemes}\n${p.cssVars}\n${p.cssClassNames}\n${p.cssAvailableComponents}\n${p.cssGlobalStyles}\n${p.cssMediaQueries}\n`;if(await t(a.join(r,"stats/stats.js"),$,"stats.js"),e){d.cssThemes+=";",d.cssVars+=";",d.cssClassNames+=";",d.cssAvailableComponents+=";",d.cssGlobalStyles+=";",d.cssMediaQueries+=";";const s=`${d.toImport}\n${d.cssThemes}\n${d.cssVars}\n${d.cssClassNames}\n${d.cssAvailableComponents}\n${d.cssGlobalStyles}\n${d.cssMediaQueries}\n`;await t(a.join(r,"stats/stats.d.ts"),s,"stats.d.ts")}},p=async({dir:s,providerDocs:o,declarationHelp:l,providerName:r,compilerType:c})=>{await m({providerDocs:o,declarationHelp:l,compilerType:c,dir:s});const n=a.resolve(__dirname,"./template/providerTemplate-link.js");let p=await e.readFile(n,"utf8");const d=i(r);if(p=p.replace(/\$_Provider_\$/g,r),await t(a.join(s,`${d}.js`),p,`${d}.js`),l){const o=a.resolve(__dirname,"./template/providerTemplate.d.ts");let l=await e.readFile(o,"utf8");l=l.replace(/\$_Provider_\$/g,r),await t(a.join(s,`${d}.d.ts`),l,`${d}.d.ts`)}};module.exports={generateProvider:p};
@@ -0,0 +1 @@
1
+ import{cssThemes as e,cssClasses as t,cssVars as s,cssAvailableComponents as n,cssGlobalStyles as i,cssMediaQueries as h}from"./stats/stats";export class $_Provider_${#e;#t;#s;#n;#i;#h;#r;#l;#o;#m=(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 n=document.location.origin,i=new URL(e,n).href;s.href=i};#a=e=>{const{css:t,foreign:s}=e,n=s?.before||[],i=s?.after||[];n.forEach((e,t)=>{const s=`${this.#l}-foreign-before-${t+1}`;this.#m(e,s)}),this.#m(t,this.#l),i.forEach((e,t)=>{const s=`${this.#l}-foreign-after-${t+1}`;this.#m(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.#n=t,this.#i=n,this.#h=i,this.#r=h,this.#l=r||"kb-styled-link",this.#e=Object.keys(e)[0],this.#o=!!l,this.getComponentStyles=this.getComponentStyles.bind(this),"undefined"!=typeof window&&"undefined"!=typeof document&&this.#o&&(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.#o&&(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.#n[this.#e]}get components(){return this.#i[this.#e]}get globalStyles(){return this.#h[this.#e]}get mediaQueries(){return this.#r[this.#e]}getComponentStyles({variant:e,component:t,additionalClassNames:s}){const n=this.#n[this.#e][t.toLocaleUpperCase()];if(!n)return{};const i={},h=!!e&&`$_${e.toLocaleLowerCase().replace(/-/g,"_")}`;if(h&&h in n){const e=n[h];Object.entries(e).forEach(([e,t])=>{e in i||(i[e]=t)})}return Object.entries(n).forEach(([e,t])=>{e.startsWith("$_")||e in i||(i[e]=t)}),s&&Object.keys(s).length&&Object.entries(s).forEach(([e,t])=>{e in i||(i[e]=""),i[e]+=` ${t}`}),i}}
@@ -0,0 +1 @@
1
+ import{cssThemes as e,cssClasses as t,cssVars as s,cssAvailableComponents as n,cssGlobalStyles as i,cssMediaQueries as h}from"./stats/stats";export class $_Provider_${#e;#t;#s;#n;#i;#h;#r;#m;#l;#a=(e,t)=>{if("undefined"==typeof document)return;let s=document.getElementById(t);s||(s=document.createElement("style"),s.id=t,s.type="text/css",document.head.appendChild(s)),s.innerHTML=e};#o=e=>{const{css:t}=e;this.#a(t,this.#m)};#c=()=>{if("undefined"==typeof document)return;const e=document.getElementById(this.#m);e&&e.remove()};constructor({linkId:r,jsInCss:m}={}){this.#t=e,this.#s=s,this.#n=t,this.#i=n,this.#h=i,this.#r=h,this.#m=r||"kb-styled-link",this.#e=Object.keys(e)[0],this.#l=!!m,this.getComponentStyles=this.getComponentStyles.bind(this),"undefined"!=typeof window&&"undefined"!=typeof document&&this.#l&&(this.#c(),this.#o(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.#l&&(this.#c(),this.#o(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.#n[this.#e]}get components(){return this.#i[this.#e]}get globalStyles(){return this.#h[this.#e]}get mediaQueries(){return this.#r[this.#e]}getComponentStyles({variant:e,component:t,additionalClassNames:s}){const n=this.#n[this.#e][t.toLocaleUpperCase()];if(!n)return{};const i={},h=!!e&&`$_${e.toLocaleLowerCase().replace(/-/g,"_")}`;if(h&&h in n){const e=n[h];Object.entries(e).forEach(([e,t])=>{e in i||(i[e]=t)})}return Object.entries(n).forEach(([e,t])=>{e.startsWith("$_")||e in i||(i[e]=t)}),s&&Object.keys(s).length&&Object.entries(s).forEach(([e,t])=>{e in i||(i[e]=""),i[e]+=` ${t}`}),i}}
@@ -33,7 +33,7 @@ export declare class $_Provider_$ {
33
33
  #linkId: string;
34
34
  #jsInCss: boolean;
35
35
  /* Bernova provider methods */
36
- #linkBuilder: (url: string, id: string) => void;
36
+ #linkBuilder: (css: string, id: string) => void;
37
37
  #handlerThemes: (data: {
38
38
  css: string;
39
39
  foreign?: { high?: string[]; low?: string[] };
@@ -0,0 +1,18 @@
1
+ export class $_Provider_$ {
2
+ constructor({ linkId, jsInCss }?: {});
3
+ getComponentStyles({ variant, component, additionalClassNames }: {
4
+ variant: any;
5
+ component: any;
6
+ additionalClassNames: any;
7
+ }): {};
8
+ set themeSelected(themeName: string);
9
+ get themeSelected(): string;
10
+ get allThemesNames(): string[];
11
+ get allThemes(): any;
12
+ get variables(): any;
13
+ get classNames(): any;
14
+ get components(): any;
15
+ get globalStyles(): any;
16
+ get mediaQueries(): any;
17
+ #private;
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bernova",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
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",
@@ -16,8 +16,12 @@
16
16
  },
17
17
  "bin": {
18
18
  "bernova": "./dist/bin/bernova.js",
19
+ "bv-config": "./dist/bin/createConfigFile.js",
19
20
  "bv-build": "./dist/bin/buildstyle.js",
20
- "bv-config": "./dist/bin/createConfigFile.js"
21
+ "bv-pre-build": "./dist/bin/preBuildStyles.js",
22
+ "bv-copy-css": "./dist/bin/copyCss.js",
23
+ "bv-copy-tools": "./dist/bin/copyTools.js",
24
+ "bv-copy-provider": "./dist/bin/copyProvider.js"
21
25
  },
22
26
  "_moduleAliases": {
23
27
  "@": "src"
@@ -105,8 +109,7 @@
105
109
  "url": "https://github.com/sponsors/kubit-ui"
106
110
  },
107
111
  "engines": {
108
- "node": ">=20.0.0 <25.0.0",
109
- "yarn": ">=4.0.0"
112
+ "node": ">=20.0.0 <25.0.0"
110
113
  },
111
114
  "publishConfig": {
112
115
  "access": "public",
@@ -142,6 +145,5 @@
142
145
  "vite": "^6.3.6",
143
146
  "vite-plugin-dts": "^4.5.0",
144
147
  "vitest": "^3.2.4"
145
- },
146
- "packageManager": "yarn@4.9.1"
148
+ }
147
149
  }
package/src/app.js CHANGED
@@ -150,7 +150,7 @@ async function bernovaStyles(compilerType) {
150
150
  : path.join('./styles', `${name}.css`);
151
151
  const { themeByPosition, variablesExtracted, classesExtracted } =
152
152
  await handlerForeignThemes({ dir, foreignThemes });
153
-
153
+
154
154
  themeRegister[name] = generateThemeRegister({
155
155
  cssPath,
156
156
  rootDocs,
@@ -162,7 +162,9 @@ async function bernovaStyles(compilerType) {
162
162
  foreignBeforeFiles: themeByPosition.before,
163
163
  foreignAfterFiles: themeByPosition.after,
164
164
  });
165
- spinner.succeed(`Theme register generated for provider for theme: ${name}`);
165
+ spinner.succeed(
166
+ `Theme register generated for provider for theme: ${name}`,
167
+ );
166
168
  }
167
169
  }
168
170
 
@@ -46,7 +46,7 @@ const anonimousWrapper = (content) => {
46
46
  * @return {string} - wrapped content
47
47
  */
48
48
  const interfaceWrapper = (content, iName) => {
49
- return `export interface ${iName} {${content}}\n`;
49
+ return `interface ${iName} {${content}}\ndeclare const ${iName}: ${iName};\nexport default ${iName};`;
50
50
  };
51
51
 
52
52
  /**
@@ -303,12 +303,12 @@ const buildStatsDoc = async ({
303
303
  statsPieces.cssGlobalStyles += `...${simplifiedName}CssGlobalStyles,`;
304
304
  statsPieces.cssMediaQueries += `...${simplifiedName}CssMediaQueries,`;
305
305
  if (declarationHelp) {
306
- statsDPieces.toImport += `import type { ${simplifiedName}CssTheme } from './${theme}/cssTheme.d.ts';\n`;
307
- statsDPieces.toImport += `import type { ${simplifiedName}CssVars } from './${theme}/cssVars.d.ts';\n`;
308
- statsDPieces.toImport += `import type { ${simplifiedName}CssClassNames } from './${theme}/cssClassNames.d.ts';\n`;
309
- statsDPieces.toImport += `import type { ${simplifiedName}CssAvailableComponents } from './${theme}/cssAvailableComponents.d.ts';\n`;
310
- statsDPieces.toImport += `import type { ${simplifiedName}CssGlobalStyles } from './${theme}/cssGlobalStyles.d.ts';\n`;
311
- statsDPieces.toImport += `import type { ${simplifiedName}CssMediaQueries } from './${theme}/cssMediaQueries.d.ts';\n`;
306
+ statsDPieces.toImport += `import type ${simplifiedName}CssTheme from './${theme}/cssTheme.d.ts';\n`;
307
+ statsDPieces.toImport += `import type ${simplifiedName}CssVars from './${theme}/cssVars.d.ts';\n`;
308
+ statsDPieces.toImport += `import type ${simplifiedName}CssClassNames from './${theme}/cssClassNames.d.ts';\n`;
309
+ statsDPieces.toImport += `import type ${simplifiedName}CssAvailableComponents from './${theme}/cssAvailableComponents.d.ts';\n`;
310
+ statsDPieces.toImport += `import type ${simplifiedName}CssGlobalStyles from './${theme}/cssGlobalStyles.d.ts';\n`;
311
+ statsDPieces.toImport += `import type ${simplifiedName}CssMediaQueries from './${theme}/cssMediaQueries.d.ts';\n`;
312
312
  if (idx > 0) {
313
313
  statsDPieces.cssThemes += ' & ';
314
314
  statsDPieces.cssVars += ' & ';
@@ -374,7 +374,8 @@ const generateProvider = async ({
374
374
  //? write stats and dependencies documents
375
375
  await buildStatsDoc({ providerDocs, declarationHelp, compilerType, dir });
376
376
  //? write provider
377
- const providerDir = path.resolve(__dirname, './template/providerTemplate.js');
377
+ const templateFile = './template/providerTemplate-link.js';
378
+ const providerDir = path.resolve(__dirname, templateFile);
378
379
  let template = await fs.readFile(providerDir, 'utf8');
379
380
  //* customize provider name
380
381
  const providerFileName = lowerCaseFirstChar(providerName);
@@ -18,7 +18,7 @@ export class $_Provider_$ {
18
18
  #linkId;
19
19
  #jsInCss;
20
20
  /* Bernova provider methods */
21
- #linkBuilder = (url, id) => {
21
+ #linkBuilder = (css, id) => {
22
22
  if (typeof document === 'undefined') return;
23
23
  let linkElement = document.getElementById(id);
24
24
  if (!linkElement) {
@@ -28,7 +28,7 @@ export class $_Provider_$ {
28
28
  document.head.appendChild(linkElement);
29
29
  }
30
30
  const baseUrl = document.location.origin;
31
- const href = new URL(url, baseUrl).href;
31
+ const href = new URL(css, baseUrl).href;
32
32
  linkElement.href = href;
33
33
  };
34
34
  #handlerThemes = (data) => {
@@ -18,40 +18,25 @@ export class $_Provider_$ {
18
18
  #linkId;
19
19
  #jsInCss;
20
20
  /* Bernova provider methods */
21
- #linkBuilder = (url, id) => {
21
+ #linkBuilder = (css, id) => {
22
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);
23
+ let styleElement = document.getElementById(id);
24
+ if (!styleElement) {
25
+ styleElement = document.createElement('style');
26
+ styleElement.id = id;
27
+ styleElement.type = 'text/css';
28
+ document.head.appendChild(styleElement);
29
29
  }
30
- const baseUrl = document.location.origin;
31
- const href = new URL(url, baseUrl).href;
32
- linkElement.href = href;
30
+ styleElement.innerHTML = css;
33
31
  };
34
32
  #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
33
+ const { css } = data;
44
34
  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
35
  };
51
36
  #cleanUpLinks = () => {
52
37
  if (typeof document === 'undefined') return;
53
- const links = document.querySelectorAll(`link[id^="${this.#linkId}"]`);
54
- links.forEach((link) => link.remove());
38
+ const style = document.getElementById(this.#linkId);
39
+ if (style) style.remove();
55
40
  };
56
41
  /* Bernova provider methods */
57
42
 
@@ -33,7 +33,7 @@ export declare class $_Provider_$ {
33
33
  #linkId: string;
34
34
  #jsInCss: boolean;
35
35
  /* Bernova provider methods */
36
- #linkBuilder: (url: string, id: string) => void;
36
+ #linkBuilder: (css: string, id: string) => void;
37
37
  #handlerThemes: (data: {
38
38
  css: string;
39
39
  foreign?: { high?: string[]; low?: string[] };