UNPKG

@hadss/hmrouter-plugin

Version:

HMRouter Compiler Plugin

64 lines (63 loc) 3.15 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.HMRouterPluginConfig = void 0; const path_1 = __importDefault(require("path")); const framework_1 = require("../../framework"); const constants_1 = require("../constants"); class HMRouterPluginConfig { constructor(moduleName, modulePath, configDir, param) { this.moduleName = moduleName; this.modulePath = modulePath; this.configDir = configDir; this.scanDir = param.scanDir ? [...new Set(param.scanDir)] : []; this.routerMapDir = param.routerMapDir || ''; this.builderDir = param.builderDir || ''; this.defaultPageTemplate = param.defaultPageTemplate || ''; this.customPageTemplate = param.customPageTemplate || []; this.saveGeneratedFile = !!param.saveGeneratedFile; this.autoObfuscation = !!param.autoObfuscation; } getScanPath(dir) { return framework_1.PluginFileUtil.pathResolve(this.modulePath, dir); } getRelativeSourcePath(filePath) { return path_1.default.relative(this.modulePath, filePath); } getRelativeBuilderPath(filePath) { return path_1.default.relative(this.builderDir, filePath); } getGeneratedFilePath(generatorViewName) { return framework_1.PluginFileUtil.pathResolve(this.modulePath, this.builderDir, generatorViewName + constants_1.FilePathConstants.ETS_SUFFIX); } getBuilderDir() { return framework_1.PluginFileUtil.pathResolve(this.modulePath, this.builderDir); } getBuilderFilePath(generatorViewName) { return path_1.default.join(this.builderDir, generatorViewName + constants_1.FilePathConstants.ETS_SUFFIX); } getRouterMapDir() { return framework_1.PluginFileUtil.pathResolve(this.modulePath, this.routerMapDir, constants_1.RouterMapConstants.ROUTER_MAP_NAME); } getModuleRouterMapFilePath(routerMapFileName) { return framework_1.PluginFileUtil.pathResolve(this.modulePath, this.routerMapDir, routerMapFileName + constants_1.FilePathConstants.JSON_SUFFIX); } getRawFilePath() { return framework_1.PluginFileUtil.pathResolve(this.modulePath, constants_1.FilePathConstants.RAWFILE_DIR); } getDefaultTplFilePath() { if (path_1.default.isAbsolute(this.defaultPageTemplate) && framework_1.PluginFileUtil.exist(this.defaultPageTemplate)) { return this.defaultPageTemplate; } return framework_1.PluginFileUtil.pathResolve(__dirname, constants_1.FilePathConstants.PARENT_DELIMITER.repeat(3) + constants_1.TemplateConstants.VIEW_BUILDER_TEMPLATE); } getObfuscationFilePath() { return framework_1.PluginFileUtil.pathResolve(this.modulePath, constants_1.FilePathConstants.OBFUSCATION_FILE_NAME); } getConsumerRulesFilePath() { return framework_1.PluginFileUtil.pathResolve(this.modulePath, constants_1.FilePathConstants.CONSUMER_FILE_NAME); } } exports.HMRouterPluginConfig = HMRouterPluginConfig;