@react-navigation/native 7.0.0-alpha.0 → 7.0.0-alpha.10
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/lib/commonjs/Link.js +16 -9
- package/lib/commonjs/Link.js.map +1 -1
- package/lib/commonjs/LinkingContext.js +8 -7
- package/lib/commonjs/LinkingContext.js.map +1 -1
- package/lib/commonjs/LocaleDirContext.js +12 -0
- package/lib/commonjs/LocaleDirContext.js.map +1 -0
- package/lib/commonjs/NavigationContainer.js +68 -32
- package/lib/commonjs/NavigationContainer.js.map +1 -1
- package/lib/commonjs/ServerContainer.js +6 -8
- package/lib/commonjs/ServerContainer.js.map +1 -1
- package/lib/commonjs/ServerContext.js +4 -6
- package/lib/commonjs/ServerContext.js.map +1 -1
- package/lib/commonjs/UnhandledLinkingContext.js +20 -0
- package/lib/commonjs/UnhandledLinkingContext.js.map +1 -0
- package/lib/commonjs/__stubs__/createStackNavigator.js +19 -0
- package/lib/commonjs/__stubs__/createStackNavigator.js.map +1 -0
- package/lib/commonjs/__stubs__/window.js +79 -0
- package/lib/commonjs/__stubs__/window.js.map +1 -0
- package/lib/commonjs/createMemoryHistory.js +5 -8
- package/lib/commonjs/createMemoryHistory.js.map +1 -1
- package/lib/commonjs/createStaticNavigation.js +8 -8
- package/lib/commonjs/createStaticNavigation.js.map +1 -1
- package/lib/commonjs/extractPathFromURL.js +4 -4
- package/lib/commonjs/extractPathFromURL.js.map +1 -1
- package/lib/commonjs/index.js +33 -34
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/theming/DarkTheme.js +5 -5
- package/lib/commonjs/theming/DarkTheme.js.map +1 -1
- package/lib/commonjs/theming/DefaultTheme.js +5 -5
- package/lib/commonjs/theming/DefaultTheme.js.map +1 -1
- package/lib/commonjs/theming/fonts.js +65 -0
- package/lib/commonjs/theming/fonts.js.map +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useBackButton.js +4 -20
- package/lib/commonjs/useBackButton.js.map +1 -1
- package/lib/commonjs/useBackButton.native.js +27 -0
- package/lib/commonjs/useBackButton.native.js.map +1 -0
- package/lib/commonjs/useDocumentTitle.js +6 -6
- package/lib/commonjs/useDocumentTitle.js.map +1 -1
- package/lib/commonjs/useDocumentTitle.native.js +1 -1
- package/lib/commonjs/useDocumentTitle.native.js.map +1 -1
- package/lib/commonjs/useLinkBuilder.js +80 -0
- package/lib/commonjs/useLinkBuilder.js.map +1 -0
- package/lib/commonjs/useLinkProps.js +23 -27
- package/lib/commonjs/useLinkProps.js.map +1 -1
- package/lib/commonjs/useLinkTo.js +30 -0
- package/lib/commonjs/useLinkTo.js.map +1 -0
- package/lib/commonjs/useLinking.js +39 -40
- package/lib/commonjs/useLinking.js.map +1 -1
- package/lib/commonjs/useLinking.native.js +33 -27
- package/lib/commonjs/useLinking.native.js.map +1 -1
- package/lib/commonjs/useLocale.js +23 -0
- package/lib/commonjs/useLocale.js.map +1 -0
- package/lib/commonjs/useScrollToTop.js +9 -7
- package/lib/commonjs/useScrollToTop.js.map +1 -1
- package/lib/commonjs/useThenable.js +4 -3
- package/lib/commonjs/useThenable.js.map +1 -1
- package/lib/commonjs/useUnhandledLinking.js +75 -0
- package/lib/commonjs/useUnhandledLinking.js.map +1 -0
- package/lib/module/Link.js +13 -5
- package/lib/module/Link.js.map +1 -1
- package/lib/module/LinkingContext.js +5 -3
- package/lib/module/LinkingContext.js.map +1 -1
- package/lib/module/LocaleDirContext.js +4 -0
- package/lib/module/LocaleDirContext.js.map +1 -0
- package/lib/module/NavigationContainer.js +60 -23
- package/lib/module/NavigationContainer.js.map +1 -1
- package/lib/module/ServerContainer.js +2 -2
- package/lib/module/ServerContainer.js.map +1 -1
- package/lib/module/ServerContext.js +1 -2
- package/lib/module/ServerContext.js.map +1 -1
- package/lib/module/UnhandledLinkingContext.js +12 -0
- package/lib/module/UnhandledLinkingContext.js.map +1 -0
- package/lib/module/__stubs__/createStackNavigator.js +11 -0
- package/lib/module/__stubs__/createStackNavigator.js.map +1 -0
- package/lib/module/__stubs__/window.js +73 -0
- package/lib/module/__stubs__/window.js.map +1 -0
- package/lib/module/createMemoryHistory.js +5 -8
- package/lib/module/createMemoryHistory.js.map +1 -1
- package/lib/module/createStaticNavigation.js +5 -4
- package/lib/module/createStaticNavigation.js.map +1 -1
- package/lib/module/extractPathFromURL.js +4 -4
- package/lib/module/extractPathFromURL.js.map +1 -1
- package/lib/module/index.js +12 -12
- package/lib/module/index.js.map +1 -1
- package/lib/module/theming/DarkTheme.js +4 -3
- package/lib/module/theming/DarkTheme.js.map +1 -1
- package/lib/module/theming/DefaultTheme.js +4 -3
- package/lib/module/theming/DefaultTheme.js.map +1 -1
- package/lib/module/theming/fonts.js +59 -0
- package/lib/module/theming/fonts.js.map +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/useBackButton.js +3 -17
- package/lib/module/useBackButton.js.map +1 -1
- package/lib/module/useBackButton.native.js +19 -0
- package/lib/module/useBackButton.native.js.map +1 -0
- package/lib/module/useDocumentTitle.js +4 -4
- package/lib/module/useDocumentTitle.js.map +1 -1
- package/lib/module/useDocumentTitle.native.js +1 -1
- package/lib/module/useDocumentTitle.native.js.map +1 -1
- package/lib/module/{useLinkTools.js → useLinkBuilder.js} +11 -11
- package/lib/module/useLinkBuilder.js.map +1 -0
- package/lib/module/useLinkProps.js +20 -23
- package/lib/module/useLinkProps.js.map +1 -1
- package/lib/module/useLinkTo.js +23 -0
- package/lib/module/useLinkTo.js.map +1 -0
- package/lib/module/useLinking.js +33 -36
- package/lib/module/useLinking.js.map +1 -1
- package/lib/module/useLinking.native.js +29 -22
- package/lib/module/useLinking.native.js.map +1 -1
- package/lib/module/useLocale.js +16 -0
- package/lib/module/useLocale.js.map +1 -0
- package/lib/module/useScrollToTop.js +8 -6
- package/lib/module/useScrollToTop.js.map +1 -1
- package/lib/module/useThenable.js +2 -1
- package/lib/module/useThenable.js.map +1 -1
- package/lib/module/useUnhandledLinking.js +69 -0
- package/lib/module/useUnhandledLinking.js.map +1 -0
- package/lib/typescript/src/Link.d.ts +3 -3
- package/lib/typescript/src/Link.d.ts.map +1 -1
- package/lib/typescript/src/LinkingContext.d.ts +2 -3
- package/lib/typescript/src/LinkingContext.d.ts.map +1 -1
- package/lib/typescript/src/LocaleDirContext.d.ts +4 -0
- package/lib/typescript/src/LocaleDirContext.d.ts.map +1 -0
- package/lib/typescript/src/NavigationContainer.d.ts +6 -6
- package/lib/typescript/src/NavigationContainer.d.ts.map +1 -1
- package/lib/typescript/src/ServerContainer.d.ts +2 -3
- package/lib/typescript/src/ServerContainer.d.ts.map +1 -1
- package/lib/typescript/src/ServerContext.d.ts +1 -2
- package/lib/typescript/src/ServerContext.d.ts.map +1 -1
- package/lib/typescript/src/UnhandledLinkingContext.d.ts +6 -0
- package/lib/typescript/src/UnhandledLinkingContext.d.ts.map +1 -0
- package/lib/typescript/src/__stubs__/createStackNavigator.d.ts +32 -0
- package/lib/typescript/src/__stubs__/createStackNavigator.d.ts.map +1 -0
- package/lib/typescript/src/{__mocks__ → __stubs__}/window.d.ts +2 -3
- package/lib/typescript/src/__stubs__/window.d.ts.map +1 -0
- package/lib/typescript/src/createMemoryHistory.d.ts +1 -1
- package/lib/typescript/src/createMemoryHistory.d.ts.map +1 -1
- package/lib/typescript/src/createStaticNavigation.d.ts +3 -3
- package/lib/typescript/src/createStaticNavigation.d.ts.map +1 -1
- package/lib/typescript/src/extractPathFromURL.d.ts +1 -1
- package/lib/typescript/src/extractPathFromURL.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +12 -12
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/theming/DarkTheme.d.ts +1 -2
- package/lib/typescript/src/theming/DarkTheme.d.ts.map +1 -1
- package/lib/typescript/src/theming/DefaultTheme.d.ts +1 -2
- package/lib/typescript/src/theming/DefaultTheme.d.ts.map +1 -1
- package/lib/typescript/src/theming/fonts.d.ts +53 -0
- package/lib/typescript/src/theming/fonts.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +41 -11
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useBackButton.d.ts +2 -2
- package/lib/typescript/src/useBackButton.d.ts.map +1 -1
- package/lib/typescript/src/useBackButton.native.d.ts +4 -0
- package/lib/typescript/src/useBackButton.native.d.ts.map +1 -0
- package/lib/typescript/src/useDocumentTitle.d.ts +1 -1
- package/lib/typescript/src/useDocumentTitle.d.ts.map +1 -1
- package/lib/typescript/src/useDocumentTitle.native.d.ts +1 -1
- package/lib/typescript/src/useDocumentTitle.native.d.ts.map +1 -1
- package/lib/typescript/src/useLinkBuilder.d.ts +25 -0
- package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -0
- package/lib/typescript/src/useLinkProps.d.ts +3 -3
- package/lib/typescript/src/useLinkProps.d.ts.map +1 -1
- package/lib/typescript/src/useLinkTo.d.ts +6 -0
- package/lib/typescript/src/useLinkTo.d.ts.map +1 -0
- package/lib/typescript/src/useLinking.d.ts +8 -20
- package/lib/typescript/src/useLinking.d.ts.map +1 -1
- package/lib/typescript/src/useLinking.native.d.ts +4 -20
- package/lib/typescript/src/useLinking.native.d.ts.map +1 -1
- package/lib/typescript/src/useLocale.d.ts +7 -0
- package/lib/typescript/src/useLocale.d.ts.map +1 -0
- package/lib/typescript/src/useScrollToTop.d.ts +1 -1
- package/lib/typescript/src/useScrollToTop.d.ts.map +1 -1
- package/lib/typescript/src/useThenable.d.ts +1 -1
- package/lib/typescript/src/useThenable.d.ts.map +1 -1
- package/lib/typescript/src/useUnhandledLinking.d.ts +7 -0
- package/lib/typescript/src/useUnhandledLinking.d.ts.map +1 -0
- package/package.json +15 -15
- package/src/Link.tsx +12 -3
- package/src/LinkingContext.tsx +9 -5
- package/src/LocaleDirContext.tsx +7 -0
- package/src/NavigationContainer.tsx +90 -36
- package/src/ServerContainer.tsx +2 -2
- package/src/ServerContext.tsx +1 -3
- package/src/UnhandledLinkingContext.tsx +18 -0
- package/src/{__mocks__ → __stubs__}/createStackNavigator.tsx +1 -3
- package/src/{__mocks__ → __stubs__}/window.tsx +8 -8
- package/src/createMemoryHistory.tsx +1 -1
- package/src/createStaticNavigation.tsx +8 -8
- package/src/extractPathFromURL.tsx +5 -2
- package/src/index.tsx +12 -12
- package/src/theming/DarkTheme.tsx +3 -3
- package/src/theming/DefaultTheme.tsx +3 -3
- package/src/theming/fonts.tsx +63 -0
- package/src/types.tsx +55 -11
- package/src/useBackButton.native.tsx +33 -0
- package/src/useBackButton.tsx +4 -26
- package/src/useDocumentTitle.native.tsx +1 -1
- package/src/useDocumentTitle.tsx +1 -1
- package/src/{useLinkTools.tsx → useLinkBuilder.tsx} +9 -9
- package/src/useLinkProps.tsx +27 -23
- package/src/useLinkTo.tsx +30 -0
- package/src/useLinking.native.tsx +28 -22
- package/src/useLinking.tsx +46 -44
- package/src/useLocale.tsx +18 -0
- package/src/useScrollToTop.tsx +14 -10
- package/src/useThenable.tsx +2 -1
- package/src/useUnhandledLinking.tsx +91 -0
- package/lib/commonjs/theming/ThemeContext.js +0 -16
- package/lib/commonjs/theming/ThemeContext.js.map +0 -1
- package/lib/commonjs/theming/ThemeProvider.js +0 -21
- package/lib/commonjs/theming/ThemeProvider.js.map +0 -1
- package/lib/commonjs/theming/useTheme.js +0 -16
- package/lib/commonjs/theming/useTheme.js.map +0 -1
- package/lib/commonjs/useLinkTools.js +0 -81
- package/lib/commonjs/useLinkTools.js.map +0 -1
- package/lib/module/theming/ThemeContext.js +0 -6
- package/lib/module/theming/ThemeContext.js.map +0 -1
- package/lib/module/theming/ThemeProvider.js +0 -12
- package/lib/module/theming/ThemeProvider.js.map +0 -1
- package/lib/module/theming/useTheme.js +0 -7
- package/lib/module/theming/useTheme.js.map +0 -1
- package/lib/module/useLinkTools.js.map +0 -1
- package/lib/typescript/src/__mocks__/createStackNavigator.d.ts +0 -57
- package/lib/typescript/src/__mocks__/createStackNavigator.d.ts.map +0 -1
- package/lib/typescript/src/__mocks__/window.d.ts.map +0 -1
- package/lib/typescript/src/theming/ThemeContext.d.ts +0 -5
- package/lib/typescript/src/theming/ThemeContext.d.ts.map +0 -1
- package/lib/typescript/src/theming/ThemeProvider.d.ts +0 -9
- package/lib/typescript/src/theming/ThemeProvider.d.ts.map +0 -1
- package/lib/typescript/src/theming/useTheme.d.ts +0 -2
- package/lib/typescript/src/theming/useTheme.d.ts.map +0 -1
- package/lib/typescript/src/useLinkTools.d.ts +0 -33
- package/lib/typescript/src/useLinkTools.d.ts.map +0 -1
- package/src/theming/ThemeContext.tsx +0 -10
- package/src/theming/ThemeProvider.tsx +0 -15
- package/src/theming/useTheme.tsx +0 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NavigationAction } from '@react-navigation/core';
|
|
1
|
+
import { type NavigationAction } from '@react-navigation/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { GestureResponderEvent } from 'react-native';
|
|
3
|
+
import { type GestureResponderEvent } from 'react-native';
|
|
4
4
|
export type Props<ParamList extends ReactNavigation.RootParamList, RouteName extends keyof ParamList = keyof ParamList> = ({
|
|
5
5
|
screen: Extract<RouteName, string>;
|
|
6
6
|
href?: string;
|
|
@@ -23,7 +23,7 @@ export type Props<ParamList extends ReactNavigation.RootParamList, RouteName ext
|
|
|
23
23
|
* @param props.href Optional absolute path to use for the href (e.g. `/feeds/hot`).
|
|
24
24
|
* @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export declare function useLinkProps<ParamList extends ReactNavigation.RootParamList>({ screen, params, href, action, }: Props<ParamList>): {
|
|
27
27
|
href: string | undefined;
|
|
28
28
|
accessibilityRole: "link";
|
|
29
29
|
onPress: (e?: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinkProps.d.ts","sourceRoot":"","sources":["../../../src/useLinkProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"useLinkProps.d.ts","sourceRoot":"","sources":["../../../src/useLinkProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EAKtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAIpE,MAAM,MAAM,KAAK,CACf,SAAS,SAAS,eAAe,CAAC,aAAa,EAC/C,SAAS,SAAS,MAAM,SAAS,GAAG,MAAM,SAAS,IAEjD,CAAC;IACC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,GAAG,CAAC,SAAS,SAAS,SAAS,CAAC,SAAS,CAAC,GACvC;IAAE,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,CAAC,CAAC,GACtC;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AA+BN;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,SAAS,SAAS,eAAe,CAAC,aAAa,EAAE,EAC5E,MAAM,EACN,MAAM,EACN,IAAI,EACJ,MAAM,GACP,EAAE,KAAK,CAAC,SAAS,CAAC;;;kBAMX,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,qBAAqB;EA8D9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLinkTo.d.ts","sourceRoot":"","sources":["../../../src/useLinkTo.tsx"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,SAAS,WAKd,MAAM,UAehB"}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
|
|
1
|
+
import { type NavigationContainerRef, type ParamListBase } from '@react-navigation/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { LinkingOptions } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Run async function in series as it's called.
|
|
6
|
+
*/
|
|
7
|
+
export declare const series: (cb: () => Promise<void>) => () => void;
|
|
4
8
|
type Options = LinkingOptions<ParamListBase>;
|
|
5
|
-
export
|
|
9
|
+
export declare function useLinking(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, config, getStateFromPath, getPathFromState, getActionFromState, }: Options, onUnhandledLinking: (lastUnhandledLining: string | undefined) => void): {
|
|
6
10
|
getInitialState: () => PromiseLike<(Partial<Omit<Readonly<{
|
|
7
11
|
key: string;
|
|
8
12
|
index: number;
|
|
9
13
|
routeNames: string[];
|
|
10
14
|
history?: unknown[] | undefined;
|
|
11
|
-
routes: (
|
|
12
|
-
key: string;
|
|
13
|
-
name: string;
|
|
14
|
-
path?: string | undefined;
|
|
15
|
-
}> & Readonly<{
|
|
16
|
-
params?: Readonly<object | undefined>;
|
|
17
|
-
}> & {
|
|
18
|
-
state?: Readonly<any> | import("@react-navigation/core").PartialState<Readonly<any>> | undefined;
|
|
19
|
-
})[];
|
|
15
|
+
routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
|
|
20
16
|
type: string;
|
|
21
17
|
stale: false;
|
|
22
18
|
}>, "stale" | "routes">> & Readonly<{
|
|
@@ -28,15 +24,7 @@ export default function useLinking(ref: React.RefObject<NavigationContainerRef<P
|
|
|
28
24
|
index: number;
|
|
29
25
|
routeNames: string[];
|
|
30
26
|
history?: unknown[] | undefined;
|
|
31
|
-
routes: (
|
|
32
|
-
key: string;
|
|
33
|
-
name: string;
|
|
34
|
-
path?: string | undefined;
|
|
35
|
-
}> & Readonly<{
|
|
36
|
-
params?: Readonly<object | undefined>;
|
|
37
|
-
}> & {
|
|
38
|
-
state?: Readonly<any> | import("@react-navigation/core").PartialState<Readonly<any>> | undefined;
|
|
39
|
-
})[];
|
|
27
|
+
routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
|
|
40
28
|
type: string;
|
|
41
29
|
stale: false;
|
|
42
30
|
}>, "stale" | "routes">> & Readonly<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../../src/useLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,sBAAsB,
|
|
1
|
+
{"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../../src/useLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA4C9C;;GAEG;AACH,eAAO,MAAM,MAAM,OAAQ,MAAM,QAAQ,IAAI,CAAC,eAO7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EAgVtE"}
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
|
|
1
|
+
import { type NavigationContainerRef, type ParamListBase } from '@react-navigation/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { LinkingOptions } from './types';
|
|
4
4
|
type Options = LinkingOptions<ParamListBase>;
|
|
5
|
-
export
|
|
5
|
+
export declare function useLinking(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, prefixes, filter, config, getInitialURL, subscribe, getStateFromPath, getActionFromState, }: Options, onUnhandledLinking: (lastUnhandledLining: string | undefined) => void): {
|
|
6
6
|
getInitialState: () => PromiseLike<(Partial<Omit<Readonly<{
|
|
7
7
|
key: string;
|
|
8
8
|
index: number;
|
|
9
9
|
routeNames: string[];
|
|
10
10
|
history?: unknown[] | undefined;
|
|
11
|
-
routes: (
|
|
12
|
-
key: string;
|
|
13
|
-
name: string;
|
|
14
|
-
path?: string | undefined;
|
|
15
|
-
}> & Readonly<{
|
|
16
|
-
params?: Readonly<object | undefined>;
|
|
17
|
-
}> & {
|
|
18
|
-
state?: Readonly<any> | import("@react-navigation/core").PartialState<Readonly<any>> | undefined;
|
|
19
|
-
})[];
|
|
11
|
+
routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
|
|
20
12
|
type: string;
|
|
21
13
|
stale: false;
|
|
22
14
|
}>, "stale" | "routes">> & Readonly<{
|
|
@@ -28,15 +20,7 @@ export default function useLinking(ref: React.RefObject<NavigationContainerRef<P
|
|
|
28
20
|
index: number;
|
|
29
21
|
routeNames: string[];
|
|
30
22
|
history?: unknown[] | undefined;
|
|
31
|
-
routes: (
|
|
32
|
-
key: string;
|
|
33
|
-
name: string;
|
|
34
|
-
path?: string | undefined;
|
|
35
|
-
}> & Readonly<{
|
|
36
|
-
params?: Readonly<object | undefined>;
|
|
37
|
-
}> & {
|
|
38
|
-
state?: Readonly<any> | import("@react-navigation/core").PartialState<Readonly<any>> | undefined;
|
|
39
|
-
})[];
|
|
23
|
+
routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
|
|
40
24
|
type: string;
|
|
41
25
|
stale: false;
|
|
42
26
|
}>, "stale" | "routes">> & Readonly<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../../src/useLinking.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,
|
|
1
|
+
{"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../../src/useLinking.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAI7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAQI,EACJ,SAmBC,EACD,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EAkKtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/useLocale.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,SAAS;;EAUxB"}
|
|
@@ -22,6 +22,6 @@ type ScrollableWrapper = {
|
|
|
22
22
|
} | {
|
|
23
23
|
getNode(): ScrollableView;
|
|
24
24
|
} | ScrollableView;
|
|
25
|
-
export
|
|
25
|
+
export declare function useScrollToTop(ref: React.RefObject<ScrollableWrapper>): void;
|
|
26
26
|
export {};
|
|
27
27
|
//# sourceMappingURL=useScrollToTop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollToTop.d.ts","sourceRoot":"","sources":["../../../src/useScrollToTop.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useScrollToTop.d.ts","sourceRoot":"","sources":["../../../src/useScrollToTop.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,KAAK,aAAa,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpE,KAAK,cAAc,GACf;IAAE,WAAW,IAAI,IAAI,CAAA;CAAE,GACvB;IAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,GAC1C;IAAE,cAAc,CAAC,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAC1E;IAAE,uBAAuB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,CAAC;AAE9D,KAAK,iBAAiB,GAClB;IAAE,kBAAkB,IAAI,KAAK,CAAC,SAAS,GAAG,UAAU,CAAA;CAAE,GACtD;IAAE,OAAO,IAAI,cAAc,CAAA;CAAE,GAC7B,cAAc,CAAC;AA8BnB,wBAAgB,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,QAoErE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function useThenable<T>(create: () => PromiseLike<T>): [boolean, T | undefined];
|
|
2
2
|
//# sourceMappingURL=useThenable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThenable.d.ts","sourceRoot":"","sources":["../../../src/useThenable.tsx"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"useThenable.d.ts","sourceRoot":"","sources":["../../../src/useThenable.tsx"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,4BAuC1D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type NavigationState, type PartialState } from '@react-navigation/core';
|
|
2
|
+
export declare function UNSTABLE_useUnhandledLinking(): {
|
|
3
|
+
lastUnhandledLink: string | undefined;
|
|
4
|
+
getStateForRouteNamesChange: (currentState: NavigationState) => PartialState<NavigationState> | undefined;
|
|
5
|
+
clearUnhandledLink: () => void;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=useUnhandledLinking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUnhandledLinking.d.ts","sourceRoot":"","sources":["../../../src/useUnhandledLinking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AA2BhC,wBAAgB,4BAA4B;;gDAU1B,eAAe,KAC5B,aAAa,eAAe,CAAC,GAAG,SAAS;;EA+C7C"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-navigation/native",
|
|
3
3
|
"description": "React Native integration for React Navigation",
|
|
4
|
-
"version": "7.0.0-alpha.
|
|
4
|
+
"version": "7.0.0-alpha.10",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
7
7
|
"react-navigation",
|
|
@@ -37,26 +37,26 @@
|
|
|
37
37
|
"clean": "del lib"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@react-navigation/core": "^7.0.0-alpha.
|
|
40
|
+
"@react-navigation/core": "^7.0.0-alpha.9",
|
|
41
41
|
"escape-string-regexp": "^4.0.0",
|
|
42
42
|
"fast-deep-equal": "^3.1.3",
|
|
43
|
-
"nanoid": "
|
|
43
|
+
"nanoid": "3.3.7",
|
|
44
|
+
"use-latest-callback": "^0.1.9"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@testing-library/react-native": "^
|
|
47
|
-
"@types/react": "~18.
|
|
48
|
-
"@types/react-dom": "~18.0.
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"react": "18.1.0",
|
|
47
|
+
"@testing-library/react-native": "^12.4.3",
|
|
48
|
+
"@types/react": "~18.2.45",
|
|
49
|
+
"@types/react-dom": "~18.0.11",
|
|
50
|
+
"del-cli": "^5.1.0",
|
|
51
|
+
"react": "18.2.0",
|
|
52
52
|
"react-dom": "18.2.0",
|
|
53
|
-
"react-native": "0.
|
|
54
|
-
"react-native-builder-bob": "^0.
|
|
55
|
-
"typescript": "^
|
|
53
|
+
"react-native": "0.73.2",
|
|
54
|
+
"react-native-builder-bob": "^0.23.2",
|
|
55
|
+
"typescript": "^5.3.3"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"react": "
|
|
59
|
-
"react-native": "
|
|
58
|
+
"react": ">= 18.2.0",
|
|
59
|
+
"react-native": ">= 0.72.0"
|
|
60
60
|
},
|
|
61
61
|
"react-native-builder-bob": {
|
|
62
62
|
"source": "src",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
]
|
|
73
73
|
]
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "38117089fff9341c72e0834ca8ec237e8186b63c"
|
|
76
76
|
}
|
package/src/Link.tsx
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { useTheme } from '@react-navigation/core';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type GestureResponderEvent,
|
|
5
|
+
Platform,
|
|
6
|
+
Text,
|
|
7
|
+
type TextProps,
|
|
8
|
+
} from 'react-native';
|
|
3
9
|
|
|
4
|
-
import
|
|
10
|
+
import { type Props as LinkProps, useLinkProps } from './useLinkProps';
|
|
5
11
|
|
|
6
12
|
type Props<ParamList extends ReactNavigation.RootParamList> =
|
|
7
13
|
LinkProps<ParamList> &
|
|
@@ -26,13 +32,15 @@ type Props<ParamList extends ReactNavigation.RootParamList> =
|
|
|
26
32
|
* @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
|
|
27
33
|
* @param props.children Child elements to render the content.
|
|
28
34
|
*/
|
|
29
|
-
export
|
|
35
|
+
export function Link<ParamList extends ReactNavigation.RootParamList>({
|
|
30
36
|
screen,
|
|
31
37
|
params,
|
|
32
38
|
action,
|
|
33
39
|
href,
|
|
40
|
+
style,
|
|
34
41
|
...rest
|
|
35
42
|
}: Props<ParamList>) {
|
|
43
|
+
const { colors, fonts } = useTheme();
|
|
36
44
|
// @ts-expect-error: This is already type-checked by the prop types
|
|
37
45
|
const props = useLinkProps<ParamList>({ screen, params, action, href });
|
|
38
46
|
|
|
@@ -56,5 +64,6 @@ export default function Link<ParamList extends ReactNavigation.RootParamList>({
|
|
|
56
64
|
web: { onClick: onPress } as any,
|
|
57
65
|
default: { onPress },
|
|
58
66
|
}),
|
|
67
|
+
style: [{ color: colors.primary }, fonts.regular, style],
|
|
59
68
|
});
|
|
60
69
|
}
|
package/src/LinkingContext.tsx
CHANGED
|
@@ -3,10 +3,14 @@ import * as React from 'react';
|
|
|
3
3
|
|
|
4
4
|
import type { LinkingOptions } from './types';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
options: LinkingOptions<ParamListBase> | undefined;
|
|
8
|
-
}>({ options: undefined });
|
|
6
|
+
const MISSING_CONTEXT_ERROR = "Couldn't find a LinkingContext context.";
|
|
9
7
|
|
|
10
|
-
LinkingContext
|
|
8
|
+
export const LinkingContext = React.createContext<{
|
|
9
|
+
options?: LinkingOptions<ParamListBase>;
|
|
10
|
+
}>({
|
|
11
|
+
get options(): any {
|
|
12
|
+
throw new Error(MISSING_CONTEXT_ERROR);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
LinkingContext.displayName = 'LinkingContext';
|
|
@@ -3,23 +3,32 @@ import {
|
|
|
3
3
|
getActionFromState,
|
|
4
4
|
getPathFromState,
|
|
5
5
|
getStateFromPath,
|
|
6
|
-
NavigationContainerProps,
|
|
7
|
-
NavigationContainerRef,
|
|
8
|
-
|
|
6
|
+
type NavigationContainerProps,
|
|
7
|
+
type NavigationContainerRef,
|
|
8
|
+
type NavigationState,
|
|
9
|
+
type ParamListBase,
|
|
9
10
|
validatePathConfig,
|
|
10
11
|
} from '@react-navigation/core';
|
|
11
12
|
import * as React from 'react';
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
import { I18nManager } from 'react-native';
|
|
14
|
+
import useLatestCallback from 'use-latest-callback';
|
|
15
|
+
|
|
16
|
+
import { LinkingContext } from './LinkingContext';
|
|
17
|
+
import { LocaleDirContext } from './LocaleDirContext';
|
|
18
|
+
import { DefaultTheme } from './theming/DefaultTheme';
|
|
19
|
+
import type {
|
|
20
|
+
DocumentTitleOptions,
|
|
21
|
+
LinkingOptions,
|
|
22
|
+
LocaleDirection,
|
|
23
|
+
} from './types';
|
|
24
|
+
import { UnhandledLinkingContext } from './UnhandledLinkingContext';
|
|
25
|
+
import { useBackButton } from './useBackButton';
|
|
26
|
+
import { useDocumentTitle } from './useDocumentTitle';
|
|
27
|
+
import { useLinking } from './useLinking';
|
|
28
|
+
import { useThenable } from './useThenable';
|
|
21
29
|
|
|
22
30
|
declare global {
|
|
31
|
+
// eslint-disable-next-line no-var
|
|
23
32
|
var REACT_NAVIGATION_DEVTOOLS: WeakMap<
|
|
24
33
|
NavigationContainerRef<any>,
|
|
25
34
|
{ readonly linking: LinkingOptions<any> }
|
|
@@ -29,7 +38,7 @@ declare global {
|
|
|
29
38
|
global.REACT_NAVIGATION_DEVTOOLS = new WeakMap();
|
|
30
39
|
|
|
31
40
|
type Props<ParamList extends {}> = NavigationContainerProps & {
|
|
32
|
-
|
|
41
|
+
direction?: LocaleDirection;
|
|
33
42
|
linking?: LinkingOptions<ParamList>;
|
|
34
43
|
fallback?: React.ReactNode;
|
|
35
44
|
documentTitle?: DocumentTitleOptions;
|
|
@@ -43,7 +52,8 @@ type Props<ParamList extends {}> = NavigationContainerProps & {
|
|
|
43
52
|
* @param props.onReady Callback which is called after the navigation tree mounts.
|
|
44
53
|
* @param props.onStateChange Callback which is called with the latest navigation state when it changes.
|
|
45
54
|
* @param props.onUnhandledAction Callback which is called when an action is not handled.
|
|
46
|
-
* @param props.
|
|
55
|
+
* @param props.direction Text direction of the components. Defaults to `'ltr'`.
|
|
56
|
+
* @param props.theme Theme object for the UI elements.
|
|
47
57
|
* @param props.linking Options for deep linking. Deep link handling is enabled when this prop is provided, unless `linking.enabled` is `false`.
|
|
48
58
|
* @param props.fallback Fallback component to render until we have finished getting initial state when linking is enabled. Defaults to `null`.
|
|
49
59
|
* @param props.documentTitle Options to configure the document title on Web. Updating document title is handled by default unless `documentTitle.enabled` is `false`.
|
|
@@ -52,10 +62,13 @@ type Props<ParamList extends {}> = NavigationContainerProps & {
|
|
|
52
62
|
*/
|
|
53
63
|
function NavigationContainerInner(
|
|
54
64
|
{
|
|
65
|
+
direction = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr',
|
|
55
66
|
theme = DefaultTheme,
|
|
56
67
|
linking,
|
|
57
68
|
fallback = null,
|
|
58
69
|
documentTitle,
|
|
70
|
+
onReady,
|
|
71
|
+
onStateChange,
|
|
59
72
|
...rest
|
|
60
73
|
}: Props<ParamListBase>,
|
|
61
74
|
ref?: React.Ref<NavigationContainerRef<ParamListBase> | null>
|
|
@@ -72,12 +85,52 @@ function NavigationContainerInner(
|
|
|
72
85
|
useBackButton(refContainer);
|
|
73
86
|
useDocumentTitle(refContainer, documentTitle);
|
|
74
87
|
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
const [lastUnhandledLink, setLastUnhandledLink] = React.useState<
|
|
89
|
+
string | undefined
|
|
90
|
+
>();
|
|
91
|
+
|
|
92
|
+
const { getInitialState } = useLinking(
|
|
93
|
+
refContainer,
|
|
94
|
+
{
|
|
95
|
+
enabled: isLinkingEnabled,
|
|
96
|
+
prefixes: [],
|
|
97
|
+
...linking,
|
|
98
|
+
},
|
|
99
|
+
setLastUnhandledLink
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);
|
|
103
|
+
|
|
104
|
+
const unhandledLinkingContext = React.useMemo(
|
|
105
|
+
() => ({ lastUnhandledLink, setLastUnhandledLink }),
|
|
106
|
+
[lastUnhandledLink, setLastUnhandledLink]
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const onReadyForLinkingHandling = useLatestCallback(() => {
|
|
110
|
+
// If the screen path matches lastUnhandledLink, we do not track it
|
|
111
|
+
const path = refContainer.current?.getCurrentRoute()?.path;
|
|
112
|
+
setLastUnhandledLink((previousLastUnhandledLink) => {
|
|
113
|
+
if (previousLastUnhandledLink === path) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
return previousLastUnhandledLink;
|
|
117
|
+
});
|
|
118
|
+
onReady?.();
|
|
79
119
|
});
|
|
80
120
|
|
|
121
|
+
const onStateChangeForLinkingHandling = useLatestCallback(
|
|
122
|
+
(state: Readonly<NavigationState> | undefined) => {
|
|
123
|
+
// If the screen path matches lastUnhandledLink, we do not track it
|
|
124
|
+
const path = refContainer.current?.getCurrentRoute()?.path;
|
|
125
|
+
setLastUnhandledLink((previousLastUnhandledLink) => {
|
|
126
|
+
if (previousLastUnhandledLink === path) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
return previousLastUnhandledLink;
|
|
130
|
+
});
|
|
131
|
+
onStateChange?.(state);
|
|
132
|
+
}
|
|
133
|
+
);
|
|
81
134
|
// Add additional linking related info to the ref
|
|
82
135
|
// This will be used by the devtools
|
|
83
136
|
React.useEffect(() => {
|
|
@@ -102,8 +155,6 @@ function NavigationContainerInner(
|
|
|
102
155
|
|
|
103
156
|
React.useImperativeHandle(ref, () => refContainer.current);
|
|
104
157
|
|
|
105
|
-
const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);
|
|
106
|
-
|
|
107
158
|
const isLinkingReady =
|
|
108
159
|
rest.initialState != null || !isLinkingEnabled || isResolved;
|
|
109
160
|
|
|
@@ -114,26 +165,29 @@ function NavigationContainerInner(
|
|
|
114
165
|
}
|
|
115
166
|
|
|
116
167
|
return (
|
|
117
|
-
<
|
|
118
|
-
<
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
168
|
+
<LocaleDirContext.Provider value={direction}>
|
|
169
|
+
<UnhandledLinkingContext.Provider value={unhandledLinkingContext}>
|
|
170
|
+
<LinkingContext.Provider value={linkingContext}>
|
|
171
|
+
<BaseNavigationContainer
|
|
172
|
+
{...rest}
|
|
173
|
+
theme={theme}
|
|
174
|
+
onReady={onReadyForLinkingHandling}
|
|
175
|
+
onStateChange={onStateChangeForLinkingHandling}
|
|
176
|
+
initialState={
|
|
177
|
+
rest.initialState == null ? initialState : rest.initialState
|
|
178
|
+
}
|
|
179
|
+
ref={refContainer}
|
|
180
|
+
/>
|
|
181
|
+
</LinkingContext.Provider>
|
|
182
|
+
</UnhandledLinkingContext.Provider>
|
|
183
|
+
</LocaleDirContext.Provider>
|
|
128
184
|
);
|
|
129
185
|
}
|
|
130
186
|
|
|
131
|
-
const NavigationContainer = React.forwardRef(
|
|
132
|
-
|
|
133
|
-
>(
|
|
187
|
+
export const NavigationContainer = React.forwardRef(
|
|
188
|
+
NavigationContainerInner
|
|
189
|
+
) as <RootParamList extends {} = ReactNavigation.RootParamList>(
|
|
134
190
|
props: Props<RootParamList> & {
|
|
135
191
|
ref?: React.Ref<NavigationContainerRef<RootParamList>>;
|
|
136
192
|
}
|
|
137
193
|
) => React.ReactElement;
|
|
138
|
-
|
|
139
|
-
export default NavigationContainer;
|
package/src/ServerContainer.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CurrentRenderContext } from '@react-navigation/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
import ServerContext,
|
|
4
|
+
import { ServerContext, type ServerContextType } from './ServerContext';
|
|
5
5
|
import type { ServerContainerRef } from './types';
|
|
6
6
|
|
|
7
7
|
type Props = ServerContextType & {
|
|
@@ -15,7 +15,7 @@ type Props = ServerContextType & {
|
|
|
15
15
|
* @param props.children Child elements to render the content.
|
|
16
16
|
* @param props.ref Ref object which contains helper methods.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export const ServerContainer = React.forwardRef(function ServerContainer(
|
|
19
19
|
{ children, location }: Props,
|
|
20
20
|
ref: React.Ref<ServerContainerRef>
|
|
21
21
|
) {
|
package/src/ServerContext.tsx
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
const MISSING_CONTEXT_ERROR =
|
|
4
|
+
"Couldn't find an UnhandledLinkingContext context.";
|
|
5
|
+
|
|
6
|
+
export const UnhandledLinkingContext = React.createContext<{
|
|
7
|
+
lastUnhandledLink: string | undefined;
|
|
8
|
+
setLastUnhandledLink: (lastUnhandledUrl: string | undefined) => void;
|
|
9
|
+
}>({
|
|
10
|
+
get lastUnhandledLink(): any {
|
|
11
|
+
throw new Error(MISSING_CONTEXT_ERROR);
|
|
12
|
+
},
|
|
13
|
+
get setLastUnhandledLink(): any {
|
|
14
|
+
throw new Error(MISSING_CONTEXT_ERROR);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
UnhandledLinkingContext.displayName = 'UnhandledLinkingContext';
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from '@react-navigation/core';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
|
|
8
|
-
const createStackNavigator = createNavigatorFactory((props) => {
|
|
8
|
+
export const createStackNavigator = createNavigatorFactory((props) => {
|
|
9
9
|
const { state, descriptors, NavigationContent } = useNavigationBuilder(
|
|
10
10
|
StackRouter,
|
|
11
11
|
props
|
|
@@ -17,5 +17,3 @@ const createStackNavigator = createNavigatorFactory((props) => {
|
|
|
17
17
|
</NavigationContent>
|
|
18
18
|
);
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
export default createStackNavigator;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
let location = new URL('', 'http://example.com');
|
|
2
2
|
|
|
3
3
|
let listeners: (() => void)[] = [];
|
|
4
4
|
let entries = [{ state: null, href: location.href }];
|
|
@@ -12,7 +12,7 @@ const history = {
|
|
|
12
12
|
},
|
|
13
13
|
|
|
14
14
|
pushState(state: any, _: string, path: string) {
|
|
15
|
-
|
|
15
|
+
location = new URL(path, location.origin);
|
|
16
16
|
|
|
17
17
|
currentState = state;
|
|
18
18
|
entries = entries.slice(0, index + 1);
|
|
@@ -21,7 +21,7 @@ const history = {
|
|
|
21
21
|
},
|
|
22
22
|
|
|
23
23
|
replaceState(state: any, _: string, path: string) {
|
|
24
|
-
|
|
24
|
+
location = new URL(path, location.origin);
|
|
25
25
|
|
|
26
26
|
currentState = state;
|
|
27
27
|
entries[index] = { state, href: location.href };
|
|
@@ -35,7 +35,7 @@ const history = {
|
|
|
35
35
|
) {
|
|
36
36
|
index += n;
|
|
37
37
|
const entry = entries[index];
|
|
38
|
-
|
|
38
|
+
location = new URL(entry.href);
|
|
39
39
|
currentState = entry.state;
|
|
40
40
|
listeners.forEach((cb) => cb());
|
|
41
41
|
}
|
|
@@ -63,9 +63,11 @@ const removeEventListener = (type: 'popstate', listener: () => void) => {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
const window = {
|
|
66
|
+
export const window = {
|
|
67
67
|
document: { title: '' },
|
|
68
|
-
location
|
|
68
|
+
get location() {
|
|
69
|
+
return location;
|
|
70
|
+
},
|
|
69
71
|
history,
|
|
70
72
|
addEventListener,
|
|
71
73
|
removeEventListener,
|
|
@@ -73,5 +75,3 @@ const window = {
|
|
|
73
75
|
return window;
|
|
74
76
|
},
|
|
75
77
|
};
|
|
76
|
-
|
|
77
|
-
export default window;
|