@vixt/core 0.9.0 → 0.11.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/dist/cli/index.mjs +1 -3
- package/dist/client/index.d.ts +56 -8
- package/dist/client/index.js +306 -6
- package/dist/node/index.d.mts +364 -161
- package/dist/node/index.mjs +210 -73
- package/package.json +18 -16
package/dist/node/index.d.mts
CHANGED
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
import { ConfigLayer, ConfigLayerMeta, LoadConfigOptions, ResolvedConfig } from "c12";
|
|
2
|
-
import * as vite from "vite";
|
|
2
|
+
import * as _$vite from "vite";
|
|
3
3
|
import { HtmlTagDescriptor, InlineConfig, LogLevel, PluginOption, ServerOptions, UserConfig } from "vite";
|
|
4
4
|
import Legacy from "@vitejs/plugin-legacy";
|
|
5
5
|
import Analyzer from "vite-bundle-analyzer";
|
|
6
6
|
import Ssl from "@vitejs/plugin-basic-ssl";
|
|
7
|
+
import AutoImport from "unplugin-auto-import/vite";
|
|
8
|
+
import { NitroPluginConfig } from "nitro/vite";
|
|
7
9
|
import Checker from "vite-plugin-checker";
|
|
8
10
|
import { RawVueCompilerOptions } from "@vue/language-core";
|
|
9
11
|
import { TSConfig } from "pkg-types";
|
|
10
12
|
|
|
11
|
-
//#region src/node/
|
|
13
|
+
//#region src/node/types/layer.d.ts
|
|
14
|
+
interface VixtConfigLayerMeta extends ConfigLayerMeta {
|
|
15
|
+
/** layer name */
|
|
16
|
+
name?: string;
|
|
17
|
+
/** layer alias */
|
|
18
|
+
alias?: string;
|
|
19
|
+
}
|
|
20
|
+
interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta> {
|
|
21
|
+
/** when layer is in node_modules, layer will copy to `<buildLayersDir>/<layerName>`, and change cwd */
|
|
22
|
+
cwd?: string;
|
|
23
|
+
}
|
|
24
|
+
interface LoadVixtConfigOptions extends LoadConfigOptions<VixtOptions, VixtConfigLayerMeta> {}
|
|
25
|
+
interface ResolvedVixtConfig extends ResolvedConfig<VixtOptions, VixtConfigLayerMeta> {}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/node/types/vixt.d.ts
|
|
12
28
|
interface Vixt {
|
|
13
29
|
options: VixtOptions;
|
|
14
30
|
_layers: VixtConfigLayer[];
|
|
15
31
|
_modules: VixtModule[];
|
|
16
32
|
}
|
|
17
|
-
declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
|
|
18
|
-
declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => vite.PluginOption;
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/node/module.d.ts
|
|
21
33
|
type ExtractPluginOptions<Options = any> = (Options extends ((...args: any[]) => any) ? Parameters<Options>[0] : Options);
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/node/types/module.d.ts
|
|
22
36
|
type ModuleOptions = Record<string, any>;
|
|
23
37
|
interface ModuleMeta extends Record<string, any> {
|
|
24
38
|
name?: string;
|
|
@@ -34,119 +48,10 @@ interface VixtModule<T extends ModuleOptions = ModuleOptions> {
|
|
|
34
48
|
getOptions?: (inlineOptions: Partial<T>, Vixt: Vixt) => T;
|
|
35
49
|
getMeta?: () => ModuleMeta;
|
|
36
50
|
}
|
|
37
|
-
declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) => PluginOption): (options?: Options) => PluginOption;
|
|
38
|
-
declare function defineVixtModule<T extends ModuleOptions>(definition: ModuleDefinition<T> | VixtModule<T>): VixtModule<T>;
|
|
39
|
-
declare function installModule<T extends ModuleOptions = ModuleOptions>(module: VixtModule<T>, inlineOptions: any, vixt: Vixt): PluginOption;
|
|
40
|
-
declare function applyLayerModules({
|
|
41
|
-
config,
|
|
42
|
-
layers
|
|
43
|
-
}: ResolvedVixtConfig): Promise<VixtModule[]>;
|
|
44
51
|
//#endregion
|
|
45
|
-
//#region src/node/
|
|
46
|
-
interface
|
|
47
|
-
|
|
48
|
-
* Vixt App configuration.
|
|
49
|
-
*/
|
|
50
|
-
app?: AppOptions;
|
|
51
|
-
/**
|
|
52
|
-
* Shared build configuration.
|
|
53
|
-
*/
|
|
54
|
-
build?: BuildOptions;
|
|
55
|
-
/**
|
|
56
|
-
* Define the root directory of your application.
|
|
57
|
-
* @default process.cwd()
|
|
58
|
-
*/
|
|
59
|
-
rootDir?: string;
|
|
60
|
-
/**
|
|
61
|
-
* Define the monorepo workspace directory of your application.
|
|
62
|
-
*/
|
|
63
|
-
workspaceDir?: string;
|
|
64
|
-
/**
|
|
65
|
-
* Define the source directory of your application.
|
|
66
|
-
* @default '<rootDir>/src'
|
|
67
|
-
*/
|
|
68
|
-
srcDir?: string;
|
|
69
|
-
/**
|
|
70
|
-
* Define the server directory of your application.
|
|
71
|
-
* @default '<rootDir>/server'
|
|
72
|
-
*/
|
|
73
|
-
serverDir?: string;
|
|
74
|
-
/**
|
|
75
|
-
* Define the directory where your built files will be placed.
|
|
76
|
-
* @default '<rootDir>/.vixt'
|
|
77
|
-
*/
|
|
78
|
-
buildDir?: string;
|
|
79
|
-
/**
|
|
80
|
-
* @default '<buildDir>/types'
|
|
81
|
-
*/
|
|
82
|
-
buildTypesDir?: string;
|
|
83
|
-
/**
|
|
84
|
-
* @default '<buildDir>/layers'
|
|
85
|
-
*/
|
|
86
|
-
buildLayersDir?: string;
|
|
87
|
-
/**
|
|
88
|
-
* @default '<buildDir>/imports'
|
|
89
|
-
*/
|
|
90
|
-
buildImportsDir?: string;
|
|
91
|
-
/**
|
|
92
|
-
* Define the directory of your Vixt modules.
|
|
93
|
-
* @default '<srcDir>/modules'
|
|
94
|
-
*/
|
|
95
|
-
modulesDir?: string;
|
|
96
|
-
/**
|
|
97
|
-
* Define the directory of your Vixt plugins.
|
|
98
|
-
* @default '<srcDir>/plugins'
|
|
99
|
-
*/
|
|
100
|
-
pluginsDir?: string;
|
|
101
|
-
/**
|
|
102
|
-
* Whether your app is running in development mode.
|
|
103
|
-
* @default false
|
|
104
|
-
*/
|
|
105
|
-
dev?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Whether your app is being unit tested.
|
|
108
|
-
* @default false
|
|
109
|
-
*/
|
|
110
|
-
test?: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Set to `true` to enable debug mode.
|
|
113
|
-
* @default false
|
|
114
|
-
*/
|
|
115
|
-
debug?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Whether to enable rendering of HTML.
|
|
118
|
-
* @default false
|
|
119
|
-
*/
|
|
120
|
-
ssr?: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* You can improve your DX by defining additional aliases to access custom directories within your JavaScript and CSS.
|
|
123
|
-
*/
|
|
124
|
-
alias?: AliasOptions;
|
|
125
|
-
/**
|
|
126
|
-
* Configuration that will be passed directly to Vite.
|
|
127
|
-
*/
|
|
128
|
-
appConfig?: Record<string, any>;
|
|
129
|
-
devServer?: DevServerOptions;
|
|
130
|
-
/** Vite config input */
|
|
131
|
-
vite?: Omit<UserConfig, 'plugins'>;
|
|
132
|
-
/** layer meta */
|
|
133
|
-
meta?: VixtConfigLayerMeta;
|
|
134
|
-
/** layers */
|
|
135
|
-
extends?: string[];
|
|
136
|
-
/** modules */
|
|
137
|
-
modules?: VixtModule[];
|
|
138
|
-
/** plugins */
|
|
139
|
-
plugins?: string[];
|
|
140
|
-
/** typescript */
|
|
141
|
-
typescript?: TypescriptOptions;
|
|
142
|
-
/**
|
|
143
|
-
* Whether to copy layers from `node_modules` to `.vixt/layers`
|
|
144
|
-
* @default true
|
|
145
|
-
* @experimental
|
|
146
|
-
*/
|
|
147
|
-
copyLayers?: boolean;
|
|
148
|
-
/** custom options */
|
|
149
|
-
[key: string]: any;
|
|
52
|
+
//#region src/node/types/options.d.ts
|
|
53
|
+
interface AliasOptions {
|
|
54
|
+
[find: string]: string;
|
|
150
55
|
}
|
|
151
56
|
interface AppHeadAttrs {
|
|
152
57
|
children?: string;
|
|
@@ -163,35 +68,88 @@ interface AppHead {
|
|
|
163
68
|
}
|
|
164
69
|
interface AppOptions {
|
|
165
70
|
/**
|
|
166
|
-
* The base path of your
|
|
71
|
+
* The base path of your Vixt application.
|
|
167
72
|
* @default '/'
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* export default defineVixtConfig({
|
|
76
|
+
* app: {
|
|
77
|
+
* baseURL: '/prefix/',
|
|
78
|
+
* },
|
|
79
|
+
* })
|
|
80
|
+
* ```
|
|
168
81
|
*/
|
|
169
82
|
baseURL?: string;
|
|
170
83
|
/**
|
|
171
84
|
* You can define the CSS files/modules/libraries you want to set globally.
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* export default defineVixtConfig({
|
|
88
|
+
* css: [
|
|
89
|
+
* // CSS file in the project
|
|
90
|
+
* '~/styles/main.css',
|
|
91
|
+
* // SCSS file in the project
|
|
92
|
+
* '~/styles/main.scss',
|
|
93
|
+
* ],
|
|
94
|
+
* })
|
|
95
|
+
* ```
|
|
172
96
|
*/
|
|
173
97
|
css?: string[];
|
|
174
98
|
/**
|
|
175
|
-
* The entry file relative to
|
|
176
|
-
* @default
|
|
177
|
-
*
|
|
178
|
-
*
|
|
99
|
+
* The entry file relative to `<srcDir>`
|
|
100
|
+
* @default
|
|
101
|
+
* 'main.ts' // in vue
|
|
102
|
+
* 'main.tsx' // in react
|
|
103
|
+
* 'index.ts' // in vitepress
|
|
104
|
+
* @example 'entry.ts' // relative to '/<srcDir>/entry.ts'
|
|
179
105
|
*/
|
|
180
106
|
entryFile?: string;
|
|
181
107
|
/** The default entry code */
|
|
182
108
|
entryCode?: string;
|
|
183
|
-
/**
|
|
184
|
-
* Whether to enable generate and transform entry file
|
|
185
|
-
* @default true
|
|
186
|
-
*/
|
|
187
|
-
transformEntryFile?: boolean;
|
|
188
|
-
/**
|
|
189
|
-
* Whether to enable transform and transform index.html
|
|
190
|
-
* @default true
|
|
191
|
-
*/
|
|
192
|
-
transformIndexHtml?: boolean;
|
|
193
109
|
/**
|
|
194
110
|
* Set default configuration for `<head>`.
|
|
111
|
+
* @default
|
|
112
|
+
* ```json
|
|
113
|
+
* {
|
|
114
|
+
* "meta": [
|
|
115
|
+
* { "charset": "utf-8" },
|
|
116
|
+
* { "name": "viewport", "content": "width=device-width, initial-scale=1" }
|
|
117
|
+
* ]
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* export default defineVixtConfig({
|
|
123
|
+
* app: {
|
|
124
|
+
* head: {
|
|
125
|
+
* meta: [
|
|
126
|
+
* // <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
127
|
+
* { name: 'viewport', content: 'width=device-width, initial-scale=1' }
|
|
128
|
+
* ],
|
|
129
|
+
* script: [
|
|
130
|
+
* // <script src="https://awesome-lib.js"></script>
|
|
131
|
+
* { src: 'https://awesome-lib.js' }
|
|
132
|
+
* ],
|
|
133
|
+
* link: [
|
|
134
|
+
* // <link rel="stylesheet" href="https://awesome-lib.css">
|
|
135
|
+
* { rel: 'stylesheet', href: 'https://awesome-lib.css' }
|
|
136
|
+
* ],
|
|
137
|
+
* style: [
|
|
138
|
+
* // <style type="text/css">:root { color: red }</style>
|
|
139
|
+
* { children: ':root { color: red }', type: 'text/css' }
|
|
140
|
+
* ],
|
|
141
|
+
* noscript: [
|
|
142
|
+
* // <noscript>JavaScript is required</noscript>
|
|
143
|
+
* { children: 'JavaScript is required' }
|
|
144
|
+
* ],
|
|
145
|
+
* title: [
|
|
146
|
+
* // <title>Website Title</title>
|
|
147
|
+
* { children: 'Website Title' }
|
|
148
|
+
* ]
|
|
149
|
+
* }
|
|
150
|
+
* }
|
|
151
|
+
* })
|
|
152
|
+
* ```
|
|
195
153
|
*/
|
|
196
154
|
head?: AppHead;
|
|
197
155
|
/**
|
|
@@ -209,12 +167,36 @@ interface AppOptions {
|
|
|
209
167
|
* @default 'div'
|
|
210
168
|
*/
|
|
211
169
|
rootTag?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Whether to enable generate and transform entry file
|
|
172
|
+
* @default true
|
|
173
|
+
*/
|
|
174
|
+
transformEntryFile?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Whether to enable transform and transform index.html
|
|
177
|
+
* @default true
|
|
178
|
+
*/
|
|
179
|
+
transformIndexHtml?: boolean;
|
|
212
180
|
}
|
|
213
|
-
interface
|
|
214
|
-
|
|
181
|
+
interface BuildOptions {
|
|
182
|
+
/**
|
|
183
|
+
* Set to true to enable bundle analysis, or pass an object with `enabled: true` and options: [vite-bundle-analyzer](https://github.com/nonzzz/vite-bundle-analyzer)
|
|
184
|
+
*/
|
|
185
|
+
analyze?: boolean | ExtractPluginOptions<typeof Analyzer> & {
|
|
186
|
+
enabled?: boolean;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Set to true to enable legacy mode, or pass an object with `enabled: true` and options: [@vitejs/plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy)
|
|
190
|
+
*/
|
|
191
|
+
legacy?: boolean | ExtractPluginOptions<typeof Legacy> & {
|
|
192
|
+
enabled?: boolean;
|
|
193
|
+
};
|
|
215
194
|
}
|
|
216
195
|
interface DevServerOptions extends Pick<ServerOptions, 'port' | 'host' | 'cors'> {
|
|
217
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* Whether to enable HTTPS by using [@vitejs/plugin-basic-ssl](https://github.com/vitejs/vite-plugin-basic-ssl).
|
|
198
|
+
* @default false
|
|
199
|
+
*/
|
|
218
200
|
https?: boolean | ExtractPluginOptions<typeof Ssl> & {
|
|
219
201
|
enabled?: boolean;
|
|
220
202
|
};
|
|
@@ -223,25 +205,41 @@ interface DevServerOptions extends Pick<ServerOptions, 'port' | 'host' | 'cors'>
|
|
|
223
205
|
*/
|
|
224
206
|
watch?: string[];
|
|
225
207
|
}
|
|
226
|
-
interface
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
};
|
|
231
|
-
/** https://github.com/vitejs/vite/tree/main/packages/plugin-legacy */
|
|
232
|
-
legacy?: boolean | ExtractPluginOptions<typeof Legacy> & {
|
|
233
|
-
enabled?: boolean;
|
|
234
|
-
};
|
|
208
|
+
interface ImportsOptions extends ExtractPluginOptions<typeof AutoImport> {}
|
|
209
|
+
interface NitroOptions extends Omit<NitroPluginConfig, 'serverDir'> {
|
|
210
|
+
enabled?: boolean;
|
|
211
|
+
serverDir?: Exclude<NitroPluginConfig['serverDir'], boolean>;
|
|
235
212
|
}
|
|
236
213
|
interface TypescriptOptions {
|
|
237
214
|
references?: (string | {
|
|
238
215
|
path?: string;
|
|
239
216
|
content?: string;
|
|
240
217
|
})[];
|
|
218
|
+
/**
|
|
219
|
+
* You can extend the generated TypeScript configurations (.vixt/tsconfig.json) using this option.
|
|
220
|
+
*/
|
|
241
221
|
tsConfig?: TSConfig & {
|
|
222
|
+
/**
|
|
223
|
+
* @default '@vue/tsconfig/tsconfig.dom.json'
|
|
224
|
+
*/
|
|
225
|
+
extends?: string | string[];
|
|
242
226
|
vueCompilerOptions?: RawVueCompilerOptions;
|
|
243
227
|
};
|
|
244
|
-
/**
|
|
228
|
+
/**
|
|
229
|
+
* Enable build-time or dev-server type checking.
|
|
230
|
+
* @see https://github.com/fi3ework/vite-plugin-checker
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* export default defineVixtConfig({
|
|
234
|
+
* typescript: {
|
|
235
|
+
* typeCheck: {
|
|
236
|
+
* vueTsc: true // for Vue
|
|
237
|
+
* typescript: true // for React
|
|
238
|
+
* },
|
|
239
|
+
* },
|
|
240
|
+
* })
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
245
243
|
typeCheck?: ExtractPluginOptions<typeof Checker>;
|
|
246
244
|
/**
|
|
247
245
|
* Generate a `*.vue` shim
|
|
@@ -249,18 +247,157 @@ interface TypescriptOptions {
|
|
|
249
247
|
*/
|
|
250
248
|
shim?: boolean;
|
|
251
249
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region src/node/types/config.d.ts
|
|
252
|
+
interface VixtConfig {
|
|
253
|
+
/**
|
|
254
|
+
* You can improve your DX by defining additional aliases to access custom directories within your JavaScript and CSS.
|
|
255
|
+
* @default
|
|
256
|
+
* ```json
|
|
257
|
+
* {
|
|
258
|
+
* "@": "/<rootDir>/<srcDir>",
|
|
259
|
+
* "~": "/<rootDir>/<srcDir>",
|
|
260
|
+
* "~~": "/<rootDir>",
|
|
261
|
+
* "@@": "/<rootDir>",
|
|
262
|
+
* "#": "/<rootDir>/<buildDir>"
|
|
263
|
+
* }
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
alias?: AliasOptions;
|
|
267
|
+
/**
|
|
268
|
+
* Vixt App configuration.
|
|
269
|
+
*/
|
|
270
|
+
app?: AppOptions;
|
|
271
|
+
/**
|
|
272
|
+
* Additional app configuration.
|
|
273
|
+
*/
|
|
274
|
+
appConfig?: Record<string, any>;
|
|
275
|
+
/**
|
|
276
|
+
* Shared build configuration.
|
|
277
|
+
*/
|
|
278
|
+
build?: BuildOptions;
|
|
279
|
+
/**
|
|
280
|
+
* Define the directory where your built files will be placed.
|
|
281
|
+
* @default '<rootDir>/.vixt'
|
|
282
|
+
*/
|
|
283
|
+
buildDir?: string;
|
|
284
|
+
/**
|
|
285
|
+
* @default '<buildDir>/types'
|
|
286
|
+
*/
|
|
287
|
+
buildTypesDir?: string;
|
|
288
|
+
/**
|
|
289
|
+
* @default '<buildDir>/layers'
|
|
290
|
+
*/
|
|
291
|
+
buildLayersDir?: string;
|
|
292
|
+
/**
|
|
293
|
+
* Whether to copy layers from `node_modules` to `.vixt/layers`
|
|
294
|
+
* @default true
|
|
295
|
+
* @experimental
|
|
296
|
+
*/
|
|
297
|
+
copyLayers?: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* Set to `true` to enable debug mode.
|
|
300
|
+
* @default false
|
|
301
|
+
*/
|
|
302
|
+
debug?: boolean;
|
|
303
|
+
/**
|
|
304
|
+
* Whether your app is running in development mode.
|
|
305
|
+
* @default false
|
|
306
|
+
*/
|
|
307
|
+
dev?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Set CORS options for the dev server, the `port`, `host`, `cors` options will be passed to `vite.server`
|
|
310
|
+
*/
|
|
311
|
+
devServer?: DevServerOptions;
|
|
312
|
+
/**
|
|
313
|
+
* Extend project from multiple local or remote sources.
|
|
314
|
+
*/
|
|
315
|
+
extends?: string[];
|
|
316
|
+
/**
|
|
317
|
+
* Configure how Vixt auto-imports composables into your application.
|
|
318
|
+
*/
|
|
319
|
+
imports?: ImportsOptions;
|
|
320
|
+
/**
|
|
321
|
+
* Custom meta for layer.
|
|
322
|
+
*/
|
|
323
|
+
meta?: VixtConfigLayerMeta;
|
|
324
|
+
/**
|
|
325
|
+
* Modules are Vixt extensions which can extend its core functionality and add endless integrations.
|
|
326
|
+
*/
|
|
327
|
+
modules?: VixtModule[];
|
|
328
|
+
/**
|
|
329
|
+
* Define the directory of your Vixt modules.
|
|
330
|
+
* @default '<srcDir>/modules'
|
|
331
|
+
*/
|
|
332
|
+
modulesDir?: string;
|
|
333
|
+
/**
|
|
334
|
+
* Configuration for Nitro.
|
|
335
|
+
*/
|
|
336
|
+
nitro?: NitroOptions;
|
|
337
|
+
/**
|
|
338
|
+
* An array of vixt app plugins.
|
|
339
|
+
*/
|
|
340
|
+
plugins?: string[];
|
|
341
|
+
/**
|
|
342
|
+
* Define the directory of your Vixt plugins.
|
|
343
|
+
* @default '<srcDir>/plugins'
|
|
344
|
+
*/
|
|
345
|
+
pluginsDir?: string;
|
|
346
|
+
/**
|
|
347
|
+
* Define the root directory of your application.
|
|
348
|
+
* @default process.cwd()
|
|
349
|
+
*/
|
|
350
|
+
rootDir?: string;
|
|
351
|
+
/**
|
|
352
|
+
* Whether to enable rendering of HTML.
|
|
353
|
+
*/
|
|
354
|
+
ssr?: boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Define the source directory of your application.
|
|
357
|
+
* @default '<rootDir>/src'
|
|
358
|
+
*/
|
|
359
|
+
srcDir?: string;
|
|
360
|
+
/**
|
|
361
|
+
* Whether your app is being unit tested.
|
|
362
|
+
* @default false
|
|
363
|
+
*/
|
|
364
|
+
test?: boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Configuration for TypeScript integration.
|
|
367
|
+
*/
|
|
368
|
+
typescript?: TypescriptOptions;
|
|
369
|
+
/**
|
|
370
|
+
* Configuration that will be passed directly to Vite.
|
|
371
|
+
*/
|
|
372
|
+
vite?: Omit<UserConfig, 'plugins'>;
|
|
373
|
+
/**
|
|
374
|
+
* Define the monorepo workspace directory of your application.
|
|
375
|
+
*/
|
|
376
|
+
workspaceDir?: string;
|
|
257
377
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
378
|
+
/**
|
|
379
|
+
* This is a global declared interface for module `@vixt/core`,
|
|
380
|
+
* it includes some properties that declared in `VueVixtOptions`, `ReactVixtOptions`, etc.,
|
|
381
|
+
* see {@link VixtConfig} to view the common options.
|
|
382
|
+
*/
|
|
383
|
+
interface VixtOptions extends VixtConfig {
|
|
384
|
+
/** custom options */
|
|
385
|
+
[key: string]: any;
|
|
261
386
|
}
|
|
262
|
-
|
|
263
|
-
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/node/config.d.ts
|
|
389
|
+
/**
|
|
390
|
+
* Define the Vixt config.
|
|
391
|
+
* @example
|
|
392
|
+
* ```ts
|
|
393
|
+
* // vixt.config.ts
|
|
394
|
+
* import { defineVixtConfig } from 'vixt'
|
|
395
|
+
*
|
|
396
|
+
* export default defineVixtConfig({
|
|
397
|
+
* // Vixt配置
|
|
398
|
+
* })
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
264
401
|
declare function defineVixtConfig(input: VixtOptions): VixtOptions;
|
|
265
402
|
declare function loadVixtConfig(opts?: LoadVixtConfigOptions): Promise<ResolvedVixtConfig>;
|
|
266
403
|
declare function applyLayers({
|
|
@@ -269,10 +406,9 @@ declare function applyLayers({
|
|
|
269
406
|
}: ResolvedVixtConfig): VixtConfigLayer[];
|
|
270
407
|
declare function isSamePath(a: string, b: string): boolean;
|
|
271
408
|
declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
|
|
272
|
-
declare const VixtClientAutoImports: Record<string, string[]>;
|
|
273
409
|
//#endregion
|
|
274
410
|
//#region src/node/env.d.ts
|
|
275
|
-
/** https://github.com/vitejs/vite/blob/
|
|
411
|
+
/** https://github.com/vitejs/vite/blob/main/packages/vite/src/node/cli.ts */
|
|
276
412
|
interface GlobalCLIOptions {
|
|
277
413
|
'--'?: string[];
|
|
278
414
|
'c'?: boolean | string;
|
|
@@ -306,12 +442,79 @@ declare function findUpWorkspaceDir(): string | undefined;
|
|
|
306
442
|
*/
|
|
307
443
|
declare function loadWorkspaceEnv(mode?: string, prefixes?: string | string[]): Record<string, string>;
|
|
308
444
|
//#endregion
|
|
445
|
+
//#region src/node/module.d.ts
|
|
446
|
+
/**
|
|
447
|
+
* A helper function for creating Vite plugins.
|
|
448
|
+
* @example
|
|
449
|
+
* ```ts
|
|
450
|
+
* import { defineVitePlugin } from 'vixt'
|
|
451
|
+
*
|
|
452
|
+
* interface PluginOptions {
|
|
453
|
+
* enabled?: boolean
|
|
454
|
+
* }
|
|
455
|
+
*
|
|
456
|
+
* export const myVitePlugin = defineVitePlugin<PluginOptions>((options) => {
|
|
457
|
+
* console.log(options)
|
|
458
|
+
* return {
|
|
459
|
+
* name: 'my-vite-plugin',
|
|
460
|
+
* configResolved(config) {
|
|
461
|
+
* console.log(config)
|
|
462
|
+
* }
|
|
463
|
+
* }
|
|
464
|
+
* })
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) => PluginOption): (options?: Options) => PluginOption;
|
|
468
|
+
/**
|
|
469
|
+
* Define a Vixt module.
|
|
470
|
+
* @example
|
|
471
|
+
* ```ts
|
|
472
|
+
* // src/modules/my-module.ts
|
|
473
|
+
* import { defineVixtModule } from 'vixt'
|
|
474
|
+
*
|
|
475
|
+
* interface ModuleOptions {
|
|
476
|
+
* enabled?: boolean
|
|
477
|
+
* }
|
|
478
|
+
*
|
|
479
|
+
* declare module 'vixt' {
|
|
480
|
+
* interface VixtOptions {
|
|
481
|
+
* myModuleOptions?: ModuleOptions
|
|
482
|
+
* }
|
|
483
|
+
* }
|
|
484
|
+
*
|
|
485
|
+
* const name = 'my-module'
|
|
486
|
+
* export default defineVixtModule<ModuleOptions>({
|
|
487
|
+
* meta: { name },
|
|
488
|
+
* defaults: { enabled: true },
|
|
489
|
+
* setup(options, vixt) {
|
|
490
|
+
* console.log(options) // { enabled: true }
|
|
491
|
+
* return {
|
|
492
|
+
* name,
|
|
493
|
+
* configResolved(config) {
|
|
494
|
+
* console.log(config)
|
|
495
|
+
* }
|
|
496
|
+
* } // return one or more vite plugins
|
|
497
|
+
* }
|
|
498
|
+
* })
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
declare function defineVixtModule<T extends ModuleOptions = ModuleOptions>(definition: ModuleDefinition<T> | VixtModule<T>): VixtModule<T>;
|
|
502
|
+
declare function installModule<T extends ModuleOptions = ModuleOptions>(module: VixtModule<T>, inlineOptions: any, vixt: Vixt): PluginOption;
|
|
503
|
+
declare function applyLayerModules({
|
|
504
|
+
config,
|
|
505
|
+
layers
|
|
506
|
+
}: ResolvedVixtConfig): Promise<VixtModule[]>;
|
|
507
|
+
//#endregion
|
|
309
508
|
//#region src/node/modules/index.d.ts
|
|
310
509
|
declare const virtualModuleIds: {
|
|
311
|
-
css: string | undefined;
|
|
312
510
|
appConfig: string | undefined;
|
|
511
|
+
css: string | undefined;
|
|
313
512
|
plugins: string | undefined;
|
|
314
513
|
};
|
|
315
|
-
declare const builtinModules: (VixtModule<ModuleOptions> | VixtModule<AliasOptions> | VixtModule<AppOptions> | VixtModule<BuildOptions> | VixtModule<DevServerOptions> | VixtModule<TypescriptOptions>)[];
|
|
514
|
+
declare const builtinModules: (VixtModule<ModuleOptions> | VixtModule<AliasOptions> | VixtModule<AppOptions> | VixtModule<BuildOptions> | VixtModule<DevServerOptions> | VixtModule<ImportsOptions> | VixtModule<NitroOptions> | VixtModule<TypescriptOptions>)[];
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region src/node/vixt.d.ts
|
|
517
|
+
declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
|
|
518
|
+
declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => _$vite.PluginOption;
|
|
316
519
|
//#endregion
|
|
317
|
-
export { AliasOptions, AppHead, AppHeadAttrs, AppOptions, BuildOptions, DevServerOptions, ExtractPluginOptions, GlobalCLIOptions, LoadVixtConfigOptions, ModuleDefinition, ModuleMeta, ModuleOptions, ResolvedVixtConfig, TypescriptOptions, Vixt,
|
|
520
|
+
export { AliasOptions, AppHead, AppHeadAttrs, AppOptions, BuildOptions, DevServerOptions, ExtractPluginOptions, GlobalCLIOptions, ImportsOptions, LoadVixtConfigOptions, ModuleDefinition, ModuleMeta, ModuleOptions, NitroOptions, ResolvedVixtConfig, TypescriptOptions, Vixt, VixtConfig, VixtConfigLayer, VixtConfigLayerMeta, VixtModule, VixtOptions, applyLayerModules, applyLayers, builtinModules, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, findUpWorkspaceDir, installModule, isSamePath, loadCLIOptions, loadEnv, loadMode, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, virtualModuleIds };
|