Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var ce = tryEntry.catchEntry;
var fe = tryEntry.finallyEntry;
var locs = [
tryEntry.firstLoc,
// The null here makes a hole in the array.
ce ? ce.firstLoc : null
];
if (fe) {
locs[2] = fe.firstLoc;
locs[3] = fe.afterLoc;
}
return t.arrayExpression(locs);
})
);
let ce = tryEntry.catchEntry;
let fe = tryEntry.finallyEntry;
let locs = [
tryEntry.firstLoc,
// The null here makes a hole in the array.
ce ? ce.firstLoc : null
];
if (fe) {
locs[2] = fe.firstLoc;
locs[3] = fe.afterLoc;
}
return t.arrayExpression(locs);
})
);
CallExpression (astPath) {
const node = astPath.node
const callee = node.callee as t.Identifier
if (callee.name === 'require') {
const args = node.arguments as Array
const requirePath = args[0].value
if (REG_JSON.test(requirePath)) {
const realRequirePath = path.resolve(path.dirname(filePath), requirePath)
if (fs.existsSync(realRequirePath)) {
const obj = JSON.parse(fs.readFileSync(realRequirePath).toString())
let objArr: t.NullLiteral | t.Expression | t.ObjectProperty[] = t.nullLiteral()
if (Array.isArray(obj)) {
objArr = t.arrayExpression(convertArrayToAstExpression(obj))
} else {
objArr = convertObjectToAstExpression(obj)
}
astPath.replaceWith(t.objectExpression(objArr as any))
}
return
}
analyzeImportUrl({
requirePath,
excludeRequire,
source: args[0],
filePath,
files,
isProduction,
npmConfig,
rootNpm,
astPath.parentPath.remove()
} else if (astPath.parent.type === 'VariableDeclarator') {
astPath.parentPath.parentPath.remove()
} else {
astPath.remove()
}
} else if (Util.REG_JSON.test(valueExtname)) {
const vpath = path.resolve(sourceFilePath, '..', value)
if (jsonFiles.indexOf(vpath) < 0) {
jsonFiles.push(vpath)
}
if (fs.existsSync(vpath)) {
const obj = JSON.parse(fs.readFileSync(vpath).toString())
let objArr = [t.nullLiteral()]
if (Array.isArray(obj)) {
objArr = t.arrayExpression(astConvert.array(obj))
} else {
objArr = t.objectExpression(astConvert.obj(obj))
}
astPath.replaceWith(t.objectExpression(objArr))
}
} else if (Util.REG_SCRIPT.test(valueExtname) || Util.REG_TYPESCRIPT.test(valueExtname)) {
const vpath = path.resolve(sourceFilePath, '..', value)
let fPath = value
if (fs.existsSync(vpath) && vpath !== sourceFilePath) {
fPath = vpath
}
if (scriptFiles.indexOf(fPath) < 0) {
scriptFiles.push(fPath)
}
} else if (Util.REG_FONT.test(valueExtname) || Util.REG_IMAGE.test(valueExtname) || Util.REG_MEDIA.test(valueExtname)) {
const vpath = path.resolve(sourceFilePath, '..', value)
function transform(
root: IRNode,
codeGen: CodeGen,
state: State,
): t.Expression {
const stack = new Stack();
stack.push(
t.arrayExpression([]),
);
traverse(root, {
text: {
exit(textNode: IRText) {
let { value } = textNode;
if (typeof value !== 'string') {
value = bindExpression(value, textNode).expression as t.MemberExpression;
}
(stack.peek() as t.ArrayExpression).elements.push(
codeGen.genText(value),
);
},
},
if (binded) args.shift()
path.replaceWith(
t.callExpression(
t.memberExpression(t.thisExpression(), t.identifier('__triggerPropsFn')),
[
t.stringLiteral(propertyArray.reverse().join('.')),
t.arrayExpression(args)
]
)
)
} else {
path.replaceWith(
t.callExpression(
t.memberExpression(t.thisExpression(), t.identifier('__triggerPropsFn')),
[t.stringLiteral(propertyArray.reverse().join('.')), t.callExpression(
t.memberExpression(t.arrayExpression([t.nullLiteral()]), t.identifier('concat')),
[t.arrayExpression(args)]
)]
)
)
}
}
traverseMember(object)
}
}
traverseMember(member)
rulesRegistration = rulesRegistration.reduce(function (result, current) {
var name;
if (current.expression && current.expression.left) {
name = current.expression.left.property.value;
if (name && rulesBuffer[name]) {
if (result[rulesBuffer[name].index].expression.right.type === 'ArrayExpression') {
result[rulesBuffer[name].index].expression.right.elements.push(
t.identifier(current.expression.right.name)
);
} else {
result[rulesBuffer[name].index].expression.right = t.arrayExpression([
t.identifier(rulesBuffer[name].rule.expression.right.name),
t.identifier(current.expression.right.name)
]);
}
} else {
rulesBuffer[name] = { index: result.length, rule: current };
result.push(current);
}
}
return result;
}, []);
_buildRunnerSetters(block, hoistDeclarators) {
let scope = this.file.scope;
return t.arrayExpression(map(this.ids, function (uid, source) {
let state = {
hoistDeclarators: hoistDeclarators,
source: source,
nodes: []
};
scope.traverse(block, runnerSettersVisitor, state);
return t.functionExpression(null, [uid], t.blockStatement(state.nodes));
}));
}
function getRuntimeMarkDecl(blockPath) {
let block = blockPath.node;
assert.ok(Array.isArray(block.body));
let info = getMarkInfo(block);
if (info.decl) {
return info.decl;
}
info.decl = t.variableDeclaration("var", [
t.variableDeclarator(
blockPath.scope.generateUidIdentifier("marked"),
t.callExpression(
t.memberExpression(
t.arrayExpression([]),
t.identifier("map"),
false
),
[util.runtimeProperty("mark")]
)
)
]);
blockPath.unshiftContainer("body", info.decl);
return info.decl;
}
handleRefs() {
const objExpr = this.refs.map(ref => {
return t.objectExpression([
t.objectProperty(t.identifier('type'), t.stringLiteral(ref.type)),
t.objectProperty(t.identifier('id'), t.stringLiteral(ref.id)),
t.objectProperty(t.identifier('refName'), t.stringLiteral(ref.refName || '')),
t.objectProperty(t.identifier('fn'), ref.fn ? ref.fn : t.nullLiteral())
]);
});
this.classPath.node.body.body.push(t.classProperty(t.identifier('$$refs'), t.arrayExpression(objExpr)));
}
traverse() {