MCPcopy Index your code
hub / github.com/angular/angular / patchWtf

Function patchWtf

packages/zone.js/lib/zone-spec/wtf.ts:18–197  ·  view source on GitHub ↗
(Zone: ZoneType)

Source from the content-addressed store, hash-verified

16 (typeof window === 'object' && window) || (typeof self === 'object' && self) || global;
17
18export function patchWtf(Zone: ZoneType): void {
19 interface Wtf {
20 trace: WtfTrace;
21 }
22 interface WtfScope {}
23 interface WtfRange {}
24 interface WtfTrace {
25 events: WtfEvents;
26 leaveScope(scope: WtfScope, returnValue?: any): void;
27 beginTimeRange(rangeType: string, action: string): WtfRange;
28 endTimeRange(range: WtfRange): void;
29 }
30 interface WtfEvents {
31 createScope(signature: string, flags?: any): WtfScopeFn;
32 createInstance(signature: string, flags?: any): WtfEventFn;
33 }
34
35 type WtfScopeFn = (...args: any[]) => WtfScope;
36 type WtfEventFn = (...args: any[]) => any;
37
38 // Detect and setup WTF.
39 let wtfTrace: WtfTrace | null = null;
40 let wtfEvents: WtfEvents | null = null;
41 const wtfEnabled: boolean = (function (): boolean {
42 const wtf: Wtf = _global['wtf'];
43 if (wtf) {
44 wtfTrace = wtf.trace;
45 if (wtfTrace) {
46 wtfEvents = wtfTrace.events;
47 return true;
48 }
49 }
50 return false;
51 })();
52
53 class WtfZoneSpec implements ZoneSpec {
54 name: string = 'WTF';
55
56 static forkInstance = wtfEnabled
57 ? wtfEvents!.createInstance('Zone:fork(ascii zone, ascii newZone)')
58 : null;
59 static scheduleInstance: {[key: string]: WtfEventFn} = {};
60 static cancelInstance: {[key: string]: WtfEventFn} = {};
61 static invokeScope: {[key: string]: WtfEventFn} = {};
62 static invokeTaskScope: {[key: string]: WtfEventFn} = {};
63
64 onFork(
65 parentZoneDelegate: ZoneDelegate,
66 currentZone: Zone,
67 targetZone: Zone,
68 zoneSpec: ZoneSpec,
69 ): Zone {
70 const retValue = parentZoneDelegate.fork(targetZone, zoneSpec);
71 WtfZoneSpec.forkInstance!(zonePathName(targetZone), retValue.name);
72 return retValue;
73 }
74
75 onInvoke(

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…