Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setProperies() {
const properties = [];
this.componentProperies.forEach((propName) => {
properties.push(t.objectProperty(t.stringLiteral(propName), t.objectExpression([
t.objectProperty(t.stringLiteral('type'), t.nullLiteral()),
t.objectProperty(t.stringLiteral('value'), t.nullLiteral())
])));
});
let classProp = t.classProperty(t.identifier('properties'), t.objectExpression(properties));
classProp.static = true;
const classPath = this.renderPath.findParent(isClassDcl);
adapter_1.Adapter.type !== "alipay" /* alipay */ && classPath.node.body.body.unshift(classProp);
}
setLoopRefFlag() {
t.objectProperty(
t.identifier('unknownShape'),
t.objectExpression([
t.objectProperty(
t.identifier('type'),
typeMap.ref({ type: 'boolean' }, false)
),
])
)
);
}
const node = t.variableDeclaration('const', [
t.variableDeclarator(
t.identifier(graphqlName),
t.newExpression(typeMap.objectTypeRef, [
t.objectExpression([
t.objectProperty(t.identifier('name'), t.stringLiteral(graphqlName)),
t.objectProperty(
t.identifier('fields'),
// arrow expression to deal with recursion
t.arrowFunctionExpression([], t.objectExpression(fields))
),
]),
])
),
]);
return node;
}
function build(namespace, globalVar = "global", builder) {
const body = [];
const container = t.functionExpression(null, [t.identifier(globalVar)], t.blockStatement(body));
const tree = t.program([
t.expressionStatement(t.callExpression(container, [
t.assignmentExpression('=',
t.memberExpression(t.thisExpression(), t.identifier(globalVar)),
t.logicalExpression('||',
t.memberExpression(t.thisExpression(), t.identifier(globalVar)),
t.objectExpression([])
)
)
]))
]);
// AST for: var globalMember = Global.globalMember = {};
body.push(t.variableDeclaration("var", [
t.variableDeclarator(
t.identifier(namespace.name),
t.assignmentExpression("=", t.memberExpression(
t.identifier(globalVar), namespace),
t.objectExpression([])
)
)
]));
.then(moduleProps => moduleSetTmpl({
GLOBAL_NAME: t.stringLiteral(globalName),
MODULES_HASH: t.objectExpression(moduleProps)
}));
},
if (t.isFunctionExpression(func) || t.isArrowFunctionExpression(func)) {
const params = func.params as t.Identifier[]
indexId = params[1]
name = names.get(callee)
}
if (indexId === null || !t.isIdentifier(indexId)) {
indexId = t.identifier(callee.scope.generateUid('anonIdx'));
(func as any).params = [(func as any).params[0], indexId]
}
if (!name) {
throw codeFrameError(callee.node, '找不到循环对应的名称')
}
loops.elements.unshift(t.objectExpression([
t.objectProperty(t.identifier('indexId'), indexId),
t.objectProperty(t.identifier('name'), t.stringLiteral(name))
]))
const parentCallExpr = callee.findParent(p => p.isCallExpression())
if (parentCallExpr && parentCallExpr.isCallExpression()) {
const callee = parentCallExpr.node.callee
if (
t.isMemberExpression(callee) &&
t.isIdentifier(callee.property) &&
callee.property.name === 'map'
) {
findParentLoops(parentCallExpr, names, loops)
}
}
}
function pushProps() {
if (!_props.length) return;
objs.push(t.objectExpression(_props));
_props = [];
}
const slots: t.ObjectProperty[] = [];
Object.keys(element.slotSet).forEach((key) => {
const slotRoot = createIRElement('template', {});
slotRoot.children = element.slotSet![key];
slots.push(
t.objectProperty(
t.stringLiteral(key),
transform(slotRoot, codeGen, state),
),
);
});
databag.properties.push(
t.objectProperty(t.stringLiteral('slotset'), t.objectExpression(slots)),
);
}
function buildUmd(namespace, builder) {
let body = [];
body.push(t.variableDeclaration("var", [
t.variableDeclarator(namespace, t.identifier("global"))
]));
builder(body);
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 if (Array.isArray(value)) {
return build.arrayExpression(value.map(item =>
buildJSON(item)));
} else if (typeof value === 'object') {
let properties = [];
for (let key in value) {
if (value.hasOwnProperty(key)) {
properties.push(
build.objectProperty(
build.stringLiteral(key),
buildJSON(value[key])
)
);
}
}
return build.objectExpression(properties);
} else {
throw new Error('cannot parse value to AST: ' + value);
}
}
function insertBefore(node, id) {
return t.callExpression(t.memberExpression(node, t.identifier('attrs')), [
t.objectExpression([
t.objectProperty(
t.StringLiteral(options.attribute),
t.StringLiteral(options.format(id))
)
])
])
}
function isStyledPrefix(node) {