@devup-ui/vite-plugin 0.1.48 → 0.1.50

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,11 +1 @@
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
- }
11
- `}:{code:m}}}}exports.DevupUI=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("node:fs"),m=require("node:fs/promises"),o=require("node:path"),a=require("@devup-ui/wasm"),l=require("vite");function d(e){var t;if(n.existsSync(e.interfacePath)||n.mkdirSync(e.interfacePath),n.existsSync(e.devupPath)){a.registerTheme((t=JSON.parse(n.readFileSync(e.devupPath,"utf-8")))==null?void 0:t.theme);const s=a.getThemeInterface(e.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");s&&n.writeFileSync(o.join(e.interfacePath,"theme.d.ts"),s,{encoding:"utf-8"})}n.existsSync(e.cssFile)||n.writeFileSync(e.cssFile,"",{encoding:"utf-8"})}let c="";function v({package:e="@devup-ui/react",devupPath:t="devup.json",interfacePath:s=".df",cssFile:i=o.resolve(s,"devup-ui.css"),extractCss:p=!0,debug:h=!1}={}){a.setDebug(h);try{d({package:e,cssFile:i,devupPath:t,interfacePath:s})}catch(r){console.error(r)}return{name:"devup-ui",config(){return{server:{watch:{ignored:[`!${t}`]}},build:{rollupOptions:{output:{manualChunks(r){if(r.startsWith("devup-ui.css"))return"devup-ui.css"}}}}}},apply(){return!0},watchChange(r){if(o.resolve(r)===o.resolve(t)&&n.existsSync(t))try{d({package:e,cssFile:i,devupPath:t,interfacePath:s})}catch(u){console.error(u)}},resolveId(r){if(l.normalizePath(r)===l.normalizePath(i))return`devup-ui.css?t=${Date.now().toString()+c.length}`},load(r){if(r.split("?")[0]==="devup-ui.css")return c},enforce:"pre",async transform(r,u){if(!p||u.includes("node_modules")||!/\.(tsx|ts|js|mjs|jsx)$/i.test(u))return;const{code:g,css:f}=a.codeExtract(u,r,e,i);return f&&c.length<f.length&&(c=f,await m.writeFile(i,`/* ${u} ${Date.now()} */`,{encoding:"utf-8"})),{code:g}}}}exports.DevupUI=v;
package/dist/plugin.d.ts CHANGED
@@ -7,5 +7,5 @@ export interface DevupUIPluginOptions {
7
7
  extractCss: boolean;
8
8
  debug: boolean;
9
9
  }
10
- export declare function DevupUI({ package: libPackage, cssFile, devupPath, interfacePath, extractCss, debug, }?: Partial<DevupUIPluginOptions>): PluginOption;
10
+ export declare function DevupUI({ package: libPackage, devupPath, interfacePath, cssFile, extractCss, debug, }?: Partial<DevupUIPluginOptions>): PluginOption;
11
11
  //# sourceMappingURL=plugin.d.ts.map
@@ -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,CA8EnD"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAUA,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,MAAM,CAAA;AAEvD,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;AA8BD,wBAAgB,OAAO,CAAC,EACtB,OAAO,EAAE,UAA8B,EACvC,SAAwB,EACxB,aAAqB,EACrB,OAAgD,EAChD,UAAiB,EACjB,KAAa,GACd,GAAE,OAAO,CAAC,oBAAoB,CAAM,GAAG,YAAY,CA+EnD"}
package/dist/plugin.js CHANGED
@@ -1,43 +1,48 @@
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 f } from "node:path";
3
- import { fileURLToPath as x } from "node:url";
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) {
1
+ import { existsSync as c, mkdirSync as g, readFileSync as v, writeFileSync as f } from "node:fs";
2
+ import { writeFile as y } from "node:fs/promises";
3
+ import { resolve as a, join as w } from "node:path";
4
+ import { setDebug as D, codeExtract as C, registerTheme as S, getThemeInterface as T } from "@devup-ui/wasm";
5
+ import { normalizePath as m } from "vite";
6
+ function p(e) {
7
7
  var t;
8
- T((t = JSON.parse(g(e.devupPath, "utf-8"))) == null ? void 0 : t.theme);
9
- const r = w(
10
- e.package,
11
- "DevupThemeColors",
12
- "DevupThemeTypography",
13
- "DevupTheme"
14
- );
15
- r && (i(e.interfacePath) || h(e.interfacePath), u(l(e.interfacePath, "theme.d.ts"), r, {
16
- encoding: "utf-8"
17
- })), u(e.cssFile, E(), {
8
+ if (c(e.interfacePath) || g(e.interfacePath), c(e.devupPath)) {
9
+ S(
10
+ (t = JSON.parse(v(e.devupPath, "utf-8"))) == null ? void 0 : t.theme
11
+ );
12
+ const n = T(
13
+ e.package,
14
+ "DevupThemeColors",
15
+ "DevupThemeTypography",
16
+ "DevupTheme"
17
+ );
18
+ n && f(w(e.interfacePath, "theme.d.ts"), n, {
19
+ encoding: "utf-8"
20
+ });
21
+ }
22
+ c(e.cssFile) || f(e.cssFile, "", {
18
23
  encoding: "utf-8"
19
24
  });
20
25
  }
21
- function N({
26
+ let o = "";
27
+ function F({
22
28
  package: e = "@devup-ui/react",
23
- cssFile: r = l(S, "devup-ui.css"),
24
29
  devupPath: t = "devup.json",
25
- interfacePath: s = ".df",
26
- extractCss: p = !0,
27
- debug: y = !1
30
+ interfacePath: n = ".df",
31
+ cssFile: i = a(n, "devup-ui.css"),
32
+ extractCss: d = !0,
33
+ debug: l = !1
28
34
  } = {}) {
29
- if (C(y), i(t))
30
- try {
31
- a({
32
- package: e,
33
- cssFile: r,
34
- devupPath: t,
35
- interfacePath: s
36
- });
37
- } catch (o) {
38
- console.error(o);
39
- }
40
- let m = null;
35
+ D(l);
36
+ try {
37
+ p({
38
+ package: e,
39
+ cssFile: i,
40
+ devupPath: t,
41
+ interfacePath: n
42
+ });
43
+ } catch (r) {
44
+ console.error(r);
45
+ }
41
46
  return {
42
47
  name: "devup-ui",
43
48
  config() {
@@ -46,49 +51,54 @@ function N({
46
51
  watch: {
47
52
  ignored: [`!${t}`]
48
53
  }
54
+ },
55
+ build: {
56
+ rollupOptions: {
57
+ output: {
58
+ manualChunks(r) {
59
+ if (r.startsWith("devup-ui.css"))
60
+ return "devup-ui.css";
61
+ }
62
+ }
63
+ }
49
64
  }
50
65
  };
51
66
  },
52
- apply(o, n) {
53
- return m = n.command, !0;
67
+ apply() {
68
+ return !0;
54
69
  },
55
- watchChange(o) {
56
- if (f(o) === f(t) && i(t))
70
+ watchChange(r) {
71
+ if (a(r) === a(t) && c(t))
57
72
  try {
58
- a({
73
+ p({
59
74
  package: e,
60
- cssFile: r,
75
+ cssFile: i,
61
76
  devupPath: t,
62
- interfacePath: s
77
+ interfacePath: n
63
78
  });
64
- } catch (n) {
65
- console.error(n);
79
+ } catch (u) {
80
+ console.error(u);
66
81
  }
67
82
  },
83
+ resolveId(r) {
84
+ if (m(r) === m(i))
85
+ return `devup-ui.css?t=${Date.now().toString() + o.length}`;
86
+ },
87
+ load(r) {
88
+ if (r.split("?")[0] === "devup-ui.css") return o;
89
+ },
68
90
  enforce: "pre",
69
- transform(o, n) {
70
- if (!p || n.includes("node_modules") || !/\.(tsx|ts|js|mjs|jsx)$/i.test(n)) return;
71
- const { code: d, css: c } = D(n, o, e, r);
72
- return c && (u(r, c, {
91
+ async transform(r, u) {
92
+ if (!d || u.includes("node_modules") || !/\.(tsx|ts|js|mjs|jsx)$/i.test(u)) return;
93
+ const { code: h, css: s } = C(u, r, e, i);
94
+ return s && o.length < s.length && (o = s, await y(i, `/* ${u} ${Date.now()} */`, {
73
95
  encoding: "utf-8"
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
- }
85
- `
86
- } : {
87
- code: d
96
+ })), {
97
+ code: h
88
98
  };
89
99
  }
90
100
  };
91
101
  }
92
102
  export {
93
- N as DevupUI
103
+ F as DevupUI
94
104
  };
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.48",
4
+ "version": "0.1.50",
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.47"
22
+ "@devup-ui/wasm": "0.1.48"
23
23
  },
24
24
  "devDependencies": {
25
25
  "vite-plugin-dts": "^4.5.0",