@dou-ui/resolver 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/index.js +1399 -0
- package/dist/types/generated/names.d.ts +10 -0
- package/dist/types/index.d.ts +81 -0
- package/package.json +40 -4
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Every component `dou-ui` exports, with the directory of its style entry. */
|
|
2
|
+
export declare const componentDirs: Record<string, string>;
|
|
3
|
+
/** Every component of the packages built on `dou-ui`, its package, where to import it from and its style entry. */
|
|
4
|
+
export declare const packageComponents: Record<string, {
|
|
5
|
+
package: string;
|
|
6
|
+
from: string;
|
|
7
|
+
style: string;
|
|
8
|
+
}>;
|
|
9
|
+
/** Every icon component `@dou-ui/icons` exports. */
|
|
10
|
+
export declare const iconNames: readonly string[];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { componentDirs, iconNames, packageComponents } from './generated/names';
|
|
2
|
+
/** What a resolver hands back: the export to import, where from, and what to import with it. */
|
|
3
|
+
export interface ImportInfo {
|
|
4
|
+
name: string;
|
|
5
|
+
from: string;
|
|
6
|
+
sideEffects?: string | string[];
|
|
7
|
+
}
|
|
8
|
+
export type ResolverFunction = (name: string) => ImportInfo | undefined;
|
|
9
|
+
/** The resolver shape of on-demand component plugins. */
|
|
10
|
+
export interface ComponentResolver {
|
|
11
|
+
type: 'component' | 'directive';
|
|
12
|
+
resolve: ResolverFunction;
|
|
13
|
+
}
|
|
14
|
+
export interface DouUIResolverOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Import each component's stylesheet along with it. Turn off when the
|
|
17
|
+
* full stylesheet (`dou-ui/style.css`) is loaded once instead.
|
|
18
|
+
*
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
importStyle?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve `v-loading` and `v-infinite-scroll` too.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
directives?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve `<SearchIcon />` and the other icons of `@dou-ui/icons`.
|
|
30
|
+
*
|
|
31
|
+
* @default true when `@dou-ui/icons` can be found from `root`
|
|
32
|
+
*/
|
|
33
|
+
icons?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The project directory, where `@dou-ui/icons` is looked for. Pass Vite's
|
|
36
|
+
* `root` when it is not the directory Vite runs in (`vite --root apps/web`).
|
|
37
|
+
*
|
|
38
|
+
* @default process.cwd()
|
|
39
|
+
*/
|
|
40
|
+
root?: string;
|
|
41
|
+
/** Names to leave alone, e.g. ones the app defines itself. */
|
|
42
|
+
exclude?: RegExp | string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The functions of `dou-ui` worth importing automatically, with the
|
|
46
|
+
* directory of the style entry for what they render (`null` when they
|
|
47
|
+
* render nothing).
|
|
48
|
+
*/
|
|
49
|
+
export declare const functionDirs: Readonly<Record<string, string | null>>;
|
|
50
|
+
/** The directives of `dou-ui`, by the name they are written with (`v-loading` → `Loading`). */
|
|
51
|
+
export declare const directives: Readonly<Record<string, {
|
|
52
|
+
name: string;
|
|
53
|
+
dir: string;
|
|
54
|
+
}>>;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve DouUI components (and the directives) as they are used in templates,
|
|
57
|
+
* for an on-demand components plugin. Besides `dou-ui`, this covers the
|
|
58
|
+
* packages built on it (`<DouChart>`, `<DouEditor>`, …) and the icons of
|
|
59
|
+
* `@dou-ui/icons`.
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* Components({ resolvers: [DouUIResolver()] })
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* `<DouButton>` becomes `import { DouButton } from 'dou-ui'` plus
|
|
66
|
+
* `import 'dou-ui/components/button/style'`; `<DouChartLine>` becomes
|
|
67
|
+
* `import { DouChartLine } from '@dou-ui/chart'` plus
|
|
68
|
+
* `import '@dou-ui/chart/style'`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function DouUIResolver(options?: DouUIResolverOptions): ComponentResolver[];
|
|
71
|
+
/**
|
|
72
|
+
* Resolve the functions of DouUI (`toast`, `dialog`, `useDialog`,
|
|
73
|
+
* `vLoading`, `vInfiniteScroll`, `useSortable`, `useColorMode`,
|
|
74
|
+
* `useCountdown`) for an auto-import plugin, with the styles of what they show.
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* AutoImport({ resolvers: [DouUIApiResolver()] })
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function DouUIApiResolver(options?: Pick<DouUIResolverOptions, 'importStyle' | 'exclude'>): ResolverFunction;
|
|
81
|
+
export { componentDirs, iconNames, packageComponents };
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dou-ui/resolver",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "DouUI 的按需自动导入解析器:组件、图标、指令、函数与样式入口",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"vue",
|
|
7
|
+
"dou-ui",
|
|
8
|
+
"auto-import",
|
|
9
|
+
"resolver"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "daidr <daidr@daidr.me>",
|
|
13
|
+
"homepage": "https://github.com/daidr/dou-ui#readme",
|
|
14
|
+
"bugs": "https://github.com/daidr/dou-ui/issues",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/daidr/dou-ui.git",
|
|
18
|
+
"directory": "packages/resolver"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"module": "./dist/index.js",
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/types/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"gen": "bun scripts/gen.ts",
|
|
37
|
+
"build": "bun scripts/build.ts"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|