tech(systemjs): almost all tests are passing

This commit is contained in:
Torkel Ödegaard 2015-12-21 16:00:58 +01:00
parent f7888886e9
commit 4522b02925
48 changed files with 10429 additions and 222 deletions

View File

@ -9,14 +9,13 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
'vendor/npm/es5-shim/es5-shim.js',
'vendor/npm/es5-shim/es5-sham.js',
'vendor/npm/es6-shim/es6-shim.js',
'vendor/npm/es6-promise/dist/es6-promise.js',
'vendor/npm/systemjs/dist/system.src.js',
'test/test-main.js',
{pattern: 'app/**/*.js', included: false},
{pattern: 'vendor/**/*.js', included: false},
{pattern: 'test/**/*.js', included: false}
{pattern: '**/*.js', included: false},
],
// list of files to exclude
@ -28,7 +27,7 @@ module.exports = function(config) {
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
captureTimeout: 60000,
captureTimeout: 2000,
singleRun: true,
autoWatchBatchDelay: 1000,

View File

@ -18,43 +18,36 @@
"grunt": "~0.4.0",
"grunt-angular-templates": "^0.5.5",
"grunt-cli": "~0.1.13",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-compress": "~0.13.0",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-cssmin": "~0.6.1",
"grunt-contrib-clean": "~0.7.0",
"grunt-contrib-compress": "~0.14.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "~0.8.2",
"grunt-contrib-cssmin": "~0.14.0",
"grunt-contrib-htmlmin": "~0.6.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-jshint": "~0.11.3",
"grunt-contrib-less": "~0.7.0",
"grunt-contrib-requirejs": "~0.4.4",
"grunt-contrib-uglify": "~0.8.0",
"grunt-contrib-uglify": "~0.11.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-filerev": "^0.2.1",
"grunt-git-describe": "~2.3.2",
"grunt-karma": "~0.8.3",
"grunt-ng-annotate": "^0.9.2",
"grunt-string-replace": "~0.2.4",
"grunt-karma": "~0.12.1",
"grunt-ng-annotate": "^1.0.1",
"grunt-string-replace": "~1.2.1",
"grunt-systemjs-builder": "^0.2.5",
"grunt-tslint": "^2.5.0",
"grunt-typescript": "^0.8.0",
"grunt-usemin": "3.0.0",
"jshint-stylish": "~0.1.5",
"karma": "~0.12.31",
"karma-chrome-launcher": "~0.1.4",
"karma-coffee-preprocessor": "~0.1.2",
"karma-coverage": "0.3.1",
"karma-coveralls": "0.1.5",
"karma": "~0.13.15",
"karma-chrome-launcher": "~0.2.2",
"karma-coverage": "0.5.3",
"karma-coveralls": "1.1.2",
"karma-expect": "~1.1.0",
"karma-mocha": "~0.1.10",
"karma-phantomjs-launcher": "0.1.4",
"karma-requirejs": "0.2.2",
"karma-script-launcher": "0.1.0",
"load-grunt-tasks": "0.2.0",
"mocha": "2.2.4",
"karma-mocha": "~0.2.1",
"karma-phantomjs-launcher": "0.2.1",
"load-grunt-tasks": "3.4.0",
"mocha": "2.3.4",
"reflect-metadata": "0.1.2",
"requirejs": "2.1.17",
"rjs-build-analysis": "0.0.3",
"rxjs": "5.0.0-beta.0",
"systemjs": "0.19.6",
"zone.js": "0.5.10"

View File

@ -3,6 +3,5 @@ define([
], function(app) {
'use strict';
// backward compatability hack;
console.log(app);
return app.default;
});

View File

@ -25,6 +25,12 @@ export class GrafanaApp {
ngModuleDependencies: any[];
preBootModules: any[];
constructor() {
this.preBootModules = [];
this.registerFunctions = {};
this.ngModuleDependencies = [];
}
useModule(module) {
if (this.preBootModules) {
this.preBootModules.push(module);
@ -36,9 +42,6 @@ export class GrafanaApp {
}
init() {
this.registerFunctions = {};
this.preBootModules = [];
var app = angular.module('grafana', []);
app.constant('grafanaVersion', "@grafanaVersion@");

View File

@ -1,10 +1,8 @@
///<amd-dependency path="app/plugins/datasource/cloudwatch/datasource" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
import "../datasource";
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
import moment = require('moment');
declare var helpers: any;
import moment from 'moment';
import helpers from 'test/specs/helpers';
describe('CloudWatchDatasource', function() {
var ctx = new helpers.ServiceTestContext();

View File

@ -0,0 +1,2 @@
declare var test: any;
export default test;

View File

@ -0,0 +1,2 @@
declare var test: any;
export default test;

View File

@ -0,0 +1,2 @@
declare var test: any;
export default test;

View File

@ -0,0 +1,2 @@
declare var test: any;
export default test;

View File

@ -1,11 +1,9 @@
///<amd-dependency path="../datasource" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
import "../datasource";
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
import moment = require('moment');
import angular = require('angular');
declare var helpers: any;
import moment from 'moment';
import angular from 'angular';
import helpers from 'test/specs/helpers';
describe('ElasticDatasource', function() {
var ctx = new helpers.ServiceTestContext();

View File

@ -1,8 +1,6 @@
///<amd-dependency path="../elastic_response" name="ElasticResponse"/>
import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
declare var ElasticResponse: any;
import ElasticResponse from '../elastic_response';
describe('ElasticResponse', function() {
var targets;

View File

@ -1,10 +1,8 @@
///<amd-dependency path="../index_pattern" name="IndexPattern"/>
///<amd-dependency path="test/specs/helpers" name="helpers" />
import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
import moment = require('moment');
declare var IndexPattern: any;
import moment from 'moment';
import IndexPattern from '../index_pattern';
describe('IndexPattern', function() {

View File

@ -1,8 +1,6 @@
///<amd-dependency path="../query_builder" name="ElasticQueryBuilder"/>
import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
declare var ElasticQueryBuilder: any;
import ElasticQueryBuilder from '../query_builder';
describe('ElasticQueryBuilder', function() {
var builder;

View File

@ -3,8 +3,7 @@
///<amd-dependency path="test/specs/helpers" name="helpers" />
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
declare var helpers: any;
import helpers from 'test/specs/helpers';
describe('ElasticQueryCtrl', function() {
var ctx = new helpers.ControllerTestContext();

View File

@ -1,16 +1,13 @@
///<amd-dependency path="../query_def" name="QueryDef" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
declare var helpers: any;
declare var QueryDef: any;
import * as queryDef from '../query_def';
describe('ElasticQueryDef', function() {
describe('getPipelineAggOptions', function() {
describe('with zero targets', function() {
var response = QueryDef.getPipelineAggOptions([]);
var response = queryDef.getPipelineAggOptions([]);
it('should return zero', function() {
expect(response.length).to.be(0);
@ -25,7 +22,7 @@ describe('ElasticQueryDef', function() {
]
};
var response = QueryDef.getPipelineAggOptions(targets);
var response = queryDef.getPipelineAggOptions(targets);
it('should return zero', function() {
expect(response.length).to.be(2);
@ -40,7 +37,7 @@ describe('ElasticQueryDef', function() {
]
};
var response = QueryDef.getPipelineAggOptions(targets);
var response = queryDef.getPipelineAggOptions(targets);
it('should return one', function() {
expect(response.length).to.be(1);
@ -54,7 +51,7 @@ describe('ElasticQueryDef', function() {
]
};
var response = QueryDef.getPipelineAggOptions(targets);
var response = queryDef.getPipelineAggOptions(targets);
it('should return zero', function() {
expect(response.length).to.be(0);
@ -64,7 +61,7 @@ describe('ElasticQueryDef', function() {
describe('isPipelineMetric', function() {
describe('moving_avg', function() {
var result = QueryDef.isPipelineAgg('moving_avg');
var result = queryDef.isPipelineAgg('moving_avg');
it('is pipe line metric', function() {
expect(result).to.be(true);
@ -72,7 +69,7 @@ describe('ElasticQueryDef', function() {
});
describe('count', function() {
var result = QueryDef.isPipelineAgg('count');
var result = queryDef.isPipelineAgg('count');
it('is not pipe line metric', function() {
expect(result).to.be(false);
@ -83,19 +80,19 @@ describe('ElasticQueryDef', function() {
describe('pipeline aggs depending on esverison', function() {
describe('using esversion undefined', function() {
it('should not get pipeline aggs', function() {
expect(QueryDef.getMetricAggTypes(undefined).length).to.be(9);
expect(queryDef.getMetricAggTypes(undefined).length).to.be(9);
});
});
describe('using esversion 1', function() {
it('should not get pipeline aggs', function() {
expect(QueryDef.getMetricAggTypes(1).length).to.be(9);
expect(queryDef.getMetricAggTypes(1).length).to.be(9);
});
});
describe('using esversion 2', function() {
it('should get pipeline aggs', function() {
expect(QueryDef.getMetricAggTypes(2).length).to.be(11);
expect(queryDef.getMetricAggTypes(2).length).to.be(11);
});
});
});

View File

@ -0,0 +1,2 @@
declare var test: any;
export default test;

View File

@ -1,8 +1,7 @@
///<amd-dependency path="app/plugins/datasource/graphite/datasource" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
import "../datasource";
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
declare var helpers: any;
import helpers from 'test/specs/helpers';
describe('graphiteDatasource', function() {
var ctx = new helpers.ServiceTestContext();

View File

@ -1,8 +1,7 @@
///<amd-dependency path="app/plugins/datasource/graphite/gfunc" name="gfunc" />
import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
declare var gfunc: any;
import gfunc from '../gfunc';
describe('when creating func instance from func names', function() {
it('should return func instance', function() {

View File

@ -1,12 +1,10 @@
///<amd-dependency path="app/plugins/datasource/graphite/gfunc" name="gfunc"/>
///<amd-dependency path="app/plugins/datasource/graphite/query_ctrl" />
///<amd-dependency path="app/core/services/segment_srv" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
import '../query_ctrl';
import 'app/core/services/segment_srv';
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
declare var gfunc: any;
declare var helpers: any;
import * as gfunc from '../gfunc';
import helpers from 'test/specs/helpers';
describe('GraphiteQueryCtrl', function() {
var ctx = new helpers.ControllerTestContext();

View File

@ -0,0 +1,2 @@
declare var test: any;
export default test;

View File

@ -0,0 +1,2 @@
declare var test: any;
export default test;

View File

@ -11,6 +11,9 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
var module = angular.module('grafana.controllers');
InfluxQuery = InfluxQuery.default;
queryPart = queryPart.default;
module.controller('InfluxQueryCtrl', function($scope, templateSrv, $q, uiSegmentSrv) {
$scope.init = function() {

View File

@ -1,6 +1,6 @@
import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
import InfluxQuery = require('../influx_query');
import InfluxQuery from '../influx_query';
describe('InfluxQuery', function() {

View File

@ -1,8 +1,5 @@
///<amd-dependency path="app/plugins/datasource/influxdb/influx_series" name="InfluxSeries"/>
import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
declare var InfluxSeries: any;
import InfluxSeries from '../influx_series';
describe('when generating timeseries from influxdb response', function() {

View File

@ -1,8 +1,5 @@
///<amd-dependency path="app/plugins/datasource/influxdb/query_builder" name="InfluxQueryBuilder"/>
import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
declare var InfluxQueryBuilder: any;
import InfluxQueryBuilder from '../query_builder';
describe('InfluxQueryBuilder', function() {

View File

@ -1,10 +1,7 @@
///<amd-dependency path="app/plugins/datasource/influxdb/query_ctrl"/>
///<amd-dependency path="app/core/services/segment_srv" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
import '../query_ctrl';
import 'app/core/services/segment_srv';
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
declare var helpers: any;
import helpers from 'test/specs/helpers';
describe('InfluxDBQueryCtrl', function() {
var ctx = new helpers.ControllerTestContext();

View File

@ -1,7 +1,7 @@
import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
import queryPart = require('../query_part');
import queryPart from '../query_part';
describe('InfluxQueryPart', () => {

View File

@ -1,9 +1,7 @@
///<amd-dependency path="app/plugins/datasource/prometheus/datasource" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
import '../datasource';
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
import moment = require('moment');
declare var helpers: any;
import moment from 'moment';
import helpers from 'test/specs/helpers';
describe('PrometheusDatasource', function() {

View File

@ -1,6 +1,6 @@
import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
import TableModel = require('app/core/table_model');
import TableModel from 'app/core/table_model';
import {TableRenderer} from '../renderer';
describe('when rendering table', () => {

View File

@ -46,5 +46,4 @@ System.config({
exports: 'angular',
},
}
});

6
public/test/specs/helpers.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
declare module "test/specs/helpers" {
let helpers: any;
export default helpers;
}

View File

@ -1,18 +0,0 @@
define([
'./helpers',
'app/features/dashboard/rowCtrl'
], function(helpers) {
'use strict';
describe('RowCtrl', function() {
var ctx = new helpers.ControllerTestContext();
beforeEach(module('grafana.controllers'));
beforeEach(ctx.providePhase());
beforeEach(ctx.createControllerPhase('RowCtrl'));
});
});

View File

@ -1,6 +1,11 @@
(function() {
"use strict";
// Tun on full stack traces in errors to help debugging
Error.stackTraceLimit=Infinity;
window.__karma__.loaded = function() {};
System.config({
baseURL: '/base/',
defaultJSExtensions: true,
@ -49,7 +54,7 @@
deps: ['jquery'],
exports: 'angular',
},
'vendor/angular/angular-mocks.js': {
'vendor/angular-mocks/angular-mocks.js': {
format: 'global',
deps: ['angular'],
}
@ -63,23 +68,24 @@
}
function onlySpecFiles(path) {
return /_specs\.js$/.test(path);
return /specs.*/.test(path);
}
window.grafanaBootData = {settings: {}};
var modules = ['lodash', 'angular', 'angular-mocks', 'app/app'];
var modules = ['angular', 'angular-mocks', 'app/app'];
var promises = modules.map(function(name) {
return System.import(name);
});
Promise.all(
modules.map(function(moduleName) {
return System.import(moduleName);
})
).then(function(deps) {
var angular = deps[1];
Promise.all(promises).then(function(deps) {
var angular = deps[0];
angular.module('grafana', ['ngRoute']);
angular.module('grafana.services', ['ngRoute', '$strap.directives']);
angular.module('grafana.panels', []);
angular.module('grafana.controllers', []);
angular.module('grafana.directives', []);
angular.module('grafana.filters', []);
angular.module('grafana.routes', ['ngRoute']);
@ -89,12 +95,15 @@
.filter(onlySpecFiles)
.map(file2moduleName)
.map(function(path) {
console.log(path);
return System.import(path);
}));
}).then(function() {
window.__karma__.start();
}, function(error) {
window.__karma__.error(error.stack || error);
}).catch(function(error) {
window.__karma__.error(error.stack || error);
});
})();

View File

@ -0,0 +1,37 @@
/**
* Declarations angular depends on for compilation to ES6.
* This file is also used to propagate our transitive typings
* to users.
*/
/// <reference path="../typings/zone/zone.d.ts"/>
/// <reference path="../typings/hammerjs/hammerjs.d.ts"/>
/// <reference path="../typings/jasmine/jasmine.d.ts"/>
/// <reference path="../typings/angular-protractor/angular-protractor.d.ts"/>
// TODO: ideally the node.d.ts reference should be scoped only for files that need and not to all
// the code including client code
/// <reference path="../typings/node/node.d.ts" />
declare var assert: any;
interface BrowserNodeGlobal {
Object: typeof Object;
Array: typeof Array;
Map: typeof Map;
Set: typeof Set;
Date: typeof Date;
RegExp: typeof RegExp;
JSON: typeof JSON;
Math: typeof Math;
assert(condition: any): void;
Reflect: any;
zone: Zone;
getAngularTestability: Function;
getAllAngularTestabilities: Function;
setTimeout: Function;
clearTimeout: Function;
setInterval: Function;
clearInterval: Function;
}

View File

@ -0,0 +1,7 @@
/**
* Declarations angular depends on for compilation to ES6.
* This file is also used to propagate our transitive typings
* to users.
*/
/// <reference path="../typings/es6-shim/es6-shim.d.ts"/>
/// <reference path="./globals-es6.d.ts"/>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,668 @@
// Type definitions for es6-shim v0.31.2
// Project: https://github.com/paulmillr/es6-shim
// Definitions by: Ron Buckton <http://github.com/rbuckton>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare type PropertyKey = string | number | symbol;
interface IteratorResult<T> {
done: boolean;
value?: T;
}
interface IterableShim<T> {
/**
* Shim for an ES6 iterable. Not intended for direct use by user code.
*/
"_es6-shim iterator_"(): Iterator<T>;
}
interface Iterator<T> {
next(value?: any): IteratorResult<T>;
return?(value?: any): IteratorResult<T>;
throw?(e?: any): IteratorResult<T>;
}
interface IterableIteratorShim<T> extends IterableShim<T>, Iterator<T> {
/**
* Shim for an ES6 iterable iterator. Not intended for direct use by user code.
*/
"_es6-shim iterator_"(): IterableIteratorShim<T>;
}
interface StringConstructor {
/**
* Return the String value whose elements are, in order, the elements in the List elements.
* If length is 0, the empty string is returned.
*/
fromCodePoint(...codePoints: number[]): string;
/**
* String.raw is intended for use as a tag function of a Tagged Template String. When called
* as such the first argument will be a well formed template call site object and the rest
* parameter will contain the substitution values.
* @param template A well-formed template string call site representation.
* @param substitutions A set of substitution values.
*/
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
}
interface String {
/**
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
* value of the UTF-16 encoded code point starting at the string element at position pos in
* the String resulting from converting this object to a String.
* If there is no element at that position, the result is undefined.
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
*/
codePointAt(pos: number): number;
/**
* Returns true if searchString appears as a substring of the result of converting this
* object to a String, at one or more positions that are
* greater than or equal to position; otherwise, returns false.
* @param searchString search string
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
*/
includes(searchString: string, position?: number): boolean;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
* same as the corresponding elements of this object (converted to a String) starting at
* endPosition length(this). Otherwise returns false.
*/
endsWith(searchString: string, endPosition?: number): boolean;
/**
* Returns a String value that is made from count copies appended together. If count is 0,
* T is the empty String is returned.
* @param count number of copies to append
*/
repeat(count: number): string;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
* same as the corresponding elements of this object (converted to a String) starting at
* position. Otherwise returns false.
*/
startsWith(searchString: string, position?: number): boolean;
/**
* Returns an <a> HTML anchor element and sets the name attribute to the text value
* @param name
*/
anchor(name: string): string;
/** Returns a <big> HTML element */
big(): string;
/** Returns a <blink> HTML element */
blink(): string;
/** Returns a <b> HTML element */
bold(): string;
/** Returns a <tt> HTML element */
fixed(): string
/** Returns a <font> HTML element and sets the color attribute value */
fontcolor(color: string): string
/** Returns a <font> HTML element and sets the size attribute value */
fontsize(size: number): string;
/** Returns a <font> HTML element and sets the size attribute value */
fontsize(size: string): string;
/** Returns an <i> HTML element */
italics(): string;
/** Returns an <a> HTML element and sets the href attribute value */
link(url: string): string;
/** Returns a <small> HTML element */
small(): string;
/** Returns a <strike> HTML element */
strike(): string;
/** Returns a <sub> HTML element */
sub(): string;
/** Returns a <sup> HTML element */
sup(): string;
/**
* Shim for an ES6 iterable. Not intended for direct use by user code.
*/
"_es6-shim iterator_"(): IterableIteratorShim<string>;
}
interface ArrayConstructor {
/**
* Creates an array from an array-like object.
* @param arrayLike An array-like object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U>(iterable: IterableShim<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
/**
* Creates an array from an array-like object.
* @param arrayLike An array-like object to convert to an array.
*/
from<T>(arrayLike: ArrayLike<T>): Array<T>;
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
from<T>(iterable: IterableShim<T>): Array<T>;
/**
* Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object.
*/
of<T>(...items: T[]): Array<T>;
}
interface Array<T> {
/**
* Returns the value of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: T) => boolean, thisArg?: any): number;
/**
* Returns the this object after filling the section identified by start and end with value
* @param value value to fill array section with
* @param start index to start filling the array at. If start is negative, it is treated as
* length+start where length is the length of the array.
* @param end index to stop filling the array at. If end is negative, it is treated as
* length+end.
*/
fill(value: T, start?: number, end?: number): T[];
/**
* Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target
* @param target If target is negative, it is treated as length+target where length is the
* length of the array.
* @param start If start is negative, it is treated as length+start. If end is negative, it
* is treated as length+end.
* @param end If not specified, length of the this object is used as its default value.
*/
copyWithin(target: number, start: number, end?: number): T[];
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIteratorShim<[number, T]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIteratorShim<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIteratorShim<T>;
/**
* Shim for an ES6 iterable. Not intended for direct use by user code.
*/
"_es6-shim iterator_"(): IterableIteratorShim<T>;
}
interface NumberConstructor {
/**
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
* that is representable as a Number value, which is approximately:
* 2.2204460492503130808472633361816 x 1016.
*/
EPSILON: number;
/**
* Returns true if passed value is finite.
* Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
* number. Only finite values of the type number, result in true.
* @param number A numeric value.
*/
isFinite(number: number): boolean;
/**
* Returns true if the value passed is an integer, false otherwise.
* @param number A numeric value.
*/
isInteger(number: number): boolean;
/**
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
* number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
* to a number. Only values of the type number, that are also NaN, result in true.
* @param number A numeric value.
*/
isNaN(number: number): boolean;
/**
* Returns true if the value passed is a safe integer.
* @param number A numeric value.
*/
isSafeInteger(number: number): boolean;
/**
* The value of the largest integer n such that n and n + 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 1.
*/
MAX_SAFE_INTEGER: number;
/**
* The value of the smallest integer n such that n and n 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is 9007199254740991 ((2^53 1)).
*/
MIN_SAFE_INTEGER: number;
/**
* Converts a string to a floating-point number.
* @param string A string that contains a floating-point number.
*/
parseFloat(string: string): number;
/**
* Converts A string to an integer.
* @param s A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
* All other strings are considered decimal.
*/
parseInt(string: string, radix?: number): number;
}
interface ObjectConstructor {
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param sources One or more source objects to copy properties from.
*/
assign(target: any, ...sources: any[]): any;
/**
* Returns true if the values are the same value, false otherwise.
* @param value1 The first value.
* @param value2 The second value.
*/
is(value1: any, value2: any): boolean;
/**
* Sets the prototype of a specified object o to object proto or null. Returns the object o.
* @param o The object to change its prototype.
* @param proto The value of the new prototype or null.
* @remarks Requires `__proto__` support.
*/
setPrototypeOf(o: any, proto: any): any;
}
interface RegExp {
/**
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
* The characters in this string are sequenced and concatenated in the following order:
*
* - "g" for global
* - "i" for ignoreCase
* - "m" for multiline
* - "u" for unicode
* - "y" for sticky
*
* If no flags are set, the value is the empty string.
*/
flags: string;
}
interface Math {
/**
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
* @param x A numeric expression.
*/
clz32(x: number): number;
/**
* Returns the result of 32-bit multiplication of two numbers.
* @param x First number
* @param y Second number
*/
imul(x: number, y: number): number;
/**
* Returns the sign of the x, indicating whether x is positive, negative or zero.
* @param x The numeric expression to test
*/
sign(x: number): number;
/**
* Returns the base 10 logarithm of a number.
* @param x A numeric expression.
*/
log10(x: number): number;
/**
* Returns the base 2 logarithm of a number.
* @param x A numeric expression.
*/
log2(x: number): number;
/**
* Returns the natural logarithm of 1 + x.
* @param x A numeric expression.
*/
log1p(x: number): number;
/**
* Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of
* the natural logarithms).
* @param x A numeric expression.
*/
expm1(x: number): number;
/**
* Returns the hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
cosh(x: number): number;
/**
* Returns the hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
sinh(x: number): number;
/**
* Returns the hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
tanh(x: number): number;
/**
* Returns the inverse hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
acosh(x: number): number;
/**
* Returns the inverse hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
asinh(x: number): number;
/**
* Returns the inverse hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
atanh(x: number): number;
/**
* Returns the square root of the sum of squares of its arguments.
* @param values Values to compute the square root for.
* If no arguments are passed, the result is +0.
* If there is only one argument, the result is the absolute value.
* If any argument is +Infinity or -Infinity, the result is +Infinity.
* If any argument is NaN, the result is NaN.
* If all arguments are either +0 or 0, the result is +0.
*/
hypot(...values: number[]): number;
/**
* Returns the integral part of the a numeric expression, x, removing any fractional digits.
* If x is already an integer, the result is x.
* @param x A numeric expression.
*/
trunc(x: number): number;
/**
* Returns the nearest single precision float representation of a number.
* @param x A numeric expression.
*/
fround(x: number): number;
/**
* Returns an implementation-dependent approximation to the cube root of number.
* @param x A numeric expression.
*/
cbrt(x: number): number;
}
interface PromiseLike<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
}
/**
* Represents the completion of an asynchronous operation
*/
interface Promise<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
catch(onrejected?: (reason: any) => void): Promise<T>;
}
interface PromiseConstructor {
/**
* A reference to the prototype.
*/
prototype: Promise<any>;
/**
* Creates a new Promise.
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
* a resolve callback used resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T>(values: IterableShim<T | PromiseLike<T>>): Promise<T[]>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
* or rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T>(values: IterableShim<T | PromiseLike<T>>): Promise<T>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject(reason: any): Promise<void>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject<T>(reason: any): Promise<T>;
/**
* Creates a new resolved promise for the provided value.
* @param value A promise.
* @returns A promise whose internal state matches the provided promise.
*/
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
/**
* Creates a new resolved promise .
* @returns A resolved promise.
*/
resolve(): Promise<void>;
}
declare var Promise: PromiseConstructor;
interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V;
has(key: K): boolean;
set(key: K, value?: V): Map<K, V>;
size: number;
entries(): IterableIteratorShim<[K, V]>;
keys(): IterableIteratorShim<K>;
values(): IterableIteratorShim<V>;
}
interface MapConstructor {
new <K, V>(): Map<K, V>;
new <K, V>(iterable: IterableShim<[K, V]>): Map<K, V>;
prototype: Map<any, any>;
}
declare var Map: MapConstructor;
interface Set<T> {
add(value: T): Set<T>;
clear(): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
has(value: T): boolean;
size: number;
entries(): IterableIteratorShim<[T, T]>;
keys(): IterableIteratorShim<T>;
values(): IterableIteratorShim<T>;
}
interface SetConstructor {
new <T>(): Set<T>;
new <T>(iterable: IterableShim<T>): Set<T>;
prototype: Set<any>;
}
declare var Set: SetConstructor;
interface WeakMap<K, V> {
delete(key: K): boolean;
get(key: K): V;
has(key: K): boolean;
set(key: K, value?: V): WeakMap<K, V>;
}
interface WeakMapConstructor {
new <K, V>(): WeakMap<K, V>;
new <K, V>(iterable: IterableShim<[K, V]>): WeakMap<K, V>;
prototype: WeakMap<any, any>;
}
declare var WeakMap: WeakMapConstructor;
interface WeakSet<T> {
add(value: T): WeakSet<T>;
delete(value: T): boolean;
has(value: T): boolean;
}
interface WeakSetConstructor {
new <T>(): WeakSet<T>;
new <T>(iterable: IterableShim<T>): WeakSet<T>;
prototype: WeakSet<any>;
}
declare var WeakSet: WeakSetConstructor;
declare module Reflect {
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
function construct(target: Function, argumentsList: ArrayLike<any>): any;
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
function enumerate(target: any): IterableIteratorShim<any>;
function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
function getPrototypeOf(target: any): any;
function has(target: any, propertyKey: PropertyKey): boolean;
function isExtensible(target: any): boolean;
function ownKeys(target: any): Array<PropertyKey>;
function preventExtensions(target: any): boolean;
function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
function setPrototypeOf(target: any, proto: any): boolean;
}
declare module "es6-shim" {
var String: StringConstructor;
var Array: ArrayConstructor;
var Number: NumberConstructor;
var Math: Math;
var Object: ObjectConstructor;
var Map: MapConstructor;
var Set: SetConstructor;
var WeakMap: WeakMapConstructor;
var WeakSet: WeakSetConstructor;
var Promise: PromiseConstructor;
module Reflect {
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
function construct(target: Function, argumentsList: ArrayLike<any>): any;
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
function enumerate(target: any): Iterator<any>;
function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
function getPrototypeOf(target: any): any;
function has(target: any, propertyKey: PropertyKey): boolean;
function isExtensible(target: any): boolean;
function ownKeys(target: any): Array<PropertyKey>;
function preventExtensions(target: any): boolean;
function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
function setPrototypeOf(target: any, proto: any): boolean;
}
}

View File

@ -0,0 +1,331 @@
// Type definitions for Hammer.js 2.0.4
// Project: http://hammerjs.github.io/
// Definitions by: Philip Bulley <https://github.com/milkisevil/>, Han Lin Yap <https://github.com/codler>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare var Hammer:HammerStatic;
declare module "Hammer" {
export = Hammer;
}
interface HammerStatic
{
new( element:HTMLElement, options?:any ): HammerManager;
defaults:HammerDefaults;
VERSION: number;
INPUT_START: number;
INPUT_MOVE: number;
INPUT_END: number;
INPUT_CANCEL: number;
STATE_POSSIBLE: number;
STATE_BEGAN: number;
STATE_CHANGED: number;
STATE_ENDED: number;
STATE_RECOGNIZED: number;
STATE_CANCELLED: number;
STATE_FAILED: number;
DIRECTION_NONE: number;
DIRECTION_LEFT: number;
DIRECTION_RIGHT: number;
DIRECTION_UP: number;
DIRECTION_DOWN: number;
DIRECTION_HORIZONTAL: number;
DIRECTION_VERTICAL: number;
DIRECTION_ALL: number;
Manager: HammerManager;
Input: HammerInput;
TouchAction: TouchAction;
TouchInput: TouchInput;
MouseInput: MouseInput;
PointerEventInput: PointerEventInput;
TouchMouseInput: TouchMouseInput;
SingleTouchInput: SingleTouchInput;
Recognizer: RecognizerStatic;
AttrRecognizer: AttrRecognizerStatic;
Tap: TapRecognizerStatic;
Pan: PanRecognizerStatic;
Swipe: SwipeRecognizerStatic;
Pinch: PinchRecognizerStatic;
Rotate: RotateRecognizerStatic;
Press: PressRecognizerStatic;
on( target:EventTarget, types:string, handler:Function ):void;
off( target:EventTarget, types:string, handler:Function ):void;
each( obj:any, iterator:Function, context:any ): void;
merge( dest:any, src:any ): any;
extend( dest:any, src:any, merge:boolean ): any;
inherit( child:Function, base:Function, properties:any ):any;
bindFn( fn:Function, context:any ):Function;
prefixed( obj:any, property:string ):string;
}
interface HammerDefaults
{
domEvents:boolean;
enable:boolean;
preset:any[];
touchAction:string;
cssProps:CssProps;
inputClass():void;
inputTarget():void;
}
interface CssProps
{
contentZooming:string;
tapHighlightColor:string;
touchCallout:string;
touchSelect:string;
userDrag:string;
userSelect:string;
}
interface HammerOptions extends HammerDefaults
{
}
interface HammerManager
{
new( element:HTMLElement, options?:any ):HammerManager;
add( recogniser:Recognizer ):Recognizer;
add( recogniser:Recognizer ):HammerManager;
add( recogniser:Recognizer[] ):Recognizer;
add( recogniser:Recognizer[] ):HammerManager;
destroy():void;
emit( event:string, data:any ):void;
get( recogniser:Recognizer ):Recognizer;
get( recogniser:string ):Recognizer;
off( events:string, handler:( event:HammerInput ) => void ):void;
on( events:string, handler:( event:HammerInput ) => void ):void;
recognize( inputData:any ):void;
remove( recogniser:Recognizer ):HammerManager;
remove( recogniser:string ):HammerManager;
set( options:HammerOptions ):HammerManager;
stop( force:boolean ):void;
}
declare class HammerInput
{
constructor( manager:HammerManager, callback:Function );
destroy():void;
handler():void;
init():void;
/** Name of the event. Like panstart. */
type:string;
/** Movement of the X axis. */
deltaX:number;
/** Movement of the Y axis. */
deltaY:number;
/** Total time in ms since the first input. */
deltaTime:number;
/** Distance moved. */
distance:number;
/** Angle moved. */
angle:number;
/** Velocity on the X axis, in px/ms. */
velocityX:number;
/** Velocity on the Y axis, in px/ms */
velocityY:number;
/** Highest velocityX/Y value. */
velocity:number;
/** Direction moved. Matches the DIRECTION constants. */
direction:number;
/** Direction moved from it's starting point. Matches the DIRECTION constants. */
offsetDirection:string;
/** Scaling that has been done when multi-touch. 1 on a single touch. */
scale:number;
/** Rotation that has been done when multi-touch. 0 on a single touch. */
rotation:number;
/** Center position for multi-touch, or just the single pointer. */
center:HammerPoint;
/** Source event object, type TouchEvent, MouseEvent or PointerEvent. */
srcEvent:TouchEvent | MouseEvent | PointerEvent;
/** Target that received the event. */
target:HTMLElement;
/** Primary pointer type, could be touch, mouse, pen or kinect. */
pointerType:string;
/** Event type, matches the INPUT constants. */
eventType:string;
/** true when the first input. */
isFirst:boolean;
/** true when the final (last) input. */
isFinal:boolean;
/** Array with all pointers, including the ended pointers (touchend, mouseup). */
pointers:any[];
/** Array with all new/moved/lost pointers. */
changedPointers:any[];
/** Reference to the srcEvent.preventDefault() method. Only for experts! */
preventDefault:Function;
}
declare class MouseInput extends HammerInput
{
constructor( manager:HammerManager, callback:Function );
}
declare class PointerEventInput extends HammerInput
{
constructor( manager:HammerManager, callback:Function );
}
declare class SingleTouchInput extends HammerInput
{
constructor( manager:HammerManager, callback:Function );
}
declare class TouchInput extends HammerInput
{
constructor( manager:HammerManager, callback:Function );
}
declare class TouchMouseInput extends HammerInput
{
constructor( manager:HammerManager, callback:Function );
}
interface RecognizerStatic
{
new( options?:any ):Recognizer;
}
interface Recognizer
{
defaults:any;
canEmit():boolean;
canRecognizeWith( otherRecognizer:Recognizer ):boolean;
dropRecognizeWith( otherRecognizer:Recognizer ):Recognizer;
dropRecognizeWith( otherRecognizer:string ):Recognizer;
dropRequireFailure( otherRecognizer:Recognizer ):Recognizer;
dropRequireFailure( otherRecognizer:string ):Recognizer;
emit( input:HammerInput ):void;
getTouchAction():any[];
hasRequireFailures():boolean;
process( inputData:HammerInput ):string;
recognize( inputData:HammerInput ):void;
recognizeWith( otherRecognizer:Recognizer ):Recognizer;
recognizeWith( otherRecognizer:string ):Recognizer;
requireFailure( otherRecognizer:Recognizer ):Recognizer;
requireFailure( otherRecognizer:string ):Recognizer;
reset():void;
set( options?:any ):Recognizer;
tryEmit( input:HammerInput ):void;
}
interface AttrRecognizerStatic
{
attrTest( input:HammerInput ):boolean;
process( input:HammerInput ):any;
}
interface AttrRecognizer extends Recognizer
{
new( options?:any ):AttrRecognizer;
}
interface PanRecognizerStatic
{
new( options?:any ):PanRecognizer;
}
interface PanRecognizer extends AttrRecognizer
{
}
interface PinchRecognizerStatic
{
new( options?:any ):PinchRecognizer;
}
interface PinchRecognizer extends AttrRecognizer
{
}
interface PressRecognizerStatic
{
new( options?:any ):PressRecognizer;
}
interface PressRecognizer extends AttrRecognizer
{
}
interface RotateRecognizerStatic
{
new( options?:any ):RotateRecognizer;
}
interface RotateRecognizer extends AttrRecognizer
{
}
interface SwipeRecognizerStatic
{
new( options?:any ):SwipeRecognizer;
}
interface SwipeRecognizer
{
}
interface TapRecognizerStatic
{
new( options?:any ):TapRecognizer;
}
interface TapRecognizer extends AttrRecognizer
{
}
declare class TouchAction
{
constructor( manager:HammerManager, value:string );
compute():string;
preventDefaults( input:HammerInput ):void;
preventSrc( srcEvent:any ):void;
set( value:string ):void;
update():void;
}
interface HammerPoint
{
x: number;
y: number;
}

View File

@ -0,0 +1,534 @@
// Type definitions for Jasmine 2.2
// Project: http://jasmine.github.io/
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Theodore Brown <https://github.com/theodorejb>, David Pärsson <https://github.com/davidparsson/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// For ddescribe / iit use : https://github.com/borisyankov/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
declare function describe(description: string, specDefinitions: () => void): void;
declare function fdescribe(description: string, specDefinitions: () => void): void;
declare function xdescribe(description: string, specDefinitions: () => void): void;
declare function it(expectation: string, assertion?: () => void, timeout?: number): void;
declare function it(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
declare function fit(expectation: string, assertion?: () => void, timeout?: number): void;
declare function fit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
declare function xit(expectation: string, assertion?: () => void, timeout?: number): void;
declare function xit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */
declare function pending(reason?: string): void;
declare function beforeEach(action: () => void, timeout?: number): void;
declare function beforeEach(action: (done: () => void) => void, timeout?: number): void;
declare function afterEach(action: () => void, timeout?: number): void;
declare function afterEach(action: (done: () => void) => void, timeout?: number): void;
declare function beforeAll(action: () => void, timeout?: number): void;
declare function beforeAll(action: (done: () => void) => void, timeout?: number): void;
declare function afterAll(action: () => void, timeout?: number): void;
declare function afterAll(action: (done: () => void) => void, timeout?: number): void;
declare function expect(spy: Function): jasmine.Matchers;
declare function expect(actual: any): jasmine.Matchers;
declare function fail(e?: any): void;
declare function spyOn(object: any, method: string): jasmine.Spy;
declare function runs(asyncMethod: Function): void;
declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void;
declare function waits(timeout?: number): void;
declare module jasmine {
var clock: () => Clock;
function any(aclass: any): Any;
function anything(): Any;
function arrayContaining(sample: any[]): ArrayContaining;
function objectContaining(sample: any): ObjectContaining;
function createSpy(name: string, originalFn?: Function): Spy;
function createSpyObj(baseName: string, methodNames: any[]): any;
function createSpyObj<T>(baseName: string, methodNames: any[]): T;
function pp(value: any): string;
function getEnv(): Env;
function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
function addMatchers(matchers: CustomMatcherFactories): void;
function stringMatching(str: string): Any;
function stringMatching(str: RegExp): Any;
interface Any {
new (expectedClass: any): any;
jasmineMatches(other: any): boolean;
jasmineToString(): string;
}
// taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
interface ArrayLike<T> {
length: number;
[n: number]: T;
}
interface ArrayContaining {
new (sample: any[]): any;
asymmetricMatch(other: any): boolean;
jasmineToString(): string;
}
interface ObjectContaining {
new (sample: any): any;
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
jasmineToString(): string;
}
interface Block {
new (env: Env, func: SpecFunction, spec: Spec): any;
execute(onComplete: () => void): void;
}
interface WaitsBlock extends Block {
new (env: Env, timeout: number, spec: Spec): any;
}
interface WaitsForBlock extends Block {
new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any;
}
interface Clock {
install(): void;
uninstall(): void;
/** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */
tick(ms: number): void;
mockDate(date?: Date): void;
}
interface CustomEqualityTester {
(first: any, second: any): boolean;
}
interface CustomMatcher {
compare<T>(actual: T, expected: T): CustomMatcherResult;
compare(actual: any, expected: any): CustomMatcherResult;
}
interface CustomMatcherFactory {
(util: MatchersUtil, customEqualityTesters: Array<CustomEqualityTester>): CustomMatcher;
}
interface CustomMatcherFactories {
[index: string]: CustomMatcherFactory;
}
interface CustomMatcherResult {
pass: boolean;
message?: string;
}
interface MatchersUtil {
equals(a: any, b: any, customTesters?: Array<CustomEqualityTester>): boolean;
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: Array<CustomEqualityTester>): boolean;
buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array<any>): string;
}
interface Env {
setTimeout: any;
clearTimeout: void;
setInterval: any;
clearInterval: void;
updateInterval: number;
currentSpec: Spec;
matchersClass: Matchers;
version(): any;
versionString(): string;
nextSpecId(): number;
addReporter(reporter: Reporter): void;
execute(): void;
describe(description: string, specDefinitions: () => void): Suite;
// ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these
beforeEach(beforeEachFunction: () => void): void;
beforeAll(beforeAllFunction: () => void): void;
currentRunner(): Runner;
afterEach(afterEachFunction: () => void): void;
afterAll(afterAllFunction: () => void): void;
xdescribe(desc: string, specDefinitions: () => void): XSuite;
it(description: string, func: () => void): Spec;
// iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these
xit(desc: string, func: () => void): XSpec;
compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean;
compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
contains_(haystack: any, needle: any): boolean;
addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
addMatchers(matchers: CustomMatcherFactories): void;
specFilter(spec: Spec): boolean;
}
interface FakeTimer {
new (): any;
reset(): void;
tick(millis: number): void;
runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
}
interface HtmlReporter {
new (): any;
}
interface HtmlSpecFilter {
new (): any;
}
interface Result {
type: string;
}
interface NestedResults extends Result {
description: string;
totalCount: number;
passedCount: number;
failedCount: number;
skipped: boolean;
rollupCounts(result: NestedResults): void;
log(values: any): void;
getItems(): Result[];
addResult(result: Result): void;
passed(): boolean;
}
interface MessageResult extends Result {
values: any;
trace: Trace;
}
interface ExpectationResult extends Result {
matcherName: string;
passed(): boolean;
expected: any;
actual: any;
message: string;
trace: Trace;
}
interface Trace {
name: string;
message: string;
stack: any;
}
interface PrettyPrinter {
new (): any;
format(value: any): void;
iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void;
emitScalar(value: any): void;
emitString(value: string): void;
emitArray(array: any[]): void;
emitObject(obj: any): void;
append(value: any): void;
}
interface StringPrettyPrinter extends PrettyPrinter {
}
interface Queue {
new (env: any): any;
env: Env;
ensured: boolean[];
blocks: Block[];
running: boolean;
index: number;
offset: number;
abort: boolean;
addBefore(block: Block, ensure?: boolean): void;
add(block: any, ensure?: boolean): void;
insertNext(block: any, ensure?: boolean): void;
start(onComplete?: () => void): void;
isRunning(): boolean;
next_(): void;
results(): NestedResults;
}
interface Matchers {
new (env: Env, actual: any, spec: Env, isNot?: boolean): any;
env: Env;
actual: any;
spec: Env;
isNot?: boolean;
message(): any;
(expected: any): boolean;
toBe(expected: any, expectationFailOutput?: any): boolean;
toEqual(expected: any, expectationFailOutput?: any): boolean;
toMatch(expected: any, expectationFailOutput?: any): boolean;
toBeDefined(expectationFailOutput?: any): boolean;
toBeUndefined(expectationFailOutput?: any): boolean;
toBeNull(expectationFailOutput?: any): boolean;
toBeNaN(): boolean;
toBeTruthy(expectationFailOutput?: any): boolean;
toBeFalsy(expectationFailOutput?: any): boolean;
toHaveBeenCalled(): boolean;
toHaveBeenCalledWith(...params: any[]): boolean;
toContain(expected: any, expectationFailOutput?: any): boolean;
toBeLessThan(expected: any, expectationFailOutput?: any): boolean;
toBeGreaterThan(expected: any, expectationFailOutput?: any): boolean;
toBeCloseTo(expected: any, precision: any, expectationFailOutput?: any): boolean;
toContainHtml(expected: string): boolean;
toContainText(expected: string): boolean;
toThrow(expected?: any): boolean;
toThrowError(expected?: any, message?: string): boolean;
not: Matchers;
Any: Any;
}
interface Reporter {
reportRunnerStarting(runner: Runner): void;
reportRunnerResults(runner: Runner): void;
reportSuiteResults(suite: Suite): void;
reportSpecStarting(spec: Spec): void;
reportSpecResults(spec: Spec): void;
log(str: string): void;
}
interface MultiReporter extends Reporter {
addReporter(reporter: Reporter): void;
}
interface Runner {
new (env: Env): any;
execute(): void;
beforeEach(beforeEachFunction: SpecFunction): void;
afterEach(afterEachFunction: SpecFunction): void;
beforeAll(beforeAllFunction: SpecFunction): void;
afterAll(afterAllFunction: SpecFunction): void;
finishCallback(): void;
addSuite(suite: Suite): void;
add(block: Block): void;
specs(): Spec[];
suites(): Suite[];
topLevelSuites(): Suite[];
results(): NestedResults;
}
interface SpecFunction {
(spec?: Spec): void;
}
interface SuiteOrSpec {
id: number;
env: Env;
description: string;
queue: Queue;
}
interface Spec extends SuiteOrSpec {
new (env: Env, suite: Suite, description: string): any;
suite: Suite;
afterCallbacks: SpecFunction[];
spies_: Spy[];
results_: NestedResults;
matchersClass: Matchers;
getFullName(): string;
results(): NestedResults;
log(arguments: any): any;
runs(func: SpecFunction): Spec;
addToQueue(block: Block): void;
addMatcherResult(result: Result): void;
expect(actual: any): any;
waits(timeout: number): Spec;
waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
fail(e?: any): void;
getMatchersClass_(): Matchers;
addMatchers(matchersPrototype: CustomMatcherFactories): void;
finishCallback(): void;
finish(onComplete?: () => void): void;
after(doAfter: SpecFunction): void;
execute(onComplete?: () => void): any;
addBeforesAndAftersToQueue(): void;
explodes(): void;
spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
removeAllSpies(): void;
}
interface XSpec {
id: number;
runs(): void;
}
interface Suite extends SuiteOrSpec {
new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any;
parentSuite: Suite;
getFullName(): string;
finish(onComplete?: () => void): void;
beforeEach(beforeEachFunction: SpecFunction): void;
afterEach(afterEachFunction: SpecFunction): void;
beforeAll(beforeAllFunction: SpecFunction): void;
afterAll(afterAllFunction: SpecFunction): void;
results(): NestedResults;
add(suiteOrSpec: SuiteOrSpec): void;
specs(): Spec[];
suites(): Suite[];
children(): any[];
execute(onComplete?: () => void): void;
}
interface XSuite {
execute(): void;
}
interface Spy {
(...params: any[]): any;
identity: string;
and: SpyAnd;
calls: Calls;
mostRecentCall: { args: any[]; };
argsForCall: any[];
wasCalled: boolean;
callCount: number;
}
interface SpyAnd {
/** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */
callThrough(): Spy;
/** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */
returnValue(val: any): void;
/** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */
callFake(fn: Function): Spy;
/** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */
throwError(msg: string): void;
/** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */
stub(): Spy;
}
interface Calls {
/** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/
any(): boolean;
/** By chaining the spy with calls.count(), will return the number of times the spy was called **/
count(): number;
/** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/
argsFor(index: number): any[];
/** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/
allArgs(): any[];
/** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/
all(): CallInfo[];
/** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/
mostRecent(): CallInfo;
/** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/
first(): CallInfo;
/** By chaining the spy with calls.reset(), will clears all tracking for a spy **/
reset(): void;
}
interface CallInfo {
/** The context (the this) for the call */
object: any;
/** All arguments passed to the call */
args: any[];
}
interface Util {
inherit(childClass: Function, parentClass: Function): any;
formatException(e: any): any;
htmlEscape(str: string): string;
argsToArray(args: any): any;
extend(destination: any, source: any): any;
}
interface JsApiReporter extends Reporter {
started: boolean;
finished: boolean;
result: any;
messages: any;
new (): any;
suites(): Suite[];
summarize_(suiteOrSpec: SuiteOrSpec): any;
results(): any;
resultsForSpec(specId: any): any;
log(str: any): any;
resultsForSpecs(specIds: any): any;
summarizeResult_(result: any): any;
}
interface Jasmine {
Spec: Spec;
clock: Clock;
util: Util;
}
export var HtmlReporter: HtmlReporter;
export var HtmlSpecFilter: HtmlSpecFilter;
export var DEFAULT_TIMEOUT_INTERVAL: number;
export interface GlobalPolluter {
describe(description: string, specDefinitions: () => void): void;
fdescribe(description: string, specDefinitions: () => void): void;
xdescribe(description: string, specDefinitions: () => void): void;
it(expectation: string, assertion?: () => void): void;
it(expectation: string, assertion?: (done: () => void) => void): void;
fit(expectation: string, assertion?: () => void): void;
fit(expectation: string, assertion?: (done: () => void) => void): void;
xit(expectation: string, assertion?: () => void): void;
xit(expectation: string, assertion?: (done: () => void) => void): void;
pending(): void;
beforeEach(action: () => void): void;
beforeEach(action: (done: () => void) => void): void;
afterEach(action: () => void): void;
afterEach(action: (done: () => void) => void): void;
beforeAll(action: () => void): void;
beforeAll(action: (done: () => void) => void): void;
afterAll(action: () => void): void;
afterAll(action: (done: () => void) => void): void;
expect(spy: Function): jasmine.Matchers;
expect(actual: any): jasmine.Matchers;
fail(e?: any): void;
spyOn(object: any, method: string): jasmine.Spy;
runs(asyncMethod: Function): void;
waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void;
waits(timeout?: number): void;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
/// <reference path="angular-protractor/angular-protractor.d.ts" />
/// <reference path="es6-shim/es6-shim.d.ts" />
/// <reference path="hammerjs/hammerjs.d.ts" />
/// <reference path="jasmine/jasmine.d.ts" />
/// <reference path="node/node.d.ts" />
/// <reference path="selenium-webdriver/selenium-webdriver.d.ts" />
/// <reference path="zone/zone.d.ts" />

View File

@ -0,0 +1,15 @@
/// <reference path="../es6-shim/es6-shim.d.ts" />
declare class Zone {
constructor(parentZone: Zone, data: any);
fork(locals: {[key: string]: any}): Zone;
bind(fn: Function, skipEnqueue?: boolean): void;
bindOnce(fn: Function): any;
run(fn: Function, applyTo?: any, applyWith?: any): void;
isRootZone(): boolean;
static bindPromiseFn<T extends () => Promise<any>>(fn: T): T;
static longStackTraceZone: {[key: string]: any};
}

View File

@ -20,7 +20,7 @@ function bootstrap() {(function(__global) {
}
return -1;
};
var defineProperty;
(function () {
try {
@ -54,7 +54,7 @@ function bootstrap() {(function(__global) {
else {
newErr = err + '\n\t' + msg;
}
return newErr;
}
@ -629,7 +629,7 @@ function logloads(loads) {
var loader = linkSet.loader;
var requests;
checkError:
checkError:
if (load) {
if (linkSet.loads[0].name == load.name) {
exc = addToError(exc, 'Error loading ' + load.name);
@ -1323,10 +1323,10 @@ var __exec;
return (wrap ? '(function(System) {' : '') + load.source + (wrap ? '\n})(System);' : '')
// adds the sourceURL comment if not already present
+ (load.source.substr(lastLineIndex, 15) != '\n//# sourceURL='
+ (load.source.substr(lastLineIndex, 15) != '\n//# sourceURL='
? '\n//# sourceURL=' + load.address + (load.metadata.sourceMap ? '!transpiled' : '') : '')
// add sourceMappingURL if load.metadata.sourceMap is set
+ (load.metadata.sourceMap && hasBtoa &&
+ (load.metadata.sourceMap && hasBtoa &&
'\n//# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(load.metadata.sourceMap))) || '')
}
@ -1407,7 +1407,7 @@ var __exec;
})();/*
SystemJS map support
Provides map configuration through
System.map['jquery'] = 'some/module/map'
@ -1445,7 +1445,7 @@ hook('normalize', function() {
if (bestMatch)
name = this.map[bestMatch] + name.substr(bestMatch.length);
}
// map is the first normalizer
return name;
};
@ -1492,8 +1492,8 @@ hookConstructor(function(constructor) {
// Default settings for globalEvaluationScope:
// Disabled for WebWorker, Chrome Extensions and jsdom
if (isWorker
|| isBrowser && window.chrome && window.chrome.extension
if (isWorker
|| isBrowser && window.chrome && window.chrome.extension
|| isBrowser && navigator.userAgent.match(/^Node\.js/))
this.globalEvaluationScope = false;
@ -1515,13 +1515,13 @@ hookConstructor(function(constructor) {
defines the `normalizeSync` function and normalizes everything into
a URL.
The final normalization
The final normalization
*/
hook('normalize', function(normalize) {
return function(name, parentName) {
// first run map config
name = normalize.apply(this, arguments);
// relative URL-normalization
if (name[0] == '.' || name[0] == '/') {
if (parentName)
@ -1559,7 +1559,7 @@ hook('fetch', function() {
/*
__useDefault
When a module object looks like:
newModule(
__useDefault: true,
@ -1665,8 +1665,8 @@ SystemJSLoader.prototype.config = function(cfg) {
// if a package main, revert it
var pkgMatch = '';
for (var pkg in this.packages) {
if (normalized.substr(0, pkg.length) == pkg
&& (!normalized[pkg.length] || normalized[pkg.length] == '/')
if (normalized.substr(0, pkg.length) == pkg
&& (!normalized[pkg.length] || normalized[pkg.length] == '/')
&& pkgMatch.split('/').length < pkg.split('/').length)
pkgMatch = pkg;
}
@ -1765,7 +1765,7 @@ SystemJSLoader.prototype.config = function(cfg) {
}
};/*
* Paths extension
*
*
* Applies paths and normalizes to a full URL
*/
hook('normalize', function(normalize) {
@ -1835,7 +1835,7 @@ hook('normalize', function(normalize) {
* // import 'package/index.js' loads in parallel package/lib/test.js,package/vendor/sizzle.js
* './index.js': ['./test'],
* './test.js': ['sizzle']
* }
* }
* }
* };
*
@ -1856,13 +1856,13 @@ hook('normalize', function(normalize) {
*
* In addition, the following modules properties will be allowed to be package
* -relative as well in the package module config:
*
*
* - loader
* - alias
*
*
* Package Configuration Loading
*
*
* Not all packages may already have their configuration present in the System config
* For these cases, a list of packageConfigPaths can be provided, which when matched against
* a request, will first request a ".json" file by the package name to derive the package
@ -1870,7 +1870,7 @@ hook('normalize', function(normalize) {
* case in SystemJS.
*
* Example:
*
*
* System.packageConfigPaths = ['packages/test/package.json', 'packages/*.json'];
*
* // will first request 'packages/new-package/package.json' for the package config
@ -1885,11 +1885,11 @@ hook('normalize', function(normalize) {
* The package name itself is taken to be the match up to and including the last wildcard
* or trailing slash.
* Package config paths are ordered - matching is done based on the first match found.
* Any existing package configurations for the package will deeply merge with the
* Any existing package configurations for the package will deeply merge with the
* package config, with the existing package configurations taking preference.
* To opt-out of the package configuration request for a package that matches
* packageConfigPaths, use the { configured: true } package config option.
*
*
*/
(function() {
@ -1918,7 +1918,7 @@ hook('normalize', function(normalize) {
function applyMap(map, name) {
var bestMatch, bestMatchLength = 0;
for (var p in map) {
if (name.substr(0, p.length) == p && (name.length == p.length || name[p.length] == '/')) {
var curMatchLength = p.split('/').length;
@ -1945,11 +1945,11 @@ hook('normalize', function(normalize) {
}
// given the package subpath, return the resultant combined path
// defaultExtension is only added if the path does not have
// defaultExtension is only added if the path does not have
// loader package meta or exact package meta
// We also re-incorporate package-level conditional syntax at this point
// allowing package map and package mains to point to conditionals
// when conditionals are present,
// when conditionals are present,
function toPackagePath(loader, pkgName, pkg, basePath, subPath, sync, isPlugin) {
// skip if its a plugin call already, or we have boolean / interpolation conditional syntax in subPath
var skipExtension = !!(isPlugin || subPath.indexOf('#?') != -1 || subPath.match(interpolationRegEx));
@ -2013,7 +2013,7 @@ hook('normalize', function(normalize) {
return toPackagePath(loader, pkgName, pkg, basePath, mapped.substr(2), sync, isPlugin);
// global package map
else
return (sync ? loader.normalizeSync : loader.normalize).call(loader, mapped);
return (sync ? loader.normalizeSync : loader.normalize).call(loader, mapped);
}
// apply non-environment map match
@ -2041,7 +2041,7 @@ hook('normalize', function(normalize) {
if (!negate && value || negate && !value)
return mapped[e] + subPath.substr(map.length);
}
}
})
.then(function(mapped) {
// no environment match
@ -2055,11 +2055,11 @@ hook('normalize', function(normalize) {
function createPackageNormalize(normalize, sync) {
return function(name, parentName, isPlugin) {
isPlugin = isPlugin === true;
// apply contextual package map first
if (parentName)
var parentPackage = getPackage.call(this, parentName) ||
this.defaultJSExtensions && parentName.substr(parentName.length - 3, 3) == '.js' &&
var parentPackage = getPackage.call(this, parentName) ||
this.defaultJSExtensions && parentName.substr(parentName.length - 3, 3) == '.js' &&
getPackage.call(this, parentName.substr(0, parentName.length - 3));
if (parentPackage) {
@ -2144,7 +2144,7 @@ hook('normalize', function(normalize) {
return pkgBundleLoads.promise;
}
})
// having loaded any bundles, attempt a package resolution now
.then(function() {
return packageResolution(normalized, pkgConfigMatch.pkgName);
@ -2177,7 +2177,7 @@ hook('normalize', function(normalize) {
for (var i = 0; i < loader.packageConfigPaths.length; i++) {
var p = loader.packageConfigPaths[i];
var pPkgLen = Math.max(p.lastIndexOf('*') + 1, p.lastIndexOf('/'));
var match = normalized.match(packageConfigPathsRegExps[p] ||
var match = normalized.match(packageConfigPathsRegExps[p] ||
(packageConfigPathsRegExps[p] = new RegExp('^(' + p.substr(0, pPkgLen).replace(/\*/g, '[^\\/]+') + ')(\/|$)')));
if (match && (!pkgPath || pkgPath == match[1])) {
pkgPath = match[1];
@ -2299,7 +2299,7 @@ hook('normalize', function(normalize) {
var pkg = loader.packages[pkgName];
var basePath = getBasePath(pkg);
var subPath = load.name.substr(pkgName.length + basePath.length + 1);
// format
if (pkg.format)
load.metadata.format = load.metadata.format || pkg.format;
@ -2353,7 +2353,7 @@ hook('normalize', function(normalize) {
// if doing worker executing, this is set to the load record being executed
var workerLoad = null;
// interactive mode handling method courtesy RequireJS
var ieEvents = head && (function() {
var s = document.createElement('script');
@ -2375,7 +2375,7 @@ hook('normalize', function(normalize) {
return interactiveScript.load;
}
}
// System.register, System.registerDynamic, AMD define pipeline
// this is called by the above methods when they execute
// we then run the reduceRegister_ collection function either immediately
@ -2450,9 +2450,9 @@ hook('normalize', function(normalize) {
return new Promise(function(resolve, reject) {
var s = document.createElement('script');
s.async = true;
if (load.metadata.integrity)
s.setAttribute('integrity', load.metadata.integrity);
@ -2541,7 +2541,7 @@ hook('normalize', function(normalize) {
*
*
* The code here replicates the ES6 linking groups algorithm to ensure that
* circular ES6 compiled into System.register can work alongside circular AMD
* circular ES6 compiled into System.register can work alongside circular AMD
* and CommonJS, identically to the actual ES6 loader.
*
*/
@ -2551,7 +2551,7 @@ hook('normalize', function(normalize) {
* Registry side table entries in loader.defined
* Registry Entry Contains:
* - name
* - deps
* - deps
* - declare for declarative modules
* - execute for dynamic modules, different to declarative execute on module
* - executingRequire indicates require drives execution for circularity of dynamic modules
@ -2569,7 +2569,7 @@ hook('normalize', function(normalize) {
* For dynamic we track the es module with:
* - esModule actual es module value
* - esmExports whether to extend the esModule with named exports
*
*
* Then for declarative only we track dynamic bindings with the 'module' records:
* - name
* - exports
@ -2606,7 +2606,7 @@ function createEntry() {
* see https://github.com/ModuleLoader/es6-module-loader/wiki/System.register-Explained
*
* 2. System.registerDynamic for dynamic modules (3-4 params) - System.registerDynamic([name, ]deps, executingRequire, execute)
* the true or false statement
* the true or false statement
*
* this extension implements the linking algorithm for the two variations identical to the spec
* allowing compiled ES6 circular references to work alongside AMD and CJS circular references.
@ -2625,7 +2625,7 @@ function createEntry() {
return this.registerDynamic.apply(this, arguments);
var entry = createEntry();
// ideally wouldn't apply map config to bundle names but
// ideally wouldn't apply map config to bundle names but
// dependencies go through map regardless so we can't restrict
// could reconsider in shift to new spec
entry.name = name && (this.normalizeSync || this.normalize).call(this, name);
@ -2711,17 +2711,17 @@ function createEntry() {
for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
var depName = entry.normalizedDeps[i];
var depEntry = loader.defined[depName];
// not in the registry means already linked / ES6
if (!depEntry || depEntry.evaluated)
continue;
// now we know the entry is in our unlinked linkage group
var depGroupIndex = entry.groupIndex + (depEntry.declarative != entry.declarative);
// the group index of an entry is always the maximum
if (depEntry.groupIndex === null || depEntry.groupIndex < depGroupIndex) {
// if already in a group, remove from the old group
if (depEntry.groupIndex !== null) {
groups[depEntry.groupIndex].splice(indexOf.call(groups[depEntry.groupIndex], depEntry), 1);
@ -2763,7 +2763,7 @@ function createEntry() {
else
linkDynamicModule(entry, loader);
}
curGroupDeclarative = !curGroupDeclarative;
curGroupDeclarative = !curGroupDeclarative;
}
}
@ -2815,7 +2815,7 @@ function createEntry() {
module.locked = false;
return value;
});
module.setters = declaration.setters;
module.execute = declaration.execute;
@ -2858,7 +2858,7 @@ function createEntry() {
else {
module.dependencies.push(null);
}
// run setters for all entries with the matching dependency name
var originalIndices = entry.originalIndices[i];
for (var j = 0, len = originalIndices.length; j < len; ++j) {
@ -2884,7 +2884,7 @@ function createEntry() {
else {
if (entry.declarative)
ensureEvaluated(name, [], loader);
else if (!entry.evaluated)
linkDynamicModule(entry, loader);
@ -2893,7 +2893,7 @@ function createEntry() {
if ((!entry || entry.declarative) && exports && exports.__useDefault)
return exports['default'];
return exports;
}
@ -2926,7 +2926,7 @@ function createEntry() {
}
throw new Error('Module ' + name + ' not declared as a dependency.');
}, exports, module);
if (output)
module.exports = output;
@ -2950,7 +2950,7 @@ function createEntry() {
* (unless one is a circular dependency already in the list of seen
* modules, in which case we execute it)
*
* Then we evaluate the module itself depth-first left to right
* Then we evaluate the module itself depth-first left to right
* execution to match ES6 modules
*/
function ensureEvaluated(moduleName, seen, loader) {
@ -3002,12 +3002,12 @@ function createEntry() {
load.metadata.format = 'defined';
return '';
}
if (load.metadata.format == 'register' && !load.metadata.authorization && load.metadata.scriptLoad !== false)
load.metadata.scriptLoad = true;
load.metadata.deps = load.metadata.deps || [];
return fetch.call(this, load);
};
});
@ -3046,9 +3046,9 @@ function createEntry() {
// Contains System.register calls
// (dont run bundles in the builder)
else if (!(loader.builder && load.metadata.bundle)
else if (!(loader.builder && load.metadata.bundle)
&& (load.metadata.format == 'register' || load.metadata.format == 'esm' || load.metadata.format == 'es6')) {
if (typeof __exec != 'undefined')
__exec.call(loader, load);
@ -3071,9 +3071,9 @@ function createEntry() {
// place this module onto defined for circular references
loader.defined[load.name] = entry;
var grouped = group(entry.deps);
entry.deps = grouped.names;
entry.originalIndices = grouped.indices;
entry.name = load.name;
@ -3091,7 +3091,7 @@ function createEntry() {
return {
deps: entry.deps,
execute: function() {
// recursively ensure that the module and all its
// recursively ensure that the module and all its
// dependencies are linked (with dependency group handling)
link(load.name, loader);
@ -3236,7 +3236,7 @@ hook('fetch', function(fetch) {
// A global with exports, no globals and no deps
// can be loaded via a script tag
if (load.metadata.format == 'global' && !load.metadata.authorization
&& load.metadata.exports && !load.metadata.globals
&& load.metadata.exports && !load.metadata.globals
&& (!load.metadata.deps || load.metadata.deps.length == 0)
&& load.metadata.scriptLoad !== false)
load.metadata.scriptLoad = true;
@ -3289,7 +3289,7 @@ hook('instantiate', function(instantiate) {
for (var g in load.metadata.globals)
globals[g] = require(load.metadata.globals[g]);
}
var exportName = load.metadata.exports;
if (exportName)
@ -3346,7 +3346,7 @@ hookConstructor(function(constructor) {
prepareGlobal: function(moduleName, exportName, globals) {
// disable module detection
var curDefine = __global.define;
__global.define = undefined;
__global.exports = undefined;
if (__global.module && __global.module.exports)
@ -3434,7 +3434,7 @@ hookConstructor(function(constructor) {
var match;
// track string and comment locations for unminified source
// track string and comment locations for unminified source
var stringLocations = [], commentLocations = [];
function inLocation(locations, match, starts) {
@ -3448,7 +3448,7 @@ hookConstructor(function(constructor) {
if (source.length / source.split('\n').length < 200) {
while (match = stringRegEx.exec(source))
stringLocations.push([match.index, match.index + match[0].length]);
while (match = commentRegEx.exec(source)) {
// only track comments not starting in strings
if (!inLocation(stringLocations, match, true))
@ -3472,9 +3472,9 @@ hookConstructor(function(constructor) {
if (typeof require != 'undefined' && require.resolve && typeof process != 'undefined')
SystemJSLoader.prototype._nodeRequire = require;
var nodeCoreModules = ['assert', 'buffer', 'child_process', 'cluster', 'console', 'constants',
'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'module', 'net', 'os', 'path',
'process', 'punycode', 'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'sys', 'timers',
var nodeCoreModules = ['assert', 'buffer', 'child_process', 'cluster', 'console', 'constants',
'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'module', 'net', 'os', 'path',
'process', 'punycode', 'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'sys', 'timers',
'tls', 'tty', 'url', 'util', 'vm', 'zlib'];
hook('normalize', function(normalize) {
@ -3582,7 +3582,7 @@ hookConstructor(function(constructor) {
var cjsRequirePost = "\\s*\\(\\s*(\"([^\"]+)\"|'([^']+)')\\s*\\)";
var fnBracketRegEx = /\(([^\)]*)\)/;
var wsRegEx = /^\s+|\s+$/g;
var requireRegExs = {};
function getCJSDeps(source, requireIndex) {
@ -3664,9 +3664,9 @@ hookConstructor(function(constructor) {
// remove system dependencies
var requireIndex, exportsIndex, moduleIndex;
if ((requireIndex = indexOf.call(deps, 'require')) != -1) {
deps.splice(requireIndex, 1);
// only trace cjs requires for non-named
@ -3677,7 +3677,7 @@ hookConstructor(function(constructor) {
if ((exportsIndex = indexOf.call(deps, 'exports')) != -1)
deps.splice(exportsIndex, 1);
if ((moduleIndex = indexOf.call(deps, 'module')) != -1)
deps.splice(moduleIndex, 1);
@ -3693,10 +3693,10 @@ hookConstructor(function(constructor) {
// add back in system dependencies
if (moduleIndex != -1)
depValues.splice(moduleIndex, 0, module);
if (exportsIndex != -1)
depValues.splice(exportsIndex, 0, exports);
if (requireIndex != -1) {
function contextualRequire(names, callback, errback) {
if (typeof names == 'string' && typeof callback != 'function')
@ -3762,12 +3762,12 @@ hookConstructor(function(constructor) {
// already defined anonymously -> throw
if (curMeta.entry)
throw new TypeError('Multiple defines for anonymous module ' + load.name);
curMeta.entry = entry;
}
// named define
else {
// if we don't have any other defines,
// if we don't have any other defines,
// then let this be an anonymous define
// this is just to support single modules of the form:
// define('jquery')
@ -3830,8 +3830,8 @@ hookConstructor(function(constructor) {
hook('fetch', function(fetch) {
return function(load) {
if (load.metadata.format === 'amd'
&& !load.metadata.authorization
if (load.metadata.format === 'amd'
&& !load.metadata.authorization
&& load.metadata.scriptLoad !== false)
load.metadata.scriptLoad = true;
// script load implies define global leak
@ -3844,10 +3844,10 @@ hookConstructor(function(constructor) {
hook('instantiate', function(instantiate) {
return function(load) {
var loader = this;
if (load.metadata.format == 'amd' || !load.metadata.format && load.source.match(amdRegEx)) {
load.metadata.format = 'amd';
if (!loader.builder && loader.execute !== false) {
var removeDefine = this.get('@@amd-helpers').createDefine();
@ -4094,13 +4094,13 @@ hookConstructor(function(constructor) {
*
* import $ from 'jquery/#{browser}';
*
* Will first load the module 'browser' via `System.import('browser')` and
* Will first load the module 'browser' via `System.import('browser')` and
* take the default export of that module.
* If the default export is not a string, an error is thrown.
*
*
* We then substitute the string into the require to get the conditional resolution
* enabling environment-specific variations like:
*
*
* import $ from 'jquery/ie'
* import $ from 'jquery/firefox'
* import $ from 'jquery/chrome'
@ -4122,7 +4122,7 @@ hookConstructor(function(constructor) {
* import 'es5-shim#?./conditions.js|needs-es5shim'
*
* These conditions can also be negated via:
*
*
* import 'es5-shim#?~./conditions.js|es6'
*
*/
@ -4429,7 +4429,7 @@ hookConstructor(function(constructor) {
/*
System bundles
Allows a bundle module to be specified which will be dynamically
Allows a bundle module to be specified which will be dynamically
loaded before trying to load a given module.
For example:
@ -4497,10 +4497,10 @@ function getBundleFor(loader, name) {
})();
/*
* Dependency Tree Cache
*
* Allows a build to pre-populate a dependency trace tree on the loader of
*
* Allows a build to pre-populate a dependency trace tree on the loader of
* the expected dependency tree, to be loaded upfront when requesting the
* module, avoinding the n round trips latency of module loading, where
* module, avoinding the n round trips latency of module loading, where
* n is the dependency tree depth.
*
* eg:
@ -4509,8 +4509,8 @@ function getBundleFor(loader, name) {
* 'normalized': ['another'],
* 'deps': ['tree']
* };
*
* System.import('app')
*
* System.import('app')
* // simultaneously starts loading all of:
* // 'normalized', 'deps', 'another', 'tree'
* // before "app" source is even loaded
@ -4537,7 +4537,7 @@ function getBundleFor(loader, name) {
};
});
})();
System = new SystemJSLoader();
System.version = '0.19.6 Standard';
// -- exporting --
@ -4602,4 +4602,4 @@ else {
}
})();
})();

View File

@ -21,6 +21,8 @@ module.exports = function(config) {
src: [
'angular2/bundles/*.js',
'angular2/*.d.ts',
'angular2/typings/**/*',
'angular2/manual_typings/**/*',
'systemjs/dist/*.js',
'es6-promise/**/*',
'es5-shim/*.js',

View File

@ -6,14 +6,17 @@ module.exports = function(config) {
configFile: 'karma.conf.js',
singleRun: false,
},
debug: {
configFile: 'karma.conf.js',
singleRun: false,
browsers: ['Chrome']
},
test: {
configFile: 'karma.conf.js',
},
coveralls: {
configFile: 'karma.conf.js',
reporters: ['dots','coverage','coveralls'],

View File

@ -3,7 +3,7 @@ module.exports = function() {
return {
build: {
src: ['public/app/**/*.ts', "!public/vendor/**/*", "!**/*_specs.ts", "!**/*.d.ts"],
src: ['public/app/**/*.ts', "!public/vendor/**/*", "!**/*.d.ts"],
dest: 'public_gen/',
options: {
module: 'system', //or commonjs