diff --git a/node_modules/ace/lib/ace/worker/worker.js b/node_modules/ace/lib/ace/worker/worker.js index 65f690c3..28fc0fe2 100644 --- a/node_modules/ace/lib/ace/worker/worker.js +++ b/node_modules/ace/lib/ace/worker/worker.js @@ -48,7 +48,7 @@ window.normalizeModule = function(parentId, moduleName) { return moduleName; }; -window.require = function(parentId, id) { +window.require = function require(parentId, id) { if (!id) { id = parentId; parentId = null; @@ -66,12 +66,11 @@ window.require = function(parentId, id) { } return module.exports; } - - var chunks = id.split("/"); + if (!window.require.tlns) return console.log("unable to load " + id); - chunks[0] = window.require.tlns[chunks[0]] || chunks[0]; - var path = chunks.join("/"); + + var path = resolveModuleId(id, window.require.tlns); if (path.slice(-3) != ".js") path += ".js"; window.require.id = id; @@ -79,6 +78,24 @@ window.require = function(parentId, id) { importScripts(path); return window.require(parentId, id); }; +function resolveModuleId(id, paths) { + var testPath = id, tail = ""; + while (testPath) { + var alias = paths[testPath]; + if (typeof alias == "string") { + return alias + tail; + } else if (alias) { + return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name); + } else if (alias === false) { + return ""; + } + var i = testPath.lastIndexOf("/"); + if (i === -1) break; + tail = testPath.substr(i) + tail; + testPath = testPath.slice(0, i); + } + return id; +} window.require.modules = {}; window.require.tlns = {}; @@ -135,9 +152,10 @@ window.define = function(id, deps, factory) { }; }; window.define.amd = {}; - +require.tlns = {}; window.initBaseUrls = function initBaseUrls(topLevelNamespaces) { - require.tlns = topLevelNamespaces; + for (var i in topLevelNamespaces) + require.tlns[i] = topLevelNamespaces[i]; }; window.initSender = function initSender() { @@ -177,21 +195,23 @@ var sender = window.sender = null; window.onmessage = function(e) { var msg = e.data; - if (msg.command) { + if (msg.event && sender) { + sender._signal(msg.event, msg.data); + } + else if (msg.command) { if (main[msg.command]) main[msg.command].apply(main, msg.args); + else if (window[msg.command]) + window[msg.command].apply(window, msg.args); else throw new Error("Unknown command:" + msg.command); } - else if (msg.init) { - initBaseUrls(msg.tlns); + else if (msg.init) { + window.initBaseUrls(msg.tlns); require("ace/lib/es5-shim"); - sender = window.sender = initSender(); + sender = window.sender = window.initSender(); var clazz = require(msg.module)[msg.classname]; main = window.main = new clazz(sender); } - else if (msg.event && sender) { - sender._signal(msg.event, msg.data); - } }; })(this); \ No newline at end of file diff --git a/node_modules/architect-build/build_support/mini_require.js b/node_modules/architect-build/build_support/mini_require.js index b2075b0c..be4abe69 100644 --- a/node_modules/architect-build/build_support/mini_require.js +++ b/node_modules/architect-build/build_support/mini_require.js @@ -273,6 +273,7 @@ var config = require.config = function(cfg) { }; config.packages = Object.create(null); config.paths = Object.create(null); +config.baseUrl = ""; require.undef = function(module, callback) { module = normalizeName("", module); @@ -310,6 +311,9 @@ require.toUrl = function(moduleName, ext, skipExt) { testPath = testPath.slice(0, i); } + if (skipExt) + return testPath; + var url = moduleName + ext; if (!absRe.test(url)) { url = (config.baseUrl || require.MODULE_LOAD_URL + "/") + url; @@ -342,7 +346,7 @@ var loadScript = function(path, id, callback) { id: id, path: path }); - } + }; }; require.load = function(module) { diff --git a/package.json b/package.json index 4de6ffed..45bfc7e4 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ }, "licenses": [], "c9plugins": { - "c9.ide.language": "#3a8040d0c5", + "c9.ide.language": "#4a23a36945", "c9.ide.language.css": "#ef8a28943e", "c9.ide.language.generic": "#8a3be4533a", "c9.ide.language.html": "#bbe81afed1",