UNPKG

@cypress/core-desktop-gui

Version:
1,648 lines (1,462 loc) 136 kB
(function() { (function($) { return $(function() { return $('[data-toggle="tooltip"]').tooltip(); }); })($); }).call(this); ; (function() { this.App = (function(Backbone, Marionette) { var App, about, debug, projects, updates, updating; about = function() { return App.vent.trigger("start:about:app", App.aboutRegion); }; debug = function() { return App.vent.trigger("start:debug:app", App.debugRegion); }; updates = function() { return App.vent.trigger("start:updates:app", App.updatesRegion); }; updating = function(options) { return App.execute("start:updates:applied:app"); }; projects = function() { return App.ipc("get:current:user").then(function(user) { App.execute("set:current:user", user); if (user && (user.session_token != null)) { App.vent.trigger("start:projects:app"); } else { App.vent.trigger("start:login:app"); } return App.vent.trigger("start:footer:app"); }); }; App = new Marionette.Application; App.addRegions({ updatesRegion: "#updates-region", aboutRegion: "#about-region", debugRegion: "#debug-region", mainRegion: "#main-region", footerRegion: "#footer-region" }); App.reqres.setHandler("default:region", function() { return App.mainRegion; }); App.on("start", function(mode) { return App.ipc("get:options").then(function(options) { var sendErr; if (options == null) { options = {}; } App.config = App.request("config:entity", options); App.updater = App.request("new:updater:entity", options.version); sendErr = function(err) { return App.ipc("gui:error", _.pick(err, "name", "message", "stack")); }; window.onerror = function(message, source, lineno, colno, err) { return sendErr(err); }; window.onunhandledrejection = sendErr; if (options.updating) { return updating(options); } switch (mode) { case "about": return about(); case "debug": return debug(); case "updates": return updates(); default: return projects(); } }); }); return App; })(Backbone, Marionette); }).call(this); ; if (!window.JST) { window.JST = {}; } window.JST["backbone/lib/templates/_empty"] = function (__obj) { if (!__obj) __obj = {}; var __out = [], __capture = function(callback) { var out = __out, result; __out = []; callback.call(this); result = __out.join(''); __out = out; return __safe(result); }, __sanitize = function(value) { if (value && value.ecoSafe) { return value; } else if (typeof value !== 'undefined' && value != null) { return __escape(value); } else { return ''; } }, __safe, __objSafe = __obj.safe, __escape = __obj.escape; __safe = __obj.safe = function(value) { if (value && value.ecoSafe) { return value; } else { if (!(typeof value !== 'undefined' && value != null)) value = ''; var result = new String(value); result.ecoSafe = true; return result; } }; if (!__escape) { __escape = __obj.escape = function(value) { return ('' + value) .replace(/&/g, '&amp;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;') .replace(/"/g, '&quot;'); }; } (function() { (function() { __out.push("<" + this.containerTag + ">"); __out.push('\n <span>\n '); __out.push(__sanitize(this.content)); __out.push('\n </span>\n'); __out.push("</" + this.containerTag + ">"); }).call(this); }).call(__obj); __obj.safe = __objSafe, __obj.escape = __escape; return __out.join(''); }; ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Entities", function(Entities, App, Backbone, Marionette, $, _) { return Entities.Collection = (function(superClass) { extend(Collection, superClass); function Collection() { return Collection.__super__.constructor.apply(this, arguments); } return Collection; })(Backbone.Collection); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Entities", function(Entities, App, Backbone, Marionette, $, _) { Entities.Model = (function(superClass) { extend(Model, superClass); function Model() { return Model.__super__.constructor.apply(this, arguments); } return Model; })(Backbone.Model); return App.reqres.setHandler("new:entity", function(attrs) { if (attrs == null) { attrs = {}; } return new Entities.Model(attrs); }); }); }).call(this); ; (function() { this.App.module("Utilities", function(Utilities, App, Backbone, Marionette, $, _) { var API, alreadyOpen; alreadyOpen = function(err) { return err && err.alreadyOpen; }; API = { loginRequest: function() { return App.ipc("window:open", { position: "center", focus: true, width: 1000, height: 635, preload: false, title: "Login", type: "GITHUB_LOGIN" }).then(function(code) { App.currentUser.loggingIn(); return App.ipc("log:in", code); }).then(function(user) { App.currentUser.loggedIn(user); return App.vent.trigger("start:projects:app"); })["catch"](alreadyOpen, function(err) {})["catch"](function(err) { return App.currentUser.setLoginError(err); }); }, logOut: function(user) { App.vent.trigger("start:login:app"); return App.ipc("log:out").then(function() { return App.ipc("clear:github:cookies"); }); } }; App.commands.setHandler("login:request", function() { return API.loginRequest(); }); App.reqres.setHandler("current:user", function() { return App.currentUser || (function() { throw new Error("No current user set on App!"); })(); }); App.commands.setHandler("set:current:user", function(attrs) { if (attrs == null) { attrs = {}; } return App.currentUser = App.request("new:user:entity", attrs); }); return App.vent.on("log:out", function(user) { return API.logOut(user); }); }); }).call(this); ; (function() { this.App.module("Utilities", function(Utilities, App, Backbone, Marionette, $, _) { return App.silenceConsole = function() { var c; c = console; return _.each(["log", "warn", "info", "error"], function(fn) { return c[fn] = function() {}; }); }; }); }).call(this); ; (function() { this.App.module("Utilities", function(Utilities, App, Backbone, Marionette, $, _) { var API, windows; windows = {}; API = { about: function() { return App.ipc("window:open", { position: "center", width: 300, height: 230, toolbar: false, title: "About", type: "ABOUT" }); }, updates: function() { return App.ipc("window:open", { position: "center", width: 300, height: 210, toolbar: false, title: "Updates", type: "UPDATES" }); }, debug: function() { return App.ipc("window:open", { position: "center", width: 800, height: 400, toolbar: false, title: "Debug Console", type: "DEBUG" }); }, preferences: function() { return App.ipc("window:open", { position: "center", width: 520, height: 270, toolbar: false, title: "Preferences", type: "PREFERENCES" }); }, tests: function() { var tests; if (!App.config.get("debug")) { return; } tests = App.request("gui:open", "http://localhost:3500", { position: "center", height: 1024, width: 768, title: "Cypress Tests" }); return tests.once("loaded", function() { return tests.showDevTools(); }); } }; App.reqres.setHandler("gui:open", function(url, options) { if (options == null) { options = {}; } return API.open(url, options); }); App.commands.setHandler("gui:check:for:updates", function() { return API.updates(); }); App.commands.setHandler("gui:debug", function() { return API.debug(); }); App.commands.setHandler("gui:tests", function() { return API.tests(); }); App.commands.setHandler("gui:about", function() { return API.about(); }); return App.commands.setHandler("gui:preferences", function() { return API.preferences(); }); }); }).call(this); ; (function() { var slice = [].slice; this.App.module("Utilities", function(Utilities, App, Backbone, Marionette, $, _) { var addMsg, createIpc, ipc, msgs, removeMsgById, removeMsgsByEvent; msgs = {}; addMsg = function(id, event, fn) { return msgs[id] = { event: event, fn: fn }; }; removeMsgsByEvent = function(event) { return msgs = _(msgs).omit(function(msg) { return msg.event === event; }); }; removeMsgById = function(id) { return msgs = _(msgs).omit("" + id); }; createIpc = function() { var responses; console.warn("Missing 'ipc'. Polyfilling in development mode."); responses = []; return { on: function() {}, off: function() {}, send: function(resp, id, event) { var response; if (response = _.find(responses, { event: event })) { responses = _.without(responses, response); return Promise.delay(1).then((function(_this) { return function() { _this.handle(event, response.err, response.data); return response.resolve(); }; })(this)); } }, handle: function(event, err, data) { return new Promise(function(resolve, reject) { var msg; msg = _.chain(msgs).where({ event: event }).first().value(); if (msg) { msg.fn(err, data); return resolve(); } else { return responses.push({ event: event, err: err, data: data, resolve: resolve }); } }); } }; }; ipc = window.ipc != null ? window.ipc : window.ipc = createIpc(); ipc.on("response", function(event, obj) { var __error, data, id, msg; if (obj == null) { obj = {}; } id = obj.id, __error = obj.__error, data = obj.data; if (msg = msgs[id]) { return msg.fn(__error, data); } }); App.ipc = function() { var args, event, fn, id, lastArg; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; if (args.length === 0) { return msgs; } id = Math.random(); event = args[0]; lastArg = args.pop(); if (lastArg && _.isFunction(lastArg)) { fn = function() { return addMsg(id, event, lastArg); }; } else { args.push(lastArg); fn = function() { return new Promise(function(resolve, reject) { return addMsg(id, event, function(err, data) { removeMsgById(id); if (err) { return reject(err); } else { return resolve(data); } }); }); }; } ipc.send.apply(ipc, ["request", id].concat(args)); return fn(); }; return App.ipc.off = function(event) { return removeMsgsByEvent(event); }; }); }).call(this); ; (function() { this.App.module("Utilities", function(Utilities, App, Backbone, Marionette, $, _) { var methods; methods = { lookups: ["backbone/apps/", "backbone/lib/components/", "backbone/lib/templates/", "support/"], withTemplate: function(string) { var array; array = string.split("/"); array.splice(-1, 0, "templates"); return array.join("/"); } }; return _.extend(Marionette.Renderer, { render: function(template, data) { var path; if (data == null) { data = {}; } if (template === false) { return; } path = this.getTemplate(template); if (!path) { throw new Error("Template " + template + " not found!"); } return path(data); }, getTemplate: function(template) { var i, j, len, len1, lookup, path, ref, ref1; ref = methods.lookups; for (i = 0, len = ref.length; i < len; i++) { lookup = ref[i]; ref1 = [template, methods.withTemplate(template)]; for (j = 0, len1 = ref1.length; j < len1; j++) { path = ref1[j]; if (JST[lookup + path]) { return JST[lookup + path]; } } } }, templateExists: function(path) { return !!this.getTemplate(path); } }); }); }).call(this); ; (function() { var slice = [].slice; this.App.module("Utilities", function(Utilities, App, Backbone, Marionette, $, _) { return window.Routes = (function(_, Backbone) { var Routes, addRoutes, createPathFn, extractObjectParams, extractParams, getParams, getQueryParams, parseArray, parseObject, r, replacePath; getParams = /(:([\w\d]+)|\*([\w\d]+))/g; replacePath = function(path, part, replacement) { if (replacement != null) { return path.replace(part, replacement); } else { return path; } }; parseObject = function(parts, path, obj) { return _.reduce(parts, function(memo, part, index) { var sliced; sliced = part.slice(1); return memo = replacePath(memo, part, obj[sliced]); }, path); }; parseArray = function(parts, path, args) { return _.reduce(parts, function(memo, part, index) { return memo = replacePath(memo, part, args[index]); }, path); }; extractParams = function(args, parts) { var count; if (parts == null) { parts = []; } count = _.isObject(args[0]) ? _.keys(args[0]).length : args.length; if (count <= parts.length) { return; } if (_.isObject(args[0])) { return extractObjectParams(args[0], parts); } else { return args.pop(); } }; extractObjectParams = function(obj, parts) { var partsOfRoute, ref; partsOfRoute = _.map(parts, function(part) { return part.replace(/(:|\*)/, ""); }); return (ref = _(obj)).omit.apply(ref, partsOfRoute); }; getQueryParams = function(path, args, parts) { var params; params = extractParams(args, parts); if (!params) { return path; } return Backbone.Router.prototype.toFragment(path, params); }; createPathFn = function(pathString) { var parts; parts = pathString.match(getParams); return function() { var args, path; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; path = pathString.toString(); if (args.length) { path = (function() { switch (false) { case !_.isObject(args[0]): return parseObject(parts, path, args[0]); default: return parseArray(parts, path, args); } })(); } if (!/^(http|\/\/)/.test(path)) { path = "/" + path; } path = getQueryParams(path, args, parts); return path; }; }; addRoutes = function(obj, routes) { var name, path, results; results = []; for (name in routes) { path = routes[name]; obj.routes[name] = path; results.push(obj[name + "_path"] = createPathFn(path)); } return results; }; Routes = (function() { function Routes(routes1) { this.routes = routes1 != null ? routes1 : {}; } return Routes; })(); r = new Routes; r.url_for = function(name) { return this.routes[name]; }; r.create = function() { var args, path; path = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; return createPathFn(path).apply(this, args); }; return r; })(_, Backbone); }); }).call(this); ; (function() { this.App.module("Views", function(Views, App, Backbone, Marionette, $, _) { var _mixinTemplateHelpers; _mixinTemplateHelpers = Marionette.View.prototype.mixinTemplateHelpers; return _.extend(Marionette.View.prototype, { mixinTemplateHelpers: function(target) { target.env = App.config.env(); target.debug = App.config.get("debug"); return _mixinTemplateHelpers.call(this, target); }, stopProp: function(e) { return e.stopPropagation(); } }); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Views", function(Views, App, Backbone, Marionette, $, _) { return Views.CollectionView = (function(superClass) { extend(CollectionView, superClass); function CollectionView() { return CollectionView.__super__.constructor.apply(this, arguments); } CollectionView.prototype.childViewOptions = function(model, index) { var options; options = {}; if (this.tagName === "ul") { options.tagName = "li"; } return options; }; return CollectionView; })(Marionette.CollectionView); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Views", function(Views, App, Backbone, Marionette, $, _) { return Views.CompositeView = (function(superClass) { extend(CompositeView, superClass); function CompositeView() { var options; CompositeView.__super__.constructor.apply(this, arguments); options = {}; if (this.isTbody()) { options.tagName = "tr"; } if (this.isUl()) { options.tagName = "li"; } this.childViewOptions = _.extend({}, _.result(this, "childViewOptions"), options); } CompositeView.prototype.buildChildView = function(item, childViewType, childViewOptions) { if (this.isTbody()) { childViewOptions.tableColumns = this.$el.find("th").length; } return CompositeView.__super__.buildChildView.apply(this, arguments); }; CompositeView.prototype.isTbody = function() { return this.childViewContainer === "tbody"; }; CompositeView.prototype.isUl = function() { return this.childViewContainer === "ul"; }; return CompositeView; })(Marionette.CompositeView); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Views", function(Views, App, Backbone, Marionette, $, _) { return Views.EmptyView = (function(superClass) { extend(EmptyView, superClass); EmptyView.prototype.template = "_empty"; EmptyView.prototype.ui = { container: ":first" }; function EmptyView() { EmptyView.__super__.constructor.apply(this, arguments); this.$el.addClass("empty"); } EmptyView.prototype.serializeData = function() { var ref; return { containerTag: this.getContainerTag(), content: (ref = _.result(this, "content")) != null ? ref : "No items found." }; }; EmptyView.prototype.onShow = function() { if (this.isRow()) { return this.ui.container.prop("colspan", this.options.tableColumns); } }; EmptyView.prototype.isRow = function() { return this.tagName === "tr"; }; EmptyView.prototype.getContainerTag = function() { if (this.isRow()) { return "td"; } return "div"; }; return EmptyView; })(Marionette.ItemView); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Views", function(Views, App, Backbone, Marionette, $, _) { return Views.ItemView = (function(superClass) { extend(ItemView, superClass); function ItemView() { return ItemView.__super__.constructor.apply(this, arguments); } return ItemView; })(Marionette.ItemView); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Views", function(Views, App, Backbone, Marionette, $, _) { return Views.LayoutView = (function(superClass) { var regionRegex; extend(LayoutView, superClass); function LayoutView() { return LayoutView.__super__.constructor.apply(this, arguments); } regionRegex = /(.+)-region/; LayoutView.prototype.getRegionsByEl = true; LayoutView.prototype.render = function() { LayoutView.__super__.render.apply(this, arguments); return this._getRegionsByEl(); }; LayoutView.prototype._childNodes = function() { return this.$el.find("*"); }; LayoutView.prototype._getRegionsByEl = function() { var regions, selectors; if (!this.getRegionsByEl || !this.$el) { return; } selectors = _.reduce(this._childNodes(), function(memo, e) { var match; match = regionRegex.exec($(e).prop("id")); if (match) { memo.push(match[0]); } return memo; }, []); regions = _.reduce(selectors, function(memo, region) { memo[_.str.camelize(region)] = "#" + region; return memo; }, {}); return this.addRegions(regions); }; return LayoutView; })(Marionette.LayoutView); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Controllers", function(Controllers, App, Backbone, Marionette, $, _) { return Controllers.Application = (function(superClass) { extend(Application, superClass); function Application(options) { var ref; if (options == null) { options = {}; } this.region = (ref = options.region) != null ? ref : App.request("default:region"); Application.__super__.constructor.apply(this, arguments); } Application.prototype.show = function(view, options) { var ref; if (options == null) { options = {}; } view = view instanceof Controllers.Application ? view.getMainView() : view; if (!view) { throw new Error("getMainView() did not return a view instance or " + (view != null ? (ref = view.constructor) != null ? ref.name : void 0 : void 0) + " is not a view instance"); } _.defaults(options, { region: this.region }); this.setMainView(view); return this._manageView(view, options); }; Application.prototype.getMainView = function() { return this._mainView; }; Application.prototype.setMainView = function(view) { if (this._mainView) { return; } this._mainView = view; return this.listenTo(view, "destroy", this.destroy); }; Application.prototype.onMainShow = function() {}; Application.prototype._manageView = function(view, options) { if (options.region) { return options.region.show(view); } }; return Application; })(Marionette.Controller); }); }).call(this); ; (function() { var slice = [].slice; this.App.module("Routers", function(Routers, App, Backbone, Marionette, $, _) { var routeParams; routeParams = /(:([\w\d]+)|\*([\w\d]+))/g; Routers.Application = (function() { Application.prototype.initialize = true; Application.prototype.module = void 0; Application.prototype.updateUrl = true; Application.prototype.before = function() {}; Application.prototype.after = function() {}; Application.prototype.controllerMap = { "list": "List", "show": "Show", "edit": "Edit", "new": "New", "destroy": "Destroy" }; function Application() { this.routes = this._createRoutes(); this.handlers = this._createHandlers(); if (this.initialize && this.hasRoutes()) { App.addRouter(this); } } Application.prototype.to = function(action, options) { if (options == null) { options = {}; } return this.handlers[action](options); }; Application.prototype.hasRoutes = function() { return !_.isEmpty(this.routes); }; Application.prototype._createRoutes = function() { var routes; routes = this._getActions((function(_this) { return function(action, key) { if (_.isUndefined(action) || !_(action).has("route")) { return []; } return [action.route, key]; }; })(this)); return this._toObject(routes); }; Application.prototype._createHandlers = function() { var handlers; handlers = this._getActions((function(_this) { return function(action, key) { var fn; fn = function(options) { var controller, resolve; resolve = options.resolve; controller = new (_this._getController(action, key))(options); return typeof resolve === "function" ? resolve(controller) : void 0; }; fn = _.wrap(fn, function() { var args, before, df, options, orig; orig = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; options = _this._normalizeArguments(args, action, key); df = $.Deferred(); df._id = _.uniqueId("deferred"); _.defaults(options, { resolve: df.resolve }); if (!options.resolve) { options.deferred = df; } before = _this._invokeBefore(options, action); if (before === false) { return; } if (_this._shouldUpdateUrl(action, args)) { _this._updateUrl(action, options); } $.when(before).done(function() { return orig.call(_this, options); }); return df; }); return [key, fn]; }; })(this)); return this._toObject(handlers); }; Application.prototype._normalizeArguments = function(args, action, key) { var defaultParams; if (this._argsArePresentAndStrings(args)) { args[0] = this._parseStringMatches(args, action, key); } if (args[0] == null) { args[0] = {}; } defaultParams = _.isFunction(action != null ? action.defaultParams : void 0) ? action.defaultParams.call(this) : action != null ? action.defaultParams : void 0; _.defaults(args[0], defaultParams || {}); return args[0]; }; Application.prototype._parseStringMatches = function(args, action, key) { var matches, params, queryParams, route, strings; route = action != null ? action.route : void 0; if (!route) { throw new Error("Routes must be defined on the action: " + key); } matches = route.match(routeParams); queryParams = this._getObjsFromArgs(args); strings = this._getStringsFromArgs(args); params = _.reduce(strings, function(memo, arg, i) { memo[matches[i].slice(1)] = arg; return memo; }, {}); return _.extend({}, queryParams, params); }; Application.prototype._getObjsFromArgs = function(args) { args = _(args).filter(_.isObject); return _.extend.apply(_, [{}].concat(slice.call(args))); }; Application.prototype._getStringsFromArgs = function(args) { return _(args).filter(_.isString); }; Application.prototype._invokeBefore = function(options, action) { var before; if (!(before = this._shouldInvokeBefore(action))) { return; } return before.call(this, options); }; Application.prototype._shouldInvokeBefore = function(action) { return (action != null ? action.before : void 0) || this.before; }; Application.prototype._interpolateUrl = function(action, options) { options = _(options).reduce(function(memo, value, key) { if (!_.isObject(value) || _.isArray(value)) { memo[key] = value; } return memo; }, {}); return Routes.create(action.route, options); }; Application.prototype._updateUrl = function(action, options) { var route; route = this._interpolateUrl(action, options); if (App.currentRoute() !== route.replace(/^\//, "")) { return App.visit(route); } }; Application.prototype._shouldUpdateUrl = function(action, args) { if (!(action != null ? action.route : void 0) || this._argsArePresentAndStrings(args)) { return false; } if (action && _(action).has("updateUrl")) { return action != null ? action.updateUrl : void 0; } return this.updateUrl; }; Application.prototype._getActions = function(fn) { return _(this.actions).map((function(_this) { return function(action, key) { action = _.result(_this.actions, key); return fn(action, key); }; })(this)); }; Application.prototype._getController = function(action, key) { switch (false) { case !_.isFunction(action != null ? action.controller : void 0): return action.controller; case !_.isUndefined(this.module): throw new Error("Module must be defined on the resource in order to instantiate a controller"); break; case !_.isString(action != null ? action.controller : void 0): return this._getControllerConstructor(this.module[action.controller]); default: return this._getControllerConstructor(this.module[this.controllerMap[key]], this.controllerMap[key], this.module.moduleName); } }; Application.prototype._getControllerConstructor = function(obj, key, module) { var err, error; try { if (_.isFunction(obj)) { return obj; } else { return obj.Controller; } } catch (error) { err = error; throw new Error("The '" + key + "' Controller was not found for for the module: '" + module + "'"); } }; Application.prototype._argsArePresentAndStrings = function(args) { return !_.isEmpty(args) && _.any(args, _.isString); }; Application.prototype._toObject = function(array) { return _.chain(array).reject(_.isEmpty).object().value(); }; return Application; })(); return App.addRouter = function(resource) { return App.addInitializer(function() { return new Marionette.AppRouter({ appRoutes: resource.routes, controller: resource.handlers }); }); }; }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Entities", function(Entities, App, Backbone, Marionette, $, _) { var API; Entities.Browser = (function(superClass) { extend(Browser, superClass); function Browser() { return Browser.__super__.constructor.apply(this, arguments); } Browser.prototype.mutators = { icon: function() { switch (this.attributes.name) { case "chrome": case "chromium": case "canary": return "chrome"; } }, displayName: function() { return _.str.capitalize(this.attributes.name); } }; return Browser; })(Entities.Model); Entities.BrowsersCollection = (function(superClass) { extend(BrowsersCollection, superClass); function BrowsersCollection() { return BrowsersCollection.__super__.constructor.apply(this, arguments); } BrowsersCollection.prototype.model = Entities.Browser; BrowsersCollection.prototype.chooseBrowserByName = function(name) { var chosen; chosen = this.findWhere({ chosen: true }); if (chosen.get("name") === name) { return chosen; } chosen.unset("chosen"); return this.findWhere({ name: name }).set("chosen", true); }; BrowsersCollection.prototype.extractDefaultBrowser = function() { var chosenBrowser, ref; if (this.length === 0) { return void 0; } chosenBrowser = (ref = this.findWhere({ "default": true })) != null ? ref : this.first(); chosenBrowser.set({ chosen: true }); return chosenBrowser; }; return BrowsersCollection; })(Entities.Collection); API = { newBrowsers: function(browsers) { return new Entities.BrowsersCollection(browsers); } }; return App.reqres.setHandler("new:browser:entities", function(browsers) { if (browsers == null) { browsers = []; } return API.newBrowsers(browsers); }); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Entities", function(Entities, App, Backbone, Marionette, $, _) { Entities.Config = (function(superClass) { extend(Config, superClass); function Config() { return Config.__super__.constructor.apply(this, arguments); } Config.prototype.env = function(str) { var env; env = this.get("env"); switch (false) { case !_.isString(str): return env === str; default: return env; } }; Config.prototype.log = function(text, data) { if (data == null) { data = {}; } data.type = "native"; return this.getLog().log("info", text, data); }; Config.prototype.getToken = function(user) { return this.getCache().getToken(user.get("session_token")); }; Config.prototype.generateToken = function(user) { return this.getCache().generateToken(user.get("session_token")); }; return Config; })(Entities.Model); return App.reqres.setHandler("config:entity", function(attrs) { if (attrs == null) { attrs = {}; } return new Entities.Config(attrs); }); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Entities", function(Entities, App, Backbone, Marionette, $, _) { var API; Entities.Log = (function(superClass) { extend(Log, superClass); function Log() { return Log.__super__.constructor.apply(this, arguments); } Log.prototype.mutators = { dataFormatted: function() { var data, error; if (_.isEmpty(this.get("data"))) { return ""; } try { data = JSON.stringify(this.get("data")); return _.str.truncate(data, 85); } catch (error) { return ""; } }, timestampFormatted: function() { var date; if (date = this.get("timestamp")) { return moment(date).fromNow(true); } } }; return Log; })(Entities.Model); Entities.LogsCollection = (function(superClass) { extend(LogsCollection, superClass); function LogsCollection() { return LogsCollection.__super__.constructor.apply(this, arguments); } LogsCollection.prototype.model = Entities.Log; LogsCollection.prototype.comparator = function(log) { var date; if (date = log.get("timestamp")) { return -moment(date).unix(); } }; LogsCollection.prototype.refresh = function() { this.reset(); return this.fetch(); }; LogsCollection.prototype.fetch = function() { return App.ipc("get:logs").bind(this).then(this.add); }; return LogsCollection; })(Entities.Collection); API = { getLogs: function() { var logs; logs = new Entities.LogsCollection; logs.fetch(); return logs; } }; return App.reqres.setHandler("log:entities", function(transport) { return API.getLogs(transport); }); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Entities", function(Entities, App, Backbone, Marionette, $, _) { Entities.Preferences = (function(superClass) { extend(Preferences, superClass); function Preferences() { return Preferences.__super__.constructor.apply(this, arguments); } Preferences.prototype.defaults = function() { return { token: null, error: false, runOnStartup: false, generatingToken: false }; }; Preferences.prototype.setToken = function(token) { this.set("generatingToken", false); return this.set("token", token); }; Preferences.prototype.generateToken = function() { return this.set("generatingToken", true); }; Preferences.prototype.isGeneratingToken = function() { return this.get("generatingToken"); }; Preferences.prototype.setError = function() { return this.set("error", true); }; return Preferences; })(Entities.Model); return App.reqres.setHandler("new:preferences:entity", function(attrs) { if (attrs == null) { attrs = {}; } return new Entities.Preferences(attrs); }); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Entities", function(Entities, App, Backbone, Marionette, $, _) { var API, stringify; stringify = function(err) { return [err.name, err.message].join(": "); }; Entities.Project = (function(superClass) { extend(Project, superClass); function Project() { return Project.__super__.constructor.apply(this, arguments); } Project.prototype.defaults = { loading: false, browserState: "closed" }; Project.prototype.mutators = { browserText: function() { var b, word; if (!(b = this.get("browser"))) { return; } word = (function() { switch (this.get("browserState")) { case "opened": return "Running"; case "opening": return "Opening"; case "closed": return "Run"; } }).call(this); return [word, b.get("displayName"), b.get("majorVersion")].join(" "); }, browserIcon: function() { switch (this.get("browserState")) { case "opening": return "fa-refresh fa-spin"; case "opened": return "fa-check-circle"; case "closed": return "fa-chrome"; } }, browserName: function() { var b; if (!(b = this.get("browser"))) { return; } return b.get("name"); } }; Project.prototype.initialize = function() { return this.setName(); }; Project.prototype.browserOpening = function() { return this.set({ browserState: "opening", browserClickable: false }); }; Project.prototype.browserOpened = function() { return this.set({ browserState: "opened", browserClickable: false }); }; Project.prototype.browserClosed = function() { return this.set({ browserState: "closed", browserClickable: true }); }; Project.prototype.setBrowser = function(name) { return this.set("browser", this.get("browsers").chooseBrowserByName(name)); }; Project.prototype.loaded = function() { return this.set("loading", false); }; Project.prototype.isLoading = function() { return !!this.get("loading"); }; Project.prototype.setName = function() { return this.set({ name: this.getNameFromPath() }); }; Project.prototype.getNameFromPath = function() { return _(this.get("path").split("/")).last(); }; Project.prototype.displayBrowsers = function() { var b; if (b = this.get("browsers")) { return b.toJSON(); } else { return []; } }; Project.prototype.getBrowsers = function(browsers) { if (browsers == null) { browsers = []; } return App.request("new:browser:entities", browsers); }; Project.prototype.setConfig = function(config) { var b; if (b = config.browsers) { config.browsers = this.getBrowsers(b); config.browser = config.browsers.extractDefaultBrowser(); } this.set(config, { silent: true }); return this.trigger("opened"); }; Project.prototype.setError = function(err) { if (err.portInUse) { this.set("portInUse", true); } return this.set("error", stringify(err)); }; Project.prototype.reset = function() { var props; props = { error: null, portInUse: null, clientUrl: null, clientUrlDisplay: null }; return this.set(props, { silent: true }); }; return Project; })(Entities.Model); Entities.ProjectsCollection = (function(superClass) { extend(ProjectsCollection, superClass); function ProjectsCollection() { return ProjectsCollection.__super__.constructor.apply(this, arguments); } ProjectsCollection.prototype.model = Entities.Project; ProjectsCollection.prototype.getProjectByPath = function(path) { return this.findWhere({ path: path }); }; return ProjectsCollection; })(Entities.Collection); API = { getProjects: function() { var projects; projects = new Entities.ProjectsCollection; App.ipc("get:project:paths").then(function(paths) { projects.add(_(paths).map(function(path) { return { path: path }; })); return projects.trigger("fetched"); }); return projects; } }; return App.reqres.setHandler("project:entities", function() { return API.getProjects(); }); }); }).call(this); ; (function() { var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; this.App.module("Entities", function(Entities, App, Backbone, Marionette, $, _) { var API; Entities.Updater = (function(superClass) { extend(Updater, superClass); function Updater() { return Updater.__super__.constructor.apply(this, arguments); } Updater.prototype.defaults = function() { return { finished: false, updatesAvailable: false }; }; Updater.prototype.mutators = { stateFormatted: function() { switch (this.get("state")) { case "checking": return "Checking for updates..."; case "downloading": return "Downloading updates..."; case "applying": return "Applying updates..."; case "done": return "Updates ready"; case "none": return "No updates available"; case "error": return "An error occurred updating"; } }, buttonFormatted: function() { if (this.get("state") === "done") { return "Restart"; } else { return "Done"; } } }; Updater.prototype.setState = function(state) { switch (state) { case "error": case "done": case "none": this.setFinished(); } return this.set("state", state); }; Updater.prototype.setNewVersion = function(newVersion) { return this.set("newVersion", newVersion); }; Updater.prototype.setFinished = function() { return this.set("finished", true); }; Upd