@unmagic/vms 0.1.1 → 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.
|
@@ -2171,9 +2171,10 @@ function getTemplateNodeProp(node, prop, returnValue, counter, wxsExpressionStat
|
|
|
2171
2171
|
* 2. babelParse(code) — 重新解析为完整 AST
|
|
2172
2172
|
*
|
|
2173
2173
|
* 注意:isAsync 必须正确传递,否则 babel 无法解析 await 关键字。
|
|
2174
|
+
* 注意:不能使用 compact: true,否则多语句的 { } 会被移除导致解析错误
|
|
2174
2175
|
*/
|
|
2175
2176
|
function reparseBodyAsAST(body, isAsync) {
|
|
2176
|
-
const code = generate(t.arrowFunctionExpression([], body, isAsync)
|
|
2177
|
+
const code = generate(t.arrowFunctionExpression([], body, isAsync)).code;
|
|
2177
2178
|
return parse$1(code, {
|
|
2178
2179
|
sourceType: "module",
|
|
2179
2180
|
plugins: ["typescript"]
|
|
@@ -2252,6 +2253,11 @@ function processASTExpression(ast, counter, callExpressionWithArgs, excludeBindi
|
|
|
2252
2253
|
if (t.isCallExpression(ast)) return processCallableExpression(ast.callee, ast.arguments, counter, callExpressionWithArgs, excludeBindingVars, vForItemName, vForInfoList, ctx, returnValue);
|
|
2253
2254
|
else if (t.isMemberExpression(ast)) return processCallableExpression(ast, null, counter, callExpressionWithArgs, excludeBindingVars, vForItemName, vForInfoList, ctx, returnValue);
|
|
2254
2255
|
else if (t.isArrowFunctionExpression(ast)) return processArrowFunctionExpression(ast, counter, callExpressionWithArgs, excludeBindingVars, vForItemName, node, returnValue, ctx);
|
|
2256
|
+
else if (t.isAssignmentExpression(ast)) return processInlineArrowFunction(t.blockStatement([t.expressionStatement(ast)]), [], counter, callExpressionWithArgs, excludeBindingVars, node, returnValue, ctx, false);
|
|
2257
|
+
else if (t.isSequenceExpression(ast)) {
|
|
2258
|
+
const statements = ast.expressions.map((expr) => t.expressionStatement(expr));
|
|
2259
|
+
return processInlineArrowFunction(t.blockStatement(statements), [], counter, callExpressionWithArgs, excludeBindingVars, node, returnValue, ctx, false);
|
|
2260
|
+
} else if (t.isLogicalExpression(ast) || t.isConditionalExpression(ast)) return createShortExprHandler(ast, [], callExpressionWithArgs, vForInfoList, getVForVariables(ctx, node), ctx, counter, returnValue, false);
|
|
2255
2261
|
return "";
|
|
2256
2262
|
}
|
|
2257
2263
|
/**
|
|
@@ -2343,6 +2349,10 @@ function collectExternalVarsFromExpression(body, arrowFunctionArgumentNames, vFo
|
|
|
2343
2349
|
collectVarsFromNode(node.left);
|
|
2344
2350
|
collectVarsFromNode(node.right);
|
|
2345
2351
|
} else if (t.isUnaryExpression(node)) collectVarsFromNode(node.argument);
|
|
2352
|
+
else if (t.isAssignmentExpression(node)) {
|
|
2353
|
+
collectVarsFromNode(node.left);
|
|
2354
|
+
collectVarsFromNode(node.right);
|
|
2355
|
+
}
|
|
2346
2356
|
};
|
|
2347
2357
|
if (t.isConditionalExpression(body)) {
|
|
2348
2358
|
collectVarsFromNode(body.test);
|
|
@@ -2375,6 +2385,14 @@ function rewriteExpressionVars(expr, varsToCollect, arrowFunctionArgumentNames,
|
|
|
2375
2385
|
else if (t.isLogicalExpression(node)) return t.logicalExpression(node.operator, processExpr(node.left), processExpr(node.right));
|
|
2376
2386
|
else if (t.isBinaryExpression(node)) return t.binaryExpression(node.operator, processExpr(node.left), processExpr(node.right));
|
|
2377
2387
|
else if (t.isUnaryExpression(node)) return t.unaryExpression(node.operator, processExpr(node.argument));
|
|
2388
|
+
else if (t.isAssignmentExpression(node)) {
|
|
2389
|
+
const left = node.left;
|
|
2390
|
+
if (t.isIdentifier(left) || t.isMemberExpression(left)) {
|
|
2391
|
+
const rewritten = processExpr(left);
|
|
2392
|
+
if (t.isIdentifier(rewritten) || t.isMemberExpression(rewritten)) return t.assignmentExpression(node.operator, rewritten, processExpr(node.right));
|
|
2393
|
+
}
|
|
2394
|
+
return t.assignmentExpression(node.operator, left, processExpr(node.right));
|
|
2395
|
+
}
|
|
2378
2396
|
return node;
|
|
2379
2397
|
};
|
|
2380
2398
|
return processExpr(expr);
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import dotenv from "dotenv-flow";
|
|
|
2
2
|
//#region src/index.ts
|
|
3
3
|
async function runVMS(options) {
|
|
4
4
|
dotenv.config({ node_env: options.mode });
|
|
5
|
-
const { dev, prod } = await import("./cli-
|
|
5
|
+
const { dev, prod } = await import("./cli-B8qDheMe.js");
|
|
6
6
|
if (options.mode === "production") return prod(options);
|
|
7
7
|
else return dev();
|
|
8
8
|
}
|