@amazon-devices/react-navigation__native 2.0.1758683737

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 (189) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +5 -0
  3. package/SystemBundles/6132afb62bda3afb78ba1a1aca51924df73e9dbcc77106aa0f97a0ef68b04ebb.bundle +15196 -0
  4. package/SystemBundles/6132afb62bda3afb78ba1a1aca51924df73e9dbcc77106aa0f97a0ef68b04ebb.map +1 -0
  5. package/SystemModules/amzn__react-navigation__native-2.modules.txt +76 -0
  6. package/SystemModules/amzn__react-navigation__native-2.private.modules.txt +101 -0
  7. package/SystemModules/keplerscript-system-bundle-config.json +7 -0
  8. package/THIRD_PARTY_NOTICES.txt +24 -0
  9. package/kepler-compatibility.json +8 -0
  10. package/kepler-transformed-package-info.json +3 -0
  11. package/lib/commonjs/Link.js +50 -0
  12. package/lib/commonjs/Link.js.map +1 -0
  13. package/lib/commonjs/LinkingContext.js +15 -0
  14. package/lib/commonjs/LinkingContext.js.map +1 -0
  15. package/lib/commonjs/NavigationContainer.js +109 -0
  16. package/lib/commonjs/NavigationContainer.js.map +1 -0
  17. package/lib/commonjs/ServerContainer.js +54 -0
  18. package/lib/commonjs/ServerContainer.js.map +1 -0
  19. package/lib/commonjs/ServerContext.js +12 -0
  20. package/lib/commonjs/ServerContext.js.map +1 -0
  21. package/lib/commonjs/createMemoryHistory.js +220 -0
  22. package/lib/commonjs/createMemoryHistory.js.map +1 -0
  23. package/lib/commonjs/extractPathFromURL.js +25 -0
  24. package/lib/commonjs/extractPathFromURL.js.map +1 -0
  25. package/lib/commonjs/index.js +129 -0
  26. package/lib/commonjs/index.js.map +1 -0
  27. package/lib/commonjs/theming/DarkTheme.js +19 -0
  28. package/lib/commonjs/theming/DarkTheme.js.map +1 -0
  29. package/lib/commonjs/theming/DefaultTheme.js +19 -0
  30. package/lib/commonjs/theming/DefaultTheme.js.map +1 -0
  31. package/lib/commonjs/theming/ThemeContext.js +15 -0
  32. package/lib/commonjs/theming/ThemeContext.js.map +1 -0
  33. package/lib/commonjs/theming/ThemeProvider.js +20 -0
  34. package/lib/commonjs/theming/ThemeProvider.js.map +1 -0
  35. package/lib/commonjs/theming/useTheme.js +16 -0
  36. package/lib/commonjs/theming/useTheme.js.map +1 -0
  37. package/lib/commonjs/types.js +6 -0
  38. package/lib/commonjs/types.js.map +1 -0
  39. package/lib/commonjs/useBackButton.js +11 -0
  40. package/lib/commonjs/useBackButton.js.map +1 -0
  41. package/lib/commonjs/useBackButton.native.js +27 -0
  42. package/lib/commonjs/useBackButton.native.js.map +1 -0
  43. package/lib/commonjs/useDocumentTitle.js +32 -0
  44. package/lib/commonjs/useDocumentTitle.js.map +1 -0
  45. package/lib/commonjs/useDocumentTitle.native.js +10 -0
  46. package/lib/commonjs/useDocumentTitle.native.js.map +1 -0
  47. package/lib/commonjs/useLinkBuilder.js +63 -0
  48. package/lib/commonjs/useLinkBuilder.js.map +1 -0
  49. package/lib/commonjs/useLinkProps.js +97 -0
  50. package/lib/commonjs/useLinkProps.js.map +1 -0
  51. package/lib/commonjs/useLinkTo.js +45 -0
  52. package/lib/commonjs/useLinkTo.js.map +1 -0
  53. package/lib/commonjs/useLinking.js +303 -0
  54. package/lib/commonjs/useLinking.js.map +1 -0
  55. package/lib/commonjs/useLinking.native.js +152 -0
  56. package/lib/commonjs/useLinking.native.js.map +1 -0
  57. package/lib/commonjs/useScrollToTop.js +95 -0
  58. package/lib/commonjs/useScrollToTop.js.map +1 -0
  59. package/lib/commonjs/useThenable.js +41 -0
  60. package/lib/commonjs/useThenable.js.map +1 -0
  61. package/lib/module/Link.js +41 -0
  62. package/lib/module/Link.js.map +1 -0
  63. package/lib/module/LinkingContext.js +7 -0
  64. package/lib/module/LinkingContext.js.map +1 -0
  65. package/lib/module/NavigationContainer.js +100 -0
  66. package/lib/module/NavigationContainer.js.map +1 -0
  67. package/lib/module/ServerContainer.js +45 -0
  68. package/lib/module/ServerContainer.js.map +1 -0
  69. package/lib/module/ServerContext.js +4 -0
  70. package/lib/module/ServerContext.js.map +1 -0
  71. package/lib/module/createMemoryHistory.js +214 -0
  72. package/lib/module/createMemoryHistory.js.map +1 -0
  73. package/lib/module/extractPathFromURL.js +18 -0
  74. package/lib/module/extractPathFromURL.js.map +1 -0
  75. package/lib/module/index.js +15 -0
  76. package/lib/module/index.js.map +1 -0
  77. package/lib/module/theming/DarkTheme.js +13 -0
  78. package/lib/module/theming/DarkTheme.js.map +1 -0
  79. package/lib/module/theming/DefaultTheme.js +13 -0
  80. package/lib/module/theming/DefaultTheme.js.map +1 -0
  81. package/lib/module/theming/ThemeContext.js +6 -0
  82. package/lib/module/theming/ThemeContext.js.map +1 -0
  83. package/lib/module/theming/ThemeProvider.js +11 -0
  84. package/lib/module/theming/ThemeProvider.js.map +1 -0
  85. package/lib/module/theming/useTheme.js +7 -0
  86. package/lib/module/theming/useTheme.js.map +1 -0
  87. package/lib/module/types.js +2 -0
  88. package/lib/module/types.js.map +1 -0
  89. package/lib/module/useBackButton.js +5 -0
  90. package/lib/module/useBackButton.js.map +1 -0
  91. package/lib/module/useBackButton.native.js +19 -0
  92. package/lib/module/useBackButton.native.js.map +1 -0
  93. package/lib/module/useDocumentTitle.js +24 -0
  94. package/lib/module/useDocumentTitle.js.map +1 -0
  95. package/lib/module/useDocumentTitle.native.js +4 -0
  96. package/lib/module/useDocumentTitle.native.js.map +1 -0
  97. package/lib/module/useLinkBuilder.js +54 -0
  98. package/lib/module/useLinkBuilder.js.map +1 -0
  99. package/lib/module/useLinkProps.js +88 -0
  100. package/lib/module/useLinkProps.js.map +1 -0
  101. package/lib/module/useLinkTo.js +36 -0
  102. package/lib/module/useLinkTo.js.map +1 -0
  103. package/lib/module/useLinking.js +292 -0
  104. package/lib/module/useLinking.js.map +1 -0
  105. package/lib/module/useLinking.native.js +143 -0
  106. package/lib/module/useLinking.native.js.map +1 -0
  107. package/lib/module/useScrollToTop.js +87 -0
  108. package/lib/module/useScrollToTop.js.map +1 -0
  109. package/lib/module/useThenable.js +33 -0
  110. package/lib/module/useThenable.js.map +1 -0
  111. package/lib/typescript/src/Link.d.ts +24 -0
  112. package/lib/typescript/src/Link.d.ts.map +1 -0
  113. package/lib/typescript/src/LinkingContext.d.ts +8 -0
  114. package/lib/typescript/src/LinkingContext.d.ts.map +1 -0
  115. package/lib/typescript/src/NavigationContainer.d.ts +26 -0
  116. package/lib/typescript/src/NavigationContainer.d.ts.map +1 -0
  117. package/lib/typescript/src/ServerContainer.d.ts +15 -0
  118. package/lib/typescript/src/ServerContainer.d.ts.map +1 -0
  119. package/lib/typescript/src/ServerContext.d.ts +10 -0
  120. package/lib/typescript/src/ServerContext.d.ts.map +1 -0
  121. package/lib/typescript/src/__mocks__/window.d.ts +19 -0
  122. package/lib/typescript/src/__mocks__/window.d.ts.map +1 -0
  123. package/lib/typescript/src/createMemoryHistory.d.ts +25 -0
  124. package/lib/typescript/src/createMemoryHistory.d.ts.map +1 -0
  125. package/lib/typescript/src/extractPathFromURL.d.ts +2 -0
  126. package/lib/typescript/src/extractPathFromURL.d.ts.map +1 -0
  127. package/lib/typescript/src/index.d.ts +15 -0
  128. package/lib/typescript/src/index.d.ts.map +1 -0
  129. package/lib/typescript/src/theming/DarkTheme.d.ts +4 -0
  130. package/lib/typescript/src/theming/DarkTheme.d.ts.map +1 -0
  131. package/lib/typescript/src/theming/DefaultTheme.d.ts +4 -0
  132. package/lib/typescript/src/theming/DefaultTheme.d.ts.map +1 -0
  133. package/lib/typescript/src/theming/ThemeContext.d.ts +5 -0
  134. package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -0
  135. package/lib/typescript/src/theming/ThemeProvider.d.ts +9 -0
  136. package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -0
  137. package/lib/typescript/src/theming/useTheme.d.ts +2 -0
  138. package/lib/typescript/src/theming/useTheme.d.ts.map +1 -0
  139. package/lib/typescript/src/types.d.ts +127 -0
  140. package/lib/typescript/src/types.d.ts.map +1 -0
  141. package/lib/typescript/src/useBackButton.d.ts +4 -0
  142. package/lib/typescript/src/useBackButton.d.ts.map +1 -0
  143. package/lib/typescript/src/useBackButton.native.d.ts +4 -0
  144. package/lib/typescript/src/useBackButton.native.d.ts.map +1 -0
  145. package/lib/typescript/src/useDocumentTitle.d.ts +8 -0
  146. package/lib/typescript/src/useDocumentTitle.d.ts.map +1 -0
  147. package/lib/typescript/src/useDocumentTitle.native.d.ts +2 -0
  148. package/lib/typescript/src/useDocumentTitle.native.d.ts.map +1 -0
  149. package/lib/typescript/src/useLinkBuilder.d.ts +6 -0
  150. package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -0
  151. package/lib/typescript/src/useLinkProps.d.ts +21 -0
  152. package/lib/typescript/src/useLinkProps.d.ts.map +1 -0
  153. package/lib/typescript/src/useLinkTo.d.ts +9 -0
  154. package/lib/typescript/src/useLinkTo.d.ts.map +1 -0
  155. package/lib/typescript/src/useLinking.d.ts +55 -0
  156. package/lib/typescript/src/useLinking.d.ts.map +1 -0
  157. package/lib/typescript/src/useLinking.native.d.ts +51 -0
  158. package/lib/typescript/src/useLinking.native.d.ts.map +1 -0
  159. package/lib/typescript/src/useScrollToTop.d.ts +27 -0
  160. package/lib/typescript/src/useScrollToTop.d.ts.map +1 -0
  161. package/lib/typescript/src/useThenable.d.ts +2 -0
  162. package/lib/typescript/src/useThenable.d.ts.map +1 -0
  163. package/package.json +1 -0
  164. package/src/Link.tsx +53 -0
  165. package/src/LinkingContext.tsx +12 -0
  166. package/src/NavigationContainer.tsx +152 -0
  167. package/src/ServerContainer.tsx +56 -0
  168. package/src/ServerContext.tsx +14 -0
  169. package/src/__mocks__/window.tsx +77 -0
  170. package/src/createMemoryHistory.tsx +224 -0
  171. package/src/extractPathFromURL.tsx +29 -0
  172. package/src/index.tsx +14 -0
  173. package/src/theming/DarkTheme.tsx +15 -0
  174. package/src/theming/DefaultTheme.tsx +15 -0
  175. package/src/theming/ThemeContext.tsx +10 -0
  176. package/src/theming/ThemeProvider.tsx +15 -0
  177. package/src/theming/useTheme.tsx +9 -0
  178. package/src/types.tsx +145 -0
  179. package/src/useBackButton.native.tsx +33 -0
  180. package/src/useBackButton.tsx +11 -0
  181. package/src/useDocumentTitle.native.tsx +3 -0
  182. package/src/useDocumentTitle.tsx +41 -0
  183. package/src/useLinkBuilder.tsx +82 -0
  184. package/src/useLinkProps.tsx +126 -0
  185. package/src/useLinkTo.tsx +71 -0
  186. package/src/useLinking.native.tsx +215 -0
  187. package/src/useLinking.tsx +395 -0
  188. package/src/useScrollToTop.tsx +116 -0
  189. package/src/useThenable.tsx +41 -0
@@ -0,0 +1,214 @@
1
+ import { nanoid } from 'nanoid/non-secure';
2
+ export default function createMemoryHistory() {
3
+ let index = 0;
4
+ let items = [];
5
+
6
+ // Pending callbacks for `history.go(n)`
7
+ // We might modify the callback stored if it was interrupted, so we have a ref to identify it
8
+ const pending = [];
9
+ const interrupt = () => {
10
+ // If another history operation was performed we need to interrupt existing ones
11
+ // This makes sure that calls such as `history.replace` after `history.go` don't happen
12
+ // Since otherwise it won't be correct if something else has changed
13
+ pending.forEach(it => {
14
+ const cb = it.cb;
15
+ it.cb = () => cb(true);
16
+ });
17
+ };
18
+ const history = {
19
+ get index() {
20
+ var _window$history$state;
21
+ // We store an id in the state instead of an index
22
+ // Index could get out of sync with in-memory values if page reloads
23
+ const id = (_window$history$state = window.history.state) === null || _window$history$state === void 0 ? void 0 : _window$history$state.id;
24
+ if (id) {
25
+ const index = items.findIndex(item => item.id === id);
26
+ return index > -1 ? index : 0;
27
+ }
28
+ return 0;
29
+ },
30
+ get(index) {
31
+ return items[index];
32
+ },
33
+ backIndex({
34
+ path
35
+ }) {
36
+ // We need to find the index from the element before current to get closest path to go back to
37
+ for (let i = index - 1; i >= 0; i--) {
38
+ const item = items[i];
39
+ if (item.path === path) {
40
+ return i;
41
+ }
42
+ }
43
+ return -1;
44
+ },
45
+ push({
46
+ path,
47
+ state
48
+ }) {
49
+ interrupt();
50
+ const id = nanoid();
51
+
52
+ // When a new entry is pushed, all the existing entries after index will be inaccessible
53
+ // So we remove any existing entries after the current index to clean them up
54
+ items = items.slice(0, index + 1);
55
+ items.push({
56
+ path,
57
+ state,
58
+ id
59
+ });
60
+ index = items.length - 1;
61
+
62
+ // We pass empty string for title because it's ignored in all browsers except safari
63
+ // We don't store state object in history.state because:
64
+ // - browsers have limits on how big it can be, and we don't control the size
65
+ // - while not recommended, there could be non-serializable data in state
66
+ window.history.pushState({
67
+ id
68
+ }, '', path);
69
+ },
70
+ replace({
71
+ path,
72
+ state
73
+ }) {
74
+ var _window$history$state2;
75
+ interrupt();
76
+ const id = ((_window$history$state2 = window.history.state) === null || _window$history$state2 === void 0 ? void 0 : _window$history$state2.id) ?? nanoid();
77
+
78
+ // Need to keep the hash part of the path if there was no previous history entry
79
+ // or the previous history entry had the same path
80
+ let pathWithHash = path;
81
+ if (!items.length || items.findIndex(item => item.id === id) < 0) {
82
+ // There are two scenarios for creating an array with only one history record:
83
+ // - When loaded id not found in the items array, this function by default will replace
84
+ // the first item. We need to keep only the new updated object, otherwise it will break
85
+ // the page when navigating forward in history.
86
+ // - This is the first time any state modifications are done
87
+ // So we need to push the entry as there's nothing to replace
88
+ pathWithHash = pathWithHash + location.hash;
89
+ items = [{
90
+ path: pathWithHash,
91
+ state,
92
+ id
93
+ }];
94
+ index = 0;
95
+ } else {
96
+ if (items[index].path === path) {
97
+ pathWithHash = pathWithHash + location.hash;
98
+ }
99
+ items[index] = {
100
+ path,
101
+ state,
102
+ id
103
+ };
104
+ }
105
+ window.history.replaceState({
106
+ id
107
+ }, '', pathWithHash);
108
+ },
109
+ // `history.go(n)` is asynchronous, there are couple of things to keep in mind:
110
+ // - it won't do anything if we can't go `n` steps, the `popstate` event won't fire.
111
+ // - each `history.go(n)` call will trigger a separate `popstate` event with correct location.
112
+ // - the `popstate` event fires before the next frame after calling `history.go(n)`.
113
+ // This method differs from `history.go(n)` in the sense that it'll go back as many steps it can.
114
+ go(n) {
115
+ interrupt();
116
+
117
+ // To guard against unexpected navigation out of the app we will assume that browser history is only as deep as the length of our memory
118
+ // history. If we don't have an item to navigate to then update our index and navigate as far as we can without taking the user out of the app.
119
+ const nextIndex = index + n;
120
+ const lastItemIndex = items.length - 1;
121
+ if (n < 0 && !items[nextIndex]) {
122
+ // Attempted to navigate beyond the first index. Negating the current index will align the browser history with the first item.
123
+ n = -index;
124
+ index = 0;
125
+ } else if (n > 0 && nextIndex > lastItemIndex) {
126
+ // Attempted to navigate past the last index. Calculate how many indices away from the last index and go there.
127
+ n = lastItemIndex - index;
128
+ index = lastItemIndex;
129
+ } else {
130
+ index = nextIndex;
131
+ }
132
+ if (n === 0) {
133
+ return;
134
+ }
135
+
136
+ // When we call `history.go`, `popstate` will fire when there's history to go back to
137
+ // So we need to somehow handle following cases:
138
+ // - There's history to go back, `history.go` is called, and `popstate` fires
139
+ // - `history.go` is called multiple times, we need to resolve on respective `popstate`
140
+ // - No history to go back, but `history.go` was called, browser has no API to detect it
141
+ return new Promise((resolve, reject) => {
142
+ const done = interrupted => {
143
+ clearTimeout(timer);
144
+ if (interrupted) {
145
+ reject(new Error('History was changed during navigation.'));
146
+ return;
147
+ }
148
+
149
+ // There seems to be a bug in Chrome regarding updating the title
150
+ // If we set a title just before calling `history.go`, the title gets lost
151
+ // However the value of `document.title` is still what we set it to
152
+ // It's just not displayed in the tab bar
153
+ // To update the tab bar, we need to reset the title to something else first (e.g. '')
154
+ // And set the title to what it was before so it gets applied
155
+ // It won't work without setting it to empty string coz otherwise title isn't changing
156
+ // Which means that the browser won't do anything after setting the title
157
+ const {
158
+ title
159
+ } = window.document;
160
+ window.document.title = '';
161
+ window.document.title = title;
162
+ resolve();
163
+ };
164
+ pending.push({
165
+ ref: done,
166
+ cb: done
167
+ });
168
+
169
+ // If navigation didn't happen within 100ms, assume that it won't happen
170
+ // This may not be accurate, but hopefully it won't take so much time
171
+ // In Chrome, navigation seems to happen instantly in next microtask
172
+ // But on Firefox, it seems to take much longer, around 50ms from our testing
173
+ // We're using a hacky timeout since there doesn't seem to be way to know for sure
174
+ const timer = setTimeout(() => {
175
+ const index = pending.findIndex(it => it.ref === done);
176
+ if (index > -1) {
177
+ pending[index].cb();
178
+ pending.splice(index, 1);
179
+ }
180
+ }, 100);
181
+ const onPopState = () => {
182
+ var _window$history$state3;
183
+ const id = (_window$history$state3 = window.history.state) === null || _window$history$state3 === void 0 ? void 0 : _window$history$state3.id;
184
+ const currentIndex = items.findIndex(item => item.id === id);
185
+
186
+ // Fix createMemoryHistory.index variable's value
187
+ // as it may go out of sync when navigating in the browser.
188
+ index = Math.max(currentIndex, 0);
189
+ const last = pending.pop();
190
+ window.removeEventListener('popstate', onPopState);
191
+ last === null || last === void 0 || last.cb();
192
+ };
193
+ window.addEventListener('popstate', onPopState);
194
+ window.history.go(n);
195
+ });
196
+ },
197
+ // The `popstate` event is triggered when history changes, except `pushState` and `replaceState`
198
+ // If we call `history.go(n)` ourselves, we don't want it to trigger the listener
199
+ // Here we normalize it so that only external changes (e.g. user pressing back/forward) trigger the listener
200
+ listen(listener) {
201
+ const onPopState = () => {
202
+ if (pending.length) {
203
+ // This was triggered by `history.go(n)`, we shouldn't call the listener
204
+ return;
205
+ }
206
+ listener();
207
+ };
208
+ window.addEventListener('popstate', onPopState);
209
+ return () => window.removeEventListener('popstate', onPopState);
210
+ }
211
+ };
212
+ return history;
213
+ }
214
+ //# sourceMappingURL=createMemoryHistory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["nanoid","createMemoryHistory","index","items","pending","interrupt","forEach","it","cb","history","_window$history$state","id","window","state","findIndex","item","get","backIndex","path","i","push","slice","length","pushState","replace","_window$history$state2","pathWithHash","location","hash","replaceState","go","n","nextIndex","lastItemIndex","Promise","resolve","reject","done","interrupted","clearTimeout","timer","Error","title","document","ref","setTimeout","splice","onPopState","_window$history$state3","currentIndex","Math","max","last","pop","removeEventListener","addEventListener","listen","listener"],"sourceRoot":"../../src","sources":["createMem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AAC,UAAU,EAAER,UAAU,CAAC;QAC/CnC,MAAM,CAACH,OAAO,CAACqB,EAAE,CAACC,CAAC,CAAC;MACtB,CAAC,CAAC;IACJ,CAAC;IAED;IACA;IACA;IACAyB,MAAMA,CAACC,QAAoB,EAAE;MAC3B,MAAMV,UAAU,GAAGA,CAAA,KAAM;QACvB,IAAI3C,OAAO,CAACkB,MAAM,EAAE;UAClB;UACA;QACF;QAEAmC,QAAQ,CAAC,CAAC;MACZ,CAAC;MAED7C,MAAM,CAAC2C,gBAAgB,CAAC,UAAU,EAAER,UAAU,CAAC;MAE/C,OAAO,MAAMnC,MAAM,CAAC0C,mBAAmB,CAAC,UAAU,EAAEP,UAAU,CAAC;IACjE;EACF,CAAC;EAED,OAAOtC,OAAO;AAChB","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ import escapeStringRegexp from 'escape-string-regexp';
2
+ export default function extractPathFromURL(prefixes, url) {
3
+ for (const prefix of prefixes) {
4
+ var _prefix$match;
5
+ const protocol = ((_prefix$match = prefix.match(/^[^:]+:/)) === null || _prefix$match === void 0 ? void 0 : _prefix$match[0]) ?? '';
6
+ const host = prefix.replace(new RegExp(`^${escapeStringRegexp(protocol)}`), '').replace(/\/+/g, '/') // Replace multiple slash (//) with single ones
7
+ .replace(/^\//, ''); // Remove extra leading slash
8
+
9
+ const prefixRegex = new RegExp(`^${escapeStringRegexp(protocol)}(/)*${host.split('.').map(it => it === '*' ? '[^/]+' : escapeStringRegexp(it)).join('\\.')}`);
10
+ const [originAndPath, searchParams] = url.split('?');
11
+ const normalizedURL = originAndPath.replace(/\/+/g, '/').concat(searchParams ? `?${searchParams}` : '');
12
+ if (prefixRegex.test(normalizedURL)) {
13
+ return normalizedURL.replace(prefixRegex, '');
14
+ }
15
+ }
16
+ return undefined;
17
+ }
18
+ //# sourceMappingURL=extractPathFromURL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["escapeStringRegexp","extractPathFromURL","prefixes","url","prefix","_prefix$match","protocol","match","host","replace","RegExp","prefixRegex","split","map","it","join","originAndPath","searchParams","normalizedURL","concat","test","undefined"],"sourceRoot":"../../src","sources":["extractPathFromURL.tsx"],"mappings":"AAAA,OAAOA,kBAAkB,MAAM,sBAAsB;AAErD,eAAe,SAASC,kBAAkBA,CAACC,QAAkB,EAAEC,GAAW,EAAE;EAC1E,KAAK,MAAMC,MAAM,IAAIF,QAAQ,EAAE;IAAA,IAAAG,aAAA;IAC7B,MAAMC,QAAQ,GAAG,EAAAD,aAAA,GAAAD,MAAM,CAACG,KAAK,CAAC,SAAS,CAAC,cAAAF,aAAA,uBAAvBA,aAAA,CAA0B,CAAC,CAAC,KAAI,EAAE;IACnD,MAAMG,IAAI,GAAGJ,MAAM,CAChBK,OAAO,CAAC,IAAIC,MAAM,CAAC,IAAIV,kBAAkB,CAACM,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAC3DG,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAA,CACrBA,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;;IAEvB,MAAME,WAAW,GAAG,IAAID,MAAM,CAC5B,IAAIV,kBAAkB,CAACM,QAAQ,CAAC,OAAOE,IAAI,CACxCI,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAAEC,EAAE,IAAMA,EAAE,KAAK,GAAG,GAAG,OAAO,GAAGd,kBAAkB,CAACc,EAAE,CAAE,CAAC,CAC5DC,IAAI,CAAC,KAAK,CAAC,EAChB,CAAC;IAED,MAAM,CAACC,aAAa,EAAEC,YAAY,CAAC,GAAGd,GAAG,CAACS,KAAK,CAAC,GAAG,CAAC;IACpD,MAAMM,aAAa,GAAGF,aAAa,CAChCP,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CACpBU,MAAM,CAACF,YAAY,GAAG,IAAIA,YAAY,EAAE,GAAG,EAAE,CAAC;IAEjD,IAAIN,WAAW,CAACS,IAAI,CAACF,aAAa,CAAC,EAAE;MACnC,OAAOA,aAAa,CAACT,OAAO,CAACE,WAAW,EAAE,EAAE,CAAC;IAC/C;EACF;EAEA,OAAOU,SAAS;AAClB","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ export { default as Link } from './Link';
2
+ export { default as LinkingContext } from './LinkingContext';
3
+ export { default as NavigationContainer } from './NavigationContainer';
4
+ export { default as ServerContainer } from './ServerContainer';
5
+ export { default as DarkTheme } from './theming/DarkTheme';
6
+ export { default as DefaultTheme } from './theming/DefaultTheme';
7
+ export { default as ThemeProvider } from './theming/ThemeProvider';
8
+ export { default as useTheme } from './theming/useTheme';
9
+ export * from './types';
10
+ export { default as useLinkBuilder } from './useLinkBuilder';
11
+ export { default as useLinkProps } from './useLinkProps';
12
+ export { default as useLinkTo } from './useLinkTo';
13
+ export { default as useScrollToTop } from './useScrollToTop';
14
+ export * from '@amazon-devices/react-navigation__core';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","Link","LinkingContext","NavigationContainer","ServerContainer","DarkTheme","DefaultTheme","ThemeProvider","useTheme","useLinkBuilder","useLinkProps","useLinkTo","useScrollToTop"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,OAAO,IAAIC,IAAI,QAAQ,QAAQ;AACxC,SAASD,OAAO,IAAIE,cAAc,QAAQ,kBAAkB;AAC5D,SAASF,OAAO,IAAIG,mBAAmB,QAAQ,uBAAuB;AACtE,SAASH,OAAO,IAAII,eAAe,QAAQ,mBAAmB;AAC9D,SAASJ,OAAO,IAAIK,SAAS,QAAQ,qBAAqB;AAC1D,SAASL,OAAO,IAAIM,YAAY,QAAQ,wBAAwB;AAChE,SAASN,OAAO,IAAIO,aAAa,QAAQ,yBAAyB;AAClE,SAASP,OAAO,IAAIQ,QAAQ,QAAQ,oBAAoB;AACxD,cAAc,SAAS;AACvB,SAASR,OAAO,IAAIS,cAAc,QAAQ,kBAAkB;AAC5D,SAAST,OAAO,IAAIU,YAAY,QAAQ,gBAAgB;AACxD,SAASV,OAAO,IAAIW,SAAS,QAAQ,aAAa;AAClD,SAASX,OAAO,IAAIY,cAAc,QAAQ,kBAAkB;AAC5D,cAAc,8BAA8B","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ const DarkTheme = {
2
+ dark: true,
3
+ colors: {
4
+ primary: 'rgb(10, 132, 255)',
5
+ background: 'rgb(1, 1, 1)',
6
+ card: 'rgb(18, 18, 18)',
7
+ text: 'rgb(229, 229, 231)',
8
+ border: 'rgb(39, 39, 41)',
9
+ notification: 'rgb(255, 69, 58)'
10
+ }
11
+ };
12
+ export default DarkTheme;
13
+ //# sourceMappingURL=DarkTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DarkTheme","dark","colors","primary","background","card","text","border","notification"],"sourceRoot":"../../../src","sources":["theming/DarkTheme.tsx"],"mappings":"AAEA,MAAMA,SAAgB,GAAG;EACvBC,IAAI,EAAE,IAAI;EACVC,MAAM,EAAE;IACNC,OAAO,EAAE,mBAAmB;IAC5BC,UAAU,EAAE,cAAc;IAC1BC,IAAI,EAAE,iBAAiB;IACvBC,IAAI,EAAE,oBAAoB;IAC1BC,MAAM,EAAE,iBAAiB;IACzBC,YAAY,EAAE;EAChB;AACF,CAAC;AAED,eAAeR,SAAS","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ const DefaultTheme = {
2
+ dark: false,
3
+ colors: {
4
+ primary: 'rgb(0, 122, 255)',
5
+ background: 'rgb(242, 242, 242)',
6
+ card: 'rgb(255, 255, 255)',
7
+ text: 'rgb(28, 28, 30)',
8
+ border: 'rgb(216, 216, 216)',
9
+ notification: 'rgb(255, 59, 48)'
10
+ }
11
+ };
12
+ export default DefaultTheme;
13
+ //# sourceMappingURL=DefaultTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DefaultTheme","dark","colors","primary","background","card","text","border","notification"],"sourceRoot":"../../../src","sources":["theming/DefaultTheme.tsx"],"mappings":"AAEA,MAAMA,YAAmB,GAAG;EAC1BC,IAAI,EAAE,KAAK;EACXC,MAAM,EAAE;IACNC,OAAO,EAAE,kBAAkB;IAC3BC,UAAU,EAAE,oBAAoB;IAChCC,IAAI,EAAE,oBAAoB;IAC1BC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE,oBAAoB;IAC5BC,YAAY,EAAE;EAChB;AACF,CAAC;AAED,eAAeR,YAAY","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ import DefaultTheme from './DefaultTheme';
3
+ const ThemeContext = /*#__PURE__*/React.createContext(DefaultTheme);
4
+ ThemeContext.displayName = 'ThemeContext';
5
+ export default ThemeContext;
6
+ //# sourceMappingURL=ThemeContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","DefaultTheme","ThemeContext","createContext","displayName"],"sourceRoot":"../../../src","sources":["theming/ThemeContext.tsx"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAG9B,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,MAAMC,YAAY,gBAAGF,KAAK,CAACG,aAAa,CAAQF,YAAY,CAAC;AAE7DC,YAAY,CAACE,WAAW,GAAG,cAAc;AAEzC,eAAeF,YAAY","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import ThemeContext from './ThemeContext';
3
+ export default function ThemeProvider({
4
+ value,
5
+ children
6
+ }) {
7
+ return /*#__PURE__*/React.createElement(ThemeContext.Provider, {
8
+ value: value
9
+ }, children);
10
+ }
11
+ //# sourceMappingURL=ThemeProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","ThemeContext","ThemeProvider","value","children","createElement","Provider"],"sourceRoot":"../../../src","sources":["theming/ThemeProvider.tsx"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAG9B,OAAOC,YAAY,MAAM,gBAAgB;AAOzC,eAAe,SAASC,aAAaA,CAAC;EAAEC,KAAK;EAAEC;AAAgB,CAAC,EAAE;EAChE,oBACEJ,KAAA,CAAAK,aAAA,CAACJ,YAAY,CAACK,QAAQ;IAACH,KAAK,EAAEA;EAAM,GAAEC,QAAgC,CAAC;AAE3E","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import ThemeContext from './ThemeContext';
3
+ export default function useTheme() {
4
+ const theme = React.useContext(ThemeContext);
5
+ return theme;
6
+ }
7
+ //# sourceMappingURL=useTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","ThemeContext","useTheme","theme","useContext"],"sourceRoot":"../../../src","sources":["theming/useTheme.tsx"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,eAAe,SAASC,QAAQA,CAAA,EAAG;EACjC,MAAMC,KAAK,GAAGH,KAAK,CAACI,UAAU,CAACH,YAAY,CAAC;EAE5C,OAAOE,KAAK;AACd","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.tsx"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ export default function useBackButton(_) {
2
+ // No-op
3
+ // BackHandler is not available on web
4
+ }
5
+ //# sourceMappingURL=useBackButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useBackButton","_"],"sourceRoot":"../../src","sources":["useBackButton.tsx"],"mappings":"AAKA,eAAe,SAASA,aAAaA,CACnCC,CAAyD,EACzD;EACA;EACA;AAAA","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { BackHandler } from 'react-native';
3
+ export default function useBackButton(ref) {
4
+ React.useEffect(() => {
5
+ const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
6
+ const navigation = ref.current;
7
+ if (navigation == null) {
8
+ return false;
9
+ }
10
+ if (navigation.canGoBack()) {
11
+ navigation.goBack();
12
+ return true;
13
+ }
14
+ return false;
15
+ });
16
+ return () => subscription.remove();
17
+ }, [ref]);
18
+ }
19
+ //# sourceMappingURL=useBackButton.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","BackHandler","useBackButton","ref","useEffect","subscription","addEventListener","navigation","current","canGoBack","goBack","remove"],"sourceRoot":"../../src","sources":["useBackButton.native.tsx"],"mappings":"AAIA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,WAAW,QAAQ,cAAc;AAE1C,eAAe,SAASC,aAAaA,CACnCC,GAA2D,EAC3D;EACAH,KAAK,CAACI,SAAS,CAAC,MAAM;IACpB,MAAMC,YAAY,GAAGJ,WAAW,CAACK,gBAAgB,CAC/C,mBAAmB,EACnB,MAAM;MACJ,MAAMC,UAAU,GAAGJ,GAAG,CAACK,OAAO;MAE9B,IAAID,UAAU,IAAI,IAAI,EAAE;QACtB,OAAO,KAAK;MACd;MAEA,IAAIA,UAAU,CAACE,SAAS,CAAC,CAAC,EAAE;QAC1BF,UAAU,CAACG,MAAM,CAAC,CAAC;QAEnB,OAAO,IAAI;MACb;MAEA,OAAO,KAAK;IACd,CACF,CAAC;IAED,OAAO,MAAML,YAAY,CAACM,MAAM,CAAC,CAAC;EACpC,CAAC,EAAE,CAACR,GAAG,CAAC,CAAC;AACX","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Set the document title for the active screen
4
+ */
5
+ export default function useDocumentTitle(ref, {
6
+ enabled = true,
7
+ formatter = (options, route) => (options === null || options === void 0 ? void 0 : options.title) ?? (route === null || route === void 0 ? void 0 : route.name)
8
+ } = {}) {
9
+ React.useEffect(() => {
10
+ if (!enabled) {
11
+ return;
12
+ }
13
+ const navigation = ref.current;
14
+ if (navigation) {
15
+ const title = formatter(navigation.getCurrentOptions(), navigation.getCurrentRoute());
16
+ document.title = title;
17
+ }
18
+ return navigation === null || navigation === void 0 ? void 0 : navigation.addListener('options', e => {
19
+ const title = formatter(e.data.options, navigation === null || navigation === void 0 ? void 0 : navigation.getCurrentRoute());
20
+ document.title = title;
21
+ });
22
+ });
23
+ }
24
+ //# sourceMappingURL=useDocumentTitle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useDocumentTitle","ref","enabled","formatter","options","route","title","name","useEffect","navigation","current","getCurrentOptions","getCurrentRoute","document","addListener","e","data"],"sourceRoot":"../../src","sources":["useDocumentTitle.tsx"],"mappings":"AAIA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAI9B;AACA;AACA;AACA,eAAe,SAASC,gBAAgBA,CACtCC,GAA2D,EAC3D;EACEC,OAAO,GAAG,IAAI;EACdC,SAAS,GAAGA,CAACC,OAAO,EAAEC,KAAK,KAAK,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,KAAK,MAAID,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEE,IAAI;AACzC,CAAC,GAAG,CAAC,CAAC,EAC5B;EACAR,KAAK,CAACS,SAAS,CAAC,MAAM;IACpB,IAAI,CAACN,OAAO,EAAE;MACZ;IACF;IAEA,MAAMO,UAAU,GAAGR,GAAG,CAACS,OAAO;IAE9B,IAAID,UAAU,EAAE;MACd,MAAMH,KAAK,GAAGH,SAAS,CACrBM,UAAU,CAACE,iBAAiB,CAAC,CAAC,EAC9BF,UAAU,CAACG,eAAe,CAAC,CAC7B,CAAC;MAEDC,QAAQ,CAACP,KAAK,GAAGA,KAAK;IACxB;IAEA,OAAOG,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEK,WAAW,CAAC,SAAS,EAAGC,CAAC,IAAK;MAC/C,MAAMT,KAAK,GAAGH,SAAS,CAACY,CAAC,CAACC,IAAI,CAACZ,OAAO,EAAEK,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEG,eAAe,CAAC,CAAC,CAAC;MAEtEC,QAAQ,CAACP,KAAK,GAAGA,KAAK;IACxB,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export default function useDocumentTitle() {
2
+ // Noop for React Native
3
+ }
4
+ //# sourceMappingURL=useDocumentTitle.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useDocumentTitle"],"sourceRoot":"../../src","sources":["useDocumentTitle.native.tsx"],"mappings":"AAAA,eAAe,SAASA,gBAAgBA,CAAA,EAAG;EACzC;AAAA","ignoreList":[]}
@@ -0,0 +1,54 @@
1
+ import { getPathFromState, NavigationHelpersContext } from '@amazon-devices/react-navigation__core';
2
+ import * as React from 'react';
3
+ import LinkingContext from './LinkingContext';
4
+ const getRootStateForNavigate = (navigation, state) => {
5
+ const parent = navigation.getParent();
6
+ if (parent) {
7
+ const parentState = parent.getState();
8
+ return getRootStateForNavigate(parent, {
9
+ index: 0,
10
+ routes: [{
11
+ ...parentState.routes[parentState.index],
12
+ state: state
13
+ }]
14
+ });
15
+ }
16
+ return state;
17
+ };
18
+
19
+ /**
20
+ * Build destination link for a navigate action.
21
+ * Useful for showing anchor tags on the web for buttons that perform navigation.
22
+ */
23
+ export default function useLinkBuilder() {
24
+ const navigation = React.useContext(NavigationHelpersContext);
25
+ const linking = React.useContext(LinkingContext);
26
+ const buildLink = React.useCallback((name, params) => {
27
+ const {
28
+ options
29
+ } = linking;
30
+ if ((options === null || options === void 0 ? void 0 : options.enabled) === false) {
31
+ return undefined;
32
+ }
33
+ const state = navigation ? getRootStateForNavigate(navigation, {
34
+ index: 0,
35
+ routes: [{
36
+ name,
37
+ params
38
+ }]
39
+ }) :
40
+ // If we couldn't find a navigation object in context, we're at root
41
+ // So we'll construct a basic state object to use
42
+ {
43
+ index: 0,
44
+ routes: [{
45
+ name,
46
+ params
47
+ }]
48
+ };
49
+ const path = options !== null && options !== void 0 && options.getPathFromState ? options.getPathFromState(state, options === null || options === void 0 ? void 0 : options.config) : getPathFromState(state, options === null || options === void 0 ? void 0 : options.config);
50
+ return path;
51
+ }, [linking, navigation]);
52
+ return buildLink;
53
+ }
54
+ //# sourceMappingURL=useLinkBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getPathFromState","NavigationHelpersContext","React","LinkingContext","getRootStateForNavigate","navigation","state","parent","getParent","parentState","getState","index","routes","useLinkBuilder","useContext","linking","buildLink","useCallback","name","params","options","enabled","undefined","path","config"],"sourceRoot":"../../src","sources":["useLinkBuilder.tsx"],"mappings":"AAAA,SACEA,gBAAgB,EAEhBC,wBAAwB,QAGnB,8BAA8B;AACrC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,OAAOC,cAAc,MAAM,kBAAkB;AAW7C,MAAMC,uBAAuB,GAAGA,CAC9BC,UAA4B,EAC5BC,KAAmB,KACF;EACjB,MAAMC,MAAM,GAAGF,UAAU,CAACG,SAAS,CAAC,CAAC;EAErC,IAAID,MAAM,EAAE;IACV,MAAME,WAAW,GAAGF,MAAM,CAACG,QAAQ,CAAC,CAAC;IAErC,OAAON,uBAAuB,CAACG,MAAM,EAAE;MACrCI,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE,CACN;QACE,GAAGH,WAAW,CAACG,MAAM,CAACH,WAAW,CAACE,KAAK,CAAC;QACxCL,KAAK,EAAEA;MACT,CAAC;IAEL,CAAC,CAAC;EACJ;EAEA,OAAOA,KAAK;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA,eAAe,SAASO,cAAcA,CAAA,EAAG;EACvC,MAAMR,UAAU,GAAGH,KAAK,CAACY,UAAU,CAACb,wBAAwB,CAAC;EAC7D,MAAMc,OAAO,GAAGb,KAAK,CAACY,UAAU,CAACX,cAAc,CAAC;EAEhD,MAAMa,SAAS,GAAGd,KAAK,CAACe,WAAW,CACjC,CAACC,IAAY,EAAEC,MAAe,KAAK;IACjC,MAAM;MAAEC;IAAQ,CAAC,GAAGL,OAAO;IAE3B,IAAI,CAAAK,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,OAAO,MAAK,KAAK,EAAE;MAC9B,OAAOC,SAAS;IAClB;IAEA,MAAMhB,KAAK,GAAGD,UAAU,GACpBD,uBAAuB,CAACC,UAAU,EAAE;MAClCM,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE,CAAC;QAAEM,IAAI;QAAEC;MAAO,CAAC;IAC3B,CAAC,CAAC;IACF;IACA;IACA;MACER,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE,CAAC;QAAEM,IAAI;QAAEC;MAAO,CAAC;IAC3B,CAAC;IAEL,MAAMI,IAAI,GAAGH,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEpB,gBAAgB,GAClCoB,OAAO,CAACpB,gBAAgB,CAACM,KAAK,EAAEc,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,MAAM,CAAC,GAChDxB,gBAAgB,CAACM,KAAK,EAAEc,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,MAAM,CAAC;IAE5C,OAAOD,IAAI;EACb,CAAC,EACD,CAACR,OAAO,EAAEV,UAAU,CACtB,CAAC;EAED,OAAOW,SAAS;AAClB","ignoreList":[]}
@@ -0,0 +1,88 @@
1
+ import { getPathFromState, NavigationContainerRefContext, NavigationHelpersContext } from '@amazon-devices/react-navigation__core';
2
+ import * as React from 'react';
3
+ import { Platform } from 'react-native';
4
+ import LinkingContext from './LinkingContext';
5
+ import useLinkTo from './useLinkTo';
6
+ const getStateFromParams = params => {
7
+ if (params !== null && params !== void 0 && params.state) {
8
+ return params.state;
9
+ }
10
+ if (params !== null && params !== void 0 && params.screen) {
11
+ return {
12
+ routes: [{
13
+ name: params.screen,
14
+ params: params.params,
15
+ // @ts-expect-error
16
+ state: params.screen ? getStateFromParams(params.params) : undefined
17
+ }]
18
+ };
19
+ }
20
+ return undefined;
21
+ };
22
+
23
+ /**
24
+ * Hook to get props for an anchor tag so it can work with in page navigation.
25
+ *
26
+ * @param props.to Absolute path to screen (e.g. `/feeds/hot`).
27
+ * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
28
+ */
29
+ export default function useLinkProps({
30
+ to,
31
+ action
32
+ }) {
33
+ const root = React.useContext(NavigationContainerRefContext);
34
+ const navigation = React.useContext(NavigationHelpersContext);
35
+ const {
36
+ options
37
+ } = React.useContext(LinkingContext);
38
+ const linkTo = useLinkTo();
39
+ const onPress = e => {
40
+ var _e$currentTarget;
41
+ let shouldHandle = false;
42
+ if (Platform.OS !== 'web' || !e) {
43
+ shouldHandle = e ? !e.defaultPrevented : true;
44
+ } else if (!e.defaultPrevented &&
45
+ // onPress prevented default
46
+ // @ts-expect-error: these properties exist on web, but not in React Native
47
+ !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && (
48
+ // ignore clicks with modifier keys
49
+ // @ts-expect-error: these properties exist on web, but not in React Native
50
+ e.button == null || e.button === 0) &&
51
+ // ignore everything but left clicks
52
+ // @ts-expect-error: these properties exist on web, but not in React Native
53
+ [undefined, null, '', 'self'].includes((_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.target) // let browser handle "target=_blank" etc.
54
+ ) {
55
+ e.preventDefault();
56
+ shouldHandle = true;
57
+ }
58
+ if (shouldHandle) {
59
+ if (action) {
60
+ if (navigation) {
61
+ navigation.dispatch(action);
62
+ } else if (root) {
63
+ root.dispatch(action);
64
+ } else {
65
+ throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
66
+ }
67
+ } else {
68
+ linkTo(to);
69
+ }
70
+ }
71
+ };
72
+ const getPathFromStateHelper = (options === null || options === void 0 ? void 0 : options.getPathFromState) ?? getPathFromState;
73
+ const href = typeof to === 'string' ? to : getPathFromStateHelper({
74
+ routes: [{
75
+ name: to.screen,
76
+ // @ts-expect-error
77
+ params: to.params,
78
+ // @ts-expect-error
79
+ state: getStateFromParams(to.params)
80
+ }]
81
+ }, options === null || options === void 0 ? void 0 : options.config);
82
+ return {
83
+ href,
84
+ accessibilityRole: 'link',
85
+ onPress
86
+ };
87
+ }
88
+ //# sourceMappingURL=useLinkProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getPathFromState","NavigationContainerRefContext","NavigationHelpersContext","React","Platform","LinkingContext","useLinkTo","getStateFromParams","params","state","screen","routes","name","undefined","useLinkProps","to","action","root","useContext","navigation","options","linkTo","onPress","e","_e$currentTarget","shouldHandle","OS","defaultPrevented","metaKey","altKey","ctrlKey","shiftKey","button","includes","currentTarget","target","preventDefault","dispatch","Error","getPathFromStateHelper","href","config","accessibilityRole"],"sourceRoot":"../../src","sources":["useLinkProps.tsx"],"mappings":"AAAA,SACEA,gBAAgB,EAEhBC,6BAA6B,EAC7BC,wBAAwB,QAGnB,8BAA8B;AAErC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAAgCC,QAAQ,QAAQ,cAAc;AAE9D,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,SAAS,MAAc,aAAa;AAO3C,MAAMC,kBAAkB,GACtBC,MAAyE,IACT;EAChE,IAAIA,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEC,KAAK,EAAE;IACjB,OAAOD,MAAM,CAACC,KAAK;EACrB;EAEA,IAAID,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEE,MAAM,EAAE;IAClB,OAAO;MACLC,MAAM,EAAE,CACN;QACEC,IAAI,EAAEJ,MAAM,CAACE,MAAM;QACnBF,MAAM,EAAEA,MAAM,CAACA,MAAM;QACrB;QACAC,KAAK,EAAED,MAAM,CAACE,MAAM,GAChBH,kBAAkB,CAChBC,MAAM,CAACA,MAGT,CAAC,GACDK;MACN,CAAC;IAEL,CAAC;EACH;EAEA,OAAOA,SAAS;AAClB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAElC;EAAEC,EAAE;EAAEC;AAAyB,CAAC,EAAE;EAClC,MAAMC,IAAI,GAAGd,KAAK,CAACe,UAAU,CAACjB,6BAA6B,CAAC;EAC5D,MAAMkB,UAAU,GAAGhB,KAAK,CAACe,UAAU,CAAChB,wBAAwB,CAAC;E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ED,MAAMwB,sBAAsB,GAAG,CAAAnB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEpB,gBAAgB,KAAIA,gBAAgB;EAE5E,MAAMwC,IAAI,GACR,OAAOzB,EAAE,KAAK,QAAQ,GAClBA,EAAE,GACFwB,sBAAsB,CACpB;IACE5B,MAAM,EAAE,CACN;MACEC,IAAI,EAAEG,EAAE,CAACL,MAAM;MACf;MACAF,MAAM,EAAEO,EAAE,CAACP,MAAM;MACjB;MACAC,KAAK,EAAEF,kBAAkB,CAACQ,EAAE,CAACP,MAAM;IACrC,CAAC;EAEL,CAAC,EACDY,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEqB,MACX,CAAC;EAEP,OAAO;IACLD,IAAI;IACJE,iBAAiB,EAAE,MAAe;IAClCpB;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ import { getActionFromState, getStateFromPath, NavigationContainerRefContext } from '@amazon-devices/react-navigation__core';
2
+ import * as React from 'react';
3
+ import LinkingContext from './LinkingContext';
4
+ export default function useLinkTo() {
5
+ const navigation = React.useContext(NavigationContainerRefContext);
6
+ const linking = React.useContext(LinkingContext);
7
+ const linkTo = React.useCallback(to => {
8
+ if (navigation === undefined) {
9
+ throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
10
+ }
11
+ if (typeof to !== 'string') {
12
+ // @ts-expect-error: This is fine
13
+ navigation.navigate(to.screen, to.params);
14
+ return;
15
+ }
16
+ if (!to.startsWith('/')) {
17
+ throw new Error(`The path must start with '/' (${to}).`);
18
+ }
19
+ const {
20
+ options
21
+ } = linking;
22
+ const state = options !== null && options !== void 0 && options.getStateFromPath ? options.getStateFromPath(to, options.config) : getStateFromPath(to, options === null || options === void 0 ? void 0 : options.config);
23
+ if (state) {
24
+ const action = getActionFromState(state, options === null || options === void 0 ? void 0 : options.config);
25
+ if (action !== undefined) {
26
+ navigation.dispatch(action);
27
+ } else {
28
+ navigation.reset(state);
29
+ }
30
+ } else {
31
+ throw new Error('Failed to parse the path to a navigation state.');
32
+ }
33
+ }, [linking, navigation]);
34
+ return linkTo;
35
+ }
36
+ //# sourceMappingURL=useLinkTo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getActionFromState","getStateFromPath","NavigationContainerRefContext","React","LinkingContext","useLinkTo","navigation","useContext","linking","linkTo","useCallback","to","undefined","Error","navigate","screen","params","startsWith","options","state","config","action","dispatch","reset"],"sourceRoot":"../../src","sources":["useLinkTo.tsx"],"mappings":"AAAA,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,6BAA6B,QACxB,8BAA8B;AACrC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,OAAOC,cAAc,MAAM,kBAAkB;AAiB7C,eAAe,SAASC,SAASA,CAAA,EAE7B;EACF,MAAMC,UAAU,GAAGH,KAAK,CAACI,UAAU,CAACL,6BAA6B,CAAC;EAClE,MAAMM,OAAO,GAAGL,KAAK,CAACI,UAAU,CAACH,cAAc,CAAC;EAEhD,MAAMK,MAAM,GAAGN,KAAK,CAACO,WAAW,CAC7BC,EAAiB,IAAK;IACrB,IAAIL,UAAU,KAAKM,SAAS,EAAE;MAC5B,MAAM,IAAIC,KAAK,CACb,kFACF,CAAC;IACH;IAEA,IAAI,OAAOF,EAAE,KAAK,QAAQ,EAAE;MAC1B;MACAL,UAAU,CAACQ,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,CAAC,iCAAiCF,EAAE,IAAI,CAAC;IAC1D;IAEA,MAAM;MAAEO;IAAQ,CAAC,GAAGV,OAAO;IAE3B,MAAMW,KAAK,GAAGD,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEjB,gBAAgB,GACnCiB,OAAO,CAACjB,gBAAgB,CAACU,EAAE,EAAEO,OAAO,CAACE,MAA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