Skip to content

Instantly share code, notes, and snippets.

View JiaLiPassion's full-sized avatar
🏠
Working from home

JiaLiPassion JiaLiPassion

🏠
Working from home
View GitHub Profile
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("zone.js");
Zone.__load_patch("generator", (global, Zone, api) => {
const generator = function* () {};
const gen = generator();
const Generator = Object.getPrototypeOf(gen);
console.log(Generator.next);
if (!Generator[Zone.__symbol__("zonePatched")]) {
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
(function (factory) {
typeof define === 'function' && define.amd ? define(factory) :
let macroTaskCount = 0;
let microTaskCount = 0;
const zone = Zone.current.fork({
name: 'monitor',
onScheduleTask: (delegate, curr, target, task) => {
if (task.type === 'macroTask') {
macroTaskCount ++;
log('new macroTask will be scheduled: ' + macroTaskCount);
} else if (task.type === 'microTask') {
microTaskCount ++;
var originalDelegate = window.setTimeout;
window.setTimeout = function(callback, delay) {
var zone = Zone.current;
var task = {
zone: zone,
type: 'macroTask',
source: 'setTimeout',
data: {
delay: delay
},
var zone = Zone.current.fork({
name: 'hook',
onScheduleTask(delegate, current, target, task) {
console.log('schedule ZoneTask', task.type, task.source);
return delegate.scheduleTask(target, task);
},
onInvokeTask(delegate, current, target, task, applyThis, applyArgs) {
console.log('invoke ZoneTask', task.type, task.source);
return delegate.invokeTask(target, task, applyThis, applyArgs);
},
async function detect() { }
const r = detect();
const nativeThen = r.__proto__.then;
r.__proto__.then = function () {
console.log('promise.then');
return nativeThen.apply(this, arguments);
}
async function test1() {
console.log('before await');
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
@Output() highlight = new EventEmitter<string>();
click() {
this.highlight.emit('highlight');
}
var originalDelegate = window.setTimeout;
window.setTimeout = function(callback, delay) {
var zone = Zone.current;
originalDelegate.call(window, function() {
zone.run(callback);
}, delay);
}
var zoneA = Zone.current.fork({name: 'zoneA'});
function callback() {
// _currentZoneFrame: {zone: zoneA, parent: rootZoneFrame}
console.log('callback is invoked in context', Zone.current.name);
}
// _currentZoneFrame = rootZoneFrame = {zone: root, parent: null}
zoneA.run(function() {
// _currentZoneFrame: {zone: zoneA, parent: rootZoneFrame}
var currentZoneFrame = {zone: root, parent: null};
class Zone {
static get current() {
return currentZoneFrame.zone;
}
run(callback, applyThis, applyArgs) {
_currentZoneFrame = {parent: _currentZoneFrame, zone: this};
try {
return callback.apply(applyThis, applyArgs);