expo-router 0.0.2 → 0.0.3

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.
@@ -106,13 +106,13 @@ function appendDirectoryRoute(routes) {
106
106
  if (!routes.length) {
107
107
  return routes;
108
108
  }
109
- const { Directory } = require("./views/Directory");
109
+ const { Directory, getNavOptions } = require("./views/Directory");
110
110
  routes.push(createRouteNode({
111
111
  getComponent() {
112
112
  return Directory;
113
113
  },
114
114
  getExtras() {
115
- return {};
115
+ return { getNavOptions };
116
116
  },
117
117
  route: "__index",
118
118
  contextKey: "./__index.tsx",
@@ -1 +1 @@
1
- {"version":3,"file":"getRoutes.js","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,SAAS,4BAA4B,CAAC,IAAY;IAChD,OAAO,yBAAyB,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,KAAoE;IAEpE,OAAO;QACL,UAAU,EAAE,4BAA4B,CAAC,KAAK,CAAC,KAAK,CAAC;QACrD,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,IAAI;QACb,GAAG,KAAK;KACT,CAAC;AACJ,CAAC;AAED,qDAAqD;AACrD,SAAS,OAAO,CACd,KAEI;IAEJ,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,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AAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE;YACpC,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAC5C,MAAmB;IAEnB,+CAA+C;IAC/C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,MAAM,aAAa,GAAG,yBAAyB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7D,IAAI,aAAa,EAAE;YACjB,OAAO,KAAK,CAAC;SACd;QACD,kCAAkC;QAClC,IAAI,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAClC,MAAM,KAAK,GAAG,8BAA8B,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC7D,IAAI,KAAK,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;SACF;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {\n getNameFromFilePath,\n matchDeepDynamicRouteName,\n matchDynamicName,\n matchFragmentName,\n} from \"./matchers\";\nimport { PickPartial, RouteNode } from \"./Route\";\nimport { RequireContext } from \"./types\";\nimport { Children } from \"./views/Layout\";\n\nfunction getReactNavigationScreenName(name: string) {\n return matchDeepDynamicRouteName(name) || matchDynamicName(name) || name;\n}\n\nexport function createRouteNode(\n route: PickPartial<RouteNode, \"screenName\" | \"dynamic\" | \"children\">\n): RouteNode {\n return {\n screenName: getReactNavigationScreenName(route.route),\n children: [],\n dynamic: null,\n ...route,\n };\n}\n\n// Recursively convert flat map of file paths to tree\nfunction convert(\n files: (Pick<RouteNode, \"contextKey\" | \"getComponent\" | \"getExtras\"> & {\n normalizedName: string;\n })[]\n): RouteNode[] {\n const tree = {};\n for (const file of files) {\n const parts = file.normalizedName.split(\"/\");\n let current = tree;\n for (const part of parts) {\n current = current[part] = current[part] || {};\n }\n // @ts-expect-error\n current.___child = file;\n }\n\n const toNodeArray = (tree): RouteNode[] => {\n const out: RouteNode[] = [];\n // @ts-expect-error\n for (const [key, { ___child, ...obj }] of Object.entries(tree)) {\n const deepDynamicName = matchDeepDynamicRouteName(key);\n const dynamicName = deepDynamicName ?? matchDynamicName(key);\n\n out.push(\n createRouteNode({\n route: key,\n getExtras: ___child?.getExtras,\n getComponent: ___child?.getComponent,\n contextKey: ___child?.contextKey,\n children: toNodeArray(obj),\n dynamic: dynamicName\n ? { name: dynamicName, deep: !!deepDynamicName }\n : null,\n })\n );\n }\n return out;\n };\n\n return toNodeArray(tree);\n}\n\n/** Given a Metro context module, return an array of nested routes. */\nexport function getRoutes(contextModule: RequireContext): RouteNode[] {\n const names = contextModule\n .keys()\n .map((key) => {\n if (process.env.NODE_ENV === \"development\") {\n // In development, check if the file exports a default component\n // this helps keep things snappy when creating files. In production we load all screens lazily.\n if (!contextModule(key)?.default) {\n return null;\n }\n }\n\n return {\n normalizedName: getNameFromFilePath(key),\n getComponent() {\n return contextModule(key).default;\n },\n contextKey: key,\n getExtras() {\n const { default: mod, ...extras } = contextModule(key);\n return extras;\n },\n };\n })\n .filter((node) => node);\n\n // @ts-expect-error\n const routes = convert(names);\n\n // Add all missing navigators\n recurseAndAddMissingNavigators(routes, []);\n\n if (process.env.NODE_ENV !== \"production\") {\n appendDirectoryRoute(routes);\n }\n\n // Auto add not found route if it doesn't exist\n appendUnmatchedRoute(routes);\n\n return routes;\n}\n\n// When there's a directory, but no sibling file with the same name, the directory won't work.\n// This method ensures that we have a file for every directory (containing valid children).\nexport function recurseAndAddMissingNavigators(\n routes: RouteNode[],\n parents: string[]\n): RouteNode[] {\n routes.forEach((route) => {\n // Route has children but no component and no contextKey (meaning no file path).\n if (route.children.length && route.contextKey == null) {\n route.getComponent = () => Children;\n route.generated = true;\n route.getExtras = () => ({});\n route.contextKey = [\".\", ...parents, route.route + \".tsx\"]\n .filter(Boolean)\n .join(\"/\");\n // TODO: Handle if the directory is dynamic.\n }\n\n route.children = recurseAndAddMissingNavigators(route.children, [\n ...parents,\n route.route,\n ]);\n return route;\n });\n\n return routes;\n}\n\nfunction appendDirectoryRoute(routes: RouteNode[]) {\n if (!routes.length) {\n return routes;\n }\n const { Directory } = require(\"./views/Directory\");\n routes.push(\n createRouteNode({\n getComponent() {\n return Directory;\n },\n getExtras() {\n return {};\n },\n route: \"__index\",\n contextKey: \"./__index.tsx\",\n generated: true,\n internal: true,\n })\n );\n return routes;\n}\n\nfunction appendUnmatchedRoute(routes: RouteNode[]) {\n // Auto add not found route if it doesn't exist\n const userDefinedDynamicRoute = getUserDefinedDeepDynamicRoute(routes);\n if (!userDefinedDynamicRoute) {\n routes.push(\n createRouteNode({\n getComponent() {\n return require(\"./views/Unmatched\").Unmatched;\n },\n getExtras() {\n return {};\n },\n route: \"[...404]\",\n contextKey: \"./[...404].tsx\",\n dynamic: { name: \"404\", deep: true },\n generated: true,\n internal: true,\n })\n );\n }\n return routes;\n}\n\n/**\n * Exposed for testing.\n * @returns a top-level deep dynamic route if it exists, otherwise null.\n */\nexport function getUserDefinedDeepDynamicRoute(\n routes: RouteNode[]\n): RouteNode | null {\n // Auto add not found route if it doesn't exist\n for (const route of routes) {\n const isDeepDynamic = matchDeepDynamicRouteName(route.route);\n if (isDeepDynamic) {\n return route;\n }\n // Recurse through fragment routes\n if (matchFragmentName(route.route)) {\n const child = getUserDefinedDeepDynamicRoute(route.children);\n if (child) {\n return child;\n }\n }\n }\n return null;\n}\n"]}
1
+ {"version":3,"file":"getRoutes.js","sourceRoot":"","sources":["../src/getRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,SAAS,4BAA4B,CAAC,IAAY;IAChD,OAAO,yBAAyB,CAAC,IAAI,CAAC,IAAI,gBAAgB,CA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icRouteName,\n matchDynamicName,\n matchFragmentName,\n} from \"./matchers\";\nimport { PickPartial, RouteNode } from \"./Route\";\nimport { RequireContext } from \"./types\";\nimport { Children } from \"./views/Layout\";\n\nfunction getReactNavigationScreenName(name: string) {\n return matchDeepDynamicRouteName(name) || matchDynamicName(name) || name;\n}\n\nexport function createRouteNode(\n route: PickPartial<RouteNode, \"screenName\" | \"dynamic\" | \"children\">\n): RouteNode {\n return {\n screenName: getReactNavigationScreenName(route.route),\n children: [],\n dynamic: null,\n ...route,\n };\n}\n\n// Recursively convert flat map of file paths to tree\nfunction convert(\n files: (Pick<RouteNode, \"contextKey\" | \"getComponent\" | \"getExtras\"> & {\n normalizedName: string;\n })[]\n): RouteNode[] {\n const tree = {};\n for (const file of files) {\n const parts = file.normalizedName.split(\"/\");\n let current = tree;\n for (const part of parts) {\n current = current[part] = current[part] || {};\n }\n // @ts-expect-error\n current.___child = file;\n }\n\n const toNodeArray = (tree): RouteNode[] => {\n const out: RouteNode[] = [];\n // @ts-expect-error\n for (const [key, { ___child, ...obj }] of Object.entries(tree)) {\n const deepDynamicName = matchDeepDynamicRouteName(key);\n const dynamicName = deepDynamicName ?? matchDynamicName(key);\n\n out.push(\n createRouteNode({\n route: key,\n getExtras: ___child?.getExtras,\n getComponent: ___child?.getComponent,\n contextKey: ___child?.contextKey,\n children: toNodeArray(obj),\n dynamic: dynamicName\n ? { name: dynamicName, deep: !!deepDynamicName }\n : null,\n })\n );\n }\n return out;\n };\n\n return toNodeArray(tree);\n}\n\n/** Given a Metro context module, return an array of nested routes. */\nexport function getRoutes(contextModule: RequireContext): RouteNode[] {\n const names = contextModule\n .keys()\n .map((key) => {\n if (process.env.NODE_ENV === \"development\") {\n // In development, check if the file exports a default component\n // this helps keep things snappy when creating files. In production we load all screens lazily.\n if (!contextModule(key)?.default) {\n return null;\n }\n }\n\n return {\n normalizedName: getNameFromFilePath(key),\n getComponent() {\n return contextModule(key).default;\n },\n contextKey: key,\n getExtras() {\n const { default: mod, ...extras } = contextModule(key);\n return extras;\n },\n };\n })\n .filter((node) => node);\n\n // @ts-expect-error\n const routes = convert(names);\n\n // Add all missing navigators\n recurseAndAddMissingNavigators(routes, []);\n\n if (process.env.NODE_ENV !== \"production\") {\n appendDirectoryRoute(routes);\n }\n\n // Auto add not found route if it doesn't exist\n appendUnmatchedRoute(routes);\n\n return routes;\n}\n\n// When there's a directory, but no sibling file with the same name, the directory won't work.\n// This method ensures that we have a file for every directory (containing valid children).\nexport function recurseAndAddMissingNavigators(\n routes: RouteNode[],\n parents: string[]\n): RouteNode[] {\n routes.forEach((route) => {\n // Route has children but no component and no contextKey (meaning no file path).\n if (route.children.length && route.contextKey == null) {\n route.getComponent = () => Children;\n route.generated = true;\n route.getExtras = () => ({});\n route.contextKey = [\".\", ...parents, route.route + \".tsx\"]\n .filter(Boolean)\n .join(\"/\");\n // TODO: Handle if the directory is dynamic.\n }\n\n route.children = recurseAndAddMissingNavigators(route.children, [\n ...parents,\n route.route,\n ]);\n return route;\n });\n\n return routes;\n}\n\nfunction appendDirectoryRoute(routes: RouteNode[]) {\n if (!routes.length) {\n return routes;\n }\n const { Directory, getNavOptions } = require(\"./views/Directory\");\n routes.push(\n createRouteNode({\n getComponent() {\n return Directory;\n },\n getExtras() {\n return { getNavOptions };\n },\n route: \"__index\",\n contextKey: \"./__index.tsx\",\n generated: true,\n internal: true,\n })\n );\n return routes;\n}\n\nfunction appendUnmatchedRoute(routes: RouteNode[]) {\n // Auto add not found route if it doesn't exist\n const userDefinedDynamicRoute = getUserDefinedDeepDynamicRoute(routes);\n if (!userDefinedDynamicRoute) {\n routes.push(\n createRouteNode({\n getComponent() {\n return require(\"./views/Unmatched\").Unmatched;\n },\n getExtras() {\n return {};\n },\n route: \"[...404]\",\n contextKey: \"./[...404].tsx\",\n dynamic: { name: \"404\", deep: true },\n generated: true,\n internal: true,\n })\n );\n }\n return routes;\n}\n\n/**\n * Exposed for testing.\n * @returns a top-level deep dynamic route if it exists, otherwise null.\n */\nexport function getUserDefinedDeepDynamicRoute(\n routes: RouteNode[]\n): RouteNode | null {\n // Auto add not found route if it doesn't exist\n for (const route of routes) {\n const isDeepDynamic = matchDeepDynamicRouteName(route.route);\n if (isDeepDynamic) {\n return route;\n }\n // Recurse through fragment routes\n if (matchFragmentName(route.route)) {\n const child = getUserDefinedDeepDynamicRoute(route.children);\n if (child) {\n return child;\n }\n }\n }\n return null;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Tutorial.d.ts","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":";AAkCA,wBAAgB,QAAQ,gBAoDvB"}
1
+ {"version":3,"file":"Tutorial.d.ts","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":";AAmCA,wBAAgB,QAAQ,gBAoDvB"}
@@ -2,11 +2,12 @@ import React from "react";
2
2
  import { SafeAreaView, StatusBar, Platform } from "react-native";
3
3
  import { View, Text, Pressable, StyleSheet } from "@bacons/react-views";
4
4
  import { createEntryFileAsync } from "./createEntryFile";
5
+ // TODO: Use openLinkFromBrowser thing
5
6
  function Header() {
6
7
  return (React.createElement(Pressable, null, ({ hovered }) => (React.createElement(Text, { accessibilityRole: "heading", accessibilityLevel: 1, style: [styles.title, Platform.OS !== "web" && { textAlign: "left" }] },
7
8
  "Welcome to",
8
9
  " ",
9
- React.createElement(Text, { href: "https://github.com/expo/expo/", style: [
10
+ React.createElement(Text, { href: "https://github.com/expo/expo-router/", style: [
10
11
  hovered && {
11
12
  textDecorationColor: "white",
12
13
  textDecorationLine: "underline",
@@ -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,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eAAe,EAAE,OAAO;aAC3B;YACD,OAAO,IAAI;gBACP,eAAe,EAAE,uBAAuB;aAC3C;SACJ;QAED,oBAAC,IAAI,IACD,UAAU,EAAE,KAAK,EACjB,KAAK,EAAE;gBACH;oBACI,QAAQ,EAAE,EAAE;oBACZ,kBAAkB,EAAE,OAAO;oBAC3B,UAAU,EAAE,MAAM;oBAClB,KAAK,EAAE,OAAO;iBACjB;gBACD,MAAM,CAAC,IAAI;gBACX,OAAO,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;aAChC;YAED,oBAAC,IAAI,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,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\nconst canAutoTouchFile = process.env.EXPO_ROUTER_APP_ROOT != null;\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 {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: 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"]}
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;IACX,OAAO,CACH,oBAAC,SAAS,QACL,CAAC,EAAE,OAAO,EAAE,EAAE,EA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E;oBACZ,kBAAkB,EAAE,OAAO;oBAC3B,UAAU,EAAE,MAAM;oBAClB,KAAK,EAAE,OAAO;iBACjB;gBACD,MAAM,CAAC,IAAI;gBACX,OAAO,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;aAChC;YAED,oBAAC,IAAI,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,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\n// TODO: Use openLinkFromBrowser thing\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-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 // 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 {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: 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"]}
@@ -1 +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"}
1
+ {"version":3,"file":"useScreens.d.ts","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B;;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"}
@@ -2,14 +2,6 @@ import React from 'react';
2
2
  import { Screen } from './primitives';
3
3
  import { Route, useRoutes } from './Route';
4
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
5
  /**
14
6
  * @returns React Navigation screens for the route.
15
7
  */
@@ -26,27 +18,13 @@ export function useScreensRecord() {
26
18
  }
27
19
  /** Wrap the component with various enhancements and add access to child routes. */
28
20
  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
21
  const Component = value.getComponent();
39
22
  const { ErrorBoundary } = value.getExtras();
40
23
  const QualifiedRoute = React.forwardRef((props, ref) => {
41
24
  // 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
25
  const children = React.createElement(Component, {
47
26
  ...props,
48
27
  ref,
49
- // [dynamicKey]: dynamicValue,
50
28
  });
51
29
  const errorBoundary = ErrorBoundary ? (React.createElement(Try, { catch: ErrorBoundary }, children)) : (children);
52
30
  return (React.createElement(Route, { filename: value.contextKey }, errorBoundary));
@@ -55,6 +33,6 @@ function getQualifiedRouteComponent(value) {
55
33
  return QualifiedRoute;
56
34
  }
57
35
  function routeToScreen(route) {
58
- return (React.createElement(Screen, { name: route.screenName, key: route.route, component: getQualifiedRouteComponent(route) }));
36
+ return (React.createElement(Screen, { name: route.screenName, key: route.route, options: route.getExtras()?.getNavOptions, component: getQualifiedRouteComponent(route) }));
59
37
  }
60
38
  //# sourceMappingURL=useScreens.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"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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"]}
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;;GAEG;AACH,MAAM,UAAU,UAAU;IACtB,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAC;IAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC5B,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAC;IAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CACzC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAC/D,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AACnB,CAAC;AAED,mFAAmF;AACnF,SAAS,0BAA0B,CAAC,KAAgB;IAEhD,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC;IAEvC,MAAM,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAE5C,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACnC,CAAC,KAAsC,EAAE,GAAQ,EAAE,EAAE;QACjD,4CAA4C;QAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE;YAC5C,GAAG,KAAK;YACR,GAAG;SACN,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,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,EAAE,aAAa,EACzC,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\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\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 children = React.createElement(Component, {\n ...props,\n ref,\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 options={route.getExtras()?.getNavOptions}\n component={getQualifiedRouteComponent(route)}\n />\n );\n}\n"]}
@@ -1,3 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { NativeStackNavigationOptions } from "@react-navigation/native-stack";
3
+ export declare function getNavOptions(): NativeStackNavigationOptions;
2
4
  export declare function Directory(): JSX.Element;
3
5
  //# sourceMappingURL=Directory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Directory.d.ts","sourceRoot":"","sources":["../../src/views/Directory.tsx"],"names":[],"mappings":";AAyEA,wBAAgB,SAAS,gBAwDxB"}
1
+ {"version":3,"file":"Directory.d.ts","sourceRoot":"","sources":["../../src/views/Directory.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAwE9E,wBAAgB,aAAa,IAAI,4BAA4B,CAqB5D;AAED,wBAAgB,SAAS,gBAmCxB"}
@@ -3,7 +3,6 @@ import React from "react";
3
3
  import { ScrollView, StatusBar, useWindowDimensions } from "react-native";
4
4
  import { useSafeAreaInsets } from "react-native-safe-area-context";
5
5
  import { useRoutesContext } from "../context";
6
- import { NativeStack } from "../layouts/NativeStack";
7
6
  import { matchFragmentName } from "../matchers";
8
7
  import { Link } from "./Link";
9
8
  const INDENT = 18;
@@ -59,30 +58,32 @@ const styles = StyleSheet.create({
59
58
  virtual: { textAlign: "right", color: "white" },
60
59
  image: { width: 24, height: 24, resizeMode: "contain" },
61
60
  });
61
+ export function getNavOptions() {
62
+ return {
63
+ title: "Index",
64
+ headerShown: true,
65
+ presentation: "modal",
66
+ animation: "default",
67
+ headerLargeTitle: true,
68
+ headerTitleStyle: {
69
+ color: "white",
70
+ },
71
+ headerTintColor: "white",
72
+ headerLargeTitleStyle: {
73
+ color: "white",
74
+ },
75
+ headerStyle: {
76
+ backgroundColor: "black",
77
+ // @ts-expect-error: mistyped
78
+ borderBottomColor: "#323232",
79
+ },
80
+ };
81
+ }
62
82
  export function Directory() {
63
83
  const routes = useSortedRoutes();
64
84
  const { bottom } = useSafeAreaInsets();
65
85
  const { width } = useWindowDimensions();
66
86
  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
87
  React.createElement(StatusBar, { barStyle: "light-content" }),
87
88
  React.createElement(View, { style: [
88
89
  styles.main,
@@ -1 +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,CA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AAE,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"]}
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;AAE/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,O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ACb,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 { NativeStackNavigationOptions } from \"@react-navigation/native-stack\";\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 { 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 getNavOptions(): NativeStackNavigationOptions {\n return {\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\nexport function Directory() {\n const routes = useSortedRoutes();\n const { bottom } = useSafeAreaInsets();\n const { width } = useWindowDimensions();\n return (\n <View style={styles.container}>\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"]}
@@ -21,6 +21,6 @@ declare type Props<ParamList extends ReactNavigation.RootParamList> = {
21
21
  * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
22
22
  * @param props.children Child elements to render the content.
23
23
  */
24
- export declare const Link: React.ForwardRefExoticComponent<Pick<Props<ReactNavigation.RootParamList>, "children" | "key" | "target" | "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" | "action" | keyof import("@bacons/react-views/build/Text").WebTextProps> & React.RefAttributes<Text>>;
24
+ export declare const Link: React.ForwardRefExoticComponent<Pick<Props<ReactNavigation.RootParamList>, "children" | "key" | "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" | "action" | keyof import("@bacons/react-views/build/Text").WebTextProps> & React.RefAttributes<Text>>;
25
25
  export {};
26
26
  //# sourceMappingURL=Link.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAQ,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAGrD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wCAAwC,CAAC;AAEjE,aAAK,KAAK,CAAC,SAAS,SAAS,eAAe,CAAC,aAAa,IAAI;I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E,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,29BAA6B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-router",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "main": "build/index.js",
5
5
  "files": [
6
6
  "entry.js",
@@ -44,7 +44,7 @@
44
44
  "jest": "^26.6.3"
45
45
  },
46
46
  "dependencies": {
47
- "@bacons/react-views": "^1.1.1",
47
+ "@bacons/react-views": "^1.1.3",
48
48
  "@radix-ui/react-slot": "^1.0.0",
49
49
  "@react-navigation/bottom-tabs": "^6.3.3",
50
50
  "@react-navigation/drawer": "^6.4.4",