expo-router 5.0.2-preview.6 → 5.0.3
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/ExpoRoot.d.ts.map +1 -1
- package/build/ExpoRoot.js +19 -18
- package/build/ExpoRoot.js.map +1 -1
- package/build/constants.d.ts +2 -0
- package/build/constants.d.ts.map +1 -0
- package/build/constants.js +5 -0
- package/build/constants.js.map +1 -0
- package/build/{link/useDomComponentNavigation.d.ts → domComponents/emitDomEvent.d.ts} +2 -4
- package/build/domComponents/emitDomEvent.d.ts.map +1 -0
- package/build/domComponents/emitDomEvent.js +32 -0
- package/build/domComponents/emitDomEvent.js.map +1 -0
- package/build/domComponents/events.d.ts +6 -0
- package/build/domComponents/events.d.ts.map +1 -0
- package/build/domComponents/events.js +9 -0
- package/build/domComponents/events.js.map +1 -0
- package/build/domComponents/useDomComponentNavigation.d.ts +2 -0
- package/build/domComponents/useDomComponentNavigation.d.ts.map +1 -0
- package/build/domComponents/useDomComponentNavigation.js +37 -0
- package/build/domComponents/useDomComponentNavigation.js.map +1 -0
- package/build/fork/getStateFromPath.d.ts +1 -2
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +11 -5
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/getLinkingConfig.d.ts +6 -7
- package/build/getLinkingConfig.d.ts.map +1 -1
- package/build/getLinkingConfig.js +10 -9
- package/build/getLinkingConfig.js.map +1 -1
- package/build/getRoutesRedirects.d.ts +2 -0
- package/build/getRoutesRedirects.d.ts.map +1 -1
- package/build/getRoutesRedirects.js +56 -0
- package/build/getRoutesRedirects.js.map +1 -1
- package/build/global-state/routeInfo.d.ts +29 -4
- package/build/global-state/routeInfo.d.ts.map +1 -1
- package/build/global-state/routeInfo.js +124 -55
- package/build/global-state/routeInfo.js.map +1 -1
- package/build/global-state/router-store.d.ts +35 -83
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +138 -238
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +13 -14
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +32 -30
- package/build/global-state/routing.js.map +1 -1
- package/build/global-state/storeContext.d.ts +29 -0
- package/build/global-state/storeContext.d.ts.map +1 -0
- package/build/global-state/storeContext.js +9 -0
- package/build/global-state/storeContext.js.map +1 -0
- package/build/hooks.d.ts +13 -4
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +13 -23
- package/build/hooks.js.map +1 -1
- package/build/imperative-api.d.ts.map +1 -1
- package/build/imperative-api.js +13 -13
- package/build/imperative-api.js.map +1 -1
- package/build/layouts/DrawerClient.d.ts +3 -2
- package/build/layouts/DrawerClient.d.ts.map +1 -1
- package/build/layouts/StackClient.d.ts +5 -2
- package/build/layouts/StackClient.d.ts.map +1 -1
- package/build/layouts/StackClient.js +2 -0
- package/build/layouts/StackClient.js.map +1 -1
- package/build/layouts/TabsClient.d.ts +3 -2
- package/build/layouts/TabsClient.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.d.ts +6 -1
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js +28 -20
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/linking.d.ts +2 -2
- package/build/link/linking.d.ts.map +1 -1
- package/build/link/linking.js +5 -4
- package/build/link/linking.js.map +1 -1
- package/build/link/useLinkToPathProps.d.ts.map +1 -1
- package/build/link/useLinkToPathProps.js +4 -5
- package/build/link/useLinkToPathProps.js.map +1 -1
- package/build/link/useLoadedNavigation.d.ts.map +1 -1
- package/build/link/useLoadedNavigation.js +2 -3
- package/build/link/useLoadedNavigation.js.map +1 -1
- package/build/primitives.d.ts.map +1 -1
- package/build/primitives.js +1 -0
- package/build/primitives.js.map +1 -1
- package/build/testing-library/index.d.ts +3 -3
- package/build/testing-library/index.d.ts.map +1 -1
- package/build/testing-library/index.js +5 -10
- package/build/testing-library/index.js.map +1 -1
- package/build/ui/common.d.ts.map +1 -1
- package/build/ui/common.js +4 -3
- package/build/ui/common.js.map +1 -1
- package/build/useNavigation.d.ts.map +1 -1
- package/build/useNavigation.js +47 -56
- package/build/useNavigation.js.map +1 -1
- package/build/useScreens.d.ts +2 -2
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +18 -3
- package/build/useScreens.js.map +1 -1
- package/build/views/ErrorBoundary.d.ts.map +1 -1
- package/build/views/ErrorBoundary.js +2 -68
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Navigator.d.ts.map +1 -1
- package/build/views/Navigator.js +4 -4
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Protected.d.ts +8 -0
- package/build/views/Protected.d.ts.map +1 -0
- package/build/views/Protected.js +11 -0
- package/build/views/Protected.js.map +1 -0
- package/build/views/Screen.d.ts +4 -0
- package/build/views/Screen.d.ts.map +1 -1
- package/build/views/Screen.js +52 -4
- package/build/views/Screen.js.map +1 -1
- package/build/views/Sitemap.js +5 -2
- package/build/views/Sitemap.js.map +1 -1
- package/package.json +3 -3
- package/build/link/useDomComponentNavigation.d.ts.map +0 -1
- package/build/link/useDomComponentNavigation.js +0 -68
- package/build/link/useDomComponentNavigation.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ParamListBase, StackRouter as RNStackRouter, StackNavigationState } from '@react-navigation/native';
|
|
2
2
|
import { NativeStackNavigationEventMap, NativeStackNavigationOptions } from '@react-navigation/native-stack';
|
|
3
3
|
import { ComponentProps } from 'react';
|
|
4
|
-
|
|
4
|
+
import { Protected } from '../views/Protected';
|
|
5
|
+
declare const RNStack: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/native-stack").NativeStackNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
5
6
|
children: React.ReactNode;
|
|
6
7
|
layout?: ((props: {
|
|
7
8
|
state: StackNavigationState<ParamListBase>;
|
|
@@ -50,7 +51,7 @@ declare const RNStack: import("react").ForwardRefExoticComponent<Omit<Omit<impor
|
|
|
50
51
|
}>>(original: import("@react-navigation/native").Router<StackNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<StackNavigationState<ParamListBase>, Action>>) | undefined;
|
|
51
52
|
} & {
|
|
52
53
|
id?: undefined;
|
|
53
|
-
}, "children"> & Partial<Pick<Omit<import("@react-navigation/native-stack").NativeStackNavigatorProps, "
|
|
54
|
+
}, "children"> & Partial<Pick<Omit<import("@react-navigation/native-stack").NativeStackNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
54
55
|
children: React.ReactNode;
|
|
55
56
|
layout?: ((props: {
|
|
56
57
|
state: StackNavigationState<ParamListBase>;
|
|
@@ -101,6 +102,7 @@ declare const RNStack: import("react").ForwardRefExoticComponent<Omit<Omit<impor
|
|
|
101
102
|
id?: undefined;
|
|
102
103
|
}, "children">> & import("react").RefAttributes<unknown>> & {
|
|
103
104
|
Screen: (props: import("../useScreens").ScreenProps<NativeStackNavigationOptions, StackNavigationState<ParamListBase>, NativeStackNavigationEventMap>) => null;
|
|
105
|
+
Protected: typeof Protected;
|
|
104
106
|
};
|
|
105
107
|
/**
|
|
106
108
|
* React Navigation matches a screen by its name or a 'getID' function that uniquely identifies a screen.
|
|
@@ -116,6 +118,7 @@ declare const Stack: ((props: ComponentProps<typeof RNStack>) => import("react")
|
|
|
116
118
|
Screen: (props: ComponentProps<typeof RNStack.Screen> & {
|
|
117
119
|
singular?: boolean;
|
|
118
120
|
}) => null;
|
|
121
|
+
Protected: import("react").FunctionComponent<import("../views/Protected").ProtectedProps>;
|
|
119
122
|
};
|
|
120
123
|
export default Stack;
|
|
121
124
|
export declare const StackRouter: typeof RNStackRouter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackClient.d.ts","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,aAAa,EAKb,WAAW,IAAI,aAAa,EAE5B,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAE7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"StackClient.d.ts","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,aAAa,EAKb,WAAW,IAAI,aAAa,EAE5B,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAE7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAM/C,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKU,CAAC;AAcxB;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,cAAc,CAAC,OAAO,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAyG9F,CAAC;AAoEF,QAAA,MAAM,KAAK,WACD,cAAc,CAAC,OAAO,OAAO,CAAC;YAIV,CACxB,KAAK,EAAE,cAAc,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAClE,IAAI;;CAGZ,CAAC;AAEF,eAAe,KAAK,CAAC;AAErB,eAAO,MAAM,WAAW,EAAE,OAAO,aAMhC,CAAC"}
|
|
@@ -6,6 +6,7 @@ const native_1 = require("@react-navigation/native");
|
|
|
6
6
|
const native_stack_1 = require("@react-navigation/native-stack");
|
|
7
7
|
const withLayoutContext_1 = require("./withLayoutContext");
|
|
8
8
|
const useScreens_1 = require("../useScreens");
|
|
9
|
+
const Protected_1 = require("../views/Protected");
|
|
9
10
|
const NativeStackNavigator = (0, native_stack_1.createNativeStackNavigator)().Navigator;
|
|
10
11
|
const RNStack = (0, withLayoutContext_1.withLayoutContext)(NativeStackNavigator);
|
|
11
12
|
function isStackAction(action) {
|
|
@@ -168,6 +169,7 @@ const Stack = Object.assign((props) => {
|
|
|
168
169
|
return <RNStack {...props} UNSTABLE_router={exports.stackRouterOverride}/>;
|
|
169
170
|
}, {
|
|
170
171
|
Screen: RNStack.Screen,
|
|
172
|
+
Protected: Protected_1.Protected,
|
|
171
173
|
});
|
|
172
174
|
exports.default = Stack;
|
|
173
175
|
const StackRouter = (options) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackClient.js","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AACb,qDAWkC;AAClC,iEAIwC;AAGxC,2DAAwD;AACxD,8CAA+D;AAI/D,MAAM,oBAAoB,GAAG,IAAA,yCAA0B,GAAE,CAAC,SAAS,CAAC;AAEpE,MAAM,OAAO,GAAG,IAAA,qCAAiB,EAK/B,oBAAoB,CAAC,CAAC;AAExB,SAAS,aAAa,CACpB,MAAwB;IAExB,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,MAAM;QACtB,MAAM,CAAC,IAAI,KAAK,UAAU;QAC1B,MAAM,CAAC,IAAI,KAAK,KAAK;QACrB,MAAM,CAAC,IAAI,KAAK,YAAY;QAC5B,MAAM,CAAC,IAAI,KAAK,SAAS,CAC1B,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACI,MAAM,mBAAmB,GAAmE,CACjG,QAAQ,EACR,EAAE;IACF,OAAO;QACL,iBAAiB,EAAE,CAAC,KAAK,EAA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KAAK,KAAK,CAAC,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,KAAK;QACR,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC;QACxB,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,CAAC,KAAqC,EAAE,EAAE;IACxC,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,2BAAmB,CAAC,EAAG,CAAC;AACtE,CAAC,EACD;IACE,MAAM,EAAE,OAAO,CAAC,MAEP;CACV,CACF,CAAC;AAEF,kBAAe,KAAK,CAAC;AAEd,MAAM,WAAW,GAAyB,CAAC,OAAO,EAAE,EAAE;IAC3D,MAAM,MAAM,GAAG,IAAA,oBAAa,EAAC,OAAO,CAAC,CAAC;IACtC,OAAO;QACL,GAAG,MAAM;QACT,GAAG,IAAA,2BAAmB,EAAC,MAAM,CAAC;KAC/B,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB","sourcesContent":["'use client';\nimport {\n CommonNavigationAction,\n NavigationAction,\n ParamListBase,\n PartialRoute,\n PartialState,\n Route,\n RouterConfigOptions,\n StackRouter as RNStackRouter,\n StackActionType,\n StackNavigationState,\n} from '@react-navigation/native';\nimport {\n NativeStackNavigationEventMap,\n NativeStackNavigationOptions,\n createNativeStackNavigator,\n} from '@react-navigation/native-stack';\nimport { ComponentProps } from 'react';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { SingularOptions, getSingularId } from '../useScreens';\n\ntype GetId = NonNullable<RouterConfigOptions['routeGetIdList'][string]>;\n\nconst NativeStackNavigator = createNativeStackNavigator().Navigator;\n\nconst RNStack = withLayoutContext<\n NativeStackNavigationOptions,\n typeof NativeStackNavigator,\n StackNavigationState<ParamListBase>,\n NativeStackNavigationEventMap\n>(NativeStackNavigator);\n\nfunction isStackAction(\n action: NavigationAction\n): action is StackActionType | Extract<CommonNavigationAction, { type: 'NAVIGATE' }> {\n return (\n action.type === 'PUSH' ||\n action.type === 'NAVIGATE' ||\n action.type === 'POP' ||\n action.type === 'POP_TO_TOP' ||\n action.type === 'REPLACE'\n );\n}\n\n/**\n * React Navigation matches a screen by its name or a 'getID' function that uniquely identifies a screen.\n * When a screen has been uniquely identified, the Stack can only have one instance of that screen.\n *\n * Expo Router allows for a screen to be matched by name and path params, a 'getID' function or a singular id.\n *\n * Instead of reimplementing the entire StackRouter, we can override the getStateForAction method to handle the singular screen logic.\n *\n */\nexport const stackRouterOverride: NonNullable<ComponentProps<typeof RNStack>['UNSTABLE_router']> = (\n original\n) => {\n return {\n getStateForAction: (state, action, options) => {\n if (action.target && action.target !== state.key) {\n return null;\n }\n\n if (!isStackAction(action)) {\n return original.getStateForAction(state, action, options);\n }\n\n // The dynamic getId added to an action, `router.push('screen', { singular: true })`\n const actionSingularOptions =\n action.payload && 'singular' in action.payload\n ? (action.payload.singular as SingularOptions)\n : undefined;\n\n // Handle if 'getID' or 'singular' is set.\n function getIdFunction(fn?: GetId): GetId | undefined {\n // Actions can be fired by the user, so we do need to validate their structure.\n if (\n !('payload' in action) ||\n !action.payload ||\n !('name' in action.payload) ||\n typeof action.payload.name !== 'string'\n ) {\n return;\n }\n\n const name = action.payload.name;\n\n return (\n // The dynamic singular added to an action, `router.push('screen', { singular: () => 'id' })`\n getActionSingularIdFn(actionSingularOptions, name) ||\n // The static getId added as a prop to `<Screen singular />` or `<Screen getId={} />`\n options.routeGetIdList[name] ||\n // The custom singular added by Expo Router to support its concept of `navigate`\n fn\n );\n }\n\n switch (action.type) {\n case 'PUSH': {\n /**\n * PUSH should always push\n *\n * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,\n * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.\n */\n const nextState = original.getStateForAction(state, action, {\n ...options,\n routeGetIdList: {\n ...options.routeGetIdList,\n [action.payload.name]: getIdFunction(),\n },\n });\n\n /**\n * React Navigation doesn't support dynamic getId function on the action. Because of this,\n * can you enter a state where the screen is pushed multiple times but the normal getStateForAction\n * doesn't remove the duplicates. We need to filter the state to only have singular screens.\n */\n return actionSingularOptions\n ? filterSingular(nextState, actionSingularOptions)\n : nextState;\n }\n case 'NAVIGATE': {\n /**\n * NAVIGATE should push unless the current name & route params of the current and target screen match.\n * Search params and hashes should be ignored.\n *\n * If the name, route params & search params match, no action is taken.\n * If both the name and route params match, the screen is replaced.\n * If the name / route params do not match, the screen is pushed.\n *\n * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,\n * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.\n */\n const nextState = original.getStateForAction(state, action, {\n ...options,\n routeGetIdList: {\n ...options.routeGetIdList,\n [action.payload.name]: getIdFunction((options) => {\n return getSingularId(action.payload.name, options);\n }),\n },\n });\n\n /**\n * React Navigation doesn't support dynamic getId function on the action. Because of this,\n * can you enter a state where the screen is pushed multiple times but the normal getStateForAction\n * doesn't remove the duplicates. We need to filter the state to only have singular screens.\n */\n return actionSingularOptions\n ? filterSingular(nextState, actionSingularOptions)\n : nextState;\n }\n default: {\n return original.getStateForAction(state, action, options);\n }\n }\n },\n };\n};\n\nfunction getActionSingularIdFn(\n actionGetId: SingularOptions | undefined,\n name: string\n): GetId | undefined {\n if (typeof actionGetId === 'function') {\n return (options) => actionGetId(name, options.params ?? {});\n } else if (actionGetId === true) {\n return (options) => getSingularId(name, options);\n }\n\n return undefined;\n}\n\n/**\n * If there is a dynamic singular on an action, then we need to filter the state to only have singular screens.\n * As multiples may have been added before we did the singular navigation.\n */\nfunction filterSingular<\n T extends\n | StackNavigationState<ParamListBase>\n | PartialState<StackNavigationState<ParamListBase>>\n | null,\n>(state: T, singular: SingularOptions): T {\n if (!state || !singular) {\n return state;\n }\n\n if (!state.routes) {\n return state;\n }\n\n const currentIndex = state.index || state.routes.length - 1;\n const current = state.routes[currentIndex];\n const name = current.name;\n\n const getId = getActionSingularIdFn(singular, name);\n\n if (!getId) {\n return state;\n }\n\n const id = getId({ params: current.params });\n\n if (!id) {\n return state;\n }\n\n // TypeScript needs a type assertion here for the filter to work.\n let routes = state.routes as PartialRoute<Route<string, object | undefined>>[];\n routes = routes.filter((route, index) => {\n // If the route is the current route, keep it.\n if (index === currentIndex) {\n return true;\n }\n\n // Remove all other routes with the same name and id.\n return name !== route.name || id !== getId({ params: route.params });\n });\n\n return {\n ...state,\n index: routes.length - 1,\n routes,\n };\n}\n\nconst Stack = Object.assign(\n (props: ComponentProps<typeof RNStack>) => {\n return <RNStack {...props} UNSTABLE_router={stackRouterOverride} />;\n },\n {\n Screen: RNStack.Screen as (\n props: ComponentProps<typeof RNStack.Screen> & { singular?: boolean }\n ) => null,\n }\n);\n\nexport default Stack;\n\nexport const StackRouter: typeof RNStackRouter = (options) => {\n const router = RNStackRouter(options);\n return {\n ...router,\n ...stackRouterOverride(router),\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"StackClient.js","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AACb,qDAWkC;AAClC,iEAIwC;AAGxC,2DAAwD;AACxD,8CAA+D;AAC/D,kDAA+C;AAI/C,MAAM,oBAAoB,GAAG,IAAA,yCAA0B,GAAE,CAAC,SAAS,CAAC;AAEpE,MAAM,OAAO,GAAG,IAAA,qCAAiB,EAK/B,oBAAoB,CAAC,CAAC;AAExB,SAAS,aAAa,CACpB,MAAwB;IAExB,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,MAAM;QACtB,MAAM,CAAC,IAAI,KAAK,UAAU;QAC1B,MAAM,CAAC,IAAI,KAAK,KAAK;QACrB,MAAM,CAAC,IAAI,KAAK,YAAY;QAC5B,MAAM,CAAC,IAAI,KAAK,SAAS,CAC1B,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;A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AK,KAAK,YAAY,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,qDAAqD;QACrD,OAAO,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,KAAK;QACR,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC;QACxB,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,CAAC,KAAqC,EAAE,EAAE;IACxC,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,2BAAmB,CAAC,EAAG,CAAC;AACtE,CAAC,EACD;IACE,MAAM,EAAE,OAAO,CAAC,MAEP;IACT,SAAS,EAAT,qBAAS;CACV,CACF,CAAC;AAEF,kBAAe,KAAK,CAAC;AAEd,MAAM,WAAW,GAAyB,CAAC,OAAO,EAAE,EAAE;IAC3D,MAAM,MAAM,GAAG,IAAA,oBAAa,EAAC,OAAO,CAAC,CAAC;IACtC,OAAO;QACL,GAAG,MAAM;QACT,GAAG,IAAA,2BAAmB,EAAC,MAAM,CAAC;KAC/B,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB","sourcesContent":["'use client';\nimport {\n CommonNavigationAction,\n NavigationAction,\n ParamListBase,\n PartialRoute,\n PartialState,\n Route,\n RouterConfigOptions,\n StackRouter as RNStackRouter,\n StackActionType,\n StackNavigationState,\n} from '@react-navigation/native';\nimport {\n NativeStackNavigationEventMap,\n NativeStackNavigationOptions,\n createNativeStackNavigator,\n} from '@react-navigation/native-stack';\nimport { ComponentProps } from 'react';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { SingularOptions, getSingularId } from '../useScreens';\nimport { Protected } from '../views/Protected';\n\ntype GetId = NonNullable<RouterConfigOptions['routeGetIdList'][string]>;\n\nconst NativeStackNavigator = createNativeStackNavigator().Navigator;\n\nconst RNStack = withLayoutContext<\n NativeStackNavigationOptions,\n typeof NativeStackNavigator,\n StackNavigationState<ParamListBase>,\n NativeStackNavigationEventMap\n>(NativeStackNavigator);\n\nfunction isStackAction(\n action: NavigationAction\n): action is StackActionType | Extract<CommonNavigationAction, { type: 'NAVIGATE' }> {\n return (\n action.type === 'PUSH' ||\n action.type === 'NAVIGATE' ||\n action.type === 'POP' ||\n action.type === 'POP_TO_TOP' ||\n action.type === 'REPLACE'\n );\n}\n\n/**\n * React Navigation matches a screen by its name or a 'getID' function that uniquely identifies a screen.\n * When a screen has been uniquely identified, the Stack can only have one instance of that screen.\n *\n * Expo Router allows for a screen to be matched by name and path params, a 'getID' function or a singular id.\n *\n * Instead of reimplementing the entire StackRouter, we can override the getStateForAction method to handle the singular screen logic.\n *\n */\nexport const stackRouterOverride: NonNullable<ComponentProps<typeof RNStack>['UNSTABLE_router']> = (\n original\n) => {\n return {\n getStateForAction: (state, action, options) => {\n if (action.target && action.target !== state.key) {\n return null;\n }\n\n if (!isStackAction(action)) {\n return original.getStateForAction(state, action, options);\n }\n\n // The dynamic getId added to an action, `router.push('screen', { singular: true })`\n const actionSingularOptions =\n action.payload && 'singular' in action.payload\n ? (action.payload.singular as SingularOptions)\n : undefined;\n\n // Handle if 'getID' or 'singular' is set.\n function getIdFunction(fn?: GetId): GetId | undefined {\n // Actions can be fired by the user, so we do need to validate their structure.\n if (\n !('payload' in action) ||\n !action.payload ||\n !('name' in action.payload) ||\n typeof action.payload.name !== 'string'\n ) {\n return;\n }\n\n const name = action.payload.name;\n\n return (\n // The dynamic singular added to an action, `router.push('screen', { singular: () => 'id' })`\n getActionSingularIdFn(actionSingularOptions, name) ||\n // The static getId added as a prop to `<Screen singular />` or `<Screen getId={} />`\n options.routeGetIdList[name] ||\n // The custom singular added by Expo Router to support its concept of `navigate`\n fn\n );\n }\n\n switch (action.type) {\n case 'PUSH': {\n /**\n * PUSH should always push\n *\n * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,\n * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.\n */\n const nextState = original.getStateForAction(state, action, {\n ...options,\n routeGetIdList: {\n ...options.routeGetIdList,\n [action.payload.name]: getIdFunction(),\n },\n });\n\n /**\n * React Navigation doesn't support dynamic getId function on the action. Because of this,\n * can you enter a state where the screen is pushed multiple times but the normal getStateForAction\n * doesn't remove the duplicates. We need to filter the state to only have singular screens.\n */\n return actionSingularOptions\n ? filterSingular(nextState, actionSingularOptions)\n : nextState;\n }\n case 'NAVIGATE': {\n /**\n * NAVIGATE should push unless the current name & route params of the current and target screen match.\n * Search params and hashes should be ignored.\n *\n * If the name, route params & search params match, no action is taken.\n * If both the name and route params match, the screen is replaced.\n * If the name / route params do not match, the screen is pushed.\n *\n * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,\n * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.\n */\n const nextState = original.getStateForAction(state, action, {\n ...options,\n routeGetIdList: {\n ...options.routeGetIdList,\n [action.payload.name]: getIdFunction((options) => {\n return getSingularId(action.payload.name, options);\n }),\n },\n });\n\n /**\n * React Navigation doesn't support dynamic getId function on the action. Because of this,\n * can you enter a state where the screen is pushed multiple times but the normal getStateForAction\n * doesn't remove the duplicates. We need to filter the state to only have singular screens.\n */\n return actionSingularOptions\n ? filterSingular(nextState, actionSingularOptions)\n : nextState;\n }\n default: {\n return original.getStateForAction(state, action, options);\n }\n }\n },\n };\n};\n\nfunction getActionSingularIdFn(\n actionGetId: SingularOptions | undefined,\n name: string\n): GetId | undefined {\n if (typeof actionGetId === 'function') {\n return (options) => actionGetId(name, options.params ?? {});\n } else if (actionGetId === true) {\n return (options) => getSingularId(name, options);\n }\n\n return undefined;\n}\n\n/**\n * If there is a dynamic singular on an action, then we need to filter the state to only have singular screens.\n * As multiples may have been added before we did the singular navigation.\n */\nfunction filterSingular<\n T extends\n | StackNavigationState<ParamListBase>\n | PartialState<StackNavigationState<ParamListBase>>\n | null,\n>(state: T, singular: SingularOptions): T {\n if (!state || !singular) {\n return state;\n }\n\n if (!state.routes) {\n return state;\n }\n\n const currentIndex = state.index || state.routes.length - 1;\n const current = state.routes[currentIndex];\n const name = current.name;\n\n const getId = getActionSingularIdFn(singular, name);\n\n if (!getId) {\n return state;\n }\n\n const id = getId({ params: current.params });\n\n if (!id) {\n return state;\n }\n\n // TypeScript needs a type assertion here for the filter to work.\n let routes = state.routes as PartialRoute<Route<string, object | undefined>>[];\n routes = routes.filter((route, index) => {\n // If the route is the current route, keep it.\n if (index === currentIndex) {\n return true;\n }\n\n // Remove all other routes with the same name and id.\n return name !== route.name || id !== getId({ params: route.params });\n });\n\n return {\n ...state,\n index: routes.length - 1,\n routes,\n };\n}\n\nconst Stack = Object.assign(\n (props: ComponentProps<typeof RNStack>) => {\n return <RNStack {...props} UNSTABLE_router={stackRouterOverride} />;\n },\n {\n Screen: RNStack.Screen as (\n props: ComponentProps<typeof RNStack.Screen> & { singular?: boolean }\n ) => null,\n Protected,\n }\n);\n\nexport default Stack;\n\nexport const StackRouter: typeof RNStackRouter = (options) => {\n const router = RNStackRouter(options);\n return {\n ...router,\n ...stackRouterOverride(router),\n };\n};\n"]}
|
|
@@ -5,7 +5,7 @@ import { Href } from '../types';
|
|
|
5
5
|
type TabsProps = BottomTabNavigationOptions & {
|
|
6
6
|
href?: Href | null;
|
|
7
7
|
};
|
|
8
|
-
export declare const Tabs: React.ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/bottom-tabs").BottomTabNavigatorProps, "
|
|
8
|
+
export declare const Tabs: 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
9
|
children: React.ReactNode;
|
|
10
10
|
layout?: ((props: {
|
|
11
11
|
state: TabNavigationState<ParamListBase>;
|
|
@@ -54,7 +54,7 @@ export declare const Tabs: React.ForwardRefExoticComponent<Omit<Omit<import("@re
|
|
|
54
54
|
}>>(original: import("@react-navigation/native").Router<TabNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<TabNavigationState<ParamListBase>, Action>>) | undefined;
|
|
55
55
|
} & {
|
|
56
56
|
id?: undefined;
|
|
57
|
-
}, "children"> & Partial<Pick<Omit<import("@react-navigation/bottom-tabs").BottomTabNavigatorProps, "
|
|
57
|
+
}, "children"> & Partial<Pick<Omit<import("@react-navigation/bottom-tabs").BottomTabNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
58
58
|
children: React.ReactNode;
|
|
59
59
|
layout?: ((props: {
|
|
60
60
|
state: TabNavigationState<ParamListBase>;
|
|
@@ -105,6 +105,7 @@ export declare const Tabs: React.ForwardRefExoticComponent<Omit<Omit<import("@re
|
|
|
105
105
|
id?: undefined;
|
|
106
106
|
}, "children">> & React.RefAttributes<unknown>> & {
|
|
107
107
|
Screen: (props: import("..").ScreenProps<TabsProps, TabNavigationState<ParamListBase>, BottomTabNavigationEventMap>) => null;
|
|
108
|
+
Protected: typeof import("../views/Protected").Protected;
|
|
108
109
|
};
|
|
109
110
|
export default Tabs;
|
|
110
111
|
//# 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;AAK1B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKhC,KAAK,SAAS,GAAG,0BAA0B,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,eAAO,MAAM,IAAI
|
|
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;AAK1B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKhC,KAAK,SAAS,GAAG,0BAA0B,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Cf,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -2,13 +2,17 @@ import { EventMapBase, NavigationState } from '@react-navigation/native';
|
|
|
2
2
|
import { ComponentProps, ComponentType, ForwardRefExoticComponent, PropsWithoutRef, ReactNode, RefAttributes } from 'react';
|
|
3
3
|
import { PickPartial } from '../types';
|
|
4
4
|
import { ScreenProps } from '../useScreens';
|
|
5
|
+
import { Protected } from '../views/Protected';
|
|
5
6
|
export declare function useFilterScreenChildren(children: ReactNode, { isCustomNavigator, contextKey, }?: {
|
|
6
7
|
isCustomNavigator?: boolean;
|
|
7
8
|
/** Used for sending developer hints */
|
|
8
9
|
contextKey?: string;
|
|
9
10
|
}): {
|
|
10
|
-
screens: ScreenProps
|
|
11
|
+
screens: (ScreenProps & {
|
|
12
|
+
name: string;
|
|
13
|
+
})[];
|
|
11
14
|
children: any[];
|
|
15
|
+
protectedScreens: Set<string>;
|
|
12
16
|
};
|
|
13
17
|
/**
|
|
14
18
|
* Returns a navigator that automatically injects matched routes and renders nothing when there are no children.
|
|
@@ -42,5 +46,6 @@ export declare function useFilterScreenChildren(children: ReactNode, { isCustomN
|
|
|
42
46
|
*/
|
|
43
47
|
export declare function withLayoutContext<TOptions extends object, T extends ComponentType<any>, TState extends NavigationState, TEventMap extends EventMapBase>(Nav: T, processor?: (options: ScreenProps[]) => ScreenProps[]): ForwardRefExoticComponent<PropsWithoutRef<PickPartial<ComponentProps<T>, "children">> & RefAttributes<unknown>> & {
|
|
44
48
|
Screen: (props: ScreenProps<TOptions, TState, TEventMap>) => null;
|
|
49
|
+
Protected: typeof Protected;
|
|
45
50
|
};
|
|
46
51
|
//# sourceMappingURL=withLayoutContext.d.ts.map
|
|
@@ -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,
|
|
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,eAAe,CAAC;AAC9D,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGxE,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,SAAS,EACnB,EACE,iBAAiB,EACjB,UAAU,GACX,GAAE;IACD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB;;cAKkC,MAAM;;;;EAsD/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,SAAS,MAAM,EACvB,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EAC5B,MAAM,SAAS,eAAe,EAC9B,SAAS,SAAS,YAAY,EAC9B,GAAG,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,GAwBxD,yBAAyB,CAC5B,eAAe,CAAC,WAAW,CAAC,cAAc,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"}
|
|
@@ -38,35 +38,41 @@ exports.withLayoutContext = withLayoutContext;
|
|
|
38
38
|
const react_1 = __importStar(require("react"));
|
|
39
39
|
const Route_1 = require("../Route");
|
|
40
40
|
const useScreens_1 = require("../useScreens");
|
|
41
|
+
const Protected_1 = require("../views/Protected");
|
|
41
42
|
const Screen_1 = require("../views/Screen");
|
|
42
43
|
function useFilterScreenChildren(children, { isCustomNavigator, contextKey, } = {}) {
|
|
43
44
|
return (0, react_1.useMemo)(() => {
|
|
44
45
|
const customChildren = [];
|
|
45
|
-
const screens =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
throw new Error(`<Screen /> component in \`default export\` at \`app${contextKey}/_layout\` must have a \`name\` prop when used as a child of a Layout Route.`);
|
|
46
|
+
const screens = [];
|
|
47
|
+
const protectedScreens = new Set();
|
|
48
|
+
function flattenChild(child, exclude = false) {
|
|
49
|
+
if ((0, Screen_1.isScreen)(child, contextKey)) {
|
|
50
|
+
if (exclude) {
|
|
51
|
+
protectedScreens.add(child.props.name);
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
throw new Error(`<Screen /> component in \`default export\` at \`app${contextKey}/_layout\` must not have a \`children\`, \`component\`, or \`getComponent\` prop when used as a child of a Layout Route`);
|
|
56
|
-
}
|
|
53
|
+
else {
|
|
54
|
+
screens.push(child.props);
|
|
57
55
|
}
|
|
58
|
-
return
|
|
56
|
+
return;
|
|
59
57
|
}
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
58
|
+
if ((0, Protected_1.isProtectedReactElement)(child)) {
|
|
59
|
+
if (child.props.guard) {
|
|
60
|
+
react_1.Children.forEach(child.props.children, (protectedChild) => flattenChild(protectedChild));
|
|
63
61
|
}
|
|
64
62
|
else {
|
|
65
|
-
|
|
63
|
+
react_1.Children.forEach(child.props.children, (protectedChild) => {
|
|
64
|
+
flattenChild(protectedChild, true);
|
|
65
|
+
});
|
|
66
66
|
}
|
|
67
|
-
return
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (isCustomNavigator) {
|
|
70
|
+
customChildren.push(child);
|
|
68
71
|
}
|
|
69
|
-
|
|
72
|
+
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
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
react_1.Children.forEach(children, (child) => flattenChild(child));
|
|
70
76
|
// Add an assertion for development
|
|
71
77
|
if (process.env.NODE_ENV !== 'production') {
|
|
72
78
|
// Assert if names are not unique
|
|
@@ -78,6 +84,7 @@ function useFilterScreenChildren(children, { isCustomNavigator, contextKey, } =
|
|
|
78
84
|
return {
|
|
79
85
|
screens,
|
|
80
86
|
children: customChildren,
|
|
87
|
+
protectedScreens,
|
|
81
88
|
};
|
|
82
89
|
}, [children]);
|
|
83
90
|
}
|
|
@@ -114,11 +121,11 @@ function useFilterScreenChildren(children, { isCustomNavigator, contextKey, } =
|
|
|
114
121
|
function withLayoutContext(Nav, processor) {
|
|
115
122
|
return Object.assign((0, react_1.forwardRef)(({ children: userDefinedChildren, ...props }, ref) => {
|
|
116
123
|
const contextKey = (0, Route_1.useContextKey)();
|
|
117
|
-
const { screens } = useFilterScreenChildren(userDefinedChildren, {
|
|
124
|
+
const { screens, protectedScreens } = useFilterScreenChildren(userDefinedChildren, {
|
|
118
125
|
contextKey,
|
|
119
126
|
});
|
|
120
127
|
const processed = processor ? processor(screens ?? []) : screens;
|
|
121
|
-
const sorted = (0, useScreens_1.useSortedScreens)(processed ?? []);
|
|
128
|
+
const sorted = (0, useScreens_1.useSortedScreens)(processed ?? [], protectedScreens);
|
|
122
129
|
// Prevent throwing an error when there are no screens.
|
|
123
130
|
if (!sorted.length) {
|
|
124
131
|
return null;
|
|
@@ -126,6 +133,7 @@ function withLayoutContext(Nav, processor) {
|
|
|
126
133
|
return <Nav {...props} id={contextKey} ref={ref} children={sorted}/>;
|
|
127
134
|
}), {
|
|
128
135
|
Screen: Screen_1.Screen,
|
|
136
|
+
Protected: Protected_1.Protected,
|
|
129
137
|
});
|
|
130
138
|
}
|
|
131
139
|
//# sourceMappingURL=withLayoutContext.js.map
|
|
@@ -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,0DAoEC;AAgCD,8CAm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GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAEjE,MAAM,MAAM,GAAG,IAAA,6BAAgB,EAAC,SAAS,IAAI,EAAE,EAAE,gBAAgB,CAAC,CAAC;QAEnE,uDAAuD;QACvD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,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 }\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"]}
|
package/build/link/linking.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LinkingOptions } from '@react-navigation/native';
|
|
2
2
|
import { getPathFromState } from '../fork/getPathFromState';
|
|
3
3
|
import { getStateFromPath } from '../fork/getStateFromPath';
|
|
4
|
-
import {
|
|
4
|
+
import { StoreRedirects } from '../global-state/router-store';
|
|
5
5
|
import { NativeIntent } from '../types';
|
|
6
6
|
export declare function getInitialURL(): ReturnType<NonNullable<LinkingOptions<Record<string, unknown>>['getInitialURL']>>;
|
|
7
7
|
export declare function getRootURL(): string;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function subscribe(nativeLinking: NativeIntent | undefined, redirects: StoreRedirects[] | undefined): (listener: (url: string) => void) => () => void;
|
|
9
9
|
export { getStateFromPath, getPathFromState };
|
|
10
10
|
//# sourceMappingURL=linking.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQ1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQ1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AASxC,wBAAgB,aAAa,IAAI,UAAU,CACzC,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CACtE,CA0BA;AAID,wBAAgB,UAAU,IAAI,MAAM,CAQnC;AAgBD,wBAAgB,SAAS,CACvB,aAAa,EAAE,YAAY,GAAG,SAAS,EACvC,SAAS,EAAE,cAAc,EAAE,GAAG,SAAS,IAE/B,UAAU,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,gBAuCxC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
|
package/build/link/linking.js
CHANGED
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.getPathFromState = exports.getStateFromPath = void 0;
|
|
37
37
|
exports.getInitialURL = getInitialURL;
|
|
38
38
|
exports.getRootURL = getRootURL;
|
|
39
|
-
exports.
|
|
39
|
+
exports.subscribe = subscribe;
|
|
40
40
|
const Linking = __importStar(require("expo-linking"));
|
|
41
41
|
const react_native_1 = require("react-native");
|
|
42
42
|
const extractPathFromURL_1 = require("../fork/extractPathFromURL");
|
|
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "getPathFromState", { enumerable: true, get: func
|
|
|
45
45
|
const getStateFromPath_1 = require("../fork/getStateFromPath");
|
|
46
46
|
Object.defineProperty(exports, "getStateFromPath", { enumerable: true, get: function () { return getStateFromPath_1.getStateFromPath; } });
|
|
47
47
|
const useLinking_1 = require("../fork/useLinking");
|
|
48
|
+
const getRoutesRedirects_1 = require("../getRoutesRedirects");
|
|
48
49
|
const isExpoGo = typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo;
|
|
49
50
|
// A custom getInitialURL is used on native to ensure the app always starts at
|
|
50
51
|
// the root path if it's launched from something other than a deep link.
|
|
@@ -95,7 +96,7 @@ function parseExpoGoUrlFromListener(url) {
|
|
|
95
96
|
}
|
|
96
97
|
return url;
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
+
function subscribe(nativeLinking, redirects) {
|
|
99
100
|
return (listener) => {
|
|
100
101
|
let callback;
|
|
101
102
|
const legacySubscription = nativeLinking?.legacy_subscribe?.(listener);
|
|
@@ -103,7 +104,7 @@ function addEventListener(nativeLinking, store) {
|
|
|
103
104
|
// This extra work is only done in the Expo Go app.
|
|
104
105
|
callback = async ({ url }) => {
|
|
105
106
|
let href = parseExpoGoUrlFromListener(url);
|
|
106
|
-
href =
|
|
107
|
+
href = (0, getRoutesRedirects_1.applyRedirects)(href, redirects);
|
|
107
108
|
if (href && nativeLinking?.redirectSystemPath) {
|
|
108
109
|
href = await nativeLinking.redirectSystemPath({ path: href, initial: false });
|
|
109
110
|
}
|
|
@@ -114,7 +115,7 @@ function addEventListener(nativeLinking, store) {
|
|
|
114
115
|
}
|
|
115
116
|
else {
|
|
116
117
|
callback = async ({ url }) => {
|
|
117
|
-
let href =
|
|
118
|
+
let href = (0, getRoutesRedirects_1.applyRedirects)(url, redirects);
|
|
118
119
|
if (href && nativeLinking?.redirectSystemPath) {
|
|
119
120
|
href = await nativeLinking.redirectSystemPath({ path: href, initial: false });
|
|
120
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linking.js","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"linking.js","sourceRoot":"","s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AAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;gBAChF,CAAC;gBAED,IAAI,IAAI,EAAE,CAAC;oBACT,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACjB,CAAC;YACH,CAAC,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,QAAQ,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;gBAC3B,IAAI,IAAI,GAAG,IAAA,mCAAc,EAAC,GAAG,EAAE,SAAS,CAAC,CAAC;gBAC1C,IAAI,IAAI,IAAI,aAAa,EAAE,kBAAkB,EAAE,CAAC;oBAC9C,IAAI,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;gBAChF,CAAC;gBAED,IAAI,IAAI,EAAE,CAAC;oBACT,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACjB,CAAC;YACH,CAAC,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAE/D,OAAO,GAAG,EAAE;YACV,2FAA2F;YAC3F,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;YACzB,kBAAkB,EAAE,EAAE,CAAC;QACzB,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { LinkingOptions } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport {\n parsePathAndParamsFromExpoGoLink,\n parsePathFromExpoGoLink,\n} from '../fork/extractPathFromURL';\nimport { getPathFromState } from '../fork/getPathFromState';\nimport { getStateFromPath } from '../fork/getStateFromPath';\nimport { getInitialURLWithTimeout } from '../fork/useLinking';\nimport { applyRedirects } from '../getRoutesRedirects';\nimport { StoreRedirects } from '../global-state/router-store';\nimport { NativeIntent } from '../types';\n\nconst isExpoGo = typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo;\n\n// A custom getInitialURL is used on native to ensure the app always starts at\n// the root path if it's launched from something other than a deep link.\n// This helps keep the native functionality working like the web functionality.\n// For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`\n// then `/index` would be used on web and `/settings` would be used on native.\nexport function getInitialURL(): ReturnType<\n NonNullable<LinkingOptions<Record<string, unknown>>['getInitialURL']>\n> {\n if (typeof window === 'undefined') {\n return '';\n }\n if (Platform.OS === 'web' && window.location?.href) {\n return window.location.href;\n }\n if (Platform.OS === 'ios') {\n // Use the new Expo API for iOS. This has better support for App Clips and handoff.\n const url = Linking.getLinkingURL();\n return (\n parseExpoGoUrlFromListener(url) ??\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n getRootURL()\n );\n }\n\n // TODO: Figure out if expo-linking on Android has full interop with the React Native implementation.\n return Promise.resolve(getInitialURLWithTimeout()).then(\n (url) =>\n parseExpoGoUrlFromListener(url) ??\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n getRootURL()\n );\n}\n\nlet _rootURL: string | undefined;\n\nexport function getRootURL(): string {\n if (_rootURL === undefined) {\n _rootURL = Linking.createURL('/');\n if (isExpoGo) {\n _rootURL = parsePathFromExpoGoLink(_rootURL);\n }\n }\n return _rootURL;\n}\n\n// Expo Go is weird and requires the root path to be `/--/`\nfunction parseExpoGoUrlFromListener<T extends string | null>(url: T): T {\n if (!url || !isExpoGo) {\n return url;\n }\n const { pathname, queryString } = parsePathAndParamsFromExpoGoLink(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (!pathname || pathname === '/') {\n return (getRootURL() + queryString) as T;\n }\n return url;\n}\n\nexport function subscribe(\n nativeLinking: NativeIntent | undefined,\n redirects: StoreRedirects[] | undefined\n) {\n return (listener: (url: string) => void) => {\n let callback: (({ url }: { url: string }) => void) | undefined;\n\n const legacySubscription = nativeLinking?.legacy_subscribe?.(listener);\n\n if (isExpoGo) {\n // This extra work is only done in the Expo Go app.\n callback = async ({ url }) => {\n let href: string | undefined | null = parseExpoGoUrlFromListener(url);\n href = applyRedirects(href, redirects);\n if (href && nativeLinking?.redirectSystemPath) {\n href = await nativeLinking.redirectSystemPath({ path: href, initial: false });\n }\n\n if (href) {\n listener(href);\n }\n };\n } else {\n callback = async ({ url }) => {\n let href = applyRedirects(url, redirects);\n if (href && nativeLinking?.redirectSystemPath) {\n href = await nativeLinking.redirectSystemPath({ path: href, initial: false });\n }\n\n if (href) {\n listener(href);\n }\n };\n }\n\n const subscription = Linking.addEventListener('url', callback);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n subscription?.remove?.();\n legacySubscription?.();\n };\n };\n}\n\nexport { getStateFromPath, getPathFromState };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinkToPathProps.d.ts","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"useLinkToPathProps.d.ts","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAI/D,OAAO,EAAU,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA4BhE,KAAK,yBAAyB,GAAG,aAAa,GAAG;IAC/C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,yBAAyB;;;sBAC/D,UAAU,CAAC,iBAAiB,CAAC,GAAG,qBAAqB;EAqB/E;AAED,wBAAgB,sBAAsB,CACpC,KAAK,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,qBAAqB,WAY9D"}
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = useLinkToPathProps;
|
|
4
4
|
exports.shouldHandleMouseEvent = shouldHandleMouseEvent;
|
|
5
5
|
const react_native_1 = require("react-native");
|
|
6
|
-
const
|
|
6
|
+
const emitDomEvent_1 = require("../domComponents/emitDomEvent");
|
|
7
7
|
const getPathFromState_forks_1 = require("../fork/getPathFromState-forks");
|
|
8
|
-
const
|
|
8
|
+
const routing_1 = require("../global-state/routing");
|
|
9
9
|
const matchers_1 = require("../matchers");
|
|
10
10
|
const url_1 = require("../utils/url");
|
|
11
11
|
function eventShouldPreventDefault(e) {
|
|
@@ -28,13 +28,12 @@ function eventShouldPreventDefault(e) {
|
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
30
|
function useLinkToPathProps({ href, ...options }) {
|
|
31
|
-
const { linkTo } = (0, router_store_1.useExpoRouter)();
|
|
32
31
|
const onPress = (event) => {
|
|
33
32
|
if (shouldHandleMouseEvent(event)) {
|
|
34
|
-
if ((0,
|
|
33
|
+
if ((0, emitDomEvent_1.emitDomLinkEvent)(href, options)) {
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
|
-
linkTo(href, options);
|
|
36
|
+
(0, routing_1.linkTo)(href, options);
|
|
38
37
|
}
|
|
39
38
|
};
|
|
40
39
|
let strippedHref = (0, matchers_1.stripGroupSegmentsFromPath)(href) || '/';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinkToPathProps.js","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"useLinkToPathProps.js","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":";;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AAa,EAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,MAAe;QACrB,OAAO;KACR,CAAC;AACJ,CAAC;AAED,SAAgB,sBAAsB,CACpC,KAA6D;IAE7D,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO,CAAC,KAAK,EAAE,gBAAgB,CAAC;IAClC,CAAC;IAED,IAAI,KAAK,IAAI,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { MouseEvent } from 'react';\nimport { GestureResponderEvent, Platform } from 'react-native';\n\nimport { emitDomLinkEvent } from '../domComponents/emitDomEvent';\nimport { appendBaseUrl } from '../fork/getPathFromState-forks';\nimport { linkTo, LinkToOptions } from '../global-state/routing';\nimport { stripGroupSegmentsFromPath } from '../matchers';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction eventShouldPreventDefault(\n e: MouseEvent<HTMLAnchorElement> | GestureResponderEvent\n): boolean {\n if (e?.defaultPrevented) {\n return false;\n }\n\n if (\n // Only check MouseEvents\n 'button' in e &&\n // ignore clicks with modifier keys\n !e.metaKey &&\n !e.altKey &&\n !e.ctrlKey &&\n !e.shiftKey &&\n (e.button == null || e.button === 0) && // Only accept left clicks\n [undefined, null, '', 'self'].includes(e.currentTarget.target) // let browser handle \"target=_blank\" etc.\n ) {\n return true;\n }\n\n return false;\n}\n\ntype UseLinkToPathPropsOptions = LinkToOptions & {\n href: string;\n};\n\nexport default function useLinkToPathProps({ href, ...options }: UseLinkToPathPropsOptions) {\n const onPress = (event?: MouseEvent<HTMLAnchorElement> | GestureResponderEvent) => {\n if (shouldHandleMouseEvent(event)) {\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n linkTo(href, options);\n }\n };\n\n let strippedHref = stripGroupSegmentsFromPath(href) || '/';\n\n // Append base url only if needed.\n if (!shouldLinkExternally(strippedHref)) {\n strippedHref = appendBaseUrl(strippedHref);\n }\n\n return {\n href: strippedHref,\n role: 'link' as const,\n onPress,\n };\n}\n\nexport function shouldHandleMouseEvent(\n event?: MouseEvent<HTMLAnchorElement> | GestureResponderEvent\n) {\n if (Platform.OS !== 'web') {\n return !event?.defaultPrevented;\n }\n\n if (event && eventShouldPreventDefault(event)) {\n event.preventDefault();\n return true;\n }\n\n return false;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoadedNavigation.d.ts","sourceRoot":"","sources":["../../src/link/useLoadedNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAiB,MAAM,0BAA0B,CAAC;AAK1F,KAAK,iBAAiB,GAAG,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,GAAG;IACvE,QAAQ,IAAI,eAAe,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useLoadedNavigation.d.ts","sourceRoot":"","sources":["../../src/link/useLoadedNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAiB,MAAM,0BAA0B,CAAC;AAK1F,KAAK,iBAAiB,GAAG,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,GAAG;IACvE,QAAQ,IAAI,eAAe,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,mBAAmB,SA6B1B,CAAC,UAAU,EAAE,iBAAiB,KAAK,IAAI,UAU/C;AAED,wBAAgB,qBAAqB,IAAI,iBAAiB,GAAG,IAAI,CAShE"}
|
|
@@ -7,7 +7,6 @@ const react_1 = require("react");
|
|
|
7
7
|
const router_store_1 = require("../global-state/router-store");
|
|
8
8
|
/** Returns a callback which is invoked when the navigation state has loaded. */
|
|
9
9
|
function useLoadedNavigation() {
|
|
10
|
-
const { navigationRef } = (0, router_store_1.useExpoRouter)();
|
|
11
10
|
const navigation = (0, native_1.useNavigation)();
|
|
12
11
|
const isMounted = (0, react_1.useRef)(true);
|
|
13
12
|
const pending = (0, react_1.useRef)([]);
|
|
@@ -27,13 +26,13 @@ function useLoadedNavigation() {
|
|
|
27
26
|
}
|
|
28
27
|
}, [navigation]);
|
|
29
28
|
(0, react_1.useEffect)(() => {
|
|
30
|
-
if (navigationRef.current) {
|
|
29
|
+
if (router_store_1.store.navigationRef.current) {
|
|
31
30
|
flush();
|
|
32
31
|
}
|
|
33
32
|
}, [flush]);
|
|
34
33
|
const push = (0, react_1.useCallback)((fn) => {
|
|
35
34
|
pending.current.push(fn);
|
|
36
|
-
if (navigationRef.current) {
|
|
35
|
+
if (router_store_1.store.navigationRef.current) {
|
|
37
36
|
flush();
|
|
38
37
|
}
|
|
39
38
|
}, [flush]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoadedNavigation.js","sourceRoot":"","sources":["../../src/link/useLoadedNavigation.ts"],"names":[],"mappings":";;AAUA,
|
|
1
|
+
{"version":3,"file":"useLoadedNavigation.js","sourceRoot":"","sources":["../../src/link/useLoadedNavigation.ts"],"names":[],"mappings":";;AAUA,kDAuCC;AAED,sDASC;AA5DD,qDAA0F;AAC1F,iCAAiE;AAEjE,+DAAqD;AAMrD,gFAAgF;AAChF,SAAgB,mBAAmB;IACjC,MAAM,UAAU,GAAG,IAAA,sBAAa,GAAE,CAAC;IACnC,MAAM,SAAS,GAAG,IAAA,cAAM,EAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,IAAA,cAAM,EAA8C,EAAE,CAAC,CAAC;IAExE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;QACzB,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;QAC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AC;AACpB,CAAC","sourcesContent":["import { NavigationProp, NavigationState, useNavigation } from '@react-navigation/native';\nimport { useCallback, useState, useEffect, useRef } from 'react';\n\nimport { store } from '../global-state/router-store';\n\ntype GenericNavigation = NavigationProp<ReactNavigation.RootParamList> & {\n getState(): NavigationState | undefined;\n};\n\n/** Returns a callback which is invoked when the navigation state has loaded. */\nexport function useLoadedNavigation() {\n const navigation = useNavigation();\n const isMounted = useRef(true);\n const pending = useRef<((navigation: GenericNavigation) => void)[]>([]);\n\n useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n const flush = useCallback(() => {\n if (isMounted.current) {\n const pendingCallbacks = pending.current;\n pending.current = [];\n pendingCallbacks.forEach((callback) => {\n callback(navigation as GenericNavigation);\n });\n }\n }, [navigation]);\n\n useEffect(() => {\n if (store.navigationRef.current) {\n flush();\n }\n }, [flush]);\n\n const push = useCallback(\n (fn: (navigation: GenericNavigation) => void) => {\n pending.current.push(fn);\n if (store.navigationRef.current) {\n flush();\n }\n },\n [flush]\n );\n\n return push;\n}\n\nexport function useOptionalNavigation(): GenericNavigation | null {\n const [navigation, setNavigation] = useState<GenericNavigation | null>(null);\n const loadNavigation = useLoadedNavigation();\n\n useEffect(() => {\n loadNavigation((nav) => setNavigation(nav));\n }, []);\n\n return navigation;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAQ,MAAM,OAAE,KAAK,KAAwC,CAAC"}
|
package/build/primitives.js
CHANGED
package/build/primitives.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;AAEb,qDAAkE;AAElE,oGAAoG;AACpG,gBAAgB;AACH,KAAoB,IAAA,+BAAsB,EAAC,EAAS,CAAC,EAAE,EAArD,cAAM,cAAE,aAAK,YAAyC","sourcesContent":["'use client';\n\nimport { createNavigatorFactory } from '@react-navigation/native';\n\n// `@react-navigation/native` does not expose the Screen or Group components directly, so we have to\n// do this hack.\nexport const { Screen, Group } = createNavigatorFactory({} as any)();\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import './expect';
|
|
2
2
|
import './mocks';
|
|
3
|
-
import { NavigationState, PartialState } from '@react-navigation/native';
|
|
4
3
|
import { render } from '@testing-library/react-native';
|
|
5
4
|
import { MockContextConfig, getMockConfig, getMockContext } from './mock-config';
|
|
6
5
|
import { ExpoLinkingOptions } from '../getLinkingConfig';
|
|
6
|
+
import { ReactNavigationState } from '../global-state/router-store';
|
|
7
7
|
export * from '@testing-library/react-native';
|
|
8
8
|
export type RenderRouterOptions = Parameters<typeof render>[1] & {
|
|
9
9
|
initialUrl?: any;
|
|
@@ -14,7 +14,7 @@ type Result = ReturnType<typeof render> & {
|
|
|
14
14
|
getPathnameWithParams(): string;
|
|
15
15
|
getSegments(): string[];
|
|
16
16
|
getSearchParams(): Record<string, string | string[]>;
|
|
17
|
-
getRouterState():
|
|
17
|
+
getRouterState(): ReactNavigationState | undefined;
|
|
18
18
|
};
|
|
19
19
|
declare global {
|
|
20
20
|
namespace jest {
|
|
@@ -23,7 +23,7 @@ declare global {
|
|
|
23
23
|
toHavePathnameWithParams(pathname: string): R;
|
|
24
24
|
toHaveSegments(segments: string[]): R;
|
|
25
25
|
toHaveSearchParams(params: Record<string, string | string[]>): R;
|
|
26
|
-
|
|
26
|
+
getRouterState(): ReactNavigationState | undefined;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|