@robot-admin/naive-ui-components 0.14.3 → 0.15.0
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 +24 -0
- package/README.md +130 -741
- package/README_EN.md +137 -678
- package/dist/C_ActionBar.css +57 -58
- package/dist/C_ActionBar2.cjs +1 -1
- package/dist/C_ActionBar2.js +1 -1
- package/dist/C_AntV.css +232 -238
- package/dist/C_AntV2.cjs +2 -2
- package/dist/C_AntV2.js +2 -2
- package/dist/C_AudioPlayer.css +9 -9
- package/dist/C_AvatarGroup.css +5 -6
- package/dist/C_Barcode.css +1 -1
- package/dist/C_Breadcrumb.css +15 -18
- package/dist/C_Breadcrumb2.cjs +1 -1
- package/dist/C_Breadcrumb2.js +1 -1
- package/dist/C_Captcha.css +46 -49
- package/dist/C_Captcha2.cjs +1 -1
- package/dist/C_Captcha2.js +1 -1
- package/dist/C_Cascade.css +5 -6
- package/dist/C_Chat.css +8 -8
- package/dist/C_City.css +2 -2
- package/dist/C_Code.css +9 -9
- package/dist/C_CollapsePanel.css +9 -9
- package/dist/C_ContextMenu.css +31 -31
- package/dist/C_Cron.css +271 -274
- package/dist/C_Date.css +1 -1
- package/dist/C_Draggable.css +10 -11
- package/dist/C_Editor.css +2 -2
- package/dist/C_FilePreview.css +423 -423
- package/dist/C_Form.base.css +608 -602
- package/dist/C_Form.cjs +1 -1
- package/dist/C_Form.css +610 -604
- package/dist/C_Form.d.cts +2 -2
- package/dist/C_Form.d.ts +2 -2
- package/dist/C_Form.js +1 -1
- package/dist/C_FormModal.cjs +1 -1
- package/dist/C_FormModal.css +12 -17
- package/dist/C_FormModal.js +1 -1
- package/dist/C_FormModal2.cjs +1 -1
- package/dist/C_FormModal2.js +1 -1
- package/dist/C_FormSearch.css +53 -55
- package/dist/C_FormSearch2.cjs +1 -1
- package/dist/C_FormSearch2.js +1 -1
- package/dist/C_FormulaEditor.css +204 -205
- package/dist/C_FullCalendar.css +13 -15
- package/dist/C_FullCalendar2.cjs +1 -1
- package/dist/C_FullCalendar2.js +1 -1
- package/dist/C_GlobalSearch.css +11 -12
- package/dist/C_Guide.css +10 -10
- package/dist/C_Icon.css +7 -8
- package/dist/C_ImageCropper.css +69 -69
- package/dist/C_Language.css +8 -8
- package/dist/C_Loading.css +22 -25
- package/dist/C_Loading2.cjs +1 -1
- package/dist/C_Loading2.js +1 -1
- package/dist/C_Login.css +130 -135
- package/dist/C_Login2.cjs +1 -1
- package/dist/C_Login2.js +1 -1
- package/dist/C_Map.css +22 -23
- package/dist/C_Markdown.css +6 -7
- package/dist/C_Menu.css +2 -5
- package/dist/C_Menu2.cjs +1 -1
- package/dist/C_Menu2.js +1 -1
- package/dist/C_NotificationCenter.css +252 -253
- package/dist/C_OrgChart.css +8 -8
- package/dist/C_PageLoading.css +34 -39
- package/dist/C_QRCode.css +5 -6
- package/dist/C_Signature.css +5 -6
- package/dist/C_Skeleton.css +2 -2
- package/dist/C_SplitPane.css +2 -2
- package/dist/C_Steps.css +5 -6
- package/dist/C_Table.base.css +1090 -879
- package/dist/C_Table.cjs +1 -1
- package/dist/C_Table.css +1096 -885
- package/dist/C_Table.d.cts +1 -1
- package/dist/C_Table.d.ts +1 -1
- package/dist/C_Table.js +1 -1
- package/dist/C_Tabs.css +5 -6
- package/dist/C_TagsView.css +60 -63
- package/dist/C_TagsView2.cjs +1 -1
- package/dist/C_TagsView2.js +1 -1
- package/dist/C_Theme.css +7 -8
- package/dist/C_Time.css +1 -1
- package/dist/C_Timeline.css +8 -8
- package/dist/C_Transfer.css +10 -11
- package/dist/C_Tree.css +16 -17
- package/dist/C_Upload.css +156 -157
- package/dist/C_VideoPlayer.css +267 -267
- package/dist/C_VtableGantt.css +2 -2
- package/dist/C_WaterFall.css +2 -2
- package/dist/C_WorkFlow.css +466 -470
- package/dist/C_WorkFlow2.cjs +1 -1
- package/dist/C_WorkFlow2.js +1 -1
- package/dist/Card.cjs +1 -0
- package/dist/Card.js +1 -0
- package/dist/Custom.cjs +1 -0
- package/dist/Custom.js +1 -0
- package/dist/Dynamic.cjs +1 -0
- package/dist/Dynamic.js +1 -0
- package/dist/Steps.cjs +1 -0
- package/dist/Steps.js +1 -0
- package/dist/Tabs.cjs +1 -0
- package/dist/Tabs.js +1 -0
- package/dist/cascader.cjs +1 -0
- package/dist/cascader.js +1 -0
- package/dist/color-picker.cjs +1 -0
- package/dist/color-picker.js +1 -0
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants3.d.cts +2 -2
- package/dist/constants3.d.ts +2 -2
- package/dist/constants4.d.cts +4 -4
- package/dist/constants4.d.ts +4 -4
- package/dist/constants5.d.cts +2 -2
- package/dist/constants5.d.ts +2 -2
- package/dist/context.cjs +1 -0
- package/dist/context.js +1 -0
- package/dist/contracts.d.cts +24 -0
- package/dist/contracts.d.ts +24 -0
- package/dist/createPageLoading.cjs +1 -1
- package/dist/createPageLoading.js +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.cts +4 -4
- package/dist/data.d.ts +4 -4
- package/dist/data.js +1 -1
- package/dist/date-picker.cjs +1 -0
- package/dist/date-picker.js +1 -0
- package/dist/feedback.cjs +1 -0
- package/dist/feedback.js +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1 -1
- package/dist/index.vue.d.cts +4 -4
- package/dist/index.vue.d.ts +4 -4
- package/dist/index10.vue.d.cts +3 -3
- package/dist/index10.vue.d.ts +3 -3
- package/dist/index11.vue.d.cts +3 -3
- package/dist/index11.vue.d.ts +2 -2
- package/dist/index12.vue.d.cts +2 -2
- package/dist/index12.vue.d.ts +1 -1
- package/dist/index13.vue.d.cts +1 -1
- package/dist/index13.vue.d.ts +2 -2
- package/dist/index14.vue.d.cts +2 -2
- package/dist/index14.vue.d.ts +7 -7
- package/dist/index15.vue.d.cts +7 -7
- package/dist/index16.vue.d.ts +1 -1
- package/dist/index17.vue.d.cts +1 -1
- package/dist/index17.vue.d.ts +2 -2
- package/dist/index18.vue.d.cts +2 -2
- package/dist/index18.vue.d.ts +2 -2
- package/dist/index19.vue.d.cts +2 -2
- package/dist/index19.vue.d.ts +1 -8
- package/dist/index2.vue.d.cts +1 -1
- package/dist/index2.vue.d.ts +1 -1
- package/dist/index20.vue.d.cts +1 -1
- package/dist/index20.vue.d.ts +1 -1
- package/dist/index21.vue.d.cts +2 -2
- package/dist/index21.vue.d.ts +2 -2
- package/dist/index22.vue.d.cts +3 -3
- package/dist/index22.vue.d.ts +3 -3
- package/dist/index23.vue.d.cts +1 -1
- package/dist/index23.vue.d.ts +1 -1
- package/dist/index25.vue.d.cts +4 -4
- package/dist/index25.vue.d.ts +4 -4
- package/dist/index26.vue.d.cts +1 -1
- package/dist/index26.vue.d.ts +1 -1
- package/dist/index27.vue.d.cts +3 -3
- package/dist/index27.vue.d.ts +3 -3
- package/dist/index3.vue.d.cts +4 -4
- package/dist/index3.vue.d.ts +4 -4
- package/dist/index4.vue.d.cts +1 -8
- package/dist/index6.vue.d.ts +2 -2
- package/dist/index7.vue.d.cts +2 -2
- package/dist/index8.vue.d.ts +3 -3
- package/dist/index9.vue.d.cts +3 -3
- package/dist/index9.vue.d.ts +3 -3
- package/dist/mapUtils.d.cts +2 -2
- package/dist/mapUtils.d.ts +2 -2
- package/dist/presets.d.cts +8 -2
- package/dist/presets.d.ts +8 -2
- package/dist/rate.cjs +1 -0
- package/dist/rate.js +1 -0
- package/dist/slider.cjs +1 -0
- package/dist/slider.js +1 -0
- package/dist/style.css +10671 -10704
- package/dist/time-picker.cjs +1 -0
- package/dist/time-picker.js +1 -0
- package/dist/upload.cjs +1 -0
- package/dist/upload.js +1 -0
- package/dist/useActionTask.cjs +1 -0
- package/dist/useActionTask.js +1 -0
- package/dist/useCalendarEvents.d.cts +1 -1
- package/dist/useCalendarEvents.d.ts +1 -1
- package/dist/useCollapsePanel.d.cts +6 -6
- package/dist/useCollapsePanel.d.ts +6 -6
- package/dist/useComponentLocale.cjs +1 -0
- package/dist/useComponentLocale.js +1 -0
- package/dist/useCropperCore.d.cts +4 -4
- package/dist/useCropperCore.d.ts +4 -4
- package/dist/useDraggableLayout.d.cts +8 -8
- package/dist/useDraggableLayout.d.ts +8 -8
- package/dist/useDynamicFormState.cjs +1 -0
- package/dist/useDynamicFormState.d.cts +62 -38
- package/dist/useDynamicFormState.d.ts +62 -38
- package/dist/useDynamicFormState.js +1 -0
- package/dist/useEdgeInteraction.d.cts +2 -2
- package/dist/useEdgeInteraction.d.ts +2 -2
- package/dist/useFullscreen.d.cts +2 -2
- package/dist/useFullscreen.d.ts +2 -2
- package/dist/useInfiniteScroll.d.cts +1 -1
- package/dist/useInfiniteScroll.d.ts +1 -1
- package/dist/useQRCode.d.cts +3 -3
- package/dist/useQRCode.d.ts +3 -3
- package/dist/useSearchState.d.cts +16 -726
- package/dist/useSearchState.d.ts +16 -835
- package/dist/useSignatureHistory.d.cts +2 -2
- package/dist/useSignatureHistory.d.ts +2 -2
- package/dist/useSplitResize.d.cts +9 -9
- package/dist/useSplitResize.d.ts +9 -9
- package/dist/useTableQuery.cjs +3 -3
- package/dist/useTableQuery.d.cts +66 -33
- package/dist/useTableQuery.d.ts +66 -33
- package/dist/useTableQuery.js +3 -3
- package/dist/useTimeSelection.d.cts +2 -2
- package/dist/useTimeSelection.d.ts +2 -2
- package/dist/useTreeOperations.d.cts +4 -4
- package/dist/useTreeOperations.d.ts +4 -4
- package/dist/useWorkflowValidation.d.cts +3 -3
- package/dist/useWorkflowValidation.d.ts +3 -3
- package/dist/verification.d.cts +2 -2
- package/dist/verification.d.ts +2 -2
- package/docs/architecture.en.md +83 -0
- package/docs/architecture.md +83 -0
- package/docs/assets/README.md +47 -0
- package/docs/assets/naive-ui-components-banner.png +0 -0
- package/docs/assets/naive-ui-components-banner.svg +69 -0
- package/docs/assets/naive-ui-components-logo.png +0 -0
- package/docs/assets/naive-ui-components-logo.svg +22 -0
- package/docs/components.en.md +118 -0
- package/docs/components.md +118 -0
- package/docs/engineering.en.md +132 -0
- package/docs/engineering.md +133 -0
- package/docs/guides/usage.en.md +638 -0
- package/docs/guides/usage.md +699 -0
- package/docs/performance-0.15.0.md +20 -0
- package/docs/security-scan-2026-10-06.md +11 -0
- package/docs/security-scan-2026-10-18.md +16 -0
- package/package.json +29 -11
- package/dist/C_Form2.cjs +0 -1
- package/dist/C_Form2.js +0 -1
- package/dist/config.cjs +0 -1
- package/dist/config.d.cts +0 -33
- package/dist/config.d.ts +0 -33
- package/dist/config.js +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
[← English README](../README_EN.md) · [中文](./engineering.md)
|
|
2
|
+
|
|
3
|
+
# Development and build
|
|
4
|
+
|
|
5
|
+
## Build Architecture
|
|
6
|
+
|
|
7
|
+
### Six-stage Build Pipeline
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
bun run build
|
|
11
|
+
├── 1. tsdown → Multi-entry bundling (55 components ESM/CJS/DTS)
|
|
12
|
+
├── 2. sass CLI → Compile the shared-variable entry → global-scss.css
|
|
13
|
+
├── 3. merge-css.js → Merge Vue-compiled SFC CSS + global variables → style.css
|
|
14
|
+
├── 4. gen-exports.js → Auto-generate package.json exports map
|
|
15
|
+
├── 5. check:dist → Validate root, subpath, SSR, and DTS public exports
|
|
16
|
+
└── 6. check:size → Enforce full/base CSS and package-size budgets
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Key Technical Details
|
|
20
|
+
|
|
21
|
+
- **Build engine**: [tsdown](https://github.com/rolldown/tsdown) (Rolldown-based), 55 component entries plus the root entry and resolver
|
|
22
|
+
- **SCSS processing**: Custom `scssTransformPlugin` compiles SFC SCSS within the Rolldown pipeline; standalone Sass CLI only compiles the shared-variable entry
|
|
23
|
+
- **CSS merging**: Post-build merges Vue scoped-compiled per-chunk CSS with shared variables into a single `style.css`, avoiding duplicate styles and leaked raw `:deep()` selectors
|
|
24
|
+
- **Type exports**: Unified `export *` barrel pattern with auto-generated `.d.ts`
|
|
25
|
+
- **Subpath exports**: `gen-exports.js` auto-scans `dist/` and writes the `exports` field in `package.json`
|
|
26
|
+
- **Export conflict detection**: `check-export-conflicts.js` ensures no naming collisions between components
|
|
27
|
+
- **Artifact entry validation**: `check-dist-entries.js` prevents internal chunks from replacing root declarations and verifies component utility subpath types
|
|
28
|
+
- **Package contract validation**: blocks Naive UI internal type paths, hidden optional installs, and plugin console side effects
|
|
29
|
+
- **Size budgets**: `check-size-budget.js` prevents accidental growth of global, C_Form/C_Table, and total dist output
|
|
30
|
+
- **Consumer budgets**: `check-consumer-size.js` builds four minimal Vite applications, sums gzip bytes along the emitted static JS import graph, and rejects eager editor, spreadsheet, screenshot, or print dependencies.
|
|
31
|
+
|
|
32
|
+
### Build Output
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
dist/
|
|
36
|
+
├── index.js / index.cjs / index.d.ts # Main entry
|
|
37
|
+
├── C_Form.js / C_Form.cjs / C_Form.d.ts # Subpath entries (55 components)
|
|
38
|
+
├── C_Form.base.css / C_Form.css # Base/full style tiers
|
|
39
|
+
├── C_Table.base.css / C_Table.css # Base/full style tiers
|
|
40
|
+
├── style.css # Merged full styles
|
|
41
|
+
└── [chunk].js # Shared code chunks
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Development
|
|
45
|
+
|
|
46
|
+
The environment baseline is Node.js 20.19.0+ and Bun 1.3.14. `.node-version`, `packageManager`, `engines`, and the frozen lockfile keep local and CI installs aligned.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
bun install --frozen-lockfile # Install exactly from the lockfile
|
|
50
|
+
bun run dev # Dev mode (SCSS watch + tsdown watch)
|
|
51
|
+
bun run build # Full build
|
|
52
|
+
bun run build:scss # Compile global SCSS only
|
|
53
|
+
bun run build:css # Merge fresh tsdown CSS chunks; safely skips a finalized dist
|
|
54
|
+
bun run build:exports # Generate exports map only
|
|
55
|
+
bun run check:exports # Check export naming conflicts
|
|
56
|
+
bun run check:dist # Validate built JS / DTS public entries
|
|
57
|
+
bun run check:consumer-contracts # Tarball consumer types and optional peer boundaries
|
|
58
|
+
bun run check:package # Validate dependencies, exports, and public source boundaries
|
|
59
|
+
bun run check:quality # Prevent any, console, and type-suppression debt regressions
|
|
60
|
+
bun run check:audit # Audit direct and transitive dependency vulnerabilities
|
|
61
|
+
bun run check:size # Enforce publish artifact size budgets
|
|
62
|
+
bun run check:consumer-size # Check initial consumer bundles after building
|
|
63
|
+
bun run type-check # TypeScript type checking
|
|
64
|
+
bun run test # Run Bun unit tests
|
|
65
|
+
bun run lint:check # Oxlint + ESLint (check only)
|
|
66
|
+
bun run lint:eslint # Audit the existing ESLint rule backlog
|
|
67
|
+
bun run verify # Type, test, export, and build verification
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Consumer budgets include Vue and Naive UI. The four applications are independent measurements and cannot be added to estimate one application's size. `C_Form/base` renders one input; `C_Table/base` renders one row and column. The other cases render one search input and one action button. Base CSS excludes the built-in rich-text editor styles. Dynamic JS is built and checked but excluded from initial bytes; using those features still loads it. This check measures transfer size, not browser interaction performance. Both `verify` and the pre-publish lifecycle include this gate.
|
|
71
|
+
|
|
72
|
+
### Project Structure
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
naive-ui-components/
|
|
76
|
+
├── src/
|
|
77
|
+
│ ├── index.ts # Library entry (global registration + export * barrel)
|
|
78
|
+
│ ├── styles/
|
|
79
|
+
│ │ ├── variables.scss # CSS variables (--c-*)
|
|
80
|
+
│ │ └── global.scss # Auto-generated shared-variable entry
|
|
81
|
+
│ ├── components/
|
|
82
|
+
│ │ └── C_[Name]/
|
|
83
|
+
│ │ ├── index.vue # Main component file
|
|
84
|
+
│ │ ├── index.ts # Barrel export
|
|
85
|
+
│ │ ├── index.scss # Component styles
|
|
86
|
+
│ │ ├── types.ts # Type definitions
|
|
87
|
+
│ │ ├── constants.ts # Constants
|
|
88
|
+
│ │ ├── data.ts # Static data
|
|
89
|
+
│ │ ├── composables/ # Composable functions
|
|
90
|
+
│ │ ├── components/ # Sub-components
|
|
91
|
+
│ │ └── layouts/ # Layout variants (C_Form/C_AntV)
|
|
92
|
+
│ ├── plugins/ # highlight.js and other plugins
|
|
93
|
+
│ └── utils/ # Utility functions
|
|
94
|
+
├── scripts/
|
|
95
|
+
│ ├── gen-global-scss.js # Generate global.scss (shared variables only)
|
|
96
|
+
│ ├── watch-global-scss.js # Dev mode SCSS watcher
|
|
97
|
+
│ ├── merge-css.js # Merge CSS artifacts
|
|
98
|
+
│ ├── gen-exports.js # Auto-generate package.json exports
|
|
99
|
+
│ └── check-export-conflicts.js # Export naming conflict detection
|
|
100
|
+
├── types/
|
|
101
|
+
│ └── env.d.ts # .vue / .scss module declarations
|
|
102
|
+
├── tsdown.config.ts # Build config (multi-entry + SCSS plugin + Vue plugin)
|
|
103
|
+
└── tsconfig.json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Adding a New Component
|
|
107
|
+
|
|
108
|
+
1. Create `src/components/C_NewComponent/` directory
|
|
109
|
+
2. Write `index.vue`, `index.ts` (barrel), `types.ts`
|
|
110
|
+
3. Add `export * from './components/C_NewComponent'` in `src/index.ts`
|
|
111
|
+
4. Add the component import and registration to the `components` array in `src/index.ts`
|
|
112
|
+
5. Add the name to `componentNames` in `src/resolver.ts`
|
|
113
|
+
6. Run `bun run verify` — build scripts will auto-generate subpath entries and exports mapping
|
|
114
|
+
|
|
115
|
+
### Publishing
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
bun run changeset # Record changes and release level
|
|
119
|
+
bun run version # Update package version and CHANGELOG
|
|
120
|
+
bun run verify # Run all pre-publish checks
|
|
121
|
+
bun run release # Publish pending Changesets releases
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The official local Changesets changelog generator uses commit IDs and change summaries; `bun run version` does not require a GitHub token. npm authentication is still required for publishing. On Windows, if `bun run release` stalls while npm repeats `prepublishOnly`, first confirm `bun run verify` succeeds, then publish from PowerShell with `$env:npm_config_ignore_scripts='true'; bun run release`. This skips only the repeated lifecycle check, not the prerequisite verification.
|
|
125
|
+
|
|
126
|
+
## Documentation assets
|
|
127
|
+
|
|
128
|
+
Brand sources and exported PNGs are in [`assets/`](./assets/). See the [asset guide](./assets/README.md) for colors, logo usage and export instructions.
|
|
129
|
+
|
|
130
|
+
## Architecture boundaries
|
|
131
|
+
|
|
132
|
+
See [architecture and isolation](./architecture.en.md) for dependency direction, app-level ownership and future Element Plus adaptation.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
[← 项目首页](../README.md) · [English](./engineering.en.md)
|
|
2
|
+
|
|
3
|
+
# 开发与构建
|
|
4
|
+
|
|
5
|
+
## 构建架构
|
|
6
|
+
|
|
7
|
+
### 六阶段构建流水线
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
bun run build
|
|
11
|
+
├── 1. tsdown → 多入口打包(55 组件 ESM/CJS/DTS)
|
|
12
|
+
├── 2. sass CLI → 编译共享变量入口 → global-scss.css
|
|
13
|
+
├── 3. merge-css.js → 合并 Vue 编译后的 SFC CSS + 全局变量 → style.css
|
|
14
|
+
├── 4. gen-exports.js → 自动生成 package.json exports 映射
|
|
15
|
+
├── 5. check:dist → 校验根入口、子路径、SSR 及 DTS 公共导出
|
|
16
|
+
└── 6. check:size → 校验全量/基础样式与发布包体积预算
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 技术要点
|
|
20
|
+
|
|
21
|
+
- **构建引擎**:[tsdown](https://github.com/rolldown/tsdown)(基于 Rolldown),55 个组件入口,加主入口与 Resolver
|
|
22
|
+
- **SCSS 处理**:自定义 `scssTransformPlugin` 在 Rolldown 管线内编译 SFC SCSS,独立 Sass CLI 仅编译共享变量入口
|
|
23
|
+
- **CSS 合并**:构建后将 Vue 已完成 scoped 转换的 per-chunk CSS 与共享变量合并为单一 `style.css`,避免重复样式和原始 `:deep()` 选择器泄漏
|
|
24
|
+
- **类型导出**:统一 `export *` barrel 模式,自动生成完整 `.d.ts`
|
|
25
|
+
- **子路径导出**:`gen-exports.js` 自动扫描 `dist/` 并写入 `package.json` 的 `exports` 字段
|
|
26
|
+
- **导出冲突检测**:`check-export-conflicts.js` 确保组件间无命名冲突
|
|
27
|
+
- **产物入口校验**:`check-dist-entries.js` 防止内部 chunk 覆盖根声明,并保证组件工具的子路径类型完整
|
|
28
|
+
- **包契约校验**:禁止 Naive UI 内部类型路径、隐式可选依赖和插件控制台副作用
|
|
29
|
+
- **体积预算**:`check-size-budget.js` 阻止全量样式、C_Form/C_Table 样式和 dist 总量意外膨胀
|
|
30
|
+
- **消费端预算**:`check-consumer-size.js` 用 Vite 构建四个最小消费应用,沿实际静态导入图累计首屏 JS gzip;同时检查编辑器、Excel、截图和打印依赖没有进入首屏。
|
|
31
|
+
|
|
32
|
+
### 输出产物
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
dist/
|
|
36
|
+
├── index.js / index.cjs / index.d.ts # 主入口
|
|
37
|
+
├── C_Form.js / C_Form.cjs / C_Form.d.ts # 子路径入口(55 组件)
|
|
38
|
+
├── C_Form.base.css / C_Form.css # 基础/完整样式层级
|
|
39
|
+
├── C_Table.base.css / C_Table.css # 基础/完整样式层级
|
|
40
|
+
├── style.css # 合并后的全量样式
|
|
41
|
+
├── images/ # Leaflet Marker/图层控件资源
|
|
42
|
+
└── [chunk].js # 共享代码块
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 开发
|
|
46
|
+
|
|
47
|
+
环境基线为 Node.js 20.19.0+ 与 Bun 1.3.14;仓库通过 `.node-version`、`packageManager`、`engines` 和冻结锁文件保持本地/CI 一致。
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
bun install --frozen-lockfile # 严格按锁文件安装依赖
|
|
51
|
+
bun run dev # 开发模式(SCSS watch + tsdown watch)
|
|
52
|
+
bun run build # 完整构建
|
|
53
|
+
bun run build:scss # 仅编译全局 SCSS
|
|
54
|
+
bun run build:css # 合并 tsdown 刚生成的 CSS chunk;已完成的 dist 会安全跳过
|
|
55
|
+
bun run build:exports # 仅生成 exports 映射
|
|
56
|
+
bun run check:exports # 检测导出命名冲突
|
|
57
|
+
bun run check:dist # 校验构建后的 JS / DTS 公共入口
|
|
58
|
+
bun run check:consumer-contracts # 真实打包消费者类型与可选 peer 边界
|
|
59
|
+
bun run check:package # 校验依赖、导出和源码公共边界
|
|
60
|
+
bun run check:quality # 防止 any、console 与类型抑制债务反弹
|
|
61
|
+
bun run check:audit # 审计直接与传递依赖漏洞
|
|
62
|
+
bun run check:size # 校验发布产物体积预算
|
|
63
|
+
bun run check:consumer-size # 构建后检查常用组件的消费端首屏预算
|
|
64
|
+
bun run type-check # TypeScript 类型检查
|
|
65
|
+
bun run test # 运行 Bun 单元测试
|
|
66
|
+
bun run lint:check # Oxlint + ESLint(只检查)
|
|
67
|
+
bun run lint:eslint # ESLint 存量规则审计
|
|
68
|
+
bun run verify # 类型、测试、导出和构建全量验证
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
消费端预算包含 Vue 和 Naive UI,四个独立场景分别测量,不能相加当作同一应用的体积。`C_Form/base` 为单输入字段,`C_Table/base` 为单列单行展示表格;另外测量一个输入查询和一个操作按钮。基础样式排除内置富文本编辑器样式。动态 JS 会完成构建检查,但不计入首屏;使用对应字段或功能时仍会加载。此检查衡量传输体积,不替代真实浏览器的交互性能测量。`verify` 和发布前生命周期均包含该门禁。
|
|
72
|
+
|
|
73
|
+
### 项目结构
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
naive-ui-components/
|
|
77
|
+
├── src/
|
|
78
|
+
│ ├── index.ts # 库入口(全量注册 + export * barrel)
|
|
79
|
+
│ ├── styles/
|
|
80
|
+
│ │ ├── variables.scss # CSS 变量 (--c-*)
|
|
81
|
+
│ │ └── global.scss # 自动生成的共享变量入口
|
|
82
|
+
│ ├── components/
|
|
83
|
+
│ │ └── C_[Name]/
|
|
84
|
+
│ │ ├── index.vue # 组件主文件
|
|
85
|
+
│ │ ├── index.ts # Barrel 导出
|
|
86
|
+
│ │ ├── index.scss # 组件样式
|
|
87
|
+
│ │ ├── types.ts # 类型定义
|
|
88
|
+
│ │ ├── constants.ts # 常量
|
|
89
|
+
│ │ ├── data.ts # 静态数据
|
|
90
|
+
│ │ ├── composables/ # 组合式函数
|
|
91
|
+
│ │ ├── components/ # 子组件
|
|
92
|
+
│ │ └── layouts/ # 布局变体(C_Form/C_AntV)
|
|
93
|
+
│ ├── plugins/ # highlight.js 等插件
|
|
94
|
+
│ └── utils/ # 工具函数
|
|
95
|
+
├── scripts/
|
|
96
|
+
│ ├── gen-global-scss.js # 生成 global.scss(仅共享变量)
|
|
97
|
+
│ ├── watch-global-scss.js # 开发模式 SCSS 监听
|
|
98
|
+
│ ├── merge-css.js # 合并 CSS 产物
|
|
99
|
+
│ ├── gen-exports.js # 自动生成 package.json exports
|
|
100
|
+
│ └── check-export-conflicts.js # 导出命名冲突检测
|
|
101
|
+
├── types/
|
|
102
|
+
│ └── env.d.ts # .vue / .scss 模块声明
|
|
103
|
+
├── tsdown.config.ts # 构建配置(多入口 + SCSS 插件 + Vue 插件)
|
|
104
|
+
└── tsconfig.json
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 添加新组件
|
|
108
|
+
|
|
109
|
+
1. 创建 `src/components/C_NewComponent/` 目录
|
|
110
|
+
2. 编写 `index.vue`、`index.ts`(barrel)、`types.ts`
|
|
111
|
+
3. 在 `src/index.ts` 中添加 `export * from './components/C_NewComponent'`
|
|
112
|
+
4. 在 `src/index.ts` 中导入组件并加入 `components` 注册数组
|
|
113
|
+
5. 在 `src/resolver.ts` 的 `componentNames` 中登记名称
|
|
114
|
+
6. 运行 `bun run verify`—构建脚本会自动生成子路径入口和 exports 映射
|
|
115
|
+
|
|
116
|
+
### 发布
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
bun run changeset # 记录变更及版本级别
|
|
120
|
+
bun run version # 更新版本号与 CHANGELOG
|
|
121
|
+
bun run verify # 发布前完整验证
|
|
122
|
+
bun run release # 发布 Changesets 中待发布版本
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
变更日志使用 Changesets 官方本地生成器,根据 Changeset 与 Git 提交生成,无需额外 `GITHUB_TOKEN`。npm 发布仍需要有效的发布账号认证,凭据不得写入仓库。Windows 下如果 `bun run release` 在 npm 的 `prepublishOnly` 重复验证阶段停滞,可先单独确认 `bun run verify` 成功,再在 PowerShell 中用 `$env:npm_config_ignore_scripts='true'; bun run release` 发布;该设置仅跳过已手动完成的重复生命周期验证,不应省略前一步。
|
|
126
|
+
|
|
127
|
+
## 文档资源
|
|
128
|
+
|
|
129
|
+
品牌源文件与 PNG 导出位于 [`assets/`](./assets/),配色、Logo 使用及导出方式见[资源说明](./assets/README.md)。
|
|
130
|
+
|
|
131
|
+
## 架构边界
|
|
132
|
+
|
|
133
|
+
依赖方向、应用所有权与后续 Element Plus 适配要求见[架构与隔离](./architecture.md)。
|