chore(build): Remove .es6 files which shadow .ts files.
This removes .es6 files which are pure duplicates of a .ts file in the same folder. Next we need to remove .js files as well, and remove karma preprocessors for dart.
This commit is contained in:
parent
c1579222bd
commit
3c77855b39
|
@ -568,7 +568,7 @@ gulp.task('build.js.cjs', ['build.tools'], function() {
|
|||
var bundleConfig = {
|
||||
paths: {
|
||||
"*": "dist/js/prod/es6/*.es6",
|
||||
"rx/*": "node_modules/rx/*.js"
|
||||
"rx": "node_modules/rx/dist/rx.js"
|
||||
},
|
||||
meta: {
|
||||
// auto-detection fails to detect properly here - https://github.com/systemjs/builder/issues/123
|
||||
|
|
|
@ -61,13 +61,14 @@ module.exports = function(config) {
|
|||
|
||||
preprocessors: {
|
||||
'modules/**/*.js': ['ts2dart'],
|
||||
'modules/angular2/src/reflection/reflector.ts': ['ts2dart'],
|
||||
'tools/**/*.js': ['ts2dart']
|
||||
},
|
||||
|
||||
ts2dartPreprocessor: {
|
||||
resolveModuleName: file2moduleName,
|
||||
transformPath: function(fileName) {
|
||||
return fileName.replace(/.js$/, '.dart');
|
||||
return fileName.replace(/\.(js|ts)$/, '.dart');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = function(config) {
|
|||
'node_modules/systemjs/dist/system.src.js',
|
||||
'node_modules/systemjs/lib/extension-register.js',
|
||||
'node_modules/systemjs/lib/extension-cjs.js',
|
||||
'node_modules/rx/dist/rx.all.js',
|
||||
'node_modules/rx/dist/rx.js',
|
||||
'node_modules/reflect-metadata/Reflect.js',
|
||||
'node_modules/zone.js/zone.js',
|
||||
'node_modules/zone.js/long-stack-trace-zone.js',
|
||||
|
|
|
@ -1,126 +0,0 @@
|
|||
import {int, global, isPresent} from 'angular2/src/facade/lang';
|
||||
import {List} from 'angular2/src/facade/collection';
|
||||
import Rx from 'rx/dist/rx.all';
|
||||
|
||||
export var Promise = global.Promise;
|
||||
|
||||
export class PromiseWrapper {
|
||||
static resolve(obj):Promise {
|
||||
return Promise.resolve(obj);
|
||||
}
|
||||
|
||||
static reject(obj):Promise {
|
||||
return Promise.reject(obj);
|
||||
}
|
||||
|
||||
// Note: We can't rename this method into `catch`, as this is not a valid
|
||||
// method name in Dart.
|
||||
static catchError(promise:Promise, onError:Function):Promise {
|
||||
return promise.catch(onError);
|
||||
}
|
||||
|
||||
static all(promises:List):Promise {
|
||||
if (promises.length == 0) return Promise.resolve([]);
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
static then(promise:Promise, success:Function, rejection:Function):Promise {
|
||||
return promise.then(success, rejection);
|
||||
}
|
||||
|
||||
static completer() {
|
||||
var resolve;
|
||||
var reject;
|
||||
|
||||
var p = new Promise(function(res, rej) {
|
||||
resolve = res;
|
||||
reject = rej;
|
||||
});
|
||||
|
||||
return {
|
||||
promise: p,
|
||||
resolve: resolve,
|
||||
reject: reject
|
||||
};
|
||||
}
|
||||
|
||||
static setTimeout(fn:Function, millis:int) {
|
||||
global.setTimeout(fn, millis);
|
||||
}
|
||||
|
||||
static isPromise(maybePromise):boolean {
|
||||
return maybePromise instanceof Promise;
|
||||
}
|
||||
}
|
||||
|
||||
export class ObservableWrapper {
|
||||
static subscribe(emitter:EventEmitter, onNext, onThrow = null, onReturn = null) {
|
||||
return emitter.observer({next: onNext, throw: onThrow, return: onReturn});
|
||||
}
|
||||
|
||||
static dispose(subscription:any) {
|
||||
subscription.dispose();
|
||||
}
|
||||
|
||||
static isObservable(obs):boolean {
|
||||
return obs instanceof Observable;
|
||||
}
|
||||
|
||||
static callNext(emitter:EventEmitter, value:any) {
|
||||
emitter.next(value);
|
||||
}
|
||||
|
||||
static callThrow(emitter:EventEmitter, error:any) {
|
||||
emitter.throw(error);
|
||||
}
|
||||
|
||||
static callReturn(emitter:EventEmitter) {
|
||||
emitter.return();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: vsavkin change to interface
|
||||
export class Observable {
|
||||
observer(generator:Function){}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use Rx.Observable but provides an adapter to make it work as specified here:
|
||||
* https://github.com/jhusain/observable-spec
|
||||
*
|
||||
* Once a reference implementation of the spec is available, switch to it.
|
||||
*/
|
||||
export class EventEmitter extends Observable {
|
||||
_subject:Rx.Subject;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._subject = new Rx.Subject();
|
||||
}
|
||||
|
||||
observer(generator) {
|
||||
// Rx.Scheduler.immediate and setTimeout is a workaround, so Rx works with zones.js.
|
||||
// Once https://github.com/angular/zone.js/issues/51 is fixed, the hack should be removed.
|
||||
return this._subject.observeOn(Rx.Scheduler.immediate).subscribe(
|
||||
(value) => {setTimeout(() => generator.next(value));},
|
||||
(error) => generator.throw ? generator.throw(error) : null,
|
||||
() => generator.return ? generator.return() : null
|
||||
);
|
||||
}
|
||||
|
||||
toRx():Rx.Observable {
|
||||
return this._subject;
|
||||
}
|
||||
|
||||
next(value) {
|
||||
this._subject.onNext(value);
|
||||
}
|
||||
|
||||
throw(error) {
|
||||
this._subject.onError(error);
|
||||
}
|
||||
|
||||
return(value) {
|
||||
this._subject.onCompleted();
|
||||
}
|
||||
}
|
|
@ -78,15 +78,23 @@ export class Observable {
|
|||
*/
|
||||
export class EventEmitter extends Observable {
|
||||
_subject: Rx.Subject<any>;
|
||||
_immediateScheduler;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._subject = new Rx.Subject<any>();
|
||||
|
||||
// System creates a different object for import * than Typescript es5 emit.
|
||||
if (Rx.hasOwnProperty('default')) {
|
||||
this._subject = new (<any>Rx).default.Rx.Subject();
|
||||
this._immediateScheduler = (<any>Rx).default.Rx.Scheduler.immediate;
|
||||
} else {
|
||||
this._subject = new Rx.Subject<any>();
|
||||
this._immediateScheduler = (<any>Rx.Scheduler).immediate;
|
||||
}
|
||||
}
|
||||
|
||||
observer(generator) {
|
||||
var immediateScheduler = (<any>Rx.Scheduler).immediate;
|
||||
return this._subject.observeOn(immediateScheduler)
|
||||
return this._subject.observeOn(this._immediateScheduler)
|
||||
.subscribe((value) => { setTimeout(() => generator.next(value)); },
|
||||
(error) => generator.throw ? generator.throw(error) : null,
|
||||
() => generator.return ? generator.return () : null);
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
/**
|
||||
* JS version of browser APIs. This library can only run in the browser.
|
||||
*/
|
||||
|
||||
var win = window;
|
||||
|
||||
export {win as window};
|
||||
export var document = window.document;
|
||||
export var location = window.location;
|
||||
export var gc = window.gc ? () => window.gc() : () => null;
|
||||
export {Event as Event};
|
||||
export {MouseEvent as MouseEvent};
|
||||
export {KeyboardEvent as KeyboardEvent};
|
|
@ -1,231 +0,0 @@
|
|||
import {int, isJsObject, global} from 'angular2/src/facade/lang';
|
||||
|
||||
export var List = global.Array;
|
||||
export var Map = global.Map;
|
||||
export var Set = global.Set;
|
||||
export var StringMap = global.Object;
|
||||
|
||||
export class MapWrapper {
|
||||
static create():Map { return new Map(); }
|
||||
static clone(m:Map):Map { return new Map(m); }
|
||||
static createFromStringMap(stringMap):Map {
|
||||
var result = MapWrapper.create();
|
||||
for (var prop in stringMap) {
|
||||
MapWrapper.set(result, prop, stringMap[prop]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
static createFromPairs(pairs:List):Map {return new Map(pairs);}
|
||||
static get(m, k) { return m.get(k); }
|
||||
static set(m, k, v) { m.set(k,v); }
|
||||
static contains(m, k) { return m.has(k); }
|
||||
static forEach(m, fn) {
|
||||
m.forEach(fn);
|
||||
}
|
||||
static size(m) {return m.size;}
|
||||
static delete(m, k) { m.delete(k); }
|
||||
static clear(m) { m.clear(); }
|
||||
static clearValues(m) {
|
||||
var keyIterator = m.keys();
|
||||
var k;
|
||||
while (!((k = keyIterator.next()).done)) {
|
||||
m.set(k.value, null);
|
||||
}
|
||||
}
|
||||
static iterable(m) { return m; }
|
||||
static keys(m) { return m.keys(); }
|
||||
static values(m) { return m.values(); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps Javascript Objects
|
||||
*/
|
||||
export class StringMapWrapper {
|
||||
static create():Object {
|
||||
// Note: We are not using Object.create(null) here due to
|
||||
// performance!
|
||||
// http://jsperf.com/ng2-object-create-null
|
||||
return { };
|
||||
}
|
||||
static contains(map, key) {
|
||||
return map.hasOwnProperty(key);
|
||||
}
|
||||
static get(map, key) {
|
||||
return map.hasOwnProperty(key) ? map[key] : undefined;
|
||||
}
|
||||
static set(map, key, value) {
|
||||
map[key] = value;
|
||||
}
|
||||
static isEmpty(map) {
|
||||
for (var prop in map) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static delete(map, key) { delete map[key]; }
|
||||
static forEach(map, callback) {
|
||||
for (var prop in map) {
|
||||
if (map.hasOwnProperty(prop)) {
|
||||
callback(map[prop], prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static merge(m1, m2) {
|
||||
var m = {};
|
||||
|
||||
for (var attr in m1) {
|
||||
if (m1.hasOwnProperty(attr)){
|
||||
m[attr] = m1[attr];
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in m2) {
|
||||
if (m2.hasOwnProperty(attr)){
|
||||
m[attr] = m2[attr];
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
export class ListWrapper {
|
||||
static create():List { return new List(); }
|
||||
static createFixedSize(size):List { return new List(size); }
|
||||
static get(m, k) { return m[k]; }
|
||||
static set(m, k, v) { m[k] = v; }
|
||||
static clone(array:List) {
|
||||
return array.slice(0);
|
||||
}
|
||||
static map(array, fn) {
|
||||
return array.map(fn);
|
||||
}
|
||||
static forEach(array:List, fn:Function) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
fn(array[i]);
|
||||
}
|
||||
}
|
||||
static push(array, el) {
|
||||
array.push(el);
|
||||
}
|
||||
static first(array) {
|
||||
if (!array) return null;
|
||||
return array[0];
|
||||
}
|
||||
static last(array) {
|
||||
if (!array || array.length == 0) return null;
|
||||
return array[array.length - 1];
|
||||
}
|
||||
static find(list:List, pred:Function) {
|
||||
for (var i = 0 ; i < list.length; ++i) {
|
||||
if (pred(list[i])) return list[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
static reduce(list:List, fn:Function, init) {
|
||||
return list.reduce(fn, init);
|
||||
}
|
||||
static filter(array, pred:Function) {
|
||||
return array.filter(pred);
|
||||
}
|
||||
static indexOf(array, value, startIndex = -1) {
|
||||
return array.indexOf(value, startIndex);
|
||||
}
|
||||
static any(list:List, pred:Function) {
|
||||
for (var i = 0 ; i < list.length; ++i) {
|
||||
if (pred(list[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static contains(list:List, el) {
|
||||
return list.indexOf(el) !== -1;
|
||||
}
|
||||
static reversed(array) {
|
||||
var a = ListWrapper.clone(array);
|
||||
return a.reverse();
|
||||
}
|
||||
static concat(a, b) {return a.concat(b);}
|
||||
static isList(list) {
|
||||
return Array.isArray(list);
|
||||
}
|
||||
static insert(list, index:int, value) {
|
||||
list.splice(index, 0, value);
|
||||
}
|
||||
static removeAt(list, index:int) {
|
||||
var res = list[index];
|
||||
list.splice(index, 1);
|
||||
return res;
|
||||
}
|
||||
static removeAll(list, items) {
|
||||
for (var i = 0; i < items.length; ++i) {
|
||||
var index = list.indexOf(items[i]);
|
||||
list.splice(index, 1);
|
||||
}
|
||||
}
|
||||
static removeLast(list:List) {
|
||||
return list.pop();
|
||||
}
|
||||
static remove(list, el): boolean {
|
||||
var index = list.indexOf(el);
|
||||
if (index > -1) {
|
||||
list.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static clear(list) {
|
||||
list.splice(0, list.length);
|
||||
}
|
||||
static join(list, s) {
|
||||
return list.join(s);
|
||||
}
|
||||
static isEmpty(list) {
|
||||
return list.length == 0;
|
||||
}
|
||||
static fill(list:List, value, start:int = 0, end:int = null) {
|
||||
list.fill(value, start, end === null ? undefined : end);
|
||||
}
|
||||
static equals(a:List, b:List):boolean {
|
||||
if(a.length != b.length) return false;
|
||||
for (var i = 0; i < a.length; ++i) {
|
||||
if (a[i] !== b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static slice(l:List, from:int = 0, to:int = null):List {
|
||||
return l.slice(from, to === null ? undefined : to);
|
||||
}
|
||||
static splice(l:List, from:int, length:int):List {
|
||||
return l.splice(from, length);
|
||||
}
|
||||
static sort(l:List, compareFn:Function) {
|
||||
l.sort(compareFn);
|
||||
}
|
||||
}
|
||||
|
||||
export function isListLikeIterable(obj):boolean {
|
||||
if (!isJsObject(obj)) return false;
|
||||
return ListWrapper.isList(obj) ||
|
||||
(!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
|
||||
Symbol.iterator in obj); // JS Iterable have a Symbol.iterator prop
|
||||
}
|
||||
|
||||
export function iterateListLike(obj, fn:Function) {
|
||||
if (ListWrapper.isList(obj)) {
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
fn(obj[i]);
|
||||
}
|
||||
} else {
|
||||
var iterator = obj[Symbol.iterator]();
|
||||
var item;
|
||||
while (!((item = iterator.next()).done)) {
|
||||
fn(item.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class SetWrapper {
|
||||
static createFromList(lst:List) { return new Set(lst); }
|
||||
static has(s:Set, key):boolean { return s.has(key); }
|
||||
}
|
|
@ -1,278 +0,0 @@
|
|||
var _global = typeof window === 'undefined' ? global : window;
|
||||
export {_global as global};
|
||||
|
||||
export var Type = Function;
|
||||
export var Math = _global.Math;
|
||||
export var Date = _global.Date;
|
||||
|
||||
var assertionsEnabled_ = typeof assert !== 'undefined';
|
||||
|
||||
var int;
|
||||
// global assert support, as Dart has it...
|
||||
// TODO: `assert` calls need to be removed in production code!
|
||||
if (assertionsEnabled_) {
|
||||
_global.assert = assert;
|
||||
// `int` is not a valid JS type
|
||||
int = assert.define('int', function(value) {
|
||||
return typeof value === 'number' && value%1 === 0;
|
||||
});
|
||||
} else {
|
||||
int = {};
|
||||
_global.assert = function() {};
|
||||
}
|
||||
export {int};
|
||||
|
||||
export class CONST {}
|
||||
export class ABSTRACT {}
|
||||
export class IMPLEMENTS {}
|
||||
|
||||
export function isPresent(obj):boolean {
|
||||
return obj !== undefined && obj !== null;
|
||||
}
|
||||
|
||||
export function isBlank(obj):boolean {
|
||||
return obj === undefined || obj === null;
|
||||
}
|
||||
|
||||
export function isString(obj):boolean {
|
||||
return typeof obj === "string";
|
||||
}
|
||||
|
||||
export function isFunction(obj):boolean {
|
||||
return typeof obj === "function";
|
||||
}
|
||||
|
||||
export function isType(obj):boolean {
|
||||
return isFunction(obj);
|
||||
}
|
||||
|
||||
export function stringify(token):string {
|
||||
if (typeof token === 'string') {
|
||||
return token;
|
||||
}
|
||||
|
||||
if (token === undefined || token === null) {
|
||||
return '' + token;
|
||||
}
|
||||
|
||||
if (token.name) {
|
||||
return token.name;
|
||||
}
|
||||
|
||||
return token.toString();
|
||||
}
|
||||
|
||||
export class StringWrapper {
|
||||
static fromCharCode(code:int):string {
|
||||
return String.fromCharCode(code);
|
||||
}
|
||||
|
||||
static charCodeAt(s:string, index:int) {
|
||||
return s.charCodeAt(index);
|
||||
}
|
||||
|
||||
static split(s:string, regExp) {
|
||||
return s.split(regExp);
|
||||
}
|
||||
|
||||
static equals(s:string, s2:string):boolean {
|
||||
return s === s2;
|
||||
}
|
||||
|
||||
static replace(s:string, from: string, replace:string): string {
|
||||
return s.replace(from, replace);
|
||||
}
|
||||
|
||||
static replaceAll(s:string, from:RegExp, replace:string):string {
|
||||
return s.replace(from, replace);
|
||||
}
|
||||
|
||||
static startsWith(s:string, start:string) {
|
||||
return s.startsWith(start);
|
||||
}
|
||||
|
||||
static substring(s:string, start:int, end:int = null) {
|
||||
return s.substring(start, end === null ? undefined: end);
|
||||
}
|
||||
|
||||
static replaceAllMapped(s:string, from:RegExp, cb:Function): string {
|
||||
return s.replace(from, function(...matches) {
|
||||
// Remove offset & string from the result array
|
||||
matches.splice(-2, 2);
|
||||
// The callback receives match, p1, ..., pn
|
||||
return cb(matches);
|
||||
});
|
||||
}
|
||||
|
||||
static contains(s:string, substr:string): boolean {
|
||||
return s.indexOf(substr) != -1;
|
||||
}
|
||||
}
|
||||
|
||||
export class StringJoiner {
|
||||
constructor() {
|
||||
this.parts = [];
|
||||
}
|
||||
|
||||
add(part:string) {
|
||||
this.parts.push(part);
|
||||
}
|
||||
|
||||
toString():string {
|
||||
return this.parts.join("");
|
||||
}
|
||||
}
|
||||
|
||||
export class NumberParseError extends Error {
|
||||
constructor(message) {
|
||||
super();
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class NumberWrapper {
|
||||
static toFixed(n:number, fractionDigits:int):string {
|
||||
return n.toFixed(fractionDigits);
|
||||
}
|
||||
|
||||
static equal(a, b):boolean {
|
||||
return a === b;
|
||||
}
|
||||
|
||||
static parseIntAutoRadix(text:string):int {
|
||||
var result:int = parseInt(text);
|
||||
if (isNaN(result)) {
|
||||
throw new NumberParseError("Invalid integer literal when parsing " + text);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static parseInt(text:string, radix:int):int {
|
||||
if (radix == 10) {
|
||||
if (/^(\-|\+)?[0-9]+$/.test(text)) {
|
||||
return parseInt(text, radix);
|
||||
}
|
||||
} else if (radix == 16) {
|
||||
if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) {
|
||||
return parseInt(text, radix);
|
||||
}
|
||||
} else {
|
||||
var result:int = parseInt(text, radix);
|
||||
if (!isNaN(result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
throw new NumberParseError("Invalid integer literal when parsing " + text + " in base " + radix);
|
||||
}
|
||||
|
||||
// TODO: NaN is a valid literal but is returned by parseFloat to indicate an error.
|
||||
static parseFloat(text:string):number {
|
||||
return parseFloat(text);
|
||||
}
|
||||
|
||||
static get NaN():number {
|
||||
return NaN;
|
||||
}
|
||||
|
||||
static isNaN(value):boolean {
|
||||
return isNaN(value);
|
||||
}
|
||||
|
||||
static isInteger(value):boolean {
|
||||
return Number.isInteger(value);
|
||||
}
|
||||
}
|
||||
|
||||
export var RegExp = _global.RegExp;
|
||||
|
||||
export class RegExpWrapper {
|
||||
static create(regExpStr, flags:string = ''):RegExp {
|
||||
flags = flags.replace(/g/g, '');
|
||||
return new _global.RegExp(regExpStr, flags + 'g');
|
||||
}
|
||||
static firstMatch(regExp, input) {
|
||||
// Reset multimatch regex state
|
||||
regExp.lastIndex = 0;
|
||||
return regExp.exec(input);
|
||||
}
|
||||
static matcher(regExp, input) {
|
||||
// Reset regex state for the case
|
||||
// someone did not loop over all matches
|
||||
// last time.
|
||||
regExp.lastIndex = 0;
|
||||
return {
|
||||
re: regExp,
|
||||
input: input
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class RegExpMatcherWrapper {
|
||||
static next(matcher) {
|
||||
return matcher.re.exec(matcher.input);
|
||||
}
|
||||
}
|
||||
|
||||
export class FunctionWrapper {
|
||||
static apply(fn:Function, posArgs) {
|
||||
return fn.apply(null, posArgs);
|
||||
}
|
||||
}
|
||||
|
||||
// No subclass so that we preserve error stack.
|
||||
export var BaseException = Error;
|
||||
|
||||
// JS has NaN !== NaN
|
||||
export function looseIdentical(a, b):boolean {
|
||||
return a === b ||
|
||||
typeof a === "number" && typeof b === "number" && isNaN(a) && isNaN(b);
|
||||
}
|
||||
|
||||
// JS considers NaN is the same as NaN for map Key (while NaN !== NaN otherwise)
|
||||
// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
|
||||
export function getMapKey(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
export function normalizeBlank(obj) {
|
||||
return isBlank(obj) ? null : obj;
|
||||
}
|
||||
|
||||
export function isJsObject(o):boolean {
|
||||
return o !== null && (typeof o === "function" || typeof o === "object");
|
||||
}
|
||||
|
||||
export function assertionsEnabled():boolean {
|
||||
return assertionsEnabled_;
|
||||
}
|
||||
|
||||
export function print(obj) {
|
||||
if (obj instanceof Error) {
|
||||
console.log(obj.stack);
|
||||
} else {
|
||||
console.log(obj);
|
||||
}
|
||||
}
|
||||
|
||||
// Can't be all uppercase as our transpiler would think it is a special directive...
|
||||
export var Json = _global.JSON;
|
||||
|
||||
export class DateWrapper {
|
||||
static fromMillis(ms) {
|
||||
return new Date(ms);
|
||||
}
|
||||
static toMillis(date:Date) {
|
||||
return date.getTime();
|
||||
}
|
||||
static now() {
|
||||
return new Date();
|
||||
}
|
||||
static toJson(date) {
|
||||
return date.toJSON();
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
import {global} from 'angular2/src/facade/lang';
|
||||
|
||||
export var Math = global.Math;
|
||||
export var NaN = global.NaN;
|
|
@ -1,7 +0,0 @@
|
|||
import {Type, isPresent} from 'angular2/src/facade/lang';
|
||||
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {Reflector} from './reflector';
|
||||
export {Reflector} from './reflector';
|
||||
import {ReflectionCapabilities} from './reflection_capabilities';
|
||||
|
||||
export var reflector = new Reflector(new ReflectionCapabilities());
|
|
@ -1,96 +0,0 @@
|
|||
import {Type, isPresent} from 'angular2/src/facade/lang';
|
||||
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {GetterFn, SetterFn, MethodFn} from './types';
|
||||
|
||||
export class ReflectionCapabilities {
|
||||
factory(type:Type):Function {
|
||||
switch (type.length) {
|
||||
case 0:
|
||||
return function(){return new type();};
|
||||
case 1:
|
||||
return function(a1){return new type(a1);};
|
||||
case 2:
|
||||
return function(a1, a2){return new type(a1, a2);};
|
||||
case 3:
|
||||
return function(a1, a2, a3){return new type(a1, a2, a3);};
|
||||
case 4:
|
||||
return function(a1, a2, a3, a4){return new type(a1, a2, a3, a4);};
|
||||
case 5:
|
||||
return function(a1, a2, a3, a4, a5){return new type(a1, a2, a3, a4, a5);};
|
||||
case 6:
|
||||
return function(a1, a2, a3, a4, a5, a6){return new type(a1, a2, a3, a4, a5, a6);};
|
||||
case 7:
|
||||
return function(a1, a2, a3, a4, a5, a6, a7){return new type(a1, a2, a3, a4, a5, a6, a7);};
|
||||
case 8:
|
||||
return function(a1, a2, a3, a4, a5, a6, a7, a8){return new type(a1, a2, a3, a4, a5, a6, a7, a8);};
|
||||
case 9:
|
||||
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9){return new type(a1, a2, a3, a4, a5, a6, a7, a8, a9);};
|
||||
case 10:
|
||||
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10){return new type(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);};
|
||||
};
|
||||
|
||||
throw new Error("Factory cannot take more than 10 arguments");
|
||||
}
|
||||
|
||||
parameters(typeOfFunc):List<List> {
|
||||
// Prefer the direct API.
|
||||
if (isPresent(typeOfFunc.parameters)) {
|
||||
return typeOfFunc.parameters;
|
||||
}
|
||||
if (isPresent(window.Reflect) && isPresent(window.Reflect.getMetadata)) {
|
||||
var paramAnnotations = window.Reflect.getMetadata('parameters', typeOfFunc);
|
||||
var paramTypes = window.Reflect.getMetadata('design:paramtypes', typeOfFunc);
|
||||
if (isPresent(paramTypes) || isPresent(paramAnnotations)) {
|
||||
return this._zipTypesAndAnnotaions(paramTypes, paramAnnotations);
|
||||
}
|
||||
}
|
||||
return ListWrapper.createFixedSize(typeOfFunc.length);
|
||||
}
|
||||
|
||||
|
||||
_zipTypesAndAnnotaions(paramTypes, paramAnnotations) {
|
||||
var result = ListWrapper.createFixedSize(paramTypes.length);
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
// TS outputs Object for parameters without types, while Traceur omits
|
||||
// the annotations. For now we preserve the Traceur behavior to aid
|
||||
// migration, but this can be revisited.
|
||||
if (paramTypes[i] != Object) {
|
||||
result[i] = [paramTypes[i]];
|
||||
} else {
|
||||
result[i] = [];
|
||||
}
|
||||
if (isPresent(paramAnnotations[i])) {
|
||||
result[i] = result[i].concat(paramAnnotations[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
annotations(typeOfFunc):List {
|
||||
// Prefer the direct API.
|
||||
if (isPresent(typeOfFunc.annotations)) {
|
||||
return typeOfFunc.annotations;
|
||||
}
|
||||
if (isPresent(window.Reflect) && isPresent(window.Reflect.getMetadata)) {
|
||||
var annotations = window.Reflect.getMetadata('annotations', typeOfFunc);
|
||||
if (isPresent(annotations)) return annotations;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
getter(name:string):GetterFn {
|
||||
return new Function('o', 'return o.' + name + ';');
|
||||
}
|
||||
|
||||
setter(name:string):SetterFn {
|
||||
return new Function('o', 'v', 'return o.' + name + ' = v;');
|
||||
}
|
||||
|
||||
method(name:string):MethodFn {
|
||||
var method = `o.${name}`;
|
||||
return new Function('o', 'args',
|
||||
`if (!${method}) throw new Error('"${name}" is undefined');` +
|
||||
`return ${method}.apply(o, args);`);
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
import {Type, isPresent, stringify, BaseException} from 'angular2/src/facade/lang';
|
||||
import {List, ListWrapper, Map, MapWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {SetterFn, GetterFn, MethodFn} from './types';
|
||||
export {SetterFn, GetterFn, MethodFn} from './types';
|
||||
|
||||
export class Reflector {
|
||||
_typeInfo:Map;
|
||||
_getters:Map;
|
||||
_setters:Map;
|
||||
_methods:Map;
|
||||
reflectionCapabilities:any;
|
||||
|
||||
constructor(reflectionCapabilities) {
|
||||
this._typeInfo = MapWrapper.create();
|
||||
this._getters = MapWrapper.create();
|
||||
this._setters = MapWrapper.create();
|
||||
this._methods = MapWrapper.create();
|
||||
this.reflectionCapabilities = reflectionCapabilities;
|
||||
}
|
||||
|
||||
registerType(type, typeInfo){
|
||||
MapWrapper.set(this._typeInfo, type, typeInfo);
|
||||
}
|
||||
|
||||
registerGetters(getters){
|
||||
_mergeMaps(this._getters, getters);
|
||||
}
|
||||
|
||||
registerSetters(setters){
|
||||
_mergeMaps(this._setters, setters);
|
||||
}
|
||||
|
||||
registerMethods(methods){
|
||||
_mergeMaps(this._methods, methods);
|
||||
}
|
||||
|
||||
factory(type:Type):Function {
|
||||
if(MapWrapper.contains(this._typeInfo, type)) {
|
||||
return MapWrapper.get(this._typeInfo, type)["factory"];
|
||||
} else {
|
||||
return this.reflectionCapabilities.factory(type);
|
||||
}
|
||||
}
|
||||
|
||||
parameters(typeOfFunc):List {
|
||||
if(MapWrapper.contains(this._typeInfo, typeOfFunc)) {
|
||||
return MapWrapper.get(this._typeInfo, typeOfFunc)["parameters"];
|
||||
} else {
|
||||
return this.reflectionCapabilities.parameters(typeOfFunc);
|
||||
}
|
||||
}
|
||||
|
||||
annotations(typeOfFunc):List {
|
||||
if(MapWrapper.contains(this._typeInfo, typeOfFunc)) {
|
||||
return MapWrapper.get(this._typeInfo, typeOfFunc)["annotations"];
|
||||
} else {
|
||||
return this.reflectionCapabilities.annotations(typeOfFunc);
|
||||
}
|
||||
}
|
||||
|
||||
getter(name:string):GetterFn {
|
||||
if(MapWrapper.contains(this._getters, name)) {
|
||||
return MapWrapper.get(this._getters, name);
|
||||
} else {
|
||||
return this.reflectionCapabilities.getter(name);
|
||||
}
|
||||
}
|
||||
|
||||
setter(name:string):SetterFn {
|
||||
if(MapWrapper.contains(this._setters, name)) {
|
||||
return MapWrapper.get(this._setters, name);
|
||||
} else {
|
||||
return this.reflectionCapabilities.setter(name);
|
||||
}
|
||||
}
|
||||
|
||||
method(name:string):MethodFn {
|
||||
if(MapWrapper.contains(this._methods, name)) {
|
||||
return MapWrapper.get(this._methods, name);
|
||||
} else {
|
||||
return this.reflectionCapabilities.method(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _mergeMaps(target:Map, config) {
|
||||
StringMapWrapper.forEach(config, (v, k) => MapWrapper.set(target, k, v));
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
export var SetterFn = Function;
|
||||
export var GetterFn = Function;
|
||||
export var MethodFn = Function;
|
|
@ -518,7 +518,7 @@ class DirectiveWithBind {}
|
|||
|
||||
@Directive()
|
||||
class DirectiveWithAttributes {
|
||||
constructor(@Attribute('someAttr') someAttr:string) {}
|
||||
constructor(@Attribute('someAttr') someAttr:String) {}
|
||||
}
|
||||
|
||||
@proxy
|
||||
|
|
|
@ -100,7 +100,7 @@ class NeedsAttribute {
|
|||
typeAttribute;
|
||||
titleAttribute;
|
||||
fooAttribute;
|
||||
constructor(@Attribute('type') typeAttribute: string, @Attribute('title') titleAttribute: string, @Attribute('foo') fooAttribute: string) {
|
||||
constructor(@Attribute('type') typeAttribute: String, @Attribute('title') titleAttribute: String, @Attribute('foo') fooAttribute: String) {
|
||||
this.typeAttribute = typeAttribute;
|
||||
this.titleAttribute = titleAttribute;
|
||||
this.fooAttribute = fooAttribute;
|
||||
|
|
|
@ -1209,7 +1209,7 @@ class NeedsAttribute {
|
|||
typeAttribute;
|
||||
titleAttribute;
|
||||
fooAttribute;
|
||||
constructor(@Attribute('type') typeAttribute: string, @Attribute('title') titleAttribute: string, @Attribute('foo') fooAttribute: string) {
|
||||
constructor(@Attribute('type') typeAttribute: String, @Attribute('title') titleAttribute: String, @Attribute('foo') fooAttribute: String) {
|
||||
this.typeAttribute = typeAttribute;
|
||||
this.titleAttribute = titleAttribute;
|
||||
this.fooAttribute = fooAttribute;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// Note: `assert` gets automatically included by traceur!
|
||||
|
||||
export function main() {
|
||||
return;
|
||||
|
||||
describe('prettyPrint', () => {
|
||||
class Type {};
|
||||
|
|
|
@ -17,7 +17,7 @@ System.paths = {
|
|||
'benchpress/*': 'dist/js/dev/es5/benchpress/*.js',
|
||||
'angular2/*': 'dist/js/dev/es5/angular2/*.js',
|
||||
'rtts_assert/*': 'dist/js/dev/es5/rtts_assert/*.js',
|
||||
'rx/*': 'node_modules/rx/*.js'
|
||||
'rx': 'node_modules/rx/dist/rx.js'
|
||||
};
|
||||
|
||||
// Import all the specs, execute their `main()` method and kick off Karma (Jasmine).
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<script src="system.src.js" type="text/javascript"></script>
|
||||
<script src="extension-register.js" type="text/javascript"></script>
|
||||
<script src="extension-cjs.js" type="text/javascript"></script>
|
||||
<script src="rx.all.js" type="text/javascript"></script>
|
||||
<script src="Reflect.js" type="text/javascript"></script>
|
||||
<script src="runtime_paths.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">System.import('@@FILENAME_NO_EXT').then(function(m) { m.main(); }, console.error.bind(console))</script>
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
<script src="system.src.js" type="text/javascript"></script>
|
||||
<script src="extension-register.js" type="text/javascript"></script>
|
||||
<script src="extension-cjs.js" type="text/javascript"></script>
|
||||
<script src="rx.all.js" type="text/javascript"></script>
|
||||
<script src="Reflect.js" type="text/javascript"></script>
|
||||
<script src="runtime_paths.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">System.import('@@FILENAME_NO_EXT').then(function(m) { m.main(); }, console.error.bind(console))</script>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
<script src="system.src.js" type="text/javascript"></script>
|
||||
<script src="extension-register.js" type="text/javascript"></script>
|
||||
<script src="extension-cjs.js" type="text/javascript"></script>
|
||||
<script src="rx.all.js" type="text/javascript"></script>
|
||||
<script src="Reflect.js" type="text/javascript"></script>
|
||||
<script src="runtime_paths.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">System.import('@@FILENAME_NO_EXT').then(function(m) { m.main(); }, console.error.bind(console))</script>
|
||||
|
|
|
@ -10,6 +10,7 @@ var replace = require('broccoli-replace');
|
|||
var stew = require('broccoli-stew');
|
||||
var ts2dart = require('../broccoli-ts2dart');
|
||||
var traceurCompiler = require('../traceur');
|
||||
var TypescriptCompiler = require('../typescript');
|
||||
|
||||
|
||||
var projectRootDir = path.normalize(path.join(__dirname, '..', '..', '..', '..'));
|
||||
|
@ -20,19 +21,35 @@ module.exports = function makeBrowserTree(options, destinationPath) {
|
|||
'modules',
|
||||
{include: ['**/**'], exclude: ['**/*.cjs', 'benchmarks/e2e_test/**'], destDir: '/'});
|
||||
|
||||
// Use Traceur to transpile original sources to ES6
|
||||
var es6Tree = traceurCompiler(modulesTree, '.es6', '.map', {
|
||||
// Use Traceur to transpile *.js sources to ES6
|
||||
var traceurTree = traceurCompiler(modulesTree, '.es6', '.map', {
|
||||
sourceMaps: true,
|
||||
annotations: true, // parse annotations
|
||||
types: true, // parse types
|
||||
script: false, // parse as a module
|
||||
memberVariables: true, // parse class fields
|
||||
modules: 'instantiate',
|
||||
typeAssertionModule: 'rtts_assert/rtts_assert',
|
||||
typeAssertions: options.typeAssertions,
|
||||
// typeAssertionModule: 'rtts_assert/rtts_assert',
|
||||
// typeAssertions: options.typeAssertions,
|
||||
outputLanguage: 'es6'
|
||||
});
|
||||
|
||||
// Use TypeScript to transpile the *.ts files to ES6
|
||||
// We don't care about errors: we let the TypeScript compilation to ES5
|
||||
// in node_tree.ts do the type-checking.
|
||||
var typescriptTree = new TypescriptCompiler(modulesTree, {
|
||||
target: 'ES6',
|
||||
sourceMap: true,
|
||||
mapRoot: '', /* force sourcemaps to use relative path */
|
||||
allowNonTsExtensions: false,
|
||||
typescript: require('typescript'),
|
||||
noEmitOnError: false,
|
||||
emitDecoratorMetadata: true,
|
||||
outDir: 'angular2'
|
||||
});
|
||||
typescriptTree = stew.rename(typescriptTree, '.js', '.es6');
|
||||
|
||||
var es6Tree = mergeTrees([traceurTree, typescriptTree]);
|
||||
|
||||
// Call Traceur again to lower the ES6 build tree to ES5
|
||||
var es5Tree =
|
||||
|
@ -53,7 +70,7 @@ module.exports = function makeBrowserTree(options, destinationPath) {
|
|||
'node_modules/systemjs/dist/system.src.js',
|
||||
'node_modules/systemjs/lib/extension-register.js',
|
||||
'node_modules/systemjs/lib/extension-cjs.js',
|
||||
'node_modules/rx/dist/rx.all.js',
|
||||
'node_modules/rx/dist/rx.js',
|
||||
'node_modules/reflect-metadata/Reflect.js',
|
||||
'tools/build/snippets/runtime_paths.js',
|
||||
path.relative(projectRootDir, traceurCompiler.RUNTIME_PATH)
|
||||
|
|
|
@ -98,17 +98,14 @@ module.exports = function makeNodeTree(destinationPath) {
|
|||
target: 'ES5',
|
||||
sourceMap: true,
|
||||
mapRoot: '', /* force sourcemaps to use relative path */
|
||||
module: /*system.js*/ 'commonjs',
|
||||
module: 'commonjs',
|
||||
allowNonTsExtensions: false,
|
||||
typescript: require('typescript'),
|
||||
// declarationFiles: true,
|
||||
noEmitOnError: true,
|
||||
outDir: 'angular2'
|
||||
});
|
||||
|
||||
// For now, we just overwrite the Traceur-compiled files with their Typescript equivalent
|
||||
nodeTree = mergeTrees([nodeTree, typescriptTree], { overwrite: true });
|
||||
nodeTree = mergeTrees([nodeTree, docs, packageJsons]);
|
||||
nodeTree = mergeTrees([nodeTree, typescriptTree, docs, packageJsons]);
|
||||
|
||||
// TODO(iminar): tree differ seems to have issues with trees created by mergeTrees, investigate!
|
||||
// ENOENT error is thrown while doing fs.readdirSync on inputRoot
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
System.paths = {
|
||||
'*': '/*.js',
|
||||
'rx/dist/*': '*.js'
|
||||
'rx': 'rx.js'
|
||||
};
|
||||
register(System);
|
||||
cjs(System);
|
||||
|
|
Loading…
Reference in New Issue