expo-router 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/build/ContextNavigationContainer.d.ts +3 -3
  2. package/build/ContextNavigationContainer.d.ts.map +1 -1
  3. package/build/ContextNavigationContainer.js +33 -12
  4. package/build/ContextNavigationContainer.js.map +1 -1
  5. package/build/ContextNavigator.d.ts +1 -1
  6. package/build/ContextNavigator.d.ts.map +1 -1
  7. package/build/ContextNavigator.js +8 -6
  8. package/build/ContextNavigator.js.map +1 -1
  9. package/build/Route.d.ts +1 -1
  10. package/build/Route.d.ts.map +1 -1
  11. package/build/Route.js +3 -3
  12. package/build/Route.js.map +1 -1
  13. package/build/aasa.js +1 -1
  14. package/build/aasa.js.map +1 -1
  15. package/build/fork/getPathFromState.d.ts +3 -3
  16. package/build/fork/getPathFromState.d.ts.map +1 -1
  17. package/build/fork/getPathFromState.js +9 -11
  18. package/build/fork/getPathFromState.js.map +1 -1
  19. package/build/fork/getStateFromPath.d.ts +3 -3
  20. package/build/fork/getStateFromPath.d.ts.map +1 -1
  21. package/build/fork/getStateFromPath.js +3 -4
  22. package/build/fork/getStateFromPath.js.map +1 -1
  23. package/build/getLinkingConfig.d.ts +3 -3
  24. package/build/getLinkingConfig.d.ts.map +1 -1
  25. package/build/getLinkingConfig.js +3 -3
  26. package/build/getLinkingConfig.js.map +1 -1
  27. package/build/getRoutes.d.ts.map +1 -1
  28. package/build/getRoutes.js.map +1 -1
  29. package/build/index.d.ts +3 -3
  30. package/build/index.d.ts.map +1 -1
  31. package/build/index.js +3 -3
  32. package/build/index.js.map +1 -1
  33. package/build/layouts/Drawer.d.ts +1 -1
  34. package/build/layouts/Drawer.d.ts.map +1 -1
  35. package/build/layouts/Drawer.js +2 -2
  36. package/build/layouts/Drawer.js.map +1 -1
  37. package/build/layouts/NativeStack.d.ts +1 -1
  38. package/build/layouts/NativeStack.d.ts.map +1 -1
  39. package/build/layouts/NativeStack.js +2 -2
  40. package/build/layouts/NativeStack.js.map +1 -1
  41. package/build/layouts/Stack.d.ts +1 -1
  42. package/build/layouts/Stack.d.ts.map +1 -1
  43. package/build/layouts/Stack.js +2 -2
  44. package/build/layouts/Stack.js.map +1 -1
  45. package/build/layouts/Tabs.d.ts +1 -1
  46. package/build/layouts/Tabs.d.ts.map +1 -1
  47. package/build/layouts/Tabs.js +2 -2
  48. package/build/layouts/Tabs.js.map +1 -1
  49. package/build/layouts/withLayoutContext.d.ts +2 -2
  50. package/build/layouts/withLayoutContext.d.ts.map +1 -1
  51. package/build/layouts/withLayoutContext.js +10 -10
  52. package/build/layouts/withLayoutContext.js.map +1 -1
  53. package/build/link/Link.d.ts +26 -0
  54. package/build/link/Link.d.ts.map +1 -0
  55. package/build/link/Link.js +40 -0
  56. package/build/link/Link.js.map +1 -0
  57. package/build/link/href.d.ts +9 -0
  58. package/build/link/href.d.ts.map +1 -0
  59. package/build/link/href.js +34 -0
  60. package/build/link/href.js.map +1 -0
  61. package/build/{linking.d.ts → link/linking.d.ts} +2 -2
  62. package/build/link/linking.d.ts.map +1 -0
  63. package/build/{linking.js → link/linking.js} +2 -2
  64. package/build/link/linking.js.map +1 -0
  65. package/build/{useLink.d.ts → link/useLink.d.ts} +2 -1
  66. package/build/link/useLink.d.ts.map +1 -0
  67. package/build/{useLink.js → link/useLink.js} +9 -4
  68. package/build/link/useLink.js.map +1 -0
  69. package/build/link/useLinkToPath.d.ts +2 -0
  70. package/build/link/useLinkToPath.d.ts.map +1 -0
  71. package/build/link/useLinkToPath.js +45 -0
  72. package/build/link/useLinkToPath.js.map +1 -0
  73. package/build/link/useLinkToPathProps.d.ts +11 -0
  74. package/build/link/useLinkToPathProps.d.ts.map +1 -0
  75. package/build/link/useLinkToPathProps.js +31 -0
  76. package/build/link/useLinkToPathProps.js.map +1 -0
  77. package/build/matchers.d.ts.map +1 -1
  78. package/build/matchers.js +2 -1
  79. package/build/matchers.js.map +1 -1
  80. package/build/onboard/Tutorial.d.ts.map +1 -1
  81. package/build/onboard/Tutorial.js +1 -1
  82. package/build/onboard/Tutorial.js.map +1 -1
  83. package/build/primitives.d.ts.map +1 -1
  84. package/build/primitives.js +1 -1
  85. package/build/primitives.js.map +1 -1
  86. package/build/useScreens.js +1 -1
  87. package/build/useScreens.js.map +1 -1
  88. package/build/views/Directory.d.ts.map +1 -1
  89. package/build/views/Directory.js +4 -4
  90. package/build/views/Directory.js.map +1 -1
  91. package/build/views/ErrorBoundary.d.ts +1 -1
  92. package/build/views/ErrorBoundary.d.ts.map +1 -1
  93. package/build/views/ErrorBoundary.js +56 -19
  94. package/build/views/ErrorBoundary.js.map +1 -1
  95. package/build/views/Layout.d.ts +1 -1
  96. package/build/views/Layout.d.ts.map +1 -1
  97. package/build/views/Layout.js +1 -1
  98. package/build/views/Layout.js.map +1 -1
  99. package/build/views/Root.d.ts +1 -1
  100. package/build/views/Root.d.ts.map +1 -1
  101. package/build/views/Root.js +4 -3
  102. package/build/views/Root.js.map +1 -1
  103. package/build/views/Screen.d.ts +1 -1
  104. package/build/views/Screen.d.ts.map +1 -1
  105. package/build/views/Screen.js +2 -1
  106. package/build/views/Screen.js.map +1 -1
  107. package/build/views/Try.d.ts.map +1 -1
  108. package/build/views/Try.js.map +1 -1
  109. package/build/views/Unmatched.d.ts.map +1 -1
  110. package/build/views/Unmatched.js +3 -4
  111. package/build/views/Unmatched.js.map +1 -1
  112. package/package.json +2 -3
  113. package/build/linking.d.ts.map +0 -1
  114. package/build/linking.js.map +0 -1
  115. package/build/useLink.d.ts.map +0 -1
  116. package/build/useLink.js.map +0 -1
  117. package/build/views/Link.d.ts +0 -36
  118. package/build/views/Link.d.ts.map +0 -1
  119. package/build/views/Link.js +0 -87
  120. package/build/views/Link.js.map +0 -1
  121. package/metro-config.js +0 -14
@@ -0,0 +1,26 @@
1
+ import { TextProps } from "@bacons/react-views";
2
+ import * as React from "react";
3
+ import { GestureResponderEvent } from "react-native";
4
+ import { Href } from "./href";
5
+ declare type Props = {
6
+ /** Add a property which is familiar to */
7
+ href: Href;
8
+ /** Forward props to child component. Useful for custom buttons. */
9
+ asChild?: boolean;
10
+ /** Should replace the current screen without adding to the history. */
11
+ replace?: boolean;
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.asChild Forward props to child component. Useful for custom buttons.
22
+ * @param props.children Child elements to render the content.
23
+ */
24
+ export declare const Link: React.ForwardRefExoticComponent<Pick<Props, "children" | "replace" | "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" | 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/link/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAe,MAAM,QAAQ,CAAC;AAG3C,aAAK,KAAK,GAAG;IACX,2CAA2C;IAC3C,IAAI,EAAE,IAAI,CAAC;IAGX,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,OAAO,CAAC,EAAE,CACR,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,qBAAqB,KACvE,IAAI,CAAC;CACX,GAAG,CAAC,SAAS,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,s7BAAmC,CAAC"}
@@ -0,0 +1,40 @@
1
+ // Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and
2
+ // `to` / `action` support removed.
3
+ import { Text } from "@bacons/react-views";
4
+ import { Slot } from "@radix-ui/react-slot";
5
+ import * as React from "react";
6
+ import { Platform } from "react-native";
7
+ import { resolveHref } from "./href";
8
+ import useLinkToPathProps from "./useLinkToPathProps";
9
+ /**
10
+ * Component to render link to another screen using a path.
11
+ * Uses an anchor tag on the web.
12
+ *
13
+ * @param props.href Absolute path to screen (e.g. `/feeds/hot`).
14
+ * @param props.asChild Forward props to child component. Useful for custom buttons.
15
+ * @param props.children Child elements to render the content.
16
+ */
17
+ export const Link = React.forwardRef(ExpoRouterLink);
18
+ function ExpoRouterLink({ href, replace, asChild, ...rest }, ref) {
19
+ // TODO: Auto use router's client-side event.
20
+ const resolvedHref = React.useMemo(() => resolveHref(href), [href]);
21
+ const props = useLinkToPathProps({ href: resolvedHref, replace });
22
+ const onPress = (e) => {
23
+ if ("onPress" in rest) {
24
+ rest.onPress?.(e);
25
+ }
26
+ props.onPress(e);
27
+ };
28
+ return React.createElement(
29
+ // @ts-expect-error: slot is not type-safe
30
+ asChild ? Slot : Text, {
31
+ ref,
32
+ ...props,
33
+ ...rest,
34
+ ...Platform.select({
35
+ web: { onClick: onPress },
36
+ default: { onPress },
37
+ }),
38
+ });
39
+ }
40
+ //# sourceMappingURL=Link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,mCAAmC;AACnC,OAAO,EAAE,IAAI,EAAa,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAyB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAQ,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAkBtD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAErD,SAAS,cAAc,CACrB,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAS,EAC1C,GAA6B;IAE7B,6CAA6C;IAC7C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEpE,MAAM,KAAK,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,CACd,CAA0E,EAC1E,EAAE;QACF,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;SACnB;QACD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC,aAAa;IACxB,0CAA0C;IAC1C,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EACrB;QACE,GAAG;QACH,GAAG,KAAK;QACR,GAAG,IAAI;QACP,GAAG,QAAQ,CAAC,MAAM,CAAC;YACjB,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAS;YAChC,OAAO,EAAE,EAAE,OAAO,EAAE;SACrB,CAAC;KACH,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and\n// `to` / `action` support removed.\nimport { Text, TextProps } from \"@bacons/react-views\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { GestureResponderEvent, Platform } from \"react-native\";\n\nimport { Href, resolveHref } from \"./href\";\nimport useLinkToPathProps from \"./useLinkToPathProps\";\n\ntype Props = {\n /** Add a property which is familiar to */\n href: Href;\n\n // TODO(EvanBacon): This may need to be extracted for React Native style support.\n /** Forward props to child component. Useful for custom buttons. */\n asChild?: boolean;\n\n /** Should replace the current screen without adding to the history. */\n replace?: boolean;\n\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.asChild Forward props to child component. Useful for custom buttons.\n * @param props.children Child elements to render the content.\n */\nexport const Link = React.forwardRef(ExpoRouterLink);\n\nfunction ExpoRouterLink(\n { href, replace, asChild, ...rest }: Props,\n ref: React.ForwardedRef<Text>\n) {\n // TODO: Auto use router's client-side event.\n const resolvedHref = React.useMemo(() => resolveHref(href), [href]);\n\n const props = useLinkToPathProps({ href: resolvedHref, replace });\n\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if (\"onPress\" in rest) {\n rest.onPress?.(e);\n }\n props.onPress(e);\n };\n\n return React.createElement(\n // @ts-expect-error: slot is not type-safe\n asChild ? Slot : Text,\n {\n ref,\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n }\n );\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export declare type Href = string | {
2
+ pathname?: string;
3
+ query?: Record<string, any>;
4
+ };
5
+ export declare const resolveHref: (href: {
6
+ pathname?: string;
7
+ query?: Record<string, any>;
8
+ } | string) => string;
9
+ //# sourceMappingURL=href.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"href.d.ts","sourceRoot":"","sources":["../../src/link/href.ts"],"names":[],"mappings":"AAAA,oBAAY,IAAI,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,CAAC;AAE/E,eAAO,MAAM,WAAW,SAChB;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,GAAG,MAAM,KAChE,MAUF,CAAC"}
@@ -0,0 +1,34 @@
1
+ export const resolveHref = (href) => {
2
+ if (typeof href === "string") {
3
+ return href ?? "";
4
+ }
5
+ const path = href.pathname ?? "";
6
+ if (!href?.query) {
7
+ return path;
8
+ }
9
+ const { pathname, query } = createQualifiedPathname(path, { ...href.query });
10
+ return pathname + (Object.keys(query).length ? `?${createQuery(query)}` : "");
11
+ };
12
+ function createQualifiedPathname(pathname, query) {
13
+ for (const [key, value = ""] of Object.entries(query)) {
14
+ const dynamicKey = `[${key}]`;
15
+ const deepDynamicKey = `[...${key}]`;
16
+ if (pathname.includes(dynamicKey)) {
17
+ pathname = pathname.replace(dynamicKey, Array.isArray(value) ? value.join("/") : value);
18
+ }
19
+ else if (pathname.includes(deepDynamicKey)) {
20
+ pathname = pathname.replace(deepDynamicKey, Array.isArray(value) ? value.join("/") : value);
21
+ }
22
+ else {
23
+ continue;
24
+ }
25
+ delete query[key];
26
+ }
27
+ return { pathname, query };
28
+ }
29
+ function createQuery(query) {
30
+ return Object.keys(query)
31
+ .map((key) => `${key}=${query[key]}`)
32
+ .join("&");
33
+ }
34
+ //# sourceMappingURL=href.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"href.js","sourceRoot":"","sources":["../../src/link/href.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAiE,EACzD,EAAE;IACV,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAI,IAAI,EAAE,CAAC;KACnB;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;IACjC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAChB,OAAO,IAAI,CAAC;KACb;IACD,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,uBAAuB,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7E,OAAO,QAAQ,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAChF,CAAC,CAAC;AAEF,SAAS,uBAAuB,CAAC,QAAgB,EAAE,KAA0B;IAC3E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACrD,MAAM,UAAU,GAAG,IAAI,GAAG,GAAG,CAAC;QAC9B,MAAM,cAAc,GAAG,OAAO,GAAG,GAAG,CAAC;QACrC,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YACjC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CACzB,UAAU,EACV,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAC/C,CAAC;SACH;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;YAC5C,QAAQ,GAAG,QAAQ,CAAC,OAAO,CACzB,cAAc,EACd,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAC/C,CAAC;SACH;aAAM;YACL,SAAS;SACV;QAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;IACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,SAAS,WAAW,CAAC,KAA0B;IAC7C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;SACtB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;SACpC,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC","sourcesContent":["export type Href = string | { pathname?: string; query?: Record<string, any> };\n\nexport const resolveHref = (\n href: { pathname?: string; query?: Record<string, any> } | string\n): string => {\n if (typeof href === \"string\") {\n return href ?? \"\";\n }\n const path = href.pathname ?? \"\";\n if (!href?.query) {\n return path;\n }\n const { pathname, query } = createQualifiedPathname(path, { ...href.query });\n return pathname + (Object.keys(query).length ? `?${createQuery(query)}` : \"\");\n};\n\nfunction createQualifiedPathname(pathname: string, query: Record<string, any>) {\n for (const [key, value = \"\"] of Object.entries(query)) {\n const dynamicKey = `[${key}]`;\n const deepDynamicKey = `[...${key}]`;\n if (pathname.includes(dynamicKey)) {\n pathname = pathname.replace(\n dynamicKey,\n Array.isArray(value) ? value.join(\"/\") : value\n );\n } else if (pathname.includes(deepDynamicKey)) {\n pathname = pathname.replace(\n deepDynamicKey,\n Array.isArray(value) ? value.join(\"/\") : value\n );\n } else {\n continue;\n }\n\n delete query[key];\n }\n return { pathname, query };\n}\n\nfunction createQuery(query: Record<string, any>) {\n return Object.keys(query)\n .map((key) => `${key}=${query[key]}`)\n .join(\"&\");\n}\n"]}
@@ -1,5 +1,5 @@
1
- import getPathFromState from "./fork/getPathFromState";
2
- import getStateFromPath from "./fork/getStateFromPath";
1
+ import getPathFromState from "../fork/getPathFromState";
2
+ import getStateFromPath from "../fork/getStateFromPath";
3
3
  export declare function getInitialURL(): Promise<string>;
4
4
  export declare function getRootURL(): string;
5
5
  export declare function addEventListener(listener: (url: string) => void): () => void;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":"AAGA,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAOxD,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CA+BrD;AAID,wBAAgB,UAAU,WAKzB;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,cAiC/D;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import Constants, { ExecutionEnvironment } from "expo-constants";
2
2
  import * as Linking from "expo-linking";
3
- import getPathFromState from "./fork/getPathFromState";
4
- import getStateFromPath from "./fork/getStateFromPath";
3
+ import getPathFromState from "../fork/getPathFromState";
4
+ import getStateFromPath from "../fork/getStateFromPath";
5
5
  // A custom getInitialURL is used on native to ensure the app always starts at
6
6
  // the root path if it's launched from something other than a deep link.
7
7
  // This helps keep the native functionality working like the web functionality.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linking.js","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAA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from \"expo-constants\";\nimport * as Linking from \"expo-linking\";\n\nimport getPathFromState from \"../fork/getPathFromState\";\nimport getStateFromPath from \"../fork/getStateFromPath\";\n\n// A custom getInitialURL is used on native to ensure the app always starts at\n// the root path if it's launched from something other than a deep link.\n// This helps keep the native functionality working like the web functionality.\n// For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`\n// then `/index` would be used on web and `/settings` would be used on native.\nexport async function getInitialURL(): Promise<string> {\n const url = await Promise.race<string>([\n (async () => {\n const url = await Linking.getInitialURL();\n\n // NOTE(EvanBacon): This could probably be wrapped with the development boundary\n // since Expo Go is mostly just used in development.\n\n // Expo Go is weird and requires the root path to be `/--/`\n if (\n url &&\n Constants.executionEnvironment === ExecutionEnvironment.StoreClient\n ) {\n const parsed = Linking.parse(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (parsed.path === null || [\"\", \"/\"].includes(parsed.path)) {\n return getRootURL();\n }\n }\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n return url ?? getRootURL();\n })(),\n new Promise<string>((resolve) =>\n // Timeout in 150ms if `getInitialState` doesn't resolve\n // Workaround for https://github.com/facebook/react-native/issues/25675\n setTimeout(() => resolve(getRootURL()), 150)\n ),\n ]);\n return url;\n}\n\nlet _rootURL: string | undefined;\n\nexport function getRootURL() {\n if (_rootURL === undefined) {\n _rootURL = Linking.createURL(\"/\");\n }\n return _rootURL;\n}\n\nexport function addEventListener(listener: (url: string) => void) {\n let callback: (({ url }: { url: string }) => void) | undefined = undefined;\n\n if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n // This extra work is only done in the Expo Go app.\n callback = ({ url }: { url: string }) => {\n const parsed = Linking.parse(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (parsed.path === null || [\"\", \"/\"].includes(parsed.path)) {\n listener(getRootURL());\n } else {\n listener(url);\n }\n };\n } else {\n callback = ({ url }: { url: string }) => listener(url);\n }\n const subscription = Linking.addEventListener(\"url\", callback) as\n | { remove(): void }\n | undefined;\n\n // Storing this in a local variable stops Jest from complaining about import after teardown\n const removeEventListener = Linking.removeEventListener?.bind(Linking);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n if (subscription?.remove) {\n subscription.remove();\n } else {\n removeEventListener?.(\"url\", callback);\n }\n };\n}\n\nexport { getStateFromPath, getPathFromState };\n"]}
@@ -1,6 +1,7 @@
1
- import { Href, resolveHref } from "./views/Link";
1
+ import { Href, resolveHref } from "./href";
2
2
  export declare function useLink(): {
3
3
  push: (href: Href) => void;
4
+ replace: (href: Href) => void;
4
5
  back: () => void;
5
6
  parse: typeof resolveHref;
6
7
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLink.d.ts","sourceRoot":"","sources":["../../src/link/useLink.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAI3C,wBAAgB,OAAO,IAAI;IACzB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,OAAO,WAAW,CAAC;CAC3B,CAqBA"}
@@ -1,18 +1,23 @@
1
- import { useLinkTo, useNavigation } from "@react-navigation/native";
1
+ import { useNavigation } from "@react-navigation/native";
2
2
  import { useMemo } from "react";
3
- import { resolveHref } from "./views/Link";
3
+ import { resolveHref } from "./href";
4
+ import { useLinkToPath } from "./useLinkToPath";
4
5
  // Wraps useLinkTo to provide an API which is similar to the Link component.
5
6
  export function useLink() {
6
- const linkTo = useLinkTo();
7
+ const linkTo = useLinkToPath();
7
8
  const navigation = useNavigation();
8
9
  return useMemo(() => ({
9
10
  push: (url) => {
10
11
  const href = resolveHref(url);
11
12
  linkTo(href);
12
13
  },
14
+ replace: (url) => {
15
+ const href = resolveHref(url);
16
+ linkTo(href, "REPLACE");
17
+ },
13
18
  back: () => navigation?.goBack(),
14
19
  parse: resolveHref,
15
- // TODO(EvanBacon): add `replace`, `pathname`, `query`, maybe `reload`
20
+ // TODO(EvanBacon): add `pathname`, `query`, maybe `reload`
16
21
  // TODO(EvanBacon): add `canGoBack` but maybe more like a `hasContext`
17
22
  }), [navigation, linkTo]);
18
23
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLink.js","sourceRoot":"","sources":["../../src/link/useLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAQ,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,4EAA4E;AAC5E,MAAM,UAAU,OAAO;IAMrB,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IAEnC,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,CAAC,GAAS,EAAE,EAAE;YAClB,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;QACD,OAAO,EAAE,CAAC,GAAS,EAAE,EAAE;YACrB,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YAC9B,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC1B,CAAC;QACD,IAAI,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE;QAChC,KAAK,EAAE,WAAW;QAClB,2DAA2D;QAC3D,sEAAsE;KACvE,CAAC,EACF,CAAC,UAAU,EAAE,MAAM,CAAC,CACrB,CAAC;AACJ,CAAC","sourcesContent":["import { useNavigation } from \"@react-navigation/native\";\nimport { useMemo } from \"react\";\n\nimport { Href, resolveHref } from \"./href\";\nimport { useLinkToPath } from \"./useLinkToPath\";\n\n// Wraps useLinkTo to provide an API which is similar to the Link component.\nexport function useLink(): {\n push: (href: Href) => void;\n replace: (href: Href) => void;\n back: () => void;\n parse: typeof resolveHref;\n} {\n const linkTo = useLinkToPath();\n const navigation = useNavigation();\n\n return useMemo(\n () => ({\n push: (url: Href) => {\n const href = resolveHref(url);\n linkTo(href);\n },\n replace: (url: Href) => {\n const href = resolveHref(url);\n linkTo(href, \"REPLACE\");\n },\n back: () => navigation?.goBack(),\n parse: resolveHref,\n // TODO(EvanBacon): add `pathname`, `query`, maybe `reload`\n // TODO(EvanBacon): add `canGoBack` but maybe more like a `hasContext`\n }),\n [navigation, linkTo]\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function useLinkToPath(): (to: string, event?: string) => void;
2
+ //# sourceMappingURL=useLinkToPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLinkToPath.d.ts","sourceRoot":"","sources":["../../src/link/useLinkToPath.ts"],"names":[],"mappings":"AASA,wBAAgB,aAAa,SAKpB,MAAM,UAAU,MAAM,UA6C9B"}
@@ -0,0 +1,45 @@
1
+ import { getActionFromState, getStateFromPath, NavigationContainerRefContext, } from "@react-navigation/core";
2
+ import { LinkingContext } from "@react-navigation/native";
3
+ import * as React from "react";
4
+ import { Linking } from "react-native";
5
+ export function useLinkToPath() {
6
+ const navigation = React.useContext(NavigationContainerRefContext);
7
+ const linking = React.useContext(LinkingContext);
8
+ const linkTo = React.useCallback((to, event) => {
9
+ if (navigation === undefined) {
10
+ throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
11
+ }
12
+ if (!to.startsWith("/")) {
13
+ if (/:\/\//.test(to)) {
14
+ // Open external link
15
+ Linking.openURL(to);
16
+ return;
17
+ }
18
+ else {
19
+ throw new Error(`The href must start with '/' (${to}) or be a fully qualified URL.`);
20
+ }
21
+ }
22
+ const { options } = linking;
23
+ const state = options?.getStateFromPath
24
+ ? options.getStateFromPath(to, options.config)
25
+ : getStateFromPath(to, options?.config);
26
+ if (state) {
27
+ const action = getActionFromState(state, options?.config);
28
+ if (action !== undefined) {
29
+ if (event) {
30
+ // @ts-ignore
31
+ action.type = event;
32
+ }
33
+ navigation.dispatch(action);
34
+ }
35
+ else {
36
+ navigation.reset(state);
37
+ }
38
+ }
39
+ else {
40
+ throw new Error("Failed to parse the path to a navigation state.");
41
+ }
42
+ }, [linking, navigation]);
43
+ return linkTo;
44
+ }
45
+ //# sourceMappingURL=useLinkToPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLinkToPath.js","sourceRoot":"","sources":["../../src/link/useLinkToPath.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,UAAU,aAAa;IAC3B,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IAEjD,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAC9B,CAAC,EAAU,EAAE,KAAc,EAAE,EAAE;QAC7B,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;SACH;QAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACvB,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;gBACpB,qBAAqB;gBACrB,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBACpB,OAAO;aACR;iBAAM;gBACL,MAAM,IAAI,KAAK,CACb,iCAAiC,EAAE,gCAAgC,CACpE,CAAC;aACH;SACF;QAED,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAE5B,MAAM,KAAK,GAAG,OAAO,EAAE,gBAAgB;YACrC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC;YAC9C,CAAC,CAAC,gBAAgB,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAE1C,IAAI,KAAK,EAAE;YACT,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAE1D,IAAI,MAAM,KAAK,SAAS,EAAE;gBACxB,IAAI,KAAK,EAAE;oBACT,aAAa;oBACb,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC;iBACrB;gBACD,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;aAC7B;iBAAM;gBACL,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACzB;SACF;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACpE;IACH,CAAC,EACD,CAAC,OAAO,EAAE,UAAU,CAAC,CACtB,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {\n getActionFromState,\n getStateFromPath,\n NavigationContainerRefContext,\n} from \"@react-navigation/core\";\nimport { LinkingContext } from \"@react-navigation/native\";\nimport * as React from \"react\";\nimport { Linking } from \"react-native\";\n\nexport function useLinkToPath() {\n const navigation = React.useContext(NavigationContainerRefContext);\n const linking = React.useContext(LinkingContext);\n\n const linkTo = React.useCallback(\n (to: string, event?: string) => {\n if (navigation === undefined) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!to.startsWith(\"/\")) {\n if (/:\\/\\//.test(to)) {\n // Open external link\n Linking.openURL(to);\n return;\n } else {\n throw new Error(\n `The href must start with '/' (${to}) or be a fully qualified URL.`\n );\n }\n }\n\n const { options } = linking;\n\n const state = options?.getStateFromPath\n ? options.getStateFromPath(to, options.config)\n : getStateFromPath(to, options?.config);\n\n if (state) {\n const action = getActionFromState(state, options?.config);\n\n if (action !== undefined) {\n if (event) {\n // @ts-ignore\n action.type = event;\n }\n navigation.dispatch(action);\n } else {\n navigation.reset(state);\n }\n } else {\n throw new Error(\"Failed to parse the path to a navigation state.\");\n }\n },\n [linking, navigation]\n );\n\n return linkTo;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import { GestureResponderEvent } from "react-native";
3
+ export default function useLinkToPathProps(props: {
4
+ href: string;
5
+ replace?: boolean;
6
+ }): {
7
+ href: string;
8
+ accessibilityRole: "link";
9
+ onPress: (e?: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => void;
10
+ };
11
+ //# sourceMappingURL=useLinkToPathProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLinkToPathProps.d.ts","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAI/D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,KAAK,EAAE;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;;;kBAIO,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,qBAAqB;EA6B9E"}
@@ -0,0 +1,31 @@
1
+ import { Platform } from "react-native";
2
+ import { useLinkToPath } from "./useLinkToPath";
3
+ export default function useLinkToPathProps(props) {
4
+ const linkTo = useLinkToPath();
5
+ const onPress = (e) => {
6
+ let shouldHandle = false;
7
+ if (Platform.OS !== "web" || !e) {
8
+ shouldHandle = e ? !e.defaultPrevented : true;
9
+ }
10
+ else if (!e.defaultPrevented && // onPress prevented default
11
+ // @ts-expect-error: these properties exist on web, but not in React Native
12
+ !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys
13
+ // @ts-expect-error: these properties exist on web, but not in React Native
14
+ (e.button == null || e.button === 0) && // ignore everything but left clicks
15
+ // @ts-expect-error: these properties exist on web, but not in React Native
16
+ [undefined, null, "", "self"].includes(e.currentTarget?.target) // let browser handle "target=_blank" etc.
17
+ ) {
18
+ e.preventDefault();
19
+ shouldHandle = true;
20
+ }
21
+ if (shouldHandle) {
22
+ linkTo(props.href, props.replace ? "REPLACE" : undefined);
23
+ }
24
+ };
25
+ return {
26
+ href: props.href,
27
+ accessibilityRole: "link",
28
+ onPress,
29
+ };
30
+ }
31
+ //# sourceMappingURL=useLinkToPathProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLinkToPathProps.js","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":"AACA,OAAO,EAAyB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,KAG1C;IACC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAE/B,MAAM,OAAO,GAAG,CACd,CAA2E,EAC3E,EAAE;QACF,IAAI,YAAY,GAAG,KAAK,CAAC;QAEzB,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,EAAE;YAC/B,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC;SAC/C;aAAM,IACL,CAAC,CAAC,CAAC,gBAAgB,IAAI,4BAA4B;YACnD,2EAA2E;YAC3E,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,mCAAmC;YAC1F,2EAA2E;YAC3E,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,oCAAoC;YAC5E,2EAA2E;YAC3E,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,0CAA0C;UAC1G;YACA,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,YAAY,GAAG,IAAI,CAAC;SACrB;QAED,IAAI,YAAY,EAAE;YAChB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;SAC3D;IACH,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,iBAAiB,EAAE,MAAe;QAClC,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\nimport { GestureResponderEvent, Platform } from \"react-native\";\n\nimport { useLinkToPath } from \"./useLinkToPath\";\n\nexport default function useLinkToPathProps(props: {\n href: string;\n replace?: boolean;\n}) {\n const linkTo = useLinkToPath();\n\n const onPress = (\n e?: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n let shouldHandle = false;\n\n if (Platform.OS !== \"web\" || !e) {\n shouldHandle = e ? !e.defaultPrevented : true;\n } else if (\n !e.defaultPrevented && // onPress prevented default\n // @ts-expect-error: these properties exist on web, but not in React Native\n !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys\n // @ts-expect-error: these properties exist on web, but not in React Native\n (e.button == null || e.button === 0) && // ignore everything but left clicks\n // @ts-expect-error: these properties exist on web, but not in React Native\n [undefined, null, \"\", \"self\"].includes(e.currentTarget?.target) // let browser handle \"target=_blank\" etc.\n ) {\n e.preventDefault();\n shouldHandle = true;\n }\n\n if (shouldHandle) {\n linkTo(props.href, props.replace ? \"REPLACE\" : undefined);\n }\n };\n\n return {\n href: props.href,\n accessibilityRole: \"link\" as const,\n onPress,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../src/matchers.tsx"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGjE;AAED,kCAAkC;AAClC,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE1E;AAED,+BAA+B;AAC/B,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAElE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD"}
1
+ {"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../src/matchers.tsx"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIjE;AAED,kCAAkC;AAClC,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE1E;AAED,+BAA+B;AAC/B,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAElE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD"}
package/build/matchers.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /** Match `[page]` -> `page` */
2
2
  export function matchDynamicName(name) {
3
3
  // Don't match `...` or `[` or `]` inside the brackets
4
- return name.match(/^\[([^/\[\](?:\.\.\.)]+?)\]$/)?.[1];
4
+ // eslint-disable-next-line no-useless-escape
5
+ return name.match(/^\[([^[\](?:\.\.\.)]+?)\]$/)?.[1];
5
6
  }
6
7
  /** Match `[...page]` -> `page` */
7
8
  export function matchDeepDynamicRouteName(name) {
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.js","sourceRoot":"","sources":["../src/matchers.tsx"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,MAAM,UAAU,gBAAgB,CAAC,IAAY;IACzC,sDAAsD;IACtD,OAAO,IAAI,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,kCAAkC;AAClC,MAAM,UAAU,yBAAyB,CAAC,IAAY;IAClD,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,+BAA+B;AAC/B,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC5C,OAAO,yBAAyB,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,0CAA0C;AAC1C,SAAS,yBAAyB,CAAC,IAAY;IAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,mEAAmE;AACnE,SAAS,oBAAoB,CAAC,QAAgB;IAC1C,OAAO,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAClD,CAAC","sourcesContent":["/** Match `[page]` -> `page` */\nexport function matchDynamicName(name: string): string | undefined {\n // Don't match `...` or `[` or `]` inside the brackets\n return name.match(/^\\[([^/\\[\\](?:\\.\\.\\.)]+?)\\]$/)?.[1];\n}\n\n/** Match `[...page]` -> `page` */\nexport function matchDeepDynamicRouteName(name: string): string | undefined {\n return name.match(/^\\[\\.\\.\\.([^/]+?)\\]$/)?.[1];\n}\n\n/** Match `(page)` -> `page` */\nexport function matchFragmentName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport function getNameFromFilePath(name: string): string {\n return removeSupportedExtensions(removeFileSystemDots(name));\n}\n\n/** Remove `.js`, `.ts`, `.jsx`, `.tsx` */\nfunction removeSupportedExtensions(name: string): string {\n return name.replace(/\\.[jt]sx?$/g, \"\");\n}\n\n// Remove any amount of `./` and `../` from the start of the string\nfunction removeFileSystemDots(filePath: string): string {\n return filePath.replace(/^(?:\\.\\.?\\/)+/g, \"\");\n}\n"]}
1
+ {"version":3,"file":"matchers.js","sourceRoot":"","sources":["../src/matchers.tsx"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,sDAAsD;IACtD,6CAA6C;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,kCAAkC;AAClC,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,+BAA+B;AAC/B,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,yBAAyB,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,0CAA0C;AAC1C,SAAS,yBAAyB,CAAC,IAAY;IAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,mEAAmE;AACnE,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,OAAO,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC","sourcesContent":["/** Match `[page]` -> `page` */\nexport function matchDynamicName(name: string): string | undefined {\n // Don't match `...` or `[` or `]` inside the brackets\n // eslint-disable-next-line no-useless-escape\n return name.match(/^\\[([^[\\](?:\\.\\.\\.)]+?)\\]$/)?.[1];\n}\n\n/** Match `[...page]` -> `page` */\nexport function matchDeepDynamicRouteName(name: string): string | undefined {\n return name.match(/^\\[\\.\\.\\.([^/]+?)\\]$/)?.[1];\n}\n\n/** Match `(page)` -> `page` */\nexport function matchFragmentName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport function getNameFromFilePath(name: string): string {\n return removeSupportedExtensions(removeFileSystemDots(name));\n}\n\n/** Remove `.js`, `.ts`, `.jsx`, `.tsx` */\nfunction removeSupportedExtensions(name: string): string {\n return name.replace(/\\.[jt]sx?$/g, \"\");\n}\n\n// Remove any amount of `./` and `../` from the start of the string\nfunction removeFileSystemDots(filePath: string): string {\n return filePath.replace(/^(?:\\.\\.?\\/)+/g, \"\");\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Tutorial.d.ts","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":";AAmCA,wBAAgB,QAAQ,gBAwDvB"}
1
+ {"version":3,"file":"Tutorial.d.ts","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":";AAoCA,wBAAgB,QAAQ,gBAwDvB"}
@@ -1,6 +1,6 @@
1
+ import { View, Text, Pressable, StyleSheet } from "@bacons/react-views";
1
2
  import React from "react";
2
3
  import { SafeAreaView, StatusBar, Platform } from "react-native";
3
- import { View, Text, Pressable, StyleSheet } from "@bacons/react-views";
4
4
  import { createEntryFileAsync } from "./createEntryFile";
5
5
  // TODO: Use openLinkFromBrowser thing
6
6
  function Header() {
@@ -1 +1 @@
1
- {"version":3,"file":"Tutorial.js","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,sCAAsC;AACtC,SAAS,MAAM;IACb,OAAO,CACL,oBAAC,SAAS,QACP,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAChB,oBAAC,IAAI,IACH,iBAAiB,EAAC,QAAQ,EAC1B,kBAAkB,EAAE,CAAC,EACrB,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;;QAE1D,GAAG;QACd,oBAAC,IAAI,IACH,IAAI,EAAC,sCAAsC,EAC3C,KAAK,EAAE;gBACL,OAAO,IAAI;oBACT,mBAAmB,EAAE,OAAO;oBAC5B,kBAAkB,EAAE,WAAW;iBAChC;aACF,WAGI,CACF,CACR,CACS,CACb,CAAC;AACJ,CAAC;AAED,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,IAAI,CAAC;AAElE,MAAM,UAAU,QAAQ;IACtB,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;YACzB,gEAAgE;YAChE,uCAAuC;YACvC,+DAA+D;YAC/D,uGAAuG;YACvG,oFAAoF;YACpF,IAAI,OAAO,QAAQ,KAAK,WAAW,IAA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L,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,aAAa,EAAE,EAAE;QACjB,UAAU,EAAE,MAAM;KACnB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,OAAO;KACf;IACD,IAAI,EAAE;QACJ,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC;YAC1B,OAAO,EAAE,SAAS;YAClB,GAAG,EAAE,aAAa;YAClB,OAAO,EAAE,WAAW;SACrB,CAAC;KACH;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,KAAK;QACjB,aAAa,EAAE,EAAE;QACjB,QAAQ,EAAE,GAAG;KACd;CACF,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport { SafeAreaView, StatusBar, Platform } from \"react-native\";\nimport { View, Text, Pressable, StyleSheet } from \"@bacons/react-views\";\nimport { createEntryFileAsync } from \"./createEntryFile\";\n\n// TODO: Use openLinkFromBrowser thing\nfunction Header() {\n return (\n <Pressable>\n {({ hovered }) => (\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={1}\n style={[styles.title, Platform.OS !== \"web\" && { textAlign: \"left\" }]}\n >\n Welcome to{\" \"}\n <Text\n href=\"https://github.com/expo/expo-router/\"\n style={[\n hovered && {\n textDecorationColor: \"white\",\n textDecorationLine: \"underline\",\n },\n ]}\n >\n Expo\n </Text>\n </Text>\n )}\n </Pressable>\n );\n}\n\nconst canAutoTouchFile = process.env.EXPO_ROUTER_APP_ROOT != null;\n\nexport function Tutorial() {\n React.useEffect(() => {\n if (Platform.OS === \"web\") {\n // Reset the route on web so the initial route isn't a 404 after\n // the user has created the entry file.\n // This is useful for cases where you are testing the tutorial.\n // To test: touch the new file, then navigate to a missing route `/foobar`, then delete the app folder.\n // you should see the tutorial again and be able to create the entry file once more.\n if (typeof location !== \"undefined\" && location.pathname !== \"/\") {\n location.replace(\"/\");\n }\n if (\n typeof window !== \"undefined\" &&\n typeof window.document !== \"undefined\"\n ) {\n window.document.title = \"npx expo start\";\n }\n }\n }, []);\n\n return (\n <View\n style={{\n backgroundColor: \"black\",\n flex: 1,\n backgroundImage:\n \"radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 1px, transparent 0)\",\n backgroundPosition: \"-3px -3px\",\n backgroundSize: \"40px 40px\",\n }}\n >\n <StatusBar barStyle=\"light-content\" />\n\n <SafeAreaView\n style={{\n flex: 1,\n maxWidth: 960,\n marginHorizontal: \"auto\",\n alignItems: \"stretch\",\n }}\n >\n <View style={styles.container}>\n <Header />\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={2}\n style={styles.subtitle}\n >\n Start by creating a file{\"\\n\"}in the{\" \"}\n <Text style={{ fontWeight: \"bold\" }}>app</Text> directory.\n </Text>\n {canAutoTouchFile && <Button />}\n </View>\n </SafeAreaView>\n </View>\n );\n}\n\nfunction Button() {\n return (\n <Pressable\n onPress={() => {\n createEntryFileAsync();\n }}\n style={{\n ...Platform.select({\n native: {\n position: \"absolute\",\n bottom: 24,\n left: 24,\n right: 24,\n overflow: \"hidden\",\n },\n }),\n }}\n >\n {({ pressed, hovered }) => (\n <View\n style={[\n {\n transitionDuration: \"200ms\",\n backgroundColor: Platform.select({\n web: \"transparent\",\n default: \"white\",\n }),\n\n borderColor: \"white\",\n borderWidth: 2,\n paddingVertical: 12,\n paddingHorizontal: 24,\n },\n hovered && {\n backgroundColor: \"white\",\n },\n pressed && {\n backgroundColor: \"rgba(255,255,255,0.7)\",\n },\n ]}\n >\n <Text\n selectable={false}\n style={[\n {\n fontSize: 18,\n transitionDuration: \"200ms\",\n fontWeight: \"bold\",\n color: Platform.select({\n web: \"white\",\n default: \"black\",\n }),\n },\n styles.code,\n hovered && { color: \"black\" },\n ]}\n >\n <Text style={{ color: \"#BCC3CD\" }}>$</Text> touch app/index.js\n </Text>\n </View>\n )}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n padding: 24,\n alignItems: \"flex-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: \"100\",\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,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,sCAAsC;AACtC,SAAS,MAAM;IACb,OAAO,CACL,oBAAC,SAAS,QACP,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAChB,oBAAC,IAAI,IACH,iBAAiB,EAAC,QAAQ,EAC1B,kBAAkB,EAAE,CAAC,EACrB,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;;QAE1D,GAAG;QACd,oBAAC,IAAI,IACH,IAAI,EAAC,sCAAsC,EAC3C,KAAK,EAAE;gBACL,OAAO,IAAI;oBACT,mBAAmB,EAAE,OAAO;oBAC5B,kBAAkB,EAAE,WAAW;iBAChC;aACF,WAGI,CACF,CACR,CACS,CACb,CAAC;AACJ,CAAC;AAED,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,IAAI,CAAC;AAElE,MAAM,UAAU,QAAQ;IACtB,KAA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ACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,IAAI,EAAE,CAAC;QACP,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,YAAY;QACxB,cAAc,EAAE,QAAQ;KACzB;IACD,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,aAAa,EAAE,EAAE;QACjB,UAAU,EAAE,MAAM;KACnB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,OAAO;KACf;IACD,IAAI,EAAE;QACJ,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC;YAC1B,OAAO,EAAE,SAAS;YAClB,GAAG,EAAE,aAAa;YAClB,OAAO,EAAE,WAAW;SACrB,CAAC;KACH;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,KAAK;QACjB,aAAa,EAAE,EAAE;QACjB,QAAQ,EAAE,GAAG;KACd;CACF,CAAC,CAAC","sourcesContent":["import { View, Text, Pressable, StyleSheet } from \"@bacons/react-views\";\nimport React from \"react\";\nimport { SafeAreaView, StatusBar, Platform } from \"react-native\";\n\nimport { createEntryFileAsync } from \"./createEntryFile\";\n\n// TODO: Use openLinkFromBrowser thing\nfunction Header() {\n return (\n <Pressable>\n {({ hovered }) => (\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={1}\n style={[styles.title, Platform.OS !== \"web\" && { textAlign: \"left\" }]}\n >\n Welcome to{\" \"}\n <Text\n href=\"https://github.com/expo/expo-router/\"\n style={[\n hovered && {\n textDecorationColor: \"white\",\n textDecorationLine: \"underline\",\n },\n ]}\n >\n Expo\n </Text>\n </Text>\n )}\n </Pressable>\n );\n}\n\nconst canAutoTouchFile = process.env.EXPO_ROUTER_APP_ROOT != null;\n\nexport function Tutorial() {\n React.useEffect(() => {\n if (Platform.OS === \"web\") {\n // Reset the route on web so the initial route isn't a 404 after\n // the user has created the entry file.\n // This is useful for cases where you are testing the tutorial.\n // To test: touch the new file, then navigate to a missing route `/foobar`, then delete the app folder.\n // you should see the tutorial again and be able to create the entry file once more.\n if (typeof location !== \"undefined\" && location.pathname !== \"/\") {\n location.replace(\"/\");\n }\n if (\n typeof window !== \"undefined\" &&\n typeof window.document !== \"undefined\"\n ) {\n window.document.title = \"npx expo start\";\n }\n }\n }, []);\n\n return (\n <View\n style={{\n backgroundColor: \"black\",\n flex: 1,\n backgroundImage:\n \"radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 1px, transparent 0)\",\n backgroundPosition: \"-3px -3px\",\n backgroundSize: \"40px 40px\",\n }}\n >\n <StatusBar barStyle=\"light-content\" />\n\n <SafeAreaView\n style={{\n flex: 1,\n maxWidth: 960,\n marginHorizontal: \"auto\",\n alignItems: \"stretch\",\n }}\n >\n <View style={styles.container}>\n <Header />\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={2}\n style={styles.subtitle}\n >\n Start by creating a file{\"\\n\"}in the{\" \"}\n <Text style={{ fontWeight: \"bold\" }}>app</Text> directory.\n </Text>\n {canAutoTouchFile && <Button />}\n </View>\n </SafeAreaView>\n </View>\n );\n}\n\nfunction Button() {\n return (\n <Pressable\n onPress={() => {\n createEntryFileAsync();\n }}\n style={{\n ...Platform.select({\n native: {\n position: \"absolute\",\n bottom: 24,\n left: 24,\n right: 24,\n overflow: \"hidden\",\n },\n }),\n }}\n >\n {({ pressed, hovered }) => (\n <View\n style={[\n {\n transitionDuration: \"200ms\",\n backgroundColor: Platform.select({\n web: \"transparent\",\n default: \"white\",\n }),\n\n borderColor: \"white\",\n borderWidth: 2,\n paddingVertical: 12,\n paddingHorizontal: 24,\n },\n hovered && {\n backgroundColor: \"white\",\n },\n pressed && {\n backgroundColor: \"rgba(255,255,255,0.7)\",\n },\n ]}\n >\n <Text\n selectable={false}\n style={[\n {\n fontSize: 18,\n transitionDuration: \"200ms\",\n fontWeight: \"bold\",\n color: Platform.select({\n web: \"white\",\n default: \"black\",\n }),\n },\n styles.code,\n hovered && { color: \"black\" },\n ]}\n >\n <Text style={{ color: \"#BCC3CD\" }}>$</Text> touch app/index.js\n </Text>\n </View>\n )}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n padding: 24,\n alignItems: \"flex-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: \"100\",\n paddingBottom: 36,\n maxWidth: 960,\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAQ,MAAM;;;;;;;;;;;;;;;;iEAAE,KAAK,sIAAwC,CAAC"}
1
+ {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":";AAIA,eAAO,MAAQ,MAAM;;;;;;;;;;;;;;;;iEAAE,KAAK,sIAAwC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { createNavigatorFactory } from '@react-navigation/core';
1
+ import { createNavigatorFactory } from "@react-navigation/core";
2
2
  // `@react-navigation/core` does not expose the Screen or Group components directly, so we have to
3
3
  // do this hack.
4
4
  export const { Screen, Group } = createNavigatorFactory({})();
@@ -1 +1 @@
1
- {"version":3,"file":"primitives.js","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,kGAAkG;AAClG,gBAAgB;AAChB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,sBAAsB,CAAC,EAAS,CAAC,EAAE,CAAC","sourcesContent":["\nimport { createNavigatorFactory } from '@react-navigation/core';\n\n// `@react-navigation/core` does not expose the Screen or Group components directly, so we have to\n// do this hack.\nexport const { Screen, Group } = createNavigatorFactory({} as any)();\n"]}
1
+ {"version":3,"file":"primitives.js","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,kGAAkG;AAClG,gBAAgB;AAChB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,sBAAsB,CAAC,EAAS,CAAC,EAAE,CAAC","sourcesContent":["import { createNavigatorFactory } from \"@react-navigation/core\";\n\n// `@react-navigation/core` does not expose the Screen or Group components directly, so we have to\n// do this hack.\nexport const { Screen, Group } = createNavigatorFactory({} as any)();\n"]}
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import { Screen } from "./primitives";
3
2
  import { Route, sortRoutes, useRoutes } from "./Route";
3
+ import { Screen } from "./primitives";
4
4
  import { Try } from "./views/Try";
5
5
  /**
6
6
  * @returns React Navigation screens for the route.
@@ -1 +1 @@
1
- {"version":3,"file":"useScreens.js","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,KAAK,EAAa,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAC;IAC7B,OAAO,KAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EACnD,CAAC,QAAQ,CAAC,CACX,CAAC;AACJ,CAAC;A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sortRoutes, 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(\n () => children.map((value) => routeToScreen(value)),\n [children]\n );\n}\n\nexport type ScreenProps<\n TOptions extends Record<string, any> = Record<string, any>\n> = {\n /** Name is required when used inside a Layout component. */\n name?: string;\n initialParams?: { [key: string]: any };\n options?: TOptions;\n};\n\nfunction getSortedChildren(\n children: RouteNode[],\n order?: ScreenProps[]\n): { route: RouteNode; props: any }[] {\n if (!order?.length) {\n return children.sort(sortRoutes).map((route) => ({ route, props: {} }));\n }\n const entries = [...children];\n\n const ordered = order\n .map(({ name, initialParams, options }) => {\n if (!entries.length) {\n console.warn(\n `[Layout children]: Too many screens defined. Route \"${name}\" is extraneous.`\n );\n return null;\n }\n const matchIndex = entries.findIndex((child) => child.route === name);\n if (matchIndex === -1) {\n console.warn(\n `[Layout children]: No route named \"${name}\" exists in nested children:`,\n children.map(({ route }) => route)\n );\n return null;\n } else {\n // Get match and remove from entries\n const match = entries[matchIndex];\n entries.splice(matchIndex, 1);\n\n return { route: match, props: { initialParams, options } };\n }\n })\n .filter(Boolean) as {\n route: RouteNode;\n props: Partial<ScreenProps>;\n }[];\n\n // Add any remaining children\n ordered.push(\n ...entries.sort(sortRoutes).map((route) => ({ route, props: {} }))\n );\n\n return ordered;\n}\n\n/**\n * @returns React Navigation screens sorted by the `route` property.\n */\nexport function useSortedScreens(order: ScreenProps[]): React.ReactNode[] {\n const children = useRoutes();\n const sorted = getSortedChildren(children, order);\n return React.useMemo(\n () => sorted.map((value) => routeToScreen(value.route, value.props)),\n [sorted]\n );\n}\n\n// TODO: Maybe there's a more React-y way to do this?\n// Without this store, the process enters a recursive loop.\nconst qualifiedStore = new WeakMap<RouteNode, React.ComponentType<any>>();\n\n/** Wrap the component with various enhancements and add access to child routes. */\nfunction getQualifiedRouteComponent(value: RouteNode) {\n if (qualifiedStore.has(value)) {\n return qualifiedStore.get(value)!;\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 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 <Route filename={value.contextKey}>{errorBoundary}</Route>;\n }\n );\n\n QualifiedRoute.displayName = `Route(${\n Component.displayName || Component.name || value.route\n })`;\n qualifiedStore.set(value, QualifiedRoute);\n return QualifiedRoute;\n}\n\nfunction routeToScreen(\n route: RouteNode,\n { options, ...props }: Partial<ScreenProps> = {}\n) {\n const staticOptions = route.getExtras()?.getNavOptions;\n return (\n <Screen\n {...props}\n name={route.route}\n key={route.route}\n options={\n options\n ? (args) => {\n const staticResult =\n typeof staticOptions === \"function\"\n ? staticOptions(args)\n : staticOptions;\n const dynamicResult =\n typeof options === \"function\" ? options?.(args) : options;\n return {\n ...staticResult,\n ...dynamicResult,\n };\n }\n : staticOptions\n }\n getComponent={() => 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,KAAK,EAAa,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAC;IAC7B,OAAO,KAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,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Content":["import React from \"react\";\n\nimport { Route, RouteNode, sortRoutes, useRoutes } from \"./Route\";\nimport { Screen } from \"./primitives\";\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(\n () => children.map((value) => routeToScreen(value)),\n [children]\n );\n}\n\nexport type ScreenProps<\n TOptions extends Record<string, any> = Record<string, any>\n> = {\n /** Name is required when used inside a Layout component. */\n name?: string;\n initialParams?: { [key: string]: any };\n options?: TOptions;\n};\n\nfunction getSortedChildren(\n children: RouteNode[],\n order?: ScreenProps[]\n): { route: RouteNode; props: any }[] {\n if (!order?.length) {\n return children.sort(sortRoutes).map((route) => ({ route, props: {} }));\n }\n const entries = [...children];\n\n const ordered = order\n .map(({ name, initialParams, options }) => {\n if (!entries.length) {\n console.warn(\n `[Layout children]: Too many screens defined. Route \"${name}\" is extraneous.`\n );\n return null;\n }\n const matchIndex = entries.findIndex((child) => child.route === name);\n if (matchIndex === -1) {\n console.warn(\n `[Layout children]: No route named \"${name}\" exists in nested children:`,\n children.map(({ route }) => route)\n );\n return null;\n } else {\n // Get match and remove from entries\n const match = entries[matchIndex];\n entries.splice(matchIndex, 1);\n\n return { route: match, props: { initialParams, options } };\n }\n })\n .filter(Boolean) as {\n route: RouteNode;\n props: Partial<ScreenProps>;\n }[];\n\n // Add any remaining children\n ordered.push(\n ...entries.sort(sortRoutes).map((route) => ({ route, props: {} }))\n );\n\n return ordered;\n}\n\n/**\n * @returns React Navigation screens sorted by the `route` property.\n */\nexport function useSortedScreens(order: ScreenProps[]): React.ReactNode[] {\n const children = useRoutes();\n const sorted = getSortedChildren(children, order);\n return React.useMemo(\n () => sorted.map((value) => routeToScreen(value.route, value.props)),\n [sorted]\n );\n}\n\n// TODO: Maybe there's a more React-y way to do this?\n// Without this store, the process enters a recursive loop.\nconst qualifiedStore = new WeakMap<RouteNode, React.ComponentType<any>>();\n\n/** Wrap the component with various enhancements and add access to child routes. */\nfunction getQualifiedRouteComponent(value: RouteNode) {\n if (qualifiedStore.has(value)) {\n return qualifiedStore.get(value)!;\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 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 <Route filename={value.contextKey}>{errorBoundary}</Route>;\n }\n );\n\n QualifiedRoute.displayName = `Route(${\n Component.displayName || Component.name || value.route\n })`;\n qualifiedStore.set(value, QualifiedRoute);\n return QualifiedRoute;\n}\n\nfunction routeToScreen(\n route: RouteNode,\n { options, ...props }: Partial<ScreenProps> = {}\n) {\n const staticOptions = route.getExtras()?.getNavOptions;\n return (\n <Screen\n {...props}\n name={route.route}\n key={route.route}\n options={\n options\n ? (args) => {\n const staticResult =\n typeof staticOptions === \"function\"\n ? staticOptions(args)\n : staticOptions;\n const dynamicResult =\n typeof options === \"function\" ? options?.(args) : options;\n return {\n ...staticResult,\n ...dynamicResult,\n };\n }\n : staticOptions\n }\n getComponent={() => getQualifiedRouteComponent(route)}\n />\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Directory.d.ts","sourceRoot":"","sources":["../../src/views/Directory.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAwE9E,wBAAgB,aAAa,IAAI,4BAA4B,CAqB5D;AAED,wBAAgB,SAAS,gBAmCxB"}
1
+ {"version":3,"file":"Directory.d.ts","sourceRoot":"","sources":["../../src/views/Directory.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AA6E9E,wBAAgB,aAAa,IAAI,4BAA4B,CAqB5D;AAED,wBAAgB,SAAS,gBAkCxB"}
@@ -1,11 +1,11 @@
1
1
  import { Image, Pressable, StyleSheet, Text, View } from "@bacons/react-views";
2
2
  import { useNavigation } from "@react-navigation/native";
3
3
  import React from "react";
4
- import { ScrollView, Platform, StatusBar, useWindowDimensions } from "react-native";
4
+ import { ScrollView, Platform, StatusBar, useWindowDimensions, } from "react-native";
5
5
  import { useSafeAreaInsets } from "react-native-safe-area-context";
6
6
  import { useRoutesContext } from "../context";
7
+ import { Link } from "../link/Link";
7
8
  import { matchDeepDynamicRouteName, matchFragmentName } from "../matchers";
8
- import { Link } from "./Link";
9
9
  const INDENT = 18;
10
10
  function useSortedRoutes() {
11
11
  const ctx = useRoutesContext();
@@ -109,7 +109,7 @@ function FileItem({ route, level = 0, parents = [], }) {
109
109
  .map((v) => {
110
110
  // add an extra layer of entropy to the url for deep dynamic routes
111
111
  if (matchDeepDynamicRouteName(v)) {
112
- return v + '/' + Date.now();
112
+ return v + "/" + Date.now();
113
113
  }
114
114
  // groups and index must be erased
115
115
  return !!matchFragmentName(v) || v === "index" ? "" : v;
@@ -119,7 +119,7 @@ function FileItem({ route, level = 0, parents = [], }) {
119
119
  }, [parents, route.route]);
120
120
  return (React.createElement(React.Fragment, null,
121
121
  React.createElement(Link, { href: href, onPress: () => {
122
- if (Platform.OS !== 'web') {
122
+ if (Platform.OS !== "web") {
123
123
  // Ensure the modal pops
124
124
  navigation.goBack();
125
125
  }