@vixt/vue 0.3.5 → 0.4.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/package.json +12 -10
- package/dist/index.d.mts +0 -97
- package/dist/index.d.ts +0 -97
- package/dist/index.mjs +0 -292
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixt/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/SoulLyoko/vixt#readme",
|
|
@@ -18,23 +18,25 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@vitejs/plugin-vue": "^5.2.
|
|
22
|
-
"@vitejs/plugin-vue-jsx": "^4.
|
|
23
|
-
"@vue/compiler-sfc": "^3.5.
|
|
24
|
-
"@vueuse/core": "^13.
|
|
21
|
+
"@vitejs/plugin-vue": "^5.2.4",
|
|
22
|
+
"@vitejs/plugin-vue-jsx": "^4.2.0",
|
|
23
|
+
"@vue/compiler-sfc": "^3.5.14",
|
|
24
|
+
"@vueuse/core": "^13.2.0",
|
|
25
25
|
"pinia": "^3.0.2",
|
|
26
|
-
"pinia-plugin-persistedstate": "^4.
|
|
27
|
-
"unocss": "
|
|
26
|
+
"pinia-plugin-persistedstate": "^4.3.0",
|
|
27
|
+
"unocss": "66.0.0",
|
|
28
28
|
"unplugin-auto-import": "^19.2.0",
|
|
29
29
|
"unplugin-vue-components": "28.0.0",
|
|
30
30
|
"unplugin-vue-router": "^0.12.0",
|
|
31
31
|
"vite-plugin-vue-devtools": "^7.7.6",
|
|
32
32
|
"vite-plugin-vue-layouts": "^0.11.0",
|
|
33
|
-
"vue": "^3.5.
|
|
33
|
+
"vue": "^3.5.14",
|
|
34
34
|
"vue-router": "^4.5.1",
|
|
35
|
-
"
|
|
35
|
+
"vue-tsc": "^2.2.10",
|
|
36
|
+
"@vixt/core": "0.4.0"
|
|
36
37
|
},
|
|
37
38
|
"scripts": {
|
|
38
|
-
"build": "unbuild"
|
|
39
|
+
"build": "unbuild",
|
|
40
|
+
"dev": "unbuild --stub"
|
|
39
41
|
}
|
|
40
42
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import * as vite from 'vite';
|
|
2
|
-
import * as _vixt_core from '@vixt/core';
|
|
3
|
-
import { Vixt, PluginOptions as PluginOptions$1, VixtOptions } from '@vixt/core';
|
|
4
|
-
import { PluginOptions } from 'pinia-plugin-persistedstate';
|
|
5
|
-
import { RouterOptions } from 'vue-router';
|
|
6
|
-
import Vue from '@vitejs/plugin-vue';
|
|
7
|
-
import VueJsx from '@vitejs/plugin-vue-jsx';
|
|
8
|
-
import UnoCSS from 'unocss/vite';
|
|
9
|
-
import AutoImport from 'unplugin-auto-import/vite';
|
|
10
|
-
import Components from 'unplugin-vue-components/vite';
|
|
11
|
-
import VueRouter from 'unplugin-vue-router/vite';
|
|
12
|
-
import VueDevTools from 'vite-plugin-vue-devtools';
|
|
13
|
-
import Layouts from 'vite-plugin-vue-layouts';
|
|
14
|
-
|
|
15
|
-
type Property = Record<string, string>;
|
|
16
|
-
interface AppHead {
|
|
17
|
-
meta?: Property[];
|
|
18
|
-
link?: Property[];
|
|
19
|
-
style?: Property[];
|
|
20
|
-
script?: Property[];
|
|
21
|
-
title?: Property[];
|
|
22
|
-
noscript?: Property[];
|
|
23
|
-
}
|
|
24
|
-
interface AppOptions {
|
|
25
|
-
head?: AppHead;
|
|
26
|
-
/**
|
|
27
|
-
* @default /
|
|
28
|
-
*/
|
|
29
|
-
baseURL?: string;
|
|
30
|
-
/**
|
|
31
|
-
* @default 'app'
|
|
32
|
-
*/
|
|
33
|
-
rootId?: string;
|
|
34
|
-
/**
|
|
35
|
-
* @default 'div'
|
|
36
|
-
*/
|
|
37
|
-
rootTag?: string;
|
|
38
|
-
/** inject css files */
|
|
39
|
-
css?: string[];
|
|
40
|
-
/**
|
|
41
|
-
* @default './loading.html'
|
|
42
|
-
*/
|
|
43
|
-
loadingTemplate?: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare function getAppComponentPath(vixt: Vixt): string | undefined;
|
|
47
|
-
declare function genarateAppComponent(vixt: Vixt): string;
|
|
48
|
-
|
|
49
|
-
declare function generateAppConfig(vixt: Vixt): string;
|
|
50
|
-
|
|
51
|
-
declare function generateCss(options: AppOptions): string;
|
|
52
|
-
|
|
53
|
-
declare function generateIndexHtml(options: AppOptions, vixt: Vixt): string;
|
|
54
|
-
|
|
55
|
-
declare function generateMainTs(options: AppOptions, vixt: Vixt): string;
|
|
56
|
-
|
|
57
|
-
declare function generatePlugins(vixt: Vixt): string;
|
|
58
|
-
|
|
59
|
-
declare module '@vixt/core' {
|
|
60
|
-
interface VixtOptions {
|
|
61
|
-
app?: AppOptions;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
declare module '@vixt/core/client' {
|
|
65
|
-
interface VixtAppConfig {
|
|
66
|
-
router?: Partial<RouterOptions>;
|
|
67
|
-
/** https://github.com/prazdevs/pinia-plugin-persistedstate */
|
|
68
|
-
piniaPersistedState?: PluginOptions;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
declare const appVue: _vixt_core.VixtModule<AppOptions>;
|
|
72
|
-
|
|
73
|
-
declare module '@vixt/core' {
|
|
74
|
-
interface VixtOptions {
|
|
75
|
-
vue?: PluginOptions$1<typeof Vue>;
|
|
76
|
-
vueJsx?: PluginOptions$1<typeof VueJsx>;
|
|
77
|
-
/** https://github.com/posva/unplugin-vue-router */
|
|
78
|
-
router?: PluginOptions$1<typeof VueRouter>;
|
|
79
|
-
/** https://github.com/JohnCampionJr/vite-plugin-vue-layouts */
|
|
80
|
-
layouts?: PluginOptions$1<typeof Layouts>;
|
|
81
|
-
/** https://github.com/unplugin/unplugin-vue-components */
|
|
82
|
-
components?: PluginOptions$1<typeof Components>;
|
|
83
|
-
/** https://github.com/unplugin/unplugin-auto-import */
|
|
84
|
-
imports?: PluginOptions$1<typeof AutoImport>;
|
|
85
|
-
/** https://github.com/unocss/unocss */
|
|
86
|
-
unocss?: PluginOptions$1<typeof UnoCSS>;
|
|
87
|
-
/** https://github.com/webfansplz/vite-plugin-vue-devtools */
|
|
88
|
-
devtools?: PluginOptions$1<typeof VueDevTools> & {
|
|
89
|
-
enabled?: boolean;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
declare const presetVue: _vixt_core.VixtModule<VixtOptions>;
|
|
94
|
-
|
|
95
|
-
declare const _default: (options?: VixtOptions | undefined) => vite.PluginOption;
|
|
96
|
-
|
|
97
|
-
export { type AppHead, type AppOptions, appVue, _default as default, genarateAppComponent, generateAppConfig, generateCss, generateIndexHtml, generateMainTs, generatePlugins, getAppComponentPath, presetVue };
|
package/dist/index.d.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import * as vite from 'vite';
|
|
2
|
-
import * as _vixt_core from '@vixt/core';
|
|
3
|
-
import { Vixt, PluginOptions as PluginOptions$1, VixtOptions } from '@vixt/core';
|
|
4
|
-
import { PluginOptions } from 'pinia-plugin-persistedstate';
|
|
5
|
-
import { RouterOptions } from 'vue-router';
|
|
6
|
-
import Vue from '@vitejs/plugin-vue';
|
|
7
|
-
import VueJsx from '@vitejs/plugin-vue-jsx';
|
|
8
|
-
import UnoCSS from 'unocss/vite';
|
|
9
|
-
import AutoImport from 'unplugin-auto-import/vite';
|
|
10
|
-
import Components from 'unplugin-vue-components/vite';
|
|
11
|
-
import VueRouter from 'unplugin-vue-router/vite';
|
|
12
|
-
import VueDevTools from 'vite-plugin-vue-devtools';
|
|
13
|
-
import Layouts from 'vite-plugin-vue-layouts';
|
|
14
|
-
|
|
15
|
-
type Property = Record<string, string>;
|
|
16
|
-
interface AppHead {
|
|
17
|
-
meta?: Property[];
|
|
18
|
-
link?: Property[];
|
|
19
|
-
style?: Property[];
|
|
20
|
-
script?: Property[];
|
|
21
|
-
title?: Property[];
|
|
22
|
-
noscript?: Property[];
|
|
23
|
-
}
|
|
24
|
-
interface AppOptions {
|
|
25
|
-
head?: AppHead;
|
|
26
|
-
/**
|
|
27
|
-
* @default /
|
|
28
|
-
*/
|
|
29
|
-
baseURL?: string;
|
|
30
|
-
/**
|
|
31
|
-
* @default 'app'
|
|
32
|
-
*/
|
|
33
|
-
rootId?: string;
|
|
34
|
-
/**
|
|
35
|
-
* @default 'div'
|
|
36
|
-
*/
|
|
37
|
-
rootTag?: string;
|
|
38
|
-
/** inject css files */
|
|
39
|
-
css?: string[];
|
|
40
|
-
/**
|
|
41
|
-
* @default './loading.html'
|
|
42
|
-
*/
|
|
43
|
-
loadingTemplate?: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare function getAppComponentPath(vixt: Vixt): string | undefined;
|
|
47
|
-
declare function genarateAppComponent(vixt: Vixt): string;
|
|
48
|
-
|
|
49
|
-
declare function generateAppConfig(vixt: Vixt): string;
|
|
50
|
-
|
|
51
|
-
declare function generateCss(options: AppOptions): string;
|
|
52
|
-
|
|
53
|
-
declare function generateIndexHtml(options: AppOptions, vixt: Vixt): string;
|
|
54
|
-
|
|
55
|
-
declare function generateMainTs(options: AppOptions, vixt: Vixt): string;
|
|
56
|
-
|
|
57
|
-
declare function generatePlugins(vixt: Vixt): string;
|
|
58
|
-
|
|
59
|
-
declare module '@vixt/core' {
|
|
60
|
-
interface VixtOptions {
|
|
61
|
-
app?: AppOptions;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
declare module '@vixt/core/client' {
|
|
65
|
-
interface VixtAppConfig {
|
|
66
|
-
router?: Partial<RouterOptions>;
|
|
67
|
-
/** https://github.com/prazdevs/pinia-plugin-persistedstate */
|
|
68
|
-
piniaPersistedState?: PluginOptions;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
declare const appVue: _vixt_core.VixtModule<AppOptions>;
|
|
72
|
-
|
|
73
|
-
declare module '@vixt/core' {
|
|
74
|
-
interface VixtOptions {
|
|
75
|
-
vue?: PluginOptions$1<typeof Vue>;
|
|
76
|
-
vueJsx?: PluginOptions$1<typeof VueJsx>;
|
|
77
|
-
/** https://github.com/posva/unplugin-vue-router */
|
|
78
|
-
router?: PluginOptions$1<typeof VueRouter>;
|
|
79
|
-
/** https://github.com/JohnCampionJr/vite-plugin-vue-layouts */
|
|
80
|
-
layouts?: PluginOptions$1<typeof Layouts>;
|
|
81
|
-
/** https://github.com/unplugin/unplugin-vue-components */
|
|
82
|
-
components?: PluginOptions$1<typeof Components>;
|
|
83
|
-
/** https://github.com/unplugin/unplugin-auto-import */
|
|
84
|
-
imports?: PluginOptions$1<typeof AutoImport>;
|
|
85
|
-
/** https://github.com/unocss/unocss */
|
|
86
|
-
unocss?: PluginOptions$1<typeof UnoCSS>;
|
|
87
|
-
/** https://github.com/webfansplz/vite-plugin-vue-devtools */
|
|
88
|
-
devtools?: PluginOptions$1<typeof VueDevTools> & {
|
|
89
|
-
enabled?: boolean;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
declare const presetVue: _vixt_core.VixtModule<VixtOptions>;
|
|
94
|
-
|
|
95
|
-
declare const _default: (options?: VixtOptions | undefined) => vite.PluginOption;
|
|
96
|
-
|
|
97
|
-
export { type AppHead, type AppOptions, appVue, _default as default, genarateAppComponent, generateAppConfig, generateCss, generateIndexHtml, generateMainTs, generatePlugins, getAppComponentPath, presetVue };
|
package/dist/index.mjs
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { defineVixtModule, resolveLayersDirs, createVixtPlugin } from '@vixt/core';
|
|
2
|
-
import path from 'pathe';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
|
-
import Vue from '@vitejs/plugin-vue';
|
|
5
|
-
import VueJsx from '@vitejs/plugin-vue-jsx';
|
|
6
|
-
import defu from 'defu';
|
|
7
|
-
import UnoCSS from 'unocss/vite';
|
|
8
|
-
import AutoImport from 'unplugin-auto-import/vite';
|
|
9
|
-
import Components from 'unplugin-vue-components/vite';
|
|
10
|
-
import { VueRouterAutoImports } from 'unplugin-vue-router';
|
|
11
|
-
import VueRouter from 'unplugin-vue-router/vite';
|
|
12
|
-
import VueDevTools from 'vite-plugin-vue-devtools';
|
|
13
|
-
import Layouts from 'vite-plugin-vue-layouts';
|
|
14
|
-
|
|
15
|
-
function getAppComponentPath(vixt) {
|
|
16
|
-
for (const layer of vixt._layers) {
|
|
17
|
-
const appComponentPath = path.resolve(layer.config.srcDir, "App.vue");
|
|
18
|
-
if (fs.existsSync(appComponentPath))
|
|
19
|
-
return appComponentPath;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function genarateAppComponent(vixt) {
|
|
23
|
-
const appComponentPath = getAppComponentPath(vixt) || "@vixt/core/client/App.vue";
|
|
24
|
-
const appComponentTemplate = `import App from '${appComponentPath}'`;
|
|
25
|
-
return appComponentTemplate;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function generateAppConfig(vixt) {
|
|
29
|
-
const { buildImportsDir } = vixt.options;
|
|
30
|
-
let appConfigsImportTemplate = "";
|
|
31
|
-
let appConfigsMergeTemplate = "";
|
|
32
|
-
let i = 0;
|
|
33
|
-
for (const layer of vixt._layers) {
|
|
34
|
-
const appConfigPath = path.resolve(layer.config.srcDir, "app.config.ts");
|
|
35
|
-
if (fs.existsSync(appConfigPath)) {
|
|
36
|
-
const appConfigName = `__app_config_${i}`;
|
|
37
|
-
appConfigsImportTemplate += `import ${appConfigName} from '${appConfigPath}'
|
|
38
|
-
`;
|
|
39
|
-
appConfigsMergeTemplate += `${appConfigName}, `;
|
|
40
|
-
i++;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const globalAppConfigKey = "__VIXT_APP_CONFIG";
|
|
44
|
-
const appConfigTemplate = `
|
|
45
|
-
import { defu } from 'defu'
|
|
46
|
-
${appConfigsImportTemplate}
|
|
47
|
-
const appConfig = defu(${appConfigsMergeTemplate}{})
|
|
48
|
-
globalThis.${globalAppConfigKey} = appConfig
|
|
49
|
-
`;
|
|
50
|
-
fs.outputFileSync(path.resolve(buildImportsDir, `app.config.ts`), `// Generated by Vixt
|
|
51
|
-
// @ts-nocheck
|
|
52
|
-
import type { VixtAppConfig } from '@vixt/core/client'
|
|
53
|
-
|
|
54
|
-
export const useAppConfig = () => globalThis.${globalAppConfigKey} as VixtAppConfig
|
|
55
|
-
`);
|
|
56
|
-
return appConfigTemplate;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function generateCss(options) {
|
|
60
|
-
const cssTemplate = options?.css?.map((css) => `import '${css}'`).join("\n") ?? "";
|
|
61
|
-
return cssTemplate;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function resolveHeadTag(tag, attrs) {
|
|
65
|
-
const attrsStr = Object.entries(attrs).filter(([k]) => k !== "children").map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
66
|
-
return attrs?.children ? `<${tag} ${attrsStr}>${attrs.children}</${tag}>` : `<${tag} ${attrsStr} />`;
|
|
67
|
-
}
|
|
68
|
-
function generateIndexHtml(options, vixt) {
|
|
69
|
-
const { buildDir, rootDir, srcDir } = vixt.options;
|
|
70
|
-
const indexHtmlPath = path.resolve(rootDir, "index.html");
|
|
71
|
-
if (!fs.existsSync(indexHtmlPath))
|
|
72
|
-
fs.outputFileSync(indexHtmlPath, `<!-- Generated by Vixt -->
|
|
73
|
-
<!-- This file transform from '${path.basename(buildDir)}/index.html' -->
|
|
74
|
-
`);
|
|
75
|
-
const { head = {}, rootTag, rootId } = options;
|
|
76
|
-
const headTemplate = Object.entries(head).filter(([k]) => k !== "noscript").map(([tag, attrs]) => attrs.map((e) => resolveHeadTag(tag, e))).flat().join("\n");
|
|
77
|
-
const noscriptTemplate = Object.entries(head).filter(([k]) => k === "noscript").map(([tag, attrs]) => attrs.map((e) => resolveHeadTag(tag, e))).flat().join("\n");
|
|
78
|
-
let { loadingTemplate = "" } = options;
|
|
79
|
-
if (!loadingTemplate) {
|
|
80
|
-
for (const layer of vixt._layers) {
|
|
81
|
-
const loadingTemplatePath = path.resolve(layer.cwd, "loading.html");
|
|
82
|
-
if (fs.existsSync(loadingTemplatePath)) {
|
|
83
|
-
loadingTemplate = fs.readFileSync(loadingTemplatePath, "utf-8");
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const code = `<!DOCTYPE html>
|
|
89
|
-
<html>
|
|
90
|
-
<head>
|
|
91
|
-
${headTemplate}
|
|
92
|
-
</head>
|
|
93
|
-
<body>
|
|
94
|
-
<${rootTag} id="${rootId}">
|
|
95
|
-
${loadingTemplate}
|
|
96
|
-
</${rootTag}>
|
|
97
|
-
<script type="module" src="${srcDir.replace(rootDir, "")}/main.ts"><\/script>
|
|
98
|
-
${noscriptTemplate}
|
|
99
|
-
</body>
|
|
100
|
-
</html>
|
|
101
|
-
`;
|
|
102
|
-
fs.outputFileSync(path.resolve(buildDir, "index.html"), code);
|
|
103
|
-
return code;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function generatePlugins(vixt) {
|
|
107
|
-
let pluginsImportTemplate = "";
|
|
108
|
-
let pluginsMergeTemplate = "";
|
|
109
|
-
let i = 0;
|
|
110
|
-
for (const layer of [...vixt._layers].reverse()) {
|
|
111
|
-
const pluginsDir = path.resolve(layer.config.srcDir, "plugins");
|
|
112
|
-
const files = fs.existsSync(pluginsDir) ? fs.readdirSync(pluginsDir) : [];
|
|
113
|
-
for (const f of files) {
|
|
114
|
-
const p = path.resolve(pluginsDir, f);
|
|
115
|
-
const pluginName = `__plugin_${i}`;
|
|
116
|
-
pluginsImportTemplate += `import ${pluginName} from '${p}'
|
|
117
|
-
`;
|
|
118
|
-
pluginsMergeTemplate += `${pluginName}, `;
|
|
119
|
-
i++;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const pluginsTemplate = `
|
|
123
|
-
${pluginsImportTemplate}
|
|
124
|
-
const plugins = [${pluginsMergeTemplate}]
|
|
125
|
-
function usePlugins(options) {
|
|
126
|
-
for (const plugin of plugins) {
|
|
127
|
-
typeof plugin === 'function' && plugin(options)
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
`;
|
|
131
|
-
return pluginsTemplate;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function generateMainTs(options, vixt) {
|
|
135
|
-
const { buildDir, srcDir } = vixt.options;
|
|
136
|
-
const mainTsPath = path.resolve(srcDir, "main.ts");
|
|
137
|
-
if (!fs.existsSync(mainTsPath))
|
|
138
|
-
fs.outputFileSync(mainTsPath, `// Generated by Vixt
|
|
139
|
-
// This file transform from '${path.basename(buildDir)}/main.ts'
|
|
140
|
-
`);
|
|
141
|
-
const appComponentTemplate = genarateAppComponent(vixt);
|
|
142
|
-
const cssTemplate = generateCss(options);
|
|
143
|
-
const appConfigTemplate = generateAppConfig(vixt);
|
|
144
|
-
const pluginsTemplate = generatePlugins(vixt);
|
|
145
|
-
const code = `// Generated by Vixt
|
|
146
|
-
// This file transform to '${srcDir}/main.ts'
|
|
147
|
-
// @ts-nocheck
|
|
148
|
-
${appComponentTemplate}
|
|
149
|
-
${cssTemplate}
|
|
150
|
-
${appConfigTemplate}
|
|
151
|
-
${pluginsTemplate}
|
|
152
|
-
|
|
153
|
-
import 'virtual:uno.css'
|
|
154
|
-
import { createApp } from 'vue'
|
|
155
|
-
import { createPinia } from 'pinia'
|
|
156
|
-
import { createPersistedState } from 'pinia-plugin-persistedstate'
|
|
157
|
-
import { createRouter, createWebHistory } from 'vue-router'
|
|
158
|
-
import { routes } from 'vue-router/auto-routes'
|
|
159
|
-
import { setupLayouts } from 'virtual:generated-layouts'
|
|
160
|
-
|
|
161
|
-
const pinia = createPinia()
|
|
162
|
-
pinia.use(createPersistedState(appConfig.piniaPersistedState))
|
|
163
|
-
|
|
164
|
-
const router = createRouter({
|
|
165
|
-
routes: setupLayouts(routes),
|
|
166
|
-
history: createWebHistory('${options.baseURL}'),
|
|
167
|
-
...appConfig.router,
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
const app = createApp(App)
|
|
171
|
-
app.use(pinia).use(router)
|
|
172
|
-
usePlugins({ app, router, routes, pinia, appConfig })
|
|
173
|
-
|
|
174
|
-
app.mount('#${options.rootId}')
|
|
175
|
-
`;
|
|
176
|
-
fs.outputFileSync(path.resolve(buildDir, "main.ts"), code);
|
|
177
|
-
return code;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const name = "vixt:app";
|
|
181
|
-
const defaults$1 = {
|
|
182
|
-
rootId: "app",
|
|
183
|
-
rootTag: "div",
|
|
184
|
-
baseURL: "/",
|
|
185
|
-
css: [],
|
|
186
|
-
head: {
|
|
187
|
-
meta: [
|
|
188
|
-
{ charset: "utf-8" },
|
|
189
|
-
{ name: "viewport", content: "width=device-width, initial-scale=1" }
|
|
190
|
-
]
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
const appVue = defineVixtModule({
|
|
194
|
-
meta: { name, configKey: "app" },
|
|
195
|
-
defaults: defaults$1,
|
|
196
|
-
setup(options, vixt) {
|
|
197
|
-
let indexHtmlCode;
|
|
198
|
-
let mainTsCode;
|
|
199
|
-
const mainTsPath = path.resolve(vixt.options.srcDir, "main.ts");
|
|
200
|
-
return {
|
|
201
|
-
name,
|
|
202
|
-
configResolved() {
|
|
203
|
-
indexHtmlCode = generateIndexHtml(options, vixt);
|
|
204
|
-
mainTsCode = generateMainTs(options, vixt);
|
|
205
|
-
},
|
|
206
|
-
transformIndexHtml: {
|
|
207
|
-
order: "pre",
|
|
208
|
-
handler() {
|
|
209
|
-
return indexHtmlCode;
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
transform: {
|
|
213
|
-
order: "pre",
|
|
214
|
-
handler(_, id) {
|
|
215
|
-
if (id !== mainTsPath)
|
|
216
|
-
return;
|
|
217
|
-
return mainTsCode;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
const presetVue = defineVixtModule({
|
|
225
|
-
async setup(_, vixt) {
|
|
226
|
-
const { components = [], composables = [], constants = [], utils = [], stores = [], pages = [], layouts = [] } = resolveLayersDirs(vixt._layers);
|
|
227
|
-
const { buildTypesDir, buildImportsDir } = vixt.options;
|
|
228
|
-
const defaultOptions = {
|
|
229
|
-
vue: {},
|
|
230
|
-
vueJsx: {},
|
|
231
|
-
router: {
|
|
232
|
-
dts: `${buildTypesDir}/typed-router.d.ts`,
|
|
233
|
-
routesFolder: pages,
|
|
234
|
-
/** Fix overrides priority */
|
|
235
|
-
extendRoute(route) {
|
|
236
|
-
const node = route.node.value;
|
|
237
|
-
const overrides = node._overrides;
|
|
238
|
-
if (overrides.size <= 1)
|
|
239
|
-
return;
|
|
240
|
-
for (const pageDir of pages) {
|
|
241
|
-
const matched = [...overrides.keys()].find((e) => e.match(pageDir));
|
|
242
|
-
if (matched) {
|
|
243
|
-
node.components.set("default", matched);
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
layouts: { layoutsDirs: [...layouts].reverse(), pagesDirs: pages },
|
|
250
|
-
components: {
|
|
251
|
-
dts: `${buildTypesDir}/components.d.ts`,
|
|
252
|
-
dirs: components,
|
|
253
|
-
directoryAsNamespace: true,
|
|
254
|
-
collapseSamePrefixes: true
|
|
255
|
-
},
|
|
256
|
-
imports: {
|
|
257
|
-
imports: ["vue", "@vueuse/core", "pinia", VueRouterAutoImports],
|
|
258
|
-
dts: `${buildTypesDir}/auto-imports.d.ts`,
|
|
259
|
-
dirs: [...composables, ...constants, ...stores, ...utils, buildImportsDir],
|
|
260
|
-
vueTemplate: true
|
|
261
|
-
},
|
|
262
|
-
unocss: {},
|
|
263
|
-
devtools: { enabled: false }
|
|
264
|
-
};
|
|
265
|
-
const options = vixt.options = defu(vixt.options, defaultOptions);
|
|
266
|
-
const plugins = [
|
|
267
|
-
VueRouter(options.router),
|
|
268
|
-
Vue(options.vue),
|
|
269
|
-
VueJsx(options.vueJsx),
|
|
270
|
-
Layouts(options.layouts),
|
|
271
|
-
Components(options.components),
|
|
272
|
-
AutoImport(options.imports),
|
|
273
|
-
UnoCSS(options.unocss),
|
|
274
|
-
options.devtools?.enabled && VueDevTools(options.devtools)
|
|
275
|
-
];
|
|
276
|
-
return plugins;
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
const defaults = {
|
|
281
|
-
modules: [appVue, presetVue],
|
|
282
|
-
typescript: {
|
|
283
|
-
tsConfig: {
|
|
284
|
-
compilerOptions: {
|
|
285
|
-
types: ["vite-plugin-vue-layouts/client", "unplugin-vue-router/client"]
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
const index = createVixtPlugin({ defaults });
|
|
291
|
-
|
|
292
|
-
export { appVue, index as default, genarateAppComponent, generateAppConfig, generateCss, generateIndexHtml, generateMainTs, generatePlugins, getAppComponentPath, presetVue };
|