niuma-ui 1.2.2 → 1.2.3

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/CHANGELOG.md CHANGED
@@ -6,6 +6,13 @@
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.2.3] - 2026-08-30
10
+
11
+ ### 修复
12
+
13
+ - 库打包把脚本里的 `import './x.css'` 写回入口。此前 Vite 收成 empty css 注释,`RsTable` 的 `rs-table.css`、Monaco 调试装饰等旁路样式进不了 npm,Ops 等宿主生产表格 / 编辑器与 `pnpm dev` 对不齐。
14
+ - `niumaUiHost` 给 `styles.css` 补 Tailwind `@source`(宿主根 + 包内 components/composables)。CI 只处理 `node_modules` 里的 CSS 时,扫描范围与本机联调源码一致。
15
+
9
16
  ## [1.2.2] - 2026-08-30
10
17
 
11
18
  ### 修复
@@ -1,3 +1,4 @@
1
+ import '../monaco/debug-decorations.css'
1
2
  import './RsMonacoEditor.css'
2
3
  import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-helper.js";
3
4
  import RsMonacoEditor_vue_vue_type_script_setup_true_lang_default from "./RsMonacoEditor.impl.js";
@@ -1,3 +1,4 @@
1
+ import './table/rs-table.css'
1
2
  import RsTable_vue_vue_type_script_setup_true_lang_default from "./RsTable.impl.js";
2
3
  //#region src/components/RsTable.vue
3
4
  var RsTable_default = RsTable_vue_vue_type_script_setup_true_lang_default;
@@ -1,4 +1,5 @@
1
- /* empty css */
1
+ import './debug-decorations.css'
2
+
2
3
  //#region src/monaco/debug-decorations.ts
3
4
  var RS_MONACO_DEBUG = {
4
5
  bpGlyph: "rs-monaco-debug-bp",
package/dist/styles.css CHANGED
@@ -1,4 +1,6 @@
1
1
  @import 'tailwindcss';
2
+ @source './components';
3
+ @source './composables';
2
4
 
3
5
  html[dir='ltr'],
4
6
  [data-sonner-toaster][dir='ltr'] {
@@ -15,6 +15,10 @@ export type NiumaUiBinding = {
15
15
  * NiumaUiHost 返回一组插件(Vite 会摊平)。serve 做 styles alias,两侧都改写具名导入。
16
16
  */
17
17
  export declare function niumaUiHost(options?: NiumaUiHostOptions): Plugin[];
18
+ /**
19
+ * ToSourceRel 把目录收成 Tailwind @source 可用的相对路径。
20
+ */
21
+ export declare function toSourceRel(fromDir: string, targetDir: string): string;
18
22
  /**
19
23
  * RewriteHostStatement 改写一条已由 lexer 切出的静态 import/export。
20
24
  * 类型-only、namespace、动态 import 原样返回 null。
@@ -7,7 +7,7 @@
7
7
  * apply / configResolved 区分 serve 与 build。
8
8
  */
9
9
  import { existsSync, readFileSync } from 'node:fs';
10
- import { dirname, join } from 'node:path';
10
+ import { dirname, join, relative } from 'node:path';
11
11
  import { createRequire } from 'node:module';
12
12
  import { createFilter } from '@rollup/pluginutils';
13
13
  import { init, parse } from 'es-module-lexer';
@@ -20,12 +20,13 @@ export function niumaUiHost(options = {}) {
20
20
  const root = options.root ?? resolvePkgRoot();
21
21
  const ctx = {
22
22
  root,
23
+ viteRoot: process.cwd(),
23
24
  hasSrc: existsSync(join(root, 'src/index.ts')),
24
25
  useSource: false,
25
26
  map: loadRuntimeBindings(root),
26
27
  filter: createFilter(options.include ?? [/\.([cm]?[jt]sx?|vue)(?:$|\?)/], options.exclude ?? [/\/node_modules\//]),
27
28
  };
28
- return [niumaUiHostAlias(ctx), niumaUiHostRewrite(ctx)];
29
+ return [niumaUiHostAlias(ctx), niumaUiHostRewrite(ctx), niumaUiHostTailwindSource(ctx)];
29
30
  }
30
31
  /**
31
32
  * NiumaUiHostAlias 仅在 serve 且存在 src 时把 styles.css 指到源码,并排除整桶预构建。
@@ -63,6 +64,7 @@ function niumaUiHostRewrite(ctx) {
63
64
  enforce: 'pre',
64
65
  configResolved(config) {
65
66
  ctx.useSource = config.command === 'serve' && ctx.hasSrc;
67
+ ctx.viteRoot = config.root;
66
68
  },
67
69
  async transform(code, id) {
68
70
  if (!ctx.filter(id))
@@ -95,6 +97,57 @@ function niumaUiHostRewrite(ctx) {
95
97
  },
96
98
  };
97
99
  }
100
+ const NIUMA_UI_STYLES = /niuma-ui[\\/](?:src|dist)[\\/]styles\.css$/;
101
+ /**
102
+ * NiumaUiHostTailwindSource 给 niuma-ui/styles.css 补上宿主根与包内扫描目录。
103
+ * CI 只看 node_modules 里的 styles.css 时,Tailwind 否则扫不到官网 / Ops 源码。
104
+ */
105
+ function niumaUiHostTailwindSource(ctx) {
106
+ return {
107
+ name: 'niuma-ui-host:tailwind-source',
108
+ enforce: 'pre',
109
+ configResolved(config) {
110
+ ctx.viteRoot = config.root;
111
+ },
112
+ transform(code, id) {
113
+ const file = id.split('?')[0] ?? id;
114
+ if (!NIUMA_UI_STYLES.test(file.replace(/\\/g, '/')))
115
+ return null;
116
+ if (!code.includes('tailwindcss'))
117
+ return null;
118
+ const cssDir = dirname(file);
119
+ const pkgScan = ctx.useSource && existsSync(join(ctx.root, 'src'))
120
+ ? join(ctx.root, 'src')
121
+ : existsSync(join(ctx.root, 'dist'))
122
+ ? join(ctx.root, 'dist')
123
+ : ctx.root;
124
+ const specs = [ctx.viteRoot, pkgScan]
125
+ .map((dir) => toSourceRel(cssDir, dir))
126
+ .filter((spec, i, all) => all.indexOf(spec) === i);
127
+ const inject = specs
128
+ .filter((spec) => !code.includes(`@source '${spec}'`) && !code.includes(`@source "${spec}"`))
129
+ .map((spec) => `@source '${spec}';`)
130
+ .join('\n');
131
+ if (!inject)
132
+ return null;
133
+ const next = code.replace(/@import\s+['"]tailwindcss['"]\s*;/, `@import 'tailwindcss';\n${inject}`);
134
+ if (next === code)
135
+ return null;
136
+ return { code: next, map: null };
137
+ },
138
+ };
139
+ }
140
+ /**
141
+ * ToSourceRel 把目录收成 Tailwind @source 可用的相对路径。
142
+ */
143
+ export function toSourceRel(fromDir, targetDir) {
144
+ let rel = relative(fromDir, targetDir).replace(/\\/g, '/');
145
+ if (rel === '')
146
+ return '.';
147
+ if (!rel.startsWith('.'))
148
+ rel = `./${rel}`;
149
+ return rel;
150
+ }
98
151
  /**
99
152
  * RewriteHostStatement 改写一条已由 lexer 切出的静态 import/export。
100
153
  * 类型-only、namespace、动态 import 原样返回 null。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "niuma-ui",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Vue 3 工作台设计系统(Rs* 组件、--rs-* token;含可选编辑器 / 终端)",