Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Jul 19, 2021
2 parents 1e27598 + 720ff42 commit da9770b
Show file tree
Hide file tree
Showing 19 changed files with 547 additions and 271 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
registry-url: "https://registry.npmjs.org"
cache: npm

- run: git pull --tags
- run: npm install
- run: npm run build
- run: npm test
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/test_typescript.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
name: Runs with TypeScript Tests
on: [push, pull_request]
on:
push:
paths:
- "baselines/*"
pull_request:
paths:
- "baselines/*"


jobs:
test:
Expand Down
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This tool is used to generate the web-based `lib.dom.d.ts` file which is include

## Why is my fancy API still not available here?

A feature needs to be supported by more than two major browser engines to be included here, to make sure there is a good consensus among vendors: __Gecko__ (Firefox), __Blink__ (Chrome/Edge), and __WebKit__ (Safari).
A feature needs to be supported by two or more major browser engines to be included here, to make sure there is a good consensus among vendors: __Gecko__ (Firefox), __Blink__ (Chrome/Edge), and __WebKit__ (Safari).

If the condition is met but still is not available here, please [file an issue](hthttps://github.com/microsoft/TypeScript-DOM-lib-generator/issues/new).
If the condition is met but still is not available here, first check the heuristics below and then please [file an issue](hthttps://github.com/microsoft/TypeScript-DOM-lib-generator/issues/new).

## Build Instructions

Expand All @@ -28,13 +28,13 @@ To test:
npm run test
```

To deploy:

```sh
npm run migrate
```
## `@types/[lib]` to TypeScript Versions

The script will look in for a clone of the TypeScript repo in "../TypeScript", or "./TypeScript" to move the generated files in.
| `@types/[lib]` version | TypeScript Version | Minimum TypeScript Support |
| ---------------------------------------------------------------------- | ----------- | -------------- |
| `@types/web` [0.0.1](https://www.npmjs.com/package/@types/web/v/0.0.1) | ~4.3 | 4.4 |
| `@types/web` [0.0.2](https://www.npmjs.com/package/@types/web/v/0.0.2) | ~4.4 beta | 4.4 |

## Contribution Guidelines

Expand Down Expand Up @@ -116,3 +116,26 @@ To give you a sense of whether we will accept changes, you can use these heurist
- `removedTypes.json`: types that are defined in the spec file but should be removed.
- `comments.json`: comment strings to be embedded in the generated .js files.
- `deprecatedMessage.json`: the reason why one type is deprecated. The reason why it is a separate file rather than merge in comment.json is mdn/apiDescriptions.json would also possibly be deprecated.

## Deployment to TypeScript

To migrate the *.d.ts files into TypeScript:

1. Run:

```sh
npm run migrate -- [previous_types_web_version]
```

The script will look in for a clone of the TypeScript repo in "../TypeScript", or "./TypeScript" to move the generated files in. Or migrate the files manually, you do you.

1. Update the README table with the mappings for versions in the `@types/[lib]`. E.g. TS 4.5 -> `@types/web` `0.0.23`.

1. Generate a CHANGELOG for the releases:

```sh
# lib from to
npm run ts-changelog -- @types/web 0.0.2 0.0.23
```

1. Add the CHANGELOG to the release issue
82 changes: 62 additions & 20 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3760,6 +3760,28 @@ declare var DOMImplementation: {
};

interface DOMMatrix extends DOMMatrixReadOnly {
a: number;
b: number;
c: number;
d: number;
e: number;
f: number;
m11: number;
m12: number;
m13: number;
m14: number;
m21: number;
m22: number;
m23: number;
m24: number;
m31: number;
m32: number;
m33: number;
m34: number;
m41: number;
m42: number;
m43: number;
m44: number;
invertSelf(): DOMMatrix;
multiplySelf(other?: DOMMatrixInit): DOMMatrix;
preMultiplySelf(other?: DOMMatrixInit): DOMMatrix;
Expand Down Expand Up @@ -3863,6 +3885,10 @@ declare var DOMParser: {
};

interface DOMPoint extends DOMPointReadOnly {
w: number;
x: number;
y: number;
z: number;
}

declare var DOMPoint: {
Expand Down Expand Up @@ -3906,6 +3932,10 @@ declare var DOMQuad: {
};

interface DOMRect extends DOMRectReadOnly {
height: number;
width: number;
x: number;
y: number;
}

declare var DOMRect: {
Expand Down Expand Up @@ -4409,6 +4439,8 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad
/** @deprecated */
captureEvents(): void;
/** @deprecated */
caretRangeFromPoint(x: number, y: number): Range | null;
/** @deprecated */
clear(): void;
/**
* Closes an output stream and forces the sent data to display.
Expand Down Expand Up @@ -4694,6 +4726,8 @@ interface DocumentAndElementEventHandlers {

/** A minimal document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. The key difference is that because the document fragment isn't part of the active document tree structure, changes made to the fragment don't affect the document, cause reflow, or incur any performance impact that can occur when changes are made. */
interface DocumentFragment extends Node, NonElementParentNode, ParentNode {
readonly ownerDocument: Document;
getElementById(elementId: string): HTMLElement | null;
}

declare var DocumentFragment: {
Expand Down Expand Up @@ -9749,7 +9783,7 @@ interface MediaKeySessionEventMap {

/** This EncryptedMediaExtensions API interface represents a context for message exchange with a content decryption module (CDM). */
interface MediaKeySession extends EventTarget {
readonly closed: Promise<undefined>;
readonly closed: Promise<MediaKeySessionClosedReason>;
readonly expiration: number;
readonly keyStatuses: MediaKeyStatusMap;
onkeystatuseschange: ((this: MediaKeySession, ev: Event) => any) | null;
Expand Down Expand Up @@ -10146,22 +10180,22 @@ interface MimeType {
* Returns the MIME type's description.
* @deprecated
*/
readonly description: undefined;
readonly description: string;
/**
* Returns the Plugin object that implements this MIME type.
* @deprecated
*/
readonly enabledPlugin: undefined;
readonly enabledPlugin: Plugin;
/**
* Returns the MIME type's typical file extensions, in a comma-separated list.
* @deprecated
*/
readonly suffixes: undefined;
readonly suffixes: string;
/**
* Returns the MIME type.
* @deprecated
*/
readonly type: undefined;
readonly type: string;
}

/** @deprecated */
Expand All @@ -10178,10 +10212,10 @@ interface MimeTypeArray {
/** @deprecated */
readonly length: number;
/** @deprecated */
item(index: number): any;
item(index: number): MimeType | null;
/** @deprecated */
namedItem(name: string): any;
[index: number]: any;
namedItem(name: string): MimeType | null;
[index: number]: MimeType;
}

/** @deprecated */
Expand Down Expand Up @@ -10226,11 +10260,17 @@ declare var MouseEvent: {
* @deprecated DOM4 [DOM] provides a new mechanism using a MutationObserver interface which addresses the use cases that mutation events solve, but in a more performant manner. Thus, this specification describes mutation events for reference and completeness of legacy behavior, but deprecates the use of the MutationEvent interface.
*/
interface MutationEvent extends Event {
/** @deprecated */
readonly attrChange: number;
/** @deprecated */
readonly attrName: string;
/** @deprecated */
readonly newValue: string;
/** @deprecated */
readonly prevValue: string;
/** @deprecated */
readonly relatedNode: Node | null;
/** @deprecated */
initMutationEvent(typeArg: string, bubblesArg?: boolean, cancelableArg?: boolean, relatedNodeArg?: Node | null, prevValueArg?: string, newValueArg?: string, attrNameArg?: string, attrChangeArg?: number): void;
readonly ADDITION: number;
readonly MODIFICATION: number;
Expand Down Expand Up @@ -10405,7 +10445,6 @@ interface NavigatorOnLine {
readonly onLine: boolean;
}

/** @deprecated */
interface NavigatorPlugins {
/** @deprecated */
readonly mimeTypes: MimeTypeArray;
Expand Down Expand Up @@ -11365,30 +11404,30 @@ interface Plugin {
* Returns the plugin's description.
* @deprecated
*/
readonly description: undefined;
readonly description: string;
/**
* Returns the plugin library's filename, if applicable on the current platform.
* @deprecated
*/
readonly filename: undefined;
readonly filename: string;
/**
* Returns the number of MIME types, represented by MimeType objects, supported by the plugin.
* @deprecated
*/
readonly length: undefined;
readonly length: number;
/**
* Returns the plugin's name.
* @deprecated
*/
readonly name: undefined;
readonly name: string;
/**
* Returns the specified MimeType object.
* @deprecated
*/
item(index: number): void;
item(index: number): MimeType | null;
/** @deprecated */
namedItem(name: string): void;
[index: number]: undefined;
namedItem(name: string): MimeType | null;
[index: number]: MimeType;
}

/** @deprecated */
Expand All @@ -11405,12 +11444,12 @@ interface PluginArray {
/** @deprecated */
readonly length: number;
/** @deprecated */
item(index: number): any;
item(index: number): Plugin | null;
/** @deprecated */
namedItem(name: string): any;
namedItem(name: string): Plugin | null;
/** @deprecated */
refresh(): void;
[index: number]: any;
[index: number]: Plugin;
}

/** @deprecated */
Expand Down Expand Up @@ -11681,6 +11720,7 @@ interface RTCPeerConnectionEventMap {
"connectionstatechange": Event;
"datachannel": RTCDataChannelEvent;
"icecandidate": RTCPeerConnectionIceEvent;
"icecandidateerror": Event;
"iceconnectionstatechange": Event;
"icegatheringstatechange": Event;
"negotiationneeded": Event;
Expand All @@ -11700,6 +11740,7 @@ interface RTCPeerConnection extends EventTarget {
onconnectionstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
ondatachannel: ((this: RTCPeerConnection, ev: RTCDataChannelEvent) => any) | null;
onicecandidate: ((this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any) | null;
onicecandidateerror: ((this: RTCPeerConnection, ev: Event) => any) | null;
oniceconnectionstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
onicegatheringstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
onnegotiationneeded: ((this: RTCPeerConnection, ev: Event) => any) | null;
Expand Down Expand Up @@ -18778,6 +18819,7 @@ type MediaDecodingType = "file" | "media-source" | "webrtc";
type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput";
type MediaEncodingType = "record" | "webrtc";
type MediaKeyMessageType = "individualization-request" | "license-release" | "license-renewal" | "license-request";
type MediaKeySessionClosedReason = "closed-by-application" | "hardware-context-reset" | "internal-error" | "release-acknowledged" | "resource-evicted";
type MediaKeySessionType = "persistent-license" | "temporary";
type MediaKeyStatus = "expired" | "internal-error" | "output-downscaled" | "output-restricted" | "released" | "status-pending" | "usable" | "usable-in-future";
type MediaKeysRequirement = "not-allowed" | "optional" | "required";
Expand All @@ -18793,7 +18835,7 @@ type OscillatorType = "custom" | "sawtooth" | "sine" | "square" | "triangle";
type OverSampleType = "2x" | "4x" | "none";
type PanningModelType = "HRTF" | "equalpower";
type PaymentComplete = "fail" | "success" | "unknown";
type PermissionName = "gamepad" | "geolocation" | "notifications" | "persistent-storage" | "push";
type PermissionName = "gamepad" | "geolocation" | "notifications" | "persistent-storage" | "push" | "screen-wake-lock";
type PermissionState = "denied" | "granted" | "prompt";
type PlaybackDirection = "alternate" | "alternate-reverse" | "normal" | "reverse";
type PositionAlignSetting = "auto" | "center" | "line-left" | "line-right";
Expand Down
6 changes: 3 additions & 3 deletions baselines/dom.iterable.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ interface MessageEvent<T = any> {
}

interface MimeTypeArray {
[Symbol.iterator](): IterableIterator<any>;
[Symbol.iterator](): IterableIterator<MimeType>;
}

interface NamedNodeMap {
Expand Down Expand Up @@ -186,11 +186,11 @@ interface NodeListOf<TNode extends Node> {
}

interface Plugin {
[Symbol.iterator](): IterableIterator<undefined>;
[Symbol.iterator](): IterableIterator<MimeType>;
}

interface PluginArray {
[Symbol.iterator](): IterableIterator<any>;
[Symbol.iterator](): IterableIterator<Plugin>;
}

interface RTCStatsReport extends ReadonlyMap<string, any> {
Expand Down
32 changes: 31 additions & 1 deletion baselines/serviceworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,28 @@ declare var DOMException: {
};

interface DOMMatrix extends DOMMatrixReadOnly {
a: number;
b: number;
c: number;
d: number;
e: number;
f: number;
m11: number;
m12: number;
m13: number;
m14: number;
m21: number;
m22: number;
m23: number;
m24: number;
m31: number;
m32: number;
m33: number;
m34: number;
m41: number;
m42: number;
m43: number;
m44: number;
invertSelf(): DOMMatrix;
multiplySelf(other?: DOMMatrixInit): DOMMatrix;
preMultiplySelf(other?: DOMMatrixInit): DOMMatrix;
Expand Down Expand Up @@ -1085,6 +1107,10 @@ declare var DOMMatrixReadOnly: {
};

interface DOMPoint extends DOMPointReadOnly {
w: number;
x: number;
y: number;
z: number;
}

declare var DOMPoint: {
Expand Down Expand Up @@ -1125,6 +1151,10 @@ declare var DOMQuad: {
};

interface DOMRect extends DOMRectReadOnly {
height: number;
width: number;
x: number;
y: number;
}

declare var DOMRect: {
Expand Down Expand Up @@ -5680,7 +5710,7 @@ type MediaDecodingType = "file" | "media-source" | "webrtc";
type MediaEncodingType = "record" | "webrtc";
type NotificationDirection = "auto" | "ltr" | "rtl";
type NotificationPermission = "default" | "denied" | "granted";
type PermissionName = "gamepad" | "geolocation" | "notifications" | "persistent-storage" | "push";
type PermissionName = "gamepad" | "geolocation" | "notifications" | "persistent-storage" | "push" | "screen-wake-lock";
type PermissionState = "denied" | "granted" | "prompt";
type PredefinedColorSpace = "display-p3" | "srgb";
type PremultiplyAlpha = "default" | "none" | "premultiply";
Expand Down
Loading

0 comments on commit da9770b

Please sign in to comment.