expo-router 4.0.0-preview.11 → 4.0.0-preview.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ExpoRoot.js +2 -2
- package/build/ExpoRoot.js.map +1 -1
- package/build/exports.d.ts +1 -1
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js +24 -2
- package/build/exports.js.map +1 -1
- package/build/fast-refresh.d.ts.map +1 -1
- package/build/fast-refresh.js.map +1 -1
- package/build/getRoutesCore.d.ts +1 -0
- package/build/getRoutesCore.d.ts.map +1 -1
- package/build/getRoutesCore.js +3 -1
- package/build/getRoutesCore.js.map +1 -1
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +1 -2
- package/build/global-state/router-store.js.map +1 -1
- package/build/head/url.d.ts +1 -0
- package/build/head/url.d.ts.map +1 -1
- package/build/head/url.js +21 -4
- package/build/head/url.js.map +1 -1
- package/build/hooks.d.ts +90 -38
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +46 -39
- package/build/hooks.js.map +1 -1
- package/build/imperative-api.d.ts +58 -15
- package/build/imperative-api.d.ts.map +1 -1
- package/build/imperative-api.js.map +1 -1
- package/build/layouts/Drawer.d.ts +2 -142
- package/build/layouts/Drawer.d.ts.map +1 -1
- package/build/layouts/Drawer.js +8 -5
- package/build/layouts/Drawer.js.map +1 -1
- package/build/layouts/DrawerClient.d.ts +144 -0
- package/build/layouts/DrawerClient.d.ts.map +1 -0
- package/build/layouts/DrawerClient.js +10 -0
- package/build/layouts/DrawerClient.js.map +1 -0
- package/build/layouts/Stack.d.ts +2 -126
- package/build/layouts/Stack.d.ts.map +1 -1
- package/build/layouts/Stack.js +8 -6
- package/build/layouts/Stack.js.map +1 -1
- package/build/layouts/StackClient.d.ts +128 -0
- package/build/layouts/StackClient.d.ts.map +1 -0
- package/build/layouts/StackClient.js +10 -0
- package/build/layouts/StackClient.js.map +1 -0
- package/build/layouts/Tabs.d.ts +2 -134
- package/build/layouts/Tabs.d.ts.map +1 -1
- package/build/layouts/Tabs.js +5 -37
- package/build/layouts/Tabs.js.map +1 -1
- package/build/layouts/TabsClient.d.ts +136 -0
- package/build/layouts/TabsClient.d.ts.map +1 -0
- package/build/layouts/TabsClient.js +44 -0
- package/build/layouts/TabsClient.js.map +1 -0
- package/build/layouts/withLayoutContext.d.ts +4 -1
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js +4 -1
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +48 -4
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js +47 -3
- package/build/link/Link.js.map +1 -1
- package/build/link/href.d.ts +1 -1
- package/build/link/href.d.ts.map +1 -1
- package/build/link/href.js.map +1 -1
- package/build/link/useLinkHooks.d.ts +122 -29
- package/build/link/useLinkHooks.d.ts.map +1 -1
- package/build/link/useLinkHooks.js.map +1 -1
- package/build/renderRootComponent.d.ts.map +1 -1
- package/build/renderRootComponent.js +1 -2
- package/build/renderRootComponent.js.map +1 -1
- package/build/rsc/exports.d.ts +3 -1
- package/build/rsc/exports.d.ts.map +1 -1
- package/build/rsc/exports.js +3 -1
- package/build/rsc/exports.js.map +1 -1
- package/build/rsc/middleware.d.ts +1 -1
- package/build/rsc/middleware.d.ts.map +1 -1
- package/build/rsc/middleware.js +2 -1
- package/build/rsc/middleware.js.map +1 -1
- package/build/rsc/router/client.d.ts +2 -2
- package/build/rsc/router/client.d.ts.map +1 -1
- package/build/rsc/router/client.js.map +1 -1
- package/build/rsc/router/host.d.ts.map +1 -1
- package/build/rsc/router/host.js +20 -15
- package/build/rsc/router/host.js.map +1 -1
- package/build/rsc/rsc-renderer.d.ts +1 -1
- package/build/rsc/rsc-renderer.d.ts.map +1 -1
- package/build/rsc/rsc-renderer.js +1 -1
- package/build/rsc/rsc-renderer.js.map +1 -1
- package/build/rsc/server.d.ts +3 -0
- package/build/rsc/server.d.ts.map +1 -1
- package/build/rsc/server.js +19 -1
- package/build/rsc/server.js.map +1 -1
- package/build/testing-library/context-stubs.d.ts.map +1 -1
- package/build/testing-library/context-stubs.js +3 -1
- package/build/testing-library/context-stubs.js.map +1 -1
- package/build/testing-library/mocks.js +14 -13
- package/build/testing-library/mocks.js.map +1 -1
- package/build/typed-routes/generate.d.ts +5 -1
- package/build/typed-routes/generate.d.ts.map +1 -1
- package/build/typed-routes/generate.js +129 -64
- package/build/typed-routes/generate.js.map +1 -1
- package/build/typed-routes/index.d.ts +5 -0
- package/build/typed-routes/index.d.ts.map +1 -1
- package/build/typed-routes/index.js +8 -3
- package/build/typed-routes/index.js.map +1 -1
- package/build/typed-routes/testSetup.d.ts +1 -1
- package/build/typed-routes/testSetup.d.ts.map +1 -1
- package/build/typed-routes/testSetup.js +29 -17
- package/build/typed-routes/testSetup.js.map +1 -1
- package/build/typed-routes/types.d.ts +43 -145
- package/build/typed-routes/types.d.ts.map +1 -1
- package/build/typed-routes/types.js.map +1 -1
- package/build/types.d.ts +33 -0
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/ui/TabContext.d.ts +158 -1
- package/build/ui/TabContext.d.ts.map +1 -1
- package/build/ui/TabContext.js +25 -1
- package/build/ui/TabContext.js.map +1 -1
- package/build/ui/TabList.d.ts +17 -1
- package/build/ui/TabList.d.ts.map +1 -1
- package/build/ui/TabList.js +16 -0
- package/build/ui/TabList.js.map +1 -1
- package/build/ui/TabSlot.d.ts +55 -5
- package/build/ui/TabSlot.d.ts.map +1 -1
- package/build/ui/TabSlot.js +38 -14
- package/build/ui/TabSlot.js.map +1 -1
- package/build/ui/TabTrigger.d.ts +65 -70
- package/build/ui/TabTrigger.d.ts.map +1 -1
- package/build/ui/TabTrigger.js +25 -1
- package/build/ui/TabTrigger.js.map +1 -1
- package/build/ui/Tabs.d.ts +89 -132
- package/build/ui/Tabs.d.ts.map +1 -1
- package/build/ui/Tabs.js +53 -8
- package/build/ui/Tabs.js.map +1 -1
- package/build/ui/common.d.ts +3 -3
- package/build/ui/common.d.ts.map +1 -1
- package/build/ui/common.js.map +1 -1
- package/build/useFocusEffect.d.ts +15 -6
- package/build/useFocusEffect.d.ts.map +1 -1
- package/build/useFocusEffect.js +15 -6
- package/build/useFocusEffect.js.map +1 -1
- package/build/useNavigation.d.ts +11 -5
- package/build/useNavigation.d.ts.map +1 -1
- package/build/useNavigation.js +11 -5
- package/build/useNavigation.js.map +1 -1
- package/build/utils/splash.d.ts +6 -0
- package/build/utils/splash.d.ts.map +1 -0
- package/build/utils/splash.js +51 -0
- package/build/utils/splash.js.map +1 -0
- package/build/views/Navigator.d.ts +6 -5
- package/build/views/Navigator.d.ts.map +1 -1
- package/build/views/Navigator.js +6 -5
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Splash.d.ts +1 -1
- package/build/views/Splash.d.ts.map +1 -1
- package/build/views/Splash.js +3 -13
- package/build/views/Splash.js.map +1 -1
- package/build/views/Try.d.ts +1 -1
- package/build/views/Try.d.ts.map +1 -1
- package/build/views/Try.js +1 -1
- package/build/views/Try.js.map +1 -1
- package/entry-classic.js +0 -6
- package/package.json +3 -5
- package/plugin/build/index.d.ts +2 -0
- package/plugin/options.json +74 -73
- package/rsc/entry.js +0 -6
- package/rsc/headers.d.ts +3 -0
- package/rsc/headers.js +5 -0
- package/build/rsc/runtime.d.ts +0 -9
- package/build/rsc/runtime.d.ts.map +0 -1
- package/build/rsc/runtime.js +0 -36
- package/build/rsc/runtime.js.map +0 -1
- package/virtual-client-boundaries.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLayoutContext.d.ts","sourceRoot":"","sources":["../../src/layouts/withLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,EAIZ,aAAa,EAGb,SAAS,EAIV,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAoB,WAAW,EAAE,MAAM,eAAe,CAAC;AAG9D,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,SAAS,EACnB,EACE,iBAAiB,EACjB,UAAU,GACX,GAAE;IACD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB;;;EA4CP;AAED
|
|
1
|
+
{"version":3,"file":"withLayoutContext.d.ts","sourceRoot":"","sources":["../../src/layouts/withLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,EAIZ,aAAa,EAGb,SAAS,EAIV,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAoB,WAAW,EAAE,MAAM,eAAe,CAAC;AAG9D,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,SAAS,EACnB,EACE,iBAAiB,EACjB,UAAU,GACX,GAAE;IACD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB;;;EA4CP;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,SAAS,MAAM,EACvB,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EAC5B,MAAM,SAAS,eAAe,EAC9B,SAAS,SAAS,YAAY,EAE9B,GAAG,EAAE,CAAC,EACN,SAAS,CAAC,EAAE,CACV,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAChD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE;oBA2B7B,YAAY,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,KAAK,IAAI;EAEpE"}
|
|
@@ -67,7 +67,10 @@ function useFilterScreenChildren(children, { isCustomNavigator, contextKey, } =
|
|
|
67
67
|
}, [children]);
|
|
68
68
|
}
|
|
69
69
|
exports.useFilterScreenChildren = useFilterScreenChildren;
|
|
70
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Returns a navigator that automatically injects matched routes and renders nothing when there are no children.
|
|
72
|
+
* Return type with `children` prop optional.
|
|
73
|
+
*/
|
|
71
74
|
function withLayoutContext(Nav, processor) {
|
|
72
75
|
return Object.assign((0, react_1.forwardRef)(({ children: userDefinedChildren, ...props }, ref) => {
|
|
73
76
|
const contextKey = (0, Route_1.useContextKey)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLayoutContext.js","sourceRoot":"","sources":["../../src/layouts/withLayoutContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAWe;AAEf,oCAAyC;AAEzC,8CAA8D;AAC9D,4CAAyC;AAEzC,SAAgB,uBAAuB,CACrC,QAAmB,EACnB,EACE,iBAAiB,EACjB,UAAU,MAKR,EAAE;IAEN,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,MAAM,cAAc,GAAU,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,gBAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YAC/C,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,eAAM,EAAE;gBAC3D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE;oBACrB,MAAM,IAAI,KAAK,CACb,sDAAsD,UAAU,8EAA8E,CAC/I,CAAC;iBACH;gBACD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;oBACzC,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,K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C,QAAQ,CAAC,CAAC,CAAC;AACjB,CAAC;AArDD,0DAqDC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAM/B,GAAM,EACN,SAE+C;IAE/C,OAAO,MAAM,CAAC,MAAM,CAClB,IAAA,kBAAU,EAAC,CAAC,EAAE,QAAQ,EAAE,mBAAmB,EAAE,GAAG,KAAK,EAAO,EAAE,GAAG,EAAE,EAAE;QACnE,MAAM,UAAU,GAAG,IAAA,qBAAa,GAAE,CAAC;QAEnC,MAAM,EAAE,OAAO,EAAE,GAAG,uBAAuB,CAAC,mBAAmB,EAAE;YAC/D,UAAU;SACX,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAEjE,MAAM,MAAM,GAAG,IAAA,6BAAgB,EAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QAEjD,uDAAuD;QACvD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,OAAO,IAAI,CAAC;SACb;QAED,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAG,CAAC;IACxE,CAAC,CAAC,EACF;QACE,MAAM,EAAN,eAAM;KACP,CAKF,CAAC;AACJ,CAAC;AAtCD,8CAsCC","sourcesContent":["import { EventMapBase, NavigationState } from '@react-navigation/native';\nimport React, {\n Children,\n forwardRef,\n ComponentProps,\n ComponentType,\n ForwardRefExoticComponent,\n PropsWithoutRef,\n ReactNode,\n RefAttributes,\n isValidElement,\n useMemo,\n} from 'react';\n\nimport { useContextKey } from '../Route';\nimport { PickPartial } from '../types';\nimport { useSortedScreens, ScreenProps } from '../useScreens';\nimport { Screen } from '../views/Screen';\n\nexport function useFilterScreenChildren(\n children: ReactNode,\n {\n isCustomNavigator,\n contextKey,\n }: {\n isCustomNavigator?: boolean;\n /** Used for sending developer hints */\n contextKey?: string;\n } = {}\n) {\n return useMemo(() => {\n const customChildren: any[] = [];\n const screens = Children.map(children, (child) => {\n if (isValidElement(child) && child && child.type === Screen) {\n if (!child.props.name) {\n throw new Error(\n `<Screen /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must have a \\`name\\` prop when used as a child of a Layout Route.`\n );\n }\n if (process.env.NODE_ENV !== 'production') {\n if (['children', 'component', 'getComponent'].some((key) => key in child.props)) {\n throw new Error(\n `<Screen /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must not have a \\`children\\`, \\`component\\`, or \\`getComponent\\` prop when used as a child of a Layout Route`\n );\n }\n }\n return child.props;\n } else {\n if (isCustomNavigator) {\n customChildren.push(child);\n } else {\n console.warn(\n `Layout children must be of type Screen, all other children are ignored. To use custom children, create a custom <Layout />. Update Layout Route at: \"app${contextKey}/_layout\"`\n );\n }\n }\n });\n\n // Add an assertion for development\n if (process.env.NODE_ENV !== 'production') {\n // Assert if names are not unique\n const names = screens?.map((screen) => screen.name);\n if (names && new Set(names).size !== names.length) {\n throw new Error('Screen names must be unique: ' + names);\n }\n }\n\n return {\n screens,\n children: customChildren,\n };\n }, [children]);\n}\n\n/**\n * Returns a navigator that automatically injects matched routes and renders nothing when there are no children.\n * Return type with `children` prop optional.\n */\nexport function withLayoutContext<\n TOptions extends object,\n T extends ComponentType<any>,\n TState extends NavigationState,\n TEventMap extends EventMapBase,\n>(\n Nav: T,\n processor?: (\n options: ScreenProps<TOptions, TState, TEventMap>[]\n ) => ScreenProps<TOptions, TState, TEventMap>[]\n) {\n return Object.assign(\n forwardRef(({ children: userDefinedChildren, ...props }: any, ref) => {\n const contextKey = useContextKey();\n\n const { screens } = useFilterScreenChildren(userDefinedChildren, {\n contextKey,\n });\n\n const processed = processor ? processor(screens ?? []) : screens;\n\n const sorted = useSortedScreens(processed ?? []);\n\n // Prevent throwing an error when there are no screens.\n if (!sorted.length) {\n return null;\n }\n\n return <Nav {...props} id={contextKey} ref={ref} children={sorted} />;\n }),\n {\n Screen,\n }\n ) as ForwardRefExoticComponent<\n PropsWithoutRef<PickPartial<ComponentProps<T>, 'children'>> & RefAttributes<unknown>\n > & {\n Screen: (props: ScreenProps<TOptions, TState, TEventMap>) => null;\n };\n}\n"]}
|
package/build/link/Link.d.ts
CHANGED
|
@@ -2,17 +2,61 @@ import { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { Href } from '../types';
|
|
3
3
|
import { LinkProps, WebAnchorProps } from './useLinkHooks';
|
|
4
4
|
export interface LinkComponent {
|
|
5
|
-
|
|
5
|
+
(props: PropsWithChildren<LinkProps>): JSX.Element;
|
|
6
6
|
/** Helper method to resolve a Href object into a string. */
|
|
7
7
|
resolveHref: (href: Href) => string;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Redirects to the `href` as soon as the component is mounted.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { View, Text } from 'react-native';
|
|
15
|
+
* import { Redirect } from 'expo-router';
|
|
16
|
+
*
|
|
17
|
+
* export default function Page() {
|
|
18
|
+
* const { user } = useAuth();
|
|
19
|
+
*
|
|
20
|
+
* if (!user) {
|
|
21
|
+
* return <Redirect href="/login" />;
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* return (
|
|
25
|
+
* <View>
|
|
26
|
+
* <Text>Welcome Back!</Text>
|
|
27
|
+
* </View>
|
|
28
|
+
* );
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
10
32
|
export declare function Redirect({ href }: {
|
|
11
33
|
href: Href;
|
|
12
34
|
}): null;
|
|
13
35
|
/**
|
|
14
|
-
* Component
|
|
15
|
-
*
|
|
36
|
+
* Component that renders a link using [`href`](#href) to another route.
|
|
37
|
+
* By default, it accepts children and wraps them in a `<Text>` component.
|
|
38
|
+
*
|
|
39
|
+
* Uses an anchor tag (`<a>`) on web and performs a client-side navigation to preserve
|
|
40
|
+
* the state of the website and navigate faster. The web-only attributes such as `target`,
|
|
41
|
+
* `rel`, and `download` are supported and passed to the anchor tag on web. See
|
|
42
|
+
* [`WebAnchorProps`](#webanchorprops) for more details.
|
|
43
|
+
*
|
|
44
|
+
* > **Note**: Client-side navigation works with both single-page apps,
|
|
45
|
+
* and [static-rendering](/router/reference/static-rendering/).
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* import { Link } from 'expo-router';
|
|
50
|
+
* import { View } from 'react-native';
|
|
51
|
+
*
|
|
52
|
+
* export default function Route() {
|
|
53
|
+
* return (
|
|
54
|
+
* <View>
|
|
55
|
+
* <Link href="/about">About</Link>
|
|
56
|
+
* </View>
|
|
57
|
+
* );
|
|
58
|
+
*}
|
|
59
|
+
* ```
|
|
16
60
|
*/
|
|
17
61
|
export declare const Link: LinkComponent;
|
|
18
62
|
export { LinkProps, WebAnchorProps };
|
package/build/link/Link.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAiD,MAAM,OAAO,CAAC;AAOzF,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAqC,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE9F,MAAM,WAAW,aAAa;IAC5B,CAAC,
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAiD,MAAM,OAAO,CAAC;AAOzF,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAqC,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE9F,MAAM,WAAW,aAAa;IAC5B,CAAC,KAAK,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;IACnD,4DAA4D;IAC5D,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,QAUhD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,IAAI,eAAyD,CAAC;AAuE3E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
|
package/build/link/Link.js
CHANGED
|
@@ -15,7 +15,29 @@ const useLinkToPathProps_1 = __importDefault(require("./useLinkToPathProps"));
|
|
|
15
15
|
const hooks_1 = require("../hooks");
|
|
16
16
|
const useFocusEffect_1 = require("../useFocusEffect");
|
|
17
17
|
const useLinkHooks_1 = require("./useLinkHooks");
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Redirects to the `href` as soon as the component is mounted.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { View, Text } from 'react-native';
|
|
24
|
+
* import { Redirect } from 'expo-router';
|
|
25
|
+
*
|
|
26
|
+
* export default function Page() {
|
|
27
|
+
* const { user } = useAuth();
|
|
28
|
+
*
|
|
29
|
+
* if (!user) {
|
|
30
|
+
* return <Redirect href="/login" />;
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* return (
|
|
34
|
+
* <View>
|
|
35
|
+
* <Text>Welcome Back!</Text>
|
|
36
|
+
* </View>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
19
41
|
function Redirect({ href }) {
|
|
20
42
|
const router = (0, hooks_1.useRouter)();
|
|
21
43
|
(0, useFocusEffect_1.useFocusEffect)(() => {
|
|
@@ -30,8 +52,30 @@ function Redirect({ href }) {
|
|
|
30
52
|
}
|
|
31
53
|
exports.Redirect = Redirect;
|
|
32
54
|
/**
|
|
33
|
-
* Component
|
|
34
|
-
*
|
|
55
|
+
* Component that renders a link using [`href`](#href) to another route.
|
|
56
|
+
* By default, it accepts children and wraps them in a `<Text>` component.
|
|
57
|
+
*
|
|
58
|
+
* Uses an anchor tag (`<a>`) on web and performs a client-side navigation to preserve
|
|
59
|
+
* the state of the website and navigate faster. The web-only attributes such as `target`,
|
|
60
|
+
* `rel`, and `download` are supported and passed to the anchor tag on web. See
|
|
61
|
+
* [`WebAnchorProps`](#webanchorprops) for more details.
|
|
62
|
+
*
|
|
63
|
+
* > **Note**: Client-side navigation works with both single-page apps,
|
|
64
|
+
* and [static-rendering](/router/reference/static-rendering/).
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* import { Link } from 'expo-router';
|
|
69
|
+
* import { View } from 'react-native';
|
|
70
|
+
*
|
|
71
|
+
* export default function Route() {
|
|
72
|
+
* return (
|
|
73
|
+
* <View>
|
|
74
|
+
* <Link href="/about">About</Link>
|
|
75
|
+
* </View>
|
|
76
|
+
* );
|
|
77
|
+
*}
|
|
78
|
+
* ```
|
|
35
79
|
*/
|
|
36
80
|
exports.Link = (0, react_1.forwardRef)(ExpoRouterLink);
|
|
37
81
|
exports.Link.resolveHref = href_1.resolveHref;
|
package/build/link/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AACb,wFAAwF;AACxF,mCAAmC;AACnC,iCAAyF;AACzF,+CAAqE;AAErE,yCAAkC;AAClC,iCAAqC;AACrC,8EAAsD;AACtD,oCAAqC;AAErC,sDAAmD;AACnD,iDAA8F;AAQ9F
|
|
1
|
+
{"version":3,"file":"Link.js","sourceRoot":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KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;QACD,OAAO,IAAA,kBAAW,EAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,IAAI,KAAK,CAAC;IACV,IAAI,IAAI;QAAE,KAAK,GAAG,MAAM,CAAC;IACzB,IAAI,OAAO;QAAE,KAAK,GAAG,SAAS,CAAC;IAE/B,MAAM,KAAK,GAAG,IAAA,4BAAkB,EAAC;QAC/B,IAAI,EAAE,YAAY;QAClB,KAAK;QACL,mBAAmB;QACnB,UAAU;KACX,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,CAAC,CAAwD,EAAE,EAAE;QAC3E,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;SACnB;QACD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,eAAI,CAAC,CAAC,CAAC,mBAAI,CAAC;IAEtC,6HAA6H;IAC7H,OAAO,CACL,CAAC,OAAO,CACN,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,IAAI,KAAK,CAAC,CACV,IAAI,SAAS,CAAC,CACd,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,IAAI,uBAAQ,CAAC,MAAM,CAAC;QAClB,GAAG,EAAE;YACH,OAAO,EAAE,OAAO;SACV;QACR,OAAO,EAAE,EAAE,OAAO,EAAE;KACrB,CAAC,CAAC,EACH,CACH,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n// Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and\n// `to` / `action` support removed.\nimport { PropsWithChildren, forwardRef, useMemo, MouseEvent, ForwardedRef } from 'react';\nimport { Text, GestureResponderEvent, Platform } from 'react-native';\n\nimport { Slot } from './LinkSlot';\nimport { resolveHref } from './href';\nimport useLinkToPathProps from './useLinkToPathProps';\nimport { useRouter } from '../hooks';\nimport { Href } from '../types';\nimport { useFocusEffect } from '../useFocusEffect';\nimport { useInteropClassName, useHrefAttrs, LinkProps, WebAnchorProps } from './useLinkHooks';\n\nexport interface LinkComponent {\n (props: PropsWithChildren<LinkProps>): JSX.Element;\n /** Helper method to resolve a Href object into a string. */\n resolveHref: (href: Href) => string;\n}\n\n/**\n * Redirects to the `href` as soon as the component is mounted.\n *\n * @example\n * ```tsx\n * import { View, Text } from 'react-native';\n * import { Redirect } from 'expo-router';\n *\n * export default function Page() {\n * const { user } = useAuth();\n *\n * if (!user) {\n * return <Redirect href=\"/login\" />;\n * }\n *\n * return (\n * <View>\n * <Text>Welcome Back!</Text>\n * </View>\n * );\n * }\n * ```\n */\nexport function Redirect({ href }: { href: Href }) {\n const router = useRouter();\n useFocusEffect(() => {\n try {\n router.replace(href);\n } catch (error) {\n console.error(error);\n }\n });\n return null;\n}\n\n/**\n * Component that renders a link using [`href`](#href) to another route.\n * By default, it accepts children and wraps them in a `<Text>` component.\n *\n * Uses an anchor tag (`<a>`) on web and performs a client-side navigation to preserve\n * the state of the website and navigate faster. The web-only attributes such as `target`,\n * `rel`, and `download` are supported and passed to the anchor tag on web. See\n * [`WebAnchorProps`](#webanchorprops) for more details.\n *\n * > **Note**: Client-side navigation works with both single-page apps,\n * and [static-rendering](/router/reference/static-rendering/).\n *\n * @example\n * ```tsx\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link href=\"/about\">About</Link>\n * </View>\n * );\n *}\n * ```\n */\nexport const Link = forwardRef(ExpoRouterLink) as unknown as LinkComponent;\n\nLink.resolveHref = resolveHref;\n\nfunction ExpoRouterLink(\n {\n href,\n replace,\n push,\n // TODO: This does not prevent default on the anchor tag.\n relativeToDirectory,\n asChild,\n rel,\n target,\n download,\n withAnchor,\n ...rest\n }: LinkProps,\n ref: ForwardedRef<Text>\n) {\n // Mutate the style prop to add the className on web.\n const style = useInteropClassName(rest);\n\n // If not passing asChild, we need to forward the props to the anchor tag using React Native Web's `hrefAttrs`.\n const hrefAttrs = useHrefAttrs({ asChild, rel, target, download });\n\n const resolvedHref = useMemo(() => {\n if (href == null) {\n throw new Error('Link: href is required');\n }\n return resolveHref(href);\n }, [href]);\n\n let event;\n if (push) event = 'PUSH';\n if (replace) event = 'REPLACE';\n\n const props = useLinkToPathProps({\n href: resolvedHref,\n event,\n relativeToDirectory,\n withAnchor,\n });\n\n const onPress = (e: MouseEvent<HTMLAnchorElement> | GestureResponderEvent) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n props.onPress(e);\n };\n\n const Element = asChild ? Slot : Text;\n\n // Avoid using createElement directly, favoring JSX, to allow tools like NativeWind to perform custom JSX handling on native.\n return (\n <Element\n ref={ref}\n {...props}\n {...hrefAttrs}\n {...rest}\n style={style}\n {...Platform.select({\n web: {\n onClick: onPress,\n } as any,\n default: { onPress },\n })}\n />\n );\n}\n\nexport { LinkProps, WebAnchorProps };\n"]}
|
package/build/link/href.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UrlObject } from '../LocationProvider';
|
|
2
2
|
import { Href } from '../types';
|
|
3
3
|
/** Resolve an href object into a fully qualified, relative href. */
|
|
4
|
-
export declare const resolveHref: (href: Href
|
|
4
|
+
export declare const resolveHref: (href: Href) => string;
|
|
5
5
|
export declare function resolveHrefStringWithSegments(href: string, { segments, params }?: Partial<UrlObject>, relativeToDirectory?: boolean): string;
|
|
6
6
|
//# sourceMappingURL=href.d.ts.map
|
package/build/link/href.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"href.d.ts","sourceRoot":"","sources":["../../src/link/href.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"href.d.ts","sourceRoot":"","sources":["../../src/link/href.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,oEAAoE;AACpE,eAAO,MAAM,WAAW,SAAU,IAAI,KAAG,MAaxC,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,EAAE,QAAa,EAAE,MAAW,EAAE,GAAE,OAAO,CAAC,SAAS,CAAM,EACvD,mBAAmB,GAAE,OAAe,UAiCrC"}
|
package/build/link/href.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"href.js","sourceRoot":"","sources":["../../src/link/href.ts"],"names":[],"mappings":";;;AAGA,oEAAoE;AAC7D,MAAM,WAAW,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"href.js","sourceRoot":"","sources":["../../src/link/href.ts"],"names":[],"mappings":";;;AAGA,oEAAoE;AAC7D,MAAM,WAAW,GAAG,CAAC,IAAU,EAAU,EAAE;IAChD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAA,mBAAW,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;KACxC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;IACjC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE;QACjB,OAAO,IAAI,CAAC;KACb;IACD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,uBAAuB,CAAC,IAAI,EAAE;QACzD,GAAG,IAAI,CAAC,MAAM;KACf,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,QAAQ,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC;AAbW,QAAA,WAA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E,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,kBAAkB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;SACvE,IAAI,CAAC,GAAG,CAAC,CACb,CAAC;AACJ,CAAC","sourcesContent":["import { UrlObject } from '../LocationProvider';\nimport { Href } from '../types';\n\n/** Resolve an href object into a fully qualified, relative href. */\nexport const resolveHref = (href: Href): string => {\n if (typeof href === 'string') {\n return resolveHref({ pathname: href });\n }\n const path = href.pathname ?? '';\n if (!href?.params) {\n return path;\n }\n const { pathname, params } = createQualifiedPathname(path, {\n ...href.params,\n });\n const paramsString = createQueryParams(params);\n return pathname + (paramsString ? `?${paramsString}` : '');\n};\n\nexport function resolveHrefStringWithSegments(\n href: string,\n { segments = [], params = {} }: Partial<UrlObject> = {},\n relativeToDirectory: boolean = false\n) {\n if (href.startsWith('.')) {\n // Resolve base path by merging the current segments with the params\n let base =\n segments\n ?.map((segment) => {\n if (!segment.startsWith('[')) return segment;\n\n if (segment.startsWith('[...')) {\n segment = segment.slice(4, -1);\n const param = params[segment];\n if (Array.isArray(param)) {\n return param.join('/');\n } else {\n return param?.split(',')?.join('/') ?? '';\n }\n } else {\n segment = segment.slice(1, -1);\n return params[segment];\n }\n })\n .filter(Boolean)\n .join('/') ?? '/';\n\n if (relativeToDirectory) {\n base = `${base}/`;\n }\n\n href = new URL(href, `http://hostname/${base}`).pathname;\n }\n\n return href;\n}\n\nfunction createQualifiedPathname(\n pathname: string,\n params: Record<string, any>\n): { pathname: string; params: any } {\n for (const [key, value = ''] of Object.entries(params)) {\n const dynamicKey = `[${key}]`;\n const deepDynamicKey = `[...${key}]`;\n if (pathname.includes(dynamicKey)) {\n pathname = pathname.replace(dynamicKey, encodeParam(value));\n } else if (pathname.includes(deepDynamicKey)) {\n pathname = pathname.replace(deepDynamicKey, encodeParam(value));\n } else {\n continue;\n }\n\n delete params[key];\n }\n return { pathname, params };\n}\n\nfunction encodeParam(param: any): string {\n if (Array.isArray(param)) {\n return param.map((p) => encodeParam(p)).join('/');\n }\n\n return encodeURIComponent(param.toString());\n}\n\nfunction createQueryParams(params: Record<string, any>): string {\n return (\n Object.entries(params)\n // Allow nullish params\n .filter(([, value]) => value != null)\n .map(([key, value]) => `${key}=${encodeURIComponent(value.toString())}`)\n .join('&')\n );\n}\n"]}
|
|
@@ -6,12 +6,13 @@ import { Href } from '../types';
|
|
|
6
6
|
*/
|
|
7
7
|
export type WebAnchorProps = {
|
|
8
8
|
/**
|
|
9
|
-
* Specifies where to open the `href
|
|
9
|
+
* Specifies where to open the [`href`](#href).
|
|
10
10
|
*
|
|
11
11
|
* - **_self**: the current tab.
|
|
12
12
|
* - **_blank**: opens in a new tab or window.
|
|
13
13
|
* - **_parent**: opens in the parent browsing context. If no parent, defaults to **_self**.
|
|
14
|
-
* - **_top**: opens in the highest browsing context ancestor. If no ancestors,
|
|
14
|
+
* - **_top**: opens in the highest browsing context ancestor. If no ancestors,
|
|
15
|
+
* defaults to **_self**.
|
|
15
16
|
*
|
|
16
17
|
* This property is passed to the underlying anchor (`<a>`) tag.
|
|
17
18
|
*
|
|
@@ -24,17 +25,22 @@ export type WebAnchorProps = {
|
|
|
24
25
|
*/
|
|
25
26
|
target?: '_self' | '_blank' | '_parent' | '_top' | (string & object);
|
|
26
27
|
/**
|
|
27
|
-
* Specifies the relationship between the `href` and the current route.
|
|
28
|
+
* Specifies the relationship between the [`href`](#href) and the current route.
|
|
28
29
|
*
|
|
29
30
|
* Common values:
|
|
30
|
-
* - **nofollow**: Indicates to search engines that they should not follow the `href`.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* - **nofollow**: Indicates to search engines that they should not follow the `href`.
|
|
32
|
+
* This is often used for user-generated content or links that should not influence
|
|
33
|
+
* search engine rankings.
|
|
34
|
+
* - **noopener**: Suggests that the `href` should not have access to the opening
|
|
35
|
+
* window's `window.opener` object, which is a security measure to prevent potentially
|
|
36
|
+
* harmful behavior in cases of links that open new tabs or windows.
|
|
37
|
+
* - **noreferrer**: Requests that the browser does not send the `Referer` HTTP header
|
|
38
|
+
* when navigating to the `href`. This can enhance user privacy.
|
|
33
39
|
*
|
|
34
40
|
* The `rel` property is primarily used for informational and instructive purposes, helping browsers and web
|
|
35
|
-
* crawlers make better decisions about how to handle and interpret the links on a web
|
|
36
|
-
* to use appropriate `rel` values to ensure that links behave as intended and adhere
|
|
37
|
-
* development and SEO (Search Engine Optimization).
|
|
41
|
+
* crawlers make better decisions about how to handle and interpret the links on a web
|
|
42
|
+
* page. It is important to use appropriate `rel` values to ensure that links behave as intended and adhere
|
|
43
|
+
* to best practices for web development and SEO (Search Engine Optimization).
|
|
38
44
|
*
|
|
39
45
|
* This property is passed to the underlying anchor (`<a>`) tag.
|
|
40
46
|
*
|
|
@@ -45,12 +51,12 @@ export type WebAnchorProps = {
|
|
|
45
51
|
*/
|
|
46
52
|
rel?: string;
|
|
47
53
|
/**
|
|
48
|
-
* Specifies that the `href` should be downloaded when the user clicks on the
|
|
49
|
-
* instead of navigating to it. It is typically used for links that point to
|
|
50
|
-
* such as PDFs, images, documents,
|
|
54
|
+
* Specifies that the [`href`](#href) should be downloaded when the user clicks on the
|
|
55
|
+
* link, instead of navigating to it. It is typically used for links that point to
|
|
56
|
+
* files that the user should download, such as PDFs, images, documents, and more.
|
|
51
57
|
*
|
|
52
|
-
* The value of the `download` property, which represents the filename for the
|
|
53
|
-
* This property is passed to the underlying anchor (`<a>`) tag.
|
|
58
|
+
* The value of the `download` property, which represents the filename for the
|
|
59
|
+
* downloaded file. This property is passed to the underlying anchor (`<a>`) tag.
|
|
54
60
|
*
|
|
55
61
|
* @example
|
|
56
62
|
* ```jsx
|
|
@@ -59,28 +65,115 @@ export type WebAnchorProps = {
|
|
|
59
65
|
*/
|
|
60
66
|
download?: string;
|
|
61
67
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
export interface LinkProps extends Omit<TextProps, 'href'>, WebAnchorProps {
|
|
69
|
+
/**
|
|
70
|
+
* The path of the route to navigate to. It can either be:
|
|
71
|
+
* - **string**: A full path like `/profile/settings` or a relative path like `../settings`.
|
|
72
|
+
* - **object**: An object with a `pathname` and optional `params`. The `pathname` can be
|
|
73
|
+
* a full path like `/profile/settings` or a relative path like `../settings`. The
|
|
74
|
+
* params can be an object of key-value pairs.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx Dynamic
|
|
78
|
+
* import { Link } from 'expo-router';
|
|
79
|
+
* import { View } from 'react-native';
|
|
80
|
+
*
|
|
81
|
+
* export default function Route() {
|
|
82
|
+
* return (
|
|
83
|
+
* <View>
|
|
84
|
+
* <Link href="/about">About</Link>
|
|
85
|
+
* <Link
|
|
86
|
+
* href={{
|
|
87
|
+
* pathname: '/user/[id]',
|
|
88
|
+
* params: { id: 'bacon' }
|
|
89
|
+
* }}>
|
|
90
|
+
* View user
|
|
91
|
+
* </Link>
|
|
92
|
+
* </View>
|
|
93
|
+
* );
|
|
94
|
+
*}
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
href: Href;
|
|
98
|
+
/**
|
|
99
|
+
* Used to customize the `Link` component. It will forward all props to the
|
|
100
|
+
* first child of the `Link`. Note that the child component must accept
|
|
101
|
+
* `onPress` or `onClick` props. The `href` and `role` are also
|
|
102
|
+
* passed to the child.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```tsx
|
|
106
|
+
* import { Link } from 'expo-router';
|
|
107
|
+
* import { Pressable, Text } from 'react-native';
|
|
108
|
+
*
|
|
109
|
+
* export default function Route() {
|
|
110
|
+
* return (
|
|
111
|
+
* <View>
|
|
112
|
+
* <Link href="/home" asChild>
|
|
113
|
+
* <Pressable>
|
|
114
|
+
* <Text>Home</Text>
|
|
115
|
+
* </Pressable>
|
|
116
|
+
* </Link>
|
|
117
|
+
* </View>
|
|
118
|
+
* );
|
|
119
|
+
*}
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
69
122
|
asChild?: boolean;
|
|
70
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Removes the current route from the history and replace it with the
|
|
125
|
+
* specified URL. This is useful for [redirects](/router/reference/redirects/).
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
*```tsx
|
|
129
|
+
* import { Link } from 'expo-router';
|
|
130
|
+
* import { View } from 'react-native';
|
|
131
|
+
*
|
|
132
|
+
* export default function Route() {
|
|
133
|
+
* return (
|
|
134
|
+
* <View>
|
|
135
|
+
* <Link replace href="/feed">Login</Link>
|
|
136
|
+
* </View>
|
|
137
|
+
* );
|
|
138
|
+
*}
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
71
141
|
replace?: boolean;
|
|
72
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* Always pushes a new route, and never pops or replaces to existing route.
|
|
144
|
+
* You can push the current route multiple times or with new parameters.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
*```tsx
|
|
148
|
+
* import { Link } from 'expo-router';
|
|
149
|
+
* import { View } from 'react-native';
|
|
150
|
+
*
|
|
151
|
+
* export default function Route() {
|
|
152
|
+
* return (
|
|
153
|
+
* <View>
|
|
154
|
+
* <Link push href="/feed">Login</Link>
|
|
155
|
+
* </View>
|
|
156
|
+
* );
|
|
157
|
+
*}
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
73
160
|
push?: boolean;
|
|
74
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* On native, this can be used with CSS interop tools like Nativewind.
|
|
163
|
+
* On web, this sets the HTML `class` directly.
|
|
164
|
+
*/
|
|
75
165
|
className?: string;
|
|
76
166
|
onPress?: (e: MouseEvent<HTMLAnchorElement> | GestureResponderEvent) => void;
|
|
77
167
|
/**
|
|
78
|
-
* Relative URL references are either relative to the directory or the document.
|
|
168
|
+
* Relative URL references are either relative to the directory or the document.
|
|
169
|
+
* By default, relative paths are relative to the document.
|
|
79
170
|
*
|
|
80
|
-
* @see [Resolving relative references in Mozilla's documentation](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references)
|
|
171
|
+
* @see [Resolving relative references in Mozilla's documentation](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).
|
|
81
172
|
*/
|
|
82
173
|
relativeToDirectory?: boolean;
|
|
83
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* Replaces the initial screen with the current route.
|
|
176
|
+
*/
|
|
84
177
|
withAnchor?: boolean;
|
|
85
178
|
}
|
|
86
179
|
export declare function useInteropClassName(props: {
|
|
@@ -90,7 +183,7 @@ export declare function useInteropClassName(props: {
|
|
|
90
183
|
$$css: boolean;
|
|
91
184
|
__routerLinkClassName: string;
|
|
92
185
|
})[] | null | undefined;
|
|
93
|
-
export declare const useHrefAttrs: (props: Partial<LinkProps
|
|
186
|
+
export declare const useHrefAttrs: (props: Partial<LinkProps>) => {
|
|
94
187
|
hrefAttrs?: any;
|
|
95
|
-
} & Partial<LinkProps
|
|
188
|
+
} & Partial<LinkProps>;
|
|
96
189
|
//# sourceMappingURL=useLinkHooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinkHooks.d.ts","sourceRoot":"","sources":["../../src/link/useLinkHooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,UAAU,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B
|
|
1
|
+
{"version":3,"file":"useLinkHooks.d.ts","sourceRoot":"","sources":["../../src/link/useLinkHooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,UAAU,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,qBAAqB,EA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IAAE,SAAS,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,QAAQ,SAAS,CAoBtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLinkHooks.js","sourceRoot":"","sources":["../../src/link/useLinkHooks.ts"],"names":[],"mappings":";;;AAAA,wFAAwF;AACxF,mCAAmC;AACnC,iCAA4C;AAC5C,+CAA0E;
|
|
1
|
+
{"version":3,"file":"useLinkHooks.js","sourceRoot":"","sources":["../../src/link/useLinkHooks.ts"],"names":[],"mappings":";;;AAAA,wFAAwF;AACxF,mCAAmC;AACnC,iCAA4C;AAC5C,+CAA0E;AAgM1E,qDAAqD;AACrD,SAAgB,mBAAmB,CAAC,KAAyD;IAC3F,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,OAAO,KAAK,CAAC,KAAK,CAAC;KACpB;IAED,sDAAsD;IACtD,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,IAAI,KAAK,CAAC,SAAS,IAAI,IAAI,EAAE;YAC3B,OAAO,KAAK,CAAC,KAAK,CAAC;SACpB;QACD,MAAM,QAAQ,GAAG;YACf,KAAK,EAAE,IAAI;YACX,qBAAqB,EAAE,KAAK,CAAC,SAAS;SACvC,CAAC;QAEF,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAC9B,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;SACnC;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AACrC,CAAC;AApBD,kDAoBC;AAEY,QAAA,YAAY,GAAG,uBAAQ,CAAC,MAAM,CAEzC;IACA,GAAG,EAAE,SAAS,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAsB;QAC/E,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;YAClB,MAAM,SAAS,GAAG;gBAChB,GAAG;gBACH,MAAM;gBACN,QAAQ;aACT,CAAC;YACF,IAAI,OAAO,EAAE;gBACX,OAAO,SAAS,CAAC;aAClB;YACD,OAAO;gBACL,SAAS;aACV,CAAC;QACJ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,EAAE,SAAS,YAAY;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and\n// `to` / `action` support removed.\nimport { useMemo, MouseEvent } from 'react';\nimport { TextProps, GestureResponderEvent, Platform } from 'react-native';\n\nimport { Href } from '../types';\n\n// docsMissing\n/**\n * @platform web\n */\nexport type WebAnchorProps = {\n /**\n * Specifies where to open the [`href`](#href).\n *\n * - **_self**: the current tab.\n * - **_blank**: opens in a new tab or window.\n * - **_parent**: opens in the parent browsing context. If no parent, defaults to **_self**.\n * - **_top**: opens in the highest browsing context ancestor. If no ancestors,\n * defaults to **_self**.\n *\n * This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @default '_self'\n *\n * @example\n * ```jsx\n * <Link href=\"https://expo.dev\" target=\"_blank\">Go to Expo in new tab</Link>\n * ```\n */\n target?: '_self' | '_blank' | '_parent' | '_top' | (string & object);\n\n /**\n * Specifies the relationship between the [`href`](#href) and the current route.\n *\n * Common values:\n * - **nofollow**: Indicates to search engines that they should not follow the `href`.\n * This is often used for user-generated content or links that should not influence\n * search engine rankings.\n * - **noopener**: Suggests that the `href` should not have access to the opening\n * window's `window.opener` object, which is a security measure to prevent potentially\n * harmful behavior in cases of links that open new tabs or windows.\n * - **noreferrer**: Requests that the browser does not send the `Referer` HTTP header\n * when navigating to the `href`. This can enhance user privacy.\n *\n * The `rel` property is primarily used for informational and instructive purposes, helping browsers and web\n * crawlers make better decisions about how to handle and interpret the links on a web\n * page. It is important to use appropriate `rel` values to ensure that links behave as intended and adhere\n * to best practices for web development and SEO (Search Engine Optimization).\n *\n * This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @example\n * ```jsx\n * <Link href=\"https://expo.dev\" rel=\"nofollow\">Go to Expo</Link>`\n * ```\n */\n rel?: string;\n\n /**\n * Specifies that the [`href`](#href) should be downloaded when the user clicks on the\n * link, instead of navigating to it. It is typically used for links that point to\n * files that the user should download, such as PDFs, images, documents, and more.\n *\n * The value of the `download` property, which represents the filename for the\n * downloaded file. This property is passed to the underlying anchor (`<a>`) tag.\n *\n * @example\n * ```jsx\n * <Link href=\"/image.jpg\" download=\"my-image.jpg\">Download image</Link>\n * ```\n */\n download?: string;\n};\n\n// @docsMissing\nexport interface LinkProps extends Omit<TextProps, 'href'>, WebAnchorProps {\n /**\n * The path of the route to navigate to. It can either be:\n * - **string**: A full path like `/profile/settings` or a relative path like `../settings`.\n * - **object**: An object with a `pathname` and optional `params`. The `pathname` can be\n * a full path like `/profile/settings` or a relative path like `../settings`. The\n * params can be an object of key-value pairs.\n *\n * @example\n * ```tsx Dynamic\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link href=\"/about\">About</Link>\n * <Link\n * href={{\n * pathname: '/user/[id]',\n * params: { id: 'bacon' }\n * }}>\n * View user\n * </Link>\n * </View>\n * );\n *}\n * ```\n */\n href: Href;\n\n // TODO(EvanBacon): This may need to be extracted for React Native style support.\n /**\n * Used to customize the `Link` component. It will forward all props to the\n * first child of the `Link`. Note that the child component must accept\n * `onPress` or `onClick` props. The `href` and `role` are also\n * passed to the child.\n *\n * @example\n * ```tsx\n * import { Link } from 'expo-router';\n * import { Pressable, Text } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link href=\"/home\" asChild>\n * <Pressable>\n * <Text>Home</Text>\n * </Pressable>\n * </Link>\n * </View>\n * );\n *}\n * ```\n */\n asChild?: boolean;\n\n /**\n * Removes the current route from the history and replace it with the\n * specified URL. This is useful for [redirects](/router/reference/redirects/).\n *\n * @example\n *```tsx\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link replace href=\"/feed\">Login</Link>\n * </View>\n * );\n *}\n * ```\n */\n replace?: boolean;\n /**\n * Always pushes a new route, and never pops or replaces to existing route.\n * You can push the current route multiple times or with new parameters.\n *\n * @example\n *```tsx\n * import { Link } from 'expo-router';\n * import { View } from 'react-native';\n *\n * export default function Route() {\n * return (\n * <View>\n * <Link push href=\"/feed\">Login</Link>\n * </View>\n * );\n *}\n * ```\n */\n push?: boolean;\n\n /**\n * On native, this can be used with CSS interop tools like Nativewind.\n * On web, this sets the HTML `class` directly.\n */\n className?: string;\n\n onPress?: (e: MouseEvent<HTMLAnchorElement> | GestureResponderEvent) => void;\n\n /**\n * Relative URL references are either relative to the directory or the document.\n * By default, relative paths are relative to the document.\n *\n * @see [Resolving relative references in Mozilla's documentation](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Replaces the initial screen with the current route.\n */\n withAnchor?: boolean;\n}\n\n// Mutate the style prop to add the className on web.\nexport function useInteropClassName(props: { style?: TextProps['style']; className?: string }) {\n if (Platform.OS !== 'web') {\n return props.style;\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useMemo(() => {\n if (props.className == null) {\n return props.style;\n }\n const cssStyle = {\n $$css: true,\n __routerLinkClassName: props.className,\n };\n\n if (Array.isArray(props.style)) {\n return [...props.style, cssStyle];\n }\n return [props.style, cssStyle];\n }, [props.style, props.className]);\n}\n\nexport const useHrefAttrs = Platform.select<\n (props: Partial<LinkProps>) => { hrefAttrs?: any } & Partial<LinkProps>\n>({\n web: function useHrefAttrs({ asChild, rel, target, download }: Partial<LinkProps>) {\n return useMemo(() => {\n const hrefAttrs = {\n rel,\n target,\n download,\n };\n if (asChild) {\n return hrefAttrs;\n }\n return {\n hrefAttrs,\n };\n }, [asChild, rel, target, download]);\n },\n default: function useHrefAttrs() {\n return {};\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRootComponent.d.ts","sourceRoot":"","sources":["../src/renderRootComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderRootComponent.d.ts","sourceRoot":"","sources":["../src/renderRootComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA+C/B;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,QAwCtE"}
|
|
@@ -25,9 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.renderRootComponent = void 0;
|
|
27
27
|
const expo_1 = require("expo");
|
|
28
|
-
const SplashScreen = __importStar(require("expo-splash-screen"));
|
|
29
28
|
const React = __importStar(require("react"));
|
|
30
29
|
const react_native_1 = require("react-native");
|
|
30
|
+
const SplashScreen = __importStar(require("./utils/splash"));
|
|
31
31
|
function isBaseObject(obj) {
|
|
32
32
|
if (Object.prototype.toString.call(obj) !== '[object Object]') {
|
|
33
33
|
return false;
|
|
@@ -70,7 +70,6 @@ function renderRootComponent(Component) {
|
|
|
70
70
|
try {
|
|
71
71
|
// This must be delayed so the user has a chance to call it first.
|
|
72
72
|
setTimeout(() => {
|
|
73
|
-
// @ts-expect-error: This function is native-only and for internal-use only.
|
|
74
73
|
SplashScreen._internal_preventAutoHideAsync?.();
|
|
75
74
|
});
|
|
76
75
|
React.startTransition(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRootComponent.js","sourceRoot":"","sources":["../src/renderRootComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;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GG;AACH,SAAgB,mBAAmB,CAAC,SAAmC;IACrE,IAAI;QACF,kEAAkE;QAClE,UAAU,CAAC,GAAG,EAAE;YACd,YAAY,CAAC,8BAA8B,EAAE,EAAE,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,eAAe,CAAC,GAAG,EAAE;YACzB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;gBACzC,MAAM,EAAE,gBAAgB,EAAE,GACxB,OAAO,CAAC,mCAAmC,CAAuD,CAAC;gBACrG,IAAA,4BAAqB,EAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;aACpD;iBAAM;gBACL,IAAA,4BAAqB,EAAC,SAAS,CAAC,CAAC;aAClC;QACH,CAAC,CAAC,CAAC;KACJ;IAAC,OAAO,CAAC,EAAE;QACV,uEAAuE;QACvE,YAAY,CAAC,SAAS,EAAE,CAAC;QAEzB,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC9B,2CAA2C;QAC3C,mFAAmF;QACnF,yIAAyI;QACzI,+FAA+F;QAC/F,IAAA,4BAAqB,EAAC,GAAG,EAAE,CAAC,CAAC,mBAAI,CAAC,AAAD,EAAG,CAAC,CAAC;QAEtC,gFAAgF;QAChF,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK,EAAE;YACjC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACnF;QAED,+CAA+C;QAC/C,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,+CAA+C;KAChD;AACH,CAAC;AAxCD,kDAwCC","sourcesContent":["import { registerRootComponent } from 'expo';\nimport * as React from 'react';\nimport { View } from 'react-native';\n\nimport * as SplashScreen from './utils/splash';\n\nfunction isBaseObject(obj: any) {\n if (Object.prototype.toString.call(obj) !== '[object Object]') {\n return false;\n }\n const proto = Object.getPrototypeOf(obj);\n if (proto === null) {\n return true;\n }\n return proto === Object.prototype;\n}\n\nfunction isErrorShaped(error: any): error is Error {\n return (\n error &&\n typeof error === 'object' &&\n typeof error.name === 'string' &&\n typeof error.message === 'string'\n );\n}\n\n/**\n * After we throw this error, any number of tools could handle it.\n * This check ensures the error is always in a reason state before surfacing it to the runtime.\n */\nfunction convertError(error: any) {\n if (isErrorShaped(error)) {\n return error;\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (error == null) {\n return new Error('A null/undefined error was thrown.');\n }\n }\n\n if (isBaseObject(error)) {\n return new Error(JSON.stringify(error));\n }\n\n return new Error(String(error));\n}\n\n/**\n * Register and mount the root component using the predefined rendering\n * method. This function ensures the Splash Screen and errors are handled correctly.\n */\nexport function renderRootComponent(Component: React.ComponentType<any>) {\n try {\n // This must be delayed so the user has a chance to call it first.\n setTimeout(() => {\n SplashScreen._internal_preventAutoHideAsync?.();\n });\n\n React.startTransition(() => {\n if (process.env.NODE_ENV !== 'production') {\n const { withErrorOverlay } =\n require('@expo/metro-runtime/error-overlay') as typeof import('@expo/metro-runtime/error-overlay');\n registerRootComponent(withErrorOverlay(Component));\n } else {\n registerRootComponent(Component);\n }\n });\n } catch (e) {\n // Hide the splash screen if there was an error so the user can see it.\n SplashScreen.hideAsync();\n\n const error = convertError(e);\n // Prevent the app from throwing confusing:\n // ERROR Invariant Violation: \"main\" has not been registered. This can happen if:\n // * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.\n // * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.\n registerRootComponent(() => <View />);\n\n // Console is pretty useless on native, on web you get interactive stack traces.\n if (process.env.EXPO_OS === 'web') {\n console.error(error);\n console.error(`A runtime error has occurred while rendering the root component.`);\n }\n\n // Give React a tick to render before throwing.\n setTimeout(() => {\n throw error;\n });\n\n // TODO: Render a production-only error screen.\n }\n}\n"]}
|
package/build/rsc/exports.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ export declare function Slot(): import("react").JSX.Element;
|
|
|
13
13
|
export declare function Stack(): import("react").JSX.Element;
|
|
14
14
|
export declare function Tabs(): import("react").JSX.Element;
|
|
15
15
|
export declare function Navigator(): void;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Redirects to the `href` as soon as the component is mounted.
|
|
18
|
+
*/
|
|
17
19
|
export declare function Redirect({ href }: {
|
|
18
20
|
href: Href;
|
|
19
21
|
}): null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/rsc/exports.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,wBAAgB,WAAW,WAG1B;AAGD,wBAAgB,oBAAoB;;EAGnC;AAED,wBAAgB,qBAAqB;;EAGpC;AAED,wBAAgB,IAAI,gCAEnB;AAED,wBAAgB,KAAK,gCAGpB;AAED,wBAAgB,IAAI,gCAGnB;AAED,wBAAgB,SAAS,SAExB;AAED
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/rsc/exports.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,wBAAgB,WAAW,WAG1B;AAGD,wBAAgB,oBAAoB;;EAGnC;AAED,wBAAgB,qBAAqB;;EAGpC;AAED,wBAAgB,IAAI,gCAEnB;AAED,wBAAgB,KAAK,gCAGpB;AAED,wBAAgB,IAAI,gCAGnB;AAED,wBAAgB,SAAS,SAExB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,QAIhD;AAED,wBAAgB,QAAQ,SAEvB;AAED,wBAAgB,cAAc,SAE7B;AAED,wBAAgB,aAAa,SAE5B;AAED,wBAAgB,iBAAiB,SAEhC;AACD,wBAAgB,yBAAyB,SAExC;AAED,wBAAgB,WAAW,SAE1B;AACD,wBAAgB,iBAAiB,SAEhC;AACD,wBAAgB,sBAAsB,SAErC;AACD,wBAAgB,qBAAqB,SAEpC;AAED,OAAO,EAAE,kBAAkB,IAAI,SAAS,EAAE,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,eAAO,MAAM,MAAM,IASlB,CAAC"}
|
package/build/rsc/exports.js
CHANGED
|
@@ -40,7 +40,9 @@ function Navigator() {
|
|
|
40
40
|
throw new Error('Navigator is not implemented in React Server Components yet');
|
|
41
41
|
}
|
|
42
42
|
exports.Navigator = Navigator;
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Redirects to the `href` as soon as the component is mounted.
|
|
45
|
+
*/
|
|
44
46
|
function Redirect({ href }) {
|
|
45
47
|
const router = (0, client_1.useRouter_UNSTABLE)();
|
|
46
48
|
router.replace(href);
|