diff --git a/build/standalone/config/default.js b/build/standalone/config/default.js index e04f3e33..6f1bd78b 100644 --- a/build/standalone/config/default.js +++ b/build/standalone/config/default.js @@ -620,6 +620,17 @@ function definePlugin(plugin, p) { }); }; } +require["vfs!"] = function(module, callback) { + var url = require.MODULE_LOAD_URL + "/~node/" + module; + if (define.fetchedUrls[url] & 3) + return false; + define.fetchedUrls[url] |= 3; + define("vfs!" + module, [], { + srcUrl: url, + path: module + }); + callback(); +}; require["text!"] = function(module, callback) { var url = require.toUrl(module); if (define.fetchedUrls[url] & 2) @@ -2182,7 +2193,6 @@ define("plugins/c9.ide.collab/members/members",[], function(require, exports, mo var panels = imports.panels; var css = require("text!./members.css"); - var staticPrefix = options.staticPrefix; var membersPanel; @@ -2196,7 +2206,7 @@ define("plugins/c9.ide.collab/members/members",[], function(require, exports, mo function load() { if (loaded) return; loaded = true; - ui.insertCss(css, staticPrefix, plugin); + ui.insertCss(css, null, plugin); membersPanel = new MembersPanel("Ajax.org", main.consumes, { showTabs: true, @@ -9749,7 +9759,6 @@ define("plugins/c9.ide.collab/notifications/notifications",[], function(require, var workspace = imports["collab.workspace"]; var css = require("text!./notifications.css"); - var staticPrefix = options.staticPrefix; var oop = require("ace/lib/oop"); var Tree = require("ace_tree/tree"); @@ -9769,7 +9778,7 @@ define("plugins/c9.ide.collab/notifications/notifications",[], function(require, function load() { if (loaded) return; loaded = true; - ui.insertCss(css, staticPrefix, plugin); + ui.insertCss(css, null, plugin); notificationsDataProvider = new TreeData(); @@ -10153,7 +10162,6 @@ define("plugins/c9.ide.collab/timeslider/timeslider",[], function(require, expor var css = require("text!./timeslider.css"); var dom = require("ace/lib/dom"); - var staticPrefix = options.staticPrefix; var isLoading; var tsVisibleKey = "user/collab/@timeslider-visible"; @@ -10284,7 +10292,7 @@ define("plugins/c9.ide.collab/timeslider/timeslider",[], function(require, expor drawn = true; ui.insertHtml(null, html, plugin); - ui.insertCss(css, staticPrefix, plugin); + ui.insertCss(css, null, plugin); function $(id) { return document.getElementById(id); @@ -16040,7 +16048,6 @@ define("plugins/c9.ide.collab/collab",[], function(require, exports, module) { var menus = imports.menus; var css = require("text!./collab.css"); - var staticPrefix = options.staticPrefix; var plugin = new Panel("Ajax.org", main.consumes, { index: 45, @@ -16113,7 +16120,7 @@ define("plugins/c9.ide.collab/collab",[], function(require, exports, module) { } }); - ui.insertCss(css, staticPrefix, plugin); + ui.insertCss(css, null, plugin); window.addEventListener("unload", function() { leaveAll(); @@ -40949,7 +40956,7 @@ define("plugins/c9.ide.test/all",[], function(require, exports, module) { function draw(opts) { if (drawn) return; drawn = true; - ui.insertCss(require("text!./style.css"), options.staticPrefix, plugin); + ui.insertCss(require("text!./style.css"), null, plugin); tree = new Tree({ container: opts.html, scrollMargin: [10, 10], @@ -43702,7 +43709,6 @@ define("plugins/c9.ide.collab/notifications/bubble",[], function(require, export var prefs = imports.preferences; var plugin = new Plugin("Ajax.org", main.consumes); - var staticPrefix = options.staticPrefix; var skin = require("text!./skin.xml"); var markup = require("text!./bubble.xml"); var emit = plugin.getEmitter(); @@ -43739,7 +43745,6 @@ define("plugins/c9.ide.collab/notifications/bubble",[], function(require, export ui.insertSkin({ name: "bubble", data: skin, - "media-path": staticPrefix + "/images/" }, plugin); ui.insertMarkup(layout.findParent(plugin), markup, plugin); @@ -44813,7 +44818,7 @@ define("plugins/c9.ide.preferences/preferences",[], function(require, exports, m if (drawn) return; drawn = true; var css = require("text!./preferences.css"); - ui.insertCss(css, options.staticPrefix, handle); + ui.insertCss(css, null, handle); parent = e.tab.appendChild(new ui.hsplitbox({ "class": "bar-preferences", "anchors": "0 0 0 0", @@ -44991,7 +44996,7 @@ define("plugins/c9.ide.behaviors/page",[], function(require, exports, module) { function load() { if (loaded) return false; loaded = true; - ui.insertCss(css, options.staticPrefix, handle); + ui.insertCss(css, null, handle); settings.on("read", function() { settings.setDefaults("user/tabs", [["autoclosepanes", true]]); @@ -49119,7 +49124,7 @@ define("plugins/c9.ide.guide/guide",[], function(require, exports, module) { function draw() { if (drawn) return; drawn = true; - ui.insertCss(require("text!./style.css"), options.staticPrefix, plugin); + ui.insertCss(require("text!./style.css"), null, plugin); thingies.forEach(drawThingy); emit("draw"); @@ -49594,10 +49599,8 @@ define("plugins/c9.ide.help/help",[], function(require, exports, module) { ui.insertSkin({ name: "help-skin", data: require("text!./skin.xml"), - "media-path": options.staticPrefix + "/images/", - "icon-path": options.staticPrefix + "/icons/" }, plugin); - ui.insertCss(css, options.staticPrefix, plugin); + ui.insertCss(css, null, plugin); ui.insertMarkup(null, markup, plugin); aboutDialog = plugin.getElement("aboutDialog"); @@ -50069,8 +50072,7 @@ define("plugins/c9.ide.welcome/welcome",[], function(require, exports, module) { } }); } - ui.insertCss(require("text!./style.css"), - options.staticPrefix, handle); + ui.insertCss(require("text!./style.css"), null, handle); } handle.on("load", load); @@ -61349,7 +61351,7 @@ define("plugins/c9.ide.preview/preview",[], function(require, exports, module) { if (drawn) return; drawn = true; var css = require("text!./preview.css"); - ui.insertCss(css, options.staticPrefix, handle); + ui.insertCss(css, null, handle); handleEmit.sticky("draw"); } @@ -63397,7 +63399,7 @@ define("plugins/c9.ide.installer/gui",[], function(require, exports, module) { if (drawn) return; drawn = true; - ui.insertCss(require("text!./style.css"), options.staticPrefix, plugin); + ui.insertCss(require("text!./style.css"), null, plugin); settings.on("user/installer/@auto", function() { cbAlways.setAttribute("checked", settings.get("user/installer/@auto")); @@ -65338,8 +65340,6 @@ define("plugins/c9.ide.panels/panels",[], function(require, exports, module) { ui.insertSkin({ name: "panels", data: require("text!./skin.xml"), - "media-path": options.staticPrefix + "/images/", - "icon-path": options.staticPrefix + "/icons/" }, plugin); menus.addItemByPath("Window/~", new ui.divider(), 40, plugin); @@ -65565,7 +65565,6 @@ define("plugins/c9.ide.language.core/outline",[], function(require, exports, mod var fullOutline = []; var ignoreFocusOnce = false; - var staticPrefix = options.staticPrefix; var tree, tdOutline, winOutline, textbox, treeParent; // UI Elements var originalLine, originalColumn, originalTab; @@ -65752,9 +65751,8 @@ define("plugins/c9.ide.language.core/outline",[], function(require, exports, mod } function createProvider() { - ui.insertCss(require("text!./outline.css"), staticPrefix, plugin); + ui.insertCss(require("text!./outline.css"), null, plugin); tdOutline = new TreeData(); - tdOutline.staticPrefix = staticPrefix; } var drawn = false; @@ -66081,6 +66079,7 @@ define("plugins/c9.ide.language.core/outline",[], function(require, exports, mod fullOutline = []; ignoreFocusOnce = false; + tree = null; tdOutline = null; winOutline = null; @@ -67298,12 +67297,10 @@ define("plugins/c9.ide.upload/upload_progress",[], function(require, exports, mo function draw() { if (drawn) return; drawn = true; - ui.insertCss(css, options.staticPrefix, plugin); + ui.insertCss(css, null, plugin); ui.insertSkin({ name: "uploadfiles", data: require("text!./markup/skin.xml"), - "media-path": options.staticPrefix + "/images/", - "icon-path": options.staticPrefix + "/icons/" }, plugin); ui.insertMarkup(layout.findParent(plugin), boxUploadActivityMarkup, plugin); @@ -68387,7 +68384,7 @@ define("plugins/c9.ide.upload/upload",[], function(require, exports, module) { } if (!winUploadFiles) { - ui.insertCss(css, options.staticPrefix, plugin); + ui.insertCss(css, null, plugin); ui.insertMarkup(null, winUploadFilesMarkup, plugin); winUploadFiles = plugin.getElement("winUploadFiles"); @@ -71327,7 +71324,7 @@ define("plugins/c9.ide.tree/tree",[], function(require, exports, module) { } }); var css = require("text!./style.css"); - ui.insertCss(css, staticPrefix, plugin); + ui.insertCss(css, null, plugin); ui.insertCss(util.getFileIconCss(staticPrefix), false, plugin); layout.on("eachTheme", function(e) { @@ -73045,8 +73042,6 @@ define("plugins/c9.ide.layout.classic/layout",[], function(require, exports, mod drawn = true; ui.insertSkin({ "data": require("text!./skins.xml"), - "media-path": options.staticPrefix + "/images/", - "icon-path": options.staticPrefix + "/icons/" }, plugin); ui.insertMarkup(null, markup, plugin); @@ -73624,7 +73619,7 @@ define("plugins/c9.ide.console/console",[], function(require, module, exports) { if (drawn) return; drawn = true; - ui.insertCss(cssString, options.staticPrefix, plugin); + ui.insertCss(cssString, null, plugin); consoleRow = layout.findParent(plugin); container = consoleRow.appendChild(new ui.bar({ @@ -73999,7 +73994,7 @@ define("plugins/c9.ide.run/output",[], function(require, exports, module) { }; handle.on("load", function() { - ui.insertCss(require("text!./style.css"), options.staticPrefix, handle); + ui.insertCss(require("text!./style.css"), null, handle); commands.addCommand({ name: "showoutput", @@ -75175,7 +75170,7 @@ define("plugins/c9.ide.terminal.monitor/message_view",[], function(require, expo function load() { if (loaded) return false; loaded = true; - ui.insertCss(css, options.staticPrefix, plugin); + ui.insertCss(css, null, plugin); tabManager.on("tabAfterActivateSync", function() { toggleMessages(); @@ -81066,7 +81061,7 @@ define("plugins/c9.ide.terminal/terminal",[], function(require, exports, module) defaults[themeName] = options.defaults[themeName]; } } - ui.insertCss(require("text!./style.css"), options.staticPrefix, handle); + ui.insertCss(require("text!./style.css"), null, handle); handle.on("load", function() { commands.addCommand({ @@ -89138,7 +89133,7 @@ define("plugins/c9.ide.immediate/immediate",[], function(require, exports, modul } } }, handle); - ui.insertCss(require("text!./style.css"), options.staticPrefix, handle); + ui.insertCss(require("text!./style.css"), null, handle); }); function search(cb) { return !tabManager.getTabs().every(function(tab) { @@ -91187,6 +91182,9 @@ define("plugins/c9.ide.run.debug/debuggers/socket",[], function(require, exports var emit = socket.getEmitter(); var state, stream, connected, away; + if (proxy == false) + return socket; + if (typeof proxy == "string") proxy = { source: proxy }; @@ -91399,108 +91397,10 @@ define("plugins/c9.ide.run.debug/debuggers/socket",[], function(require, exports } }); -define("plugins/c9.ide.run.debug/debuggers/v8/lib/util",[], function(require, exports, module) { -"use strict"; - -exports.byteLength = function(str) { - var s = str.length; - for (var i = str.length - 1; i >= 0; i--) { - var code = str.charCodeAt(i); - if (code > 0x7f && code <= 0x7ff) s++; - else if (code > 0x7ff && code <= 0xffff) s += 2; - if (code >= 0xDC00 && code <= 0xDFFF) i--; // trail surrogate - } - return s; -}; - -exports.readBytes = function(str, start, bytes) { - var consumed = 0; - for (var i = start; i < str.length; i++) { - var code = str.charCodeAt(i); - if (code < 0x7f) consumed++; - else if (code > 0x7f && code <= 0x7ff) consumed += 2; - else if (code > 0x7ff && code <= 0xffff) consumed += 3; - if (code >= 0xD800 && code <= 0xDBFF) i++; // leading surrogate - if (consumed >= bytes) { i++; break; } - } - return { bytes: consumed, length: i - start }; -}; - -exports.inherits = (function() { - var tempCtor = function() {}; - return function(ctor, superCtor) { - tempCtor.prototype = superCtor.prototype; - ctor.super_ = superCtor.prototype; - ctor.prototype = new tempCtor(); - ctor.prototype.constructor = ctor; - }; -}()); - -exports.mixin = function(obj, mixin) { - for (var key in mixin) - obj[key] = mixin[key]; -}; - -exports.implement = function(proto, mixin) { - exports.mixin(proto, mixin); -}; - -var EventEmitter = {}; - -EventEmitter._emit = -EventEmitter.emit = -EventEmitter._dispatchEvent = function(eventName, e) { - this._eventRegistry = this._eventRegistry || {}; - - var listeners = this._eventRegistry[eventName]; - if (!listeners || !listeners.length) - return; - - e = e || {}; - e.type = eventName; - - for (var i = listeners.length - 1; i >= 0; i--) - listeners[i](e); -}; - -EventEmitter.on = -EventEmitter.addEventListener = function(eventName, callback) { - this._eventRegistry = this._eventRegistry || {}; - - var listeners = this._eventRegistry[eventName]; - if (!listeners) - listeners = this._eventRegistry[eventName] = []; - - if (listeners.indexOf(callback) == -1) - listeners.push(callback); -}; - -EventEmitter.removeListener = -EventEmitter.removeEventListener = function(eventName, callback) { - this._eventRegistry = this._eventRegistry || {}; - - var listeners = this._eventRegistry[eventName]; - if (!listeners) - return; - - var index = listeners.indexOf(callback); - if (index !== -1) - listeners.splice(index, 1); -}; - -EventEmitter.removeAllListeners = function(eventName) { - if (this._eventRegistry) - this._eventRegistry[eventName] = []; -}; - -exports.EventEmitter = EventEmitter; - -}); - define("plugins/c9.ide.run.debug/debuggers/v8/lib/V8Message",[], function(require, exports, module) { "use strict"; -var Util = require("./util"); +var oop = require("ace/lib/oop"); var V8Message = module.exports = function(type) { this.seq = V8Message.$seq++; @@ -91526,7 +91426,7 @@ var V8Message = module.exports = function(type) { this.parse = function(msgString) { var json = JSON.parse(msgString); - Util.mixin(this, json); + oop.mixin(this, json); return this; }; @@ -91537,8 +91437,6 @@ var V8Message = module.exports = function(type) { if (typeof this[name] != "undefined") tmp[name] = this[name]; } - if (tmp.arguments && !tmp.arguments.maxStringLength) - tmp.arguments.maxStringLength = 10000; return JSON.stringify(tmp); }; @@ -91552,7 +91450,7 @@ V8Message.fromString = function(msgString) { V8Message.fromObject = function(obj) { var msg = new V8Message(); - Util.mixin(msg, obj); + oop.mixin(msg, obj); return msg; }; @@ -91562,8 +91460,8 @@ define("plugins/c9.ide.run.debug/debuggers/v8/lib/V8Debugger",[], function(requi "use strict"; -var Util = require("./util"); -var EventEmitter = Util.EventEmitter; +var oop = require("ace/lib/oop"); +var EventEmitter = require("ace/lib/event_emitter").EventEmitter; var V8Message = require("./V8Message"); var V8Debugger = module.exports = function(tabId, v8service) { @@ -91583,7 +91481,7 @@ var V8Debugger = module.exports = function(tabId, v8service) { delete pending[requestSeq]; } else if (response.event) { - self.emit(response.event, { data: response.body }); + self._signal(response.event, { data: response.body }); } self.$updateRunning(response); @@ -91592,7 +91490,7 @@ var V8Debugger = module.exports = function(tabId, v8service) { (function() { - Util.implement(this, EventEmitter); + oop.implement(this, EventEmitter); this.$seq = 0; @@ -91611,7 +91509,7 @@ var V8Debugger = module.exports = function(tabId, v8service) { if (running !== this.$running) { this.$running = running; - this.emit("changeRunning", { data: running }); + this._signal("changeRunning", { data: running }); } }; @@ -91854,148 +91752,11 @@ V8Debugger.NORMAL_SCRIPTS = 4; }); -define("plugins/c9.ide.run.debug/debuggers/v8/lib/MessageReader",[], function(require, exports, module) { -"use strict"; - -var Util = require("./util"); -var readBytes = Util.readBytes; - -var MessageReader = module.exports = function(socket, callback) { - this.$socket = socket; - this.$callback = callback; - - this.$received = ""; - this.$expectedBytes = 0; - this.$offset = 0; - this.$cbReceive = this.$onreceive.bind(this); - socket.on("data", this.$cbReceive); -}; - -(function() { - - this.$onreceive = function(data) { - this.$received += data; - - var fullResponse; - while (fullResponse = this.$checkForWholeMessage()) - this.$callback(fullResponse); - }; - - this.$checkForWholeMessage = function() { - var fullResponse = false; - var received = this.$received; - if (!this.$expectedBytes) { // header - var i = received.indexOf("\r\n\r\n"); - if (i !== -1) { - var c = received.lastIndexOf("Content-Length:", i); - if (c != -1) { - var l = received.indexOf("\r\n", c); - var len = parseInt(received.substring(c + 15, l), 10); - this.$expectedBytes = len; - } - this.$offset = i + 4; - } - } - if (this.$expectedBytes) { // body - var result = readBytes(received, this.$offset, this.$expectedBytes); - this.$expectedBytes -= result.bytes; - this.$offset += result.length; - } - if (this.$offset && this.$expectedBytes <= 0) { - fullResponse = received.substring(0, this.$offset); - this.$received = received.substr(this.$offset); - this.$offset = this.$expectedBytes = 0; - } - return fullResponse; - }; - - this.destroy = function() { - this.$socket && this.$socket.removeListener("data", this.$cbReceive); - delete this.$socket; - delete this.$callback; - this.$received = ""; - }; - -}).call(MessageReader.prototype); - -}); - -define("plugins/c9.ide.run.debug/debuggers/v8/lib/DevToolsMessage",[], function(require, exports, module) { -"use strict"; - -var DevToolsMessage = module.exports = function(headers, content) { - this.$headers = {}; - this.$content = ""; - - if (headers) - this.$headers = headers; - if (content) - this.setContent(content); -}; - -(function() { - - this.setContent = function(content) { - this.$content = content.toString(); - }; - - this.getContent = function() { - return this.$content; - }; - - this.setHeader = function(name, value) { - this.$headers[name] = value; - }; - - this.parse = function(msgString) { - var headers = this.$headers = {}; - var responseParts = msgString.split("\r\n\r\n"); - - var headerText = responseParts[0]; - this.$content = responseParts[1]; - - var re = /([\w\-\d]+)\s*:\s*([^\r\n]*)(\r|$)/g; - headerText.replace(re, function(str, key, value) { - headers[key] = value; - }); - - return this; - }; - - this.stringify = function() { - var headers = this.getHeaders(); - - var str = []; - for (var name in headers) - str.push(name, ":", headers[name], "\r\n"); - if (this.$content) - str.push("\r\n", this.$content); - return str.join(""); - }; - - this.getHeaders = function() { - this.$headers["Content-Length"] = this.$content.length; - this.$headers["Tool"] = this.$headers["Tool"] || "DevToolsService"; - - return this.$headers; - }; - -}).call(DevToolsMessage.prototype); - -DevToolsMessage.fromString = function(msgString) { - return new DevToolsMessage().parse(msgString); -}; - -}); - define("plugins/c9.ide.run.debug/debuggers/v8/lib/StandaloneV8DebuggerService",[], function(require, exports, module) { "use strict"; -var Util = require("./util"); -var EventEmitter = Util.EventEmitter; -var MessageReader = require("./MessageReader"); -var DevToolsMessage = require("./DevToolsMessage"); -var byteLength = Util.byteLength; +var oop = require("ace/lib/oop"); +var EventEmitter = require("ace/lib/event_emitter").EventEmitter; var StandaloneV8DebuggerService = module.exports = function(socket) { this.$socket = socket; @@ -92006,93 +91767,47 @@ var StandaloneV8DebuggerService = module.exports = function(socket) { (function() { - Util.implement(this, EventEmitter); + oop.implement(this, EventEmitter); this.attach = function(tabId, callback) { if (this.$attached) throw new Error("already attached!"); - var self = this; - this.$reader = new MessageReader(this.$socket, this.$onMessage.bind(this)); - this.on("connect", function(e) { - callback(null, e); - }); - this.$socket.connect(); - - this.$socket.on("end", function() { - self.$pending.forEach(function(item) { - self.emit("debugger_command_0", { data: { - request_seq: item[1].seq, - success: false, - message: "Debug Session Ended" - }}); - }); - }); - - this.$socket.on("beforeBack", function() { - if (self.$pending.length) { - self.$pending.forEach(function(item) { - self.debuggerCommand(item[0], item[1], true); - }); - } - }); + this.$socket.on("message", this.$onMessage.bind(this)); + callback(null, null); }; this.detach = function(tabId, callback) { this.$socket.close(); this.$attached = false; this.$connected = false; - if (this.$reader) - this.$reader.destroy(); callback && callback(); }; - this.$onMessage = function(messageText) { - var response = new DevToolsMessage.fromString(messageText); - - var contentText = response.getContent(); - if (!contentText) { - if (response.$headers.Type == "connect" || !this.$connected) { - this.emit("connect", { type: response.$headers.Type }); - this.$connected = true; - } + this.$onMessage = function(message) { + if (!message) { + this.$connected = true; return; } - - var content; - try { - content = JSON.parse(contentText); - } - catch (ex) { - return setTimeout(function() { - var e = new Error("Debugger recieved invalid message"); - e.data = contentText; - throw e; - }); - } for (var i = 0; i < this.$pending.length; i++) { - if (this.$pending[i][1].seq == content.request_seq) { + if (this.$pending[i][1].seq == message.request_seq) { this.$pending.splice(i, 1); break; } } - this.emit("debugger_command_0", { data: content }); + this._signal("debugger_command_0", { data: message }); }; this.debuggerCommand = function(tabId, v8Command, noPending) { if (!noPending && v8Command.command != "scripts") this.$pending.push([tabId, v8Command]); - - if (typeof v8Command != "string") - v8Command = v8Command.stringify(); - + this.$send(v8Command); }; - this.$send = function(text) { - var msg = ["Content-Length:", byteLength(text), "\r\n\r\n", text].join(""); + this.$send = function(msg) { this.$socket.send(msg); }; @@ -92100,14 +91815,14 @@ var StandaloneV8DebuggerService = module.exports = function(socket) { }); -define("plugins/c9.ide.run.debug/debuggers/v8/v8debugger",[], function(require, exports, module) { +define("plugins/c9.ide.run.debug/debuggers/v8/oldv8debugger",[], function(require, exports, module) { main.consumes = [ "Plugin", "debugger", "util", "c9" ]; main.provides = ["v8debugger"]; return main; - function main(options, imports, register) { + function main(options, imports) { var Plugin = imports.Plugin; var util = imports.util; var debug = imports["debugger"]; @@ -92183,7 +91898,7 @@ define("plugins/c9.ide.run.debug/debuggers/v8/v8debugger",[], function(require, }); } - onChangeRunning(null, isResumed); + onChangeRunning(null); callback(); }); }); @@ -92528,11 +92243,11 @@ define("plugins/c9.ide.run.debug/debuggers/v8/v8debugger",[], function(require, }); } - function onChangeRunning(e, isResumed) { + function onChangeRunning(e) { if (!v8dbg) { state = null; } else { - state = v8dbg.isRunning() || isResumed ? "running" : "stopped"; + state = v8dbg.isRunning() ? "running" : "stopped"; } emit("stateChange", { state: state }); @@ -92614,10 +92329,7 @@ define("plugins/c9.ide.run.debug/debuggers/v8/v8debugger",[], function(require, } function getProxySource(process) { - return debug.proxySource - .replace(/\/\/.*/g, "") - .replace(/[\n\r]/g, "") - .replace(/\{PORT\}/, process.runner.debugport); + return false; } function attach(s, reconnect, callback) { @@ -92638,10 +92350,10 @@ define("plugins/c9.ide.run.debug/debuggers/v8/v8debugger",[], function(require, if (err) return callback(err); v8dbg = new V8Debugger(0, v8ds); - v8dbg.addEventListener("changeRunning", onChangeRunning); - v8dbg.addEventListener("break", onBreak); - v8dbg.addEventListener("exception", onException); - v8dbg.addEventListener("afterCompile", onAfterCompile); + v8dbg.on("changeRunning", onChangeRunning); + v8dbg.on("break", onBreak); + v8dbg.on("exception", onException); + v8dbg.on("afterCompile", onAfterCompile); onChangeFrame(null); @@ -92663,10 +92375,10 @@ define("plugins/c9.ide.run.debug/debuggers/v8/v8debugger",[], function(require, onChangeRunning(); if (v8dbg) { - v8dbg.removeEventListener("changeRunning", onChangeRunning); - v8dbg.removeEventListener("break", onBreak); - v8dbg.removeEventListener("exception", onException); - v8dbg.removeEventListener("afterCompile", onAfterCompile); + v8dbg.off("changeRunning", onChangeRunning); + v8dbg.off("break", onBreak); + v8dbg.off("exception", onException); + v8dbg.off("afterCompile", onAfterCompile); } socket = null; @@ -93088,11 +92800,8 @@ define("plugins/c9.ide.run.debug/debuggers/v8/v8debugger",[], function(require, } plugin.on("load", function() { - debug.registerDebugger(TYPE, plugin); }); plugin.on("unload", function() { - debug.unregisterDebugger(TYPE, plugin); - breakOnExceptions = null; breakOnUncaughtExceptions = null; breakpointQueue = null; @@ -93163,8 +92872,1331 @@ define("plugins/c9.ide.run.debug/debuggers/v8/v8debugger",[], function(require, setPathMap: setPathMap }); + return plugin; + } +}); + +define("plugins/c9.ide.run.debug/debuggers/chrome/DevtoolsProtocol",[], function(require, exports, module) { + +"use strict"; + +var oop = require("ace/lib/oop"); +var EventEmitter = require("ace/lib/event_emitter").EventEmitter; + +var DevtoolsProtocol = module.exports = function(socket) { + this.callbacks = {}; + this.$scripts = {}; + this.socket = socket; +}; + +(function() { + + oop.implement(this, EventEmitter); + + this.events = [ + "changeRunning", + "break", + "exception", + "afterCompile" + ]; + + this.$seq = 0; + + this.$send = function(method, params, callback) { + this.$seq++; + if (callback) + this.callbacks[this.$seq] = callback; + this.ws.send({ + id: this.$seq, + method: method, + params: params || undefined, + }); + }; + + this.handleMessage = function(message) { + if (message.id) { + if (this.callbacks[message.id]) + return this.callbacks[message.id](message.result, message.error); + } else { + var params = message.params; + if (message.method == "Debugger.scriptParsed") { + this.$scripts[params.scriptId] = params; + this._signal("afterCompile", params); + } + else if (message.method == "Runtime.executionContextCreated") { + console.log(message.params); + } + else if (message.method == "Runtime.executionContextDestroyed") { + console.log(message.params); + this.detachDebugger(); + } + else if (message.method == "Debugger.resumed") { + this.$callstack = null; + this._signal("changeRunning", params); + console.warn(message); + } + else if (message.method == "Debugger.paused") { + this.$callstack = params; + this._signal("changeRunning", params); + console.warn(message); + if (params.reason == "exception") { + this._signal("exception", params); + } else { + this._signal("break", params); + } + } + else { + console.warn(message); + } + } + }; + + this.detachDebugger = function() { + if (this.ws) + this.ws.send({ $: "detach" }); + } + + this.attach = function(port, cb) { + this.ws = this.socket; + this.ws.on("message", this.handleMessage.bind(this)); + this.$send("Profiler.enable"); + this.$send("Runtime.enable"); + this.$send("Debugger.enable"); + this.$send("Debugger.setAsyncCallStackDepth", { maxDepth: 32 }); + this.$send("Runtime.runIfWaitingForDebugger"); + cb(); + }; + + + this.detach = function() { + if (this.ws) + this.ws.close(); + }; + + this.isRunning = function() { + return !this.$callstack; + }; + + this.stepInto = function(callback) { + this.$send("Debugger.stepInto", null, callback); + }; + this.stepOver = function(callback) { + this.$send("Debugger.stepOver", null, callback); + }; + this.stepOut = function(callback) { + this.$send("Debugger.stepOut", null, callback); + }; + this.resume = function(callback) { + this.$send("Debugger.resume", null, callback); + }; + this.suspend = function(callback) { + this.$send("Debugger.pause", null, callback); + }; + + this.backtrace = function(callback) { + callback(this.$callstack || []); + }; + + this.getProperties = function(params, callback) { + this.$send("Runtime.getProperties", params, callback); + }; + + this.scripts = function(callback) { + callback(this.$scripts); + }; + + this.getScriptSource = function(id, callback) { + this.$send("Debugger.getScriptSource", { scriptId: id }, callback); + }; + + this.evaluate = function(expression, frame, global, disableBreak, callback) { + if (frame) { + this.$send("Debugger.evaluateOnCallFrame", { + expression: expression, + callFrameId: frame.id, + objectGroup: "popover", + includeCommandLineAPI: false, + silent: true, + returnByValue: false, + generatePreview: false, + }, callback); + } else { + this.$send("Runtime.evaluate", { + expression: expression, + objectGroup: "console", + includeCommandLineAPI: true, + silent: false, + contextId: 1, + returnByValue: false, + generatePreview: true, + userGesture: true, + awaitPromise: false, + }, callback); + } + }; + + this.setexceptionbreak = function(state, callback) { + this.$send("Debugger.setPauseOnExceptions", { + state: state + }, callback); + }; + + this.setvariablevalue = function(variable, value, frame, callback) { + if (!variable.parent) + return; + this.evaluate("(" + value + ")", frame, null, true, function(data, err) { + if (err) + return callback(err); + if (variable.parent.index != null) { + return this.$send("Debugger.setVariableValue", { + scopeNumber: variable.parent.index, + variableName: variable.name, + newValue: data.result, + callFrameId: frame.id, + }, function(data, err) { + callback(err); + }); + } + + this.$send("Runtime.callFunctionOn", { + "objectId": variable.parent.ref || variable.parent.id, + "functionDeclaration": "function(a, b) { this[a] = b; }", + "arguments": [ + { "value": variable.name }, + data.result + ], + "silent": true + }, function(data, err) { + callback(err); + }); + }.bind(this)); + }; + + this.setbreakpoint = function(target, line, column, enabled, condition, callback) { + var breakpointId = target + ":" + line + ":" + column; + this.$send("Debugger.removeBreakpoint", { + breakpointId: breakpointId + }, function() { + if (!enabled) callback(null, {}); + }); + + if (!enabled) return; + + this.$send("Debugger.setBreakpointByUrl", { + lineNumber: line, + url: target, + columnNumber: column || 0, + condition: condition + }, callback); + }; + + this.clearbreakpoint = function(breakpointId, callback) { + this.$send("Debugger.removeBreakpoint", { + breakpointId: breakpointId + }, callback); + }; + + this.listbreakpoints = function(callback) { + callback({ + breakpoints: [] + }); + }; + + + this.changelive = function(scriptId, newSource, previewOnly, callback, $retry) { + that.$send("Debugger.setScriptSource", { + scriptId: scriptId, + scriptSource: newSource, + dryRun: !!previewOnly + }, function(result, error) { + if (error && error.code == -32000 && !$retry) { + return this.changelive(scriptId, newSource, previewOnly, callback, true); + } + if (result && result.stackChanged) { + return this.stepInto(function() { + callback({}, null); + }); + } + callback(result, error); + }.bind(this)); + }; + + this.restartframe = function(frameId, callback) { + this.$send("Debugger.restartFrame", { + callFrameId: frameId + }, callback); + }; + +}).call(DevtoolsProtocol.prototype); + + +}); + +define("plugins/c9.ide.run.debug/debuggers/chrome/chromedebugger",[], function(require, exports, module) { + main.consumes = ["Plugin", "debugger", "util", "c9"]; + main.provides = ["chromedebugger"]; + return main; + + function main(options, imports, register) { + var Plugin = imports.Plugin; + var util = imports.util; + var debug = imports["debugger"]; + var c9 = imports.c9; + var async = require("async"); + + var Frame = debug.Frame; + var Source = debug.Source; + var Breakpoint = debug.Breakpoint; + var Variable = debug.Variable; + var Scope = debug.Scope; + + var DevtoolsProtocol = require("./DevtoolsProtocol"); + + var plugin = new Plugin("Ajax.org", main.consumes); + var emit = plugin.getEmitter(); + emit.setMaxListeners(1000); + + var stripPrefix = c9.toInternalPath((options.basePath || "").replace(/[\/\\]$/, "")); + var breakOnExceptions = false; + var breakOnUncaughtExceptions = false; + + var NODE_PREFIX = "(function (exports, require, module, __filename, __dirname) { "; + var NODE_POSTFIX = "\n});"; + + var RE_NODE_PREFIX = new RegExp("^" + util.escapeRegExp(NODE_PREFIX)); + var RE_NODE_POSTFIX = new RegExp(util.escapeRegExp(NODE_POSTFIX) + "$"); + + var TYPE = "chrome"; + + var attached = false; + var v8dbg, state, activeFrame, sources, socket, pathMap; + + var hasChildren = { + "regexp": 32, + "error": 16, + "object": 8, + "function": 4 + }; + function sync(breakpoints, reconnect, callback) { + if (!v8dbg) + return console.error("Sync called without v8dbg"); + getSources(function(err, sources) { + if (err) return callback(err); + + updateBreakpoints(breakpoints, reconnect, function(err, breakpoints) { + if (err) return callback(err); + + handleDebugBreak(breakpoints, reconnect, null, function(canAttach) { + attached = canAttach; + emit("attach", { breakpoints: breakpoints }); + }, + function(isResumed) { + callback(); + }); + }); + }); + } + + function updateBreakpoints(breakpoints, reconnect, callback) { + function find(bp) { + for (var i = 0, l = breakpoints.length; i < l; i++) { + if (breakpoints[i].equals(bp)) + return breakpoints[i]; + } + } + + var list = breakpoints.slice(0); + var retries = 0; + + listBreakpoints(function handleBps(err, remoteBreakpoints) { + if (err) return callback(err); + + var found = []; + var notfound = []; + + remoteBreakpoints.forEach(function(rbp) { + var bp; + if ((bp = find(rbp))) { + if (rbp.enabled == bp.enabled) + found.push(bp); + } + else + notfound.push(rbp); + }); + + async.each(list, function(bp, next) { + if (found.indexOf(bp) == -1) + setBreakpoint(bp, next); + else + next(); + }, done); + + function done() { + notfound.forEach(function(bp) { + bp.serverOnly = true; + list.push(bp); + }); + + list.sort(function(a, b) { + if (!a.id && !b.id) return 0; + if (!a.id && b.id) return 1; + if (a.id && !b.id) return -1; + return a.id - b.id; + }); + + callback(null, list); + } + }); + } + function handleDebugBreak(breakpoints, reconnect, frame, attach, callback) { + if (!v8dbg) { + console.error("No debugger is set"); + attach(); + return callback(); + } + + wait(); + reconnect = true; + + function wait() { + function resumeIfNeeded(callback) { + if (!activeFrame) { + return v8dbg.$waitForBreak = function(frame) { + activeFrame = frame; + v8dbg.$waitForBreak = null; + resumeIfNeeded(function() { + callback(); + }); + return true; + }; + } + var onBreakpoint = breakpoints.some(function(bp) { + return bp.enabled && activeFrame.path === bp.path && bp.line == activeFrame.line; + }); + if (!onBreakpoint) { + resume(callback); + } else { + onChangeRunning(); + onBreak({frame: activeFrame}); + } + } + if (reconnect) { + onChangeFrame(frame); + attach(true); + callback(false); + } + else { + attach(true); + resumeIfNeeded(callback.bind(this, true)); + } + } + } + function strip(str) { + if (!str) return ""; + str = c9.toInternalPath(str); + str = applyPathMap(str, "toInternal"); + return str && str.lastIndexOf(stripPrefix, 0) === 0 + ? util.normalizePath(str.slice(stripPrefix.length)) + : util.normalizePath(str || ""); + } + function getFrameId(frame) { + return frame.func.name + ":" + frame.func.inferredName + + ":" + frame.func.scriptId + ":" + + (frame.received && frame.received.ref || "") + + frame.arguments.map(function(a) {return a.value.ref;}).join("-"); + } + + function formatType(value) { + if (value.description) + return value.description; + switch (value.type) { + case "undefined": + case "null": + return value.type; + + case "error": + return value.value || "[Error]"; + + case "regexp": + return value.text; + + case "boolean": + case "number": + return value.value + ""; + + case "string": + return JSON.stringify(value.value); + + case "object": + var name = value.className || (value.text + ? value.text.replace(/#<(.*)>/, "$1") + : "Object"); + return "[" + name + "]"; + + case "function": + return "function " + value.inferredName + "()"; + + default: + return value.type; + } + } + + function isTruthy(variable) { + if ("undefined|null".indexOf(variable.type) > -1) + return false; + if ("false|NaN|\"\"".indexOf(variable.value) > -1) + return false; + return true; + } + + + function getPathFromScriptId(scriptId) { + for (var i = 0; i < sources.length; i++) { + if (sources[i].id == scriptId) + return sources[i].path; + } + } + + function getScriptIdFromPath(path) { + for (var i = 0; i < sources.length; i++) { + if (sources[i].path == path) + return sources[i].id; + } + } + + function getLocalScriptPath(script) { + var scriptName = script.url || ("-anonymous-" + script.scriptId); + scriptName = c9.toExternalPath(scriptName); + scriptName = strip(scriptName); + return scriptName; + } + + function createFrame(frameData, index) { + var options = frameData[index]; + var frame = options._frame || new Frame({ + istop: index == 0, + index: index, + name: options.functionName || "(anonymous)", + line: options.location.lineNumber, + column: options.location.columnNumber, + id: options.callFrameId, + script: options.location.scriptId, + path: getLocalScriptPath(v8dbg.$scripts[options.location.scriptId]), + sourceId: options.location.scriptId + }); + options._frame = frame; + + var vars = []; + + frame.variables = frame.variables || vars; + + frame.scopes = options.scopeChain.map(function(scope, i) { + return new Scope({ + id: scope.object.objectId, + type: scope.type, + frame: frame, + index: i + }); + }); + if (frame.scopes[0]) + frame.scopes[0].isOpen = true; + + return frame; + } + + function createVariable(options, name, scope, variable) { + var value = options.value || options; + + if (variable) { + } + else { + variable = new Variable({ + name: name || options.name, + scope: scope, + value: formatType(value), + type: value.type, + ref: value.objectId, + children: options.children === false + ? false : (hasChildren[value.type] ? true : false), + options: options, + }); + } + return variable; + } + + function createSource(options) { + var path = getLocalScriptPath(options); + return new Source({ + id: options.scriptId, + name: options.url || "anonymous", + path: path, + text: strip(options.text || "anonymous"), + debug: path.charAt(0) != "/" || path.match(/ \(old\)$/) ? true : false, + lineOffset: options.lineOffset, + customSyntax: "javascript", + threadId: options.executionContextId, + }); + } + + function createBreakpoint(options, serverOnly) { + return new Breakpoint({ + id: options.number, + path: getPathFromScriptId(options.script_id), + line: options.line, + column: options.column, + condition: options.condition, + enabled: options.active, + ignoreCount: options.ignoreCount, + serverOnly: serverOnly || false + }); + } + + function onChangeRunning(e) { + if (!v8dbg) { + state = null; + } else { + state = v8dbg.isRunning() ? "running" : "stopped"; + } + + if (attached) { + emit("stateChange", { state: state }); + + if (state != "stopped") + onChangeFrame(null); + } + } + + function onBreak(e) { + var frame = e.frame || createFrame(e.callFrames, 0); + if (v8dbg.$waitForBreak && v8dbg.$waitForBreak(frame)) { + return; + } + onChangeFrame(frame, !attached); + if (attached) + emit("break", { frame: frame }); + } + + function onException(e) { + var frame = createFrame(e.callFrames, 0); + + var options = e.data; + var m = /^(\w+):(.*)$/m.exec(options.description); + var name = m && m[1] || options.className; + var value = m && m[2] || options.description; + + options.name = name; + options.value = { + value: value, + type: "error", + objectId: options.objectId, + }; + options.children = true; + + var variable = createVariable(options); + variable.error = true; + + emit("exception", { + frame: frame, + exception: variable + }); + } + + function onAfterCompile(e) { + emit("sourcesCompile", { source: createSource(e) }); + } + + function onChangeFrame(frame, silent) { + activeFrame = frame; + if (!silent) + emit("frameActivate", { frame: frame }); + } + + function getProxySource(_process) { + return false; + } + + function attach(s, reconnect, callback) { + if (v8dbg) + v8dbg.detach(); + + socket = s; + socket.on("back", function(err) { + sync(emit("getBreakpoints"), true, callback); + }, plugin); + socket.on("error", function(err) { + emit("error", err); + }, plugin); + + v8dbg = new DevtoolsProtocol(socket); + attached = false; + v8dbg.attach(s, function(err, msg) { + if (err) return callback(err); + v8dbg.on("changeRunning", onChangeRunning); + v8dbg.on("break", onBreak); + v8dbg.on("exception", onException); + v8dbg.on("afterCompile", onAfterCompile); + + onChangeFrame(null); + + if (msg && msg.type == "connect") + reconnect = false; + setTimeout(function() { + sync(emit("getBreakpoints"), reconnect, callback); + }); + }); + } + + function detach() { + onChangeFrame(null); + onChangeRunning(); + + if (v8dbg) { + v8dbg.detach(); + v8dbg.off("changeRunning", onChangeRunning); + v8dbg.off("break", onBreak); + v8dbg.off("exception", onException); + v8dbg.off("afterCompile", onAfterCompile); + } + + socket = null; + v8dbg = null; + attached = false; + + emit("detach"); + } + + function getSources(callback) { + v8dbg.scripts(function(scriptMap) { + sources = []; + for (var i in scriptMap) { + var script = scriptMap[i]; + if ((script.name || "").indexOf("chrome-extension://") === 0) + continue; + sources.push(createSource(script)); + } + callback(null, sources); + + emit("sources", { sources: sources }); + }); + } + + function getSource(source, callback) { + v8dbg.getScriptSource(source.id, function(script) { + if (!script || !script.scriptSource) + return callback(new Error("File not found : " + source.path)); + + var source = script.scriptSource + .replace(RE_NODE_PREFIX, "") + .replace(RE_NODE_POSTFIX, ""); + + callback(null, source); + }); + } + + function getFrames(callback, silent) { + v8dbg.backtrace(function(data) { + var frames = data.callFrames.map(function(frameData, index) { + return createFrame(data.callFrames, index); + }); + + emit("getFrames", { frames: frames }); + callback(null, frames); + }); + } + + function getScope(frame, scope, callback) { + v8dbg.getProperties({ + objectId: scope.id, + ownProperties: false, + accessorPropertiesOnly: false, + generatePreview: true + }, function(body, error) { + if (error) + return callback(error); + + var variables = (body.result || []).map(function(prop) { + return createVariable(prop); + }); + + scope.variables = variables; + + callback(null, variables, scope, frame); + }); + } + + function getProperties(variable, callback) { + if (!variable.ref) + return callback(null, []); + v8dbg.getProperties({ + objectId: variable.ref, + ownProperties: true, + accessorPropertiesOnly: false, + generatePreview: true + }, function(body, error) { + if (error) + return callback(error); + + var properties = (body.result || []).map(function(prop) { + return createVariable(prop); + }); + + variable.properties = properties; + + callback(null, properties); + }); + } + + function stepInto(callback) { + v8dbg.stepInto(callback); + } + + function stepOver(callback) { + v8dbg.stepOver(callback); + } + + function stepOut(callback) { + v8dbg.stepOut(callback); + } + + function resume(callback) { + v8dbg.resume(callback); + } + + function suspend(callback) { + v8dbg.suspend(function() { + emit("suspend"); + callback && callback(); + }); + } + + function setScriptSource(script, newSource, previewOnly, callback) { + newSource = NODE_PREFIX + newSource.replace(/^#!.*/, "") + NODE_POSTFIX; + + v8dbg.changelive(script.id, newSource, previewOnly, function(data, error) { + var errorMessage = "Debugger could not update source of saved file." + if (error) + return callback(new Error(errorMessage)); + if (data && data.exceptionDetails) + return callback(new Error(errorMessage + " " + data.exceptionDetails.text)); + + emit("setScriptSource", data); + callback(null, data); + }); + } + + function restartFrame(frame, callback) { + v8dbg.restartframe(frame.id, function(result, error) { + stepInto(callback); + }); + } + + function evaluate(expression, frame, global, disableBreak, callback) { + v8dbg.evaluate(expression, frame, global, disableBreak, function(data) { + var value = data.result; + var error = data.error; + var name = expression.trim(); + if (error) { + var err = new Error(error.message); + err.name = name; + err.stack = error.stack; + return callback(err); + } + + var variable = createVariable({ + name: name, + value: value, + }); + + callback(null, variable); + }); + } + + function setBreakpoint(bp, callback) { + var sm = bp.sourcemap || {}; + var path = sm.source || bp.path; + var line = sm.line || bp.line; + var column = sm.column || bp.column; + + if (!path) { + callback && callback(new Error("Ignoring breakpoint with invalid path.")); + return false; + } + + path = applyPathMap(path, "toExternal"); + + if (path[0] == "/") + path = stripPrefix + path; + else if (path[0] == "~") + path = c9.home + path.substr(1); + + path = c9.toExternalPath(path); + + v8dbg.setbreakpoint(path, line, column, bp.enabled, bp.condition, function(info) { + if (!info) + return callback && callback(new Error()); + + bp.id = info.breakpointId; + if (info.locations) { + var loc = info.locations[0]; + bp.actual = loc && { + line: loc.lineNumber, + column: loc.columnNumber, + scriptId: loc.scriptId, + }; + emit("breakpointUpdate", { breakpoint: bp }); + } + callback && callback(null, bp, info); + }); + + return true; + } + + function changeBreakpoint(bp, callback) { + setBreakpoint(bp, callback); + } + + function clearBreakpoint(bp, callback) { + v8dbg.clearbreakpoint(bp.id, callback); + } + + function listBreakpoints(callback) { + v8dbg.listbreakpoints(function(data) { + if (!data) return callback(new Error("Not Connected")); + + breakOnExceptions = data.breakOnExceptions; + breakOnUncaughtExceptions = data.breakOnUncaughtExceptions; + + callback(null, data.breakpoints.map(function(bp) { + return createBreakpoint(bp); + })); + }); + } + + function setVariable(variable, value, frame, callback) { + v8dbg.setvariablevalue(variable, value, frame, callback); + } + + function serializeVariable(variable, callback) { + return callback(variable.value); + } + + function setBreakBehavior(type, enabled, callback) { + breakOnExceptions = enabled ? type == "all" : false; + breakOnUncaughtExceptions = enabled ? type == "uncaught" : false; + + v8dbg.setexceptionbreak(enabled ? type : "none", callback); + } + + function setPathMap(v) { + if (!Array.isArray(v)) v = null; + pathMap = v && v.map(function(x) { + if (!x.toInternal || !x.toExternal) return; + var map = { + toInternal: {}, + toExternal: {} + }; + if (typeof x.toInternal.regex == "string") + map.toInternal.regex = new RegExp(x.toInternal.regex, "g"); + map.toInternal.replacement = x.toInternal.replacement; + if (typeof x.toExternal.regex == "string") + map.toExternal.regex = new RegExp(x.toExternal.regex, "g"); + map.toExternal.replacement = x.toExternal.replacement; + return map; + }).filter(Boolean); + } + + function applyPathMap(path, dir) { + if (!pathMap) + return path; + pathMap.forEach(function(record) { + var mapping = record[dir]; + path = path.replace(mapping.regex, mapping.replacement); + }); + return path; + } + + plugin.on("load", function() { + }); + plugin.on("unload", function() { + breakOnExceptions = null; + breakOnUncaughtExceptions = null; + attached = false; + v8dbg = null; + state = null; + activeFrame = null; + sources = null; + socket = null; + pathMap = null; + }); + plugin.freezePublicAPI({ + features: { + scripts: true, + conditionalBreakpoints: true, + liveUpdate: true, + updateWatchedVariables: true, + updateScopeVariables: true, + setBreakBehavior: true, + executeCode: true + }, + type: TYPE, + get state() { return state; }, + get attached() { return attached; }, + get breakOnExceptions() { return breakOnExceptions; }, + get breakOnUncaughtExceptions() { return breakOnUncaughtExceptions; }, + + _events: [ + "attach", + "detach", + "suspend", + "setScriptSource", + "error", + "getBreakpoints", + "breakpointUpdate", + "break", + "stateChange", + "exception", + "frameActivate", + "getFrames", + "sources", + "sourcesCompile" + ], + attach: attach, + detach: detach, + getSources: getSources, + getSource: getSource, + getFrames: getFrames, + getScope: getScope, + getProperties: getProperties, + stepInto: stepInto, + stepOver: stepOver, + stepOut: stepOut, + resume: resume, + suspend: suspend, + evaluate: evaluate, + setScriptSource: setScriptSource, + setBreakpoint: setBreakpoint, + changeBreakpoint: changeBreakpoint, + clearBreakpoint: clearBreakpoint, + listBreakpoints: listBreakpoints, + setVariable: setVariable, + restartFrame: restartFrame, + serializeVariable: serializeVariable, + setBreakBehavior: setBreakBehavior, + getProxySource: getProxySource, + setPathMap: setPathMap + }); + + return plugin; + } +}); + +define("vfs!plugins/c9.ide.run.debug/debuggers/chrome/chrome-debug-proxy.js",[],function (require, exports,module) { + var path = module.id.slice(4); + return { + srcUrl: requirejs.MODULE_LOAD_URL + "/~node/" + path, + path: path, + }; + }); + +define("plugins/c9.ide.run.debug/debuggers/chrome/chrome-debug-proxy-launcher",[], function(require, exports, module) { + var debugProxy = require("vfs!./chrome-debug-proxy.js"); + + var code = "module.exports = " + function(vfs, options, register) { + var extPath = "{EXTPATH}"; + var detached = true; + var force = false; + var nodeRequire = require; + var fs = nodeRequire("fs"); + check(); + + function check() { + fs.exists(extPath, function(exists) { + if (!exists) + return register(null, { launch: launch }); + launch(register); + }); + } + + function launch(callback) { + var p = nodeRequire("child_process").spawn(process.execPath, [extPath, force], { + stdio: detached ? "ignore" : undefined, + detached: detached + }); + if (detached) { + p.unref(); + } else { + p.stdout.pipe(process.stderr); + p.stderr.pipe(process.stderr); + } + callback(null, {}); + } + }; + + exports.connect = function(imports, options, callback) { + var util = imports.util; + var vfs = imports.vfs; + var c9 = imports.c9; + var fs = imports.fs; + var extPath = c9.standalone && !/packed=1/.test(c9.location) + ? c9.sourceDir + "/" + debugProxy.path + : c9.home + "/.c9/vfs-cache/chrome-debug-proxy.js"; + + var socketPath = c9.home + "/.c9/chrome.sock"; + if (c9.platform == "win32") + socketPath = "\\\\.\\pipe\\" + socketPath.replace(/\//g, "\\"); + + vfs.extend("chromeDebugProxyLauncher", { + code: code.replace("{EXTPATH}", extPath), + redefine: true + }, function(err, remote) { + if (err) console.error("Error loading vfs extension", err); + if (remote && remote.api.launch) { + return require(["text!" + debugProxy.srcUrl], function(code) { + if (!code) + return console.error("Debug proxy module not found"); + fs.writeFile(util.normalizePath(extPath), code, function() { + remote.api.launch(function() { + tryConnect(30); + }); + }); + }); + } + + tryConnect(30); + }); + + function tryConnect(retries) { + connectPort(function next(err, socket) { + if (err && retries > 0) { + return setTimeout(function() { + tryConnect(retries - 1); + }, 100); + } + callback(err, socket); + }); + } + + function connectPort(callback) { + vfs.connect(socketPath, { encoding: "utf8" }, function(err, meta) { + if (err) return callback(err); + + stream = meta.stream; + var buff = []; + stream.on("data", function(data) { + var idx; + while (true) { + idx = data.indexOf("\0"); + if (idx === -1) + return data && buff.push(data); + buff.push(data.substring(0, idx)); + var clientMsg = buff.join(""); + data = data.substring(idx + 1); + buff = []; + var m; + try { + m = JSON.parse(clientMsg); + } catch (e) { + continue; + } + socket.emit("message", m); + } + }); + stream.on("end", function(err) { + console.log("end", err); + socket.emit("end", err); + }); + stream.on("error", function(err) { + socket.emit("error", err); + }); + + socket.send({ $: "connect", port: options.port, host: options.host }); + socket.on("message", function me(m) { + if (m && m.$ == "connected") { + socket.mode = m.mode; + socket.off("message", me); + callback && callback(null, socket); + } + }); + }); + } + + var stream; + var socket = options.socket; + socket.emit = socket.getEmitter(); + socket.send = function(s) { + stream && stream.write(JSON.stringify(s) + "\0"); + }; + socket.close = function() { + stream && stream.end(); + }; + c9.on("disconnect", function() { + stream && stream.end(); + }, socket); + c9.on("connect", function() { + stream && stream.end(); + connectPort(function() {}); + }, socket); + + socket.on("unload", function() { + stream.end(); + }); + }; +}); + +define("plugins/c9.ide.run.debug/debuggers/v8/v8debugger",[], function(require, exports, module) { + main.consumes = ["Plugin", "debugger", "util", "c9", "vfs", "fs"]; + main.provides = ["nodedebugger"]; + return main; + + function main(options, imports, register) { + var c9 = imports.c9; + var vfs = imports.vfs; + var util = imports.util; + var Plugin = imports.Plugin; + var debug = imports.debugger; + var v8DebuggerPlugin = require("./oldv8debugger")(options, imports); + var chromeDebuggerPlugin = require("../chrome/chromedebugger")(options, imports); + + var proxyLauncher = require("../chrome/chrome-debug-proxy-launcher"); + + var dbg, state, process, attached; + + var plugin = new Plugin("Ajax.org", main.consumes); + var emit = plugin.getEmitter(); + emit.setMaxListeners(1000); + var eventForwarder; + var _events = [ + "attach", + "detach", + "suspend", + "setScriptSource", + "error", + "getBreakpoints", + "breakpointUpdate", + "break", + "stateChange", + "exception", + "frameActivate", + "getFrames", + "sources", + "sourcesCompile" + ]; + + function attach(socket, reconnect, callback) { + var runner = process.runner; + proxyLauncher.connect(imports, { + port: runner.debugport, + host: runner.debughost, + sourceDir: c9.sourceDir, + socket: socket, + }, function(err, socket) { + if (err) return callback(err); + + var newDbg = socket.mode == "v8" + ? v8DebuggerPlugin + : chromeDebuggerPlugin; + + if (dbg != newDbg) { + detach(); + dbg = newDbg; + } + + if (eventForwarder) + eventForwarder.unload(); + eventForwarder = new Plugin(); + eventForwarder.load(); + _events.forEach(function(event) { + dbg.on(event, function(e) { + return emit(event, e); + }, eventForwarder); + }); + + dbg.on(event, function(e) { + return emit(event, e); + }, eventForwarder); + + dbg.attach(socket, reconnect, callback); + }); + } + + function detach() { + if (dbg) { + dbg.detach(); + dbg = null; + } + } + + plugin.on("load", function() { + v8DebuggerPlugin.load(); + chromeDebuggerPlugin.load(); + + debug.registerDebugger("v8", plugin); + debug.registerDebugger("chrome", plugin); + }); + plugin.on("unload", function() { + debug.unregisterDebugger("v8", plugin); + debug.unregisterDebugger("chrome", plugin); + + v8DebuggerPlugin.unload(); + chromeDebuggerPlugin.unload(); + process = attached = dbg = null; + eventForwarder.unload(); + eventForwarder = null; + }); + + plugin.freezePublicAPI({ + features: { + scripts: true, + conditionalBreakpoints: true, + liveUpdate: true, + updateWatchedVariables: true, + updateScopeVariables: true, + setBreakBehavior: true, + executeCode: true + }, + get type() { dbg ? dbg.type : "" }, + get state() { return dbg ? dbg.state : state; }, + get attached() { return dbg ? dbg.attached : attached; }, + get breakOnExceptions() { return dbg.breakOnExceptions; }, + get breakOnUncaughtExceptions() { return dbg.breakOnUncaughtExceptions; }, + + _events: _events, + + attach: attach, + detach: detach, + + getSources: function() { return dbg.getSources.apply(dbg, arguments); }, + getSource: function() { return dbg.getSource.apply(dbg, arguments); }, + getFrames: function() { return dbg.getFrames.apply(dbg, arguments); }, + getScope: function() { return dbg.getScope.apply(dbg, arguments); }, + getProperties: function() { return dbg.getProperties.apply(dbg, arguments); }, + stepInto: function() { return dbg.stepInto.apply(dbg, arguments); }, + stepOver: function() { return dbg.stepOver.apply(dbg, arguments); }, + stepOut: function() { return dbg.stepOut.apply(dbg, arguments); }, + resume: function() { return dbg.resume.apply(dbg, arguments); }, + suspend: function() { return dbg.suspend.apply(dbg, arguments); }, + evaluate: function() { return dbg.evaluate.apply(dbg, arguments); }, + setScriptSource: function() { return dbg.setScriptSource.apply(dbg, arguments); }, + setBreakpoint: function() { return dbg.setBreakpoint.apply(dbg, arguments); }, + changeBreakpoint: function() { return dbg.changeBreakpoint.apply(dbg, arguments); }, + clearBreakpoint: function() { return dbg.clearBreakpoint.apply(dbg, arguments); }, + listBreakpoints: function() { return dbg.listBreakpoints.apply(dbg, arguments); }, + setVariable: function() { return dbg.setVariable.apply(dbg, arguments); }, + restartFrame: function() { return dbg.restartFrame.apply(dbg, arguments); }, + serializeVariable: function() { return dbg.serializeVariable.apply(dbg, arguments); }, + setBreakBehavior: function() { return dbg.setBreakBehavior.apply(dbg, arguments); }, + getProxySource: function(_process) { + process = _process; + return false; + }, + setPathMap: function() { + v8DebuggerPlugin.setPathMap.apply(v8DebuggerPlugin, arguments); + chromeDebuggerPlugin.setPathMap.apply(chromeDebuggerPlugin, arguments); + }, + }); + register(null, { - v8debugger: plugin + nodedebugger: plugin }); } }); @@ -93179,7 +94211,7 @@ define("plugins/c9.ide.run.debug/data/scope",[], function(require, exports, modu } Scope.prototype = new Data( - ["index", "frameIndex", "type"], + ["index", "frameIndex", "type", "id"], ["variables"] ); @@ -93425,8 +94457,6 @@ define("plugins/c9.ide.run.debug/debuggers/debugger",[], function(require, expor ui.insertSkin({ name: "debugger", data: require("text!./skin.xml"), - "media-path": options.staticPrefix + "/images/", - "icon-path": options.staticPrefix + "/icons/" }, plugin); var bar = opts.aml; @@ -106849,7 +107879,6 @@ return function(_request) { if ($reqHeaders) message += ($reqHeaders == headers) + $reqHeaders["x-request-metadata"]; console.error($reqHeaders, headers, message); - setTimeout(function() { throw new Error(message); }); return callback(err, data.substr(0, ln - ml), res); } callback(err, data.substr(0, ln - ml), ml && data.substr(-1 * ml) || "", res); @@ -108311,8 +109340,7 @@ define("plugins/c9.ide.dialog.common/notification",[], function(require, exports if (loaded) return false; loaded = true; - ui.insertCss(require("text!./notification.css"), - options.staticPrefix, plugin); + ui.insertCss(require("text!./notification.css"), null, plugin); layout.on("themeChange", function() { if (logo) { @@ -108464,8 +109492,7 @@ define("plugins/c9.ide.dialog.common/error",[], function(require, exports, modul var DISCONNECTDELAY = 1000; function load() { - ui.insertCss(require("text!./error.css"), - options.staticPrefix, plugin); + ui.insertCss(require("text!./error.css"), true, plugin); } function initDisconnectEvents(vfs) { @@ -127878,7 +128905,7 @@ define("plugins/c9.ide.ui/widgets.list",[], function(require, exports, module) { }; ui.on("load", function() { - ui.insertCss(require("text!./widgets.less"), options.staticPrefix, ui); + ui.insertCss(require("text!./widgets.less"), null, ui); }); function List(options, forPlugin, baseclass) { @@ -131432,12 +132459,10 @@ define("plugins/c9.ide.find.replace/findreplace",[], function(require, exports, function draw() { if (drawn) return; drawn = true; - ui.insertCss(css, options.staticPrefix, plugin); + ui.insertCss(css, null, plugin); ui.insertSkin({ name: "searchreplace", data: skin, - "media-path": options.staticPrefix + "/images/", - "icon-path": options.staticPrefix + "/icons/" }, plugin); searchRow = layout.findParent(plugin); ui.insertMarkup(null, markup, plugin); @@ -141347,8 +142372,6 @@ define("plugins/c9.ide.ace.statusbar/statusbar",[], function(require, exports, m ui.insertSkin({ name: "c9statusbar", data: skin, - "media-path": options.staticPrefix + "/images/", - "icon-path": options.staticPrefix + "/icons/" }, handle); } @@ -141663,7 +142686,6 @@ define("plugins/c9.ide.ace.gotoline/gotoline",[], function(require, exports, mod ui.insertSkin({ name: "gotoline", data: skin, - "media-path": options.staticPrefix + "/images/" }, plugin); ui.insertMarkup(null, markup, plugin); @@ -145034,7 +146056,7 @@ define("plugins/c9.ide.ace/ace",[], function(require, exports, module) { if (e.type != "ace") handle.setTheme(defaultThemes[e.theme]); }, handle); - ui.insertCss(cssString, options.staticPrefix, handle); + ui.insertCss(cssString, null, handle); }); handle.on("unload", function() { drawn = false; @@ -148070,7 +149092,6 @@ define("plugins/c9.ide.openfiles/openfiles",[], function(require, exports, modul var plugin = new Plugin("Ajax.org", main.consumes); var emit = plugin.getEmitter(); - var staticPrefix = options.staticPrefix; var showOpenFiles = false; var defaultShow = options.defaultShow; var dragged = false; @@ -148131,7 +149152,7 @@ define("plugins/c9.ide.openfiles/openfiles",[], function(require, exports, modul function draw() { if (drawn) return; drawn = true; - ui.insertCss(require("text!./openfiles.css"), staticPrefix, plugin); + ui.insertCss(require("text!./openfiles.css"), null, plugin); tree.getElement("winOpenfiles", function(winOpenfiles) { treeParent = winOpenfiles; @@ -148146,7 +149167,6 @@ define("plugins/c9.ide.openfiles/openfiles",[], function(require, exports, modul ofDataProvider = new TreeData(); ofTree.renderer.setTheme({ cssClass: "filetree" }); ofTree.setDataProvider(ofDataProvider); - ofDataProvider.staticPrefix = staticPrefix; layout.on("eachTheme", function(e) { var height = parseInt(ui.getStyleRule(".openfiles .ace_tree .tree-row", "height"), 10); @@ -152192,8 +153212,7 @@ define("plugins/c9.ide.imgeditor/imgeditor",[], function(require, exports, modul handle.draw = function() { if (drawn) return; drawn = true; - ui.insertCss(require("text!./style.css"), - options.staticPrefix, handle); + ui.insertCss(require("text!./style.css"), null, handle); }; function UndoItem(original, changed, apply) { this.getState = function() { }; diff --git a/build/standalone/skin/default/dark-gray.css b/build/standalone/skin/default/dark-gray.css index b1bb511e..511dc99b 100644 --- a/build/standalone/skin/default/dark-gray.css +++ b/build/standalone/skin/default/dark-gray.css @@ -2915,7 +2915,7 @@ body .error_widget_arrow.ace_ok { z-index: 100001; } .thingy-popup > .close { - background-image: url("/static/plugins/c9.ide.guide/images/close_tab_btn_flat_light@2x.png"); + background-image: url("/static/plugins/c9.ide.layout.classic/images/close_tab_btn_flat_light@2x.png"); background-size: 42px 28px; position: absolute; right: 20px; diff --git a/build/standalone/skin/default/dark.css b/build/standalone/skin/default/dark.css index 64d2ef6f..8a411e79 100644 --- a/build/standalone/skin/default/dark.css +++ b/build/standalone/skin/default/dark.css @@ -2915,7 +2915,7 @@ body .error_widget_arrow.ace_ok { z-index: 100001; } .thingy-popup > .close { - background-image: url("/static/plugins/c9.ide.guide/images/close_tab_btn_flat_light@2x.png"); + background-image: url("/static/plugins/c9.ide.layout.classic/images/close_tab_btn_flat_light@2x.png"); background-size: 42px 28px; position: absolute; right: 20px; diff --git a/build/standalone/skin/default/flat-dark.css b/build/standalone/skin/default/flat-dark.css index 4793603c..3d8c5e63 100644 --- a/build/standalone/skin/default/flat-dark.css +++ b/build/standalone/skin/default/flat-dark.css @@ -2844,7 +2844,7 @@ body .error_widget_arrow.ace_ok { z-index: 100001; } .thingy-popup > .close { - background-image: url("/static/plugins/c9.ide.guide/images/close_tab_btn_flat_light@2x.png"); + background-image: url("/static/plugins/c9.ide.layout.classic/images/close_tab_btn_flat_light@2x.png"); background-size: 42px 28px; position: absolute; right: 20px; diff --git a/build/standalone/skin/default/flat-light.css b/build/standalone/skin/default/flat-light.css index 120ff622..0ffeb551 100644 --- a/build/standalone/skin/default/flat-light.css +++ b/build/standalone/skin/default/flat-light.css @@ -2844,7 +2844,7 @@ body .error_widget_arrow.ace_ok { z-index: 100001; } .thingy-popup > .close { - background-image: url("/static/plugins/c9.ide.guide/images/close_tab_btn_flat_light@2x.png"); + background-image: url("/static/plugins/c9.ide.layout.classic/images/close_tab_btn_flat_light@2x.png"); background-size: 42px 28px; position: absolute; right: 20px; diff --git a/build/standalone/skin/default/light-gray.css b/build/standalone/skin/default/light-gray.css index d219aa1e..6135e178 100644 --- a/build/standalone/skin/default/light-gray.css +++ b/build/standalone/skin/default/light-gray.css @@ -2915,7 +2915,7 @@ body .error_widget_arrow.ace_ok { z-index: 100001; } .thingy-popup > .close { - background-image: url("/static/plugins/c9.ide.guide/images/close_tab_btn_flat_light@2x.png"); + background-image: url("/static/plugins/c9.ide.layout.classic/images/close_tab_btn_flat_light@2x.png"); background-size: 42px 28px; position: absolute; right: 20px; diff --git a/build/standalone/skin/default/light.css b/build/standalone/skin/default/light.css index b18adee3..eaa6b13d 100644 --- a/build/standalone/skin/default/light.css +++ b/build/standalone/skin/default/light.css @@ -2915,7 +2915,7 @@ body .error_widget_arrow.ace_ok { z-index: 100001; } .thingy-popup > .close { - background-image: url("/static/plugins/c9.ide.guide/images/close_tab_btn_flat_light@2x.png"); + background-image: url("/static/plugins/c9.ide.layout.classic/images/close_tab_btn_flat_light@2x.png"); background-size: 42px 28px; position: absolute; right: 20px; diff --git a/build/standalone/static/plugins/c9.ide.run/runners-docker/Node.js (default).run b/build/standalone/static/plugins/c9.ide.run/runners-docker/Node.js (default).run index 8e6be838..e6edcb7b 100644 --- a/build/standalone/static/plugins/c9.ide.run/runners-docker/Node.js (default).run +++ b/build/standalone/static/plugins/c9.ide.run/runners-docker/Node.js (default).run @@ -1,5 +1,18 @@ { - "cmd": ["bash", "--login", "-c", "nvm use default > /dev/null; node ${debug?--nocrankshaft --nolazy --nodead_code_elimination --debug-brk=15454} '$file' $args"], + "script": [ + "set -e", + "if ! [ \"$debug\" == true ]; then ", + " node $file $args", + "elif node --debug -e '' &> /dev/null; then", + " FLAGS=\"--nocrankshaft --nolazy --debug-brk=$debugport\"", + " if node --nodead_code_elimination -e '' &> /dev/null; then", + " FLAGS=\"$FLAGS --nodead_code_elimination\"", + " fi", + " node $FLAGS $file $args", + "else", + " node --inspect-brk=$debugport $file $args", + "fi" + ], "debugger": "v8", "debugport": 15454, "selector": "source.js", diff --git a/build/standalone/static/plugins/c9.ide.run/runners/Node.js.run b/build/standalone/static/plugins/c9.ide.run/runners/Node.js.run index 0a96b4da..1879613f 100644 --- a/build/standalone/static/plugins/c9.ide.run/runners/Node.js.run +++ b/build/standalone/static/plugins/c9.ide.run/runners/Node.js.run @@ -1,12 +1,17 @@ { - "cmd": [ - "node", - "${debug?--nocrankshaft}", - "${debug?--nolazy}", - "${debug?`node --version | grep -vqE \"v0\\..\\.\" && echo --nodead_code_elimination`}", - "${debug?--debug-brk=$debugport}", - "$file", - "$args" + "script": [ + "set -e", + "if ! [ \"$debug\" == true ]; then ", + " node $file $args", + "elif node --debug -e '' &> /dev/null; then", + " FLAGS=\"--nocrankshaft --nolazy --debug-brk=$debugport\"", + " if node --nodead_code_elimination -e '' &> /dev/null; then", + " FLAGS=\"$FLAGS --nodead_code_elimination\"", + " fi", + " node $FLAGS $file $args", + "else", + " node --inspect-brk=$debugport $file $args", + "fi" ], "debugger": "v8", "debugport": 15454, diff --git a/configs/ide/default.js b/configs/ide/default.js index cb53d374..9930230e 100644 --- a/configs/ide/default.js +++ b/configs/ide/default.js @@ -91,7 +91,6 @@ module.exports = function(options) { "plugins/c9.ide.plugins/gui", // { // packagePath: "plugins/c9.ide.plugins/test", - // staticPrefix: staticPrefix + "/plugins/c9.ide.plugins" // }, // VFS @@ -164,7 +163,6 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.openfiles/openfiles", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic", defaultShow: options.local }, { @@ -177,21 +175,14 @@ module.exports = function(options) { "plugins/c9.ide.keys/editor", { packagePath: "plugins/c9.ide.ace/ace", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic", workerPrefix: options.workerPrefix }, "plugins/c9.ide.ace/themes", "plugins/c9.ide.ace.stripws/stripws", "plugins/c9.ide.ace.repl/editor", // "plugins/c9.ide.ace.split/split", - { - packagePath: "plugins/c9.ide.ace.gotoline/gotoline", - staticPrefix: staticPrefix + "/plugins/c9.ide.ace.gotoline" - }, - { - packagePath: "plugins/c9.ide.ace.statusbar/statusbar", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic" - }, + "plugins/c9.ide.ace.gotoline/gotoline", + "plugins/c9.ide.ace.statusbar/statusbar", "plugins/c9.ide.ace.keymaps/keymaps", "plugins/c9.ide.ace.keymaps/cli", @@ -212,10 +203,7 @@ module.exports = function(options) { node: options.nodeBin, local: options.local, }, - { - packagePath: "plugins/c9.ide.find.infiles/findinfiles", - staticPrefix: staticPrefix + "/plugins/c9.ide.find.infiles" - }, + "plugins/c9.ide.find.infiles/findinfiles", { packagePath: "plugins/c9.ide.find.replace/findreplace", staticPrefix: staticPrefix + "/plugins/c9.ide.find.replace" @@ -224,7 +212,6 @@ module.exports = function(options) { // UI { packagePath: "plugins/c9.ide.ui/ui", - staticPrefix: staticPrefix + "/plugins/c9.ide.ui" }, "plugins/c9.ide.ui/anims", "plugins/c9.ide.ui/tooltip", @@ -233,10 +220,7 @@ module.exports = function(options) { autoInit: !options.local }, "plugins/c9.ide.ui/forms", - { - packagePath: "plugins/c9.ide.ui/widgets.list", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic" - }, + "plugins/c9.ide.ui/widgets.list", "plugins/c9.ide.ui/widgets.tree", "plugins/c9.ide.ui/widgets.datagrid", "plugins/c9.ide.ui/widgets.terminal", @@ -255,11 +239,9 @@ module.exports = function(options) { "plugins/c9.ide.dialog.common/upsell", { packagePath: "plugins/c9.ide.dialog.common/error", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic" }, { packagePath: "plugins/c9.ide.dialog.common/notification", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic" }, { packagePath: "plugins/c9.ide.dialog.login/login", @@ -413,7 +395,6 @@ module.exports = function(options) { { packagePath: "plugins/c9.ide.run/run", base: workspaceDir, - staticPrefix: staticPrefix + "/plugins/c9.ide.run", tmux: options.tmux, runners: runners, installPath: options.correctedInstallPath, @@ -421,7 +402,6 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.run/gui", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic", defaultConfigs: {} }, { @@ -435,7 +415,6 @@ module.exports = function(options) { // "plugins/c9.ide.run.debug/debuggers/sourcemap", { packagePath: "plugins/c9.ide.run.debug/debuggers/debugger", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic" }, { packagePath: "plugins/c9.ide.run.debug/debuggers/v8/v8debugger", @@ -450,7 +429,6 @@ module.exports = function(options) { "plugins/c9.ide.run.debug/callstack", { packagePath: "plugins/c9.ide.immediate/immediate", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic" }, "plugins/c9.ide.immediate/evaluator", "plugins/c9.ide.immediate/evaluators/browserjs", @@ -471,7 +449,6 @@ module.exports = function(options) { root: workspaceDir, tmpdir: options.tmpdir, shell: options.shell || "", - staticPrefix: staticPrefix + "/plugins/c9.ide.terminal", installPath: options.correctedInstallPath }, { @@ -487,18 +464,15 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.terminal.monitor/message_view", - staticPrefix: options.staticPrefix + "/plugins/c9.ide.layout.classic" }, "plugins/c9.ide.terminal/opentermhere", { packagePath: "plugins/c9.ide.run/output", - staticPrefix: options.staticPrefix + "/plugins/c9.ide.layout.classic", tmux: options.tmux, basePath: workspaceDir }, { packagePath: "plugins/c9.ide.console/console", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic", defaultState: options.project.scmurl ? { type: "pane", nodes: [{ @@ -560,7 +534,6 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.upload/upload", - staticPrefix: staticPrefix + "/plugins/c9.ide.upload" }, { packagePath: "plugins/c9.ide.upload/upload_manager", @@ -568,7 +541,6 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.upload/upload_progress", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic" }, { packagePath: "plugins/c9.ide.navigate/navigate", @@ -579,11 +551,9 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.language.core/outline", - staticPrefix: staticPrefix + "/plugins/c9.ide.language" }, { packagePath: "plugins/c9.ide.panels/panels", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic", defaultActiveLeft: "tree" }, "plugins/c9.ide.panels/panel", @@ -591,10 +561,7 @@ module.exports = function(options) { "plugins/c9.ide.processlist/processlist", // Installer - { - packagePath: "plugins/c9.ide.installer/gui", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic", - }, + "plugins/c9.ide.installer/gui", "plugins/c9.automate/automate", "plugins/c9.ide.installer/commands/centos", "plugins/c9.ide.installer/commands/darwin", @@ -621,7 +588,6 @@ module.exports = function(options) { // Previewer { packagePath: "plugins/c9.ide.preview/preview", - staticPrefix: staticPrefix + "/plugins/c9.ide.preview", defaultPreviewer: "preview.browser", previewUrl: options.previewUrl, local: options.local @@ -682,7 +648,6 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.welcome/welcome", - staticPrefix: staticPrefix + "/plugins/c9.ide.welcome", intro: "Welcome to Cloud9. Use this welcome screen " + "to tweak the look & feel of the Cloud9 user interface. ", checkOS: true @@ -697,12 +662,10 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.help/help", - staticPrefix: staticPrefix + "/plugins/c9.ide.help", hosted: hosted }, { packagePath: "plugins/c9.ide.guide/guide", - staticPrefix: staticPrefix + "/plugins/c9.ide.guide" }, { packagePath: "plugins/c9.ide.guide/default" @@ -726,15 +689,12 @@ module.exports = function(options) { "plugins/c9.ide.behaviors/tabs", // { // packagePath: "plugins/c9.ide.behaviors/dashboard", - // staticPrefix : staticPrefix + "/plugins/c9.ide.behaviors" // }, { packagePath: "plugins/c9.ide.behaviors/page", - staticPrefix: staticPrefix + "/plugins/c9.ide.behaviors" }, { packagePath: "plugins/c9.ide.preferences/preferences", - staticPrefix: staticPrefix + "/plugins/c9.ide.preferences" }, "plugins/c9.ide.preferences/preferencepanel", { @@ -750,7 +710,6 @@ module.exports = function(options) { "plugins/c9.ide.preferences/experimental", { packagePath: "plugins/c9.ide.login/login", - staticPrefix: staticPrefix + "/plugins/c9.ide.login", ideBaseUrl: options.ideBaseUrl, dashboardUrl: options.dashboardUrl, accountUrl: options.accountUrl, @@ -761,7 +720,6 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.collab/notifications/bubble", - staticPrefix: staticPrefix + "/plugins/c9.ide.collab/notifications" }, "plugins/c9.ide.behaviors/zentabs", @@ -773,7 +731,6 @@ module.exports = function(options) { "plugins/c9.ide.test/testrunner", { packagePath: "plugins/c9.ide.test/all", - staticPrefix: staticPrefix + "/plugins/c9.ide.test" }, "plugins/c9.ide.test/results", "plugins/c9.ide.test/coverage", @@ -784,7 +741,6 @@ module.exports = function(options) { // git integration v2 // { // packagePath: "plugins/c9.ide.scm/scm.commit", - // staticPrefix: staticPrefix + "/plugins/c9.ide.scm" // }, // "plugins/c9.ide.scm/scm", // "plugins/c9.ide.scm/scm.branches", @@ -861,12 +817,10 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.collab/cursor_layer", - staticPrefix: staticPrefix + "/plugins/c9.ide.collab" }, "plugins/c9.ide.collab/author_layer", { packagePath: "plugins/c9.ide.collab/timeslider/timeslider", - staticPrefix: staticPrefix + "/plugins/c9.ide.collab/timeslider" }, // Collab panels { @@ -882,7 +836,6 @@ module.exports = function(options) { }, { packagePath: "plugins/c9.ide.collab/members/members", - staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic" }, { packagePath: "plugins/c9.ide.collab/chat/chat", diff --git a/lib/tern/node_modules/glob/node_modules/inherits/package.json b/lib/tern/node_modules/glob/node_modules/inherits/package.json index fd63bd6d..f0e62d3c 100644 --- a/lib/tern/node_modules/glob/node_modules/inherits/package.json +++ b/lib/tern/node_modules/glob/node_modules/inherits/package.json @@ -36,7 +36,7 @@ "homepage": "https://github.com/isaacs/inherits#readme", "_id": "inherits@2.0.3", "_shasum": "633c2c83e3da42a502f52466022480f4208261de", - "_from": "inherits@>=2.0.0 <3.0.0", + "_from": "inherits@>=2.0.1 <2.1.0", "_npmVersion": "3.10.7", "_nodeVersion": "6.5.0", "_npmUser": { diff --git a/lib/tern/package.json b/lib/tern/package.json index 23cc0c24..bc8c884a 100644 --- a/lib/tern/package.json +++ b/lib/tern/package.json @@ -248,7 +248,7 @@ }, "homepage": "https://github.com/ternjs/tern#readme", "_id": "tern@0.16.1", - "_shasum": "4ca130c0ce663fee9add61de32be700cfede4d07", + "_shasum": "2214c041bc8f4cda10887f5056b38a716cd8bf2f", "_from": "git+https://github.com/cloud9ide/tern.git#39015d544d4c00c7899fea4c95c2e5bc2720e68e", "_resolved": "git+https://github.com/cloud9ide/tern.git#39015d544d4c00c7899fea4c95c2e5bc2720e68e" } diff --git a/lib/tern_from_ts/package.json b/lib/tern_from_ts/package.json index a4b1ffc7..9ec62a64 100644 --- a/lib/tern_from_ts/package.json +++ b/lib/tern_from_ts/package.json @@ -20,7 +20,7 @@ "readme": "# tern_from_ts\n\nTern signatures extracted from typescript signatures.\n\nLicense: MIT\n\nSee also https://github.com/marijnh/tern and https://github.com/borisyankov/DefinitelyTyped\n", "readmeFilename": "README.md", "_id": "tern_from_ts@0.0.1", - "_shasum": "f0553eb889a809d4bdd920acf43f78259245c70c", + "_shasum": "4980859cce428ad97c2dd6463b9d906be6c9da84", "_from": "git+https://github.com/cloud9ide/tern_from_ts.git#66df507986bbdd63f3bc4f0c53edb39169ce4f1c", "_resolved": "git+https://github.com/cloud9ide/tern_from_ts.git#66df507986bbdd63f3bc4f0c53edb39169ce4f1c" } diff --git a/node_modules/architect-build/build.js b/node_modules/architect-build/build.js index 7696cce1..1eda37c4 100644 --- a/node_modules/architect-build/build.js +++ b/node_modules/architect-build/build.js @@ -386,6 +386,15 @@ function rewriteDefines(sources, opts){ + source + '");'; } + else if (pkg.id.indexOf("vfs!") > -1) { + pkg.source = 'define("' + pkg.id + '",[],' + function(require, exports,module) { + var path = module.id.slice(4); + return { + srcUrl: requirejs.MODULE_LOAD_URL + "/~node/" + path, + path: path, + }; + } + ');'; + } else { var deps = []; if (keepDeps) { diff --git a/node_modules/architect-build/build_support/mini_require.js b/node_modules/architect-build/build_support/mini_require.js index 7be11ca4..d579bc94 100644 --- a/node_modules/architect-build/build_support/mini_require.js +++ b/node_modules/architect-build/build_support/mini_require.js @@ -1,6 +1,6 @@ (function() { -var MODULE_LOAD_URL = "/load/module"; +var MODULE_LOAD_URL = "/static/build/modules"; var global = (function() { return this; })(); if (!global && typeof window != "undefined") global = window; // can happen in strict mode @@ -632,6 +632,17 @@ function definePlugin(plugin, p) { } /*** plugins ***/ +require["vfs!"] = function(module, callback) { + var url = require.MODULE_LOAD_URL + "/~node/" + module; + if (define.fetchedUrls[url] & 3) + return false; + define.fetchedUrls[url] |= 3; + define("vfs!" + module, [], { + srcUrl: url, + path: module + }); + callback(); +}; require["text!"] = function(module, callback) { var url = require.toUrl(module); if (define.fetchedUrls[url] & 2) diff --git a/node_modules/architect-build/module-deps.js b/node_modules/architect-build/module-deps.js index 8bca9920..4779c6b0 100644 --- a/node_modules/architect-build/module-deps.js +++ b/node_modules/architect-build/module-deps.js @@ -75,11 +75,15 @@ module.exports = function(mains, opts) { function idToPathNode(mod) { var packagePath = mod.id; var filepath = mod.parent && mod.parent.file || root; - return Module._resolveFilename(packagePath, { - paths: Module._nodeModulePaths(filepath), - filename: filepath, - id: filepath, - }); + try { + return Module._resolveFilename(packagePath, { + paths: Module._nodeModulePaths(filepath), + filename: filepath, + id: filepath, + }); + } catch (e) { + return packagePath; + } } function readModule(mod, cb) { @@ -448,7 +452,7 @@ function debugSrc(module) { function quote(str) { return "'" - + str.replace(/[\\']/g, "\\$&").replace(/\n/g, "\\n") + + str.replace(/[\\']/g, "\\$&").replace(/\n/g, "\\n\\\n") + "'"; } diff --git a/node_modules/nak/package.json b/node_modules/nak/package.json index 7ad9f3cf..4e2fa827 100644 --- a/node_modules/nak/package.json +++ b/node_modules/nak/package.json @@ -52,7 +52,7 @@ }, "homepage": "https://github.com/gjtorikian/nak#readme", "_id": "nak@0.3.3", - "_shasum": "27ac2a29ae9b3a471056f7368730d4c51dae49de", + "_shasum": "57863f70104cbf7b7eaef2b83495da9d00075d5c", "_from": "git+https://github.com/cloud9ide/nak.git#6deef931594", "_resolved": "git+https://github.com/cloud9ide/nak.git#6deef931594787edd167040f7352e3e7533430e4" } diff --git a/node_modules/tern/node_modules/glob/node_modules/inherits/package.json b/node_modules/tern/node_modules/glob/node_modules/inherits/package.json index fd63bd6d..f0e62d3c 100644 --- a/node_modules/tern/node_modules/glob/node_modules/inherits/package.json +++ b/node_modules/tern/node_modules/glob/node_modules/inherits/package.json @@ -36,7 +36,7 @@ "homepage": "https://github.com/isaacs/inherits#readme", "_id": "inherits@2.0.3", "_shasum": "633c2c83e3da42a502f52466022480f4208261de", - "_from": "inherits@>=2.0.0 <3.0.0", + "_from": "inherits@>=2.0.1 <2.1.0", "_npmVersion": "3.10.7", "_nodeVersion": "6.5.0", "_npmUser": { diff --git a/node_modules/tern/package.json b/node_modules/tern/package.json index 23cc0c24..bc8c884a 100644 --- a/node_modules/tern/package.json +++ b/node_modules/tern/package.json @@ -248,7 +248,7 @@ }, "homepage": "https://github.com/ternjs/tern#readme", "_id": "tern@0.16.1", - "_shasum": "4ca130c0ce663fee9add61de32be700cfede4d07", + "_shasum": "2214c041bc8f4cda10887f5056b38a716cd8bf2f", "_from": "git+https://github.com/cloud9ide/tern.git#39015d544d4c00c7899fea4c95c2e5bc2720e68e", "_resolved": "git+https://github.com/cloud9ide/tern.git#39015d544d4c00c7899fea4c95c2e5bc2720e68e" } diff --git a/node_modules/tern_from_ts/package.json b/node_modules/tern_from_ts/package.json index a4b1ffc7..9ec62a64 100644 --- a/node_modules/tern_from_ts/package.json +++ b/node_modules/tern_from_ts/package.json @@ -20,7 +20,7 @@ "readme": "# tern_from_ts\n\nTern signatures extracted from typescript signatures.\n\nLicense: MIT\n\nSee also https://github.com/marijnh/tern and https://github.com/borisyankov/DefinitelyTyped\n", "readmeFilename": "README.md", "_id": "tern_from_ts@0.0.1", - "_shasum": "f0553eb889a809d4bdd920acf43f78259245c70c", + "_shasum": "4980859cce428ad97c2dd6463b9d906be6c9da84", "_from": "git+https://github.com/cloud9ide/tern_from_ts.git#66df507986bbdd63f3bc4f0c53edb39169ce4f1c", "_resolved": "git+https://github.com/cloud9ide/tern_from_ts.git#66df507986bbdd63f3bc4f0c53edb39169ce4f1c" } diff --git a/package.json b/package.json index 7102a670..70167037 100644 --- a/package.json +++ b/package.json @@ -49,5 +49,5 @@ }, "devDependencies": {}, "licenses": [], - "revision": "7ba90a03a5584e431261fa8006e87d29532878b7" + "revision": "2eab9c795751a21e2da1d00c968b89f040278dec" } diff --git a/plugins/c9.ide.run/runners-docker/Node.js (default).run b/plugins/c9.ide.run/runners-docker/Node.js (default).run index 8e6be838..e6edcb7b 100644 --- a/plugins/c9.ide.run/runners-docker/Node.js (default).run +++ b/plugins/c9.ide.run/runners-docker/Node.js (default).run @@ -1,5 +1,18 @@ { - "cmd": ["bash", "--login", "-c", "nvm use default > /dev/null; node ${debug?--nocrankshaft --nolazy --nodead_code_elimination --debug-brk=15454} '$file' $args"], + "script": [ + "set -e", + "if ! [ \"$debug\" == true ]; then ", + " node $file $args", + "elif node --debug -e '' &> /dev/null; then", + " FLAGS=\"--nocrankshaft --nolazy --debug-brk=$debugport\"", + " if node --nodead_code_elimination -e '' &> /dev/null; then", + " FLAGS=\"$FLAGS --nodead_code_elimination\"", + " fi", + " node $FLAGS $file $args", + "else", + " node --inspect-brk=$debugport $file $args", + "fi" + ], "debugger": "v8", "debugport": 15454, "selector": "source.js", diff --git a/plugins/c9.ide.run/runners/Node.js.run b/plugins/c9.ide.run/runners/Node.js.run index 0a96b4da..1879613f 100644 --- a/plugins/c9.ide.run/runners/Node.js.run +++ b/plugins/c9.ide.run/runners/Node.js.run @@ -1,12 +1,17 @@ { - "cmd": [ - "node", - "${debug?--nocrankshaft}", - "${debug?--nolazy}", - "${debug?`node --version | grep -vqE \"v0\\..\\.\" && echo --nodead_code_elimination`}", - "${debug?--debug-brk=$debugport}", - "$file", - "$args" + "script": [ + "set -e", + "if ! [ \"$debug\" == true ]; then ", + " node $file $args", + "elif node --debug -e '' &> /dev/null; then", + " FLAGS=\"--nocrankshaft --nolazy --debug-brk=$debugport\"", + " if node --nodead_code_elimination -e '' &> /dev/null; then", + " FLAGS=\"$FLAGS --nodead_code_elimination\"", + " fi", + " node $FLAGS $file $args", + "else", + " node --inspect-brk=$debugport $file $args", + "fi" ], "debugger": "v8", "debugport": 15454, diff --git a/plugins/c9.static/build.js b/plugins/c9.static/build.js index 8f8442dc..a6d26cf8 100644 --- a/plugins/c9.static/build.js +++ b/plugins/c9.static/build.js @@ -203,7 +203,14 @@ function main(options, imports, register) { if (/^(ace\/|plugins\/c9.ide.ace)/.test(module)) return buildAce(module, pathConfig, callback); - build([], { + var compileForNode = false; + if (/^~node\//.test(module)) { + module = module.substring(6); + compileForNode = true; + } + + build(compileForNode ? [module] : [], { + node: compileForNode, cache: cache, pathConfig: pathConfig, enableBrowser: true, @@ -212,11 +219,11 @@ function main(options, imports, register) { compress: compress, filter: [], ignore: [], - additional: [{ + additional: compileForNode && [{ id: module, noDeps: true }], - withRequire: false, + withRequire: compileForNode, basepath: pathConfig.root }, callback); } diff --git a/version b/version index 2b393d6a..4b409fe6 100644 --- a/version +++ b/version @@ -1 +1 @@ -1517889708 +1517976168