one 1.1.390 → 1.1.391
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/dist/cjs/Root.cjs +6 -17
- package/dist/cjs/Root.js +9 -13
- package/dist/cjs/Root.js.map +1 -1
- package/dist/cjs/Root.native.js +4 -12
- package/dist/cjs/Root.native.js.map +1 -1
- package/dist/cjs/fork/NavigationContainer.cjs +49 -31
- package/dist/cjs/fork/NavigationContainer.js +40 -21
- package/dist/cjs/fork/NavigationContainer.js.map +2 -2
- package/dist/cjs/fork/NavigationContainer.native.js +51 -29
- package/dist/cjs/fork/NavigationContainer.native.js.map +2 -2
- package/dist/cjs/fork/createMemoryHistory.cjs +4 -3
- package/dist/cjs/fork/createMemoryHistory.js +3 -2
- package/dist/cjs/fork/createMemoryHistory.js.map +1 -1
- package/dist/cjs/fork/createMemoryHistory.native.js +8 -4
- package/dist/cjs/fork/createMemoryHistory.native.js.map +2 -2
- package/dist/cjs/fork/extractPathFromURL.cjs +48 -28
- package/dist/cjs/fork/extractPathFromURL.js +44 -21
- package/dist/cjs/fork/extractPathFromURL.js.map +2 -2
- package/dist/cjs/fork/extractPathFromURL.native.js +58 -26
- package/dist/cjs/fork/extractPathFromURL.native.js.map +2 -2
- package/dist/cjs/fork/findFocusedRoute.js.map +1 -1
- package/dist/cjs/fork/findFocusedRoute.native.js.map +1 -1
- package/dist/cjs/fork/getPathFromState-mods.cjs +65 -0
- package/dist/cjs/fork/getPathFromState-mods.js +56 -0
- package/dist/cjs/fork/getPathFromState-mods.js.map +6 -0
- package/dist/cjs/fork/getPathFromState-mods.native.js +70 -0
- package/dist/cjs/fork/getPathFromState-mods.native.js.map +6 -0
- package/dist/cjs/fork/getPathFromState.cjs +75 -224
- package/dist/cjs/fork/getPathFromState.js +68 -223
- package/dist/cjs/fork/getPathFromState.js.map +2 -2
- package/dist/cjs/fork/getPathFromState.native.js +79 -261
- package/dist/cjs/fork/getPathFromState.native.js.map +2 -2
- package/dist/cjs/fork/getStateFromPath-mods.cjs +187 -0
- package/dist/cjs/fork/getStateFromPath-mods.js +199 -0
- package/dist/cjs/fork/getStateFromPath-mods.js.map +6 -0
- package/dist/cjs/fork/getStateFromPath-mods.native.js +284 -0
- package/dist/cjs/fork/getStateFromPath-mods.native.js.map +6 -0
- package/dist/cjs/fork/getStateFromPath.cjs +181 -263
- package/dist/cjs/fork/getStateFromPath.js +148 -264
- package/dist/cjs/fork/getStateFromPath.js.map +2 -2
- package/dist/cjs/fork/getStateFromPath.native.js +164 -304
- package/dist/cjs/fork/getStateFromPath.native.js.map +2 -2
- package/dist/cjs/fork/useBackButton.js.map +1 -1
- package/dist/cjs/fork/useBackButton.native.js.map +1 -1
- package/dist/cjs/fork/useDocumentTitle.js +4 -1
- package/dist/cjs/fork/useDocumentTitle.js.map +1 -1
- package/dist/cjs/fork/useDocumentTitle.native.js +1 -1
- package/dist/cjs/fork/useDocumentTitle.native.js.map +2 -2
- package/dist/cjs/fork/useLinking.cjs +21 -24
- package/dist/cjs/fork/useLinking.js +21 -25
- package/dist/cjs/fork/useLinking.js.map +2 -2
- package/dist/cjs/fork/useLinking.native.js +68 -66
- package/dist/cjs/fork/useLinking.native.js.map +2 -2
- package/dist/cjs/fork/useThenable.js.map +1 -1
- package/dist/cjs/fork/useThenable.native.js.map +1 -1
- package/dist/cjs/fork/validatePathConfig.cjs +32 -11
- package/dist/cjs/fork/validatePathConfig.js +41 -11
- package/dist/cjs/fork/validatePathConfig.js.map +1 -1
- package/dist/cjs/fork/validatePathConfig.native.js +47 -18
- package/dist/cjs/fork/validatePathConfig.native.js.map +2 -2
- package/dist/cjs/layouts/withLayoutContext.cjs +1 -1
- package/dist/cjs/layouts/withLayoutContext.js +1 -1
- package/dist/cjs/layouts/withLayoutContext.js.map +1 -1
- package/dist/cjs/layouts/withLayoutContext.native.js +1 -1
- package/dist/cjs/layouts/withLayoutContext.native.js.map +1 -1
- package/dist/cjs/link/linking.cjs +4 -4
- package/dist/cjs/link/linking.js +3 -3
- package/dist/cjs/link/linking.js.map +2 -2
- package/dist/cjs/link/linking.native.js +3 -3
- package/dist/cjs/link/linking.native.js.map +1 -1
- package/dist/cjs/link/useLinkTo.cjs +2 -2
- package/dist/cjs/link/useLinkTo.js +2 -2
- package/dist/cjs/link/useLinkTo.js.map +1 -1
- package/dist/cjs/link/useLinkTo.native.js +2 -2
- package/dist/cjs/link/useLinkTo.native.js.map +1 -1
- package/dist/cjs/router/getNormalizedStatePath.cjs +2 -2
- package/dist/cjs/router/getNormalizedStatePath.js +2 -2
- package/dist/cjs/router/getNormalizedStatePath.js.map +1 -1
- package/dist/cjs/router/getNormalizedStatePath.native.js +2 -2
- package/dist/cjs/router/getNormalizedStatePath.native.js.map +1 -1
- package/dist/cjs/router/router.cjs +19 -3
- package/dist/cjs/router/router.js +25 -3
- package/dist/cjs/router/router.js.map +1 -1
- package/dist/cjs/router/router.native.js +39 -3
- package/dist/cjs/router/router.native.js.map +2 -2
- package/dist/esm/Root.js +6 -2
- package/dist/esm/Root.js.map +1 -1
- package/dist/esm/Root.mjs +1 -1
- package/dist/esm/Root.mjs.map +1 -1
- package/dist/esm/Root.native.js +1 -1
- package/dist/esm/Root.native.js.map +2 -2
- package/dist/esm/fork/NavigationContainer.js +43 -20
- package/dist/esm/fork/NavigationContainer.js.map +1 -1
- package/dist/esm/fork/NavigationContainer.mjs +42 -24
- package/dist/esm/fork/NavigationContainer.mjs.map +1 -1
- package/dist/esm/fork/NavigationContainer.native.js +44 -24
- package/dist/esm/fork/NavigationContainer.native.js.map +2 -2
- package/dist/esm/fork/createMemoryHistory.js +3 -2
- package/dist/esm/fork/createMemoryHistory.js.map +1 -1
- package/dist/esm/fork/createMemoryHistory.mjs +4 -3
- package/dist/esm/fork/createMemoryHistory.mjs.map +1 -1
- package/dist/esm/fork/createMemoryHistory.native.js +4 -4
- package/dist/esm/fork/createMemoryHistory.native.js.map +2 -2
- package/dist/esm/fork/extractPathFromURL.js +42 -11
- package/dist/esm/fork/extractPathFromURL.js.map +1 -1
- package/dist/esm/fork/extractPathFromURL.mjs +39 -11
- package/dist/esm/fork/extractPathFromURL.mjs.map +1 -1
- package/dist/esm/fork/extractPathFromURL.native.js +52 -15
- package/dist/esm/fork/extractPathFromURL.native.js.map +2 -2
- package/dist/esm/fork/findFocusedRoute.js.map +1 -1
- package/dist/esm/fork/findFocusedRoute.mjs.map +1 -1
- package/dist/esm/fork/findFocusedRoute.native.js.map +1 -1
- package/dist/esm/fork/getPathFromState-mods.js +40 -0
- package/dist/esm/fork/getPathFromState-mods.js.map +6 -0
- package/dist/esm/fork/getPathFromState-mods.mjs +40 -0
- package/dist/esm/fork/getPathFromState-mods.mjs.map +1 -0
- package/dist/esm/fork/getPathFromState-mods.native.js +47 -0
- package/dist/esm/fork/getPathFromState-mods.native.js.map +6 -0
- package/dist/esm/fork/getPathFromState.js +71 -228
- package/dist/esm/fork/getPathFromState.js.map +2 -2
- package/dist/esm/fork/getPathFromState.mjs +73 -221
- package/dist/esm/fork/getPathFromState.mjs.map +1 -1
- package/dist/esm/fork/getPathFromState.native.js +79 -260
- package/dist/esm/fork/getPathFromState.native.js.map +2 -2
- package/dist/esm/fork/getStateFromPath-mods.js +176 -0
- package/dist/esm/fork/getStateFromPath-mods.js.map +6 -0
- package/dist/esm/fork/getStateFromPath-mods.mjs +143 -0
- package/dist/esm/fork/getStateFromPath-mods.mjs.map +1 -0
- package/dist/esm/fork/getStateFromPath-mods.native.js +246 -0
- package/dist/esm/fork/getStateFromPath-mods.native.js.map +6 -0
- package/dist/esm/fork/getStateFromPath.js +160 -265
- package/dist/esm/fork/getStateFromPath.js.map +2 -2
- package/dist/esm/fork/getStateFromPath.mjs +181 -260
- package/dist/esm/fork/getStateFromPath.mjs.map +1 -1
- package/dist/esm/fork/getStateFromPath.native.js +164 -302
- package/dist/esm/fork/getStateFromPath.native.js.map +2 -2
- package/dist/esm/fork/useBackButton.js.map +1 -1
- package/dist/esm/fork/useBackButton.mjs.map +1 -1
- package/dist/esm/fork/useBackButton.native.js.map +1 -1
- package/dist/esm/fork/useDocumentTitle.js +4 -1
- package/dist/esm/fork/useDocumentTitle.js.map +1 -1
- package/dist/esm/fork/useDocumentTitle.mjs.map +1 -1
- package/dist/esm/fork/useDocumentTitle.native.js +1 -1
- package/dist/esm/fork/useDocumentTitle.native.js.map +2 -2
- package/dist/esm/fork/useLinking.js +22 -26
- package/dist/esm/fork/useLinking.js.map +1 -1
- package/dist/esm/fork/useLinking.mjs +20 -23
- package/dist/esm/fork/useLinking.mjs.map +1 -1
- package/dist/esm/fork/useLinking.native.js +65 -67
- package/dist/esm/fork/useLinking.native.js.map +2 -2
- package/dist/esm/fork/useThenable.js.map +1 -1
- package/dist/esm/fork/useThenable.mjs.map +1 -1
- package/dist/esm/fork/useThenable.native.js.map +1 -1
- package/dist/esm/fork/validatePathConfig.js +41 -11
- package/dist/esm/fork/validatePathConfig.js.map +1 -1
- package/dist/esm/fork/validatePathConfig.mjs +32 -11
- package/dist/esm/fork/validatePathConfig.mjs.map +1 -1
- package/dist/esm/fork/validatePathConfig.native.js +43 -18
- package/dist/esm/fork/validatePathConfig.native.js.map +2 -2
- package/dist/esm/layouts/withLayoutContext.js +1 -1
- package/dist/esm/layouts/withLayoutContext.js.map +1 -1
- package/dist/esm/layouts/withLayoutContext.mjs +1 -1
- package/dist/esm/layouts/withLayoutContext.mjs.map +1 -1
- package/dist/esm/layouts/withLayoutContext.native.js +1 -1
- package/dist/esm/layouts/withLayoutContext.native.js.map +1 -1
- package/dist/esm/link/linking.js +2 -2
- package/dist/esm/link/linking.js.map +1 -1
- package/dist/esm/link/linking.mjs +2 -2
- package/dist/esm/link/linking.mjs.map +1 -1
- package/dist/esm/link/linking.native.js +2 -2
- package/dist/esm/link/linking.native.js.map +1 -1
- package/dist/esm/link/useLinkTo.js +1 -1
- package/dist/esm/link/useLinkTo.mjs +1 -1
- package/dist/esm/link/useLinkTo.native.js +1 -1
- package/dist/esm/router/getNormalizedStatePath.js +1 -1
- package/dist/esm/router/getNormalizedStatePath.mjs +1 -1
- package/dist/esm/router/getNormalizedStatePath.native.js +1 -1
- package/dist/esm/router/router.js +24 -2
- package/dist/esm/router/router.js.map +1 -1
- package/dist/esm/router/router.mjs +18 -2
- package/dist/esm/router/router.mjs.map +1 -1
- package/dist/esm/router/router.native.js +38 -2
- package/dist/esm/router/router.native.js.map +2 -2
- package/package.json +8 -9
- package/src/Root.tsx +6 -2
- package/src/fork/NavigationContainer.tsx +101 -39
- package/src/fork/createMemoryHistory.tsx +15 -13
- package/src/fork/extractPathFromURL.ts +85 -40
- package/src/fork/findFocusedRoute.tsx +9 -1
- package/src/fork/getPathFromState-mods.ts +142 -0
- package/src/fork/getPathFromState.ts +244 -501
- package/src/fork/getStateFromPath-mods.ts +400 -0
- package/src/fork/getStateFromPath.ts +447 -538
- package/src/fork/useBackButton.native.tsx +16 -2
- package/src/fork/useBackButton.tsx +11 -2
- package/src/fork/useDocumentTitle.native.tsx +9 -4
- package/src/fork/useDocumentTitle.tsx +12 -7
- package/src/fork/useLinking.native.ts +71 -63
- package/src/fork/useLinking.ts +75 -40
- package/src/fork/useThenable.tsx +7 -1
- package/src/fork/validatePathConfig.ts +64 -12
- package/src/layouts/withLayoutContext.tsx +1 -1
- package/src/link/linking.ts +2 -2
- package/src/link/useLinkTo.tsx +1 -1
- package/src/router/getNormalizedStatePath.tsx +1 -1
- package/src/router/router.ts +41 -2
- package/types/Root.d.ts.map +1 -1
- package/types/fork/NavigationContainer.d.ts +19 -8
- package/types/fork/NavigationContainer.d.ts.map +1 -1
- package/types/fork/createMemoryHistory.d.ts +10 -1
- package/types/fork/createMemoryHistory.d.ts.map +1 -1
- package/types/fork/extractPathFromURL.d.ts +7 -1
- package/types/fork/extractPathFromURL.d.ts.map +1 -1
- package/types/fork/findFocusedRoute.d.ts +9 -0
- package/types/fork/findFocusedRoute.d.ts.map +1 -1
- package/types/fork/getPathFromState-mods.d.ts +23 -0
- package/types/fork/getPathFromState-mods.d.ts.map +1 -0
- package/types/fork/getPathFromState.d.ts +15 -14
- package/types/fork/getPathFromState.d.ts.map +1 -1
- package/types/fork/getStateFromPath-mods.d.ts +58 -0
- package/types/fork/getStateFromPath-mods.d.ts.map +1 -0
- package/types/fork/getStateFromPath.d.ts +28 -29
- package/types/fork/getStateFromPath.d.ts.map +1 -1
- package/types/fork/useBackButton.d.ts +6 -0
- package/types/fork/useBackButton.d.ts.map +1 -1
- package/types/fork/useBackButton.native.d.ts +9 -1
- package/types/fork/useBackButton.native.d.ts.map +1 -1
- package/types/fork/useDocumentTitle.d.ts +8 -6
- package/types/fork/useDocumentTitle.d.ts.map +1 -1
- package/types/fork/useDocumentTitle.native.d.ts +5 -2
- package/types/fork/useDocumentTitle.native.d.ts.map +1 -1
- package/types/fork/useLinking.d.ts +8 -1
- package/types/fork/useLinking.d.ts.map +1 -1
- package/types/fork/useLinking.native.d.ts +9 -2
- package/types/fork/useLinking.native.d.ts.map +1 -1
- package/types/fork/useThenable.d.ts +6 -0
- package/types/fork/useThenable.d.ts.map +1 -1
- package/types/fork/validatePathConfig.d.ts +8 -1
- package/types/fork/validatePathConfig.d.ts.map +1 -1
- package/types/link/linking.d.ts +2 -2
- package/types/link/linking.d.ts.map +1 -1
@@ -1,19 +1,33 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* This file is copied from the react-navigation repo:
|
3
|
+
* https://github.com/react-navigation/react-navigation/blob/%40react-navigation/core%407.1.2/packages/core/src/getPathFromState.tsx
|
4
|
+
*
|
5
|
+
* Please refrain from making changes to this file, as it will make merging updates from the upstream harder.
|
6
|
+
* All modifications except formatting should be marked with `// @modified` comment.
|
7
|
+
*/
|
3
8
|
|
9
|
+
// @modified - start
|
4
10
|
import {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
} from '
|
11
|
+
type ConfigItemMods,
|
12
|
+
getPathWithConventionsCollapsed,
|
13
|
+
appendBaseUrl,
|
14
|
+
type AdditionalOptions,
|
15
|
+
} from './getPathFromState-mods'
|
16
|
+
// @modified - end
|
10
17
|
|
11
|
-
type
|
18
|
+
import type { NavigationState, PartialState, Route } from '@react-navigation/routers'
|
19
|
+
// import * as queryString from 'query-string' // @modified: not used
|
20
|
+
|
21
|
+
import type { PathConfig, PathConfigMap } from '@react-navigation/core' // @modified: import from package instead of relative code
|
22
|
+
import { validatePathConfig } from './validatePathConfig'
|
23
|
+
|
24
|
+
type Options<ParamList extends {}> = {
|
25
|
+
path?: string
|
12
26
|
initialRouteName?: string
|
13
27
|
screens: PathConfigMap<ParamList>
|
14
|
-
}
|
28
|
+
} & AdditionalOptions // @modified: add `AdditionalOptions`
|
15
29
|
|
16
|
-
export type State = NavigationState | Omit<PartialState<NavigationState>, 'stale'>
|
30
|
+
export type State = NavigationState | Omit<PartialState<NavigationState>, 'stale'> // @modified: add export
|
17
31
|
|
18
32
|
type StringifyConfig = Record<string, (value: any) => string>
|
19
33
|
|
@@ -21,15 +35,7 @@ type ConfigItem = {
|
|
21
35
|
pattern?: string
|
22
36
|
stringify?: StringifyConfig
|
23
37
|
screens?: Record<string, ConfigItem>
|
24
|
-
|
25
|
-
initialRouteName?: string
|
26
|
-
}
|
27
|
-
|
28
|
-
type CustomRoute = Route<string> & {
|
29
|
-
state?: State
|
30
|
-
}
|
31
|
-
|
32
|
-
const DEFAULT_SCREENS: PathConfigMap<object> = {}
|
38
|
+
} & ConfigItemMods // @modified: union `ConfigItemMods` for modifications
|
33
39
|
|
34
40
|
const getActiveRoute = (state: State): { name: string; params?: object } => {
|
35
41
|
const route =
|
@@ -41,44 +47,26 @@ const getActiveRoute = (state: State): { name: string; params?: object } => {
|
|
41
47
|
return getActiveRoute(route.state)
|
42
48
|
}
|
43
49
|
|
44
|
-
if (route && isInvalidParams(route.params)) {
|
45
|
-
return getActiveRoute(createFakeState(route.params))
|
46
|
-
}
|
47
|
-
|
48
50
|
return route
|
49
51
|
}
|
50
52
|
|
51
|
-
|
52
|
-
return {
|
53
|
-
stale: false,
|
54
|
-
type: 'UNKNOWN',
|
55
|
-
key: 'UNKNOWN',
|
56
|
-
index: 0,
|
57
|
-
routeNames: [],
|
58
|
-
routes: [
|
59
|
-
{
|
60
|
-
key: 'UNKNOWN',
|
61
|
-
name: params.screen,
|
62
|
-
params: params.params,
|
63
|
-
path: params.path,
|
64
|
-
},
|
65
|
-
],
|
66
|
-
}
|
67
|
-
}
|
53
|
+
const cachedNormalizedConfigs = new WeakMap<PathConfigMap<{}>, Record<string, ConfigItem>>()
|
68
54
|
|
69
|
-
|
70
|
-
return
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
)
|
76
|
-
}
|
55
|
+
const getNormalizedConfigs = (options?: Options<{}>) => {
|
56
|
+
if (!options?.screens) return {}
|
57
|
+
|
58
|
+
const cached = cachedNormalizedConfigs.get(options?.screens)
|
59
|
+
|
60
|
+
if (cached) return cached
|
77
61
|
|
78
|
-
|
79
|
-
|
62
|
+
const normalizedConfigs = createNormalizedConfigs(options.screens)
|
63
|
+
|
64
|
+
cachedNormalizedConfigs.set(options.screens, normalizedConfigs)
|
65
|
+
|
66
|
+
return normalizedConfigs
|
80
67
|
}
|
81
68
|
|
69
|
+
// @modified - start: extract an underlying `getPathDataFromState` function so we can get both the path and the params
|
82
70
|
/**
|
83
71
|
* Utility to serialize a navigation state object to a path string.
|
84
72
|
*
|
@@ -108,513 +96,273 @@ function encodeURIComponentPreservingBrackets(str: string) {
|
|
108
96
|
* @param options Extra options to fine-tune how to serialize the path.
|
109
97
|
* @returns Path representing the state, e.g. /foo/bar?count=42.
|
110
98
|
*/
|
111
|
-
export
|
99
|
+
export function getPathFromState<ParamList extends {}>(
|
112
100
|
state: State,
|
113
|
-
|
114
|
-
preserveGroups?: boolean
|
115
|
-
preserveDynamicRoutes?: boolean
|
116
|
-
}
|
101
|
+
options?: Options<ParamList>
|
117
102
|
): string {
|
118
|
-
return getPathDataFromState(state,
|
103
|
+
return getPathDataFromState(state, options).path
|
119
104
|
}
|
120
105
|
|
121
|
-
export function getPathDataFromState<ParamList extends
|
106
|
+
export function getPathDataFromState<ParamList extends {}>(
|
122
107
|
state: State,
|
123
|
-
|
124
|
-
preserveGroups?: boolean
|
125
|
-
preserveDynamicRoutes?: boolean
|
126
|
-
} = { screens: DEFAULT_SCREENS }
|
108
|
+
options?: Options<ParamList>
|
127
109
|
) {
|
110
|
+
// @modified - end
|
111
|
+
|
128
112
|
if (state == null) {
|
129
113
|
throw Error("Got 'undefined' for the navigation state. You must pass a valid state object.")
|
130
114
|
}
|
131
115
|
|
132
|
-
|
133
|
-
|
134
|
-
validatePathConfig(options)
|
135
|
-
|
136
|
-
// One disallows usage without a linking config.
|
137
|
-
if (Object.is(options.screens, DEFAULT_SCREENS)) {
|
138
|
-
throw Error("You must pass a 'screens' object to 'getPathFromState' to generate a path.")
|
116
|
+
if (options) {
|
117
|
+
validatePathConfig(options)
|
139
118
|
}
|
140
119
|
|
141
|
-
|
142
|
-
state,
|
143
|
-
// Create a normalized configs object which will be easier to use
|
144
|
-
createNormalizedConfigs(options.screens),
|
145
|
-
{ preserveGroups, preserveDynamicRoutes }
|
146
|
-
)
|
147
|
-
}
|
120
|
+
const configs = getNormalizedConfigs(options)
|
148
121
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
return Object.fromEntries(
|
153
|
-
Object.entries(params).map(([key, value]) => [
|
154
|
-
key,
|
155
|
-
// TODO: Strip nullish values here.
|
156
|
-
stringify?.[key]
|
157
|
-
? stringify[key](value)
|
158
|
-
: // Preserve rest params
|
159
|
-
Array.isArray(value)
|
160
|
-
? value
|
161
|
-
: String(value),
|
162
|
-
])
|
163
|
-
)
|
164
|
-
}
|
122
|
+
let path = '/'
|
123
|
+
let current: State | undefined = state
|
165
124
|
|
166
|
-
|
167
|
-
if (a === b) {
|
168
|
-
return true
|
169
|
-
}
|
125
|
+
const allParams: Record<string, any> = {}
|
170
126
|
|
171
|
-
|
172
|
-
|
173
|
-
|
127
|
+
while (current) {
|
128
|
+
let index = typeof current.index === 'number' ? current.index : 0
|
129
|
+
let route = current.routes[index] as Route<string> & {
|
130
|
+
state?: State
|
174
131
|
}
|
175
132
|
|
176
|
-
|
177
|
-
if (!deepEqual(a[i], b[i])) {
|
178
|
-
return false
|
179
|
-
}
|
180
|
-
}
|
133
|
+
let pattern: string | undefined
|
181
134
|
|
182
|
-
|
183
|
-
|
135
|
+
let focusedParams: Record<string, any> | undefined // @modified: value change to any type
|
136
|
+
const focusedRoute = getActiveRoute(state)
|
137
|
+
let currentOptions = configs
|
184
138
|
|
185
|
-
|
186
|
-
const
|
187
|
-
const keysB = Object.keys(b)
|
139
|
+
// Keep all the route names that appeared during going deeper in config in case the pattern is resolved to undefined
|
140
|
+
const nestedRouteNames: string[] = [] // @modified: add type annotation
|
188
141
|
|
189
|
-
|
190
|
-
return false
|
191
|
-
}
|
142
|
+
let hasNext = true
|
192
143
|
|
193
|
-
|
194
|
-
|
195
|
-
return false
|
196
|
-
}
|
197
|
-
}
|
144
|
+
while (route.name in currentOptions && hasNext) {
|
145
|
+
pattern = currentOptions[route.name].pattern
|
198
146
|
|
199
|
-
|
200
|
-
}
|
147
|
+
nestedRouteNames.push(route.name)
|
201
148
|
|
202
|
-
|
203
|
-
|
149
|
+
if (route.params) {
|
150
|
+
const stringify = currentOptions[route.name]?.stringify
|
204
151
|
|
205
|
-
|
206
|
-
route: CustomRoute,
|
207
|
-
focusedRoute: {
|
208
|
-
name: string
|
209
|
-
params?: object
|
210
|
-
},
|
211
|
-
configs: Record<string, ConfigItem>,
|
212
|
-
{
|
213
|
-
preserveDynamicRoutes,
|
214
|
-
}: {
|
215
|
-
preserveDynamicRoutes?: boolean
|
216
|
-
}
|
217
|
-
) {
|
218
|
-
// NOTE: Fill in current route using state that was passed as params.
|
219
|
-
if (!route.state && isInvalidParams(route.params)) {
|
220
|
-
// FIXME: This is a hack to make things work since the `route` object is immutable on react-navigation v7 (`TypeError: Cannot add property state, object is not extensible`), and seems that things are working. But we might want to do a proper migration for these forked code.
|
221
|
-
// route.state = createFakeState(route.params)
|
222
|
-
}
|
152
|
+
// @modified - start
|
223
153
|
|
224
|
-
|
225
|
-
|
226
|
-
|
154
|
+
// const currentParams = Object.fromEntries(
|
155
|
+
// Object.entries(route.params).map(([key, value]) => [
|
156
|
+
// key,
|
157
|
+
// stringify?.[key] ? stringify[key](value) : String(value),
|
158
|
+
// ])
|
159
|
+
// )
|
227
160
|
|
228
|
-
|
161
|
+
// Better handle array params
|
162
|
+
const currentParams = Object.fromEntries(
|
163
|
+
Object.entries(route.params!).flatMap(([key, value]) => {
|
164
|
+
if (key === 'screen' || key === 'params') {
|
165
|
+
return []
|
166
|
+
}
|
229
167
|
|
230
|
-
|
231
|
-
|
232
|
-
|
168
|
+
return [
|
169
|
+
[
|
170
|
+
key,
|
171
|
+
stringify?.[key]
|
172
|
+
? stringify[key](value)
|
173
|
+
: Array.isArray(value)
|
174
|
+
? value.map(String)
|
175
|
+
: String(value),
|
176
|
+
],
|
177
|
+
]
|
178
|
+
})
|
179
|
+
)
|
233
180
|
|
234
|
-
|
235
|
-
// This should never happen in One.
|
236
|
-
throw new Error('Unexpected: No pattern found for route ' + route.name)
|
237
|
-
}
|
238
|
-
pattern = inputPattern
|
181
|
+
// @modified - end
|
239
182
|
|
240
|
-
|
241
|
-
if (route.params['#']) {
|
242
|
-
hash = route.params['#']
|
243
|
-
delete route.params['#']
|
244
|
-
}
|
183
|
+
// @modified - start
|
245
184
|
|
246
|
-
|
185
|
+
// if (pattern) {
|
186
|
+
// Object.assign(allParams, currentParams)
|
187
|
+
// }
|
247
188
|
|
248
|
-
|
249
|
-
Object.assign(
|
250
|
-
}
|
189
|
+
// Always assign params, as non pattern routes may still have query params
|
190
|
+
Object.assign(allParams, currentParams)
|
251
191
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
} else {
|
192
|
+
// @modified - end
|
193
|
+
|
194
|
+
if (focusedRoute === route) {
|
256
195
|
// If this is the focused route, keep the params for later use
|
257
196
|
// We save it here since it's been stringified already
|
258
|
-
focusedParams =
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
197
|
+
focusedParams = { ...currentParams }
|
198
|
+
|
199
|
+
pattern
|
200
|
+
?.split('/')
|
201
|
+
.filter((p) => p.startsWith(':'))
|
202
|
+
// eslint-disable-next-line no-loop-func
|
203
|
+
.forEach((p) => {
|
204
|
+
const name = getParamName(p)
|
205
|
+
|
206
|
+
// Remove the params present in the pattern since we'll only use the rest for query string
|
207
|
+
if (focusedParams) {
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
209
|
+
delete focusedParams[name]
|
210
|
+
}
|
211
|
+
})
|
263
212
|
}
|
264
213
|
}
|
265
|
-
}
|
266
214
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
focusedParams = getParamsWithConventionsCollapsed({
|
289
|
-
params: focusedParams,
|
290
|
-
pattern,
|
291
|
-
routeName: route.name,
|
292
|
-
})
|
293
|
-
}
|
215
|
+
// If there is no `screens` property or no nested state, we return pattern
|
216
|
+
if (!currentOptions[route.name].screens || route.state === undefined) {
|
217
|
+
// @modified - start
|
218
|
+
|
219
|
+
// hasNext = false
|
220
|
+
|
221
|
+
// One can end up in some configs that React Navigation doesn't seem to support
|
222
|
+
// We can get around this by providing a fake state
|
223
|
+
const screens = currentOptions[route.name].screens
|
224
|
+
const screen =
|
225
|
+
route.params && 'screen' in route.params
|
226
|
+
? route.params.screen?.toString()
|
227
|
+
: screens
|
228
|
+
? Object.keys(screens)[0]
|
229
|
+
: undefined
|
230
|
+
|
231
|
+
if (screen && screens && currentOptions[route.name].screens?.[screen]) {
|
232
|
+
route = { ...screens[screen], name: screen, key: screen }
|
233
|
+
currentOptions = screens
|
234
|
+
} else {
|
235
|
+
hasNext = false
|
294
236
|
}
|
295
|
-
}
|
296
|
-
break
|
297
|
-
}
|
298
237
|
|
299
|
-
|
238
|
+
// @modified - end
|
239
|
+
} else {
|
240
|
+
index =
|
241
|
+
typeof route.state.index === 'number' ? route.state.index : route.state.routes.length - 1
|
300
242
|
|
301
|
-
|
302
|
-
|
243
|
+
const nextRoute = route.state.routes[index]
|
244
|
+
const nestedConfig = currentOptions[route.name].screens
|
303
245
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
246
|
+
// if there is config for next route name, we go deeper
|
247
|
+
if (nestedConfig && nextRoute.name in nestedConfig) {
|
248
|
+
route = nextRoute as Route<string> & { state?: State }
|
249
|
+
currentOptions = nestedConfig
|
250
|
+
} else {
|
251
|
+
// If not, there is no sense in going deeper in config
|
252
|
+
hasNext = false
|
253
|
+
}
|
254
|
+
}
|
311
255
|
}
|
312
|
-
}
|
313
256
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
257
|
+
// @modified - start
|
258
|
+
if (currentOptions[route.name] !== undefined) {
|
259
|
+
// path += pattern
|
260
|
+
// .split('/')
|
261
|
+
// .map((p) => {
|
262
|
+
// const name = getParamName(p)
|
263
|
+
|
264
|
+
// // We don't know what to show for wildcard patterns
|
265
|
+
// // Showing the route name seems ok, though whatever we show here will be incorrect
|
266
|
+
// // Since the page doesn't actually exist
|
267
|
+
// if (p === '*') {
|
268
|
+
// return route.name
|
269
|
+
// }
|
270
|
+
|
271
|
+
// // If the path has a pattern for a param, put the param in the path
|
272
|
+
// if (p.startsWith(':')) {
|
273
|
+
// const value = allParams[name]
|
274
|
+
|
275
|
+
// if (value === undefined && p.endsWith('?')) {
|
276
|
+
// // Optional params without value assigned in route.params should be ignored
|
277
|
+
// return ''
|
278
|
+
// }
|
279
|
+
|
280
|
+
// // Valid characters according to
|
281
|
+
// // https://datatracker.ietf.org/doc/html/rfc3986#section-3.3 (see pchar definition)
|
282
|
+
// return String(value).replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]/g, (char) =>
|
283
|
+
// encodeURIComponent(char)
|
284
|
+
// )
|
285
|
+
// }
|
286
|
+
|
287
|
+
// return encodeURIComponent(p)
|
288
|
+
// })
|
289
|
+
// .join('/')
|
290
|
+
|
291
|
+
if (pattern === undefined) {
|
292
|
+
pattern = nestedRouteNames.join('/')
|
293
|
+
}
|
319
294
|
|
320
|
-
|
321
|
-
|
322
|
-
focusedParams = focusedRoute.params
|
323
|
-
} else {
|
324
|
-
// If this is the focused route, keep the params for later use
|
325
|
-
// We save it here since it's been stringified already
|
326
|
-
focusedParams = getParamsWithConventionsCollapsed({
|
327
|
-
params: focusedRoute.params,
|
295
|
+
path += getPathWithConventionsCollapsed({
|
296
|
+
...options,
|
328
297
|
pattern,
|
329
|
-
|
298
|
+
route,
|
299
|
+
params: allParams,
|
300
|
+
initialRouteName: configs[route.name]?.initialRouteName,
|
330
301
|
})
|
331
|
-
}
|
332
|
-
focusedParams = {
|
333
|
-
...focusedParams,
|
334
|
-
...collectedParams,
|
335
|
-
}
|
336
|
-
}
|
337
|
-
|
338
|
-
return {
|
339
|
-
pattern,
|
340
|
-
nextRoute: route,
|
341
|
-
focusedParams,
|
342
|
-
hash,
|
343
|
-
params: collectedParams,
|
344
|
-
}
|
345
|
-
}
|
346
|
-
|
347
|
-
function getPathFromResolvedState(
|
348
|
-
state: State,
|
349
|
-
configs: Record<string, ConfigItem>,
|
350
|
-
{
|
351
|
-
preserveGroups,
|
352
|
-
preserveDynamicRoutes,
|
353
|
-
}: { preserveGroups?: boolean; preserveDynamicRoutes?: boolean }
|
354
|
-
) {
|
355
|
-
let path = ''
|
356
|
-
let current: State = state
|
357
|
-
let hash: string | undefined
|
358
|
-
|
359
|
-
const allParams: Record<string, any> = {}
|
360
|
-
|
361
|
-
while (current) {
|
362
|
-
path += '/'
|
363
|
-
|
364
|
-
// Make mutable copies to ensure we don't leak state outside of the function.
|
365
|
-
const route = current.routes[current.index ?? 0] as CustomRoute
|
366
302
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
// FIXME: This is a hack to make things work since the `route` object is immutable on react-navigation v7, and seems that things are working. But we might want to do a proper migration for these forked code.
|
371
|
-
// route.state = createFakeState(route.params)
|
303
|
+
// } else {
|
304
|
+
} else if (!route.name.startsWith('+')) {
|
305
|
+
path += encodeURIComponent(route.name)
|
372
306
|
}
|
307
|
+
// @modified - end
|
373
308
|
|
374
|
-
|
375
|
-
|
376
|
-
params,
|
377
|
-
nextRoute,
|
378
|
-
focusedParams,
|
379
|
-
hash: $hash,
|
380
|
-
} = walkConfigItems(route, getActiveRoute(current), { ...configs }, { preserveDynamicRoutes })
|
381
|
-
|
382
|
-
if ($hash) {
|
383
|
-
hash = $hash
|
309
|
+
if (!focusedParams) {
|
310
|
+
focusedParams = focusedRoute.params
|
384
311
|
}
|
385
312
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
preserveGroups,
|
394
|
-
preserveDynamicRoutes,
|
395
|
-
})
|
396
|
-
|
397
|
-
if (
|
398
|
-
nextRoute.state &&
|
399
|
-
// NOTE: The upstream implementation allows for sending in synthetic states (states that weren't generated by `getStateFromPath`)
|
400
|
-
// and any invalid routes will simply be ignored.
|
401
|
-
// Because of this, we need to check if the next route is valid before continuing, otherwise our more strict
|
402
|
-
// implementation will throw an error.
|
403
|
-
configs[nextRoute.state.routes?.[nextRoute.state?.index ?? 0]?.name]
|
404
|
-
) {
|
405
|
-
// Continue looping with the next state if available.
|
406
|
-
current = nextRoute.state
|
407
|
-
} else {
|
408
|
-
// Finished crawling state.
|
409
|
-
|
410
|
-
// Check for query params before exiting.
|
411
|
-
if (
|
412
|
-
focusedParams &&
|
413
|
-
// note: using [...route] is returning an array which shouldn't go on search, this is just
|
414
|
-
// an initial hacky test to work around this as we dont want to pass that to search
|
415
|
-
!Array.isArray(focusedParams)
|
416
|
-
) {
|
417
|
-
for (const param in focusedParams) {
|
418
|
-
// TODO: This is not good. We shouldn't squat strings named "undefined".
|
419
|
-
if (focusedParams[param] === 'undefined') {
|
420
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
421
|
-
delete focusedParams[param]
|
422
|
-
}
|
423
|
-
}
|
424
|
-
|
425
|
-
const query = new URLSearchParams(focusedParams).toString()
|
426
|
-
if (query) {
|
427
|
-
path += `?${query}`
|
313
|
+
if (route.state) {
|
314
|
+
path += '/'
|
315
|
+
} else if (focusedParams) {
|
316
|
+
for (const param in focusedParams) {
|
317
|
+
if (focusedParams[param] === 'undefined') {
|
318
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
319
|
+
delete focusedParams[param]
|
428
320
|
}
|
429
321
|
}
|
430
|
-
break
|
431
|
-
}
|
432
|
-
}
|
433
|
-
|
434
|
-
if (hash) {
|
435
|
-
allParams['#'] = hash
|
436
|
-
path += `#${hash}`
|
437
|
-
}
|
438
322
|
|
439
|
-
|
323
|
+
// @modified - start
|
324
|
+
delete focusedParams['#']
|
325
|
+
// @modified - end
|
440
326
|
|
441
|
-
|
442
|
-
}
|
443
|
-
|
444
|
-
|
445
|
-
const parsed: Record<string, any> = {}
|
327
|
+
// @modified - start
|
328
|
+
// const query = queryString.stringify(focusedParams, { sort: false })
|
329
|
+
const query = new URLSearchParams(focusedParams).toString()
|
330
|
+
// @modified - end
|
446
331
|
|
447
|
-
|
448
|
-
|
449
|
-
if (Array.isArray(value)) {
|
450
|
-
parsed[key] = value.map((v) => decodeURIComponent(v))
|
451
|
-
} else {
|
452
|
-
parsed[key] = decodeURIComponent(value)
|
332
|
+
if (query) {
|
333
|
+
path += `?${query}`
|
453
334
|
}
|
454
|
-
} catch {
|
455
|
-
parsed[key] = value
|
456
335
|
}
|
457
|
-
}
|
458
336
|
|
459
|
-
|
460
|
-
}
|
461
|
-
|
462
|
-
function getPathWithConventionsCollapsed({
|
463
|
-
pattern,
|
464
|
-
routePath,
|
465
|
-
params,
|
466
|
-
preserveGroups,
|
467
|
-
preserveDynamicRoutes,
|
468
|
-
initialRouteName,
|
469
|
-
}: {
|
470
|
-
pattern: string
|
471
|
-
routePath?: string
|
472
|
-
params: Record<string, any>
|
473
|
-
preserveGroups?: boolean
|
474
|
-
preserveDynamicRoutes?: boolean
|
475
|
-
initialRouteName?: string
|
476
|
-
}) {
|
477
|
-
const segments = pattern.split('/')
|
478
|
-
return segments
|
479
|
-
.map((p, i) => {
|
480
|
-
const name = getParamName(p)
|
481
|
-
|
482
|
-
// We don't know what to show for wildcard patterns
|
483
|
-
// Showing the route name seems ok, though whatever we show here will be incorrect
|
484
|
-
// Since the page doesn't actually exist
|
485
|
-
if (p.startsWith('*')) {
|
486
|
-
if (preserveDynamicRoutes) {
|
487
|
-
if (name === 'not-found') {
|
488
|
-
return '+not-found'
|
489
|
-
}
|
490
|
-
return `[...${name}]`
|
491
|
-
}
|
492
|
-
if (params[name]) {
|
493
|
-
if (Array.isArray(params[name])) {
|
494
|
-
return params[name].join('/')
|
495
|
-
}
|
496
|
-
return params[name]
|
497
|
-
}
|
498
|
-
if (i === 0) {
|
499
|
-
// This can occur when a wildcard matches all routes and the given path was `/`.
|
500
|
-
return routePath
|
501
|
-
}
|
502
|
-
// remove existing segments from route.path and return it
|
503
|
-
// this is used for nested wildcard routes. Without this, the path would add
|
504
|
-
// all nested segments to the beginning of the wildcard route.
|
505
|
-
return routePath
|
506
|
-
?.split('/')
|
507
|
-
.slice(i + 1)
|
508
|
-
.join('/')
|
509
|
-
}
|
510
|
-
|
511
|
-
// If the path has a pattern for a param, put the param in the path
|
512
|
-
if (p.startsWith(':')) {
|
513
|
-
if (preserveDynamicRoutes) {
|
514
|
-
return `[${name}]`
|
515
|
-
}
|
516
|
-
// Optional params without value assigned in route.params should be ignored
|
517
|
-
return params[name]
|
518
|
-
}
|
519
|
-
|
520
|
-
if (!preserveGroups && matchGroupName(p) != null) {
|
521
|
-
// When the last part is a group it could be a shared URL
|
522
|
-
// if the route has an initialRouteName defined, then we should
|
523
|
-
// use that as the component path as we can assume it will be shown.
|
524
|
-
if (segments.length - 1 === i) {
|
525
|
-
if (initialRouteName) {
|
526
|
-
// Return an empty string if the init route is ambiguous.
|
527
|
-
if (segmentMatchesConvention(initialRouteName)) {
|
528
|
-
return ''
|
529
|
-
}
|
530
|
-
return encodeURIComponentPreservingBrackets(initialRouteName)
|
531
|
-
}
|
532
|
-
}
|
533
|
-
return ''
|
534
|
-
}
|
535
|
-
// Preserve dynamic syntax for rehydration
|
536
|
-
return encodeURIComponentPreservingBrackets(p)
|
537
|
-
})
|
538
|
-
.map((v) => v ?? '')
|
539
|
-
.join('/')
|
540
|
-
}
|
541
|
-
|
542
|
-
/** Given a set of query params and a pattern with possible conventions, collapse the conventions and return the remaining params. */
|
543
|
-
function getParamsWithConventionsCollapsed({
|
544
|
-
pattern,
|
545
|
-
routeName,
|
546
|
-
params,
|
547
|
-
}: {
|
548
|
-
pattern: string
|
549
|
-
/** Route name is required for matching the wildcard route. This is specific to One. */
|
550
|
-
routeName: string
|
551
|
-
params: object
|
552
|
-
}): Record<string, string> {
|
553
|
-
const processedParams: Record<string, string> = { ...params }
|
554
|
-
|
555
|
-
// Remove the params present in the pattern since we'll only use the rest for query string
|
556
|
-
|
557
|
-
const segments = pattern.split('/')
|
558
|
-
|
559
|
-
// Dynamic Routes
|
560
|
-
segments
|
561
|
-
.filter((segment) => segment.startsWith(':'))
|
562
|
-
.forEach((segment) => {
|
563
|
-
const name = getParamName(segment)
|
564
|
-
delete processedParams[name]
|
565
|
-
})
|
566
|
-
|
567
|
-
// Deep Dynamic Routes
|
568
|
-
if (segments.some((segment) => segment.startsWith('*'))) {
|
569
|
-
// NOTE: Drop the param name matching the wildcard route name -- this is specific to One.
|
570
|
-
const name = testNotFound(routeName)
|
571
|
-
? 'not-found'
|
572
|
-
: (matchDeepDynamicRouteName(routeName) ?? routeName)
|
573
|
-
|
574
|
-
delete processedParams[name]
|
337
|
+
current = route.state
|
575
338
|
}
|
576
339
|
|
577
|
-
|
578
|
-
|
340
|
+
// Remove multiple as well as trailing slashes
|
341
|
+
path = path.replace(/\/+/g, '/')
|
342
|
+
path = path.length > 1 ? path.replace(/\/$/, '') : path
|
579
343
|
|
580
|
-
//
|
581
|
-
|
582
|
-
|
583
|
-
const simplifiedPath = path.replace(/\/+/g, '/')
|
584
|
-
if (simplifiedPath.length <= 1) {
|
585
|
-
return simplifiedPath
|
344
|
+
// Include the root path if specified
|
345
|
+
if (options?.path) {
|
346
|
+
path = joinPaths(options.path, path)
|
586
347
|
}
|
587
|
-
// Remove trailing slash like `foo/bar/` -> `foo/bar`
|
588
|
-
return simplifiedPath.replace(/\/$/, '')
|
589
|
-
}
|
590
348
|
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
screen: string
|
595
|
-
params: Record<string, any>
|
596
|
-
}
|
349
|
+
// @modified - start
|
350
|
+
path = appendBaseUrl(path)
|
351
|
+
// @modified - end
|
597
352
|
|
598
|
-
//
|
599
|
-
|
600
|
-
|
601
|
-
if (!params) {
|
602
|
-
return false
|
353
|
+
// @modified - start
|
354
|
+
if (allParams['#']) {
|
355
|
+
path += `#${allParams['#']}`
|
603
356
|
}
|
357
|
+
// @modified - end
|
604
358
|
|
605
|
-
|
606
|
-
|
607
|
-
}
|
608
|
-
|
609
|
-
return (
|
610
|
-
'initial' in params &&
|
611
|
-
typeof params.initial === 'boolean' &&
|
612
|
-
// "path" in params &&
|
613
|
-
'screen' in params
|
614
|
-
)
|
359
|
+
// @modified - start
|
360
|
+
// return path
|
361
|
+
return { path, params: allParams }
|
362
|
+
// @modified - end
|
615
363
|
}
|
616
364
|
|
617
|
-
const getParamName = (pattern: string) => pattern.replace(
|
365
|
+
const getParamName = (pattern: string) => pattern.replace(/^:/, '').replace(/\?$/, '')
|
618
366
|
|
619
367
|
const joinPaths = (...paths: string[]): string =>
|
620
368
|
([] as string[])
|
@@ -651,7 +399,6 @@ const createConfigItem = (
|
|
651
399
|
pattern: pattern?.split('/').filter(Boolean).join('/'),
|
652
400
|
stringify: config.stringify,
|
653
401
|
screens,
|
654
|
-
initialRouteName: config.initialRouteName,
|
655
402
|
}
|
656
403
|
}
|
657
404
|
|
@@ -660,17 +407,13 @@ const createNormalizedConfigs = (
|
|
660
407
|
pattern?: string
|
661
408
|
): Record<string, ConfigItem> =>
|
662
409
|
Object.fromEntries(
|
663
|
-
Object.entries(options).map(([name, c]) =>
|
410
|
+
Object.entries(options).map(([name, c]) => {
|
411
|
+
const result = createConfigItem(c, pattern)
|
412
|
+
|
413
|
+
return [name, result]
|
414
|
+
})
|
664
415
|
)
|
665
416
|
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
) {
|
670
|
-
if (process.env.NODE_ENV !== 'development') {
|
671
|
-
if (baseUrl) {
|
672
|
-
return `/${baseUrl.replace(/^\/+/, '').replace(/\/$/, '')}${path}`
|
673
|
-
}
|
674
|
-
}
|
675
|
-
return path
|
676
|
-
}
|
417
|
+
// @modified - start
|
418
|
+
export default getPathFromState
|
419
|
+
// @modified - end
|