expo-router 4.1.0-canary-20250122-166c2cb → 4.1.0-canary-20250131-5c4e588

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.
@@ -6,6 +6,7 @@ export { withLayoutContext } from './layouts/withLayoutContext';
6
6
  export { Navigator, Slot };
7
7
  export { ExpoRoot } from './ExpoRoot';
8
8
  export { Unmatched } from './views/Unmatched';
9
+ export { Sitemap } from './views/Sitemap';
9
10
  export { ErrorBoundaryProps } from './views/Try';
10
11
  export { ErrorBoundary } from './views/ErrorBoundary';
11
12
  export type { ScreenProps } from './useScreens';
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,WAAW,EACX,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAG3B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD;;GAEG;AACH,OAAO,KAAK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BAAkB,CAAC;AAClE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,mBAAmB,SAAS,CAAC"}
package/build/exports.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.useFocusEffect = exports.useNavigation = exports.SplashScreen = exports.ErrorBoundary = exports.Unmatched = exports.ExpoRoot = exports.Slot = exports.Navigator = exports.withLayoutContext = exports.Redirect = exports.Link = exports.router = exports.useRootNavigationState = exports.useRootNavigation = exports.useSegments = exports.useLocalSearchParams = exports.useGlobalSearchParams = exports.useNavigationContainerRef = exports.usePathname = exports.useUnstableGlobalHref = exports.useRouter = void 0;
26
+ exports.useFocusEffect = exports.useNavigation = exports.SplashScreen = exports.ErrorBoundary = exports.Sitemap = exports.Unmatched = exports.ExpoRoot = exports.Slot = exports.Navigator = exports.withLayoutContext = exports.Redirect = exports.Link = exports.router = exports.useRootNavigationState = exports.useRootNavigation = exports.useSegments = exports.useLocalSearchParams = exports.useGlobalSearchParams = exports.useNavigationContainerRef = exports.usePathname = exports.useUnstableGlobalHref = exports.useRouter = void 0;
27
27
  // Expo Router API
28
28
  const Navigator_1 = require("./views/Navigator");
29
29
  Object.defineProperty(exports, "Navigator", { enumerable: true, get: function () { return Navigator_1.Navigator; } });
@@ -50,6 +50,8 @@ var ExpoRoot_1 = require("./ExpoRoot");
50
50
  Object.defineProperty(exports, "ExpoRoot", { enumerable: true, get: function () { return ExpoRoot_1.ExpoRoot; } });
51
51
  var Unmatched_1 = require("./views/Unmatched");
52
52
  Object.defineProperty(exports, "Unmatched", { enumerable: true, get: function () { return Unmatched_1.Unmatched; } });
53
+ var Sitemap_1 = require("./views/Sitemap");
54
+ Object.defineProperty(exports, "Sitemap", { enumerable: true, get: function () { return Sitemap_1.Sitemap; } });
53
55
  var ErrorBoundary_1 = require("./views/ErrorBoundary");
54
56
  Object.defineProperty(exports, "ErrorBoundary", { enumerable: true, get: function () { return ErrorBoundary_1.ErrorBoundary; } });
55
57
  // Platform
@@ -1 +1 @@
1
- {"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAAkB;AAClB,iDAAoD;AAmB3C,0FAnBA,qBAAS,OAmBA;AAAE,qFAnBA,gBAAI,OAmBA;AAjBxB,iCAUiB;AATf,kGAAA,SAAS,OAAA;AACT,8GAAA,qBAAqB,OAAA;AACrB,oGAAA,WAAW,OAAA;AACX,kHAAA,yBAAyB,OAAA;AACzB,8GAAA,qBAAqB,OAAA;AACrB,6GAAA,oBAAoB,OAAA;AACpB,oGAAA,WAAW,OAAA;AACX,0GAAA,iBAAiB,OAAA;AACjB,+GAAA,sBAAsB,OAAA;AAGxB,mDAAkD;AAAzC,wGAAA,MAAM,OAAA;AAEf,oCAAuF;AAA9E,4FAAA,IAAI,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAEvB,iEAAgE;AAAvD,sHAAA,iBAAiB,OAAA;AAG1B,oBAAoB;AACpB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,+CAA8C;AAArC,sGAAA,SAAS,OAAA;AAElB,uDAAsD;AAA7C,8GAAA,aAAa,OAAA;AAGtB,WAAW;AACX;;GAEG;AACH,+DAA+C;AAE/C,mBAAmB;AACnB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,mDAAkE;AAAzD,gHAAA,cAAc,OAAA","sourcesContent":["// Expo Router API\nimport { Navigator, Slot } from './views/Navigator';\n\nexport {\n useRouter,\n useUnstableGlobalHref,\n usePathname,\n useNavigationContainerRef,\n useGlobalSearchParams,\n useLocalSearchParams,\n useSegments,\n useRootNavigation,\n useRootNavigationState,\n} from './hooks';\n\nexport { router, Router } from './imperative-api';\n\nexport { Link, Redirect, RedirectProps, LinkProps, WebAnchorProps } from './link/Link';\n\nexport { withLayoutContext } from './layouts/withLayoutContext';\nexport { Navigator, Slot };\n\n// Expo Router Views\nexport { ExpoRoot } from './ExpoRoot';\nexport { Unmatched } from './views/Unmatched';\nexport { ErrorBoundaryProps } from './views/Try';\nexport { ErrorBoundary } from './views/ErrorBoundary';\nexport type { ScreenProps } from './useScreens';\n\n// Platform\n/**\n * @hidden\n */\nexport * as SplashScreen from './views/Splash';\n\n// React Navigation\nexport { useNavigation } from './useNavigation';\nexport { useFocusEffect, EffectCallback } from './useFocusEffect';\nexport type { ResultState } from './fork/getStateFromPath';\n\nexport type * from './types';\n"]}
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAAkB;AAClB,iDAAoD;AAmB3C,0FAnBA,qBAAS,OAmBA;AAAE,qFAnBA,gBAAI,OAmBA;AAjBxB,iCAUiB;AATf,kGAAA,SAAS,OAAA;AACT,8GAAA,qBAAqB,OAAA;AACrB,oGAAA,WAAW,OAAA;AACX,kHAAA,yBAAyB,OAAA;AACzB,8GAAA,qBAAqB,OAAA;AACrB,6GAAA,oBAAoB,OAAA;AACpB,oGAAA,WAAW,OAAA;AACX,0GAAA,iBAAiB,OAAA;AACjB,+GAAA,sBAAsB,OAAA;AAGxB,mDAAkD;AAAzC,wGAAA,MAAM,OAAA;AAEf,oCAAuF;AAA9E,4FAAA,IAAI,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAEvB,iEAAgE;AAAvD,sHAAA,iBAAiB,OAAA;AAG1B,oBAAoB;AACpB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,+CAA8C;AAArC,sGAAA,SAAS,OAAA;AAClB,2CAA0C;AAAjC,kGAAA,OAAO,OAAA;AAEhB,uDAAsD;AAA7C,8GAAA,aAAa,OAAA;AAGtB,WAAW;AACX;;GAEG;AACH,+DAA+C;AAE/C,mBAAmB;AACnB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,mDAAkE;AAAzD,gHAAA,cAAc,OAAA","sourcesContent":["// Expo Router API\nimport { Navigator, Slot } from './views/Navigator';\n\nexport {\n useRouter,\n useUnstableGlobalHref,\n usePathname,\n useNavigationContainerRef,\n useGlobalSearchParams,\n useLocalSearchParams,\n useSegments,\n useRootNavigation,\n useRootNavigationState,\n} from './hooks';\n\nexport { router, Router } from './imperative-api';\n\nexport { Link, Redirect, RedirectProps, LinkProps, WebAnchorProps } from './link/Link';\n\nexport { withLayoutContext } from './layouts/withLayoutContext';\nexport { Navigator, Slot };\n\n// Expo Router Views\nexport { ExpoRoot } from './ExpoRoot';\nexport { Unmatched } from './views/Unmatched';\nexport { Sitemap } from './views/Sitemap';\nexport { ErrorBoundaryProps } from './views/Try';\nexport { ErrorBoundary } from './views/ErrorBoundary';\nexport type { ScreenProps } from './useScreens';\n\n// Platform\n/**\n * @hidden\n */\nexport * as SplashScreen from './views/Splash';\n\n// React Navigation\nexport { useNavigation } from './useNavigation';\nexport { useFocusEffect, EffectCallback } from './useFocusEffect';\nexport type { ResultState } from './fork/getStateFromPath';\n\nexport type * from './types';\n"]}
@@ -32,5 +32,6 @@ export declare function useLinking(ref: React.RefObject<NavigationContainerRef<P
32
32
  }> & any) | undefined;
33
33
  }) | undefined>;
34
34
  };
35
+ export declare function getInitialURLWithTimeout(): string | null | Promise<string | null>;
35
36
  export {};
36
37
  //# sourceMappingURL=useLinking.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAKd,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgD/B;;GAEG;AACH,eAAO,MAAM,MAAM,OAAQ,MAAM,QAAQ,IAAI,CAAC,eAM7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EA6WtE"}
1
+ {"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAKd,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgD/B;;GAEG;AACH,eAAO,MAAM,MAAM,OAAQ,MAAM,QAAQ,IAAI,CAAC,eAM7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EA6WtE;AAED,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAEjF"}
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.useLinking = exports.series = void 0;
29
+ exports.getInitialURLWithTimeout = exports.useLinking = exports.series = void 0;
30
30
  const native_1 = require("@react-navigation/native");
31
31
  const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
32
32
  const React = __importStar(require("react"));
@@ -368,4 +368,8 @@ function useLinking(ref, { enabled = true, config, getStateFromPath = native_1.g
368
368
  };
369
369
  }
370
370
  exports.useLinking = useLinking;
371
+ function getInitialURLWithTimeout() {
372
+ return typeof window === 'undefined' ? '' : window.location.href;
373
+ }
374
+ exports.getInitialURLWithTimeout = getInitialURLWithTimeout;
371
375
  //# sourceMappingURL=useLinking.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.js","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUkC;AAClC,sEAAsC;AACtC,6CAA+B;AAE/B,+DAA4D;AAC5D,yDAAmD;AACnD,iFAAsE;AAItE;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CACxB,CAAgB,EAChB,CAAgB,EACgB,EAAE;IAClC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE;QACzD,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;KAC/B;IAED,uFAAuF;IACvF,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IACtE,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAEtE,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,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,CAAC,YAAY,CAAC,CAAC;yBAChC;wBAED,+DAA+D;wBAC/D,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;qBAClC;oBAAC,MAAM;wBACN,iCAAiC;qBAClC;iBACF;qBAAM;oBACL,0DAA0D;oBAC1D,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;iBAClC;aACF;iBAAM;gBACL,iEAAiE;gBACjE,6EAA6E;gBAC7E,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;aAClC;QACH,CAAC,CAAC;QAEF,+FAA+F;QAC/F,0DAA0D;QAC1D,qGAAqG;QACrG,OAAO,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,IAAA,cAAM,EAAC,aAAa,CAAC,CAAC,CAAC;IAClE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAE5B,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC;AAtXD,gCAsXC","sourcesContent":["import {\n LinkingOptions,\n findFocusedRoute,\n getActionFromState as getActionFromStateDefault,\n getPathFromState as getPathFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type NavigationState,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/native';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport { createMemoryHistory } from './createMemoryHistory';\nimport { appendBaseUrl } from './getPathFromState';\nimport { ServerContext } from '../global-state/serverLocationContext';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\n/**\n * Find the matching navigation state that changed between 2 navigation states\n * e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state\n */\nconst findMatchingState = <T extends NavigationState>(\n a: T | undefined,\n b: T | undefined\n): [T | undefined, T | undefined] => {\n if (a === undefined || b === undefined || a.key !== b.key) {\n return [undefined, undefined];\n }\n\n // Tab and drawer will have `history` property, but stack will have history in `routes`\n const aHistoryLength = a.history ? a.history.length : a.routes.length;\n const bHistoryLength = b.history ? b.history.length : b.routes.length;\n\n const aRoute = a.routes[a.index];\n const bRoute = b.routes[b.index];\n\n const aChildState = aRoute.state as T | undefined;\n const bChildState = bRoute.state as T | undefined;\n\n // Stop here if this is the state object that changed:\n // - history length is different\n // - focused routes are different\n // - one of them doesn't have child state\n // - child state keys are different\n if (\n aHistoryLength !== bHistoryLength ||\n aRoute.key !== bRoute.key ||\n aChildState === undefined ||\n bChildState === undefined ||\n aChildState.key !== bChildState.key\n ) {\n return [a, b];\n }\n\n return findMatchingState(aChildState, bChildState);\n};\n\n/**\n * Run async function in series as it's called.\n */\nexport const series = (cb: () => Promise<void>) => {\n let queue = Promise.resolve();\n const callback = () => {\n queue = queue.then(cb);\n };\n return callback;\n};\n\nconst linkingHandlers: symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase>;\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') {\n return undefined;\n }\n\n if (independent) {\n return undefined;\n }\n\n if (enabled !== false && linkingHandlers.length) {\n console.error(\n [\n 'Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:',\n \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n '- Only a single instance of the root component is rendered',\n ]\n .join('\\n')\n .trim()\n );\n }\n\n const handler = Symbol();\n\n if (enabled !== false) {\n linkingHandlers.push(handler);\n }\n\n return () => {\n const index = linkingHandlers.indexOf(handler);\n\n if (index > -1) {\n linkingHandlers.splice(index, 1);\n }\n };\n }, [enabled, independent]);\n\n const [history] = React.useState(createMemoryHistory);\n\n // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n const enabledRef = React.useRef(enabled);\n const configRef = React.useRef(config);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getPathFromStateRef = React.useRef(getPathFromState);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n configRef.current = config;\n getStateFromPathRef.current = getStateFromPath;\n getPathFromStateRef.current = getPathFromState;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const validateRoutesNotExistInRootState = React.useCallback(\n (state: ResultState) => {\n const navigation = ref.current;\n const rootState = navigation?.getRootState();\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n return state?.routes.some((r) => !rootState?.routeNames.includes(r.name));\n },\n [ref]\n );\n\n const server = React.useContext(ServerContext);\n\n const getInitialState = React.useCallback(() => {\n let value: ResultState | undefined;\n\n if (enabledRef.current) {\n const location =\n server?.location ?? (typeof window !== 'undefined' ? window.location : undefined);\n\n const path = location ? location.pathname + location.search : undefined;\n\n if (path) {\n value = getStateFromPathRef.current(path, configRef.current);\n }\n\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const previousIndexRef = React.useRef<number | undefined>(undefined);\n const previousStateRef = React.useRef<NavigationState | undefined>(undefined);\n const pendingPopStatePathRef = React.useRef<string | undefined>(undefined);\n\n React.useEffect(() => {\n previousIndexRef.current = history.index;\n\n return history.listen(() => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const { location } = window;\n\n const path = location.pathname + location.search + location.hash;\n const index = history.index;\n\n const previousIndex = previousIndexRef.current ?? 0;\n\n previousIndexRef.current = index;\n pendingPopStatePathRef.current = path;\n\n // When browser back/forward is clicked, we first need to check if state object for this index exists\n // If it does we'll reset to that state object\n // Otherwise, we'll handle it like a regular deep link\n const record = history.get(index);\n\n if (record?.path === path && record?.state) {\n navigation.resetRoot(record.state);\n return;\n }\n\n const state = getStateFromPathRef.current(path, configRef.current);\n\n // We should only dispatch an action when going forward\n // Otherwise the action will likely add items to history, which would mess things up\n if (state) {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n if (validateRoutesNotExistInRootState(state)) {\n return;\n }\n\n if (\n index > previousIndex ||\n /* START FORK\n *\n * This is a workaround for React Navigation's handling of hashes (it doesn't handle them)\n * When you click on <a href=\"#hash\">, the browser will first fire a popstate event\n * and this callback will be called.\n *\n * From React Navigation's perspective, it's treating the new hash change like a back/forward\n * button press, so it thinks it should reset the state. When we should\n * be to be pushing the new state\n *\n * Our fix is to check if the index is the same as the previous index\n * and if the incoming path is the same as the old path but with the hash added,\n * then treat it as a push instead of a reset\n *\n * This also works for subsequent hash changes, as internally RN\n * doesn't store the hash in the history state.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent\n */\n (index === previousIndex && (!record || `${record?.path}${location.hash}` === path))\n // END FORK\n ) {\n const action = getActionFromStateRef.current(state, configRef.current);\n\n if (action !== undefined) {\n try {\n navigation.dispatch(action);\n } catch (e) {\n // Ignore any errors from deep linking.\n // This could happen in case of malformed links, navigation object not being initialized etc.\n console.warn(\n `An error occurred when trying to handle the link '${path}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n // if current path didn't return any state, we should revert to initial state\n navigation.resetRoot(state);\n }\n });\n }, [enabled, history, onUnhandledLinking, ref, validateRoutesNotExistInRootState]);\n\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const getPathForRoute = (\n route: ReturnType<typeof findFocusedRoute>,\n state: NavigationState\n ): string => {\n let path;\n\n // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match\n // This makes sure that we preserve the original URL for wildcard routes\n if (route?.path) {\n const stateForPath = getStateFromPathRef.current(route.path, configRef.current);\n\n if (stateForPath) {\n const focusedRoute = findFocusedRoute(stateForPath);\n\n if (\n focusedRoute &&\n focusedRoute.name === route.name &&\n isEqual({ ...focusedRoute.params }, { ...route.params })\n ) {\n // START FORK - Ensure paths coming from events (e.g refresh) have the base URL\n // path = route.path;\n path = appendBaseUrl(route.path);\n // END FORK\n }\n }\n }\n\n if (path == null) {\n path = getPathFromStateRef.current(state, configRef.current);\n }\n\n // START FORK - ExpoRouter manually handles hashes. This code is intentionally removed\n // const previousRoute = previousStateRef.current\n // ? findFocusedRoute(previousStateRef.current)\n // : undefined;\n\n // Preserve the hash if the route didn't change\n // if (\n // previousRoute &&\n // route &&\n // 'key' in previousRoute &&\n // 'key' in route &&\n // previousRoute.key === route.key\n // ) {\n // path = path + location.hash;\n // }\n // END FORK\n\n return path;\n };\n\n if (ref.current) {\n // We need to record the current metadata on the first render if they aren't set\n // This will allow the initial state to be in the history entry\n const state = ref.current.getRootState();\n\n if (state) {\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n if (previousStateRef.current === undefined) {\n previousStateRef.current = state;\n }\n\n history.replace({ path, state });\n }\n }\n\n const onStateChange = async () => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const previousState = previousStateRef.current;\n const state = navigation.getRootState();\n\n // root state may not available, for example when root navigators switch inside the container\n if (!state) {\n return;\n }\n\n const pendingPath = pendingPopStatePathRef.current;\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n previousStateRef.current = state;\n pendingPopStatePathRef.current = undefined;\n\n // To detect the kind of state change, we need to:\n // - Find the common focused navigation state in previous and current state\n // - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace\n // - If no common focused navigation state found, it's a replace\n const [previousFocusedState, focusedState] = findMatchingState(previousState, state);\n\n if (\n previousFocusedState &&\n focusedState &&\n // We should only handle push/pop if path changed from what was in last `popstate`\n // Otherwise it's likely a change triggered by `popstate`\n path !== pendingPath\n ) {\n const historyDelta =\n (focusedState.history ? focusedState.history.length : focusedState.routes.length) -\n (previousFocusedState.history\n ? previousFocusedState.history.length\n : previousFocusedState.routes.length);\n\n if (historyDelta > 0) {\n // If history length is increased, we should pushState\n // Note that path might not actually change here, for example, drawer open should pushState\n history.push({ path, state });\n } else if (historyDelta < 0) {\n // If history length is decreased, i.e. entries were removed, we want to go back\n\n const nextIndex = history.backIndex({ path });\n const currentIndex = history.index;\n\n try {\n if (\n nextIndex !== -1 &&\n nextIndex < currentIndex &&\n // We should only go back if the entry exists and it's less than current index\n history.get(nextIndex - currentIndex)\n ) {\n // An existing entry for this path exists and it's less than current index, go back to that\n await history.go(nextIndex - currentIndex);\n } else {\n // We couldn't find an existing entry to go back to, so we'll go back by the delta\n // This won't be correct if multiple routes were pushed in one go before\n // Usually this shouldn't happen and this is a fallback for that\n await history.go(historyDelta);\n }\n\n // Store the updated state as well as fix the path if incorrect\n history.replace({ path, state });\n } catch {\n // The navigation was interrupted\n }\n } else {\n // If history length is unchanged, we want to replaceState\n history.replace({ path, state });\n }\n } else {\n // If no common navigation state was found, assume it's a replace\n // This would happen if the user did a reset/conditionally changed navigators\n history.replace({ path, state });\n }\n };\n\n // We debounce onStateChange coz we don't want multiple state changes to be handled at one time\n // This could happen since `history.go(n)` is asynchronous\n // If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up\n return ref.current?.addListener('state', series(onStateChange));\n }, [enabled, history, ref]);\n\n return {\n getInitialState,\n };\n}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C,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;aAClC;QACH,CAAC,CAAC;QAEF,+FAA+F;QAC/F,0DAA0D;QAC1D,qGAAqG;QACrG,OAAO,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,IAAA,cAAM,EAAC,aAAa,CAAC,CAAC,CAAC;IAClE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAE5B,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC;AAtXD,gCAsXC;AAED,SAAgB,wBAAwB;IACtC,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnE,CAAC;AAFD,4DAEC","sourcesContent":["import {\n LinkingOptions,\n findFocusedRoute,\n getActionFromState as getActionFromStateDefault,\n getPathFromState as getPathFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type NavigationState,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/native';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport { createMemoryHistory } from './createMemoryHistory';\nimport { appendBaseUrl } from './getPathFromState';\nimport { ServerContext } from '../global-state/serverLocationContext';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\n/**\n * Find the matching navigation state that changed between 2 navigation states\n * e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state\n */\nconst findMatchingState = <T extends NavigationState>(\n a: T | undefined,\n b: T | undefined\n): [T | undefined, T | undefined] => {\n if (a === undefined || b === undefined || a.key !== b.key) {\n return [undefined, undefined];\n }\n\n // Tab and drawer will have `history` property, but stack will have history in `routes`\n const aHistoryLength = a.history ? a.history.length : a.routes.length;\n const bHistoryLength = b.history ? b.history.length : b.routes.length;\n\n const aRoute = a.routes[a.index];\n const bRoute = b.routes[b.index];\n\n const aChildState = aRoute.state as T | undefined;\n const bChildState = bRoute.state as T | undefined;\n\n // Stop here if this is the state object that changed:\n // - history length is different\n // - focused routes are different\n // - one of them doesn't have child state\n // - child state keys are different\n if (\n aHistoryLength !== bHistoryLength ||\n aRoute.key !== bRoute.key ||\n aChildState === undefined ||\n bChildState === undefined ||\n aChildState.key !== bChildState.key\n ) {\n return [a, b];\n }\n\n return findMatchingState(aChildState, bChildState);\n};\n\n/**\n * Run async function in series as it's called.\n */\nexport const series = (cb: () => Promise<void>) => {\n let queue = Promise.resolve();\n const callback = () => {\n queue = queue.then(cb);\n };\n return callback;\n};\n\nconst linkingHandlers: symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase>;\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') {\n return undefined;\n }\n\n if (independent) {\n return undefined;\n }\n\n if (enabled !== false && linkingHandlers.length) {\n console.error(\n [\n 'Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:',\n \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n '- Only a single instance of the root component is rendered',\n ]\n .join('\\n')\n .trim()\n );\n }\n\n const handler = Symbol();\n\n if (enabled !== false) {\n linkingHandlers.push(handler);\n }\n\n return () => {\n const index = linkingHandlers.indexOf(handler);\n\n if (index > -1) {\n linkingHandlers.splice(index, 1);\n }\n };\n }, [enabled, independent]);\n\n const [history] = React.useState(createMemoryHistory);\n\n // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n const enabledRef = React.useRef(enabled);\n const configRef = React.useRef(config);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getPathFromStateRef = React.useRef(getPathFromState);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n configRef.current = config;\n getStateFromPathRef.current = getStateFromPath;\n getPathFromStateRef.current = getPathFromState;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const validateRoutesNotExistInRootState = React.useCallback(\n (state: ResultState) => {\n const navigation = ref.current;\n const rootState = navigation?.getRootState();\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n return state?.routes.some((r) => !rootState?.routeNames.includes(r.name));\n },\n [ref]\n );\n\n const server = React.useContext(ServerContext);\n\n const getInitialState = React.useCallback(() => {\n let value: ResultState | undefined;\n\n if (enabledRef.current) {\n const location =\n server?.location ?? (typeof window !== 'undefined' ? window.location : undefined);\n\n const path = location ? location.pathname + location.search : undefined;\n\n if (path) {\n value = getStateFromPathRef.current(path, configRef.current);\n }\n\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const previousIndexRef = React.useRef<number | undefined>(undefined);\n const previousStateRef = React.useRef<NavigationState | undefined>(undefined);\n const pendingPopStatePathRef = React.useRef<string | undefined>(undefined);\n\n React.useEffect(() => {\n previousIndexRef.current = history.index;\n\n return history.listen(() => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const { location } = window;\n\n const path = location.pathname + location.search + location.hash;\n const index = history.index;\n\n const previousIndex = previousIndexRef.current ?? 0;\n\n previousIndexRef.current = index;\n pendingPopStatePathRef.current = path;\n\n // When browser back/forward is clicked, we first need to check if state object for this index exists\n // If it does we'll reset to that state object\n // Otherwise, we'll handle it like a regular deep link\n const record = history.get(index);\n\n if (record?.path === path && record?.state) {\n navigation.resetRoot(record.state);\n return;\n }\n\n const state = getStateFromPathRef.current(path, configRef.current);\n\n // We should only dispatch an action when going forward\n // Otherwise the action will likely add items to history, which would mess things up\n if (state) {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n if (validateRoutesNotExistInRootState(state)) {\n return;\n }\n\n if (\n index > previousIndex ||\n /* START FORK\n *\n * This is a workaround for React Navigation's handling of hashes (it doesn't handle them)\n * When you click on <a href=\"#hash\">, the browser will first fire a popstate event\n * and this callback will be called.\n *\n * From React Navigation's perspective, it's treating the new hash change like a back/forward\n * button press, so it thinks it should reset the state. When we should\n * be to be pushing the new state\n *\n * Our fix is to check if the index is the same as the previous index\n * and if the incoming path is the same as the old path but with the hash added,\n * then treat it as a push instead of a reset\n *\n * This also works for subsequent hash changes, as internally RN\n * doesn't store the hash in the history state.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent\n */\n (index === previousIndex && (!record || `${record?.path}${location.hash}` === path))\n // END FORK\n ) {\n const action = getActionFromStateRef.current(state, configRef.current);\n\n if (action !== undefined) {\n try {\n navigation.dispatch(action);\n } catch (e) {\n // Ignore any errors from deep linking.\n // This could happen in case of malformed links, navigation object not being initialized etc.\n console.warn(\n `An error occurred when trying to handle the link '${path}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n // if current path didn't return any state, we should revert to initial state\n navigation.resetRoot(state);\n }\n });\n }, [enabled, history, onUnhandledLinking, ref, validateRoutesNotExistInRootState]);\n\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const getPathForRoute = (\n route: ReturnType<typeof findFocusedRoute>,\n state: NavigationState\n ): string => {\n let path;\n\n // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match\n // This makes sure that we preserve the original URL for wildcard routes\n if (route?.path) {\n const stateForPath = getStateFromPathRef.current(route.path, configRef.current);\n\n if (stateForPath) {\n const focusedRoute = findFocusedRoute(stateForPath);\n\n if (\n focusedRoute &&\n focusedRoute.name === route.name &&\n isEqual({ ...focusedRoute.params }, { ...route.params })\n ) {\n // START FORK - Ensure paths coming from events (e.g refresh) have the base URL\n // path = route.path;\n path = appendBaseUrl(route.path);\n // END FORK\n }\n }\n }\n\n if (path == null) {\n path = getPathFromStateRef.current(state, configRef.current);\n }\n\n // START FORK - ExpoRouter manually handles hashes. This code is intentionally removed\n // const previousRoute = previousStateRef.current\n // ? findFocusedRoute(previousStateRef.current)\n // : undefined;\n\n // Preserve the hash if the route didn't change\n // if (\n // previousRoute &&\n // route &&\n // 'key' in previousRoute &&\n // 'key' in route &&\n // previousRoute.key === route.key\n // ) {\n // path = path + location.hash;\n // }\n // END FORK\n\n return path;\n };\n\n if (ref.current) {\n // We need to record the current metadata on the first render if they aren't set\n // This will allow the initial state to be in the history entry\n const state = ref.current.getRootState();\n\n if (state) {\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n if (previousStateRef.current === undefined) {\n previousStateRef.current = state;\n }\n\n history.replace({ path, state });\n }\n }\n\n const onStateChange = async () => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const previousState = previousStateRef.current;\n const state = navigation.getRootState();\n\n // root state may not available, for example when root navigators switch inside the container\n if (!state) {\n return;\n }\n\n const pendingPath = pendingPopStatePathRef.current;\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n previousStateRef.current = state;\n pendingPopStatePathRef.current = undefined;\n\n // To detect the kind of state change, we need to:\n // - Find the common focused navigation state in previous and current state\n // - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace\n // - If no common focused navigation state found, it's a replace\n const [previousFocusedState, focusedState] = findMatchingState(previousState, state);\n\n if (\n previousFocusedState &&\n focusedState &&\n // We should only handle push/pop if path changed from what was in last `popstate`\n // Otherwise it's likely a change triggered by `popstate`\n path !== pendingPath\n ) {\n const historyDelta =\n (focusedState.history ? focusedState.history.length : focusedState.routes.length) -\n (previousFocusedState.history\n ? previousFocusedState.history.length\n : previousFocusedState.routes.length);\n\n if (historyDelta > 0) {\n // If history length is increased, we should pushState\n // Note that path might not actually change here, for example, drawer open should pushState\n history.push({ path, state });\n } else if (historyDelta < 0) {\n // If history length is decreased, i.e. entries were removed, we want to go back\n\n const nextIndex = history.backIndex({ path });\n const currentIndex = history.index;\n\n try {\n if (\n nextIndex !== -1 &&\n nextIndex < currentIndex &&\n // We should only go back if the entry exists and it's less than current index\n history.get(nextIndex - currentIndex)\n ) {\n // An existing entry for this path exists and it's less than current index, go back to that\n await history.go(nextIndex - currentIndex);\n } else {\n // We couldn't find an existing entry to go back to, so we'll go back by the delta\n // This won't be correct if multiple routes were pushed in one go before\n // Usually this shouldn't happen and this is a fallback for that\n await history.go(historyDelta);\n }\n\n // Store the updated state as well as fix the path if incorrect\n history.replace({ path, state });\n } catch {\n // The navigation was interrupted\n }\n } else {\n // If history length is unchanged, we want to replaceState\n history.replace({ path, state });\n }\n } else {\n // If no common navigation state was found, assume it's a replace\n // This would happen if the user did a reset/conditionally changed navigators\n history.replace({ path, state });\n }\n };\n\n // We debounce onStateChange coz we don't want multiple state changes to be handled at one time\n // This could happen since `history.go(n)` is asynchronous\n // If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up\n return ref.current?.addListener('state', series(onStateChange));\n }, [enabled, history, ref]);\n\n return {\n getInitialState,\n };\n}\n\nexport function getInitialURLWithTimeout(): string | null | Promise<string | null> {\n return typeof window === 'undefined' ? '' : window.location.href;\n}\n"]}
@@ -29,5 +29,6 @@ export declare function useLinking(ref: React.RefObject<NavigationContainerRef<P
29
29
  }> & any) | undefined;
30
30
  }) | undefined>;
31
31
  };
32
+ export declare function getInitialURLWithTimeout(): string | null | Promise<string | null>;
32
33
  export {};
33
34
  //# sourceMappingURL=useLinking.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAI7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAQI,EACJ,SAmBC,EACD,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EA+JtE"}
1
+ {"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAI7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAAgD,EAChD,SAmBC,EACD,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EA+JtE;AAED,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBjF"}
@@ -23,20 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.useLinking = void 0;
26
+ exports.getInitialURLWithTimeout = exports.useLinking = void 0;
27
27
  const native_1 = require("@react-navigation/native");
28
+ const ExpoLinking = __importStar(require("expo-linking"));
28
29
  const React = __importStar(require("react"));
29
30
  const react_native_1 = require("react-native");
30
31
  const extractPathFromURL_1 = require("./extractPathFromURL");
31
32
  const linkingHandlers = [];
32
- function useLinking(ref, { enabled = true, prefixes, filter, config, getInitialURL = () => Promise.race([
33
- react_native_1.Linking.getInitialURL(),
34
- new Promise((resolve) => {
35
- // Timeout in 150ms if `getInitialState` doesn't resolve
36
- // Workaround for https://github.com/facebook/react-native/issues/25675
37
- setTimeout(resolve, 150);
38
- }),
39
- ]), subscribe = (listener) => {
33
+ function useLinking(ref, { enabled = true, prefixes, filter, config, getInitialURL = () => getInitialURLWithTimeout(), subscribe = (listener) => {
40
34
  const callback = ({ url }) => listener(url);
41
35
  const subscription = react_native_1.Linking.addEventListener('url', callback);
42
36
  // Storing this in a local variable stops Jest from complaining about import after teardown
@@ -177,4 +171,22 @@ function useLinking(ref, { enabled = true, prefixes, filter, config, getInitialU
177
171
  };
178
172
  }
179
173
  exports.useLinking = useLinking;
174
+ function getInitialURLWithTimeout() {
175
+ if (typeof window === 'undefined') {
176
+ return '';
177
+ }
178
+ else if (react_native_1.Platform.OS === 'ios') {
179
+ // Use the new Expo API for iOS. This has better support for App Clips and handoff.
180
+ return ExpoLinking.getLinkingURL();
181
+ }
182
+ return Promise.race([
183
+ // TODO: Phase this out in favor of expo-linking on Android.
184
+ react_native_1.Linking.getInitialURL(),
185
+ new Promise((resolve) =>
186
+ // Timeout in 150ms if `getInitialState` doesn't resolve
187
+ // Workaround for https://github.com/facebook/react-native/issues/25675
188
+ setTimeout(() => resolve(null), 150)),
189
+ ]);
190
+ }
191
+ exports.getInitialURLWithTimeout = getInitialURLWithTimeout;
180
192
  //# sourceMappingURL=useLinking.native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.native.js","sourceRoot":"","sources":["../../src/fork/useLinking.native.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAMkC;AAElC,6CAA+B;AAC/B,+CAAiD;AAEjD,6DAA8D;AAM9D,MAAM,eAAe,GAAa,EAAE,CAAC;AAErC,SAAgB,UAAU,CACxB,GAA2D,EAC3D,EACE,OAAO,GAAG,IAAI,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAAa,GAAG,GAAG,EAAE,CACnB,OAAO,CAAC,IAAI,CAAC;IACX,sBAAO,CAAC,aAAa,EAAE;IACvB,IAAI,OAAO,CAAY,CAAC,OAAO,EAAE,EAAE;QACjC,wDAAwD;QACxD,uEAAuE;QACvE,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC,CAAC;CACH,CAAC,EACJ,SAAS,GAAG,CAAC,QAAQ,EAAE,EAAE;IACvB,MAAM,QAAQ,GAAG,CAAC,EAAE,GAAG,EAAmB,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE7D,MAAM,YAAY,GAAG,sBAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAEhD,CAAC;IAEd,2FAA2F;IAC3F,4EAA4E;IAC5E,MAAM,mBAAmB,GAAG,sBAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,sBAAO,CAAC,CAAC;IAEvE,OAAO,GAAG,EAAE;QACV,2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CAAC;IAC7B,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;IAE7E,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC;AAtMD,gCAsMC","sourcesContent":["import {\n getActionFromState as getActionFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/native';\nimport { LinkingOptions } from '@react-navigation/native';\nimport * as React from 'react';\nimport { Linking, Platform } from 'react-native';\n\nimport { extractExpoPathFromURL } from './extractPathFromURL';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\ntype Options = LinkingOptions<ParamListBase>;\n\nconst linkingHandlers: symbol[] = [];\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n prefixes,\n filter,\n config,\n getInitialURL = () =>\n Promise.race([\n Linking.getInitialURL(),\n new Promise<undefined>((resolve) => {\n // Timeout in 150ms if `getInitialState` doesn't resolve\n // Workaround for https://github.com/facebook/react-native/issues/25675\n setTimeout(resolve, 150);\n }),\n ]),\n subscribe = (listener) => {\n const 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 // @ts-expect-error: removeEventListener is not present in newer RN versions\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 getStateFromPath = getStateFromPathDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') {\n return undefined;\n }\n\n if (independent) {\n return undefined;\n }\n\n if (enabled !== false && linkingHandlers.length) {\n console.error(\n [\n 'Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:',\n \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n '- Only a single instance of the root component is rendered',\n Platform.OS === 'android'\n ? \"- You have set 'android:launchMode=singleTask' in the '<activity />' section of the 'AndroidManifest.xml' file to avoid launching multiple instances\"\n : '',\n ]\n .join('\\n')\n .trim()\n );\n }\n\n const handler = Symbol();\n\n if (enabled !== false) {\n linkingHandlers.push(handler);\n }\n\n return () => {\n const index = linkingHandlers.indexOf(handler);\n\n if (index > -1) {\n linkingHandlers.splice(index, 1);\n }\n };\n }, [enabled, independent]);\n\n // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n const enabledRef = React.useRef(enabled);\n const prefixesRef = React.useRef(prefixes);\n const filterRef = React.useRef(filter);\n const configRef = React.useRef(config);\n const getInitialURLRef = React.useRef(getInitialURL);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n prefixesRef.current = prefixes;\n filterRef.current = filter;\n configRef.current = config;\n getInitialURLRef.current = getInitialURL;\n getStateFromPathRef.current = getStateFromPath;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const getStateFromURL = React.useCallback(\n (url: string | null | undefined) => {\n if (!url || (filterRef.current && !filterRef.current(url))) {\n return undefined;\n }\n\n const path = extractExpoPathFromURL(prefixesRef.current, url);\n\n return path !== undefined ? getStateFromPathRef.current(path, configRef.current) : undefined;\n },\n\n []\n );\n\n const getInitialState = React.useCallback(() => {\n let state: ResultState | undefined;\n\n if (enabledRef.current) {\n const url = getInitialURLRef.current();\n\n if (url != null) {\n if (typeof url !== 'string') {\n return url.then((url) => {\n const state = getStateFromURL(url);\n\n if (typeof url === 'string') {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n }\n\n return state;\n });\n } else {\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n }\n }\n\n state = getStateFromURL(url);\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(state) : state);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n }, [getStateFromURL, onUnhandledLinking, prefixes]);\n\n React.useEffect(() => {\n const listener = (url: string) => {\n if (!enabled) {\n return;\n }\n\n const navigation = ref.current;\n const state = navigation ? getStateFromURL(url) : undefined;\n\n if (navigation && state) {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n const rootState = navigation.getRootState();\n if (state.routes.some((r) => !rootState?.routeNames.includes(r.name))) {\n return;\n }\n\n const action = getActionFromStateRef.current(state, configRef.current);\n\n if (action !== undefined) {\n try {\n navigation.dispatch(action);\n } catch (e) {\n // Ignore any errors from deep linking.\n // This could happen in case of malformed links, navigation object not being initialized etc.\n console.warn(\n `An error occurred when trying to handle the link '${url}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n }\n };\n\n return subscribe(listener);\n }, [enabled, getStateFromURL, onUnhandledLinking, prefixes, ref, subscribe]);\n\n return {\n getInitialState,\n };\n}\n"]}
1
+ {"version":3,"file":"useLinking.native.js","sourceRoot":"","sources":["../../src/fork/useLinking.native.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAMkC;AAElC,0DAA4C;AAC5C,6CAA+B;AAC/B,+CAAiD;AAEjD,6DAA8D;AAM9D,MAAM,eAAe,GAAa,EAAE,CAAC;AAErC,SAAgB,UAAU,CACxB,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,\n type NavigationContainerRef,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/native';\nimport { LinkingOptions } from '@react-navigation/native';\nimport * as ExpoLinking from 'expo-linking';\nimport * as React from 'react';\nimport { Linking, Platform } from 'react-native';\n\nimport { extractExpoPathFromURL } from './extractPathFromURL';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\ntype Options = LinkingOptions<ParamListBase>;\n\nconst linkingHandlers: symbol[] = [];\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n prefixes,\n filter,\n config,\n getInitialURL = () => getInitialURLWithTimeout(),\n subscribe = (listener) => {\n const 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 // @ts-expect-error: removeEventListener is not present in newer RN versions\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 getStateFromPath = getStateFromPathDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') {\n return undefined;\n }\n\n if (independent) {\n return undefined;\n }\n\n if (enabled !== false && linkingHandlers.length) {\n console.error(\n [\n 'Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:',\n \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n '- Only a single instance of the root component is rendered',\n Platform.OS === 'android'\n ? \"- You have set 'android:launchMode=singleTask' in the '<activity />' section of the 'AndroidManifest.xml' file to avoid launching multiple instances\"\n : '',\n ]\n .join('\\n')\n .trim()\n );\n }\n\n const handler = Symbol();\n\n if (enabled !== false) {\n linkingHandlers.push(handler);\n }\n\n return () => {\n const index = linkingHandlers.indexOf(handler);\n\n if (index > -1) {\n linkingHandlers.splice(index, 1);\n }\n };\n }, [enabled, independent]);\n\n // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n const enabledRef = React.useRef(enabled);\n const prefixesRef = React.useRef(prefixes);\n const filterRef = React.useRef(filter);\n const configRef = React.useRef(config);\n const getInitialURLRef = React.useRef(getInitialURL);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n prefixesRef.current = prefixes;\n filterRef.current = filter;\n configRef.current = config;\n getInitialURLRef.current = getInitialURL;\n getStateFromPathRef.current = getStateFromPath;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const getStateFromURL = React.useCallback(\n (url: string | null | undefined) => {\n if (!url || (filterRef.current && !filterRef.current(url))) {\n return undefined;\n }\n\n const path = extractExpoPathFromURL(prefixesRef.current, url);\n\n return path !== undefined ? getStateFromPathRef.current(path, configRef.current) : undefined;\n },\n\n []\n );\n\n const getInitialState = React.useCallback(() => {\n let state: ResultState | undefined;\n\n if (enabledRef.current) {\n const url = getInitialURLRef.current();\n\n if (url != null) {\n if (typeof url !== 'string') {\n return url.then((url) => {\n const state = getStateFromURL(url);\n\n if (typeof url === 'string') {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n }\n\n return state;\n });\n } else {\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n }\n }\n\n state = getStateFromURL(url);\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(state) : state);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n }, [getStateFromURL, onUnhandledLinking, prefixes]);\n\n React.useEffect(() => {\n const listener = (url: string) => {\n if (!enabled) {\n return;\n }\n\n const navigation = ref.current;\n const state = navigation ? getStateFromURL(url) : undefined;\n\n if (navigation && state) {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n const rootState = navigation.getRootState();\n if (state.routes.some((r) => !rootState?.routeNames.includes(r.name))) {\n return;\n }\n\n const action = getActionFromStateRef.current(state, configRef.current);\n\n if (action !== undefined) {\n try {\n navigation.dispatch(action);\n } catch (e) {\n // Ignore any errors from deep linking.\n // This could happen in case of malformed links, navigation object not being initialized etc.\n console.warn(\n `An error occurred when trying to handle the link '${url}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n }\n };\n\n return subscribe(listener);\n }, [enabled, getStateFromURL, onUnhandledLinking, prefixes, ref, subscribe]);\n\n return {\n getInitialState,\n };\n}\n\nexport function getInitialURLWithTimeout(): string | null | Promise<string | null> {\n if (typeof window === 'undefined') {\n return '';\n } else if (Platform.OS === 'ios') {\n // Use the new Expo API for iOS. This has better support for App Clips and handoff.\n return ExpoLinking.getLinkingURL();\n }\n\n return Promise.race([\n // TODO: Phase this out in favor of expo-linking on Android.\n Linking.getInitialURL(),\n new Promise<null>((resolve) =>\n // Timeout in 150ms if `getInitialState` doesn't resolve\n // Workaround for https://github.com/facebook/react-native/issues/25675\n setTimeout(() => resolve(null), 150)\n ),\n ]);\n}\n"]}
@@ -401,19 +401,20 @@ function appendNotFoundRoute(directory, options) {
401
401
  function getLayoutNode(node, options) {
402
402
  /**
403
403
  * A file called `(a,b)/(c)/_layout.tsx` will generate two _layout routes: `(a)/(c)/_layout` and `(b)/(c)/_layout`.
404
- * Each of these layouts will have a different initialRouteName based upon the first group name.
404
+ * Each of these layouts will have a different anchor based upon the first group name.
405
405
  */
406
406
  // We may strip loadRoute during testing
407
407
  const groupName = (0, matchers_1.matchLastGroupName)(node.route);
408
408
  const childMatchingGroup = node.children.find((child) => {
409
409
  return child.route.replace(/\/index$/, '') === groupName;
410
410
  });
411
- let initialRouteName = childMatchingGroup?.route;
411
+ let anchor = childMatchingGroup?.route;
412
412
  const loaded = node.loadRoute();
413
413
  if (loaded?.unstable_settings) {
414
414
  try {
415
415
  // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.
416
- initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;
416
+ anchor =
417
+ loaded.unstable_settings.anchor ?? loaded.unstable_settings.initialRouteName ?? anchor;
417
418
  }
418
419
  catch (error) {
419
420
  if (error instanceof Error) {
@@ -424,15 +425,16 @@ function getLayoutNode(node, options) {
424
425
  }
425
426
  if (groupName) {
426
427
  // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.
427
- const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.initialRouteName;
428
- initialRouteName = groupSpecificInitialRouteName ?? initialRouteName;
428
+ const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.anchor ??
429
+ loaded.unstable_settings?.[groupName]?.initialRouteName;
430
+ anchor = groupSpecificInitialRouteName ?? anchor;
429
431
  }
430
432
  }
431
433
  return {
432
434
  ...node,
433
435
  route: node.route.replace(/\/?_layout$/, ''),
434
436
  children: [],
435
- initialRouteName,
437
+ initialRouteName: anchor,
436
438
  };
437
439
  }
438
440
  function crawlAndAppendInitialRoutesAndEntryFiles(node, options, entryPoints = []) {
@@ -449,20 +451,21 @@ function crawlAndAppendInitialRoutesAndEntryFiles(node, options, entryPoints = [
449
451
  * Calculate the initialRouteNode
450
452
  *
451
453
  * A file called `(a,b)/(c)/_layout.tsx` will generate two _layout routes: `(a)/(c)/_layout` and `(b)/(c)/_layout`.
452
- * Each of these layouts will have a different initialRouteName based upon the first group.
454
+ * Each of these layouts will have a different anchor based upon the first group.
453
455
  */
454
456
  const groupName = (0, matchers_1.matchGroupName)(node.route);
455
457
  const childMatchingGroup = node.children.find((child) => {
456
458
  return child.route.replace(/\/index$/, '') === groupName;
457
459
  });
458
- let initialRouteName = childMatchingGroup?.route;
460
+ let anchor = childMatchingGroup?.route;
459
461
  // We may strip loadRoute during testing
460
462
  if (!options.internal_stripLoadRoute) {
461
463
  const loaded = node.loadRoute();
462
464
  if (loaded?.unstable_settings) {
463
465
  try {
464
466
  // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.
465
- initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;
467
+ anchor =
468
+ loaded.unstable_settings.anchor ?? loaded.unstable_settings.initialRouteName ?? anchor;
466
469
  }
467
470
  catch (error) {
468
471
  if (error instanceof Error) {
@@ -473,28 +476,29 @@ function crawlAndAppendInitialRoutesAndEntryFiles(node, options, entryPoints = [
473
476
  }
474
477
  if (groupName) {
475
478
  // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.
476
- const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.initialRouteName;
477
- initialRouteName = groupSpecificInitialRouteName ?? initialRouteName;
479
+ const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.anchor ??
480
+ loaded.unstable_settings?.[groupName]?.initialRouteName;
481
+ anchor = groupSpecificInitialRouteName ?? anchor;
478
482
  }
479
483
  }
480
484
  }
481
- if (initialRouteName) {
482
- const initialRoute = node.children.find((child) => child.route === initialRouteName);
483
- if (!initialRoute) {
484
- const validInitialRoutes = node.children
485
+ if (anchor) {
486
+ const anchorRoute = node.children.find((child) => child.route === anchor);
487
+ if (!anchorRoute) {
488
+ const validAnchorRoutes = node.children
485
489
  .filter((child) => !child.generated)
486
490
  .map((child) => `'${child.route}'`)
487
491
  .join(', ');
488
492
  if (groupName) {
489
- throw new Error(`Layout ${node.contextKey} has invalid initialRouteName '${initialRouteName}' for group '(${groupName})'. Valid options are: ${validInitialRoutes}`);
493
+ throw new Error(`Layout ${node.contextKey} has invalid anchor '${anchor}' for group '(${groupName})'. Valid options are: ${validAnchorRoutes}`);
490
494
  }
491
495
  else {
492
- throw new Error(`Layout ${node.contextKey} has invalid initialRouteName '${initialRouteName}'. Valid options are: ${validInitialRoutes}`);
496
+ throw new Error(`Layout ${node.contextKey} has invalid anchor '${anchor}'. Valid options are: ${validAnchorRoutes}`);
493
497
  }
494
498
  }
495
499
  // Navigators can add initialsRoutes into the history, so they need to be to be included in the entryPoints
496
- node.initialRouteName = initialRouteName;
497
- entryPoints.push(initialRoute.contextKey);
500
+ node.initialRouteName = anchor;
501
+ entryPoints.push(anchorRoute.contextKey);
498
502
  }
499
503
  for (const child of node.children) {
500
504
  crawlAndAppendInitialRoutesAndEntryFiles(child, options, entryPoints);
@@ -1 +1 @@
1
- {"version":3,"file":"getRoutesCore.js","sourceRoot":"","sources":["../src/getRoutesCore.ts"],"names":[],"mappings":";;;AACA,yCAOoB;AA6BpB,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;AAEpE;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS,CAAC,aAA6B,EAAE,OAAgB;IACvE,MAAM,aAAa,GAAG,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAE/D,yBAAyB;IACzB,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,QAAQ,GAAG,4BAA4B,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAEtE,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;QAC9B,wCAAwC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC7D;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAfD,8BAeC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,aAA6B,EAAE,OAAgB;IACvE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAA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ACb,YAAY,KAAK,CAAC,UAAU,sEAAsE,CACnG,CAAC;KACH;IAED,wFAAwF;IACxF,4CAA4C;IAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type { DynamicConvention, RouteNode } from './Route';\nimport {\n matchArrayGroupName,\n matchDeepDynamicRouteName,\n matchDynamicName,\n matchGroupName,\n matchLastGroupName,\n removeSupportedExtensions,\n} from './matchers';\nimport type { RequireContext } from './types';\n\nexport type Options = {\n ignore?: RegExp[];\n preserveApiRoutes?: boolean;\n ignoreRequireErrors?: boolean;\n ignoreEntryPoints?: boolean;\n /* Used to simplify testing for toEqual() comparison */\n internal_stripLoadRoute?: boolean;\n /* Used to simplify by skipping the generated routes */\n skipGenerated?: boolean;\n /* Skip the generated not found route */\n notFound?: boolean;\n importMode?: string;\n platformRoutes?: boolean;\n sitemap?: boolean;\n platform?: string;\n\n /** Get the system route for a location. Useful for shimming React Native imports in SSR environments. */\n getSystemRoute: (route: Pick<RouteNode, 'route' | 'type'>) => RouteNode;\n};\n\ntype DirectoryNode = {\n layout?: RouteNode[];\n files: Map<string, RouteNode[]>;\n subdirectories: Map<string, DirectoryNode>;\n};\n\nconst validPlatforms = new Set(['android', 'ios', 'native', 'web']);\n\n/**\n * Given a Metro context module, return an array of nested routes.\n *\n * This is a two step process:\n * 1. Convert the RequireContext keys (file paths) into a directory tree.\n * - This should extrapolate array syntax into multiple routes\n * - Routes are given a specificity score\n * 2. Flatten the directory tree into routes\n * - Routes in directories without _layout files are hoisted to the nearest _layout\n * - The name of the route is relative to the nearest _layout\n * - If multiple routes have the same name, the most specific route is used\n */\nexport function getRoutes(contextModule: RequireContext, options: Options): RouteNode | null {\n const directoryTree = getDirectoryTree(contextModule, options);\n\n // If there are no routes\n if (!directoryTree) {\n return null;\n }\n\n const rootNode = flattenDirectoryTreeToRoutes(directoryTree, options);\n\n if (!options.ignoreEntryPoints) {\n crawlAndAppendInitialRoutesAndEntryFiles(rootNode, options);\n }\n\n return rootNode;\n}\n\n/**\n * Converts the RequireContext keys (file paths) into a directory tree.\n */\nfunction getDirectoryTree(contextModule: RequireContext, options: Options) {\n const importMode = options.importMode || process.env.EXPO_ROUTER_IMPORT_MODE;\n\n const ignoreList: RegExp[] = [/^\\.\\/\\+(html|native-intent)\\.[tj]sx?$/]; // Ignore the top level ./+html file\n\n if (options.ignore) {\n ignoreList.push(...options.ignore);\n }\n if (!options.preserveApiRoutes) {\n ignoreList.push(/\\+api\\.[tj]sx?$/);\n }\n\n const rootDirectory: DirectoryNode = {\n files: new Map(),\n subdirectories: new Map(),\n };\n\n let hasRoutes = false;\n let isValid = false;\n\n for (const filePath of contextModule.keys()) {\n if (ignoreList.some((regex) => regex.test(filePath))) {\n continue;\n }\n\n isValid = true;\n\n const meta = getFileMeta(filePath, options);\n\n // This is a file that should be ignored. e.g maybe it has an invalid platform?\n if (meta.specificity < 0) {\n continue;\n }\n\n let node: RouteNode = {\n type: meta.isApi ? 'api' : meta.isLayout ? 'layout' : 'route',\n loadRoute() {\n let routeModule: any;\n if (options.ignoreRequireErrors) {\n try {\n routeModule = contextModule(filePath);\n } catch {\n routeModule = {};\n }\n } else {\n routeModule = contextModule(filePath);\n }\n\n if (process.env.NODE_ENV === 'development' && importMode === 'sync') {\n // In development mode, when async routes are disabled, add some extra error handling to improve the developer experience.\n // This can be useful when you accidentally use an async function in a route file for the default export.\n if (routeModule instanceof Promise) {\n throw new Error(\n `Route \"${filePath}\" cannot be a promise when async routes is disabled.`\n );\n }\n\n const defaultExport = routeModule?.default;\n if (defaultExport instanceof Promise) {\n throw new Error(\n `The default export from route \"${filePath}\" is a promise. Ensure the React Component does not use async or promises.`\n );\n }\n\n // check if default is an async function without invoking it\n if (\n defaultExport instanceof Function &&\n // This only works on web because Hermes support async functions so we have to transform them out.\n defaultExport.constructor.name === 'AsyncFunction'\n ) {\n throw new Error(\n `The default export from route \"${filePath}\" is an async function. Ensure the React Component does not use async or promises.`\n );\n }\n }\n\n return routeModule;\n },\n contextKey: filePath,\n route: '', // This is overwritten during hoisting based upon the _layout\n dynamic: null,\n children: [], // While we are building the directory tree, we don't know the node's children just yet. This is added during hoisting\n };\n\n if (process.env.NODE_ENV === 'development') {\n // If the user has set the `EXPO_ROUTER_IMPORT_MODE` to `sync` then we should\n // filter the missing routes.\n if (node.type !== 'api' && importMode === 'sync') {\n const routeItem = node.loadRoute();\n // Have a warning for nullish ex\n const route = routeItem?.default;\n if (route == null) {\n // Do not throw an error since a user may just be creating a new route.\n console.warn(\n `Route \"${filePath}\" is missing the required default export. Ensure a React component is exported as default.`\n );\n continue;\n }\n if (['boolean', 'number', 'string'].includes(typeof route)) {\n throw new Error(\n `The default export from route \"${filePath}\" is an unsupported type: \"${typeof route}\". Only React Components are supported as default exports from route files.`\n );\n }\n }\n }\n\n /**\n * A single filepath may be extrapolated into multiple routes if it contains array syntax.\n * Another way to thinking about is that a filepath node is present in multiple leaves of the directory tree.\n */\n for (const route of extrapolateGroups(meta.route)) {\n // Traverse the directory tree to its leaf node, creating any missing directories along the way\n const subdirectoryParts = route.split('/').slice(0, -1);\n\n // Start at the root directory and traverse the path to the leaf directory\n let directory = rootDirectory;\n\n for (const part of subdirectoryParts) {\n let subDirectory = directory.subdirectories.get(part);\n\n // Create any missing subdirectories\n if (!subDirectory) {\n subDirectory = {\n files: new Map(),\n subdirectories: new Map(),\n };\n directory.subdirectories.set(part, subDirectory);\n }\n\n directory = subDirectory;\n }\n\n // Clone the node for this route\n node = { ...node, route };\n\n if (meta.isLayout) {\n directory.layout ??= [];\n const existing = directory.layout[meta.specificity];\n if (existing) {\n // In production, use the first route found\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n `The layouts \"${filePath}\" and \"${existing.contextKey}\" conflict on the route \"/${route}\". Please remove or rename one of these files.`\n );\n }\n } else {\n node = getLayoutNode(node, options);\n directory.layout[meta.specificity] = node;\n }\n } else if (meta.isApi) {\n const fileKey = `${route}+api`;\n let nodes = directory.files.get(fileKey);\n\n if (!nodes) {\n nodes = [];\n directory.files.set(fileKey, nodes);\n }\n\n // API Routes have no specificity, they are always the first node\n const existing = nodes[0];\n\n if (existing) {\n // In production, use the first route found\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n `The API route file \"${filePath}\" and \"${existing.contextKey}\" conflict on the route \"/${route}\". Please remove or rename one of these files.`\n );\n }\n } else {\n nodes[0] = node;\n }\n } else {\n let nodes = directory.files.get(route);\n\n if (!nodes) {\n nodes = [];\n directory.files.set(route, nodes);\n }\n\n /**\n * If there is an existing node with the same specificity, then we have a conflict.\n * NOTE(Platform Routes):\n * We cannot check for specificity conflicts here, as we haven't processed all the context keys yet!\n * This will be checked during hoisting, as well as enforcing that all routes have a non-platform route.\n */\n const existing = nodes[meta.specificity];\n if (existing) {\n // In production, use the first route found\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n `The route files \"${filePath}\" and \"${existing.contextKey}\" conflict on the route \"/${route}\". Please remove or rename one of these files.`\n );\n }\n } else {\n hasRoutes ||= true;\n nodes[meta.specificity] = node;\n }\n }\n }\n }\n\n // If there are no routes/layouts then we should display the tutorial.\n if (!isValid) {\n return null;\n }\n\n /**\n * If there are no top-level _layout, add a default _layout\n * While this is a generated route, it will still be generated even if skipGenerated is true.\n */\n if (!rootDirectory.layout) {\n rootDirectory.layout = [\n options.getSystemRoute({\n type: 'layout',\n route: '',\n }),\n ];\n }\n\n // Only include the sitemap if there are routes.\n if (!options.skipGenerated) {\n if (hasRoutes && options.sitemap !== false) {\n appendSitemapRoute(rootDirectory, options);\n }\n if (options.notFound !== false) {\n appendNotFoundRoute(rootDirectory, options);\n }\n }\n return rootDirectory;\n}\n\n/**\n * Flatten the directory tree into routes, hoisting routes to the nearest _layout.\n */\nfunction flattenDirectoryTreeToRoutes(\n directory: DirectoryNode,\n options: Options,\n /* The nearest _layout file in the directory tree */\n layout?: RouteNode,\n /* Route names are relative to their layout */\n pathToRemove = ''\n) {\n /**\n * This directory has a _layout file so it becomes the new target for hoisting routes.\n */\n if (directory.layout) {\n const previousLayout = layout;\n layout = getMostSpecific(directory.layout);\n\n // Add the new layout as a child of its parent\n if (previousLayout) {\n previousLayout.children.push(layout);\n }\n\n if (options.internal_stripLoadRoute) {\n delete (layout as any).loadRoute;\n }\n\n // `route` is the absolute pathname. We need to make this relative to the last _layout\n const newRoute = layout.route.replace(pathToRemove, '');\n pathToRemove = layout.route ? `${layout.route}/` : '';\n\n // Now update this layout with the new relative route and dynamic conventions\n layout.route = newRoute;\n layout.dynamic = generateDynamic(layout.contextKey.slice(0));\n }\n\n // This should never occur as there will always be a root layout, but it makes the type system happy\n if (!layout) throw new Error('Expo Router Internal Error: No nearest layout');\n\n for (const routes of directory.files.values()) {\n const routeNode = getMostSpecific(routes);\n\n // `route` is the absolute pathname. We need to make this relative to the nearest layout\n routeNode.route = routeNode.route.replace(pathToRemove, '');\n routeNode.dynamic = generateDynamic(routeNode.route);\n\n if (options.internal_stripLoadRoute) {\n delete (routeNode as any).loadRoute;\n }\n\n layout.children.push(routeNode);\n }\n\n // Recursively flatten the subdirectories\n for (const child of directory.subdirectories.values()) {\n flattenDirectoryTreeToRoutes(child, options, layout, pathToRemove);\n }\n\n return layout;\n}\n\nfunction getFileMeta(key: string, options: Options) {\n // Remove the leading `./`\n key = key.replace(/^\\.\\//, '');\n\n const parts = key.split('/');\n let route = removeSupportedExtensions(key);\n const filename = parts[parts.length - 1];\n const [filenameWithoutExtensions, platformExtension] =\n removeSupportedExtensions(filename).split('.');\n const isLayout = filenameWithoutExtensions === '_layout';\n const isApi = filename.match(/\\+api\\.(\\w+\\.)?[jt]sx?$/);\n\n if (filenameWithoutExtensions.startsWith('(') && filenameWithoutExtensions.endsWith(')')) {\n throw new Error(`Invalid route ./${key}. Routes cannot end with '(group)' syntax`);\n }\n\n // Nested routes cannot start with the '+' character, except for the '+not-found' route\n if (!isApi && filename.startsWith('+') && filenameWithoutExtensions !== '+not-found') {\n const renamedRoute = [...parts.slice(0, -1), filename.slice(1)].join('/');\n throw new Error(\n `Invalid route ./${key}. Route nodes cannot start with the '+' character. \"Please rename to ${renamedRoute}\"`\n );\n }\n let specificity = 0;\n\n const hasPlatformExtension = validPlatforms.has(platformExtension);\n const usePlatformRoutes = options.platformRoutes ?? true;\n\n if (hasPlatformExtension) {\n if (!usePlatformRoutes) {\n // If the user has disabled platform routes, then we should ignore this file\n specificity = -1;\n } else if (!options.platform) {\n // If we don't have a platform, then we should ignore this file\n // This used by typed routes, sitemap, etc\n specificity = -1;\n } else if (platformExtension === options.platform) {\n // If the platform extension is the same as the options.platform, then it is the most specific\n specificity = 2;\n } else if (platformExtension === 'native' && options.platform !== 'web') {\n // `native` is allow but isn't as specific as the platform\n specificity = 1;\n } else if (platformExtension !== options.platform) {\n // Somehow we have a platform extension that doesn't match the options.platform and it isn't native\n // This is an invalid file and we will ignore it\n specificity = -1;\n }\n\n if (isApi && specificity !== 0) {\n throw new Error(\n `Api routes cannot have platform extensions. Please remove '.${platformExtension}' from './${key}'`\n );\n }\n\n route = route.replace(new RegExp(`.${platformExtension}$`), '');\n }\n\n return {\n route,\n specificity,\n isLayout,\n isApi,\n };\n}\n\nexport function getIgnoreList(options?: Options) {\n const ignore: RegExp[] = [/^\\.\\/\\+html\\.[tj]sx?$/, ...(options?.ignore ?? [])];\n if (options?.preserveApiRoutes !== true) {\n ignore.push(/\\+api\\.[tj]sx?$/);\n }\n return ignore;\n}\n\n/**\n * Generates a set of strings which have the router array syntax extrapolated.\n *\n * /(a,b)/(c,d)/e.tsx => new Set(['a/c/e.tsx', 'a/d/e.tsx', 'b/c/e.tsx', 'b/d/e.tsx'])\n */\nexport function extrapolateGroups(key: string, keys: Set<string> = new Set()): Set<string> {\n const match = matchArrayGroupName(key);\n\n if (!match) {\n keys.add(key);\n return keys;\n }\n const groups = match.split(',');\n const groupsSet = new Set(groups);\n\n if (groupsSet.size !== groups.length) {\n throw new Error(`Array syntax cannot contain duplicate group name \"${groups}\" in \"${key}\".`);\n }\n\n if (groups.length === 1) {\n keys.add(key);\n return keys;\n }\n\n for (const group of groups) {\n extrapolateGroups(key.replace(match, group.trim()), keys);\n }\n\n return keys;\n}\n\nexport function generateDynamic(path: string): DynamicConvention[] | null {\n const dynamic = path\n .split('/')\n .map((part): DynamicConvention | null => {\n if (part === '+not-found') {\n return {\n name: '+not-found',\n deep: true,\n notFound: true,\n };\n }\n\n const deepDynamicName = matchDeepDynamicRouteName(part);\n const dynamicName = deepDynamicName ?? matchDynamicName(part);\n\n if (!dynamicName) return null;\n return { name: dynamicName, deep: !!deepDynamicName };\n })\n .filter((part): part is DynamicConvention => !!part);\n\n return dynamic.length === 0 ? null : dynamic;\n}\n\nfunction appendSitemapRoute(directory: DirectoryNode, options: Options) {\n if (!directory.files.has('_sitemap') && options.getSystemRoute) {\n directory.files.set('_sitemap', [\n options.getSystemRoute({\n type: 'route',\n route: '_sitemap',\n }),\n ]);\n }\n}\n\nfunction appendNotFoundRoute(directory: DirectoryNode, options: Options) {\n if (!directory.files.has('+not-found') && options.getSystemRoute) {\n directory.files.set('+not-found', [\n options.getSystemRoute({\n type: 'route',\n route: '+not-found',\n }),\n ]);\n }\n}\n\nfunction getLayoutNode(node: RouteNode, options: Options) {\n /**\n * A file called `(a,b)/(c)/_layout.tsx` will generate two _layout routes: `(a)/(c)/_layout` and `(b)/(c)/_layout`.\n * Each of these layouts will have a different initialRouteName based upon the first group name.\n */\n // We may strip loadRoute during testing\n const groupName = matchLastGroupName(node.route);\n const childMatchingGroup = node.children.find((child) => {\n return child.route.replace(/\\/index$/, '') === groupName;\n });\n let initialRouteName = childMatchingGroup?.route;\n const loaded = node.loadRoute();\n if (loaded?.unstable_settings) {\n try {\n // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.\n initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;\n } catch (error: any) {\n if (error instanceof Error) {\n if (!error.message.match(/You cannot dot into a client module/)) {\n throw error;\n }\n }\n }\n\n if (groupName) {\n // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.\n const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.initialRouteName;\n\n initialRouteName = groupSpecificInitialRouteName ?? initialRouteName;\n }\n }\n\n return {\n ...node,\n route: node.route.replace(/\\/?_layout$/, ''),\n children: [], // Each layout should have its own children\n initialRouteName,\n };\n}\n\nfunction crawlAndAppendInitialRoutesAndEntryFiles(\n node: RouteNode,\n options: Options,\n entryPoints: string[] = []\n) {\n if (node.type === 'route') {\n node.entryPoints = [...new Set([...entryPoints, node.contextKey])];\n } else if (node.type === 'layout') {\n if (!node.children) {\n throw new Error(`Layout \"${node.contextKey}\" does not contain any child routes`);\n }\n\n // Every node below this layout will have it as an entryPoint\n entryPoints = [...entryPoints, node.contextKey];\n\n /**\n * Calculate the initialRouteNode\n *\n * A file called `(a,b)/(c)/_layout.tsx` will generate two _layout routes: `(a)/(c)/_layout` and `(b)/(c)/_layout`.\n * Each of these layouts will have a different initialRouteName based upon the first group.\n */\n const groupName = matchGroupName(node.route);\n const childMatchingGroup = node.children.find((child) => {\n return child.route.replace(/\\/index$/, '') === groupName;\n });\n let initialRouteName = childMatchingGroup?.route;\n // We may strip loadRoute during testing\n if (!options.internal_stripLoadRoute) {\n const loaded = node.loadRoute();\n if (loaded?.unstable_settings) {\n try {\n // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.\n initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;\n } catch (error: any) {\n if (error instanceof Error) {\n if (!error.message.match(/You cannot dot into a client module/)) {\n throw error;\n }\n }\n }\n\n if (groupName) {\n // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.\n const groupSpecificInitialRouteName =\n loaded.unstable_settings?.[groupName]?.initialRouteName;\n\n initialRouteName = groupSpecificInitialRouteName ?? initialRouteName;\n }\n }\n }\n\n if (initialRouteName) {\n const initialRoute = node.children.find((child) => child.route === initialRouteName);\n if (!initialRoute) {\n const validInitialRoutes = node.children\n .filter((child) => !child.generated)\n .map((child) => `'${child.route}'`)\n .join(', ');\n\n if (groupName) {\n throw new Error(\n `Layout ${node.contextKey} has invalid initialRouteName '${initialRouteName}' for group '(${groupName})'. Valid options are: ${validInitialRoutes}`\n );\n } else {\n throw new Error(\n `Layout ${node.contextKey} has invalid initialRouteName '${initialRouteName}'. Valid options are: ${validInitialRoutes}`\n );\n }\n }\n\n // Navigators can add initialsRoutes into the history, so they need to be to be included in the entryPoints\n node.initialRouteName = initialRouteName;\n entryPoints.push(initialRoute.contextKey);\n }\n\n for (const child of node.children) {\n crawlAndAppendInitialRoutesAndEntryFiles(child, options, entryPoints);\n }\n }\n}\n\nfunction getMostSpecific(routes: RouteNode[]) {\n const route = routes[routes.length - 1];\n\n if (!routes[0]) {\n throw new Error(\n `The file ${route.contextKey} does not have a fallback sibling file without a platform extension.`\n );\n }\n\n // This works even tho routes is holey array (e.g it might have index 0 and 2 but not 1)\n // `.length` includes the holes in its count\n return routes[routes.length - 1];\n}\n"]}
1
+ {"version":3,"file":"getRoutesCore.js","sourceRoot":"","sources":["../src/getRoutesCore.ts"],"names":[],"mappings":";;;AACA,yCAOoB;AA6BpB,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;AAEpE;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS,CAAC,aAA6B,EAAE,OAAgB;IACvE,MAAM,aAAa,GAAG,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAE/D,yBAAyB;IACzB,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,QAAQ,GAAG,4BAA4B,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAEtE,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;QAC9B,wCAAwC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC7D;IAED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AAC,WAAW,CAAC,UAAU,CAAC,CAAC;SAC1C;QAED,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjC,wCAAwC,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;SACvE;KACF;AACH,CAAC;AAED,SAAS,eAAe,CAAC,MAAmB;IAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QACd,MAAM,IAAI,KAAK,CACb,YAAY,KAAK,CAAC,UAAU,sEAAsE,CACnG,CAAC;KACH;IAED,wFAAwF;IACxF,4CAA4C;IAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type { DynamicConvention, RouteNode } from './Route';\nimport {\n matchArrayGroupName,\n matchDeepDynamicRouteName,\n matchDynamicName,\n matchGroupName,\n matchLastGroupName,\n removeSupportedExtensions,\n} from './matchers';\nimport type { RequireContext } from './types';\n\nexport type Options = {\n ignore?: RegExp[];\n preserveApiRoutes?: boolean;\n ignoreRequireErrors?: boolean;\n ignoreEntryPoints?: boolean;\n /* Used to simplify testing for toEqual() comparison */\n internal_stripLoadRoute?: boolean;\n /* Used to simplify by skipping the generated routes */\n skipGenerated?: boolean;\n /* Skip the generated not found route */\n notFound?: boolean;\n importMode?: string;\n platformRoutes?: boolean;\n sitemap?: boolean;\n platform?: string;\n\n /** Get the system route for a location. Useful for shimming React Native imports in SSR environments. */\n getSystemRoute: (route: Pick<RouteNode, 'route' | 'type'>) => RouteNode;\n};\n\ntype DirectoryNode = {\n layout?: RouteNode[];\n files: Map<string, RouteNode[]>;\n subdirectories: Map<string, DirectoryNode>;\n};\n\nconst validPlatforms = new Set(['android', 'ios', 'native', 'web']);\n\n/**\n * Given a Metro context module, return an array of nested routes.\n *\n * This is a two step process:\n * 1. Convert the RequireContext keys (file paths) into a directory tree.\n * - This should extrapolate array syntax into multiple routes\n * - Routes are given a specificity score\n * 2. Flatten the directory tree into routes\n * - Routes in directories without _layout files are hoisted to the nearest _layout\n * - The name of the route is relative to the nearest _layout\n * - If multiple routes have the same name, the most specific route is used\n */\nexport function getRoutes(contextModule: RequireContext, options: Options): RouteNode | null {\n const directoryTree = getDirectoryTree(contextModule, options);\n\n // If there are no routes\n if (!directoryTree) {\n return null;\n }\n\n const rootNode = flattenDirectoryTreeToRoutes(directoryTree, options);\n\n if (!options.ignoreEntryPoints) {\n crawlAndAppendInitialRoutesAndEntryFiles(rootNode, options);\n }\n\n return rootNode;\n}\n\n/**\n * Converts the RequireContext keys (file paths) into a directory tree.\n */\nfunction getDirectoryTree(contextModule: RequireContext, options: Options) {\n const importMode = options.importMode || process.env.EXPO_ROUTER_IMPORT_MODE;\n\n const ignoreList: RegExp[] = [/^\\.\\/\\+(html|native-intent)\\.[tj]sx?$/]; // Ignore the top level ./+html file\n\n if (options.ignore) {\n ignoreList.push(...options.ignore);\n }\n if (!options.preserveApiRoutes) {\n ignoreList.push(/\\+api\\.[tj]sx?$/);\n }\n\n const rootDirectory: DirectoryNode = {\n files: new Map(),\n subdirectories: new Map(),\n };\n\n let hasRoutes = false;\n let isValid = false;\n\n for (const filePath of contextModule.keys()) {\n if (ignoreList.some((regex) => regex.test(filePath))) {\n continue;\n }\n\n isValid = true;\n\n const meta = getFileMeta(filePath, options);\n\n // This is a file that should be ignored. e.g maybe it has an invalid platform?\n if (meta.specificity < 0) {\n continue;\n }\n\n let node: RouteNode = {\n type: meta.isApi ? 'api' : meta.isLayout ? 'layout' : 'route',\n loadRoute() {\n let routeModule: any;\n if (options.ignoreRequireErrors) {\n try {\n routeModule = contextModule(filePath);\n } catch {\n routeModule = {};\n }\n } else {\n routeModule = contextModule(filePath);\n }\n\n if (process.env.NODE_ENV === 'development' && importMode === 'sync') {\n // In development mode, when async routes are disabled, add some extra error handling to improve the developer experience.\n // This can be useful when you accidentally use an async function in a route file for the default export.\n if (routeModule instanceof Promise) {\n throw new Error(\n `Route \"${filePath}\" cannot be a promise when async routes is disabled.`\n );\n }\n\n const defaultExport = routeModule?.default;\n if (defaultExport instanceof Promise) {\n throw new Error(\n `The default export from route \"${filePath}\" is a promise. Ensure the React Component does not use async or promises.`\n );\n }\n\n // check if default is an async function without invoking it\n if (\n defaultExport instanceof Function &&\n // This only works on web because Hermes support async functions so we have to transform them out.\n defaultExport.constructor.name === 'AsyncFunction'\n ) {\n throw new Error(\n `The default export from route \"${filePath}\" is an async function. Ensure the React Component does not use async or promises.`\n );\n }\n }\n\n return routeModule;\n },\n contextKey: filePath,\n route: '', // This is overwritten during hoisting based upon the _layout\n dynamic: null,\n children: [], // While we are building the directory tree, we don't know the node's children just yet. This is added during hoisting\n };\n\n if (process.env.NODE_ENV === 'development') {\n // If the user has set the `EXPO_ROUTER_IMPORT_MODE` to `sync` then we should\n // filter the missing routes.\n if (node.type !== 'api' && importMode === 'sync') {\n const routeItem = node.loadRoute();\n // Have a warning for nullish ex\n const route = routeItem?.default;\n if (route == null) {\n // Do not throw an error since a user may just be creating a new route.\n console.warn(\n `Route \"${filePath}\" is missing the required default export. Ensure a React component is exported as default.`\n );\n continue;\n }\n if (['boolean', 'number', 'string'].includes(typeof route)) {\n throw new Error(\n `The default export from route \"${filePath}\" is an unsupported type: \"${typeof route}\". Only React Components are supported as default exports from route files.`\n );\n }\n }\n }\n\n /**\n * A single filepath may be extrapolated into multiple routes if it contains array syntax.\n * Another way to thinking about is that a filepath node is present in multiple leaves of the directory tree.\n */\n for (const route of extrapolateGroups(meta.route)) {\n // Traverse the directory tree to its leaf node, creating any missing directories along the way\n const subdirectoryParts = route.split('/').slice(0, -1);\n\n // Start at the root directory and traverse the path to the leaf directory\n let directory = rootDirectory;\n\n for (const part of subdirectoryParts) {\n let subDirectory = directory.subdirectories.get(part);\n\n // Create any missing subdirectories\n if (!subDirectory) {\n subDirectory = {\n files: new Map(),\n subdirectories: new Map(),\n };\n directory.subdirectories.set(part, subDirectory);\n }\n\n directory = subDirectory;\n }\n\n // Clone the node for this route\n node = { ...node, route };\n\n if (meta.isLayout) {\n directory.layout ??= [];\n const existing = directory.layout[meta.specificity];\n if (existing) {\n // In production, use the first route found\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n `The layouts \"${filePath}\" and \"${existing.contextKey}\" conflict on the route \"/${route}\". Please remove or rename one of these files.`\n );\n }\n } else {\n node = getLayoutNode(node, options);\n directory.layout[meta.specificity] = node;\n }\n } else if (meta.isApi) {\n const fileKey = `${route}+api`;\n let nodes = directory.files.get(fileKey);\n\n if (!nodes) {\n nodes = [];\n directory.files.set(fileKey, nodes);\n }\n\n // API Routes have no specificity, they are always the first node\n const existing = nodes[0];\n\n if (existing) {\n // In production, use the first route found\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n `The API route file \"${filePath}\" and \"${existing.contextKey}\" conflict on the route \"/${route}\". Please remove or rename one of these files.`\n );\n }\n } else {\n nodes[0] = node;\n }\n } else {\n let nodes = directory.files.get(route);\n\n if (!nodes) {\n nodes = [];\n directory.files.set(route, nodes);\n }\n\n /**\n * If there is an existing node with the same specificity, then we have a conflict.\n * NOTE(Platform Routes):\n * We cannot check for specificity conflicts here, as we haven't processed all the context keys yet!\n * This will be checked during hoisting, as well as enforcing that all routes have a non-platform route.\n */\n const existing = nodes[meta.specificity];\n if (existing) {\n // In production, use the first route found\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n `The route files \"${filePath}\" and \"${existing.contextKey}\" conflict on the route \"/${route}\". Please remove or rename one of these files.`\n );\n }\n } else {\n hasRoutes ||= true;\n nodes[meta.specificity] = node;\n }\n }\n }\n }\n\n // If there are no routes/layouts then we should display the tutorial.\n if (!isValid) {\n return null;\n }\n\n /**\n * If there are no top-level _layout, add a default _layout\n * While this is a generated route, it will still be generated even if skipGenerated is true.\n */\n if (!rootDirectory.layout) {\n rootDirectory.layout = [\n options.getSystemRoute({\n type: 'layout',\n route: '',\n }),\n ];\n }\n\n // Only include the sitemap if there are routes.\n if (!options.skipGenerated) {\n if (hasRoutes && options.sitemap !== false) {\n appendSitemapRoute(rootDirectory, options);\n }\n if (options.notFound !== false) {\n appendNotFoundRoute(rootDirectory, options);\n }\n }\n return rootDirectory;\n}\n\n/**\n * Flatten the directory tree into routes, hoisting routes to the nearest _layout.\n */\nfunction flattenDirectoryTreeToRoutes(\n directory: DirectoryNode,\n options: Options,\n /* The nearest _layout file in the directory tree */\n layout?: RouteNode,\n /* Route names are relative to their layout */\n pathToRemove = ''\n) {\n /**\n * This directory has a _layout file so it becomes the new target for hoisting routes.\n */\n if (directory.layout) {\n const previousLayout = layout;\n layout = getMostSpecific(directory.layout);\n\n // Add the new layout as a child of its parent\n if (previousLayout) {\n previousLayout.children.push(layout);\n }\n\n if (options.internal_stripLoadRoute) {\n delete (layout as any).loadRoute;\n }\n\n // `route` is the absolute pathname. We need to make this relative to the last _layout\n const newRoute = layout.route.replace(pathToRemove, '');\n pathToRemove = layout.route ? `${layout.route}/` : '';\n\n // Now update this layout with the new relative route and dynamic conventions\n layout.route = newRoute;\n layout.dynamic = generateDynamic(layout.contextKey.slice(0));\n }\n\n // This should never occur as there will always be a root layout, but it makes the type system happy\n if (!layout) throw new Error('Expo Router Internal Error: No nearest layout');\n\n for (const routes of directory.files.values()) {\n const routeNode = getMostSpecific(routes);\n\n // `route` is the absolute pathname. We need to make this relative to the nearest layout\n routeNode.route = routeNode.route.replace(pathToRemove, '');\n routeNode.dynamic = generateDynamic(routeNode.route);\n\n if (options.internal_stripLoadRoute) {\n delete (routeNode as any).loadRoute;\n }\n\n layout.children.push(routeNode);\n }\n\n // Recursively flatten the subdirectories\n for (const child of directory.subdirectories.values()) {\n flattenDirectoryTreeToRoutes(child, options, layout, pathToRemove);\n }\n\n return layout;\n}\n\nfunction getFileMeta(key: string, options: Options) {\n // Remove the leading `./`\n key = key.replace(/^\\.\\//, '');\n\n const parts = key.split('/');\n let route = removeSupportedExtensions(key);\n const filename = parts[parts.length - 1];\n const [filenameWithoutExtensions, platformExtension] =\n removeSupportedExtensions(filename).split('.');\n const isLayout = filenameWithoutExtensions === '_layout';\n const isApi = filename.match(/\\+api\\.(\\w+\\.)?[jt]sx?$/);\n\n if (filenameWithoutExtensions.startsWith('(') && filenameWithoutExtensions.endsWith(')')) {\n throw new Error(`Invalid route ./${key}. Routes cannot end with '(group)' syntax`);\n }\n\n // Nested routes cannot start with the '+' character, except for the '+not-found' route\n if (!isApi && filename.startsWith('+') && filenameWithoutExtensions !== '+not-found') {\n const renamedRoute = [...parts.slice(0, -1), filename.slice(1)].join('/');\n throw new Error(\n `Invalid route ./${key}. Route nodes cannot start with the '+' character. \"Please rename to ${renamedRoute}\"`\n );\n }\n let specificity = 0;\n\n const hasPlatformExtension = validPlatforms.has(platformExtension);\n const usePlatformRoutes = options.platformRoutes ?? true;\n\n if (hasPlatformExtension) {\n if (!usePlatformRoutes) {\n // If the user has disabled platform routes, then we should ignore this file\n specificity = -1;\n } else if (!options.platform) {\n // If we don't have a platform, then we should ignore this file\n // This used by typed routes, sitemap, etc\n specificity = -1;\n } else if (platformExtension === options.platform) {\n // If the platform extension is the same as the options.platform, then it is the most specific\n specificity = 2;\n } else if (platformExtension === 'native' && options.platform !== 'web') {\n // `native` is allow but isn't as specific as the platform\n specificity = 1;\n } else if (platformExtension !== options.platform) {\n // Somehow we have a platform extension that doesn't match the options.platform and it isn't native\n // This is an invalid file and we will ignore it\n specificity = -1;\n }\n\n if (isApi && specificity !== 0) {\n throw new Error(\n `Api routes cannot have platform extensions. Please remove '.${platformExtension}' from './${key}'`\n );\n }\n\n route = route.replace(new RegExp(`.${platformExtension}$`), '');\n }\n\n return {\n route,\n specificity,\n isLayout,\n isApi,\n };\n}\n\nexport function getIgnoreList(options?: Options) {\n const ignore: RegExp[] = [/^\\.\\/\\+html\\.[tj]sx?$/, ...(options?.ignore ?? [])];\n if (options?.preserveApiRoutes !== true) {\n ignore.push(/\\+api\\.[tj]sx?$/);\n }\n return ignore;\n}\n\n/**\n * Generates a set of strings which have the router array syntax extrapolated.\n *\n * /(a,b)/(c,d)/e.tsx => new Set(['a/c/e.tsx', 'a/d/e.tsx', 'b/c/e.tsx', 'b/d/e.tsx'])\n */\nexport function extrapolateGroups(key: string, keys: Set<string> = new Set()): Set<string> {\n const match = matchArrayGroupName(key);\n\n if (!match) {\n keys.add(key);\n return keys;\n }\n const groups = match.split(',');\n const groupsSet = new Set(groups);\n\n if (groupsSet.size !== groups.length) {\n throw new Error(`Array syntax cannot contain duplicate group name \"${groups}\" in \"${key}\".`);\n }\n\n if (groups.length === 1) {\n keys.add(key);\n return keys;\n }\n\n for (const group of groups) {\n extrapolateGroups(key.replace(match, group.trim()), keys);\n }\n\n return keys;\n}\n\nexport function generateDynamic(path: string): DynamicConvention[] | null {\n const dynamic = path\n .split('/')\n .map((part): DynamicConvention | null => {\n if (part === '+not-found') {\n return {\n name: '+not-found',\n deep: true,\n notFound: true,\n };\n }\n\n const deepDynamicName = matchDeepDynamicRouteName(part);\n const dynamicName = deepDynamicName ?? matchDynamicName(part);\n\n if (!dynamicName) return null;\n return { name: dynamicName, deep: !!deepDynamicName };\n })\n .filter((part): part is DynamicConvention => !!part);\n\n return dynamic.length === 0 ? null : dynamic;\n}\n\nfunction appendSitemapRoute(directory: DirectoryNode, options: Options) {\n if (!directory.files.has('_sitemap') && options.getSystemRoute) {\n directory.files.set('_sitemap', [\n options.getSystemRoute({\n type: 'route',\n route: '_sitemap',\n }),\n ]);\n }\n}\n\nfunction appendNotFoundRoute(directory: DirectoryNode, options: Options) {\n if (!directory.files.has('+not-found') && options.getSystemRoute) {\n directory.files.set('+not-found', [\n options.getSystemRoute({\n type: 'route',\n route: '+not-found',\n }),\n ]);\n }\n}\n\nfunction getLayoutNode(node: RouteNode, options: Options) {\n /**\n * A file called `(a,b)/(c)/_layout.tsx` will generate two _layout routes: `(a)/(c)/_layout` and `(b)/(c)/_layout`.\n * Each of these layouts will have a different anchor based upon the first group name.\n */\n // We may strip loadRoute during testing\n const groupName = matchLastGroupName(node.route);\n const childMatchingGroup = node.children.find((child) => {\n return child.route.replace(/\\/index$/, '') === groupName;\n });\n let anchor = childMatchingGroup?.route;\n const loaded = node.loadRoute();\n if (loaded?.unstable_settings) {\n try {\n // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.\n anchor =\n loaded.unstable_settings.anchor ?? loaded.unstable_settings.initialRouteName ?? anchor;\n } catch (error: any) {\n if (error instanceof Error) {\n if (!error.message.match(/You cannot dot into a client module/)) {\n throw error;\n }\n }\n }\n\n if (groupName) {\n // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.\n const groupSpecificInitialRouteName =\n loaded.unstable_settings?.[groupName]?.anchor ??\n loaded.unstable_settings?.[groupName]?.initialRouteName;\n\n anchor = groupSpecificInitialRouteName ?? anchor;\n }\n }\n\n return {\n ...node,\n route: node.route.replace(/\\/?_layout$/, ''),\n children: [], // Each layout should have its own children\n initialRouteName: anchor,\n };\n}\n\nfunction crawlAndAppendInitialRoutesAndEntryFiles(\n node: RouteNode,\n options: Options,\n entryPoints: string[] = []\n) {\n if (node.type === 'route') {\n node.entryPoints = [...new Set([...entryPoints, node.contextKey])];\n } else if (node.type === 'layout') {\n if (!node.children) {\n throw new Error(`Layout \"${node.contextKey}\" does not contain any child routes`);\n }\n\n // Every node below this layout will have it as an entryPoint\n entryPoints = [...entryPoints, node.contextKey];\n\n /**\n * Calculate the initialRouteNode\n *\n * A file called `(a,b)/(c)/_layout.tsx` will generate two _layout routes: `(a)/(c)/_layout` and `(b)/(c)/_layout`.\n * Each of these layouts will have a different anchor based upon the first group.\n */\n const groupName = matchGroupName(node.route);\n const childMatchingGroup = node.children.find((child) => {\n return child.route.replace(/\\/index$/, '') === groupName;\n });\n let anchor = childMatchingGroup?.route;\n // We may strip loadRoute during testing\n if (!options.internal_stripLoadRoute) {\n const loaded = node.loadRoute();\n if (loaded?.unstable_settings) {\n try {\n // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.\n anchor =\n loaded.unstable_settings.anchor ?? loaded.unstable_settings.initialRouteName ?? anchor;\n } catch (error: any) {\n if (error instanceof Error) {\n if (!error.message.match(/You cannot dot into a client module/)) {\n throw error;\n }\n }\n }\n\n if (groupName) {\n // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.\n const groupSpecificInitialRouteName =\n loaded.unstable_settings?.[groupName]?.anchor ??\n loaded.unstable_settings?.[groupName]?.initialRouteName;\n\n anchor = groupSpecificInitialRouteName ?? anchor;\n }\n }\n }\n\n if (anchor) {\n const anchorRoute = node.children.find((child) => child.route === anchor);\n if (!anchorRoute) {\n const validAnchorRoutes = node.children\n .filter((child) => !child.generated)\n .map((child) => `'${child.route}'`)\n .join(', ');\n\n if (groupName) {\n throw new Error(\n `Layout ${node.contextKey} has invalid anchor '${anchor}' for group '(${groupName})'. Valid options are: ${validAnchorRoutes}`\n );\n } else {\n throw new Error(\n `Layout ${node.contextKey} has invalid anchor '${anchor}'. Valid options are: ${validAnchorRoutes}`\n );\n }\n }\n\n // Navigators can add initialsRoutes into the history, so they need to be to be included in the entryPoints\n node.initialRouteName = anchor;\n entryPoints.push(anchorRoute.contextKey);\n }\n\n for (const child of node.children) {\n crawlAndAppendInitialRoutesAndEntryFiles(child, options, entryPoints);\n }\n }\n}\n\nfunction getMostSpecific(routes: RouteNode[]) {\n const route = routes[routes.length - 1];\n\n if (!routes[0]) {\n throw new Error(\n `The file ${route.contextKey} does not have a fallback sibling file without a platform extension.`\n );\n }\n\n // This works even tho routes is holey array (e.g it might have index 0 and 2 but not 1)\n // `.length` includes the holes in its count\n return routes[routes.length - 1];\n}\n"]}
@@ -20,7 +20,7 @@ export type LinkToOptions = {
20
20
  */
21
21
  relativeToDirectory?: boolean;
22
22
  /**
23
- *
23
+ * Include the anchor when navigating to a new navigator
24
24
  */
25
25
  withAnchor?: boolean;
26
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"routing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CAAC;QAElB;;;;;;;;;;;;;WAaG;QACH,IAAI,eAAe,CAAC,IAAI,KAAK,OAAO,EAAE;YACpC,WAAW,CAAC,MAAM,CAAC,iBAAiB,GAAG,GAAG,WAAW,CAAC,IAAI,IAAI,IAAA,mBAAM,GAAE,EAAE,CAAC,CAAC,yJAAyJ;SACpO;KACF;IAED,IAAI,eAAe,CAAC,IAAI,KAAK,UAAU,EAAE;QACvC,IAAI,GAAG,SAAS,CAAC;KAClB;IAED,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,eAAe,CAAC,IAAI,KAAK,KAAK,IAAI,eAAe,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE;QAC/F,IAAI,GAAG,SAAS,CAAC;KAClB;IAED,IAAI,UAAU,KAAK,SAAS,EAAE;QAC5B,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE;YAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;gBACzC,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;aAC1F;SACF;QACD;;;;;;;;WAQG;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC;KAC1C;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,eAAe,CAAC,GAAG;QAC3B,OAAO,EAAE;YACP,wBAAwB;YACxB,IAAI,EAAE,WAAW,CAAC,MAAM;YACxB,MAAM,EAAE,WAAW,CAAC,MAAM;SAC3B;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { StackActions, type NavigationState, PartialRoute } from '@react-navigation/native';\nimport { IS_DOM } from 'expo/dom';\nimport * as Linking from 'expo-linking';\nimport { nanoid } from 'nanoid/non-secure';\nimport { Platform } from 'react-native';\n\nimport { type RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../link/useDomComponentNavigation';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload(this: RouterStore) {\n // TODO(EvanBacon): add `reload` support.\n throw new Error('The reload method is not implemented in the client-side router yet.');\n}\n\nexport function push(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(this: RouterStore, count?: number) {\n if (emitDomDismiss(count)) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.pop(count));\n}\n\nexport function dismissTo(this: RouterStore, href: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll(this: RouterStore) {\n if (emitDomDismissAll()) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = this.rootState;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n this: RouterStore,\n params: Record<string, string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n *\n */\n withAnchor?: boolean;\n};\n\nexport function linkTo(this: RouterStore, href: string, options: LinkToOptions = {}) {\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(\n getNavigateAction(state, rootState, options.event, options.withAnchor)\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n // Expo Router uses only three actions, but these don't directly translate to all navigator actions\n if (type === 'PUSH') {\n // Only stack navigators have a push action, and even then we want to use NAVIGATE (see below)\n type = 'NAVIGATE';\n\n /*\n * The StackAction.PUSH does not work correctly with Expo Router.\n *\n * Expo Router provides a getId() function for every route, altering how React Navigation handles stack routing.\n * Ordinarily, PUSH always adds a new screen to the stack. However, with getId() present, it navigates to the screen with the matching ID instead (by moving the screen to the top of the stack)\n * When you try and push to a screen with the same ID, no navigation will occur\n * Refer to: https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L279-L290\n *\n * Expo Router needs to retain the default behavior of PUSH, consistently adding new screens to the stack, even if their IDs are identical.\n *\n * To resolve this issue, we switch to using a NAVIGATE action with a new key. In the navigate action, screens are matched by either key or getId() function.\n * By generating a unique new key, we ensure that the screen is always pushed onto the stack.\n *\n */\n if (navigationState.type === 'stack') {\n rootPayload.params.__EXPO_ROUTER_key = `${rootPayload.name}-${nanoid()}`; // @see https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L406-L407\n }\n }\n\n if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n }\n\n if (type === 'REPLACE' && (navigationState.type === 'tab' || navigationState.type === 'drawer')) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA4F;AAC5F,kCAAkC;AAClC,sDAAwC;AACxC,kDAA2C;AAC3C,+CAAwC;AAIxC,uCAA0E;AAC1E,iFAM2C;AAC3C,0CAA+C;AAE/C,sCAAoD;AAEpD,SAAS,aAAa,CAAC,KAAkB;IACvC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE;QAClC,MAAM,IAAI,KAAK,CACb,gKAAgK,CACjK,CAAC;KACH;AACH,CAAC;AAID,SAAgB,QAAQ,CAAoB,GAAS,EAAE,OAA2B;IAChF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;AAC1E,CAAC;AAFD,4BAEC;AAED,SAAgB,MAAM;IACpB,yCAAyC;IACzC,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;AACzF,CAAC;AAHD,wBAGC;AAED,SAAgB,IAAI,CAAoB,GAAS,EAAE,OAA2B;IAC5E,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AACtE,CAAC;AAFD,oBAEC;AAED,SAAgB,OAAO,CAAoB,KAAc;IACvD,IAAI,IAAA,0CAAc,EAAC,KAAK,CAAC,EAAE;QACzB,OAAO;KACR;IACD,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,qBAAY,CAAC,GAAG,CAAC,KAAK,CAAC,C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AgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;KAC9F;IAED,mGAAmG;IACnG,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,8FAA8F;QAC9F,IAAI,GAAG,UAAU,CAAC;QAElB;;;;;;;;;;;;;WAaG;QACH,IAAI,eAAe,CAAC,IAAI,KAAK,OAAO,EAAE;YACpC,WAAW,CAAC,MAAM,CAAC,iBAAiB,GAAG,GAAG,WAAW,CAAC,IAAI,IAAI,IAAA,mBAAM,GAAE,EAAE,CAAC,CAAC,yJAAyJ;SACpO;KACF;IAED,IAAI,eAAe,CAAC,IAAI,KAAK,UAAU,EAAE;QACvC,IAAI,GAAG,SAAS,CAAC;KAClB;IAED,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,eAAe,CAAC,IAAI,KAAK,KAAK,IAAI,eAAe,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE;QAC/F,IAAI,GAAG,SAAS,CAAC;KAClB;IAED,IAAI,UAAU,KAAK,SAAS,EAAE;QAC5B,IAAI,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE;YAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;gBACzC,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;aAC1F;SACF;QACD;;;;;;;;WAQG;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC;KAC1C;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,eAAe,CAAC,GAAG;QAC3B,OAAO,EAAE;YACP,wBAAwB;YACxB,IAAI,EAAE,WAAW,CAAC,MAAM;YACxB,MAAM,EAAE,WAAW,CAAC,MAAM;SAC3B;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { StackActions, type NavigationState, PartialRoute } from '@react-navigation/native';\nimport { IS_DOM } from 'expo/dom';\nimport * as Linking from 'expo-linking';\nimport { nanoid } from 'nanoid/non-secure';\nimport { Platform } from 'react-native';\n\nimport { type RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport {\n emitDomDismiss,\n emitDomDismissAll,\n emitDomGoBack,\n emitDomLinkEvent,\n emitDomSetParams,\n} from '../link/useDomComponentNavigation';\nimport { matchDynamicName } from '../matchers';\nimport { Href } from '../types';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction assertIsReady(store: RouterStore) {\n if (!store.navigationRef.isReady()) {\n throw new Error(\n 'Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render.'\n );\n }\n}\n\nexport type NavigationOptions = Omit<LinkToOptions, 'event'>;\n\nexport function navigate(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'NAVIGATE' });\n}\n\nexport function reload(this: RouterStore) {\n // TODO(EvanBacon): add `reload` support.\n throw new Error('The reload method is not implemented in the client-side router yet.');\n}\n\nexport function push(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'PUSH' });\n}\n\nexport function dismiss(this: RouterStore, count?: number) {\n if (emitDomDismiss(count)) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.pop(count));\n}\n\nexport function dismissTo(this: RouterStore, href: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(href), { ...options, event: 'POP_TO' });\n}\n\nexport function replace(this: RouterStore, url: Href, options?: NavigationOptions) {\n return this.linkTo(resolveHref(url), { ...options, event: 'REPLACE' });\n}\n\nexport function dismissAll(this: RouterStore) {\n if (emitDomDismissAll()) {\n return;\n }\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n if (emitDomGoBack()) {\n return;\n }\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canGoBack imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n // Return a default value here if the navigation hasn't mounted yet.\n // This can happen if the user calls `canGoBack` from the Root Layout route\n // before mounting a navigator. This behavior exists due to React Navigation being dynamically\n // constructed at runtime. We can get rid of this in the future if we use\n // the static configuration internally.\n if (!this.navigationRef.isReady()) {\n return false;\n }\n return this.navigationRef?.current?.canGoBack() ?? false;\n}\n\nexport function canDismiss(this: RouterStore): boolean {\n if (IS_DOM) {\n throw new Error(\n 'canDismiss imperative method is not supported. Pass the property to the DOM component instead.'\n );\n }\n let state = this.rootState;\n\n // Keep traversing down the state tree until we find a stack navigator that we can pop\n while (state) {\n if (state.type === 'stack' && state.routes.length > 1) {\n return true;\n }\n if (state.index === undefined) return false;\n\n state = state.routes?.[state.index]?.state as any;\n }\n\n return false;\n}\n\nexport function setParams(\n this: RouterStore,\n params: Record<string, string | number | (string | number)[]> = {}\n) {\n if (emitDomSetParams(params)) {\n return;\n }\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport type LinkToOptions = {\n event?: string;\n\n /**\n * Relative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.\n * @see: [MDN's documentation on Resolving relative references to a URL](https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references).\n */\n relativeToDirectory?: boolean;\n\n /**\n * Include the anchor when navigating to a new navigator\n */\n withAnchor?: boolean;\n};\n\nexport function linkTo(this: RouterStore, href: string, options: LinkToOptions = {}) {\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n\n if (shouldLinkExternally(href)) {\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}`;\n }\n\n Linking.openURL(href);\n return;\n }\n\n assertIsReady(this);\n const navigationRef = this.navigationRef.current;\n\n if (navigationRef == null) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (!this.linking) {\n throw new Error('Attempted to link to route when no routes are present');\n }\n\n if (href === '..' || href === '../') {\n navigationRef.goBack();\n return;\n }\n\n const rootState = navigationRef.getRootState();\n\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n\n const state = this.linking.getStateFromPath!(href, this.linking.config);\n\n if (!state || state.routes.length === 0) {\n console.error('Could not generate a valid navigation state for the given path: ' + href);\n return;\n }\n\n return navigationRef.dispatch(\n getNavigateAction(state, rootState, options.event, options.withAnchor)\n );\n}\n\nfunction getNavigateAction(\n actionState: ResultState,\n navigationState: NavigationState,\n type = 'NAVIGATE',\n withAnchor?: boolean\n) {\n /**\n * We need to find the deepest navigator where the action and current state diverge, If they do not diverge, the\n * lowest navigator is the target.\n *\n * By default React Navigation will target the current navigator, but this doesn't work for all actions\n * For example:\n * - /deeply/nested/route -> /top-level-route the target needs to be the top-level navigator\n * - /stack/nestedStack/page -> /stack1/nestedStack/other-page needs to target the nestedStack navigator\n *\n * This matching needs to done by comparing the route names and the dynamic path, for example\n * - /1/page -> /2/anotherPage needs to target the /[id] navigator\n *\n * Other parameters such as search params and hash are not evaluated.\n */\n let actionStateRoute: PartialRoute<any> | undefined;\n\n // Traverse the state tree comparing the current state and the action state until we find where they diverge\n while (actionState && navigationState) {\n const stateRoute = navigationState.routes[navigationState.index];\n\n actionStateRoute = actionState.routes[actionState.routes.length - 1];\n\n const childState: any = actionStateRoute.state;\n const nextNavigationState = stateRoute.state;\n\n const dynamicName = matchDynamicName(actionStateRoute.name);\n\n const didActionAndCurrentStateDiverge =\n actionStateRoute.name !== stateRoute.name ||\n !childState ||\n !nextNavigationState ||\n (dynamicName && actionStateRoute.params?.[dynamicName] !== stateRoute.params?.[dynamicName]);\n\n if (didActionAndCurrentStateDiverge) {\n break;\n }\n\n actionState = childState;\n navigationState = nextNavigationState as NavigationState;\n }\n\n /*\n * We found the target navigator, but the payload is in the incorrect format\n * We need to convert the action state to a payload that can be dispatched\n */\n const rootPayload: Record<string, any> = { params: {} };\n let payload = rootPayload;\n let params = payload.params;\n\n // The root level of payload is a bit weird, its params are in the child object\n while (actionStateRoute) {\n Object.assign(params, { ...payload.params, ...actionStateRoute.params });\n // Assign the screen name to the payload\n payload.screen = actionStateRoute.name;\n // Merge the params, ensuring that we create a new object\n payload.params = { ...params };\n\n // Params don't include the screen, thats a separate attribute\n delete payload.params['screen'];\n\n // Continue down the payload tree\n // Initially these values are separate, but React Nav merges them after the first layer\n payload = payload.params;\n params = payload;\n\n actionStateRoute = actionStateRoute.state?.routes[actionStateRoute.state?.routes.length - 1];\n }\n\n // Expo Router uses only three actions, but these don't directly translate to all navigator actions\n if (type === 'PUSH') {\n // Only stack navigators have a push action, and even then we want to use NAVIGATE (see below)\n type = 'NAVIGATE';\n\n /*\n * The StackAction.PUSH does not work correctly with Expo Router.\n *\n * Expo Router provides a getId() function for every route, altering how React Navigation handles stack routing.\n * Ordinarily, PUSH always adds a new screen to the stack. However, with getId() present, it navigates to the screen with the matching ID instead (by moving the screen to the top of the stack)\n * When you try and push to a screen with the same ID, no navigation will occur\n * Refer to: https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L279-L290\n *\n * Expo Router needs to retain the default behavior of PUSH, consistently adding new screens to the stack, even if their IDs are identical.\n *\n * To resolve this issue, we switch to using a NAVIGATE action with a new key. In the navigate action, screens are matched by either key or getId() function.\n * By generating a unique new key, we ensure that the screen is always pushed onto the stack.\n *\n */\n if (navigationState.type === 'stack') {\n rootPayload.params.__EXPO_ROUTER_key = `${rootPayload.name}-${nanoid()}`; // @see https://github.com/react-navigation/react-navigation/blob/13d4aa270b301faf07960b4cd861ffc91e9b2c46/packages/routers/src/StackRouter.tsx#L406-L407\n }\n }\n\n if (navigationState.type === 'expo-tab') {\n type = 'JUMP_TO';\n }\n\n if (type === 'REPLACE' && (navigationState.type === 'tab' || navigationState.type === 'drawer')) {\n type = 'JUMP_TO';\n }\n\n if (withAnchor !== undefined) {\n if (rootPayload.params.initial) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`The parameter 'initial' is a reserved parameter name in React Navigation`);\n }\n }\n /*\n * The logic for initial can seen backwards depending on your perspective\n * True: The initialRouteName is not loaded. The incoming screen is the initial screen (default)\n * False: The initialRouteName is loaded. THe incoming screen is placed after the initialRouteName\n *\n * withAnchor flips the perspective.\n * True: You want the initialRouteName to load.\n * False: You do not want the initialRouteName to load.\n */\n rootPayload.params.initial = !withAnchor;\n }\n\n return {\n type,\n target: navigationState.key,\n payload: {\n // key: rootPayload.key,\n name: rootPayload.screen,\n params: rootPayload.params,\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAoBxC,wBAAgB,aAAa,IAAI,UAAU,CACzC,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CACtE,CAgBA;AAID,wBAAgB,UAAU,IAAI,MAAM,CAKnC;AAgBD,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,YAAY,oBACnC,MAAM,KAAK,IAAI,gBAiCxC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AASxC,wBAAgB,aAAa,IAAI,UAAU,CACzC,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CACtE,CA0BA;AAID,wBAAgB,UAAU,IAAI,MAAM,CAKnC;AAgBD,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,YAAY,oBACnC,MAAM,KAAK,IAAI,gBAiCxC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
@@ -31,31 +31,30 @@ const getPathFromState_1 = require("../fork/getPathFromState");
31
31
  Object.defineProperty(exports, "getPathFromState", { enumerable: true, get: function () { return getPathFromState_1.getPathFromState; } });
32
32
  const getStateFromPath_1 = require("../fork/getStateFromPath");
33
33
  Object.defineProperty(exports, "getStateFromPath", { enumerable: true, get: function () { return getStateFromPath_1.getStateFromPath; } });
34
+ const useLinking_1 = require("../fork/useLinking");
34
35
  const isExpoGo = typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo;
35
- function getInitialURLWithTimeout() {
36
- return Promise.race([
37
- Linking.getInitialURL(),
38
- new Promise((resolve) =>
39
- // Timeout in 150ms if `getInitialState` doesn't resolve
40
- // Workaround for https://github.com/facebook/react-native/issues/25675
41
- setTimeout(() => resolve(null), 150)),
42
- ]);
43
- }
44
36
  // A custom getInitialURL is used on native to ensure the app always starts at
45
37
  // the root path if it's launched from something other than a deep link.
46
38
  // This helps keep the native functionality working like the web functionality.
47
39
  // For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`
48
40
  // then `/index` would be used on web and `/settings` would be used on native.
49
41
  function getInitialURL() {
50
- if (react_native_1.Platform.OS === 'web') {
51
- if (typeof window === 'undefined') {
52
- return '';
53
- }
54
- else if (window.location?.href) {
55
- return window.location.href;
56
- }
42
+ if (typeof window === 'undefined') {
43
+ return '';
44
+ }
45
+ if (react_native_1.Platform.OS === 'web' && window.location?.href) {
46
+ return window.location.href;
47
+ }
48
+ if (react_native_1.Platform.OS === 'ios') {
49
+ // Use the new Expo API for iOS. This has better support for App Clips and handoff.
50
+ const url = Linking.getLinkingURL();
51
+ return (parseExpoGoUrlFromListener(url) ??
52
+ // The path will be nullish in bare apps when the app is launched from the home screen.
53
+ // TODO(EvanBacon): define some policy around notifications.
54
+ getRootURL());
57
55
  }
58
- return getInitialURLWithTimeout().then((url) => parseExpoGoUrlFromListener(url) ??
56
+ // TODO: Figure out if expo-linking on Android has full interop with the React Native implementation.
57
+ return Promise.resolve((0, useLinking_1.getInitialURLWithTimeout)()).then((url) => parseExpoGoUrlFromListener(url) ??
59
58
  // The path will be nullish in bare apps when the app is launched from the home screen.
60
59
  // TODO(EvanBacon): define some policy around notifications.
61
60
  getRootURL());
@@ -1 +1 @@
1
- {"version":3,"file":"linking.js","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwC;AACxC,+CAAwC;AAExC,mEAA8E;AAC9E,+DAA4D;AAqGjC,iGArGlB,mCAAgB,OAqGkB;AApG3C,+DAA4D;AAoGnD,iGApGA,mCAAgB,OAoGA;AAjGzB,MAAM,QAAQ,GAAG,OAAO,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;AAEjF,SAAS,wBAAwB;IAC/B,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,OAAO,CAAC,aAAa,EAAE;QACvB,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAC5B,wDAAwD;QACxD,uEAAuE;QACvE,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CACrC;KACF,CAAC,CAAC;AACL,CAAC;AAED,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,8GAA8G;AAC9G,8EAA8E;AAC9E,SAAgB,aAAa;IAG3B,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;Q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E,EAAE;gBAC3B,GAAG,GAAG,0BAA0B,CAAC,GAAG,CAAC,CAAC;gBAEtC,IAAI,GAAG,IAAI,aAAa,EAAE,kBAAkB,EAAE;oBAC5C,GAAG,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC7E;gBAED,QAAQ,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC;SACH;aAAM;YACL,QAAQ,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;gBAC3B,IAAI,GAAG,IAAI,aAAa,EAAE,kBAAkB,EAAE;oBAC5C,GAAG,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC7E;gBACD,QAAQ,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC;SACH;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAE/D,OAAO,GAAG,EAAE;YACV,2FAA2F;YAC3F,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;YACzB,kBAAkB,EAAE,EAAE,CAAC;QACzB,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAlCD,4CAkCC","sourcesContent":["import { LinkingOptions } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { parsePathAndParamsFromExpoGoLink } from '../fork/extractPathFromURL';\nimport { getPathFromState } from '../fork/getPathFromState';\nimport { getStateFromPath } from '../fork/getStateFromPath';\nimport { NativeIntent } from '../types';\n\nconst isExpoGo = typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo;\n\nfunction getInitialURLWithTimeout(): Promise<string | null> {\n return Promise.race([\n Linking.getInitialURL(),\n new Promise<null>((resolve) =>\n // Timeout in 150ms if `getInitialState` doesn't resolve\n // Workaround for https://github.com/facebook/react-native/issues/25675\n setTimeout(() => resolve(null), 150)\n ),\n ]);\n}\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 function getInitialURL(): ReturnType<\n NonNullable<LinkingOptions<Record<string, unknown>>['getInitialURL']>\n> {\n if (Platform.OS === 'web') {\n if (typeof window === 'undefined') {\n return '';\n } else if (window.location?.href) {\n return window.location.href;\n }\n }\n\n return getInitialURLWithTimeout().then(\n (url) =>\n parseExpoGoUrlFromListener(url) ??\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 getRootURL()\n );\n}\n\nlet _rootURL: string | undefined;\n\nexport function getRootURL(): string {\n if (_rootURL === undefined) {\n _rootURL = Linking.createURL('/');\n }\n return _rootURL;\n}\n\n// Expo Go is weird and requires the root path to be `/--/`\nfunction parseExpoGoUrlFromListener<T extends string | null>(url: T): T {\n if (!url || !isExpoGo) {\n return url;\n }\n const { pathname, queryString } = parsePathAndParamsFromExpoGoLink(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 (!pathname || pathname === '/') {\n return (getRootURL() + queryString) as T;\n }\n return url;\n}\n\nexport function addEventListener(nativeLinking?: NativeIntent) {\n return (listener: (url: string) => void) => {\n let callback: (({ url }: { url: string }) => void) | undefined;\n\n const legacySubscription = nativeLinking?.legacy_subscribe?.(listener);\n\n if (isExpoGo) {\n // This extra work is only done in the Expo Go app.\n callback = async ({ url }) => {\n url = parseExpoGoUrlFromListener(url);\n\n if (url && nativeLinking?.redirectSystemPath) {\n url = await nativeLinking.redirectSystemPath({ path: url, initial: false });\n }\n\n listener(url);\n };\n } else {\n callback = async ({ url }) => {\n if (url && nativeLinking?.redirectSystemPath) {\n url = await nativeLinking.redirectSystemPath({ path: url, initial: false });\n }\n listener(url);\n };\n }\n\n const subscription = Linking.addEventListener('url', callback);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n subscription?.remove?.();\n legacySubscription?.();\n };\n };\n}\n\nexport { getStateFromPath, getPathFromState };\n"]}
1
+ {"version":3,"file":"linking.js","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwC;AACxC,+CAAwC;AAExC,mEAA8E;AAC9E,+DAA4D;AAqGjC,iGArGlB,mCAAgB,OAqGkB;AApG3C,+DAA4D;AAoGnD,iGApGA,mCAAgB,OAoGA;AAnGzB,mDAA8D;AAG9D,MAAM,QAAQ,GAAG,OAAO,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;AAEjF,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,8GAA8G;AAC9G,8EAA8E;AAC9E,SAAgB,aAAa;IAG3B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,EAAE,CAAC;KACX;IACD,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE;QAClD,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;KAC7B;IACD,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,mFAAmF;QACnF,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QACpC,OAAO,CACL,0BAA0B,CAAC,GAAG,CAAC;YAC/B,uFAAuF;YACvF,4DAA4D;YAC5D,UAAU,EAAE,CACb,CAAC;KACH;IAED,qGAAqG;IACrG,OAAO,OAAO,CAAC,OAAO,CAAC,IAAA,qCAAwB,GAAE,CAAC,CAAC,IAAI,CAC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,CAAC,CAAC;iBAC7E;gBAED,QAAQ,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC;SACH;aAAM;YACL,QAAQ,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;gBAC3B,IAAI,GAAG,IAAI,aAAa,EAAE,kBAAkB,EAAE;oBAC5C,GAAG,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC7E;gBACD,QAAQ,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC;SACH;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAE/D,OAAO,GAAG,EAAE;YACV,2FAA2F;YAC3F,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;YACzB,kBAAkB,EAAE,EAAE,CAAC;QACzB,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAlCD,4CAkCC","sourcesContent":["import { LinkingOptions } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { parsePathAndParamsFromExpoGoLink } from '../fork/extractPathFromURL';\nimport { getPathFromState } from '../fork/getPathFromState';\nimport { getStateFromPath } from '../fork/getStateFromPath';\nimport { getInitialURLWithTimeout } from '../fork/useLinking';\nimport { NativeIntent } from '../types';\n\nconst isExpoGo = typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo;\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 function getInitialURL(): ReturnType<\n NonNullable<LinkingOptions<Record<string, unknown>>['getInitialURL']>\n> {\n if (typeof window === 'undefined') {\n return '';\n }\n if (Platform.OS === 'web' && window.location?.href) {\n return window.location.href;\n }\n if (Platform.OS === 'ios') {\n // Use the new Expo API for iOS. This has better support for App Clips and handoff.\n const url = Linking.getLinkingURL();\n return (\n parseExpoGoUrlFromListener(url) ??\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 getRootURL()\n );\n }\n\n // TODO: Figure out if expo-linking on Android has full interop with the React Native implementation.\n return Promise.resolve(getInitialURLWithTimeout()).then(\n (url) =>\n parseExpoGoUrlFromListener(url) ??\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 getRootURL()\n );\n}\n\nlet _rootURL: string | undefined;\n\nexport function getRootURL(): string {\n if (_rootURL === undefined) {\n _rootURL = Linking.createURL('/');\n }\n return _rootURL;\n}\n\n// Expo Go is weird and requires the root path to be `/--/`\nfunction parseExpoGoUrlFromListener<T extends string | null>(url: T): T {\n if (!url || !isExpoGo) {\n return url;\n }\n const { pathname, queryString } = parsePathAndParamsFromExpoGoLink(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 (!pathname || pathname === '/') {\n return (getRootURL() + queryString) as T;\n }\n return url;\n}\n\nexport function addEventListener(nativeLinking?: NativeIntent) {\n return (listener: (url: string) => void) => {\n let callback: (({ url }: { url: string }) => void) | undefined;\n\n const legacySubscription = nativeLinking?.legacy_subscribe?.(listener);\n\n if (isExpoGo) {\n // This extra work is only done in the Expo Go app.\n callback = async ({ url }) => {\n url = parseExpoGoUrlFromListener(url);\n\n if (url && nativeLinking?.redirectSystemPath) {\n url = await nativeLinking.redirectSystemPath({ path: url, initial: false });\n }\n\n listener(url);\n };\n } else {\n callback = async ({ url }) => {\n if (url && nativeLinking?.redirectSystemPath) {\n url = await nativeLinking.redirectSystemPath({ path: url, initial: false });\n }\n listener(url);\n };\n }\n\n const subscription = Linking.addEventListener('url', callback);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n subscription?.remove?.();\n legacySubscription?.();\n };\n };\n}\n\nexport { getStateFromPath, getPathFromState };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useLinkToPathProps.d.ts","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA8BxD,KAAK,yBAAyB,GAAG,aAAa,GAAG;IAC/C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,yBAAyB;;;sBAG/D,WAAW,iBAAiB,CAAC,GAAG,qBAAqB;EAqB/E;AAED,wBAAgB,sBAAsB,CACpC,KAAK,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,qBAAqB,WAY9D"}
1
+ {"version":3,"file":"useLinkToPathProps.d.ts","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAK/D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA4BxD,KAAK,yBAAyB,GAAG,aAAa,GAAG;IAC/C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,yBAAyB;;;sBAG/D,WAAW,iBAAiB,CAAC,GAAG,qBAAqB;EAqB/E;AAED,wBAAgB,sBAAsB,CACpC,KAAK,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,qBAAqB,WAY9D"}
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shouldHandleMouseEvent = void 0;
4
4
  const react_native_1 = require("react-native");
5
- const router_store_1 = require("../global-state/router-store");
6
- const matchers_1 = require("../matchers");
7
5
  const useDomComponentNavigation_1 = require("./useDomComponentNavigation");
8
6
  const getPathFromState_forks_1 = require("../fork/getPathFromState-forks");
7
+ const router_store_1 = require("../global-state/router-store");
8
+ const matchers_1 = require("../matchers");
9
9
  const url_1 = require("../utils/url");
10
10
  function eventShouldPreventDefault(e) {
11
11
  if (e?.defaultPrevented) {
@@ -1 +1 @@
1
- {"version":3,"file":"useLinkToPathProps.js","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":";;;AACA,+CAA+D;AAE/D,+DAA6D;AAE7D,0CAAyD;AACzD,2EAA+D;AAC/D,2EAA+D;AAC/D,sCAAoD;AAEpD,SAAS,yBAAyB,CAChC,CAAwD;IAExD,IAAI,CAAC,EAAE,gBAAgB,EAAE;QACvB,OAAO,KAAK,CAAC;KACd;IAED;IACE,yBAAyB;IACzB,QAAQ,IAAI,CAAC;QACb,mCAAmC;QACnC,CAAC,CAAC,CAAC,OAAO;QACV,CAAC,CAAC,CAAC,MAAM;QACT,CAAC,CAAC,CAAC,OAAO;QACV,CAAC,CAAC,CAAC,QAAQ;QACX,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,0BAA0B;QAClE,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,0CAA0C;MACzG;QACA,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAMD,SAAwB,kBAAkB,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAA6B;IACxF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,4BAAa,GAAE,CAAC;IAEnC,MAAM,OAAO,GAAG,CAAC,KAA6D,EAAE,EAAE;QAChF,IAAI,sBAAsB,CAAC,KAAK,CAAC,EAAE;YACjC,IAAI,IAAA,4CAAgB,EAAC,IAAI,EAAE,OAAO,CAAC,EAAE;gBACnC,OAAO;aACR;YACD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SACvB;IACH,CAAC,CAAC;IAEF,IAAI,YAAY,GAAG,IAAA,qCAA0B,EAAC,IAAI,CAAC,IAAI,GAAG,CAAC;IAE3D,kCAAkC;IAClC,IAAI,CAAC,IAAA,0BAAoB,EAAC,YAAY,CAAC,EAAE;QACvC,YAAY,GAAG,IAAA,sCAAa,EAAC,YAAY,CAAC,CAAC;KAC5C;IAED,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,MAAe;QACrB,OAAO;KACR,CAAC;AACJ,CAAC;AAxBD,qCAwBC;AAED,SAAgB,sBAAsB,CACpC,KAA6D;IAE7D,IAAI,uBAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,OAAO,CAAC,KAAK,EAAE,gBAAgB,CAAC;KACjC;IAED,IAAI,KAAK,IAAI,yBAAyB,CAAC,KAAK,CAAC,EAAE;QAC7C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAbD,wDAaC","sourcesContent":["import { MouseEvent } from 'react';\nimport { GestureResponderEvent, Platform } from 'react-native';\n\nimport { useExpoRouter } from '../global-state/router-store';\nimport { LinkToOptions } from '../global-state/routing';\nimport { stripGroupSegmentsFromPath } from '../matchers';\nimport { emitDomLinkEvent } from './useDomComponentNavigation';\nimport { appendBaseUrl } from '../fork/getPathFromState-forks';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction eventShouldPreventDefault(\n e: MouseEvent<HTMLAnchorElement> | GestureResponderEvent\n): boolean {\n if (e?.defaultPrevented) {\n return false;\n }\n\n if (\n // Only check MouseEvents\n 'button' in e &&\n // ignore clicks with modifier keys\n !e.metaKey &&\n !e.altKey &&\n !e.ctrlKey &&\n !e.shiftKey &&\n (e.button == null || e.button === 0) && // Only accept left clicks\n [undefined, null, '', 'self'].includes(e.currentTarget.target) // let browser handle \"target=_blank\" etc.\n ) {\n return true;\n }\n\n return false;\n}\n\ntype UseLinkToPathPropsOptions = LinkToOptions & {\n href: string;\n};\n\nexport default function useLinkToPathProps({ href, ...options }: UseLinkToPathPropsOptions) {\n const { linkTo } = useExpoRouter();\n\n const onPress = (event?: MouseEvent<HTMLAnchorElement> | GestureResponderEvent) => {\n if (shouldHandleMouseEvent(event)) {\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n linkTo(href, options);\n }\n };\n\n let strippedHref = stripGroupSegmentsFromPath(href) || '/';\n\n // Append base url only if needed.\n if (!shouldLinkExternally(strippedHref)) {\n strippedHref = appendBaseUrl(strippedHref);\n }\n\n return {\n href: strippedHref,\n role: 'link' as const,\n onPress,\n };\n}\n\nexport function shouldHandleMouseEvent(\n event?: MouseEvent<HTMLAnchorElement> | GestureResponderEvent\n) {\n if (Platform.OS !== 'web') {\n return !event?.defaultPrevented;\n }\n\n if (event && eventShouldPreventDefault(event)) {\n event.preventDefault();\n return true;\n }\n\n return false;\n}\n"]}
1
+ {"version":3,"file":"useLinkToPathProps.js","sourceRoot":"","sources":["../../src/link/useLinkToPathProps.tsx"],"names":[],"mappings":";;;AACA,+CAA+D;AAE/D,2EAA+D;AAC/D,2EAA+D;AAC/D,+DAA6D;AAE7D,0CAAyD;AACzD,sCAAoD;AAEpD,SAAS,yBAAyB,CAChC,CAAwD;IAExD,IAAI,CAAC,EAAE,gBAAgB,EAAE;QACvB,OAAO,KAAK,CAAC;KACd;IAED;IACE,yBAAyB;IACzB,QAAQ,IAAI,CAAC;QACb,mCAAmC;QACnC,CAAC,CAAC,CAAC,OAAO;QACV,CAAC,CAAC,C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,CAAC,EAAE;QAC7C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAbD,wDAaC","sourcesContent":["import { MouseEvent } from 'react';\nimport { GestureResponderEvent, Platform } from 'react-native';\n\nimport { emitDomLinkEvent } from './useDomComponentNavigation';\nimport { appendBaseUrl } from '../fork/getPathFromState-forks';\nimport { useExpoRouter } from '../global-state/router-store';\nimport { LinkToOptions } from '../global-state/routing';\nimport { stripGroupSegmentsFromPath } from '../matchers';\nimport { shouldLinkExternally } from '../utils/url';\n\nfunction eventShouldPreventDefault(\n e: MouseEvent<HTMLAnchorElement> | GestureResponderEvent\n): boolean {\n if (e?.defaultPrevented) {\n return false;\n }\n\n if (\n // Only check MouseEvents\n 'button' in e &&\n // ignore clicks with modifier keys\n !e.metaKey &&\n !e.altKey &&\n !e.ctrlKey &&\n !e.shiftKey &&\n (e.button == null || e.button === 0) && // Only accept left clicks\n [undefined, null, '', 'self'].includes(e.currentTarget.target) // let browser handle \"target=_blank\" etc.\n ) {\n return true;\n }\n\n return false;\n}\n\ntype UseLinkToPathPropsOptions = LinkToOptions & {\n href: string;\n};\n\nexport default function useLinkToPathProps({ href, ...options }: UseLinkToPathPropsOptions) {\n const { linkTo } = useExpoRouter();\n\n const onPress = (event?: MouseEvent<HTMLAnchorElement> | GestureResponderEvent) => {\n if (shouldHandleMouseEvent(event)) {\n if (emitDomLinkEvent(href, options)) {\n return;\n }\n linkTo(href, options);\n }\n };\n\n let strippedHref = stripGroupSegmentsFromPath(href) || '/';\n\n // Append base url only if needed.\n if (!shouldLinkExternally(strippedHref)) {\n strippedHref = appendBaseUrl(strippedHref);\n }\n\n return {\n href: strippedHref,\n role: 'link' as const,\n onPress,\n };\n}\n\nexport function shouldHandleMouseEvent(\n event?: MouseEvent<HTMLAnchorElement> | GestureResponderEvent\n) {\n if (Platform.OS !== 'web') {\n return !event?.defaultPrevented;\n }\n\n if (event && eventShouldPreventDefault(event)) {\n event.preventDefault();\n return true;\n }\n\n return false;\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  {
2
- "platforms": ["ios", "web"],
3
- "ios": {
2
+ "platforms": ["apple", "web"],
3
+ "apple": {
4
4
  "modules": ["ExpoHeadModule"],
5
5
  "appDelegateSubscribers": ["ExpoHeadAppDelegateSubscriber"]
6
6
  }
7
7
  }
8
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-router",
3
- "version": "4.1.0-canary-20250122-166c2cb",
3
+ "version": "4.1.0-canary-20250131-5c4e588",
4
4
  "description": "Expo Router is a file-based router for React Native and web applications.",
5
5
  "author": "650 Industries, Inc.",
6
6
  "license": "MIT",
@@ -75,9 +75,9 @@
75
75
  ],
76
76
  "peerDependencies": {
77
77
  "@react-navigation/drawer": "^7.1.1",
78
- "expo": "53.0.0-canary-20250122-166c2cb",
79
- "expo-constants": "17.0.5-canary-20250122-166c2cb",
80
- "expo-linking": "7.0.5-canary-20250122-166c2cb",
78
+ "expo": "53.0.0-canary-20250131-5c4e588",
79
+ "expo-constants": "17.0.6-canary-20250131-5c4e588",
80
+ "expo-linking": "7.1.0-canary-20250131-5c4e588",
81
81
  "react-native-reanimated": "*",
82
82
  "react-native-safe-area-context": "*",
83
83
  "react-native-screens": "*"
@@ -103,8 +103,8 @@
103
103
  "tsd": "^0.28.1"
104
104
  },
105
105
  "dependencies": {
106
- "@expo/metro-runtime": "4.0.2-canary-20250122-166c2cb",
107
- "@expo/server": "0.5.2-canary-20250122-166c2cb",
106
+ "@expo/metro-runtime": "4.0.2-canary-20250131-5c4e588",
107
+ "@expo/server": "0.5.2-canary-20250131-5c4e588",
108
108
  "@radix-ui/react-slot": "1.0.1",
109
109
  "@react-navigation/bottom-tabs": "^7.2.0",
110
110
  "@react-navigation/native": "^7.0.14",
@@ -115,7 +115,6 @@
115
115
  "react-native-is-edge-to-edge": "^1.1.6",
116
116
  "schema-utils": "^4.0.1",
117
117
  "semver": "~7.6.3",
118
- "server-only": "^0.0.1",
119
- "react-server-dom-webpack": "19.0.0-rc-6230622a1a-20240610"
118
+ "server-only": "^0.0.1"
120
119
  }
121
120
  }