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
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # expo-router
2
+
3
+ > This package is still in development and is not ready for production use.
Binary file
Binary file
package/assets/pkg.png ADDED
Binary file
package/babel.js ADDED
@@ -0,0 +1,77 @@
1
+ const { relative } = require("path");
2
+
3
+ module.exports = function (api) {
4
+ const { types: t } = api;
5
+ const getRelPath = (state) =>
6
+ "./" + relative(state.file.opts.root, state.filename);
7
+
8
+ return {
9
+ name: "expo-router",
10
+ visitor: {
11
+ // Add support for Node.js __filename
12
+ Identifier(path, state) {
13
+ if (path.node.name === "__filename") {
14
+ path.replaceWith(t.stringLiteral(getRelPath(state)));
15
+ }
16
+ },
17
+
18
+ // Auto add the React prop `context={require.context('./app')}` to a component named `Root` that's
19
+ JSXOpeningElement(path, state) {
20
+ if (!getRelPath(state).match(/^\.\/app\//)) {
21
+ return;
22
+ }
23
+ if (path.node.name.name === "ExpoRoot") {
24
+ // Check if the context prop already exists
25
+ const contextProp = path.node.attributes.find(
26
+ (attr) => attr.name.name === "context"
27
+ );
28
+ if (contextProp) {
29
+ return;
30
+ }
31
+
32
+ path.node.attributes.push(
33
+ t.jsxAttribute(
34
+ t.jsxIdentifier("context"),
35
+ t.jsxExpressionContainer(
36
+ t.callExpression(t.identifier("require"), [
37
+ t.callExpression(t.identifier("context"), [
38
+ t.stringLiteral("./app"),
39
+ ]),
40
+ ])
41
+ )
42
+ )
43
+ );
44
+ }
45
+ },
46
+
47
+ // Convert `process.env.EXPO_ROUTER_APP_ROOT` to a string literal
48
+ MemberExpression(path, state) {
49
+ if (
50
+ !t.isIdentifier(path.node.object, { name: "process" }) ||
51
+ !t.isIdentifier(path.node.property, { name: "env" })
52
+ ) {
53
+ return;
54
+ }
55
+
56
+ const parent = path.parentPath;
57
+ if (!t.isMemberExpression(parent.node)) {
58
+ return;
59
+ }
60
+
61
+ if (
62
+ !t.isIdentifier(parent.node.property, {
63
+ name: "EXPO_ROUTER_APP_ROOT",
64
+ })
65
+ ) {
66
+ return;
67
+ }
68
+
69
+ if (parent.parentPath.isAssignmentExpression()) {
70
+ return;
71
+ }
72
+
73
+ parent.replaceWith(t.stringLiteral(process.env.EXPO_ROUTER_APP_ROOT));
74
+ },
75
+ },
76
+ };
77
+ };
@@ -0,0 +1,33 @@
1
+ import { LinkingOptions, NavigationContainer } from "@react-navigation/native";
2
+ import React from "react";
3
+ declare type NavigationContainerProps = React.ComponentProps<typeof NavigationContainer>;
4
+ export declare function useNavigationContainerContext(): [Partial<import("@react-navigation/native").NavigationContainerProps & {
5
+ theme?: import("@react-navigation/native").Theme | undefined;
6
+ linking?: LinkingOptions<{}> | undefined;
7
+ fallback?: React.ReactNode;
8
+ documentTitle?: import("@react-navigation/native").DocumentTitleOptions | undefined;
9
+ onReady?: (() => void) | undefined;
10
+ } & {
11
+ ref?: React.Ref<import("@react-navigation/native").NavigationContainerRef<{}>> | undefined;
12
+ }>, (props: Partial<import("@react-navigation/native").NavigationContainerProps & {
13
+ theme?: import("@react-navigation/native").Theme | undefined;
14
+ linking?: LinkingOptions<{}> | undefined;
15
+ fallback?: React.ReactNode;
16
+ documentTitle?: import("@react-navigation/native").DocumentTitleOptions | undefined;
17
+ onReady?: (() => void) | undefined;
18
+ } & {
19
+ ref?: React.Ref<import("@react-navigation/native").NavigationContainerRef<{}>> | undefined;
20
+ }>) => void];
21
+ /** react-navigation `NavigationContainer` with automatic `linking` prop generated from the routes context. */
22
+ export declare const ContextNavigationContainer: React.ForwardRefExoticComponent<Pick<import("@react-navigation/native").NavigationContainerProps & {
23
+ theme?: import("@react-navigation/native").Theme | undefined;
24
+ linking?: LinkingOptions<{}> | undefined;
25
+ fallback?: React.ReactNode;
26
+ documentTitle?: import("@react-navigation/native").DocumentTitleOptions | undefined;
27
+ onReady?: (() => void) | undefined;
28
+ } & {
29
+ ref?: React.Ref<import("@react-navigation/native").NavigationContainerRef<{}>> | undefined;
30
+ }, keyof import("@react-navigation/native").NavigationContainerProps | "theme" | "linking" | "fallback" | "documentTitle" | "onReady"> & React.RefAttributes<import("@react-navigation/native").NavigationContainerRef<{}>>>;
31
+ export declare function RootContainer(props: Omit<NavigationContainerProps, 'children' | 'linking'>): null;
32
+ export {};
33
+ //# sourceMappingURL=ContextNavigationContainer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextNavigationContainer.d.ts","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAA+B,MAAM,OAAO,CAAC;AAIpD,aAAK,wBAAwB,GAAG,KAAK,CAAC,cAAc,CAChD,OAAO,mBAAmB,CAC7B,CAAC;AASF,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;aAQ5C;AAUD,8GAA8G;AAC9G,eAAO,MAAM,0BAA0B;;;;;;;;4NA6BtC,CAAC;AAgBF,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,SAAS,CAAC,QAQ1F"}
@@ -0,0 +1,59 @@
1
+ import { NavigationContainer } from "@react-navigation/native";
2
+ import React, { useMemo, useCallback } from "react";
3
+ import { useRoutesContext } from "./context";
4
+ import { getLinkingConfig } from "./getLinkingConfig";
5
+ function useLinkingConfig() {
6
+ const routes = useRoutesContext();
7
+ return useMemo(() => getLinkingConfig(routes), [routes]);
8
+ }
9
+ const NavigationContainerContext = React.createContext([{}, function () { }]);
10
+ export function useNavigationContainerContext() {
11
+ const context = React.useContext(NavigationContainerContext);
12
+ if (!context) {
13
+ throw new Error("useNavigationContainerContext must be used within a NavigationContainerContext");
14
+ }
15
+ return context;
16
+ }
17
+ let hideAsync;
18
+ try {
19
+ hideAsync =
20
+ require("expo-splash-screen").hideAsync;
21
+ // Automatically handle hiding the splash screen if expo-splash-screen is installed.
22
+ }
23
+ catch { }
24
+ /** react-navigation `NavigationContainer` with automatic `linking` prop generated from the routes context. */
25
+ export const ContextNavigationContainer = React.forwardRef((props, ref) => {
26
+ const [state, setState] = React.useState({});
27
+ const linking = useLinkingConfig();
28
+ console.log('linking', linking);
29
+ const onReady = useCallback(() => {
30
+ props.onReady?.();
31
+ if (hideAsync) {
32
+ hideAsync();
33
+ }
34
+ }, [props.onReady]);
35
+ return (React.createElement(NavigationContainerContext.Provider, { value: [
36
+ {
37
+ ...props,
38
+ linking,
39
+ onReady,
40
+ ...state,
41
+ },
42
+ setState,
43
+ ] },
44
+ React.createElement(InternalContextNavigationContainer, { ref: ref })));
45
+ });
46
+ const InternalContextNavigationContainer = React.forwardRef((props, ref) => {
47
+ const [contextProps] = useNavigationContainerContext();
48
+ return (
49
+ // @ts-expect-error: children are required
50
+ React.createElement(NavigationContainer, { ref: ref, ...props, ...contextProps }));
51
+ });
52
+ export function RootContainer(props) {
53
+ const [, setProps] = useNavigationContainerContext();
54
+ React.useEffect(() => {
55
+ setProps(props);
56
+ }, [props]);
57
+ return null;
58
+ }
59
+ //# sourceMappingURL=ContextNavigationContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextNavigationContainer.js","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMtD,SAAS,gBAAgB;IACrB,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;IAClC,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7D,CAAC;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C,GAAG,KAAK,CAAC,UAAU,CACvD,CAAC,KAAS,EAAE,GAAoC,EAAE,EAAE;IAChD,MAAM,CAAC,YAAY,CAAC,GAAG,6BAA6B,EAAE,CAAC;IACvD,OAAO;IACH,0CAA0C;IAC1C,oBAAC,mBAAmB,IAChB,GAAG,EAAE,GAAG,KACJ,KAAK,KACL,YAAY,GAClB,CACL,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,KAA6D;IACvF,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,6BAA6B,EAAE,CAAC;IAErD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { LinkingOptions, NavigationContainer } from \"@react-navigation/native\";\nimport React, { useMemo, useCallback } from \"react\";\nimport { useRoutesContext } from \"./context\";\nimport { getLinkingConfig } from \"./getLinkingConfig\";\n\ntype NavigationContainerProps = React.ComponentProps<\n typeof NavigationContainer\n>;\n\nfunction useLinkingConfig(): LinkingOptions<{}> {\n const routes = useRoutesContext();\n return useMemo(() => getLinkingConfig(routes), [routes]);\n}\n\nconst NavigationContainerContext = React.createContext<[Partial<NavigationContainerProps>, (props: Partial<NavigationContainerProps>) => void]>([{}, function () { }]);\n\nexport function useNavigationContainerContext() {\n const context = React.useContext(NavigationContainerContext);\n if (!context) {\n throw new Error(\n \"useNavigationContainerContext must be used within a NavigationContainerContext\"\n );\n }\n return context;\n}\n\nlet hideAsync: () => Promise<boolean> | undefined;\ntry {\n hideAsync =\n (require(\"expo-splash-screen\") as typeof import(\"expo-splash-screen\")).hideAsync;\n // Automatically handle hiding the splash screen if expo-splash-screen is installed.\n} catch { }\n\n\n/** react-navigation `NavigationContainer` with automatic `linking` prop generated from the routes context. */\nexport const ContextNavigationContainer = React.forwardRef(\n (props: NavigationContainerProps, ref: NavigationContainerProps[\"ref\"]) => {\n const [state, setState] = React.useState<Partial<NavigationContainerProps>>({});\n\n const linking = useLinkingConfig();\n console.log('linking', linking);\n const onReady = useCallback(() => {\n props.onReady?.();\n if (hideAsync) {\n hideAsync();\n }\n }, [props.onReady]);\n\n return (\n <NavigationContainerContext.Provider value={[\n {\n ...props,\n linking,\n onReady,\n ...state,\n },\n setState,\n ]}>\n <InternalContextNavigationContainer\n ref={ref}\n />\n </NavigationContainerContext.Provider>\n );\n }\n);\n\nconst InternalContextNavigationContainer = React.forwardRef(\n (props: {}, ref: NavigationContainerProps[\"ref\"]) => {\n const [contextProps] = useNavigationContainerContext();\n return (\n // @ts-expect-error: children are required\n <NavigationContainer\n ref={ref}\n {...props}\n {...contextProps}\n />\n );\n }\n);\n\nexport function RootContainer(props: Omit<NavigationContainerProps, 'children' | 'linking'>) {\n const [, setProps] = useNavigationContainerContext();\n\n React.useEffect(() => {\n setProps(props);\n }, [props]);\n\n return null;\n}"]}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { RequireContext } from './types';
3
+ export declare function ContextNavigator({ context }: {
4
+ context: RequireContext;
5
+ }): JSX.Element;
6
+ //# sourceMappingURL=ContextNavigator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextNavigator.d.ts","sourceRoot":"","sources":["../src/ContextNavigator.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAyDzC,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,eAkBxE"}
@@ -0,0 +1,52 @@
1
+ import React, { useMemo } from 'react';
2
+ import { RoutesContext } from './context';
3
+ import { ContextNavigationContainer } from './ContextNavigationContainer';
4
+ import { getRoutes } from './getRoutes';
5
+ import { NativeStack } from './layouts/NativeStack';
6
+ import { Route } from './Route';
7
+ function useContextModuleAsRoutes(context) {
8
+ // TODO: Is this an optimal hook dependency?
9
+ return useMemo(() => getRoutes(context), [context]);
10
+ }
11
+ function RoutesContextProvider({ context, children, }) {
12
+ const routes = useContextModuleAsRoutes(context);
13
+ return (React.createElement(RoutesContext.Provider, { value: routes }, children));
14
+ }
15
+ function isFunctionOrReactComponent(Component) {
16
+ return (!!Component &&
17
+ (typeof Component === "function" ||
18
+ Component?.prototype?.isReactComponent ||
19
+ Component.$$typeof === Symbol.for("react.forward_ref")));
20
+ }
21
+ /** Returns the Tutorial component if there are no React components exported as default from any files in the provided context module. */
22
+ function useTutorial(context) {
23
+ if (process.env.NODE_ENV === "production") {
24
+ return null;
25
+ }
26
+ const keys = useMemo(() => context.keys(), [context]);
27
+ const hasAnyValidComponent = useMemo(() => {
28
+ for (const key of keys) {
29
+ // NOTE(EvanBacon): This should only ever occur in development as it breaks lazily loading.
30
+ const component = context(key)?.default;
31
+ if (isFunctionOrReactComponent(component)) {
32
+ return true;
33
+ }
34
+ }
35
+ return false;
36
+ }, [keys]);
37
+ if (hasAnyValidComponent) {
38
+ return null;
39
+ }
40
+ return require("./onboard/Tutorial").Tutorial;
41
+ }
42
+ export function ContextNavigator({ context }) {
43
+ const Tutorial = useTutorial(context);
44
+ if (Tutorial) {
45
+ return React.createElement(Tutorial, null);
46
+ }
47
+ return (React.createElement(RoutesContextProvider, { context: context },
48
+ React.createElement(Route, { filename: "./" },
49
+ React.createElement(ContextNavigationContainer, null,
50
+ React.createElement(NativeStack, { screenOptions: { animation: "none", headerShown: false } })))));
51
+ }
52
+ //# sourceMappingURL=ContextNavigator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextNavigator.js","sourceRoot":"","sources":["../src/ContextNavigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;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,CAAC,EAAE;gBACvC,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,IAAI,oBAAoB,EAAE;QACtB,OAAO,IAAI,CAAC;KACf;IAED,OAAO,OAAO,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAE,OAAO,EAA+B;IACrE,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,QAAQ,EAAE;QACV,OAAO,oBAAC,QAAQ,OAAG,CAAC;KACvB;IAED,OAAO,CACH,oBAAC,qBAAqB,IAAC,OAAO,EAAE,OAAO;QACnC,oBAAC,KAAK,IAAC,QAAQ,EAAC,IAAI;YAChB,oBAAC,0BAA0B;gBAEvB,oBAAC,WAAW,IACR,aAAa,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,GAC1D,CACuB,CACzB,CACY,CAC3B,CAAC;AACN,CAAC","sourcesContent":["import React, { useMemo } from 'react';\n\nimport { RoutesContext } from './context';\nimport { ContextNavigationContainer } from './ContextNavigationContainer';\nimport { getRoutes } from './getRoutes';\nimport { NativeStack } from './layouts/NativeStack';\nimport { Route } from './Route';\nimport { RequireContext } from './types';\n\n\nfunction useContextModuleAsRoutes(context: RequireContext) {\n // TODO: Is this an optimal hook dependency?\n return useMemo(() => getRoutes(context), [context]);\n}\n\nfunction RoutesContextProvider({\n context,\n children,\n}: {\n context: RequireContext;\n children: React.ReactNode;\n}) {\n const routes = useContextModuleAsRoutes(context);\n return (\n <RoutesContext.Provider value={routes}>{children}</RoutesContext.Provider>\n );\n}\n\nfunction isFunctionOrReactComponent(\n Component: any\n): Component is React.ComponentType {\n return (\n !!Component &&\n (typeof Component === \"function\" ||\n Component?.prototype?.isReactComponent ||\n Component.$$typeof === Symbol.for(\"react.forward_ref\"))\n );\n}\n\n/** Returns the Tutorial component if there are no React components exported as default from any files in the provided context module. */\nfunction useTutorial(context: RequireContext) {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n\n const keys = useMemo(() => context.keys(), [context]);\n const hasAnyValidComponent = useMemo(() => {\n for (const key of keys) {\n // NOTE(EvanBacon): This should only ever occur in development as it breaks lazily loading.\n const component = context(key)?.default;\n if (isFunctionOrReactComponent(component)) {\n return true;\n }\n }\n return false;\n }, [keys]);\n\n if (hasAnyValidComponent) {\n return null;\n }\n\n return require(\"./onboard/Tutorial\").Tutorial;\n}\n\nexport function ContextNavigator({ context }: { context: RequireContext }) {\n const Tutorial = useTutorial(context);\n if (Tutorial) {\n return <Tutorial />;\n }\n\n return (\n <RoutesContextProvider context={context}>\n <Route filename=\"./\">\n <ContextNavigationContainer>\n {/* Using a switch navigator at the root to host all pages. */}\n <NativeStack\n screenOptions={{ animation: \"none\", headerShown: false }}\n />\n </ContextNavigationContainer>\n </Route>\n </RoutesContextProvider>\n );\n}\n"]}
@@ -0,0 +1,34 @@
1
+ import React, { ReactNode } from 'react';
2
+ /** The list of input keys will become optional, everything else will remain the same. */
3
+ export declare type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
4
+ export declare type RouteNode = {
5
+ /** nested routes */
6
+ children: RouteNode[];
7
+ /** Lazily get the React component */
8
+ getComponent: () => React.ComponentType<any>;
9
+ /** Is the route a dynamic path */
10
+ dynamic: null | {
11
+ name: string;
12
+ deep: boolean;
13
+ };
14
+ /** All static exports from the file. */
15
+ getExtras: () => Record<string, any>;
16
+ /** `index`, `error-boundary`, etc. */
17
+ route: string;
18
+ /** require.context key, used for matching children. */
19
+ contextKey: string;
20
+ /** Added in-memory */
21
+ generated?: boolean;
22
+ /** Internal screens like the directory or the auto 404 should be marked as internal. */
23
+ internal?: boolean;
24
+ /** React Navigation screen name. */
25
+ screenName: string;
26
+ };
27
+ /** Return all the routes for the current boundary. */
28
+ export declare function useRoutes(): RouteNode[];
29
+ /** Provides the matching routes and filename to the children. */
30
+ export declare function Route({ filename, children, }: {
31
+ filename: string;
32
+ children: ReactNode;
33
+ }): JSX.Element;
34
+ //# sourceMappingURL=Route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAIrD,yFAAyF;AACzF,oBAAY,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACtD,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAExB,oBAAY,SAAS,GAAG;IACpB,oBAAoB;IACpB,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,qCAAqC;IACrC,YAAY,EAAE,MAAM,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7C,kCAAkC;IAClC,OAAO,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IAChD,wCAAwC;IACxC,SAAS,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,wFAAwF;IACxF,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AAkBF,sDAAsD;AACtD,wBAAgB,SAAS,IAAI,SAAS,EAAE,CAQvC;AAED,iEAAiE;AACjE,wBAAgB,KAAK,CAAC,EAClB,QAAQ,EACR,QAAQ,GACX,EAAE;IACC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACvB,eAUA"}
package/build/Route.js ADDED
@@ -0,0 +1,56 @@
1
+ import React, { useContext } from 'react';
2
+ import { getNameFromFilePath } from './matchers';
3
+ import { RoutesContext } from './context';
4
+ const CurrentRouteContext = React.createContext({
5
+ filename: null,
6
+ routes: [],
7
+ // siblings: [],
8
+ // parent: null,
9
+ });
10
+ if (process.env.NODE_ENV === "development") {
11
+ CurrentRouteContext.displayName = "Route";
12
+ }
13
+ /** Return all the routes for the current boundary. */
14
+ export function useRoutes() {
15
+ const { filename, routes } = useContext(CurrentRouteContext);
16
+ if (process.env.NODE_ENV === "development") {
17
+ if (!filename) {
18
+ throw new Error("No filename found. This is likely a bug in expo-router.");
19
+ }
20
+ }
21
+ return routes;
22
+ }
23
+ /** Provides the matching routes and filename to the children. */
24
+ export function Route({ filename, children, }) {
25
+ const routes = useRoutesAtPath(filename);
26
+ return (React.createElement(CurrentRouteContext.Provider, { value: { filename, routes } }, children));
27
+ }
28
+ function useRoutesAtPath(filename) {
29
+ const normalName = React.useMemo(() => getNameFromFilePath(filename), [filename]);
30
+ const routes = useContext(RoutesContext);
31
+ const keys = React.useMemo(() => routes.keys(), [routes]);
32
+ const family = React.useMemo(() => {
33
+ let children = routes;
34
+ let current = null;
35
+ // let siblings: RouteNode[] = [];
36
+ // let parent: RouteNode | null = null;
37
+ // Skip root directory
38
+ if (normalName) {
39
+ // split and search
40
+ const parts = normalName.split("/");
41
+ for (const part of parts) {
42
+ const next = children.find(({ route }) => route === part);
43
+ if (!next?.children) {
44
+ return [];
45
+ }
46
+ // parent = current;
47
+ // siblings = children;
48
+ current = next;
49
+ children = next?.children;
50
+ }
51
+ }
52
+ return children;
53
+ }, [normalName, keys]);
54
+ return family;
55
+ }
56
+ //# sourceMappingURL=Route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Route.js","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA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,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC9B,IAAI,QAAQ,GAAgB,MAAM,CAAC;QACnC,IAAI,OAAO,GAAqB,IAAI,CAAC;QACrC,kCAAkC;QAClC,uCAAuC;QAEvC,sBAAsB;QACtB,IAAI,UAAU,EAAE;YACZ,mBAAmB;YACnB,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACtB,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;gBAE1D,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE;oBACjB,OAAO,EAAE,CAAC;iBACb;gBAED,oBAAoB;gBACpB,uBAAuB;gBACvB,OAAO,GAAG,IAAI,CAAC;gBACf,QAAQ,GAAG,IAAI,EAAE,QAAQ,CAAC;aAC7B;SACJ;QAED,OAAO,QAAQ,CAAA;IACnB,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;IAEvB,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import React, { ReactNode, useContext } from 'react';\nimport { getNameFromFilePath } from './matchers';\nimport { RoutesContext } from './context';\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> &\n Partial<Pick<T, K>>;\n\nexport type RouteNode = {\n /** nested routes */\n children: RouteNode[];\n /** Lazily get the React component */\n getComponent: () => React.ComponentType<any>;\n /** Is the route a dynamic path */\n dynamic: null | { name: string; deep: boolean };\n /** All static exports from the file. */\n getExtras: () => Record<string, any>;\n /** `index`, `error-boundary`, etc. */\n route: string;\n /** require.context key, used for matching children. */\n contextKey: string;\n /** Added in-memory */\n generated?: boolean;\n\n /** Internal screens like the directory or the auto 404 should be marked as internal. */\n internal?: boolean;\n\n /** React Navigation screen name. */\n screenName: string;\n};\n\nconst CurrentRouteContext = React.createContext<{\n filename: string | null;\n routes: RouteNode[];\n // siblings: RouteNode[];\n // parent: RouteNode | null;\n}>({\n filename: null,\n routes: [],\n // siblings: [],\n // parent: null,\n});\n\nif (process.env.NODE_ENV === \"development\") {\n CurrentRouteContext.displayName = \"Route\";\n}\n\n/** Return all the routes for the current boundary. */\nexport function useRoutes(): RouteNode[] {\n const { filename, routes } = useContext(CurrentRouteContext);\n if (process.env.NODE_ENV === \"development\") {\n if (!filename) {\n throw new Error(\"No filename found. This is likely a bug in expo-router.\");\n }\n }\n return routes;\n}\n\n/** Provides the matching routes and filename to the children. */\nexport function Route({\n filename,\n children,\n}: {\n filename: string;\n children: ReactNode;\n}) {\n const routes = useRoutesAtPath(filename);\n\n return (\n <CurrentRouteContext.Provider\n value={{ filename, routes }}\n >\n {children}\n </CurrentRouteContext.Provider>\n );\n}\n\nfunction useRoutesAtPath(filename: string): RouteNode[] {\n const normalName = React.useMemo(() => getNameFromFilePath(filename), [filename]);\n const routes = useContext(RoutesContext);\n const keys = React.useMemo(() => routes.keys(), [routes]);\n\n const family = React.useMemo(() => {\n let children: RouteNode[] = routes;\n let current: RouteNode | null = null;\n // let siblings: RouteNode[] = [];\n // let parent: RouteNode | null = null;\n\n // Skip root directory\n if (normalName) {\n // split and search\n const parts = normalName.split(\"/\");\n for (const part of parts) {\n const next = children.find(({ route }) => route === part);\n\n if (!next?.children) {\n return [];\n }\n\n // parent = current;\n // siblings = children;\n current = next;\n children = next?.children;\n }\n }\n\n return children\n }, [normalName, keys]);\n\n return family;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function getAllWebRedirects(protocols?: string[], subdomains?: string[]): string[];
2
+ //# sourceMappingURL=aasa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aasa.d.ts","sourceRoot":"","sources":["../src/aasa.ts"],"names":[],"mappings":"AAkBA,wBAAgB,kBAAkB,CAChC,SAAS,WAAoB,EAC7B,UAAU,WAAQ,YAgBnB"}
package/build/aasa.js ADDED
@@ -0,0 +1,25 @@
1
+ import Constants from "expo-constants";
2
+ function getWebUrlsFromManifest() {
3
+ // TODO: Replace this with the source of truth native manifest
4
+ // Then do a check to warn the user if the config doesn't match the native manifest.
5
+ // TODO: Warn if the applinks have `https://` in them.
6
+ const domains = Constants.expoConfig?.ios?.associatedDomains || [];
7
+ // [applinks:explore-api.netlify.app/] -> [explore-api.netlify.app]
8
+ const applinks = domains
9
+ .filter((domain) => domain.startsWith("applinks:"))
10
+ .map((domain) => {
11
+ let clean = domain.replace(/^applinks:/, "");
12
+ return clean.endsWith("/") ? clean.slice(0, -1) : clean;
13
+ });
14
+ return applinks;
15
+ }
16
+ export function getAllWebRedirects(protocols = ["https", "http"], subdomains = ["*"]) {
17
+ const urls = getWebUrlsFromManifest();
18
+ const _subdomains = [""].concat(subdomains);
19
+ return urls
20
+ .map((url) => protocols
21
+ .map((protocol) => _subdomains.map((subdomain) => `${protocol}://${[subdomain, url].filter(Boolean).join(".")}/`))
22
+ .flat())
23
+ .flat();
24
+ }
25
+ //# sourceMappingURL=aasa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aasa.js","sourceRoot":"","sources":["../src/aasa.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAEvC,SAAS,sBAAsB;IAC7B,8DAA8D;IAC9D,oFAAoF;IACpF,sDAAsD;IACtD,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,iBAAiB,IAAI,EAAE,CAAC;IACnE,mEAAmE;IACnE,MAAM,QAAQ,GAAG,OAAO;SACrB,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;SAClD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACd,IAAI,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC7C,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEL,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAC7B,UAAU,GAAG,CAAC,GAAG,CAAC;IAElB,MAAM,IAAI,GAAG,sBAAsB,EAAE,CAAC;IACtC,MAAM,WAAW,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC5C,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACX,SAAS;SACN,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAChB,WAAW,CAAC,GAAG,CACb,CAAC,SAAS,EAAE,EAAE,CACZ,GAAG,QAAQ,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CACjE,CACF;SACA,IAAI,EAAE,CACV;SACA,IAAI,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import Constants from \"expo-constants\";\n\nfunction getWebUrlsFromManifest() {\n // TODO: Replace this with the source of truth native manifest\n // Then do a check to warn the user if the config doesn't match the native manifest.\n // TODO: Warn if the applinks have `https://` in them.\n const domains = Constants.expoConfig?.ios?.associatedDomains || [];\n // [applinks:explore-api.netlify.app/] -> [explore-api.netlify.app]\n const applinks = domains\n .filter((domain) => domain.startsWith(\"applinks:\"))\n .map((domain) => {\n let clean = domain.replace(/^applinks:/, \"\");\n return clean.endsWith(\"/\") ? clean.slice(0, -1) : clean;\n });\n\n return applinks;\n}\n\nexport function getAllWebRedirects(\n protocols = [\"https\", \"http\"],\n subdomains = [\"*\"]\n) {\n const urls = getWebUrlsFromManifest();\n const _subdomains = [\"\"].concat(subdomains);\n return urls\n .map((url) =>\n protocols\n .map((protocol) =>\n _subdomains.map(\n (subdomain) =>\n `${protocol}://${[subdomain, url].filter(Boolean).join(\".\")}/`\n )\n )\n .flat()\n )\n .flat();\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { RouteNode } from "./Route";
3
+ export declare const RoutesContext: import("react").Context<RouteNode[]>;
4
+ export declare function useRoutesContext(): RouteNode[];
5
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,eAAO,MAAM,aAAa,sCAAiC,CAAC;AAM5D,wBAAgB,gBAAgB,gBAQ/B"}
@@ -0,0 +1,14 @@
1
+ import { createContext, useContext } from "react";
2
+ // Routes context
3
+ export const RoutesContext = createContext([]);
4
+ if (process.env.NODE_ENV !== "production") {
5
+ RoutesContext.displayName = "RoutesContext";
6
+ }
7
+ export function useRoutesContext() {
8
+ const routes = useContext(RoutesContext);
9
+ if (!routes) {
10
+ throw new Error("useRoutes is being used outside of RoutesContext.Provider");
11
+ }
12
+ return routes;
13
+ }
14
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAIlD,iBAAiB;AACjB,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAc,EAAE,CAAC,CAAC;AAE5D,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC;CAC7C;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createContext, useContext } from \"react\";\n\nimport { RouteNode } from \"./Route\";\n\n// Routes context\nexport const RoutesContext = createContext<RouteNode[]>([]);\n\nif (process.env.NODE_ENV !== \"production\") {\n RoutesContext.displayName = \"RoutesContext\";\n}\n\nexport function useRoutesContext() {\n const routes = useContext(RoutesContext);\n if (!routes) {\n throw new Error(\n \"useRoutes is being used outside of RoutesContext.Provider\"\n );\n }\n return routes;\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import type { NavigationState, PartialState } from "@react-navigation/routers";
2
+ import { PathConfigMap } from "@react-navigation/core";
3
+ declare type Options<ParamList extends {}> = {
4
+ initialRouteName?: string;
5
+ screens: PathConfigMap<ParamList>;
6
+ };
7
+ declare type State = NavigationState | Omit<PartialState<NavigationState>, "stale">;
8
+ /**
9
+ * Utility to serialize a navigation state object to a path string.
10
+ *
11
+ * @example
12
+ * ```js
13
+ * getPathFromState(
14
+ * {
15
+ * routes: [
16
+ * {
17
+ * name: 'Chat',
18
+ * params: { author: 'Jane', id: 42 },
19
+ * },
20
+ * ],
21
+ * },
22
+ * {
23
+ * screens: {
24
+ * Chat: {
25
+ * path: 'chat/:author/:id',
26
+ * stringify: { author: author => author.toLowerCase() }
27
+ * }
28
+ * }
29
+ * }
30
+ * )
31
+ * ```
32
+ *
33
+ * @param state Navigation state to serialize.
34
+ * @param options Extra options to fine-tune how to serialize the path.
35
+ * @returns Path representing the state, e.g. /foo/bar?count=42.
36
+ */
37
+ export default function getPathFromState<ParamList extends {}>(state: State, options?: Options<ParamList>): string;
38
+ export {};
39
+ //# sourceMappingURL=getPathFromState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPathFromState.d.ts","sourceRoot":"","sources":["../../src/fork/getPathFromState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EAEb,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAGL,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,aAAK,OAAO,CAAC,SAAS,SAAS,EAAE,IAAI;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACnC,CAAC;AAEF,aAAK,KAAK,GAAG,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC;AAuB5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,SAAS,SAAS,EAAE,EAC3D,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAC3B,MAAM,CAuKR"}