@vixt/vue 0.11.2 → 0.12.1
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/node/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import preset_vue_default from "./modules/preset-vue.mjs";
|
|
2
|
+
import virtual_root_component_default from "./modules/virtual-root-component.mjs";
|
|
3
3
|
import { createVixtPlugin } from "@vixt/core";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import { resolvePathSync } from "mlly";
|
|
4
6
|
import { VueRouterAutoImports } from "vue-router/unplugin";
|
|
5
7
|
//#region src/node/index.ts
|
|
6
8
|
/** @module vue */
|
|
7
|
-
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
8
9
|
const plugins = ["@vixt/vue/client/plugins/router"];
|
|
9
10
|
/** @hidden */
|
|
10
11
|
var node_default = createVixtPlugin({ defaults: {
|
|
@@ -12,7 +13,7 @@ var node_default = createVixtPlugin({ defaults: {
|
|
|
12
13
|
plugins,
|
|
13
14
|
app: {
|
|
14
15
|
entryFile: "main.ts",
|
|
15
|
-
entryCode:
|
|
16
|
+
entryCode: fs.readFileSync(resolvePathSync("@vixt/vue/client/entry"), "utf-8"),
|
|
16
17
|
head: { meta: [{ charset: "utf-8" }, {
|
|
17
18
|
name: "viewport",
|
|
18
19
|
content: "width=device-width, initial-scale=1.0"
|
|
@@ -1,2 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineVixtModule, resolveLayersDirs } from "@vixt/core";
|
|
2
|
+
import Vue from "@vitejs/plugin-vue";
|
|
3
|
+
import VueJsx from "@vitejs/plugin-vue-jsx";
|
|
4
|
+
import defu from "defu";
|
|
5
|
+
import Components from "unplugin-vue-components/vite";
|
|
6
|
+
import VueDevTools from "vite-plugin-vue-devtools";
|
|
7
|
+
import Layouts from "vite-plugin-vue-layouts";
|
|
8
|
+
import VueRouter from "vue-router/vite";
|
|
9
|
+
var preset_vue_default = defineVixtModule({
|
|
10
|
+
meta: { name: "vixt:preset-vue" },
|
|
11
|
+
setup(_, vixt) {
|
|
12
|
+
const { components = [], pages = [], layouts = [] } = resolveLayersDirs([...vixt._layers].reverse());
|
|
13
|
+
const { buildTypesDir } = vixt.options;
|
|
14
|
+
const defaultOptions = {
|
|
15
|
+
vue: {},
|
|
16
|
+
vueJsx: {},
|
|
17
|
+
router: {
|
|
18
|
+
dts: `${buildTypesDir}/typed-router.d.ts`,
|
|
19
|
+
routesFolder: pages,
|
|
20
|
+
extendRoute(route) {
|
|
21
|
+
const node = route.node.value;
|
|
22
|
+
const overrides = node._overrides;
|
|
23
|
+
if (overrides.size <= 1) return;
|
|
24
|
+
for (const pageDir of [...pages].reverse()) {
|
|
25
|
+
const matched = [...overrides.keys()].find((e) => e.match(pageDir));
|
|
26
|
+
if (matched) {
|
|
27
|
+
node.components.set("default", matched);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
layouts: {
|
|
34
|
+
layoutsDirs: layouts,
|
|
35
|
+
pagesDirs: pages
|
|
36
|
+
},
|
|
37
|
+
components: {
|
|
38
|
+
dts: `${buildTypesDir}/components.d.ts`,
|
|
39
|
+
dirs: [...components].reverse(),
|
|
40
|
+
directoryAsNamespace: true,
|
|
41
|
+
collapseSamePrefixes: true
|
|
42
|
+
},
|
|
43
|
+
devtools: { enabled: false }
|
|
44
|
+
};
|
|
45
|
+
const options = vixt.options = defu(vixt.options, defaultOptions);
|
|
46
|
+
return [
|
|
47
|
+
VueRouter(options.router),
|
|
48
|
+
Vue(options.vue),
|
|
49
|
+
VueJsx(options.vueJsx),
|
|
50
|
+
Layouts(options.layouts),
|
|
51
|
+
Components(options.components),
|
|
52
|
+
options.devtools?.enabled && VueDevTools(options.devtools)
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
//#endregion
|
|
2
57
|
export { preset_vue_default as default };
|
|
@@ -1,2 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineVixtModule } from "@vixt/core";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { resolvePathSync } from "mlly";
|
|
4
|
+
import { parse } from "@vue/compiler-sfc";
|
|
5
|
+
import path from "pathe";
|
|
6
|
+
//#region src/node/modules/virtual-root-component.ts
|
|
7
|
+
function resolveRootComponent(vixt) {
|
|
8
|
+
for (const layer of vixt._layers) {
|
|
9
|
+
const layerRootComponentPath = path.resolve(layer.config.srcDir, "App.vue");
|
|
10
|
+
const layerRootComponentCode = fs.existsSync(layerRootComponentPath) && fs.readFileSync(layerRootComponentPath, "utf-8") || "";
|
|
11
|
+
if (!isEmptyCode(layerRootComponentCode)) return {
|
|
12
|
+
path: layerRootComponentPath,
|
|
13
|
+
code: layerRootComponentCode
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const defaultRootComponentPath = resolvePathSync("@vixt/vue/client/App");
|
|
17
|
+
return {
|
|
18
|
+
path: defaultRootComponentPath,
|
|
19
|
+
code: fs.readFileSync(defaultRootComponentPath, "utf-8")
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function isEmptyCode(code) {
|
|
23
|
+
if (!code) return true;
|
|
24
|
+
try {
|
|
25
|
+
const { descriptor: { template, script, scriptSetup } } = parse(code);
|
|
26
|
+
return !template && !script && !scriptSetup;
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const name = "virtual:vixt:root-component.vue";
|
|
32
|
+
var virtual_root_component_default = defineVixtModule({
|
|
33
|
+
meta: { name },
|
|
34
|
+
setup(_, vixt) {
|
|
35
|
+
return {
|
|
36
|
+
name,
|
|
37
|
+
resolveId(id) {
|
|
38
|
+
if (id === name) return name;
|
|
39
|
+
},
|
|
40
|
+
load(id) {
|
|
41
|
+
if (id === name) {
|
|
42
|
+
const { path, code } = resolveRootComponent(vixt);
|
|
43
|
+
this.addWatchFile(path);
|
|
44
|
+
return code;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//#endregion
|
|
2
51
|
export { virtual_root_component_default as default, isEmptyCode };
|
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.12.1",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://soullyoko.github.io/vixt/",
|
|
@@ -28,13 +28,19 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
31
|
-
"@vitejs/plugin-vue-jsx": "^5.1.
|
|
31
|
+
"@vitejs/plugin-vue-jsx": "^5.1.6",
|
|
32
|
+
"@vue/compiler-sfc": "^3.5.39",
|
|
33
|
+
"defu": "^6.1.7",
|
|
34
|
+
"fs-extra": "^11.3.6",
|
|
35
|
+
"mlly": "^1.8.2",
|
|
36
|
+
"pathe": "^2.0.3",
|
|
32
37
|
"unplugin-vue-components": "28.0.0",
|
|
33
|
-
"vite
|
|
38
|
+
"vite": "^8.1.2",
|
|
39
|
+
"vite-plugin-vue-devtools": "^8.1.5",
|
|
34
40
|
"vite-plugin-vue-layouts": "^0.11.0",
|
|
35
|
-
"vue": "^3.5.
|
|
41
|
+
"vue": "^3.5.39",
|
|
36
42
|
"vue-router": "^5.1.0",
|
|
37
|
-
"vue-tsc": "^3.3.
|
|
38
|
-
"@vixt/core": "0.
|
|
43
|
+
"vue-tsc": "^3.3.6",
|
|
44
|
+
"@vixt/core": "0.12.1"
|
|
39
45
|
}
|
|
40
46
|
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { defineVixtModule, resolveLayersDirs } from "@vixt/core";
|
|
2
|
-
import Vue from "@vitejs/plugin-vue";
|
|
3
|
-
import VueJsx from "@vitejs/plugin-vue-jsx";
|
|
4
|
-
import Components from "unplugin-vue-components/vite";
|
|
5
|
-
import VueDevTools from "vite-plugin-vue-devtools";
|
|
6
|
-
import Layouts from "vite-plugin-vue-layouts";
|
|
7
|
-
import VueRouter from "vue-router/vite";
|
|
8
|
-
//#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
|
|
9
|
-
function isPlainObject(value) {
|
|
10
|
-
if (value === null || typeof value !== "object") return false;
|
|
11
|
-
const prototype = Object.getPrototypeOf(value);
|
|
12
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
|
|
13
|
-
if (Symbol.iterator in value) return false;
|
|
14
|
-
if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
18
|
-
if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace, merger);
|
|
19
|
-
const object = { ...defaults };
|
|
20
|
-
for (const key of Object.keys(baseObject)) {
|
|
21
|
-
if (key === "__proto__" || key === "constructor") continue;
|
|
22
|
-
const value = baseObject[key];
|
|
23
|
-
if (value === null || value === void 0) continue;
|
|
24
|
-
if (merger && merger(object, key, value, namespace)) continue;
|
|
25
|
-
if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
|
|
26
|
-
else if (isPlainObject(value) && isPlainObject(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
|
|
27
|
-
else object[key] = value;
|
|
28
|
-
}
|
|
29
|
-
return object;
|
|
30
|
-
}
|
|
31
|
-
function createDefu(merger) {
|
|
32
|
-
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
|
33
|
-
}
|
|
34
|
-
const defu = createDefu();
|
|
35
|
-
var preset_vue_default = defineVixtModule({
|
|
36
|
-
meta: { name: "vixt:preset-vue" },
|
|
37
|
-
setup(_, vixt) {
|
|
38
|
-
const { components = [], pages = [], layouts = [] } = resolveLayersDirs([...vixt._layers].reverse());
|
|
39
|
-
const { buildTypesDir } = vixt.options;
|
|
40
|
-
const defaultOptions = {
|
|
41
|
-
vue: {},
|
|
42
|
-
vueJsx: {},
|
|
43
|
-
router: {
|
|
44
|
-
dts: `${buildTypesDir}/typed-router.d.ts`,
|
|
45
|
-
routesFolder: pages,
|
|
46
|
-
extendRoute(route) {
|
|
47
|
-
const node = route.node.value;
|
|
48
|
-
const overrides = node._overrides;
|
|
49
|
-
if (overrides.size <= 1) return;
|
|
50
|
-
for (const pageDir of [...pages].reverse()) {
|
|
51
|
-
const matched = [...overrides.keys()].find((e) => e.match(pageDir));
|
|
52
|
-
if (matched) {
|
|
53
|
-
node.components.set("default", matched);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
layouts: {
|
|
60
|
-
layoutsDirs: layouts,
|
|
61
|
-
pagesDirs: pages
|
|
62
|
-
},
|
|
63
|
-
components: {
|
|
64
|
-
dts: `${buildTypesDir}/components.d.ts`,
|
|
65
|
-
dirs: [...components].reverse(),
|
|
66
|
-
directoryAsNamespace: true,
|
|
67
|
-
collapseSamePrefixes: true
|
|
68
|
-
},
|
|
69
|
-
devtools: { enabled: false }
|
|
70
|
-
};
|
|
71
|
-
const options = vixt.options = defu(vixt.options, defaultOptions);
|
|
72
|
-
return [
|
|
73
|
-
VueRouter(options.router),
|
|
74
|
-
Vue(options.vue),
|
|
75
|
-
VueJsx(options.vueJsx),
|
|
76
|
-
Layouts(options.layouts),
|
|
77
|
-
Components(options.components),
|
|
78
|
-
options.devtools?.enabled && VueDevTools(options.devtools)
|
|
79
|
-
];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
//#endregion
|
|
83
|
-
export { preset_vue_default as t };
|