{"version":3,"file":"getZoneJsOriginalValue.mjs","names":[],"sources":["../../src/tools/getZoneJsOriginalValue.ts"],"sourcesContent":["import { globalObject } from './globalObject'\n\nexport interface BrowserWindowWithZoneJs {\n  Zone?: {\n    // All Zone.js versions expose the __symbol__ method, but we observed that some website have a\n    // 'Zone' global variable unrelated to Zone.js, so let's consider this method optional\n    // nonetheless.\n    __symbol__?: (name: string) => string\n  }\n}\n\n/**\n * Gets the original value for a DOM API that was potentially patched by Zone.js.\n *\n * Zone.js[1] is a library that patches a bunch of JS and DOM APIs. It usually stores the original\n * value of the patched functions/constructors/methods in a hidden property prefixed by\n * __zone_symbol__.\n *\n * In multiple occasions, we observed that Zone.js is the culprit of important issues leading to\n * browser resource exhaustion (memory leak, high CPU usage). This method is used as a workaround to\n * use the original DOM API instead of the one patched by Zone.js.\n *\n * [1]: https://github.com/angular/angular/tree/main/packages/zone.js\n */\nexport function getZoneJsOriginalValue<Target, Name extends keyof Target & string>(\n  target: Target,\n  name: Name\n): Target[Name] {\n  const browserWindow = globalObject as BrowserWindowWithZoneJs\n  let original: Target[Name] | undefined\n  if (browserWindow.Zone && typeof browserWindow.Zone.__symbol__ === 'function') {\n    original = (target as any)[browserWindow.Zone.__symbol__(name)]\n  }\n  if (!original) {\n    original = target[name]\n  }\n  return original\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,SAAgB,uBACd,QACA,MACc;CACd,MAAM,gBAAgB;CACtB,IAAI;CACJ,IAAI,cAAc,QAAQ,OAAO,cAAc,KAAK,eAAe,YACjE,WAAY,OAAe,cAAc,KAAK,WAAW,IAAI;CAE/D,IAAI,CAAC,UACH,WAAW,OAAO;CAEpB,OAAO;AACT"}