hybrid-navigation 2.18.3 → 2.18.4

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.
Files changed (76) hide show
  1. package/LICENSE +1 -1
  2. package/{lib → dist}/Navigation.js +3 -2
  3. package/{lib → dist}/NavigationComponentWrap.js +6 -5
  4. package/{lib → dist}/Navigator.d.ts +0 -1
  5. package/{lib → dist}/Navigator.js +15 -4
  6. package/{lib → dist}/hooks.js +2 -1
  7. package/{lib → dist}/router/index.js +6 -2
  8. package/{lib → dist}/router/stack.js +1 -1
  9. package/ios/HybridNavigation/HBDUtils.h +2 -0
  10. package/ios/HybridNavigation/HBDUtils.m +12 -3
  11. package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +2 -6
  12. package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +11 -12
  13. package/ios/HybridNavigation/ViewController/HBDDrawerController.m +1 -1
  14. package/ios/HybridNavigation/ViewController/HBDNavigationController.m +1 -1
  15. package/ios/HybridNavigation/ViewController/HBDViewController.m +1 -1
  16. package/package.json +47 -78
  17. package/src/DeepLink.ts +52 -52
  18. package/src/Event.ts +88 -83
  19. package/src/GardenModule.ts +30 -30
  20. package/src/Navigation.ts +293 -281
  21. package/src/NavigationComponentWrap.tsx +52 -47
  22. package/src/NavigationModule.ts +77 -77
  23. package/src/Navigator.ts +212 -201
  24. package/src/Options.ts +120 -112
  25. package/src/Route.ts +59 -59
  26. package/src/handler/BarButtonEventHandler.ts +50 -46
  27. package/src/handler/DispatchCommandHandler.ts +56 -52
  28. package/src/handler/LayoutCommandHandler.ts +21 -21
  29. package/src/handler/ResultEventHandler.ts +63 -49
  30. package/src/handler/VisibilityEventHandler.ts +57 -40
  31. package/src/hooks.ts +23 -21
  32. package/src/index.ts +15 -15
  33. package/src/router/drawer.ts +24 -24
  34. package/src/router/index.ts +206 -198
  35. package/src/router/screen.ts +28 -28
  36. package/src/router/stack.ts +76 -76
  37. package/src/router/tabs.ts +28 -28
  38. package/src/store.ts +9 -9
  39. package/README.md +0 -79
  40. /package/{lib → dist}/DeepLink.d.ts +0 -0
  41. /package/{lib → dist}/DeepLink.js +0 -0
  42. /package/{lib → dist}/Event.d.ts +0 -0
  43. /package/{lib → dist}/Event.js +0 -0
  44. /package/{lib → dist}/GardenModule.d.ts +0 -0
  45. /package/{lib → dist}/GardenModule.js +0 -0
  46. /package/{lib → dist}/Navigation.d.ts +0 -0
  47. /package/{lib → dist}/NavigationComponentWrap.d.ts +0 -0
  48. /package/{lib → dist}/NavigationModule.d.ts +0 -0
  49. /package/{lib → dist}/NavigationModule.js +0 -0
  50. /package/{lib → dist}/Options.d.ts +0 -0
  51. /package/{lib → dist}/Options.js +0 -0
  52. /package/{lib → dist}/Route.d.ts +0 -0
  53. /package/{lib → dist}/Route.js +0 -0
  54. /package/{lib → dist}/handler/BarButtonEventHandler.d.ts +0 -0
  55. /package/{lib → dist}/handler/BarButtonEventHandler.js +0 -0
  56. /package/{lib → dist}/handler/DispatchCommandHandler.d.ts +0 -0
  57. /package/{lib → dist}/handler/DispatchCommandHandler.js +0 -0
  58. /package/{lib → dist}/handler/LayoutCommandHandler.d.ts +0 -0
  59. /package/{lib → dist}/handler/LayoutCommandHandler.js +0 -0
  60. /package/{lib → dist}/handler/ResultEventHandler.d.ts +0 -0
  61. /package/{lib → dist}/handler/ResultEventHandler.js +0 -0
  62. /package/{lib → dist}/handler/VisibilityEventHandler.d.ts +0 -0
  63. /package/{lib → dist}/handler/VisibilityEventHandler.js +0 -0
  64. /package/{lib → dist}/hooks.d.ts +0 -0
  65. /package/{lib → dist}/index.d.ts +0 -0
  66. /package/{lib → dist}/index.js +0 -0
  67. /package/{lib → dist}/router/drawer.d.ts +0 -0
  68. /package/{lib → dist}/router/drawer.js +0 -0
  69. /package/{lib → dist}/router/index.d.ts +0 -0
  70. /package/{lib → dist}/router/screen.d.ts +0 -0
  71. /package/{lib → dist}/router/screen.js +0 -0
  72. /package/{lib → dist}/router/stack.d.ts +0 -0
  73. /package/{lib → dist}/router/tabs.d.ts +0 -0
  74. /package/{lib → dist}/router/tabs.js +0 -0
  75. /package/{lib → dist}/store.d.ts +0 -0
  76. /package/{lib → dist}/store.js +0 -0
@@ -1,93 +1,93 @@
1
- import { ScreenGraph, isScreenGraph, isTargetLocateIn } from './screen'
2
- import { LayoutMode, RouteGraph, RouteHandler, RouteInfo } from '../Route'
3
- import Navigation from '../Navigation'
1
+ import {ScreenGraph, isScreenGraph, isTargetLocateIn} from './screen';
2
+ import {LayoutMode, RouteGraph, RouteHandler, RouteInfo} from '../Route';
3
+ import Navigation from '../Navigation';
4
4
 
5
5
  export interface StackGraph extends RouteGraph {
6
- layout: 'stack'
7
- sceneId: string
8
- mode: LayoutMode
9
- children: RouteGraph[]
6
+ layout: 'stack';
7
+ sceneId: string;
8
+ mode: LayoutMode;
9
+ children: RouteGraph[];
10
10
  }
11
11
 
12
12
  export function isStackGraph(graph: RouteGraph): graph is StackGraph {
13
- return graph.layout === 'stack'
13
+ return graph.layout === 'stack';
14
14
  }
15
15
 
16
16
  export class StackRouteHandler implements RouteHandler {
17
- async process(graph: RouteGraph, target: RouteInfo): Promise<[boolean, RouteGraph | null]> {
18
- if (!isStackGraph(graph)) {
19
- throw new Error(`${graph} is Not a StackGraph`)
20
- }
17
+ async process(graph: RouteGraph, target: RouteInfo): Promise<[boolean, RouteGraph | null]> {
18
+ if (!isStackGraph(graph)) {
19
+ throw new Error(`${graph} is Not a StackGraph`);
20
+ }
21
21
 
22
- const { children } = graph
22
+ const {children} = graph;
23
23
 
24
- for (let i = children.length - 1; i > -1; i--) {
25
- const childGraph = children[i]
26
- if (isTargetLocateIn(childGraph, target)) {
27
- if (isScreenGraph(childGraph)) {
28
- this.navigateTo(childGraph, target)
29
- return [true, null]
30
- }
24
+ for (let i = children.length - 1; i > -1; i--) {
25
+ const childGraph = children[i];
26
+ if (isTargetLocateIn(childGraph, target)) {
27
+ if (isScreenGraph(childGraph)) {
28
+ this.navigateTo(childGraph, target);
29
+ return [true, null];
30
+ }
31
31
 
32
- await this.popToIfNeeded(childGraph, i === children.length - 1)
33
- return [true, childGraph]
34
- }
35
- }
32
+ await this.popToIfNeeded(childGraph, i === children.length - 1);
33
+ return [true, childGraph];
34
+ }
35
+ }
36
36
 
37
- return [false, graph]
38
- }
37
+ return [false, graph];
38
+ }
39
39
 
40
- private async popToIfNeeded(childGraph: RouteGraph, isLastChildAtStack: boolean) {
41
- if (!isLastChildAtStack) {
42
- await Navigation.dispatch(childGraph.sceneId, 'popTo', {
43
- moduleName: childGraph.sceneId,
44
- })
45
- }
46
- }
40
+ private async popToIfNeeded(childGraph: RouteGraph, isLastChildAtStack: boolean) {
41
+ if (!isLastChildAtStack) {
42
+ await Navigation.dispatch(childGraph.sceneId, 'popTo', {
43
+ moduleName: childGraph.sceneId,
44
+ });
45
+ }
46
+ }
47
47
 
48
- private navigateTo(childGraph: ScreenGraph, target: RouteInfo) {
49
- const { mode, moduleName, dependencies, props } = target
50
- const expectations = [...dependencies, moduleName]
51
- const index = expectations.findIndex(name => name === childGraph.moduleName)
52
- const pendings = expectations.slice(index + 1)
53
- console.log('pendings', pendings, 'moduleName', childGraph.moduleName)
54
- const sceneId = childGraph.sceneId
48
+ private navigateTo(childGraph: ScreenGraph, target: RouteInfo) {
49
+ const {moduleName, dependencies, props} = target;
50
+ const expectations = [...dependencies, moduleName];
51
+ const index = expectations.findIndex(name => name === childGraph.moduleName);
52
+ const pendings = expectations.slice(index + 1);
53
+ console.log('pendings', pendings, 'moduleName', childGraph.moduleName);
54
+ const sceneId = childGraph.sceneId;
55
55
 
56
- const moduleExisting = pendings.length === 0
56
+ const moduleExisting = pendings.length === 0;
57
57
 
58
- if (moduleExisting) {
59
- if (JSON.stringify(props) === '{}') {
60
- Navigation.dispatch(sceneId, 'popTo', {
61
- moduleName,
62
- from: childGraph.moduleName,
63
- to: moduleName,
64
- })
65
- } else {
66
- Navigation.dispatch(sceneId, 'redirectTo', {
67
- moduleName,
68
- from: childGraph.moduleName,
69
- to: moduleName,
70
- props,
71
- })
72
- }
73
- } else {
74
- for (let i = 0; i < pendings.length; i++) {
75
- const isLast = i === pendings.length - 1
76
- if (isLast) {
77
- Navigation.dispatch(sceneId, 'push', {
78
- moduleName,
79
- from: childGraph.moduleName,
80
- to: moduleName,
81
- props,
82
- })
83
- } else {
84
- Navigation.dispatch(sceneId, 'push', {
85
- moduleName: pendings[i],
86
- from: childGraph.moduleName,
87
- to: pendings[i],
88
- })
89
- }
90
- }
91
- }
92
- }
58
+ if (moduleExisting) {
59
+ if (JSON.stringify(props) === '{}') {
60
+ Navigation.dispatch(sceneId, 'popTo', {
61
+ moduleName,
62
+ from: childGraph.moduleName,
63
+ to: moduleName,
64
+ });
65
+ } else {
66
+ Navigation.dispatch(sceneId, 'redirectTo', {
67
+ moduleName,
68
+ from: childGraph.moduleName,
69
+ to: moduleName,
70
+ props,
71
+ });
72
+ }
73
+ } else {
74
+ for (let i = 0; i < pendings.length; i++) {
75
+ const isLast = i === pendings.length - 1;
76
+ if (isLast) {
77
+ Navigation.dispatch(sceneId, 'push', {
78
+ moduleName,
79
+ from: childGraph.moduleName,
80
+ to: moduleName,
81
+ props,
82
+ });
83
+ } else {
84
+ Navigation.dispatch(sceneId, 'push', {
85
+ moduleName: pendings[i],
86
+ from: childGraph.moduleName,
87
+ to: pendings[i],
88
+ });
89
+ }
90
+ }
91
+ }
92
+ }
93
93
  }
@@ -1,39 +1,39 @@
1
- import { isTargetLocateIn } from './screen'
2
- import { LayoutMode, RouteGraph, RouteHandler, RouteInfo } from '../Route'
3
- import Navigation from '../Navigation'
1
+ import {isTargetLocateIn} from './screen';
2
+ import {LayoutMode, RouteGraph, RouteHandler, RouteInfo} from '../Route';
3
+ import Navigation from '../Navigation';
4
4
 
5
5
  export interface TabsGraph extends RouteGraph {
6
- layout: 'tabs'
7
- sceneId: string
8
- selectedIndex: number
9
- mode: LayoutMode
10
- children: RouteGraph[]
6
+ layout: 'tabs';
7
+ sceneId: string;
8
+ selectedIndex: number;
9
+ mode: LayoutMode;
10
+ children: RouteGraph[];
11
11
  }
12
12
 
13
13
  export function isTabsGraph(graph: RouteGraph): graph is TabsGraph {
14
- return graph.layout === 'tabs'
14
+ return graph.layout === 'tabs';
15
15
  }
16
16
  export class TabsRouteHandler implements RouteHandler {
17
- async process(graph: RouteGraph, target: RouteInfo): Promise<[boolean, RouteGraph]> {
18
- if (!isTabsGraph(graph)) {
19
- throw new Error(`${graph} is NOT a TabsGraph`)
20
- }
17
+ async process(graph: RouteGraph, target: RouteInfo): Promise<[boolean, RouteGraph]> {
18
+ if (!isTabsGraph(graph)) {
19
+ throw new Error(`${graph} is NOT a TabsGraph`);
20
+ }
21
21
 
22
- const { children, selectedIndex } = graph
22
+ const {children, selectedIndex} = graph;
23
23
 
24
- for (let i = 0; i < children.length; i++) {
25
- if (isTargetLocateIn(children[i], target)) {
26
- if (selectedIndex !== i) {
27
- await Navigation.dispatch(children[selectedIndex].sceneId, 'switchTab', {
28
- from: selectedIndex,
29
- to: i,
30
- popToRoot: true,
31
- })
32
- }
33
- return [true, children[i]]
34
- }
35
- }
24
+ for (let i = 0; i < children.length; i++) {
25
+ if (isTargetLocateIn(children[i], target)) {
26
+ if (selectedIndex !== i) {
27
+ await Navigation.dispatch(children[selectedIndex].sceneId, 'switchTab', {
28
+ from: selectedIndex,
29
+ to: i,
30
+ popToRoot: true,
31
+ });
32
+ }
33
+ return [true, children[i]];
34
+ }
35
+ }
36
36
 
37
- return [false, graph]
38
- }
37
+ return [false, graph];
38
+ }
39
39
  }
package/src/store.ts CHANGED
@@ -1,21 +1,21 @@
1
- import { Navigator } from './Navigator'
1
+ import {Navigator} from './Navigator';
2
2
 
3
- const navigators = new Map<string, Navigator>()
3
+ const navigators = new Map<string, Navigator>();
4
4
 
5
5
  function addNavigator(sceneId: string, navigator: Navigator) {
6
- navigators.set(sceneId, navigator)
6
+ navigators.set(sceneId, navigator);
7
7
  }
8
8
 
9
9
  function removeNavigator(sceneId: string) {
10
- navigators.delete(sceneId)
10
+ navigators.delete(sceneId);
11
11
  }
12
12
 
13
13
  function getNavigator(sceneId: string) {
14
- return navigators.get(sceneId)
14
+ return navigators.get(sceneId);
15
15
  }
16
16
 
17
17
  export default {
18
- addNavigator,
19
- removeNavigator,
20
- getNavigator,
21
- }
18
+ addNavigator,
19
+ removeNavigator,
20
+ getNavigator,
21
+ };
package/README.md DELETED
@@ -1,79 +0,0 @@
1
- # hybrid-navigation
2
-
3
- React Native Navigation that supports seamless navigation between Native and React.
4
-
5
- ## 特性
6
-
7
- - 使用原生导航组件实现 React Native 页面间的导航,不仅具有更优的性能,而且使得 RN 页面具有原生质感
8
- - 原生页面和 RN 页面共享路由, 使得它们之间相互跳转和传值轻而易举
9
- - 内置 drawer, tabs, stack 标准容器,同时支持自定义容器和导航
10
- - 支持 Deep Link
11
-
12
- ![navigation-android](./screenshot/android.png)
13
-
14
- ## Support
15
-
16
- | version | react-native version |
17
- | ------- | -------------------- |
18
- | 1.0.0+ | 0.60.0+ |
19
-
20
- ## 运行 example 项目
21
-
22
- 首先 clone 本项目
23
-
24
- ```shell
25
- git clone git@github.com:listenzz/hybrid-navigation.git
26
- cd hybrid-navigation
27
- ```
28
-
29
- 然后在项目根目录下运行如下命令:
30
-
31
- ```shell
32
- yarn install
33
- # &
34
- yarn start
35
- ```
36
-
37
- ### 在 Android 上运行
38
-
39
- 首先,确保你有一个模拟器或设备
40
-
41
- 如果熟悉原生开发,使用 Android Studio 打开 example/android,像运行原生应用那样运行它,也可以使用命令行:
42
-
43
- ```sh
44
- # 在项目根目录下运行
45
- yarn android
46
- ```
47
-
48
- 你可能需要运行如下命令,才可以使用 Hot Reload 功能
49
-
50
- ```sh
51
- adb reverse tcp:8081 tcp:8081
52
- ```
53
-
54
- [**Download demo apk**](https://todoit.oss-cn-shanghai.aliyuncs.com/app-release.apk)
55
-
56
- 或通过扫描二维码安装 demo
57
-
58
- ![README-2021-10-19-15-58-19](https://todoit.oss-cn-shanghai.aliyuncs.com/todoit/README-2021-10-19-15-58-19.png)
59
-
60
- ### 在 iOS 上运行
61
-
62
- 首先安装 cocoapods 依赖,在项目根目录下运行如下命令:
63
-
64
- ```sh
65
- cd example/ios && pod install
66
- # 成功安装依赖后,回到根目录
67
- cd -
68
- ```
69
-
70
- 如果熟悉原生开发,使用 Xcode 打开 example/ios,像运行原生应用那样运行它,或者使用命令行:
71
-
72
- ```sh
73
- # 在项目根目录下运行
74
- yarn ios
75
- ```
76
-
77
- ## 文档
78
-
79
- [从这里开始](https://todoit.tech/rn/hybrid-navigation/)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes