@granite-js/react-native 0.1.13 → 0.1.14
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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +0 -1
- package/package.json +9 -9
- package/src/index.ts +0 -1
- package/src/router/utils/screen.tsx +6 -0
- package/dist/react/index.d.ts +0 -1
- package/dist/react/useWaitForReturnNavigator.d.ts +0 -39
- package/src/react/index.ts +0 -1
- package/src/react/useWaitForReturnNavigator.ts +0 -75
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @granite-js/react-native
|
|
2
2
|
|
|
3
|
+
## 0.1.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0520d19: Fix type error
|
|
8
|
+
- a06bb7d: Remove useWaitForReturnNavigator
|
|
9
|
+
- 6d38bc5: Clarify error message for missing \_404 Page
|
|
10
|
+
- @granite-js/cli@0.1.14
|
|
11
|
+
- @granite-js/image@0.1.14
|
|
12
|
+
- @granite-js/jest@0.1.14
|
|
13
|
+
- @granite-js/lottie@0.1.14
|
|
14
|
+
- @granite-js/mpack@0.1.14
|
|
15
|
+
- @granite-js/native@0.1.14
|
|
16
|
+
- @granite-js/plugin-core@0.1.14
|
|
17
|
+
- @granite-js/style-utils@0.1.14
|
|
18
|
+
|
|
3
19
|
## 0.1.13
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export * from './keyboard';
|
|
|
11
11
|
export * from './intersection-observer';
|
|
12
12
|
export * from './impression-area';
|
|
13
13
|
export * from './scroll-view-inertial-background';
|
|
14
|
-
export * from './react';
|
|
15
14
|
export * from './router/createRoute';
|
|
16
15
|
export * from './event';
|
|
17
16
|
export * from './video';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "The Granite Framework",
|
|
5
5
|
"bin": {
|
|
6
6
|
"granite": "./bin/cli.js"
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@babel/core": "^7.24.9",
|
|
75
75
|
"@babel/preset-env": "^7.24.8",
|
|
76
76
|
"@babel/preset-typescript": "^7.24.7",
|
|
77
|
-
"@granite-js/native": "0.1.
|
|
77
|
+
"@granite-js/native": "0.1.14",
|
|
78
78
|
"@testing-library/dom": "^10.4.0",
|
|
79
79
|
"@testing-library/react": "^16.1.0",
|
|
80
80
|
"@types/babel__core": "^7",
|
|
@@ -100,13 +100,13 @@
|
|
|
100
100
|
"react-native": "*"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@granite-js/cli": "0.1.
|
|
104
|
-
"@granite-js/image": "0.1.
|
|
105
|
-
"@granite-js/jest": "0.1.
|
|
106
|
-
"@granite-js/lottie": "0.1.
|
|
107
|
-
"@granite-js/mpack": "0.1.
|
|
108
|
-
"@granite-js/plugin-core": "0.1.
|
|
109
|
-
"@granite-js/style-utils": "0.1.
|
|
103
|
+
"@granite-js/cli": "0.1.14",
|
|
104
|
+
"@granite-js/image": "0.1.14",
|
|
105
|
+
"@granite-js/jest": "0.1.14",
|
|
106
|
+
"@granite-js/lottie": "0.1.14",
|
|
107
|
+
"@granite-js/mpack": "0.1.14",
|
|
108
|
+
"@granite-js/plugin-core": "0.1.14",
|
|
109
|
+
"@granite-js/style-utils": "0.1.14",
|
|
110
110
|
"es-toolkit": "^1.39.8",
|
|
111
111
|
"react-native-url-polyfill": "1.3.0"
|
|
112
112
|
}
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,6 @@ export * from './keyboard';
|
|
|
13
13
|
export * from './intersection-observer';
|
|
14
14
|
export * from './impression-area';
|
|
15
15
|
export * from './scroll-view-inertial-background';
|
|
16
|
-
export * from './react';
|
|
17
16
|
export * from './router/createRoute';
|
|
18
17
|
export * from './event';
|
|
19
18
|
export * from './video';
|
|
@@ -72,6 +72,12 @@ export function getScreenPathMapConfig(routeScreens: RouteScreen[]) {
|
|
|
72
72
|
path: '',
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
+
const notFoundPage = routeScreens.find((screen) => screen.path === '/_404');
|
|
76
|
+
|
|
77
|
+
if (notFoundPage == null) {
|
|
78
|
+
throw new Error('404 page not found. Please create a `_404.ts` or `_404.tsx` file in the `pages/*` folder.');
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
// https://reactnavigation.org/docs/configuring-links/#handling-unmatched-routes-or-404
|
|
76
82
|
screensConfig['/_404'] = {
|
|
77
83
|
path: '*',
|
package/dist/react/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useWaitForReturnNavigator } from './useWaitForReturnNavigator';
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
* @category Screen Control
|
|
4
|
-
* @name useWaitForReturnNavigator
|
|
5
|
-
* @description
|
|
6
|
-
* A Hook that helps execute the next code synchronously when returning from a screen transition.
|
|
7
|
-
* Screen navigation uses [@react-navigation/native `useNavigation`'s `navigate`](https://reactnavigation.org/docs/6.x/navigation-prop#navigate).
|
|
8
|
-
*
|
|
9
|
-
* For example, it can be used when you want to log that a user has navigated to another screen and returned.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ### Example of code execution when returning from screen navigation
|
|
13
|
-
*
|
|
14
|
-
* When the **"Navigate"** button is pressed, it navigates to another screen, and logs are created when returning.
|
|
15
|
-
*
|
|
16
|
-
* ```tsx
|
|
17
|
-
* import { Button } from 'react-native';
|
|
18
|
-
* import { useWaitForReturnNavigator } from '@granite-js/react-native';
|
|
19
|
-
*
|
|
20
|
-
* export function UseWaitForReturnNavigator() {
|
|
21
|
-
* const navigate = useWaitForReturnNavigator();
|
|
22
|
-
*
|
|
23
|
-
* return (
|
|
24
|
-
* <>
|
|
25
|
-
* <Button
|
|
26
|
-
* title="Navigate"
|
|
27
|
-
* onPress={async () => {
|
|
28
|
-
* console.log(1);
|
|
29
|
-
* await navigate('/examples/use-visibility');
|
|
30
|
-
* // This code executes when returning to the screen
|
|
31
|
-
* console.log(2);
|
|
32
|
-
* }}
|
|
33
|
-
* />
|
|
34
|
-
* </>
|
|
35
|
-
* );
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare function useWaitForReturnNavigator<T extends Record<string, object | undefined>>(): <RouteName extends keyof T>(route: RouteName, params?: T[RouteName]) => Promise<void>;
|
package/src/react/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useWaitForReturnNavigator } from './useWaitForReturnNavigator';
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { useNavigation } from '@granite-js/native/@react-navigation/native';
|
|
2
|
-
import { NativeStackNavigationProp } from '@granite-js/native/@react-navigation/native-stack';
|
|
3
|
-
import { useCallback, useRef } from 'react';
|
|
4
|
-
import { useVisibilityChange, type VisibilityState } from '../visibility';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
* @category Screen Control
|
|
9
|
-
* @name useWaitForReturnNavigator
|
|
10
|
-
* @description
|
|
11
|
-
* A Hook that helps execute the next code synchronously when returning from a screen transition.
|
|
12
|
-
* Screen navigation uses [@react-navigation/native `useNavigation`'s `navigate`](https://reactnavigation.org/docs/6.x/navigation-prop#navigate).
|
|
13
|
-
*
|
|
14
|
-
* For example, it can be used when you want to log that a user has navigated to another screen and returned.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ### Example of code execution when returning from screen navigation
|
|
18
|
-
*
|
|
19
|
-
* When the **"Navigate"** button is pressed, it navigates to another screen, and logs are created when returning.
|
|
20
|
-
*
|
|
21
|
-
* ```tsx
|
|
22
|
-
* import { Button } from 'react-native';
|
|
23
|
-
* import { useWaitForReturnNavigator } from '@granite-js/react-native';
|
|
24
|
-
*
|
|
25
|
-
* export function UseWaitForReturnNavigator() {
|
|
26
|
-
* const navigate = useWaitForReturnNavigator();
|
|
27
|
-
*
|
|
28
|
-
* return (
|
|
29
|
-
* <>
|
|
30
|
-
* <Button
|
|
31
|
-
* title="Navigate"
|
|
32
|
-
* onPress={async () => {
|
|
33
|
-
* console.log(1);
|
|
34
|
-
* await navigate('/examples/use-visibility');
|
|
35
|
-
* // This code executes when returning to the screen
|
|
36
|
-
* console.log(2);
|
|
37
|
-
* }}
|
|
38
|
-
* />
|
|
39
|
-
* </>
|
|
40
|
-
* );
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
export function useWaitForReturnNavigator<T extends Record<string, object | undefined>>() {
|
|
46
|
-
const callbacks = useRef<Array<() => void>>([]).current;
|
|
47
|
-
const navigation = useNavigation<NativeStackNavigationProp<T>>();
|
|
48
|
-
|
|
49
|
-
const startNavigating = useCallback(
|
|
50
|
-
<RouteName extends keyof T>(route: RouteName, params?: T[RouteName]): Promise<void> => {
|
|
51
|
-
return new Promise<void>((resolve) => {
|
|
52
|
-
callbacks.push(resolve);
|
|
53
|
-
navigation.navigate(route as any, params as any);
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
[callbacks, navigation]
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const handleVisibilityChange = useCallback(
|
|
60
|
-
(state: VisibilityState) => {
|
|
61
|
-
if (state === 'visible' && callbacks.length > 0) {
|
|
62
|
-
for (const callback of callbacks) {
|
|
63
|
-
callback();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
callbacks.splice(0, callbacks.length);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
[callbacks]
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
useVisibilityChange(handleVisibilityChange);
|
|
73
|
-
|
|
74
|
-
return startNavigating;
|
|
75
|
-
}
|