expo-router 5.0.4 → 5.0.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/build/Route.d.ts.map +1 -1
- package/build/Route.js +1 -1
- package/build/Route.js.map +1 -1
- package/build/fork/native-stack/NativeStackView.d.ts.map +1 -1
- package/build/fork/native-stack/NativeStackView.js +1 -1
- package/build/fork/native-stack/NativeStackView.js.map +1 -1
- package/build/fork/useLinking.js +1 -1
- package/build/fork/useLinking.js.map +1 -1
- package/build/global-state/routeInfo.d.ts.map +1 -1
- package/build/global-state/routeInfo.js +9 -3
- package/build/global-state/routeInfo.js.map +1 -1
- package/build/global-state/router-store.d.ts +2 -4
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +38 -17
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.js +1 -2
- package/build/global-state/routing.js.map +1 -1
- package/build/global-state/storeContext.d.ts +2 -4
- package/build/global-state/storeContext.d.ts.map +1 -1
- package/build/hooks.js +1 -1
- package/build/hooks.js.map +1 -1
- package/build/layouts/RootModal.js +1 -1
- package/build/layouts/RootModal.js.map +1 -1
- package/build/layouts/TabRouter.d.ts +4 -0
- package/build/layouts/TabRouter.d.ts.map +1 -0
- package/build/layouts/TabRouter.js +45 -0
- package/build/layouts/TabRouter.js.map +1 -0
- package/build/layouts/TabsClient.d.ts +56 -2
- package/build/layouts/TabsClient.d.ts.map +1 -1
- package/build/layouts/TabsClient.js +8 -3
- package/build/layouts/TabsClient.js.map +1 -1
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js +1 -0
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/rsc/router/client.js +2 -2
- package/build/rsc/router/client.js.map +1 -1
- package/build/testing-library/index.d.ts +0 -11
- package/build/testing-library/index.d.ts.map +1 -1
- package/build/testing-library/index.js.map +1 -1
- package/build/ui/TabTrigger.d.ts.map +1 -1
- package/build/ui/TabTrigger.js +1 -1
- package/build/ui/TabTrigger.js.map +1 -1
- package/build/ui/Tabs.d.ts.map +1 -1
- package/build/ui/Tabs.js +2 -2
- package/build/ui/Tabs.js.map +1 -1
- package/build/views/ErrorBoundary.js +1 -1
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Navigator.js +2 -2
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Toast.js +1 -1
- package/build/views/Toast.js.map +1 -1
- package/package.json +3 -3
- package/types/expect.d.ts +10 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export declare const StoreContext: import("react").Context<{
|
|
2
2
|
shouldShowTutorial(): boolean;
|
|
3
3
|
readonly state: import("./router-store").ReactNavigationState | undefined;
|
|
4
|
-
readonly focusedState: import("@react-navigation/core/lib/typescript/src/NavigationFocusedRouteStateContext").FocusedRouteState | undefined;
|
|
5
4
|
readonly navigationRef: import("@react-navigation/core").NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;
|
|
6
5
|
readonly routeNode: import("../Route").RouteNode | null;
|
|
7
|
-
getRouteInfo(
|
|
6
|
+
getRouteInfo(): import("./routeInfo").UrlObject;
|
|
8
7
|
readonly redirects: import("./router-store").StoreRedirects[];
|
|
9
8
|
readonly rootComponent: import("react").ComponentType<any>;
|
|
10
9
|
readonly linking: import("../getLinkingConfig").ExpoLinkingOptions | undefined;
|
|
@@ -15,10 +14,9 @@ export declare const StoreContext: import("react").Context<{
|
|
|
15
14
|
export declare const useExpoRouterStore: () => {
|
|
16
15
|
shouldShowTutorial(): boolean;
|
|
17
16
|
readonly state: import("./router-store").ReactNavigationState | undefined;
|
|
18
|
-
readonly focusedState: import("@react-navigation/core/lib/typescript/src/NavigationFocusedRouteStateContext").FocusedRouteState | undefined;
|
|
19
17
|
readonly navigationRef: import("@react-navigation/core").NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;
|
|
20
18
|
readonly routeNode: import("../Route").RouteNode | null;
|
|
21
|
-
getRouteInfo(
|
|
19
|
+
getRouteInfo(): import("./routeInfo").UrlObject;
|
|
22
20
|
readonly redirects: import("./router-store").StoreRedirects[];
|
|
23
21
|
readonly rootComponent: import("react").ComponentType<any>;
|
|
24
22
|
readonly linking: import("../getLinkingConfig").ExpoLinkingOptions | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storeContext.d.ts","sourceRoot":"","sources":["../../src/global-state/storeContext.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"storeContext.d.ts","sourceRoot":"","sources":["../../src/global-state/storeContext.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY;;;;;;;;;;;;SAA0C,CAAC;AAEpE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;CAA2B,CAAC"}
|
package/build/hooks.js
CHANGED
|
@@ -112,7 +112,7 @@ function useGlobalSearchParams() {
|
|
|
112
112
|
return (0, router_store_1.useRouteInfo)().params;
|
|
113
113
|
}
|
|
114
114
|
function useLocalSearchParams() {
|
|
115
|
-
const params = react_1.default.
|
|
115
|
+
const params = react_1.default.use(Route_1.LocalRouteParamsContext) ?? {};
|
|
116
116
|
return Object.fromEntries(Object.entries(params).map(([key, value]) => {
|
|
117
117
|
if (Array.isArray(value)) {
|
|
118
118
|
return [
|
package/build/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;AA4Bb,wDAIC;AAMD,8CAEC;AAMD,8DAEC;AAoBD,8BAEC;AAOD,sDAEC;AA2CD,kCAEC;AAmBD,kCAEC;AA4CD,sDAEC;AAyCD,oDAwBC;AAED,0CAsBC;AAtRD,qDAAyE;AACzE,kDAA0B;AAE1B,mCAAkD;AAClD,2CAAiD;AACjD,8DAAkE;AAIzD,6FAJO,2BAAY,OAIP;AAHrB,qDAAkD;AAKlD;;;;;;;;;;;;;;GAcG;AACH,SA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,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,uBAAwB,SAAQ,eAAe;IACnD,GAAG;QACD,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;CACF","sourcesContent":["'use client';\n\nimport { NavigationProp, useNavigation } from '@react-navigation/native';\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { INTERNAL_SLOT_NAME } from './constants';\nimport { store, useRouteInfo } from './global-state/router-store';\nimport { router, Router } from './imperative-api';\nimport { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';\n\nexport { useRouteInfo };\n\n/**\n * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)\n * of the navigator which contains the current screen.\n *\n * @example\n * ```tsx\n * import { useRootNavigationState } from 'expo-router';\n *\n * export default function Route() {\n * const { routes } = useRootNavigationState();\n *\n * return <Text>{routes[0].name}</Text>;\n * }\n * ```\n */\nexport function useRootNavigationState() {\n return useNavigation<NavigationProp<object, never, string>>()\n .getParent(INTERNAL_SLOT_NAME)!\n .getState();\n}\n\n/**\n * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,\n * which returns a React `ref`.\n */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/**\n * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`\n * if the `<NavigationContainer />` hasn't mounted yet.\n */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\n/**\n *\n * Returns the [Router](#router) object for imperative navigation.\n *\n * @example\n *```tsx\n * import { useRouter } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n * const router = useRouter();\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport function useRouter(): Router {\n return router;\n}\n\n/**\n * @private\n * @returns The current global pathname with query params attached. This may change in the future to include the hostname\n * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.\n */\nexport function useUnstableGlobalHref(): string {\n return useRouteInfo().unstable_globalHref;\n}\n\n/**\n * Returns a list of selected file segments for the currently selected route. Segments are not normalized,\n * so they will be the same as the file path. For example, `/[id]?id=normal` becomes `[\"[id]\"]`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useSegments } from 'expo-router';\n *\n * export default function Route() {\n * // segments = [\"profile\", \"[user]\"]\n * const segments = useSegments();\n *\n * return <Text>Hello</Text>;\n * }\n * ```\n *\n *\n * `useSegments` can be typed using an abstract. Consider the following file structure:\n *\n * ```md\n * - app\n * - [user]\n * - index.tsx\n * - followers.tsx\n * - settings.tsx\n * ```\n *\n *\n * This can be strictly typed using the following abstract with `useSegments` hook:\n *\n * ```tsx\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends Route = Route>(): RouteSegments<TSegments>;\n\n/**\n * @hidden\n */\nexport function useSegments<TSegments extends RouteSegments<Route>>(): TSegments;\nexport function useSegments() {\n return useRouteInfo().segments;\n}\n\n/**\n * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.\n * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { usePathname } from 'expo-router';\n *\n * export default function Route() {\n * // pathname = \"/profile/baconbrix\"\n * const pathname = usePathname();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useRouteInfo().pathname;\n}\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns URL parameters for globally selected route, including dynamic path segments.\n * This function updates even when the route is not focused. Useful for analytics or\n * other background operations that don't draw to the screen.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * When querying search params in a stack, opt-towards using\n * [`useLocalSearchParams`](#uselocalsearchparams) because it will only update when the route is focused.\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useGlobalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useGlobalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function useGlobalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useGlobalSearchParams() {\n return useRouteInfo().params;\n}\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen\n * that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * To observe updates even when the invoking route is not focused, use [`useGlobalSearchParams`](#useglobalsearchparams).\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useLocalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useLocalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n */\nexport function useLocalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useLocalSearchParams() {\n const params = React.useContext(LocalRouteParamsContext) ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as any;\n}\n\nexport function useSearchParams({ global = false } = {}): URLSearchParams {\n const globalRef = React.useRef(global);\n if (process.env.NODE_ENV !== 'production') {\n if (global !== globalRef.current) {\n console.warn(\n `Detected change in 'global' option of useSearchParams. This value cannot change between renders`\n );\n }\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const params = global ? useGlobalSearchParams() : useLocalSearchParams();\n const entries = Object.entries(params).flatMap(([key, value]) => {\n if (global) {\n if (key === 'params') return [];\n if (key === 'screen') return [];\n }\n\n return Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]];\n });\n\n return new ReadOnlyURLSearchParams(entries);\n}\n\nclass ReadOnlyURLSearchParams extends URLSearchParams {\n set() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n append() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n delete() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;AA4Bb,wDAIC;AAMD,8CAEC;AAMD,8DAEC;AAoBD,8BAEC;AAOD,sDAEC;AA2CD,kCAEC;AAmBD,kCAEC;AA4CD,sDAEC;AAyCD,oDAwBC;AAED,0CAsBC;AAtRD,qDAAyE;AACzE,kDAA0B;AAE1B,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K,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,uBAAwB,SAAQ,eAAe;IACnD,GAAG;QACD,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;CACF","sourcesContent":["'use client';\n\nimport { NavigationProp, useNavigation } from '@react-navigation/native';\nimport React from 'react';\n\nimport { LocalRouteParamsContext } from './Route';\nimport { INTERNAL_SLOT_NAME } from './constants';\nimport { store, useRouteInfo } from './global-state/router-store';\nimport { router, Router } from './imperative-api';\nimport { RouteParams, RouteSegments, UnknownOutputParams, Route } from './types';\n\nexport { useRouteInfo };\n\n/**\n * Returns the [navigation state](https://reactnavigation.org/docs/navigation-state/)\n * of the navigator which contains the current screen.\n *\n * @example\n * ```tsx\n * import { useRootNavigationState } from 'expo-router';\n *\n * export default function Route() {\n * const { routes } = useRootNavigationState();\n *\n * return <Text>{routes[0].name}</Text>;\n * }\n * ```\n */\nexport function useRootNavigationState() {\n return useNavigation<NavigationProp<object, never, string>>()\n .getParent(INTERNAL_SLOT_NAME)!\n .getState();\n}\n\n/**\n * @deprecated Use [`useNavigationContainerRef`](#usenavigationcontainerref) instead,\n * which returns a React `ref`.\n */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/**\n * @return The root `<NavigationContainer />` ref for the app. The `ref.current` may be `null`\n * if the `<NavigationContainer />` hasn't mounted yet.\n */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\n/**\n *\n * Returns the [Router](#router) object for imperative navigation.\n *\n * @example\n *```tsx\n * import { useRouter } from 'expo-router';\n * import { Text } from 'react-native';\n *\n * export default function Route() {\n * const router = useRouter();\n *\n * return (\n * <Text onPress={() => router.push('/home')}>Go Home</Text>\n * );\n *}\n * ```\n */\nexport function useRouter(): Router {\n return router;\n}\n\n/**\n * @private\n * @returns The current global pathname with query params attached. This may change in the future to include the hostname\n * from a predefined universal link. For example, `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`.\n */\nexport function useUnstableGlobalHref(): string {\n return useRouteInfo().unstable_globalHref;\n}\n\n/**\n * Returns a list of selected file segments for the currently selected route. Segments are not normalized,\n * so they will be the same as the file path. For example, `/[id]?id=normal` becomes `[\"[id]\"]`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useSegments } from 'expo-router';\n *\n * export default function Route() {\n * // segments = [\"profile\", \"[user]\"]\n * const segments = useSegments();\n *\n * return <Text>Hello</Text>;\n * }\n * ```\n *\n *\n * `useSegments` can be typed using an abstract. Consider the following file structure:\n *\n * ```md\n * - app\n * - [user]\n * - index.tsx\n * - followers.tsx\n * - settings.tsx\n * ```\n *\n *\n * This can be strictly typed using the following abstract with `useSegments` hook:\n *\n * ```tsx\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends Route = Route>(): RouteSegments<TSegments>;\n\n/**\n * @hidden\n */\nexport function useSegments<TSegments extends RouteSegments<Route>>(): TSegments;\nexport function useSegments() {\n return useRouteInfo().segments;\n}\n\n/**\n * Returns the currently selected route location without search parameters. For example, `/acme?foo=bar` returns `/acme`.\n * Segments will be normalized. For example, `/[id]?id=normal` becomes `/normal`.\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { usePathname } from 'expo-router';\n *\n * export default function Route() {\n * // pathname = \"/profile/baconbrix\"\n * const pathname = usePathname();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function usePathname(): string {\n return useRouteInfo().pathname;\n}\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useGlobalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns URL parameters for globally selected route, including dynamic path segments.\n * This function updates even when the route is not focused. Useful for analytics or\n * other background operations that don't draw to the screen.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * When querying search params in a stack, opt-towards using\n * [`useLocalSearchParams`](#uselocalsearchparams) because it will only update when the route is focused.\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useGlobalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useGlobalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n * ```\n */\nexport function useGlobalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useGlobalSearchParams() {\n return useRouteInfo().params;\n}\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): TParams;\n\n/**\n * @hidden\n */\nexport function useLocalSearchParams<TRoute extends Route>(): RouteParams<TRoute>;\n\n/**\n * Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen\n * that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.\n *\n * Route URL example: `acme://profile/baconbrix?extra=info`.\n *\n * To observe updates even when the invoking route is not focused, use [`useGlobalSearchParams`](#useglobalsearchparams).\n *\n * > **Note:** For usage information, see\n * [Local versus global search parameters](/router/reference/url-parameters/#local-versus-global-url-parameters).\n *\n * @example\n * ```tsx app/profile/[user].tsx\n * import { Text } from 'react-native';\n * import { useLocalSearchParams } from 'expo-router';\n *\n * export default function Route() {\n * // user=baconbrix & extra=info\n * const { user, extra } = useLocalSearchParams();\n *\n * return <Text>User: {user}</Text>;\n * }\n */\nexport function useLocalSearchParams<\n TRoute extends Route,\n TParams extends UnknownOutputParams = UnknownOutputParams,\n>(): RouteParams<TRoute> & TParams;\nexport function useLocalSearchParams() {\n const params = React.use(LocalRouteParamsContext) ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as any;\n}\n\nexport function useSearchParams({ global = false } = {}): URLSearchParams {\n const globalRef = React.useRef(global);\n if (process.env.NODE_ENV !== 'production') {\n if (global !== globalRef.current) {\n console.warn(\n `Detected change in 'global' option of useSearchParams. This value cannot change between renders`\n );\n }\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const params = global ? useGlobalSearchParams() : useLocalSearchParams();\n const entries = Object.entries(params).flatMap(([key, value]) => {\n if (global) {\n if (key === 'params') return [];\n if (key === 'screen') return [];\n }\n\n return Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]];\n });\n\n return new ReadOnlyURLSearchParams(entries);\n}\n\nclass ReadOnlyURLSearchParams extends URLSearchParams {\n set() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n append() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n delete() {\n throw new Error('The URLSearchParams object return from useSearchParams is read-only');\n }\n}\n"]}
|
|
@@ -10,7 +10,7 @@ exports.RootModalContext = (0, react_1.createContext)({
|
|
|
10
10
|
removeModal: () => { },
|
|
11
11
|
});
|
|
12
12
|
function RootModalProvider({ children }) {
|
|
13
|
-
const parent = (0, react_1.
|
|
13
|
+
const parent = (0, react_1.use)(exports.RootModalContext);
|
|
14
14
|
const [state, setState] = (0, react_1.useState)(() => ({
|
|
15
15
|
root: false,
|
|
16
16
|
routes: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RootModal.js","sourceRoot":"","sources":["../../src/layouts/RootModal.tsx"],"names":[],"mappings":";;;AAgBA,8CAeC;AA/BD,
|
|
1
|
+
{"version":3,"file":"RootModal.js","sourceRoot":"","sources":["../../src/layouts/RootModal.tsx"],"names":[],"mappings":";;;AAgBA,8CAeC;AA/BD,iCAAqD;AASxC,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAAwB;IACnE,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;CACtB,CAAC,CAAC;AAEH,SAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAiC;IAC3E,MAAM,MAAM,GAAG,IAAA,WAAG,EAAC,wBAAgB,CAAC,CAAC;IAErC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAwB,GAAG,EAAE,CAAC,CAAC;QAC/D,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE;YACzB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnF,CAAC;QACD,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE;YAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnF,CAAC;KACF,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,wBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,wBAAgB,CAAC,QAAQ,CAAC,CAAC;AACzF,CAAC","sourcesContent":["import { createContext, use, useState } from 'react';\n\ntype RootModalContextValue = {\n root: boolean;\n routes: never[];\n addModal: (name: string) => void;\n removeModal: (name: string) => void;\n};\n\nexport const RootModalContext = createContext<RootModalContextValue>({\n root: true,\n routes: [],\n addModal: () => {},\n removeModal: () => {},\n});\n\nexport function RootModalProvider({ children }: { children: React.ReactNode }) {\n const parent = use(RootModalContext);\n\n const [state, setState] = useState<RootModalContextValue>(() => ({\n root: false,\n routes: [],\n addModal: (name: string) => {\n return parent.root ? setState((state) => ({ ...state })) : parent.addModal(name);\n },\n removeModal: (name: string) => {\n return parent.root ? setState((state) => ({ ...state })) : parent.addModal(name);\n },\n }));\n\n return <RootModalContext.Provider value={state}>{children}</RootModalContext.Provider>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabRouter.d.ts","sourceRoot":"","sources":["../../src/layouts/TabRouter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,iBAAiB,EAAE,WAAW,CACzC,cAAc,CAAC,kBAAkB,CAAC,CAAC,iBAAiB,CAAC,CA8CtD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.tabRouterOverride = void 0;
|
|
5
|
+
const tabRouterOverride = (original) => {
|
|
6
|
+
return {
|
|
7
|
+
...original,
|
|
8
|
+
getStateForAction: (state, action, options) => {
|
|
9
|
+
if (action.target && action.target !== state.key) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (isReplaceAction(action)) {
|
|
13
|
+
// Generate the state as if we were using JUMP_TO
|
|
14
|
+
let nextState = original.getStateForAction(state, {
|
|
15
|
+
...action,
|
|
16
|
+
type: 'JUMP_TO',
|
|
17
|
+
}, options);
|
|
18
|
+
if (!nextState || nextState.index === undefined || !Array.isArray(nextState.history)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
// If the state is valid and we didn't JUMP_TO a single history state,
|
|
22
|
+
// then remove the previous state.
|
|
23
|
+
if (nextState.index !== 0) {
|
|
24
|
+
const previousIndex = nextState.index - 1;
|
|
25
|
+
nextState = {
|
|
26
|
+
...nextState,
|
|
27
|
+
key: `${nextState.key}-replace`,
|
|
28
|
+
// Omit the previous history entry that we are replacing
|
|
29
|
+
history: [
|
|
30
|
+
...nextState.history.slice(0, previousIndex),
|
|
31
|
+
...nextState.history.splice(nextState.index),
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return nextState;
|
|
36
|
+
}
|
|
37
|
+
return original.getStateForAction(state, action, options);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.tabRouterOverride = tabRouterOverride;
|
|
42
|
+
function isReplaceAction(action) {
|
|
43
|
+
return action.type === 'REPLACE';
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=TabRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabRouter.js","sourceRoot":"","sources":["../../src/layouts/TabRouter.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAMN,MAAM,iBAAiB,GAE1B,CAAC,QAAQ,EAAE,EAAE;IACf,OAAO;QACL,GAAG,QAAQ;QACX,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,EA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S,CAAC;AACnC,CAAC","sourcesContent":["'use client';\nimport { type NavigationAction, type StackActionType } from '@react-navigation/native';\nimport type { ComponentProps } from 'react';\n\nimport type { BottomTabNavigator } from './TabsClient';\n\nexport const tabRouterOverride: NonNullable<\n ComponentProps<BottomTabNavigator>['UNSTABLE_router']\n> = (original) => {\n return {\n ...original,\n getStateForAction: (state, action, options) => {\n if (action.target && action.target !== state.key) {\n return null;\n }\n\n if (isReplaceAction(action)) {\n // Generate the state as if we were using JUMP_TO\n let nextState = original.getStateForAction(\n state,\n {\n ...action,\n type: 'JUMP_TO',\n },\n options\n );\n\n if (!nextState || nextState.index === undefined || !Array.isArray(nextState.history)) {\n return null;\n }\n\n // If the state is valid and we didn't JUMP_TO a single history state,\n // then remove the previous state.\n if (nextState.index !== 0) {\n const previousIndex = nextState.index - 1;\n\n nextState = {\n ...nextState,\n key: `${nextState.key}-replace`,\n // Omit the previous history entry that we are replacing\n history: [\n ...nextState.history.slice(0, previousIndex),\n ...nextState.history.splice(nextState.index),\n ],\n };\n }\n\n return nextState;\n }\n\n return original.getStateForAction(state, action, options);\n },\n };\n};\n\nfunction isReplaceAction(\n action: NavigationAction\n): action is Extract<StackActionType, { type: 'REPLACE' }> {\n return action.type === 'REPLACE';\n}\n"]}
|
|
@@ -1,11 +1,62 @@
|
|
|
1
1
|
import { BottomTabNavigationEventMap, BottomTabNavigationOptions } from '@react-navigation/bottom-tabs';
|
|
2
2
|
import { ParamListBase, TabNavigationState } from '@react-navigation/native';
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { ComponentProps } from 'react';
|
|
4
4
|
import { Href } from '../types';
|
|
5
|
+
declare const BottomTabNavigator: React.ComponentType<Omit<import("@react-navigation/bottom-tabs").BottomTabNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
layout?: ((props: {
|
|
8
|
+
state: TabNavigationState<ParamListBase>;
|
|
9
|
+
navigation: import("@react-navigation/native").NavigationHelpers<ParamListBase, {}>;
|
|
10
|
+
descriptors: Record<string, import("@react-navigation/native").Descriptor<BottomTabNavigationOptions, import("@react-navigation/native").NavigationProp<ParamListBase, string, string | undefined, TabNavigationState<ParamListBase>, BottomTabNavigationOptions, BottomTabNavigationEventMap>, import("@react-navigation/native").RouteProp<ParamListBase, string>>>;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}) => React.ReactElement) | undefined;
|
|
13
|
+
screenListeners?: Partial<{
|
|
14
|
+
tabPress: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "tabPress", true>;
|
|
15
|
+
tabLongPress: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "tabLongPress", unknown>;
|
|
16
|
+
transitionStart: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "transitionStart", unknown>;
|
|
17
|
+
transitionEnd: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "transitionEnd", unknown>;
|
|
18
|
+
focus: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "focus", unknown>;
|
|
19
|
+
blur: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "blur", unknown>;
|
|
20
|
+
state: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "state", unknown>;
|
|
21
|
+
beforeRemove: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "beforeRemove", true>;
|
|
22
|
+
}> | ((props: {
|
|
23
|
+
route: import("@react-navigation/native").RouteProp<ParamListBase, string>;
|
|
24
|
+
navigation: import("@react-navigation/bottom-tabs").BottomTabNavigationProp<ParamListBase, string, undefined>;
|
|
25
|
+
}) => Partial<{
|
|
26
|
+
tabPress: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "tabPress", true>;
|
|
27
|
+
tabLongPress: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "tabLongPress", unknown>;
|
|
28
|
+
transitionStart: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "transitionStart", unknown>;
|
|
29
|
+
transitionEnd: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "transitionEnd", unknown>;
|
|
30
|
+
focus: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "focus", unknown>;
|
|
31
|
+
blur: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "blur", unknown>;
|
|
32
|
+
state: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "state", unknown>;
|
|
33
|
+
beforeRemove: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "beforeRemove", true>;
|
|
34
|
+
}>) | undefined;
|
|
35
|
+
screenOptions?: BottomTabNavigationOptions | ((props: {
|
|
36
|
+
route: import("@react-navigation/native").RouteProp<ParamListBase, string>;
|
|
37
|
+
navigation: import("@react-navigation/bottom-tabs").BottomTabNavigationProp<ParamListBase, string, undefined>;
|
|
38
|
+
theme: ReactNavigation.Theme;
|
|
39
|
+
}) => BottomTabNavigationOptions) | undefined;
|
|
40
|
+
screenLayout?: ((props: {
|
|
41
|
+
route: import("@react-navigation/native").RouteProp<ParamListBase, string>;
|
|
42
|
+
navigation: import("@react-navigation/bottom-tabs").BottomTabNavigationProp<ParamListBase, string, undefined>;
|
|
43
|
+
theme: ReactNavigation.Theme;
|
|
44
|
+
children: React.ReactElement;
|
|
45
|
+
}) => React.ReactElement) | undefined;
|
|
46
|
+
UNSTABLE_router?: (<Action extends Readonly<{
|
|
47
|
+
type: string;
|
|
48
|
+
payload?: object;
|
|
49
|
+
source?: string;
|
|
50
|
+
target?: string;
|
|
51
|
+
}>>(original: import("@react-navigation/native").Router<TabNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<TabNavigationState<ParamListBase>, Action>>) | undefined;
|
|
52
|
+
} & {
|
|
53
|
+
id?: undefined;
|
|
54
|
+
}>;
|
|
55
|
+
export type BottomTabNavigator = typeof BottomTabNavigator;
|
|
5
56
|
type TabsProps = BottomTabNavigationOptions & {
|
|
6
57
|
href?: Href | null;
|
|
7
58
|
};
|
|
8
|
-
|
|
59
|
+
declare const ExpoTabs: React.ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/bottom-tabs").BottomTabNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
9
60
|
children: React.ReactNode;
|
|
10
61
|
layout?: ((props: {
|
|
11
62
|
state: TabNavigationState<ParamListBase>;
|
|
@@ -107,5 +158,8 @@ export declare const Tabs: React.ForwardRefExoticComponent<Omit<Omit<import("@re
|
|
|
107
158
|
Screen: (props: import("..").ScreenProps<TabsProps, TabNavigationState<ParamListBase>, BottomTabNavigationEventMap>) => null;
|
|
108
159
|
Protected: typeof import("../views/Protected").Protected;
|
|
109
160
|
};
|
|
161
|
+
declare const Tabs: ((props: ComponentProps<typeof ExpoTabs>) => React.JSX.Element) & {
|
|
162
|
+
Screen: (props: import("..").ScreenProps<TabsProps, TabNavigationState<ParamListBase>, BottomTabNavigationEventMap>) => null;
|
|
163
|
+
};
|
|
110
164
|
export default Tabs;
|
|
111
165
|
//# sourceMappingURL=TabsClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsClient.d.ts","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TabsClient.d.ts","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAK9C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIhC,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAuC,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC;AAE3D,KAAK,SAAS,GAAG,0BAA0B,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CZ,CAAC;AAEH,QAAA,MAAM,IAAI,WACA,cAAc,CAAC,OAAO,QAAQ,CAAC;;CAMxC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.Tabs = void 0;
|
|
8
7
|
const bottom_tabs_1 = require("@react-navigation/bottom-tabs");
|
|
9
8
|
const react_1 = __importDefault(require("react"));
|
|
10
9
|
const react_native_1 = require("react-native");
|
|
11
10
|
const withLayoutContext_1 = require("./withLayoutContext");
|
|
12
11
|
const Link_1 = require("../link/Link");
|
|
12
|
+
const TabRouter_1 = require("./TabRouter");
|
|
13
13
|
// This is the only way to access the navigator.
|
|
14
14
|
const BottomTabNavigator = (0, bottom_tabs_1.createBottomTabNavigator)().Navigator;
|
|
15
|
-
|
|
15
|
+
const ExpoTabs = (0, withLayoutContext_1.withLayoutContext)(BottomTabNavigator, (screens) => {
|
|
16
16
|
// Support the `href` shortcut prop.
|
|
17
17
|
return screens.map((screen) => {
|
|
18
18
|
if (typeof screen.options !== 'function' && screen.options?.href !== undefined) {
|
|
@@ -41,5 +41,10 @@ exports.Tabs = (0, withLayoutContext_1.withLayoutContext)(BottomTabNavigator, (s
|
|
|
41
41
|
return screen;
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
const Tabs = Object.assign((props) => {
|
|
45
|
+
return <ExpoTabs {...props} UNSTABLE_router={TabRouter_1.tabRouterOverride}/>;
|
|
46
|
+
}, {
|
|
47
|
+
Screen: ExpoTabs.Screen,
|
|
48
|
+
});
|
|
49
|
+
exports.default = Tabs;
|
|
45
50
|
//# sourceMappingURL=TabsClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsClient.js","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"TabsClient.js","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;AAEb,+DAIuC;AAEvC,kDAA8C;AAC9C,+CAAmD;AAEnD,2DAAwD;AACxD,uCAAoC;AAEpC,2CAAgD;AAEhD,gDAAgD;AAChD,MAAM,kBAAkB,GAAG,IAAA,sCAAwB,GAAE,CAAC,SAAS,CAAC;AAMhE,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAKhC,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;IAChC,oCAAoC;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5B,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/E,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;YAC5C,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;YACpE,CAAC;YACD,OAAO;gBACL,GAAG,MAAM;gBACT,OAAO,EAAE;oBACP,GAAG,OAAO;oBACV,eAAe,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe;oBAC7E,6DAA6D;oBAC7D,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;wBACtB,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;4BACjB,OAAO,IAAI,CAAC;wBACd,CAAC;wBACD,MAAM,QAAQ,GACZ,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,wBAAS,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,wBAAS,CAAC,CAAC;wBACnF,+FAA+F;wBAC/F,0EAA0E;wBAC1E,OAAO,CACL,CAAC,WAAI,CACH,IAAK,KAAa,CAAC,CACnB,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,KAAY,CAAC,CAAC,CACjD,IAAI,CAAC,CAAC,IAAI,CAAC,CACX,OAAO,CAAC,CAAC,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAC/B,QAAQ,CAAC,CAAC,QAAQ,CAAC,EACnB,CACH,CAAC;oBACJ,CAAC;iBACF;aACF,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CACxB,CAAC,KAAsC,EAAE,EAAE;IACzC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,6BAAiB,CAAC,EAAG,CAAC;AACrE,CAAC,EACD;IACE,MAAM,EAAE,QAAQ,CAAC,MAAM;CACxB,CACF,CAAC;AAEF,kBAAe,IAAI,CAAC","sourcesContent":["'use client';\n\nimport {\n BottomTabNavigationEventMap,\n BottomTabNavigationOptions,\n createBottomTabNavigator,\n} from '@react-navigation/bottom-tabs';\nimport { ParamListBase, TabNavigationState } from '@react-navigation/native';\nimport React, { ComponentProps } from 'react';\nimport { Pressable, Platform } from 'react-native';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { Link } from '../link/Link';\nimport { Href } from '../types';\nimport { tabRouterOverride } from './TabRouter';\n\n// This is the only way to access the navigator.\nconst BottomTabNavigator = createBottomTabNavigator().Navigator;\n\nexport type BottomTabNavigator = typeof BottomTabNavigator;\n\ntype TabsProps = BottomTabNavigationOptions & { href?: Href | null };\n\nconst ExpoTabs = withLayoutContext<\n TabsProps,\n typeof BottomTabNavigator,\n TabNavigationState<ParamListBase>,\n BottomTabNavigationEventMap\n>(BottomTabNavigator, (screens) => {\n // Support the `href` shortcut prop.\n return screens.map((screen) => {\n if (typeof screen.options !== 'function' && screen.options?.href !== undefined) {\n const { href, ...options } = screen.options;\n if (options.tabBarButton) {\n throw new Error('Cannot use `href` and `tabBarButton` together.');\n }\n return {\n ...screen,\n options: {\n ...options,\n tabBarItemStyle: href == null ? { display: 'none' } : options.tabBarItemStyle,\n // @ts-expect-error: TODO(@kitten): This isn't properly typed\n tabBarButton: (props) => {\n if (href == null) {\n return null;\n }\n const children =\n Platform.OS === 'web' ? props.children : <Pressable>{props.children}</Pressable>;\n // TODO: React Navigation types these props as Animated.WithAnimatedValue<StyleProp<ViewStyle>>\n // While Link expects a TextStyle. We need to reconcile these types.\n return (\n <Link\n {...(props as any)}\n style={[{ display: 'flex' }, props.style as any]}\n href={href}\n asChild={Platform.OS !== 'web'}\n children={children}\n />\n );\n },\n },\n };\n }\n return screen;\n });\n});\n\nconst Tabs = Object.assign(\n (props: ComponentProps<typeof ExpoTabs>) => {\n return <ExpoTabs {...props} UNSTABLE_router={tabRouterOverride} />;\n },\n {\n Screen: ExpoTabs.Screen,\n }\n);\n\nexport default Tabs;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLayoutContext.d.ts","sourceRoot":"","sources":["../../src/layouts/withLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAc,EAGZ,cAAc,EACd,aAAa,EACb,yBAAyB,EACzB,eAAe,EACf,SAAS,EACT,aAAa,EAEd,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAoB,WAAW,EAAE,MAAM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AAc,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,CACrF,GAAG;IACF,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,KAAK,IAAI,CAAC;IAClE,SAAS,EAAE,OAAO,SAAS,CAAC;CAC7B,CACF"}
|
|
@@ -68,6 +68,7 @@ function useFilterScreenChildren(children, { isCustomNavigator, contextKey, } =
|
|
|
68
68
|
}
|
|
69
69
|
if (isCustomNavigator) {
|
|
70
70
|
customChildren.push(child);
|
|
71
|
+
return null;
|
|
71
72
|
}
|
|
72
73
|
console.warn(`Layout children must be of type Screen, all other children are ignored. To use custom children, create a custom <Layout />. Update Layout Route at: "app${contextKey}/_layout"`);
|
|
73
74
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLayoutContext.js","sourceRoot":"","sources":["../../src/layouts/withLayoutContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,
|
|
1
|
+
{"version":3,"file":"withLayoutContext.js","sourceRoot":"","sources":["../../src/layouts/withLayoutContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,0DAqEC;AAgCD,8CAmCC;AA1JD,+CAUe;AAEf,oCAAyC;AAEzC,8CAA8D;AAC9D,kDAAwE;AACxE,4CAAmD;AAEnD,SAAgB,uBAAuB,CACrC,QAAmB,EACnB,EACE,iBAAiB,EACjB,UAAU,MAKR,EAAE;IAEN,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,MAAM,cAAc,GAAU,EAAE,CAAC;QAEjC,MAAM,OAAO,GAAuC,EAAE,CAAC;QACvD,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;QAE3C,SAAS,YAAY,CAAC,KAAgB,EAAE,OAAO,GAAG,KAAK;YACrD,IAAI,IAAA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GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAG,CAAC;IACxE,CAAC,CAAC,EACF;QACE,MAAM,EAAN,eAAM;QACN,SAAS,EAAT,qBAAS;KACV,CAMF,CAAC;AACJ,CAAC","sourcesContent":["import { EventMapBase, NavigationState } from '@react-navigation/native';\nimport React, {\n Children,\n forwardRef,\n ComponentProps,\n ComponentType,\n ForwardRefExoticComponent,\n PropsWithoutRef,\n ReactNode,\n RefAttributes,\n useMemo,\n} from 'react';\n\nimport { useContextKey } from '../Route';\nimport { PickPartial } from '../types';\nimport { useSortedScreens, ScreenProps } from '../useScreens';\nimport { isProtectedReactElement, Protected } from '../views/Protected';\nimport { isScreen, Screen } from '../views/Screen';\n\nexport function useFilterScreenChildren(\n children: ReactNode,\n {\n isCustomNavigator,\n contextKey,\n }: {\n isCustomNavigator?: boolean;\n /** Used for sending developer hints */\n contextKey?: string;\n } = {}\n) {\n return useMemo(() => {\n const customChildren: any[] = [];\n\n const screens: (ScreenProps & { name: string })[] = [];\n const protectedScreens = new Set<string>();\n\n function flattenChild(child: ReactNode, exclude = false) {\n if (isScreen(child, contextKey)) {\n if (exclude) {\n protectedScreens.add(child.props.name);\n } else {\n screens.push(child.props);\n }\n return;\n }\n\n if (isProtectedReactElement(child)) {\n if (child.props.guard) {\n Children.forEach(child.props.children, (protectedChild) => flattenChild(protectedChild));\n } else {\n Children.forEach(child.props.children, (protectedChild) => {\n flattenChild(protectedChild, true);\n });\n }\n return;\n }\n\n if (isCustomNavigator) {\n customChildren.push(child);\n return null;\n }\n\n console.warn(\n `Layout children must be of type Screen, all other children are ignored. To use custom children, create a custom <Layout />. Update Layout Route at: \"app${contextKey}/_layout\"`\n );\n\n return null;\n }\n\n Children.forEach(children, (child) => flattenChild(child));\n\n // Add an assertion for development\n if (process.env.NODE_ENV !== 'production') {\n // Assert if names are not unique\n const names = screens?.map(\n (screen) => screen && typeof screen === 'object' && 'name' in screen && screen.name\n );\n if (names && new Set(names).size !== names.length) {\n throw new Error('Screen names must be unique: ' + names);\n }\n }\n\n return {\n screens,\n children: customChildren,\n protectedScreens,\n };\n }, [children]);\n}\n\n/**\n * Returns a navigator that automatically injects matched routes and renders nothing when there are no children.\n * Return type with `children` prop optional.\n * \n * Enables use of other built-in React Navigation navigators and other navigators built with the React Navigation custom navigator API.\n *\n * @example\n * ```tsx app/_layout.tsx\n * import { ParamListBase, TabNavigationState } from \"@react-navigation/native\";\n * import {\n * createMaterialTopTabNavigator,\n * MaterialTopTabNavigationOptions,\n * MaterialTopTabNavigationEventMap,\n * } from \"@react-navigation/material-top-tabs\";\n * import { withLayoutContext } from \"expo-router\";\n * \n * const MaterialTopTabs = createMaterialTopTabNavigator();\n * \n * const ExpoRouterMaterialTopTabs = withLayoutContext<\n * MaterialTopTabNavigationOptions,\n * typeof MaterialTopTabs.Navigator,\n * TabNavigationState<ParamListBase>,\n * MaterialTopTabNavigationEventMap\n * >(MaterialTopTabs.Navigator);\n\n * export default function TabLayout() {\n * return <ExpoRouterMaterialTopTabs />;\n * }\n * ```\n */\nexport function withLayoutContext<\n TOptions extends object,\n T extends ComponentType<any>,\n TState extends NavigationState,\n TEventMap extends EventMapBase,\n>(Nav: T, processor?: (options: ScreenProps[]) => ScreenProps[]) {\n return Object.assign(\n forwardRef(({ children: userDefinedChildren, ...props }: any, ref) => {\n const contextKey = useContextKey();\n\n const { screens, protectedScreens } = useFilterScreenChildren(userDefinedChildren, {\n contextKey,\n });\n\n const processed = processor ? processor(screens ?? []) : screens;\n\n const sorted = useSortedScreens(processed ?? [], protectedScreens);\n\n // Prevent throwing an error when there are no screens.\n if (!sorted.length) {\n return null;\n }\n\n return <Nav {...props} id={contextKey} ref={ref} children={sorted} />;\n }),\n {\n Screen,\n Protected,\n }\n ) as ForwardRefExoticComponent<\n PropsWithoutRef<PickPartial<ComponentProps<T>, 'children'>> & RefAttributes<unknown>\n > & {\n Screen: (props: ScreenProps<TOptions, TState, TEventMap>) => null;\n Protected: typeof Protected;\n };\n}\n"]}
|
|
@@ -212,7 +212,7 @@ function getHistory() {
|
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
214
|
function useRouter_UNSTABLE() {
|
|
215
|
-
const router = (0, react_1.
|
|
215
|
+
const router = (0, react_1.use)(RouterContext);
|
|
216
216
|
if (!router) {
|
|
217
217
|
throw new Error('Missing Router');
|
|
218
218
|
}
|
|
@@ -356,7 +356,7 @@ children, ...props }, ref) {
|
|
|
356
356
|
}
|
|
357
357
|
return (0, href_1.resolveHref)(href);
|
|
358
358
|
}, [href]);
|
|
359
|
-
const router = (0, react_1.
|
|
359
|
+
const router = (0, react_1.use)(RouterContext);
|
|
360
360
|
const changeRoute = router
|
|
361
361
|
? router.changeRoute
|
|
362
362
|
: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/rsc/router/client.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,YAAY,CAAC;AAVb;;;;;;;;GAQG;;;AAqRH,gDAgGC;AAoED,wBAUC;AASD,oCAgBC;AAxdD,qDAAyD;AACzD,iCAae;AAUf,+CAAoC;AAEpC,2CAA8E;AAE9E,uCAAgE;AAIhE,0CAA8C;AAC9C,0DAA4E;AAG5E,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC1C,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC;QAC1C,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAc,EAAE;IAC1C,IAAK,UAAkB,CAAC,mBAAmB,EAA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AU,EAAE,CAAC,KAAK;gBACrB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC,QAAQ;aACzD,EACD,EAAE,EACF,GAAG,CACJ,CAAC;YACF,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,IAAI;QACJ,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,gDAAgD;IAChD,kDAAkD;IAClD,4CAA4C;IAC5C,sCAAsC;IACtC,yCAAyC;IACzC,gCAAgC;IAChC,UAAU;IACV,qCAAqC;IACrC,QAAQ;IACR,0BAA0B;IAE1B,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,iBAAS,CAAC,CAAC,CAAC,mBAAI,CAAC;IAE3C,MAAM,GAAG,GAAG,IAAA,qBAAa;IACvB,mBAAmB;IACnB,OAAO,EACP;QACE,GAAG,SAAS;QACZ,GAAG,KAAK;QACR,KAAK;QACL,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,OAAO;QAChB,gBAAgB;QAChB,GAAG;KACJ,EACD,QAAQ,CACT,CAAC;IACF,4CAA4C;IAC5C,wDAAwD;IACxD,IAAI;IACJ,gDAAgD;IAChD,2DAA2D;IAC3D,IAAI;IACJ,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n * Copyright © 2024 2023 Daishi Kato\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * https://github.com/dai-shi/waku/blob/3d1cc7d714b67b142c847e879c30f0724fc457a7/packages/waku/src/router/client.ts#L1\n */\n\n'use client';\n\nimport { Slot as ReactSlot } from '@radix-ui/react-slot';\nimport {\n startTransition,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useTransition,\n createElement,\n createContext,\n useState,\n Fragment,\n forwardRef,\n useMemo,\n} from 'react';\nimport type {\n ComponentProps,\n FunctionComponent,\n ReactNode,\n MutableRefObject,\n AnchorHTMLAttributes,\n MouseEvent,\n ForwardedRef,\n} from 'react';\nimport { Text } from 'react-native';\n\nimport { PARAM_KEY_SKIP, getComponentIds, getInputString } from './common.js';\nimport type { RouteProps } from './common.js';\nimport { prefetchRSC, Root, Slot, useRefetch } from './host.js';\nimport type { NavigationOptions } from '../../global-state/routing.js';\nimport type { Router as ClassicExpoRouterType } from '../../imperative-api';\nimport type { LinkProps as ClassicLinkProps, LinkComponent } from '../../link/Link.js';\nimport { resolveHref } from '../../link/href';\nimport { useInteropClassName, useHrefAttrs } from '../../link/useLinkHooks';\nimport type { Href } from '../../types.js';\n\nconst normalizeRoutePath = (path: string) => {\n for (const suffix of ['/', '/index.html']) {\n if (path.endsWith(suffix)) {\n return path.slice(0, -suffix.length) || '/';\n }\n }\n return path;\n};\n\nconst parseRoute = (url: URL): RouteProps => {\n if ((globalThis as any).__EXPO_ROUTER_404__) {\n return { path: '/404', query: '', hash: '' };\n }\n const { pathname, searchParams, hash } = url;\n if (searchParams.has(PARAM_KEY_SKIP)) {\n console.warn(`The search param \"${PARAM_KEY_SKIP}\" is reserved`);\n }\n return {\n path: normalizeRoutePath(pathname),\n query: searchParams.toString(),\n hash,\n };\n};\nconst getHref = () =>\n process.env.EXPO_OS === 'web'\n ? window.location.href\n : // TODO: This is hardcoded on native to simplify the initial PR.\n 'http://localhost:8081/';\n\ntype ChangeRoute = (\n route: RouteProps,\n options?: {\n checkCache?: boolean;\n skipRefetch?: boolean;\n }\n) => void;\n\ntype PrefetchRoute = (route: RouteProps) => void;\n\nconst equalRouteProps = (a: RouteProps, b: RouteProps) => {\n if (a.path !== b.path) {\n return false;\n }\n if (a.query !== b.query) {\n return false;\n }\n return true;\n};\n\nconst RouterContext = createContext<{\n route: RouteProps;\n changeRoute: ChangeRoute;\n prefetchRoute: PrefetchRoute;\n} | null>(null);\n\nconst InnerRouter = ({ routerData }: { routerData: RouterData }) => {\n const refetch = useRefetch();\n\n const initialRouteRef = useRef<RouteProps>(null);\n if (!initialRouteRef.current) {\n initialRouteRef.current = parseRoute(new URL(getHref()));\n }\n const [route, setRoute] = useState(() => ({\n // This is the first initialization of the route, and it has\n // to ignore the hash, because on server side there is none.\n // Otherwise there will be a hydration error.\n // The client side route, including the hash, will be updated in the effect below.\n ...initialRouteRef.current!,\n hash: '',\n }));\n\n // Update the route post-load to include the current hash.\n useEffect(() => {\n const initialRoute = initialRouteRef.current!;\n setRoute((prev) => {\n if (\n prev.path === initialRoute.path &&\n prev.query === initialRoute.query &&\n prev.hash === initialRoute.hash\n ) {\n return prev;\n }\n return initialRoute;\n });\n }, []);\n\n const componentIds = getComponentIds(route.path);\n\n // const refetchRoute = () => {\n // const loc = parseRoute(new URL(getHref()));\n // const input = getInputString(loc.path);\n // refetch(input, loc.query);\n // refetch(input, JSON.stringify({ query: route.query }));\n // };\n // globalThis.__EXPO_REFETCH_ROUTE_NO_CACHE__ = refetchRoute;\n\n const [cached, setCached] = useState<Record<string, RouteProps>>(() => {\n return Object.fromEntries(componentIds.map((id) => [id, route]));\n });\n const cachedRef = useRef(cached);\n useEffect(() => {\n cachedRef.current = cached;\n }, [cached]);\n\n const changeRoute: ChangeRoute = useCallback(\n (route, options) => {\n const { checkCache, skipRefetch } = options || {};\n startTransition(() => {\n setRoute(route);\n });\n const componentIds = getComponentIds(route.path);\n if (\n checkCache &&\n componentIds.every((id) => {\n const cachedLoc = cachedRef.current[id];\n return cachedLoc && equalRouteProps(cachedLoc, route);\n })\n ) {\n return; // everything is cached\n }\n const shouldSkip = routerData[0];\n const skip = getSkipList(shouldSkip, componentIds, route, cachedRef.current);\n if (componentIds.every((id) => skip.includes(id))) {\n return; // everything is skipped\n }\n const input = getInputString(route.path);\n if (!skipRefetch) {\n refetch(input, JSON.stringify({ query: route.query, skip }));\n }\n startTransition(() => {\n setCached((prev) => ({\n ...prev,\n ...Object.fromEntries(\n componentIds.flatMap((id) => (skip.includes(id) ? [] : [[id, route]]))\n ),\n }));\n });\n },\n [refetch, routerData]\n );\n\n const prefetchRoute: PrefetchRoute = useCallback(\n (route) => {\n const componentIds = getComponentIds(route.path);\n const shouldSkip = routerData[0];\n const skip = getSkipList(shouldSkip, componentIds, route, cachedRef.current);\n if (componentIds.every((id) => skip.includes(id))) {\n return; // everything is cached\n }\n const input = getInputString(route.path);\n prefetchRSC(input, JSON.stringify({ query: route.query, skip }));\n (globalThis as any).__EXPO_ROUTER_PREFETCH__?.(route.path);\n },\n [routerData]\n );\n\n useEffect(() => {\n const callback = () => {\n const route = parseRoute(new URL(getHref()));\n changeRoute(route, { checkCache: true });\n };\n if (window.addEventListener) {\n window.addEventListener('popstate', callback);\n return () => {\n window.removeEventListener('popstate', callback);\n };\n }\n return () => {};\n }, [changeRoute]);\n\n useEffect(() => {\n const callback = (pathname: string, searchParamsString: string) => {\n const url = new URL(getHref());\n url.pathname = pathname;\n url.search = searchParamsString;\n url.hash = '';\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(parseRoute(url), { skipRefetch: true });\n };\n // eslint-disable-next-line no-multi-assign\n const listeners = (routerData[1] ||= new Set());\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n }, [changeRoute, routerData]);\n\n useEffect(() => {\n const { hash } = window.location;\n const { state } = getHistory();\n const element = hash && document.getElementById(hash.slice(1));\n if (window.scrollTo) {\n window.scrollTo({\n left: 0,\n top: element ? element.getBoundingClientRect().top + window.scrollY : 0,\n behavior: state?.expo_new_path ? 'instant' : 'auto',\n });\n } else {\n // TODO: Native\n // console.log('window.scrollTo is not available');\n }\n });\n\n const children = componentIds.reduceRight(\n (acc: ReactNode, id) =>\n createElement(RouterSlot, { route, routerData, cachedRef, id, fallback: acc }, acc),\n null\n );\n\n return createElement(\n RouterContext.Provider,\n { value: { route, changeRoute, prefetchRoute } },\n children\n );\n};\n\nfunction getHistory() {\n if (process.env.EXPO_OS === 'web') {\n return window.history;\n }\n // Native shim\n return {\n pushState: () => {},\n replaceState: () => {},\n back: () => {},\n forward: () => {},\n state: {},\n };\n}\n\nexport function useRouter_UNSTABLE(): ClassicExpoRouterType &\n RouteProps & {\n forward: () => void;\n prefetch: (href: Href) => void;\n } {\n const router = useContext(RouterContext);\n if (!router) {\n throw new Error('Missing Router');\n }\n const { route, changeRoute, prefetchRoute } = router;\n const push: ClassicExpoRouterType['push'] = useCallback(\n (href: Href, options?: NavigationOptions) => {\n if (options) {\n // TODO(Bacon): Implement options\n console.warn(\n 'options prop of router.push() is not supported in React Server Components yet'\n );\n }\n\n const url = new URL(resolveHref(href), getHref());\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(parseRoute(url));\n },\n [changeRoute]\n );\n const replace: ClassicExpoRouterType['replace'] = useCallback(\n (href: Href, options?: NavigationOptions) => {\n if (options) {\n // TODO(Bacon): Implement options\n console.warn(\n 'options prop of router.replace() is not supported in React Server Components yet'\n );\n }\n\n const url = new URL(resolveHref(href), getHref());\n getHistory().replaceState(getHistory().state, '', url);\n changeRoute(parseRoute(url));\n },\n [changeRoute]\n );\n const reload = useCallback(() => {\n const url = new URL(getHref());\n changeRoute(parseRoute(url));\n }, [changeRoute]);\n const back = useCallback(() => {\n // FIXME is this correct?\n getHistory().back();\n }, []);\n const forward = useCallback(() => {\n // FIXME is this correct?\n getHistory().forward();\n }, []);\n const prefetch = useCallback(\n (href: Href) => {\n const url = new URL(resolveHref(href), getHref());\n prefetchRoute(parseRoute(url));\n },\n [prefetchRoute]\n );\n return {\n ...route,\n canDismiss() {\n throw new Error('router.canDismiss() is not supported in React Server Components yet');\n },\n canGoBack() {\n throw new Error('router.canGoBack() is not supported in React Server Components yet');\n },\n dismiss() {\n throw new Error('router.dismiss() is not supported in React Server Components yet');\n },\n dismissTo() {\n throw new Error('router.dismissTo() is not supported in React Server Components yet');\n },\n dismissAll() {\n throw new Error('router.dismissAll() is not supported in React Server Components yet');\n },\n setParams() {\n throw new Error('router.setParams() is not supported in React Server Components yet');\n },\n\n // TODO: The behavior here is not the same as before.\n navigate: push,\n push,\n replace,\n reload,\n back,\n forward,\n prefetch,\n };\n}\n\nconst RouterSlot = ({\n route,\n routerData,\n cachedRef,\n id,\n fallback,\n children,\n}: {\n route: RouteProps;\n routerData: RouterData;\n cachedRef: MutableRefObject<Record<string, RouteProps>>;\n id: string;\n fallback?: ReactNode;\n children?: ReactNode;\n}) => {\n // const unstable_shouldRenderPrev = (_err: unknown) => {\n // const shouldSkip = routerData[0];\n // const skip = getSkipList(shouldSkip, [id], route, cachedRef.current);\n // return skip.length > 0;\n // };\n return createElement(Slot, { id, fallback }, children);\n};\n\nconst getSkipList = (\n shouldSkip: ShouldSkip | undefined,\n componentIds: readonly string[],\n route: RouteProps,\n cached: Record<string, RouteProps>\n): string[] => {\n const shouldSkipObj = Object.fromEntries(shouldSkip || []);\n return componentIds.filter((id) => {\n const prevProps = cached[id];\n if (!prevProps) {\n return false;\n }\n const shouldCheck = shouldSkipObj[id];\n if (!shouldCheck) {\n return false;\n }\n if (shouldCheck[0] && route.path !== prevProps.path) {\n return false;\n }\n if (shouldCheck[0] && route.query !== prevProps.query) {\n return false;\n }\n return true;\n });\n};\n\n// TODO revisit shouldSkip API\ntype ShouldSkip = (readonly [\n string,\n readonly [\n boolean, // if we compare path\n string[], // searchParams keys to compare\n ],\n])[];\n\n// Note: The router data must be a stable mutable object (array).\ntype RouterData = [\n shouldSkip?: ShouldSkip,\n locationListeners?: Set<(path: string, query: string) => void>,\n];\n\nconst DEFAULT_ROUTER_DATA: RouterData = [];\n\nexport function Router({ routerData = DEFAULT_ROUTER_DATA }) {\n const route = parseRoute(new URL(getHref()));\n const initialInput = getInputString(route.path);\n const initialParams = JSON.stringify({ query: route.query });\n const unstable_onFetchData = () => {};\n return createElement(\n Root as FunctionComponent<Omit<ComponentProps<typeof Root>, 'children'>>,\n { initialInput, initialParams, unstable_onFetchData },\n createElement(InnerRouter, { routerData })\n );\n}\n\nconst notAvailableInServer = (name: string) => () => {\n throw new Error(`${name} is not in the server`);\n};\n/**\n * ServerRouter for SSR\n * This is not a public API.\n */\nexport function ServerRouter({ children, route }: { children: ReactNode; route: RouteProps }) {\n return createElement(\n Fragment,\n null,\n createElement(\n RouterContext.Provider,\n {\n value: {\n route,\n changeRoute: notAvailableInServer('changeRoute'),\n prefetchRoute: notAvailableInServer('prefetchRoute'),\n },\n },\n children\n )\n );\n}\n\nexport type LinkProps = ClassicLinkProps & {\n href: string;\n // pending?: ReactNode;\n // notPending?: ReactNode;\n\n // unstable_prefetchOnEnter?: boolean;\n // unstable_prefetchOnView?: boolean;\n} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>;\n\nexport const Link = forwardRef(ExpoRouterLink) as unknown as LinkComponent;\n\nLink.resolveHref = resolveHref;\n\nfunction ExpoRouterLink(\n {\n href,\n replace,\n push,\n // TODO: This does not prevent default on the anchor tag.\n relativeToDirectory,\n asChild,\n rel,\n target,\n download,\n // pending,\n // notPending,\n // unstable_prefetchOnEnter,\n // unstable_prefetchOnView,\n children,\n ...props\n }: LinkProps,\n ref: ForwardedRef<Text>\n) {\n // Mutate the style prop to add the className on web.\n const style = useInteropClassName(props);\n\n // If not passing asChild, we need to forward the props to the anchor tag using React Native Web's `hrefAttrs`.\n const hrefAttrs = useHrefAttrs({ asChild, rel, target, download });\n\n const resolvedHref = useMemo(() => {\n if (href == null) {\n throw new Error('Link: href is required');\n }\n return resolveHref(href);\n }, [href]);\n\n const router = useContext(RouterContext);\n const changeRoute = router\n ? router.changeRoute\n : () => {\n throw new Error('Missing Router');\n };\n const prefetchRoute = router\n ? router.prefetchRoute\n : () => {\n throw new Error('Missing Router');\n };\n // TODO: Implement support for pending states in the future.\n const [, startTransition] = useTransition();\n // const elementRef = useRef<HTMLAnchorElement>();\n\n // useEffect(() => {\n // if (unstable_prefetchOnView && process.env.EXPO_OS === 'web' && ref.current) {\n // const observer = new IntersectionObserver(\n // (entries) => {\n // entries.forEach((entry) => {\n // if (entry.isIntersecting) {\n // const url = new URL(resolvedHref, getHref());\n // if (router && url.href !== getHref()) {\n // const route = parseRoute(url);\n // router.prefetchRoute(route);\n // }\n // }\n // });\n // },\n // { threshold: 0.1 }\n // );\n\n // observer.observe(ref.current);\n\n // return () => {\n // observer.disconnect();\n // };\n // }\n // return () => {};\n // }, [unstable_prefetchOnView, router, resolvedHref]);\n\n const onClick = (event: MouseEvent<HTMLAnchorElement>) => {\n event.preventDefault();\n const url = new URL(resolvedHref, getHref());\n // TODO: Use in-memory route for native platforms.\n // if (url.href !== getHref()) {\n const route = parseRoute(url);\n prefetchRoute(route);\n startTransition(() => {\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(route);\n });\n // }\n props.onClick?.(event);\n };\n // const onMouseEnter = unstable_prefetchOnEnter\n // ? (event: MouseEvent<HTMLAnchorElement>) => {\n // const url = new URL(to, getHref());\n // if (url.href !== getHref()) {\n // const route = parseRoute(url);\n // prefetchRoute(route);\n // }\n // props.onMouseEnter?.(event);\n // }\n // : props.onMouseEnter;\n\n const Element = asChild ? ReactSlot : Text;\n\n const ele = createElement(\n // @ts-expect-error\n Element,\n {\n ...hrefAttrs,\n ...props,\n style,\n href: resolvedHref,\n onPress: onClick,\n // onMouseEnter,\n ref,\n },\n children\n );\n // if (isPending && pending !== undefined) {\n // return createElement(Fragment, null, ele, pending);\n // }\n // if (!isPending && notPending !== undefined) {\n // return createElement(Fragment, null, ele, notPending);\n // }\n return ele;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/rsc/router/client.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,YAAY,CAAC;AAVb;;;;;;;;GAQG;;;AAqRH,gDAgGC;AAoED,wBAUC;AASD,oCAgBC;AAxdD,qDAAyD;AACzD,iCAae;AAUf,+CAAoC;AAEpC,2CAA8E;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D;IACxD,IAAI;IACJ,gDAAgD;IAChD,2DAA2D;IAC3D,IAAI;IACJ,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n * Copyright © 2024 2023 Daishi Kato\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * https://github.com/dai-shi/waku/blob/3d1cc7d714b67b142c847e879c30f0724fc457a7/packages/waku/src/router/client.ts#L1\n */\n\n'use client';\n\nimport { Slot as ReactSlot } from '@radix-ui/react-slot';\nimport {\n startTransition,\n useCallback,\n use,\n useEffect,\n useRef,\n useTransition,\n createElement,\n createContext,\n useState,\n Fragment,\n forwardRef,\n useMemo,\n} from 'react';\nimport type {\n ComponentProps,\n FunctionComponent,\n ReactNode,\n MutableRefObject,\n AnchorHTMLAttributes,\n MouseEvent,\n ForwardedRef,\n} from 'react';\nimport { Text } from 'react-native';\n\nimport { PARAM_KEY_SKIP, getComponentIds, getInputString } from './common.js';\nimport type { RouteProps } from './common.js';\nimport { prefetchRSC, Root, Slot, useRefetch } from './host.js';\nimport type { NavigationOptions } from '../../global-state/routing.js';\nimport type { Router as ClassicExpoRouterType } from '../../imperative-api';\nimport type { LinkProps as ClassicLinkProps, LinkComponent } from '../../link/Link.js';\nimport { resolveHref } from '../../link/href';\nimport { useInteropClassName, useHrefAttrs } from '../../link/useLinkHooks';\nimport type { Href } from '../../types.js';\n\nconst normalizeRoutePath = (path: string) => {\n for (const suffix of ['/', '/index.html']) {\n if (path.endsWith(suffix)) {\n return path.slice(0, -suffix.length) || '/';\n }\n }\n return path;\n};\n\nconst parseRoute = (url: URL): RouteProps => {\n if ((globalThis as any).__EXPO_ROUTER_404__) {\n return { path: '/404', query: '', hash: '' };\n }\n const { pathname, searchParams, hash } = url;\n if (searchParams.has(PARAM_KEY_SKIP)) {\n console.warn(`The search param \"${PARAM_KEY_SKIP}\" is reserved`);\n }\n return {\n path: normalizeRoutePath(pathname),\n query: searchParams.toString(),\n hash,\n };\n};\nconst getHref = () =>\n process.env.EXPO_OS === 'web'\n ? window.location.href\n : // TODO: This is hardcoded on native to simplify the initial PR.\n 'http://localhost:8081/';\n\ntype ChangeRoute = (\n route: RouteProps,\n options?: {\n checkCache?: boolean;\n skipRefetch?: boolean;\n }\n) => void;\n\ntype PrefetchRoute = (route: RouteProps) => void;\n\nconst equalRouteProps = (a: RouteProps, b: RouteProps) => {\n if (a.path !== b.path) {\n return false;\n }\n if (a.query !== b.query) {\n return false;\n }\n return true;\n};\n\nconst RouterContext = createContext<{\n route: RouteProps;\n changeRoute: ChangeRoute;\n prefetchRoute: PrefetchRoute;\n} | null>(null);\n\nconst InnerRouter = ({ routerData }: { routerData: RouterData }) => {\n const refetch = useRefetch();\n\n const initialRouteRef = useRef<RouteProps>(null);\n if (!initialRouteRef.current) {\n initialRouteRef.current = parseRoute(new URL(getHref()));\n }\n const [route, setRoute] = useState(() => ({\n // This is the first initialization of the route, and it has\n // to ignore the hash, because on server side there is none.\n // Otherwise there will be a hydration error.\n // The client side route, including the hash, will be updated in the effect below.\n ...initialRouteRef.current!,\n hash: '',\n }));\n\n // Update the route post-load to include the current hash.\n useEffect(() => {\n const initialRoute = initialRouteRef.current!;\n setRoute((prev) => {\n if (\n prev.path === initialRoute.path &&\n prev.query === initialRoute.query &&\n prev.hash === initialRoute.hash\n ) {\n return prev;\n }\n return initialRoute;\n });\n }, []);\n\n const componentIds = getComponentIds(route.path);\n\n // const refetchRoute = () => {\n // const loc = parseRoute(new URL(getHref()));\n // const input = getInputString(loc.path);\n // refetch(input, loc.query);\n // refetch(input, JSON.stringify({ query: route.query }));\n // };\n // globalThis.__EXPO_REFETCH_ROUTE_NO_CACHE__ = refetchRoute;\n\n const [cached, setCached] = useState<Record<string, RouteProps>>(() => {\n return Object.fromEntries(componentIds.map((id) => [id, route]));\n });\n const cachedRef = useRef(cached);\n useEffect(() => {\n cachedRef.current = cached;\n }, [cached]);\n\n const changeRoute: ChangeRoute = useCallback(\n (route, options) => {\n const { checkCache, skipRefetch } = options || {};\n startTransition(() => {\n setRoute(route);\n });\n const componentIds = getComponentIds(route.path);\n if (\n checkCache &&\n componentIds.every((id) => {\n const cachedLoc = cachedRef.current[id];\n return cachedLoc && equalRouteProps(cachedLoc, route);\n })\n ) {\n return; // everything is cached\n }\n const shouldSkip = routerData[0];\n const skip = getSkipList(shouldSkip, componentIds, route, cachedRef.current);\n if (componentIds.every((id) => skip.includes(id))) {\n return; // everything is skipped\n }\n const input = getInputString(route.path);\n if (!skipRefetch) {\n refetch(input, JSON.stringify({ query: route.query, skip }));\n }\n startTransition(() => {\n setCached((prev) => ({\n ...prev,\n ...Object.fromEntries(\n componentIds.flatMap((id) => (skip.includes(id) ? [] : [[id, route]]))\n ),\n }));\n });\n },\n [refetch, routerData]\n );\n\n const prefetchRoute: PrefetchRoute = useCallback(\n (route) => {\n const componentIds = getComponentIds(route.path);\n const shouldSkip = routerData[0];\n const skip = getSkipList(shouldSkip, componentIds, route, cachedRef.current);\n if (componentIds.every((id) => skip.includes(id))) {\n return; // everything is cached\n }\n const input = getInputString(route.path);\n prefetchRSC(input, JSON.stringify({ query: route.query, skip }));\n (globalThis as any).__EXPO_ROUTER_PREFETCH__?.(route.path);\n },\n [routerData]\n );\n\n useEffect(() => {\n const callback = () => {\n const route = parseRoute(new URL(getHref()));\n changeRoute(route, { checkCache: true });\n };\n if (window.addEventListener) {\n window.addEventListener('popstate', callback);\n return () => {\n window.removeEventListener('popstate', callback);\n };\n }\n return () => {};\n }, [changeRoute]);\n\n useEffect(() => {\n const callback = (pathname: string, searchParamsString: string) => {\n const url = new URL(getHref());\n url.pathname = pathname;\n url.search = searchParamsString;\n url.hash = '';\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(parseRoute(url), { skipRefetch: true });\n };\n // eslint-disable-next-line no-multi-assign\n const listeners = (routerData[1] ||= new Set());\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n }, [changeRoute, routerData]);\n\n useEffect(() => {\n const { hash } = window.location;\n const { state } = getHistory();\n const element = hash && document.getElementById(hash.slice(1));\n if (window.scrollTo) {\n window.scrollTo({\n left: 0,\n top: element ? element.getBoundingClientRect().top + window.scrollY : 0,\n behavior: state?.expo_new_path ? 'instant' : 'auto',\n });\n } else {\n // TODO: Native\n // console.log('window.scrollTo is not available');\n }\n });\n\n const children = componentIds.reduceRight(\n (acc: ReactNode, id) =>\n createElement(RouterSlot, { route, routerData, cachedRef, id, fallback: acc }, acc),\n null\n );\n\n return createElement(\n RouterContext.Provider,\n { value: { route, changeRoute, prefetchRoute } },\n children\n );\n};\n\nfunction getHistory() {\n if (process.env.EXPO_OS === 'web') {\n return window.history;\n }\n // Native shim\n return {\n pushState: () => {},\n replaceState: () => {},\n back: () => {},\n forward: () => {},\n state: {},\n };\n}\n\nexport function useRouter_UNSTABLE(): ClassicExpoRouterType &\n RouteProps & {\n forward: () => void;\n prefetch: (href: Href) => void;\n } {\n const router = use(RouterContext);\n if (!router) {\n throw new Error('Missing Router');\n }\n const { route, changeRoute, prefetchRoute } = router;\n const push: ClassicExpoRouterType['push'] = useCallback(\n (href: Href, options?: NavigationOptions) => {\n if (options) {\n // TODO(Bacon): Implement options\n console.warn(\n 'options prop of router.push() is not supported in React Server Components yet'\n );\n }\n\n const url = new URL(resolveHref(href), getHref());\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(parseRoute(url));\n },\n [changeRoute]\n );\n const replace: ClassicExpoRouterType['replace'] = useCallback(\n (href: Href, options?: NavigationOptions) => {\n if (options) {\n // TODO(Bacon): Implement options\n console.warn(\n 'options prop of router.replace() is not supported in React Server Components yet'\n );\n }\n\n const url = new URL(resolveHref(href), getHref());\n getHistory().replaceState(getHistory().state, '', url);\n changeRoute(parseRoute(url));\n },\n [changeRoute]\n );\n const reload = useCallback(() => {\n const url = new URL(getHref());\n changeRoute(parseRoute(url));\n }, [changeRoute]);\n const back = useCallback(() => {\n // FIXME is this correct?\n getHistory().back();\n }, []);\n const forward = useCallback(() => {\n // FIXME is this correct?\n getHistory().forward();\n }, []);\n const prefetch = useCallback(\n (href: Href) => {\n const url = new URL(resolveHref(href), getHref());\n prefetchRoute(parseRoute(url));\n },\n [prefetchRoute]\n );\n return {\n ...route,\n canDismiss() {\n throw new Error('router.canDismiss() is not supported in React Server Components yet');\n },\n canGoBack() {\n throw new Error('router.canGoBack() is not supported in React Server Components yet');\n },\n dismiss() {\n throw new Error('router.dismiss() is not supported in React Server Components yet');\n },\n dismissTo() {\n throw new Error('router.dismissTo() is not supported in React Server Components yet');\n },\n dismissAll() {\n throw new Error('router.dismissAll() is not supported in React Server Components yet');\n },\n setParams() {\n throw new Error('router.setParams() is not supported in React Server Components yet');\n },\n\n // TODO: The behavior here is not the same as before.\n navigate: push,\n push,\n replace,\n reload,\n back,\n forward,\n prefetch,\n };\n}\n\nconst RouterSlot = ({\n route,\n routerData,\n cachedRef,\n id,\n fallback,\n children,\n}: {\n route: RouteProps;\n routerData: RouterData;\n cachedRef: MutableRefObject<Record<string, RouteProps>>;\n id: string;\n fallback?: ReactNode;\n children?: ReactNode;\n}) => {\n // const unstable_shouldRenderPrev = (_err: unknown) => {\n // const shouldSkip = routerData[0];\n // const skip = getSkipList(shouldSkip, [id], route, cachedRef.current);\n // return skip.length > 0;\n // };\n return createElement(Slot, { id, fallback }, children);\n};\n\nconst getSkipList = (\n shouldSkip: ShouldSkip | undefined,\n componentIds: readonly string[],\n route: RouteProps,\n cached: Record<string, RouteProps>\n): string[] => {\n const shouldSkipObj = Object.fromEntries(shouldSkip || []);\n return componentIds.filter((id) => {\n const prevProps = cached[id];\n if (!prevProps) {\n return false;\n }\n const shouldCheck = shouldSkipObj[id];\n if (!shouldCheck) {\n return false;\n }\n if (shouldCheck[0] && route.path !== prevProps.path) {\n return false;\n }\n if (shouldCheck[0] && route.query !== prevProps.query) {\n return false;\n }\n return true;\n });\n};\n\n// TODO revisit shouldSkip API\ntype ShouldSkip = (readonly [\n string,\n readonly [\n boolean, // if we compare path\n string[], // searchParams keys to compare\n ],\n])[];\n\n// Note: The router data must be a stable mutable object (array).\ntype RouterData = [\n shouldSkip?: ShouldSkip,\n locationListeners?: Set<(path: string, query: string) => void>,\n];\n\nconst DEFAULT_ROUTER_DATA: RouterData = [];\n\nexport function Router({ routerData = DEFAULT_ROUTER_DATA }) {\n const route = parseRoute(new URL(getHref()));\n const initialInput = getInputString(route.path);\n const initialParams = JSON.stringify({ query: route.query });\n const unstable_onFetchData = () => {};\n return createElement(\n Root as FunctionComponent<Omit<ComponentProps<typeof Root>, 'children'>>,\n { initialInput, initialParams, unstable_onFetchData },\n createElement(InnerRouter, { routerData })\n );\n}\n\nconst notAvailableInServer = (name: string) => () => {\n throw new Error(`${name} is not in the server`);\n};\n/**\n * ServerRouter for SSR\n * This is not a public API.\n */\nexport function ServerRouter({ children, route }: { children: ReactNode; route: RouteProps }) {\n return createElement(\n Fragment,\n null,\n createElement(\n RouterContext.Provider,\n {\n value: {\n route,\n changeRoute: notAvailableInServer('changeRoute'),\n prefetchRoute: notAvailableInServer('prefetchRoute'),\n },\n },\n children\n )\n );\n}\n\nexport type LinkProps = ClassicLinkProps & {\n href: string;\n // pending?: ReactNode;\n // notPending?: ReactNode;\n\n // unstable_prefetchOnEnter?: boolean;\n // unstable_prefetchOnView?: boolean;\n} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>;\n\nexport const Link = forwardRef(ExpoRouterLink) as unknown as LinkComponent;\n\nLink.resolveHref = resolveHref;\n\nfunction ExpoRouterLink(\n {\n href,\n replace,\n push,\n // TODO: This does not prevent default on the anchor tag.\n relativeToDirectory,\n asChild,\n rel,\n target,\n download,\n // pending,\n // notPending,\n // unstable_prefetchOnEnter,\n // unstable_prefetchOnView,\n children,\n ...props\n }: LinkProps,\n ref: ForwardedRef<Text>\n) {\n // Mutate the style prop to add the className on web.\n const style = useInteropClassName(props);\n\n // If not passing asChild, we need to forward the props to the anchor tag using React Native Web's `hrefAttrs`.\n const hrefAttrs = useHrefAttrs({ asChild, rel, target, download });\n\n const resolvedHref = useMemo(() => {\n if (href == null) {\n throw new Error('Link: href is required');\n }\n return resolveHref(href);\n }, [href]);\n\n const router = use(RouterContext);\n const changeRoute = router\n ? router.changeRoute\n : () => {\n throw new Error('Missing Router');\n };\n const prefetchRoute = router\n ? router.prefetchRoute\n : () => {\n throw new Error('Missing Router');\n };\n // TODO: Implement support for pending states in the future.\n const [, startTransition] = useTransition();\n // const elementRef = useRef<HTMLAnchorElement>();\n\n // useEffect(() => {\n // if (unstable_prefetchOnView && process.env.EXPO_OS === 'web' && ref.current) {\n // const observer = new IntersectionObserver(\n // (entries) => {\n // entries.forEach((entry) => {\n // if (entry.isIntersecting) {\n // const url = new URL(resolvedHref, getHref());\n // if (router && url.href !== getHref()) {\n // const route = parseRoute(url);\n // router.prefetchRoute(route);\n // }\n // }\n // });\n // },\n // { threshold: 0.1 }\n // );\n\n // observer.observe(ref.current);\n\n // return () => {\n // observer.disconnect();\n // };\n // }\n // return () => {};\n // }, [unstable_prefetchOnView, router, resolvedHref]);\n\n const onClick = (event: MouseEvent<HTMLAnchorElement>) => {\n event.preventDefault();\n const url = new URL(resolvedHref, getHref());\n // TODO: Use in-memory route for native platforms.\n // if (url.href !== getHref()) {\n const route = parseRoute(url);\n prefetchRoute(route);\n startTransition(() => {\n getHistory().pushState(\n {\n ...getHistory().state,\n expo_new_path: url.pathname !== window.location.pathname,\n },\n '',\n url\n );\n changeRoute(route);\n });\n // }\n props.onClick?.(event);\n };\n // const onMouseEnter = unstable_prefetchOnEnter\n // ? (event: MouseEvent<HTMLAnchorElement>) => {\n // const url = new URL(to, getHref());\n // if (url.href !== getHref()) {\n // const route = parseRoute(url);\n // prefetchRoute(route);\n // }\n // props.onMouseEnter?.(event);\n // }\n // : props.onMouseEnter;\n\n const Element = asChild ? ReactSlot : Text;\n\n const ele = createElement(\n // @ts-expect-error\n Element,\n {\n ...hrefAttrs,\n ...props,\n style,\n href: resolvedHref,\n onPress: onClick,\n // onMouseEnter,\n ref,\n },\n children\n );\n // if (isPending && pending !== undefined) {\n // return createElement(Fragment, null, ele, pending);\n // }\n // if (!isPending && notPending !== undefined) {\n // return createElement(Fragment, null, ele, notPending);\n // }\n return ele;\n}\n"]}
|
|
@@ -16,17 +16,6 @@ type Result = ReturnType<typeof render> & {
|
|
|
16
16
|
getSearchParams(): Record<string, string | string[]>;
|
|
17
17
|
getRouterState(): ReactNavigationState | undefined;
|
|
18
18
|
};
|
|
19
|
-
declare global {
|
|
20
|
-
namespace jest {
|
|
21
|
-
interface Matchers<R> {
|
|
22
|
-
toHavePathname(pathname: string): R;
|
|
23
|
-
toHavePathnameWithParams(pathname: string): R;
|
|
24
|
-
toHaveSegments(segments: string[]): R;
|
|
25
|
-
toHaveSearchParams(params: Record<string, string | string[]>): R;
|
|
26
|
-
getRouterState(): ReactNavigationState | undefined;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
19
|
export { MockContextConfig, getMockConfig, getMockContext };
|
|
31
20
|
export declare function renderRouter(context?: MockContextConfig, { initialUrl, linking, ...options }?: RenderRouterOptions): Result;
|
|
32
21
|
export declare const testRouter: {
|