@vixt/core 0.5.16 → 0.6.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/client/index.d.ts +21 -8
- package/dist/client/index.js +28 -0
- package/dist/index.d.mts +293 -0
- package/dist/index.mjs +643 -0
- package/package.json +14 -19
- package/dist/client/index.d.mts +0 -18
- package/dist/client/index.mjs +0 -11
- package/dist/node/index.d.mts +0 -182
- package/dist/node/index.d.ts +0 -182
- package/dist/node/index.mjs +0 -457
package/dist/client/index.d.ts
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
+
//#region src/client/app.d.ts
|
|
1
2
|
interface VixtApp {
|
|
2
|
-
|
|
3
|
+
app: any;
|
|
4
|
+
appConfig: VixtAppConfig;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
interface CreateOptions {
|
|
8
|
+
app: any;
|
|
9
|
+
appConfig: VixtAppConfig;
|
|
3
10
|
}
|
|
4
11
|
interface VixtAppConfig extends Record<string, any> {
|
|
12
|
+
readonly baseURL?: string;
|
|
13
|
+
readonly rootId?: string;
|
|
5
14
|
}
|
|
6
15
|
declare function defineAppConfig(config: VixtAppConfig): VixtAppConfig;
|
|
7
|
-
|
|
16
|
+
declare function useAppConfig(): VixtAppConfig;
|
|
17
|
+
declare function useVixtApp(): VixtApp;
|
|
18
|
+
declare function createVixtApp(options: CreateOptions): VixtApp;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/client/plugin.d.ts
|
|
8
21
|
interface PluginDefinition {
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
name?: string;
|
|
23
|
+
setup?: (this: void, vixt: VixtApp) => any;
|
|
11
24
|
}
|
|
12
25
|
interface VixtPlugin {
|
|
13
|
-
|
|
26
|
+
(this: void, vixt: VixtApp): any;
|
|
14
27
|
}
|
|
15
28
|
declare function defineVixtPlugin(definition: PluginDefinition | VixtPlugin): VixtPlugin;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export
|
|
29
|
+
declare function applyPlugins(vixt: VixtApp, plugins: VixtPlugin[]): Promise<void>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { CreateOptions, PluginDefinition, VixtApp, VixtAppConfig, VixtPlugin, applyPlugins, createVixtApp, defineAppConfig, defineVixtPlugin, useAppConfig, useVixtApp };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/client/app.ts
|
|
2
|
+
function defineAppConfig(config) {
|
|
3
|
+
return config;
|
|
4
|
+
}
|
|
5
|
+
function useAppConfig() {
|
|
6
|
+
return useVixtApp()?.appConfig ?? {};
|
|
7
|
+
}
|
|
8
|
+
function useVixtApp() {
|
|
9
|
+
return globalThis.useVixtApp?.();
|
|
10
|
+
}
|
|
11
|
+
function createVixtApp(options) {
|
|
12
|
+
const vixtApp = { ...options };
|
|
13
|
+
globalThis.useVixtApp = () => vixtApp;
|
|
14
|
+
return vixtApp;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/client/plugin.ts
|
|
19
|
+
function defineVixtPlugin(definition) {
|
|
20
|
+
if (typeof definition == "function") return defineVixtPlugin({ setup: definition });
|
|
21
|
+
return (vixt) => definition.setup?.(vixt);
|
|
22
|
+
}
|
|
23
|
+
async function applyPlugins(vixt, plugins) {
|
|
24
|
+
for (const plugin of plugins) typeof plugin === "function" && await plugin(vixt);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { applyPlugins, createVixtApp, defineAppConfig, defineVixtPlugin, useAppConfig, useVixtApp };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import * as c120 from "c12";
|
|
2
|
+
import { ConfigLayer, ConfigLayerMeta, LoadConfigOptions } from "c12";
|
|
3
|
+
import * as vite0 from "vite";
|
|
4
|
+
import { HtmlTagDescriptor, InlineConfig, LogLevel, PluginOption, ServerOptions, UserConfig } from "vite";
|
|
5
|
+
import Legacy from "@vitejs/plugin-legacy";
|
|
6
|
+
import Analyzer from "vite-bundle-analyzer";
|
|
7
|
+
import Ssl from "@vitejs/plugin-basic-ssl";
|
|
8
|
+
import Checker from "vite-plugin-checker";
|
|
9
|
+
import { RawVueCompilerOptions } from "@vue/language-core";
|
|
10
|
+
import { TSConfig } from "pkg-types";
|
|
11
|
+
|
|
12
|
+
//#region src/node/vixt.d.ts
|
|
13
|
+
interface Vixt {
|
|
14
|
+
options: VixtOptions;
|
|
15
|
+
_layers: VixtConfigLayer[];
|
|
16
|
+
_modules: VixtModule[];
|
|
17
|
+
}
|
|
18
|
+
declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
|
|
19
|
+
declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => vite0.PluginOption;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/node/module.d.ts
|
|
22
|
+
type ExtractPluginOptions<Options = any> = (Options extends ((...args: any[]) => any) ? Parameters<Options>[0] : Options);
|
|
23
|
+
type ModuleOptions = Record<string, any>;
|
|
24
|
+
interface ModuleMeta extends Record<string, any> {
|
|
25
|
+
name?: string;
|
|
26
|
+
configKey?: string;
|
|
27
|
+
}
|
|
28
|
+
interface ModuleDefinition<T extends ModuleOptions = ModuleOptions> {
|
|
29
|
+
meta?: ModuleMeta;
|
|
30
|
+
defaults?: Partial<T> | ((vixt: Vixt) => Partial<T>);
|
|
31
|
+
setup?: (this: void, resolvedOptions: T, vixt: Vixt) => PluginOption | void;
|
|
32
|
+
}
|
|
33
|
+
interface VixtModule<T extends ModuleOptions = ModuleOptions> {
|
|
34
|
+
(this: void, resolvedOptions: T, vixt: Vixt): PluginOption;
|
|
35
|
+
getOptions?: (inlineOptions: Partial<T>, Vixt: Vixt) => T;
|
|
36
|
+
getMeta?: () => ModuleMeta;
|
|
37
|
+
}
|
|
38
|
+
declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) => PluginOption): (options?: Options) => PluginOption;
|
|
39
|
+
declare function defineVixtModule<T extends ModuleOptions>(definition: ModuleDefinition<T> | VixtModule<T>): VixtModule<T>;
|
|
40
|
+
declare function installModule<T extends ModuleOptions = ModuleOptions>(module: VixtModule<T>, inlineOptions: any, vixt: Vixt): PluginOption;
|
|
41
|
+
declare function applyLayerModules(layers: VixtConfigLayer[]): Promise<VixtModule[]>;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/node/config.d.ts
|
|
44
|
+
interface VixtOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Vixt App configuration.
|
|
47
|
+
*/
|
|
48
|
+
app?: AppOptions;
|
|
49
|
+
/**
|
|
50
|
+
* Shared build configuration.
|
|
51
|
+
*/
|
|
52
|
+
build?: BuildOptions;
|
|
53
|
+
/**
|
|
54
|
+
* Define the root directory of your application.
|
|
55
|
+
* @default process.cwd()
|
|
56
|
+
*/
|
|
57
|
+
rootDir?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Define the monorepo workspace directory of your application.
|
|
60
|
+
*/
|
|
61
|
+
workspaceDir?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Define the source directory of your application.
|
|
64
|
+
* @default '<rootDir>/src'
|
|
65
|
+
*/
|
|
66
|
+
srcDir?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Define the server directory of your application.
|
|
69
|
+
* @default '<rootDir>/server'
|
|
70
|
+
*/
|
|
71
|
+
serverDir?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Define the directory where your built files will be placed.
|
|
74
|
+
* @default '<rootDir>/.vixt'
|
|
75
|
+
*/
|
|
76
|
+
buildDir?: string;
|
|
77
|
+
/**
|
|
78
|
+
* @default '<buildDir>/types'
|
|
79
|
+
*/
|
|
80
|
+
buildTypesDir?: string;
|
|
81
|
+
/**
|
|
82
|
+
* @default '<buildDir>/layers'
|
|
83
|
+
*/
|
|
84
|
+
buildLayersDir?: string;
|
|
85
|
+
/**
|
|
86
|
+
* @default '<buildDir>/imports'
|
|
87
|
+
*/
|
|
88
|
+
buildImportsDir?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Define the directory of your Vixt modules.
|
|
91
|
+
* @default '<srcDir>/modules'
|
|
92
|
+
*/
|
|
93
|
+
modulesDir?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Define the directory of your Vixt plugins.
|
|
96
|
+
* @default '<srcDir>/plugins'
|
|
97
|
+
*/
|
|
98
|
+
pluginsDir?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Whether your app is running in development mode.
|
|
101
|
+
* @default false
|
|
102
|
+
*/
|
|
103
|
+
dev?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether your app is being unit tested.
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
test?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Set to `true` to enable debug mode.
|
|
111
|
+
* @default false
|
|
112
|
+
*/
|
|
113
|
+
debug?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Whether to enable rendering of HTML.
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
ssr?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* You can improve your DX by defining additional aliases to access custom directories within your JavaScript and CSS.
|
|
121
|
+
*/
|
|
122
|
+
alias?: AliasOptions;
|
|
123
|
+
/**
|
|
124
|
+
* Configuration that will be passed directly to Vite.
|
|
125
|
+
*/
|
|
126
|
+
appConfig?: Record<string, any>;
|
|
127
|
+
devServer?: DevServerOptions;
|
|
128
|
+
/** Vite config input */
|
|
129
|
+
vite?: Omit<UserConfig, 'plugins'>;
|
|
130
|
+
/** layer meta */
|
|
131
|
+
meta?: VixtConfigLayerMeta;
|
|
132
|
+
/** layers */
|
|
133
|
+
extends?: string[];
|
|
134
|
+
/** modules */
|
|
135
|
+
modules?: VixtModule[];
|
|
136
|
+
/** plugins */
|
|
137
|
+
plugins?: string[];
|
|
138
|
+
/** typescript */
|
|
139
|
+
typescript?: TypescriptOptions;
|
|
140
|
+
/** custom options */
|
|
141
|
+
[key: string]: any;
|
|
142
|
+
}
|
|
143
|
+
interface AppHeadAttrs {
|
|
144
|
+
children?: string;
|
|
145
|
+
injectTo?: HtmlTagDescriptor['injectTo'];
|
|
146
|
+
[key: string]: string | boolean | undefined;
|
|
147
|
+
}
|
|
148
|
+
interface AppHead {
|
|
149
|
+
title?: AppHeadAttrs[];
|
|
150
|
+
link?: AppHeadAttrs[];
|
|
151
|
+
meta?: AppHeadAttrs[];
|
|
152
|
+
style?: AppHeadAttrs[];
|
|
153
|
+
script?: AppHeadAttrs[];
|
|
154
|
+
noscript?: AppHeadAttrs[];
|
|
155
|
+
}
|
|
156
|
+
interface AppOptions {
|
|
157
|
+
/**
|
|
158
|
+
* The base path of your Nuxt application.
|
|
159
|
+
* @default '/'
|
|
160
|
+
*/
|
|
161
|
+
baseURL?: string;
|
|
162
|
+
/**
|
|
163
|
+
* You can define the CSS files/modules/libraries you want to set globally.
|
|
164
|
+
*/
|
|
165
|
+
css?: string[];
|
|
166
|
+
/**
|
|
167
|
+
* The entry file relative to <srcDir>
|
|
168
|
+
* @default 'main.ts'(vue)
|
|
169
|
+
* @default 'main.tsx'(react)
|
|
170
|
+
* @example 'entry.ts'(means '/<srcDir>/entry.ts')
|
|
171
|
+
*/
|
|
172
|
+
entryFile?: string;
|
|
173
|
+
entryCode?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Set default configuration for `<head>`.
|
|
176
|
+
*/
|
|
177
|
+
head?: AppHead;
|
|
178
|
+
/**
|
|
179
|
+
* The path to an HTML file with the contents of which will be inserted into index.html.
|
|
180
|
+
* Some good sources for spinners are [SpinKit](https://github.com/tobiasahlin/SpinKit) or [SVG Spinners](https://icones.js.org/collection/svg-spinners).
|
|
181
|
+
*/
|
|
182
|
+
loadingTemplate?: string;
|
|
183
|
+
/**
|
|
184
|
+
* Customize Vixt root element id.
|
|
185
|
+
* @default 'app'
|
|
186
|
+
*/
|
|
187
|
+
rootId?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Customize Vixt root element tag.
|
|
190
|
+
* @default 'div'
|
|
191
|
+
*/
|
|
192
|
+
rootTag?: string;
|
|
193
|
+
}
|
|
194
|
+
interface AliasOptions {
|
|
195
|
+
[find: string]: string;
|
|
196
|
+
}
|
|
197
|
+
interface DevServerOptions extends Pick<ServerOptions, 'port' | 'host' | 'cors'> {
|
|
198
|
+
/** https://github.com/vitejs/vite-plugin-basic-ssl */
|
|
199
|
+
https?: boolean | ExtractPluginOptions<typeof Ssl> & {
|
|
200
|
+
enabled?: boolean;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* The watch property lets you define patterns that will restart the dev server when changed.
|
|
204
|
+
*/
|
|
205
|
+
watch?: string[];
|
|
206
|
+
}
|
|
207
|
+
interface BuildOptions {
|
|
208
|
+
/** https://github.com/nonzzz/vite-bundle-analyzer */
|
|
209
|
+
analyze?: boolean | ExtractPluginOptions<typeof Analyzer> & {
|
|
210
|
+
enabled?: boolean;
|
|
211
|
+
};
|
|
212
|
+
/** https://github.com/vitejs/vite/tree/main/packages/plugin-legacy */
|
|
213
|
+
legacy?: boolean | ExtractPluginOptions<typeof Legacy> & {
|
|
214
|
+
enabled?: boolean;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
interface TypescriptOptions {
|
|
218
|
+
references?: (string | {
|
|
219
|
+
path?: string;
|
|
220
|
+
content?: string;
|
|
221
|
+
})[];
|
|
222
|
+
tsConfig?: TSConfig & {
|
|
223
|
+
vueCompilerOptions?: RawVueCompilerOptions;
|
|
224
|
+
};
|
|
225
|
+
/** https://github.com/fi3ework/vite-plugin-checker */
|
|
226
|
+
typeCheck?: ExtractPluginOptions<typeof Checker>;
|
|
227
|
+
/**
|
|
228
|
+
* Generate a `*.vue` shim
|
|
229
|
+
* @default false
|
|
230
|
+
*/
|
|
231
|
+
shim?: boolean;
|
|
232
|
+
}
|
|
233
|
+
interface VixtConfigLayerMeta extends ConfigLayerMeta {
|
|
234
|
+
/** layer name */
|
|
235
|
+
name?: string;
|
|
236
|
+
/** layer alias */
|
|
237
|
+
alias?: string;
|
|
238
|
+
}
|
|
239
|
+
interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta> {
|
|
240
|
+
/** when layer is in node_modules, layer will copy to `<buildLayersDir>/<layerName>`, and change cwd */
|
|
241
|
+
cwd?: string;
|
|
242
|
+
}
|
|
243
|
+
declare function defineVixtConfig(input: VixtOptions): VixtOptions;
|
|
244
|
+
declare function loadVixtConfig(opts?: LoadConfigOptions<VixtOptions>): Promise<c120.ResolvedConfig<VixtOptions, ConfigLayerMeta>>;
|
|
245
|
+
declare function applyLayers(layers: VixtConfigLayer[], config: VixtOptions): VixtConfigLayer[];
|
|
246
|
+
declare function isSamePath(a: string, b: string): boolean;
|
|
247
|
+
declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
|
|
248
|
+
declare const VixtClientAutoImports: Record<string, string[]>;
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/node/env.d.ts
|
|
251
|
+
/** https://github.com/vitejs/vite/blob/v8.0.0-beta.3/packages/vite/src/node/cli.ts */
|
|
252
|
+
interface GlobalCLIOptions {
|
|
253
|
+
'--'?: string[];
|
|
254
|
+
'c'?: boolean | string;
|
|
255
|
+
'config'?: string;
|
|
256
|
+
'base'?: string;
|
|
257
|
+
'l'?: LogLevel;
|
|
258
|
+
'logLevel'?: LogLevel;
|
|
259
|
+
'clearScreen'?: boolean;
|
|
260
|
+
'configLoader'?: InlineConfig['configLoader'];
|
|
261
|
+
'd'?: boolean | string;
|
|
262
|
+
'debug'?: boolean | string;
|
|
263
|
+
'f'?: string;
|
|
264
|
+
'filter'?: string;
|
|
265
|
+
'm'?: string;
|
|
266
|
+
'mode'?: string;
|
|
267
|
+
'force'?: boolean;
|
|
268
|
+
'w'?: boolean;
|
|
269
|
+
}
|
|
270
|
+
declare function loadCLIOptions(): GlobalCLIOptions;
|
|
271
|
+
declare function loadMode(): string | undefined;
|
|
272
|
+
/**
|
|
273
|
+
* Load workspace and cwd env variables by default
|
|
274
|
+
*/
|
|
275
|
+
declare function loadEnv(mode?: string, envDir?: string | false, prefixes?: string | string[]): ImportMeta["env"];
|
|
276
|
+
/**
|
|
277
|
+
* find the workspace dir
|
|
278
|
+
*/
|
|
279
|
+
declare function findUpWorkspaceDir(): string | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* Load workspace env variables
|
|
282
|
+
*/
|
|
283
|
+
declare function loadWorkspaceEnv(mode?: string, prefixes?: string | string[]): Record<string, string>;
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/node/modules/index.d.ts
|
|
286
|
+
declare const virtualModuleIds: {
|
|
287
|
+
css: string | undefined;
|
|
288
|
+
appConfig: string | undefined;
|
|
289
|
+
plugins: string | undefined;
|
|
290
|
+
};
|
|
291
|
+
declare const builtinModules: (VixtModule<ModuleOptions> | VixtModule<AliasOptions> | VixtModule<AppOptions> | VixtModule<BuildOptions> | VixtModule<DevServerOptions> | VixtModule<TypescriptOptions>)[];
|
|
292
|
+
//#endregion
|
|
293
|
+
export { AliasOptions, AppHead, AppHeadAttrs, AppOptions, BuildOptions, DevServerOptions, ExtractPluginOptions, GlobalCLIOptions, ModuleDefinition, ModuleMeta, ModuleOptions, TypescriptOptions, Vixt, VixtClientAutoImports, VixtConfigLayer, VixtConfigLayerMeta, VixtModule, VixtOptions, applyLayerModules, applyLayers, builtinModules, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, findUpWorkspaceDir, installModule, isSamePath, loadCLIOptions, loadEnv, loadMode, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, virtualModuleIds };
|