expo-router 0.0.1
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/README.md +3 -0
- package/assets/file.png +0 -0
- package/assets/forward.png +0 -0
- package/assets/pkg.png +0 -0
- package/babel.js +77 -0
- package/build/ContextNavigationContainer.d.ts +33 -0
- package/build/ContextNavigationContainer.d.ts.map +1 -0
- package/build/ContextNavigationContainer.js +59 -0
- package/build/ContextNavigationContainer.js.map +1 -0
- package/build/ContextNavigator.d.ts +6 -0
- package/build/ContextNavigator.d.ts.map +1 -0
- package/build/ContextNavigator.js +52 -0
- package/build/ContextNavigator.js.map +1 -0
- package/build/Route.d.ts +34 -0
- package/build/Route.d.ts.map +1 -0
- package/build/Route.js +56 -0
- package/build/Route.js.map +1 -0
- package/build/aasa.d.ts +2 -0
- package/build/aasa.d.ts.map +1 -0
- package/build/aasa.js +25 -0
- package/build/aasa.js.map +1 -0
- package/build/context.d.ts +5 -0
- package/build/context.d.ts.map +1 -0
- package/build/context.js +14 -0
- package/build/context.js.map +1 -0
- package/build/fork/getPathFromState.d.ts +39 -0
- package/build/fork/getPathFromState.d.ts.map +1 -0
- package/build/fork/getPathFromState.js +209 -0
- package/build/fork/getPathFromState.js.map +1 -0
- package/build/fork/getStateFromPath.d.ts +33 -0
- package/build/fork/getStateFromPath.d.ts.map +1 -0
- package/build/fork/getStateFromPath.js +415 -0
- package/build/fork/getStateFromPath.js.map +1 -0
- package/build/getDevServer/index.d.ts +7 -0
- package/build/getDevServer/index.d.ts.map +1 -0
- package/build/getDevServer/index.js +30 -0
- package/build/getDevServer/index.js.map +1 -0
- package/build/getDevServer/index.native.d.ts +2 -0
- package/build/getDevServer/index.native.d.ts.map +1 -0
- package/build/getDevServer/index.native.js +2 -0
- package/build/getDevServer/index.native.js.map +1 -0
- package/build/getLinkingConfig.d.ts +5 -0
- package/build/getLinkingConfig.d.ts.map +1 -0
- package/build/getLinkingConfig.js +62 -0
- package/build/getLinkingConfig.js.map +1 -0
- package/build/getRoutes.d.ts +12 -0
- package/build/getRoutes.d.ts.map +1 -0
- package/build/getRoutes.js +165 -0
- package/build/getRoutes.js.map +1 -0
- package/build/index.d.ts +14 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +13 -0
- package/build/index.js.map +1 -0
- package/build/layouts/Drawer.d.ts +132 -0
- package/build/layouts/Drawer.d.ts.map +1 -0
- package/build/layouts/Drawer.js +5 -0
- package/build/layouts/Drawer.js.map +1 -0
- package/build/layouts/NativeStack.d.ts +132 -0
- package/build/layouts/NativeStack.d.ts.map +1 -0
- package/build/layouts/NativeStack.js +5 -0
- package/build/layouts/NativeStack.js.map +1 -0
- package/build/layouts/Stack.d.ts +156 -0
- package/build/layouts/Stack.d.ts.map +1 -0
- package/build/layouts/Stack.js +6 -0
- package/build/layouts/Stack.js.map +1 -0
- package/build/layouts/Tabs.d.ts +136 -0
- package/build/layouts/Tabs.d.ts.map +1 -0
- package/build/layouts/Tabs.js +6 -0
- package/build/layouts/Tabs.js.map +1 -0
- package/build/layouts/withLayoutContext.d.ts +16 -0
- package/build/layouts/withLayoutContext.d.ts.map +1 -0
- package/build/layouts/withLayoutContext.js +73 -0
- package/build/layouts/withLayoutContext.js.map +1 -0
- package/build/matchers.d.ts +8 -0
- package/build/matchers.d.ts.map +1 -0
- package/build/matchers.js +25 -0
- package/build/matchers.js.map +1 -0
- package/build/onboard/Tutorial.d.ts +3 -0
- package/build/onboard/Tutorial.d.ts.map +1 -0
- package/build/onboard/Tutorial.js +129 -0
- package/build/onboard/Tutorial.js.map +1 -0
- package/build/onboard/createEntryFile.d.ts +3 -0
- package/build/onboard/createEntryFile.d.ts.map +1 -0
- package/build/onboard/createEntryFile.js +54 -0
- package/build/onboard/createEntryFile.js.map +1 -0
- package/build/primitives.d.ts +19 -0
- package/build/primitives.d.ts.map +1 -0
- package/build/primitives.js +5 -0
- package/build/primitives.js.map +1 -0
- package/build/types.d.ts +11 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/build/useScreens.d.ts +10 -0
- package/build/useScreens.d.ts.map +1 -0
- package/build/useScreens.js +60 -0
- package/build/useScreens.js.map +1 -0
- package/build/views/Directory.d.ts +3 -0
- package/build/views/Directory.d.ts.map +1 -0
- package/build/views/Directory.js +142 -0
- package/build/views/Directory.js.map +1 -0
- package/build/views/ErrorBoundary.d.ts +4 -0
- package/build/views/ErrorBoundary.d.ts.map +1 -0
- package/build/views/ErrorBoundary.js +53 -0
- package/build/views/ErrorBoundary.js.map +1 -0
- package/build/views/Layout.d.ts +19 -0
- package/build/views/Layout.d.ts.map +1 -0
- package/build/views/Layout.js +48 -0
- package/build/views/Layout.js.map +1 -0
- package/build/views/Link.d.ts +26 -0
- package/build/views/Link.d.ts.map +1 -0
- package/build/views/Link.js +47 -0
- package/build/views/Link.js.map +1 -0
- package/build/views/Root.d.ts +6 -0
- package/build/views/Root.d.ts.map +1 -0
- package/build/views/Root.js +20 -0
- package/build/views/Root.js.map +1 -0
- package/build/views/Screen.d.ts +7 -0
- package/build/views/Screen.d.ts.map +1 -0
- package/build/views/Screen.js +19 -0
- package/build/views/Screen.js.map +1 -0
- package/build/views/Try.d.ts +24 -0
- package/build/views/Try.d.ts.map +1 -0
- package/build/views/Try.js +24 -0
- package/build/views/Try.js.map +1 -0
- package/build/views/Unmatched.d.ts +4 -0
- package/build/views/Unmatched.d.ts.map +1 -0
- package/build/views/Unmatched.js +46 -0
- package/build/views/Unmatched.js.map +1 -0
- package/entry.js +103 -0
- package/metro-config.js +14 -0
- package/package.json +62 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SafeAreaView, StatusBar, Platform } from "react-native";
|
|
3
|
+
import { View, Text, Pressable, StyleSheet } from "@bacons/react-views";
|
|
4
|
+
import { createEntryFileAsync } from "./createEntryFile";
|
|
5
|
+
function Header() {
|
|
6
|
+
return (React.createElement(Pressable, null, ({ hovered }) => (React.createElement(Text, { accessibilityRole: "heading", accessibilityLevel: 1, style: [styles.title, Platform.OS !== "web" && { textAlign: "left" }] },
|
|
7
|
+
"Welcome to",
|
|
8
|
+
" ",
|
|
9
|
+
React.createElement(Text, { href: "https://github.com/expo/expo/", style: [
|
|
10
|
+
hovered && {
|
|
11
|
+
textDecorationColor: "white",
|
|
12
|
+
textDecorationLine: "underline",
|
|
13
|
+
},
|
|
14
|
+
] }, "Expo")))));
|
|
15
|
+
}
|
|
16
|
+
export function Tutorial() {
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
// Reset the route on web so the initial route isn't a 404 after
|
|
19
|
+
// the user has created the entry file.
|
|
20
|
+
// This is useful for cases where you are testing the tutorial.
|
|
21
|
+
// To test: touch the new file, then navigate to a missing route `/foobar`, then delete the app folder.
|
|
22
|
+
// you should see the tutorial again and be able to create the entry file once more.
|
|
23
|
+
if (typeof location !== "undefined" && location.pathname !== "/") {
|
|
24
|
+
location.replace("/");
|
|
25
|
+
}
|
|
26
|
+
if (typeof window !== "undefined") {
|
|
27
|
+
window.document.title = "npx expo start";
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
return (React.createElement(View, { style: {
|
|
31
|
+
backgroundColor: "black",
|
|
32
|
+
flex: 1,
|
|
33
|
+
backgroundImage: "radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 1px, transparent 0)",
|
|
34
|
+
backgroundPosition: "-3px -3px",
|
|
35
|
+
backgroundSize: "40px 40px",
|
|
36
|
+
} },
|
|
37
|
+
React.createElement(StatusBar, { barStyle: "light-content" }),
|
|
38
|
+
React.createElement(SafeAreaView, { style: {
|
|
39
|
+
flex: 1,
|
|
40
|
+
maxWidth: 960,
|
|
41
|
+
marginHorizontal: "auto",
|
|
42
|
+
alignItems: "stretch",
|
|
43
|
+
} },
|
|
44
|
+
React.createElement(View, { accessibilityRole: "main", style: styles.container },
|
|
45
|
+
React.createElement(Header, null),
|
|
46
|
+
React.createElement(Text, { accessibilityRole: "heading", accessibilityLevel: 2, style: styles.subtitle },
|
|
47
|
+
"Get started by creating a file",
|
|
48
|
+
"\n",
|
|
49
|
+
"in the",
|
|
50
|
+
" ",
|
|
51
|
+
React.createElement(Text, { style: { fontWeight: "bold" } }, "app"),
|
|
52
|
+
" directory",
|
|
53
|
+
"\n",
|
|
54
|
+
"that exports a React component."),
|
|
55
|
+
React.createElement(Button, null)))));
|
|
56
|
+
}
|
|
57
|
+
function Button() {
|
|
58
|
+
return (React.createElement(Pressable, { onPress: () => {
|
|
59
|
+
createEntryFileAsync();
|
|
60
|
+
}, style: {
|
|
61
|
+
...Platform.select({
|
|
62
|
+
native: {
|
|
63
|
+
position: "absolute",
|
|
64
|
+
bottom: 8,
|
|
65
|
+
left: 24,
|
|
66
|
+
right: 24,
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
} }, ({ pressed, hovered }) => (React.createElement(View, { style: [
|
|
70
|
+
{
|
|
71
|
+
transitionDuration: "200ms",
|
|
72
|
+
backgroundColor: "transparent",
|
|
73
|
+
borderColor: "white",
|
|
74
|
+
borderWidth: 2,
|
|
75
|
+
paddingVertical: 12,
|
|
76
|
+
paddingHorizontal: 24,
|
|
77
|
+
},
|
|
78
|
+
hovered && {
|
|
79
|
+
backgroundColor: "white",
|
|
80
|
+
},
|
|
81
|
+
pressed && {
|
|
82
|
+
backgroundColor: "rgba(255,255,255,0.7)",
|
|
83
|
+
},
|
|
84
|
+
] },
|
|
85
|
+
React.createElement(Text, { selectable: false, style: [
|
|
86
|
+
{
|
|
87
|
+
fontSize: 18,
|
|
88
|
+
transitionDuration: "200ms",
|
|
89
|
+
fontWeight: "bold",
|
|
90
|
+
color: "white",
|
|
91
|
+
},
|
|
92
|
+
styles.code,
|
|
93
|
+
hovered && { color: "black" },
|
|
94
|
+
] },
|
|
95
|
+
React.createElement(Text, { style: { color: "#BCC3CD" } }, "$"),
|
|
96
|
+
" touch app/index.js")))));
|
|
97
|
+
}
|
|
98
|
+
const styles = StyleSheet.create({
|
|
99
|
+
container: {
|
|
100
|
+
flex: 1,
|
|
101
|
+
padding: 24,
|
|
102
|
+
alignItems: "start",
|
|
103
|
+
justifyContent: "center",
|
|
104
|
+
},
|
|
105
|
+
title: {
|
|
106
|
+
color: "white",
|
|
107
|
+
fontSize: 64,
|
|
108
|
+
paddingBottom: 24,
|
|
109
|
+
fontWeight: "bold",
|
|
110
|
+
},
|
|
111
|
+
buttonText: {
|
|
112
|
+
color: "black",
|
|
113
|
+
},
|
|
114
|
+
code: {
|
|
115
|
+
fontFamily: Platform.select({
|
|
116
|
+
default: "Courier",
|
|
117
|
+
ios: "Courier New",
|
|
118
|
+
android: "monospace",
|
|
119
|
+
}),
|
|
120
|
+
},
|
|
121
|
+
subtitle: {
|
|
122
|
+
color: "#BCC3CD",
|
|
123
|
+
fontSize: 36,
|
|
124
|
+
fontWeight: "light",
|
|
125
|
+
paddingBottom: 36,
|
|
126
|
+
maxWidth: 960,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=Tutorial.js.map
|
|
@@ -0,0 +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,SAAS,MAAM;IACX,OAAO,CACH,oBAAC,SAAS,QACL,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CACd,oBAAC,IAAI,IACD,iBAAiB,EAAC,SAAS,EAC3B,kBAAkB,EAAE,CAAC,EACrB,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,QAA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EAAE,QAAU;kCACxC,CACJ,CACV,CACO,CACf,CAAC;AACN,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC7B,SAAS,EAAE;QACP,IAAI,EAAE,CAAC;QACP,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,OAAO;QACnB,cAAc,EAAE,QAAQ;KAC3B;IACD,KAAK,EAAE;QACH,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,aAAa,EAAE,EAAE;QACjB,UAAU,EAAE,MAAM;KACrB;IACD,UAAU,EAAE;QACR,KAAK,EAAE,OAAO;KACjB;IACD,IAAI,EAAE;QACF,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC;YACxB,OAAO,EAAE,SAAS;YAClB,GAAG,EAAE,aAAa;YAClB,OAAO,EAAE,WAAW;SACvB,CAAC;KACL;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,OAAO;QACnB,aAAa,EAAE,EAAE;QACjB,QAAQ,EAAE,GAAG;KAChB;CACJ,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\nfunction Header() {\n return (\n <Pressable>\n {({ hovered }) => (\n <Text\n accessibilityRole=\"heading\"\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/\"\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\nexport function Tutorial() {\n React.useEffect(() => {\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 (typeof window !== \"undefined\") {\n window.document.title = \"npx expo start\";\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 accessibilityRole=\"main\" style={styles.container}>\n <Header />\n <Text\n accessibilityRole=\"heading\"\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 <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: 8,\n left: 24,\n right: 24,\n },\n }),\n }}\n >\n {({ pressed, hovered }) => (\n <View\n style={[\n {\n transitionDuration: \"200ms\",\n backgroundColor: \"transparent\",\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: \"white\",\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEntryFile.d.ts","sourceRoot":"","sources":["../../src/onboard/createEntryFile.ts"],"names":[],"mappings":"AAEA,4DAA4D;AAC5D,wBAAgB,oBAAoB,kCAenC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getDevServer } from "../getDevServer";
|
|
2
|
+
/** Middleware for creating an entry file in the project. */
|
|
3
|
+
export function createEntryFileAsync() {
|
|
4
|
+
if (process.env.NODE_ENV === "production") {
|
|
5
|
+
// No dev server
|
|
6
|
+
console.warn("createEntryFile() cannot be used in production");
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
// Pings middleware in the Expo CLI dev server.
|
|
10
|
+
return fetch(getDevServer().url + "_expo/touch", {
|
|
11
|
+
method: "POST",
|
|
12
|
+
body: JSON.stringify({
|
|
13
|
+
contents: TEMPLATE,
|
|
14
|
+
path: "./app/index.js",
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const TEMPLATE = `import { StyleSheet, Text, View } from "react-native";
|
|
19
|
+
|
|
20
|
+
export default function Page() {
|
|
21
|
+
return (
|
|
22
|
+
<View style={styles.container}>
|
|
23
|
+
<View style={styles.main}>
|
|
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>
|
|
28
|
+
</View>
|
|
29
|
+
</View>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const styles = StyleSheet.create({
|
|
34
|
+
container: {
|
|
35
|
+
flex: 1,
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
},
|
|
38
|
+
main: {
|
|
39
|
+
flex: 1,
|
|
40
|
+
justifyContent: "center",
|
|
41
|
+
maxWidth: 960,
|
|
42
|
+
marginHorizontal: "auto",
|
|
43
|
+
},
|
|
44
|
+
title: {
|
|
45
|
+
fontSize: 64,
|
|
46
|
+
fontWeight: "bold",
|
|
47
|
+
},
|
|
48
|
+
subtitle: {
|
|
49
|
+
fontSize: 36,
|
|
50
|
+
color: "#38434D",
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
`;
|
|
54
|
+
//# sourceMappingURL=createEntryFile.js.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmChB,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}>\n This is the first page of your{\"\\\\n\"}native app, and website.\n </Text>\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n alignItems: \"center\",\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,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Screen: <RouteName extends string>(_: import("@react-navigation/core").RouteConfig<import("@react-navigation/core").ParamListBase, RouteName, Readonly<{
|
|
3
|
+
key: string;
|
|
4
|
+
index: number;
|
|
5
|
+
routeNames: string[];
|
|
6
|
+
history?: unknown[] | undefined;
|
|
7
|
+
routes: (Readonly<{
|
|
8
|
+
key: string;
|
|
9
|
+
name: string;
|
|
10
|
+
path?: string | undefined;
|
|
11
|
+
}> & Readonly<{
|
|
12
|
+
params?: Readonly<object | undefined>;
|
|
13
|
+
}> & {
|
|
14
|
+
state?: Readonly<any> | import("@react-navigation/core").PartialState<Readonly<any>> | undefined;
|
|
15
|
+
})[];
|
|
16
|
+
type: string;
|
|
17
|
+
stale: false;
|
|
18
|
+
}>, {}, import("@react-navigation/core").EventMapBase>) => null, Group: import("react").ComponentType<import("@react-navigation/core").RouteGroupConfig<import("@react-navigation/core").ParamListBase, {}>>;
|
|
19
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAQ,MAAM;;;;;;;;;;;;;;;;iEAAE,KAAK,sIAAwC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createNavigatorFactory } from '@react-navigation/core';
|
|
2
|
+
// `@react-navigation/core` does not expose the Screen or Group components directly, so we have to
|
|
3
|
+
// do this hack.
|
|
4
|
+
export const { Screen, Group } = createNavigatorFactory({})();
|
|
5
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,kGAAkG;AAClG,gBAAgB;AAChB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,sBAAsB,CAAC,EAAS,CAAC,EAAE,CAAC","sourcesContent":["\nimport { createNavigatorFactory } from '@react-navigation/core';\n\n// `@react-navigation/core` does not expose the Screen or Group components directly, so we have to\n// do this hack.\nexport const { Screen, Group } = createNavigatorFactory({} as any)();\n"]}
|
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface RequireContext {
|
|
2
|
+
/** Return the keys that can be resolved. */
|
|
3
|
+
keys(): string[];
|
|
4
|
+
(id: string): any;
|
|
5
|
+
<T>(id: string): T;
|
|
6
|
+
/** **Unimplemented:** Return the module identifier for a user request. */
|
|
7
|
+
resolve(id: string): string;
|
|
8
|
+
/** **Unimplemented:** Readable identifier for the context module. */
|
|
9
|
+
id: string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAC;IAClB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;IACnB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;CACZ"}
|
package/build/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["// TODO: Use the global type\nexport interface RequireContext {\n /** Return the keys that can be resolved. */\n keys(): string[];\n (id: string): any;\n <T>(id: string): T;\n /** **Unimplemented:** Return the module identifier for a user request. */\n resolve(id: string): string;\n /** **Unimplemented:** Readable identifier for the context module. */\n id: string;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @returns React Navigation screens for the route.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useScreens(): React.ReactNode[];
|
|
6
|
+
/**
|
|
7
|
+
* @returns React Navigation screens sorted by the `route` property.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useScreensRecord(): Record<string, React.ReactNode>;
|
|
10
|
+
//# sourceMappingURL=useScreens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScreens.d.ts","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAmB1B;;GAEG;AACH,wBAAgB,UAAU,IAAI,KAAK,CAAC,SAAS,EAAE,CAG9C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAKlE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Screen } from './primitives';
|
|
3
|
+
import { Route, useRoutes } from './Route';
|
|
4
|
+
import { Try } from './views/Try';
|
|
5
|
+
function formatDynamicProps(path, dynamic) {
|
|
6
|
+
// Remove the first slash
|
|
7
|
+
const sanitized = path.replace(/^\//, "");
|
|
8
|
+
if (dynamic.deep) {
|
|
9
|
+
return [dynamic.name, sanitized.split("/").map((value) => value || "/")];
|
|
10
|
+
}
|
|
11
|
+
return [dynamic.name, sanitized];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @returns React Navigation screens for the route.
|
|
15
|
+
*/
|
|
16
|
+
export function useScreens() {
|
|
17
|
+
const children = useRoutes();
|
|
18
|
+
return React.useMemo(() => children.map((value) => routeToScreen(value)), [children]);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @returns React Navigation screens sorted by the `route` property.
|
|
22
|
+
*/
|
|
23
|
+
export function useScreensRecord() {
|
|
24
|
+
const children = useRoutes();
|
|
25
|
+
return React.useMemo(() => Object.fromEntries(children.map((value) => [value.route, routeToScreen(value)])), [children]);
|
|
26
|
+
}
|
|
27
|
+
/** Wrap the component with various enhancements and add access to child routes. */
|
|
28
|
+
function getQualifiedRouteComponent(value) {
|
|
29
|
+
// console.log('getQualifiedRouteComponent:', value)
|
|
30
|
+
const getDynamicProps = !value.dynamic
|
|
31
|
+
? () => ([])
|
|
32
|
+
: (path) => {
|
|
33
|
+
if (path == null) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return formatDynamicProps(path, value.dynamic);
|
|
37
|
+
};
|
|
38
|
+
const Component = value.getComponent();
|
|
39
|
+
const { ErrorBoundary } = value.getExtras();
|
|
40
|
+
const QualifiedRoute = React.forwardRef((props, ref) => {
|
|
41
|
+
// Surface dynamic name as props to the view
|
|
42
|
+
// const [dynamicKey, dynamicValue] = React.useMemo(
|
|
43
|
+
// () => getDynamicProps(props.route?.path),
|
|
44
|
+
// [props.route?.path]
|
|
45
|
+
// );
|
|
46
|
+
const children = React.createElement(Component, {
|
|
47
|
+
...props,
|
|
48
|
+
ref,
|
|
49
|
+
// [dynamicKey]: dynamicValue,
|
|
50
|
+
});
|
|
51
|
+
const errorBoundary = ErrorBoundary ? (React.createElement(Try, { catch: ErrorBoundary }, children)) : (children);
|
|
52
|
+
return (React.createElement(Route, { filename: value.contextKey }, errorBoundary));
|
|
53
|
+
});
|
|
54
|
+
QualifiedRoute.displayName = `Route(${Component.displayName || Component.name || value.route})`;
|
|
55
|
+
return QualifiedRoute;
|
|
56
|
+
}
|
|
57
|
+
function routeToScreen(route) {
|
|
58
|
+
return (React.createElement(Screen, { name: route.screenName, key: route.route, component: getQualifiedRouteComponent(route) }));
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=useScreens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScreens.js","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,KAAK,EAAa,SAAS,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,SAAS,kBAAkB,CACvB,IAAY,EACZ,OAAwC;IAExC,yBAAyB;IACzB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAE1C,IAAI,OAAO,CAAC,IAAI,EAAE;QACd,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,K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,CAAC,UAAU,CACnC,CAAC,KAAsC,EAAE,GAAQ,EAAE,EAAE;QACjD,4CAA4C;QAC5C,oDAAoD;QACpD,gDAAgD;QAChD,0BAA0B;QAC1B,KAAK;QAEL,MAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE;YAC5C,GAAG,KAAK;YACR,GAAG;YACH,8BAA8B;SACjC,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,aAAa,CAAC,CAAC,CAAC,CAClC,oBAAC,GAAG,IAAC,KAAK,EAAE,aAAa,IAAG,QAAQ,CAAO,CAC9C,CAAC,CAAC,CAAC,CACA,QAAQ,CACX,CAAC;QAEF,OAAO,CACH,oBAAC,KAAK,IAAC,QAAQ,EAAE,KAAK,CAAC,UAAU,IAC5B,aAAa,CACV,CACX,CAAC;IACN,CAAC,CACJ,CAAC;IAEF,cAAc,CAAC,WAAW,GAAG,SAAS,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC;IAEhG,OAAO,cAAc,CAAC;AAC1B,CAAC;AAED,SAAS,aAAa,CAAC,KAAgB;IACnC,OAAO,CACH,oBAAC,MAAM,IACH,IAAI,EAAE,KAAK,CAAC,UAAU,EACtB,GAAG,EAAE,KAAK,CAAC,KAAK,EAChB,SAAS,EAAE,0BAA0B,CAAC,KAAK,CAAC,GAC9C,CACL,CAAC;AACN,CAAC","sourcesContent":["import React from 'react';\n\nimport { Screen } from './primitives';\nimport { Route, RouteNode, useRoutes } from './Route';\nimport { Try } from './views/Try';\n\nfunction formatDynamicProps(\n path: string,\n dynamic: { name: string; deep: boolean }\n): [string, string | string[]] {\n // Remove the first slash\n const sanitized = path.replace(/^\\//, \"\");\n\n if (dynamic.deep) {\n return [dynamic.name, sanitized.split(\"/\").map((value) => value || \"/\")]\n }\n return [dynamic.name, sanitized]\n}\n\n/**\n * @returns React Navigation screens for the route.\n */\nexport function useScreens(): React.ReactNode[] {\n const children = useRoutes();\n return React.useMemo(() => children.map((value) => routeToScreen(value)), [children]);\n}\n\n/** \n * @returns React Navigation screens sorted by the `route` property.\n */\nexport function useScreensRecord(): Record<string, React.ReactNode> {\n const children = useRoutes();\n return React.useMemo(() => Object.fromEntries(\n children.map((value) => [value.route, routeToScreen(value)])\n ), [children]);\n}\n\n/** Wrap the component with various enhancements and add access to child routes. */\nfunction getQualifiedRouteComponent(value: RouteNode) {\n // console.log('getQualifiedRouteComponent:', value)\n const getDynamicProps = !value.dynamic\n ? () => ([])\n : (path?: string | null) => {\n if (path == null) {\n return [];\n }\n return formatDynamicProps(path, value.dynamic!);\n };\n\n\n const Component = value.getComponent();\n\n const { ErrorBoundary } = value.getExtras();\n\n const QualifiedRoute = React.forwardRef(\n (props: { route: any; navigation: any }, ref: any) => {\n // Surface dynamic name as props to the view\n // const [dynamicKey, dynamicValue] = React.useMemo(\n // () => getDynamicProps(props.route?.path),\n // [props.route?.path]\n // );\n\n const children = React.createElement(Component, {\n ...props,\n ref,\n // [dynamicKey]: dynamicValue,\n });\n\n const errorBoundary = ErrorBoundary ? (\n <Try catch={ErrorBoundary}>{children}</Try>\n ) : (\n children\n );\n\n return (\n <Route filename={value.contextKey}>\n {errorBoundary}\n </Route>\n );\n }\n );\n\n QualifiedRoute.displayName = `Route(${Component.displayName || Component.name || value.route})`;\n\n return QualifiedRoute;\n}\n\nfunction routeToScreen(route: RouteNode) {\n return (\n <Screen\n name={route.screenName}\n key={route.route}\n component={getQualifiedRouteComponent(route)}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Directory.d.ts","sourceRoot":"","sources":["../../src/views/Directory.tsx"],"names":[],"mappings":";AAyEA,wBAAgB,SAAS,gBAwDxB"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Image, Pressable, StyleSheet, Text, View } from "@bacons/react-views";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ScrollView, StatusBar, useWindowDimensions } from "react-native";
|
|
4
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
|
+
import { useRoutesContext } from "../context";
|
|
6
|
+
import { NativeStack } from "../layouts/NativeStack";
|
|
7
|
+
import { matchFragmentName } from "../matchers";
|
|
8
|
+
import { Link } from "./Link";
|
|
9
|
+
const INDENT = 18;
|
|
10
|
+
function useSortedRoutes() {
|
|
11
|
+
const ctx = useRoutesContext();
|
|
12
|
+
const routes = React.useMemo(() => ctx
|
|
13
|
+
.filter((route) => !route.internal)
|
|
14
|
+
.sort((a, b) => {
|
|
15
|
+
// Emulate vscode's sorting
|
|
16
|
+
if (a.route < b.route) {
|
|
17
|
+
return -1;
|
|
18
|
+
}
|
|
19
|
+
if (a.route > b.route) {
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
return 0;
|
|
23
|
+
}), [ctx]);
|
|
24
|
+
return routes;
|
|
25
|
+
}
|
|
26
|
+
const styles = StyleSheet.create({
|
|
27
|
+
container: {
|
|
28
|
+
backgroundColor: "black",
|
|
29
|
+
flex: 1,
|
|
30
|
+
alignItems: "stretch",
|
|
31
|
+
},
|
|
32
|
+
main: {
|
|
33
|
+
marginHorizontal: "auto",
|
|
34
|
+
flex: 1,
|
|
35
|
+
alignItems: "stretch",
|
|
36
|
+
},
|
|
37
|
+
scroll: {
|
|
38
|
+
padding: 12,
|
|
39
|
+
flex: 1,
|
|
40
|
+
// paddingTop: top + 12,
|
|
41
|
+
alignItems: "stretch",
|
|
42
|
+
},
|
|
43
|
+
itemContainer: {
|
|
44
|
+
borderWidth: 1,
|
|
45
|
+
borderColor: "#323232",
|
|
46
|
+
borderRadius: 19,
|
|
47
|
+
marginBottom: 12,
|
|
48
|
+
overflow: "hidden",
|
|
49
|
+
},
|
|
50
|
+
itemPressable: {
|
|
51
|
+
paddingHorizontal: INDENT,
|
|
52
|
+
paddingVertical: 16,
|
|
53
|
+
flexDirection: "row",
|
|
54
|
+
justifyContent: "space-between",
|
|
55
|
+
alignItems: "center",
|
|
56
|
+
transitionDuration: "100ms",
|
|
57
|
+
},
|
|
58
|
+
filename: { color: "white", fontSize: 20, marginLeft: 12 },
|
|
59
|
+
virtual: { textAlign: "right", color: "white" },
|
|
60
|
+
image: { width: 24, height: 24, resizeMode: "contain" },
|
|
61
|
+
});
|
|
62
|
+
export function Directory() {
|
|
63
|
+
const routes = useSortedRoutes();
|
|
64
|
+
const { bottom } = useSafeAreaInsets();
|
|
65
|
+
const { width } = useWindowDimensions();
|
|
66
|
+
return (React.createElement(View, { style: styles.container },
|
|
67
|
+
React.createElement(NativeStack.Screen, { options: {
|
|
68
|
+
title: "Index",
|
|
69
|
+
headerShown: true,
|
|
70
|
+
presentation: "modal",
|
|
71
|
+
animation: "default",
|
|
72
|
+
headerLargeTitle: true,
|
|
73
|
+
headerTitleStyle: {
|
|
74
|
+
color: "white",
|
|
75
|
+
},
|
|
76
|
+
headerTintColor: "white",
|
|
77
|
+
headerLargeTitleStyle: {
|
|
78
|
+
color: "white",
|
|
79
|
+
},
|
|
80
|
+
headerStyle: {
|
|
81
|
+
backgroundColor: "black",
|
|
82
|
+
// @ts-expect-error: mistyped
|
|
83
|
+
borderBottomColor: "#323232",
|
|
84
|
+
},
|
|
85
|
+
} }),
|
|
86
|
+
React.createElement(StatusBar, { barStyle: "light-content" }),
|
|
87
|
+
React.createElement(View, { style: [
|
|
88
|
+
styles.main,
|
|
89
|
+
{
|
|
90
|
+
minWidth: Math.min(960, width * 0.9),
|
|
91
|
+
},
|
|
92
|
+
] },
|
|
93
|
+
React.createElement(ScrollView, { contentInsetAdjustmentBehavior: "automatic", contentContainerStyle: [
|
|
94
|
+
styles.scroll,
|
|
95
|
+
{
|
|
96
|
+
paddingBottom: bottom + 12,
|
|
97
|
+
},
|
|
98
|
+
], style: { flex: 1 } }, routes.map((child) => (React.createElement(View, { key: child.contextKey, style: styles.itemContainer },
|
|
99
|
+
React.createElement(FileItem, { route: child }))))))));
|
|
100
|
+
}
|
|
101
|
+
function FileItem({ route, level = 0, parents = [], }) {
|
|
102
|
+
const disabled = route.children.length > 0;
|
|
103
|
+
const href = React.useMemo(() => {
|
|
104
|
+
return ("/" +
|
|
105
|
+
[...parents, route.route]
|
|
106
|
+
.map((v) => {
|
|
107
|
+
// groups and index must be erased
|
|
108
|
+
return !!matchFragmentName(v) || v === "index" ? "" : v;
|
|
109
|
+
})
|
|
110
|
+
.filter(Boolean)
|
|
111
|
+
.join("/"));
|
|
112
|
+
}, [parents, route.route]);
|
|
113
|
+
return (React.createElement(React.Fragment, null,
|
|
114
|
+
React.createElement(Link, { href: href, disabled: disabled, asChild: true },
|
|
115
|
+
React.createElement(Pressable, null, ({ pressed, hovered }) => (React.createElement(View, { style: [
|
|
116
|
+
styles.itemPressable,
|
|
117
|
+
{
|
|
118
|
+
paddingLeft: INDENT + level * INDENT,
|
|
119
|
+
backgroundColor: hovered
|
|
120
|
+
? "rgba(255,255,255,0.1)"
|
|
121
|
+
: "transparent",
|
|
122
|
+
},
|
|
123
|
+
pressed && { backgroundColor: "#323232" },
|
|
124
|
+
disabled && { opacity: 0.4 },
|
|
125
|
+
] },
|
|
126
|
+
React.createElement(View, { style: { flexDirection: "row", alignItems: "center" } },
|
|
127
|
+
route.children.length ? React.createElement(PkgIcon, null) : React.createElement(FileIcon, null),
|
|
128
|
+
React.createElement(Text, { style: styles.filename }, route.contextKey)),
|
|
129
|
+
!disabled && React.createElement(ForwardIcon, null),
|
|
130
|
+
route.generated && React.createElement(Text, { style: styles.virtual }, "Virtual"))))),
|
|
131
|
+
route.children.map((child, index) => (React.createElement(FileItem, { key: child.contextKey, route: child, parents: [...parents, route.route], level: level + 1 })))));
|
|
132
|
+
}
|
|
133
|
+
function FileIcon() {
|
|
134
|
+
return (React.createElement(Image, { style: styles.image, source: require("expo-router/assets/file.png") }));
|
|
135
|
+
}
|
|
136
|
+
function PkgIcon() {
|
|
137
|
+
return (React.createElement(Image, { style: styles.image, source: require("expo-router/assets/pkg.png") }));
|
|
138
|
+
}
|
|
139
|
+
function ForwardIcon() {
|
|
140
|
+
return (React.createElement(Image, { style: styles.image, source: require("expo-router/assets/forward.png") }));
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=Directory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Directory.js","sourceRoot":"","sources":["../../src/views/Directory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,MAAM,GAAG,EAAE,CAAC;AAElB,SAAS,eAAe;IACpB,MAAM,GAAG,GAAG,gBAAgB,EAAE,CAAC;IAE/B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CACxB,GAAG,EAAE,CACD,GAAG;SACE,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;SAClC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACX,2BAA2B;QAC3B,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,EAAE;YACnB,OAAO,CAAC,CAAC,CAAC;SACb;QACD,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,EAAE;YACnB,OAAO,CAAC,CAAC;SACZ;QACD,OAAO,CAAC,CAAC;IAC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ACnD,oBAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,IAAG,KAAK,CAAC,UAAU,CAAQ,CACpD;gBAEN,CAAC,QAAQ,IAAI,oBAAC,WAAW,OAAG;gBAC5B,KAAK,CAAC,SAAS,IAAI,oBAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,OAAO,cAAgB,CAC5D,CACV,CACO,CACT;QACN,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAClC,oBAAC,QAAQ,IACL,GAAG,EAAE,KAAK,CAAC,UAAU,EACrB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,EAClC,KAAK,EAAE,KAAK,GAAG,CAAC,GAClB,CACL,CAAC,CACH,CACN,CAAC;AACN,CAAC;AAED,SAAS,QAAQ;IACb,OAAO,CACH,oBAAC,KAAK,IACF,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,MAAM,EAAE,OAAO,CAAC,6BAA6B,CAAC,GAChD,CACL,CAAC;AACN,CAAC;AAED,SAAS,OAAO;IACZ,OAAO,CACH,oBAAC,KAAK,IACF,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,MAAM,EAAE,OAAO,CAAC,4BAA4B,CAAC,GAC/C,CACL,CAAC;AACN,CAAC;AAED,SAAS,WAAW;IAChB,OAAO,CACH,oBAAC,KAAK,IACF,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,MAAM,EAAE,OAAO,CAAC,gCAAgC,CAAC,GACnD,CACL,CAAC;AACN,CAAC","sourcesContent":["import { Image, Pressable, StyleSheet, Text, View } from \"@bacons/react-views\";\nimport React from \"react\";\nimport { ScrollView, StatusBar, useWindowDimensions } from \"react-native\";\nimport { useSafeAreaInsets } from \"react-native-safe-area-context\";\n\nimport { useRoutesContext } from \"../context\";\nimport { NativeStack } from \"../layouts/NativeStack\";\nimport { matchFragmentName } from \"../matchers\";\nimport { RouteNode } from \"../Route\";\nimport { Link } from \"./Link\";\n\nconst INDENT = 18;\n\nfunction useSortedRoutes() {\n const ctx = useRoutesContext();\n\n const routes = React.useMemo(\n () =>\n ctx\n .filter((route) => !route.internal)\n .sort((a, b) => {\n // Emulate vscode's sorting\n if (a.route < b.route) {\n return -1;\n }\n if (a.route > b.route) {\n return 1;\n }\n return 0;\n }),\n [ctx]\n );\n return routes;\n}\n\nconst styles = StyleSheet.create({\n container: {\n backgroundColor: \"black\",\n flex: 1,\n alignItems: \"stretch\",\n },\n main: {\n marginHorizontal: \"auto\",\n flex: 1,\n\n alignItems: \"stretch\",\n },\n scroll: {\n padding: 12,\n flex: 1,\n // paddingTop: top + 12,\n alignItems: \"stretch\",\n },\n itemContainer: {\n borderWidth: 1,\n borderColor: \"#323232\",\n borderRadius: 19,\n marginBottom: 12,\n overflow: \"hidden\",\n },\n itemPressable: {\n paddingHorizontal: INDENT,\n paddingVertical: 16,\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n transitionDuration: \"100ms\",\n },\n filename: { color: \"white\", fontSize: 20, marginLeft: 12 },\n virtual: { textAlign: \"right\", color: \"white\" },\n image: { width: 24, height: 24, resizeMode: \"contain\" },\n});\n\nexport function Directory() {\n const routes = useSortedRoutes();\n const { bottom } = useSafeAreaInsets();\n const { width } = useWindowDimensions();\n return (\n <View style={styles.container}>\n <NativeStack.Screen\n options={{\n title: \"Index\",\n headerShown: true,\n presentation: \"modal\",\n animation: \"default\",\n headerLargeTitle: true,\n headerTitleStyle: {\n color: \"white\",\n },\n\n headerTintColor: \"white\",\n headerLargeTitleStyle: {\n color: \"white\",\n },\n headerStyle: {\n backgroundColor: \"black\",\n // @ts-expect-error: mistyped\n borderBottomColor: \"#323232\",\n },\n }}\n />\n <StatusBar barStyle=\"light-content\" />\n <View\n style={[\n styles.main,\n {\n minWidth: Math.min(960, width * 0.9),\n },\n ]}\n >\n <ScrollView\n contentInsetAdjustmentBehavior=\"automatic\"\n contentContainerStyle={[\n styles.scroll,\n {\n paddingBottom: bottom + 12,\n },\n ]}\n style={{ flex: 1 }}\n >\n {routes.map((child) => (\n <View key={child.contextKey} style={styles.itemContainer}>\n <FileItem route={child} />\n </View>\n ))}\n </ScrollView>\n </View>\n </View>\n );\n}\n\nfunction FileItem({\n route,\n level = 0,\n parents = [],\n}: {\n route: RouteNode;\n level?: number;\n parents?: string[];\n}) {\n const disabled = route.children.length > 0;\n\n const href = React.useMemo(() => {\n return (\n \"/\" +\n [...parents, route.route]\n .map((v) => {\n // groups and index must be erased\n return !!matchFragmentName(v) || v === \"index\" ? \"\" : v;\n })\n .filter(Boolean)\n .join(\"/\")\n );\n }, [parents, route.route]);\n\n return (\n <>\n {/* @ts-expect-error: disabled not on type */}\n <Link href={href} disabled={disabled} asChild>\n <Pressable>\n {({ pressed, hovered }) => (\n <View\n style={[\n styles.itemPressable,\n {\n paddingLeft: INDENT + level * INDENT,\n backgroundColor: hovered\n ? \"rgba(255,255,255,0.1)\"\n : \"transparent\",\n },\n pressed && { backgroundColor: \"#323232\" },\n disabled && { opacity: 0.4 },\n ]}\n >\n <View style={{ flexDirection: \"row\", alignItems: \"center\" }}>\n {route.children.length ? <PkgIcon /> : <FileIcon />}\n <Text style={styles.filename}>{route.contextKey}</Text>\n </View>\n\n {!disabled && <ForwardIcon />}\n {route.generated && <Text style={styles.virtual}>Virtual</Text>}\n </View>\n )}\n </Pressable>\n </Link>\n {route.children.map((child, index) => (\n <FileItem\n key={child.contextKey}\n route={child}\n parents={[...parents, route.route]}\n level={level + 1}\n />\n ))}\n </>\n );\n}\n\nfunction FileIcon() {\n return (\n <Image\n style={styles.image}\n source={require(\"expo-router/assets/file.png\")}\n />\n );\n}\n\nfunction PkgIcon() {\n return (\n <Image\n style={styles.image}\n source={require(\"expo-router/assets/pkg.png\")}\n />\n );\n}\n\nfunction ForwardIcon() {\n return (\n <Image\n style={styles.image}\n source={require(\"expo-router/assets/forward.png\")}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/views/ErrorBoundary.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAG3C,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,kBAAkB,eAiCjE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Pressable, StyleSheet, Text, View } from '@bacons/react-views';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Platform, ScrollView, TouchableOpacity } from 'react-native';
|
|
4
|
+
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
5
|
+
import { Link } from './Link';
|
|
6
|
+
export function ErrorBoundary({ error, retry }) {
|
|
7
|
+
return (React.createElement(View, { accessibilityRole: 'main', style: [styles.container] },
|
|
8
|
+
React.createElement(SafeAreaView, { style: { flex: 1, maxWidth: 720, marginHorizontal: 'auto' } },
|
|
9
|
+
React.createElement(View, { style: { marginBottom: 12, flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'center' } },
|
|
10
|
+
React.createElement(Text, { accessibilityRole: "heading", accessibilityLevel: 1, style: styles.title }, "Something went wrong"),
|
|
11
|
+
React.createElement(View, { style: { flexDirection: 'row', alignItems: 'center' } },
|
|
12
|
+
React.createElement(Pressable, null, ({ hovered }) => (React.createElement(TouchableOpacity, { onPress: retry },
|
|
13
|
+
React.createElement(View, { style: [{ transitionDuration: '100ms', paddingVertical: 12, paddingHorizontal: 24, borderColor: 'white', borderWidth: 2, marginLeft: 8 }, hovered && { backgroundColor: 'white' }] },
|
|
14
|
+
React.createElement(Text, { style: [styles.buttonText, { transitionDuration: '100ms', color: hovered ? 'black' : 'white' }] }, "Retry"))))))),
|
|
15
|
+
React.createElement(StackTrace, { error: error }),
|
|
16
|
+
process.env.NODE_ENV === 'development' && React.createElement(Link, { href: '/__index', style: styles.link }, "Sitemap"))));
|
|
17
|
+
}
|
|
18
|
+
function StackTrace({ error }) {
|
|
19
|
+
return (React.createElement(ScrollView, { style: { marginVertical: 8, borderColor: 'rgba(255,255,255,0.5)', borderWidth: 1, padding: 12, } },
|
|
20
|
+
React.createElement(Text, { style: [styles.code, { color: 'white' }] }, error.stack)));
|
|
21
|
+
}
|
|
22
|
+
const styles = StyleSheet.create({
|
|
23
|
+
container: {
|
|
24
|
+
flex: 1,
|
|
25
|
+
backgroundColor: "black",
|
|
26
|
+
padding: 24,
|
|
27
|
+
alignItems: "stretch",
|
|
28
|
+
justifyContent: "center",
|
|
29
|
+
},
|
|
30
|
+
title: {
|
|
31
|
+
color: "white",
|
|
32
|
+
fontSize: 36,
|
|
33
|
+
// textAlign: "center",
|
|
34
|
+
fontWeight: "bold",
|
|
35
|
+
},
|
|
36
|
+
buttonText: {
|
|
37
|
+
fontSize: 18,
|
|
38
|
+
fontWeight: 'bold',
|
|
39
|
+
color: 'black',
|
|
40
|
+
},
|
|
41
|
+
code: {
|
|
42
|
+
fontFamily: Platform.select({ default: 'Courier', ios: 'Courier New', android: 'monospace' }),
|
|
43
|
+
fontWeight: '500',
|
|
44
|
+
},
|
|
45
|
+
subtitle: {
|
|
46
|
+
color: "white",
|
|
47
|
+
fontSize: 14,
|
|
48
|
+
marginBottom: 12,
|
|
49
|
+
// textAlign: "center",
|
|
50
|
+
},
|
|
51
|
+
link: { color: "rgba(255,255,255,0.4)", textDecorationStyle: 'solid', textDecorationLine: 'underline', fontSize: 14, textAlign: "center" },
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../src/views/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACxE,O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AAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;QAC7F,UAAU,EAAE,KAAK;KACpB;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,YAAY,EAAE,EAAE;QAChB,uBAAuB;KAC1B;IACD,IAAI,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;CAC7I,CAAC,CAAC","sourcesContent":["import { Pressable, StyleSheet, Text, View } from '@bacons/react-views';\nimport React from 'react';\nimport { Platform, ScrollView, TouchableOpacity } from 'react-native';\nimport { SafeAreaView } from 'react-native-safe-area-context';\n\nimport { ErrorBoundaryProps } from './Try';\nimport { Link } from './Link';\n\nexport function ErrorBoundary({ error, retry }: ErrorBoundaryProps) {\n return (\n <View accessibilityRole='main' style={[styles.container]}>\n <SafeAreaView style={{ flex: 1, maxWidth: 720, marginHorizontal: 'auto' }}>\n <View style={{ marginBottom: 12, flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'center' }}>\n <Text\n accessibilityRole=\"heading\" accessibilityLevel={1}\n style={styles.title}\n >\n Something went wrong\n </Text>\n <View style={{ flexDirection: 'row', alignItems: 'center' }}>\n <Pressable>\n {({ hovered }) => (\n <TouchableOpacity onPress={retry}>\n <View style={[{ transitionDuration: '100ms', paddingVertical: 12, paddingHorizontal: 24, borderColor: 'white', borderWidth: 2, marginLeft: 8 }, hovered && { backgroundColor: 'white' }]}>\n <Text style={[styles.buttonText, { transitionDuration: '100ms', color: hovered ? 'black' : 'white' }]}>\n Retry\n </Text>\n </View>\n </TouchableOpacity>\n )}\n </Pressable>\n </View>\n </View>\n\n <StackTrace error={error} />\n {process.env.NODE_ENV === 'development' && <Link href={'/__index'} style={styles.link}>\n Sitemap\n </Link>}\n </SafeAreaView>\n </View>\n );\n}\n\nfunction StackTrace({ error }: { error: Error }) {\n return (\n <ScrollView style={{ marginVertical: 8, borderColor: 'rgba(255,255,255,0.5)', borderWidth: 1, padding: 12, }}>\n <Text style={[styles.code, { color: 'white' }]}>\n {error.stack}\n </Text>\n </ScrollView>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n backgroundColor: \"black\",\n padding: 24,\n alignItems: \"stretch\",\n justifyContent: \"center\",\n },\n title: {\n color: \"white\",\n fontSize: 36,\n\n // textAlign: \"center\",\n fontWeight: \"bold\",\n },\n buttonText: {\n fontSize: 18,\n fontWeight: 'bold',\n color: 'black',\n },\n code: {\n fontFamily: Platform.select({ default: 'Courier', ios: 'Courier New', android: 'monospace' }),\n fontWeight: '500',\n },\n subtitle: {\n color: \"white\",\n fontSize: 14,\n marginBottom: 12,\n // textAlign: \"center\",\n },\n link: { color: \"rgba(255,255,255,0.4)\", textDecorationStyle: 'solid', textDecorationLine: 'underline', fontSize: 14, textAlign: \"center\" },\n});\n"]}
|