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

Function initZone

packages/zone.js/lib/zone-impl.ts:774–1640  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

772}
773
774export function initZone(): ZoneType {
775 const performance: {mark(name: string): void; measure(name: string, label: string): void} =
776 global['performance'];
777 function mark(name: string) {
778 performance && performance['mark'] && performance['mark'](name);
779 }
780 function performanceMeasure(name: string, label: string) {
781 performance && performance['measure'] && performance['measure'](name, label);
782 }
783 mark('Zone');
784
785 class ZoneImpl implements AmbientZone {
786 static __symbol__: (name: string) => string = __symbol__;
787
788 static assertZonePatched() {
789 if (global['Promise'] !== patches['ZoneAwarePromise']) {
790 throw new Error(
791 'Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' +
792 'has been overwritten.\n' +
793 'Most likely cause is that a Promise polyfill has been loaded ' +
794 'after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. ' +
795 'If you must load one, do so before loading zone.js.)',
796 );
797 }
798 }
799
800 static get root(): AmbientZone {
801 let zone = ZoneImpl.current;
802 while (zone.parent) {
803 zone = zone.parent;
804 }
805 return zone;
806 }
807
808 static get current(): AmbientZone {
809 return _currentZoneFrame.zone;
810 }
811
812 static get currentTask(): Task | null {
813 return _currentTask;
814 }
815
816 static __load_patch(name: string, fn: PatchFn, ignoreDuplicate = false): void {
817 if (Object.hasOwn(patches, name)) {
818 // `checkDuplicate` option is defined from global variable
819 // so it works for all modules.
820 // `ignoreDuplicate` can work for the specified module
821 const checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true;
822 if (!ignoreDuplicate && checkDuplicate) {
823 throw Error('Already loaded patch: ' + name);
824 }
825 } else if (!global['__Zone_disable_' + name]) {
826 const perfName = 'Zone:' + name;
827 mark(perfName);
828 patches[name] = fn(global, ZoneImpl, _api);
829 performanceMeasure(perfName, perfName);
830 }
831 }

Callers 1

loadZoneFunction · 0.90

Calls 8

__symbol__Function · 0.85
performanceMeasureFunction · 0.85
markFunction · 0.70
hasTaskMethod · 0.65
scheduleTaskMethod · 0.65
invokeTaskMethod · 0.65
cancelTaskMethod · 0.65
createMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…