@devup-ui/vite-plugin 0.1.42 → 0.1.44
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 +10 -8
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +37 -35
- package/package.json +1 -1
package/dist/plugin.cjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("node:fs"),
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("node:fs"),o=require("node:path"),g=require("node:url"),u=require("@devup-ui/wasm");var d=typeof document<"u"?document.currentScript:null;const h=g.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:d&&d.tagName.toUpperCase()==="SCRIPT"&&d.src||new URL("plugin.cjs",document.baseURI).href),v=o.dirname(h);function l(e){var t;u.registerTheme((t=JSON.parse(r.readFileSync(e.devupPath,"utf-8")))==null?void 0:t.theme);const n=u.getThemeInterface(e.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");n&&(r.existsSync(e.interfacePath)||r.mkdirSync(e.interfacePath),r.writeFileSync(o.join(e.interfacePath,"theme.d.ts"),n,{encoding:"utf-8"})),r.writeFileSync(e.cssFile,u.getCss(),{encoding:"utf-8"})}function S({package:e="@devup-ui/react",cssFile:n=o.join(v,"devup-ui.css"),devupPath:t="devup.json",interfacePath:a=".df",extractCss:p=!0,debug:y=!1}={}){if(u.setDebug(y),r.existsSync(t))try{l({package:e,cssFile:n,devupPath:t,interfacePath:a})}catch(i){console.error(i)}let f=null;return{name:"devup-ui",config(){return{server:{watch:{ignored:[`!${t}`]}}}},apply(i,c){return f=c.command,!0},watchChange(i){if(o.resolve(i)===o.resolve(t)&&r.existsSync(t))try{l({package:e,cssFile:n,devupPath:t,interfacePath:a})}catch(c){console.error(c)}},enforce:"pre",transform(i,c){if(!p||c.includes("node_modules")||!/\.(tsx|ts|js|mjs|jsx)$/i.test(c))return;const{code:m,css:s}=u.codeExtract(c,i,e,n);return s&&(r.writeFileSync(n,s,{encoding:"utf-8"}),f==="serve"&&process.env.NODE_ENV!=="test")?{code:`${m}
|
|
2
|
+
if(typeof window !== 'undefined'){
|
|
3
|
+
const exists = !!document.getElementById('devup-ui');
|
|
4
|
+
const style = document.getElementById('devup-ui') || document.createElement('style');
|
|
5
|
+
style.id = 'devup-ui';
|
|
6
|
+
style.textContent = \`
|
|
7
|
+
${s}
|
|
8
|
+
\`;
|
|
9
|
+
if (!exists) document.head.appendChild(style);
|
|
10
|
+
}
|
|
9
11
|
`}:{code:m}}}}exports.DevupUI=S;
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAA;AAKxC,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;CACf;AAuBD,wBAAgB,OAAO,CAAC,EACtB,OAAO,EAAE,UAA8B,EACvC,OAAwC,EACxC,SAAwB,EACxB,aAAqB,EACrB,UAAiB,EACjB,KAAa,GACd,GAAE,OAAO,CAAC,oBAAoB,CAAM,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAA;AAKxC,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;CACf;AAuBD,wBAAgB,OAAO,CAAC,EACtB,OAAO,EAAE,UAA8B,EACvC,OAAwC,EACxC,SAAwB,EACxB,aAAqB,EACrB,UAAiB,EACjB,KAAa,GACd,GAAE,OAAO,CAAC,oBAAoB,CAAM,GAAG,YAAY,CA8EnD"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { existsSync as i, writeFileSync as u, readFileSync as g, mkdirSync as h } from "node:fs";
|
|
2
|
-
import { dirname as v, join as l, resolve as
|
|
2
|
+
import { dirname as v, join as l, resolve as f } from "node:path";
|
|
3
3
|
import { fileURLToPath as x } from "node:url";
|
|
4
|
-
import { setDebug as C, codeExtract as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
4
|
+
import { setDebug as C, codeExtract as D, registerTheme as T, getThemeInterface as w, getCss as E } from "@devup-ui/wasm";
|
|
5
|
+
const j = x(import.meta.url), S = v(j);
|
|
6
|
+
function a(e) {
|
|
7
7
|
var t;
|
|
8
|
-
|
|
9
|
-
const r =
|
|
8
|
+
T((t = JSON.parse(g(e.devupPath, "utf-8"))) == null ? void 0 : t.theme);
|
|
9
|
+
const r = w(
|
|
10
10
|
e.package,
|
|
11
11
|
"DevupThemeColors",
|
|
12
12
|
"DevupThemeTypography",
|
|
@@ -14,30 +14,30 @@ function f(e) {
|
|
|
14
14
|
);
|
|
15
15
|
r && (i(e.interfacePath) || h(e.interfacePath), u(l(e.interfacePath, "theme.d.ts"), r, {
|
|
16
16
|
encoding: "utf-8"
|
|
17
|
-
})), u(e.cssFile,
|
|
17
|
+
})), u(e.cssFile, E(), {
|
|
18
18
|
encoding: "utf-8"
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function N({
|
|
22
22
|
package: e = "@devup-ui/react",
|
|
23
|
-
cssFile: r = l(
|
|
23
|
+
cssFile: r = l(S, "devup-ui.css"),
|
|
24
24
|
devupPath: t = "devup.json",
|
|
25
|
-
interfacePath:
|
|
25
|
+
interfacePath: s = ".df",
|
|
26
26
|
extractCss: p = !0,
|
|
27
27
|
debug: y = !1
|
|
28
28
|
} = {}) {
|
|
29
29
|
if (C(y), i(t))
|
|
30
30
|
try {
|
|
31
|
-
|
|
31
|
+
a({
|
|
32
32
|
package: e,
|
|
33
33
|
cssFile: r,
|
|
34
34
|
devupPath: t,
|
|
35
|
-
interfacePath:
|
|
35
|
+
interfacePath: s
|
|
36
36
|
});
|
|
37
|
-
} catch (
|
|
38
|
-
console.error(
|
|
37
|
+
} catch (o) {
|
|
38
|
+
console.error(o);
|
|
39
39
|
}
|
|
40
|
-
let
|
|
40
|
+
let m = null;
|
|
41
41
|
return {
|
|
42
42
|
name: "devup-ui",
|
|
43
43
|
config() {
|
|
@@ -49,44 +49,46 @@ function B({
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
},
|
|
52
|
-
apply(
|
|
53
|
-
return
|
|
52
|
+
apply(o, n) {
|
|
53
|
+
return m = n.command, !0;
|
|
54
54
|
},
|
|
55
|
-
watchChange(
|
|
56
|
-
if (
|
|
55
|
+
watchChange(o) {
|
|
56
|
+
if (f(o) === f(t) && i(t))
|
|
57
57
|
try {
|
|
58
|
-
|
|
58
|
+
a({
|
|
59
59
|
package: e,
|
|
60
60
|
cssFile: r,
|
|
61
61
|
devupPath: t,
|
|
62
|
-
interfacePath:
|
|
62
|
+
interfacePath: s
|
|
63
63
|
});
|
|
64
64
|
} catch (n) {
|
|
65
65
|
console.error(n);
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
enforce: "pre",
|
|
69
|
-
transform(
|
|
69
|
+
transform(o, n) {
|
|
70
70
|
if (!p || n.includes("node_modules") || !/\.(tsx|ts|js|mjs|jsx)$/i.test(n)) return;
|
|
71
|
-
const { code:
|
|
72
|
-
return
|
|
71
|
+
const { code: d, css: c } = D(n, o, e, r);
|
|
72
|
+
return c && (u(r, c, {
|
|
73
73
|
encoding: "utf-8"
|
|
74
|
-
}),
|
|
75
|
-
code: `${
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
}), m === "serve" && process.env.NODE_ENV !== "test") ? {
|
|
75
|
+
code: `${d}
|
|
76
|
+
if(typeof window !== 'undefined'){
|
|
77
|
+
const exists = !!document.getElementById('devup-ui');
|
|
78
|
+
const style = document.getElementById('devup-ui') || document.createElement('style');
|
|
79
|
+
style.id = 'devup-ui';
|
|
80
|
+
style.textContent = \`
|
|
81
|
+
${c}
|
|
82
|
+
\`;
|
|
83
|
+
if (!exists) document.head.appendChild(style);
|
|
84
|
+
}
|
|
83
85
|
`
|
|
84
86
|
} : {
|
|
85
|
-
code:
|
|
87
|
+
code: d
|
|
86
88
|
};
|
|
87
89
|
}
|
|
88
90
|
};
|
|
89
91
|
}
|
|
90
92
|
export {
|
|
91
|
-
|
|
93
|
+
N as DevupUI
|
|
92
94
|
};
|