nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions

View File

@@ -10,93 +10,107 @@ const getFunctionExpression = require("./getFunctionExpression");
module.exports = class RequireEnsureDependenciesBlockParserPlugin {
apply(parser) {
parser.plugin("call require.ensure", expr => {
let chunkName = null;
let chunkNameRange = null;
let errorExpressionArg = null;
let errorExpression = null;
switch(expr.arguments.length) {
case 4:
{
parser.hooks.call
.for("require.ensure")
.tap("RequireEnsureDependenciesBlockParserPlugin", expr => {
let chunkName = null;
let chunkNameRange = null;
let errorExpressionArg = null;
let errorExpression = null;
switch (expr.arguments.length) {
case 4: {
const chunkNameExpr = parser.evaluateExpression(expr.arguments[3]);
if(!chunkNameExpr.isString()) return;
if (!chunkNameExpr.isString()) return;
chunkNameRange = chunkNameExpr.range;
chunkName = chunkNameExpr.string;
}
// falls through
case 3:
{
case 3: {
errorExpressionArg = expr.arguments[2];
errorExpression = getFunctionExpression(errorExpressionArg);
if(!errorExpression && !chunkName) {
const chunkNameExpr = parser.evaluateExpression(expr.arguments[2]);
if(!chunkNameExpr.isString()) return;
if (!errorExpression && !chunkName) {
const chunkNameExpr = parser.evaluateExpression(
expr.arguments[2]
);
if (!chunkNameExpr.isString()) return;
chunkNameRange = chunkNameExpr.range;
chunkName = chunkNameExpr.string;
}
}
// falls through
case 2:
{
const dependenciesExpr = parser.evaluateExpression(expr.arguments[0]);
const dependenciesItems = dependenciesExpr.isArray() ? dependenciesExpr.items : [dependenciesExpr];
case 2: {
const dependenciesExpr = parser.evaluateExpression(
expr.arguments[0]
);
const dependenciesItems = dependenciesExpr.isArray()
? dependenciesExpr.items
: [dependenciesExpr];
const successExpressionArg = expr.arguments[1];
const successExpression = getFunctionExpression(successExpressionArg);
const successExpression = getFunctionExpression(
successExpressionArg
);
if(successExpression) {
if (successExpression) {
parser.walkExpressions(successExpression.expressions);
}
if(errorExpression) {
if (errorExpression) {
parser.walkExpressions(errorExpression.expressions);
}
const dep = new RequireEnsureDependenciesBlock(expr,
const dep = new RequireEnsureDependenciesBlock(
expr,
successExpression ? successExpression.fn : successExpressionArg,
errorExpression ? errorExpression.fn : errorExpressionArg,
chunkName, chunkNameRange, parser.state.module, expr.loc);
chunkName,
chunkNameRange,
parser.state.module,
expr.loc
);
const old = parser.state.current;
parser.state.current = dep;
try {
let failed = false;
parser.inScope([], () => {
dependenciesItems.forEach(ee => {
if(ee.isString()) {
const edep = new RequireEnsureItemDependency(ee.string, ee.range);
for (const ee of dependenciesItems) {
if (ee.isString()) {
const edep = new RequireEnsureItemDependency(ee.string);
edep.loc = dep.loc;
dep.addDependency(edep);
} else {
failed = true;
}
});
}
});
if(failed) {
if (failed) {
return;
}
if(successExpression) {
if(successExpression.fn.body.type === "BlockStatement")
if (successExpression) {
if (successExpression.fn.body.type === "BlockStatement") {
parser.walkStatement(successExpression.fn.body);
else
} else {
parser.walkExpression(successExpression.fn.body);
}
}
old.addBlock(dep);
} finally {
parser.state.current = old;
}
if(!successExpression) {
if (!successExpression) {
parser.walkExpression(successExpressionArg);
}
if(errorExpression) {
if(errorExpression.fn.body.type === "BlockStatement")
if (errorExpression) {
if (errorExpression.fn.body.type === "BlockStatement") {
parser.walkStatement(errorExpression.fn.body);
else
} else {
parser.walkExpression(errorExpression.fn.body);
} else if(errorExpressionArg) {
}
} else if (errorExpressionArg) {
parser.walkExpression(errorExpressionArg);
}
return true;
}
}
});
}
});
}
};