@jskit-ai/create-app 0.1.28 → 0.1.30
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
CHANGED
|
@@ -5,6 +5,102 @@ import VueRouter from "vue-router/vite";
|
|
|
5
5
|
import { createJskitClientBootstrapPlugin } from "@jskit-ai/kernel/client/vite";
|
|
6
6
|
import { loadViteDevProxyEntries, toPositiveInt } from "./vite.shared.mjs";
|
|
7
7
|
|
|
8
|
+
const NESTED_CHILDREN_GROUP_SEGMENTS = Object.freeze(["/(nestedChildren)/", "/(nested-children)/"]);
|
|
9
|
+
|
|
10
|
+
function toPosixPath(value = "") {
|
|
11
|
+
return String(value || "").replaceAll("\\", "/");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function nodeDeclaresNestedChildrenSource(node) {
|
|
15
|
+
const sourcePaths = [];
|
|
16
|
+
if (node.component) {
|
|
17
|
+
sourcePaths.push(node.component);
|
|
18
|
+
}
|
|
19
|
+
for (const filePath of node.components.values()) {
|
|
20
|
+
sourcePaths.push(filePath);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
for (const sourcePath of sourcePaths) {
|
|
24
|
+
const normalizedSourcePath = toPosixPath(sourcePath);
|
|
25
|
+
if (NESTED_CHILDREN_GROUP_SEGMENTS.some((segment) => normalizedSourcePath.includes(segment))) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function collectBranchComponentNodes(node) {
|
|
34
|
+
const entries = [];
|
|
35
|
+
const stack = [node];
|
|
36
|
+
while (stack.length > 0) {
|
|
37
|
+
const current = stack.pop();
|
|
38
|
+
if (current.component || current.components.size > 0) {
|
|
39
|
+
entries.push(current);
|
|
40
|
+
}
|
|
41
|
+
stack.push(...current.children);
|
|
42
|
+
}
|
|
43
|
+
return entries.sort((left, right) => String(left.fullPath).localeCompare(String(right.fullPath)));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isNestedChildrenBranch(node) {
|
|
47
|
+
const componentNodes = collectBranchComponentNodes(node);
|
|
48
|
+
if (componentNodes.length < 1) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return componentNodes.every((entry) => nodeDeclaresNestedChildrenSource(entry));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function reparentNestedChildrenToIndexOwners(rootRoute) {
|
|
56
|
+
for (const owner of rootRoute.traverseDFS()) {
|
|
57
|
+
const indexChild = owner.children.find((child) => child.path === "" && child.component) || null;
|
|
58
|
+
if (!indexChild) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const siblingBranches = owner.children.filter((child) => child !== indexChild && isNestedChildrenBranch(child));
|
|
63
|
+
if (siblingBranches.length === 0) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
for (const branch of siblingBranches) {
|
|
68
|
+
for (const sourceNode of collectBranchComponentNodes(branch)) {
|
|
69
|
+
let relativePath = String(sourceNode.fullPath).slice(String(owner.fullPath).length);
|
|
70
|
+
if (relativePath.startsWith("/")) {
|
|
71
|
+
relativePath = relativePath.slice(1);
|
|
72
|
+
}
|
|
73
|
+
if (!relativePath) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const sourceComponentPath = sourceNode.component
|
|
78
|
+
? toPosixPath(sourceNode.component)
|
|
79
|
+
: toPosixPath(sourceNode.components.values().next().value || "");
|
|
80
|
+
if (!sourceComponentPath) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const cloned = indexChild.insert(relativePath, sourceComponentPath);
|
|
85
|
+
for (const [viewName, filePath] of sourceNode.components.entries()) {
|
|
86
|
+
cloned.components.set(viewName, toPosixPath(filePath));
|
|
87
|
+
}
|
|
88
|
+
if (typeof sourceNode.name === "string" && sourceNode.name) {
|
|
89
|
+
cloned.name = sourceNode.name;
|
|
90
|
+
}
|
|
91
|
+
if (sourceNode.meta) {
|
|
92
|
+
cloned.addToMeta(sourceNode.meta);
|
|
93
|
+
}
|
|
94
|
+
for (const alias of sourceNode.alias || []) {
|
|
95
|
+
cloned.addAlias(alias);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
branch.delete();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
8
104
|
const devPort = toPositiveInt(process.env.VITE_DEV_PORT, 5173);
|
|
9
105
|
const apiProxyTarget = String(process.env.VITE_API_PROXY_TARGET || "").trim() || "http://localhost:3000";
|
|
10
106
|
const viteModuleProxyEntries = loadViteDevProxyEntries({
|
|
@@ -36,7 +132,8 @@ export default defineConfig({
|
|
|
36
132
|
createJskitClientBootstrapPlugin(),
|
|
37
133
|
VueRouter({
|
|
38
134
|
routesFolder: "src/pages",
|
|
39
|
-
dts: "src/typed-router.d.ts"
|
|
135
|
+
dts: "src/typed-router.d.ts",
|
|
136
|
+
beforeWriteFiles: reparentNestedChildrenToIndexOwners
|
|
40
137
|
}),
|
|
41
138
|
vue(),
|
|
42
139
|
{
|