| 45 | } |
| 46 | |
| 47 | function scheduleEditorModuleWarmup(): () => void { |
| 48 | let cancelled = false |
| 49 | let delayId: number | null = null |
| 50 | let frameId: number | null = null |
| 51 | |
| 52 | const warmup = (): void => { |
| 53 | if (!cancelled) void loadEditorModule() |
| 54 | } |
| 55 | |
| 56 | delayId = window.setTimeout(() => { |
| 57 | delayId = null |
| 58 | frameId = window.requestAnimationFrame(() => { |
| 59 | frameId = null |
| 60 | warmup() |
| 61 | }) |
| 62 | }, EDITOR_MODULE_WARMUP_GRACE_MS) |
| 63 | |
| 64 | return () => { |
| 65 | cancelled = true |
| 66 | if (delayId !== null) window.clearTimeout(delayId) |
| 67 | if (frameId !== null) window.cancelAnimationFrame(frameId) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | function scheduleSearchPaletteModuleWarmup(): () => void { |
| 72 | let cancelled = false |