@hadss/hmrouter-plugin 1.2.0 → 1.2.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 CHANGED
@@ -21,7 +21,7 @@ HMRouter编译插件是一个基于hvigor的编译插件,用于:
21
21
  ```json5
22
22
  {
23
23
  "dependencies": {
24
- "@hadss/hmrouter-plugin": "^1.2.0" // 使用最新版本
24
+ "@hadss/hmrouter-plugin": "^1.2.2" // 使用最新版本
25
25
  },
26
26
  // ...其余配置
27
27
  }
@@ -438,6 +438,18 @@ hvigor 5.7.3及以上
438
438
 
439
439
  ## 更新日志
440
440
 
441
+ ### 1.2.2 (2025.10.24)
442
+
443
+ - [修复系统路由表合并异常的问题](https://gitcode.com/openharmony-sig/ohrouter/issues/215)
444
+
445
+ ### 1.2.1 (2025.10.20)
446
+
447
+ - [修复低版本IDE编译错误的问题](https://gitcode.com/openharmony-sig/ohrouter/issues/206)
448
+
449
+ ### 1.2.0 (2025.09.28)
450
+
451
+ - 支持API20新接口的生成
452
+
441
453
  ### 1.2.0-rc.0 (2025.09.02)
442
454
 
443
455
  - [修复多target工程下编译app的问题](https://gitcode.com/openharmony-sig/ohrouter/issues/131)
@@ -4,8 +4,9 @@ export declare class HMRouterPluginManager {
4
4
  private static instance;
5
5
  private controllerMap;
6
6
  private moduleNodes;
7
+ private nodeIgnored;
7
8
  private constructor();
8
9
  static getInstance(): HMRouterPluginManager;
9
10
  registerPlugin(node: HvigorNode, pluginId: string, options: PluginParam): void;
10
- addModuleNode(node: HvigorNode): void;
11
+ addModuleNode(node: HvigorNode, isIgnored: boolean): void;
11
12
  }
@@ -9,6 +9,7 @@ class HMRouterPluginManager {
9
9
  constructor() {
10
10
  this.controllerMap = new Map();
11
11
  this.moduleNodes = [];
12
+ this.nodeIgnored = new Set();
12
13
  framework_1.Logger.info('', 'HMRouterPlugin starting...');
13
14
  (0, framework_1.registerPluginExtension)(new HMRouterExtension_1.HMRouterDefaultExtension());
14
15
  hvigor_1.hvigor.nodesEvaluated(() => {
@@ -16,7 +17,6 @@ class HMRouterPluginManager {
16
17
  if (this.controllerMap.has(node.getNodeName())) {
17
18
  return;
18
19
  }
19
- ;
20
20
  node.getAllPluginIds().forEach((pluginId) => {
21
21
  this.registerPlugin(node, pluginId, {});
22
22
  });
@@ -47,7 +47,7 @@ class HMRouterPluginManager {
47
47
  if (!moduleContext) {
48
48
  throw PluginError_1.PluginError.create(PluginError_1.ErrorCode.ERROR_CONFIG, node.getNodeName(), node.getNodePath());
49
49
  }
50
- const controller = new framework_1.PluginExecutionController(node, moduleContext, options.extensions);
50
+ const controller = new framework_1.PluginExecutionController(node, moduleContext, this.nodeIgnored.has(node.getNodeName()), options.extensions);
51
51
  this.controllerMap.set(node.getNodeName(), controller);
52
52
  if ((0, framework_1.isHspModule)(node)) {
53
53
  let packageJsonPath = framework_1.PluginFileUtil.pathResolve(node.getNodePath(), 'oh-package.json5');
@@ -63,12 +63,15 @@ class HMRouterPluginManager {
63
63
  framework_1.PluginStore.getInstance().get('hspModuleNames')?.push(packageJson.name);
64
64
  framework_1.PluginStore.getInstance().get('hspModulesInfo')?.push({
65
65
  moduleName: node.getNodeName(),
66
- packageName: packageJson.name
66
+ packageName: packageJson.name,
67
67
  });
68
68
  }
69
69
  }
70
- addModuleNode(node) {
70
+ addModuleNode(node, isIgnored) {
71
71
  this.moduleNodes.push(node);
72
+ if (isIgnored) {
73
+ this.nodeIgnored.add(node.getNodeName());
74
+ }
72
75
  }
73
76
  }
74
77
  exports.HMRouterPluginManager = HMRouterPluginManager;
package/dist/Index.js CHANGED
@@ -65,16 +65,17 @@ function appPlugin(options) {
65
65
  if (!options) {
66
66
  throw new Error('No options provided');
67
67
  }
68
- hondleNode(options, node);
68
+ handleNode(options, node);
69
69
  },
70
70
  };
71
71
  }
72
72
  exports.appPlugin = appPlugin;
73
- function hondleNode(options, node) {
74
- node.subNodes(subNode => {
73
+ function handleNode(options, node) {
74
+ node.subNodes((subNode) => {
75
+ let isIgnored = false;
75
76
  if (options.ignoreModuleNames.includes(subNode.getNodeName())) {
76
- return;
77
+ isIgnored = true;
77
78
  }
78
- HMRouterPluginManager_1.HMRouterPluginManager.getInstance().addModuleNode(subNode);
79
+ HMRouterPluginManager_1.HMRouterPluginManager.getInstance().addModuleNode(subNode, isIgnored);
79
80
  });
80
81
  }
@@ -7,7 +7,7 @@ export declare class PluginExecutionController {
7
7
  private readonly taskManager;
8
8
  private readonly baseContext;
9
9
  private originalBuilderDir?;
10
- constructor(node: HvigorNode, moduleContext: OhosModuleContext, moduleExtensions?: PluginExtension[]);
10
+ constructor(node: HvigorNode, moduleContext: OhosModuleContext, moduleIgnored: boolean, moduleExtensions?: PluginExtension[]);
11
11
  start(): void;
12
12
  complete(): void;
13
13
  private initializeContext;
@@ -7,10 +7,11 @@ const constants_1 = require("../constants");
7
7
  const extension_1 = require("../extension");
8
8
  const utils_1 = require("../utils");
9
9
  class PluginExecutionController {
10
- constructor(node, moduleContext, moduleExtensions) {
10
+ constructor(node, moduleContext, moduleIgnored, moduleExtensions) {
11
11
  this.node = node;
12
12
  this.moduleContext = moduleContext;
13
13
  this.baseContext = this.initializeContext();
14
+ this.baseContext.moduleIgnored = moduleIgnored;
14
15
  this.taskManager = new TaskManager_1.TaskManager(this.baseContext, moduleExtensions);
15
16
  }
16
17
  start() {
@@ -5,6 +5,7 @@ export declare class ExtensionContextImpl implements ExtensionContext {
5
5
  node: HvigorNode;
6
6
  moduleContext: OhosModuleContext;
7
7
  currentTarget?: Target;
8
+ moduleIgnored?: boolean;
8
9
  private moduleScanFilesMaster;
9
10
  private templateMetadata;
10
11
  private perTargetState;
@@ -10,6 +10,7 @@ export interface BaseExtensionContext {
10
10
  readonly moduleContext: OhosModuleContext;
11
11
  readonly currentView: ReadonlyArray<BaseAnalyzeResult>;
12
12
  currentTarget?: Target;
13
+ moduleIgnored?: boolean;
13
14
  scanFiles: string[];
14
15
  }
15
16
  export interface ExtensionContext extends BaseExtensionContext {
@@ -15,6 +15,10 @@ class HMRouterDefaultExtension extends framework_1.PluginExtension {
15
15
  initializer.execute();
16
16
  }
17
17
  afterAnnotationAnalysis(sourceFile, filePath, context) {
18
+ if (context.moduleIgnored) {
19
+ framework_2.Logger.debug(this.name, 'module ignored: annotationAnalysis');
20
+ return;
21
+ }
18
22
  AnnotationAnalyzerRegistry_1.AnnotationAnalyzerRegistry.getInstance().initialize(context.config.modulePath);
19
23
  const analyzers = AnnotationAnalyzerRegistry_1.AnnotationAnalyzerRegistry.getInstance().getAnalyzers();
20
24
  for (const analyzer of analyzers) {
@@ -78,6 +82,10 @@ class HMRouterDefaultExtension extends framework_1.PluginExtension {
78
82
  }
79
83
  }
80
84
  afterCodeGeneration(context) {
85
+ if (context.moduleIgnored) {
86
+ framework_2.Logger.debug(this.name, 'module ignored: codeGeneration');
87
+ return;
88
+ }
81
89
  const generator = new processor_1.CodeGenerationProcessor(context);
82
90
  generator.execute();
83
91
  }
@@ -90,6 +98,10 @@ class HMRouterDefaultExtension extends framework_1.PluginExtension {
90
98
  processor.execute();
91
99
  }
92
100
  afterObfuscationProcess(context) {
101
+ if (context.moduleIgnored) {
102
+ framework_2.Logger.debug(this.name, 'module ignored: obfuscationProcess');
103
+ return;
104
+ }
93
105
  const processor = new processor_1.ObfuscationProcessor(context);
94
106
  processor.execute();
95
107
  }
@@ -13,6 +13,9 @@ export default class FilePathConstants {
13
13
  static readonly OH_MODULE_PATH = "oh_modules";
14
14
  static readonly OH_PACKAGE_FILE_NAME = "oh-package.json5";
15
15
  static readonly LINE_BREAK = "\n";
16
+ static readonly BUILD_PROFILE = "build-profile.json5";
17
+ static readonly SDK_HOME = "default/openharmony/ets/oh-uni-package.json";
18
+ static readonly DEFAULT_VALUE = 10;
16
19
  static readonly DEFAULT_SCAN_DIR = "src/main/ets";
17
20
  static readonly DEFAULT_ROUTER_MAP_DIR = "src/main/resources/base/profile";
18
21
  static readonly DEFAULT_BUILD_DIR = "src/main/ets/generated";
@@ -21,6 +21,9 @@ FilePathConstants.CURRENT_DELIMITER = './';
21
21
  FilePathConstants.OH_MODULE_PATH = 'oh_modules';
22
22
  FilePathConstants.OH_PACKAGE_FILE_NAME = 'oh-package.json5';
23
23
  FilePathConstants.LINE_BREAK = '\n';
24
+ FilePathConstants.BUILD_PROFILE = 'build-profile.json5';
25
+ FilePathConstants.SDK_HOME = 'default/openharmony/ets/oh-uni-package.json';
26
+ FilePathConstants.DEFAULT_VALUE = 10;
24
27
  FilePathConstants.DEFAULT_SCAN_DIR = 'src/main/ets';
25
28
  FilePathConstants.DEFAULT_ROUTER_MAP_DIR = 'src/main/resources/base/profile';
26
29
  FilePathConstants.DEFAULT_BUILD_DIR = 'src/main/ets/generated';
@@ -1,4 +1,5 @@
1
1
  export interface TemplateModel {
2
+ sdkVersion: number;
2
3
  pageUrl: string;
3
4
  importPath: string;
4
5
  componentName: string;
@@ -1,8 +1,12 @@
1
1
  import { HMRouterExtensionContext } from '../HMRouterExtensionContext';
2
2
  export declare class CodeGenerationProcessor {
3
3
  private context;
4
+ private sdkVersion;
4
5
  constructor(context: HMRouterExtensionContext);
5
6
  execute(): void;
7
+ extractVersion(compatibleSdkVersion: string | number): number;
8
+ getCompileSdkVersion(): number;
9
+ getSdkVersion(json5FilePath: string, index: number): number;
6
10
  private generatePageFile;
7
11
  private matchedPath;
8
12
  private prepareTemplateModel;
@@ -11,9 +11,11 @@ const PluginError_1 = require("../error/PluginError");
11
11
  const constants_1 = require("../constants");
12
12
  class CodeGenerationProcessor {
13
13
  constructor(context) {
14
+ this.sdkVersion = 0;
14
15
  this.context = context;
15
16
  }
16
17
  execute() {
18
+ this.sdkVersion = this.getCompileSdkVersion();
17
19
  framework_1.Logger.debug(this.context.node.getNodeName(), `Start to code generation...`);
18
20
  this.context.generatedPaths = new Map();
19
21
  this.context.getAnalyzeResults().forEach((result) => {
@@ -28,6 +30,63 @@ class CodeGenerationProcessor {
28
30
  }
29
31
  });
30
32
  }
33
+ extractVersion(compatibleSdkVersion) {
34
+ if (typeof compatibleSdkVersion === 'number') {
35
+ return compatibleSdkVersion;
36
+ }
37
+ else {
38
+ const match = compatibleSdkVersion.match(/\((\d+)\)/);
39
+ if (match && match[1]) {
40
+ return parseInt(match[1], 10);
41
+ }
42
+ const num = parseFloat(compatibleSdkVersion);
43
+ if (!isNaN(num) && num > constants_1.FilePathConstants.DEFAULT_VALUE) {
44
+ return num;
45
+ }
46
+ return constants_1.FilePathConstants.DEFAULT_VALUE;
47
+ }
48
+ }
49
+ getCompileSdkVersion() {
50
+ let json5FilePath = '';
51
+ let sdkVersion = constants_1.FilePathConstants.DEFAULT_VALUE;
52
+ let arrData = ['DEVECO_SDK_HOME', 'HOS_SDK_HOME', 'OHOS_SDK_HOME'];
53
+ for (let index = 0; index <= 4; index++) {
54
+ if (index < 3 && process.env[arrData[index]]) {
55
+ json5FilePath = framework_1.PluginFileUtil.pathResolve(process.env[arrData[index]], constants_1.FilePathConstants.SDK_HOME);
56
+ }
57
+ else if (index === 3) {
58
+ json5FilePath = framework_1.PluginFileUtil.pathResolve(framework_1.PluginStore.getInstance().get('projectFilePath'), constants_1.FilePathConstants.BUILD_PROFILE);
59
+ }
60
+ else if (index === 4) {
61
+ json5FilePath = framework_1.PluginFileUtil.pathResolve(framework_1.PluginStore.getInstance().get('projectFilePath'), constants_1.FilePathConstants.BUILD_PROFILE);
62
+ }
63
+ const sdkVer = this.getSdkVersion(json5FilePath, index);
64
+ if (sdkVer > constants_1.FilePathConstants.DEFAULT_VALUE) {
65
+ sdkVersion = sdkVer;
66
+ break;
67
+ }
68
+ }
69
+ return sdkVersion;
70
+ }
71
+ getSdkVersion(json5FilePath, index) {
72
+ if (framework_1.PluginFileUtil.exist(json5FilePath)) {
73
+ const data = framework_1.PluginFileUtil.readJson5(json5FilePath);
74
+ if (index < 3) {
75
+ return this.extractVersion(data.apiVersion);
76
+ }
77
+ else if (index === 3) {
78
+ if (data.app.products[0].compileSdkVersion) {
79
+ return this.extractVersion(data.app.products[0].compileSdkVersion);
80
+ }
81
+ }
82
+ else if (index === 4) {
83
+ if (data.app.products[0].compatibleSdkVersion) {
84
+ return this.extractVersion(data.app.products[0].compatibleSdkVersion);
85
+ }
86
+ }
87
+ }
88
+ return constants_1.FilePathConstants.DEFAULT_VALUE;
89
+ }
31
90
  generatePageFile(result, pageSourceFile, tempFilePath) {
32
91
  const templateModel = this.prepareTemplateModel(result, pageSourceFile);
33
92
  tempFilePath = this.determineTemplatePath(result, tempFilePath);
@@ -53,6 +112,7 @@ class CodeGenerationProcessor {
53
112
  let generatorViewName = constants_1.PrefixConstants.VIEW_NAME_PREFIX + analyzeResult.name + framework_1.StringUtil.stringToHashCode(analyzeResult.pageUrl);
54
113
  let templateData = this.context.getTemplateData(analyzeResult.name);
55
114
  return {
115
+ sdkVersion: this.sdkVersion,
56
116
  pageUrl: analyzeResult.pageUrl,
57
117
  componentName: analyzeResult.name,
58
118
  dialog: !!analyzeResult.dialog,
@@ -1,5 +1,6 @@
1
1
  import { HMRouterExtensionContext } from '../HMRouterExtensionContext';
2
2
  export declare class ConfigUpdateProcessor {
3
+ private context;
3
4
  private moduleContext;
4
5
  private readonly routerMap;
5
6
  private readonly nodeName;
@@ -5,13 +5,21 @@ const framework_1 = require("../../framework");
5
5
  const constants_1 = require("../constants");
6
6
  class ConfigUpdateProcessor {
7
7
  constructor(context) {
8
+ this.context = context;
8
9
  this.moduleContext = context.moduleContext;
9
10
  this.routerMap = context.routerMap;
10
11
  this.nodeName = context.node.getNodeName();
11
12
  }
12
13
  execute() {
13
14
  framework_1.Logger.debug(this.nodeName, `Start to update module.json and build profile...`);
14
- this.updateModuleJson();
15
+ const isHar = (0, framework_1.isHarModule)(this.context.node);
16
+ if (this.context.moduleIgnored && isHar) {
17
+ framework_1.Logger.info(this.nodeName, `skip update module.json and build profile...`);
18
+ return;
19
+ }
20
+ if (this.routerMap.length > 0 || !isHar) {
21
+ this.updateModuleJson();
22
+ }
15
23
  this.updateBuildProfile();
16
24
  }
17
25
  updateModuleJson() {
@@ -13,6 +13,10 @@ class InitializerProcessor {
13
13
  this.context.config = this.initConfig(this.context.node);
14
14
  this.context.routerMap = [];
15
15
  framework_1.Logger.debug(this.context.node.getNodeName(), `read config finished, config: ${this.context.config}`);
16
+ if (this.context.moduleIgnored) {
17
+ framework_1.Logger.debug(this.context.node.getNodeName(), `module ignored: initialize`);
18
+ return;
19
+ }
16
20
  this.scanFiles();
17
21
  framework_1.Logger.debug(this.context.node.getNodeName(), `Scanned ${this.context.scanFiles.length} files ${this.context.scanFiles}`);
18
22
  }
@@ -9,6 +9,10 @@ class ObfuscationProcessor {
9
9
  }
10
10
  execute() {
11
11
  framework_1.Logger.debug(this.context.node.getNodeName(), `Start to obfuscation...`);
12
+ if (!this.context.routerMap || this.context.routerMap.length === 0) {
13
+ framework_1.Logger.info(this.context.node.getNodeName(), 'Skip generating obfuscation files');
14
+ return;
15
+ }
12
16
  const buildProfileOpt = this.context.moduleContext?.getBuildProfileOpt();
13
17
  if (!this.isEnableObfuscation(buildProfileOpt)) {
14
18
  framework_1.Logger.info(this.context.node.getNodeName(), 'This compilation does not turn on code obfuscation, skip hmrouter_obfuscation_rules.txt file generation');
@@ -20,7 +24,10 @@ class ObfuscationProcessor {
20
24
  }
21
25
  generateObfuscationRuleFile() {
22
26
  const obfuscationFilePath = framework_1.PluginFileUtil.pathResolve(this.context.config.modulePath, constants_1.FilePathConstants.OBFUSCATION_FILE_NAME);
23
- const routerMap = JSON.parse(framework_1.PluginFileUtil.readFileSync(this.context.config.getRouterMapDir()).toString()).routerMap;
27
+ let routerMap = [];
28
+ if (framework_1.PluginFileUtil.exist(this.context.config.getRouterMapDir())) {
29
+ routerMap = JSON.parse(framework_1.PluginFileUtil.readFileSync(this.context.config.getRouterMapDir()).toString()).routerMap;
30
+ }
24
31
  const obfuscationString = this.buildObfuscatedStrings(routerMap);
25
32
  framework_1.PluginFileUtil.ensureFileSync(obfuscationFilePath);
26
33
  framework_1.PluginFileUtil.writeFileSync(obfuscationFilePath, obfuscationString);
@@ -9,6 +9,11 @@ class ResourceProcessProcessor {
9
9
  }
10
10
  execute() {
11
11
  framework_1.Logger.debug(this.context.node.getNodeName(), `Start to copy router map to raw file...`);
12
+ const isHar = (0, framework_1.isHarModule)(this.context.node);
13
+ if ((isHar && !this.context.routerMap) || (isHar && this.context.routerMap.length === 0)) {
14
+ framework_1.Logger.info(this.context.node.getNodeName(), 'Skip copy router map');
15
+ return;
16
+ }
12
17
  this.copyRouterMapToRawFile();
13
18
  this.processHspModuleName();
14
19
  }
@@ -16,7 +21,9 @@ class ResourceProcessProcessor {
16
21
  let routerMapFilePath = framework_1.PluginFileUtil.pathResolve(this.context.currentTarget?.getBuildTargetOutputPath(), constants_1.FilePathConstants.TEMP_ROUTER_MAP_PATH, this.context.currentTarget?.getTargetName(), constants_1.RouterMapConstants.ROUTER_MAP_NAME);
17
22
  let rawFilePath = this.context.config.getRawFilePath();
18
23
  framework_1.PluginFileUtil.ensureFileSync(rawFilePath);
19
- framework_1.PluginFileUtil.copyFileSync(routerMapFilePath, rawFilePath);
24
+ if (framework_1.PluginFileUtil.exist(routerMapFilePath)) {
25
+ framework_1.PluginFileUtil.copyFileSync(routerMapFilePath, rawFilePath);
26
+ }
20
27
  framework_1.Logger.info(this.context.node.getNodeName(), `Copy router map to raw file successfully, filePath: ${rawFilePath}`);
21
28
  }
22
29
  processHspModuleName() {
@@ -38,7 +45,7 @@ class ResourceProcessProcessor {
38
45
  for (const remoteName of remoteHspModuleNames) {
39
46
  rawFileRouterMap.hspModulesInfo.push({
40
47
  moduleName: remoteName,
41
- packageName: remoteName
48
+ packageName: remoteName,
42
49
  });
43
50
  }
44
51
  framework_1.PluginFileUtil.writeFileSync(rawFilePath, JSON.stringify(rawFileRouterMap));
@@ -10,10 +10,15 @@ class RouterMapBuildingProcessor {
10
10
  }
11
11
  execute() {
12
12
  framework_1.Logger.debug(this.context.node.getNodeName(), `Start to build router map...`);
13
- this.readExistingRouterMap();
14
13
  for (const result of this.context.getAnalyzeResults()) {
15
14
  this.buildRouterMap(result);
16
15
  }
16
+ const isHar = (0, framework_1.isHarModule)(this.context.node);
17
+ if ((isHar && !this.context.routerMap) || (isHar && this.context.routerMap.length === 0)) {
18
+ framework_1.Logger.info(this.context.node.getNodeName(), `Skip generating routerMap`);
19
+ return;
20
+ }
21
+ this.readExistingRouterMap();
17
22
  this.generateRouterMapFile();
18
23
  }
19
24
  buildRouterMap(result) {
@@ -103,7 +108,7 @@ class RouterMapBuildingProcessor {
103
108
  readExistingRouterMap() {
104
109
  const moduleJsonOpt = this.context.moduleContext.getModuleJsonOpt();
105
110
  if (!moduleJsonOpt?.module.routerMap) {
106
- framework_1.Logger.debug(this.context.node.getNodeName(), `No routerMap found in the module configuration`);
111
+ framework_1.Logger.info(this.context.node.getNodeName(), `No routerMap found in the module configuration`);
107
112
  return;
108
113
  }
109
114
  const routerMapFileName = moduleJsonOpt.module.routerMap.split(':')[1];
@@ -113,7 +118,7 @@ class RouterMapBuildingProcessor {
113
118
  const systemRouterMap = routerMapObj[constants_1.RouterMapConstants.ROUTER_MAP_KEY];
114
119
  if (systemRouterMap && systemRouterMap.length > 0) {
115
120
  this.context.routerMap.unshift(...systemRouterMap);
116
- framework_1.Logger.debug(this.context.node.getNodeName(), `System routerMap added to the current routerMap`);
121
+ framework_1.Logger.info(this.context.node.getNodeName(), `System routerMap added to the current routerMap`);
117
122
  }
118
123
  }
119
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hadss/hmrouter-plugin",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "HMRouter Compiler Plugin",
5
5
  "main": "dist/Index.js",
6
6
  "scripts": {
@@ -8,7 +8,8 @@
8
8
  "test": "cross-env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
9
9
  "dev": "tsc && node dist/index.js",
10
10
  "build": "tsc",
11
- "release": "rm -rf ./dist && tsc && npm publish --access public"
11
+ "package": "rm -rf ./dist && npm i && npx tsc && npm pack",
12
+ "release": "rm -rf ./dist && npm i && npx tsc && npm publish --access public"
12
13
  },
13
14
  "keywords": [
14
15
  "hmrouter",
@@ -48,10 +48,10 @@ export struct <%= componentName %>Generated {
48
48
  .onDisAppear(()=>{this.helper.onDisAppear()})
49
49
  .onReady((ctx)=>{this.helper.onReady(ctx)})
50
50
  .onBackPressed(()=> this.helper.onBackPressed())
51
- .onResult((result:ESObject)=>{this.helper.onResult(result)})
52
- .onActive((activeReason:NavDestinationActiveReason)=>{this.helper.onActive(activeReason)})
53
- .onInactive((inactiveReason:NavDestinationActiveReason)=>{this.helper.onInactive(inactiveReason)})
54
- .onNewParam((newParam:ESObject)=>{this.helper.onNewParam(newParam)})
51
+ <% if(sdkVersion>=15){ %>.onResult((result:ESObject)=>{this.helper.onResult(result)})<% } %>
52
+ <% if(sdkVersion>=17){ %>.onActive((activeReason:NavDestinationActiveReason)=>{this.helper.onActive(activeReason)})<% } %>
53
+ <% if(sdkVersion>=17){ %>.onInactive((inactiveReason:NavDestinationActiveReason)=>{this.helper.onInactive(inactiveReason)})<% } %>
54
+ <% if(sdkVersion>=19){ %>.onNewParam((newParam:ESObject)=>{this.helper.onNewParam(newParam)})<% } %>
55
55
  }else if(this.helper.sdkApiVersion>=17){
56
56
  NavDestination() {
57
57
  <%= componentName %>()
@@ -70,9 +70,9 @@ export struct <%= componentName %>Generated {
70
70
  .onDisAppear(()=>{this.helper.onDisAppear()})
71
71
  .onReady((ctx)=>{this.helper.onReady(ctx)})
72
72
  .onBackPressed(()=> this.helper.onBackPressed())
73
- .onResult((result:ESObject)=>{this.helper.onResult(result)})
74
- .onActive((activeReason:NavDestinationActiveReason)=>{this.helper.onActive(activeReason)})
75
- .onInactive((inactiveReason:NavDestinationActiveReason)=>{this.helper.onInactive(inactiveReason)})
73
+ <% if(sdkVersion>=15){ %>.onResult((result:ESObject)=>{this.helper.onResult(result)})<% } %>
74
+ <% if(sdkVersion>=17){ %>.onActive((activeReason:NavDestinationActiveReason)=>{this.helper.onActive(activeReason)})<% } %>
75
+ <% if(sdkVersion>=17){ %>.onInactive((inactiveReason:NavDestinationActiveReason)=>{this.helper.onInactive(inactiveReason)})<% } %>
76
76
  }else if(this.helper.sdkApiVersion>=15){
77
77
  NavDestination() {
78
78
  <%= componentName %>()
@@ -91,7 +91,7 @@ export struct <%= componentName %>Generated {
91
91
  .onDisAppear(()=>{this.helper.onDisAppear()})
92
92
  .onReady((ctx)=>{this.helper.onReady(ctx)})
93
93
  .onBackPressed(()=> this.helper.onBackPressed())
94
- .onResult((result:ESObject)=>{this.helper.onResult(result)})
94
+ <% if(sdkVersion>=15){ %>.onResult((result:ESObject)=>{this.helper.onResult(result)})<% } %>
95
95
  }else{
96
96
  NavDestination() {
97
97
  <%= componentName %>()