@devup-ui/webpack-plugin 1.0.32 → 1.0.34

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("@devup-ui/wasm");let r="",c="";const o=function(n,t,e){var l;const{watch:u}=this.getOptions();if(!u)return this.callback(null,i.getCss());const s=((l=this._compiler)==null?void 0:l.__DEVUP_CACHE)||n.toString();if(c===s){this.callback(null,r,t,e);return}c=s,this.callback(null,r=i.getCss(),t,e)};exports.default=o;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@devup-ui/wasm");let n="",c="";function a(t){return t.endsWith("devup-ui.css")?null:parseInt(t.split("devup-ui-")[1].split(".")[0])}const p=function(t,e,s){var l;const{watch:o}=this.getOptions(),u=a(this.resourcePath);if(!o)return this.callback(null,r.getCss(u,!0));const i=((l=this._compiler)==null?void 0:l.__DEVUP_CACHE)||t.toString();if(c===i){this.callback(null,n,e,s);return}c=i,this.callback(null,n=r.getCss(u,!0),e,s)};exports.default=p;
@@ -1 +1 @@
1
- {"version":3,"file":"css-loader.d.ts","sourceRoot":"","sources":["../src/css-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAK1D,QAAA,MAAM,gBAAgB,EAAE,2BAA2B,CAAC;IAClD,KAAK,EAAE,OAAO,CAAA;CACf,CAYA,CAAA;AACD,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"css-loader.d.ts","sourceRoot":"","sources":["../src/css-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAU1D,QAAA,MAAM,gBAAgB,EAAE,2BAA2B,CAAC;IAClD,KAAK,EAAE,OAAO,CAAA;CACf,CAaA,CAAA;AACD,eAAe,gBAAgB,CAAA"}
@@ -1,16 +1,19 @@
1
- import { getCss as i } from "@devup-ui/wasm";
2
- let r = "", c = "";
3
- const u = function(n, t, l) {
4
- var e;
5
- const { watch: o } = this.getOptions();
6
- if (!o) return this.callback(null, i());
7
- const s = ((e = this._compiler) == null ? void 0 : e.__DEVUP_CACHE) || n.toString();
8
- if (c === s) {
9
- this.callback(null, r, t, l);
1
+ import { getCss as u } from "@devup-ui/wasm";
2
+ let n = "", c = "";
3
+ function a(t) {
4
+ return t.endsWith("devup-ui.css") ? null : parseInt(t.split("devup-ui-")[1].split(".")[0]);
5
+ }
6
+ const h = function(t, e, i) {
7
+ var l;
8
+ const { watch: o } = this.getOptions(), s = a(this.resourcePath);
9
+ if (!o) return this.callback(null, u(s, !0));
10
+ const r = ((l = this._compiler) == null ? void 0 : l.__DEVUP_CACHE) || t.toString();
11
+ if (c === r) {
12
+ this.callback(null, n, e, i);
10
13
  return;
11
14
  }
12
- c = s, this.callback(null, r = i(), t, l);
15
+ c = r, this.callback(null, n = u(s, !0), e, i);
13
16
  };
14
17
  export {
15
- u as default
18
+ h as default
16
19
  };
package/dist/loader.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("node:fs/promises"),n=require("node:path"),s=require("@devup-ui/wasm"),P=function(u){const{watch:h,package:p,cssFile:i,sheetFile:d,classMapFile:m}=this.getOptions(),t=this.async(),_=this.resourcePath;try{let e=n.relative(n.dirname(this.resourcePath),i).replaceAll("\\","/");e.startsWith("./")||(e=`./${e}`);const{code:c,css:f,map:o}=s.codeExtract(_,u.toString(),p,e),l=o?JSON.parse(o):null;if(f&&h){const a=`${this.resourcePath} ${Date.now()}`;this._compiler&&(this._compiler.__DEVUP_CACHE=a),Promise.all([r.writeFile(i,`/* ${a} */`),r.writeFile(d,s.exportSheet()),r.writeFile(m,s.exportClassMap())]).catch(console.error).finally(()=>t(null,c,l));return}t(null,c,l)}catch(e){t(e)}};exports.default=P;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("node:fs/promises"),s=require("node:path"),i=require("@devup-ui/wasm"),S=function(d){const{watch:l,package:f,cssDir:a,sheetFile:m,classMapFile:F,fileMapFile:g,singleCss:w}=this.getOptions(),o=this.async(),_=this.resourcePath;try{let e=s.relative(s.dirname(this.resourcePath),a).replaceAll("\\","/");e.startsWith("./")||(e=`./${e}`);const{code:c,css:n,map:u,cssFile:M,updatedBaseStyle:P}=i.codeExtract(_,d.toString(),f,e,w,!1,!0),p=u?JSON.parse(u):null,r=[];if(P&&r.push(t.writeFile(s.join(a,"devup-ui.css"),i.getCss(null,!1),"utf-8")),n){const h=`${this.resourcePath} ${Date.now()}`;l&&this._compiler&&(this._compiler.__DEVUP_CACHE=h),r.push(t.writeFile(s.join(a,s.basename(M)),l?`/* ${h} */`:n)),l&&r.push(t.writeFile(m,i.exportSheet()),t.writeFile(F,i.exportClassMap()),t.writeFile(g,i.exportFileMap())),Promise.all(r).catch(console.error).finally(()=>o(null,c,p));return}o(null,c,p)}catch(e){o(e)}};exports.default=S;
package/dist/loader.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { RawLoaderDefinitionFunction } from 'webpack';
2
2
  export interface DevupUILoaderOptions {
3
3
  package: string;
4
- cssFile: string;
4
+ cssDir: string;
5
5
  sheetFile: string;
6
6
  classMapFile: string;
7
+ fileMapFile: string;
7
8
  watch: boolean;
9
+ singleCss: boolean;
8
10
  }
9
11
  declare const devupUILoader: RawLoaderDefinitionFunction<DevupUILoaderOptions>;
10
12
  export default devupUILoader;
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAE1D,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,OAAO,CAAA;CACf;AAED,QAAA,MAAM,aAAa,EAAE,2BAA2B,CAAC,oBAAoB,CA2ClE,CAAA;AACH,eAAe,aAAa,CAAA"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAE1D,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,QAAA,MAAM,aAAa,EAAE,2BAA2B,CAAC,oBAAoB,CAkElE,CAAA;AACH,eAAe,aAAa,CAAA"}
package/dist/loader.js CHANGED
@@ -1,40 +1,52 @@
1
- import { writeFile as r } from "node:fs/promises";
2
- import { relative as d, dirname as P } from "node:path";
3
- import { codeExtract as _, exportSheet as g, exportClassMap as x } from "@devup-ui/wasm";
4
- const w = function(l) {
1
+ import { writeFile as t } from "node:fs/promises";
2
+ import { relative as M, dirname as _, join as u, basename as y } from "node:path";
3
+ import { codeExtract as S, getCss as $, exportSheet as b, exportClassMap as k, exportFileMap as v } from "@devup-ui/wasm";
4
+ const A = function(h) {
5
5
  const {
6
- watch: n,
7
- package: p,
8
- cssFile: o,
9
- sheetFile: h,
10
- classMapFile: u
11
- } = this.getOptions(), e = this.async(), m = this.resourcePath;
6
+ watch: r,
7
+ package: f,
8
+ cssDir: i,
9
+ sheetFile: m,
10
+ classMapFile: d,
11
+ fileMapFile: g,
12
+ singleCss: F
13
+ } = this.getOptions(), a = this.async(), P = this.resourcePath;
12
14
  try {
13
- let t = d(P(this.resourcePath), o).replaceAll(
15
+ let e = M(_(this.resourcePath), i).replaceAll(
14
16
  "\\",
15
17
  "/"
16
18
  );
17
- t.startsWith("./") || (t = `./${t}`);
18
- const { code: s, css: f, map: c } = _(
19
- m,
20
- l.toString(),
21
- p,
22
- t
23
- ), a = c ? JSON.parse(c) : null;
24
- if (f && n) {
25
- const i = `${this.resourcePath} ${Date.now()}`;
26
- this._compiler && (this._compiler.__DEVUP_CACHE = i), Promise.all([
27
- r(o, `/* ${i} */`),
28
- r(h, g()),
29
- r(u, x())
30
- ]).catch(console.error).finally(() => e(null, s, a));
19
+ e.startsWith("./") || (e = `./${e}`);
20
+ const { code: o, css: l, map: c, cssFile: x, updatedBaseStyle: C } = S(
21
+ P,
22
+ h.toString(),
23
+ f,
24
+ e,
25
+ F,
26
+ !1,
27
+ !0
28
+ ), n = c ? JSON.parse(c) : null, s = [];
29
+ if (C && s.push(
30
+ t(u(i, "devup-ui.css"), $(null, !1), "utf-8")
31
+ ), l) {
32
+ const p = `${this.resourcePath} ${Date.now()}`;
33
+ r && this._compiler && (this._compiler.__DEVUP_CACHE = p), s.push(
34
+ t(
35
+ u(i, y(x)),
36
+ r ? `/* ${p} */` : l
37
+ )
38
+ ), r && s.push(
39
+ t(m, b()),
40
+ t(d, k()),
41
+ t(g, v())
42
+ ), Promise.all(s).catch(console.error).finally(() => a(null, o, n));
31
43
  return;
32
44
  }
33
- e(null, s, a);
34
- } catch (t) {
35
- e(t);
45
+ a(null, o, n);
46
+ } catch (e) {
47
+ a(e);
36
48
  }
37
49
  };
38
50
  export {
39
- w as default
51
+ A as default
40
52
  };
package/dist/plugin.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var y=(n,e,i)=>e in n?v(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var f=(n,e,i)=>y(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("node:fs"),g=require("node:module"),c=require("node:path"),o=require("@devup-ui/wasm");var p=typeof document<"u"?document.currentScript:null;class w{constructor({package:e="@devup-ui/react",devupPath:i="devup.json",interfacePath:a="df",cssFile:r=c.resolve(a,"devup-ui.css"),watch:s=!1,debug:u=!1,include:h=[]}={}){f(this,"options");this.options={package:e,cssFile:r,devupPath:i,interfacePath:a,watch:s,debug:u,include:h}}writeDataFiles(){var i;o.registerTheme((i=JSON.parse(t.readFileSync(this.options.devupPath,"utf-8")))==null?void 0:i.theme);const e=o.getThemeInterface(this.options.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");e&&t.writeFileSync(c.join(this.options.interfacePath,"theme.d.ts"),e,{encoding:"utf-8"}),this.options.watch&&t.writeFileSync(this.options.cssFile,`/* ${Date.now()} */`,{encoding:"utf-8"})}apply(e){o.setDebug(this.options.debug);const i=t.existsSync(this.options.devupPath);t.existsSync(this.options.interfacePath)||t.mkdirSync(this.options.interfacePath),t.writeFileSync(c.join(this.options.interfacePath,".gitignore"),"*",{encoding:"utf-8"});const a=c.join(this.options.interfacePath,"sheet.json"),r=c.join(this.options.interfacePath,"classMap.json");if(this.options.watch){try{t.existsSync(a)&&o.importSheet(JSON.parse(t.readFileSync(a,"utf-8"))),t.existsSync(r)&&o.importClassMap(JSON.parse(t.readFileSync(r,"utf-8")))}catch(u){console.error(u)}let s=null;e.hooks.watchRun.tapAsync("DevupUIWebpackPlugin",(u,h)=>{i&&t.stat(this.options.devupPath,(l,m)=>{if(l){console.error(`Error checking ${this.options.devupPath}:`,l);return}const d=m.mtimeMs;s&&s!==d&&this.writeDataFiles(),s=d}),h()})}if(i){try{this.writeDataFiles()}catch(s){console.error(s)}e.hooks.afterCompile.tap("DevupUIWebpackPlugin",s=>{s.fileDependencies.add(c.resolve(this.options.devupPath))})}t.existsSync(this.options.cssFile)||t.writeFileSync(this.options.cssFile,"",{encoding:"utf-8"}),e.options.plugins.push(new e.webpack.DefinePlugin({"process.env.DEVUP_UI_DEFAULT_THEME":JSON.stringify(o.getDefaultTheme())})),this.options.watch||e.hooks.done.tap("DevupUIWebpackPlugin",s=>{s.hasErrors()||t.writeFileSync(this.options.cssFile,o.getCss(),{encoding:"utf-8"})}),e.options.module.rules.push({test:/\.(tsx|ts|js|mjs|jsx)$/,exclude:new RegExp(this.options.include.length?`node_modules(?!.*(${this.options.include.join("|").replaceAll("/","[\\/\\\\]")})([\\/\\\\]|$))`:"node_modules"),enforce:"pre",use:[{loader:g.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:p&&p.tagName.toUpperCase()==="SCRIPT"&&p.src||new URL("plugin.cjs",document.baseURI).href).resolve("@devup-ui/webpack-plugin/loader"),options:{package:this.options.package,cssFile:this.options.cssFile,sheetFile:a,classMapFile:r,watch:this.options.watch}}]},{test:this.options.cssFile,enforce:"pre",use:[{loader:g.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:p&&p.tagName.toUpperCase()==="SCRIPT"&&p.src||new URL("plugin.cjs",document.baseURI).href).resolve("@devup-ui/webpack-plugin/css-loader"),options:{watch:this.options.watch}}]})}}exports.DevupUIWebpackPlugin=w;
1
+ "use strict";var F=Object.defineProperty;var g=(p,e,t)=>e in p?F(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t;var a=(p,e,t)=>g(p,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("node:fs"),u=require("node:fs/promises"),h=require("node:module"),n=require("node:path"),o=require("@devup-ui/wasm");var r=typeof document<"u"?document.currentScript:null;class v{constructor({package:e="@devup-ui/react",devupFile:t="devup.json",distDir:s="df",cssDir:c=n.resolve(s,"devup-ui"),watch:l=!1,debug:d=!1,include:f=[],singleCss:m=!1}={}){a(this,"options");a(this,"sheetFile");a(this,"classMapFile");a(this,"fileMapFile");this.options={package:e,cssDir:c,devupFile:t,distDir:s,watch:l,debug:d,include:f,singleCss:m},this.sheetFile=n.join(this.options.distDir,"sheet.json"),this.classMapFile=n.join(this.options.distDir,"classMap.json"),this.fileMapFile=n.join(this.options.distDir,"fileMap.json")}writeDataFiles(){var e;try{const t=i.existsSync(this.options.devupFile)?i.readFileSync(this.options.devupFile,"utf-8"):void 0;if(t){o.registerTheme(((e=JSON.parse(t))==null?void 0:e.theme)??{});const s=o.getThemeInterface(this.options.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");s&&i.writeFileSync(n.join(this.options.distDir,"theme.d.ts"),s,{encoding:"utf-8"})}else o.registerTheme({})}catch(t){console.error(t),o.registerTheme({})}i.existsSync(this.options.cssDir)||i.mkdirSync(this.options.cssDir,{recursive:!0}),this.options.watch&&i.writeFileSync(n.join(this.options.cssDir,"devup-ui.css"),o.getCss(null,!1))}apply(e){o.setDebug(this.options.debug);const t=i.existsSync(this.options.devupFile);if(i.existsSync(this.options.distDir)||i.mkdirSync(this.options.distDir,{recursive:!0}),i.writeFileSync(n.join(this.options.distDir,".gitignore"),"*","utf-8"),this.options.watch)try{i.existsSync(this.sheetFile)&&o.importSheet(JSON.parse(i.readFileSync(this.sheetFile,"utf-8"))),i.existsSync(this.classMapFile)&&o.importClassMap(JSON.parse(i.readFileSync(this.classMapFile,"utf-8"))),i.existsSync(this.fileMapFile)&&o.importFileMap(JSON.parse(i.readFileSync(this.fileMapFile,"utf-8")))}catch(s){console.error(s),o.importSheet({}),o.importClassMap({}),o.importFileMap({})}if(this.writeDataFiles(),this.options.watch){let s=null;e.hooks.watchRun.tapPromise("DevupUIWebpackPlugin",async()=>{if(t){const l=(await u.stat(this.options.devupFile)).mtimeMs;s&&s!==l&&this.writeDataFiles(),s=l}})}t&&e.hooks.afterCompile.tap("DevupUIWebpackPlugin",s=>{s.fileDependencies.add(n.resolve(this.options.devupFile))}),e.options.plugins.push(new e.webpack.DefinePlugin({"process.env.DEVUP_UI_DEFAULT_THEME":JSON.stringify(o.getDefaultTheme())})),this.options.watch||e.hooks.done.tapPromise("DevupUIWebpackPlugin",async s=>{s.hasErrors()||await u.writeFile(n.join(this.options.cssDir,"devup-ui.css"),o.getCss(null,!1),"utf-8")}),e.options.module.rules.push({test:/\.(tsx|ts|js|mjs|jsx)$/,exclude:new RegExp(`node_modules(?!.*(${["@devup-ui",...this.options.include].join("|").replaceAll("/","[\\/\\\\_]")})([\\/\\\\.]|$))`),enforce:"pre",use:[{loader:h.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:r&&r.tagName.toUpperCase()==="SCRIPT"&&r.src||new URL("plugin.cjs",document.baseURI).href).resolve("@devup-ui/webpack-plugin/loader"),options:{package:this.options.package,cssDir:this.options.cssDir,sheetFile:this.sheetFile,classMapFile:this.classMapFile,fileMapFile:this.fileMapFile,watch:this.options.watch,singleCss:this.options.singleCss}}]},{test:this.options.cssDir,enforce:"pre",use:[{loader:h.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:r&&r.tagName.toUpperCase()==="SCRIPT"&&r.src||new URL("plugin.cjs",document.baseURI).href).resolve("@devup-ui/webpack-plugin/css-loader"),options:{watch:this.options.watch}}]})}}exports.DevupUIWebpackPlugin=v;
package/dist/plugin.d.ts CHANGED
@@ -1,16 +1,20 @@
1
1
  import { Compiler } from 'webpack';
2
2
  export interface DevupUIWebpackPluginOptions {
3
3
  package: string;
4
- cssFile: string;
5
- devupPath: string;
6
- interfacePath: string;
4
+ cssDir: string;
5
+ devupFile: string;
6
+ distDir: string;
7
7
  watch: boolean;
8
8
  debug: boolean;
9
9
  include: string[];
10
+ singleCss: boolean;
10
11
  }
11
12
  export declare class DevupUIWebpackPlugin {
12
13
  options: DevupUIWebpackPluginOptions;
13
- constructor({ package: libPackage, devupPath, interfacePath, cssFile, watch, debug, include, }?: Partial<DevupUIWebpackPluginOptions>);
14
+ sheetFile: string;
15
+ classMapFile: string;
16
+ fileMapFile: string;
17
+ constructor({ package: libPackage, devupFile, distDir, cssDir, watch, debug, include, singleCss, }?: Partial<DevupUIWebpackPluginOptions>);
14
18
  writeDataFiles(): void;
15
19
  apply(compiler: Compiler): void;
16
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,EAAE,2BAA2B,CAAA;gBAExB,EACV,OAAO,EAAE,UAA8B,EACvC,SAAwB,EACxB,aAAoB,EACpB,OAAgD,EAChD,KAAa,EACb,KAAa,EACb,OAAY,GACb,GAAE,OAAO,CAAC,2BAA2B,CAAM;IAY5C,cAAc;IA4Bd,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAiHzB"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,EAAE,2BAA2B,CAAA;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;gBAEP,EACV,OAAO,EAAE,UAA8B,EACvC,SAAwB,EACxB,OAAc,EACd,MAAqC,EACrC,KAAa,EACb,KAAa,EACb,OAAY,EACZ,SAAiB,GAClB,GAAE,OAAO,CAAC,2BAA2B,CAAM;IAiB5C,cAAc;IAwCd,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAyGzB"}
package/dist/plugin.js CHANGED
@@ -1,124 +1,126 @@
1
- var w = Object.defineProperty;
2
- var D = (i, e, t) => e in i ? w(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var d = (i, e, t) => D(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { readFileSync as u, writeFileSync as p, existsSync as a, mkdirSync as k, stat as P } from "node:fs";
5
- import { createRequire as g } from "node:module";
6
- import { resolve as m, join as c } from "node:path";
7
- import { registerTheme as F, getThemeInterface as y, setDebug as T, importSheet as b, importClassMap as S, getDefaultTheme as j, getCss as x } from "@devup-ui/wasm";
8
- class C {
1
+ var k = Object.defineProperty;
2
+ var y = (p, s, e) => s in p ? k(p, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[s] = e;
3
+ var a = (p, s, e) => y(p, typeof s != "symbol" ? s + "" : s, e);
4
+ import { existsSync as t, readFileSync as l, writeFileSync as n, mkdirSync as u } from "node:fs";
5
+ import { stat as T, writeFile as S } from "node:fs/promises";
6
+ import { createRequire as f } from "node:module";
7
+ import { resolve as d, join as o } from "node:path";
8
+ import { registerTheme as h, getThemeInterface as b, getCss as m, setDebug as j, importSheet as F, importClassMap as D, importFileMap as v, getDefaultTheme as P } from "@devup-ui/wasm";
9
+ class N {
9
10
  constructor({
10
- package: e = "@devup-ui/react",
11
- devupPath: t = "devup.json",
12
- interfacePath: o = "df",
13
- cssFile: n = m(o, "devup-ui.css"),
14
- watch: s = !1,
15
- debug: r = !1,
16
- include: h = []
11
+ package: s = "@devup-ui/react",
12
+ devupFile: e = "devup.json",
13
+ distDir: i = "df",
14
+ cssDir: c = d(i, "devup-ui"),
15
+ watch: r = !1,
16
+ debug: g = !1,
17
+ include: w = [],
18
+ singleCss: M = !1
17
19
  } = {}) {
18
- d(this, "options");
20
+ a(this, "options");
21
+ a(this, "sheetFile");
22
+ a(this, "classMapFile");
23
+ a(this, "fileMapFile");
19
24
  this.options = {
20
- package: e,
21
- cssFile: n,
22
- devupPath: t,
23
- interfacePath: o,
24
- watch: s,
25
- debug: r,
26
- include: h
27
- };
25
+ package: s,
26
+ cssDir: c,
27
+ devupFile: e,
28
+ distDir: i,
29
+ watch: r,
30
+ debug: g,
31
+ include: w,
32
+ singleCss: M
33
+ }, this.sheetFile = o(this.options.distDir, "sheet.json"), this.classMapFile = o(this.options.distDir, "classMap.json"), this.fileMapFile = o(this.options.distDir, "fileMap.json");
28
34
  }
29
35
  writeDataFiles() {
30
- var t;
31
- F(
32
- (t = JSON.parse(u(this.options.devupPath, "utf-8"))) == null ? void 0 : t.theme
33
- );
34
- const e = y(
35
- this.options.package,
36
- "DevupThemeColors",
37
- "DevupThemeTypography",
38
- "DevupTheme"
36
+ var s;
37
+ try {
38
+ const e = t(this.options.devupFile) ? l(this.options.devupFile, "utf-8") : void 0;
39
+ if (e) {
40
+ h(((s = JSON.parse(e)) == null ? void 0 : s.theme) ?? {});
41
+ const i = b(
42
+ this.options.package,
43
+ "DevupThemeColors",
44
+ "DevupThemeTypography",
45
+ "DevupTheme"
46
+ );
47
+ i && n(
48
+ o(this.options.distDir, "theme.d.ts"),
49
+ i,
50
+ {
51
+ encoding: "utf-8"
52
+ }
53
+ );
54
+ } else
55
+ h({});
56
+ } catch (e) {
57
+ console.error(e), h({});
58
+ }
59
+ t(this.options.cssDir) || u(this.options.cssDir, { recursive: !0 }), this.options.watch && n(
60
+ o(this.options.cssDir, "devup-ui.css"),
61
+ m(null, !1)
39
62
  );
40
- e && p(
41
- c(this.options.interfacePath, "theme.d.ts"),
42
- e,
43
- {
44
- encoding: "utf-8"
45
- }
46
- ), this.options.watch && p(this.options.cssFile, `/* ${Date.now()} */`, {
47
- encoding: "utf-8"
48
- });
49
63
  }
50
- apply(e) {
51
- T(this.options.debug);
52
- const t = a(this.options.devupPath);
53
- a(this.options.interfacePath) || k(this.options.interfacePath), p(c(this.options.interfacePath, ".gitignore"), "*", {
54
- encoding: "utf-8"
55
- });
56
- const o = c(this.options.interfacePath, "sheet.json"), n = c(this.options.interfacePath, "classMap.json");
57
- if (this.options.watch) {
64
+ apply(s) {
65
+ j(this.options.debug);
66
+ const e = t(this.options.devupFile);
67
+ if (t(this.options.distDir) || u(this.options.distDir, { recursive: !0 }), n(o(this.options.distDir, ".gitignore"), "*", "utf-8"), this.options.watch)
58
68
  try {
59
- a(o) && b(JSON.parse(u(o, "utf-8"))), a(n) && S(JSON.parse(u(n, "utf-8")));
60
- } catch (r) {
61
- console.error(r);
69
+ t(this.sheetFile) && F(JSON.parse(l(this.sheetFile, "utf-8"))), t(this.classMapFile) && D(JSON.parse(l(this.classMapFile, "utf-8"))), t(this.fileMapFile) && v(JSON.parse(l(this.fileMapFile, "utf-8")));
70
+ } catch (i) {
71
+ console.error(i), F({}), D({}), v({});
62
72
  }
63
- let s = null;
64
- e.hooks.watchRun.tapAsync(
65
- "DevupUIWebpackPlugin",
66
- (r, h) => {
67
- t && P(this.options.devupPath, (l, v) => {
68
- if (l) {
69
- console.error(`Error checking ${this.options.devupPath}:`, l);
70
- return;
71
- }
72
- const f = v.mtimeMs;
73
- s && s !== f && this.writeDataFiles(), s = f;
74
- }), h();
73
+ if (this.writeDataFiles(), this.options.watch) {
74
+ let i = null;
75
+ s.hooks.watchRun.tapPromise("DevupUIWebpackPlugin", async () => {
76
+ if (e) {
77
+ const r = (await T(this.options.devupFile)).mtimeMs;
78
+ i && i !== r && this.writeDataFiles(), i = r;
75
79
  }
76
- );
77
- }
78
- if (t) {
79
- try {
80
- this.writeDataFiles();
81
- } catch (s) {
82
- console.error(s);
83
- }
84
- e.hooks.afterCompile.tap("DevupUIWebpackPlugin", (s) => {
85
- s.fileDependencies.add(m(this.options.devupPath));
86
80
  });
87
81
  }
88
- a(this.options.cssFile) || p(this.options.cssFile, "", { encoding: "utf-8" }), e.options.plugins.push(
89
- new e.webpack.DefinePlugin({
90
- "process.env.DEVUP_UI_DEFAULT_THEME": JSON.stringify(j())
82
+ e && s.hooks.afterCompile.tap("DevupUIWebpackPlugin", (i) => {
83
+ i.fileDependencies.add(d(this.options.devupFile));
84
+ }), s.options.plugins.push(
85
+ new s.webpack.DefinePlugin({
86
+ "process.env.DEVUP_UI_DEFAULT_THEME": JSON.stringify(P())
91
87
  })
92
- ), this.options.watch || e.hooks.done.tap("DevupUIWebpackPlugin", (s) => {
93
- s.hasErrors() || p(this.options.cssFile, x(), { encoding: "utf-8" });
94
- }), e.options.module.rules.push(
88
+ ), this.options.watch || s.hooks.done.tapPromise("DevupUIWebpackPlugin", async (i) => {
89
+ i.hasErrors() || await S(
90
+ o(this.options.cssDir, "devup-ui.css"),
91
+ m(null, !1),
92
+ "utf-8"
93
+ );
94
+ }), s.options.module.rules.push(
95
95
  {
96
96
  test: /\.(tsx|ts|js|mjs|jsx)$/,
97
97
  exclude: new RegExp(
98
- this.options.include.length ? `node_modules(?!.*(${this.options.include.join("|").replaceAll("/", "[\\/\\\\]")})([\\/\\\\]|$))` : "node_modules"
98
+ `node_modules(?!.*(${["@devup-ui", ...this.options.include].join("|").replaceAll("/", "[\\/\\\\_]")})([\\/\\\\.]|$))`
99
99
  ),
100
100
  enforce: "pre",
101
101
  use: [
102
102
  {
103
- loader: g(import.meta.url).resolve(
103
+ loader: f(import.meta.url).resolve(
104
104
  "@devup-ui/webpack-plugin/loader"
105
105
  ),
106
106
  options: {
107
107
  package: this.options.package,
108
- cssFile: this.options.cssFile,
109
- sheetFile: o,
110
- classMapFile: n,
111
- watch: this.options.watch
108
+ cssDir: this.options.cssDir,
109
+ sheetFile: this.sheetFile,
110
+ classMapFile: this.classMapFile,
111
+ fileMapFile: this.fileMapFile,
112
+ watch: this.options.watch,
113
+ singleCss: this.options.singleCss
112
114
  }
113
115
  }
114
116
  ]
115
117
  },
116
118
  {
117
- test: this.options.cssFile,
119
+ test: this.options.cssDir,
118
120
  enforce: "pre",
119
121
  use: [
120
122
  {
121
- loader: g(import.meta.url).resolve(
123
+ loader: f(import.meta.url).resolve(
122
124
  "@devup-ui/webpack-plugin/css-loader"
123
125
  ),
124
126
  options: {
@@ -131,5 +133,5 @@ class C {
131
133
  }
132
134
  }
133
135
  export {
134
- C as DevupUIWebpackPlugin
136
+ N as DevupUIWebpackPlugin
135
137
  };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "webpack"
19
19
  ],
20
20
  "type": "module",
21
- "version": "1.0.32",
21
+ "version": "1.0.34",
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
@@ -45,13 +45,13 @@
45
45
  "dist"
46
46
  ],
47
47
  "dependencies": {
48
- "@devup-ui/wasm": "1.0.32"
48
+ "@devup-ui/wasm": "1.0.34"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@devup-ui/wasm": "*"
52
52
  },
53
53
  "devDependencies": {
54
- "vite": "^7.1.3",
54
+ "vite": "^7.1.4",
55
55
  "@types/webpack": "^5.28.5",
56
56
  "vite-plugin-dts": "^4.5.4",
57
57
  "vitest": "^3.2.4",