(m: unknown)
| 276 | } |
| 277 | |
| 278 | function handleWorkerMessage(m: unknown): void { |
| 279 | if (fatal !== null) return; |
| 280 | if (typeof m !== "object" || m === null) return; |
| 281 | const type = (m as { type?: unknown }).type; |
| 282 | if (typeof type !== "string") return; |
| 283 | |
| 284 | const msg = m as WorkerToMainMessage; |
| 285 | switch (msg.type) { |
| 286 | case "ready": { |
| 287 | started = true; |
| 288 | stopRequested = false; |
| 289 | if (startDef !== null && !startSettled) { |
| 290 | startSettled = true; |
| 291 | startDef.resolve(); |
| 292 | } |
| 293 | return; |
| 294 | } |
| 295 | |
| 296 | case "frameStatus": { |
| 297 | if (frameAudit.enabled) { |
| 298 | frameAudit.emit("worker.frameStatus", { |
| 299 | acceptedSeq: msg.acceptedSeq, |
| 300 | completedSeq: msg.completedSeq ?? null, |
| 301 | completedResult: msg.completedResult ?? null, |
| 302 | }); |
| 303 | } |
| 304 | if (!Number.isInteger(msg.acceptedSeq) || msg.acceptedSeq <= 0) { |
| 305 | fatal = new ZrUiError( |
| 306 | "ZRUI_BACKEND_ERROR", |
| 307 | `invalid frameStatus.acceptedSeq: ${String(msg.acceptedSeq)}`, |
| 308 | ); |
| 309 | failAll(fatal); |
| 310 | return; |
| 311 | } |
| 312 | resolveAcceptedFramesUpTo(frameTracking, frameAudit, msg.acceptedSeq); |
| 313 | resolveCoalescedCompletionFramesUpTo(frameTracking, frameAudit, msg.acceptedSeq); |
| 314 | |
| 315 | if (msg.completedSeq !== undefined) { |
| 316 | if (!Number.isInteger(msg.completedSeq) || msg.completedSeq <= 0) { |
| 317 | fatal = new ZrUiError( |
| 318 | "ZRUI_BACKEND_ERROR", |
| 319 | `invalid frameStatus.completedSeq: ${String(msg.completedSeq)}`, |
| 320 | ); |
| 321 | failAll(fatal); |
| 322 | return; |
| 323 | } |
| 324 | const completedResult = msg.completedResult ?? 0; |
| 325 | if (!Number.isInteger(completedResult)) { |
| 326 | fatal = new ZrUiError( |
| 327 | "ZRUI_BACKEND_ERROR", |
| 328 | `invalid frameStatus.completedResult: ${String(msg.completedResult)}`, |
| 329 | ); |
| 330 | failAll(fatal); |
| 331 | return; |
| 332 | } |
| 333 | settleCompletedFrame(frameTracking, frameAudit, msg.completedSeq, completedResult); |
| 334 | if (completedResult < 0) { |
| 335 | fatal = new ZrUiError( |
nothing calls this directly
no test coverage detected