Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static retriveUsedUniforms(shaderToySample) {
/*
uniform vec3 iResolution; //Done: viewport resolution (in pixels)
uniform float iTime; //Done: shader playback time (in seconds)
uniform float iTimeDelta; //Done: render time (in seconds)
uniform int iFrame; //Done: shader playback frame
uniform float iChannelTime[4]; //Wont Do now: channel playback time (in seconds)
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube
uniform vec4 iDate; //Do (year, month, day, time in seconds)
uniform float iSampleRate; //Wont Do sound sample rate (i.e., 44100)
*/
let commentLessShader = shaderToySample.replace(commentRegex(), "");
let expectedUniforms = "iTime,iTimeDelta,iResolution,iFrame,iChannelTime[4],iChannelResolution,iChannel0,iChannel1,iChannel2,iChannel3,iDate,iMouse".split(",");
let existingUniforms = {};
expectedUniforms.forEach(uniform => {
if (commentLessShader.includes(uniform))
existingUniforms[uniform] = true;
});
return existingUniforms;
}
static retriveUsedUniforms(shaderToySample) {
/*
uniform vec3 iResolution; //Done: viewport resolution (in pixels)
uniform float iTime; //Done: shader playback time (in seconds)
uniform float iTimeDelta; //Done: render time (in seconds)
uniform int iFrame; //Done: shader playback frame
uniform float iChannelTime[4]; //Wont Do now: channel playback time (in seconds)
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube
uniform vec4 iDate; //Do (year, month, day, time in seconds)
uniform float iSampleRate; //Wont Do sound sample rate (i.e., 44100)
*/
let commentLessShader = shaderToySample.replace(commentRegex(), "");
let expectedUniforms = "iTime,iTimeDelta,iResolution,iFrame,iChannelTime[4],iChannelResolution,iChannel0,iChannel1,iChannel2,iChannel3,iDate,iMouse".split(",");
let existingUniforms = {};
expectedUniforms.forEach(uniform => {
if (commentLessShader.includes(uniform))
existingUniforms[uniform] = true;
});
return existingUniforms;
}
}
});
rule.value = ast.toString();
// Format `!important`
if (rule.important) {
rule.raws.important = ' !important';
}
if (raws.value) {
rule.raws.value.raw = rule.value;
}
// ensure space following colon
if (!commentRegex().test(rule.raws.between)) {
rule.raws.between = ': ';
}
maxValueLength(rule, opts);
setIndent(rule, opts);
};
rule.raws.after = ' ';
rule.raws.before = indent + blank(rule.raws.before);
rule.raws.semicolon = true;
}
if (rule.raws.selector && rule.raws.selector.raw) {
rule.selector = rule.raws.selector.raw;
}
maxSelectorLength(rule, opts);
if (rule.type === 'decl') {
if (deeplyNested(rule.parent)) {
let newline = rule === css.first ? '' : '\n';
rule.raws.before = newline + indent + blank(rule.raws.before);
} else {
rule.raws.before = ' ' + blank(rule.raws.before);
}
if (!commentRegex().test(rule.raws.between)) {
rule.raws.between = ': ';
}
}
if ((deep || rule.nodes) && rule !== css.first) {
rule.raws.before = '\n ';
}
if (deep) {
rule.raws.after = '\n' + indent;
}
if (rule.parent && rule !== rule.parent.first && (rule.type === 'rule' || rule.type === 'atrule')) {
rule.raws.before = '\n' + indent;
}
});
css.raws.after = '\n';
css.walk(rule => {
const {raws, type} = rule;
rule.raws.semicolon = false;
if (type === 'comment' && raws.inline) {
rule.raws.inline = null;
}
if (type === 'rule' || type === 'atrule') {
rule.raws.between = rule.raws.after = '';
}
if (type === 'decl' && !commentRegex().test(raws.between)) {
rule.raws.between = ':';
}
if (rule.type === 'decl') {
if (raws.value) {
rule.value = raws.value.raw.trim();
}
const ast = valueParser(rule.value);
walk(ast, (node, index, parent) => {
const next = parent.nodes[index + 1];
if (node.type === 'div' && node.value === ',' || node.type === 'function') {
node.before = node.after = '';
}
if (node.type === 'space') {
node.value = ' ';
}
});
});
}
if (raws.selector && raws.selector.raw) {
rule.selector = rule.raws.selector.raw;
}
maxSelectorLength(rule, opts);
if (type === 'atrule') {
if (rule.params) {
rule.raws.afterName = ' ';
}
maxAtRuleLength(rule, opts);
}
if (type === 'decl') {
if (!commentRegex().test(rule.raws.between)) {
rule.raws.between = ': ';
}
maxValueLength(rule, opts);
}
if (rule.parent && rule.parent.type !== 'root') {
rule.raws.before = '\n' + blank(rule.raws.before);
rule.raws.after = '\n' + indent;
}
if (rule.parent && rule !== rule.parent.first && (type === 'rule' || type === 'atrule')) {
if (type === 'atrule' && !rule.nodes) {
rule.raws.before = '\n' + indent;
return;
}
rule.raws.before = '\n\n' + indent;
}
});
export default function (input, {
colors = defaultColors
} = {}) {
let index = 0
const cache = {}
const wordRe = /[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/
const leftAngleRe = / {
if (cm) {
return toComment(cm)
}
if (word === '<') {
return '<'
}
let color
if (cache[word]) {
color = cache[word]
} else {
color = colors[index]
cache[word] = color
}
const apiDeatil = formatRequestUrl(ctx.request.url);
const Url = global.dbHandle.getModel('urls');
const result = await Url.find({
parent_project: apiDeatil.project_id,
method: ctx.method.toLocaleLowerCase()
})
.or([{ url: apiDeatil.api_url }, { url: apiDeatil.api_url.replace(/^\//, '') }]);
const checkResult = checkReqParams(ctx, result[0]);
if (checkResult.err) {
ctx.fail(404, errMap[checkResult.map]);
return;
}
try {
ctx.body = JSON.parse(result[0].response_example.exapmle_array[result[0].response_example.in_use].replace(commentRegex(), ''));
} catch (e) {
ctx.fail(500, '出错啦');
}
});