Reduce reliance on METADATA
parent
6047f09f96
commit
a7179b0bef
@ -1,50 +1,62 @@
|
|||||||
|
(function() {
|
||||||
|
|
||||||
function loadDevEditor() {
|
self.loadDevEditor = function() {
|
||||||
return (getQueryStringValue('editor') === 'dev');
|
return (getQueryStringValue('editor') === 'dev');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQueryStringValue (key) {
|
function getQueryStringValue (key) {
|
||||||
return unescape(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
|
return unescape(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
(function() {
|
function resolveCorePath(core) {
|
||||||
// Resolve paths
|
if (loadDevEditor()) {
|
||||||
// should run the editor and/or plugins from source? (or from the node module)
|
return core.srcPath;
|
||||||
if (loadDevEditor()) {
|
} else {
|
||||||
METADATA.CORE.path = METADATA.CORE.srcPath;
|
return '/monaco-editor/' + core.path;
|
||||||
} else {
|
}
|
||||||
METADATA.CORE.path = '/monaco-editor/' + METADATA.CORE.path;
|
|
||||||
}
|
}
|
||||||
METADATA.PLUGINS.forEach(function(plugin) {
|
|
||||||
// should run the editor plugins from source? (or from node modules)
|
function resolvePluginPath(plugin) {
|
||||||
if (plugin.srcPath && getQueryStringValue(plugin.name) === 'dev') {
|
if (plugin.srcPath && getQueryStringValue(plugin.name) === 'dev') {
|
||||||
plugin.path = plugin.srcPath;
|
return plugin.srcPath;
|
||||||
} else {
|
} else {
|
||||||
plugin.path = '/monaco-editor/' + plugin.path;
|
return '/monaco-editor/' + plugin.path;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
})();
|
|
||||||
|
|
||||||
function loadEditor(callback, PATH_PREFIX) {
|
self.RESOLVED_CORE_PATH = resolveCorePath(METADATA.CORE);
|
||||||
PATH_PREFIX = PATH_PREFIX || '';
|
var RESOLVED_PLUGINS = METADATA.PLUGINS.map(function(plugin) {
|
||||||
var pathsConfig = {};
|
return {
|
||||||
METADATA.PLUGINS.forEach(function(plugin) {
|
name: plugin.name,
|
||||||
pathsConfig[plugin.modulePrefix] = PATH_PREFIX + plugin.path;
|
contrib: plugin.contrib,
|
||||||
|
modulePrefix: plugin.modulePrefix,
|
||||||
|
path: resolvePluginPath(plugin)
|
||||||
|
};
|
||||||
});
|
});
|
||||||
pathsConfig['vs'] = PATH_PREFIX + METADATA.CORE.path;
|
self.METADATA = null;
|
||||||
|
|
||||||
// console.log(JSON.stringify(pathsConfig, null, '\t'));
|
self.loadEditor = function(callback, PATH_PREFIX) {
|
||||||
|
PATH_PREFIX = PATH_PREFIX || '';
|
||||||
|
var pathsConfig = {};
|
||||||
|
RESOLVED_PLUGINS.forEach(function(plugin) {
|
||||||
|
pathsConfig[plugin.modulePrefix] = PATH_PREFIX + plugin.path;
|
||||||
|
});
|
||||||
|
pathsConfig['vs'] = PATH_PREFIX + RESOLVED_CORE_PATH;
|
||||||
|
|
||||||
require.config({
|
console.log('LOADER PATH CONFIGURATION: ');
|
||||||
paths: pathsConfig
|
console.log(JSON.stringify(pathsConfig, null, '\t'));
|
||||||
});
|
|
||||||
|
|
||||||
require(['vs/editor/editor.main'], function() {
|
require.config({
|
||||||
// At this point we've loaded the monaco-editor-core
|
paths: pathsConfig
|
||||||
require(METADATA.PLUGINS.map(function(plugin) { return plugin.contrib; }), function() {
|
|
||||||
// At this point we've loaded all the plugins
|
|
||||||
callback();
|
|
||||||
// require(['./index'], function() {});
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
require(['vs/editor/editor.main'], function() {
|
||||||
|
// At this point we've loaded the monaco-editor-core
|
||||||
|
require(RESOLVED_PLUGINS.map(function(plugin) { return plugin.contrib; }), function() {
|
||||||
|
// At this point we've loaded all the plugins
|
||||||
|
callback();
|
||||||
|
// require(['./index'], function() {});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
Loading…
Reference in New Issue