| 99 | } |
| 100 | |
| 101 | export class Driver implements Debuggable, UpdateSource { |
| 102 | /** |
| 103 | * Tracks the current readiness condition under which the SW is operating. This controls |
| 104 | * whether the SW attempts to respond to some or all requests. |
| 105 | */ |
| 106 | state: DriverReadyState = DriverReadyState.NORMAL; |
| 107 | private stateMessage: string = '(nominal)'; |
| 108 | |
| 109 | /** |
| 110 | * Tracks whether the SW is in an initialized state or not. Before initialization, |
| 111 | * it's not legal to respond to requests. |
| 112 | */ |
| 113 | initialized: Promise<void> | null = null; |
| 114 | |
| 115 | /** |
| 116 | * Maps client IDs to the manifest hash of the application version being used to serve |
| 117 | * them. If a client ID is not present here, it has not yet been assigned a version. |
| 118 | * |
| 119 | * If a ManifestHash appears here, it is also present in the `versions` map below. |
| 120 | */ |
| 121 | private clientVersionMap = new Map<ClientId, ManifestHash>(); |
| 122 | |
| 123 | /** |
| 124 | * Maps manifest hashes to instances of `AppVersion` for those manifests. |
| 125 | */ |
| 126 | private versions = new Map<ManifestHash, AppVersion>(); |
| 127 | |
| 128 | /** |
| 129 | * The latest version fetched from the server. |
| 130 | * |
| 131 | * Valid after initialization has completed. |
| 132 | */ |
| 133 | private latestHash: ManifestHash | null = null; |
| 134 | |
| 135 | private lastUpdateCheck: number | null = null; |
| 136 | |
| 137 | /** |
| 138 | * Whether there is a check for updates currently scheduled due to navigation. |
| 139 | */ |
| 140 | private scheduledNavUpdateCheck: boolean = false; |
| 141 | |
| 142 | /** |
| 143 | * Keep track of whether we have logged an invalid `only-if-cached` request. |
| 144 | * (See `.onFetch()` for details.) |
| 145 | */ |
| 146 | private loggedInvalidOnlyIfCachedRequest: boolean = false; |
| 147 | |
| 148 | private ngswStatePath: string; |
| 149 | |
| 150 | /** |
| 151 | * A scheduler which manages a queue of tasks that need to be executed when the SW is |
| 152 | * not doing any other work (not processing any other requests). |
| 153 | */ |
| 154 | idle: IdleScheduler; |
| 155 | |
| 156 | debugger: DebugHandler; |
| 157 | |
| 158 | // A promise resolving to the control DB table. |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…