Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (uidl.seo.assets) {
uidl.seo.assets.forEach((asset) => {
// TODO: Handle other asset types when needed
if (asset.type === 'canonical') {
headObject.link = [{ rel: 'canonical', href: asset.path }]
}
})
}
if (Object.keys(headObject).length > 0) {
const exportObjectAST = componentChunk.content.declaration as types.ObjectExpression
exportObjectAST.properties.push(
types.objectProperty(
types.identifier(metaObjectKey),
ASTUtils.objectToObjectExpression(headObject)
)
)
}
return structure
}
if (componentDependencies.length) {
const componentsAST = t.objectExpression([
...componentDependencies.map((declarationName) => {
return t.objectProperty(
t.identifier(declarationName),
t.identifier(declarationName),
false,
true
)
}),
])
vueObjectProperties.push(t.objectProperty(t.identifier('components'), componentsAST))
}
if (Object.keys(dataObject).length > 0) {
const dataAST = ASTUtils.objectToObjectExpression(dataObject)
vueObjectProperties.push(
t.objectMethod(
'method',
t.identifier('data'),
[],
t.blockStatement([t.returnStatement(dataAST)])
)
)
}
if (Object.keys(methodsObject).length > 0) {
const methodsAST = createMethodsObject(methodsObject, uidl.propDefinitions)
vueObjectProperties.push(
t.objectProperty(t.identifier('methods'), t.objectExpression(methodsAST))
)
}
}
return acc
},
{ values: {}, count: 0 }
)
if (defaultValuesSearch.count === 0) {
return null
}
const memberExpression = t.memberExpression(
t.identifier(componentName),
t.identifier('defaultProps')
)
const memberExpressionValue = ASTUtils.objectToObjectExpression(defaultValuesSearch.values)
const assignmentExpression = t.assignmentExpression('=', memberExpression, memberExpressionValue)
return t.expressionStatement(assignmentExpression)
}
}
dependencies.injectSheet = {
type: 'library',
path: 'react-jss',
version: '8.6.1',
}
chunks.push({
type: ChunkType.AST,
fileType: FileType.JS,
name: styleChunkName,
linkAfter: [importChunkName],
content: ASTBuilders.createConstAssignment(
jssDeclarationName,
ASTUtils.objectToObjectExpression(jssStyleMap)
),
})
const exportChunk = chunks.find((chunk) => chunk.name === exportChunkName)
const componentName = UIDLUtils.getComponentClassName(uidl)
const exportStatement = ASTBuilders.createReactJSSDefaultExport(
componentName,
jssDeclarationName
)
if (exportChunk) {
exportChunk.content = exportStatement
exportChunk.linkAfter = [importChunkName, styleChunkName]
} else {
chunks.push({
export const generateVueComponentJS = (
uidl: ComponentUIDL,
componentDependencies: string[],
dataObject: Record,
methodsObject: Record,
t = types
) => {
const vueObjectProperties = []
if (uidl.propDefinitions) {
const props = createVuePropsDefinition(uidl.propDefinitions)
const propsAST = ASTUtils.objectToObjectExpression(props)
vueObjectProperties.push(t.objectProperty(t.identifier('props'), propsAST))
}
if (componentDependencies.length) {
const componentsAST = t.objectExpression([
...componentDependencies.map((declarationName) => {
return t.objectProperty(
t.identifier(declarationName),
t.identifier(declarationName),
false,
true
)
}),
])
vueObjectProperties.push(t.objectProperty(t.identifier('components'), componentsAST))
}
metaTags.forEach((tag: UIDLMetaTag) => {
metaTagsAST.push(ASTUtils.objectToObjectExpression(tag))
})
return metaTagsAST