( pendingPromises = [], eventArguments, silentNavigation = false )
| 37 | } |
| 38 | |
| 39 | export function reroute( |
| 40 | pendingPromises = [], |
| 41 | eventArguments, |
| 42 | silentNavigation = false |
| 43 | ) { |
| 44 | if (appChangeUnderway) { |
| 45 | return new Promise((resolve, reject) => { |
| 46 | peopleWaitingOnAppChange.push({ |
| 47 | resolve, |
| 48 | reject, |
| 49 | eventArguments, |
| 50 | }); |
| 51 | }); |
| 52 | } |
| 53 | |
| 54 | let startTime, profilerKind; |
| 55 | |
| 56 | if (__PROFILE__) { |
| 57 | startTime = performance.now(); |
| 58 | if (silentNavigation) { |
| 59 | profilerKind = "silentNavigation"; |
| 60 | } else if (eventArguments) { |
| 61 | profilerKind = "browserNavigation"; |
| 62 | } else { |
| 63 | profilerKind = "triggerAppChange"; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | const { appsToUnload, appsToUnmount, appsToLoad, appsToMount } = |
| 68 | getAppChanges(); |
| 69 | let appsThatChanged, |
| 70 | cancelPromises = [], |
| 71 | oldUrl = currentUrl, |
| 72 | newUrl = (currentUrl = window.location.href); |
| 73 | |
| 74 | if (isStarted()) { |
| 75 | appChangeUnderway = true; |
| 76 | appsThatChanged = appsToUnload.concat( |
| 77 | appsToLoad, |
| 78 | appsToUnmount, |
| 79 | appsToMount |
| 80 | ); |
| 81 | return performAppChanges(); |
| 82 | } else { |
| 83 | appsThatChanged = appsToLoad; |
| 84 | return loadApps(); |
| 85 | } |
| 86 | |
| 87 | function cancelNavigation(val = true) { |
| 88 | const promise = |
| 89 | typeof val?.then === "function" ? val : Promise.resolve(val); |
| 90 | cancelPromises.push( |
| 91 | promise.catch((err) => { |
| 92 | console.warn( |
| 93 | Error( |
| 94 | formatErrorMessage( |
| 95 | 42, |
| 96 | __DEV__ && |
no test coverage detected
searching dependent graphs…