Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
get() {
let fields
if (this.templateIndex === 1) {
fields = this.configForm.blocks.routerBlock.blocks.chart1.data
}
const stringFields = JSON.stringify(fields)
// return stringFields
return beautify(stringFields, { indent_size: 4, space_in_empty_paren: true });
},
set(newvalue) {
const data = this._data
let code = data.val
const len = data.val.length
// If source code too big, don't process it.
if (len < MAX_BEAUTIFY_LEN && this._formatCode) {
switch (data.type) {
case 'html':
code = beautify.html(code, { unformatted: [] })
break
case 'css':
code = beautify.css(code)
break
case 'js':
code = beautify(code)
break
}
const curTheme = evalCss.getCurTheme()
code = highlight(code, data.type, {
keyword: `color:${curTheme.keywordColor}`,
number: `color:${curTheme.numberColor}`,
operator: `color:${curTheme.operatorColor}`,
comment: `color:${curTheme.commentColor}`,
string: `color:${curTheme.stringColor}`
})
} else {
code = escape(code)
}
if (len < MAX_LINE_NUM_LEN && this._showLineNum) {
export async function prettyPrintAsSourceMap(
fileName: string,
minified: string,
): Promise {
const source = beautify(minified);
const from = generatePositions(source);
const to = generatePositions(minified);
if (from.length !== to.length) return Promise.resolve(undefined);
const generator = new sourceMap.SourceMapGenerator();
generator.setSourceContent(fileName, source);
// We know that AST for both sources is the same, so we can
// walk them together to generate mapping.
for (let i = 0; i < from.length; i += 2) {
generator.addMapping({
source: fileName,
original: { line: from[i], column: from[i + 1] },
generated: { line: to[i], column: to[i + 1] },
});
}
mounted(){
const stringConfig = stringify(block[this.blockName])
this.configCode = beautify(stringConfig, { indent_size: 2, space_in_empty_paren: true })
// 如果已经注册过则不再注册
if (ams && ams.blocks && ams.blocks[this.blockName]) {
this.init = true;
return;
}
ams.block(`${this.blockName}`, block[this.blockName])
this.init = true
}
}
onToProduceHTML(e){
const config = beautify(stringify(this.filterConfig()), { indent_size: 4, space_in_empty_paren: true });
downloadTemplate(e.currentTarget, this.templateFileName[this.templateIndex], config)
}
}
return {
route,
filename,
index: filename === 'index.html',
depth: path.length - 1,
};
}).sort((a, b): number => a.depth - b.depth);
const serviceWorker = `
const DEV = ${JSON.stringify(dev)};
const routes = ${JSON.stringify(paths, null, 3)}
${swFile}
`;
const cleanUpFile = beautify(serviceWorker, { indent_size: 2, keep_array_indentation: true });
return fs.outputFile(normalize(`${CWD}/dist/${sw}`), cleanUpFile);
};
function jsBeauty(str) {
const opts = {
indent_size: '4',
indent_char: ' ',
preserve_newlines: true,
brace_style: 'collapse',
keep_array_indentation: false,
space_after_anon_function: true,
};
return jsBeautify(str, opts);
}
function formatJs(code) {
const curTheme = evalCss.getCurTheme()
return highlight(beautify(code), 'js', {
keyword: `color:${curTheme.keywordColor}`,
number: `color:${curTheme.numberColor}`,
operator: `color:${curTheme.operatorColor}`,
comment: `color:${curTheme.commentColor}`,
string: `color:${curTheme.stringColor}`
})
}
function createRootSchema(AST) {
for (let key in AST) {
const schema = AST[key]
if (schema.customType) {
rootTypes.push(schema.fieldsType)
if (schema.nestedSchema) {
createRootSchema(schema.nestedSchema)
}
}
fields.push(schema.schema)
}
const root = schemaTemplate(fields.join(','), rootTypes)
return beautify(root)
}