respond-framework
Version:
create as fast you think
32 lines (30 loc) • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createBranches;
var _reserved = require("./reserved.js");
var _constants = require("../helpers/constants.js");
var _sliceBranch = require("./helpers/sliceBranch.js");
var replayToolsModule = require("../modules/replayTools/index.js");
function createBranches(mod, focusedBranch, branchNames = [], b = '', isReplayTools) {
mod[_reserved._module] = true;
mod.moduleKeys = [];
mod.branchAbsolute = b;
mod.branch = (0, _sliceBranch.stripBranchWithUnknownFallback)(focusedBranch, b); // ancestor branches of focused branch will be prefixed with '.unknown'
if (!isReplayTools) branchNames.push(b);
Object.keys(mod).forEach(k => {
const v = mod[k];
const isMod = v?.plugins && v.components && v.id;
if (!isMod) return;
mod.moduleKeys.push(k);
createBranches(v, focusedBranch, branchNames, b ? `${b}.${k}` : k);
});
if (b === focusedBranch) {
// put replayTools as child of focused branch
mod.replayTools = replayToolsModule;
mod.moduleKeys.push('replayTools');
createBranches(replayToolsModule, focusedBranch, branchNames, (0, _sliceBranch.prepend)(focusedBranch, 'replayTools'), true);
}
return branchNames;
}