expo-router 0.0.13 → 0.0.14
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/index.d.ts +3 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -5
- package/build/index.js.map +1 -1
- package/build/onboard/Tutorial.d.ts.map +1 -1
- package/build/onboard/Tutorial.js +13 -5
- package/build/onboard/Tutorial.js.map +1 -1
- package/build/onboard/createEntryFile.js +2 -3
- package/build/onboard/createEntryFile.js.map +1 -1
- package/build/useLink.d.ts +7 -0
- package/build/useLink.d.ts.map +1 -0
- package/build/useLink.js +19 -0
- package/build/useLink.js.map +1 -0
- package/build/views/Link.d.ts +16 -6
- package/build/views/Link.d.ts.map +1 -1
- package/build/views/Link.js +53 -13
- package/build/views/Link.js.map +1 -1
- package/build/views/Unmatched.js +1 -1
- package/build/views/Unmatched.js.map +1 -1
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export { useRoutes } from "./Route";
|
|
2
|
-
export { useScreens } from "./useScreens";
|
|
3
1
|
export { ErrorBoundaryProps } from "./views/Try";
|
|
4
2
|
export { Stack } from "./layouts/Stack";
|
|
5
3
|
export { NativeStack } from "./layouts/NativeStack";
|
|
@@ -11,7 +9,7 @@ export { Unmatched } from "./views/Unmatched";
|
|
|
11
9
|
export { ErrorBoundary } from "./views/ErrorBoundary";
|
|
12
10
|
export { Layout, Children } from "./views/Layout";
|
|
13
11
|
export { Link } from "./views/Link";
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export * as Linking from
|
|
12
|
+
export { useLink } from "./useLink";
|
|
13
|
+
export { RootContainer } from "./ContextNavigationContainer";
|
|
14
|
+
export * as Linking from "./linking";
|
|
17
15
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { useRoutes } from "./Route";
|
|
2
|
-
export { useScreens } from "./useScreens";
|
|
1
|
+
// export { useRoutes } from "./Route";
|
|
2
|
+
// export { useScreens } from "./useScreens";
|
|
3
3
|
export { Stack } from "./layouts/Stack";
|
|
4
4
|
export { NativeStack } from "./layouts/NativeStack";
|
|
5
5
|
export { Tabs } from "./layouts/Tabs";
|
|
@@ -10,8 +10,8 @@ export { Unmatched } from "./views/Unmatched";
|
|
|
10
10
|
export { ErrorBoundary } from "./views/ErrorBoundary";
|
|
11
11
|
export { Layout, Children } from "./views/Layout";
|
|
12
12
|
export { Link } from "./views/Link";
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
import * as Linking_1 from
|
|
13
|
+
export { useLink } from "./useLink";
|
|
14
|
+
export { RootContainer } from "./ContextNavigationContainer";
|
|
15
|
+
import * as Linking_1 from "./linking";
|
|
16
16
|
export { Linking_1 as Linking };
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,6CAA6C;AAI7C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;2BAGpC,WAAW;sBAAxB,OAAO","sourcesContent":["// export { useRoutes } from \"./Route\";\n// export { useScreens } from \"./useScreens\";\n\nexport { ErrorBoundaryProps } from \"./views/Try\";\n\nexport { Stack } from \"./layouts/Stack\";\nexport { NativeStack } from \"./layouts/NativeStack\";\nexport { Tabs } from \"./layouts/Tabs\";\nexport { Drawer } from \"./layouts/Drawer\";\nexport { withLayoutContext } from \"./layouts/withLayoutContext\";\n\nexport { ExpoRoot } from \"./views/Root\";\nexport { Unmatched } from \"./views/Unmatched\";\nexport { ErrorBoundary } from \"./views/ErrorBoundary\";\n\nexport { Layout, Children } from \"./views/Layout\";\nexport { Link } from \"./views/Link\";\nexport { useLink } from \"./useLink\";\nexport { RootContainer } from \"./ContextNavigationContainer\";\n// export { useCurrentRoute } from \"./useCurrentRoute\";\n\nexport * as Linking from \"./linking\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tutorial.d.ts","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":";AAmCA,wBAAgB,QAAQ,
|
|
1
|
+
{"version":3,"file":"Tutorial.d.ts","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":";AAmCA,wBAAgB,QAAQ,gBAyDvB"}
|
|
@@ -26,7 +26,8 @@ export function Tutorial() {
|
|
|
26
26
|
if (typeof location !== "undefined" && location.pathname !== "/") {
|
|
27
27
|
location.replace("/");
|
|
28
28
|
}
|
|
29
|
-
if (typeof window !== "undefined" &&
|
|
29
|
+
if (typeof window !== "undefined" &&
|
|
30
|
+
typeof window.document !== "undefined") {
|
|
30
31
|
window.document.title = "npx expo start";
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -45,7 +46,7 @@ export function Tutorial() {
|
|
|
45
46
|
marginHorizontal: "auto",
|
|
46
47
|
alignItems: "stretch",
|
|
47
48
|
} },
|
|
48
|
-
React.createElement(View, {
|
|
49
|
+
React.createElement(View, { style: styles.container },
|
|
49
50
|
React.createElement(Header, null),
|
|
50
51
|
React.createElement(Text, { accessibilityRole: "header", accessibilityLevel: 2, style: styles.subtitle },
|
|
51
52
|
"Get started by creating a file",
|
|
@@ -65,15 +66,19 @@ function Button() {
|
|
|
65
66
|
...Platform.select({
|
|
66
67
|
native: {
|
|
67
68
|
position: "absolute",
|
|
68
|
-
bottom:
|
|
69
|
+
bottom: 24,
|
|
69
70
|
left: 24,
|
|
70
71
|
right: 24,
|
|
72
|
+
overflow: "hidden",
|
|
71
73
|
},
|
|
72
74
|
}),
|
|
73
75
|
} }, ({ pressed, hovered }) => (React.createElement(View, { style: [
|
|
74
76
|
{
|
|
75
77
|
transitionDuration: "200ms",
|
|
76
|
-
backgroundColor:
|
|
78
|
+
backgroundColor: Platform.select({
|
|
79
|
+
web: "transparent",
|
|
80
|
+
default: "white",
|
|
81
|
+
}),
|
|
77
82
|
borderColor: "white",
|
|
78
83
|
borderWidth: 2,
|
|
79
84
|
paddingVertical: 12,
|
|
@@ -91,7 +96,10 @@ function Button() {
|
|
|
91
96
|
fontSize: 18,
|
|
92
97
|
transitionDuration: "200ms",
|
|
93
98
|
fontWeight: "bold",
|
|
94
|
-
color:
|
|
99
|
+
color: Platform.select({
|
|
100
|
+
web: "white",
|
|
101
|
+
default: "black",
|
|
102
|
+
}),
|
|
95
103
|
},
|
|
96
104
|
styles.code,
|
|
97
105
|
hovered && { color: "black" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tutorial.js","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,sCAAsC;AACtC,SAAS,MAAM;
|
|
1
|
+
{"version":3,"file":"Tutorial.js","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC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,MAAM,CAAC;YAC1B,OAAO,EAAE,SAAS;YAClB,GAAG,EAAE,aAAa;YAClB,OAAO,EAAE,WAAW;SACrB,CAAC;KACH;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,OAAO;QACnB,aAAa,EAAE,EAAE;QACjB,QAAQ,EAAE,GAAG;KACd;CACF,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport { SafeAreaView, StatusBar, Platform } from \"react-native\";\nimport { View, Text, Pressable, StyleSheet } from \"@bacons/react-views\";\nimport { createEntryFileAsync } from \"./createEntryFile\";\n\n// TODO: Use openLinkFromBrowser thing\nfunction Header() {\n return (\n <Pressable>\n {({ hovered }) => (\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={1}\n style={[styles.title, Platform.OS !== \"web\" && { textAlign: \"left\" }]}\n >\n Welcome to{\" \"}\n <Text\n href=\"https://github.com/expo/expo-router/\"\n style={[\n hovered && {\n textDecorationColor: \"white\",\n textDecorationLine: \"underline\",\n },\n ]}\n >\n Expo\n </Text>\n </Text>\n )}\n </Pressable>\n );\n}\n\nconst canAutoTouchFile = process.env.EXPO_ROUTER_APP_ROOT != null;\n\nexport function Tutorial() {\n React.useEffect(() => {\n if (Platform.OS === \"web\") {\n // Reset the route on web so the initial route isn't a 404 after\n // the user has created the entry file.\n // This is useful for cases where you are testing the tutorial.\n // To test: touch the new file, then navigate to a missing route `/foobar`, then delete the app folder.\n // you should see the tutorial again and be able to create the entry file once more.\n if (typeof location !== \"undefined\" && location.pathname !== \"/\") {\n location.replace(\"/\");\n }\n if (\n typeof window !== \"undefined\" &&\n typeof window.document !== \"undefined\"\n ) {\n window.document.title = \"npx expo start\";\n }\n }\n }, []);\n\n return (\n <View\n style={{\n backgroundColor: \"black\",\n flex: 1,\n backgroundImage:\n \"radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 1px, transparent 0)\",\n backgroundPosition: \"-3px -3px\",\n backgroundSize: \"40px 40px\",\n }}\n >\n <StatusBar barStyle=\"light-content\" />\n\n <SafeAreaView\n style={{\n flex: 1,\n maxWidth: 960,\n marginHorizontal: \"auto\",\n alignItems: \"stretch\",\n }}\n >\n <View style={styles.container}>\n <Header />\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={2}\n style={styles.subtitle}\n >\n Get started by creating a file{\"\\n\"}in the{\" \"}\n <Text style={{ fontWeight: \"bold\" }}>app</Text> directory{\"\\n\"}that\n exports a React component.\n </Text>\n {canAutoTouchFile && <Button />}\n </View>\n </SafeAreaView>\n </View>\n );\n}\n\nfunction Button() {\n return (\n <Pressable\n onPress={() => {\n createEntryFileAsync();\n }}\n style={{\n ...Platform.select({\n native: {\n position: \"absolute\",\n bottom: 24,\n left: 24,\n right: 24,\n overflow: \"hidden\",\n },\n }),\n }}\n >\n {({ pressed, hovered }) => (\n <View\n style={[\n {\n transitionDuration: \"200ms\",\n backgroundColor: Platform.select({\n web: \"transparent\",\n default: \"white\",\n }),\n\n borderColor: \"white\",\n borderWidth: 2,\n paddingVertical: 12,\n paddingHorizontal: 24,\n },\n hovered && {\n backgroundColor: \"white\",\n },\n pressed && {\n backgroundColor: \"rgba(255,255,255,0.7)\",\n },\n ]}\n >\n <Text\n selectable={false}\n style={[\n {\n fontSize: 18,\n transitionDuration: \"200ms\",\n fontWeight: \"bold\",\n color: Platform.select({\n web: \"white\",\n default: \"black\",\n }),\n },\n styles.code,\n hovered && { color: \"black\" },\n ]}\n >\n <Text style={{ color: \"#BCC3CD\" }}>$</Text> touch app/index.js\n </Text>\n </View>\n )}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n padding: 24,\n alignItems: \"start\",\n justifyContent: \"center\",\n },\n title: {\n color: \"white\",\n fontSize: 64,\n paddingBottom: 24,\n fontWeight: \"bold\",\n },\n buttonText: {\n color: \"black\",\n },\n code: {\n fontFamily: Platform.select({\n default: \"Courier\",\n ios: \"Courier New\",\n android: \"monospace\",\n }),\n },\n subtitle: {\n color: \"#BCC3CD\",\n fontSize: 36,\n fontWeight: \"light\",\n paddingBottom: 36,\n maxWidth: 960,\n },\n});\n"]}
|
|
@@ -22,9 +22,7 @@ export default function Page() {
|
|
|
22
22
|
<View style={styles.container}>
|
|
23
23
|
<View style={styles.main}>
|
|
24
24
|
<Text style={styles.title}>Hello World</Text>
|
|
25
|
-
<Text style={styles.subtitle}>
|
|
26
|
-
This is the first page of your{"\\n"}native app, and website.
|
|
27
|
-
</Text>
|
|
25
|
+
<Text style={styles.subtitle}>This is the first page of your app.</Text>
|
|
28
26
|
</View>
|
|
29
27
|
</View>
|
|
30
28
|
);
|
|
@@ -34,6 +32,7 @@ const styles = StyleSheet.create({
|
|
|
34
32
|
container: {
|
|
35
33
|
flex: 1,
|
|
36
34
|
alignItems: "center",
|
|
35
|
+
padding: 24,
|
|
37
36
|
},
|
|
38
37
|
main: {
|
|
39
38
|
flex: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEntryFile.js","sourceRoot":"","sources":["../../src/onboard/createEntryFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,4DAA4D;AAC5D,MAAM,UAAU,oBAAoB;IAClC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,gBAAgB;QAChB,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO;KACR;IAED,+CAA+C;IAC/C,OAAO,KAAK,CAAC,YAAY,EAAE,CAAC,GAAG,GAAG,aAAa,EAAE;QAC/C,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,gBAAgB;SACvB,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED,MAAM,QAAQ,GAAG
|
|
1
|
+
{"version":3,"file":"createEntryFile.js","sourceRoot":"","sources":["../../src/onboard/createEntryFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,4DAA4D;AAC5D,MAAM,UAAU,oBAAoB;IAClC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,gBAAgB;QAChB,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO;KACR;IAED,+CAA+C;IAC/C,OAAO,KAAK,CAAC,YAAY,EAAE,CAAC,GAAG,GAAG,aAAa,EAAE;QAC/C,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,gBAAgB;SACvB,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkChB,CAAC","sourcesContent":["import { getDevServer } from \"../getDevServer\";\n\n/** Middleware for creating an entry file in the project. */\nexport function createEntryFileAsync() {\n if (process.env.NODE_ENV === \"production\") {\n // No dev server\n console.warn(\"createEntryFile() cannot be used in production\");\n return;\n }\n\n // Pings middleware in the Expo CLI dev server.\n return fetch(getDevServer().url + \"_expo/touch\", {\n method: \"POST\",\n body: JSON.stringify({\n contents: TEMPLATE,\n path: \"./app/index.js\",\n }),\n });\n}\n\nconst TEMPLATE = `import { StyleSheet, Text, View } from \"react-native\";\n\nexport default function Page() {\n return (\n <View style={styles.container}>\n <View style={styles.main}>\n <Text style={styles.title}>Hello World</Text>\n <Text style={styles.subtitle}>This is the first page of your app.</Text>\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n alignItems: \"center\",\n padding: 24,\n },\n main: {\n flex: 1,\n justifyContent: \"center\",\n maxWidth: 960,\n marginHorizontal: \"auto\",\n },\n title: {\n fontSize: 64,\n fontWeight: \"bold\",\n },\n subtitle: {\n fontSize: 36,\n color: \"#38434D\",\n },\n});\n`;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLink.d.ts","sourceRoot":"","sources":["../src/useLink.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGjD,wBAAgB,OAAO,IAAI;IACzB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,OAAO,WAAW,CAAC;CAC3B,CAiBA"}
|
package/build/useLink.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useLinkTo, useNavigation } from "@react-navigation/native";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { resolveHref } from "./views/Link";
|
|
4
|
+
// Wraps useLinkTo to provide an API which is similar to the Link component.
|
|
5
|
+
export function useLink() {
|
|
6
|
+
const linkTo = useLinkTo();
|
|
7
|
+
const navigation = useNavigation();
|
|
8
|
+
return useMemo(() => ({
|
|
9
|
+
push: (url) => {
|
|
10
|
+
const href = resolveHref(url);
|
|
11
|
+
linkTo(href);
|
|
12
|
+
},
|
|
13
|
+
back: () => navigation?.goBack(),
|
|
14
|
+
parse: resolveHref,
|
|
15
|
+
// TODO(EvanBacon): add `replace`, `pathname`, `query`, maybe `reload`
|
|
16
|
+
// TODO(EvanBacon): add `canGoBack` but maybe more like a `hasContext`
|
|
17
|
+
}), [navigation, linkTo]);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=useLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLink.js","sourceRoot":"","sources":["../src/useLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAQ,WAAW,EAAE,MAAM,cAAc,CAAC;AAEjD,4EAA4E;AAC5E,MAAM,UAAU,OAAO;IAKrB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IAEnC,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,CAAC,GAAS,EAAE,EAAE;YAClB,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;QACD,IAAI,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE;QAChC,KAAK,EAAE,WAAW;QAClB,sEAAsE;QACtE,sEAAsE;KACvE,CAAC,EACF,CAAC,UAAU,EAAE,MAAM,CAAC,CACrB,CAAC;AACJ,CAAC","sourcesContent":["import { useLinkTo, useNavigation } from \"@react-navigation/native\";\nimport { useMemo } from \"react\";\n\nimport { Href, resolveHref } from \"./views/Link\";\n\n// Wraps useLinkTo to provide an API which is similar to the Link component.\nexport function useLink(): {\n push: (href: Href) => void;\n back: () => void;\n parse: typeof resolveHref;\n} {\n const linkTo = useLinkTo();\n const navigation = useNavigation();\n\n return useMemo(\n () => ({\n push: (url: Href) => {\n const href = resolveHref(url);\n linkTo(href);\n },\n back: () => navigation?.goBack(),\n parse: resolveHref,\n // TODO(EvanBacon): add `replace`, `pathname`, `query`, maybe `reload`\n // TODO(EvanBacon): add `canGoBack` but maybe more like a `hasContext`\n }),\n [navigation, linkTo]\n );\n}\n"]}
|
package/build/views/Link.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from
|
|
3
|
-
import { GestureResponderEvent } from
|
|
4
|
-
import {
|
|
5
|
-
import type { To } from
|
|
1
|
+
import { TextProps } from "@bacons/react-views";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { GestureResponderEvent } from "react-native";
|
|
4
|
+
import type { NavigationAction } from "@react-navigation/core";
|
|
5
|
+
import type { To } from "@react-navigation/native/src/useLinkTo";
|
|
6
|
+
export declare type Href = string | {
|
|
7
|
+
pathname?: string;
|
|
8
|
+
query?: Record<string, any>;
|
|
9
|
+
};
|
|
6
10
|
declare type Props<ParamList extends ReactNavigation.RootParamList> = {
|
|
11
|
+
/** Add a property which is familiar to */
|
|
12
|
+
href?: Href;
|
|
13
|
+
/** Forward props to child component. Useful for custom buttons. */
|
|
7
14
|
asChild?: boolean;
|
|
8
|
-
href?: string;
|
|
9
15
|
to?: To<ParamList>;
|
|
10
16
|
action?: NavigationAction;
|
|
11
17
|
target?: string;
|
|
@@ -22,5 +28,9 @@ declare type Props<ParamList extends ReactNavigation.RootParamList> = {
|
|
|
22
28
|
* @param props.children Child elements to render the content.
|
|
23
29
|
*/
|
|
24
30
|
export declare const Link: React.ForwardRefExoticComponent<Pick<Props<ReactNavigation.RootParamList>, "children" | "key" | "action" | "allowFontScaling" | "ellipsizeMode" | "lineBreakMode" | "numberOfLines" | "onLayout" | "onTextLayout" | "onPress" | "onPressIn" | "onPressOut" | "onLongPress" | "testID" | "nativeID" | "maxFontSizeMultiplier" | "adjustsFontSizeToFit" | "minimumFontScale" | "suppressHighlighting" | "selectable" | "selectionColor" | "textBreakStrategy" | "dataDetectorType" | "android_hyphenationFrequency" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "asChild" | "to" | keyof import("@bacons/react-views/build/Text").WebTextProps> & React.RefAttributes<Text>>;
|
|
31
|
+
export declare const resolveHref: (href: {
|
|
32
|
+
pathname?: string;
|
|
33
|
+
query?: Record<string, any>;
|
|
34
|
+
} | string) => string;
|
|
25
35
|
export {};
|
|
26
36
|
//# sourceMappingURL=Link.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"mappings":"AACA,OAAO,EAAQ,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wCAAwC,CAAC;AAEjE,oBAAY,IAAI,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,CAAC;AAE/E,aAAK,KAAK,CAAC,SAAS,SAAS,eAAe,CAAC,aAAa,IAAI;IAC5D,2CAA2C;IAC3C,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;IACnB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,CACR,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,qBAAqB,KACvE,IAAI,CAAC;CACX,GAAG,CAAC,SAAS,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,29BAA6B,CAAC;AAE/C,eAAO,MAAM,WAAW,SAChB;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,GAAG,MAAM,KAChE,MAUF,CAAC"}
|
package/build/views/Link.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useLinkProps
|
|
5
|
-
import
|
|
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";
|
|
6
7
|
/**
|
|
7
8
|
* Component to render link to another screen using a path.
|
|
8
9
|
* Uses an anchor tag on the web.
|
|
@@ -12,22 +13,61 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
12
13
|
* @param props.children Child elements to render the content.
|
|
13
14
|
*/
|
|
14
15
|
export const Link = React.forwardRef(BaseLink);
|
|
15
|
-
|
|
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, }) {
|
|
16
50
|
// TODO: Auto use router's client-side event.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
51
|
+
return React.useMemo(() => {
|
|
52
|
+
if (href) {
|
|
53
|
+
return resolveHref(href);
|
|
54
|
+
}
|
|
55
|
+
if (to == null) {
|
|
20
56
|
throw new Error(`You must specify either 'href' or 'to' prop in a <Link />.`);
|
|
21
57
|
}
|
|
22
|
-
if (typeof
|
|
58
|
+
if (typeof to === "string" && !to.startsWith("/")) {
|
|
23
59
|
// TODO: Auto delegate out external links
|
|
24
|
-
return
|
|
60
|
+
return "/";
|
|
25
61
|
}
|
|
26
|
-
return
|
|
62
|
+
return to;
|
|
27
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 });
|
|
28
68
|
const props = useLinkProps({ to: resolvedTo, action });
|
|
29
69
|
const onPress = (e) => {
|
|
30
|
-
if (
|
|
70
|
+
if ("onPress" in rest) {
|
|
31
71
|
rest.onPress?.(e);
|
|
32
72
|
}
|
|
33
73
|
props.onPress(e);
|
package/build/views/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"m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EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACjD,yCAAyC;YACzC,OAAO,GAAG,CAAC;SACZ;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AACjB,CAAC;AAED,SAAS,QAAQ,CACf,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAoB,EACxD,GAA6B;IAE7B,6CAA6C;IAC7C,MAAM,UAAU,GAAG,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAEjD,MAAM,KAAK,GAAG,YAAY,CAAY,EAAE,EAAE,EAAE,UAAU,EAAE,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/build/views/Unmatched.js
CHANGED
|
@@ -8,7 +8,7 @@ export const Unmatched = forwardRef((props, ref) => {
|
|
|
8
8
|
const url = createURL("");
|
|
9
9
|
return (
|
|
10
10
|
// @ts-ignore
|
|
11
|
-
React.createElement(View, { ref: ref,
|
|
11
|
+
React.createElement(View, { ref: ref, style: styles.container },
|
|
12
12
|
React.createElement(Text, { accessibilityRole: "header", accessibilityLevel: 1, style: styles.title }, "Unmatched Route"),
|
|
13
13
|
React.createElement(Text, { accessibilityRole: "header", accessibilityLevel: 2, style: styles.subtitle },
|
|
14
14
|
"Page could not be found.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Unmatched.js","sourceRoot":"","sources":["../../src/views/Unmatched.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC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;;YAEG,GAAG;YAC5B,oBAAC,IAAI,IAAC,IAAI,EAAC,GAAG,EAAC,KAAK,EAAE,MAAM,CAAC,IAAI,eAE1B,CACJ;QAEP,oBAAC,IAAI,IAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,IAC9B,GAAG,CACD;QAEN,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,CACvC,oBAAC,IAAI,IAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,cAEnC,CACV,CACE,CACV,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC7B,SAAS,EAAE;QACP,IAAI,EAAE,CAAC;QACP,eAAe,EAAE,OAAO;QACxB,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KAC3B;IACD,KAAK,EAAE;QACH,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,aAAa,EAAE,EAAE;QACjB,YAAY,EAAE,EAAE;QAChB,iBAAiB,EAAE,SAAS;QAC5B,iBAAiB,EAAE,CAAC;QACpB,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,MAAM;KACrB;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,YAAY,EAAE,EAAE;QAChB,SAAS,EAAE,QAAQ;KACtB;IACD,IAAI,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,SAAS,EAAE,QAAQ,EAAE;CAChE,CAAC,CAAC","sourcesContent":["import React, { forwardRef } from \"react\";\nimport { createURL } from \"expo-linking\";\nimport { StyleSheet } from \"@bacons/react-views\";\nimport { Link } from \"./Link\";\nimport { Text, View } from \"@bacons/react-views\";\n\n/** Default screen for unmatched routes. */\nexport const Unmatched = forwardRef((props, ref) => {\n const url = createURL(\"\");\n return (\n // @ts-ignore\n <View ref={ref} style={styles.container}>\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={1}\n style={styles.title}\n >\n Unmatched Route\n </Text>\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={2}\n style={styles.subtitle}\n >\n Page could not be found.{\" \"}\n <Link href=\"/\" style={styles.link}>\n Go back.\n </Link>\n </Text>\n\n <Link href={\"/\"} style={styles.link}>\n {url}\n </Link>\n\n {process.env.NODE_ENV === \"development\" && (\n <Link href={\"/__index\"} style={styles.link}>\n Sitemap\n </Link>\n )}\n </View>\n );\n});\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n backgroundColor: \"black\",\n padding: 24,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n title: {\n color: \"white\",\n fontSize: 36,\n paddingBottom: 12,\n marginBottom: 12,\n borderBottomColor: \"#323232\",\n borderBottomWidth: 1,\n textAlign: \"center\",\n fontWeight: \"bold\",\n },\n subtitle: {\n color: \"white\",\n fontSize: 18,\n marginBottom: 12,\n textAlign: \"center\",\n },\n link: { color: \"rgba(255,255,255,0.4)\", textAlign: \"center\" },\n});\n"]}
|