Skip to content

Commit aa7716a

Browse files
Gaubeeclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 1432e20 commit aa7716a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/common/TaskQueue.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* @license MIT
44
*/
55

6-
import { isNode } from 'common/Platform';
76
import type { ILogService } from 'common/services/Services';
87

98
interface ITaskQueue {
@@ -148,7 +147,7 @@ class IdleTaskQueueInternal extends TaskQueue {
148147
* This reverts to a {@link PriorityTaskQueue} if the environment does not support idle callbacks.
149148
*/
150149
// eslint-disable-next-line @typescript-eslint/naming-convention
151-
export const IdleTaskQueue = (!isNode && 'requestIdleCallback' in window) ? IdleTaskQueueInternal : PriorityTaskQueue;
150+
export const IdleTaskQueue = ('requestIdleCallback' in globalThis) ? IdleTaskQueueInternal : PriorityTaskQueue;
152151

153152
/**
154153
* An object that tracks a single debounced task that will run on the next idle frame. When called

0 commit comments

Comments
 (0)