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.
Files changed (132) hide show
  1. package/README.md +3 -0
  2. package/assets/file.png +0 -0
  3. package/assets/forward.png +0 -0
  4. package/assets/pkg.png +0 -0
  5. package/babel.js +77 -0
  6. package/build/ContextNavigationContainer.d.ts +33 -0
  7. package/build/ContextNavigationContainer.d.ts.map +1 -0
  8. package/build/ContextNavigationContainer.js +59 -0
  9. package/build/ContextNavigationContainer.js.map +1 -0
  10. package/build/ContextNavigator.d.ts +6 -0
  11. package/build/ContextNavigator.d.ts.map +1 -0
  12. package/build/ContextNavigator.js +52 -0
  13. package/build/ContextNavigator.js.map +1 -0
  14. package/build/Route.d.ts +34 -0
  15. package/build/Route.d.ts.map +1 -0
  16. package/build/Route.js +56 -0
  17. package/build/Route.js.map +1 -0
  18. package/build/aasa.d.ts +2 -0
  19. package/build/aasa.d.ts.map +1 -0
  20. package/build/aasa.js +25 -0
  21. package/build/aasa.js.map +1 -0
  22. package/build/context.d.ts +5 -0
  23. package/build/context.d.ts.map +1 -0
  24. package/build/context.js +14 -0
  25. package/build/context.js.map +1 -0
  26. package/build/fork/getPathFromState.d.ts +39 -0
  27. package/build/fork/getPathFromState.d.ts.map +1 -0
  28. package/build/fork/getPathFromState.js +209 -0
  29. package/build/fork/getPathFromState.js.map +1 -0
  30. package/build/fork/getStateFromPath.d.ts +33 -0
  31. package/build/fork/getStateFromPath.d.ts.map +1 -0
  32. package/build/fork/getStateFromPath.js +415 -0
  33. package/build/fork/getStateFromPath.js.map +1 -0
  34. package/build/getDevServer/index.d.ts +7 -0
  35. package/build/getDevServer/index.d.ts.map +1 -0
  36. package/build/getDevServer/index.js +30 -0
  37. package/build/getDevServer/index.js.map +1 -0
  38. package/build/getDevServer/index.native.d.ts +2 -0
  39. package/build/getDevServer/index.native.d.ts.map +1 -0
  40. package/build/getDevServer/index.native.js +2 -0
  41. package/build/getDevServer/index.native.js.map +1 -0
  42. package/build/getLinkingConfig.d.ts +5 -0
  43. package/build/getLinkingConfig.d.ts.map +1 -0
  44. package/build/getLinkingConfig.js +62 -0
  45. package/build/getLinkingConfig.js.map +1 -0
  46. package/build/getRoutes.d.ts +12 -0
  47. package/build/getRoutes.d.ts.map +1 -0
  48. package/build/getRoutes.js +165 -0
  49. package/build/getRoutes.js.map +1 -0
  50. package/build/index.d.ts +14 -0
  51. package/build/index.d.ts.map +1 -0
  52. package/build/index.js +13 -0
  53. package/build/index.js.map +1 -0
  54. package/build/layouts/Drawer.d.ts +132 -0
  55. package/build/layouts/Drawer.d.ts.map +1 -0
  56. package/build/layouts/Drawer.js +5 -0
  57. package/build/layouts/Drawer.js.map +1 -0
  58. package/build/layouts/NativeStack.d.ts +132 -0
  59. package/build/layouts/NativeStack.d.ts.map +1 -0
  60. package/build/layouts/NativeStack.js +5 -0
  61. package/build/layouts/NativeStack.js.map +1 -0
  62. package/build/layouts/Stack.d.ts +156 -0
  63. package/build/layouts/Stack.d.ts.map +1 -0
  64. package/build/layouts/Stack.js +6 -0
  65. package/build/layouts/Stack.js.map +1 -0
  66. package/build/layouts/Tabs.d.ts +136 -0
  67. package/build/layouts/Tabs.d.ts.map +1 -0
  68. package/build/layouts/Tabs.js +6 -0
  69. package/build/layouts/Tabs.js.map +1 -0
  70. package/build/layouts/withLayoutContext.d.ts +16 -0
  71. package/build/layouts/withLayoutContext.d.ts.map +1 -0
  72. package/build/layouts/withLayoutContext.js +73 -0
  73. package/build/layouts/withLayoutContext.js.map +1 -0
  74. package/build/matchers.d.ts +8 -0
  75. package/build/matchers.d.ts.map +1 -0
  76. package/build/matchers.js +25 -0
  77. package/build/matchers.js.map +1 -0
  78. package/build/onboard/Tutorial.d.ts +3 -0
  79. package/build/onboard/Tutorial.d.ts.map +1 -0
  80. package/build/onboard/Tutorial.js +129 -0
  81. package/build/onboard/Tutorial.js.map +1 -0
  82. package/build/onboard/createEntryFile.d.ts +3 -0
  83. package/build/onboard/createEntryFile.d.ts.map +1 -0
  84. package/build/onboard/createEntryFile.js +54 -0
  85. package/build/onboard/createEntryFile.js.map +1 -0
  86. package/build/primitives.d.ts +19 -0
  87. package/build/primitives.d.ts.map +1 -0
  88. package/build/primitives.js +5 -0
  89. package/build/primitives.js.map +1 -0
  90. package/build/types.d.ts +11 -0
  91. package/build/types.d.ts.map +1 -0
  92. package/build/types.js +2 -0
  93. package/build/types.js.map +1 -0
  94. package/build/useScreens.d.ts +10 -0
  95. package/build/useScreens.d.ts.map +1 -0
  96. package/build/useScreens.js +60 -0
  97. package/build/useScreens.js.map +1 -0
  98. package/build/views/Directory.d.ts +3 -0
  99. package/build/views/Directory.d.ts.map +1 -0
  100. package/build/views/Directory.js +142 -0
  101. package/build/views/Directory.js.map +1 -0
  102. package/build/views/ErrorBoundary.d.ts +4 -0
  103. package/build/views/ErrorBoundary.d.ts.map +1 -0
  104. package/build/views/ErrorBoundary.js +53 -0
  105. package/build/views/ErrorBoundary.js.map +1 -0
  106. package/build/views/Layout.d.ts +19 -0
  107. package/build/views/Layout.d.ts.map +1 -0
  108. package/build/views/Layout.js +48 -0
  109. package/build/views/Layout.js.map +1 -0
  110. package/build/views/Link.d.ts +26 -0
  111. package/build/views/Link.d.ts.map +1 -0
  112. package/build/views/Link.js +47 -0
  113. package/build/views/Link.js.map +1 -0
  114. package/build/views/Root.d.ts +6 -0
  115. package/build/views/Root.d.ts.map +1 -0
  116. package/build/views/Root.js +20 -0
  117. package/build/views/Root.js.map +1 -0
  118. package/build/views/Screen.d.ts +7 -0
  119. package/build/views/Screen.d.ts.map +1 -0
  120. package/build/views/Screen.js +19 -0
  121. package/build/views/Screen.js.map +1 -0
  122. package/build/views/Try.d.ts +24 -0
  123. package/build/views/Try.d.ts.map +1 -0
  124. package/build/views/Try.js +24 -0
  125. package/build/views/Try.js.map +1 -0
  126. package/build/views/Unmatched.d.ts +4 -0
  127. package/build/views/Unmatched.d.ts.map +1 -0
  128. package/build/views/Unmatched.js +46 -0
  129. package/build/views/Unmatched.js.map +1 -0
  130. package/entry.js +103 -0
  131. package/metro-config.js +14 -0
  132. package/package.json +62 -0
@@ -0,0 +1,19 @@
1
+ import { useNavigationBuilder } from '@react-navigation/native';
2
+ import * as React from 'react';
3
+ export declare const LayoutContext: React.Context<any>;
4
+ export declare type LayoutProps = {
5
+ initialRouteName?: Parameters<typeof useNavigationBuilder>[1]['initialRouteName'];
6
+ screenOptions?: Parameters<typeof useNavigationBuilder>[1]['screenOptions'];
7
+ children?: Parameters<typeof useNavigationBuilder>[1]['children'];
8
+ router?: Parameters<typeof useNavigationBuilder>[0];
9
+ };
10
+ /** An unstyled custom navigator. Good for basic web layouts */
11
+ export declare function Layout({ initialRouteName, screenOptions, children, router, }: LayoutProps): JSX.Element;
12
+ export declare namespace Layout {
13
+ var Children: typeof import("./Layout").Children;
14
+ var useContext: typeof useLayoutContext;
15
+ }
16
+ export declare function useLayoutContext(): any;
17
+ /** Renders the currently selected content. */
18
+ export declare function Children(props: Omit<LayoutProps, 'children'>): any;
19
+ //# sourceMappingURL=Layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../src/views/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,eAAO,MAAM,aAAa,oBAAiC,CAAC;AAM5D,oBAAY,WAAW,GAAG;IACtB,gBAAgB,CAAC,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;IAClF,aAAa,CAAC,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;IAC5E,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAClE,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;CACvD,CAAA;AAED,+DAA+D;AAC/D,wBAAgB,MAAM,CAAC,EACnB,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,MAAkB,GACrB,EAAE,WAAW,eAeb;yBApBe,MAAM;;;;AAsBtB,wBAAgB,gBAAgB,QAQ/B;AAaD,8CAA8C;AAC9C,wBAAgB,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,OAY5D"}
@@ -0,0 +1,48 @@
1
+ import { TabRouter, useNavigationBuilder } from '@react-navigation/native';
2
+ import * as React from 'react';
3
+ import { useScreens } from '../useScreens';
4
+ // TODO: This might already exist upstream, maybe something like `useCurrentRender` ?
5
+ export const LayoutContext = React.createContext(null);
6
+ if (process.env.NODE_ENV !== "production") {
7
+ LayoutContext.displayName = "LayoutContext";
8
+ }
9
+ /** An unstyled custom navigator. Good for basic web layouts */
10
+ export function Layout({ initialRouteName, screenOptions, children, router = TabRouter, }) {
11
+ const screens = useScreens();
12
+ const { state, navigation, descriptors, NavigationContent } = useNavigationBuilder(router, {
13
+ children: screens,
14
+ screenOptions,
15
+ initialRouteName,
16
+ });
17
+ return (React.createElement(LayoutContext.Provider, { value: { state, navigation, descriptors, router } },
18
+ React.createElement(NavigationContent, null, children)));
19
+ }
20
+ export function useLayoutContext() {
21
+ const context = React.useContext(LayoutContext);
22
+ if (!context) {
23
+ throw new Error("useLayoutContext must be used within a <Layout />");
24
+ }
25
+ return context;
26
+ }
27
+ function useChild() {
28
+ const context = React.useContext(LayoutContext);
29
+ const { state, descriptors } = context;
30
+ const current = state.routes.find((route, i) => state.index === i);
31
+ if (!current) {
32
+ return null;
33
+ }
34
+ return descriptors[current.key]?.render() ?? null;
35
+ }
36
+ /** Renders the currently selected content. */
37
+ export function Children(props) {
38
+ const context = React.useContext(LayoutContext);
39
+ if (!context) {
40
+ // Qualify the content and re-export.
41
+ return (React.createElement(Layout, { ...props },
42
+ React.createElement(Children, null)));
43
+ }
44
+ return useChild();
45
+ }
46
+ Layout.Children = Children;
47
+ Layout.useContext = useLayoutContext;
48
+ //# sourceMappingURL=Layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../src/views/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,qFAAqF;AACrF,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAM,IAAI,CAAC,CAAC;AAE5D,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACvC,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC;CAC/C;AASD,+DAA+D;AAC/D,MAAM,UAAU,MAAM,CAAC,EACnB,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,MAAM,GAAG,SAAS,GACR;IACV,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,GACvD,oBAAoB,CAAC,MAAM,EAAE;QACzB,QAAQ,EAAE,OAAO;QACjB,aAAa;QACb,gBAAgB;KACnB,CAAC,CAAC;IAEP,OAAO,CACH,oBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE;QACrE,oBAAC,iBAAiB,QAAE,QAAQ,CAAqB,CAC5B,CAC5B,CAAC;AACN,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC5B,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE;QACV,MAAM,IAAI,KAAK,CACX,mDAAmD,CACtD,CAAC;KACL;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ;IACb,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAEhD,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;IACnE,IAAI,CAAC,OAAO,EAAE;QACV,OAAO,IAAI,CAAC;KACf;IACD,OAAO,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC;AACtD,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,QAAQ,CAAC,KAAoC;IACzD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE;QACV,qCAAqC;QACrC,OAAO,CACH,oBAAC,MAAM,OAAK,KAAK;YACb,oBAAC,QAAQ,OAAG,CACP,CACZ,CAAC;KACL;IAED,OAAO,QAAQ,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC3B,MAAM,CAAC,UAAU,GAAG,gBAAgB,CAAC","sourcesContent":["import { TabRouter, useNavigationBuilder } from '@react-navigation/native';\nimport * as React from 'react';\n\nimport { useScreens } from '../useScreens';\n\n// TODO: This might already exist upstream, maybe something like `useCurrentRender` ?\nexport const LayoutContext = React.createContext<any>(null);\n\nif (process.env.NODE_ENV !== \"production\") {\n LayoutContext.displayName = \"LayoutContext\";\n}\n\nexport type LayoutProps = {\n initialRouteName?: Parameters<typeof useNavigationBuilder>[1]['initialRouteName'];\n screenOptions?: Parameters<typeof useNavigationBuilder>[1]['screenOptions'];\n children?: Parameters<typeof useNavigationBuilder>[1]['children'];\n router?: Parameters<typeof useNavigationBuilder>[0];\n}\n\n/** An unstyled custom navigator. Good for basic web layouts */\nexport function Layout({\n initialRouteName,\n screenOptions,\n children,\n router = TabRouter,\n}: LayoutProps) {\n const screens = useScreens();\n\n const { state, navigation, descriptors, NavigationContent } =\n useNavigationBuilder(router, {\n children: screens,\n screenOptions,\n initialRouteName,\n });\n\n return (\n <LayoutContext.Provider value={{ state, navigation, descriptors, router }}>\n <NavigationContent>{children}</NavigationContent>\n </LayoutContext.Provider>\n );\n}\n\nexport function useLayoutContext() {\n const context = React.useContext(LayoutContext);\n if (!context) {\n throw new Error(\n \"useLayoutContext must be used within a <Layout />\"\n );\n }\n return context;\n}\n\nfunction useChild() {\n const context = React.useContext(LayoutContext);\n\n const { state, descriptors } = context;\n const current = state.routes.find((route, i) => state.index === i);\n if (!current) {\n return null;\n }\n return descriptors[current.key]?.render() ?? null;\n}\n\n/** Renders the currently selected content. */\nexport function Children(props: Omit<LayoutProps, 'children'>) {\n const context = React.useContext(LayoutContext);\n if (!context) {\n // Qualify the content and re-export.\n return (\n <Layout {...props}>\n <Children />\n </Layout>\n );\n }\n\n return useChild();\n}\n\nLayout.Children = Children;\nLayout.useContext = useLayoutContext;\n"]}
@@ -0,0 +1,26 @@
1
+ import type { NavigationAction } from '@react-navigation/core';
2
+ import * as React from 'react';
3
+ import { GestureResponderEvent } from 'react-native';
4
+ import { TextProps } from '@bacons/react-views';
5
+ import type { To } from '@react-navigation/native/src/useLinkTo';
6
+ declare type Props<ParamList extends ReactNavigation.RootParamList> = {
7
+ asChild?: boolean;
8
+ href?: string;
9
+ to?: To<ParamList>;
10
+ action?: NavigationAction;
11
+ target?: string;
12
+ onPress?: (e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => void;
13
+ } & (TextProps & {
14
+ children: React.ReactNode;
15
+ });
16
+ /**
17
+ * Component to render link to another screen using a path.
18
+ * Uses an anchor tag on the web.
19
+ *
20
+ * @param props.href Absolute path to screen (e.g. `/feeds/hot`).
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
+ * @param props.children Child elements to render the content.
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>>;
25
+ export {};
26
+ //# sourceMappingURL=Link.d.ts.map
@@ -0,0 +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;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;IACnB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,CACN,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,qBAAqB,KACzE,IAAI,CAAC;CACb,GAAG,CAAC,SAAS,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,s+BAA6B,CAAC"}
@@ -0,0 +1,47 @@
1
+ import * as React from 'react';
2
+ import { Platform } from 'react-native';
3
+ import { Text } from '@bacons/react-views';
4
+ import { useLinkProps, } from '@react-navigation/native';
5
+ import { Slot } from '@radix-ui/react-slot';
6
+ /**
7
+ * Component to render link to another screen using a path.
8
+ * Uses an anchor tag on the web.
9
+ *
10
+ * @param props.href Absolute path to screen (e.g. `/feeds/hot`).
11
+ * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
12
+ * @param props.children Child elements to render the content.
13
+ */
14
+ export const Link = React.forwardRef(BaseLink);
15
+ function BaseLink({ to, href, action, asChild, ...rest }, ref) {
16
+ // TODO: Auto use router's client-side event.
17
+ const resolvedTo = React.useMemo(() => {
18
+ const resolved = href ? href : to;
19
+ if (resolved == null) {
20
+ throw new Error(`You must specify either 'href' or 'to' prop in a <Link />.`);
21
+ }
22
+ if (typeof resolved === 'string' && !resolved.startsWith('/')) {
23
+ // TODO: Auto delegate out external links
24
+ return '/';
25
+ }
26
+ return resolved;
27
+ }, [href, to]);
28
+ const props = useLinkProps({ to: resolvedTo, action });
29
+ const onPress = (e) => {
30
+ if ('onPress' in rest) {
31
+ rest.onPress?.(e);
32
+ }
33
+ props.onPress(e);
34
+ };
35
+ return React.createElement(
36
+ // @ts-expect-error: slot is not type-safe
37
+ asChild ? Slot : Text, {
38
+ ref,
39
+ ...props,
40
+ ...rest,
41
+ ...Platform.select({
42
+ web: { onClick: onPress },
43
+ default: { onPress },
44
+ }),
45
+ });
46
+ }
47
+ //# sourceMappingURL=Link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAyB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAa,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,GAAG,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAc3C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAE/C,SAAS,QAAQ,CAAkD,EAC/D,EAAE,EACF,IAAI,EACJ,MAAM,EACN,OAAO,EACP,GAAG,IAAI,EACQ,EAAE,GAA6B;IAC9C,6CAA6C;IAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAClC,IAAI,QAAQ,IAAI,IAAI,EAAE;YAClB,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;SACL;QACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC3D,yCAAyC;YACzC,OAAO,GAAG,CAAA;SACb;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACf,MAAM,KAAK,GAAG,YAAY,CAAY,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,CACZ,CAA0E,EAC5E,EAAE;QACA,IAAI,SAAS,IAAI,IAAI,EAAE;YACnB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;SACrB;QAED,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC,aAAa;IACtB,0CAA0C;IAC1C,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EACrB;QACI,GAAG;QACH,GAAG,KAAK;QACR,GAAG,IAAI;QACP,GAAG,QAAQ,CAAC,MAAM,CAAC;YACf,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAS;YAChC,OAAO,EAAE,EAAE,OAAO,EAAE;SACvB,CAAC;KACL,CAAC,CAAC;AACX,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx\nimport type { NavigationAction } from '@react-navigation/core';\nimport * as React from 'react';\nimport { GestureResponderEvent, Platform } from 'react-native';\nimport { Text, TextProps } from '@bacons/react-views'\nimport { useLinkProps, } from '@react-navigation/native';\nimport { Slot } from '@radix-ui/react-slot'\nimport type { To } from '@react-navigation/native/src/useLinkTo';\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n asChild?: boolean;\n href?: string;\n to?: To<ParamList>;\n action?: NavigationAction;\n target?: string;\n onPress?: (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => void;\n} & (TextProps & { children: React.ReactNode });\n\n/**\n * Component to render link to another screen using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.href Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.\n * @param props.children Child elements to render the content.\n */\nexport const Link = React.forwardRef(BaseLink);\n\nfunction BaseLink<ParamList extends ReactNavigation.RootParamList>({\n to,\n href,\n action,\n asChild,\n ...rest\n}: Props<ParamList>, ref: React.ForwardedRef<Text>) {\n // TODO: Auto use router's client-side event.\n const resolvedTo = React.useMemo(() => {\n const resolved = href ? href : to;\n if (resolved == null) {\n throw new Error(\n `You must specify either 'href' or 'to' prop in a <Link />.`\n );\n }\n if (typeof resolved === 'string' && !resolved.startsWith('/')) {\n // TODO: Auto delegate out external links\n return '/'\n }\n return resolved;\n }, [href, to]);\n const props = useLinkProps<ParamList>({ to: resolvedTo, action });\n\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n\n props.onPress(e);\n };\n\n return React.createElement(\n // @ts-expect-error: slot is not type-safe\n asChild ? Slot : Text,\n {\n ref,\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n });\n}\n"]}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { RequireContext } from '../types';
3
+ export declare function ExpoRoot({ context }: {
4
+ context: RequireContext;
5
+ }): JSX.Element;
6
+ //# sourceMappingURL=Root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Root.d.ts","sourceRoot":"","sources":["../../src/views/Root.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAU1C,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,eAYhE"}
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { SafeAreaProvider } from "react-native-safe-area-context";
3
+ import { StatusBar } from 'expo-status-bar';
4
+ import { ContextNavigator } from '../ContextNavigator';
5
+ function getGestureHandlerRootView() {
6
+ try {
7
+ return require("react-native-gesture-handler").GestureHandlerRootView;
8
+ }
9
+ catch {
10
+ return React.Fragment;
11
+ }
12
+ }
13
+ export function ExpoRoot({ context }) {
14
+ const GestureHandlerRootView = React.useMemo(() => getGestureHandlerRootView(), []);
15
+ return (React.createElement(GestureHandlerRootView, { style: { flex: 1 } },
16
+ React.createElement(SafeAreaProvider, null,
17
+ React.createElement(ContextNavigator, { context: context }),
18
+ React.createElement(StatusBar, { style: "auto" }))));
19
+ }
20
+ //# sourceMappingURL=Root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Root.js","sourceRoot":"","sources":["../../src/views/Root.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,SAAS,yBAAyB;IAC9B,IAAI;QACA,OAAO,OAAO,CAAC,8BAA8B,CAAC,CAAC,sBAA8F,CAAC;KACjJ;IAAC,MAAM;QACJ,OAAO,KAAK,CAAC,QAAQ,CAAC;KACzB;AACL,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,EAAE,OAAO,EAA+B;IAC7D,MAAM,sBAAsB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,yBAAyB,EAAE,EAAE,EAAE,CAAC,CAAC;IAEpF,OAAO,CACH,oBAAC,sBAAsB,IAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;QACtC,oBAAC,gBAAgB;YACb,oBAAC,gBAAgB,IAAC,OAAO,EAAE,OAAO,GAAI;YAEtC,oBAAC,SAAS,IAAC,KAAK,EAAC,MAAM,GAAG,CACX,CACE,CAC5B,CAAC;AACN,CAAC","sourcesContent":["import React from \"react\";\n\nimport { SafeAreaProvider } from \"react-native-safe-area-context\";\nimport { StatusBar } from 'expo-status-bar';\n\nimport { ContextNavigator } from '../ContextNavigator';\nimport { RequireContext } from '../types';\n\nfunction getGestureHandlerRootView() {\n try {\n return require(\"react-native-gesture-handler\").GestureHandlerRootView as typeof import('react-native-gesture-handler').GestureHandlerRootView;\n } catch {\n return React.Fragment;\n }\n}\n\nexport function ExpoRoot({ context }: { context: RequireContext }) {\n const GestureHandlerRootView = React.useMemo(() => getGestureHandlerRootView(), []);\n\n return (\n <GestureHandlerRootView style={{ flex: 1 }}>\n <SafeAreaProvider>\n <ContextNavigator context={context} />\n {/* Users can override this by adding another StatusBar element anywhere higher in the component tree. */}\n <StatusBar style=\"auto\" />\n </SafeAreaProvider>\n </GestureHandlerRootView>\n );\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /** Component for setting the current screen's options dynamically. */
2
+ export declare function Screen<TOptions extends {} = {}>({ name, options }: {
3
+ name?: string;
4
+ initialParams?: Record<string, any>;
5
+ options?: TOptions;
6
+ }): null;
7
+ //# sourceMappingURL=Screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Screen.d.ts","sourceRoot":"","sources":["../../src/views/Screen.tsx"],"names":[],"mappings":"AAGA,sEAAsE;AACtE,wBAAgB,MAAM,CAAC,QAAQ,SAAS,EAAE,GAAG,EAAE,EAAE,EAC7C,IAAI,EACJ,OAAO,EACV,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAA;CAAE,QAmB5E"}
@@ -0,0 +1,19 @@
1
+ import { useNavigation } from "@react-navigation/native";
2
+ import React from "react";
3
+ /** Component for setting the current screen's options dynamically. */
4
+ export function Screen({ name, options }) {
5
+ // TODO: Maybe disable all this hook stuff when name is defined.
6
+ const navigation = useNavigation();
7
+ React.useLayoutEffect(() => {
8
+ navigation.setOptions(options ?? {});
9
+ }, [navigation, options]);
10
+ if (process.env.NODE_ENV !== "production") {
11
+ React.useEffect(() => {
12
+ if (name != null) {
13
+ throw new Error("Screen components should only use the name prop when nested directly inside a Layout. When a Screen is used for dynamic options it uses the nearest navigation context.");
14
+ }
15
+ }, [name]);
16
+ }
17
+ return null;
18
+ }
19
+ //# sourceMappingURL=Screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Screen.js","sourceRoot":"","sources":["../../src/views/Screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,sEAAsE;AACtE,MAAM,UAAU,MAAM,CAA2B,EAC7C,IAAI,EACJ,OAAO,EACkE;IACzE,gEAAgE;IAChE,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IAEnC,KAAK,CAAC,eAAe,CAAC,GAAG,EAAE;QACvB,UAAU,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IAE1B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACvC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;YACjB,IAAI,IAAI,IAAI,IAAI,EAAE;gBACd,MAAM,IAAI,KAAK,CACX,yKAAyK,CAC5K,CAAC;aACL;QACL,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { useNavigation } from \"@react-navigation/native\";\nimport React from \"react\";\n\n/** Component for setting the current screen's options dynamically. */\nexport function Screen<TOptions extends {} = {}>({\n name,\n options\n}: { name?: string, initialParams?: Record<string, any>; options?: TOptions }) {\n // TODO: Maybe disable all this hook stuff when name is defined.\n const navigation = useNavigation();\n\n React.useLayoutEffect(() => {\n navigation.setOptions(options ?? {});\n }, [navigation, options]);\n\n if (process.env.NODE_ENV !== \"production\") {\n React.useEffect(() => {\n if (name != null) {\n throw new Error(\n \"Screen components should only use the name prop when nested directly inside a Layout. When a Screen is used for dynamic options it uses the nearest navigation context.\"\n );\n }\n }, [name]);\n }\n\n return null;\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ /** Props passed to a page's `ErrorBoundary` export. */
3
+ export declare type ErrorBoundaryProps = {
4
+ /** Retry rendering the component by clearing the `error` state. */
5
+ retry: () => Promise<void>;
6
+ /** The error that was thrown. */
7
+ error: Error;
8
+ };
9
+ export declare class Try extends React.Component<{
10
+ catch: React.ComponentType<ErrorBoundaryProps>;
11
+ children: React.ReactNode;
12
+ }, {
13
+ error?: Error;
14
+ }> {
15
+ state: {
16
+ error: undefined;
17
+ };
18
+ static getDerivedStateFromError(error: Error): {
19
+ error: Error;
20
+ };
21
+ retry: () => Promise<void>;
22
+ render(): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
23
+ }
24
+ //# sourceMappingURL=Try.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Try.d.ts","sourceRoot":"","sources":["../../src/views/Try.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,uDAAuD;AACvD,oBAAY,kBAAkB,GAAG;IAC7B,mEAAmE;IACnE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,iCAAiC;IACjC,KAAK,EAAE,KAAK,CAAC;CAChB,CAAC;AAGF,qBAAa,GAAI,SAAQ,KAAK,CAAC,SAAS,CACpC;IACI,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAC/C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B,EACD;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CACpB;IACG,KAAK;;MAAwB;IAE7B,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;;;IAI5C,KAAK,sBAMH;IAEF,MAAM;CAQT"}
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ // No way to access `getDerivedStateFromError` from a functional component afaict.
3
+ export class Try extends React.Component {
4
+ state = { error: undefined };
5
+ static getDerivedStateFromError(error) {
6
+ return { error };
7
+ }
8
+ retry = () => {
9
+ return new Promise((resolve) => {
10
+ this.setState({ error: undefined }, () => {
11
+ resolve();
12
+ });
13
+ });
14
+ };
15
+ render() {
16
+ const { error } = this.state;
17
+ const { catch: ErrorBoundary, children } = this.props;
18
+ if (!error) {
19
+ return children;
20
+ }
21
+ return React.createElement(ErrorBoundary, { error: error, retry: this.retry });
22
+ }
23
+ }
24
+ //# sourceMappingURL=Try.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Try.js","sourceRoot":"","sources":["../../src/views/Try.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,kFAAkF;AAClF,MAAM,OAAO,GAAI,SAAQ,KAAK,CAAC,SAM9B;IACG,KAAK,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAE7B,MAAM,CAAC,wBAAwB,CAAC,KAAY;QACxC,OAAO,EAAE,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,KAAK,GAAG,GAAG,EAAE;QACT,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACjC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE;gBACrC,OAAO,EAAE,CAAC;YACd,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,MAAM;QACF,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7B,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACtD,IAAI,CAAC,KAAK,EAAE;YACR,OAAO,QAAQ,CAAC;SACnB;QACD,OAAO,oBAAC,aAAa,IAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,GAAI,CAAC;IAC9D,CAAC;CACJ","sourcesContent":["import React from \"react\";\n\n/** Props passed to a page's `ErrorBoundary` export. */\nexport type ErrorBoundaryProps = {\n /** Retry rendering the component by clearing the `error` state. */\n retry: () => Promise<void>;\n /** The error that was thrown. */\n error: Error;\n};\n\n// No way to access `getDerivedStateFromError` from a functional component afaict.\nexport class Try extends React.Component<\n {\n catch: React.ComponentType<ErrorBoundaryProps>;\n children: React.ReactNode;\n },\n { error?: Error }\n> {\n state = { error: undefined };\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n retry = () => {\n return new Promise<void>((resolve) => {\n this.setState({ error: undefined }, () => {\n resolve();\n });\n });\n };\n\n render() {\n const { error } = this.state;\n const { catch: ErrorBoundary, children } = this.props;\n if (!error) {\n return children;\n }\n return <ErrorBoundary error={error} retry={this.retry} />;\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ /** Default screen for unmatched routes. */
3
+ export declare const Unmatched: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=Unmatched.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Unmatched.d.ts","sourceRoot":"","sources":["../../src/views/Unmatched.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAM1C,2CAA2C;AAC3C,eAAO,MAAM,SAAS,+DAkCpB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import React, { forwardRef } from "react";
2
+ import { createURL } from "expo-linking";
3
+ import { StyleSheet } from "@bacons/react-views";
4
+ import { Link } from "./Link";
5
+ import { Text, View } from "@bacons/react-views";
6
+ /** Default screen for unmatched routes. */
7
+ export const Unmatched = forwardRef((props, ref) => {
8
+ const url = createURL("");
9
+ return (
10
+ // @ts-ignore
11
+ React.createElement(View, { ref: ref, accessibilityRole: "main", style: styles.container },
12
+ React.createElement(Text, { accessibilityRole: "heading", accessibilityLevel: 1, style: styles.title }, "Unmatched Route"),
13
+ React.createElement(Text, { accessibilityRole: "heading", accessibilityLevel: 2, style: styles.subtitle },
14
+ "Page could not be found.",
15
+ " ",
16
+ React.createElement(Link, { href: "/", style: styles.link }, "Go back.")),
17
+ React.createElement(Link, { href: "/", style: styles.link }, url),
18
+ process.env.NODE_ENV === "development" && (React.createElement(Link, { href: "/__index", style: styles.link }, "Sitemap"))));
19
+ });
20
+ const styles = StyleSheet.create({
21
+ container: {
22
+ flex: 1,
23
+ backgroundColor: "black",
24
+ padding: 24,
25
+ alignItems: "center",
26
+ justifyContent: "center",
27
+ },
28
+ title: {
29
+ color: "white",
30
+ fontSize: 36,
31
+ paddingBottom: 12,
32
+ marginBottom: 12,
33
+ borderBottomColor: "#323232",
34
+ borderBottomWidth: 1,
35
+ textAlign: "center",
36
+ fontWeight: "bold",
37
+ },
38
+ subtitle: {
39
+ color: "white",
40
+ fontSize: 18,
41
+ marginBottom: 12,
42
+ textAlign: "center",
43
+ },
44
+ link: { color: "rgba(255,255,255,0.4)", textAlign: "center" },
45
+ });
46
+ //# sourceMappingURL=Unmatched.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Unmatched.js","sourceRoot":"","sources":["../../src/views/Unmatched.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEjD,2CAA2C;AAC3C,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC/C,MAAM,GAAG,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;IAC1B,OAAO;IACH,aAAa;IACb,oBAAC,IAAI,IAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,EAAC,MAAM,EAAC,KAAK,EAAE,MAAM,CAAC,SAAS;QAC5D,oBAAC,IAAI,IACD,iBAAiB,EAAC,SAAS,EAC3B,kBAAkB,EAAE,CAAC,EACrB,KAAK,EAAE,MAAM,CAAC,KAAK,sBAGhB;QACP,oBAAC,IAAI,IACD,iBAAiB,EAAC,SAAS,EAC3B,kBAAkB,EAAE,CAAC,EACrB,KAAK,EAAE,MAAM,CAAC,QAAQ;;YAEG,GAAG;YAC5B,oBAAC,IAAI,IAAC,IAAI,EAAC,GAAG,EAAC,KAAK,EAAE,MAAM,CAAC,IAAI,eAE1B,CACJ;QAEP,oBAAC,IAAI,IAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,IAC9B,GAAG,CACD;QAEN,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,CACvC,oBAAC,IAAI,IAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,cAEnC,CACV,CACE,CACV,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC7B,SAAS,EAAE;QACP,IAAI,EAAE,CAAC;QACP,eAAe,EAAE,OAAO;QACxB,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KAC3B;IACD,KAAK,EAAE;QACH,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,aAAa,EAAE,EAAE;QACjB,YAAY,EAAE,EAAE;QAChB,iBAAiB,EAAE,SAAS;QAC5B,iBAAiB,EAAE,CAAC;QACpB,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,MAAM;KACrB;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,YAAY,EAAE,EAAE;QAChB,SAAS,EAAE,QAAQ;KACtB;IACD,IAAI,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,SAAS,EAAE,QAAQ,EAAE;CAChE,CAAC,CAAC","sourcesContent":["import React, { forwardRef } from \"react\";\nimport { createURL } from \"expo-linking\";\nimport { StyleSheet } from \"@bacons/react-views\";\nimport { Link } from \"./Link\";\nimport { Text, View } from \"@bacons/react-views\";\n\n/** Default screen for unmatched routes. */\nexport const Unmatched = forwardRef((props, ref) => {\n const url = createURL(\"\");\n return (\n // @ts-ignore\n <View ref={ref} accessibilityRole=\"main\" style={styles.container}>\n <Text\n accessibilityRole=\"heading\"\n accessibilityLevel={1}\n style={styles.title}\n >\n Unmatched Route\n </Text>\n <Text\n accessibilityRole=\"heading\"\n accessibilityLevel={2}\n style={styles.subtitle}\n >\n Page could not be found.{\" \"}\n <Link href=\"/\" style={styles.link}>\n Go back.\n </Link>\n </Text>\n\n <Link href={\"/\"} style={styles.link}>\n {url}\n </Link>\n\n {process.env.NODE_ENV === \"development\" && (\n <Link href={\"/__index\"} style={styles.link}>\n Sitemap\n </Link>\n )}\n </View>\n );\n});\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n backgroundColor: \"black\",\n padding: 24,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n title: {\n color: \"white\",\n fontSize: 36,\n paddingBottom: 12,\n marginBottom: 12,\n borderBottomColor: \"#323232\",\n borderBottomWidth: 1,\n textAlign: \"center\",\n fontWeight: \"bold\",\n },\n subtitle: {\n color: \"white\",\n fontSize: 18,\n marginBottom: 12,\n textAlign: \"center\",\n },\n link: { color: \"rgba(255,255,255,0.4)\", textAlign: \"center\" },\n});\n"]}
package/entry.js ADDED
@@ -0,0 +1,103 @@
1
+ import { registerRootComponent } from "expo";
2
+ import { ExpoRoot } from "expo-router";
3
+ import { View, Platform } from "react-native";
4
+ import Constants, { ExecutionEnvironment } from "expo-constants";
5
+
6
+ // Must be exported or Fast Refresh won't update the context >:[
7
+ export function App() {
8
+ // Babel + Expo CLI: process.env.EXPO_ROUTER_APP_ROOT -> '../../apps/demo/app'
9
+ // console.log("output", process.env.EXPO_ROUTER_APP_ROOT);
10
+ const ctx = require.context(process.env.EXPO_ROUTER_APP_ROOT);
11
+ return <ExpoRoot context={ctx} />;
12
+ }
13
+
14
+ function isBaseObject(obj) {
15
+ if (Object.prototype.toString.call(obj) !== "[object Object]") {
16
+ return false;
17
+ }
18
+ const proto = Object.getPrototypeOf(obj);
19
+ if (proto === null) {
20
+ return true;
21
+ }
22
+ return proto === Object.prototype;
23
+ }
24
+
25
+ function isErrorShaped(error) {
26
+ return (
27
+ error &&
28
+ typeof error === "object" &&
29
+ typeof error.name === "string" &&
30
+ typeof error.message === "string"
31
+ );
32
+ }
33
+
34
+ /**
35
+ * After we throw this error, any number of tools could handle it.
36
+ * This check ensures the error is always in a reason state before surfacing it to the runtime.
37
+ */
38
+ function convertError(error) {
39
+ if (isErrorShaped(error)) {
40
+ return error;
41
+ }
42
+
43
+ if (process.env.NODE_ENV === "development") {
44
+ if (error == null) {
45
+ return new Error("A null/undefined error was thrown.");
46
+ }
47
+ }
48
+
49
+ if (isBaseObject(error)) {
50
+ return new Error(JSON.stringify(error));
51
+ }
52
+
53
+ return new Error(String(error));
54
+ }
55
+
56
+ function preventAutoHide() {
57
+ // Not applicable to Expo Go.
58
+ if (Constants.executionEnvironment !== ExecutionEnvironment.StoreClient) {
59
+ try {
60
+ // Automatically handle hiding the splash screen if expo-splash-screen is installed.
61
+ return require("expo-splash-screen").preventAutoHideAsync();
62
+ } catch {}
63
+ }
64
+ }
65
+
66
+ function hideSplash() {
67
+ try {
68
+ return require("expo-splash-screen").hideAsync();
69
+ } catch {}
70
+ }
71
+
72
+ (() => {
73
+ try {
74
+ preventAutoHide();
75
+
76
+ registerRootComponent(App);
77
+ } catch (e) {
78
+ // Hide the splash screen if there was an error so the user can see it.
79
+ hideSplash();
80
+
81
+ const error = convertError(e);
82
+ // Prevent the app from throwing confusing:
83
+ // ERROR Invariant Violation: "main" has not been registered. This can happen if:
84
+ // * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
85
+ // * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
86
+ registerRootComponent(View);
87
+
88
+ // Console is pretty useless on native, on web you get interactive stack traces.
89
+ if (Platform.OS === "web") {
90
+ console.error(error);
91
+ console.error(
92
+ `A runtime error has occurred while rendering the root component.`
93
+ );
94
+ }
95
+
96
+ // Give React a tick to render before throwing.
97
+ setTimeout(() => {
98
+ throw error;
99
+ });
100
+
101
+ // TODO: Render a production-only error screen.
102
+ }
103
+ })();
@@ -0,0 +1,14 @@
1
+ // Learn more https://docs.expo.io/guides/customizing-metro
2
+ const { getDefaultConfig } = require("expo/metro-config");
3
+
4
+ module.exports.getDefaultConfig = (dirname) => {
5
+ const config = getDefaultConfig(dirname);
6
+
7
+ config.transformer = {
8
+ ...config.transformer,
9
+ // `require.context` support
10
+ unstable_allowRequireContext: true,
11
+ };
12
+
13
+ return config;
14
+ };
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "expo-router",
3
+ "version": "0.0.1",
4
+ "main": "build/index.js",
5
+ "files": [
6
+ "entry.js",
7
+ "build",
8
+ "babel.js",
9
+ "assets",
10
+ "metro-config.js"
11
+ ],
12
+ "repository": {
13
+ "url": "https://github.com/expo/router.git",
14
+ "type": "git",
15
+ "directory": "packages/expo-router"
16
+ },
17
+ "scripts": {
18
+ "build": "expo-module build",
19
+ "clean": "expo-module clean",
20
+ "lint": "expo-module lint",
21
+ "test": "expo-module test",
22
+ "prepare": "expo-module prepare",
23
+ "prepublishOnly": "expo-module prepublishOnly",
24
+ "expo-module": "expo-module"
25
+ },
26
+ "keywords": [
27
+ "react-native",
28
+ "expo"
29
+ ],
30
+ "jest": {
31
+ "preset": "jest-expo"
32
+ },
33
+ "peerDependencies": {
34
+ "expo": "^46.0.2",
35
+ "expo-splash-screen": "^0.16.2",
36
+ "metro": "~0.72.3",
37
+ "react-native-gesture-handler": "~2.5.0"
38
+ },
39
+ "devDependencies": {
40
+ "@radix-ui/react-slot": "^1.0.0",
41
+ "@types/jest": "^26",
42
+ "expo-module-scripts": "^2.0.0",
43
+ "expo-splash-screen": "^0.16.2",
44
+ "jest": "^26.6.3"
45
+ },
46
+ "dependencies": {
47
+ "@bacons/react-views": "^1.1.1",
48
+ "@radix-ui/react-slot": "^1.0.0",
49
+ "@react-navigation/bottom-tabs": "^6.3.3",
50
+ "@react-navigation/drawer": "^6.4.4",
51
+ "@react-navigation/native": "^6.0.12",
52
+ "@react-navigation/native-stack": "^6.8.0",
53
+ "@react-navigation/stack": "^6.2.3",
54
+ "expo-constants": "~13.2.4",
55
+ "expo-linking": "^3.2.2",
56
+ "expo-status-bar": "^1.4.0",
57
+ "react-native-gesture-handler": "~2.5.0",
58
+ "react-native-reanimated": "~2.9.1",
59
+ "react-native-safe-area-context": "4.3.1",
60
+ "react-native-screens": "~3.15.0"
61
+ }
62
+ }