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;
}
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, '出错啦');
}
});