Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
),
),
);
}
}
}
} else if (t.isFunctionDeclaration(node)) {
// Function declarations can be hoisted out of the module initialization function
fns.push(node);
} else if (t.isClassDeclaration(node)) {
// Class declarations are not hoisted. We declare a variable outside the
// function convert to a class expression assignment.
decls.push(t.variableDeclarator(t.identifier(node.id.name)));
body.push(
t.expressionStatement(
t.assignmentExpression(
'=',
t.identifier(node.id.name),
t.toExpression(node),
),
),
);
} else {
body.push(node);
}
}
let executed = getName(asset, 'executed');
decls.push(
t.variableDeclarator(t.identifier(executed), t.booleanLiteral(false)),
);
node: { expressions }
} = path;
for (let index = 0; index < expressions.length; index++) {
let assignments = extractSequentialDestructurableElements(module, expressions, index);
if (assignments.length > 0 && index === 0) {
// `a = obj.a;` -> `(a = obj.a);`
module.magicString.appendLeft(assignments[0].start, '(');
module.magicString.appendRight(assignments[assignments.length - 1].end, ')');
}
if (assignments.length > 0) {
rewriteDestructurableElements(module, assignments);
expressions.splice(index, assignments.length, t.assignmentExpression(
'=',
t.objectPattern(
assignments.map(({ left }) => t.objectProperty(
left, left, false, true
))
),
assignments[0].right.object
));
}
}
if (expressions.length === 1) {
path.replaceWith(expressions[0]);
}
}
};
get(key) {
if (!this.has(key)) return;
const record = this._map.get(key);
const { value } = record;
record.count--;
if (record.count === 0) {
// The `count` access is the outermost function call (hopefully), so it
// does the assignment.
return t.assignmentExpression("=", value, key);
}
return value;
}
() => {
invariant(proto);
let serializedProto = this.serializeValue(proto);
let uid = this.getSerializeObjectIdentifier(obj);
if (!this.realm.isCompatibleWith(this.realm.MOBILE_JSC_VERSION) && !this.realm.isCompatibleWith("mobile"))
this.emitter.emit(
t.expressionStatement(
t.callExpression(this.preludeGenerator.memoizeReference("Object.setPrototypeOf"), [uid, serializedProto])
)
);
else {
this.emitter.emit(
t.expressionStatement(
t.assignmentExpression("=", t.memberExpression(uid, protoExpression), serializedProto)
)
);
}
if (semaphore !== undefined) semaphore.releaseOne();
},
this.emitter.getBody()
bindName: "article_" + arguments[0].value, //加个前缀以防冲突
type: arguments[1].value,
data: generate(arguments[2]).code, //这里可能会有多种类型,so,直接转字符串
target: arguments[3]
}
global.log.push("wxParse: " + generate(path).code + " file: " + file_js);
//将原来的代码注释
babelUtil.addComment(path, `${generate(path.node).code}`);
//替换节点
//装13之选 ,一堆代码只为还原一行代码: setTimeout(()=>{this.uParseArticle = contentData}, 200);
const left = t.memberExpression(wxParseArgs.target, t.identifier(wxParseArgs.bindName), false);
const right = t.identifier(wxParseArgs.data);
const assExp = t.assignmentExpression("=", left, right);
const bState = t.blockStatement([t.expressionStatement(assExp)]);
const args = [t.ArrowFunctionExpression([], bState), t.numericLiteral(200)]; //延时200ms防止百度小程序解析不出来
const callExp = t.callExpression(t.identifier("setTimeout"), args);
const expState = t.expressionStatement(callExp);
path.replaceWith(expState);
/////////////////////////////////////////////////////////////////
//填充变量名到data里去,astDataPath理论上会有值,因为根据模板填充,data是居第一个,so,开搂~
if (astDataPath) {
try {
const properties = astDataPath.get("body.body.0.argument.properties");
const op = t.objectProperty(t.Identifier(wxParseArgs.bindName), t.stringLiteral(""));
properties.push(op);
} catch (error) {
const logStr = "Error: " + error + " source: astDataPath.get(\"body.body.0.argument.properties\")" + " file: " + file_js;
//存入日志,方便查看,以防上面那么多层级搜索出问题
functionDeclaration.scope.hasOwnBinding(variable.name) &&
variable.name == stateVariable.node.name
) {
const stateName = functionDeclaration.scope.generateUidIdentifier(stateVariable.node.name);
path.get('right').traverse({
Identifier(p: NodePath) {
if (functionDeclaration.scope.hasOwnBinding(p.node.name) && p.node.name == stateVariable.node.name) {
p.replaceWith(stateName);
}
}
});
path.replaceWith(
t.callExpression(updater, [
t.arrowFunctionExpression(
[stateName],
t.assignmentExpression(path.node.operator, stateName, path.get('right').node)
)
])
);
}
}
});
function buildUmd(whitelist) {
const namespace = t.identifier("babelHelpers");
const body = [];
body.push(
t.variableDeclaration("var", [
t.variableDeclarator(namespace, t.identifier("global")),
]),
);
buildHelpers(body, namespace, whitelist);
return t.program([
buildUmdWrapper({
FACTORY_PARAMETERS: t.identifier("global"),
BROWSER_ARGUMENTS: t.assignmentExpression(
"=",
t.memberExpression(t.identifier("root"), namespace),
t.objectExpression([]),
),
COMMON_ARGUMENTS: t.identifier("exports"),
AMD_ARGUMENTS: t.arrayExpression([t.stringLiteral("exports")]),
FACTORY_BODY: body,
UMD_ROOT: t.identifier("this"),
}),
]);
}
}
else {
extra.push(t.variableDeclaration('let', [t.variableDeclarator(cloned, uid)]));
param.replaceWith(uid);
}
accumulating = true;
}
else if (accumulating && assignmentRight && !isSimple(assignmentRight)) {
extra.push(t.ifStatement(
t.binaryExpression(
'===',
param.node,
t.identifier('undefined')
),
t.blockStatement([
t.expressionStatement(t.assignmentExpression(
'=',
param.node,
assignmentRight.node
))
])
));
original.replaceWith(param.node);
}
}
if (extra.length > 0) {
body.unshiftContainer('body', extra);
}
}
export const setComponentPropsToDom = (path, result) => {
const parentComponent = jsxParentComponent(path);
if (parentComponent && parentComponent.params.length === 1) {
//_el$.$props = props;
result.exprs.push(
t.expressionStatement(
t.assignmentExpression(
"=",
t.memberExpression(result.id, t.identifier("$props")),
parentComponent.params[0]
)
)
);
}
};
function assignment(value) {
return t.assignmentExpression(
'=',
t.memberExpression(
t.identifier('module'),
t.identifier('exports'),
false
),
value
);
}