Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Babylon represents directives like "use strict" as elements of
// a bodyBlockPath.node.directives array. (#248)
node.body.directives = oldDirectives;
}
let wasGeneratorFunction = node.generator;
if (wasGeneratorFunction) {
node.generator = false;
}
if (node.async) {
node.async = false;
}
if (wasGeneratorFunction && t.isExpression(node)) {
util.replaceWithOrRemove(path, t.callExpression(util.runtimeProperty("mark"), [node]))
path.addComment("leading", "#__PURE__");
}
// Generators are processed in 'exit' handlers so that regenerator only has to run on
// an ES5 AST, but that means traversal will not pick up newly inserted references
// to things like 'regeneratorRuntime'. To avoid this, we explicitly requeue.
path.requeue();
}
}
if (objs.length === 1) {
// only one object
attribs = objs[0];
} else {
// looks like we have multiple objects
if (!t.isObjectExpression(objs[0])) {
objs.unshift(t.objectExpression([]));
}
const helper = useBuiltIns ?
t.memberExpression(t.identifier("Object"), t.identifier("assign")) :
file.addHelper("extends");
// spread it
attribs = t.callExpression(helper, objs);
}
return attribs;
}
}
exports.genConstructor = function genConstructor (path, state) {
const nodeLists = path.node.body;
const blocks = [
t.expressionStatement(t.callExpression(t.super(), [t.identifier('props')]))
];
if (state.data['_statements']) {
state.data['_statements'].forEach(node => {
if (t.isReturnStatement(node)) {
const props = node.argument.properties;
// supports init data property with props property
props.forEach(n => {
if (t.isMemberExpression(n.value)) {
n.value = t.memberExpression(t.identifier('props'), t.identifier(n.value.property.name));
}
});
blocks.push(
t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('state')), node.argument))
);
} else {
if (callee.isReferencedIdentifier()) {
const id = callee.node
const ids = [id.name]
if (t.isIdentifier(id) && id.name.startsWith('on')) {
const funcExpr = path.findParent(p => p.isFunctionExpression())
if (funcExpr && funcExpr.isFunctionExpression()) {
const taroAPI = funcExpr.findParent(p => p.isCallExpression() && t.isMemberExpression(p.node.callee) && t.isIdentifier(p.node.callee.object, { name: 'Taro' }))
if (taroAPI && taroAPI.isCallExpression()) {
throw codeFrameError(funcExpr.node, '在回调函数使用从 props 传递的函数时,请把回调函数改造为箭头函数并一直使用 `this` 取值')
}
}
const fullPath = buildFullPathThisPropsRef(id, ids, path)
if (fullPath) {
path.replaceWith(
t.callExpression(
fullPath,
path.node.arguments
)
)
}
}
}
},
// JSXIdentifier (path) {
// Babylon represents directives like "use strict" as elements of
// a bodyBlockPath.node.directives array. (#248)
node.body.directives = oldDirectives;
}
let wasGeneratorFunction = node.generator;
if (wasGeneratorFunction) {
node.generator = false;
}
if (node.async) {
node.async = false;
}
if (wasGeneratorFunction && t.isExpression(node)) {
path.replaceWith(t.callExpression(util.runtimeProperty("mark"), [node]));
}
// Generators are processed in 'exit' handlers so that regenerator only has to run on
// an ES5 AST, but that means traversal will not pick up newly inserted references
// to things like 'regeneratorRuntime'. To avoid this, we explicitly requeue.
path.requeue();
}
}
})
root = rootNode ? rootNode.value.value : ''
}
value.elements.forEach(v => {
const pagePath = `${root}/${v.value}`.replace(/\/{2,}/g, '/')
pages.push(pagePath.replace(/^\//, ''))
})
} else if (keyName === 'tabBar' && t.isObjectExpression(value)) {
// tabBar
tabBar = value
value.properties.forEach(node => {
if (node.keyName === 'position') tabbarPos = node.value.value
})
} else if ((keyName === 'iconPath' || keyName === 'selectedIconPath') && t.isStringLiteral(value)) {
astPath.replaceWith(
t.objectProperty(t.stringLiteral(keyName), t.callExpression(t.identifier('require'), [t.stringLiteral(`./${value.value}`)]))
)
}
}
}
const cpsBodyStatements = cps(body.body, path).map((x) => {
if (t.isReturnStatement(x)) {
return t.returnStatement(t.callExpression(continuation, x.argument));
}
return x;
});
const cpsBody = t.blockStatement(cpsBodyStatements);
validIdentifier,
t.booleanLiteral(true)
));
if (validatorKeys.length) {
body.unshift(
firstValueParserNode,
ifAllTruthy([
valueParserNodesLength(1),
], validatorList)
);
}
body.push(
t.expressionStatement(
t.callExpression(
t.memberExpression(
valueParserASTIdentifier,
t.identifier('walk')
), [
t.arrowFunctionExpression([
nodeIdentifier,
indexIdentifier,
], t.blockStatement([
t.ifStatement(
t.binaryExpression(
'!==',
validIdentifier,
t.booleanLiteral(true)
),
t.blockStatement([
t.returnStatement(),
if (prop.decorators) memoiseDecorators(prop.decorators, scope);
if (prop.kind === "init" && !prop.method) {
prop.kind = "";
prop.value = t.functionExpression(null, [], t.blockStatement([
t.returnStatement(prop.value)
]));
}
defineMap.push(mutatorMap, prop, "initializer", file);
}
var obj = defineMap.toClassObject(mutatorMap);
obj = defineMap.toComputedObjectFromClass(obj);
return t.callExpression(file.addHelper("create-decorated-object"), [obj]);
}
};
keyIterNextFn,
t.callExpression(
util.runtimeProperty("keys"),
[self.explodeExpression(path.get("right"))]
)
);
self.mark(head);
let keyInfoTmpVar = self.makeTempVar();
self.jumpIf(
t.memberExpression(
t.assignmentExpression(
"=",
keyInfoTmpVar,
t.callExpression(keyIterNextFn, [])
),
t.identifier("done"),
false
),
after
);
self.emitAssign(
stmt.left,
t.memberExpression(
keyInfoTmpVar,
t.identifier("value"),
false
)
);