@devup-ui/vite-plugin 1.0.32 → 1.0.34

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 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("node:fs"),w=require("node:fs/promises"),l=require("node:path"),c=require("@devup-ui/wasm"),m=require("vite");function y(e){var s;if(i.existsSync(e.interfacePath)||i.mkdirSync(e.interfacePath),i.existsSync(e.devupPath)){c.registerTheme((s=JSON.parse(i.readFileSync(e.devupPath,"utf-8")))==null?void 0:s.theme);const u=c.getThemeInterface(e.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");u&&i.writeFileSync(l.join(e.interfacePath,"theme.d.ts"),u,{encoding:"utf-8"})}i.existsSync(e.cssFile)||i.writeFileSync(e.cssFile,"",{encoding:"utf-8"}),i.writeFileSync(l.join(e.interfacePath,".gitignore"),"*",{encoding:"utf-8"})}let f="";function T({package:e="@devup-ui/react",devupPath:s="devup.json",interfacePath:u="df",cssFile:a=l.resolve(u,"devup-ui.css"),extractCss:d=!0,debug:v=!1,include:g=[]}={}){c.setDebug(v);try{y({package:e,cssFile:a,devupPath:s,interfacePath:u})}catch(t){console.error(t)}const h=c.getDefaultTheme();return h&&JSON.stringify(h),{name:"devup-ui",config(){const t=c.getDefaultTheme(),r={};t&&(r["process.env.DEVUP_UI_DEFAULT_THEME"]=JSON.stringify(t));const n={server:{watch:{ignored:[`!${s}`]}},define:r,optimizeDeps:{exclude:g}};return d&&(n.build={rollupOptions:{output:{manualChunks(o){if(o.startsWith("devup-ui.css"))return"devup-ui.css"}}}}),n},apply(){return!0},watchChange(t){if(l.resolve(t)===l.resolve(s)&&i.existsSync(s))try{y({package:e,cssFile:a,devupPath:s,interfacePath:u})}catch(r){console.error(r)}},resolveId(t){if(m.normalizePath(t)===m.normalizePath(a))return`devup-ui.css?t=${Date.now().toString()+f.length}`},load(t){if(t.split("?")[0]==="devup-ui.css")return f=c.getCss()},enforce:"pre",async transform(t,r){if(!d)return;const n=r.split("?")[0];if((g.length?new RegExp(`node_modules(?!(${g.map(D=>`.*${D}`).join("|").replaceAll("/","[\\/\\\\_]")})([\\/\\\\.]|$))`).test(n):r.includes("node_modules"))||!/\.(tsx|ts|js|mjs|jsx)$/i.test(n))return;const{code:o,css:p,map:S}=c.codeExtract(n,t,e,a);return p&&f.length<p.length&&(f=p,await w.writeFile(a,`/* ${r} ${Date.now()} */`,{encoding:"utf-8"})),{code:o,map:S}},async generateBundle(t,r){if(!d)return;const n=Object.keys(r).find(o=>o.includes("devup-ui")&&o.endsWith(".css"));n&&"source"in r[n]&&(r[n].source=f)}}}exports.DevupUI=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("node:fs"),l=require("node:fs/promises"),t=require("node:path"),o=require("@devup-ui/wasm");function T(r){return r.endsWith("devup-ui.css")?null:parseInt(r.split("devup-ui-")[1].split(".")[0])}async function F(r){var c;try{const n=p.existsSync(r.devupFile)?await l.readFile(r.devupFile,"utf-8"):void 0;if(n){o.registerTheme(((c=JSON.parse(n))==null?void 0:c.theme)??{});const a=o.getThemeInterface(r.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");a&&await l.writeFile(t.join(r.distDir,"theme.d.ts"),a,"utf-8")}else o.registerTheme({})}catch(n){console.error(n),o.registerTheme({})}await Promise.all([p.existsSync(r.cssDir)?Promise.resolve():l.mkdir(r.cssDir,{recursive:!0}),r.singleCss?Promise.resolve():l.writeFile(t.join(r.cssDir,"devup-ui.css"),o.getCss(null,!1))])}function N({package:r="@devup-ui/react",devupFile:c="devup.json",distDir:n="df",cssDir:a=t.resolve(n,"devup-ui"),extractCss:m=!0,debug:S=!1,include:h=[],singleCss:d=!1}={}){o.setDebug(S);const f=new Map;return{name:"devup-ui",async configResolved(){p.existsSync(n)||await l.mkdir(n,{recursive:!0}),await l.writeFile(t.join(n,".gitignore"),"*","utf-8"),await F({package:r,cssDir:a,devupFile:c,distDir:n,singleCss:d})},config(){const i=o.getDefaultTheme(),e={};i&&(e["process.env.DEVUP_UI_DEFAULT_THEME"]=JSON.stringify(i));const s={server:{watch:{ignored:[`!${c}`]}},define:e,optimizeDeps:{exclude:h}};return m&&(s.build={rollupOptions:{output:{manualChunks(u){if(u.split("?")[0].endsWith("devup-ui.css"))return"devup-ui.css"}}}}),s},apply(){return!0},async watchChange(i){if(t.resolve(i)===t.resolve(c)&&p.existsSync(c))try{await F({package:r,cssDir:a,devupFile:c,distDir:n,singleCss:d})}catch(e){console.error(e)}},resolveId(i,e){var s;if(i.includes("devup-ui.css")&&t.resolve(e?t.join(t.dirname(e),i):i)===t.resolve(t.join(a,"devup-ui.css")))return t.join(a,`devup-ui.css?t=${Date.now().toString()+(((s=f.get(null))==null?void 0:s.length)??0)}`)},load(i){const e=t.basename(i).split("?")[0];if(e.startsWith("devup-ui")&&e.endsWith(".css")){const s=T(e),u=o.getCss(s,!1);return f.set(s,u),u}},enforce:"pre",async transform(i,e){if(!m)return;const s=e.split("?")[0];if(!/\.(tsx|ts|js|mjs|jsx)$/i.test(s)||new RegExp(`node_modules(?!.*(${["@devup-ui",...h].join("|").replaceAll("/","[\\/\\\\_]")})([\\/\\\\.]|$))`).test(s))return;let u=t.relative(t.dirname(e),a).replaceAll("\\","/");u.startsWith("./")||(u=`./${u}`);const{code:$,css:v,map:_,cssFile:w,updatedBaseStyle:x}=o.codeExtract(s,i,r,u,d,!0,!1),g=[];if(x&&g.push(l.writeFile(t.join(a,"devup-ui.css"),o.getCss(null,!1),"utf-8")),v){const y=T(w),j=f.get(y);j&&j.length<v.length&&f.set(y,v),g.push(l.writeFile(t.join(a,t.basename(w)),`/* ${e} ${Date.now()} */`,"utf-8"))}return await Promise.all(g),{code:$,map:_}},async generateBundle(i,e){if(!m)return;const s=Object.keys(e).find(u=>e[u].name==="devup-ui.css");s&&"source"in e[s]&&(e[s].source=f.get(null))}}}exports.DevupUI=N;
package/dist/plugin.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { PluginOption } from 'vite';
2
2
  export interface DevupUIPluginOptions {
3
3
  package: string;
4
- cssFile: string;
5
- devupPath: string;
6
- interfacePath: string;
4
+ cssDir: string;
5
+ devupFile: string;
6
+ distDir: string;
7
7
  extractCss: boolean;
8
8
  debug: boolean;
9
9
  include: string[];
10
+ singleCss: boolean;
10
11
  }
11
- export declare function DevupUI({ package: libPackage, devupPath, interfacePath, cssFile, extractCss, debug, include, }?: Partial<DevupUIPluginOptions>): PluginOption;
12
+ export declare function DevupUI({ package: libPackage, devupFile, distDir, cssDir, extractCss, debug, include, singleCss, }?: Partial<DevupUIPluginOptions>): PluginOption;
12
13
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAYA,OAAO,EAAiB,KAAK,YAAY,EAAmB,MAAM,MAAM,CAAA;AAExE,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;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAiCD,wBAAgB,OAAO,CAAC,EACtB,OAAO,EAAE,UAA8B,EACvC,SAAwB,EACxB,aAAoB,EACpB,OAAgD,EAChD,UAAiB,EACjB,KAAa,EACb,OAAY,GACb,GAAE,OAAO,CAAC,oBAAoB,CAAM,GAAG,YAAY,CA8HnD"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,MAAM,CAAA;AAEzD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;CACnB;AAgDD,wBAAgB,OAAO,CAAC,EACtB,OAAO,EAAE,UAA8B,EACvC,SAAwB,EACxB,OAAc,EACd,MAAqC,EACrC,UAAiB,EACjB,KAAa,EACb,OAAY,EACZ,SAAiB,GAClB,GAAE,OAAO,CAAC,oBAAoB,CAAM,GAAG,YAAY,CA0JnD"}
package/dist/plugin.js CHANGED
@@ -1,128 +1,158 @@
1
- import { existsSync as f, mkdirSync as $, readFileSync as j, writeFileSync as d } from "node:fs";
2
- import { writeFile as _ } from "node:fs/promises";
3
- import { resolve as l, join as h } from "node:path";
4
- import { setDebug as E, getDefaultTheme as v, codeExtract as k, getCss as x, registerTheme as C, getThemeInterface as O } from "@devup-ui/wasm";
5
- import { normalizePath as y } from "vite";
6
- function D(e) {
7
- var i;
8
- if (f(e.interfacePath) || $(e.interfacePath), f(e.devupPath)) {
9
- C(
10
- (i = JSON.parse(j(e.devupPath, "utf-8"))) == null ? void 0 : i.theme
11
- );
12
- const s = O(
13
- e.package,
14
- "DevupThemeColors",
15
- "DevupThemeTypography",
16
- "DevupTheme"
17
- );
18
- s && d(h(e.interfacePath, "theme.d.ts"), s, {
19
- encoding: "utf-8"
20
- });
1
+ import { existsSync as p } from "node:fs";
2
+ import { writeFile as f, mkdir as k, readFile as W } from "node:fs/promises";
3
+ import { relative as C, dirname as N, resolve as l, join as c, basename as E } from "node:path";
4
+ import { setDebug as O, codeExtract as U, getCss as w, getDefaultTheme as A, registerTheme as g, getThemeInterface as B } from "@devup-ui/wasm";
5
+ function F(s) {
6
+ return s.endsWith("devup-ui.css") ? null : parseInt(s.split("devup-ui-")[1].split(".")[0]);
7
+ }
8
+ async function _(s) {
9
+ var a;
10
+ try {
11
+ const u = p(s.devupFile) ? await W(s.devupFile, "utf-8") : void 0;
12
+ if (u) {
13
+ g(((a = JSON.parse(u)) == null ? void 0 : a.theme) ?? {});
14
+ const i = B(
15
+ s.package,
16
+ "DevupThemeColors",
17
+ "DevupThemeTypography",
18
+ "DevupTheme"
19
+ );
20
+ i && await f(
21
+ c(s.distDir, "theme.d.ts"),
22
+ i,
23
+ "utf-8"
24
+ );
25
+ } else
26
+ g({});
27
+ } catch (u) {
28
+ console.error(u), g({});
21
29
  }
22
- f(e.cssFile) || d(e.cssFile, "", {
23
- encoding: "utf-8"
24
- }), d(h(e.interfacePath, ".gitignore"), "*", {
25
- encoding: "utf-8"
26
- });
30
+ await Promise.all([
31
+ p(s.cssDir) ? Promise.resolve() : k(s.cssDir, { recursive: !0 }),
32
+ s.singleCss ? Promise.resolve() : f(c(s.cssDir, "devup-ui.css"), w(null, !1))
33
+ ]);
27
34
  }
28
- let c = "";
29
35
  function z({
30
- package: e = "@devup-ui/react",
31
- devupPath: i = "devup.json",
32
- interfacePath: s = "df",
33
- cssFile: u = l(s, "devup-ui.css"),
34
- extractCss: a = !0,
35
- debug: w = !1,
36
- include: m = []
36
+ package: s = "@devup-ui/react",
37
+ devupFile: a = "devup.json",
38
+ distDir: u = "df",
39
+ cssDir: i = l(u, "devup-ui"),
40
+ extractCss: m = !0,
41
+ debug: x = !1,
42
+ include: y = [],
43
+ singleCss: d = !1
37
44
  } = {}) {
38
- E(w);
39
- try {
40
- D({
41
- package: e,
42
- cssFile: u,
43
- devupPath: i,
44
- interfacePath: s
45
- });
46
- } catch (t) {
47
- console.error(t);
48
- }
49
- const g = v();
50
- return g && JSON.stringify(g), {
45
+ O(x);
46
+ const o = /* @__PURE__ */ new Map();
47
+ return {
51
48
  name: "devup-ui",
49
+ async configResolved() {
50
+ p(u) || await k(u, { recursive: !0 }), await f(c(u, ".gitignore"), "*", "utf-8"), await _({
51
+ package: s,
52
+ cssDir: i,
53
+ devupFile: a,
54
+ distDir: u,
55
+ singleCss: d
56
+ });
57
+ },
52
58
  config() {
53
- const t = v(), r = {};
54
- t && (r["process.env.DEVUP_UI_DEFAULT_THEME"] = JSON.stringify(t));
55
- const n = {
59
+ const r = A(), e = {};
60
+ r && (e["process.env.DEVUP_UI_DEFAULT_THEME"] = JSON.stringify(r));
61
+ const t = {
56
62
  server: {
57
63
  watch: {
58
- ignored: [`!${i}`]
64
+ ignored: [`!${a}`]
59
65
  }
60
66
  },
61
- define: r,
67
+ define: e,
62
68
  optimizeDeps: {
63
- exclude: m
69
+ exclude: y
64
70
  }
65
71
  };
66
- return a && (n.build = {
72
+ return m && (t.build = {
67
73
  rollupOptions: {
68
74
  output: {
69
- manualChunks(o) {
70
- if (o.startsWith("devup-ui.css"))
75
+ manualChunks(n) {
76
+ if (n.split("?")[0].endsWith("devup-ui.css"))
71
77
  return "devup-ui.css";
72
78
  }
73
79
  }
74
80
  }
75
- }), n;
81
+ }), t;
76
82
  },
77
83
  apply() {
78
84
  return !0;
79
85
  },
80
- watchChange(t) {
81
- if (l(t) === l(i) && f(i))
86
+ async watchChange(r) {
87
+ if (l(r) === l(a) && p(a))
82
88
  try {
83
- D({
84
- package: e,
85
- cssFile: u,
86
- devupPath: i,
87
- interfacePath: s
89
+ await _({
90
+ package: s,
91
+ cssDir: i,
92
+ devupFile: a,
93
+ distDir: u,
94
+ singleCss: d
88
95
  });
89
- } catch (r) {
90
- console.error(r);
96
+ } catch (e) {
97
+ console.error(e);
91
98
  }
92
99
  },
93
- resolveId(t) {
94
- if (y(t) === y(u))
95
- return `devup-ui.css?t=${Date.now().toString() + c.length}`;
100
+ resolveId(r, e) {
101
+ var t;
102
+ if (r.includes("devup-ui.css") && l(e ? c(N(e), r) : r) === l(c(i, "devup-ui.css")))
103
+ return c(
104
+ i,
105
+ `devup-ui.css?t=${Date.now().toString() + (((t = o.get(null)) == null ? void 0 : t.length) ?? 0)}`
106
+ );
96
107
  },
97
- load(t) {
98
- if (t.split("?")[0] === "devup-ui.css")
99
- return c = x();
108
+ load(r) {
109
+ const e = E(r).split("?")[0];
110
+ if (e.startsWith("devup-ui") && e.endsWith(".css")) {
111
+ const t = F(e), n = w(t, !1);
112
+ return o.set(t, n), n;
113
+ }
100
114
  },
101
115
  enforce: "pre",
102
- async transform(t, r) {
103
- if (!a) return;
104
- const n = r.split("?")[0];
105
- if ((m.length ? new RegExp(
106
- `node_modules(?!(${m.map((S) => `.*${S}`).join("|").replaceAll("/", "[\\/\\\\_]")})([\\/\\\\.]|$))`
107
- ).test(n) : r.includes("node_modules")) || !/\.(tsx|ts|js|mjs|jsx)$/i.test(n)) return;
116
+ async transform(r, e) {
117
+ if (!m) return;
118
+ const t = e.split("?")[0];
119
+ if (!/\.(tsx|ts|js|mjs|jsx)$/i.test(t) || new RegExp(
120
+ `node_modules(?!.*(${["@devup-ui", ...y].join("|").replaceAll("/", "[\\/\\\\_]")})([\\/\\\\.]|$))`
121
+ ).test(t))
122
+ return;
123
+ let n = C(N(e), i).replaceAll("\\", "/");
124
+ n.startsWith("./") || (n = `./${n}`);
108
125
  const {
109
- code: o,
110
- css: p,
111
- map: T
112
- } = k(n, t, e, u);
113
- return p && c.length < p.length && (c = p, await _(u, `/* ${r} ${Date.now()} */`, {
114
- encoding: "utf-8"
115
- })), {
116
- code: o,
117
- map: T
126
+ code: D,
127
+ css: v,
128
+ map: I,
129
+ cssFile: T,
130
+ updatedBaseStyle: S
131
+ // import main css in code
132
+ } = U(t, r, s, n, d, !0, !1), h = [];
133
+ if (S && h.push(
134
+ f(c(i, "devup-ui.css"), w(null, !1), "utf-8")
135
+ ), v) {
136
+ const $ = F(T), j = o.get($);
137
+ j && j.length < v.length && o.set($, v), h.push(
138
+ f(
139
+ c(i, E(T)),
140
+ `/* ${e} ${Date.now()} */`,
141
+ "utf-8"
142
+ )
143
+ );
144
+ }
145
+ return await Promise.all(h), {
146
+ code: D,
147
+ map: I
118
148
  };
119
149
  },
120
- async generateBundle(t, r) {
121
- if (!a) return;
122
- const n = Object.keys(r).find(
123
- (o) => o.includes("devup-ui") && o.endsWith(".css")
150
+ async generateBundle(r, e) {
151
+ if (!m) return;
152
+ const t = Object.keys(e).find(
153
+ (n) => e[n].name === "devup-ui.css"
124
154
  );
125
- n && "source" in r[n] && (r[n].source = c);
155
+ t && "source" in e[t] && (e[t].source = o.get(null));
126
156
  }
127
157
  };
128
158
  }
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "vite"
19
19
  ],
20
20
  "type": "module",
21
- "version": "1.0.32",
21
+ "version": "1.0.34",
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
@@ -36,7 +36,7 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@devup-ui/wasm": "1.0.32"
39
+ "@devup-ui/wasm": "1.0.34"
40
40
  },
41
41
  "devDependencies": {
42
42
  "vite-plugin-dts": "^4.5.4",