Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
new commonTags.TemplateTag(commonTags.trimResultTransformer());
new commonTags.TemplateTag(commonTags.trimResultTransformer('left'));
new commonTags.TemplateTag(commonTags.trimResultTransformer('right'));
new commonTags.TemplateTag(commonTags.stripIndentTransformer());
new commonTags.TemplateTag(commonTags.stripIndentTransformer('initial'));
new commonTags.TemplateTag(commonTags.stripIndentTransformer('all'));
new commonTags.TemplateTag(commonTags.replaceResultTransformer('foo', 'bar'));
new commonTags.TemplateTag(commonTags.inlineArrayTransformer());
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({}));
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({separator: 'foo'}));
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({conjunction: 'bar'}));
new commonTags.TemplateTag(commonTags.splitStringTransformer('foo'));
const generateRawTags = (items: any[] = []) => {
if (typeof items === 'string' || items instanceof String) return items
return items.map(item => item).join('')
}
const getHtmlFilepath = (indexHtml: string | undefined) =>
indexHtml
? path.resolve(paths.root, indexHtml)
: fromTemplates('index.tpl.html')
const getPublicUrl = (config: Config, dev: boolean): string => {
const prefix = config.base === '/' ? '' : config.base
return dev ? prefix : `${prefix}/public`
}
const emptyLineTrim = new ctags.TemplateTag(
ctags.replaceResultTransformer(/^\s*[\r\n]/gm, ''),
ctags.trimResultTransformer
)
export const htmlTemplate = async (indexHtml: string | undefined) =>
compiled(getHtmlFilepath(indexHtml), {
minimize: false,
escape: false,
})
interface ParseHtmlParams {
config: Config
ctx: Record
dev: boolean
template: (props: Record) => string
}
msat: 'red desaturate 60',
mlight: 'rgb(255,255,255) darken 25',
bright: 'rgb(255,255,255)',
bob: 'black lighten 50 saturate 50 spin 180',
ul: 'underline',
invert: 'invert',
exBackground: 'background dark red',
exBold: 'bold yellow',
exFaint: 'faint yellow',
exItalic: 'italic #33FF33',
exInvert: 'invert #7B00B1',
exUnderline: 'underline #fff',
exBlink: 'blink orange'
}))
export const colorReplacer = new TemplateTag(
replaceSubstitutionTransformer(
/([a-zA-Z]+?)[:/|](.+)/,
(match, colorName, content) => `${clr[colorName]}${content}${clr[colorName].out}`
)
)
export function spectrum(width, char) {
if (terminalFeatures.color.has16m) {
return _.map(new Array(width), (val, col) => {
const scos = Math.cos((col / width) * (Math.PI / 2))
const ssin = Math.sin((col / width) * (Math.PI))
const red = (scos > 0) ? Math.floor(scos * 255) : 0
const green = (ssin > 0) ? Math.floor(ssin * 255) : 0
const blue = (scos > 0) ? Math.floor((1 - scos) * 255) : 0
return `\u001B[38;2;${red};${green};${blue}m${char}`
}).join('')