@granite-js/react-native 0.1.23-next.10 → 0.1.23-next.12
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 +30 -0
- package/dist/app/AppRoot.d.ts +1 -1
- package/dist/app/Granite.d.ts +8 -1
- package/dist/native-event-emitter/nativeEventEmitter.d.ts +1 -5
- package/dist/native-modules/core/GraniteCoreModule.d.ts +1 -1
- package/dist/native-modules/natives/GraniteModule.d.ts +1 -1
- package/dist/router/Router.d.ts +1 -1
- package/dist/router/hooks/useRouterControls.d.ts +2 -1
- package/package.json +10 -10
- package/src/app/AppRoot.tsx +4 -1
- package/src/app/Granite.tsx +10 -1
- package/src/router/Router.tsx +5 -4
- package/src/router/hooks/useRouterControls.tsx +13 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @granite-js/react-native
|
|
2
2
|
|
|
3
|
+
## 0.1.23-next.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @granite-js/plugin-core@0.1.23-next.12
|
|
10
|
+
- @granite-js/style-utils@0.1.23-next.12
|
|
11
|
+
- @granite-js/lottie@0.1.23-next.12
|
|
12
|
+
- @granite-js/native@0.1.23-next.12
|
|
13
|
+
- @granite-js/image@0.1.23-next.12
|
|
14
|
+
- @granite-js/mpack@0.1.23-next.12
|
|
15
|
+
- @granite-js/jest@0.1.23-next.12
|
|
16
|
+
- @granite-js/cli@0.1.23-next.12
|
|
17
|
+
|
|
18
|
+
## 0.1.23-next.11
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- fix
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- @granite-js/plugin-core@0.1.23-next.11
|
|
25
|
+
- @granite-js/style-utils@0.1.23-next.11
|
|
26
|
+
- @granite-js/lottie@0.1.23-next.11
|
|
27
|
+
- @granite-js/native@0.1.23-next.11
|
|
28
|
+
- @granite-js/image@0.1.23-next.11
|
|
29
|
+
- @granite-js/mpack@0.1.23-next.11
|
|
30
|
+
- @granite-js/jest@0.1.23-next.11
|
|
31
|
+
- @granite-js/cli@0.1.23-next.11
|
|
32
|
+
|
|
3
33
|
## 0.1.23-next.10
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/app/AppRoot.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function AppRoot({ appName, context, container: Container, initialProps, initialScheme, router, setIosSwipeGestureEnabled, }: AppRootProps): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare function AppRoot({ appName, context, container: Container, initialProps, initialScheme, router, setIosSwipeGestureEnabled, getInitialUrl, }: AppRootProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/app/Granite.d.ts
CHANGED
|
@@ -31,6 +31,13 @@ export interface GraniteProps {
|
|
|
31
31
|
setIosSwipeGestureEnabled?: ({ isEnabled }: {
|
|
32
32
|
isEnabled: boolean;
|
|
33
33
|
}) => void;
|
|
34
|
+
/**
|
|
35
|
+
* @description
|
|
36
|
+
* The function to provide the initial URL to router.
|
|
37
|
+
* @param initialScheme The initial scheme of the app.
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
getInitialUrl?: (initialScheme: string) => string | undefined | Promise<string | undefined>;
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
36
43
|
* @public
|
|
@@ -67,7 +74,7 @@ export interface GraniteProps {
|
|
|
67
74
|
* ```
|
|
68
75
|
*/
|
|
69
76
|
export declare const Granite: {
|
|
70
|
-
registerApp(AppContainer: ComponentType<PropsWithChildren<InitialProps>>, { appName, context, router, initialScheme, setIosSwipeGestureEnabled }: GraniteProps): (initialProps: InitialProps) => JSX.Element;
|
|
77
|
+
registerApp(AppContainer: ComponentType<PropsWithChildren<InitialProps>>, { appName, context, router, initialScheme, setIosSwipeGestureEnabled, getInitialUrl }: GraniteProps): (initialProps: InitialProps) => JSX.Element;
|
|
71
78
|
registerHostApp(AppContainer: ComponentType<PropsWithChildren<InitialProps>>, { appName }: Pick<GraniteProps, "appName">): (initialProps: InitialProps) => React.JSX.Element;
|
|
72
79
|
readonly appName: string;
|
|
73
80
|
};
|
|
@@ -11,9 +11,5 @@ type ParamOf<K extends EventKeys> = EventEmittersMap[K]['params'];
|
|
|
11
11
|
interface EventEmitter {
|
|
12
12
|
addListener<Event extends EventKeys>(event: Event, callback: (...params: ParamOf<Event>) => void): EmitterSubscription;
|
|
13
13
|
}
|
|
14
|
-
export declare const nativeEventEmitter: EventEmitter
|
|
15
|
-
addListener: () => {
|
|
16
|
-
remove: () => void;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
14
|
+
export declare const nativeEventEmitter: EventEmitter;
|
|
19
15
|
export {};
|
|
@@ -4,5 +4,5 @@ interface GraniteCoreModule extends TurboModule {
|
|
|
4
4
|
removeListeners: (count: number) => void;
|
|
5
5
|
importLazy: () => Promise<void>;
|
|
6
6
|
}
|
|
7
|
-
export declare const GraniteCoreModule: GraniteCoreModule
|
|
7
|
+
export declare const GraniteCoreModule: GraniteCoreModule;
|
|
8
8
|
export {};
|
package/dist/router/Router.d.ts
CHANGED
|
@@ -55,5 +55,5 @@ type NavigationContainerProps = Pick<ComponentProps<typeof NavigationContainer>,
|
|
|
55
55
|
* }
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
|
-
export declare function Router({ prefix, context, container: Container, initialProps, initialScheme, navigationContainerRef, defaultScreenOption, screenContainer, setIosSwipeGestureEnabled, ...navigationContainerProps }: InternalRouterProps & RouterProps): ReactElement;
|
|
58
|
+
export declare function Router({ prefix, context, container: Container, initialProps, initialScheme, navigationContainerRef, defaultScreenOption, screenContainer, setIosSwipeGestureEnabled, getInitialUrl, ...navigationContainerProps }: InternalRouterProps & RouterProps): ReactElement;
|
|
59
59
|
export {};
|
|
@@ -4,9 +4,10 @@ export interface RouterControlsConfig {
|
|
|
4
4
|
prefix: string;
|
|
5
5
|
initialScheme: string;
|
|
6
6
|
context: RequireContext;
|
|
7
|
+
getInitialUrl?: (initialScheme: string) => string | undefined | Promise<string | undefined>;
|
|
7
8
|
screenContainer?: ComponentType<PropsWithChildren<any>>;
|
|
8
9
|
}
|
|
9
|
-
export declare function useRouterControls({ prefix, context, screenContainer: ScreenContainer, initialScheme, }: RouterControlsConfig): {
|
|
10
|
+
export declare function useRouterControls({ prefix, context, screenContainer: ScreenContainer, getInitialUrl, initialScheme, }: RouterControlsConfig): {
|
|
10
11
|
Screens: import("react/jsx-runtime").JSX.Element[];
|
|
11
12
|
linkingOptions: import("@react-navigation/native").LinkingOptions<{}>;
|
|
12
13
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/react-native",
|
|
3
|
-
"version": "0.1.23-next.
|
|
3
|
+
"version": "0.1.23-next.12",
|
|
4
4
|
"description": "The Granite Framework",
|
|
5
5
|
"bin": {
|
|
6
6
|
"granite": "./bin/cli.js"
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@babel/core": "^7.24.9",
|
|
87
87
|
"@babel/preset-env": "^7.24.8",
|
|
88
88
|
"@babel/preset-typescript": "^7.24.7",
|
|
89
|
-
"@granite-js/native": "0.1.23-next.
|
|
89
|
+
"@granite-js/native": "0.1.23-next.12",
|
|
90
90
|
"@testing-library/dom": "^10.4.0",
|
|
91
91
|
"@testing-library/react": "^16.1.0",
|
|
92
92
|
"@types/babel__core": "^7",
|
|
@@ -105,20 +105,20 @@
|
|
|
105
105
|
"vitest": "^2.1.8"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"@granite-js/native": "0.1.23-next.
|
|
108
|
+
"@granite-js/native": "0.1.23-next.12",
|
|
109
109
|
"@types/react": "*",
|
|
110
110
|
"brick-module": "*",
|
|
111
111
|
"react": "*",
|
|
112
112
|
"react-native": "*"
|
|
113
113
|
},
|
|
114
114
|
"dependencies": {
|
|
115
|
-
"@granite-js/cli": "0.1.23-next.
|
|
116
|
-
"@granite-js/image": "0.1.23-next.
|
|
117
|
-
"@granite-js/jest": "0.1.23-next.
|
|
118
|
-
"@granite-js/lottie": "0.1.23-next.
|
|
119
|
-
"@granite-js/mpack": "0.1.23-next.
|
|
120
|
-
"@granite-js/plugin-core": "0.1.23-next.
|
|
121
|
-
"@granite-js/style-utils": "0.1.23-next.
|
|
115
|
+
"@granite-js/cli": "0.1.23-next.12",
|
|
116
|
+
"@granite-js/image": "0.1.23-next.12",
|
|
117
|
+
"@granite-js/jest": "0.1.23-next.12",
|
|
118
|
+
"@granite-js/lottie": "0.1.23-next.12",
|
|
119
|
+
"@granite-js/mpack": "0.1.23-next.12",
|
|
120
|
+
"@granite-js/plugin-core": "0.1.23-next.12",
|
|
121
|
+
"@granite-js/style-utils": "0.1.23-next.12",
|
|
122
122
|
"es-toolkit": "^1.39.8",
|
|
123
123
|
"react-native-url-polyfill": "1.3.0"
|
|
124
124
|
}
|
package/src/app/AppRoot.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SafeAreaProvider } from '@granite-js/native/react-native-safe-area-context';
|
|
2
2
|
import type { ComponentType, PropsWithChildren } from 'react';
|
|
3
3
|
import type { InitialProps } from '../initial-props';
|
|
4
|
-
import { Router } from '../router';
|
|
4
|
+
import { Router, type InternalRouterProps } from '../router';
|
|
5
5
|
import { BackEventProvider } from '../use-back-event';
|
|
6
6
|
import { App } from './App';
|
|
7
7
|
import type { GraniteProps } from './Granite';
|
|
@@ -16,6 +16,7 @@ interface AppRootProps extends GraniteProps {
|
|
|
16
16
|
initialProps: InitialProps;
|
|
17
17
|
initialScheme: string;
|
|
18
18
|
setIosSwipeGestureEnabled?: ({ isEnabled }: { isEnabled: boolean }) => void;
|
|
19
|
+
getInitialUrl: InternalRouterProps['getInitialUrl'];
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export function AppRoot({
|
|
@@ -26,6 +27,7 @@ export function AppRoot({
|
|
|
26
27
|
initialScheme,
|
|
27
28
|
router,
|
|
28
29
|
setIosSwipeGestureEnabled,
|
|
30
|
+
getInitialUrl,
|
|
29
31
|
}: AppRootProps) {
|
|
30
32
|
const prefix = getSchemePrefix({
|
|
31
33
|
appName,
|
|
@@ -45,6 +47,7 @@ export function AppRoot({
|
|
|
45
47
|
container={Container}
|
|
46
48
|
prefix={prefix}
|
|
47
49
|
setIosSwipeGestureEnabled={setIosSwipeGestureEnabled}
|
|
50
|
+
getInitialUrl={getInitialUrl}
|
|
48
51
|
{...router}
|
|
49
52
|
/>
|
|
50
53
|
</BackEventProvider>
|
package/src/app/Granite.tsx
CHANGED
|
@@ -37,6 +37,14 @@ export interface GraniteProps {
|
|
|
37
37
|
* The function to set the iOS swipe gesture enabled.
|
|
38
38
|
*/
|
|
39
39
|
setIosSwipeGestureEnabled?: ({ isEnabled }: { isEnabled: boolean }) => void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @description
|
|
43
|
+
* The function to provide the initial URL to router.
|
|
44
|
+
* @param initialScheme The initial scheme of the app.
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
getInitialUrl?: (initialScheme: string) => string | undefined | Promise<string | undefined>;
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
const createApp = () => {
|
|
@@ -54,7 +62,7 @@ const createApp = () => {
|
|
|
54
62
|
return {
|
|
55
63
|
registerApp(
|
|
56
64
|
AppContainer: ComponentType<PropsWithChildren<InitialProps>>,
|
|
57
|
-
{ appName, context, router, initialScheme, setIosSwipeGestureEnabled }: GraniteProps
|
|
65
|
+
{ appName, context, router, initialScheme, setIosSwipeGestureEnabled, getInitialUrl }: GraniteProps
|
|
58
66
|
): (initialProps: InitialProps) => JSX.Element {
|
|
59
67
|
if (appName === ENTRY_BUNDLE_NAME) {
|
|
60
68
|
throw new Error(`Reserved app name 'shared' cannot be used`);
|
|
@@ -67,6 +75,7 @@ const createApp = () => {
|
|
|
67
75
|
initialProps={initialProps}
|
|
68
76
|
initialScheme={initialScheme ?? getSchemeUri()}
|
|
69
77
|
setIosSwipeGestureEnabled={setIosSwipeGestureEnabled}
|
|
78
|
+
getInitialUrl={getInitialUrl}
|
|
70
79
|
appName={appName}
|
|
71
80
|
context={context}
|
|
72
81
|
router={router}
|
package/src/router/Router.tsx
CHANGED
|
@@ -23,8 +23,7 @@ import { BackButton } from './components/BackButton';
|
|
|
23
23
|
import { CanGoBackGuard } from './components/CanGoBackGuard';
|
|
24
24
|
import { StackNavigator } from './components/StackNavigator';
|
|
25
25
|
import { useInternalRouterBackHandler } from './components/useRouterBackHandler';
|
|
26
|
-
import {
|
|
27
|
-
import { useRouterControls } from './hooks/useRouterControls';
|
|
26
|
+
import { useRouterControls, type RouterControlsConfig } from './hooks/useRouterControls';
|
|
28
27
|
import { RequireContext } from './types';
|
|
29
28
|
import { BASE_STACK_NAVIGATOR_STYLE } from './types/screen-option';
|
|
30
29
|
|
|
@@ -66,6 +65,7 @@ export interface InternalRouterProps {
|
|
|
66
65
|
initialProps: InitialProps;
|
|
67
66
|
initialScheme: string;
|
|
68
67
|
setIosSwipeGestureEnabled?: ({ isEnabled }: { isEnabled: boolean }) => Promise<void> | void;
|
|
68
|
+
getInitialUrl?: RouterControlsConfig['getInitialUrl'];
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export type RouterProps = StackNavigatorProps & NavigationContainerProps;
|
|
@@ -140,14 +140,15 @@ export function Router({
|
|
|
140
140
|
screenContainer,
|
|
141
141
|
// Public props (StackNavigator)
|
|
142
142
|
setIosSwipeGestureEnabled,
|
|
143
|
+
getInitialUrl,
|
|
143
144
|
...navigationContainerProps
|
|
144
145
|
}: InternalRouterProps & RouterProps): ReactElement {
|
|
145
|
-
const initialRouteName = useInitialRouteName({ prefix, initialScheme });
|
|
146
146
|
const { Screens, linkingOptions } = useRouterControls({
|
|
147
147
|
prefix,
|
|
148
148
|
context,
|
|
149
149
|
screenContainer,
|
|
150
150
|
initialScheme,
|
|
151
|
+
getInitialUrl,
|
|
151
152
|
});
|
|
152
153
|
|
|
153
154
|
const ref = useMemo(() => navigationContainerRef ?? createNavigationContainerRef<never>(), [navigationContainerRef]);
|
|
@@ -190,7 +191,7 @@ export function Router({
|
|
|
190
191
|
setIosSwipeGestureEnabled={setIosSwipeGestureEnabled}
|
|
191
192
|
>
|
|
192
193
|
<Container {...initialProps}>
|
|
193
|
-
<StackNavigator.Navigator
|
|
194
|
+
<StackNavigator.Navigator screenOptions={screenOptions} >
|
|
194
195
|
{Screens}
|
|
195
196
|
</StackNavigator.Navigator>
|
|
196
197
|
</Container>
|
|
@@ -14,6 +14,7 @@ export interface RouterControlsConfig {
|
|
|
14
14
|
prefix: string;
|
|
15
15
|
initialScheme: string;
|
|
16
16
|
context: RequireContext;
|
|
17
|
+
getInitialUrl?: (initialScheme: string) => string | undefined | Promise<string | undefined>;
|
|
17
18
|
screenContainer?: ComponentType<PropsWithChildren<any>>;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -21,6 +22,7 @@ export function useRouterControls({
|
|
|
21
22
|
prefix,
|
|
22
23
|
context,
|
|
23
24
|
screenContainer: ScreenContainer,
|
|
25
|
+
getInitialUrl = defaultGetInitialUrl,
|
|
24
26
|
initialScheme,
|
|
25
27
|
}: RouterControlsConfig) {
|
|
26
28
|
const routeScreens = useMemo(() => getRouteScreens(context), [context]);
|
|
@@ -61,15 +63,19 @@ export function useRouterControls({
|
|
|
61
63
|
screens: getScreenPathMapConfig(registerScreens),
|
|
62
64
|
},
|
|
63
65
|
async getInitialURL() {
|
|
64
|
-
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** @NOTE Korean paths need to be decoded. */
|
|
69
|
-
return decodeURI(initialScheme);
|
|
66
|
+
return (getInitialUrl ?? defaultGetInitialUrl)(initialScheme);
|
|
70
67
|
},
|
|
71
68
|
};
|
|
72
|
-
}, [initialScheme, prefix, registerScreens]);
|
|
69
|
+
}, [initialScheme, prefix, registerScreens, getInitialUrl]);
|
|
73
70
|
|
|
74
71
|
return { Screens, linkingOptions };
|
|
75
72
|
}
|
|
73
|
+
|
|
74
|
+
function defaultGetInitialUrl(initialScheme: string) {
|
|
75
|
+
if (initialScheme == null) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @NOTE Korean paths need to be decoded. */
|
|
80
|
+
return decodeURI(initialScheme);
|
|
81
|
+
}
|