fix: make sure that Zone does not show up in angular2.d.ts
Closes #7655
This commit is contained in:
		
							parent
							
								
									048bd280dd
								
							
						
					
					
						commit
						d4e9b55fb6
					
				| @ -988,7 +988,7 @@ gulp.task('test.typings', | |||||||
|           ['!pre.test.typings.layoutNodeModule', '!pre.test.typings.copyTypingsSpec'], function() { |           ['!pre.test.typings.layoutNodeModule', '!pre.test.typings.copyTypingsSpec'], function() { | ||||||
|             var tsc = require('gulp-typescript'); |             var tsc = require('gulp-typescript'); | ||||||
| 
 | 
 | ||||||
|             return gulp.src([tmpdir + '/*.ts', 'node_modules/zone.js/dist/zone.js.d.ts']) |             return gulp.src([tmpdir + '/*.ts']) | ||||||
|                 .pipe(tsc({ |                 .pipe(tsc({ | ||||||
|                   target: 'ES6', |                   target: 'ES6', | ||||||
|                   module: 'commonjs', |                   module: 'commonjs', | ||||||
|  | |||||||
| @ -8,13 +8,12 @@ export class NgZoneError { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| export class NgZoneImpl implements ZoneSpec { | export class NgZoneImpl { | ||||||
|   static isInAngularZone(): boolean { return Zone.current.get('isAngularZone') === true; } |   static isInAngularZone(): boolean { return Zone.current.get('isAngularZone') === true; } | ||||||
| 
 | 
 | ||||||
|   public name: string = 'angular'; |   /** @internal */ | ||||||
|   public properties: {[k: string]: string} = <any>{'isAngularZone': true}; |  | ||||||
| 
 |  | ||||||
|   private outer: Zone; |   private outer: Zone; | ||||||
|  |   /** @internal */ | ||||||
|   private inner: Zone; |   private inner: Zone; | ||||||
| 
 | 
 | ||||||
|   private onEnter: () => void; |   private onEnter: () => void; | ||||||
| @ -37,7 +36,7 @@ export class NgZoneImpl implements ZoneSpec { | |||||||
|     this.setMacrotask = setMacrotask; |     this.setMacrotask = setMacrotask; | ||||||
|     this.onError = onError; |     this.onError = onError; | ||||||
| 
 | 
 | ||||||
|     if (global.Zone) { |     if (Zone) { | ||||||
|       this.outer = this.inner = Zone.current; |       this.outer = this.inner = Zone.current; | ||||||
|       if (Zone['wtfZoneSpec']) { |       if (Zone['wtfZoneSpec']) { | ||||||
|         this.inner = this.inner.fork(Zone['wtfZoneSpec']); |         this.inner = this.inner.fork(Zone['wtfZoneSpec']); | ||||||
| @ -45,52 +44,56 @@ export class NgZoneImpl implements ZoneSpec { | |||||||
|       if (trace) { |       if (trace) { | ||||||
|         this.inner = this.inner.fork(Zone['longStackTraceZoneSpec']); |         this.inner = this.inner.fork(Zone['longStackTraceZoneSpec']); | ||||||
|       } |       } | ||||||
|       this.inner = this.inner.fork(this); |       this.inner = this.inner.fork({ | ||||||
|  |         name: 'angular', | ||||||
|  |         properties:<any>{'isAngularZone': true}, | ||||||
|  |         onInvokeTask: (delegate: ZoneDelegate, current: Zone, target: Zone, task: Task, | ||||||
|  |                        applyThis: any, applyArgs: any): any => { | ||||||
|  |           try { | ||||||
|  |             this.onEnter(); | ||||||
|  |             return delegate.invokeTask(target, task, applyThis, applyArgs); | ||||||
|  |           } finally { | ||||||
|  |             this.onLeave(); | ||||||
|  |           } | ||||||
|  |         }, | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         onInvoke: (delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, | ||||||
|  |                    applyThis: any, applyArgs: any[], source: string): any => { | ||||||
|  |           try { | ||||||
|  |             this.onEnter(); | ||||||
|  |             return delegate.invoke(target, callback, applyThis, applyArgs, source); | ||||||
|  |           } finally { | ||||||
|  |             this.onLeave(); | ||||||
|  |           } | ||||||
|  |         }, | ||||||
|  | 
 | ||||||
|  |         onHasTask: | ||||||
|  |             (delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) => { | ||||||
|  |               delegate.hasTask(target, hasTaskState); | ||||||
|  |               if (current == target) { | ||||||
|  |                 // We are only interested in hasTask events which originate from our zone
 | ||||||
|  |                 // (A child hasTask event is not interesting to us)
 | ||||||
|  |                 if (hasTaskState.change == 'microTask') { | ||||||
|  |                   this.setMicrotask(hasTaskState.microTask); | ||||||
|  |                 } else if (hasTaskState.change == 'macroTask') { | ||||||
|  |                   this.setMacrotask(hasTaskState.macroTask); | ||||||
|  |                 } | ||||||
|  |               } | ||||||
|  |             }, | ||||||
|  | 
 | ||||||
|  |         onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any): | ||||||
|  |                            boolean => { | ||||||
|  |                              delegate.handleError(target, error); | ||||||
|  |                              this.onError(new NgZoneError(error, error.stack)); | ||||||
|  |                              return false; | ||||||
|  |                            } | ||||||
|  |       }); | ||||||
|     } else { |     } else { | ||||||
|       throw new Error('Angular2 needs to be run with Zone.js polyfill.'); |       throw new Error('Angular2 needs to be run with Zone.js polyfill.'); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   onInvokeTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task, applyThis: any, |  | ||||||
|                applyArgs: any): any { |  | ||||||
|     try { |  | ||||||
|       this.onEnter(); |  | ||||||
|       return delegate.invokeTask(target, task, applyThis, applyArgs); |  | ||||||
|     } finally { |  | ||||||
|       this.onLeave(); |  | ||||||
|     } |  | ||||||
|   }; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|   onInvoke(delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, applyThis: any, |  | ||||||
|            applyArgs: any[], source: string): any { |  | ||||||
|     try { |  | ||||||
|       this.onEnter(); |  | ||||||
|       return delegate.invoke(target, callback, applyThis, applyArgs, source); |  | ||||||
|     } finally { |  | ||||||
|       this.onLeave(); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) { |  | ||||||
|     delegate.hasTask(target, hasTaskState); |  | ||||||
|     if (current == target) { |  | ||||||
|       // We are only interested in hasTask events which originate from our zone
 |  | ||||||
|       // (A child hasTask event is not interesting to us)
 |  | ||||||
|       if (hasTaskState.change == 'microTask') { |  | ||||||
|         this.setMicrotask(hasTaskState.microTask); |  | ||||||
|       } else if (hasTaskState.change == 'macroTask') { |  | ||||||
|         this.setMacrotask(hasTaskState.macroTask); |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   onHandleError(delegate: ZoneDelegate, current: Zone, target: Zone, error: any): boolean { |  | ||||||
|     delegate.handleError(target, error); |  | ||||||
|     this.onError(new NgZoneError(error, error.stack)); |  | ||||||
|     return false; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   runInner(fn: () => any): any { return this.inner.runGuarded(fn); }; |   runInner(fn: () => any): any { return this.inner.runGuarded(fn); }; | ||||||
|   runOuter(fn: () => any): any { return this.outer.run(fn); }; |   runOuter(fn: () => any): any { return this.outer.run(fn); }; | ||||||
| } | } | ||||||
|  | |||||||
| @ -9,7 +9,6 @@ export interface BrowserNodeGlobal { | |||||||
|   Math: any;  // typeof Math;
 |   Math: any;  // typeof Math;
 | ||||||
|   assert(condition: any): void; |   assert(condition: any): void; | ||||||
|   Reflect: any; |   Reflect: any; | ||||||
|   Zone: typeof Zone; |  | ||||||
|   getAngularTestability: Function; |   getAngularTestability: Function; | ||||||
|   getAllAngularTestabilities: Function; |   getAllAngularTestabilities: Function; | ||||||
|   getAllAngularRootElements: Function; |   getAllAngularRootElements: Function; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user