move files to adequate folders and fix imports
This commit is contained in:
12
src/external/core-js-bundle/minified.js
vendored
Normal file
12
src/external/core-js-bundle/minified.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
src/external/core-js-bundle/minified.js.map
vendored
Normal file
1
src/external/core-js-bundle/minified.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
102
src/external/deparam/deparam.esm.js
vendored
Normal file
102
src/external/deparam/deparam.esm.js
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Created by alexey2baranov on 28.01.17.
|
||||
*/
|
||||
/*
|
||||
An extraction of the deparam method from Ben Alman's jQuery BBQ
|
||||
http://benalman.com/projects/jquery-bbq-plugin/
|
||||
*/
|
||||
|
||||
const coerce_types = {'true': !0, 'false': !1, 'null': null};
|
||||
|
||||
function deparam (params, coerce) {
|
||||
// console.log(params)
|
||||
const obj = {};
|
||||
|
||||
// Iterate over all name=value pairs.
|
||||
params.replace(/\+/g, ' ').split('&').forEach(function (v) {
|
||||
const param = v.split('=');
|
||||
|
||||
let
|
||||
key = decodeURIComponent(param[0]),
|
||||
// If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it
|
||||
// into its component parts.
|
||||
keys = key.split(']['),
|
||||
keys_last = keys.length - 1;
|
||||
|
||||
// If the first keys part contains [ and the last ends with ], then []
|
||||
// are correctly balanced.
|
||||
if (/\[/.test(keys[0]) && /\]$/.test(keys[keys_last])) {
|
||||
// Remove the trailing ] from the last keys part.
|
||||
keys[keys_last] = keys[keys_last].replace(/\]$/, '');
|
||||
|
||||
// Split first keys part into two parts on the [ and add them back onto
|
||||
// the beginning of the keys array.
|
||||
keys = keys.shift().split('[').concat(keys);
|
||||
|
||||
keys_last = keys.length - 1;
|
||||
} else {
|
||||
// Basic 'foo' style key.
|
||||
keys_last = 0;
|
||||
}
|
||||
|
||||
// Are we dealing with a name=value pair, or just a name?
|
||||
if (param.length >= 2) {
|
||||
let val = decodeURIComponent(param.slice(1).join('='));
|
||||
|
||||
// Coerce values.
|
||||
if (coerce) {
|
||||
val = val && !isNaN(val) ? +val // number
|
||||
: val === 'undefined' ? undefined // undefined
|
||||
: coerce_types[val] !== undefined ? coerce_types[val] // true, false, null
|
||||
: val; // string
|
||||
}
|
||||
|
||||
if (keys_last) {
|
||||
let cur = obj;
|
||||
// Complex key, build deep object structure based on a few rules:
|
||||
// * The 'cur' pointer starts at the object top-level.
|
||||
// * [] = array push (n is set to array length), [n] = array if n is
|
||||
// numeric, otherwise object.
|
||||
// * If at the last keys part, set the value.
|
||||
// * For each keys part, if the current level is undefined create an
|
||||
// object or array based on the type of the next keys part.
|
||||
// * Move the 'cur' pointer to the next level.
|
||||
// * Rinse & repeat.
|
||||
for (let i = 0; i <= keys_last; i++) {
|
||||
key = keys[i] === '' ? cur.length : keys[i];
|
||||
cur = cur[key] = i < keys_last
|
||||
? cur[key] || (keys[i + 1] && isNaN(keys[i + 1]) ? {} : [])
|
||||
: val;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Simple key, even simpler rules, since only scalars and shallow
|
||||
// arrays are allowed.
|
||||
|
||||
if (Array.isArray(obj[key])) {
|
||||
// val is already an array, so push on the next value.
|
||||
obj[key].push(val);
|
||||
|
||||
} else if (obj[key] !== undefined) {
|
||||
// val isn't an array, but since a second value has been specified,
|
||||
// convert val into an array.
|
||||
obj[key] = [obj[key], val];
|
||||
|
||||
} else {
|
||||
// val is a scalar.
|
||||
obj[key] = val;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (key) {
|
||||
// No value was defined, so set something meaningful.
|
||||
obj[key] = coerce
|
||||
? undefined
|
||||
: '';
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
export default deparam;
|
||||
119
src/external/dom-polyfill/dom-polyfill.js
vendored
Normal file
119
src/external/dom-polyfill/dom-polyfill.js
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
// From https://github.com/inexorabletash/polyfill/blob/master/dom.js
|
||||
|
||||
/**
|
||||
* @module DOMPolyfill
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Node} o
|
||||
* @param {module:DOMPolyfill~ParentNode|module:DOMPolyfill~ChildNode} ps
|
||||
* @returns {void}
|
||||
*/
|
||||
function mixin (o, ps) {
|
||||
if (!o) return;
|
||||
Object.keys(ps).forEach((p) => {
|
||||
if ((p in o) || (p in o.prototype)) { return; }
|
||||
try {
|
||||
Object.defineProperty(
|
||||
o.prototype,
|
||||
p,
|
||||
Object.getOwnPropertyDescriptor(ps, p)
|
||||
);
|
||||
} catch (ex) {
|
||||
// Throws in IE8; just copy it
|
||||
o[p] = ps[p];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Node[]} nodes
|
||||
* @returns {Node}
|
||||
*/
|
||||
function convertNodesIntoANode (nodes) {
|
||||
nodes = nodes.map((node) => {
|
||||
const isNode = node && typeof node === 'object' && 'nodeType' in node;
|
||||
return isNode ? node : document.createTextNode(node);
|
||||
});
|
||||
if (nodes.length === 1) {
|
||||
return nodes[0];
|
||||
}
|
||||
const node = document.createDocumentFragment();
|
||||
nodes.forEach((n) => {
|
||||
node.appendChild(n);
|
||||
});
|
||||
return node;
|
||||
}
|
||||
|
||||
const ParentNode = {
|
||||
prepend (...nodes) {
|
||||
nodes = convertNodesIntoANode(nodes);
|
||||
this.insertBefore(nodes, this.firstChild);
|
||||
},
|
||||
append (...nodes) {
|
||||
nodes = convertNodesIntoANode(nodes);
|
||||
this.appendChild(nodes);
|
||||
}
|
||||
};
|
||||
|
||||
mixin(Document || HTMLDocument, ParentNode); // HTMLDocument for IE8
|
||||
mixin(DocumentFragment, ParentNode);
|
||||
mixin(Element, ParentNode);
|
||||
|
||||
// Mixin ChildNode
|
||||
// https://dom.spec.whatwg.org/#interface-childnode
|
||||
|
||||
const ChildNode = {
|
||||
before (...nodes) {
|
||||
const parent = this.parentNode;
|
||||
if (!parent) return;
|
||||
let viablePreviousSibling = this.previousSibling;
|
||||
while (nodes.includes(viablePreviousSibling)) {
|
||||
viablePreviousSibling = viablePreviousSibling.previousSibling;
|
||||
}
|
||||
const node = convertNodesIntoANode(nodes);
|
||||
parent.insertBefore(
|
||||
node,
|
||||
viablePreviousSibling
|
||||
? viablePreviousSibling.nextSibling
|
||||
: parent.firstChild
|
||||
);
|
||||
},
|
||||
after (...nodes) {
|
||||
const parent = this.parentNode;
|
||||
if (!parent) return;
|
||||
let viableNextSibling = this.nextSibling;
|
||||
while (nodes.includes(viableNextSibling)) {
|
||||
viableNextSibling = viableNextSibling.nextSibling;
|
||||
}
|
||||
const node = convertNodesIntoANode(nodes);
|
||||
// eslint-disable-next-line unicorn/prefer-modern-dom-apis
|
||||
parent.insertBefore(node, viableNextSibling);
|
||||
},
|
||||
replaceWith (...nodes) {
|
||||
const parent = this.parentNode;
|
||||
if (!parent) return;
|
||||
let viableNextSibling = this.nextSibling;
|
||||
while (nodes.includes(viableNextSibling)) {
|
||||
viableNextSibling = viableNextSibling.nextSibling;
|
||||
}
|
||||
const node = convertNodesIntoANode(nodes);
|
||||
|
||||
if (this.parentNode === parent) {
|
||||
parent.replaceChild(node, this);
|
||||
} else {
|
||||
// eslint-disable-next-line unicorn/prefer-modern-dom-apis
|
||||
parent.insertBefore(node, viableNextSibling);
|
||||
}
|
||||
},
|
||||
remove () {
|
||||
if (!this.parentNode) { return; }
|
||||
this.parentNode.removeChild(this); // eslint-disable-line unicorn/prefer-node-remove
|
||||
}
|
||||
};
|
||||
|
||||
mixin(DocumentType, ChildNode);
|
||||
mixin(Element, ChildNode);
|
||||
mixin(CharacterData, ChildNode);
|
||||
172
src/external/dynamic-import-polyfill/importModule.js
vendored
Normal file
172
src/external/dynamic-import-polyfill/importModule.js
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
/* eslint-disable jsdoc/require-file-overview */
|
||||
/**
|
||||
* Adapted from {@link https://github.com/uupaa/dynamic-import-polyfill/blob/master/importModule.js}.
|
||||
* @module importModule
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Converts a possible relative URL into an absolute one.
|
||||
* @param {string} url
|
||||
* @returns {string}
|
||||
*/
|
||||
function toAbsoluteURL (url) {
|
||||
const a = document.createElement('a');
|
||||
a.setAttribute('href', url); // <a href="hoge.html">
|
||||
return a.cloneNode(false).href; // -> "http://example.com/hoge.html"
|
||||
}
|
||||
|
||||
/**
|
||||
* Add any of the whitelisted attributes to the script tag.
|
||||
* @param {HTMLScriptElement} script
|
||||
* @param {PlainObject<string, string>} atts
|
||||
* @returns {void}
|
||||
*/
|
||||
function addScriptAtts (script, atts) {
|
||||
['id', 'class', 'type'].forEach((prop) => {
|
||||
if (prop in atts) {
|
||||
script[prop] = atts[prop];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Additions by Brett
|
||||
/**
|
||||
* @typedef {PlainObject} module:importModule.ImportConfig
|
||||
* @property {string} global The variable name to set on `window` (when not using the modular version)
|
||||
* @property {boolean} [returnDefault=false]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @function module:importModule.importSetGlobalDefault
|
||||
* @param {string|GenericArray<any>} url
|
||||
* @param {module:importModule.ImportConfig} config
|
||||
* @returns {Promise<any>} The value to which it resolves depends on the export of the targeted module.
|
||||
*/
|
||||
export function importSetGlobalDefault (url, config) {
|
||||
return importSetGlobal(url, {...config, returnDefault: true});
|
||||
}
|
||||
/**
|
||||
* @function module:importModule.importSetGlobal
|
||||
* @param {string|string[]} url
|
||||
* @param {module:importModule.ImportConfig} config
|
||||
* @returns {Promise<ArbitraryModule>} The promise resolves to either an `ArbitraryModule` or
|
||||
* any other value depends on the export of the targeted module.
|
||||
*/
|
||||
export async function importSetGlobal (url, {global: glob, returnDefault}) {
|
||||
// Todo: Replace calls to this function with `import()` when supported
|
||||
const modularVersion = !('svgEditor' in window) ||
|
||||
!window.svgEditor ||
|
||||
window.svgEditor.modules !== false;
|
||||
if (modularVersion) {
|
||||
return importModule(url, undefined, {returnDefault});
|
||||
}
|
||||
await importScript(url);
|
||||
return window[glob];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Brett Zamir (other items are from `dynamic-import-polyfill`)
|
||||
* @param {string|string[]} url
|
||||
* @param {PlainObject} [atts={}]
|
||||
* @returns {Promise<void|Error>} Resolves to `undefined` or rejects with an `Error` upon a
|
||||
* script loading error
|
||||
*/
|
||||
export function importScript (url, atts = {}) {
|
||||
if (Array.isArray(url)) {
|
||||
return Promise.all(url.map((u) => {
|
||||
return importScript(u, atts);
|
||||
}));
|
||||
}
|
||||
return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
|
||||
const script = document.createElement('script');
|
||||
/**
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function scriptOnError () {
|
||||
reject(new Error(`Failed to import: ${url}`));
|
||||
destructor();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function scriptOnLoad () {
|
||||
resolve();
|
||||
destructor();
|
||||
}
|
||||
const destructor = () => {
|
||||
script.removeEventListener('error', scriptOnError);
|
||||
script.removeEventListener('load', scriptOnLoad);
|
||||
script.remove();
|
||||
script.src = '';
|
||||
};
|
||||
script.defer = 'defer';
|
||||
addScriptAtts(script, atts);
|
||||
script.addEventListener('error', scriptOnError);
|
||||
script.addEventListener('load', scriptOnLoad);
|
||||
script.src = url;
|
||||
|
||||
document.head.append(script);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string|string[]} url
|
||||
* @param {PlainObject} [atts={}]
|
||||
* @param {PlainObject} opts
|
||||
* @param {boolean} [opts.returnDefault=false} = {}]
|
||||
* @returns {Promise<any>} Resolves to value of loading module or rejects with
|
||||
* `Error` upon a script loading error.
|
||||
*/
|
||||
export function importModule (url, atts = {}, {returnDefault = false} = {}) {
|
||||
if (Array.isArray(url)) {
|
||||
return Promise.all(url.map((u) => {
|
||||
return importModule(u, atts);
|
||||
}));
|
||||
}
|
||||
return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
|
||||
const vector = '$importModule$' + Math.random().toString(32).slice(2);
|
||||
const script = document.createElement('script');
|
||||
/**
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function scriptOnError () {
|
||||
reject(new Error(`Failed to import: ${url}`));
|
||||
destructor();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function scriptOnLoad () {
|
||||
resolve(window[vector]);
|
||||
destructor();
|
||||
}
|
||||
const destructor = () => {
|
||||
delete window[vector];
|
||||
script.removeEventListener('error', scriptOnError);
|
||||
script.removeEventListener('load', scriptOnLoad);
|
||||
script.remove();
|
||||
URL.revokeObjectURL(script.src);
|
||||
script.src = '';
|
||||
};
|
||||
addScriptAtts(script, atts);
|
||||
script.defer = 'defer';
|
||||
script.type = 'module';
|
||||
script.addEventListener('error', scriptOnError);
|
||||
script.addEventListener('load', scriptOnLoad);
|
||||
const absURL = toAbsoluteURL(url);
|
||||
const loader = `import * as m from '${absURL.replace(/'/g, "\\'")}'; window.${vector} = ${returnDefault ? 'm.default || ' : ''}m;`; // export Module
|
||||
const blob = new Blob([loader], {type: 'text/javascript'});
|
||||
script.src = URL.createObjectURL(blob);
|
||||
|
||||
document.head.append(script);
|
||||
});
|
||||
}
|
||||
|
||||
export default importModule;
|
||||
1932
src/external/jamilih/jml-es.js
vendored
Normal file
1932
src/external/jamilih/jml-es.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
162
src/external/load-stylesheets/index-es.js
vendored
Normal file
162
src/external/load-stylesheets/index-es.js
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
function _slicedToArray(arr, i) {
|
||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"] != null) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
|
||||
function loadStylesheets(stylesheets) {
|
||||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
beforeDefault = _ref.before,
|
||||
afterDefault = _ref.after,
|
||||
faviconDefault = _ref.favicon,
|
||||
canvasDefault = _ref.canvas,
|
||||
_ref$image = _ref.image,
|
||||
imageDefault = _ref$image === void 0 ? true : _ref$image,
|
||||
acceptErrors = _ref.acceptErrors;
|
||||
|
||||
stylesheets = Array.isArray(stylesheets) ? stylesheets : [stylesheets];
|
||||
|
||||
function setupLink(stylesheetURL) {
|
||||
var options = {};
|
||||
|
||||
if (Array.isArray(stylesheetURL)) {
|
||||
var _stylesheetURL = stylesheetURL;
|
||||
|
||||
var _stylesheetURL2 = _slicedToArray(_stylesheetURL, 2);
|
||||
|
||||
stylesheetURL = _stylesheetURL2[0];
|
||||
var _stylesheetURL2$ = _stylesheetURL2[1];
|
||||
options = _stylesheetURL2$ === void 0 ? {} : _stylesheetURL2$;
|
||||
}
|
||||
|
||||
var _options = options,
|
||||
_options$favicon = _options.favicon,
|
||||
favicon = _options$favicon === void 0 ? faviconDefault : _options$favicon;
|
||||
var _options2 = options,
|
||||
_options2$before = _options2.before,
|
||||
before = _options2$before === void 0 ? beforeDefault : _options2$before,
|
||||
_options2$after = _options2.after,
|
||||
after = _options2$after === void 0 ? afterDefault : _options2$after,
|
||||
_options2$canvas = _options2.canvas,
|
||||
canvas = _options2$canvas === void 0 ? canvasDefault : _options2$canvas,
|
||||
_options2$image = _options2.image,
|
||||
image = _options2$image === void 0 ? imageDefault : _options2$image;
|
||||
|
||||
function addLink() {
|
||||
if (before) {
|
||||
before.before(link);
|
||||
} else if (after) {
|
||||
after.after(link);
|
||||
} else {
|
||||
// eslint-disable-next-line unicorn/prefer-node-append
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
}
|
||||
|
||||
var link = document.createElement('link'); // eslint-disable-next-line promise/avoid-new
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
var rej = reject;
|
||||
|
||||
if (acceptErrors) {
|
||||
rej = typeof acceptErrors === 'function' ? function (error) {
|
||||
acceptErrors({
|
||||
error: error,
|
||||
stylesheetURL: stylesheetURL,
|
||||
options: options,
|
||||
resolve: resolve,
|
||||
reject: reject
|
||||
});
|
||||
} : resolve;
|
||||
}
|
||||
|
||||
if (stylesheetURL.endsWith('.css')) {
|
||||
favicon = false;
|
||||
} else if (stylesheetURL.endsWith('.ico')) {
|
||||
favicon = true;
|
||||
}
|
||||
|
||||
if (favicon) {
|
||||
link.rel = 'shortcut icon';
|
||||
link.type = 'image/x-icon';
|
||||
|
||||
if (image === false) {
|
||||
link.href = stylesheetURL;
|
||||
addLink();
|
||||
resolve(link);
|
||||
return;
|
||||
}
|
||||
|
||||
var cnv = document.createElement('canvas');
|
||||
cnv.width = 16;
|
||||
cnv.height = 16;
|
||||
var context = cnv.getContext('2d');
|
||||
var img = document.createElement('img');
|
||||
img.addEventListener('error', function (error) {
|
||||
reject(error);
|
||||
});
|
||||
img.addEventListener('load', function () {
|
||||
context.drawImage(img, 0, 0);
|
||||
link.href = canvas ? cnv.toDataURL('image/x-icon') : stylesheetURL;
|
||||
addLink();
|
||||
resolve(link);
|
||||
});
|
||||
img.src = stylesheetURL;
|
||||
return;
|
||||
}
|
||||
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = stylesheetURL;
|
||||
addLink();
|
||||
link.addEventListener('error', function (error) {
|
||||
rej(error);
|
||||
});
|
||||
link.addEventListener('load', function () {
|
||||
resolve(link);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.all(stylesheets.map(function (stylesheetURL) {
|
||||
return setupLink(stylesheetURL);
|
||||
}));
|
||||
}
|
||||
|
||||
export default loadStylesheets;
|
||||
556
src/external/qr-manipulation/dist/index-es.js
vendored
Normal file
556
src/external/qr-manipulation/dist/index-es.js
vendored
Normal file
@@ -0,0 +1,556 @@
|
||||
function _typeof(obj) {
|
||||
"@babel/helpers - typeof";
|
||||
|
||||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||||
_typeof = function (obj) {
|
||||
return typeof obj;
|
||||
};
|
||||
} else {
|
||||
_typeof = function (obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||||
};
|
||||
}
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
||||
}
|
||||
|
||||
function _toConsumableArray(arr) {
|
||||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
||||
}
|
||||
|
||||
function _arrayWithoutHoles(arr) {
|
||||
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function _iterableToArray(iter) {
|
||||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"] != null) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) {
|
||||
if (!o) return;
|
||||
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
||||
var n = Object.prototype.toString.call(o).slice(8, -1);
|
||||
if (n === "Object" && o.constructor) n = o.constructor.name;
|
||||
if (n === "Map" || n === "Set") return Array.from(o);
|
||||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
||||
}
|
||||
|
||||
function _arrayLikeToArray(arr, len) {
|
||||
if (len == null || len > arr.length) len = arr.length;
|
||||
|
||||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
||||
|
||||
return arr2;
|
||||
}
|
||||
|
||||
function _nonIterableSpread() {
|
||||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
|
||||
function convertToString(content, type) {
|
||||
switch (_typeof(content)) {
|
||||
case 'object':
|
||||
{
|
||||
if (!content) {
|
||||
throw new TypeError('Cannot supply `null`');
|
||||
}
|
||||
|
||||
switch (content.nodeType) {
|
||||
case 1:
|
||||
{
|
||||
// ELEMENT
|
||||
return content.outerHTML;
|
||||
}
|
||||
|
||||
case 3:
|
||||
{
|
||||
// TEXT
|
||||
return content.nodeValue;
|
||||
}
|
||||
|
||||
case 11:
|
||||
{
|
||||
// DOCUMENT_FRAGMENT_NODE
|
||||
return _toConsumableArray(content.childNodes).reduce(function (s, node) {
|
||||
return s + convertToString(node, type);
|
||||
}, '');
|
||||
}
|
||||
|
||||
case undefined:
|
||||
// Array of nodes, QueryResult objects
|
||||
// if (Array.isArray(content)) {
|
||||
if (typeof content.reduce === 'function') {
|
||||
return content.reduce(function (s, node) {
|
||||
return s + convertToString(node, type);
|
||||
}, '');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
case 'string':
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new TypeError('Bad content for ' + type + '; type: ' + _typeof(content));
|
||||
}
|
||||
}
|
||||
|
||||
function convertToDOM(content, type, avoidClone) {
|
||||
switch (_typeof(content)) {
|
||||
case 'object':
|
||||
{
|
||||
if (!content) {
|
||||
throw new TypeError('Cannot supply `null`');
|
||||
}
|
||||
|
||||
if ([1, // ELEMENT
|
||||
3, // TEXT
|
||||
11 // Document fragment
|
||||
].includes(content.nodeType)) {
|
||||
return avoidClone ? content : content.cloneNode(true);
|
||||
}
|
||||
|
||||
if (typeof content.reduce !== 'function') {
|
||||
throw new TypeError('Unrecognized type of object for conversion to DOM');
|
||||
} // Array of nodes, QueryResult objects
|
||||
|
||||
|
||||
return avoidClone ? content : content.map(function (node) {
|
||||
if (!node || !node.cloneNode) {
|
||||
// Allows for arrays of HTML strings
|
||||
return convertToDOM(node, type, false);
|
||||
}
|
||||
|
||||
return node.cloneNode(true);
|
||||
});
|
||||
}
|
||||
|
||||
case 'string':
|
||||
{
|
||||
var div = document.createElement('div'); // eslint-disable-next-line no-unsanitized/property
|
||||
|
||||
div.innerHTML = content;
|
||||
return div.firstElementChild || div.firstChild;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new TypeError('Bad content for ' + type + '; type: ' + _typeof(content));
|
||||
}
|
||||
}
|
||||
|
||||
function insert(type) {
|
||||
return function () {
|
||||
var _this = this;
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var cbOrContent = args[0];
|
||||
|
||||
switch (_typeof(cbOrContent)) {
|
||||
case 'function':
|
||||
{
|
||||
this.forEach(function (node, i) {
|
||||
var ret = cbOrContent.call(_this, i, node.textContent);
|
||||
node[type](ret);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
this.forEach(function (node, i, arr) {
|
||||
node[type].apply(node, _toConsumableArray(args.flatMap(function (content) {
|
||||
return convertToDOM(content, type, i === arr.length - 1);
|
||||
})));
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
function insertText(type) {
|
||||
return function (cbOrContent) {
|
||||
var _this2 = this;
|
||||
|
||||
switch (_typeof(cbOrContent)) {
|
||||
case 'function':
|
||||
{
|
||||
this.forEach(function (node, i) {
|
||||
var ret = cbOrContent.call(_this2, i, node[type]);
|
||||
node[type] = convertToString(ret, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
this.forEach(function (node) {
|
||||
node[type] = convertToString(cbOrContent, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
var after = insert('after');
|
||||
var before = insert('before');
|
||||
var append = insert('append');
|
||||
var prepend = insert('prepend');
|
||||
var html = insertText('innerHTML');
|
||||
var text = insertText('textContent');
|
||||
/*
|
||||
// Todo:
|
||||
export const val = function (valueOrFunc) {
|
||||
|
||||
};
|
||||
*/
|
||||
// Given that these types require a selector engine and
|
||||
// in order to avoid the absence of optimization of `document.querySelectorAll`
|
||||
// for `:first-child` and different behavior in different contexts,
|
||||
// and to avoid making a mutual dependency with query-result,
|
||||
// exports of this type accept a QueryResult instance;
|
||||
// if selected without a second argument, we do default to
|
||||
// `document.querySelectorAll`, however.
|
||||
|
||||
var insertTo = function insertTo(method) {
|
||||
var $ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (sel) {
|
||||
return _toConsumableArray(document.querySelectorAll(sel));
|
||||
};
|
||||
var type = {
|
||||
appendTo: 'append',
|
||||
prependTo: 'prepend',
|
||||
insertAfter: 'after',
|
||||
insertBefore: 'before'
|
||||
}[method] || 'append';
|
||||
return function (target) {
|
||||
var toType = type + 'To';
|
||||
this.forEach(function (node, i, arr) {
|
||||
if (typeof target === 'string' && target.charAt(0) !== '<') {
|
||||
target = $(target);
|
||||
}
|
||||
|
||||
target = Array.isArray(target) ? target : [target];
|
||||
node[type].apply(node, _toConsumableArray(target.flatMap(function (content) {
|
||||
return convertToDOM(content, toType, i === arr.length - 1);
|
||||
})));
|
||||
});
|
||||
return this;
|
||||
};
|
||||
}; // Todo: optional `withDataAndEvents` and `deepWithDataAndEvents` arguments?
|
||||
|
||||
var clone = function clone() {
|
||||
return this.map(function (node) {
|
||||
// Still a QueryResult with such a map
|
||||
return node.cloneNode(true);
|
||||
});
|
||||
};
|
||||
var empty = function empty() {
|
||||
this.forEach(function (node) {
|
||||
node.textContent = '';
|
||||
});
|
||||
};
|
||||
var remove = function remove(selector) {
|
||||
if (selector) {
|
||||
this.forEach(function (node) {
|
||||
if (node.matches(selector)) {
|
||||
// Todo: Use query-result instead?
|
||||
node.remove();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.forEach(function (node) {
|
||||
node.remove();
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
/*
|
||||
// Todo:
|
||||
export const detach = function (selector) {
|
||||
// Should preserve attached data
|
||||
return remove(selector);
|
||||
};
|
||||
*/
|
||||
|
||||
var attr = function attr(attributeNameOrAtts, valueOrCb) {
|
||||
var _this3 = this;
|
||||
|
||||
if (valueOrCb === undefined) {
|
||||
switch (_typeof(attributeNameOrAtts)) {
|
||||
case 'string':
|
||||
{
|
||||
return this[0].hasAttribute(attributeNameOrAtts) ? this[0].getAttribute(attributeNameOrAtts) : undefined;
|
||||
}
|
||||
|
||||
case 'object':
|
||||
{
|
||||
if (attributeNameOrAtts) {
|
||||
this.forEach(function (node, i) {
|
||||
Object.entries(attributeNameOrAtts).forEach(function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 2),
|
||||
att = _ref2[0],
|
||||
val = _ref2[1];
|
||||
|
||||
node.setAttribute(att, val);
|
||||
});
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
default:
|
||||
{
|
||||
throw new TypeError('Unexpected type for attribute name: ' + _typeof(attributeNameOrAtts));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (_typeof(valueOrCb)) {
|
||||
case 'function':
|
||||
{
|
||||
this.forEach(function (node, i) {
|
||||
var ret = valueOrCb.call(_this3, i, node.getAttribute(valueOrCb));
|
||||
|
||||
if (ret === null) {
|
||||
node.removeAttribute(attributeNameOrAtts);
|
||||
} else {
|
||||
node.setAttribute(attributeNameOrAtts, ret);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'string':
|
||||
{
|
||||
this.forEach(function (node, i) {
|
||||
node.setAttribute(attributeNameOrAtts, valueOrCb);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'object':
|
||||
{
|
||||
if (!valueOrCb) {
|
||||
// `null`
|
||||
return removeAttr.call(this, attributeNameOrAtts);
|
||||
}
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
default:
|
||||
{
|
||||
throw new TypeError('Unexpected type for attribute name: ' + _typeof(attributeNameOrAtts));
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
var removeAttr = function removeAttr(attributeName) {
|
||||
if (typeof attributeName !== 'string') {
|
||||
throw new TypeError('Unexpected type for attribute name: ' + _typeof(attributeName));
|
||||
}
|
||||
|
||||
this.forEach(function (node) {
|
||||
node.removeAttribute(attributeName);
|
||||
});
|
||||
};
|
||||
|
||||
function classAttManipulation(type) {
|
||||
return function (cbOrContent) {
|
||||
var _this4 = this;
|
||||
|
||||
switch (_typeof(cbOrContent)) {
|
||||
case 'function':
|
||||
{
|
||||
this.forEach(function (node, i) {
|
||||
var _node$classList;
|
||||
|
||||
var ret = cbOrContent.call(_this4, i, node.className);
|
||||
|
||||
(_node$classList = node.classList)[type].apply(_node$classList, _toConsumableArray(ret.split(' ')));
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if (type === 'remove' && !cbOrContent) {
|
||||
this.forEach(function (node) {
|
||||
node.className = '';
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
this.forEach(function (node) {
|
||||
var _node$classList2;
|
||||
|
||||
(_node$classList2 = node.classList)[type].apply(_node$classList2, _toConsumableArray(cbOrContent.split(' ')));
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
var addClass = classAttManipulation('add');
|
||||
var removeClass = classAttManipulation('remove');
|
||||
var hasClass = function hasClass(className) {
|
||||
return this.some(function (node) {
|
||||
return node.classList.contains(className);
|
||||
});
|
||||
};
|
||||
var toggleClass = function toggleClass(classNameOrCb, state) {
|
||||
var _this5 = this;
|
||||
|
||||
switch (typeof cbOrContent === "undefined" ? "undefined" : _typeof(cbOrContent)) {
|
||||
case 'function':
|
||||
{
|
||||
if (typeof state === 'boolean') {
|
||||
this.forEach(function (node, i) {
|
||||
var _node$classList3;
|
||||
|
||||
var ret = classNameOrCb.call(_this5, i, node.className, state);
|
||||
|
||||
(_node$classList3 = node.classList).toggle.apply(_node$classList3, _toConsumableArray(ret.split(' ')).concat([state]));
|
||||
});
|
||||
} else {
|
||||
this.forEach(function (node, i) {
|
||||
var _node$classList4;
|
||||
|
||||
var ret = classNameOrCb.call(_this5, i, node.className, state);
|
||||
|
||||
(_node$classList4 = node.classList).toggle.apply(_node$classList4, _toConsumableArray(ret.split(' ')));
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'string':
|
||||
{
|
||||
if (typeof state === 'boolean') {
|
||||
this.forEach(function (node) {
|
||||
var _node$classList5;
|
||||
|
||||
(_node$classList5 = node.classList).toggle.apply(_node$classList5, _toConsumableArray(classNameOrCb.split(' ')).concat([state]));
|
||||
});
|
||||
} else {
|
||||
this.forEach(function (node) {
|
||||
var _node$classList6;
|
||||
|
||||
(_node$classList6 = node.classList).toggle.apply(_node$classList6, _toConsumableArray(classNameOrCb.split(' ')));
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
var methods = {
|
||||
after: after,
|
||||
before: before,
|
||||
append: append,
|
||||
prepend: prepend,
|
||||
html: html,
|
||||
text: text,
|
||||
clone: clone,
|
||||
empty: empty,
|
||||
remove: remove,
|
||||
// detach
|
||||
attr: attr,
|
||||
removeAttr: removeAttr,
|
||||
addClass: addClass,
|
||||
hasClass: hasClass,
|
||||
removeClass: removeClass,
|
||||
toggleClass: toggleClass
|
||||
};
|
||||
|
||||
var manipulation = function manipulation($, jml) {
|
||||
['after', 'before', 'append', 'prepend', 'html', 'text', 'clone', 'empty', 'remove', // 'detach'
|
||||
'attr', 'removeAttr', 'addClass', 'hasClass', 'removeClass', 'toggleClass'].forEach(function (method) {
|
||||
$.extend(method, methods[method]);
|
||||
});
|
||||
['appendTo', 'prependTo', 'insertAfter', 'insertBefore'].forEach(function (method) {
|
||||
$.extend(method, insertTo(method, $));
|
||||
});
|
||||
|
||||
if (jml) {
|
||||
$.extend('jml', function () {
|
||||
var _this6 = this;
|
||||
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
this.forEach(function (node) {
|
||||
while (node.hasChildNodes()) {
|
||||
node.firstChild.remove();
|
||||
}
|
||||
|
||||
var n = jml.apply(void 0, args);
|
||||
return append.call(_this6, n);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return $;
|
||||
};
|
||||
|
||||
export { addClass, after, append, attr, before, clone, empty, hasClass, html, insertTo, manipulation, prepend, remove, removeAttr, removeClass, text, toggleClass };
|
||||
124
src/external/query-result/esm/index.js
vendored
Normal file
124
src/external/query-result/esm/index.js
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* ISC License
|
||||
*
|
||||
* Copyright (c) 2018, Andrea Giammarchi, @WebReflection
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
class QueryResult extends Array {}
|
||||
const {create, defineProperty} = Object;
|
||||
const AP = Array.prototype;
|
||||
const DOM_CONTENT_LOADED = 'DOMContentLoaded';
|
||||
const LOAD = 'load';
|
||||
const NO_TRANSPILER_ISSUES = (new QueryResult) instanceof QueryResult;
|
||||
const QRP = QueryResult.prototype;
|
||||
// fixes methods returning non QueryResult
|
||||
/* istanbul ignore if */
|
||||
if (!NO_TRANSPILER_ISSUES)
|
||||
Object.getOwnPropertyNames(AP).forEach(name => {
|
||||
const desc = Object.getOwnPropertyDescriptor(AP, name);
|
||||
if (typeof desc.value === 'function') {
|
||||
const fn = desc.value;
|
||||
desc.value = function () {
|
||||
const result = fn.apply(this, arguments);
|
||||
return result instanceof Array ? patch(result) : result;
|
||||
};
|
||||
}
|
||||
defineProperty(QRP, name, desc);
|
||||
});
|
||||
// fixes badly transpiled classes
|
||||
const patch = NO_TRANSPILER_ISSUES ?
|
||||
qr => qr :
|
||||
/* istanbul ignore next */
|
||||
qr => {
|
||||
const nqr = create(QRP);
|
||||
push.apply(nqr, slice(qr));
|
||||
return nqr;
|
||||
};
|
||||
const push = AP.push;
|
||||
const search = (list, el) => {
|
||||
const nodes = [];
|
||||
const length = list.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
const css = list[i].trim();
|
||||
if (css.slice(-6) === ':first') {
|
||||
const node = el.querySelector(css.slice(0, -6));
|
||||
if (node) push.call(nodes, node);
|
||||
} else
|
||||
push.apply(nodes, slice(el.querySelectorAll(css)));
|
||||
}
|
||||
return new QueryResult(...nodes);
|
||||
};
|
||||
const slice = NO_TRANSPILER_ISSUES ?
|
||||
patch :
|
||||
/* istanbul ignore next */
|
||||
all => {
|
||||
// do not use slice.call(...) due old IE gotcha
|
||||
const nodes = [];
|
||||
const length = all.length;
|
||||
for (let i = 0; i < length; i++)
|
||||
nodes[i] = all[i];
|
||||
return nodes;
|
||||
}
|
||||
// use function to avoid usage of Symbol.hasInstance
|
||||
// (broken in older browsers anyway)
|
||||
const $ = function $(CSS, parent = document) {
|
||||
switch (typeof CSS) {
|
||||
case 'string': return patch(search(CSS.split(','), parent));
|
||||
case 'object':
|
||||
// needed to avoid iterator dance (breaks in older IEs)
|
||||
const nodes = [];
|
||||
const all = ('nodeType' in CSS || 'postMessage' in CSS) ? [CSS] : CSS;
|
||||
push.apply(nodes, slice(all));
|
||||
return patch(new QueryResult(...nodes));
|
||||
case 'function':
|
||||
const $parent = $(parent);
|
||||
const $window = $(parent.defaultView);
|
||||
const handler = {handleEvent(event) {
|
||||
$parent.off(DOM_CONTENT_LOADED, handler);
|
||||
$window.off(LOAD, handler);
|
||||
CSS(event);
|
||||
}};
|
||||
$parent.on(DOM_CONTENT_LOADED, handler);
|
||||
$window.on(LOAD, handler);
|
||||
const rs = parent.readyState;
|
||||
if (rs == 'complete' || (rs != 'loading' && !parent.documentElement.doScroll))
|
||||
setTimeout(() => $parent.dispatch(DOM_CONTENT_LOADED));
|
||||
return $;
|
||||
}
|
||||
};
|
||||
$.prototype = QRP;
|
||||
$.extend = (key, value) =>
|
||||
(defineProperty(QRP, key, {configurable: true, value}), $);
|
||||
// dropped usage of for-of to avoid broken iteration dance in older IEs
|
||||
$.extend('dispatch', function dispatch(type, init = {}) {
|
||||
const event = new CustomEvent(type, init);
|
||||
const length = this.length;
|
||||
for (let i = 0; i < length; i++)
|
||||
this[i].dispatchEvent(event);
|
||||
return this;
|
||||
})
|
||||
.extend('off', function off(type, handler, options = false) {
|
||||
const length = this.length;
|
||||
for (let i = 0; i < length; i++)
|
||||
this[i].removeEventListener(type, handler, options);
|
||||
return this;
|
||||
})
|
||||
.extend('on', function on(type, handler, options = false) {
|
||||
const length = this.length;
|
||||
for (let i = 0; i < length; i++)
|
||||
this[i].addEventListener(type, handler, options);
|
||||
return this;
|
||||
});
|
||||
|
||||
export default $;
|
||||
729
src/external/regenerator-runtime/runtime.js
vendored
Normal file
729
src/external/regenerator-runtime/runtime.js
vendored
Normal file
@@ -0,0 +1,729 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
var runtime = (function (exports) {
|
||||
"use strict";
|
||||
|
||||
var Op = Object.prototype;
|
||||
var hasOwn = Op.hasOwnProperty;
|
||||
var undefined; // More compressible than void 0.
|
||||
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
||||
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
||||
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
||||
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
||||
|
||||
function wrap(innerFn, outerFn, self, tryLocsList) {
|
||||
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
||||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
||||
var generator = Object.create(protoGenerator.prototype);
|
||||
var context = new Context(tryLocsList || []);
|
||||
|
||||
// The ._invoke method unifies the implementations of the .next,
|
||||
// .throw, and .return methods.
|
||||
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
||||
|
||||
return generator;
|
||||
}
|
||||
exports.wrap = wrap;
|
||||
|
||||
// Try/catch helper to minimize deoptimizations. Returns a completion
|
||||
// record like context.tryEntries[i].completion. This interface could
|
||||
// have been (and was previously) designed to take a closure to be
|
||||
// invoked without arguments, but in all the cases we care about we
|
||||
// already have an existing method we want to call, so there's no need
|
||||
// to create a new function object. We can even get away with assuming
|
||||
// the method takes exactly one argument, since that happens to be true
|
||||
// in every case, so we don't have to touch the arguments object. The
|
||||
// only additional allocation required is the completion record, which
|
||||
// has a stable shape and so hopefully should be cheap to allocate.
|
||||
function tryCatch(fn, obj, arg) {
|
||||
try {
|
||||
return { type: "normal", arg: fn.call(obj, arg) };
|
||||
} catch (err) {
|
||||
return { type: "throw", arg: err };
|
||||
}
|
||||
}
|
||||
|
||||
var GenStateSuspendedStart = "suspendedStart";
|
||||
var GenStateSuspendedYield = "suspendedYield";
|
||||
var GenStateExecuting = "executing";
|
||||
var GenStateCompleted = "completed";
|
||||
|
||||
// Returning this object from the innerFn has the same effect as
|
||||
// breaking out of the dispatch switch statement.
|
||||
var ContinueSentinel = {};
|
||||
|
||||
// Dummy constructor functions that we use as the .constructor and
|
||||
// .constructor.prototype properties for functions that return Generator
|
||||
// objects. For full spec compliance, you may wish to configure your
|
||||
// minifier not to mangle the names of these two functions.
|
||||
function Generator() {}
|
||||
function GeneratorFunction() {}
|
||||
function GeneratorFunctionPrototype() {}
|
||||
|
||||
// This is a polyfill for %IteratorPrototype% for environments that
|
||||
// don't natively support it.
|
||||
var IteratorPrototype = {};
|
||||
IteratorPrototype[iteratorSymbol] = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
var getProto = Object.getPrototypeOf;
|
||||
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
||||
if (NativeIteratorPrototype &&
|
||||
NativeIteratorPrototype !== Op &&
|
||||
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
||||
// This environment has a native %IteratorPrototype%; use it instead
|
||||
// of the polyfill.
|
||||
IteratorPrototype = NativeIteratorPrototype;
|
||||
}
|
||||
|
||||
var Gp = GeneratorFunctionPrototype.prototype =
|
||||
Generator.prototype = Object.create(IteratorPrototype);
|
||||
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
||||
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
||||
GeneratorFunctionPrototype[toStringTagSymbol] =
|
||||
GeneratorFunction.displayName = "GeneratorFunction";
|
||||
|
||||
// Helper for defining the .next, .throw, and .return methods of the
|
||||
// Iterator interface in terms of a single ._invoke method.
|
||||
function defineIteratorMethods(prototype) {
|
||||
["next", "throw", "return"].forEach(function(method) {
|
||||
prototype[method] = function(arg) {
|
||||
return this._invoke(method, arg);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
exports.isGeneratorFunction = function(genFun) {
|
||||
var ctor = typeof genFun === "function" && genFun.constructor;
|
||||
return ctor
|
||||
? ctor === GeneratorFunction ||
|
||||
// For the native GeneratorFunction constructor, the best we can
|
||||
// do is to check its .name property.
|
||||
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
||||
: false;
|
||||
};
|
||||
|
||||
exports.mark = function(genFun) {
|
||||
if (Object.setPrototypeOf) {
|
||||
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
||||
} else {
|
||||
genFun.__proto__ = GeneratorFunctionPrototype;
|
||||
if (!(toStringTagSymbol in genFun)) {
|
||||
genFun[toStringTagSymbol] = "GeneratorFunction";
|
||||
}
|
||||
}
|
||||
genFun.prototype = Object.create(Gp);
|
||||
return genFun;
|
||||
};
|
||||
|
||||
// Within the body of any async function, `await x` is transformed to
|
||||
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
||||
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
||||
// meant to be awaited.
|
||||
exports.awrap = function(arg) {
|
||||
return { __await: arg };
|
||||
};
|
||||
|
||||
function AsyncIterator(generator, PromiseImpl) {
|
||||
function invoke(method, arg, resolve, reject) {
|
||||
var record = tryCatch(generator[method], generator, arg);
|
||||
if (record.type === "throw") {
|
||||
reject(record.arg);
|
||||
} else {
|
||||
var result = record.arg;
|
||||
var value = result.value;
|
||||
if (value &&
|
||||
typeof value === "object" &&
|
||||
hasOwn.call(value, "__await")) {
|
||||
return PromiseImpl.resolve(value.__await).then(function(value) {
|
||||
invoke("next", value, resolve, reject);
|
||||
}, function(err) {
|
||||
invoke("throw", err, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
return PromiseImpl.resolve(value).then(function(unwrapped) {
|
||||
// When a yielded Promise is resolved, its final value becomes
|
||||
// the .value of the Promise<{value,done}> result for the
|
||||
// current iteration.
|
||||
result.value = unwrapped;
|
||||
resolve(result);
|
||||
}, function(error) {
|
||||
// If a rejected Promise was yielded, throw the rejection back
|
||||
// into the async generator function so it can be handled there.
|
||||
return invoke("throw", error, resolve, reject);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var previousPromise;
|
||||
|
||||
function enqueue(method, arg) {
|
||||
function callInvokeWithMethodAndArg() {
|
||||
return new PromiseImpl(function(resolve, reject) {
|
||||
invoke(method, arg, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
return previousPromise =
|
||||
// If enqueue has been called before, then we want to wait until
|
||||
// all previous Promises have been resolved before calling invoke,
|
||||
// so that results are always delivered in the correct order. If
|
||||
// enqueue has not been called before, then it is important to
|
||||
// call invoke immediately, without waiting on a callback to fire,
|
||||
// so that the async generator function has the opportunity to do
|
||||
// any necessary setup in a predictable way. This predictability
|
||||
// is why the Promise constructor synchronously invokes its
|
||||
// executor callback, and why async functions synchronously
|
||||
// execute code before the first await. Since we implement simple
|
||||
// async functions in terms of async generators, it is especially
|
||||
// important to get this right, even though it requires care.
|
||||
previousPromise ? previousPromise.then(
|
||||
callInvokeWithMethodAndArg,
|
||||
// Avoid propagating failures to Promises returned by later
|
||||
// invocations of the iterator.
|
||||
callInvokeWithMethodAndArg
|
||||
) : callInvokeWithMethodAndArg();
|
||||
}
|
||||
|
||||
// Define the unified helper method that is used to implement .next,
|
||||
// .throw, and .return (see defineIteratorMethods).
|
||||
this._invoke = enqueue;
|
||||
}
|
||||
|
||||
defineIteratorMethods(AsyncIterator.prototype);
|
||||
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
||||
return this;
|
||||
};
|
||||
exports.AsyncIterator = AsyncIterator;
|
||||
|
||||
// Note that simple async functions are implemented on top of
|
||||
// AsyncIterator objects; they just return a Promise for the value of
|
||||
// the final result produced by the iterator.
|
||||
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
||||
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
||||
|
||||
var iter = new AsyncIterator(
|
||||
wrap(innerFn, outerFn, self, tryLocsList),
|
||||
PromiseImpl
|
||||
);
|
||||
|
||||
return exports.isGeneratorFunction(outerFn)
|
||||
? iter // If outerFn is a generator, return the full iterator.
|
||||
: iter.next().then(function(result) {
|
||||
return result.done ? result.value : iter.next();
|
||||
});
|
||||
};
|
||||
|
||||
function makeInvokeMethod(innerFn, self, context) {
|
||||
var state = GenStateSuspendedStart;
|
||||
|
||||
return function invoke(method, arg) {
|
||||
if (state === GenStateExecuting) {
|
||||
throw new Error("Generator is already running");
|
||||
}
|
||||
|
||||
if (state === GenStateCompleted) {
|
||||
if (method === "throw") {
|
||||
throw arg;
|
||||
}
|
||||
|
||||
// Be forgiving, per 25.3.3.3.3 of the spec:
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
||||
return doneResult();
|
||||
}
|
||||
|
||||
context.method = method;
|
||||
context.arg = arg;
|
||||
|
||||
while (true) {
|
||||
var delegate = context.delegate;
|
||||
if (delegate) {
|
||||
var delegateResult = maybeInvokeDelegate(delegate, context);
|
||||
if (delegateResult) {
|
||||
if (delegateResult === ContinueSentinel) continue;
|
||||
return delegateResult;
|
||||
}
|
||||
}
|
||||
|
||||
if (context.method === "next") {
|
||||
// Setting context._sent for legacy support of Babel's
|
||||
// function.sent implementation.
|
||||
context.sent = context._sent = context.arg;
|
||||
|
||||
} else if (context.method === "throw") {
|
||||
if (state === GenStateSuspendedStart) {
|
||||
state = GenStateCompleted;
|
||||
throw context.arg;
|
||||
}
|
||||
|
||||
context.dispatchException(context.arg);
|
||||
|
||||
} else if (context.method === "return") {
|
||||
context.abrupt("return", context.arg);
|
||||
}
|
||||
|
||||
state = GenStateExecuting;
|
||||
|
||||
var record = tryCatch(innerFn, self, context);
|
||||
if (record.type === "normal") {
|
||||
// If an exception is thrown from innerFn, we leave state ===
|
||||
// GenStateExecuting and loop back for another invocation.
|
||||
state = context.done
|
||||
? GenStateCompleted
|
||||
: GenStateSuspendedYield;
|
||||
|
||||
if (record.arg === ContinueSentinel) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return {
|
||||
value: record.arg,
|
||||
done: context.done
|
||||
};
|
||||
|
||||
} else if (record.type === "throw") {
|
||||
state = GenStateCompleted;
|
||||
// Dispatch the exception by looping back around to the
|
||||
// context.dispatchException(context.arg) call above.
|
||||
context.method = "throw";
|
||||
context.arg = record.arg;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Call delegate.iterator[context.method](context.arg) and handle the
|
||||
// result, either by returning a { value, done } result from the
|
||||
// delegate iterator, or by modifying context.method and context.arg,
|
||||
// setting context.delegate to null, and returning the ContinueSentinel.
|
||||
function maybeInvokeDelegate(delegate, context) {
|
||||
var method = delegate.iterator[context.method];
|
||||
if (method === undefined) {
|
||||
// A .throw or .return when the delegate iterator has no .throw
|
||||
// method always terminates the yield* loop.
|
||||
context.delegate = null;
|
||||
|
||||
if (context.method === "throw") {
|
||||
// Note: ["return"] must be used for ES3 parsing compatibility.
|
||||
if (delegate.iterator["return"]) {
|
||||
// If the delegate iterator has a return method, give it a
|
||||
// chance to clean up.
|
||||
context.method = "return";
|
||||
context.arg = undefined;
|
||||
maybeInvokeDelegate(delegate, context);
|
||||
|
||||
if (context.method === "throw") {
|
||||
// If maybeInvokeDelegate(context) changed context.method from
|
||||
// "return" to "throw", let that override the TypeError below.
|
||||
return ContinueSentinel;
|
||||
}
|
||||
}
|
||||
|
||||
context.method = "throw";
|
||||
context.arg = new TypeError(
|
||||
"The iterator does not provide a 'throw' method");
|
||||
}
|
||||
|
||||
return ContinueSentinel;
|
||||
}
|
||||
|
||||
var record = tryCatch(method, delegate.iterator, context.arg);
|
||||
|
||||
if (record.type === "throw") {
|
||||
context.method = "throw";
|
||||
context.arg = record.arg;
|
||||
context.delegate = null;
|
||||
return ContinueSentinel;
|
||||
}
|
||||
|
||||
var info = record.arg;
|
||||
|
||||
if (! info) {
|
||||
context.method = "throw";
|
||||
context.arg = new TypeError("iterator result is not an object");
|
||||
context.delegate = null;
|
||||
return ContinueSentinel;
|
||||
}
|
||||
|
||||
if (info.done) {
|
||||
// Assign the result of the finished delegate to the temporary
|
||||
// variable specified by delegate.resultName (see delegateYield).
|
||||
context[delegate.resultName] = info.value;
|
||||
|
||||
// Resume execution at the desired location (see delegateYield).
|
||||
context.next = delegate.nextLoc;
|
||||
|
||||
// If context.method was "throw" but the delegate handled the
|
||||
// exception, let the outer generator proceed normally. If
|
||||
// context.method was "next", forget context.arg since it has been
|
||||
// "consumed" by the delegate iterator. If context.method was
|
||||
// "return", allow the original .return call to continue in the
|
||||
// outer generator.
|
||||
if (context.method !== "return") {
|
||||
context.method = "next";
|
||||
context.arg = undefined;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Re-yield the result returned by the delegate method.
|
||||
return info;
|
||||
}
|
||||
|
||||
// The delegate iterator is finished, so forget it and continue with
|
||||
// the outer generator.
|
||||
context.delegate = null;
|
||||
return ContinueSentinel;
|
||||
}
|
||||
|
||||
// Define Generator.prototype.{next,throw,return} in terms of the
|
||||
// unified ._invoke helper method.
|
||||
defineIteratorMethods(Gp);
|
||||
|
||||
Gp[toStringTagSymbol] = "Generator";
|
||||
|
||||
// A Generator should always return itself as the iterator object when the
|
||||
// @@iterator function is called on it. Some browsers' implementations of the
|
||||
// iterator prototype chain incorrectly implement this, causing the Generator
|
||||
// object to not be returned from this call. This ensures that doesn't happen.
|
||||
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
||||
Gp[iteratorSymbol] = function() {
|
||||
return this;
|
||||
};
|
||||
|
||||
Gp.toString = function() {
|
||||
return "[object Generator]";
|
||||
};
|
||||
|
||||
function pushTryEntry(locs) {
|
||||
var entry = { tryLoc: locs[0] };
|
||||
|
||||
if (1 in locs) {
|
||||
entry.catchLoc = locs[1];
|
||||
}
|
||||
|
||||
if (2 in locs) {
|
||||
entry.finallyLoc = locs[2];
|
||||
entry.afterLoc = locs[3];
|
||||
}
|
||||
|
||||
this.tryEntries.push(entry);
|
||||
}
|
||||
|
||||
function resetTryEntry(entry) {
|
||||
var record = entry.completion || {};
|
||||
record.type = "normal";
|
||||
delete record.arg;
|
||||
entry.completion = record;
|
||||
}
|
||||
|
||||
function Context(tryLocsList) {
|
||||
// The root entry object (effectively a try statement without a catch
|
||||
// or a finally block) gives us a place to store values thrown from
|
||||
// locations where there is no enclosing try statement.
|
||||
this.tryEntries = [{ tryLoc: "root" }];
|
||||
tryLocsList.forEach(pushTryEntry, this);
|
||||
this.reset(true);
|
||||
}
|
||||
|
||||
exports.keys = function(object) {
|
||||
var keys = [];
|
||||
for (var key in object) {
|
||||
keys.push(key);
|
||||
}
|
||||
keys.reverse();
|
||||
|
||||
// Rather than returning an object with a next method, we keep
|
||||
// things simple and return the next function itself.
|
||||
return function next() {
|
||||
while (keys.length) {
|
||||
var key = keys.pop();
|
||||
if (key in object) {
|
||||
next.value = key;
|
||||
next.done = false;
|
||||
return next;
|
||||
}
|
||||
}
|
||||
|
||||
// To avoid creating an additional object, we just hang the .value
|
||||
// and .done properties off the next function object itself. This
|
||||
// also ensures that the minifier will not anonymize the function.
|
||||
next.done = true;
|
||||
return next;
|
||||
};
|
||||
};
|
||||
|
||||
function values(iterable) {
|
||||
if (iterable) {
|
||||
var iteratorMethod = iterable[iteratorSymbol];
|
||||
if (iteratorMethod) {
|
||||
return iteratorMethod.call(iterable);
|
||||
}
|
||||
|
||||
if (typeof iterable.next === "function") {
|
||||
return iterable;
|
||||
}
|
||||
|
||||
if (!isNaN(iterable.length)) {
|
||||
var i = -1, next = function next() {
|
||||
while (++i < iterable.length) {
|
||||
if (hasOwn.call(iterable, i)) {
|
||||
next.value = iterable[i];
|
||||
next.done = false;
|
||||
return next;
|
||||
}
|
||||
}
|
||||
|
||||
next.value = undefined;
|
||||
next.done = true;
|
||||
|
||||
return next;
|
||||
};
|
||||
|
||||
return next.next = next;
|
||||
}
|
||||
}
|
||||
|
||||
// Return an iterator with no values.
|
||||
return { next: doneResult };
|
||||
}
|
||||
exports.values = values;
|
||||
|
||||
function doneResult() {
|
||||
return { value: undefined, done: true };
|
||||
}
|
||||
|
||||
Context.prototype = {
|
||||
constructor: Context,
|
||||
|
||||
reset: function(skipTempReset) {
|
||||
this.prev = 0;
|
||||
this.next = 0;
|
||||
// Resetting context._sent for legacy support of Babel's
|
||||
// function.sent implementation.
|
||||
this.sent = this._sent = undefined;
|
||||
this.done = false;
|
||||
this.delegate = null;
|
||||
|
||||
this.method = "next";
|
||||
this.arg = undefined;
|
||||
|
||||
this.tryEntries.forEach(resetTryEntry);
|
||||
|
||||
if (!skipTempReset) {
|
||||
for (var name in this) {
|
||||
// Not sure about the optimal order of these conditions:
|
||||
if (name.charAt(0) === "t" &&
|
||||
hasOwn.call(this, name) &&
|
||||
!isNaN(+name.slice(1))) {
|
||||
this[name] = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
this.done = true;
|
||||
|
||||
var rootEntry = this.tryEntries[0];
|
||||
var rootRecord = rootEntry.completion;
|
||||
if (rootRecord.type === "throw") {
|
||||
throw rootRecord.arg;
|
||||
}
|
||||
|
||||
return this.rval;
|
||||
},
|
||||
|
||||
dispatchException: function(exception) {
|
||||
if (this.done) {
|
||||
throw exception;
|
||||
}
|
||||
|
||||
var context = this;
|
||||
function handle(loc, caught) {
|
||||
record.type = "throw";
|
||||
record.arg = exception;
|
||||
context.next = loc;
|
||||
|
||||
if (caught) {
|
||||
// If the dispatched exception was caught by a catch block,
|
||||
// then let that catch block handle the exception normally.
|
||||
context.method = "next";
|
||||
context.arg = undefined;
|
||||
}
|
||||
|
||||
return !! caught;
|
||||
}
|
||||
|
||||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||||
var entry = this.tryEntries[i];
|
||||
var record = entry.completion;
|
||||
|
||||
if (entry.tryLoc === "root") {
|
||||
// Exception thrown outside of any try block that could handle
|
||||
// it, so set the completion value of the entire function to
|
||||
// throw the exception.
|
||||
return handle("end");
|
||||
}
|
||||
|
||||
if (entry.tryLoc <= this.prev) {
|
||||
var hasCatch = hasOwn.call(entry, "catchLoc");
|
||||
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
||||
|
||||
if (hasCatch && hasFinally) {
|
||||
if (this.prev < entry.catchLoc) {
|
||||
return handle(entry.catchLoc, true);
|
||||
} else if (this.prev < entry.finallyLoc) {
|
||||
return handle(entry.finallyLoc);
|
||||
}
|
||||
|
||||
} else if (hasCatch) {
|
||||
if (this.prev < entry.catchLoc) {
|
||||
return handle(entry.catchLoc, true);
|
||||
}
|
||||
|
||||
} else if (hasFinally) {
|
||||
if (this.prev < entry.finallyLoc) {
|
||||
return handle(entry.finallyLoc);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error("try statement without catch or finally");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
abrupt: function(type, arg) {
|
||||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||||
var entry = this.tryEntries[i];
|
||||
if (entry.tryLoc <= this.prev &&
|
||||
hasOwn.call(entry, "finallyLoc") &&
|
||||
this.prev < entry.finallyLoc) {
|
||||
var finallyEntry = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (finallyEntry &&
|
||||
(type === "break" ||
|
||||
type === "continue") &&
|
||||
finallyEntry.tryLoc <= arg &&
|
||||
arg <= finallyEntry.finallyLoc) {
|
||||
// Ignore the finally entry if control is not jumping to a
|
||||
// location outside the try/catch block.
|
||||
finallyEntry = null;
|
||||
}
|
||||
|
||||
var record = finallyEntry ? finallyEntry.completion : {};
|
||||
record.type = type;
|
||||
record.arg = arg;
|
||||
|
||||
if (finallyEntry) {
|
||||
this.method = "next";
|
||||
this.next = finallyEntry.finallyLoc;
|
||||
return ContinueSentinel;
|
||||
}
|
||||
|
||||
return this.complete(record);
|
||||
},
|
||||
|
||||
complete: function(record, afterLoc) {
|
||||
if (record.type === "throw") {
|
||||
throw record.arg;
|
||||
}
|
||||
|
||||
if (record.type === "break" ||
|
||||
record.type === "continue") {
|
||||
this.next = record.arg;
|
||||
} else if (record.type === "return") {
|
||||
this.rval = this.arg = record.arg;
|
||||
this.method = "return";
|
||||
this.next = "end";
|
||||
} else if (record.type === "normal" && afterLoc) {
|
||||
this.next = afterLoc;
|
||||
}
|
||||
|
||||
return ContinueSentinel;
|
||||
},
|
||||
|
||||
finish: function(finallyLoc) {
|
||||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||||
var entry = this.tryEntries[i];
|
||||
if (entry.finallyLoc === finallyLoc) {
|
||||
this.complete(entry.completion, entry.afterLoc);
|
||||
resetTryEntry(entry);
|
||||
return ContinueSentinel;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"catch": function(tryLoc) {
|
||||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||||
var entry = this.tryEntries[i];
|
||||
if (entry.tryLoc === tryLoc) {
|
||||
var record = entry.completion;
|
||||
if (record.type === "throw") {
|
||||
var thrown = record.arg;
|
||||
resetTryEntry(entry);
|
||||
}
|
||||
return thrown;
|
||||
}
|
||||
}
|
||||
|
||||
// The context.catch method must only be called with a location
|
||||
// argument that corresponds to a known catch block.
|
||||
throw new Error("illegal catch attempt");
|
||||
},
|
||||
|
||||
delegateYield: function(iterable, resultName, nextLoc) {
|
||||
this.delegate = {
|
||||
iterator: values(iterable),
|
||||
resultName: resultName,
|
||||
nextLoc: nextLoc
|
||||
};
|
||||
|
||||
if (this.method === "next") {
|
||||
// Deliberately forget the last sent value so that we don't
|
||||
// accidentally pass it on to the delegate.
|
||||
this.arg = undefined;
|
||||
}
|
||||
|
||||
return ContinueSentinel;
|
||||
}
|
||||
};
|
||||
|
||||
// Regardless of whether this script is executing as a CommonJS module
|
||||
// or not, return the runtime object so that we can declare the variable
|
||||
// regeneratorRuntime in the outer scope, which allows this module to be
|
||||
// injected easily by `bin/regenerator --include-runtime script.js`.
|
||||
return exports;
|
||||
|
||||
}(
|
||||
// If this script is executing as a CommonJS module, use module.exports
|
||||
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
||||
// object. Either way, the resulting object will be used to initialize
|
||||
// the regeneratorRuntime variable at the top of this file.
|
||||
typeof module === "object" ? module.exports : {}
|
||||
));
|
||||
|
||||
try {
|
||||
regeneratorRuntime = runtime;
|
||||
} catch (accidentalStrictMode) {
|
||||
// This module should not be running in strict mode, so the above
|
||||
// assignment should always work unless something is misconfigured. Just
|
||||
// in case runtime.js accidentally runs in strict mode, we can escape
|
||||
// strict mode using a global Function call. This could conceivably fail
|
||||
// if a Content Security Policy forbids using Function, but in that case
|
||||
// the proper solution is to fix the accidental strict mode problem. If
|
||||
// you've misconfigured your bundler to force strict mode and applied a
|
||||
// CSP to forbid Function, and you're not willing to fix either of those
|
||||
// problems, please detail your unique predicament in a GitHub issue.
|
||||
Function("r", "regeneratorRuntime = r")(runtime);
|
||||
}
|
||||
580
src/external/stackblur-canvas/dist/stackblur-es.js
vendored
Normal file
580
src/external/stackblur-canvas/dist/stackblur-es.js
vendored
Normal file
@@ -0,0 +1,580 @@
|
||||
function _typeof(obj) {
|
||||
"@babel/helpers - typeof";
|
||||
|
||||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||||
_typeof = function (obj) {
|
||||
return typeof obj;
|
||||
};
|
||||
} else {
|
||||
_typeof = function (obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||||
};
|
||||
}
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable no-bitwise, unicorn/prefer-query-selector */
|
||||
|
||||
/**
|
||||
* StackBlur - a fast almost Gaussian Blur For Canvas
|
||||
*
|
||||
* In case you find this class useful - especially in commercial projects -
|
||||
* I am not totally unhappy for a small donation to my PayPal account
|
||||
* mario@quasimondo.de
|
||||
*
|
||||
* Or support me on flattr:
|
||||
* {@link https://flattr.com/thing/72791/StackBlur-a-fast-almost-Gaussian-Blur-Effect-for-CanvasJavascript}.
|
||||
*
|
||||
* @module StackBlur
|
||||
* @author Mario Klingemann
|
||||
* Contact: mario@quasimondo.com
|
||||
* Website: {@link http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html}
|
||||
* Twitter: @quasimondo
|
||||
*
|
||||
* @copyright (c) 2010 Mario Klingemann
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* eslint-disable max-len */
|
||||
var mulTable = [512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259];
|
||||
var shgTable = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24];
|
||||
/* eslint-enable max-len */
|
||||
|
||||
/**
|
||||
* @param {string|HTMLImageElement} img
|
||||
* @param {string|HTMLCanvasElement} canvas
|
||||
* @param {Float} radius
|
||||
* @param {boolean} blurAlphaChannel
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
function processImage(img, canvas, radius, blurAlphaChannel) {
|
||||
if (typeof img === 'string') {
|
||||
img = document.getElementById(img);
|
||||
}
|
||||
|
||||
if (!img || !('naturalWidth' in img)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var w = img.naturalWidth;
|
||||
var h = img.naturalHeight;
|
||||
|
||||
if (typeof canvas === 'string') {
|
||||
canvas = document.getElementById(canvas);
|
||||
}
|
||||
|
||||
if (!canvas || !('getContext' in canvas)) {
|
||||
return;
|
||||
}
|
||||
|
||||
canvas.style.width = w + 'px';
|
||||
canvas.style.height = h + 'px';
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
var context = canvas.getContext('2d');
|
||||
context.clearRect(0, 0, w, h);
|
||||
context.drawImage(img, 0, 0);
|
||||
|
||||
if (isNaN(radius) || radius < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (blurAlphaChannel) {
|
||||
processCanvasRGBA(canvas, 0, 0, w, h, radius);
|
||||
} else {
|
||||
processCanvasRGB(canvas, 0, 0, w, h, radius);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param {string|HTMLCanvasElement} canvas
|
||||
* @param {Integer} topX
|
||||
* @param {Integer} topY
|
||||
* @param {Integer} width
|
||||
* @param {Integer} height
|
||||
* @throws {Error|TypeError}
|
||||
* @returns {ImageData} See {@link https://html.spec.whatwg.org/multipage/canvas.html#imagedata}
|
||||
*/
|
||||
|
||||
|
||||
function getImageDataFromCanvas(canvas, topX, topY, width, height) {
|
||||
if (typeof canvas === 'string') {
|
||||
canvas = document.getElementById(canvas);
|
||||
}
|
||||
|
||||
if (!canvas || _typeof(canvas) !== 'object' || !('getContext' in canvas)) {
|
||||
throw new TypeError('Expecting canvas with `getContext` method ' + 'in processCanvasRGB(A) calls!');
|
||||
}
|
||||
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
try {
|
||||
return context.getImageData(topX, topY, width, height);
|
||||
} catch (e) {
|
||||
throw new Error('unable to access image data: ' + e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param {HTMLCanvasElement} canvas
|
||||
* @param {Integer} topX
|
||||
* @param {Integer} topY
|
||||
* @param {Integer} width
|
||||
* @param {Integer} height
|
||||
* @param {Float} radius
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function processCanvasRGBA(canvas, topX, topY, width, height, radius) {
|
||||
if (isNaN(radius) || radius < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
radius |= 0;
|
||||
var imageData = getImageDataFromCanvas(canvas, topX, topY, width, height);
|
||||
imageData = processImageDataRGBA(imageData, topX, topY, width, height, radius);
|
||||
canvas.getContext('2d').putImageData(imageData, topX, topY);
|
||||
}
|
||||
/**
|
||||
* @param {ImageData} imageData
|
||||
* @param {Integer} topX
|
||||
* @param {Integer} topY
|
||||
* @param {Integer} width
|
||||
* @param {Integer} height
|
||||
* @param {Float} radius
|
||||
* @returns {ImageData}
|
||||
*/
|
||||
|
||||
|
||||
function processImageDataRGBA(imageData, topX, topY, width, height, radius) {
|
||||
var pixels = imageData.data;
|
||||
var x, y, i, p, yp, yi, yw, rSum, gSum, bSum, aSum, rOutSum, gOutSum, bOutSum, aOutSum, rInSum, gInSum, bInSum, aInSum, pr, pg, pb, pa, rbs;
|
||||
var div = 2 * radius + 1; // const w4 = width << 2;
|
||||
|
||||
var widthMinus1 = width - 1;
|
||||
var heightMinus1 = height - 1;
|
||||
var radiusPlus1 = radius + 1;
|
||||
var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;
|
||||
var stackStart = new BlurStack();
|
||||
var stack = stackStart;
|
||||
var stackEnd;
|
||||
|
||||
for (i = 1; i < div; i++) {
|
||||
stack = stack.next = new BlurStack();
|
||||
|
||||
if (i === radiusPlus1) {
|
||||
stackEnd = stack;
|
||||
}
|
||||
}
|
||||
|
||||
stack.next = stackStart;
|
||||
var stackIn = null;
|
||||
var stackOut = null;
|
||||
yw = yi = 0;
|
||||
var mulSum = mulTable[radius];
|
||||
var shgSum = shgTable[radius];
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
rInSum = gInSum = bInSum = aInSum = rSum = gSum = bSum = aSum = 0;
|
||||
rOutSum = radiusPlus1 * (pr = pixels[yi]);
|
||||
gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);
|
||||
bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);
|
||||
aOutSum = radiusPlus1 * (pa = pixels[yi + 3]);
|
||||
rSum += sumFactor * pr;
|
||||
gSum += sumFactor * pg;
|
||||
bSum += sumFactor * pb;
|
||||
aSum += sumFactor * pa;
|
||||
stack = stackStart;
|
||||
|
||||
for (i = 0; i < radiusPlus1; i++) {
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack.a = pa;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
for (i = 1; i < radiusPlus1; i++) {
|
||||
p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
|
||||
rSum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);
|
||||
gSum += (stack.g = pg = pixels[p + 1]) * rbs;
|
||||
bSum += (stack.b = pb = pixels[p + 2]) * rbs;
|
||||
aSum += (stack.a = pa = pixels[p + 3]) * rbs;
|
||||
rInSum += pr;
|
||||
gInSum += pg;
|
||||
bInSum += pb;
|
||||
aInSum += pa;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
pixels[yi + 3] = pa = aSum * mulSum >> shgSum;
|
||||
|
||||
if (pa !== 0) {
|
||||
pa = 255 / pa;
|
||||
pixels[yi] = (rSum * mulSum >> shgSum) * pa;
|
||||
pixels[yi + 1] = (gSum * mulSum >> shgSum) * pa;
|
||||
pixels[yi + 2] = (bSum * mulSum >> shgSum) * pa;
|
||||
} else {
|
||||
pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;
|
||||
}
|
||||
|
||||
rSum -= rOutSum;
|
||||
gSum -= gOutSum;
|
||||
bSum -= bOutSum;
|
||||
aSum -= aOutSum;
|
||||
rOutSum -= stackIn.r;
|
||||
gOutSum -= stackIn.g;
|
||||
bOutSum -= stackIn.b;
|
||||
aOutSum -= stackIn.a;
|
||||
p = yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1) << 2;
|
||||
rInSum += stackIn.r = pixels[p];
|
||||
gInSum += stackIn.g = pixels[p + 1];
|
||||
bInSum += stackIn.b = pixels[p + 2];
|
||||
aInSum += stackIn.a = pixels[p + 3];
|
||||
rSum += rInSum;
|
||||
gSum += gInSum;
|
||||
bSum += bInSum;
|
||||
aSum += aInSum;
|
||||
stackIn = stackIn.next;
|
||||
rOutSum += pr = stackOut.r;
|
||||
gOutSum += pg = stackOut.g;
|
||||
bOutSum += pb = stackOut.b;
|
||||
aOutSum += pa = stackOut.a;
|
||||
rInSum -= pr;
|
||||
gInSum -= pg;
|
||||
bInSum -= pb;
|
||||
aInSum -= pa;
|
||||
stackOut = stackOut.next;
|
||||
yi += 4;
|
||||
}
|
||||
|
||||
yw += width;
|
||||
}
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
gInSum = bInSum = aInSum = rInSum = gSum = bSum = aSum = rSum = 0;
|
||||
yi = x << 2;
|
||||
rOutSum = radiusPlus1 * (pr = pixels[yi]);
|
||||
gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);
|
||||
bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);
|
||||
aOutSum = radiusPlus1 * (pa = pixels[yi + 3]);
|
||||
rSum += sumFactor * pr;
|
||||
gSum += sumFactor * pg;
|
||||
bSum += sumFactor * pb;
|
||||
aSum += sumFactor * pa;
|
||||
stack = stackStart;
|
||||
|
||||
for (i = 0; i < radiusPlus1; i++) {
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack.a = pa;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
yp = width;
|
||||
|
||||
for (i = 1; i <= radius; i++) {
|
||||
yi = yp + x << 2;
|
||||
rSum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);
|
||||
gSum += (stack.g = pg = pixels[yi + 1]) * rbs;
|
||||
bSum += (stack.b = pb = pixels[yi + 2]) * rbs;
|
||||
aSum += (stack.a = pa = pixels[yi + 3]) * rbs;
|
||||
rInSum += pr;
|
||||
gInSum += pg;
|
||||
bInSum += pb;
|
||||
aInSum += pa;
|
||||
stack = stack.next;
|
||||
|
||||
if (i < heightMinus1) {
|
||||
yp += width;
|
||||
}
|
||||
}
|
||||
|
||||
yi = x;
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
p = yi << 2;
|
||||
pixels[p + 3] = pa = aSum * mulSum >> shgSum;
|
||||
|
||||
if (pa > 0) {
|
||||
pa = 255 / pa;
|
||||
pixels[p] = (rSum * mulSum >> shgSum) * pa;
|
||||
pixels[p + 1] = (gSum * mulSum >> shgSum) * pa;
|
||||
pixels[p + 2] = (bSum * mulSum >> shgSum) * pa;
|
||||
} else {
|
||||
pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;
|
||||
}
|
||||
|
||||
rSum -= rOutSum;
|
||||
gSum -= gOutSum;
|
||||
bSum -= bOutSum;
|
||||
aSum -= aOutSum;
|
||||
rOutSum -= stackIn.r;
|
||||
gOutSum -= stackIn.g;
|
||||
bOutSum -= stackIn.b;
|
||||
aOutSum -= stackIn.a;
|
||||
p = x + ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width << 2;
|
||||
rSum += rInSum += stackIn.r = pixels[p];
|
||||
gSum += gInSum += stackIn.g = pixels[p + 1];
|
||||
bSum += bInSum += stackIn.b = pixels[p + 2];
|
||||
aSum += aInSum += stackIn.a = pixels[p + 3];
|
||||
stackIn = stackIn.next;
|
||||
rOutSum += pr = stackOut.r;
|
||||
gOutSum += pg = stackOut.g;
|
||||
bOutSum += pb = stackOut.b;
|
||||
aOutSum += pa = stackOut.a;
|
||||
rInSum -= pr;
|
||||
gInSum -= pg;
|
||||
bInSum -= pb;
|
||||
aInSum -= pa;
|
||||
stackOut = stackOut.next;
|
||||
yi += width;
|
||||
}
|
||||
}
|
||||
|
||||
return imageData;
|
||||
}
|
||||
/**
|
||||
* @param {HTMLCanvasElement} canvas
|
||||
* @param {Integer} topX
|
||||
* @param {Integer} topY
|
||||
* @param {Integer} width
|
||||
* @param {Integer} height
|
||||
* @param {Float} radius
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function processCanvasRGB(canvas, topX, topY, width, height, radius) {
|
||||
if (isNaN(radius) || radius < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
radius |= 0;
|
||||
var imageData = getImageDataFromCanvas(canvas, topX, topY, width, height);
|
||||
imageData = processImageDataRGB(imageData, topX, topY, width, height, radius);
|
||||
canvas.getContext('2d').putImageData(imageData, topX, topY);
|
||||
}
|
||||
/**
|
||||
* @param {ImageData} imageData
|
||||
* @param {Integer} topX
|
||||
* @param {Integer} topY
|
||||
* @param {Integer} width
|
||||
* @param {Integer} height
|
||||
* @param {Float} radius
|
||||
* @returns {ImageData}
|
||||
*/
|
||||
|
||||
|
||||
function processImageDataRGB(imageData, topX, topY, width, height, radius) {
|
||||
var pixels = imageData.data;
|
||||
var x, y, i, p, yp, yi, yw, rSum, gSum, bSum, rOutSum, gOutSum, bOutSum, rInSum, gInSum, bInSum, pr, pg, pb, rbs;
|
||||
var div = 2 * radius + 1; // const w4 = width << 2;
|
||||
|
||||
var widthMinus1 = width - 1;
|
||||
var heightMinus1 = height - 1;
|
||||
var radiusPlus1 = radius + 1;
|
||||
var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;
|
||||
var stackStart = new BlurStack();
|
||||
var stack = stackStart;
|
||||
var stackEnd;
|
||||
|
||||
for (i = 1; i < div; i++) {
|
||||
stack = stack.next = new BlurStack();
|
||||
|
||||
if (i === radiusPlus1) {
|
||||
stackEnd = stack;
|
||||
}
|
||||
}
|
||||
|
||||
stack.next = stackStart;
|
||||
var stackIn = null;
|
||||
var stackOut = null;
|
||||
yw = yi = 0;
|
||||
var mulSum = mulTable[radius];
|
||||
var shgSum = shgTable[radius];
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
rInSum = gInSum = bInSum = rSum = gSum = bSum = 0;
|
||||
rOutSum = radiusPlus1 * (pr = pixels[yi]);
|
||||
gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);
|
||||
bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);
|
||||
rSum += sumFactor * pr;
|
||||
gSum += sumFactor * pg;
|
||||
bSum += sumFactor * pb;
|
||||
stack = stackStart;
|
||||
|
||||
for (i = 0; i < radiusPlus1; i++) {
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
for (i = 1; i < radiusPlus1; i++) {
|
||||
p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
|
||||
rSum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);
|
||||
gSum += (stack.g = pg = pixels[p + 1]) * rbs;
|
||||
bSum += (stack.b = pb = pixels[p + 2]) * rbs;
|
||||
rInSum += pr;
|
||||
gInSum += pg;
|
||||
bInSum += pb;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
pixels[yi] = rSum * mulSum >> shgSum;
|
||||
pixels[yi + 1] = gSum * mulSum >> shgSum;
|
||||
pixels[yi + 2] = bSum * mulSum >> shgSum;
|
||||
rSum -= rOutSum;
|
||||
gSum -= gOutSum;
|
||||
bSum -= bOutSum;
|
||||
rOutSum -= stackIn.r;
|
||||
gOutSum -= stackIn.g;
|
||||
bOutSum -= stackIn.b;
|
||||
p = yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1) << 2;
|
||||
rInSum += stackIn.r = pixels[p];
|
||||
gInSum += stackIn.g = pixels[p + 1];
|
||||
bInSum += stackIn.b = pixels[p + 2];
|
||||
rSum += rInSum;
|
||||
gSum += gInSum;
|
||||
bSum += bInSum;
|
||||
stackIn = stackIn.next;
|
||||
rOutSum += pr = stackOut.r;
|
||||
gOutSum += pg = stackOut.g;
|
||||
bOutSum += pb = stackOut.b;
|
||||
rInSum -= pr;
|
||||
gInSum -= pg;
|
||||
bInSum -= pb;
|
||||
stackOut = stackOut.next;
|
||||
yi += 4;
|
||||
}
|
||||
|
||||
yw += width;
|
||||
}
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
gInSum = bInSum = rInSum = gSum = bSum = rSum = 0;
|
||||
yi = x << 2;
|
||||
rOutSum = radiusPlus1 * (pr = pixels[yi]);
|
||||
gOutSum = radiusPlus1 * (pg = pixels[yi + 1]);
|
||||
bOutSum = radiusPlus1 * (pb = pixels[yi + 2]);
|
||||
rSum += sumFactor * pr;
|
||||
gSum += sumFactor * pg;
|
||||
bSum += sumFactor * pb;
|
||||
stack = stackStart;
|
||||
|
||||
for (i = 0; i < radiusPlus1; i++) {
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
yp = width;
|
||||
|
||||
for (i = 1; i <= radius; i++) {
|
||||
yi = yp + x << 2;
|
||||
rSum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);
|
||||
gSum += (stack.g = pg = pixels[yi + 1]) * rbs;
|
||||
bSum += (stack.b = pb = pixels[yi + 2]) * rbs;
|
||||
rInSum += pr;
|
||||
gInSum += pg;
|
||||
bInSum += pb;
|
||||
stack = stack.next;
|
||||
|
||||
if (i < heightMinus1) {
|
||||
yp += width;
|
||||
}
|
||||
}
|
||||
|
||||
yi = x;
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
p = yi << 2;
|
||||
pixels[p] = rSum * mulSum >> shgSum;
|
||||
pixels[p + 1] = gSum * mulSum >> shgSum;
|
||||
pixels[p + 2] = bSum * mulSum >> shgSum;
|
||||
rSum -= rOutSum;
|
||||
gSum -= gOutSum;
|
||||
bSum -= bOutSum;
|
||||
rOutSum -= stackIn.r;
|
||||
gOutSum -= stackIn.g;
|
||||
bOutSum -= stackIn.b;
|
||||
p = x + ((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width << 2;
|
||||
rSum += rInSum += stackIn.r = pixels[p];
|
||||
gSum += gInSum += stackIn.g = pixels[p + 1];
|
||||
bSum += bInSum += stackIn.b = pixels[p + 2];
|
||||
stackIn = stackIn.next;
|
||||
rOutSum += pr = stackOut.r;
|
||||
gOutSum += pg = stackOut.g;
|
||||
bOutSum += pb = stackOut.b;
|
||||
rInSum -= pr;
|
||||
gInSum -= pg;
|
||||
bInSum -= pb;
|
||||
stackOut = stackOut.next;
|
||||
yi += width;
|
||||
}
|
||||
}
|
||||
|
||||
return imageData;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
var BlurStack =
|
||||
/**
|
||||
* Set properties.
|
||||
*/
|
||||
function BlurStack() {
|
||||
_classCallCheck(this, BlurStack);
|
||||
|
||||
this.r = 0;
|
||||
this.g = 0;
|
||||
this.b = 0;
|
||||
this.a = 0;
|
||||
this.next = null;
|
||||
};
|
||||
|
||||
export { BlurStack, processCanvasRGB as canvasRGB, processCanvasRGBA as canvasRGBA, processImage as image, processImageDataRGB as imageDataRGB, processImageDataRGBA as imageDataRGBA };
|
||||
Reference in New Issue
Block a user