(appOrParcel)
| 13 | const appsToUnload = {}; |
| 14 | |
| 15 | export function toUnloadPromise(appOrParcel) { |
| 16 | return Promise.resolve().then(() => { |
| 17 | const unloadInfo = appsToUnload[toName(appOrParcel)]; |
| 18 | |
| 19 | if (!unloadInfo) { |
| 20 | /* No one has called unloadApplication for this app, |
| 21 | */ |
| 22 | return appOrParcel; |
| 23 | } |
| 24 | |
| 25 | if (appOrParcel.status === NOT_LOADED) { |
| 26 | /* This app is already unloaded. We just need to clean up |
| 27 | * anything that still thinks we need to unload the app. |
| 28 | */ |
| 29 | finishUnloadingApp(appOrParcel, unloadInfo); |
| 30 | return appOrParcel; |
| 31 | } |
| 32 | |
| 33 | if (appOrParcel.status === UNLOADING) { |
| 34 | /* Both unloadApplication and reroute want to unload this app. |
| 35 | * It only needs to be done once, though. |
| 36 | */ |
| 37 | return unloadInfo.promise.then(() => appOrParcel); |
| 38 | } |
| 39 | |
| 40 | if ( |
| 41 | appOrParcel.status !== NOT_MOUNTED && |
| 42 | appOrParcel.status !== LOAD_ERROR |
| 43 | ) { |
| 44 | /* The app cannot be unloaded until it is unmounted. |
| 45 | */ |
| 46 | return appOrParcel; |
| 47 | } |
| 48 | |
| 49 | let startTime; |
| 50 | |
| 51 | if (__PROFILE__) { |
| 52 | startTime = performance.now(); |
| 53 | } |
| 54 | |
| 55 | const unloadPromise = |
| 56 | appOrParcel.status === LOAD_ERROR |
| 57 | ? Promise.resolve() |
| 58 | : reasonableTime(appOrParcel, "unload"); |
| 59 | |
| 60 | appOrParcel.status = UNLOADING; |
| 61 | |
| 62 | return unloadPromise |
| 63 | .then(() => { |
| 64 | if (__PROFILE__) { |
| 65 | addProfileEntry( |
| 66 | "application", |
| 67 | toName(appOrParcel), |
| 68 | "unload", |
| 69 | startTime, |
| 70 | performance.now(), |
| 71 | true |
| 72 | ); |
nothing calls this directly
no test coverage detected
searching dependent graphs…