@devup-ui/webpack-plugin 0.1.2 → 0.1.4

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/dist/loader.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("node:fs"),u=require("@devup-ui/wasm"),a=function(c){const{package:i,cssFile:n}=this.getOptions(),e=this.async(),t=this.resourcePath;if(t.includes("node_modules/")||t.includes("@devup-ui/react")||!/\.[tj](s|sx)?$/.test(t)){e(null,c);return}try{const{code:s,css:r}=u.codeExtract(this.resourcePath,c.toString(),i,n);r&&o.writeFileSync(n,r,{encoding:"utf-8"}),e(null,s)}catch(s){e(s)}};exports.default=a;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("node:fs"),a=require("@devup-ui/wasm"),l=function(c){const{plugin:n}=this.getOptions(),{package:r,cssFile:o}=n.options,e=this.async(),t=this.resourcePath;if(t.includes("node_modules/")||t.includes("@devup-ui/react")||!/\.[tj](s|sx)?$/.test(t)){e(null,c);return}try{const{code:s,css:i}=a.codeExtract(this.resourcePath,c.toString(),r,o+(n.watch?"?"+Date.now():""));i&&u.writeFileSync(o,i,{encoding:"utf-8"}),e(null,s)}catch(s){e(s)}};exports.default=l;
package/dist/loader.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RawLoaderDefinitionFunction } from 'webpack';
2
+ import { DevupUIWebpackPlugin } from './plugin';
2
3
  export interface DevupUILoaderOptions {
3
- package: string;
4
- cssFile: string;
4
+ plugin: DevupUIWebpackPlugin;
5
5
  }
6
6
  declare const devupUILoader: RawLoaderDefinitionFunction<DevupUILoaderOptions>;
7
7
  export default devupUILoader;
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAE1D,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,QAAA,MAAM,aAAa,EAAE,2BAA2B,CAAC,oBAAoB,CAgClE,CAAA;AACH,eAAe,aAAa,CAAA"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAE1D,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,oBAAoB,CAAA;CAC7B;AAED,QAAA,MAAM,aAAa,EAAE,2BAA2B,CAAC,oBAAoB,CAiClE,CAAA;AACH,eAAe,aAAa,CAAA"}
package/dist/loader.js CHANGED
@@ -1,19 +1,19 @@
1
- import { writeFileSync as n } from "node:fs";
2
- import { codeExtract as a } from "@devup-ui/wasm";
3
- const d = function(s) {
4
- const { package: i, cssFile: o } = this.getOptions(), t = this.async(), e = this.resourcePath;
1
+ import { writeFileSync as a } from "node:fs";
2
+ import { codeExtract as u } from "@devup-ui/wasm";
3
+ const p = function(o) {
4
+ const { plugin: s } = this.getOptions(), { package: r, cssFile: n } = s.options, t = this.async(), e = this.resourcePath;
5
5
  if (e.includes("node_modules/") || e.includes("@devup-ui/react") || !/\.[tj](s|sx)?$/.test(e)) {
6
- t(null, s);
6
+ t(null, o);
7
7
  return;
8
8
  }
9
9
  try {
10
- const { code: c, css: r } = a(
10
+ const { code: c, css: i } = u(
11
11
  this.resourcePath,
12
- s.toString(),
13
- i,
14
- o
12
+ o.toString(),
13
+ r,
14
+ n + (s.watch ? "?" + Date.now() : "")
15
15
  );
16
- r && n(o, r, {
16
+ i && a(n, i, {
17
17
  encoding: "utf-8"
18
18
  }), t(null, c);
19
19
  } catch (c) {
@@ -21,5 +21,5 @@ const d = function(s) {
21
21
  }
22
22
  };
23
23
  export {
24
- d as default
24
+ p as default
25
25
  };
package/dist/plugin.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var f=(s,e,t)=>e in s?l(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var d=(s,e,t)=>f(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("node:fs"),m=require("node:module"),c=require("node:path"),g=require("node:url"),a=require("@devup-ui/wasm");var n=typeof document<"u"?document.currentScript:null;const v=g.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:n&&n.tagName.toUpperCase()==="SCRIPT"&&n.src||new URL("plugin.cjs",document.baseURI).href),y=c.dirname(v);class P{constructor({package:e="@devup-ui/react",cssFile:t=c.join(y,"devup-ui.css"),devupPath:o="devup.json",interfacePath:r=".df"}){d(this,"options");this.options={package:e,cssFile:t,devupPath:o,interfacePath:r}}writeDataFiles(){var t;a.registerTheme((t=JSON.parse(i.readFileSync(this.options.devupPath,"utf-8")))==null?void 0:t.theme);const e=a.getThemeInterface(this.options.package,"DevupThemeColors","DevupThemeTypography");e&&(i.existsSync(this.options.interfacePath)||i.mkdirSync(this.options.interfacePath),i.writeFileSync(c.join(this.options.interfacePath,"theme.d.ts"),e,{encoding:"utf-8"})),i.writeFileSync(this.options.cssFile,a.getCss(),{encoding:"utf-8"})}apply(e){if(i.existsSync(this.options.devupPath)){try{this.writeDataFiles()}catch(o){console.error(o)}let t=null;e.hooks.afterCompile.tap("DevupUIWebpackPlugin",o=>{o.fileDependencies.add(this.options.devupPath)}),e.hooks.watchRun.tapAsync("DevupUIWebpackPlugin",(o,r)=>{i.stat(this.options.devupPath,(p,h)=>{if(p)return console.error(`Error checking ${this.options.devupPath}:`,p),r();const u=h.mtimeMs;t&&t!==u&&this.writeDataFiles(),t=u,r()})})}i.existsSync(this.options.cssFile)||i.writeFileSync(this.options.cssFile,"",{encoding:"utf-8"}),e.options.module.rules.push({test:/\.(tsx|ts|js|mjs|jsx)$/,exclude:/node_modules/,use:[{loader:m.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:n&&n.tagName.toUpperCase()==="SCRIPT"&&n.src||new URL("plugin.cjs",document.baseURI).href).resolve("@devup-ui/webpack-plugin/loader"),options:{package:this.options.package,cssFile:this.options.cssFile}}]})}}exports.DevupUIWebpackPlugin=P;
1
+ "use strict";var f=Object.defineProperty;var m=(s,e,t)=>e in s?f(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var a=(s,e,t)=>m(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("node:fs"),g=require("node:module"),c=require("node:path"),v=require("node:url"),u=require("@devup-ui/wasm");var n=typeof document<"u"?document.currentScript:null;const y=v.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:n&&n.tagName.toUpperCase()==="SCRIPT"&&n.src||new URL("plugin.cjs",document.baseURI).href),P=c.dirname(y);class S{constructor({package:e="@devup-ui/react",cssFile:t=c.join(P,"devup-ui.css"),devupPath:r="devup.json",interfacePath:o=".df"}){a(this,"options");a(this,"watch",!1);this.options={package:e,cssFile:t,devupPath:r,interfacePath:o}}writeDataFiles(){var t;u.registerTheme((t=JSON.parse(i.readFileSync(this.options.devupPath,"utf-8")))==null?void 0:t.theme);const e=u.getThemeInterface(this.options.package,"DevupThemeColors","DevupThemeTypography");e&&(i.existsSync(this.options.interfacePath)||i.mkdirSync(this.options.interfacePath),i.writeFileSync(c.join(this.options.interfacePath,"theme.d.ts"),e,{encoding:"utf-8"})),i.writeFileSync(this.options.cssFile,u.getCss(),{encoding:"utf-8"})}apply(e){const t=i.existsSync(this.options.devupPath);if(t){try{this.writeDataFiles()}catch(o){console.error(o)}e.hooks.afterCompile.tap("DevupUIWebpackPlugin",o=>{o.fileDependencies.add(this.options.devupPath)})}let r=null;e.hooks.watchRun.tapAsync("DevupUIWebpackPlugin",(o,p)=>{this.watch=!0,t&&i.stat(this.options.devupPath,(d,l)=>{if(d)return console.error(`Error checking ${this.options.devupPath}:`,d),p();const h=l.mtimeMs;r&&r!==h&&this.writeDataFiles(),r=h,p()})}),i.existsSync(this.options.cssFile)||i.writeFileSync(this.options.cssFile,"",{encoding:"utf-8"}),e.options.module.rules.push({test:/\.(tsx|ts|js|mjs|jsx)$/,exclude:/node_modules/,use:[{loader:g.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:n&&n.tagName.toUpperCase()==="SCRIPT"&&n.src||new URL("plugin.cjs",document.baseURI).href).resolve("@devup-ui/webpack-plugin/loader"),options:{plugin:this}}]})}}exports.DevupUIWebpackPlugin=S;
package/dist/plugin.d.ts CHANGED
@@ -7,6 +7,7 @@ export interface DevupUIWebpackPluginOptions {
7
7
  }
8
8
  export declare class DevupUIWebpackPlugin {
9
9
  options: DevupUIWebpackPluginOptions;
10
+ watch: boolean;
10
11
  constructor({ package: libPackage, cssFile, devupPath, interfacePath, }: Partial<DevupUIWebpackPluginOptions>);
11
12
  writeDataFiles(): void;
12
13
  apply(compiler: Compiler): void;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AAKvC,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,EAAE,2BAA2B,CAAA;gBAExB,EACV,OAAO,EAAE,UAA8B,EACvC,OAAwC,EACxC,SAAwB,EACxB,aAAqB,GACtB,EAAE,OAAO,CAAC,2BAA2B,CAAC;IASvC,cAAc;IAyBd,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAsDzB"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AAKvC,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,EAAE,2BAA2B,CAAA;IACpC,KAAK,UAAQ;gBAED,EACV,OAAO,EAAE,UAA8B,EACvC,OAAwC,EACxC,SAAwB,EACxB,aAAqB,GACtB,EAAE,OAAO,CAAC,2BAA2B,CAAC;IASvC,cAAc;IAyBd,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAqDzB"}
package/dist/plugin.js CHANGED
@@ -1,80 +1,78 @@
1
- var d = Object.defineProperty;
2
- var l = (i, e, t) => e in i ? d(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var c = (i, e, t) => l(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { readFileSync as m, existsSync as p, mkdirSync as f, writeFileSync as n, stat as g } from "node:fs";
5
- import { createRequire as v } from "node:module";
6
- import { dirname as k, join as h } from "node:path";
7
- import { fileURLToPath as P } from "node:url";
8
- import { registerTheme as F, getThemeInterface as y, getCss as D } from "@devup-ui/wasm";
9
- const T = P(import.meta.url), w = k(T);
10
- class _ {
1
+ var l = Object.defineProperty;
2
+ var m = (i, e, t) => e in i ? l(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var n = (i, e, t) => m(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { readFileSync as f, existsSync as p, mkdirSync as g, writeFileSync as r, stat as v } from "node:fs";
5
+ import { createRequire as P } from "node:module";
6
+ import { dirname as k, join as u } from "node:path";
7
+ import { fileURLToPath as D } from "node:url";
8
+ import { registerTheme as y, getThemeInterface as w, getCss as F } from "@devup-ui/wasm";
9
+ const T = D(import.meta.url), x = k(T);
10
+ class b {
11
11
  constructor({
12
12
  package: e = "@devup-ui/react",
13
- cssFile: t = h(w, "devup-ui.css"),
14
- devupPath: s = "devup.json",
15
- interfacePath: o = ".df"
13
+ cssFile: t = u(x, "devup-ui.css"),
14
+ devupPath: o = "devup.json",
15
+ interfacePath: s = ".df"
16
16
  }) {
17
- c(this, "options");
17
+ n(this, "options");
18
+ n(this, "watch", !1);
18
19
  this.options = {
19
20
  package: e,
20
21
  cssFile: t,
21
- devupPath: s,
22
- interfacePath: o
22
+ devupPath: o,
23
+ interfacePath: s
23
24
  };
24
25
  }
25
26
  writeDataFiles() {
26
27
  var t;
27
- F(
28
- (t = JSON.parse(m(this.options.devupPath, "utf-8"))) == null ? void 0 : t.theme
28
+ y(
29
+ (t = JSON.parse(f(this.options.devupPath, "utf-8"))) == null ? void 0 : t.theme
29
30
  );
30
- const e = y(
31
+ const e = w(
31
32
  this.options.package,
32
33
  "DevupThemeColors",
33
34
  "DevupThemeTypography"
34
35
  );
35
- e && (p(this.options.interfacePath) || f(this.options.interfacePath), n(
36
- h(this.options.interfacePath, "theme.d.ts"),
36
+ e && (p(this.options.interfacePath) || g(this.options.interfacePath), r(
37
+ u(this.options.interfacePath, "theme.d.ts"),
37
38
  e,
38
39
  {
39
40
  encoding: "utf-8"
40
41
  }
41
- )), n(this.options.cssFile, D(), {
42
+ )), r(this.options.cssFile, F(), {
42
43
  encoding: "utf-8"
43
44
  });
44
45
  }
45
46
  apply(e) {
46
- if (p(this.options.devupPath)) {
47
+ const t = p(this.options.devupPath);
48
+ if (t) {
47
49
  try {
48
50
  this.writeDataFiles();
49
51
  } catch (s) {
50
52
  console.error(s);
51
53
  }
52
- let t = null;
53
54
  e.hooks.afterCompile.tap("DevupUIWebpackPlugin", (s) => {
54
55
  s.fileDependencies.add(this.options.devupPath);
55
- }), e.hooks.watchRun.tapAsync(
56
- "DevupUIWebpackPlugin",
57
- (s, o) => {
58
- g(this.options.devupPath, (a, u) => {
59
- if (a)
60
- return console.error(`Error checking ${this.options.devupPath}:`, a), o();
61
- const r = u.mtimeMs;
62
- t && t !== r && this.writeDataFiles(), t = r, o();
63
- });
64
- }
65
- );
56
+ });
66
57
  }
67
- p(this.options.cssFile) || n(this.options.cssFile, "", { encoding: "utf-8" }), e.options.module.rules.push({
58
+ let o = null;
59
+ e.hooks.watchRun.tapAsync("DevupUIWebpackPlugin", (s, a) => {
60
+ this.watch = !0, t && v(this.options.devupPath, (c, d) => {
61
+ if (c)
62
+ return console.error(`Error checking ${this.options.devupPath}:`, c), a();
63
+ const h = d.mtimeMs;
64
+ o && o !== h && this.writeDataFiles(), o = h, a();
65
+ });
66
+ }), p(this.options.cssFile) || r(this.options.cssFile, "", { encoding: "utf-8" }), e.options.module.rules.push({
68
67
  test: /\.(tsx|ts|js|mjs|jsx)$/,
69
68
  exclude: /node_modules/,
70
69
  use: [
71
70
  {
72
- loader: v(import.meta.url).resolve(
71
+ loader: P(import.meta.url).resolve(
73
72
  "@devup-ui/webpack-plugin/loader"
74
73
  ),
75
74
  options: {
76
- package: this.options.package,
77
- cssFile: this.options.cssFile
75
+ plugin: this
78
76
  }
79
77
  }
80
78
  ]
@@ -82,5 +80,5 @@ class _ {
82
80
  }
83
81
  }
84
82
  export {
85
- _ as DevupUIWebpackPlugin
83
+ b as DevupUIWebpackPlugin
86
84
  };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@devup-ui/webpack-plugin",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "dependencies": {
6
6
  "webpack": "^5.97",
7
- "@devup-ui/wasm": "0.1.1"
7
+ "@devup-ui/wasm": "0.1.2"
8
8
  },
9
9
  "exports": {
10
10
  ".": {
@@ -31,8 +31,6 @@
31
31
  "webpack": "*"
32
32
  },
33
33
  "scripts": {
34
- "test": "vitest run --coverage",
35
- "test:s": "vitest run -u",
36
34
  "lint": "eslint",
37
35
  "build": "tsc && vite build"
38
36
  }