@vixt/core 0.0.6 → 0.0.7
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/index.d.mts +2 -41
- package/dist/index.d.ts +2 -41
- package/dist/index.mjs +57 -113
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
|
-
import { PluginOption, UserConfig, TransformResult
|
|
2
|
+
import { PluginOption, UserConfig, TransformResult } from 'vite';
|
|
3
3
|
import * as c12 from 'c12';
|
|
4
4
|
import { ConfigLayer, LoadConfigOptions } from 'c12';
|
|
5
5
|
import { TSConfig } from 'pkg-types';
|
|
@@ -95,27 +95,6 @@ declare const app: VixtModule<AppOptions>;
|
|
|
95
95
|
|
|
96
96
|
declare const config: VixtModule<ModuleOptions>;
|
|
97
97
|
|
|
98
|
-
declare module '@vixt/core' {
|
|
99
|
-
interface VixtOptions {
|
|
100
|
-
devProxy?: DevProxyOptions;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
interface DevProxyOptions {
|
|
104
|
-
/**
|
|
105
|
-
* 环境变量的 key
|
|
106
|
-
* @default 'VITE_PROXY'
|
|
107
|
-
*/
|
|
108
|
-
key?: string;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* @param list [prefix,target,rewrite?][]
|
|
112
|
-
*/
|
|
113
|
-
declare function transformProxy(list: string): {
|
|
114
|
-
[k: string]: ProxyOptions;
|
|
115
|
-
};
|
|
116
|
-
/** 为 vite 开发服务添加代理配置 */
|
|
117
|
-
declare const devProxy: VixtModule<DevProxyOptions>;
|
|
118
|
-
|
|
119
98
|
declare module '@vixt/core' {
|
|
120
99
|
interface VixtOptions {
|
|
121
100
|
typescript?: TypescriptOptions;
|
|
@@ -132,24 +111,6 @@ interface TypescriptOptions {
|
|
|
132
111
|
}
|
|
133
112
|
declare const typescript: VixtModule<TypescriptOptions>;
|
|
134
113
|
|
|
135
|
-
declare module '@vixt/core' {
|
|
136
|
-
interface VixtOptions {
|
|
137
|
-
warmup?: WarmupOptions;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
interface WarmupOptions {
|
|
141
|
-
enabled?: boolean;
|
|
142
|
-
/**
|
|
143
|
-
* The files to be transformed and used on the client-side. Supports glob patterns.
|
|
144
|
-
*/
|
|
145
|
-
clientFiles?: string[];
|
|
146
|
-
/**
|
|
147
|
-
* The files to be transformed and used in SSR. Supports glob patterns.
|
|
148
|
-
*/
|
|
149
|
-
ssrFiles?: string[];
|
|
150
|
-
}
|
|
151
|
-
declare const warmup: VixtModule<WarmupOptions>;
|
|
152
|
-
|
|
153
114
|
declare function defineVixtConfig(input: VixtOptions): VixtOptions;
|
|
154
115
|
declare const rootDir: string;
|
|
155
116
|
declare const buildDir = ".vixt";
|
|
@@ -165,4 +126,4 @@ declare function applyLayerModules(layers?: VixtConfigLayer[]): Promise<VixtModu
|
|
|
165
126
|
declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
|
|
166
127
|
declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => vite.PluginOption;
|
|
167
128
|
|
|
168
|
-
export { type AppHead, type AppOptions, type
|
|
129
|
+
export { type AppHead, type AppOptions, type ModuleDefinition, type ModuleMeta, type ModuleOptions, type PluginOptions, type TypescriptOptions, type Vixt, type VixtConfigLayer, type VixtModule, type VixtOptions, alias, app, applyLayerModules, buildDir, buildTypesDir, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadVixt, loadVixtConfig, resolveLayersDirs, rootDir, typescript };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
|
-
import { PluginOption, UserConfig, TransformResult
|
|
2
|
+
import { PluginOption, UserConfig, TransformResult } from 'vite';
|
|
3
3
|
import * as c12 from 'c12';
|
|
4
4
|
import { ConfigLayer, LoadConfigOptions } from 'c12';
|
|
5
5
|
import { TSConfig } from 'pkg-types';
|
|
@@ -95,27 +95,6 @@ declare const app: VixtModule<AppOptions>;
|
|
|
95
95
|
|
|
96
96
|
declare const config: VixtModule<ModuleOptions>;
|
|
97
97
|
|
|
98
|
-
declare module '@vixt/core' {
|
|
99
|
-
interface VixtOptions {
|
|
100
|
-
devProxy?: DevProxyOptions;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
interface DevProxyOptions {
|
|
104
|
-
/**
|
|
105
|
-
* 环境变量的 key
|
|
106
|
-
* @default 'VITE_PROXY'
|
|
107
|
-
*/
|
|
108
|
-
key?: string;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* @param list [prefix,target,rewrite?][]
|
|
112
|
-
*/
|
|
113
|
-
declare function transformProxy(list: string): {
|
|
114
|
-
[k: string]: ProxyOptions;
|
|
115
|
-
};
|
|
116
|
-
/** 为 vite 开发服务添加代理配置 */
|
|
117
|
-
declare const devProxy: VixtModule<DevProxyOptions>;
|
|
118
|
-
|
|
119
98
|
declare module '@vixt/core' {
|
|
120
99
|
interface VixtOptions {
|
|
121
100
|
typescript?: TypescriptOptions;
|
|
@@ -132,24 +111,6 @@ interface TypescriptOptions {
|
|
|
132
111
|
}
|
|
133
112
|
declare const typescript: VixtModule<TypescriptOptions>;
|
|
134
113
|
|
|
135
|
-
declare module '@vixt/core' {
|
|
136
|
-
interface VixtOptions {
|
|
137
|
-
warmup?: WarmupOptions;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
interface WarmupOptions {
|
|
141
|
-
enabled?: boolean;
|
|
142
|
-
/**
|
|
143
|
-
* The files to be transformed and used on the client-side. Supports glob patterns.
|
|
144
|
-
*/
|
|
145
|
-
clientFiles?: string[];
|
|
146
|
-
/**
|
|
147
|
-
* The files to be transformed and used in SSR. Supports glob patterns.
|
|
148
|
-
*/
|
|
149
|
-
ssrFiles?: string[];
|
|
150
|
-
}
|
|
151
|
-
declare const warmup: VixtModule<WarmupOptions>;
|
|
152
|
-
|
|
153
114
|
declare function defineVixtConfig(input: VixtOptions): VixtOptions;
|
|
154
115
|
declare const rootDir: string;
|
|
155
116
|
declare const buildDir = ".vixt";
|
|
@@ -165,4 +126,4 @@ declare function applyLayerModules(layers?: VixtConfigLayer[]): Promise<VixtModu
|
|
|
165
126
|
declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
|
|
166
127
|
declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => vite.PluginOption;
|
|
167
128
|
|
|
168
|
-
export { type AppHead, type AppOptions, type
|
|
129
|
+
export { type AppHead, type AppOptions, type ModuleDefinition, type ModuleMeta, type ModuleOptions, type PluginOptions, type TypescriptOptions, type Vixt, type VixtConfigLayer, type VixtModule, type VixtOptions, alias, app, applyLayerModules, buildDir, buildTypesDir, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadVixt, loadVixtConfig, resolveLayersDirs, rootDir, typescript };
|
package/dist/index.mjs
CHANGED
|
@@ -4,15 +4,15 @@ import fs from 'fs-extra';
|
|
|
4
4
|
import 'tsx/esm';
|
|
5
5
|
import { pathToFileURL } from 'mlly';
|
|
6
6
|
import defu from 'defu';
|
|
7
|
-
import Checker from 'vite-plugin-checker';
|
|
8
7
|
import { loadConfig } from 'c12';
|
|
8
|
+
import Checker from 'vite-plugin-checker';
|
|
9
9
|
|
|
10
|
-
const name$
|
|
10
|
+
const name$3 = "vixt:alias";
|
|
11
11
|
const alias = defineVixtModule({
|
|
12
|
-
meta: { name: name$
|
|
12
|
+
meta: { name: name$3 },
|
|
13
13
|
setup(_, vixt) {
|
|
14
14
|
return {
|
|
15
|
-
name: name$
|
|
15
|
+
name: name$3,
|
|
16
16
|
config() {
|
|
17
17
|
return {
|
|
18
18
|
root: vixt.options.rootDir,
|
|
@@ -30,6 +30,42 @@ const alias = defineVixtModule({
|
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
function defineVixtConfig(input) {
|
|
34
|
+
return input;
|
|
35
|
+
}
|
|
36
|
+
const rootDir = cwd();
|
|
37
|
+
const buildDir = ".vixt";
|
|
38
|
+
const buildTypesDir = `${buildDir}/types`;
|
|
39
|
+
async function loadVixtConfig(opts) {
|
|
40
|
+
const result = await loadConfig({
|
|
41
|
+
name: "vixt",
|
|
42
|
+
rcFile: false,
|
|
43
|
+
...opts,
|
|
44
|
+
defaults: {
|
|
45
|
+
rootDir,
|
|
46
|
+
buildDir,
|
|
47
|
+
buildTypesDir,
|
|
48
|
+
...opts?.defaults
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
result.layers = result.layers?.filter((e) => e.cwd);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
function resolveLayersDirs(layers = []) {
|
|
55
|
+
const dirs = {};
|
|
56
|
+
for (const layer of layers) {
|
|
57
|
+
const contents = fs.readdirSync(path.resolve(layer.cwd, "src"));
|
|
58
|
+
for (const content of contents) {
|
|
59
|
+
const fileOrDirPath = path.resolve(layer.cwd, "src", content);
|
|
60
|
+
if (fs.statSync(fileOrDirPath).isDirectory()) {
|
|
61
|
+
dirs[content] ?? (dirs[content] = []);
|
|
62
|
+
dirs[content].push(fileOrDirPath);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return dirs;
|
|
67
|
+
}
|
|
68
|
+
|
|
33
69
|
function defineVitePlugin(pluginFn) {
|
|
34
70
|
return pluginFn;
|
|
35
71
|
}
|
|
@@ -72,39 +108,6 @@ async function applyLayerModules(layers) {
|
|
|
72
108
|
return modules;
|
|
73
109
|
}
|
|
74
110
|
|
|
75
|
-
function defineVixtConfig(input) {
|
|
76
|
-
return input;
|
|
77
|
-
}
|
|
78
|
-
const rootDir = cwd();
|
|
79
|
-
const buildDir = ".vixt";
|
|
80
|
-
const buildTypesDir = `${buildDir}/types`;
|
|
81
|
-
function loadVixtConfig(opts) {
|
|
82
|
-
return loadConfig({
|
|
83
|
-
name: "vixt",
|
|
84
|
-
...opts,
|
|
85
|
-
defaults: {
|
|
86
|
-
rootDir,
|
|
87
|
-
buildDir,
|
|
88
|
-
buildTypesDir,
|
|
89
|
-
...opts?.defaults
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function resolveLayersDirs(layers) {
|
|
94
|
-
const dirs = {};
|
|
95
|
-
for (const layer of layers?.filter((e) => e.cwd) ?? []) {
|
|
96
|
-
const contents = fs.readdirSync(path.resolve(layer.cwd, "src"));
|
|
97
|
-
for (const content of contents) {
|
|
98
|
-
const fileOrDirPath = path.resolve(layer.cwd, "src", content);
|
|
99
|
-
if (fs.statSync(fileOrDirPath).isDirectory()) {
|
|
100
|
-
dirs[content] ?? (dirs[content] = []);
|
|
101
|
-
dirs[content].push(fileOrDirPath);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return dirs;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
111
|
function resolveHeadTag(tag, attrs) {
|
|
109
112
|
const attrsStr = Object.entries(attrs).filter(([k]) => k !== "children").map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
110
113
|
return attrs?.children ? `<${tag} ${attrsStr}>${attrs.children}</${tag}>` : `<${tag} ${attrsStr} />`;
|
|
@@ -141,10 +144,11 @@ ${noscriptTemplate}
|
|
|
141
144
|
fs.outputFileSync(path.resolve(rootDir, `${buildDir2}/index.html`), code);
|
|
142
145
|
return code;
|
|
143
146
|
}
|
|
144
|
-
const name$
|
|
145
|
-
const defaults$
|
|
147
|
+
const name$2 = "vixt:app";
|
|
148
|
+
const defaults$1 = {
|
|
146
149
|
rootId: "app",
|
|
147
150
|
rootTag: "div",
|
|
151
|
+
baseURL: "/",
|
|
148
152
|
loadingTemplate: "./loading.html",
|
|
149
153
|
main: `${buildDir}/main.ts`,
|
|
150
154
|
head: {
|
|
@@ -156,12 +160,12 @@ const defaults$2 = {
|
|
|
156
160
|
}
|
|
157
161
|
};
|
|
158
162
|
const app = defineVixtModule({
|
|
159
|
-
meta: { name: name$
|
|
160
|
-
defaults: defaults$
|
|
163
|
+
meta: { name: name$2, configKey: "app" },
|
|
164
|
+
defaults: defaults$1,
|
|
161
165
|
setup(options, vixt) {
|
|
162
166
|
generateIndexHtml(options, vixt);
|
|
163
167
|
return {
|
|
164
|
-
name: name$
|
|
168
|
+
name: name$2,
|
|
165
169
|
transformIndexHtml: {
|
|
166
170
|
order: "pre",
|
|
167
171
|
handler() {
|
|
@@ -181,12 +185,12 @@ const app = defineVixtModule({
|
|
|
181
185
|
}
|
|
182
186
|
});
|
|
183
187
|
|
|
184
|
-
const name$
|
|
188
|
+
const name$1 = "vixt:config";
|
|
185
189
|
const config = defineVixtModule({
|
|
186
|
-
meta: { name: name$
|
|
190
|
+
meta: { name: name$1 },
|
|
187
191
|
setup(options, vixt) {
|
|
188
192
|
return {
|
|
189
|
-
name: name$
|
|
193
|
+
name: name$1,
|
|
190
194
|
enforce: "pre",
|
|
191
195
|
config(config2) {
|
|
192
196
|
vixt.options.vite = config2;
|
|
@@ -198,41 +202,6 @@ const config = defineVixtModule({
|
|
|
198
202
|
}
|
|
199
203
|
});
|
|
200
204
|
|
|
201
|
-
function transformProxy(list) {
|
|
202
|
-
return Object.fromEntries(
|
|
203
|
-
JSON.parse(list).map(([prefix, target, rewrite]) => {
|
|
204
|
-
const option = {
|
|
205
|
-
target,
|
|
206
|
-
changeOrigin: true,
|
|
207
|
-
ws: true,
|
|
208
|
-
secure: /^https:\/\//.test(target)
|
|
209
|
-
};
|
|
210
|
-
if (rewrite)
|
|
211
|
-
option.rewrite = (path) => path.replace(new RegExp(`^${prefix}`), "");
|
|
212
|
-
return [prefix, option];
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
const name$2 = "vixt:dev-proxy";
|
|
217
|
-
const devProxy = defineVixtModule({
|
|
218
|
-
meta: { name: name$2, configKey: "devProxy" },
|
|
219
|
-
defaults: { key: "VITE_PROXY" },
|
|
220
|
-
setup(options) {
|
|
221
|
-
return {
|
|
222
|
-
name: name$2,
|
|
223
|
-
configResolved(config) {
|
|
224
|
-
const { env } = config;
|
|
225
|
-
const proxyList = env[options.key];
|
|
226
|
-
if (proxyList) {
|
|
227
|
-
const proxy = transformProxy(proxyList);
|
|
228
|
-
config.server.proxy = defu(proxy, config.server.proxy);
|
|
229
|
-
config.preview.proxy = defu(proxy, config.server.proxy);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
|
|
236
205
|
function generateDts(options, vixt, config) {
|
|
237
206
|
const { root } = config;
|
|
238
207
|
const { buildDir } = vixt.options;
|
|
@@ -253,7 +222,7 @@ function generateTsConfig(options, vixt, config) {
|
|
|
253
222
|
const { root } = config;
|
|
254
223
|
const { buildDir } = vixt.options;
|
|
255
224
|
const tsConfigPath = path.resolve(root, buildDir, "tsconfig.json");
|
|
256
|
-
const layersDirs = vixt._layers.
|
|
225
|
+
const layersDirs = vixt._layers.map((e) => e.cwd);
|
|
257
226
|
const tsConfig = defu(options.tsConfig, { include: layersDirs });
|
|
258
227
|
fs.outputFileSync(tsConfigPath, JSON.stringify(tsConfig, null, 2));
|
|
259
228
|
}
|
|
@@ -286,8 +255,8 @@ declare module '*.vue' {
|
|
|
286
255
|
const shimsDtsPath = path.resolve(root, buildDir, "types", "shims.d.ts");
|
|
287
256
|
fs.outputFileSync(shimsDtsPath, shimsDts);
|
|
288
257
|
}
|
|
289
|
-
const name
|
|
290
|
-
const defaults
|
|
258
|
+
const name = "vixt:typescript";
|
|
259
|
+
const defaults = {
|
|
291
260
|
references: ["./types/vite-env.d.ts", "./types/shims.d.ts"],
|
|
292
261
|
tsConfig: {
|
|
293
262
|
extends: "@vue/tsconfig/tsconfig.dom.json",
|
|
@@ -307,12 +276,12 @@ const defaults$1 = {
|
|
|
307
276
|
typeCheck: { enableBuild: false, overlay: { initialIsOpen: false } }
|
|
308
277
|
};
|
|
309
278
|
const typescript = defineVixtModule({
|
|
310
|
-
meta: { name
|
|
311
|
-
defaults
|
|
279
|
+
meta: { name, configKey: "typescript" },
|
|
280
|
+
defaults,
|
|
312
281
|
setup(options, vixt) {
|
|
313
282
|
return [
|
|
314
283
|
{
|
|
315
|
-
name
|
|
284
|
+
name,
|
|
316
285
|
configResolved(config) {
|
|
317
286
|
generateDts(options, vixt, config);
|
|
318
287
|
generateTsConfig(options, vixt, config);
|
|
@@ -325,35 +294,10 @@ const typescript = defineVixtModule({
|
|
|
325
294
|
}
|
|
326
295
|
});
|
|
327
296
|
|
|
328
|
-
const defaults = {
|
|
329
|
-
enabled: true,
|
|
330
|
-
clientFiles: ["./index.html", "./src/**/*.vue", "./src/**/*.ts", "./src/**/*.tsx"],
|
|
331
|
-
ssrFiles: ["./index.html", "./src/**/*.vue", "./src/**/*.ts", "./src/**/*.tsx"]
|
|
332
|
-
};
|
|
333
|
-
const name = "vixt:warmup";
|
|
334
|
-
const warmup = defineVixtModule({
|
|
335
|
-
meta: { name, configKey: "warmup" },
|
|
336
|
-
defaults,
|
|
337
|
-
setup(options) {
|
|
338
|
-
return {
|
|
339
|
-
name,
|
|
340
|
-
config() {
|
|
341
|
-
if (!options.enabled)
|
|
342
|
-
return;
|
|
343
|
-
return {
|
|
344
|
-
server: {
|
|
345
|
-
warmup: options
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
|
|
353
297
|
async function loadVixt(opts) {
|
|
354
298
|
const result = await loadVixtConfig(defu(opts, {
|
|
355
299
|
defaults: {
|
|
356
|
-
modules: [alias, app, config,
|
|
300
|
+
modules: [alias, app, config, typescript]
|
|
357
301
|
}
|
|
358
302
|
}));
|
|
359
303
|
const layerModules = await applyLayerModules(result.layers);
|
|
@@ -372,4 +316,4 @@ function createVixtPlugin(loadOptions) {
|
|
|
372
316
|
});
|
|
373
317
|
}
|
|
374
318
|
|
|
375
|
-
export { alias, app, applyLayerModules, buildDir, buildTypesDir, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule,
|
|
319
|
+
export { alias, app, applyLayerModules, buildDir, buildTypesDir, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadVixt, loadVixtConfig, resolveLayersDirs, rootDir, typescript };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixt/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/SoulLyoko/vixt#readme",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"fs-extra": "^11.2.0",
|
|
26
26
|
"mlly": "1.7.1",
|
|
27
27
|
"pathe": "^1.1.2",
|
|
28
|
-
"pkg-types": "^1.1.
|
|
28
|
+
"pkg-types": "^1.1.2",
|
|
29
29
|
"tsx": "^4.16.0",
|
|
30
30
|
"vite": "^5.3.2",
|
|
31
31
|
"vite-plugin-checker": "^0.7.0",
|