diff --git a/bin/gpu-core.js b/bin/gpu-core.js index c519fc88..f7860569 100644 --- a/bin/gpu-core.js +++ b/bin/gpu-core.js @@ -5,14 +5,14 @@ * GPU Accelerated JavaScript * * @version 1.6.2 - * @date Sun Sep 02 2018 13:35:51 GMT-0400 (EDT) + * @date Mon Sep 03 2018 14:59:43 GMT-0500 (Central Daylight Time) * * @license MIT * The MIT License * * Copyright (c) 2018 gpu.js Team */ -"use strict";(function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { retArr.push(','); } @@ -586,7 +587,7 @@ module.exports = function (_BaseFunctionNode) { key: 'astMemberExpression', value: function astMemberExpression(mNode, retArr) { if (mNode.computed) { - if (mNode.object.type === 'Identifier') { + if (mNode.object.type === 'Identifier' || mNode.object.type === 'MemberExpression' && mNode.object.object.object && mNode.object.object.object.type === 'ThisExpression' && mNode.object.object.property.name === 'constants') { this.pushState('identifier'); this.astGeneric(mNode.object, retArr); this.popState('identifier'); @@ -658,7 +659,9 @@ module.exports = function (_BaseFunctionNode) { unrolled = 'user_' + unrolled; } - if (unrolled.indexOf('this') === 0) { + if (unrolled.indexOf('this.constants') === 0) { + unrolled = 'constants_' + unrolled.substring(15); + } else if (unrolled.indexOf('this') === 0) { unrolled = '_' + unrolled; } @@ -679,6 +682,9 @@ module.exports = function (_BaseFunctionNode) { retArr.push(this.output[2]); break; default: + if (mNode.object && mNode.object.name && this.declarations[mNode.object.name]) { + retArr.push('user_'); + } retArr.push(unrolled); } @@ -815,7 +821,7 @@ function removeNoise(str) { } module.exports = function (cpuKernel, name) { - return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n class ' + (name || 'Kernel') + ' {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(cpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(cpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(cpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n this._kernelString = `' + cpuKernel._kernelString + '`;\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(cpuKernel.build.toString()) + '\n ' + removeFnNoise(cpuKernel.setupParams.toString()) + '\n run () { ' + cpuKernel.kernelString + ' }\n getKernelString() { return this._kernelString; }\n ' + removeFnNoise(cpuKernel.validateOptions.toString()) + '\n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n class ' + (name || 'Kernel') + ' {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(cpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(cpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(cpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n this._kernelString = `' + cpuKernel._kernelString + '`;\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(cpuKernel.build.toString()) + '\n ' + removeFnNoise(cpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(cpuKernel.setupConstants.toString()) + '\n run () { ' + cpuKernel.kernelString + ' }\n getKernelString() { return this._kernelString; }\n ' + removeFnNoise(cpuKernel.validateOptions.toString()) + '\n };\n return kernelRunShortcut(new Kernel());\n };'; }; },{"../../core/utils":32,"../kernel-run-shortcut":9}],4:[function(require,module,exports){ 'use strict'; @@ -887,8 +893,11 @@ module.exports = function (_KernelBase) { }, { key: 'build', value: function build() { + this.setupConstants(); this.setupParams(arguments); this.validateOptions(); + var canvas = this._canvas; + this._canvasCtx = canvas.getContext('2d'); var threadDim = this.threadDim = utils.clone(this.output); while (threadDim.length < 3) { @@ -896,10 +905,8 @@ module.exports = function (_KernelBase) { } if (this.graphical) { - var canvas = this.getCanvas(); canvas.width = threadDim[0]; canvas.height = threadDim[1]; - this._canvasCtx = canvas.getContext('2d'); this._imageData = this._canvasCtx.createImageData(threadDim[0], threadDim[1]); this._colorData = new Uint8ClampedArray(threadDim[0] * threadDim[1] * 4); } @@ -965,7 +972,8 @@ module.exports = function (_KernelBase) { loopMaxIterations: this.loopMaxIterations, paramNames: this.paramNames, paramTypes: this.paramTypes, - paramSizes: this.paramSizes + paramSizes: this.paramSizes, + constantTypes: this.constantTypes }); builder.addFunctions(this.functions, { @@ -1012,11 +1020,11 @@ module.exports = function (_KernelBase) { } else { kernel = prototypes.shift(); } - var kernelString = this._kernelString = '\n\t\tvar LOOP_MAX = ' + this._getLoopMaxString() + ';\n\t\tvar _this = this;\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) { + var kernelString = this._kernelString = '\n\t\tvar LOOP_MAX = ' + this._getLoopMaxString() + '\n\t\tvar constants = this.constants;\n\t\tvar _this = this;\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) { return ' var ' + name + ' = null;\n'; }).join('')) + '\n return function (' + this.paramNames.map(function (paramName) { return 'user_' + paramName; - }).join(', ') + ') {\n ' + this._processInputs() + '\n var ret = new Array(' + threadDim[2] + ');\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) { + }).join(', ') + ') {\n ' + this._processConstants() + '\n ' + this._processParams() + '\n var ret = new Array(' + threadDim[2] + ');\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) { return ' ' + name + 'Z = new Array(' + threadDim[2] + ');\n'; }).join('')) + '\n for (this.thread.z = 0; this.thread.z < ' + threadDim[2] + '; this.thread.z++) {\n ret[this.thread.z] = new Array(' + threadDim[1] + ');\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) { return ' ' + name + 'Z[this.thread.z] = new Array(' + threadDim[1] + ');\n'; @@ -1052,8 +1060,32 @@ module.exports = function (_KernelBase) { return this.loopMaxIterations ? ' ' + parseInt(this.loopMaxIterations) + ';\n' : ' 1000;\n'; } }, { - key: '_processInputs', - value: function _processInputs() { + key: '_processConstants', + value: function _processConstants() { + if (!this.constants) return ''; + + var result = []; + for (var p in this.constants) { + var type = this.constantTypes[p]; + switch (type) { + case 'HTMLImage': + result.push(' var constants_' + p + ' = this._imageTo2DArray(this.constants.' + p + ')'); + break; + case 'HTMLImageArray': + result.push(' var constants_' + p + ' = this._imageTo3DArray(this.constants.' + p + ')'); + break; + case 'Input': + result.push(' var constants_' + p + ' = this.constants.' + p + '.value'); + break; + default: + result.push(' var constants_' + p + ' = this.constants.' + p); + } + } + return result.join('\n'); + } + }, { + key: '_processParams', + value: function _processParams() { var result = []; for (var i = 0; i < this.paramTypes.length; i++) { switch (this.paramTypes[i]) { @@ -1073,14 +1105,31 @@ module.exports = function (_KernelBase) { }, { key: '_imageTo2DArray', value: function _imageTo2DArray(image) { - this._canvasCtx.drawImage(image, 0, 0, image.width, image.height); - var pixelsData = this._canvasCtx.getImageData(0, 0, image.width, image.height).data; + var canvas = this._canvas; + if (canvas.width < image.width) { + canvas.width = image.width; + } + if (canvas.height < image.height) { + canvas.height = image.height; + } + var ctx = this._canvasCtx; + ctx.drawImage(image, 0, 0, image.width, image.height); + var pixelsData = ctx.getImageData(0, 0, image.width, image.height).data; var imageArray = new Array(image.height); var index = 0; for (var y = image.height - 1; y >= 0; y--) { imageArray[y] = new Array(image.width); for (var x = 0; x < image.width; x++) { - imageArray[y][x] = [pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255]; + var r = pixelsData[index++] / 255; + var g = pixelsData[index++] / 255; + var b = pixelsData[index++] / 255; + var a = pixelsData[index++] / 255; + var result = [r, g, b, a]; + result.r = r; + result.g = g; + result.b = b; + result.a = a; + imageArray[y][x] = result; } } return imageArray; @@ -1386,6 +1435,11 @@ module.exports = function () { if (options.hasOwnProperty('paramTypes')) { this.paramTypes = paramTypes = options.paramTypes; } + if (options.hasOwnProperty('constantTypes')) { + this.constantTypes = options.constantTypes; + } else { + this.constantTypes = {}; + } if (options.hasOwnProperty('returnType')) { returnType = options.returnType; } @@ -1600,6 +1654,14 @@ module.exports = function () { } return null; } + }, { + key: 'getConstantType', + value: function getConstantType(constantName) { + if (this.constantTypes[constantName]) { + return this.constantTypes[constantName]; + } + return null; + } }, { @@ -1904,6 +1966,7 @@ module.exports = function () { this.functionBuilder = null; this.paramTypes = null; this.paramSizes = null; + this.constantTypes = null; this.fixIntegerDivisionAccuracy = null; for (var p in settings) { @@ -1938,6 +2001,16 @@ module.exports = function () { this.paramSizes.push(arg.constructor === Input ? arg.size : null); } } + }, { + key: 'setupConstants', + value: function setupConstants() { + this.constantTypes = {}; + if (this.constants) { + for (var p in this.constants) { + this.constantTypes[p] = utils.getArgumentType(this.constants[p]); + } + } + } }, { key: 'setAddFunction', value: function setAddFunction(cb) { @@ -2274,8 +2347,6 @@ module.exports = function () { },{"../core/utils":32,"./kernel-run-shortcut":9}],11:[function(require,module,exports){ 'use strict'; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } @@ -2283,43 +2354,22 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var FunctionBuilderBase = require('../function-builder-base'); -var WebGLFunctionNode = require('./function-node'); +var WebGL2FunctionNode = require('./function-node'); module.exports = function (_FunctionBuilderBase) { - _inherits(WebGLFunctionBuilder, _FunctionBuilderBase); - - function WebGLFunctionBuilder() { - _classCallCheck(this, WebGLFunctionBuilder); - - var _this = _possibleConstructorReturn(this, (WebGLFunctionBuilder.__proto__ || Object.getPrototypeOf(WebGLFunctionBuilder)).call(this)); - - _this.Node = WebGLFunctionNode; - return _this; - } - - - + _inherits(WebGL2FunctionBuilder, _FunctionBuilderBase); - _createClass(WebGLFunctionBuilder, [{ - key: 'polyfillStandardFunctions', + function WebGL2FunctionBuilder() { + _classCallCheck(this, WebGL2FunctionBuilder); + var _this = _possibleConstructorReturn(this, (WebGL2FunctionBuilder.__proto__ || Object.getPrototypeOf(WebGL2FunctionBuilder)).call(this)); - value: function polyfillStandardFunctions() { - this.addFunction('round', _round); - } - }], [{ - key: 'round', - value: function round(a) { - return _round(a); - } - }]); + _this.Node = WebGL2FunctionNode; + return _this; + } - return WebGLFunctionBuilder; + return WebGL2FunctionBuilder; }(FunctionBuilderBase); - -function _round(a) { - return Math.floor(a + 0.5); -} },{"../function-builder-base":6,"./function-node":12}],12:[function(require,module,exports){ 'use strict'; @@ -2331,33 +2381,30 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var FunctionNodeBase = require('../function-node-base'); -var utils = require('../../core/utils'); -var jsMathPrefix = 'Math.'; -var localPrefix = 'this.'; +var WebGLFunctionNode = require('../web-gl/function-node'); + var constantsPrefix = 'this.constants.'; var DECODE32_ENCODE32 = /decode32\(\s+encode32\(/g; var ENCODE32_DECODE32 = /encode32\(\s+decode32\(/g; -var debugLog = function debugLog() {}; -module.exports = function (_FunctionNodeBase) { - _inherits(WebGLFunctionNode, _FunctionNodeBase); +module.exports = function (_WebGLFunctionNode) { + _inherits(WebGL2FunctionNode, _WebGLFunctionNode); - function WebGLFunctionNode() { - _classCallCheck(this, WebGLFunctionNode); + function WebGL2FunctionNode() { + _classCallCheck(this, WebGL2FunctionNode); - return _possibleConstructorReturn(this, (WebGLFunctionNode.__proto__ || Object.getPrototypeOf(WebGLFunctionNode)).apply(this, arguments)); + return _possibleConstructorReturn(this, (WebGL2FunctionNode.__proto__ || Object.getPrototypeOf(WebGL2FunctionNode)).apply(this, arguments)); } - _createClass(WebGLFunctionNode, [{ + _createClass(WebGL2FunctionNode, [{ key: 'generate', value: function generate() { if (this.debug) { - debugLog(this); + console.log(this); } if (this.prototypeOnly) { - return WebGLFunctionNode.astFunctionPrototype(this.getJsAST(), [], this).join('').trim(); + return WebGL2FunctionNode.astFunctionPrototype(this.getJsAST(), [], this).join('').trim(); } else { this.functionStringArray = this.astGeneric(this.getJsAST(), [], this); } @@ -2366,20 +2413,8 @@ module.exports = function (_FunctionNodeBase) { } - }, { - key: 'astFunctionDeclaration', - value: function astFunctionDeclaration(ast, retArr) { - if (this.addFunction) { - this.addFunction(null, utils.getAstString(this.jsFunctionString, ast)); - } - return retArr; - } - - }, { key: 'astFunctionExpression', - - value: function astFunctionExpression(ast, retArr) { if (this.isRootKernel) { @@ -2404,6 +2439,7 @@ module.exports = function (_FunctionNodeBase) { case 'Texture': case 'Input': case 'Array': + case 'HTMLImage': retArr.push('sampler2D'); break; default: @@ -2428,108 +2464,13 @@ module.exports = function (_FunctionNodeBase) { } - }, { - key: 'astReturnStatement', - value: function astReturnStatement(ast, retArr) { - if (this.isRootKernel) { - retArr.push('kernelResult = '); - this.astGeneric(ast.argument, retArr); - retArr.push(';'); - retArr.push('return;'); - } else if (this.isSubKernel) { - retArr.push(this.functionName + 'Result = '); - this.astGeneric(ast.argument, retArr); - retArr.push(';'); - retArr.push('return ' + this.functionName + 'Result;'); - } else { - retArr.push('return '); - this.astGeneric(ast.argument, retArr); - retArr.push(';'); - } - - - return retArr; - } - - - }, { - key: 'astLiteral', - value: function astLiteral(ast, retArr) { - - if (isNaN(ast.value)) { - throw this.astErrorOutput('Non-numeric literal not supported : ' + ast.value, ast); - } - - retArr.push(ast.value); - - var inGetParams = this.isState('in-get-call-parameters'); - if (Number.isInteger(ast.value)) { - if (!inGetParams) { - retArr.push('.0'); - } - } else if (inGetParams) { - retArr.pop(); - retArr.push('int('); - retArr.push(ast.value); - retArr.push(')'); - } - - return retArr; - } - - - }, { - key: 'astBinaryExpression', - value: function astBinaryExpression(ast, retArr) { - var inGetParams = this.isState('in-get-call-parameters'); - if (inGetParams) { - this.pushState('not-in-get-call-parameters'); - retArr.push('int'); - } - retArr.push('('); - - if (ast.operator === '%') { - retArr.push('mod('); - this.astGeneric(ast.left, retArr); - retArr.push(','); - this.astGeneric(ast.right, retArr); - retArr.push(')'); - } else if (ast.operator === '===') { - this.astGeneric(ast.left, retArr); - retArr.push('=='); - this.astGeneric(ast.right, retArr); - } else if (ast.operator === '!==') { - this.astGeneric(ast.left, retArr); - retArr.push('!='); - this.astGeneric(ast.right, retArr); - } else if (this.fixIntegerDivisionAccuracy && ast.operator === '/') { - retArr.push('div_with_int_check('); - this.astGeneric(ast.left, retArr); - retArr.push(', '); - this.astGeneric(ast.right, retArr); - retArr.push(')'); - } else { - this.astGeneric(ast.left, retArr); - retArr.push(ast.operator); - this.astGeneric(ast.right, retArr); - } - - retArr.push(')'); - - if (inGetParams) { - this.popState('not-in-get-call-parameters'); - } - - return retArr; - } - - }, { key: 'astIdentifierExpression', value: function astIdentifierExpression(idtNode, retArr) { if (idtNode.type !== 'Identifier') { throw this.astErrorOutput('IdentifierExpression - not an Identifier', idtNode); } + var castFloat = !this.isState('in-get-call-parameters'); switch (idtNode.name) { @@ -2558,7 +2499,7 @@ module.exports = function (_FunctionNodeBase) { retArr.push('uOutputDim.z'); break; case 'Infinity': - retArr.push('3.402823466e+38'); + retArr.push('intBitsToFloat(2139095039)'); break; default: if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { @@ -2575,2081 +2516,1901 @@ module.exports = function (_FunctionNodeBase) { return retArr; } + }]); + return WebGL2FunctionNode; +}(WebGLFunctionNode); - }, { - key: 'astForStatement', - value: function astForStatement(forNode, retArr) { - if (forNode.type !== 'ForStatement') { - throw this.astErrorOutput('Invalid for statment', forNode); - } +function webGlRegexOptimize(inStr) { + return inStr.replace(DECODE32_ENCODE32, '((').replace(ENCODE32_DECODE32, '(('); +} +},{"../web-gl/function-node":19}],13:[function(require,module,exports){ +'use strict'; - if (forNode.test && forNode.test.type === 'BinaryExpression') { - if (forNode.test.right.type === 'Identifier' && forNode.test.operator === '<' && this.isIdentifierConstant(forNode.test.right.name) === false) { +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - if (!this.loopMaxIterations) { - console.warn('Warning: loopMaxIterations is not set! Using default of 1000 which may result in unintended behavior.'); - console.warn('Set loopMaxIterations or use a for loop of fixed length to silence this message.'); - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - retArr.push('for ('); - this.astGeneric(forNode.init, retArr); - this.astGeneric(forNode.test.left, retArr); - retArr.push(forNode.test.operator); - retArr.push('LOOP_MAX'); - retArr.push(';'); - this.astGeneric(forNode.update, retArr); - retArr.push(')'); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - retArr.push('{\n'); - retArr.push('if ('); - this.astGeneric(forNode.test.left, retArr); - retArr.push(forNode.test.operator); - this.astGeneric(forNode.test.right, retArr); - retArr.push(') {\n'); - if (forNode.body.type === 'BlockStatement') { - for (var i = 0; i < forNode.body.body.length; i++) { - this.astGeneric(forNode.body.body[i], retArr); - } - } else { - this.astGeneric(forNode.body, retArr); - } - retArr.push('} else {\n'); - retArr.push('break;\n'); - retArr.push('}\n'); - retArr.push('}\n'); +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - return retArr; - } else { - var declarations = JSON.parse(JSON.stringify(forNode.init.declarations)); - var updateArgument = forNode.update.argument; - if (!Array.isArray(declarations) || declarations.length < 1) { - debugLog(this.jsFunctionString); - throw new Error('Error: Incompatible for loop declaration'); - } +var WebGLKernel = require('../web-gl/kernel'); +var utils = require('../../core/utils'); +var Texture = require('../../core/texture'); +var fragShaderString = require('./shader-frag'); +var vertShaderString = require('./shader-vert'); - if (declarations.length > 1) { - var initArgument = null; - for (var _i2 = 0; _i2 < declarations.length; _i2++) { - var declaration = declarations[_i2]; - if (declaration.id.name === updateArgument.name) { - initArgument = declaration; - declarations.splice(_i2, 1); - } else { - retArr.push('float '); - this.astGeneric(declaration, retArr); - retArr.push(';'); - } - } +module.exports = function (_WebGLKernel) { + _inherits(WebGL2Kernel, _WebGLKernel); - retArr.push('for (float '); - this.astGeneric(initArgument, retArr); - retArr.push(';'); - } else { - retArr.push('for ('); - this.astGeneric(forNode.init, retArr); - } + function WebGL2Kernel() { + _classCallCheck(this, WebGL2Kernel); - this.astGeneric(forNode.test, retArr); - retArr.push(';'); - this.astGeneric(forNode.update, retArr); - retArr.push(')'); - this.astGeneric(forNode.body, retArr); - return retArr; - } - } + return _possibleConstructorReturn(this, (WebGL2Kernel.__proto__ || Object.getPrototypeOf(WebGL2Kernel)).apply(this, arguments)); + } - throw this.astErrorOutput('Invalid for statement', forNode); + _createClass(WebGL2Kernel, [{ + key: 'initWebGl', + value: function initWebGl() { + return utils.initWebGl2(this.getCanvas()); } - }, { - key: 'astWhileStatement', - value: function astWhileStatement(whileNode, retArr) { - if (whileNode.type !== 'WhileStatement') { - throw this.astErrorOutput('Invalid while statment', whileNode); + key: 'validateOptions', + value: function validateOptions() { + var isFloatReadPixel = utils.isFloatReadPixelsSupportedWebGL2(); + if (this.floatOutput === true && this.floatOutputForce !== true && !isFloatReadPixel) { + throw new Error('Float texture outputs are not supported on this browser'); + } else if (this.floatTextures === undefined) { + this.floatTextures = true; + this.floatOutput = isFloatReadPixel; } - retArr.push('for (float i = 0.0; i < LOOP_MAX; i++) {'); - retArr.push('if ('); - this.astGeneric(whileNode.test, retArr); - retArr.push(') {\n'); - this.astGeneric(whileNode.body, retArr); - retArr.push('} else {\n'); - retArr.push('break;\n'); - retArr.push('}\n'); - retArr.push('}\n'); + var hasIntegerDivisionBug = utils.hasIntegerDivisionAccuracyBug(); + if (this.fixIntegerDivisionAccuracy === null) { + this.fixIntegerDivisionAccuracy = hasIntegerDivisionBug; + } else if (this.fixIntegerDivisionAccuracy && !hasIntegerDivisionBug) { + this.fixIntegerDivisionAccuracy = false; + } - return retArr; - } + utils.checkOutput(this.output); + if (!this.output || this.output.length === 0) { + if (arguments.length !== 1) { + throw new Error('Auto output only supported for kernels with only one input'); + } - }, { - key: 'astDoWhileStatement', - value: function astDoWhileStatement(doWhileNode, retArr) { - if (doWhileNode.type !== 'DoWhileStatement') { - throw this.astErrorOutput('Invalid while statment', doWhileNode); + var argType = utils.getArgumentType(arguments[0]); + if (argType === 'Array') { + this.output = utils.getDimensions(argType); + } else if (argType === 'Texture') { + this.output = arguments[0].output; + } else { + throw new Error('Auto output not supported for input type: ' + argType); + } } - retArr.push('for (float i = 0.0; i < LOOP_MAX; i++) {'); - this.astGeneric(doWhileNode.body, retArr); - retArr.push('if (!'); - this.astGeneric(doWhileNode.test, retArr); - retArr.push(') {\n'); - retArr.push('break;\n'); - retArr.push('}\n'); - retArr.push('}\n'); + this.texSize = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, this.output, true); - return retArr; - } + if (this.graphical) { + if (this.output.length !== 2) { + throw new Error('Output must have 2 dimensions on graphical mode'); + } + if (this.floatOutput) { + this.floatOutput = false; + console.warn('Cannot use graphical mode and float output at the same time'); + } - }, { - key: 'astAssignmentExpression', - value: function astAssignmentExpression(assNode, retArr) { - if (assNode.operator === '%=') { - this.astGeneric(assNode.left, retArr); - retArr.push('='); - retArr.push('mod('); - this.astGeneric(assNode.left, retArr); - retArr.push(','); - this.astGeneric(assNode.right, retArr); - retArr.push(')'); - } else { - this.astGeneric(assNode.left, retArr); - retArr.push(assNode.operator); - this.astGeneric(assNode.right, retArr); - return retArr; + this.texSize = utils.clone(this.output); + } else if (this.floatOutput === undefined) { + this.floatOutput = true; + } + + if (this.floatOutput || this.floatOutputForce) { + this._webGl.getExtension('EXT_color_buffer_float'); } } }, { - key: 'astEmptyStatement', - value: function astEmptyStatement(eNode, retArr) { - return retArr; - } + key: 'run', + value: function run() { + if (this.program === null) { + this.build.apply(this, arguments); + } + var paramNames = this.paramNames; + var paramTypes = this.paramTypes; + var texSize = this.texSize; + var gl = this._webGl; + gl.useProgram(this.program); + gl.scissor(0, 0, texSize[0], texSize[1]); - }, { - key: 'astBlockStatement', - value: function astBlockStatement(bNode, retArr) { - retArr.push('{\n'); - for (var i = 0; i < bNode.body.length; i++) { - this.astGeneric(bNode.body[i], retArr); + if (!this.hardcodeConstants) { + this.setUniform3iv('uOutputDim', new Int32Array(this.threadDim)); + this.setUniform2iv('uTexSize', texSize); } - retArr.push('}\n'); - return retArr; - } + this.setUniform2f('ratio', texSize[0] / this.maxTexSize[0], texSize[1] / this.maxTexSize[1]); - }, { - key: 'astExpressionStatement', - value: function astExpressionStatement(esNode, retArr) { - this.astGeneric(esNode.expression, retArr); - retArr.push(';\n'); - return retArr; - } + this.argumentsLength = 0; + for (var texIndex = 0; texIndex < paramNames.length; texIndex++) { + this._addArgument(arguments[texIndex], paramTypes[texIndex], paramNames[texIndex]); + } + if (this.graphical) { + gl.bindRenderbuffer(gl.RENDERBUFFER, null); + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + return; + } - }, { - key: 'astVariableDeclaration', - value: function astVariableDeclaration(vardecNode, retArr) { - for (var i = 0; i < vardecNode.declarations.length; i++) { - var declaration = vardecNode.declarations[i]; - if (i > 0) { - retArr.push(','); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer); + if (this.outputImmutable) { + this._setupOutputTexture(); + } + var outputTexture = this.outputTexture; + + if (this.subKernelOutputVariableNames !== null) { + if (this.outputImmutable) { + this.subKernelOutputTextures = []; + this._setupSubOutputTextures(this.subKernelOutputVariableNames.length); } - var retDeclaration = []; - this.astGeneric(declaration, retDeclaration); - if (retDeclaration[2] === 'getImage2D(' || retDeclaration[2] === 'getImage3D(') { - if (i === 0) { - retArr.push('vec4 '); + gl.drawBuffers(this.drawBuffersMap); + } + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + + if (this.subKernelOutputTextures !== null) { + if (this.subKernels !== null) { + var output = []; + output.result = this.renderOutput(outputTexture); + for (var i = 0; i < this.subKernels.length; i++) { + output.push(new Texture(this.subKernelOutputTextures[i], texSize, this.threadDim, this.output, this._webGl)); } - this.declarations[declaration.id.name] = 'vec4'; - } else { - if (i === 0) { - retArr.push('float '); + return output; + } else if (this.subKernelProperties !== null) { + var _output = { + result: this.renderOutput(outputTexture) + }; + var _i = 0; + for (var p in this.subKernelProperties) { + if (!this.subKernelProperties.hasOwnProperty(p)) continue; + _output[p] = new Texture(this.subKernelOutputTextures[_i], texSize, this.threadDim, this.output, this._webGl); + _i++; } - this.declarations[declaration.id.name] = 'float'; + return _output; } - retArr.push.apply(retArr, retDeclaration); } - retArr.push(';'); - return retArr; + + return this.renderOutput(outputTexture); } }, { - key: 'astVariableDeclarator', - value: function astVariableDeclarator(ivardecNode, retArr) { - this.astGeneric(ivardecNode.id, retArr); - if (ivardecNode.init !== null) { - retArr.push('='); - this.astGeneric(ivardecNode.init, retArr); - } - return retArr; + key: 'getOutputTexture', + value: function getOutputTexture() { + return this.outputTexture; } }, { - key: 'astIfStatement', - value: function astIfStatement(ifNode, retArr) { - retArr.push('if ('); - this.astGeneric(ifNode.test, retArr); - retArr.push(')'); - if (ifNode.consequent.type === 'BlockStatement') { - this.astGeneric(ifNode.consequent, retArr); + key: '_setupOutputTexture', + value: function _setupOutputTexture() { + var gl = this._webGl; + var texSize = this.texSize; + var texture = this.outputTexture = this._webGl.createTexture(); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + if (this.floatOutput) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); } else { - retArr.push(' {\n'); - this.astGeneric(ifNode.consequent, retArr); - retArr.push('\n}\n'); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); } + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); + } - if (ifNode.alternate) { - retArr.push('else '); - if (ifNode.alternate.type === 'BlockStatement') { - this.astGeneric(ifNode.alternate, retArr); + + }, { + key: '_setupSubOutputTextures', + value: function _setupSubOutputTextures(length) { + var gl = this._webGl; + var texSize = this.texSize; + var drawBuffersMap = this.drawBuffersMap = [gl.COLOR_ATTACHMENT0]; + var textures = this.subKernelOutputTextures = []; + for (var i = 0; i < length; i++) { + var texture = this._webGl.createTexture(); + textures.push(texture); + drawBuffersMap.push(gl.COLOR_ATTACHMENT0 + i + 1); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length + i); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + if (this.floatOutput) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); } else { - retArr.push(' {\n'); - this.astGeneric(ifNode.alternate, retArr); - retArr.push('\n}\n'); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); } + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i + 1, gl.TEXTURE_2D, texture, 0); } - return retArr; } }, { - key: 'astBreakStatement', - value: function astBreakStatement(brNode, retArr) { - retArr.push('break;\n'); - return retArr; - } + key: '_addArgument', + value: function _addArgument(value, type, name) { + var gl = this._webGl; + var argumentTexture = this.getArgumentTexture(name); + if (value instanceof Texture) { + type = 'Texture'; + } + switch (type) { + case 'Array': + { + var dim = utils.getDimensions(value, true); + var size = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, dim); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + var length = size[0] * size[1]; - }, { - key: 'astContinueStatement', - value: function astContinueStatement(crNode, retArr) { - retArr.push('continue;\n'); - return retArr; - } + var _formatArrayTransfer = this._formatArrayTransfer(value, length), + valuesFlat = _formatArrayTransfer.valuesFlat, + bitRatio = _formatArrayTransfer.bitRatio; + var buffer = void 0; + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); + } else { + buffer = new Uint8Array(valuesFlat.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + } - }, { - key: 'astLogicalExpression', - value: function astLogicalExpression(logNode, retArr) { - retArr.push('('); - this.astGeneric(logNode.left, retArr); - retArr.push(logNode.operator); - this.astGeneric(logNode.right, retArr); - retArr.push(')'); - return retArr; - } + if (!this.hardcodeConstants) { + this.setUniform3iv('user_' + name + 'Dim', dim); + this.setUniform2iv('user_' + name + 'Size', size); + } + this.setUniform1i('user_' + name + 'BitRatio', bitRatio); + this.setUniform1i('user_' + name, this.argumentsLength); + break; + } + case 'Integer': + case 'Float': + { + this.setUniform1f('user_' + name, value); + break; + } + case 'Input': + { + var input = value; + var _dim = input.size; + var _size = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, _dim); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + var _length = _size[0] * _size[1]; - }, { - key: 'astUpdateExpression', - value: function astUpdateExpression(uNode, retArr) { - if (uNode.prefix) { - retArr.push(uNode.operator); - this.astGeneric(uNode.argument, retArr); - } else { - this.astGeneric(uNode.argument, retArr); - retArr.push(uNode.operator); - } + var _formatArrayTransfer2 = this._formatArrayTransfer(value.value, _length), + _valuesFlat = _formatArrayTransfer2.valuesFlat, + _bitRatio = _formatArrayTransfer2.bitRatio; - return retArr; - } + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, _size[0], _size[1], 0, gl.RGBA, gl.FLOAT, inputArray); + } else { + var _buffer = new Uint8Array(_valuesFlat.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size[0] / _bitRatio, _size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, _buffer); + } + if (!this.hardcodeConstants) { + this.setUniform3iv('user_' + name + 'Dim', _dim); + this.setUniform2iv('user_' + name + 'Size', _size); + } + this.setUniform1i('user_' + name + 'BitRatio', _bitRatio); + this.setUniform1i('user_' + name, this.argumentsLength); + break; + } + case 'HTMLImage': + { + var inputImage = value; + var _dim2 = [inputImage.width, inputImage.height, 1]; + var _size2 = [inputImage.width, inputImage.height]; - }, { - key: 'astUnaryExpression', - value: function astUnaryExpression(uNode, retArr) { - if (uNode.prefix) { - retArr.push(uNode.operator); - this.astGeneric(uNode.argument, retArr); - } else { - this.astGeneric(uNode.argument, retArr); - retArr.push(uNode.operator); - } + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + var mipLevel = 0; + var internalFormat = gl.RGBA; + var srcFormat = gl.RGBA; + var srcType = gl.UNSIGNED_BYTE; + gl.texImage2D(gl.TEXTURE_2D, mipLevel, internalFormat, srcFormat, srcType, inputImage); + this.setUniform3iv('user_' + name + 'Dim', _dim2); + this.setUniform2iv('user_' + name + 'Size', _size2); + this.setUniform1i('user_' + name, this.argumentsLength); + break; + } + case 'HTMLImageArray': + { + var inputImages = value; + var _dim3 = [inputImages[0].width, inputImages[0].height, inputImages.length]; + var _size3 = [inputImages[0].width, inputImages[0].height]; - return retArr; - } + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); + gl.bindTexture(gl.TEXTURE_2D_ARRAY, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + var _mipLevel = 0; + var _internalFormat = gl.RGBA; + var width = inputImages[0].width; + var height = inputImages[0].height; + var textureDepth = inputImages.length; + var border = 0; + var _srcFormat = gl.RGBA; + var _srcType = gl.UNSIGNED_BYTE; + gl.texImage3D(gl.TEXTURE_2D_ARRAY, _mipLevel, _internalFormat, width, height, textureDepth, border, _srcFormat, _srcType, null); + for (var i = 0; i < inputImages.length; i++) { + var xOffset = 0; + var yOffset = 0; + var imageDepth = 1; + gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, _mipLevel, xOffset, yOffset, i, inputImages[i].width, inputImages[i].height, imageDepth, _srcFormat, _srcType, inputImages[i]); + } + this.setUniform3iv('user_' + name + 'Dim', _dim3); + this.setUniform2iv('user_' + name + 'Size', _size3); + this.setUniform1i('user_' + name, this.argumentsLength); + break; + } + case 'Texture': + { + var inputTexture = value; + var _dim4 = inputTexture.dimensions; + var _size4 = inputTexture.size; + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); + gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); - }, { - key: 'astThisExpression', - value: function astThisExpression(tNode, retArr) { - retArr.push('this'); - return retArr; + this.setUniform3iv('user_' + name + 'Dim', _dim4); + this.setUniform2iv('user_' + name + 'Size', _size4); + this.setUniform1i('user_' + name + 'BitRatio', 1); + this.setUniform1i('user_' + name, this.argumentsLength); + break; + } + default: + throw new Error('Input type not supported (WebGL): ' + value); + } + this.argumentsLength++; } }, { - key: 'astMemberExpression', - value: function astMemberExpression(mNode, retArr) { - debugLog("[in] astMemberExpression " + mNode.object.type); - if (mNode.computed) { - if (mNode.object.type === 'Identifier') { - var reqName = mNode.object.name; - var funcName = this.functionName || 'kernel'; - var assumeNotTexture = false; - - if (this.paramNames) { - var idx = this.paramNames.indexOf(reqName); - if (idx >= 0 && this.paramTypes[idx] === 'float') { - assumeNotTexture = true; - } - } - debugLog("- astMemberExpression " + reqName + " " + funcName); - if (assumeNotTexture) { - this.astGeneric(mNode.object, retArr); - retArr.push('[int('); - this.astGeneric(mNode.property, retArr); - retArr.push(')]'); - } else { - var isInGetParams = this.isState('in-get-call-parameters'); - var multiMemberExpression = this.isState('multi-member-expression'); - if (multiMemberExpression) { - this.popState('multi-member-expression'); - } - this.pushState('not-in-get-call-parameters'); - - switch (this.getParamType(mNode.object.name)) { - case 'vec4': - this.astGeneric(mNode.object, retArr); - retArr.push('['); - retArr.push(mNode.property.raw); - retArr.push(']'); - if (multiMemberExpression) { - this.popState('not-in-get-call-parameters'); - } - break; - case 'HTMLImageArray': - retArr.push('getImage3D('); - this.astGeneric(mNode.object, retArr); - retArr.push(', ivec2('); - this.astGeneric(mNode.object, retArr); - retArr.push('Size[0],'); - this.astGeneric(mNode.object, retArr); - retArr.push('Size[1]), ivec3('); - this.astGeneric(mNode.object, retArr); - retArr.push('Dim[0],'); - this.astGeneric(mNode.object, retArr); - retArr.push('Dim[1],'); - this.astGeneric(mNode.object, retArr); - retArr.push('Dim[2]'); - retArr.push('), '); - this.popState('not-in-get-call-parameters'); - this.pushState('in-get-call-parameters'); - this.astGeneric(mNode.property, retArr); - if (!multiMemberExpression) { - this.popState('in-get-call-parameters'); - } - retArr.push(')'); - break; - case 'HTMLImage': - retArr.push('getImage2D('); - this.astGeneric(mNode.object, retArr); - retArr.push(', ivec2('); - this.astGeneric(mNode.object, retArr); - retArr.push('Size[0],'); - this.astGeneric(mNode.object, retArr); - retArr.push('Size[1]), ivec3('); - this.astGeneric(mNode.object, retArr); - retArr.push('Dim[0],'); - this.astGeneric(mNode.object, retArr); - retArr.push('Dim[1],'); - this.astGeneric(mNode.object, retArr); - retArr.push('Dim[2]'); - retArr.push('), '); - this.popState('not-in-get-call-parameters'); - this.pushState('in-get-call-parameters'); - this.astGeneric(mNode.property, retArr); - if (!multiMemberExpression) { - this.popState('in-get-call-parameters'); - } - retArr.push(')'); - break; - default: - if (isInGetParams) { - retArr.push('int('); - } - retArr.push('get('); - this.astGeneric(mNode.object, retArr); - retArr.push(', ivec2('); - this.astGeneric(mNode.object, retArr); - retArr.push('Size[0],'); - this.astGeneric(mNode.object, retArr); - retArr.push('Size[1]), ivec3('); - this.astGeneric(mNode.object, retArr); - retArr.push('Dim[0],'); - this.astGeneric(mNode.object, retArr); - retArr.push('Dim[1],'); - this.astGeneric(mNode.object, retArr); - retArr.push('Dim[2]'); - retArr.push('), '); - this.astGeneric(mNode.object, retArr); - retArr.push('BitRatio'); - retArr.push(', '); - this.popState('not-in-get-call-parameters'); - this.pushState('in-get-call-parameters'); - this.astGeneric(mNode.property, retArr); - if (!multiMemberExpression) { - this.popState('in-get-call-parameters'); - } - retArr.push(')'); - if (isInGetParams) { - retArr.push(')'); - } - break; - } - } - } else { - - debugLog("- astMemberExpression obj:", mNode.object); - var stateStackDepth = this.states.length; - var startedInGetParamsState = this.isState('in-get-call-parameters'); - if (!startedInGetParamsState) { - this.pushState('multi-member-expression'); - } - this.astGeneric(mNode.object, retArr); - if (this.isState('multi-member-expression')) { - this.popState('multi-member-expression'); - } - var changedGetParamsState = !startedInGetParamsState && this.isState('in-get-call-parameters'); - var last = retArr.pop(); - retArr.push(','); - debugLog("- astMemberExpression prop:", mNode.property); - var shouldPopParamState = this.isState('should-pop-in-get-call-parameters'); - if (shouldPopParamState) { - this.popState('should-pop-in-get-call-parameters'); - } - this.astGeneric(mNode.property, retArr); - retArr.push(last); - - if (changedGetParamsState) { - this.pushState('should-pop-in-get-call-parameters'); - } else if (shouldPopParamState) { - this.popState('in-get-call-parameters'); - } - } - } else { - - var unrolled = this.astMemberExpressionUnroll(mNode); - var unrolled_lc = unrolled.toLowerCase(); - debugLog("- astMemberExpression unrolled:", unrolled); - if (unrolled.indexOf(constantsPrefix) === 0) { - unrolled = 'constants_' + unrolled.slice(constantsPrefix.length); - } - - var castFloat = !this.isState('in-get-call-parameters'); - - switch (unrolled_lc) { - case 'this.thread.x': - castFloat && retArr.push('float('); - retArr.push('threadId.x'); - castFloat && retArr.push(')'); - break; - case 'this.thread.y': - castFloat && retArr.push('float('); - retArr.push('threadId.y'); - castFloat && retArr.push(')'); - break; - case 'this.thread.z': - castFloat && retArr.push('float('); - retArr.push('threadId.z'); - castFloat && retArr.push(')'); - break; - case 'this.output.x': - retArr.push(this.output[0] + '.0'); - break; - case 'this.output.y': - retArr.push(this.output[1] + '.0'); - break; - case 'this.output.z': - retArr.push(this.output[2] + '.0'); - break; - default: - retArr.push(unrolled); - } - } - debugLog("[out] astMemberExpression " + mNode.object.type); - return retArr; - } - }, { - key: 'astSequenceExpression', - value: function astSequenceExpression(sNode, retArr) { - for (var i = 0; i < sNode.expressions.length; i++) { - if (i > 0) { - retArr.push(','); - } - this.astGeneric(sNode.expressions, retArr); - } - return retArr; - } - - - }, { - key: 'astCallExpression', - value: function astCallExpression(ast, retArr) { - if (ast.callee) { - var funcName = this.astMemberExpressionUnroll(ast.callee); - - if (funcName.indexOf(jsMathPrefix) === 0) { - funcName = funcName.slice(jsMathPrefix.length); - } - - if (funcName.indexOf(localPrefix) === 0) { - funcName = funcName.slice(localPrefix.length); - } - - if (funcName === 'atan2') { - funcName = 'atan'; - } - - if (this.calledFunctions.indexOf(funcName) < 0) { - this.calledFunctions.push(funcName); - } - if (!this.hasOwnProperty('funcName')) { - this.calledFunctionsArguments[funcName] = []; - } - - var functionArguments = []; - this.calledFunctionsArguments[funcName].push(functionArguments); - - retArr.push(funcName); - - retArr.push('('); - - for (var i = 0; i < ast.arguments.length; ++i) { - var argument = ast.arguments[i]; - if (i > 0) { - retArr.push(', '); - } - this.astGeneric(argument, retArr); - if (argument.type === 'Identifier') { - var paramIndex = this.paramNames.indexOf(argument.name); - if (paramIndex === -1) { - functionArguments.push(null); - } else { - functionArguments.push({ - name: argument.name, - type: this.paramTypes[paramIndex] - }); - } - } else { - functionArguments.push(null); - } - } - - retArr.push(')'); - - return retArr; - } - - throw this.astErrorOutput('Unknown CallExpression', ast); - - return retArr; - } - - - }, { - key: 'astArrayExpression', - value: function astArrayExpression(arrNode, retArr) { - var arrLen = arrNode.elements.length; - - retArr.push('float[' + arrLen + ']('); - for (var i = 0; i < arrLen; ++i) { - if (i > 0) { - retArr.push(', '); - } - var subNode = arrNode.elements[i]; - this.astGeneric(subNode, retArr); - } - retArr.push(')'); - - return retArr; - - } - - - }, { - key: 'getFunctionPrototypeString', - value: function getFunctionPrototypeString() { - if (this.webGlFunctionPrototypeString) { - return this.webGlFunctionPrototypeString; - } - return this.webGlFunctionPrototypeString = this.generate(); - } - }, { - key: 'build', - value: function build() { - return this.getFunctionPrototypeString().length > 0; - } - }], [{ - key: 'astFunctionPrototype', - value: function astFunctionPrototype(ast, retArr) { - if (this.isRootKernel || this.isSubKernel) { - return retArr; - } - - retArr.push(this.returnType); - retArr.push(' '); - retArr.push(this.functionName); - retArr.push('('); - - for (var i = 0; i < this.paramNames.length; ++i) { - if (i > 0) { - retArr.push(', '); - } - - retArr.push(this.paramTypes[i]); - retArr.push(' '); - retArr.push('user_'); - retArr.push(this.paramNames[i]); - } - - retArr.push(');\n'); - - return retArr; - } - }]); - - return WebGLFunctionNode; -}(FunctionNodeBase); - -function isIdentifierKernelParam(paramName, ast, funcParam) { - return funcParam.paramNames.indexOf(paramName) !== -1; -} - -function ensureIndentifierType(paramName, expectedType, ast, funcParam) { - var start = ast.loc.start; - - if (!isIdentifierKernelParam(paramName) && expectedType !== 'float') { - throw new Error('Error unexpected identifier ' + paramName + ' on line ' + start.line); - } else { - var actualType = funcParam.paramTypes[funcParam.paramNames.indexOf(paramName)]; - if (actualType !== expectedType) { - throw new Error('Error unexpected identifier ' + paramName + ' on line ' + start.line); - } - } -} - -function webGlRegexOptimize(inStr) { - return inStr.replace(DECODE32_ENCODE32, '((').replace(ENCODE32_DECODE32, '(('); -} -},{"../../core/utils":32,"../function-node-base":7}],13:[function(require,module,exports){ -'use strict'; - -var utils = require('../../core/utils'); -var kernelRunShortcut = require('../kernel-run-shortcut'); - -function removeFnNoise(fn) { - if (/^function /.test(fn)) { - fn = fn.substring(9); - } - return fn.replace(/[_]typeof/g, 'typeof'); -} - -function removeNoise(str) { - return str.replace(/[_]typeof/g, 'typeof'); -} - -module.exports = function (gpuKernel, name) { - return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform2ivCache = {};\n\t\t this.uniform3fvCache = {};\n\t\t this.uniform3ivCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2iv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n\t\t ' + removeFnNoise(gpuKernel.setUniform3iv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; -}; -},{"../../core/utils":32,"../kernel-run-shortcut":9}],14:[function(require,module,exports){ -'use strict'; - -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var KernelBase = require('../kernel-base'); -var utils = require('../../core/utils'); -var Texture = require('../../core/texture'); -var fragShaderString = require('./shader-frag'); -var vertShaderString = require('./shader-vert'); -var kernelString = require('./kernel-string'); -var canvases = []; -var maxTexSizes = {}; - -module.exports = function (_KernelBase) { - _inherits(WebGLKernel, _KernelBase); - - _createClass(WebGLKernel, null, [{ - key: 'fragShaderString', - get: function get() { - return fragShaderString; - } - }, { - key: 'vertShaderString', - get: function get() { - return vertShaderString; - } - - }]); - - function WebGLKernel(fnString, settings) { - _classCallCheck(this, WebGLKernel); - - var _this = _possibleConstructorReturn(this, (WebGLKernel.__proto__ || Object.getPrototypeOf(WebGLKernel)).call(this, fnString, settings)); - - _this.textureCache = {}; - _this.threadDim = {}; - _this.programUniformLocationCache = {}; - _this.framebuffer = null; - - _this.buffer = null; - _this.program = null; - _this.outputToTexture = settings.outputToTexture; - _this.endianness = utils.systemEndianness(); - _this.subKernelOutputTextures = null; - _this.subKernelOutputVariableNames = null; - _this.argumentsLength = 0; - _this.compiledFragShaderString = null; - _this.compiledVertShaderString = null; - _this.fragShader = null; - _this.vertShader = null; - _this.drawBuffersMap = null; - _this.outputTexture = null; - _this.maxTexSize = null; - _this.uniform1fCache = {}; - _this.uniform1iCache = {}; - _this.uniform2fCache = {}; - _this.uniform2fvCache = {}; - _this.uniform2ivCache = {}; - _this.uniform3fvCache = {}; - _this.uniform3ivCache = {}; - if (!_this._webGl) _this._webGl = _this.initWebGl(); - return _this; - } - - _createClass(WebGLKernel, [{ - key: 'initWebGl', - value: function initWebGl() { - return utils.initWebGl(this.getCanvas()); - } - - - }, { - key: 'validateOptions', - value: function validateOptions() { - var isFloatReadPixel = utils.isFloatReadPixelsSupported(); - if (this.floatTextures === true && !utils.OES_texture_float) { - throw new Error('Float textures are not supported on this browser'); - } else if (this.floatOutput === true && this.floatOutputForce !== true && !isFloatReadPixel) { - throw new Error('Float texture outputs are not supported on this browser'); - } else if (this.floatTextures === undefined && utils.OES_texture_float) { - this.floatTextures = true; - this.floatOutput = isFloatReadPixel; - } - - var hasIntegerDivisionBug = utils.hasIntegerDivisionAccuracyBug(); - if (this.fixIntegerDivisionAccuracy == null) { - this.fixIntegerDivisionAccuracy = hasIntegerDivisionBug; - } else if (this.fixIntegerDivisionAccuracy && !hasIntegerDivisionBug) { - this.fixIntegerDivisionAccuracy = false; - } - - utils.checkOutput(this.output); - - if (!this.output || this.output.length === 0) { - if (arguments.length !== 1) { - throw new Error('Auto output only supported for kernels with only one input'); - } - - var argType = utils.getArgumentType(arguments[0]); - if (argType === 'Array') { - this.output = utils.getDimensions(argType); - } else if (argType === 'Texture') { - this.output = arguments[0].output; - } else { - throw new Error('Auto output not supported for input type: ' + argType); - } - } - - this.texSize = utils.dimToTexSize({ - floatTextures: this.floatTextures, - floatOutput: this.floatOutput - }, this.output, true); - - if (this.graphical) { - if (this.output.length !== 2) { - throw new Error('Output must have 2 dimensions on graphical mode'); - } - - if (this.floatOutput) { - this.floatOutput = false; - console.warn('Cannot use graphical mode and float output at the same time'); - } + key: '_getMainConstantsString', + value: function _getMainConstantsString() { + var result = []; + if (this.constants) { + for (var name in this.constants) { + if (!this.constants.hasOwnProperty(name)) continue; + var value = this.constants[name]; + var type = utils.getArgumentType(value); + switch (type) { + case 'Integer': + result.push('const float constants_' + name + ' = ' + parseInt(value) + '.0'); + break; + case 'Float': + result.push('const float constants_' + name + ' = ' + parseFloat(value)); + break; + case 'Array': + case 'Input': + case 'HTMLImage': + case 'Texture': + result.push('uniform highp sampler2D constants_' + name, 'uniform highp ivec2 constants_' + name + 'Size', 'uniform highp ivec3 constants_' + name + 'Dim', 'uniform highp int constants_' + name + 'BitRatio'); + break; + case 'HTMLImageArray': + result.push('uniform highp sampler2DArray constants_' + name, 'uniform highp ivec2 constants_' + name + 'Size', 'uniform highp ivec3 constants_' + name + 'Dim', 'uniform highp int constants_' + name + 'BitRatio'); + break; - this.texSize = utils.clone(this.output); - } else if (this.floatOutput === undefined && utils.OES_texture_float) { - this.floatOutput = true; - } - } - }, { - key: 'updateMaxTexSize', - value: function updateMaxTexSize() { - var texSize = this.texSize; - var canvas = this._canvas; - if (this.maxTexSize === null) { - var canvasIndex = canvases.indexOf(canvas); - if (canvasIndex === -1) { - canvasIndex = canvases.length; - canvases.push(canvas); - maxTexSizes[canvasIndex] = [texSize[0], texSize[1]]; + default: + throw new Error('Unsupported constant ' + name + ' type ' + type); + } } - this.maxTexSize = maxTexSizes[canvasIndex]; - } - if (this.maxTexSize[0] < texSize[0]) { - this.maxTexSize[0] = texSize[0]; - } - if (this.maxTexSize[1] < texSize[1]) { - this.maxTexSize[1] = texSize[1]; } + return this._linesToString(result); } }, { - key: 'build', - value: function build() { - this.validateOptions(); - this.setupParams(arguments); - this.updateMaxTexSize(); - var texSize = this.texSize; + key: '_addConstant', + value: function _addConstant(value, type, name) { var gl = this._webGl; - var canvas = this._canvas; - gl.enable(gl.SCISSOR_TEST); - gl.viewport(0, 0, this.maxTexSize[0], this.maxTexSize[1]); - canvas.width = this.maxTexSize[0]; - canvas.height = this.maxTexSize[1]; - var threadDim = this.threadDim = utils.clone(this.output); - while (threadDim.length < 3) { - threadDim.push(1); - } - - if (this.functionBuilder) this._addKernels(); - - var compiledVertShaderString = this._getVertShaderString(arguments); - var vertShader = gl.createShader(gl.VERTEX_SHADER); - gl.shaderSource(vertShader, compiledVertShaderString); - gl.compileShader(vertShader); - if (this.vertShader) {} - this.vertShader = vertShader; - - var compiledFragShaderString = this._getFragShaderString(arguments); - var fragShader = gl.createShader(gl.FRAGMENT_SHADER); - gl.shaderSource(fragShader, compiledFragShaderString); - gl.compileShader(fragShader); - this.fragShader = fragShader; - - if (!gl.getShaderParameter(vertShader, gl.COMPILE_STATUS)) { - console.log(compiledVertShaderString); - console.error('An error occurred compiling the shaders: ' + gl.getShaderInfoLog(vertShader)); - throw new Error('Error compiling vertex shader'); - } - if (!gl.getShaderParameter(fragShader, gl.COMPILE_STATUS)) { - console.log(compiledFragShaderString); - console.error('An error occurred compiling the shaders: ' + gl.getShaderInfoLog(fragShader)); - throw new Error('Error compiling fragment shader'); - } - - if (this.debug) { - console.log('Options:'); - console.dir(this); - console.log('GLSL Shader Output:'); - console.log(compiledFragShaderString); - } - - var program = this.program = gl.createProgram(); - gl.attachShader(program, vertShader); - gl.attachShader(program, fragShader); - gl.linkProgram(program); - this.framebuffer = gl.createFramebuffer(); - this.framebuffer.width = texSize[0]; - this.framebuffer.height = texSize[1]; - - var vertices = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]); - var texCoords = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]); - - var texCoordOffset = vertices.byteLength; - - var buffer = this.buffer; - if (!buffer) { - buffer = this.buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, vertices.byteLength + texCoords.byteLength, gl.STATIC_DRAW); - } else { - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - } - - gl.bufferSubData(gl.ARRAY_BUFFER, 0, vertices); - gl.bufferSubData(gl.ARRAY_BUFFER, texCoordOffset, texCoords); - - var aPosLoc = gl.getAttribLocation(this.program, 'aPos'); - gl.enableVertexAttribArray(aPosLoc); - gl.vertexAttribPointer(aPosLoc, 2, gl.FLOAT, gl.FALSE, 0, 0); - var aTexCoordLoc = gl.getAttribLocation(this.program, 'aTexCoord'); - gl.enableVertexAttribArray(aTexCoordLoc); - gl.vertexAttribPointer(aTexCoordLoc, 2, gl.FLOAT, gl.FALSE, 0, texCoordOffset); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer); - - if (!this.outputImmutable) { - this._setupOutputTexture(); - if (this.subKernelOutputVariableNames !== null && this.subKernelOutputVariableNames.length > 0) { - this._setupSubOutputTextures(this.subKernelOutputVariableNames.length); - } + var argumentTexture = this.getArgumentTexture(name); + if (value instanceof Texture) { + type = 'Texture'; } - } - + switch (type) { + case 'Array': + { + var dim = utils.getDimensions(value, true); + var size = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, dim); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - }, { - key: 'run', - value: function run() { - if (this.program === null) { - this.build.apply(this, arguments); - } - var paramNames = this.paramNames; - var paramTypes = this.paramTypes; - var texSize = this.texSize; - var gl = this._webGl; + var length = size[0] * size[1]; - gl.useProgram(this.program); - gl.scissor(0, 0, texSize[0], texSize[1]); + var _formatArrayTransfer3 = this._formatArrayTransfer(value, length), + valuesFlat = _formatArrayTransfer3.valuesFlat, + bitRatio = _formatArrayTransfer3.bitRatio; - if (!this.hardcodeConstants) { - this.setUniform3iv('uOutputDim', this.threadDim); - this.setUniform2iv('uTexSize', texSize); - } + var buffer = void 0; + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); + } else { + buffer = new Uint8Array(valuesFlat.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + } - this.setUniform2f('ratio', texSize[0] / this.maxTexSize[0], texSize[1] / this.maxTexSize[1]); + if (!this.hardcodeConstants) { + this.setUniform3iv('constants_' + name + 'Dim', dim); + this.setUniform2iv('constants_' + name + 'Size', size); + } + this.setUniform1i('constants_' + name + 'BitRatio', bitRatio); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'Integer': + case 'Float': + { + this.setUniform1f('constants_' + name, value); + break; + } + case 'Input': + { + var input = value; + var _dim5 = input.size; + var _size5 = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, _dim5); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - this.argumentsLength = 0; - for (var texIndex = 0; texIndex < paramNames.length; texIndex++) { - this._addArgument(arguments[texIndex], paramTypes[texIndex], paramNames[texIndex]); - } + var _length2 = _size5[0] * _size5[1]; - if (this.graphical) { - gl.bindRenderbuffer(gl.RENDERBUFFER, null); - gl.bindFramebuffer(gl.FRAMEBUFFER, null); - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - return; - } + var _formatArrayTransfer4 = this._formatArrayTransfer(value.value, _length2), + _valuesFlat2 = _formatArrayTransfer4.valuesFlat, + _bitRatio2 = _formatArrayTransfer4.bitRatio; - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer); - if (this.outputImmutable) { - this._setupOutputTexture(); - } - var outputTexture = this.outputTexture; + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, _size5[0], _size5[1], 0, gl.RGBA, gl.FLOAT, inputArray); + } else { + var _buffer2 = new Uint8Array(_valuesFlat2.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size5[0] / _bitRatio2, _size5[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, _buffer2); + } - if (this.subKernelOutputVariableNames !== null) { - if (this.outputImmutable) { - this.subKernelOutputTextures = []; - this._setupSubOutputTextures(this.subKernelOutputVariableNames.length); - } - this.drawBuffers.drawBuffersWEBGL(this.drawBuffersMap); - } + if (!this.hardcodeConstants) { + this.setUniform3iv('constants_' + name + 'Dim', _dim5); + this.setUniform2iv('constants_' + name + 'Size', _size5); + } + this.setUniform1i('constants_' + name + 'BitRatio', _bitRatio2); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'HTMLImage': + { + var inputImage = value; + var _dim6 = [inputImage.width, inputImage.height, 1]; + var _size6 = [inputImage.width, inputImage.height]; - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + var mipLevel = 0; + var internalFormat = gl.RGBA; + var srcFormat = gl.RGBA; + var srcType = gl.UNSIGNED_BYTE; + gl.texImage2D(gl.TEXTURE_2D, mipLevel, internalFormat, srcFormat, srcType, inputImage); + this.setUniform3iv('constants_' + name + 'Dim', _dim6); + this.setUniform2iv('constants_' + name + 'Size', _size6); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'HTMLImageArray': + { + var inputImages = value; + var _dim7 = [inputImages[0].width, inputImages[0].height, inputImages.length]; + var _size7 = [inputImages[0].width, inputImages[0].height]; - if (this.subKernelOutputTextures !== null) { - if (this.subKernels !== null) { - var output = []; - output.result = this.renderOutput(outputTexture); - for (var i = 0; i < this.subKernels.length; i++) { - output.push(new Texture(this.subKernelOutputTextures[i], texSize, this.threadDim, this.output, this._webGl)); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D_ARRAY, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + var _mipLevel2 = 0; + var _internalFormat2 = gl.RGBA; + var width = inputImages[0].width; + var height = inputImages[0].height; + var textureDepth = inputImages.length; + var border = 0; + var _srcFormat2 = gl.RGBA; + var _srcType2 = gl.UNSIGNED_BYTE; + gl.texImage3D(gl.TEXTURE_2D_ARRAY, _mipLevel2, _internalFormat2, width, height, textureDepth, border, _srcFormat2, _srcType2, null); + for (var i = 0; i < inputImages.length; i++) { + var xOffset = 0; + var yOffset = 0; + var imageDepth = 1; + gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, _mipLevel2, xOffset, yOffset, i, inputImages[i].width, inputImages[i].height, imageDepth, _srcFormat2, _srcType2, inputImages[i]); + } + this.setUniform3iv('constants_' + name + 'Dim', _dim7); + this.setUniform2iv('constants_' + name + 'Size', _size7); + this.setUniform1i('constants_' + name, this.constantsLength); + break; } - return output; - } else if (this.subKernelProperties !== null) { - var _output = { - result: this.renderOutput(outputTexture) - }; - var _i = 0; - for (var p in this.subKernelProperties) { - if (!this.subKernelProperties.hasOwnProperty(p)) continue; - _output[p] = new Texture(this.subKernelOutputTextures[_i], texSize, this.threadDim, this.output, this._webGl); - _i++; + case 'Texture': + { + var inputTexture = value; + var _dim8 = inputTexture.dimensions; + var _size8 = inputTexture.size; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); + + this.setUniform3iv('constants_' + name + 'Dim', _dim8); + this.setUniform2iv('constants_' + name + 'Size', _size8); + this.setUniform1i('constants_' + name + 'BitRatio', 1); + this.setUniform1i('constants_' + name, this.constantsLength); + break; } - return _output; - } + default: + throw new Error('Input type not supported (WebGL): ' + value); } - - return this.renderOutput(outputTexture); } }, { - key: 'renderOutput', - value: function renderOutput(outputTexture) { - var texSize = this.texSize; - var gl = this._webGl; - var threadDim = this.threadDim; - var output = this.output; - if (this.outputToTexture) { - return new Texture(outputTexture, texSize, this.threadDim, output, this._webGl); - } else { - var result = void 0; - if (this.floatOutput) { - var w = texSize[0]; - var h = Math.ceil(texSize[1] / 4); - result = new Float32Array(w * h * 4); - gl.readPixels(0, 0, w, h, gl.RGBA, gl.FLOAT, result); - } else { - var bytes = new Uint8Array(texSize[0] * texSize[1] * 4); - gl.readPixels(0, 0, texSize[0], texSize[1], gl.RGBA, gl.UNSIGNED_BYTE, bytes); - result = new Float32Array(bytes.buffer); - } - - result = result.subarray(0, threadDim[0] * threadDim[1] * threadDim[2]); - - if (output.length === 1) { - return result; - } else if (output.length === 2) { - return utils.splitArray(result, output[0]); - } else if (output.length === 3) { - var cube = utils.splitArray(result, output[0] * output[1]); - return cube.map(function (x) { - return utils.splitArray(x, output[0]); - }); - } + key: '_getGetResultString', + value: function _getGetResultString() { + if (!this.floatTextures) { + return ' return decode(texel, x, bitRatio);'; } + return ' return texel[channel];'; } }, { - key: 'getOutputTexture', - value: function getOutputTexture() { - return this.outputTexture; + key: '_getHeaderString', + value: function _getHeaderString() { + return ''; } }, { - key: '_setupOutputTexture', - value: function _setupOutputTexture() { - var gl = this._webGl; - var texSize = this.texSize; - var texture = this.outputTexture = this._webGl.createTexture(); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - if (this.floatOutput) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); + key: '_getTextureCoordinate', + value: function _getTextureCoordinate() { + var names = this.subKernelOutputVariableNames; + if (names === null || names.length < 1) { + return 'in highp vec2 vTexCoord;\n'; } else { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + return 'out highp vec2 vTexCoord;\n'; } - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); } }, { - key: '_setupSubOutputTextures', - value: function _setupSubOutputTextures(length) { - var gl = this._webGl; - var texSize = this.texSize; - var drawBuffersMap = this.drawBuffersMap = [gl.COLOR_ATTACHMENT0]; - var textures = this.subKernelOutputTextures = []; - for (var i = 0; i < length; i++) { - var texture = this._webGl.createTexture(); - textures.push(texture); - drawBuffersMap.push(gl.COLOR_ATTACHMENT0 + i + 1); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length + i); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - if (this.floatOutput) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); + key: '_getMainParamsString', + value: function _getMainParamsString(args) { + var result = []; + var paramTypes = this.paramTypes; + var paramNames = this.paramNames; + for (var i = 0; i < paramNames.length; i++) { + var param = args[i]; + var paramName = paramNames[i]; + var paramType = paramTypes[i]; + if (this.hardcodeConstants) { + if (paramType === 'Array' || paramType === 'Texture') { + var paramDim = utils.getDimensions(param, true); + var paramSize = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, paramDim); + + result.push('uniform highp sampler2D user_' + paramName, 'highp ivec2 user_' + paramName + 'Size = ivec2(' + paramSize[0] + ', ' + paramSize[1] + ')', 'highp ivec3 user_' + paramName + 'Dim = ivec3(' + paramDim[0] + ', ' + paramDim[1] + ', ' + paramDim[2] + ')', 'uniform highp int user_' + paramName + 'BitRatio'); + + if (paramType === 'Array') { + result.push('uniform highp int user_' + paramName + 'BitRatio'); + } + } else if (paramType === 'Integer') { + result.push('highp float user_' + paramName + ' = ' + param + '.0'); + } else if (paramType === 'Float') { + result.push('highp float user_' + paramName + ' = ' + param); + } } else { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + if (paramType === 'Array' || paramType === 'Texture' || paramType === 'Input' || paramType === 'HTMLImage') { + result.push('uniform highp sampler2D user_' + paramName, 'uniform highp ivec2 user_' + paramName + 'Size', 'uniform highp ivec3 user_' + paramName + 'Dim'); + if (paramType !== 'HTMLImage') { + result.push('uniform highp int user_' + paramName + 'BitRatio'); + } + } else if (paramType === 'HTMLImageArray') { + result.push('uniform highp sampler2DArray user_' + paramName, 'uniform highp ivec2 user_' + paramName + 'Size', 'uniform highp ivec3 user_' + paramName + 'Dim'); + } else if (paramType === 'Integer' || paramType === 'Float') { + result.push('uniform float user_' + paramName); + } } - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i + 1, gl.TEXTURE_2D, texture, 0); } + return this._linesToString(result); } }, { - key: 'getArgumentTexture', - value: function getArgumentTexture(name) { - return this.getTextureCache('ARGUMENT_' + name); + key: '_getKernelString', + value: function _getKernelString() { + var result = []; + var names = this.subKernelOutputVariableNames; + if (names !== null) { + result.push('float kernelResult = 0.0'); + result.push('layout(location = 0) out vec4 data0'); + for (var i = 0; i < names.length; i++) { + result.push('float ' + names[i] + ' = 0.0', 'layout(location = ' + (i + 1) + ') out vec4 data' + (i + 1)); + } + } else { + result.push('out vec4 data0'); + result.push('float kernelResult = 0.0'); + } + + return this._linesToString(result) + this.functionBuilder.getPrototypeString('kernel'); } }, { - key: 'getTextureCache', - value: function getTextureCache(name) { - if (this.textureCache.hasOwnProperty(name)) { - return this.textureCache[name]; + key: '_getMainResultString', + value: function _getMainResultString() { + var names = this.subKernelOutputVariableNames; + var result = []; + + if (this.floatOutput) { + result.push(' index *= 4'); } - return this.textureCache[name] = this._webGl.createTexture(); - } + if (this.graphical) { + result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' data0 = actualColor'); + } else if (this.floatOutput) { + var channels = ['r', 'g', 'b', 'a']; - }, { - key: 'detachTextureCache', - value: function detachTextureCache(name) { - delete this.textureCache[name]; - } - }, { - key: 'setUniform1f', - value: function setUniform1f(name, value) { - if (this.uniform1fCache.hasOwnProperty(name)) { - var cache = this.uniform1fCache[name]; - if (value === cache) { - return; + for (var i = 0; i < channels.length; ++i) { + result.push(' threadId = indexTo3D(index, uOutputDim)'); + result.push(' kernel()'); + + if (names) { + result.push(' data0.' + channels[i] + ' = kernelResult'); + + for (var j = 0; j < names.length; ++j) { + result.push(' data' + (j + 1) + '.' + channels[i] + ' = ' + names[j]); + } + } else { + result.push(' data0.' + channels[i] + ' = kernelResult'); + } + + if (i < channels.length - 1) { + result.push(' index += 1'); + } } - } - this.uniform1fCache[name] = value; - var loc = this.getUniformLocation(name); - this._webGl.uniform1f(loc, value); - } - }, { - key: 'setUniform1i', - value: function setUniform1i(name, value) { - if (this.uniform1iCache.hasOwnProperty(name)) { - var cache = this.uniform1iCache[name]; - if (value === cache) { - return; + } else if (names !== null) { + result.push(' threadId = indexTo3D(index, uOutputDim)'); + result.push(' kernel()'); + result.push(' data0 = encode32(kernelResult)'); + for (var _i2 = 0; _i2 < names.length; _i2++) { + result.push(' data' + (_i2 + 1) + ' = encode32(' + names[_i2] + ')'); } + } else { + result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' data0 = encode32(kernelResult)'); } - this.uniform1iCache[name] = value; - var loc = this.getUniformLocation(name); - this._webGl.uniform1i(loc, value); + + return this._linesToString(result); } + + }, { - key: 'setUniform2f', - value: function setUniform2f(name, value1, value2) { - if (this.uniform2fCache.hasOwnProperty(name)) { - var cache = this.uniform2fCache[name]; - if (value1 === cache[0] && value2 === cache[1]) { - return; - } + key: '_addKernels', + value: function _addKernels() { + var _this2 = this; + + var builder = this.functionBuilder; + var gl = this._webGl; + + builder.addFunctions(this.functions, { + constants: this.constants, + output: this.output + }); + builder.addNativeFunctions(this.nativeFunctions); + + builder.addKernel(this.fnString, { + prototypeOnly: false, + constants: this.constants, + output: this.output, + debug: this.debug, + loopMaxIterations: this.loopMaxIterations, + paramNames: this.paramNames, + paramTypes: this.paramTypes, + constantTypes: this.constantTypes, + fixIntegerDivisionAccuracy: this.fixIntegerDivisionAccuracy + }); + + if (this.subKernels !== null) { + this.subKernelOutputTextures = []; + this.subKernelOutputVariableNames = []; + this.subKernels.forEach(function (subKernel) { + return _this2._addSubKernel(subKernel); + }); + } else if (this.subKernelProperties !== null) { + this.subKernelOutputTextures = []; + this.subKernelOutputVariableNames = []; + Object.keys(this.subKernelProperties).forEach(function (property) { + return _this2._addSubKernel(_this2.subKernelProperties[property]); + }); } - this.uniform2fCache[name] = [value1, value2]; - var loc = this.getUniformLocation(name); - this._webGl.uniform2f(loc, value1, value2); } + + }, { - key: 'setUniform2fv', - value: function setUniform2fv(name, value) { - if (this.uniform2fvCache.hasOwnProperty(name)) { - var cache = this.uniform2fvCache[name]; - if (value[0] === cache[0] && value[1] === cache[1]) { - return; - } + key: '_getFragShaderString', + value: function _getFragShaderString(args) { + if (this.compiledFragShaderString !== null) { + return this.compiledFragShaderString; } - this.uniform2fvCache[name] = value; - var loc = this.getUniformLocation(name); - this._webGl.uniform2fv(loc, value); + return this.compiledFragShaderString = this._replaceArtifacts(this.constructor.fragShaderString, this._getFragShaderArtifactMap(args)); } + + }, { - key: 'setUniform2iv', - value: function setUniform2iv(name, value) { - if (this.uniform2ivCache.hasOwnProperty(name)) { - var cache = this.uniform2ivCache[name]; - if (value[0] === cache[0] && value[1] === cache[1]) { - return; - } + key: '_getVertShaderString', + value: function _getVertShaderString(args) { + if (this.compiledVertShaderString !== null) { + return this.compiledVertShaderString; } - this.uniform2ivCache[name] = value; - var loc = this.getUniformLocation(name); - this._webGl.uniform2iv(loc, value); + return this.compiledVertShaderString = this.constructor.vertShaderString; } - }, { - key: 'setUniform3fv', - value: function setUniform3fv(name, value) { - if (this.uniform3fvCache.hasOwnProperty(name)) { - var cache = this.uniform3fvCache[name]; - if (value[0] === cache[0] && value[1] === cache[1] && value[2] === cache[2]) { - return; - } - } - this.uniform3fvCache[name] = value; - var loc = this.getUniformLocation(name); - this._webGl.uniform3fv(loc, value); + }], [{ + key: 'fragShaderString', + get: function get() { + return fragShaderString; } }, { - key: 'setUniform3iv', - value: function setUniform3iv(name, value) { - if (this.uniform3ivCache.hasOwnProperty(name)) { - var cache = this.uniform3ivCache[name]; - if (value[0] === cache[0] && value[1] === cache[1] && value[2] === cache[2]) { - return; - } - } - this.uniform3ivCache[name] = value; - var loc = this.getUniformLocation(name); - this._webGl.uniform3iv(loc, value); + key: 'vertShaderString', + get: function get() { + return vertShaderString; } + }]); + return WebGL2Kernel; +}(WebGLKernel); +},{"../../core/texture":30,"../../core/utils":32,"../web-gl/kernel":21,"./shader-frag":15,"./shader-vert":16}],14:[function(require,module,exports){ +'use strict'; - }, { - key: 'getUniformLocation', - value: function getUniformLocation(name) { - if (this.programUniformLocationCache.hasOwnProperty(name)) { - return this.programUniformLocationCache[name]; - } - return this.programUniformLocationCache[name] = this._webGl.getUniformLocation(this.program, name); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var RunnerBase = require('../runner-base'); +var WebGL2FunctionBuilder = require('./function-builder'); +var WebGL2Kernel = require('./kernel'); + +module.exports = function (_RunnerBase) { + _inherits(WebGL2Runner, _RunnerBase); + + function WebGL2Runner(settings) { + _classCallCheck(this, WebGL2Runner); + + var _this = _possibleConstructorReturn(this, (WebGL2Runner.__proto__ || Object.getPrototypeOf(WebGL2Runner)).call(this, new WebGL2FunctionBuilder(), settings)); + + _this.Kernel = WebGL2Kernel; + _this.kernel = null; + return _this; + } + + + + _createClass(WebGL2Runner, [{ + key: 'getMode', + value: function getMode() { + return 'gpu'; } + }]); + return WebGL2Runner; +}(RunnerBase); +},{"../runner-base":10,"./function-builder":11,"./kernel":13}],15:[function(require,module,exports){ +"use strict"; - }, { - key: '_getFragShaderArtifactMap', - value: function _getFragShaderArtifactMap(args) { - return { - HEADER: this._getHeaderString(), - LOOP_MAX: this._getLoopMaxString(), - CONSTANTS: this._getConstantsString(), - DECODE32_ENDIANNESS: this._getDecode32EndiannessString(), - ENCODE32_ENDIANNESS: this._getEncode32EndiannessString(), - DIVIDE_WITH_INTEGER_CHECK: this._getDivideWithIntegerCheckString(), - GET_WRAPAROUND: this._getGetWraparoundString(), - GET_TEXTURE_CHANNEL: this._getGetTextureChannelString(), - GET_TEXTURE_INDEX: this._getGetTextureIndexString(), - GET_RESULT: this._getGetResultString(), - MAIN_PARAMS: this._getMainParamsString(args), - MAIN_CONSTANTS: this._getMainConstantsString(), - KERNEL: this._getKernelString(), - MAIN_RESULT: this._getMainResultString() - }; +module.exports = "#version 300 es\n__HEADER__;\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nconst float LOOP_MAX = __LOOP_MAX__;\n\n__CONSTANTS__;\n\nin vec2 vTexCoord;\n\nvec2 integerMod(vec2 x, float y) {\n vec2 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec3 integerMod(vec3 x, float y) {\n vec3 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec4 integerMod(vec4 x, vec4 y) {\n vec4 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nfloat integerMod(float x, float y) {\n float res = floor(mod(x, y));\n return res * (res > floor(y) - 1.0 ? 0.0 : 1.0);\n}\n\nint integerMod(int x, int y) {\n return x - (y * int(x/y));\n}\n\n__DIVIDE_WITH_INTEGER_CHECK__;\n\n// Here be dragons!\n// DO NOT OPTIMIZE THIS CODE\n// YOU WILL BREAK SOMETHING ON SOMEBODY'S MACHINE\n// LEAVE IT AS IT IS, LEST YOU WASTE YOUR OWN TIME\nconst vec2 MAGIC_VEC = vec2(1.0, -256.0);\nconst vec4 SCALE_FACTOR = vec4(1.0, 256.0, 65536.0, 0.0);\nconst vec4 SCALE_FACTOR_INV = vec4(1.0, 0.00390625, 0.0000152587890625, 0.0); // 1, 1/256, 1/65536\nfloat decode32(vec4 rgba) {\n __DECODE32_ENDIANNESS__;\n rgba *= 255.0;\n vec2 gte128;\n gte128.x = rgba.b >= 128.0 ? 1.0 : 0.0;\n gte128.y = rgba.a >= 128.0 ? 1.0 : 0.0;\n float exponent = 2.0 * rgba.a - 127.0 + dot(gte128, MAGIC_VEC);\n float res = exp2(round(exponent));\n rgba.b = rgba.b - 128.0 * gte128.x;\n res = dot(rgba, SCALE_FACTOR) * exp2(round(exponent-23.0)) + res;\n res *= gte128.y * -2.0 + 1.0;\n return res;\n}\n\nvec4 encode32(float f) {\n float F = abs(f);\n float sign = f < 0.0 ? 1.0 : 0.0;\n float exponent = floor(log2(F));\n float mantissa = (exp2(-exponent) * F);\n // exponent += floor(log2(mantissa));\n vec4 rgba = vec4(F * exp2(23.0-exponent)) * SCALE_FACTOR_INV;\n rgba.rg = integerMod(rgba.rg, 256.0);\n rgba.b = integerMod(rgba.b, 128.0);\n rgba.a = exponent*0.5 + 63.5;\n rgba.ba += vec2(integerMod(exponent+127.0, 2.0), sign) * 128.0;\n rgba = floor(rgba);\n rgba *= 0.003921569; // 1/255\n __ENCODE32_ENDIANNESS__;\n return rgba;\n}\n// Dragons end here\n\nfloat decode(vec4 rgba, int x, int bitRatio) {\n if (bitRatio == 1) {\n return decode32(rgba);\n }\n __DECODE32_ENDIANNESS__;\n int channel = integerMod(x, bitRatio);\n if (bitRatio == 4) {\n return rgba[channel] * 255.0;\n }\n else {\n return rgba[channel*2] * 255.0 + rgba[channel*2 + 1] * 65280.0;\n }\n}\n\nint index;\nivec3 threadId;\n\nivec3 indexTo3D(int idx, ivec3 texDim) {\n int z = int(idx / (texDim.x * texDim.y));\n idx -= z * int(texDim.x * texDim.y);\n int y = int(idx / texDim.x);\n int x = int(integerMod(idx, texDim.x));\n return ivec3(x, y, z);\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int z, int y, int x) {\n ivec3 xyz = ivec3(x, y, z);\n __GET_WRAPAROUND__;\n int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);\n __GET_TEXTURE_CHANNEL__;\n int w = texSize.x;\n vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;\n __GET_TEXTURE_INDEX__;\n vec4 texel = texture(tex, st / vec2(texSize));\n __GET_RESULT__;\n \n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int z, int y, int x) {\n ivec3 xyz = ivec3(x, y, z);\n __GET_WRAPAROUND__;\n int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);\n __GET_TEXTURE_CHANNEL__;\n int w = texSize.x;\n vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;\n __GET_TEXTURE_INDEX__;\n return texture(tex, st / vec2(texSize));\n}\n\nvec4 getImage3D(sampler2DArray tex, ivec2 texSize, ivec3 texDim, int z, int y, int x) {\n ivec3 xyz = ivec3(x, y, z);\n __GET_WRAPAROUND__;\n int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);\n __GET_TEXTURE_CHANNEL__;\n int w = texSize.x;\n vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;\n __GET_TEXTURE_INDEX__;\n return texture(tex, vec3(st / vec2(texSize), z));\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int y, int x) {\n return get(tex, texSize, texDim, bitRatio, 0, y, x);\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int x) {\n return get(tex, texSize, texDim, bitRatio, 0, 0, x);\n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int y, int x) {\n return getImage2D(tex, texSize, texDim, 0, y, x);\n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int x) {\n return getImage2D(tex, texSize, texDim, 0, 0, x);\n}\n\nvec4 actualColor;\nvoid color(float r, float g, float b, float a) {\n actualColor = vec4(r,g,b,a);\n}\n\nvoid color(float r, float g, float b) {\n color(r,g,b,1.0);\n}\n\n__MAIN_PARAMS__;\n__MAIN_CONSTANTS__;\n__KERNEL__;\n\nvoid main(void) {\n index = int(vTexCoord.s * float(uTexSize.x)) + int(vTexCoord.t * float(uTexSize.y)) * uTexSize.x;\n __MAIN_RESULT__;\n}"; +},{}],16:[function(require,module,exports){ +"use strict"; + +module.exports = "#version 300 es\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nin vec2 aPos;\nin vec2 aTexCoord;\n\nout vec2 vTexCoord;\nuniform vec2 ratio;\n\nvoid main(void) {\n gl_Position = vec4((aPos + vec2(1)) * ratio + vec2(-1), 0, 1);\n vTexCoord = aTexCoord;\n}"; +},{}],17:[function(require,module,exports){ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var WebGLKernel = require('./kernel'); +var utils = require('../../core/utils'); + +module.exports = function (_WebGLKernel) { + _inherits(WebGL2ValidatorKernel, _WebGLKernel); + + function WebGL2ValidatorKernel() { + _classCallCheck(this, WebGL2ValidatorKernel); + + return _possibleConstructorReturn(this, (WebGL2ValidatorKernel.__proto__ || Object.getPrototypeOf(WebGL2ValidatorKernel)).apply(this, arguments)); + } + + _createClass(WebGL2ValidatorKernel, [{ + key: 'validateOptions', + + + value: function validateOptions() { + this._webGl.getExtension('EXT_color_buffer_float'); + this.texSize = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, this.output, true); } + }]); + return WebGL2ValidatorKernel; +}(WebGLKernel); +},{"../../core/utils":32,"./kernel":13}],18:[function(require,module,exports){ +'use strict'; - }, { - key: '_addArgument', - value: function _addArgument(value, type, name) { - var gl = this._webGl; - var argumentTexture = this.getArgumentTexture(name); - if (value instanceof Texture) { - type = 'Texture'; - } - switch (type) { - case 'Array': - { - var dim = utils.getDimensions(value, true); - var size = utils.dimToTexSize({ - floatTextures: this.floatTextures, - floatOutput: this.floatOutput - }, dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); - gl.bindTexture(gl.TEXTURE_2D, argumentTexture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var length = size[0] * size[1]; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var _formatArrayTransfer2 = this._formatArrayTransfer(value, length), - valuesFlat = _formatArrayTransfer2.valuesFlat, - bitRatio = _formatArrayTransfer2.bitRatio; +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - var buffer = void 0; - if (this.floatTextures) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); - } else { - buffer = new Uint8Array(valuesFlat.buffer); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); - } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - if (!this.hardcodeConstants) { - this.setUniform3iv('user_' + name + 'Dim', dim); - this.setUniform2iv('user_' + name + 'Size', size); - } - this.setUniform1i('user_' + name + 'BitRatio', bitRatio); - this.setUniform1i('user_' + name, this.argumentsLength); - break; - } - case 'Integer': - case 'Float': - { - this.setUniform1f('user_' + name, value); - break; - } - case 'Input': - { - var input = value; - var _dim = input.size; - var _size = utils.dimToTexSize({ - floatTextures: this.floatTextures, - floatOutput: this.floatOutput - }, _dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); - gl.bindTexture(gl.TEXTURE_2D, argumentTexture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); +var FunctionBuilderBase = require('../function-builder-base'); +var WebGLFunctionNode = require('./function-node'); + +module.exports = function (_FunctionBuilderBase) { + _inherits(WebGLFunctionBuilder, _FunctionBuilderBase); + + function WebGLFunctionBuilder() { + _classCallCheck(this, WebGLFunctionBuilder); - var _length = _size[0] * _size[1]; + var _this = _possibleConstructorReturn(this, (WebGLFunctionBuilder.__proto__ || Object.getPrototypeOf(WebGLFunctionBuilder)).call(this)); - var _formatArrayTransfer3 = this._formatArrayTransfer(value.value, _length), - _valuesFlat = _formatArrayTransfer3.valuesFlat, - _bitRatio = _formatArrayTransfer3.bitRatio; + _this.Node = WebGLFunctionNode; + return _this; + } - if (this.floatTextures) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size[0], _size[1], 0, gl.RGBA, gl.FLOAT, inputArray); - } else { - var _buffer = new Uint8Array(_valuesFlat.buffer); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size[0] / _bitRatio, _size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, _buffer); - } - if (!this.hardcodeConstants) { - this.setUniform3iv('user_' + name + 'Dim', _dim); - this.setUniform2iv('user_' + name + 'Size', _size); - } - this.setUniform1i('user_' + name + 'BitRatio', _bitRatio); - this.setUniform1i('user_' + name, this.argumentsLength); - break; - } - case 'HTMLImage': - { - var inputImage = value; - var _dim2 = [inputImage.width, inputImage.height, 1]; - var _size2 = [inputImage.width, inputImage.height]; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); - gl.bindTexture(gl.TEXTURE_2D, argumentTexture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); - var mipLevel = 0; - var internalFormat = gl.RGBA; - var srcFormat = gl.RGBA; - var srcType = gl.UNSIGNED_BYTE; - gl.texImage2D(gl.TEXTURE_2D, mipLevel, internalFormat, srcFormat, srcType, inputImage); - this.setUniform3iv('user_' + name + 'Dim', _dim2); - this.setUniform2iv('user_' + name + 'Size', _size2); - this.setUniform1i('user_' + name, this.argumentsLength); - break; - } - case 'Texture': - { - var inputTexture = value; - var _dim3 = inputTexture.dimensions; - var _size3 = inputTexture.size; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); - gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); + _createClass(WebGLFunctionBuilder, [{ + key: 'polyfillStandardFunctions', - this.setUniform3iv('user_' + name + 'Dim', _dim3); - this.setUniform2iv('user_' + name + 'Size', _size3); - this.setUniform1i('user_' + name + 'BitRatio', 1); - this.setUniform1i('user_' + name, this.argumentsLength); - break; - } - default: - throw new Error('Input type not supported (WebGL): ' + value); - } - this.argumentsLength++; + + value: function polyfillStandardFunctions() { + this.addFunction('round', _round); } + }], [{ + key: 'round', + value: function round(a) { + return _round(a); + } + }]); + return WebGLFunctionBuilder; +}(FunctionBuilderBase); - }, { - key: '_formatArrayTransfer', - value: function _formatArrayTransfer(value, length) { - var bitRatio = 1; - var valuesFlat = value; - if (utils.isArray(value[0]) || this.floatTextures) { - valuesFlat = new Float32Array(length); - utils.flattenTo(value, valuesFlat); - } else { +function _round(a) { + return Math.floor(a + 0.5); +} +},{"../function-builder-base":6,"./function-node":19}],19:[function(require,module,exports){ +'use strict'; - switch (value.constructor) { - case Uint8Array: - case Int8Array: - bitRatio = 4; - break; - case Uint16Array: - case Int16Array: - bitRatio = 2; - case Float32Array: - case Int32Array: - break; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - default: - valuesFlat = new Float32Array(length); - utils.flattenTo(value, valuesFlat); - } - } - return { - bitRatio: bitRatio, - valuesFlat: valuesFlat - }; - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - }, { - key: '_getHeaderString', - value: function _getHeaderString() { - return this.subKernels !== null || this.subKernelProperties !== null ? - '#extension GL_EXT_draw_buffers : require\n' : ''; - } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +var FunctionNodeBase = require('../function-node-base'); +var utils = require('../../core/utils'); +var jsMathPrefix = 'Math.'; +var localPrefix = 'this.'; +var constantsPrefix = 'this.constants.'; - }, { - key: '_getLoopMaxString', - value: function _getLoopMaxString() { - return this.loopMaxIterations ? ' ' + parseInt(this.loopMaxIterations) + '.0;\n' : ' 1000.0;\n'; - } +var DECODE32_ENCODE32 = /decode32\(\s+encode32\(/g; +var ENCODE32_DECODE32 = /encode32\(\s+decode32\(/g; +var debugLog = function debugLog() {}; +module.exports = function (_FunctionNodeBase) { + _inherits(WebGLFunctionNode, _FunctionNodeBase); - }, { - key: '_getConstantsString', - value: function _getConstantsString() { - var result = []; - var threadDim = this.threadDim; - var texSize = this.texSize; - if (this.hardcodeConstants) { - result.push('ivec3 uOutputDim = ivec3(' + threadDim[0] + ',' + threadDim[1] + ', ' + threadDim[2] + ')', 'ivec2 uTexSize = ivec2(' + texSize[0] + ', ' + texSize[1] + ')'); + function WebGLFunctionNode() { + _classCallCheck(this, WebGLFunctionNode); + + return _possibleConstructorReturn(this, (WebGLFunctionNode.__proto__ || Object.getPrototypeOf(WebGLFunctionNode)).apply(this, arguments)); + } + + _createClass(WebGLFunctionNode, [{ + key: 'generate', + value: function generate() { + if (this.debug) { + debugLog(this); + } + if (this.prototypeOnly) { + return WebGLFunctionNode.astFunctionPrototype(this.getJsAST(), [], this).join('').trim(); } else { - result.push('uniform ivec3 uOutputDim', 'uniform ivec2 uTexSize'); + this.functionStringArray = this.astGeneric(this.getJsAST(), [], this); } - - return this._linesToString(result); + this.functionString = webGlRegexOptimize(this.functionStringArray.join('').trim()); + return this.functionString; } }, { - key: '_getTextureCoordinate', - value: function _getTextureCoordinate() { - var names = this.subKernelOutputVariableNames; - if (names === null || names.length < 1) { - return 'varying vec2 vTexCoord;\n'; - } else { - return 'out vec2 vTexCoord;\n'; + key: 'astFunctionDeclaration', + value: function astFunctionDeclaration(ast, retArr) { + if (this.addFunction) { + this.addFunction(null, utils.getAstString(this.jsFunctionString, ast)); } + return retArr; } }, { - key: '_getDecode32EndiannessString', - value: function _getDecode32EndiannessString() { - return this.endianness === 'LE' ? '' : ' rgba.rgba = rgba.abgr;\n'; - } + key: 'astFunctionExpression', - }, { - key: '_getEncode32EndiannessString', - value: function _getEncode32EndiannessString() { - return this.endianness === 'LE' ? '' : ' rgba.rgba = rgba.abgr;\n'; - } + value: function astFunctionExpression(ast, retArr) { + if (this.isRootKernel) { + retArr.push('void'); + this.kernalAst = ast; + } else { + retArr.push(this.returnType); + } + retArr.push(' '); + retArr.push(this.functionName); + retArr.push('('); - }, { - key: '_getDivideWithIntegerCheckString', - value: function _getDivideWithIntegerCheckString() { - return this.fixIntegerDivisionAccuracy ? '\n\t\t\t float div_with_int_check(float x, float y) {\n\t\t\t if (floor(x) == x && floor(y) == y && integerMod(x, y) == 0.0) {\n\t\t\t return float(int(x)/int(y));\n\t\t\t }\n\t\t\t return x / y;\n\t\t\t}\n\t\t\t' : ''; - } + if (!this.isRootKernel) { + for (var i = 0; i < this.paramNames.length; ++i) { + var paramName = this.paramNames[i]; + if (i > 0) { + retArr.push(', '); + } + var type = this.getParamType(paramName); + switch (type) { + case 'Texture': + case 'Input': + case 'Array': + retArr.push('sampler2D'); + break; + default: + retArr.push('float'); + } - }, { - key: '_getGetWraparoundString', - value: function _getGetWraparoundString() { - return this.wraparound ? ' xyz = mod(xyz, texDim);\n' : ''; - } + retArr.push(' '); + retArr.push('user_'); + retArr.push(paramName); + } + } + retArr.push(') {\n'); - }, { - key: '_getGetTextureChannelString', - value: function _getGetTextureChannelString() { - if (!this.floatTextures) return ''; + for (var _i = 0; _i < ast.body.body.length; ++_i) { + this.astGeneric(ast.body.body[_i], retArr); + retArr.push('\n'); + } - return this._linesToString([' int channel = integerMod(index, 4)', ' index = index / 4']); + retArr.push('}\n'); + return retArr; } }, { - key: '_getGetTextureIndexString', - value: function _getGetTextureIndexString() { - return this.floatTextures ? ' index = index / 4;\n' : ''; + key: 'astReturnStatement', + value: function astReturnStatement(ast, retArr) { + if (this.isRootKernel) { + retArr.push('kernelResult = '); + this.astGeneric(ast.argument, retArr); + retArr.push(';'); + retArr.push('return;'); + } else if (this.isSubKernel) { + retArr.push(this.functionName + 'Result = '); + this.astGeneric(ast.argument, retArr); + retArr.push(';'); + retArr.push('return ' + this.functionName + 'Result;'); + } else { + retArr.push('return '); + this.astGeneric(ast.argument, retArr); + retArr.push(';'); + } + + + return retArr; } }, { - key: '_getGetResultString', - value: function _getGetResultString() { - if (!this.floatTextures) { - return ' return decode(texel, x, bitRatio);'; - } - return this._linesToString([' if (channel == 0) return texel.r', ' if (channel == 1) return texel.g', ' if (channel == 2) return texel.b', ' if (channel == 3) return texel.a']); - } + key: 'astLiteral', + value: function astLiteral(ast, retArr) { + if (isNaN(ast.value)) { + throw this.astErrorOutput('Non-numeric literal not supported : ' + ast.value, ast); + } - }, { - key: '_getMainParamsString', - value: function _getMainParamsString(args) { - var result = []; - var paramTypes = this.paramTypes; - var paramNames = this.paramNames; - for (var i = 0; i < paramNames.length; i++) { - var param = args[i]; - var paramName = paramNames[i]; - var paramType = paramTypes[i]; - if (this.hardcodeConstants) { - if (paramType === 'Array' || paramType === 'Texture') { - var paramDim = utils.getDimensions(param, true); - var paramSize = utils.dimToTexSize({ - floatTextures: this.floatTextures, - floatOutput: this.floatOutput - }, paramDim); + retArr.push(ast.value); - result.push('uniform sampler2D user_' + paramName, 'ivec2 user_' + paramName + 'Size = vec2(' + paramSize[0] + ', ' + paramSize[1] + ')', 'ivec3 user_' + paramName + 'Dim = vec3(' + paramDim[0] + ', ' + paramDim[1] + ', ' + paramDim[2] + ')', 'uniform int user_' + paramName + 'BitRatio'); - } else if (paramType === 'Integer') { - result.push('float user_' + paramName + ' = ' + param + '.0'); - } else if (paramType === 'Float') { - result.push('float user_' + paramName + ' = ' + param); - } - } else { - if (paramType === 'Array' || paramType === 'Texture' || paramType === 'Input' || paramType === 'HTMLImage') { - result.push('uniform sampler2D user_' + paramName, 'uniform ivec2 user_' + paramName + 'Size', 'uniform ivec3 user_' + paramName + 'Dim'); - if (paramType !== 'HTMLImage') { - result.push('uniform int user_' + paramName + 'BitRatio'); - } - } else if (paramType === 'Integer' || paramType === 'Float') { - result.push('uniform float user_' + paramName); - } else { - throw new Error('Param type ' + paramType + ' not supported in WebGL, only WebGL2'); - } + var inGetParams = this.isState('in-get-call-parameters'); + if (Number.isInteger(ast.value)) { + if (!inGetParams) { + retArr.push('.0'); } + } else if (inGetParams) { + retArr.pop(); + retArr.push('int('); + retArr.push(ast.value); + retArr.push(')'); } - return this._linesToString(result); + + return retArr; } }, { - key: '_getMainConstantsString', - value: function _getMainConstantsString() { - var result = []; - if (this.constants) { - for (var name in this.constants) { - if (!this.constants.hasOwnProperty(name)) continue; - var value = this.constants[name]; - var type = utils.getArgumentType(value); - switch (type) { - case 'Integer': - result.push('const float constants_' + name + ' = ' + parseInt(value) + '.0'); - break; - case 'Float': - result.push('const float constants_' + name + ' = ' + parseFloat(value)); - break; - default: - throw new Error('Unsupported constant ' + name + ' type ' + type); - } - } + key: 'astBinaryExpression', + value: function astBinaryExpression(ast, retArr) { + var inGetParams = this.isState('in-get-call-parameters'); + if (inGetParams) { + this.pushState('not-in-get-call-parameters'); + retArr.push('int'); } - return this._linesToString(result); + retArr.push('('); + + if (ast.operator === '%') { + retArr.push('mod('); + this.astGeneric(ast.left, retArr); + retArr.push(','); + this.astGeneric(ast.right, retArr); + retArr.push(')'); + } else if (ast.operator === '===') { + this.astGeneric(ast.left, retArr); + retArr.push('=='); + this.astGeneric(ast.right, retArr); + } else if (ast.operator === '!==') { + this.astGeneric(ast.left, retArr); + retArr.push('!='); + this.astGeneric(ast.right, retArr); + } else if (this.fixIntegerDivisionAccuracy && ast.operator === '/') { + retArr.push('div_with_int_check('); + this.astGeneric(ast.left, retArr); + retArr.push(', '); + this.astGeneric(ast.right, retArr); + retArr.push(')'); + } else { + this.astGeneric(ast.left, retArr); + retArr.push(ast.operator); + this.astGeneric(ast.right, retArr); + } + + retArr.push(')'); + + if (inGetParams) { + this.popState('not-in-get-call-parameters'); + } + + return retArr; } }, { - key: '_getKernelString', - value: function _getKernelString() { - var result = []; - var names = this.subKernelOutputVariableNames; - if (names !== null) { - result.push('float kernelResult = 0.0'); - for (var i = 0; i < names.length; i++) { - result.push('float ' + names[i] + ' = 0.0'); - } - } else { - result.push('float kernelResult = 0.0'); + key: 'astIdentifierExpression', + value: function astIdentifierExpression(idtNode, retArr) { + if (idtNode.type !== 'Identifier') { + throw this.astErrorOutput('IdentifierExpression - not an Identifier', idtNode); } + var castFloat = !this.isState('in-get-call-parameters'); - return this._linesToString(result) + this.functionBuilder.getPrototypeString('kernel'); + switch (idtNode.name) { + case 'gpu_threadX': + castFloat && retArr.push('float('); + retArr.push('threadId.x'); + castFloat && retArr.push(')'); + break; + case 'gpu_threadY': + castFloat && retArr.push('float('); + retArr.push('threadId.y'); + castFloat && retArr.push(')'); + break; + case 'gpu_threadZ': + castFloat && retArr.push('float('); + retArr.push('threadId.z'); + castFloat && retArr.push(')'); + break; + case 'gpu_outputX': + retArr.push('uOutputDim.x'); + break; + case 'gpu_outputY': + retArr.push('uOutputDim.y'); + break; + case 'gpu_outputZ': + retArr.push('uOutputDim.z'); + break; + case 'Infinity': + retArr.push('3.402823466e+38'); + break; + default: + if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { + this.pushParameter(retArr, 'constants_' + idtNode.name); + } else { + var userParamName = this.getUserParamName(idtNode.name); + if (userParamName !== null) { + this.pushParameter(retArr, 'user_' + userParamName); + } else { + this.pushParameter(retArr, 'user_' + idtNode.name); + } + } + } + + return retArr; } }, { - key: '_getMainResultString', - value: function _getMainResultString() { - var names = this.subKernelOutputVariableNames; - var result = []; - - if (this.floatOutput) { - result.push(' index *= 4'); + key: 'astForStatement', + value: function astForStatement(forNode, retArr) { + if (forNode.type !== 'ForStatement') { + throw this.astErrorOutput('Invalid for statment', forNode); } - if (this.graphical) { - result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' gl_FragColor = actualColor'); - } else if (this.floatOutput) { - var channels = ['r', 'g', 'b', 'a']; + if (forNode.test && forNode.test.type === 'BinaryExpression') { + if (forNode.test.right.type === 'Identifier' && forNode.test.operator === '<' && this.isIdentifierConstant(forNode.test.right.name) === false) { - for (var i = 0; i < channels.length; ++i) { - result.push(' threadId = indexTo3D(index, uOutputDim)'); - result.push(' kernel()'); + if (!this.loopMaxIterations) { + console.warn('Warning: loopMaxIterations is not set! Using default of 1000 which may result in unintended behavior.'); + console.warn('Set loopMaxIterations or use a for loop of fixed length to silence this message.'); + } - if (names) { - result.push(' gl_FragData[0].' + channels[i] + ' = kernelResult'); + retArr.push('for ('); + this.astGeneric(forNode.init, retArr); + this.astGeneric(forNode.test.left, retArr); + retArr.push(forNode.test.operator); + retArr.push('LOOP_MAX'); + retArr.push(';'); + this.astGeneric(forNode.update, retArr); + retArr.push(')'); - for (var j = 0; j < names.length; ++j) { - result.push(' gl_FragData[' + (j + 1) + '].' + channels[i] + ' = ' + names[j]); + retArr.push('{\n'); + retArr.push('if ('); + this.astGeneric(forNode.test.left, retArr); + retArr.push(forNode.test.operator); + this.astGeneric(forNode.test.right, retArr); + retArr.push(') {\n'); + if (forNode.body.type === 'BlockStatement') { + for (var i = 0; i < forNode.body.body.length; i++) { + this.astGeneric(forNode.body.body[i], retArr); + } + } else { + this.astGeneric(forNode.body, retArr); + } + retArr.push('} else {\n'); + retArr.push('break;\n'); + retArr.push('}\n'); + retArr.push('}\n'); + + return retArr; + } else { + var declarations = JSON.parse(JSON.stringify(forNode.init.declarations)); + var updateArgument = forNode.update.argument; + if (!Array.isArray(declarations) || declarations.length < 1) { + debugLog(this.jsFunctionString); + throw new Error('Error: Incompatible for loop declaration'); + } + + if (declarations.length > 1) { + var initArgument = null; + for (var _i2 = 0; _i2 < declarations.length; _i2++) { + var declaration = declarations[_i2]; + if (declaration.id.name === updateArgument.name) { + initArgument = declaration; + declarations.splice(_i2, 1); + } else { + retArr.push('float '); + this.astGeneric(declaration, retArr); + retArr.push(';'); + } } + + retArr.push('for (float '); + this.astGeneric(initArgument, retArr); + retArr.push(';'); } else { - result.push(' gl_FragColor.' + channels[i] + ' = kernelResult'); + retArr.push('for ('); + this.astGeneric(forNode.init, retArr); } - if (i < channels.length - 1) { - result.push(' index += 1'); - } - } - } else if (names !== null) { - result.push(' threadId = indexTo3D(index, uOutputDim)'); - result.push(' kernel()'); - result.push(' gl_FragData[0] = encode32(kernelResult)'); - for (var _i2 = 0; _i2 < names.length; _i2++) { - result.push(' gl_FragData[' + (_i2 + 1) + '] = encode32(' + names[_i2] + ')'); + this.astGeneric(forNode.test, retArr); + retArr.push(';'); + this.astGeneric(forNode.update, retArr); + retArr.push(')'); + this.astGeneric(forNode.body, retArr); + return retArr; } - } else { - result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' gl_FragColor = encode32(kernelResult)'); } - return this._linesToString(result); + throw this.astErrorOutput('Invalid for statement', forNode); } }, { - key: '_linesToString', - value: function _linesToString(lines) { - if (lines.length > 0) { - return lines.join(';\n') + ';\n'; - } else { - return '\n'; + key: 'astWhileStatement', + value: function astWhileStatement(whileNode, retArr) { + if (whileNode.type !== 'WhileStatement') { + throw this.astErrorOutput('Invalid while statment', whileNode); } - } + retArr.push('for (float i = 0.0; i < LOOP_MAX; i++) {'); + retArr.push('if ('); + this.astGeneric(whileNode.test, retArr); + retArr.push(') {\n'); + this.astGeneric(whileNode.body, retArr); + retArr.push('} else {\n'); + retArr.push('break;\n'); + retArr.push('}\n'); + retArr.push('}\n'); - }, { - key: '_replaceArtifacts', - value: function _replaceArtifacts(src, map) { - return src.replace(/[ ]*__([A-Z]+[0-9]*([_]?[A-Z])*)__;\n/g, function (match, artifact) { - if (map.hasOwnProperty(artifact)) { - return map[artifact]; - } - throw 'unhandled artifact ' + artifact; - }); + return retArr; } }, { - key: '_addKernels', - value: function _addKernels() { - var _this2 = this; + key: 'astDoWhileStatement', + value: function astDoWhileStatement(doWhileNode, retArr) { + if (doWhileNode.type !== 'DoWhileStatement') { + throw this.astErrorOutput('Invalid while statment', doWhileNode); + } - var builder = this.functionBuilder; - var gl = this._webGl; + retArr.push('for (float i = 0.0; i < LOOP_MAX; i++) {'); + this.astGeneric(doWhileNode.body, retArr); + retArr.push('if (!'); + this.astGeneric(doWhileNode.test, retArr); + retArr.push(') {\n'); + retArr.push('break;\n'); + retArr.push('}\n'); + retArr.push('}\n'); - builder.addFunctions(this.functions, { - constants: this.constants, - output: this.output - }); - builder.addNativeFunctions(this.nativeFunctions); + return retArr; + } - builder.addKernel(this.fnString, { - prototypeOnly: false, - constants: this.constants, - output: this.output, - debug: this.debug, - loopMaxIterations: this.loopMaxIterations, - paramNames: this.paramNames, - paramTypes: this.paramTypes, - fixIntegerDivisionAccuracy: this.fixIntegerDivisionAccuracy - }); - if (this.subKernels !== null) { - var drawBuffers = this.drawBuffers = gl.getExtension('WEBGL_draw_buffers'); - if (!drawBuffers) throw new Error('could not instantiate draw buffers extension'); - this.subKernelOutputVariableNames = []; - this.subKernels.forEach(function (subKernel) { - return _this2._addSubKernel(subKernel); - }); - } else if (this.subKernelProperties !== null) { - var _drawBuffers = this.drawBuffers = gl.getExtension('WEBGL_draw_buffers'); - if (!_drawBuffers) throw new Error('could not instantiate draw buffers extension'); - this.subKernelOutputVariableNames = []; - Object.keys(this.subKernelProperties).forEach(function (property) { - return _this2._addSubKernel(_this2.subKernelProperties[property]); - }); - } - } }, { - key: '_addSubKernel', - value: function _addSubKernel(subKernel) { - this.functionBuilder.addSubKernel(subKernel, { - prototypeOnly: false, - constants: this.constants, - output: this.output, - debug: this.debug, - loopMaxIterations: this.loopMaxIterations, - fixIntegerDivisionAccuracy: this.fixIntegerDivisionAccuracy - }); - this.subKernelOutputVariableNames.push(subKernel.name + 'Result'); + key: 'astAssignmentExpression', + value: function astAssignmentExpression(assNode, retArr) { + if (assNode.operator === '%=') { + this.astGeneric(assNode.left, retArr); + retArr.push('='); + retArr.push('mod('); + this.astGeneric(assNode.left, retArr); + retArr.push(','); + this.astGeneric(assNode.right, retArr); + retArr.push(')'); + } else { + this.astGeneric(assNode.left, retArr); + retArr.push(assNode.operator); + this.astGeneric(assNode.right, retArr); + return retArr; + } } }, { - key: '_getFragShaderString', - value: function _getFragShaderString(args) { - if (this.compiledFragShaderString !== null) { - return this.compiledFragShaderString; - } - return this.compiledFragShaderString = this._replaceArtifacts(this.constructor.fragShaderString, this._getFragShaderArtifactMap(args)); + key: 'astEmptyStatement', + value: function astEmptyStatement(eNode, retArr) { + return retArr; } }, { - key: '_getVertShaderString', - value: function _getVertShaderString(args) { - if (this.compiledVertShaderString !== null) { - return this.compiledVertShaderString; + key: 'astBlockStatement', + value: function astBlockStatement(bNode, retArr) { + retArr.push('{\n'); + for (var i = 0; i < bNode.body.length; i++) { + this.astGeneric(bNode.body[i], retArr); } - return this.compiledVertShaderString = this.constructor.vertShaderString; + retArr.push('}\n'); + return retArr; } }, { - key: 'toString', - value: function toString() { - return kernelString(this); - } - }, { - key: 'addFunction', - value: function addFunction(fn) { - this.functionBuilder.addFunction(null, fn); + key: 'astExpressionStatement', + value: function astExpressionStatement(esNode, retArr) { + this.astGeneric(esNode.expression, retArr); + retArr.push(';\n'); + return retArr; } - }, { - key: 'destroy', - value: function destroy(removeCanvasReferences) { - _get(WebGLKernel.prototype.__proto__ || Object.getPrototypeOf(WebGLKernel.prototype), 'destroy', this).call(this); - if (this.outputTexture) { - this._webGl.deleteTexture(this.outputTexture); - } - if (this.buffer) { - this._webGl.deleteBuffer(this.buffer); - } - if (this.framebuffer) { - this._webGl.deleteFramebuffer(this.framebuffer); - } - - if (this.vertShader) { - this._webGl.deleteShader(this.vertShader); - } - - if (this.fragShader) { - this._webGl.deleteShader(this.fragShader); - } - - if (this.program) { - this._webGl.deleteProgram(this.program); - } - - var keys = Object.keys(this.textureCache); - for (var i = 0; i < keys.length; i++) { - var name = keys[i]; - this._webGl.deleteTexture(this.textureCache[name]); - } - if (this.subKernelOutputTextures) { - for (var _i3 = 0; _i3 < this.subKernelOutputTextures.length; _i3++) { - this._webGl.deleteTexture(this.subKernelOutputTextures[_i3]); - } - } - if (removeCanvasReferences) { - var idx = canvases.indexOf(this._canvas); - if (idx >= 0) { - canvases[idx] = null; - maxTexSizes[idx] = null; + }, { + key: 'astVariableDeclaration', + value: function astVariableDeclaration(vardecNode, retArr) { + for (var i = 0; i < vardecNode.declarations.length; i++) { + var declaration = vardecNode.declarations[i]; + if (i > 0) { + retArr.push(','); } - } - delete this._webGl; - } - }]); - - return WebGLKernel; -}(KernelBase); -},{"../../core/texture":30,"../../core/utils":32,"../kernel-base":8,"./kernel-string":13,"./shader-frag":16,"./shader-vert":17}],15:[function(require,module,exports){ -'use strict'; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var RunnerBase = require('../runner-base'); -var WebGLKernel = require('./kernel'); -var WebGLFunctionBuilder = require('./function-builder'); - -module.exports = function (_RunnerBase) { - _inherits(WebGLRunner, _RunnerBase); - - function WebGLRunner(settings) { - _classCallCheck(this, WebGLRunner); - - var _this = _possibleConstructorReturn(this, (WebGLRunner.__proto__ || Object.getPrototypeOf(WebGLRunner)).call(this, new WebGLFunctionBuilder(), settings)); - - _this.Kernel = WebGLKernel; - _this.kernel = null; - return _this; - } - - - - _createClass(WebGLRunner, [{ - key: 'getMode', - value: function getMode() { - return 'gpu'; + var retDeclaration = []; + this.astGeneric(declaration, retDeclaration); + if (retDeclaration[2] === 'getImage2D(' || retDeclaration[2] === 'getImage3D(') { + if (i === 0) { + retArr.push('vec4 '); + } + this.declarations[declaration.id.name] = 'vec4'; + } else { + if (i === 0) { + retArr.push('float '); + } + this.declarations[declaration.id.name] = 'float'; + } + retArr.push.apply(retArr, retDeclaration); + } + retArr.push(';'); + return retArr; } - }]); - return WebGLRunner; -}(RunnerBase); -},{"../runner-base":10,"./function-builder":11,"./kernel":14}],16:[function(require,module,exports){ -"use strict"; -module.exports = "__HEADER__;\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nconst float LOOP_MAX = __LOOP_MAX__;\n\n__CONSTANTS__;\n\nvarying vec2 vTexCoord;\n\nvec4 round(vec4 x) {\n return floor(x + 0.5);\n}\n\nfloat round(float x) {\n return floor(x + 0.5);\n}\n\nvec2 integerMod(vec2 x, float y) {\n vec2 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec3 integerMod(vec3 x, float y) {\n vec3 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec4 integerMod(vec4 x, vec4 y) {\n vec4 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nfloat integerMod(float x, float y) {\n float res = floor(mod(x, y));\n return res * (res > floor(y) - 1.0 ? 0.0 : 1.0);\n}\n\nint integerMod(int x, int y) {\n return x - (y * int(x / y));\n}\n\n__DIVIDE_WITH_INTEGER_CHECK__;\n\n// Here be dragons!\n// DO NOT OPTIMIZE THIS CODE\n// YOU WILL BREAK SOMETHING ON SOMEBODY'S MACHINE\n// LEAVE IT AS IT IS, LEST YOU WASTE YOUR OWN TIME\nconst vec2 MAGIC_VEC = vec2(1.0, -256.0);\nconst vec4 SCALE_FACTOR = vec4(1.0, 256.0, 65536.0, 0.0);\nconst vec4 SCALE_FACTOR_INV = vec4(1.0, 0.00390625, 0.0000152587890625, 0.0); // 1, 1/256, 1/65536\nfloat decode32(vec4 rgba) {\n __DECODE32_ENDIANNESS__;\n rgba *= 255.0;\n vec2 gte128;\n gte128.x = rgba.b >= 128.0 ? 1.0 : 0.0;\n gte128.y = rgba.a >= 128.0 ? 1.0 : 0.0;\n float exponent = 2.0 * rgba.a - 127.0 + dot(gte128, MAGIC_VEC);\n float res = exp2(round(exponent));\n rgba.b = rgba.b - 128.0 * gte128.x;\n res = dot(rgba, SCALE_FACTOR) * exp2(round(exponent-23.0)) + res;\n res *= gte128.y * -2.0 + 1.0;\n return res;\n}\n\nvec4 encode32(float f) {\n float F = abs(f);\n float sign = f < 0.0 ? 1.0 : 0.0;\n float exponent = floor(log2(F));\n float mantissa = (exp2(-exponent) * F);\n // exponent += floor(log2(mantissa));\n vec4 rgba = vec4(F * exp2(23.0-exponent)) * SCALE_FACTOR_INV;\n rgba.rg = integerMod(rgba.rg, 256.0);\n rgba.b = integerMod(rgba.b, 128.0);\n rgba.a = exponent*0.5 + 63.5;\n rgba.ba += vec2(integerMod(exponent+127.0, 2.0), sign) * 128.0;\n rgba = floor(rgba);\n rgba *= 0.003921569; // 1/255\n __ENCODE32_ENDIANNESS__;\n return rgba;\n}\n// Dragons end here\n\nfloat decode(vec4 rgba, int x, int bitRatio) {\n if (bitRatio == 1) {\n return decode32(rgba);\n }\n __DECODE32_ENDIANNESS__;\n int channel = integerMod(x, bitRatio);\n if (bitRatio == 4) {\n if (channel == 0) return rgba.r * 255.0;\n if (channel == 1) return rgba.g * 255.0;\n if (channel == 2) return rgba.b * 255.0;\n if (channel == 3) return rgba.a * 255.0;\n }\n else {\n if (channel == 0) return rgba.r * 255.0 + rgba.g * 65280.0;\n if (channel == 1) return rgba.b * 255.0 + rgba.a * 65280.0;\n }\n}\n\nint index;\nivec3 threadId;\n\nivec3 indexTo3D(int idx, ivec3 texDim) {\n int z = int(idx / (texDim.x * texDim.y));\n idx -= z * int(texDim.x * texDim.y);\n int y = int(idx / texDim.x);\n int x = int(integerMod(idx, texDim.x));\n return ivec3(x, y, z);\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int z, int y, int x) {\n ivec3 xyz = ivec3(x, y, z);\n __GET_WRAPAROUND__;\n int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);\n __GET_TEXTURE_CHANNEL__;\n int w = texSize.x;\n vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;\n __GET_TEXTURE_INDEX__;\n vec4 texel = texture2D(tex, st / vec2(texSize));\n __GET_RESULT__;\n \n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int z, int y, int x) {\n ivec3 xyz = ivec3(x, y, z);\n __GET_WRAPAROUND__;\n int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);\n __GET_TEXTURE_CHANNEL__;\n int w = texSize.x;\n vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;\n __GET_TEXTURE_INDEX__;\n return texture2D(tex, st / vec2(texSize));\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int y, int x) {\n return get(tex, texSize, texDim, bitRatio, int(0), y, x);\n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int y, int x) {\n return getImage2D(tex, texSize, texDim, int(0), y, x);\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int x) {\n return get(tex, texSize, texDim, bitRatio, int(0), int(0), x);\n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int x) {\n return getImage2D(tex, texSize, texDim, int(0), int(0), x);\n}\n\n\nvec4 actualColor;\nvoid color(float r, float g, float b, float a) {\n actualColor = vec4(r,g,b,a);\n}\n\nvoid color(float r, float g, float b) {\n color(r,g,b,1.0);\n}\n\nvoid color(sampler2D image) {\n actualColor = texture2D(image, vTexCoord);\n}\n\n__MAIN_PARAMS__;\n__MAIN_CONSTANTS__;\n__KERNEL__;\n\nvoid main(void) {\n index = int(vTexCoord.s * float(uTexSize.x)) + int(vTexCoord.t * float(uTexSize.y)) * uTexSize.x;\n __MAIN_RESULT__;\n}"; -},{}],17:[function(require,module,exports){ -"use strict"; + }, { + key: 'astVariableDeclarator', + value: function astVariableDeclarator(ivardecNode, retArr) { + this.astGeneric(ivardecNode.id, retArr); + if (ivardecNode.init !== null) { + retArr.push('='); + this.astGeneric(ivardecNode.init, retArr); + } + return retArr; + } -module.exports = "precision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nattribute vec2 aPos;\nattribute vec2 aTexCoord;\n\nvarying vec2 vTexCoord;\nuniform vec2 ratio;\n\nvoid main(void) {\n gl_Position = vec4((aPos + vec2(1)) * ratio + vec2(-1), 0, 1);\n vTexCoord = aTexCoord;\n}"; -},{}],18:[function(require,module,exports){ -'use strict'; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + }, { + key: 'astIfStatement', + value: function astIfStatement(ifNode, retArr) { + retArr.push('if ('); + this.astGeneric(ifNode.test, retArr); + retArr.push(')'); + if (ifNode.consequent.type === 'BlockStatement') { + this.astGeneric(ifNode.consequent, retArr); + } else { + retArr.push(' {\n'); + this.astGeneric(ifNode.consequent, retArr); + retArr.push('\n}\n'); + } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + if (ifNode.alternate) { + retArr.push('else '); + if (ifNode.alternate.type === 'BlockStatement') { + this.astGeneric(ifNode.alternate, retArr); + } else { + retArr.push(' {\n'); + this.astGeneric(ifNode.alternate, retArr); + retArr.push('\n}\n'); + } + } + return retArr; + } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + }, { + key: 'astBreakStatement', + value: function astBreakStatement(brNode, retArr) { + retArr.push('break;\n'); + return retArr; + } -var WebGLKernel = require('./kernel'); -var utils = require('../../core/utils'); -module.exports = function (_WebGLKernel) { - _inherits(WebGLValidatorKernel, _WebGLKernel); + }, { + key: 'astContinueStatement', + value: function astContinueStatement(crNode, retArr) { + retArr.push('continue;\n'); + return retArr; + } - function WebGLValidatorKernel() { - _classCallCheck(this, WebGLValidatorKernel); - return _possibleConstructorReturn(this, (WebGLValidatorKernel.__proto__ || Object.getPrototypeOf(WebGLValidatorKernel)).apply(this, arguments)); - } + }, { + key: 'astLogicalExpression', + value: function astLogicalExpression(logNode, retArr) { + retArr.push('('); + this.astGeneric(logNode.left, retArr); + retArr.push(logNode.operator); + this.astGeneric(logNode.right, retArr); + retArr.push(')'); + return retArr; + } - _createClass(WebGLValidatorKernel, [{ - key: 'validateOptions', + }, { + key: 'astUpdateExpression', + value: function astUpdateExpression(uNode, retArr) { + if (uNode.prefix) { + retArr.push(uNode.operator); + this.astGeneric(uNode.argument, retArr); + } else { + this.astGeneric(uNode.argument, retArr); + retArr.push(uNode.operator); + } - value: function validateOptions() { - this.texSize = utils.dimToTexSize({ - floatTextures: this.floatTextures, - floatOutput: this.floatOutput - }, this.output, true); + return retArr; } - }]); - - return WebGLValidatorKernel; -}(WebGLKernel); -},{"../../core/utils":32,"./kernel":14}],19:[function(require,module,exports){ -'use strict'; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + }, { + key: 'astUnaryExpression', + value: function astUnaryExpression(uNode, retArr) { + if (uNode.prefix) { + retArr.push(uNode.operator); + this.astGeneric(uNode.argument, retArr); + } else { + this.astGeneric(uNode.argument, retArr); + retArr.push(uNode.operator); + } -var FunctionBuilderBase = require('../function-builder-base'); -var WebGL2FunctionNode = require('./function-node'); + return retArr; + } -module.exports = function (_FunctionBuilderBase) { - _inherits(WebGL2FunctionBuilder, _FunctionBuilderBase); - function WebGL2FunctionBuilder() { - _classCallCheck(this, WebGL2FunctionBuilder); + }, { + key: 'astThisExpression', + value: function astThisExpression(tNode, retArr) { + retArr.push('this'); + return retArr; + } - var _this = _possibleConstructorReturn(this, (WebGL2FunctionBuilder.__proto__ || Object.getPrototypeOf(WebGL2FunctionBuilder)).call(this)); - _this.Node = WebGL2FunctionNode; - return _this; - } + }, { + key: 'astMemberExpression', + value: function astMemberExpression(mNode, retArr) { + debugLog("[in] astMemberExpression " + mNode.object.type); + if (mNode.computed) { + if (mNode.object.type === 'Identifier' || mNode.object.type === 'MemberExpression' && mNode.object.object.object && mNode.object.object.object.type === 'ThisExpression' && mNode.object.object.property.name === 'constants') { + var reqName = mNode.object.name; + var funcName = this.functionName || 'kernel'; + var assumeNotTexture = false; - return WebGL2FunctionBuilder; -}(FunctionBuilderBase); -},{"../function-builder-base":6,"./function-node":20}],20:[function(require,module,exports){ -'use strict'; + if (this.paramNames) { + var idx = this.paramNames.indexOf(reqName); + if (idx >= 0 && this.paramTypes[idx] === 'float') { + assumeNotTexture = true; + } + } + debugLog("- astMemberExpression " + reqName + " " + funcName); + if (assumeNotTexture) { + this.astGeneric(mNode.object, retArr); + retArr.push('[int('); + this.astGeneric(mNode.property, retArr); + retArr.push(')]'); + } else { + var isInGetParams = this.isState('in-get-call-parameters'); + var multiMemberExpression = this.isState('multi-member-expression'); + if (multiMemberExpression) { + this.popState('multi-member-expression'); + } + this.pushState('not-in-get-call-parameters'); -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + var variableType = null; + if (mNode.object.name) { + variableType = this.getParamType(mNode.object.name); + } else if (mNode.object && mNode.object.object && mNode.object.object.object && mNode.object.object.object.type === 'ThisExpression') { + variableType = this.getConstantType(mNode.object.property.name); + } + switch (variableType) { + case 'vec4': + this.astGeneric(mNode.object, retArr); + retArr.push('['); + retArr.push(mNode.property.raw); + retArr.push(']'); + if (multiMemberExpression) { + this.popState('not-in-get-call-parameters'); + } + break; + case 'HTMLImageArray': + retArr.push('getImage3D('); + this.astGeneric(mNode.object, retArr); + retArr.push(', ivec2('); + this.astGeneric(mNode.object, retArr); + retArr.push('Size[0],'); + this.astGeneric(mNode.object, retArr); + retArr.push('Size[1]), ivec3('); + this.astGeneric(mNode.object, retArr); + retArr.push('Dim[0],'); + this.astGeneric(mNode.object, retArr); + retArr.push('Dim[1],'); + this.astGeneric(mNode.object, retArr); + retArr.push('Dim[2]'); + retArr.push('), '); + this.popState('not-in-get-call-parameters'); + this.pushState('in-get-call-parameters'); + this.astGeneric(mNode.property, retArr); + if (!multiMemberExpression) { + this.popState('in-get-call-parameters'); + } + retArr.push(')'); + break; + case 'HTMLImage': + retArr.push('getImage2D('); + this.astGeneric(mNode.object, retArr); + retArr.push(', ivec2('); + this.astGeneric(mNode.object, retArr); + retArr.push('Size[0],'); + this.astGeneric(mNode.object, retArr); + retArr.push('Size[1]), ivec3('); + this.astGeneric(mNode.object, retArr); + retArr.push('Dim[0],'); + this.astGeneric(mNode.object, retArr); + retArr.push('Dim[1],'); + this.astGeneric(mNode.object, retArr); + retArr.push('Dim[2]'); + retArr.push('), '); + this.popState('not-in-get-call-parameters'); + this.pushState('in-get-call-parameters'); + this.astGeneric(mNode.property, retArr); + if (!multiMemberExpression) { + this.popState('in-get-call-parameters'); + } + retArr.push(')'); + break; + default: + if (isInGetParams) { + retArr.push('int('); + } + retArr.push('get('); + this.astGeneric(mNode.object, retArr); + retArr.push(', ivec2('); + this.astGeneric(mNode.object, retArr); + retArr.push('Size[0],'); + this.astGeneric(mNode.object, retArr); + retArr.push('Size[1]), ivec3('); + this.astGeneric(mNode.object, retArr); + retArr.push('Dim[0],'); + this.astGeneric(mNode.object, retArr); + retArr.push('Dim[1],'); + this.astGeneric(mNode.object, retArr); + retArr.push('Dim[2]'); + retArr.push('), '); + this.astGeneric(mNode.object, retArr); + retArr.push('BitRatio'); + retArr.push(', '); + this.popState('not-in-get-call-parameters'); + this.pushState('in-get-call-parameters'); + this.astGeneric(mNode.property, retArr); + if (!multiMemberExpression) { + this.popState('in-get-call-parameters'); + } + retArr.push(')'); + if (isInGetParams) { + retArr.push(')'); + } + break; + } + } + } else { -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + debugLog("- astMemberExpression obj:", mNode.object); + var stateStackDepth = this.states.length; + var startedInGetParamsState = this.isState('in-get-call-parameters'); + if (!startedInGetParamsState) { + this.pushState('multi-member-expression'); + } + this.astGeneric(mNode.object, retArr); + if (this.isState('multi-member-expression')) { + this.popState('multi-member-expression'); + } + var changedGetParamsState = !startedInGetParamsState && this.isState('in-get-call-parameters'); + var last = retArr.pop(); + retArr.push(','); + debugLog("- astMemberExpression prop:", mNode.property); + var shouldPopParamState = this.isState('should-pop-in-get-call-parameters'); + if (shouldPopParamState) { + this.popState('should-pop-in-get-call-parameters'); + } + this.astGeneric(mNode.property, retArr); + retArr.push(last); -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + if (changedGetParamsState) { + this.pushState('should-pop-in-get-call-parameters'); + } else if (shouldPopParamState) { + this.popState('in-get-call-parameters'); + } + } + } else { -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + var unrolled = this.astMemberExpressionUnroll(mNode); + var unrolled_lc = unrolled.toLowerCase(); + debugLog("- astMemberExpression unrolled:", unrolled); + if (unrolled.indexOf(constantsPrefix) === 0) { + unrolled = 'constants_' + unrolled.slice(constantsPrefix.length); + } -var WebGLFunctionNode = require('../web-gl/function-node'); + var castFloat = !this.isState('in-get-call-parameters'); -var constantsPrefix = 'this.constants.'; + switch (unrolled_lc) { + case 'this.thread.x': + castFloat && retArr.push('float('); + retArr.push('threadId.x'); + castFloat && retArr.push(')'); + break; + case 'this.thread.y': + castFloat && retArr.push('float('); + retArr.push('threadId.y'); + castFloat && retArr.push(')'); + break; + case 'this.thread.z': + castFloat && retArr.push('float('); + retArr.push('threadId.z'); + castFloat && retArr.push(')'); + break; + case 'this.output.x': + retArr.push(this.output[0] + '.0'); + break; + case 'this.output.y': + retArr.push(this.output[1] + '.0'); + break; + case 'this.output.z': + retArr.push(this.output[2] + '.0'); + break; + default: + if (mNode.object && mNode.object.name && this.declarations[mNode.object.name]) { + retArr.push('user_'); + } + retArr.push(unrolled); + } + } + debugLog("[out] astMemberExpression " + mNode.object.type); + return retArr; + } + }, { + key: 'astSequenceExpression', + value: function astSequenceExpression(sNode, retArr) { + for (var i = 0; i < sNode.expressions.length; i++) { + if (i > 0) { + retArr.push(','); + } + this.astGeneric(sNode.expressions, retArr); + } + return retArr; + } -var DECODE32_ENCODE32 = /decode32\(\s+encode32\(/g; -var ENCODE32_DECODE32 = /encode32\(\s+decode32\(/g; -module.exports = function (_WebGLFunctionNode) { - _inherits(WebGL2FunctionNode, _WebGLFunctionNode); + }, { + key: 'astCallExpression', + value: function astCallExpression(ast, retArr) { + if (ast.callee) { + var funcName = this.astMemberExpressionUnroll(ast.callee); - function WebGL2FunctionNode() { - _classCallCheck(this, WebGL2FunctionNode); + if (funcName.indexOf(jsMathPrefix) === 0) { + funcName = funcName.slice(jsMathPrefix.length); + } - return _possibleConstructorReturn(this, (WebGL2FunctionNode.__proto__ || Object.getPrototypeOf(WebGL2FunctionNode)).apply(this, arguments)); - } + if (funcName.indexOf(localPrefix) === 0) { + funcName = funcName.slice(localPrefix.length); + } - _createClass(WebGL2FunctionNode, [{ - key: 'generate', - value: function generate() { - if (this.debug) { - console.log(this); - } - if (this.prototypeOnly) { - return WebGL2FunctionNode.astFunctionPrototype(this.getJsAST(), [], this).join('').trim(); - } else { - this.functionStringArray = this.astGeneric(this.getJsAST(), [], this); - } - this.functionString = webGlRegexOptimize(this.functionStringArray.join('').trim()); - return this.functionString; - } + if (funcName === 'atan2') { + funcName = 'atan'; + } + if (this.calledFunctions.indexOf(funcName) < 0) { + this.calledFunctions.push(funcName); + } + if (!this.hasOwnProperty('funcName')) { + this.calledFunctionsArguments[funcName] = []; + } - }, { - key: 'astFunctionExpression', - value: function astFunctionExpression(ast, retArr) { + var functionArguments = []; + this.calledFunctionsArguments[funcName].push(functionArguments); - if (this.isRootKernel) { - retArr.push('void'); - this.kernalAst = ast; - } else { - retArr.push(this.returnType); - } - retArr.push(' '); - retArr.push(this.functionName); - retArr.push('('); + retArr.push(funcName); - if (!this.isRootKernel) { - for (var i = 0; i < this.paramNames.length; ++i) { - var paramName = this.paramNames[i]; + retArr.push('('); + for (var i = 0; i < ast.arguments.length; ++i) { + var argument = ast.arguments[i]; if (i > 0) { retArr.push(', '); } - var type = this.getParamType(paramName); - switch (type) { - case 'Texture': - case 'Input': - case 'Array': - case 'HTMLImage': - retArr.push('sampler2D'); - break; - default: - retArr.push('float'); + this.astGeneric(argument, retArr); + if (argument.type === 'Identifier') { + var paramIndex = this.paramNames.indexOf(argument.name); + if (paramIndex === -1) { + functionArguments.push(null); + } else { + functionArguments.push({ + name: argument.name, + type: this.paramTypes[paramIndex] + }); + } + } else { + functionArguments.push(null); } - - retArr.push(' '); - retArr.push('user_'); - retArr.push(paramName); } - } - retArr.push(') {\n'); + retArr.push(')'); - for (var _i = 0; _i < ast.body.body.length; ++_i) { - this.astGeneric(ast.body.body[_i], retArr); - retArr.push('\n'); + return retArr; } - retArr.push('}\n'); + throw this.astErrorOutput('Unknown CallExpression', ast); + return retArr; } }, { - key: 'astIdentifierExpression', - value: function astIdentifierExpression(idtNode, retArr) { - if (idtNode.type !== 'Identifier') { - throw this.astErrorOutput('IdentifierExpression - not an Identifier', idtNode); - } + key: 'astArrayExpression', + value: function astArrayExpression(arrNode, retArr) { + var arrLen = arrNode.elements.length; - var castFloat = !this.isState('in-get-call-parameters'); + retArr.push('float[' + arrLen + ']('); + for (var i = 0; i < arrLen; ++i) { + if (i > 0) { + retArr.push(', '); + } + var subNode = arrNode.elements[i]; + this.astGeneric(subNode, retArr); + } + retArr.push(')'); - switch (idtNode.name) { - case 'gpu_threadX': - castFloat && retArr.push('float('); - retArr.push('threadId.x'); - castFloat && retArr.push(')'); - break; - case 'gpu_threadY': - castFloat && retArr.push('float('); - retArr.push('threadId.y'); - castFloat && retArr.push(')'); - break; - case 'gpu_threadZ': - castFloat && retArr.push('float('); - retArr.push('threadId.z'); - castFloat && retArr.push(')'); - break; - case 'gpu_outputX': - retArr.push('uOutputDim.x'); - break; - case 'gpu_outputY': - retArr.push('uOutputDim.y'); - break; - case 'gpu_outputZ': - retArr.push('uOutputDim.z'); - break; - case 'Infinity': - retArr.push('intBitsToFloat(2139095039)'); - break; - default: - if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { - this.pushParameter(retArr, 'constants_' + idtNode.name); - } else { - var userParamName = this.getUserParamName(idtNode.name); - if (userParamName !== null) { - this.pushParameter(retArr, 'user_' + userParamName); - } else { - this.pushParameter(retArr, 'user_' + idtNode.name); - } - } + return retArr; + + } + + + }, { + key: 'getFunctionPrototypeString', + value: function getFunctionPrototypeString() { + if (this.webGlFunctionPrototypeString) { + return this.webGlFunctionPrototypeString; + } + return this.webGlFunctionPrototypeString = this.generate(); + } + }, { + key: 'build', + value: function build() { + return this.getFunctionPrototypeString().length > 0; + } + }], [{ + key: 'astFunctionPrototype', + value: function astFunctionPrototype(ast, retArr) { + if (this.isRootKernel || this.isSubKernel) { + return retArr; + } + + retArr.push(this.returnType); + retArr.push(' '); + retArr.push(this.functionName); + retArr.push('('); + + for (var i = 0; i < this.paramNames.length; ++i) { + if (i > 0) { + retArr.push(', '); + } + + retArr.push(this.paramTypes[i]); + retArr.push(' '); + retArr.push('user_'); + retArr.push(this.paramNames[i]); } + retArr.push(');\n'); + return retArr; } }]); - return WebGL2FunctionNode; -}(WebGLFunctionNode); + return WebGLFunctionNode; +}(FunctionNodeBase); + +function isIdentifierKernelParam(paramName, ast, funcParam) { + return funcParam.paramNames.indexOf(paramName) !== -1; +} + +function ensureIndentifierType(paramName, expectedType, ast, funcParam) { + var start = ast.loc.start; + + if (!isIdentifierKernelParam(paramName) && expectedType !== 'float') { + throw new Error('Error unexpected identifier ' + paramName + ' on line ' + start.line); + } else { + var actualType = funcParam.paramTypes[funcParam.paramNames.indexOf(paramName)]; + if (actualType !== expectedType) { + throw new Error('Error unexpected identifier ' + paramName + ' on line ' + start.line); + } + } +} function webGlRegexOptimize(inStr) { return inStr.replace(DECODE32_ENCODE32, '((').replace(ENCODE32_DECODE32, '(('); } -},{"../web-gl/function-node":12}],21:[function(require,module,exports){ +},{"../../core/utils":32,"../function-node-base":7}],20:[function(require,module,exports){ +'use strict'; + +var utils = require('../../core/utils'); +var kernelRunShortcut = require('../kernel-run-shortcut'); + +function removeFnNoise(fn) { + if (/^function /.test(fn)) { + fn = fn.substring(9); + } + return fn.replace(/[_]typeof/g, 'typeof'); +} + +function removeNoise(str) { + return str.replace(/[_]typeof/g, 'typeof'); +} + +module.exports = function (gpuKernel, name) { + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform2ivCache = {};\n\t\t this.uniform3fvCache = {};\n\t\t this.uniform3ivCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setupConstants() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.setupConstants.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2iv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n\t\t ' + removeFnNoise(gpuKernel.setUniform3iv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; +}; +},{"../../core/utils":32,"../kernel-run-shortcut":9}],21:[function(require,module,exports){ 'use strict'; +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -4658,84 +4419,255 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var WebGLKernel = require('../web-gl/kernel'); +var KernelBase = require('../kernel-base'); var utils = require('../../core/utils'); var Texture = require('../../core/texture'); var fragShaderString = require('./shader-frag'); var vertShaderString = require('./shader-vert'); +var kernelString = require('./kernel-string'); +var canvases = []; +var maxTexSizes = {}; -module.exports = function (_WebGLKernel) { - _inherits(WebGL2Kernel, _WebGLKernel); +module.exports = function (_KernelBase) { + _inherits(WebGLKernel, _KernelBase); - function WebGL2Kernel() { - _classCallCheck(this, WebGL2Kernel); + _createClass(WebGLKernel, null, [{ + key: 'fragShaderString', + get: function get() { + return fragShaderString; + } + }, { + key: 'vertShaderString', + get: function get() { + return vertShaderString; + } - return _possibleConstructorReturn(this, (WebGL2Kernel.__proto__ || Object.getPrototypeOf(WebGL2Kernel)).apply(this, arguments)); + }]); + + function WebGLKernel(fnString, settings) { + _classCallCheck(this, WebGLKernel); + + var _this = _possibleConstructorReturn(this, (WebGLKernel.__proto__ || Object.getPrototypeOf(WebGLKernel)).call(this, fnString, settings)); + + _this.textureCache = {}; + _this.threadDim = {}; + _this.programUniformLocationCache = {}; + _this.framebuffer = null; + + _this.buffer = null; + _this.program = null; + _this.outputToTexture = settings.outputToTexture; + _this.endianness = utils.systemEndianness(); + _this.subKernelOutputTextures = null; + _this.subKernelOutputVariableNames = null; + _this.argumentsLength = 0; + _this.constantsLength = 0; + _this.compiledFragShaderString = null; + _this.compiledVertShaderString = null; + _this.fragShader = null; + _this.vertShader = null; + _this.drawBuffersMap = null; + _this.outputTexture = null; + _this.maxTexSize = null; + _this.uniform1fCache = {}; + _this.uniform1iCache = {}; + _this.uniform2fCache = {}; + _this.uniform2fvCache = {}; + _this.uniform2ivCache = {}; + _this.uniform3fvCache = {}; + _this.uniform3ivCache = {}; + if (!_this._webGl) _this._webGl = _this.initWebGl(); + return _this; } - _createClass(WebGL2Kernel, [{ + _createClass(WebGLKernel, [{ key: 'initWebGl', value: function initWebGl() { - return utils.initWebGl2(this.getCanvas()); + return utils.initWebGl(this.getCanvas()); + } + + + }, { + key: 'validateOptions', + value: function validateOptions() { + var isFloatReadPixel = utils.isFloatReadPixelsSupported(); + if (this.floatTextures === true && !utils.OES_texture_float) { + throw new Error('Float textures are not supported on this browser'); + } else if (this.floatOutput === true && this.floatOutputForce !== true && !isFloatReadPixel) { + throw new Error('Float texture outputs are not supported on this browser'); + } else if (this.floatTextures === undefined && utils.OES_texture_float) { + this.floatTextures = true; + this.floatOutput = isFloatReadPixel; + } + + var hasIntegerDivisionBug = utils.hasIntegerDivisionAccuracyBug(); + if (this.fixIntegerDivisionAccuracy === null) { + this.fixIntegerDivisionAccuracy = hasIntegerDivisionBug; + } else if (this.fixIntegerDivisionAccuracy && !hasIntegerDivisionBug) { + this.fixIntegerDivisionAccuracy = false; + } + + utils.checkOutput(this.output); + + if (!this.output || this.output.length === 0) { + if (arguments.length !== 1) { + throw new Error('Auto output only supported for kernels with only one input'); + } + + var argType = utils.getArgumentType(arguments[0]); + if (argType === 'Array') { + this.output = utils.getDimensions(argType); + } else if (argType === 'Texture') { + this.output = arguments[0].output; + } else { + throw new Error('Auto output not supported for input type: ' + argType); + } + } + + this.texSize = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, this.output, true); + + if (this.graphical) { + if (this.output.length !== 2) { + throw new Error('Output must have 2 dimensions on graphical mode'); + } + + if (this.floatOutput) { + this.floatOutput = false; + console.warn('Cannot use graphical mode and float output at the same time'); + } + + this.texSize = utils.clone(this.output); + } else if (this.floatOutput === undefined && utils.OES_texture_float) { + this.floatOutput = true; + } + } + }, { + key: 'updateMaxTexSize', + value: function updateMaxTexSize() { + var texSize = this.texSize; + var canvas = this._canvas; + if (this.maxTexSize === null) { + var canvasIndex = canvases.indexOf(canvas); + if (canvasIndex === -1) { + canvasIndex = canvases.length; + canvases.push(canvas); + maxTexSizes[canvasIndex] = [texSize[0], texSize[1]]; + } + this.maxTexSize = maxTexSizes[canvasIndex]; + } + if (this.maxTexSize[0] < texSize[0]) { + this.maxTexSize[0] = texSize[0]; + } + if (this.maxTexSize[1] < texSize[1]) { + this.maxTexSize[1] = texSize[1]; + } } - }, { - key: 'validateOptions', - value: function validateOptions() { - var isFloatReadPixel = utils.isFloatReadPixelsSupportedWebGL2(); - if (this.floatOutput === true && this.floatOutputForce !== true && !isFloatReadPixel) { - throw new Error('Float texture outputs are not supported on this browser'); - } else if (this.floatTextures === undefined) { - this.floatTextures = true; - this.floatOutput = isFloatReadPixel; + + }, { + key: 'build', + value: function build() { + this.validateOptions(); + this.setupConstants(); + this.setupParams(arguments); + this.updateMaxTexSize(); + var texSize = this.texSize; + var gl = this._webGl; + var canvas = this._canvas; + gl.enable(gl.SCISSOR_TEST); + gl.viewport(0, 0, this.maxTexSize[0], this.maxTexSize[1]); + canvas.width = this.maxTexSize[0]; + canvas.height = this.maxTexSize[1]; + var threadDim = this.threadDim = utils.clone(this.output); + while (threadDim.length < 3) { + threadDim.push(1); + } + + if (this.functionBuilder) this._addKernels(); + + var compiledVertShaderString = this._getVertShaderString(arguments); + var vertShader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(vertShader, compiledVertShaderString); + gl.compileShader(vertShader); + if (this.vertShader) {} + this.vertShader = vertShader; + + var compiledFragShaderString = this._getFragShaderString(arguments); + var fragShader = gl.createShader(gl.FRAGMENT_SHADER); + gl.shaderSource(fragShader, compiledFragShaderString); + gl.compileShader(fragShader); + this.fragShader = fragShader; + + if (!gl.getShaderParameter(vertShader, gl.COMPILE_STATUS)) { + console.log(compiledVertShaderString); + console.error('An error occurred compiling the shaders: ' + gl.getShaderInfoLog(vertShader)); + throw new Error('Error compiling vertex shader'); + } + if (!gl.getShaderParameter(fragShader, gl.COMPILE_STATUS)) { + console.log(compiledFragShaderString); + console.error('An error occurred compiling the shaders: ' + gl.getShaderInfoLog(fragShader)); + throw new Error('Error compiling fragment shader'); } - var hasIntegerDivisionBug = utils.hasIntegerDivisionAccuracyBug(); - if (this.fixIntegerDivisionAccuracy == null) { - this.fixIntegerDivisionAccuracy = hasIntegerDivisionBug; - } else if (this.fixIntegerDivisionAccuracy && !hasIntegerDivisionBug) { - this.fixIntegerDivisionAccuracy = false; + if (this.debug) { + console.log('Options:'); + console.dir(this); + console.log('GLSL Shader Output:'); + console.log(compiledFragShaderString); } - utils.checkOutput(this.output); + var program = this.program = gl.createProgram(); + gl.attachShader(program, vertShader); + gl.attachShader(program, fragShader); + gl.linkProgram(program); + this.framebuffer = gl.createFramebuffer(); + this.framebuffer.width = texSize[0]; + this.framebuffer.height = texSize[1]; - if (!this.output || this.output.length === 0) { - if (arguments.length !== 1) { - throw new Error('Auto output only supported for kernels with only one input'); - } + var vertices = new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]); + var texCoords = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]); - var argType = utils.getArgumentType(arguments[0]); - if (argType === 'Array') { - this.output = utils.getDimensions(argType); - } else if (argType === 'Texture') { - this.output = arguments[0].output; - } else { - throw new Error('Auto output not supported for input type: ' + argType); - } + var texCoordOffset = vertices.byteLength; + + var buffer = this.buffer; + if (!buffer) { + buffer = this.buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, vertices.byteLength + texCoords.byteLength, gl.STATIC_DRAW); + } else { + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); } - this.texSize = utils.dimToTexSize({ - floatTextures: this.floatTextures, - floatOutput: this.floatOutput - }, this.output, true); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, vertices); + gl.bufferSubData(gl.ARRAY_BUFFER, texCoordOffset, texCoords); - if (this.graphical) { - if (this.output.length !== 2) { - throw new Error('Output must have 2 dimensions on graphical mode'); - } + var aPosLoc = gl.getAttribLocation(this.program, 'aPos'); + gl.enableVertexAttribArray(aPosLoc); + gl.vertexAttribPointer(aPosLoc, 2, gl.FLOAT, gl.FALSE, 0, 0); + var aTexCoordLoc = gl.getAttribLocation(this.program, 'aTexCoord'); + gl.enableVertexAttribArray(aTexCoordLoc); + gl.vertexAttribPointer(aTexCoordLoc, 2, gl.FLOAT, gl.FALSE, 0, texCoordOffset); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer); - if (this.floatOutput) { - this.floatOutput = false; - console.warn('Cannot use graphical mode and float output at the same time'); + for (var p in this.constants) { + var value = this.constants[p]; + var type = utils.getArgumentType(value); + if (type === 'Decimal' || type === 'Integer') { + continue; } - - this.texSize = utils.clone(this.output); - } else if (this.floatOutput === undefined) { - this.floatOutput = true; + gl.useProgram(this.program); + this._addConstant(this.constants[p], type, p); + this.constantsLength++; } - if (this.floatOutput || this.floatOutputForce) { - this._webGl.getExtension('EXT_color_buffer_float'); + if (!this.outputImmutable) { + this._setupOutputTexture(); + if (this.subKernelOutputVariableNames !== null && this.subKernelOutputVariableNames.length > 0) { + this._setupSubOutputTextures(this.subKernelOutputVariableNames.length); + } } } @@ -4755,7 +4687,7 @@ module.exports = function (_WebGLKernel) { gl.scissor(0, 0, texSize[0], texSize[1]); if (!this.hardcodeConstants) { - this.setUniform3iv('uOutputDim', new Int32Array(this.threadDim)); + this.setUniform3iv('uOutputDim', this.threadDim); this.setUniform2iv('uTexSize', texSize); } @@ -4784,7 +4716,7 @@ module.exports = function (_WebGLKernel) { this.subKernelOutputTextures = []; this._setupSubOutputTextures(this.subKernelOutputVariableNames.length); } - gl.drawBuffers(this.drawBuffersMap); + this.drawBuffers.drawBuffersWEBGL(this.drawBuffersMap); } gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); @@ -4815,6 +4747,44 @@ module.exports = function (_WebGLKernel) { } + }, { + key: 'renderOutput', + value: function renderOutput(outputTexture) { + var texSize = this.texSize; + var gl = this._webGl; + var threadDim = this.threadDim; + var output = this.output; + if (this.outputToTexture) { + return new Texture(outputTexture, texSize, this.threadDim, output, this._webGl); + } else { + var result = void 0; + if (this.floatOutput) { + var w = texSize[0]; + var h = Math.ceil(texSize[1] / 4); + result = new Float32Array(w * h * 4); + gl.readPixels(0, 0, w, h, gl.RGBA, gl.FLOAT, result); + } else { + var bytes = new Uint8Array(texSize[0] * texSize[1] * 4); + gl.readPixels(0, 0, texSize[0], texSize[1], gl.RGBA, gl.UNSIGNED_BYTE, bytes); + result = new Float32Array(bytes.buffer); + } + + result = result.subarray(0, threadDim[0] * threadDim[1] * threadDim[2]); + + if (output.length === 1) { + return result; + } else if (output.length === 2) { + return utils.splitArray(result, output[0]); + } else if (output.length === 3) { + var cube = utils.splitArray(result, output[0] * output[1]); + return cube.map(function (x) { + return utils.splitArray(x, output[0]); + }); + } + } + } + + }, { key: 'getOutputTexture', value: function getOutputTexture() { @@ -4828,14 +4798,14 @@ module.exports = function (_WebGLKernel) { var gl = this._webGl; var texSize = this.texSize; var texture = this.outputTexture = this._webGl.createTexture(); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); if (this.floatOutput) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); } else { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); } @@ -4854,14 +4824,14 @@ module.exports = function (_WebGLKernel) { var texture = this._webGl.createTexture(); textures.push(texture); drawBuffersMap.push(gl.COLOR_ATTACHMENT0 + i + 1); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length + i); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length + i); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); if (this.floatOutput) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); } else { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); } @@ -4870,6 +4840,153 @@ module.exports = function (_WebGLKernel) { } + }, { + key: 'getArgumentTexture', + value: function getArgumentTexture(name) { + return this.getTextureCache('ARGUMENT_' + name); + } + + + }, { + key: 'getTextureCache', + value: function getTextureCache(name) { + if (this.textureCache.hasOwnProperty(name)) { + return this.textureCache[name]; + } + return this.textureCache[name] = this._webGl.createTexture(); + } + + + }, { + key: 'detachTextureCache', + value: function detachTextureCache(name) { + delete this.textureCache[name]; + } + }, { + key: 'setUniform1f', + value: function setUniform1f(name, value) { + if (this.uniform1fCache.hasOwnProperty(name)) { + var cache = this.uniform1fCache[name]; + if (value === cache) { + return; + } + } + this.uniform1fCache[name] = value; + var loc = this.getUniformLocation(name); + this._webGl.uniform1f(loc, value); + } + }, { + key: 'setUniform1i', + value: function setUniform1i(name, value) { + if (this.uniform1iCache.hasOwnProperty(name)) { + var cache = this.uniform1iCache[name]; + if (value === cache) { + return; + } + } + this.uniform1iCache[name] = value; + var loc = this.getUniformLocation(name); + this._webGl.uniform1i(loc, value); + } + }, { + key: 'setUniform2f', + value: function setUniform2f(name, value1, value2) { + if (this.uniform2fCache.hasOwnProperty(name)) { + var cache = this.uniform2fCache[name]; + if (value1 === cache[0] && value2 === cache[1]) { + return; + } + } + this.uniform2fCache[name] = [value1, value2]; + var loc = this.getUniformLocation(name); + this._webGl.uniform2f(loc, value1, value2); + } + }, { + key: 'setUniform2fv', + value: function setUniform2fv(name, value) { + if (this.uniform2fvCache.hasOwnProperty(name)) { + var cache = this.uniform2fvCache[name]; + if (value[0] === cache[0] && value[1] === cache[1]) { + return; + } + } + this.uniform2fvCache[name] = value; + var loc = this.getUniformLocation(name); + this._webGl.uniform2fv(loc, value); + } + }, { + key: 'setUniform2iv', + value: function setUniform2iv(name, value) { + if (this.uniform2ivCache.hasOwnProperty(name)) { + var cache = this.uniform2ivCache[name]; + if (value[0] === cache[0] && value[1] === cache[1]) { + return; + } + } + this.uniform2ivCache[name] = value; + var loc = this.getUniformLocation(name); + this._webGl.uniform2iv(loc, value); + } + }, { + key: 'setUniform3fv', + value: function setUniform3fv(name, value) { + if (this.uniform3fvCache.hasOwnProperty(name)) { + var cache = this.uniform3fvCache[name]; + if (value[0] === cache[0] && value[1] === cache[1] && value[2] === cache[2]) { + return; + } + } + this.uniform3fvCache[name] = value; + var loc = this.getUniformLocation(name); + this._webGl.uniform3fv(loc, value); + } + }, { + key: 'setUniform3iv', + value: function setUniform3iv(name, value) { + if (this.uniform3ivCache.hasOwnProperty(name)) { + var cache = this.uniform3ivCache[name]; + if (value[0] === cache[0] && value[1] === cache[1] && value[2] === cache[2]) { + return; + } + } + this.uniform3ivCache[name] = value; + var loc = this.getUniformLocation(name); + this._webGl.uniform3iv(loc, value); + } + + + }, { + key: 'getUniformLocation', + value: function getUniformLocation(name) { + if (this.programUniformLocationCache.hasOwnProperty(name)) { + return this.programUniformLocationCache[name]; + } + return this.programUniformLocationCache[name] = this._webGl.getUniformLocation(this.program, name); + } + + + }, { + key: '_getFragShaderArtifactMap', + value: function _getFragShaderArtifactMap(args) { + return { + HEADER: this._getHeaderString(), + LOOP_MAX: this._getLoopMaxString(), + CONSTANTS: this._getConstantsString(), + DECODE32_ENDIANNESS: this._getDecode32EndiannessString(), + ENCODE32_ENDIANNESS: this._getEncode32EndiannessString(), + DIVIDE_WITH_INTEGER_CHECK: this._getDivideWithIntegerCheckString(), + GET_WRAPAROUND: this._getGetWraparoundString(), + GET_TEXTURE_CHANNEL: this._getGetTextureChannelString(), + GET_TEXTURE_INDEX: this._getGetTextureIndexString(), + GET_RESULT: this._getGetResultString(), + MAIN_PARAMS: this._getMainParamsString(args), + MAIN_CONSTANTS: this._getMainConstantsString(), + KERNEL: this._getKernelString(), + MAIN_RESULT: this._getMainResultString() + }; + } + + }, { key: '_addArgument', value: function _addArgument(value, type, name) { @@ -4886,7 +5003,7 @@ module.exports = function (_WebGLKernel) { floatTextures: this.floatTextures, floatOutput: this.floatOutput }, dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -4895,13 +5012,13 @@ module.exports = function (_WebGLKernel) { var length = size[0] * size[1]; - var _formatArrayTransfer = this._formatArrayTransfer(value, length), - valuesFlat = _formatArrayTransfer.valuesFlat, - bitRatio = _formatArrayTransfer.bitRatio; + var _formatArrayTransfer2 = this._formatArrayTransfer(value, length), + valuesFlat = _formatArrayTransfer2.valuesFlat, + bitRatio = _formatArrayTransfer2.bitRatio; var buffer = void 0; if (this.floatTextures) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); } else { buffer = new Uint8Array(valuesFlat.buffer); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); @@ -4929,7 +5046,7 @@ module.exports = function (_WebGLKernel) { floatTextures: this.floatTextures, floatOutput: this.floatOutput }, _dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -4938,12 +5055,12 @@ module.exports = function (_WebGLKernel) { var _length = _size[0] * _size[1]; - var _formatArrayTransfer2 = this._formatArrayTransfer(value.value, _length), - _valuesFlat = _formatArrayTransfer2.valuesFlat, - _bitRatio = _formatArrayTransfer2.bitRatio; + var _formatArrayTransfer3 = this._formatArrayTransfer(value.value, _length), + _valuesFlat = _formatArrayTransfer3.valuesFlat, + _bitRatio = _formatArrayTransfer3.bitRatio; if (this.floatTextures) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, _size[0], _size[1], 0, gl.RGBA, gl.FLOAT, inputArray); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size[0], _size[1], 0, gl.RGBA, gl.FLOAT, inputArray); } else { var _buffer = new Uint8Array(_valuesFlat.buffer); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size[0] / _bitRatio, _size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, _buffer); @@ -4963,7 +5080,7 @@ module.exports = function (_WebGLKernel) { var _dim2 = [inputImage.width, inputImage.height, 1]; var _size2 = [inputImage.width, inputImage.height]; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -4980,85 +5097,287 @@ module.exports = function (_WebGLKernel) { this.setUniform1i('user_' + name, this.argumentsLength); break; } - case 'HTMLImageArray': + case 'Texture': { - var inputImages = value; - var _dim3 = [inputImages[0].width, inputImages[0].height, inputImages.length]; - var _size3 = [inputImages[0].width, inputImages[0].height]; + var inputTexture = value; + var _dim3 = inputTexture.dimensions; + var _size3 = inputTexture.size; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); + gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); - gl.bindTexture(gl.TEXTURE_2D_ARRAY, argumentTexture); - gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); - var _mipLevel = 0; - var _internalFormat = gl.RGBA; - var width = inputImages[0].width; - var height = inputImages[0].height; - var textureDepth = inputImages.length; - var border = 0; - var _srcFormat = gl.RGBA; - var _srcType = gl.UNSIGNED_BYTE; - gl.texImage3D(gl.TEXTURE_2D_ARRAY, _mipLevel, _internalFormat, width, height, textureDepth, border, _srcFormat, _srcType, null); - for (var i = 0; i < inputImages.length; i++) { - var xOffset = 0; - var yOffset = 0; - var imageDepth = 1; - gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, _mipLevel, xOffset, yOffset, i, inputImages[i].width, inputImages[i].height, imageDepth, _srcFormat, _srcType, inputImages[i]); - } this.setUniform3iv('user_' + name + 'Dim', _dim3); this.setUniform2iv('user_' + name + 'Size', _size3); + this.setUniform1i('user_' + name + 'BitRatio', 1); this.setUniform1i('user_' + name, this.argumentsLength); break; } + default: + throw new Error('Input type not supported (WebGL): ' + value); + } + this.argumentsLength++; + } + + + }, { + key: '_addConstant', + value: function _addConstant(value, type, name) { + var gl = this._webGl; + var argumentTexture = this.getArgumentTexture(name); + if (value instanceof Texture) { + type = 'Texture'; + } + switch (type) { + case 'Array': + { + var dim = utils.getDimensions(value, true); + var size = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, dim); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + var length = size[0] * size[1]; + + var _formatArrayTransfer4 = this._formatArrayTransfer(value, length), + valuesFlat = _formatArrayTransfer4.valuesFlat, + bitRatio = _formatArrayTransfer4.bitRatio; + + var buffer = void 0; + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); + } else { + buffer = new Uint8Array(valuesFlat.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + } + + if (!this.hardcodeConstants) { + this.setUniform3iv('constants_' + name + 'Dim', dim); + this.setUniform2iv('constants_' + name + 'Size', size); + } + this.setUniform1i('constants_' + name + 'BitRatio', bitRatio); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'Integer': + case 'Float': + { + this.setUniform1f('constants_' + name, value); + break; + } + case 'Input': + { + var input = value; + var _dim4 = input.size; + var _size4 = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, _dim4); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + var _length2 = _size4[0] * _size4[1]; + + var _formatArrayTransfer5 = this._formatArrayTransfer(value.value, _length2), + _valuesFlat2 = _formatArrayTransfer5.valuesFlat, + _bitRatio2 = _formatArrayTransfer5.bitRatio; + + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size4[0], _size4[1], 0, gl.RGBA, gl.FLOAT, inputArray); + } else { + var _buffer2 = new Uint8Array(_valuesFlat2.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size4[0] / _bitRatio2, _size4[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, _buffer2); + } + + if (!this.hardcodeConstants) { + this.setUniform3iv('constants_' + name + 'Dim', _dim4); + this.setUniform2iv('constants_' + name + 'Size', _size4); + } + this.setUniform1i('constants_' + name + 'BitRatio', _bitRatio2); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'HTMLImage': + { + var inputImage = value; + var _dim5 = [inputImage.width, inputImage.height, 1]; + var _size5 = [inputImage.width, inputImage.height]; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + var mipLevel = 0; + var internalFormat = gl.RGBA; + var srcFormat = gl.RGBA; + var srcType = gl.UNSIGNED_BYTE; + gl.texImage2D(gl.TEXTURE_2D, mipLevel, internalFormat, srcFormat, srcType, inputImage); + this.setUniform3iv('constants_' + name + 'Dim', _dim5); + this.setUniform2iv('constants_' + name + 'Size', _size5); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } case 'Texture': { var inputTexture = value; - var _dim4 = inputTexture.dimensions; - var _size4 = inputTexture.size; + var _dim6 = inputTexture.dimensions; + var _size6 = inputTexture.size; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); - this.setUniform3iv('user_' + name + 'Dim', _dim4); - this.setUniform2iv('user_' + name + 'Size', _size4); - this.setUniform1i('user_' + name + 'BitRatio', 1); - this.setUniform1i('user_' + name, this.argumentsLength); + this.setUniform3iv('constants_' + name + 'Dim', _dim6); + this.setUniform2iv('constants_' + name + 'Size', _size6); + this.setUniform1i('constants_' + name + 'BitRatio', 1); + this.setUniform1i('constants_' + name, this.constantsLength); break; } default: throw new Error('Input type not supported (WebGL): ' + value); } - this.argumentsLength++; } }, { - key: '_getGetResultString', - value: function _getGetResultString() { - if (!this.floatTextures) { - return ' return decode(texel, x, bitRatio);'; - } - return ' return texel[channel];'; + key: '_formatArrayTransfer', + value: function _formatArrayTransfer(value, length) { + var bitRatio = 1; + var valuesFlat = value; + if (utils.isArray(value[0]) || this.floatTextures) { + valuesFlat = new Float32Array(length); + utils.flattenTo(value, valuesFlat); + } else { + + switch (value.constructor) { + case Uint8Array: + case Int8Array: + bitRatio = 4; + break; + case Uint16Array: + case Int16Array: + bitRatio = 2; + case Float32Array: + case Int32Array: + break; + + default: + valuesFlat = new Float32Array(length); + utils.flattenTo(value, valuesFlat); + } + } + return { + bitRatio: bitRatio, + valuesFlat: valuesFlat + }; + } + + + }, { + key: '_getHeaderString', + value: function _getHeaderString() { + return this.subKernels !== null || this.subKernelProperties !== null ? + '#extension GL_EXT_draw_buffers : require\n' : ''; + } + + + }, { + key: '_getLoopMaxString', + value: function _getLoopMaxString() { + return this.loopMaxIterations ? ' ' + parseInt(this.loopMaxIterations) + '.0;\n' : ' 1000.0;\n'; + } + + + }, { + key: '_getConstantsString', + value: function _getConstantsString() { + var result = []; + var threadDim = this.threadDim; + var texSize = this.texSize; + if (this.hardcodeConstants) { + result.push('ivec3 uOutputDim = ivec3(' + threadDim[0] + ',' + threadDim[1] + ', ' + threadDim[2] + ')', 'ivec2 uTexSize = ivec2(' + texSize[0] + ', ' + texSize[1] + ')'); + } else { + result.push('uniform ivec3 uOutputDim', 'uniform ivec2 uTexSize'); + } + + return this._linesToString(result); + } + + + }, { + key: '_getTextureCoordinate', + value: function _getTextureCoordinate() { + var names = this.subKernelOutputVariableNames; + if (names === null || names.length < 1) { + return 'varying vec2 vTexCoord;\n'; + } else { + return 'out vec2 vTexCoord;\n'; + } + } + + + }, { + key: '_getDecode32EndiannessString', + value: function _getDecode32EndiannessString() { + return this.endianness === 'LE' ? '' : ' rgba.rgba = rgba.abgr;\n'; + } + + + }, { + key: '_getEncode32EndiannessString', + value: function _getEncode32EndiannessString() { + return this.endianness === 'LE' ? '' : ' rgba.rgba = rgba.abgr;\n'; + } + + + }, { + key: '_getDivideWithIntegerCheckString', + value: function _getDivideWithIntegerCheckString() { + return this.fixIntegerDivisionAccuracy ? '\n\t\t\t float div_with_int_check(float x, float y) {\n\t\t\t if (floor(x) == x && floor(y) == y && integerMod(x, y) == 0.0) {\n\t\t\t return float(int(x)/int(y));\n\t\t\t }\n\t\t\t return x / y;\n\t\t\t}\n\t\t\t' : ''; + } + + + }, { + key: '_getGetWraparoundString', + value: function _getGetWraparoundString() { + return this.wraparound ? ' xyz = mod(xyz, texDim);\n' : ''; } }, { - key: '_getHeaderString', - value: function _getHeaderString() { - return ''; + key: '_getGetTextureChannelString', + value: function _getGetTextureChannelString() { + if (!this.floatTextures) return ''; + + return this._linesToString([' int channel = integerMod(index, 4)', ' index = index / 4']); } }, { - key: '_getTextureCoordinate', - value: function _getTextureCoordinate() { - var names = this.subKernelOutputVariableNames; - if (names === null || names.length < 1) { - return 'in highp vec2 vTexCoord;\n'; - } else { - return 'out highp vec2 vTexCoord;\n'; + key: '_getGetTextureIndexString', + value: function _getGetTextureIndexString() { + return this.floatTextures ? ' index = index / 4;\n' : ''; + } + + + }, { + key: '_getGetResultString', + value: function _getGetResultString() { + if (!this.floatTextures) { + return ' return decode(texel, x, bitRatio);'; } + return this._linesToString([' if (channel == 0) return texel.r', ' if (channel == 1) return texel.g', ' if (channel == 2) return texel.b', ' if (channel == 3) return texel.a']); } @@ -5080,26 +5399,53 @@ module.exports = function (_WebGLKernel) { floatOutput: this.floatOutput }, paramDim); - result.push('uniform highp sampler2D user_' + paramName, 'highp ivec2 user_' + paramName + 'Size = ivec2(' + paramSize[0] + ', ' + paramSize[1] + ')', 'highp ivec3 user_' + paramName + 'Dim = ivec3(' + paramDim[0] + ', ' + paramDim[1] + ', ' + paramDim[2] + ')', 'uniform highp int user_' + paramName + 'BitRatio'); - - if (paramType === 'Array') { - result.push('uniform highp int user_' + paramName + 'BitRatio'); - } + result.push('uniform sampler2D user_' + paramName, 'ivec2 user_' + paramName + 'Size = vec2(' + paramSize[0] + ', ' + paramSize[1] + ')', 'ivec3 user_' + paramName + 'Dim = vec3(' + paramDim[0] + ', ' + paramDim[1] + ', ' + paramDim[2] + ')', 'uniform int user_' + paramName + 'BitRatio'); } else if (paramType === 'Integer') { - result.push('highp float user_' + paramName + ' = ' + param + '.0'); + result.push('float user_' + paramName + ' = ' + param + '.0'); } else if (paramType === 'Float') { - result.push('highp float user_' + paramName + ' = ' + param); + result.push('float user_' + paramName + ' = ' + param); } } else { if (paramType === 'Array' || paramType === 'Texture' || paramType === 'Input' || paramType === 'HTMLImage') { - result.push('uniform highp sampler2D user_' + paramName, 'uniform highp ivec2 user_' + paramName + 'Size', 'uniform highp ivec3 user_' + paramName + 'Dim'); + result.push('uniform sampler2D user_' + paramName, 'uniform ivec2 user_' + paramName + 'Size', 'uniform ivec3 user_' + paramName + 'Dim'); if (paramType !== 'HTMLImage') { - result.push('uniform highp int user_' + paramName + 'BitRatio'); + result.push('uniform int user_' + paramName + 'BitRatio'); } - } else if (paramType === 'HTMLImageArray') { - result.push('uniform highp sampler2DArray user_' + paramName, 'uniform highp ivec2 user_' + paramName + 'Size', 'uniform highp ivec3 user_' + paramName + 'Dim'); } else if (paramType === 'Integer' || paramType === 'Float') { result.push('uniform float user_' + paramName); + } else { + throw new Error('Param type ' + paramType + ' not supported in WebGL, only WebGL2'); + } + } + } + return this._linesToString(result); + } + + + }, { + key: '_getMainConstantsString', + value: function _getMainConstantsString() { + var result = []; + if (this.constants) { + for (var name in this.constants) { + if (!this.constants.hasOwnProperty(name)) continue; + var value = this.constants[name]; + var type = utils.getArgumentType(value); + switch (type) { + case 'Integer': + result.push('const float constants_' + name + ' = ' + parseInt(value) + '.0'); + break; + case 'Float': + result.push('const float constants_' + name + ' = ' + parseFloat(value)); + break; + case 'Array': + case 'Input': + case 'HTMLImage': + case 'Texture': + result.push('uniform sampler2D constants_' + name, 'uniform ivec2 constants_' + name + 'Size', 'uniform ivec3 constants_' + name + 'Dim', 'uniform int constants_' + name + 'BitRatio'); + break; + default: + throw new Error('Unsupported constant ' + name + ' type ' + type); } } } @@ -5114,12 +5460,10 @@ module.exports = function (_WebGLKernel) { var names = this.subKernelOutputVariableNames; if (names !== null) { result.push('float kernelResult = 0.0'); - result.push('layout(location = 0) out vec4 data0'); for (var i = 0; i < names.length; i++) { - result.push('float ' + names[i] + ' = 0.0', 'layout(location = ' + (i + 1) + ') out vec4 data' + (i + 1)); + result.push('float ' + names[i] + ' = 0.0'); } } else { - result.push('out vec4 data0'); result.push('float kernelResult = 0.0'); } @@ -5138,7 +5482,7 @@ module.exports = function (_WebGLKernel) { } if (this.graphical) { - result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' data0 = actualColor'); + result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' gl_FragColor = actualColor'); } else if (this.floatOutput) { var channels = ['r', 'g', 'b', 'a']; @@ -5147,13 +5491,13 @@ module.exports = function (_WebGLKernel) { result.push(' kernel()'); if (names) { - result.push(' data0.' + channels[i] + ' = kernelResult'); + result.push(' gl_FragData[0].' + channels[i] + ' = kernelResult'); for (var j = 0; j < names.length; ++j) { - result.push(' data' + (j + 1) + '.' + channels[i] + ' = ' + names[j]); + result.push(' gl_FragData[' + (j + 1) + '].' + channels[i] + ' = ' + names[j]); } } else { - result.push(' data0.' + channels[i] + ' = kernelResult'); + result.push(' gl_FragColor.' + channels[i] + ' = kernelResult'); } if (i < channels.length - 1) { @@ -5163,18 +5507,41 @@ module.exports = function (_WebGLKernel) { } else if (names !== null) { result.push(' threadId = indexTo3D(index, uOutputDim)'); result.push(' kernel()'); - result.push(' data0 = encode32(kernelResult)'); + result.push(' gl_FragData[0] = encode32(kernelResult)'); for (var _i2 = 0; _i2 < names.length; _i2++) { - result.push(' data' + (_i2 + 1) + ' = encode32(' + names[_i2] + ')'); + result.push(' gl_FragData[' + (_i2 + 1) + '] = encode32(' + names[_i2] + ')'); } } else { - result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' data0 = encode32(kernelResult)'); + result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' gl_FragColor = encode32(kernelResult)'); } return this._linesToString(result); } + }, { + key: '_linesToString', + value: function _linesToString(lines) { + if (lines.length > 0) { + return lines.join(';\n') + ';\n'; + } else { + return '\n'; + } + } + + + }, { + key: '_replaceArtifacts', + value: function _replaceArtifacts(src, map) { + return src.replace(/[ ]*__([A-Z]+[0-9]*([_]?[A-Z])*)__;\n/g, function (match, artifact) { + if (map.hasOwnProperty(artifact)) { + return map[artifact]; + } + throw 'unhandled artifact ' + artifact; + }); + } + + }, { key: '_addKernels', value: function _addKernels() { @@ -5197,23 +5564,39 @@ module.exports = function (_WebGLKernel) { loopMaxIterations: this.loopMaxIterations, paramNames: this.paramNames, paramTypes: this.paramTypes, + constantTypes: this.constantTypes, fixIntegerDivisionAccuracy: this.fixIntegerDivisionAccuracy }); if (this.subKernels !== null) { - this.subKernelOutputTextures = []; + var drawBuffers = this.drawBuffers = gl.getExtension('WEBGL_draw_buffers'); + if (!drawBuffers) throw new Error('could not instantiate draw buffers extension'); this.subKernelOutputVariableNames = []; this.subKernels.forEach(function (subKernel) { return _this2._addSubKernel(subKernel); }); } else if (this.subKernelProperties !== null) { - this.subKernelOutputTextures = []; + var _drawBuffers = this.drawBuffers = gl.getExtension('WEBGL_draw_buffers'); + if (!_drawBuffers) throw new Error('could not instantiate draw buffers extension'); this.subKernelOutputVariableNames = []; Object.keys(this.subKernelProperties).forEach(function (property) { return _this2._addSubKernel(_this2.subKernelProperties[property]); }); } } + }, { + key: '_addSubKernel', + value: function _addSubKernel(subKernel) { + this.functionBuilder.addSubKernel(subKernel, { + prototypeOnly: false, + constants: this.constants, + output: this.output, + debug: this.debug, + loopMaxIterations: this.loopMaxIterations, + fixIntegerDivisionAccuracy: this.fixIntegerDivisionAccuracy + }); + this.subKernelOutputVariableNames.push(subKernel.name + 'Result'); + } }, { @@ -5234,21 +5617,70 @@ module.exports = function (_WebGLKernel) { } return this.compiledVertShaderString = this.constructor.vertShaderString; } - }], [{ - key: 'fragShaderString', - get: function get() { - return fragShaderString; + + + }, { + key: 'toString', + value: function toString() { + return kernelString(this); } }, { - key: 'vertShaderString', - get: function get() { - return vertShaderString; + key: 'addFunction', + value: function addFunction(fn) { + this.functionBuilder.addFunction(null, fn); + } + }, { + key: 'destroy', + value: function destroy(removeCanvasReferences) { + _get(WebGLKernel.prototype.__proto__ || Object.getPrototypeOf(WebGLKernel.prototype), 'destroy', this).call(this); + if (this.outputTexture) { + this._webGl.deleteTexture(this.outputTexture); + } + if (this.buffer) { + this._webGl.deleteBuffer(this.buffer); + } + if (this.framebuffer) { + this._webGl.deleteFramebuffer(this.framebuffer); + } + + if (this.vertShader) { + this._webGl.deleteShader(this.vertShader); + } + + if (this.fragShader) { + this._webGl.deleteShader(this.fragShader); + } + + if (this.program) { + this._webGl.deleteProgram(this.program); + } + + var keys = Object.keys(this.textureCache); + + for (var i = 0; i < keys.length; i++) { + var name = keys[i]; + this._webGl.deleteTexture(this.textureCache[name]); + } + + if (this.subKernelOutputTextures) { + for (var _i3 = 0; _i3 < this.subKernelOutputTextures.length; _i3++) { + this._webGl.deleteTexture(this.subKernelOutputTextures[_i3]); + } + } + if (removeCanvasReferences) { + var idx = canvases.indexOf(this._canvas); + if (idx >= 0) { + canvases[idx] = null; + maxTexSizes[idx] = null; + } + } + delete this._webGl; } }]); - return WebGL2Kernel; -}(WebGLKernel); -},{"../../core/texture":30,"../../core/utils":32,"../web-gl/kernel":14,"./shader-frag":23,"./shader-vert":24}],22:[function(require,module,exports){ + return WebGLKernel; +}(KernelBase); +},{"../../core/texture":30,"../../core/utils":32,"../kernel-base":8,"./kernel-string":20,"./shader-frag":23,"./shader-vert":24}],22:[function(require,module,exports){ 'use strict'; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); @@ -5260,41 +5692,41 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var RunnerBase = require('../runner-base'); -var WebGL2FunctionBuilder = require('./function-builder'); -var WebGL2Kernel = require('./kernel'); +var WebGLKernel = require('./kernel'); +var WebGLFunctionBuilder = require('./function-builder'); module.exports = function (_RunnerBase) { - _inherits(WebGL2Runner, _RunnerBase); + _inherits(WebGLRunner, _RunnerBase); - function WebGL2Runner(settings) { - _classCallCheck(this, WebGL2Runner); + function WebGLRunner(settings) { + _classCallCheck(this, WebGLRunner); - var _this = _possibleConstructorReturn(this, (WebGL2Runner.__proto__ || Object.getPrototypeOf(WebGL2Runner)).call(this, new WebGL2FunctionBuilder(), settings)); + var _this = _possibleConstructorReturn(this, (WebGLRunner.__proto__ || Object.getPrototypeOf(WebGLRunner)).call(this, new WebGLFunctionBuilder(), settings)); - _this.Kernel = WebGL2Kernel; + _this.Kernel = WebGLKernel; _this.kernel = null; return _this; } - _createClass(WebGL2Runner, [{ + _createClass(WebGLRunner, [{ key: 'getMode', value: function getMode() { return 'gpu'; } }]); - return WebGL2Runner; + return WebGLRunner; }(RunnerBase); -},{"../runner-base":10,"./function-builder":19,"./kernel":21}],23:[function(require,module,exports){ +},{"../runner-base":10,"./function-builder":18,"./kernel":21}],23:[function(require,module,exports){ "use strict"; -module.exports = "#version 300 es\n__HEADER__;\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nconst float LOOP_MAX = __LOOP_MAX__;\n\n__CONSTANTS__;\n\nin vec2 vTexCoord;\n\nvec2 integerMod(vec2 x, float y) {\n vec2 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec3 integerMod(vec3 x, float y) {\n vec3 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec4 integerMod(vec4 x, vec4 y) {\n vec4 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nfloat integerMod(float x, float y) {\n float res = floor(mod(x, y));\n return res * (res > floor(y) - 1.0 ? 0.0 : 1.0);\n}\n\nint integerMod(int x, int y) {\n return x - (y * int(x/y));\n}\n\n__DIVIDE_WITH_INTEGER_CHECK__;\n\n// Here be dragons!\n// DO NOT OPTIMIZE THIS CODE\n// YOU WILL BREAK SOMETHING ON SOMEBODY'S MACHINE\n// LEAVE IT AS IT IS, LEST YOU WASTE YOUR OWN TIME\nconst vec2 MAGIC_VEC = vec2(1.0, -256.0);\nconst vec4 SCALE_FACTOR = vec4(1.0, 256.0, 65536.0, 0.0);\nconst vec4 SCALE_FACTOR_INV = vec4(1.0, 0.00390625, 0.0000152587890625, 0.0); // 1, 1/256, 1/65536\nfloat decode32(vec4 rgba) {\n __DECODE32_ENDIANNESS__;\n rgba *= 255.0;\n vec2 gte128;\n gte128.x = rgba.b >= 128.0 ? 1.0 : 0.0;\n gte128.y = rgba.a >= 128.0 ? 1.0 : 0.0;\n float exponent = 2.0 * rgba.a - 127.0 + dot(gte128, MAGIC_VEC);\n float res = exp2(round(exponent));\n rgba.b = rgba.b - 128.0 * gte128.x;\n res = dot(rgba, SCALE_FACTOR) * exp2(round(exponent-23.0)) + res;\n res *= gte128.y * -2.0 + 1.0;\n return res;\n}\n\nvec4 encode32(float f) {\n float F = abs(f);\n float sign = f < 0.0 ? 1.0 : 0.0;\n float exponent = floor(log2(F));\n float mantissa = (exp2(-exponent) * F);\n // exponent += floor(log2(mantissa));\n vec4 rgba = vec4(F * exp2(23.0-exponent)) * SCALE_FACTOR_INV;\n rgba.rg = integerMod(rgba.rg, 256.0);\n rgba.b = integerMod(rgba.b, 128.0);\n rgba.a = exponent*0.5 + 63.5;\n rgba.ba += vec2(integerMod(exponent+127.0, 2.0), sign) * 128.0;\n rgba = floor(rgba);\n rgba *= 0.003921569; // 1/255\n __ENCODE32_ENDIANNESS__;\n return rgba;\n}\n// Dragons end here\n\nfloat decode(vec4 rgba, int x, int bitRatio) {\n if (bitRatio == 1) {\n return decode32(rgba);\n }\n __DECODE32_ENDIANNESS__;\n int channel = integerMod(x, bitRatio);\n if (bitRatio == 4) {\n return rgba[channel] * 255.0;\n }\n else {\n return rgba[channel*2] * 255.0 + rgba[channel*2 + 1] * 65280.0;\n }\n}\n\nint index;\nivec3 threadId;\n\nivec3 indexTo3D(int idx, ivec3 texDim) {\n int z = int(idx / (texDim.x * texDim.y));\n idx -= z * int(texDim.x * texDim.y);\n int y = int(idx / texDim.x);\n int x = int(integerMod(idx, texDim.x));\n return ivec3(x, y, z);\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int z, int y, int x) {\n ivec3 xyz = ivec3(x, y, z);\n __GET_WRAPAROUND__;\n int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);\n __GET_TEXTURE_CHANNEL__;\n int w = texSize.x;\n vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;\n __GET_TEXTURE_INDEX__;\n vec4 texel = texture(tex, st / vec2(texSize));\n __GET_RESULT__;\n \n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int z, int y, int x) {\n ivec3 xyz = ivec3(x, y, z);\n __GET_WRAPAROUND__;\n int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);\n __GET_TEXTURE_CHANNEL__;\n int w = texSize.x;\n vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;\n __GET_TEXTURE_INDEX__;\n return texture(tex, st / vec2(texSize));\n}\n\nvec4 getImage3D(sampler2DArray tex, ivec2 texSize, ivec3 texDim, int z, int y, int x) {\n ivec3 xyz = ivec3(x, y, z);\n __GET_WRAPAROUND__;\n int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);\n __GET_TEXTURE_CHANNEL__;\n int w = texSize.x;\n vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;\n __GET_TEXTURE_INDEX__;\n return texture(tex, vec3(st / vec2(texSize), z));\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int y, int x) {\n return get(tex, texSize, texDim, bitRatio, 0, y, x);\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int x) {\n return get(tex, texSize, texDim, bitRatio, 0, 0, x);\n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int y, int x) {\n return getImage2D(tex, texSize, texDim, 0, y, x);\n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int x) {\n return getImage2D(tex, texSize, texDim, 0, 0, x);\n}\n\nvec4 actualColor;\nvoid color(float r, float g, float b, float a) {\n actualColor = vec4(r,g,b,a);\n}\n\nvoid color(float r, float g, float b) {\n color(r,g,b,1.0);\n}\n\n__MAIN_PARAMS__;\n__MAIN_CONSTANTS__;\n__KERNEL__;\n\nvoid main(void) {\n index = int(vTexCoord.s * float(uTexSize.x)) + int(vTexCoord.t * float(uTexSize.y)) * uTexSize.x;\n __MAIN_RESULT__;\n}"; +module.exports = "__HEADER__;\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nconst float LOOP_MAX = __LOOP_MAX__;\n\n__CONSTANTS__;\n\nvarying vec2 vTexCoord;\n\nvec4 round(vec4 x) {\n return floor(x + 0.5);\n}\n\nfloat round(float x) {\n return floor(x + 0.5);\n}\n\nvec2 integerMod(vec2 x, float y) {\n vec2 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec3 integerMod(vec3 x, float y) {\n vec3 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec4 integerMod(vec4 x, vec4 y) {\n vec4 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nfloat integerMod(float x, float y) {\n float res = floor(mod(x, y));\n return res * (res > floor(y) - 1.0 ? 0.0 : 1.0);\n}\n\nint integerMod(int x, int y) {\n return x - (y * int(x / y));\n}\n\n__DIVIDE_WITH_INTEGER_CHECK__;\n\n// Here be dragons!\n// DO NOT OPTIMIZE THIS CODE\n// YOU WILL BREAK SOMETHING ON SOMEBODY'S MACHINE\n// LEAVE IT AS IT IS, LEST YOU WASTE YOUR OWN TIME\nconst vec2 MAGIC_VEC = vec2(1.0, -256.0);\nconst vec4 SCALE_FACTOR = vec4(1.0, 256.0, 65536.0, 0.0);\nconst vec4 SCALE_FACTOR_INV = vec4(1.0, 0.00390625, 0.0000152587890625, 0.0); // 1, 1/256, 1/65536\nfloat decode32(vec4 rgba) {\n __DECODE32_ENDIANNESS__;\n rgba *= 255.0;\n vec2 gte128;\n gte128.x = rgba.b >= 128.0 ? 1.0 : 0.0;\n gte128.y = rgba.a >= 128.0 ? 1.0 : 0.0;\n float exponent = 2.0 * rgba.a - 127.0 + dot(gte128, MAGIC_VEC);\n float res = exp2(round(exponent));\n rgba.b = rgba.b - 128.0 * gte128.x;\n res = dot(rgba, SCALE_FACTOR) * exp2(round(exponent-23.0)) + res;\n res *= gte128.y * -2.0 + 1.0;\n return res;\n}\n\nvec4 encode32(float f) {\n float F = abs(f);\n float sign = f < 0.0 ? 1.0 : 0.0;\n float exponent = floor(log2(F));\n float mantissa = (exp2(-exponent) * F);\n // exponent += floor(log2(mantissa));\n vec4 rgba = vec4(F * exp2(23.0-exponent)) * SCALE_FACTOR_INV;\n rgba.rg = integerMod(rgba.rg, 256.0);\n rgba.b = integerMod(rgba.b, 128.0);\n rgba.a = exponent*0.5 + 63.5;\n rgba.ba += vec2(integerMod(exponent+127.0, 2.0), sign) * 128.0;\n rgba = floor(rgba);\n rgba *= 0.003921569; // 1/255\n __ENCODE32_ENDIANNESS__;\n return rgba;\n}\n// Dragons end here\n\nfloat decode(vec4 rgba, int x, int bitRatio) {\n if (bitRatio == 1) {\n return decode32(rgba);\n }\n __DECODE32_ENDIANNESS__;\n int channel = integerMod(x, bitRatio);\n if (bitRatio == 4) {\n if (channel == 0) return rgba.r * 255.0;\n if (channel == 1) return rgba.g * 255.0;\n if (channel == 2) return rgba.b * 255.0;\n if (channel == 3) return rgba.a * 255.0;\n }\n else {\n if (channel == 0) return rgba.r * 255.0 + rgba.g * 65280.0;\n if (channel == 1) return rgba.b * 255.0 + rgba.a * 65280.0;\n }\n}\n\nint index;\nivec3 threadId;\n\nivec3 indexTo3D(int idx, ivec3 texDim) {\n int z = int(idx / (texDim.x * texDim.y));\n idx -= z * int(texDim.x * texDim.y);\n int y = int(idx / texDim.x);\n int x = int(integerMod(idx, texDim.x));\n return ivec3(x, y, z);\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int z, int y, int x) {\n ivec3 xyz = ivec3(x, y, z);\n __GET_WRAPAROUND__;\n int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);\n __GET_TEXTURE_CHANNEL__;\n int w = texSize.x;\n vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;\n __GET_TEXTURE_INDEX__;\n vec4 texel = texture2D(tex, st / vec2(texSize));\n __GET_RESULT__;\n \n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int z, int y, int x) {\n ivec3 xyz = ivec3(x, y, z);\n __GET_WRAPAROUND__;\n int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);\n __GET_TEXTURE_CHANNEL__;\n int w = texSize.x;\n vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;\n __GET_TEXTURE_INDEX__;\n return texture2D(tex, st / vec2(texSize));\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int y, int x) {\n return get(tex, texSize, texDim, bitRatio, int(0), y, x);\n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int y, int x) {\n return getImage2D(tex, texSize, texDim, int(0), y, x);\n}\n\nfloat get(sampler2D tex, ivec2 texSize, ivec3 texDim, int bitRatio, int x) {\n return get(tex, texSize, texDim, bitRatio, int(0), int(0), x);\n}\n\nvec4 getImage2D(sampler2D tex, ivec2 texSize, ivec3 texDim, int x) {\n return getImage2D(tex, texSize, texDim, int(0), int(0), x);\n}\n\n\nvec4 actualColor;\nvoid color(float r, float g, float b, float a) {\n actualColor = vec4(r,g,b,a);\n}\n\nvoid color(float r, float g, float b) {\n color(r,g,b,1.0);\n}\n\nvoid color(sampler2D image) {\n actualColor = texture2D(image, vTexCoord);\n}\n\n__MAIN_PARAMS__;\n__MAIN_CONSTANTS__;\n__KERNEL__;\n\nvoid main(void) {\n index = int(vTexCoord.s * float(uTexSize.x)) + int(vTexCoord.t * float(uTexSize.y)) * uTexSize.x;\n __MAIN_RESULT__;\n}"; },{}],24:[function(require,module,exports){ "use strict"; -module.exports = "#version 300 es\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nin vec2 aPos;\nin vec2 aTexCoord;\n\nout vec2 vTexCoord;\nuniform vec2 ratio;\n\nvoid main(void) {\n gl_Position = vec4((aPos + vec2(1)) * ratio + vec2(-1), 0, 1);\n vTexCoord = aTexCoord;\n}"; +module.exports = "precision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nattribute vec2 aPos;\nattribute vec2 aTexCoord;\n\nvarying vec2 vTexCoord;\nuniform vec2 ratio;\n\nvoid main(void) {\n gl_Position = vec4((aPos + vec2(1)) * ratio + vec2(-1), 0, 1);\n vTexCoord = aTexCoord;\n}"; },{}],25:[function(require,module,exports){ 'use strict'; @@ -5310,20 +5742,19 @@ var WebGLKernel = require('./kernel'); var utils = require('../../core/utils'); module.exports = function (_WebGLKernel) { - _inherits(WebGL2ValidatorKernel, _WebGLKernel); + _inherits(WebGLValidatorKernel, _WebGLKernel); - function WebGL2ValidatorKernel() { - _classCallCheck(this, WebGL2ValidatorKernel); + function WebGLValidatorKernel() { + _classCallCheck(this, WebGLValidatorKernel); - return _possibleConstructorReturn(this, (WebGL2ValidatorKernel.__proto__ || Object.getPrototypeOf(WebGL2ValidatorKernel)).apply(this, arguments)); + return _possibleConstructorReturn(this, (WebGLValidatorKernel.__proto__ || Object.getPrototypeOf(WebGLValidatorKernel)).apply(this, arguments)); } - _createClass(WebGL2ValidatorKernel, [{ + _createClass(WebGLValidatorKernel, [{ key: 'validateOptions', value: function validateOptions() { - this._webGl.getExtension('EXT_color_buffer_float'); this.texSize = utils.dimToTexSize({ floatTextures: this.floatTextures, floatOutput: this.floatOutput @@ -5331,7 +5762,7 @@ module.exports = function (_WebGLKernel) { } }]); - return WebGL2ValidatorKernel; + return WebGLValidatorKernel; }(WebGLKernel); },{"../../core/utils":32,"./kernel":21}],26:[function(require,module,exports){ 'use strict'; @@ -5674,7 +6105,7 @@ var GPU = function (_GPUCore) { Object.assign(GPU, GPUCore); module.exports = GPU; -},{"../backend/cpu/runner":5,"../backend/web-gl/runner":15,"../backend/web-gl/validator-kernel":18,"../backend/web-gl2/runner":22,"../backend/web-gl2/validator-kernel":25,"./gpu-core":27,"./utils":32}],29:[function(require,module,exports){ +},{"../backend/cpu/runner":5,"../backend/web-gl/runner":22,"../backend/web-gl/validator-kernel":25,"../backend/web-gl2/runner":14,"../backend/web-gl2/validator-kernel":17,"./gpu-core":27,"./utils":32}],29:[function(require,module,exports){ "use strict"; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -6333,6 +6764,7 @@ module.exports = Utils; },{"../index":33,"./input":29,"./texture":30,"./utils-core":31}],33:[function(require,module,exports){ 'use strict'; +console.log("Testing"); var GPU = require('./core/gpu'); var alias = require('./core/alias'); var utils = require('./core/utils'); @@ -6383,7 +6815,7 @@ if (typeof module !== 'undefined') { if (typeof window !== 'undefined') { window.GPU = GPU; } -},{"./backend/cpu/function-builder":1,"./backend/cpu/function-node":2,"./backend/cpu/kernel":4,"./backend/cpu/runner":5,"./backend/web-gl/function-builder":11,"./backend/web-gl/function-node":12,"./backend/web-gl/kernel":14,"./backend/web-gl/runner":15,"./backend/web-gl2/function-builder":19,"./backend/web-gl2/function-node":20,"./backend/web-gl2/kernel":21,"./backend/web-gl2/runner":22,"./core/alias":26,"./core/gpu":28,"./core/input":29,"./core/texture":30,"./core/utils":32}],34:[function(require,module,exports){ +},{"./backend/cpu/function-builder":1,"./backend/cpu/function-node":2,"./backend/cpu/kernel":4,"./backend/cpu/runner":5,"./backend/web-gl/function-builder":18,"./backend/web-gl/function-node":19,"./backend/web-gl/kernel":21,"./backend/web-gl/runner":22,"./backend/web-gl2/function-builder":11,"./backend/web-gl2/function-node":12,"./backend/web-gl2/kernel":13,"./backend/web-gl2/runner":14,"./core/alias":26,"./core/gpu":28,"./core/input":29,"./core/texture":30,"./core/utils":32}],34:[function(require,module,exports){ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : @@ -6411,8 +6843,8 @@ var keywordRelationalOperator = /^in(stanceof)?$/; -var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312e\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fea\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ae\ua7b0-\ua7b7\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab65\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; -var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d4-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; +var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7b9\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab65\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; +var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); @@ -6420,9 +6852,9 @@ var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCI nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; -var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,55,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,698,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,1,31,6124,20,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541]; +var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,190,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,26,230,43,117,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,68,12,0,67,12,65,1,31,6129,15,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541]; -var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,19719,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239]; +var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239]; function isInAstralSet(code, set) { var pos = 0x10000; @@ -6578,8 +7010,8 @@ var types = { var lineBreak = /\r\n?|\n|\u2028|\u2029/; var lineBreakG = new RegExp(lineBreak.source, "g"); -function isNewLine(code) { - return code === 10 || code === 13 || code === 0x2028 || code === 0x2029 +function isNewLine(code, ecma2019String) { + return code === 10 || code === 13 || (!ecma2019String && (code === 0x2028 || code === 0x2029)) } var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; @@ -6638,6 +7070,7 @@ var defaultOptions = { allowReserved: null, allowReturnOutsideFunction: false, allowImportExportEverywhere: false, + allowAwaitOutsideFunction: false, allowHashBang: false, locations: false, onToken: null, @@ -6703,7 +7136,7 @@ var Parser = function Parser(options, input, startPos) { if (!options.allowReserved) { for (var v = options.ecmaVersion;; v--) { if (reserved = reservedWords[v]) { break } } - if (options.sourceType == "module") { reserved += " await"; } + if (options.sourceType === "module") { reserved += " await"; } } this.reservedWords = keywordRegexp(reserved); var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict; @@ -6789,7 +7222,7 @@ pp.strictDirective = function(start) { start += skipWhiteSpace.exec(this$1.input)[0].length; var match = literal.exec(this$1.input.slice(start)); if (!match) { return false } - if ((match[1] || match[2]) == "use strict") { return true } + if ((match[1] || match[2]) === "use strict") { return true } start += match[0].length; } }; @@ -6842,7 +7275,7 @@ pp.semicolon = function() { }; pp.afterTrailingComma = function(tokType, notNext) { - if (this.type == tokType) { + if (this.type === tokType) { if (this.options.onTrailingComma) { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); } if (!notNext) @@ -6931,7 +7364,7 @@ pp$1.isLet = function() { skipWhiteSpace.lastIndex = this.pos; var skip = skipWhiteSpace.exec(this.input); var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); - if (nextCh === 91 || nextCh == 123) { return true } + if (nextCh === 91 || nextCh === 123) { return true } if (isIdentifierStart(nextCh, true)) { var pos = next + 1; while (isIdentifierChar(this.input.charCodeAt(pos), true)) { ++pos; } @@ -6950,7 +7383,7 @@ pp$1.isAsyncFunction = function() { var next = this.pos + skip[0].length; return !lineBreak.test(this.input.slice(this.pos, next)) && this.input.slice(next, next + 8) === "function" && - (next + 8 == this.input.length || !isIdentifierChar(this.input.charAt(next + 8))) + (next + 8 === this.input.length || !isIdentifierChar(this.input.charAt(next + 8))) }; @@ -6981,7 +7414,7 @@ pp$1.parseStatement = function(declaration, topLevel, exports) { case types._try: return this.parseTryStatement(node) case types._const: case types._var: kind = kind || this.value; - if (!declaration && kind != "var") { this.unexpected(); } + if (!declaration && kind !== "var") { this.unexpected(); } return this.parseVarStatement(node, kind) case types._while: return this.parseWhileStatement(node) case types._with: return this.parseWithStatement(node) @@ -7014,7 +7447,7 @@ pp$1.parseStatement = function(declaration, topLevel, exports) { pp$1.parseBreakContinueStatement = function(node, keyword) { var this$1 = this; - var isBreak = keyword == "break"; + var isBreak = keyword === "break"; this.next(); if (this.eat(types.semi) || this.insertSemicolon()) { node.label = null; } else if (this.type !== types.name) { this.unexpected(); } @@ -7110,8 +7543,8 @@ pp$1.parseFunctionStatement = function(node, isAsync) { pp$1.parseIfStatement = function(node) { this.next(); node.test = this.parseParenExpression(); - node.consequent = this.parseStatement(!this.strict && this.type == types._function); - node.alternate = this.eat(types._else) ? this.parseStatement(!this.strict && this.type == types._function) : null; + node.consequent = this.parseStatement(!this.strict && this.type === types._function); + node.alternate = this.eat(types._else) ? this.parseStatement(!this.strict && this.type === types._function) : null; return this.finishNode(node, "IfStatement") }; @@ -7138,7 +7571,7 @@ pp$1.parseSwitchStatement = function(node) { var cur; - for (var sawDefault = false; this.type != types.braceR;) { + for (var sawDefault = false; this.type !== types.braceR;) { if (this$1.type === types._case || this$1.type === types._default) { var isCase = this$1.type === types._case; if (cur) { this$1.finishNode(cur, "SwitchCase"); } @@ -7184,11 +7617,16 @@ pp$1.parseTryStatement = function(node) { if (this.type === types._catch) { var clause = this.startNode(); this.next(); - this.expect(types.parenL); - clause.param = this.parseBindingAtom(); - this.enterLexicalScope(); - this.checkLVal(clause.param, "let"); - this.expect(types.parenR); + if (this.eat(types.parenL)) { + clause.param = this.parseBindingAtom(); + this.enterLexicalScope(); + this.checkLVal(clause.param, "let"); + this.expect(types.parenR); + } else { + if (this.options.ecmaVersion < 10) { this.unexpected(); } + clause.param = null; + this.enterLexicalScope(); + } clause.body = this.parseBlock(false); this.exitLexicalScope(); node.handler = this.finishNode(clause, "CatchClause"); @@ -7241,16 +7679,16 @@ pp$1.parseLabeledStatement = function(node, maybeName, expr) { var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null; for (var i = this.labels.length - 1; i >= 0; i--) { var label$1 = this$1.labels[i]; - if (label$1.statementStart == node.start) { + if (label$1.statementStart === node.start) { label$1.statementStart = this$1.start; label$1.kind = kind; } else { break } } this.labels.push({name: maybeName, kind: kind, statementStart: this.start}); node.body = this.parseStatement(true); - if (node.body.type == "ClassDeclaration" || - node.body.type == "VariableDeclaration" && node.body.kind != "var" || - node.body.type == "FunctionDeclaration" && (this.strict || node.body.generator)) + if (node.body.type === "ClassDeclaration" || + node.body.type === "VariableDeclaration" && node.body.kind !== "var" || + node.body.type === "FunctionDeclaration" && (this.strict || node.body.generator)) { this.raiseRecoverable(node.body.start, "Invalid labeled declaration"); } this.labels.pop(); node.label = expr; @@ -7302,14 +7740,14 @@ pp$1.parseFor = function(node, init) { pp$1.parseForIn = function(node, init) { var type = this.type === types._in ? "ForInStatement" : "ForOfStatement"; this.next(); - if (type == "ForInStatement") { + if (type === "ForInStatement") { if (init.type === "AssignmentPattern" || (init.type === "VariableDeclaration" && init.declarations[0].init != null && (this.strict || init.declarations[0].id.type !== "Identifier"))) { this.raise(init.start, "Invalid assignment in for-in loop head"); } } node.left = init; - node.right = type == "ForInStatement" ? this.parseExpression() : this.parseMaybeAssign(); + node.right = type === "ForInStatement" ? this.parseExpression() : this.parseMaybeAssign(); this.expect(types.parenR); this.exitLexicalScope(); node.body = this.parseStatement(false); @@ -7330,7 +7768,7 @@ pp$1.parseVar = function(node, isFor, kind) { decl.init = this$1.parseMaybeAssign(isFor); } else if (kind === "const" && !(this$1.type === types._in || (this$1.options.ecmaVersion >= 6 && this$1.isContextual("of")))) { this$1.unexpected(); - } else if (decl.id.type != "Identifier" && !(isFor && (this$1.type === types._in || this$1.isContextual("of")))) { + } else if (decl.id.type !== "Identifier" && !(isFor && (this$1.type === types._in || this$1.isContextual("of")))) { this$1.raise(this$1.lastTokEnd, "Complex binding patterns require an initialization value"); } else { decl.init = null; @@ -7355,7 +7793,7 @@ pp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) { { node.async = !!isAsync; } if (isStatement) { - node.id = isStatement === "nullableID" && this.type != types.name ? null : this.parseIdent(); + node.id = isStatement === "nullableID" && this.type !== types.name ? null : this.parseIdent(); if (node.id) { this.checkLVal(node.id, "var"); } @@ -7371,7 +7809,7 @@ pp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) { this.enterFunctionScope(); if (!isStatement) - { node.id = this.type == types.name ? this.parseIdent() : null; } + { node.id = this.type === types.name ? this.parseIdent() : null; } this.parseFunctionParams(node); this.parseFunctionBody(node, allowExpressionBody); @@ -7549,28 +7987,28 @@ pp$1.checkPatternExport = function(exports, pat) { var this$1 = this; var type = pat.type; - if (type == "Identifier") + if (type === "Identifier") { this.checkExport(exports, pat.name, pat.start); } - else if (type == "ObjectPattern") + else if (type === "ObjectPattern") { for (var i = 0, list = pat.properties; i < list.length; i += 1) { var prop = list[i]; this$1.checkPatternExport(exports, prop); } } - else if (type == "ArrayPattern") + else if (type === "ArrayPattern") { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) { var elt = list$1[i$1]; if (elt) { this$1.checkPatternExport(exports, elt); } } } - else if (type == "Property") + else if (type === "Property") { this.checkPatternExport(exports, pat.value); } - else if (type == "AssignmentPattern") + else if (type === "AssignmentPattern") { this.checkPatternExport(exports, pat.left); } - else if (type == "RestElement") + else if (type === "RestElement") { this.checkPatternExport(exports, pat.argument); } - else if (type == "ParenthesizedExpression") + else if (type === "ParenthesizedExpression") { this.checkPatternExport(exports, pat.expression); } }; @@ -8007,7 +8445,7 @@ pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) { } var startPos = this.start, startLoc = this.startLoc; - if (this.type == types.parenL || this.type == types.name) + if (this.type === types.parenL || this.type === types.name) { this.potentialArrowAt = this.start; } var left = this.parseMaybeConditional(noIn, refDestructuringErrors); if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); } @@ -8050,7 +8488,7 @@ pp$3.parseExprOps = function(noIn, refDestructuringErrors) { var startPos = this.start, startLoc = this.startLoc; var expr = this.parseMaybeUnary(refDestructuringErrors, false); if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } - return expr.start == startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn) + return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn) }; @@ -8083,7 +8521,7 @@ pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) { var this$1 = this; var startPos = this.start, startLoc = this.startLoc, expr; - if (this.inAsync && this.isContextual("await")) { + if (this.isContextual("await") && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction))) { expr = this.parseAwait(); sawUnary = true; } else if (this.type.prefix) { @@ -8137,7 +8575,7 @@ pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { var this$1 = this; var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && - this.lastTokEnd == base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async"; + this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async"; for (var computed = (void 0);;) { if ((computed = this$1.eat(types.bracketL)) || this$1.eat(types.dot)) { var node = this$1.startNodeAt(startPos, startLoc); @@ -8178,7 +8616,7 @@ pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { pp$3.parseExprAtom = function(refDestructuringErrors) { - var node, canBeArrow = this.potentialArrowAt == this.start; + var node, canBeArrow = this.potentialArrowAt === this.start; switch (this.type) { case types._super: if (!this.inFunction) @@ -8506,7 +8944,7 @@ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP } else if (!isPattern && !containsEsc && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && - (this.type != types.comma && this.type != types.braceR)) { + (this.type !== types.comma && this.type !== types.braceR)) { if (isGenerator || isAsync) { this.unexpected(); } prop.kind = prop.key.name; this.parsePropertyName(prop); @@ -8716,7 +9154,7 @@ pp$3.checkUnreserved = function(ref) { if (this.isKeyword(name)) { this.raise(start, ("Unexpected keyword '" + name + "'")); } if (this.options.ecmaVersion < 6 && - this.input.slice(start, end).indexOf("\\") != -1) { return } + this.input.slice(start, end).indexOf("\\") !== -1) { return } var re = this.strict ? this.reservedWordsStrict : this.reservedWords; if (re.test(name)) { if (!this.inAsync && name === "await") @@ -8728,7 +9166,7 @@ pp$3.checkUnreserved = function(ref) { pp$3.parseIdent = function(liberal, isBinding) { var node = this.startNode(); - if (liberal && this.options.allowReserved == "never") { liberal = false; } + if (liberal && this.options.allowReserved === "never") { liberal = false; } if (this.type === types.name) { node.name = this.value; } else if (this.type.keyword) { @@ -8753,7 +9191,7 @@ pp$3.parseYield = function() { var node = this.startNode(); this.next(); - if (this.type == types.semi || this.canInsertSemicolon() || (this.type != types.star && !this.type.startsExpr)) { + if (this.type === types.semi || this.canInsertSemicolon() || (this.type !== types.star && !this.type.startsExpr)) { node.delegate = false; node.argument = null; } else { @@ -8931,13 +9369,13 @@ pp$7.braceIsBlock = function(prevType) { if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr)) { return !parent.isExpr } - if (prevType === types._return || prevType == types.name && this.exprAllowed) + if (prevType === types._return || prevType === types.name && this.exprAllowed) { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) } - if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType == types.arrow) + if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow) { return true } - if (prevType == types.braceL) + if (prevType === types.braceL) { return parent === types$1.b_stat } - if (prevType == types._var || prevType == types.name) + if (prevType === types._var || prevType === types.name) { return false } return !this.exprAllowed }; @@ -8955,7 +9393,7 @@ pp$7.inGeneratorContext = function() { pp$7.updateContext = function(prevType) { var update, type = this.type; - if (type.keyword && prevType == types.dot) + if (type.keyword && prevType === types.dot) { this.exprAllowed = false; } else if (update = type.updateContext) { update.call(this, prevType); } @@ -8965,7 +9403,7 @@ pp$7.updateContext = function(prevType) { types.parenR.updateContext = types.braceR.updateContext = function() { - if (this.context.length == 1) { + if (this.context.length === 1) { this.exprAllowed = true; return } @@ -9013,7 +9451,7 @@ types.backQuote.updateContext = function() { }; types.star.updateContext = function(prevType) { - if (prevType == types._function) { + if (prevType === types._function) { var index = this.context.length - 1; if (this.context[index] === types$1.f_expr) { this.context[index] = types$1.f_expr_gen; } @@ -9026,8 +9464,8 @@ types.star.updateContext = function(prevType) { types.name.updateContext = function(prevType) { var allowed = false; if (this.options.ecmaVersion >= 6) { - if (this.value == "of" && !this.exprAllowed || - this.value == "yield" && this.inGeneratorContext()) + if (this.value === "of" && !this.exprAllowed || + this.value === "yield" && this.inGeneratorContext()) { allowed = true; } } this.exprAllowed = allowed; @@ -9588,7 +10026,7 @@ pp$9.validateRegExpFlags = function(state) { for (var i = 0; i < flags.length; i++) { var flag = flags.charAt(i); - if (validFlags.indexOf(flag) == -1) { + if (validFlags.indexOf(flag) === -1) { this$1.raise(state.start, "Invalid regular expression flag"); } if (flags.indexOf(flag, i + 1) > -1) { @@ -10630,7 +11068,7 @@ pp$8.readToken_mult_modulo_exp = function(code) { var size = 1; var tokentype = code === 42 ? types.star : types.modulo; - if (this.options.ecmaVersion >= 7 && code == 42 && next === 42) { + if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) { ++size; tokentype = types.starstar; next = this.input.charCodeAt(this.pos + 2); @@ -10656,7 +11094,7 @@ pp$8.readToken_caret = function() { pp$8.readToken_plus_min = function(code) { var next = this.input.charCodeAt(this.pos + 1); if (next === code) { - if (next == 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) == 62 && + if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) { this.skipLineComment(3); this.skipSpace(); @@ -10676,8 +11114,8 @@ pp$8.readToken_lt_gt = function(code) { if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) } return this.finishOp(types.bitShift, size) } - if (next == 33 && code == 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) == 45 && - this.input.charCodeAt(this.pos + 3) == 45) { + if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && + this.input.charCodeAt(this.pos + 3) === 45) { this.skipLineComment(4); this.skipSpace(); return this.nextToken() @@ -10890,7 +11328,7 @@ pp$8.readString = function(quote) { out += this$1.readEscapedChar(false); chunkStart = this$1.pos; } else { - if (isNewLine(ch)) { this$1.raise(this$1.start, "Unterminated string constant"); } + if (isNewLine(ch, this$1.options.ecmaVersion >= 10)) { this$1.raise(this$1.start, "Unterminated string constant"); } ++this$1.pos; } } @@ -11021,8 +11459,13 @@ pp$8.readEscapedChar = function(inTemplate) { } this.pos += octalStr.length - 1; ch = this.input.charCodeAt(this.pos); - if ((octalStr !== "0" || ch == 56 || ch == 57) && (this.strict || inTemplate)) { - this.invalidStringToken(this.pos - 1 - octalStr.length, "Octal literal in strict mode"); + if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) { + this.invalidStringToken( + this.pos - 1 - octalStr.length, + inTemplate + ? "Octal literal in template string" + : "Octal literal in strict mode" + ); } return String.fromCharCode(octal) } @@ -11053,7 +11496,7 @@ pp$8.readWord1 = function() { this$1.containsEsc = true; word += this$1.input.slice(chunkStart, this$1.pos); var escStart = this$1.pos; - if (this$1.input.charCodeAt(++this$1.pos) != 117) + if (this$1.input.charCodeAt(++this$1.pos) !== 117) { this$1.invalidStringToken(this$1.pos, "Expecting Unicode escape sequence \\uXXXX"); } ++this$1.pos; var esc = this$1.readCodePoint(); @@ -11081,7 +11524,7 @@ pp$8.readWord = function() { }; -var version = "5.5.0"; +var version = "5.7.1"; function parse(input, options) { diff --git a/bin/gpu.min.js b/bin/gpu.min.js index cba443eb..59303016 100644 --- a/bin/gpu.min.js +++ b/bin/gpu.min.js @@ -5,17 +5,18 @@ * GPU Accelerated JavaScript * * @version 1.6.2 - * @date Sun Sep 02 2018 13:35:52 GMT-0400 (EDT) + * @date Mon Sep 03 2018 14:59:44 GMT-0500 (Central Daylight Time) * * @license MIT * The MIT License * * Copyright (c) 2018 gpu.js Team */ -"use strict";!function(){function t(e,n,r){function i(a,o){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return i(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a0&&e.push(", "),e.push(this.paramTypes[n]),e.push(" "),e.push("user_"),e.push(this.paramNames[n]);return e.push(");\n"),e}},{key:"astFunctionExpression",value:function(t,e){if(!this.isRootKernel){e.push("function"),this.kernalAst=t,e.push(" "),e.push(this.functionName),e.push("(");for(var n=0;n0&&e.push(", "),e.push(" "),e.push("user_"),e.push(r)}e.push(") {\n")}for(var i=0;i1){for(var s=null,a=0;a0&&e.push(","),this.astGeneric(t.declarations[n],e);return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e){return this.astGeneric(t.id,e),null!==t.init&&(e.push("="),this.astGeneric(t.init,e)),e}},{key:"astIfStatement",value:function(t,e){return e.push("if ("),this.astGeneric(t.test,e),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e):(e.push(" {\n"),this.astGeneric(t.consequent,e),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e):(e.push(" {\n"),this.astGeneric(t.alternate,e),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e){return e.push("("),this.astGeneric(t.left,e),e.push(t.operator),this.astGeneric(t.right,e),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e){return e.push("_this"),e}},{key:"astMemberExpression",value:function(t,e){if(t.computed)if("Identifier"===t.object.type)this.pushState("identifier"),this.astGeneric(t.object,e),this.popState("identifier"),e.push("["),this.isInput(t.object.name)?this.astGeneric(t.property,e):this.astGeneric(t.property,e),e.push("]");else if(t.object.object)if(t.object.object.object&&this.isInput(t.object.object.object.name)){this.pushMemberState(t.object.object.object.name),this.pushState("input-index-z"),this.astGeneric(t.object,e);var n=e.pop();e.push(" + "),this.popState("input-index-z"),this.pushState("input-index"),this.astGeneric(t.property,e),this.popState("input-index"),e.push(n),this.popMemberState(t.object.object.object.name)}else if(this.isInput(t.object.object.name)){this.pushMemberState(t.object.object.name),this.isState("input-index-z")||this.pushState("input-index-y"),this.astGeneric(t.object,e);var r=e.pop();e.push(" + "),this.isState("input-index-z")||this.popState("input-index-y");var i=this.isState("input-index-z");i?this.pushState("input-index-y"):this.pushState("input-index"),this.astGeneric(t.property,e),i?this.popState("input-index-y"):this.popState("input-index"),e.push(r),this.popMemberState(t.object.object.name)}else{this.astGeneric(t.object,e);var s=e.pop();e.push("]["),this.astGeneric(t.property,e),e.push(s)}else{this.astGeneric(t.object,e);var a=e.pop();e.push("]["),this.astGeneric(t.property,e),e.push(a)}else{var o=this.astMemberExpressionUnroll(t);switch("Identifier"===t.property.type&&t.computed&&(o="user_"+o),0===o.indexOf("this")&&(o="_"+o),this.state){case"input-index-y":case"input-index-z":e.push("(")}switch(o){case"_this.output.x":e.push(this.output[0]);break;case"_this.output.y":e.push(this.output[1]);break;case"_this.output.z":e.push(this.output[2]);break;default:e.push(o)}switch(this.state){case"input-index-y":var u=this.paramSizes[this.paramNames.indexOf(this.memberState)];e.push(" * "+u[0]+")");break;case"input-index-z":var h=this.paramSizes[this.paramNames.indexOf(this.memberState)];e.push(" * "+h[0]*h[1]+")")}}return e}},{key:"astSequenceExpression",value:function(t,e){for(var n=0;n0&&e.push(","),this.astGeneric(t.expressions,e);return e}},{key:"astCallExpression",value:function(t,e){if(t.callee){var n=this.astMemberExpressionUnroll(t.callee);this.calledFunctions.indexOf(n)<0&&this.calledFunctions.push(n),this.hasOwnProperty("funcName")||(this.calledFunctionsArguments[n]=[]);var r=[];this.calledFunctionsArguments[n].push(r),e.push(n),e.push("(");for(var i=0;i0&&e.push(", "),this.astGeneric(s,e),"Identifier"===s.type){var a=this.paramNames.indexOf(s.name);a===-1?r.push(null):r.push({name:s.name,type:this.paramTypes[a]})}else r.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t)}},{key:"astArrayExpression",value:function(t,e){var n=t.elements.length;e.push("new Float32Array(");for(var r=0;r0&&e.push(", ");var i=t.elements[r];this.astGeneric(i,e)}return e.push(")"),e}},{key:"astDebuggerStatement",value:function(t,e){return e.push("debugger;"),e}},{key:"memberState",get:function(){return this.memberStates[this.memberStates.length-1]}}]),e}(o)},{"../../core/utils":32,"../function-node-base":7}],3:[function(t,e,n){function r(t){return/^function /.test(t)&&(t=t.substring(9)),t.replace(/[_]typeof/g,"typeof")}function i(t){return t.replace(/[_]typeof/g,"typeof")}var s=t("../../core/utils"),a=t("../kernel-run-shortcut");e.exports=function(t,e){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+i(s.allPropertiesOf.toString())+",\n clone: "+i(s.clone.toString())+",\n checkOutput: "+i(s.checkOutput.toString())+"\n };\n const Utils = utils;\n class "+(e||"Kernel")+" {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(t.paramNames)+";\n this.paramTypes = "+JSON.stringify(t.paramTypes)+";\n this.texSize = "+JSON.stringify(t.texSize)+";\n this.output = "+JSON.stringify(t.output)+";\n this._kernelString = `"+t._kernelString+"`;\n this.output = "+JSON.stringify(t.output)+";\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+r(t.build.toString())+"\n "+r(t.setupParams.toString())+"\n run () { "+t.kernelString+" }\n getKernelString() { return this._kernelString; }\n "+r(t.validateOptions.toString())+"\n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],4:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n1?h=h.filter(function(t){return/^function/.test(t)?t:(l=t,!1)}):l=h.shift();var c=this._kernelString="\n\t\tvar LOOP_MAX = "+this._getLoopMaxString()+";\n\t\tvar _this = this;\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" var "+t+" = null;\n"}).join(""))+"\n return function ("+this.paramNames.map(function(t){return"user_"+t}).join(", ")+") {\n "+this._processInputs()+"\n var ret = new Array("+n[2]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z = new Array("+n[2]+");\n"}).join(""))+"\n for (this.thread.z = 0; this.thread.z < "+n[2]+"; this.thread.z++) {\n ret[this.thread.z] = new Array("+n[1]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z[this.thread.z] = new Array("+n[1]+");\n"}).join(""))+"\n for (this.thread.y = 0; this.thread.y < "+n[1]+"; this.thread.y++) {\n ret[this.thread.z][this.thread.y] = "+(this.floatOutput?"new Float32Array("+n[0]+")":"new Array("+n[0]+")")+";\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+"Z[this.thread.z][this.thread.y] = "+(t.floatOutput?"new Float32Array("+n[0]+")":"new Array("+n[0]+")")+";\n"}).join(""))+"\n for (this.thread.x = 0; this.thread.x < "+n[0]+"; this.thread.x++) {\n var kernelResult;\n "+l+"\n ret[this.thread.z][this.thread.y][this.thread.x] = kernelResult;\n"+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z[this.thread.z][this.thread.y][this.thread.x] = "+t+";\n"}).join(""))+"\n }\n }\n }\n \n if (this.graphical) {\n this._imageData.data.set(this._colorData);\n this._canvasCtx.putImageData(this._imageData, 0, 0);\n return;\n }\n \n if (this.output.length === 1) {\n ret = ret[0][0];\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+" = "+t+"Z[0][0];\n"}).join(""))+"\n \n } else if (this.output.length === 2) {\n ret = ret[0];\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+" = "+t+"Z[0];\n"}).join(""))+"\n } else {\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+" = "+t+"Z;\n"}).join(""))+"\n }\n \n "+(null===this.subKernelOutputVariableNames?"return ret;\n":null!==this.subKernels?"var result = [\n "+this.subKernelOutputVariableNames.map(function(t){return""+t}).join(",\n")+"\n ];\n result.result = ret;\n return result;\n":"return {\n result: ret,\n "+Object.keys(this.subKernelProperties).map(function(e,n){return e+": "+t.subKernelOutputVariableNames[n]}).join(",\n")+"\n };")+"\n "+(h.length>0?h.join("\n"):"")+"\n }.bind(this);";return c}},{key:"toString",value:function(){return h(this)}},{key:"_getLoopMaxString",value:function(){return this.loopMaxIterations?" "+parseInt(this.loopMaxIterations)+";\n":" 1000;\n"}},{key:"_processInputs",value:function(){for(var t=[],e=0;e=0;i--){n[i]=new Array(t.width);for(var s=0;s=0||e.push(t)),e}},{key:"addKernel",value:function(t,e){var n=new this.Node("kernel",t,e);return n.setAddFunction(this.addFunction.bind(this)),n.isRootKernel=!0,this.addFunctionNode(n),n}},{key:"addSubKernel",value:function(t,e){var n=new this.Node(null,t,e);return n.setAddFunction(this.addFunction.bind(this)),n.isSubKernel=!0,this.addFunctionNode(n),n}},{key:"getPrototypeString",value:function(t){return this.getPrototypes(t).join("\n")}},{key:"getPrototypes",value:function(t){return this.rootKernel.generate(),t?this.getPrototypesFromFunctionNames(this.traceFunctionCalls(t,[]).reverse()):this.getPrototypesFromFunctionNames(Object.keys(this.nodeMap))}},{key:"getStringFromFunctionNames",value:function(t){for(var e=[],n=0;n ("+r.length+","+this.paramNames.length+")";this.paramTypes=r}else if("object"===("undefined"==typeof r?"undefined":_typeof(r))){var s=Object.keys(r);if(r.hasOwnProperty("returns")&&(this.returnType=r.returns,s.splice(s.indexOf("returns"),1)),s.length>0&&s.length!==this.paramNames.length)throw"Invalid argument type array length, against function length -> ("+s.length+","+this.paramNames.length+")";this.paramTypes=this.paramNames.map(function(t){return r.hasOwnProperty(t)?r[t]:"float"})}}else this.paramTypes=[];this.returnType||(this.returnType=i||"float")}return _createClass(BaseFunctionNode,[{key:"isIdentifierConstant",value:function(t){return!!this.constants&&this.constants.hasOwnProperty(t)}},{key:"isInput",value:function(t){return"Input"===this.paramTypes[this.paramNames.indexOf(t)]}},{key:"setAddFunction",value:function(t){return this.addFunction=t,this}},{key:"pushState",value:function(t){this.states.push(t)}},{key:"popState",value:function(t){if(this.state!==t)throw new Error("Cannot popState "+t+" when in "+this.state);this.states.pop()}},{key:"isState",value:function(t){return this.state===t}},{key:"getJsFunction",value:function getJsFunction(){if(this.jsFunction)return this.jsFunction;if(this.jsFunctionString)return this.jsFunction=eval(this.jsFunctionString),this.jsFunction;throw"Missing jsFunction, and jsFunctionString parameter"}},{key:"astMemberExpressionUnroll",value:function(t){if("Identifier"===t.type)return t.name;if("ThisExpression"===t.type)return"this";if("MemberExpression"===t.type&&t.object&&t.property)return t.object.hasOwnProperty("name")&&"_"===t.object.name[0]?this.astMemberExpressionUnroll(t.property):this.astMemberExpressionUnroll(t.object)+"."+this.astMemberExpressionUnroll(t.property);if(t.hasOwnProperty("expressions")){var e=t.expressions[0];if("Literal"===e.type&&0===e.value&&2===t.expressions.length)return this.astMemberExpressionUnroll(t.expressions[1])}throw this.astErrorOutput("Unknown CallExpression_unroll",t)}},{key:"getJsAST",value:function(t){if(this.jsFunctionAST)return this.jsFunctionAST;if(t=t||acorn,null===t)throw"Missing JS to AST parser";var e=t.parse("var "+this.functionName+" = "+this.jsFunctionString+";",{locations:!0});if(null===e)throw"Failed to parse JS code";var n=e.body[0].declarations[0].init;return this.jsFunctionAST=n,n}},{key:"getFunctionString",value:function(){return this.generate(),this.functionString}},{key:"setFunctionString",value:function(t){this.functionString=t}},{key:"getParamType",value:function(t){var e=this.paramNames.indexOf(t);if(e===-1)return this.declarations.hasOwnProperty(t)?this.declarations[t]:null; -if(this.parent){if(this.paramTypes[e])return this.paramTypes[e];for(var n=this.parent.calledFunctionsArguments[this.functionName],r=0;r0&&e.push(", ");var i=this.getParamType(r);switch(i){case"Texture":case"Input":case"Array":e.push("sampler2D");break;default:e.push("float")}e.push(" "),e.push("user_"),e.push(r)}e.push(") {\n");for(var s=0;s1){for(var s=null,a=0;a0&&e.push(",");var i=[];this.astGeneric(r,i),"getImage2D("===i[2]||"getImage3D("===i[2]?(0===n&&e.push("vec4 "),this.declarations[r.id.name]="vec4"):(0===n&&e.push("float "),this.declarations[r.id.name]="float"),e.push.apply(e,i)}return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e){return this.astGeneric(t.id,e),null!==t.init&&(e.push("="),this.astGeneric(t.init,e)),e}},{key:"astIfStatement",value:function(t,e){return e.push("if ("),this.astGeneric(t.test,e),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e):(e.push(" {\n"),this.astGeneric(t.consequent,e),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e):(e.push(" {\n"),this.astGeneric(t.alternate,e),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e){return e.push("("),this.astGeneric(t.left,e),e.push(t.operator),this.astGeneric(t.right,e),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e){return e.push("this"),e}},{key:"astMemberExpression",value:function(t,e){if(m("[in] astMemberExpression "+t.object.type),t.computed)if("Identifier"===t.object.type){var n=t.object.name,r=this.functionName||"kernel",i=!1;if(this.paramNames){var s=this.paramNames.indexOf(n);s>=0&&"float"===this.paramTypes[s]&&(i=!0)}if(m("- astMemberExpression "+n+" "+r),i)this.astGeneric(t.object,e),e.push("[int("),this.astGeneric(t.property,e),e.push(")]");else{var a=this.isState("in-get-call-parameters"),o=this.isState("multi-member-expression");switch(o&&this.popState("multi-member-expression"),this.pushState("not-in-get-call-parameters"),this.getParamType(t.object.name)){case"vec4":this.astGeneric(t.object,e),e.push("["),e.push(t.property.raw),e.push("]"),o&&this.popState("not-in-get-call-parameters");break;case"HTMLImageArray":e.push("getImage3D("),this.astGeneric(t.object,e),e.push(", ivec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), ivec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.popState("not-in-get-call-parameters"),this.pushState("in-get-call-parameters"),this.astGeneric(t.property,e),o||this.popState("in-get-call-parameters"),e.push(")");break;case"HTMLImage":e.push("getImage2D("),this.astGeneric(t.object,e),e.push(", ivec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), ivec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.popState("not-in-get-call-parameters"),this.pushState("in-get-call-parameters"),this.astGeneric(t.property,e),o||this.popState("in-get-call-parameters"),e.push(")");break;default:a&&e.push("int("),e.push("get("),this.astGeneric(t.object,e),e.push(", ivec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), ivec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.astGeneric(t.object,e),e.push("BitRatio"),e.push(", "),this.popState("not-in-get-call-parameters"),this.pushState("in-get-call-parameters"),this.astGeneric(t.property,e),o||this.popState("in-get-call-parameters"),e.push(")"),a&&e.push(")")}}}else{m("- astMemberExpression obj:",t.object);var u=(this.states.length,this.isState("in-get-call-parameters"));u||this.pushState("multi-member-expression"),this.astGeneric(t.object,e),this.isState("multi-member-expression")&&this.popState("multi-member-expression");var h=!u&&this.isState("in-get-call-parameters"),l=e.pop();e.push(","),m("- astMemberExpression prop:",t.property);var c=this.isState("should-pop-in-get-call-parameters");c&&this.popState("should-pop-in-get-call-parameters"),this.astGeneric(t.property,e),e.push(l),h?this.pushState("should-pop-in-get-call-parameters"):c&&this.popState("in-get-call-parameters")}else{var f=this.astMemberExpressionUnroll(t),d=f.toLowerCase();m("- astMemberExpression unrolled:",f),0===f.indexOf(p)&&(f="constants_"+f.slice(p.length));var g=!this.isState("in-get-call-parameters");switch(d){case"this.thread.x":g&&e.push("float("),e.push("threadId.x"),g&&e.push(")");break;case"this.thread.y":g&&e.push("float("),e.push("threadId.y"),g&&e.push(")");break;case"this.thread.z":g&&e.push("float("),e.push("threadId.z"),g&&e.push(")");break;case"this.output.x":e.push(this.output[0]+".0");break;case"this.output.y":e.push(this.output[1]+".0");break;case"this.output.z":e.push(this.output[2]+".0");break;default:e.push(f)}}return m("[out] astMemberExpression "+t.object.type),e}},{key:"astSequenceExpression",value:function(t,e){for(var n=0;n0&&e.push(","),this.astGeneric(t.expressions,e);return e}},{key:"astCallExpression",value:function(t,e){if(t.callee){var n=this.astMemberExpressionUnroll(t.callee);0===n.indexOf(l)&&(n=n.slice(l.length)),0===n.indexOf(c)&&(n=n.slice(c.length)),"atan2"===n&&(n="atan"),this.calledFunctions.indexOf(n)<0&&this.calledFunctions.push(n),this.hasOwnProperty("funcName")||(this.calledFunctionsArguments[n]=[]);var r=[];this.calledFunctionsArguments[n].push(r),e.push(n),e.push("(");for(var i=0;i0&&e.push(", "),this.astGeneric(s,e),"Identifier"===s.type){var a=this.paramNames.indexOf(s.name);a===-1?r.push(null):r.push({name:s.name,type:this.paramTypes[a]})}else r.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t)}},{key:"astArrayExpression",value:function(t,e){var n=t.elements.length;e.push("float["+n+"](");for(var r=0;r0&&e.push(", ");var i=t.elements[r];this.astGeneric(i,e)}return e.push(")"),e}},{key:"getFunctionPrototypeString",value:function(){return this.webGlFunctionPrototypeString?this.webGlFunctionPrototypeString:this.webGlFunctionPrototypeString=this.generate()}},{key:"build",value:function(){return this.getFunctionPrototypeString().length>0}}],[{key:"astFunctionPrototype",value:function(t,e){if(this.isRootKernel||this.isSubKernel)return e;e.push(this.returnType),e.push(" "),e.push(this.functionName),e.push("(");for(var n=0;n0&&e.push(", "),e.push(this.paramTypes[n]),e.push(" "),e.push("user_"),e.push(this.paramNames[n]);return e.push(");\n"),e}}]),e}(u)},{"../../core/utils":32,"../function-node-base":7}],13:[function(t,e,n){function r(t){return/^function /.test(t)&&(t=t.substring(9)),t.replace(/[_]typeof/g,"typeof")}function i(t){return t.replace(/[_]typeof/g,"typeof")}var s=t("../../core/utils"),a=t("../kernel-run-shortcut");e.exports=function(t,e){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+i(s.allPropertiesOf.toString())+",\n clone: "+i(s.clone.toString())+",\n splitArray: "+i(s.splitArray.toString())+",\n getArgumentType: "+i(s.getArgumentType.toString())+",\n getDimensions: "+i(s.getDimensions.toString())+",\n dimToTexSize: "+i(s.dimToTexSize.toString())+",\n flattenTo: "+i(s.flattenTo.toString())+",\n flatten2dArrayTo: "+i(s.flatten2dArrayTo.toString())+",\n flatten3dArrayTo: "+i(s.flatten3dArrayTo.toString())+",\n systemEndianness: '"+i(s.systemEndianness())+"',\n initWebGl: "+i(s.initWebGl.toString())+",\n isArray: "+i(s.isArray.toString())+",\n checkOutput: "+i(s.checkOutput.toString())+"\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class "+(e||"Kernel")+" {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(t.paramNames)+";\n this.paramTypes = "+JSON.stringify(t.paramTypes)+";\n this.texSize = "+JSON.stringify(t.texSize)+";\n this.output = "+JSON.stringify(t.output)+";\n this.compiledFragShaderString = `"+t.compiledFragShaderString+"`;\n\t\t this.compiledVertShaderString = `"+t.compiledVertShaderString+"`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform2ivCache = {};\n\t\t this.uniform3fvCache = {};\n\t\t this.uniform3ivCache = {};\n }\n "+r(t._getFragShaderString.toString())+"\n "+r(t._getVertShaderString.toString())+"\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+r(t.getUniformLocation.toString())+"\n "+r(t.setupParams.toString())+"\n "+r(t.build.toString())+"\n\t\t "+r(t.run.toString())+"\n\t\t "+r(t._addArgument.toString())+"\n\t\t "+r(t.getArgumentTexture.toString())+"\n\t\t "+r(t.getTextureCache.toString())+"\n\t\t "+r(t.getOutputTexture.toString())+"\n\t\t "+r(t.renderOutput.toString())+"\n\t\t "+r(t.updateMaxTexSize.toString())+"\n\t\t "+r(t._setupOutputTexture.toString())+"\n\t\t "+r(t.detachTextureCache.toString())+"\n\t\t "+r(t.setUniform1f.toString())+"\n\t\t "+r(t.setUniform1i.toString())+"\n\t\t "+r(t.setUniform2f.toString())+"\n\t\t "+r(t.setUniform2fv.toString())+"\n\t\t "+r(t.setUniform2iv.toString())+"\n\t\t "+r(t.setUniform3fv.toString())+" \n\t\t "+r(t.setUniform3iv.toString())+" \n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],14:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function g(t,e,n){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,e);if(void 0===r){var i=Object.getPrototypeOf(t);return null===i?void 0:g(i,e,n)}if("value"in r)return r.value;var s=r.get;if(void 0!==s)return s.call(n)},o=function(){function t(t,e){for(var n=0;n0&&this._setupSubOutputTextures(this.subKernelOutputVariableNames.length))}},{key:"run",value:function(){null===this.program&&this.build.apply(this,arguments);var t=this.paramNames,e=this.paramTypes,n=this.texSize,r=this._webGl;r.useProgram(this.program),r.scissor(0,0,n[0],n[1]),this.hardcodeConstants||(this.setUniform3iv("uOutputDim",this.threadDim),this.setUniform2iv("uTexSize",n)),this.setUniform2f("ratio",n[0]/this.maxTexSize[0],n[1]/this.maxTexSize[1]),this.argumentsLength=0;for(var i=0;i0?t.join(";\n")+";\n":"\n"}},{key:"_replaceArtifacts",value:function(t,e){return t.replace(/[ ]*__([A-Z]+[0-9]*([_]?[A-Z])*)__;\n/g,function(t,n){if(e.hasOwnProperty(n))return e[n];throw"unhandled artifact "+n})}},{key:"_addKernels",value:function(){var t=this,e=this.functionBuilder,n=this._webGl;if(e.addFunctions(this.functions,{constants:this.constants,output:this.output}),e.addNativeFunctions(this.nativeFunctions),e.addKernel(this.fnString,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations,paramNames:this.paramNames,paramTypes:this.paramTypes,fixIntegerDivisionAccuracy:this.fixIntegerDivisionAccuracy}),null!==this.subKernels){var r=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!r)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],this.subKernels.forEach(function(e){return t._addSubKernel(e)})}else if(null!==this.subKernelProperties){var i=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!i)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],Object.keys(this.subKernelProperties).forEach(function(e){return t._addSubKernel(t.subKernelProperties[e])})}}},{key:"_addSubKernel",value:function(t){this.functionBuilder.addSubKernel(t,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations,fixIntegerDivisionAccuracy:this.fixIntegerDivisionAccuracy}),this.subKernelOutputVariableNames.push(t.name+"Result")}},{key:"_getFragShaderString",value:function(t){return null!==this.compiledFragShaderString?this.compiledFragShaderString:this.compiledFragShaderString=this._replaceArtifacts(this.constructor.fragShaderString,this._getFragShaderArtifactMap(t))}},{key:"_getVertShaderString",value:function(t){return null!==this.compiledVertShaderString?this.compiledVertShaderString:this.compiledVertShaderString=this.constructor.vertShaderString}},{key:"toString",value:function(){return f(this)}},{key:"addFunction",value:function(t){this.functionBuilder.addFunction(null,t)}},{key:"destroy",value:function(t){a(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"destroy",this).call(this),this.outputTexture&&this._webGl.deleteTexture(this.outputTexture),this.buffer&&this._webGl.deleteBuffer(this.buffer),this.framebuffer&&this._webGl.deleteFramebuffer(this.framebuffer),this.vertShader&&this._webGl.deleteShader(this.vertShader),this.fragShader&&this._webGl.deleteShader(this.fragShader),this.program&&this._webGl.deleteProgram(this.program);for(var n=Object.keys(this.textureCache),r=0;r=0&&(d[o]=null,m[o]=null)}delete this._webGl}}]),e}(u)},{"../../core/texture":30,"../../core/utils":32,"../kernel-base":8,"./kernel-string":13,"./shader-frag":16,"./shader-vert":17}],15:[function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n0&&e.push(", ");var i=this.getParamType(r);switch(i){case"Texture":case"Input":case"Array": -case"HTMLImage":e.push("sampler2D");break;default:e.push("float")}e.push(" "),e.push("user_"),e.push(r)}e.push(") {\n");for(var s=0;s1&&i*s===r)return[i,s];for(var o=Math.sqrt(r),u=Math.ceil(o),h=Math.floor(o);u*h>r;)u--,h=Math.ceil(r/u);return i=h,s=Math.ceil(r/i),[i,s]}},{key:"getDimensions",value:function(t,e){var r=void 0;if(n.isArray(t)){for(var i=[],s=t;n.isArray(s);)i.push(s.length),s=s[0];r=i.reverse()}else if(t instanceof l)r=t.output;else{if(!(t instanceof h))throw"Unknown dimensions of "+t;r=t.size}if(e)for(r=n.clone(r);r.length<3;)r.push(1);return new Int32Array(r)}},{key:"pad",value:function(t,e){function n(t){return Array.apply(null,new Array(t)).map(Number.prototype.valueOf,0)}for(var r=t.length+2*e,i=t.map(function(t){return[].concat(n(e),t,n(e))}),s=0;st)return!1;if(n+=e[r+1],n>=t)return!0}}function n(t,n){return t<65?36===t:t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&U.test(String.fromCharCode(t)):n!==!1&&e(t,V)))}function r(t,n){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&M.test(String.fromCharCode(t)):n!==!1&&(e(t,V)||e(t,B)))))}function i(t,e){return new j(t,{beforeExpr:!0,binop:e})}function s(t,e){return void 0===e&&(e={}),e.keyword=t,X[t]=new j(t,e)}function a(t){return 10===t||13===t||8232===t||8233===t}function o(t,e){return Z.call(t,e)}function u(t,e){for(var n=1,r=0;;){q.lastIndex=r;var i=q.exec(t);if(!(i&&i.index=2015&&(e.ecmaVersion-=2009),null==e.allowReserved&&(e.allowReserved=e.ecmaVersion<5),tt(e.onToken)){var r=e.onToken;e.onToken=function(t){return r.push(t)}}return tt(e.onComment)&&(e.onComment=l(e,e.onComment)),e}function l(t,e){return function(n,r,i,s,a,o){var u={type:n?"Block":"Line",value:r,start:i,end:s};t.locations&&(u.loc=new nt(this,a,o)),t.ranges&&(u.range=[i,s]),e.push(u)}}function c(t){return new RegExp("^(?:"+t.replace(/ /g,"|")+")$")}function p(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1}function f(t,e,n,r){return t.type=e,t.end=n,this.options.locations&&(t.loc.end=r),this.options.ranges&&(t.range[1]=n),t}function d(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(1023&t)+56320))}function m(t){return 36===t||t>=40&&t<=43||46===t||63===t||t>=91&&t<=94||t>=123&&t<=125}function g(t){return n(t,!0)||36===t||95===t}function y(t){return r(t,!0)||36===t||95===t||8204===t||8205===t}function x(t){return t>=65&&t<=90||t>=97&&t<=122}function v(t){return t>=0&&t<=1114111}function b(t){return 100===t||68===t||115===t||83===t||119===t||87===t}function _(t){return x(t)||95===t}function E(t){return _(t)||T(t)}function T(t){return t>=48&&t<=57}function S(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function k(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}function w(t){return t>=48&&t<=55}function A(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(1023&t)+56320))}function O(t,e){return new st(e,t).parse()}function C(t,e,n){var r=new st(n,t,e);return r.nextToken(),r.parseExpression()}function R(t,e){return new st(e,t)}function I(e,n,r){t.parse_dammit=e,t.LooseParser=n,t.pluginsLoose=r}var P={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},N="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",D={5:N,6:N+" const class extends export import super"},L=/^in(stanceof)?$/,F="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄮㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿪ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",G="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳷-᳹᷀-᷹᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",U=new RegExp("["+F+"]"),M=new RegExp("["+F+G+"]");F=G=null;var V=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,55,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,698,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,1,31,6124,20,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541],B=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,19719,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239],j=function(t,e){void 0===e&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null},z={beforeExpr:!0},K={startsExpr:!0},X={},W={num:new j("num",K),regexp:new j("regexp",K),string:new j("string",K),name:new j("name",K),eof:new j("eof"),bracketL:new j("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new j("]"),braceL:new j("{",{beforeExpr:!0,startsExpr:!0}),braceR:new j("}"),parenL:new j("(",{beforeExpr:!0,startsExpr:!0}),parenR:new j(")"),comma:new j(",",z),semi:new j(";",z),colon:new j(":",z),dot:new j("."),question:new j("?",z),arrow:new j("=>",z),template:new j("template"),invalidTemplate:new j("invalidTemplate"),ellipsis:new j("...",z),backQuote:new j("`",K),dollarBraceL:new j("${",{beforeExpr:!0,startsExpr:!0}),eq:new j("=",{beforeExpr:!0,isAssign:!0}),assign:new j("_=",{beforeExpr:!0,isAssign:!0}),incDec:new j("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new j("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:i("||",1),logicalAND:i("&&",2),bitwiseOR:i("|",3),bitwiseXOR:i("^",4),bitwiseAND:i("&",5),equality:i("==/!=/===/!==",6),relational:i("/<=/>=",7),bitShift:i("<>/>>>",8),plusMin:new j("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:i("%",10),star:i("*",10),slash:i("/",10),starstar:new j("**",{beforeExpr:!0}),_break:s("break"),_case:s("case",z),_catch:s("catch"),_continue:s("continue"),_debugger:s("debugger"),_default:s("default",z),_do:s("do",{isLoop:!0,beforeExpr:!0}),_else:s("else",z),_finally:s("finally"),_for:s("for",{isLoop:!0}),_function:s("function",K),_if:s("if"),_return:s("return",z),_switch:s("switch"),_throw:s("throw",z),_try:s("try"),_var:s("var"),_const:s("const"),_while:s("while",{isLoop:!0}),_with:s("with"),_new:s("new",{beforeExpr:!0,startsExpr:!0}),_this:s("this",K),_super:s("super",K),_class:s("class",K),_extends:s("extends",z),_export:s("export"),_import:s("import"),_null:s("null",K),_true:s("true",K),_false:s("false",K),_in:s("in",{beforeExpr:!0,binop:7}),_instanceof:s("instanceof",{beforeExpr:!0,binop:7}),_typeof:s("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:s("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:s("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},H=/\r\n?|\n|\u2028|\u2029/,q=new RegExp(H.source,"g"),Y=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,J=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Q=Object.prototype,Z=Q.hasOwnProperty,$=Q.toString,tt=Array.isArray||function(t){return"[object Array]"===$.call(t)},et=function(t,e){this.line=t,this.column=e};et.prototype.offset=function(t){return new et(this.line,this.column+t)};var nt=function(t,e,n){this.start=e,this.end=n,null!==t.sourceFile&&(this.source=t.sourceFile)},rt={ecmaVersion:7,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowHashBang:!1,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1,plugins:{}},it={},st=function(t,e,n){this.options=t=h(t),this.sourceFile=t.sourceFile,this.keywords=c(D[t.ecmaVersion>=6?6:5]);var r="";if(!t.allowReserved){for(var i=t.ecmaVersion;!(r=P[i]);i--);"module"==t.sourceType&&(r+=" await")}this.reservedWords=c(r);var s=(r?r+" ":"")+P.strict;this.reservedWordsStrict=c(s),this.reservedWordsStrictBind=c(s+" "+P.strictBind),this.input=String(e),this.containsEsc=!1,this.loadPlugins(t.plugins),n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(H).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=W.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===t.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.inFunction=this.inGenerator=this.inAsync=!1,this.yieldPos=this.awaitPos=0,this.labels=[],0===this.pos&&t.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterFunctionScope(),this.regexpState=null};st.prototype.isKeyword=function(t){return this.keywords.test(t)},st.prototype.isReservedWord=function(t){return this.reservedWords.test(t)},st.prototype.extend=function(t,e){this[t]=e(this[t])},st.prototype.loadPlugins=function(t){var e=this;for(var n in t){var r=it[n];if(!r)throw new Error("Plugin '"+n+"' not found");r(e,t[n])}},st.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};var at=st.prototype,ot=/^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;at.strictDirective=function(t){for(var e=this;;){J.lastIndex=t,t+=J.exec(e.input)[0].length;var n=ot.exec(e.input.slice(t));if(!n)return!1;if("use strict"==(n[1]||n[2]))return!0;t+=n[0].length}},at.eat=function(t){return this.type===t&&(this.next(),!0)},at.isContextual=function(t){return this.type===W.name&&this.value===t&&!this.containsEsc},at.eatContextual=function(t){return!!this.isContextual(t)&&(this.next(),!0)},at.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},at.canInsertSemicolon=function(){return this.type===W.eof||this.type===W.braceR||H.test(this.input.slice(this.lastTokEnd,this.start))},at.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},at.semicolon=function(){this.eat(W.semi)||this.insertSemicolon()||this.unexpected()},at.afterTrailingComma=function(t,e){if(this.type==t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0},at.expect=function(t){this.eat(t)||this.unexpected()},at.unexpected=function(t){this.raise(null!=t?t:this.start,"Unexpected token")},at.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var n=e?t.parenthesizedAssign:t.parenthesizedBind;n>-1&&this.raiseRecoverable(n,"Parenthesized pattern")}},at.checkExpressionErrors=function(t,e){if(!t)return!1;var n=t.shorthandAssign,r=t.doubleProto;return e?(n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),void(r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property"))):n>=0||r>=0},at.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&(t.sourceType=this.options.sourceType),this.finishNode(t,"Program")};var ht={kind:"loop"},lt={kind:"switch"};ut.isLet=function(){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;J.lastIndex=this.pos;var t=J.exec(this.input),e=this.pos+t[0].length,i=this.input.charCodeAt(e);if(91===i||123==i)return!0;if(n(i,!0)){for(var s=e+1;r(this.input.charCodeAt(s),!0);)++s;var a=this.input.slice(e,s);if(!L.test(a))return!0}return!1},ut.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;J.lastIndex=this.pos;var t=J.exec(this.input),e=this.pos+t[0].length;return!(H.test(this.input.slice(this.pos,e))||"function"!==this.input.slice(e,e+8)||e+8!=this.input.length&&r(this.input.charAt(e+8)))},ut.parseStatement=function(t,e,n){var r,i=this.type,s=this.startNode();switch(this.isLet()&&(i=W._var,r="let"),i){case W._break:case W._continue:return this.parseBreakContinueStatement(s,i.keyword);case W._debugger:return this.parseDebuggerStatement(s);case W._do:return this.parseDoStatement(s);case W._for:return this.parseForStatement(s);case W._function:return!t&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1);case W._class:return t||this.unexpected(),this.parseClass(s,!0);case W._if:return this.parseIfStatement(s);case W._return:return this.parseReturnStatement(s);case W._switch:return this.parseSwitchStatement(s);case W._throw:return this.parseThrowStatement(s);case W._try:return this.parseTryStatement(s);case W._const:case W._var:return r=r||this.value,t||"var"==r||this.unexpected(),this.parseVarStatement(s,r);case W._while:return this.parseWhileStatement(s);case W._with:return this.parseWithStatement(s);case W.braceL:return this.parseBlock();case W.semi:return this.parseEmptyStatement(s);case W._export:case W._import:return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),i===W._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return t||this.unexpected(),this.next(),this.parseFunctionStatement(s,!0);var a=this.value,o=this.parseExpression();return i===W.name&&"Identifier"===o.type&&this.eat(W.colon)?this.parseLabeledStatement(s,a,o):this.parseExpressionStatement(s,o)}},ut.parseBreakContinueStatement=function(t,e){var n=this,r="break"==e;this.next(),this.eat(W.semi)||this.insertSemicolon()?t.label=null:this.type!==W.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var i=0;i=6?this.eat(W.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")},ut.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.inAsync&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(ht),this.enterLexicalScope(),this.expect(W.parenL),this.type===W.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var n=this.isLet();if(this.type===W._var||this.type===W._const||n){var r=this.startNode(),i=n?"let":this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,"VariableDeclaration"),!(this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==r.declarations.length||"var"!==i&&r.declarations[0].init?(e>-1&&this.unexpected(e),this.parseFor(t,r)):(this.options.ecmaVersion>=9&&(this.type===W._in?e>-1&&this.unexpected(e):t.await=e>-1),this.parseForIn(t,r))}var s=new p,a=this.parseExpression(!0,s);return this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.options.ecmaVersion>=9&&(this.type===W._in?e>-1&&this.unexpected(e):t.await=e>-1),this.toAssignable(a,!1,s),this.checkLVal(a),this.parseForIn(t,a)):(this.checkExpressionErrors(s,!0),e>-1&&this.unexpected(e),this.parseFor(t,a))},ut.parseFunctionStatement=function(t,e){return this.next(),this.parseFunction(t,!0,!1,e)},ut.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement(!this.strict&&this.type==W._function),t.alternate=this.eat(W._else)?this.parseStatement(!this.strict&&this.type==W._function):null,this.finishNode(t,"IfStatement")},ut.parseReturnStatement=function(t){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(W.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")},ut.parseSwitchStatement=function(t){var e=this;this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(W.braceL),this.labels.push(lt),this.enterLexicalScope();for(var n,r=!1;this.type!=W.braceR;)if(e.type===W._case||e.type===W._default){var i=e.type===W._case;n&&e.finishNode(n,"SwitchCase"),t.cases.push(n=e.startNode()),n.consequent=[],e.next(),i?n.test=e.parseExpression():(r&&e.raiseRecoverable(e.lastTokStart,"Multiple default clauses"),r=!0,n.test=null),e.expect(W.colon)}else n||e.unexpected(),n.consequent.push(e.parseStatement(!0));return this.exitLexicalScope(),n&&this.finishNode(n,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")},ut.parseThrowStatement=function(t){return this.next(),H.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var ct=[];ut.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===W._catch){var e=this.startNode();this.next(),this.expect(W.parenL),e.param=this.parseBindingAtom(),this.enterLexicalScope(),this.checkLVal(e.param,"let"),this.expect(W.parenR),e.body=this.parseBlock(!1),this.exitLexicalScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(W._finally)?this.parseBlock():null,t.handler||t.finalizer||this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")},ut.parseVarStatement=function(t,e){return this.next(),this.parseVar(t,!1,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")},ut.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(ht),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"WhileStatement")},ut.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement(!1),this.finishNode(t,"WithStatement")},ut.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")},ut.parseLabeledStatement=function(t,e,n){for(var r=this,i=0,s=r.labels;i=0;u--){var h=r.labels[u];if(h.statementStart!=t.start)break;h.statementStart=r.start,h.kind=o}return this.labels.push({name:e,kind:o,statementStart:this.start}),t.body=this.parseStatement(!0),("ClassDeclaration"==t.body.type||"VariableDeclaration"==t.body.type&&"var"!=t.body.kind||"FunctionDeclaration"==t.body.type&&(this.strict||t.body.generator))&&this.raiseRecoverable(t.body.start,"Invalid labeled declaration"),this.labels.pop(),t.label=n,this.finishNode(t,"LabeledStatement")},ut.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")},ut.parseBlock=function(t){var e=this;void 0===t&&(t=!0);var n=this.startNode();for(n.body=[],this.expect(W.braceL),t&&this.enterLexicalScope();!this.eat(W.braceR);){var r=e.parseStatement(!0);n.body.push(r)}return t&&this.exitLexicalScope(),this.finishNode(n,"BlockStatement")},ut.parseFor=function(t,e){return t.init=e,this.expect(W.semi),t.test=this.type===W.semi?null:this.parseExpression(),this.expect(W.semi),t.update=this.type===W.parenR?null:this.parseExpression(),this.expect(W.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"ForStatement")},ut.parseForIn=function(t,e){var n=this.type===W._in?"ForInStatement":"ForOfStatement";return this.next(),"ForInStatement"==n&&("AssignmentPattern"===e.type||"VariableDeclaration"===e.type&&null!=e.declarations[0].init&&(this.strict||"Identifier"!==e.declarations[0].id.type))&&this.raise(e.start,"Invalid assignment in for-in loop head"),t.left=e,t.right="ForInStatement"==n?this.parseExpression():this.parseMaybeAssign(),this.expect(W.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,n)},ut.parseVar=function(t,e,n){var r=this;for(t.declarations=[],t.kind=n;;){var i=r.startNode();if(r.parseVarId(i,n),r.eat(W.eq)?i.init=r.parseMaybeAssign(e):"const"!==n||r.type===W._in||r.options.ecmaVersion>=6&&r.isContextual("of")?"Identifier"==i.id.type||e&&(r.type===W._in||r.isContextual("of"))?i.init=null:r.raise(r.lastTokEnd,"Complex binding patterns require an initialization value"):r.unexpected(),t.declarations.push(r.finishNode(i,"VariableDeclarator")),!r.eat(W.comma))break}return t},ut.parseVarId=function(t,e){t.id=this.parseBindingAtom(e),this.checkLVal(t.id,e,!1)},ut.parseFunction=function(t,e,n,r){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(t.generator=this.eat(W.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&&(t.id="nullableID"===e&&this.type!=W.name?null:this.parseIdent(),t.id&&this.checkLVal(t.id,"var"));var i=this.inGenerator,s=this.inAsync,a=this.yieldPos,o=this.awaitPos,u=this.inFunction;return this.inGenerator=t.generator,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),e||(t.id=this.type==W.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,n),this.inGenerator=i,this.inAsync=s,this.yieldPos=a,this.awaitPos=o,this.inFunction=u, -this.finishNode(t,e?"FunctionDeclaration":"FunctionExpression")},ut.parseFunctionParams=function(t){this.expect(W.parenL),t.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},ut.parseClass=function(t,e){var n=this;this.next(),this.parseClassId(t,e),this.parseClassSuper(t);var r=this.startNode(),i=!1;for(r.body=[],this.expect(W.braceL);!this.eat(W.braceR);){var s=n.parseClassMember(r);s&&"MethodDefinition"===s.type&&"constructor"===s.kind&&(i&&n.raise(s.start,"Duplicate constructor in the same class"),i=!0)}return t.body=this.finishNode(r,"ClassBody"),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")},ut.parseClassMember=function(t){var e=this;if(this.eat(W.semi))return null;var n=this.startNode(),r=function(t,r){void 0===r&&(r=!1);var i=e.start,s=e.startLoc;return!!e.eatContextual(t)&&(!(e.type===W.parenL||r&&e.canInsertSemicolon())||(n.key&&e.unexpected(),n.computed=!1,n.key=e.startNodeAt(i,s),n.key.name=t,e.finishNode(n.key,"Identifier"),!1))};n.kind="method",n["static"]=r("static");var i=this.eat(W.star),s=!1;i||(this.options.ecmaVersion>=8&&r("async",!0)?(s=!0,i=this.options.ecmaVersion>=9&&this.eat(W.star)):r("get")?n.kind="get":r("set")&&(n.kind="set")),n.key||this.parsePropertyName(n);var a=n.key;return n.computed||n["static"]||!("Identifier"===a.type&&"constructor"===a.name||"Literal"===a.type&&"constructor"===a.value)?n["static"]&&"Identifier"===a.type&&"prototype"===a.name&&this.raise(a.start,"Classes may not have a static property named prototype"):("method"!==n.kind&&this.raise(a.start,"Constructor can't have get/set modifier"),i&&this.raise(a.start,"Constructor can't be a generator"),s&&this.raise(a.start,"Constructor can't be an async method"),n.kind="constructor"),this.parseClassMethod(t,n,i,s),"get"===n.kind&&0!==n.value.params.length&&this.raiseRecoverable(n.value.start,"getter should have no params"),"set"===n.kind&&1!==n.value.params.length&&this.raiseRecoverable(n.value.start,"setter should have exactly one param"),"set"===n.kind&&"RestElement"===n.value.params[0].type&&this.raiseRecoverable(n.value.params[0].start,"Setter cannot use rest params"),n},ut.parseClassMethod=function(t,e,n,r){e.value=this.parseMethod(n,r),t.body.push(this.finishNode(e,"MethodDefinition"))},ut.parseClassId=function(t,e){t.id=this.type===W.name?this.parseIdent():e===!0?this.unexpected():null},ut.parseClassSuper=function(t){t.superClass=this.eat(W._extends)?this.parseExprSubscripts():null},ut.parseExport=function(t,e){var n=this;if(this.next(),this.eat(W.star))return this.expectContextual("from"),this.type!==W.string&&this.unexpected(),t.source=this.parseExprAtom(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration");if(this.eat(W._default)){this.checkExport(e,"default",this.lastTokStart);var r;if(this.type===W._function||(r=this.isAsyncFunction())){var i=this.startNode();this.next(),r&&this.next(),t.declaration=this.parseFunction(i,"nullableID",!1,r)}else if(this.type===W._class){var s=this.startNode();t.declaration=this.parseClass(s,"nullableID")}else t.declaration=this.parseMaybeAssign(),this.semicolon();return this.finishNode(t,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())t.declaration=this.parseStatement(!0),"VariableDeclaration"===t.declaration.type?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id.name,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==W.string&&this.unexpected(),t.source=this.parseExprAtom();else{for(var a=0,o=t.specifiers;a=6&&t)switch(t.type){case"Identifier":this.inAsync&&"await"===t.name&&this.raise(t.start,"Can not use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var i=0,s=t.properties;i=9&&"SpreadElement"===t.type||this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var r,i=t.key;switch(i.type){case"Identifier":r=i.name;break;case"Literal":r=String(i.value);break;default:return}var s=t.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===r&&"init"===s&&(e.proto&&(n&&n.doubleProto<0?n.doubleProto=i.start:this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),e.proto=!0));r="$"+r;var a=e[r];if(a){var o;o="init"===s?this.strict&&a.init||a.get||a.set:a.init||a[s],o&&this.raiseRecoverable(i.start,"Redefinition of property")}else a=e[r]={init:!1,get:!1,set:!1};a[s]=!0}},ft.parseExpression=function(t,e){var n=this,r=this.start,i=this.startLoc,s=this.parseMaybeAssign(t,e);if(this.type===W.comma){var a=this.startNodeAt(r,i);for(a.expressions=[s];this.eat(W.comma);)a.expressions.push(n.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return s},ft.parseMaybeAssign=function(t,e,n){if(this.inGenerator&&this.isContextual("yield"))return this.parseYield();var r=!1,i=-1,s=-1;e?(i=e.parenthesizedAssign,s=e.trailingComma,e.parenthesizedAssign=e.trailingComma=-1):(e=new p,r=!0);var a=this.start,o=this.startLoc;this.type!=W.parenL&&this.type!=W.name||(this.potentialArrowAt=this.start);var u=this.parseMaybeConditional(t,e);if(n&&(u=n.call(this,u,a,o)),this.type.isAssign){var h=this.startNodeAt(a,o);return h.operator=this.value,h.left=this.type===W.eq?this.toAssignable(u,!1,e):u,r||p.call(e),e.shorthandAssign=-1,this.checkLVal(u),this.next(),h.right=this.parseMaybeAssign(t),this.finishNode(h,"AssignmentExpression")}return r&&this.checkExpressionErrors(e,!0),i>-1&&(e.parenthesizedAssign=i),s>-1&&(e.trailingComma=s),u},ft.parseMaybeConditional=function(t,e){var n=this.start,r=this.startLoc,i=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return i;if(this.eat(W.question)){var s=this.startNodeAt(n,r);return s.test=i,s.consequent=this.parseMaybeAssign(),this.expect(W.colon),s.alternate=this.parseMaybeAssign(t),this.finishNode(s,"ConditionalExpression")}return i},ft.parseExprOps=function(t,e){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(e,!1);return this.checkExpressionErrors(e)?i:i.start==n&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,n,r,-1,t)},ft.parseExprOp=function(t,e,n,r,i){var s=this.type.binop;if(null!=s&&(!i||this.type!==W._in)&&s>r){var a=this.type===W.logicalOR||this.type===W.logicalAND,o=this.value;this.next();var u=this.start,h=this.startLoc,l=this.parseExprOp(this.parseMaybeUnary(null,!1),u,h,s,i),c=this.buildBinary(e,n,t,l,o,a);return this.parseExprOp(c,e,n,r,i)}return t},ft.buildBinary=function(t,e,n,r,i,s){var a=this.startNodeAt(t,e);return a.left=n,a.operator=i,a.right=r,this.finishNode(a,s?"LogicalExpression":"BinaryExpression")},ft.parseMaybeUnary=function(t,e){var n,r=this,i=this.start,s=this.startLoc;if(this.inAsync&&this.isContextual("await"))n=this.parseAwait(),e=!0;else if(this.type.prefix){var a=this.startNode(),o=this.type===W.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(t,!0),o?this.checkLVal(a.argument):this.strict&&"delete"===a.operator&&"Identifier"===a.argument.type?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):e=!0,n=this.finishNode(a,o?"UpdateExpression":"UnaryExpression")}else{if(n=this.parseExprSubscripts(t),this.checkExpressionErrors(t))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=r.startNodeAt(i,s);u.operator=r.value,u.prefix=!1,u.argument=n,r.checkLVal(n),r.next(),n=r.finishNode(u,"UpdateExpression")}}return!e&&this.eat(W.starstar)?this.buildBinary(i,s,n,this.parseMaybeUnary(null,!1),"**",!1):n},ft.parseExprSubscripts=function(t){var e=this.start,n=this.startLoc,r=this.parseExprAtom(t),i="ArrowFunctionExpression"===r.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd);if(this.checkExpressionErrors(t)||i)return r;var s=this.parseSubscripts(r,e,n);return t&&"MemberExpression"===s.type&&(t.parenthesizedAssign>=s.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=s.start&&(t.parenthesizedBind=-1)),s},ft.parseSubscripts=function(t,e,n,r){for(var i=this,s=this.options.ecmaVersion>=8&&"Identifier"===t.type&&"async"===t.name&&this.lastTokEnd==t.end&&!this.canInsertSemicolon()&&"async"===this.input.slice(t.start,t.end),a=void 0;;)if((a=i.eat(W.bracketL))||i.eat(W.dot)){var o=i.startNodeAt(e,n);o.object=t,o.property=a?i.parseExpression():i.parseIdent(!0),o.computed=!!a,a&&i.expect(W.bracketR),t=i.finishNode(o,"MemberExpression")}else if(!r&&i.eat(W.parenL)){var u=new p,h=i.yieldPos,l=i.awaitPos;i.yieldPos=0,i.awaitPos=0;var c=i.parseExprList(W.parenR,i.options.ecmaVersion>=8,!1,u);if(s&&!i.canInsertSemicolon()&&i.eat(W.arrow))return i.checkPatternErrors(u,!1),i.checkYieldAwaitInDefaultParams(),i.yieldPos=h,i.awaitPos=l,i.parseArrowExpression(i.startNodeAt(e,n),c,!0);i.checkExpressionErrors(u,!0),i.yieldPos=h||i.yieldPos,i.awaitPos=l||i.awaitPos;var f=i.startNodeAt(e,n);f.callee=t,f.arguments=c,t=i.finishNode(f,"CallExpression")}else{if(i.type!==W.backQuote)return t;var d=i.startNodeAt(e,n);d.tag=t,d.quasi=i.parseTemplate({isTagged:!0}),t=i.finishNode(d,"TaggedTemplateExpression")}},ft.parseExprAtom=function(t){var e,n=this.potentialArrowAt==this.start;switch(this.type){case W._super:return this.inFunction||this.raise(this.start,"'super' outside of function or class"),e=this.startNode(),this.next(),this.type!==W.dot&&this.type!==W.bracketL&&this.type!==W.parenL&&this.unexpected(),this.finishNode(e,"Super");case W._this:return e=this.startNode(),this.next(),this.finishNode(e,"ThisExpression");case W.name:var r=this.start,i=this.startLoc,s=this.containsEsc,a=this.parseIdent(this.type!==W.name);if(this.options.ecmaVersion>=8&&!s&&"async"===a.name&&!this.canInsertSemicolon()&&this.eat(W._function))return this.parseFunction(this.startNodeAt(r,i),!1,!1,!0);if(n&&!this.canInsertSemicolon()){if(this.eat(W.arrow))return this.parseArrowExpression(this.startNodeAt(r,i),[a],!1);if(this.options.ecmaVersion>=8&&"async"===a.name&&this.type===W.name&&!s)return a=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(W.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,i),[a],!0)}return a;case W.regexp:var o=this.value;return e=this.parseLiteral(o.value),e.regex={pattern:o.pattern,flags:o.flags},e;case W.num:case W.string:return this.parseLiteral(this.value);case W._null:case W._true:case W._false:return e=this.startNode(),e.value=this.type===W._null?null:this.type===W._true,e.raw=this.type.keyword,this.next(),this.finishNode(e,"Literal");case W.parenL:var u=this.start,h=this.parseParenAndDistinguishExpression(n);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(t.parenthesizedAssign=u),t.parenthesizedBind<0&&(t.parenthesizedBind=u)),h;case W.bracketL:return e=this.startNode(),this.next(),e.elements=this.parseExprList(W.bracketR,!0,!0,t),this.finishNode(e,"ArrayExpression");case W.braceL:return this.parseObj(!1,t);case W._function:return e=this.startNode(),this.next(),this.parseFunction(e,!1);case W._class:return this.parseClass(this.startNode(),!1);case W._new:return this.parseNew();case W.backQuote:return this.parseTemplate();default:this.unexpected()}},ft.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),this.next(),this.finishNode(e,"Literal")},ft.parseParenExpression=function(){this.expect(W.parenL);var t=this.parseExpression();return this.expect(W.parenR),t},ft.parseParenAndDistinguishExpression=function(t){var e,n=this,r=this.start,i=this.startLoc,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,u=this.startLoc,h=[],l=!0,c=!1,f=new p,d=this.yieldPos,m=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==W.parenR;){if(l?l=!1:n.expect(W.comma),s&&n.afterTrailingComma(W.parenR,!0)){c=!0;break}if(n.type===W.ellipsis){a=n.start,h.push(n.parseParenItem(n.parseRestBinding())),n.type===W.comma&&n.raise(n.start,"Comma is not permitted after the rest element");break}h.push(n.parseMaybeAssign(!1,f,n.parseParenItem))}var g=this.start,y=this.startLoc;if(this.expect(W.parenR),t&&!this.canInsertSemicolon()&&this.eat(W.arrow))return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=d,this.awaitPos=m,this.parseParenArrowList(r,i,h);h.length&&!c||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(f,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=m||this.awaitPos,h.length>1?(e=this.startNodeAt(o,u),e.expressions=h,this.finishNodeAt(e,"SequenceExpression",g,y)):e=h[0]}else e=this.parseParenExpression();if(this.options.preserveParens){var x=this.startNodeAt(r,i);return x.expression=e,this.finishNode(x,"ParenthesizedExpression")}return e},ft.parseParenItem=function(t){return t},ft.parseParenArrowList=function(t,e,n){return this.parseArrowExpression(this.startNodeAt(t,e),n)};var dt=[];ft.parseNew=function(){var t=this.startNode(),e=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(W.dot)){t.meta=e;var n=this.containsEsc;return t.property=this.parseIdent(!0),("target"!==t.property.name||n)&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is new.target"),this.inFunction||this.raiseRecoverable(t.start,"new.target can only be used in functions"),this.finishNode(t,"MetaProperty")}var r=this.start,i=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(),r,i,!0),this.eat(W.parenL)?t.arguments=this.parseExprList(W.parenR,this.options.ecmaVersion>=8,!1):t.arguments=dt,this.finishNode(t,"NewExpression")},ft.parseTemplateElement=function(t){var e=t.isTagged,n=this.startNode();return this.type===W.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value,cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===W.backQuote,this.finishNode(n,"TemplateElement")},ft.parseTemplate=function(t){var e=this;void 0===t&&(t={});var n=t.isTagged;void 0===n&&(n=!1);var r=this.startNode();this.next(),r.expressions=[];var i=this.parseTemplateElement({isTagged:n});for(r.quasis=[i];!i.tail;)e.expect(W.dollarBraceL),r.expressions.push(e.parseExpression()),e.expect(W.braceR),r.quasis.push(i=e.parseTemplateElement({isTagged:n}));return this.next(),this.finishNode(r,"TemplateLiteral")},ft.isAsyncProp=function(t){return!t.computed&&"Identifier"===t.key.type&&"async"===t.key.name&&(this.type===W.name||this.type===W.num||this.type===W.string||this.type===W.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===W.star)&&!H.test(this.input.slice(this.lastTokEnd,this.start))},ft.parseObj=function(t,e){var n=this,r=this.startNode(),i=!0,s={};for(r.properties=[],this.next();!this.eat(W.braceR);){if(i)i=!1;else if(n.expect(W.comma),n.afterTrailingComma(W.braceR))break;var a=n.parseProperty(t,e);t||n.checkPropClash(a,s,e),r.properties.push(a)}return this.finishNode(r,t?"ObjectPattern":"ObjectExpression")},ft.parseProperty=function(t,e){var n,r,i,s,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(W.ellipsis))return t?(a.argument=this.parseIdent(!1),this.type===W.comma&&this.raise(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(this.type===W.parenL&&e&&(e.parenthesizedAssign<0&&(e.parenthesizedAssign=this.start),e.parenthesizedBind<0&&(e.parenthesizedBind=this.start)),a.argument=this.parseMaybeAssign(!1,e),this.type===W.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(t||e)&&(i=this.start,s=this.startLoc),t||(n=this.eat(W.star)));var o=this.containsEsc;return this.parsePropertyName(a),!t&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(r=!0,n=this.options.ecmaVersion>=9&&this.eat(W.star),this.parsePropertyName(a,e)):r=!1,this.parsePropertyValue(a,t,n,r,i,s,e,o),this.finishNode(a,"Property")},ft.parsePropertyValue=function(t,e,n,r,i,s,a,o){if((n||r)&&this.type===W.colon&&this.unexpected(),this.eat(W.colon))t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init";else if(this.options.ecmaVersion>=6&&this.type===W.parenL)e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(n,r);else if(e||o||!(this.options.ecmaVersion>=5)||t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||this.type==W.comma||this.type==W.braceR)this.options.ecmaVersion>=6&&!t.computed&&"Identifier"===t.key.type?(this.checkUnreserved(t.key),t.kind="init",e?t.value=this.parseMaybeDefault(i,s,t.key):this.type===W.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(i,s,t.key)):t.value=t.key,t.shorthand=!0):this.unexpected();else{(n||r)&&this.unexpected(),t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var u="get"===t.kind?0:1;if(t.value.params.length!==u){var h=t.value.start;"get"===t.kind?this.raiseRecoverable(h,"getter should have no params"):this.raiseRecoverable(h,"setter should have exactly one param")}else"set"===t.kind&&"RestElement"===t.value.params[0].type&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")}},ft.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(W.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(W.bracketR),t.key;t.computed=!1}return t.key=this.type===W.num||this.type===W.string?this.parseExprAtom():this.parseIdent(!0)},ft.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=!1,t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},ft.parseMethod=function(t,e){var n=this.startNode(),r=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=t),this.options.ecmaVersion>=8&&(n.async=!!e),this.inGenerator=n.generator,this.inAsync=n.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),this.expect(W.parenL),n.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1),this.inGenerator=r,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(n,"FunctionExpression")},ft.parseArrowExpression=function(t,e,n){var r=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.enterFunctionScope(),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!n),this.inGenerator=!1,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0),this.inGenerator=r,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(t,"ArrowFunctionExpression")},ft.parseFunctionBody=function(t,e){var n=e&&this.type!==W.braceL,r=this.strict,i=!1;if(n)t.body=this.parseMaybeAssign(),t.expression=!0,this.checkParams(t,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);r&&!s||(i=this.strictDirective(this.end),i&&s&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var a=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(t,!r&&!i&&!e&&this.isSimpleParamList(t.params)),t.body=this.parseBlock(!1),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=a}this.exitFunctionScope(),this.strict&&t.id&&this.checkLVal(t.id,"none"),this.strict=r},ft.isSimpleParamList=function(t){for(var e=0,n=t;e0;)e[n]=arguments[n+1];for(var r=0,i=e;r=1;e--){var n=t.context[e];if("function"===n.token)return n.generator}return!1},Et.updateContext=function(t){var e,n=this.type;n.keyword&&t==W.dot?this.exprAllowed=!1:(e=n.updateContext)?e.call(this,t):this.exprAllowed=n.beforeExpr; -},W.parenR.updateContext=W.braceR.updateContext=function(){if(1==this.context.length)return void(this.exprAllowed=!0);var t=this.context.pop();t===_t.b_stat&&"function"===this.curContext().token&&(t=this.context.pop()),this.exprAllowed=!t.isExpr},W.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?_t.b_stat:_t.b_expr),this.exprAllowed=!0},W.dollarBraceL.updateContext=function(){this.context.push(_t.b_tmpl),this.exprAllowed=!0},W.parenL.updateContext=function(t){var e=t===W._if||t===W._for||t===W._with||t===W._while;this.context.push(e?_t.p_stat:_t.p_expr),this.exprAllowed=!0},W.incDec.updateContext=function(){},W._function.updateContext=W._class.updateContext=function(t){t.beforeExpr&&t!==W.semi&&t!==W._else&&(t!==W.colon&&t!==W.braceL||this.curContext()!==_t.b_stat)?this.context.push(_t.f_expr):this.context.push(_t.f_stat),this.exprAllowed=!1},W.backQuote.updateContext=function(){this.curContext()===_t.q_tmpl?this.context.pop():this.context.push(_t.q_tmpl),this.exprAllowed=!1},W.star.updateContext=function(t){if(t==W._function){var e=this.context.length-1;this.context[e]===_t.f_expr?this.context[e]=_t.f_expr_gen:this.context[e]=_t.f_gen}this.exprAllowed=!0},W.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&("of"==this.value&&!this.exprAllowed||"yield"==this.value&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var Tt={$LONE:["ASCII","ASCII_Hex_Digit","AHex","Alphabetic","Alpha","Any","Assigned","Bidi_Control","Bidi_C","Bidi_Mirrored","Bidi_M","Case_Ignorable","CI","Cased","Changes_When_Casefolded","CWCF","Changes_When_Casemapped","CWCM","Changes_When_Lowercased","CWL","Changes_When_NFKC_Casefolded","CWKCF","Changes_When_Titlecased","CWT","Changes_When_Uppercased","CWU","Dash","Default_Ignorable_Code_Point","DI","Deprecated","Dep","Diacritic","Dia","Emoji","Emoji_Component","Emoji_Modifier","Emoji_Modifier_Base","Emoji_Presentation","Extender","Ext","Grapheme_Base","Gr_Base","Grapheme_Extend","Gr_Ext","Hex_Digit","Hex","IDS_Binary_Operator","IDSB","IDS_Trinary_Operator","IDST","ID_Continue","IDC","ID_Start","IDS","Ideographic","Ideo","Join_Control","Join_C","Logical_Order_Exception","LOE","Lowercase","Lower","Math","Noncharacter_Code_Point","NChar","Pattern_Syntax","Pat_Syn","Pattern_White_Space","Pat_WS","Quotation_Mark","QMark","Radical","Regional_Indicator","RI","Sentence_Terminal","STerm","Soft_Dotted","SD","Terminal_Punctuation","Term","Unified_Ideograph","UIdeo","Uppercase","Upper","Variation_Selector","VS","White_Space","space","XID_Continue","XIDC","XID_Start","XIDS"],General_Category:["Cased_Letter","LC","Close_Punctuation","Pe","Connector_Punctuation","Pc","Control","Cc","cntrl","Currency_Symbol","Sc","Dash_Punctuation","Pd","Decimal_Number","Nd","digit","Enclosing_Mark","Me","Final_Punctuation","Pf","Format","Cf","Initial_Punctuation","Pi","Letter","L","Letter_Number","Nl","Line_Separator","Zl","Lowercase_Letter","Ll","Mark","M","Combining_Mark","Math_Symbol","Sm","Modifier_Letter","Lm","Modifier_Symbol","Sk","Nonspacing_Mark","Mn","Number","N","Open_Punctuation","Ps","Other","C","Other_Letter","Lo","Other_Number","No","Other_Punctuation","Po","Other_Symbol","So","Paragraph_Separator","Zp","Private_Use","Co","Punctuation","P","punct","Separator","Z","Space_Separator","Zs","Spacing_Mark","Mc","Surrogate","Cs","Symbol","S","Titlecase_Letter","Lt","Unassigned","Cn","Uppercase_Letter","Lu"],Script:["Adlam","Adlm","Ahom","Anatolian_Hieroglyphs","Hluw","Arabic","Arab","Armenian","Armn","Avestan","Avst","Balinese","Bali","Bamum","Bamu","Bassa_Vah","Bass","Batak","Batk","Bengali","Beng","Bhaiksuki","Bhks","Bopomofo","Bopo","Brahmi","Brah","Braille","Brai","Buginese","Bugi","Buhid","Buhd","Canadian_Aboriginal","Cans","Carian","Cari","Caucasian_Albanian","Aghb","Chakma","Cakm","Cham","Cherokee","Cher","Common","Zyyy","Coptic","Copt","Qaac","Cuneiform","Xsux","Cypriot","Cprt","Cyrillic","Cyrl","Deseret","Dsrt","Devanagari","Deva","Duployan","Dupl","Egyptian_Hieroglyphs","Egyp","Elbasan","Elba","Ethiopic","Ethi","Georgian","Geor","Glagolitic","Glag","Gothic","Goth","Grantha","Gran","Greek","Grek","Gujarati","Gujr","Gurmukhi","Guru","Han","Hani","Hangul","Hang","Hanunoo","Hano","Hatran","Hatr","Hebrew","Hebr","Hiragana","Hira","Imperial_Aramaic","Armi","Inherited","Zinh","Qaai","Inscriptional_Pahlavi","Phli","Inscriptional_Parthian","Prti","Javanese","Java","Kaithi","Kthi","Kannada","Knda","Katakana","Kana","Kayah_Li","Kali","Kharoshthi","Khar","Khmer","Khmr","Khojki","Khoj","Khudawadi","Sind","Lao","Laoo","Latin","Latn","Lepcha","Lepc","Limbu","Limb","Linear_A","Lina","Linear_B","Linb","Lisu","Lycian","Lyci","Lydian","Lydi","Mahajani","Mahj","Malayalam","Mlym","Mandaic","Mand","Manichaean","Mani","Marchen","Marc","Masaram_Gondi","Gonm","Meetei_Mayek","Mtei","Mende_Kikakui","Mend","Meroitic_Cursive","Merc","Meroitic_Hieroglyphs","Mero","Miao","Plrd","Modi","Mongolian","Mong","Mro","Mroo","Multani","Mult","Myanmar","Mymr","Nabataean","Nbat","New_Tai_Lue","Talu","Newa","Nko","Nkoo","Nushu","Nshu","Ogham","Ogam","Ol_Chiki","Olck","Old_Hungarian","Hung","Old_Italic","Ital","Old_North_Arabian","Narb","Old_Permic","Perm","Old_Persian","Xpeo","Old_South_Arabian","Sarb","Old_Turkic","Orkh","Oriya","Orya","Osage","Osge","Osmanya","Osma","Pahawh_Hmong","Hmng","Palmyrene","Palm","Pau_Cin_Hau","Pauc","Phags_Pa","Phag","Phoenician","Phnx","Psalter_Pahlavi","Phlp","Rejang","Rjng","Runic","Runr","Samaritan","Samr","Saurashtra","Saur","Sharada","Shrd","Shavian","Shaw","Siddham","Sidd","SignWriting","Sgnw","Sinhala","Sinh","Sora_Sompeng","Sora","Soyombo","Soyo","Sundanese","Sund","Syloti_Nagri","Sylo","Syriac","Syrc","Tagalog","Tglg","Tagbanwa","Tagb","Tai_Le","Tale","Tai_Tham","Lana","Tai_Viet","Tavt","Takri","Takr","Tamil","Taml","Tangut","Tang","Telugu","Telu","Thaana","Thaa","Thai","Tibetan","Tibt","Tifinagh","Tfng","Tirhuta","Tirh","Ugaritic","Ugar","Vai","Vaii","Warang_Citi","Wara","Yi","Yiii","Zanabazar_Square","Zanb"]};Array.prototype.push.apply(Tt.$LONE,Tt.General_Category),Tt.gc=Tt.General_Category,Tt.sc=Tt.Script_Extensions=Tt.scx=Tt.Script;var St=st.prototype,kt=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":""),this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=[],this.backReferenceNames=[]};kt.prototype.reset=function(t,e,n){var r=n.indexOf("u")!==-1;this.start=0|t,this.source=e+"",this.flags=n,this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchN=r&&this.parser.options.ecmaVersion>=9},kt.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)},kt.prototype.at=function(t){var e=this.source,n=e.length;if(t>=n)return-1;var r=e.charCodeAt(t);return!this.switchU||r<=55295||r>=57344||t+1>=n?r:(r<<10)+e.charCodeAt(t+1)-56613888},kt.prototype.nextIndex=function(t){var e=this.source,n=e.length;if(t>=n)return n;var r=e.charCodeAt(t);return!this.switchU||r<=55295||r>=57344||t+1>=n?t+1:t+2},kt.prototype.current=function(){return this.at(this.pos)},kt.prototype.lookahead=function(){return this.at(this.nextIndex(this.pos))},kt.prototype.advance=function(){this.pos=this.nextIndex(this.pos)},kt.prototype.eat=function(t){return this.current()===t&&(this.advance(),!0)},St.validateRegExpFlags=function(t){for(var e=this,n=t.validFlags,r=t.flags,i=0;i-1&&e.raise(t.start,"Duplicate regular expression flag")}},St.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&t.groupNames.length>0&&(t.switchN=!0,this.regexp_pattern(t))},St.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames.length=0,t.backReferenceNames.length=0,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,n=t.backReferenceNames;e=9&&(n=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!n,!0}return t.pos=e,!1},St.regexp_eatQuantifier=function(t,e){return void 0===e&&(e=!1),!!this.regexp_eatQuantifierPrefix(t,e)&&(t.eat(63),!0)},St.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)},St.regexp_eatBracedQuantifier=function(t,e){var n=t.pos;if(t.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(i=t.lastIntValue),t.eat(125)))return i!==-1&&i=9?this.regexp_groupSpecifier(t):63===t.current()&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1},St.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)},St.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1},St.regexp_eatSyntaxCharacter=function(t){var e=t.current();return!!m(e)&&(t.lastIntValue=e,t.advance(),!0)},St.regexp_eatPatternCharacters=function(t){for(var e=t.pos,n=0;(n=t.current())!==-1&&!m(n);)t.advance();return t.pos!==e},St.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return!(e===-1||36===e||e>=40&&e<=43||46===e||63===e||91===e||94===e||124===e)&&(t.advance(),!0)},St.regexp_groupSpecifier=function(t){if(t.eat(63)){if(this.regexp_eatGroupName(t))return t.groupNames.indexOf(t.lastStringValue)!==-1&&t.raise("Duplicate capture group name"),void t.groupNames.push(t.lastStringValue);t.raise("Invalid group")}},St.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1},St.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=d(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=d(t.lastIntValue);return!0}return!1},St.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,n=t.current();return t.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(t)&&(n=t.lastIntValue),g(n)?(t.lastIntValue=n,!0):(t.pos=e,!1)},St.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,n=t.current();return t.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(t)&&(n=t.lastIntValue),y(n)?(t.lastIntValue=n,!0):(t.pos=e,!1)},St.regexp_eatAtomEscape=function(t){return!!(this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t))||(t.switchU&&(99===t.current()&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)},St.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var n=t.lastIntValue;if(t.switchU)return n>t.maxBackReference&&(t.maxBackReference=n),!0;if(n<=t.numCapturingParens)return!0;t.pos=e}return!1},St.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1},St.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)},St.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1},St.regexp_eatZero=function(t){return 48===t.current()&&!T(t.lookahead())&&(t.lastIntValue=0,t.advance(),!0)},St.regexp_eatControlEscape=function(t){var e=t.current();return 116===e?(t.lastIntValue=9,t.advance(),!0):110===e?(t.lastIntValue=10,t.advance(),!0):118===e?(t.lastIntValue=11,t.advance(),!0):102===e?(t.lastIntValue=12,t.advance(),!0):114===e&&(t.lastIntValue=13,t.advance(),!0)},St.regexp_eatControlLetter=function(t){var e=t.current();return!!x(e)&&(t.lastIntValue=e%32,t.advance(),!0)},St.regexp_eatRegExpUnicodeEscapeSequence=function(t){var e=t.pos;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var n=t.lastIntValue;if(t.switchU&&n>=55296&&n<=56319){var r=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var i=t.lastIntValue;if(i>=56320&&i<=57343)return t.lastIntValue=1024*(n-55296)+(i-56320)+65536,!0}t.pos=r,t.lastIntValue=n}return!0}if(t.switchU&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&v(t.lastIntValue))return!0;t.switchU&&t.raise("Invalid unicode escape"),t.pos=e}return!1},St.regexp_eatIdentityEscape=function(t){if(t.switchU)return!!this.regexp_eatSyntaxCharacter(t)||!!t.eat(47)&&(t.lastIntValue=47,!0);var e=t.current();return!(99===e||t.switchN&&107===e)&&(t.lastIntValue=e,t.advance(),!0)},St.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do t.lastIntValue=10*t.lastIntValue+(e-48),t.advance();while((e=t.current())>=48&&e<=57);return!0}return!1},St.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(b(e))return t.lastIntValue=-1,t.advance(),!0;if(t.switchU&&this.options.ecmaVersion>=9&&(80===e||112===e)){if(t.lastIntValue=-1,t.advance(),t.eat(123)&&this.regexp_eatUnicodePropertyValueExpression(t)&&t.eat(125))return!0;t.raise("Invalid property name")}return!1},St.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var n=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,n,r),!0}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var i=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,i),!0}return!1},St.regexp_validateUnicodePropertyNameAndValue=function(t,e,n){Tt.hasOwnProperty(e)&&Tt[e].indexOf(n)!==-1||t.raise("Invalid property name")},St.regexp_validateUnicodePropertyNameOrValue=function(t,e){Tt.$LONE.indexOf(e)===-1&&t.raise("Invalid property name")},St.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";_(e=t.current());)t.lastStringValue+=d(e),t.advance();return""!==t.lastStringValue},St.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";E(e=t.current());)t.lastStringValue+=d(e),t.advance();return""!==t.lastStringValue},St.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)},St.regexp_eatCharacterClass=function(t){if(t.eat(91)){if(t.eat(94),this.regexp_classRanges(t),t.eat(93))return!0;t.raise("Unterminated character class")}return!1},St.regexp_classRanges=function(t){for(var e=this;this.regexp_eatClassAtom(t);){var n=t.lastIntValue;if(t.eat(45)&&e.regexp_eatClassAtom(t)){var r=t.lastIntValue;!t.switchU||n!==-1&&r!==-1||t.raise("Invalid character class"),n!==-1&&r!==-1&&n>r&&t.raise("Range out of order in character class")}}},St.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var n=t.current();(99===n||w(n))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var r=t.current();return 93!==r&&(t.lastIntValue=r,t.advance(),!0)},St.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)},St.regexp_eatClassControlLetter=function(t){var e=t.current();return!(!T(e)&&95!==e)&&(t.lastIntValue=e%32,t.advance(),!0)},St.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1},St.regexp_eatDecimalDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;T(n=t.current());)t.lastIntValue=10*t.lastIntValue+(n-48),t.advance();return t.pos!==e},St.regexp_eatHexDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;S(n=t.current());)t.lastIntValue=16*t.lastIntValue+k(n),t.advance();return t.pos!==e},St.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var n=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=64*e+8*n+t.lastIntValue:t.lastIntValue=8*e+n}else t.lastIntValue=e;return!0}return!1},St.regexp_eatOctalDigit=function(t){var e=t.current();return w(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)},St.regexp_eatFixedHexDigits=function(t,e){var n=t.pos;t.lastIntValue=0;for(var r=0;r=this.input.length?this.finishToken(W.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},At.readToken=function(t){return n(t,this.options.ecmaVersion>=6)||92===t?this.readWord():this.getTokenFromCode(t)},At.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);if(t<=55295||t>=57344)return t;var e=this.input.charCodeAt(this.pos+1);return(t<<10)+e-56613888},At.skipBlockComment=function(){var t=this,e=this.options.onComment&&this.curPosition(),n=this.pos,r=this.input.indexOf("*/",this.pos+=2);if(r===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=r+2,this.options.locations){q.lastIndex=n;for(var i;(i=q.exec(this.input))&&i.index8&&e<14||e>=5760&&Y.test(String.fromCharCode(e))))break t;++t.pos}}},At.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=t,this.value=e,this.updateContext(n)},At.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===t&&46===e?(this.pos+=3,this.finishToken(W.ellipsis)):(++this.pos,this.finishToken(W.dot))},At.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===t?this.finishOp(W.assign,2):this.finishOp(W.slash,1)},At.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),n=1,r=42===t?W.star:W.modulo;return this.options.ecmaVersion>=7&&42==t&&42===e&&(++n,r=W.starstar,e=this.input.charCodeAt(this.pos+2)),61===e?this.finishOp(W.assign,n+1):this.finishOp(r,n)},At.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?this.finishOp(124===t?W.logicalOR:W.logicalAND,2):61===e?this.finishOp(W.assign,2):this.finishOp(124===t?W.bitwiseOR:W.bitwiseAND,1)},At.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(W.assign,2):this.finishOp(W.bitwiseXOR,1)},At.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?45!=e||this.inModule||62!=this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!H.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(W.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===e?this.finishOp(W.assign,2):this.finishOp(W.plusMin,1)},At.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),n=1;return e===t?(n=62===t&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(W.assign,n+1):this.finishOp(W.bitShift,n)):33!=e||60!=t||this.inModule||45!=this.input.charCodeAt(this.pos+2)||45!=this.input.charCodeAt(this.pos+3)?(61===e&&(n=2),this.finishOp(W.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},At.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(W.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===t&&62===e&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(W.arrow)):this.finishOp(61===t?W.eq:W.prefix,1)},At.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(W.parenL);case 41:return++this.pos,this.finishToken(W.parenR);case 59:return++this.pos,this.finishToken(W.semi);case 44:return++this.pos,this.finishToken(W.comma);case 91:return++this.pos,this.finishToken(W.bracketL);case 93:return++this.pos,this.finishToken(W.bracketR);case 123:return++this.pos,this.finishToken(W.braceL);case 125:return++this.pos,this.finishToken(W.braceR);case 58:return++this.pos,this.finishToken(W.colon);case 63:return++this.pos,this.finishToken(W.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(W.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(120===e||88===e)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===e||79===e)return this.readRadixNumber(8);if(98===e||66===e)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 126:return this.finishOp(W.prefix,1)}this.raise(this.pos,"Unexpected character '"+A(t)+"'")},At.finishOp=function(t,e){var n=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,n)},At.readRegexp=function(){for(var t,e,n=this,r=this.pos;;){n.pos>=n.input.length&&n.raise(r,"Unterminated regular expression");var i=n.input.charAt(n.pos);if(H.test(i)&&n.raise(r,"Unterminated regular expression"),t)t=!1;else{if("["===i)e=!0;else if("]"===i&&e)e=!1;else if("/"===i&&!e)break;t="\\"===i}++n.pos}var s=this.input.slice(r,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var u=this.regexpState||(this.regexpState=new kt(this));u.reset(r,s,o),this.validateRegExpFlags(u),this.validateRegExpPattern(u);var h=null;try{h=new RegExp(s,o)}catch(l){}return this.finishToken(W.regexp,{pattern:s,flags:o,value:h})},At.readInt=function(t,e){for(var n=this,r=this.pos,i=0,s=0,a=null==e?1/0:e;s=97?o-97+10:o>=65?o-65+10:o>=48&&o<=57?o-48:1/0,u>=t)break;++n.pos,i=i*t+u}return this.pos===r||null!=e&&this.pos-r!==e?null:i},At.readRadixNumber=function(t){this.pos+=2;var e=this.readInt(t);return null==e&&this.raise(this.start+2,"Expected number in radix "+t),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(W.num,e)},At.readNumber=function(t){var e=this.pos;t||null!==this.readInt(10)||this.raise(e,"Invalid number");var r=this.pos-e>=2&&48===this.input.charCodeAt(e);r&&this.strict&&this.raise(e,"Invalid number"),r&&/[89]/.test(this.input.slice(e,this.pos))&&(r=!1);var i=this.input.charCodeAt(this.pos);46!==i||r||(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),69!==i&&101!==i||r||(i=this.input.charCodeAt(++this.pos),43!==i&&45!==i||++this.pos,null===this.readInt(10)&&this.raise(e,"Invalid number")),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s=this.input.slice(e,this.pos),a=r?parseInt(s,8):parseFloat(s);return this.finishToken(W.num,a)},At.readCodePoint=function(){var t,e=this.input.charCodeAt(this.pos);if(123===e){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t},At.readString=function(t){for(var e=this,n="",r=++this.pos;;){e.pos>=e.input.length&&e.raise(e.start,"Unterminated string constant");var i=e.input.charCodeAt(e.pos);if(i===t)break;92===i?(n+=e.input.slice(r,e.pos),n+=e.readEscapedChar(!1),r=e.pos):(a(i)&&e.raise(e.start,"Unterminated string constant"),++e.pos)}return n+=this.input.slice(r,this.pos++),this.finishToken(W.string,n)};var Ot={};At.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t!==Ot)throw t;this.readInvalidTemplateToken()}this.inTemplateElement=!1},At.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ot;this.raise(t,e)},At.readTmplToken=function(){for(var t=this,e="",n=this.pos;;){t.pos>=t.input.length&&t.raise(t.start,"Unterminated template");var r=t.input.charCodeAt(t.pos);if(96===r||36===r&&123===t.input.charCodeAt(t.pos+1))return t.pos!==t.start||t.type!==W.template&&t.type!==W.invalidTemplate?(e+=t.input.slice(n,t.pos),t.finishToken(W.template,e)):36===r?(t.pos+=2,t.finishToken(W.dollarBraceL)):(++t.pos,t.finishToken(W.backQuote));if(92===r)e+=t.input.slice(n,t.pos),e+=t.readEscapedChar(!0),n=t.pos;else if(a(r)){switch(e+=t.input.slice(n,t.pos),++t.pos,r){case 13:10===t.input.charCodeAt(t.pos)&&++t.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(r)}t.options.locations&&(++t.curLine,t.lineStart=t.pos),n=t.pos}else++t.pos}},At.readInvalidTemplateToken=function(){for(var t=this;this.pos=48&&e<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(n,8);return r>255&&(n=n.slice(0,-1),r=parseInt(n,8)),this.pos+=n.length-1,e=this.input.charCodeAt(this.pos),"0"===n&&56!=e&&57!=e||!this.strict&&!t||this.invalidStringToken(this.pos-1-n.length,"Octal literal in strict mode"),String.fromCharCode(r)}return String.fromCharCode(e)}},At.readHexChar=function(t){var e=this.pos,n=this.readInt(16,t);return null===n&&this.invalidStringToken(e,"Bad character escape sequence"),n},At.readWord1=function(){var t=this;this.containsEsc=!1;for(var e="",i=!0,s=this.pos,a=this.options.ecmaVersion>=6;this.pos0&&e.push(", "),e.push(this.paramTypes[n]),e.push(" "),e.push("user_"),e.push(this.paramNames[n]);return e.push(");\n"),e}},{key:"astFunctionExpression",value:function(t,e){if(!this.isRootKernel){e.push("function"),this.kernalAst=t,e.push(" "),e.push(this.functionName),e.push("(");for(var n=0;n0&&e.push(", "),e.push(" "),e.push("user_"),e.push(i)}e.push(") {\n")}for(var r=0;r1){for(var s=null,a=0;a0&&e.push(","),this.astGeneric(t.declarations[n],e);return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e){return this.astGeneric(t.id,e),null!==t.init&&(e.push("="),this.astGeneric(t.init,e)),e}},{key:"astIfStatement",value:function(t,e){return e.push("if ("),this.astGeneric(t.test,e),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e):(e.push(" {\n"),this.astGeneric(t.consequent,e),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e):(e.push(" {\n"),this.astGeneric(t.alternate,e),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e){return e.push("("),this.astGeneric(t.left,e),e.push(t.operator),this.astGeneric(t.right,e),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e){return e.push("_this"),e}},{key:"astMemberExpression",value:function(t,e){if(t.computed)if("Identifier"===t.object.type||"MemberExpression"===t.object.type&&t.object.object.object&&"ThisExpression"===t.object.object.object.type&&"constants"===t.object.object.property.name)this.pushState("identifier"),this.astGeneric(t.object,e),this.popState("identifier"),e.push("["),this.isInput(t.object.name)?this.astGeneric(t.property,e):this.astGeneric(t.property,e),e.push("]");else if(t.object.object)if(t.object.object.object&&this.isInput(t.object.object.object.name)){this.pushMemberState(t.object.object.object.name),this.pushState("input-index-z"),this.astGeneric(t.object,e);var n=e.pop();e.push(" + "),this.popState("input-index-z"),this.pushState("input-index"),this.astGeneric(t.property,e),this.popState("input-index"),e.push(n),this.popMemberState(t.object.object.object.name)}else if(this.isInput(t.object.object.name)){this.pushMemberState(t.object.object.name),this.isState("input-index-z")||this.pushState("input-index-y"),this.astGeneric(t.object,e);var i=e.pop();e.push(" + "),this.isState("input-index-z")||this.popState("input-index-y");var r=this.isState("input-index-z");r?this.pushState("input-index-y"):this.pushState("input-index"),this.astGeneric(t.property,e),r?this.popState("input-index-y"):this.popState("input-index"),e.push(i),this.popMemberState(t.object.object.name)}else{this.astGeneric(t.object,e);var s=e.pop();e.push("]["),this.astGeneric(t.property,e),e.push(s)}else{this.astGeneric(t.object,e);var a=e.pop();e.push("]["),this.astGeneric(t.property,e),e.push(a)}else{var o=this.astMemberExpressionUnroll(t);switch("Identifier"===t.property.type&&t.computed&&(o="user_"+o),0===o.indexOf("this.constants")?o="constants_"+o.substring(15):0===o.indexOf("this")&&(o="_"+o),this.state){case"input-index-y":case"input-index-z":e.push("(")}switch(o){case"_this.output.x":e.push(this.output[0]);break;case"_this.output.y":e.push(this.output[1]);break;case"_this.output.z":e.push(this.output[2]);break;default:t.object&&t.object.name&&this.declarations[t.object.name]&&e.push("user_"),e.push(o)}switch(this.state){case"input-index-y":var u=this.paramSizes[this.paramNames.indexOf(this.memberState)];e.push(" * "+u[0]+")");break;case"input-index-z":var h=this.paramSizes[this.paramNames.indexOf(this.memberState)];e.push(" * "+h[0]*h[1]+")")}}return e}},{key:"astSequenceExpression",value:function(t,e){for(var n=0;n0&&e.push(","),this.astGeneric(t.expressions,e);return e}},{key:"astCallExpression",value:function(t,e){if(t.callee){var n=this.astMemberExpressionUnroll(t.callee);this.calledFunctions.indexOf(n)<0&&this.calledFunctions.push(n),this.hasOwnProperty("funcName")||(this.calledFunctionsArguments[n]=[]);var i=[];this.calledFunctionsArguments[n].push(i),e.push(n),e.push("(");for(var r=0;r0&&e.push(", "),this.astGeneric(s,e),"Identifier"===s.type){var a=this.paramNames.indexOf(s.name);a===-1?i.push(null):i.push({name:s.name,type:this.paramTypes[a]})}else i.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t)}},{key:"astArrayExpression",value:function(t,e){var n=t.elements.length;e.push("new Float32Array(");for(var i=0;i0&&e.push(", ");var r=t.elements[i];this.astGeneric(r,e)}return e.push(")"),e}},{key:"astDebuggerStatement",value:function(t,e){return e.push("debugger;"),e}},{key:"memberState",get:function(){return this.memberStates[this.memberStates.length-1]}}]),e}(o)},{"../../core/utils":32,"../function-node-base":7}],3:[function(t,e,n){function i(t){return/^function /.test(t)&&(t=t.substring(9)),t.replace(/[_]typeof/g,"typeof")}function r(t){return t.replace(/[_]typeof/g,"typeof")}var s=t("../../core/utils"),a=t("../kernel-run-shortcut");e.exports=function(t,e){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+r(s.allPropertiesOf.toString())+",\n clone: "+r(s.clone.toString())+",\n checkOutput: "+r(s.checkOutput.toString())+"\n };\n const Utils = utils;\n class "+(e||"Kernel")+" {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(t.paramNames)+";\n this.paramTypes = "+JSON.stringify(t.paramTypes)+";\n this.texSize = "+JSON.stringify(t.texSize)+";\n this.output = "+JSON.stringify(t.output)+";\n this._kernelString = `"+t._kernelString+"`;\n this.output = "+JSON.stringify(t.output)+";\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+i(t.build.toString())+"\n "+i(t.setupParams.toString())+"\n "+i(t.setupConstants.toString())+"\n run () { "+t.kernelString+" }\n getKernelString() { return this._kernelString; }\n "+i(t.validateOptions.toString())+"\n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],4:[function(t,e,n){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n1?h=h.filter(function(t){return/^function/.test(t)?t:(c=t,!1)}):c=h.shift();var l=this._kernelString="\n\t\tvar LOOP_MAX = "+this._getLoopMaxString()+"\n\t\tvar constants = this.constants;\n\t\tvar _this = this;\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" var "+t+" = null;\n"}).join(""))+"\n return function ("+this.paramNames.map(function(t){return"user_"+t}).join(", ")+") {\n "+this._processConstants()+"\n "+this._processParams()+"\n var ret = new Array("+n[2]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z = new Array("+n[2]+");\n"}).join(""))+"\n for (this.thread.z = 0; this.thread.z < "+n[2]+"; this.thread.z++) {\n ret[this.thread.z] = new Array("+n[1]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z[this.thread.z] = new Array("+n[1]+");\n"}).join(""))+"\n for (this.thread.y = 0; this.thread.y < "+n[1]+"; this.thread.y++) {\n ret[this.thread.z][this.thread.y] = "+(this.floatOutput?"new Float32Array("+n[0]+")":"new Array("+n[0]+")")+";\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+"Z[this.thread.z][this.thread.y] = "+(t.floatOutput?"new Float32Array("+n[0]+")":"new Array("+n[0]+")")+";\n"}).join(""))+"\n for (this.thread.x = 0; this.thread.x < "+n[0]+"; this.thread.x++) {\n var kernelResult;\n "+c+"\n ret[this.thread.z][this.thread.y][this.thread.x] = kernelResult;\n"+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+"Z[this.thread.z][this.thread.y][this.thread.x] = "+t+";\n"}).join(""))+"\n }\n }\n }\n \n if (this.graphical) {\n this._imageData.data.set(this._colorData);\n this._canvasCtx.putImageData(this._imageData, 0, 0);\n return;\n }\n \n if (this.output.length === 1) {\n ret = ret[0][0];\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+" = "+t+"Z[0][0];\n"}).join(""))+"\n \n } else if (this.output.length === 2) {\n ret = ret[0];\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+" = "+t+"Z[0];\n"}).join(""))+"\n } else {\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(t){return" "+t+" = "+t+"Z;\n"}).join(""))+"\n }\n \n "+(null===this.subKernelOutputVariableNames?"return ret;\n":null!==this.subKernels?"var result = [\n "+this.subKernelOutputVariableNames.map(function(t){return""+t}).join(",\n")+"\n ];\n result.result = ret;\n return result;\n":"return {\n result: ret,\n "+Object.keys(this.subKernelProperties).map(function(e,n){return e+": "+t.subKernelOutputVariableNames[n]}).join(",\n")+"\n };")+"\n "+(h.length>0?h.join("\n"):"")+"\n }.bind(this);";return l}},{key:"toString",value:function(){return h(this)}},{key:"_getLoopMaxString",value:function(){return this.loopMaxIterations?" "+parseInt(this.loopMaxIterations)+";\n":" 1000;\n"}},{key:"_processConstants",value:function(){if(!this.constants)return"";var t=[];for(var e in this.constants){var n=this.constantTypes[e];switch(n){case"HTMLImage":t.push(" var constants_"+e+" = this._imageTo2DArray(this.constants."+e+")");break;case"HTMLImageArray":t.push(" var constants_"+e+" = this._imageTo3DArray(this.constants."+e+")");break;case"Input":t.push(" var constants_"+e+" = this.constants."+e+".value");break;default:t.push(" var constants_"+e+" = this.constants."+e)}}return t.join("\n")}},{key:"_processParams",value:function(){for(var t=[],e=0;e=0;a--){r[a]=new Array(t.width);for(var o=0;o=0||e.push(t)),e}},{key:"addKernel",value:function(t,e){var n=new this.Node("kernel",t,e);return n.setAddFunction(this.addFunction.bind(this)),n.isRootKernel=!0,this.addFunctionNode(n),n}},{key:"addSubKernel",value:function(t,e){var n=new this.Node(null,t,e);return n.setAddFunction(this.addFunction.bind(this)),n.isSubKernel=!0,this.addFunctionNode(n),n}},{key:"getPrototypeString",value:function(t){return this.getPrototypes(t).join("\n")}},{key:"getPrototypes",value:function(t){return this.rootKernel.generate(),t?this.getPrototypesFromFunctionNames(this.traceFunctionCalls(t,[]).reverse()):this.getPrototypesFromFunctionNames(Object.keys(this.nodeMap))}},{key:"getStringFromFunctionNames",value:function(t){for(var e=[],n=0;n ("+i.length+","+this.paramNames.length+")";this.paramTypes=i}else if("object"===("undefined"==typeof i?"undefined":_typeof(i))){var s=Object.keys(i);if(i.hasOwnProperty("returns")&&(this.returnType=i.returns,s.splice(s.indexOf("returns"),1)),s.length>0&&s.length!==this.paramNames.length)throw"Invalid argument type array length, against function length -> ("+s.length+","+this.paramNames.length+")";this.paramTypes=this.paramNames.map(function(t){return i.hasOwnProperty(t)?i[t]:"float"})}}else this.paramTypes=[];this.returnType||(this.returnType=r||"float")}return _createClass(BaseFunctionNode,[{key:"isIdentifierConstant",value:function(t){return!!this.constants&&this.constants.hasOwnProperty(t)}},{key:"isInput",value:function(t){return"Input"===this.paramTypes[this.paramNames.indexOf(t)]}},{key:"setAddFunction",value:function(t){return this.addFunction=t,this}},{key:"pushState",value:function(t){this.states.push(t)}},{key:"popState",value:function(t){if(this.state!==t)throw new Error("Cannot popState "+t+" when in "+this.state);this.states.pop()}},{key:"isState",value:function(t){return this.state===t}},{key:"getJsFunction",value:function getJsFunction(){if(this.jsFunction)return this.jsFunction;if(this.jsFunctionString)return this.jsFunction=eval(this.jsFunctionString),this.jsFunction;throw"Missing jsFunction, and jsFunctionString parameter"; +}},{key:"astMemberExpressionUnroll",value:function(t){if("Identifier"===t.type)return t.name;if("ThisExpression"===t.type)return"this";if("MemberExpression"===t.type&&t.object&&t.property)return t.object.hasOwnProperty("name")&&"_"===t.object.name[0]?this.astMemberExpressionUnroll(t.property):this.astMemberExpressionUnroll(t.object)+"."+this.astMemberExpressionUnroll(t.property);if(t.hasOwnProperty("expressions")){var e=t.expressions[0];if("Literal"===e.type&&0===e.value&&2===t.expressions.length)return this.astMemberExpressionUnroll(t.expressions[1])}throw this.astErrorOutput("Unknown CallExpression_unroll",t)}},{key:"getJsAST",value:function(t){if(this.jsFunctionAST)return this.jsFunctionAST;if(t=t||acorn,null===t)throw"Missing JS to AST parser";var e=t.parse("var "+this.functionName+" = "+this.jsFunctionString+";",{locations:!0});if(null===e)throw"Failed to parse JS code";var n=e.body[0].declarations[0].init;return this.jsFunctionAST=n,n}},{key:"getFunctionString",value:function(){return this.generate(),this.functionString}},{key:"setFunctionString",value:function(t){this.functionString=t}},{key:"getParamType",value:function(t){var e=this.paramNames.indexOf(t);if(e===-1)return this.declarations.hasOwnProperty(t)?this.declarations[t]:null;if(this.parent){if(this.paramTypes[e])return this.paramTypes[e];for(var n=this.parent.calledFunctionsArguments[this.functionName],i=0;i0&&e.push(", ");var r=this.getParamType(i);switch(r){case"Texture":case"Input":case"Array":case"HTMLImage":e.push("sampler2D");break;default:e.push("float")}e.push(" "),e.push("user_"),e.push(i)}e.push(") {\n");for(var s=0;s0&&e.push(", ");var r=this.getParamType(i);switch(r){case"Texture":case"Input":case"Array":e.push("sampler2D");break;default:e.push("float")}e.push(" "),e.push("user_"),e.push(i)}e.push(") {\n");for(var s=0;s1){for(var s=null,a=0;a0&&e.push(",");var r=[];this.astGeneric(i,r),"getImage2D("===r[2]||"getImage3D("===r[2]?(0===n&&e.push("vec4 "),this.declarations[i.id.name]="vec4"):(0===n&&e.push("float "),this.declarations[i.id.name]="float"),e.push.apply(e,r)}return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e){return this.astGeneric(t.id,e),null!==t.init&&(e.push("="),this.astGeneric(t.init,e)),e}},{key:"astIfStatement",value:function(t,e){return e.push("if ("),this.astGeneric(t.test,e),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e):(e.push(" {\n"),this.astGeneric(t.consequent,e),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e):(e.push(" {\n"),this.astGeneric(t.alternate,e),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e){return e.push("("),this.astGeneric(t.left,e),e.push(t.operator),this.astGeneric(t.right,e),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e)):(this.astGeneric(t.argument,e),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e){return e.push("this"),e}},{key:"astMemberExpression",value:function(t,e){if(m("[in] astMemberExpression "+t.object.type),t.computed)if("Identifier"===t.object.type||"MemberExpression"===t.object.type&&t.object.object.object&&"ThisExpression"===t.object.object.object.type&&"constants"===t.object.object.property.name){var n=t.object.name,i=this.functionName||"kernel",r=!1;if(this.paramNames){var s=this.paramNames.indexOf(n);s>=0&&"float"===this.paramTypes[s]&&(r=!0)}if(m("- astMemberExpression "+n+" "+i),r)this.astGeneric(t.object,e),e.push("[int("),this.astGeneric(t.property,e),e.push(")]");else{var a=this.isState("in-get-call-parameters"),o=this.isState("multi-member-expression");o&&this.popState("multi-member-expression"),this.pushState("not-in-get-call-parameters");var u=null;switch(t.object.name?u=this.getParamType(t.object.name):t.object&&t.object.object&&t.object.object.object&&"ThisExpression"===t.object.object.object.type&&(u=this.getConstantType(t.object.property.name)),u){case"vec4":this.astGeneric(t.object,e),e.push("["),e.push(t.property.raw),e.push("]"),o&&this.popState("not-in-get-call-parameters");break;case"HTMLImageArray":e.push("getImage3D("),this.astGeneric(t.object,e),e.push(", ivec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), ivec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.popState("not-in-get-call-parameters"),this.pushState("in-get-call-parameters"),this.astGeneric(t.property,e),o||this.popState("in-get-call-parameters"),e.push(")");break;case"HTMLImage":e.push("getImage2D("),this.astGeneric(t.object,e),e.push(", ivec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), ivec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.popState("not-in-get-call-parameters"),this.pushState("in-get-call-parameters"),this.astGeneric(t.property,e),o||this.popState("in-get-call-parameters"),e.push(")");break;default:a&&e.push("int("),e.push("get("),this.astGeneric(t.object,e),e.push(", ivec2("),this.astGeneric(t.object,e),e.push("Size[0],"),this.astGeneric(t.object,e),e.push("Size[1]), ivec3("),this.astGeneric(t.object,e),e.push("Dim[0],"),this.astGeneric(t.object,e),e.push("Dim[1],"),this.astGeneric(t.object,e),e.push("Dim[2]"),e.push("), "),this.astGeneric(t.object,e),e.push("BitRatio"),e.push(", "),this.popState("not-in-get-call-parameters"),this.pushState("in-get-call-parameters"),this.astGeneric(t.property,e),o||this.popState("in-get-call-parameters"),e.push(")"),a&&e.push(")")}}}else{m("- astMemberExpression obj:",t.object);var h=(this.states.length,this.isState("in-get-call-parameters"));h||this.pushState("multi-member-expression"),this.astGeneric(t.object,e),this.isState("multi-member-expression")&&this.popState("multi-member-expression");var c=!h&&this.isState("in-get-call-parameters"),l=e.pop();e.push(","),m("- astMemberExpression prop:",t.property);var f=this.isState("should-pop-in-get-call-parameters");f&&this.popState("should-pop-in-get-call-parameters"),this.astGeneric(t.property,e),e.push(l),c?this.pushState("should-pop-in-get-call-parameters"):f&&this.popState("in-get-call-parameters")}else{var d=this.astMemberExpressionUnroll(t),g=d.toLowerCase();m("- astMemberExpression unrolled:",d),0===d.indexOf(p)&&(d="constants_"+d.slice(p.length));var x=!this.isState("in-get-call-parameters");switch(g){case"this.thread.x":x&&e.push("float("),e.push("threadId.x"),x&&e.push(")");break;case"this.thread.y":x&&e.push("float("),e.push("threadId.y"),x&&e.push(")");break;case"this.thread.z":x&&e.push("float("),e.push("threadId.z"),x&&e.push(")");break;case"this.output.x":e.push(this.output[0]+".0");break;case"this.output.y":e.push(this.output[1]+".0");break;case"this.output.z":e.push(this.output[2]+".0");break;default:t.object&&t.object.name&&this.declarations[t.object.name]&&e.push("user_"),e.push(d)}}return m("[out] astMemberExpression "+t.object.type),e}},{key:"astSequenceExpression",value:function(t,e){for(var n=0;n0&&e.push(","),this.astGeneric(t.expressions,e);return e}},{key:"astCallExpression",value:function(t,e){if(t.callee){var n=this.astMemberExpressionUnroll(t.callee);0===n.indexOf(c)&&(n=n.slice(c.length)),0===n.indexOf(l)&&(n=n.slice(l.length)),"atan2"===n&&(n="atan"),this.calledFunctions.indexOf(n)<0&&this.calledFunctions.push(n),this.hasOwnProperty("funcName")||(this.calledFunctionsArguments[n]=[]);var i=[];this.calledFunctionsArguments[n].push(i),e.push(n),e.push("(");for(var r=0;r0&&e.push(", "),this.astGeneric(s,e),"Identifier"===s.type){var a=this.paramNames.indexOf(s.name);a===-1?i.push(null):i.push({name:s.name,type:this.paramTypes[a]})}else i.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t)}},{key:"astArrayExpression",value:function(t,e){var n=t.elements.length;e.push("float["+n+"](");for(var i=0;i0&&e.push(", ");var r=t.elements[i];this.astGeneric(r,e)}return e.push(")"),e}},{key:"getFunctionPrototypeString",value:function(){return this.webGlFunctionPrototypeString?this.webGlFunctionPrototypeString:this.webGlFunctionPrototypeString=this.generate()}},{key:"build",value:function(){return this.getFunctionPrototypeString().length>0}}],[{key:"astFunctionPrototype",value:function(t,e){if(this.isRootKernel||this.isSubKernel)return e;e.push(this.returnType),e.push(" "),e.push(this.functionName),e.push("(");for(var n=0;n0&&e.push(", "),e.push(this.paramTypes[n]),e.push(" "),e.push("user_"),e.push(this.paramNames[n]);return e.push(");\n"),e}}]),e}(u)},{"../../core/utils":32,"../function-node-base":7}],20:[function(t,e,n){function i(t){return/^function /.test(t)&&(t=t.substring(9)),t.replace(/[_]typeof/g,"typeof")}function r(t){return t.replace(/[_]typeof/g,"typeof")}var s=t("../../core/utils"),a=t("../kernel-run-shortcut");e.exports=function(t,e){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+r(s.allPropertiesOf.toString())+",\n clone: "+r(s.clone.toString())+",\n splitArray: "+r(s.splitArray.toString())+",\n getArgumentType: "+r(s.getArgumentType.toString())+",\n getDimensions: "+r(s.getDimensions.toString())+",\n dimToTexSize: "+r(s.dimToTexSize.toString())+",\n flattenTo: "+r(s.flattenTo.toString())+",\n flatten2dArrayTo: "+r(s.flatten2dArrayTo.toString())+",\n flatten3dArrayTo: "+r(s.flatten3dArrayTo.toString())+",\n systemEndianness: '"+r(s.systemEndianness())+"',\n initWebGl: "+r(s.initWebGl.toString())+",\n isArray: "+r(s.isArray.toString())+",\n checkOutput: "+r(s.checkOutput.toString())+"\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class "+(e||"Kernel")+" {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(t.paramNames)+";\n this.paramTypes = "+JSON.stringify(t.paramTypes)+";\n this.texSize = "+JSON.stringify(t.texSize)+";\n this.output = "+JSON.stringify(t.output)+";\n this.compiledFragShaderString = `"+t.compiledFragShaderString+"`;\n\t\t this.compiledVertShaderString = `"+t.compiledVertShaderString+"`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform2ivCache = {};\n\t\t this.uniform3fvCache = {};\n\t\t this.uniform3ivCache = {};\n }\n "+i(t._getFragShaderString.toString())+"\n "+i(t._getVertShaderString.toString())+"\n validateOptions() {}\n setupParams() {}\n setupConstants() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+i(t.getUniformLocation.toString())+"\n "+i(t.setupParams.toString())+"\n "+i(t.setupConstants.toString())+"\n "+i(t.build.toString())+"\n\t\t "+i(t.run.toString())+"\n\t\t "+i(t._addArgument.toString())+"\n\t\t "+i(t.getArgumentTexture.toString())+"\n\t\t "+i(t.getTextureCache.toString())+"\n\t\t "+i(t.getOutputTexture.toString())+"\n\t\t "+i(t.renderOutput.toString())+"\n\t\t "+i(t.updateMaxTexSize.toString())+"\n\t\t "+i(t._setupOutputTexture.toString())+"\n\t\t "+i(t.detachTextureCache.toString())+"\n\t\t "+i(t.setUniform1f.toString())+"\n\t\t "+i(t.setUniform1i.toString())+"\n\t\t "+i(t.setUniform2f.toString())+"\n\t\t "+i(t.setUniform2fv.toString())+"\n\t\t "+i(t.setUniform2iv.toString())+"\n\t\t "+i(t.setUniform3fv.toString())+" \n\t\t "+i(t.setUniform3iv.toString())+" \n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],21:[function(t,e,n){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function g(t,e,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,e);if(void 0===i){var r=Object.getPrototypeOf(t);return null===r?void 0:g(r,e,n)}if("value"in i)return i.value;var s=i.get;if(void 0!==s)return s.call(n)},o=function(){function t(t,e){for(var n=0;n0&&this._setupSubOutputTextures(this.subKernelOutputVariableNames.length))}},{key:"run",value:function(){null===this.program&&this.build.apply(this,arguments);var t=this.paramNames,e=this.paramTypes,n=this.texSize,i=this._webGl;i.useProgram(this.program),i.scissor(0,0,n[0],n[1]),this.hardcodeConstants||(this.setUniform3iv("uOutputDim",this.threadDim),this.setUniform2iv("uTexSize",n)),this.setUniform2f("ratio",n[0]/this.maxTexSize[0],n[1]/this.maxTexSize[1]),this.argumentsLength=0;for(var r=0;r0?t.join(";\n")+";\n":"\n"}},{key:"_replaceArtifacts",value:function(t,e){return t.replace(/[ ]*__([A-Z]+[0-9]*([_]?[A-Z])*)__;\n/g,function(t,n){if(e.hasOwnProperty(n))return e[n];throw"unhandled artifact "+n})}},{key:"_addKernels",value:function(){var t=this,e=this.functionBuilder,n=this._webGl;if(e.addFunctions(this.functions,{constants:this.constants,output:this.output}),e.addNativeFunctions(this.nativeFunctions),e.addKernel(this.fnString,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations,paramNames:this.paramNames,paramTypes:this.paramTypes,constantTypes:this.constantTypes,fixIntegerDivisionAccuracy:this.fixIntegerDivisionAccuracy}),null!==this.subKernels){var i=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!i)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],this.subKernels.forEach(function(e){return t._addSubKernel(e)})}else if(null!==this.subKernelProperties){var r=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!r)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],Object.keys(this.subKernelProperties).forEach(function(e){return t._addSubKernel(t.subKernelProperties[e])})}}},{key:"_addSubKernel",value:function(t){this.functionBuilder.addSubKernel(t,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations,fixIntegerDivisionAccuracy:this.fixIntegerDivisionAccuracy}),this.subKernelOutputVariableNames.push(t.name+"Result")}},{key:"_getFragShaderString",value:function(t){return null!==this.compiledFragShaderString?this.compiledFragShaderString:this.compiledFragShaderString=this._replaceArtifacts(this.constructor.fragShaderString,this._getFragShaderArtifactMap(t))}},{key:"_getVertShaderString",value:function(t){return null!==this.compiledVertShaderString?this.compiledVertShaderString:this.compiledVertShaderString=this.constructor.vertShaderString}},{key:"toString",value:function(){return f(this)}},{key:"addFunction",value:function(t){this.functionBuilder.addFunction(null,t)}},{key:"destroy",value:function(t){a(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"destroy",this).call(this),this.outputTexture&&this._webGl.deleteTexture(this.outputTexture),this.buffer&&this._webGl.deleteBuffer(this.buffer),this.framebuffer&&this._webGl.deleteFramebuffer(this.framebuffer),this.vertShader&&this._webGl.deleteShader(this.vertShader),this.fragShader&&this._webGl.deleteShader(this.fragShader),this.program&&this._webGl.deleteProgram(this.program);for(var n=Object.keys(this.textureCache),i=0;i=0&&(d[o]=null,m[o]=null)}delete this._webGl}}]),e}(u)},{"../../core/texture":30,"../../core/utils":32,"../kernel-base":8,"./kernel-string":20,"./shader-frag":23,"./shader-vert":24}],22:[function(t,e,n){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n1&&r*s===i)return[r,s];for(var o=Math.sqrt(i),u=Math.ceil(o),h=Math.floor(o);u*h>i;)u--,h=Math.ceil(i/u);return r=h,s=Math.ceil(i/r),[r,s]}},{key:"getDimensions",value:function(t,e){var i=void 0;if(n.isArray(t)){for(var r=[],s=t;n.isArray(s);)r.push(s.length),s=s[0];i=r.reverse()}else if(t instanceof c)i=t.output;else{if(!(t instanceof h))throw"Unknown dimensions of "+t;i=t.size}if(e)for(i=n.clone(i);i.length<3;)i.push(1);return new Int32Array(i)}},{key:"pad",value:function(t,e){function n(t){return Array.apply(null,new Array(t)).map(Number.prototype.valueOf,0)}for(var i=t.length+2*e,r=t.map(function(t){return[].concat(n(e),t,n(e))}),s=0;st)return!1;if(n+=e[i+1],n>=t)return!0}}function n(t,n){return t<65?36===t:t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&F.test(String.fromCharCode(t)):n!==!1&&e(t,B)))}function i(t,n){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&M.test(String.fromCharCode(t)):n!==!1&&(e(t,B)||e(t,j)))))}function r(t,e){return new V(t,{beforeExpr:!0,binop:e})}function s(t,e){return void 0===e&&(e={}),e.keyword=t,K[t]=new V(t,e)}function a(t,e){return 10===t||13===t||!e&&(8232===t||8233===t)}function o(t,e){return Z.call(t,e)}function u(t,e){for(var n=1,i=0;;){Y.lastIndex=i;var r=Y.exec(t);if(!(r&&r.index=2015&&(e.ecmaVersion-=2009),null==e.allowReserved&&(e.allowReserved=e.ecmaVersion<5),tt(e.onToken)){var i=e.onToken;e.onToken=function(t){return i.push(t)}}return tt(e.onComment)&&(e.onComment=c(e,e.onComment)),e}function c(t,e){return function(n,i,r,s,a,o){var u={type:n?"Block":"Line",value:i,start:r,end:s};t.locations&&(u.loc=new nt(this,a,o)),t.ranges&&(u.range=[r,s]),e.push(u)}}function l(t){return new RegExp("^(?:"+t.replace(/ /g,"|")+")$")}function p(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1}function f(t,e,n,i){return t.type=e,t.end=n,this.options.locations&&(t.loc.end=i),this.options.ranges&&(t.range[1]=n),t}function d(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(1023&t)+56320))}function m(t){return 36===t||t>=40&&t<=43||46===t||63===t||t>=91&&t<=94||t>=123&&t<=125}function g(t){return n(t,!0)||36===t||95===t}function x(t){return i(t,!0)||36===t||95===t||8204===t||8205===t}function v(t){return t>=65&&t<=90||t>=97&&t<=122}function y(t){return t>=0&&t<=1114111}function b(t){return 100===t||68===t||115===t||83===t||119===t||87===t}function _(t){return v(t)||95===t}function E(t){return _(t)||T(t)}function T(t){return t>=48&&t<=57}function S(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function k(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}function w(t){return t>=48&&t<=55}function A(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(1023&t)+56320))}function R(t,e){return new st(e,t).parse()}function O(t,e,n){var i=new st(n,t,e);return i.nextToken(),i.parseExpression()}function C(t,e){return new st(e,t)}function I(e,n,i){t.parse_dammit=e,t.LooseParser=n,t.pluginsLoose=i}var D={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},P="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",N={5:P,6:P+" const class extends export import super"},L=/^in(stanceof)?$/,U="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿯ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞹꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",G="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࣓-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳷-᳹᷀-᷹᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",F=new RegExp("["+U+"]"),M=new RegExp("["+U+G+"]");U=G=null;var B=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,190,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,26,230,43,117,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,68,12,0,67,12,65,1,31,6129,15,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541],j=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239],V=function(t,e){void 0===e&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null},z={beforeExpr:!0},X={startsExpr:!0},K={},W={num:new V("num",X),regexp:new V("regexp",X),string:new V("string",X),name:new V("name",X),eof:new V("eof"),bracketL:new V("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new V("]"),braceL:new V("{",{beforeExpr:!0,startsExpr:!0}),braceR:new V("}"),parenL:new V("(",{beforeExpr:!0,startsExpr:!0}),parenR:new V(")"),comma:new V(",",z),semi:new V(";",z),colon:new V(":",z),dot:new V("."),question:new V("?",z),arrow:new V("=>",z),template:new V("template"),invalidTemplate:new V("invalidTemplate"),ellipsis:new V("...",z),backQuote:new V("`",X),dollarBraceL:new V("${",{beforeExpr:!0,startsExpr:!0}),eq:new V("=",{beforeExpr:!0,isAssign:!0}),assign:new V("_=",{beforeExpr:!0,isAssign:!0}),incDec:new V("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new V("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:r("||",1),logicalAND:r("&&",2),bitwiseOR:r("|",3),bitwiseXOR:r("^",4),bitwiseAND:r("&",5),equality:r("==/!=/===/!==",6),relational:r("/<=/>=",7),bitShift:r("<>/>>>",8),plusMin:new V("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:r("%",10),star:r("*",10),slash:r("/",10),starstar:new V("**",{beforeExpr:!0}),_break:s("break"),_case:s("case",z),_catch:s("catch"),_continue:s("continue"),_debugger:s("debugger"),_default:s("default",z),_do:s("do",{isLoop:!0,beforeExpr:!0}),_else:s("else",z),_finally:s("finally"),_for:s("for",{isLoop:!0}),_function:s("function",X),_if:s("if"),_return:s("return",z),_switch:s("switch"),_throw:s("throw",z),_try:s("try"),_var:s("var"),_const:s("const"),_while:s("while",{isLoop:!0}),_with:s("with"),_new:s("new",{beforeExpr:!0,startsExpr:!0}),_this:s("this",X),_super:s("super",X),_class:s("class",X),_extends:s("extends",z),_export:s("export"),_import:s("import"),_null:s("null",X),_true:s("true",X),_false:s("false",X),_in:s("in",{beforeExpr:!0,binop:7}),_instanceof:s("instanceof",{beforeExpr:!0,binop:7}),_typeof:s("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:s("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:s("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},H=/\r\n?|\n|\u2028|\u2029/,Y=new RegExp(H.source,"g"),q=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,J=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Q=Object.prototype,Z=Q.hasOwnProperty,$=Q.toString,tt=Array.isArray||function(t){return"[object Array]"===$.call(t)},et=function(t,e){this.line=t,this.column=e};et.prototype.offset=function(t){return new et(this.line,this.column+t)};var nt=function(t,e,n){this.start=e,this.end=n,null!==t.sourceFile&&(this.source=t.sourceFile)},it={ecmaVersion:7,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:!1,allowHashBang:!1,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1,plugins:{}},rt={},st=function(t,e,n){this.options=t=h(t),this.sourceFile=t.sourceFile,this.keywords=l(N[t.ecmaVersion>=6?6:5]);var i="";if(!t.allowReserved){for(var r=t.ecmaVersion;!(i=D[r]);r--);"module"===t.sourceType&&(i+=" await")}this.reservedWords=l(i);var s=(i?i+" ":"")+D.strict;this.reservedWordsStrict=l(s),this.reservedWordsStrictBind=l(s+" "+D.strictBind),this.input=String(e),this.containsEsc=!1,this.loadPlugins(t.plugins),n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(H).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=W.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===t.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.inFunction=this.inGenerator=this.inAsync=!1,this.yieldPos=this.awaitPos=0,this.labels=[],0===this.pos&&t.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterFunctionScope(),this.regexpState=null};st.prototype.isKeyword=function(t){return this.keywords.test(t)},st.prototype.isReservedWord=function(t){return this.reservedWords.test(t)},st.prototype.extend=function(t,e){this[t]=e(this[t])},st.prototype.loadPlugins=function(t){var e=this;for(var n in t){var i=rt[n];if(!i)throw new Error("Plugin '"+n+"' not found");i(e,t[n])}},st.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};var at=st.prototype,ot=/^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;at.strictDirective=function(t){for(var e=this;;){J.lastIndex=t,t+=J.exec(e.input)[0].length;var n=ot.exec(e.input.slice(t));if(!n)return!1;if("use strict"===(n[1]||n[2]))return!0;t+=n[0].length}},at.eat=function(t){return this.type===t&&(this.next(),!0)},at.isContextual=function(t){return this.type===W.name&&this.value===t&&!this.containsEsc},at.eatContextual=function(t){return!!this.isContextual(t)&&(this.next(),!0)},at.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},at.canInsertSemicolon=function(){return this.type===W.eof||this.type===W.braceR||H.test(this.input.slice(this.lastTokEnd,this.start))},at.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},at.semicolon=function(){this.eat(W.semi)||this.insertSemicolon()||this.unexpected()},at.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0},at.expect=function(t){this.eat(t)||this.unexpected()},at.unexpected=function(t){this.raise(null!=t?t:this.start,"Unexpected token")},at.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var n=e?t.parenthesizedAssign:t.parenthesizedBind;n>-1&&this.raiseRecoverable(n,"Parenthesized pattern")}},at.checkExpressionErrors=function(t,e){if(!t)return!1;var n=t.shorthandAssign,i=t.doubleProto;return e?(n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),void(i>=0&&this.raiseRecoverable(i,"Redefinition of __proto__ property"))):n>=0||i>=0},at.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&(t.sourceType=this.options.sourceType),this.finishNode(t,"Program")};var ht={kind:"loop"},ct={kind:"switch"};ut.isLet=function(){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;J.lastIndex=this.pos;var t=J.exec(this.input),e=this.pos+t[0].length,r=this.input.charCodeAt(e);if(91===r||123===r)return!0;if(n(r,!0)){for(var s=e+1;i(this.input.charCodeAt(s),!0);)++s;var a=this.input.slice(e,s);if(!L.test(a))return!0}return!1},ut.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;J.lastIndex=this.pos;var t=J.exec(this.input),e=this.pos+t[0].length;return!(H.test(this.input.slice(this.pos,e))||"function"!==this.input.slice(e,e+8)||e+8!==this.input.length&&i(this.input.charAt(e+8)))},ut.parseStatement=function(t,e,n){var i,r=this.type,s=this.startNode();switch(this.isLet()&&(r=W._var,i="let"),r){case W._break:case W._continue:return this.parseBreakContinueStatement(s,r.keyword);case W._debugger:return this.parseDebuggerStatement(s);case W._do:return this.parseDoStatement(s);case W._for:return this.parseForStatement(s);case W._function:return!t&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1);case W._class:return t||this.unexpected(),this.parseClass(s,!0);case W._if:return this.parseIfStatement(s);case W._return:return this.parseReturnStatement(s);case W._switch:return this.parseSwitchStatement(s);case W._throw:return this.parseThrowStatement(s);case W._try:return this.parseTryStatement(s);case W._const:case W._var:return i=i||this.value,t||"var"===i||this.unexpected(),this.parseVarStatement(s,i);case W._while:return this.parseWhileStatement(s);case W._with:return this.parseWithStatement(s);case W.braceL:return this.parseBlock();case W.semi:return this.parseEmptyStatement(s);case W._export:case W._import:return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===W._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return t||this.unexpected(),this.next(),this.parseFunctionStatement(s,!0);var a=this.value,o=this.parseExpression();return r===W.name&&"Identifier"===o.type&&this.eat(W.colon)?this.parseLabeledStatement(s,a,o):this.parseExpressionStatement(s,o)}},ut.parseBreakContinueStatement=function(t,e){var n=this,i="break"===e;this.next(),this.eat(W.semi)||this.insertSemicolon()?t.label=null:this.type!==W.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var r=0;r=6?this.eat(W.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")},ut.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.inAsync&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(ht),this.enterLexicalScope(),this.expect(W.parenL),this.type===W.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var n=this.isLet();if(this.type===W._var||this.type===W._const||n){var i=this.startNode(),r=n?"let":this.value;return this.next(),this.parseVar(i,!0,r),this.finishNode(i,"VariableDeclaration"),!(this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==i.declarations.length||"var"!==r&&i.declarations[0].init?(e>-1&&this.unexpected(e),this.parseFor(t,i)):(this.options.ecmaVersion>=9&&(this.type===W._in?e>-1&&this.unexpected(e):t.await=e>-1),this.parseForIn(t,i))}var s=new p,a=this.parseExpression(!0,s);return this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.options.ecmaVersion>=9&&(this.type===W._in?e>-1&&this.unexpected(e):t.await=e>-1),this.toAssignable(a,!1,s),this.checkLVal(a),this.parseForIn(t,a)):(this.checkExpressionErrors(s,!0),e>-1&&this.unexpected(e),this.parseFor(t,a))},ut.parseFunctionStatement=function(t,e){return this.next(),this.parseFunction(t,!0,!1,e)},ut.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement(!this.strict&&this.type===W._function),t.alternate=this.eat(W._else)?this.parseStatement(!this.strict&&this.type===W._function):null,this.finishNode(t,"IfStatement")},ut.parseReturnStatement=function(t){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(W.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")},ut.parseSwitchStatement=function(t){var e=this;this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(W.braceL),this.labels.push(ct),this.enterLexicalScope();for(var n,i=!1;this.type!==W.braceR;)if(e.type===W._case||e.type===W._default){var r=e.type===W._case;n&&e.finishNode(n,"SwitchCase"),t.cases.push(n=e.startNode()),n.consequent=[],e.next(),r?n.test=e.parseExpression():(i&&e.raiseRecoverable(e.lastTokStart,"Multiple default clauses"),i=!0,n.test=null),e.expect(W.colon)}else n||e.unexpected(),n.consequent.push(e.parseStatement(!0));return this.exitLexicalScope(),n&&this.finishNode(n,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")},ut.parseThrowStatement=function(t){return this.next(),H.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var lt=[];ut.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===W._catch){var e=this.startNode();this.next(),this.eat(W.parenL)?(e.param=this.parseBindingAtom(),this.enterLexicalScope(),this.checkLVal(e.param,"let"),this.expect(W.parenR)):(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterLexicalScope()),e.body=this.parseBlock(!1),this.exitLexicalScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(W._finally)?this.parseBlock():null,t.handler||t.finalizer||this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")},ut.parseVarStatement=function(t,e){return this.next(),this.parseVar(t,!1,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")},ut.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(ht),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"WhileStatement")},ut.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement(!1),this.finishNode(t,"WithStatement")},ut.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")},ut.parseLabeledStatement=function(t,e,n){for(var i=this,r=0,s=i.labels;r=0;u--){var h=i.labels[u];if(h.statementStart!==t.start)break;h.statementStart=i.start,h.kind=o}return this.labels.push({name:e,kind:o,statementStart:this.start}),t.body=this.parseStatement(!0),("ClassDeclaration"===t.body.type||"VariableDeclaration"===t.body.type&&"var"!==t.body.kind||"FunctionDeclaration"===t.body.type&&(this.strict||t.body.generator))&&this.raiseRecoverable(t.body.start,"Invalid labeled declaration"),this.labels.pop(),t.label=n,this.finishNode(t,"LabeledStatement")},ut.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")},ut.parseBlock=function(t){var e=this;void 0===t&&(t=!0);var n=this.startNode();for(n.body=[],this.expect(W.braceL),t&&this.enterLexicalScope();!this.eat(W.braceR);){var i=e.parseStatement(!0);n.body.push(i)}return t&&this.exitLexicalScope(),this.finishNode(n,"BlockStatement")},ut.parseFor=function(t,e){return t.init=e,this.expect(W.semi),t.test=this.type===W.semi?null:this.parseExpression(),this.expect(W.semi),t.update=this.type===W.parenR?null:this.parseExpression(),this.expect(W.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"ForStatement")},ut.parseForIn=function(t,e){var n=this.type===W._in?"ForInStatement":"ForOfStatement";return this.next(),"ForInStatement"===n&&("AssignmentPattern"===e.type||"VariableDeclaration"===e.type&&null!=e.declarations[0].init&&(this.strict||"Identifier"!==e.declarations[0].id.type))&&this.raise(e.start,"Invalid assignment in for-in loop head"),t.left=e,t.right="ForInStatement"===n?this.parseExpression():this.parseMaybeAssign(),this.expect(W.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,n)},ut.parseVar=function(t,e,n){var i=this;for(t.declarations=[],t.kind=n;;){var r=i.startNode();if(i.parseVarId(r,n),i.eat(W.eq)?r.init=i.parseMaybeAssign(e):"const"!==n||i.type===W._in||i.options.ecmaVersion>=6&&i.isContextual("of")?"Identifier"===r.id.type||e&&(i.type===W._in||i.isContextual("of"))?r.init=null:i.raise(i.lastTokEnd,"Complex binding patterns require an initialization value"):i.unexpected(),t.declarations.push(i.finishNode(r,"VariableDeclarator")),!i.eat(W.comma))break}return t},ut.parseVarId=function(t,e){t.id=this.parseBindingAtom(e),this.checkLVal(t.id,e,!1)},ut.parseFunction=function(t,e,n,i){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!i)&&(t.generator=this.eat(W.star)),this.options.ecmaVersion>=8&&(t.async=!!i),e&&(t.id="nullableID"===e&&this.type!==W.name?null:this.parseIdent(),t.id&&this.checkLVal(t.id,"var"));var r=this.inGenerator,s=this.inAsync,a=this.yieldPos,o=this.awaitPos,u=this.inFunction;return this.inGenerator=t.generator,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),e||(t.id=this.type===W.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,n),this.inGenerator=r,this.inAsync=s,this.yieldPos=a,this.awaitPos=o,this.inFunction=u,this.finishNode(t,e?"FunctionDeclaration":"FunctionExpression")},ut.parseFunctionParams=function(t){this.expect(W.parenL),t.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},ut.parseClass=function(t,e){var n=this;this.next(),this.parseClassId(t,e),this.parseClassSuper(t);var i=this.startNode(),r=!1;for(i.body=[],this.expect(W.braceL);!this.eat(W.braceR);){var s=n.parseClassMember(i);s&&"MethodDefinition"===s.type&&"constructor"===s.kind&&(r&&n.raise(s.start,"Duplicate constructor in the same class"),r=!0)}return t.body=this.finishNode(i,"ClassBody"),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")},ut.parseClassMember=function(t){var e=this;if(this.eat(W.semi))return null;var n=this.startNode(),i=function(t,i){void 0===i&&(i=!1);var r=e.start,s=e.startLoc;return!!e.eatContextual(t)&&(!(e.type===W.parenL||i&&e.canInsertSemicolon())||(n.key&&e.unexpected(),n.computed=!1,n.key=e.startNodeAt(r,s),n.key.name=t,e.finishNode(n.key,"Identifier"),!1))};n.kind="method",n["static"]=i("static");var r=this.eat(W.star),s=!1;r||(this.options.ecmaVersion>=8&&i("async",!0)?(s=!0,r=this.options.ecmaVersion>=9&&this.eat(W.star)):i("get")?n.kind="get":i("set")&&(n.kind="set")),n.key||this.parsePropertyName(n);var a=n.key;return n.computed||n["static"]||!("Identifier"===a.type&&"constructor"===a.name||"Literal"===a.type&&"constructor"===a.value)?n["static"]&&"Identifier"===a.type&&"prototype"===a.name&&this.raise(a.start,"Classes may not have a static property named prototype"):("method"!==n.kind&&this.raise(a.start,"Constructor can't have get/set modifier"),r&&this.raise(a.start,"Constructor can't be a generator"),s&&this.raise(a.start,"Constructor can't be an async method"),n.kind="constructor"),this.parseClassMethod(t,n,r,s),"get"===n.kind&&0!==n.value.params.length&&this.raiseRecoverable(n.value.start,"getter should have no params"),"set"===n.kind&&1!==n.value.params.length&&this.raiseRecoverable(n.value.start,"setter should have exactly one param"),"set"===n.kind&&"RestElement"===n.value.params[0].type&&this.raiseRecoverable(n.value.params[0].start,"Setter cannot use rest params"),n},ut.parseClassMethod=function(t,e,n,i){e.value=this.parseMethod(n,i),t.body.push(this.finishNode(e,"MethodDefinition"))},ut.parseClassId=function(t,e){t.id=this.type===W.name?this.parseIdent():e===!0?this.unexpected():null},ut.parseClassSuper=function(t){t.superClass=this.eat(W._extends)?this.parseExprSubscripts():null},ut.parseExport=function(t,e){var n=this;if(this.next(),this.eat(W.star))return this.expectContextual("from"),this.type!==W.string&&this.unexpected(),t.source=this.parseExprAtom(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration");if(this.eat(W._default)){this.checkExport(e,"default",this.lastTokStart);var i;if(this.type===W._function||(i=this.isAsyncFunction())){var r=this.startNode();this.next(),i&&this.next(),t.declaration=this.parseFunction(r,"nullableID",!1,i)}else if(this.type===W._class){var s=this.startNode();t.declaration=this.parseClass(s,"nullableID")}else t.declaration=this.parseMaybeAssign(),this.semicolon();return this.finishNode(t,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())t.declaration=this.parseStatement(!0),"VariableDeclaration"===t.declaration.type?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id.name,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==W.string&&this.unexpected(),t.source=this.parseExprAtom();else{for(var a=0,o=t.specifiers;a=6&&t)switch(t.type){case"Identifier":this.inAsync&&"await"===t.name&&this.raise(t.start,"Can not use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var r=0,s=t.properties;r=9&&"SpreadElement"===t.type||this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var i,r=t.key;switch(r.type){case"Identifier":i=r.name;break;case"Literal":i=String(r.value);break;default:return}var s=t.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===i&&"init"===s&&(e.proto&&(n&&n.doubleProto<0?n.doubleProto=r.start:this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),e.proto=!0));i="$"+i;var a=e[i];if(a){var o;o="init"===s?this.strict&&a.init||a.get||a.set:a.init||a[s],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else a=e[i]={init:!1,get:!1,set:!1};a[s]=!0}},ft.parseExpression=function(t,e){var n=this,i=this.start,r=this.startLoc,s=this.parseMaybeAssign(t,e);if(this.type===W.comma){var a=this.startNodeAt(i,r);for(a.expressions=[s];this.eat(W.comma);)a.expressions.push(n.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return s},ft.parseMaybeAssign=function(t,e,n){if(this.inGenerator&&this.isContextual("yield"))return this.parseYield();var i=!1,r=-1,s=-1;e?(r=e.parenthesizedAssign,s=e.trailingComma,e.parenthesizedAssign=e.trailingComma=-1):(e=new p,i=!0);var a=this.start,o=this.startLoc;this.type!==W.parenL&&this.type!==W.name||(this.potentialArrowAt=this.start);var u=this.parseMaybeConditional(t,e);if(n&&(u=n.call(this,u,a,o)),this.type.isAssign){var h=this.startNodeAt(a,o);return h.operator=this.value,h.left=this.type===W.eq?this.toAssignable(u,!1,e):u,i||p.call(e),e.shorthandAssign=-1,this.checkLVal(u),this.next(),h.right=this.parseMaybeAssign(t),this.finishNode(h,"AssignmentExpression")}return i&&this.checkExpressionErrors(e,!0),r>-1&&(e.parenthesizedAssign=r),s>-1&&(e.trailingComma=s),u},ft.parseMaybeConditional=function(t,e){var n=this.start,i=this.startLoc,r=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return r;if(this.eat(W.question)){var s=this.startNodeAt(n,i);return s.test=r,s.consequent=this.parseMaybeAssign(),this.expect(W.colon),s.alternate=this.parseMaybeAssign(t),this.finishNode(s,"ConditionalExpression")}return r},ft.parseExprOps=function(t,e){var n=this.start,i=this.startLoc,r=this.parseMaybeUnary(e,!1);return this.checkExpressionErrors(e)?r:r.start===n&&"ArrowFunctionExpression"===r.type?r:this.parseExprOp(r,n,i,-1,t)},ft.parseExprOp=function(t,e,n,i,r){var s=this.type.binop;if(null!=s&&(!r||this.type!==W._in)&&s>i){var a=this.type===W.logicalOR||this.type===W.logicalAND,o=this.value;this.next();var u=this.start,h=this.startLoc,c=this.parseExprOp(this.parseMaybeUnary(null,!1),u,h,s,r),l=this.buildBinary(e,n,t,c,o,a);return this.parseExprOp(l,e,n,i,r)}return t},ft.buildBinary=function(t,e,n,i,r,s){var a=this.startNodeAt(t,e);return a.left=n,a.operator=r,a.right=i,this.finishNode(a,s?"LogicalExpression":"BinaryExpression")},ft.parseMaybeUnary=function(t,e){var n,i=this,r=this.start,s=this.startLoc;if(this.isContextual("await")&&(this.inAsync||!this.inFunction&&this.options.allowAwaitOutsideFunction))n=this.parseAwait(),e=!0;else if(this.type.prefix){var a=this.startNode(),o=this.type===W.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(t,!0),o?this.checkLVal(a.argument):this.strict&&"delete"===a.operator&&"Identifier"===a.argument.type?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):e=!0,n=this.finishNode(a,o?"UpdateExpression":"UnaryExpression")}else{if(n=this.parseExprSubscripts(t),this.checkExpressionErrors(t))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=i.startNodeAt(r,s);u.operator=i.value,u.prefix=!1,u.argument=n,i.checkLVal(n),i.next(),n=i.finishNode(u,"UpdateExpression")}}return!e&&this.eat(W.starstar)?this.buildBinary(r,s,n,this.parseMaybeUnary(null,!1),"**",!1):n},ft.parseExprSubscripts=function(t){var e=this.start,n=this.startLoc,i=this.parseExprAtom(t),r="ArrowFunctionExpression"===i.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd);if(this.checkExpressionErrors(t)||r)return i;var s=this.parseSubscripts(i,e,n);return t&&"MemberExpression"===s.type&&(t.parenthesizedAssign>=s.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=s.start&&(t.parenthesizedBind=-1)),s},ft.parseSubscripts=function(t,e,n,i){for(var r=this,s=this.options.ecmaVersion>=8&&"Identifier"===t.type&&"async"===t.name&&this.lastTokEnd===t.end&&!this.canInsertSemicolon()&&"async"===this.input.slice(t.start,t.end),a=void 0;;)if((a=r.eat(W.bracketL))||r.eat(W.dot)){var o=r.startNodeAt(e,n);o.object=t,o.property=a?r.parseExpression():r.parseIdent(!0),o.computed=!!a,a&&r.expect(W.bracketR),t=r.finishNode(o,"MemberExpression")}else if(!i&&r.eat(W.parenL)){var u=new p,h=r.yieldPos,c=r.awaitPos;r.yieldPos=0,r.awaitPos=0;var l=r.parseExprList(W.parenR,r.options.ecmaVersion>=8,!1,u);if(s&&!r.canInsertSemicolon()&&r.eat(W.arrow))return r.checkPatternErrors(u,!1),r.checkYieldAwaitInDefaultParams(),r.yieldPos=h,r.awaitPos=c,r.parseArrowExpression(r.startNodeAt(e,n),l,!0);r.checkExpressionErrors(u,!0),r.yieldPos=h||r.yieldPos,r.awaitPos=c||r.awaitPos;var f=r.startNodeAt(e,n);f.callee=t,f.arguments=l,t=r.finishNode(f,"CallExpression")}else{if(r.type!==W.backQuote)return t;var d=r.startNodeAt(e,n);d.tag=t,d.quasi=r.parseTemplate({isTagged:!0}),t=r.finishNode(d,"TaggedTemplateExpression")}},ft.parseExprAtom=function(t){var e,n=this.potentialArrowAt===this.start;switch(this.type){case W._super:return this.inFunction||this.raise(this.start,"'super' outside of function or class"),e=this.startNode(),this.next(),this.type!==W.dot&&this.type!==W.bracketL&&this.type!==W.parenL&&this.unexpected(),this.finishNode(e,"Super");case W._this:return e=this.startNode(),this.next(),this.finishNode(e,"ThisExpression");case W.name:var i=this.start,r=this.startLoc,s=this.containsEsc,a=this.parseIdent(this.type!==W.name);if(this.options.ecmaVersion>=8&&!s&&"async"===a.name&&!this.canInsertSemicolon()&&this.eat(W._function))return this.parseFunction(this.startNodeAt(i,r),!1,!1,!0);if(n&&!this.canInsertSemicolon()){if(this.eat(W.arrow))return this.parseArrowExpression(this.startNodeAt(i,r),[a],!1);if(this.options.ecmaVersion>=8&&"async"===a.name&&this.type===W.name&&!s)return a=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(W.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(i,r),[a],!0)}return a;case W.regexp:var o=this.value;return e=this.parseLiteral(o.value),e.regex={pattern:o.pattern,flags:o.flags},e;case W.num:case W.string:return this.parseLiteral(this.value);case W._null:case W._true:case W._false:return e=this.startNode(),e.value=this.type===W._null?null:this.type===W._true,e.raw=this.type.keyword,this.next(),this.finishNode(e,"Literal");case W.parenL:var u=this.start,h=this.parseParenAndDistinguishExpression(n);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(t.parenthesizedAssign=u),t.parenthesizedBind<0&&(t.parenthesizedBind=u)),h;case W.bracketL:return e=this.startNode(),this.next(),e.elements=this.parseExprList(W.bracketR,!0,!0,t),this.finishNode(e,"ArrayExpression");case W.braceL:return this.parseObj(!1,t);case W._function:return e=this.startNode(),this.next(),this.parseFunction(e,!1);case W._class:return this.parseClass(this.startNode(),!1);case W._new:return this.parseNew();case W.backQuote:return this.parseTemplate();default:this.unexpected()}},ft.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),this.next(),this.finishNode(e,"Literal")},ft.parseParenExpression=function(){this.expect(W.parenL);var t=this.parseExpression();return this.expect(W.parenR),t},ft.parseParenAndDistinguishExpression=function(t){var e,n=this,i=this.start,r=this.startLoc,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,u=this.startLoc,h=[],c=!0,l=!1,f=new p,d=this.yieldPos,m=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==W.parenR;){if(c?c=!1:n.expect(W.comma),s&&n.afterTrailingComma(W.parenR,!0)){l=!0;break}if(n.type===W.ellipsis){a=n.start,h.push(n.parseParenItem(n.parseRestBinding())),n.type===W.comma&&n.raise(n.start,"Comma is not permitted after the rest element");break}h.push(n.parseMaybeAssign(!1,f,n.parseParenItem))}var g=this.start,x=this.startLoc;if(this.expect(W.parenR),t&&!this.canInsertSemicolon()&&this.eat(W.arrow))return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=d,this.awaitPos=m,this.parseParenArrowList(i,r,h);h.length&&!l||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(f,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=m||this.awaitPos,h.length>1?(e=this.startNodeAt(o,u),e.expressions=h,this.finishNodeAt(e,"SequenceExpression",g,x)):e=h[0]}else e=this.parseParenExpression();if(this.options.preserveParens){var v=this.startNodeAt(i,r);return v.expression=e,this.finishNode(v,"ParenthesizedExpression")}return e},ft.parseParenItem=function(t){return t},ft.parseParenArrowList=function(t,e,n){return this.parseArrowExpression(this.startNodeAt(t,e),n)};var dt=[];ft.parseNew=function(){var t=this.startNode(),e=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(W.dot)){t.meta=e;var n=this.containsEsc;return t.property=this.parseIdent(!0),("target"!==t.property.name||n)&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is new.target"),this.inFunction||this.raiseRecoverable(t.start,"new.target can only be used in functions"),this.finishNode(t,"MetaProperty")}var i=this.start,r=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(),i,r,!0),this.eat(W.parenL)?t.arguments=this.parseExprList(W.parenR,this.options.ecmaVersion>=8,!1):t.arguments=dt,this.finishNode(t,"NewExpression")},ft.parseTemplateElement=function(t){var e=t.isTagged,n=this.startNode();return this.type===W.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"), +n.value={raw:this.value,cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===W.backQuote,this.finishNode(n,"TemplateElement")},ft.parseTemplate=function(t){var e=this;void 0===t&&(t={});var n=t.isTagged;void 0===n&&(n=!1);var i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:n});for(i.quasis=[r];!r.tail;)e.expect(W.dollarBraceL),i.expressions.push(e.parseExpression()),e.expect(W.braceR),i.quasis.push(r=e.parseTemplateElement({isTagged:n}));return this.next(),this.finishNode(i,"TemplateLiteral")},ft.isAsyncProp=function(t){return!t.computed&&"Identifier"===t.key.type&&"async"===t.key.name&&(this.type===W.name||this.type===W.num||this.type===W.string||this.type===W.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===W.star)&&!H.test(this.input.slice(this.lastTokEnd,this.start))},ft.parseObj=function(t,e){var n=this,i=this.startNode(),r=!0,s={};for(i.properties=[],this.next();!this.eat(W.braceR);){if(r)r=!1;else if(n.expect(W.comma),n.afterTrailingComma(W.braceR))break;var a=n.parseProperty(t,e);t||n.checkPropClash(a,s,e),i.properties.push(a)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")},ft.parseProperty=function(t,e){var n,i,r,s,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(W.ellipsis))return t?(a.argument=this.parseIdent(!1),this.type===W.comma&&this.raise(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(this.type===W.parenL&&e&&(e.parenthesizedAssign<0&&(e.parenthesizedAssign=this.start),e.parenthesizedBind<0&&(e.parenthesizedBind=this.start)),a.argument=this.parseMaybeAssign(!1,e),this.type===W.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(t||e)&&(r=this.start,s=this.startLoc),t||(n=this.eat(W.star)));var o=this.containsEsc;return this.parsePropertyName(a),!t&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(i=!0,n=this.options.ecmaVersion>=9&&this.eat(W.star),this.parsePropertyName(a,e)):i=!1,this.parsePropertyValue(a,t,n,i,r,s,e,o),this.finishNode(a,"Property")},ft.parsePropertyValue=function(t,e,n,i,r,s,a,o){if((n||i)&&this.type===W.colon&&this.unexpected(),this.eat(W.colon))t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init";else if(this.options.ecmaVersion>=6&&this.type===W.parenL)e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(n,i);else if(e||o||!(this.options.ecmaVersion>=5)||t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||this.type===W.comma||this.type===W.braceR)this.options.ecmaVersion>=6&&!t.computed&&"Identifier"===t.key.type?(this.checkUnreserved(t.key),t.kind="init",e?t.value=this.parseMaybeDefault(r,s,t.key):this.type===W.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(r,s,t.key)):t.value=t.key,t.shorthand=!0):this.unexpected();else{(n||i)&&this.unexpected(),t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var u="get"===t.kind?0:1;if(t.value.params.length!==u){var h=t.value.start;"get"===t.kind?this.raiseRecoverable(h,"getter should have no params"):this.raiseRecoverable(h,"setter should have exactly one param")}else"set"===t.kind&&"RestElement"===t.value.params[0].type&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")}},ft.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(W.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(W.bracketR),t.key;t.computed=!1}return t.key=this.type===W.num||this.type===W.string?this.parseExprAtom():this.parseIdent(!0)},ft.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=!1,t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},ft.parseMethod=function(t,e){var n=this.startNode(),i=this.inGenerator,r=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=t),this.options.ecmaVersion>=8&&(n.async=!!e),this.inGenerator=n.generator,this.inAsync=n.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),this.expect(W.parenL),n.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1),this.inGenerator=i,this.inAsync=r,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(n,"FunctionExpression")},ft.parseArrowExpression=function(t,e,n){var i=this.inGenerator,r=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.enterFunctionScope(),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!n),this.inGenerator=!1,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0),this.inGenerator=i,this.inAsync=r,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(t,"ArrowFunctionExpression")},ft.parseFunctionBody=function(t,e){var n=e&&this.type!==W.braceL,i=this.strict,r=!1;if(n)t.body=this.parseMaybeAssign(),t.expression=!0,this.checkParams(t,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);i&&!s||(r=this.strictDirective(this.end),r&&s&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var a=this.labels;this.labels=[],r&&(this.strict=!0),this.checkParams(t,!i&&!r&&!e&&this.isSimpleParamList(t.params)),t.body=this.parseBlock(!1),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=a}this.exitFunctionScope(),this.strict&&t.id&&this.checkLVal(t.id,"none"),this.strict=i},ft.isSimpleParamList=function(t){for(var e=0,n=t;e0;)e[n]=arguments[n+1];for(var i=0,r=e;i=1;e--){var n=t.context[e];if("function"===n.token)return n.generator}return!1},Et.updateContext=function(t){var e,n=this.type;n.keyword&&t===W.dot?this.exprAllowed=!1:(e=n.updateContext)?e.call(this,t):this.exprAllowed=n.beforeExpr},W.parenR.updateContext=W.braceR.updateContext=function(){if(1===this.context.length)return void(this.exprAllowed=!0);var t=this.context.pop();t===_t.b_stat&&"function"===this.curContext().token&&(t=this.context.pop()),this.exprAllowed=!t.isExpr},W.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?_t.b_stat:_t.b_expr),this.exprAllowed=!0},W.dollarBraceL.updateContext=function(){this.context.push(_t.b_tmpl),this.exprAllowed=!0},W.parenL.updateContext=function(t){var e=t===W._if||t===W._for||t===W._with||t===W._while;this.context.push(e?_t.p_stat:_t.p_expr),this.exprAllowed=!0},W.incDec.updateContext=function(){},W._function.updateContext=W._class.updateContext=function(t){t.beforeExpr&&t!==W.semi&&t!==W._else&&(t!==W.colon&&t!==W.braceL||this.curContext()!==_t.b_stat)?this.context.push(_t.f_expr):this.context.push(_t.f_stat),this.exprAllowed=!1},W.backQuote.updateContext=function(){this.curContext()===_t.q_tmpl?this.context.pop():this.context.push(_t.q_tmpl),this.exprAllowed=!1},W.star.updateContext=function(t){if(t===W._function){var e=this.context.length-1;this.context[e]===_t.f_expr?this.context[e]=_t.f_expr_gen:this.context[e]=_t.f_gen}this.exprAllowed=!0},W.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&("of"===this.value&&!this.exprAllowed||"yield"===this.value&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var Tt={$LONE:["ASCII","ASCII_Hex_Digit","AHex","Alphabetic","Alpha","Any","Assigned","Bidi_Control","Bidi_C","Bidi_Mirrored","Bidi_M","Case_Ignorable","CI","Cased","Changes_When_Casefolded","CWCF","Changes_When_Casemapped","CWCM","Changes_When_Lowercased","CWL","Changes_When_NFKC_Casefolded","CWKCF","Changes_When_Titlecased","CWT","Changes_When_Uppercased","CWU","Dash","Default_Ignorable_Code_Point","DI","Deprecated","Dep","Diacritic","Dia","Emoji","Emoji_Component","Emoji_Modifier","Emoji_Modifier_Base","Emoji_Presentation","Extender","Ext","Grapheme_Base","Gr_Base","Grapheme_Extend","Gr_Ext","Hex_Digit","Hex","IDS_Binary_Operator","IDSB","IDS_Trinary_Operator","IDST","ID_Continue","IDC","ID_Start","IDS","Ideographic","Ideo","Join_Control","Join_C","Logical_Order_Exception","LOE","Lowercase","Lower","Math","Noncharacter_Code_Point","NChar","Pattern_Syntax","Pat_Syn","Pattern_White_Space","Pat_WS","Quotation_Mark","QMark","Radical","Regional_Indicator","RI","Sentence_Terminal","STerm","Soft_Dotted","SD","Terminal_Punctuation","Term","Unified_Ideograph","UIdeo","Uppercase","Upper","Variation_Selector","VS","White_Space","space","XID_Continue","XIDC","XID_Start","XIDS"],General_Category:["Cased_Letter","LC","Close_Punctuation","Pe","Connector_Punctuation","Pc","Control","Cc","cntrl","Currency_Symbol","Sc","Dash_Punctuation","Pd","Decimal_Number","Nd","digit","Enclosing_Mark","Me","Final_Punctuation","Pf","Format","Cf","Initial_Punctuation","Pi","Letter","L","Letter_Number","Nl","Line_Separator","Zl","Lowercase_Letter","Ll","Mark","M","Combining_Mark","Math_Symbol","Sm","Modifier_Letter","Lm","Modifier_Symbol","Sk","Nonspacing_Mark","Mn","Number","N","Open_Punctuation","Ps","Other","C","Other_Letter","Lo","Other_Number","No","Other_Punctuation","Po","Other_Symbol","So","Paragraph_Separator","Zp","Private_Use","Co","Punctuation","P","punct","Separator","Z","Space_Separator","Zs","Spacing_Mark","Mc","Surrogate","Cs","Symbol","S","Titlecase_Letter","Lt","Unassigned","Cn","Uppercase_Letter","Lu"],Script:["Adlam","Adlm","Ahom","Anatolian_Hieroglyphs","Hluw","Arabic","Arab","Armenian","Armn","Avestan","Avst","Balinese","Bali","Bamum","Bamu","Bassa_Vah","Bass","Batak","Batk","Bengali","Beng","Bhaiksuki","Bhks","Bopomofo","Bopo","Brahmi","Brah","Braille","Brai","Buginese","Bugi","Buhid","Buhd","Canadian_Aboriginal","Cans","Carian","Cari","Caucasian_Albanian","Aghb","Chakma","Cakm","Cham","Cherokee","Cher","Common","Zyyy","Coptic","Copt","Qaac","Cuneiform","Xsux","Cypriot","Cprt","Cyrillic","Cyrl","Deseret","Dsrt","Devanagari","Deva","Duployan","Dupl","Egyptian_Hieroglyphs","Egyp","Elbasan","Elba","Ethiopic","Ethi","Georgian","Geor","Glagolitic","Glag","Gothic","Goth","Grantha","Gran","Greek","Grek","Gujarati","Gujr","Gurmukhi","Guru","Han","Hani","Hangul","Hang","Hanunoo","Hano","Hatran","Hatr","Hebrew","Hebr","Hiragana","Hira","Imperial_Aramaic","Armi","Inherited","Zinh","Qaai","Inscriptional_Pahlavi","Phli","Inscriptional_Parthian","Prti","Javanese","Java","Kaithi","Kthi","Kannada","Knda","Katakana","Kana","Kayah_Li","Kali","Kharoshthi","Khar","Khmer","Khmr","Khojki","Khoj","Khudawadi","Sind","Lao","Laoo","Latin","Latn","Lepcha","Lepc","Limbu","Limb","Linear_A","Lina","Linear_B","Linb","Lisu","Lycian","Lyci","Lydian","Lydi","Mahajani","Mahj","Malayalam","Mlym","Mandaic","Mand","Manichaean","Mani","Marchen","Marc","Masaram_Gondi","Gonm","Meetei_Mayek","Mtei","Mende_Kikakui","Mend","Meroitic_Cursive","Merc","Meroitic_Hieroglyphs","Mero","Miao","Plrd","Modi","Mongolian","Mong","Mro","Mroo","Multani","Mult","Myanmar","Mymr","Nabataean","Nbat","New_Tai_Lue","Talu","Newa","Nko","Nkoo","Nushu","Nshu","Ogham","Ogam","Ol_Chiki","Olck","Old_Hungarian","Hung","Old_Italic","Ital","Old_North_Arabian","Narb","Old_Permic","Perm","Old_Persian","Xpeo","Old_South_Arabian","Sarb","Old_Turkic","Orkh","Oriya","Orya","Osage","Osge","Osmanya","Osma","Pahawh_Hmong","Hmng","Palmyrene","Palm","Pau_Cin_Hau","Pauc","Phags_Pa","Phag","Phoenician","Phnx","Psalter_Pahlavi","Phlp","Rejang","Rjng","Runic","Runr","Samaritan","Samr","Saurashtra","Saur","Sharada","Shrd","Shavian","Shaw","Siddham","Sidd","SignWriting","Sgnw","Sinhala","Sinh","Sora_Sompeng","Sora","Soyombo","Soyo","Sundanese","Sund","Syloti_Nagri","Sylo","Syriac","Syrc","Tagalog","Tglg","Tagbanwa","Tagb","Tai_Le","Tale","Tai_Tham","Lana","Tai_Viet","Tavt","Takri","Takr","Tamil","Taml","Tangut","Tang","Telugu","Telu","Thaana","Thaa","Thai","Tibetan","Tibt","Tifinagh","Tfng","Tirhuta","Tirh","Ugaritic","Ugar","Vai","Vaii","Warang_Citi","Wara","Yi","Yiii","Zanabazar_Square","Zanb"]};Array.prototype.push.apply(Tt.$LONE,Tt.General_Category),Tt.gc=Tt.General_Category,Tt.sc=Tt.Script_Extensions=Tt.scx=Tt.Script;var St=st.prototype,kt=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":""),this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=[],this.backReferenceNames=[]};kt.prototype.reset=function(t,e,n){var i=n.indexOf("u")!==-1;this.start=0|t,this.source=e+"",this.flags=n,this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchN=i&&this.parser.options.ecmaVersion>=9},kt.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)},kt.prototype.at=function(t){var e=this.source,n=e.length;if(t>=n)return-1;var i=e.charCodeAt(t);return!this.switchU||i<=55295||i>=57344||t+1>=n?i:(i<<10)+e.charCodeAt(t+1)-56613888},kt.prototype.nextIndex=function(t){var e=this.source,n=e.length;if(t>=n)return n;var i=e.charCodeAt(t);return!this.switchU||i<=55295||i>=57344||t+1>=n?t+1:t+2},kt.prototype.current=function(){return this.at(this.pos)},kt.prototype.lookahead=function(){return this.at(this.nextIndex(this.pos))},kt.prototype.advance=function(){this.pos=this.nextIndex(this.pos)},kt.prototype.eat=function(t){return this.current()===t&&(this.advance(),!0)},St.validateRegExpFlags=function(t){for(var e=this,n=t.validFlags,i=t.flags,r=0;r-1&&e.raise(t.start,"Duplicate regular expression flag")}},St.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&t.groupNames.length>0&&(t.switchN=!0,this.regexp_pattern(t))},St.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames.length=0,t.backReferenceNames.length=0,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,n=t.backReferenceNames;e=9&&(n=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!n,!0}return t.pos=e,!1},St.regexp_eatQuantifier=function(t,e){return void 0===e&&(e=!1),!!this.regexp_eatQuantifierPrefix(t,e)&&(t.eat(63),!0)},St.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)},St.regexp_eatBracedQuantifier=function(t,e){var n=t.pos;if(t.eat(123)){var i=0,r=-1;if(this.regexp_eatDecimalDigits(t)&&(i=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue),t.eat(125)))return r!==-1&&r=9?this.regexp_groupSpecifier(t):63===t.current()&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1},St.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)},St.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1},St.regexp_eatSyntaxCharacter=function(t){var e=t.current();return!!m(e)&&(t.lastIntValue=e,t.advance(),!0)},St.regexp_eatPatternCharacters=function(t){for(var e=t.pos,n=0;(n=t.current())!==-1&&!m(n);)t.advance();return t.pos!==e},St.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return!(e===-1||36===e||e>=40&&e<=43||46===e||63===e||91===e||94===e||124===e)&&(t.advance(),!0)},St.regexp_groupSpecifier=function(t){if(t.eat(63)){if(this.regexp_eatGroupName(t))return t.groupNames.indexOf(t.lastStringValue)!==-1&&t.raise("Duplicate capture group name"),void t.groupNames.push(t.lastStringValue);t.raise("Invalid group")}},St.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1},St.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=d(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=d(t.lastIntValue);return!0}return!1},St.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,n=t.current();return t.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(t)&&(n=t.lastIntValue),g(n)?(t.lastIntValue=n,!0):(t.pos=e,!1)},St.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,n=t.current();return t.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(t)&&(n=t.lastIntValue),x(n)?(t.lastIntValue=n,!0):(t.pos=e,!1)},St.regexp_eatAtomEscape=function(t){return!!(this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t))||(t.switchU&&(99===t.current()&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)},St.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var n=t.lastIntValue;if(t.switchU)return n>t.maxBackReference&&(t.maxBackReference=n),!0;if(n<=t.numCapturingParens)return!0;t.pos=e}return!1},St.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1},St.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)},St.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1},St.regexp_eatZero=function(t){return 48===t.current()&&!T(t.lookahead())&&(t.lastIntValue=0,t.advance(),!0)},St.regexp_eatControlEscape=function(t){var e=t.current();return 116===e?(t.lastIntValue=9,t.advance(),!0):110===e?(t.lastIntValue=10,t.advance(),!0):118===e?(t.lastIntValue=11,t.advance(),!0):102===e?(t.lastIntValue=12,t.advance(),!0):114===e&&(t.lastIntValue=13,t.advance(),!0)},St.regexp_eatControlLetter=function(t){var e=t.current();return!!v(e)&&(t.lastIntValue=e%32,t.advance(),!0)},St.regexp_eatRegExpUnicodeEscapeSequence=function(t){var e=t.pos;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var n=t.lastIntValue;if(t.switchU&&n>=55296&&n<=56319){var i=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var r=t.lastIntValue;if(r>=56320&&r<=57343)return t.lastIntValue=1024*(n-55296)+(r-56320)+65536,!0}t.pos=i,t.lastIntValue=n}return!0}if(t.switchU&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&y(t.lastIntValue))return!0;t.switchU&&t.raise("Invalid unicode escape"),t.pos=e}return!1},St.regexp_eatIdentityEscape=function(t){if(t.switchU)return!!this.regexp_eatSyntaxCharacter(t)||!!t.eat(47)&&(t.lastIntValue=47,!0);var e=t.current();return!(99===e||t.switchN&&107===e)&&(t.lastIntValue=e,t.advance(),!0)},St.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do t.lastIntValue=10*t.lastIntValue+(e-48),t.advance();while((e=t.current())>=48&&e<=57);return!0}return!1},St.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(b(e))return t.lastIntValue=-1,t.advance(),!0;if(t.switchU&&this.options.ecmaVersion>=9&&(80===e||112===e)){if(t.lastIntValue=-1,t.advance(),t.eat(123)&&this.regexp_eatUnicodePropertyValueExpression(t)&&t.eat(125))return!0;t.raise("Invalid property name")}return!1},St.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var n=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var i=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,n,i),!0}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,r),!0}return!1},St.regexp_validateUnicodePropertyNameAndValue=function(t,e,n){Tt.hasOwnProperty(e)&&Tt[e].indexOf(n)!==-1||t.raise("Invalid property name")},St.regexp_validateUnicodePropertyNameOrValue=function(t,e){Tt.$LONE.indexOf(e)===-1&&t.raise("Invalid property name")},St.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";_(e=t.current());)t.lastStringValue+=d(e),t.advance();return""!==t.lastStringValue},St.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";E(e=t.current());)t.lastStringValue+=d(e),t.advance();return""!==t.lastStringValue},St.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)},St.regexp_eatCharacterClass=function(t){if(t.eat(91)){if(t.eat(94),this.regexp_classRanges(t),t.eat(93))return!0;t.raise("Unterminated character class")}return!1},St.regexp_classRanges=function(t){for(var e=this;this.regexp_eatClassAtom(t);){var n=t.lastIntValue;if(t.eat(45)&&e.regexp_eatClassAtom(t)){var i=t.lastIntValue;!t.switchU||n!==-1&&i!==-1||t.raise("Invalid character class"),n!==-1&&i!==-1&&n>i&&t.raise("Range out of order in character class")}}},St.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var n=t.current();(99===n||w(n))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var i=t.current();return 93!==i&&(t.lastIntValue=i,t.advance(),!0)},St.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)},St.regexp_eatClassControlLetter=function(t){var e=t.current();return!(!T(e)&&95!==e)&&(t.lastIntValue=e%32,t.advance(),!0)},St.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1},St.regexp_eatDecimalDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;T(n=t.current());)t.lastIntValue=10*t.lastIntValue+(n-48),t.advance();return t.pos!==e},St.regexp_eatHexDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;S(n=t.current());)t.lastIntValue=16*t.lastIntValue+k(n),t.advance();return t.pos!==e},St.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var n=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=64*e+8*n+t.lastIntValue:t.lastIntValue=8*e+n}else t.lastIntValue=e;return!0}return!1},St.regexp_eatOctalDigit=function(t){var e=t.current();return w(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)},St.regexp_eatFixedHexDigits=function(t,e){var n=t.pos;t.lastIntValue=0;for(var i=0;i=this.input.length?this.finishToken(W.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},At.readToken=function(t){return n(t,this.options.ecmaVersion>=6)||92===t?this.readWord():this.getTokenFromCode(t)},At.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);if(t<=55295||t>=57344)return t;var e=this.input.charCodeAt(this.pos+1);return(t<<10)+e-56613888},At.skipBlockComment=function(){var t=this,e=this.options.onComment&&this.curPosition(),n=this.pos,i=this.input.indexOf("*/",this.pos+=2);if(i===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=i+2,this.options.locations){Y.lastIndex=n;for(var r;(r=Y.exec(this.input))&&r.index8&&e<14||e>=5760&&q.test(String.fromCharCode(e))))break t;++t.pos}}},At.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=t,this.value=e,this.updateContext(n)},At.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===t&&46===e?(this.pos+=3,this.finishToken(W.ellipsis)):(++this.pos,this.finishToken(W.dot))},At.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===t?this.finishOp(W.assign,2):this.finishOp(W.slash,1)},At.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),n=1,i=42===t?W.star:W.modulo;return this.options.ecmaVersion>=7&&42===t&&42===e&&(++n,i=W.starstar,e=this.input.charCodeAt(this.pos+2)),61===e?this.finishOp(W.assign,n+1):this.finishOp(i,n)},At.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?this.finishOp(124===t?W.logicalOR:W.logicalAND,2):61===e?this.finishOp(W.assign,2):this.finishOp(124===t?W.bitwiseOR:W.bitwiseAND,1)},At.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(W.assign,2):this.finishOp(W.bitwiseXOR,1)},At.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?45!==e||this.inModule||62!==this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!H.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(W.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===e?this.finishOp(W.assign,2):this.finishOp(W.plusMin,1)},At.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),n=1;return e===t?(n=62===t&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(W.assign,n+1):this.finishOp(W.bitShift,n)):33!==e||60!==t||this.inModule||45!==this.input.charCodeAt(this.pos+2)||45!==this.input.charCodeAt(this.pos+3)?(61===e&&(n=2),this.finishOp(W.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},At.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(W.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===t&&62===e&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(W.arrow)):this.finishOp(61===t?W.eq:W.prefix,1)},At.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(W.parenL);case 41:return++this.pos,this.finishToken(W.parenR);case 59:return++this.pos,this.finishToken(W.semi);case 44:return++this.pos,this.finishToken(W.comma);case 91:return++this.pos,this.finishToken(W.bracketL);case 93:return++this.pos,this.finishToken(W.bracketR);case 123:return++this.pos,this.finishToken(W.braceL);case 125:return++this.pos,this.finishToken(W.braceR);case 58:return++this.pos,this.finishToken(W.colon);case 63:return++this.pos,this.finishToken(W.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(W.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(120===e||88===e)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===e||79===e)return this.readRadixNumber(8);if(98===e||66===e)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 126:return this.finishOp(W.prefix,1)}this.raise(this.pos,"Unexpected character '"+A(t)+"'")},At.finishOp=function(t,e){var n=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,n)},At.readRegexp=function(){for(var t,e,n=this,i=this.pos;;){n.pos>=n.input.length&&n.raise(i,"Unterminated regular expression");var r=n.input.charAt(n.pos);if(H.test(r)&&n.raise(i,"Unterminated regular expression"),t)t=!1;else{if("["===r)e=!0;else if("]"===r&&e)e=!1;else if("/"===r&&!e)break;t="\\"===r}++n.pos}var s=this.input.slice(i,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var u=this.regexpState||(this.regexpState=new kt(this));u.reset(i,s,o),this.validateRegExpFlags(u),this.validateRegExpPattern(u);var h=null;try{h=new RegExp(s,o)}catch(c){}return this.finishToken(W.regexp,{pattern:s,flags:o,value:h})},At.readInt=function(t,e){for(var n=this,i=this.pos,r=0,s=0,a=null==e?1/0:e;s=97?o-97+10:o>=65?o-65+10:o>=48&&o<=57?o-48:1/0,u>=t)break;++n.pos,r=r*t+u}return this.pos===i||null!=e&&this.pos-i!==e?null:r},At.readRadixNumber=function(t){this.pos+=2;var e=this.readInt(t);return null==e&&this.raise(this.start+2,"Expected number in radix "+t),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(W.num,e)},At.readNumber=function(t){var e=this.pos;t||null!==this.readInt(10)||this.raise(e,"Invalid number");var i=this.pos-e>=2&&48===this.input.charCodeAt(e);i&&this.strict&&this.raise(e,"Invalid number"),i&&/[89]/.test(this.input.slice(e,this.pos))&&(i=!1);var r=this.input.charCodeAt(this.pos);46!==r||i||(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),69!==r&&101!==r||i||(r=this.input.charCodeAt(++this.pos),43!==r&&45!==r||++this.pos,null===this.readInt(10)&&this.raise(e,"Invalid number")),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s=this.input.slice(e,this.pos),a=i?parseInt(s,8):parseFloat(s);return this.finishToken(W.num,a)},At.readCodePoint=function(){var t,e=this.input.charCodeAt(this.pos);if(123===e){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t},At.readString=function(t){for(var e=this,n="",i=++this.pos;;){e.pos>=e.input.length&&e.raise(e.start,"Unterminated string constant");var r=e.input.charCodeAt(e.pos);if(r===t)break;92===r?(n+=e.input.slice(i,e.pos),n+=e.readEscapedChar(!1),i=e.pos):(a(r,e.options.ecmaVersion>=10)&&e.raise(e.start,"Unterminated string constant"),++e.pos)}return n+=this.input.slice(i,this.pos++),this.finishToken(W.string,n)};var Rt={};At.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t!==Rt)throw t;this.readInvalidTemplateToken()}this.inTemplateElement=!1},At.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Rt;this.raise(t,e)},At.readTmplToken=function(){for(var t=this,e="",n=this.pos;;){t.pos>=t.input.length&&t.raise(t.start,"Unterminated template");var i=t.input.charCodeAt(t.pos);if(96===i||36===i&&123===t.input.charCodeAt(t.pos+1))return t.pos!==t.start||t.type!==W.template&&t.type!==W.invalidTemplate?(e+=t.input.slice(n,t.pos),t.finishToken(W.template,e)):36===i?(t.pos+=2,t.finishToken(W.dollarBraceL)):(++t.pos,t.finishToken(W.backQuote));if(92===i)e+=t.input.slice(n,t.pos),e+=t.readEscapedChar(!0),n=t.pos;else if(a(i)){switch(e+=t.input.slice(n,t.pos),++t.pos,i){case 13:10===t.input.charCodeAt(t.pos)&&++t.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(i)}t.options.locations&&(++t.curLine,t.lineStart=t.pos),n=t.pos}else++t.pos}},At.readInvalidTemplateToken=function(){for(var t=this;this.pos=48&&e<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(n,8);return i>255&&(n=n.slice(0,-1),i=parseInt(n,8)),this.pos+=n.length-1,e=this.input.charCodeAt(this.pos),"0"===n&&56!==e&&57!==e||!this.strict&&!t||this.invalidStringToken(this.pos-1-n.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return String.fromCharCode(e)}},At.readHexChar=function(t){var e=this.pos,n=this.readInt(16,t);return null===n&&this.invalidStringToken(e,"Bad character escape sequence"),n},At.readWord1=function(){var t=this;this.containsEsc=!1;for(var e="",r=!0,s=this.pos,a=this.options.ecmaVersion>=6;this.pos 0) { retArr.push(','); } @@ -881,7 +882,7 @@ module.exports = function (_BaseFunctionNode) { key: 'astMemberExpression', value: function astMemberExpression(mNode, retArr) { if (mNode.computed) { - if (mNode.object.type === 'Identifier') { + if (mNode.object.type === 'Identifier' || mNode.object.type === 'MemberExpression' && mNode.object.object.object && mNode.object.object.object.type === 'ThisExpression' && mNode.object.object.property.name === 'constants') { this.pushState('identifier'); this.astGeneric(mNode.object, retArr); this.popState('identifier'); @@ -953,8 +954,11 @@ module.exports = function (_BaseFunctionNode) { unrolled = 'user_' + unrolled; } - // Its a reference to `this`, add '_' before - if (unrolled.indexOf('this') === 0) { + if (unrolled.indexOf('this.constants') === 0) { + // remove 'this.constants' from beginning + unrolled = 'constants_' + unrolled.substring(15); + } else if (unrolled.indexOf('this') === 0) { + // Its a reference to `this`, add '_' before unrolled = '_' + unrolled; } @@ -975,6 +979,9 @@ module.exports = function (_BaseFunctionNode) { retArr.push(this.output[2]); break; default: + if (mNode.object && mNode.object.name && this.declarations[mNode.object.name]) { + retArr.push('user_'); + } retArr.push(unrolled); } diff --git a/dist/backend/cpu/kernel-string.js b/dist/backend/cpu/kernel-string.js index 9687b365..b434a80e 100644 --- a/dist/backend/cpu/kernel-string.js +++ b/dist/backend/cpu/kernel-string.js @@ -15,5 +15,5 @@ function removeNoise(str) { } module.exports = function (cpuKernel, name) { - return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n class ' + (name || 'Kernel') + ' {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(cpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(cpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(cpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n this._kernelString = `' + cpuKernel._kernelString + '`;\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(cpuKernel.build.toString()) + '\n ' + removeFnNoise(cpuKernel.setupParams.toString()) + '\n run () { ' + cpuKernel.kernelString + ' }\n getKernelString() { return this._kernelString; }\n ' + removeFnNoise(cpuKernel.validateOptions.toString()) + '\n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n class ' + (name || 'Kernel') + ' {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(cpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(cpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(cpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n this._kernelString = `' + cpuKernel._kernelString + '`;\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(cpuKernel.build.toString()) + '\n ' + removeFnNoise(cpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(cpuKernel.setupConstants.toString()) + '\n run () { ' + cpuKernel.kernelString + ' }\n getKernelString() { return this._kernelString; }\n ' + removeFnNoise(cpuKernel.validateOptions.toString()) + '\n };\n return kernelRunShortcut(new Kernel());\n };'; }; \ No newline at end of file diff --git a/dist/backend/cpu/kernel.js b/dist/backend/cpu/kernel.js index 44b7931f..bd4bd312 100644 --- a/dist/backend/cpu/kernel.js +++ b/dist/backend/cpu/kernel.js @@ -103,8 +103,11 @@ module.exports = function (_KernelBase) { }, { key: 'build', value: function build() { + this.setupConstants(); this.setupParams(arguments); this.validateOptions(); + var canvas = this._canvas; + this._canvasCtx = canvas.getContext('2d'); var threadDim = this.threadDim = utils.clone(this.output); while (threadDim.length < 3) { @@ -112,10 +115,8 @@ module.exports = function (_KernelBase) { } if (this.graphical) { - var canvas = this.getCanvas(); canvas.width = threadDim[0]; canvas.height = threadDim[1]; - this._canvasCtx = canvas.getContext('2d'); this._imageData = this._canvasCtx.createImageData(threadDim[0], threadDim[1]); this._colorData = new Uint8ClampedArray(threadDim[0] * threadDim[1] * 4); } @@ -196,7 +197,8 @@ module.exports = function (_KernelBase) { loopMaxIterations: this.loopMaxIterations, paramNames: this.paramNames, paramTypes: this.paramTypes, - paramSizes: this.paramSizes + paramSizes: this.paramSizes, + constantTypes: this.constantTypes }); builder.addFunctions(this.functions, { @@ -243,11 +245,11 @@ module.exports = function (_KernelBase) { } else { kernel = prototypes.shift(); } - var kernelString = this._kernelString = '\n\t\tvar LOOP_MAX = ' + this._getLoopMaxString() + ';\n\t\tvar _this = this;\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) { + var kernelString = this._kernelString = '\n\t\tvar LOOP_MAX = ' + this._getLoopMaxString() + '\n\t\tvar constants = this.constants;\n\t\tvar _this = this;\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) { return ' var ' + name + ' = null;\n'; }).join('')) + '\n return function (' + this.paramNames.map(function (paramName) { return 'user_' + paramName; - }).join(', ') + ') {\n ' + this._processInputs() + '\n var ret = new Array(' + threadDim[2] + ');\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) { + }).join(', ') + ') {\n ' + this._processConstants() + '\n ' + this._processParams() + '\n var ret = new Array(' + threadDim[2] + ');\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) { return ' ' + name + 'Z = new Array(' + threadDim[2] + ');\n'; }).join('')) + '\n for (this.thread.z = 0; this.thread.z < ' + threadDim[2] + '; this.thread.z++) {\n ret[this.thread.z] = new Array(' + threadDim[1] + ');\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) { return ' ' + name + 'Z[this.thread.z] = new Array(' + threadDim[1] + ');\n'; @@ -301,8 +303,32 @@ module.exports = function (_KernelBase) { return this.loopMaxIterations ? ' ' + parseInt(this.loopMaxIterations) + ';\n' : ' 1000;\n'; } }, { - key: '_processInputs', - value: function _processInputs() { + key: '_processConstants', + value: function _processConstants() { + if (!this.constants) return ''; + + var result = []; + for (var p in this.constants) { + var type = this.constantTypes[p]; + switch (type) { + case 'HTMLImage': + result.push(' var constants_' + p + ' = this._imageTo2DArray(this.constants.' + p + ')'); + break; + case 'HTMLImageArray': + result.push(' var constants_' + p + ' = this._imageTo3DArray(this.constants.' + p + ')'); + break; + case 'Input': + result.push(' var constants_' + p + ' = this.constants.' + p + '.value'); + break; + default: + result.push(' var constants_' + p + ' = this.constants.' + p); + } + } + return result.join('\n'); + } + }, { + key: '_processParams', + value: function _processParams() { var result = []; for (var i = 0; i < this.paramTypes.length; i++) { switch (this.paramTypes[i]) { @@ -322,14 +348,31 @@ module.exports = function (_KernelBase) { }, { key: '_imageTo2DArray', value: function _imageTo2DArray(image) { - this._canvasCtx.drawImage(image, 0, 0, image.width, image.height); - var pixelsData = this._canvasCtx.getImageData(0, 0, image.width, image.height).data; + var canvas = this._canvas; + if (canvas.width < image.width) { + canvas.width = image.width; + } + if (canvas.height < image.height) { + canvas.height = image.height; + } + var ctx = this._canvasCtx; + ctx.drawImage(image, 0, 0, image.width, image.height); + var pixelsData = ctx.getImageData(0, 0, image.width, image.height).data; var imageArray = new Array(image.height); var index = 0; for (var y = image.height - 1; y >= 0; y--) { imageArray[y] = new Array(image.width); for (var x = 0; x < image.width; x++) { - imageArray[y][x] = [pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255]; + var r = pixelsData[index++] / 255; + var g = pixelsData[index++] / 255; + var b = pixelsData[index++] / 255; + var a = pixelsData[index++] / 255; + var result = [r, g, b, a]; + result.r = r; + result.g = g; + result.b = b; + result.a = a; + imageArray[y][x] = result; } } return imageArray; diff --git a/dist/backend/function-node-base.js b/dist/backend/function-node-base.js index 059a9302..a5b79b68 100644 --- a/dist/backend/function-node-base.js +++ b/dist/backend/function-node-base.js @@ -70,6 +70,11 @@ module.exports = function () { if (options.hasOwnProperty('paramTypes')) { this.paramTypes = paramTypes = options.paramTypes; } + if (options.hasOwnProperty('constantTypes')) { + this.constantTypes = options.constantTypes; + } else { + this.constantTypes = {}; + } if (options.hasOwnProperty('returnType')) { returnType = options.returnType; } @@ -378,6 +383,14 @@ module.exports = function () { } return null; } + }, { + key: 'getConstantType', + value: function getConstantType(constantName) { + if (this.constantTypes[constantName]) { + return this.constantTypes[constantName]; + } + return null; + } /** * @memberOf FunctionNodeBase# diff --git a/dist/backend/kernel-base.js b/dist/backend/kernel-base.js index b888d6bb..72af2b6c 100644 --- a/dist/backend/kernel-base.js +++ b/dist/backend/kernel-base.js @@ -62,6 +62,7 @@ module.exports = function () { this.functionBuilder = null; this.paramTypes = null; this.paramSizes = null; + this.constantTypes = null; this.fixIntegerDivisionAccuracy = null; for (var p in settings) { @@ -107,6 +108,16 @@ module.exports = function () { this.paramSizes.push(arg.constructor === Input ? arg.size : null); } } + }, { + key: 'setupConstants', + value: function setupConstants() { + this.constantTypes = {}; + if (this.constants) { + for (var p in this.constants) { + this.constantTypes[p] = utils.getArgumentType(this.constants[p]); + } + } + } }, { key: 'setAddFunction', value: function setAddFunction(cb) { diff --git a/dist/backend/web-gl/function-node.js b/dist/backend/web-gl/function-node.js index 7b59afba..00c34f26 100644 --- a/dist/backend/web-gl/function-node.js +++ b/dist/backend/web-gl/function-node.js @@ -23,7 +23,7 @@ var ENCODE32_DECODE32 = /encode32\(\s+decode32\(/g; // TODO: optimise out - webpack/babel options? maybe some generic logging support in core/utils? // const debugLog = console.log var debugLog = function debugLog() {}; -/** +/** * @class WebGLFunctionNode * * @desc [INTERNAL] Takes in a function node, and does all the AST voodoo required to generate its respective webGL code. @@ -892,7 +892,7 @@ module.exports = function (_FunctionNodeBase) { value: function astMemberExpression(mNode, retArr) { debugLog("[in] astMemberExpression " + mNode.object.type); if (mNode.computed) { - if (mNode.object.type === 'Identifier') { + if (mNode.object.type === 'Identifier' || mNode.object.type === 'MemberExpression' && mNode.object.object.object && mNode.object.object.object.type === 'ThisExpression' && mNode.object.object.property.name === 'constants') { // Working logger var reqName = mNode.object.name; var funcName = this.functionName || 'kernel'; @@ -921,7 +921,13 @@ module.exports = function (_FunctionNodeBase) { this.pushState('not-in-get-call-parameters'); // This normally refers to the global read only input vars - switch (this.getParamType(mNode.object.name)) { + var variableType = null; + if (mNode.object.name) { + variableType = this.getParamType(mNode.object.name); + } else if (mNode.object && mNode.object.object && mNode.object.object.object && mNode.object.object.object.type === 'ThisExpression') { + variableType = this.getConstantType(mNode.object.property.name); + } + switch (variableType) { case 'vec4': // Get from local vec4 this.astGeneric(mNode.object, retArr); @@ -1087,6 +1093,9 @@ module.exports = function (_FunctionNodeBase) { retArr.push(this.output[2] + '.0'); break; default: + if (mNode.object && mNode.object.name && this.declarations[mNode.object.name]) { + retArr.push('user_'); + } retArr.push(unrolled); } } @@ -1309,7 +1318,7 @@ function ensureIndentifierType(paramName, expectedType, ast, funcParam) { * @name webgl_regex_optimize * * @desc [INTERNAL] Takes the near final webgl function string, and do regex search and replacments. - * For voodoo optimize out the following: + * For voodoo optimize out the following: * * - decode32(encode32(
* - encode32(decode32(
diff --git a/dist/backend/web-gl/kernel-string.js b/dist/backend/web-gl/kernel-string.js index 56b519b4..3ec6cbb8 100644 --- a/dist/backend/web-gl/kernel-string.js +++ b/dist/backend/web-gl/kernel-string.js @@ -15,5 +15,5 @@ function removeNoise(str) { } module.exports = function (gpuKernel, name) { - return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform2ivCache = {};\n\t\t this.uniform3fvCache = {};\n\t\t this.uniform3ivCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2iv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n\t\t ' + removeFnNoise(gpuKernel.setUniform3iv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform2ivCache = {};\n\t\t this.uniform3fvCache = {};\n\t\t this.uniform3ivCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setupConstants() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.setupConstants.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2iv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n\t\t ' + removeFnNoise(gpuKernel.setUniform3iv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; }; \ No newline at end of file diff --git a/dist/backend/web-gl/kernel.js b/dist/backend/web-gl/kernel.js index 24af67ea..dbc59e0c 100644 --- a/dist/backend/web-gl/kernel.js +++ b/dist/backend/web-gl/kernel.js @@ -75,6 +75,7 @@ module.exports = function (_KernelBase) { _this.subKernelOutputTextures = null; _this.subKernelOutputVariableNames = null; _this.argumentsLength = 0; + _this.constantsLength = 0; _this.compiledFragShaderString = null; _this.compiledVertShaderString = null; _this.fragShader = null; @@ -124,7 +125,7 @@ module.exports = function (_KernelBase) { } var hasIntegerDivisionBug = utils.hasIntegerDivisionAccuracyBug(); - if (this.fixIntegerDivisionAccuracy == null) { + if (this.fixIntegerDivisionAccuracy === null) { this.fixIntegerDivisionAccuracy = hasIntegerDivisionBug; } else if (this.fixIntegerDivisionAccuracy && !hasIntegerDivisionBug) { this.fixIntegerDivisionAccuracy = false; @@ -203,6 +204,7 @@ module.exports = function (_KernelBase) { key: 'build', value: function build() { this.validateOptions(); + this.setupConstants(); this.setupParams(arguments); this.updateMaxTexSize(); var texSize = this.texSize; @@ -283,6 +285,17 @@ module.exports = function (_KernelBase) { gl.vertexAttribPointer(aTexCoordLoc, 2, gl.FLOAT, gl.FALSE, 0, texCoordOffset); gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer); + for (var p in this.constants) { + var value = this.constants[p]; + var type = utils.getArgumentType(value); + if (type === 'Decimal' || type === 'Integer') { + continue; + } + gl.useProgram(this.program); + this._addConstant(this.constants[p], type, p); + this.constantsLength++; + } + if (!this.outputImmutable) { this._setupOutputTexture(); if (this.subKernelOutputVariableNames !== null && this.subKernelOutputVariableNames.length > 0) { @@ -467,7 +480,7 @@ module.exports = function (_KernelBase) { var gl = this._webGl; var texSize = this.texSize; var texture = this.outputTexture = this._webGl.createTexture(); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -500,7 +513,7 @@ module.exports = function (_KernelBase) { var texture = this._webGl.createTexture(); textures.push(texture); drawBuffersMap.push(gl.COLOR_ATTACHMENT0 + i + 1); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length + i); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length + i); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -746,7 +759,7 @@ module.exports = function (_KernelBase) { floatTextures: this.floatTextures, floatOutput: this.floatOutput }, dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -789,7 +802,7 @@ module.exports = function (_KernelBase) { floatTextures: this.floatTextures, floatOutput: this.floatOutput }, _dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -823,7 +836,7 @@ module.exports = function (_KernelBase) { var _dim2 = [inputImage.width, inputImage.height, 1]; var _size2 = [inputImage.width, inputImage.height]; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -847,7 +860,7 @@ module.exports = function (_KernelBase) { var _dim3 = inputTexture.dimensions; var _size3 = inputTexture.size; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); this.setUniform3iv('user_' + name + 'Dim', _dim3); @@ -865,6 +878,151 @@ module.exports = function (_KernelBase) { /** * @memberOf WebGLKernel# * @function + * @name _addConstant + * + * @desc Adds kernel parameters to the Argument Texture, + * binding it to the webGl instance, etc. + * + * @param {Array|Texture|Number} value - The actual argument supplied to the kernel + * @param {String} type - Type of the argument + * @param {String} name - Name of the argument + * + */ + + }, { + key: '_addConstant', + value: function _addConstant(value, type, name) { + var gl = this._webGl; + var argumentTexture = this.getArgumentTexture(name); + if (value instanceof Texture) { + type = 'Texture'; + } + switch (type) { + case 'Array': + { + var dim = utils.getDimensions(value, true); + var size = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, dim); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + var length = size[0] * size[1]; + + var _formatArrayTransfer4 = this._formatArrayTransfer(value, length), + valuesFlat = _formatArrayTransfer4.valuesFlat, + bitRatio = _formatArrayTransfer4.bitRatio; + + var buffer = void 0; + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); + } else { + buffer = new Uint8Array(valuesFlat.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + } + + if (!this.hardcodeConstants) { + this.setUniform3iv('constants_' + name + 'Dim', dim); + this.setUniform2iv('constants_' + name + 'Size', size); + } + this.setUniform1i('constants_' + name + 'BitRatio', bitRatio); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'Integer': + case 'Float': + { + this.setUniform1f('constants_' + name, value); + break; + } + case 'Input': + { + var input = value; + var _dim4 = input.size; + var _size4 = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, _dim4); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + var _length2 = _size4[0] * _size4[1]; + + var _formatArrayTransfer5 = this._formatArrayTransfer(value.value, _length2), + _valuesFlat2 = _formatArrayTransfer5.valuesFlat, + _bitRatio2 = _formatArrayTransfer5.bitRatio; + + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size4[0], _size4[1], 0, gl.RGBA, gl.FLOAT, inputArray); + } else { + var _buffer2 = new Uint8Array(_valuesFlat2.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size4[0] / _bitRatio2, _size4[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, _buffer2); + } + + if (!this.hardcodeConstants) { + this.setUniform3iv('constants_' + name + 'Dim', _dim4); + this.setUniform2iv('constants_' + name + 'Size', _size4); + } + this.setUniform1i('constants_' + name + 'BitRatio', _bitRatio2); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'HTMLImage': + { + var inputImage = value; + var _dim5 = [inputImage.width, inputImage.height, 1]; + var _size5 = [inputImage.width, inputImage.height]; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + // Upload the image into the texture. + var mipLevel = 0; // the largest mip + var internalFormat = gl.RGBA; // format we want in the texture + var srcFormat = gl.RGBA; // format of data we are supplying + var srcType = gl.UNSIGNED_BYTE; // type of data we are supplying + gl.texImage2D(gl.TEXTURE_2D, mipLevel, internalFormat, srcFormat, srcType, inputImage); + this.setUniform3iv('constants_' + name + 'Dim', _dim5); + this.setUniform2iv('constants_' + name + 'Size', _size5); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'Texture': + { + var inputTexture = value; + var _dim6 = inputTexture.dimensions; + var _size6 = inputTexture.size; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); + + this.setUniform3iv('constants_' + name + 'Dim', _dim6); + this.setUniform2iv('constants_' + name + 'Size', _size6); + this.setUniform1i('constants_' + name + 'BitRatio', 1); // aways float32 + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + default: + throw new Error('Input type not supported (WebGL): ' + value); + } + } + + /** + * @memberOf WebGLKernel# + * @function * @name _formatArrayTransfer * * @desc Adds kernel parameters to the Argument Texture, @@ -1188,6 +1346,12 @@ module.exports = function (_KernelBase) { case 'Float': result.push('const float constants_' + name + ' = ' + parseFloat(value)); break; + case 'Array': + case 'Input': + case 'HTMLImage': + case 'Texture': + result.push('uniform sampler2D constants_' + name, 'uniform ivec2 constants_' + name + 'Size', 'uniform ivec3 constants_' + name + 'Dim', 'uniform int constants_' + name + 'BitRatio'); + break; default: throw new Error('Unsupported constant ' + name + ' type ' + type); } @@ -1356,6 +1520,7 @@ module.exports = function (_KernelBase) { loopMaxIterations: this.loopMaxIterations, paramNames: this.paramNames, paramTypes: this.paramTypes, + constantTypes: this.constantTypes, fixIntegerDivisionAccuracy: this.fixIntegerDivisionAccuracy }); diff --git a/dist/backend/web-gl/runner.js b/dist/backend/web-gl/runner.js index e1344c4a..f1672c72 100644 --- a/dist/backend/web-gl/runner.js +++ b/dist/backend/web-gl/runner.js @@ -19,7 +19,8 @@ module.exports = function (_RunnerBase) { * @constructor WebGLRunner * * @extends RunnerBase - * @desc Instantiates a Runner instance for the kernel. + + * @desc Instantiates a Runner instance for the kernel. * * @param {Object} settings - Settings to instantiate properties in RunnerBase, with given values * diff --git a/dist/backend/web-gl2/kernel-string.js b/dist/backend/web-gl2/kernel-string.js index 56b519b4..3ec6cbb8 100644 --- a/dist/backend/web-gl2/kernel-string.js +++ b/dist/backend/web-gl2/kernel-string.js @@ -15,5 +15,5 @@ function removeNoise(str) { } module.exports = function (gpuKernel, name) { - return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform2ivCache = {};\n\t\t this.uniform3fvCache = {};\n\t\t this.uniform3ivCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2iv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n\t\t ' + removeFnNoise(gpuKernel.setUniform3iv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + ',\n checkOutput: ' + removeNoise(utils.checkOutput.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform2ivCache = {};\n\t\t this.uniform3fvCache = {};\n\t\t this.uniform3ivCache = {};\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setupConstants() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.setupConstants.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform1i.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2f.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2fv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform2iv.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.setUniform3fv.toString()) + ' \n\t\t ' + removeFnNoise(gpuKernel.setUniform3iv.toString()) + ' \n };\n return kernelRunShortcut(new Kernel());\n };'; }; \ No newline at end of file diff --git a/dist/backend/web-gl2/kernel.js b/dist/backend/web-gl2/kernel.js index a6f97037..04a29f55 100644 --- a/dist/backend/web-gl2/kernel.js +++ b/dist/backend/web-gl2/kernel.js @@ -51,7 +51,7 @@ module.exports = function (_WebGLKernel) { } var hasIntegerDivisionBug = utils.hasIntegerDivisionAccuracyBug(); - if (this.fixIntegerDivisionAccuracy == null) { + if (this.fixIntegerDivisionAccuracy === null) { this.fixIntegerDivisionAccuracy = hasIntegerDivisionBug; } else if (this.fixIntegerDivisionAccuracy && !hasIntegerDivisionBug) { this.fixIntegerDivisionAccuracy = false; @@ -219,7 +219,7 @@ module.exports = function (_WebGLKernel) { var gl = this._webGl; var texSize = this.texSize; var texture = this.outputTexture = this._webGl.createTexture(); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -252,7 +252,7 @@ module.exports = function (_WebGLKernel) { var texture = this._webGl.createTexture(); textures.push(texture); drawBuffersMap.push(gl.COLOR_ATTACHMENT0 + i + 1); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length + i); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length + i); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -297,7 +297,7 @@ module.exports = function (_WebGLKernel) { floatTextures: this.floatTextures, floatOutput: this.floatOutput }, dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -340,7 +340,7 @@ module.exports = function (_WebGLKernel) { floatTextures: this.floatTextures, floatOutput: this.floatOutput }, _dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -374,7 +374,7 @@ module.exports = function (_WebGLKernel) { var _dim2 = [inputImage.width, inputImage.height, 1]; var _size2 = [inputImage.width, inputImage.height]; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -398,7 +398,7 @@ module.exports = function (_WebGLKernel) { var _dim3 = [inputImages[0].width, inputImages[0].height, inputImages.length]; var _size3 = [inputImages[0].width, inputImages[0].height]; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D_ARRAY, argumentTexture); gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MAG_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MIN_FILTER, gl.NEAREST); @@ -430,7 +430,7 @@ module.exports = function (_WebGLKernel) { var _dim4 = inputTexture.dimensions; var _size4 = inputTexture.size; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); this.setUniform3iv('user_' + name + 'Dim', _dim4); @@ -445,6 +445,224 @@ module.exports = function (_WebGLKernel) { this.argumentsLength++; } + /** + * @memberOf WebGLKernel# + * @function + * @name _getMainConstantsString + * + */ + + }, { + key: '_getMainConstantsString', + value: function _getMainConstantsString() { + var result = []; + if (this.constants) { + for (var name in this.constants) { + if (!this.constants.hasOwnProperty(name)) continue; + var value = this.constants[name]; + var type = utils.getArgumentType(value); + switch (type) { + case 'Integer': + result.push('const float constants_' + name + ' = ' + parseInt(value) + '.0'); + break; + case 'Float': + result.push('const float constants_' + name + ' = ' + parseFloat(value)); + break; + case 'Array': + case 'Input': + case 'HTMLImage': + case 'Texture': + result.push('uniform highp sampler2D constants_' + name, 'uniform highp ivec2 constants_' + name + 'Size', 'uniform highp ivec3 constants_' + name + 'Dim', 'uniform highp int constants_' + name + 'BitRatio'); + break; + case 'HTMLImageArray': + result.push('uniform highp sampler2DArray constants_' + name, 'uniform highp ivec2 constants_' + name + 'Size', 'uniform highp ivec3 constants_' + name + 'Dim', 'uniform highp int constants_' + name + 'BitRatio'); + break; + + default: + throw new Error('Unsupported constant ' + name + ' type ' + type); + } + } + } + return this._linesToString(result); + } + + /** + * @memberOf WebGLKernel# + * @function + * @name _addConstant + * + * @desc Adds kernel parameters to the Argument Texture, + * binding it to the webGl instance, etc. + * + * @param {Array|Texture|Number} value - The actual argument supplied to the kernel + * @param {String} type - Type of the argument + * @param {String} name - Name of the argument + * + */ + + }, { + key: '_addConstant', + value: function _addConstant(value, type, name) { + var gl = this._webGl; + var argumentTexture = this.getArgumentTexture(name); + if (value instanceof Texture) { + type = 'Texture'; + } + switch (type) { + case 'Array': + { + var dim = utils.getDimensions(value, true); + var size = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, dim); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + var length = size[0] * size[1]; + + var _formatArrayTransfer3 = this._formatArrayTransfer(value, length), + valuesFlat = _formatArrayTransfer3.valuesFlat, + bitRatio = _formatArrayTransfer3.bitRatio; + + var buffer = void 0; + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); + } else { + buffer = new Uint8Array(valuesFlat.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + } + + if (!this.hardcodeConstants) { + this.setUniform3iv('constants_' + name + 'Dim', dim); + this.setUniform2iv('constants_' + name + 'Size', size); + } + this.setUniform1i('constants_' + name + 'BitRatio', bitRatio); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'Integer': + case 'Float': + { + this.setUniform1f('constants_' + name, value); + break; + } + case 'Input': + { + var input = value; + var _dim5 = input.size; + var _size5 = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, _dim5); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + var _length2 = _size5[0] * _size5[1]; + + var _formatArrayTransfer4 = this._formatArrayTransfer(value.value, _length2), + _valuesFlat2 = _formatArrayTransfer4.valuesFlat, + _bitRatio2 = _formatArrayTransfer4.bitRatio; + + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, _size5[0], _size5[1], 0, gl.RGBA, gl.FLOAT, inputArray); + } else { + var _buffer2 = new Uint8Array(_valuesFlat2.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size5[0] / _bitRatio2, _size5[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, _buffer2); + } + + if (!this.hardcodeConstants) { + this.setUniform3iv('constants_' + name + 'Dim', _dim5); + this.setUniform2iv('constants_' + name + 'Size', _size5); + } + this.setUniform1i('constants_' + name + 'BitRatio', _bitRatio2); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'HTMLImage': + { + var inputImage = value; + var _dim6 = [inputImage.width, inputImage.height, 1]; + var _size6 = [inputImage.width, inputImage.height]; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + // Upload the image into the texture. + var mipLevel = 0; // the largest mip + var internalFormat = gl.RGBA; // format we want in the texture + var srcFormat = gl.RGBA; // format of data we are supplying + var srcType = gl.UNSIGNED_BYTE; // type of data we are supplying + gl.texImage2D(gl.TEXTURE_2D, mipLevel, internalFormat, srcFormat, srcType, inputImage); + this.setUniform3iv('constants_' + name + 'Dim', _dim6); + this.setUniform2iv('constants_' + name + 'Size', _size6); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'HTMLImageArray': + { + var inputImages = value; + var _dim7 = [inputImages[0].width, inputImages[0].height, inputImages.length]; + var _size7 = [inputImages[0].width, inputImages[0].height]; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D_ARRAY, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + // Upload the images into the texture. + var _mipLevel2 = 0; // the largest mip + var _internalFormat2 = gl.RGBA; // format we want in the texture + var width = inputImages[0].width; + var height = inputImages[0].height; + var textureDepth = inputImages.length; + var border = 0; + var _srcFormat2 = gl.RGBA; // format of data we are supplying + var _srcType2 = gl.UNSIGNED_BYTE; // type of data we are supplying + gl.texImage3D(gl.TEXTURE_2D_ARRAY, _mipLevel2, _internalFormat2, width, height, textureDepth, border, _srcFormat2, _srcType2, null); + for (var i = 0; i < inputImages.length; i++) { + var xOffset = 0; + var yOffset = 0; + var imageDepth = 1; + gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, _mipLevel2, xOffset, yOffset, i, inputImages[i].width, inputImages[i].height, imageDepth, _srcFormat2, _srcType2, inputImages[i]); + } + this.setUniform3iv('constants_' + name + 'Dim', _dim7); + this.setUniform2iv('constants_' + name + 'Size', _size7); + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + case 'Texture': + { + var inputTexture = value; + var _dim8 = inputTexture.dimensions; + var _size8 = inputTexture.size; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); + + this.setUniform3iv('constants_' + name + 'Dim', _dim8); + this.setUniform2iv('constants_' + name + 'Size', _size8); + this.setUniform1i('constants_' + name + 'BitRatio', 1); // aways float32 + this.setUniform1i('constants_' + name, this.constantsLength); + break; + } + default: + throw new Error('Input type not supported (WebGL): ' + value); + } + } + /** * @memberOf WebGL2Kernel# * @function @@ -678,6 +896,7 @@ module.exports = function (_WebGLKernel) { loopMaxIterations: this.loopMaxIterations, paramNames: this.paramNames, paramTypes: this.paramTypes, + constantTypes: this.constantTypes, fixIntegerDivisionAccuracy: this.fixIntegerDivisionAccuracy }); diff --git a/dist/backend/web-gl2/runner.js b/dist/backend/web-gl2/runner.js index e1ef2140..8f521351 100644 --- a/dist/backend/web-gl2/runner.js +++ b/dist/backend/web-gl2/runner.js @@ -19,7 +19,8 @@ module.exports = function (_RunnerBase) { * @constructor WebGL2Runner * * @extends RunnerBase - * @desc Instantiates a Runner instance for the kernel. + + * @desc Instantiates a Runner instance for the kernel. * * @param {Object} settings - Settings to instantiate properties in RunnerBase, with given values * diff --git a/dist/core/utils.js b/dist/core/utils.js index a9492eca..8dcefb7c 100644 --- a/dist/core/utils.js +++ b/dist/core/utils.js @@ -657,7 +657,8 @@ var Utils = function (_UtilsCore) { * @param {Array} array - The array to split into chunks * @param {Array} part - elements in one chunk * - * @returns {Array} An array of smaller chunks + + * @returns {Array} An array of smaller chunks * */ diff --git a/dist/index.js b/dist/index.js index bd973cd6..de8f1f82 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,5 +1,6 @@ 'use strict'; +console.log("Testing"); var GPU = require('./core/gpu'); var alias = require('./core/alias'); var utils = require('./core/utils'); diff --git a/package-lock.json b/package-lock.json index cfd8e75c..ecaa3d69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gpu.js", - "version": "1.4.11", + "version": "1.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -10,8 +10,8 @@ "integrity": "sha512-3Sp6WZZ/lXl+nTDoGpGWHEpTnnC6X5fnkolYZR6nwIfzbxxvA8utPWe1gCt7i0m9uVGsSz2IS8K8mJ7HmlduMg==", "dev": true, "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" } }, "abbrev": { @@ -26,7 +26,7 @@ "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", "dev": true, "requires": { - "mime-types": "2.1.18", + "mime-types": "~2.1.18", "negotiator": "0.6.1" } }, @@ -41,7 +41,7 @@ "integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==", "dev": true, "requires": { - "acorn": "5.7.1" + "acorn": "^5.0.0" } }, "acorn-node": { @@ -50,9 +50,9 @@ "integrity": "sha512-krFKvw/d1F17AN3XZbybIUzEY4YEPNiGo05AfP3dBlfVKrMHETKpgjpuZkSF8qDNt9UkQcqj7am8yJLseklCMg==", "dev": true, "requires": { - "acorn": "5.7.1", - "acorn-dynamic-import": "3.0.0", - "xtend": "4.0.1" + "acorn": "^5.7.1", + "acorn-dynamic-import": "^3.0.0", + "xtend": "^4.0.1" } }, "after": { @@ -67,9 +67,9 @@ "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, "requires": { - "kind-of": "3.2.2", - "longest": "1.0.1", - "repeat-string": "1.6.1" + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" } }, "ansi-colors": { @@ -78,7 +78,7 @@ "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", "dev": true, "requires": { - "ansi-wrap": "0.1.0" + "ansi-wrap": "^0.1.0" } }, "ansi-cyan": { @@ -132,8 +132,8 @@ "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", "dev": true, "requires": { - "micromatch": "2.3.11", - "normalize-path": "2.1.1" + "micromatch": "^2.1.5", + "normalize-path": "^2.0.0" } }, "archy": { @@ -148,7 +148,7 @@ "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", "dev": true, "requires": { - "arr-flatten": "1.1.0" + "arr-flatten": "^1.0.1" } }, "arr-flatten": { @@ -205,7 +205,7 @@ "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true, "requires": { - "array-uniq": "1.0.3" + "array-uniq": "^1.0.1" } }, "array-uniq": { @@ -232,9 +232,9 @@ "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, "requires": { - "bn.js": "4.11.8", - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" } }, "assert": { @@ -305,8 +305,8 @@ "integrity": "sha1-LY4+XQvb1zJ/kbyBT1xXZg+Bgk0=", "dev": true, "requires": { - "follow-redirects": "1.5.1", - "is-buffer": "1.1.6" + "follow-redirects": "^1.2.5", + "is-buffer": "^1.1.5" } }, "babel-code-frame": { @@ -315,9 +315,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "1.1.3", - "esutils": "2.0.2", - "js-tokens": "3.0.2" + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" } }, "babel-core": { @@ -326,25 +326,25 @@ "integrity": "sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "babel-generator": "6.26.1", - "babel-helpers": "6.24.1", - "babel-messages": "6.23.0", - "babel-register": "6.26.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "convert-source-map": "1.5.1", - "debug": "2.6.9", - "json5": "0.5.1", - "lodash": "4.17.10", - "minimatch": "3.0.4", - "path-is-absolute": "1.0.1", - "private": "0.1.8", - "slash": "1.0.0", - "source-map": "0.5.7" + "babel-code-frame": "^6.26.0", + "babel-generator": "^6.26.0", + "babel-helpers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-register": "^6.26.0", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "convert-source-map": "^1.5.1", + "debug": "^2.6.9", + "json5": "^0.5.1", + "lodash": "^4.17.4", + "minimatch": "^3.0.4", + "path-is-absolute": "^1.0.1", + "private": "^0.1.8", + "slash": "^1.0.0", + "source-map": "^0.5.7" }, "dependencies": { "convert-source-map": { @@ -361,14 +361,14 @@ "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", "dev": true, "requires": { - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "detect-indent": "4.0.0", - "jsesc": "1.3.0", - "lodash": "4.17.10", - "source-map": "0.5.7", - "trim-right": "1.0.1" + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "detect-indent": "^4.0.0", + "jsesc": "^1.3.0", + "lodash": "^4.17.4", + "source-map": "^0.5.7", + "trim-right": "^1.0.1" }, "dependencies": { "jsesc": { @@ -385,9 +385,9 @@ "integrity": "sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=", "dev": true, "requires": { - "babel-helper-explode-assignable-expression": "6.24.1", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-explode-assignable-expression": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helper-call-delegate": { @@ -396,10 +396,10 @@ "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", "dev": true, "requires": { - "babel-helper-hoist-variables": "6.24.1", - "babel-runtime": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helper-define-map": { @@ -408,10 +408,10 @@ "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=", "dev": true, "requires": { - "babel-helper-function-name": "6.24.1", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "lodash": "4.17.10" + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" } }, "babel-helper-explode-assignable-expression": { @@ -420,9 +420,9 @@ "integrity": "sha1-8luCz33BBDPFX3BZLVdGQArCLKo=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helper-function-name": { @@ -431,11 +431,11 @@ "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", "dev": true, "requires": { - "babel-helper-get-function-arity": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helper-get-function-arity": { @@ -444,8 +444,8 @@ "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helper-hoist-variables": { @@ -454,8 +454,8 @@ "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helper-optimise-call-expression": { @@ -464,8 +464,8 @@ "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-helper-regex": { @@ -474,9 +474,9 @@ "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "lodash": "4.17.10" + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" } }, "babel-helper-remap-async-to-generator": { @@ -485,11 +485,11 @@ "integrity": "sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=", "dev": true, "requires": { - "babel-helper-function-name": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helper-replace-supers": { @@ -498,12 +498,12 @@ "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=", "dev": true, "requires": { - "babel-helper-optimise-call-expression": "6.24.1", - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-optimise-call-expression": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-helpers": { @@ -512,8 +512,8 @@ "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-messages": { @@ -522,7 +522,7 @@ "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-check-es2015-constants": { @@ -531,7 +531,7 @@ "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-syntax-async-functions": { @@ -558,9 +558,9 @@ "integrity": "sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=", "dev": true, "requires": { - "babel-helper-remap-async-to-generator": "6.24.1", - "babel-plugin-syntax-async-functions": "6.13.0", - "babel-runtime": "6.26.0" + "babel-helper-remap-async-to-generator": "^6.24.1", + "babel-plugin-syntax-async-functions": "^6.8.0", + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-arrow-functions": { @@ -569,7 +569,7 @@ "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-block-scoped-functions": { @@ -578,7 +578,7 @@ "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-block-scoping": { @@ -587,11 +587,11 @@ "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "lodash": "4.17.10" + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" } }, "babel-plugin-transform-es2015-classes": { @@ -600,15 +600,15 @@ "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=", "dev": true, "requires": { - "babel-helper-define-map": "6.26.0", - "babel-helper-function-name": "6.24.1", - "babel-helper-optimise-call-expression": "6.24.1", - "babel-helper-replace-supers": "6.24.1", - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-define-map": "^6.24.1", + "babel-helper-function-name": "^6.24.1", + "babel-helper-optimise-call-expression": "^6.24.1", + "babel-helper-replace-supers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-computed-properties": { @@ -617,8 +617,8 @@ "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-plugin-transform-es2015-destructuring": { @@ -627,7 +627,7 @@ "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-duplicate-keys": { @@ -636,8 +636,8 @@ "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-for-of": { @@ -646,7 +646,7 @@ "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-function-name": { @@ -655,9 +655,9 @@ "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", "dev": true, "requires": { - "babel-helper-function-name": "6.24.1", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-literals": { @@ -666,7 +666,7 @@ "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-modules-amd": { @@ -675,9 +675,9 @@ "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=", "dev": true, "requires": { - "babel-plugin-transform-es2015-modules-commonjs": "6.26.2", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-plugin-transform-es2015-modules-commonjs": { @@ -686,10 +686,10 @@ "integrity": "sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==", "dev": true, "requires": { - "babel-plugin-transform-strict-mode": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-types": "6.26.0" + "babel-plugin-transform-strict-mode": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-types": "^6.26.0" } }, "babel-plugin-transform-es2015-modules-systemjs": { @@ -698,9 +698,9 @@ "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=", "dev": true, "requires": { - "babel-helper-hoist-variables": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-plugin-transform-es2015-modules-umd": { @@ -709,9 +709,9 @@ "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=", "dev": true, "requires": { - "babel-plugin-transform-es2015-modules-amd": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0" + "babel-plugin-transform-es2015-modules-amd": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" } }, "babel-plugin-transform-es2015-object-super": { @@ -720,8 +720,8 @@ "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=", "dev": true, "requires": { - "babel-helper-replace-supers": "6.24.1", - "babel-runtime": "6.26.0" + "babel-helper-replace-supers": "^6.24.1", + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-parameters": { @@ -730,12 +730,12 @@ "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", "dev": true, "requires": { - "babel-helper-call-delegate": "6.24.1", - "babel-helper-get-function-arity": "6.24.1", - "babel-runtime": "6.26.0", - "babel-template": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-call-delegate": "^6.24.1", + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-shorthand-properties": { @@ -744,8 +744,8 @@ "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-spread": { @@ -754,7 +754,7 @@ "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-sticky-regex": { @@ -763,9 +763,9 @@ "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", "dev": true, "requires": { - "babel-helper-regex": "6.26.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-plugin-transform-es2015-template-literals": { @@ -774,7 +774,7 @@ "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-typeof-symbol": { @@ -783,7 +783,7 @@ "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=", "dev": true, "requires": { - "babel-runtime": "6.26.0" + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-es2015-unicode-regex": { @@ -792,9 +792,9 @@ "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", "dev": true, "requires": { - "babel-helper-regex": "6.26.0", - "babel-runtime": "6.26.0", - "regexpu-core": "2.0.0" + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "regexpu-core": "^2.0.0" } }, "babel-plugin-transform-exponentiation-operator": { @@ -803,9 +803,9 @@ "integrity": "sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=", "dev": true, "requires": { - "babel-helper-builder-binary-assignment-operator-visitor": "6.24.1", - "babel-plugin-syntax-exponentiation-operator": "6.13.0", - "babel-runtime": "6.26.0" + "babel-helper-builder-binary-assignment-operator-visitor": "^6.24.1", + "babel-plugin-syntax-exponentiation-operator": "^6.8.0", + "babel-runtime": "^6.22.0" } }, "babel-plugin-transform-regenerator": { @@ -814,7 +814,7 @@ "integrity": "sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=", "dev": true, "requires": { - "regenerator-transform": "0.10.1" + "regenerator-transform": "^0.10.0" } }, "babel-plugin-transform-strict-mode": { @@ -823,8 +823,8 @@ "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0" + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" } }, "babel-preset-env": { @@ -833,36 +833,36 @@ "integrity": "sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg==", "dev": true, "requires": { - "babel-plugin-check-es2015-constants": "6.22.0", - "babel-plugin-syntax-trailing-function-commas": "6.22.0", - "babel-plugin-transform-async-to-generator": "6.24.1", - "babel-plugin-transform-es2015-arrow-functions": "6.22.0", - "babel-plugin-transform-es2015-block-scoped-functions": "6.22.0", - "babel-plugin-transform-es2015-block-scoping": "6.26.0", - "babel-plugin-transform-es2015-classes": "6.24.1", - "babel-plugin-transform-es2015-computed-properties": "6.24.1", - "babel-plugin-transform-es2015-destructuring": "6.23.0", - "babel-plugin-transform-es2015-duplicate-keys": "6.24.1", - "babel-plugin-transform-es2015-for-of": "6.23.0", - "babel-plugin-transform-es2015-function-name": "6.24.1", - "babel-plugin-transform-es2015-literals": "6.22.0", - "babel-plugin-transform-es2015-modules-amd": "6.24.1", - "babel-plugin-transform-es2015-modules-commonjs": "6.26.2", - "babel-plugin-transform-es2015-modules-systemjs": "6.24.1", - "babel-plugin-transform-es2015-modules-umd": "6.24.1", - "babel-plugin-transform-es2015-object-super": "6.24.1", - "babel-plugin-transform-es2015-parameters": "6.24.1", - "babel-plugin-transform-es2015-shorthand-properties": "6.24.1", - "babel-plugin-transform-es2015-spread": "6.22.0", - "babel-plugin-transform-es2015-sticky-regex": "6.24.1", - "babel-plugin-transform-es2015-template-literals": "6.22.0", - "babel-plugin-transform-es2015-typeof-symbol": "6.23.0", - "babel-plugin-transform-es2015-unicode-regex": "6.24.1", - "babel-plugin-transform-exponentiation-operator": "6.24.1", - "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "3.2.8", - "invariant": "2.2.4", - "semver": "5.5.0" + "babel-plugin-check-es2015-constants": "^6.22.0", + "babel-plugin-syntax-trailing-function-commas": "^6.22.0", + "babel-plugin-transform-async-to-generator": "^6.22.0", + "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoping": "^6.23.0", + "babel-plugin-transform-es2015-classes": "^6.23.0", + "babel-plugin-transform-es2015-computed-properties": "^6.22.0", + "babel-plugin-transform-es2015-destructuring": "^6.23.0", + "babel-plugin-transform-es2015-duplicate-keys": "^6.22.0", + "babel-plugin-transform-es2015-for-of": "^6.23.0", + "babel-plugin-transform-es2015-function-name": "^6.22.0", + "babel-plugin-transform-es2015-literals": "^6.22.0", + "babel-plugin-transform-es2015-modules-amd": "^6.22.0", + "babel-plugin-transform-es2015-modules-commonjs": "^6.23.0", + "babel-plugin-transform-es2015-modules-systemjs": "^6.23.0", + "babel-plugin-transform-es2015-modules-umd": "^6.23.0", + "babel-plugin-transform-es2015-object-super": "^6.22.0", + "babel-plugin-transform-es2015-parameters": "^6.23.0", + "babel-plugin-transform-es2015-shorthand-properties": "^6.22.0", + "babel-plugin-transform-es2015-spread": "^6.22.0", + "babel-plugin-transform-es2015-sticky-regex": "^6.22.0", + "babel-plugin-transform-es2015-template-literals": "^6.22.0", + "babel-plugin-transform-es2015-typeof-symbol": "^6.23.0", + "babel-plugin-transform-es2015-unicode-regex": "^6.22.0", + "babel-plugin-transform-exponentiation-operator": "^6.22.0", + "babel-plugin-transform-regenerator": "^6.22.0", + "browserslist": "^3.2.6", + "invariant": "^2.2.2", + "semver": "^5.3.0" } }, "babel-register": { @@ -871,13 +871,13 @@ "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", "dev": true, "requires": { - "babel-core": "6.26.3", - "babel-runtime": "6.26.0", - "core-js": "2.5.7", - "home-or-tmp": "2.0.0", - "lodash": "4.17.10", - "mkdirp": "0.5.1", - "source-map-support": "0.4.18" + "babel-core": "^6.26.0", + "babel-runtime": "^6.26.0", + "core-js": "^2.5.0", + "home-or-tmp": "^2.0.0", + "lodash": "^4.17.4", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.15" } }, "babel-runtime": { @@ -886,8 +886,8 @@ "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", "dev": true, "requires": { - "core-js": "2.5.7", - "regenerator-runtime": "0.11.1" + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" } }, "babel-template": { @@ -896,11 +896,11 @@ "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-traverse": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "lodash": "4.17.10" + "babel-runtime": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "lodash": "^4.17.4" } }, "babel-traverse": { @@ -909,15 +909,15 @@ "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "babel-messages": "6.23.0", - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "babylon": "6.18.0", - "debug": "2.6.9", - "globals": "9.18.0", - "invariant": "2.2.4", - "lodash": "4.17.10" + "babel-code-frame": "^6.26.0", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "debug": "^2.6.8", + "globals": "^9.18.0", + "invariant": "^2.2.2", + "lodash": "^4.17.4" } }, "babel-types": { @@ -926,10 +926,10 @@ "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "esutils": "2.0.2", - "lodash": "4.17.10", - "to-fast-properties": "1.0.3" + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" } }, "babylon": { @@ -956,13 +956,13 @@ "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, "requires": { - "cache-base": "1.0.1", - "class-utils": "0.3.6", - "component-emitter": "1.2.1", - "define-property": "1.0.0", - "isobject": "3.0.1", - "mixin-deep": "1.3.1", - "pascalcase": "0.1.1" + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" }, "dependencies": { "define-property": { @@ -971,7 +971,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "is-accessor-descriptor": { @@ -980,7 +980,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -989,7 +989,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -998,9 +998,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } }, "isobject": { @@ -1068,8 +1068,8 @@ "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", "dev": true, "requires": { - "readable-stream": "2.3.6", - "safe-buffer": "5.1.2" + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" } }, "blob": { @@ -1096,7 +1096,7 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -1106,9 +1106,9 @@ "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", "dev": true, "requires": { - "expand-range": "1.8.2", - "preserve": "0.2.0", - "repeat-element": "1.1.2" + "expand-range": "^1.8.1", + "preserve": "^0.2.0", + "repeat-element": "^1.1.2" } }, "brorand": { @@ -1123,12 +1123,12 @@ "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, "requires": { - "JSONStream": "1.3.3", - "combine-source-map": "0.8.0", - "defined": "1.0.0", - "safe-buffer": "5.1.2", - "through2": "2.0.3", - "umd": "3.0.3" + "JSONStream": "^1.0.3", + "combine-source-map": "~0.8.0", + "defined": "^1.0.0", + "safe-buffer": "^5.1.1", + "through2": "^2.0.0", + "umd": "^3.0.0" } }, "browser-resolve": { @@ -1154,16 +1154,16 @@ "integrity": "sha512-r6ZRYncfYRGerw4Rh5S8Q9x9WKDdrwH572hd3ofsYgn0Px6a6EqXiLBVTCss2+2a45G9ZgjRHSeo9YY56UpgKw==", "dev": true, "requires": { - "browser-sync-ui": "1.0.1", + "browser-sync-ui": "v1.0.1", "bs-recipes": "1.3.4", "chokidar": "1.7.0", "connect": "3.6.6", - "connect-history-api-fallback": "1.5.0", - "dev-ip": "1.0.1", + "connect-history-api-fallback": "^1.5.0", + "dev-ip": "^1.0.1", "easy-extender": "2.3.2", "eazy-logger": "3.0.2", - "etag": "1.8.1", - "fresh": "0.5.2", + "etag": "^1.8.1", + "fresh": "^0.5.2", "fs-extra": "3.0.1", "http-proxy": "1.15.2", "immutable": "3.8.2", @@ -1172,7 +1172,7 @@ "opn": "4.0.2", "portscanner": "2.1.1", "qs": "6.2.3", - "raw-body": "2.3.3", + "raw-body": "^2.3.2", "resp-modifier": "6.0.2", "rx": "4.1.0", "serve-index": "1.9.1", @@ -1190,11 +1190,11 @@ "dev": true, "requires": { "async-each-series": "0.1.1", - "connect-history-api-fallback": "1.5.0", - "immutable": "3.8.2", + "connect-history-api-fallback": "^1.1.0", + "immutable": "^3.7.6", "server-destroy": "1.0.1", "socket.io-client": "2.0.4", - "stream-throttle": "0.1.3" + "stream-throttle": "^0.1.3" } }, "browserify": { @@ -1203,53 +1203,53 @@ "integrity": "sha512-gKfOsNQv/toWz+60nSPfYzuwSEdzvV2WdxrVPUbPD/qui44rAkB3t3muNtmmGYHqrG56FGwX9SUEQmzNLAeS7g==", "dev": true, "requires": { - "JSONStream": "1.3.3", - "assert": "1.4.1", - "browser-pack": "6.1.0", - "browser-resolve": "1.11.3", - "browserify-zlib": "0.2.0", - "buffer": "5.1.0", - "cached-path-relative": "1.0.1", - "concat-stream": "1.5.2", - "console-browserify": "1.1.0", - "constants-browserify": "1.0.0", - "crypto-browserify": "3.12.0", - "defined": "1.0.0", - "deps-sort": "2.0.0", - "domain-browser": "1.1.7", - "duplexer2": "0.1.4", - "events": "1.1.1", - "glob": "7.1.2", - "has": "1.0.3", - "htmlescape": "1.1.1", - "https-browserify": "1.0.0", - "inherits": "2.0.3", - "insert-module-globals": "7.2.0", - "labeled-stream-splicer": "2.0.1", - "module-deps": "4.1.1", - "os-browserify": "0.3.0", - "parents": "1.0.1", - "path-browserify": "0.0.1", - "process": "0.11.10", - "punycode": "1.4.1", - "querystring-es3": "0.2.1", - "read-only-stream": "2.0.0", - "readable-stream": "2.3.6", - "resolve": "1.8.1", - "shasum": "1.0.2", - "shell-quote": "1.6.1", - "stream-browserify": "2.0.1", - "stream-http": "2.8.3", - "string_decoder": "1.0.3", - "subarg": "1.0.0", - "syntax-error": "1.4.0", - "through2": "2.0.3", - "timers-browserify": "1.4.2", - "tty-browserify": "0.0.1", - "url": "0.11.0", - "util": "0.10.4", - "vm-browserify": "0.0.4", - "xtend": "4.0.1" + "JSONStream": "^1.0.3", + "assert": "^1.4.0", + "browser-pack": "^6.0.1", + "browser-resolve": "^1.11.0", + "browserify-zlib": "~0.2.0", + "buffer": "^5.0.2", + "cached-path-relative": "^1.0.0", + "concat-stream": "~1.5.1", + "console-browserify": "^1.1.0", + "constants-browserify": "~1.0.0", + "crypto-browserify": "^3.0.0", + "defined": "^1.0.0", + "deps-sort": "^2.0.0", + "domain-browser": "~1.1.0", + "duplexer2": "~0.1.2", + "events": "~1.1.0", + "glob": "^7.1.0", + "has": "^1.0.0", + "htmlescape": "^1.1.0", + "https-browserify": "^1.0.0", + "inherits": "~2.0.1", + "insert-module-globals": "^7.0.0", + "labeled-stream-splicer": "^2.0.0", + "module-deps": "^4.0.8", + "os-browserify": "~0.3.0", + "parents": "^1.0.1", + "path-browserify": "~0.0.0", + "process": "~0.11.0", + "punycode": "^1.3.2", + "querystring-es3": "~0.2.0", + "read-only-stream": "^2.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.1.4", + "shasum": "^1.0.0", + "shell-quote": "^1.6.1", + "stream-browserify": "^2.0.0", + "stream-http": "^2.0.0", + "string_decoder": "~1.0.0", + "subarg": "^1.0.0", + "syntax-error": "^1.1.1", + "through2": "^2.0.0", + "timers-browserify": "^1.0.1", + "tty-browserify": "~0.0.0", + "url": "~0.11.0", + "util": "~0.10.1", + "vm-browserify": "~0.0.1", + "xtend": "^4.0.0" }, "dependencies": { "string_decoder": { @@ -1258,7 +1258,7 @@ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { - "safe-buffer": "5.1.2" + "safe-buffer": "~5.1.0" } } } @@ -1269,12 +1269,12 @@ "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { - "buffer-xor": "1.0.3", - "cipher-base": "1.0.4", - "create-hash": "1.2.0", - "evp_bytestokey": "1.0.3", - "inherits": "2.0.3", - "safe-buffer": "5.1.2" + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "browserify-cipher": { @@ -1283,9 +1283,9 @@ "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, "requires": { - "browserify-aes": "1.2.0", - "browserify-des": "1.0.2", - "evp_bytestokey": "1.0.3" + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" } }, "browserify-des": { @@ -1294,10 +1294,10 @@ "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, "requires": { - "cipher-base": "1.0.4", - "des.js": "1.0.0", - "inherits": "2.0.3", - "safe-buffer": "5.1.2" + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" } }, "browserify-rsa": { @@ -1306,8 +1306,8 @@ "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { - "bn.js": "4.11.8", - "randombytes": "2.0.6" + "bn.js": "^4.1.0", + "randombytes": "^2.0.1" } }, "browserify-sign": { @@ -1316,13 +1316,13 @@ "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", "dev": true, "requires": { - "bn.js": "4.11.8", - "browserify-rsa": "4.0.1", - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "elliptic": "6.4.0", - "inherits": "2.0.3", - "parse-asn1": "5.1.1" + "bn.js": "^4.1.1", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.2", + "elliptic": "^6.0.0", + "inherits": "^2.0.1", + "parse-asn1": "^5.0.0" } }, "browserify-zlib": { @@ -1331,7 +1331,7 @@ "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, "requires": { - "pako": "1.0.6" + "pako": "~1.0.5" } }, "browserslist": { @@ -1340,8 +1340,8 @@ "integrity": "sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==", "dev": true, "requires": { - "caniuse-lite": "1.0.30000865", - "electron-to-chromium": "1.3.52" + "caniuse-lite": "^1.0.30000844", + "electron-to-chromium": "^1.3.47" } }, "bs-recipes": { @@ -1356,8 +1356,8 @@ "integrity": "sha512-YkIRgwsZwJWTnyQrsBTWefizHh+8GYj3kbL1BTiAQ/9pwpino0G7B2gp5tx/FUBqUlvtxV85KNR3mwfAtv15Yw==", "dev": true, "requires": { - "base64-js": "1.3.0", - "ieee754": "1.1.12" + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" } }, "buffer-from": { @@ -1396,15 +1396,15 @@ "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, "requires": { - "collection-visit": "1.0.0", - "component-emitter": "1.2.1", - "get-value": "2.0.6", - "has-value": "1.0.0", - "isobject": "3.0.1", - "set-value": "2.0.0", - "to-object-path": "0.3.0", - "union-value": "1.0.0", - "unset-value": "1.0.0" + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" }, "dependencies": { "isobject": { @@ -1445,7 +1445,7 @@ "integrity": "sha1-mMyJDKZS3S7w5ws3klMQ/56Q/Is=", "dev": true, "requires": { - "underscore-contrib": "0.3.0" + "underscore-contrib": "~0.3.0" } }, "center-align": { @@ -1454,8 +1454,8 @@ "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", "dev": true, "requires": { - "align-text": "0.1.4", - "lazy-cache": "1.0.4" + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" } }, "chalk": { @@ -1464,11 +1464,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "chokidar": { @@ -1477,15 +1477,15 @@ "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", "dev": true, "requires": { - "anymatch": "1.3.2", - "async-each": "1.0.1", - "fsevents": "1.2.4", - "glob-parent": "2.0.0", - "inherits": "2.0.3", - "is-binary-path": "1.0.1", - "is-glob": "2.0.1", - "path-is-absolute": "1.0.1", - "readdirp": "2.1.0" + "anymatch": "^1.3.0", + "async-each": "^1.0.0", + "fsevents": "^1.0.0", + "glob-parent": "^2.0.0", + "inherits": "^2.0.1", + "is-binary-path": "^1.0.0", + "is-glob": "^2.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.0.0" } }, "cipher-base": { @@ -1494,8 +1494,8 @@ "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.2" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "class-utils": { @@ -1504,10 +1504,10 @@ "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, "requires": { - "arr-union": "3.1.0", - "define-property": "0.2.5", - "isobject": "3.0.1", - "static-extend": "0.1.2" + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" }, "dependencies": { "define-property": { @@ -1516,7 +1516,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "isobject": { @@ -1533,9 +1533,9 @@ "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", "dev": true, "requires": { - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wrap-ansi": "2.1.0" + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" } }, "clone": { @@ -1562,9 +1562,9 @@ "integrity": "sha512-Bq6+4t+lbM8vhTs/Bef5c5AdEMtapp/iFb6+s4/Hh9MVTt8OLKH7ZOOZSCT+Ys7hsHvqv0GuMPJ1lnQJVHvxpg==", "dev": true, "requires": { - "inherits": "2.0.3", - "process-nextick-args": "2.0.0", - "readable-stream": "2.3.6" + "inherits": "^2.0.1", + "process-nextick-args": "^2.0.0", + "readable-stream": "^2.3.5" } }, "code-point-at": { @@ -1579,8 +1579,8 @@ "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, "requires": { - "map-visit": "1.0.0", - "object-visit": "1.0.1" + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" } }, "color-support": { @@ -1595,10 +1595,10 @@ "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, "requires": { - "convert-source-map": "1.1.3", - "inline-source-map": "0.6.2", - "lodash.memoize": "3.0.4", - "source-map": "0.5.7" + "convert-source-map": "~1.1.0", + "inline-source-map": "~0.6.0", + "lodash.memoize": "~3.0.3", + "source-map": "~0.5.3" } }, "commander": { @@ -1637,9 +1637,9 @@ "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "2.0.6", - "typedarray": "0.0.6" + "inherits": "~2.0.1", + "readable-stream": "~2.0.0", + "typedarray": "~0.0.5" }, "dependencies": { "isarray": { @@ -1660,12 +1660,12 @@ "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "0.10.31", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" } }, "string_decoder": { @@ -1682,7 +1682,7 @@ "integrity": "sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg==", "dev": true, "requires": { - "source-map": "0.6.1" + "source-map": "^0.6.1" }, "dependencies": { "source-map": { @@ -1699,8 +1699,8 @@ "integrity": "sha1-q6CXR9++TD5w52am5BWG4YWfxvI=", "dev": true, "requires": { - "ini": "1.3.5", - "proto-list": "1.2.4" + "ini": "^1.3.4", + "proto-list": "~1.2.1" } }, "connect": { @@ -1711,7 +1711,7 @@ "requires": { "debug": "2.6.9", "finalhandler": "1.1.0", - "parseurl": "1.3.2", + "parseurl": "~1.3.2", "utils-merge": "1.0.1" } }, @@ -1727,7 +1727,7 @@ "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", "dev": true, "requires": { - "date-now": "0.1.4" + "date-now": "^0.1.4" } }, "constants-browserify": { @@ -1772,8 +1772,8 @@ "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, "requires": { - "bn.js": "4.11.8", - "elliptic": "6.4.0" + "bn.js": "^4.1.0", + "elliptic": "^6.0.0" } }, "create-hash": { @@ -1782,11 +1782,11 @@ "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { - "cipher-base": "1.0.4", - "inherits": "2.0.3", - "md5.js": "1.3.4", - "ripemd160": "2.0.2", - "sha.js": "2.4.11" + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" } }, "create-hmac": { @@ -1795,12 +1795,12 @@ "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { - "cipher-base": "1.0.4", - "create-hash": "1.2.0", - "inherits": "2.0.3", - "ripemd160": "2.0.2", - "safe-buffer": "5.1.2", - "sha.js": "2.4.11" + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" } }, "crypto-browserify": { @@ -1809,17 +1809,17 @@ "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { - "browserify-cipher": "1.0.1", - "browserify-sign": "4.0.4", - "create-ecdh": "4.0.3", - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "diffie-hellman": "5.0.3", - "inherits": "2.0.3", - "pbkdf2": "3.0.16", - "public-encrypt": "4.0.2", - "randombytes": "2.0.6", - "randomfill": "1.0.4" + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" } }, "date-now": { @@ -1867,7 +1867,7 @@ "integrity": "sha512-9vwabbCoArDvgbZnFqWcGPVvSIIvWTNu1yaAc3Tg3q5pOzORo6nANO3TPwBuiKwN7stMDZJgNnR6USU3H6EQrQ==", "dev": true, "requires": { - "esprima": "4.0.0" + "esprima": "~4.0.0" } }, "deep-extend": { @@ -1882,7 +1882,7 @@ "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", "dev": true, "requires": { - "clone": "1.0.4" + "clone": "^1.0.2" } }, "define-property": { @@ -1891,8 +1891,8 @@ "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", "dev": true, "requires": { - "is-descriptor": "1.0.2", - "isobject": "3.0.1" + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" }, "dependencies": { "is-accessor-descriptor": { @@ -1901,7 +1901,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -1910,7 +1910,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -1919,9 +1919,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } }, "isobject": { @@ -1950,12 +1950,12 @@ "integrity": "sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU=", "dev": true, "requires": { - "globby": "6.1.0", - "is-path-cwd": "1.0.0", - "is-path-in-cwd": "1.0.1", - "p-map": "1.2.0", - "pify": "3.0.0", - "rimraf": "2.6.2" + "globby": "^6.1.0", + "is-path-cwd": "^1.0.0", + "is-path-in-cwd": "^1.0.0", + "p-map": "^1.1.1", + "pify": "^3.0.0", + "rimraf": "^2.2.8" }, "dependencies": { "pify": { @@ -1984,10 +1984,10 @@ "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", "dev": true, "requires": { - "JSONStream": "1.3.3", - "shasum": "1.0.2", - "subarg": "1.0.0", - "through2": "2.0.3" + "JSONStream": "^1.0.3", + "shasum": "^1.0.0", + "subarg": "^1.0.0", + "through2": "^2.0.0" } }, "des.js": { @@ -1996,8 +1996,8 @@ "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", "dev": true, "requires": { - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" } }, "destroy": { @@ -2018,7 +2018,7 @@ "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", "dev": true, "requires": { - "repeating": "2.0.1" + "repeating": "^2.0.0" } }, "detective": { @@ -2027,8 +2027,8 @@ "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", "dev": true, "requires": { - "acorn": "5.7.1", - "defined": "1.0.0" + "acorn": "^5.2.1", + "defined": "^1.0.0" } }, "dev-ip": { @@ -2043,9 +2043,9 @@ "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { - "bn.js": "4.11.8", - "miller-rabin": "4.0.1", - "randombytes": "2.0.6" + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" } }, "docdash": { @@ -2066,7 +2066,7 @@ "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, "requires": { - "readable-stream": "2.3.6" + "readable-stream": "^2.0.2" } }, "easy-extender": { @@ -2075,7 +2075,7 @@ "integrity": "sha1-PTJI/r4rFZYHMW2PnPSRwWZIIh0=", "dev": true, "requires": { - "lodash": "3.10.1" + "lodash": "^3.10.1" }, "dependencies": { "lodash": { @@ -2092,7 +2092,7 @@ "integrity": "sha1-oyWqXlPROiIliJsqxBE7K5Y29Pw=", "dev": true, "requires": { - "tfunk": "3.1.0" + "tfunk": "^3.0.1" } }, "editorconfig": { @@ -2101,11 +2101,11 @@ "integrity": "sha512-WkjsUNVCu+ITKDj73QDvi0trvpdDWdkDyHybDGSXPfekLCqwmpD7CP7iPbvBgosNuLcI96XTDwNa75JyFl7tEQ==", "dev": true, "requires": { - "bluebird": "3.5.1", - "commander": "2.16.0", - "lru-cache": "3.2.0", - "semver": "5.5.0", - "sigmund": "1.0.1" + "bluebird": "^3.0.5", + "commander": "^2.9.0", + "lru-cache": "^3.2.0", + "semver": "^5.1.0", + "sigmund": "^1.0.1" }, "dependencies": { "lru-cache": { @@ -2114,7 +2114,7 @@ "integrity": "sha1-cXibO39Tmb7IVl3aOKow0qCX7+4=", "dev": true, "requires": { - "pseudomap": "1.0.2" + "pseudomap": "^1.0.1" } } } @@ -2137,13 +2137,13 @@ "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", "dev": true, "requires": { - "bn.js": "4.11.8", - "brorand": "1.1.0", - "hash.js": "1.1.5", - "hmac-drbg": "1.0.1", - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1", - "minimalistic-crypto-utils": "1.0.1" + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" } }, "encodeurl": { @@ -2158,7 +2158,7 @@ "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", "dev": true, "requires": { - "once": "1.3.3" + "once": "~1.3.0" }, "dependencies": { "once": { @@ -2167,7 +2167,7 @@ "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } } } @@ -2178,12 +2178,12 @@ "integrity": "sha512-mRbgmAtQ4GAlKwuPnnAvXXwdPhEx+jkc0OBCLrXuD/CRvwNK3AxRSnqK4FSqmAMRRHryVJP8TopOvmEaA64fKw==", "dev": true, "requires": { - "accepts": "1.3.5", + "accepts": "~1.3.4", "base64id": "1.0.0", "cookie": "0.3.1", - "debug": "3.1.0", - "engine.io-parser": "2.1.2", - "ws": "3.3.3" + "debug": "~3.1.0", + "engine.io-parser": "~2.1.0", + "ws": "~3.3.1" }, "dependencies": { "debug": { @@ -2205,14 +2205,14 @@ "requires": { "component-emitter": "1.2.1", "component-inherit": "0.0.3", - "debug": "3.1.0", - "engine.io-parser": "2.1.2", + "debug": "~3.1.0", + "engine.io-parser": "~2.1.1", "has-cors": "1.1.0", "indexof": "0.0.1", "parseqs": "0.0.5", "parseuri": "0.0.5", - "ws": "3.3.3", - "xmlhttprequest-ssl": "1.5.5", + "ws": "~3.3.1", + "xmlhttprequest-ssl": "~1.5.4", "yeast": "0.1.2" }, "dependencies": { @@ -2234,10 +2234,10 @@ "dev": true, "requires": { "after": "0.8.2", - "arraybuffer.slice": "0.0.7", + "arraybuffer.slice": "~0.0.7", "base64-arraybuffer": "0.1.5", "blob": "0.0.4", - "has-binary2": "1.0.3" + "has-binary2": "~1.0.2" } }, "ensure-posix-path": { @@ -2252,7 +2252,7 @@ "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", "dev": true, "requires": { - "is-arrayish": "0.2.1" + "is-arrayish": "^0.2.1" } }, "escape-html": { @@ -2303,8 +2303,8 @@ "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { - "md5.js": "1.3.4", - "safe-buffer": "5.1.2" + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" } }, "exists-stat": { @@ -2319,7 +2319,7 @@ "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", "dev": true, "requires": { - "is-posix-bracket": "0.1.1" + "is-posix-bracket": "^0.1.0" } }, "expand-range": { @@ -2328,7 +2328,7 @@ "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", "dev": true, "requires": { - "fill-range": "2.2.4" + "fill-range": "^2.1.0" } }, "expand-tilde": { @@ -2337,7 +2337,7 @@ "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", "dev": true, "requires": { - "homedir-polyfill": "1.0.1" + "homedir-polyfill": "^1.0.1" } }, "extend": { @@ -2352,8 +2352,8 @@ "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, "requires": { - "assign-symbols": "1.0.0", - "is-extendable": "1.0.1" + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" }, "dependencies": { "is-extendable": { @@ -2362,7 +2362,7 @@ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { - "is-plain-object": "2.0.4" + "is-plain-object": "^2.0.4" } } } @@ -2373,7 +2373,7 @@ "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", "dev": true, "requires": { - "is-extglob": "1.0.0" + "is-extglob": "^1.0.0" } }, "fancy-log": { @@ -2382,9 +2382,9 @@ "integrity": "sha1-9BEl49hPLn2JpD0G2VjI94vha+E=", "dev": true, "requires": { - "ansi-gray": "0.1.1", - "color-support": "1.1.3", - "time-stamp": "1.1.0" + "ansi-gray": "^0.1.1", + "color-support": "^1.1.3", + "time-stamp": "^1.0.0" } }, "filename-regex": { @@ -2399,11 +2399,11 @@ "integrity": "sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==", "dev": true, "requires": { - "is-number": "2.1.0", - "isobject": "2.1.0", - "randomatic": "3.0.0", - "repeat-element": "1.1.2", - "repeat-string": "1.6.1" + "is-number": "^2.1.0", + "isobject": "^2.0.0", + "randomatic": "^3.0.0", + "repeat-element": "^1.1.2", + "repeat-string": "^1.5.2" } }, "finalhandler": { @@ -2413,12 +2413,12 @@ "dev": true, "requires": { "debug": "2.6.9", - "encodeurl": "1.0.2", - "escape-html": "1.0.3", - "on-finished": "2.3.0", - "parseurl": "1.3.2", - "statuses": "1.3.1", - "unpipe": "1.0.0" + "encodeurl": "~1.0.1", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.3.1", + "unpipe": "~1.0.0" } }, "find-index": { @@ -2433,8 +2433,8 @@ "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "dev": true, "requires": { - "path-exists": "2.1.0", - "pinkie-promise": "2.0.1" + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" } }, "findup-sync": { @@ -2443,10 +2443,10 @@ "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", "dev": true, "requires": { - "detect-file": "1.0.0", - "is-glob": "3.1.0", - "micromatch": "3.1.10", - "resolve-dir": "1.0.1" + "detect-file": "^1.0.0", + "is-glob": "^3.1.0", + "micromatch": "^3.0.4", + "resolve-dir": "^1.0.1" }, "dependencies": { "arr-diff": { @@ -2467,16 +2467,16 @@ "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" }, "dependencies": { "extend-shallow": { @@ -2485,7 +2485,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -2496,13 +2496,13 @@ "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -2511,7 +2511,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "extend-shallow": { @@ -2520,7 +2520,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "is-accessor-descriptor": { @@ -2529,7 +2529,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -2538,7 +2538,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -2549,7 +2549,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -2558,7 +2558,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -2569,9 +2569,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" } }, "kind-of": { @@ -2588,14 +2588,14 @@ "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -2604,7 +2604,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "extend-shallow": { @@ -2613,7 +2613,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -2624,10 +2624,10 @@ "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" }, "dependencies": { "extend-shallow": { @@ -2636,7 +2636,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -2647,7 +2647,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -2656,7 +2656,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -2665,9 +2665,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } }, "is-extglob": { @@ -2682,7 +2682,7 @@ "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, "requires": { - "is-extglob": "2.1.1" + "is-extglob": "^2.1.0" } }, "is-number": { @@ -2691,7 +2691,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -2700,7 +2700,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -2723,19 +2723,19 @@ "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.13", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" } } } @@ -2746,11 +2746,11 @@ "integrity": "sha1-s33IRLdqL15wgeiE98CuNE8VNHY=", "dev": true, "requires": { - "expand-tilde": "2.0.2", - "is-plain-object": "2.0.4", - "object.defaults": "1.1.0", - "object.pick": "1.3.0", - "parse-filepath": "1.0.2" + "expand-tilde": "^2.0.2", + "is-plain-object": "^2.0.3", + "object.defaults": "^1.1.0", + "object.pick": "^1.2.0", + "parse-filepath": "^1.0.1" } }, "first-chunk-stream": { @@ -2771,7 +2771,7 @@ "integrity": "sha512-v9GI1hpaqq1ZZR6pBD1+kI7O24PhDvNGNodjS3MdcEqyrahCp8zbtpv+2B/krUnSmUH80lbAS7MrdeK5IylgKg==", "dev": true, "requires": { - "debug": "3.1.0" + "debug": "^3.1.0" }, "dependencies": { "debug": { @@ -2797,7 +2797,7 @@ "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", "dev": true, "requires": { - "for-in": "1.0.2" + "for-in": "^1.0.1" } }, "fragment-cache": { @@ -2806,7 +2806,7 @@ "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, "requires": { - "map-cache": "0.2.2" + "map-cache": "^0.2.2" } }, "fresh": { @@ -2827,9 +2827,9 @@ "integrity": "sha1-N5TzeMWLNC6n27sjCVEJxLO2IpE=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "jsonfile": "3.0.1", - "universalify": "0.1.2" + "graceful-fs": "^4.1.2", + "jsonfile": "^3.0.0", + "universalify": "^0.1.0" } }, "fs.realpath": { @@ -2845,8 +2845,8 @@ "dev": true, "optional": true, "requires": { - "nan": "2.10.0", - "node-pre-gyp": "0.10.0" + "nan": "^2.9.2", + "node-pre-gyp": "^0.10.0" }, "dependencies": { "abbrev": { @@ -2872,8 +2872,8 @@ "dev": true, "optional": true, "requires": { - "delegates": "1.0.0", - "readable-stream": "2.3.6" + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" } }, "balanced-match": { @@ -2886,7 +2886,7 @@ "bundled": true, "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -2950,7 +2950,7 @@ "dev": true, "optional": true, "requires": { - "minipass": "2.2.4" + "minipass": "^2.2.1" } }, "fs.realpath": { @@ -2965,14 +2965,14 @@ "dev": true, "optional": true, "requires": { - "aproba": "1.2.0", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" } }, "glob": { @@ -2981,12 +2981,12 @@ "dev": true, "optional": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "has-unicode": { @@ -3001,7 +3001,7 @@ "dev": true, "optional": true, "requires": { - "safer-buffer": "2.1.2" + "safer-buffer": "^2.1.0" } }, "ignore-walk": { @@ -3010,7 +3010,7 @@ "dev": true, "optional": true, "requires": { - "minimatch": "3.0.4" + "minimatch": "^3.0.4" } }, "inflight": { @@ -3019,8 +3019,8 @@ "dev": true, "optional": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -3039,7 +3039,7 @@ "bundled": true, "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "isarray": { @@ -3053,7 +3053,7 @@ "bundled": true, "dev": true, "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -3066,8 +3066,8 @@ "bundled": true, "dev": true, "requires": { - "safe-buffer": "5.1.1", - "yallist": "3.0.2" + "safe-buffer": "^5.1.1", + "yallist": "^3.0.0" } }, "minizlib": { @@ -3076,7 +3076,7 @@ "dev": true, "optional": true, "requires": { - "minipass": "2.2.4" + "minipass": "^2.2.1" } }, "mkdirp": { @@ -3099,9 +3099,9 @@ "dev": true, "optional": true, "requires": { - "debug": "2.6.9", - "iconv-lite": "0.4.21", - "sax": "1.2.4" + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" } }, "node-pre-gyp": { @@ -3110,16 +3110,16 @@ "dev": true, "optional": true, "requires": { - "detect-libc": "1.0.3", - "mkdirp": "0.5.1", - "needle": "2.2.0", - "nopt": "4.0.1", - "npm-packlist": "1.1.10", - "npmlog": "4.1.2", - "rc": "1.2.7", - "rimraf": "2.6.2", - "semver": "5.5.0", - "tar": "4.4.1" + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.0", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.1.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" } }, "nopt": { @@ -3128,8 +3128,8 @@ "dev": true, "optional": true, "requires": { - "abbrev": "1.1.1", - "osenv": "0.1.5" + "abbrev": "1", + "osenv": "^0.1.4" } }, "npm-bundled": { @@ -3144,8 +3144,8 @@ "dev": true, "optional": true, "requires": { - "ignore-walk": "3.0.1", - "npm-bundled": "1.0.3" + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" } }, "npmlog": { @@ -3154,10 +3154,10 @@ "dev": true, "optional": true, "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" } }, "number-is-nan": { @@ -3176,7 +3176,7 @@ "bundled": true, "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "os-homedir": { @@ -3197,8 +3197,8 @@ "dev": true, "optional": true, "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" } }, "path-is-absolute": { @@ -3219,10 +3219,10 @@ "dev": true, "optional": true, "requires": { - "deep-extend": "0.5.1", - "ini": "1.3.5", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" + "deep-extend": "^0.5.1", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" }, "dependencies": { "minimist": { @@ -3239,13 +3239,13 @@ "dev": true, "optional": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.1", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, "rimraf": { @@ -3254,7 +3254,7 @@ "dev": true, "optional": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } }, "safe-buffer": { @@ -3297,9 +3297,9 @@ "bundled": true, "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, "string_decoder": { @@ -3308,7 +3308,7 @@ "dev": true, "optional": true, "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "~5.1.0" } }, "strip-ansi": { @@ -3316,7 +3316,7 @@ "bundled": true, "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-json-comments": { @@ -3331,13 +3331,13 @@ "dev": true, "optional": true, "requires": { - "chownr": "1.0.1", - "fs-minipass": "1.2.5", - "minipass": "2.2.4", - "minizlib": "1.1.0", - "mkdirp": "0.5.1", - "safe-buffer": "5.1.1", - "yallist": "3.0.2" + "chownr": "^1.0.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.2.4", + "minizlib": "^1.1.0", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.1", + "yallist": "^3.0.2" } }, "util-deprecate": { @@ -3352,7 +3352,7 @@ "dev": true, "optional": true, "requires": { - "string-width": "1.0.2" + "string-width": "^1.0.2" } }, "wrappy": { @@ -3379,7 +3379,7 @@ "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", "dev": true, "requires": { - "globule": "0.1.0" + "globule": "~0.1.0" } }, "get-assigned-identifiers": { @@ -3406,12 +3406,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "glob-base": { @@ -3420,8 +3420,8 @@ "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", "dev": true, "requires": { - "glob-parent": "2.0.0", - "is-glob": "2.0.1" + "glob-parent": "^2.0.0", + "is-glob": "^2.0.0" } }, "glob-parent": { @@ -3430,7 +3430,7 @@ "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", "dev": true, "requires": { - "is-glob": "2.0.1" + "is-glob": "^2.0.0" } }, "glob-stream": { @@ -3439,12 +3439,12 @@ "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", "dev": true, "requires": { - "glob": "4.5.3", - "glob2base": "0.0.12", - "minimatch": "2.0.10", - "ordered-read-streams": "0.1.0", - "through2": "0.6.5", - "unique-stream": "1.0.0" + "glob": "^4.3.1", + "glob2base": "^0.0.12", + "minimatch": "^2.0.1", + "ordered-read-streams": "^0.1.0", + "through2": "^0.6.1", + "unique-stream": "^1.0.0" }, "dependencies": { "glob": { @@ -3453,10 +3453,10 @@ "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", "dev": true, "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "2.0.10", - "once": "1.4.0" + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^2.0.1", + "once": "^1.3.0" } }, "isarray": { @@ -3471,7 +3471,7 @@ "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", "dev": true, "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.0.0" } }, "readable-stream": { @@ -3480,10 +3480,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "string_decoder": { @@ -3498,8 +3498,8 @@ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } } } @@ -3510,7 +3510,7 @@ "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", "dev": true, "requires": { - "gaze": "0.5.2" + "gaze": "^0.5.1" } }, "glob2base": { @@ -3519,7 +3519,7 @@ "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", "dev": true, "requires": { - "find-index": "0.1.1" + "find-index": "^0.1.1" } }, "global-modules": { @@ -3528,9 +3528,9 @@ "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", "dev": true, "requires": { - "global-prefix": "1.0.2", - "is-windows": "1.0.2", - "resolve-dir": "1.0.1" + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" } }, "global-prefix": { @@ -3539,11 +3539,11 @@ "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", "dev": true, "requires": { - "expand-tilde": "2.0.2", - "homedir-polyfill": "1.0.1", - "ini": "1.3.5", - "is-windows": "1.0.2", - "which": "1.3.1" + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" } }, "globals": { @@ -3558,11 +3558,11 @@ "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "dev": true, "requires": { - "array-union": "1.0.2", - "glob": "7.1.2", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" } }, "globule": { @@ -3571,9 +3571,9 @@ "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", "dev": true, "requires": { - "glob": "3.1.21", - "lodash": "1.0.2", - "minimatch": "0.2.14" + "glob": "~3.1.21", + "lodash": "~1.0.1", + "minimatch": "~0.2.11" }, "dependencies": { "glob": { @@ -3582,9 +3582,9 @@ "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", "dev": true, "requires": { - "graceful-fs": "1.2.3", - "inherits": "1.0.2", - "minimatch": "0.2.14" + "graceful-fs": "~1.2.0", + "inherits": "1", + "minimatch": "~0.2.11" } }, "graceful-fs": { @@ -3611,8 +3611,8 @@ "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", "dev": true, "requires": { - "lru-cache": "2.7.3", - "sigmund": "1.0.1" + "lru-cache": "2", + "sigmund": "~1.0.0" } } } @@ -3623,7 +3623,7 @@ "integrity": "sha512-ynYqXLoluBKf9XGR1gA59yEJisIL7YHEH4xr3ZziHB5/yl4qWfaK8Js9jGe6gBGCSCKVqiyO30WnRZADvemUNw==", "dev": true, "requires": { - "sparkles": "1.0.1" + "sparkles": "^1.0.0" } }, "graceful-fs": { @@ -3644,19 +3644,19 @@ "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", "dev": true, "requires": { - "archy": "1.0.0", - "chalk": "1.1.3", - "deprecated": "0.0.1", - "gulp-util": "3.0.8", - "interpret": "1.1.0", - "liftoff": "2.5.0", - "minimist": "1.2.0", - "orchestrator": "0.3.8", - "pretty-hrtime": "1.0.3", - "semver": "4.3.6", - "tildify": "1.2.0", - "v8flags": "2.1.1", - "vinyl-fs": "0.3.14" + "archy": "^1.0.0", + "chalk": "^1.0.0", + "deprecated": "^0.0.1", + "gulp-util": "^3.0.0", + "interpret": "^1.0.0", + "liftoff": "^2.1.0", + "minimist": "^1.1.0", + "orchestrator": "^0.3.0", + "pretty-hrtime": "^1.0.0", + "semver": "^4.1.0", + "tildify": "^1.0.0", + "v8flags": "^2.0.2", + "vinyl-fs": "^0.3.0" }, "dependencies": { "semver": { @@ -3673,12 +3673,12 @@ "integrity": "sha512-tm15R3rt4gO59WXCuqrwf4QXJM9VIJC+0J2NPYSC6xZn+cZRD5y5RPGAiHaDxCJq7Rz5BDljlrk3cEjWADF+wQ==", "dev": true, "requires": { - "babel-core": "6.26.3", - "object-assign": "4.1.1", - "plugin-error": "1.0.1", + "babel-core": "^6.23.1", + "object-assign": "^4.0.1", + "plugin-error": "^1.0.1", "replace-ext": "0.0.1", - "through2": "2.0.3", - "vinyl-sourcemaps-apply": "0.2.1" + "through2": "^2.0.0", + "vinyl-sourcemaps-apply": "^0.2.0" } }, "gulp-concat": { @@ -3687,9 +3687,9 @@ "integrity": "sha1-Yz0WyV2IUEYorQJmVmPO5aR5M1M=", "dev": true, "requires": { - "concat-with-sourcemaps": "1.1.0", - "through2": "2.0.3", - "vinyl": "2.2.0" + "concat-with-sourcemaps": "^1.0.0", + "through2": "^2.0.0", + "vinyl": "^2.0.0" }, "dependencies": { "clone": { @@ -3716,12 +3716,12 @@ "integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==", "dev": true, "requires": { - "clone": "2.1.1", - "clone-buffer": "1.0.0", - "clone-stats": "1.0.0", - "cloneable-readable": "1.1.2", - "remove-trailing-separator": "1.1.0", - "replace-ext": "1.0.0" + "clone": "^2.1.1", + "clone-buffer": "^1.0.0", + "clone-stats": "^1.0.0", + "cloneable-readable": "^1.0.0", + "remove-trailing-separator": "^1.0.1", + "replace-ext": "^1.0.0" } } } @@ -3732,9 +3732,9 @@ "integrity": "sha512-lh9HLdb53sC7XIZOYzTXM4lFuXElv3EVkSDhsd7DoJBj7hm+Ni7D3qYbb+Rr8DuM8nRanBvkVO9d7askreXGnQ==", "dev": true, "requires": { - "concat-with-sourcemaps": "1.1.0", - "lodash.template": "4.4.0", - "through2": "2.0.3" + "concat-with-sourcemaps": "*", + "lodash.template": "^4.4.0", + "through2": "^2.0.0" }, "dependencies": { "lodash.template": { @@ -3743,8 +3743,8 @@ "integrity": "sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A=", "dev": true, "requires": { - "lodash._reinterpolate": "3.0.0", - "lodash.templatesettings": "4.1.0" + "lodash._reinterpolate": "~3.0.0", + "lodash.templatesettings": "^4.0.0" } }, "lodash.templatesettings": { @@ -3753,7 +3753,7 @@ "integrity": "sha1-K01OlbpEDZFf8IvImeRVNmZxMxY=", "dev": true, "requires": { - "lodash._reinterpolate": "3.0.0" + "lodash._reinterpolate": "~3.0.0" } } } @@ -3764,13 +3764,13 @@ "integrity": "sha512-tZUk4c11zF8xzCCTOEmktxGitv/H2vpAcflZNVU8nxL+G5XxQyLJUJVUKylz7/dax+FXb3YwQYByaJ+yxmo8iw==", "dev": true, "requires": { - "chalk": "1.1.3", - "fancy-log": "1.3.2", - "js-beautify": "1.7.5", - "lodash": "4.17.10", - "plugin-error": "0.1.2", - "rc": "1.2.8", - "through2": "2.0.3" + "chalk": "^1.1.3", + "fancy-log": "^1.3.2", + "js-beautify": "^1.7.5", + "lodash": "^4.17.4", + "plugin-error": "^0.1.2", + "rc": "^1.2.2", + "through2": "^2.0.3" }, "dependencies": { "arr-diff": { @@ -3779,8 +3779,8 @@ "integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-slice": "0.2.3" + "arr-flatten": "^1.0.1", + "array-slice": "^0.2.3" } }, "arr-union": { @@ -3801,7 +3801,7 @@ "integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=", "dev": true, "requires": { - "kind-of": "1.1.0" + "kind-of": "^1.1.0" } }, "kind-of": { @@ -3816,11 +3816,11 @@ "integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=", "dev": true, "requires": { - "ansi-cyan": "0.1.1", - "ansi-red": "0.1.1", - "arr-diff": "1.1.0", - "arr-union": "2.1.0", - "extend-shallow": "1.1.4" + "ansi-cyan": "^0.1.1", + "ansi-red": "^0.1.1", + "arr-diff": "^1.0.1", + "arr-union": "^2.0.1", + "extend-shallow": "^1.1.2" } } } @@ -3837,9 +3837,9 @@ "integrity": "sha512-lb1bW7rsPWDD8f4ZPSguDvmCdjKmjr5HR4yZb9ros3sLl5AfW7oUj8KzY9/VRisT7dG8dL7hVHzNpQEVxfwZGQ==", "dev": true, "requires": { - "decomment": "0.9.1", - "plugin-error": "0.1.2", - "through2": "2.0.3" + "decomment": "^0.9.0", + "plugin-error": "^0.1.2", + "through2": "^2.0.3" }, "dependencies": { "arr-diff": { @@ -3848,8 +3848,8 @@ "integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-slice": "0.2.3" + "arr-flatten": "^1.0.1", + "array-slice": "^0.2.3" } }, "arr-union": { @@ -3870,7 +3870,7 @@ "integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=", "dev": true, "requires": { - "kind-of": "1.1.0" + "kind-of": "^1.1.0" } }, "kind-of": { @@ -3885,11 +3885,11 @@ "integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=", "dev": true, "requires": { - "ansi-cyan": "0.1.1", - "ansi-red": "0.1.1", - "arr-diff": "1.1.0", - "arr-union": "2.1.0", - "extend-shallow": "1.1.4" + "ansi-cyan": "^0.1.1", + "ansi-red": "^0.1.1", + "arr-diff": "^1.0.1", + "arr-union": "^2.0.1", + "extend-shallow": "^1.1.2" } } } @@ -3900,14 +3900,14 @@ "integrity": "sha1-UkeI2HZm0J+dDCH7IXf5ADmmWMk=", "dev": true, "requires": { - "deap": "1.0.1", - "fancy-log": "1.3.2", - "gulp-util": "3.0.8", - "isobject": "2.1.0", - "through2": "2.0.3", + "deap": "^1.0.0", + "fancy-log": "^1.0.0", + "gulp-util": "^3.0.0", + "isobject": "^2.0.0", + "through2": "^2.0.0", "uglify-js": "2.6.4", - "uglify-save-license": "0.4.1", - "vinyl-sourcemaps-apply": "0.2.1" + "uglify-save-license": "^0.4.1", + "vinyl-sourcemaps-apply": "^0.2.0" } }, "gulp-util": { @@ -3916,24 +3916,24 @@ "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", "dev": true, "requires": { - "array-differ": "1.0.0", - "array-uniq": "1.0.3", - "beeper": "1.1.1", - "chalk": "1.1.3", - "dateformat": "2.2.0", - "fancy-log": "1.3.2", - "gulplog": "1.0.0", - "has-gulplog": "0.1.0", - "lodash._reescape": "3.0.0", - "lodash._reevaluate": "3.0.0", - "lodash._reinterpolate": "3.0.0", - "lodash.template": "3.6.2", - "minimist": "1.2.0", - "multipipe": "0.1.2", - "object-assign": "3.0.0", + "array-differ": "^1.0.0", + "array-uniq": "^1.0.2", + "beeper": "^1.0.0", + "chalk": "^1.0.0", + "dateformat": "^2.0.0", + "fancy-log": "^1.1.0", + "gulplog": "^1.0.0", + "has-gulplog": "^0.1.0", + "lodash._reescape": "^3.0.0", + "lodash._reevaluate": "^3.0.0", + "lodash._reinterpolate": "^3.0.0", + "lodash.template": "^3.0.0", + "minimist": "^1.1.0", + "multipipe": "^0.1.2", + "object-assign": "^3.0.0", "replace-ext": "0.0.1", - "through2": "2.0.3", - "vinyl": "0.5.3" + "through2": "^2.0.0", + "vinyl": "^0.5.0" }, "dependencies": { "object-assign": { @@ -3950,7 +3950,7 @@ "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", "dev": true, "requires": { - "glogg": "1.0.1" + "glogg": "^1.0.0" } }, "has": { @@ -3959,7 +3959,7 @@ "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, "requires": { - "function-bind": "1.1.1" + "function-bind": "^1.1.1" } }, "has-ansi": { @@ -3968,7 +3968,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "has-binary2": { @@ -3992,7 +3992,7 @@ "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", "dev": true, "requires": { - "sparkles": "1.0.1" + "sparkles": "^1.0.0" } }, "has-value": { @@ -4001,9 +4001,9 @@ "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, "requires": { - "get-value": "2.0.6", - "has-values": "1.0.0", - "isobject": "3.0.1" + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" }, "dependencies": { "isobject": { @@ -4020,8 +4020,8 @@ "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", "dev": true, "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" + "is-number": "^3.0.0", + "kind-of": "^4.0.0" }, "dependencies": { "is-number": { @@ -4030,7 +4030,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -4039,7 +4039,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -4050,7 +4050,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -4061,8 +4061,8 @@ "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.2" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "hash.js": { @@ -4071,8 +4071,8 @@ "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==", "dev": true, "requires": { - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" } }, "hmac-drbg": { @@ -4081,9 +4081,9 @@ "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, "requires": { - "hash.js": "1.1.5", - "minimalistic-assert": "1.0.1", - "minimalistic-crypto-utils": "1.0.1" + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" } }, "home-or-tmp": { @@ -4092,8 +4092,8 @@ "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", "dev": true, "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.1" } }, "homedir-polyfill": { @@ -4102,7 +4102,7 @@ "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", "dev": true, "requires": { - "parse-passwd": "1.0.0" + "parse-passwd": "^1.0.0" } }, "hosted-git-info": { @@ -4123,10 +4123,10 @@ "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", "dev": true, "requires": { - "depd": "1.1.2", + "depd": "~1.1.2", "inherits": "2.0.3", "setprototypeof": "1.1.0", - "statuses": "1.5.0" + "statuses": ">= 1.4.0 < 2" }, "dependencies": { "statuses": { @@ -4143,8 +4143,8 @@ "integrity": "sha1-ZC/cr/5S00SNK9o7AHnpQJBk2jE=", "dev": true, "requires": { - "eventemitter3": "1.2.0", - "requires-port": "1.0.0" + "eventemitter3": "1.x.x", + "requires-port": "1.x.x" } }, "https-browserify": { @@ -4159,7 +4159,7 @@ "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", "dev": true, "requires": { - "safer-buffer": "2.1.2" + "safer-buffer": ">= 2.1.2 < 3" } }, "ieee754": { @@ -4186,8 +4186,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -4208,7 +4208,7 @@ "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "~0.5.3" } }, "insert-module-globals": { @@ -4217,16 +4217,16 @@ "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", "dev": true, "requires": { - "JSONStream": "1.3.3", - "acorn-node": "1.5.2", - "combine-source-map": "0.8.0", - "concat-stream": "1.6.2", - "is-buffer": "1.1.6", - "path-is-absolute": "1.0.1", - "process": "0.11.10", - "through2": "2.0.3", - "undeclared-identifiers": "1.1.2", - "xtend": "4.0.1" + "JSONStream": "^1.0.3", + "acorn-node": "^1.5.2", + "combine-source-map": "^0.8.0", + "concat-stream": "^1.6.1", + "is-buffer": "^1.1.0", + "path-is-absolute": "^1.0.1", + "process": "~0.11.0", + "through2": "^2.0.0", + "undeclared-identifiers": "^1.1.2", + "xtend": "^4.0.0" }, "dependencies": { "concat-stream": { @@ -4235,10 +4235,10 @@ "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, "requires": { - "buffer-from": "1.1.0", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "typedarray": "0.0.6" + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" } } } @@ -4255,7 +4255,7 @@ "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", "dev": true, "requires": { - "loose-envify": "1.4.0" + "loose-envify": "^1.0.0" } }, "invert-kv": { @@ -4270,8 +4270,8 @@ "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", "dev": true, "requires": { - "is-relative": "1.0.0", - "is-windows": "1.0.2" + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" } }, "is-accessor-descriptor": { @@ -4280,7 +4280,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-arrayish": { @@ -4295,7 +4295,7 @@ "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", "dev": true, "requires": { - "binary-extensions": "1.11.0" + "binary-extensions": "^1.0.0" } }, "is-buffer": { @@ -4310,7 +4310,7 @@ "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { - "builtin-modules": "1.1.1" + "builtin-modules": "^1.0.0" } }, "is-data-descriptor": { @@ -4319,7 +4319,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-descriptor": { @@ -4328,9 +4328,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" }, "dependencies": { "kind-of": { @@ -4353,7 +4353,7 @@ "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", "dev": true, "requires": { - "is-primitive": "2.0.0" + "is-primitive": "^2.0.0" } }, "is-extendable": { @@ -4374,7 +4374,7 @@ "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-fullwidth-code-point": { @@ -4383,7 +4383,7 @@ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "is-glob": { @@ -4392,7 +4392,7 @@ "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", "dev": true, "requires": { - "is-extglob": "1.0.0" + "is-extglob": "^1.0.0" } }, "is-number": { @@ -4401,7 +4401,7 @@ "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-number-like": { @@ -4410,7 +4410,7 @@ "integrity": "sha512-6rZi3ezCyFcn5L71ywzz2bS5b2Igl1En3eTlZlvKjpz1n3IZLAYMbKYAIQgFmEu0GENg92ziU/faEOA/aixjbA==", "dev": true, "requires": { - "lodash.isfinite": "3.3.2" + "lodash.isfinite": "^3.3.2" } }, "is-path-cwd": { @@ -4425,7 +4425,7 @@ "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", "dev": true, "requires": { - "is-path-inside": "1.0.1" + "is-path-inside": "^1.0.0" } }, "is-path-inside": { @@ -4434,7 +4434,7 @@ "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { - "path-is-inside": "1.0.2" + "path-is-inside": "^1.0.1" } }, "is-plain-object": { @@ -4443,7 +4443,7 @@ "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.1" }, "dependencies": { "isobject": { @@ -4472,7 +4472,7 @@ "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", "dev": true, "requires": { - "is-unc-path": "1.0.0" + "is-unc-path": "^1.0.0" } }, "is-unc-path": { @@ -4481,7 +4481,7 @@ "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", "dev": true, "requires": { - "unc-path-regex": "0.1.2" + "unc-path-regex": "^0.1.2" } }, "is-utf8": { @@ -4531,10 +4531,10 @@ "integrity": "sha512-9OhfAqGOrD7hoQBLJMTA+BKuKmoEtTJXzZ7WDF/9gvjtey1koVLuZqIY6c51aPDjbNdNtIXAkiWKVhziawE9Og==", "dev": true, "requires": { - "config-chain": "1.1.11", - "editorconfig": "0.13.3", - "mkdirp": "0.5.1", - "nopt": "3.0.6" + "config-chain": "~1.1.5", + "editorconfig": "^0.13.2", + "mkdirp": "~0.5.0", + "nopt": "~3.0.1" } }, "js-reporters": { @@ -4555,7 +4555,7 @@ "integrity": "sha1-P7YOqgicVED5MZ9RdgzNB+JJlzM=", "dev": true, "requires": { - "xmlcreate": "1.0.2" + "xmlcreate": "^1.0.1" } }, "jsdoc": { @@ -4565,17 +4565,17 @@ "dev": true, "requires": { "babylon": "7.0.0-beta.19", - "bluebird": "3.5.1", - "catharsis": "0.8.9", - "escape-string-regexp": "1.0.5", - "js2xmlparser": "3.0.0", - "klaw": "2.0.0", - "marked": "0.3.19", - "mkdirp": "0.5.1", - "requizzle": "0.2.1", - "strip-json-comments": "2.0.1", + "bluebird": "~3.5.0", + "catharsis": "~0.8.9", + "escape-string-regexp": "~1.0.5", + "js2xmlparser": "~3.0.0", + "klaw": "~2.0.0", + "marked": "~0.3.6", + "mkdirp": "~0.5.1", + "requizzle": "~0.2.1", + "strip-json-comments": "~2.0.1", "taffydb": "2.6.2", - "underscore": "1.8.3" + "underscore": "~1.8.3" }, "dependencies": { "babylon": { @@ -4598,7 +4598,7 @@ "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", "dev": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } }, "json5": { @@ -4613,7 +4613,7 @@ "integrity": "sha1-pezG9l9T9mLEQVx2daAzHQmS7GY=", "dev": true, "requires": { - "graceful-fs": "4.1.11" + "graceful-fs": "^4.1.6" } }, "jsonify": { @@ -4634,7 +4634,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } }, "klaw": { @@ -4643,7 +4643,7 @@ "integrity": "sha1-WcEo4Nxc5BAgEVEZTuucv4WGUPY=", "dev": true, "requires": { - "graceful-fs": "4.1.11" + "graceful-fs": "^4.1.9" } }, "labeled-stream-splicer": { @@ -4652,9 +4652,9 @@ "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==", "dev": true, "requires": { - "inherits": "2.0.3", - "isarray": "2.0.4", - "stream-splicer": "2.0.0" + "inherits": "^2.0.1", + "isarray": "^2.0.4", + "stream-splicer": "^2.0.0" }, "dependencies": { "isarray": { @@ -4677,7 +4677,7 @@ "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", "dev": true, "requires": { - "invert-kv": "1.0.0" + "invert-kv": "^1.0.0" } }, "liftoff": { @@ -4686,14 +4686,14 @@ "integrity": "sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew=", "dev": true, "requires": { - "extend": "3.0.1", - "findup-sync": "2.0.0", - "fined": "1.1.0", - "flagged-respawn": "1.0.0", - "is-plain-object": "2.0.4", - "object.map": "1.0.1", - "rechoir": "0.6.2", - "resolve": "1.8.1" + "extend": "^3.0.0", + "findup-sync": "^2.0.0", + "fined": "^1.0.1", + "flagged-respawn": "^1.0.0", + "is-plain-object": "^2.0.4", + "object.map": "^1.0.0", + "rechoir": "^0.6.2", + "resolve": "^1.1.7" } }, "limiter": { @@ -4708,11 +4708,11 @@ "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "parse-json": "2.2.0", - "pify": "2.3.0", - "pinkie-promise": "2.0.1", - "strip-bom": "2.0.0" + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" } }, "localtunnel": { @@ -4742,19 +4742,19 @@ "integrity": "sha1-eC7CHvQDNF+DCoCMo9UTr1YGUgg=", "dev": true, "requires": { - "camelcase": "3.0.0", - "cliui": "3.2.0", - "decamelize": "1.2.0", - "get-caller-file": "1.0.3", - "os-locale": "1.4.0", - "read-pkg-up": "1.0.1", - "require-directory": "2.1.1", - "require-main-filename": "1.0.1", - "set-blocking": "2.0.0", - "string-width": "1.0.2", - "which-module": "1.0.0", - "y18n": "3.2.1", - "yargs-parser": "4.2.1" + "camelcase": "^3.0.0", + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.2", + "which-module": "^1.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^4.2.0" } } } @@ -4825,7 +4825,7 @@ "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", "dev": true, "requires": { - "lodash._root": "3.0.1" + "lodash._root": "^3.0.0" } }, "lodash.isarguments": { @@ -4852,9 +4852,9 @@ "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", "dev": true, "requires": { - "lodash._getnative": "3.9.1", - "lodash.isarguments": "3.1.0", - "lodash.isarray": "3.0.4" + "lodash._getnative": "^3.0.0", + "lodash.isarguments": "^3.0.0", + "lodash.isarray": "^3.0.0" } }, "lodash.memoize": { @@ -4875,15 +4875,15 @@ "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", "dev": true, "requires": { - "lodash._basecopy": "3.0.1", - "lodash._basetostring": "3.0.1", - "lodash._basevalues": "3.0.0", - "lodash._isiterateecall": "3.0.9", - "lodash._reinterpolate": "3.0.0", - "lodash.escape": "3.2.0", - "lodash.keys": "3.1.2", - "lodash.restparam": "3.6.1", - "lodash.templatesettings": "3.1.1" + "lodash._basecopy": "^3.0.0", + "lodash._basetostring": "^3.0.0", + "lodash._basevalues": "^3.0.0", + "lodash._isiterateecall": "^3.0.0", + "lodash._reinterpolate": "^3.0.0", + "lodash.escape": "^3.0.0", + "lodash.keys": "^3.0.0", + "lodash.restparam": "^3.0.0", + "lodash.templatesettings": "^3.0.0" } }, "lodash.templatesettings": { @@ -4892,8 +4892,8 @@ "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", "dev": true, "requires": { - "lodash._reinterpolate": "3.0.0", - "lodash.escape": "3.2.0" + "lodash._reinterpolate": "^3.0.0", + "lodash.escape": "^3.0.0" } }, "longest": { @@ -4908,7 +4908,7 @@ "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "dev": true, "requires": { - "js-tokens": "3.0.2" + "js-tokens": "^3.0.0 || ^4.0.0" } }, "lru-cache": { @@ -4923,7 +4923,7 @@ "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.2" }, "dependencies": { "kind-of": { @@ -4946,7 +4946,7 @@ "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, "requires": { - "object-visit": "1.0.1" + "object-visit": "^1.0.0" } }, "marked": { @@ -4961,7 +4961,7 @@ "integrity": "sha512-nUCmzKipcJEwYsBVAFh5P+d7JBuhJaW1xs85Hara9xuMLqtCVUrW6DSC0JVIkluxEH2W45nPBM/wjHtBXa/tYA==", "dev": true, "requires": { - "minimatch": "3.0.4" + "minimatch": "^3.0.2" } }, "math-random": { @@ -4976,8 +4976,8 @@ "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", "dev": true, "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.3" + "hash-base": "^3.0.0", + "inherits": "^2.0.1" } }, "merge-stream": { @@ -4986,7 +4986,7 @@ "integrity": "sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE=", "dev": true, "requires": { - "readable-stream": "2.3.6" + "readable-stream": "^2.0.1" } }, "micromatch": { @@ -4995,19 +4995,19 @@ "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", "dev": true, "requires": { - "arr-diff": "2.0.0", - "array-unique": "0.2.1", - "braces": "1.8.5", - "expand-brackets": "0.1.5", - "extglob": "0.3.2", - "filename-regex": "2.0.1", - "is-extglob": "1.0.0", - "is-glob": "2.0.1", - "kind-of": "3.2.2", - "normalize-path": "2.1.1", - "object.omit": "2.0.1", - "parse-glob": "3.0.4", - "regex-cache": "0.4.4" + "arr-diff": "^2.0.0", + "array-unique": "^0.2.1", + "braces": "^1.8.2", + "expand-brackets": "^0.1.4", + "extglob": "^0.3.1", + "filename-regex": "^2.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.1", + "kind-of": "^3.0.2", + "normalize-path": "^2.0.1", + "object.omit": "^2.0.0", + "parse-glob": "^3.0.4", + "regex-cache": "^0.4.2" } }, "miller-rabin": { @@ -5016,8 +5016,8 @@ "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, "requires": { - "bn.js": "4.11.8", - "brorand": "1.1.0" + "bn.js": "^4.0.0", + "brorand": "^1.0.1" } }, "mime": { @@ -5038,7 +5038,7 @@ "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { - "mime-db": "1.33.0" + "mime-db": "~1.33.0" } }, "minimalistic-assert": { @@ -5059,7 +5059,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -5074,8 +5074,8 @@ "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", "dev": true, "requires": { - "for-in": "1.0.2", - "is-extendable": "1.0.1" + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" }, "dependencies": { "is-extendable": { @@ -5084,7 +5084,7 @@ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { - "is-plain-object": "2.0.4" + "is-plain-object": "^2.0.4" } } } @@ -5112,21 +5112,21 @@ "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", "dev": true, "requires": { - "JSONStream": "1.3.3", - "browser-resolve": "1.11.3", - "cached-path-relative": "1.0.1", - "concat-stream": "1.5.2", - "defined": "1.0.0", - "detective": "4.7.1", - "duplexer2": "0.1.4", - "inherits": "2.0.3", - "parents": "1.0.1", - "readable-stream": "2.3.6", - "resolve": "1.8.1", - "stream-combiner2": "1.1.1", - "subarg": "1.0.0", - "through2": "2.0.3", - "xtend": "4.0.1" + "JSONStream": "^1.0.3", + "browser-resolve": "^1.7.0", + "cached-path-relative": "^1.0.0", + "concat-stream": "~1.5.0", + "defined": "^1.0.0", + "detective": "^4.0.0", + "duplexer2": "^0.1.2", + "inherits": "^2.0.1", + "parents": "^1.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.1.3", + "stream-combiner2": "^1.1.1", + "subarg": "^1.0.0", + "through2": "^2.0.0", + "xtend": "^4.0.0" } }, "ms": { @@ -5150,7 +5150,7 @@ "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", "dev": true, "requires": { - "readable-stream": "1.1.14" + "readable-stream": "~1.1.9" } }, "isarray": { @@ -5165,10 +5165,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "string_decoder": { @@ -5192,17 +5192,17 @@ "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "fragment-cache": "0.2.1", - "is-windows": "1.0.2", - "kind-of": "6.0.2", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "arr-diff": { @@ -5243,7 +5243,7 @@ "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", "dev": true, "requires": { - "abbrev": "1.1.1" + "abbrev": "1" } }, "normalize-package-data": { @@ -5252,10 +5252,10 @@ "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { - "hosted-git-info": "2.7.1", - "is-builtin-module": "1.0.0", - "semver": "5.5.0", - "validate-npm-package-license": "3.0.3" + "hosted-git-info": "^2.1.4", + "is-builtin-module": "^1.0.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" } }, "normalize-path": { @@ -5264,7 +5264,7 @@ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "remove-trailing-separator": "1.1.0" + "remove-trailing-separator": "^1.0.1" } }, "number-is-nan": { @@ -5291,9 +5291,9 @@ "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, "requires": { - "copy-descriptor": "0.1.1", - "define-property": "0.2.5", - "kind-of": "3.2.2" + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" }, "dependencies": { "define-property": { @@ -5302,7 +5302,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } } } @@ -5319,7 +5319,7 @@ "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.0" }, "dependencies": { "isobject": { @@ -5336,10 +5336,10 @@ "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", "dev": true, "requires": { - "array-each": "1.0.1", - "array-slice": "1.1.0", - "for-own": "1.0.0", - "isobject": "3.0.1" + "array-each": "^1.0.1", + "array-slice": "^1.0.0", + "for-own": "^1.0.0", + "isobject": "^3.0.0" }, "dependencies": { "for-own": { @@ -5348,7 +5348,7 @@ "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", "dev": true, "requires": { - "for-in": "1.0.2" + "for-in": "^1.0.1" } }, "isobject": { @@ -5365,8 +5365,8 @@ "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", "dev": true, "requires": { - "for-own": "1.0.0", - "make-iterator": "1.0.1" + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" }, "dependencies": { "for-own": { @@ -5375,7 +5375,7 @@ "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", "dev": true, "requires": { - "for-in": "1.0.2" + "for-in": "^1.0.1" } } } @@ -5386,8 +5386,8 @@ "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", "dev": true, "requires": { - "for-own": "0.1.5", - "is-extendable": "0.1.1" + "for-own": "^0.1.4", + "is-extendable": "^0.1.1" } }, "object.pick": { @@ -5396,7 +5396,7 @@ "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.1" }, "dependencies": { "isobject": { @@ -5422,7 +5422,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "openurl": { @@ -5437,8 +5437,8 @@ "integrity": "sha1-erwi5kTf9jsKltWrfyeQwPAavJU=", "dev": true, "requires": { - "object-assign": "4.1.1", - "pinkie-promise": "2.0.1" + "object-assign": "^4.0.1", + "pinkie-promise": "^2.0.0" } }, "orchestrator": { @@ -5447,9 +5447,9 @@ "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", "dev": true, "requires": { - "end-of-stream": "0.1.5", - "sequencify": "0.0.7", - "stream-consume": "0.1.1" + "end-of-stream": "~0.1.5", + "sequencify": "~0.0.7", + "stream-consume": "~0.1.0" } }, "ordered-read-streams": { @@ -5476,7 +5476,7 @@ "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", "dev": true, "requires": { - "lcid": "1.0.0" + "lcid": "^1.0.0" } }, "os-tmpdir": { @@ -5503,7 +5503,7 @@ "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", "dev": true, "requires": { - "path-platform": "0.11.15" + "path-platform": "~0.11.15" } }, "parse-asn1": { @@ -5512,11 +5512,11 @@ "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", "dev": true, "requires": { - "asn1.js": "4.10.1", - "browserify-aes": "1.2.0", - "create-hash": "1.2.0", - "evp_bytestokey": "1.0.3", - "pbkdf2": "3.0.16" + "asn1.js": "^4.0.0", + "browserify-aes": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3" } }, "parse-filepath": { @@ -5525,9 +5525,9 @@ "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", "dev": true, "requires": { - "is-absolute": "1.0.0", - "map-cache": "0.2.2", - "path-root": "0.1.1" + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" } }, "parse-glob": { @@ -5536,10 +5536,10 @@ "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", "dev": true, "requires": { - "glob-base": "0.3.0", - "is-dotfile": "1.0.3", - "is-extglob": "1.0.0", - "is-glob": "2.0.1" + "glob-base": "^0.3.0", + "is-dotfile": "^1.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.0" } }, "parse-json": { @@ -5548,7 +5548,7 @@ "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", "dev": true, "requires": { - "error-ex": "1.3.2" + "error-ex": "^1.2.0" } }, "parse-passwd": { @@ -5563,7 +5563,7 @@ "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", "dev": true, "requires": { - "better-assert": "1.0.2" + "better-assert": "~1.0.0" } }, "parseuri": { @@ -5572,7 +5572,7 @@ "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", "dev": true, "requires": { - "better-assert": "1.0.2" + "better-assert": "~1.0.0" } }, "parseurl": { @@ -5599,7 +5599,7 @@ "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", "dev": true, "requires": { - "pinkie-promise": "2.0.1" + "pinkie-promise": "^2.0.0" } }, "path-is-absolute": { @@ -5632,7 +5632,7 @@ "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", "dev": true, "requires": { - "path-root-regex": "0.1.2" + "path-root-regex": "^0.1.0" } }, "path-root-regex": { @@ -5647,9 +5647,9 @@ "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" } }, "pbkdf2": { @@ -5658,11 +5658,11 @@ "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", "dev": true, "requires": { - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "ripemd160": "2.0.2", - "safe-buffer": "5.1.2", - "sha.js": "2.4.11" + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" } }, "pify": { @@ -5683,7 +5683,7 @@ "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, "requires": { - "pinkie": "2.0.4" + "pinkie": "^2.0.0" } }, "plugin-error": { @@ -5692,10 +5692,10 @@ "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", "dev": true, "requires": { - "ansi-colors": "1.1.0", - "arr-diff": "4.0.0", - "arr-union": "3.1.0", - "extend-shallow": "3.0.2" + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" }, "dependencies": { "arr-diff": { @@ -5713,7 +5713,7 @@ "dev": true, "requires": { "async": "1.5.2", - "is-number-like": "1.0.8" + "is-number-like": "^1.0.3" } }, "posix-character-classes": { @@ -5770,11 +5770,11 @@ "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==", "dev": true, "requires": { - "bn.js": "4.11.8", - "browserify-rsa": "4.0.1", - "create-hash": "1.2.0", - "parse-asn1": "5.1.1", - "randombytes": "2.0.6" + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1" } }, "punycode": { @@ -5828,15 +5828,15 @@ "integrity": "sha1-L0RHq16W5Q+z14n9kNTHLg5McMI=", "dev": true, "requires": { - "anymatch": "1.3.2", - "async-each": "1.0.1", - "fsevents": "1.2.4", - "glob-parent": "2.0.0", - "inherits": "2.0.3", - "is-binary-path": "1.0.1", - "is-glob": "2.0.1", - "path-is-absolute": "1.0.1", - "readdirp": "2.1.0" + "anymatch": "^1.3.0", + "async-each": "^1.0.0", + "fsevents": "^1.0.0", + "glob-parent": "^2.0.0", + "inherits": "^2.0.1", + "is-binary-path": "^1.0.0", + "is-glob": "^2.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.0.0" } }, "commander": { @@ -5845,7 +5845,7 @@ "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", "dev": true, "requires": { - "graceful-readlink": "1.0.1" + "graceful-readlink": ">= 1.0.0" } }, "detect-file": { @@ -5854,7 +5854,7 @@ "integrity": "sha1-STXe39lIhkjgBrASlWbpOGcR6mM=", "dev": true, "requires": { - "fs-exists-sync": "0.1.0" + "fs-exists-sync": "^0.1.0" } }, "expand-tilde": { @@ -5863,7 +5863,7 @@ "integrity": "sha1-C4HrqJflo9MdHD0QL48BRB5VlEk=", "dev": true, "requires": { - "os-homedir": "1.0.2" + "os-homedir": "^1.0.1" } }, "findup-sync": { @@ -5872,10 +5872,10 @@ "integrity": "sha1-QAQ5Kee8YK3wt/SCfExudaDeyhI=", "dev": true, "requires": { - "detect-file": "0.1.0", - "is-glob": "2.0.1", - "micromatch": "2.3.11", - "resolve-dir": "0.1.1" + "detect-file": "^0.1.0", + "is-glob": "^2.0.1", + "micromatch": "^2.3.7", + "resolve-dir": "^0.1.0" } }, "global-modules": { @@ -5884,8 +5884,8 @@ "integrity": "sha1-6lo77ULG1s6ZWk+KEmm12uIjgo0=", "dev": true, "requires": { - "global-prefix": "0.1.5", - "is-windows": "0.2.0" + "global-prefix": "^0.1.4", + "is-windows": "^0.2.0" } }, "global-prefix": { @@ -5894,10 +5894,10 @@ "integrity": "sha1-jTvGuNo8qBEqFg2NSW/wRiv+948=", "dev": true, "requires": { - "homedir-polyfill": "1.0.1", - "ini": "1.3.5", - "is-windows": "0.2.0", - "which": "1.3.1" + "homedir-polyfill": "^1.0.0", + "ini": "^1.3.4", + "is-windows": "^0.2.0", + "which": "^1.2.12" } }, "is-windows": { @@ -5912,7 +5912,7 @@ "integrity": "sha1-HwRCyeDLuBNuh7kwX5MvRsfygjU=", "dev": true, "requires": { - "path-parse": "1.0.5" + "path-parse": "^1.0.5" } }, "resolve-dir": { @@ -5921,8 +5921,8 @@ "integrity": "sha1-shklmlYC+sXFxJatiUpujMQwJh4=", "dev": true, "requires": { - "expand-tilde": "1.2.2", - "global-modules": "0.2.3" + "expand-tilde": "^1.2.2", + "global-modules": "^0.2.3" } } } @@ -5933,9 +5933,9 @@ "integrity": "sha512-VdxFOIEY3mNO5PtSRkkle/hPJDHvQhK21oa73K4yAc9qmp6N429gAyF1gZMOTMeS0/AYzaV/2Trcef+NaIonSA==", "dev": true, "requires": { - "is-number": "4.0.0", - "kind-of": "6.0.2", - "math-random": "1.0.1" + "is-number": "^4.0.0", + "kind-of": "^6.0.0", + "math-random": "^1.0.1" }, "dependencies": { "is-number": { @@ -5958,7 +5958,7 @@ "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", "dev": true, "requires": { - "safe-buffer": "5.1.2" + "safe-buffer": "^5.1.0" } }, "randomfill": { @@ -5967,8 +5967,8 @@ "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, "requires": { - "randombytes": "2.0.6", - "safe-buffer": "5.1.2" + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" } }, "range-parser": { @@ -5995,10 +5995,10 @@ "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", "dev": true, "requires": { - "deep-extend": "0.6.0", - "ini": "1.3.5", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" } }, "read-only-stream": { @@ -6007,7 +6007,7 @@ "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", "dev": true, "requires": { - "readable-stream": "2.3.6" + "readable-stream": "^2.0.2" } }, "read-pkg": { @@ -6016,9 +6016,9 @@ "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", "dev": true, "requires": { - "load-json-file": "1.1.0", - "normalize-package-data": "2.4.0", - "path-type": "1.1.0" + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" } }, "read-pkg-up": { @@ -6027,8 +6027,8 @@ "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", "dev": true, "requires": { - "find-up": "1.1.2", - "read-pkg": "1.1.0" + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" } }, "readable-stream": { @@ -6037,13 +6037,13 @@ "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.2", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" }, "dependencies": { "isarray": { @@ -6060,10 +6060,10 @@ "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "minimatch": "3.0.4", - "readable-stream": "2.3.6", - "set-immediate-shim": "1.0.1" + "graceful-fs": "^4.1.2", + "minimatch": "^3.0.2", + "readable-stream": "^2.0.2", + "set-immediate-shim": "^1.0.1" } }, "rechoir": { @@ -6072,7 +6072,7 @@ "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "dev": true, "requires": { - "resolve": "1.8.1" + "resolve": "^1.1.6" } }, "regenerate": { @@ -6093,9 +6093,9 @@ "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==", "dev": true, "requires": { - "babel-runtime": "6.26.0", - "babel-types": "6.26.0", - "private": "0.1.8" + "babel-runtime": "^6.18.0", + "babel-types": "^6.19.0", + "private": "^0.1.6" } }, "regex-cache": { @@ -6104,7 +6104,7 @@ "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { - "is-equal-shallow": "0.1.3" + "is-equal-shallow": "^0.1.3" } }, "regex-not": { @@ -6113,8 +6113,8 @@ "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, "requires": { - "extend-shallow": "3.0.2", - "safe-regex": "1.1.0" + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" } }, "regexpu-core": { @@ -6123,9 +6123,9 @@ "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", "dev": true, "requires": { - "regenerate": "1.4.0", - "regjsgen": "0.2.0", - "regjsparser": "0.1.5" + "regenerate": "^1.2.1", + "regjsgen": "^0.2.0", + "regjsparser": "^0.1.4" } }, "regjsgen": { @@ -6140,7 +6140,7 @@ "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", "dev": true, "requires": { - "jsesc": "0.5.0" + "jsesc": "~0.5.0" } }, "remove-trailing-separator": { @@ -6167,7 +6167,7 @@ "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", "dev": true, "requires": { - "is-finite": "1.0.2" + "is-finite": "^1.0.0" } }, "replace-ext": { @@ -6200,7 +6200,7 @@ "integrity": "sha1-aUPDUwxNmn5G8c3dUcFY/GcM294=", "dev": true, "requires": { - "underscore": "1.6.0" + "underscore": "~1.6.0" }, "dependencies": { "underscore": { @@ -6217,7 +6217,7 @@ "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", "dev": true, "requires": { - "path-parse": "1.0.5" + "path-parse": "^1.0.5" } }, "resolve-dir": { @@ -6226,8 +6226,8 @@ "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", "dev": true, "requires": { - "expand-tilde": "2.0.2", - "global-modules": "1.0.0" + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" } }, "resolve-url": { @@ -6242,8 +6242,8 @@ "integrity": "sha1-sSTeXE+6/LpUH0j/pzlw9KpFa08=", "dev": true, "requires": { - "debug": "2.6.9", - "minimatch": "3.0.4" + "debug": "^2.2.0", + "minimatch": "^3.0.2" } }, "ret": { @@ -6258,7 +6258,7 @@ "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", "dev": true, "requires": { - "align-text": "0.1.4" + "align-text": "^0.1.1" } }, "rimraf": { @@ -6267,7 +6267,7 @@ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } }, "ripemd160": { @@ -6276,8 +6276,8 @@ "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.3" + "hash-base": "^3.0.0", + "inherits": "^2.0.1" } }, "rx": { @@ -6298,7 +6298,7 @@ "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { - "ret": "0.1.15" + "ret": "~0.1.10" } }, "safer-buffer": { @@ -6320,18 +6320,18 @@ "dev": true, "requires": { "debug": "2.6.9", - "depd": "1.1.2", - "destroy": "1.0.4", - "encodeurl": "1.0.2", - "escape-html": "1.0.3", - "etag": "1.8.1", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "1.6.3", + "http-errors": "~1.6.2", "mime": "1.4.1", "ms": "2.0.0", - "on-finished": "2.3.0", - "range-parser": "1.2.0", - "statuses": "1.4.0" + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.4.0" }, "dependencies": { "statuses": { @@ -6354,13 +6354,13 @@ "integrity": "sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=", "dev": true, "requires": { - "accepts": "1.3.5", + "accepts": "~1.3.4", "batch": "0.6.1", "debug": "2.6.9", - "escape-html": "1.0.3", - "http-errors": "1.6.3", - "mime-types": "2.1.18", - "parseurl": "1.3.2" + "escape-html": "~1.0.3", + "http-errors": "~1.6.2", + "mime-types": "~2.1.17", + "parseurl": "~1.3.2" } }, "serve-static": { @@ -6369,9 +6369,9 @@ "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", "dev": true, "requires": { - "encodeurl": "1.0.2", - "escape-html": "1.0.3", - "parseurl": "1.3.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", "send": "0.16.2" } }, @@ -6399,10 +6399,10 @@ "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "split-string": "3.1.0" + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" }, "dependencies": { "extend-shallow": { @@ -6411,7 +6411,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -6428,8 +6428,8 @@ "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.2" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "shasum": { @@ -6438,8 +6438,8 @@ "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true, "requires": { - "json-stable-stringify": "0.0.1", - "sha.js": "2.4.11" + "json-stable-stringify": "~0.0.0", + "sha.js": "~2.4.4" } }, "shell-quote": { @@ -6448,10 +6448,10 @@ "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", "dev": true, "requires": { - "array-filter": "0.0.1", - "array-map": "0.0.0", - "array-reduce": "0.0.0", - "jsonify": "0.0.0" + "array-filter": "~0.0.0", + "array-map": "~0.0.0", + "array-reduce": "~0.0.0", + "jsonify": "~0.0.0" } }, "sigmund": { @@ -6478,14 +6478,14 @@ "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, "requires": { - "base": "0.11.2", - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "map-cache": "0.2.2", - "source-map": "0.5.7", - "source-map-resolve": "0.5.2", - "use": "3.1.1" + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" }, "dependencies": { "define-property": { @@ -6494,7 +6494,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "extend-shallow": { @@ -6503,7 +6503,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -6514,9 +6514,9 @@ "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, "requires": { - "define-property": "1.0.0", - "isobject": "3.0.1", - "snapdragon-util": "3.0.1" + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" }, "dependencies": { "define-property": { @@ -6525,7 +6525,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "is-accessor-descriptor": { @@ -6534,7 +6534,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -6543,7 +6543,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -6552,9 +6552,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } }, "isobject": { @@ -6577,7 +6577,7 @@ "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.2.0" } }, "socket.io": { @@ -6586,12 +6586,12 @@ "integrity": "sha512-rORqq9c+7W0DAK3cleWNSyfv/qKXV99hV4tZe+gGLfBECw3XEhBy7x85F3wypA9688LKjtwO9pX9L33/xQI8yA==", "dev": true, "requires": { - "debug": "3.1.0", - "engine.io": "3.2.0", - "has-binary2": "1.0.3", - "socket.io-adapter": "1.1.1", + "debug": "~3.1.0", + "engine.io": "~3.2.0", + "has-binary2": "~1.0.2", + "socket.io-adapter": "~1.1.0", "socket.io-client": "2.1.1", - "socket.io-parser": "3.2.0" + "socket.io-parser": "~3.2.0" }, "dependencies": { "debug": { @@ -6611,14 +6611,14 @@ "requires": { "component-emitter": "1.2.1", "component-inherit": "0.0.3", - "debug": "3.1.0", - "engine.io-parser": "2.1.2", + "debug": "~3.1.0", + "engine.io-parser": "~2.1.1", "has-cors": "1.1.0", "indexof": "0.0.1", "parseqs": "0.0.5", "parseuri": "0.0.5", - "ws": "3.3.3", - "xmlhttprequest-ssl": "1.5.5", + "ws": "~3.3.1", + "xmlhttprequest-ssl": "~1.5.4", "yeast": "0.1.2" } }, @@ -6632,15 +6632,15 @@ "base64-arraybuffer": "0.1.5", "component-bind": "1.0.0", "component-emitter": "1.2.1", - "debug": "3.1.0", - "engine.io-client": "3.2.1", - "has-binary2": "1.0.3", + "debug": "~3.1.0", + "engine.io-client": "~3.2.0", + "has-binary2": "~1.0.2", "has-cors": "1.1.0", "indexof": "0.0.1", "object-component": "0.0.3", "parseqs": "0.0.5", "parseuri": "0.0.5", - "socket.io-parser": "3.2.0", + "socket.io-parser": "~3.2.0", "to-array": "0.1.4" } }, @@ -6651,7 +6651,7 @@ "dev": true, "requires": { "component-emitter": "1.2.1", - "debug": "3.1.0", + "debug": "~3.1.0", "isarray": "2.0.1" } } @@ -6673,14 +6673,14 @@ "base64-arraybuffer": "0.1.5", "component-bind": "1.0.0", "component-emitter": "1.2.1", - "debug": "2.6.9", - "engine.io-client": "3.1.6", + "debug": "~2.6.4", + "engine.io-client": "~3.1.0", "has-cors": "1.1.0", "indexof": "0.0.1", "object-component": "0.0.3", "parseqs": "0.0.5", "parseuri": "0.0.5", - "socket.io-parser": "3.1.3", + "socket.io-parser": "~3.1.1", "to-array": "0.1.4" } }, @@ -6691,8 +6691,8 @@ "dev": true, "requires": { "component-emitter": "1.2.1", - "debug": "3.1.0", - "has-binary2": "1.0.3", + "debug": "~3.1.0", + "has-binary2": "~1.0.2", "isarray": "2.0.1" }, "dependencies": { @@ -6719,11 +6719,11 @@ "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", "dev": true, "requires": { - "atob": "2.1.1", - "decode-uri-component": "0.2.0", - "resolve-url": "0.2.1", - "source-map-url": "0.4.0", - "urix": "0.1.0" + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" } }, "source-map-support": { @@ -6732,7 +6732,7 @@ "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "^0.5.6" } }, "source-map-url": { @@ -6753,8 +6753,8 @@ "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { - "spdx-expression-parse": "3.0.0", - "spdx-license-ids": "3.0.0" + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" } }, "spdx-exceptions": { @@ -6769,8 +6769,8 @@ "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { - "spdx-exceptions": "2.1.0", - "spdx-license-ids": "3.0.0" + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" } }, "spdx-license-ids": { @@ -6785,7 +6785,7 @@ "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, "requires": { - "extend-shallow": "3.0.2" + "extend-shallow": "^3.0.0" } }, "static-extend": { @@ -6794,8 +6794,8 @@ "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", "dev": true, "requires": { - "define-property": "0.2.5", - "object-copy": "0.1.0" + "define-property": "^0.2.5", + "object-copy": "^0.1.0" }, "dependencies": { "define-property": { @@ -6804,7 +6804,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } } } @@ -6821,8 +6821,8 @@ "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.6" + "inherits": "~2.0.1", + "readable-stream": "^2.0.2" } }, "stream-combiner2": { @@ -6831,8 +6831,8 @@ "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, "requires": { - "duplexer2": "0.1.4", - "readable-stream": "2.3.6" + "duplexer2": "~0.1.0", + "readable-stream": "^2.0.2" } }, "stream-consume": { @@ -6847,11 +6847,11 @@ "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", "dev": true, "requires": { - "builtin-status-codes": "3.0.0", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "to-arraybuffer": "1.0.1", - "xtend": "4.0.1" + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.3.6", + "to-arraybuffer": "^1.0.0", + "xtend": "^4.0.0" } }, "stream-splicer": { @@ -6860,8 +6860,8 @@ "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.6" + "inherits": "^2.0.1", + "readable-stream": "^2.0.2" } }, "stream-throttle": { @@ -6870,8 +6870,8 @@ "integrity": "sha1-rdV8jXzHOoFjDTHNVdOWHPr7qcM=", "dev": true, "requires": { - "commander": "2.16.0", - "limiter": "1.1.3" + "commander": "^2.2.0", + "limiter": "^1.0.5" } }, "string-width": { @@ -6880,9 +6880,9 @@ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, "string_decoder": { @@ -6891,7 +6891,7 @@ "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { - "safe-buffer": "5.1.2" + "safe-buffer": "~5.1.0" } }, "strip-ansi": { @@ -6900,7 +6900,7 @@ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-bom": { @@ -6909,7 +6909,7 @@ "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, "requires": { - "is-utf8": "0.2.1" + "is-utf8": "^0.2.0" } }, "strip-json-comments": { @@ -6924,7 +6924,7 @@ "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", "dev": true, "requires": { - "minimist": "1.2.0" + "minimist": "^1.1.0" } }, "supports-color": { @@ -6939,7 +6939,7 @@ "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, "requires": { - "acorn-node": "1.5.2" + "acorn-node": "^1.2.0" } }, "taffydb": { @@ -6954,8 +6954,8 @@ "integrity": "sha1-OORBT8ZJd9h6/apy+sttKfgve1s=", "dev": true, "requires": { - "chalk": "1.1.3", - "object-path": "0.9.2" + "chalk": "^1.1.1", + "object-path": "^0.9.0" } }, "through": { @@ -6970,8 +6970,8 @@ "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "readable-stream": "2.3.6", - "xtend": "4.0.1" + "readable-stream": "^2.1.5", + "xtend": "~4.0.1" } }, "tildify": { @@ -6980,7 +6980,7 @@ "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", "dev": true, "requires": { - "os-homedir": "1.0.2" + "os-homedir": "^1.0.0" } }, "time-stamp": { @@ -6995,7 +6995,7 @@ "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", "dev": true, "requires": { - "process": "0.11.10" + "process": "~0.11.0" } }, "to-array": { @@ -7022,7 +7022,7 @@ "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "to-regex": { @@ -7031,10 +7031,10 @@ "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, "requires": { - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "regex-not": "1.0.2", - "safe-regex": "1.1.0" + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" } }, "to-regex-range": { @@ -7043,8 +7043,8 @@ "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, "requires": { - "is-number": "3.0.0", - "repeat-string": "1.6.1" + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" }, "dependencies": { "is-number": { @@ -7053,7 +7053,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } } } @@ -7088,10 +7088,10 @@ "integrity": "sha1-ZeovswWck5RpLxX+2HwrNsFrmt8=", "dev": true, "requires": { - "async": "0.2.10", - "source-map": "0.5.7", - "uglify-to-browserify": "1.0.2", - "yargs": "3.10.0" + "async": "~0.2.6", + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" }, "dependencies": { "async": { @@ -7112,8 +7112,8 @@ "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", "dev": true, "requires": { - "center-align": "0.1.3", - "right-align": "0.1.3", + "center-align": "^0.1.1", + "right-align": "^0.1.1", "wordwrap": "0.0.2" } }, @@ -7129,9 +7129,9 @@ "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", "dev": true, "requires": { - "camelcase": "1.2.1", - "cliui": "2.1.0", - "decamelize": "1.2.0", + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", "window-size": "0.1.0" } } @@ -7173,10 +7173,10 @@ "integrity": "sha512-13EaeocO4edF/3JKime9rD7oB6QI8llAGhgn5fKOPyfkJbRb6NFv9pYV6dFEmpa4uRjKeBqLZP8GpuzqHlKDMQ==", "dev": true, "requires": { - "acorn-node": "1.5.2", - "get-assigned-identifiers": "1.2.0", - "simple-concat": "1.0.0", - "xtend": "4.0.1" + "acorn-node": "^1.3.0", + "get-assigned-identifiers": "^1.2.0", + "simple-concat": "^1.0.0", + "xtend": "^4.0.1" } }, "underscore": { @@ -7208,10 +7208,10 @@ "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", "dev": true, "requires": { - "arr-union": "3.1.0", - "get-value": "2.0.6", - "is-extendable": "0.1.1", - "set-value": "0.4.3" + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^0.4.3" }, "dependencies": { "extend-shallow": { @@ -7220,7 +7220,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "set-value": { @@ -7229,10 +7229,10 @@ "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "to-object-path": "0.3.0" + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.1", + "to-object-path": "^0.3.0" } } } @@ -7261,8 +7261,8 @@ "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, "requires": { - "has-value": "0.3.1", - "isobject": "3.0.1" + "has-value": "^0.3.1", + "isobject": "^3.0.0" }, "dependencies": { "has-value": { @@ -7271,9 +7271,9 @@ "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, "requires": { - "get-value": "2.0.6", - "has-values": "0.1.4", - "isobject": "2.1.0" + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" }, "dependencies": { "isobject": { @@ -7370,7 +7370,7 @@ "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", "dev": true, "requires": { - "user-home": "1.1.1" + "user-home": "^1.1.1" } }, "validate-npm-package-license": { @@ -7379,8 +7379,8 @@ "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { - "spdx-correct": "3.0.0", - "spdx-expression-parse": "3.0.0" + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" } }, "vinyl": { @@ -7389,8 +7389,8 @@ "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", "dev": true, "requires": { - "clone": "1.0.4", - "clone-stats": "0.0.1", + "clone": "^1.0.0", + "clone-stats": "^0.0.1", "replace-ext": "0.0.1" } }, @@ -7400,8 +7400,8 @@ "integrity": "sha1-lsGjR5uMU5JULGEgKQE7Wyf4i78=", "dev": true, "requires": { - "bl": "1.2.2", - "through2": "2.0.3" + "bl": "^1.2.1", + "through2": "^2.0.3" } }, "vinyl-fs": { @@ -7410,14 +7410,14 @@ "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", "dev": true, "requires": { - "defaults": "1.0.3", - "glob-stream": "3.1.18", - "glob-watcher": "0.0.6", - "graceful-fs": "3.0.11", - "mkdirp": "0.5.1", - "strip-bom": "1.0.0", - "through2": "0.6.5", - "vinyl": "0.4.6" + "defaults": "^1.0.0", + "glob-stream": "^3.1.5", + "glob-watcher": "^0.0.6", + "graceful-fs": "^3.0.0", + "mkdirp": "^0.5.0", + "strip-bom": "^1.0.0", + "through2": "^0.6.1", + "vinyl": "^0.4.0" }, "dependencies": { "clone": { @@ -7432,7 +7432,7 @@ "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", "dev": true, "requires": { - "natives": "1.1.4" + "natives": "^1.1.0" } }, "isarray": { @@ -7447,10 +7447,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "string_decoder": { @@ -7465,8 +7465,8 @@ "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", "dev": true, "requires": { - "first-chunk-stream": "1.0.0", - "is-utf8": "0.2.1" + "first-chunk-stream": "^1.0.0", + "is-utf8": "^0.2.0" } }, "through2": { @@ -7475,8 +7475,8 @@ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } }, "vinyl": { @@ -7485,8 +7485,8 @@ "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", "dev": true, "requires": { - "clone": "0.2.0", - "clone-stats": "0.0.1" + "clone": "^0.2.0", + "clone-stats": "^0.0.1" } } } @@ -7497,8 +7497,8 @@ "integrity": "sha1-YrU6E1YQqJbpjKlr7jqH8Aio54A=", "dev": true, "requires": { - "through2": "2.0.3", - "vinyl": "0.4.6" + "through2": "^2.0.3", + "vinyl": "^0.4.3" }, "dependencies": { "clone": { @@ -7513,8 +7513,8 @@ "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", "dev": true, "requires": { - "clone": "0.2.0", - "clone-stats": "0.0.1" + "clone": "^0.2.0", + "clone-stats": "^0.0.1" } } } @@ -7525,7 +7525,7 @@ "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "^0.5.1" } }, "vm-browserify": { @@ -7543,8 +7543,8 @@ "integrity": "sha1-VYoWrqyMDbWcAotzxm85doTs5GU=", "dev": true, "requires": { - "ensure-posix-path": "1.0.2", - "matcher-collection": "1.0.5" + "ensure-posix-path": "^1.0.0", + "matcher-collection": "^1.0.0" } }, "which": { @@ -7553,7 +7553,7 @@ "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, "requires": { - "isexe": "2.0.0" + "isexe": "^2.0.0" } }, "which-module": { @@ -7580,8 +7580,8 @@ "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { - "string-width": "1.0.2", - "strip-ansi": "3.0.1" + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" } }, "wrappy": { @@ -7596,9 +7596,9 @@ "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", "dev": true, "requires": { - "async-limiter": "1.0.0", - "safe-buffer": "5.1.2", - "ultron": "1.1.1" + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0", + "ultron": "~1.1.0" } }, "xmlcreate": { @@ -7631,20 +7631,20 @@ "integrity": "sha1-gW4ahm1VmMzzTlWW3c4i2S2kkNQ=", "dev": true, "requires": { - "camelcase": "3.0.0", - "cliui": "3.2.0", - "decamelize": "1.2.0", - "get-caller-file": "1.0.3", - "os-locale": "1.4.0", - "read-pkg-up": "1.0.1", - "require-directory": "2.1.1", - "require-main-filename": "1.0.1", - "set-blocking": "2.0.0", - "string-width": "1.0.2", - "which-module": "1.0.0", - "window-size": "0.2.0", - "y18n": "3.2.1", - "yargs-parser": "4.2.1" + "camelcase": "^3.0.0", + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.2", + "which-module": "^1.0.0", + "window-size": "^0.2.0", + "y18n": "^3.2.1", + "yargs-parser": "^4.1.0" } }, "yargs-parser": { @@ -7653,7 +7653,7 @@ "integrity": "sha1-KczqwNxPA8bIe0qfIX3RjJ90hxw=", "dev": true, "requires": { - "camelcase": "3.0.0" + "camelcase": "^3.0.0" } }, "yeast": { diff --git a/src/backend/cpu/function-node.js b/src/backend/cpu/function-node.js index 489d4123..db4f4be5 100644 --- a/src/backend/cpu/function-node.js +++ b/src/backend/cpu/function-node.js @@ -5,7 +5,7 @@ const utils = require('../../core/utils'); /** * @class CPUFunctionNode - * + * * @extends BaseFunctionNode# * * @desc [INTERNAL] Represents a single function, inside JS @@ -614,6 +614,7 @@ module.exports = class CPUFunctionNode extends BaseFunctionNode { astVariableDeclaration(vardecNode, retArr) { retArr.push('var '); for (let i = 0; i < vardecNode.declarations.length; i++) { + this.declarations[vardecNode.declarations[i].id.name] = 'var'; if (i > 0) { retArr.push(','); } @@ -816,7 +817,13 @@ module.exports = class CPUFunctionNode extends BaseFunctionNode { */ astMemberExpression(mNode, retArr) { if (mNode.computed) { - if (mNode.object.type === 'Identifier') { + if (mNode.object.type === 'Identifier' || + ( + mNode.object.type === 'MemberExpression' && + mNode.object.object.object && + mNode.object.object.object.type === 'ThisExpression' && + mNode.object.object.property.name === 'constants' + )) { this.pushState('identifier'); this.astGeneric(mNode.object, retArr); this.popState('identifier'); @@ -888,8 +895,11 @@ module.exports = class CPUFunctionNode extends BaseFunctionNode { unrolled = 'user_' + unrolled; } - // Its a reference to `this`, add '_' before - if (unrolled.indexOf('this') === 0) { + if (unrolled.indexOf('this.constants') === 0) { + // remove 'this.constants' from beginning + unrolled = 'constants_' + unrolled.substring(15); + } else if (unrolled.indexOf('this') === 0) { + // Its a reference to `this`, add '_' before unrolled = '_' + unrolled; } @@ -910,6 +920,12 @@ module.exports = class CPUFunctionNode extends BaseFunctionNode { retArr.push(this.output[2]); break; default: + if ( + mNode.object && + mNode.object.name && + this.declarations[mNode.object.name]) { + retArr.push('user_'); + } retArr.push(unrolled); } diff --git a/src/backend/cpu/kernel-string.js b/src/backend/cpu/kernel-string.js index 26b9e8c1..09df37b9 100644 --- a/src/backend/cpu/kernel-string.js +++ b/src/backend/cpu/kernel-string.js @@ -51,6 +51,7 @@ module.exports = function(cpuKernel, name) { setWebGl(webGl) { this._webGl = webGl; return this; } ${ removeFnNoise(cpuKernel.build.toString()) } ${ removeFnNoise(cpuKernel.setupParams.toString()) } + ${ removeFnNoise(cpuKernel.setupConstants.toString()) } run () { ${ cpuKernel.kernelString } } getKernelString() { return this._kernelString; } ${ removeFnNoise(cpuKernel.validateOptions.toString()) } diff --git a/src/backend/cpu/kernel.js b/src/backend/cpu/kernel.js index 5814f5c1..b63cbffb 100644 --- a/src/backend/cpu/kernel.js +++ b/src/backend/cpu/kernel.js @@ -83,8 +83,11 @@ module.exports = class CPUKernel extends KernelBase { * */ build() { + this.setupConstants(); this.setupParams(arguments); this.validateOptions(); + const canvas = this._canvas; + this._canvasCtx = canvas.getContext('2d'); const threadDim = this.threadDim = utils.clone(this.output); while (threadDim.length < 3) { @@ -92,10 +95,8 @@ module.exports = class CPUKernel extends KernelBase { } if (this.graphical) { - const canvas = this.getCanvas(); canvas.width = threadDim[0]; canvas.height = threadDim[1]; - this._canvasCtx = canvas.getContext('2d'); this._imageData = this._canvasCtx.createImageData(threadDim[0], threadDim[1]); this._colorData = new Uint8ClampedArray(threadDim[0] * threadDim[1] * 4); } @@ -170,7 +171,8 @@ module.exports = class CPUKernel extends KernelBase { loopMaxIterations: this.loopMaxIterations, paramNames: this.paramNames, paramTypes: this.paramTypes, - paramSizes: this.paramSizes + paramSizes: this.paramSizes, + constantTypes: this.constantTypes }); builder.addFunctions(this.functions, { @@ -219,14 +221,16 @@ module.exports = class CPUKernel extends KernelBase { kernel = prototypes.shift(); } const kernelString = this._kernelString = ` - var LOOP_MAX = ${ this._getLoopMaxString() }; + var LOOP_MAX = ${ this._getLoopMaxString() } + var constants = this.constants; var _this = this; ${ this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map((name) => ` var ${ name } = null;\n`).join('') } return function (${ this.paramNames.map(paramName => 'user_' + paramName).join(', ') }) { - ${ this._processInputs() } + ${ this._processConstants() } + ${ this._processParams() } var ret = new Array(${ threadDim[2] }); ${ this.subKernelOutputVariableNames === null ? '' @@ -334,7 +338,30 @@ ${ this.subKernelOutputVariableNames === null ); } - _processInputs() { + _processConstants() { + if (!this.constants) return ''; + + const result = []; + for (let p in this.constants) { + const type = this.constantTypes[p]; + switch (type) { + case 'HTMLImage': + result.push(` var constants_${p} = this._imageTo2DArray(this.constants.${p})`); + break; + case 'HTMLImageArray': + result.push(` var constants_${p} = this._imageTo3DArray(this.constants.${p})`); + break; + case 'Input': + result.push(` var constants_${p} = this.constants.${p}.value`); + break; + default: + result.push(` var constants_${p} = this.constants.${p}`); + } + } + return result.join('\n'); + } + + _processParams() { const result = []; for (let i = 0; i < this.paramTypes.length; i++) { switch (this.paramTypes[i]) { @@ -353,14 +380,31 @@ ${ this.subKernelOutputVariableNames === null } _imageTo2DArray(image) { - this._canvasCtx.drawImage(image, 0, 0, image.width, image.height); - const pixelsData = this._canvasCtx.getImageData(0, 0, image.width, image.height).data; + const canvas = this._canvas; + if (canvas.width < image.width) { + canvas.width = image.width; + } + if (canvas.height < image.height) { + canvas.height = image.height; + } + const ctx = this._canvasCtx; + ctx.drawImage(image, 0, 0, image.width, image.height); + const pixelsData = ctx.getImageData(0, 0, image.width, image.height).data; const imageArray = new Array(image.height); let index = 0; for (let y = image.height - 1; y >= 0; y--) { imageArray[y] = new Array(image.width); for (let x = 0; x < image.width; x++) { - imageArray[y][x] = [pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255]; + const r = pixelsData[index++] / 255; + const g = pixelsData[index++] / 255; + const b = pixelsData[index++] / 255; + const a = pixelsData[index++] / 255; + const result = [r, g, b, a]; + result.r = r; + result.g = g; + result.b = b; + result.a = a; + imageArray[y][x] = result; } } return imageArray; diff --git a/src/backend/function-node-base.js b/src/backend/function-node-base.js index 26af762a..40380dff 100644 --- a/src/backend/function-node-base.js +++ b/src/backend/function-node-base.js @@ -62,6 +62,11 @@ module.exports = class BaseFunctionNode { if (options.hasOwnProperty('paramTypes')) { this.paramTypes = paramTypes = options.paramTypes; } + if (options.hasOwnProperty('constantTypes')) { + this.constantTypes = options.constantTypes; + } else { + this.constantTypes = {}; + } if (options.hasOwnProperty('returnType')) { returnType = options.returnType; } @@ -366,6 +371,13 @@ module.exports = class BaseFunctionNode { return null; } + getConstantType(constantName) { + if (this.constantTypes[constantName]) { + return this.constantTypes[constantName]; + } + return null; + } + /** * @memberOf FunctionNodeBase# * @function diff --git a/src/backend/kernel-base.js b/src/backend/kernel-base.js index cae1963b..7a63c23b 100644 --- a/src/backend/kernel-base.js +++ b/src/backend/kernel-base.js @@ -56,6 +56,7 @@ module.exports = class KernelBase { this.functionBuilder = null; this.paramTypes = null; this.paramSizes = null; + this.constantTypes = null; this.fixIntegerDivisionAccuracy = null; for (let p in settings) { @@ -97,6 +98,15 @@ module.exports = class KernelBase { } } + setupConstants() { + this.constantTypes = {}; + if (this.constants) { + for (let p in this.constants) { + this.constantTypes[p] = utils.getArgumentType(this.constants[p]) + } + } + } + setAddFunction(cb) { this.addFunction = cb; return this; diff --git a/src/backend/web-gl/function-node.js b/src/backend/web-gl/function-node.js index d4336f19..05ffd638 100644 --- a/src/backend/web-gl/function-node.js +++ b/src/backend/web-gl/function-node.js @@ -15,7 +15,7 @@ const ENCODE32_DECODE32 = /encode32\(\s+decode32\(/g; // TODO: optimise out - webpack/babel options? maybe some generic logging support in core/utils? // const debugLog = console.log const debugLog = () => {}; -/** +/** * @class WebGLFunctionNode * * @desc [INTERNAL] Takes in a function node, and does all the AST voodoo required to generate its respective webGL code. @@ -856,7 +856,14 @@ module.exports = class WebGLFunctionNode extends FunctionNodeBase { astMemberExpression(mNode, retArr) { debugLog("[in] astMemberExpression " + mNode.object.type); if (mNode.computed) { - if (mNode.object.type === 'Identifier') { + if (mNode.object.type === 'Identifier' || + ( + mNode.object.type === 'MemberExpression' && + mNode.object.object.object && + mNode.object.object.object.type === 'ThisExpression' && + mNode.object.object.property.name === 'constants' + ) + ) { // Working logger const reqName = mNode.object.name; const funcName = this.functionName || 'kernel'; @@ -885,7 +892,18 @@ module.exports = class WebGLFunctionNode extends FunctionNodeBase { this.pushState('not-in-get-call-parameters'); // This normally refers to the global read only input vars - switch (this.getParamType(mNode.object.name)) { + let variableType = null; + if (mNode.object.name) { + variableType = this.getParamType(mNode.object.name); + } else if ( + mNode.object && + mNode.object.object && + mNode.object.object.object && + mNode.object.object.object.type === 'ThisExpression' + ) { + variableType = this.getConstantType(mNode.object.property.name); + } + switch (variableType) { case 'vec4': // Get from local vec4 this.astGeneric(mNode.object, retArr); @@ -1051,6 +1069,12 @@ module.exports = class WebGLFunctionNode extends FunctionNodeBase { retArr.push(this.output[2] + '.0'); break; default: + if ( + mNode.object && + mNode.object.name && + this.declarations[mNode.object.name]) { + retArr.push('user_'); + } retArr.push(unrolled); } } @@ -1233,7 +1257,7 @@ function ensureIndentifierType(paramName, expectedType, ast, funcParam) { * @name webgl_regex_optimize * * @desc [INTERNAL] Takes the near final webgl function string, and do regex search and replacments. - * For voodoo optimize out the following: + * For voodoo optimize out the following: * * - decode32(encode32(
* - encode32(decode32(
diff --git a/src/backend/web-gl/kernel-string.js b/src/backend/web-gl/kernel-string.js index fe0f7803..3143e668 100644 --- a/src/backend/web-gl/kernel-string.js +++ b/src/backend/web-gl/kernel-string.js @@ -65,10 +65,12 @@ module.exports = function(gpuKernel, name) { ${ removeFnNoise(gpuKernel._getVertShaderString.toString()) } validateOptions() {} setupParams() {} + setupConstants() {} setCanvas(canvas) { this._canvas = canvas; return this; } setWebGl(webGl) { this._webGl = webGl; return this; } ${ removeFnNoise(gpuKernel.getUniformLocation.toString()) } ${ removeFnNoise(gpuKernel.setupParams.toString()) } + ${ removeFnNoise(gpuKernel.setupConstants.toString()) } ${ removeFnNoise(gpuKernel.build.toString()) } ${ removeFnNoise(gpuKernel.run.toString()) } ${ removeFnNoise(gpuKernel._addArgument.toString()) } diff --git a/src/backend/web-gl/kernel.js b/src/backend/web-gl/kernel.js index 9afbcc58..6ad1127e 100644 --- a/src/backend/web-gl/kernel.js +++ b/src/backend/web-gl/kernel.js @@ -53,6 +53,7 @@ module.exports = class WebGLKernel extends KernelBase { this.subKernelOutputTextures = null; this.subKernelOutputVariableNames = null; this.argumentsLength = 0; + this.constantsLength = 0; this.compiledFragShaderString = null; this.compiledVertShaderString = null; this.fragShader = null; @@ -96,7 +97,7 @@ module.exports = class WebGLKernel extends KernelBase { } const hasIntegerDivisionBug = utils.hasIntegerDivisionAccuracyBug(); - if (this.fixIntegerDivisionAccuracy == null) { + if (this.fixIntegerDivisionAccuracy === null) { this.fixIntegerDivisionAccuracy = hasIntegerDivisionBug; } else if (this.fixIntegerDivisionAccuracy && !hasIntegerDivisionBug) { this.fixIntegerDivisionAccuracy = false; @@ -172,6 +173,7 @@ module.exports = class WebGLKernel extends KernelBase { build() { this.validateOptions(); + this.setupConstants(); this.setupParams(arguments); this.updateMaxTexSize(); const texSize = this.texSize; @@ -262,6 +264,17 @@ module.exports = class WebGLKernel extends KernelBase { gl.vertexAttribPointer(aTexCoordLoc, 2, gl.FLOAT, gl.FALSE, 0, texCoordOffset); gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer); + for (let p in this.constants) { + const value = this.constants[p] + const type = utils.getArgumentType(value); + if (type === 'Decimal' || type === 'Integer') { + continue; + } + gl.useProgram(this.program); + this._addConstant(this.constants[p], type, p); + this.constantsLength++; + } + if (!this.outputImmutable) { this._setupOutputTexture(); if ( @@ -437,7 +450,7 @@ module.exports = class WebGLKernel extends KernelBase { const gl = this._webGl; const texSize = this.texSize; const texture = this.outputTexture = this._webGl.createTexture(); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -467,7 +480,7 @@ module.exports = class WebGLKernel extends KernelBase { const texture = this._webGl.createTexture(); textures.push(texture); drawBuffersMap.push(gl.COLOR_ATTACHMENT0 + i + 1); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length + i); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length + i); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -705,7 +718,7 @@ module.exports = class WebGLKernel extends KernelBase { floatTextures: this.floatTextures, floatOutput: this.floatOutput }, dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -749,7 +762,7 @@ module.exports = class WebGLKernel extends KernelBase { floatTextures: this.floatTextures, floatOutput: this.floatOutput }, dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -757,6 +770,7 @@ module.exports = class WebGLKernel extends KernelBase { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); let length = size[0] * size[1]; + const { valuesFlat, bitRatio @@ -783,7 +797,7 @@ module.exports = class WebGLKernel extends KernelBase { const dim = [inputImage.width, inputImage.height, 1]; const size = [inputImage.width, inputImage.height]; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -812,7 +826,7 @@ module.exports = class WebGLKernel extends KernelBase { const dim = inputTexture.dimensions; const size = inputTexture.size; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); this.setUniform3iv(`user_${name}Dim`, dim); @@ -827,6 +841,154 @@ module.exports = class WebGLKernel extends KernelBase { this.argumentsLength++; } + /** + * @memberOf WebGLKernel# + * @function + * @name _addConstant + * + * @desc Adds kernel parameters to the Argument Texture, + * binding it to the webGl instance, etc. + * + * @param {Array|Texture|Number} value - The actual argument supplied to the kernel + * @param {String} type - Type of the argument + * @param {String} name - Name of the argument + * + */ + _addConstant(value, type, name) { + const gl = this._webGl; + const argumentTexture = this.getArgumentTexture(name); + if (value instanceof Texture) { + type = 'Texture'; + } + switch (type) { + case 'Array': + { + const dim = utils.getDimensions(value, true); + const size = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, dim); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + let length = size[0] * size[1]; + + const { + valuesFlat, + bitRatio + } = this._formatArrayTransfer(value, length); + + let buffer; + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); + } else { + buffer = new Uint8Array(valuesFlat.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + } + + if (!this.hardcodeConstants) { + this.setUniform3iv(`constants_${name}Dim`, dim); + this.setUniform2iv(`constants_${name}Size`, size); + } + this.setUniform1i(`constants_${name}BitRatio`, bitRatio); + this.setUniform1i(`constants_${name}`, this.constantsLength); + break; + } + case 'Integer': + case 'Float': + { + this.setUniform1f(`constants_${name}`, value); + break; + } + case 'Input': + { + const input = value; + const dim = input.size; + const size = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, dim); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + let length = size[0] * size[1]; + const { + valuesFlat, + bitRatio + } = this._formatArrayTransfer(value.value, length); + + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.FLOAT, inputArray); + } else { + const buffer = new Uint8Array(valuesFlat.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + } + + if (!this.hardcodeConstants) { + this.setUniform3iv(`constants_${name}Dim`, dim); + this.setUniform2iv(`constants_${name}Size`, size); + } + this.setUniform1i(`constants_${name}BitRatio`, bitRatio); + this.setUniform1i(`constants_${name}`, this.constantsLength); + break; + } + case 'HTMLImage': + { + const inputImage = value; + const dim = [inputImage.width, inputImage.height, 1]; + const size = [inputImage.width, inputImage.height]; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + // Upload the image into the texture. + const mipLevel = 0; // the largest mip + const internalFormat = gl.RGBA; // format we want in the texture + const srcFormat = gl.RGBA; // format of data we are supplying + const srcType = gl.UNSIGNED_BYTE; // type of data we are supplying + gl.texImage2D(gl.TEXTURE_2D, + mipLevel, + internalFormat, + srcFormat, + srcType, + inputImage); + this.setUniform3iv(`constants_${name}Dim`, dim); + this.setUniform2iv(`constants_${name}Size`, size); + this.setUniform1i(`constants_${name}`, this.constantsLength); + break; + } + case 'Texture': + { + const inputTexture = value; + const dim = inputTexture.dimensions; + const size = inputTexture.size; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); + + this.setUniform3iv(`constants_${name}Dim`, dim); + this.setUniform2iv(`constants_${name}Size`, size); + this.setUniform1i(`constants_${name}BitRatio`, 1); // aways float32 + this.setUniform1i(`constants_${name}`, this.constantsLength); + break; + } + default: + throw new Error('Input type not supported (WebGL): ' + value); + } + } + /** * @memberOf WebGLKernel# * @function @@ -1146,6 +1308,8 @@ module.exports = class WebGLKernel extends KernelBase { return this._linesToString(result); } + + /** * @memberOf WebGLKernel# * @function @@ -1166,6 +1330,17 @@ module.exports = class WebGLKernel extends KernelBase { case 'Float': result.push('const float constants_' + name + ' = ' + parseFloat(value)); break; + case 'Array': + case 'Input': + case 'HTMLImage': + case 'Texture': + result.push( + `uniform sampler2D constants_${ name }`, + `uniform ivec2 constants_${ name }Size`, + `uniform ivec3 constants_${ name }Dim`, + `uniform int constants_${ name }BitRatio` + ); + break; default: throw new Error(`Unsupported constant ${ name } type ${ type }`); } @@ -1327,6 +1502,7 @@ module.exports = class WebGLKernel extends KernelBase { loopMaxIterations: this.loopMaxIterations, paramNames: this.paramNames, paramTypes: this.paramTypes, + constantTypes: this.constantTypes, fixIntegerDivisionAccuracy: this.fixIntegerDivisionAccuracy }); diff --git a/src/backend/web-gl2/kernel-string.js b/src/backend/web-gl2/kernel-string.js index fe0f7803..3143e668 100644 --- a/src/backend/web-gl2/kernel-string.js +++ b/src/backend/web-gl2/kernel-string.js @@ -65,10 +65,12 @@ module.exports = function(gpuKernel, name) { ${ removeFnNoise(gpuKernel._getVertShaderString.toString()) } validateOptions() {} setupParams() {} + setupConstants() {} setCanvas(canvas) { this._canvas = canvas; return this; } setWebGl(webGl) { this._webGl = webGl; return this; } ${ removeFnNoise(gpuKernel.getUniformLocation.toString()) } ${ removeFnNoise(gpuKernel.setupParams.toString()) } + ${ removeFnNoise(gpuKernel.setupConstants.toString()) } ${ removeFnNoise(gpuKernel.build.toString()) } ${ removeFnNoise(gpuKernel.run.toString()) } ${ removeFnNoise(gpuKernel._addArgument.toString()) } diff --git a/src/backend/web-gl2/kernel.js b/src/backend/web-gl2/kernel.js index 9c4f9974..34956aa2 100644 --- a/src/backend/web-gl2/kernel.js +++ b/src/backend/web-gl2/kernel.js @@ -36,7 +36,7 @@ module.exports = class WebGL2Kernel extends WebGLKernel { } const hasIntegerDivisionBug = utils.hasIntegerDivisionAccuracyBug(); - if (this.fixIntegerDivisionAccuracy == null) { + if (this.fixIntegerDivisionAccuracy === null) { this.fixIntegerDivisionAccuracy = hasIntegerDivisionBug; } else if (this.fixIntegerDivisionAccuracy && !hasIntegerDivisionBug) { this.fixIntegerDivisionAccuracy = false; @@ -197,7 +197,7 @@ module.exports = class WebGL2Kernel extends WebGLKernel { const gl = this._webGl; const texSize = this.texSize; const texture = this.outputTexture = this._webGl.createTexture(); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -227,7 +227,7 @@ module.exports = class WebGL2Kernel extends WebGLKernel { const texture = this._webGl.createTexture(); textures.push(texture); drawBuffersMap.push(gl.COLOR_ATTACHMENT0 + i + 1); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length + i); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.paramNames.length + i); gl.bindTexture(gl.TEXTURE_2D, texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -270,7 +270,7 @@ module.exports = class WebGL2Kernel extends WebGLKernel { floatTextures: this.floatTextures, floatOutput: this.floatOutput }, dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -314,7 +314,7 @@ module.exports = class WebGL2Kernel extends WebGLKernel { floatTextures: this.floatTextures, floatOutput: this.floatOutput }, dim); - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -348,7 +348,7 @@ module.exports = class WebGL2Kernel extends WebGLKernel { const dim = [inputImage.width, inputImage.height, 1]; const size = [inputImage.width, inputImage.height]; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, argumentTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); @@ -377,7 +377,7 @@ module.exports = class WebGL2Kernel extends WebGLKernel { const dim = [inputImages[0].width, inputImages[0].height, inputImages.length]; const size = [inputImages[0].width, inputImages[0].height]; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D_ARRAY, argumentTexture); gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MAG_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MIN_FILTER, gl.NEAREST); @@ -432,7 +432,7 @@ module.exports = class WebGL2Kernel extends WebGLKernel { const dim = inputTexture.dimensions; const size = inputTexture.size; - gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); this.setUniform3iv(`user_${name}Dim`, dim); @@ -447,6 +447,257 @@ module.exports = class WebGL2Kernel extends WebGLKernel { this.argumentsLength++; } + /** + * @memberOf WebGLKernel# + * @function + * @name _getMainConstantsString + * + */ + _getMainConstantsString() { + const result = []; + if (this.constants) { + for (let name in this.constants) { + if (!this.constants.hasOwnProperty(name)) continue; + let value = this.constants[name]; + let type = utils.getArgumentType(value); + switch (type) { + case 'Integer': + result.push('const float constants_' + name + ' = ' + parseInt(value) + '.0'); + break; + case 'Float': + result.push('const float constants_' + name + ' = ' + parseFloat(value)); + break; + case 'Array': + case 'Input': + case 'HTMLImage': + case 'Texture': + result.push( + `uniform highp sampler2D constants_${ name }`, + `uniform highp ivec2 constants_${ name }Size`, + `uniform highp ivec3 constants_${ name }Dim`, + `uniform highp int constants_${ name }BitRatio` + ); + break; + case 'HTMLImageArray': + result.push( + `uniform highp sampler2DArray constants_${ name }`, + `uniform highp ivec2 constants_${ name }Size`, + `uniform highp ivec3 constants_${ name }Dim`, + `uniform highp int constants_${ name }BitRatio` + ); + break; + + default: + throw new Error(`Unsupported constant ${ name } type ${ type }`); + } + } + } + return this._linesToString(result); + } + + /** + * @memberOf WebGLKernel# + * @function + * @name _addConstant + * + * @desc Adds kernel parameters to the Argument Texture, + * binding it to the webGl instance, etc. + * + * @param {Array|Texture|Number} value - The actual argument supplied to the kernel + * @param {String} type - Type of the argument + * @param {String} name - Name of the argument + * + */ + _addConstant(value, type, name) { + const gl = this._webGl; + const argumentTexture = this.getArgumentTexture(name); + if (value instanceof Texture) { + type = 'Texture'; + } + switch (type) { + case 'Array': + { + const dim = utils.getDimensions(value, true); + const size = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, dim); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + let length = size[0] * size[1]; + + const { + valuesFlat, + bitRatio + } = this._formatArrayTransfer(value, length); + + let buffer; + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); + } else { + buffer = new Uint8Array(valuesFlat.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + } + + if (!this.hardcodeConstants) { + this.setUniform3iv(`constants_${name}Dim`, dim); + this.setUniform2iv(`constants_${name}Size`, size); + } + this.setUniform1i(`constants_${name}BitRatio`, bitRatio); + this.setUniform1i(`constants_${name}`, this.constantsLength); + break; + } + case 'Integer': + case 'Float': + { + this.setUniform1f(`constants_${name}`, value); + break; + } + case 'Input': + { + const input = value; + const dim = input.size; + const size = utils.dimToTexSize({ + floatTextures: this.floatTextures, + floatOutput: this.floatOutput + }, dim); + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + let length = size[0] * size[1]; + const { + valuesFlat, + bitRatio + } = this._formatArrayTransfer(value.value, length); + + if (this.floatTextures) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, size[0], size[1], 0, gl.RGBA, gl.FLOAT, inputArray); + } else { + const buffer = new Uint8Array(valuesFlat.buffer); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0] / bitRatio, size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); + } + + if (!this.hardcodeConstants) { + this.setUniform3iv(`constants_${name}Dim`, dim); + this.setUniform2iv(`constants_${name}Size`, size); + } + this.setUniform1i(`constants_${name}BitRatio`, bitRatio); + this.setUniform1i(`constants_${name}`, this.constantsLength); + break; + } + case 'HTMLImage': + { + const inputImage = value; + const dim = [inputImage.width, inputImage.height, 1]; + const size = [inputImage.width, inputImage.height]; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + // Upload the image into the texture. + const mipLevel = 0; // the largest mip + const internalFormat = gl.RGBA; // format we want in the texture + const srcFormat = gl.RGBA; // format of data we are supplying + const srcType = gl.UNSIGNED_BYTE; // type of data we are supplying + gl.texImage2D(gl.TEXTURE_2D, + mipLevel, + internalFormat, + srcFormat, + srcType, + inputImage); + this.setUniform3iv(`constants_${name}Dim`, dim); + this.setUniform2iv(`constants_${name}Size`, size); + this.setUniform1i(`constants_${name}`, this.constantsLength); + break; + } + case 'HTMLImageArray': + { + const inputImages = value; + const dim = [inputImages[0].width, inputImages[0].height, inputImages.length]; + const size = [inputImages[0].width, inputImages[0].height]; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D_ARRAY, argumentTexture); + gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + // Upload the images into the texture. + const mipLevel = 0; // the largest mip + const internalFormat = gl.RGBA; // format we want in the texture + const width = inputImages[0].width; + const height = inputImages[0].height; + const textureDepth = inputImages.length; + const border = 0; + const srcFormat = gl.RGBA; // format of data we are supplying + const srcType = gl.UNSIGNED_BYTE; // type of data we are supplying + gl.texImage3D( + gl.TEXTURE_2D_ARRAY, + mipLevel, + internalFormat, + width, + height, + textureDepth, + border, + srcFormat, + srcType, + null + ); + for (let i = 0; i < inputImages.length; i++) { + const xOffset = 0; + const yOffset = 0; + const imageDepth = 1; + gl.texSubImage3D( + gl.TEXTURE_2D_ARRAY, + mipLevel, + xOffset, + yOffset, + i, + inputImages[i].width, + inputImages[i].height, + imageDepth, + srcFormat, + srcType, + inputImages[i] + ); + } + this.setUniform3iv(`constants_${name}Dim`, dim); + this.setUniform2iv(`constants_${name}Size`, size); + this.setUniform1i(`constants_${name}`, this.constantsLength); + break; + } + case 'Texture': + { + const inputTexture = value; + const dim = inputTexture.dimensions; + const size = inputTexture.size; + + gl.activeTexture(gl.TEXTURE0 + this.constantsLength); + gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); + + this.setUniform3iv(`constants_${name}Dim`, dim); + this.setUniform2iv(`constants_${name}Size`, size); + this.setUniform1i(`constants_${name}BitRatio`, 1); // aways float32 + this.setUniform1i(`constants_${name}`, this.constantsLength); + break; + } + default: + throw new Error('Input type not supported (WebGL): ' + value); + } + } + /** * @memberOf WebGL2Kernel# * @function @@ -681,6 +932,7 @@ module.exports = class WebGL2Kernel extends WebGLKernel { loopMaxIterations: this.loopMaxIterations, paramNames: this.paramNames, paramTypes: this.paramTypes, + constantTypes: this.constantTypes, fixIntegerDivisionAccuracy: this.fixIntegerDivisionAccuracy }); diff --git a/src/index.js b/src/index.js index 5d6dcc6b..e06a0566 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ 'use strict'; +console.log("Testing") const GPU = require('./core/gpu'); const alias = require('./core/alias'); const utils = require('./core/utils'); diff --git a/test/all.html b/test/all.html index 471a1d3d..9cfdfb5a 100644 --- a/test/all.html +++ b/test/all.html @@ -19,8 +19,15 @@ + + + + + + + @@ -34,7 +41,6 @@ - diff --git a/test/features/constants-array.js b/test/features/constants-array.js new file mode 100644 index 00000000..7e44aacf --- /dev/null +++ b/test/features/constants-array.js @@ -0,0 +1,44 @@ +(function() { + function arrayConstantTest(mode) { + var gpu = new GPU({ mode: mode }); + var array = [200, 200]; + var tryConst = gpu.createKernel( + function() { + return this.constants.array[this.thread.x]; + }, + { + constants: { array } + } + ).setOutput([2]); + var result = tryConst(); + var match = new Float32Array([200, 200]); + var test = (result[0] === match[0] && result[1] === match[1]); + QUnit.assert.ok(test, 'array constant passed test'); + tryConst.destroy(); + } + + QUnit.test( 'arrayConstantTest (auto)', function(assert) { + var mode = null; + arrayConstantTest(mode); + }); + + QUnit.test( 'arrayConstantTest (gpu)', function(assert) { + var mode = 'gpu'; + arrayConstantTest(mode); + }); + + QUnit.test( 'arrayConstantTest (webgl)', function(assert) { + var mode = 'webgl'; + arrayConstantTest(mode); + }); + + QUnit.test( 'arrayConstantTest (webgl2)', function(assert) { + var mode = 'webgl2'; + arrayConstantTest(mode); + }); + + QUnit.test( 'arrayConstantTest (cpu)', function(assert) { + var mode = 'cpu'; + arrayConstantTest(mode); + }); +})(); diff --git a/test/features/constants-float.js b/test/features/constants-float.js new file mode 100644 index 00000000..dbcaf810 --- /dev/null +++ b/test/features/constants-float.js @@ -0,0 +1,47 @@ +(function() { + function floatConstantTest(mode) { + var gpu = new GPU({ mode: mode }); + var float = 200.01; + var tryConst = gpu.createKernel( + function() { + return this.constants.float; + }, + { + constants: { float } + } + ).setOutput([2]); + var result = tryConst(); + var match = new Float32Array([200.01, 200.01]); + var test = ( + result[0].toFixed(1) === match[0].toFixed(1) + && result[1].toFixed(1) === match[1].toFixed(1) + ); + QUnit.assert.ok(test, 'float constant passed test'); + tryConst.destroy(); + } + + QUnit.test( 'floatConstantTest (auto)', function(assert) { + var mode = null; + floatConstantTest(mode); + }); + + QUnit.test( 'floatConstantTest (gpu)', function(assert) { + var mode = 'gpu'; + floatConstantTest(mode); + }); + + QUnit.test( 'floatConstantTest (webgl)', function(assert) { + var mode = 'webgl'; + floatConstantTest(mode); + }); + + QUnit.test( 'floatConstantTest (webgl2)', function(assert) { + var mode = 'webgl2'; + floatConstantTest(mode); + }); + + QUnit.test( 'floatConstantTest (cpu)', function(assert) { + var mode = 'cpu'; + floatConstantTest(mode); + }); +})(); diff --git a/test/features/constants-image-array.js b/test/features/constants-image-array.js new file mode 100644 index 00000000..b00106f6 --- /dev/null +++ b/test/features/constants-image-array.js @@ -0,0 +1,95 @@ +(function() { + function imageArrayConstantFixture(mode, assert, cb) { + console.log('Testing image array constant:'); + var done = assert.async(); + var gpu = new GPU({ mode: mode }); + var image = new Image(); + var imageArray = []; + image.src = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCABbAIoDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDtjB/vL/wHP8qUBk//AGv8anjEr/7L/wC1z/hUhib+Lb/wHj+dfQOfc893WjK/+8u3/a6f5/OkU7Plb7nZun4Yqx5TJ93/ANB/w4pvkb/67cH8xS5kNW6htpCtRm2b7yv9duf1BNO2/wB75f8AaXj+dO4uVdGBWkI2UpXZ/Ezf72Qf/r1KsS/eXbRzE7Fb/d3Uv/AW/n/KrOyneXRzCKqbX+X/AMd6H8quww76jMKv97/P0qxC2z5W/BvX/wCvWc5aaAONtUDxbKtvLUON9RFvqBGq1JipAlCKzPuocihM06nrFsepNiVDkgKRs4n/AINv+7x/KmeTKn/LVvbdhh/iPzq3HJ/C303difT2PtU+2jna3HzSW5n/AL9PvKrf7uRSM8T/AOsiZf8Aa6/qKumHZ/q/l/2e3/1qbtV/9l/896OdBzLsVBEr/wCrfd/P86Ywli+8m5P5/wBKtPaL97b/AOyn8xTNsqfxbv8AZk4P5iq5gKwVX+aP7v8Ad/wBpEj2fd+51G3t6jB6VK6qn96Dd9Cuf5VG4/iWXa/5girTCxIP++v93r+VPUK/3agllaL5ZEX/AHucfgR0/HFSfvfvSbV9JFbj8Tjp+GKTDke5NspfL/haoVafzPmTcvZl53epA46VaRt393/DPTI7VDdhONiHbs+99z+96fX/ABqZVqbb/eqJJET5V3MvT2B9MmpcriJVjp0UVBbZHuZ4ok/vNz/hUIv7T7v21V/4DgfqKj3nsVYsiOneXTVli8vct1Gyd23KQPyxVT+29MHB1C0z/vCpipS2RSpyeyuUfKn/AIrhW/2vN4+hAUfrSJcT277ZNzJ2aPLAe3DVvgU14ll+WRVb/eXNae27o1VZdUY6ao3/ADyZk6D5GyfXHAx3/KnNqcb/AHopFbt0q81rsj2wttX/AJ5su5fy6j8KhO6L70W3/aVuD+fT86FKD2QOVJ7Rt8yuupx/db7/AF+6w/QrUy3cD/xr/wB9L/LOaZJEv3vs7f8AfJX9QSDVbyf+mUsUq9GVcj+fT2xVpRaIcab2v+BZNxbfd81f93qPyqu/2R/vSqqdmVuP/rfhT992ke1oo2/LP5cGkjWN/mkRWf8A2sqB+GMU1pqCiluQW9xI++NWgliVsDc4BYeuP0/ClS4+zx7Wib5ePlbr+Jx+tPDRyu/z7Zdxxtw2AMDucY46U77b5Ue5pYv9tVz26jB/pVPXoW4puyiPivYn/dq67P7sjBSPT6j3p8vyfeZV7/T15/z+fXOn1LTZZ/IbazbciaFOPx/qKqSXdy8nl2Hn/d5ZWyOuON3GKaotvt6m0MJKT2t67fedLDJE3zM3zc/MzZzjuO1NnuILe3/eN8zNkKq5ZmJyAB3Oa5wJ4it/lWJvK7fKGwPfr/Wov7H1O7f7RLcbZW6qzFcD0yP8MUfV4p+9JWN44CnH3qtVW8tWyxqOptLOvmI3m9Et1+bae+e2ahSy1K4/1zrAjdFVQT/WtLSxY6Z/q5W+0N/E0YbJ7gEdunetq2n1C4j+7Ay/7WVP5ZNVKt7NWgtPMU50qWlKK9WvyT0XzuctZ6TbS3yW0zK0rZKSN82SOcY7cZP4Vq/8I1EON1vx/sf/AF6uXtg1xG3k/u72P50WT2PUH/PXnFU18QQKoEthfrIBhgucA98VDr1Z6wZzTq1amrkzeFLSZozXCcgU1qUmmk1SEQtAv/LNmj/3en5VBI86fet/N/2o8fqDVyirT7jUrbq5nm+g8v8AiXsVkXp6+1RM8cv+p2+zbsEfQdPxP5GrV3brcSRfdV1yQ20Hkdv1P5Uxo28zbG8ay/7K8D684P061onG2hsvZ2utyv5WyPy47hW7/vMce+fWiJInkaHarfxbmYnr1AHIJzzn3qd1kf8Ac/uvvAlmXIb/AOv7fSnppkH3m+ZmxnaoUce3+etHOurHzJLViT2FpcQeXPZfJ1+7nB+oOazDoMtvJ5lle/PtIEMnAxnIHP5fia1xYKnzR7v93eRT/Lb7q3Esbf3ZMOp/E/40o1ZR0i9P69S6eInBcqlp2ev+ZXtNQlidYbuLypePl3AZPsc/596qXl0t7fPpUCSLt5uWXB2L1wMHnPcf1q9cRK8Hk3turRd/Qe4J+6fyrGutMl0+f7bDcSz2rYjkXzCrBeylhzjOBVU1Byvs+na5rh40nJuTs7adrmgkuiW/7mPy1+bDxqpYkHvjB74psWtLFO26KSW328MyZdPw5LD9frVhYrN7RGWw2pt3Iy4baRzkHr9akNnBLI+37/de49x6/wA/rUc0Nea7MZNdE/mWSIru0intLhZEZhsZW3D069vQj3NaCSRuit5mMgHBcAj8O1chPb32j3bzWn325kj/AIJhjrjs3vV3+3NGk+eS3cSNyw9+9TPDSaThqvIajfWJqbqN1V91Lupcpxk2+mFqZmkJppAPzS7qizRmnYRIdr/K1AC+XtX5VqPNKDRYdxQv7xFX+4fvc9SP8DTsyp/DuT9R9PWmj/WbvoPyz/jUgNJjuPR9/wAy0/G/71Q7f4l+V/5/WpFl/hb5W/Q/Q1D8hj1h2f6v/vlun/1qrta7N7W/7p2Uh7duEf6H+E+4/EVcBp/3/lao5mjSLsc9pVxPdR3vk/K0bMGsmwAO3GehOCeuOfrWnDLFcbJFVliZTjdwUx1Xg5GPQ+/pWbqGns2oytC7xy7VeOTqVIHIyTypGePUdQcUmm3Uj3UsckTLKu57iPkkdBuHqcncD1IK9xW00pJzidkoKcXKHT8P815/f3NO5gk8t9v71dvCt1UnsD3z1H/165d7iNXZcKMHGGBz+NdbA2/zVb+HCv8ATkg/1+lYE5fz5N1pEzbjklevNVh52umRSV2y+Gpd1QrThWnKeeS5pM0ykNTYCTdSbqjpafKBJmlBqOlFKwEwNOBqEVIKmwEympAN/wArVCtSCs2UhwLRf7UX5lf8RVlTUK0ltwJVHRTwPTgGoaNER3yr5luzfKrN5b+2eVP/AH0B+dZ0nlJrtr527zZEeEMvthlP5bgfcVpX6hrJlIyPMTj/AIEKxNTZm1OzBJI+XjPq65rSlHm09TqoPX1Vvv2/EtCT+ytZSOT5re4XyQ3XZjkZz2+bH+cVbksJGldlkwCxIFV9SUSW8e4Z4iP6mr8Mj+TH87fdHf2pSm4pS6m0G9Gt+p//2Q=='; + image.onload = function() { + imageArray.push(image); + imageArray.push(image); + var width = image.width; + var height = image.height; + var tryConst = gpu.createKernel( + function() { + var pixel1 = this.constants.imageArray[0][this.thread.y][this.thread.x]; + var pixel2 = this.constants.imageArray[1][this.thread.y][this.thread.x]; + var color = 0; + if (this.thread.z === 0) { + color = (pixel1.r + pixel2.r) / 2; + } + if (this.thread.z === 1) { + color = (pixel1.g + pixel2.g) / 2; + } + if (this.thread.z === 2) { + color = (pixel1.b + pixel2.b) / 2; + } + if (this.thread.z === 3) { + color = 1; + } + return Math.floor(255 * color); + }, + { + constants: { imageArray } + } + ).setOutput([width, height, 4]); + cb(tryConst); + tryConst.destroy(); + done(); + } + } + + QUnit.test( 'imageArrayConstantTest (auto)', function(assert) { + var mode = null; + imageArrayConstantFixture(mode, assert, function(tryConst) { + var result = tryConst(); + var test = result[0][0][0] > 0; + console.log('Result: ', result); + console.log('Test: ', test); + assert.ok(test, 'image array constant passed test'); + }); + }); + + QUnit.test( 'imageArrayConstantTest (gpu)', function(assert) { + var mode = 'gpu'; + imageArrayConstantFixture(mode, assert, function(tryConst) { + var result = tryConst(); + var test = result[0][0][0] > 0; + console.log('Result: ', result); + console.log('Test: ', test); + assert.ok(test, 'image array constant passed test'); + }); + }); + + QUnit.test( 'imageArrayConstantTest (webgl)', function(assert) { + var mode = 'webgl'; + imageArrayConstantFixture(mode, assert, function(tryConst) { + assert.throws(function() { + tryConst(); + }, 'imageArray are not compatible with webgl'); + }); + }); + + QUnit.test( 'imageArrayConstantTest (webgl2)', function(assert) { + var mode = 'webgl2'; + imageArrayConstantFixture(mode, assert, function(tryConst) { + var result = tryConst(); + var test = result[0][0][0] > 0; + console.log('Result: ', result); + console.log('Test: ', test); + assert.ok(test, 'image array constant passed test'); + }); + }); + + QUnit.test( 'imageArrayConstantTest (cpu)', function(assert) { + var mode = 'cpu'; + imageArrayConstantFixture(mode, assert, function(tryConst) { + var result = tryConst(); + var test = result[0][0][0] > 0; + console.log('Result: ', result); + console.log('Test: ', test); + assert.ok(test, 'image array constant passed test'); + }); + }); +})(); diff --git a/test/features/constants-image.js b/test/features/constants-image.js new file mode 100644 index 00000000..77b6a724 --- /dev/null +++ b/test/features/constants-image.js @@ -0,0 +1,64 @@ +(function() { + function imageConstantTest(mode, assert) { + console.log('Testing image constant:'); + var done = assert.async(); + var gpu = new GPU({ mode: mode }); + var image = new Image(); + image.src = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCABbAIoDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDtjB/vL/wHP8qUBk//AGv8anjEr/7L/wC1z/hUhib+Lb/wHj+dfQOfc893WjK/+8u3/a6f5/OkU7Plb7nZun4Yqx5TJ93/ANB/w4pvkb/67cH8xS5kNW6htpCtRm2b7yv9duf1BNO2/wB75f8AaXj+dO4uVdGBWkI2UpXZ/Ezf72Qf/r1KsS/eXbRzE7Fb/d3Uv/AW/n/KrOyneXRzCKqbX+X/AMd6H8quww76jMKv97/P0qxC2z5W/BvX/wCvWc5aaAONtUDxbKtvLUON9RFvqBGq1JipAlCKzPuocihM06nrFsepNiVDkgKRs4n/AINv+7x/KmeTKn/LVvbdhh/iPzq3HJ/C303difT2PtU+2jna3HzSW5n/AL9PvKrf7uRSM8T/AOsiZf8Aa6/qKumHZ/q/l/2e3/1qbtV/9l/896OdBzLsVBEr/wCrfd/P86Ywli+8m5P5/wBKtPaL97b/AOyn8xTNsqfxbv8AZk4P5iq5gKwVX+aP7v8Ad/wBpEj2fd+51G3t6jB6VK6qn96Dd9Cuf5VG4/iWXa/5girTCxIP++v93r+VPUK/3agllaL5ZEX/AHucfgR0/HFSfvfvSbV9JFbj8Tjp+GKTDke5NspfL/haoVafzPmTcvZl53epA46VaRt393/DPTI7VDdhONiHbs+99z+96fX/ABqZVqbb/eqJJET5V3MvT2B9MmpcriJVjp0UVBbZHuZ4ok/vNz/hUIv7T7v21V/4DgfqKj3nsVYsiOneXTVli8vct1Gyd23KQPyxVT+29MHB1C0z/vCpipS2RSpyeyuUfKn/AIrhW/2vN4+hAUfrSJcT277ZNzJ2aPLAe3DVvgU14ll+WRVb/eXNae27o1VZdUY6ao3/ADyZk6D5GyfXHAx3/KnNqcb/AHopFbt0q81rsj2wttX/AJ5su5fy6j8KhO6L70W3/aVuD+fT86FKD2QOVJ7Rt8yuupx/db7/AF+6w/QrUy3cD/xr/wB9L/LOaZJEv3vs7f8AfJX9QSDVbyf+mUsUq9GVcj+fT2xVpRaIcab2v+BZNxbfd81f93qPyqu/2R/vSqqdmVuP/rfhT992ke1oo2/LP5cGkjWN/mkRWf8A2sqB+GMU1pqCiluQW9xI++NWgliVsDc4BYeuP0/ClS4+zx7Wib5ePlbr+Jx+tPDRyu/z7Zdxxtw2AMDucY46U77b5Ue5pYv9tVz26jB/pVPXoW4puyiPivYn/dq67P7sjBSPT6j3p8vyfeZV7/T15/z+fXOn1LTZZ/IbazbciaFOPx/qKqSXdy8nl2Hn/d5ZWyOuON3GKaotvt6m0MJKT2t67fedLDJE3zM3zc/MzZzjuO1NnuILe3/eN8zNkKq5ZmJyAB3Oa5wJ4it/lWJvK7fKGwPfr/Wov7H1O7f7RLcbZW6qzFcD0yP8MUfV4p+9JWN44CnH3qtVW8tWyxqOptLOvmI3m9Et1+bae+e2ahSy1K4/1zrAjdFVQT/WtLSxY6Z/q5W+0N/E0YbJ7gEdunetq2n1C4j+7Ay/7WVP5ZNVKt7NWgtPMU50qWlKK9WvyT0XzuctZ6TbS3yW0zK0rZKSN82SOcY7cZP4Vq/8I1EON1vx/sf/AF6uXtg1xG3k/u72P50WT2PUH/PXnFU18QQKoEthfrIBhgucA98VDr1Z6wZzTq1amrkzeFLSZozXCcgU1qUmmk1SEQtAv/LNmj/3en5VBI86fet/N/2o8fqDVyirT7jUrbq5nm+g8v8AiXsVkXp6+1RM8cv+p2+zbsEfQdPxP5GrV3brcSRfdV1yQ20Hkdv1P5Uxo28zbG8ay/7K8D684P061onG2hsvZ2utyv5WyPy47hW7/vMce+fWiJInkaHarfxbmYnr1AHIJzzn3qd1kf8Ac/uvvAlmXIb/AOv7fSnppkH3m+ZmxnaoUce3+etHOurHzJLViT2FpcQeXPZfJ1+7nB+oOazDoMtvJ5lle/PtIEMnAxnIHP5fia1xYKnzR7v93eRT/Lb7q3Esbf3ZMOp/E/40o1ZR0i9P69S6eInBcqlp2ev+ZXtNQlidYbuLypePl3AZPsc/596qXl0t7fPpUCSLt5uWXB2L1wMHnPcf1q9cRK8Hk3turRd/Qe4J+6fyrGutMl0+f7bDcSz2rYjkXzCrBeylhzjOBVU1Byvs+na5rh40nJuTs7adrmgkuiW/7mPy1+bDxqpYkHvjB74psWtLFO26KSW328MyZdPw5LD9frVhYrN7RGWw2pt3Iy4baRzkHr9akNnBLI+37/de49x6/wA/rUc0Nea7MZNdE/mWSIru0intLhZEZhsZW3D069vQj3NaCSRuit5mMgHBcAj8O1chPb32j3bzWn325kj/AIJhjrjs3vV3+3NGk+eS3cSNyw9+9TPDSaThqvIajfWJqbqN1V91Lupcpxk2+mFqZmkJppAPzS7qizRmnYRIdr/K1AC+XtX5VqPNKDRYdxQv7xFX+4fvc9SP8DTsyp/DuT9R9PWmj/WbvoPyz/jUgNJjuPR9/wAy0/G/71Q7f4l+V/5/WpFl/hb5W/Q/Q1D8hj1h2f6v/vlun/1qrta7N7W/7p2Uh7duEf6H+E+4/EVcBp/3/lao5mjSLsc9pVxPdR3vk/K0bMGsmwAO3GehOCeuOfrWnDLFcbJFVliZTjdwUx1Xg5GPQ+/pWbqGns2oytC7xy7VeOTqVIHIyTypGePUdQcUmm3Uj3UsckTLKu57iPkkdBuHqcncD1IK9xW00pJzidkoKcXKHT8P815/f3NO5gk8t9v71dvCt1UnsD3z1H/165d7iNXZcKMHGGBz+NdbA2/zVb+HCv8ATkg/1+lYE5fz5N1pEzbjklevNVh52umRSV2y+Gpd1QrThWnKeeS5pM0ykNTYCTdSbqjpafKBJmlBqOlFKwEwNOBqEVIKmwEympAN/wArVCtSCs2UhwLRf7UX5lf8RVlTUK0ltwJVHRTwPTgGoaNER3yr5luzfKrN5b+2eVP/AH0B+dZ0nlJrtr527zZEeEMvthlP5bgfcVpX6hrJlIyPMTj/AIEKxNTZm1OzBJI+XjPq65rSlHm09TqoPX1Vvv2/EtCT+ytZSOT5re4XyQ3XZjkZz2+bH+cVbksJGldlkwCxIFV9SUSW8e4Z4iP6mr8Mj+TH87fdHf2pSm4pS6m0G9Gt+p//2Q=='; + image.onload = function() { + var width = image.width; + var height = image.height; + var tryConst = gpu.createKernel( + function() { + var pixel = this.constants.image[this.thread.y][this.thread.x]; + var color = 0; + if (this.thread.z === 0) { + color = pixel.r; + } + if (this.thread.z === 1) { + color = pixel.g; + } + if (this.thread.z === 2) { + color = pixel.b; + } + return 255 * color; + }, + { + constants: { image } + } + ).setOutput([width, height, 3]); + var result = tryConst(); + var test = result[0][0][0] > 0; + console.log('Result: ', result); + console.log('Test: ', test); + QUnit.assert.ok(test, 'image constant passed test'); + tryConst.destroy(); + done(); + } + } + + QUnit.test( 'imageConstantTest (auto)', function(assert) { + var mode = null; + imageConstantTest(mode, assert); + }); + + QUnit.test( 'imageConstantTest (gpu)', function(assert) { + var mode = 'gpu'; + imageConstantTest(mode, assert); + }); + + QUnit.test( 'imageConstantTest (webgl)', function(assert) { + var mode = 'webgl'; + imageConstantTest(mode, assert); + }); + + QUnit.test( 'imageConstantTest (webgl2)', function(assert) { + var mode = 'webgl2'; + imageConstantTest(mode, assert); + }); + + QUnit.test( 'imageConstantTest (cpu)', function(assert) { + var mode = 'cpu'; + imageConstantTest(mode, assert); + }); +})(); diff --git a/test/features/constants-integer.js b/test/features/constants-integer.js new file mode 100644 index 00000000..681ece75 --- /dev/null +++ b/test/features/constants-integer.js @@ -0,0 +1,44 @@ +(function() { + function integerConstantTest(mode) { + var gpu = new GPU({ mode: mode }); + var int = 200; + var tryConst = gpu.createKernel( + function() { + return this.constants.int; + }, + { + constants: { int } + } + ).setOutput([2]); + var result = tryConst(); + var match = new Float32Array([200, 200]); + var test = (result[0] === match[0] && result[1] === match[1]); + QUnit.assert.ok(test, 'int constant passed test'); + tryConst.destroy(); + } + + QUnit.test( 'integerConstantTest (auto)', function(assert) { + var mode = null; + integerConstantTest(mode); + }); + + QUnit.test( 'integerConstantTest (gpu)', function(assert) { + var mode = 'gpu'; + integerConstantTest(mode); + }); + + QUnit.test( 'integerConstantTest (webgl)', function(assert) { + var mode = 'webgl'; + integerConstantTest(mode); + }); + + QUnit.test( 'integerConstantTest (webgl2)', function(assert) { + var mode = 'webgl2'; + integerConstantTest(mode); + }); + + QUnit.test( 'integerConstantTest (cpu)', function(assert) { + var mode = 'cpu'; + integerConstantTest(mode); + }); +})(); diff --git a/test/features/constants-texture.js b/test/features/constants-texture.js new file mode 100644 index 00000000..936b6a2a --- /dev/null +++ b/test/features/constants-texture.js @@ -0,0 +1,50 @@ +(function() { + function textureConstantTest(mode) { + var gpu = new GPU({ mode: mode }); + var createTexture = gpu + .createKernel(function() { + return 200; + }) + .setOutput([2]) + .setOutputToTexture(true); + var texture = createTexture(); + var tryConst = gpu.createKernel( + function() { + return this.constants.texture[this.thread.x]; + }, + { + constants: { texture } + } + ).setOutput([2]); + var result = tryConst(); + var match = new Float32Array([200, 200]); + var test = (result[0] === match[0] && result[1] === match[1]); + QUnit.assert.ok(test, 'texture constant passed test'); + tryConst.destroy(); + } + + QUnit.test( 'textureConstantTest (auto)', function(assert) { + var mode = null; + textureConstantTest(mode); + }); + + QUnit.test( 'textureConstantTest (gpu)', function(assert) { + var mode = 'gpu'; + textureConstantTest(mode); + }); + + QUnit.test( 'textureConstantTest (webgl)', function(assert) { + var mode = 'webgl'; + textureConstantTest(mode); + }); + + QUnit.test( 'textureConstantTest (webgl2)', function(assert) { + var mode = 'webgl2'; + textureConstantTest(mode); + }); + + QUnit.test( 'textureConstantTest (cpu)', function(assert) { + var mode = 'cpu'; + textureConstantTest(mode); + }); +})(); diff --git a/test/features/image.js b/test/features/image.js index ee7ec5ee..851531b9 100644 --- a/test/features/image.js +++ b/test/features/image.js @@ -4,16 +4,16 @@ var gpu = new GPU({ mode: mode }); - var imageKernel = gpu.createKernel(function(image) { - const pixel = image[this.thread.y][this.thread.x]; - this.color(pixel[0], pixel[1], pixel[2], pixel[3]); - }, { - graphical: true, - output : [276, 183] - }); var image = document.createElement('img'); image.src = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxAQEhUPDxIVFRUVFRAPEBUVFRUPFRAVFRUWFhUVFRUYHSggGBolHRUVITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OFxAQGi0lHSUtLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0vLf/AABEIALcBFAMBEQACEQEDEQH/xAAbAAADAQEBAQEAAAAAAAAAAAABAgMABAUGB//EADgQAAIBAgMGBAQFAwUBAQAAAAECAAMREiExBBNBUWFxBSKBkTKhsdEGQsHh8FJikhQjM3LxwhX/xAAbAQEBAQEBAQEBAAAAAAAAAAABAAIDBAUGB//EADMRAAICAQIDBQgCAgIDAAAAAAABAhEDEiEEMUETUWFx8AUiMoGRobHB0eFS8RSSI0Jy/9oADAMBAAIRAxEAPwD7A0e49L/SfoNR4VIIBH/v3hsWw/cW66fz3gVdwFNsjpwOnpaXMXG9yuGZs5gKxshSsbABFo2Iva8hoPofr9JBQUscvlofaDJpo66NK85SlQFTs8xrEi9O02pWQVWTYlLTIjXgRWnMMh2EEwJkRIXDNWQSICKRGyEImiBaRCmJAiQZEYmVEa8KIN5EMIEM0EDFMQEiRzUwx6Hrn9p0bR0kkihpnjb0y+szqRnYG7I0+n2ylY7C7m/62sfcR1UKdEzs51B72v8ANSZrWa196Dh55dRl9ZX3Bt0CVtxJ73B/eVmH5FFpjUWmbM2w4JWQcELIxpA6/wA7SskXotbI+h5/vOclZFXqTKiRK15vkQ4SZsTIpJvJtCUWnYzLkQ+74iZ1EZ3tr37ySvkRgLi8roA4ZWIpWNkKRGyEZYpkIVmrIUiJAIiQLRI0gFtIgyEcGZAIMgAZAKZohjsqnhbtl9JnWzr2kuom6YfmPS9mH3HvHUn0HVF9PX4G841APa4h7rKoPkwM6n4lI66/MSp9GGl9DCmD8Jv9feV1zM3QjBl1Fx9f0jaZbMAUHNdOX2Bjb6lv1AiW001FuHMWOkW7IoPftr7TIUOoB0g2A2GFkHBwMLIGG2unPl3+8rEqqzLZFVSZbEalThKRDhJmyCRaVkeb4jtGWEfExVQLHLEbXvPThhvfRHSEbtndTAtYTg7OY2GBCkRshcMbAVljZCETREyJqyFIiQLSIFokC0iNaJAJkRsUqIBaVADFGiOym/A9r8CeXQ9Jwa7jTiWwzFmRDSt8OXTh+01q7xsXCD0P84ysib7MNbf/ACfcTamzWoXCw436Nkf8hG0y91knUDml+xW/0mk78Rr5iOOIax9wRFPvQKu41WoVyYDvnb0I09bSST5G4wUkP5tWsOTA5eptp6Wmduhmo9Aqz3zFxwIzxcyBlpB1RNROlGvy+19LjhMMzRXDzmbAmjgZC5GnQHlcxafUdNcyxawuSqjmc/tMVbpDRIbbS03oHpYfMTfZT/xGn3HQtRbXFRSOJupA9rTlUrqhroebtnj2zqLb1Dzwm59hPVj4TLLfSzquGy/4teexz7Dt1PaKq4AQAwIvYXCjvrc39BOmXFPFB6hnB44tM911zE8CZ5zERTIUiNgKViQpEbAmwmrIRhFELaaIBWVkLhjZAtEgESIUiNkC0QFMSBIg7t+Lg9ceXYgKPnM3Hu+39nu1Y3yjXy/tgSu6GzXI4FbsB0yaThGXL19h7OEuX32/RRPET/SSNB5Wuedshbj7TLwrvKXBpL4lfmv5YzeIKdVYHhpJYmuTOT4WSVpr6mXxBdDrrow+RWXZMy+GyJXW3mv5KrtKHiPdfpe8y4SRyljnHmhTXp6Yh21HtHTPuHRLuOd90dWAHAg5ft6Ta19xpRm3SVk9nrsbqCjKDYXYAsOdvl6TUornumdJ4VCm7T8gpXwCxU5ZZHX1NvnBwvkzPZansy9La1PlBFuTEIRy7jrMSxtb/gzLFKO7Q9XLUgce3PP+e+uUEFex0UXU5k555k3vbiOEw0waaFr10RfMcybgAXZmJuABxN4whKT2N48Usjpf0vM8PxHxAswxA4tFpjzYTxxcLz24cSitnt3nvxcBKfw7R6yey+VkU2TaH+MhAdAACf1nR5cUeW50muBwr3bnLzpfyPsfhlNqgpuQWNyrHz3Iztbhlc+kzkzyUNS5HGfH5mv/AB+4u5bffmdu0eBACwVW4ZC3895yhxj72jx9rNu2zx9o2apsrhlJUC6EgeZQ1zbqOR1E9cJxzxae/XwPXDKpxkmt+Z7vhHiBBVWbGh8quSSwJ4Ezw8RgTtpU+48MnvyPeKzwJmRCI2QpE1YCERIQrNWAhEQEImrI1pEKRGyARERSIkKREBSIkKREhYke0BPCaFemGyYA9xeKbXIVJrkyLbNYWQ2H9JGJfbUek0p3z/sdXeRN11W3UHI++nvN7PkxtE6lMa4D7FfmCQZqLfeKm+8591/aysNCBcfXTpadNXjaN6vFMfFVAsVU+1/8cjM1B9Q04+/15gpqpzYAnrdQPS1ou+hNyWyFDKxOdmubWs1gLDibWy0lTXkLi4pXy9MP+rwi5Zf7gL8NRhP6S7Nt7Jj2LfJM5q+37OzYDYm1w6Ll6/qJ1jhyqOpfRnohwudR1JfJnLU2moThoY9MyDca2yxZWnRQhV5K9eR6ceHFFXma9eRgm3pkFOHhkGsOuv6yf/Hlve53WP2dL3pS+/r9E/8A8vaKh3jPZjqCSthyuPtaUc+OC01ZuftHh8cVjww91eTt/NP+T0fCxRofCxxniVDXPEAjhpxnHN2mTmtvM8PE58vEfGtl416+h6+zVq7jRCOt0PtczyThjj3+voeH3PFff+CO27EXBweWqvnUN0OoP81ztN48yi1q+EzGlLfkV2DahUVTocQWoh+KkV8x62yvnwImMuNwk/s+8nGmx/GNkVwAQDr65Wt84cPkcXsStHydBTTqPQP73AuD7fMT68mpwWRA+8+y2CrvKavxIz7jI/SfGyx0zaBqipEwAhEUwEYTaYCmIEzEBCJogRIBiQhiQpMUQpM0QhMUQhMSEJmqA90T55sMiBIhWmkBFqI/KSvbT2m1LvFMjUdxqmLqtvmDNJRfWjpGEXvqrz/omdsS3EcCGGnPpNdlKx7Cd7b+RNnVvgt0N7Edl09T7GaSlHma7OUfiXrz9eYN3YYVcHj5rZdb85ar3ozdvU0akqklLA/muSTrqAMwTfO/WTckrNybrU2dFfYqTrhellrpex7qbznHLOLuMgx58uOWqEtzzj4KyHFRq52ICNkLXuBn7epno/5SkqnH5o9j42GSOnJBee9+J6GybcykJVXC2WVwLnob/wA6zzzxJ7wdo8c8S5x5HNtm0irUOyoGFs65FjgXWwsc78R+s644dnDtZPyO+LE8cO2fLkvP+iiVNjTyLhGdmUAuSDxtY8bTDWeW7M9nnn70vq9l9WLS8WCsbqzJbIlbunpmWHz7zUuGbWzp/Z/x+Dm4q66/Y9MhaiK9JwwJGEg4hy14ciOpnl3hJxkgcWnUuZzeK+HCqRWp5Ph83AsMrDLQi5+k64M+hOEuVkpUT2fbTVpmlUBFVEa4/rtazA9bZ+s1PFompR+Fv6G3FKVrkeT45ZNrWsPMtWktuhF8x6Wnr4W5cO4dYs7LH2mBRiveTd+Kdfjc+j8I2U06YDfEbuw4KTwHafO4jIpztcjyzq9uR1MJyRzEaICGbAmZoBDEBDNELEgGJCGJCNNIhYkIYoBGmiEMSPevPnmzXkQCYgKTFACJGkRzbXQDldARcg2BzHD5n2nSE3FM7Y8rhGVdRGQ3spUN0GQ752PbWN7b8iUv8uXrkB1Y+Ty6gkkXDfv07SVLfc0pRXvOx08PTU5k2vYBRl0/msO2fQzLK2xxsQGa37YiIPK3zDtH1/A2A6B2U8ms6n1P3mbXd9NjWtPmvpsT2imCuCsgK8eQ6qT8J9pqLp3B7+vqag3F3Bnk7V4e1Ft8js9M2RxiKsF4KzDO17CeqGZZFokqfTbbzo+lDjYzw9lKCTW6fj5cj01p0igIo2FsSkWbCRndTr3nlcpqVaj5zcm+ZQ7KjE214jiOo5/XvBZZI56Ty69Ctszl6WpzdfyVhbW3Bus9cZY80an9eq/o6xnfuz+vd/R7vg+3JWxFf7Th4qTcsPfP1E8GfFLHSfruKUWjz/HKW6qJXU2w3OYuCMgVb3E9HDS7SDxvqbxR1e4ldni7HtS7RXpBwcCZKAC12U3GQ4Xt7T2Tg8WKenmz7c+Flw3DTkvifPwT/dcvM+3M+KfnBWigJtNGWTabAmZoCZiApM0QpiQpMSFJiRMzSIUmICmaRCGJCRA9vFPDRqzYpUQMUaIUtEAXkQcUiAbHIyFNrkYAWsMhIb3tihcwB/Sdc9SPsY2PSxrsOFx8x25wpMEUR75iZaoR7X1mbogrSt8PsdP2g5XzNEG2a1zT8pIIamckf/qfynqPUTosl0pfXqv5Oqle0vqef4VWeoKuDIqWDUDYAcMr6E4SdbZ952zxjFxv/t6/2d8mPRpT5PlLv/1y7z0aVRXswBCkG18ilviXI3FuR68p53Fx2OMoOOzNtNFrG3mFsgdVJ4A8b6j94wmvIHTPH2ADHdcm82A53uuqMOo+dp7M16N+XrdHaUfdL/iLbVNErUHmtkNbkFWVhbVbKc/ochx4XHJTuPI93srFKedNclz8jm/DdFF2hgFAw0kVeN2yxnve/tO3Fybwrfr/AKOvtCcpYFK/im2/0fVGfLPhsRppATaaQEmm0ZJMZsyITFEJeaIUmICExEBMaAQmaIUxIUxIUxISIHqYp5KEOKVEa8qIBMaIF5Ea8qI15UQQZEEa37D2v94DZQGZI2HiMj9e8hTHWpwOR+R7GZaEsDMGh9cjBieJ4hsJNVihKtZXRtSpAzFyc1IvlzXUG09ePKtCteHryPXjz6YqL3j1X78H4/oXw3aWLsrKQwxPWXMkaDEvM3OIHUgrxEs0FpVPbo/Xq7OmfBoipJ2nyfr1dnq0GviB4WVu2ZU/r2nml0Z42eFVfdV0qsLeZsduIuVPrnf/ANnviteJwXceyKThKF91HL+IP9wlgf8AiUonUX19vpN8N7kfPdn1PZk+zlGH+Tt/oH4eroA2NgjDAKbn4RYG6npp8jHioy2SVru/Ye04Scvc3jva633n0a+IkWx0znaxVlZW6qbi/wBek+f2K6P8nxexv4X/AF59xajtavcLe62xKRYrfS45HnpMODjzOeTHKFX15dRmMkjiyLtOiRkizTaQE2aaSAUtGiFLxohS0aIF4kAmJCmJAMiEMSFiB3hp56EOKVEG8CBeNEbFKiBilRBvKiCDAhgYEMDBkUUzIjgXyMDSMCV6r7lfuIVfmaW50KZgTm25RdCcgTgbpfND/kB/lN4+TXz/AJ+x0itSa+ZwVMI2injviZXpAj+2zIfbGD1E6pN45OPgenHKUuGlG/hd/XZ/TYK1P9PXCtmlQboHXBbzLe/DzW/lpNdpjbXNb+voSh2uOTXNb+a6nE9I1dsNBs1RhWt/bhBz555es9Clo4ftFzex309nw6zf5Kl58vwT/EFJkF1FwzVFPIWe4HteXCzi9peH4PZwDWTbrGn9ifgKooqip8JNNgWXGo+Ieblpfpn63Ezfu09/XI37R7Wcscse0qfJ0/7E8X2pKXkpUlQk5lD5SvFhkCrZ39OM6Ycc8m7lfn63PPwuvOnLNO9qS6t9Pket+HNnIpCq2tQK4BzKIbsqluPxE9yZ5OJl7+nus8PH5VLJojyjt5vk386/B6TGcUeBkHM2jBFjOiIkTNJAIWmqIW8aIF40RryI15EGRAMiEMSFiB0q050IwaFEHFCiAWlRAxRog4pUQcUKIIaVEMDM0RQGFEOpmKEoDBiUUzDNIFM4Th4H4eh4j9feT3VmjbaoKEHS6t7MD+ksbalsag2nseNt2J3JGZpghRfJmDi6nuN1/kZ68dRj5/iv9nqxpR0qXJ8/J8vpzL7TVWrTDgEi9IDgTa7E/wCJBtOUFolXmbhCWObi9mk/4/J5dbaHTaBtCC4wii2WI2sATa4ubg8dFE9UIKeF42+to9kXCWF8PNbr3udfp9PudO21DVsuIEYt4CAVzsBYg6ds+M4Yvcu14Hq4PFHEtdNNqt/X8HJW2V1p1G0whiP7gFJzt1OnQTnLPHV3o9kZwlkiu88/x6xV2xXYlUUDIA4cRz7G/pPVw/ES1qMVsdOCxQxJe70bt+f8n1/hSBaKAXthBF9QDmL+hnlzO8kmfipybk2+ZdjMIwQczogOd2nRIySZptIiZaaoAXkRryE15Ea8iGBkRiZEITEhSY0ZGV4OIjh5miDjhRALxojYpUQccKIIaVCENKiHDTNEUVploiitMtEUVphoSitBo0M4uLcdR0I0mVszSZ53jPiSrTC3AZ9BwGHMljwAIsZ2w4nqb6I9/BcLLNJvoufz6Lx9PY4mqsFVUBBYl94wwYjcMWCnhfn7aTo+f2ruPauHxuUsmR7KvdW9dybX3r6k6rlUWmL+QKBnf4hZsgBwJ1uYxi5Sb8T0YscZyeR/+3h3Pbv6rpSFoKxspyuCFPO362/WM8scS35nVYIRk5/P14Wd/h9IDGrfkbPsVDA+x+U+dm4hzZZZP3Wuv+jyPF/Ev9hkY2NRKCi2RBqp5/YYmnLEpTdLqe3huHrKpLknL7Pb6vY8fweg+21/N/xqzPU5WY/D1OQToEfmJ9hJYIWufT14GfafEx4TBS+Jql+38vy/A/Q7zwn4kRzNojnqGdEgOd2nRIyRYzaQCEzVEDFKiDeVEa8qI15URsUqI2OVEKWjRC4o0ZJrUmmhHWpMtFY28hRG3kqEOOVAbHKhCHlRDB5miHDwaEorzLRFFeZaIorzDQlVeZoSgeYaNHzXjnhdVWqbRTs4KtdSLMnl8xXg188sviM9uHJGSjje37Pvez/aGJQhgyWqfNcnv16+kedQrtVVcTYvyA3LYCeBPK+U7ZezxS3W59j/AI3ZuWhaeu3Vd/0PY2KlcFgLsPK44grwz453HO45z52biW/h2OU3o93p0OmhVSoDSc2Y5KR5cR4FTqri18Oqn0J+dKdvc5SjKL1rdL1v3p9/JnNU2jA96zANh/01a2QcEMaNbpezr3NuEwdYw1RqC2+JeHLVH8Py8z4upUrbdWFOiPy088rL/tqhY8hYH/MifW4SChHUz7GaeHgMDyZX1dLq3bdL10P0PwXw1NlpikmfF2OrtxJllm8krZ/PuM4vJxWV5Z/JdEu5HazzCR5iT1JtRBnPUedUgOd3nRICZaaoBS0aATHGiCHlQhxQojYo0QC8qIGONADHKiBilQHKKk60VjirDSQd7DSQd5LSQwqQ0kEVIaSGDyoRg8zRDh4UJQVJnSQ6vMtCUWpMtCVV5hoiqvMtCNivrM0NnzHi/hlSgd9syhlzNSnbM+g1y9dMjnPT7udVN1Lo+h+k9me1ItdjxD/+X3eB5NL8TYWxgMrjJr55D8rj4WHInCwnnyez2up+gjwXaRrmvt5prl5brwOip+KA2dSmmeEF0dVxW0uj3XLhmSOE8cuEkS9mOPwye3Rr9rf7UcJ8P2zbmCliKQOHeOCCyYgbAatoMzxF78J3xcKo7y/s4cV7T4TgI+5Tyf4rkvN9Pl9D7TwfwylsqbukP+zHNnPMmdpNvyPxfGcbm4vI8mV2/svBHaXgonlJtUm1EiL1JtRAg9SdEgIu82kBI1JqgAXjQCF5qiMKkKIbHKhNjhRALxohccaA2OVEDHKiOMPO1GRg8KKw7yVFYd5CisYVIaRsYVIaSCKktIjipM6SHV4UJQPM0RRXmWhKK8y0JRXmWiKipMUI4qQ0jY28mdJEK2z03+NFbuob6zSclyZ0hlyY/gk15OhKPh9BM0poD0UCLnJ9Tpk4viMiqeSTXi2dWKYo84peKRE2qTaQEmqzSiRJqk2ohZFqk2omSTVJtICZeNEKakaAQvNURhUlpIO8hQhFSWkgF5UQC8aAGOVFZt5GgOJXnZoh8czQGxyojY5aSCKktJDbyGkRhUhRDipM0JQVJlohxUhQlFqTLiJRaky4kUFSZ0iOKszpKxxVhpEYVYaRDvYaSsO9lpKwGrLSVimrHSRN6k0ohZFqk2ogSapNqIEmqTSiBNqk0kAhqTVATLzVEAvKgAHjQjY4UIccKIBeVEDHGgAXjRA3kaA41qTs4kNvJmgNvJaRDjlRBDwohg8qIYPCiHWpMtCOHmWhGDwoigqQoR1qTOkrHFSZ0kOKkNIjirM6Ssbey0kbew0jYd7LSVg30tJWA1o6Qsm1WaUSJtUmlECTVJpIibPNUBMvNUAheaoBccaIGONEDHKiGDQoQ44UQMcaIGONAKXlRALx0hZwCpO9EOKkNJWHeSogh4UQweFEOHhQhxwohleFEUDzNCMHhRDCpChHFSZ0kOtSDRFA8zQjY4aSDvIURhUlpI28lpIG8jRANSVEKak1REy8aImzzSQCF5qgJs81QCF5qgBjlRC440QccqEIeFCbHKiBjlRALxoAF40DENSNAzgV53ozY4eFDYccKKwh5URRXmWhGDwoRscKEYPCiGDwohscKEYVIUQ4qTNEOtSFCUFSZoh95DSJt5DSRscqI2OWkgF40QDUlpIU1JqgENSOkhDUjpAm1SaSImXmkgELzVALjjRGxyorNjlRBDwoTY5URscqIBeNEKXjRliF40ZPPV56GjnY4eFGrGxwobCHhRWUDwo0MKkzQ2MHhRWMHhQ2OHhQhxwohhUhpIYVIUI6vCiKCpM0I28hpIO8lpIOOFEbHKiAakqEU1JqgFNSNEIakaIQ1IpAxC81QCF5qgELxoBccaCwY5URscqKw45UIccKE2OVFYC8aARnikZbELzVGbPNWrPS4nmUygqTNG9QwqQoVIYVJmjVlA8KN2EVIUVjCpCjSY4qQoUxhUhpGxscKKwipChsYPCiscVIUI4qTNCMKkNI2NvJaSMKkKIO8lpKxTUjpIU1I6SAXjRWIXjRkUvGiENSKRmyZeaSBsU1JqgsXeSozYN5GiswqSokw7yFDYccqGzbyVE2KakaByEapFIw5EzVmtJyctzzw09NHnGxwobGDw0jqGFSZ0mtQ4qzOk0sg+8hRvUMKkKNKTHFSGk1qGFSGk0mMKkKGxhUhQ2MHhQ2OHmaGxhUlpGwipCiDvIUVh3ktI2HeS0kDeSorFNSNFYDUlQWI1Sa0g2IakdJlsQ1JqjLkI1SNGHIQ1I0ZchTUmtJlzFNSWkNZhVlpHWOKkKN6jbyVEpGNSWknMQ1I6Tm5iNUmlE5ynYhea0mLP/Z'; image.onload = function() { + var imageKernel = gpu.createKernel(function(image) { + const pixel = image[this.thread.y][this.thread.x]; + this.color(pixel[0], pixel[1], pixel[2], pixel[3]); + }, { + graphical: true, + output : [image.width, image.height] + }); imageKernel(image); assert.equal(true, true, 'does not throw'); gpu.destroy(); diff --git a/test/issues/349-division-by-factors-of-3.js b/test/issues/349-division-by-factors-of-3.js index 8ef4a27d..c663c027 100644 --- a/test/issues/349-division-by-factors-of-3.js +++ b/test/issues/349-division-by-factors-of-3.js @@ -41,14 +41,30 @@ var gpu = new GPU({mode: null}); var idfix = gpu.createKernel(function(v1, v2) { return v1 / v2; - }).setOutput([1]).setFloatOutput(true) + }) + .setOutput([1]) + .setFloatOutput(true); var idfixoff = gpu.createKernel(function(v1, v2) { return v1 / v2; - }).setOutput([1]).setFloatOutput(true).setFixIntegerDivisionAccuracy(false) + }) + .setOutput([1]) + .setFloatOutput(true) + .setFixIntegerDivisionAccuracy(false); var hasBug = gpu.hasIntegerDivisionAccuracyBug(); - QUnit.assert.ok(idfix(6,3)[0] == 2 && (!hasBug || idfixoff(6,3)[0] != 2), "should show bug!"); + if (hasBug) { + QUnit.assert.ok( + ( + idfix(6, 3)[0] === 2 + && idfix(6030401, 3991)[0] === 1511 + ) && ( + idfixoff(6, 3)[0] !== 2 + || idfixoff(6030401, 3991)[0] !== 1511 + ), "when bug is present should show bug!"); + } else { + QUnit.assert.ok(idfix(6, 3)[0] === 2 && idfixoff(6, 3)[0] === 2, "when bug isn't present should not show bug!"); + } gpu.destroy(); }); })();