@devup-ui/rsbuild-plugin 1.0.28 → 1.0.30

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./plugin.cjs");exports.DevupUIRsbuildPlugin=e.DevupUIRsbuildPlugin;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./plugin.cjs");exports.DevupUI=e.DevupUI;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { DevupUIRsbuildPlugin, type DevupUIRsbuildPluginOptions, } from './plugin';
1
+ export { DevupUI, type DevupUIRsbuildPluginOptions } from './plugin';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,UAAU,CAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DevupUIRsbuildPlugin as i } from "./plugin.js";
1
+ import { DevupUI as p } from "./plugin.js";
2
2
  export {
3
- i as DevupUIRsbuildPlugin
3
+ p as DevupUI
4
4
  };
package/dist/plugin.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("node:fs/promises"),d=require("node:path"),w=require("@devup-ui/wasm");let s="";const v=({include:u=[],package:a="@devup-ui/react",extractCss:g=!0,interfacePath:n="df",cssFile:e=d.resolve(n,"devup-ui.css")}={})=>({name:"devup-ui-rsbuild-plugin",async setup(o){g&&(await i.mkdir(n,{recursive:!0}),await i.writeFile(d.join(n,".gitignore"),"*",{encoding:"utf-8"}),await i.writeFile(e,""),o.transform({test:e},()=>s),o.transform({test:/\.(tsx|ts|js|mjs|jsx)$/},async({code:l,resourcePath:t})=>{if(u.length?new RegExp(`node_modules(?!(${u.map(m=>`.*${m}`).join("|").replaceAll("/","[\\/\\\\_]")})([\\/\\\\.]|$))`).test(t):t.includes("node_modules"))return l;const{code:p,css:r,map:c}=w.codeExtract(t,l,a,e);return r&&s.length<r.length&&(s=r,await i.writeFile(e,`/* ${t} ${Date.now()} */`,{encoding:"utf-8"})),{code:p,map:c}}))}});exports.DevupUIRsbuildPlugin=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("node:fs"),i=require("node:fs/promises"),u=require("node:path"),t=require("@devup-ui/wasm");let f="";async function F(e){var l;try{const a=p.existsSync(e.devupFile)?await i.readFile(e.devupFile,"utf-8"):void 0;if(a){t.registerTheme(((l=JSON.parse(a))==null?void 0:l.theme)??{});const r=t.getThemeInterface(e.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");r&&await i.writeFile(u.join(e.distDir,"theme.d.ts"),r,"utf-8")}else t.registerTheme({})}catch(a){console.error(a),t.registerTheme({})}await Promise.all([p.existsSync(e.cssDir)?Promise.resolve():i.mkdir(e.cssDir,{recursive:!0}),e.singleCss?Promise.resolve():i.writeFile(u.join(e.cssDir,"devup-ui.css"),t.getCss(null,!1))])}const D=({include:e=[],package:l="@devup-ui/react",extractCss:a=!0,distDir:r="df",cssDir:n=u.resolve(r,"devup-ui"),devupFile:h="devup.json",debug:g=!1,singleCss:v=!1}={})=>({name:"devup-ui-rsbuild-plugin",async setup(c){t.setDebug(g),p.existsSync(r)||await i.mkdir(r,{recursive:!0}),await i.writeFile(u.join(r,".gitignore"),"*","utf-8"),await F({package:l,cssDir:n,devupFile:h,distDir:r,singleCss:v}),a&&(c.transform({test:n},()=>f),c.modifyRsbuildConfig(s=>(t.getDefaultTheme()&&(s.source??(s.source={}),s.source.define={"process.env.DEVUP_UI_DEFAULT_THEME":JSON.stringify(t.getDefaultTheme()),...s.source.define}),s)),c.transform({test:/\.(tsx|ts|js|mjs|jsx)$/},async({code:s,resourcePath:o})=>{if(new RegExp(`node_modules(?!.*(${["@devup-ui",...e].join("|").replaceAll("/","[\\/\\\\_]")})([\\/\\\\.]|$))`).test(o))return s;const{code:w,css:m,map:y,cssFile:T,updatedBaseStyle:j}=t.codeExtract(o,s,l,n,v,!1,!0),d=[];return j&&d.push(i.writeFile(u.join(n,"devup-ui.css"),t.getCss(null,!1),"utf-8")),m&&(f.length<m.length&&(f=m),d.push(i.writeFile(u.join(n,u.basename(T)),`/* ${o} ${Date.now()} */`,"utf-8"))),await Promise.all(d),{code:w,map:y}}))}});exports.DevupUI=D;
package/dist/plugin.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { RsbuildPlugin } from '@rsbuild/core';
2
2
  export interface DevupUIRsbuildPluginOptions {
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 const DevupUIRsbuildPlugin: ({ include, package: libPackage, extractCss, interfacePath, cssFile, }?: Partial<DevupUIRsbuildPluginOptions>) => RsbuildPlugin;
12
+ export declare const DevupUI: ({ include, package: libPackage, extractCss, distDir, cssDir, devupFile, debug, singleCss, }?: Partial<DevupUIRsbuildPluginOptions>) => RsbuildPlugin;
12
13
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,WAAW,2BAA2B;IAC1C,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;AAID,eAAO,MAAM,oBAAoB,GAAI,wEAMlC,OAAO,CAAC,2BAA2B,CAAM,KAAG,aAqD7C,CAAA"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,WAAW,2BAA2B;IAC1C,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,eAAO,MAAM,OAAO,GAAI,8FASrB,OAAO,CAAC,2BAA2B,CAAM,KAAG,aA+F7C,CAAA"}
package/dist/plugin.js CHANGED
@@ -1,47 +1,105 @@
1
- import { mkdir as f, writeFile as r } from "node:fs/promises";
2
- import { join as c, resolve as w } from "node:path";
3
- import { codeExtract as v } from "@devup-ui/wasm";
4
- let i = "";
5
- const b = ({
6
- include: s = [],
7
- package: m = "@devup-ui/react",
8
- extractCss: a = !0,
9
- interfacePath: n = "df",
10
- cssFile: t = w(n, "devup-ui.css")
1
+ import { existsSync as d } from "node:fs";
2
+ import { mkdir as w, writeFile as l, readFile as D } from "node:fs/promises";
3
+ import { join as i, resolve as E, basename as _ } from "node:path";
4
+ import { setDebug as $, getDefaultTheme as h, codeExtract as b, getCss as g, registerTheme as p, getThemeInterface as S } from "@devup-ui/wasm";
5
+ let c = "";
6
+ async function U(e) {
7
+ var u;
8
+ try {
9
+ const s = d(e.devupFile) ? await D(e.devupFile, "utf-8") : void 0;
10
+ if (s) {
11
+ p(((u = JSON.parse(s)) == null ? void 0 : u.theme) ?? {});
12
+ const r = S(
13
+ e.package,
14
+ "DevupThemeColors",
15
+ "DevupThemeTypography",
16
+ "DevupTheme"
17
+ );
18
+ r && await l(
19
+ i(e.distDir, "theme.d.ts"),
20
+ r,
21
+ "utf-8"
22
+ );
23
+ } else
24
+ p({});
25
+ } catch (s) {
26
+ console.error(s), p({});
27
+ }
28
+ await Promise.all([
29
+ d(e.cssDir) ? Promise.resolve() : w(e.cssDir, { recursive: !0 }),
30
+ e.singleCss ? Promise.resolve() : l(i(e.cssDir, "devup-ui.css"), g(null, !1))
31
+ ]);
32
+ }
33
+ const N = ({
34
+ include: e = [],
35
+ package: u = "@devup-ui/react",
36
+ extractCss: s = !0,
37
+ distDir: r = "df",
38
+ cssDir: a = E(r, "devup-ui"),
39
+ devupFile: y = "devup.json",
40
+ debug: T = !1,
41
+ singleCss: v = !1
11
42
  } = {}) => ({
12
43
  name: "devup-ui-rsbuild-plugin",
13
- async setup(u) {
14
- a && (await f(n, { recursive: !0 }), await r(c(n, ".gitignore"), "*", {
15
- encoding: "utf-8"
16
- }), await r(t, ""), u.transform(
44
+ async setup(o) {
45
+ $(T), d(r) || await w(r, { recursive: !0 }), await l(i(r, ".gitignore"), "*", "utf-8"), await U({
46
+ package: u,
47
+ cssDir: a,
48
+ devupFile: y,
49
+ distDir: r,
50
+ singleCss: v
51
+ }), s && (o.transform(
17
52
  {
18
- test: t
53
+ test: a
19
54
  },
20
- () => i
21
- ), u.transform(
55
+ () => c
56
+ ), o.modifyRsbuildConfig((t) => (h() && (t.source ?? (t.source = {}), t.source.define = {
57
+ "process.env.DEVUP_UI_DEFAULT_THEME": JSON.stringify(h()),
58
+ ...t.source.define
59
+ }), t)), o.transform(
22
60
  {
23
61
  test: /\.(tsx|ts|js|mjs|jsx)$/
24
62
  },
25
- async ({ code: d, resourcePath: e }) => {
26
- if (s.length ? new RegExp(
27
- `node_modules(?!(${s.map((g) => `.*${g}`).join("|").replaceAll("/", "[\\/\\\\_]")})([\\/\\\\.]|$))`
28
- ).test(e) : e.includes("node_modules"))
29
- return d;
63
+ async ({ code: t, resourcePath: m }) => {
64
+ if (new RegExp(
65
+ `node_modules(?!.*(${["@devup-ui", ...e].join("|").replaceAll("/", "[\\/\\\\_]")})([\\/\\\\.]|$))`
66
+ ).test(m))
67
+ return t;
30
68
  const {
31
- code: l,
32
- css: o,
33
- map: p
34
- } = v(e, d, m, t);
35
- return o && i.length < o.length && (i = o, await r(t, `/* ${e} ${Date.now()} */`, {
36
- encoding: "utf-8"
37
- })), {
38
- code: l,
39
- map: p
69
+ code: F,
70
+ css: f,
71
+ map: j,
72
+ cssFile: x,
73
+ updatedBaseStyle: C
74
+ } = b(
75
+ m,
76
+ t,
77
+ u,
78
+ a,
79
+ v,
80
+ !1,
81
+ !0
82
+ ), n = [];
83
+ return C && n.push(
84
+ l(
85
+ i(a, "devup-ui.css"),
86
+ g(null, !1),
87
+ "utf-8"
88
+ )
89
+ ), f && (c.length < f.length && (c = f), n.push(
90
+ l(
91
+ i(a, _(x)),
92
+ `/* ${m} ${Date.now()} */`,
93
+ "utf-8"
94
+ )
95
+ )), await Promise.all(n), {
96
+ code: F,
97
+ map: j
40
98
  };
41
99
  }
42
100
  ));
43
101
  }
44
102
  });
45
103
  export {
46
- b as DevupUIRsbuildPlugin
104
+ N as DevupUI
47
105
  };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rsbuild"
19
19
  ],
20
20
  "type": "module",
21
- "version": "1.0.28",
21
+ "version": "1.0.30",
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
@@ -45,15 +45,15 @@
45
45
  "dist"
46
46
  ],
47
47
  "dependencies": {
48
- "@devup-ui/wasm": "1.0.32"
48
+ "@devup-ui/wasm": "1.0.34"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@devup-ui/wasm": "*",
52
52
  "@rsbuild/core": "*"
53
53
  },
54
54
  "devDependencies": {
55
- "@rsbuild/core": "^1.4.15",
56
- "vite": "^7.1.3",
55
+ "@rsbuild/core": "^1.5.3",
56
+ "vite": "^7.1.4",
57
57
  "vite-plugin-dts": "^4.5.4",
58
58
  "vitest": "^3.2.4",
59
59
  "typescript": "^5.9.2"