@hadss/hmrouter-plugin 1.0.0-rc.10 → 1.0.0-rc.11

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.
@@ -199,6 +199,9 @@ class AnalyzerService {
199
199
  parseIdentifierPropertyValue(value) {
200
200
  switch (value.getKind()) {
201
201
  case ts_morph_1.SyntaxKind.Identifier:
202
+ if (value.getText() === 'undefined') {
203
+ throw new Error(`Invalid property value, in ${this.sourceFilePath}`);
204
+ }
202
205
  return {
203
206
  type: 'constant',
204
207
  variableName: value.getText(),
@@ -96,6 +96,10 @@ class HMRouterHvigorPlugin {
96
96
  let serviceName = CommonConstants_1.default.SERVICE_PREFIX + analyzeResult.serviceName;
97
97
  this.routerMap.push(new PluginModel_1.RouterInfo(serviceName, pageSourceFile, '', analyzeResult));
98
98
  break;
99
+ case CommonConstants_1.default.SERVICE_PROVIDE_ANNOTATION:
100
+ let className = CommonConstants_1.default.SERVICE_PROVIDE_PREFIX + analyzeResult.serviceName;
101
+ this.routerMap.push(new PluginModel_1.RouterInfo(className, pageSourceFile, '', analyzeResult));
102
+ break;
99
103
  }
100
104
  }
101
105
  generateBuilder(analyzeResult, pageSourceFile, tempFilePath) {
@@ -21,7 +21,8 @@ class HMRouterPluginConfig {
21
21
  ConfigConstants_1.default.ANIMATOR_ANNOTATION,
22
22
  ConfigConstants_1.default.INTERCEPTOR_ANNOTATION,
23
23
  ConfigConstants_1.default.LIFECYCLE_ANNOTATION,
24
- ConfigConstants_1.default.SERVICE_ANNOTATION
24
+ ConfigConstants_1.default.SERVICE_ANNOTATION,
25
+ ConfigConstants_1.default.SERVICE_PROVIDE_ANNOTATION
25
26
  ];
26
27
  this.defaultPageTemplate =
27
28
  param.defaultPageTemplate ? param.defaultPageTemplate : ConfigConstants_1.default.DEFAULT_BUILD_TPL;
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HMRouterPluginHandle = void 0;
7
- const hvigor_1 = require("@ohos/hvigor");
8
7
  const hvigor_ohos_plugin_1 = require("@ohos/hvigor-ohos-plugin");
9
8
  const HMRouterPluginConfig_1 = require("./HMRouterPluginConfig");
10
9
  const HMRouterHvigorPlugin_1 = require("./HMRouterHvigorPlugin");
@@ -124,16 +123,8 @@ class HMRouterPluginHandle {
124
123
  return;
125
124
  let rawFilePath = this.config.getRawFilePath();
126
125
  let rawFileRouterMap = JSON.parse(FileUtil_1.default.readFileSync(rawFilePath).toString());
127
- rawFileRouterMap.hspModuleNames = [];
128
- hvigor_1.hvigor.getAllNodes().forEach((node) => {
129
- let pluginIds = node.getAllPluginIds();
130
- if (pluginIds.includes(hvigor_ohos_plugin_1.OhosPluginId.OHOS_HSP_PLUGIN)) {
131
- let packageJson = FileUtil_1.default.readJson5(FileUtil_1.default.pathResolve(node.getNodePath(), 'oh-package.json5'));
132
- rawFileRouterMap.hspModuleNames.push(packageJson.name);
133
- }
134
- rawFileRouterMap.hspModuleNames.push(...this.getRemoteHspModuleNames(node, pluginIds));
135
- });
136
- rawFileRouterMap.hspModuleNames = [...new Set(rawFileRouterMap.hspModuleNames)];
126
+ rawFileRouterMap.hspModuleNames = [...new Set(PluginStore_1.default.getInstance().hspModuleNames)];
127
+ rawFileRouterMap.hspModuleNames.push(...this.getRemoteHspModuleNames(this.node, this.node.getAllPluginIds()));
137
128
  FileUtil_1.default.writeFileSync(rawFilePath, JSON.stringify(rawFileRouterMap));
138
129
  }
139
130
  getRemoteHspModuleNames(node, pluginIds) {
package/dist/Index.js CHANGED
@@ -13,6 +13,7 @@ const CommonConstants_1 = __importDefault(require("./constants/CommonConstants")
13
13
  const TsAstUtil_1 = require("./utils/TsAstUtil");
14
14
  const FileUtil_1 = __importDefault(require("./utils/FileUtil"));
15
15
  const HMRouterPluginHandle_1 = require("./HMRouterPluginHandle");
16
+ const PluginStore_1 = __importDefault(require("./store/PluginStore"));
16
17
  class HMRouterPluginMgr {
17
18
  constructor() {
18
19
  this.hmRouterPluginSet = new Set();
@@ -46,10 +47,13 @@ class HMRouterPluginMgr {
46
47
  throw new Error('moduleContext is null');
47
48
  }
48
49
  let pluginHandle = new HMRouterPluginHandle_1.HMRouterPluginHandle(node, moduleContext);
50
+ let packageJson = FileUtil_1.default.readJson5(FileUtil_1.default.pathResolve(node.getNodePath(), 'oh-package.json5'));
49
51
  if (pluginId === hvigor_ohos_plugin_1.OhosPluginId.OHOS_HAP_PLUGIN) {
50
- let packageJson = FileUtil_1.default.readJson5(FileUtil_1.default.pathResolve(node.getNodePath(), 'oh-package.json5'));
51
52
  pluginHandle.config.moduleName = packageJson.name;
52
53
  }
54
+ if (pluginId === hvigor_ohos_plugin_1.OhosPluginId.OHOS_HSP_PLUGIN) {
55
+ PluginStore_1.default.getInstance().hspModuleNames.push(packageJson.name);
56
+ }
53
57
  this.hmRouterPluginSet.add(pluginHandle);
54
58
  }
55
59
  deleteGeneratorFile(pluginHandle) {
@@ -3,11 +3,9 @@ export default class HMRouterPluginConstant {
3
3
  static readonly INTERCEPTOR_PREFIX = "__interceptor__";
4
4
  static readonly LIFECYCLE_PREFIX = "__lifecycle__";
5
5
  static readonly SERVICE_PREFIX = "__service__";
6
- static readonly PAGE_URL_PREFIX = "";
6
+ static readonly SERVICE_PROVIDE_PREFIX = "__service_provider__";
7
7
  static readonly OBFUSCATION_FILE_NAME = "hmrouter-obfuscation-rules.txt";
8
8
  static readonly CONSUMER_FILE_NAME = "hmrouter-consumer-rules.txt";
9
- static readonly VARIABLE_SEPARATOR = "__";
10
- static readonly PAGE_URL = "pageUrl";
11
9
  static readonly ROUTER_MAP_KEY = "routerMap";
12
10
  static readonly FILE_SEPARATOR: "\\" | "/";
13
11
  static readonly DELIMITER = "/";
@@ -27,6 +25,7 @@ export default class HMRouterPluginConstant {
27
25
  static readonly INTERCEPTOR_ANNOTATION = "HMInterceptor";
28
26
  static readonly LIFECYCLE_ANNOTATION = "HMLifecycle";
29
27
  static readonly SERVICE_ANNOTATION = "HMService";
28
+ static readonly SERVICE_PROVIDE_ANNOTATION = "HMServiceProvider";
30
29
  static readonly CONFIG_FILE_NAME = "hmrouter_config.json";
31
30
  static readonly PARENT_DELIMITER = "../";
32
31
  static readonly CURRENT_DELIMITER = "./";
@@ -10,11 +10,9 @@ HMRouterPluginConstant.ANIMATOR_PREFIX = '__animator__';
10
10
  HMRouterPluginConstant.INTERCEPTOR_PREFIX = '__interceptor__';
11
11
  HMRouterPluginConstant.LIFECYCLE_PREFIX = '__lifecycle__';
12
12
  HMRouterPluginConstant.SERVICE_PREFIX = '__service__';
13
- HMRouterPluginConstant.PAGE_URL_PREFIX = '';
13
+ HMRouterPluginConstant.SERVICE_PROVIDE_PREFIX = '__service_provider__';
14
14
  HMRouterPluginConstant.OBFUSCATION_FILE_NAME = 'hmrouter-obfuscation-rules.txt';
15
15
  HMRouterPluginConstant.CONSUMER_FILE_NAME = 'hmrouter-consumer-rules.txt';
16
- HMRouterPluginConstant.VARIABLE_SEPARATOR = '__';
17
- HMRouterPluginConstant.PAGE_URL = 'pageUrl';
18
16
  HMRouterPluginConstant.ROUTER_MAP_KEY = 'routerMap';
19
17
  HMRouterPluginConstant.FILE_SEPARATOR = path_1.default.sep;
20
18
  HMRouterPluginConstant.DELIMITER = '/';
@@ -34,6 +32,7 @@ HMRouterPluginConstant.ANIMATOR_ANNOTATION = 'HMAnimator';
34
32
  HMRouterPluginConstant.INTERCEPTOR_ANNOTATION = 'HMInterceptor';
35
33
  HMRouterPluginConstant.LIFECYCLE_ANNOTATION = 'HMLifecycle';
36
34
  HMRouterPluginConstant.SERVICE_ANNOTATION = 'HMService';
35
+ HMRouterPluginConstant.SERVICE_PROVIDE_ANNOTATION = 'HMServiceProvider';
37
36
  HMRouterPluginConstant.CONFIG_FILE_NAME = 'hmrouter_config.json';
38
37
  HMRouterPluginConstant.PARENT_DELIMITER = '../';
39
38
  HMRouterPluginConstant.CURRENT_DELIMITER = './';
@@ -8,4 +8,5 @@ export default class ConfigConstants {
8
8
  static readonly INTERCEPTOR_ANNOTATION = "HMInterceptor";
9
9
  static readonly LIFECYCLE_ANNOTATION = "HMLifecycle";
10
10
  static readonly SERVICE_ANNOTATION = "HMService";
11
+ static readonly SERVICE_PROVIDE_ANNOTATION = "HMServiceProvider";
11
12
  }
@@ -11,5 +11,6 @@ ConfigConstants.ANIMATOR_ANNOTATION = 'HMAnimator';
11
11
  ConfigConstants.INTERCEPTOR_ANNOTATION = 'HMInterceptor';
12
12
  ConfigConstants.LIFECYCLE_ANNOTATION = 'HMLifecycle';
13
13
  ConfigConstants.SERVICE_ANNOTATION = 'HMService';
14
+ ConfigConstants.SERVICE_PROVIDE_ANNOTATION = 'HMServiceProvider';
14
15
  exports.default = ConfigConstants;
15
16
  ;
@@ -2,11 +2,13 @@ export default class PluginStore implements IPluginStore {
2
2
  private static instance;
3
3
  variableCache: Map<string, Map<string, string[]>>;
4
4
  projectFilePath: string;
5
+ hspModuleNames: string[];
5
6
  static clear(): void;
6
7
  static getInstance(): IPluginStore;
7
8
  }
8
9
  interface IPluginStore {
9
10
  variableCache: Map<string, Map<string, string[]>>;
10
11
  projectFilePath: string;
12
+ hspModuleNames: string[];
11
13
  }
12
14
  export {};
@@ -4,6 +4,7 @@ class PluginStore {
4
4
  constructor() {
5
5
  this.variableCache = new Map();
6
6
  this.projectFilePath = '';
7
+ this.hspModuleNames = [];
7
8
  }
8
9
  static clear() {
9
10
  this.instance = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hadss/hmrouter-plugin",
3
- "version": "1.0.0-rc.10",
3
+ "version": "1.0.0-rc.11",
4
4
  "description": "HMRouter Compiler Plugin",
5
5
  "main": "dist/Index.js",
6
6
  "scripts": {
@@ -43,4 +43,4 @@
43
43
  "type": "git",
44
44
  "url": "https://gitee.com/hadss/hmrouter"
45
45
  }
46
- }
46
+ }