From aa7716a333c44c7a8be4cdc45b5d36affd238ace Mon Sep 17 00:00:00 2001 From: Gaubee Date: Sun, 15 Mar 2026 10:30:12 +0800 Subject: [PATCH] Fix @xterm/headless compatibility with Bun and Deno runtimes Replace `window` with `globalThis` in IdleTaskQueue export. In Bun and Deno, `isNode` is false but `window` is undefined, causing a ReferenceError. Using `globalThis` is safe in all JS runtimes and makes the `isNode` guard unnecessary. This is the only `in window` expression in code bundled into @xterm/headless. Co-Authored-By: Claude Opus 4.6 --- src/common/TaskQueue.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/common/TaskQueue.ts b/src/common/TaskQueue.ts index 508e5d460..6f3b40bc4 100644 --- a/src/common/TaskQueue.ts +++ b/src/common/TaskQueue.ts @@ -3,7 +3,6 @@ * @license MIT */ -import { isNode } from 'common/Platform'; import type { ILogService } from 'common/services/Services'; interface ITaskQueue { @@ -148,7 +147,7 @@ class IdleTaskQueueInternal extends TaskQueue { * This reverts to a {@link PriorityTaskQueue} if the environment does not support idle callbacks. */ // eslint-disable-next-line @typescript-eslint/naming-convention -export const IdleTaskQueue = (!isNode && 'requestIdleCallback' in window) ? IdleTaskQueueInternal : PriorityTaskQueue; +export const IdleTaskQueue = ('requestIdleCallback' in globalThis) ? IdleTaskQueueInternal : PriorityTaskQueue; /** * An object that tracks a single debounced task that will run on the next idle frame. When called