expo-router 5.2.0-canary-20250630-547cd82 → 5.2.0-canary-20250709-136b77f
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/assets/modal.module.css +124 -0
- package/build/fork/useLinking.d.ts.map +1 -1
- package/build/fork/useLinking.js +7 -3
- package/build/fork/useLinking.js.map +1 -1
- package/build/layouts/DrawerClient.d.ts +2 -2
- package/build/layouts/Stack.web.d.ts +17 -0
- package/build/layouts/Stack.web.d.ts.map +1 -0
- package/build/layouts/Stack.web.js +17 -0
- package/build/layouts/Stack.web.js.map +1 -0
- package/build/layouts/StackClient.d.ts +41 -3
- package/build/layouts/StackClient.d.ts.map +1 -1
- package/build/layouts/StackClient.js +79 -2
- package/build/layouts/StackClient.js.map +1 -1
- package/build/layouts/TabsClient.d.ts +3 -3
- package/build/link/BaseExpoRouterLink.d.ts +2 -1
- package/build/link/BaseExpoRouterLink.d.ts.map +1 -1
- package/build/link/BaseExpoRouterLink.js +37 -1
- package/build/link/BaseExpoRouterLink.js.map +1 -1
- package/build/link/ExpoLink.d.ts +2 -1
- package/build/link/ExpoLink.d.ts.map +1 -1
- package/build/link/ExpoLink.js +44 -3
- package/build/link/ExpoLink.js.map +1 -1
- package/build/link/Link.d.ts +3 -3
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js.map +1 -1
- package/build/link/LinkWithPreview.d.ts +19 -6
- package/build/link/LinkWithPreview.d.ts.map +1 -1
- package/build/link/LinkWithPreview.js +53 -18
- package/build/link/LinkWithPreview.js.map +1 -1
- package/build/link/preview/HrefPreview.d.ts.map +1 -1
- package/build/link/preview/HrefPreview.js +2 -2
- package/build/link/preview/HrefPreview.js.map +1 -1
- package/build/link/preview/native.d.ts +2 -0
- package/build/link/preview/native.d.ts.map +1 -1
- package/build/link/preview/native.js.map +1 -1
- package/build/modal/web/ModalStack.web.d.ts +25 -0
- package/build/modal/web/ModalStack.web.d.ts.map +1 -0
- package/build/modal/web/ModalStack.web.js +86 -0
- package/build/modal/web/ModalStack.web.js.map +1 -0
- package/build/modal/web/ModalStackRouteDrawer.web.d.ts +14 -0
- package/build/modal/web/ModalStackRouteDrawer.web.d.ts.map +1 -0
- package/build/modal/web/ModalStackRouteDrawer.web.js +161 -0
- package/build/modal/web/ModalStackRouteDrawer.web.js.map +1 -0
- package/build/modal/web/TransparentModalStackRouteDrawer.web.d.ts +10 -0
- package/build/modal/web/TransparentModalStackRouteDrawer.web.d.ts.map +1 -0
- package/build/modal/web/TransparentModalStackRouteDrawer.web.js +28 -0
- package/build/modal/web/TransparentModalStackRouteDrawer.web.js.map +1 -0
- package/build/modal/web/modalStyles.d.ts +3 -0
- package/build/modal/web/modalStyles.d.ts.map +1 -0
- package/build/modal/web/modalStyles.js +8 -0
- package/build/modal/web/modalStyles.js.map +1 -0
- package/build/modal/web/types.d.ts +14 -0
- package/build/modal/web/types.d.ts.map +1 -0
- package/build/modal/web/types.js +3 -0
- package/build/modal/web/types.js.map +1 -0
- package/build/modal/web/utils.d.ts +70 -0
- package/build/modal/web/utils.d.ts.map +1 -0
- package/build/modal/web/utils.js +117 -0
- package/build/modal/web/utils.js.map +1 -0
- package/ios/ExpoHead.podspec +1 -1
- package/ios/LinkPreview/LinkPreviewNativeActionView.swift +22 -0
- package/ios/LinkPreview/LinkPreviewNativeModule.swift +3 -0
- package/ios/LinkPreview/LinkPreviewNativeView.swift +30 -11
- package/package.json +9 -7
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
.modal {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
flex: 1;
|
|
5
|
+
pointer-events: auto;
|
|
6
|
+
border: var(--expo-router-modal-border, 1px solid rgba(61.2, 61.2, 66, 0.29));
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
overflow: auto;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.overlay {
|
|
12
|
+
position: fixed;
|
|
13
|
+
inset: 0;
|
|
14
|
+
background-color: var(--expo-router-modal-overlay-background, rgba(0, 0, 0, 0.4));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@media (min-width: 768px) {
|
|
18
|
+
.modal {
|
|
19
|
+
position: relative;
|
|
20
|
+
z-index: 50;
|
|
21
|
+
/* Default width 580px (iPad modals) but responsive up to 90vw unless overridden */
|
|
22
|
+
width: var(--expo-router-modal-width, 580px);
|
|
23
|
+
min-width: var(--expo-router-modal-min-width, auto);
|
|
24
|
+
/* If --expo-router-modal-width is provided use that, otherwise default clamp */
|
|
25
|
+
max-width: var(--expo-router-modal-max-width, 90vw);
|
|
26
|
+
/* Clamp height so modal never exceeds viewport minus 2rem padding */
|
|
27
|
+
max-height: min(var(--expo-router-modal-height, 640px), calc(100vh - 2rem));
|
|
28
|
+
/* Ensure modal retains a reasonable minimum but never bigger than viewport */
|
|
29
|
+
min-height: min(var(--expo-router-modal-min-height, var(--expo-router-modal-height, 640px)), calc(100vh - 2rem));
|
|
30
|
+
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1),
|
|
31
|
+
0 4px 6px -4px rgb(0 0 0 / 0.1);
|
|
32
|
+
overflow: auto;
|
|
33
|
+
outline: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.modalWrap>.modal {
|
|
37
|
+
pointer-events: auto;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.drawerContent {
|
|
42
|
+
position: fixed;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
bottom: 0;
|
|
46
|
+
left: 0;
|
|
47
|
+
right: 0;
|
|
48
|
+
height: 100%;
|
|
49
|
+
outline: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
body>.transparentDrawerContent {
|
|
53
|
+
position: fixed;
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
bottom: 0;
|
|
57
|
+
left: 0;
|
|
58
|
+
right: 0;
|
|
59
|
+
height: 100%;
|
|
60
|
+
outline: none;
|
|
61
|
+
animation: none;
|
|
62
|
+
animation-name: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@media (min-width: 768px) {
|
|
66
|
+
.drawerContent {
|
|
67
|
+
max-height: 100%;
|
|
68
|
+
pointer-events: box-none;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.modal::-webkit-scrollbar {
|
|
73
|
+
width: 0px;
|
|
74
|
+
height: 0px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.modal::-webkit-scrollbar-thumb {
|
|
78
|
+
background: transparent;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.modalBody {
|
|
82
|
+
flex: 1;
|
|
83
|
+
overflow: auto;
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* Ensure bottom sheets (inside drawerContent) can shrink to any detent */
|
|
88
|
+
.drawerContent .modal[data-presentation='formSheet'],
|
|
89
|
+
.drawerContent .modal[data-presentation='containedModal'] {
|
|
90
|
+
/* Reset inherited centering */
|
|
91
|
+
position: relative;
|
|
92
|
+
transform: none;
|
|
93
|
+
box-shadow: none;
|
|
94
|
+
border-radius: inherit;
|
|
95
|
+
min-height: auto;
|
|
96
|
+
max-height: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* Form-sheet style (snap-point based) should be full width */
|
|
100
|
+
.drawerContent .modal[data-presentation='formSheet'],
|
|
101
|
+
.drawerContent .modal[data-presentation='containedModal'] {
|
|
102
|
+
width: 100%;
|
|
103
|
+
max-width: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Regular modal keeps desktop max-width for nicer look */
|
|
107
|
+
.drawerContent .modal[data-presentation='modal'],
|
|
108
|
+
.drawerContent .modal[data-presentation='fullScreenModal'] {
|
|
109
|
+
position: fixed;
|
|
110
|
+
left: 50%;
|
|
111
|
+
top: 50%;
|
|
112
|
+
transform: translate(-50%, -50%);
|
|
113
|
+
/* Use the same sizing variables as the primary desktop rule */
|
|
114
|
+
width: var(--expo-router-modal-width, 580px);
|
|
115
|
+
min-width: var(--expo-router-modal-min-width, auto);
|
|
116
|
+
max-width: var(--expo-router-modal-max-width, 90vw);
|
|
117
|
+
margin: 0;
|
|
118
|
+
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
|
119
|
+
border-radius: var(--expo-router-modal-border-radius, 10px);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.srOnly {
|
|
123
|
+
display: none;
|
|
124
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAId,gBAAgB,IAAI,uBAAuB,EAC3C,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAId,gBAAgB,IAAI,uBAAuB,EAC3C,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AA0C9D;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,OAAO,CAAC,IAAI,CAAC,eAM7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,EAClE,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;2BA4GhD,WAAW,CAAC,WAAW,GAAG,SAAS,CAAC;EA8R1D;AAED,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAEjF"}
|
package/build/fork/useLinking.js
CHANGED
|
@@ -44,6 +44,7 @@ const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
|
44
44
|
const React = __importStar(require("react"));
|
|
45
45
|
const createMemoryHistory_1 = require("./createMemoryHistory");
|
|
46
46
|
const getPathFromState_1 = require("./getPathFromState");
|
|
47
|
+
const constants_1 = require("../constants");
|
|
47
48
|
const serverLocationContext_1 = require("../global-state/serverLocationContext");
|
|
48
49
|
const storeContext_1 = require("../global-state/storeContext");
|
|
49
50
|
/**
|
|
@@ -135,14 +136,17 @@ function useLinking(ref, { enabled = true, config, getStateFromPath = native_1.g
|
|
|
135
136
|
});
|
|
136
137
|
const validateRoutesNotExistInRootState = React.useCallback((state) => {
|
|
137
138
|
// START FORK
|
|
138
|
-
// Instead of using the rootState
|
|
139
|
+
// Instead of using the rootState, we use INTERNAL_SLOT_NAME, which is the only route in the root navigator in Expo Router
|
|
139
140
|
// const navigation = ref.current;
|
|
140
141
|
// const rootState = navigation?.getRootState();
|
|
141
|
-
const
|
|
142
|
+
const routeNames = [constants_1.INTERNAL_SLOT_NAME];
|
|
142
143
|
// END FORK
|
|
143
144
|
// Make sure that the routes in the state exist in the root navigator
|
|
144
145
|
// Otherwise there's an error in the linking configuration
|
|
145
|
-
|
|
146
|
+
// START FORK
|
|
147
|
+
// return state?.routes.some((r) => !rootState?.routeNames?.includes(r.name));
|
|
148
|
+
return state?.routes.some((r) => !routeNames.includes(r.name));
|
|
149
|
+
// END FORK
|
|
146
150
|
}, [ref]);
|
|
147
151
|
const server = React.use(serverLocationContext_1.ServerContext);
|
|
148
152
|
const getInitialState = React.useCallback(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinking.js","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,gCAiZC;AAED,4DAEC;AAjeD,qDAUkC;AAClC,sEAAsC;AACtC,6CAA+B;AAE/B,+DAA4D;AAC5D,yDAAmD;AACnD,iFAAsE;AACtE,+DAAkE;AAIlE;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CACxB,CAAgB,EAChB,CAAgB,EACgB,EAAE;IAClC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1D,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,uFAAuF;IACvF,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IACtE,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAEtE,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAEjC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAsB,CAAC;IAClD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAsB,CAAC;IAElD,sDAAsD;IACtD,gCAAgC;IAChC,iCAAiC;I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,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAE5B,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,SAAgB,wBAAwB;IACtC,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnE,CAAC","sourcesContent":["import {\n LinkingOptions,\n findFocusedRoute,\n getActionFromState as getActionFromStateDefault,\n getPathFromState as getPathFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type NavigationState,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/native';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport { createMemoryHistory } from './createMemoryHistory';\nimport { appendBaseUrl } from './getPathFromState';\nimport { ServerContext } from '../global-state/serverLocationContext';\nimport { useExpoRouterStore } from '../global-state/storeContext';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\n/**\n * Find the matching navigation state that changed between 2 navigation states\n * e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state\n */\nconst findMatchingState = <T extends NavigationState>(\n a: T | undefined,\n b: T | undefined\n): [T | undefined, T | undefined] => {\n if (a === undefined || b === undefined || a.key !== b.key) {\n return [undefined, undefined];\n }\n\n // Tab and drawer will have `history` property, but stack will have history in `routes`\n const aHistoryLength = a.history ? a.history.length : a.routes.length;\n const bHistoryLength = b.history ? b.history.length : b.routes.length;\n\n const aRoute = a.routes[a.index];\n const bRoute = b.routes[b.index];\n\n const aChildState = aRoute.state as T | undefined;\n const bChildState = bRoute.state as T | undefined;\n\n // Stop here if this is the state object that changed:\n // - history length is different\n // - focused routes are different\n // - one of them doesn't have child state\n // - child state keys are different\n if (\n aHistoryLength !== bHistoryLength ||\n aRoute.key !== bRoute.key ||\n aChildState === undefined ||\n bChildState === undefined ||\n aChildState.key !== bChildState.key\n ) {\n return [a, b];\n }\n\n return findMatchingState(aChildState, bChildState);\n};\n\n/**\n * Run async function in series as it's called.\n */\nexport const series = (cb: () => Promise<void>) => {\n let queue = Promise.resolve();\n const callback = () => {\n queue = queue.then(cb);\n };\n return callback;\n};\n\nconst linkingHandlers: symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase>;\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase> | null>,\n {\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\n\n const store = useExpoRouterStore();\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') {\n return undefined;\n }\n\n if (independent) {\n return undefined;\n }\n\n if (enabled !== false && linkingHandlers.length) {\n console.error(\n [\n 'Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:',\n \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n '- Only a single instance of the root component is rendered',\n ]\n .join('\\n')\n .trim()\n );\n }\n\n const handler = Symbol();\n\n if (enabled !== false) {\n linkingHandlers.push(handler);\n }\n\n return () => {\n const index = linkingHandlers.indexOf(handler);\n\n if (index > -1) {\n linkingHandlers.splice(index, 1);\n }\n };\n }, [enabled, independent]);\n\n const [history] = React.useState(createMemoryHistory);\n\n // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n const enabledRef = React.useRef(enabled);\n const configRef = React.useRef(config);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getPathFromStateRef = React.useRef(getPathFromState);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n configRef.current = config;\n getStateFromPathRef.current = getStateFromPath;\n getPathFromStateRef.current = getPathFromState;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const validateRoutesNotExistInRootState = React.useCallback(\n (state: ResultState) => {\n // START FORK\n // Instead of using the rootState (which might be stale) we should use the focused state\n // const navigation = ref.current;\n // const rootState = navigation?.getRootState();\n const rootState = store.state as NavigationState;\n\n // END FORK\n\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n return state?.routes.some((r) => !rootState?.routeNames.includes(r.name));\n },\n [ref]\n );\n\n const server = React.use(ServerContext);\n\n const getInitialState = React.useCallback(() => {\n let value: ResultState | undefined;\n\n if (enabledRef.current) {\n const location =\n server?.location ?? (typeof window !== 'undefined' ? window.location : undefined);\n\n const path = location ? location.pathname + location.search : undefined;\n\n if (path) {\n value = getStateFromPathRef.current(path, configRef.current);\n }\n\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const previousIndexRef = React.useRef<number | undefined>(undefined);\n const previousStateRef = React.useRef<NavigationState | undefined>(undefined);\n const pendingPopStatePathRef = React.useRef<string | undefined>(undefined);\n\n React.useEffect(() => {\n previousIndexRef.current = history.index;\n\n return history.listen(() => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const { location } = window;\n\n const path = location.pathname + location.search + location.hash;\n const index = history.index;\n\n const previousIndex = previousIndexRef.current ?? 0;\n\n previousIndexRef.current = index;\n pendingPopStatePathRef.current = path;\n\n // When browser back/forward is clicked, we first need to check if state object for this index exists\n // If it does we'll reset to that state object\n // Otherwise, we'll handle it like a regular deep link\n const record = history.get(index);\n\n if (record?.path === path && record?.state) {\n navigation.resetRoot(record.state);\n return;\n }\n\n const state = getStateFromPathRef.current(path, configRef.current);\n\n // We should only dispatch an action when going forward\n // Otherwise the action will likely add items to history, which would mess things up\n if (state) {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n if (validateRoutesNotExistInRootState(state)) {\n return;\n }\n\n if (\n index > previousIndex ||\n /* START FORK\n *\n * This is a workaround for React Navigation's handling of hashes (it doesn't handle them)\n * When you click on <a href=\"#hash\">, the browser will first fire a popstate event\n * and this callback will be called.\n *\n * From React Navigation's perspective, it's treating the new hash change like a back/forward\n * button press, so it thinks it should reset the state. When we should\n * be to be pushing the new state\n *\n * Our fix is to check if the index is the same as the previous index\n * and if the incoming path is the same as the old path but with the hash added,\n * then treat it as a push instead of a reset\n *\n * This also works for subsequent hash changes, as internally RN\n * doesn't store the hash in the history state.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent\n */\n (index === previousIndex && (!record || `${record?.path}${location.hash}` === path))\n // END FORK\n ) {\n const action = getActionFromStateRef.current(state, configRef.current);\n\n if (action !== undefined) {\n try {\n navigation.dispatch(action);\n } catch (e) {\n // Ignore any errors from deep linking.\n // This could happen in case of malformed links, navigation object not being initialized etc.\n console.warn(\n `An error occurred when trying to handle the link '${path}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n // if current path didn't return any state, we should revert to initial state\n navigation.resetRoot(state);\n }\n });\n }, [enabled, history, onUnhandledLinking, ref, validateRoutesNotExistInRootState]);\n\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const getPathForRoute = (\n route: ReturnType<typeof findFocusedRoute>,\n state: NavigationState\n ): string => {\n let path;\n\n // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match\n // This makes sure that we preserve the original URL for wildcard routes\n if (route?.path) {\n const stateForPath = getStateFromPathRef.current(route.path, configRef.current);\n\n if (stateForPath) {\n const focusedRoute = findFocusedRoute(stateForPath);\n\n if (\n focusedRoute &&\n focusedRoute.name === route.name &&\n isEqual({ ...focusedRoute.params }, { ...route.params })\n ) {\n // START FORK - Ensure paths coming from events (e.g refresh) have the base URL\n // path = route.path;\n path = appendBaseUrl(route.path);\n // END FORK\n }\n }\n }\n\n if (path == null) {\n path = getPathFromStateRef.current(state, configRef.current);\n }\n\n // START FORK - ExpoRouter manually handles hashes. This code is intentionally removed\n // const previousRoute = previousStateRef.current\n // ? findFocusedRoute(previousStateRef.current)\n // : undefined;\n\n // Preserve the hash if the route didn't change\n // if (\n // previousRoute &&\n // route &&\n // 'key' in previousRoute &&\n // 'key' in route &&\n // previousRoute.key === route.key\n // ) {\n // path = path + location.hash;\n // }\n // END FORK\n\n return path;\n };\n\n if (ref.current) {\n // We need to record the current metadata on the first render if they aren't set\n // This will allow the initial state to be in the history entry\n\n // START FORK\n // Instead of using the rootState (which might be stale) we should use the focused state\n // const state = ref.current.getRootState();\n const rootState = ref.current.getRootState();\n const state = store.state as NavigationState;\n\n // END FORK\n\n if (state) {\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n if (previousStateRef.current === undefined) {\n // START FORK\n // previousStateRef.current = state;\n previousStateRef.current = rootState;\n // END FORK\n }\n\n history.replace({ path, state });\n }\n }\n\n const onStateChange = async () => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const previousState = previousStateRef.current;\n // START FORK\n // Instead of using the rootState (which might be stale) we should use the focused state\n // const state = navigation.getRootState();\n const rootState = navigation.getRootState();\n const state = store.state as NavigationState;\n\n // END FORK\n\n // root state may not available, for example when root navigators switch inside the container\n if (!state) {\n return;\n }\n\n const pendingPath = pendingPopStatePathRef.current;\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n // START FORK\n // previousStateRef.current = state;\n previousStateRef.current = rootState;\n // END FORK\n pendingPopStatePathRef.current = undefined;\n\n // To detect the kind of state change, we need to:\n // - Find the common focused navigation state in previous and current state\n // - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace\n // - If no common focused navigation state found, it's a replace\n const [previousFocusedState, focusedState] = findMatchingState(previousState, state);\n\n if (\n previousFocusedState &&\n focusedState &&\n // We should only handle push/pop if path changed from what was in last `popstate`\n // Otherwise it's likely a change triggered by `popstate`\n path !== pendingPath\n ) {\n const historyDelta =\n (focusedState.history ? focusedState.history.length : focusedState.routes.length) -\n (previousFocusedState.history\n ? previousFocusedState.history.length\n : previousFocusedState.routes.length);\n\n if (historyDelta > 0) {\n // If history length is increased, we should pushState\n // Note that path might not actually change here, for example, drawer open should pushState\n history.push({ path, state });\n } else if (historyDelta < 0) {\n // If history length is decreased, i.e. entries were removed, we want to go back\n\n const nextIndex = history.backIndex({ path });\n const currentIndex = history.index;\n\n try {\n if (\n nextIndex !== -1 &&\n nextIndex < currentIndex &&\n // We should only go back if the entry exists and it's less than current index\n history.get(nextIndex - currentIndex)\n ) {\n // An existing entry for this path exists and it's less than current index, go back to that\n await history.go(nextIndex - currentIndex);\n } else {\n // We couldn't find an existing entry to go back to, so we'll go back by the delta\n // This won't be correct if multiple routes were pushed in one go before\n // Usually this shouldn't happen and this is a fallback for that\n await history.go(historyDelta);\n }\n\n // Store the updated state as well as fix the path if incorrect\n history.replace({ path, state });\n } catch {\n // The navigation was interrupted\n }\n } else {\n // If history length is unchanged, we want to replaceState\n history.replace({ path, state });\n }\n } else {\n // If no common navigation state was found, assume it's a replace\n // This would happen if the user did a reset/conditionally changed navigators\n history.replace({ path, state });\n }\n };\n\n // We debounce onStateChange coz we don't want multiple state changes to be handled at one time\n // This could happen since `history.go(n)` is asynchronous\n // If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up\n return ref.current?.addListener('state', series(onStateChange));\n }, [enabled, history, ref]);\n\n return {\n getInitialState,\n };\n}\n\nexport function getInitialURLWithTimeout(): string | null | Promise<string | null> {\n return typeof window === 'undefined' ? '' : window.location.href;\n}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KAChB,CAAC;AACJ,CAAC;AAED,SAAgB,wBAAwB;IACtC,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnE,CAAC","sourcesContent":["import {\n LinkingOptions,\n findFocusedRoute,\n getActionFromState as getActionFromStateDefault,\n getPathFromState as getPathFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type NavigationState,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/native';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport { createMemoryHistory } from './createMemoryHistory';\nimport { appendBaseUrl } from './getPathFromState';\nimport { INTERNAL_SLOT_NAME } from '../constants';\nimport { ServerContext } from '../global-state/serverLocationContext';\nimport { useExpoRouterStore } from '../global-state/storeContext';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\n/**\n * Find the matching navigation state that changed between 2 navigation states\n * e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state\n */\nconst findMatchingState = <T extends NavigationState>(\n a: T | undefined,\n b: T | undefined\n): [T | undefined, T | undefined] => {\n if (a === undefined || b === undefined || a.key !== b.key) {\n return [undefined, undefined];\n }\n\n // Tab and drawer will have `history` property, but stack will have history in `routes`\n const aHistoryLength = a.history ? a.history.length : a.routes.length;\n const bHistoryLength = b.history ? b.history.length : b.routes.length;\n\n const aRoute = a.routes[a.index];\n const bRoute = b.routes[b.index];\n\n const aChildState = aRoute.state as T | undefined;\n const bChildState = bRoute.state as T | undefined;\n\n // Stop here if this is the state object that changed:\n // - history length is different\n // - focused routes are different\n // - one of them doesn't have child state\n // - child state keys are different\n if (\n aHistoryLength !== bHistoryLength ||\n aRoute.key !== bRoute.key ||\n aChildState === undefined ||\n bChildState === undefined ||\n aChildState.key !== bChildState.key\n ) {\n return [a, b];\n }\n\n return findMatchingState(aChildState, bChildState);\n};\n\n/**\n * Run async function in series as it's called.\n */\nexport const series = (cb: () => Promise<void>) => {\n let queue = Promise.resolve();\n const callback = () => {\n queue = queue.then(cb);\n };\n return callback;\n};\n\nconst linkingHandlers: symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase>;\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase> | null>,\n {\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\n\n const store = useExpoRouterStore();\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') {\n return undefined;\n }\n\n if (independent) {\n return undefined;\n }\n\n if (enabled !== false && linkingHandlers.length) {\n console.error(\n [\n 'Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:',\n \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n '- Only a single instance of the root component is rendered',\n ]\n .join('\\n')\n .trim()\n );\n }\n\n const handler = Symbol();\n\n if (enabled !== false) {\n linkingHandlers.push(handler);\n }\n\n return () => {\n const index = linkingHandlers.indexOf(handler);\n\n if (index > -1) {\n linkingHandlers.splice(index, 1);\n }\n };\n }, [enabled, independent]);\n\n const [history] = React.useState(createMemoryHistory);\n\n // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n const enabledRef = React.useRef(enabled);\n const configRef = React.useRef(config);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getPathFromStateRef = React.useRef(getPathFromState);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n configRef.current = config;\n getStateFromPathRef.current = getStateFromPath;\n getPathFromStateRef.current = getPathFromState;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const validateRoutesNotExistInRootState = React.useCallback(\n (state: ResultState) => {\n // START FORK\n // Instead of using the rootState, we use INTERNAL_SLOT_NAME, which is the only route in the root navigator in Expo Router\n // const navigation = ref.current;\n // const rootState = navigation?.getRootState();\n const routeNames = [INTERNAL_SLOT_NAME];\n // END FORK\n\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n // START FORK\n // return state?.routes.some((r) => !rootState?.routeNames?.includes(r.name));\n return state?.routes.some((r) => !routeNames.includes(r.name));\n // END FORK\n },\n [ref]\n );\n\n const server = React.use(ServerContext);\n\n const getInitialState = React.useCallback(() => {\n let value: ResultState | undefined;\n\n if (enabledRef.current) {\n const location =\n server?.location ?? (typeof window !== 'undefined' ? window.location : undefined);\n\n const path = location ? location.pathname + location.search : undefined;\n\n if (path) {\n value = getStateFromPathRef.current(path, configRef.current);\n }\n\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const previousIndexRef = React.useRef<number | undefined>(undefined);\n const previousStateRef = React.useRef<NavigationState | undefined>(undefined);\n const pendingPopStatePathRef = React.useRef<string | undefined>(undefined);\n\n React.useEffect(() => {\n previousIndexRef.current = history.index;\n\n return history.listen(() => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const { location } = window;\n\n const path = location.pathname + location.search + location.hash;\n const index = history.index;\n\n const previousIndex = previousIndexRef.current ?? 0;\n\n previousIndexRef.current = index;\n pendingPopStatePathRef.current = path;\n\n // When browser back/forward is clicked, we first need to check if state object for this index exists\n // If it does we'll reset to that state object\n // Otherwise, we'll handle it like a regular deep link\n const record = history.get(index);\n\n if (record?.path === path && record?.state) {\n navigation.resetRoot(record.state);\n return;\n }\n\n const state = getStateFromPathRef.current(path, configRef.current);\n\n // We should only dispatch an action when going forward\n // Otherwise the action will likely add items to history, which would mess things up\n if (state) {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n if (validateRoutesNotExistInRootState(state)) {\n return;\n }\n\n if (\n index > previousIndex ||\n /* START FORK\n *\n * This is a workaround for React Navigation's handling of hashes (it doesn't handle them)\n * When you click on <a href=\"#hash\">, the browser will first fire a popstate event\n * and this callback will be called.\n *\n * From React Navigation's perspective, it's treating the new hash change like a back/forward\n * button press, so it thinks it should reset the state. When we should\n * be to be pushing the new state\n *\n * Our fix is to check if the index is the same as the previous index\n * and if the incoming path is the same as the old path but with the hash added,\n * then treat it as a push instead of a reset\n *\n * This also works for subsequent hash changes, as internally RN\n * doesn't store the hash in the history state.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent\n */\n (index === previousIndex && (!record || `${record?.path}${location.hash}` === path))\n // END FORK\n ) {\n const action = getActionFromStateRef.current(state, configRef.current);\n\n if (action !== undefined) {\n try {\n navigation.dispatch(action);\n } catch (e) {\n // Ignore any errors from deep linking.\n // This could happen in case of malformed links, navigation object not being initialized etc.\n console.warn(\n `An error occurred when trying to handle the link '${path}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n // if current path didn't return any state, we should revert to initial state\n navigation.resetRoot(state);\n }\n });\n }, [enabled, history, onUnhandledLinking, ref, validateRoutesNotExistInRootState]);\n\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const getPathForRoute = (\n route: ReturnType<typeof findFocusedRoute>,\n state: NavigationState\n ): string => {\n let path;\n\n // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match\n // This makes sure that we preserve the original URL for wildcard routes\n if (route?.path) {\n const stateForPath = getStateFromPathRef.current(route.path, configRef.current);\n\n if (stateForPath) {\n const focusedRoute = findFocusedRoute(stateForPath);\n\n if (\n focusedRoute &&\n focusedRoute.name === route.name &&\n isEqual({ ...focusedRoute.params }, { ...route.params })\n ) {\n // START FORK - Ensure paths coming from events (e.g refresh) have the base URL\n // path = route.path;\n path = appendBaseUrl(route.path);\n // END FORK\n }\n }\n }\n\n if (path == null) {\n path = getPathFromStateRef.current(state, configRef.current);\n }\n\n // START FORK - ExpoRouter manually handles hashes. This code is intentionally removed\n // const previousRoute = previousStateRef.current\n // ? findFocusedRoute(previousStateRef.current)\n // : undefined;\n\n // Preserve the hash if the route didn't change\n // if (\n // previousRoute &&\n // route &&\n // 'key' in previousRoute &&\n // 'key' in route &&\n // previousRoute.key === route.key\n // ) {\n // path = path + location.hash;\n // }\n // END FORK\n\n return path;\n };\n\n if (ref.current) {\n // We need to record the current metadata on the first render if they aren't set\n // This will allow the initial state to be in the history entry\n\n // START FORK\n // Instead of using the rootState (which might be stale) we should use the focused state\n // const state = ref.current.getRootState();\n const rootState = ref.current.getRootState();\n const state = store.state as NavigationState;\n\n // END FORK\n\n if (state) {\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n if (previousStateRef.current === undefined) {\n // START FORK\n // previousStateRef.current = state;\n previousStateRef.current = rootState;\n // END FORK\n }\n\n history.replace({ path, state });\n }\n }\n\n const onStateChange = async () => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const previousState = previousStateRef.current;\n // START FORK\n // Instead of using the rootState (which might be stale) we should use the focused state\n // const state = navigation.getRootState();\n const rootState = navigation.getRootState();\n const state = store.state as NavigationState;\n\n // END FORK\n\n // root state may not available, for example when root navigators switch inside the container\n if (!state) {\n return;\n }\n\n const pendingPath = pendingPopStatePathRef.current;\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n // START FORK\n // previousStateRef.current = state;\n previousStateRef.current = rootState;\n // END FORK\n pendingPopStatePathRef.current = undefined;\n\n // To detect the kind of state change, we need to:\n // - Find the common focused navigation state in previous and current state\n // - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace\n // - If no common focused navigation state found, it's a replace\n const [previousFocusedState, focusedState] = findMatchingState(previousState, state);\n\n if (\n previousFocusedState &&\n focusedState &&\n // We should only handle push/pop if path changed from what was in last `popstate`\n // Otherwise it's likely a change triggered by `popstate`\n path !== pendingPath\n ) {\n const historyDelta =\n (focusedState.history ? focusedState.history.length : focusedState.routes.length) -\n (previousFocusedState.history\n ? previousFocusedState.history.length\n : previousFocusedState.routes.length);\n\n if (historyDelta > 0) {\n // If history length is increased, we should pushState\n // Note that path might not actually change here, for example, drawer open should pushState\n history.push({ path, state });\n } else if (historyDelta < 0) {\n // If history length is decreased, i.e. entries were removed, we want to go back\n\n const nextIndex = history.backIndex({ path });\n const currentIndex = history.index;\n\n try {\n if (\n nextIndex !== -1 &&\n nextIndex < currentIndex &&\n // We should only go back if the entry exists and it's less than current index\n history.get(nextIndex - currentIndex)\n ) {\n // An existing entry for this path exists and it's less than current index, go back to that\n await history.go(nextIndex - currentIndex);\n } else {\n // We couldn't find an existing entry to go back to, so we'll go back by the delta\n // This won't be correct if multiple routes were pushed in one go before\n // Usually this shouldn't happen and this is a fallback for that\n await history.go(historyDelta);\n }\n\n // Store the updated state as well as fix the path if incorrect\n history.replace({ path, state });\n } catch {\n // The navigation was interrupted\n }\n } else {\n // If history length is unchanged, we want to replaceState\n history.replace({ path, state });\n }\n } else {\n // If no common navigation state was found, assume it's a replace\n // This would happen if the user did a reset/conditionally changed navigators\n history.replace({ path, state });\n }\n };\n\n // We debounce onStateChange coz we don't want multiple state changes to be handled at one time\n // This could happen since `history.go(n)` is asynchronous\n // If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up\n return ref.current?.addListener('state', series(onStateChange));\n }, [enabled, history, ref]);\n\n return {\n getInitialState,\n };\n}\n\nexport function getInitialURLWithTimeout(): string | null | Promise<string | null> {\n return typeof window === 'undefined' ? '' : window.location.href;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DrawerNavigationOptions, DrawerNavigationEventMap } from '@react-navigation/drawer';
|
|
2
2
|
import { DrawerNavigationState, ParamListBase } from '@react-navigation/native';
|
|
3
|
-
export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "
|
|
3
|
+
export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenOptions" | "screenListeners" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
layout?: ((props: {
|
|
6
6
|
state: DrawerNavigationState<ParamListBase>;
|
|
@@ -53,7 +53,7 @@ export declare const Drawer: import("react").ForwardRefExoticComponent<Omit<Omit
|
|
|
53
53
|
}>>(original: import("@react-navigation/native").Router<DrawerNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<DrawerNavigationState<ParamListBase>, Action>>) | undefined;
|
|
54
54
|
} & {
|
|
55
55
|
id?: undefined;
|
|
56
|
-
}, "children"> & Partial<Pick<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "
|
|
56
|
+
}, "children"> & Partial<Pick<Omit<import("@react-navigation/drawer").DrawerNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenOptions" | "screenListeners" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
57
57
|
children: React.ReactNode;
|
|
58
58
|
layout?: ((props: {
|
|
59
59
|
state: DrawerNavigationState<ParamListBase>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
import { RouterModal } from '../modal/web/ModalStack.web';
|
|
3
|
+
declare const Stack: ((props: ComponentProps<typeof RouterModal>) => import("react").JSX.Element) & {
|
|
4
|
+
Screen: (props: import("..").ScreenProps<object, Readonly<{
|
|
5
|
+
key: string;
|
|
6
|
+
index: number;
|
|
7
|
+
routeNames: string[];
|
|
8
|
+
history?: unknown[];
|
|
9
|
+
routes: import("@react-navigation/routers").NavigationRoute<import("@react-navigation/routers").ParamListBase, string>[];
|
|
10
|
+
type: string;
|
|
11
|
+
stale: false;
|
|
12
|
+
}>, import("@react-navigation/core").EventMapBase>) => null;
|
|
13
|
+
Protected: import("react").FunctionComponent<import("../views/Protected").ProtectedProps>;
|
|
14
|
+
};
|
|
15
|
+
export { Stack };
|
|
16
|
+
export default Stack;
|
|
17
|
+
//# sourceMappingURL=Stack.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stack.web.d.ts","sourceRoot":"","sources":["../../src/layouts/Stack.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAM7E,QAAA,MAAM,KAAK,WACD,cAAc,CAAC,OAAO,WAAW,CAAC;;;;;;;;;;;CAO3C,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,CAAC;AAEjB,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Stack = void 0;
|
|
4
|
+
const StackClient_1 = require("./StackClient");
|
|
5
|
+
const ModalStack_web_1 = require("../modal/web/ModalStack.web");
|
|
6
|
+
const Protected_1 = require("../views/Protected");
|
|
7
|
+
// The RouterModal already includes Screen and Protected via withLayoutContext
|
|
8
|
+
// but we need to ensure we forward the stackRouterOverride for singular routes etc.
|
|
9
|
+
const Stack = Object.assign((props) => {
|
|
10
|
+
return <ModalStack_web_1.RouterModal {...props} UNSTABLE_router={StackClient_1.stackRouterOverride}/>;
|
|
11
|
+
}, {
|
|
12
|
+
Screen: ModalStack_web_1.RouterModalScreen,
|
|
13
|
+
Protected: Protected_1.Protected,
|
|
14
|
+
});
|
|
15
|
+
exports.Stack = Stack;
|
|
16
|
+
exports.default = Stack;
|
|
17
|
+
//# sourceMappingURL=Stack.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stack.web.js","sourceRoot":"","sources":["../../src/layouts/Stack.web.tsx"],"names":[],"mappings":";;;AAEA,+CAAoD;AACpD,gEAA6E;AAC7E,kDAA+C;AAE/C,8EAA8E;AAC9E,oFAAoF;AAEpF,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,CAAC,KAAyC,EAAE,EAAE;IAC5C,OAAO,CAAC,4BAAW,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,iCAAmB,CAAC,EAAG,CAAC;AAC1E,CAAC,EACD;IACE,MAAM,EAAE,kCAAiB;IACzB,SAAS,EAAT,qBAAS;CACV,CACF,CAAC;AAEO,sBAAK;AAEd,kBAAe,KAAK,CAAC","sourcesContent":["import { ComponentProps } from 'react';\n\nimport { stackRouterOverride } from './StackClient';\nimport { RouterModal, RouterModalScreen } from '../modal/web/ModalStack.web';\nimport { Protected } from '../views/Protected';\n\n// The RouterModal already includes Screen and Protected via withLayoutContext\n// but we need to ensure we forward the stackRouterOverride for singular routes etc.\n\nconst Stack = Object.assign(\n (props: ComponentProps<typeof RouterModal>) => {\n return <RouterModal {...props} UNSTABLE_router={stackRouterOverride} />;\n },\n {\n Screen: RouterModalScreen,\n Protected,\n }\n);\n\nexport { Stack };\n\nexport default Stack;\n"]}
|
|
@@ -2,7 +2,45 @@ import { ParamListBase, StackRouter as RNStackRouter, StackNavigationState } fro
|
|
|
2
2
|
import { NativeStackNavigationEventMap, NativeStackNavigationOptions } from '@react-navigation/native-stack';
|
|
3
3
|
import { ComponentProps } from 'react';
|
|
4
4
|
import { Protected } from '../views/Protected';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* We extend NativeStackNavigationOptions with our custom props
|
|
7
|
+
* to allow for several extra props to be used on web, like modalWidth
|
|
8
|
+
*/
|
|
9
|
+
export type ExtendedStackNavigationOptions = NativeStackNavigationOptions & {
|
|
10
|
+
webModalStyle?: {
|
|
11
|
+
/**
|
|
12
|
+
* Override the width of the modal (px or percentage). Only applies on web platform.
|
|
13
|
+
* @platform web
|
|
14
|
+
*/
|
|
15
|
+
width?: number | string;
|
|
16
|
+
/**
|
|
17
|
+
* Override the height of the modal (px or percentage). Applies on web desktop.
|
|
18
|
+
* @platform web
|
|
19
|
+
*/
|
|
20
|
+
height?: number | string;
|
|
21
|
+
/**
|
|
22
|
+
* Minimum height of the desktop modal (px or percentage). Overrides the default 640px clamp.
|
|
23
|
+
* @platform web
|
|
24
|
+
*/
|
|
25
|
+
minHeight?: number | string;
|
|
26
|
+
/**
|
|
27
|
+
* Minimum width of the desktop modal (px or percentage). Overrides the default 580px.
|
|
28
|
+
* @platform web
|
|
29
|
+
*/
|
|
30
|
+
minWidth?: number | string;
|
|
31
|
+
/**
|
|
32
|
+
* Override the border of the desktop modal (any valid CSS border value, e.g. '1px solid #ccc' or 'none').
|
|
33
|
+
* @platform web
|
|
34
|
+
*/
|
|
35
|
+
border?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Override the overlay background color (any valid CSS color or rgba/hsla value).
|
|
38
|
+
* @platform web
|
|
39
|
+
*/
|
|
40
|
+
overlayBackground?: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
declare const RNStack: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/native-stack").NativeStackNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenOptions" | "screenListeners" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
6
44
|
children: React.ReactNode;
|
|
7
45
|
layout?: ((props: {
|
|
8
46
|
state: StackNavigationState<ParamListBase>;
|
|
@@ -51,7 +89,7 @@ declare const RNStack: import("react").ForwardRefExoticComponent<Omit<Omit<impor
|
|
|
51
89
|
}>>(original: import("@react-navigation/native").Router<StackNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<StackNavigationState<ParamListBase>, Action>>) | undefined;
|
|
52
90
|
} & {
|
|
53
91
|
id?: undefined;
|
|
54
|
-
}, "children"> & Partial<Pick<Omit<import("@react-navigation/native-stack").NativeStackNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "
|
|
92
|
+
}, "children"> & Partial<Pick<Omit<import("@react-navigation/native-stack").NativeStackNavigatorProps, "children" | "layout" | "initialRouteName" | "id" | "screenOptions" | "screenListeners" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
|
|
55
93
|
children: React.ReactNode;
|
|
56
94
|
layout?: ((props: {
|
|
57
95
|
state: StackNavigationState<ParamListBase>;
|
|
@@ -101,7 +139,7 @@ declare const RNStack: import("react").ForwardRefExoticComponent<Omit<Omit<impor
|
|
|
101
139
|
} & {
|
|
102
140
|
id?: undefined;
|
|
103
141
|
}, "children">> & import("react").RefAttributes<unknown>> & {
|
|
104
|
-
Screen: (props: import("../useScreens").ScreenProps<
|
|
142
|
+
Screen: (props: import("../useScreens").ScreenProps<ExtendedStackNavigationOptions, StackNavigationState<ParamListBase>, NativeStackNavigationEventMap>) => null;
|
|
105
143
|
Protected: typeof Protected;
|
|
106
144
|
};
|
|
107
145
|
/**
|
|
@@ -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,g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,EAAE,cAAc,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAClE,IAAI;;CAGZ,CAAC;AA6BF,eAAe,KAAK,CAAC;AAErB,eAAO,MAAM,WAAW,EAAE,OAAO,aAMhC,CAAC"}
|
|
@@ -8,6 +8,7 @@ const non_secure_1 = require("nanoid/non-secure");
|
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const withLayoutContext_1 = require("./withLayoutContext");
|
|
10
10
|
const LinkPreviewContext_1 = require("../link/preview/LinkPreviewContext");
|
|
11
|
+
const ModalStack_web_1 = require("../modal/web/ModalStack.web");
|
|
11
12
|
const useScreens_1 = require("../useScreens");
|
|
12
13
|
const Protected_1 = require("../views/Protected");
|
|
13
14
|
const NativeStackNavigator = (0, native_stack_1.createNativeStackNavigator)().Navigator;
|
|
@@ -17,7 +18,8 @@ function isStackAction(action) {
|
|
|
17
18
|
action.type === 'NAVIGATE' ||
|
|
18
19
|
action.type === 'POP' ||
|
|
19
20
|
action.type === 'POP_TO_TOP' ||
|
|
20
|
-
action.type === 'REPLACE'
|
|
21
|
+
action.type === 'REPLACE' ||
|
|
22
|
+
action.type === 'PRELOAD');
|
|
21
23
|
}
|
|
22
24
|
const isPreviewAction = (action) => !!action.payload && 'previewKey' in action.payload && !!action.payload.previewKey;
|
|
23
25
|
/**
|
|
@@ -209,6 +211,75 @@ const stackRouterOverride = (original) => {
|
|
|
209
211
|
// };
|
|
210
212
|
// END FORK
|
|
211
213
|
}
|
|
214
|
+
case 'PRELOAD': {
|
|
215
|
+
const getId = options.routeGetIdList[action.payload.name];
|
|
216
|
+
const id = getId?.({ params: action.payload.params });
|
|
217
|
+
let route;
|
|
218
|
+
if (id !== undefined) {
|
|
219
|
+
route = state.routes.find((route) => route.name === action.payload.name && id === getId?.({ params: route.params }));
|
|
220
|
+
}
|
|
221
|
+
if (route) {
|
|
222
|
+
return {
|
|
223
|
+
...state,
|
|
224
|
+
routes: state.routes.map((r) => {
|
|
225
|
+
if (r.key !== route?.key) {
|
|
226
|
+
return r;
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
...r,
|
|
230
|
+
params: routeParamList[action.payload.name] !== undefined
|
|
231
|
+
? {
|
|
232
|
+
...routeParamList[action.payload.name],
|
|
233
|
+
...action.payload.params,
|
|
234
|
+
}
|
|
235
|
+
: action.payload.params,
|
|
236
|
+
};
|
|
237
|
+
}),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// START FORK
|
|
242
|
+
const currentPreloadedRoute = {
|
|
243
|
+
key: `${action.payload.name}-${(0, non_secure_1.nanoid)()}`,
|
|
244
|
+
name: action.payload.name,
|
|
245
|
+
params: routeParamList[action.payload.name] !== undefined
|
|
246
|
+
? {
|
|
247
|
+
...routeParamList[action.payload.name],
|
|
248
|
+
...action.payload.params,
|
|
249
|
+
}
|
|
250
|
+
: action.payload.params,
|
|
251
|
+
};
|
|
252
|
+
// END FORK
|
|
253
|
+
return {
|
|
254
|
+
...state,
|
|
255
|
+
// START FORK
|
|
256
|
+
// Adding the current preloaded route to the beginning of the preloadedRoutes array
|
|
257
|
+
// This ensures that the preloaded route will be the next one after the visible route
|
|
258
|
+
// and when navigation will happen, there will be no reshuffling
|
|
259
|
+
// This is a workaround for the link preview navigation issue, when screen would freeze after navigation from native side
|
|
260
|
+
// and reshuffling from react-navigation
|
|
261
|
+
preloadedRoutes: [currentPreloadedRoute].concat(state.preloadedRoutes.filter((r) => r.name !== action.payload.name || id !== getId?.({ params: r.params }))),
|
|
262
|
+
// preloadedRoutes: state.preloadedRoutes
|
|
263
|
+
// .filter(
|
|
264
|
+
// (r) =>
|
|
265
|
+
// r.name !== action.payload.name ||
|
|
266
|
+
// id !== getId?.({ params: r.params })
|
|
267
|
+
// )
|
|
268
|
+
// .concat({
|
|
269
|
+
// key: `${action.payload.name}-${nanoid()}`,
|
|
270
|
+
// name: action.payload.name,
|
|
271
|
+
// params:
|
|
272
|
+
// routeParamList[action.payload.name] !== undefined
|
|
273
|
+
// ? {
|
|
274
|
+
// ...routeParamList[action.payload.name],
|
|
275
|
+
// ...action.payload.params,
|
|
276
|
+
// }
|
|
277
|
+
// : action.payload.params,
|
|
278
|
+
// }),
|
|
279
|
+
// END FORK
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
212
283
|
default: {
|
|
213
284
|
return original.getStateForAction(state, action, options);
|
|
214
285
|
}
|
|
@@ -261,6 +332,7 @@ function filterSingular(state, getId) {
|
|
|
261
332
|
};
|
|
262
333
|
}
|
|
263
334
|
const Stack = Object.assign((props) => {
|
|
335
|
+
const isWeb = process.env.EXPO_OS === 'web';
|
|
264
336
|
const { isPreviewOpen } = (0, LinkPreviewContext_1.useLinkPreviewContext)();
|
|
265
337
|
const screenOptions = (0, react_1.useMemo)(() => {
|
|
266
338
|
if (isPreviewOpen) {
|
|
@@ -268,7 +340,12 @@ const Stack = Object.assign((props) => {
|
|
|
268
340
|
}
|
|
269
341
|
return props.screenOptions;
|
|
270
342
|
}, [props.screenOptions, isPreviewOpen]);
|
|
271
|
-
|
|
343
|
+
if (isWeb) {
|
|
344
|
+
return (<ModalStack_web_1.RouterModal {...props} screenOptions={screenOptions} UNSTABLE_router={exports.stackRouterOverride}/>);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
return (<RNStack {...props} screenOptions={screenOptions} UNSTABLE_router={exports.stackRouterOverride}/>);
|
|
348
|
+
}
|
|
272
349
|
}, {
|
|
273
350
|
Screen: RNStack.Screen,
|
|
274
351
|
Protected: Protected_1.Protected,
|