@granite-js/react-native 0.1.31 → 0.1.32
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
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @granite-js/react-native
|
|
2
2
|
|
|
3
|
+
## 0.1.32
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 74b2223: fix(react-native): VisibilityChangedProvider only provider
|
|
8
|
+
- 7572713: bump version up babel
|
|
9
|
+
- Updated dependencies [74b2223]
|
|
10
|
+
- Updated dependencies [7572713]
|
|
11
|
+
- @granite-js/native@0.1.32
|
|
12
|
+
- @granite-js/plugin-core@0.1.32
|
|
13
|
+
- @granite-js/style-utils@0.1.32
|
|
14
|
+
- @granite-js/image@0.1.32
|
|
15
|
+
- @granite-js/mpack@0.1.32
|
|
16
|
+
- @granite-js/cli@0.1.32
|
|
17
|
+
- @granite-js/jest@0.1.32
|
|
18
|
+
- @granite-js/lottie@0.1.32
|
|
19
|
+
|
|
3
20
|
## 0.1.31
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -7,8 +7,9 @@ interface Props {
|
|
|
7
7
|
* @name VisibilityProvider
|
|
8
8
|
* @description
|
|
9
9
|
* A Provider that manages whether a ReactNative view is currently in the foreground state.
|
|
10
|
+
* It subscribes to the app's `visibilityChanged` event to detect and manage screen visibility.
|
|
10
11
|
* @param {boolean} isVisible - Whether the app is in the foreground state.
|
|
11
|
-
* @param {ReactNode | undefined} children - Child components that observe `AppState
|
|
12
|
+
* @param {ReactNode | undefined} children - Child components that observe `visibilityChanged` and `AppState` event.
|
|
12
13
|
* @returns {ReactElement} - A React Provider component wrapped with `VisibilityChangedProvider`.
|
|
13
14
|
* @example
|
|
14
15
|
* ```typescript
|
|
@@ -3,8 +3,7 @@ import { PropsWithChildren, ReactElement } from 'react';
|
|
|
3
3
|
* @name VisibilityChangedProvider
|
|
4
4
|
* @kind function
|
|
5
5
|
* @description
|
|
6
|
-
* A Provider that manages whether a React Native screen is visible.
|
|
7
|
-
* It subscribes to the app's `visibilityChanged` event to detect and manage screen visibility.
|
|
6
|
+
* A Provider that manages whether a React Native screen is visible provider.
|
|
8
7
|
*
|
|
9
8
|
* @param {ReactNode | undefined} children - Child components that check screen visibility.
|
|
10
9
|
* @param {boolean} isVisible - A boolean value indicating whether the screen is visible.
|
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.32",
|
|
4
4
|
"description": "The Granite Framework",
|
|
5
5
|
"bin": {
|
|
6
6
|
"granite": "./bin/cli.js"
|
|
@@ -88,10 +88,10 @@
|
|
|
88
88
|
"*.d.ts"
|
|
89
89
|
],
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@babel/core": "
|
|
92
|
-
"@babel/preset-env": "
|
|
93
|
-
"@babel/preset-typescript": "
|
|
94
|
-
"@granite-js/native": "0.1.
|
|
91
|
+
"@babel/core": "7.28.5",
|
|
92
|
+
"@babel/preset-env": "7.28.5",
|
|
93
|
+
"@babel/preset-typescript": "7.28.5",
|
|
94
|
+
"@granite-js/native": "0.1.32",
|
|
95
95
|
"@testing-library/dom": "^10.4.0",
|
|
96
96
|
"@testing-library/react": "^16.1.0",
|
|
97
97
|
"@types/babel__core": "^7",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@types/node": "^22.10.2",
|
|
100
100
|
"@types/react": "18.3.3",
|
|
101
101
|
"@types/react-dom": "^18",
|
|
102
|
-
"@vitest/coverage-v8": "^
|
|
102
|
+
"@vitest/coverage-v8": "^4.0.12",
|
|
103
103
|
"esbuild": "0.25.8",
|
|
104
104
|
"eslint": "^9.7.0",
|
|
105
105
|
"jsdom": "^25.0.1",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"react-native": "0.72.6",
|
|
109
109
|
"tsup": "^8.5.0",
|
|
110
110
|
"typescript": "5.8.3",
|
|
111
|
-
"vitest": "^
|
|
111
|
+
"vitest": "^4.0.12",
|
|
112
112
|
"zod": "^4.1.12"
|
|
113
113
|
},
|
|
114
114
|
"peerDependencies": {
|
|
@@ -118,13 +118,13 @@
|
|
|
118
118
|
"react-native": "*"
|
|
119
119
|
},
|
|
120
120
|
"dependencies": {
|
|
121
|
-
"@granite-js/cli": "0.1.
|
|
122
|
-
"@granite-js/image": "0.1.
|
|
123
|
-
"@granite-js/jest": "0.1.
|
|
124
|
-
"@granite-js/lottie": "0.1.
|
|
125
|
-
"@granite-js/mpack": "0.1.
|
|
126
|
-
"@granite-js/plugin-core": "0.1.
|
|
127
|
-
"@granite-js/style-utils": "0.1.
|
|
121
|
+
"@granite-js/cli": "0.1.32",
|
|
122
|
+
"@granite-js/image": "0.1.32",
|
|
123
|
+
"@granite-js/jest": "0.1.32",
|
|
124
|
+
"@granite-js/lottie": "0.1.32",
|
|
125
|
+
"@granite-js/mpack": "0.1.32",
|
|
126
|
+
"@granite-js/plugin-core": "0.1.32",
|
|
127
|
+
"@granite-js/style-utils": "0.1.32",
|
|
128
128
|
"@standard-schema/spec": "^1.0.0",
|
|
129
129
|
"es-toolkit": "^1.39.8",
|
|
130
130
|
"react-native-url-polyfill": "3.0.0"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from 'react';
|
|
1
|
+
import { ReactElement, ReactNode, useEffect, useState } from 'react';
|
|
2
2
|
import { AppStateProvider } from './useIsAppForeground';
|
|
3
3
|
import { VisibilityChangedProvider } from './useVisibilityChanged';
|
|
4
|
+
import { nativeEventEmitter } from '../native-event-emitter/nativeEventEmitter';
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
isVisible: boolean;
|
|
@@ -11,8 +12,9 @@ interface Props {
|
|
|
11
12
|
* @name VisibilityProvider
|
|
12
13
|
* @description
|
|
13
14
|
* A Provider that manages whether a ReactNative view is currently in the foreground state.
|
|
15
|
+
* It subscribes to the app's `visibilityChanged` event to detect and manage screen visibility.
|
|
14
16
|
* @param {boolean} isVisible - Whether the app is in the foreground state.
|
|
15
|
-
* @param {ReactNode | undefined} children - Child components that observe `AppState
|
|
17
|
+
* @param {ReactNode | undefined} children - Child components that observe `visibilityChanged` and `AppState` event.
|
|
16
18
|
* @returns {ReactElement} - A React Provider component wrapped with `VisibilityChangedProvider`.
|
|
17
19
|
* @example
|
|
18
20
|
* ```typescript
|
|
@@ -28,8 +30,20 @@ interface Props {
|
|
|
28
30
|
* ```
|
|
29
31
|
*/
|
|
30
32
|
export function VisibilityProvider({ isVisible, children }: Props): ReactElement {
|
|
33
|
+
const [visible, setVisible] = useState(isVisible);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const subscription = nativeEventEmitter.addListener('visibilityChanged', (nextVisible) => {
|
|
37
|
+
setVisible(nextVisible);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return () => {
|
|
41
|
+
subscription.remove();
|
|
42
|
+
};
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
31
45
|
return (
|
|
32
|
-
<VisibilityChangedProvider isVisible={
|
|
46
|
+
<VisibilityChangedProvider isVisible={visible}>
|
|
33
47
|
<AppStateProvider>{children}</AppStateProvider>
|
|
34
48
|
</VisibilityChangedProvider>
|
|
35
49
|
);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createContext, PropsWithChildren, ReactElement, useContext
|
|
2
|
-
import { nativeEventEmitter } from '../native-event-emitter';
|
|
1
|
+
import { createContext, PropsWithChildren, ReactElement, useContext } from 'react';
|
|
3
2
|
|
|
4
3
|
const VisibilityChangedContext = createContext<boolean | undefined>(undefined);
|
|
5
4
|
|
|
@@ -7,8 +6,7 @@ const VisibilityChangedContext = createContext<boolean | undefined>(undefined);
|
|
|
7
6
|
* @name VisibilityChangedProvider
|
|
8
7
|
* @kind function
|
|
9
8
|
* @description
|
|
10
|
-
* A Provider that manages whether a React Native screen is visible.
|
|
11
|
-
* It subscribes to the app's `visibilityChanged` event to detect and manage screen visibility.
|
|
9
|
+
* A Provider that manages whether a React Native screen is visible provider.
|
|
12
10
|
*
|
|
13
11
|
* @param {ReactNode | undefined} children - Child components that check screen visibility.
|
|
14
12
|
* @param {boolean} isVisible - A boolean value indicating whether the screen is visible.
|
|
@@ -28,19 +26,7 @@ export function VisibilityChangedProvider({
|
|
|
28
26
|
children,
|
|
29
27
|
isVisible,
|
|
30
28
|
}: PropsWithChildren<{ isVisible: boolean }>): ReactElement {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const subscription = nativeEventEmitter.addListener('visibilityChanged', (nextVisible) => {
|
|
35
|
-
setVisible(nextVisible);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return () => {
|
|
39
|
-
subscription.remove();
|
|
40
|
-
};
|
|
41
|
-
}, []);
|
|
42
|
-
|
|
43
|
-
return <VisibilityChangedContext.Provider value={visible}>{children}</VisibilityChangedContext.Provider>;
|
|
29
|
+
return <VisibilityChangedContext.Provider value={isVisible}>{children}</VisibilityChangedContext.Provider>;
|
|
44
30
|
}
|
|
45
31
|
|
|
46
32
|
/**
|