@devup-ui/webpack-plugin 0.1.0 → 0.1.1

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/plugin.cjs CHANGED
@@ -1 +1 @@
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 d=(s,e,t)=>m(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("node:fs"),r=require("node:path"),g=require("node:url"),a=require("@devup-ui/wasm");var c=typeof document<"u"?document.currentScript:null;const y=g.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:c&&c.tagName.toUpperCase()==="SCRIPT"&&c.src||new URL("plugin.cjs",document.baseURI).href),h=r.dirname(y);class v{constructor({package:e="@devup-ui/react",cssFile:t=r.join(h,"devup-ui.css"),devupPath:o="devup.json",interfacePath:n=".df"}){d(this,"options");this.options={package:e,cssFile:t,devupPath:o,interfacePath:n}}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(r.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,n)=>{i.stat(this.options.devupPath,(p,l)=>{if(p)return console.error(`Error checking ${this.options.devupPath}:`,p),n();const u=l.mtimeMs;t&&t!==u&&this.writeDataFiles(),t=u,n()})})}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:r.join(h,"loader.js"),options:{package:this.options.package,cssFile:this.options.cssFile}}]})}}exports.DevupUIWebpackPlugin=v;
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 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAWA,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;CAoDzB"}
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"}
package/dist/plugin.js CHANGED
@@ -1,19 +1,20 @@
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 h = (i, e, t) => m(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { readFileSync as f, existsSync as n, mkdirSync as g, writeFileSync as p, stat as v } from "node:fs";
5
- import { dirname as P, join as a } from "node:path";
6
- import { fileURLToPath as k } from "node:url";
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";
7
8
  import { registerTheme as F, getThemeInterface as y, getCss as D } from "@devup-ui/wasm";
8
- const T = k(import.meta.url), u = P(T);
9
- class I {
9
+ const T = P(import.meta.url), w = k(T);
10
+ class _ {
10
11
  constructor({
11
12
  package: e = "@devup-ui/react",
12
- cssFile: t = a(u, "devup-ui.css"),
13
+ cssFile: t = h(w, "devup-ui.css"),
13
14
  devupPath: s = "devup.json",
14
15
  interfacePath: o = ".df"
15
16
  }) {
16
- h(this, "options");
17
+ c(this, "options");
17
18
  this.options = {
18
19
  package: e,
19
20
  cssFile: t,
@@ -24,25 +25,25 @@ class I {
24
25
  writeDataFiles() {
25
26
  var t;
26
27
  F(
27
- (t = JSON.parse(f(this.options.devupPath, "utf-8"))) == null ? void 0 : t.theme
28
+ (t = JSON.parse(m(this.options.devupPath, "utf-8"))) == null ? void 0 : t.theme
28
29
  );
29
30
  const e = y(
30
31
  this.options.package,
31
32
  "DevupThemeColors",
32
33
  "DevupThemeTypography"
33
34
  );
34
- e && (n(this.options.interfacePath) || g(this.options.interfacePath), p(
35
- a(this.options.interfacePath, "theme.d.ts"),
35
+ e && (p(this.options.interfacePath) || f(this.options.interfacePath), n(
36
+ h(this.options.interfacePath, "theme.d.ts"),
36
37
  e,
37
38
  {
38
39
  encoding: "utf-8"
39
40
  }
40
- )), p(this.options.cssFile, D(), {
41
+ )), n(this.options.cssFile, D(), {
41
42
  encoding: "utf-8"
42
43
  });
43
44
  }
44
45
  apply(e) {
45
- if (n(this.options.devupPath)) {
46
+ if (p(this.options.devupPath)) {
46
47
  try {
47
48
  this.writeDataFiles();
48
49
  } catch (s) {
@@ -54,21 +55,23 @@ class I {
54
55
  }), e.hooks.watchRun.tapAsync(
55
56
  "DevupUIWebpackPlugin",
56
57
  (s, o) => {
57
- v(this.options.devupPath, (r, d) => {
58
- if (r)
59
- return console.error(`Error checking ${this.options.devupPath}:`, r), o();
60
- const c = d.mtimeMs;
61
- t && t !== c && this.writeDataFiles(), t = c, 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();
62
63
  });
63
64
  }
64
65
  );
65
66
  }
66
- n(this.options.cssFile) || p(this.options.cssFile, "", { encoding: "utf-8" }), e.options.module.rules.push({
67
+ p(this.options.cssFile) || n(this.options.cssFile, "", { encoding: "utf-8" }), e.options.module.rules.push({
67
68
  test: /\.(tsx|ts|js|mjs|jsx)$/,
68
69
  exclude: /node_modules/,
69
70
  use: [
70
71
  {
71
- loader: a(u, "loader.js"),
72
+ loader: v(import.meta.url).resolve(
73
+ "@devup-ui/webpack-plugin/loader"
74
+ ),
72
75
  options: {
73
76
  package: this.options.package,
74
77
  cssFile: this.options.cssFile
@@ -79,5 +82,5 @@ class I {
79
82
  }
80
83
  }
81
84
  export {
82
- I as DevupUIWebpackPlugin
85
+ _ as DevupUIWebpackPlugin
83
86
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devup-ui/webpack-plugin",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "dependencies": {
6
6
  "webpack": "^5.97",
7
7
  "@devup-ui/wasm": "0.1.0"