Run prettier on the loader
This commit is contained in:
parent
cc56f226b8
commit
9dcdbcfd5b
|
@ -1,18 +1,21 @@
|
||||||
var define, requirejs;
|
var define, requirejs;
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var MOVED_MODULES = {
|
var MOVED_MODULES = {
|
||||||
"discourse/views/list/post-count-or-badges": "discourse/raw-views/list/post-count-or-badges",
|
"discourse/views/list/post-count-or-badges":
|
||||||
"discourse/views/list/posts-count-column" : "discourse/raw-views/list/posts-count-column",
|
"discourse/raw-views/list/post-count-or-badges",
|
||||||
"discourse/views/list/visited-line" : "discourse/raw-views/list/visited-line",
|
"discourse/views/list/posts-count-column":
|
||||||
"discourse/views/topic-list-header-column" : "discourse/raw-views/topic-list-header-column",
|
"discourse/raw-views/list/posts-count-column",
|
||||||
"discourse/views/topic-status" : "discourse/raw-views/topic-status"
|
"discourse/views/list/visited-line":
|
||||||
|
"discourse/raw-views/list/visited-line",
|
||||||
|
"discourse/views/topic-list-header-column":
|
||||||
|
"discourse/raw-views/topic-list-header-column",
|
||||||
|
"discourse/views/topic-status": "discourse/raw-views/topic-status"
|
||||||
};
|
};
|
||||||
|
|
||||||
var _isArray;
|
var _isArray;
|
||||||
if (!Array.isArray) {
|
if (!Array.isArray) {
|
||||||
_isArray = function (x) {
|
_isArray = function(x) {
|
||||||
return Object.prototype.toString.call(x) === "[object Array]";
|
return Object.prototype.toString.call(x) === "[object Array]";
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
@ -34,28 +37,34 @@ var define, requirejs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsupportedModule(length) {
|
function unsupportedModule(length) {
|
||||||
throw new Error("an unsupported module was defined, expected `define(name, deps, module)` instead got: `" + length + "` arguments to define`");
|
throw new Error(
|
||||||
|
"an unsupported module was defined, expected `define(name, deps, module)` instead got: `" +
|
||||||
|
length +
|
||||||
|
"` arguments to define`"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultDeps = ['require', 'exports', 'module'];
|
var defaultDeps = ["require", "exports", "module"];
|
||||||
|
|
||||||
function Module(name, deps, callback, exports) {
|
function Module(name, deps, callback, exports) {
|
||||||
this.id = uuid++;
|
this.id = uuid++;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.deps = !deps.length && callback.length ? defaultDeps : deps;
|
this.deps = !deps.length && callback.length ? defaultDeps : deps;
|
||||||
this.exports = exports || { };
|
this.exports = exports || {};
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
this.state = undefined;
|
this.state = undefined;
|
||||||
this._require = undefined;
|
this._require = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Module.prototype.makeRequire = function() {
|
Module.prototype.makeRequire = function() {
|
||||||
var name = this.name;
|
var name = this.name;
|
||||||
|
|
||||||
return this._require || (this._require = function(dep) {
|
return (
|
||||||
|
this._require ||
|
||||||
|
(this._require = function(dep) {
|
||||||
return requirejs(resolve(dep, name));
|
return requirejs(resolve(dep, name));
|
||||||
});
|
})
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
define = function(name, deps, callback) {
|
define = function(name, deps, callback) {
|
||||||
|
@ -74,7 +83,7 @@ var define, requirejs;
|
||||||
// we don't support all of AMD
|
// we don't support all of AMD
|
||||||
// define.amd = {};
|
// define.amd = {};
|
||||||
// we will support petals...
|
// we will support petals...
|
||||||
define.petal = { };
|
define.petal = {};
|
||||||
|
|
||||||
function Alias(path) {
|
function Alias(path) {
|
||||||
this.name = path;
|
this.name = path;
|
||||||
|
@ -91,15 +100,15 @@ var define, requirejs;
|
||||||
var dep;
|
var dep;
|
||||||
// TODO: new Module
|
// TODO: new Module
|
||||||
// TODO: seen refactor
|
// TODO: seen refactor
|
||||||
var module = { };
|
var module = {};
|
||||||
|
|
||||||
for (var i = 0, l = length; i < l; i++) {
|
for (var i = 0, l = length; i < l; i++) {
|
||||||
dep = deps[i];
|
dep = deps[i];
|
||||||
if (dep === 'exports') {
|
if (dep === "exports") {
|
||||||
module.exports = reified[i] = rseen;
|
module.exports = reified[i] = rseen;
|
||||||
} else if (dep === 'require') {
|
} else if (dep === "require") {
|
||||||
reified[i] = mod.makeRequire();
|
reified[i] = mod.makeRequire();
|
||||||
} else if (dep === 'module') {
|
} else if (dep === "module") {
|
||||||
mod.exports = rseen;
|
mod.exports = rseen;
|
||||||
module = reified[i] = mod;
|
module = reified[i] = mod;
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,28 +123,29 @@ var define, requirejs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function requireFrom(name, origin) {
|
function requireFrom(name, origin) {
|
||||||
|
|
||||||
var mod = registry[name];
|
var mod = registry[name];
|
||||||
if (!mod) {
|
if (!mod) {
|
||||||
var moved = MOVED_MODULES[name];
|
var moved = MOVED_MODULES[name];
|
||||||
if (moved) {
|
if (moved) {
|
||||||
console.warn("DEPRECATION: `" + name + "` was moved to `" + moved + "`"); // eslint-disable-line no-console
|
var msg = "DEPRECATION: `" + name + "` was moved to `" + moved + "`";
|
||||||
|
console.warn(msg); // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
mod = registry[moved];
|
mod = registry[moved];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mod) {
|
if (!mod) {
|
||||||
throw new Error('Could not find module `' + name + '` imported from `' + origin + '`');
|
throw new Error(
|
||||||
|
"Could not find module `" + name + "` imported from `" + origin + "`"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return requirejs(name);
|
return requirejs(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function missingModule(name) {
|
function missingModule(name) {
|
||||||
throw new Error('Could not find module ' + name);
|
throw new Error("Could not find module " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
requirejs = require = function(name) {
|
requirejs = require = function(name) {
|
||||||
|
|
||||||
if (MOVED_MODULES[name]) {
|
if (MOVED_MODULES[name]) {
|
||||||
name = MOVED_MODULES[name];
|
name = MOVED_MODULES[name];
|
||||||
}
|
}
|
||||||
|
@ -146,10 +156,11 @@ var define, requirejs;
|
||||||
mod = registry[mod.callback.name];
|
mod = registry[mod.callback.name];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mod) { missingModule(name); }
|
if (!mod) {
|
||||||
|
missingModule(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (mod.state !== FAILED &&
|
if (mod.state !== FAILED && seen.hasOwnProperty(name)) {
|
||||||
seen.hasOwnProperty(name)) {
|
|
||||||
return seen[name];
|
return seen[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,17 +168,20 @@ var define, requirejs;
|
||||||
var module;
|
var module;
|
||||||
var loaded = false;
|
var loaded = false;
|
||||||
|
|
||||||
seen[name] = { }; // placeholder for run-time cycles
|
seen[name] = {}; // placeholder for run-time cycles
|
||||||
|
|
||||||
tryFinally(function() {
|
tryFinally(
|
||||||
|
function() {
|
||||||
reified = reify(mod, name, seen[name]);
|
reified = reify(mod, name, seen[name]);
|
||||||
module = mod.callback.apply(this, reified.deps);
|
module = mod.callback.apply(this, reified.deps);
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}, function() {
|
},
|
||||||
|
function() {
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
mod.state = FAILED;
|
mod.state = FAILED;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
var obj;
|
var obj;
|
||||||
if (module === undefined && reified.module.exports) {
|
if (module === undefined && reified.module.exports) {
|
||||||
|
@ -176,10 +190,12 @@ var define, requirejs;
|
||||||
obj = seen[name] = module;
|
obj = seen[name] = module;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj !== null &&
|
if (
|
||||||
(typeof obj === 'object' || typeof obj === 'function') &&
|
obj !== null &&
|
||||||
obj['default'] === undefined) {
|
(typeof obj === "object" || typeof obj === "function") &&
|
||||||
obj['default'] = obj;
|
obj["default"] === undefined
|
||||||
|
) {
|
||||||
|
obj["default"] = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (seen[name] = obj);
|
return (seen[name] = obj);
|
||||||
|
@ -187,26 +203,30 @@ var define, requirejs;
|
||||||
window.requireModule = requirejs;
|
window.requireModule = requirejs;
|
||||||
|
|
||||||
function resolve(child, name) {
|
function resolve(child, name) {
|
||||||
if (child.charAt(0) !== '.') { return child; }
|
if (child.charAt(0) !== ".") {
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
var parts = child.split('/');
|
var parts = child.split("/");
|
||||||
var nameParts = name.split('/');
|
var nameParts = name.split("/");
|
||||||
var parentBase = nameParts.slice(0, -1);
|
var parentBase = nameParts.slice(0, -1);
|
||||||
|
|
||||||
for (var i = 0, l = parts.length; i < l; i++) {
|
for (var i = 0, l = parts.length; i < l; i++) {
|
||||||
var part = parts[i];
|
var part = parts[i];
|
||||||
|
|
||||||
if (part === '..') {
|
if (part === "..") {
|
||||||
if (parentBase.length === 0) {
|
if (parentBase.length === 0) {
|
||||||
throw new Error('Cannot access parent module of root');
|
throw new Error("Cannot access parent module of root");
|
||||||
}
|
}
|
||||||
parentBase.pop();
|
parentBase.pop();
|
||||||
} else if (part === '.') {
|
} else if (part === ".") {
|
||||||
continue;
|
continue;
|
||||||
} else { parentBase.push(part); }
|
} else {
|
||||||
|
parentBase.push(part);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parentBase.join('/');
|
return parentBase.join("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
requirejs.entries = requirejs._eak_seen = registry;
|
requirejs.entries = requirejs._eak_seen = registry;
|
||||||
|
|
Loading…
Reference in New Issue