(options)
| 165 | * @returns {StateMachine} state machine |
| 166 | */ |
| 167 | const createOverlayMachine = (options) => { |
| 168 | const { hideOverlay, showOverlay } = options; |
| 169 | |
| 170 | return createMachine( |
| 171 | { |
| 172 | initial: "hidden", |
| 173 | context: { |
| 174 | level: "error", |
| 175 | messages: [], |
| 176 | messageSource: "build", |
| 177 | }, |
| 178 | states: { |
| 179 | hidden: { |
| 180 | on: { |
| 181 | BUILD_ERROR: { |
| 182 | target: "displayBuildError", |
| 183 | actions: ["setMessages", "showOverlay"], |
| 184 | }, |
| 185 | RUNTIME_ERROR: { |
| 186 | target: "displayRuntimeError", |
| 187 | actions: ["setMessages", "showOverlay"], |
| 188 | }, |
| 189 | }, |
| 190 | }, |
| 191 | displayBuildError: { |
| 192 | on: { |
| 193 | DISMISS: { |
| 194 | target: "hidden", |
| 195 | actions: ["dismissMessages", "hideOverlay"], |
| 196 | }, |
| 197 | BUILD_ERROR: { |
| 198 | target: "displayBuildError", |
| 199 | actions: ["appendMessages", "showOverlay"], |
| 200 | }, |
| 201 | }, |
| 202 | }, |
| 203 | displayRuntimeError: { |
| 204 | on: { |
| 205 | DISMISS: { |
| 206 | target: "hidden", |
| 207 | actions: ["dismissMessages", "hideOverlay"], |
| 208 | }, |
| 209 | RUNTIME_ERROR: { |
| 210 | target: "displayRuntimeError", |
| 211 | actions: ["appendMessages", "showOverlay"], |
| 212 | }, |
| 213 | BUILD_ERROR: { |
| 214 | target: "displayBuildError", |
| 215 | actions: ["setMessages", "showOverlay"], |
| 216 | }, |
| 217 | }, |
| 218 | }, |
| 219 | }, |
| 220 | }, |
| 221 | { |
| 222 | actions: { |
| 223 | dismissMessages: () => { |
| 224 | return { |
no test coverage detected
searching dependent graphs…