niuma-ui 1.2.2 → 1.2.4
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 +13 -0
- package/dist/components/RsMonacoEditor.js +1 -0
- package/dist/components/RsTable.js +1 -0
- package/dist/monaco/debug-decorations2.js +2 -1
- package/dist/styles.css +16 -0
- package/dist/vite-plugins/niuma-ui-host.d.ts +4 -0
- package/dist/vite-plugins/niuma-ui-host.js +55 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,19 @@
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.2.4] - 2026-08-30
|
|
10
|
+
|
|
11
|
+
### 变更
|
|
12
|
+
|
|
13
|
+
- `styles.css` 自己收口盒模型:`html { box-sizing: border-box }`,其余 `inherit`。Rs* 宽高不再赌宿主 Tailwind Preflight。
|
|
14
|
+
|
|
15
|
+
## [1.2.3] - 2026-08-30
|
|
16
|
+
|
|
17
|
+
### 修复
|
|
18
|
+
|
|
19
|
+
- 库打包把脚本里的 `import './x.css'` 写回入口。此前 Vite 收成 empty css 注释,`RsTable` 的 `rs-table.css`、Monaco 调试装饰等旁路样式进不了 npm,Ops 等宿主生产表格 / 编辑器与 `pnpm dev` 对不齐。
|
|
20
|
+
- `niumaUiHost` 给 `styles.css` 补 Tailwind `@source`(宿主根 + 包内 components/composables)。CI 只处理 `node_modules` 里的 CSS 时,扫描范围与本机联调源码一致。
|
|
21
|
+
|
|
9
22
|
## [1.2.2] - 2026-08-30
|
|
10
23
|
|
|
11
24
|
### 修复
|
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'] {
|
|
@@ -643,6 +645,20 @@ to {
|
|
|
643
645
|
}
|
|
644
646
|
|
|
645
647
|
|
|
648
|
+
/*
|
|
649
|
+
* 盒模型由本包收口,不依赖宿主 Tailwind Preflight 有没有进 @layer。
|
|
650
|
+
* 对齐 Ant Design reset / Arco:html 定 border-box,其余 inherit(弹出层挂 body 也一致)。
|
|
651
|
+
*/
|
|
652
|
+
html {
|
|
653
|
+
box-sizing: border-box;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
*,
|
|
657
|
+
*::before,
|
|
658
|
+
*::after {
|
|
659
|
+
box-sizing: inherit;
|
|
660
|
+
}
|
|
661
|
+
|
|
646
662
|
/* ── 静态 token(不随明暗变化) ── */
|
|
647
663
|
:root {
|
|
648
664
|
--rs-radius-xs: 0.25rem;
|
|
@@ -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。
|