@devup-ui/vite-plugin 1.0.31 → 1.0.33

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 d=require("node:fs"),l=require("node:fs/promises"),n=require("node:path"),c=require("@devup-ui/wasm");function g(e){return e.endsWith("devup-ui.css")?null:parseInt(e.split("devup-ui-")[1].split(".")[0])}async function _(e){var a;try{const i=d.existsSync(e.devupFile)?await l.readFile(e.devupFile,"utf-8"):void 0;if(i){c.registerTheme(((a=JSON.parse(i))==null?void 0:a.theme)??{});const o=c.getThemeInterface(e.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");o&&await l.writeFile(n.join(e.distDir,"theme.d.ts"),o,"utf-8")}else c.registerTheme({})}catch(i){console.error(i),c.registerTheme({})}await Promise.all([d.existsSync(e.cssDir)?Promise.resolve():l.mkdir(e.cssDir,{recursive:!0}),e.singleCss?Promise.resolve():l.writeFile(n.join(e.cssDir,"devup-ui.css"),c.getCss())])}const m=new Map;function N({package:e="@devup-ui/react",devupFile:a="devup.json",distDir:i="df",cssDir:o=n.resolve(i,"devup-ui"),extractCss:v=!0,debug:D=!1,include:w=[],singleCss:f=!1}={}){return c.setDebug(D),{name:"devup-ui",async configResolved(){d.existsSync(i)||await l.mkdir(i,{recursive:!0}),await l.writeFile(n.join(i,".gitignore"),"*","utf-8"),await _({package:e,cssDir:o,devupFile:a,distDir:i,singleCss:f})},config(){const u=c.getDefaultTheme(),t={};u&&(t["process.env.DEVUP_UI_DEFAULT_THEME"]=JSON.stringify(u));const s={server:{watch:{ignored:[`!${a}`]}},define:t,optimizeDeps:{exclude:w}};return v&&(s.build={rollupOptions:{output:{manualChunks(r){if(f&&r.endsWith("devup-ui.css"))return"devup-ui.css"}}}}),s},apply(){return!0},async watchChange(u){if(n.resolve(u)===n.resolve(a)&&d.existsSync(a))try{await _({package:e,cssDir:o,devupFile:a,distDir:i,singleCss:f})}catch(t){console.error(t)}},load(u){const t=n.basename(u).split("?")[0];if(t.startsWith("devup-ui")&&t.endsWith(".css")){const s=g(u),r=c.getCss(s);return m.set(s,r),r}},enforce:"pre",async transform(u,t){if(!v)return;const s=t.split("?")[0];if(!/\.(tsx|ts|js|mjs|jsx)$/i.test(s)||new RegExp(`node_modules(?!.*(${["@devup-ui",...w].join("|").replaceAll("/","[\\/\\\\_]")})([\\/\\\\.]|$))`).test(s))return;let r=n.relative(n.dirname(t),o).replaceAll("\\","/");r.startsWith("./")||(r=`./${r}`);const{code:p,css:h,map:F,css_file:y}=c.codeExtract(s,u,e,r,f);if(h){const T=g(y),j=m.get(T);j&&j.length<h.length&&m.set(T,h),await l.writeFile(n.join(o,n.basename(y)),`/* ${t} ${Date.now()} */`,"utf-8")}return{code:p,map:F}},async generateBundle(u,t){if(!v)return;const s=Object.keys(t).find(r=>r.includes("devup-ui")&&r.endsWith(".css"));if(s&&"source"in t[s]){const r=g(s),p=m.get(r);p&&(t[s].source=p)}}}}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;AAkDD,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,CAmInD"}
package/dist/plugin.js CHANGED
@@ -1,131 +1,149 @@
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 l } from "node:fs";
2
+ import { writeFile as p, mkdir as $, readFile as x } from "node:fs/promises";
3
+ import { relative as F, dirname as I, resolve as h, join as m, basename as D } from "node:path";
4
+ import { setDebug as O, codeExtract as U, getCss as E, getDefaultTheme as A, registerTheme as g, getThemeInterface as C } from "@devup-ui/wasm";
5
+ function w(e) {
6
+ return e.endsWith("devup-ui.css") ? null : parseInt(e.split("devup-ui-")[1].split(".")[0]);
7
+ }
8
+ async function _(e) {
9
+ var u;
10
+ try {
11
+ const i = l(e.devupFile) ? await x(e.devupFile, "utf-8") : void 0;
12
+ if (i) {
13
+ g(((u = JSON.parse(i)) == null ? void 0 : u.theme) ?? {});
14
+ const c = C(
15
+ e.package,
16
+ "DevupThemeColors",
17
+ "DevupThemeTypography",
18
+ "DevupTheme"
19
+ );
20
+ c && await p(
21
+ m(e.distDir, "theme.d.ts"),
22
+ c,
23
+ "utf-8"
24
+ );
25
+ } else
26
+ g({});
27
+ } catch (i) {
28
+ console.error(i), 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
+ l(e.cssDir) ? Promise.resolve() : $(e.cssDir, { recursive: !0 }),
32
+ e.singleCss ? Promise.resolve() : p(m(e.cssDir, "devup-ui.css"), E())
33
+ ]);
27
34
  }
28
- let c = "";
29
- function z({
35
+ const f = /* @__PURE__ */ new Map();
36
+ function P({
30
37
  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 = []
38
+ devupFile: u = "devup.json",
39
+ distDir: i = "df",
40
+ cssDir: c = h(i, "devup-ui"),
41
+ extractCss: d = !0,
42
+ debug: W = !1,
43
+ include: y = [],
44
+ singleCss: a = !1
37
45
  } = {}) {
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), {
46
+ return O(W), {
51
47
  name: "devup-ui",
48
+ async configResolved() {
49
+ l(i) || await $(i, { recursive: !0 }), await p(m(i, ".gitignore"), "*", "utf-8"), await _({
50
+ package: e,
51
+ cssDir: c,
52
+ devupFile: u,
53
+ distDir: i,
54
+ singleCss: a
55
+ });
56
+ },
52
57
  config() {
53
- const t = v(), r = {};
54
- t && (r["process.env.DEVUP_UI_DEFAULT_THEME"] = JSON.stringify(t));
55
- const n = {
58
+ const n = A(), t = {};
59
+ n && (t["process.env.DEVUP_UI_DEFAULT_THEME"] = JSON.stringify(n));
60
+ const r = {
56
61
  server: {
57
62
  watch: {
58
- ignored: [`!${i}`]
63
+ ignored: [`!${u}`]
59
64
  }
60
65
  },
61
- define: r,
66
+ define: t,
62
67
  optimizeDeps: {
63
- exclude: m
68
+ exclude: y
64
69
  }
65
70
  };
66
- return a && (n.build = {
71
+ return d && (r.build = {
67
72
  rollupOptions: {
68
73
  output: {
69
- manualChunks(o) {
70
- if (o.startsWith("devup-ui.css"))
74
+ manualChunks(s) {
75
+ if (a && s.endsWith("devup-ui.css"))
71
76
  return "devup-ui.css";
72
77
  }
73
78
  }
74
79
  }
75
- }), n;
80
+ }), r;
76
81
  },
77
82
  apply() {
78
83
  return !0;
79
84
  },
80
- watchChange(t) {
81
- if (l(t) === l(i) && f(i))
85
+ async watchChange(n) {
86
+ if (h(n) === h(u) && l(u))
82
87
  try {
83
- D({
88
+ await _({
84
89
  package: e,
85
- cssFile: u,
86
- devupPath: i,
87
- interfacePath: s
90
+ cssDir: c,
91
+ devupFile: u,
92
+ distDir: i,
93
+ singleCss: a
88
94
  });
89
- } catch (r) {
90
- console.error(r);
95
+ } catch (t) {
96
+ console.error(t);
91
97
  }
92
98
  },
93
- resolveId(t) {
94
- if (y(t) === y(u))
95
- return `devup-ui.css?t=${Date.now().toString() + c.length}`;
96
- },
97
- load(t) {
98
- if (t.split("?")[0] === "devup-ui.css")
99
- return c = x();
99
+ load(n) {
100
+ const t = D(n).split("?")[0];
101
+ if (t.startsWith("devup-ui") && t.endsWith(".css")) {
102
+ const r = w(n), s = E(r);
103
+ return f.set(r, s), s;
104
+ }
100
105
  },
101
106
  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;
107
+ async transform(n, t) {
108
+ if (!d) return;
109
+ const r = t.split("?")[0];
110
+ if (!/\.(tsx|ts|js|mjs|jsx)$/i.test(r) || new RegExp(
111
+ `node_modules(?!.*(${["@devup-ui", ...y].join("|").replaceAll("/", "[\\/\\\\_]")})([\\/\\\\.]|$))`
112
+ ).test(r))
113
+ return;
114
+ let s = F(I(t), c).replaceAll("\\", "/");
115
+ s.startsWith("./") || (s = `./${s}`);
108
116
  const {
109
117
  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
- })), {
118
+ css: v,
119
+ map: k,
120
+ css_file: T
121
+ } = U(r, n, e, s, a);
122
+ if (v) {
123
+ const N = w(T), j = f.get(N);
124
+ j && j.length < v.length && f.set(N, v), await p(
125
+ m(c, D(T)),
126
+ `/* ${t} ${Date.now()} */`,
127
+ "utf-8"
128
+ );
129
+ }
130
+ return {
116
131
  code: o,
117
- map: T
132
+ map: k
118
133
  };
119
134
  },
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")
135
+ async generateBundle(n, t) {
136
+ if (!d) return;
137
+ const r = Object.keys(t).find(
138
+ (s) => s.includes("devup-ui") && s.endsWith(".css")
124
139
  );
125
- n && "source" in r[n] && (r[n].source = c);
140
+ if (r && "source" in t[r]) {
141
+ const s = w(r), o = f.get(s);
142
+ o && (t[r].source = o);
143
+ }
126
144
  }
127
145
  };
128
146
  }
129
147
  export {
130
- z as DevupUI
148
+ P as DevupUI
131
149
  };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "vite"
19
19
  ],
20
20
  "type": "module",
21
- "version": "1.0.31",
21
+ "version": "1.0.33",
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.31"
39
+ "@devup-ui/wasm": "1.0.33"
40
40
  },
41
41
  "devDependencies": {
42
42
  "vite-plugin-dts": "^4.5.4",