Fix worker CORS errors with unpacked helper

pull/223/head
Lennart Kats 2015-11-17 12:00:39 +00:00
rodzic 3042e61641
commit 4fdaccd3c8
3 zmienionych plików z 7 dodań i 9 usunięć

Wyświetl plik

@ -303,9 +303,7 @@ module.exports = function(options) {
{
packagePath: "plugins/c9.ide.language/language",
workspaceDir: workspaceDir,
staticPrefix: hosted && !options.packed
? options.ideBaseUrl + "/uph" + staticPrefix
: staticPrefix,
staticPrefix: staticPrefix,
workerPrefix: options.CORSWorkerPrefix // "/static/standalone/worker"
},
"plugins/c9.ide.language/keyhandler",

Wyświetl plik

@ -49,11 +49,11 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
workerUrl = workerUrl || config.moduleUrl(mod, "worker");
} else {
var normalizePath = this.$normalizePath;
workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_", true));
var tlns = {};
topLevelNamespaces.forEach(function(ns) {
tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
tlns[ns] = normalizePath(require.toUrl(ns, null, "_", true).replace(/(\.js)?(\?.*)?$/, ""));
});
}

Wyświetl plik

@ -152,8 +152,8 @@ var activateModule = function(name) {
var req = function(path, callback) {
return _require(name, path, callback);
};
req.toUrl = function(namePlusExt) {
return require.toUrl(normalizeName(name, namePlusExt));
req.toUrl = function(namePlusExt, _1, _2, skipBalancers) {
return require.toUrl(normalizeName(name, namePlusExt), null, null, skipBalancers);
};
req.config = require.config;
@ -315,7 +315,7 @@ function undefAll(module, hash) {
require.MODULE_LOAD_URL = MODULE_LOAD_URL;
require.toUrl = function(moduleName, ext, skipExt) {
require.toUrl = function(moduleName, ext, skipExt, skipBalancers) {
var absRe = /^([\w\+\.\-]+:|\/)/;
var index = moduleName.indexOf("!");
if (index !== -1 || !ext || /^\/|\.js$/.test(moduleName))
@ -347,7 +347,7 @@ require.toUrl = function(moduleName, ext, skipExt) {
if (!absRe.test(url)) {
url = (config.baseUrl || require.MODULE_LOAD_URL + "/") + url;
}
if (url[0] === "/" && config.baseUrlLoadBalancers) {
if (url[0] === "/" && config.baseUrlLoadBalancers && !skipBalancers) {
var n = Math.abs(hashCode(url)) % config.baseUrlLoadBalancers.length;
url = config.baseUrlLoadBalancers[n] + url;
}