@devup-ui/vite-plugin 0.1.20 → 0.1.21

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"),o=require("node:path"),p=require("node:url"),u=require("@devup-ui/wasm");var d=typeof document<"u"?document.currentScript:null;const y=p.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:d&&d.tagName.toUpperCase()==="SCRIPT"&&d.src||new URL("plugin.cjs",document.baseURI).href),g=o.dirname(y);function m(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 h({package:e="@devup-ui/react",cssFile:n=o.join(g,"devup-ui.css"),devupPath:t="devup.json",interfacePath:a=".df",extractCss:l=!0}={}){if(r.existsSync(t))try{m({package:e,cssFile:n,devupPath:t,interfacePath:a})}catch(c){console.error(c)}return{name:"devup-ui",config(){return{server:{watch:{ignored:[`!${t}`]}}}},watchChange(c){if(o.resolve(c)===o.resolve(t)&&r.existsSync(t))try{m({package:e,cssFile:n,devupPath:t,interfacePath:a})}catch(i){console.error(i)}},enforce:"pre",transform(c,i){if(!l||i.includes("node_modules")||!/\.(tsx|ts|js|mjs|jsx)$/i.test(i))return;const{code:f,css:s}=u.codeExtract(i,c,e,n);return s?(r.writeFileSync(n,s,{encoding:"utf-8"}),{code:`${f}
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:f}}}}exports.DevupUI=h;
@@ -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,CAqEnD"}
package/dist/plugin.js CHANGED
@@ -1,58 +1,60 @@
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 l, mkdirSync as y } from "node:fs";
2
+ import { dirname as g, resolve as d, join as a } from "node:path";
3
+ import { fileURLToPath as h } from "node:url";
4
+ import { codeExtract as v, registerTheme as x, getThemeInterface as C, getCss as T } from "@devup-ui/wasm";
5
+ const j = h(import.meta.url), D = g(j);
6
+ function f(e) {
7
+ var t;
8
+ x((t = JSON.parse(l(e.devupPath, "utf-8"))) == null ? void 0 : t.theme);
9
+ const r = C(
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) || y(e.interfacePath), u(a(e.interfacePath, "theme.d.ts"), r, {
16
16
  encoding: "utf-8"
17
- })), i(e.cssFile, x(), {
17
+ })), u(e.cssFile, T(), {
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 = a(D, "devup-ui.css"),
24
+ devupPath: t = "devup.json",
25
+ interfacePath: s = ".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: s
35
35
  });
36
36
  } catch (n) {
37
37
  console.error(n);
38
38
  }
39
39
  return {
40
40
  name: "devup-ui",
41
- config: () => ({
42
- server: {
43
- watch: {
44
- ignored: [`!${r}`]
41
+ config() {
42
+ return {
43
+ server: {
44
+ watch: {
45
+ ignored: [`!${t}`]
46
+ }
45
47
  }
46
- }
47
- }),
48
+ };
49
+ },
48
50
  watchChange(n) {
49
- if (m(n) === m(r) && o(r))
51
+ if (d(n) === d(t) && i(t))
50
52
  try {
51
- u({
53
+ f({
52
54
  package: e,
53
- cssFile: t,
54
- devupPath: r,
55
- interfacePath: f
55
+ cssFile: r,
56
+ devupPath: t,
57
+ interfacePath: s
56
58
  });
57
59
  } catch (c) {
58
60
  console.error(c);
@@ -60,16 +62,26 @@ function I({
60
62
  },
61
63
  enforce: "pre",
62
64
  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, {
65
+ if (!p || c.includes("node_modules") || !/\.(tsx|ts|js|mjs|jsx)$/i.test(c)) return;
66
+ const { code: m, css: o } = v(c, n, e, r);
67
+ return o ? (u(r, o, {
66
68
  encoding: "utf-8"
67
69
  }), {
68
- code: p
70
+ code: `${m}
71
+ const exists = !!document.getElementById('devup-ui');
72
+ const style = document.getElementById('devup-ui') || document.createElement('style');
73
+ style.id = 'devup-ui';
74
+ style.textContent = \`
75
+ ${o}
76
+ \`;
77
+ if (!exists) document.head.appendChild(style);
78
+ `
79
+ }) : {
80
+ code: m
69
81
  };
70
82
  }
71
83
  };
72
84
  }
73
85
  export {
74
- I as DevupUI
86
+ $ as DevupUI
75
87
  };
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.21",
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",