@lingxia/cli 0.0.9 → 0.1.3
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/bin/lingxia.js +207 -32
- package/dist/builder/commands/build.d.ts +1 -1
- package/dist/builder/commands/build.d.ts.map +1 -1
- package/dist/builder/commands/build.js +138 -103
- package/dist/builder/commands/build.js.map +1 -1
- package/dist/builder/core/builders/logic.d.ts +3 -3
- package/dist/builder/core/builders/logic.d.ts.map +1 -1
- package/dist/builder/core/builders/logic.js +55 -46
- package/dist/builder/core/builders/logic.js.map +1 -1
- package/dist/builder/core/builders/page-functions.d.ts.map +1 -1
- package/dist/builder/core/builders/page-functions.js +43 -35
- package/dist/builder/core/builders/page-functions.js.map +1 -1
- package/dist/builder/core/builders/page-path-injector.js +27 -27
- package/dist/builder/core/builders/page-path-injector.js.map +1 -1
- package/dist/builder/core/builders/page-types.d.ts +22 -0
- package/dist/builder/core/builders/page-types.d.ts.map +1 -0
- package/dist/builder/core/builders/page-types.js +374 -0
- package/dist/builder/core/builders/page-types.js.map +1 -0
- package/dist/builder/core/builders/page.d.ts +5 -4
- package/dist/builder/core/builders/page.d.ts.map +1 -1
- package/dist/builder/core/builders/page.js +54 -52
- package/dist/builder/core/builders/page.js.map +1 -1
- package/dist/builder/core/builders/view-validator.d.ts +9 -0
- package/dist/builder/core/builders/view-validator.d.ts.map +1 -0
- package/dist/builder/core/builders/view-validator.js +58 -0
- package/dist/builder/core/builders/view-validator.js.map +1 -0
- package/dist/builder/core/builders/view.d.ts +40 -3
- package/dist/builder/core/builders/view.d.ts.map +1 -1
- package/dist/builder/core/builders/view.js +406 -55
- package/dist/builder/core/builders/view.js.map +1 -1
- package/dist/builder/core/config/alias-config.d.ts +1 -1
- package/dist/builder/core/config/alias-config.d.ts.map +1 -1
- package/dist/builder/core/config/alias-config.js +8 -8
- package/dist/builder/core/config/alias-config.js.map +1 -1
- package/dist/builder/core/config/framework.d.ts +1 -1
- package/dist/builder/core/config/framework.d.ts.map +1 -1
- package/dist/builder/core/config/framework.js +14 -11
- package/dist/builder/core/config/framework.js.map +1 -1
- package/dist/builder/core/config/lxapp-config.d.ts +74 -0
- package/dist/builder/core/config/lxapp-config.d.ts.map +1 -0
- package/dist/builder/core/config/lxapp-config.js +195 -0
- package/dist/builder/core/config/lxapp-config.js.map +1 -0
- package/dist/builder/core/config/view-build-schema.d.ts +2 -2
- package/dist/builder/core/config/view-config.d.ts +3 -3
- package/dist/builder/core/config/view-config.d.ts.map +1 -1
- package/dist/builder/core/config/view-config.js +16 -16
- package/dist/builder/core/config/view-config.js.map +1 -1
- package/dist/builder/core/config.d.ts +1 -1
- package/dist/builder/core/config.js +11 -11
- package/dist/builder/core/constants/source-dirs.d.ts +1 -1
- package/dist/builder/core/constants/source-dirs.js +9 -9
- package/dist/builder/core/constants/source-dirs.js.map +1 -1
- package/dist/builder/core/constants/static-dirs.d.ts +1 -1
- package/dist/builder/core/constants/static-dirs.d.ts.map +1 -1
- package/dist/builder/core/constants/static-dirs.js +11 -11
- package/dist/builder/core/constants/static-dirs.js.map +1 -1
- package/dist/builder/core/frameworks/base.d.ts +1 -1
- package/dist/builder/core/frameworks/base.d.ts.map +1 -1
- package/dist/builder/core/frameworks/base.js +13 -11
- package/dist/builder/core/frameworks/base.js.map +1 -1
- package/dist/builder/core/frameworks/factory.d.ts +1 -1
- package/dist/builder/core/frameworks/factory.d.ts.map +1 -1
- package/dist/builder/core/frameworks/factory.js +9 -9
- package/dist/builder/core/frameworks/factory.js.map +1 -1
- package/dist/builder/core/frameworks/html.d.ts +2 -2
- package/dist/builder/core/frameworks/html.d.ts.map +1 -1
- package/dist/builder/core/frameworks/html.js +10 -10
- package/dist/builder/core/frameworks/html.js.map +1 -1
- package/dist/builder/core/frameworks/react.d.ts +3 -3
- package/dist/builder/core/frameworks/react.d.ts.map +1 -1
- package/dist/builder/core/frameworks/react.js +45 -43
- package/dist/builder/core/frameworks/react.js.map +1 -1
- package/dist/builder/core/frameworks/templates.d.ts +1 -1
- package/dist/builder/core/frameworks/templates.d.ts.map +1 -1
- package/dist/builder/core/frameworks/templates.js +1 -1
- package/dist/builder/core/frameworks/templates.js.map +1 -1
- package/dist/builder/core/frameworks/vue.d.ts +3 -3
- package/dist/builder/core/frameworks/vue.d.ts.map +1 -1
- package/dist/builder/core/frameworks/vue.js +48 -43
- package/dist/builder/core/frameworks/vue.js.map +1 -1
- package/dist/builder/core/registry.d.ts.map +1 -1
- package/dist/builder/core/registry.js +34 -25
- package/dist/builder/core/registry.js.map +1 -1
- package/dist/builder/core/template.d.ts +1 -1
- package/dist/builder/core/template.d.ts.map +1 -1
- package/dist/builder/core/template.js +19 -14
- package/dist/builder/core/template.js.map +1 -1
- package/dist/builder/core/templates/embedded.d.ts +3 -3
- package/dist/builder/core/templates/embedded.d.ts.map +1 -1
- package/dist/builder/core/templates/embedded.js +62 -31
- package/dist/builder/core/templates/embedded.js.map +1 -1
- package/dist/builder/core/type-generator.d.ts +17 -0
- package/dist/builder/core/type-generator.d.ts.map +1 -0
- package/dist/builder/core/type-generator.js +172 -0
- package/dist/builder/core/type-generator.js.map +1 -0
- package/dist/builder/core/utils/file.js +4 -4
- package/dist/builder/core/utils/incremental.d.ts +59 -0
- package/dist/builder/core/utils/incremental.d.ts.map +1 -0
- package/dist/builder/core/utils/incremental.js +177 -0
- package/dist/builder/core/utils/incremental.js.map +1 -0
- package/dist/builder/core/utils/page.d.ts +12 -2
- package/dist/builder/core/utils/page.d.ts.map +1 -1
- package/dist/builder/core/utils/page.js +63 -8
- package/dist/builder/core/utils/page.js.map +1 -1
- package/dist/builder/index.d.ts +1 -1
- package/dist/builder/index.js +1 -1
- package/dist/builder/types/index.d.ts +7 -6
- package/dist/builder/types/index.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -16
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/scripts/install.cjs +35 -15
- package/templates/AppIcon.png +0 -0
- package/templates/android-native/app/src/main/java/MainActivity.kt +2 -2
- package/templates/android-native/app/src/main/res/values/strings.xml +1 -1
- package/templates/android-native/settings.gradle.kts +4 -0
- package/templates/harmony-native/AppScope/app.json5 +10 -0
- package/templates/harmony-native/AppScope/resources/base/element/string.json +8 -0
- package/templates/harmony-native/build-profile.json5 +41 -0
- package/templates/harmony-native/entry/build-profile.json5 +8 -0
- package/templates/harmony-native/entry/hvigorfile.ts +6 -0
- package/templates/harmony-native/entry/oh-package.json5 +11 -0
- package/templates/harmony-native/entry/src/main/ets/entryability/EntryAbility.ets +38 -0
- package/templates/harmony-native/entry/src/main/ets/pages/Index.ets +15 -0
- package/templates/harmony-native/entry/src/main/module.json5 +38 -0
- package/templates/harmony-native/entry/src/main/resources/base/element/color.json +8 -0
- package/templates/harmony-native/entry/src/main/resources/base/element/string.json +16 -0
- package/templates/harmony-native/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/templates/harmony-native/entry/src/main/resources/dark/element/color.json +8 -0
- package/templates/harmony-native/hvigor/hvigor-config.json5 +13 -0
- package/templates/harmony-native/hvigorfile.ts +6 -0
- package/templates/harmony-native/oh-package.json5 +10 -0
- package/templates/ios-native/App.entitlements +10 -0
- package/templates/ios-native/Info.plist +8 -0
- package/templates/ios-native/Package.swift +31 -0
- package/templates/ios-native/Sources/App.swift +44 -0
- package/templates/lxapp-create/html/global.d.ts +1 -0
- package/templates/lxapp-create/html/lxapp.config.ts +5 -0
- package/templates/lxapp-create/html/lxapp.json +8 -0
- package/templates/lxapp-create/html/lxapp.ts +8 -0
- package/templates/lxapp-create/html/package.json +20 -0
- package/templates/lxapp-create/html/pages/home/index.html +32 -0
- package/templates/lxapp-create/html/pages/home/index.json +3 -0
- package/templates/lxapp-create/html/pages/home/index.ts +14 -0
- package/templates/lxapp-create/html/tsconfig.json +13 -0
- package/templates/lxapp-create/html/view/home.ts +19 -0
- package/templates/lxapp-create/react/app.css +20 -0
- package/templates/lxapp-create/react/lxapp.config.ts +8 -0
- package/templates/lxapp-create/react/lxapp.json +1 -1
- package/templates/lxapp-create/react/package.json +2 -0
- package/templates/lxapp-create/react/pages/home/index.json +1 -1
- package/templates/lxapp-create/react/pages/home/index.ts +8 -3
- package/templates/lxapp-create/react/pages/home/index.tsx +113 -42
- package/templates/lxapp-create/react/tsconfig.json +5 -2
- package/templates/lxapp-create/vue/app.css +20 -0
- package/templates/lxapp-create/vue/lxapp.config.ts +8 -0
- package/templates/lxapp-create/vue/lxapp.json +1 -1
- package/templates/lxapp-create/vue/package.json +2 -0
- package/templates/lxapp-create/vue/pages/home/index.json +1 -1
- package/templates/lxapp-create/vue/pages/home/index.ts +8 -3
- package/templates/lxapp-create/vue/pages/home/index.vue +124 -37
- package/templates/lxapp-create/vue/tsconfig.json +5 -2
- package/templates/macos-native/Info.plist +40 -0
- package/templates/macos-native/Package.swift +30 -0
- package/templates/macos-native/Sources/main.swift +23 -0
- package/templates/rust-lib/Cargo.toml +16 -1
- package/templates/rust-lib/README.md +1 -1
- package/templates/rust-lib/src/lib.rs +39 -1
- package/vendor/lingxia +0 -0
- package/templates/lxapp-create/react/lxapp.config.json +0 -8
- package/templates/lxapp-create/react/public/.gitkeep +0 -0
- package/templates/lxapp-create/vue/lxapp.config.json +0 -8
- package/templates/lxapp-create/vue/public/.gitkeep +0 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { parse } from "@babel/parser";
|
|
2
|
+
const LIFECYCLE_FUNCTIONS = new Set([
|
|
3
|
+
"onLoad",
|
|
4
|
+
"onShow",
|
|
5
|
+
"onHide",
|
|
6
|
+
"onUnload",
|
|
7
|
+
"onReady",
|
|
8
|
+
"onPullDownRefresh",
|
|
9
|
+
"onReachBottom",
|
|
10
|
+
"onShareAppMessage",
|
|
11
|
+
"onPageScroll",
|
|
12
|
+
"onTabItemTap",
|
|
13
|
+
]);
|
|
14
|
+
const AST_PARSE_OPTIONS = {
|
|
15
|
+
sourceType: "module",
|
|
16
|
+
plugins: [
|
|
17
|
+
"typescript",
|
|
18
|
+
"jsx",
|
|
19
|
+
"classProperties",
|
|
20
|
+
"decorators-legacy",
|
|
21
|
+
"dynamicImport",
|
|
22
|
+
"objectRestSpread",
|
|
23
|
+
"optionalChaining",
|
|
24
|
+
"nullishCoalescingOperator",
|
|
25
|
+
"topLevelAwait",
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
export function extractPageTypes(source) {
|
|
29
|
+
const ast = parse(source, AST_PARSE_OPTIONS);
|
|
30
|
+
const result = { data: {}, methods: {} };
|
|
31
|
+
traverseAst(ast.program, (node) => {
|
|
32
|
+
if (!isPageCall(node))
|
|
33
|
+
return;
|
|
34
|
+
const firstArg = unwrapExpression(node.arguments?.[0]);
|
|
35
|
+
if (firstArg?.type === "ObjectExpression") {
|
|
36
|
+
extractFromPageObject(firstArg, result);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
function extractFromPageObject(node, result) {
|
|
42
|
+
const properties = node.properties;
|
|
43
|
+
if (!properties)
|
|
44
|
+
return;
|
|
45
|
+
for (const prop of properties) {
|
|
46
|
+
if (!prop || prop.type === "SpreadElement")
|
|
47
|
+
continue;
|
|
48
|
+
const name = getPropertyName(prop.key);
|
|
49
|
+
if (!name || name.startsWith("_"))
|
|
50
|
+
continue;
|
|
51
|
+
// Extract data object
|
|
52
|
+
if (name === "data" && prop.type === "ObjectProperty") {
|
|
53
|
+
const valueNode = unwrapExpression(prop.value);
|
|
54
|
+
if (valueNode?.type === "ObjectExpression") {
|
|
55
|
+
result.data = extractDataTypes(valueNode);
|
|
56
|
+
}
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
// Skip lifecycle functions
|
|
60
|
+
if (LIFECYCLE_FUNCTIONS.has(name))
|
|
61
|
+
continue;
|
|
62
|
+
// Extract method
|
|
63
|
+
if (prop.type === "ObjectMethod") {
|
|
64
|
+
result.methods[name] = extractMethodInfo(prop);
|
|
65
|
+
}
|
|
66
|
+
else if (prop.type === "ObjectProperty") {
|
|
67
|
+
const valueNode = unwrapExpression(prop.value);
|
|
68
|
+
if (valueNode &&
|
|
69
|
+
(valueNode.type === "FunctionExpression" ||
|
|
70
|
+
valueNode.type === "ArrowFunctionExpression")) {
|
|
71
|
+
result.methods[name] = extractMethodInfo(valueNode);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function extractDataTypes(node) {
|
|
77
|
+
const result = {};
|
|
78
|
+
const properties = node.properties;
|
|
79
|
+
if (!properties)
|
|
80
|
+
return result;
|
|
81
|
+
for (const prop of properties) {
|
|
82
|
+
if (!prop || prop.type === "SpreadElement")
|
|
83
|
+
continue;
|
|
84
|
+
const name = getPropertyName(prop.key);
|
|
85
|
+
if (!name)
|
|
86
|
+
continue;
|
|
87
|
+
if (prop.type === "ObjectProperty") {
|
|
88
|
+
const valueNode = unwrapExpression(prop.value);
|
|
89
|
+
result[name] = inferTypeFromValue(valueNode);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
function inferTypeFromValue(node) {
|
|
95
|
+
if (!node)
|
|
96
|
+
return { type: "unknown" };
|
|
97
|
+
switch (node.type) {
|
|
98
|
+
case "StringLiteral":
|
|
99
|
+
return { type: "string" };
|
|
100
|
+
case "NumericLiteral":
|
|
101
|
+
return { type: "number" };
|
|
102
|
+
case "BooleanLiteral":
|
|
103
|
+
return { type: "boolean" };
|
|
104
|
+
case "NullLiteral":
|
|
105
|
+
return { type: "null", optional: true };
|
|
106
|
+
case "ArrayExpression": {
|
|
107
|
+
const elements = node.elements;
|
|
108
|
+
if (elements && elements.length > 0) {
|
|
109
|
+
const firstElement = unwrapExpression(elements[0]);
|
|
110
|
+
return { type: "array", elementType: inferTypeFromValue(firstElement) };
|
|
111
|
+
}
|
|
112
|
+
return { type: "array", elementType: { type: "unknown" } };
|
|
113
|
+
}
|
|
114
|
+
case "ObjectExpression": {
|
|
115
|
+
const properties = extractDataTypes(node);
|
|
116
|
+
return { type: "object", properties };
|
|
117
|
+
}
|
|
118
|
+
case "TemplateLiteral":
|
|
119
|
+
return { type: "string" };
|
|
120
|
+
case "UnaryExpression":
|
|
121
|
+
// Handle negative numbers: -1
|
|
122
|
+
if (node.operator === "-" || node.operator === "+") {
|
|
123
|
+
return { type: "number" };
|
|
124
|
+
}
|
|
125
|
+
return { type: "unknown" };
|
|
126
|
+
default:
|
|
127
|
+
return { type: "unknown" };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function extractMethodInfo(node) {
|
|
131
|
+
const params = [];
|
|
132
|
+
const nodeParams = node.params;
|
|
133
|
+
if (nodeParams) {
|
|
134
|
+
for (const param of nodeParams) {
|
|
135
|
+
const paramInfo = extractParamInfo(param);
|
|
136
|
+
if (paramInfo)
|
|
137
|
+
params.push(paramInfo);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const isAsync = Boolean(node.async);
|
|
141
|
+
const returnType = extractReturnType(node);
|
|
142
|
+
return { params, async: isAsync, returnType };
|
|
143
|
+
}
|
|
144
|
+
function extractParamInfo(param) {
|
|
145
|
+
if (!param)
|
|
146
|
+
return null;
|
|
147
|
+
// Handle simple identifier: function foo(arg) {}
|
|
148
|
+
if (param.type === "Identifier") {
|
|
149
|
+
const typeAnnotation = param.typeAnnotation;
|
|
150
|
+
return {
|
|
151
|
+
name: param.name,
|
|
152
|
+
type: extractTypeAnnotation(typeAnnotation),
|
|
153
|
+
optional: Boolean(param.optional),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// Handle assignment pattern: function foo(arg = defaultValue) {}
|
|
157
|
+
if (param.type === "AssignmentPattern") {
|
|
158
|
+
const left = param.left;
|
|
159
|
+
if (left?.type === "Identifier") {
|
|
160
|
+
const typeAnnotation = left.typeAnnotation;
|
|
161
|
+
const right = param.right;
|
|
162
|
+
return {
|
|
163
|
+
name: left.name,
|
|
164
|
+
type: typeAnnotation
|
|
165
|
+
? extractTypeAnnotation(typeAnnotation)
|
|
166
|
+
: inferTypeFromValue(right).type,
|
|
167
|
+
optional: true,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Handle rest parameter: function foo(...args) {}
|
|
172
|
+
if (param.type === "RestElement") {
|
|
173
|
+
const argument = param.argument;
|
|
174
|
+
if (argument?.type === "Identifier") {
|
|
175
|
+
const typeAnnotation = param.typeAnnotation;
|
|
176
|
+
return {
|
|
177
|
+
name: `...${argument.name}`,
|
|
178
|
+
type: extractTypeAnnotation(typeAnnotation) || "unknown[]",
|
|
179
|
+
optional: true,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Handle object destructuring: function foo({ name, age }) {}
|
|
184
|
+
if (param.type === "ObjectPattern") {
|
|
185
|
+
const typeAnnotation = param.typeAnnotation;
|
|
186
|
+
return {
|
|
187
|
+
name: "options",
|
|
188
|
+
type: extractTypeAnnotation(typeAnnotation) || "object",
|
|
189
|
+
optional: Boolean(param.optional),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
function extractTypeAnnotation(typeAnnotation) {
|
|
195
|
+
if (!typeAnnotation)
|
|
196
|
+
return "unknown";
|
|
197
|
+
// Handle TSTypeAnnotation wrapper
|
|
198
|
+
if (typeAnnotation.type === "TSTypeAnnotation") {
|
|
199
|
+
return extractTSType(typeAnnotation.typeAnnotation);
|
|
200
|
+
}
|
|
201
|
+
return extractTSType(typeAnnotation);
|
|
202
|
+
}
|
|
203
|
+
function extractTSType(node) {
|
|
204
|
+
if (!node)
|
|
205
|
+
return "unknown";
|
|
206
|
+
switch (node.type) {
|
|
207
|
+
case "TSStringKeyword":
|
|
208
|
+
return "string";
|
|
209
|
+
case "TSNumberKeyword":
|
|
210
|
+
return "number";
|
|
211
|
+
case "TSBooleanKeyword":
|
|
212
|
+
return "boolean";
|
|
213
|
+
case "TSNullKeyword":
|
|
214
|
+
return "null";
|
|
215
|
+
case "TSUndefinedKeyword":
|
|
216
|
+
return "undefined";
|
|
217
|
+
case "TSVoidKeyword":
|
|
218
|
+
return "void";
|
|
219
|
+
case "TSAnyKeyword":
|
|
220
|
+
return "unknown";
|
|
221
|
+
case "TSUnknownKeyword":
|
|
222
|
+
return "unknown";
|
|
223
|
+
case "TSNeverKeyword":
|
|
224
|
+
return "never";
|
|
225
|
+
case "TSObjectKeyword":
|
|
226
|
+
return "object";
|
|
227
|
+
case "TSArrayType": {
|
|
228
|
+
const elementType = extractTSType(node.elementType);
|
|
229
|
+
return `${elementType}[]`;
|
|
230
|
+
}
|
|
231
|
+
case "TSTypeReference": {
|
|
232
|
+
const typeName = node.typeName;
|
|
233
|
+
if (typeName?.type === "Identifier") {
|
|
234
|
+
const name = typeName.name;
|
|
235
|
+
const typeParams = node.typeParameters;
|
|
236
|
+
if (typeParams?.type === "TSTypeParameterInstantiation") {
|
|
237
|
+
const params = typeParams.params
|
|
238
|
+
.map((p) => extractTSType(p))
|
|
239
|
+
.join(", ");
|
|
240
|
+
return `${name}<${params}>`;
|
|
241
|
+
}
|
|
242
|
+
return name;
|
|
243
|
+
}
|
|
244
|
+
return "unknown";
|
|
245
|
+
}
|
|
246
|
+
case "TSUnionType": {
|
|
247
|
+
const types = node.types.map((t) => extractTSType(t));
|
|
248
|
+
return types.join(" | ");
|
|
249
|
+
}
|
|
250
|
+
case "TSIntersectionType": {
|
|
251
|
+
const types = node.types.map((t) => extractTSType(t));
|
|
252
|
+
return types.join(" & ");
|
|
253
|
+
}
|
|
254
|
+
case "TSLiteralType": {
|
|
255
|
+
const literal = node.literal;
|
|
256
|
+
if (literal?.type === "StringLiteral")
|
|
257
|
+
return `"${literal.value}"`;
|
|
258
|
+
if (literal?.type === "NumericLiteral")
|
|
259
|
+
return String(literal.value);
|
|
260
|
+
if (literal?.type === "BooleanLiteral")
|
|
261
|
+
return String(literal.value);
|
|
262
|
+
return "unknown";
|
|
263
|
+
}
|
|
264
|
+
case "TSTypeLiteral": {
|
|
265
|
+
// Inline object type: { name: string; age: number }
|
|
266
|
+
const members = node.members;
|
|
267
|
+
if (!members || members.length === 0)
|
|
268
|
+
return "{}";
|
|
269
|
+
const props = members
|
|
270
|
+
.map((m) => {
|
|
271
|
+
if (m.type === "TSPropertySignature") {
|
|
272
|
+
const key = getPropertyName(m.key);
|
|
273
|
+
const typeAnn = m.typeAnnotation;
|
|
274
|
+
const propType = extractTypeAnnotation(typeAnn);
|
|
275
|
+
const optional = m.optional ? "?" : "";
|
|
276
|
+
return `${key}${optional}: ${propType}`;
|
|
277
|
+
}
|
|
278
|
+
return null;
|
|
279
|
+
})
|
|
280
|
+
.filter(Boolean);
|
|
281
|
+
return `{ ${props.join("; ")} }`;
|
|
282
|
+
}
|
|
283
|
+
case "TSFunctionType": {
|
|
284
|
+
const params = node.parameters || [];
|
|
285
|
+
const paramStrs = params.map((p) => {
|
|
286
|
+
const name = p.name || "arg";
|
|
287
|
+
const typeAnn = p.typeAnnotation;
|
|
288
|
+
return `${name}: ${extractTypeAnnotation(typeAnn)}`;
|
|
289
|
+
});
|
|
290
|
+
const returnType = extractTypeAnnotation(node.typeAnnotation);
|
|
291
|
+
return `(${paramStrs.join(", ")}) => ${returnType}`;
|
|
292
|
+
}
|
|
293
|
+
case "TSParenthesizedType":
|
|
294
|
+
return `(${extractTSType(node.typeAnnotation)})`;
|
|
295
|
+
case "TSTupleType": {
|
|
296
|
+
const elementTypes = node.elementTypes.map((t) => extractTSType(t));
|
|
297
|
+
return `[${elementTypes.join(", ")}]`;
|
|
298
|
+
}
|
|
299
|
+
default:
|
|
300
|
+
return "unknown";
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function extractReturnType(node) {
|
|
304
|
+
const returnType = node.returnType;
|
|
305
|
+
if (!returnType)
|
|
306
|
+
return undefined;
|
|
307
|
+
if (returnType.type === "TSTypeAnnotation") {
|
|
308
|
+
const type = extractTSType(returnType.typeAnnotation);
|
|
309
|
+
// Don't return void as it's the default
|
|
310
|
+
if (type === "void")
|
|
311
|
+
return undefined;
|
|
312
|
+
return type;
|
|
313
|
+
}
|
|
314
|
+
return undefined;
|
|
315
|
+
}
|
|
316
|
+
// Helper functions (same as page-functions.ts)
|
|
317
|
+
function traverseAst(node, visitor) {
|
|
318
|
+
if (!node || typeof node.type !== "string")
|
|
319
|
+
return;
|
|
320
|
+
visitor(node);
|
|
321
|
+
for (const value of Object.values(node)) {
|
|
322
|
+
if (!value)
|
|
323
|
+
continue;
|
|
324
|
+
if (Array.isArray(value)) {
|
|
325
|
+
for (const child of value) {
|
|
326
|
+
if (child && typeof child.type === "string") {
|
|
327
|
+
traverseAst(child, visitor);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
if (value && typeof value.type === "string") {
|
|
333
|
+
traverseAst(value, visitor);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function isPageCall(node) {
|
|
338
|
+
if (node.type !== "CallExpression")
|
|
339
|
+
return false;
|
|
340
|
+
const callee = node.callee;
|
|
341
|
+
return Boolean(callee && callee.type === "Identifier" && callee.name === "Page");
|
|
342
|
+
}
|
|
343
|
+
function unwrapExpression(node) {
|
|
344
|
+
let current = node ?? null;
|
|
345
|
+
while (current) {
|
|
346
|
+
if (current.type === "SpreadElement")
|
|
347
|
+
return null;
|
|
348
|
+
if (current.type === "TSAsExpression" ||
|
|
349
|
+
current.type === "TSTypeAssertion" ||
|
|
350
|
+
current.type === "TSNonNullExpression" ||
|
|
351
|
+
current.type === "TypeCastExpression") {
|
|
352
|
+
current = current.expression;
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
if (current.type === "ParenthesizedExpression") {
|
|
356
|
+
current = current.expression;
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
return current;
|
|
362
|
+
}
|
|
363
|
+
function getPropertyName(key) {
|
|
364
|
+
if (!key)
|
|
365
|
+
return null;
|
|
366
|
+
if (key.type === "Identifier")
|
|
367
|
+
return key.name;
|
|
368
|
+
if (key.type === "StringLiteral")
|
|
369
|
+
return key.value;
|
|
370
|
+
if (key.type === "NumericLiteral")
|
|
371
|
+
return String(key.value);
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=page-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-types.js","sourceRoot":"","sources":["../../../../src/builder/core/builders/page-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAsB,MAAM,eAAe,CAAC;AAE1D,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,SAAS;IACT,mBAAmB;IACnB,eAAe;IACf,mBAAmB;IACnB,cAAc;IACd,cAAc;CACf,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAkB;IACvC,UAAU,EAAE,QAAQ;IACpB,OAAO,EAAE;QACP,YAAY;QACZ,KAAK;QACL,iBAAiB;QACjB,mBAAmB;QACnB,eAAe;QACf,kBAAkB;QAClB,kBAAkB;QAClB,2BAA2B;QAC3B,eAAe;KAChB;CACF,CAAC;AA+BF,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAiB,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAEvD,WAAW,CAAC,GAAG,CAAC,OAA+B,EAAE,CAAC,IAAI,EAAE,EAAE;QACxD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,OAAO;QAE9B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAA0B,CAAC,CAAC;QAChF,IAAI,QAA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IAE5D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { BuildOptions, Page, PageFiles } from
|
|
2
|
-
import type {
|
|
1
|
+
import type { BuildOptions, Page, PageFiles } from "../../types/index.js";
|
|
2
|
+
import type { ProjectFramework } from "../config/framework.js";
|
|
3
|
+
import type { BuildConfig } from "../config/lxapp-config.js";
|
|
3
4
|
export declare class PageProcessor {
|
|
4
5
|
private projectPath;
|
|
5
6
|
private outputDir;
|
|
@@ -12,14 +13,14 @@ export declare class PageProcessor {
|
|
|
12
13
|
private pluginSpecs?;
|
|
13
14
|
private projectRequire;
|
|
14
15
|
private framework;
|
|
15
|
-
constructor(projectPath: string, outputDir: string, staticDirs?: string[], buildConfig?: BuildConfig);
|
|
16
|
+
constructor(projectPath: string, outputDir: string, staticDirs?: string[], buildConfig?: BuildConfig, framework?: ProjectFramework);
|
|
16
17
|
/**
|
|
17
18
|
* Batch build multiple pages for a single framework using Vite multi-entry.
|
|
18
19
|
* Writes a dedicated multi-entry vite.config.js (no framework API changes),
|
|
19
20
|
* installs once, builds once, then normalizes per-entry to existing processor
|
|
20
21
|
* expectations by temporarily mapping <entry>.html/js to index.html/main.js.
|
|
21
22
|
*/
|
|
22
|
-
buildPagesBatch(framework:
|
|
23
|
+
buildPagesBatch(framework: "react" | "vue", items: {
|
|
23
24
|
page: Page;
|
|
24
25
|
pageFiles: PageFiles;
|
|
25
26
|
pageFunctions: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../src/builder/core/builders/page.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../src/builder/core/builders/page.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,E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
|
6
|
-
import { TemplateManager } from
|
|
7
|
-
import { FrameworkFactory } from
|
|
8
|
-
import { ViewConfigManager, DEFAULT_ASSET_DIR } from
|
|
9
|
-
import { extractViewOverrides, extractPluginSpecs,
|
|
10
|
-
import { readProjectFramework } from
|
|
11
|
-
import { DEFAULT_STATIC_DIRS } from
|
|
12
|
-
import { DEFAULT_SOURCE_DIRS, resolveSourceDirs } from
|
|
13
|
-
import { resolveAliasMap } from
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import { pathToFileURL } from "url";
|
|
5
|
+
import { FileUtils } from "../utils/file.js";
|
|
6
|
+
import { TemplateManager } from "../template.js";
|
|
7
|
+
import { FrameworkFactory } from "../frameworks/factory.js";
|
|
8
|
+
import { ViewConfigManager, DEFAULT_ASSET_DIR } from "../config/view-config.js";
|
|
9
|
+
import { extractViewOverrides, extractPluginSpecs, loadLxappConfig, } from "../config/lxapp-config.js";
|
|
10
|
+
import { readProjectFramework } from "../config/framework.js";
|
|
11
|
+
import { DEFAULT_STATIC_DIRS } from "../constants/static-dirs.js";
|
|
12
|
+
import { DEFAULT_SOURCE_DIRS, resolveSourceDirs, } from "../constants/source-dirs.js";
|
|
13
|
+
import { resolveAliasMap } from "../config/alias-config.js";
|
|
14
14
|
export class PageProcessor {
|
|
15
15
|
projectPath;
|
|
16
16
|
outputDir;
|
|
@@ -23,16 +23,18 @@ export class PageProcessor {
|
|
|
23
23
|
pluginSpecs;
|
|
24
24
|
projectRequire;
|
|
25
25
|
framework;
|
|
26
|
-
constructor(projectPath, outputDir, staticDirs = DEFAULT_STATIC_DIRS, buildConfig) {
|
|
26
|
+
constructor(projectPath, outputDir, staticDirs = DEFAULT_STATIC_DIRS, buildConfig, framework) {
|
|
27
27
|
this.projectPath = projectPath;
|
|
28
28
|
this.outputDir = outputDir;
|
|
29
29
|
this.fileUtils = new FileUtils();
|
|
30
30
|
this.templateManager = new TemplateManager();
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
// Use provided framework or auto-detect
|
|
32
|
+
this.framework = framework ?? readProjectFramework(projectPath);
|
|
33
|
+
// Use buildConfig if provided, otherwise load from lxapp.config.ts
|
|
34
|
+
const lingxiaConfig = buildConfig ?? loadLxappConfig(projectPath);
|
|
33
35
|
const viewOverrides = extractViewOverrides(lingxiaConfig, this.framework);
|
|
34
|
-
const combinedOverrides =
|
|
35
|
-
? { ...viewOverrides, assetDir:
|
|
36
|
+
const combinedOverrides = lingxiaConfig?.assetDir && !viewOverrides?.assetDir
|
|
37
|
+
? { ...viewOverrides, assetDir: lingxiaConfig.assetDir }
|
|
36
38
|
: viewOverrides;
|
|
37
39
|
this.pluginSpecs = extractPluginSpecs(lingxiaConfig);
|
|
38
40
|
this.viewConfigManager = new ViewConfigManager(projectPath, combinedOverrides);
|
|
@@ -55,7 +57,7 @@ export class PageProcessor {
|
|
|
55
57
|
if (items.length === 0)
|
|
56
58
|
return;
|
|
57
59
|
const processor = FrameworkFactory.createProcessor(framework, this.projectPath, this.outputDir);
|
|
58
|
-
const buildDir = path.join(this.projectPath,
|
|
60
|
+
const buildDir = path.join(this.projectPath, ".lingxia", "build", `view-${framework}`);
|
|
59
61
|
this.fileUtils.cleanDirectory(buildDir);
|
|
60
62
|
// Shared package.json: copy from root and override build script for Vite
|
|
61
63
|
// Copy shared assets/config
|
|
@@ -65,11 +67,13 @@ export class PageProcessor {
|
|
|
65
67
|
const inputs = {};
|
|
66
68
|
const entryNameByPagePath = {};
|
|
67
69
|
for (const { page, pageFiles, pageFunctions } of items) {
|
|
68
|
-
const entryName = page.name ||
|
|
69
|
-
|
|
70
|
+
const entryName = page.name ||
|
|
71
|
+
path.dirname(page.path).replace(/^pages\//, "") ||
|
|
72
|
+
path.basename(page.path, path.extname(page.path));
|
|
73
|
+
const subDir = path.join(buildDir, "pages", entryName);
|
|
70
74
|
this.fileUtils.ensureDirectory(subDir);
|
|
71
75
|
await processor.setupBuild(subDir, page, pageFiles, pageFunctions);
|
|
72
|
-
inputs[entryName] = path.join(subDir,
|
|
76
|
+
inputs[entryName] = path.join(subDir, "index.html");
|
|
73
77
|
entryNameByPagePath[page.path] = entryName;
|
|
74
78
|
}
|
|
75
79
|
const frameworkConfig = this.viewConfigManager.getFrameworkConfig(framework);
|
|
@@ -85,9 +89,9 @@ export class PageProcessor {
|
|
|
85
89
|
cssCodeSplit: frameworkConfig.cssCodeSplitMulti,
|
|
86
90
|
target,
|
|
87
91
|
esbuild,
|
|
88
|
-
alias: this.alias
|
|
92
|
+
alias: this.alias,
|
|
89
93
|
});
|
|
90
|
-
const distDir = path.join(buildDir,
|
|
94
|
+
const distDir = path.join(buildDir, "dist");
|
|
91
95
|
// Copy assets from build dist to final output
|
|
92
96
|
const buildAssetsDir = path.join(distDir, assetDir);
|
|
93
97
|
if (fs.existsSync(buildAssetsDir)) {
|
|
@@ -99,47 +103,50 @@ export class PageProcessor {
|
|
|
99
103
|
for (const { page, pageFiles, pageFunctions } of items) {
|
|
100
104
|
const entryName = entryNameByPagePath[page.path];
|
|
101
105
|
// Determine relative paths based on Vite output structure
|
|
102
|
-
const entryHtml = path.join(
|
|
103
|
-
const entryJs = path.join(
|
|
106
|
+
const entryHtml = path.join("pages", entryName, "index.html");
|
|
107
|
+
const entryJs = path.join("pages", entryName, `${entryName}.js`);
|
|
104
108
|
// Generate bridge and output via updated processor API
|
|
105
109
|
const bridgeScript = this.templateManager.generateFunctionBridge(pageFunctions);
|
|
106
110
|
await processor.generateOutput(page, pageFiles, {
|
|
107
111
|
distDir,
|
|
108
112
|
assetDir,
|
|
109
113
|
entryHtml,
|
|
110
|
-
entryJs
|
|
114
|
+
entryJs,
|
|
111
115
|
}, bridgeScript);
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
async runViteBuild(buildDir, framework, config) {
|
|
115
|
-
const { build } = await import(
|
|
119
|
+
const { build } = await import("vite");
|
|
116
120
|
const plugins = await this.resolveFrameworkPlugins(framework, config.frameworkConfig);
|
|
117
121
|
const css = await this.createCssConfig(buildDir, config.frameworkConfig);
|
|
118
|
-
const
|
|
119
|
-
const
|
|
122
|
+
const isProd = Boolean(config.options.release);
|
|
123
|
+
const isDev = !isProd;
|
|
120
124
|
await build({
|
|
121
125
|
configFile: false,
|
|
122
126
|
root: buildDir,
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
base: "/", // Use absolute paths in HTML output
|
|
128
|
+
logLevel: "warn",
|
|
129
|
+
mode: isDev ? "development" : isProd ? "production" : undefined,
|
|
125
130
|
plugins,
|
|
126
131
|
css,
|
|
127
132
|
resolve: {
|
|
128
|
-
alias: config.alias
|
|
133
|
+
alias: config.alias,
|
|
129
134
|
},
|
|
130
135
|
esbuild: config.esbuild,
|
|
131
136
|
build: {
|
|
132
|
-
outDir: path.join(buildDir,
|
|
137
|
+
outDir: path.join(buildDir, "dist"),
|
|
133
138
|
emptyOutDir: true,
|
|
134
139
|
rollupOptions: {
|
|
135
140
|
input: config.inputs,
|
|
136
|
-
output: config.output
|
|
141
|
+
output: config.output,
|
|
137
142
|
},
|
|
138
143
|
cssCodeSplit: config.cssCodeSplit ?? true,
|
|
139
144
|
target: config.target,
|
|
140
|
-
minify: isProd
|
|
141
|
-
|
|
142
|
-
|
|
145
|
+
minify: isProd
|
|
146
|
+
? (config.frameworkConfig.minifyStrategy ?? "esbuild")
|
|
147
|
+
: false,
|
|
148
|
+
sourcemap: isDev,
|
|
149
|
+
},
|
|
143
150
|
});
|
|
144
151
|
}
|
|
145
152
|
async resolveFrameworkPlugins(framework, config) {
|
|
@@ -148,13 +155,13 @@ export class PageProcessor {
|
|
|
148
155
|
if (pluginFactories && pluginFactories.length > 0) {
|
|
149
156
|
plugins = [...pluginFactories];
|
|
150
157
|
}
|
|
151
|
-
else if (framework ===
|
|
152
|
-
const reactModule = await import(
|
|
158
|
+
else if (framework === "react") {
|
|
159
|
+
const reactModule = await import("@vitejs/plugin-react");
|
|
153
160
|
const pluginFactory = reactModule.default ?? reactModule;
|
|
154
161
|
plugins = [pluginFactory()];
|
|
155
162
|
}
|
|
156
163
|
else {
|
|
157
|
-
const vueModule = await import(
|
|
164
|
+
const vueModule = await import("@vitejs/plugin-vue");
|
|
158
165
|
const pluginFactory = vueModule.default ?? vueModule;
|
|
159
166
|
plugins = [pluginFactory()];
|
|
160
167
|
}
|
|
@@ -168,7 +175,7 @@ export class PageProcessor {
|
|
|
168
175
|
if (config.cssConfig === false) {
|
|
169
176
|
return undefined;
|
|
170
177
|
}
|
|
171
|
-
if (typeof config.cssConfig ===
|
|
178
|
+
if (typeof config.cssConfig === "function") {
|
|
172
179
|
return config.cssConfig(buildDir);
|
|
173
180
|
}
|
|
174
181
|
return undefined;
|
|
@@ -198,7 +205,7 @@ export class PageProcessor {
|
|
|
198
205
|
}
|
|
199
206
|
const plugins = [];
|
|
200
207
|
for (const spec of specs) {
|
|
201
|
-
if (
|
|
208
|
+
if ("plugin" in spec && spec.plugin) {
|
|
202
209
|
plugins.push(spec.plugin);
|
|
203
210
|
}
|
|
204
211
|
else {
|
|
@@ -213,8 +220,8 @@ export class PageProcessor {
|
|
|
213
220
|
const imported = await import(moduleUrl);
|
|
214
221
|
const factory = spec.namedExport
|
|
215
222
|
? imported[spec.namedExport]
|
|
216
|
-
: imported.default ?? imported;
|
|
217
|
-
if (typeof factory !==
|
|
223
|
+
: (imported.default ?? imported);
|
|
224
|
+
if (typeof factory !== "function") {
|
|
218
225
|
throw new Error(`Plugin module "${spec.module}" must export a function (default or named) returning a Vite plugin.`);
|
|
219
226
|
}
|
|
220
227
|
return await factory(spec.options);
|
|
@@ -228,19 +235,14 @@ export class PageProcessor {
|
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
237
|
createProjectRequire(projectPath) {
|
|
231
|
-
const candidateFiles = [
|
|
232
|
-
'package.json',
|
|
233
|
-
'lxapp.config.json',
|
|
234
|
-
'lingxia.config.ts',
|
|
235
|
-
'lingxia.config.js'
|
|
236
|
-
];
|
|
238
|
+
const candidateFiles = ["package.json", "lxapp.config.ts"];
|
|
237
239
|
for (const file of candidateFiles) {
|
|
238
240
|
const fullPath = path.join(projectPath, file);
|
|
239
241
|
if (fs.existsSync(fullPath)) {
|
|
240
242
|
return createRequire(fullPath);
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
|
-
return createRequire(path.join(projectPath,
|
|
245
|
+
return createRequire(path.join(projectPath, "index.js"));
|
|
244
246
|
}
|
|
245
247
|
}
|
|
246
248
|
//# sourceMappingURL=page.js.map
|