diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
commit | abd94a7f5a50f43c797a11b53549ae48fff667c3 (patch) | |
tree | ab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/gulp-typescript | |
parent | a0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff) | |
download | wallet-core-abd94a7f5a50f43c797a11b53549ae48fff667c3.tar.xz |
add node_modules to address #4364
Diffstat (limited to 'node_modules/gulp-typescript')
35 files changed, 2301 insertions, 0 deletions
diff --git a/node_modules/gulp-typescript/.editorconfig b/node_modules/gulp-typescript/.editorconfig new file mode 100644 index 000000000..2730bb11d --- /dev/null +++ b/node_modules/gulp-typescript/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[{lib/**.ts,gulpfile.js,test/**/gulptask.js}] +indent_style = tab +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true
\ No newline at end of file diff --git a/node_modules/gulp-typescript/.gitmodules b/node_modules/gulp-typescript/.gitmodules new file mode 100644 index 000000000..a96a26aa9 --- /dev/null +++ b/node_modules/gulp-typescript/.gitmodules @@ -0,0 +1,17 @@ +[submodule "typescript/dev"] + path = typescript/dev + url = https://github.com/Microsoft/TypeScript.git +[submodule "typescript/1-4"] + path = typescript/1-4 + url = https://github.com/Microsoft/TypeScript.git + branch = release-1.4 +[submodule "typescript/1-5"] + path = typescript/1-5 + url = https://github.com/Microsoft/TypeScript.git + branch = release-1.5 +[submodule "typescript/1-6"] + path = typescript/1-6 + url = https://github.com/Microsoft/TypeScript.git +[submodule "typescript/1-7"] + path = typescript/1-7 + url = https://github.com/Microsoft/TypeScript.git diff --git a/node_modules/gulp-typescript/.npmignore b/node_modules/gulp-typescript/.npmignore new file mode 100644 index 000000000..d41b8095b --- /dev/null +++ b/node_modules/gulp-typescript/.npmignore @@ -0,0 +1,8 @@ +definitions +gulpfile.js +lib +release-2 +test +typescript +typings +.vscode
\ No newline at end of file diff --git a/node_modules/gulp-typescript/.travis.yml b/node_modules/gulp-typescript/.travis.yml new file mode 100644 index 000000000..6e3d5dc54 --- /dev/null +++ b/node_modules/gulp-typescript/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.12" + - "0.10" +notifications: + email: false diff --git a/node_modules/gulp-typescript/issue_template.md b/node_modules/gulp-typescript/issue_template.md new file mode 100644 index 000000000..2511f1146 --- /dev/null +++ b/node_modules/gulp-typescript/issue_template.md @@ -0,0 +1,34 @@ +<!-- +Before submitting an issue, check that the following questions can be answered with yes: + +- Is this related to gulp-typescript, and not to TypeScript? +- Is the behavior of gulp-typescript different than the behavior of tsc? +- There was no similar issue already opened? (Please don't bump old closed issues) + +If you can answer all these questions with yes, add a description of your issue here and fill in the related sections below. +--> + +**Expected behavior:** + +**Actual behavior:** + +**Your gulpfile:** + +*Include your gulpfile, or only the related task (with `ts.createProject`).* +```javascript + +``` + +**tsconfig.json** + +*Include your tsconfig, if related to this issue.* +```json + +``` + +**Code** + +*Include your TypeScript code, if necessary.* +```typescript + +``` diff --git a/node_modules/gulp-typescript/package.json b/node_modules/gulp-typescript/package.json new file mode 100644 index 000000000..8845e12c8 --- /dev/null +++ b/node_modules/gulp-typescript/package.json @@ -0,0 +1,147 @@ +{ + "_args": [ + [ + { + "raw": "gulp-typescript@^3.0.2", + "scope": null, + "escapedName": "gulp-typescript", + "name": "gulp-typescript", + "rawSpec": "^3.0.2", + "spec": ">=3.0.2 <4.0.0", + "type": "range" + }, + "/home/dold/repos/taler/wallet-webex" + ] + ], + "_from": "gulp-typescript@>=3.0.2 <4.0.0", + "_id": "gulp-typescript@3.0.2", + "_inCache": true, + "_location": "/gulp-typescript", + "_nodeVersion": "6.2.0", + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/gulp-typescript-3.0.2.tgz_1475354011112_0.3127239129971713" + }, + "_npmUser": { + "name": "ivogabe", + "email": "ivogabe@ivogabe.nl" + }, + "_npmVersion": "3.8.9", + "_phantomChildren": {}, + "_requested": { + "raw": "gulp-typescript@^3.0.2", + "scope": null, + "escapedName": "gulp-typescript", + "name": "gulp-typescript", + "rawSpec": "^3.0.2", + "spec": ">=3.0.2 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "#DEV:/" + ], + "_resolved": "https://registry.npmjs.org/gulp-typescript/-/gulp-typescript-3.0.2.tgz", + "_shasum": "684cfd75d0df0647514e8679d4f9f34b28df1da5", + "_shrinkwrap": null, + "_spec": "gulp-typescript@^3.0.2", + "_where": "/home/dold/repos/taler/wallet-webex", + "author": { + "name": "Ivo Gabe de Wolff", + "url": "http://ivogabe.com/" + }, + "bugs": { + "url": "https://github.com/ivogabe/gulp-typescript/issues" + }, + "contributors": [ + { + "name": "Jesper Jonsson", + "email": "jesper.m.jonsson@gmail.com" + }, + { + "name": "Shogo Iwano", + "email": "shiwano@gmail.com" + }, + { + "name": "Martin Poelstra", + "email": "m.poelstra@spiritit.com" + }, + { + "name": "Jakub Olek", + "email": "bukaj.kelo+github@gmail.com" + }, + { + "name": "Ilan Frumer", + "email": "IlanFrumer@gmail.com" + }, + { + "name": "James Whitney", + "email": "james@whitney.io" + }, + { + "name": "Jaroslaw Zalucki", + "email": "mad.jaro@gmail.com" + }, + { + "name": "Yui Tanglertsampan", + "email": "yuisu@microsoft.com" + } + ], + "dependencies": { + "gulp-util": "~3.0.7", + "source-map": "~0.5.3", + "through2": "~2.0.1", + "vinyl-fs": "~2.4.3" + }, + "description": "A typescript compiler for gulp with incremental compilation support.", + "devDependencies": { + "gulp": "~3.9.1", + "gulp-concat": "~2.6.0", + "gulp-diff": "~1.0.0", + "gulp-header": "~1.7.1", + "gulp-plumber": "~1.1.0", + "gulp-sourcemaps": "~1.6.0", + "merge-stream": "~1.0.0", + "rimraf": "~2.5.2", + "typescript": "2.0.3" + }, + "directories": {}, + "dist": { + "shasum": "684cfd75d0df0647514e8679d4f9f34b28df1da5", + "tarball": "https://registry.npmjs.org/gulp-typescript/-/gulp-typescript-3.0.2.tgz" + }, + "gitHead": "dc2103c51839138e40b5542fcf351c609df86de3", + "homepage": "https://github.com/ivogabe/gulp-typescript", + "keywords": [ + "typescript", + "gulpplugin", + "incremental compilation", + "ts", + "tsc", + "compile", + "compiler", + "transpile" + ], + "license": "MIT", + "main": "release/main.js", + "maintainers": [ + { + "name": "ivogabe", + "email": "ivogabe@ivogabe.nl" + } + ], + "name": "gulp-typescript", + "optionalDependencies": {}, + "peerDependencies": { + "typescript": "~2.0.3 || >=2.0.0-dev || >=2.1.0-dev" + }, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/ivogabe/gulp-typescript.git" + }, + "scripts": { + "test": "gulp" + }, + "typings": "release/main.d.ts", + "version": "3.0.2" +} diff --git a/node_modules/gulp-typescript/readme.md b/node_modules/gulp-typescript/readme.md new file mode 100644 index 000000000..cf4df68a1 --- /dev/null +++ b/node_modules/gulp-typescript/readme.md @@ -0,0 +1,228 @@ +gulp-typescript +=============== +A gulp plugin for handling TypeScript compilation workflow. The plugin exposes TypeScript's compiler options to gulp using TypeScript API. + +Updating from version 2? See the [breaking changes in version 3](http://dev.ivogabe.com/gulp-typescript-3/). + +[![Build Status](https://travis-ci.org/ivogabe/gulp-typescript.svg?branch=master)](https://travis-ci.org/ivogabe/gulp-typescript) + +Features +-------- +- Incremental compilation (so faster builds) +- Error reporting +- Different output streams for .js, .d.ts files. +- Support for sourcemaps using gulp-sourcemaps +- Compile once, and filter different targets + +How to install +-------------- +##### 1. Install gulp +```shell +npm install --global gulp +``` +##### 2. Install gulp in the project dependency +```shell +npm install gulp +``` +##### 3. Install gulp-typescript & TypeScript +```shell +npm install gulp-typescript typescript +``` + +Options +------- +Allmost all options from TypeScript are supported. +- `outFile` (string) - Generate one javascript and one definition file. Only works when no module system is used. +- `outDir` (string) - Move output to a different (virtual) directory. Note that you still need `gulp.dest` to write output to disk. +- `noImplicitAny` (boolean) - Warn on expressions and declarations with an implied 'any' type. +- `suppressImplicitAnyIndexErrors` (boolean) - Suppress `--noImplicitAny` errors for indexing objects lacking index signatures. +- `noLib` (boolean) - Don't include the default lib (with definitions for - Array, Date etc) +- `lib` (string[]) - List of library files to be included in the compilation. +- `target` (string) - Specify ECMAScript target version: 'ES3' (default), 'ES5' or 'ES6'. +- `module` (string) - Specify module code generation: 'commonjs', 'amd', 'umd' or 'system'. +- `jsx` (string) - Specify jsx code generation: 'react' or 'preserve' (TS1.6+). +- `declaration` (boolean) - Generates corresponding .d.ts files. You need to pipe the `dts` streams to save these files. +- `removeComments` (boolean) - Do not emit comments to output. +- `emitDecoratorMetadata` (boolean) - Emit design-time metadate for decorated declarations in source. +- `experimentalAsyncFunctions` (boolean) - Support for ES7-proposed asynchronous functions using the `async`/`await` keywords (TS1.6+). +- `experimentalDecorators` (boolean) - Enables experimental support for ES7 decorators. +- `moduleResolution` (string) - Determine how modules get resolved. Either 'node' for Node.js/io.js style resolution, or 'classic' (default) (TS1.6+). +- `noEmitOnError` (boolean) - Do not emit outputs if any type checking errors were reported. +- `noEmitHelpers` (boolean) - Do not generate custom helper functions like __extends in compiled output. +- `preserveConstEnums` (boolean) - Do not erase const enum declarations in generated code. +- `isolatedModules` (boolean) - Compiles files seperately and doesn't check types, which causes a big speed increase. You have to use gulp-plumber and TypeScript 1.5+. +- `allowJs` (boolean) - Allow JavaScript files to be compiled. +- `rootDir` - Specifies the root directory of input files. Only use to control the output directory structure with `outDir`. + +See the [TypeScript wiki](https://www.typescriptlang.org/docs/handbook/compiler-options.html) for a complete list. +These options are not supported: +- Sourcemap options (`sourceMap`, `inlineSourceMap`, `inlineSources`, `sourceRoot`) - Use [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) instead. +- `watch` - Use `gulp.watch` instead. See the paragraph "Incremental compilation". +- `project` - See "Using `tsconfig.json`". +- Obvious: `help`, `version` + +Basic Usage +---------- +Below is a minimal `gulpfile.js` which will compile all TypeScript file in folder `src` and emit a single output file called `output.js` in `built/local`. To invoke, simple run `gulp`. + +```javascript +var gulp = require('gulp'); +var ts = require('gulp-typescript'); + +gulp.task('default', function () { + return gulp.src('src/**/*.ts') + .pipe(ts({ + noImplicitAny: true, + out: 'output.js' + })) + .pipe(gulp.dest('built/local')); +}); +``` +Another example of `gulpfile.js`. Instead of creating the default task, the file specifies custom named task. To invoke, run `gulp scripts` instead of `gulp`. As a result, the task will generate both JavaScript files and TypeScript definition files (`.d.ts`). +```javascript +var gulp = require('gulp'); +var ts = require('gulp-typescript'); +var merge = require('merge2'); // Requires separate installation + +gulp.task('scripts', function() { + var tsResult = gulp.src('lib/**/*.ts') + .pipe(ts({ + declaration: true + })); + + return merge([ + tsResult.dts.pipe(gulp.dest('release/definitions')), + tsResult.js.pipe(gulp.dest('release/js')) + ]); +}); +``` +`tsResult` is a stream containing the generated JavaScript and definition files. +In many situations, some plugins need to be executed on the JavaScript files. +For these situations, the stream has sub-streams, namely a JavaScript stream (`tsResult.js`) and a definition file stream (`tsResult.dts`). +You need to set the `declaration` option to generate definition files. +If you don't need the definition files, you can use a configuration as seen in the first example. + +Incremental compilation +----------------------- +Instead of calling `ts(options)`, you can create a project first, and then call `tsProject()`. An example: +```javascript +var gulp = require('gulp'); +var ts = require('gulp-typescript'); +var merge = require('merge2'); + +var tsProject = ts.createProject({ + declaration: true +}); + +gulp.task('scripts', function() { + var tsResult = gulp.src('lib/*.ts') + .pipe(tsProject()); + + return merge([ // Merge the two output streams, so this task is finished when the IO of both operations is done. + tsResult.dts.pipe(gulp.dest('release/definitions')), + tsResult.js.pipe(gulp.dest('release/js')) + ]); +}); + +gulp.task('watch', ['scripts'], function() { + gulp.watch('lib/*.ts', ['scripts']); +}); +``` +When you run `gulp watch`, the source will be compiled as usual. Then, when you make a change and save the file, your TypeScript files will be compiled in about half the time. + +You must create the project outside of the task. You can't use the same project in multiple tasks. +Instead, create multiple projects or use a single task to compile your sources. + +Using `tsconfig.json` +------------- +To use `tsconfig.json`, you have to use `ts.createProject`: +```javascript +var tsProject = ts.createProject('tsconfig.json'); +``` +If you want to add or overwrite certain settings in the `tsconfig.json` file, you can use: +```javascript +var tsProject = ts.createProject('tsconfig.json', { noImplicitAny: true }); +``` +The task will look like: +```javascript +gulp.task('scripts', function() { + var tsResult = tsProject.src() // instead of gulp.src(...) + .pipe(tsProject()); + + return tsResult.js.pipe(gulp.dest('release')); +}); +``` + +TypeScript version +------------------ +gulp-typescript isn't restricted to a single TypeScript version. +You can install the latest stable version using `npm install typescript --save-dev` or a nightly `npm install typescript@next --save-dev`. + +You can also use a fork of TypeScript, if it is based on TypeScript 2.x. You can configure this in your gulpfile: +```javascript +[...].pipe(ts({ + typescript: require('my-fork-of-typescript') +})); +``` +Or in combination with a `tsconfig` file: +```javascript +var tsProject = ts.createProject('tsconfig.json', { + typescript: require('my-form-of-typescript') +}); +``` + +Source maps +---------- +Example of ```gulpfile.js``` which will compile typescript to javascript as well as generate +associated sourcemap. + +```javascript +var gulp = require('gulp') +var ts = require('gulp-typescript'); +var sourcemaps = require('gulp-sourcemaps'); + +gulp.task('scripts', function() { + var tsResult = gulp.src('lib/*.ts') + .pipe(sourcemaps.init()) // This means sourcemaps will be generated + .pipe(ts({ + // ... + })); + + return tsResult.js + .pipe( ... ) // You can use other plugins that also support gulp-sourcemaps + .pipe(sourcemaps.write()) // Now the sourcemaps are added to the .js file + .pipe(gulp.dest('release/js')); +}); +``` +For more information, see [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps). + +Reporters +--------- +You can specify a custom reporter as the second argument of the main function, or as the only argument when using a `tsProject`: +```javascript +ts(options, reporter); +tsProject(reporter); +``` +Available reporters are: +- nullReporter (`ts.reporter.nullReporter()`) - Don't report errors +- defaultReporter (`ts.reporter.defaultReporter()`) - Report basic errors to the console +- longReporter (`ts.reporter.longReporter()`) - Extended version of default reporter, intelliJ link functionality + file watcher error highlighting should work using this one +- fullReporter (`ts.reporter.fullReporter(showFullFilename?: boolean)`) - Show full error messages, with source. + +If you want to build a custom reporter, you take a look at `lib/reporter.ts`, that file declares an interface which a reporter should implement. + +Build gulp-typescript +------------ + +1. Clone this repo +2. Execute `npm install` +3. Execute `git submodule update --init` to pull down the TypeScript compiler/services versions used in the test suite. +4. Ensure the gulp CLI is globally installed (`npm install -g gulp`). +5. Execute the tests: `gulp`. + +The plugin uses itself to compile. There are 2 build directories, ```release``` and ```release-2```. ```release``` must always contain a working build. ```release-2``` contains the last build. When you run ```gulp compile```, the build will be saved in the ```release-2``` directory. ```gulp test``` will compile the source to ```release-2```, and then it will run some tests. If these tests give no errors, you can run ```gulp release```. The contents from ```release-2``` will be copied to ```release```. + + +License +------- +gulp-typescript is licensed under the [MIT license](http://opensource.org/licenses/MIT). diff --git a/node_modules/gulp-typescript/release/compiler.d.ts b/node_modules/gulp-typescript/release/compiler.d.ts new file mode 100644 index 000000000..1349e3040 --- /dev/null +++ b/node_modules/gulp-typescript/release/compiler.d.ts @@ -0,0 +1,35 @@ +import * as ts from 'typescript'; +import { File } from './input'; +import { Host } from './host'; +import { ProjectInfo } from './project'; +export interface ICompiler { + prepare(project: ProjectInfo): void; + inputFile(file: File): void; + inputDone(): void; +} +/** + * Compiles a whole project, with full type checking + */ +export declare class ProjectCompiler implements ICompiler { + host: Host; + project: ProjectInfo; + program: ts.Program; + private hasSourceMap; + prepare(project: ProjectInfo): void; + inputFile(file: File): void; + inputDone(): void; + private emitFile(result, currentDirectory, file?); + private reportDiagnostics(diagnostics); + private removeSourceMapComment(content); +} +export declare class FileCompiler implements ICompiler { + host: Host; + project: ProjectInfo; + private output; + private previousOutput; + private compilationResult; + prepare(project: ProjectInfo): void; + private write(file, fileName, diagnostics, content, sourceMap); + inputFile(file: File): void; + inputDone(): void; +} diff --git a/node_modules/gulp-typescript/release/compiler.js b/node_modules/gulp-typescript/release/compiler.js new file mode 100644 index 000000000..f9e22a2b6 --- /dev/null +++ b/node_modules/gulp-typescript/release/compiler.js @@ -0,0 +1,196 @@ +"use strict"; +var path = require('path'); +var input_1 = require('./input'); +var host_1 = require('./host'); +var reporter_1 = require('./reporter'); +var utils = require('./utils'); +/** + * Compiles a whole project, with full type checking + */ +var ProjectCompiler = (function () { + function ProjectCompiler() { + } + ProjectCompiler.prototype.prepare = function (project) { + this.project = project; + this.hasSourceMap = false; + }; + ProjectCompiler.prototype.inputFile = function (file) { + if (file.gulp.sourceMap) + this.hasSourceMap = true; + }; + ProjectCompiler.prototype.inputDone = function () { + var _this = this; + if (!this.project.input.firstSourceFile) { + this.project.output.finish(reporter_1.emptyCompilationResult()); + return; + } + var rootFilenames = this.project.input.getFileNames(true); + if (!this.project.singleOutput) { + if (this.project.options.rootDir === undefined) { + this.project.options.rootDir = utils.getCommonBasePathOfArray(rootFilenames.filter(function (fileName) { return fileName.substr(-5) !== ".d.ts"; }) + .map(function (fileName) { return _this.project.input.getFile(fileName).gulp.base; })); + } + } + this.project.options.sourceMap = this.hasSourceMap; + var currentDirectory = utils.getCommonBasePathOfArray(rootFilenames.map(function (fileName) { return _this.project.input.getFile(fileName).gulp.cwd; })); + this.host = new host_1.Host(this.project.typescript, currentDirectory, this.project.input, this.project.options); + this.program = this.project.typescript.createProgram(rootFilenames, this.project.options, this.host, this.program); + var preEmitDiagnostics = this.project.typescript.getPreEmitDiagnostics(this.program); + var result = reporter_1.emptyCompilationResult(); + result.optionsErrors = this.program.getOptionsDiagnostics().length; + result.syntaxErrors = this.program.getSyntacticDiagnostics().length; + result.globalErrors = this.program.getGlobalDiagnostics().length; + result.semanticErrors = this.program.getSemanticDiagnostics().length; + if (this.project.options.declaration) { + result.declarationErrors = this.program.getDeclarationDiagnostics().length; + } + this.reportDiagnostics(preEmitDiagnostics); + var emitOutput = this.program.emit(); + result.emitErrors = emitOutput.diagnostics.length; + result.emitSkipped = emitOutput.emitSkipped; + if (this.project.singleOutput) { + this.emitFile(result, currentDirectory); + } + else { + // Emit files one by one + for (var _i = 0, _a = this.host.input.getFileNames(true); _i < _a.length; _i++) { + var fileName = _a[_i]; + var file = this.project.input.getFile(fileName); + this.emitFile(result, currentDirectory, file); + } + } + this.project.output.finish(result); + }; + ProjectCompiler.prototype.emitFile = function (result, currentDirectory, file) { + var jsFileName; + var dtsFileName; + var jsContent; + var dtsContent; + var jsMapContent; + var emitOutput = this.program.emit(file && file.ts, function (fileName, content) { + var _a = utils.splitExtension(fileName, ['d.ts']), extension = _a[1]; + switch (extension) { + case 'js': + case 'jsx': + jsFileName = fileName; + jsContent = content; + break; + case 'd.ts': + dtsFileName = fileName; + dtsContent = content; + break; + case 'map': + jsMapContent = content; + break; + } + }); + result.emitErrors += emitOutput.diagnostics.length; + this.reportDiagnostics(emitOutput.diagnostics); + if (emitOutput.emitSkipped) { + result.emitSkipped = true; + } + if (!jsFileName) + return; + var base; + var baseDeclarations; + if (file) { + base = file.gulp.base; + if (this.project.options.outDir) { + var baseRelative = path.relative(this.project.options.rootDir, base); + base = path.join(this.project.options.outDir, baseRelative); + } + baseDeclarations = base; + if (this.project.options.declarationDir) { + var baseRelative = path.relative(this.project.options.rootDir, file.gulp.base); + baseDeclarations = path.join(this.project.options.declarationDir, baseRelative); + } + } + else { + var outFile = this.project.options.outFile || this.project.options.out; + base = jsFileName.substring(0, jsFileName.length - outFile.length); + } + if (jsContent !== undefined) { + if (jsMapContent !== undefined) { + jsContent = this.removeSourceMapComment(jsContent); + } + this.project.output.writeJs(base, jsFileName, jsContent, jsMapContent, file ? file.gulp.cwd : currentDirectory, file); + } + if (dtsContent !== undefined) { + this.project.output.writeDts(baseDeclarations, dtsFileName, dtsContent, file ? file.gulp.cwd : currentDirectory); + } + }; + ProjectCompiler.prototype.reportDiagnostics = function (diagnostics) { + for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) { + var error = diagnostics_1[_i]; + this.project.output.diagnostic(error); + } + }; + ProjectCompiler.prototype.removeSourceMapComment = function (content) { + // By default the TypeScript automaticly inserts a source map comment. + // This should be removed because gulp-sourcemaps takes care of that. + // The comment is always on the last line, so it's easy to remove it + // (But the last line also ends with a \n, so we need to look for the \n before the other) + var index = content.lastIndexOf('\n', content.length - 2); + return content.substring(0, index) + '\n'; + }; + return ProjectCompiler; +}()); +exports.ProjectCompiler = ProjectCompiler; +var FileCompiler = (function () { + function FileCompiler() { + this.output = {}; + this.previousOutput = {}; + this.compilationResult = undefined; + } + FileCompiler.prototype.prepare = function (project) { + this.project = project; + this.project.input.noParse = true; + this.compilationResult = reporter_1.emptyCompilationResult(); + }; + FileCompiler.prototype.write = function (file, fileName, diagnostics, content, sourceMap) { + this.output[file.fileNameNormalized] = { fileName: fileName, diagnostics: diagnostics, content: content, sourceMap: sourceMap }; + for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { + var error = diagnostics_2[_i]; + this.project.output.diagnostic(error); + } + this.compilationResult.transpileErrors += diagnostics.length; + this.project.output.writeJs(file.gulp.base, fileName, content, sourceMap, file.gulp.cwd, file); + }; + FileCompiler.prototype.inputFile = function (file) { + if (file.fileNameNormalized.substr(file.fileNameNormalized.length - 5) === '.d.ts') { + return; // Don't compile definition files + } + if (this.project.input.getFileChange(file.fileNameOriginal).state === input_1.FileChangeState.Equal) { + // Not changed, re-use old file. + var old = this.previousOutput[file.fileNameNormalized]; + this.write(file, old.fileName, old.diagnostics, old.content, old.sourceMap); + return; + } + var diagnostics = []; + var outputString = this.project.typescript.transpile(file.content, this.project.options, file.fileNameOriginal, diagnostics); + var index = outputString.lastIndexOf('\n'); + var mapString = outputString.substring(index + 1); + if (mapString.substring(0, 1) === '\r') + mapString = mapString.substring(1); + var start = '//# sourceMappingURL=data:application/json;base64,'; + if (mapString.substring(0, start.length) !== start) { + console.error('Couldn\'t read the sourceMap generated by TypeScript. This is likely an issue with gulp-typescript.'); + return; + } + mapString = mapString.substring(start.length); + var map = JSON.parse(new Buffer(mapString, 'base64').toString()); + // TODO: Set paths correctly + // map.sourceRoot = path.resolve(file.gulp.cwd, file.gulp.base); + // map.sources[0] = path.relative(map.sourceRoot, file.gulp.path); + var fileNameExtensionless = utils.splitExtension(file.fileNameOriginal)[0]; + var _a = utils.splitExtension(map.file), extension = _a[1]; // js or jsx + this.write(file, fileNameExtensionless + '.' + extension, diagnostics, outputString.substring(0, index), JSON.stringify(map)); + }; + FileCompiler.prototype.inputDone = function () { + this.project.output.finish(this.compilationResult); + this.previousOutput = this.output; + this.output = {}; + }; + return FileCompiler; +}()); +exports.FileCompiler = FileCompiler; diff --git a/node_modules/gulp-typescript/release/file.js b/node_modules/gulp-typescript/release/file.js new file mode 100644 index 000000000..61eeff7dc --- /dev/null +++ b/node_modules/gulp-typescript/release/file.js @@ -0,0 +1,149 @@ +var path = require('path'); +var tsApi = require('./tsapi'); +var utils = require('./utils'); +(function (FileChangeState) { + FileChangeState[FileChangeState["New"] = 0] = "New"; + FileChangeState[FileChangeState["Equal"] = 1] = "Equal"; + FileChangeState[FileChangeState["Modified"] = 2] = "Modified"; + FileChangeState[FileChangeState["Deleted"] = 3] = "Deleted"; + FileChangeState[FileChangeState["NotFound"] = 4] = "NotFound"; +})(exports.FileChangeState || (exports.FileChangeState = {})); +var FileChangeState = exports.FileChangeState; +(function (FileKind) { + FileKind[FileKind["Source"] = 0] = "Source"; + FileKind[FileKind["Config"] = 1] = "Config"; +})(exports.FileKind || (exports.FileKind = {})); +var FileKind = exports.FileKind; +var File; +(function (File) { + function fromContent(fileName, content) { + var kind = FileKind.Source; + if (path.extname(fileName).toLowerCase() === 'json') + kind = FileKind.Config; + return { + fileNameNormalized: utils.normalizePath(fileName), + fileNameOriginal: fileName, + content: content, + kind: kind + }; + } + File.fromContent = fromContent; + function fromGulp(file) { + var str = file.contents.toString('utf8'); + var data = fromContent(file.path, str); + data.gulp = file; + return data; + } + File.fromGulp = fromGulp; + function equal(a, b) { + if (a === undefined || b === undefined) + return a === b; // They could be both undefined. + return (a.fileNameOriginal === b.fileNameOriginal) + && (a.content === b.content); + } + File.equal = equal; + function getChangeState(previous, current) { + if (previous === undefined) { + return current === undefined ? FileChangeState.NotFound : FileChangeState.New; + } + if (current === undefined) { + return FileChangeState.Deleted; + } + if (equal(previous, current)) { + return FileChangeState.Equal; + } + return FileChangeState.Modified; + } + File.getChangeState = getChangeState; +})(File = exports.File || (exports.File = {})); +var FileDictionary = (function () { + function FileDictionary(typescript) { + this.files = {}; + this.typescript = typescript; + } + FileDictionary.prototype.addGulp = function (gFile) { + this.addFile(File.fromGulp(gFile)); + }; + FileDictionary.prototype.addContent = function (fileName, content) { + this.addFile(File.fromContent(fileName, content)); + }; + FileDictionary.prototype.addFile = function (file) { + if (file.kind === FileKind.Source) + this.initTypeScriptSourceFile(file); + this.files[file.fileNameNormalized] = file; + }; + FileDictionary.prototype.getFile = function (name) { + return this.files[utils.normalizePath(name)]; + }; + FileDictionary.prototype.getGulpFileNames = function (onlyGulp) { + if (onlyGulp === void 0) { onlyGulp = false; } + var fileNames = []; + for (var fileName in this.files) { + if (!this.files.hasOwnProperty(fileName)) + continue; + var file = this.files[fileName]; + if (onlyGulp && !file.gulp) + continue; + fileNames.push(file.fileNameOriginal); + } + return fileNames; + }; + return FileDictionary; +})(); +exports.FileDictionary = FileDictionary; +var FileCache = (function () { + function FileCache(typescript, options) { + this.previous = undefined; + this.version = 0; + this.typescript = typescript; + this.options = options; + this.createDictionary(); + } + FileCache.prototype.addGulp = function (gFile) { + this.current.addGulp(gFile); + }; + FileCache.prototype.addContent = function (fileName, content) { + this.current.addContent(fileName, content); + }; + FileCache.prototype.reset = function () { + this.version++; + this.previous = this.current; + this.createDictionary(); + }; + FileCache.prototype.createDictionary = function () { + var _this = this; + this.current = new FileDictionary(this.typescript); + this.current.initTypeScriptSourceFile = function (file) { return _this.initTypeScriptSourceFile(file); }; + }; + FileCache.prototype.initTypeScriptSourceFile = function (file) { + if (this.previous) { + var previous = this.previous.getFile(file.fileNameOriginal); + if (File.equal(previous, file)) { + file.ts = previous.ts; // Re-use previous source file. + return; + } + } + file.ts = tsApi.createSourceFile(this.typescript, file.fileNameOriginal, file.content, this.options.target, this.version + ''); + }; + FileCache.prototype.getFile = function (name) { + return this.current.getFile(name); + }; + FileCache.prototype.getFileChange = function (name) { + var previous; + if (this.previous) { + previous = this.previous.getFile(name); + } + var current = this.current.getFile(name); + return { + previous: previous, + current: current, + state: File.getChangeState(previous, current) + }; + }; + FileCache.prototype.getFileNames = function (onlyGulp) { + if (onlyGulp === void 0) { onlyGulp = false; } + return this.current.getGulpFileNames(onlyGulp); + }; + return FileCache; +})(); +exports.FileCache = FileCache; diff --git a/node_modules/gulp-typescript/release/filter.d.ts b/node_modules/gulp-typescript/release/filter.d.ts new file mode 100644 index 000000000..b6084d11f --- /dev/null +++ b/node_modules/gulp-typescript/release/filter.d.ts @@ -0,0 +1,12 @@ +import { Project } from './project'; +import * as main from './main'; +export declare class Filter { + project: Project; + constructor(project: Project, filters: main.FilterSettings); + private mapFilenamesToFiles(filenames); + private getFile(searchFileName); + private referencedFrom; + private referencedFromAll; + match(fileName: string): boolean; + private matchReferencedFrom(filename, file); +} diff --git a/node_modules/gulp-typescript/release/filter.js b/node_modules/gulp-typescript/release/filter.js new file mode 100644 index 000000000..ddd732377 --- /dev/null +++ b/node_modules/gulp-typescript/release/filter.js @@ -0,0 +1,84 @@ +"use strict"; +var tsApi = require('./tsapi'); +var path = require('path'); +var utils = require('./utils'); +var Filter = (function () { + function Filter(project, filters) { + var _this = this; + this.referencedFrom = undefined; + this.referencedFromAll = undefined; + this.project = project; + if (filters.referencedFrom !== undefined) { + this.referencedFrom = this.mapFilenamesToFiles(filters.referencedFrom); + this.referencedFromAll = []; + var addReference_1 = function (file) { + if (_this.referencedFromAll.indexOf(file.fileNameNormalized) !== -1) + return; + _this.referencedFromAll.push(file.fileNameNormalized); + for (var i = 0; i < file.ts.referencedFiles.length; i++) { + var ref = tsApi.getFileName(file.ts.referencedFiles[i]); + ref = utils.normalizePath(path.join(path.dirname(tsApi.getFileName(file.ts)), ref)); + var refFile = _this.project.input.getFile(ref); + if (refFile) + addReference_1(refFile); + } + }; + for (var i = 0; i < this.referencedFrom.length; i++) { + addReference_1(this.referencedFrom[i]); + } + } + } + Filter.prototype.mapFilenamesToFiles = function (filenames) { + var files = []; + for (var i = 0; i < filenames.length; i++) { + var file = this.getFile(filenames[i]); + if (file === undefined) { + console.log('gulp-typescript: Could not find file ' + filenames[i]); + } + else { + files.push(file); + } + } + return files; + }; + Filter.prototype.getFile = function (searchFileName) { + var fileNames = this.project.input.getFileNames(true); + for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { + var fileName = fileNames_1[_i]; + var file = this.project.input.getFile(fileName); + if (!file || !file.gulp) + continue; + var base = path.resolve(process.cwd(), file.gulp.base) + '/'; + if (path.resolve(base, searchFileName) === file.gulp.path) { + return file; + } + } + return undefined; + }; + Filter.prototype.match = function (fileName) { + var fileNameExtensionless = utils.splitExtension(fileName)[0]; + var outputFile = this.project.output.files[utils.normalizePath(fileNameExtensionless)]; + var file; + if (!outputFile) { + file = this.project.input.getFile(fileName); + if (!file) { + console.log('gulp-typescript: Could not find file ' + fileName + '. Make sure you don\'t rename a file before you pass it to ts.filter()'); + return false; + } + } + else { + file = outputFile.original; + } + if (this.referencedFrom !== undefined) { + if (!this.matchReferencedFrom(fileName, file)) { + return false; + } + } + return true; + }; + Filter.prototype.matchReferencedFrom = function (filename, file) { + return this.referencedFromAll.indexOf(file.fileNameNormalized) !== -1; + }; + return Filter; +}()); +exports.Filter = Filter; diff --git a/node_modules/gulp-typescript/release/host.d.ts b/node_modules/gulp-typescript/release/host.d.ts new file mode 100644 index 000000000..fb6523fb1 --- /dev/null +++ b/node_modules/gulp-typescript/release/host.d.ts @@ -0,0 +1,22 @@ +import * as ts from 'typescript'; +import { FileCache } from './input'; +export declare class Host implements ts.CompilerHost { + typescript: typeof ts; + fallback: ts.CompilerHost; + currentDirectory: string; + input: FileCache; + constructor(typescript: typeof ts, currentDirectory: string, input: FileCache, options: ts.CompilerOptions); + getNewLine(): string; + useCaseSensitiveFileNames(): boolean; + getCurrentDirectory: () => string; + getCanonicalFileName(filename: string): string; + getDefaultLibFileName(options: ts.CompilerOptions): string; + getDefaultLibLocation(): string; + writeFile: (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) => void; + fileExists: (fileName: string) => boolean; + readFile: (fileName: string) => string; + getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void) => ts.SourceFile; + realpath: (path: string) => string; + getDirectories: (path: string) => string[]; + directoryExists: (path: string) => boolean; +} diff --git a/node_modules/gulp-typescript/release/host.js b/node_modules/gulp-typescript/release/host.js new file mode 100644 index 000000000..0f43f9e91 --- /dev/null +++ b/node_modules/gulp-typescript/release/host.js @@ -0,0 +1,54 @@ +"use strict"; +var utils = require('./utils'); +var Host = (function () { + function Host(typescript, currentDirectory, input, options) { + var _this = this; + this.getCurrentDirectory = function () { + return _this.currentDirectory; + }; + this.writeFile = function (fileName, data, writeByteOrderMark, onError) { }; + this.fileExists = function (fileName) { + var sourceFile = _this.input.getFile(fileName); + if (sourceFile) + return true; + return _this.fallback.fileExists(fileName); + }; + this.readFile = function (fileName) { + var sourceFile = _this.input.getFile(fileName); + if (sourceFile) + return sourceFile.content; + return _this.fallback.readFile(fileName); + }; + this.getSourceFile = function (fileName, languageVersion, onError) { + // TODO: Cache lib.d.ts files between compilations + var sourceFile = _this.input.getFile(fileName); + if (sourceFile) + return sourceFile.ts; + return _this.fallback.getSourceFile(fileName, languageVersion, onError); + }; + this.realpath = function (path) { return _this.fallback.realpath(path); }; + this.getDirectories = function (path) { return _this.fallback.getDirectories(path); }; + this.directoryExists = function (path) { return _this.fallback.directoryExists(path); }; + this.typescript = typescript; + this.fallback = typescript.createCompilerHost(options); + this.currentDirectory = currentDirectory; + this.input = input; + } + Host.prototype.getNewLine = function () { + return '\n'; + }; + Host.prototype.useCaseSensitiveFileNames = function () { + return false; + }; + Host.prototype.getCanonicalFileName = function (filename) { + return utils.normalizePath(filename); + }; + Host.prototype.getDefaultLibFileName = function (options) { + return this.fallback.getDefaultLibFileName(options); + }; + Host.prototype.getDefaultLibLocation = function () { + return this.fallback.getDefaultLibLocation(); + }; + return Host; +}()); +exports.Host = Host; diff --git a/node_modules/gulp-typescript/release/input.d.ts b/node_modules/gulp-typescript/release/input.d.ts new file mode 100644 index 000000000..8aef76867 --- /dev/null +++ b/node_modules/gulp-typescript/release/input.d.ts @@ -0,0 +1,69 @@ +import * as ts from 'typescript'; +import * as utils from './utils'; +import { VinylFile } from './types'; +export declare enum FileChangeState { + New = 0, + Equal = 1, + Modified = 2, + Deleted = 3, + NotFound = 4, +} +export declare enum FileKind { + Source = 0, + Config = 1, +} +export interface FileChange { + previous: File; + current: File; + state: FileChangeState; +} +export interface File { + gulp?: VinylFile; + fileNameNormalized: string; + fileNameOriginal: string; + content: string; + kind: FileKind; + ts?: ts.SourceFile; +} +export declare module File { + function fromContent(fileName: string, content: string): File; + function fromGulp(file: VinylFile): File; + function equal(a: File, b: File): boolean; + function getChangeState(previous: File, current: File): FileChangeState; +} +export declare class FileDictionary { + files: utils.Map<File>; + firstSourceFile: File; + typescript: typeof ts; + constructor(typescript: typeof ts); + addGulp(gFile: VinylFile): File; + addContent(fileName: string, content: string): File; + private addFile(file); + getFile(name: string): File; + initTypeScriptSourceFile: (file: File) => void; + getFileNames(onlyGulp?: boolean): string[]; + private getSourceFileNames(onlyGulp?); + commonBasePath: string; + commonSourceDirectory: string; +} +export declare class FileCache { + previous: FileDictionary; + current: FileDictionary; + options: ts.CompilerOptions; + noParse: boolean; + typescript: typeof ts; + version: number; + constructor(typescript: typeof ts, options: ts.CompilerOptions); + addGulp(gFile: VinylFile): File; + addContent(fileName: string, content: string): File; + reset(): void; + private createDictionary(); + private initTypeScriptSourceFile(file); + getFile(name: string): File; + getFileChange(name: string): FileChange; + getFileNames(onlyGulp?: boolean): string[]; + firstSourceFile: File; + commonBasePath: string; + commonSourceDirectory: string; + isChanged(onlyGulp?: boolean): boolean; +} diff --git a/node_modules/gulp-typescript/release/input.js b/node_modules/gulp-typescript/release/input.js new file mode 100644 index 000000000..15f0ece14 --- /dev/null +++ b/node_modules/gulp-typescript/release/input.js @@ -0,0 +1,245 @@ +"use strict"; +var path = require('path'); +var utils = require('./utils'); +(function (FileChangeState) { + FileChangeState[FileChangeState["New"] = 0] = "New"; + FileChangeState[FileChangeState["Equal"] = 1] = "Equal"; + FileChangeState[FileChangeState["Modified"] = 2] = "Modified"; + FileChangeState[FileChangeState["Deleted"] = 3] = "Deleted"; + FileChangeState[FileChangeState["NotFound"] = 4] = "NotFound"; +})(exports.FileChangeState || (exports.FileChangeState = {})); +var FileChangeState = exports.FileChangeState; +(function (FileKind) { + FileKind[FileKind["Source"] = 0] = "Source"; + FileKind[FileKind["Config"] = 1] = "Config"; +})(exports.FileKind || (exports.FileKind = {})); +var FileKind = exports.FileKind; +var File; +(function (File) { + function fromContent(fileName, content) { + var kind = FileKind.Source; + if (path.extname(fileName).toLowerCase() === 'json') + kind = FileKind.Config; + return { + fileNameNormalized: utils.normalizePath(fileName), + fileNameOriginal: fileName, + content: content, + kind: kind + }; + } + File.fromContent = fromContent; + function fromGulp(file) { + var str = file.contents.toString('utf8'); + var data = fromContent(file.path, str); + data.gulp = file; + return data; + } + File.fromGulp = fromGulp; + function equal(a, b) { + if (a === undefined || b === undefined) + return a === b; // They could be both undefined. + return (a.fileNameOriginal === b.fileNameOriginal) + && (a.content === b.content); + } + File.equal = equal; + function getChangeState(previous, current) { + if (previous === undefined) { + return current === undefined ? FileChangeState.NotFound : FileChangeState.New; + } + if (current === undefined) { + return FileChangeState.Deleted; + } + if (equal(previous, current)) { + return FileChangeState.Equal; + } + return FileChangeState.Modified; + } + File.getChangeState = getChangeState; +})(File = exports.File || (exports.File = {})); +var FileDictionary = (function () { + function FileDictionary(typescript) { + this.files = {}; + this.firstSourceFile = undefined; + this.typescript = typescript; + } + FileDictionary.prototype.addGulp = function (gFile) { + return this.addFile(File.fromGulp(gFile)); + }; + FileDictionary.prototype.addContent = function (fileName, content) { + return this.addFile(File.fromContent(fileName, content)); + }; + FileDictionary.prototype.addFile = function (file) { + if (file.kind === FileKind.Source) { + this.initTypeScriptSourceFile(file); + if (!this.firstSourceFile) + this.firstSourceFile = file; + } + this.files[file.fileNameNormalized] = file; + return file; + }; + FileDictionary.prototype.getFile = function (name) { + return this.files[utils.normalizePath(name)]; + }; + FileDictionary.prototype.getFileNames = function (onlyGulp) { + if (onlyGulp === void 0) { onlyGulp = false; } + var fileNames = []; + for (var fileName in this.files) { + if (!this.files.hasOwnProperty(fileName)) + continue; + var file = this.files[fileName]; + if (onlyGulp && !file.gulp) + continue; + fileNames.push(file.fileNameOriginal); + } + return fileNames; + }; + FileDictionary.prototype.getSourceFileNames = function (onlyGulp) { + var fileNames = this.getFileNames(onlyGulp); + var sourceFileNames = fileNames + .filter(function (fileName) { return fileName.substr(fileName.length - 5).toLowerCase() !== '.d.ts'; }); + if (sourceFileNames.length === 0) { + // Only definition files, so we will calculate the common base path based on the + // paths of the definition files. + return fileNames; + } + return sourceFileNames; + }; + Object.defineProperty(FileDictionary.prototype, "commonBasePath", { + get: function () { + var _this = this; + var fileNames = this.getSourceFileNames(true); + return utils.getCommonBasePathOfArray(fileNames.map(function (fileName) { + var file = _this.files[utils.normalizePath(fileName)]; + return path.resolve(process.cwd(), file.gulp.base); + })); + }, + // This empty setter will prevent that TS emits 'readonly' modifier. + // 'readonly' is not supported in current stable release. + set: function (value) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(FileDictionary.prototype, "commonSourceDirectory", { + get: function () { + var _this = this; + var fileNames = this.getSourceFileNames(); + return utils.getCommonBasePathOfArray(fileNames.map(function (fileName) { + var file = _this.files[utils.normalizePath(fileName)]; + return path.dirname(file.fileNameNormalized); + })); + }, + // This empty setter will prevent that TS emits 'readonly' modifier. + // 'readonly' is not supported in current stable release. + set: function (value) { }, + enumerable: true, + configurable: true + }); + return FileDictionary; +}()); +exports.FileDictionary = FileDictionary; +var FileCache = (function () { + function FileCache(typescript, options) { + this.previous = undefined; + this.noParse = false; // true when using a file based compiler. + this.version = 0; + this.typescript = typescript; + this.options = options; + this.createDictionary(); + } + FileCache.prototype.addGulp = function (gFile) { + return this.current.addGulp(gFile); + }; + FileCache.prototype.addContent = function (fileName, content) { + return this.current.addContent(fileName, content); + }; + FileCache.prototype.reset = function () { + this.version++; + this.previous = this.current; + this.createDictionary(); + }; + FileCache.prototype.createDictionary = function () { + var _this = this; + this.current = new FileDictionary(this.typescript); + this.current.initTypeScriptSourceFile = function (file) { return _this.initTypeScriptSourceFile(file); }; + }; + FileCache.prototype.initTypeScriptSourceFile = function (file) { + if (this.noParse) + return; + if (this.previous) { + var previous = this.previous.getFile(file.fileNameOriginal); + if (File.equal(previous, file)) { + file.ts = previous.ts; // Re-use previous source file. + return; + } + } + file.ts = this.typescript.createSourceFile(file.fileNameOriginal, file.content, this.options.target); + }; + FileCache.prototype.getFile = function (name) { + return this.current.getFile(name); + }; + FileCache.prototype.getFileChange = function (name) { + var previous; + if (this.previous) { + previous = this.previous.getFile(name); + } + var current = this.current.getFile(name); + return { + previous: previous, + current: current, + state: File.getChangeState(previous, current) + }; + }; + FileCache.prototype.getFileNames = function (onlyGulp) { + if (onlyGulp === void 0) { onlyGulp = false; } + return this.current.getFileNames(onlyGulp); + }; + Object.defineProperty(FileCache.prototype, "firstSourceFile", { + get: function () { + return this.current.firstSourceFile; + }, + // This empty setter will prevent that TS emits 'readonly' modifier. + // 'readonly' is not supported in current stable release. + set: function (value) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(FileCache.prototype, "commonBasePath", { + get: function () { + return this.current.commonBasePath; + }, + set: function (value) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(FileCache.prototype, "commonSourceDirectory", { + get: function () { + return this.current.commonSourceDirectory; + }, + set: function (value) { }, + enumerable: true, + configurable: true + }); + FileCache.prototype.isChanged = function (onlyGulp) { + if (onlyGulp === void 0) { onlyGulp = false; } + if (!this.previous) + return true; + var files = this.getFileNames(onlyGulp); + var oldFiles = this.previous.getFileNames(onlyGulp); + if (files.length !== oldFiles.length) + return true; + for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { + var fileName = files_1[_i]; + if (oldFiles.indexOf(fileName) === -1) + return true; + } + for (var _a = 0, files_2 = files; _a < files_2.length; _a++) { + var fileName = files_2[_a]; + var change = this.getFileChange(fileName); + if (change.state !== FileChangeState.Equal) + return true; + } + return false; + }; + return FileCache; +}()); +exports.FileCache = FileCache; diff --git a/node_modules/gulp-typescript/release/main.d.ts b/node_modules/gulp-typescript/release/main.d.ts new file mode 100644 index 000000000..e67e54bb9 --- /dev/null +++ b/node_modules/gulp-typescript/release/main.d.ts @@ -0,0 +1,46 @@ +/// <reference path="../typings/tsd.d.ts" /> +import * as ts from 'typescript'; +import * as _project from './project'; +import * as _reporter from './reporter'; +declare function compile(): compile.CompileStream; +declare function compile(proj: _project.Project, theReporter?: _reporter.Reporter): compile.CompileStream; +declare function compile(settings: compile.Settings, theReporter?: _reporter.Reporter): compile.CompileStream; +declare module compile { + interface Settings { + out?: string; + outFile?: string; + outDir?: string; + allowNonTsExtensions?: boolean; + charset?: string; + codepage?: number; + declaration?: boolean; + locale?: string; + mapRoot?: string; + noEmitOnError?: boolean; + noImplicitAny?: boolean; + noLib?: boolean; + noLibCheck?: boolean; + noResolve?: boolean; + preserveConstEnums?: boolean; + removeComments?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: string | ts.ScriptTarget; + module?: string | ts.ModuleKind; + moduleResolution?: string | number; + jsx?: string | number; + declarationFiles?: boolean; + noExternalResolve?: boolean; + sortOutput?: boolean; + typescript?: typeof ts; + isolatedModules?: boolean; + rootDir?: string; + sourceRoot?: string; + } + type Project = _project.Project; + type CompileStream = _project.ICompileStream; + export import reporter = _reporter; + function createProject(settings?: Settings): any; + function createProject(tsConfigFileName: string, settings?: Settings): any; + function filter(...args: any[]): void; +} +export = compile; diff --git a/node_modules/gulp-typescript/release/main.js b/node_modules/gulp-typescript/release/main.js new file mode 100644 index 000000000..501efd5b7 --- /dev/null +++ b/node_modules/gulp-typescript/release/main.js @@ -0,0 +1,137 @@ +/// <reference path="../typings/tsd.d.ts" /> +"use strict"; +var fs = require('fs'); +var path = require('path'); +var gutil = require('gulp-util'); +var _project = require('./project'); +var utils = require('./utils'); +var _reporter = require('./reporter'); +function compile(param, theReporter) { + if (arguments.length >= 3) { + deprecate("Reporter are now passed as the second argument", "remove the second argument", "Filters have been removed as of gulp-typescript 3.0.\nThe reporter is now passed as the second argument instead of the third argument."); + } + var proj; + if (typeof param === "function") { + proj = param; + if (arguments.length >= 2) { + deprecate("ts(tsProject, ...) has been deprecated", "use .pipe(tsProject(reporter)) instead", "As of gulp-typescript 3.0, .pipe(ts(tsProject, ...)) should be written as .pipe(tsProject(reporter))."); + } + else { + deprecate("ts(tsProject) has been deprecated", "use .pipe(tsProject(reporter)) instead", "As of gulp-typescript 3.0, .pipe(ts(tsProject)) should be written as .pipe(tsProject())."); + } + } + else { + proj = compile.createProject(param || {}); + } + return proj(theReporter); +} +function getTypeScript(typescript) { + if (typescript) + return typescript; + try { + return require('typescript'); + } + catch (e) { + deprecate("TypeScript not installed", "install with `npm install typescript --save-dev`", "As of gulp-typescript 3.0, TypeScript isn't bundled with gulp-typescript any more.\nInstall the latest stable version with `npm install typescript --save-dev`\nor a nightly with `npm install typescript@next --save-dev`"); + throw new Error("TypeScript not installed"); + } +} +function getCompilerOptions(settings, projectPath, configFileName) { + var typescript = getTypeScript(settings.typescript); + if (settings.sourceRoot !== undefined) { + console.warn('gulp-typescript: sourceRoot isn\'t supported any more. Use sourceRoot option of gulp-sourcemaps instead.'); + } + if (settings.noExternalResolve !== undefined) { + deprecate("noExternalResolve is deprecated", "use noResolve instead", "The non-standard option noExternalResolve has been removed as of gulp-typescript 3.0.\nUse noResolve instead."); + } + if (settings.sortOutput !== undefined) { + deprecate("sortOutput is deprecated", "your project might work without it", "The non-standard option sortOutput has been removed as of gulp-typescript 3.0.\nYour project will probably compile without this option.\nOtherwise, if you're using gulp-concat, you should remove gulp-concat and use the outFile option instead."); + } + // Copy settings and remove several options + var newSettings = {}; + for (var _i = 0, _a = Object.keys(settings); _i < _a.length; _i++) { + var option = _a[_i]; + if (option === 'declarationFiles') { + newSettings.declaration = settings.declarationFiles; + continue; + } + if (option === 'noExternalResolve' || + option === 'sortOutput' || + option === 'typescript' || + option === 'sourceMap' || + option === 'inlineSourceMap') + continue; + newSettings[option] = settings[option]; + } + var result = typescript.convertCompilerOptionsFromJson(newSettings, projectPath, configFileName); + var reporter = _reporter.defaultReporter(); + for (var _b = 0, _c = result.errors; _b < _c.length; _b++) { + var error = _c[_b]; + reporter.error(utils.getError(error, typescript), typescript); + } + result.options.sourceMap = true; + result.options.suppressOutputPathCheck = true; + return result.options; +} +var compile; +(function (compile) { + compile.reporter = _reporter; + function createProject(fileNameOrSettings, settings) { + var tsConfigFileName = undefined; + var tsConfigContent = undefined; + var projectDirectory = process.cwd(); + if (fileNameOrSettings !== undefined) { + if (typeof fileNameOrSettings === 'string') { + tsConfigFileName = path.resolve(process.cwd(), fileNameOrSettings); + projectDirectory = path.dirname(tsConfigFileName); + // Load file and strip BOM, since JSON.parse fails to parse if there's a BOM present + var tsConfigText = fs.readFileSync(tsConfigFileName).toString(); + var typescript = getTypeScript(settings && settings.typescript); + var tsConfig = typescript.parseConfigFileTextToJson(tsConfigFileName, tsConfigText); + tsConfigContent = tsConfig.config || {}; + if (tsConfig.error) { + console.log(tsConfig.error.messageText); + } + var newSettings = {}; + if (tsConfigContent.compilerOptions) { + for (var _i = 0, _a = Object.keys(tsConfigContent.compilerOptions); _i < _a.length; _i++) { + var key = _a[_i]; + newSettings[key] = tsConfigContent.compilerOptions[key]; + } + } + if (settings) { + for (var _b = 0, _c = Object.keys(settings); _b < _c.length; _b++) { + var key = _c[_b]; + newSettings[key] = settings[key]; + } + } + settings = newSettings; + } + else { + settings = fileNameOrSettings; + } + } + var project = _project.setupProject(projectDirectory, tsConfigContent, getCompilerOptions(settings, projectDirectory, tsConfigFileName), getTypeScript(settings.typescript)); + return project; + } + compile.createProject = createProject; + function filter() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + deprecate('ts.filter() is deprecated', 'soon you can use tsProject.resolve()', 'Filters have been removed as of gulp-typescript 3.0.\nSoon tsProject.resolve() will be available as an alternative.\nSee https://github.com/ivogabe/gulp-typescript/issues/190.'); + } + compile.filter = filter; +})(compile || (compile = {})); +function deprecate(title, alternative, description) { + console.log(gutil.colors.red('gulp-typescript').toString() + + gutil.colors.gray(': ') + + title + + gutil.colors.gray(' - ') + + alternative); + if (description) + console.log(' ' + gutil.colors.gray(description.replace(/\n/g, '\n '))); + console.log(' ' + gutil.colors.gray('More information: ' + gutil.colors.underline('http://dev.ivogabe.com/gulp-typescript-3/'))); +} +module.exports = compile; diff --git a/node_modules/gulp-typescript/release/output.d.ts b/node_modules/gulp-typescript/release/output.d.ts new file mode 100644 index 000000000..7109b62f3 --- /dev/null +++ b/node_modules/gulp-typescript/release/output.d.ts @@ -0,0 +1,20 @@ +import * as stream from 'stream'; +import * as ts from 'typescript'; +import * as input from './input'; +import * as reporter from './reporter'; +import * as project from './project'; +export declare class Output { + constructor(_project: project.ProjectInfo, streamFull: stream.Readable, streamJs: stream.Readable, streamDts: stream.Readable); + project: project.ProjectInfo; + result: reporter.CompilationResult; + streamFull: stream.Readable; + streamJs: stream.Readable; + streamDts: stream.Readable; + writeJs(base: string, fileName: string, content: string, sourceMapContent: string, cwd: string, original: input.File): void; + writeDts(base: string, fileName: string, content: string, cwd: string): void; + private applySourceMap(sourceMapContent, original, output); + finish(result: reporter.CompilationResult): void; + private getError(info); + diagnostic(info: ts.Diagnostic): void; + error(error: reporter.TypeScriptError): void; +} diff --git a/node_modules/gulp-typescript/release/output.js b/node_modules/gulp-typescript/release/output.js new file mode 100644 index 000000000..679c5b3ce --- /dev/null +++ b/node_modules/gulp-typescript/release/output.js @@ -0,0 +1,107 @@ +"use strict"; +var path = require('path'); +var sourceMap = require('source-map'); +var gutil = require('gulp-util'); +var utils = require('./utils'); +var Output = (function () { + function Output(_project, streamFull, streamJs, streamDts) { + this.project = _project; + this.streamFull = streamFull; + this.streamJs = streamJs; + this.streamDts = streamDts; + } + Output.prototype.writeJs = function (base, fileName, content, sourceMapContent, cwd, original) { + var file = new gutil.File({ + path: fileName, + contents: new Buffer(content), + cwd: cwd, + base: base + }); + var appliedSourceMap = this.applySourceMap(sourceMapContent, original, file); + if (appliedSourceMap) + file.sourceMap = JSON.parse(appliedSourceMap); + this.streamFull.push(file); + this.streamJs.push(file); + }; + Output.prototype.writeDts = function (base, fileName, content, cwd) { + var file = new gutil.File({ + path: fileName, + contents: new Buffer(content), + cwd: cwd, + base: base + }); + this.streamFull.push(file); + this.streamDts.push(file); + }; + Output.prototype.applySourceMap = function (sourceMapContent, original, output) { + var _this = this; + if (sourceMapContent === undefined) + return undefined; + var map = JSON.parse(sourceMapContent); + var directory = path.dirname(output.path); + // gulp-sourcemaps docs: + // paths in the generated source map (`file` and `sources`) are relative to `file.base` (e.g. use `file.relative`). + map.file = output.relative; + map.sources = map.sources.map(relativeToOutput); + delete map.sourceRoot; + var generator = sourceMap.SourceMapGenerator.fromSourceMap(new sourceMap.SourceMapConsumer(map)); + var sourceMapOrigins = this.project.singleOutput + ? this.project.input.getFileNames(true).map(function (fName) { return _this.project.input.getFile(fName); }) + : [original]; + for (var _i = 0, sourceMapOrigins_1 = sourceMapOrigins; _i < sourceMapOrigins_1.length; _i++) { + var sourceFile = sourceMapOrigins_1[_i]; + if (!sourceFile || !sourceFile.gulp || !sourceFile.gulp.sourceMap) + continue; + var inputOriginalMap = sourceFile.gulp.sourceMap; + var inputMap = typeof inputOriginalMap === 'object' ? inputOriginalMap : JSON.parse(inputOriginalMap); + // We should only apply the input mappings if the input mapping isn't empty, + // since `generator.applySourceMap` has a really bad performance on big inputs. + if (inputMap.mappings !== '') { + var consumer = new sourceMap.SourceMapConsumer(inputMap); + generator.applySourceMap(consumer, sourceFile.fileNameOriginal, sourceFile.gulp.base); + } + if (!inputMap.sources || !inputMap.sourcesContent) + continue; + for (var i = 0; i < inputMap.sources.length; i++) { + var absolute = path.resolve(sourceFile.gulp.base, inputMap.sources[i]); + var relative = path.relative(output.base, absolute); + generator.setSourceContent(relative, inputMap.sourcesContent[i]); + } + } + return generator.toString(); + function relativeToOutput(fileName) { + var absolute = path.resolve(directory, fileName.replace(/\\/g, '/')); + return path.relative(output.base, absolute); + } + }; + Output.prototype.finish = function (result) { + this.result = result; + if (this.project.reporter.finish) + this.project.reporter.finish(result); + this.streamFull.emit('finish'); + this.streamJs.emit('finish'); + this.streamDts.emit('finish'); + this.streamFull.push(null); + this.streamJs.push(null); + this.streamDts.push(null); + }; + Output.prototype.getError = function (info) { + var fileName = info.file && info.file.fileName; + var file = fileName && this.project.input.getFile(fileName); + return utils.getError(info, this.project.typescript, file); + }; + Output.prototype.diagnostic = function (info) { + this.error(this.getError(info)); + }; + Output.prototype.error = function (error) { + if (!error) + return; + // call reporter callback + if (this.project.reporter.error) + this.project.reporter.error(error, this.project.typescript); + // & emit the error on the stream. + this.streamFull.emit('error', error); + }; + return Output; +}()); +exports.Output = Output; diff --git a/node_modules/gulp-typescript/release/project.d.ts b/node_modules/gulp-typescript/release/project.d.ts new file mode 100644 index 000000000..a6d331cd9 --- /dev/null +++ b/node_modules/gulp-typescript/release/project.d.ts @@ -0,0 +1,29 @@ +import * as stream from 'stream'; +import * as ts from 'typescript'; +import { Reporter } from './reporter'; +import { FileCache } from './input'; +import { Output } from './output'; +import { ICompiler } from './compiler'; +import { TsConfig } from './types'; +export interface Project { + (reporter?: Reporter): ICompileStream; + src(this: Project): NodeJS.ReadWriteStream; + readonly typescript?: typeof ts; + readonly projectDirectory: string; + readonly config: TsConfig; + readonly options: ts.CompilerOptions; +} +export interface ProjectInfo { + input: FileCache; + output: Output; + compiler: ICompiler; + singleOutput: boolean; + options: ts.CompilerOptions; + typescript: typeof ts; + reporter: Reporter; +} +export declare function setupProject(projectDirectory: string, config: TsConfig, options: ts.CompilerOptions, typescript: typeof ts): Project; +export interface ICompileStream extends NodeJS.ReadWriteStream { + js: stream.Readable; + dts: stream.Readable; +} diff --git a/node_modules/gulp-typescript/release/project.js b/node_modules/gulp-typescript/release/project.js new file mode 100644 index 000000000..01f4696ae --- /dev/null +++ b/node_modules/gulp-typescript/release/project.js @@ -0,0 +1,134 @@ +"use strict"; +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var stream = require('stream'); +var vfs = require('vinyl-fs'); +var path = require('path'); +var gutil = require('gulp-util'); +var utils = require('./utils'); +var reporter_1 = require('./reporter'); +var input_1 = require('./input'); +var output_1 = require('./output'); +var compiler_1 = require('./compiler'); +function setupProject(projectDirectory, config, options, typescript) { + var input = new input_1.FileCache(typescript, options); + var compiler = options.isolatedModules ? new compiler_1.FileCompiler() : new compiler_1.ProjectCompiler(); + var running = false; + if (options.isolatedModules) { + options.newLine = typescript.NewLineKind.LineFeed; + options.sourceMap = false; + options.declaration = false; + options.inlineSourceMap = true; + } + var project = function (reporter) { + if (running) { + throw new Error('gulp-typescript: A project cannot be used in two compilations at the same time. Create multiple projects with createProject instead.'); + } + running = true; + input.reset(); + compiler.prepare(projectInfo); + var stream = new CompileStream(projectInfo); + projectInfo.output = new output_1.Output(projectInfo, stream, stream.js, stream.dts); + projectInfo.reporter = reporter || reporter_1.defaultReporter(); + stream.on('finish', function () { + running = false; + }); + return stream; + }; + var singleOutput = options.out !== undefined || options.outFile !== undefined; + project.src = src; + project.typescript = typescript; + project.projectDirectory = projectDirectory; + project.config = config; + project.options = options; + var projectInfo = { + input: input, + singleOutput: singleOutput, + compiler: compiler, + options: options, + typescript: typescript, + // Set when `project` is called + output: undefined, + reporter: undefined + }; + return project; +} +exports.setupProject = setupProject; +function src() { + var base; + if (this.options["rootDir"]) { + base = path.resolve(this.projectDirectory, this.options["rootDir"]); + } + var content = {}; + if (this.config.include) + content.include = this.config.include; + if (this.config.exclude) + content.exclude = this.config.exclude; + if (this.config.files) + content.files = this.config.files; + if (this.options['allowJs']) + content.compilerOptions = { allowJs: true }; + var _a = this.typescript.parseJsonConfigFileContent(content, this.typescript.sys, this.projectDirectory), fileNames = _a.fileNames, errors = _a.errors; + for (var _i = 0, errors_1 = errors; _i < errors_1.length; _i++) { + var error = errors_1[_i]; + console.log(error.messageText); + } + if (base === undefined) + base = utils.getCommonBasePathOfArray(fileNames.filter(function (file) { return file.substr(-5) !== ".d.ts"; }) + .map(function (file) { return path.dirname(file); })); + var vinylOptions = { base: base, allowEmpty: true }; + return vfs.src(fileNames, vinylOptions); +} +var CompileStream = (function (_super) { + __extends(CompileStream, _super); + function CompileStream(project) { + _super.call(this, { objectMode: true }); + this.js = new CompileOutputStream(); + this.dts = new CompileOutputStream(); + this.project = project; + // Prevent "Unhandled stream error in pipe" when a compilation error occurs. + this.on('error', function () { }); + } + CompileStream.prototype._write = function (file, encoding, cb) { + if (cb === void 0) { cb = function (err) { }; } + if (!file) + return cb(); + if (file.isNull()) { + cb(); + return; + } + if (file.isStream()) { + return cb(new gutil.PluginError('gulp-typescript', 'Streaming not supported')); + } + var inputFile = this.project.input.addGulp(file); + this.project.compiler.inputFile(inputFile); + cb(); + }; + CompileStream.prototype._read = function () { + }; + CompileStream.prototype.end = function (chunk, encoding, callback) { + if (typeof chunk === 'function') { + this._write(null, null, chunk); + } + else if (typeof encoding === 'function') { + this._write(chunk, null, encoding); + } + else { + this._write(chunk, encoding, callback); + } + this.project.compiler.inputDone(); + }; + return CompileStream; +}(stream.Duplex)); +var CompileOutputStream = (function (_super) { + __extends(CompileOutputStream, _super); + function CompileOutputStream() { + _super.call(this, { objectMode: true }); + } + CompileOutputStream.prototype._read = function () { + }; + return CompileOutputStream; +}(stream.Readable)); diff --git a/node_modules/gulp-typescript/release/reporter.d.ts b/node_modules/gulp-typescript/release/reporter.d.ts new file mode 100644 index 000000000..3dba518e1 --- /dev/null +++ b/node_modules/gulp-typescript/release/reporter.d.ts @@ -0,0 +1,41 @@ +import * as ts from 'typescript'; +import { VinylFile } from './types'; +export interface TypeScriptError extends Error { + fullFilename?: string; + relativeFilename?: string; + file?: VinylFile; + tsFile?: ts.SourceFile; + diagnostic: ts.Diagnostic; + startPosition?: { + position: number; + line: number; + character: number; + }; + endPosition?: { + position: number; + line: number; + character: number; + }; +} +export interface CompilationResult { + /** + * Only used when using isolatedModules. + */ + transpileErrors: number; + optionsErrors: number; + syntaxErrors: number; + globalErrors: number; + semanticErrors: number; + declarationErrors: number; + emitErrors: number; + emitSkipped: boolean; +} +export declare function emptyCompilationResult(): CompilationResult; +export interface Reporter { + error?: (error: TypeScriptError, typescript: typeof ts) => void; + finish?: (results: CompilationResult) => void; +} +export declare function nullReporter(): Reporter; +export declare function defaultReporter(): Reporter; +export declare function longReporter(): Reporter; +export declare function fullReporter(fullFilename?: boolean): Reporter; diff --git a/node_modules/gulp-typescript/release/reporter.js b/node_modules/gulp-typescript/release/reporter.js new file mode 100644 index 000000000..157b7e70e --- /dev/null +++ b/node_modules/gulp-typescript/release/reporter.js @@ -0,0 +1,96 @@ +"use strict"; +var gutil = require('gulp-util'); +function emptyCompilationResult() { + return { + transpileErrors: 0, + optionsErrors: 0, + syntaxErrors: 0, + globalErrors: 0, + semanticErrors: 0, + declarationErrors: 0, + emitErrors: 0, + emitSkipped: false + }; +} +exports.emptyCompilationResult = emptyCompilationResult; +function defaultFinishHandler(results) { + var hasError = false; + var showErrorCount = function (count, type) { + if (count === 0) + return; + gutil.log('TypeScript:', gutil.colors.magenta(count.toString()), (type !== '' ? type + ' ' : '') + (count === 1 ? 'error' : 'errors')); + hasError = true; + }; + showErrorCount(results.transpileErrors, ''); + showErrorCount(results.optionsErrors, 'options'); + showErrorCount(results.syntaxErrors, 'syntax'); + showErrorCount(results.globalErrors, 'global'); + showErrorCount(results.semanticErrors, 'semantic'); + showErrorCount(results.declarationErrors, 'declaration'); + showErrorCount(results.emitErrors, 'emit'); + if (results.emitSkipped) { + gutil.log('TypeScript: emit', gutil.colors.red('failed')); + } + else if (hasError) { + gutil.log('TypeScript: emit', gutil.colors.cyan('succeeded'), '(with errors)'); + } +} +function nullReporter() { + return {}; +} +exports.nullReporter = nullReporter; +function defaultReporter() { + return { + error: function (error) { + console.error(error.message); + }, + finish: defaultFinishHandler + }; +} +exports.defaultReporter = defaultReporter; +function longReporter() { + var typescript = require('typescript'); + return { + error: function (error) { + if (error.tsFile) { + console.error('[' + gutil.colors.gray('gulp-typescript') + '] ' + gutil.colors.red(error.fullFilename + + '(' + error.startPosition.line + ',' + error.startPosition.character + '): ') + + 'error TS' + error.diagnostic.code + ' ' + typescript.flattenDiagnosticMessageText(error.diagnostic.messageText, '\n')); + } + else { + console.error(error.message); + } + }, + finish: defaultFinishHandler + }; +} +exports.longReporter = longReporter; +function fullReporter(fullFilename) { + if (fullFilename === void 0) { fullFilename = false; } + var typescript = require('typescript'); + return { + error: function (error, typescript) { + console.error('[' + gutil.colors.gray('gulp-typescript') + '] ' + + gutil.colors.bgRed(error.diagnostic.code + '') + + ' ' + gutil.colors.red(typescript.flattenDiagnosticMessageText(error.diagnostic.messageText, '\n'))); + if (error.tsFile) { + console.error('> ' + gutil.colors.gray('file: ') + (fullFilename ? error.fullFilename : error.relativeFilename) + gutil.colors.gray(':')); + var lines_1 = error.tsFile.text.split(/(\r\n|\r|\n)/); + var logLine = function (lineIndex, errorStart, errorEnd) { + var line = lines_1[lineIndex]; + if (errorEnd === undefined) + errorEnd = line.length; + console.error('> ' + gutil.colors.gray('[' + lineIndex + '] ') + + line.substring(0, errorStart) + + gutil.colors.red(line.substring(errorStart, errorEnd)) + + line.substring(errorEnd)); + }; + for (var i = error.startPosition.line; i <= error.endPosition.line; i++) { + logLine(i, i === error.startPosition.line ? error.startPosition.character - 1 : 0, i === error.endPosition.line ? error.endPosition.character - 1 : undefined); + } + } + }, + finish: defaultFinishHandler + }; +} +exports.fullReporter = fullReporter; diff --git a/node_modules/gulp-typescript/release/tsapi.d.ts b/node_modules/gulp-typescript/release/tsapi.d.ts new file mode 100644 index 000000000..da1dc42b5 --- /dev/null +++ b/node_modules/gulp-typescript/release/tsapi.d.ts @@ -0,0 +1,88 @@ +import * as ts from 'typescript'; +import { CompilationResult } from './reporter'; +export interface TypeScript { + convertCompilerOptionsFromJson?: (jsonOptions: any, basePath: string, configFileName?: string) => { + options: ts.CompilerOptions; + errors: ts.Diagnostic[]; + }; + parseJsonConfigFileContent?: (json: any, host: any, basePath: string) => { + fileNames: string[]; + errors: ts.Diagnostic[]; + }; + sys?: any; +} +export interface TypeScript14 { + createSourceFile(filename: string, content: string, target: ts.ScriptTarget, version: string): any; +} +export interface TypeScript15 { + createSourceFile(fileName: string, content: string, target: ts.ScriptTarget, isOpen: boolean): any; + findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string; + flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain15, newLine: string): string; + transpile(input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]): string; +} +export interface TypeScript17 { + parseConfigFileTextToJson(fileName: string, jsonText: string): { + config?: any; + error?: ts.Diagnostic; + }; +} +export declare function parseTsConfig(typescript: TypeScript14 | TypeScript15 | TypeScript17, fileName: string, content: string): { + config?: any; + error?: ts.Diagnostic; +}; +export declare type CreateProgram = (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost, oldProgram?: ts.Program) => ts.Program; +export interface Program14 { + getDiagnostics(): ts.Diagnostic[]; + getTypeChecker(fullTypeCheckMode: boolean): TypeChecker14; +} +export interface Program15 { + getSyntacticDiagnostics(): ts.Diagnostic[]; + getGlobalDiagnostics(): ts.Diagnostic[]; + getSemanticDiagnostics(): ts.Diagnostic[]; + getDeclarationDiagnostics(): ts.Diagnostic[]; + emit(): { + diagnostics: ts.Diagnostic[]; + emitSkipped: boolean; + }; +} +export interface TypeChecker14 { + getDiagnostics(sourceFile?: ts.SourceFile): ts.Diagnostic[]; + emitFiles(): { + diagnostics: ts.Diagnostic[]; + }; +} +export interface DiagnosticMessageChain15 { + messageText: string; + category: ts.DiagnosticCategory; + code: number; + next?: DiagnosticMessageChain15; +} +export interface TSFile14 { + getLineAndCharacterFromPosition(pos: number): ts.LineAndCharacter; +} +export interface TSFile15 { + getLineAndCharacterOfPosition(pos: number): ts.LineAndCharacter; +} +export interface TSOptions18 { + allowJs?: boolean; + suppressOutputPathCheck?: boolean; +} +export interface TSOptions20 extends TSOptions18 { + baseUrl?: string; + rootDirs?: string[]; +} +export declare function isTS14(typescript: typeof ts): boolean; +export declare function isTS16OrNewer(typescript: typeof ts): boolean; +export declare function getFileName(thing: { + filename: string; +} | { + fileName: string; +}): string; +export declare function getDiagnosticsAndEmit(program: Program14 | Program15): [ts.Diagnostic[], CompilationResult]; +export declare function getLineAndCharacterOfPosition(typescript: typeof ts, file: TSFile14 | TSFile15, position: number): { + line: number; + character: number; +}; +export declare function createSourceFile(typescript: TypeScript14 | TypeScript15, fileName: string, content: string, target: ts.ScriptTarget, version?: string): any; +export declare function flattenDiagnosticMessageText(typescript: TypeScript14 | TypeScript15, messageText: string | DiagnosticMessageChain15): string; +export declare function transpile(typescript: TypeScript14 | TypeScript15, input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]): string; diff --git a/node_modules/gulp-typescript/release/tsapi.js b/node_modules/gulp-typescript/release/tsapi.js new file mode 100644 index 000000000..6da970c59 --- /dev/null +++ b/node_modules/gulp-typescript/release/tsapi.js @@ -0,0 +1,105 @@ +"use strict"; +var reporter_1 = require('./reporter'); +function parseTsConfig(typescript, fileName, content) { + if ('parseConfigFileTextToJson' in typescript) { + return typescript.parseConfigFileTextToJson(fileName, content); + } + else { + return { + config: JSON.parse(content.replace(/^\uFEFF/, '')) + }; + } +} +exports.parseTsConfig = parseTsConfig; +function isTS14(typescript) { + return !('findConfigFile' in typescript); +} +exports.isTS14 = isTS14; +function isTS16OrNewer(typescript) { + return ('ModuleResolutionKind' in typescript); +} +exports.isTS16OrNewer = isTS16OrNewer; +function getFileName(thing) { + if (thing.filename) + return thing.filename; // TS 1.4 + return thing.fileName; // TS 1.5 +} +exports.getFileName = getFileName; +function getDiagnosticsAndEmit(program) { + var result = reporter_1.emptyCompilationResult(); + if (program.getDiagnostics) { + var errors = program.getDiagnostics(); + result.syntaxErrors = errors.length; + if (!errors.length) { + // If there are no syntax errors, check types + var checker = program.getTypeChecker(true); + var semanticErrors = checker.getDiagnostics(); + var emitErrors = checker.emitFiles().diagnostics; + errors = semanticErrors.concat(emitErrors); + result.semanticErrors = errors.length; + } + else { + result.emitSkipped = true; + } + return [errors, result]; + } + else { + var errors = program.getSyntacticDiagnostics(); + result.syntaxErrors = errors.length; + if (errors.length === 0) { + errors = program.getGlobalDiagnostics(); + // Remove error: "File '...' is not under 'rootDir' '...'. 'rootDir' is expected to contain all source files." + // This is handled by ICompiler#correctSourceMap, so this error can be muted. + errors = errors.filter(function (item) { return item.code !== 6059; }); + result.globalErrors = errors.length; + } + if (errors.length === 0) { + errors = program.getSemanticDiagnostics(); + result.semanticErrors = errors.length; + } + var emitOutput = program.emit(); + result.emitErrors = emitOutput.diagnostics.length; + result.emitSkipped = emitOutput.emitSkipped; + return [errors.concat(emitOutput.diagnostics), result]; + } +} +exports.getDiagnosticsAndEmit = getDiagnosticsAndEmit; +function getLineAndCharacterOfPosition(typescript, file, position) { + if (file.getLineAndCharacterOfPosition) { + var lineAndCharacter = file.getLineAndCharacterOfPosition(position); + return { + line: lineAndCharacter.line + 1, + character: lineAndCharacter.character + 1 + }; + } + else { + return file.getLineAndCharacterFromPosition(position); + } +} +exports.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; +function createSourceFile(typescript, fileName, content, target, version) { + if (version === void 0) { version = '0'; } + if (typescript.findConfigFile) { + return typescript.createSourceFile(fileName, content, target, true); + } + else { + return typescript.createSourceFile(fileName, content, target, version); + } +} +exports.createSourceFile = createSourceFile; +function flattenDiagnosticMessageText(typescript, messageText) { + if (typeof messageText === 'string') { + return messageText; + } + else { + return typescript.flattenDiagnosticMessageText(messageText, "\n"); + } +} +exports.flattenDiagnosticMessageText = flattenDiagnosticMessageText; +function transpile(typescript, input, compilerOptions, fileName, diagnostics) { + if (!typescript.transpile) { + throw new Error('gulp-typescript: Single file compilation is not supported using TypeScript 1.4'); + } + return typescript.transpile(input, compilerOptions, fileName.replace(/\\/g, '/'), diagnostics); +} +exports.transpile = transpile; diff --git a/node_modules/gulp-typescript/release/tsconfig.d.ts b/node_modules/gulp-typescript/release/tsconfig.d.ts new file mode 100644 index 000000000..dbf30be76 --- /dev/null +++ b/node_modules/gulp-typescript/release/tsconfig.d.ts @@ -0,0 +1,5 @@ +export interface TsConfig { + files?: string[]; + exclude?: string[]; + compilerOptions?: any; +} diff --git a/node_modules/gulp-typescript/release/tsconfig.js b/node_modules/gulp-typescript/release/tsconfig.js new file mode 100644 index 000000000..3918c74e4 --- /dev/null +++ b/node_modules/gulp-typescript/release/tsconfig.js @@ -0,0 +1 @@ +"use strict"; diff --git a/node_modules/gulp-typescript/release/types.d.ts b/node_modules/gulp-typescript/release/types.d.ts new file mode 100644 index 000000000..8b19cf69a --- /dev/null +++ b/node_modules/gulp-typescript/release/types.d.ts @@ -0,0 +1,28 @@ +export interface TsConfig { + files?: string[]; + include?: string[]; + exclude?: string[]; + compilerOptions?: any; +} +export interface VinylFile { + cwd: string; + base: string; + path: string; + stat: {}; + contents: {}; + sourceMap?: any; + relative: string; + isBuffer(): boolean; + isStream(): boolean; + isNull(): boolean; + isDirectory(): boolean; +} +export interface RawSourceMap { + file?: string; + sourceRoot?: string; + version: string; + sources: string[]; + names: string[]; + sourcesContent?: string; + mappings: string; +} diff --git a/node_modules/gulp-typescript/release/types.js b/node_modules/gulp-typescript/release/types.js new file mode 100644 index 000000000..3918c74e4 --- /dev/null +++ b/node_modules/gulp-typescript/release/types.js @@ -0,0 +1 @@ +"use strict"; diff --git a/node_modules/gulp-typescript/release/utils.d.ts b/node_modules/gulp-typescript/release/utils.d.ts new file mode 100644 index 000000000..7f40e33f9 --- /dev/null +++ b/node_modules/gulp-typescript/release/utils.d.ts @@ -0,0 +1,20 @@ +import * as ts from 'typescript'; +import { File } from './input'; +import * as reporter from './reporter'; +export interface Map<T> { + [key: string]: T; +} +export declare function normalizePath(pathString: string): string; +/** + * Splits a filename into an extensionless filename and an extension. + * 'bar/foo.js' is turned into ['bar/foo', 'js'] + * 'foo.d.ts' is parsed as ['foo', 'd.ts'] if you add 'd.ts' to knownExtensions. + * @param knownExtensions An array with known extensions, that contain multiple parts, like 'd.ts'. 'a.b.c' should be listed before 'b.c'. + */ +export declare function splitExtension(fileName: string, knownExtensions?: string[]): [string, string]; +/** + * Finds the common base path of two directories + */ +export declare function getCommonBasePath(a: string, b: string): string; +export declare function getCommonBasePathOfArray(paths: string[]): string; +export declare function getError(info: ts.Diagnostic, typescript: typeof ts, file?: File): reporter.TypeScriptError; diff --git a/node_modules/gulp-typescript/release/utils.js b/node_modules/gulp-typescript/release/utils.js new file mode 100644 index 000000000..fbd442b42 --- /dev/null +++ b/node_modules/gulp-typescript/release/utils.js @@ -0,0 +1,95 @@ +"use strict"; +var path = require('path'); +var gutil = require('gulp-util'); +function normalizePath(pathString) { + return path.normalize(pathString).toLowerCase(); +} +exports.normalizePath = normalizePath; +/** + * Splits a filename into an extensionless filename and an extension. + * 'bar/foo.js' is turned into ['bar/foo', 'js'] + * 'foo.d.ts' is parsed as ['foo', 'd.ts'] if you add 'd.ts' to knownExtensions. + * @param knownExtensions An array with known extensions, that contain multiple parts, like 'd.ts'. 'a.b.c' should be listed before 'b.c'. + */ +function splitExtension(fileName, knownExtensions) { + if (knownExtensions) { + for (var _i = 0, knownExtensions_1 = knownExtensions; _i < knownExtensions_1.length; _i++) { + var ext_1 = knownExtensions_1[_i]; + var index_1 = fileName.length - ext_1.length - 1; + if (fileName.substr(index_1) === '.' + ext_1) { + return [fileName.substr(0, index_1), ext_1]; + } + } + } + var ext = path.extname(fileName).toLowerCase().substr(1); + var index = fileName.length - ext.length; + return [fileName.substr(0, index - 1), ext]; +} +exports.splitExtension = splitExtension; +/** + * Finds the common base path of two directories + */ +function getCommonBasePath(a, b) { + var aSplit = a.split(/\\|\//); // Split on '/' or '\'. + var bSplit = b.split(/\\|\//); + var commonLength = 0; + for (var i = 0; i < aSplit.length && i < bSplit.length; i++) { + if (aSplit[i] !== bSplit[i]) + break; + commonLength += aSplit[i].length + 1; + } + return a.substr(0, commonLength); +} +exports.getCommonBasePath = getCommonBasePath; +function getCommonBasePathOfArray(paths) { + if (paths.length === 0) + return ''; + return paths.reduce(getCommonBasePath); +} +exports.getCommonBasePathOfArray = getCommonBasePathOfArray; +function getError(info, typescript, file) { + var err = new Error(); + err.name = 'TypeScript error'; + err.diagnostic = info; + var codeAndMessageText = typescript.DiagnosticCategory[info.category].toLowerCase() + + ' TS' + + info.code + + ': ' + + typescript.flattenDiagnosticMessageText(info.messageText, '\n'); + if (!info.file) { + err.message = codeAndMessageText; + return err; + } + var fileName = info.file.fileName; + if (file) { + err.tsFile = file.ts; + err.fullFilename = file.fileNameOriginal; + if (file.gulp) { + fileName = path.relative(file.gulp.cwd, file.fileNameOriginal); + err.relativeFilename = fileName; + err.file = file.gulp; + } + else { + fileName = file.fileNameOriginal; + } + } + else { + err.fullFilename = info.file.fileName; + } + var startPos = typescript.getLineAndCharacterOfPosition(info.file, info.start); + var endPos = typescript.getLineAndCharacterOfPosition(info.file, info.start + info.length); + err.startPosition = { + position: info.start, + line: startPos.line, + character: startPos.character + }; + err.endPosition = { + position: info.start + info.length - 1, + line: endPos.line, + character: endPos.character + }; + err.message = gutil.colors.red(fileName + '(' + (startPos.line + 1) + ',' + (startPos.character + 1) + '): ').toString() + + codeAndMessageText; + return err; +} +exports.getError = getError; diff --git a/node_modules/gulp-typescript/release/vinyl-file.d.ts b/node_modules/gulp-typescript/release/vinyl-file.d.ts new file mode 100644 index 000000000..8d70314e3 --- /dev/null +++ b/node_modules/gulp-typescript/release/vinyl-file.d.ts @@ -0,0 +1,4 @@ +import Vinyl = require('vinyl'); +export interface VinylFile extends Vinyl { + sourceMap?: any; +} diff --git a/node_modules/gulp-typescript/release/vinyl-file.js b/node_modules/gulp-typescript/release/vinyl-file.js new file mode 100644 index 000000000..3918c74e4 --- /dev/null +++ b/node_modules/gulp-typescript/release/vinyl-file.js @@ -0,0 +1 @@ +"use strict"; diff --git a/node_modules/gulp-typescript/tsd.json b/node_modules/gulp-typescript/tsd.json new file mode 100644 index 000000000..1672366a1 --- /dev/null +++ b/node_modules/gulp-typescript/tsd.json @@ -0,0 +1,30 @@ +{ + "version": "v4", + "repo": "borisyankov/DefinitelyTyped", + "ref": "master", + "path": "typings", + "bundle": "typings/tsd.d.ts", + "installed": { + "node/node.d.ts": { + "commit": "6f6e5c7dd9effe21fee14eb65fe340ecbbc8580a" + }, + "vinyl-fs/vinyl-fs.d.ts": { + "commit": "6f6e5c7dd9effe21fee14eb65fe340ecbbc8580a" + }, + "gulp-util/gulp-util.d.ts": { + "commit": "6f6e5c7dd9effe21fee14eb65fe340ecbbc8580a" + }, + "source-map/source-map.d.ts": { + "commit": "6f6e5c7dd9effe21fee14eb65fe340ecbbc8580a" + }, + "through2/through2.d.ts": { + "commit": "6f6e5c7dd9effe21fee14eb65fe340ecbbc8580a" + }, + "vinyl/vinyl.d.ts": { + "commit": "6f6e5c7dd9effe21fee14eb65fe340ecbbc8580a" + }, + "chalk/chalk.d.ts": { + "commit": "6f6e5c7dd9effe21fee14eb65fe340ecbbc8580a" + } + } +} |