@devup-ui/webpack-plugin 1.0.1 → 1.0.3
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 +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +22 -20
- package/package.json +2 -2
package/dist/plugin.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var y=(
|
|
1
|
+
"use strict";var v=Object.defineProperty;var y=(n,e,s)=>e in n?v(n,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[e]=s;var f=(n,e,s)=>y(n,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("node:fs"),g=require("node:module"),r=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:s="devup.json",interfacePath:a=".df",cssFile:c=r.resolve(a,"devup-ui.css"),watch:i=!1,debug:u=!1,include:h=[]}={}){f(this,"options");this.options={package:e,cssFile:c,devupPath:s,interfacePath:a,watch:i,debug:u,include:h}}writeDataFiles(){var s;o.registerTheme((s=JSON.parse(t.readFileSync(this.options.devupPath,"utf-8")))==null?void 0:s.theme);const e=o.getThemeInterface(this.options.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");e&&t.writeFileSync(r.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 s=t.existsSync(this.options.devupPath);t.existsSync(this.options.interfacePath)||t.mkdirSync(this.options.interfacePath);const a=r.join(this.options.interfacePath,"sheet.json"),c=r.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(c)&&o.importClassMap(JSON.parse(t.readFileSync(c,"utf-8")))}catch(u){console.error(u)}let i=null;e.hooks.watchRun.tapAsync("DevupUIWebpackPlugin",(u,h)=>{s&&t.stat(this.options.devupPath,(l,m)=>{if(l){console.error(`Error checking ${this.options.devupPath}:`,l);return}const d=m.mtimeMs;i&&i!==d&&this.writeDataFiles(),i=d}),h()})}if(s){try{this.writeDataFiles()}catch(i){console.error(i)}e.hooks.afterCompile.tap("DevupUIWebpackPlugin",i=>{i.fileDependencies.add(r.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",i=>{i.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:c,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;
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
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,aAAqB,EACrB,OAAgD,EAChD,KAAa,EACb,KAAa,EACb,OAAY,GACb,GAAE,OAAO,CAAC,2BAA2B,CAAM;IAY5C,cAAc;IA2Bd,KAAK,CAAC,QAAQ,EAAE,QAAQ;CA6GzB"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
var w = Object.defineProperty;
|
|
2
2
|
var D = (i, e, t) => e in i ? w(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var d = (i, e, t) => D(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { readFileSync as
|
|
5
|
-
import { createRequire as
|
|
6
|
-
import { resolve as
|
|
7
|
-
import { registerTheme as P, getThemeInterface as y, setDebug as T, importSheet as
|
|
8
|
-
class
|
|
4
|
+
import { readFileSync as h, writeFileSync as r, existsSync as p, mkdirSync as k, stat as F } from "node:fs";
|
|
5
|
+
import { createRequire as g } from "node:module";
|
|
6
|
+
import { resolve as m, join as u } from "node:path";
|
|
7
|
+
import { registerTheme as P, 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 {
|
|
9
9
|
constructor({
|
|
10
10
|
package: e = "@devup-ui/react",
|
|
11
11
|
devupPath: t = "devup.json",
|
|
12
12
|
interfacePath: o = ".df",
|
|
13
|
-
cssFile: n =
|
|
13
|
+
cssFile: n = m(o, "devup-ui.css"),
|
|
14
14
|
watch: s = !1,
|
|
15
15
|
debug: a = !1,
|
|
16
|
-
include:
|
|
16
|
+
include: c = []
|
|
17
17
|
} = {}) {
|
|
18
18
|
d(this, "options");
|
|
19
19
|
this.options = {
|
|
@@ -23,13 +23,13 @@ class I {
|
|
|
23
23
|
interfacePath: o,
|
|
24
24
|
watch: s,
|
|
25
25
|
debug: a,
|
|
26
|
-
include:
|
|
26
|
+
include: c
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
writeDataFiles() {
|
|
30
30
|
var t;
|
|
31
31
|
P(
|
|
32
|
-
(t = JSON.parse(
|
|
32
|
+
(t = JSON.parse(h(this.options.devupPath, "utf-8"))) == null ? void 0 : t.theme
|
|
33
33
|
);
|
|
34
34
|
const e = y(
|
|
35
35
|
this.options.package,
|
|
@@ -37,13 +37,13 @@ class I {
|
|
|
37
37
|
"DevupThemeTypography",
|
|
38
38
|
"DevupTheme"
|
|
39
39
|
);
|
|
40
|
-
e &&
|
|
40
|
+
e && r(
|
|
41
41
|
u(this.options.interfacePath, "theme.d.ts"),
|
|
42
42
|
e,
|
|
43
43
|
{
|
|
44
44
|
encoding: "utf-8"
|
|
45
45
|
}
|
|
46
|
-
), this.options.watch &&
|
|
46
|
+
), this.options.watch && r(this.options.cssFile, `/* ${Date.now()} */`, {
|
|
47
47
|
encoding: "utf-8"
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -54,14 +54,14 @@ class I {
|
|
|
54
54
|
const o = u(this.options.interfacePath, "sheet.json"), n = u(this.options.interfacePath, "classMap.json");
|
|
55
55
|
if (this.options.watch) {
|
|
56
56
|
try {
|
|
57
|
-
p(o) &&
|
|
57
|
+
p(o) && b(JSON.parse(h(o, "utf-8"))), p(n) && S(JSON.parse(h(n, "utf-8")));
|
|
58
58
|
} catch (a) {
|
|
59
59
|
console.error(a);
|
|
60
60
|
}
|
|
61
61
|
let s = null;
|
|
62
62
|
e.hooks.watchRun.tapAsync(
|
|
63
63
|
"DevupUIWebpackPlugin",
|
|
64
|
-
(a,
|
|
64
|
+
(a, c) => {
|
|
65
65
|
t && F(this.options.devupPath, (l, v) => {
|
|
66
66
|
if (l) {
|
|
67
67
|
console.error(`Error checking ${this.options.devupPath}:`, l);
|
|
@@ -69,7 +69,7 @@ class I {
|
|
|
69
69
|
}
|
|
70
70
|
const f = v.mtimeMs;
|
|
71
71
|
s && s !== f && this.writeDataFiles(), s = f;
|
|
72
|
-
}),
|
|
72
|
+
}), c();
|
|
73
73
|
}
|
|
74
74
|
);
|
|
75
75
|
}
|
|
@@ -80,14 +80,16 @@ class I {
|
|
|
80
80
|
console.error(s);
|
|
81
81
|
}
|
|
82
82
|
e.hooks.afterCompile.tap("DevupUIWebpackPlugin", (s) => {
|
|
83
|
-
s.fileDependencies.add(
|
|
83
|
+
s.fileDependencies.add(m(this.options.devupPath));
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
p(this.options.cssFile) ||
|
|
86
|
+
p(this.options.cssFile) || r(this.options.cssFile, "", { encoding: "utf-8" }), e.options.plugins.push(
|
|
87
87
|
new e.webpack.DefinePlugin({
|
|
88
88
|
"process.env.DEVUP_UI_DEFAULT_THEME": JSON.stringify(j())
|
|
89
89
|
})
|
|
90
|
-
),
|
|
90
|
+
), this.options.watch || e.hooks.done.tap("DevupUIWebpackPlugin", (s) => {
|
|
91
|
+
s.hasErrors() || r(this.options.cssFile, x(), { encoding: "utf-8" });
|
|
92
|
+
}), e.options.module.rules.push(
|
|
91
93
|
{
|
|
92
94
|
test: /\.(tsx|ts|js|mjs|jsx)$/,
|
|
93
95
|
exclude: new RegExp(
|
|
@@ -96,7 +98,7 @@ class I {
|
|
|
96
98
|
enforce: "pre",
|
|
97
99
|
use: [
|
|
98
100
|
{
|
|
99
|
-
loader:
|
|
101
|
+
loader: g(import.meta.url).resolve(
|
|
100
102
|
"@devup-ui/webpack-plugin/loader"
|
|
101
103
|
),
|
|
102
104
|
options: {
|
|
@@ -114,7 +116,7 @@ class I {
|
|
|
114
116
|
enforce: "pre",
|
|
115
117
|
use: [
|
|
116
118
|
{
|
|
117
|
-
loader:
|
|
119
|
+
loader: g(import.meta.url).resolve(
|
|
118
120
|
"@devup-ui/webpack-plugin/css-loader"
|
|
119
121
|
),
|
|
120
122
|
options: {
|
|
@@ -127,5 +129,5 @@ class I {
|
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
export {
|
|
130
|
-
|
|
132
|
+
C as DevupUIWebpackPlugin
|
|
131
133
|
};
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"webpack"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "1.0.
|
|
21
|
+
"version": "1.0.3",
|
|
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.
|
|
48
|
+
"@devup-ui/wasm": "1.0.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@devup-ui/wasm": "*"
|