make uses of staticPrefix more consistent

This commit is contained in:
nightwing 2016-12-12 02:41:23 +04:00
parent bcdfb80af5
commit 4be6aa745c
8 changed files with 52 additions and 110 deletions

View File

@ -36,6 +36,28 @@ var net = require("../lib/net");
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var config = require("../config");
function $workerBlob(workerUrl) {
// workerUrl can be protocol relative
// importScripts only takes fully qualified urls
var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
try {
return new Blob([script], {"type": "application/javascript"});
} catch (e) { // Backwards-compatibility
var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
var blobBuilder = new BlobBuilder();
blobBuilder.append(script);
return blobBuilder.getBlob("application/javascript");
}
}
function createWorker(workerUrl) {
var blob = $workerBlob(workerUrl);
var URL = window.URL || window.webkitURL;
var blobURL = URL.createObjectURL(blob);
// calling URL.revokeObjectURL before worker is terminated breaks it on IE Edge
return new Worker(blobURL);
}
var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl, importScripts) {
this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
this.changeListener = this.changeListener.bind(this);
@ -58,23 +80,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl, impor
});
}
try {
this.$worker = new Worker(workerUrl);
} catch(e) {
if (e instanceof window.DOMException) {
// Likely same origin problem. Use importScripts from a shim Worker
var blob = this.$workerBlob(workerUrl);
var URL = window.URL || window.webkitURL;
var blobURL = URL.createObjectURL(blob);
this.$worker = new Worker(blobURL);
setTimeout(function() { // IE EDGE needs a timeout here
URL.revokeObjectURL(blobURL);
});
} else {
throw e;
}
}
this.$worker = createWorker(workerUrl);
if (importScripts) {
this.send("importScripts", importScripts);
}
@ -189,20 +195,6 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl, impor
this.emit("change", {data: q});
};
this.$workerBlob = function(workerUrl) {
// workerUrl can be protocol relative
// importScripts only takes fully qualified urls
var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
try {
return new Blob([script], {"type": "application/javascript"});
} catch (e) { // Backwards-compatibility
var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
var blobBuilder = new BlobBuilder();
blobBuilder.append(script);
return blobBuilder.getBlob("application/javascript");
}
};
}).call(WorkerClient.prototype);
@ -260,5 +252,7 @@ UIWorkerClient.prototype = WorkerClient.prototype;
exports.UIWorkerClient = UIWorkerClient;
exports.WorkerClient = WorkerClient;
exports.createWorker = createWorker;
});

View File

@ -14,7 +14,7 @@ function getInlineDeps(fn) {
fn.toString().replace(commentRegExp, "")
.replace(cjsRequireRegExp, function (match, dep, index, str) {
var i = index;
while (str.charCodeAt(i-=1) <= 32) {}
while (str.charCodeAt(i -= 1) <= 32) {}
if (str.charAt(i) !== ".")
deps.push(dep);
});
@ -293,10 +293,15 @@ var config = require.config = function(cfg) {
if (cfg.baseUrlLoadBalancers)
config.baseUrlLoadBalancers = cfg.baseUrlLoadBalancers;
};
config.packages = Object.create(null);
config.paths = Object.create(null);
config.baseUrl = "";
config.useCache = false;
require.resetConfig = function() {
config.packages = Object.create(null);
config.paths = Object.create(null);
config.baseUrl = "";
config.useCache = false;
};
require.resetConfig();
define.undef = require.undef = function(module, recursive) {
if (recursive) {
@ -503,7 +508,9 @@ function checkCache() {
ideCache = ideCache_;
return ideCache.keys();
}).then(function(keys) {
baseUrl = host + config.baseUrl;
baseUrl = config.baseUrl;
if (baseUrl[0] == "/")
baseUrl = host + baseUrl;
var val = keys.map(function(r) {
var url = r.url;
if (url.startsWith(baseUrl))
@ -520,7 +527,7 @@ function checkCache() {
var checked = 0;
var buffer = "";
var toDelete = [];
post("/static/__check__", val, function(t) {
post(baseUrl + "__check__", val, function(t) {
var e = t.slice(checked);
checked = t.length;
var parts = (buffer + e).split("\n");

View File

@ -15,7 +15,7 @@ function compress(sources, opts) {
return literals.push(pkg.source);
}
if (pkg.file) console.log("Adding '" + pkg.file + "'.");
// if (pkg.file) console.log("Adding '" + pkg.file + "'.");
toplevel = UglifyJS.parse(pkg.source, {
filename: (pkg.file || pkg.id).replace(new RegExp("^" + opts.basepath + "/"), ""), //@todo remove prefix

View File

@ -329,6 +329,8 @@ function resolveModulePath(id, pathMap) {
tail = testPath.substr(i) + tail;
testPath = testPath.slice(0, i);
}
if (!testPath && pathMap["/"])
return pathMap["/"] + tail;
return id;
}

View File

@ -56,72 +56,5 @@
"architect-build",
"msgpack-js",
"c9"
],
"c9plugins": {
"c9.ide.language": "#9843fc4875",
"c9.ide.language.core": "#208159eda7",
"c9.ide.language.css": "#5827caacda",
"c9.ide.language.generic": "#809e6994e6",
"c9.ide.language.html": "#ae00c111da",
"c9.ide.language.html.diff": "#33ac0f78aa",
"c9.ide.language.javascript": "#6f86fc7900",
"c9.ide.language.javascript.immediate": "#efc3518d0a",
"c9.ide.language.javascript.eslint": "#004c86f8ef",
"c9.ide.language.javascript.tern": "#cc569cfa6f",
"c9.ide.language.javascript.infer": "#d9f6dc5e51",
"c9.ide.language.jsonalyzer": "#6d0ed9fbf6",
"c9.ide.language.codeintel": "#435e084066",
"c9.ide.collab": "#5a2071f4ea",
"c9.ide.local": "#976ad9fca0",
"c9.ide.find": "#5c1d1ea078",
"c9.ide.find.infiles": "#d4762d1382",
"c9.ide.find.replace": "#1f96b87bf7",
"c9.ide.run.debug": "#91bc33714f",
"c9.automate": "#1c6006046e",
"c9.ide.ace.emmet": "#06791647c5",
"c9.ide.ace.gotoline": "#636d426035",
"c9.ide.ace.keymaps": "#832302482c",
"c9.ide.ace.repl": "#623561ecff",
"c9.ide.ace.split": "#d2143d8336",
"c9.ide.ace.statusbar": "#102340271c",
"c9.ide.ace.stripws": "#0aaa293283",
"c9.ide.behaviors": "#cc04e94c62",
"c9.ide.closeconfirmation": "#6b758eb957",
"c9.ide.configuration": "#5d8c381035",
"c9.ide.dialog.wizard": "#c8200c6ad1",
"c9.ide.fontawesome": "#96cb342a4a",
"c9.ide.format": "#660cf065ac",
"c9.ide.help.support": "#42d843e0db",
"c9.ide.imgeditor": "#353308ec1b",
"c9.ide.immediate": "#909e6f0bd1",
"c9.ide.installer": "#5f8f75eb2c",
"c9.ide.language.python": "#102398b335",
"c9.ide.language.go": "#e018761e24",
"c9.ide.navigate": "#992381bbf6",
"c9.ide.newresource": "#8ce79bb66c",
"c9.ide.openfiles": "#8ab1e2c85f",
"c9.ide.preview": "#a337636943",
"c9.ide.preview.browser": "#339cc3c10d",
"c9.ide.preview.markdown": "#df4b12c34c",
"c9.ide.pubsub": "#2accad6c0f",
"c9.ide.readonly": "#59bd0c4961",
"c9.ide.recentfiles": "#e8a52f2015",
"c9.ide.remote": "#14f717a0d5",
"c9.ide.processlist": "#99111d40fd",
"c9.ide.run": "#9dfbcebf81",
"c9.ide.run.build": "#652cd18587",
"c9.ide.run.debug.xdebug": "#def07a584b",
"c9.ide.run.debug.ikpdb": "#a223b727e0",
"c9.ide.save": "#9b06b29d7e",
"c9.ide.scm": "#a2dd947ed5",
"c9.ide.terminal.monitor": "#9dfda63972",
"c9.ide.test": "#4a56c01f66",
"c9.ide.test.mocha": "#ceace59aaf",
"c9.ide.theme.flat": "#6f9382edeb",
"c9.ide.threewaymerge": "#7a3a0dd1ad",
"c9.ide.undo": "#0e47e11192",
"c9.ide.upload": "#7ceff1a51d",
"c9.ide.welcome": "#b352446b17",
"c9.ide.guide": "#4249f58769"
}
]
}

View File

@ -17,6 +17,8 @@ define(function(require, exports, module) {
var showError = imports["dialog.error"].show;
var prefs = imports.preferences;
var createWorker = require("ace/worker/worker_client").createWorker;
/***** Initialization *****/
var plugin = new Plugin("Ajax.org", main.consumes);
@ -521,7 +523,7 @@ define(function(require, exports, module) {
hash.counter = 0;
function hash(data, callback) {
if (!worker) {
worker = new Worker('/static/lib/rusha/rusha.min.js');
worker = createWorker((options.staticPrefix || "/static") + "/lib/rusha/rusha.min.js");
worker.addEventListener("message", function(e) {
// @todo security?

View File

@ -1,12 +1,11 @@
define(function(require, exports, module) {
main.consumes = ["Plugin", "http", "ui", "settings"];
main.consumes = ["Plugin", "ui", "settings"];
main.provides = ["layout.preload"];
return main;
function main(options, imports, register) {
var settings = imports.settings;
var Plugin = imports.Plugin;
var http = imports.http;
var ui = imports.ui;
var async = require("async");

View File

@ -132,6 +132,11 @@ define(function(require, exports, module) {
);
}
statics.addStatics([{
path: __dirname + "/../../configs/ide",
mount: "/configs/ide"
}]);
statics.addStatics([{
path: __dirname + "/www",
mount: "/"