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