zone_externs.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. /**
  9. * @fileoverview Externs for zone.js
  10. * @see https://github.com/angular/zone.js
  11. * @externs
  12. */
  13. /**
  14. * @interface
  15. */
  16. var Zone = function() {};
  17. /**
  18. * @type {!Zone} The parent Zone.
  19. */
  20. Zone.prototype.parent;
  21. /**
  22. * @type {!string} The Zone name (useful for debugging)
  23. */
  24. Zone.prototype.name;
  25. Zone.assertZonePatched = function() {};
  26. Zone.__symbol__ = function(name) {};
  27. Zone.__load_patch = function(name, fn) {};
  28. /**
  29. * @type {!Zone} Returns the current [Zone]. Returns the current zone. The only way to change
  30. * the current zone is by invoking a run() method, which will update the current zone for the
  31. * duration of the run method callback.
  32. */
  33. Zone.current;
  34. /**
  35. * @type {Task} The task associated with the current execution.
  36. */
  37. Zone.currentTask;
  38. /**
  39. * @type {!Zone} Return the root zone.
  40. */
  41. Zone.root;
  42. /**
  43. * Returns a value associated with the `key`.
  44. *
  45. * If the current zone does not have a key, the request is delegated to the parent zone. Use
  46. * [ZoneSpec.properties] to configure the set of properties associated with the current zone.
  47. *
  48. * @param {!string} key The key to retrieve.
  49. * @returns {?} The value for the key, or `undefined` if not found.
  50. */
  51. Zone.prototype.get = function(key) {};
  52. /**
  53. * Returns a Zone which defines a `key`.
  54. *
  55. * Recursively search the parent Zone until a Zone which has a property `key` is found.
  56. *
  57. * @param {!string} key The key to use for identification of the returned zone.
  58. * @returns {?Zone} The Zone which defines the `key`, `null` if not found.
  59. */
  60. Zone.prototype.getZoneWith = function(key) {};
  61. /**
  62. * Used to create a child zone.
  63. *
  64. * @param {!ZoneSpec} zoneSpec A set of rules which the child zone should follow.
  65. * @returns {!Zone} A new child zone.
  66. */
  67. Zone.prototype.fork = function(zoneSpec) {};
  68. /**
  69. * Wraps a callback function in a new function which will properly restore the current zone upon
  70. * invocation.
  71. *
  72. * The wrapped function will properly forward `this` as well as `arguments` to the `callback`.
  73. *
  74. * Before the function is wrapped the zone can intercept the `callback` by declaring
  75. * [ZoneSpec.onIntercept].
  76. *
  77. * @param {!Function} callback the function which will be wrapped in the zone.
  78. * @param {!string=} source A unique debug location of the API being wrapped.
  79. * @returns {!Function} A function which will invoke the `callback` through [Zone.runGuarded].
  80. */
  81. Zone.prototype.wrap = function(callback, source) {};
  82. /**
  83. * Invokes a function in a given zone.
  84. *
  85. * The invocation of `callback` can be intercepted be declaring [ZoneSpec.onInvoke].
  86. *
  87. * @param {!Function} callback The function to invoke.
  88. * @param {?Object=} applyThis
  89. * @param {?Array=} applyArgs
  90. * @param {?string=} source A unique debug location of the API being invoked.
  91. * @returns {*} Value from the `callback` function.
  92. */
  93. Zone.prototype.run = function(callback, applyThis, applyArgs, source) {};
  94. /**
  95. * Invokes a function in a given zone and catches any exceptions.
  96. *
  97. * Any exceptions thrown will be forwarded to [Zone.HandleError].
  98. *
  99. * The invocation of `callback` can be intercepted be declaring [ZoneSpec.onInvoke]. The
  100. * handling of exceptions can intercepted by declaring [ZoneSpec.handleError].
  101. *
  102. * @param {!Function} callback The function to invoke.
  103. * @param {?Object=} applyThis
  104. * @param {?Array=} applyArgs
  105. * @param {?string=} source A unique debug location of the API being invoked.
  106. * @returns {*} Value from the `callback` function.
  107. */
  108. Zone.prototype.runGuarded = function(callback, applyThis, applyArgs, source) {};
  109. /**
  110. * Execute the Task by restoring the [Zone.currentTask] in the Task's zone.
  111. *
  112. * @param {!Task} task
  113. * @param {?Object=} applyThis
  114. * @param {?Array=} applyArgs
  115. * @returns {*}
  116. */
  117. Zone.prototype.runTask = function(task, applyThis, applyArgs) {};
  118. /**
  119. * @param {string} source
  120. * @param {!Function} callback
  121. * @param {?TaskData=} data
  122. * @param {?function(!Task)=} customSchedule
  123. * @return {!MicroTask} microTask
  124. */
  125. Zone.prototype.scheduleMicroTask = function(source, callback, data, customSchedule) {};
  126. /**
  127. * @param {string} source
  128. * @param {!Function} callback
  129. * @param {?TaskData=} data
  130. * @param {?function(!Task)=} customSchedule
  131. * @param {?function(!Task)=} customCancel
  132. * @return {!MacroTask} macroTask
  133. */
  134. Zone.prototype.scheduleMacroTask = function(
  135. source, callback, data, customSchedule, customCancel) {};
  136. /**
  137. * @param {string} source
  138. * @param {!Function} callback
  139. * @param {?TaskData=} data
  140. * @param {?function(!Task)=} customSchedule
  141. * @param {?function(!Task)=} customCancel
  142. * @return {!EventTask} eventTask
  143. */
  144. Zone.prototype.scheduleEventTask = function(
  145. source, callback, data, customSchedule, customCancel) {};
  146. /**
  147. * @param {!Task} task
  148. * @return {!Task} task
  149. */
  150. Zone.prototype.scheduleTask = function(task) {};
  151. /**
  152. * @param {!Task} task
  153. * @return {!Task} task
  154. */
  155. Zone.prototype.cancelTask = function(task) {};
  156. /**
  157. * @record
  158. */
  159. var ZoneSpec = function() {};
  160. /**
  161. * @type {!string} The name of the zone. Useful when debugging Zones.
  162. */
  163. ZoneSpec.prototype.name;
  164. /**
  165. * @type {Object<string, Object>|undefined} A set of properties to be associated with Zone. Use
  166. * [Zone.get] to retrieve them.
  167. */
  168. ZoneSpec.prototype.properties;
  169. /**
  170. * Allows the interception of zone forking.
  171. *
  172. * When the zone is being forked, the request is forwarded to this method for interception.
  173. *
  174. * @type {
  175. * undefined|?function(ZoneDelegate, Zone, Zone, ZoneSpec): Zone
  176. * }
  177. */
  178. ZoneSpec.prototype.onFork;
  179. /**
  180. * Allows the interception of the wrapping of the callback.
  181. *
  182. * When the zone is being forked, the request is forwarded to this method for interception.
  183. *
  184. * @type {
  185. * undefined|?function(ZoneDelegate, Zone, Zone, Function, string): Function
  186. * }
  187. */
  188. ZoneSpec.prototype.onIntercept;
  189. /**
  190. * Allows interception of the callback invocation.
  191. *
  192. * @type {
  193. * undefined|?function(ZoneDelegate, Zone, Zone, Function, Object, Array, string): *
  194. * }
  195. */
  196. ZoneSpec.prototype.onInvoke;
  197. /**
  198. * Allows interception of the error handling.
  199. *
  200. * @type {
  201. * undefined|?function(ZoneDelegate, Zone, Zone, Object): boolean
  202. * }
  203. */
  204. ZoneSpec.prototype.onHandleError;
  205. /**
  206. * Allows interception of task scheduling.
  207. *
  208. * @type {
  209. * undefined|?function(ZoneDelegate, Zone, Zone, Task): Task
  210. * }
  211. */
  212. ZoneSpec.prototype.onScheduleTask;
  213. /**
  214. * Allows interception of task invoke.
  215. *
  216. * @type {
  217. * undefined|?function(ZoneDelegate, Zone, Zone, Task, Object, Array): *
  218. * }
  219. */
  220. ZoneSpec.prototype.onInvokeTask;
  221. /**
  222. * Allows interception of task cancelation.
  223. *
  224. * @type {
  225. * undefined|?function(ZoneDelegate, Zone, Zone, Task): *
  226. * }
  227. */
  228. ZoneSpec.prototype.onCancelTask;
  229. /**
  230. * Notifies of changes to the task queue empty status.
  231. *
  232. * @type {
  233. * undefined|?function(ZoneDelegate, Zone, Zone, HasTaskState)
  234. * }
  235. */
  236. ZoneSpec.prototype.onHasTask;
  237. /**
  238. * @interface
  239. */
  240. var ZoneDelegate = function() {};
  241. /**
  242. * @type {!Zone} zone
  243. */
  244. ZoneDelegate.prototype.zone;
  245. /**
  246. * @param {!Zone} targetZone the [Zone] which originally received the request.
  247. * @param {!ZoneSpec} zoneSpec the argument passed into the `fork` method.
  248. * @returns {!Zone} the new forked zone
  249. */
  250. ZoneDelegate.prototype.fork = function(targetZone, zoneSpec) {};
  251. /**
  252. * @param {!Zone} targetZone the [Zone] which originally received the request.
  253. * @param {!Function} callback the callback function passed into `wrap` function
  254. * @param {string=} source the argument passed into the `wrap` method.
  255. * @returns {!Function}
  256. */
  257. ZoneDelegate.prototype.intercept = function(targetZone, callback, source) {};
  258. /**
  259. * @param {Zone} targetZone the [Zone] which originally received the request.
  260. * @param {!Function} callback the callback which will be invoked.
  261. * @param {?Object=} applyThis the argument passed into the `run` method.
  262. * @param {?Array=} applyArgs the argument passed into the `run` method.
  263. * @param {?string=} source the argument passed into the `run` method.
  264. * @returns {*}
  265. */
  266. ZoneDelegate.prototype.invoke = function(targetZone, callback, applyThis, applyArgs, source) {};
  267. /**
  268. * @param {!Zone} targetZone the [Zone] which originally received the request.
  269. * @param {!Object} error the argument passed into the `handleError` method.
  270. * @returns {boolean}
  271. */
  272. ZoneDelegate.prototype.handleError = function(targetZone, error) {};
  273. /**
  274. * @param {!Zone} targetZone the [Zone] which originally received the request.
  275. * @param {!Task} task the argument passed into the `scheduleTask` method.
  276. * @returns {!Task} task
  277. */
  278. ZoneDelegate.prototype.scheduleTask = function(targetZone, task) {};
  279. /**
  280. * @param {!Zone} targetZone The [Zone] which originally received the request.
  281. * @param {!Task} task The argument passed into the `scheduleTask` method.
  282. * @param {?Object=} applyThis The argument passed into the `run` method.
  283. * @param {?Array=} applyArgs The argument passed into the `run` method.
  284. * @returns {*}
  285. */
  286. ZoneDelegate.prototype.invokeTask = function(targetZone, task, applyThis, applyArgs) {};
  287. /**
  288. * @param {!Zone} targetZone The [Zone] which originally received the request.
  289. * @param {!Task} task The argument passed into the `cancelTask` method.
  290. * @returns {*}
  291. */
  292. ZoneDelegate.prototype.cancelTask = function(targetZone, task) {};
  293. /**
  294. * @param {!Zone} targetZone The [Zone] which originally received the request.
  295. * @param {!HasTaskState} hasTaskState
  296. */
  297. ZoneDelegate.prototype.hasTask = function(targetZone, hasTaskState) {};
  298. /**
  299. * @interface
  300. */
  301. var HasTaskState = function() {};
  302. /**
  303. * @type {boolean}
  304. */
  305. HasTaskState.prototype.microTask;
  306. /**
  307. * @type {boolean}
  308. */
  309. HasTaskState.prototype.macroTask;
  310. /**
  311. * @type {boolean}
  312. */
  313. HasTaskState.prototype.eventTask;
  314. /**
  315. * @type {TaskType}
  316. */
  317. HasTaskState.prototype.change;
  318. /**
  319. * @interface
  320. */
  321. var TaskType = function() {};
  322. /**
  323. * @interface
  324. */
  325. var TaskState = function() {};
  326. /**
  327. * @interface
  328. */
  329. var TaskData = function() {};
  330. /**
  331. * @type {boolean|undefined}
  332. */
  333. TaskData.prototype.isPeriodic;
  334. /**
  335. * @type {number|undefined}
  336. */
  337. TaskData.prototype.delay;
  338. /**
  339. * @type {number|undefined}
  340. */
  341. TaskData.prototype.handleId;
  342. /**
  343. * @interface
  344. */
  345. var Task = function() {};
  346. /**
  347. * @type {TaskType}
  348. */
  349. Task.prototype.type;
  350. /**
  351. * @type {TaskState}
  352. */
  353. Task.prototype.state;
  354. /**
  355. * @type {string}
  356. */
  357. Task.prototype.source;
  358. /**
  359. * @type {Function}
  360. */
  361. Task.prototype.invoke;
  362. /**
  363. * @type {Function}
  364. */
  365. Task.prototype.callback;
  366. /**
  367. * @type {TaskData}
  368. */
  369. Task.prototype.data;
  370. /**
  371. * @param {!Task} task
  372. */
  373. Task.prototype.scheduleFn = function(task) {};
  374. /**
  375. * @param {!Task} task
  376. */
  377. Task.prototype.cancelFn = function(task) {};
  378. /**
  379. * @type {Zone}
  380. */
  381. Task.prototype.zone;
  382. /**
  383. * @type {number}
  384. */
  385. Task.prototype.runCount;
  386. Task.prototype.cancelScheduleRequest = function() {};
  387. /**
  388. * @interface
  389. * @extends {Task}
  390. */
  391. var MicroTask = function() {};
  392. /**
  393. * @interface
  394. * @extends {Task}
  395. */
  396. var MacroTask = function() {};
  397. /**
  398. * @interface
  399. * @extends {Task}
  400. */
  401. var EventTask = function() {};
  402. /**
  403. * @type {?string}
  404. */
  405. Error.prototype.zoneAwareStack;
  406. /**
  407. * @type {?string}
  408. */
  409. Error.prototype.originalStack;