expo-router 0.0.19 → 0.0.21
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/ContextNavigationContainer.d.ts +3 -3
- package/build/ContextNavigationContainer.d.ts.map +1 -1
- package/build/ContextNavigationContainer.js +33 -12
- package/build/ContextNavigationContainer.js.map +1 -1
- package/build/ContextNavigator.d.ts +1 -1
- package/build/ContextNavigator.d.ts.map +1 -1
- package/build/ContextNavigator.js +8 -6
- package/build/ContextNavigator.js.map +1 -1
- package/build/Route.d.ts +1 -1
- package/build/Route.d.ts.map +1 -1
- package/build/Route.js +3 -3
- package/build/Route.js.map +1 -1
- package/build/aasa.js +1 -1
- package/build/aasa.js.map +1 -1
- package/build/fork/getPathFromState.d.ts +3 -3
- package/build/fork/getPathFromState.d.ts.map +1 -1
- package/build/fork/getPathFromState.js +9 -11
- package/build/fork/getPathFromState.js.map +1 -1
- package/build/fork/getStateFromPath.d.ts +3 -3
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +3 -4
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/getLinkingConfig.d.ts +3 -3
- package/build/getLinkingConfig.d.ts.map +1 -1
- package/build/getLinkingConfig.js +3 -3
- package/build/getLinkingConfig.js.map +1 -1
- package/build/getRoutes.d.ts.map +1 -1
- package/build/getRoutes.js.map +1 -1
- package/build/index.d.ts +3 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -3
- package/build/index.js.map +1 -1
- package/build/layouts/Drawer.d.ts +1 -1
- package/build/layouts/Drawer.d.ts.map +1 -1
- package/build/layouts/Drawer.js +2 -2
- package/build/layouts/Drawer.js.map +1 -1
- package/build/layouts/NativeStack.d.ts +1 -1
- package/build/layouts/NativeStack.d.ts.map +1 -1
- package/build/layouts/NativeStack.js +2 -2
- package/build/layouts/NativeStack.js.map +1 -1
- package/build/layouts/Stack.d.ts +1 -1
- package/build/layouts/Stack.d.ts.map +1 -1
- package/build/layouts/Stack.js +2 -2
- package/build/layouts/Stack.js.map +1 -1
- package/build/layouts/Tabs.d.ts +1 -1
- package/build/layouts/Tabs.d.ts.map +1 -1
- package/build/layouts/Tabs.js +2 -2
- package/build/layouts/Tabs.js.map +1 -1
- package/build/layouts/withLayoutContext.d.ts +2 -2
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js +10 -10
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +26 -0
- package/build/link/Link.d.ts.map +1 -0
- package/build/link/Link.js +40 -0
- package/build/link/Link.js.map +1 -0
- package/build/link/href.d.ts +9 -0
- package/build/link/href.d.ts.map +1 -0
- package/build/link/href.js +34 -0
- package/build/link/href.js.map +1 -0
- package/build/{linking.d.ts → link/linking.d.ts} +2 -2
- package/build/link/linking.d.ts.map +1 -0
- package/build/{linking.js → link/linking.js} +2 -2
- package/build/link/linking.js.map +1 -0
- package/build/{useLink.d.ts → link/useLink.d.ts} +2 -1
- package/build/link/useLink.d.ts.map +1 -0
- package/build/{useLink.js → link/useLink.js} +9 -4
- package/build/link/useLink.js.map +1 -0
- package/build/link/useLinkToPath.d.ts +2 -0
- package/build/link/useLinkToPath.d.ts.map +1 -0
- package/build/link/useLinkToPath.js +45 -0
- package/build/link/useLinkToPath.js.map +1 -0
- package/build/link/useLinkToPathProps.d.ts +11 -0
- package/build/link/useLinkToPathProps.d.ts.map +1 -0
- package/build/link/useLinkToPathProps.js +31 -0
- package/build/link/useLinkToPathProps.js.map +1 -0
- package/build/matchers.d.ts.map +1 -1
- package/build/matchers.js +2 -1
- package/build/matchers.js.map +1 -1
- package/build/onboard/Tutorial.d.ts.map +1 -1
- package/build/onboard/Tutorial.js +1 -1
- package/build/onboard/Tutorial.js.map +1 -1
- package/build/primitives.d.ts.map +1 -1
- package/build/primitives.js +1 -1
- package/build/primitives.js.map +1 -1
- package/build/useScreens.js +1 -1
- package/build/useScreens.js.map +1 -1
- package/build/views/Directory.d.ts.map +1 -1
- package/build/views/Directory.js +4 -4
- package/build/views/Directory.js.map +1 -1
- package/build/views/ErrorBoundary.d.ts +1 -1
- package/build/views/ErrorBoundary.d.ts.map +1 -1
- package/build/views/ErrorBoundary.js +56 -19
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Layout.d.ts +1 -1
- package/build/views/Layout.d.ts.map +1 -1
- package/build/views/Layout.js +1 -1
- package/build/views/Layout.js.map +1 -1
- package/build/views/Root.d.ts +1 -1
- package/build/views/Root.d.ts.map +1 -1
- package/build/views/Root.js +4 -3
- package/build/views/Root.js.map +1 -1
- package/build/views/Screen.d.ts +1 -1
- package/build/views/Screen.d.ts.map +1 -1
- package/build/views/Screen.js +2 -1
- package/build/views/Screen.js.map +1 -1
- package/build/views/Try.d.ts.map +1 -1
- package/build/views/Try.js.map +1 -1
- package/build/views/Unmatched.d.ts.map +1 -1
- package/build/views/Unmatched.js +3 -4
- package/build/views/Unmatched.js.map +1 -1
- package/package.json +2 -3
- package/build/linking.d.ts.map +0 -1
- package/build/linking.js.map +0 -1
- package/build/useLink.d.ts.map +0 -1
- package/build/useLink.js.map +0 -1
- package/build/views/Link.d.ts +0 -36
- package/build/views/Link.d.ts.map +0 -1
- package/build/views/Link.js +0 -87
- package/build/views/Link.js.map +0 -1
- package/metro-config.js +0 -14
package/build/views/Link.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// Fork of @react-navigation/native Link.tsx
|
|
2
|
-
import { Text } from "@bacons/react-views";
|
|
3
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
-
import { useLinkProps } from "@react-navigation/native";
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
import { Platform } from "react-native";
|
|
7
|
-
/**
|
|
8
|
-
* Component to render link to another screen using a path.
|
|
9
|
-
* Uses an anchor tag on the web.
|
|
10
|
-
*
|
|
11
|
-
* @param props.href Absolute path to screen (e.g. `/feeds/hot`).
|
|
12
|
-
* @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
|
|
13
|
-
* @param props.children Child elements to render the content.
|
|
14
|
-
*/
|
|
15
|
-
export const Link = React.forwardRef(BaseLink);
|
|
16
|
-
export const resolveHref = (href) => {
|
|
17
|
-
if (typeof href === "string") {
|
|
18
|
-
return href ?? "";
|
|
19
|
-
}
|
|
20
|
-
const path = href.pathname ?? "";
|
|
21
|
-
if (!href?.query) {
|
|
22
|
-
return path;
|
|
23
|
-
}
|
|
24
|
-
const { pathname, query } = createQualifiedPathname(path, { ...href.query });
|
|
25
|
-
return pathname + (Object.keys(query).length ? `?${createQuery(query)}` : "");
|
|
26
|
-
};
|
|
27
|
-
function createQualifiedPathname(pathname, query) {
|
|
28
|
-
for (const [key, value = ""] of Object.entries(query)) {
|
|
29
|
-
const dynamicKey = `[${key}]`;
|
|
30
|
-
const deepDynamicKey = `[...${key}]`;
|
|
31
|
-
if (pathname.includes(dynamicKey)) {
|
|
32
|
-
pathname = pathname.replace(dynamicKey, Array.isArray(value) ? value.join("/") : value);
|
|
33
|
-
}
|
|
34
|
-
else if (pathname.includes(deepDynamicKey)) {
|
|
35
|
-
pathname = pathname.replace(deepDynamicKey, Array.isArray(value) ? value.join("/") : value);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
delete query[key];
|
|
41
|
-
}
|
|
42
|
-
return { pathname, query };
|
|
43
|
-
}
|
|
44
|
-
function createQuery(query) {
|
|
45
|
-
return Object.keys(query)
|
|
46
|
-
.map((key) => `${key}=${query[key]}`)
|
|
47
|
-
.join("&");
|
|
48
|
-
}
|
|
49
|
-
function useResolvedHref({ href, to, }) {
|
|
50
|
-
// TODO: Auto use router's client-side event.
|
|
51
|
-
return React.useMemo(() => {
|
|
52
|
-
if (href) {
|
|
53
|
-
return resolveHref(href);
|
|
54
|
-
}
|
|
55
|
-
if (to == null) {
|
|
56
|
-
throw new Error(`You must specify either 'href' or 'to' prop in a <Link />.`);
|
|
57
|
-
}
|
|
58
|
-
if (typeof to === "string" && !to.startsWith("/")) {
|
|
59
|
-
// TODO: Auto delegate out external links
|
|
60
|
-
return "/";
|
|
61
|
-
}
|
|
62
|
-
return to;
|
|
63
|
-
}, [href, to]);
|
|
64
|
-
}
|
|
65
|
-
function BaseLink({ to, href, action, asChild, ...rest }, ref) {
|
|
66
|
-
// TODO: Auto use router's client-side event.
|
|
67
|
-
const resolvedTo = useResolvedHref({ href, to });
|
|
68
|
-
const props = useLinkProps({ to: resolvedTo, action });
|
|
69
|
-
const onPress = (e) => {
|
|
70
|
-
if ("onPress" in rest) {
|
|
71
|
-
rest.onPress?.(e);
|
|
72
|
-
}
|
|
73
|
-
props.onPress(e);
|
|
74
|
-
};
|
|
75
|
-
return React.createElement(
|
|
76
|
-
// @ts-expect-error: slot is not type-safe
|
|
77
|
-
asChild ? Slot : Text, {
|
|
78
|
-
ref,
|
|
79
|
-
...props,
|
|
80
|
-
...rest,
|
|
81
|
-
...Platform.select({
|
|
82
|
-
web: { onClick: onPress },
|
|
83
|
-
default: { onPress },
|
|
84
|
-
}),
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=Link.js.map
|
package/build/views/Link.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,IAAI,EAAa,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAyB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAsB/D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAE/C,M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,MAAM,EAAE,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,CACd,CAA0E,EAC1E,EAAE;QACF,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,OAAO,KAAK,CAAC,aAAa;IACxB,0CAA0C;IAC1C,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EACrB;QACE,GAAG;QACH,GAAG,KAAK;QACR,GAAG,IAAI;QACP,GAAG,QAAQ,CAAC,MAAM,CAAC;YACjB,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAS;YAChC,OAAO,EAAE,EAAE,OAAO,EAAE;SACrB,CAAC;KACH,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx\nimport { Text, TextProps } from \"@bacons/react-views\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useLinkProps } from \"@react-navigation/native\";\nimport * as React from \"react\";\nimport { GestureResponderEvent, Platform } from \"react-native\";\n\nimport type { NavigationAction } from \"@react-navigation/core\";\nimport type { To } from \"@react-navigation/native/src/useLinkTo\";\n\nexport type Href = string | { pathname?: string; query?: Record<string, any> };\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n /** Add a property which is familiar to */\n href?: Href;\n\n /** Forward props to child component. Useful for custom buttons. */\n asChild?: boolean;\n\n to?: To<ParamList>;\n action?: NavigationAction;\n target?: string;\n onPress?: (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => void;\n} & (TextProps & { children: React.ReactNode });\n\n/**\n * Component to render link to another screen using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.href Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.\n * @param props.children Child elements to render the content.\n */\nexport const Link = React.forwardRef(BaseLink);\n\nexport const resolveHref = (\n href: { pathname?: string; query?: Record<string, any> } | string\n): string => {\n if (typeof href === \"string\") {\n return href ?? \"\";\n }\n const path = href.pathname ?? \"\";\n if (!href?.query) {\n return path;\n }\n const { pathname, query } = createQualifiedPathname(path, { ...href.query });\n return pathname + (Object.keys(query).length ? `?${createQuery(query)}` : \"\");\n};\n\nfunction createQualifiedPathname(pathname: string, query: Record<string, any>) {\n for (const [key, value = \"\"] of Object.entries(query)) {\n const dynamicKey = `[${key}]`;\n const deepDynamicKey = `[...${key}]`;\n if (pathname.includes(dynamicKey)) {\n pathname = pathname.replace(\n dynamicKey,\n Array.isArray(value) ? value.join(\"/\") : value\n );\n } else if (pathname.includes(deepDynamicKey)) {\n pathname = pathname.replace(\n deepDynamicKey,\n Array.isArray(value) ? value.join(\"/\") : value\n );\n } else {\n continue;\n }\n\n delete query[key];\n }\n return { pathname, query };\n}\n\nfunction createQuery(query: Record<string, any>) {\n return Object.keys(query)\n .map((key) => `${key}=${query[key]}`)\n .join(\"&\");\n}\n\nfunction useResolvedHref<ParamList extends ReactNavigation.RootParamList>({\n href,\n to,\n}: Pick<Props<ParamList>, \"href\" | \"to\">) {\n // TODO: Auto use router's client-side event.\n return React.useMemo(() => {\n if (href) {\n return resolveHref(href);\n }\n\n if (to == null) {\n throw new Error(\n `You must specify either 'href' or 'to' prop in a <Link />.`\n );\n }\n if (typeof to === \"string\" && !to.startsWith(\"/\")) {\n // TODO: Auto delegate out external links\n return \"/\";\n }\n return to;\n }, [href, to]);\n}\n\nfunction BaseLink<ParamList extends ReactNavigation.RootParamList>(\n { to, href, action, asChild, ...rest }: Props<ParamList>,\n ref: React.ForwardedRef<Text>\n) {\n // TODO: Auto use router's client-side event.\n const resolvedTo = useResolvedHref({ href, to });\n\n const props = useLinkProps<ParamList>({ to: resolvedTo, action });\n\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if (\"onPress\" in rest) {\n rest.onPress?.(e);\n }\n props.onPress(e);\n };\n\n return React.createElement(\n // @ts-expect-error: slot is not type-safe\n asChild ? Slot : Text,\n {\n ref,\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n }\n );\n}\n"]}
|
package/metro-config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Learn more https://docs.expo.io/guides/customizing-metro
|
|
2
|
-
const { getDefaultConfig } = require("expo/metro-config");
|
|
3
|
-
|
|
4
|
-
module.exports.getDefaultConfig = (dirname) => {
|
|
5
|
-
const config = getDefaultConfig(dirname);
|
|
6
|
-
|
|
7
|
-
config.transformer = {
|
|
8
|
-
...config.transformer,
|
|
9
|
-
// `require.context` support
|
|
10
|
-
unstable_allowRequireContext: true,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
return config;
|
|
14
|
-
};
|