Skip to content

Commit

Permalink
v1.3.0 (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny authored Oct 22, 2024
1 parent 86f8068 commit cc76af7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 37 deletions.
28 changes: 7 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,39 +51,25 @@ A browser that supports ES6 is required for this polyfill.

## Usage

**TODO(shaseley)**: Update this when we figure out the versioning.

### Include via unpkg

**Use the next version of the polyfill, which includes `scheduler.yield()`:**
```html
<script src="https://unpkg.com/scheduler-polyfill@next"></script>
```

**or use the current stable release of the polyfill:**
```html
<script src="https://unpkg.com/scheduler-polyfill"></script>
```

### Include via npm and a bundler

```console
npm install scheduler-polyfill@next
```

**Or use the stable release (without `scheduler.yield()`):**

```sh
npm install scheduler-polyfill
```

Import to populate the task scheduling global variables, if not already
Import to populate the task-scheduling global variables, if not already
available in the executing browser:

```js
import 'scheduler-polyfill';
```

### Include via unpkg

```html
<script src="https://unpkg.com/scheduler-polyfill"></script>
```

### Building from source

```console
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scheduler-polyfill",
"version": "1.3.0-beta.0",
"version": "1.3.0",
"description": "Polyfill of self.scheduler API",
"main": "./dist/scheduler-polyfill.js",
"module": "./dist/scheduler-polyfill.js",
Expand Down
19 changes: 4 additions & 15 deletions types/scheduler.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ export type SchedulerPostTaskOptions = {
delay?: number;
};

/**
* {@link Scheduler.yield} options.
*
* [Explainer reference](https://github.com/WICG/scheduling-apis/blob/main/explainers/yield-and-continuation.md#controlling-continuation-priority-and-abort-behavior)
*/
export type SchedulerYieldOptions = {
/** The priority for the continuation, either a {@link TaskPriority} (`"user-blocking"`, `"user-visible"`, or `"background"`) or `"inherit"` to infer the priority from the current context. If set, this priority is used for the lifetime of the task and priority set on the `signal` is ignored. */
priority?: TaskPriority | 'inherit';
/** An {@link AbortSignal} or {@link TaskSignal} that can be used to abort or re-prioritize the task (from its associated controller), or `"inherit"` to inherit the current task's signal. The signal's priority is ignored if `priority` is set. */
signal?: AbortSignal | TaskSignal | 'inherit';
};

/**
* {@link TaskController} options.
*
Expand Down Expand Up @@ -75,10 +63,11 @@ declare global {
*/
postTask<T extends unknown>(callback: () => T, options?: SchedulerPostTaskOptions): Promise<T>;
/**
* Returns a promise that yields to the event loop when awaited. Optionally specify a priority and/or a signal for aborting the task.
* @param options {@link SchedulerYieldOptions} options.
* Returns a promise that yields to the event loop when awaited, allowing continuation in a new task.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler/yield)
*/
yield(options?: SchedulerYieldOptions): Promise<void>;
yield(): Promise<void>;
}

/**
Expand Down

0 comments on commit cc76af7

Please sign in to comment.