@veltra/vite 3.0.0 → 3.0.1
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/components.gen.js +110 -0
- package/dist/components.gen.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/resolver.d.ts +11 -19
- package/dist/resolver.js +19 -137
- package/dist/resolver.js.map +1 -1
- package/package.json +14 -4
- package/src/components.gen.ts +108 -0
- package/src/index.ts +2 -2
- package/src/resolver.ts +26 -155
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
//#region src/components.gen.ts
|
|
2
|
+
const VELTRA_COMPONENT_PACKAGES = [
|
|
3
|
+
{
|
|
4
|
+
from: "@veltra/desktop",
|
|
5
|
+
components: {
|
|
6
|
+
UAction: "components/action/style",
|
|
7
|
+
UActionGroup: "components/action/style",
|
|
8
|
+
UAutoComplete: "components/auto-complete/style",
|
|
9
|
+
UBadge: "components/badge/style",
|
|
10
|
+
UBatchEdit: "components/batch-edit/style",
|
|
11
|
+
UBreadcrumb: "components/breadcrumb/style",
|
|
12
|
+
UButton: "components/button/style",
|
|
13
|
+
UButtonGroup: "components/button/style",
|
|
14
|
+
UCalendar: "components/calendar/style",
|
|
15
|
+
UCard: "components/card/style",
|
|
16
|
+
UCardAction: "components/card/style",
|
|
17
|
+
UCardContent: "components/card/style",
|
|
18
|
+
UCardCover: "components/card/style",
|
|
19
|
+
UCardHeader: "components/card/style",
|
|
20
|
+
UCascade: "components/cascade/style",
|
|
21
|
+
UCheckbox: "components/checkbox/style",
|
|
22
|
+
UCheckboxButton: "components/checkbox/style",
|
|
23
|
+
UCheckboxGroup: "components/checkbox-group/style",
|
|
24
|
+
UCheckTag: "components/check-tag/style",
|
|
25
|
+
UCodeEditor: "components/code-editor/style",
|
|
26
|
+
UCollapse: "components/collapse/style",
|
|
27
|
+
UCollapseItem: "components/collapse/style",
|
|
28
|
+
UConditionEditor: "components/condition-editor/style",
|
|
29
|
+
UContextmenu: "components/contextmenu/style",
|
|
30
|
+
UDatePanel: "components/date-panel/style",
|
|
31
|
+
UDatePicker: "components/date-picker/style",
|
|
32
|
+
UDateRangePicker: "components/date-range-picker/style",
|
|
33
|
+
UDialog: "components/dialog/style",
|
|
34
|
+
UDrawer: "components/drawer/style",
|
|
35
|
+
UDropdown: "components/dropdown/style",
|
|
36
|
+
UDualNav: "components/dual-nav/style",
|
|
37
|
+
UEmpty: "components/empty/style",
|
|
38
|
+
UExpressionEditor: "components/expression-editor/style",
|
|
39
|
+
UFilePicker: "components/file-picker/style",
|
|
40
|
+
UFileViewer: "components/file-viewer/style",
|
|
41
|
+
UFloatButton: "components/float-button/style",
|
|
42
|
+
UForm: "components/form/style",
|
|
43
|
+
UFormItem: "components/form-item/style",
|
|
44
|
+
UGanttChart: "components/gantt-chart/style",
|
|
45
|
+
UGrid: "components/grid/style",
|
|
46
|
+
UGridInput: "components/grid-input/style",
|
|
47
|
+
UGridItem: "components/grid/style",
|
|
48
|
+
UGroupInput: "components/group-input/style",
|
|
49
|
+
UGroupNav: "components/group-nav/style",
|
|
50
|
+
UIcon: "components/icon/style",
|
|
51
|
+
UInput: "components/input/style",
|
|
52
|
+
UKbd: "components/kbd/style",
|
|
53
|
+
ULayout: "components/layout/style",
|
|
54
|
+
UList: "components/list/style",
|
|
55
|
+
UListItem: "components/list/style",
|
|
56
|
+
ULoading: "components/loading/style",
|
|
57
|
+
UMessage: "components/message/style",
|
|
58
|
+
UMessageConfirm: "components/message-confirm/style",
|
|
59
|
+
UMultiSelect: "components/multi-select/style",
|
|
60
|
+
UMultiTreeSelect: "components/multi-tree-select/style",
|
|
61
|
+
UNav: "components/nav/style",
|
|
62
|
+
UNavItem: "components/nav/style",
|
|
63
|
+
UNavSub: "components/nav/style",
|
|
64
|
+
UNodeRender: "components/node-render/style",
|
|
65
|
+
UNotification: "components/notification/style",
|
|
66
|
+
UNumber: "components/number/style",
|
|
67
|
+
UNumberInput: "components/number-input/style",
|
|
68
|
+
UNumberRangeInput: "components/number-range-input/style",
|
|
69
|
+
UPaginator: "components/paginator/style",
|
|
70
|
+
UPalette: "components/palette/style",
|
|
71
|
+
UPasswordInput: "components/password-input/style",
|
|
72
|
+
UPopConfirm: "components/pop-confirm/style",
|
|
73
|
+
UProgress: "components/progress/style",
|
|
74
|
+
UProgressNodes: "components/progress-nodes/style",
|
|
75
|
+
URadio: "components/radio/style",
|
|
76
|
+
URadioGroup: "components/radio-group/style",
|
|
77
|
+
URichTextEditor: "components/rich-text-editor/style",
|
|
78
|
+
UScroll: "components/scroll/style",
|
|
79
|
+
USelect: "components/select/style",
|
|
80
|
+
USlider: "components/slider/style",
|
|
81
|
+
USteps: "components/steps/style",
|
|
82
|
+
USwitch: "components/switch/style",
|
|
83
|
+
UTable: "components/table/style",
|
|
84
|
+
UTableEditor: "components/table-editor/style",
|
|
85
|
+
UTabs: "components/tabs/style",
|
|
86
|
+
UTabsHorizontal: "components/tabs/style",
|
|
87
|
+
UTabsVertical: "components/tabs/style",
|
|
88
|
+
UTag: "components/tag/style",
|
|
89
|
+
UText: "components/text/style",
|
|
90
|
+
UTextarea: "components/textarea/style",
|
|
91
|
+
UTheme: "components/theme/style",
|
|
92
|
+
UTip: "components/tip/style",
|
|
93
|
+
UTree: "components/tree/style",
|
|
94
|
+
UTreeSelect: "components/tree-select/style",
|
|
95
|
+
UWatermark: "components/watermark/style"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
from: "@veltra/ai",
|
|
100
|
+
components: { UAiChat: "components/ai-chat/style" }
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
from: "@veltra/sheet",
|
|
104
|
+
components: { USheet: "vue/style" }
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
//#endregion
|
|
108
|
+
export { VELTRA_COMPONENT_PACKAGES };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=components.gen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.gen.js","names":[],"sources":["../src/components.gen.ts"],"sourcesContent":["// 由 `bun run resolver:gen`(scripts/gen-vite-resolver.ts)生成,请勿手动编辑。\n\nexport interface VeltraComponentPackage {\n /** 组件的导入来源包名 */\n from: string\n /** 组件名 → 样式副作用子路径(相对包名,无扩展名) */\n components: Record<string, string>\n}\n\nexport const VELTRA_COMPONENT_PACKAGES: VeltraComponentPackage[] = [\n {\n from: '@veltra/desktop',\n components: {\n UAction: 'components/action/style',\n UActionGroup: 'components/action/style',\n UAutoComplete: 'components/auto-complete/style',\n UBadge: 'components/badge/style',\n UBatchEdit: 'components/batch-edit/style',\n UBreadcrumb: 'components/breadcrumb/style',\n UButton: 'components/button/style',\n UButtonGroup: 'components/button/style',\n UCalendar: 'components/calendar/style',\n UCard: 'components/card/style',\n UCardAction: 'components/card/style',\n UCardContent: 'components/card/style',\n UCardCover: 'components/card/style',\n UCardHeader: 'components/card/style',\n UCascade: 'components/cascade/style',\n UCheckbox: 'components/checkbox/style',\n UCheckboxButton: 'components/checkbox/style',\n UCheckboxGroup: 'components/checkbox-group/style',\n UCheckTag: 'components/check-tag/style',\n UCodeEditor: 'components/code-editor/style',\n UCollapse: 'components/collapse/style',\n UCollapseItem: 'components/collapse/style',\n UConditionEditor: 'components/condition-editor/style',\n UContextmenu: 'components/contextmenu/style',\n UDatePanel: 'components/date-panel/style',\n UDatePicker: 'components/date-picker/style',\n UDateRangePicker: 'components/date-range-picker/style',\n UDialog: 'components/dialog/style',\n UDrawer: 'components/drawer/style',\n UDropdown: 'components/dropdown/style',\n UDualNav: 'components/dual-nav/style',\n UEmpty: 'components/empty/style',\n UExpressionEditor: 'components/expression-editor/style',\n UFilePicker: 'components/file-picker/style',\n UFileViewer: 'components/file-viewer/style',\n UFloatButton: 'components/float-button/style',\n UForm: 'components/form/style',\n UFormItem: 'components/form-item/style',\n UGanttChart: 'components/gantt-chart/style',\n UGrid: 'components/grid/style',\n UGridInput: 'components/grid-input/style',\n UGridItem: 'components/grid/style',\n UGroupInput: 'components/group-input/style',\n UGroupNav: 'components/group-nav/style',\n UIcon: 'components/icon/style',\n UInput: 'components/input/style',\n UKbd: 'components/kbd/style',\n ULayout: 'components/layout/style',\n UList: 'components/list/style',\n UListItem: 'components/list/style',\n ULoading: 'components/loading/style',\n UMessage: 'components/message/style',\n UMessageConfirm: 'components/message-confirm/style',\n UMultiSelect: 'components/multi-select/style',\n UMultiTreeSelect: 'components/multi-tree-select/style',\n UNav: 'components/nav/style',\n UNavItem: 'components/nav/style',\n UNavSub: 'components/nav/style',\n UNodeRender: 'components/node-render/style',\n UNotification: 'components/notification/style',\n UNumber: 'components/number/style',\n UNumberInput: 'components/number-input/style',\n UNumberRangeInput: 'components/number-range-input/style',\n UPaginator: 'components/paginator/style',\n UPalette: 'components/palette/style',\n UPasswordInput: 'components/password-input/style',\n UPopConfirm: 'components/pop-confirm/style',\n UProgress: 'components/progress/style',\n UProgressNodes: 'components/progress-nodes/style',\n URadio: 'components/radio/style',\n URadioGroup: 'components/radio-group/style',\n URichTextEditor: 'components/rich-text-editor/style',\n UScroll: 'components/scroll/style',\n USelect: 'components/select/style',\n USlider: 'components/slider/style',\n USteps: 'components/steps/style',\n USwitch: 'components/switch/style',\n UTable: 'components/table/style',\n UTableEditor: 'components/table-editor/style',\n UTabs: 'components/tabs/style',\n UTabsHorizontal: 'components/tabs/style',\n UTabsVertical: 'components/tabs/style',\n UTag: 'components/tag/style',\n UText: 'components/text/style',\n UTextarea: 'components/textarea/style',\n UTheme: 'components/theme/style',\n UTip: 'components/tip/style',\n UTree: 'components/tree/style',\n UTreeSelect: 'components/tree-select/style',\n UWatermark: 'components/watermark/style'\n }\n },\n { from: '@veltra/ai', components: { UAiChat: 'components/ai-chat/style' } },\n { from: '@veltra/sheet', components: { USheet: 'vue/style' } }\n]\n"],"mappings":";AASA,MAAa,4BAAsD;CACjE;EACE,MAAM;EACN,YAAY;GACV,SAAS;GACT,cAAc;GACd,eAAe;GACf,QAAQ;GACR,YAAY;GACZ,aAAa;GACb,SAAS;GACT,cAAc;GACd,WAAW;GACX,OAAO;GACP,aAAa;GACb,cAAc;GACd,YAAY;GACZ,aAAa;GACb,UAAU;GACV,WAAW;GACX,iBAAiB;GACjB,gBAAgB;GAChB,WAAW;GACX,aAAa;GACb,WAAW;GACX,eAAe;GACf,kBAAkB;GAClB,cAAc;GACd,YAAY;GACZ,aAAa;GACb,kBAAkB;GAClB,SAAS;GACT,SAAS;GACT,WAAW;GACX,UAAU;GACV,QAAQ;GACR,mBAAmB;GACnB,aAAa;GACb,aAAa;GACb,cAAc;GACd,OAAO;GACP,WAAW;GACX,aAAa;GACb,OAAO;GACP,YAAY;GACZ,WAAW;GACX,aAAa;GACb,WAAW;GACX,OAAO;GACP,QAAQ;GACR,MAAM;GACN,SAAS;GACT,OAAO;GACP,WAAW;GACX,UAAU;GACV,UAAU;GACV,iBAAiB;GACjB,cAAc;GACd,kBAAkB;GAClB,MAAM;GACN,UAAU;GACV,SAAS;GACT,aAAa;GACb,eAAe;GACf,SAAS;GACT,cAAc;GACd,mBAAmB;GACnB,YAAY;GACZ,UAAU;GACV,gBAAgB;GAChB,aAAa;GACb,WAAW;GACX,gBAAgB;GAChB,QAAQ;GACR,aAAa;GACb,iBAAiB;GACjB,SAAS;GACT,SAAS;GACT,SAAS;GACT,QAAQ;GACR,SAAS;GACT,QAAQ;GACR,cAAc;GACd,OAAO;GACP,iBAAiB;GACjB,eAAe;GACf,MAAM;GACN,OAAO;GACP,WAAW;GACX,QAAQ;GACR,MAAM;GACN,OAAO;GACP,aAAa;GACb,YAAY;EACd;CACF;CACA;EAAE,MAAM;EAAc,YAAY,EAAE,SAAS,2BAA2B;CAAE;CAC1E;EAAE,MAAM;EAAiB,YAAY,EAAE,QAAQ,YAAY;CAAE;AAC/D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { VeltraUIResolver, VeltraUIResolverOptions } from "./resolver.js";
|
|
2
|
+
export { VeltraUIResolver, type VeltraUIResolverOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { VeltraUIResolver } from "./resolver.js";
|
|
2
|
+
export { VeltraUIResolver };
|
package/dist/resolver.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { ComponentResolver } from "unplugin-vue-components/types";
|
|
2
2
|
//#region src/resolver.d.ts
|
|
3
|
-
interface
|
|
4
|
-
/**
|
|
5
|
-
* Component style directories to exclude.
|
|
6
|
-
* @example ['button', 'loading']
|
|
7
|
-
*/
|
|
8
|
-
exclude?: string[];
|
|
9
|
-
/**
|
|
10
|
-
* Component style directories to include. Empty or omitted means all known
|
|
11
|
-
* desktop components are eligible.
|
|
12
|
-
* @example ['button', 'input', 'dialog']
|
|
13
|
-
*/
|
|
14
|
-
include?: string[];
|
|
3
|
+
interface VeltraUIResolverOptions {
|
|
15
4
|
/**
|
|
16
5
|
* Whether to import component styles as side effects.
|
|
17
6
|
* @default true
|
|
@@ -19,16 +8,19 @@ interface VeltraDesktopUIResolverOptions {
|
|
|
19
8
|
importStyle?: boolean;
|
|
20
9
|
}
|
|
21
10
|
/**
|
|
22
|
-
* Resolver for `unplugin-vue-components` that auto-imports
|
|
23
|
-
*
|
|
11
|
+
* Resolver for `unplugin-vue-components` that auto-imports Veltra UI components
|
|
12
|
+
* (`@veltra/desktop`, `@veltra/ai`, `@veltra/sheet`) and their style side effects.
|
|
13
|
+
*
|
|
14
|
+
* The component table lives in `components.gen.ts`, regenerated by
|
|
15
|
+
* `bun run resolver:gen` whenever those packages gain or drop a component.
|
|
24
16
|
*
|
|
25
|
-
* Style resolution relies on
|
|
26
|
-
* - **veltra-dev** (Vite dev): resolves to `src
|
|
17
|
+
* Style resolution relies on each package's exports conditions:
|
|
18
|
+
* - **veltra-dev** (Vite dev): resolves to `src/<dir>/style.ts`
|
|
27
19
|
* (source SCSS pipeline, full HMR)
|
|
28
|
-
* - **
|
|
20
|
+
* - **import** (Vite build): resolves to `dist/<dir>/style.js`
|
|
29
21
|
* (pre-compiled, CSS imported by the JS entry)
|
|
30
22
|
*/
|
|
31
|
-
declare function
|
|
23
|
+
declare function VeltraUIResolver(options?: VeltraUIResolverOptions): ComponentResolver;
|
|
32
24
|
//#endregion
|
|
33
|
-
export {
|
|
25
|
+
export { VeltraUIResolver, VeltraUIResolverOptions };
|
|
34
26
|
//# sourceMappingURL=resolver.d.ts.map
|
package/dist/resolver.js
CHANGED
|
@@ -1,156 +1,38 @@
|
|
|
1
|
+
import { VELTRA_COMPONENT_PACKAGES } from "./components.gen.js";
|
|
1
2
|
//#region src/resolver.ts
|
|
3
|
+
const COMPONENTS = new Map(VELTRA_COMPONENT_PACKAGES.flatMap(({ components, from }) => Object.entries(components).map(([name, stylePath]) => [name, {
|
|
4
|
+
from,
|
|
5
|
+
style: `${from}/${stylePath}`
|
|
6
|
+
}])));
|
|
2
7
|
/**
|
|
3
|
-
*
|
|
8
|
+
* Resolver for `unplugin-vue-components` that auto-imports Veltra UI components
|
|
9
|
+
* (`@veltra/desktop`, `@veltra/ai`, `@veltra/sheet`) and their style side effects.
|
|
4
10
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `button/` and uses `button/style.ts`).
|
|
8
|
-
*/
|
|
9
|
-
const SHARED_STYLE_DIR = {
|
|
10
|
-
"button-group": "button",
|
|
11
|
-
"collapse-item": "collapse",
|
|
12
|
-
"action-group": "action",
|
|
13
|
-
"card-header": "card",
|
|
14
|
-
"card-cover": "card",
|
|
15
|
-
"card-content": "card",
|
|
16
|
-
"card-action": "card",
|
|
17
|
-
"checkbox-button": "checkbox",
|
|
18
|
-
"grid-item": "grid",
|
|
19
|
-
"list-item": "list",
|
|
20
|
-
"nav-sub": "nav",
|
|
21
|
-
"nav-item": "nav",
|
|
22
|
-
"dual-nav-app": "dual-nav",
|
|
23
|
-
"group-nav-item": "group-nav",
|
|
24
|
-
"tabs-horizontal": "tabs",
|
|
25
|
-
"tabs-vertical": "tabs"
|
|
26
|
-
};
|
|
27
|
-
const DESKTOP_COMPONENTS = /* @__PURE__ */ new Set([
|
|
28
|
-
"UAction",
|
|
29
|
-
"UActionGroup",
|
|
30
|
-
"UAutoComplete",
|
|
31
|
-
"UBadge",
|
|
32
|
-
"UBatchEdit",
|
|
33
|
-
"UBreadcrumb",
|
|
34
|
-
"UButton",
|
|
35
|
-
"UButtonGroup",
|
|
36
|
-
"UCalendar",
|
|
37
|
-
"UCard",
|
|
38
|
-
"UCardAction",
|
|
39
|
-
"UCardContent",
|
|
40
|
-
"UCardCover",
|
|
41
|
-
"UCardHeader",
|
|
42
|
-
"UCascade",
|
|
43
|
-
"UCheckTag",
|
|
44
|
-
"UCheckbox",
|
|
45
|
-
"UCollapse",
|
|
46
|
-
"UCollapseItem",
|
|
47
|
-
"UCheckboxButton",
|
|
48
|
-
"UCheckboxGroup",
|
|
49
|
-
"UCodeEditor",
|
|
50
|
-
"UConditionEditor",
|
|
51
|
-
"UContextmenu",
|
|
52
|
-
"UDatePanel",
|
|
53
|
-
"UDatePicker",
|
|
54
|
-
"UDateRangePicker",
|
|
55
|
-
"UDialog",
|
|
56
|
-
"UDrawer",
|
|
57
|
-
"UDropdown",
|
|
58
|
-
"UEmpty",
|
|
59
|
-
"UExpressionEditor",
|
|
60
|
-
"UFilePicker",
|
|
61
|
-
"UFileViewer",
|
|
62
|
-
"UFloatButton",
|
|
63
|
-
"UForm",
|
|
64
|
-
"UFormItem",
|
|
65
|
-
"UGanttChart",
|
|
66
|
-
"UGrid",
|
|
67
|
-
"UGridInput",
|
|
68
|
-
"UGridItem",
|
|
69
|
-
"UGroupInput",
|
|
70
|
-
"UIcon",
|
|
71
|
-
"UKbd",
|
|
72
|
-
"UInput",
|
|
73
|
-
"ULayout",
|
|
74
|
-
"UList",
|
|
75
|
-
"UListItem",
|
|
76
|
-
"ULoading",
|
|
77
|
-
"UDualNav",
|
|
78
|
-
"UGroupNav",
|
|
79
|
-
"UGroupNavItem",
|
|
80
|
-
"UNav",
|
|
81
|
-
"UNavItem",
|
|
82
|
-
"UNavSub",
|
|
83
|
-
"UMessage",
|
|
84
|
-
"UMessageConfirm",
|
|
85
|
-
"UMultiSelect",
|
|
86
|
-
"UMultiTreeSelect",
|
|
87
|
-
"UNodeRender",
|
|
88
|
-
"UNotification",
|
|
89
|
-
"UNumber",
|
|
90
|
-
"UNumberInput",
|
|
91
|
-
"UNumberRangeInput",
|
|
92
|
-
"UPaginator",
|
|
93
|
-
"UPalette",
|
|
94
|
-
"UPasswordInput",
|
|
95
|
-
"UPopConfirm",
|
|
96
|
-
"UProgress",
|
|
97
|
-
"UProgressNodes",
|
|
98
|
-
"URadio",
|
|
99
|
-
"URadioGroup",
|
|
100
|
-
"URichTextEditor",
|
|
101
|
-
"UScroll",
|
|
102
|
-
"USelect",
|
|
103
|
-
"USlider",
|
|
104
|
-
"USteps",
|
|
105
|
-
"USwitch",
|
|
106
|
-
"UTable",
|
|
107
|
-
"UTableEditor",
|
|
108
|
-
"UTabs",
|
|
109
|
-
"UTabsHorizontal",
|
|
110
|
-
"UTabsVertical",
|
|
111
|
-
"UTag",
|
|
112
|
-
"UText",
|
|
113
|
-
"UTextarea",
|
|
114
|
-
"UTheme",
|
|
115
|
-
"UTip",
|
|
116
|
-
"UTree",
|
|
117
|
-
"UTreeSelect",
|
|
118
|
-
"UWatermark"
|
|
119
|
-
]);
|
|
120
|
-
function pascalToKebab(str) {
|
|
121
|
-
return str.replace(/[A-Z]/g, (char, index) => (index > 0 ? "-" : "") + char.toLowerCase());
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Resolver for `unplugin-vue-components` that auto-imports `@veltra/desktop`
|
|
125
|
-
* components and their style side effects.
|
|
11
|
+
* The component table lives in `components.gen.ts`, regenerated by
|
|
12
|
+
* `bun run resolver:gen` whenever those packages gain or drop a component.
|
|
126
13
|
*
|
|
127
|
-
* Style resolution relies on
|
|
128
|
-
* - **veltra-dev** (Vite dev): resolves to `src
|
|
14
|
+
* Style resolution relies on each package's exports conditions:
|
|
15
|
+
* - **veltra-dev** (Vite dev): resolves to `src/<dir>/style.ts`
|
|
129
16
|
* (source SCSS pipeline, full HMR)
|
|
130
|
-
* - **
|
|
17
|
+
* - **import** (Vite build): resolves to `dist/<dir>/style.js`
|
|
131
18
|
* (pre-compiled, CSS imported by the JS entry)
|
|
132
19
|
*/
|
|
133
|
-
function
|
|
134
|
-
const {
|
|
135
|
-
const excluded = new Set(exclude);
|
|
136
|
-
const included = new Set(include);
|
|
20
|
+
function VeltraUIResolver(options = {}) {
|
|
21
|
+
const { importStyle = true } = options;
|
|
137
22
|
return {
|
|
138
23
|
type: "component",
|
|
139
24
|
resolve(name) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const styleDir = SHARED_STYLE_DIR[kebabName] ?? kebabName;
|
|
143
|
-
if (excluded.has(styleDir)) return;
|
|
144
|
-
if (included.size > 0 && !included.has(styleDir)) return;
|
|
25
|
+
const component = COMPONENTS.get(name);
|
|
26
|
+
if (!component) return;
|
|
145
27
|
return {
|
|
146
28
|
name,
|
|
147
|
-
from:
|
|
148
|
-
sideEffects: importStyle ?
|
|
29
|
+
from: component.from,
|
|
30
|
+
sideEffects: importStyle ? component.style : void 0
|
|
149
31
|
};
|
|
150
32
|
}
|
|
151
33
|
};
|
|
152
34
|
}
|
|
153
35
|
//#endregion
|
|
154
|
-
export {
|
|
36
|
+
export { VeltraUIResolver };
|
|
155
37
|
|
|
156
38
|
//# sourceMappingURL=resolver.js.map
|
package/dist/resolver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","names":[],"sources":["../src/resolver.ts"],"sourcesContent":["import type { ComponentResolver } from 'unplugin-vue-components/types'\n\
|
|
1
|
+
{"version":3,"file":"resolver.js","names":[],"sources":["../src/resolver.ts"],"sourcesContent":["import type { ComponentResolver } from 'unplugin-vue-components/types'\n\nimport { VELTRA_COMPONENT_PACKAGES } from './components.gen'\n\nexport interface VeltraUIResolverOptions {\n /**\n * Whether to import component styles as side effects.\n * @default true\n */\n importStyle?: boolean\n}\n\ninterface ComponentEntry {\n from: string\n style: string\n}\n\nconst COMPONENTS: ReadonlyMap<string, ComponentEntry> = new Map(\n VELTRA_COMPONENT_PACKAGES.flatMap(({ components, from }) =>\n Object.entries(components).map(\n ([name, stylePath]) => [name, { from, style: `${from}/${stylePath}` }] as const\n )\n )\n)\n\n/**\n * Resolver for `unplugin-vue-components` that auto-imports Veltra UI components\n * (`@veltra/desktop`, `@veltra/ai`, `@veltra/sheet`) and their style side effects.\n *\n * The component table lives in `components.gen.ts`, regenerated by\n * `bun run resolver:gen` whenever those packages gain or drop a component.\n *\n * Style resolution relies on each package's exports conditions:\n * - **veltra-dev** (Vite dev): resolves to `src/<dir>/style.ts`\n * (source SCSS pipeline, full HMR)\n * - **import** (Vite build): resolves to `dist/<dir>/style.js`\n * (pre-compiled, CSS imported by the JS entry)\n */\nexport function VeltraUIResolver(options: VeltraUIResolverOptions = {}): ComponentResolver {\n const { importStyle = true } = options\n\n return {\n type: 'component',\n resolve(name: string) {\n const component = COMPONENTS.get(name)\n if (!component) return\n\n return { name, from: component.from, sideEffects: importStyle ? component.style : undefined }\n }\n }\n}\n"],"mappings":";;AAiBA,MAAM,aAAkD,IAAI,IAC1D,0BAA0B,SAAS,EAAE,YAAY,WAC/C,OAAO,QAAQ,UAAU,CAAC,CAAC,KACxB,CAAC,MAAM,eAAe,CAAC,MAAM;CAAE;CAAM,OAAO,GAAG,KAAK,GAAG;AAAY,CAAC,CACvE,CACF,CACF;;;;;;;;;;;;;;AAeA,SAAgB,iBAAiB,UAAmC,CAAC,GAAsB;CACzF,MAAM,EAAE,cAAc,SAAS;CAE/B,OAAO;EACL,MAAM;EACN,QAAQ,MAAc;GACpB,MAAM,YAAY,WAAW,IAAI,IAAI;GACrC,IAAI,CAAC,WAAW;GAEhB,OAAO;IAAE;IAAM,MAAM,UAAU;IAAM,aAAa,cAAc,UAAU,QAAQ,KAAA;GAAU;EAC9F;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltra/vite",
|
|
3
|
-
"version": "3.0.
|
|
4
|
-
"description": "Vite helpers for Veltra UI (e.g. unplugin-vue-components resolver for @veltra/desktop)",
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"description": "Vite helpers for Veltra UI (e.g. unplugin-vue-components resolver for @veltra/desktop, @veltra/ai and @veltra/sheet)",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"src"
|
|
@@ -14,10 +14,20 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@veltra/desktop": "1.
|
|
17
|
+
"@veltra/desktop": "1.5.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@veltra/
|
|
20
|
+
"@veltra/ai": "^1.4.0",
|
|
21
|
+
"@veltra/desktop": "^1.5.0",
|
|
22
|
+
"@veltra/sheet": "^2.1.1",
|
|
21
23
|
"unplugin-vue-components": ">=32.0.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependenciesMeta": {
|
|
26
|
+
"@veltra/ai": {
|
|
27
|
+
"optional": true
|
|
28
|
+
},
|
|
29
|
+
"@veltra/sheet": {
|
|
30
|
+
"optional": true
|
|
31
|
+
}
|
|
22
32
|
}
|
|
23
33
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// 由 `bun run resolver:gen`(scripts/gen-vite-resolver.ts)生成,请勿手动编辑。
|
|
2
|
+
|
|
3
|
+
export interface VeltraComponentPackage {
|
|
4
|
+
/** 组件的导入来源包名 */
|
|
5
|
+
from: string
|
|
6
|
+
/** 组件名 → 样式副作用子路径(相对包名,无扩展名) */
|
|
7
|
+
components: Record<string, string>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const VELTRA_COMPONENT_PACKAGES: VeltraComponentPackage[] = [
|
|
11
|
+
{
|
|
12
|
+
from: '@veltra/desktop',
|
|
13
|
+
components: {
|
|
14
|
+
UAction: 'components/action/style',
|
|
15
|
+
UActionGroup: 'components/action/style',
|
|
16
|
+
UAutoComplete: 'components/auto-complete/style',
|
|
17
|
+
UBadge: 'components/badge/style',
|
|
18
|
+
UBatchEdit: 'components/batch-edit/style',
|
|
19
|
+
UBreadcrumb: 'components/breadcrumb/style',
|
|
20
|
+
UButton: 'components/button/style',
|
|
21
|
+
UButtonGroup: 'components/button/style',
|
|
22
|
+
UCalendar: 'components/calendar/style',
|
|
23
|
+
UCard: 'components/card/style',
|
|
24
|
+
UCardAction: 'components/card/style',
|
|
25
|
+
UCardContent: 'components/card/style',
|
|
26
|
+
UCardCover: 'components/card/style',
|
|
27
|
+
UCardHeader: 'components/card/style',
|
|
28
|
+
UCascade: 'components/cascade/style',
|
|
29
|
+
UCheckbox: 'components/checkbox/style',
|
|
30
|
+
UCheckboxButton: 'components/checkbox/style',
|
|
31
|
+
UCheckboxGroup: 'components/checkbox-group/style',
|
|
32
|
+
UCheckTag: 'components/check-tag/style',
|
|
33
|
+
UCodeEditor: 'components/code-editor/style',
|
|
34
|
+
UCollapse: 'components/collapse/style',
|
|
35
|
+
UCollapseItem: 'components/collapse/style',
|
|
36
|
+
UConditionEditor: 'components/condition-editor/style',
|
|
37
|
+
UContextmenu: 'components/contextmenu/style',
|
|
38
|
+
UDatePanel: 'components/date-panel/style',
|
|
39
|
+
UDatePicker: 'components/date-picker/style',
|
|
40
|
+
UDateRangePicker: 'components/date-range-picker/style',
|
|
41
|
+
UDialog: 'components/dialog/style',
|
|
42
|
+
UDrawer: 'components/drawer/style',
|
|
43
|
+
UDropdown: 'components/dropdown/style',
|
|
44
|
+
UDualNav: 'components/dual-nav/style',
|
|
45
|
+
UEmpty: 'components/empty/style',
|
|
46
|
+
UExpressionEditor: 'components/expression-editor/style',
|
|
47
|
+
UFilePicker: 'components/file-picker/style',
|
|
48
|
+
UFileViewer: 'components/file-viewer/style',
|
|
49
|
+
UFloatButton: 'components/float-button/style',
|
|
50
|
+
UForm: 'components/form/style',
|
|
51
|
+
UFormItem: 'components/form-item/style',
|
|
52
|
+
UGanttChart: 'components/gantt-chart/style',
|
|
53
|
+
UGrid: 'components/grid/style',
|
|
54
|
+
UGridInput: 'components/grid-input/style',
|
|
55
|
+
UGridItem: 'components/grid/style',
|
|
56
|
+
UGroupInput: 'components/group-input/style',
|
|
57
|
+
UGroupNav: 'components/group-nav/style',
|
|
58
|
+
UIcon: 'components/icon/style',
|
|
59
|
+
UInput: 'components/input/style',
|
|
60
|
+
UKbd: 'components/kbd/style',
|
|
61
|
+
ULayout: 'components/layout/style',
|
|
62
|
+
UList: 'components/list/style',
|
|
63
|
+
UListItem: 'components/list/style',
|
|
64
|
+
ULoading: 'components/loading/style',
|
|
65
|
+
UMessage: 'components/message/style',
|
|
66
|
+
UMessageConfirm: 'components/message-confirm/style',
|
|
67
|
+
UMultiSelect: 'components/multi-select/style',
|
|
68
|
+
UMultiTreeSelect: 'components/multi-tree-select/style',
|
|
69
|
+
UNav: 'components/nav/style',
|
|
70
|
+
UNavItem: 'components/nav/style',
|
|
71
|
+
UNavSub: 'components/nav/style',
|
|
72
|
+
UNodeRender: 'components/node-render/style',
|
|
73
|
+
UNotification: 'components/notification/style',
|
|
74
|
+
UNumber: 'components/number/style',
|
|
75
|
+
UNumberInput: 'components/number-input/style',
|
|
76
|
+
UNumberRangeInput: 'components/number-range-input/style',
|
|
77
|
+
UPaginator: 'components/paginator/style',
|
|
78
|
+
UPalette: 'components/palette/style',
|
|
79
|
+
UPasswordInput: 'components/password-input/style',
|
|
80
|
+
UPopConfirm: 'components/pop-confirm/style',
|
|
81
|
+
UProgress: 'components/progress/style',
|
|
82
|
+
UProgressNodes: 'components/progress-nodes/style',
|
|
83
|
+
URadio: 'components/radio/style',
|
|
84
|
+
URadioGroup: 'components/radio-group/style',
|
|
85
|
+
URichTextEditor: 'components/rich-text-editor/style',
|
|
86
|
+
UScroll: 'components/scroll/style',
|
|
87
|
+
USelect: 'components/select/style',
|
|
88
|
+
USlider: 'components/slider/style',
|
|
89
|
+
USteps: 'components/steps/style',
|
|
90
|
+
USwitch: 'components/switch/style',
|
|
91
|
+
UTable: 'components/table/style',
|
|
92
|
+
UTableEditor: 'components/table-editor/style',
|
|
93
|
+
UTabs: 'components/tabs/style',
|
|
94
|
+
UTabsHorizontal: 'components/tabs/style',
|
|
95
|
+
UTabsVertical: 'components/tabs/style',
|
|
96
|
+
UTag: 'components/tag/style',
|
|
97
|
+
UText: 'components/text/style',
|
|
98
|
+
UTextarea: 'components/textarea/style',
|
|
99
|
+
UTheme: 'components/theme/style',
|
|
100
|
+
UTip: 'components/tip/style',
|
|
101
|
+
UTree: 'components/tree/style',
|
|
102
|
+
UTreeSelect: 'components/tree-select/style',
|
|
103
|
+
UWatermark: 'components/watermark/style'
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{ from: '@veltra/ai', components: { UAiChat: 'components/ai-chat/style' } },
|
|
107
|
+
{ from: '@veltra/sheet', components: { USheet: 'vue/style' } }
|
|
108
|
+
]
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
1
|
+
export { VeltraUIResolver } from './resolver'
|
|
2
|
+
export type { VeltraUIResolverOptions } from './resolver'
|
package/src/resolver.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import type { ComponentResolver } from 'unplugin-vue-components/types'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* @example ['button', 'loading']
|
|
7
|
-
*/
|
|
8
|
-
exclude?: string[]
|
|
9
|
-
/**
|
|
10
|
-
* Component style directories to include. Empty or omitted means all known
|
|
11
|
-
* desktop components are eligible.
|
|
12
|
-
* @example ['button', 'input', 'dialog']
|
|
13
|
-
*/
|
|
14
|
-
include?: string[]
|
|
3
|
+
import { VELTRA_COMPONENT_PACKAGES } from './components.gen'
|
|
4
|
+
|
|
5
|
+
export interface VeltraUIResolverOptions {
|
|
15
6
|
/**
|
|
16
7
|
* Whether to import component styles as side effects.
|
|
17
8
|
* @default true
|
|
@@ -19,162 +10,42 @@ export interface VeltraDesktopUIResolverOptions {
|
|
|
19
10
|
importStyle?: boolean
|
|
20
11
|
}
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* These components don't have their own `style.ts` — they live inside a parent
|
|
26
|
-
* component directory and use the parent's style (e.g. `UButtonGroup` lives in
|
|
27
|
-
* `button/` and uses `button/style.ts`).
|
|
28
|
-
*/
|
|
29
|
-
const SHARED_STYLE_DIR: Record<string, string> = {
|
|
30
|
-
'button-group': 'button',
|
|
31
|
-
'collapse-item': 'collapse',
|
|
32
|
-
'action-group': 'action',
|
|
33
|
-
'card-header': 'card',
|
|
34
|
-
'card-cover': 'card',
|
|
35
|
-
'card-content': 'card',
|
|
36
|
-
'card-action': 'card',
|
|
37
|
-
'checkbox-button': 'checkbox',
|
|
38
|
-
'grid-item': 'grid',
|
|
39
|
-
'list-item': 'list',
|
|
40
|
-
'nav-sub': 'nav',
|
|
41
|
-
'nav-item': 'nav',
|
|
42
|
-
'dual-nav-app': 'dual-nav',
|
|
43
|
-
'group-nav-item': 'group-nav',
|
|
44
|
-
'tabs-horizontal': 'tabs',
|
|
45
|
-
'tabs-vertical': 'tabs'
|
|
13
|
+
interface ComponentEntry {
|
|
14
|
+
from: string
|
|
15
|
+
style: string
|
|
46
16
|
}
|
|
47
17
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
'UButton',
|
|
56
|
-
'UButtonGroup',
|
|
57
|
-
'UCalendar',
|
|
58
|
-
'UCard',
|
|
59
|
-
'UCardAction',
|
|
60
|
-
'UCardContent',
|
|
61
|
-
'UCardCover',
|
|
62
|
-
'UCardHeader',
|
|
63
|
-
'UCascade',
|
|
64
|
-
'UCheckTag',
|
|
65
|
-
'UCheckbox',
|
|
66
|
-
'UCollapse',
|
|
67
|
-
'UCollapseItem',
|
|
68
|
-
'UCheckboxButton',
|
|
69
|
-
'UCheckboxGroup',
|
|
70
|
-
'UCodeEditor',
|
|
71
|
-
'UConditionEditor',
|
|
72
|
-
'UContextmenu',
|
|
73
|
-
'UDatePanel',
|
|
74
|
-
'UDatePicker',
|
|
75
|
-
'UDateRangePicker',
|
|
76
|
-
'UDialog',
|
|
77
|
-
'UDrawer',
|
|
78
|
-
'UDropdown',
|
|
79
|
-
'UEmpty',
|
|
80
|
-
'UExpressionEditor',
|
|
81
|
-
'UFilePicker',
|
|
82
|
-
'UFileViewer',
|
|
83
|
-
'UFloatButton',
|
|
84
|
-
'UForm',
|
|
85
|
-
'UFormItem',
|
|
86
|
-
'UGanttChart',
|
|
87
|
-
'UGrid',
|
|
88
|
-
'UGridInput',
|
|
89
|
-
'UGridItem',
|
|
90
|
-
'UGroupInput',
|
|
91
|
-
'UIcon',
|
|
92
|
-
'UKbd',
|
|
93
|
-
'UInput',
|
|
94
|
-
'ULayout',
|
|
95
|
-
'UList',
|
|
96
|
-
'UListItem',
|
|
97
|
-
'ULoading',
|
|
98
|
-
'UDualNav',
|
|
99
|
-
'UGroupNav',
|
|
100
|
-
'UGroupNavItem',
|
|
101
|
-
'UNav',
|
|
102
|
-
'UNavItem',
|
|
103
|
-
'UNavSub',
|
|
104
|
-
'UMessage',
|
|
105
|
-
'UMessageConfirm',
|
|
106
|
-
'UMultiSelect',
|
|
107
|
-
'UMultiTreeSelect',
|
|
108
|
-
'UNodeRender',
|
|
109
|
-
'UNotification',
|
|
110
|
-
'UNumber',
|
|
111
|
-
'UNumberInput',
|
|
112
|
-
'UNumberRangeInput',
|
|
113
|
-
'UPaginator',
|
|
114
|
-
'UPalette',
|
|
115
|
-
'UPasswordInput',
|
|
116
|
-
'UPopConfirm',
|
|
117
|
-
'UProgress',
|
|
118
|
-
'UProgressNodes',
|
|
119
|
-
'URadio',
|
|
120
|
-
'URadioGroup',
|
|
121
|
-
'URichTextEditor',
|
|
122
|
-
'UScroll',
|
|
123
|
-
'USelect',
|
|
124
|
-
'USlider',
|
|
125
|
-
'USteps',
|
|
126
|
-
'USwitch',
|
|
127
|
-
'UTable',
|
|
128
|
-
'UTableEditor',
|
|
129
|
-
'UTabs',
|
|
130
|
-
'UTabsHorizontal',
|
|
131
|
-
'UTabsVertical',
|
|
132
|
-
'UTag',
|
|
133
|
-
'UText',
|
|
134
|
-
'UTextarea',
|
|
135
|
-
'UTheme',
|
|
136
|
-
'UTip',
|
|
137
|
-
'UTree',
|
|
138
|
-
'UTreeSelect',
|
|
139
|
-
'UWatermark'
|
|
140
|
-
])
|
|
141
|
-
|
|
142
|
-
function pascalToKebab(str: string): string {
|
|
143
|
-
return str.replace(/[A-Z]/g, (char, index) => (index > 0 ? '-' : '') + char.toLowerCase())
|
|
144
|
-
}
|
|
18
|
+
const COMPONENTS: ReadonlyMap<string, ComponentEntry> = new Map(
|
|
19
|
+
VELTRA_COMPONENT_PACKAGES.flatMap(({ components, from }) =>
|
|
20
|
+
Object.entries(components).map(
|
|
21
|
+
([name, stylePath]) => [name, { from, style: `${from}/${stylePath}` }] as const
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
)
|
|
145
25
|
|
|
146
26
|
/**
|
|
147
|
-
* Resolver for `unplugin-vue-components` that auto-imports
|
|
148
|
-
*
|
|
27
|
+
* Resolver for `unplugin-vue-components` that auto-imports Veltra UI components
|
|
28
|
+
* (`@veltra/desktop`, `@veltra/ai`, `@veltra/sheet`) and their style side effects.
|
|
29
|
+
*
|
|
30
|
+
* The component table lives in `components.gen.ts`, regenerated by
|
|
31
|
+
* `bun run resolver:gen` whenever those packages gain or drop a component.
|
|
149
32
|
*
|
|
150
|
-
* Style resolution relies on
|
|
151
|
-
* - **veltra-dev** (Vite dev): resolves to `src
|
|
33
|
+
* Style resolution relies on each package's exports conditions:
|
|
34
|
+
* - **veltra-dev** (Vite dev): resolves to `src/<dir>/style.ts`
|
|
152
35
|
* (source SCSS pipeline, full HMR)
|
|
153
|
-
* - **
|
|
36
|
+
* - **import** (Vite build): resolves to `dist/<dir>/style.js`
|
|
154
37
|
* (pre-compiled, CSS imported by the JS entry)
|
|
155
38
|
*/
|
|
156
|
-
export function
|
|
157
|
-
|
|
158
|
-
): ComponentResolver {
|
|
159
|
-
const { exclude = [], importStyle = true, include = [] } = options
|
|
160
|
-
const excluded = new Set(exclude)
|
|
161
|
-
const included = new Set(include)
|
|
39
|
+
export function VeltraUIResolver(options: VeltraUIResolverOptions = {}): ComponentResolver {
|
|
40
|
+
const { importStyle = true } = options
|
|
162
41
|
|
|
163
42
|
return {
|
|
164
43
|
type: 'component',
|
|
165
44
|
resolve(name: string) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const kebabName = pascalToKebab(name.slice(1))
|
|
169
|
-
const styleDir = SHARED_STYLE_DIR[kebabName] ?? kebabName
|
|
170
|
-
if (excluded.has(styleDir)) return
|
|
171
|
-
if (included.size > 0 && !included.has(styleDir)) return
|
|
45
|
+
const component = COMPONENTS.get(name)
|
|
46
|
+
if (!component) return
|
|
172
47
|
|
|
173
|
-
return {
|
|
174
|
-
name,
|
|
175
|
-
from: '@veltra/desktop',
|
|
176
|
-
sideEffects: importStyle ? `@veltra/desktop/components/${styleDir}/style` : undefined
|
|
177
|
-
}
|
|
48
|
+
return { name, from: component.from, sideEffects: importStyle ? component.style : undefined }
|
|
178
49
|
}
|
|
179
50
|
}
|
|
180
51
|
}
|