Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const FILL = 'FILL'
const TEXT = 'TEXT'
const flatten = (arr = []) => arr.reduce((a, b) => {
return [
...a,
b,
...flatten(b.children)
]
}, [])
// schema
const Theme = struct({
colors: 'object',
textStyles: struct.dict([
'string',
struct({
fontFamily: 'string',
fontSize: 'number',
fontWeight: 'number',
lineHeight: 'number',
})
]),
fonts: 'array',
fontSizes: 'array',
fontWeights: 'array',
lineHeights: 'array',
metadata: 'object?'
})
const Data = struct.partial({
]),
fonts: 'array',
fontSizes: 'array',
fontWeights: 'array',
lineHeights: 'array',
metadata: 'object?'
})
const Data = struct.partial({
name: 'string',
lastModified: 'string',
thumbnailUrl: 'string',
document: struct.partial({
children: struct.list([ 'object' ]),
}),
styles: struct.dict([
'string',
struct.partial({
name: 'string',
styleType: 'string',
})
])
})
const unique = arr => [...new Set(arr)]
module.exports = (data, opts = {}) => {
Data(data)
const {
styles = {},
document: {
children: tree = []
const gatewayFragmentVersionStructure = struct({
assets: [gatewayFragmentAssetsStructure],
dependencies: [gatewayFragmentDependenctStructure],
handler: 'string?'
});
const gatewayFragmentStructure = struct({
name: 'string',
testCookie: 'string',
prg: struct.optional('boolean'),
render: gatewayRenderStructure,
warden: struct.optional('object'),
version: 'string',
versionMatcher: 'string?',
versions: struct.dict(['string', gatewayFragmentVersionStructure])
});
const gatewayStructure = struct({
name: 'string',
url: 'string',
serverOptions: serverOptionsStructure,
fragments: [gatewayFragmentStructure],
api: [apiStructure],
isMobile: 'boolean?',
authToken: 'string?',
fragmentsFolder: 'string',
corsDomains: struct.optional(['string']),
corsMaxAge: 'number?',
customHeaders: struct.optional([customHeaderStructure])
});