d11 theme
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

69 lines
2.6 KiB

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizePathForDictDef = exports.normalizePathForDictDefs = exports.filterDictDefsToLoad = void 0;
const path = __importStar(require("path"));
const resolveFile_1 = require("../util/resolveFile");
function filterDictDefsToLoad(dictIds, defs) {
// Process the dictIds in order, if it starts with a '!', remove it from the set.
const dictIdSet = dictIds
.map((id) => id.trim())
.filter((id) => !!id)
.reduce((dictSet, id) => {
if (id[0] === '!') {
dictSet.delete(id.slice(1));
}
else {
dictSet.add(id);
}
return dictSet;
}, new Set());
const activeDefs = defs
.filter(({ name }) => dictIdSet.has(name))
.map((def) => ({ ...def, path: getFullPathName(def) }))
// Remove any empty paths.
.filter((def) => !!def.path)
.map((def) => [def.name, def]);
return [...new Map(activeDefs)];
}
exports.filterDictDefsToLoad = filterDictDefsToLoad;
function getFullPathName(def) {
const { path: filePath = '', file = '' } = def;
if (!filePath && !file) {
return '';
}
return path.join(filePath, file);
}
function normalizePathForDictDefs(defs, defaultPath) {
return defs.map((def) => normalizePathForDictDef(def, defaultPath));
}
exports.normalizePathForDictDefs = normalizePathForDictDefs;
function normalizePathForDictDef(def, defaultPath) {
const { path: relPath = '', file = '', ...rest } = def;
const filePath = path.join(relPath, file);
const r = resolveFile_1.resolveFile(filePath, defaultPath);
return {
...rest,
path: r.filename,
};
}
exports.normalizePathForDictDef = normalizePathForDictDef;
//# sourceMappingURL=DictionarySettings.js.map