one 1.1.298 → 1.1.299
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/vite/replaceLoader.js +7 -1
- package/dist/cjs/vite/replaceLoader.js.map +1 -1
- package/dist/cjs/vite/replaceLoader.native.js +7 -1
- package/dist/cjs/vite/replaceLoader.native.js.map +1 -1
- package/dist/esm/Root.native.js +110 -104
- package/dist/esm/Root.native.js.map +6 -1
- package/dist/esm/Route.native.js +12 -10
- package/dist/esm/Route.native.js.map +6 -1
- package/dist/esm/cleanUrl.native.js +12 -13
- package/dist/esm/cleanUrl.native.js.map +6 -1
- package/dist/esm/cli/label-process.native.js +5 -4
- package/dist/esm/cli/label-process.native.js.map +6 -1
- package/dist/esm/cli/main.native.js +8 -13
- package/dist/esm/cli/main.native.js.map +6 -1
- package/dist/esm/cli/prebuild.native.js +5 -5
- package/dist/esm/cli/prebuild.native.js.map +6 -1
- package/dist/esm/cli/run.native.js +21 -28
- package/dist/esm/cli/run.native.js.map +6 -1
- package/dist/esm/cli.native.js +119 -148
- package/dist/esm/cli.native.js.map +6 -1
- package/dist/esm/clientLoaderResolver.native.js +9 -6
- package/dist/esm/clientLoaderResolver.native.js.map +6 -1
- package/dist/esm/config.native.js +12 -11
- package/dist/esm/config.native.js.map +6 -1
- package/dist/esm/constants.native.js +7 -5
- package/dist/esm/constants.native.js.map +6 -1
- package/dist/esm/createApp.native.js +13 -9
- package/dist/esm/createApp.native.js.map +6 -1
- package/dist/esm/createHandleRequest.native.js +55 -64
- package/dist/esm/createHandleRequest.native.js.map +6 -1
- package/dist/esm/createRoute.native.js +16 -16
- package/dist/esm/createRoute.native.js.map +6 -1
- package/dist/esm/fallbackViews/Sitemap.native.js +6 -3
- package/dist/esm/fallbackViews/Sitemap.native.js.map +6 -1
- package/dist/esm/fallbackViews/Unmatched.native.js +5 -3
- package/dist/esm/fallbackViews/Unmatched.native.js.map +6 -1
- package/dist/esm/fork/NavigationContainer.native.js +24 -31
- package/dist/esm/fork/NavigationContainer.native.js.map +6 -1
- package/dist/esm/fork/createMemoryHistory.native.js +99 -115
- package/dist/esm/fork/createMemoryHistory.native.js.map +6 -1
- package/dist/esm/fork/extractPathFromURL.native.js +16 -15
- package/dist/esm/fork/extractPathFromURL.native.js.map +6 -1
- package/dist/esm/fork/findFocusedRoute.native.js +6 -5
- package/dist/esm/fork/findFocusedRoute.native.js.map +6 -1
- package/dist/esm/fork/getPathFromState.native.js +127 -140
- package/dist/esm/fork/getPathFromState.native.js.map +6 -1
- package/dist/esm/fork/getStateFromPath.native.js +292 -288
- package/dist/esm/fork/getStateFromPath.native.js.map +6 -1
- package/dist/esm/fork/useLinking.native.js +70 -61
- package/dist/esm/fork/useLinking.native.js.map +6 -1
- package/dist/esm/fork/validatePathConfig.native.js +15 -9
- package/dist/esm/fork/validatePathConfig.native.js.map +6 -1
- package/dist/esm/getLinkingConfig.native.js +11 -6
- package/dist/esm/getLinkingConfig.native.js.map +6 -1
- package/dist/esm/getReactNavigationConfig.native.js +28 -20
- package/dist/esm/getReactNavigationConfig.native.js.map +6 -1
- package/dist/esm/getRoutes.native.js +249 -229
- package/dist/esm/getRoutes.native.js.map +6 -1
- package/dist/esm/getURL.native.js +4 -4
- package/dist/esm/getURL.native.js.map +6 -1
- package/dist/esm/head/Head.android.js +5 -3
- package/dist/esm/head/Head.android.js.map +6 -1
- package/dist/esm/head/Head.ios.js +144 -132
- package/dist/esm/head/Head.ios.js.map +6 -1
- package/dist/esm/head/Head.native.js +7 -7
- package/dist/esm/head/Head.native.js.map +6 -1
- package/dist/esm/head/HeadModule.native.js +6 -6
- package/dist/esm/head/HeadModule.native.js.map +6 -1
- package/dist/esm/head/index.native.js +2 -2
- package/dist/esm/head/index.native.js.map +6 -1
- package/dist/esm/head/types.native.js +1 -2
- package/dist/esm/head/types.native.js.map +6 -1
- package/dist/esm/head/url.native.js +10 -8
- package/dist/esm/head/url.native.js.map +6 -1
- package/dist/esm/hooks.native.js +53 -34
- package/dist/esm/hooks.native.js.map +6 -1
- package/dist/esm/imperative-api.native.js +9 -6
- package/dist/esm/imperative-api.native.js.map +6 -1
- package/dist/esm/import-mode/index.android.js +4 -3
- package/dist/esm/import-mode/index.android.js.map +6 -1
- package/dist/esm/import-mode/index.ios.js +4 -3
- package/dist/esm/import-mode/index.ios.js.map +6 -1
- package/dist/esm/import-mode/index.native.js +3 -1
- package/dist/esm/import-mode/index.native.js.map +6 -1
- package/dist/esm/index.native.js +65 -27
- package/dist/esm/index.native.js.map +6 -1
- package/dist/esm/interfaces/router.native.js +4 -2
- package/dist/esm/interfaces/router.native.js.map +6 -1
- package/dist/esm/layouts/Drawer.native.js +7 -6
- package/dist/esm/layouts/Drawer.native.js.map +6 -1
- package/dist/esm/layouts/Stack.native.js +7 -6
- package/dist/esm/layouts/Stack.native.js.map +6 -1
- package/dist/esm/layouts/Tabs.native.js +42 -39
- package/dist/esm/layouts/Tabs.native.js.map +6 -1
- package/dist/esm/layouts/withLayoutContext.native.js +51 -48
- package/dist/esm/layouts/withLayoutContext.native.js.map +6 -1
- package/dist/esm/link/Link.native.js +62 -53
- package/dist/esm/link/Link.native.js.map +6 -1
- package/dist/esm/link/Redirect.native.js +8 -9
- package/dist/esm/link/Redirect.native.js.map +6 -1
- package/dist/esm/link/href.native.js +28 -27
- package/dist/esm/link/href.native.js.map +6 -1
- package/dist/esm/link/linking.native.js +51 -40
- package/dist/esm/link/linking.native.js.map +6 -1
- package/dist/esm/link/path.native.js +28 -19
- package/dist/esm/link/path.native.js.map +6 -1
- package/dist/esm/link/useLinkTo.native.js +22 -20
- package/dist/esm/link/useLinkTo.native.js.map +6 -1
- package/dist/esm/link/useLoadedNavigation.native.js +30 -23
- package/dist/esm/link/useLoadedNavigation.native.js.map +6 -1
- package/dist/esm/matchers.native.js +16 -3
- package/dist/esm/matchers.native.js.map +6 -1
- package/dist/esm/platform.native.js +4 -2
- package/dist/esm/platform.native.js.map +6 -1
- package/dist/esm/polyfills-mobile.native.js +4 -5
- package/dist/esm/polyfills-mobile.native.js.map +6 -1
- package/dist/esm/polyfills-server.native.js +1 -1
- package/dist/esm/polyfills-server.native.js.map +6 -1
- package/dist/esm/render.native.js +3 -1
- package/dist/esm/render.native.js.map +6 -1
- package/dist/esm/router/RouterStore.native.js +1 -2
- package/dist/esm/router/RouterStore.native.js.map +6 -1
- package/dist/esm/router/constants.native.js +4 -2
- package/dist/esm/router/constants.native.js.map +6 -1
- package/dist/esm/router/getNormalizedStatePath.native.js +18 -17
- package/dist/esm/router/getNormalizedStatePath.native.js.map +6 -1
- package/dist/esm/router/lastAction.native.js +10 -9
- package/dist/esm/router/lastAction.native.js.map +6 -1
- package/dist/esm/router/router.native.js +135 -114
- package/dist/esm/router/router.native.js.map +6 -1
- package/dist/esm/router/serverLocationContext.native.js +4 -2
- package/dist/esm/router/serverLocationContext.native.js.map +6 -1
- package/dist/esm/router/useInitializeOneRouter.native.js +8 -5
- package/dist/esm/router/useInitializeOneRouter.native.js.map +6 -1
- package/dist/esm/serve.native.js +77 -104
- package/dist/esm/serve.native.js.map +6 -1
- package/dist/esm/server/createRoutesManifest.native.js +14 -11
- package/dist/esm/server/createRoutesManifest.native.js.map +6 -1
- package/dist/esm/server/getServerManifest.native.js +61 -67
- package/dist/esm/server/getServerManifest.native.js.map +6 -1
- package/dist/esm/server-render.native.js +9 -10
- package/dist/esm/server-render.native.js.map +6 -1
- package/dist/esm/sortRoutes.native.js +27 -17
- package/dist/esm/sortRoutes.native.js.map +6 -1
- package/dist/esm/typed-routes/generateRouteTypes.native.js +10 -11
- package/dist/esm/typed-routes/generateRouteTypes.native.js.map +6 -1
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js +38 -37
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js.map +6 -1
- package/dist/esm/types.native.js +1 -2
- package/dist/esm/types.native.js.map +6 -1
- package/dist/esm/useFocusEffect.native.js +25 -22
- package/dist/esm/useFocusEffect.native.js.map +6 -1
- package/dist/esm/useLoader.native.js +50 -50
- package/dist/esm/useLoader.native.js.map +6 -1
- package/dist/esm/useNavigation.native.js +23 -19
- package/dist/esm/useNavigation.native.js.map +6 -1
- package/dist/esm/useScreens.native.js +143 -160
- package/dist/esm/useScreens.native.js.map +6 -1
- package/dist/esm/useViteRoutes.native.js +25 -28
- package/dist/esm/useViteRoutes.native.js.map +6 -1
- package/dist/esm/utils/assertIsReady.native.js +6 -3
- package/dist/esm/utils/assertIsReady.native.js.map +6 -1
- package/dist/esm/utils/dynamicImport.native.js +5 -3
- package/dist/esm/utils/dynamicImport.native.js.map +6 -1
- package/dist/esm/utils/existsAsync.native.js +6 -4
- package/dist/esm/utils/existsAsync.native.js.map +6 -1
- package/dist/esm/utils/getPageExport.native.js +12 -11
- package/dist/esm/utils/getPageExport.native.js.map +6 -1
- package/dist/esm/utils/globDir.native.js +5 -3
- package/dist/esm/utils/globDir.native.js.map +6 -1
- package/dist/esm/utils/hashString.native.js +4 -2
- package/dist/esm/utils/hashString.native.js.map +6 -1
- package/dist/esm/utils/isResponse.native.js +4 -2
- package/dist/esm/utils/isResponse.native.js.map +6 -1
- package/dist/esm/utils/isStatus.native.js +4 -2
- package/dist/esm/utils/isStatus.native.js.map +6 -1
- package/dist/esm/utils/promiseWithResolvers.native.js +7 -7
- package/dist/esm/utils/promiseWithResolvers.native.js.map +6 -1
- package/dist/esm/utils/rand.native.js +5 -3
- package/dist/esm/utils/rand.native.js.map +6 -1
- package/dist/esm/utils/redirect.native.js +7 -5
- package/dist/esm/utils/redirect.native.js.map +6 -1
- package/dist/esm/utils/removeSearch.native.js +4 -2
- package/dist/esm/utils/removeSearch.native.js.map +6 -1
- package/dist/esm/utils/removeUndefined.native.js +6 -3
- package/dist/esm/utils/removeUndefined.native.js.map +6 -1
- package/dist/esm/utils/requireResolve.native.js +4 -2
- package/dist/esm/utils/requireResolve.native.js.map +6 -1
- package/dist/esm/utils/url.native.js +6 -2
- package/dist/esm/utils/url.native.js.map +6 -1
- package/dist/esm/utils/weakKey.native.js +11 -10
- package/dist/esm/utils/weakKey.native.js.map +6 -1
- package/dist/esm/utils/weakMemo.native.js +8 -8
- package/dist/esm/utils/weakMemo.native.js.map +6 -1
- package/dist/esm/views/EmptyRoute.native.js +5 -3
- package/dist/esm/views/EmptyRoute.native.js.map +6 -1
- package/dist/esm/views/ErrorBoundary.native.js +5 -8
- package/dist/esm/views/ErrorBoundary.native.js.map +6 -1
- package/dist/esm/views/LoadProgressBar.native.js +58 -57
- package/dist/esm/views/LoadProgressBar.native.js.map +6 -1
- package/dist/esm/views/Navigator.native.js +54 -71
- package/dist/esm/views/Navigator.native.js.map +6 -1
- package/dist/esm/views/PreloadLinks.native.js +3 -1
- package/dist/esm/views/PreloadLinks.native.js.map +6 -1
- package/dist/esm/views/RootErrorBoundary.native.js +39 -29
- package/dist/esm/views/RootErrorBoundary.native.js.map +6 -1
- package/dist/esm/views/Screen.native.js +12 -12
- package/dist/esm/views/Screen.native.js.map +6 -1
- package/dist/esm/views/ScrollRestoration.native.js +27 -27
- package/dist/esm/views/ScrollRestoration.native.js.map +6 -1
- package/dist/esm/views/Try.native.js +40 -37
- package/dist/esm/views/Try.native.js.map +6 -1
- package/dist/esm/vite/build.native.js +260 -295
- package/dist/esm/vite/build.native.js.map +6 -1
- package/dist/esm/vite/clientTreeShakePlugin.native.js +34 -33
- package/dist/esm/vite/clientTreeShakePlugin.native.js.map +6 -1
- package/dist/esm/vite/constants.native.js +6 -4
- package/dist/esm/vite/constants.native.js.map +6 -1
- package/dist/esm/vite/createFileSystemRouter.native.js +99 -130
- package/dist/esm/vite/createFileSystemRouter.native.js.map +6 -1
- package/dist/esm/vite/customNodeExternals.native.js +9 -10
- package/dist/esm/vite/customNodeExternals.native.js.map +6 -1
- package/dist/esm/vite/ensureTsConfig.native.js +7 -5
- package/dist/esm/vite/ensureTsConfig.native.js.map +6 -1
- package/dist/esm/vite/findDepsToOptimize.native.js +27 -19
- package/dist/esm/vite/findDepsToOptimize.native.js.map +6 -1
- package/dist/esm/vite/fixDependenciesPlugin.native.js +5 -3
- package/dist/esm/vite/fixDependenciesPlugin.native.js.map +6 -1
- package/dist/esm/vite/generateTypesForRoutes.native.js +9 -9
- package/dist/esm/vite/generateTypesForRoutes.native.js.map +6 -1
- package/dist/esm/vite/getManifest.native.js +6 -4
- package/dist/esm/vite/getManifest.native.js.map +6 -1
- package/dist/esm/vite/headers.native.js +11 -5
- package/dist/esm/vite/headers.native.js.map +6 -1
- package/dist/esm/vite/loadEnv.native.js +7 -6
- package/dist/esm/vite/loadEnv.native.js.map +6 -1
- package/dist/esm/vite/makePluginWebOnly.native.js +9 -5
- package/dist/esm/vite/makePluginWebOnly.native.js.map +6 -1
- package/dist/esm/vite/one.native.js +142 -127
- package/dist/esm/vite/one.native.js.map +6 -1
- package/dist/esm/vite/removeReactNativeWebAnimatedPlugin.native.js +14 -11
- package/dist/esm/vite/removeReactNativeWebAnimatedPlugin.native.js.map +6 -1
- package/dist/esm/vite/replaceLoader.js +7 -1
- package/dist/esm/vite/replaceLoader.js.map +1 -1
- package/dist/esm/vite/replaceLoader.mjs +5 -1
- package/dist/esm/vite/replaceLoader.mjs.map +1 -1
- package/dist/esm/vite/replaceLoader.native.js +13 -10
- package/dist/esm/vite/replaceLoader.native.js.map +6 -1
- package/dist/esm/vite/resolveAPIRequest.native.js +44 -47
- package/dist/esm/vite/resolveAPIRequest.native.js.map +6 -1
- package/dist/esm/vite/server.native.js +5 -4
- package/dist/esm/vite/server.native.js.map +6 -1
- package/dist/esm/vite/types.native.js +1 -2
- package/dist/esm/vite/types.native.js.map +6 -1
- package/dist/esm/vite/virtualEntryPlugin.native.js +21 -16
- package/dist/esm/vite/virtualEntryPlugin.native.js.map +6 -1
- package/dist/esm/vite/vitePluginSsrCss.native.js +61 -50
- package/dist/esm/vite/vitePluginSsrCss.native.js.map +6 -1
- package/dist/esm/vite.native.js +19 -10
- package/dist/esm/vite.native.js.map +6 -1
- package/dist/esm/zero/getQueryKey.native.js +5 -3
- package/dist/esm/zero/getQueryKey.native.js.map +6 -1
- package/dist/esm/zero/isZeroQuery.native.js +4 -2
- package/dist/esm/zero/isZeroQuery.native.js.map +6 -1
- package/dist/esm/zero/resolveQuery.native.js +9 -8
- package/dist/esm/zero/resolveQuery.native.js.map +6 -1
- package/dist/esm/zero/subscribeToQuery.native.js +5 -3
- package/dist/esm/zero/subscribeToQuery.native.js.map +6 -1
- package/dist/esm/zero/types.native.js +1 -2
- package/dist/esm/zero/types.native.js.map +6 -1
- package/dist/esm/zero/useQuery.native.js +12 -12
- package/dist/esm/zero/useQuery.native.js.map +6 -1
- package/dist/esm/zero/useQueryZero.native.js +24 -20
- package/dist/esm/zero/useQueryZero.native.js.map +6 -1
- package/dist/esm/zero.native.js +9 -5
- package/dist/esm/zero.native.js.map +6 -1
- package/package.json +7 -7
- package/src/vite/replaceLoader.ts +7 -1
- package/types/vite/replaceLoader.d.ts.map +1 -1
@@ -1,38 +1,48 @@
|
|
1
|
-
import { matchGroupName } from "./matchers
|
1
|
+
import { matchGroupName } from "./matchers";
|
2
2
|
function sortDynamicConvention(a, b) {
|
3
3
|
return a.deep && !b.deep ? 1 : !a.deep && b.deep ? -1 : 0;
|
4
4
|
}
|
5
5
|
function sortRoutes(a, b) {
|
6
|
-
if (a.dynamic && !b.dynamic)
|
7
|
-
|
6
|
+
if (a.dynamic && !b.dynamic)
|
7
|
+
return 1;
|
8
|
+
if (!a.dynamic && b.dynamic)
|
9
|
+
return -1;
|
8
10
|
if (a.dynamic && b.dynamic) {
|
9
|
-
if (a.dynamic.length !== b.dynamic.length)
|
11
|
+
if (a.dynamic.length !== b.dynamic.length)
|
12
|
+
return b.dynamic.length - a.dynamic.length;
|
10
13
|
for (var i = 0; i < a.dynamic.length; i++) {
|
11
|
-
var aDynamic = a.dynamic[i],
|
12
|
-
bDynamic = b.dynamic[i];
|
14
|
+
var aDynamic = a.dynamic[i], bDynamic = b.dynamic[i];
|
13
15
|
if (aDynamic.notFound && bDynamic.notFound) {
|
14
16
|
var s = sortDynamicConvention(aDynamic, bDynamic);
|
15
|
-
if (s)
|
17
|
+
if (s)
|
18
|
+
return s;
|
16
19
|
}
|
17
|
-
if (aDynamic.notFound && !bDynamic.notFound)
|
18
|
-
|
20
|
+
if (aDynamic.notFound && !bDynamic.notFound)
|
21
|
+
return 1;
|
22
|
+
if (!aDynamic.notFound && bDynamic.notFound)
|
23
|
+
return -1;
|
19
24
|
var s1 = sortDynamicConvention(aDynamic, bDynamic);
|
20
|
-
if (s1)
|
25
|
+
if (s1)
|
26
|
+
return s1;
|
21
27
|
}
|
22
28
|
return 0;
|
23
29
|
}
|
24
|
-
var aIndex = a.route === "index" || matchGroupName(a.route) != null,
|
25
|
-
bIndex = b.route === "index" || matchGroupName(b.route) != null;
|
30
|
+
var aIndex = a.route === "index" || matchGroupName(a.route) != null, bIndex = b.route === "index" || matchGroupName(b.route) != null;
|
26
31
|
return aIndex && !bIndex ? -1 : !aIndex && bIndex ? 1 : a.route.length - b.route.length;
|
27
32
|
}
|
28
33
|
function sortRoutesWithInitial(initialRouteName) {
|
29
|
-
return function
|
34
|
+
return function(a, b) {
|
30
35
|
if (initialRouteName) {
|
31
|
-
if (a.route === initialRouteName)
|
32
|
-
|
36
|
+
if (a.route === initialRouteName)
|
37
|
+
return -1;
|
38
|
+
if (b.route === initialRouteName)
|
39
|
+
return 1;
|
33
40
|
}
|
34
41
|
return sortRoutes(a, b);
|
35
42
|
};
|
36
43
|
}
|
37
|
-
export {
|
38
|
-
|
44
|
+
export {
|
45
|
+
sortRoutes,
|
46
|
+
sortRoutesWithInitial
|
47
|
+
};
|
48
|
+
//# sourceMappingURL=sortRoutes.js.map
|
@@ -1 +1,6 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/Users/n8/one/packages/one/src/sortRoutes.ts"],
|
4
|
+
"mappings": "AACA,SAASA,sBAAsB;AAE/B,SAASC,sBAAsBC,GAAsBC,GAAoB;AACvE,SAAID,EAAEE,QAAQ,CAACD,EAAEC,OACR,IAEL,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["matchGroupName", "sortDynamicConvention", "a", "b", "deep", "sortRoutes", "dynamic", "length", "i", "aDynamic", "bDynamic", "notFound", "s", "aIndex", "route", "bIndex", "sortRoutesWithInitial", "initialRouteName"]
|
6
|
+
}
|
@@ -1,17 +1,16 @@
|
|
1
1
|
import FSExtra from "fs-extra";
|
2
2
|
import { writeFile } from "node:fs/promises";
|
3
3
|
import { dirname } from "node:path";
|
4
|
-
import { globbedRoutesToRouteContext } from "../useViteRoutes
|
5
|
-
import { globDir } from "../utils/globDir
|
6
|
-
import { getTypedRoutesDeclarationFile } from "./getTypedRoutesDeclarationFile
|
4
|
+
import { globbedRoutesToRouteContext } from "../useViteRoutes";
|
5
|
+
import { globDir } from "../utils/globDir";
|
6
|
+
import { getTypedRoutesDeclarationFile } from "./getTypedRoutesDeclarationFile";
|
7
7
|
async function generateRouteTypes(outFile) {
|
8
|
-
var routePaths = globDir("app"),
|
9
|
-
|
10
|
-
|
11
|
-
}, {}),
|
12
|
-
context = globbedRoutesToRouteContext(routes),
|
13
|
-
declarations = getTypedRoutesDeclarationFile(context);
|
8
|
+
var routePaths = globDir("app"), routes = routePaths.reduce(function(acc, cur) {
|
9
|
+
return acc[cur] = {}, acc;
|
10
|
+
}, {}), context = globbedRoutesToRouteContext(routes), declarations = getTypedRoutesDeclarationFile(context);
|
14
11
|
await FSExtra.ensureDir(dirname(outFile)), await writeFile(outFile, declarations);
|
15
12
|
}
|
16
|
-
export {
|
17
|
-
|
13
|
+
export {
|
14
|
+
generateRouteTypes
|
15
|
+
};
|
16
|
+
//# sourceMappingURL=generateRouteTypes.js.map
|
@@ -1 +1,6 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/typed-routes/Users/n8/one/packages/one/src/typed-routes/generateRouteTypes.ts"],
|
4
|
+
"mappings": "AAAA,OAAOA,aAAa;AACpB,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,mCAAmC;AAC5C,SAASC,eAAe;AACxB,SAASC,qCAAqC;AAE9C,eAAsBC,mBAAmBC,SAAe;AACtD,MAAMC,aAAaJ,QAAQ,KAAA,GACrBK,SAASD,WAAWE,OAAO,SAACC,KAAKC,KAAAA;AACrCD,eAAIC,GAAAA,IAAO,CAAC,GACLD;EACT,GAAG,CAAC,CAAA,GACEE,UAAUV,4BAA4BM,MAAAA,GACtCK,eAAeT,8BAA8BQ,OAAAA;AACnD,QAAMb,QAAQe,UAAUb,QAAQK,OAAAA,CAAAA,GAChC,MAAMN,UAAUM,SAASO,YAAAA;AAC3B;",
|
5
|
+
"names": ["FSExtra", "writeFile", "dirname", "globbedRoutesToRouteContext", "globDir", "getTypedRoutesDeclarationFile", "generateRouteTypes", "outFile", "routePaths", "routes", "reduce", "acc", "cur", "context", "declarations", "ensureDir"]
|
6
|
+
}
|
@@ -1,19 +1,21 @@
|
|
1
|
-
import { getRoutes } from "../getRoutes
|
2
|
-
import { isTypedRoute, removeSupportedExtensions } from "../matchers
|
3
|
-
var CATCH_ALL = /\[\.\.\..+?\]/g,
|
4
|
-
SLUG = /\[.+?\]/g;
|
1
|
+
import { getRoutes } from "../getRoutes";
|
2
|
+
import { isTypedRoute, removeSupportedExtensions } from "../matchers";
|
3
|
+
var CATCH_ALL = /\[\.\.\..+?\]/g, SLUG = /\[.+?\]/g;
|
5
4
|
function getTypedRoutesDeclarationFile(ctx) {
|
6
|
-
var staticRoutes = /* @__PURE__ */new Set(),
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
var staticRoutes = /* @__PURE__ */ new Set(), dynamicRoutes = /* @__PURE__ */ new Set(), dynamicRouteContextKeys = /* @__PURE__ */ new Set();
|
6
|
+
return walkRouteNode(
|
7
|
+
getRoutes(ctx, {
|
8
|
+
platformRoutes: !1,
|
9
|
+
// We don't need to generate platform specific routes
|
10
|
+
ignoreEntryPoints: !0,
|
11
|
+
ignoreRequireErrors: !0
|
12
|
+
}),
|
13
|
+
// importMode: 'async',
|
14
|
+
"",
|
15
|
+
staticRoutes,
|
16
|
+
dynamicRoutes,
|
17
|
+
dynamicRouteContextKeys
|
18
|
+
), `
|
17
19
|
import type { OneRouter } from 'one'
|
18
20
|
|
19
21
|
declare module 'one' {
|
@@ -31,9 +33,7 @@ declare module 'one' {
|
|
31
33
|
function walkRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, dynamicRouteContextKeys) {
|
32
34
|
if (routeNode) {
|
33
35
|
addRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, dynamicRouteContextKeys), parentRoutePath = `${removeSupportedExtensions(`${parentRoutePath}/${routeNode.route}`).replace(/\/?index$/, "")}`;
|
34
|
-
var _iteratorNormalCompletion = !0,
|
35
|
-
_didIteratorError = !1,
|
36
|
-
_iteratorError = void 0;
|
36
|
+
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
37
37
|
try {
|
38
38
|
for (var _iterator = routeNode.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
39
39
|
var child = _step.value;
|
@@ -45,7 +45,8 @@ function walkRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes,
|
|
45
45
|
try {
|
46
46
|
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
47
47
|
} finally {
|
48
|
-
if (_didIteratorError)
|
48
|
+
if (_didIteratorError)
|
49
|
+
throw _iteratorError;
|
49
50
|
}
|
50
51
|
}
|
51
52
|
}
|
@@ -54,9 +55,7 @@ function addRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, d
|
|
54
55
|
if (routeNode?.route && isTypedRoute(routeNode.route)) {
|
55
56
|
var routePath = `${parentRoutePath}/${removeSupportedExtensions(routeNode.route).replace(/\/?index$/, "")}`;
|
56
57
|
if (routePath.startsWith("/") || (routePath = `/${routePath}`), routeNode.dynamic) {
|
57
|
-
var _iteratorNormalCompletion = !0,
|
58
|
-
_didIteratorError = !1,
|
59
|
-
_iteratorError = void 0;
|
58
|
+
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
60
59
|
try {
|
61
60
|
for (var _iterator = generateCombinations(routePath)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
62
61
|
var path = _step.value;
|
@@ -68,13 +67,12 @@ function addRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, d
|
|
68
67
|
try {
|
69
68
|
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
70
69
|
} finally {
|
71
|
-
if (_didIteratorError)
|
70
|
+
if (_didIteratorError)
|
71
|
+
throw _iteratorError;
|
72
72
|
}
|
73
73
|
}
|
74
74
|
} else {
|
75
|
-
var _iteratorNormalCompletion1 = !0,
|
76
|
-
_didIteratorError1 = !1,
|
77
|
-
_iteratorError1 = void 0;
|
75
|
+
var _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
|
78
76
|
try {
|
79
77
|
for (var _iterator1 = generateCombinations(routePath)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|
80
78
|
var combination = _step1.value;
|
@@ -86,32 +84,35 @@ function addRouteNode(routeNode, parentRoutePath, staticRoutes, dynamicRoutes, d
|
|
86
84
|
try {
|
87
85
|
!_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
|
88
86
|
} finally {
|
89
|
-
if (_didIteratorError1)
|
87
|
+
if (_didIteratorError1)
|
88
|
+
throw _iteratorError1;
|
90
89
|
}
|
91
90
|
}
|
92
91
|
}
|
93
92
|
}
|
94
93
|
}
|
95
|
-
var setToUnionType = function
|
96
|
-
return set.size > 0 ? [
|
94
|
+
var setToUnionType = function(set) {
|
95
|
+
return set.size > 0 ? [
|
96
|
+
...set
|
97
|
+
].sort().map(function(s) {
|
97
98
|
return `\`${s}\``;
|
98
99
|
}).join(" | ") : "never";
|
99
100
|
};
|
100
101
|
function generateCombinations(pathname) {
|
101
|
-
var groups = pathname.split("/").filter(function
|
102
|
-
|
103
|
-
|
104
|
-
combinations = [];
|
102
|
+
var groups = pathname.split("/").filter(function(part) {
|
103
|
+
return part.startsWith("(") && part.endsWith(")");
|
104
|
+
}), combinations = [];
|
105
105
|
function generate(currentIndex, currentPath) {
|
106
106
|
if (currentIndex === groups.length) {
|
107
107
|
combinations.push(currentPath.replace(/\/{2,}/g, "/"));
|
108
108
|
return;
|
109
109
|
}
|
110
|
-
var group = groups[currentIndex],
|
111
|
-
withoutGroup = currentPath.replace(`/${group}`, "");
|
110
|
+
var group = groups[currentIndex], withoutGroup = currentPath.replace(`/${group}`, "");
|
112
111
|
generate(currentIndex + 1, withoutGroup), generate(currentIndex + 1, currentPath);
|
113
112
|
}
|
114
113
|
return generate(0, pathname), combinations;
|
115
114
|
}
|
116
|
-
export {
|
117
|
-
|
115
|
+
export {
|
116
|
+
getTypedRoutesDeclarationFile
|
117
|
+
};
|
118
|
+
//# sourceMappingURL=getTypedRoutesDeclarationFile.js.map
|
@@ -1 +1,6 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/typed-routes/Users/n8/one/packages/one/src/typed-routes/getTypedRoutesDeclarationFile.ts"],
|
4
|
+
"mappings": "AAAA,SAASA,iBAAiB;AAC1B,SAASC,cAAcC,iCAAiC;AAKxD,IAAMC,YAAY,kBAEZC,OAAO;AAEN,SAASC,8BAA8BC,KAAqB;AACjE,MAAMC,eAAe,oBAAIC,IAAAA,GACnBC,gBAAgB,oBAAID,IAAAA,GACpBE,0BAA0B,oBAAIF,IAAAA;AAEpCG;IACEX,UAAUM,KAAK;MACbM,gBAAgB;;MAChBC,mBAAmB;MACnBC,qBAAqB;IAEvB,CAAA;;IACA;IACAP;IACAE;IACAC;EAAA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
|
+
"names": ["getRoutes", "isTypedRoute", "removeSupportedExtensions", "CATCH_ALL", "SLUG", "getTypedRoutesDeclarationFile", "ctx", "staticRoutes", "Set", "dynamicRoutes", "dynamicRouteContextKeys", "walkRouteNode", "platformRoutes", "ignoreEntryPoints", "ignoreRequireErrors", "setToUnionType", "trim", "routeNode", "parentRoutePath", "addRouteNode", "route", "replace", "children", "child", "routePath", "startsWith", "dynamic", "generateCombinations", "path", "add", "replaceAll", "combination", "set", "size", "sort", "map", "s", "join", "pathname", "groups", "split", "filter", "part", "endsWith", "combinations", "generate", "currentIndex", "currentPath", "length", "push", "group", "withoutGroup"]
|
6
|
+
}
|
package/dist/esm/types.native.js
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
//# sourceMappingURL=types.native.js.map
|
1
|
+
//# sourceMappingURL=types.js.map
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import { useOptionalNavigation } from "./link/useLoadedNavigation
|
2
|
+
import { useOptionalNavigation } from "./link/useLoadedNavigation";
|
3
3
|
function useFocusEffect(effect, do_not_pass_a_second_prop) {
|
4
4
|
var navigation = useOptionalNavigation();
|
5
5
|
if (do_not_pass_a_second_prop !== void 0) {
|
@@ -14,16 +14,15 @@ useFocusEffect(
|
|
14
14
|
See usage guide: https://reactnavigation.org/docs/use-focus-effect`;
|
15
15
|
console.error(message);
|
16
16
|
}
|
17
|
-
React.useEffect(function
|
17
|
+
React.useEffect(function() {
|
18
18
|
if (navigation) {
|
19
|
-
var isFocused = !1,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
destroy === null ? message2 += " You returned 'null'. If your effect does not require clean-up, return 'undefined' (or nothing)." : typeof destroy.then == "function" ? message2 += `
|
19
|
+
var isFocused = !1, cleanup, callback = function() {
|
20
|
+
var destroy = effect();
|
21
|
+
if (destroy === void 0 || typeof destroy == "function")
|
22
|
+
return destroy;
|
23
|
+
if (process.env.NODE_ENV !== "production") {
|
24
|
+
var message2 = "An effect function must not return anything besides a function, which is used for clean-up.";
|
25
|
+
destroy === null ? message2 += " You returned 'null'. If your effect does not require clean-up, return 'undefined' (or nothing)." : typeof destroy.then == "function" ? message2 += `
|
27
26
|
|
28
27
|
It looks like you wrote 'useFocusEffect(async () => ...)' or returned a Promise. Instead, write the async function inside your effect and call it immediately:
|
29
28
|
|
@@ -40,20 +39,24 @@ useFocusEffect(
|
|
40
39
|
);
|
41
40
|
|
42
41
|
See usage guide: https://reactnavigation.org/docs/use-focus-effect` : message2 += ` You returned '${JSON.stringify(destroy)}'.`, console.error(message2);
|
43
|
-
|
44
|
-
|
42
|
+
}
|
43
|
+
};
|
45
44
|
navigation.isFocused() && (cleanup = callback(), isFocused = !0);
|
46
|
-
var unsubscribeFocus = navigation.addListener("focus", function
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
return function () {
|
45
|
+
var unsubscribeFocus = navigation.addListener("focus", function() {
|
46
|
+
isFocused || (cleanup !== void 0 && cleanup(), cleanup = callback(), isFocused = !0);
|
47
|
+
}), unsubscribeBlur = navigation.addListener("blur", function() {
|
48
|
+
cleanup !== void 0 && cleanup(), cleanup = void 0, isFocused = !1;
|
49
|
+
});
|
50
|
+
return function() {
|
53
51
|
cleanup !== void 0 && cleanup(), unsubscribeFocus(), unsubscribeBlur();
|
54
52
|
};
|
55
53
|
}
|
56
|
-
}, [
|
54
|
+
}, [
|
55
|
+
effect,
|
56
|
+
navigation
|
57
|
+
]);
|
57
58
|
}
|
58
|
-
export {
|
59
|
-
|
59
|
+
export {
|
60
|
+
useFocusEffect
|
61
|
+
};
|
62
|
+
//# sourceMappingURL=useFocusEffect.js.map
|
@@ -1 +1,6 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/Users/n8/one/packages/one/src/useFocusEffect.ts"],
|
4
|
+
"mappings": "AAEA,YAAYA,WAAW;AAEvB,SAASC,6BAA6B;AAW/B,SAASC,eAAeC,QAAwBC,2BAAiC;AACtF,MAAMC,aAAaJ,sBAAAA;AAEnB,MAAIG,8BAA8BE,QAAW;AAC3C,QAAMC,UACJ;;;;;;;;;AASFC,YAAQC,MAAMF,OAAAA;EAChB;AAEAP,QAAMU,UAAU,WAAA;AACd,QAAKL,YAIL;UAAIM,YAAY,IACZC,SAEEC,WAAW,WAAA;AACf,YAAMC,UAAUX,OAAAA;AAEhB,YAAIW,YAAYR,UAAa,OAAOQ,WAAY;AAC9C,iBAAOA;AAGT,YAAIC,QAAQC,IAAIC,aAAa,cAAc;AACzC,cAAIV,WACF;AAEF,UAAIO,YAAY,OACdP,YACE,qGACO,OAAQO,QAAgBI,QAAS,aAC1CX,YACE;;;;;;;;;;;;;;;;sEAeFA,YAAW,kBAAkBY,KAAKC,UAAUN,OAAAA,CAAAA,MAG9CN,QAAQC,MAAMF,QAAAA;QAChB;MACF;AAGA,MAAIF,WAAWM,UAAS,MACtBC,UAAUC,SAAAA,GACVF,YAAY;AAGd,UAAMU,mBAAmBhB,WAAWiB,YAAY,SAAS,WAAA;AAGvD,QAAIX,cAIAC,YAAYN,UACdM,QAAAA,GAGFA,UAAUC,SAAAA,GACVF,YAAY;MACd,CAAA,GAEMY,kBAAkBlB,WAAWiB,YAAY,QAAQ,WAAA;AACrD,QAAIV,YAAYN,UACdM,QAAAA,GAGFA,UAAUN,QACVK,YAAY;MACd,CAAA;AAEA,aAAO,WAAA;AACL,QAAIC,YAAYN,UACdM,QAAAA,GAGFS,iBAAAA,GACAE,gBAAAA;MACF;;EACF,GAAG;IAACpB;IAAQE;GAAW;AACzB;",
|
5
|
+
"names": ["React", "useOptionalNavigation", "useFocusEffect", "effect", "do_not_pass_a_second_prop", "navigation", "undefined", "message", "console", "error", "useEffect", "isFocused", "cleanup", "callback", "destroy", "process", "env", "NODE_ENV", "then", "JSON", "stringify", "unsubscribeFocus", "addListener", "unsubscribeBlur"]
|
6
|
+
}
|
@@ -1,62 +1,60 @@
|
|
1
1
|
import { useEffect, useRef } from "react";
|
2
|
-
import { useActiveParams, useParams } from "./hooks
|
3
|
-
import { resolveHref } from "./link/href
|
4
|
-
import { useRouteNode } from "./Route
|
5
|
-
import { preloadingLoader } from "./router/router
|
6
|
-
import { dynamicImport } from "./utils/dynamicImport
|
7
|
-
import { weakKey } from "./utils/weakKey
|
8
|
-
import { getLoaderPath } from "./cleanUrl
|
9
|
-
var promises = {},
|
10
|
-
errors = {},
|
11
|
-
loadedData = {};
|
2
|
+
import { useActiveParams, useParams } from "./hooks";
|
3
|
+
import { resolveHref } from "./link/href";
|
4
|
+
import { useRouteNode } from "./Route";
|
5
|
+
import { preloadingLoader } from "./router/router";
|
6
|
+
import { dynamicImport } from "./utils/dynamicImport";
|
7
|
+
import { weakKey } from "./utils/weakKey";
|
8
|
+
import { getLoaderPath } from "./cleanUrl";
|
9
|
+
var promises = {}, errors = {}, loadedData = {};
|
12
10
|
function useLoader(loader) {
|
13
|
-
var _window_location,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
var isNative = !0,
|
19
|
-
routeNode
|
20
|
-
params
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
35
|
-
[preloadedData]), errors[currentPath]) throw errors[currentPath];
|
11
|
+
var _window_location, preloadedProps = globalThis.__vxrnLoaderProps__;
|
12
|
+
if (typeof window > "u")
|
13
|
+
return useAsyncFn(loader, preloadedProps || {
|
14
|
+
params: useActiveParams()
|
15
|
+
});
|
16
|
+
var isNative = !0, routeNode = useRouteNode(), params = useParams(), pathName = "/" + resolveHref({
|
17
|
+
pathname: routeNode?.route || "",
|
18
|
+
params
|
19
|
+
}).replace(/index$/, ""), currentPath = (isNative ? null : globalThis.__vxrntodopath) || // @zetavg: not sure why we're using `globalThis['__vxrntodopath']` here, but this breaks native when switching between tabs where the value stays with the previous path, so ignoring this on native
|
20
|
+
// TODO likely either not needed or needs proper path from server side
|
21
|
+
(typeof window < "u" ? ((_window_location = window.location) === null || _window_location === void 0 ? void 0 : _window_location.pathname) || pathName : "/"), preloadedData = preloadedProps?.path === currentPath ? globalThis.__vxrnLoaderData__ : void 0, currentData = useRef(preloadedData);
|
22
|
+
if (useEffect(
|
23
|
+
function() {
|
24
|
+
preloadedData && (loadedData[currentPath] = preloadedData, delete globalThis.__vxrnLoaderData__);
|
25
|
+
},
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
27
|
+
[
|
28
|
+
preloadedData
|
29
|
+
]
|
30
|
+
), errors[currentPath])
|
31
|
+
throw errors[currentPath];
|
36
32
|
var loaded = loadedData[currentPath];
|
37
|
-
if (typeof loaded < "u")
|
33
|
+
if (typeof loaded < "u")
|
34
|
+
return loaded;
|
38
35
|
if (!preloadedData) {
|
39
|
-
if (preloadingLoader[currentPath] && (typeof preloadingLoader[currentPath] == "function" && (preloadingLoader[currentPath] = preloadingLoader[currentPath]()), promises[currentPath] = preloadingLoader[currentPath].then(function
|
36
|
+
if (preloadingLoader[currentPath] && (typeof preloadingLoader[currentPath] == "function" && (preloadingLoader[currentPath] = preloadingLoader[currentPath]()), promises[currentPath] = preloadingLoader[currentPath].then(function(val) {
|
40
37
|
loadedData[currentPath] = val;
|
41
|
-
}).catch(function
|
38
|
+
}).catch(function(err) {
|
42
39
|
console.error("Error loading loader", err), errors[currentPath] = err, delete promises[currentPath], delete preloadingLoader[currentPath];
|
43
40
|
})), !promises[currentPath]) {
|
44
|
-
var getData = async function
|
41
|
+
var getData = async function() {
|
45
42
|
var loaderJSUrl = getLoaderPath(currentPath, !0);
|
46
43
|
try {
|
47
|
-
var response = await async function
|
44
|
+
var response = await async function() {
|
48
45
|
if (isNative) {
|
49
46
|
var nativeLoaderJSUrl = `${loaderJSUrl}&platform=ios`;
|
50
47
|
try {
|
51
48
|
var loaderJsCodeResp = await fetch(nativeLoaderJSUrl);
|
52
|
-
if (!loaderJsCodeResp.ok)
|
53
|
-
|
54
|
-
|
55
|
-
if (typeof result.loader != "function")
|
49
|
+
if (!loaderJsCodeResp.ok)
|
50
|
+
throw new Error(`Response not ok: ${loaderJsCodeResp.status}`);
|
51
|
+
var loaderJsCode = await loaderJsCodeResp.text(), result = eval(`() => { var exports = {}; ${loaderJsCode}; return exports; }`)();
|
52
|
+
if (typeof result.loader != "function")
|
53
|
+
throw new Error("Loader code isn't exporting a `loader` function");
|
56
54
|
return result;
|
57
55
|
} catch (e) {
|
58
56
|
return console.error(`Error fetching loader from URL: ${nativeLoaderJSUrl}, ${e}`), {
|
59
|
-
loader: function
|
57
|
+
loader: function() {
|
60
58
|
return {};
|
61
59
|
}
|
62
60
|
};
|
@@ -75,22 +73,24 @@ function useLoader(loader) {
|
|
75
73
|
}
|
76
74
|
return currentData.current;
|
77
75
|
}
|
78
|
-
var results = /* @__PURE__ */new Map(),
|
79
|
-
started = /* @__PURE__ */new Map();
|
76
|
+
var results = /* @__PURE__ */ new Map(), started = /* @__PURE__ */ new Map();
|
80
77
|
function useAsyncFn(val, props) {
|
81
78
|
var key = (val ? weakKey(val) : "") + JSON.stringify(props);
|
82
79
|
if (val && !started.get(key)) {
|
83
80
|
started.set(key, !0);
|
84
81
|
var next = val(props);
|
85
|
-
next instanceof Promise && (next = next.then(function
|
82
|
+
next instanceof Promise && (next = next.then(function(final) {
|
86
83
|
results.set(key, final);
|
87
|
-
}).catch(function
|
84
|
+
}).catch(function(err) {
|
88
85
|
console.error("Error running loader()", err), results.set(key, void 0);
|
89
86
|
})), results.set(key, next);
|
90
87
|
}
|
91
88
|
var current = results.get(key);
|
92
|
-
if (current instanceof Promise)
|
89
|
+
if (current instanceof Promise)
|
90
|
+
throw current;
|
93
91
|
return current;
|
94
92
|
}
|
95
|
-
export {
|
96
|
-
|
93
|
+
export {
|
94
|
+
useLoader
|
95
|
+
};
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C,yBAAQC,MAAM,yBAAyBF,GAAAA,EAAK,GAC5C1B,OAAOgB,WAAAA,IAAeU,KACtB,OAAO3B,SAASiB,WAAAA,GACT;QACT;MACF;AACAjB,eAASiB,WAAAA,IAAea,QAAAA;IAC1B;AAEA,UAAM9B,SAASiB,WAAAA;EACjB;AAEA,SAAOK,YAAYsB;AACrB;AAEA,IAAMC,UAAU,oBAAIC,IAAAA,GACdC,UAAU,oBAAID,IAAAA;AAEpB,SAAStC,WAAWiB,KAAUuB,OAAW;AACvC,MAAMC,OAAOxB,MAAM3B,QAAQ2B,GAAAA,IAAO,MAAMyB,KAAKC,UAAUH,KAAAA;AAEvD,MAAIvB,OACE,CAACsB,QAAQK,IAAIH,GAAAA,GAAM;AACrBF,YAAQM,IAAIJ,KAAK,EAAA;AAEjB,QAAIK,OAAO7B,IAAIuB,KAAAA;AACf,IAAIM,gBAAgBC,YAClBD,OAAOA,KACJ9B,KAAK,SAACgC,OAAAA;AACLX,cAAQQ,IAAIJ,KAAKO,KAAAA;IACnB,CAAA,EACC9B,MAAM,SAACC,KAAAA;AACNC,cAAQC,MAAM,0BAA0BF,GAAAA,GACxCkB,QAAQQ,IAAIJ,KAAK5B,MAAAA;IACnB,CAAA,IAEJwB,QAAQQ,IAAIJ,KAAKK,IAAAA;EACnB;AAGF,MAAMV,UAAUC,QAAQO,IAAIH,GAAAA;AAE5B,MAAIL,mBAAmBW;AACrB,UAAMX;AAGR,SAAOA;AACT;",
|
5
|
+
"names": ["useEffect", "useRef", "useActiveParams", "useParams", "resolveHref", "useRouteNode", "preloadingLoader", "dynamicImport", "weakKey", "getLoaderPath", "promises", "errors", "loadedData", "useLoader", "loader", "window", "preloadedProps", "globalThis", "useAsyncFn", "params", "isNative", "process", "routeNode", "pathName", "pathname", "route", "replace", "currentPath", "location", "preloadedData", "path", "undefined", "currentData", "loaded", "then", "val", "catch", "err", "console", "error", "getData", "loaderJSUrl", "response", "nativeLoaderJSUrl", "loaderJsCodeResp", "fetch", "ok", "Error", "status", "loaderJsCode", "text", "result", "eval", "e", "current", "results", "Map", "started", "props", "key", "JSON", "stringify", "get", "set", "next", "Promise", "final"]
|
6
|
+
}
|
@@ -1,18 +1,21 @@
|
|
1
1
|
import { useNavigation as useUpstreamNavigation } from "@react-navigation/native";
|
2
2
|
import React from "react";
|
3
|
-
import { getNameFromFilePath } from "./matchers
|
4
|
-
import { useContextKey } from "./Route
|
3
|
+
import { getNameFromFilePath } from "./matchers";
|
4
|
+
import { useContextKey } from "./Route";
|
5
5
|
function useNavigation(parent) {
|
6
|
-
var navigation = useUpstreamNavigation(),
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
var navigation = useUpstreamNavigation(), contextKey = useContextKey(), normalizedParent = React.useMemo(function() {
|
7
|
+
if (!parent)
|
8
|
+
return null;
|
9
|
+
var normalized = getNameFromFilePath(parent);
|
10
|
+
return parent.startsWith(".") ? relativePaths(contextKey, parent) : normalized;
|
11
|
+
}, [
|
12
|
+
contextKey,
|
13
|
+
parent
|
14
|
+
]);
|
13
15
|
if (normalizedParent != null) {
|
14
16
|
var parentNavigation = navigation.getParent(normalizedParent);
|
15
|
-
if (!parentNavigation)
|
17
|
+
if (!parentNavigation)
|
18
|
+
throw new Error(`Could not find parent navigation with route "${parent}".` + (normalizedParent !== parent ? ` (normalized: ${normalizedParent})` : ""));
|
16
19
|
return parentNavigation;
|
17
20
|
}
|
18
21
|
return navigation;
|
@@ -21,16 +24,13 @@ function resolveParentId(contextKey, parentId) {
|
|
21
24
|
return parentId ? parentId.startsWith(".") ? getNameFromFilePath(relativePaths(contextKey, parentId)) : getNameFromFilePath(parentId) : null;
|
22
25
|
}
|
23
26
|
function relativePaths(from, to) {
|
24
|
-
var fromParts = from.split("/").filter(Boolean),
|
25
|
-
toParts = to.split("/").filter(Boolean),
|
26
|
-
_iteratorNormalCompletion = !0,
|
27
|
-
_didIteratorError = !1,
|
28
|
-
_iteratorError = void 0;
|
27
|
+
var fromParts = from.split("/").filter(Boolean), toParts = to.split("/").filter(Boolean), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
29
28
|
try {
|
30
29
|
for (var _iterator = toParts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
31
30
|
var part = _step.value;
|
32
31
|
if (part === "..") {
|
33
|
-
if (fromParts.length === 0)
|
32
|
+
if (fromParts.length === 0)
|
33
|
+
throw new Error(`Cannot resolve path "${to}" relative to "${from}"`);
|
34
34
|
fromParts.pop();
|
35
35
|
} else part === "." || fromParts.push(part);
|
36
36
|
}
|
@@ -40,10 +40,14 @@ function relativePaths(from, to) {
|
|
40
40
|
try {
|
41
41
|
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
42
42
|
} finally {
|
43
|
-
if (_didIteratorError)
|
43
|
+
if (_didIteratorError)
|
44
|
+
throw _iteratorError;
|
44
45
|
}
|
45
46
|
}
|
46
47
|
return "/" + fromParts.join("/");
|
47
48
|
}
|
48
|
-
export {
|
49
|
-
|
49
|
+
export {
|
50
|
+
resolveParentId,
|
51
|
+
useNavigation
|
52
|
+
};
|
53
|
+
//# sourceMappingURL=useNavigation.js.map
|
@@ -1 +1,6 @@
|
|
1
|
-
{
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/Users/n8/one/packages/one/src/useNavigation.ts"],
|
4
|
+
"mappings": "AAAA,SAEEA,iBAAiBC,6BACZ;AACP,OAAOC,WAAW;AAElB,SAASC,2BAA2B;AACpC,SAASC,qBAAqB;AAOvB,SAASJ,cACdK,QAAe;AAEf,MAAMC,aAAaL,sBAAAA,GAEbM,aAAaH,cAAAA,GACbI,mBAAmBN,MAAMO,QAAQ,WAAA;AACrC,QAAI,CAACJ;AACH,aAAO;AAET,QAAMK,aAAaP,oBAAoBE,MAAAA;AAEvC,WAAIA,OAAOM,WAAW,GAAA,IACbC,cAAcL,YAAYF,MAAAA,IAE5BK;EACT,GAAG;IAACH;IAAYF;GAAO;AAEvB,MAAIG,oBAAoB,MAAM;AAC5B,QAAMK,mBAAmBP,WAAWQ,UAAUN,gBAAAA;AAI9C,QAAI,CAACK;AACH,YAAM,IAAIE,MACR,gDAAgDV,MAAAA,QAC7CG,qBAAqBH,SAAS,iBAAiBG,gBAAAA,MAAsB,GAAC;AAG7E,WAAOK;EACT;AACA,SAAOP;AACT;AAEO,SAASU,gBAAgBT,YAAoBU,UAAwB;AAC1E,SAAKA,WAIDA,SAASN,WAAW,GAAA,IACfR,oBAAoBS,cAAcL,YAAYU,QAAAA,CAAAA,IAEhDd,oBAAoBc,QAAAA,IANlB;AAOX;AAGA,SAASL,cAAcM,MAAcC,IAAU;AAC7C,MAAMC,YAAYF,KAAKG,MAAM,GAAA,EAAKC,OAAOC,OAAAA,GACnCC,UAAUL,GAAGE,MAAM,GAAA,EAAKC,OAAOC,OAAAA,GAEhC,4BAAA,IAAA,oBAAA,IAAA,iBAAA;;AAAL,aAAK,YAAcC,QAAAA,OAAAA,QAAAA,EAAAA,GAAd,OAAA,EAAA,6BAAA,QAAA,UAAA,KAAA,GAAA,OAAA,4BAAA,IAAuB;AAAvB,UAAMC,OAAN,MAAA;AACH,UAAIA,SAAS,MAAM;AACjB,YAAIL,UAAUM,WAAW;AACvB,gBAAM,IAAIX,MAAM,wBAAwBI,EAAAA,kBAAoBD,IAAAA,GAAO;AAErEE,kBAAUO,IAAG;MACf,MAAO,CAAIF,SAAS,OAGlBL,UAAUQ,KAAKH,IAAAA;IAEnB;;AAXK,wBAAA,IAAA,iBAAA;;;OAAA,6BAAA,UAAA,UAAA,QAAA,UAAA,OAAA;;UAAA;cAAA;;;AAaL,SAAO,MAAML,UAAUS,KAAK,GAAA;AAC9B;",
|
5
|
+
"names": ["useNavigation", "useUpstreamNavigation", "React", "getNameFromFilePath", "useContextKey", "parent", "navigation", "contextKey", "normalizedParent", "useMemo", "normalized", "startsWith", "relativePaths", "parentNavigation", "getParent", "Error", "resolveParentId", "parentId", "from", "to", "fromParts", "split", "filter", "Boolean", "toParts", "part", "length", "pop", "push", "join"]
|
6
|
+
}
|