@devup-ui/rsbuild-plugin 1.0.27 → 1.0.29

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 f=require("node:fs"),i=require("node:fs/promises"),a=require("node:path"),r=require("@devup-ui/wasm");let d="";async function T(e){var n;try{const u=f.existsSync(e.devupFile)?await i.readFile(e.devupFile,"utf-8"):void 0;if(u){r.registerTheme(((n=JSON.parse(u))==null?void 0:n.theme)??{});const s=r.getThemeInterface(e.package,"DevupThemeColors","DevupThemeTypography","DevupTheme");s&&await i.writeFile(a.join(e.distDir,"theme.d.ts"),s,"utf-8")}else r.registerTheme({})}catch(u){console.error(u),r.registerTheme({})}await Promise.all([f.existsSync(e.cssDir)?Promise.resolve():i.mkdir(e.cssDir,{recursive:!0}),e.singleCss?Promise.resolve():i.writeFile(a.join(e.cssDir,"devup-ui.css"),r.getCss())])}const j=({include:e=[],package:n="@devup-ui/react",extractCss:u=!0,distDir:s="df",cssDir:l=a.resolve(s,"devup-ui"),devupFile:p="devup.json",debug:h=!1,singleCss:v=!1}={})=>({name:"devup-ui-rsbuild-plugin",async setup(c){r.setDebug(h),f.existsSync(s)||await i.mkdir(s,{recursive:!0}),await i.writeFile(a.join(s,".gitignore"),"*","utf-8"),await T({package:n,cssDir:l,devupFile:p,distDir:s,singleCss:v}),u&&(c.transform({test:l},()=>d),c.modifyRsbuildConfig(t=>(r.getDefaultTheme()&&(t.source??(t.source={}),t.source.define={"process.env.DEVUP_UI_DEFAULT_THEME":JSON.stringify(r.getDefaultTheme()),...t.source.define}),t)),c.transform({test:/\.(tsx|ts|js|mjs|jsx)$/},async({code:t,resourcePath:o})=>{if(new RegExp(`node_modules(?!.*(${["@devup-ui",...e].join("|").replaceAll("/","[\\/\\\\_]")})([\\/\\\\.]|$))`).test(o))return t;const{code:g,css:m,map:w,css_file:y}=r.codeExtract(o,t,n,l,v);return m&&(d.length<m.length&&(d=m),await i.writeFile(a.join(l,a.basename(y)),`/* ${o} ${Date.now()} */`,"utf-8")),{code:g,map:w}}))}});exports.DevupUI=j;
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,aAwE7C,CAAA"}
package/dist/plugin.js CHANGED
@@ -1,47 +1,88 @@
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 h, writeFile as m, readFile as j } from "node:fs/promises";
3
+ import { join as l, resolve as x, basename as C } from "node:path";
4
+ import { setDebug as E, getDefaultTheme as v, codeExtract as F, registerTheme as f, getThemeInterface as _, getCss as $ } from "@devup-ui/wasm";
5
+ let c = "";
6
+ async function b(e) {
7
+ var a;
8
+ try {
9
+ const s = d(e.devupFile) ? await j(e.devupFile, "utf-8") : void 0;
10
+ if (s) {
11
+ f(((a = JSON.parse(s)) == null ? void 0 : a.theme) ?? {});
12
+ const r = _(
13
+ e.package,
14
+ "DevupThemeColors",
15
+ "DevupThemeTypography",
16
+ "DevupTheme"
17
+ );
18
+ r && await m(
19
+ l(e.distDir, "theme.d.ts"),
20
+ r,
21
+ "utf-8"
22
+ );
23
+ } else
24
+ f({});
25
+ } catch (s) {
26
+ console.error(s), f({});
27
+ }
28
+ await Promise.all([
29
+ d(e.cssDir) ? Promise.resolve() : h(e.cssDir, { recursive: !0 }),
30
+ e.singleCss ? Promise.resolve() : m(l(e.cssDir, "devup-ui.css"), $())
31
+ ]);
32
+ }
33
+ const A = ({
34
+ include: e = [],
35
+ package: a = "@devup-ui/react",
36
+ extractCss: s = !0,
37
+ distDir: r = "df",
38
+ cssDir: u = x(r, "devup-ui"),
39
+ devupFile: w = "devup.json",
40
+ debug: g = !1,
41
+ singleCss: p = !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
+ E(g), d(r) || await h(r, { recursive: !0 }), await m(l(r, ".gitignore"), "*", "utf-8"), await b({
46
+ package: a,
47
+ cssDir: u,
48
+ devupFile: w,
49
+ distDir: r,
50
+ singleCss: p
51
+ }), s && (o.transform(
17
52
  {
18
- test: t
53
+ test: u
19
54
  },
20
- () => i
21
- ), u.transform(
55
+ () => c
56
+ ), o.modifyRsbuildConfig((t) => (v() && (t.source ?? (t.source = {}), t.source.define = {
57
+ "process.env.DEVUP_UI_DEFAULT_THEME": JSON.stringify(v()),
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: i }) => {
64
+ if (new RegExp(
65
+ `node_modules(?!.*(${["@devup-ui", ...e].join("|").replaceAll("/", "[\\/\\\\_]")})([\\/\\\\.]|$))`
66
+ ).test(i))
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: y,
70
+ css: n,
71
+ map: T,
72
+ css_file: D
73
+ } = F(i, t, a, u, p);
74
+ return n && (c.length < n.length && (c = n), await m(
75
+ l(u, C(D)),
76
+ `/* ${i} ${Date.now()} */`,
77
+ "utf-8"
78
+ )), {
79
+ code: y,
80
+ map: T
40
81
  };
41
82
  }
42
83
  ));
43
84
  }
44
85
  });
45
86
  export {
46
- b as DevupUIRsbuildPlugin
87
+ A as DevupUI
47
88
  };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rsbuild"
19
19
  ],
20
20
  "type": "module",
21
- "version": "1.0.27",
21
+ "version": "1.0.29",
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
@@ -45,14 +45,14 @@
45
45
  "dist"
46
46
  ],
47
47
  "dependencies": {
48
- "@devup-ui/wasm": "1.0.31"
48
+ "@devup-ui/wasm": "1.0.33"
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",
55
+ "@rsbuild/core": "^1.5.1",
56
56
  "vite": "^7.1.3",
57
57
  "vite-plugin-dts": "^4.5.4",
58
58
  "vitest": "^3.2.4",