update packaged ace

This commit is contained in:
Fabian Jakobs 2011-01-10 13:17:14 +01:00
commit a5eb376e4c
133 changed files with 13027 additions and 3335 deletions

106
build/pilot/canon.js Normal file
View file

@ -0,0 +1,106 @@
define(function(d, b) {
function p(a) {
if(!a.name) {
throw new Error("All registered commands must have a name");
}if(a.params == null) {
a.params = []
}if(!Array.isArray(a.params)) {
throw new Error("command.params must be an array in " + a.name);
}a.params.forEach(function(c) {
if(!c.name) {
throw new Error("In " + a.name + ": all params must have a name");
}k(a.name, c)
}, this);
g[a.name] = a;
h.push(a.name);
h.sort()
}
function k(a, c) {
var f = c.type;
c.type = q.getType(f);
if(c.type == null) {
throw new Error("In " + a + "/" + c.name + ": can't find type for: " + JSON.stringify(f));
}
}
function r(a) {
a = typeof a === "string" ? a : a.name;
delete g[a];
s.arrayRemove(h, a)
}
function t(a) {
return g[a]
}
function u() {
return h
}
function v(a, c, f, j) {
if(typeof a === "string") {
a = g[a]
}if(!a) {
return false
}j = new e({command:a, args:f, typed:j});
a.exec(c, f || {}, j);
return true
}
function e(a) {
a = a || {};
this.command = a.command;
this.args = a.args;
this.typed = a.typed;
this._begunOutput = false;
this.start = new Date;
this.end = null;
this.error = this.completed = false
}
d("pilot/console");
d("pilot/stacktrace");
var l = d("pilot/oop"), m = d("pilot/event_emitter").EventEmitter, n = d("pilot/catalog");
d("pilot/types");
var q = d("pilot/types"), s = d("pilot/lang"), o = {name:"command", description:"A command is a bit of functionality with optional typed arguments which can do something small like moving the cursor around the screen, or large like cloning a project from VCS.", indexOn:"name"};
b.startup = function() {
n.addExtensionSpec(o)
};
b.shutdown = function() {
n.removeExtensionSpec(o)
};
var g = {}, h = [];
b.removeCommand = r;
b.addCommand = p;
b.getCommand = t;
b.getCommandNames = u;
b.exec = v;
b.upgradeType = k;
l.implement(b, m);
var i = [];
l.implement(e.prototype, m);
e.prototype._beginOutput = function() {
this._begunOutput = true;
this.outputs = [];
for(i.push(this);i.length > 100;) {
i.shiftObject()
}b._dispatchEvent("output", {requests:i, request:this})
};
e.prototype.doneWithError = function(a) {
this.error = true;
this.done(a)
};
e.prototype.async = function() {
this._begunOutput || this._beginOutput()
};
e.prototype.output = function(a) {
this._begunOutput || this._beginOutput();
if(typeof a !== "string" && !(a instanceof Node)) {
a = a.toString()
}this.outputs.push(a);
this._dispatchEvent("output", {});
return this
};
e.prototype.done = function(a) {
this.completed = true;
this.end = new Date;
this.duration = this.end.getTime() - this.start.getTime();
a && this.output(a);
this._dispatchEvent("output", {})
};
b.Request = e
});

19
build/pilot/catalog.js Normal file
View file

@ -0,0 +1,19 @@
define(function(d, c) {
var b = {};
c.addExtensionSpec = function(a) {
b[a.name] = a
};
c.removeExtensionSpec = function(a) {
if(typeof a === "string") {
delete b[a]
}else {
delete b[a.name]
}
};
c.getExtensionSpec = function(a) {
return b[a]
};
c.getExtensionSpecs = function() {
return Object.keys(b)
}
});

View file

@ -0,0 +1,91 @@
define(function(l, m) {
var i = l("pilot/typecheck"), e = l("pilot/canon"), j = {plainPrefix:'<h2>Welcome to Skywriter - Code in the Cloud</h2><ul><li><a href="http://labs.mozilla.com/projects/skywriter" target="_blank">Home Page</a></li><li><a href="https://wiki.mozilla.org/Labs/Skywriter" target="_blank">Wiki</a></li><li><a href="https://wiki.mozilla.org/Labs/Skywriter/UserGuide" target="_blank">User Guide</a></li><li><a href="https://wiki.mozilla.org/Labs/Skywriter/Tips" target="_blank">Tips and Tricks</a></li><li><a href="https://wiki.mozilla.org/Labs/Skywriter/FAQ" target="_blank">FAQ</a></li><li><a href="https://wiki.mozilla.org/Labs/Skywriter/DeveloperGuide" target="_blank">Developers Guide</a></li></ul>',
plainSuffix:'For more information, see the <a href="https://wiki.mozilla.org/Labs/Skywriter">Skywriter Wiki</a>.'}, n = {name:"help", params:[{name:"search", type:"text", description:"Search string to narrow the output.", defaultValue:null}], description:"Get help on the available commands.", exec:function(b, c, g) {
b = [];
var a = e.getCommand(c.search);
if(a && a.exec) {
b.push(a.description ? a.description : "No description for " + c.search)
}else {
var k = false;
!c.search && j.plainPrefix && b.push(j.plainPrefix);
if(a) {
b.push("<h2>Sub-Commands of " + a.name + "</h2>");
b.push("<p>" + a.description + "</p>")
}else {
if(c.search) {
if(c.search == "hidden") {
c.search = "";
k = true
}b.push("<h2>Commands starting with '" + c.search + "':</h2>")
}else {
b.push("<h2>Available Commands:</h2>")
}
}var f = e.getCommandNames();
f.sort();
b.push("<table>");
for(var d = 0;d < f.length;d++) {
a = e.getCommand(f[d]);
if(!(!k && a.hidden)) {
if(a.description !== undefined) {
if(!(c.search && a.name.indexOf(c.search) !== 0)) {
if(!(!c.search && a.name.indexOf(" ") != -1)) {
if(!(a && a.name == c.search)) {
b.push("<tr>");
b.push('<th class="right">' + a.name + "</th>");
b.push("<td>" + a.description + "</td>");
b.push("</tr>")
}
}
}
}
}
}b.push("</table>");
!c.search && j.plainSuffix && b.push(j.plainSuffix)
}g.done(b.join(""))
}}, p = {name:"eval", params:[{name:"javascript", type:"text", description:"The JavaScript to evaluate"}], description:"evals given js code and show the result", hidden:true, exec:function(b, c, g) {
var a;
b = c.javascript;
try {
a = eval(b)
}catch(k) {
a = "<b>Error: " + k.message + "</b>"
}var f = c = "", d;
if(i.isFunction(a)) {
c = (a + "").replace(/\n/g, "<br>").replace(/ /g, "&#160");
f = "function"
}else {
if(i.isObject(a)) {
f = Array.isArray(a) ? "array" : "object";
var h = [], o;
for(d in a) {
if(a.hasOwnProperty(d)) {
o = i.isFunction(a[d]) ? "[function]" : i.isObject(a[d]) ? "[object]" : a[d];
h.push({name:d, value:o})
}
}h.sort(function(s, t) {
return s.name.toLowerCase() < t.name.toLowerCase() ? -1 : 1
});
for(d = 0;d < h.length;d++) {
c += "<b>" + h[d].name + "</b>: " + h[d].value + "<br>"
}
}else {
c = a;
f = typeof a
}
}g.done("Result for eval <b>'" + b + "'</b> (type: " + f + "): <br><br>" + c)
}}, r = {name:"skywriter", hidden:true, exec:function(b, c, g) {
b = Math.floor(Math.random() * q.length);
g.done("Skywriter " + q[b])
}}, q = ["really wants you to trick it out in some way.", "is your Web editor.", "would love to be like Emacs on the Web.", "is written on the Web platform, so you can tweak it."];
e = l("pilot/canon");
m.startup = function() {
e.addCommand(n);
e.addCommand(p);
e.addCommand(r)
};
m.shutdown = function() {
e.removeCommand(n);
e.removeCommand(p);
e.removeCommand(r)
}
});

View file

@ -0,0 +1,6 @@
define(function(c, a) {
var b = 0;
a.addedRequestOutput = function() {
b = history.requests.length
}
});

View file

@ -0,0 +1,39 @@
define(function(j, g) {
var h = {name:"set", params:[{name:"setting", type:"setting", description:"The name of the setting to display or alter", defaultValue:null}, {name:"value", type:"settingValue", description:"The new value for the chosen setting", defaultValue:null}], description:"define and show settings", exec:function(d, a, e) {
var b;
if(a.setting) {
if(a.value === undefined) {
b = "<strong>" + setting.name + "</strong> = " + setting.get()
}else {
a.setting.set(a.value);
b = "Setting: <strong>" + a.setting.name + "</strong> = " + a.setting.get()
}
}else {
a = d.settings.getSettingNames();
b = "";
a.sort(function(c, k) {
return c.localeCompare(k)
});
a.forEach(function(c) {
c = d.settings.getSetting(c);
b += '<a class="setting" href="' + ("https://wiki.mozilla.org/Labs/Skywriter/Settings#" + c.name) + '" title="View external documentation on setting: ' + c.name + '" target="_blank">' + c.name + "</a> = " + c.value + "<br/>"
})
}e.done(b)
}}, i = {name:"unset", params:[{name:"setting", type:"setting", description:"The name of the setting to return to defaults"}], description:"unset a setting entirely", exec:function(d, a, e) {
var b = d.settings.get(a.setting);
if(b) {
b.reset();
e.done("Reset " + b.name + " to default: " + d.settings.get(a.setting))
}else {
e.doneWithError("No setting with the name <strong>" + a.setting + "</strong>.")
}
}}, f = j("pilot/canon");
g.startup = function() {
f.addCommand(h);
f.addCommand(i)
};
g.shutdown = function() {
f.removeCommand(h);
f.removeCommand(i)
}
});

13
build/pilot/console.js Normal file
View file

@ -0,0 +1,13 @@
define(function(b, c) {
var d = function() {
};
b = ["assert", "count", "debug", "dir", "dirxml", "error", "group", "groupEnd", "info", "log", "profile", "profileEnd", "time", "timeEnd", "trace", "warn"];
typeof window === "undefined" ? b.forEach(function(a) {
c[a] = function() {
var e = Array.prototype.slice.call(arguments);
postMessage(JSON.stringify({op:"log", method:a, args:e}))
}
}) : b.forEach(function(a) {
c[a] = window.console && window.console[a] ? Function.prototype.bind.call(window.console[a], window.console) : d
})
});

74
build/pilot/dom.js Normal file
View file

@ -0,0 +1,74 @@
define(function(f, c) {
c.setText = function(a, b) {
if(a.innerText !== undefined) {
a.innerText = b
}if(a.textContent !== undefined) {
a.textContent = b
}
};
c.hasCssClass = function(a, b) {
return a.className.split(/\s+/g).indexOf(b) !== -1
};
c.addCssClass = function(a, b) {
c.hasCssClass(a, b) || (a.className += " " + b)
};
c.setCssClass = function(a, b, d) {
d ? c.addCssClass(a, b) : c.removeCssClass(a, b)
};
c.removeCssClass = function(a, b) {
for(var d = a.className.split(/\s+/g);;) {
var e = d.indexOf(b);
if(e == -1) {
break
}d.splice(e, 1)
}a.className = d.join(" ")
};
c.importCssString = function(a, b) {
b = b || document;
if(b.createStyleSheet) {
b.createStyleSheet().cssText = a
}else {
var d = b.createElement("style");
d.appendChild(b.createTextNode(a));
b.getElementsByTagName("head")[0].appendChild(d)
}
};
c.getInnerWidth = function(a) {
return parseInt(c.computedStyle(a, "paddingLeft")) + parseInt(c.computedStyle(a, "paddingRight")) + a.clientWidth
};
c.getInnerHeight = function(a) {
return parseInt(c.computedStyle(a, "paddingTop")) + parseInt(c.computedStyle(a, "paddingBottom")) + a.clientHeight
};
c.computedStyle = function(a, b) {
return window.getComputedStyle ? (window.getComputedStyle(a, "") || {})[b] || "" : a.currentStyle[b]
};
c.scrollbarWidth = function() {
var a = document.createElement("p");
a.style.width = "100%";
a.style.height = "200px";
var b = document.createElement("div"), d = b.style;
d.position = "absolute";
d.left = "-10000px";
d.overflow = "hidden";
d.width = "200px";
d.height = "150px";
b.appendChild(a);
document.body.appendChild(b);
var e = a.offsetWidth;
d.overflow = "scroll";
a = a.offsetWidth;
if(e == a) {
a = b.clientWidth
}document.body.removeChild(b);
return e - a
};
c.setInnerHtml = function(a, b) {
var d = a.cloneNode(false);
d.innerHTML = b;
a.parentNode.replaceChild(d, a);
return d
};
c.getParentWindow = function(a) {
return a.defaultView || a.parentWindow
}
});

201
build/pilot/domtemplate.js Normal file
View file

@ -0,0 +1,201 @@
define(function(r, q) {
function g() {
this.scope = []
}
g.prototype.processNode = function(a, c) {
if(typeof a === "string") {
a = document.getElementById(a)
}if(c === null || c === undefined) {
c = {}
}this.scope.push(a.nodeName + (a.id ? "#" + a.id : ""));
try {
if(a.attributes && a.attributes.length) {
if(a.hasAttribute("foreach")) {
this.processForEach(a, c);
return
}if(a.hasAttribute("if")) {
if(!this.processIf(a, c)) {
return
}
}c.__element = a;
for(var d = Array.prototype.slice.call(a.attributes), b = 0;b < d.length;b++) {
var e = d[b].value, f = d[b].name;
this.scope.push(f);
try {
if(f === "save") {
e = this.stripBraces(e);
this.property(e, c, a);
a.removeAttribute("save")
}else {
if(f.substring(0, 2) === "on") {
e = this.stripBraces(e);
var j = this.property(e, c);
typeof j !== "function" && this.handleError("Expected " + e + " to resolve to a function, but got " + typeof j);
a.removeAttribute(f);
var n = a.hasAttribute("capture" + f.substring(2));
a.addEventListener(f.substring(2), j, n);
n && a.removeAttribute("capture" + f.substring(2))
}else {
var o = this, i = e.replace(/\$\{[^}]*\}/g, function(p) {
return o.envEval(p.slice(2, -1), c, e)
});
if(f.charAt(0) === "_") {
a.removeAttribute(f);
a.setAttribute(f.substring(1), i)
}else {
if(e !== i) {
d[b].value = i
}
}
}
}
}finally {
this.scope.pop()
}
}
}var m = Array.prototype.slice.call(a.childNodes);
for(d = 0;d < m.length;d++) {
this.processNode(m[d], c)
}a.nodeType === Node.TEXT_NODE && this.processTextNode(a, c)
}finally {
this.scope.pop()
}
};
g.prototype.processIf = function(a, c) {
this.scope.push("if");
try {
var d = a.getAttribute("if"), b = this.stripBraces(d), e = true;
try {
e = !!this.envEval(b, c, d)
}catch(f) {
this.handleError("Error with '" + b + "'", f);
e = false
}e || a.parentNode.removeChild(a);
a.removeAttribute("if");
return e
}finally {
this.scope.pop()
}
};
g.prototype.processForEach = function(a, c) {
this.scope.push("foreach");
try {
var d = a.getAttribute("foreach"), b = d, e = "param";
if(b.charAt(0) === "$") {
b = this.stripBraces(b)
}else {
var f = b.split(" in ");
e = f[0].trim();
b = this.stripBraces(f[1].trim())
}a.removeAttribute("foreach");
try {
var j = this, n = function(h, k, l) {
l.parentNode.insertBefore(k, l);
c[e] = h;
j.processNode(k, c);
delete c[e]
}, o = function(h, k) {
j.scope.push(h);
try {
if(a.nodeName === "LOOP") {
for(h = 0;h < a.childNodes.length;h++) {
var l = a.childNodes[h].cloneNode(true);
n(k, l, a)
}
}else {
l = a.cloneNode(true);
l.removeAttribute("foreach");
n(k, l, a)
}
}finally {
j.scope.pop()
}
}, i = this.envEval(b, c, d);
if(Array.isArray(i)) {
i.forEach(function(h, k) {
o("" + k, h)
}, this)
}else {
for(var m in i) {
i.hasOwnProperty(m) && o(m, m)
}
}a.parentNode.removeChild(a)
}catch(p) {
this.handleError("Error with '" + b + "'", p)
}
}finally {
this.scope.pop()
}
};
g.prototype.processTextNode = function(a, c) {
var d = a.data;
d = d.replace(/\$\{([^}]*)\}/g, "\uf001$$$1\uf002");
d = d.split(/\uF001|\uF002/);
if(d.length > 1) {
d.forEach(function(b) {
if(!(b === null || b === undefined || b === "")) {
if(b.charAt(0) === "$") {
b = this.envEval(b.slice(1), c, a.data)
}if(b === null) {
b = "null"
}if(b === undefined) {
b = "undefined"
}if(typeof b.cloneNode !== "function") {
b = a.ownerDocument.createTextNode(b.toString())
}a.parentNode.insertBefore(b, a)
}
}, this);
a.parentNode.removeChild(a)
}
};
g.prototype.stripBraces = function(a) {
if(!a.match(/\$\{.*\}/g)) {
this.handleError("Expected " + a + " to match ${...}");
return a
}return a.slice(2, -1)
};
g.prototype.property = function(a, c, d) {
this.scope.push(a);
try {
if(typeof a === "string") {
a = a.split(".")
}var b = c[a[0]];
if(a.length === 1) {
if(d !== undefined) {
c[a[0]] = d
}if(typeof b === "function") {
return function() {
return b.apply(c, arguments)
}
}return b
}if(!b) {
this.handleError("Can't find path=" + a);
return null
}return this.property(a.slice(1), b, d)
}finally {
this.scope.pop()
}
};
g.prototype.envEval = function(a, c, d) {
with(c) {
try {
this.scope.push(d);
return eval(a)
}catch(b) {
this.handleError("Template error evaluating '" + a + "'", b);
return a
}finally {
this.scope.pop()
}
}
};
g.prototype.handleError = function(a, c) {
this.logError(a);
this.logError("In: " + this.scope.join(" > "));
c && this.logError(c)
};
g.prototype.logError = function(a) {
console.log(a)
};
q.Templater = g
});

View file

@ -0,0 +1,7 @@
define(function(a, b) {
function c() {
return{settings:d}
}
var d = a("pilot/settings").settings;
b.create = c
});

135
build/pilot/event.js Normal file
View file

@ -0,0 +1,135 @@
define(function(m, c) {
var i = m("pilot/useragent");
c.addListener = function(a, e, d) {
if(a.addEventListener) {
return a.addEventListener(e, d, false)
}if(a.attachEvent) {
var b = function() {
d(window.event)
};
d._wrapper = b;
a.attachEvent("on" + e, b)
}
};
c.removeListener = function(a, e, d) {
if(a.removeEventListener) {
return a.removeEventListener(e, d, false)
}if(a.detachEvent) {
a.detachEvent("on" + e, d._wrapper || d)
}
};
c.stopEvent = function(a) {
c.stopPropagation(a);
c.preventDefault(a);
return false
};
c.stopPropagation = function(a) {
if(a.stopPropagation) {
a.stopPropagation()
}else {
a.cancelBubble = true
}
};
c.preventDefault = function(a) {
if(a.preventDefault) {
a.preventDefault()
}else {
a.returnValue = false
}
};
c.getDocumentX = function(a) {
return a.clientX ? a.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) : a.pageX
};
c.getDocumentY = function(a) {
return a.clientY ? a.clientY + (document.documentElement.scrollTop || document.body.scrollTop) : a.pageX
};
c.getButton = function(a) {
return a.preventDefault ? a.button : Math.max(a.button - 1, 2)
};
c.capture = document.documentElement.setCapture ? function(a, e, d) {
function b(h) {
e && e(h);
d && d();
c.removeListener(a, "mousemove", e);
c.removeListener(a, "mouseup", b);
c.removeListener(a, "losecapture", b);
a.releaseCapture()
}
c.addListener(a, "mousemove", e);
c.addListener(a, "mouseup", b);
c.addListener(a, "losecapture", b);
a.setCapture()
} : function(a, e, d) {
function b(f) {
e(f);
f.stopPropagation()
}
function h(f) {
e && e(f);
d && d();
document.removeEventListener("mousemove", b, true);
document.removeEventListener("mouseup", h, true);
f.stopPropagation()
}
document.addEventListener("mousemove", b, true);
document.addEventListener("mouseup", h, true)
};
c.addMouseWheelListener = function(a, e) {
var d = function(b) {
if(b.wheelDelta !== undefined) {
if(b.wheelDeltaX !== undefined) {
b.wheelX = -b.wheelDeltaX / 8;
b.wheelY = -b.wheelDeltaY / 8
}else {
b.wheelX = 0;
b.wheelY = -b.wheelDelta / 8
}
}else {
if(b.axis && b.axis == b.HORIZONTAL_AXIS) {
b.wheelX = (b.detail || 0) * 5;
b.wheelY = 0
}else {
b.wheelX = 0;
b.wheelY = (b.detail || 0) * 5
}
}e(b)
};
c.addListener(a, "DOMMouseScroll", d);
c.addListener(a, "mousewheel", d)
};
c.addMultiMouseDownListener = function(a, e, d, b, h) {
var f = 0, j, k, l = function(g) {
f += 1;
if(f == 1) {
j = g.clientX;
k = g.clientY;
setTimeout(function() {
f = 0
}, b || 600)
}if(c.getButton(g) != e || Math.abs(g.clientX - j) > 5 || Math.abs(g.clientY - k) > 5) {
f = 0
}if(f == d) {
f = 0;
h(g)
}return c.preventDefault(g)
};
c.addListener(a, "mousedown", l);
i.isIE && c.addListener(a, "dblclick", l)
};
c.addKeyListener = function(a, e) {
var d = null;
c.addListener(a, "keydown", function(b) {
d = b.keyIdentifier || b.keyCode;
return e(b)
});
if(i.isMac && (i.isGecko || i.isOpera)) {
c.addListener(a, "keypress", function(b) {
if(d !== (b.keyIdentifier || b.keyCode)) {
return e(b)
}else {
d = null
}
})
}
}
});

View file

@ -0,0 +1,28 @@
define(function(d, e) {
d = {};
d._dispatchEvent = function(a, b) {
this._eventRegistry = this._eventRegistry || {};
var c = this._eventRegistry[a];
if(c && c.length) {
b = b || {};
b.type = a;
for(a = 0;a < c.length;a++) {
c[a](b)
}
}
};
d.on = d.addEventListener = function(a, b) {
this._eventRegistry = this._eventRegistry || {};
var c = this._eventRegistry[a];
c || (c = this._eventRegistry[a] = []);
c.indexOf(b) == -1 && c.push(b)
};
d.removeEventListener = function(a, b) {
this._eventRegistry = this._eventRegistry || {};
if(a = this._eventRegistry[a]) {
b = a.indexOf(b);
b !== -1 && a.splice(b, 1)
}
};
e.EventEmitter = d
});

View file

@ -0,0 +1,97 @@
define(function(require, exports) {
if(!Array.isArray) {
Array.isArray = function(data) {
return data && Object.prototype.toString.call(data) === "[object Array]"
}
}if(!Array.prototype.indexOf) {
Array.prototype.indexOf = function(searchElement) {
if(this === void 0 || this === null) {
throw new TypeError;
}var t = Object(this);
var len = t.length >>> 0;
if(len === 0) {
return-1
}var n = 0;
if(arguments.length > 0) {
n = Number(arguments[1]);
if(n !== n) {
n = 0
}else {
if(n !== 0 && n !== 1 / 0 && n !== -(1 / 0)) {
n = (n > 0 || -1) * Math.floor(Math.abs(n))
}
}
}if(n >= len) {
return-1
}var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
for(;k < len;k++) {
if(k in t && t[k] === searchElement) {
return k
}
}return-1
}
}if(!Array.prototype.map) {
Array.prototype.map = function(fun, JSCompiler_OptimizeArgumentsArray_p0) {
if(this === void 0 || this === null) {
throw new TypeError;
}var t$$1 = Object(this);
var len$$1 = t$$1.length >>> 0;
if(typeof fun !== "function") {
throw new TypeError;
}res = new Array(len$$1);
var thisp = JSCompiler_OptimizeArgumentsArray_p0;
var i = 0;
for(;i < len$$1;i++) {
if(i in t$$1) {
res[i] = fun.call(thisp, t$$1[i], i, t$$1)
}
}return res
}
}if(!Array.prototype.forEach) {
Array.prototype.forEach = function(fun$$1, JSCompiler_OptimizeArgumentsArray_p1) {
if(this === void 0 || this === null) {
throw new TypeError;
}var t$$2 = Object(this);
var len$$2 = t$$2.length >>> 0;
if(typeof fun$$1 !== "function") {
throw new TypeError;
}var thisp$$1 = JSCompiler_OptimizeArgumentsArray_p1;
var i$$1 = 0;
for(;i$$1 < len$$2;i$$1++) {
i$$1 in t$$2 && fun$$1.call(thisp$$1, t$$2[i$$1], i$$1, t$$2)
}
}
}if(!Object.keys) {
Object.keys = function(obj) {
var k$$1;
var ret = [];
for(k$$1 in obj) {
obj.hasOwnProperty(k$$1) && ret.push(k$$1)
}return ret
}
}if(!Function.prototype.bind) {
Function.prototype.bind = function(obj$$1) {
var slice = [].slice;
var args = slice.call(arguments, 1);
var self = this;
var nop = function() {
};
var bound = arguments.length == 1 ? function() {
return self.apply(this instanceof nop ? this : obj$$1, arguments)
} : function() {
return self.apply(this instanceof nop ? this : obj$$1 || {}, args.concat(slice.call(arguments)))
};
nop.prototype = self.prototype;
bound.prototype = new nop;
bound.name = this.name;
bound.displayName = this.displayName;
bound.length = this.length;
bound.unbound = self;
return bound
}
}if(!String.prototype.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+/, "").replace(/\s+$/, "")
}
}exports.globalsLoaded = true
});

10
build/pilot/index.js Normal file
View file

@ -0,0 +1,10 @@
var deps = ["pilot/fixoldbrowsers", "pilot/types/basic", "pilot/types/command", "pilot/types/settings", "pilot/commands/settings", "pilot/commands/basic", "pilot/settings/canon", "pilot/canon"], packages = deps.slice();
packages.unshift("require", "exports", "module");
define(packages, function(b, c) {
c.startup = function(d, e) {
deps.forEach(function(a) {
a = b(a);
typeof a.startup === "function" && a.startup(d, e)
})
}
});

View file

@ -0,0 +1,172 @@
define(function(m, f) {
require("pilot/console");
require("pilot/stacktrace");
var o = require("pilot/keyboard/keyutil"), p = require("canon/history"), q = require("canon/request").Request, r = require("environment").env;
f.keymappings = {};
f.addKeymapping = function(a) {
f.keymappings[a.name] = a
};
f.removeKeymapping = function(a) {
delete f.keymapping[a]
};
f.startup = function(a) {
a.env.settings.settingChange.add({match:"customKeymapping", ref:f.keyboardManager, func:f.keyboardManager._customKeymappingChanged.bind(f.keyboardManager)})
};
f.shutdown = function(a) {
a.env.settings.settingChange.remove(f.keyboardManager)
};
f.buildFlags = function(a) {
a.context = r.contexts[0];
return a
};
m = function() {
};
m.prototype = {_customKeymappingCache:{states:{}}, processKeyEvent:function(a, b, c) {
a = o.commandCodes(a, true)[0];
if(util.none(a)) {
return false
}f.buildFlags(c);
c.isCommandKey = true;
return this._matchCommand(a, b, c)
}, _matchCommand:function(a, b, c) {
var d = this._findCommandExtension(a, b, c);
if(d && d.commandExt !== "no command") {
c.isTextView && b.resetKeyBuffers();
var e = d.commandExt;
e.load(function(h) {
h = new q({command:h, commandExt:e});
p.execute(d.args, h)
});
return true
}return d && d.commandExt === "no command" ? true : false
}, _buildBindingsRegex:function(a) {
a.forEach(function(b) {
if(util.none(b.key)) {
if(Array.isArray(b.regex)) {
b.key = new RegExp("^" + b.regex[1] + "$");
b.regex = new RegExp(b.regex.join("") + "$")
}else {
b.regex = new RegExp(b.regex + "$")
}
}else {
b.key = new RegExp("^" + b.key + "$")
}
})
}, _buildKeymappingRegex:function(a) {
for(state in a.states) {
this._buildBindingsRegex(a.states[state])
}a._convertedRegExp = true
}, _findCommandExtension:function(a, b, c) {
if(c.isTextView) {
var d = b._keyState;
if(!c.isCommandKey || a.indexOf("alt_") === -1) {
b._keyBuffer += a.replace(/ctrl_meta|meta/, "ctrl");
b._keyMetaBuffer += a
}var e = [this._customKeymappingCache];
e = e.concat(catalog.getExtensions("keymapping"));
for(var h = 0;h < e.length;h++) {
if(!util.none(e[h].states[d])) {
util.none(e[h]._convertedRegExp) && this._buildKeymappingRegex(e[h]);
var k = this._bindingsMatch(a, c, b, e[h]);
if(!util.none(k)) {
return k
}
}
}
}b = catalog.getExtensions("command");
var i = null;
d = {};
a = a.replace(/ctrl_meta|meta/, "ctrl");
b.some(function(g) {
if(this._commandMatches(g, a, c)) {
i = g;
return true
}return false
}.bind(this));
return util.none(i) ? null : {commandExt:i, args:d}
}, _bindingsMatch:function(a, b, c, d) {
var e, h = null, k = {}, i;
i = util.none(d.hasMetaKey) ? c._keyMetaBuffer : c._keyBuffer;
if(a.indexOf("alt_") === 0 && b.isCommandKey) {
i += a
}d.states[c._keyState].some(function(g) {
if(g.key && !g.key.test(a)) {
return false
}if(g.regex && !(e = g.regex.exec(i))) {
return false
}if(g.disallowMatches) {
for(var n = 0;n < g.disallowMatches.length;n++) {
if(e[g.disallowMatches[n]]) {
return true
}
}
}if(!f.flagsMatch(g.predicates, b)) {
return false
}if(g.exec) {
h = catalog.getExtensionByKey("command", g.exec);
if(util.none(h)) {
throw new Error("Can't find command " + g.exec + " in state=" + c._keyState + ", symbolicName=" + a);
}if(g.params) {
var l;
g.params.forEach(function(j) {
l = !util.none(j.match) && !util.none(e) ? e[j.match] || j.defaultValue : j.defaultValue;
if(j.type === "number") {
l = parseInt(l, 10)
}k[j.name] = l
})
}c.resetKeyBuffers()
}if(g.then) {
c._keyState = g.then;
c.resetKeyBuffers()
}if(util.none(h)) {
h = "no command"
}return true
});
if(util.none(h)) {
return null
}return{commandExt:h, args:k}
}, _commandMatches:function(a, b, c) {
var d = a.key;
if(!d) {
return false
}if(!f.flagsMatch(a.predicates, c)) {
return false
}if(typeof d === "string") {
if(d != b) {
return false
}return true
}if(!Array.isArray(d)) {
d = [d];
a.key = d
}for(a = 0;a < d.length;a++) {
var e = d[a];
if(typeof e === "string") {
if(e == b) {
return true
}
}else {
if(e.key == b) {
return f.flagsMatch(e.predicates, c)
}
}
}return false
}, _customKeymappingChanged:function(a, b) {
a = this._customKeymappingCache = JSON.parse(b);
a.states = a.states || {};
for(state in a.states) {
this._buildBindingsRegex(a.states[state])
}a._convertedRegExp = true
}};
f.flagsMatch = function(a, b) {
if(util.none(a)) {
return true
}if(!b) {
return false
}for(var c in a) {
if(b[c] !== a[c]) {
return false
}
}return true
};
f.keyboardManager = new m
});

View file

@ -0,0 +1,101 @@
define(function(i, e) {
var h = i("pilot/event"), j = i("pilot/useragent");
e.KeyHelper = function() {
var a = {MODIFIER_KEYS:{16:"shift", 17:"ctrl", 18:"alt", 224:"meta"}, FUNCTION_KEYS:{8:"backspace", 9:"tab", 13:"return", 19:"pause", 27:"escape", 33:"pageup", 34:"pagedown", 35:"end", 36:"home", 37:"left", 38:"up", 39:"right", 40:"down", 44:"printscreen", 45:"insert", 46:"delete", 112:"f1", 113:"f2", 114:"f3", 115:"f4", 116:"f5", 117:"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:".", 188:",", 190:".", 191:"/", 192:"`", 219:"[", 220:"\\", 221:"]", 222:'"'}, PRINTABLE_KEYS_CHARCODE:{}, KEY:{}};
for(var f in a.PRINTABLE_KEYS) {
var c = a.PRINTABLE_KEYS[f];
a.PRINTABLE_KEYS_CHARCODE[c.charCodeAt(0)] = f;
if(c.toUpperCase() != c) {
a.PRINTABLE_KEYS_CHARCODE[c.toUpperCase().charCodeAt(0)] = f
}
}for(f in a.FUNCTION_KEYS) {
c = a.FUNCTION_KEYS[f].toUpperCase();
a.KEY[c] = parseInt(f, 10)
}return a
}();
var m = function(a) {
return!!(a.altKey || a.ctrlKey || a.metaKey || a.charCode !== a.which && e.KeyHelper.FUNCTION_KEYS[a.which])
};
e.commandCodes = function(a, f) {
var c = a._keyCode || a.keyCode, b = a._charCode === undefined ? a.charCode : a._charCode, d = null, k = null, g = "", l = true;
if(c === 0 && a.which === 0) {
return false
}if(b !== 0) {
return false
}if(e.KeyHelper.MODIFIER_KEYS[b]) {
return[e.KeyHelper.MODIFIER_KEYS[b], null]
}if(c) {
d = e.KeyHelper.FUNCTION_KEYS[c];
if(!d && (a.altKey || a.ctrlKey || a.metaKey)) {
d = e.KeyHelper.PRINTABLE_KEYS[c];
if(c > 47 && c < 58) {
l = a.altKey
}
}if(d) {
if(a.altKey) {
g += "alt_"
}if(a.ctrlKey) {
g += "ctrl_"
}if(a.metaKey) {
g += "meta_"
}
}else {
if(a.ctrlKey || a.metaKey) {
return false
}
}
}if(!d) {
c = a.which;
k = d = String.fromCharCode(c);
c = d.toLowerCase();
if(a.metaKey) {
g = "meta_";
d = c
}else {
d = null
}
}if(a.shiftKey && d && l) {
g += "shift_"
}if(d) {
d = g + d
}if(!f && d) {
d = d.replace(/ctrl_meta|meta/, "ctrl")
}return[d, k]
};
e.addKeyDownListener = function(a, f) {
var c = function(b) {
var d = f(b);
d && h.stopEvent(b);
return d
};
h.addListener(a, "keydown", function(b) {
if(j.isGecko) {
if(e.KeyHelper.FUNCTION_KEYS[b.keyCode]) {
return true
}else {
if((b.ctrlKey || b.metaKey) && e.KeyHelper.PRINTABLE_KEYS[b.keyCode]) {
return true
}
}
}if(m(b)) {
return c(b)
}return true
});
h.addListener(a, "keypress", function(b) {
if(j.isGecko) {
if(e.KeyHelper.FUNCTION_KEYS[b.keyCode]) {
return c(b)
}else {
if((b.ctrlKey || b.metaKey) && e.KeyHelper.PRINTABLE_KEYS_CHARCODE[b.charCode]) {
b._keyCode = e.KeyHelper.PRINTABLE_KEYS_CHARCODE[b.charCode];
b._charCode = 0;
return c(b)
}
}
}if(b.charCode !== undefined && b.charCode === 0) {
return true
}return c(b)
})
}
});

View file

@ -0,0 +1,24 @@
require.def(["require", "exports", "module", "keyboard/keyboard", "keyboard/tests/plugindev"], function(f, d, g, e, b) {
d.testKeyMatching = function() {
var c = e.keyboardManager, a = {};
b.equal(c._commandMatches(a, "meta_z", {}), false, "no keymapping means false");
a = {key:"meta_z"};
b.equal(c._commandMatches(a, "meta_z", {}), true, "matching keys, simple string");
b.equal(c._commandMatches(a, "meta_a", {}), false, "not matching key, simple string");
a = {key:{key:"meta_z", predicates:{isGreen:true}}};
b.equal(c._commandMatches(a, "meta_z", {}), false, "object with not matching predicate");
b.equal(c._commandMatches(a, "meta_z", {isGreen:true}), true, "object with matching key and predicate");
b.equal(c._commandMatches(a, "meta_a", {isGreen:true}), false, "object with not matching key");
b.equal(c._commandMatches(a, "meta_a", {isGreen:false}), false, "object with neither matching");
b.equal(c._commandMatches(a, "meta_z", {isGreen:false}), false, "object with matching key and but different predicate");
a = {key:["meta_b", {key:"meta_z", predicates:{isGreen:true}}, {key:"meta_c"}]};
b.equal(c._commandMatches(a, "meta_z", {}), false, "list: object with not matching predicate");
b.equal(c._commandMatches(a, "meta_z", {isGreen:true}), true, "list: object with matching key and predicate");
b.equal(c._commandMatches(a, "meta_a", {isGreen:true}), false, "list: object with not matching key");
b.equal(c._commandMatches(a, "meta_a", {isGreen:false}), false, "list: object with neither matching");
b.equal(c._commandMatches(a, "meta_z", {isGreen:false}), false, "list: object with matching key and but different predicate");
b.equal(c._commandMatches(a, "meta_b"), true, "list: simple key match");
b.equal(c._commandMatches(a, "meta_c"), true, "list: object without predicate match");
b.equal(c._commandMatches(a, "meta_c", {isGreen:false}), true, "list: flags don't matter without predicates")
}
});

42
build/pilot/lang.js Normal file
View file

@ -0,0 +1,42 @@
define(function(e, d) {
d.stringReverse = function(a) {
return a.split("").reverse().join("")
};
d.stringRepeat = function(a, b) {
return(new Array(b + 1)).join(a)
};
d.copyObject = function(a) {
var b = {};
for(var c in a) {
b[c] = a[c]
}return b
};
d.arrayToMap = function(a) {
for(var b = {}, c = 0;c < a.length;c++) {
b[a[c]] = 1
}return b
};
d.arrayRemove = function(a, b) {
for(var c = 0;c <= a.length;c++) {
b === a[c] && a.splice(c, 1)
}
};
d.escapeRegExp = function(a) {
return a.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1")
};
d.deferredCall = function(a) {
var b = null, c = function() {
b = null;
a()
};
return{schedule:function() {
b || (b = setTimeout(c, 0))
}, call:function() {
this.cancel();
a()
}, cancel:function() {
clearTimeout(b);
b = null
}}
}
});

18
build/pilot/oop.js Normal file
View file

@ -0,0 +1,18 @@
define(function(e, d) {
d.inherits = function(a, b) {
var c = function() {
};
c.prototype = b.prototype;
a.super_ = b.prototype;
a.prototype = new c;
a.prototype.constructor = a
};
d.mixin = function(a, b) {
for(var c in b) {
a[c] = b[c]
}
};
d.implement = function(a, b) {
d.mixin(a, b)
}
});

View file

@ -0,0 +1,68 @@
define(function(f, e) {
var g = f("pilot/promise").Promise;
e.REASONS = {APP_STARTUP:1, APP_SHUTDOWN:2, PLUGIN_ENABLE:3, PLUGIN_DISABLE:4, PLUGIN_INSTALL:5, PLUGIN_UNINSTALL:6, PLUGIN_UPGRADE:7, PLUGIN_DOWNGRADE:8};
e.Plugin = function(b) {
this.name = b;
this.status = this.INSTALLED
};
e.Plugin.prototype = {NEW:0, INSTALLED:1, REGISTERED:2, STARTED:3, UNREGISTERED:4, SHUTDOWN:5, install:function(b, d) {
var a = new g;
if(this.status > this.NEW) {
a.resolve(this);
return a
}f([this.name], function(c) {
c.install && c.install(b, d);
this.status = this.INSTALLED;
a.resolve(this)
}.bind(this));
return a
}, register:function(b, d) {
var a = new g;
if(this.status != this.INSTALLED) {
a.resolve(this);
return a
}f([this.name], function(c) {
c.register && c.register(b, d);
this.status = this.REGISTERED;
a.resolve(this)
}.bind(this));
return a
}, startup:function(b, d) {
var a = new g;
if(this.status != this.REGISTERED) {
a.resolve(this);
return a
}f([this.name], function(c) {
c.startup && c.startup(b, d);
this.status = this.STARTED;
a.resolve(this)
}.bind(this));
return a
}, shutdown:function(b, d) {
if(this.status == this.STARTED) {
pluginModule = f(this.name);
pluginModule.shutdown && pluginModule.shutdown(b, d)
}
}};
e.PluginCatalog = function() {
this.plugins = {}
};
e.PluginCatalog.prototype = {registerPlugins:function(b, d, a) {
var c = [];
b.forEach(function(i) {
var h = this.plugins[i];
if(h === undefined) {
h = new e.Plugin(i);
this.plugins[i] = h;
c.push(h.register(d, a))
}
}.bind(this));
return g.group(c)
}, startupPlugins:function(b, d) {
var a = [];
for(var c in this.plugins) {
a.push(this.plugins[c].startup(b, d))
}return g.group(a)
}};
e.catalog = new e.PluginCatalog
});

102
build/pilot/promise.js Normal file
View file

@ -0,0 +1,102 @@
define(function(l, h) {
var d = l("pilot/console"), m = l("pilot/stacktrace").Trace, n = 0, o = false, i = [], g = [];
Promise = function() {
this._status = 0;
this._value = undefined;
this._onSuccessHandlers = [];
this._onErrorHandlers = [];
this._id = n++;
i[this._id] = this
};
Promise.prototype.isPromise = true;
Promise.prototype.isComplete = function() {
return this._status != 0
};
Promise.prototype.isResolved = function() {
return this._status == 1
};
Promise.prototype.isRejected = function() {
return this._status == -1
};
Promise.prototype.then = function(a, b) {
if(typeof a === "function") {
if(this._status === 1) {
a.call(null, this._value)
}else {
this._status === 0 && this._onSuccessHandlers.push(a)
}
}if(typeof b === "function") {
if(this._status === -1) {
b.call(null, this._value)
}else {
this._status === 0 && this._onErrorHandlers.push(b)
}
}return this
};
Promise.prototype.chainPromise = function(a) {
var b = new Promise;
b._chainedFrom = this;
this.then(function(c) {
try {
b.resolve(a(c))
}catch(e) {
b.reject(e)
}
}, function(c) {
b.reject(c)
});
return b
};
Promise.prototype.resolve = function(a) {
return this._complete(this._onSuccessHandlers, 1, a, "resolve")
};
Promise.prototype.reject = function(a) {
return this._complete(this._onErrorHandlers, -1, a, "reject")
};
Promise.prototype._complete = function(a, b, c, e) {
if(this._status != 0) {
d.group("Promise already closed");
d.error("Attempted " + e + "() with ", c);
d.error("Previous status = ", this._status, ", previous value = ", this._value);
d.trace();
if(this._completeTrace) {
d.error("Trace of previous completion:");
this._completeTrace.log(5)
}d.groupEnd();
return this
}if(o) {
this._completeTrace = new m(new Error)
}this._status = b;
this._value = c;
a.forEach(function(j) {
j.call(null, this._value)
}, this);
this._onSuccessHandlers.length = 0;
this._onErrorHandlers.length = 0;
delete i[this._id];
for(g.push(this);g.length > 20;) {
g.shift()
}return this
};
Promise.group = function(a) {
a instanceof Array || (a = Array.prototype.slice.call(arguments));
if(a.length === 0) {
return(new Promise).resolve([])
}var b = new Promise, c = [], e = 0, j = function(k) {
return function(f) {
c[k] = f;
e++;
b._status !== -1 && e === a.length && b.resolve(c)
}
};
a.forEach(function(k, f) {
f = j(f);
var p = b.reject.bind(b);
k.then(f, p)
});
return b
};
h.Promise = Promise;
h._outstanding = i;
h._recent = g
});

29
build/pilot/proxy.js Normal file
View file

@ -0,0 +1,29 @@
define(function(i, f) {
var j = i("pilot/promise").Promise;
f.xhr = function(c, g, h, e) {
var d = new j;
if(!skywriter.proxy || !skywriter.proxy.xhr) {
var a = new XMLHttpRequest;
a.onreadystatechange = function() {
if(a.readyState === 4) {
var b = a.status;
if(b !== 0 && b !== 200) {
b = new Error(a.responseText + " (Status " + a.status + ")");
b.xhr = a;
d.reject(b)
}else {
d.resolve(a.responseText)
}
}
}.bind(this);
a.open("GET", g, h);
e && e(a);
a.send()
}else {
skywriter.proxy.xhr.call(this, c, g, h, e, d)
}return d
};
f.Worker = function(c) {
return!skywriter.proxy || !skywriter.proxy.worker ? new Worker(c) : new skywriter.proxy.worker(c)
}
});

84
build/pilot/rangeutils.js Normal file
View file

@ -0,0 +1,84 @@
define(function(j, c) {
var g = j("util/util");
c.addPositions = function(a, b) {
return{row:a.row + b.row, col:a.col + b.col}
};
c.cloneRange = function(a) {
var b = a.start;
a = a.end;
return{start:{row:b.row, col:b.col}, end:{row:a.row, col:a.col}}
};
c.comparePositions = function(a, b) {
var f = a.row - b.row;
return f === 0 ? a.col - b.col : f
};
c.equal = function(a, b) {
return c.comparePositions(a.start, b.start) === 0 && c.comparePositions(a.end, b.end) === 0
};
c.extendRange = function(a, b) {
var f = a.end;
return{start:a.start, end:{row:f.row + b.row, col:f.col + b.col}}
};
c.intersectRangeSets = function(a, b) {
a = g.clone(a);
b = g.clone(b);
for(var f = [];a.length > 0 && b.length > 0;) {
var d = a.shift(), e = b.shift(), h = c.comparePositions(d.start, e.start), i = c.comparePositions(d.end, e.end);
if(c.comparePositions(d.end, e.start) < 0) {
f.push(d);
b.unshift(e)
}else {
if(c.comparePositions(e.end, d.start) < 0) {
f.push(e);
a.unshift(d)
}else {
if(h < 0) {
f.push({start:d.start, end:e.start});
a.unshift({start:e.start, end:d.end});
b.unshift(e)
}else {
if(h === 0) {
if(i < 0) {
b.unshift({start:d.end, end:e.end})
}else {
i > 0 && a.unshift({start:e.end, end:d.end})
}
}else {
if(h > 0) {
f.push({start:e.start, end:d.start});
a.unshift(d);
b.unshift({start:d.start, end:e.end})
}
}
}
}
}
}return f.concat(a, b)
};
c.isZeroLength = function(a) {
return a.start.row === a.end.row && a.start.col === a.end.col
};
c.maxPosition = function(a, b) {
return c.comparePositions(a, b) > 0 ? a : b
};
c.normalizeRange = function(a) {
return this.comparePositions(a.start, a.end) < 0 ? a : {start:a.end, end:a.start}
};
c.rangeSetBoundaries = function(a) {
return{start:a[0].start, end:a[a.length - 1].end}
};
c.toString = function(a) {
var b = a.start;
a = a.end;
return"[ " + b.row + ", " + b.col + " " + a.row + "," + +a.col + " ]"
};
c.unionRanges = function(a, b) {
return{start:a.start.row < b.start.row || a.start.row === b.start.row && a.start.col < b.start.col ? a.start : b.start, end:a.end.row > b.end.row || a.end.row === b.end.row && a.end.col > b.end.col ? a.end : b.end}
};
c.isPosition = function(a) {
return!g.none(a) && !g.none(a.row) && !g.none(a.col)
};
c.isRange = function(a) {
return!g.none(a) && c.isPosition(a.start) && c.isPosition(a.end)
}
});

105
build/pilot/settings.js Normal file
View file

@ -0,0 +1,105 @@
define(function(d, e) {
function f(a, b) {
this._settings = b;
Object.keys(a).forEach(function(c) {
this[c] = a[c]
}, this);
this.type = k.getType(this.type);
if(this.type == null) {
throw new Error("In " + this.name + ": can't find type for: " + JSON.stringify(a.type));
}if(!this.name) {
throw new Error("Setting.name == undefined. Ignoring.", this);
}if(!this.defaultValue === undefined) {
throw new Error("Setting.defaultValue == undefined", this);
}this.value = this.defaultValue
}
function g(a) {
this._deactivated = {};
this._settings = {};
this._settingNames = [];
a && this.setPersister(a)
}
function h() {
}
var l = d("pilot/console"), m = d("pilot/oop"), k = d("pilot/types"), n = d("pilot/event_emitter").EventEmitter, i = d("pilot/catalog"), j = {name:"setting", description:"A setting is something that the application offers as a way to customize how it works", register:"env.settings.addSetting", indexOn:"name"};
e.startup = function() {
i.addExtensionSpec(j)
};
e.shutdown = function() {
i.removeExtensionSpec(j)
};
f.prototype = {get:function() {
return this.value
}, set:function(a) {
if(this.value !== a) {
this.value = a;
this._settings.persister && this._settings.persister.persistValue(this._settings, this.name, a);
this._dispatchEvent("change", {setting:this, value:a})
}
}, resetValue:function() {
this.set(this.defaultValue)
}};
m.implement(f.prototype, n);
g.prototype = {addSetting:function(a) {
a = new f(a, this);
this._settings[a.name] = a;
this._settingNames.push(a.name);
this._settingNames.sort()
}, removeSetting:function(a) {
a = typeof a === "string" ? a : a.name;
delete this._settings[a];
util.arrayRemove(this._settingNames, a)
}, getSettingNames:function() {
return this._settingNames
}, getSetting:function(a) {
return this._settings[a]
}, setPersister:function(a) {
(this._persister = a) && a.loadInitialValues(this)
}, resetAll:function() {
this.getSettingNames().forEach(function(a) {
this.resetValue(a)
}, this)
}, _list:function() {
var a = [];
this.getSettingNames().forEach(function(b) {
a.push({key:b, value:this.getSetting(b).get()})
}, this);
return a
}, _loadDefaultValues:function() {
this._loadFromObject(this._getDefaultValues())
}, _loadFromObject:function(a) {
for(var b in a) {
if(a.hasOwnProperty(b)) {
var c = this._settings[b];
if(c) {
c = c.type.parse(a[b]);
this.set(b, c)
}else {
this.set(b, a[b])
}
}
}
}, _saveToObject:function() {
return this.getSettingNames().map(function(a) {
return this._settings[a].type.stringify(this.get(a))
}.bind(this))
}, _getDefaultValues:function() {
return this.getSettingNames().map(function(a) {
return this._settings[a].spec.defaultValue
}.bind(this))
}};
e.settings = new g;
h.prototype = {loadInitialValues:function(a) {
a._loadDefaultValues();
var b = cookie.get("settings");
a._loadFromObject(JSON.parse(b))
}, persistValue:function(a) {
try {
var b = JSON.stringify(a._saveToObject());
cookie.set("settings", b)
}catch(c) {
l.error("Unable to JSONify the settings! " + c)
}
}};
e.CookiePersister = h
});

View file

@ -0,0 +1,9 @@
define(function(d, b) {
var c = {name:"historyLength", description:"How many typed commands do we recall for reference?", type:"number", defaultValue:50};
b.startup = function(a) {
a.env.settings.addSetting(c)
};
b.shutdown = function(a) {
a.env.settings.removeSetting(c)
}
});

145
build/pilot/stacktrace.js Normal file
View file

@ -0,0 +1,145 @@
define(function(j, h) {
function n(a) {
for(var b = 0;b < a.length;++b) {
var c = a[b];
if(typeof c == "object") {
a[b] = "#object"
}else {
if(typeof c == "function") {
a[b] = "#function"
}else {
if(typeof c == "string") {
a[b] = '"' + c + '"'
}
}
}
}return a.join(",")
}
function k() {
}
var l = j("pilot/useragent"), i = j("pilot/console"), o = function() {
return l.isGecko ? "firefox" : l.isOpera ? "opera" : "other"
}(), p = {chrome:function(a) {
var b = a.stack;
if(!b) {
i.log(a);
return[]
}return b.replace(/^.*?\n/, "").replace(/^.*?\n/, "").replace(/^.*?\n/, "").replace(/^[^\(]+?[\n$]/gm, "").replace(/^\s+at\s+/gm, "").replace(/^Object.<anonymous>\s*\(/gm, "{anonymous}()@").split("\n")
}, firefox:function(a) {
var b = a.stack;
if(!b) {
i.log(a);
return[]
}b = b.replace(/(?:\n@:0)?\s+$/m, "");
b = b.replace(/^\(/gm, "{anonymous}(");
return b.split("\n")
}, opera:function(a) {
a = a.message.split("\n");
var b = /Line\s+(\d+).*?script\s+(http\S+)(?:.*?in\s+function\s+(\S+))?/i, c, d, e;
c = 4;
d = 0;
for(e = a.length;c < e;c += 2) {
if(b.test(a[c])) {
a[d++] = (RegExp.$3 ? RegExp.$3 + "()@" + RegExp.$2 + RegExp.$1 : "{anonymous}()@" + RegExp.$2 + ":" + RegExp.$1) + " -- " + a[c + 1].replace(/^\s+/, "")
}
}a.splice(d, a.length - d);
return a
}, other:function(a) {
for(var b = /function\s*([\w\-$]+)?\s*\(/i, c = [], d = 0, e, f;a && c.length < 10;) {
e = b.test(a.toString()) ? RegExp.$1 || "{anonymous}" : "{anonymous}";
f = Array.prototype.slice.call(a.arguments);
c[d++] = e + "(" + n(f) + ")";
if(a === a.caller && window.opera) {
break
}a = a.caller
}return c
}};
k.prototype = {sourceCache:{}, ajax:function(a) {
var b = this.createXMLHTTPObject();
if(b) {
b.open("GET", a, false);
b.setRequestHeader("User-Agent", "XMLHTTP/1.0");
b.send("");
return b.responseText
}
}, createXMLHTTPObject:function() {
for(var a, b = [function() {
return new XMLHttpRequest
}, function() {
return new ActiveXObject("Msxml2.XMLHTTP")
}, function() {
return new ActiveXObject("Msxml3.XMLHTTP")
}, function() {
return new ActiveXObject("Microsoft.XMLHTTP")
}], c = 0;c < b.length;c++) {
try {
a = b[c]();
this.createXMLHTTPObject = b[c];
return a
}catch(d) {
}
}
}, getSource:function(a) {
a in this.sourceCache || (this.sourceCache[a] = this.ajax(a).split("\n"));
return this.sourceCache[a]
}, guessFunctions:function(a) {
for(var b = 0;b < a.length;++b) {
var c = a[b], d = /{anonymous}\(.*\)@(\w+:\/\/([-\w\.]+)+(:\d+)?[^:]+):(\d+):?(\d+)?/.exec(c);
if(d) {
var e = d[1];
d = d[4];
if(e && d) {
e = this.guessFunctionName(e, d);
a[b] = c.replace("{anonymous}", e)
}
}
}return a
}, guessFunctionName:function(a, b) {
try {
return this.guessFunctionNameFromLines(b, this.getSource(a))
}catch(c) {
return"getSource failed with url: " + a + ", exception: " + c.toString()
}
}, guessFunctionNameFromLines:function(a, b) {
for(var c = /function ([^(]*)\(([^)]*)\)/, d = /['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*(function|eval|new Function)/, e = "", f = 0;f < 10;++f) {
e = b[a - f] + e;
if(e !== undefined) {
var g = d.exec(e);
if(g) {
return g[1]
}else {
g = c.exec(e)
}if(g && g[1]) {
return g[1]
}
}
}return"(?)"
}};
var q = new k, m = [/http:\/\/localhost:4020\/sproutcore.js:/];
h.ignoreFramesMatching = function(a) {
m.push(a)
};
h.Trace = function(a, b) {
this._ex = a;
this._stack = p[o](a);
if(b) {
this._stack = q.guessFunctions(this._stack)
}
};
h.Trace.prototype.log = function(a) {
if(a <= 0) {
a = 999999999
}for(var b = 0, c = 0;c < this._stack.length && b < a;c++) {
var d = this._stack[c], e = true;
m.forEach(function(f) {
if(f.test(d)) {
e = false
}
});
if(e) {
i.debug(d);
b++
}
}
}
});

View file

@ -0,0 +1,42 @@
require.def(["require", "exports", "module", "rangeutils/tests/plugindev", "rangeutils/tests/utils/range"], function(f, c, g, a, b) {
c.testAddPositions = function() {
a.deepEqual(b.addPositions({row:0, col:0}, {row:0, col:0}), {row:0, col:0}, "0,0 + 0,0 and 0,0");
a.deepEqual(b.addPositions({row:1, col:0}, {row:2, col:0}), {row:3, col:0}, "1,0 + 2,0 and 3,0");
a.deepEqual(b.addPositions({row:0, col:1}, {row:0, col:1}), {row:0, col:2}, "0,1 + 0,1 and 0,2");
a.deepEqual(b.addPositions({row:1, col:2}, {row:-1, col:-2}), {row:0, col:0}, "1,2 + -1,-2 and 0,0")
};
c.testCloneRange = function() {
var d = {start:{row:1, col:2}, end:{row:3, col:4}}, e = b.cloneRange(d);
a.deepEqual(d, e, "the old range and the new range");
a.ok(d.start !== e.start, "the old range's start position is distinct from the new range's start position");
a.ok(d.end !== e.end, "the old range's end position is distinct from the new range's end position");
a.ok(d !== e, "the old range is distinct from the new range")
};
c.testComparePositions = function() {
a.equal(b.comparePositions({row:0, col:0}, {row:0, col:0}), 0, "0,0 = 0,0");
a.ok(b.comparePositions({row:0, col:0}, {row:1, col:0}) < 0, "0,0 < 1,0");
a.ok(b.comparePositions({row:0, col:0}, {row:0, col:1}) < 0, "0,0 < 0,1");
a.ok(b.comparePositions({row:1, col:0}, {row:0, col:0}) > 0, "1,0 > 0,0");
a.ok(b.comparePositions({row:0, col:1}, {row:0, col:0}) > 0, "0,1 > 0,0")
};
c.testExtendRange = function() {
a.deepEqual(b.extendRange({start:{row:1, col:2}, end:{row:3, col:4}}, {row:5, col:6}), {start:{row:1, col:2}, end:{row:8, col:10}}, "[ 1,2 3,4 ] extended by 5,6 = [ 1,2 8,10 ]");
a.deepEqual(b.extendRange({start:{row:7, col:8}, end:{row:9, col:10}}, {row:0, col:0}), {start:{row:7, col:8}, end:{row:9, col:10}}, "[ 7,8 9,10 ] extended by 0,0 remains the same")
};
c.testMaxPosition = function() {
a.deepEqual(b.maxPosition({row:0, col:0}, {row:0, col:0}), {row:0, col:0}, "max(0,0 0,0) = 0,0");
a.deepEqual(b.maxPosition({row:0, col:0}, {row:1, col:0}), {row:1, col:0}, "max(0,0 1,0) = 1,0");
a.deepEqual(b.maxPosition({row:0, col:0}, {row:0, col:1}), {row:0, col:1}, "max(0,0 0,1) = 0,1");
a.deepEqual(b.maxPosition({row:1, col:0}, {row:0, col:0}), {row:1, col:0}, "max(1,0 0,0) = 1,0");
a.deepEqual(b.maxPosition({row:0, col:1}, {row:0, col:0}), {row:0, col:1}, "max(0,1 0,0) = 0,1")
};
c.testNormalizeRange = function() {
a.deepEqual(b.normalizeRange({start:{row:0, col:0}, end:{row:0, col:0}}), {start:{row:0, col:0}, end:{row:0, col:0}}, "normalize(0,0 0,0) and (0,0 0,0)");
a.deepEqual(b.normalizeRange({start:{row:1, col:2}, end:{row:3, col:4}}), {start:{row:1, col:2}, end:{row:3, col:4}}, "normalize(1,2 3,4) and (1,2 3,4)");
a.deepEqual(b.normalizeRange({start:{row:4, col:3}, end:{row:2, col:1}}), {start:{row:2, col:1}, end:{row:4, col:3}}, "normalize(4,3 2,1) and (2,1 4,3)")
};
c.testUnionRanges = function() {
a.deepEqual(b.unionRanges({start:{row:1, col:2}, end:{row:3, col:4}}, {start:{row:5, col:6}, end:{row:7, col:8}}), {start:{row:1, col:2}, end:{row:7, col:8}}, "[ 1,2 3,4 ] union [ 5,6 7,8 ] = [ 1,2 7,8 ]");
a.deepEqual(b.unionRanges({start:{row:4, col:4}, end:{row:5, col:5}}, {start:{row:3, col:3}, end:{row:4, col:5}}), {start:{row:3, col:3}, end:{row:5, col:5}}, "[ 4,4 5,5 ] union [ 3,3 4,5 ] = [ 3,3 5,5 ]")
}
});

18
build/pilot/typecheck.js Normal file
View file

@ -0,0 +1,18 @@
define(function(d, b) {
var c = Object.prototype.toString;
b.isString = function(a) {
return a && c.call(a) === "[object String]"
};
b.isBoolean = function(a) {
return a && c.call(a) === "[object Boolean]"
};
b.isNumber = function(a) {
return a && c.call(a) === "[object Number]" && isFinite(a)
};
b.isObject = function(a) {
return a !== undefined && (a === null || typeof a == "object" || Array.isArray(a) || b.isFunction(a))
};
b.isFunction = function(a) {
return a && c.call(a) === "[object Function]"
}
});

77
build/pilot/types.js Normal file
View file

@ -0,0 +1,77 @@
define(function(k, c) {
function h(a, b, i, j) {
this.value = a;
this.status = b || e.VALID;
this.message = i;
this.predictions = j || []
}
function f() {
}
function g(a, b) {
a = d[a];
if(typeof a === "function") {
a = new a(b)
}return a
}
var e = {VALID:{toString:function() {
return"VALID"
}, valueOf:function() {
return 0
}}, INCOMPLETE:{toString:function() {
return"INCOMPLETE"
}, valueOf:function() {
return 1
}}, INVALID:{toString:function() {
return"INVALID"
}, valueOf:function() {
return 2
}}, combine:function() {
for(var a = e.VALID, b = 0;b < arguments;b++) {
if(arguments[b] > a) {
a = arguments[b]
}
}return a
}};
c.Status = e;
c.Conversion = h;
f.prototype = {stringify:function() {
throw new Error("not implemented");
}, parse:function() {
throw new Error("not implemented");
}, name:undefined, increment:function() {
}, decrement:function() {
}};
c.Type = f;
var d = {};
c.registerType = function(a) {
if(typeof a === "object") {
if(a instanceof f) {
if(!a.name) {
throw new Error("All registered types must have a name");
}d[a.name] = a
}else {
throw new Error("Can't registerType using: " + a);
}
}else {
if(typeof a === "function") {
if(!a.prototype.name) {
throw new Error("All registered types must have a name");
}d[a.prototype.name] = a
}else {
throw new Error("Unknown type: " + a);
}
}
};
c.deregisterType = function(a) {
delete d[a.name]
};
c.getType = function(a) {
if(typeof a === "string") {
return g(a, a)
}if(typeof a == "object") {
if(!a.name) {
throw new Error("Missing 'name' member to typeSpec");
}return g(a.name, a)
}throw new Error("Can't extract type from " + a);
}
});

144
build/pilot/types/basic.js Normal file
View file

@ -0,0 +1,144 @@
define(function(g, j) {
function d(a) {
if(!Array.isArray(a.data) && typeof a.data !== "function") {
throw new Error("instances of SelectionType need typeSpec.data to be an array or function that returns an array:" + JSON.stringify(a));
}Object.keys(a).forEach(function(b) {
this[b] = a[b]
}, this)
}
function e(a) {
if(typeof a.defer !== "function") {
throw new Error("Instances of DeferredType need typeSpec.defer to be a function that returns a type");
}Object.keys(a).forEach(function(b) {
this[b] = a[b]
}, this)
}
var c = g("pilot/types");
g = c.Type;
var h = c.Conversion, k = c.Status, i = new g;
i.stringify = function(a) {
return a
};
i.parse = function(a) {
if(typeof a != "string") {
throw new Error("non-string passed to text.parse()");
}return new h(a)
};
i.name = "text";
var f = new g;
f.stringify = function(a) {
if(!a) {
return null
}return"" + a
};
f.parse = function(a) {
if(typeof a != "string") {
throw new Error("non-string passed to number.parse()");
}if(a.replace(/\s/g, "").length === 0) {
return new h(null, k.INCOMPLETE, "")
}var b = new h(parseInt(a, 10));
if(isNaN(b.value)) {
b.status = k.INVALID;
b.message = "Can't convert \"" + a + '" to a number.'
}return b
};
f.decrement = function(a) {
return a - 1
};
f.increment = function(a) {
return a + 1
};
f.name = "number";
d.prototype = new g;
d.prototype.stringify = function(a) {
return a
};
d.prototype.parse = function(a) {
if(typeof a != "string") {
throw new Error("non-string passed to parse()");
}if(!this.data) {
throw new Error("Missing data on selection type extension.");
}var b = false, o, l = [];
(typeof this.data === "function" ? this.data() : this.data).forEach(function(m) {
if(a == m) {
o = this.fromString(m);
b = true
}else {
m.indexOf(a) === 0 && l.push(this.fromString(m))
}
}, this);
if(b) {
return new h(o)
}else {
this.noMatch && this.noMatch();
if(l.length > 0) {
var n = "Possibilities" + (a.length === 0 ? "" : " for '" + a + "'");
return new h(null, k.INCOMPLETE, n, l)
}else {
n = "Can't use '" + a + "'.";
return new h(null, k.INVALID, n, l)
}
}
};
d.prototype.fromString = function(a) {
return a
};
d.prototype.decrement = function(a) {
var b = typeof this.data === "function" ? this.data() : this.data;
if(a == null) {
a = b.length - 1
}else {
a = this.stringify(a);
a = b.indexOf(a);
a = a === 0 ? b.length - 1 : a - 1
}return this.fromString(b[a])
};
d.prototype.increment = function(a) {
var b = typeof this.data === "function" ? this.data() : this.data;
if(a == null) {
a = 0
}else {
a = this.stringify(a);
a = b.indexOf(a);
a = a === b.length - 1 ? 0 : a + 1
}return this.fromString(b[a])
};
d.prototype.name = "selection";
j.SelectionType = d;
var p = new d({name:"bool", data:["true", "false"], stringify:function(a) {
return"" + a
}, fromString:function(a) {
return a === "true" ? true : false
}});
e.prototype = new g;
e.prototype.stringify = function(a) {
return this.defer().stringify(a)
};
e.prototype.parse = function(a) {
return this.defer().parse(a)
};
e.prototype.decrement = function(a) {
var b = this.defer();
return b.decrement ? b.decrement(a) : undefined
};
e.prototype.increment = function(a) {
var b = this.defer();
return b.increment ? b.increment(a) : undefined
};
e.prototype.name = "deferred";
j.DeferredType = e;
j.startup = function() {
c.registerType(i);
c.registerType(f);
c.registerType(p);
c.registerType(d);
c.registerType(e)
};
j.shutdown = function() {
c.unregisterType(i);
c.unregisterType(f);
c.unregisterType(p);
c.unregisterType(d);
c.unregisterType(e)
}
});

View file

@ -0,0 +1,15 @@
define(function(a, c) {
var d = a("pilot/canon"), g = a("pilot/types/basic").SelectionType, e = a("pilot/types"), f = new g({name:"command", data:function() {
return d.getCommandNames()
}, stringify:function(b) {
return b.name
}, fromString:function(b) {
return d.getCommand(b)
}});
c.startup = function() {
e.registerType(f)
};
c.shutdown = function() {
e.unregisterType(f)
}
});

View file

@ -0,0 +1,23 @@
define(function(d, e) {
var i = d("pilot/types/basic").SelectionType, j = d("pilot/types/basic").DeferredType, b = d("pilot/types"), k = d("pilot/settings").settings, c, g = new i({name:"setting", data:function() {
return f.settings.getSettingNames()
}, stringify:function(a) {
c = a;
return a.name
}, fromString:function(a) {
return c = k.getSetting(a)
}, noMatch:function() {
c = null
}}), h = new j({name:"settingValue", defer:function() {
return c ? c.type : b.getType("text")
}}), f;
e.startup = function(a) {
f = a.env;
b.registerType(g);
b.registerType(h)
};
e.shutdown = function() {
b.unregisterType(g);
b.unregisterType(h)
}
});

16
build/pilot/useragent.js Normal file
View file

@ -0,0 +1,16 @@
define(function(b, a) {
b = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
var c = navigator.userAgent;
a.isWin = b == "win";
a.isMac = b == "mac";
a.isLinux = b == "linux";
a.isIE = !+"\u000b1";
a.isGecko = a.isMozilla = window.controllers && window.navigator.product === "Gecko";
a.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
a.isWebKit = parseFloat(c.split("WebKit/")[1]) || undefined;
a.isAIR = c.indexOf("AdobeAIR") >= 0;
a.OS = {LINUX:"LINUX", MAC:"MAC", WINDOWS:"WINDOWS"};
a.getOS = function() {
return a.isMac ? a.OS.MAC : a.isLinux ? a.OS.LINUX : a.OS.WINDOWS
}
});