@devup-ui/vite-plugin 0.1.20 → 0.1.22

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