Skip to content

Commit e182172

Browse files
committed
Merge master branch
2 parents 3d731ad + 7e7ca0e commit e182172

File tree

6 files changed

+66
-14
lines changed

6 files changed

+66
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ ClientBin/
162162
*.publishsettings
163163
node_modules/
164164
bower_components/
165+
.DS_Store
165166

166167
# RIA/Silverlight projects
167168
Generated_Code/

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
# TypeScript and JavaScript lib generator
2+
3+
[![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)
4+
25
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.
36

47
## Build Instruction
5-
To build the tool, simply clone the repo, and run `build.cmd` in command line or powershell. If it runs successfully, the output files will be generated under the `generated` folder.
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.
9+
10+
Note: for OS X/ Unix users, [Mono 4.2](http://www.mono-project.com/download/alpha/) is required.
11+
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.
16+
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.
20+
21+
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.
626

727
## Code Structure
828
- `Shared.fs`: handles the parsing from XML spec file, and stores the common data structures for later use;
929
- `TS.fs`: handles the emitting of the `lib.d.ts` file;
1030
- `JS.fs`: handles the emitting of the `domWeb.js` and `domWindows.js`
1131

12-
## Contribution Guide
13-
The `dom.generated.d.ts` and `webworker.generated.d.ts` files that are used in TypeScript repo `master` branch are used as baselines. For each pull request, we will try run the script and compare the generated files with the baseline files. So to make the tests passed, please update the baseline and the code at the same pull request.
14-
1532
## Input Files:
1633
- `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.);
1734
- `webworker.webidl.xml`: contains additional types for webworker.

Shared.fsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#r @"packages\FSharp.Data\lib\net40\FSharp.Data.dll"
1+
#r "packages/FSharp.Data/lib/net40/FSharp.Data.dll"
22
#r "System.Xml.Linq.dll"
33

44
open FSharp.Data
@@ -12,11 +12,11 @@ open Microsoft.FSharp.Reflection
1212
/// Global variables
1313
/// ===========================================
1414
module GlobalVars =
15-
if not (Directory.Exists(__SOURCE_DIRECTORY__ + @"\generated")) then
16-
Directory.CreateDirectory(__SOURCE_DIRECTORY__ + @"\generated") |> ignore
15+
if not (Directory.Exists(__SOURCE_DIRECTORY__ + @"/generated")) then
16+
Directory.CreateDirectory(__SOURCE_DIRECTORY__ + @"/generated") |> ignore
1717

18-
let inputFolder = __SOURCE_DIRECTORY__ + @"\inputfiles"
19-
let makeTextWriter fileName = File.CreateText(__SOURCE_DIRECTORY__ + @"\generated\" + fileName) :> TextWriter
18+
let inputFolder = __SOURCE_DIRECTORY__ + @"/inputfiles"
19+
let makeTextWriter fileName = File.CreateText(__SOURCE_DIRECTORY__ + @"/generated/" + fileName) :> TextWriter
2020
// let jsWebOutput = makeTextWriter "domWeb.js"
2121
// let jsWinOutput = makeTextWriter "domWindows.js"
2222
// let jsWorkerOutput = makeTextWriter "dedicatedworker.js"
@@ -49,13 +49,13 @@ module JsonItems =
4949
type ItemsType = JsonProvider<"inputfiles/sample.json">
5050

5151
let overriddenItems =
52-
File.ReadAllText(GlobalVars.inputFolder + @"\overridingTypes.json") |> ItemsType.Parse
52+
File.ReadAllText(GlobalVars.inputFolder + @"/overridingTypes.json") |> ItemsType.Parse
5353

5454
let removedItems =
55-
File.ReadAllText(GlobalVars.inputFolder + @"\removedTypes.json") |> ItemsType.Parse
55+
File.ReadAllText(GlobalVars.inputFolder + @"/removedTypes.json") |> ItemsType.Parse
5656

5757
let addedItems =
58-
File.ReadAllText(GlobalVars.inputFolder + @"\addedTypes.json") |> ItemsType.Parse
58+
File.ReadAllText(GlobalVars.inputFolder + @"/addedTypes.json") |> ItemsType.Parse
5959

6060
// This is the kind of items in the external json files that are used as a
6161
// correction for the spec.
@@ -95,7 +95,7 @@ module JsonItems =
9595
module Comments =
9696
type CommentType = JsonProvider<"inputfiles/comments.json">
9797

98-
let comments = File.ReadAllText(__SOURCE_DIRECTORY__ + @"\inputfiles\comments.json") |> CommentType.Parse
98+
let comments = File.ReadAllText(__SOURCE_DIRECTORY__ + @"/inputfiles/comments.json") |> CommentType.Parse
9999

100100
let GetCommentForProperty iName pName =
101101
match comments.Interfaces |> Array.tryFind (fun i -> i.Name = iName) with

baselines/dom.generated.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
20582058
* Gets or sets the version attribute specified in the declaration of an XML document.
20592059
*/
20602060
xmlVersion: string;
2061+
currentScript: HTMLScriptElement;
20612062
adoptNode(source: Node): Node;
20622063
captureEvents(): void;
20632064
clear(): void;
@@ -7869,6 +7870,7 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte
78697870
getGamepads(): Gamepad[];
78707871
javaEnabled(): boolean;
78717872
msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void;
7873+
vibrate(pattern: number | number[]): boolean;
78727874
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
78737875
}
78747876

build.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
if [ ! -d ".paket" ]; then
3+
mkdir ".paket"
4+
curl https://github.com/fsprojects/Paket/releases/download/2.12.5/paket.bootstrapper.exe -L --insecure -o .paket/paket.bootstrapper.exe
5+
fi
6+
7+
mono .paket/paket.bootstrapper.exe
8+
exit_code=$?
9+
if [ $exit_code -ne 0 ]; then
10+
exit $exit_code
11+
fi
12+
13+
mono .paket/paket.exe restore
14+
exit_code=$?
15+
if [ $exit_code -ne 0 ]; then
16+
exit $exit_code
17+
fi
18+
19+
mono packages/FAKE/tools/FAKE.exe build.fsx

inputfiles/addedTypes.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,18 @@
217217
"kind": "method",
218218
"interface": "Node",
219219
"signatures":["contains(node: Node): boolean"]
220-
}
220+
},
221+
{
222+
"kind": "method",
223+
"interface": "Navigator",
224+
"signatures": [
225+
"vibrate(pattern: number | number[]): boolean"
226+
]
227+
},
228+
{
229+
"kind": "property",
230+
"interface": "Document",
231+
"name": "currentScript",
232+
"type": "HTMLScriptElement"
233+
}
221234
]

0 commit comments

Comments
 (0)