@devup-ui/webpack-plugin 1.0.31 → 1.0.33

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 u;const{watch:o}=this.getOptions(),i=a(this.resourcePath);if(!o)return this.callback(null,r.getCss(i));const l=((u=this._compiler)==null?void 0:u.__DEVUP_CACHE)||t.toString();if(c===l){this.callback(null,n,e,s);return}c=l,this.callback(null,n=r.getCss(i),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 r } from "@devup-ui/wasm";
2
+ let u = "", 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 n;
8
+ const { watch: o } = this.getOptions(), s = a(this.resourcePath);
9
+ if (!o) return this.callback(null, r(s));
10
+ const l = ((n = this._compiler) == null ? void 0 : n.__DEVUP_CACHE) || t.toString();
11
+ if (c === l) {
12
+ this.callback(null, u, e, i);
10
13
  return;
11
14
  }
12
- c = s, this.callback(null, r = i(), t, l);
15
+ c = l, this.callback(null, u = r(s), 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 r=require("node:fs/promises"),s=require("node:path"),i=require("@devup-ui/wasm"),M=function(h){const{watch:t,package:d,cssDir:o,sheetFile:f,classMapFile:m,fileMapFile:_,singleCss:F}=this.getOptions(),l=this.async(),g=this.resourcePath;try{let e=s.relative(s.dirname(this.resourcePath),o).replaceAll("\\","/");e.startsWith("./")||(e=`./${e}`);const{code:a,css:c,map:n,css_file:w}=i.codeExtract(g,h.toString(),d,e,F),u=n?JSON.parse(n):null;if(c){const p=`${this.resourcePath} ${Date.now()}`;t&&this._compiler&&(this._compiler.__DEVUP_CACHE=p),Promise.all([r.writeFile(s.join(o,s.basename(w)),t?`/* ${p} */`:c),t?r.writeFile(f,i.exportSheet()):null,t?r.writeFile(m,i.exportClassMap()):null,t?r.writeFile(_,i.exportFileMap()):null]).catch(console.error).finally(()=>l(null,a,u));return}l(null,a,u)}catch(e){l(e)}};exports.default=M;
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":"AASA,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,CAoDlE,CAAA;AACH,eAAe,aAAa,CAAA"}
package/dist/loader.js CHANGED
@@ -1,40 +1,47 @@
1
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) {
2
+ import { relative as g, dirname as x, join as F, basename as M } from "node:path";
3
+ import { codeExtract as C, exportSheet as $, exportClassMap as b, exportFileMap as k } from "@devup-ui/wasm";
4
+ const E = function(p) {
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: t,
7
+ package: h,
8
+ cssDir: l,
9
+ sheetFile: u,
10
+ classMapFile: m,
11
+ fileMapFile: f,
12
+ singleCss: d
13
+ } = this.getOptions(), s = this.async(), P = this.resourcePath;
12
14
  try {
13
- let t = d(P(this.resourcePath), o).replaceAll(
15
+ let e = g(x(this.resourcePath), l).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: i, map: a, css_file: _ } = C(
21
+ P,
22
+ p.toString(),
23
+ h,
24
+ e,
25
+ d
26
+ ), c = a ? JSON.parse(a) : null;
27
+ if (i) {
28
+ const n = `${this.resourcePath} ${Date.now()}`;
29
+ t && this._compiler && (this._compiler.__DEVUP_CACHE = n), Promise.all([
30
+ r(
31
+ F(l, M(_)),
32
+ t ? `/* ${n} */` : i
33
+ ),
34
+ t ? r(u, $()) : null,
35
+ t ? r(m, b()) : null,
36
+ t ? r(f, k()) : null
37
+ ]).catch(console.error).finally(() => s(null, o, c));
31
38
  return;
32
39
  }
33
- e(null, s, a);
34
- } catch (t) {
35
- e(t);
40
+ s(null, o, c);
41
+ } catch (e) {
42
+ s(e);
36
43
  }
37
44
  };
38
45
  export {
39
- w as default
46
+ E as default
40
47
  };
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,s)=>e in p?F(p,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):p[e]=s;var c=(p,e,s)=>g(p,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("node:fs"),o=require("node:fs/promises"),d=require("node:module"),a=require("node:path"),t=require("@devup-ui/wasm");var l=typeof document<"u"?document.currentScript:null;class v{constructor({package:e="@devup-ui/react",devupFile:s="devup.json",distDir:r="df",cssDir:i=a.resolve(r,"devup-ui"),watch:h=!1,debug:u=!1,include:f=[],singleCss:m=!1}={}){c(this,"options");c(this,"sheetFile");c(this,"classMapFile");c(this,"fileMapFile");this.options={package:e,cssDir:i,devupFile:s,distDir:r,watch:h,debug:u,include:f,singleCss:m},this.sheetFile=a.join(this.options.distDir,"sheet.json"),this.classMapFile=a.join(this.options.distDir,"classMap.json"),this.fileMapFile=a.join(this.options.distDir,"fileMap.json")}async writeDataFiles(){var e;try{const s=n.existsSync(this.options.devupFile)?await o.readFile(this.options.devupFile,"utf-8"):void 0;if(s){t.registerTheme(((e=JSON.parse(s))==null?void 0:e.theme)??{});const r=t.getThemeInterface(this.options.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");r&&await o.writeFile(a.join(this.options.distDir,"theme.d.ts"),r,{encoding:"utf-8"})}else t.registerTheme({})}catch(s){console.error(s),t.registerTheme({})}await Promise.all([n.existsSync(this.options.cssDir)?Promise.resolve():o.mkdir(this.options.cssDir,{recursive:!0}),this.options.watch?o.writeFile(a.join(this.options.cssDir,"devup-ui.css"),t.getCss()):Promise.resolve()])}apply(e){t.setDebug(this.options.debug);let s=!1;const r=n.existsSync(this.options.devupFile);if(e.hooks[this.options.watch?"watchRun":"beforeRun"].tapPromise("DevupUIWebpackPlugin",async()=>{if(!s){if(s=!0,n.existsSync(this.options.distDir)||await o.mkdir(this.options.distDir,{recursive:!0}),await o.writeFile(a.join(this.options.distDir,".gitignore"),"*","utf-8"),this.options.watch)try{await Promise.all([n.existsSync(this.sheetFile)?o.readFile(this.sheetFile,"utf-8").then(i=>t.importSheet(JSON.parse(i))):Promise.resolve(),n.existsSync(this.classMapFile)?o.readFile(this.classMapFile,"utf-8").then(i=>t.importClassMap(JSON.parse(i))):Promise.resolve(),n.existsSync(this.fileMapFile)?o.readFile(this.fileMapFile,"utf-8").then(i=>t.importFileMap(JSON.parse(i))):Promise.resolve()])}catch(i){console.error(i),t.importSheet({}),t.importClassMap({}),t.importFileMap({})}await this.writeDataFiles()}}),this.options.watch){let i=null;e.hooks.watchRun.tapPromise("DevupUIWebpackPlugin",async()=>{if(r){const u=(await o.stat(this.options.devupFile)).mtimeMs;i&&i!==u&&await this.writeDataFiles(),i=u}})}r&&e.hooks.afterCompile.tap("DevupUIWebpackPlugin",i=>{i.fileDependencies.add(a.resolve(this.options.devupFile))}),e.options.plugins.push(new e.webpack.DefinePlugin({"process.env.DEVUP_UI_DEFAULT_THEME":JSON.stringify(t.getDefaultTheme())})),this.options.watch||e.hooks.done.tapPromise("DevupUIWebpackPlugin",async i=>{i.hasErrors()||await o.writeFile(a.join(this.options.cssDir,"devup-ui.css"),t.getCss(),"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:d.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:l&&l.tagName.toUpperCase()==="SCRIPT"&&l.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:d.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:l&&l.tagName.toUpperCase()==="SCRIPT"&&l.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,17 +1,21 @@
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
- writeDataFiles(): void;
14
+ sheetFile: string;
15
+ classMapFile: string;
16
+ fileMapFile: string;
17
+ constructor({ package: libPackage, devupFile, distDir, cssDir, watch, debug, include, singleCss, }?: Partial<DevupUIWebpackPluginOptions>);
18
+ writeDataFiles(): Promise<void>;
15
19
  apply(compiler: Compiler): void;
16
20
  }
17
21
  //# sourceMappingURL=plugin.d.ts.map
@@ -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;IAiBtC,cAAc;IA0CpB,KAAK,CAAC,QAAQ,EAAE,QAAQ;CA4HzB"}
package/dist/plugin.js CHANGED
@@ -1,124 +1,144 @@
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 P = (p, e, i) => e in p ? k(p, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : p[e] = i;
3
+ var r = (p, e, i) => P(p, typeof e != "symbol" ? e + "" : e, i);
4
+ import { existsSync as o } from "node:fs";
5
+ import { readFile as n, writeFile as h, mkdir as f, stat as b } from "node:fs/promises";
6
+ import { createRequire as d } from "node:module";
7
+ import { resolve as m, join as a } from "node:path";
8
+ import { registerTheme as u, getThemeInterface as y, getCss as v, setDebug as T, importSheet as D, importClassMap as w, importFileMap as F, getDefaultTheme as j } from "@devup-ui/wasm";
9
+ class J {
9
10
  constructor({
10
11
  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 = []
12
+ devupFile: i = "devup.json",
13
+ distDir: t = "df",
14
+ cssDir: s = m(t, "devup-ui"),
15
+ watch: c = !1,
16
+ debug: l = !1,
17
+ include: g = [],
18
+ singleCss: M = !1
17
19
  } = {}) {
18
- d(this, "options");
20
+ r(this, "options");
21
+ r(this, "sheetFile");
22
+ r(this, "classMapFile");
23
+ r(this, "fileMapFile");
19
24
  this.options = {
20
25
  package: e,
21
- cssFile: n,
22
- devupPath: t,
23
- interfacePath: o,
24
- watch: s,
25
- debug: r,
26
- include: h
27
- };
26
+ cssDir: s,
27
+ devupFile: i,
28
+ distDir: t,
29
+ watch: c,
30
+ debug: l,
31
+ include: g,
32
+ singleCss: M
33
+ }, this.sheetFile = a(this.options.distDir, "sheet.json"), this.classMapFile = a(this.options.distDir, "classMap.json"), this.fileMapFile = a(this.options.distDir, "fileMap.json");
28
34
  }
29
- 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"
39
- );
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
- });
35
+ async writeDataFiles() {
36
+ var e;
37
+ try {
38
+ const i = o(this.options.devupFile) ? await n(this.options.devupFile, "utf-8") : void 0;
39
+ if (i) {
40
+ u(((e = JSON.parse(i)) == null ? void 0 : e.theme) ?? {});
41
+ const t = y(
42
+ this.options.package,
43
+ "DevupThemeColors",
44
+ "DevupThemeTypography",
45
+ "DevupTheme"
46
+ );
47
+ t && await h(
48
+ a(this.options.distDir, "theme.d.ts"),
49
+ t,
50
+ {
51
+ encoding: "utf-8"
52
+ }
53
+ );
54
+ } else
55
+ u({});
56
+ } catch (i) {
57
+ console.error(i), u({});
58
+ }
59
+ await Promise.all([
60
+ o(this.options.cssDir) ? Promise.resolve() : f(this.options.cssDir, { recursive: !0 }),
61
+ this.options.watch ? h(a(this.options.cssDir, "devup-ui.css"), v()) : Promise.resolve()
62
+ ]);
49
63
  }
50
64
  apply(e) {
51
65
  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) {
58
- 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);
62
- }
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;
66
+ let i = !1;
67
+ const t = o(this.options.devupFile);
68
+ if (e.hooks[this.options.watch ? "watchRun" : "beforeRun"].tapPromise(
69
+ "DevupUIWebpackPlugin",
70
+ async () => {
71
+ if (!i) {
72
+ if (i = !0, o(this.options.distDir) || await f(this.options.distDir, { recursive: !0 }), await h(a(this.options.distDir, ".gitignore"), "*", "utf-8"), this.options.watch)
73
+ try {
74
+ await Promise.all([
75
+ o(this.sheetFile) ? n(this.sheetFile, "utf-8").then(
76
+ (s) => D(JSON.parse(s))
77
+ ) : Promise.resolve(),
78
+ o(this.classMapFile) ? n(this.classMapFile, "utf-8").then(
79
+ (s) => w(JSON.parse(s))
80
+ ) : Promise.resolve(),
81
+ o(this.fileMapFile) ? n(this.fileMapFile, "utf-8").then(
82
+ (s) => F(JSON.parse(s))
83
+ ) : Promise.resolve()
84
+ ]);
85
+ } catch (s) {
86
+ console.error(s), D({}), w({}), F({});
71
87
  }
72
- const f = v.mtimeMs;
73
- s && s !== f && this.writeDataFiles(), s = f;
74
- }), h();
88
+ await this.writeDataFiles();
75
89
  }
76
- );
77
- }
78
- if (t) {
79
- try {
80
- this.writeDataFiles();
81
- } catch (s) {
82
- console.error(s);
83
90
  }
84
- e.hooks.afterCompile.tap("DevupUIWebpackPlugin", (s) => {
85
- s.fileDependencies.add(m(this.options.devupPath));
91
+ ), this.options.watch) {
92
+ let s = null;
93
+ e.hooks.watchRun.tapPromise("DevupUIWebpackPlugin", async () => {
94
+ if (t) {
95
+ const l = (await b(this.options.devupFile)).mtimeMs;
96
+ s && s !== l && await this.writeDataFiles(), s = l;
97
+ }
86
98
  });
87
99
  }
88
- a(this.options.cssFile) || p(this.options.cssFile, "", { encoding: "utf-8" }), e.options.plugins.push(
100
+ t && e.hooks.afterCompile.tap("DevupUIWebpackPlugin", (s) => {
101
+ s.fileDependencies.add(m(this.options.devupFile));
102
+ }), e.options.plugins.push(
89
103
  new e.webpack.DefinePlugin({
90
104
  "process.env.DEVUP_UI_DEFAULT_THEME": JSON.stringify(j())
91
105
  })
92
- ), this.options.watch || e.hooks.done.tap("DevupUIWebpackPlugin", (s) => {
93
- s.hasErrors() || p(this.options.cssFile, x(), { encoding: "utf-8" });
106
+ ), this.options.watch || e.hooks.done.tapPromise("DevupUIWebpackPlugin", async (s) => {
107
+ s.hasErrors() || await h(
108
+ a(this.options.cssDir, "devup-ui.css"),
109
+ v(),
110
+ "utf-8"
111
+ );
94
112
  }), e.options.module.rules.push(
95
113
  {
96
114
  test: /\.(tsx|ts|js|mjs|jsx)$/,
97
115
  exclude: new RegExp(
98
- this.options.include.length ? `node_modules(?!.*(${this.options.include.join("|").replaceAll("/", "[\\/\\\\]")})([\\/\\\\]|$))` : "node_modules"
116
+ `node_modules(?!.*(${["@devup-ui", ...this.options.include].join("|").replaceAll("/", "[\\/\\\\_]")})([\\/\\\\.]|$))`
99
117
  ),
100
118
  enforce: "pre",
101
119
  use: [
102
120
  {
103
- loader: g(import.meta.url).resolve(
121
+ loader: d(import.meta.url).resolve(
104
122
  "@devup-ui/webpack-plugin/loader"
105
123
  ),
106
124
  options: {
107
125
  package: this.options.package,
108
- cssFile: this.options.cssFile,
109
- sheetFile: o,
110
- classMapFile: n,
111
- watch: this.options.watch
126
+ cssDir: this.options.cssDir,
127
+ sheetFile: this.sheetFile,
128
+ classMapFile: this.classMapFile,
129
+ fileMapFile: this.fileMapFile,
130
+ watch: this.options.watch,
131
+ singleCss: this.options.singleCss
112
132
  }
113
133
  }
114
134
  ]
115
135
  },
116
136
  {
117
- test: this.options.cssFile,
137
+ test: this.options.cssDir,
118
138
  enforce: "pre",
119
139
  use: [
120
140
  {
121
- loader: g(import.meta.url).resolve(
141
+ loader: d(import.meta.url).resolve(
122
142
  "@devup-ui/webpack-plugin/css-loader"
123
143
  ),
124
144
  options: {
@@ -131,5 +151,5 @@ class C {
131
151
  }
132
152
  }
133
153
  export {
134
- C as DevupUIWebpackPlugin
154
+ J as DevupUIWebpackPlugin
135
155
  };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "webpack"
19
19
  ],
20
20
  "type": "module",
21
- "version": "1.0.31",
21
+ "version": "1.0.33",
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
@@ -45,7 +45,7 @@
45
45
  "dist"
46
46
  ],
47
47
  "dependencies": {
48
- "@devup-ui/wasm": "1.0.31"
48
+ "@devup-ui/wasm": "1.0.33"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@devup-ui/wasm": "*"