Skip to content

Commit 0ebeb8d

Browse files
authored
Merge branch 'master' into buffersource
2 parents 048c8bd + 8ebb762 commit 0ebeb8d

File tree

6 files changed

+137
-17
lines changed

6 files changed

+137
-17
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
AppVeyor Status: [![Build status](https://ci.appveyor.com/api/projects/status/8oj3j7u6nvag1xvu/branch/master?svg=true)](https://ci.appveyor.com/project/zhengbli/tsjs-lib-generator/branch/master)
44
Travis CI Status: [![Build Status](https://travis-ci.org/Microsoft/TSJS-lib-generator.svg?branch=master)](https://travis-ci.org/Microsoft/TSJS-lib-generator)
55

6-
This tool is used to generate `dom.generated.d.ts` and `webworker.generated.d.ts` for TypeScript, and `domWeb.js` and `domWindows.js` for Visual Studio JavaScript language service.
6+
This tool is used to generate `dom.generated.d.ts`, `webworker.generated.d.ts` and `dom.es6.generated.d.ts` for TypeScript.
77
The input file is the XML spec file generated by the Microsoft Edge browser.
88

99
## Build Instructions
@@ -15,12 +15,15 @@ Note: for OS X and Unix users, [Mono 4.2 or higher](http://www.mono-project.com/
1515

1616
## Contribution Guidelines
1717

18-
The `dom.generated.d.ts` and `webworker.generated.d.ts` files in the TypeScript repo are used as baselines.
18+
The `dom.generated.d.ts`, `webworker.generated.d.ts` and `dom.es6.generated.d.ts` files from the TypeScript repo are used as baselines.
1919
For each pull request, we will run the script and compare the generated files with the baseline files.
2020
In order to make the tests pass, please update the baseline as well in any pull requests.
2121

2222
For common changes, it is sufficient to change the json files.
23-
There are three json files that are used to alter the file generation: `addedTypes.json`, `overridingTypes.json`, and `removedTypes.json`.
23+
There are three json files that are typically used to alter the type generation: `addedTypes.json`, `overridingTypes.json`, and `removedTypes.json`.
24+
`comments.json` can used to add comments to the types.
25+
Finally, `knownWorkerEnums` and `knownWorkerInterfaces` determine which types are available in a WebWorker environment.
26+
2427
The format of each file can be inferred from their existing content.
2528

2629
The common steps to send a pull request are:
@@ -50,9 +53,8 @@ A "Living Standard" ([example](https://xhr.spec.whatwg.org/)) should be added he
5053

5154
## Code Structure
5255

53-
- `Shared.fs`: handles the parsing from XML spec file, and stores the common data structures for later use.
54-
- `TS.fs`: handles the emitting of the `lib.d.ts` file.
55-
- `JS.fs`: handles the emitting of the `domWeb.js` and `domWindows.js`.
56+
- `Build.fsx`: Runs `TS.fsx` for all targets, then does a snapshot test by comparing the `generated/` and `baseline/` contents.
57+
- `TS.fsx`: handles the emitting of the `.d.ts` files.
5658

5759
## Input Files
5860

@@ -63,5 +65,4 @@ A "Living Standard" ([example](https://xhr.spec.whatwg.org/)) should be added he
6365
- `overridingTypes.json`: types that are defined in the spec file but has a better or more up-to-date definitions in the json files.
6466
- `removedTypes.json`: types that are defined in the spec file but should be removed.
6567
- `comments.json`: comment strings to be embedded in the generated .js files.
66-
- `jsTemplate.js`: the initial templates for `domWeb.js` and `domWindows.js`, which contains the necessary helper functions.
67-
- `sample.json`: sample json file used to tell F# json type provider that structure of the json files. The content of it is not used anywhere.
68+
- `sample.json`: sample json file used to tell F# json type provider that structure of the json files. The content of it is not used anywhere. **Do not edit this file**.

baselines/dom.generated.d.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ interface RegistrationOptions {
770770
}
771771

772772
interface RequestInit {
773+
signal?: AbortSignal;
773774
body?: Blob | BufferSource | FormData | string | null;
774775
cache?: RequestCache;
775776
credentials?: RequestCredentials;
@@ -3596,8 +3597,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
35963597
slot: string;
35973598
readonly shadowRoot: ShadowRoot | null;
35983599
getAttribute(name: string): string | null;
3599-
getAttributeNode(name: string): Attr;
3600-
getAttributeNodeNS(namespaceURI: string, localName: string): Attr;
3600+
getAttributeNode(name: string): Attr | null;
3601+
getAttributeNodeNS(namespaceURI: string, localName: string): Attr | null;
36013602
getAttributeNS(namespaceURI: string, localName: string): string;
36023603
getBoundingClientRect(): ClientRect;
36033604
getClientRects(): ClientRectList;
@@ -5500,8 +5501,9 @@ interface HTMLInputElement extends HTMLElement {
55005501
* Sets the start and end positions of a selection in a text field.
55015502
* @param start The offset into the text field for the start of the selection.
55025503
* @param end The offset into the text field for the end of the selection.
5504+
* @param direction The direction in which the selection is performed.
55035505
*/
5504-
setSelectionRange(start?: number, end?: number, direction?: string): void;
5506+
setSelectionRange(start: number, end: number, direction?: "forward" | "backward" | "none"): void;
55055507
/**
55065508
* Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value.
55075509
* @param n Value to decrement the value by.
@@ -6964,8 +6966,9 @@ interface HTMLTextAreaElement extends HTMLElement {
69646966
* Sets the start and end positions of a selection in a text field.
69656967
* @param start The offset into the text field for the start of the selection.
69666968
* @param end The offset into the text field for the end of the selection.
6969+
* @param direction The direction in which the selection is performed.
69676970
*/
6968-
setSelectionRange(start: number, end: number): void;
6971+
setSelectionRange(start: number, end: number, direction?: "forward" | "backward" | "none"): void;
69696972
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
69706973
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
69716974
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -9233,6 +9236,7 @@ interface Request extends Object, Body {
92339236
readonly referrerPolicy: ReferrerPolicy;
92349237
readonly type: RequestType;
92359238
readonly url: string;
9239+
readonly signal: AbortSignal;
92369240
clone(): Request;
92379241
}
92389242

@@ -14785,6 +14789,21 @@ interface WEBGL_lose_context {
1478514789
restoreContext(): void;
1478614790
}
1478714791

14792+
interface AbortController {
14793+
readonly signal: AbortSignal;
14794+
abort(): void;
14795+
}
14796+
14797+
declare var AbortController: {
14798+
prototype: AbortController;
14799+
new(): AbortController;
14800+
};
14801+
14802+
interface AbortSignal extends EventTarget {
14803+
readonly aborted: boolean;
14804+
onabort: (ev: Event) => any;
14805+
}
14806+
1478814807
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
1478914808

1479014809
interface DecodeErrorCallback {
@@ -15365,4 +15384,4 @@ type ServiceWorkerState = "installing" | "installed" | "activating" | "activated
1536515384
type Transport = "usb" | "nfc" | "ble";
1536615385
type VideoFacingModeEnum = "user" | "environment" | "left" | "right";
1536715386
type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded";
15368-
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
15387+
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";

baselines/webworker.generated.d.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ interface PushSubscriptionOptionsInit {
7171
}
7272

7373
interface RequestInit {
74+
signal?: AbortSignal;
7475
body?: Blob | BufferSource | FormData | string | null;
7576
cache?: RequestCache;
7677
credentials?: RequestCredentials;
@@ -960,6 +961,7 @@ interface Request extends Object, Body {
960961
readonly referrerPolicy: ReferrerPolicy;
961962
readonly type: RequestType;
962963
readonly url: string;
964+
readonly signal: AbortSignal;
963965
clone(): Request;
964966
}
965967

@@ -1822,6 +1824,21 @@ interface AddEventListenerOptions extends EventListenerOptions {
18221824
once?: boolean;
18231825
}
18241826

1827+
interface AbortController {
1828+
readonly signal: AbortSignal;
1829+
abort(): void;
1830+
}
1831+
1832+
declare var AbortController: {
1833+
prototype: AbortController;
1834+
new(): AbortController;
1835+
};
1836+
1837+
interface AbortSignal extends EventTarget {
1838+
readonly aborted: boolean;
1839+
onabort: (ev: Event) => any;
1840+
}
1841+
18251842
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
18261843

18271844
interface DecodeErrorCallback {
@@ -1912,4 +1929,4 @@ type ServiceWorkerState = "installing" | "installed" | "activating" | "activated
19121929
type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded";
19131930
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
19141931
type ClientType = "window" | "worker" | "sharedworker" | "all";
1915-
type FrameType = "auxiliary" | "top-level" | "nested" | "none";
1932+
type FrameType = "auxiliary" | "top-level" | "nested" | "none";

inputfiles/addedTypes.json

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2488,5 +2488,56 @@
24882488
"readonly": true,
24892489
"name": "lastModified",
24902490
"type": "number"
2491+
},
2492+
{
2493+
"kind": "interface",
2494+
"name": "AbortController",
2495+
"constructorSignatures": [
2496+
"new(): AbortController"
2497+
],
2498+
"properties": [
2499+
{
2500+
"readonly": true,
2501+
"name": "signal",
2502+
"type": "AbortSignal"
2503+
}
2504+
],
2505+
"methods": [
2506+
{
2507+
"name": "abort",
2508+
"signatures": [
2509+
"abort(): void"
2510+
]
2511+
}
2512+
]
2513+
},
2514+
{
2515+
"kind": "interface",
2516+
"name": "AbortSignal",
2517+
"extends": "EventTarget",
2518+
"properties": [
2519+
{
2520+
"readonly": true,
2521+
"name": "aborted",
2522+
"type": "boolean"
2523+
},
2524+
{
2525+
"name": "onabort",
2526+
"type": "(ev: Event) => any"
2527+
}
2528+
]
2529+
},
2530+
{
2531+
"kind": "property",
2532+
"interface": "Request",
2533+
"readonly": true,
2534+
"name": "signal",
2535+
"type": "AbortSignal"
2536+
},
2537+
{
2538+
"kind": "property",
2539+
"interface": "RequestInit",
2540+
"name": "signal?",
2541+
"type": "AbortSignal"
24912542
}
2492-
]
2543+
]

inputfiles/comments.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@
19481948
},
19491949
{
19501950
"name": "setSelectionRange",
1951-
"comment": "/**\r\n * Sets the start and end positions of a selection in a text field.\r\n * @param start The offset into the text field for the start of the selection.\r\n * @param end The offset into the text field for the end of the selection.\r\n */"
1951+
"comment": "/**\r\n * Sets the start and end positions of a selection in a text field.\r\n * @param start The offset into the text field for the start of the selection.\r\n * @param end The offset into the text field for the end of the selection.\r\n * @param direction The direction in which the selection is performed.\r\n */"
19521952
},
19531953
{
19541954
"name": "select",
@@ -2335,7 +2335,7 @@
23352335
},
23362336
{
23372337
"name": "setSelectionRange",
2338-
"comment": "/**\r\n * Sets the start and end positions of a selection in a text field.\r\n * @param start The offset into the text field for the start of the selection.\r\n * @param end The offset into the text field for the end of the selection.\r\n */"
2338+
"comment": "/**\r\n * Sets the start and end positions of a selection in a text field.\r\n * @param start The offset into the text field for the start of the selection.\r\n * @param end The offset into the text field for the end of the selection.\r\n * @param direction The direction in which the selection is performed.\r\n */"
23392339
},
23402340
{
23412341
"name": "select",

inputfiles/overridingTypes.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,5 +1739,37 @@
17391739
"readonly": true,
17401740
"name": "lastModifiedDate",
17411741
"type": "Date"
1742+
},
1743+
{
1744+
"kind": "method",
1745+
"interface": "HTMLInputElement",
1746+
"name": "setSelectionRange",
1747+
"signatures": [
1748+
"setSelectionRange(start: number, end: number, direction?: \"forward\" | \"backward\" | \"none\"): void"
1749+
]
1750+
},
1751+
{
1752+
"kind": "method",
1753+
"interface": "HTMLTextAreaElement",
1754+
"name": "setSelectionRange",
1755+
"signatures": [
1756+
"setSelectionRange(start: number, end: number, direction?: \"forward\" | \"backward\" | \"none\"): void"
1757+
]
1758+
},
1759+
{
1760+
"kind": "method",
1761+
"interface": "Element",
1762+
"name": "getAttributeNodeNS",
1763+
"signatures": [
1764+
"getAttributeNodeNS(namespaceURI: string, localName: string): Attr | null"
1765+
]
1766+
},
1767+
{
1768+
"kind": "method",
1769+
"interface": "Element",
1770+
"name": "getAttributeNode",
1771+
"signatures": [
1772+
"getAttributeNode(name: string): Attr | null"
1773+
]
17421774
}
17431775
]

0 commit comments

Comments
 (0)