hybrid-navigation 2.13.5 → 2.13.6
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/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +4 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +10 -12
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +3 -3
- package/ios/HybridNavigation/GlobalStyle.m +3 -0
- package/ios/HybridNavigation/ReactBridge/HBDReactBridgeManager.m +2 -6
- package/lib/DeepLink.d.ts +10 -6
- package/lib/DeepLink.js +46 -47
- package/lib/Route.d.ts +1 -1
- package/lib/router/index.d.ts +4 -1
- package/package.json +2 -2
- package/src/DeepLink.ts +45 -46
- package/src/Route.ts +1 -1
- package/src/router/index.ts +1 -1
|
@@ -194,19 +194,17 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
194
194
|
UiThreadUtil.runOnUiThread(this, 16);
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
|
+
|
|
198
|
+
FragmentManager fragmentManager = activity.getSupportFragmentManager();
|
|
199
|
+
Fragment fragment = fragmentManager.findFragmentById(android.R.id.content);
|
|
200
|
+
if (!(fragment instanceof AwesomeFragment)) {
|
|
201
|
+
callback.invoke(null, null);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
197
204
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (!(fragment instanceof AwesomeFragment)) {
|
|
202
|
-
callback.invoke(null, null);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
String sceneId = findSceneIdByModuleName(moduleName, (AwesomeFragment) fragment);
|
|
207
|
-
FLog.i(TAG, "The sceneId found by " + moduleName + " : " + sceneId);
|
|
208
|
-
callback.invoke(null, sceneId);
|
|
209
|
-
});
|
|
205
|
+
String sceneId = findSceneIdByModuleName(moduleName, (AwesomeFragment) fragment);
|
|
206
|
+
FLog.i(TAG, "The sceneId found by " + moduleName + " : " + sceneId);
|
|
207
|
+
callback.invoke(null, sceneId);
|
|
210
208
|
}
|
|
211
209
|
};
|
|
212
210
|
|
|
@@ -68,7 +68,7 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
68
68
|
public void inflateStyle() {
|
|
69
69
|
Style style = getStyle();
|
|
70
70
|
GlobalStyle globalStyle = Garden.getGlobalStyle();
|
|
71
|
-
if (style != null &&
|
|
71
|
+
if (style != null && !isFinishing()) {
|
|
72
72
|
styleInflated = true;
|
|
73
73
|
FLog.i(TAG, "ReactAppCompatActivity#inflateStyle");
|
|
74
74
|
globalStyle.inflateStyle(this, style);
|
|
@@ -160,7 +160,7 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
160
160
|
}
|
|
161
161
|
HBDEventEmitter.sendEvent(HBDEventEmitter.EVENT_DID_SET_ROOT, Arguments.createMap());
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
|
|
164
164
|
@Override
|
|
165
165
|
protected void onPause() {
|
|
166
166
|
activityDelegate.onPause();
|
|
@@ -177,7 +177,7 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
177
177
|
}
|
|
178
178
|
activityDelegate.onResume();
|
|
179
179
|
}
|
|
180
|
-
|
|
180
|
+
|
|
181
181
|
@Override
|
|
182
182
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
183
183
|
activityDelegate.onActivityResult(requestCode, resultCode, data);
|
|
@@ -188,12 +188,8 @@ const NSInteger ResultCancel = 0;
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
- (UIViewController *)viewControllerBySceneId:(NSString *)sceneId {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return [self viewControllerWithSceneId:sceneId viewController:window.rootViewController];
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return nil;
|
|
191
|
+
UIWindow *window = [self mainWindow];
|
|
192
|
+
return [self viewControllerWithSceneId:sceneId viewController:window.rootViewController];
|
|
197
193
|
}
|
|
198
194
|
|
|
199
195
|
- (UIViewController *)viewControllerWithSceneId:(NSString *)sceneId viewController:(UIViewController *)vc {
|
package/lib/DeepLink.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
declare class DeepLinkImpl {
|
|
2
|
+
private active;
|
|
3
|
+
private uriPrefix;
|
|
4
|
+
private hasHandleInitialURL;
|
|
5
|
+
private subscription;
|
|
6
|
+
activate(uriPrefix: string): void;
|
|
7
|
+
deactivate(): void;
|
|
8
|
+
private handleLinking;
|
|
9
|
+
}
|
|
10
|
+
export declare const DeepLink: DeepLinkImpl;
|
|
7
11
|
export {};
|
package/lib/DeepLink.js
CHANGED
|
@@ -1,55 +1,54 @@
|
|
|
1
1
|
import { Linking } from 'react-native';
|
|
2
2
|
import { router } from './router';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
class DeepLinkImpl {
|
|
4
|
+
active = 0;
|
|
5
|
+
uriPrefix = '';
|
|
6
|
+
hasHandleInitialURL = false;
|
|
7
|
+
subscription = null;
|
|
8
|
+
activate(uriPrefix) {
|
|
9
|
+
if (!uriPrefix) {
|
|
10
|
+
throw new Error('must pass `uriPrefix` when activate router.');
|
|
11
|
+
}
|
|
12
|
+
if (this.active === 0) {
|
|
13
|
+
this.uriPrefix = uriPrefix;
|
|
14
|
+
if (!this.hasHandleInitialURL) {
|
|
15
|
+
this.hasHandleInitialURL = true;
|
|
16
|
+
Linking.getInitialURL()
|
|
17
|
+
.then(url => {
|
|
18
|
+
if (url) {
|
|
19
|
+
console.info(`deeplink:${url}`);
|
|
20
|
+
const path = url.replace(this.uriPrefix, '');
|
|
21
|
+
return router.open(path);
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
.catch(err => console.error('An error occurred', err));
|
|
25
|
+
}
|
|
26
|
+
this.subscription = Linking.addEventListener('url', this.handleLinking);
|
|
24
27
|
}
|
|
25
|
-
|
|
28
|
+
this.active++;
|
|
26
29
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
deactivate() {
|
|
31
|
+
this.active--;
|
|
32
|
+
if (this.active === 0) {
|
|
33
|
+
if (this.subscription) {
|
|
34
|
+
this.subscription.remove();
|
|
35
|
+
this.subscription = null;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
Linking.removeEventListener('url', this.handleLinking);
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
if (this.active < 0) {
|
|
42
|
+
this.active = 0;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
path = '/' + path;
|
|
49
|
-
}
|
|
50
|
-
router.open(path);
|
|
45
|
+
handleLinking = (event) => {
|
|
46
|
+
console.info(`deeplink:${event.url}`);
|
|
47
|
+
let path = event.url.replace(this.uriPrefix, '');
|
|
48
|
+
if (!path.startsWith('/')) {
|
|
49
|
+
path = '/' + path;
|
|
50
|
+
}
|
|
51
|
+
router.open(path);
|
|
52
|
+
};
|
|
51
53
|
}
|
|
52
|
-
export const DeepLink =
|
|
53
|
-
activate,
|
|
54
|
-
deactivate,
|
|
55
|
-
};
|
|
54
|
+
export const DeepLink = new DeepLinkImpl();
|
package/lib/Route.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export interface RouteHandler {
|
|
|
72
72
|
/**
|
|
73
73
|
* @param graph - current RouteGraph to process
|
|
74
74
|
* @param target - route may add to the graph
|
|
75
|
-
* @
|
|
75
|
+
* @returns [boolean, RouteGraph] - if the route is handled, return true and childGraph for next Handler to process, [false, graph] otherwise
|
|
76
76
|
*/
|
|
77
77
|
process: (graph: RouteGraph, target: RouteInfo) => Promise<[boolean, RouteGraph | null]>;
|
|
78
78
|
}
|
package/lib/router/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { RouteHandler, RouteInterceptor } from '../Route';
|
|
2
2
|
import { NavigationItem } from '../Options';
|
|
3
|
+
interface IndexType {
|
|
4
|
+
[index: string]: any;
|
|
5
|
+
}
|
|
3
6
|
declare class Router {
|
|
4
7
|
constructor();
|
|
5
8
|
private handlers;
|
|
@@ -16,7 +19,7 @@ declare class Router {
|
|
|
16
19
|
private pathToRoute;
|
|
17
20
|
private routeDependencies;
|
|
18
21
|
private processRoute;
|
|
19
|
-
open(path: string, props?:
|
|
22
|
+
open(path: string, props?: IndexType, options?: NavigationItem): Promise<void>;
|
|
20
23
|
}
|
|
21
24
|
export declare const router: Router;
|
|
22
25
|
export * from './drawer';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hybrid-navigation",
|
|
3
3
|
"description": "React Native Navigation that supports seamless navigation between Native and React.",
|
|
4
|
-
"version": "2.13.
|
|
4
|
+
"version": "2.13.6",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"react-test-renderer": "17.0.2",
|
|
70
70
|
"redux": "^4.1.1",
|
|
71
71
|
"typescript": "^4.6.4",
|
|
72
|
-
"vuepress": "
|
|
72
|
+
"vuepress": "2.0.0-beta.51",
|
|
73
73
|
"zustand": "^3.7.1"
|
|
74
74
|
}
|
|
75
75
|
}
|
package/src/DeepLink.ts
CHANGED
|
@@ -1,60 +1,59 @@
|
|
|
1
1
|
import { EmitterSubscription, Linking } from 'react-native'
|
|
2
2
|
import { router } from './router'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
class DeepLinkImpl {
|
|
5
|
+
private active = 0
|
|
6
|
+
private uriPrefix = ''
|
|
7
|
+
private hasHandleInitialURL = false
|
|
8
|
+
private subscription: EmitterSubscription | null = null
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
activate(uriPrefix: string) {
|
|
11
|
+
if (!uriPrefix) {
|
|
12
|
+
throw new Error('must pass `uriPrefix` when activate router.')
|
|
13
|
+
}
|
|
14
|
+
if (this.active === 0) {
|
|
15
|
+
this.uriPrefix = uriPrefix
|
|
16
|
+
if (!this.hasHandleInitialURL) {
|
|
17
|
+
this.hasHandleInitialURL = true
|
|
18
|
+
Linking.getInitialURL()
|
|
19
|
+
.then(url => {
|
|
20
|
+
if (url) {
|
|
21
|
+
console.info(`deeplink:${url}`)
|
|
22
|
+
const path = url.replace(this.uriPrefix, '')
|
|
23
|
+
return router.open(path)
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
.catch(err => console.error('An error occurred', err))
|
|
27
|
+
}
|
|
28
|
+
this.subscription = Linking.addEventListener('url', this.handleLinking)
|
|
26
29
|
}
|
|
27
|
-
|
|
30
|
+
this.active++
|
|
28
31
|
}
|
|
29
|
-
_active++
|
|
30
|
-
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
deactivate() {
|
|
34
|
+
this.active--
|
|
35
|
+
if (this.active === 0) {
|
|
36
|
+
if (this.subscription) {
|
|
37
|
+
this.subscription.remove()
|
|
38
|
+
this.subscription = null
|
|
39
|
+
} else {
|
|
40
|
+
Linking.removeEventListener('url', this.handleLinking)
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
|
-
}
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if (this.active < 0) {
|
|
45
|
+
this.active = 0
|
|
46
|
+
}
|
|
45
47
|
}
|
|
46
|
-
}
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
private handleLinking = (event: { url: string }) => {
|
|
50
|
+
console.info(`deeplink:${event.url}`)
|
|
51
|
+
let path = event.url.replace(this.uriPrefix, '')
|
|
52
|
+
if (!path.startsWith('/')) {
|
|
53
|
+
path = '/' + path
|
|
54
|
+
}
|
|
55
|
+
router.open(path)
|
|
53
56
|
}
|
|
54
|
-
router.open(path)
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
export const DeepLink =
|
|
58
|
-
activate,
|
|
59
|
-
deactivate,
|
|
60
|
-
}
|
|
59
|
+
export const DeepLink = new DeepLinkImpl()
|
package/src/Route.ts
CHANGED
|
@@ -85,7 +85,7 @@ export interface RouteHandler {
|
|
|
85
85
|
/**
|
|
86
86
|
* @param graph - current RouteGraph to process
|
|
87
87
|
* @param target - route may add to the graph
|
|
88
|
-
* @
|
|
88
|
+
* @returns [boolean, RouteGraph] - if the route is handled, return true and childGraph for next Handler to process, [false, graph] otherwise
|
|
89
89
|
*/
|
|
90
90
|
process: (graph: RouteGraph, target: RouteInfo) => Promise<[boolean, RouteGraph | null]>
|
|
91
91
|
}
|
package/src/router/index.ts
CHANGED
|
@@ -151,7 +151,7 @@ class Router {
|
|
|
151
151
|
return consumed
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
async open(path: string, props:
|
|
154
|
+
async open(path: string, props: IndexType = {}, options: NavigationItem = {}) {
|
|
155
155
|
this.inflateRouteData()
|
|
156
156
|
|
|
157
157
|
const intercepted = await this.intercept(path)
|