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,62 +1,67 @@
1
- import React, { useEffect } from 'react'
2
- import type { NavigationItem } from './Options'
3
- import { Navigator, NavigationContext } from './Navigator'
4
- import Navigation from './Navigation'
1
+ import React, {useEffect} from 'react';
2
+ import type {NavigationItem} from './Options';
3
+ import {Navigator, NavigationContext} from './Navigator';
4
+ import Navigation from './Navigation';
5
5
 
6
6
  export interface NavigationProps {
7
- navigator: Navigator
8
- sceneId: string
7
+ navigator: Navigator;
8
+ sceneId: string;
9
9
  }
10
10
 
11
11
  interface NativeProps {
12
- sceneId: string
12
+ sceneId: string;
13
13
  }
14
14
 
15
15
  function getDisplayName(WrappedComponent: React.ComponentType<any>) {
16
- return WrappedComponent.displayName || WrappedComponent.name || 'Component'
16
+ return WrappedComponent.displayName || WrappedComponent.name || 'Component';
17
17
  }
18
18
 
19
19
  export function withNavigation(moduleName: string) {
20
- return function (WrappedComponent: React.ComponentType<any>) {
21
- const FC = React.forwardRef((props: NativeProps, ref: React.Ref<React.ComponentType<any>>) => {
22
- const { sceneId } = props
23
-
24
- const navigator = Navigator.of(sceneId)
25
- if (navigator.moduleName === undefined) {
26
- navigator.moduleName = moduleName
27
- }
28
-
29
- useEffect(() => {
30
- Navigation.signalFirstRenderComplete(sceneId)
31
- return () => {
32
- Navigator.unmount(sceneId)
33
- }
34
- }, [sceneId])
35
-
36
- const injected = {
37
- navigator,
38
- }
39
-
40
- return (
41
- <NavigationContext.Provider value={navigator}>
42
- <WrappedComponent ref={ref} {...props} {...injected} />
43
- </NavigationContext.Provider>
44
- )
45
- })
46
-
47
- FC.displayName = `withNavigation(${getDisplayName(WrappedComponent)})`
48
- return FC
49
- }
20
+ return function (WrappedComponent: React.ComponentType<any>) {
21
+ const FC = React.forwardRef(
22
+ (props: NativeProps, ref: React.Ref<React.ComponentType<any>>) => {
23
+ const {sceneId} = props;
24
+
25
+ const navigator = Navigator.of(sceneId);
26
+ if (navigator.moduleName === undefined) {
27
+ navigator.moduleName = moduleName;
28
+ }
29
+
30
+ useEffect(() => {
31
+ Navigation.signalFirstRenderComplete(sceneId);
32
+ return () => {
33
+ Navigator.unmount(sceneId);
34
+ };
35
+ }, [sceneId]);
36
+
37
+ const injected = {
38
+ navigator,
39
+ };
40
+
41
+ return (
42
+ <NavigationContext.Provider value={navigator}>
43
+ <WrappedComponent ref={ref} {...props} {...injected} />
44
+ </NavigationContext.Provider>
45
+ );
46
+ },
47
+ );
48
+
49
+ FC.displayName = `withNavigation(${getDisplayName(WrappedComponent)})`;
50
+ return FC;
51
+ };
50
52
  }
51
53
 
52
54
  export function withNavigationItem(item: NavigationItem) {
53
- return function (WrappedComponent: React.ComponentType<any>): React.ComponentType<any> {
54
- let navigationItem = (WrappedComponent as any).navigationItem
55
- if (navigationItem) {
56
- ;(WrappedComponent as any).navigationItem = { ...navigationItem, ...item }
57
- } else {
58
- ;(WrappedComponent as any).navigationItem = item
59
- }
60
- return WrappedComponent
61
- }
55
+ return function (WrappedComponent: React.ComponentType<any>): React.ComponentType<any> {
56
+ let navigationItem = (WrappedComponent as any).navigationItem;
57
+ if (navigationItem) {
58
+ (WrappedComponent as any).navigationItem = {
59
+ ...navigationItem,
60
+ ...item,
61
+ };
62
+ } else {
63
+ (WrappedComponent as any).navigationItem = item;
64
+ }
65
+ return WrappedComponent;
66
+ };
62
67
  }
@@ -1,123 +1,123 @@
1
- import { NativeModules } from 'react-native'
2
- import { Route, RouteGraph } from './Route'
1
+ import {NativeModules} from 'react-native';
2
+ import {Route, RouteGraph} from './Route';
3
3
 
4
- type Callback = (error: never, result: any) => void
4
+ type Callback = (error: never, result: any) => void;
5
5
 
6
6
  interface NavigationModule {
7
- getConstants: () => {
8
- RESULT_OK: number
9
- RESULT_CANCEL: number
10
- RESULT_BLOCK: number
11
- }
12
-
13
- startRegisterReactComponent: () => void
14
- endRegisterReactComponent: () => void
15
- registerReactComponent: (appKey: string, options: object) => void
16
- signalFirstRenderComplete: (sceneId: string) => void
17
- setRoot: (layout: object, sticky: boolean, callback: Callback) => void
18
- setResult: (sceneId: string, resultCode: number, data: object | null) => void
19
- dispatch: (sceneId: string, action: string, params: object, callback: Callback) => void
20
- currentTab: (sceneId: string, callback: Callback) => void
21
- isStackRoot: (sceneId: string, callback: Callback) => void
22
- findSceneIdByModuleName: (moduleName: string, callback: Callback) => void
23
- currentRoute: (callback: Callback) => void
24
- routeGraph: (callback: Callback) => void
7
+ getConstants: () => {
8
+ RESULT_OK: number;
9
+ RESULT_CANCEL: number;
10
+ RESULT_BLOCK: number;
11
+ };
12
+
13
+ startRegisterReactComponent: () => void;
14
+ endRegisterReactComponent: () => void;
15
+ registerReactComponent: (appKey: string, options: object) => void;
16
+ signalFirstRenderComplete: (sceneId: string) => void;
17
+ setRoot: (layout: object, sticky: boolean, callback: Callback) => void;
18
+ setResult: (sceneId: string, resultCode: number, data: object | null) => void;
19
+ dispatch: (sceneId: string, action: string, params: object, callback: Callback) => void;
20
+ currentTab: (sceneId: string, callback: Callback) => void;
21
+ isStackRoot: (sceneId: string, callback: Callback) => void;
22
+ findSceneIdByModuleName: (moduleName: string, callback: Callback) => void;
23
+ currentRoute: (callback: Callback) => void;
24
+ routeGraph: (callback: Callback) => void;
25
25
  }
26
26
 
27
- const NavigationModule: NavigationModule = NativeModules.NavigationModule
27
+ const NavigationModule: NavigationModule = NativeModules.NavigationModule;
28
28
 
29
29
  function getConstants() {
30
- return NavigationModule.getConstants()
30
+ return NavigationModule.getConstants();
31
31
  }
32
32
 
33
33
  function startRegisterReactComponent() {
34
- NavigationModule.startRegisterReactComponent()
34
+ NavigationModule.startRegisterReactComponent();
35
35
  }
36
36
 
37
37
  function endRegisterReactComponent() {
38
- NavigationModule.endRegisterReactComponent()
38
+ NavigationModule.endRegisterReactComponent();
39
39
  }
40
40
 
41
41
  function registerReactComponent(appKey: string, options: object) {
42
- NavigationModule.registerReactComponent(appKey, options)
42
+ NavigationModule.registerReactComponent(appKey, options);
43
43
  }
44
44
 
45
45
  function signalFirstRenderComplete(sceneId: string) {
46
- NavigationModule.signalFirstRenderComplete(sceneId)
46
+ NavigationModule.signalFirstRenderComplete(sceneId);
47
47
  }
48
48
 
49
49
  function setResult(sceneId: string, resultCode: number, data: object | null) {
50
- NavigationModule.setResult(sceneId, resultCode, data)
50
+ NavigationModule.setResult(sceneId, resultCode, data);
51
51
  }
52
52
 
53
53
  function setRoot(layout: object, sticky: boolean) {
54
- return new Promise<boolean>(resolve => {
55
- NavigationModule.setRoot(layout, sticky, (_, success) => {
56
- resolve(success)
57
- })
58
- })
54
+ return new Promise<boolean>(resolve => {
55
+ NavigationModule.setRoot(layout, sticky, (_, success) => {
56
+ resolve(success);
57
+ });
58
+ });
59
59
  }
60
60
 
61
61
  function dispatch(sceneId: string, action: string, params: object) {
62
- return new Promise<boolean>(resolve => {
63
- NavigationModule.dispatch(sceneId, action, params, (_, result) => {
64
- resolve(result)
65
- })
66
- })
62
+ return new Promise<boolean>(resolve => {
63
+ NavigationModule.dispatch(sceneId, action, params, (_, result) => {
64
+ resolve(result);
65
+ });
66
+ });
67
67
  }
68
68
 
69
69
  function currentTab(sceneId: string) {
70
- return new Promise<number>(resolve => {
71
- NavigationModule.currentTab(sceneId, (_, result) => {
72
- resolve(result)
73
- })
74
- })
70
+ return new Promise<number>(resolve => {
71
+ NavigationModule.currentTab(sceneId, (_, result) => {
72
+ resolve(result);
73
+ });
74
+ });
75
75
  }
76
76
 
77
77
  function isStackRoot(sceneId: string) {
78
- return new Promise<boolean>(resolve => {
79
- NavigationModule.isStackRoot(sceneId, (_, result) => {
80
- resolve(result)
81
- })
82
- })
78
+ return new Promise<boolean>(resolve => {
79
+ NavigationModule.isStackRoot(sceneId, (_, result) => {
80
+ resolve(result);
81
+ });
82
+ });
83
83
  }
84
84
 
85
85
  function findSceneIdByModuleName(moduleName: string) {
86
- return new Promise<string | null>(resolve => {
87
- NavigationModule.findSceneIdByModuleName(moduleName, (_, result) => {
88
- resolve(result)
89
- })
90
- })
86
+ return new Promise<string | null>(resolve => {
87
+ NavigationModule.findSceneIdByModuleName(moduleName, (_, result) => {
88
+ resolve(result);
89
+ });
90
+ });
91
91
  }
92
92
 
93
93
  function currentRoute() {
94
- return new Promise<Route>(resolve => {
95
- NavigationModule.currentRoute((_, result) => {
96
- resolve(result)
97
- })
98
- })
94
+ return new Promise<Route>(resolve => {
95
+ NavigationModule.currentRoute((_, result) => {
96
+ resolve(result);
97
+ });
98
+ });
99
99
  }
100
100
 
101
101
  function routeGraph() {
102
- return new Promise<RouteGraph[]>(resolve => {
103
- NavigationModule.routeGraph((_, result) => {
104
- resolve(result)
105
- })
106
- })
102
+ return new Promise<RouteGraph[]>(resolve => {
103
+ NavigationModule.routeGraph((_, result) => {
104
+ resolve(result);
105
+ });
106
+ });
107
107
  }
108
108
 
109
109
  export default {
110
- getConstants,
111
- startRegisterReactComponent,
112
- endRegisterReactComponent,
113
- registerReactComponent,
114
- signalFirstRenderComplete,
115
- setResult,
116
- setRoot,
117
- dispatch,
118
- currentTab,
119
- isStackRoot,
120
- findSceneIdByModuleName,
121
- currentRoute,
122
- routeGraph,
123
- }
110
+ getConstants,
111
+ startRegisterReactComponent,
112
+ endRegisterReactComponent,
113
+ registerReactComponent,
114
+ signalFirstRenderComplete,
115
+ setResult,
116
+ setRoot,
117
+ dispatch,
118
+ currentTab,
119
+ isStackRoot,
120
+ findSceneIdByModuleName,
121
+ currentRoute,
122
+ routeGraph,
123
+ };