@react-navigation/native 6.0.16 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/lib/commonjs/Link.js +2 -12
  2. package/lib/commonjs/Link.js.map +1 -1
  3. package/lib/commonjs/LinkingContext.js +0 -4
  4. package/lib/commonjs/LinkingContext.js.map +1 -1
  5. package/lib/commonjs/NavigationContainer.js +9 -31
  6. package/lib/commonjs/NavigationContainer.js.map +1 -1
  7. package/lib/commonjs/ServerContainer.js +2 -12
  8. package/lib/commonjs/ServerContainer.js.map +1 -1
  9. package/lib/commonjs/ServerContext.js +0 -4
  10. package/lib/commonjs/ServerContext.js.map +1 -1
  11. package/lib/commonjs/createMemoryHistory.js +36 -53
  12. package/lib/commonjs/createMemoryHistory.js.map +1 -1
  13. package/lib/commonjs/extractPathFromURL.js +2 -8
  14. package/lib/commonjs/extractPathFromURL.js.map +1 -1
  15. package/lib/commonjs/index.js +0 -17
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/theming/DarkTheme.js.map +1 -1
  18. package/lib/commonjs/theming/DefaultTheme.js.map +1 -1
  19. package/lib/commonjs/theming/ThemeContext.js +0 -6
  20. package/lib/commonjs/theming/ThemeContext.js.map +1 -1
  21. package/lib/commonjs/theming/ThemeProvider.js +0 -6
  22. package/lib/commonjs/theming/ThemeProvider.js.map +1 -1
  23. package/lib/commonjs/theming/useTheme.js +0 -6
  24. package/lib/commonjs/theming/useTheme.js.map +1 -1
  25. package/lib/commonjs/types.js.map +1 -1
  26. package/lib/commonjs/useBackButton.js +0 -9
  27. package/lib/commonjs/useBackButton.js.map +1 -1
  28. package/lib/commonjs/useDocumentTitle.js +1 -12
  29. package/lib/commonjs/useDocumentTitle.js.map +1 -1
  30. package/lib/commonjs/useDocumentTitle.native.js +2 -2
  31. package/lib/commonjs/useDocumentTitle.native.js.map +1 -1
  32. package/lib/commonjs/useLinkBuilder.js +5 -15
  33. package/lib/commonjs/useLinkBuilder.js.map +1 -1
  34. package/lib/commonjs/useLinkProps.js +8 -24
  35. package/lib/commonjs/useLinkProps.js.map +1 -1
  36. package/lib/commonjs/useLinkTo.js +0 -12
  37. package/lib/commonjs/useLinkTo.js.map +1 -1
  38. package/lib/commonjs/useLinking.js +35 -79
  39. package/lib/commonjs/useLinking.js.map +1 -1
  40. package/lib/commonjs/useLinking.native.js +9 -36
  41. package/lib/commonjs/useLinking.native.js.map +1 -1
  42. package/lib/commonjs/useScrollToTop.js +48 -47
  43. package/lib/commonjs/useScrollToTop.js.map +1 -1
  44. package/lib/commonjs/useThenable.js +2 -9
  45. package/lib/commonjs/useThenable.js.map +1 -1
  46. package/lib/module/Link.js +2 -6
  47. package/lib/module/Link.js.map +1 -1
  48. package/lib/module/LinkingContext.js.map +1 -1
  49. package/lib/module/NavigationContainer.js +9 -18
  50. package/lib/module/NavigationContainer.js.map +1 -1
  51. package/lib/module/ServerContainer.js +2 -5
  52. package/lib/module/ServerContainer.js.map +1 -1
  53. package/lib/module/ServerContext.js.map +1 -1
  54. package/lib/module/createMemoryHistory.js +36 -51
  55. package/lib/module/createMemoryHistory.js.map +1 -1
  56. package/lib/module/extractPathFromURL.js +2 -5
  57. package/lib/module/extractPathFromURL.js.map +1 -1
  58. package/lib/module/index.js.map +1 -1
  59. package/lib/module/theming/DarkTheme.js.map +1 -1
  60. package/lib/module/theming/DefaultTheme.js.map +1 -1
  61. package/lib/module/theming/ThemeContext.js.map +1 -1
  62. package/lib/module/theming/ThemeProvider.js.map +1 -1
  63. package/lib/module/theming/useTheme.js.map +1 -1
  64. package/lib/module/types.js.map +1 -1
  65. package/lib/module/useBackButton.js +0 -3
  66. package/lib/module/useBackButton.js.map +1 -1
  67. package/lib/module/useDocumentTitle.js +1 -9
  68. package/lib/module/useDocumentTitle.js.map +1 -1
  69. package/lib/module/useDocumentTitle.native.js +2 -1
  70. package/lib/module/useDocumentTitle.native.js.map +1 -1
  71. package/lib/module/useLinkBuilder.js +5 -9
  72. package/lib/module/useLinkBuilder.js.map +1 -1
  73. package/lib/module/useLinkProps.js +8 -16
  74. package/lib/module/useLinkProps.js.map +1 -1
  75. package/lib/module/useLinkTo.js +0 -5
  76. package/lib/module/useLinkTo.js.map +1 -1
  77. package/lib/module/useLinking.js +35 -70
  78. package/lib/module/useLinking.js.map +1 -1
  79. package/lib/module/useLinking.native.js +9 -26
  80. package/lib/module/useLinking.native.js.map +1 -1
  81. package/lib/module/useScrollToTop.js +48 -43
  82. package/lib/module/useScrollToTop.js.map +1 -1
  83. package/lib/module/useThenable.js +2 -5
  84. package/lib/module/useThenable.js.map +1 -1
  85. package/lib/typescript/src/Link.d.ts +1 -0
  86. package/lib/typescript/src/Link.d.ts.map +1 -0
  87. package/lib/typescript/src/LinkingContext.d.ts +1 -0
  88. package/lib/typescript/src/LinkingContext.d.ts.map +1 -0
  89. package/lib/typescript/src/NavigationContainer.d.ts +1 -0
  90. package/lib/typescript/src/NavigationContainer.d.ts.map +1 -0
  91. package/lib/typescript/src/ServerContainer.d.ts +1 -0
  92. package/lib/typescript/src/ServerContainer.d.ts.map +1 -0
  93. package/lib/typescript/src/ServerContext.d.ts +1 -0
  94. package/lib/typescript/src/ServerContext.d.ts.map +1 -0
  95. package/lib/typescript/src/__mocks__/window.d.ts +1 -0
  96. package/lib/typescript/src/__mocks__/window.d.ts.map +1 -0
  97. package/lib/typescript/src/createMemoryHistory.d.ts +1 -0
  98. package/lib/typescript/src/createMemoryHistory.d.ts.map +1 -0
  99. package/lib/typescript/src/extractPathFromURL.d.ts +1 -0
  100. package/lib/typescript/src/extractPathFromURL.d.ts.map +1 -0
  101. package/lib/typescript/src/index.d.ts +1 -0
  102. package/lib/typescript/src/index.d.ts.map +1 -0
  103. package/lib/typescript/src/theming/DarkTheme.d.ts +1 -0
  104. package/lib/typescript/src/theming/DarkTheme.d.ts.map +1 -0
  105. package/lib/typescript/src/theming/DefaultTheme.d.ts +1 -0
  106. package/lib/typescript/src/theming/DefaultTheme.d.ts.map +1 -0
  107. package/lib/typescript/src/theming/ThemeContext.d.ts +1 -0
  108. package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -0
  109. package/lib/typescript/src/theming/ThemeProvider.d.ts +1 -0
  110. package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -0
  111. package/lib/typescript/src/theming/useTheme.d.ts +1 -0
  112. package/lib/typescript/src/theming/useTheme.d.ts.map +1 -0
  113. package/lib/typescript/src/types.d.ts +1 -0
  114. package/lib/typescript/src/types.d.ts.map +1 -0
  115. package/lib/typescript/src/useBackButton.d.ts +1 -0
  116. package/lib/typescript/src/useBackButton.d.ts.map +1 -0
  117. package/lib/typescript/src/useDocumentTitle.d.ts +1 -0
  118. package/lib/typescript/src/useDocumentTitle.d.ts.map +1 -0
  119. package/lib/typescript/src/useDocumentTitle.native.d.ts +1 -0
  120. package/lib/typescript/src/useDocumentTitle.native.d.ts.map +1 -0
  121. package/lib/typescript/src/useLinkBuilder.d.ts +1 -0
  122. package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -0
  123. package/lib/typescript/src/useLinkProps.d.ts +1 -0
  124. package/lib/typescript/src/useLinkProps.d.ts.map +1 -0
  125. package/lib/typescript/src/useLinkTo.d.ts +1 -0
  126. package/lib/typescript/src/useLinkTo.d.ts.map +1 -0
  127. package/lib/typescript/src/useLinking.d.ts +1 -0
  128. package/lib/typescript/src/useLinking.d.ts.map +1 -0
  129. package/lib/typescript/src/useLinking.native.d.ts +1 -0
  130. package/lib/typescript/src/useLinking.native.d.ts.map +1 -0
  131. package/lib/typescript/src/useScrollToTop.d.ts +1 -0
  132. package/lib/typescript/src/useScrollToTop.d.ts.map +1 -0
  133. package/lib/typescript/src/useThenable.d.ts +1 -0
  134. package/lib/typescript/src/useThenable.d.ts.map +1 -0
  135. package/package.json +4 -4
  136. package/src/createMemoryHistory.tsx +10 -2
  137. package/src/useScrollToTop.tsx +52 -38
@@ -1 +1 @@
1
- {"version":3,"names":["useLinkTo","navigation","React","useContext","NavigationContainerRefContext","linking","LinkingContext","linkTo","useCallback","to","undefined","Error","navigate","screen","params","startsWith","options","state","getStateFromPath","config","action","getActionFromState","dispatch","reset"],"sources":["useLinkTo.tsx"],"sourcesContent":["import {\n getActionFromState,\n getStateFromPath,\n NavigationContainerRefContext,\n} from '@react-navigation/core';\nimport * as React from 'react';\n\nimport LinkingContext from './LinkingContext';\n\nexport type To<\n ParamList extends ReactNavigation.RootParamList = ReactNavigation.RootParamList,\n RouteName extends keyof ParamList = keyof ParamList\n> =\n | string\n | (undefined extends ParamList[RouteName]\n ? {\n screen: Extract<RouteName, string>;\n params?: ParamList[RouteName];\n }\n : {\n screen: Extract<RouteName, string>;\n params: ParamList[RouteName];\n });\n\nexport default function useLinkTo<\n ParamList extends ReactNavigation.RootParamList\n>() {\n const navigation = React.useContext(NavigationContainerRefContext);\n const linking = React.useContext(LinkingContext);\n\n const linkTo = React.useCallback(\n (to: To<ParamList>) => {\n if (navigation === undefined) {\n throw new Error(\n \"Couldn't find a navigation object. Is your component inside NavigationContainer?\"\n );\n }\n\n if (typeof to !== 'string') {\n // @ts-expect-error: This is fine\n navigation.navigate(to.screen, to.params);\n return;\n }\n\n if (!to.startsWith('/')) {\n throw new Error(`The path must start with '/' (${to}).`);\n }\n\n const { options } = linking;\n\n const state = options?.getStateFromPath\n ? options.getStateFromPath(to, options.config)\n : getStateFromPath(to, options?.config);\n\n if (state) {\n const action = getActionFromState(state, options?.config);\n\n if (action !== undefined) {\n navigation.dispatch(action);\n } else {\n navigation.reset(state);\n }\n } else {\n throw new Error('Failed to parse the path to a navigation state.');\n }\n },\n [linking, navigation]\n );\n\n return linkTo;\n}\n"],"mappings":";;;;;;;AAAA;;AAKA;;AAEA;;;;;;;;AAiBe,SAASA,SAAT,GAEX;EACF,MAAMC,UAAU,GAAGC,KAAK,CAACC,UAAN,CAAiBC,mCAAjB,CAAnB;EACA,MAAMC,OAAO,GAAGH,KAAK,CAACC,UAAN,CAAiBG,uBAAj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ext","linking","LinkingContext","linkTo","useCallback","to","undefined","Error","navigate","screen","params","startsWith","options","state","getStateFromPath","config","action","getActionFromState","dispatch","reset"],"sourceRoot":"../../src","sources":["useLinkTo.tsx"],"mappings":";;;;;;AAAA;AAKA;AAEA;AAA8C;AAAA;AAAA;AAiB/B,SAASA,SAAS,GAE7B;EACF,MAAMC,UAAU,GAAGC,KAAK,CAACC,UAAU,CAACC,mCAA6B,CAAC;EAClE,MAAMC,OAAO,GAAGH,KAAK,CAACC,UAAU,CAACG,uBAAc,CAAC;EAEhD,MAAMC,MAAM,GAAGL,KAAK,CAACM,WAAW,CAC7BC,EAAiB,IAAK;IACrB,IAAIR,UAAU,KAAKS,SAAS,EAAE;MAC5B,MAAM,IAAIC,KAAK,CACb,kFAAkF,CACnF;IACH;IAEA,IAAI,OAAOF,EAAE,KAAK,QAAQ,EAAE;MAC1B;MACAR,UAAU,CAACW,QAAQ,CAACH,EAAE,CAACI,MAAM,EAAEJ,EAAE,CAACK,MAAM,CAAC;MACzC;IACF;IAEA,IAAI,CAACL,EAAE,CAACM,UAAU,CAAC,GAAG,CAAC,EAAE;MACvB,MAAM,IAAIJ,KAAK,CAAE,iCAAgCF,EAAG,IAAG,CAAC;IAC1D;IAEA,MAAM;MAAEO;IAAQ,CAAC,GAAGX,OAAO;IAE3B,MAAMY,KAAK,GAAGD,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEE,gBAAgB,GACnCF,OAAO,CAACE,gBAAgB,CAACT,EAAE,EAAEO,OAAO,CAACG,MAAM,CAAC,GAC5C,IAAAD,sBAAgB,EAACT,EAAE,EAAEO,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,MAAM,CAAC;IAEzC,IAAIF,KAAK,EAAE;MACT,MAAMG,MAAM,GAAG,IAAAC,wBAAkB,EAACJ,KAAK,EAAED,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,MAAM,CAAC;MAEzD,IAAIC,MAAM,KAAKV,SAAS,EAAE;QACxBT,UAAU,CAACqB,QAAQ,CAACF,MAAM,CAAC;MAC7B,CAAC,MAAM;QACLnB,UAAU,CAACsB,KAAK,CAACN,KAAK,CAAC;MACzB;IACF,CAAC,MAAM;MACL,MAAM,IAAIN,KAAK,CAAC,iDAAiD,CAAC;IACpE;EACF,CAAC,EACD,CAACN,OAAO,EAAEJ,UAAU,CAAC,CACtB;EAED,OAAOM,MAAM;AACf"}
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useLinking;
7
-
8
7
  var _core = require("@react-navigation/core");
9
-
10
8
  var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
11
-
12
9
  var React = _interopRequireWildcard(require("react"));
13
-
14
10
  var _createMemoryHistory = _interopRequireDefault(require("./createMemoryHistory"));
15
-
16
11
  var _ServerContext = _interopRequireDefault(require("./ServerContext"));
17
-
18
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
13
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
15
  /**
25
16
  * Find the matching navigation state that changed between 2 navigation states
26
17
  * e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state
@@ -28,36 +19,34 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
28
19
  const findMatchingState = (a, b) => {
29
20
  if (a === undefined || b === undefined || a.key !== b.key) {
30
21
  return [undefined, undefined];
31
- } // Tab and drawer will have `history` property, but stack will have history in `routes`
32
-
22
+ }
33
23
 
24
+ // Tab and drawer will have `history` property, but stack will have history in `routes`
34
25
  const aHistoryLength = a.history ? a.history.length : a.routes.length;
35
26
  const bHistoryLength = b.history ? b.history.length : b.routes.length;
36
27
  const aRoute = a.routes[a.index];
37
28
  const bRoute = b.routes[b.index];
38
29
  const aChildState = aRoute.state;
39
- const bChildState = bRoute.state; // Stop here if this is the state object that changed:
30
+ const bChildState = bRoute.state;
31
+
32
+ // Stop here if this is the state object that changed:
40
33
  // - history length is different
41
34
  // - focused routes are different
42
35
  // - one of them doesn't have child state
43
36
  // - child state keys are different
44
-
45
37
  if (aHistoryLength !== bHistoryLength || aRoute.key !== bRoute.key || aChildState === undefined || bChildState === undefined || aChildState.key !== bChildState.key) {
46
38
  return [a, b];
47
39
  }
48
-
49
40
  return findMatchingState(aChildState, bChildState);
50
41
  };
42
+
51
43
  /**
52
44
  * Run async function in series as it's called.
53
45
  */
54
-
55
-
56
46
  const series = cb => {
57
47
  // Whether we're currently handling a callback
58
48
  let handling = false;
59
49
  let queue = [];
60
-
61
50
  const callback = async () => {
62
51
  try {
63
52
  if (handling) {
@@ -66,12 +55,10 @@ const series = cb => {
66
55
  queue.unshift(callback);
67
56
  return;
68
57
  }
69
-
70
58
  handling = true;
71
59
  await cb();
72
60
  } finally {
73
61
  handling = false;
74
-
75
62
  if (queue.length) {
76
63
  // If we have queued items, handle the last one
77
64
  const last = queue.pop();
@@ -79,12 +66,9 @@ const series = cb => {
79
66
  }
80
67
  }
81
68
  };
82
-
83
69
  return callback;
84
70
  };
85
-
86
71
  let linkingHandlers = [];
87
-
88
72
  function useLinking(ref, _ref) {
89
73
  let {
90
74
  independent,
@@ -98,33 +82,28 @@ function useLinking(ref, _ref) {
98
82
  if (process.env.NODE_ENV === 'production') {
99
83
  return undefined;
100
84
  }
101
-
102
85
  if (independent) {
103
86
  return undefined;
104
87
  }
105
-
106
88
  if (enabled !== false && linkingHandlers.length) {
107
89
  console.error(['Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:', "- You don't have multiple NavigationContainers in the app each with 'linking' enabled", '- Only a single instance of the root component is rendered'].join('\n').trim());
108
90
  }
109
-
110
91
  const handler = Symbol();
111
-
112
92
  if (enabled !== false) {
113
93
  linkingHandlers.push(handler);
114
94
  }
115
-
116
95
  return () => {
117
96
  const index = linkingHandlers.indexOf(handler);
118
-
119
97
  if (index > -1) {
120
98
  linkingHandlers.splice(index, 1);
121
99
  }
122
100
  };
123
101
  }, [enabled, independent]);
124
- const [history] = React.useState(_createMemoryHistory.default); // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
102
+ const [history] = React.useState(_createMemoryHistory.default);
103
+
104
+ // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
125
105
  // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`
126
106
  // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect
127
-
128
107
  const enabledRef = React.useRef(enabled);
129
108
  const configRef = React.useRef(config);
130
109
  const getStateFromPathRef = React.useRef(getStateFromPath);
@@ -140,29 +119,23 @@ function useLinking(ref, _ref) {
140
119
  const server = React.useContext(_ServerContext.default);
141
120
  const getInitialState = React.useCallback(() => {
142
121
  let value;
143
-
144
122
  if (enabledRef.current) {
145
- var _server$location;
146
-
147
- const location = (_server$location = server === null || server === void 0 ? void 0 : server.location) !== null && _server$location !== void 0 ? _server$location : typeof window !== 'undefined' ? window.location : undefined;
123
+ const location = (server === null || server === void 0 ? void 0 : server.location) ?? (typeof window !== 'undefined' ? window.location : undefined);
148
124
  const path = location ? location.pathname + location.search : undefined;
149
-
150
125
  if (path) {
151
126
  value = getStateFromPathRef.current(path, configRef.current);
152
127
  }
153
128
  }
154
-
155
129
  const thenable = {
156
130
  then(onfulfilled) {
157
131
  return Promise.resolve(onfulfilled ? onfulfilled(value) : value);
158
132
  },
159
-
160
133
  catch() {
161
134
  return thenable;
162
135
  }
163
-
164
136
  };
165
- return thenable; // eslint-disable-next-line react-hooks/exhaustive-deps
137
+ return thenable;
138
+ // eslint-disable-next-line react-hooks/exhaustive-deps
166
139
  }, []);
167
140
  const previousIndexRef = React.useRef(undefined);
168
141
  const previousStateRef = React.useRef(undefined);
@@ -170,52 +143,46 @@ function useLinking(ref, _ref) {
170
143
  React.useEffect(() => {
171
144
  previousIndexRef.current = history.index;
172
145
  return history.listen(() => {
173
- var _previousIndexRef$cur;
174
-
175
146
  const navigation = ref.current;
176
-
177
147
  if (!navigation || !enabled) {
178
148
  return;
179
149
  }
180
-
181
150
  const path = location.pathname + location.search;
182
151
  const index = history.index;
183
- const previousIndex = (_previousIndexRef$cur = previousIndexRef.current) !== null && _previousIndexRef$cur !== void 0 ? _previousIndexRef$cur : 0;
152
+ const previousIndex = previousIndexRef.current ?? 0;
184
153
  previousIndexRef.current = index;
185
- pendingPopStatePathRef.current = path; // When browser back/forward is clicked, we first need to check if state object for this index exists
154
+ pendingPopStatePathRef.current = path;
155
+
156
+ // When browser back/forward is clicked, we first need to check if state object for this index exists
186
157
  // If it does we'll reset to that state object
187
158
  // Otherwise, we'll handle it like a regular deep link
188
-
189
159
  const record = history.get(index);
190
-
191
160
  if ((record === null || record === void 0 ? void 0 : record.path) === path && record !== null && record !== void 0 && record.state) {
192
161
  navigation.resetRoot(record.state);
193
162
  return;
194
163
  }
164
+ const state = getStateFromPathRef.current(path, configRef.current);
195
165
 
196
- const state = getStateFromPathRef.current(path, configRef.current); // We should only dispatch an action when going forward
166
+ // We should only dispatch an action when going forward
197
167
  // Otherwise the action will likely add items to history, which would mess things up
198
-
199
168
  if (state) {
200
169
  // Make sure that the routes in the state exist in the root navigator
201
170
  // Otherwise there's an error in the linking configuration
202
171
  const rootState = navigation.getRootState();
203
-
204
172
  if (state.routes.some(r => !(rootState !== null && rootState !== void 0 && rootState.routeNames.includes(r.name)))) {
205
173
  console.warn("The navigation state parsed from the URL contains routes not present in the root navigator. This usually means that the linking configuration doesn't match the navigation structure. See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.");
206
174
  return;
207
175
  }
208
-
209
176
  if (index > previousIndex) {
210
177
  const action = getActionFromStateRef.current(state, configRef.current);
211
-
212
178
  if (action !== undefined) {
213
179
  try {
214
180
  navigation.dispatch(action);
215
181
  } catch (e) {
216
182
  // Ignore any errors from deep linking.
217
183
  // This could happen in case of malformed links, navigation object not being initialized etc.
218
- console.warn(`An error occurred when trying to handle the link '${path}': ${typeof e === 'object' && e != null && 'message' in e ? // @ts-expect-error: we're already checking for this
184
+ console.warn(`An error occurred when trying to handle the link '${path}': ${typeof e === 'object' && e != null && 'message' in e ?
185
+ // @ts-expect-error: we're already checking for this
219
186
  e.message : e}`);
220
187
  }
221
188
  } else {
@@ -232,79 +199,67 @@ function useLinking(ref, _ref) {
232
199
  }, [enabled, history, ref]);
233
200
  React.useEffect(() => {
234
201
  var _ref$current;
235
-
236
202
  if (!enabled) {
237
203
  return;
238
204
  }
239
-
240
205
  const getPathForRoute = (route, state) => {
241
206
  // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match
242
207
  // This makes sure that we preserve the original URL for wildcard routes
243
208
  if (route !== null && route !== void 0 && route.path) {
244
209
  const stateForPath = getStateFromPathRef.current(route.path, configRef.current);
245
-
246
210
  if (stateForPath) {
247
211
  const focusedRoute = (0, _core.findFocusedRoute)(stateForPath);
248
-
249
212
  if (focusedRoute && focusedRoute.name === route.name && (0, _fastDeepEqual.default)(focusedRoute.params, route.params)) {
250
213
  return route.path;
251
214
  }
252
215
  }
253
216
  }
254
-
255
217
  return getPathFromStateRef.current(state, configRef.current);
256
218
  };
257
-
258
219
  if (ref.current) {
259
220
  // We need to record the current metadata on the first render if they aren't set
260
221
  // This will allow the initial state to be in the history entry
261
222
  const state = ref.current.getRootState();
262
-
263
223
  if (state) {
264
224
  const route = (0, _core.findFocusedRoute)(state);
265
225
  const path = getPathForRoute(route, state);
266
-
267
226
  if (previousStateRef.current === undefined) {
268
227
  previousStateRef.current = state;
269
228
  }
270
-
271
229
  history.replace({
272
230
  path,
273
231
  state
274
232
  });
275
233
  }
276
234
  }
277
-
278
235
  const onStateChange = async () => {
279
236
  const navigation = ref.current;
280
-
281
237
  if (!navigation || !enabled) {
282
238
  return;
283
239
  }
284
-
285
240
  const previousState = previousStateRef.current;
286
- const state = navigation.getRootState(); // root state may not available, for example when root navigators switch inside the container
241
+ const state = navigation.getRootState();
287
242
 
243
+ // root state may not available, for example when root navigators switch inside the container
288
244
  if (!state) {
289
245
  return;
290
246
  }
291
-
292
247
  const pendingPath = pendingPopStatePathRef.current;
293
248
  const route = (0, _core.findFocusedRoute)(state);
294
249
  const path = getPathForRoute(route, state);
295
250
  previousStateRef.current = state;
296
- pendingPopStatePathRef.current = undefined; // To detect the kind of state change, we need to:
251
+ pendingPopStatePathRef.current = undefined;
252
+
253
+ // To detect the kind of state change, we need to:
297
254
  // - Find the common focused navigation state in previous and current state
298
255
  // - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace
299
256
  // - If no common focused navigation state found, it's a replace
300
-
301
257
  const [previousFocusedState, focusedState] = findMatchingState(previousState, state);
302
-
303
- if (previousFocusedState && focusedState && // We should only handle push/pop if path changed from what was in last `popstate`
258
+ if (previousFocusedState && focusedState &&
259
+ // We should only handle push/pop if path changed from what was in last `popstate`
304
260
  // Otherwise it's likely a change triggered by `popstate`
305
261
  path !== pendingPath) {
306
262
  const historyDelta = (focusedState.history ? focusedState.history.length : focusedState.routes.length) - (previousFocusedState.history ? previousFocusedState.history.length : previousFocusedState.routes.length);
307
-
308
263
  if (historyDelta > 0) {
309
264
  // If history length is increased, we should pushState
310
265
  // Note that path might not actually change here, for example, drawer open should pushState
@@ -314,11 +269,11 @@ function useLinking(ref, _ref) {
314
269
  });
315
270
  } else if (historyDelta < 0) {
316
271
  // If history length is decreased, i.e. entries were removed, we want to go back
272
+
317
273
  const nextIndex = history.backIndex({
318
274
  path
319
275
  });
320
276
  const currentIndex = history.index;
321
-
322
277
  try {
323
278
  if (nextIndex !== -1 && nextIndex < currentIndex) {
324
279
  // An existing entry for this path exists and it's less than current index, go back to that
@@ -328,14 +283,15 @@ function useLinking(ref, _ref) {
328
283
  // This won't be correct if multiple routes were pushed in one go before
329
284
  // Usually this shouldn't happen and this is a fallback for that
330
285
  await history.go(historyDelta);
331
- } // Store the updated state as well as fix the path if incorrect
332
-
286
+ }
333
287
 
288
+ // Store the updated state as well as fix the path if incorrect
334
289
  history.replace({
335
290
  path,
336
291
  state
337
292
  });
338
- } catch (e) {// The navigation was interrupted
293
+ } catch (e) {
294
+ // The navigation was interrupted
339
295
  }
340
296
  } else {
341
297
  // If history length is unchanged, we want to replaceState
@@ -352,11 +308,11 @@ function useLinking(ref, _ref) {
352
308
  state
353
309
  });
354
310
  }
355
- }; // We debounce onStateChange coz we don't want multiple state changes to be handled at one time
311
+ };
312
+
313
+ // We debounce onStateChange coz we don't want multiple state changes to be handled at one time
356
314
  // This could happen since `history.go(n)` is asynchronous
357
315
  // If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up
358
-
359
-
360
316
  return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.addListener('state', series(onStateChange));
361
317
  });
362
318
  return {
@@ -1 +1 @@
1
- {"version":3,"names":["findMatchingState","a","b","undefined","key","aHistoryLength","history","length","routes","bHistoryLength","aRoute","index","bRoute","aChildState","state","bChildState","series","cb","handling","queue","callback","unshift","last","pop","linkingHandlers","useLinking","ref","independent","enabled","config","getStateFromPath","getStateFromPathDefault","getPathFromState","getPathFromStateDefault","getActionFromState","getActionFromStateDefault","React","useEffect","process","env","NODE_ENV","console","error","join","trim","handler","Symbol","push","indexOf","splice","useState","createMemoryHistory","enabledRef","useRef","configRef","getStateFromPathRef","getPathFromStateRef","getActionFromStateRef","current","server","useContext","ServerContext","getInitialState","useCallback","value","location","window","path","pathname","search","thenable","then","onfulfilled","Promise","resolve","catch","previousIndexRef","previousStateRef","pendingPopStatePathRef","listen","navigation","previousIndex","record","get","resetRoot","rootState","getRootState","some","r","routeNames","includes","name","warn","action","dispatch","e","message","getPathForRoute","route","stateForPath","focusedRoute","findFocusedRoute","isEqual","params","replace","onStateChange","previousState","pendingPath","previousFocusedState","focusedState","historyDelta","nextIndex","backIndex","currentIndex","go","addListener"],"sources":["useLinking.tsx"],"sourcesContent":["import {\n findFocusedRoute,\n getActionFromState as getActionFromStateDefault,\n getPathFromState as getPathFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n NavigationContainerRef,\n NavigationState,\n ParamListBase,\n} from '@react-navigation/core';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport createMemoryHistory from './createMemoryHistory';\nimport ServerContext from './ServerContext';\nimport type { LinkingOptions } from './types';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\n/**\n * Find the matching navigation state that changed between 2 navigation states\n * e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state\n */\nconst findMatchingState = <T extends NavigationState>(\n a: T | undefined,\n b: T | undefined\n): [T | undefined, T | undefined] => {\n if (a === undefined || b === undefined || a.key !== b.key) {\n return [undefined, undefined];\n }\n\n // Tab and drawer will have `history` property, but stack will have history in `routes`\n const aHistoryLength = a.history ? a.history.length : a.routes.length;\n const bHistoryLength = b.history ? b.history.length : b.routes.length;\n\n const aRoute = a.routes[a.index];\n const bRoute = b.routes[b.index];\n\n const aChildState = aRoute.state as T | undefined;\n const bChildState = bRoute.state as T | undefined;\n\n // Stop here if this is the state object that changed:\n // - history length is different\n // - focused routes are different\n // - one of them doesn't have child state\n // - child state keys are different\n if (\n aHistoryLength !== bHistoryLength ||\n aRoute.key !== bRoute.key ||\n aChildState === undefined ||\n bChildState === undefined ||\n aChildState.key !== bChildState.key\n ) {\n return [a, b];\n }\n\n return findMatchingState(aChildState, bChildState);\n};\n\n/**\n * Run async function in series as it's called.\n */\nconst series = (cb: () => Promise<void>) => {\n // Whether we're currently handling a callback\n let handling = false;\n let queue: (() => Promise<void>)[] = [];\n\n const callback = async () => {\n try {\n if (handling) {\n // If we're currently handling a previous event, wait before handling this one\n // Add the callback to the beginning of the queue\n queue.unshift(callback);\n return;\n }\n\n handling = true;\n\n await cb();\n } finally {\n handling = false;\n\n if (queue.length) {\n // If we have queued items, handle the last one\n const last = queue.pop();\n\n last?.();\n }\n }\n };\n\n return callback;\n};\n\nlet linkingHandlers: Symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase> & {\n independent?: boolean;\n};\n\nexport default function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n independent,\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options\n) {\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') {\n return undefined;\n }\n\n if (independent) {\n return undefined;\n }\n\n if (enabled !== false && linkingHandlers.length) {\n console.error(\n [\n 'Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:',\n \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n '- Only a single instance of the root component is rendered',\n ]\n .join('\\n')\n .trim()\n );\n }\n\n const handler = Symbol();\n\n if (enabled !== false) {\n linkingHandlers.push(handler);\n }\n\n return () => {\n const index = linkingHandlers.indexOf(handler);\n\n if (index > -1) {\n linkingHandlers.splice(index, 1);\n }\n };\n }, [enabled, independent]);\n\n const [history] = React.useState(createMemoryHistory);\n\n // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n const enabledRef = React.useRef(enabled);\n const configRef = React.useRef(config);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getPathFromStateRef = React.useRef(getPathFromState);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n configRef.current = config;\n getStateFromPathRef.current = getStateFromPath;\n getPathFromStateRef.current = getPathFromState;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const server = React.useContext(ServerContext);\n\n const getInitialState = React.useCallback(() => {\n let value: ResultState | undefined;\n\n if (enabledRef.current) {\n const location =\n server?.location ??\n (typeof window !== 'undefined' ? window.location : undefined);\n\n const path = location ? location.pathname + location.search : undefined;\n\n if (path) {\n value = getStateFromPathRef.current(path, configRef.current);\n }\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const previousIndexRef = React.useRef<number | undefined>(undefined);\n const previousStateRef = React.useRef<NavigationState | undefined>(undefined);\n const pendingPopStatePathRef = React.useRef<string | undefined>(undefined);\n\n React.useEffect(() => {\n previousIndexRef.current = history.index;\n\n return history.listen(() => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const path = location.pathname + location.search;\n const index = history.index;\n\n const previousIndex = previousIndexRef.current ?? 0;\n\n previousIndexRef.current = index;\n pendingPopStatePathRef.current = path;\n\n // When browser back/forward is clicked, we first need to check if state object for this index exists\n // If it does we'll reset to that state object\n // Otherwise, we'll handle it like a regular deep link\n const record = history.get(index);\n\n if (record?.path === path && record?.state) {\n navigation.resetRoot(record.state);\n return;\n }\n\n const state = getStateFromPathRef.current(path, configRef.current);\n\n // We should only dispatch an action when going forward\n // Otherwise the action will likely add items to history, which would mess things up\n if (state) {\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n const rootState = navigation.getRootState();\n\n if (state.routes.some((r) => !rootState?.routeNames.includes(r.name))) {\n console.warn(\n \"The navigation state parsed from the URL contains routes not present in the root navigator. This usually means that the linking configuration doesn't match the navigation structure. See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.\"\n );\n return;\n }\n\n if (index > previousIndex) {\n const action = getActionFromStateRef.current(\n state,\n configRef.current\n );\n\n if (action !== undefined) {\n try {\n navigation.dispatch(action);\n } catch (e) {\n // Ignore any errors from deep linking.\n // This could happen in case of malformed links, navigation object not being initialized etc.\n console.warn(\n `An error occurred when trying to handle the link '${path}': ${\n typeof e === 'object' && e != null && 'message' in e\n ? // @ts-expect-error: we're already checking for this\n e.message\n : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n // if current path didn't return any state, we should revert to initial state\n navigation.resetRoot(state);\n }\n });\n }, [enabled, history, ref]);\n\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const getPathForRoute = (\n route: ReturnType<typeof findFocusedRoute>,\n state: NavigationState\n ): string => {\n // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match\n // This makes sure that we preserve the original URL for wildcard routes\n if (route?.path) {\n const stateForPath = getStateFromPathRef.current(\n route.path,\n configRef.current\n );\n\n if (stateForPath) {\n const focusedRoute = findFocusedRoute(stateForPath);\n\n if (\n focusedRoute &&\n focusedRoute.name === route.name &&\n isEqual(focusedRoute.params, route.params)\n ) {\n return route.path;\n }\n }\n }\n\n return getPathFromStateRef.current(state, configRef.current);\n };\n\n if (ref.current) {\n // We need to record the current metadata on the first render if they aren't set\n // This will allow the initial state to be in the history entry\n const state = ref.current.getRootState();\n\n if (state) {\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n if (previousStateRef.current === undefined) {\n previousStateRef.current = state;\n }\n\n history.replace({ path, state });\n }\n }\n\n const onStateChange = async () => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const previousState = previousStateRef.current;\n const state = navigation.getRootState();\n\n // root state may not available, for example when root navigators switch inside the container\n if (!state) {\n return;\n }\n\n const pendingPath = pendingPopStatePathRef.current;\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n previousStateRef.current = state;\n pendingPopStatePathRef.current = undefined;\n\n // To detect the kind of state change, we need to:\n // - Find the common focused navigation state in previous and current state\n // - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace\n // - If no common focused navigation state found, it's a replace\n const [previousFocusedState, focusedState] = findMatchingState(\n previousState,\n state\n );\n\n if (\n previousFocusedState &&\n focusedState &&\n // We should only handle push/pop if path changed from what was in last `popstate`\n // Otherwise it's likely a change triggered by `popstate`\n path !== pendingPath\n ) {\n const historyDelta =\n (focusedState.history\n ? focusedState.history.length\n : focusedState.routes.length) -\n (previousFocusedState.history\n ? previousFocusedState.history.length\n : previousFocusedState.routes.length);\n\n if (historyDelta > 0) {\n // If history length is increased, we should pushState\n // Note that path might not actually change here, for example, drawer open should pushState\n history.push({ path, state });\n } else if (historyDelta < 0) {\n // If history length is decreased, i.e. entries were removed, we want to go back\n\n const nextIndex = history.backIndex({ path });\n const currentIndex = history.index;\n\n try {\n if (nextIndex !== -1 && nextIndex < currentIndex) {\n // An existing entry for this path exists and it's less than current index, go back to that\n await history.go(nextIndex - currentIndex);\n } else {\n // We couldn't find an existing entry to go back to, so we'll go back by the delta\n // This won't be correct if multiple routes were pushed in one go before\n // Usually this shouldn't happen and this is a fallback for that\n await history.go(historyDelta);\n }\n\n // Store the updated state as well as fix the path if incorrect\n history.replace({ path, state });\n } catch (e) {\n // The navigation was interrupted\n }\n } else {\n // If history length is unchanged, we want to replaceState\n history.replace({ path, state });\n }\n } else {\n // If no common navigation state was found, assume it's a replace\n // This would happen if the user did a reset/conditionally changed navigators\n history.replace({ path, state });\n }\n };\n\n // We debounce onStateChange coz we don't want multiple state changes to be handled at one time\n // This could happen since `history.go(n)` is asynchronous\n // If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up\n return ref.current?.addListener('state', series(onStateChange));\n });\n\n return {\n getInitialState,\n };\n}\n"],"mappings":";;;;;;;AAAA;;AASA;;AACA;;AAEA;;AACA;;;;;;;;AAKA;AACA;AACA;AACA;AACA,MAAMA,iBAAiB,GAAG,CACxBC,CADwB,EAExBC,CAFwB,KAGW;EACnC,IAAID,CAAC,KAAKE,SAAN,IAAmBD,CAAC,KAAKC,SAAzB,IAAsCF,CAAC,CAACG,GAAF,KAAUF,CAAC,CAACE,GAAtD,EAA2D;IACzD,OAAO,CAACD,SAAD,EAAYA,SAAZ,CAAP;EACD,CAHkC,CAKnC;;;EACA,MAAME,cAAc,GAAGJ,CAAC,CAACK,OAAF,GAAYL,CAAC,CAACK,OAAF,CAAUC,MAAtB,GAA+BN,CAAC,CAACO,MAAF,CAASD,MAA/D;EACA,MAAME,cAAc,GAAGP,CAAC,CAACI,OAAF,GAAYJ,CAAC,CAACI,OAAF,CAAUC,MAAtB,GAA+BL,CAAC,CAACM,MAAF,CAASD,MAA/D;EAEA,MAAMG,MAAM,GAAGT,CAAC,CAACO,MAAF,CAASP,CAAC,CAACU,KAAX,CAAf;EACA,MAAMC,MAAM,GAAGV,CAAC,CAACM,MAAF,CAASN,CAAC,CAACS,KAAX,CAAf;EAEA,MAAME,WAAW,GAAGH,MAAM,CAACI,KAA3B;EACA,MAAMC,WAAW,GAAGH,MAAM,CAACE,KAA3B,CAbmC,CAenC;EACA;EACA;EACA;EACA;;EACA,IACET,cAAc,KAAKI,cAAnB,IACAC,MAAM,CAACN,GAAP,KAAeQ,MAAM,CAACR,GADtB,IAEAS,WAAW,KAAKV,SAFhB,IAGAY,WAAW,KAAKZ,SAHhB,IAIAU,WAAW,CAACT,GAAZ,KAAoBW,WAAW,CAACX,GALlC,EAME;IACA,OAAO,CAACH,CAAD,EAAIC,CAAJ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AhB;MACD;IACF,CAjFD,CAlDoB,CAqIpB;IACA;IACA;;;IACA,uBAAOY,GAAG,CAACgC,OAAX,iDAAO,aAAayD,WAAb,CAAyB,OAAzB,EAAkCnG,MAAM,CAACyF,aAAD,CAAxC,CAAP;EACD,CAzID;EA2IA,OAAO;IACL3C;EADK,CAAP;AAGD"}
1
+ {"version":3,"names":["findMatchingState","a","b","undefined","key","aHistoryLength","history","length","routes","bHistoryLength","aRoute","index","bRoute","aChildState","state","bChildState","series","cb","handling","queue","callback","unshift","last","pop","linkingHandlers","useLinking","ref","independent","enabled","config","getStateFromPath","getStateFromPathDefault","getPathFromState","getPathFromStateDefault","getActionFromState","getActionFromStateDefault","React","useEffect","process","env","NODE_ENV","console","error","join","trim","handler","Symbol","push","indexOf","splice","useState","createMemoryHistory","enabledRef","useRef","configRef","getStateFromPathRef","getPathFromStateRef","getActionFromStateRef","current","server","useContext","ServerContext","getInitialState","useCallback","value","location","window","path","pathname","search","thenable","then","onfulfilled","Promise","resolve","catch","previousIndexRef","previousStateRef","pendingPopStatePathRef","listen","navigation","previousIndex","record","get","resetRoot","rootState","getRootState","some","r","routeNames","includes","name","warn","action","dispatch","e","message","getPathForRoute","route","stateForPath","focusedRoute","findFocusedRoute","isEqual","params","replace","onStateChange","previousState","pendingPath","previousFocusedState","focusedState","historyDelta","nextIndex","backIndex","currentIndex","go","addListener"],"sourceRoot":"../../src","sources":["useLinking.tsx"],"mappings":";;;;;;AAAA;AASA;AACA;AAEA;AACA;AAA4C;AAAA;AAAA;AAK5C;AACA;AACA;AACA;AACA,MAAMA,iBAAiB,GAAG,CACxBC,CAAgB,EAChBC,CAAgB,KACmB;EACnC,IAAID,CAAC,KAAKE,SAAS,IAAID,CAAC,KAAKC,SAAS,IAAIF,CAAC,CAACG,GAAG,KAAKF,CAAC,CAACE,GAAG,EAAE;IACzD,OAAO,CAACD,SAAS,EAAEA,SAAS,CAAC;EAC/B;;EAEA;EACA,MAAME,cAAc,GAAGJ,CAAC,CA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oG,SAAS,KAAK,CAAC,CAAC,IAAIA,SAAS,GAAGE,YAAY,EAAE;cAChD;cACA,MAAM3G,OAAO,CAAC4G,EAAE,CAACH,SAAS,GAAGE,YAAY,CAAC;YAC5C,CAAC,MAAM;cACL;cACA;cACA;cACA,MAAM3G,OAAO,CAAC4G,EAAE,CAACJ,YAAY,CAAC;YAChC;;YAEA;YACAxG,OAAO,CAACkG,OAAO,CAAC;cAAErC,IAAI;cAAErD;YAAM,CAAC,CAAC;UAClC,CAAC,CAAC,OAAOiF,CAAC,EAAE;YACV;UAAA;QAEJ,CAAC,MAAM;UACL;UACAzF,OAAO,CAACkG,OAAO,CAAC;YAAErC,IAAI;YAAErD;UAAM,CAAC,CAAC;QAClC;MACF,CAAC,MAAM;QACL;QACA;QACAR,OAAO,CAACkG,OAAO,CAAC;UAAErC,IAAI;UAAErD;QAAM,CAAC,CAAC;MAClC;IACF,CAAC;;IAED;IACA;IACA;IACA,uBAAOY,GAAG,CAACgC,OAAO,iDAAX,aAAayD,WAAW,CAAC,OAAO,EAAEnG,MAAM,CAACyF,aAAa,CAAC,CAAC;EACjE,CAAC,CAAC;EAEF,OAAO;IACL3C;EACF,CAAC;AACH"}
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useLinking;
7
-
8
7
  var _core = require("@react-navigation/core");
9
-
10
8
  var React = _interopRequireWildcard(require("react"));
11
-
12
9
  var _reactNative = require("react-native");
13
-
14
10
  var _extractPathFromURL = _interopRequireDefault(require("./extractPathFromURL"));
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
13
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
14
  let linkingHandlers = [];
23
-
24
15
  function useLinking(ref, _ref) {
25
16
  let {
26
17
  independent,
@@ -28,22 +19,21 @@ function useLinking(ref, _ref) {
28
19
  prefixes,
29
20
  filter,
30
21
  config,
31
- getInitialURL = () => Promise.race([_reactNative.Linking.getInitialURL(), new Promise(resolve => // Timeout in 150ms if `getInitialState` doesn't resolve
22
+ getInitialURL = () => Promise.race([_reactNative.Linking.getInitialURL(), new Promise(resolve =>
23
+ // Timeout in 150ms if `getInitialState` doesn't resolve
32
24
  // Workaround for https://github.com/facebook/react-native/issues/25675
33
25
  setTimeout(resolve, 150))]),
34
26
  subscribe = listener => {
35
27
  var _Linking$removeEventL;
36
-
37
28
  const callback = _ref2 => {
38
29
  let {
39
30
  url
40
31
  } = _ref2;
41
32
  return listener(url);
42
33
  };
34
+ const subscription = _reactNative.Linking.addEventListener('url', callback);
43
35
 
44
- const subscription = _reactNative.Linking.addEventListener('url', callback); // Storing this in a local variable stops Jest from complaining about import after teardown
45
-
46
-
36
+ // Storing this in a local variable stops Jest from complaining about import after teardown
47
37
  const removeEventListener = (_Linking$removeEventL = _reactNative.Linking.removeEventListener) === null || _Linking$removeEventL === void 0 ? void 0 : _Linking$removeEventL.bind(_reactNative.Linking);
48
38
  return () => {
49
39
  // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7
@@ -61,32 +51,27 @@ function useLinking(ref, _ref) {
61
51
  if (process.env.NODE_ENV === 'production') {
62
52
  return undefined;
63
53
  }
64
-
65
54
  if (independent) {
66
55
  return undefined;
67
56
  }
68
-
69
57
  if (enabled !== false && linkingHandlers.length) {
70
58
  console.error(['Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:', "- You don't have multiple NavigationContainers in the app each with 'linking' enabled", '- Only a single instance of the root component is rendered', _reactNative.Platform.OS === 'android' ? "- You have set 'android:launchMode=singleTask' in the '<activity />' section of the 'AndroidManifest.xml' file to avoid launching multiple instances" : ''].join('\n').trim());
71
59
  }
72
-
73
60
  const handler = Symbol();
74
-
75
61
  if (enabled !== false) {
76
62
  linkingHandlers.push(handler);
77
63
  }
78
-
79
64
  return () => {
80
65
  const index = linkingHandlers.indexOf(handler);
81
-
82
66
  if (index > -1) {
83
67
  linkingHandlers.splice(index, 1);
84
68
  }
85
69
  };
86
- }, [enabled, independent]); // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
70
+ }, [enabled, independent]);
71
+
72
+ // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
87
73
  // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`
88
74
  // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect
89
-
90
75
  const enabledRef = React.useRef(enabled);
91
76
  const prefixesRef = React.useRef(prefixes);
92
77
  const filterRef = React.useRef(filter);
@@ -107,35 +92,28 @@ function useLinking(ref, _ref) {
107
92
  if (!url || filterRef.current && !filterRef.current(url)) {
108
93
  return undefined;
109
94
  }
110
-
111
95
  const path = (0, _extractPathFromURL.default)(prefixesRef.current, url);
112
96
  return path !== undefined ? getStateFromPathRef.current(path, configRef.current) : undefined;
113
97
  }, []);
114
98
  const getInitialState = React.useCallback(() => {
115
99
  let state;
116
-
117
100
  if (enabledRef.current) {
118
101
  const url = getInitialURLRef.current();
119
-
120
102
  if (url != null && typeof url !== 'string') {
121
103
  return url.then(url => {
122
104
  const state = getStateFromURL(url);
123
105
  return state;
124
106
  });
125
107
  }
126
-
127
108
  state = getStateFromURL(url);
128
109
  }
129
-
130
110
  const thenable = {
131
111
  then(onfulfilled) {
132
112
  return Promise.resolve(onfulfilled ? onfulfilled(state) : state);
133
113
  },
134
-
135
114
  catch() {
136
115
  return thenable;
137
116
  }
138
-
139
117
  };
140
118
  return thenable;
141
119
  }, [getStateFromURL]);
@@ -144,29 +122,25 @@ function useLinking(ref, _ref) {
144
122
  if (!enabled) {
145
123
  return;
146
124
  }
147
-
148
125
  const navigation = ref.current;
149
126
  const state = navigation ? getStateFromURL(url) : undefined;
150
-
151
127
  if (navigation && state) {
152
128
  // Make sure that the routes in the state exist in the root navigator
153
129
  // Otherwise there's an error in the linking configuration
154
130
  const rootState = navigation.getRootState();
155
-
156
131
  if (state.routes.some(r => !(rootState !== null && rootState !== void 0 && rootState.routeNames.includes(r.name)))) {
157
132
  console.warn("The navigation state parsed from the URL contains routes not present in the root navigator. This usually means that the linking configuration doesn't match the navigation structure. See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.");
158
133
  return;
159
134
  }
160
-
161
135
  const action = getActionFromStateRef.current(state, configRef.current);
162
-
163
136
  if (action !== undefined) {
164
137
  try {
165
138
  navigation.dispatch(action);
166
139
  } catch (e) {
167
140
  // Ignore any errors from deep linking.
168
141
  // This could happen in case of malformed links, navigation object not being initialized etc.
169
- console.warn(`An error occurred when trying to handle the link '${url}': ${typeof e === 'object' && e != null && 'message' in e ? // @ts-expect-error: we're already checking for this
142
+ console.warn(`An error occurred when trying to handle the link '${url}': ${typeof e === 'object' && e != null && 'message' in e ?
143
+ // @ts-expect-error: we're already checking for this
170
144
  e.message : e}`);
171
145
  }
172
146
  } else {
@@ -174,7 +148,6 @@ function useLinking(ref, _ref) {
174
148
  }
175
149
  }
176
150
  };
177
-
178
151
  return subscribe(listener);
179
152
  }, [enabled, getStateFromURL, ref, subscribe]);
180
153
  return {