kopia lustrzana https://github.com/c9/core
Fix worker CORS errors with unpacked helper
rodzic
3042e61641
commit
4fdaccd3c8
|
@ -303,9 +303,7 @@ module.exports = function(options) {
|
||||||
{
|
{
|
||||||
packagePath: "plugins/c9.ide.language/language",
|
packagePath: "plugins/c9.ide.language/language",
|
||||||
workspaceDir: workspaceDir,
|
workspaceDir: workspaceDir,
|
||||||
staticPrefix: hosted && !options.packed
|
staticPrefix: staticPrefix,
|
||||||
? options.ideBaseUrl + "/uph" + staticPrefix
|
|
||||||
: staticPrefix,
|
|
||||||
workerPrefix: options.CORSWorkerPrefix // "/static/standalone/worker"
|
workerPrefix: options.CORSWorkerPrefix // "/static/standalone/worker"
|
||||||
},
|
},
|
||||||
"plugins/c9.ide.language/keyhandler",
|
"plugins/c9.ide.language/keyhandler",
|
||||||
|
|
|
@ -49,11 +49,11 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
|
||||||
workerUrl = workerUrl || config.moduleUrl(mod, "worker");
|
workerUrl = workerUrl || config.moduleUrl(mod, "worker");
|
||||||
} else {
|
} else {
|
||||||
var normalizePath = this.$normalizePath;
|
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 = {};
|
var tlns = {};
|
||||||
topLevelNamespaces.forEach(function(ns) {
|
topLevelNamespaces.forEach(function(ns) {
|
||||||
tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
|
tlns[ns] = normalizePath(require.toUrl(ns, null, "_", true).replace(/(\.js)?(\?.*)?$/, ""));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,8 +152,8 @@ var activateModule = function(name) {
|
||||||
var req = function(path, callback) {
|
var req = function(path, callback) {
|
||||||
return _require(name, path, callback);
|
return _require(name, path, callback);
|
||||||
};
|
};
|
||||||
req.toUrl = function(namePlusExt) {
|
req.toUrl = function(namePlusExt, _1, _2, skipBalancers) {
|
||||||
return require.toUrl(normalizeName(name, namePlusExt));
|
return require.toUrl(normalizeName(name, namePlusExt), null, null, skipBalancers);
|
||||||
};
|
};
|
||||||
req.config = require.config;
|
req.config = require.config;
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ function undefAll(module, hash) {
|
||||||
|
|
||||||
require.MODULE_LOAD_URL = MODULE_LOAD_URL;
|
require.MODULE_LOAD_URL = MODULE_LOAD_URL;
|
||||||
|
|
||||||
require.toUrl = function(moduleName, ext, skipExt) {
|
require.toUrl = function(moduleName, ext, skipExt, skipBalancers) {
|
||||||
var absRe = /^([\w\+\.\-]+:|\/)/;
|
var absRe = /^([\w\+\.\-]+:|\/)/;
|
||||||
var index = moduleName.indexOf("!");
|
var index = moduleName.indexOf("!");
|
||||||
if (index !== -1 || !ext || /^\/|\.js$/.test(moduleName))
|
if (index !== -1 || !ext || /^\/|\.js$/.test(moduleName))
|
||||||
|
@ -347,7 +347,7 @@ require.toUrl = function(moduleName, ext, skipExt) {
|
||||||
if (!absRe.test(url)) {
|
if (!absRe.test(url)) {
|
||||||
url = (config.baseUrl || require.MODULE_LOAD_URL + "/") + 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;
|
var n = Math.abs(hashCode(url)) % config.baseUrlLoadBalancers.length;
|
||||||
url = config.baseUrlLoadBalancers[n] + url;
|
url = config.baseUrlLoadBalancers[n] + url;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue