Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
acc[styleKey] = styleValue
return acc
case 'static':
const staticContent = styleValue.content
if (typeof staticContent === 'number') {
acc[styleKey] = styleValue
return acc
}
if (
typeof staticContent === 'string' &&
STYLE_PROPERTIES_WITH_URL.includes(styleKey) &&
staticContent.includes(Constants.ASSETS_IDENTIFIER)
) {
// split the string at the beginning of the ASSETS_IDENTIFIER string
const startIndex = staticContent.indexOf(Constants.ASSETS_IDENTIFIER) - 1 // account for the leading '/'
const newStyleValue =
staticContent.slice(0, startIndex) +
UIDLUtils.prefixAssetsPath(
assetsPrefix,
staticContent.slice(startIndex, staticContent.length)
)
acc[styleKey] = {
type: 'static',
content: newStyleValue,
}
} else {
acc[styleKey] = styleValue
}
return acc
case 'nested-style':
acc[styleKey] = styleValue
const projectTemplate =
projectType === ProjectType.PREACT && publisher === PublisherType.CODESANDBOX
? PreactCodesandBoxTemplate
: templates[projectType]
if (!projectGeneratorFactory) {
throw new InvalidProjectTypeError(projectType)
}
if (publisher && !projectPublisherFactories[publisher]) {
throw new InvalidPublisherTypeError(publisher)
}
packer.setAssets({
assets,
path: [Constants.ASSETS_IDENTIFIER],
})
packer.setGenerator(projectGeneratorFactory())
packer.setTemplate(projectTemplate)
// If no publisher is provided, the packer will return the generated project
if (publisher) {
const publisherFactory = projectPublisherFactories[publisher]
const projectPublisher = publisherFactory(publishOptions)
packer.setPublisher(projectPublisher)
}
return packer.pack(projectUIDL)
}
switch (styleValue.type) {
case 'dynamic':
acc[styleKey] = styleValue
return acc
case 'static':
const staticContent = styleValue.content
if (typeof staticContent === 'number') {
acc[styleKey] = styleValue
return acc
}
if (
typeof staticContent === 'string' &&
STYLE_PROPERTIES_WITH_URL.includes(styleKey) &&
staticContent.includes(Constants.ASSETS_IDENTIFIER)
) {
// split the string at the beginning of the ASSETS_IDENTIFIER string
const startIndex = staticContent.indexOf(Constants.ASSETS_IDENTIFIER) - 1 // account for the leading '/'
const newStyleValue =
staticContent.slice(0, startIndex) +
UIDLUtils.prefixAssetsPath(
assetsPrefix,
staticContent.slice(startIndex, staticContent.length)
)
acc[styleKey] = {
type: 'static',
content: newStyleValue,
}
} else {
acc[styleKey] = styleValue
}