expo-router 3.4.6 → 3.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/build/fork/extractPathFromURL.d.ts.map +1 -1
  2. package/build/fork/extractPathFromURL.js +2 -2
  3. package/build/fork/extractPathFromURL.js.map +1 -1
  4. package/build/getServerManifest.d.ts +5 -0
  5. package/build/getServerManifest.d.ts.map +1 -1
  6. package/build/getServerManifest.js +10 -6
  7. package/build/getServerManifest.js.map +1 -1
  8. package/build/global-state/router-store.d.ts +3 -0
  9. package/build/global-state/router-store.d.ts.map +1 -1
  10. package/build/global-state/router-store.js +3 -0
  11. package/build/global-state/router-store.js.map +1 -1
  12. package/build/global-state/routing.d.ts +3 -0
  13. package/build/global-state/routing.d.ts.map +1 -1
  14. package/build/global-state/routing.js +24 -1
  15. package/build/global-state/routing.js.map +1 -1
  16. package/build/head/ExpoHeadModule.d.ts +2 -1
  17. package/build/head/ExpoHeadModule.d.ts.map +1 -1
  18. package/build/head/ExpoHeadModule.js +6 -1
  19. package/build/head/ExpoHeadModule.js.map +1 -1
  20. package/build/hooks.d.ts.map +1 -1
  21. package/build/hooks.js +3 -0
  22. package/build/hooks.js.map +1 -1
  23. package/build/imperative-api.d.ts.map +1 -1
  24. package/build/imperative-api.js +3 -0
  25. package/build/imperative-api.js.map +1 -1
  26. package/build/link/linking.d.ts.map +1 -1
  27. package/build/link/linking.js +3 -3
  28. package/build/link/linking.js.map +1 -1
  29. package/build/testing-library/context-stubs.d.ts +1 -1
  30. package/build/testing-library/context-stubs.d.ts.map +1 -1
  31. package/build/testing-library/context-stubs.js +7 -2
  32. package/build/testing-library/context-stubs.js.map +1 -1
  33. package/build/testing-library/index.d.ts +8 -4
  34. package/build/testing-library/index.d.ts.map +1 -1
  35. package/build/testing-library/index.js +23 -12
  36. package/build/testing-library/index.js.map +1 -1
  37. package/build/testing-library/mocks.d.ts +0 -1
  38. package/build/testing-library/mocks.d.ts.map +1 -1
  39. package/build/testing-library/mocks.js +7 -1
  40. package/build/testing-library/mocks.js.map +1 -1
  41. package/build/types.d.ts +7 -1
  42. package/build/types.d.ts.map +1 -1
  43. package/build/types.js.map +1 -1
  44. package/package.json +3 -3
  45. package/build/head/ExpoHeadModule.native.d.ts +0 -3
  46. package/build/head/ExpoHeadModule.native.d.ts.map +0 -1
  47. package/build/head/ExpoHeadModule.native.js +0 -36
  48. package/build/head/ExpoHeadModule.native.js.map +0 -1
  49. package/build/utils/mockState.d.ts +0 -7
  50. package/build/utils/mockState.d.ts.map +0 -1
  51. package/build/utils/mockState.js +0 -29
  52. package/build/utils/mockState.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"extractPathFromURL.d.ts","sourceRoot":"","sources":["../../src/fork/extractPathFromURL.ts"],"names":[],"mappings":"AAwFA,wBAAgB,sBAAsB,CAAC,GAAG,GAAE,MAAW,UAGtD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,UAMjF"}
1
+ {"version":3,"file":"extractPathFromURL.d.ts","sourceRoot":"","sources":["../../src/fork/extractPathFromURL.ts"],"names":[],"mappings":"AAyFA,wBAAgB,sBAAsB,CAAC,GAAG,GAAE,MAAW,UAGtD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,UAMjF"}
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.adjustPathname = exports.extractExpoPathFromURL = void 0;
27
- const expo_constants_1 = __importStar(require("expo-constants"));
28
27
  const Linking = __importStar(require("expo-linking"));
29
28
  // This is only run on native.
30
29
  function extractExactPathFromURL(url) {
@@ -35,8 +34,9 @@ function extractExactPathFromURL(url) {
35
34
  const { origin, href } = new URL(url);
36
35
  return href.replace(origin, '');
37
36
  }
37
+ const isExpoGo = typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo;
38
38
  // Handle special URLs used in Expo Go: `/--/pathname` -> `pathname`
39
- if (expo_constants_1.default.executionEnvironment === expo_constants_1.ExecutionEnvironment.StoreClient &&
39
+ if (isExpoGo &&
40
40
  // while not exhaustive, `exp` and `exps` are the only two schemes which
41
41
  // are passed through to other apps in Expo Go.
42
42
  url.match(/^exp(s)?:\/\//)) {
@@ -1 +1 @@
1
- {"version":3,"file":"extractPathFromURL.js","sourceRoot":"","sources":["../../src/fork/extractPathFromURL.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAiE;AACjE,sDAAwC;AAExC,8BAA8B;AAC9B,SAAS,uBAAuB,CAAC,GAAW;IAC1C;IACE,2EAA2E;IAC3E,4CAA4C;IAC5C,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,EACzB;QACA,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;KACjC;IAED,oEAAoE;IACpE,IACE,wBAAS,CAAC,oBAAoB,KAAK,qCAAoB,CAAC,WAAW;QACnE,wEAAwE;QACxE,+CAA+C;QAC/C,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,EAC1B;QACA,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3D,IAAI,QAAQ,EAAE;YACZ,OAAO,YAAY,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;SACxC;QAED,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/B,MAAM,EAAE,GAAG,CAAC,GAAG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AO,IAAI,GAAG,CAAC,IAAI,CAAC;KACrB;IAED,IAAI,GAAG,CAAC,QAAQ,EAAE;QAChB,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC;KACzB;IAED,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM;QACpB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,wEAAwE;YACxE,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE/F,IAAI,EAAE,EAAE;QACN,OAAO,IAAI,GAAG,GAAG,EAAE,CAAC;KACrB;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,sBAAsB,CAAC,MAAc,EAAE;IACrD,sEAAsE;IACtE,OAAO,uBAAuB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC;AAHD,wDAGC;AAED,SAAgB,cAAc,CAAC,GAAmD;IAChF,IAAI,GAAG,CAAC,QAAQ,KAAK,UAAU,IAAI,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QAChE,6CAA6C;QAC7C,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACnD;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtB,CAAC;AAND,wCAMC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Linking from 'expo-linking';\n\n// This is only run on native.\nfunction extractExactPathFromURL(url: string): string {\n if (\n // If a universal link / app link / web URL is used, we should use the path\n // from the URL, while stripping the origin.\n url.match(/^https?:\\/\\//)\n ) {\n const { origin, href } = new URL(url);\n return href.replace(origin, '');\n }\n\n // Handle special URLs used in Expo Go: `/--/pathname` -> `pathname`\n if (\n Constants.executionEnvironment === ExecutionEnvironment.StoreClient &&\n // while not exhaustive, `exp` and `exps` are the only two schemes which\n // are passed through to other apps in Expo Go.\n url.match(/^exp(s)?:\\/\\//)\n ) {\n const pathname = url.match(/exps?:\\/\\/.*?\\/--\\/(.*)/)?.[1];\n if (pathname) {\n return fromDeepLink('a://' + pathname);\n }\n\n const res = Linking.parse(url);\n\n const qs = !res.queryParams\n ? ''\n : Object.entries(res.queryParams)\n .map(([k, v]) => `${k}=${v}`)\n .join('&');\n return (\n adjustPathname({ hostname: res.hostname, pathname: res.path || '' }) + (qs ? '?' + qs : '')\n );\n }\n\n // TODO: Support dev client URLs\n\n return fromDeepLink(url);\n}\n\n/** Major hack to support the makeshift expo-development-client system. */\nfunction isExpoDevelopmentClient(url: URL): boolean {\n return url.hostname === 'expo-development-client';\n}\n\nfunction fromDeepLink(url: string): string {\n let res: URL;\n try {\n // This is for all standard deep links, e.g. `foobar://` where everything\n // after the `://` is the path.\n res = new URL(url);\n } catch {\n return url;\n }\n\n if (isExpoDevelopmentClient(res)) {\n if (!res.searchParams.get('url')) {\n return '';\n }\n const incomingUrl = res.searchParams.get('url')!;\n return extractExactPathFromURL(decodeURI(incomingUrl));\n }\n\n let results = '';\n\n if (res.host) {\n results += res.host;\n }\n\n if (res.pathname) {\n results += res.pathname;\n }\n\n const qs = !res.search\n ? ''\n : // @ts-ignore: `entries` is not on `URLSearchParams` in some typechecks.\n [...res.searchParams.entries()].map(([k, v]) => `${k}=${decodeURIComponent(v)}`).join('&');\n\n if (qs) {\n results += '?' + qs;\n }\n\n return results;\n}\n\nexport function extractExpoPathFromURL(url: string = '') {\n // TODO: We should get rid of this, dropping specificities is not good\n return extractExactPathFromURL(url).replace(/^\\//, '');\n}\n\nexport function adjustPathname(url: { hostname?: string | null; pathname: string }) {\n if (url.hostname === 'exp.host' || url.hostname === 'u.expo.dev') {\n // drop the first two segments from pathname:\n return url.pathname.split('/').slice(2).join('/');\n }\n return url.pathname;\n}\n"]}
1
+ {"version":3,"file":"extractPathFromURL.js","sourceRoot":"","sources":["../../src/fork/extractPathFromURL.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AAExC,8BAA8B;AAC9B,SAAS,uBAAuB,CAAC,GAAW;IAC1C;IACE,2EAA2E;IAC3E,4CAA4C;IAC5C,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,EACzB;QACA,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;KACjC;IAED,MAAM,QAAQ,GAAG,OAAO,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;IAEjF,oEAAoE;IACpE,IACE,QAAQ;QACR,wEAAwE;QACxE,+CAA+C;QAC/C,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,EAC1B;QACA,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3D,IAAI,QAAQ,EAAE;YACZ,OAAO,YAAY,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;SACxC;QAED,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/B,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW;YACzB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;iBAC5B,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;iBAC5B,IAAI,CAAC,GAA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G,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE/F,IAAI,EAAE,EAAE;QACN,OAAO,IAAI,GAAG,GAAG,EAAE,CAAC;KACrB;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,sBAAsB,CAAC,MAAc,EAAE;IACrD,sEAAsE;IACtE,OAAO,uBAAuB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC;AAHD,wDAGC;AAED,SAAgB,cAAc,CAAC,GAAmD;IAChF,IAAI,GAAG,CAAC,QAAQ,KAAK,UAAU,IAAI,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QAChE,6CAA6C;QAC7C,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACnD;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtB,CAAC;AAND,wCAMC","sourcesContent":["import * as Linking from 'expo-linking';\n\n// This is only run on native.\nfunction extractExactPathFromURL(url: string): string {\n if (\n // If a universal link / app link / web URL is used, we should use the path\n // from the URL, while stripping the origin.\n url.match(/^https?:\\/\\//)\n ) {\n const { origin, href } = new URL(url);\n return href.replace(origin, '');\n }\n\n const isExpoGo = typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo;\n\n // Handle special URLs used in Expo Go: `/--/pathname` -> `pathname`\n if (\n isExpoGo &&\n // while not exhaustive, `exp` and `exps` are the only two schemes which\n // are passed through to other apps in Expo Go.\n url.match(/^exp(s)?:\\/\\//)\n ) {\n const pathname = url.match(/exps?:\\/\\/.*?\\/--\\/(.*)/)?.[1];\n if (pathname) {\n return fromDeepLink('a://' + pathname);\n }\n\n const res = Linking.parse(url);\n\n const qs = !res.queryParams\n ? ''\n : Object.entries(res.queryParams)\n .map(([k, v]) => `${k}=${v}`)\n .join('&');\n return (\n adjustPathname({ hostname: res.hostname, pathname: res.path || '' }) + (qs ? '?' + qs : '')\n );\n }\n\n // TODO: Support dev client URLs\n\n return fromDeepLink(url);\n}\n\n/** Major hack to support the makeshift expo-development-client system. */\nfunction isExpoDevelopmentClient(url: URL): boolean {\n return url.hostname === 'expo-development-client';\n}\n\nfunction fromDeepLink(url: string): string {\n let res: URL;\n try {\n // This is for all standard deep links, e.g. `foobar://` where everything\n // after the `://` is the path.\n res = new URL(url);\n } catch {\n return url;\n }\n\n if (isExpoDevelopmentClient(res)) {\n if (!res.searchParams.get('url')) {\n return '';\n }\n const incomingUrl = res.searchParams.get('url')!;\n return extractExactPathFromURL(decodeURI(incomingUrl));\n }\n\n let results = '';\n\n if (res.host) {\n results += res.host;\n }\n\n if (res.pathname) {\n results += res.pathname;\n }\n\n const qs = !res.search\n ? ''\n : // @ts-ignore: `entries` is not on `URLSearchParams` in some typechecks.\n [...res.searchParams.entries()].map(([k, v]) => `${k}=${decodeURIComponent(v)}`).join('&');\n\n if (qs) {\n results += '?' + qs;\n }\n\n return results;\n}\n\nexport function extractExpoPathFromURL(url: string = '') {\n // TODO: We should get rid of this, dropping specificities is not good\n return extractExactPathFromURL(url).replace(/^\\//, '');\n}\n\nexport function adjustPathname(url: { hostname?: string | null; pathname: string }) {\n if (url.hostname === 'exp.host' || url.hostname === 'u.expo.dev') {\n // drop the first two segments from pathname:\n return url.pathname.split('/').slice(2).join('/');\n }\n return url.pathname;\n}\n"]}
@@ -33,4 +33,9 @@ export interface RouteRegex {
33
33
  }
34
34
  export declare function getServerManifest(route: RouteNode): ExpoRouterServerManifestV1;
35
35
  export declare function getNamedRouteRegex(normalizedRoute: string, page: string): ExpoRouterServerManifestV1Route;
36
+ export declare function parseParameter(param: string): {
37
+ name: string;
38
+ repeat: boolean;
39
+ optional: boolean;
40
+ };
36
41
  //# sourceMappingURL=getServerManifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,MAAM,MAAM,+BAA+B,CAAC,MAAM,GAAG,MAAM,IAAI;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,MAAM,GAAG,MAAM,IAAI;IACxD,SAAS,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;IACrD,UAAU,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;IACtD,cAAc,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;CAC3D,CAAC;AAEF,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC;CACZ;AAWD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,0BAA0B,CA8B9E;AAWD,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,MAAM,GACX,+BAA+B,CAQjC"}
1
+ {"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,MAAM,MAAM,+BAA+B,CAAC,MAAM,GAAG,MAAM,IAAI;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,MAAM,GAAG,MAAM,IAAI;IACxD,SAAS,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;IACrD,UAAU,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;IACtD,cAAc,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE,CAAC;CAC3D,CAAC;AAEF,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC;CACZ;AAWD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,0BAA0B,CA8B9E;AAiBD,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,MAAM,GACX,+BAA+B,CAQjC;AA2GD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM;;;;EAgB3C"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNamedRouteRegex = exports.getServerManifest = void 0;
3
+ exports.parseParameter = exports.getNamedRouteRegex = exports.getServerManifest = void 0;
4
4
  const matchers_1 = require("./matchers");
5
5
  const sortRoutes_1 = require("./sortRoutes");
6
6
  function isApiRoute(route) {
@@ -33,10 +33,13 @@ function getServerManifest(route) {
33
33
  }
34
34
  exports.getServerManifest = getServerManifest;
35
35
  function getMatchableManifestForPaths(paths) {
36
- return paths.map((normalizedRoutePath) => ({
37
- ...getNamedRouteRegex(normalizedRoutePath[0], normalizedRoutePath[1].contextKey),
38
- generated: normalizedRoutePath[1].generated,
39
- }));
36
+ return paths.map((normalizedRoutePath) => {
37
+ const matcher = getNamedRouteRegex(normalizedRoutePath[0], normalizedRoutePath[1].contextKey);
38
+ if (normalizedRoutePath[1].generated) {
39
+ matcher.generated = true;
40
+ }
41
+ return matcher;
42
+ });
40
43
  }
41
44
  function getNamedRouteRegex(normalizedRoute, page) {
42
45
  const result = getNamedParametrizedRoute(normalizedRoute);
@@ -94,7 +97,7 @@ function getNamedParametrizedRoute(route) {
94
97
  segment = '[...not-found]';
95
98
  }
96
99
  if (/^\[.*\]$/.test(segment)) {
97
- const { name, optional, repeat } = parseParameter(segment.slice(1, -1));
100
+ const { name, optional, repeat } = parseParameter(segment);
98
101
  // replace any non-word characters since they can break
99
102
  // the named regex
100
103
  let cleanedKey = name.replace(/\W/g, '');
@@ -157,4 +160,5 @@ function parseParameter(param) {
157
160
  }
158
161
  return { name, repeat, optional };
159
162
  }
163
+ exports.parseParameter = parseParameter;
160
164
  //# sourceMappingURL=getServerManifest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":";;;AAUA,yCAA2C;AAC3C,6CAA0C;AA4B1C,SAAS,UAAU,CAAC,KAAgB;IAClC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,eAAe,CAAC,KAAgB;IACvC,OAAO,KAAK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AU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;gBACnC,wBAAwB;gBACxB,OAAO,OAAO,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC;aAC/C;iBAAM;gBACL,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;aAC1C;QACH,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC;QACX,SAAS;KACV,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAC1C,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAE/C,SAAS,kBAAkB,CAAC,GAAW;IACrC,+GAA+G;IAC/G,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACzB,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;KAC7C;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,IAAI,GAAG,KAAK,CAAC;IAEjB,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACzB,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC1B;IAED,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACxB,MAAM,GAAG,IAAI,CAAC;QACd,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACtB;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright © 2023 Vercel, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts\n */\nimport type { RouteNode } from './Route';\nimport { getContextKey } from './matchers';\nimport { sortRoutes } from './sortRoutes';\n\n// TODO: Share these types across cli, server, router, etc.\nexport type ExpoRouterServerManifestV1Route<TRegex = string> = {\n file: string;\n page: string;\n routeKeys: Record<string, string>;\n namedRegex: TRegex;\n generated?: boolean;\n};\n\nexport type ExpoRouterServerManifestV1<TRegex = string> = {\n apiRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n htmlRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n notFoundRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n};\n\nexport interface Group {\n pos: number;\n repeat: boolean;\n optional: boolean;\n}\n\nexport interface RouteRegex {\n groups: { [groupName: string]: Group };\n re: RegExp;\n}\n\nfunction isApiRoute(route: RouteNode) {\n return !route.children.length && !!route.contextKey.match(/\\+api\\.[jt]sx?$/);\n}\n\nfunction isNotFoundRoute(route: RouteNode) {\n return route.dynamic && route.dynamic[route.dynamic.length - 1].notFound;\n}\n\n// Given a nested route tree, return a flattened array of all routes that can be matched.\nexport function getServerManifest(route: RouteNode): ExpoRouterServerManifestV1 {\n function getFlatNodes(route: RouteNode): [string, RouteNode][] {\n if (route.children.length) {\n return route.children.map((child) => getFlatNodes(child)).flat();\n }\n\n const key = getContextKey(route.contextKey).replace(/\\/index$/, '') ?? '/';\n return [[key, route]];\n }\n\n const flat = getFlatNodes(route)\n .sort(([, a], [, b]) => sortRoutes(b, a))\n .reverse();\n\n const apiRoutes = flat.filter(([, route]) => isApiRoute(route));\n const otherRoutes = flat.filter(([, route]) => !isApiRoute(route));\n const standardRoutes = otherRoutes.filter(([, route]) => !isNotFoundRoute(route));\n const notFoundRoutes = otherRoutes.filter(([, route]) => isNotFoundRoute(route));\n\n return {\n apiRoutes: getMatchableManifestForPaths(\n apiRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n htmlRoutes: getMatchableManifestForPaths(\n standardRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n notFoundRoutes: getMatchableManifestForPaths(\n notFoundRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n };\n}\n\nfunction getMatchableManifestForPaths(\n paths: [string, RouteNode][]\n): ExpoRouterServerManifestV1Route[] {\n return paths.map((normalizedRoutePath) => ({\n ...getNamedRouteRegex(normalizedRoutePath[0], normalizedRoutePath[1].contextKey),\n generated: normalizedRoutePath[1].generated,\n }));\n}\n\nexport function getNamedRouteRegex(\n normalizedRoute: string,\n page: string\n): ExpoRouterServerManifestV1Route {\n const result = getNamedParametrizedRoute(normalizedRoute);\n return {\n file: page,\n page: page.replace(/\\.[jt]sx?$/, ''),\n namedRegex: `^${result.namedParameterizedRoute}(?:/)?$`,\n routeKeys: result.routeKeys,\n };\n}\n\n/**\n * Builds a function to generate a minimal routeKey using only a-z and minimal\n * number of characters.\n */\nfunction buildGetSafeRouteKey() {\n let currentCharCode = 96; // Starting one before 'a' to make the increment logic simpler\n let currentLength = 1;\n\n return () => {\n let result = '';\n let incrementNext = true;\n\n // Iterate from right to left to build the key\n for (let i = 0; i < currentLength; i++) {\n if (incrementNext) {\n currentCharCode++;\n if (currentCharCode > 122) {\n currentCharCode = 97; // Reset to 'a'\n incrementNext = true; // Continue to increment the next character\n } else {\n incrementNext = false;\n }\n }\n result = String.fromCharCode(currentCharCode) + result;\n }\n\n // If all characters are 'z', increase the length of the key\n if (incrementNext) {\n currentLength++;\n currentCharCode = 96; // This will make the next key start with 'a'\n }\n\n return result;\n };\n}\n\nfunction removeTrailingSlash(route: string): string {\n return route.replace(/\\/$/, '') || '/';\n}\n\nfunction getNamedParametrizedRoute(route: string) {\n const segments = removeTrailingSlash(route).slice(1).split('/');\n const getSafeRouteKey = buildGetSafeRouteKey();\n const routeKeys: { [named: string]: string } = {};\n return {\n namedParameterizedRoute: segments\n .map((segment, index) => {\n if (segment === '+not-found' && index === segments.length - 1) {\n segment = '[...not-found]';\n }\n if (/^\\[.*\\]$/.test(segment)) {\n const { name, optional, repeat } = parseParameter(segment.slice(1, -1));\n // replace any non-word characters since they can break\n // the named regex\n let cleanedKey = name.replace(/\\W/g, '');\n let invalidKey = false;\n\n // check if the key is still invalid and fallback to using a known\n // safe key\n if (cleanedKey.length === 0 || cleanedKey.length > 30) {\n invalidKey = true;\n }\n if (!isNaN(parseInt(cleanedKey.slice(0, 1), 10))) {\n invalidKey = true;\n }\n\n // Prevent duplicates after sanitizing the key\n if (cleanedKey in routeKeys) {\n invalidKey = true;\n }\n\n if (invalidKey) {\n cleanedKey = getSafeRouteKey();\n }\n\n routeKeys[cleanedKey] = name;\n return repeat\n ? optional\n ? `(?:/(?<${cleanedKey}>.+?))?`\n : `/(?<${cleanedKey}>.+?)`\n : `/(?<${cleanedKey}>[^/]+?)`;\n } else if (/^\\(.*\\)$/.test(segment)) {\n // Make section optional\n return `(?:/${escapeStringRegexp(segment)})?`;\n } else {\n return `/${escapeStringRegexp(segment)}`;\n }\n })\n .join(''),\n routeKeys,\n };\n}\n\n// regexp is based on https://github.com/sindresorhus/escape-string-regexp\nconst reHasRegExp = /[|\\\\{}()[\\]^$+*?.-]/;\nconst reReplaceRegExp = /[|\\\\{}()[\\]^$+*?.-]/g;\n\nfunction escapeStringRegexp(str: string) {\n // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23\n if (reHasRegExp.test(str)) {\n return str.replace(reReplaceRegExp, '\\\\$&');\n }\n return str;\n}\n\nfunction parseParameter(param: string) {\n let repeat = false;\n let optional = false;\n let name = param;\n\n if (/^\\[.*\\]$/.test(name)) {\n optional = true;\n name = name.slice(1, -1);\n }\n\n if (/^\\.\\.\\./.test(name)) {\n repeat = true;\n name = name.slice(3);\n }\n\n return { name, repeat, optional };\n}\n"]}
1
+ {"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../src/get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,CAAC,EAAE;QACxB,MAAM,GAAG,IAAI,CAAC;QACd,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACtB;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC;AAhBD,wCAgBC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright © 2023 Vercel, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts\n */\nimport type { RouteNode } from './Route';\nimport { getContextKey } from './matchers';\nimport { sortRoutes } from './sortRoutes';\n\n// TODO: Share these types across cli, server, router, etc.\nexport type ExpoRouterServerManifestV1Route<TRegex = string> = {\n file: string;\n page: string;\n routeKeys: Record<string, string>;\n namedRegex: TRegex;\n generated?: boolean;\n};\n\nexport type ExpoRouterServerManifestV1<TRegex = string> = {\n apiRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n htmlRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n notFoundRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n};\n\nexport interface Group {\n pos: number;\n repeat: boolean;\n optional: boolean;\n}\n\nexport interface RouteRegex {\n groups: { [groupName: string]: Group };\n re: RegExp;\n}\n\nfunction isApiRoute(route: RouteNode) {\n return !route.children.length && !!route.contextKey.match(/\\+api\\.[jt]sx?$/);\n}\n\nfunction isNotFoundRoute(route: RouteNode) {\n return route.dynamic && route.dynamic[route.dynamic.length - 1].notFound;\n}\n\n// Given a nested route tree, return a flattened array of all routes that can be matched.\nexport function getServerManifest(route: RouteNode): ExpoRouterServerManifestV1 {\n function getFlatNodes(route: RouteNode): [string, RouteNode][] {\n if (route.children.length) {\n return route.children.map((child) => getFlatNodes(child)).flat();\n }\n\n const key = getContextKey(route.contextKey).replace(/\\/index$/, '') ?? '/';\n return [[key, route]];\n }\n\n const flat = getFlatNodes(route)\n .sort(([, a], [, b]) => sortRoutes(b, a))\n .reverse();\n\n const apiRoutes = flat.filter(([, route]) => isApiRoute(route));\n const otherRoutes = flat.filter(([, route]) => !isApiRoute(route));\n const standardRoutes = otherRoutes.filter(([, route]) => !isNotFoundRoute(route));\n const notFoundRoutes = otherRoutes.filter(([, route]) => isNotFoundRoute(route));\n\n return {\n apiRoutes: getMatchableManifestForPaths(\n apiRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n htmlRoutes: getMatchableManifestForPaths(\n standardRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n notFoundRoutes: getMatchableManifestForPaths(\n notFoundRoutes.map(([normalizedRoutePath, node]) => [normalizedRoutePath, node])\n ),\n };\n}\n\nfunction getMatchableManifestForPaths(\n paths: [string, RouteNode][]\n): ExpoRouterServerManifestV1Route[] {\n return paths.map((normalizedRoutePath) => {\n const matcher: ExpoRouterServerManifestV1Route = getNamedRouteRegex(\n normalizedRoutePath[0],\n normalizedRoutePath[1].contextKey\n );\n if (normalizedRoutePath[1].generated) {\n matcher.generated = true;\n }\n return matcher;\n });\n}\n\nexport function getNamedRouteRegex(\n normalizedRoute: string,\n page: string\n): ExpoRouterServerManifestV1Route {\n const result = getNamedParametrizedRoute(normalizedRoute);\n return {\n file: page,\n page: page.replace(/\\.[jt]sx?$/, ''),\n namedRegex: `^${result.namedParameterizedRoute}(?:/)?$`,\n routeKeys: result.routeKeys,\n };\n}\n\n/**\n * Builds a function to generate a minimal routeKey using only a-z and minimal\n * number of characters.\n */\nfunction buildGetSafeRouteKey() {\n let currentCharCode = 96; // Starting one before 'a' to make the increment logic simpler\n let currentLength = 1;\n\n return () => {\n let result = '';\n let incrementNext = true;\n\n // Iterate from right to left to build the key\n for (let i = 0; i < currentLength; i++) {\n if (incrementNext) {\n currentCharCode++;\n if (currentCharCode > 122) {\n currentCharCode = 97; // Reset to 'a'\n incrementNext = true; // Continue to increment the next character\n } else {\n incrementNext = false;\n }\n }\n result = String.fromCharCode(currentCharCode) + result;\n }\n\n // If all characters are 'z', increase the length of the key\n if (incrementNext) {\n currentLength++;\n currentCharCode = 96; // This will make the next key start with 'a'\n }\n\n return result;\n };\n}\n\nfunction removeTrailingSlash(route: string): string {\n return route.replace(/\\/$/, '') || '/';\n}\n\nfunction getNamedParametrizedRoute(route: string) {\n const segments = removeTrailingSlash(route).slice(1).split('/');\n const getSafeRouteKey = buildGetSafeRouteKey();\n const routeKeys: { [named: string]: string } = {};\n return {\n namedParameterizedRoute: segments\n .map((segment, index) => {\n if (segment === '+not-found' && index === segments.length - 1) {\n segment = '[...not-found]';\n }\n if (/^\\[.*\\]$/.test(segment)) {\n const { name, optional, repeat } = parseParameter(segment);\n // replace any non-word characters since they can break\n // the named regex\n let cleanedKey = name.replace(/\\W/g, '');\n let invalidKey = false;\n\n // check if the key is still invalid and fallback to using a known\n // safe key\n if (cleanedKey.length === 0 || cleanedKey.length > 30) {\n invalidKey = true;\n }\n if (!isNaN(parseInt(cleanedKey.slice(0, 1), 10))) {\n invalidKey = true;\n }\n\n // Prevent duplicates after sanitizing the key\n if (cleanedKey in routeKeys) {\n invalidKey = true;\n }\n\n if (invalidKey) {\n cleanedKey = getSafeRouteKey();\n }\n\n routeKeys[cleanedKey] = name;\n return repeat\n ? optional\n ? `(?:/(?<${cleanedKey}>.+?))?`\n : `/(?<${cleanedKey}>.+?)`\n : `/(?<${cleanedKey}>[^/]+?)`;\n } else if (/^\\(.*\\)$/.test(segment)) {\n // Make section optional\n return `(?:/${escapeStringRegexp(segment)})?`;\n } else {\n return `/${escapeStringRegexp(segment)}`;\n }\n })\n .join(''),\n routeKeys,\n };\n}\n\n// regexp is based on https://github.com/sindresorhus/escape-string-regexp\nconst reHasRegExp = /[|\\\\{}()[\\]^$+*?.-]/;\nconst reReplaceRegExp = /[|\\\\{}()[\\]^$+*?.-]/g;\n\nfunction escapeStringRegexp(str: string) {\n // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23\n if (reHasRegExp.test(str)) {\n return str.replace(reReplaceRegExp, '\\\\$&');\n }\n return str;\n}\n\nexport function parseParameter(param: string) {\n let repeat = false;\n let optional = false;\n let name = param;\n\n if (/^\\[.*\\]$/.test(name)) {\n optional = true;\n name = name.slice(1, -1);\n }\n\n if (/^\\.\\.\\./.test(name)) {\n repeat = true;\n name = name.slice(3);\n }\n\n return { name, repeat, optional };\n}\n"]}
@@ -28,7 +28,10 @@ export declare class RouterStore {
28
28
  goBack: any;
29
29
  canGoBack: any;
30
30
  push: any;
31
+ dismiss: any;
31
32
  replace: any;
33
+ dismissAll: any;
34
+ canDismiss: any;
32
35
  setParams: any;
33
36
  navigate: any;
34
37
  initialize(context: RequireContext, navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>, initialLocation?: URL): void;
@@ -1 +1 @@
1
- {"version":3,"file":"router-store.d.ts","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAGlC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAiC,aAAa,EAAY,MAAM,OAAO,CAAC;AAI/E,OAAO,EAAE,SAAS,EAAyB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAoB,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C;;;;GAIG;AACH,qBAAa,WAAW;IACtB,SAAS,EAAG,SAAS,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAG,aAAa,CAAC;IAC9B,OAAO,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACxC,OAAO,CAAC,wBAAwB,CAAkB;IAElD,YAAY,EAAE,WAAW,GAAG,SA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D,YAAY,CAAC,KAAK,EAAE,WAAW;IAgB/B,kBAAkB;IAIlB,uEAAuE;IACvE,oBAAoB,eAAgB,MAAM,IAAI,mBAG5C;IACF,gBAAgB,eAAgB,MAAM,IAAI,mBAGxC;IACF,QAAQ,aAEN;IACF,iBAAiB,oBAEf;IACF,iBAAiB,kBAEf;CACH;AAED,eAAO,MAAM,KAAK,aAAoB,CAAC;AAEvC,wBAAgB,aAAa,gBAE5B;AAYD,wBAAgB,iBAAiB,gBAOhC;AAED,wBAAgB,iBAAiB,cAOhC;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,GAAG,SAAS,eAQhG"}
@@ -57,7 +57,10 @@ class RouterStore {
57
57
  goBack = routing_1.goBack.bind(this);
58
58
  canGoBack = routing_1.canGoBack.bind(this);
59
59
  push = routing_1.push.bind(this);
60
+ dismiss = routing_1.dismiss.bind(this);
60
61
  replace = routing_1.replace.bind(this);
62
+ dismissAll = routing_1.dismissAll.bind(this);
63
+ canDismiss = routing_1.canDismiss.bind(this);
61
64
  setParams = routing_1.setParams.bind(this);
62
65
  navigate = routing_1.navigate.bind(this);
63
66
  initialize(context, navigationRef, initialLocation) {
@@ -1 +1 @@
1
- {"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAIkC;AAClC,iEAAmD;AACnD,iCAA+E;AAE/E,uCAA0F;AAC1F,+CAAgD;AAChD,0DAAuE;AAEvE,+DAA2E;AAE3E,0DAA2E;AAC3E,4CAAyC;AAEzC,8CAA2D;AAE3D;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;IAC7B,aAAa,CAAiB;IAC9B,OAAO,CAAiC;IAChC,wBAAwB,GAAY,KAAK,CAAC;IAElD,YAAY,CAA0B;IACtC,SAAS,CAA0B;IACnC,SAAS,CAA0B;IACnC,SAAS,CAAyB;IAElC,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,CAAC,QAAQ,CAAC,CAAC;AACtF,CAAC;AAFD,sCAEC;AAED,SAAS,kBAAkB;IACzB,IAAI,aAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE;QACjC,MAAM,YAAY,GAAG,aAAK,CAAC,aAAa,CAAC,YAAY,EAA4B,CAAC;QAElF,IAAI,aAAK,CAAC,SAAS,KAAK,YAAY,EAAE;YACpC,aAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACjC;KACF;AACH,CAAC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,uBAAuB,CAAC,OAAuB,EAAE,eAAgC;IAC/F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EACL,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,eAAe,CAAC,EAC/D,CAAC,OAAO,EAAE,eAAe,CAAC,CAC3B,CAAC;IACF,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AARD,0DAQC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n getPathFromState,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\n\nimport { canGoBack, goBack, linkTo, navigate, push, replace, setParams } from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { deepEqual, getPathDataFromState } from '../fork/getPathFromState';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking: ExpoLinkingOptions | undefined;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState: ResultState | undefined;\n rootState: ResultState | undefined;\n nextState: ResultState | undefined;\n routeInfo?: UrlObject | undefined;\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n replace = replace.bind(this);\n setParams = setParams.bind(this);\n navigate = navigate.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n initialLocation?: URL\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.routeInfo = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context, { ignoreEntryPoints: true });\n\n this.rootComponent = this.routeNode ? getQualifiedRouteComponent(this.routeNode) : Fragment;\n\n // Only error in production, in development we will show the onboarding screen\n if (!this.routeNode && process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n this.navigationRef = navigationRef;\n\n if (this.routeNode) {\n this.linking = getLinkingConfig(this.routeNode!);\n\n if (initialLocation) {\n this.linking.getInitialURL = () => initialLocation.toString();\n this.initialState = this.linking.getStateFromPath?.(\n initialLocation.pathname + initialLocation.search,\n this.linking.config\n );\n }\n }\n\n // There is no routeNode, so we will be showing the onboarding screen\n // In the meantime, just mock the routeInfo\n if (this.initialState) {\n this.rootState = this.initialState;\n this.routeInfo = this.getRouteInfo(this.initialState);\n } else {\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigation's state changes and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n requestAnimationFrame(\n () =>\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_maybeHideAsync?.()\n );\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!deepEqual(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: [],\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, initialLocation: URL | undefined) {\n const navigationRef = useNavigationContainerRef();\n useMemo(\n () => store.initialize(context, navigationRef, initialLocation),\n [context, initialLocation]\n );\n useExpoRouter();\n return store;\n}\n"]}
1
+ {"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAIkC;AAClC,iEAAmD;AACnD,iCAA+E;AAE/E,uCAWmB;AACnB,+CAAgD;AAChD,0DAAuE;AAEvE,+DAA2E;AAE3E,0DAA2E;AAC3E,4CAAyC;AAEzC,8CAA2D;AAE3D;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;IAC7B,aAAa,CAAiB;IAC9B,OAAO,CAAiC;IAChC,wBAAwB,GAAY,KAAK,CAAC;IAElD,YAAY,CAA0B;IACtC,SAAS,CAA0B;IACnC,SAAS,CAA0B;IACnC,SAAS,CAAyB;IAElC,aAAa,CAAoE;IACjF,yBAAyB,CAAc;IAEvC,oBAAoB,GAAG,IAAI,GAAG,EAAc,CAAC;IAC7C,gBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;IAEzC,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,eAAe,GAAG,6BAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,SAAS,GAAG,mBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,GAAG,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,GAAG,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,UAAU,GAAG,oBAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,UAAU,GAAG,oBAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,SAAS,GAAG,mBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACj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IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAPD,8CAOC;AAED,SAAgB,uBAAuB,CAAC,OAAuB,EAAE,eAAgC;IAC/F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EACL,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,eAAe,CAAC,EAC/D,CAAC,OAAO,EAAE,eAAe,CAAC,CAC3B,CAAC;IACF,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC;AARD,0DAQC","sourcesContent":["import {\n NavigationContainerRefWithCurrent,\n getPathFromState,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\n\nimport {\n canGoBack,\n canDismiss,\n goBack,\n linkTo,\n navigate,\n dismiss,\n dismissAll,\n push,\n replace,\n setParams,\n} from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { deepEqual, getPathDataFromState } from '../fork/getPathFromState';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { ExpoLinkingOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking: ExpoLinkingOptions | undefined;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState: ResultState | undefined;\n rootState: ResultState | undefined;\n nextState: ResultState | undefined;\n routeInfo?: UrlObject | undefined;\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n dismiss = dismiss.bind(this);\n replace = replace.bind(this);\n dismissAll = dismissAll.bind(this);\n canDismiss = canDismiss.bind(this);\n setParams = setParams.bind(this);\n navigate = navigate.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n initialLocation?: URL\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.routeInfo = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.routeNode = getRoutes(context, { ignoreEntryPoints: true });\n\n this.rootComponent = this.routeNode ? getQualifiedRouteComponent(this.routeNode) : Fragment;\n\n // Only error in production, in development we will show the onboarding screen\n if (!this.routeNode && process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n this.navigationRef = navigationRef;\n\n if (this.routeNode) {\n this.linking = getLinkingConfig(this.routeNode!);\n\n if (initialLocation) {\n this.linking.getInitialURL = () => initialLocation.toString();\n this.initialState = this.linking.getStateFromPath?.(\n initialLocation.pathname + initialLocation.search,\n this.linking.config\n );\n }\n }\n\n // There is no routeNode, so we will be showing the onboarding screen\n // In the meantime, just mock the routeInfo\n if (this.initialState) {\n this.rootState = this.initialState;\n this.routeInfo = this.getRouteInfo(this.initialState);\n } else {\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigation's state changes and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n requestAnimationFrame(\n () =>\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_maybeHideAsync?.()\n );\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!deepEqual(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: [],\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, initialLocation: URL | undefined) {\n const navigationRef = useNavigationContainerRef();\n useMemo(\n () => store.initialize(context, navigationRef, initialLocation),\n [context, initialLocation]\n );\n useExpoRouter();\n return store;\n}\n"]}
@@ -2,9 +2,12 @@ import type { RouterStore } from './router-store';
2
2
  import { Href } from '../link/href';
3
3
  export declare function navigate(this: RouterStore, url: Href): any;
4
4
  export declare function push(this: RouterStore, url: Href): any;
5
+ export declare function dismiss(this: RouterStore, count?: number): void;
5
6
  export declare function replace(this: RouterStore, url: Href): any;
7
+ export declare function dismissAll(this: RouterStore): void;
6
8
  export declare function goBack(this: RouterStore): void;
7
9
  export declare function canGoBack(this: RouterStore): boolean;
10
+ export declare function canDismiss(this: RouterStore): boolean;
8
11
  export declare function setParams(this: RouterStore, params?: Record<string, string | number>): any;
9
12
  export declare function linkTo(this: RouterStore, href: string, event?: string): void;
10
13
  //# sourceMappingURL=routing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,IAAI,EAAe,MAAM,cAAc,CAAC;AAYjD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,OAEpD;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,OAEhD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,OAEnD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,QAGvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAUpD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAM,OAGxF;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,QAgErE"}
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,IAAI,EAAe,MAAM,cAAc,CAAC;AAYjD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,OAEpD;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,OAEhD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,MAAM,QAExD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,OAEnD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,QAE3C;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,QAGvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAUpD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAcrD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAM,OAGxF;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,QAgErE"}
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.linkTo = exports.setParams = exports.canGoBack = exports.goBack = exports.replace = exports.push = exports.navigate = void 0;
26
+ exports.linkTo = exports.setParams = exports.canDismiss = exports.canGoBack = exports.goBack = exports.dismissAll = exports.replace = exports.dismiss = exports.push = exports.navigate = void 0;
27
+ const native_1 = require("@react-navigation/native");
27
28
  const Linking = __importStar(require("expo-linking"));
28
29
  const href_1 = require("../link/href");
29
30
  const path_1 = require("../link/path");
@@ -41,10 +42,18 @@ function push(url) {
41
42
  return this.linkTo((0, href_1.resolveHref)(url), 'PUSH');
42
43
  }
43
44
  exports.push = push;
45
+ function dismiss(count) {
46
+ this.navigationRef?.dispatch(native_1.StackActions.pop(count));
47
+ }
48
+ exports.dismiss = dismiss;
44
49
  function replace(url) {
45
50
  return this.linkTo((0, href_1.resolveHref)(url), 'REPLACE');
46
51
  }
47
52
  exports.replace = replace;
53
+ function dismissAll() {
54
+ this.navigationRef?.dispatch(native_1.StackActions.popToTop());
55
+ }
56
+ exports.dismissAll = dismissAll;
48
57
  function goBack() {
49
58
  assertIsReady(this);
50
59
  this.navigationRef?.current?.goBack();
@@ -62,6 +71,20 @@ function canGoBack() {
62
71
  return this.navigationRef?.current?.canGoBack() ?? false;
63
72
  }
64
73
  exports.canGoBack = canGoBack;
74
+ function canDismiss() {
75
+ let state = this.rootState;
76
+ // Keep traversing down the state tree until we find a stack navigator that we can pop
77
+ while (state) {
78
+ if (state.type === 'stack' && state.routes.length > 1) {
79
+ return true;
80
+ }
81
+ if (state.index === undefined)
82
+ return false;
83
+ state = state.routes?.[state.index]?.state;
84
+ }
85
+ return false;
86
+ }
87
+ exports.canDismiss = canDismiss;
65
88
  function setParams(params = {}) {
66
89
  assertIsReady(this);
67
90
  return (this.navigationRef?.current?.setParams)(params);
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwC;AAIxC,uCAAiD;AACjD,uCAAuC;AACvC,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;AAED,SAAgB,QAAQ,CAAoB,GAAS;IACnD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;AACnD,CAAC;AAFD,4BAEC;AAED,SAAgB,IAAI,CAAoB,GAAS;IAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC;AAFD,oBAEC;AAED,SAAgB,OAAO,CAAoB,GAAS;IAClD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAA,kBAAW,EAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC;AAFD,0BAEC;AAED,SAAgB,MAAM;IACpB,aAA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KAAK,CAAC,IAAI,CAAC,CAAC;IAC/F,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC;IAE9E,wFAAwF;IACxF,IAAI,KAAK,CAAC,KAAK,IAAI,cAAc,IAAI,YAAY,CAAC,KAAK,EAAE;QACvD,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,KAAY,EAAE,IAAI,CAAC,CAAC;KACxE;IAED,mFAAmF;IACnF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,8BAA8B,CAAC,KAAK,CAAC,CAAC;IAEjE,IAAI,IAAI,KAAK,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,OAAO,EAAE;QACnD,IAAI,GAAG,UAAU,CAAC;KACnB;SAAM,IAAI,IAAI,KAAK,SAAS,IAAI,WAAW,CAAC,IAAI,KAAK,KAAK,EAAE;QAC3D,IAAI,GAAG,SAAS,CAAC;KAClB;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,WAAW,CAAC,GAAG;QACvB,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,MAAM;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { type NavigationState } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\n\nimport type { RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { Href, resolveHref } from '../link/href';\nimport { resolve } from '../link/path';\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 function navigate(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url), 'NAVIGATE');\n}\n\nexport function push(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url), 'PUSH');\n}\n\nexport function replace(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url), 'REPLACE');\n}\n\nexport function goBack(this: RouterStore) {\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\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 setParams(this: RouterStore, params: Record<string, string | number> = {}) {\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport function linkTo(this: RouterStore, href: string, event?: string) {\n if (shouldLinkExternally(href)) {\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 if (href.startsWith('.')) {\n // Resolve base path by merging the current segments with the params\n let base =\n this.routeInfo?.segments\n ?.map((segment) => {\n if (!segment.startsWith('[')) return segment;\n\n if (segment.startsWith('[...')) {\n segment = segment.slice(4, -1);\n const params = this.routeInfo?.params?.[segment];\n if (Array.isArray(params)) {\n return params.join('/');\n } else {\n return params?.split(',')?.join('/') ?? '';\n }\n } else {\n segment = segment.slice(1, -1);\n return this.routeInfo?.params?.[segment];\n }\n })\n .filter(Boolean)\n .join('/') ?? '/';\n\n if (!this.routeInfo?.isIndex) {\n base += '/..';\n }\n\n href = resolve(base, href);\n }\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(getNavigateAction(state, rootState, event));\n}\n\ntype NavigationParams = Partial<{\n screen: string;\n params: NavigationParams;\n}>;\n\nfunction rewriteNavigationStateToParams(\n state?: { routes: ResultState['routes'] } | NavigationState,\n params: NavigationParams = {}\n) {\n if (!state) return params;\n // We Should always have at least one route in the state\n const lastRoute = state.routes[state.routes.length - 1]!;\n params.screen = lastRoute.name;\n // Weirdly, this always needs to be an object. If it's undefined, it won't work.\n params.params = lastRoute.params ? JSON.parse(JSON.stringify(lastRoute.params)) : {};\n\n if (lastRoute.state) {\n rewriteNavigationStateToParams(lastRoute.state, params.params);\n }\n\n return JSON.parse(JSON.stringify(params));\n}\n\nfunction getNavigateAction(state: ResultState, parentState: NavigationState, type = 'NAVIGATE') {\n const route = state.routes[state.routes.length - 1]!;\n\n const currentRoute = parentState.routes.find((parentRoute) => parentRoute.name === route.name);\n const routesAreEqual = parentState.routes[parentState.index] === currentRoute;\n\n // If there is nested state and the routes are equal, we should keep going down the tree\n if (route.state && routesAreEqual && currentRoute.state) {\n return getNavigateAction(route.state, currentRoute.state as any, type);\n }\n\n // Either we reached the bottom of the state or the point where the routes diverged\n const { screen, params } = rewriteNavigationStateToParams(state);\n\n if (type === 'PUSH' && parentState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (type === 'REPLACE' && parentState.type === 'tab') {\n type = 'JUMP_TO';\n }\n\n return {\n type,\n target: parentState.key,\n payload: {\n name: screen,\n params,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA8E;AAC9E,sDAAwC;AAIxC,uCAAiD;AACjD,uCAAuC;AACvC,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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M,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC;IAE9E,wFAAwF;IACxF,IAAI,KAAK,CAAC,KAAK,IAAI,cAAc,IAAI,YAAY,CAAC,KAAK,EAAE;QACvD,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,KAAY,EAAE,IAAI,CAAC,CAAC;KACxE;IAED,mFAAmF;IACnF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,8BAA8B,CAAC,KAAK,CAAC,CAAC;IAEjE,IAAI,IAAI,KAAK,MAAM,IAAI,WAAW,CAAC,IAAI,KAAK,OAAO,EAAE;QACnD,IAAI,GAAG,UAAU,CAAC;KACnB;SAAM,IAAI,IAAI,KAAK,SAAS,IAAI,WAAW,CAAC,IAAI,KAAK,KAAK,EAAE;QAC3D,IAAI,GAAG,SAAS,CAAC;KAClB;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,WAAW,CAAC,GAAG;QACvB,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,MAAM;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { StackActions, type NavigationState } from '@react-navigation/native';\nimport * as Linking from 'expo-linking';\n\nimport type { RouterStore } from './router-store';\nimport { ResultState } from '../fork/getStateFromPath';\nimport { Href, resolveHref } from '../link/href';\nimport { resolve } from '../link/path';\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 function navigate(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url), 'NAVIGATE');\n}\n\nexport function push(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url), 'PUSH');\n}\n\nexport function dismiss(this: RouterStore, count?: number) {\n this.navigationRef?.dispatch(StackActions.pop(count));\n}\n\nexport function replace(this: RouterStore, url: Href) {\n return this.linkTo(resolveHref(url), 'REPLACE');\n}\n\nexport function dismissAll(this: RouterStore) {\n this.navigationRef?.dispatch(StackActions.popToTop());\n}\n\nexport function goBack(this: RouterStore) {\n assertIsReady(this);\n this.navigationRef?.current?.goBack();\n}\n\nexport function canGoBack(this: RouterStore): boolean {\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 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(this: RouterStore, params: Record<string, string | number> = {}) {\n assertIsReady(this);\n return (this.navigationRef?.current?.setParams as any)(params);\n}\n\nexport function linkTo(this: RouterStore, href: string, event?: string) {\n if (shouldLinkExternally(href)) {\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 if (href.startsWith('.')) {\n // Resolve base path by merging the current segments with the params\n let base =\n this.routeInfo?.segments\n ?.map((segment) => {\n if (!segment.startsWith('[')) return segment;\n\n if (segment.startsWith('[...')) {\n segment = segment.slice(4, -1);\n const params = this.routeInfo?.params?.[segment];\n if (Array.isArray(params)) {\n return params.join('/');\n } else {\n return params?.split(',')?.join('/') ?? '';\n }\n } else {\n segment = segment.slice(1, -1);\n return this.routeInfo?.params?.[segment];\n }\n })\n .filter(Boolean)\n .join('/') ?? '/';\n\n if (!this.routeInfo?.isIndex) {\n base += '/..';\n }\n\n href = resolve(base, href);\n }\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(getNavigateAction(state, rootState, event));\n}\n\ntype NavigationParams = Partial<{\n screen: string;\n params: NavigationParams;\n}>;\n\nfunction rewriteNavigationStateToParams(\n state?: { routes: ResultState['routes'] } | NavigationState,\n params: NavigationParams = {}\n) {\n if (!state) return params;\n // We Should always have at least one route in the state\n const lastRoute = state.routes[state.routes.length - 1]!;\n params.screen = lastRoute.name;\n // Weirdly, this always needs to be an object. If it's undefined, it won't work.\n params.params = lastRoute.params ? JSON.parse(JSON.stringify(lastRoute.params)) : {};\n\n if (lastRoute.state) {\n rewriteNavigationStateToParams(lastRoute.state, params.params);\n }\n\n return JSON.parse(JSON.stringify(params));\n}\n\nfunction getNavigateAction(state: ResultState, parentState: NavigationState, type = 'NAVIGATE') {\n const route = state.routes[state.routes.length - 1]!;\n\n const currentRoute = parentState.routes.find((parentRoute) => parentRoute.name === route.name);\n const routesAreEqual = parentState.routes[parentState.index] === currentRoute;\n\n // If there is nested state and the routes are equal, we should keep going down the tree\n if (route.state && routesAreEqual && currentRoute.state) {\n return getNavigateAction(route.state, currentRoute.state as any, type);\n }\n\n // Either we reached the bottom of the state or the point where the routes diverged\n const { screen, params } = rewriteNavigationStateToParams(state);\n\n if (type === 'PUSH' && parentState.type !== 'stack') {\n type = 'NAVIGATE';\n } else if (type === 'REPLACE' && parentState.type === 'tab') {\n type = 'JUMP_TO';\n }\n\n return {\n type,\n target: parentState.key,\n payload: {\n name: screen,\n params,\n },\n };\n}\n"]}
@@ -20,7 +20,7 @@ export type UserActivity = {
20
20
  dateModified?: Date;
21
21
  expirationDate?: Date;
22
22
  };
23
- export declare const ExpoHead: {
23
+ declare let ExpoHead: {
24
24
  activities: {
25
25
  INDEXED_ROUTE: string;
26
26
  };
@@ -30,4 +30,5 @@ export declare const ExpoHead: {
30
30
  suspendActivity(id: string): void;
31
31
  revokeActivity(id: string): void;
32
32
  } | null;
33
+ export { ExpoHead };
33
34
  //# sourceMappingURL=ExpoHeadModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoHeadModule.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHeadModule.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB,YAAY,EAAE,MAAM,CAAC;IAErB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,cAAc,CAAC,EAAE,IAAI,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE;IACrB,UAAU,EAAE;QACV,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,iBAAiB,IAAI,YAAY,CAAC;IAClC,cAAc,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IACj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AI,CAAC,CAAC;IACnD,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,GAAG,IAAW,CAAC;AAOhB,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -3,5 +3,10 @@
3
3
  // https://developer.apple.com/documentation/foundation/nsuseractivity/2980674-iseligibleforprediction
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.ExpoHead = void 0;
6
- exports.ExpoHead = null;
6
+ let ExpoHead = null;
7
+ exports.ExpoHead = ExpoHead;
8
+ // If running in Expo Go.
9
+ if (typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo) {
10
+ exports.ExpoHead = ExpoHead = globalThis.expo?.modules?.ExpoHead;
11
+ }
7
12
  //# sourceMappingURL=ExpoHeadModule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoHeadModule.js","sourceRoot":"","sources":["../../src/head/ExpoHeadModule.ts"],"names":[],"mappings":";AAAA,0BAA0B;AAC1B,sGAAsG;;;AA+BzF,QAAA,QAAQ,GASV,IAAI,CAAC","sourcesContent":["// isEligibleForPrediction\n// https://developer.apple.com/documentation/foundation/nsuseractivity/2980674-iseligibleforprediction\n\nexport type UserActivity = {\n id?: string;\n /**\n * The activity title should be clear and concise. This text describes the content of the link, like “Photo taken on July 27, 2020” or “Conversation with Maria”. Use nouns for activity titles.\n */\n title?: string;\n description?: string;\n webpageURL?: string;\n keywords?: string[];\n // TODO: Get this automatically somehow\n activityType: string;\n // TODO: Maybe something like robots.txt?\n phrase?: string;\n\n thumbnailURL?: string;\n\n userInfo?: Record<string, string>;\n\n isEligibleForHandoff?: boolean;\n isEligibleForPrediction?: boolean;\n isEligibleForSearch?: boolean;\n\n /** Local file path for an image */\n imageUrl?: string;\n darkImageUrl?: string;\n dateModified?: Date;\n expirationDate?: Date;\n};\n\nexport const ExpoHead: {\n activities: {\n INDEXED_ROUTE: string;\n };\n getLaunchActivity(): UserActivity;\n createActivity(userActivity: UserActivity): void;\n clearActivitiesAsync(ids: string[]): Promise<void>;\n suspendActivity(id: string): void;\n revokeActivity(id: string): void;\n} | null = null;\n"]}
1
+ {"version":3,"file":"ExpoHeadModule.js","sourceRoot":"","sources":["../../src/head/ExpoHeadModule.ts"],"names":[],"mappings":";AAAA,0BAA0B;AAC1B,sGAAsG;;;AA+BtG,IAAI,QAAQ,GASD,IAAI,CAAC;AAOP,4BAAQ;AALjB,yBAAyB;AACzB,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE;IACnE,mBAAA,QAAQ,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC;CAC/C","sourcesContent":["// isEligibleForPrediction\n// https://developer.apple.com/documentation/foundation/nsuseractivity/2980674-iseligibleforprediction\n\nexport type UserActivity = {\n id?: string;\n /**\n * The activity title should be clear and concise. This text describes the content of the link, like “Photo taken on July 27, 2020” or “Conversation with Maria”. Use nouns for activity titles.\n */\n title?: string;\n description?: string;\n webpageURL?: string;\n keywords?: string[];\n // TODO: Get this automatically somehow\n activityType: string;\n // TODO: Maybe something like robots.txt?\n phrase?: string;\n\n thumbnailURL?: string;\n\n userInfo?: Record<string, string>;\n\n isEligibleForHandoff?: boolean;\n isEligibleForPrediction?: boolean;\n isEligibleForSearch?: boolean;\n\n /** Local file path for an image */\n imageUrl?: string;\n darkImageUrl?: string;\n dateModified?: Date;\n expirationDate?: Date;\n};\n\nlet ExpoHead: {\n activities: {\n INDEXED_ROUTE: string;\n };\n getLaunchActivity(): UserActivity;\n createActivity(userActivity: UserActivity): void;\n clearActivitiesAsync(ids: string[]): Promise<void>;\n suspendActivity(id: string): void;\n revokeActivity(id: string): void;\n} | null = null;\n\n// If running in Expo Go.\nif (typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo) {\n ExpoHead = globalThis.expo?.modules?.ExpoHead;\n}\n\nexport { ExpoHead };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,wBAAgB,sBAAsB,kDAErC;AAED,wBAAgB,YAAY,2CAE3B;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,oGAEhC;AAED,uJAAuJ;AACvJ,wBAAgB,yBAAyB,wGAExC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAalC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,KAAK,SAAS,CAE9E;AAED,kEAAkE;AAClE,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAEpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAwBpB"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,wBAAgB,sBAAsB,kDAErC;AAED,wBAAgB,YAAY,2CAE3B;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,oGAEhC;AAED,uJAAuJ;AACvJ,wBAAgB,yBAAyB,wGAExC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAgBlC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,KAAK,SAAS,CAE9E;AAED,kEAAkE;AAClE,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAEpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,YAAY,GAAG,YAAY,KACxC,OAAO,CAAC,OAAO,CAAC,CAwBpB"}
package/build/hooks.js CHANGED
@@ -28,6 +28,9 @@ exports.useNavigationContainerRef = useNavigationContainerRef;
28
28
  function useRouter() {
29
29
  return react_1.default.useMemo(() => ({
30
30
  push: router_store_1.store.push,
31
+ dismiss: router_store_1.store.dismiss,
32
+ dismissAll: router_store_1.store.dismissAll,
33
+ canDismiss: router_store_1.store.canDismiss,
31
34
  back: router_store_1.store.goBack,
32
35
  replace: router_store_1.store.replace,
33
36
  setParams: router_store_1.store.setParams,
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAkE;AAClE,kDAA0B;AAE1B,8DAA0F;AAK1F,SAAgB,sBAAsB;IACpC,OAAO,IAAA,gCAAiB,GAAE,CAAC;AAC7B,CAAC;AAFD,wDAEC;AAED,SAAgB,YAAY;IAC1B,OAAO,IAAA,gCAAiB,GAAE,CAAC;AAC7B,CAAC;AAFD,oCAEC;AAED,wFAAwF;AACxF,SAAgB,iBAAiB;IAC/B,OAAO,oBAAK,CAAC,aAAa,CAAC,OAAO,CAAC;AACrC,CAAC;AAFD,8CAEC;AAED,uJAAuJ;AACvJ,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AAK,CAAC,EAAE;YACxB,OAAO;gBACL,GAAG;gBACH,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACd,IAAI;wBACF,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;qBAC9B;oBAAC,MAAM;wBACN,OAAO,CAAC,CAAC;qBACV;gBACH,CAAC,CAAC;aACH,CAAC;SACH;aAAM;YACL,IAAI;gBACF,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,KAAe,CAAC,CAAC,CAAC;aACnD;YAAC,MAAM;gBACN,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC,CAAC,CACiB,CAAC;AACxB,CAAC;AA1BD,oDA0BC","sourcesContent":["import { NavigationRouteContext } from '@react-navigation/native';\nimport React from 'react';\n\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './types';\n\ntype SearchParams = Record<string, string | string[]>;\n\nexport function useRootNavigationState() {\n return useStoreRootState();\n}\n\nexport function useRouteInfo() {\n return useStoreRouteInfo();\n}\n\n/** @deprecated use `useNavigationContainerRef()` instead, which returns a React ref. */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/** @return the root `<NavigationContainer />` ref for the app. The `ref.current` may be `null` if the `<NavigationContainer />` hasn't mounted yet. */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\nexport function useRouter(): Router {\n return React.useMemo(\n () => ({\n push: store.push,\n back: store.goBack,\n replace: store.replace,\n setParams: store.setParams,\n canGoBack: store.canGoBack,\n navigate: store.navigate,\n // TODO(EvanBacon): add `reload`\n }),\n []\n );\n}\n\n/**\n * @private\n * @returns the current global pathname with query params attached. This may change in the future to include the hostname from a predefined universal link, i.e. `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`\n */\nexport function useUnstableGlobalHref(): string {\n return useStoreRouteInfo().unstable_globalHref;\n}\n\n/**\n * Get a list of selected file segments for the currently selected route. Segments are not normalized, so they will be the same as the file path. e.g. /[id]?id=normal -> [\"[id]\"]\n *\n * `useSegments` can be typed using an abstract.\n * Consider the following file structure, and strictly typed `useSegments` function:\n *\n * ```md\n * - app\n * - [user]\n * - index.js\n * - followers.js\n * - settings.js\n * ```\n * This can be strictly typed using the following abstract:\n *\n * ```ts\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends string[] = string[]>(): TSegments {\n return useStoreRouteInfo().segments as TSegments;\n}\n\n/** @returns global selected pathname without query parameters. */\nexport function usePathname(): string {\n return useStoreRouteInfo().pathname;\n}\n\n/**\n * Get the globally selected query parameters, including dynamic path segments. This function will update even when the route is not focused.\n * Useful for analytics or other background operations that don't draw to the screen.\n *\n * When querying search params in a stack, opt-towards using `useLocalSearchParams` as these will only\n * update when the route is focused.\n *\n * @see `useLocalSearchParams`\n */\nexport function useGlobalSearchParams<\n TParams extends SearchParams = SearchParams,\n>(): Partial<TParams> {\n return useStoreRouteInfo().params as Partial<TParams>;\n}\n\n/**\n * Returns the URL search parameters for the contextually focused route. e.g. `/acme?foo=bar` -> `{ foo: \"bar\" }`.\n * This is useful for stacks where you may push a new screen that changes the query parameters.\n *\n * To observe updates even when the invoking route is not focused, use `useGlobalSearchParams()`.\n */\nexport function useLocalSearchParams<\n TParams extends SearchParams = SearchParams,\n>(): Partial<TParams> {\n const params = React.useContext(NavigationRouteContext)?.params ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as Partial<TParams>;\n}\n"]}
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAkE;AAClE,kDAA0B;AAE1B,8DAA0F;AAK1F,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;;GAQG;AACH,SAAgB,qBAAqB;IAGnC,OAAO,IAAA,gCAAiB,GAAE,CAAC,MAA0B,CAAC;AACxD,CAAC;AAJD,sDAIC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB;IAGlC,MAAM,MAAM,GAAG,eAAK,CAAC,UAAU,CAAC,+BAAsB,CAAC,EAAE,MAAM,IAAI,EAAE,CAAC;IACtE,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,OAAO;gBACL,GAAG;gBACH,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACd,IAAI;wBACF,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;qBAC9B;oBAAC,MAAM;wBACN,OAAO,CAAC,CAAC;qBACV;gBACH,CAAC,CAAC;aACH,CAAC;SACH;aAAM;YACL,IAAI;gBACF,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,KAAe,CAAC,CAAC,CAAC;aACnD;YAAC,MAAM;gBACN,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC,CAAC,CACiB,CAAC;AACxB,CAAC;AA1BD,oDA0BC","sourcesContent":["import { NavigationRouteContext } from '@react-navigation/native';\nimport React from 'react';\n\nimport { store, useStoreRootState, useStoreRouteInfo } from './global-state/router-store';\nimport { Router } from './types';\n\ntype SearchParams = Record<string, string | string[]>;\n\nexport function useRootNavigationState() {\n return useStoreRootState();\n}\n\nexport function useRouteInfo() {\n return useStoreRouteInfo();\n}\n\n/** @deprecated use `useNavigationContainerRef()` instead, which returns a React ref. */\nexport function useRootNavigation() {\n return store.navigationRef.current;\n}\n\n/** @return the root `<NavigationContainer />` ref for the app. The `ref.current` may be `null` if the `<NavigationContainer />` hasn't mounted yet. */\nexport function useNavigationContainerRef() {\n return store.navigationRef;\n}\n\nexport function useRouter(): Router {\n return React.useMemo(\n () => ({\n push: store.push,\n dismiss: store.dismiss,\n dismissAll: store.dismissAll,\n canDismiss: store.canDismiss,\n back: store.goBack,\n replace: store.replace,\n setParams: store.setParams,\n canGoBack: store.canGoBack,\n navigate: store.navigate,\n // TODO(EvanBacon): add `reload`\n }),\n []\n );\n}\n\n/**\n * @private\n * @returns the current global pathname with query params attached. This may change in the future to include the hostname from a predefined universal link, i.e. `/foobar?hey=world` becomes `https://acme.dev/foobar?hey=world`\n */\nexport function useUnstableGlobalHref(): string {\n return useStoreRouteInfo().unstable_globalHref;\n}\n\n/**\n * Get a list of selected file segments for the currently selected route. Segments are not normalized, so they will be the same as the file path. e.g. /[id]?id=normal -> [\"[id]\"]\n *\n * `useSegments` can be typed using an abstract.\n * Consider the following file structure, and strictly typed `useSegments` function:\n *\n * ```md\n * - app\n * - [user]\n * - index.js\n * - followers.js\n * - settings.js\n * ```\n * This can be strictly typed using the following abstract:\n *\n * ```ts\n * const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()\n * ```\n */\nexport function useSegments<TSegments extends string[] = string[]>(): TSegments {\n return useStoreRouteInfo().segments as TSegments;\n}\n\n/** @returns global selected pathname without query parameters. */\nexport function usePathname(): string {\n return useStoreRouteInfo().pathname;\n}\n\n/**\n * Get the globally selected query parameters, including dynamic path segments. This function will update even when the route is not focused.\n * Useful for analytics or other background operations that don't draw to the screen.\n *\n * When querying search params in a stack, opt-towards using `useLocalSearchParams` as these will only\n * update when the route is focused.\n *\n * @see `useLocalSearchParams`\n */\nexport function useGlobalSearchParams<\n TParams extends SearchParams = SearchParams,\n>(): Partial<TParams> {\n return useStoreRouteInfo().params as Partial<TParams>;\n}\n\n/**\n * Returns the URL search parameters for the contextually focused route. e.g. `/acme?foo=bar` -> `{ foo: \"bar\" }`.\n * This is useful for stacks where you may push a new screen that changes the query parameters.\n *\n * To observe updates even when the invoking route is not focused, use `useGlobalSearchParams()`.\n */\nexport function useLocalSearchParams<\n TParams extends SearchParams = SearchParams,\n>(): Partial<TParams> {\n const params = React.useContext(NavigationRouteContext)?.params ?? {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => {\n if (Array.isArray(value)) {\n return [\n key,\n value.map((v) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n }),\n ];\n } else {\n try {\n return [key, decodeURIComponent(value as string)];\n } catch {\n return [key, value];\n }\n }\n })\n ) as Partial<TParams>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"imperative-api.d.ts","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,eAAO,MAAM,MAAM,EAAE,MAOpB,CAAC"}
1
+ {"version":3,"file":"imperative-api.d.ts","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,eAAO,MAAM,MAAM,EAAE,MAUpB,CAAC"}
@@ -5,6 +5,9 @@ const router_store_1 = require("./global-state/router-store");
5
5
  exports.router = {
6
6
  navigate: (href) => router_store_1.store.navigate(href),
7
7
  push: (href) => router_store_1.store.push(href),
8
+ dismiss: (count) => router_store_1.store.dismiss(count),
9
+ dismissAll: () => router_store_1.store.dismissAll(),
10
+ canDismiss: () => router_store_1.store.canDismiss(),
8
11
  replace: (href) => router_store_1.store.replace(href),
9
12
  back: () => router_store_1.store.goBack(),
10
13
  canGoBack: () => router_store_1.store.canGoBack(),
@@ -1 +1 @@
1
- {"version":3,"file":"imperative-api.js","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":";;;AAAA,8DAAoD;AAGvC,QAAA,MAAM,GAAW;IAC5B,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;IACxC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,IAAI,CAAC;IACtC,IAAI,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,SAAS,EAAE;IAClC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAK,CAAC,SAAS,CAAC,MAAM,CAAC;CAC/C,CAAC","sourcesContent":["import { store } from './global-state/router-store';\nimport { Router } from './types';\n\nexport const router: Router = {\n navigate: (href) => store.navigate(href),\n push: (href) => store.push(href),\n replace: (href) => store.replace(href),\n back: () => store.goBack(),\n canGoBack: () => store.canGoBack(),\n setParams: (params) => store.setParams(params),\n};\n"]}
1
+ {"version":3,"file":"imperative-api.js","sourceRoot":"","sources":["../src/imperative-api.ts"],"names":[],"mappings":";;;AAAA,8DAAoD;AAGvC,QAAA,MAAM,GAAW;IAC5B,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;IACxC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IACxC,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,UAAU,EAAE;IACpC,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,UAAU,EAAE;IACpC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAK,CAAC,OAAO,CAAC,IAAI,CAAC;IACtC,IAAI,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,GAAG,EAAE,CAAC,oBAAK,CAAC,SAAS,EAAE;IAClC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAK,CAAC,SAAS,CAAC,MAAM,CAAC;CAC/C,CAAC","sourcesContent":["import { store } from './global-state/router-store';\nimport { Router } from './types';\n\nexport const router: Router = {\n navigate: (href) => store.navigate(href),\n push: (href) => store.push(href),\n dismiss: (count) => store.dismiss(count),\n dismissAll: () => store.dismissAll(),\n canDismiss: () => store.canDismiss(),\n replace: (href) => store.replace(href),\n back: () => store.goBack(),\n canGoBack: () => store.canGoBack(),\n setParams: (params) => store.setParams(params),\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":"AAKA,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAOxD,wBAAgB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,CA8C/D;AAID,wBAAgB,UAAU,IAAI,MAAM,CAKnC;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,cA4B/D;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":"AAIA,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AASxD,wBAAgB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,CA8C/D;AAID,wBAAgB,UAAU,IAAI,MAAM,CAKnC;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,cA4B/D;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
@@ -27,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.getPathFromState = exports.getStateFromPath = exports.addEventListener = exports.getRootURL = exports.getInitialURL = void 0;
30
- const expo_constants_1 = __importStar(require("expo-constants"));
31
30
  const Linking = __importStar(require("expo-linking"));
32
31
  const react_native_1 = require("react-native");
33
32
  const extractPathFromURL_1 = require("../fork/extractPathFromURL");
@@ -35,6 +34,7 @@ const getPathFromState_1 = __importDefault(require("../fork/getPathFromState"));
35
34
  exports.getPathFromState = getPathFromState_1.default;
36
35
  const getStateFromPath_1 = __importDefault(require("../fork/getStateFromPath"));
37
36
  exports.getStateFromPath = getStateFromPath_1.default;
37
+ const isExpoGo = typeof expo !== 'undefined' && globalThis.expo?.modules?.ExpoGo;
38
38
  // A custom getInitialURL is used on native to ensure the app always starts at
39
39
  // the root path if it's launched from something other than a deep link.
40
40
  // This helps keep the native functionality working like the web functionality.
@@ -58,7 +58,7 @@ function getInitialURL() {
58
58
  // NOTE(EvanBacon): This could probably be wrapped with the development boundary
59
59
  // since Expo Go is mostly just used in development.
60
60
  // Expo Go is weird and requires the root path to be `/--/`
61
- if (url && expo_constants_1.default.executionEnvironment === expo_constants_1.ExecutionEnvironment.StoreClient) {
61
+ if (url && isExpoGo) {
62
62
  const parsed = Linking.parse(url);
63
63
  // If the URL is defined (default in Expo Go dev apps) and the URL has no path:
64
64
  // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`
@@ -91,7 +91,7 @@ function getRootURL() {
91
91
  exports.getRootURL = getRootURL;
92
92
  function addEventListener(listener) {
93
93
  let callback = undefined;
94
- if (expo_constants_1.default.executionEnvironment === expo_constants_1.ExecutionEnvironment.StoreClient) {
94
+ if (isExpoGo) {
95
95
  // This extra work is only done in the Expo Go app.
96
96
  callback = ({ url }) => {
97
97
  const parsed = Linking.parse(url);
@@ -1 +1 @@
1
- {"version":3,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f;QACH,CAAC,CAAC;KACH;SAAM;QACL,QAAQ,GAAG,CAAC,EAAE,GAAG,EAAmB,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;KACxD;IACD,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAE/D,OAAO,GAAG,EAAE;QACV,2FAA2F;QAC3F,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC;AA5BD,4CA4BC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { adjustPathname } from '../fork/extractPathFromURL';\nimport getPathFromState from '../fork/getPathFromState';\nimport getStateFromPath from '../fork/getStateFromPath';\n\n// A custom getInitialURL is used on native to ensure the app always starts at\n// the root path if it's launched from something other than a deep link.\n// This helps keep the native functionality working like the web functionality.\n// For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`\n// then `/index` would be used on web and `/settings` would be used on native.\nexport function getInitialURL(): Promise<string | null> | string {\n if (process.env.NODE_ENV === 'test') {\n return Linking.getInitialURL() ?? getRootURL();\n }\n\n if (Platform.OS === 'web') {\n if (typeof window === 'undefined') {\n return '';\n } else if (typeof window.location?.href === 'string') {\n return window.location.href;\n }\n }\n return Promise.race<string>([\n (async () => {\n const url = await Linking.getInitialURL();\n\n // NOTE(EvanBacon): This could probably be wrapped with the development boundary\n // since Expo Go is mostly just used in development.\n\n // Expo Go is weird and requires the root path to be `/--/`\n if (url && Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n const parsed = Linking.parse(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (\n parsed.path === null ||\n ['', '/'].includes(\n adjustPathname({\n hostname: parsed.hostname,\n pathname: parsed.path,\n })\n )\n ) {\n return getRootURL();\n }\n }\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n return url ?? getRootURL();\n })(),\n new Promise<string>((resolve) =>\n // Timeout in 150ms if `getInitialState` doesn't resolve\n // Workaround for https://github.com/facebook/react-native/issues/25675\n setTimeout(() => resolve(getRootURL()), 150)\n ),\n ]);\n}\n\nlet _rootURL: string | undefined;\n\nexport function getRootURL(): string {\n if (_rootURL === undefined) {\n _rootURL = Linking.createURL('/');\n }\n return _rootURL;\n}\n\nexport function addEventListener(listener: (url: string) => void) {\n let callback: (({ url }: { url: string }) => void) | undefined = undefined;\n\n if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n // This extra work is only done in the Expo Go app.\n callback = ({ url }: { url: string }) => {\n const parsed = Linking.parse(url);\n\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 (\n parsed.path === null ||\n ['', '/'].includes(adjustPathname({ hostname: parsed.hostname, pathname: parsed.path }))\n ) {\n listener(getRootURL());\n } else {\n listener(url);\n }\n };\n } else {\n callback = ({ url }: { url: string }) => listener(url);\n }\n const subscription = Linking.addEventListener('url', callback);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n subscription?.remove?.();\n };\n}\n\nexport { getStateFromPath, getPathFromState };\n"]}
1
+ {"version":3,"file":"linking.js","sourceRoot":"","sources":["../../src/link/linking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,+CAAwC;AAExC,mEAA4D;AAC5D,gFAAwD;AAiG7B,2BAjGpB,0BAAgB,CAiGoB;AAhG3C,gFAAwD;AAgG/C,2BAhGF,0BAAgB,CAgGE;AA9FzB,MAAM,QAAQ,GAAG,OAAO,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;AAEjF,8EAA8E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":["import * as Linking from 'expo-linking';\nimport { Platform } from 'react-native';\n\nimport { adjustPathname } from '../fork/extractPathFromURL';\nimport getPathFromState from '../fork/getPathFromState';\nimport getStateFromPath from '../fork/getStateFromPath';\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(): Promise<string | null> | string {\n if (process.env.NODE_ENV === 'test') {\n return Linking.getInitialURL() ?? getRootURL();\n }\n\n if (Platform.OS === 'web') {\n if (typeof window === 'undefined') {\n return '';\n } else if (typeof window.location?.href === 'string') {\n return window.location.href;\n }\n }\n return Promise.race<string>([\n (async () => {\n const url = await Linking.getInitialURL();\n\n // NOTE(EvanBacon): This could probably be wrapped with the development boundary\n // since Expo Go is mostly just used in development.\n\n // Expo Go is weird and requires the root path to be `/--/`\n if (url && isExpoGo) {\n const parsed = Linking.parse(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (\n parsed.path === null ||\n ['', '/'].includes(\n adjustPathname({\n hostname: parsed.hostname,\n pathname: parsed.path,\n })\n )\n ) {\n return getRootURL();\n }\n }\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n return url ?? getRootURL();\n })(),\n new Promise<string>((resolve) =>\n // Timeout in 150ms if `getInitialState` doesn't resolve\n // Workaround for https://github.com/facebook/react-native/issues/25675\n setTimeout(() => resolve(getRootURL()), 150)\n ),\n ]);\n}\n\nlet _rootURL: string | undefined;\n\nexport function getRootURL(): string {\n if (_rootURL === undefined) {\n _rootURL = Linking.createURL('/');\n }\n return _rootURL;\n}\n\nexport function addEventListener(listener: (url: string) => void) {\n let callback: (({ url }: { url: string }) => void) | undefined = undefined;\n\n if (isExpoGo) {\n // This extra work is only done in the Expo Go app.\n callback = ({ url }: { url: string }) => {\n const parsed = Linking.parse(url);\n\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 (\n parsed.path === null ||\n ['', '/'].includes(adjustPathname({ hostname: parsed.hostname, pathname: parsed.path }))\n ) {\n listener(getRootURL());\n } else {\n listener(url);\n }\n };\n } else {\n callback = ({ url }: { url: string }) => listener(url);\n }\n const subscription = Linking.addEventListener('url', callback);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n subscription?.remove?.();\n };\n}\n\nexport { getStateFromPath, getPathFromState };\n"]}
@@ -12,9 +12,9 @@ export declare function inMemoryContext(context: Record<string, FileStub>): ((id
12
12
  }) | {
13
13
  default: FileStub;
14
14
  }) & {
15
- keys: () => string[];
16
15
  resolve: (key: string) => string;
17
16
  id: string;
17
+ keys: () => string[];
18
18
  };
19
19
  export declare function requireContextWithOverrides(dir: string, overrides: Record<string, FileStub>): ((id: string) => any) & {
20
20
  keys: () => string[];
@@ -1 +1 @@
1
- {"version":3,"file":"context-stubs.d.ts","sourceRoot":"","sources":["../../src/testing-library/context-stubs.ts"],"names":[],"mappings":";AAEA,OAAO,cAAc,MAAM,4BAA4B,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;AACvE,MAAM,MAAM,QAAQ,GAChB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACzB,OAAO,EAAE,cAAc,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,CAAC,GACF,cAAc,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,SAE/C,MAAM;;;;;;;mBAMH,MAAM;;EAI1B;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,SAI1E,MAAM;;mBAUH,MAAM;;EAI1B"}
1
+ {"version":3,"file":"context-stubs.d.ts","sourceRoot":"","sources":["../../src/testing-library/context-stubs.ts"],"names":[],"mappings":";AAEA,OAAO,cAAc,MAAM,4BAA4B,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;AACvE,MAAM,MAAM,QAAQ,GAChB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACzB,OAAO,EAAE,cAAc,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,CAAC,GACF,cAAc,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,CAAC;AAI1B,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,SAE/C,MAAM;;;;;;mBAKH,MAAM;;;EAU1B;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,SAI1E,MAAM;;mBAUH,MAAM;;EAI1B"}
@@ -7,14 +7,19 @@ exports.requireContextWithOverrides = exports.inMemoryContext = exports.requireC
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const require_context_ponyfill_1 = __importDefault(require("./require-context-ponyfill"));
9
9
  exports.requireContext = require_context_ponyfill_1.default;
10
+ const validExtensions = ['.js', '.jsx', '.ts', '.tsx'];
10
11
  function inMemoryContext(context) {
11
12
  return Object.assign(function (id) {
12
- id = id.replace(/^\.\//, '').replace(/\.js$/, '');
13
+ id = id.replace(/^\.\//, '').replace(/\.\w*$/, '');
13
14
  return typeof context[id] === 'function' ? { default: context[id] } : context[id];
14
15
  }, {
15
- keys: () => Object.keys(context).map((key) => './' + key + '.js'),
16
16
  resolve: (key) => key,
17
17
  id: '0',
18
+ keys: () => Object.keys(context).map((key) => {
19
+ const ext = path_1.default.extname(key);
20
+ key = key.replace(/^\.\//, '');
21
+ return validExtensions.includes(ext) ? `./${key}` : `./${key}.js`;
22
+ }),
18
23
  });
19
24
  }
20
25
  exports.inMemoryContext = inMemoryContext;
@@ -1 +1 @@
1
- {"version":3,"file":"context-stubs.js","sourceRoot":"","sources":["../../src/testing-library/context-stubs.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,0FAAwD;AAU/C,yBAVF,kCAAc,CAUE;AAEvB,SAAgB,eAAe,CAAC,OAAiC;IAC/D,OAAO,MAAM,CAAC,MAAM,CAClB,UAAU,EAAU;QAClB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAClD,OAAO,OAAO,OAAO,CAAC,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC,EACD;QACE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC;QACjE,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG;QAC7B,EAAE,EAAE,GAAG;KACR,CACF,CAAC;AACJ,CAAC;AAZD,0CAYC;AAED,SAAgB,2BAA2B,CAAC,GAAW,EAAE,SAAmC;IAC1F,MAAM,eAAe,GAAG,IAAA,kCAAc,EAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAEzE,OAAO,MAAM,CAAC,MAAM,CAClB,UAAU,EAAU;QAClB,IAAI,EAAE,IAAI,SAAS,EAAE;YACnB,MAAM,KAAK,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;YAC5B,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;SACjE;aAAM;YACL,OAAO,eAAe,CAAC,EAAE,CAAC,CAAC;SAC5B;IACH,CAAC,EACD;QACE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC;QAClE,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG;QAC7B,EAAE,EAAE,GAAG;KACR,CACF,CAAC;AACJ,CAAC;AAlBD,kEAkBC","sourcesContent":["import path from 'path';\n\nimport requireContext from './require-context-ponyfill';\n\nexport type ReactComponent = () => React.ReactElement<any, any> | null;\nexport type FileStub =\n | (Record<string, unknown> & {\n default: ReactComponent;\n unstable_settings?: Record<string, any>;\n })\n | ReactComponent;\n\nexport { requireContext };\n\nexport function inMemoryContext(context: Record<string, FileStub>) {\n return Object.assign(\n function (id: string) {\n id = id.replace(/^\\.\\//, '').replace(/\\.js$/, '');\n return typeof context[id] === 'function' ? { default: context[id] } : context[id];\n },\n {\n keys: () => Object.keys(context).map((key) => './' + key + '.js'),\n resolve: (key: string) => key,\n id: '0',\n }\n );\n}\n\nexport function requireContextWithOverrides(dir: string, overrides: Record<string, FileStub>) {\n const existingContext = requireContext(path.resolve(process.cwd(), dir));\n\n return Object.assign(\n function (id: string) {\n if (id in overrides) {\n const route = overrides[id];\n return typeof route === 'function' ? { default: route } : route;\n } else {\n return existingContext(id);\n }\n },\n {\n keys: () => [...Object.keys(overrides), ...existingContext.keys()],\n resolve: (key: string) => key,\n id: '0',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"context-stubs.js","sourceRoot":"","sources":["../../src/testing-library/context-stubs.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,0FAAwD;AAU/C,yBAVF,kCAAc,CAUE;AAEvB,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEvD,SAAgB,eAAe,CAAC,OAAiC;IAC/D,OAAO,MAAM,CAAC,MAAM,CAClB,UAAU,EAAU;QAClB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACnD,OAAO,OAAO,OAAO,CAAC,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC,EACD;QACE,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG;QAC7B,EAAE,EAAE,GAAG;QACP,IAAI,EAAE,GAAG,EAAE,CACT,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC9B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC/B,OAAO,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC;QACpE,CAAC,CAAC;KACL,CACF,CAAC;AACJ,CAAC;AAjBD,0CAiBC;AAED,SAAgB,2BAA2B,CAAC,GAAW,EAAE,SAAmC;IAC1F,MAAM,eAAe,GAAG,IAAA,kCAAc,EAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAEzE,OAAO,MAAM,CAAC,MAAM,CAClB,UAAU,EAAU;QAClB,IAAI,EAAE,IAAI,SAAS,EAAE;YACnB,MAAM,KAAK,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;YAC5B,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;SACjE;aAAM;YACL,OAAO,eAAe,CAAC,EAAE,CAAC,CAAC;SAC5B;IACH,CAAC,EACD;QACE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC;QAClE,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG;QAC7B,EAAE,EAAE,GAAG;KACR,CACF,CAAC;AACJ,CAAC;AAlBD,kEAkBC","sourcesContent":["import path from 'path';\n\nimport requireContext from './require-context-ponyfill';\n\nexport type ReactComponent = () => React.ReactElement<any, any> | null;\nexport type FileStub =\n | (Record<string, unknown> & {\n default: ReactComponent;\n unstable_settings?: Record<string, any>;\n })\n | ReactComponent;\n\nexport { requireContext };\n\nconst validExtensions = ['.js', '.jsx', '.ts', '.tsx'];\n\nexport function inMemoryContext(context: Record<string, FileStub>) {\n return Object.assign(\n function (id: string) {\n id = id.replace(/^\\.\\//, '').replace(/\\.\\w*$/, '');\n return typeof context[id] === 'function' ? { default: context[id] } : context[id];\n },\n {\n resolve: (key: string) => key,\n id: '0',\n keys: () =>\n Object.keys(context).map((key) => {\n const ext = path.extname(key);\n key = key.replace(/^\\.\\//, '');\n return validExtensions.includes(ext) ? `./${key}` : `./${key}.js`;\n }),\n }\n );\n}\n\nexport function requireContextWithOverrides(dir: string, overrides: Record<string, FileStub>) {\n const existingContext = requireContext(path.resolve(process.cwd(), dir));\n\n return Object.assign(\n function (id: string) {\n if (id in overrides) {\n const route = overrides[id];\n return typeof route === 'function' ? { default: route } : route;\n } else {\n return existingContext(id);\n }\n },\n {\n keys: () => [...Object.keys(overrides), ...existingContext.keys()],\n resolve: (key: string) => key,\n id: '0',\n }\n );\n}\n"]}
@@ -11,10 +11,14 @@ type Result = ReturnType<typeof render> & {
11
11
  getSegments(): string[];
12
12
  getSearchParams(): Record<string, string | string[]>;
13
13
  };
14
- export declare function renderRouter(context?: string, options?: RenderRouterOptions): Result;
15
- export declare function renderRouter(context: Record<string, FileStub>, options?: RenderRouterOptions): Result;
16
- export declare function renderRouter(context: {
14
+ export type MockContextConfig = string | string[] | Record<string, FileStub> | {
17
15
  appDir: string;
18
16
  overrides: Record<string, FileStub>;
19
- }, options?: RenderRouterOptions): Result;
17
+ };
18
+ export declare function getMockConfig(context: MockContextConfig): {
19
+ initialRouteName?: string | undefined;
20
+ screens: Record<string, import("../getReactNavigationConfig").Screen>;
21
+ };
22
+ export declare function getMockContext(context: MockContextConfig): import("../types").RequireContext;
23
+ export declare function renderRouter(context?: MockContextConfig, { initialUrl, ...options }?: RenderRouterOptions): Result;
20
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing-library/index.tsx"],"names":[],"mappings":"AACA,OAAO,UAAU,CAAC;AAElB,OAAO,EAAE,MAAM,EAAgB,MAAM,+BAA+B,CAAC;AAIrE,OAAO,EACL,QAAQ,EAIT,MAAM,iBAAiB,CAAC;AASzB,cAAc,+BAA+B,CAAC;AAE9C,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG;IACxD,UAAU,CAAC,EAAE,GAAG,CAAC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,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;CACtD,CAAC;AAQF,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,MAAM,EAAE,GACR,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GACxB;IAEE,MAAM,EAAE,MAAM,CAAC;IAEf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACrC,CAAC;AAEN,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB;;;EAEvD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,iBAAiB,qCAYxD;AAED,wBAAgB,YAAY,CAC1B,OAAO,GAAE,iBAA2B,EACpC,EAAE,UAAgB,EAAE,GAAG,OAAO,EAAE,GAAE,mBAAwB,GACzD,MAAM,CAsCR"}
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.renderRouter = void 0;
20
+ exports.renderRouter = exports.getMockContext = exports.getMockConfig = void 0;
21
21
  /// <reference types="../../types/jest" />
22
22
  require("./expect");
23
23
  const react_native_1 = require("@testing-library/react-native");
@@ -28,28 +28,39 @@ const mocks_1 = require("./mocks");
28
28
  const ExpoRoot_1 = require("../ExpoRoot");
29
29
  const getPathFromState_1 = __importDefault(require("../fork/getPathFromState"));
30
30
  const getLinkingConfig_1 = require("../getLinkingConfig");
31
+ const getRoutes_1 = require("../getRoutes");
31
32
  const router_store_1 = require("../global-state/router-store");
32
33
  // re-export everything
33
34
  __exportStar(require("@testing-library/react-native"), exports);
34
35
  function isOverrideContext(context) {
35
36
  return Boolean(typeof context === 'object' && 'appDir' in context);
36
37
  }
37
- function renderRouter(context = './app', { initialUrl = '/', ...options } = {}) {
38
- jest.useFakeTimers();
39
- let ctx;
40
- // Reset the initial URL
41
- (0, mocks_1.setInitialUrl)(initialUrl);
42
- // Force the render to be synchronous
43
- process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';
38
+ function getMockConfig(context) {
39
+ return (0, getLinkingConfig_1.getNavigationConfig)((0, getRoutes_1.getExactRoutes)(getMockContext(context)));
40
+ }
41
+ exports.getMockConfig = getMockConfig;
42
+ function getMockContext(context) {
44
43
  if (typeof context === 'string') {
45
- ctx = (0, context_stubs_1.requireContext)(path_1.default.resolve(process.cwd(), context));
44
+ return (0, context_stubs_1.requireContext)(path_1.default.resolve(process.cwd(), context));
45
+ }
46
+ else if (Array.isArray(context)) {
47
+ return (0, context_stubs_1.inMemoryContext)(Object.fromEntries(context.map((filename) => [filename, { default: () => null }])));
46
48
  }
47
49
  else if (isOverrideContext(context)) {
48
- ctx = (0, context_stubs_1.requireContextWithOverrides)(context.appDir, context.overrides);
50
+ return (0, context_stubs_1.requireContextWithOverrides)(context.appDir, context.overrides);
49
51
  }
50
52
  else {
51
- ctx = (0, context_stubs_1.inMemoryContext)(context);
53
+ return (0, context_stubs_1.inMemoryContext)(context);
52
54
  }
55
+ }
56
+ exports.getMockContext = getMockContext;
57
+ function renderRouter(context = './app', { initialUrl = '/', ...options } = {}) {
58
+ jest.useFakeTimers();
59
+ const mockContext = getMockContext(context);
60
+ // Reset the initial URL
61
+ (0, mocks_1.setInitialUrl)(initialUrl);
62
+ // Force the render to be synchronous
63
+ process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';
53
64
  getLinkingConfig_1.stateCache.clear();
54
65
  let location;
55
66
  if (typeof initialUrl === 'string') {
@@ -58,7 +69,7 @@ function renderRouter(context = './app', { initialUrl = '/', ...options } = {})
58
69
  else if (initialUrl instanceof URL) {
59
70
  location = initialUrl;
60
71
  }
61
- const result = (0, react_native_1.render)(<ExpoRoot_1.ExpoRoot context={ctx} location={location}/>, {
72
+ const result = (0, react_native_1.render)(<ExpoRoot_1.ExpoRoot context={mockContext} location={location}/>, {
62
73
  ...options,
63
74
  });
64
75
  return Object.assign(result, {
@@ -1 +1 @@
1
- {"version":3,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SAAS,CAAC,CAAC;KAC3C;SAAM,IAAI,UAAU,YAAY,GAAG,EAAE;QACpC,QAAQ,GAAG,UAAU,CAAC;KACvB;IAED,MAAM,MAAM,GAAG,IAAA,qBAAM,EAAC,CAAC,mBAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAG,EAAE;QACpE,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3B,WAAW;YACT,OAAO,oBAAK,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC;QAC5C,CAAC;QACD,WAAW;YACT,OAAO,oBAAK,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC;QAC5C,CAAC;QACD,eAAe;YACb,OAAO,oBAAK,CAAC,iBAAiB,EAAE,CAAC,MAAM,CAAC;QAC1C,CAAC;QACD,qBAAqB;YACnB,OAAO,IAAA,0BAAgB,EAAC,oBAAK,CAAC,SAAU,EAAE,oBAAK,CAAC,OAAQ,CAAC,MAAM,CAAC,CAAC;QACnE,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAtDD,oCAsDC","sourcesContent":["/// <reference types=\"../../types/jest\" />\nimport './expect';\n\nimport { render, RenderResult } from '@testing-library/react-native';\nimport path from 'path';\nimport React from 'react';\n\nimport {\n FileStub,\n inMemoryContext,\n requireContext,\n requireContextWithOverrides,\n} from './context-stubs';\nimport { setInitialUrl } from './mocks';\nimport { ExpoRoot } from '../ExpoRoot';\nimport getPathFromState from '../fork/getPathFromState';\nimport { stateCache } from '../getLinkingConfig';\nimport { store } from '../global-state/router-store';\nimport { RequireContext } from '../types';\n\n// re-export everything\nexport * from '@testing-library/react-native';\n\ntype RenderRouterOptions = Parameters<typeof render>[1] & {\n initialUrl?: any;\n};\n\ntype Result = ReturnType<typeof render> & {\n getPathname(): string;\n getPathnameWithParams(): string;\n getSegments(): string[];\n getSearchParams(): Record<string, string | string[]>;\n};\n\nfunction isOverrideContext(\n context: object\n): context is { appDir: string; overrides: Record<string, FileStub> } {\n return Boolean(typeof context === 'object' && 'appDir' in context);\n}\n\nexport function renderRouter(context?: string, options?: RenderRouterOptions): Result;\nexport function renderRouter(\n context: Record<string, FileStub>,\n options?: RenderRouterOptions\n): Result;\nexport function renderRouter(\n context: { appDir: string; overrides: Record<string, FileStub> },\n options?: RenderRouterOptions\n): Result;\nexport function renderRouter(\n context:\n | string\n | { appDir: string; overrides: Record<string, FileStub> }\n | Record<string, FileStub> = './app',\n { initialUrl = '/', ...options }: RenderRouterOptions = {}\n): Result {\n jest.useFakeTimers();\n\n let ctx: RequireContext;\n\n // Reset the initial URL\n\n setInitialUrl(initialUrl);\n\n // Force the render to be synchronous\n process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';\n\n if (typeof context === 'string') {\n ctx = requireContext(path.resolve(process.cwd(), context));\n } else if (isOverrideContext(context)) {\n ctx = requireContextWithOverrides(context.appDir, context.overrides);\n } else {\n ctx = inMemoryContext(context);\n }\n\n stateCache.clear();\n\n let location: URL | undefined;\n\n if (typeof initialUrl === 'string') {\n location = new URL(initialUrl, 'test://');\n } else if (initialUrl instanceof URL) {\n location = initialUrl;\n }\n\n const result = render(<ExpoRoot context={ctx} location={location} />, {\n ...options,\n });\n\n return Object.assign(result, {\n getPathname(this: RenderResult): string {\n return store.routeInfoSnapshot().pathname;\n },\n getSegments(this: RenderResult): string[] {\n return store.routeInfoSnapshot().segments;\n },\n getSearchParams(this: RenderResult): Record<string, string | string[]> {\n return store.routeInfoSnapshot().params;\n },\n getPathnameWithParams(this: RenderResult): string {\n return getPathFromState(store.rootState!, store.linking!.config);\n },\n });\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing-library/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,0CAA0C;AAC1C,oBAAkB;AAElB,gEAAqE;AACrE,gDAAwB;AACxB,kDAA0B;AAE1B,m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MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAE5C,wBAAwB;IACxB,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;IAE1B,qCAAqC;IACrC,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,MAAM,CAAC;IAC7C,6BAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,IAAI,QAAyB,CAAC;IAE9B,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,QAAQ,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;KAC3C;SAAM,IAAI,UAAU,YAAY,GAAG,EAAE;QACpC,QAAQ,GAAG,UAAU,CAAC;KACvB;IAED,MAAM,MAAM,GAAG,IAAA,qBAAM,EAAC,CAAC,mBAAQ,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAG,EAAE;QAC5E,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3B,WAAW;YACT,OAAO,oBAAK,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC;QAC5C,CAAC;QACD,WAAW;YACT,OAAO,oBAAK,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC;QAC5C,CAAC;QACD,eAAe;YACb,OAAO,oBAAK,CAAC,iBAAiB,EAAE,CAAC,MAAM,CAAC;QAC1C,CAAC;QACD,qBAAqB;YACnB,OAAO,IAAA,0BAAgB,EAAC,oBAAK,CAAC,SAAU,EAAE,oBAAK,CAAC,OAAQ,CAAC,MAAM,CAAC,CAAC;QACnE,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAzCD,oCAyCC","sourcesContent":["/// <reference types=\"../../types/jest\" />\nimport './expect';\n\nimport { render, RenderResult } from '@testing-library/react-native';\nimport path from 'path';\nimport React from 'react';\n\nimport {\n FileStub,\n inMemoryContext,\n requireContext,\n requireContextWithOverrides,\n} from './context-stubs';\nimport { setInitialUrl } from './mocks';\nimport { ExpoRoot } from '../ExpoRoot';\nimport getPathFromState from '../fork/getPathFromState';\nimport { getNavigationConfig, stateCache } from '../getLinkingConfig';\nimport { getExactRoutes } from '../getRoutes';\nimport { store } from '../global-state/router-store';\n\n// re-export everything\nexport * from '@testing-library/react-native';\n\ntype RenderRouterOptions = Parameters<typeof render>[1] & {\n initialUrl?: any;\n};\n\ntype Result = ReturnType<typeof render> & {\n getPathname(): string;\n getPathnameWithParams(): string;\n getSegments(): string[];\n getSearchParams(): Record<string, string | string[]>;\n};\n\nfunction isOverrideContext(\n context: object\n): context is { appDir: string; overrides: Record<string, FileStub> } {\n return Boolean(typeof context === 'object' && 'appDir' in context);\n}\n\nexport type MockContextConfig =\n | string // Pathname to a directory\n | string[] // Array of filenames to mock as empty components, e.g () => null\n | Record<string, FileStub> // Map of filenames and their exports\n | {\n // Directory to load as context\n appDir: string;\n // Map of filenames and their exports. Will override contents of files loaded in `appDir\n overrides: Record<string, FileStub>;\n };\n\nexport function getMockConfig(context: MockContextConfig) {\n return getNavigationConfig(getExactRoutes(getMockContext(context))!);\n}\n\nexport function getMockContext(context: MockContextConfig) {\n if (typeof context === 'string') {\n return requireContext(path.resolve(process.cwd(), context));\n } else if (Array.isArray(context)) {\n return inMemoryContext(\n Object.fromEntries(context.map((filename) => [filename, { default: () => null }]))\n );\n } else if (isOverrideContext(context)) {\n return requireContextWithOverrides(context.appDir, context.overrides);\n } else {\n return inMemoryContext(context);\n }\n}\n\nexport function renderRouter(\n context: MockContextConfig = './app',\n { initialUrl = '/', ...options }: RenderRouterOptions = {}\n): Result {\n jest.useFakeTimers();\n\n const mockContext = getMockContext(context);\n\n // Reset the initial URL\n setInitialUrl(initialUrl);\n\n // Force the render to be synchronous\n process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';\n stateCache.clear();\n\n let location: URL | undefined;\n\n if (typeof initialUrl === 'string') {\n location = new URL(initialUrl, 'test://');\n } else if (initialUrl instanceof URL) {\n location = initialUrl;\n }\n\n const result = render(<ExpoRoot context={mockContext} location={location} />, {\n ...options,\n });\n\n return Object.assign(result, {\n getPathname(this: RenderResult): string {\n return store.routeInfoSnapshot().pathname;\n },\n getSegments(this: RenderResult): string[] {\n return store.routeInfoSnapshot().segments;\n },\n getSearchParams(this: RenderResult): Record<string, string | string[]> {\n return store.routeInfoSnapshot().params;\n },\n getPathnameWithParams(this: RenderResult): string {\n return getPathFromState(store.rootState!, store.linking!.config);\n },\n });\n}\n"]}
@@ -1,3 +1,2 @@
1
- import '@testing-library/jest-native/extend-expect';
2
1
  export declare function setInitialUrl(value: string): void;
3
2
  //# sourceMappingURL=mocks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,4CAA4C,CAAC;AAsBpD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,QAE1C"}
1
+ {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":"AA2BA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,QAE1C"}
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setInitialUrl = void 0;
4
- require("@testing-library/jest-native/extend-expect");
4
+ /*
5
+ * Optionally enable @testing-library/jest-native/extend-expect. We use this internally for the `toBeOnTheScreen` matcher()
6
+ */
7
+ try {
8
+ require('@testing-library/jest-native/extend-expect');
9
+ }
10
+ catch { }
5
11
  // include this section and the NativeAnimatedHelper section for mocking react-native-reanimated
6
12
  jest.mock('react-native-reanimated', () => {
7
13
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":";;;AAAA,sDAAoD;AAEpD,gGAAgG;AAChG,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACxC,IAAI;QACF,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;QAE3D,wEAAwE;QACxE,iCAAiC;QACjC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAEnC,OAAO,UAAU,CAAC;KACnB;IAAC,MAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC,CAAC,CAAC;AAEH,kHAAkH;AAClH,IAAI,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;AAElE,IAAI,cAAc,GAA6B,EAAE,CAAC;AAElD,SAAgB,aAAa,CAAC,KAAa;IACzC,cAAc,GAAG,KAAK,CAAC;AACzB,CAAC;AAFD,sCAEC;AAED,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,MAAM,MAAM,GAAkC;QAC5C,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;QACrC,SAAS,CAAC,IAAY;YACpB,OAAO,eAAe,GAAG,IAAI,CAAC;QAChC,CAAC;QACD,aAAa;YACX,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,gBAAgB;YACd,OAAO,EAAE,MAAM,KAAI,CAAC,EAAS,CAAC;QAChC,CAAC;QACD,KAAK,CAAC,aAAa;YACjB,OAAO,cAAc,CAAC;QACxB,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,CAAC","sourcesContent":["import '@testing-library/jest-native/extend-expect';\n\n// include this section and the NativeAnimatedHelper section for mocking react-native-reanimated\njest.mock('react-native-reanimated', () => {\n try {\n const Reanimated = require('react-native-reanimated/mock');\n\n // The mock for `call` immediately calls the callback which is incorrect\n // So we override it with a no-op\n Reanimated.default.call = () => {};\n\n return Reanimated;\n } catch {\n return {};\n }\n});\n\n// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing\njest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');\n\nlet mockInitialUrl: string | Promise<string> = '';\n\nexport function setInitialUrl(value: string) {\n mockInitialUrl = value;\n}\n\njest.mock('expo-linking', () => {\n const module: typeof import('expo-linking') = {\n ...jest.requireActual('expo-linking'),\n createURL(path: string) {\n return 'yourscheme://' + path;\n },\n resolveScheme() {\n return 'yourscheme';\n },\n addEventListener() {\n return { remove() {} } as any;\n },\n async getInitialURL() {\n return mockInitialUrl;\n },\n };\n\n return module;\n});\n"]}
1
+ {"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAI;IACF,OAAO,CAAC,4CAA4C,CAAC,CAAC;CACvD;AAAC,MAAM,GAAE;AAEV,gGAAgG;AAChG,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACxC,IAAI;QACF,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;QAE3D,wEAAwE;QACxE,iCAAiC;QACjC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAEnC,OAAO,UAAU,CAAC;KACnB;IAAC,MAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC,CAAC,CAAC;AAEH,kHAAkH;AAClH,IAAI,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;AAElE,IAAI,cAAc,GAA6B,EAAE,CAAC;AAElD,SAAgB,aAAa,CAAC,KAAa;IACzC,cAAc,GAAG,KAAK,CAAC;AACzB,CAAC;AAFD,sCAEC;AAED,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,MAAM,MAAM,GAAkC;QAC5C,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;QACrC,SAAS,CAAC,IAAY;YACpB,OAAO,eAAe,GAAG,IAAI,CAAC;QAChC,CAAC;QACD,aAAa;YACX,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,gBAAgB;YACd,OAAO,EAAE,MAAM,KAAI,CAAC,EAAS,CAAC;QAChC,CAAC;QACD,KAAK,CAAC,aAAa;YACjB,OAAO,cAAc,CAAC;QACxB,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,CAAC","sourcesContent":["/*\n * Optionally enable @testing-library/jest-native/extend-expect. We use this internally for the `toBeOnTheScreen` matcher()\n */\ntry {\n require('@testing-library/jest-native/extend-expect');\n} catch {}\n\n// include this section and the NativeAnimatedHelper section for mocking react-native-reanimated\njest.mock('react-native-reanimated', () => {\n try {\n const Reanimated = require('react-native-reanimated/mock');\n\n // The mock for `call` immediately calls the callback which is incorrect\n // So we override it with a no-op\n Reanimated.default.call = () => {};\n\n return Reanimated;\n } catch {\n return {};\n }\n});\n\n// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing\njest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');\n\nlet mockInitialUrl: string | Promise<string> = '';\n\nexport function setInitialUrl(value: string) {\n mockInitialUrl = value;\n}\n\njest.mock('expo-linking', () => {\n const module: typeof import('expo-linking') = {\n ...jest.requireActual('expo-linking'),\n createURL(path: string) {\n return 'yourscheme://' + path;\n },\n resolveScheme() {\n return 'yourscheme';\n },\n addEventListener() {\n return { remove() {} } as any;\n },\n async getInitialURL() {\n return mockInitialUrl;\n },\n };\n\n return module;\n});\n"]}
package/build/types.d.ts CHANGED
@@ -12,16 +12,22 @@ export interface RequireContext {
12
12
  /** The list of input keys will become optional, everything else will remain the same. */
13
13
  export type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
14
14
  export type Router = {
15
- /** Navigate to the provided href using a push operation if possible. */
15
+ /** Navigate to the provided href using a dismiss operation if possible. */
16
16
  push: (href: Href) => void;
17
+ /** Navigate to the provided href using a push operation if possible. */
18
+ dismiss: (count?: number) => void;
17
19
  /** Navigate to the provided href. */
18
20
  navigate: (href: Href) => void;
19
21
  /** Navigate to route without appending to the history. */
20
22
  replace: (href: Href) => void;
23
+ /** Navigate to first screen within the lowest stack */
24
+ dismissAll: () => void;
21
25
  /** Go back in the history. */
22
26
  back: () => void;
23
27
  /** If there's history that supports invoking the `back` function. */
24
28
  canGoBack: () => boolean;
29
+ /** If there's history that supports invoking the `dismiss` and `dismissAll` function. */
30
+ canDismiss: () => boolean;
25
31
  /** Update the current route query params. */
26
32
  setParams: (params?: Record<string, string>) => void;
27
33
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAC;IAClB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;IACnB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,yFAAyF;AACzF,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEjF,MAAM,MAAM,MAAM,GAAG;IACnB,wEAAwE;IACxE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC3B,qCAAqC;IACrC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC/B,0DAA0D;IAC1D,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,qEAAqE;IACrE,SAAS,EAAE,M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AE,MAAM,OAAO,CAAC;IACzB,yFAAyF;IACzF,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,6CAA6C;IAC7C,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CACtD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Href } from './link/href';\n\n// TODO: Use the global type\nexport interface RequireContext {\n /** Return the keys that can be resolved. */\n keys(): string[];\n (id: string): any;\n <T>(id: string): T;\n /** **Unimplemented:** Return the module identifier for a user request. */\n resolve(id: string): string;\n /** **Unimplemented:** Readable identifier for the context module. */\n id: string;\n}\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport type Router = {\n /** Navigate to the provided href using a push operation if possible. */\n push: (href: Href) => void;\n /** Navigate to the provided href. */\n navigate: (href: Href) => void;\n /** Navigate to route without appending to the history. */\n replace: (href: Href) => void;\n /** Go back in the history. */\n back: () => void;\n /** If there's history that supports invoking the `back` function. */\n canGoBack: () => boolean;\n /** Update the current route query params. */\n setParams: (params?: Record<string, string>) => void;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Href } from './link/href';\n\n// TODO: Use the global type\nexport interface RequireContext {\n /** Return the keys that can be resolved. */\n keys(): string[];\n (id: string): any;\n <T>(id: string): T;\n /** **Unimplemented:** Return the module identifier for a user request. */\n resolve(id: string): string;\n /** **Unimplemented:** Readable identifier for the context module. */\n id: string;\n}\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport type Router = {\n /** Navigate to the provided href using a dismiss operation if possible. */\n push: (href: Href) => void;\n /** Navigate to the provided href using a push operation if possible. */\n dismiss: (count?: number) => void;\n /** Navigate to the provided href. */\n navigate: (href: Href) => void;\n /** Navigate to route without appending to the history. */\n replace: (href: Href) => void;\n /** Navigate to first screen within the lowest stack */\n dismissAll: () => void;\n /** Go back in the history. */\n back: () => void;\n /** If there's history that supports invoking the `back` function. */\n canGoBack: () => boolean;\n /** If there's history that supports invoking the `dismiss` and `dismissAll` function. */\n canDismiss: () => boolean;\n /** Update the current route query params. */\n setParams: (params?: Record<string, string>) => void;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-router",
3
- "version": "3.4.6",
3
+ "version": "3.4.8",
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",
@@ -91,7 +91,7 @@
91
91
  "tsd": "^0.28.1"
92
92
  },
93
93
  "dependencies": {
94
- "@expo/metro-runtime": "3.1.2",
94
+ "@expo/metro-runtime": "3.1.3",
95
95
  "@expo/server": "^0.3.0",
96
96
  "@radix-ui/react-slot": "1.0.1",
97
97
  "@react-navigation/bottom-tabs": "~6.5.7",
@@ -101,5 +101,5 @@
101
101
  "react-helmet-async": "^1.3.0",
102
102
  "schema-utils": "^4.0.1"
103
103
  },
104
- "gitHead": "82b69cba5b2e967806ca03413c3277f1d53bff8d"
104
+ "gitHead": "01bef8630cd9fd913bb465afd010d6030a9ca38f"
105
105
  }
@@ -1,3 +0,0 @@
1
- declare let ExpoHead: null | any;
2
- export { ExpoHead };
3
- //# sourceMappingURL=ExpoHeadModule.native.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoHeadModule.native.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHeadModule.native.ts"],"names":[],"mappings":"AAGA,QAAA,IAAI,QAAQ,EAAE,IAAI,GAAG,GAAU,CAAC;AAQhC,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ExpoHead = void 0;
27
- const expo_constants_1 = __importStar(require("expo-constants"));
28
- const expo_modules_core_1 = require("expo-modules-core");
29
- let ExpoHead = null;
30
- exports.ExpoHead = ExpoHead;
31
- if (expo_constants_1.default.executionEnvironment === expo_constants_1.ExecutionEnvironment.Bare) {
32
- // Loads the native module object from the JSI or falls back to
33
- // the bridge module (from NativeModulesProxy) if the remote debugger is on.
34
- exports.ExpoHead = ExpoHead = (0, expo_modules_core_1.requireNativeModule)('ExpoHead');
35
- }
36
- //# sourceMappingURL=ExpoHeadModule.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoHeadModule.native.js","sourceRoot":"","sources":["../../src/head/ExpoHeadModule.native.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAiE;AACjE,yDAAwD;AAExD,IAAI,QAAQ,GAAe,IAAI,CAAC;AAQvB,4BAAQ;AANjB,IAAI,wBAAS,CAAC,oBAAoB,KAAK,qCAAoB,CAAC,IAAI,EAAE;IAChE,+DAA+D;IAC/D,4EAA4E;IAC5E,mBAAA,QAAQ,GAAG,IAAA,uCAAmB,EAAC,UAAU,CAAC,CAAC;CAC5C","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport { requireNativeModule } from 'expo-modules-core';\n\nlet ExpoHead: null | any = null;\n\nif (Constants.executionEnvironment === ExecutionEnvironment.Bare) {\n // Loads the native module object from the JSI or falls back to\n // the bridge module (from NativeModulesProxy) if the remote debugger is on.\n ExpoHead = requireNativeModule('ExpoHead');\n}\n\nexport { ExpoHead };\n"]}
@@ -1,7 +0,0 @@
1
- import { RequireContext } from '../types';
2
- export declare function createMockContextModule(map?: Record<string, Record<string, any>>): RequireContext;
3
- export declare function configFromFs(map?: (string | [string, object])[]): {
4
- initialRouteName?: string | undefined;
5
- screens: Record<string, import("../getReactNavigationConfig").Screen>;
6
- };
7
- //# sourceMappingURL=mockState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mockState.d.ts","sourceRoot":"","sources":["../../src/utils/mockState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,wBAAgB,uBAAuB,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM,kBAQpF;AAED,wBAAgB,YAAY,CAAC,GAAG,GAAE,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAO;;;EAiBnE"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configFromFs = exports.createMockContextModule = void 0;
4
- const getLinkingConfig_1 = require("../getLinkingConfig");
5
- const getRoutes_1 = require("../getRoutes");
6
- function createMockContextModule(map = {}) {
7
- const contextModule = jest.fn((key) => map[key]);
8
- Object.defineProperty(contextModule, 'keys', {
9
- value: () => Object.keys(map),
10
- });
11
- return contextModule;
12
- }
13
- exports.createMockContextModule = createMockContextModule;
14
- function configFromFs(map = []) {
15
- const ctx = map.reduce((acc, value) => {
16
- if (typeof value === 'string') {
17
- acc[value] = { default: () => { } };
18
- return acc;
19
- }
20
- acc[value[0]] = {
21
- default: () => { },
22
- ...value[1],
23
- };
24
- return acc;
25
- }, {});
26
- return (0, getLinkingConfig_1.getNavigationConfig)((0, getRoutes_1.getExactRoutes)(createMockContextModule(ctx)));
27
- }
28
- exports.configFromFs = configFromFs;
29
- //# sourceMappingURL=mockState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mockState.js","sourceRoot":"","sources":["../../src/utils/mockState.ts"],"names":[],"mappings":";;;AAAA,0DAA0D;AAC1D,4CAA8C;AAG9C,SAAgB,uBAAuB,CAAC,MAA2C,EAAE;IACnF,MAAM,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAEjD,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE;QAC3C,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;KAC9B,CAAC,CAAC;IAEH,OAAO,aAA0C,CAAC;AACpD,CAAC;AARD,0DAQC;AAED,SAAgB,YAAY,CAAC,MAAqC,EAAE;IAClE,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CACpB,CAAC,GAAG,EAAE,KAAU,EAAE,EAAE;QAClB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;YACnC,OAAO,GAAG,CAAC;SACZ;QACD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG;YACd,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;YACjB,GAAG,KAAK,CAAC,CAAC,CAAC;SACZ,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAyC,CAC1C,CAAC;IAEF,OAAO,IAAA,sCAAmB,EAAC,IAAA,0BAAc,EAAC,uBAAuB,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC;AAC5E,CAAC;AAjBD,oCAiBC","sourcesContent":["import { getNavigationConfig } from '../getLinkingConfig';\nimport { getExactRoutes } from '../getRoutes';\nimport { RequireContext } from '../types';\n\nexport function createMockContextModule(map: Record<string, Record<string, any>> = {}) {\n const contextModule = jest.fn((key) => map[key]);\n\n Object.defineProperty(contextModule, 'keys', {\n value: () => Object.keys(map),\n });\n\n return contextModule as unknown as RequireContext;\n}\n\nexport function configFromFs(map: (string | [string, object])[] = []) {\n const ctx = map.reduce(\n (acc, value: any) => {\n if (typeof value === 'string') {\n acc[value] = { default: () => {} };\n return acc;\n }\n acc[value[0]] = {\n default: () => {},\n ...value[1],\n };\n return acc;\n },\n {} as Record<string, Record<string, any>>\n );\n\n return getNavigationConfig(getExactRoutes(createMockContextModule(ctx))!);\n}\n"]}