Skip to content

Commit 086167b

Browse files
fetch latest branch
fetch latest branch.
2 parents ee39b6d + 9e9785f commit 086167b

File tree

5 files changed

+60
-28
lines changed

5 files changed

+60
-28
lines changed

README.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,47 @@
22

33
[![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

5-
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. The input file is the XML spec file generated by the Microsoft Edge browser.
5+
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+
The input file is the XML spec file generated by the Microsoft Edge browser.
67

7-
## Build Instruction
8-
To build the tool, simply clone the repo, and run `build.cmd` (Windows) or `build.sh` (OS X/Unix) in command line. If it runs successfully, the output files will be generated under the `generated` folder.
8+
## Build Instructions
99

10-
Note: for OS X/ Unix users, [Mono 4.2](http://www.mono-project.com/download/alpha/) is required.
10+
To build the tool, simply clone this repo, and run `build.cmd` (Windows) or `build.sh` (OS X/Unix) on the command line.
11+
If it runs successfully, the output files will be generated under the `generated` folder.
1112

12-
## Contribution Guide
13-
The `dom.generated.d.ts` and `webworker.generated.d.ts` files in the TypeScript repo are used as baselines.
14-
For each pull request, we will run the script and compare the generated files with the baseline files.
15-
In order to make the tests pass, please update the baseline as well in any pull requests.
13+
Note: for OS X and Unix users, [Mono 4.2](http://www.mono-project.com/download/alpha/) is required.
1614

17-
For common changes, it is sufficient to change the json files.
18-
There are three json files that are used to alter the file generation: `addedTypes.json`, `overridingTypes.json` and `removedTypes.json`.
19-
The format of each file can be inferred from their existing content.
15+
## Contribution Guidelines
16+
17+
The `dom.generated.d.ts` and `webworker.generated.d.ts` files in the TypeScript repo are used as baselines.
18+
For each pull request, we will run the script and compare the generated files with the baseline files.
19+
In order to make the tests pass, please update the baseline as well in any pull requests.
20+
21+
For common changes, it is sufficient to change the json files.
22+
There are three json files that are used to alter the file generation: `addedTypes.json`, `overridingTypes.json`, and `removedTypes.json`.
23+
The format of each file can be inferred from their existing content.
2024

2125
The common steps to send a pull request are:
22-
0. Open or refer to an issue in the [TypeScript repo](https://github.com/Microsoft/TypeScript).
23-
1. Add missing elements to `inputfiles/addedTypes.json`, overriding elements to `inputfiles/overridingTypes.json`, or elements to remove to `inputfiles/removedTypes.json`.
24-
2. Run the script locally to obtain new `dom.generated.d.ts` and `webworker.generated.d.ts`.
25-
3. Update the files in the `baselines` folder using the newly generated files.
26+
27+
0. Open or refer to an issue in the [TypeScript repo](https://github.com/Microsoft/TypeScript).
28+
1. Add missing elements to `inputfiles/addedTypes.json`, overriding elements to `inputfiles/overridingTypes.json`, or elements to remove to `inputfiles/removedTypes.json`.
29+
2. Run the script locally to obtain new `dom.generated.d.ts` and `webworker.generated.d.ts`.
30+
3. Update the files in the `baselines` folder using the newly generated files.
2631

2732
## Code Structure
28-
- `Shared.fs`: handles the parsing from XML spec file, and stores the common data structures for later use;
29-
- `TS.fs`: handles the emitting of the `lib.d.ts` file;
30-
- `JS.fs`: handles the emitting of the `domWeb.js` and `domWindows.js`
3133

32-
## Input Files:
33-
- `browser.webidl.xml`: the XML spec file generated by Microsoft Edge (due to the different updating schedules between Edge and TypeScript, this may **not** be the most up-to-date version of the spec.);
34-
- `webworker.webidl.xml`: contains additional types for webworker.
34+
- `Shared.fs`: handles the parsing from XML spec file, and stores the common data structures for later use.
35+
- `TS.fs`: handles the emitting of the `lib.d.ts` file.
36+
- `JS.fs`: handles the emitting of the `domWeb.js` and `domWindows.js`.
37+
38+
## Input Files
39+
40+
- `browser.webidl.xml`: an XML spec file generated by Microsoft Edge. **Do not edit this file**.
41+
- Due to the different update schedules between Edge and TypeScript, this may not be the most up-to-date version of the spec.
42+
- `webworker.webidl.xml`: an XML spec file generated by Microsoft Edge that contains types for Web Workers. **Do not edit this file**.
3543
- `addedTypes.json`: types that should exist in either browser or webworker but are missing from the Edge spec. The type can be `property`, `method`, `interface`, `constructor`, or `indexer`.
3644
- `overridingTypes.json`: types that are defined in the spec file but has a better or more up-to-date definitions in the json files.
3745
- `removedTypes.json`: types that are defined in the spec file but should be removed.
38-
- `comments.json`: comment strings to be embedded in the generated .js files
39-
- `jsTemplate.js`: the initial templates for `domWeb.js` and `domWindows.js`, which contains the necessary helper functions;
46+
- `comments.json`: comment strings to be embedded in the generated .js files.
47+
- `jsTemplate.js`: the initial templates for `domWeb.js` and `domWindows.js`, which contains the necessary helper functions.
4048
- `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.

baselines/dom.generated.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ interface Console {
12551255
select(element: Element): void;
12561256
time(timerName?: string): void;
12571257
timeEnd(timerName?: string): void;
1258-
trace(): void;
1258+
trace(message?: any, ...optionalParams: any[]): void;
12591259
warn(message?: any, ...optionalParams: any[]): void;
12601260
}
12611261

@@ -1514,9 +1514,9 @@ interface DataTransferItemList {
15141514
length: number;
15151515
add(data: File): DataTransferItem;
15161516
clear(): void;
1517-
item(index: number): File;
1517+
item(index: number): DataTransferItem;
15181518
remove(index: number): void;
1519-
[index: number]: File;
1519+
[index: number]: DataTransferItem;
15201520
}
15211521

15221522
declare var DataTransferItemList: {
@@ -3770,6 +3770,7 @@ interface HTMLCanvasElement extends HTMLElement {
37703770
* @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image.
37713771
*/
37723772
toDataURL(type?: string, ...args: any[]): string;
3773+
toBlob(): Blob;
37733774
}
37743775

37753776
declare var HTMLCanvasElement: {
@@ -12829,7 +12830,7 @@ declare function msCancelRequestAnimationFrame(handle: number): void;
1282912830
declare function msMatchMedia(mediaQuery: string): MediaQueryList;
1283012831
declare function msRequestAnimationFrame(callback: FrameRequestCallback): number;
1283112832
declare function msWriteProfilerMark(profilerMarkName: string): void;
12832-
declare function open(url?: string, target?: string, features?: string, replace?: boolean): any;
12833+
declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window;
1283312834
declare function postMessage(message: any, targetOrigin: string, ports?: any): void;
1283412835
declare function print(): void;
1283512836
declare function prompt(message?: string, _default?: string): string;

baselines/webworker.generated.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ interface Console {
6969
select(element: any): void;
7070
time(timerName?: string): void;
7171
timeEnd(timerName?: string): void;
72-
trace(): void;
72+
trace(message?: any, ...optionalParams: any[]): void;
7373
warn(message?: any, ...optionalParams: any[]): void;
7474
}
7575

inputfiles/addedTypes.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,5 +302,11 @@
302302
"interface": "HTMLSelectElement",
303303
"name": "selectedOptions",
304304
"type": "HTMLCollection"
305+
},
306+
{
307+
"kind": "method",
308+
"interface": "HTMLCanvasElement",
309+
"name": "toBlob",
310+
"signatures": ["toBlob(): Blob"]
305311
}
306312
]

inputfiles/overridingTypes.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,23 @@
296296
"name": "version",
297297
"type": "number"
298298
},
299+
{
300+
"kind": "method",
301+
"interface": "Console",
302+
"name": "trace",
303+
"signatures": ["trace(message?: any, ...optionalParams: any[]): void"]
304+
},
305+
{
306+
"kind": "method",
307+
"interface": "DataTransferItemList",
308+
"name": "item",
309+
"signatures": ["item(index: number): DataTransferItem"]
310+
},
311+
{
312+
"kind": "indexer",
313+
"interface": "DataTransferItemList",
314+
"signatures": ["[index: number]: DataTransferItem"]
315+
},
299316
{
300317
"kind": "method",
301318
"interface": "Window",

0 commit comments

Comments
 (0)