| 67 | const TIMELINE_RESIZE_GRIP_MARKS = [0, 1, 2] as const; |
| 68 | |
| 69 | const scheduleIdleWork = (callback: () => void) => { |
| 70 | const win = window as Window & { |
| 71 | requestIdleCallback?: ( |
| 72 | callback: () => void, |
| 73 | options?: { timeout: number }, |
| 74 | ) => number; |
| 75 | cancelIdleCallback?: (handle: number) => void; |
| 76 | }; |
| 77 | |
| 78 | if (win.requestIdleCallback) { |
| 79 | const handle = win.requestIdleCallback(callback, { timeout: 1_000 }); |
| 80 | return () => win.cancelIdleCallback?.(handle); |
| 81 | } |
| 82 | |
| 83 | const handle = window.setTimeout(callback, 250); |
| 84 | return () => window.clearTimeout(handle); |
| 85 | }; |
| 86 | |
| 87 | function getEditorErrorMessage(error: unknown) { |
| 88 | return error instanceof Error ? error.message : String(error); |