@hadss/hmrouter-plugin 1.1.1-alpha.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 +126 -56
- package/dist/HMRouterPluginManager.d.ts +3 -1
- package/dist/HMRouterPluginManager.js +26 -8
- package/dist/Index.d.ts +5 -0
- package/dist/Index.js +29 -1
- package/dist/framework/core/PluginExecutionController.d.ts +11 -0
- package/dist/framework/core/PluginExecutionController.js +129 -22
- package/dist/framework/core/TaskManager.js +6 -5
- package/dist/framework/utils/FileUtil.d.ts +4 -0
- package/dist/framework/utils/FileUtil.js +11 -0
- package/dist/hmrouter_extension/HMRouterExtension.d.ts +1 -0
- package/dist/hmrouter_extension/HMRouterExtension.js +55 -0
- package/dist/hmrouter_extension/analyzer/ComponentAnalyzer.js +0 -1
- package/dist/hmrouter_extension/analyzer/RouterAnalyzer.d.ts +1 -0
- package/dist/hmrouter_extension/analyzer/RouterAnalyzer.js +16 -8
- package/dist/hmrouter_extension/config/HMRouterPluginConfig.js +3 -4
- package/dist/hmrouter_extension/constants/PluginConstants.d.ts +1 -0
- package/dist/hmrouter_extension/constants/PluginConstants.js +1 -0
- 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 +30 -5
- package/dist/hmrouter_extension/processor/ObfuscationProcessor.d.ts +0 -1
- package/dist/hmrouter_extension/processor/ObfuscationProcessor.js +6 -9
- package/dist/hmrouter_extension/processor/ResourceProcessor.js +14 -0
- package/dist/hmrouter_extension/processor/RouterMapBuildingProcessor.js +2 -6
- package/package.json +2 -1
- package/template/viewBuilder.ejs +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
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HMRouterDefaultExtension = void 0;
|
|
4
4
|
const framework_1 = require("../framework");
|
|
5
5
|
const AnnotationAnalyzerRegistry_1 = require("./analyzer/AnnotationAnalyzerRegistry");
|
|
6
|
+
const ConstantAnalyzer_1 = require("./analyzer/utils/ConstantAnalyzer");
|
|
6
7
|
const processor_1 = require("./processor");
|
|
8
|
+
const framework_2 = require("../framework");
|
|
7
9
|
class HMRouterDefaultExtension extends framework_1.PluginExtension {
|
|
8
10
|
get name() {
|
|
9
11
|
return 'HMRouterExtension';
|
|
@@ -18,6 +20,59 @@ class HMRouterDefaultExtension extends framework_1.PluginExtension {
|
|
|
18
20
|
for (const analyzer of analyzers) {
|
|
19
21
|
analyzer.analyze(sourceFile, filePath, context);
|
|
20
22
|
}
|
|
23
|
+
this.executeConstantParsing(filePath, context);
|
|
24
|
+
}
|
|
25
|
+
executeConstantParsing(filePath, context) {
|
|
26
|
+
try {
|
|
27
|
+
const contextImpl = context;
|
|
28
|
+
const analyzeResults = contextImpl.analyzeResults;
|
|
29
|
+
const currentView = contextImpl._currentView;
|
|
30
|
+
const currentFilePath = contextImpl._currentFilePath;
|
|
31
|
+
const currentFileResults = [];
|
|
32
|
+
analyzeResults.forEach((result) => {
|
|
33
|
+
if (result.sourceFilePath === currentFilePath) {
|
|
34
|
+
currentFileResults.push(result);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (currentFileResults.length === 0) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
framework_2.Logger.debug(this.name, `Start constant parsing for ${currentFileResults.length} results in file: ${filePath}`);
|
|
41
|
+
const constantResolver = AnnotationAnalyzerRegistry_1.AnnotationAnalyzerRegistry.getInstance().getConstantResolver();
|
|
42
|
+
if (!constantResolver) {
|
|
43
|
+
framework_2.Logger.warn(this.name, `Constant resolver not available, skip constant parsing for file: ${filePath}`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const constantAnalyzer = new ConstantAnalyzer_1.ConstantAnalyzer(constantResolver);
|
|
47
|
+
const currentFileResultsCopy = currentFileResults.map((result) => ({ ...result }));
|
|
48
|
+
const resultsSet = new Set(currentFileResultsCopy);
|
|
49
|
+
constantAnalyzer.parseConstants(resultsSet);
|
|
50
|
+
const updatedResults = new Set();
|
|
51
|
+
analyzeResults.forEach((result) => {
|
|
52
|
+
if (result.sourceFilePath !== currentFilePath) {
|
|
53
|
+
updatedResults.add(result);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
resultsSet.forEach((parsedResult) => {
|
|
57
|
+
updatedResults.add(parsedResult);
|
|
58
|
+
});
|
|
59
|
+
contextImpl.analyzeResults = updatedResults;
|
|
60
|
+
for (let i = 0; i < currentView.length; i++) {
|
|
61
|
+
const viewResult = currentView[i];
|
|
62
|
+
if (viewResult.sourceFilePath === currentFilePath) {
|
|
63
|
+
for (const parsedResult of resultsSet) {
|
|
64
|
+
if (parsedResult.name === viewResult.name && parsedResult.sourceFilePath === viewResult.sourceFilePath) {
|
|
65
|
+
currentView[i] = parsedResult;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
framework_2.Logger.debug(this.name, `Constant parsing completed for file: ${filePath}`);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
framework_2.Logger.warn(this.name, `Failed to execute constant parsing for file ${filePath}: ${error}`);
|
|
75
|
+
}
|
|
21
76
|
}
|
|
22
77
|
afterCodeGeneration(context) {
|
|
23
78
|
const generator = new processor_1.CodeGenerationProcessor(context);
|
|
@@ -20,7 +20,6 @@ class ComponentAnalyzer extends AbstractAnnotationAnalyzer_1.AbstractAnnotationA
|
|
|
20
20
|
analyzeClassDecorators(cls, filePath, sourceFile, results) {
|
|
21
21
|
cls.getDecorators().forEach((decorator) => {
|
|
22
22
|
if ([
|
|
23
|
-
constants_1.AnnotationConstants.SERVICE_ANNOTATION,
|
|
24
23
|
constants_1.AnnotationConstants.INTERCEPTOR_ANNOTATION,
|
|
25
24
|
constants_1.AnnotationConstants.LIFECYCLE_ANNOTATION,
|
|
26
25
|
constants_1.AnnotationConstants.ANIMATOR_ANNOTATION,
|
|
@@ -8,4 +8,5 @@ export declare class RouterAnalyzer extends AbstractAnnotationAnalyzer {
|
|
|
8
8
|
analyze(sourceFile: SourceFile, filePath: string, context: HMRouterExtensionContext): void;
|
|
9
9
|
private addToResultSet;
|
|
10
10
|
private checkNavDestinationUsage;
|
|
11
|
+
private extractComponentNameFromNode;
|
|
11
12
|
}
|
|
@@ -14,22 +14,20 @@ class RouterAnalyzer extends AbstractAnnotationAnalyzer_1.AbstractAnnotationAnal
|
|
|
14
14
|
}
|
|
15
15
|
analyze(sourceFile, filePath, context) {
|
|
16
16
|
framework_1.Logger.debug('', `Start to analyze source file: ${filePath}`);
|
|
17
|
-
|
|
18
|
-
.
|
|
19
|
-
.map((node) => node.getText())
|
|
20
|
-
.filter((text) => text !== 'struct');
|
|
21
|
-
sourceFile.getChildrenOfKind(ts_morph_1.SyntaxKind.MissingDeclaration).forEach((node, index) => {
|
|
17
|
+
sourceFile.getChildrenOfKind(ts_morph_1.SyntaxKind.MissingDeclaration).forEach((node) => {
|
|
18
|
+
const componentName = this.extractComponentNameFromNode(node);
|
|
22
19
|
node.getChildrenOfKind(ts_morph_1.SyntaxKind.Decorator).forEach((decorator) => {
|
|
23
20
|
if (decorator.getName() === constants_1.AnnotationConstants.ROUTER_ANNOTATION) {
|
|
24
|
-
const result = this.addToResultSet(decorator,
|
|
21
|
+
const result = this.addToResultSet(decorator, componentName, filePath, sourceFile);
|
|
25
22
|
context.addAnalyzeResults(result);
|
|
26
23
|
}
|
|
27
24
|
});
|
|
28
25
|
});
|
|
29
|
-
sourceFile.getExportAssignments().forEach((exportAssignment
|
|
26
|
+
sourceFile.getExportAssignments().forEach((exportAssignment) => {
|
|
27
|
+
const componentName = exportAssignment.getNextSiblingIfKind(ts_morph_1.SyntaxKind.ExpressionStatement)?.getText() || '';
|
|
30
28
|
exportAssignment.getDescendantsOfKind(ts_morph_1.SyntaxKind.Decorator).forEach((decorator) => {
|
|
31
29
|
if (decorator.getName() === constants_1.AnnotationConstants.ROUTER_ANNOTATION) {
|
|
32
|
-
const result = this.addToResultSet(decorator,
|
|
30
|
+
const result = this.addToResultSet(decorator, componentName, filePath, sourceFile);
|
|
33
31
|
context.addAnalyzeResults(result);
|
|
34
32
|
context.addTemplateData(result.name, { isDefaultExport: 'true' });
|
|
35
33
|
}
|
|
@@ -75,5 +73,15 @@ class RouterAnalyzer extends AbstractAnnotationAnalyzer_1.AbstractAnnotationAnal
|
|
|
75
73
|
}
|
|
76
74
|
});
|
|
77
75
|
}
|
|
76
|
+
extractComponentNameFromNode(node) {
|
|
77
|
+
const nextSibling = node.getNextSiblingIfKind(ts_morph_1.SyntaxKind.ExpressionStatement);
|
|
78
|
+
if (nextSibling && nextSibling.getText() === constants_1.PluginConstants.STRUCT_KEYWORD) {
|
|
79
|
+
const componentName = nextSibling.getNextSiblingIfKind(ts_morph_1.SyntaxKind.ExpressionStatement);
|
|
80
|
+
if (componentName) {
|
|
81
|
+
return componentName.getText();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return '';
|
|
85
|
+
}
|
|
78
86
|
}
|
|
79
87
|
exports.RouterAnalyzer = RouterAnalyzer;
|
|
@@ -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 = {
|
|
@@ -80,6 +95,7 @@ class InitializerProcessor {
|
|
|
80
95
|
if (appContext) {
|
|
81
96
|
framework_1.PluginStore.getInstance().set('projectFilePath', appContext.getProjectPath());
|
|
82
97
|
framework_1.PluginStore.getInstance().set('appContext', appContext);
|
|
98
|
+
framework_1.PluginStore.getInstance().set('buildMode', appContext.getBuildMode());
|
|
83
99
|
}
|
|
84
100
|
}
|
|
85
101
|
createConfigInstance(node, configParam) {
|
|
@@ -89,7 +105,16 @@ class InitializerProcessor {
|
|
|
89
105
|
let packageJson = framework_1.PluginFileUtil.readJson5(framework_1.PluginFileUtil.pathResolve(node.getNodePath(), constants_1.FilePathConstants.OH_PACKAGE_FILE_NAME));
|
|
90
106
|
nodeName = packageJson.name;
|
|
91
107
|
}
|
|
92
|
-
|
|
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);
|
|
93
118
|
}
|
|
94
119
|
}
|
|
95
120
|
exports.InitializerProcessor = InitializerProcessor;
|
|
@@ -9,15 +9,14 @@ class ObfuscationProcessor {
|
|
|
9
9
|
}
|
|
10
10
|
execute() {
|
|
11
11
|
framework_1.Logger.debug(this.context.node.getNodeName(), `Start to obfuscation...`);
|
|
12
|
-
|
|
12
|
+
const buildProfileOpt = this.context.moduleContext?.getBuildProfileOpt();
|
|
13
|
+
if (!this.isEnableObfuscation(buildProfileOpt)) {
|
|
13
14
|
framework_1.Logger.info(this.context.node.getNodeName(), 'This compilation does not turn on code obfuscation, skip hmrouter_obfuscation_rules.txt file generation');
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
const obfuscationString = this.generateObfuscationRuleFile();
|
|
17
18
|
this.handleHarPackageLogic(obfuscationString);
|
|
18
|
-
|
|
19
|
-
checkObfuscationEnabled() {
|
|
20
|
-
return this.isEnableObfuscation();
|
|
19
|
+
this.context.moduleContext?.setBuildProfileOpt(buildProfileOpt);
|
|
21
20
|
}
|
|
22
21
|
generateObfuscationRuleFile() {
|
|
23
22
|
const obfuscationFilePath = framework_1.PluginFileUtil.pathResolve(this.context.config.modulePath, constants_1.FilePathConstants.OBFUSCATION_FILE_NAME);
|
|
@@ -35,11 +34,9 @@ class ObfuscationProcessor {
|
|
|
35
34
|
framework_1.PluginFileUtil.writeFileSync(consumerRulesPath, obfuscationString);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
isEnableObfuscation() {
|
|
37
|
+
isEnableObfuscation(buildProfileOpt) {
|
|
39
38
|
const currentBuildMode = framework_1.PluginStore.getInstance().get('buildMode');
|
|
40
|
-
const buildOption =
|
|
41
|
-
?.getBuildProfileOpt()
|
|
42
|
-
.buildOptionSet?.find((item) => item.name === currentBuildMode);
|
|
39
|
+
const buildOption = buildProfileOpt.buildOptionSet?.find((item) => item.name === currentBuildMode);
|
|
43
40
|
if (!buildOption) {
|
|
44
41
|
return false;
|
|
45
42
|
}
|
|
@@ -89,7 +86,7 @@ class ObfuscationProcessor {
|
|
|
89
86
|
return routerInfo.name.includes('__');
|
|
90
87
|
})
|
|
91
88
|
.map((routerInfo) => {
|
|
92
|
-
return routerInfo.customData.
|
|
89
|
+
return routerInfo.customData.name;
|
|
93
90
|
})),
|
|
94
91
|
];
|
|
95
92
|
let functionName = [
|
|
@@ -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) {
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RouterMapBuildingProcessor = void 0;
|
|
4
4
|
const framework_1 = require("../../framework");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
|
-
const AnnotationAnalyzerRegistry_1 = require("../analyzer/AnnotationAnalyzerRegistry");
|
|
7
|
-
const ConstantAnalyzer_1 = require("../analyzer/utils/ConstantAnalyzer");
|
|
8
6
|
const PluginError_1 = require("../error/PluginError");
|
|
9
7
|
class RouterMapBuildingProcessor {
|
|
10
8
|
constructor(context) {
|
|
@@ -13,9 +11,6 @@ class RouterMapBuildingProcessor {
|
|
|
13
11
|
execute() {
|
|
14
12
|
framework_1.Logger.debug(this.context.node.getNodeName(), `Start to build router map...`);
|
|
15
13
|
this.readExistingRouterMap();
|
|
16
|
-
const constantResolver = AnnotationAnalyzerRegistry_1.AnnotationAnalyzerRegistry.getInstance().getConstantResolver();
|
|
17
|
-
const constantAnalyzer = new ConstantAnalyzer_1.ConstantAnalyzer(constantResolver);
|
|
18
|
-
constantAnalyzer.parseConstants(this.context.getAnalyzeResults());
|
|
19
14
|
for (const result of this.context.getAnalyzeResults()) {
|
|
20
15
|
this.buildRouterMap(result);
|
|
21
16
|
}
|
|
@@ -30,7 +25,8 @@ class RouterMapBuildingProcessor {
|
|
|
30
25
|
.replaceAll(constants_1.FilePathConstants.FILE_SEPARATOR, constants_1.FilePathConstants.DELIMITER);
|
|
31
26
|
if (result.annotation === constants_1.AnnotationConstants.ROUTER_ANNOTATION) {
|
|
32
27
|
let pageUrl = result.pageUrl;
|
|
33
|
-
let
|
|
28
|
+
let uniqueKey = `${result.name}#${pageUrl}`;
|
|
29
|
+
let builderPath = this.context.generatedPaths.get(uniqueKey) || '';
|
|
34
30
|
this.context.routerMap.push({
|
|
35
31
|
name: pageUrl,
|
|
36
32
|
pageSourceFile: builderPath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadss/hmrouter-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-beta.2",
|
|
4
4
|
"description": "HMRouter Compiler Plugin",
|
|
5
5
|
"main": "dist/Index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"ts-node": "^10.9.2"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
40
41
|
"registry": "https://registry.npmjs.org"
|
|
41
42
|
},
|
|
42
43
|
"homepage": "https://gitcode.com/openharmony-sig/ohrouter",
|
package/template/viewBuilder.ejs
CHANGED
|
@@ -39,7 +39,7 @@ export struct <%= componentName %>Generated {
|
|
|
39
39
|
.gestureModifier(this.helper.gestureModifier)
|
|
40
40
|
.onWillAppear(()=>{this.helper.onWillAppear()})
|
|
41
41
|
.onAppear(() => {this.helper.onAppear()})
|
|
42
|
-
.onWillShow(()=>{this.helper.
|
|
42
|
+
.onWillShow(()=>{this.helper.onWillShow()})
|
|
43
43
|
.onShown(()=>{this.helper.onShown()})
|
|
44
44
|
.onWillHide(()=>{this.helper.onWillHide()})
|
|
45
45
|
.onHidden(()=>{this.helper.onHidden()})
|
|
@@ -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
|
-
}
|