@hadss/hmrouter-plugin 1.0.0-rc.9 → 1.1.0-beta.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hadss/hmrouter-plugin",
3
- "version": "1.0.0-rc.9",
3
+ "version": "1.1.0-beta.0",
4
4
  "description": "HMRouter Compiler Plugin",
5
5
  "main": "dist/Index.js",
6
6
  "scripts": {
@@ -8,7 +8,6 @@
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
- "package": "tsc && npm pack && mv hadss*.tgz ../libs",
12
11
  "release": "tsc && npm publish --access public"
13
12
  },
14
13
  "keywords": [
@@ -24,8 +23,9 @@
24
23
  "ts-morph": "^23.0.0"
25
24
  },
26
25
  "devDependencies": {
27
- "@ohos/hvigor": "5.7.4",
28
- "@ohos/hvigor-ohos-plugin": "5.7.4",
26
+ "@ohos/hvigor": "^5.8.9",
27
+ "@ohos/hvigor-ohos-plugin": "^5.8.9",
28
+ "typescript": "4.9.5",
29
29
  "@types/chai": "^4.3.19",
30
30
  "@types/ejs": "^3.1.5",
31
31
  "@types/micromatch": "^4.0.9",
@@ -39,9 +39,10 @@
39
39
  "publishConfig": {
40
40
  "registry": "https://registry.npmjs.org"
41
41
  },
42
- "homepage": "https://gitee.com/hadss/hmrouter",
42
+ "homepage": "https://gitcode.com/openharmony-sig/ohrouter",
43
43
  "repository": {
44
44
  "type": "git",
45
- "url": "https://gitee.com/hadss/hmrouter"
45
+ "url": "git+https://gitcode.com/openharmony-sig/ohrouter.git",
46
+ "directory": "HMRouterPlugin"
46
47
  }
47
- }
48
+ }
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ // auto-generated <%= componentName %>Builder.ets by HMRouter
17
+ import <%if(isDefaultExport) {%> <%= componentName %> <% } else {%> { <%= componentName %> } <% } %> from '<%= importPath %>'
18
+
19
+ @Builder
20
+ export function <%= componentName %>Builder(name: string, param: Object) {
21
+ <%= componentName %>()
22
+ }
23
+
24
+ export const <%= componentName %>BuilderWrapBuilder = wrapBuilder(<%= componentName %>Builder)
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ // auto-generated <%= componentName %>Builder.ets by HMRouter
17
+ import <%if(isDefaultExport) {%> <%= componentName %> <% } else {%> { <%= componentName %> } <% } %> from '<%= importPath %>'
18
+ import { NavDestinationHelper } from '@hadss/hmrouter';
19
+
20
+ @Builder
21
+ export function <%= componentName %>Builder(name: string, param: Object) {
22
+ <%= componentName %>Generated()
23
+ }
24
+
25
+ export const <%= componentName %>BuilderWrapBuilder = wrapBuilder(<%= componentName %>Builder)
26
+
27
+ @Component
28
+ export struct <%= componentName %>Generated {
29
+ private helper: NavDestinationHelper = new NavDestinationHelper(this);
30
+
31
+ build() {
32
+ NavDestination() {
33
+ <%= componentName %>()
34
+ }
35
+ <% if(dialog){ %>.mode(NavDestinationMode.DIALOG)<% } %>
36
+ .hideTitleBar(true)
37
+ .attributeModifier(this.helper.modifier)
38
+ .gestureModifier(this.helper.gestureModifier)
39
+ .onWillAppear(()=>{this.helper.onWillAppear()})
40
+ .onAppear(() => {this.helper.onAppear()})
41
+ .onWillShow(()=>{this.helper.onWillAppear()})
42
+ .onShown(()=>{this.helper.onShown()})
43
+ .onWillHide(()=>{this.helper.onWillHide()})
44
+ .onHidden(()=>{this.helper.onHidden()})
45
+ .onWillDisappear(()=>{this.helper.onWillDisappear()})
46
+ .onDisAppear(()=>{this.helper.onDisAppear()})
47
+ .onReady((ctx)=>{this.helper.onReady(ctx)})
48
+ .onBackPressed(()=> this.helper.onBackPressed())
49
+ }
50
+ }
@@ -1,27 +0,0 @@
1
- export declare class HMRouterPluginConstant {
2
- static readonly ANIMATOR_PREFIX = "__animator__";
3
- static readonly INTERCEPTOR_PREFIX = "__interceptor__";
4
- static readonly LIFECYCLE_PREFIX = "__lifecycle__";
5
- static readonly SERVICE_PREFIX = "__service__";
6
- static readonly PAGE_URL_PREFIX = "";
7
- static readonly FILE_SEPARATOR: "\\" | "/";
8
- static readonly DELIMITER = "/";
9
- static readonly MODULE_ROUTER_MAP_NAME = "$profile:hm_router_map";
10
- static readonly ROUTER_MAP_NAME = "hm_router_map.json";
11
- static readonly TEMP_ROUTER_MAP_PATH = "../../intermediates/router_map";
12
- static readonly RAWFILE_DIR = "src/main/resources/rawfile/hm_router_map.json";
13
- static readonly VIEW_NAME_PREFIX = "HM";
14
- static readonly VIEW_NAME_SUFFIX = ".ets";
15
- static readonly JSON_SUFFIX = ".json";
16
- static readonly HAP_PLUGIN_ID = "HAP_HMROUTER_PLUGIN";
17
- static readonly HSP_PLUGIN_ID = "HSP_HMROUTER_PLUGIN";
18
- static readonly HAR_PLUGIN_ID = "HAR_HMROUTER_PLUGIN";
19
- static readonly ROUTER_ANNOTATION = "HMRouter";
20
- static readonly ANIMATOR_ANNOTATION = "HMAnimator";
21
- static readonly INTERCEPTOR_ANNOTATION = "HMInterceptor";
22
- static readonly LIFECYCLE_ANNOTATION = "HMLifecycle";
23
- static readonly SERVICE_ANNOTATION = "HMService";
24
- static readonly CLASS_ANNOTATION_ARR: string[];
25
- static readonly CONFIG_FILE_NAME = "hmrouter_config.json";
26
- static readonly PARENT_DELIMITER = "../";
27
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.HMRouterPluginConstant = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- class HMRouterPluginConstant {
9
- }
10
- exports.HMRouterPluginConstant = HMRouterPluginConstant;
11
- HMRouterPluginConstant.ANIMATOR_PREFIX = '__animator__';
12
- HMRouterPluginConstant.INTERCEPTOR_PREFIX = '__interceptor__';
13
- HMRouterPluginConstant.LIFECYCLE_PREFIX = '__lifecycle__';
14
- HMRouterPluginConstant.SERVICE_PREFIX = '__service__';
15
- HMRouterPluginConstant.PAGE_URL_PREFIX = '';
16
- HMRouterPluginConstant.FILE_SEPARATOR = path_1.default.sep;
17
- HMRouterPluginConstant.DELIMITER = '/';
18
- HMRouterPluginConstant.MODULE_ROUTER_MAP_NAME = '$profile:hm_router_map';
19
- HMRouterPluginConstant.ROUTER_MAP_NAME = 'hm_router_map.json';
20
- HMRouterPluginConstant.TEMP_ROUTER_MAP_PATH = '../../intermediates/router_map';
21
- HMRouterPluginConstant.RAWFILE_DIR = 'src/main/resources/rawfile/hm_router_map.json';
22
- HMRouterPluginConstant.VIEW_NAME_PREFIX = 'HM';
23
- HMRouterPluginConstant.VIEW_NAME_SUFFIX = '.ets';
24
- HMRouterPluginConstant.JSON_SUFFIX = '.json';
25
- HMRouterPluginConstant.HAP_PLUGIN_ID = 'HAP_HMROUTER_PLUGIN';
26
- HMRouterPluginConstant.HSP_PLUGIN_ID = 'HSP_HMROUTER_PLUGIN';
27
- HMRouterPluginConstant.HAR_PLUGIN_ID = 'HAR_HMROUTER_PLUGIN';
28
- HMRouterPluginConstant.ROUTER_ANNOTATION = 'HMRouter';
29
- HMRouterPluginConstant.ANIMATOR_ANNOTATION = 'HMAnimator';
30
- HMRouterPluginConstant.INTERCEPTOR_ANNOTATION = 'HMInterceptor';
31
- HMRouterPluginConstant.LIFECYCLE_ANNOTATION = 'HMLifecycle';
32
- HMRouterPluginConstant.SERVICE_ANNOTATION = 'HMService';
33
- HMRouterPluginConstant.CLASS_ANNOTATION_ARR = ['HMAnimator', 'HMInterceptor', 'HMLifecycle'];
34
- HMRouterPluginConstant.CONFIG_FILE_NAME = 'hmrouter_config.json';
35
- HMRouterPluginConstant.PARENT_DELIMITER = '../';
@@ -1,4 +0,0 @@
1
- import { RouterInfo } from '../common/PluginModel';
2
- export default class ConfusionUtil {
3
- static buildObfuscatedStrings(routerMap: RouterInfo[]): string;
4
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const CommonConstants_1 = __importDefault(require("../constants/CommonConstants"));
7
- class ConfusionUtil {
8
- static buildObfuscatedStrings(routerMap) {
9
- let srcPathArr = [...new Set(routerMap.map((routerInfo) => {
10
- return CommonConstants_1.default.CURRENT_DELIMITER + routerInfo.pageSourceFile;
11
- }))];
12
- let classNameArr = [...new Set(routerMap.filter((routerInfo) => {
13
- return routerInfo.name.includes('__');
14
- }).map((routerInfo) => {
15
- return routerInfo.customData.name;
16
- }))];
17
- let functionName = [...new Set(routerMap.filter((routerInfo) => {
18
- return routerInfo.name.includes(CommonConstants_1.default.SERVICE_PREFIX);
19
- }).map((routerInfo) => {
20
- return routerInfo.customData.functionName;
21
- }))];
22
- return CommonConstants_1.default.KEEP_FILE_NAME + CommonConstants_1.default.LINE_BREAK +
23
- srcPathArr.concat(CommonConstants_1.default.KEEP_PROPERTY_NAME, classNameArr, functionName)
24
- .join(CommonConstants_1.default.LINE_BREAK);
25
- }
26
- }
27
- exports.default = ConfusionUtil;
package/viewBuilder.ejs DELETED
@@ -1,97 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- // auto-generated <%= componentName %>Builder.ets by HMRouter
17
- import { <%= componentName %> } from '<%= importPath %>'
18
- import { TemplateService, TranslateOption, ScaleOption, OpacityOption } from '@hadss/hmrouter'
19
-
20
- @Builder
21
- export function <%= componentName %>Builder(name: string, param: Object) {
22
- <%= componentName %>Generated()
23
- }
24
-
25
- @Component
26
- export struct <%= componentName %>Generated {
27
- @State translateOption: TranslateOption = new TranslateOption()
28
- @State scaleOption: ScaleOption = new ScaleOption()
29
- @State opacityOption: OpacityOption = new OpacityOption()
30
- private pageUrl: string = '<%= pageUrl %>'
31
- private ndId: string = ''
32
- private navigationId: string = ''
33
-
34
- aboutToAppear(): void {
35
- this.navigationId = this.queryNavigationInfo()!.navigationId;
36
- TemplateService.aboutToAppear(this.navigationId, this.pageUrl, <%= dialog %>,
37
- this.translateOption, this.scaleOption, this.opacityOption)
38
- }
39
-
40
- aboutToDisappear(): void {
41
- TemplateService.aboutToDisappear(this.navigationId, this.pageUrl, this.ndId)
42
- }
43
-
44
- build() {
45
- NavDestination() {
46
- <%= componentName %>()
47
- }
48
- <% if(dialog){ %>.mode(NavDestinationMode.DIALOG)<% } %>
49
- .hideTitleBar(true)
50
- .hitTestBehavior(HitTestMode.Transparent)
51
- .gesture(PanGesture()
52
- .onActionStart((event: GestureEvent) => {
53
- TemplateService.interactiveStart(this.navigationId, this.ndId, event)
54
- })
55
- .onActionUpdate((event: GestureEvent) =>{
56
- TemplateService.interactiveProgress(this.navigationId, this.ndId, event)
57
- })
58
- .onActionEnd((event: GestureEvent) =>{
59
- TemplateService.interactiveFinish(this.navigationId, this.ndId, event)
60
- })
61
- )
62
- .translate(this.translateOption)
63
- .scale(this.scaleOption)
64
- .opacity(this.opacityOption.opacity)
65
- .onAppear(() => {
66
- TemplateService.onAppear(this.navigationId, this.pageUrl, this.ndId)
67
- })
68
- .onDisAppear(() => {
69
- TemplateService.onDisAppear(this.navigationId, this.pageUrl, this.ndId)
70
- })
71
- .onShown(() => {
72
- TemplateService.onShown(this.navigationId, this.pageUrl, this.ndId)
73
- })
74
- .onHidden(() => {
75
- TemplateService.onHidden(this.navigationId, this.pageUrl, this.ndId)
76
- })
77
- .onWillAppear(() => {
78
- TemplateService.onWillAppear(this.navigationId, this.pageUrl)
79
- })
80
- .onWillDisappear(() => {
81
- TemplateService.onWillDisappear(this.navigationId, this.pageUrl, this.ndId)
82
- })
83
- .onWillShow(() => {
84
- TemplateService.onWillShow(this.navigationId, this.pageUrl, this.ndId)
85
- })
86
- .onWillHide(() => {
87
- TemplateService.onWillHide(this.navigationId, this.pageUrl, this.ndId)
88
- })
89
- .onReady((navContext: NavDestinationContext) => {
90
- this.ndId = navContext.navDestinationId!
91
- TemplateService.onReady(this.navigationId, this.pageUrl, navContext)
92
- })
93
- .onBackPressed(() => {
94
- return TemplateService.onBackPressed(this.navigationId, this.pageUrl, this.ndId)
95
- })
96
- }
97
- }