@hadss/hmrouter-plugin 1.2.0-beta.0 → 1.2.0-beta.2
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/core/PluginExecutionController.d.ts +11 -0
- package/dist/framework/core/PluginExecutionController.js +129 -22
- 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) {
|
|
@@ -7,9 +7,20 @@ export declare class PluginExecutionController {
|
|
|
7
7
|
private readonly taskManager;
|
|
8
8
|
private readonly baseContext;
|
|
9
9
|
private extensionContextCache;
|
|
10
|
+
private originalBuilderDir?;
|
|
10
11
|
constructor(node: HvigorNode, moduleContext: OhosModuleContext, moduleExtensions?: PluginExtension[]);
|
|
11
12
|
start(): void;
|
|
12
13
|
complete(): void;
|
|
13
14
|
private initializeContext;
|
|
14
15
|
private registerHvigorTasks;
|
|
16
|
+
private filterScanFilesForTarget;
|
|
17
|
+
private backupScanFiles;
|
|
18
|
+
private restoreScanFiles;
|
|
19
|
+
private backupConfig;
|
|
20
|
+
private restoreConfig;
|
|
21
|
+
private adjustConfigForTarget;
|
|
22
|
+
private registerMainPluginTask;
|
|
23
|
+
private registerObfuscationTask;
|
|
24
|
+
private registerCopyRouterMapTask;
|
|
25
|
+
private getTaskName;
|
|
15
26
|
}
|
|
@@ -5,6 +5,7 @@ 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
11
|
this.extensionContextCache = new Map();
|
|
@@ -28,35 +29,141 @@ class PluginExecutionController {
|
|
|
28
29
|
registerHvigorTasks() {
|
|
29
30
|
this.moduleContext.targets((target) => {
|
|
30
31
|
const targetName = target.getTargetName();
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
this.taskManager.context.currentTarget = target;
|
|
33
|
+
this.registerMainPluginTask(targetName);
|
|
34
|
+
this.registerObfuscationTask(targetName);
|
|
35
|
+
if ((0, utils_1.isHapModule)(this.node) || (0, utils_1.isHspModule)(this.node)) {
|
|
36
|
+
this.registerCopyRouterMapTask(targetName);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
filterScanFilesForTarget() {
|
|
41
|
+
const currentTargetName = this.taskManager.context.currentTarget?.getTargetName();
|
|
42
|
+
if (!currentTargetName) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const buildProfileTargets = this.moduleContext.getBuildProfileOpt().targets || [];
|
|
46
|
+
const targetOpt = buildProfileTargets.find((target) => target.name === currentTargetName);
|
|
47
|
+
if (!targetOpt?.source?.sourceRoots || targetOpt.source.sourceRoots.length === 0) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const moduleRoot = this.moduleContext.getModulePath();
|
|
51
|
+
const absoluteSourceRoots = targetOpt.source.sourceRoots.map((sourceRoot) => {
|
|
52
|
+
const absolutePath = utils_1.PluginFileUtil.resolve(moduleRoot, sourceRoot);
|
|
53
|
+
const normalizedPath = utils_1.PluginFileUtil.normalize(absolutePath);
|
|
54
|
+
return normalizedPath.endsWith(utils_1.PluginFileUtil.sep) ? normalizedPath : normalizedPath + utils_1.PluginFileUtil.sep;
|
|
55
|
+
});
|
|
56
|
+
this.baseContext.scanFiles = this.baseContext.scanFiles.filter((filePath) => {
|
|
57
|
+
const normalizedFilePath = utils_1.PluginFileUtil.normalize(filePath);
|
|
58
|
+
return absoluteSourceRoots.some((sourceRootPath) => {
|
|
59
|
+
return normalizedFilePath.startsWith(sourceRootPath);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
backupScanFiles() {
|
|
64
|
+
return [...this.baseContext.scanFiles];
|
|
65
|
+
}
|
|
66
|
+
restoreScanFiles(backup) {
|
|
67
|
+
this.baseContext.scanFiles = backup;
|
|
68
|
+
}
|
|
69
|
+
backupConfig() {
|
|
70
|
+
const hmrouterContext = this.taskManager.context;
|
|
71
|
+
if (hmrouterContext.config && hmrouterContext.config.builderDir) {
|
|
72
|
+
this.originalBuilderDir = hmrouterContext.config.builderDir;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
restoreConfig() {
|
|
76
|
+
if (this.originalBuilderDir) {
|
|
77
|
+
const hmrouterContext = this.taskManager.context;
|
|
78
|
+
if (hmrouterContext.config) {
|
|
79
|
+
hmrouterContext.config.builderDir = this.originalBuilderDir;
|
|
80
|
+
}
|
|
81
|
+
this.originalBuilderDir = undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
adjustConfigForTarget() {
|
|
85
|
+
const currentTargetName = this.taskManager.context.currentTarget?.getTargetName();
|
|
86
|
+
if (!currentTargetName) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const buildProfileTargets = this.moduleContext.getBuildProfileOpt().targets || [];
|
|
90
|
+
const targetOpt = buildProfileTargets.find((target) => target.name === currentTargetName);
|
|
91
|
+
if (!targetOpt?.source?.sourceRoots || targetOpt.source.sourceRoots.length === 0) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const hmrouterContext = this.taskManager.context;
|
|
95
|
+
if (!hmrouterContext.config || !hmrouterContext.config.builderDir) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const firstSourceRoot = targetOpt.source.sourceRoots[0];
|
|
99
|
+
const cleanSourceRoot = firstSourceRoot.replace(/^\.\//, '');
|
|
100
|
+
hmrouterContext.config.builderDir = `${cleanSourceRoot}/ets/generated`;
|
|
101
|
+
}
|
|
102
|
+
registerMainPluginTask(targetName) {
|
|
103
|
+
this.node.registerTask({
|
|
104
|
+
name: this.getTaskName(targetName, constants_1.TaskConstants.PLUGIN_TASK),
|
|
105
|
+
run: () => {
|
|
106
|
+
const scanFilesBackup = this.backupScanFiles();
|
|
107
|
+
try {
|
|
108
|
+
this.backupConfig();
|
|
109
|
+
this.filterScanFilesForTarget();
|
|
110
|
+
this.adjustConfigForTarget();
|
|
34
111
|
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_ANNOTATION_ANALYSIS);
|
|
35
112
|
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_CODE_GENERATION);
|
|
36
113
|
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_ROUTER_MAP_BUILDING);
|
|
37
114
|
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_CONFIG_UPDATE);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
this.restoreConfig();
|
|
118
|
+
this.restoreScanFiles(scanFilesBackup);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
dependencies: [],
|
|
122
|
+
postDependencies: [this.getTaskName(targetName, constants_1.TaskConstants.PRE_BUILD)],
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
registerObfuscationTask(targetName) {
|
|
126
|
+
this.node.registerTask({
|
|
127
|
+
name: this.getTaskName(targetName, constants_1.TaskConstants.GENERATE_OBFUSCATION_TASK),
|
|
128
|
+
run: () => {
|
|
129
|
+
const scanFilesBackup = this.backupScanFiles();
|
|
130
|
+
try {
|
|
131
|
+
this.backupConfig();
|
|
132
|
+
this.filterScanFilesForTarget();
|
|
133
|
+
this.adjustConfigForTarget();
|
|
45
134
|
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_OBFUSCATION_PROCESS);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
this.restoreConfig();
|
|
138
|
+
this.restoreScanFiles(scanFilesBackup);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
dependencies: [this.getTaskName(targetName, constants_1.TaskConstants.PLUGIN_TASK)],
|
|
142
|
+
postDependencies: [this.getTaskName(targetName, constants_1.TaskConstants.PRE_BUILD)],
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
registerCopyRouterMapTask(targetName) {
|
|
146
|
+
this.node.registerTask({
|
|
147
|
+
name: this.getTaskName(targetName, constants_1.TaskConstants.COPY_ROUTER_MAP_TASK),
|
|
148
|
+
run: () => {
|
|
149
|
+
const scanFilesBackup = this.backupScanFiles();
|
|
150
|
+
try {
|
|
151
|
+
this.backupConfig();
|
|
152
|
+
this.filterScanFilesForTarget();
|
|
153
|
+
this.adjustConfigForTarget();
|
|
54
154
|
this.taskManager.executeStage(TaskStage_1.TaskStage.AFTER_RESOURCE_PROCESS);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
this.restoreConfig();
|
|
158
|
+
this.restoreScanFiles(scanFilesBackup);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
dependencies: [this.getTaskName(targetName, constants_1.TaskConstants.PROCESS_ROUTER_MAP)],
|
|
162
|
+
postDependencies: [this.getTaskName(targetName, constants_1.TaskConstants.PROCESS_RESOURCE)],
|
|
59
163
|
});
|
|
60
164
|
}
|
|
165
|
+
getTaskName(targetName, taskConstant) {
|
|
166
|
+
return targetName + taskConstant;
|
|
167
|
+
}
|
|
61
168
|
}
|
|
62
169
|
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
|
-
}
|