Skip to content

Add Task Scheduling API #1249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,18 @@ interface SVGBoundingBoxOptions {
stroke?: boolean;
}

interface SchedulerPostTaskOptions {
delay?: number;
priority?: TaskPriority;
signal?: AbortSignal;
}

interface Scheduler {
postTask<T, P extends readonly unknown[] | []>(callback: (...params: P) => T, options?: SchedulerPostTaskOptions, ...arguments: P): Promise<T>;
}

declare var scheduler: Scheduler;

interface ScrollIntoViewOptions extends ScrollOptions {
block?: ScrollLogicalPosition;
inline?: ScrollLogicalPosition;
Expand Down Expand Up @@ -1665,6 +1677,22 @@ interface SubmitEventInit extends EventInit {
submitter?: HTMLElement | null;
}

interface TaskSignal extends AbortSignal {
readonly priority: TaskPriority;
onprioritychange: ((this: TaskSignal, ev: Event) => any) | null;
addEventListener<K extends keyof TaskSignalEventMap>(type: K, listener: (this: TaskSignal, ev: TaskSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof TaskSignalEventMap>(type: K, listener: (this: TaskSignal, ev: TaskSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
}

declare var TaskSignal: {
prototype: TaskSignal;
new(): TaskSignal;
}

interface TaskSignalEventMap {
"prioritychange": Event;
}

interface TextDecodeOptions {
stream?: boolean;
}
Expand Down Expand Up @@ -17915,6 +17943,7 @@ type ServiceWorkerUpdateViaCache = "all" | "imports" | "none";
type ShadowRootMode = "closed" | "open";
type SlotAssignmentMode = "manual" | "named";
type SpeechSynthesisErrorCode = "audio-busy" | "audio-hardware" | "canceled" | "interrupted" | "invalid-argument" | "language-unavailable" | "network" | "not-allowed" | "synthesis-failed" | "synthesis-unavailable" | "text-too-long" | "voice-unavailable";
type TaskPriority = "user-blocking" | "user-visible" | "background";
type TextTrackKind = "captions" | "chapters" | "descriptions" | "metadata" | "subtitles";
type TextTrackMode = "disabled" | "hidden" | "showing";
type TouchType = "direct" | "stylus";
Expand Down
29 changes: 29 additions & 0 deletions baselines/serviceworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,18 @@ interface RsaPssParams extends Algorithm {
saltLength: number;
}

interface SchedulerPostTaskOptions {
delay?: number;
priority?: TaskPriority;
signal?: AbortSignal;
}

interface Scheduler {
postTask<T, P extends readonly unknown[] | []>(callback: (...params: P) => T, options?: SchedulerPostTaskOptions, ...arguments: P): Promise<T>;
}

declare var scheduler: Scheduler;

interface SecurityPolicyViolationEventInit extends EventInit {
blockedURI?: string;
columnNumber?: number;
Expand Down Expand Up @@ -591,6 +603,22 @@ interface StructuredSerializeOptions {
transfer?: Transferable[];
}

interface TaskSignal extends AbortSignal {
readonly priority: TaskPriority;
onprioritychange: ((this: TaskSignal, ev: Event) => any) | null;
addEventListener<K extends keyof TaskSignalEventMap>(type: K, listener: (this: TaskSignal, ev: TaskSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof TaskSignalEventMap>(type: K, listener: (this: TaskSignal, ev: TaskSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
}

declare var TaskSignal: {
prototype: TaskSignal;
new(): TaskSignal;
}

interface TaskSignalEventMap {
"prioritychange": Event;
}

interface TextDecodeOptions {
stream?: boolean;
}
Expand Down Expand Up @@ -5569,6 +5597,7 @@ type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaquer
type SecurityPolicyViolationEventDisposition = "enforce" | "report";
type ServiceWorkerState = "activated" | "activating" | "installed" | "installing" | "parsed" | "redundant";
type ServiceWorkerUpdateViaCache = "all" | "imports" | "none";
type TaskPriority = "user-blocking" | "user-visible" | "background";
type TransferFunction = "hlg" | "pq" | "srgb";
type WebGLPowerPreference = "default" | "high-performance" | "low-power";
type WorkerType = "classic" | "module";
69 changes: 69 additions & 0 deletions baselines/sharedworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,22 @@ interface RsaPssParams extends Algorithm {
saltLength: number;
}

interface SchedulerPostTaskOptions {
delay?: number;
priority?: TaskPriority;
signal?: AbortSignal;
}

interface Scheduler {
postTask<T, P extends readonly unknown[] | []>(
callback: (...params: P) => T,
options?: SchedulerPostTaskOptions,
...arguments: P
): Promise<T>;
}

declare var scheduler: Scheduler;

interface SecurityPolicyViolationEventInit extends EventInit {
blockedURI?: string;
columnNumber?: number;
Expand Down Expand Up @@ -557,6 +573,30 @@ interface StructuredSerializeOptions {
transfer?: Transferable[];
}

interface TaskSignal extends AbortSignal {
readonly priority: TaskPriority;
onprioritychange: ((this: TaskSignal, ev: Event) => any) | null;
addEventListener<K extends keyof TaskSignalEventMap>(
type: K,
listener: (this: TaskSignal, ev: TaskSignalEventMap[K]) => any,
options?: boolean | AddEventListenerOptions
): void;
removeEventListener<K extends keyof TaskSignalEventMap>(
type: K,
listener: (this: TaskSignal, ev: TaskSignalEventMap[K]) => any,
options?: boolean | EventListenerOptions
): void;
}

declare var TaskSignal: {
prototype: TaskSignal;
new (): TaskSignal;
};

interface TaskSignalEventMap {
prioritychange: Event;
}

interface TextDecodeOptions {
stream?: boolean;
}
Expand Down Expand Up @@ -5410,6 +5450,34 @@ interface QueuingStrategySize<T = any> {
(chunk: T): number;
}

interface SchedulerPostTaskOptions {
delay?: number;
priority?: TaskPriority;
signal?: AbortSignal;
}

interface Scheduler {
postTask<T, P extends readonly unknown[] | []>(callback: (...params: P) => T, options?: SchedulerPostTaskOptions, ...arguments: P): Promise<T>;
}

declare var scheduler: Scheduler;

interface TaskSignal extends AbortSignal {
readonly priority: TaskPriority;
onprioritychange: ((this: TaskSignal, ev: Event) => any) | null;
addEventListener<K extends keyof TaskSignalEventMap>(type: K, listener: (this: TaskSignal, ev: TaskSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof TaskSignalEventMap>(type: K, listener: (this: TaskSignal, ev: TaskSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
}

declare var TaskSignal: {
prototype: TaskSignal;
new(): TaskSignal;
}

interface TaskSignalEventMap {
"prioritychange": Event;
}

interface TransformerFlushCallback<O> {
(controller: TransformStreamDefaultController<O>): void | PromiseLike<void>;
}
Expand Down Expand Up @@ -5583,6 +5651,7 @@ type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaquer
type SecurityPolicyViolationEventDisposition = "enforce" | "report";
type ServiceWorkerState = "activated" | "activating" | "installed" | "installing" | "parsed" | "redundant";
type ServiceWorkerUpdateViaCache = "all" | "imports" | "none";
type TaskPriority = "user-blocking" | "user-visible" | "background";
type TransferFunction = "hlg" | "pq" | "srgb";
type WebGLPowerPreference = "default" | "high-performance" | "low-power";
type WorkerType = "classic" | "module";
Expand Down
29 changes: 29 additions & 0 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,18 @@ declare var Response: {
redirect(url: string | URL, status?: number): Response;
};

interface SchedulerPostTaskOptions {
delay?: number;
priority?: TaskPriority;
signal?: AbortSignal;
}

interface Scheduler {
postTask<T, P extends readonly unknown[] | []>(callback: (...params: P) => T, options?: SchedulerPostTaskOptions, ...arguments: P): Promise<T>;
}

declare var scheduler: Scheduler;

/** Inherits from Event, and represents the event object of an event sent on a document or worker when its content security policy is violated. */
interface SecurityPolicyViolationEvent extends Event {
readonly blockedURI: string;
Expand Down Expand Up @@ -2908,6 +2920,22 @@ declare var SubtleCrypto: {
new(): SubtleCrypto;
};

interface TaskSignal extends AbortSignal {
readonly priority: TaskPriority;
onprioritychange: ((this: TaskSignal, ev: Event) => any) | null;
addEventListener<K extends keyof TaskSignalEventMap>(type: K, listener: (this: TaskSignal, ev: TaskSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof TaskSignalEventMap>(type: K, listener: (this: TaskSignal, ev: TaskSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
}

declare var TaskSignal: {
prototype: TaskSignal;
new(): TaskSignal;
}

interface TaskSignalEventMap {
"prioritychange": Event;
}

/** A decoder for a specific method, that is a specific character encoding, like utf-8, iso-8859-2, koi8, cp1261, gbk, etc. A decoder takes a stream of bytes as input and emits a stream of code points. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays. */
interface TextDecoder extends TextDecoderCommon {
/**
Expand Down Expand Up @@ -5816,6 +5844,7 @@ type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaquer
type SecurityPolicyViolationEventDisposition = "enforce" | "report";
type ServiceWorkerState = "activated" | "activating" | "installed" | "installing" | "parsed" | "redundant";
type ServiceWorkerUpdateViaCache = "all" | "imports" | "none";
type TaskPriority = "user-blocking" | "user-visible" | "background";
type TransferFunction = "hlg" | "pq" | "srgb";
type WebGLPowerPreference = "default" | "high-performance" | "low-power";
type WorkerType = "classic" | "module";
Expand Down