ea-route-dwitter
Version:
app.use('/mountpoint', require('ea-route-dwitter')) in your express app - edit and live-preview dwitter golfing code.
1,436 lines (1,362 loc) • 771 kB
JavaScript
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
/**
* Define a module along with a payload
* @param module a name for the payload
* @param payload a function to call with (require, exports, module) params
*/
(function() {
var ACE_NAMESPACE = "";
var global = (function() { return this; })();
if (!global && typeof window != "undefined") global = window; // strict mode
if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
return;
var define = function(module, deps, payload) {
if (typeof module !== "string") {
if (define.original)
define.original.apply(this, arguments);
else {
console.error("dropping module because define wasn\'t a string.");
console.trace();
}
return;
}
if (arguments.length == 2)
payload = deps;
if (!define.modules[module]) {
define.payloads[module] = payload;
define.modules[module] = null;
}
};
define.modules = {};
define.payloads = {};
/**
* Get at functionality define()ed using the function above
*/
var _require = function(parentId, module, callback) {
if (typeof module === "string") {
var payload = lookup(parentId, module);
if (payload != undefined) {
callback && callback();
return payload;
}
} else if (Object.prototype.toString.call(module) === "[object Array]") {
var params = [];
for (var i = 0, l = module.length; i < l; ++i) {
var dep = lookup(parentId, module[i]);
if (dep == undefined && require.original)
return;
params.push(dep);
}
return callback && callback.apply(null, params) || true;
}
};
var require = function(module, callback) {
var packagedModule = _require("", module, callback);
if (packagedModule == undefined && require.original)
return require.original.apply(this, arguments);
return packagedModule;
};
var normalizeModule = function(parentId, moduleName) {
// normalize plugin requires
if (moduleName.indexOf("!") !== -1) {
var chunks = moduleName.split("!");
return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
}
// normalize relative requires
if (moduleName.charAt(0) == ".") {
var base = parentId.split("/").slice(0, -1).join("/");
moduleName = base + "/" + moduleName;
while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
var previous = moduleName;
moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
}
}
return moduleName;
};
/**
* Internal function to lookup moduleNames and resolve them by calling the
* definition function if needed.
*/
var lookup = function(parentId, moduleName) {
moduleName = normalizeModule(parentId, moduleName);
var module = define.modules[moduleName];
if (!module) {
module = define.payloads[moduleName];
if (typeof module === 'function') {
var exports = {};
var mod = {
id: moduleName,
uri: '',
exports: exports,
packaged: true
};
var req = function(module, callback) {
return _require(moduleName, module, callback);
};
var returnValue = module(req, exports, mod);
exports = returnValue || mod.exports;
define.modules[moduleName] = exports;
delete define.payloads[moduleName];
}
module = define.modules[moduleName] = exports || module;
}
return module;
};
function exportAce(ns) {
var root = global;
if (ns) {
if (!global[ns])
global[ns] = {};
root = global[ns];
}
if (!root.define || !root.define.packaged) {
define.original = root.define;
root.define = define;
root.define.packaged = true;
}
if (!root.require || !root.require.packaged) {
require.original = root.require;
root.require = require;
root.require.packaged = true;
}
}
exportAce(ACE_NAMESPACE);
})();
define("ace/lib/es6-shim",["require","exports","module"], function(require, exports, module){function defineProp(obj, name, val) {
Object.defineProperty(obj, name, {
value: val,
enumerable: false,
writable: true,
configurable: true
});
}
if (!String.prototype.startsWith) {
defineProp(String.prototype, "startsWith", function (searchString, position) {
position = position || 0;
return this.lastIndexOf(searchString, position) === position;
});
}
if (!String.prototype.endsWith) {
defineProp(String.prototype, "endsWith", function (searchString, position) {
var subjectString = this;
if (position === undefined || position > subjectString.length) {
position = subjectString.length;
}
position -= searchString.length;
var lastIndex = subjectString.indexOf(searchString, position);
return lastIndex !== -1 && lastIndex === position;
});
}
if (!String.prototype.repeat) {
defineProp(String.prototype, "repeat", function (count) {
var result = "";
var string = this;
while (count > 0) {
if (count & 1)
result += string;
if ((count >>= 1))
string += string;
}
return result;
});
}
if (!String.prototype.includes) {
defineProp(String.prototype, "includes", function (str, position) {
return this.indexOf(str, position) != -1;
});
}
if (!Object.assign) {
Object.assign = function (target) {
if (target === undefined || target === null) {
throw new TypeError("Cannot convert undefined or null to object");
}
var output = Object(target);
for (var index = 1; index < arguments.length; index++) {
var source = arguments[index];
if (source !== undefined && source !== null) {
Object.keys(source).forEach(function (key) {
output[key] = source[key];
});
}
}
return output;
};
}
if (!Object.values) {
Object.values = function (o) {
return Object.keys(o).map(function (k) {
return o[k];
});
};
}
if (!Array.prototype.find) {
defineProp(Array.prototype, "find", function (predicate) {
var len = this.length;
var thisArg = arguments[1];
for (var k = 0; k < len; k++) {
var kValue = this[k];
if (predicate.call(thisArg, kValue, k, this)) {
return kValue;
}
}
});
}
if (!Array.prototype.findIndex) {
defineProp(Array.prototype, "findIndex", function (predicate) {
var len = this.length;
var thisArg = arguments[1];
for (var k = 0; k < len; k++) {
var kValue = this[k];
if (predicate.call(thisArg, kValue, k, this)) {
return k;
}
}
});
}
if (!Array.prototype.includes) {
defineProp(Array.prototype, "includes", function (item, position) {
return this.indexOf(item, position) != -1;
});
}
if (!Array.prototype.fill) {
defineProp(Array.prototype, "fill", function (value) {
var O = this;
var len = O.length >>> 0;
var start = arguments[1];
var relativeStart = start >> 0;
var k = relativeStart < 0
? Math.max(len + relativeStart, 0)
: Math.min(relativeStart, len);
var end = arguments[2];
var relativeEnd = end === undefined ? len : end >> 0;
var final = relativeEnd < 0
? Math.max(len + relativeEnd, 0)
: Math.min(relativeEnd, len);
while (k < final) {
O[k] = value;
k++;
}
return O;
});
}
if (!Array.of) {
defineProp(Array, "of", function () {
return Array.prototype.slice.call(arguments);
});
}
});
define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/es6-shim"], function(require, exports, module){// vim:set ts=4 sts=4 sw=4 st:
"use strict";
require("./es6-shim");
});
define("ace/lib/lang",["require","exports","module"], function(require, exports, module){"use strict";
exports.last = function (a) {
return a[a.length - 1];
};
exports.stringReverse = function (string) {
return string.split("").reverse().join("");
};
exports.stringRepeat = function (string, count) {
var result = '';
while (count > 0) {
if (count & 1)
result += string;
if (count >>= 1)
string += string;
}
return result;
};
var trimBeginRegexp = /^\s\s*/;
var trimEndRegexp = /\s\s*$/;
exports.stringTrimLeft = function (string) {
return string.replace(trimBeginRegexp, '');
};
exports.stringTrimRight = function (string) {
return string.replace(trimEndRegexp, '');
};
exports.copyObject = function (obj) {
var copy = {};
for (var key in obj) {
copy[key] = obj[key];
}
return copy;
};
exports.copyArray = function (array) {
var copy = [];
for (var i = 0, l = array.length; i < l; i++) {
if (array[i] && typeof array[i] == "object")
copy[i] = this.copyObject(array[i]);
else
copy[i] = array[i];
}
return copy;
};
exports.deepCopy = function deepCopy(obj) {
if (typeof obj !== "object" || !obj)
return obj;
var copy;
if (Array.isArray(obj)) {
copy = [];
for (var key = 0; key < obj.length; key++) {
copy[key] = deepCopy(obj[key]);
}
return copy;
}
if (Object.prototype.toString.call(obj) !== "[object Object]")
return obj;
copy = {};
for (var key in obj)
copy[key] = deepCopy(obj[key]);
return copy;
};
exports.arrayToMap = function (arr) {
var map = {};
for (var i = 0; i < arr.length; i++) {
map[arr[i]] = 1;
}
return map;
};
exports.createMap = function (props) {
var map = Object.create(null);
for (var i in props) {
map[i] = props[i];
}
return map;
};
exports.arrayRemove = function (array, value) {
for (var i = 0; i <= array.length; i++) {
if (value === array[i]) {
array.splice(i, 1);
}
}
};
exports.escapeRegExp = function (str) {
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
};
exports.escapeHTML = function (str) {
return ("" + str).replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<");
};
exports.getMatchOffsets = function (string, regExp) {
var matches = [];
string.replace(regExp, function (str) {
matches.push({
offset: arguments[arguments.length - 2],
length: str.length
});
});
return matches;
};
exports.deferredCall = function (fcn) {
var timer = null;
var callback = function () {
timer = null;
fcn();
};
var deferred = function (timeout) {
deferred.cancel();
timer = setTimeout(callback, timeout || 0);
return deferred;
};
deferred.schedule = deferred;
deferred.call = function () {
this.cancel();
fcn();
return deferred;
};
deferred.cancel = function () {
clearTimeout(timer);
timer = null;
return deferred;
};
deferred.isPending = function () {
return timer;
};
return deferred;
};
exports.delayedCall = function (fcn, defaultTimeout) {
var timer = null;
var callback = function () {
timer = null;
fcn();
};
var _self = function (timeout) {
if (timer == null)
timer = setTimeout(callback, timeout || defaultTimeout);
};
_self.delay = function (timeout) {
timer && clearTimeout(timer);
timer = setTimeout(callback, timeout || defaultTimeout);
};
_self.schedule = _self;
_self.call = function () {
this.cancel();
fcn();
};
_self.cancel = function () {
timer && clearTimeout(timer);
timer = null;
};
_self.isPending = function () {
return timer;
};
return _self;
};
});
define("ace/lib/oop",["require","exports","module"], function(require, exports, module){"use strict";
exports.inherits = function (ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
exports.mixin = function (obj, mixin) {
for (var key in mixin) {
obj[key] = mixin[key];
}
return obj;
};
exports.implement = function (proto, mixin) {
exports.mixin(proto, mixin);
};
});
define("ace/lib/useragent",["require","exports","module"], function(require, exports, module){"use strict";
exports.OS = {
LINUX: "LINUX",
MAC: "MAC",
WINDOWS: "WINDOWS"
};
exports.getOS = function () {
if (exports.isMac) {
return exports.OS.MAC;
}
else if (exports.isLinux) {
return exports.OS.LINUX;
}
else {
return exports.OS.WINDOWS;
}
};
var _navigator = typeof navigator == "object" ? navigator : {};
var os = (/mac|win|linux/i.exec(_navigator.platform) || ["other"])[0].toLowerCase();
var ua = _navigator.userAgent || "";
var appName = _navigator.appName || "";
exports.isWin = (os == "win");
exports.isMac = (os == "mac");
exports.isLinux = (os == "linux");
exports.isIE =
(appName == "Microsoft Internet Explorer" || appName.indexOf("MSAppHost") >= 0)
? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/) || [])[1])
: parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/) || [])[1]); // for ie
exports.isOldIE = exports.isIE && exports.isIE < 9;
exports.isGecko = exports.isMozilla = ua.match(/ Gecko\/\d+/);
exports.isOpera = typeof opera == "object" && Object.prototype.toString.call(window.opera) == "[object Opera]";
exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
exports.isEdge = parseFloat(ua.split(" Edge/")[1]) || undefined;
exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
exports.isAndroid = ua.indexOf("Android") >= 0;
exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
exports.isIOS = /iPad|iPhone|iPod/.test(ua) && !window.MSStream;
if (exports.isIOS)
exports.isMac = true;
exports.isMobile = exports.isIOS || exports.isAndroid;
});
define("ace/lib/dom",["require","exports","module","ace/lib/useragent"], function(require, exports, module){"use strict";
var useragent = require("./useragent");
var XHTML_NS = "http://www.w3.org/1999/xhtml";
exports.buildDom = function buildDom(arr, parent, refs) {
if (typeof arr == "string" && arr) {
var txt = document.createTextNode(arr);
if (parent)
parent.appendChild(txt);
return txt;
}
if (!Array.isArray(arr)) {
if (arr && arr.appendChild && parent)
parent.appendChild(arr);
return arr;
}
if (typeof arr[0] != "string" || !arr[0]) {
var els = [];
for (var i = 0; i < arr.length; i++) {
var ch = buildDom(arr[i], parent, refs);
ch && els.push(ch);
}
return els;
}
var el = document.createElement(arr[0]);
var options = arr[1];
var childIndex = 1;
if (options && typeof options == "object" && !Array.isArray(options))
childIndex = 2;
for (var i = childIndex; i < arr.length; i++)
buildDom(arr[i], el, refs);
if (childIndex == 2) {
Object.keys(options).forEach(function (n) {
var val = options[n];
if (n === "class") {
el.className = Array.isArray(val) ? val.join(" ") : val;
}
else if (typeof val == "function" || n == "value" || n[0] == "$") {
el[n] = val;
}
else if (n === "ref") {
if (refs)
refs[val] = el;
}
else if (n === "style") {
if (typeof val == "string")
el.style.cssText = val;
}
else if (val != null) {
el.setAttribute(n, val);
}
});
}
if (parent)
parent.appendChild(el);
return el;
};
exports.getDocumentHead = function (doc) {
if (!doc)
doc = document;
return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
};
exports.createElement = function (tag, ns) {
return document.createElementNS ?
document.createElementNS(ns || XHTML_NS, tag) :
document.createElement(tag);
};
exports.removeChildren = function (element) {
element.innerHTML = "";
};
exports.createTextNode = function (textContent, element) {
var doc = element ? element.ownerDocument : document;
return doc.createTextNode(textContent);
};
exports.createFragment = function (element) {
var doc = element ? element.ownerDocument : document;
return doc.createDocumentFragment();
};
exports.hasCssClass = function (el, name) {
var classes = (el.className + "").split(/\s+/g);
return classes.indexOf(name) !== -1;
};
exports.addCssClass = function (el, name) {
if (!exports.hasCssClass(el, name)) {
el.className += " " + name;
}
};
exports.removeCssClass = function (el, name) {
var classes = el.className.split(/\s+/g);
while (true) {
var index = classes.indexOf(name);
if (index == -1) {
break;
}
classes.splice(index, 1);
}
el.className = classes.join(" ");
};
exports.toggleCssClass = function (el, name) {
var classes = el.className.split(/\s+/g), add = true;
while (true) {
var index = classes.indexOf(name);
if (index == -1) {
break;
}
add = false;
classes.splice(index, 1);
}
if (add)
classes.push(name);
el.className = classes.join(" ");
return add;
};
exports.setCssClass = function (node, className, include) {
if (include) {
exports.addCssClass(node, className);
}
else {
exports.removeCssClass(node, className);
}
};
exports.hasCssString = function (id, doc) {
var index = 0, sheets;
doc = doc || document;
if ((sheets = doc.querySelectorAll("style"))) {
while (index < sheets.length) {
if (sheets[index++].id === id) {
return true;
}
}
}
};
exports.removeElementById = function (id, doc) {
doc = doc || document;
if (doc.getElementById(id)) {
doc.getElementById(id).remove();
}
};
var strictCSP;
var cssCache = [];
exports.useStrictCSP = function (value) {
strictCSP = value;
if (value == false)
insertPendingStyles();
else if (!cssCache)
cssCache = [];
};
function insertPendingStyles() {
var cache = cssCache;
cssCache = null;
cache && cache.forEach(function (item) {
importCssString(item[0], item[1]);
});
}
function importCssString(cssText, id, target) {
if (typeof document == "undefined")
return;
if (cssCache) {
if (target) {
insertPendingStyles();
}
else if (target === false) {
return cssCache.push([cssText, id]);
}
}
if (strictCSP)
return;
var container = target;
if (!target || !target.getRootNode) {
container = document;
}
else {
container = target.getRootNode();
if (!container || container == target)
container = document;
}
var doc = container.ownerDocument || container;
if (id && exports.hasCssString(id, container))
return null;
if (id)
cssText += "\n/*# sourceURL=ace/css/" + id + " */";
var style = exports.createElement("style");
style.appendChild(doc.createTextNode(cssText));
if (id)
style.id = id;
if (container == doc)
container = exports.getDocumentHead(doc);
container.insertBefore(style, container.firstChild);
}
exports.importCssString = importCssString;
exports.importCssStylsheet = function (uri, doc) {
exports.buildDom(["link", { rel: "stylesheet", href: uri }], exports.getDocumentHead(doc));
};
exports.scrollbarWidth = function (doc) {
var inner = exports.createElement("ace_inner");
inner.style.width = "100%";
inner.style.minWidth = "0px";
inner.style.height = "200px";
inner.style.display = "block";
var outer = exports.createElement("ace_outer");
var style = outer.style;
style.position = "absolute";
style.left = "-10000px";
style.overflow = "hidden";
style.width = "200px";
style.minWidth = "0px";
style.height = "150px";
style.display = "block";
outer.appendChild(inner);
var body = (doc && doc.documentElement) || (document && document.documentElement);
if (!body)
return 0;
body.appendChild(outer);
var noScrollbar = inner.offsetWidth;
style.overflow = "scroll";
var withScrollbar = inner.offsetWidth;
if (noScrollbar === withScrollbar) {
withScrollbar = outer.clientWidth;
}
body.removeChild(outer);
return noScrollbar - withScrollbar;
};
exports.computedStyle = function (element, style) {
return window.getComputedStyle(element, "") || {};
};
exports.setStyle = function (styles, property, value) {
if (styles[property] !== value) {
styles[property] = value;
}
};
exports.HAS_CSS_ANIMATION = false;
exports.HAS_CSS_TRANSFORMS = false;
exports.HI_DPI = useragent.isWin
? typeof window !== "undefined" && window.devicePixelRatio >= 1.5
: true;
if (useragent.isChromeOS)
exports.HI_DPI = false;
if (typeof document !== "undefined") {
var div = document.createElement("div");
if (exports.HI_DPI && div.style.transform !== undefined)
exports.HAS_CSS_TRANSFORMS = true;
if (!useragent.isEdge && typeof div.style.animationName !== "undefined")
exports.HAS_CSS_ANIMATION = true;
div = null;
}
if (exports.HAS_CSS_TRANSFORMS) {
exports.translate = function (element, tx, ty) {
element.style.transform = "translate(" + Math.round(tx) + "px, " + Math.round(ty) + "px)";
};
}
else {
exports.translate = function (element, tx, ty) {
element.style.top = Math.round(ty) + "px";
element.style.left = Math.round(tx) + "px";
};
}
});
define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module){/*
* based on code from:
*
* @license RequireJS text 0.25.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
"use strict";
var dom = require("./dom");
exports.get = function (url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
callback(xhr.responseText);
}
};
xhr.send(null);
};
exports.loadScript = function (path, callback) {
var head = dom.getDocumentHead();
var s = document.createElement('script');
s.src = path;
head.appendChild(s);
s.onload = s.onreadystatechange = function (_, isAbort) {
if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
s = s.onload = s.onreadystatechange = null;
if (!isAbort)
callback();
}
};
};
exports.qualifyURL = function (url) {
var a = document.createElement('a');
a.href = url;
return a.href;
};
});
define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module){"use strict";
var EventEmitter = {};
var stopPropagation = function () { this.propagationStopped = true; };
var preventDefault = function () { this.defaultPrevented = true; };
EventEmitter._emit =
EventEmitter._dispatchEvent = function (eventName, e) {
this._eventRegistry || (this._eventRegistry = {});
this._defaultHandlers || (this._defaultHandlers = {});
var listeners = this._eventRegistry[eventName] || [];
var defaultHandler = this._defaultHandlers[eventName];
if (!listeners.length && !defaultHandler)
return;
if (typeof e != "object" || !e)
e = {};
if (!e.type)
e.type = eventName;
if (!e.stopPropagation)
e.stopPropagation = stopPropagation;
if (!e.preventDefault)
e.preventDefault = preventDefault;
listeners = listeners.slice();
for (var i = 0; i < listeners.length; i++) {
listeners[i](e, this);
if (e.propagationStopped)
break;
}
if (defaultHandler && !e.defaultPrevented)
return defaultHandler(e, this);
};
EventEmitter._signal = function (eventName, e) {
var listeners = (this._eventRegistry || {})[eventName];
if (!listeners)
return;
listeners = listeners.slice();
for (var i = 0; i < listeners.length; i++)
listeners[i](e, this);
};
EventEmitter.once = function (eventName, callback) {
var _self = this;
this.on(eventName, function newCallback() {
_self.off(eventName, newCallback);
callback.apply(null, arguments);
});
if (!callback) {
return new Promise(function (resolve) {
callback = resolve;
});
}
};
EventEmitter.setDefaultHandler = function (eventName, callback) {
var handlers = this._defaultHandlers;
if (!handlers)
handlers = this._defaultHandlers = { _disabled_: {} };
if (handlers[eventName]) {
var old = handlers[eventName];
var disabled = handlers._disabled_[eventName];
if (!disabled)
handlers._disabled_[eventName] = disabled = [];
disabled.push(old);
var i = disabled.indexOf(callback);
if (i != -1)
disabled.splice(i, 1);
}
handlers[eventName] = callback;
};
EventEmitter.removeDefaultHandler = function (eventName, callback) {
var handlers = this._defaultHandlers;
if (!handlers)
return;
var disabled = handlers._disabled_[eventName];
if (handlers[eventName] == callback) {
if (disabled)
this.setDefaultHandler(eventName, disabled.pop());
}
else if (disabled) {
var i = disabled.indexOf(callback);
if (i != -1)
disabled.splice(i, 1);
}
};
EventEmitter.on =
EventEmitter.addEventListener = function (eventName, callback, capturing) {
this._eventRegistry = this._eventRegistry || {};
var listeners = this._eventRegistry[eventName];
if (!listeners)
listeners = this._eventRegistry[eventName] = [];
if (listeners.indexOf(callback) == -1)
listeners[capturing ? "unshift" : "push"](callback);
return callback;
};
EventEmitter.off =
EventEmitter.removeListener =
EventEmitter.removeEventListener = function (eventName, callback) {
this._eventRegistry = this._eventRegistry || {};
var listeners = this._eventRegistry[eventName];
if (!listeners)
return;
var index = listeners.indexOf(callback);
if (index !== -1)
listeners.splice(index, 1);
};
EventEmitter.removeAllListeners = function (eventName) {
if (!eventName)
this._eventRegistry = this._defaultHandlers = undefined;
if (this._eventRegistry)
this._eventRegistry[eventName] = undefined;
if (this._defaultHandlers)
this._defaultHandlers[eventName] = undefined;
};
exports.EventEmitter = EventEmitter;
});
define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module){"no use strict";
var oop = require("./oop");
var EventEmitter = require("./event_emitter").EventEmitter;
var optionsProvider = {
setOptions: function (optList) {
Object.keys(optList).forEach(function (key) {
this.setOption(key, optList[key]);
}, this);
},
getOptions: function (optionNames) {
var result = {};
if (!optionNames) {
var options = this.$options;
optionNames = Object.keys(options).filter(function (key) {
return !options[key].hidden;
});
}
else if (!Array.isArray(optionNames)) {
result = optionNames;
optionNames = Object.keys(result);
}
optionNames.forEach(function (key) {
result[key] = this.getOption(key);
}, this);
return result;
},
setOption: function (name, value) {
if (this["$" + name] === value)
return;
var opt = this.$options[name];
if (!opt) {
return warn('misspelled option "' + name + '"');
}
if (opt.forwardTo)
return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
if (!opt.handlesSet)
this["$" + name] = value;
if (opt && opt.set)
opt.set.call(this, value);
},
getOption: function (name) {
var opt = this.$options[name];
if (!opt) {
return warn('misspelled option "' + name + '"');
}
if (opt.forwardTo)
return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
return opt && opt.get ? opt.get.call(this) : this["$" + name];
}
};
function warn(message) {
if (typeof console != "undefined" && console.warn)
console.warn.apply(console, arguments);
}
function reportError(msg, data) {
var e = new Error(msg);
e.data = data;
if (typeof console == "object" && console.error)
console.error(e);
setTimeout(function () { throw e; });
}
var AppConfig = function () {
this.$defaultOptions = {};
};
(function () {
oop.implement(this, EventEmitter);
this.defineOptions = function (obj, path, options) {
if (!obj.$options)
this.$defaultOptions[path] = obj.$options = {};
Object.keys(options).forEach(function (key) {
var opt = options[key];
if (typeof opt == "string")
opt = { forwardTo: opt };
opt.name || (opt.name = key);
obj.$options[opt.name] = opt;
if ("initialValue" in opt)
obj["$" + opt.name] = opt.initialValue;
});
oop.implement(obj, optionsProvider);
return this;
};
this.resetOptions = function (obj) {
Object.keys(obj.$options).forEach(function (key) {
var opt = obj.$options[key];
if ("value" in opt)
obj.setOption(key, opt.value);
});
};
this.setDefaultValue = function (path, name, value) {
if (!path) {
for (path in this.$defaultOptions)
if (this.$defaultOptions[path][name])
break;
if (!this.$defaultOptions[path][name])
return false;
}
var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
if (opts[name]) {
if (opts.forwardTo)
this.setDefaultValue(opts.forwardTo, name, value);
else
opts[name].value = value;
}
};
this.setDefaultValues = function (path, optionHash) {
Object.keys(optionHash).forEach(function (key) {
this.setDefaultValue(path, key, optionHash[key]);
}, this);
};
this.warn = warn;
this.reportError = reportError;
}).call(AppConfig.prototype);
exports.AppConfig = AppConfig;
});
define("ace/theme/textmate.css",["require","exports","module"], function(require, exports, module){module.exports = ".ace-tm .ace_gutter {\n background: #f0f0f0;\n color: #333;\n}\n\n.ace-tm .ace_print-margin {\n width: 1px;\n background: #e8e8e8;\n}\n\n.ace-tm .ace_fold {\n background-color: #6B72E6;\n}\n\n.ace-tm {\n background-color: #FFFFFF;\n color: black;\n}\n\n.ace-tm .ace_cursor {\n color: black;\n}\n \n.ace-tm .ace_invisible {\n color: rgb(191, 191, 191);\n}\n\n.ace-tm .ace_storage,\n.ace-tm .ace_keyword {\n color: blue;\n}\n\n.ace-tm .ace_constant {\n color: rgb(197, 6, 11);\n}\n\n.ace-tm .ace_constant.ace_buildin {\n color: rgb(88, 72, 246);\n}\n\n.ace-tm .ace_constant.ace_language {\n color: rgb(88, 92, 246);\n}\n\n.ace-tm .ace_constant.ace_library {\n color: rgb(6, 150, 14);\n}\n\n.ace-tm .ace_invalid {\n background-color: rgba(255, 0, 0, 0.1);\n color: red;\n}\n\n.ace-tm .ace_support.ace_function {\n color: rgb(60, 76, 114);\n}\n\n.ace-tm .ace_support.ace_constant {\n color: rgb(6, 150, 14);\n}\n\n.ace-tm .ace_support.ace_type,\n.ace-tm .ace_support.ace_class {\n color: rgb(109, 121, 222);\n}\n\n.ace-tm .ace_keyword.ace_operator {\n color: rgb(104, 118, 135);\n}\n\n.ace-tm .ace_string {\n color: rgb(3, 106, 7);\n}\n\n.ace-tm .ace_comment {\n color: rgb(76, 136, 107);\n}\n\n.ace-tm .ace_comment.ace_doc {\n color: rgb(0, 102, 255);\n}\n\n.ace-tm .ace_comment.ace_doc.ace_tag {\n color: rgb(128, 159, 191);\n}\n\n.ace-tm .ace_constant.ace_numeric {\n color: rgb(0, 0, 205);\n}\n\n.ace-tm .ace_variable {\n color: rgb(49, 132, 149);\n}\n\n.ace-tm .ace_xml-pe {\n color: rgb(104, 104, 91);\n}\n\n.ace-tm .ace_entity.ace_name.ace_function {\n color: #0000A2;\n}\n\n\n.ace-tm .ace_heading {\n color: rgb(12, 7, 255);\n}\n\n.ace-tm .ace_list {\n color:rgb(185, 6, 144);\n}\n\n.ace-tm .ace_meta.ace_tag {\n color:rgb(0, 22, 142);\n}\n\n.ace-tm .ace_string.ace_regex {\n color: rgb(255, 0, 0)\n}\n\n.ace-tm .ace_marker-layer .ace_selection {\n background: rgb(181, 213, 255);\n}\n.ace-tm.ace_multiselect .ace_selection.ace_start {\n box-shadow: 0 0 3px 0px white;\n}\n.ace-tm .ace_marker-layer .ace_step {\n background: rgb(252, 255, 0);\n}\n\n.ace-tm .ace_marker-layer .ace_stack {\n background: rgb(164, 229, 101);\n}\n\n.ace-tm .ace_marker-layer .ace_bracket {\n margin: -1px 0 0 -1px;\n border: 1px solid rgb(192, 192, 192);\n}\n\n.ace-tm .ace_marker-layer .ace_active-line {\n background: rgba(0, 0, 0, 0.07);\n}\n\n.ace-tm .ace_gutter-active-line {\n background-color : #dcdcdc;\n}\n\n.ace-tm .ace_marker-layer .ace_selected-word {\n background: rgb(250, 250, 255);\n border: 1px solid rgb(200, 200, 250);\n}\n\n.ace-tm .ace_indent-guide {\n background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\n}\n\n.ace-tm .ace_indent-guide-active {\n background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAAZSURBVHjaYvj///9/hivKyv8BAAAA//8DACLqBhbvk+/eAAAAAElFTkSuQmCC\") right repeat-y;\n}\n";
});
define("ace/theme/textmate",["require","exports","module","ace/theme/textmate.css","ace/lib/dom"], function(require, exports, module){"use strict";
exports.isDark = false;
exports.cssClass = "ace-tm";
exports.cssText = require("./textmate.css");
exports.$id = "ace/theme/textmate";
var dom = require("../lib/dom");
dom.importCssString(exports.cssText, exports.cssClass, false);
});
define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/dom","ace/lib/app_config","ace/theme/textmate"], function(require, exports, module){"no use strict";
var lang = require("./lib/lang");
var oop = require("./lib/oop");
var net = require("./lib/net");
var dom = require("./lib/dom");
var AppConfig = require("./lib/app_config").AppConfig;
module.exports = exports = new AppConfig();
var options = {
packaged: false,
workerPath: null,
modePath: null,
themePath: null,
basePath: "",
suffix: ".js",
$moduleUrls: {},
loadWorkerFromBlob: true,
sharedPopups: false,
useStrictCSP: null
};
exports.get = function (key) {
if (!options.hasOwnProperty(key))
throw new Error("Unknown config key: " + key);
return options[key];
};
exports.set = function (key, value) {
if (options.hasOwnProperty(key))
options[key] = value;
else if (this.setDefaultValue("", key, value) == false)
throw new Error("Unknown config key: " + key);
if (key == "useStrictCSP")
dom.useStrictCSP(value);
};
exports.all = function () {
return lang.copyObject(options);
};
exports.$modes = {};
exports.moduleUrl = function (name, component) {
if (options.$moduleUrls[name])
return options.$moduleUrls[name];
var parts = name.split("/");
component = component || parts[parts.length - 2] || "";
var sep = component == "snippets" ? "/" : "-";
var base = parts[parts.length - 1];
if (component == "worker" && sep == "-") {
var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
base = base.replace(re, "");
}
if ((!base || base == component) && parts.length > 1)
base = parts[parts.length - 2];
var path = options[component + "Path"];
if (path == null) {
path = options.basePath;
}
else if (sep == "/") {
component = sep = "";
}
if (path && path.slice(-1) != "/")
path += "/";
return path + component + sep + base + this.get("suffix");
};
exports.setModuleUrl = function (name, subst) {
return options.$moduleUrls[name] = subst;
};
var loader = function (moduleName, cb) {
if (moduleName === "ace/theme/textmate" || moduleName === "./theme/textmate")
return cb(null, require("./theme/textmate"));
return console.error("loader is not configured");
};
exports.setLoader = function (cb) {
loader = cb;
};
exports.dynamicModules = Object.create(null);
exports.$loading = {};
exports.loadModule = function (moduleName, onLoad) {
var module, moduleType;
if (Array.isArray(moduleName)) {
moduleType = moduleName[0];
moduleName = moduleName[1];
}
var load = function (module) {
if (module && !exports.$loading[moduleName])
return onLoad && onLoad(module);
if (!exports.$loading[moduleName])
exports.$loading[moduleName] = [];
exports.$loading[moduleName].push(onLoad);
if (exports.$loading[moduleName].length > 1)
return;
var afterLoad = function () {
loader(moduleName, function (err, module) {
exports._emit("load.module", { name: moduleName, module: module });
var listeners = exports.$loading[moduleName];
exports.$loading[moduleName] = null;
listeners.forEach(function (onLoad) {
onLoad && onLoad(module);
});
});
};
if (!exports.get("packaged"))
return afterLoad();
net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
reportErrorIfPathIsNotConfigured();
};
if (exports.dynamicModules[moduleName]) {
exports.dynamicModules[moduleName]().then(function (module) {
if (module.default) {
load(module.default);
}
else {
load(module);
}
});
}
else {
try {
module = require(moduleName);
}
catch (e) { }
load(module);
}
};
exports.setModuleLoader = function (moduleName, onLoad) {
exports.dynamicModules[moduleName] = onLoad;
};
var reportErrorIfPathIsNotConfigured = function () {
if (!options.basePath && !options.workerPath
&& !options.modePath && !options.themePath
&& !Object.keys(options.$moduleUrls).length) {
console.error("Unable to infer path to ace from script src,", "use ace.config.set('basePath', 'path') to enable dynamic loading of modes and themes", "or with webpack use ace/webpack-resolver");
reportErrorIfPathIsNotConfigured = function () { };
}
};
exports.version = "1.16.0";
});
define("ace/loader_build",["require","exports","module","ace/lib/fixoldbrowsers","ace/config"], function(require, exports, module) {
"use strict";
require("./lib/fixoldbrowsers");
var config = require("./config");
config.setLoader(function(moduleName, cb) {
require([moduleName], function(module) {
cb(null, module);
});
});
var global = (function() {
return this || typeof window != "undefined" && window;
})();
module.exports = function(ace) {
config.init = init;
ace.require = require;
if (typeof define === "function")
ace.define = define;
};
init(true);function init(packaged) {
if (!global || !global.document)
return;
config.set("packaged", packaged || require.packaged || module.packaged || (global.define && define.packaged));
var scriptOptions = {};
var scriptUrl = "";
var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
var currentDocument = currentScript && currentScript.ownerDocument || document;
if (currentScript && currentScript.src) {
scriptUrl = currentScript.src.split(/[?#]/)[0].split("/").slice(0, -1).join("/") || "";
}
var scripts = currentDocument.getElementsByTagName("script");
for (var i=0; i<scripts.length; i++) {
var script = scripts[i];
var src = script.src || script.getAttribute("src");
if (!src)
continue;
var attributes = script.attributes;
for (var j=0, l=attributes.length; j < l; j++) {
var attr = attributes[j];
if (attr.name.indexOf("data-ace-") === 0) {
scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
}
}
var m = src.match(/^(.*)\/ace([\-.]\w+)?\.js(\?|$)/);
if (m)
scriptUrl = m[1];
}
if (scriptUrl) {
scriptOptions.base = scriptOptions.base || scriptUrl;
scriptOptions.packaged = true;
}
scriptOptions.basePath = scriptOptions.base;
scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
delete scriptOptions.base;
for (var key in scriptOptions)
if (typeof scriptOptions[key] !== "undefined")
config.set(key, scriptOptions[key]);
}
function deHyphenate(str) {
return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
}
});
define("ace/lib/keys",["require","exports","module","ace/lib/oop"], function(require, exports, module){/*! @license
==========================================================================
SproutCore -- JavaScript Application Framework
copyright 2006-2009, Sprout Systems Inc., Apple Inc. and contributors.
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.
SproutCore and the SproutCore logo are trademarks of Sprout Systems, Inc.
For more information about SproutCore, visit http://www.sproutcore.com
==========================================================================
@license */
"use strict";
var oop = require("./oop");
var Keys = (function () {
var ret = {
MODIFIER_KEYS: {
16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta',
91: 'MetaLeft', 92: 'MetaRight', 93: 'ContextMenu'
},
KEY_MODS: {
"ctrl": 1, "alt": 2, "option": 2, "shift": 4,
"super": 8, "meta": 8, "command": 8, "cmd": 8,
"control": 1
},
FUNCTION_KEYS: {
8: "Backspace",
9: "Tab",
13: "Return",
19: "Pause",
27: "Esc",
32: "Space",
33: "PageUp",
34: "PageDown",
35: "End",
36: "Home",
37: "Left",
38: "Up",
39: "Right",
40: "Down",
44: "Print",
45: "Insert",
46: "Delete",
96: "Numpad0",
97: "Numpad1",
98: "Numpad2",
99: "Numpad3",
100: "Numpad4",
101: "Numpad5",
102: "Numpad6",
103: "Numpad7",
104: "Numpad8",
105: "Numpad9",
'-13': "NumpadEnter",
112: "F1",
113: "F2",
114: "F3",
115: "F4",
116: "F5",
117: "F6",
118: "F7",
119: "F8",
120: "F9",
121: "F10",
122: "F11",
123: "F12",
144: "Numlock",
145: "Scrolllock"
},
PRINTABLE_KEYS: {
32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
219: '[', 220: '\\', 221: ']', 222: "'", 111: '/', 106: '*'
}
};
ret.PRINTABLE_KEYS[173] = '-';
var name, i;
for (i in ret.FUNCTION_KEYS) {
name = ret.FUNCTION_KEYS[i].toLowerCase();
ret[name] = parseInt(i, 10);
}
for (i in ret.PRINTABLE_KEYS) {
name = ret.PRINTABLE_KEYS[i].toLowerCase();
ret[name] = parseInt(i, 10);
}
oop.mixin(ret, ret.MODIFIER_KEYS);
oop.mixin(ret, ret.PRINTABLE_KEYS);
oop.mixin(ret, ret.FUNCTION_KEYS);
ret.enter = ret["return"];
ret.escape = ret.esc;
ret.del = ret["delete"];
(function () {
var mods = ["cmd", "ctrl", "alt", "shift"];
for (var i = Math.pow(2, mods.length); i--;) {
ret.KEY_MODS[i] = mods.filter(function (x) {
return i & ret.KEY_MODS[x];
}).join("-") + "-";
}
})();
ret.KEY_MODS[0] = "";
ret.KEY_MODS[-1] = "input-";
return ret;
})();
oop.mixin(exports, Keys);
exports.keyCodeToString = function (keyCode) {
var keyString = Keys[keyCode];
if (typeof keyString != "string")
keyString = String.fromCharCode(keyCode);
return keyString.toLowerCase();
};
});
define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module){"use strict";
var keys = require("./keys");
var useragent = require("./useragent");
var pressedKeys = null;
var ts = 0;
var activeListenerOptions;
function detectListenerOptionsSupport() {
activeListenerOptions = false;
try {
document.createComment("").addEventListener("test", function () { }, {
get passive() {
activeListenerOptions = { passive: false };
}
});