zone_externs.js 11 KB

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