@hadss/hmrouter-plugin 1.2.0-beta.0 → 1.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/HMRouterPluginManager.js +9 -2
- package/dist/framework/constants/TaskConstants.d.ts +1 -0
- package/dist/framework/constants/TaskConstants.js +1 -0
- package/dist/framework/core/PluginExecutionController.d.ts +7 -1
- package/dist/framework/core/PluginExecutionController.js +72 -28
- package/dist/framework/utils/FileUtil.d.ts +4 -0
- package/dist/framework/utils/FileUtil.js +11 -0
- package/dist/hmrouter_extension/config/HMRouterPluginConfig.js +3 -4
- package/dist/hmrouter_extension/processor/CodeGenerationProcessor.js +2 -1
- package/dist/hmrouter_extension/processor/InitializerProcessor.d.ts +1 -0
- package/dist/hmrouter_extension/processor/InitializerProcessor.js +29 -5
- package/dist/hmrouter_extension/processor/ObfuscationProcessor.js +1 -1
- package/dist/hmrouter_extension/processor/ResourceProcessor.js +14 -0
- package/dist/hmrouter_extension/processor/RouterMapBuildingProcessor.js +2 -1
- package/package.json +1 -1
- package/dist/HMRouterAnalyzer.d.ts +0 -31
- package/dist/HMRouterAnalyzer.js +0 -343
- package/dist/HMRouterHvigorPlugin.d.ts +0 -15
- package/dist/HMRouterHvigorPlugin.js +0 -153
- package/dist/HMRouterPluginConfig.d.ts +0 -39
- package/dist/HMRouterPluginConfig.js +0 -74
- package/dist/HMRouterPluginHandle.d.ts +0 -23
- package/dist/HMRouterPluginHandle.js +0 -222
- package/dist/common/Logger.d.ts +0 -13
- package/dist/common/Logger.js +0 -55
- package/dist/common/PluginModel.d.ts +0 -51
- package/dist/common/PluginModel.js +0 -23
- package/dist/constants/CommonConstants.d.ts +0 -39
- package/dist/constants/CommonConstants.js +0 -46
- package/dist/constants/ConfigConstants.d.ts +0 -12
- package/dist/constants/ConfigConstants.js +0 -16
- package/dist/constants/TaskConstants.d.ts +0 -9
- package/dist/constants/TaskConstants.js +0 -13
- package/dist/store/PluginStore.d.ts +0 -14
- package/dist/store/PluginStore.js +0 -20
- package/dist/utils/FileUtil.d.ts +0 -13
- package/dist/utils/FileUtil.js +0 -20
- package/dist/utils/ObfuscationUtil.d.ts +0 -4
- package/dist/utils/ObfuscationUtil.js +0 -34
- package/dist/utils/StringUtil.d.ts +0 -3
- package/dist/utils/StringUtil.js +0 -18
- package/dist/utils/TsAstUtil.d.ts +0 -9
- package/dist/utils/TsAstUtil.js +0 -97
package/README.md
CHANGED
|
@@ -49,13 +49,20 @@ class HMRouterPluginManager {
|
|
|
49
49
|
this.controllerMap.set(node.getNodeName(), controller);
|
|
50
50
|
if ((0, framework_1.isHspModule)(node)) {
|
|
51
51
|
let packageJsonPath = framework_1.PluginFileUtil.pathResolve(node.getNodePath(), 'oh-package.json5');
|
|
52
|
-
let
|
|
53
|
-
let packageJson = JSON.parse(packageJsonContent.toString());
|
|
52
|
+
let packageJson = framework_1.PluginFileUtil.readJson5(packageJsonPath);
|
|
54
53
|
let hspNameArr = framework_1.PluginStore.getInstance().get('hspModuleNames');
|
|
55
54
|
if (!hspNameArr) {
|
|
56
55
|
framework_1.PluginStore.getInstance().set('hspModuleNames', []);
|
|
57
56
|
}
|
|
57
|
+
let hspModulesInfo = framework_1.PluginStore.getInstance().get('hspModulesInfo');
|
|
58
|
+
if (!hspModulesInfo) {
|
|
59
|
+
framework_1.PluginStore.getInstance().set('hspModulesInfo', []);
|
|
60
|
+
}
|
|
58
61
|
framework_1.PluginStore.getInstance().get('hspModuleNames')?.push(packageJson.name);
|
|
62
|
+
framework_1.PluginStore.getInstance().get('hspModulesInfo')?.push({
|
|
63
|
+
moduleName: node.getNodeName(),
|
|
64
|
+
packageName: packageJson.name
|
|
65
|
+
});
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
68
|
addModuleNode(node) {
|
|
@@ -5,4 +5,5 @@ export declare class TaskConstants {
|
|
|
5
5
|
static readonly PLUGIN_TASK = "@HMRouterPluginTask";
|
|
6
6
|
static readonly COPY_ROUTER_MAP_TASK = "@HMRouterCopyRouterMapToRawFileTask";
|
|
7
7
|
static readonly GENERATE_OBFUSCATION_TASK = "@HMRouterGenerateObfuscationFileTask";
|
|
8
|
+
static readonly DEFAULT_SOURCE_ROOT = "./src/main";
|
|
8
9
|
}
|
|
@@ -10,3 +10,4 @@ TaskConstants.PROCESS_RESOURCE = '@ProcessResource';
|
|
|
10
10
|
TaskConstants.PLUGIN_TASK = '@HMRouterPluginTask';
|
|
11
11
|
TaskConstants.COPY_ROUTER_MAP_TASK = '@HMRouterCopyRouterMapToRawFileTask';
|
|
12
12
|
TaskConstants.GENERATE_OBFUSCATION_TASK = '@HMRouterGenerateObfuscationFileTask';
|
|
13
|
+
TaskConstants.DEFAULT_SOURCE_ROOT = './src/main';
|
|
@@ -6,10 +6,16 @@ export declare class PluginExecutionController {
|
|
|
6
6
|
private readonly moduleContext;
|
|
7
7
|
private readonly taskManager;
|
|
8
8
|
private readonly baseContext;
|
|
9
|
-
private
|
|
9
|
+
private originalBuilderDir?;
|
|
10
10
|
constructor(node: HvigorNode, moduleContext: OhosModuleContext, moduleExtensions?: PluginExtension[]);
|
|
11
11
|
start(): void;
|
|
12
12
|
complete(): void;
|
|
13
13
|
private initializeContext;
|
|
14
14
|
private registerHvigorTasks;
|
|
15
|
+
private filterScanFilesForTarget;
|
|
16
|
+
private getAbsoluteSourceRoots;
|
|
17
|
+
private registerMainPluginTask;
|
|
18
|
+
private registerObfuscationTask;
|
|
19
|
+
private registerCopyRouterMapTask;
|
|
20
|
+
private getTaskName;
|
|
15
21
|
}
|
|
@@ -5,9 +5,9 @@ const TaskManager_1 = require("./TaskManager");
|
|
|
5
5
|
const TaskStage_1 = require("./TaskStage");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
7
|
const extension_1 = require("../extension");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
8
9
|
class PluginExecutionController {
|
|
9
10
|
constructor(node, moduleContext, moduleExtensions) {
|
|
10
|
-
this.extensionContextCache = new Map();
|
|
11
11
|
this.node = node;
|
|
12
12
|
this.moduleContext = moduleContext;
|
|
13
13
|
this.baseContext = this.initializeContext();
|
|
@@ -28,35 +28,79 @@ class PluginExecutionController {
|
|
|
28
28
|
registerHvigorTasks() {
|
|
29
29
|
this.moduleContext.targets((target) => {
|
|
30
30
|
const targetName = target.getTargetName();
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
dependencies: [targetName + constants_1.TaskConstants.PROCESS_ROUTER_MAP],
|
|
57
|
-
postDependencies: [targetName + constants_1.TaskConstants.PROCESS_RESOURCE],
|
|
31
|
+
this.registerMainPluginTask(targetName);
|
|
32
|
+
this.registerObfuscationTask(targetName);
|
|
33
|
+
if ((0, utils_1.isHapModule)(this.node) || (0, utils_1.isHspModule)(this.node)) {
|
|
34
|
+
this.registerCopyRouterMapTask(target);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
filterScanFilesForTarget(currentTargetName) {
|
|
39
|
+
const buildProfileTargets = this.moduleContext.getBuildProfileOpt().targets || [];
|
|
40
|
+
const targetOpt = buildProfileTargets.find((target) => target.name === currentTargetName);
|
|
41
|
+
let absoluteSourceRoots;
|
|
42
|
+
if (!targetOpt?.source?.sourceRoots || targetOpt.source.sourceRoots.length === 0) {
|
|
43
|
+
absoluteSourceRoots = this.getAbsoluteSourceRoots([constants_1.TaskConstants.DEFAULT_SOURCE_ROOT]);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (!targetOpt.source.sourceRoots.find((value) => value === constants_1.TaskConstants.DEFAULT_SOURCE_ROOT)) {
|
|
47
|
+
targetOpt.source.sourceRoots.push(constants_1.TaskConstants.DEFAULT_SOURCE_ROOT);
|
|
48
|
+
}
|
|
49
|
+
absoluteSourceRoots = this.getAbsoluteSourceRoots(targetOpt.source.sourceRoots);
|
|
50
|
+
}
|
|
51
|
+
this.baseContext.scanFiles = this.baseContext.scanFiles.filter((filePath) => {
|
|
52
|
+
const normalizedFilePath = utils_1.PluginFileUtil.normalize(filePath);
|
|
53
|
+
return absoluteSourceRoots.some((sourceRootPath) => {
|
|
54
|
+
return normalizedFilePath.startsWith(sourceRootPath);
|
|
58
55
|
});
|
|
59
56
|
});
|
|
60
57
|
}
|
|
58
|
+
getAbsoluteSourceRoots(sourceRoots) {
|
|
59
|
+
const moduleRoot = this.moduleContext.getModulePath();
|
|
60
|
+
return sourceRoots.map((sourceRoot) => {
|
|
61
|
+
const absolutePath = utils_1.PluginFileUtil.resolve(moduleRoot, sourceRoot);
|
|
62
|
+
const normalizedPath = utils_1.PluginFileUtil.normalize(absolutePath);
|
|
63
|
+
return normalizedPath.endsWith(utils_1.PluginFileUtil.sep) ? normalizedPath : normalizedPath + utils_1.PluginFileUtil.sep;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
registerMainPluginTask(targetName) {
|
|
67
|
+
this.node.registerTask({
|
|
68
|
+
name: this.getTaskName(targetName, constants_1.TaskConstants.PLUGIN_TASK),
|
|
69
|
+
run: () => {
|
|
70
|
+
this.filterScanFilesForTarget(targetName);
|
|
71
|
+
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_ANNOTATION_ANALYSIS);
|
|
72
|
+
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_CODE_GENERATION);
|
|
73
|
+
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_ROUTER_MAP_BUILDING);
|
|
74
|
+
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_CONFIG_UPDATE);
|
|
75
|
+
},
|
|
76
|
+
dependencies: [],
|
|
77
|
+
postDependencies: [this.getTaskName(targetName, constants_1.TaskConstants.PRE_BUILD)],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
registerObfuscationTask(targetName) {
|
|
81
|
+
this.node.registerTask({
|
|
82
|
+
name: this.getTaskName(targetName, constants_1.TaskConstants.GENERATE_OBFUSCATION_TASK),
|
|
83
|
+
run: () => {
|
|
84
|
+
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_OBFUSCATION_PROCESS);
|
|
85
|
+
},
|
|
86
|
+
dependencies: [this.getTaskName(targetName, constants_1.TaskConstants.PLUGIN_TASK)],
|
|
87
|
+
postDependencies: [this.getTaskName(targetName, constants_1.TaskConstants.PRE_BUILD)],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
registerCopyRouterMapTask(target) {
|
|
91
|
+
const targetName = target.getTargetName();
|
|
92
|
+
this.node.registerTask({
|
|
93
|
+
name: this.getTaskName(targetName, constants_1.TaskConstants.COPY_ROUTER_MAP_TASK),
|
|
94
|
+
run: () => {
|
|
95
|
+
this.taskManager.context.currentTarget = target;
|
|
96
|
+
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_RESOURCE_PROCESS);
|
|
97
|
+
},
|
|
98
|
+
dependencies: [this.getTaskName(targetName, constants_1.TaskConstants.PROCESS_ROUTER_MAP)],
|
|
99
|
+
postDependencies: [this.getTaskName(targetName, constants_1.TaskConstants.PROCESS_RESOURCE)],
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
getTaskName(targetName, taskConstant) {
|
|
103
|
+
return targetName + taskConstant;
|
|
104
|
+
}
|
|
61
105
|
}
|
|
62
106
|
exports.PluginExecutionController = PluginExecutionController;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { FileUtil } from '@ohos/hvigor';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
export declare class PluginFileUtil extends FileUtil {
|
|
6
|
+
static readonly sep: "\\" | "/";
|
|
6
7
|
static rmSync(path: fs.PathLike, options?: fs.RmOptions): void;
|
|
7
8
|
static unlinkSync(path: fs.PathLike): void;
|
|
8
9
|
static readdirSync(path: fs.PathLike, options?: {
|
|
@@ -10,4 +11,7 @@ export declare class PluginFileUtil extends FileUtil {
|
|
|
10
11
|
withFileTypes?: false | undefined;
|
|
11
12
|
recursive?: boolean | undefined;
|
|
12
13
|
}): string[];
|
|
14
|
+
static normalize(filePath: string): string;
|
|
15
|
+
static resolve(...paths: string[]): string;
|
|
16
|
+
static join(...paths: string[]): string;
|
|
13
17
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.PluginFileUtil = void 0;
|
|
7
7
|
const hvigor_1 = require("@ohos/hvigor");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
9
10
|
class PluginFileUtil extends hvigor_1.FileUtil {
|
|
10
11
|
static rmSync(path, options) {
|
|
11
12
|
return fs_1.default.rmSync(path, options);
|
|
@@ -16,5 +17,15 @@ class PluginFileUtil extends hvigor_1.FileUtil {
|
|
|
16
17
|
static readdirSync(path, options) {
|
|
17
18
|
return fs_1.default.readdirSync(path, options);
|
|
18
19
|
}
|
|
20
|
+
static normalize(filePath) {
|
|
21
|
+
return path_1.default.normalize(filePath);
|
|
22
|
+
}
|
|
23
|
+
static resolve(...paths) {
|
|
24
|
+
return path_1.default.resolve(...paths);
|
|
25
|
+
}
|
|
26
|
+
static join(...paths) {
|
|
27
|
+
return path_1.default.join(...paths);
|
|
28
|
+
}
|
|
19
29
|
}
|
|
20
30
|
exports.PluginFileUtil = PluginFileUtil;
|
|
31
|
+
PluginFileUtil.sep = path_1.default.sep;
|
|
@@ -48,11 +48,10 @@ class HMRouterPluginConfig {
|
|
|
48
48
|
return framework_1.PluginFileUtil.pathResolve(this.modulePath, constants_1.FilePathConstants.RAWFILE_DIR);
|
|
49
49
|
}
|
|
50
50
|
getDefaultTplFilePath() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return templateFilePath;
|
|
51
|
+
if (path_1.default.isAbsolute(this.defaultPageTemplate) && framework_1.PluginFileUtil.exist(this.defaultPageTemplate)) {
|
|
52
|
+
return this.defaultPageTemplate;
|
|
54
53
|
}
|
|
55
|
-
return framework_1.PluginFileUtil.pathResolve(__dirname, constants_1.FilePathConstants.PARENT_DELIMITER.repeat(3) +
|
|
54
|
+
return framework_1.PluginFileUtil.pathResolve(__dirname, constants_1.FilePathConstants.PARENT_DELIMITER.repeat(3) + constants_1.TemplateConstants.VIEW_BUILDER_TEMPLATE);
|
|
56
55
|
}
|
|
57
56
|
getObfuscationFilePath() {
|
|
58
57
|
return framework_1.PluginFileUtil.pathResolve(this.modulePath, constants_1.FilePathConstants.OBFUSCATION_FILE_NAME);
|
|
@@ -33,7 +33,8 @@ class CodeGenerationProcessor {
|
|
|
33
33
|
tempFilePath = this.determineTemplatePath(result, tempFilePath);
|
|
34
34
|
const generatedFilePath = this.generateFile(templateModel, tempFilePath);
|
|
35
35
|
framework_1.Logger.info(this.context.node.getNodeName(), `Builder ${templateModel.generatorViewName}.ets has been generated in ${generatedFilePath}`);
|
|
36
|
-
|
|
36
|
+
const uniqueKey = `${result.name}#${result.pageUrl}`;
|
|
37
|
+
this.context.generatedPaths.set(uniqueKey, generatedFilePath);
|
|
37
38
|
}
|
|
38
39
|
matchedPath(filePath, customPageTemplate, defaultTplFilePath) {
|
|
39
40
|
for (const template of customPageTemplate) {
|
|
@@ -52,12 +52,27 @@ class InitializerProcessor {
|
|
|
52
52
|
return configParam;
|
|
53
53
|
}
|
|
54
54
|
readProjectConfig() {
|
|
55
|
-
const
|
|
56
|
-
|
|
55
|
+
const projectPath = framework_1.PluginStore.getInstance().get('projectFilePath');
|
|
56
|
+
const projectConfigFilePath = framework_1.PluginFileUtil.pathResolve(projectPath, constants_1.FilePathConstants.CONFIG_FILE_NAME);
|
|
57
|
+
const configParam = this.readConfigFile(projectConfigFilePath);
|
|
58
|
+
return this.resolveConfigPaths(configParam, projectPath);
|
|
57
59
|
}
|
|
58
60
|
readModuleConfig(node) {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
+
const modulePath = node.getNodePath();
|
|
62
|
+
const moduleConfigFilePath = framework_1.PluginFileUtil.pathResolve(modulePath, constants_1.FilePathConstants.CONFIG_FILE_NAME);
|
|
63
|
+
const configParam = this.readConfigFile(moduleConfigFilePath);
|
|
64
|
+
return this.resolveConfigPaths(configParam, modulePath);
|
|
65
|
+
}
|
|
66
|
+
resolveConfigPaths(configParam, basePath) {
|
|
67
|
+
if (configParam.defaultPageTemplate) {
|
|
68
|
+
configParam.defaultPageTemplate = framework_1.PluginFileUtil.pathResolve(basePath, configParam.defaultPageTemplate);
|
|
69
|
+
}
|
|
70
|
+
if (configParam.customPageTemplate) {
|
|
71
|
+
configParam.customPageTemplate.forEach((item) => {
|
|
72
|
+
item.templatePath = framework_1.PluginFileUtil.pathResolve(basePath, item.templatePath);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return configParam;
|
|
61
76
|
}
|
|
62
77
|
mergeConfigs(projectConfigParam, moduleConfigParam) {
|
|
63
78
|
const defaultConfig = {
|
|
@@ -90,7 +105,16 @@ class InitializerProcessor {
|
|
|
90
105
|
let packageJson = framework_1.PluginFileUtil.readJson5(framework_1.PluginFileUtil.pathResolve(node.getNodePath(), constants_1.FilePathConstants.OH_PACKAGE_FILE_NAME));
|
|
91
106
|
nodeName = packageJson.name;
|
|
92
107
|
}
|
|
93
|
-
|
|
108
|
+
let configDir = modulePath;
|
|
109
|
+
const moduleConfigPath = framework_1.PluginFileUtil.pathResolve(modulePath, constants_1.FilePathConstants.CONFIG_FILE_NAME);
|
|
110
|
+
const projectConfigPath = framework_1.PluginFileUtil.pathResolve(framework_1.PluginStore.getInstance().get('projectFilePath'), constants_1.FilePathConstants.CONFIG_FILE_NAME);
|
|
111
|
+
if (framework_1.PluginFileUtil.exist(moduleConfigPath)) {
|
|
112
|
+
configDir = modulePath;
|
|
113
|
+
}
|
|
114
|
+
else if (framework_1.PluginFileUtil.exist(projectConfigPath)) {
|
|
115
|
+
configDir = framework_1.PluginStore.getInstance().get('projectFilePath');
|
|
116
|
+
}
|
|
117
|
+
return new HMRouterPluginConfig_1.HMRouterPluginConfig(nodeName, modulePath, configDir, configParam);
|
|
94
118
|
}
|
|
95
119
|
}
|
|
96
120
|
exports.InitializerProcessor = InitializerProcessor;
|
|
@@ -27,6 +27,20 @@ class ResourceProcessProcessor {
|
|
|
27
27
|
let rawFileRouterMap = JSON.parse(framework_1.PluginFileUtil.readFileSync(rawFilePath).toString());
|
|
28
28
|
rawFileRouterMap.hspModuleNames = [...new Set(framework_1.PluginStore.getInstance().get('hspModuleNames'))];
|
|
29
29
|
rawFileRouterMap.hspModuleNames.push(...this.getRemoteHspModuleNames(this.context.node.getAllPluginIds()));
|
|
30
|
+
let hspModulesInfo = framework_1.PluginStore.getInstance().get('hspModulesInfo');
|
|
31
|
+
if (hspModulesInfo && hspModulesInfo.length > 0) {
|
|
32
|
+
rawFileRouterMap.hspModulesInfo = hspModulesInfo;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
rawFileRouterMap.hspModulesInfo = [];
|
|
36
|
+
}
|
|
37
|
+
let remoteHspModuleNames = this.getRemoteHspModuleNames(this.context.node.getAllPluginIds());
|
|
38
|
+
for (const remoteName of remoteHspModuleNames) {
|
|
39
|
+
rawFileRouterMap.hspModulesInfo.push({
|
|
40
|
+
moduleName: remoteName,
|
|
41
|
+
packageName: remoteName
|
|
42
|
+
});
|
|
43
|
+
}
|
|
30
44
|
framework_1.PluginFileUtil.writeFileSync(rawFilePath, JSON.stringify(rawFileRouterMap));
|
|
31
45
|
}
|
|
32
46
|
getRemoteHspModuleNames(pluginIds) {
|
|
@@ -25,7 +25,8 @@ class RouterMapBuildingProcessor {
|
|
|
25
25
|
.replaceAll(constants_1.FilePathConstants.FILE_SEPARATOR, constants_1.FilePathConstants.DELIMITER);
|
|
26
26
|
if (result.annotation === constants_1.AnnotationConstants.ROUTER_ANNOTATION) {
|
|
27
27
|
let pageUrl = result.pageUrl;
|
|
28
|
-
let
|
|
28
|
+
let uniqueKey = `${result.name}#${pageUrl}`;
|
|
29
|
+
let builderPath = this.context.generatedPaths.get(uniqueKey) || '';
|
|
29
30
|
this.context.routerMap.push({
|
|
30
31
|
name: pageUrl,
|
|
31
32
|
pageSourceFile: builderPath,
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AnalyzerResultLike } from './common/PluginModel';
|
|
2
|
-
import { HMRouterPluginConfig } from './HMRouterPluginConfig';
|
|
3
|
-
export declare class AnalyzerController {
|
|
4
|
-
private analyzeResult;
|
|
5
|
-
analyzeFile(sourceFilePath: string, config: HMRouterPluginConfig): void;
|
|
6
|
-
parseConstants(): void;
|
|
7
|
-
private parsePropertyValue;
|
|
8
|
-
getAnalyzeResultSet(): Set<AnalyzerResultLike>;
|
|
9
|
-
clearAnalyzeResultSet(): void;
|
|
10
|
-
}
|
|
11
|
-
export declare class AnalyzerService {
|
|
12
|
-
private readonly sourceFilePath;
|
|
13
|
-
private sourceFile;
|
|
14
|
-
private config;
|
|
15
|
-
private analyzerResultSet;
|
|
16
|
-
private importMap;
|
|
17
|
-
constructor(sourceFilePath: string, config: HMRouterPluginConfig);
|
|
18
|
-
start(): void;
|
|
19
|
-
getResult(): Set<AnalyzerResultLike>;
|
|
20
|
-
private analyzeImport;
|
|
21
|
-
private analyzeRouter;
|
|
22
|
-
private parseFileByLineOrder;
|
|
23
|
-
private analyzeComponent;
|
|
24
|
-
private addToResultSet;
|
|
25
|
-
private parseDecorator;
|
|
26
|
-
private parseDecoratorArguments;
|
|
27
|
-
private parseIdentifierPropertyValue;
|
|
28
|
-
private parsePrimitiveValue;
|
|
29
|
-
private getVariableFilePath;
|
|
30
|
-
private getOtherModuleVariableFilePath;
|
|
31
|
-
}
|